0030537: Visualization - wrapping text in font text formatter
[occt.git] / src / AIS / AIS_ViewCube.hxx
CommitLineData
2108d9a2 1// Created on: 2017-07-25
2// Created by: Anastasia BOBYLEVA
3// Copyright (c) 2017-2019 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef _AIS_ViewCube_HeaderFile
17#define _AIS_ViewCube_HeaderFile
18
19#include <AIS_InteractiveObject.hxx>
20#include <Graphic3d_Camera.hxx>
21#include <Graphic3d_Vec2.hxx>
22#include <Prs3d_DatumParts.hxx>
23#include <Prs3d_ShadingAspect.hxx>
24#include <Prs3d_TextAspect.hxx>
25#include <SelectMgr_EntityOwner.hxx>
26#include <V3d_TypeOfOrientation.hxx>
27
28class AIS_AnimationCamera;
29class AIS_ViewCubeOwner;
30class Graphic3d_ArrayOfTriangles;
caa309aa 31class V3d_View;
2108d9a2 32
33//! Interactive object for displaying the view manipulation cube.
34//!
35//! View cube consists of several parts that are responsible for different camera manipulations:
36//! @li Cube sides represent main views: top, bottom, left, right, front and back.
37//! @li Edges represent rotation of one of main views on 45 degrees.
38//! @li Vertices represent rotation of one of man views in two directions.
39//!
40//! The object is expected to behave like a trihedron in the view corner,
41//! therefore its position should be defined using transformation persistence flags:
42//! @code SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_TriedronPers, Aspect_TOTP_LEFT_LOWER, Graphic3d_Vec2i (100, 100)); @endcode
43//!
44//! View Cube parts are sensitive to detection, or dynamic highlighting (but not selection),
45//! and every its owner AIS_ViewCubeOwner corresponds to camera transformation.
46//! @code
47//! for (aViewCube->StartAnimation (aDetectedOwner); aViewCube->HasAnimation(); )
48//! {
49//! aViewCube->UpdateAnimation();
50//! ... // updating of application window
51//! }
52//! @endcode
53//! or
54//! @code aViewCube->HandleClick (aDetectedOwner); @endcode
55//! that includes transformation loop.
56//! This loop allows external actions like application updating. For this purpose AIS_ViewCube has virtual interface onAfterAnimation(),
57//! that is to be redefined on application level.
58class AIS_ViewCube : public AIS_InteractiveObject
59{
60 DEFINE_STANDARD_RTTIEXT(AIS_ViewCube, AIS_InteractiveObject)
61public:
62
63 //! Return TRUE if specified orientation belongs to box side.
64 Standard_EXPORT static bool IsBoxSide (V3d_TypeOfOrientation theOrient);
65
66 //! Return TRUE if specified orientation belongs to box edge.
67 Standard_EXPORT static bool IsBoxEdge (V3d_TypeOfOrientation theOrient);
68
69 //! Return TRUE if specified orientation belongs to box corner (vertex).
70 Standard_EXPORT static bool IsBoxCorner (V3d_TypeOfOrientation theOrient);
71
72public:
73
74 //! Empty constructor.
75 Standard_EXPORT AIS_ViewCube();
76
77 //! Return view animation.
78 const Handle(AIS_AnimationCamera)& ViewAnimation() const { return myViewAnimation; }
79
80 //! Set view animation.
81 void SetViewAnimation (const Handle(AIS_AnimationCamera)& theAnimation) { myViewAnimation = theAnimation; }
82
83 //! Return TRUE if automatic camera transformation on selection (highlighting) is enabled; TRUE by default.
84 Standard_Boolean ToAutoStartAnimation() const { return myToAutoStartAnim; }
85
86 //! Enable/disable automatic camera transformation on selection (highlighting).
87 //! The automatic logic can be disabled if application wants performing action manually
88 //! basing on picking results (AIS_ViewCubeOwner).
89 void SetAutoStartAnimation (bool theToEnable) { myToAutoStartAnim = theToEnable; }
90
91 //! Return TRUE if camera animation should be done in uninterruptible loop; TRUE by default.
92 Standard_Boolean IsFixedAnimationLoop() const { return myIsFixedAnimation; }
93
94 //! Set if camera animation should be done in uninterruptible loop.
95 void SetFixedAnimationLoop (bool theToEnable) { myIsFixedAnimation = theToEnable; }
96
97 //! Reset all size and style parameters to default.
98 //! @warning It doesn't reset position of View Cube
99 Standard_EXPORT void ResetStyles();
100
101protected:
102
103 //! Set default visual attributes
104 Standard_EXPORT void setDefaultAttributes();
105
106 //! Set default dynamic highlight properties
107 Standard_EXPORT void setDefaultHighlightAttributes();
108
109public: //! @name Geometry management API
110
111 //! @return size (width and height) of View cube sides; 100 by default.
112 Standard_Real Size() const { return mySize; }
113
114 //! Sets size (width and height) of View cube sides.
115 //! @param theToAdaptAnother if TRUE, then other parameters will be adapted to specified size
116 Standard_EXPORT void SetSize (Standard_Real theValue,
117 Standard_Boolean theToAdaptAnother = true);
118
119 //! Return box facet extension to edge/corner facet split; 10 by default.
120 Standard_Real BoxFacetExtension() const { return myBoxFacetExtension; }
121
122 //! Set new value of box facet extension.
123 void SetBoxFacetExtension (Standard_Real theValue)
124 {
125 if (Abs (myBoxFacetExtension - theValue) > Precision::Confusion())
126 {
127 myBoxFacetExtension = theValue;
128 SetToUpdate();
129 }
130 }
131
132 //! Return padding between axes and 3D part (box); 10 by default.
133 Standard_Real AxesPadding() const { return myAxesPadding; }
134
135 //! Set new value of padding between axes and 3D part (box).
136 void SetAxesPadding (Standard_Real theValue)
137 {
138 if (Abs (myAxesPadding - theValue) > Precision::Confusion())
139 {
140 myAxesPadding = theValue;
141 SetToUpdate();
142 }
143 }
144
145 //! Return gap between box edges and box sides; 0 by default.
146 Standard_Real BoxEdgeGap() const { return myBoxEdgeGap; }
147
148 //! Set new value of box edges gap.
149 void SetBoxEdgeGap (Standard_Real theValue)
150 {
151 if (Abs (myBoxEdgeGap - theValue) > Precision::Confusion())
152 {
153 myBoxEdgeGap = theValue;
154 SetToUpdate();
155 }
156 }
157
158 //! Return minimal size of box edge; 2 by default.
159 Standard_Real BoxEdgeMinSize() const { return myBoxEdgeMinSize; }
160
161 //! Set new value of box edge minimal size.
162 void SetBoxEdgeMinSize (Standard_Real theValue)
163 {
164 if (Abs (myBoxEdgeMinSize - theValue) > Precision::Confusion())
165 {
166 myBoxEdgeMinSize = theValue;
167 SetToUpdate();
168 }
169 }
170
171 //! Return minimal size of box corner; 2 by default.
172 Standard_Real BoxCornerMinSize() const { return myCornerMinSize; }
173
174 //! Set new value of box corner minimal size.
175 void SetBoxCornerMinSize (Standard_Real theValue)
176 {
177 if (Abs (myCornerMinSize - theValue) > Precision::Confusion())
178 {
179 myCornerMinSize = theValue;
180 SetToUpdate();
181 }
182 }
183
184 //! Return relative radius of side corners (round rectangle); 0.0 by default.
185 //! The value in within [0, 0.5] range meaning absolute radius = RoundRadius() / Size().
186 Standard_Real RoundRadius() const { return myRoundRadius; }
187
188 //! Set relative radius of View Cube sides corners (round rectangle).
189 //! The value should be within [0, 0.5] range.
190 Standard_EXPORT void SetRoundRadius (const Standard_Real theValue);
191
6466cc9e 192 //! Returns radius of axes of the trihedron; 1.0 by default.
193 Standard_Real AxesRadius() const { return myAxesRadius; }
194
195 //! Sets radius of axes of the trihedron.
196 void SetAxesRadius (const Standard_Real theRadius)
197 {
198 if (Abs (myAxesRadius - theRadius) > Precision::Confusion())
199 {
200 myAxesRadius = theRadius;
201 SetToUpdate();
202 }
203 }
204
205 //! Returns radius of cone of axes of the trihedron; 3.0 by default.
206 Standard_Real AxesConeRadius() const { return myAxesConeRadius; }
207
208 //! Sets radius of cone of axes of the trihedron.
209 void SetAxesConeRadius (Standard_Real theRadius)
210 {
211 if (Abs (myAxesConeRadius - theRadius) > Precision::Confusion())
212 {
213 myAxesConeRadius = theRadius;
214 SetToUpdate();
215 }
216 }
217
218 //! Returns radius of sphere (central point) of the trihedron; 4.0 by default.
219 Standard_Real AxesSphereRadius() const { return myAxesSphereRadius; }
220
221 //! Sets radius of sphere (central point) of the trihedron.
222 void SetAxesSphereRadius (Standard_Real theRadius)
223 {
224 if (Abs (myAxesSphereRadius - theRadius) > Precision::Confusion())
225 {
226 myAxesSphereRadius = theRadius;
227 SetToUpdate();
228 }
229 }
230
2108d9a2 231 //! @return TRUE if trihedron is drawn; TRUE by default.
232 Standard_Boolean ToDrawAxes() const { return myToDisplayAxes; }
233
234 //! Enable/disable drawing of trihedron.
235 void SetDrawAxes (Standard_Boolean theValue)
236 {
237 if (myToDisplayAxes != theValue)
238 {
239 myToDisplayAxes = theValue;
240 SetToUpdate();
241 }
242 }
243
244 //! @return TRUE if edges of View Cube is drawn; TRUE by default.
245 Standard_Boolean ToDrawEdges() const { return myToDisplayEdges; }
246
247 //! Enable/disable drawing of edges of View Cube.
248 void SetDrawEdges (Standard_Boolean theValue)
249 {
250 if (myToDisplayEdges != theValue)
251 {
252 myToDisplayEdges = theValue;
253 SetToUpdate();
254 }
255 }
256
257 //! Return TRUE if vertices (vertex) of View Cube is drawn; TRUE by default.
258 Standard_Boolean ToDrawVertices() const { return myToDisplayVertices; }
259
260 //! Enable/disable drawing of vertices (corners) of View Cube.
261 void SetDrawVertices (Standard_Boolean theValue)
262 {
263 if (myToDisplayVertices != theValue)
264 {
265 myToDisplayVertices = theValue;
266 SetToUpdate();
267 }
268 }
269
270 //! Return TRUE if application expects Y-up viewer orientation instead of Z-up; FALSE by default.
271 Standard_Boolean IsYup() const { return myIsYup; }
272
273 //! Set if application expects Y-up viewer orientation instead of Z-up.
274 Standard_EXPORT void SetYup (Standard_Boolean theIsYup,
275 Standard_Boolean theToUpdateLabels = Standard_True);
276
277public: //! @name Style management API
278
279 //! Return shading style of box sides.
280 const Handle(Prs3d_ShadingAspect)& BoxSideStyle() const { return myDrawer->ShadingAspect(); }
281
282 //! Return shading style of box edges.
283 const Handle(Prs3d_ShadingAspect)& BoxEdgeStyle() const { return myBoxEdgeAspect; }
284
285 //! Return shading style of box corners.
286 const Handle(Prs3d_ShadingAspect)& BoxCornerStyle() const { return myBoxCornerAspect; }
287
288 //! Return value of front color for the 3D part of object.
289 const Quantity_Color& BoxColor() const { return myDrawer->ShadingAspect()->Color(); }
290
291 //! Set new value of front color for the 3D part of object.
292 //! @param theColor [in] input color value.
293 void SetBoxColor (const Quantity_Color& theColor)
294 {
295 if (!myDrawer->ShadingAspect()->Color().IsEqual (theColor)
296 || !myBoxEdgeAspect ->Color().IsEqual (theColor)
297 || !myBoxCornerAspect->Color().IsEqual (theColor))
298 {
299 myDrawer->ShadingAspect()->SetColor (theColor);
300 myBoxEdgeAspect->SetColor (theColor);
301 myBoxCornerAspect->SetColor (theColor);
302 SynchronizeAspects();
303 }
304 }
305
306 //! Return transparency for 3D part of object.
307 Standard_Real BoxTransparency() const { return myDrawer->ShadingAspect()->Transparency(); }
308
309 //! Set new value of transparency for 3D part of object.
310 //! @param theValue [in] input transparency value
311 void SetBoxTransparency (Standard_Real theValue)
312 {
313 if (Abs (myDrawer->ShadingAspect()->Transparency() - theValue) > Precision::Confusion()
314 || Abs (myBoxEdgeAspect ->Transparency() - theValue) > Precision::Confusion()
315 || Abs (myBoxCornerAspect->Transparency() - theValue) > Precision::Confusion())
316 {
317 myDrawer->ShadingAspect()->SetTransparency (theValue);
318 myBoxEdgeAspect->SetTransparency (theValue);
319 myBoxCornerAspect->SetTransparency (theValue);
320 SynchronizeAspects();
321 }
322 }
323
324 //! Return color of sides back material.
325 const Quantity_Color& InnerColor() const { return myDrawer->ShadingAspect()->Color (Aspect_TOFM_BACK_SIDE); }
326
327 //! Set color of sides back material. Alias for:
328 //! @code Attributes()->ShadingAspect()->Aspect()->ChangeBackMaterial().SetColor() @endcode
329 void SetInnerColor (const Quantity_Color& theColor)
330 {
331 myDrawer->ShadingAspect()->SetColor (theColor, Aspect_TOFM_BACK_SIDE);
332 SynchronizeAspects();
333 }
334
335 //! Return box side label or empty string if undefined.
336 //! Default labels: FRONT, BACK, LEFT, RIGHT, TOP, BOTTOM.
337 TCollection_AsciiString BoxSideLabel (V3d_TypeOfOrientation theSide) const
338 {
339 const TCollection_AsciiString* aLabel = myBoxSideLabels.Seek (theSide);
340 return aLabel != NULL ? *aLabel : TCollection_AsciiString();
341 }
342
343 //! Set box side label.
344 void SetBoxSideLabel (const V3d_TypeOfOrientation theSide,
345 const TCollection_AsciiString& theLabel)
346 {
347 if (!IsBoxSide (theSide))
348 {
349 throw Standard_ProgramError ("AIS_ViewCube::SetBoxSideLabel(), invalid enumeration value");
350 }
351 myBoxSideLabels.Bind (theSide, theLabel);
352 SetToUpdate();
353 }
354
355 //! Return text color of labels of box sides; BLACK by default.
356 const Quantity_Color& TextColor() const { return myDrawer->TextAspect()->Aspect()->Color(); }
357
358 //! Set color of text labels on box sides. Alias for:
359 //! @code Attributes()->TextAspect()->SetColor() @endcode
360 void SetTextColor (const Quantity_Color& theColor)
361 {
362 myDrawer->TextAspect()->SetColor (theColor);
363 SynchronizeAspects();
364 }
365
366 //! Return font name that is used for displaying of sides and axes text. Alias for:
367 //! @code Attributes()->TextAspect()->Aspect()->SetFont() @endcode
368 const TCollection_AsciiString& Font() const { return myDrawer->TextAspect()->Aspect()->Font(); }
369
370 //! Set font name that is used for displaying of sides and axes text. Alias for:
371 //! @code Attributes()->TextAspect()->SetFont() @endcode
372 void SetFont (const TCollection_AsciiString& theFont)
373 {
374 myDrawer->TextAspect()->Aspect()->SetFont (theFont);
375 SynchronizeAspects();
376 }
377
378 //! Return height of font
379 Standard_Real FontHeight() const { return myDrawer->TextAspect()->Height(); }
380
381 //! Change font height. Alias for:
382 //! @code Attributes()->TextAspect()->SetHeight() @endcode
383 void SetFontHeight (Standard_Real theValue)
384 {
385 if (Abs (myDrawer->TextAspect()->Height() - theValue) > Precision::Confusion())
386 {
387 myDrawer->TextAspect()->SetHeight (theValue);
388 SetToUpdate();
389 }
390 }
391
392 //! Return axes labels or empty string if undefined.
393 //! Default labels: X, Y, Z.
394 TCollection_AsciiString AxisLabel (Prs3d_DatumParts theAxis) const
395 {
396 const TCollection_AsciiString* aLabel = myAxesLabels.Seek (theAxis);
397 return aLabel != NULL ? *aLabel : TCollection_AsciiString();
398 }
399
400 //! Set axes labels.
401 void SetAxesLabels (const TCollection_AsciiString& theX,
402 const TCollection_AsciiString& theY,
403 const TCollection_AsciiString& theZ)
404 {
405 myAxesLabels.Bind (Prs3d_DP_XAxis, theX);
406 myAxesLabels.Bind (Prs3d_DP_YAxis, theY);
407 myAxesLabels.Bind (Prs3d_DP_ZAxis, theZ);
408 SetToUpdate();
409 }
410
411public:
412
413 //! Set new value of color for the whole object.
414 //! @param theColor [in] input color value.
415 virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE
416 {
417 SetBoxColor (theColor);
418 }
419
420 //! Reset color for the whole object.
421 virtual void UnsetColor() Standard_OVERRIDE
422 {
423 myDrawer->ShadingAspect()->SetColor (Quantity_NOC_WHITE);
424 myBoxEdgeAspect ->SetColor (Quantity_NOC_GRAY30);
425 myBoxCornerAspect->SetColor (Quantity_NOC_GRAY30);
426 SynchronizeAspects();
427 }
428
429 //! Set new value of transparency for the whole object.
430 //! @param theValue [in] input transparency value.
431 virtual void SetTransparency (const Standard_Real theValue) Standard_OVERRIDE
432 {
433 SetBoxTransparency (theValue);
434 }
435
436 //! Reset transparency for the whole object.
437 virtual void UnsetTransparency() Standard_OVERRIDE
438 {
439 SetBoxTransparency (0.0f);
440 }
441
442 //! Sets the material for the interactive object.
443 virtual void SetMaterial (const Graphic3d_MaterialAspect& theMat) Standard_OVERRIDE
444 {
445 myDrawer->ShadingAspect()->SetMaterial (theMat);
446 myBoxEdgeAspect ->SetMaterial (theMat);
447 myBoxCornerAspect->SetMaterial (theMat);
448 SynchronizeAspects();
449 }
450
451 //! Sets the material for the interactive object.
452 virtual void UnsetMaterial() Standard_OVERRIDE
453 {
454 Graphic3d_MaterialAspect aMat (Graphic3d_NOM_UserDefined);
455 aMat.SetColor (Quantity_NOC_WHITE);
456 aMat.SetAmbientColor (Quantity_NOC_GRAY60);
457 myDrawer->ShadingAspect()->SetMaterial (aMat);
458 myBoxEdgeAspect ->SetMaterial (aMat);
459 myBoxEdgeAspect ->SetColor (Quantity_NOC_GRAY30);
460 myBoxCornerAspect->SetMaterial (aMat);
461 myBoxCornerAspect->SetColor (Quantity_NOC_GRAY30);
462 SynchronizeAspects();
463 }
464
465public: //! @name animation methods
466
467 //! Return duration of animation in seconds; 0.5 sec by default
d6fbb2ab 468 Standard_EXPORT Standard_Real Duration() const;
2108d9a2 469
470 //! Set duration of animation.
471 //! @param theValue [in] input value of duration in seconds
d6fbb2ab 472 Standard_EXPORT void SetDuration (Standard_Real theValue);
2108d9a2 473
474 //! Return TRUE if new camera Up direction should be always set to default value for a new camera Direction; FALSE by default.
475 //! When this flag is FALSE, the new camera Up will be set as current Up orthogonalized to the new camera Direction,
476 //! and will set to default Up on second click.
477 Standard_Boolean ToResetCameraUp() const { return myToResetCameraUp; }
478
479 //! Set if new camera Up direction should be always set to default value for a new camera Direction.
480 void SetResetCamera (Standard_Boolean theToReset) { myToResetCameraUp = theToReset; }
481
482 //! Return TRUE if animation should fit selected objects and FALSE to fit entire scene; TRUE by default.
483 Standard_Boolean ToFitSelected() const { return myToFitSelected; }
484
485 //! Set if animation should fit selected objects or to fit entire scene.
486 void SetFitSelected (Standard_Boolean theToFitSelected) { myToFitSelected = theToFitSelected; }
487
488 //! @return TRUE if View Cube has unfinished animation of view camera.
489 Standard_EXPORT Standard_Boolean HasAnimation() const;
490
491 //! Start camera transformation corresponding to the input detected owner.
492 //! @param theOwner [in] detected owner.
493 Standard_EXPORT virtual void StartAnimation (const Handle(AIS_ViewCubeOwner)& theOwner);
494
495 //! Perform one step of current camera transformation.
496 //! theToUpdate [in] enable/disable update of view.
497 //! @return TRUE if animation is not stopped.
498 Standard_EXPORT virtual Standard_Boolean UpdateAnimation (const Standard_Boolean theToUpdate);
499
500 //! Perform camera transformation corresponding to the input detected owner.
501 Standard_EXPORT virtual void HandleClick (const Handle(AIS_ViewCubeOwner)& theOwner);
502
503protected:
504
505 //! Perform internal single step of animation.
506 //! @return FALSE if animation has been finished
507 Standard_EXPORT Standard_Boolean updateAnimation();
508
caa309aa 509 //! Fit selected/all into view.
510 //! @param theView [in] view definition to retrieve scene bounding box
511 //! @param theCamera [in,out] camera definition
512 Standard_EXPORT virtual void viewFitAll (const Handle(V3d_View)& theView,
513 const Handle(Graphic3d_Camera)& theCamera);
514
2108d9a2 515protected: //! @name protected virtual API
516
517 //! Method that is called after one step of transformation.
518 virtual void onAfterAnimation() {}
519
520 //! Method that is called after transformation finish.
521 virtual void onAnimationFinished() {}
522
523public: //! @name Presentation computation
524
525 //! Return TRUE for supported display mode.
526 virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
527
528 //! Global selection has no meaning for this class.
529 virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const Standard_OVERRIDE { return Handle(SelectMgr_EntityOwner)(); }
530
531 //! Compute 3D part of View Cube.
532 //! @param thePrsMgr [in] presentation manager.
533 //! @param thePrs [in] input presentation that is to be filled with flat presentation primitives.
534 //! @param theMode [in] display mode.
535 //! @warning this object accept only 0 display mode.
536 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
537 const Handle(Prs3d_Presentation)& thePrs,
538 const Standard_Integer theMode = 0) Standard_OVERRIDE;
539
540 //! Redefine computing of sensitive entities for View Cube.
541 //! @param theSelection [in] input selection object that is to be filled with sensitive entities.
542 //! @param theMode [in] selection mode.
543 //! @warning object accepts only 0 selection mode.
544 Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
545 const Standard_Integer theMode) Standard_OVERRIDE;
546
547 //! Disables auto highlighting to use HilightSelected() and HilightOwnerWithColor() overridden methods.
548 virtual Standard_Boolean IsAutoHilight() const Standard_OVERRIDE { return Standard_False; }
549
550 //! Method which clear all selected owners belonging to this selectable object.
551 //! @warning this object does not support selection.
552 virtual void ClearSelected() Standard_OVERRIDE {}
553
554 //! Method which highlights input owner belonging to this selectable object.
555 //! @param thePM [in] presentation manager
556 //! @param theStyle [in] style for dynamic highlighting.
557 //! @param theOwner [in] input entity owner.
558 Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
559 const Handle(Prs3d_Drawer)& theStyle,
560 const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE;
561
562 //! Method which draws selected owners.
563 Standard_EXPORT virtual void HilightSelected (const Handle(PrsMgr_PresentationManager3d)& thePM,
564 const SelectMgr_SequenceOfOwner& theSeq) Standard_OVERRIDE;
565
566 //! Set default parameters for visual attributes
567 //! @sa Attributes()
568 virtual void UnsetAttributes() Standard_OVERRIDE
569 {
570 setDefaultAttributes();
571 SetToUpdate();
572 }
573
574 //! Set default parameters for dynamic highlighting attributes, reset highlight attributes
575 virtual void UnsetHilightAttributes() Standard_OVERRIDE
576 {
577 myHilightDrawer.Nullify();
578 setDefaultHighlightAttributes();
579 SetToUpdate();
580 }
581
582protected: //! @name Auxiliary classes to fill presentation with proper primitives
583
584 //! Create triangulation for a box part - for presentation and selection purposes.
caa309aa 585 //! @param theTris [in,out] triangulation to fill, or NULL to return size
586 //! @param theNbNodes [in,out] should be incremented by a number of nodes defining this triangulation
587 //! @param theNbTris [in,out] should be incremented by a number of triangles defining this triangulation
588 //! @param theDir [in] part to define
589 Standard_EXPORT virtual void createBoxPartTriangles (const Handle(Graphic3d_ArrayOfTriangles)& theTris,
590 Standard_Integer& theNbNodes,
591 Standard_Integer& theNbTris,
592 V3d_TypeOfOrientation theDir) const;
2108d9a2 593
594 //! Create triangulation for a box side.
caa309aa 595 //! @param theTris [in,out] triangulation to fill, or NULL to return size
596 //! @param theNbNodes [in,out] should be incremented by a number of nodes defining this triangulation
597 //! @param theNbTris [in,out] should be incremented by a number of triangles defining this triangulation
598 //! @param theDir [in] part to define
599 Standard_EXPORT virtual void createBoxSideTriangles (const Handle(Graphic3d_ArrayOfTriangles)& theTris,
600 Standard_Integer& theNbNodes,
601 Standard_Integer& theNbTris,
602 V3d_TypeOfOrientation theDir) const;
2108d9a2 603
604 //! Create triangulation for a box edge.
caa309aa 605 //! @param theTris [in,out] triangulation to fill, or NULL to return size
606 //! @param theNbNodes [in,out] should be incremented by a number of nodes defining this triangulation
607 //! @param theNbTris [in,out] should be incremented by a number of triangles defining this triangulation
608 //! @param theDir [in] part to define
609 Standard_EXPORT virtual void createBoxEdgeTriangles (const Handle(Graphic3d_ArrayOfTriangles)& theTris,
610 Standard_Integer& theNbNodes,
611 Standard_Integer& theNbTris,
612 V3d_TypeOfOrientation theDir) const;
2108d9a2 613
614 //! Create triangulation for a box corner (vertex).
caa309aa 615 //! @param theTris [in,out] triangulation to fill, or NULL to return size
616 //! @param theNbNodes [in,out] should be incremented by a number of nodes defining this triangulation
617 //! @param theNbTris [in,out] should be incremented by a number of triangles defining this triangulation
618 //! @param theDir [in] part to define
619 Standard_EXPORT virtual void createBoxCornerTriangles (const Handle(Graphic3d_ArrayOfTriangles)& theTris,
620 Standard_Integer& theNbNodes,
621 Standard_Integer& theNbTris,
622 V3d_TypeOfOrientation theDir) const;
2108d9a2 623
624protected:
625
626 //! Create triangulation for a rectangle with round corners.
caa309aa 627 //! @param theTris [in,out] triangulation to fill, or NULL to return size
628 //! @param theNbNodes [in,out] should be incremented by a number of nodes defining this triangulation
629 //! @param theNbTris [in,out] should be incremented by a number of triangles defining this triangulation
630 //! @param theSize [in] rectangle dimensions
631 //! @param theRadius [in] radius at corners
632 //! @param theTrsf [in] transformation
633 Standard_EXPORT static void createRoundRectangleTriangles (const Handle(Graphic3d_ArrayOfTriangles)& theTris,
634 Standard_Integer& theNbNodes,
635 Standard_Integer& theNbTris,
636 const gp_XY& theSize,
637 Standard_Real theRadius,
638 const gp_Trsf& theTrsf);
2108d9a2 639
640protected:
641
642 //! Trivial hasher to avoid ambiguity with enumeration type.
643 struct IntegerHasher
644 {
645 static Standard_Integer HashCode (Standard_Integer theValue, Standard_Integer theUpper) { return ::HashCode (theValue, theUpper); }
646 static Standard_Boolean IsEqual (Standard_Integer theA, Standard_Integer theB) { return theA == theB; }
647 };
648
649protected:
650
651 NCollection_DataMap<V3d_TypeOfOrientation, TCollection_AsciiString, IntegerHasher>
652 myBoxSideLabels; //!< map with box side labels
653 NCollection_DataMap<Prs3d_DatumParts, TCollection_AsciiString, IntegerHasher>
654 myAxesLabels; //!< map with axes labels
655 Handle(Prs3d_ShadingAspect) myBoxEdgeAspect; //!< style for box edges
656 Handle(Prs3d_ShadingAspect) myBoxCornerAspect; //!< style for box corner
657
658 Standard_Real mySize; //!< size of box side, length of one axis
659 Standard_Real myBoxEdgeMinSize; //!< minimal size of box edge
660 Standard_Real myBoxEdgeGap; //!< gap between box side and box edge
661 Standard_Real myBoxFacetExtension; //!< box facet extension
662 Standard_Real myAxesPadding; //!< Padding between box and axes
6466cc9e 663 Standard_Real myAxesRadius; //!< radius of axes of the trihedron; 1.0 by default
664 Standard_Real myAxesConeRadius; //!< radius of cone of axes of the trihedron; 3.0 by default
665 Standard_Real myAxesSphereRadius; //!< radius of sphere (central point) of the trihedron; 4.0 by default
2108d9a2 666 Standard_Real myCornerMinSize; //!< minimal size of box corner
667 Standard_Real myRoundRadius; //!< relative round radius within [0; 0.5] range
668 Standard_Boolean myToDisplayAxes; //!< trihedron visibility
669 Standard_Boolean myToDisplayEdges; //!< box edges visibility
670 Standard_Boolean myToDisplayVertices; //!< box corners (vertices) visibility
671 Standard_Boolean myIsYup; //!< flag indicating that application expects Y-up viewer orientation instead of Z-up
672
673protected: //! @name Animation options
674
675 Handle(AIS_AnimationCamera) myViewAnimation; //!< Camera animation object
676 Handle(Graphic3d_Camera) myStartState; //!< Start state of view camera
677 Handle(Graphic3d_Camera) myEndState; //!< End state of view camera
2108d9a2 678 Standard_Boolean myToAutoStartAnim; //!< start animation automatically on click
679 Standard_Boolean myIsFixedAnimation; //!< fixed-loop animation
680 Standard_Boolean myToFitSelected; //!< fit selected or fit entire scene
681 Standard_Boolean myToResetCameraUp; //!< always reset camera up direction to default
682
683};
684
685//! Redefined entity owner that is highlighted when owner is detected,
686//! even if Interactive Context highlighted on last detection procedure.
687class AIS_ViewCubeOwner : public SelectMgr_EntityOwner
688{
689 DEFINE_STANDARD_RTTIEXT(AIS_ViewCubeOwner, SelectMgr_EntityOwner)
690public:
691
692 //! Main constructor.
693 AIS_ViewCubeOwner (const Handle(AIS_ViewCube)& theObject,
694 V3d_TypeOfOrientation theOrient,
695 Standard_Integer thePriority = 5)
696 : SelectMgr_EntityOwner ((const Handle(SelectMgr_SelectableObject)& )theObject, thePriority),
697 myMainOrient (theOrient)
698 {
699 myFromDecomposition = true;
700 }
701
702 //! @return TRUE. This owner will always call method
703 //! Hilight for its Selectable Object when the owner is detected.
704 virtual Standard_Boolean IsForcedHilight() const Standard_OVERRIDE { return Standard_True; }
705
706 //! Return new orientation to set.
707 V3d_TypeOfOrientation MainOrientation() const { return myMainOrient; }
708
709 //! Handle mouse button click event.
710 virtual Standard_Boolean HandleMouseClick (const Graphic3d_Vec2i& thePoint,
711 Aspect_VKeyMouse theButton,
712 Aspect_VKeyFlags theModifiers,
713 bool theIsDoubleClick) Standard_OVERRIDE
714 {
715 (void )thePoint; (void )theButton; (void )theModifiers; (void )theIsDoubleClick;
716 AIS_ViewCube* aCubePrs = dynamic_cast<AIS_ViewCube* >(mySelectable);
717 aCubePrs->HandleClick (this);
718 return Standard_True;
719 }
720
721protected:
722
723 V3d_TypeOfOrientation myMainOrient; //!< new orientation to set
724
725};
726
727#endif // _AIS_ViewCube_HeaderFile