0029882: Visualization - AcceptDisplayMode() should be redefined in class AIS_Texture...
[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
bc001a40 107 //! Sets the color theColor for this trihedron object, it changes color of axes.
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
fae1ae11
ZA
155 //! Returns true if arrows are to be drawn
156 Standard_EXPORT Standard_Boolean ToDrawArrows() const;
157
158 //! Sets whether to draw the arrows in visualization
159 Standard_EXPORT void SetDrawArrows (const Standard_Boolean theToDraw);
160
bc001a40 161 //! Sets priority of selection for owner of the given type
162 void SetSelectionPriority (Prs3d_DatumParts thePart,
163 Standard_Integer thePriority)
164 {
165 mySelectionPriority.Bind (thePart, thePriority);
166 }
167
168 //! Sets priority of selection for owner of the given type
169 Standard_Integer SelectionPriority (Prs3d_DatumParts thePart)
170 {
171 return mySelectionPriority.Find (thePart);
172 }
173
174 //! Sets text label for trihedron axis. Parameter thePart should be XAxis, YAxis or ZAxis
175 void SetLabel (const Prs3d_DatumParts thePart,
176 const TCollection_ExtendedString& thePriority)
177 {
178 myLabel.Bind (thePart, thePriority);
179 }
180
181 //! Returns text of axis. Parameter thePart should be XAxis, YAxis or ZAxis
182 const TCollection_ExtendedString& Label (Prs3d_DatumParts thePart)
183 {
184 return myLabel.Find (thePart);
185 }
186
187public:
188
189 //! Disables auto highlighting to use HilightSelected() and HilightOwnerWithColor() overridden methods.
190 virtual Standard_Boolean IsAutoHilight() const Standard_OVERRIDE { return false; }
191
192 //! Method which clear all selected owners belonging
193 //! to this selectable object ( for fast presentation draw ).
194 Standard_EXPORT virtual void ClearSelected() Standard_OVERRIDE;
195
196 //! Method which draws selected owners ( for fast presentation draw ).
197 Standard_EXPORT virtual void HilightSelected (const Handle(PrsMgr_PresentationManager3d)& thePM,
198 const SelectMgr_SequenceOfOwner& theOwners) Standard_OVERRIDE;
199
200 //! Method which hilight an owner belonging to
201 //! this selectable object ( for fast presentation draw ).
202 Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
203 const Handle(Prs3d_Drawer)& theStyle,
204 const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE;
42cf5bc1 205
42cf5bc1 206protected:
207
bc001a40 208 //! Compute trihedron presentation.
209 Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
210 const Handle(Prs3d_Presentation)& thePrs,
211 const Standard_Integer theMode) Standard_OVERRIDE;
42cf5bc1 212
bc001a40 213 //! This compute is unavailable for trihedron presentation.
214 void Compute (const Handle(Prs3d_Projector)& , const Handle(Prs3d_Presentation)& ) Standard_OVERRIDE {}
215
216 //! This compute is unavailable for trihedron presentation.
217 Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& theProjector,
218 const Handle(Geom_Transformation)& theTrsf,
219 const Handle(Prs3d_Presentation)& thePrs) Standard_OVERRIDE;
220
221 //! Compute selection.
222 Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
223 const Standard_Integer theMode) Standard_OVERRIDE;
42cf5bc1 224
046a1c9d 225protected:
226
bc001a40 227 Standard_EXPORT void LoadRecomputable (const Standard_Integer theMode);
228
229 //! Creates a sensitive entity for the datum part that will be used in selection owner creation.
230 Standard_EXPORT Handle(SelectBasics_SensitiveEntity) createSensitiveEntity (const Prs3d_DatumParts thePart,
231 const Handle(SelectBasics_EntityOwner)& theOwner) const;
232
233 //! Computes presentation for display mode equal 1.
234 Standard_EXPORT void computePresentation (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
235 const Handle(Prs3d_Presentation)& thePrs);
236
237 //! Returns own datum aspect of trihedron, create this aspect if it was not created yet.
238 Standard_EXPORT void setOwnDatumAspect();
239
240 //! Returns primitives.
241 Standard_EXPORT Handle(Graphic3d_ArrayOfPrimitives) arrayOfPrimitives(
242 Prs3d_DatumParts thePart) const;
243
244 //! Updates graphic groups for the current datum mode
245 //! Parameters of datum position and orientation
246 Standard_EXPORT void updatePrimitives (const Handle(Prs3d_DatumAspect)& theAspect,
247 Prs3d_DatumMode theMode,
248 const gp_Pnt& theOrigin,
249 const gp_Dir& theXDir,
250 const gp_Dir& theYDir,
251 const gp_Dir& theZDir);
252
253 //! Returns highlight line aspect , create if it is the first call
254 Handle(Prs3d_ShadingAspect) getHighlightAspect();
255 //! Returns highlight line aspect , create if it is the first call
256 Handle(Prs3d_LineAspect) getHighlightLineAspect();
257 //! Returns highlight line aspect , create if it is the first call
258 Handle(Prs3d_PointAspect) getHighlightPointAspect();
259
260protected:
42cf5bc1 261 Standard_Boolean myHasOwnSize;
262 Standard_Boolean myHasOwnTextColor;
42cf5bc1 263 Standard_Boolean myHasOwnArrowColor;
bc001a40 264 Standard_Boolean myHasOwnDatumAspect;
42cf5bc1 265
bc001a40 266 Prs3d_DatumMode myTrihDispMode;
267 Handle(Geom_Axis2Placement) myComponent;
42cf5bc1 268
bc001a40 269 NCollection_DataMap<Prs3d_DatumParts, Standard_Integer> mySelectionPriority;
270 NCollection_DataMap<Prs3d_DatumParts, TCollection_ExtendedString> myLabel;
42cf5bc1 271
bc001a40 272 NCollection_DataMap<Prs3d_DatumParts, Handle(Graphic3d_Group)> myPartToGroup;
273 NCollection_List<Prs3d_DatumParts> mySelectedParts;
42cf5bc1 274
bc001a40 275 Handle(Prs3d_ShadingAspect) myHighlightAspect;
276 Handle(Prs3d_LineAspect) myHighlightLineAspect;
277 Handle(Prs3d_PointAspect) myHighlightPointAspect;
42cf5bc1 278
bc001a40 279 NCollection_DataMap<Prs3d_DatumParts, Handle(Graphic3d_ArrayOfPrimitives)> myPrimitives;
280};
42cf5bc1 281
bc001a40 282DEFINE_STANDARD_HANDLE(AIS_Trihedron, AIS_InteractiveObject)
42cf5bc1 283
284#endif // _AIS_Trihedron_HeaderFile