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