Commit | Line | Data |
---|---|---|
42cf5bc1 | 1 | // Created on: 1995-10-09 |
2 | // Created by: Arnaud BOUZY/Odile Olivier | |
3 | // Copyright (c) 1995-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_Trihedron_HeaderFile | |
18 | #define _AIS_Trihedron_HeaderFile | |
19 | ||
42cf5bc1 | 20 | #include <AIS_InteractiveObject.hxx> |
bc001a40 | 21 | #include <AIS_KindOfInteractive.hxx> |
22 | #include <AIS_TrihedronSelectionMode.hxx> | |
23 | #include <Graphic3d_ArrayOfTriangles.hxx> | |
42cf5bc1 | 24 | #include <PrsMgr_PresentationManager3d.hxx> |
bc001a40 | 25 | #include <Prs3d_DatumAspect.hxx> |
26 | #include <Prs3d_DatumMode.hxx> | |
27 | #include <Prs3d_DatumParts.hxx> | |
28 | #include <Prs3d_ShadingAspect.hxx> | |
29 | #include <Prs3d_LineAspect.hxx> | |
30 | #include <Prs3d_PointAspect.hxx> | |
42cf5bc1 | 31 | #include <SelectMgr_Selection.hxx> |
42cf5bc1 | 32 | #include <TColgp_Array1OfPnt.hxx> |
bc001a40 | 33 | #include <Quantity_Color.hxx> |
34 | ||
42cf5bc1 | 35 | class Geom_Axis2Placement; |
42cf5bc1 | 36 | |
37 | //! Create a selectable trihedron | |
bc001a40 | 38 | //! The trihedron includes 1 origin, 3 axes and 3 labels. |
39 | //! Default text of labels are "X", "Y", "Z". | |
40 | //! Color of origin and any axis, color of arrows and labels may be changed. | |
41 | //! Visual presentation might be shown in two, shaded and wireframe modes, wireframe by default). | |
42 | //! There are 4 modes of selection: | |
43 | //! - AIS_TrihedronSelectionMode_EntireObject to select trihedron, priority = 1 | |
44 | //! - AIS_TrihedronSelectionMode_Origin to select its origin, priority = 5 | |
45 | //! - AIS_TrihedronSelectionMode_Axes to select its axis, priority = 3 | |
46 | //! - AIS_TrihedronSelectionMode_MainPlanes to select its planes, priority = 2 | |
47 | //! | |
48 | //! Warning! | |
49 | //! For the presentation of trihedron, the default unit of length is the millimetre, | |
50 | //! and the default value for the representation of the axes is 100. | |
51 | //! If you modify these dimensions, you must temporarily recover the Drawer. | |
52 | //! From inside it, you take the aspect in which the values for length are stocked. | |
53 | //! For trihedron, this is Prs3d_Drawer_LineAspect. | |
54 | //! You change the values inside this Aspect and recalculate the presentation. | |
42cf5bc1 | 55 | class AIS_Trihedron : public AIS_InteractiveObject |
56 | { | |
1f7f5a90 | 57 | DEFINE_STANDARD_RTTIEXT(AIS_Trihedron, AIS_InteractiveObject) |
42cf5bc1 | 58 | public: |
59 | ||
42cf5bc1 | 60 | //! Initializes a trihedron entity. |
bc001a40 | 61 | Standard_EXPORT AIS_Trihedron (const Handle(Geom_Axis2Placement)& theComponent); |
62 | ||
63 | //! Sets Shading or Wireframe display mode, triangle or segment graphic group is used relatively. | |
64 | void SetDatumDisplayMode (Prs3d_DatumMode theMode) { myTrihDispMode = theMode; } | |
65 | ||
66 | //! Returns datum display mode. | |
67 | Prs3d_DatumMode DatumDisplayMode() const { return myTrihDispMode; } | |
68 | ||
42cf5bc1 | 69 | //! Returns the right-handed coordinate system set in SetComponent. |
bc001a40 | 70 | const Handle(Geom_Axis2Placement)& Component() const { return myComponent; } |
71 | ||
42cf5bc1 | 72 | //! Constructs the right-handed coordinate system aComponent. |
bc001a40 | 73 | Standard_EXPORT void SetComponent (const Handle(Geom_Axis2Placement)& theComponent); |
74 | ||
42cf5bc1 | 75 | //! Returns true if the trihedron object has a size other |
bc001a40 | 76 | //! than the default size of 100 mm. along each axis. |
77 | Standard_Boolean HasOwnSize() const { return myHasOwnSize; } | |
78 | ||
42cf5bc1 | 79 | //! Sets the size aValue for the trihedron object. |
bc001a40 | 80 | //! The default value is 100 mm. |
81 | Standard_EXPORT void SetSize (const Standard_Real theValue); | |
82 | ||
83 | //! Removes any non-default settings for size of this trihedron object. | |
84 | //! If the object has 1 color, the default size of the | |
85 | //! drawer is reproduced, otherwise DatumAspect becomes null. | |
42cf5bc1 | 86 | Standard_EXPORT void UnsetSize(); |
bc001a40 | 87 | |
42cf5bc1 | 88 | Standard_EXPORT Standard_Real Size() const; |
bc001a40 | 89 | |
90 | //! Returns true if the display mode selected, aMode, is valid for trihedron datums. | |
91 | virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE | |
92 | { | |
93 | return theMode == 0; | |
94 | } | |
1f7f5a90 | 95 | |
42cf5bc1 | 96 | //! Returns index 3, selection of the planes XOY, YOZ, XOZ. |
bc001a40 | 97 | virtual Standard_Integer Signature() const Standard_OVERRIDE { return 3; } |
98 | ||
42cf5bc1 | 99 | //! Indicates that the type of Interactive Object is datum. |
bc001a40 | 100 | virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KOI_Datum; } |
101 | ||
bc001a40 | 102 | //! Sets the color theColor for this trihedron object, it changes color of axes. |
103 | Standard_EXPORT void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE; | |
42cf5bc1 | 104 | |
bc001a40 | 105 | //! Sets color of label of trihedron axes. |
106 | Standard_EXPORT void SetTextColor (const Quantity_Color& theColor); | |
107 | ||
108 | //! Returns true if trihedron has own text color | |
109 | Standard_Boolean HasTextColor() const { return myHasOwnTextColor; } | |
110 | ||
111 | //! Returns trihedron text color | |
112 | Standard_EXPORT Quantity_Color TextColor() const; | |
113 | ||
114 | //! Sets color of arrow of trihedron axes. Used only in wireframe mode | |
115 | Standard_EXPORT void SetArrowColor (const Quantity_Color& theColor); | |
116 | ||
117 | //! Returns true if trihedron has own arrow color | |
118 | Standard_Boolean HasArrowColor() const { return myHasOwnArrowColor; } | |
119 | ||
120 | //! Returns trihedron arrow color | |
121 | Standard_EXPORT Quantity_Color ArrowColor() const; | |
122 | ||
42cf5bc1 | 123 | //! Removes the settings for color. |
bc001a40 | 124 | Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE; |
125 | ||
126 | //! Sets color of datum part: origin or some of trihedron axes. | |
127 | //! If presentation is shading mode, this color is set for both sides of facing model | |
128 | Standard_EXPORT void SetDatumPartColor (const Prs3d_DatumParts thePart, | |
129 | const Quantity_Color& theColor); | |
130 | ||
131 | //! Returns color of datum part: origin or some of trihedron axes. | |
132 | Standard_EXPORT Quantity_Color DatumPartColor (Prs3d_DatumParts thePart); | |
133 | ||
134 | //! Sets color of origin. | |
135 | //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead") | |
136 | Standard_EXPORT void SetOriginColor (const Quantity_Color& theColor); | |
137 | ||
138 | //! Sets color of x-axis. | |
139 | //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead") | |
140 | Standard_EXPORT void SetXAxisColor (const Quantity_Color& theColor); | |
141 | ||
142 | //! Sets color of y-axis. | |
143 | //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead") | |
144 | Standard_EXPORT void SetYAxisColor (const Quantity_Color& theColor); | |
145 | ||
146 | //! Sets color of z-axis. | |
147 | //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead") | |
148 | Standard_EXPORT void SetAxisColor (const Quantity_Color& theColor); | |
149 | ||
fae1ae11 ZA |
150 | //! Returns true if arrows are to be drawn |
151 | Standard_EXPORT Standard_Boolean ToDrawArrows() const; | |
152 | ||
153 | //! Sets whether to draw the arrows in visualization | |
154 | Standard_EXPORT void SetDrawArrows (const Standard_Boolean theToDraw); | |
155 | ||
bc001a40 | 156 | //! Sets priority of selection for owner of the given type |
157 | void SetSelectionPriority (Prs3d_DatumParts thePart, | |
158 | Standard_Integer thePriority) | |
159 | { | |
160 | mySelectionPriority.Bind (thePart, thePriority); | |
161 | } | |
162 | ||
163 | //! Sets priority of selection for owner of the given type | |
164 | Standard_Integer SelectionPriority (Prs3d_DatumParts thePart) | |
165 | { | |
166 | return mySelectionPriority.Find (thePart); | |
167 | } | |
168 | ||
169 | //! Sets text label for trihedron axis. Parameter thePart should be XAxis, YAxis or ZAxis | |
170 | void SetLabel (const Prs3d_DatumParts thePart, | |
171 | const TCollection_ExtendedString& thePriority) | |
172 | { | |
173 | myLabel.Bind (thePart, thePriority); | |
174 | } | |
175 | ||
176 | //! Returns text of axis. Parameter thePart should be XAxis, YAxis or ZAxis | |
177 | const TCollection_ExtendedString& Label (Prs3d_DatumParts thePart) | |
178 | { | |
179 | return myLabel.Find (thePart); | |
180 | } | |
181 | ||
182 | public: | |
183 | ||
bc001a40 | 184 | //! Method which clear all selected owners belonging |
185 | //! to this selectable object ( for fast presentation draw ). | |
186 | Standard_EXPORT virtual void ClearSelected() Standard_OVERRIDE; | |
187 | ||
188 | //! Method which draws selected owners ( for fast presentation draw ). | |
189 | Standard_EXPORT virtual void HilightSelected (const Handle(PrsMgr_PresentationManager3d)& thePM, | |
190 | const SelectMgr_SequenceOfOwner& theOwners) Standard_OVERRIDE; | |
191 | ||
192 | //! Method which hilight an owner belonging to | |
193 | //! this selectable object ( for fast presentation draw ). | |
194 | Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, | |
195 | const Handle(Prs3d_Drawer)& theStyle, | |
196 | const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE; | |
42cf5bc1 | 197 | |
42cf5bc1 | 198 | protected: |
199 | ||
bc001a40 | 200 | //! Compute trihedron presentation. |
201 | Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr, | |
202 | const Handle(Prs3d_Presentation)& thePrs, | |
203 | const Standard_Integer theMode) Standard_OVERRIDE; | |
42cf5bc1 | 204 | |
bc001a40 | 205 | //! Compute selection. |
206 | Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, | |
207 | const Standard_Integer theMode) Standard_OVERRIDE; | |
42cf5bc1 | 208 | |
bc73b006 | 209 | //! Dumps the content of me into the stream |
210 | Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE; | |
211 | ||
046a1c9d | 212 | protected: |
213 | ||
bc001a40 | 214 | //! Creates a sensitive entity for the datum part that will be used in selection owner creation. |
0ef04197 | 215 | Standard_EXPORT Handle(Select3D_SensitiveEntity) createSensitiveEntity (const Prs3d_DatumParts thePart, |
216 | const Handle(SelectMgr_EntityOwner)& theOwner) const; | |
bc001a40 | 217 | |
218 | //! Computes presentation for display mode equal 1. | |
219 | Standard_EXPORT void computePresentation (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr, | |
220 | const Handle(Prs3d_Presentation)& thePrs); | |
221 | ||
222 | //! Returns own datum aspect of trihedron, create this aspect if it was not created yet. | |
223 | Standard_EXPORT void setOwnDatumAspect(); | |
224 | ||
225 | //! Returns primitives. | |
226 | Standard_EXPORT Handle(Graphic3d_ArrayOfPrimitives) arrayOfPrimitives( | |
227 | Prs3d_DatumParts thePart) const; | |
228 | ||
229 | //! Updates graphic groups for the current datum mode | |
230 | //! Parameters of datum position and orientation | |
231 | Standard_EXPORT void updatePrimitives (const Handle(Prs3d_DatumAspect)& theAspect, | |
232 | Prs3d_DatumMode theMode, | |
233 | const gp_Pnt& theOrigin, | |
234 | const gp_Dir& theXDir, | |
235 | const gp_Dir& theYDir, | |
236 | const gp_Dir& theZDir); | |
237 | ||
bc001a40 | 238 | protected: |
42cf5bc1 | 239 | Standard_Boolean myHasOwnSize; |
240 | Standard_Boolean myHasOwnTextColor; | |
42cf5bc1 | 241 | Standard_Boolean myHasOwnArrowColor; |
bc001a40 | 242 | Standard_Boolean myHasOwnDatumAspect; |
42cf5bc1 | 243 | |
bc001a40 | 244 | Prs3d_DatumMode myTrihDispMode; |
245 | Handle(Geom_Axis2Placement) myComponent; | |
42cf5bc1 | 246 | |
bc001a40 | 247 | NCollection_DataMap<Prs3d_DatumParts, Standard_Integer> mySelectionPriority; |
248 | NCollection_DataMap<Prs3d_DatumParts, TCollection_ExtendedString> myLabel; | |
42cf5bc1 | 249 | |
bc001a40 | 250 | NCollection_DataMap<Prs3d_DatumParts, Handle(Graphic3d_Group)> myPartToGroup; |
251 | NCollection_List<Prs3d_DatumParts> mySelectedParts; | |
df8c7e3e | 252 | Handle(Graphic3d_AspectLine3d) myHiddenLineAspect; |
42cf5bc1 | 253 | |
bc001a40 | 254 | NCollection_DataMap<Prs3d_DatumParts, Handle(Graphic3d_ArrayOfPrimitives)> myPrimitives; |
255 | }; | |
42cf5bc1 | 256 | |
bc001a40 | 257 | DEFINE_STANDARD_HANDLE(AIS_Trihedron, AIS_InteractiveObject) |
42cf5bc1 | 258 | |
259 | #endif // _AIS_Trihedron_HeaderFile |