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 | ||
bc001a40 | 63 | //! Returns datum display mode. |
64 | Prs3d_DatumMode DatumDisplayMode() const { return myTrihDispMode; } | |
65 | ||
24f9d04c | 66 | //! Sets Shading or Wireframe display mode, triangle or segment graphic group is used relatively. |
67 | void SetDatumDisplayMode (Prs3d_DatumMode theMode) { myTrihDispMode = theMode; } | |
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 | ||
24f9d04c | 79 | //! Returns the size of trihedron object; 100.0 by DEFAULT. |
80 | Standard_EXPORT Standard_Real Size() const; | |
81 | ||
82 | //! Sets the size of trihedron object. | |
bc001a40 | 83 | Standard_EXPORT void SetSize (const Standard_Real theValue); |
84 | ||
85 | //! Removes any non-default settings for size of this trihedron object. | |
86 | //! If the object has 1 color, the default size of the | |
87 | //! drawer is reproduced, otherwise DatumAspect becomes null. | |
42cf5bc1 | 88 | Standard_EXPORT void UnsetSize(); |
bc001a40 | 89 | |
bc001a40 | 90 | //! Returns true if trihedron has own text color |
91 | Standard_Boolean HasTextColor() const { return myHasOwnTextColor; } | |
92 | ||
93 | //! Returns trihedron text color | |
94 | Standard_EXPORT Quantity_Color TextColor() const; | |
95 | ||
24f9d04c | 96 | //! Sets color of label of trihedron axes. |
97 | Standard_EXPORT void SetTextColor (const Quantity_Color& theColor); | |
bc001a40 | 98 | |
0aeb8984 | 99 | //! Sets color of label of trihedron axis. |
100 | Standard_EXPORT void SetTextColor (const Prs3d_DatumParts thePart, | |
101 | const Quantity_Color& theColor); | |
102 | ||
bc001a40 | 103 | //! Returns true if trihedron has own arrow color |
104 | Standard_Boolean HasArrowColor() const { return myHasOwnArrowColor; } | |
105 | ||
106 | //! Returns trihedron arrow color | |
107 | Standard_EXPORT Quantity_Color ArrowColor() const; | |
108 | ||
0aeb8984 | 109 | //! Sets color of arrow of trihedron axes. |
24f9d04c | 110 | Standard_EXPORT void SetArrowColor (const Quantity_Color& theColor); |
111 | ||
0aeb8984 | 112 | //! Sets color of arrow of trihedron axes. |
113 | Standard_EXPORT void SetArrowColor (const Prs3d_DatumParts thePart, | |
114 | const Quantity_Color& theColor); | |
115 | ||
24f9d04c | 116 | //! Returns color of datum part: origin or some of trihedron axes. |
117 | Standard_EXPORT Quantity_Color DatumPartColor (Prs3d_DatumParts thePart); | |
bc001a40 | 118 | |
119 | //! Sets color of datum part: origin or some of trihedron axes. | |
120 | //! If presentation is shading mode, this color is set for both sides of facing model | |
121 | Standard_EXPORT void SetDatumPartColor (const Prs3d_DatumParts thePart, | |
122 | const Quantity_Color& theColor); | |
bc001a40 | 123 | //! Sets color of origin. |
124 | //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead") | |
125 | Standard_EXPORT void SetOriginColor (const Quantity_Color& theColor); | |
126 | ||
127 | //! Sets color of x-axis. | |
128 | //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead") | |
129 | Standard_EXPORT void SetXAxisColor (const Quantity_Color& theColor); | |
130 | ||
131 | //! Sets color of y-axis. | |
132 | //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead") | |
133 | Standard_EXPORT void SetYAxisColor (const Quantity_Color& theColor); | |
134 | ||
135 | //! Sets color of z-axis. | |
136 | //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead") | |
137 | Standard_EXPORT void SetAxisColor (const Quantity_Color& theColor); | |
138 | ||
fae1ae11 ZA |
139 | //! Returns true if arrows are to be drawn |
140 | Standard_EXPORT Standard_Boolean ToDrawArrows() const; | |
141 | ||
142 | //! Sets whether to draw the arrows in visualization | |
143 | Standard_EXPORT void SetDrawArrows (const Standard_Boolean theToDraw); | |
144 | ||
24f9d04c | 145 | //! Returns priority of selection for owner of the given type |
146 | Standard_Integer SelectionPriority (Prs3d_DatumParts thePart) { return mySelectionPriority[thePart]; } | |
147 | ||
bc001a40 | 148 | //! Sets priority of selection for owner of the given type |
149 | void SetSelectionPriority (Prs3d_DatumParts thePart, | |
150 | Standard_Integer thePriority) | |
151 | { | |
24f9d04c | 152 | mySelectionPriority[thePart] = thePriority; |
bc001a40 | 153 | } |
154 | ||
24f9d04c | 155 | //! Returns text of axis. Parameter thePart should be XAxis, YAxis or ZAxis |
156 | const TCollection_ExtendedString& Label (Prs3d_DatumParts thePart) { return myLabels[thePart]; } | |
bc001a40 | 157 | |
158 | //! Sets text label for trihedron axis. Parameter thePart should be XAxis, YAxis or ZAxis | |
159 | void SetLabel (const Prs3d_DatumParts thePart, | |
24f9d04c | 160 | const TCollection_ExtendedString& theName) |
bc001a40 | 161 | { |
24f9d04c | 162 | myLabels[thePart] = theName; |
bc001a40 | 163 | } |
164 | ||
24f9d04c | 165 | public: |
166 | ||
167 | //! Sets the color theColor for this trihedron object, it changes color of axes. | |
168 | Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE; | |
169 | ||
170 | //! Returns true if the display mode selected, aMode, is valid for trihedron datums. | |
171 | virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE | |
bc001a40 | 172 | { |
24f9d04c | 173 | return theMode == 0; |
bc001a40 | 174 | } |
175 | ||
24f9d04c | 176 | //! Returns index 3, selection of the planes XOY, YOZ, XOZ. |
177 | virtual Standard_Integer Signature() const Standard_OVERRIDE { return 3; } | |
178 | ||
179 | //! Indicates that the type of Interactive Object is datum. | |
82b856b8 | 180 | virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Datum; } |
24f9d04c | 181 | |
182 | //! Removes the settings for color. | |
183 | Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE; | |
184 | ||
bc001a40 | 185 | public: |
186 | ||
bc001a40 | 187 | //! Method which clear all selected owners belonging |
188 | //! to this selectable object ( for fast presentation draw ). | |
189 | Standard_EXPORT virtual void ClearSelected() Standard_OVERRIDE; | |
190 | ||
191 | //! Method which draws selected owners ( for fast presentation draw ). | |
192 | Standard_EXPORT virtual void HilightSelected (const Handle(PrsMgr_PresentationManager3d)& thePM, | |
193 | const SelectMgr_SequenceOfOwner& theOwners) Standard_OVERRIDE; | |
194 | ||
195 | //! Method which hilight an owner belonging to | |
196 | //! this selectable object ( for fast presentation draw ). | |
197 | Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, | |
198 | const Handle(Prs3d_Drawer)& theStyle, | |
199 | const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE; | |
42cf5bc1 | 200 | |
42cf5bc1 | 201 | protected: |
202 | ||
bc001a40 | 203 | //! Compute trihedron presentation. |
204 | Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr, | |
205 | const Handle(Prs3d_Presentation)& thePrs, | |
206 | const Standard_Integer theMode) Standard_OVERRIDE; | |
42cf5bc1 | 207 | |
bc001a40 | 208 | //! Compute selection. |
209 | Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, | |
210 | const Standard_Integer theMode) Standard_OVERRIDE; | |
42cf5bc1 | 211 | |
bc73b006 | 212 | //! Dumps the content of me into the stream |
213 | Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE; | |
214 | ||
046a1c9d | 215 | protected: |
216 | ||
bc001a40 | 217 | //! Creates a sensitive entity for the datum part that will be used in selection owner creation. |
0ef04197 | 218 | Standard_EXPORT Handle(Select3D_SensitiveEntity) createSensitiveEntity (const Prs3d_DatumParts thePart, |
219 | const Handle(SelectMgr_EntityOwner)& theOwner) const; | |
bc001a40 | 220 | |
221 | //! Computes presentation for display mode equal 1. | |
222 | Standard_EXPORT void computePresentation (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr, | |
223 | const Handle(Prs3d_Presentation)& thePrs); | |
224 | ||
225 | //! Returns own datum aspect of trihedron, create this aspect if it was not created yet. | |
226 | Standard_EXPORT void setOwnDatumAspect(); | |
227 | ||
228 | //! Returns primitives. | |
24f9d04c | 229 | const Handle(Graphic3d_ArrayOfPrimitives)& arrayOfPrimitives (Prs3d_DatumParts thePart) const { return myPrimitives[thePart]; } |
bc001a40 | 230 | |
231 | //! Updates graphic groups for the current datum mode | |
232 | //! Parameters of datum position and orientation | |
233 | Standard_EXPORT void updatePrimitives (const Handle(Prs3d_DatumAspect)& theAspect, | |
234 | Prs3d_DatumMode theMode, | |
235 | const gp_Pnt& theOrigin, | |
236 | const gp_Dir& theXDir, | |
237 | const gp_Dir& theYDir, | |
238 | const gp_Dir& theZDir); | |
239 | ||
bc001a40 | 240 | protected: |
24f9d04c | 241 | Handle(Geom_Axis2Placement) myComponent; |
242 | Prs3d_DatumMode myTrihDispMode; | |
42cf5bc1 | 243 | Standard_Boolean myHasOwnSize; |
244 | Standard_Boolean myHasOwnTextColor; | |
42cf5bc1 | 245 | Standard_Boolean myHasOwnArrowColor; |
42cf5bc1 | 246 | |
24f9d04c | 247 | TCollection_ExtendedString myLabels[Prs3d_DatumParts_NB]; |
248 | Standard_Integer mySelectionPriority[Prs3d_DatumParts_NB]; | |
42cf5bc1 | 249 | |
24f9d04c | 250 | Handle(Graphic3d_Group) myPartToGroup[Prs3d_DatumParts_NB]; |
bc001a40 | 251 | NCollection_List<Prs3d_DatumParts> mySelectedParts; |
df8c7e3e | 252 | Handle(Graphic3d_AspectLine3d) myHiddenLineAspect; |
42cf5bc1 | 253 | |
24f9d04c | 254 | Handle(Graphic3d_ArrayOfPrimitives) myPrimitives[Prs3d_DatumParts_NB]; |
bc001a40 | 255 | }; |
42cf5bc1 | 256 | |
bc001a40 | 257 | DEFINE_STANDARD_HANDLE(AIS_Trihedron, AIS_InteractiveObject) |
42cf5bc1 | 258 | |
259 | #endif // _AIS_Trihedron_HeaderFile |