1 // Created on: 2017-07-25
2 // Created by: Anastasia BOBYLEVA
3 // Copyright (c) 2017-2019 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _AIS_ViewCube_HeaderFile
17 #define _AIS_ViewCube_HeaderFile
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>
28 class AIS_AnimationCamera;
29 class AIS_ViewCubeOwner;
30 class Graphic3d_ArrayOfTriangles;
33 //! Interactive object for displaying the view manipulation cube.
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.
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
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.
47 //! for (aViewCube->StartAnimation (aDetectedOwner); aViewCube->HasAnimation(); )
49 //! aViewCube->UpdateAnimation();
50 //! ... // updating of application window
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.
58 class AIS_ViewCube : public AIS_InteractiveObject
60 DEFINE_STANDARD_RTTIEXT(AIS_ViewCube, AIS_InteractiveObject)
63 //! Return TRUE if specified orientation belongs to box side.
64 Standard_EXPORT static bool IsBoxSide (V3d_TypeOfOrientation theOrient);
66 //! Return TRUE if specified orientation belongs to box edge.
67 Standard_EXPORT static bool IsBoxEdge (V3d_TypeOfOrientation theOrient);
69 //! Return TRUE if specified orientation belongs to box corner (vertex).
70 Standard_EXPORT static bool IsBoxCorner (V3d_TypeOfOrientation theOrient);
74 //! Empty constructor.
75 Standard_EXPORT AIS_ViewCube();
77 //! Return view animation.
78 const Handle(AIS_AnimationCamera)& ViewAnimation() const { return myViewAnimation; }
80 //! Set view animation.
81 void SetViewAnimation (const Handle(AIS_AnimationCamera)& theAnimation) { myViewAnimation = theAnimation; }
83 //! Return TRUE if automatic camera transformation on selection (highlighting) is enabled; TRUE by default.
84 Standard_Boolean ToAutoStartAnimation() const { return myToAutoStartAnim; }
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; }
91 //! Return TRUE if camera animation should be done in uninterruptible loop; TRUE by default.
92 Standard_Boolean IsFixedAnimationLoop() const { return myIsFixedAnimation; }
94 //! Set if camera animation should be done in uninterruptible loop.
95 void SetFixedAnimationLoop (bool theToEnable) { myIsFixedAnimation = theToEnable; }
97 //! Reset all size and style parameters to default.
98 //! @warning It doesn't reset position of View Cube
99 Standard_EXPORT void ResetStyles();
103 //! Set default visual attributes
104 Standard_EXPORT void setDefaultAttributes();
106 //! Set default dynamic highlight properties
107 Standard_EXPORT void setDefaultHighlightAttributes();
109 public: //! @name Geometry management API
111 //! @return size (width and height) of View cube sides; 100 by default.
112 Standard_Real Size() const { return mySize; }
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);
119 //! Return box facet extension to edge/corner facet split; 10 by default.
120 Standard_Real BoxFacetExtension() const { return myBoxFacetExtension; }
122 //! Set new value of box facet extension.
123 void SetBoxFacetExtension (Standard_Real theValue)
125 if (Abs (myBoxFacetExtension - theValue) > Precision::Confusion())
127 myBoxFacetExtension = theValue;
132 //! Return padding between axes and 3D part (box); 10 by default.
133 Standard_Real AxesPadding() const { return myAxesPadding; }
135 //! Set new value of padding between axes and 3D part (box).
136 void SetAxesPadding (Standard_Real theValue)
138 if (Abs (myAxesPadding - theValue) > Precision::Confusion())
140 myAxesPadding = theValue;
145 //! Return gap between box edges and box sides; 0 by default.
146 Standard_Real BoxEdgeGap() const { return myBoxEdgeGap; }
148 //! Set new value of box edges gap.
149 void SetBoxEdgeGap (Standard_Real theValue)
151 if (Abs (myBoxEdgeGap - theValue) > Precision::Confusion())
153 myBoxEdgeGap = theValue;
158 //! Return minimal size of box edge; 2 by default.
159 Standard_Real BoxEdgeMinSize() const { return myBoxEdgeMinSize; }
161 //! Set new value of box edge minimal size.
162 void SetBoxEdgeMinSize (Standard_Real theValue)
164 if (Abs (myBoxEdgeMinSize - theValue) > Precision::Confusion())
166 myBoxEdgeMinSize = theValue;
171 //! Return minimal size of box corner; 2 by default.
172 Standard_Real BoxCornerMinSize() const { return myCornerMinSize; }
174 //! Set new value of box corner minimal size.
175 void SetBoxCornerMinSize (Standard_Real theValue)
177 if (Abs (myCornerMinSize - theValue) > Precision::Confusion())
179 myCornerMinSize = theValue;
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; }
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);
192 //! Returns radius of axes of the trihedron; 1.0 by default.
193 Standard_Real AxesRadius() const { return myAxesRadius; }
195 //! Sets radius of axes of the trihedron.
196 void SetAxesRadius (const Standard_Real theRadius)
198 if (Abs (myAxesRadius - theRadius) > Precision::Confusion())
200 myAxesRadius = theRadius;
205 //! Returns radius of cone of axes of the trihedron; 3.0 by default.
206 Standard_Real AxesConeRadius() const { return myAxesConeRadius; }
208 //! Sets radius of cone of axes of the trihedron.
209 void SetAxesConeRadius (Standard_Real theRadius)
211 if (Abs (myAxesConeRadius - theRadius) > Precision::Confusion())
213 myAxesConeRadius = theRadius;
218 //! Returns radius of sphere (central point) of the trihedron; 4.0 by default.
219 Standard_Real AxesSphereRadius() const { return myAxesSphereRadius; }
221 //! Sets radius of sphere (central point) of the trihedron.
222 void SetAxesSphereRadius (Standard_Real theRadius)
224 if (Abs (myAxesSphereRadius - theRadius) > Precision::Confusion())
226 myAxesSphereRadius = theRadius;
231 //! @return TRUE if trihedron is drawn; TRUE by default.
232 Standard_Boolean ToDrawAxes() const { return myToDisplayAxes; }
234 //! Enable/disable drawing of trihedron.
235 void SetDrawAxes (Standard_Boolean theValue)
237 if (myToDisplayAxes != theValue)
239 myToDisplayAxes = theValue;
244 //! @return TRUE if edges of View Cube is drawn; TRUE by default.
245 Standard_Boolean ToDrawEdges() const { return myToDisplayEdges; }
247 //! Enable/disable drawing of edges of View Cube.
248 void SetDrawEdges (Standard_Boolean theValue)
250 if (myToDisplayEdges != theValue)
252 myToDisplayEdges = theValue;
257 //! Return TRUE if vertices (vertex) of View Cube is drawn; TRUE by default.
258 Standard_Boolean ToDrawVertices() const { return myToDisplayVertices; }
260 //! Enable/disable drawing of vertices (corners) of View Cube.
261 void SetDrawVertices (Standard_Boolean theValue)
263 if (myToDisplayVertices != theValue)
265 myToDisplayVertices = theValue;
270 //! Return TRUE if application expects Y-up viewer orientation instead of Z-up; FALSE by default.
271 Standard_Boolean IsYup() const { return myIsYup; }
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);
277 public: //! @name Style management API
279 //! Return shading style of box sides.
280 const Handle(Prs3d_ShadingAspect)& BoxSideStyle() const { return myDrawer->ShadingAspect(); }
282 //! Return shading style of box edges.
283 const Handle(Prs3d_ShadingAspect)& BoxEdgeStyle() const { return myBoxEdgeAspect; }
285 //! Return shading style of box corners.
286 const Handle(Prs3d_ShadingAspect)& BoxCornerStyle() const { return myBoxCornerAspect; }
288 //! Return value of front color for the 3D part of object.
289 const Quantity_Color& BoxColor() const { return myDrawer->ShadingAspect()->Color(); }
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)
295 if (!myDrawer->ShadingAspect()->Color().IsEqual (theColor)
296 || !myBoxEdgeAspect ->Color().IsEqual (theColor)
297 || !myBoxCornerAspect->Color().IsEqual (theColor))
299 myDrawer->ShadingAspect()->SetColor (theColor);
300 myBoxEdgeAspect->SetColor (theColor);
301 myBoxCornerAspect->SetColor (theColor);
302 SynchronizeAspects();
306 //! Return transparency for 3D part of object.
307 Standard_Real BoxTransparency() const { return myDrawer->ShadingAspect()->Transparency(); }
309 //! Set new value of transparency for 3D part of object.
310 //! @param theValue [in] input transparency value
311 void SetBoxTransparency (Standard_Real theValue)
313 if (Abs (myDrawer->ShadingAspect()->Transparency() - theValue) > Precision::Confusion()
314 || Abs (myBoxEdgeAspect ->Transparency() - theValue) > Precision::Confusion()
315 || Abs (myBoxCornerAspect->Transparency() - theValue) > Precision::Confusion())
317 myDrawer->ShadingAspect()->SetTransparency (theValue);
318 myBoxEdgeAspect->SetTransparency (theValue);
319 myBoxCornerAspect->SetTransparency (theValue);
320 SynchronizeAspects();
324 //! Return color of sides back material.
325 const Quantity_Color& InnerColor() const { return myDrawer->ShadingAspect()->Color (Aspect_TOFM_BACK_SIDE); }
327 //! Set color of sides back material. Alias for:
328 //! @code Attributes()->ShadingAspect()->Aspect()->ChangeBackMaterial().SetColor() @endcode
329 void SetInnerColor (const Quantity_Color& theColor)
331 myDrawer->ShadingAspect()->SetColor (theColor, Aspect_TOFM_BACK_SIDE);
332 SynchronizeAspects();
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
339 const TCollection_AsciiString* aLabel = myBoxSideLabels.Seek (theSide);
340 return aLabel != NULL ? *aLabel : TCollection_AsciiString();
343 //! Set box side label.
344 void SetBoxSideLabel (const V3d_TypeOfOrientation theSide,
345 const TCollection_AsciiString& theLabel)
347 if (!IsBoxSide (theSide))
349 throw Standard_ProgramError ("AIS_ViewCube::SetBoxSideLabel(), invalid enumeration value");
351 myBoxSideLabels.Bind (theSide, theLabel);
355 //! Return text color of labels of box sides; BLACK by default.
356 const Quantity_Color& TextColor() const { return myDrawer->TextAspect()->Aspect()->Color(); }
358 //! Set color of text labels on box sides. Alias for:
359 //! @code Attributes()->TextAspect()->SetColor() @endcode
360 void SetTextColor (const Quantity_Color& theColor)
362 myDrawer->TextAspect()->SetColor (theColor);
363 SynchronizeAspects();
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(); }
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)
374 myDrawer->TextAspect()->Aspect()->SetFont (theFont);
375 SynchronizeAspects();
378 //! Return height of font
379 Standard_Real FontHeight() const { return myDrawer->TextAspect()->Height(); }
381 //! Change font height. Alias for:
382 //! @code Attributes()->TextAspect()->SetHeight() @endcode
383 void SetFontHeight (Standard_Real theValue)
385 if (Abs (myDrawer->TextAspect()->Height() - theValue) > Precision::Confusion())
387 myDrawer->TextAspect()->SetHeight (theValue);
392 //! Return axes labels or empty string if undefined.
393 //! Default labels: X, Y, Z.
394 TCollection_AsciiString AxisLabel (Prs3d_DatumParts theAxis) const
396 const TCollection_AsciiString* aLabel = myAxesLabels.Seek (theAxis);
397 return aLabel != NULL ? *aLabel : TCollection_AsciiString();
401 void SetAxesLabels (const TCollection_AsciiString& theX,
402 const TCollection_AsciiString& theY,
403 const TCollection_AsciiString& theZ)
405 myAxesLabels.Bind (Prs3d_DP_XAxis, theX);
406 myAxesLabels.Bind (Prs3d_DP_YAxis, theY);
407 myAxesLabels.Bind (Prs3d_DP_ZAxis, theZ);
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
417 SetBoxColor (theColor);
420 //! Reset color for the whole object.
421 virtual void UnsetColor() Standard_OVERRIDE
423 myDrawer->ShadingAspect()->SetColor (Quantity_NOC_WHITE);
424 myBoxEdgeAspect ->SetColor (Quantity_NOC_GRAY30);
425 myBoxCornerAspect->SetColor (Quantity_NOC_GRAY30);
426 SynchronizeAspects();
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
433 SetBoxTransparency (theValue);
436 //! Reset transparency for the whole object.
437 virtual void UnsetTransparency() Standard_OVERRIDE
439 SetBoxTransparency (0.0f);
442 //! Sets the material for the interactive object.
443 virtual void SetMaterial (const Graphic3d_MaterialAspect& theMat) Standard_OVERRIDE
445 myDrawer->ShadingAspect()->SetMaterial (theMat);
446 myBoxEdgeAspect ->SetMaterial (theMat);
447 myBoxCornerAspect->SetMaterial (theMat);
448 SynchronizeAspects();
451 //! Sets the material for the interactive object.
452 virtual void UnsetMaterial() Standard_OVERRIDE
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();
465 public: //! @name animation methods
467 //! Return duration of animation in seconds; 0.5 sec by default
468 Standard_EXPORT Standard_Real Duration() const;
470 //! Set duration of animation.
471 //! @param theValue [in] input value of duration in seconds
472 Standard_EXPORT void SetDuration (Standard_Real theValue);
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; }
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; }
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; }
485 //! Set if animation should fit selected objects or to fit entire scene.
486 void SetFitSelected (Standard_Boolean theToFitSelected) { myToFitSelected = theToFitSelected; }
488 //! @return TRUE if View Cube has unfinished animation of view camera.
489 Standard_EXPORT Standard_Boolean HasAnimation() const;
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);
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);
500 //! Perform camera transformation corresponding to the input detected owner.
501 Standard_EXPORT virtual void HandleClick (const Handle(AIS_ViewCubeOwner)& theOwner);
505 //! Perform internal single step of animation.
506 //! @return FALSE if animation has been finished
507 Standard_EXPORT Standard_Boolean updateAnimation();
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);
515 protected: //! @name protected virtual API
517 //! Method that is called after one step of transformation.
518 virtual void onAfterAnimation() {}
520 //! Method that is called after transformation finish.
521 virtual void onAnimationFinished() {}
523 public: //! @name Presentation computation
525 //! Return TRUE for supported display mode.
526 virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
528 //! Global selection has no meaning for this class.
529 virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const Standard_OVERRIDE { return Handle(SelectMgr_EntityOwner)(); }
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;
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;
547 //! Disables auto highlighting to use HilightSelected() and HilightOwnerWithColor() overridden methods.
548 virtual Standard_Boolean IsAutoHilight() const Standard_OVERRIDE { return Standard_False; }
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 {}
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;
562 //! Method which draws selected owners.
563 Standard_EXPORT virtual void HilightSelected (const Handle(PrsMgr_PresentationManager3d)& thePM,
564 const SelectMgr_SequenceOfOwner& theSeq) Standard_OVERRIDE;
566 //! Set default parameters for visual attributes
568 virtual void UnsetAttributes() Standard_OVERRIDE
570 setDefaultAttributes();
574 //! Set default parameters for dynamic highlighting attributes, reset highlight attributes
575 virtual void UnsetHilightAttributes() Standard_OVERRIDE
577 myHilightDrawer.Nullify();
578 setDefaultHighlightAttributes();
582 protected: //! @name Auxiliary classes to fill presentation with proper primitives
584 //! Create triangulation for a box part - for presentation and selection purposes.
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;
594 //! Create triangulation for a box side.
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;
604 //! Create triangulation for a box edge.
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;
614 //! Create triangulation for a box corner (vertex).
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;
626 //! Create triangulation for a rectangle with round corners.
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);
642 //! Trivial hasher to avoid ambiguity with enumeration type.
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; }
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
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
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
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
673 protected: //! @name Animation options
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
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
685 //! Redefined entity owner that is highlighted when owner is detected,
686 //! even if Interactive Context highlighted on last detection procedure.
687 class AIS_ViewCubeOwner : public SelectMgr_EntityOwner
689 DEFINE_STANDARD_RTTIEXT(AIS_ViewCubeOwner, SelectMgr_EntityOwner)
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)
699 myFromDecomposition = true;
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; }
706 //! Return new orientation to set.
707 V3d_TypeOfOrientation MainOrientation() const { return myMainOrient; }
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
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;
723 V3d_TypeOfOrientation myMainOrient; //!< new orientation to set
727 #endif // _AIS_ViewCube_HeaderFile