42cf5bc1 |
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 | |
42cf5bc1 |
20 | #include <AIS_InteractiveObject.hxx> |
42cf5bc1 |
21 | #include <AIS_KindOfInteractive.hxx> |
1f7f5a90 |
22 | #include <TopoDS_Shape.hxx> |
42cf5bc1 |
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 | { |
1f7f5a90 |
38 | DEFINE_STANDARD_RTTIEXT(AIS_ConnectedInteractive, AIS_InteractiveObject) |
42cf5bc1 |
39 | public: |
40 | |
42cf5bc1 |
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 |
82b856b8 |
48 | virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Object; } |
60adbe67 |
49 | |
50 | //! Returns 0 |
51 | virtual Standard_Integer Signature() const Standard_OVERRIDE { return 0; } |
42cf5bc1 |
52 | |
53 | //! Establishes the connection between the Connected |
54 | //! Interactive Object, anotherIobj, and its reference. |
7f24b768 |
55 | void Connect (const Handle(AIS_InteractiveObject)& theAnotherObj) { connect (theAnotherObj, Handle(TopLoc_Datum3D)()); } |
60adbe67 |
56 | |
42cf5bc1 |
57 | //! Establishes the connection between the Connected |
58 | //! Interactive Object, anotherIobj, and its reference. |
59 | //! Locates instance in aLocation. |
0f57ab75 |
60 | void Connect (const Handle(AIS_InteractiveObject)& theAnotherObj, |
7f24b768 |
61 | const gp_Trsf& theLocation) { connect (theAnotherObj, new TopLoc_Datum3D (theLocation)); } |
1f7f5a90 |
62 | |
63 | //! Establishes the connection between the Connected |
64 | //! Interactive Object, anotherIobj, and its reference. |
65 | //! Locates instance in aLocation. |
0f57ab75 |
66 | void Connect (const Handle(AIS_InteractiveObject)& theAnotherObj, |
7f24b768 |
67 | const Handle(TopLoc_Datum3D)& theLocation) { connect (theAnotherObj, theLocation); } |
42cf5bc1 |
68 | |
69 | //! Returns true if there is a connection established |
70 | //! between the presentation and its source reference. |
60adbe67 |
71 | Standard_Boolean HasConnection() const { return !myReference.IsNull(); } |
42cf5bc1 |
72 | |
73 | //! Returns the connection with the reference Interactive Object. |
60adbe67 |
74 | const Handle(AIS_InteractiveObject)& ConnectedTo() const { return myReference; } |
75 | |
42cf5bc1 |
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(); |
60adbe67 |
80 | |
42cf5bc1 |
81 | //! Informs the graphic context that the interactive Object |
82 | //! may be decomposed into sub-shapes for dynamic selection. |
60adbe67 |
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 | } |
42cf5bc1 |
94 | |
42cf5bc1 |
95 | protected: |
96 | |
42cf5bc1 |
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. |
decbff0d |
106 | Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr, |
107 | const Handle(Prs3d_Presentation)& theprs, |
108 | const Standard_Integer theMode) Standard_OVERRIDE; |
60adbe67 |
109 | |
b5163d2f |
110 | //! Computes the presentation according to a point of view. |
111 | Standard_EXPORT virtual void computeHLR (const Handle(Graphic3d_Camera)& theProjector, |
7f24b768 |
112 | const Handle(TopLoc_Datum3D)& theTrsf, |
b5163d2f |
113 | const Handle(Prs3d_Presentation)& thePrs) Standard_OVERRIDE; |
60adbe67 |
114 | |
42cf5bc1 |
115 | //! Generates sensitive entities by copying |
116 | //! them from myReference selection, creates and sets an entity |
117 | //! owner for this entities and adds them to theSelection |
118 | Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode) Standard_OVERRIDE; |
60adbe67 |
119 | |
42cf5bc1 |
120 | //! Generates sensitive entities by copying |
121 | //! them from myReference sub shapes selection, creates and sets an entity |
122 | //! owner for this entities and adds them to theSelection |
123 | Standard_EXPORT void computeSubShapeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode); |
60adbe67 |
124 | |
42cf5bc1 |
125 | Standard_EXPORT void updateShape (const Standard_Boolean WithLocation = Standard_True); |
60adbe67 |
126 | |
1f7f5a90 |
127 | Standard_EXPORT void connect (const Handle(AIS_InteractiveObject)& theAnotherObj, |
7f24b768 |
128 | const Handle(TopLoc_Datum3D)& theLocation); |
1f7f5a90 |
129 | |
60adbe67 |
130 | protected: |
42cf5bc1 |
131 | |
60adbe67 |
132 | Handle(AIS_InteractiveObject) myReference; |
133 | TopoDS_Shape myShape; |
42cf5bc1 |
134 | |
135 | }; |
136 | |
1f7f5a90 |
137 | DEFINE_STANDARD_HANDLE(AIS_ConnectedInteractive, AIS_InteractiveObject) |
138 | |
42cf5bc1 |
139 | #endif // _AIS_ConnectedInteractive_HeaderFile |