0031458: Visualization - refine classes across Prs3d and StdPrs packages
[occt.git] / src / AIS / AIS_ConnectedInteractive.hxx
1 // Created on: 1997-01-08
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _AIS_ConnectedInteractive_HeaderFile
18 #define _AIS_ConnectedInteractive_HeaderFile
19
20 #include <AIS_InteractiveObject.hxx>
21 #include <AIS_KindOfInteractive.hxx>
22 #include <TopoDS_Shape.hxx>
23
24 //! Creates an arbitrary located instance of another Interactive Object,
25 //! which serves as a reference.
26 //! This allows you to use the Connected Interactive
27 //! Object without having to recalculate presentation,
28 //! selection or graphic structure. These are deduced
29 //! from your reference object.
30 //! The relation between the connected interactive object
31 //! and its source is generally one of geometric transformation.
32 //! AIS_ConnectedInteractive class supports selection mode 0 for any InteractiveObject and
33 //! all standard modes if its reference based on AIS_Shape.
34 //! Descendants may redefine ComputeSelection() though.
35 //! Also ConnectedInteractive will handle HLR if its reference based on AIS_Shape.
36 class AIS_ConnectedInteractive : public AIS_InteractiveObject
37 {
38   DEFINE_STANDARD_RTTIEXT(AIS_ConnectedInteractive, AIS_InteractiveObject)
39 public:
40
41   //! Disconnects the previous view and sets highlight
42   //! mode to 0. This highlights the wireframe presentation
43   //! aTypeOfPresentation3d.
44   //! Top_AllView deactivates hidden line removal.
45   Standard_EXPORT AIS_ConnectedInteractive(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
46   
47   //! Returns KOI_Object
48   virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KOI_Object; }
49
50   //! Returns 0
51   virtual Standard_Integer Signature() const Standard_OVERRIDE { return 0; }
52   
53   //! Establishes the connection between the Connected
54   //! Interactive Object, anotherIobj, and its reference.
55   void Connect (const Handle(AIS_InteractiveObject)& theAnotherObj) { connect (theAnotherObj, Handle(TopLoc_Datum3D)()); }
56
57   //! Establishes the connection between the Connected
58   //! Interactive Object, anotherIobj, and its reference.
59   //! Locates instance in aLocation.
60   void Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
61                 const gp_Trsf& theLocation)  { connect (theAnotherObj, new TopLoc_Datum3D (theLocation)); }
62
63   //! Establishes the connection between the Connected
64   //! Interactive Object, anotherIobj, and its reference.
65   //! Locates instance in aLocation.
66   void Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
67                 const Handle(TopLoc_Datum3D)& theLocation) { connect (theAnotherObj, theLocation); }
68
69   //! Returns true if there is a connection established
70   //! between the presentation and its source reference.
71   Standard_Boolean HasConnection() const { return !myReference.IsNull(); }
72
73   //! Returns the connection with the reference Interactive Object.
74   const Handle(AIS_InteractiveObject)& ConnectedTo() const { return myReference; }
75
76   //! Clears the connection with a source reference. The
77   //! presentation will no longer be displayed.
78   //! Warning Must be done before deleting the presentation.
79   Standard_EXPORT void Disconnect();
80
81   //! Informs the graphic context that the interactive Object
82   //! may be decomposed into sub-shapes for dynamic selection.
83   virtual Standard_Boolean AcceptShapeDecomposition() const Standard_OVERRIDE
84   {
85     return !myReference.IsNull() && myReference->AcceptShapeDecomposition();
86   }
87
88   //! Return true if reference presentation accepts specified display mode.
89   virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE
90   {
91     return myReference.IsNull()
92         || myReference->AcceptDisplayMode (theMode);
93   }
94
95 protected:
96
97   //! Calculates the view aPresentation and its updates.
98   //! The latter are managed by aPresentationManager.
99   //! The display mode aMode is 0 by default.
100   //! this method is redefined virtual;
101   //! when the instance is connected to another
102   //! InteractiveObject,this method doesn't
103   //! compute anything, but just uses the
104   //! presentation of this last object, with
105   //! a transformation if there's one stored.
106   Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode) Standard_OVERRIDE;
107
108   //! Computes the presentation according to a point of view.
109   Standard_EXPORT virtual void computeHLR (const Handle(Graphic3d_Camera)& theProjector,
110                                            const Handle(TopLoc_Datum3D)& theTrsf,
111                                            const Handle(Prs3d_Presentation)& thePrs) Standard_OVERRIDE;
112
113   //! Generates sensitive entities by copying
114   //! them from myReference selection, creates and sets an entity
115   //! owner for this entities and adds them to theSelection
116   Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode) Standard_OVERRIDE;
117
118   //! Generates sensitive entities by copying
119   //! them from myReference sub shapes selection, creates and sets an entity
120   //! owner for this entities and adds them to theSelection
121   Standard_EXPORT void computeSubShapeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode);
122
123   Standard_EXPORT void updateShape (const Standard_Boolean WithLocation = Standard_True);
124
125   Standard_EXPORT void connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
126                                 const Handle(TopLoc_Datum3D)& theLocation);
127
128 protected:
129
130   Handle(AIS_InteractiveObject) myReference;
131   TopoDS_Shape myShape;
132
133 };
134
135 DEFINE_STANDARD_HANDLE(AIS_ConnectedInteractive, AIS_InteractiveObject)
136
137 #endif // _AIS_ConnectedInteractive_HeaderFile