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