Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-28 09:19:14

0001 // Created on: 1997-01-08
0002 // Created by: Robert COUBLANC
0003 // Copyright (c) 1997-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _AIS_ConnectedInteractive_HeaderFile
0018 #define _AIS_ConnectedInteractive_HeaderFile
0019 
0020 #include <AIS_InteractiveObject.hxx>
0021 #include <AIS_KindOfInteractive.hxx>
0022 #include <TopoDS_Shape.hxx>
0023 
0024 //! Creates an arbitrary located instance of another Interactive Object,
0025 //! which serves as a reference.
0026 //! This allows you to use the Connected Interactive
0027 //! Object without having to recalculate presentation,
0028 //! selection or graphic structure. These are deduced
0029 //! from your reference object.
0030 //! The relation between the connected interactive object
0031 //! and its source is generally one of geometric transformation.
0032 //! AIS_ConnectedInteractive class supports selection mode 0 for any InteractiveObject and
0033 //! all standard modes if its reference based on AIS_Shape.
0034 //! Descendants may redefine ComputeSelection() though.
0035 //! Also ConnectedInteractive will handle HLR if its reference based on AIS_Shape.
0036 class AIS_ConnectedInteractive : public AIS_InteractiveObject
0037 {
0038   DEFINE_STANDARD_RTTIEXT(AIS_ConnectedInteractive, AIS_InteractiveObject)
0039 public:
0040   //! Disconnects the previous view and sets highlight
0041   //! mode to 0. This highlights the wireframe presentation
0042   //! aTypeOfPresentation3d.
0043   //! Top_AllView deactivates hidden line removal.
0044   Standard_EXPORT AIS_ConnectedInteractive(
0045     const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
0046 
0047   //! Returns KOI_Object
0048   AIS_KindOfInteractive Type() const override { return AIS_KindOfInteractive_Object; }
0049 
0050   //! Returns 0
0051   int Signature() const override { return 0; }
0052 
0053   //! Establishes the connection between the Connected
0054   //! Interactive Object, anotherIobj, and its reference.
0055   void Connect(const occ::handle<AIS_InteractiveObject>& theAnotherObj)
0056   {
0057     connect(theAnotherObj, occ::handle<TopLoc_Datum3D>());
0058   }
0059 
0060   //! Establishes the connection between the Connected
0061   //! Interactive Object, anotherIobj, and its reference.
0062   //! Locates instance in aLocation.
0063   void Connect(const occ::handle<AIS_InteractiveObject>& theAnotherObj, const gp_Trsf& theLocation)
0064   {
0065     connect(theAnotherObj, new TopLoc_Datum3D(theLocation));
0066   }
0067 
0068   //! Establishes the connection between the Connected
0069   //! Interactive Object, anotherIobj, and its reference.
0070   //! Locates instance in aLocation.
0071   void Connect(const occ::handle<AIS_InteractiveObject>& theAnotherObj,
0072                const occ::handle<TopLoc_Datum3D>&        theLocation)
0073   {
0074     connect(theAnotherObj, theLocation);
0075   }
0076 
0077   //! Returns true if there is a connection established
0078   //! between the presentation and its source reference.
0079   bool HasConnection() const { return !myReference.IsNull(); }
0080 
0081   //! Returns the connection with the reference Interactive Object.
0082   const occ::handle<AIS_InteractiveObject>& ConnectedTo() const { return myReference; }
0083 
0084   //! Clears the connection with a source reference. The
0085   //! presentation will no longer be displayed.
0086   //! Warning Must be done before deleting the presentation.
0087   Standard_EXPORT void Disconnect();
0088 
0089   //! Informs the graphic context that the interactive Object
0090   //! may be decomposed into sub-shapes for dynamic selection.
0091   bool AcceptShapeDecomposition() const override
0092   {
0093     return !myReference.IsNull() && myReference->AcceptShapeDecomposition();
0094   }
0095 
0096   //! Return true if reference presentation accepts specified display mode.
0097   bool AcceptDisplayMode(const int theMode) const override
0098   {
0099     return myReference.IsNull() || myReference->AcceptDisplayMode(theMode);
0100   }
0101 
0102 protected:
0103   //! Calculates the view aPresentation and its updates.
0104   //! The latter are managed by aPresentationManager.
0105   //! The display mode aMode is 0 by default.
0106   //! this method is redefined virtual;
0107   //! when the instance is connected to another
0108   //! InteractiveObject,this method doesn't
0109   //! compute anything, but just uses the
0110   //! presentation of this last object, with
0111   //! a transformation if there's one stored.
0112   Standard_EXPORT void Compute(const occ::handle<PrsMgr_PresentationManager>& thePrsMgr,
0113                                const occ::handle<Prs3d_Presentation>&         theprs,
0114                                const int                                      theMode) override;
0115 
0116   //! Computes the presentation according to a point of view.
0117   Standard_EXPORT void computeHLR(const occ::handle<Graphic3d_Camera>&   theProjector,
0118                                   const occ::handle<TopLoc_Datum3D>&     theTrsf,
0119                                   const occ::handle<Prs3d_Presentation>& thePrs) override;
0120 
0121   //! Generates sensitive entities by copying
0122   //! them from myReference selection, creates and sets an entity
0123   //! owner for this entities and adds them to theSelection
0124   Standard_EXPORT void ComputeSelection(const occ::handle<SelectMgr_Selection>& theSelection,
0125                                         const int                               theMode) override;
0126 
0127   //! Generates sensitive entities by copying
0128   //! them from myReference sub shapes selection, creates and sets an entity
0129   //! owner for this entities and adds them to theSelection
0130   Standard_EXPORT void computeSubShapeSelection(
0131     const occ::handle<SelectMgr_Selection>& theSelection,
0132     const int                               theMode);
0133 
0134   Standard_EXPORT void updateShape(const bool WithLocation = true);
0135 
0136   Standard_EXPORT void connect(const occ::handle<AIS_InteractiveObject>& theAnotherObj,
0137                                const occ::handle<TopLoc_Datum3D>&        theLocation);
0138 
0139 protected:
0140   occ::handle<AIS_InteractiveObject> myReference;
0141   TopoDS_Shape                       myShape;
0142 };
0143 
0144 #endif // _AIS_ConnectedInteractive_HeaderFile