0030674: Visualization, AIS_InteractiveObject - fix accessibility of several properties
[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(Geom_Transformation)()); }
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 Geom_Transformation (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(Geom_Transformation)& 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   //! given by <aProjector>.
110   //! To be Used when the associated degenerated Presentations
111   //! have been transformed by <aTrsf> which is not a Pure
112   //! Translation. The HLR Prs can't be deducted automatically
113   //! WARNING :<aTrsf> must be applied
114   //! to the object to display before computation  !!!
115   Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTrsf, const Handle(Prs3d_Presentation)& aPresentation) Standard_OVERRIDE;
116
117   //! Computes the presentation according to a point of view
118   //! given by <aProjector>.
119   Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation) Standard_OVERRIDE;
120
121   //! Generates sensitive entities by copying
122   //! them from myReference selection, creates and sets an entity
123   //! owner for this entities and adds them to theSelection
124   Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode) Standard_OVERRIDE;
125
126   //! Generates sensitive entities by copying
127   //! them from myReference sub shapes selection, creates and sets an entity
128   //! owner for this entities and adds them to theSelection
129   Standard_EXPORT void computeSubShapeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode);
130
131   Standard_EXPORT void updateShape (const Standard_Boolean WithLocation = Standard_True);
132
133   //! Computes the presentation according to a point of view
134   //! given by <aProjector>.
135   Standard_EXPORT void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation, const TopoDS_Shape& aShape);
136
137   Standard_EXPORT void connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
138                                 const Handle(Geom_Transformation)& theLocation);
139
140 protected:
141
142   Handle(AIS_InteractiveObject) myReference;
143   TopoDS_Shape myShape;
144
145 };
146
147 DEFINE_STANDARD_HANDLE(AIS_ConnectedInteractive, AIS_InteractiveObject)
148
149 #endif // _AIS_ConnectedInteractive_HeaderFile