Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-26 09:15:41

0001 // Created on: 2017-07-25
0002 // Created by: Anastasia BOBYLEVA
0003 // Copyright (c) 2017-2019 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _AIS_ViewCube_HeaderFile
0017 #define _AIS_ViewCube_HeaderFile
0018 
0019 #include <AIS_InteractiveObject.hxx>
0020 #include <Graphic3d_Camera.hxx>
0021 #include <Graphic3d_Vec2.hxx>
0022 #include <Prs3d_DatumParts.hxx>
0023 #include <Prs3d_ShadingAspect.hxx>
0024 #include <Prs3d_TextAspect.hxx>
0025 #include <SelectMgr_EntityOwner.hxx>
0026 #include <V3d_TypeOfOrientation.hxx>
0027 #include <Select3D_SensitivePrimitiveArray.hxx>
0028 
0029 class AIS_AnimationCamera;
0030 class AIS_ViewCubeOwner;
0031 class Graphic3d_ArrayOfTriangles;
0032 class V3d_View;
0033 
0034 //! Interactive object for displaying the view manipulation cube.
0035 //!
0036 //! View cube consists of several parts that are responsible for different camera manipulations:
0037 //! @li Cube sides represent main views: top, bottom, left, right, front and back.
0038 //! @li Edges represent rotation of one of main views on 45 degrees.
0039 //! @li Vertices represent rotation of one of man views in two directions.
0040 //!
0041 //! The object is expected to behave like a trihedron in the view corner,
0042 //! therefore its position should be defined using transformation persistence flags:
0043 //! @code SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_TriedronPers,
0044 //! Aspect_TOTP_LEFT_LOWER, Graphic3d_Vec2i (100, 100)); @endcode
0045 //!
0046 //! View Cube parts are sensitive to detection, or dynamic highlighting (but not selection),
0047 //! and every its owner AIS_ViewCubeOwner corresponds to camera transformation.
0048 //! @code
0049 //!   for (aViewCube->StartAnimation (aDetectedOwner); aViewCube->HasAnimation(); )
0050 //!   {
0051 //!     aViewCube->UpdateAnimation();
0052 //!     ... // updating of application window
0053 //!   }
0054 //! @endcode
0055 //! or
0056 //! @code aViewCube->HandleClick (aDetectedOwner); @endcode
0057 //! that includes transformation loop.
0058 //! This loop allows external actions like application updating. For this purpose AIS_ViewCube has
0059 //! virtual interface onAfterAnimation(), that is to be redefined on application level.
0060 class AIS_ViewCube : public AIS_InteractiveObject
0061 {
0062   DEFINE_STANDARD_RTTIEXT(AIS_ViewCube, AIS_InteractiveObject)
0063 public:
0064   //! Return TRUE if specified orientation belongs to box side.
0065   Standard_EXPORT static bool IsBoxSide(V3d_TypeOfOrientation theOrient);
0066 
0067   //! Return TRUE if specified orientation belongs to box edge.
0068   Standard_EXPORT static bool IsBoxEdge(V3d_TypeOfOrientation theOrient);
0069 
0070   //! Return TRUE if specified orientation belongs to box corner (vertex).
0071   Standard_EXPORT static bool IsBoxCorner(V3d_TypeOfOrientation theOrient);
0072 
0073 public:
0074   //! Empty constructor.
0075   Standard_EXPORT AIS_ViewCube();
0076 
0077   //! Return view animation.
0078   const Handle(AIS_AnimationCamera)& ViewAnimation() const { return myViewAnimation; }
0079 
0080   //! Set view animation.
0081   void SetViewAnimation(const Handle(AIS_AnimationCamera)& theAnimation)
0082   {
0083     myViewAnimation = theAnimation;
0084   }
0085 
0086   //! Return TRUE if automatic camera transformation on selection (highlighting) is enabled; TRUE by
0087   //! default.
0088   Standard_Boolean ToAutoStartAnimation() const { return myToAutoStartAnim; }
0089 
0090   //! Enable/disable automatic camera transformation on selection (highlighting).
0091   //! The automatic logic can be disabled if application wants performing action manually
0092   //! basing on picking results (AIS_ViewCubeOwner).
0093   void SetAutoStartAnimation(bool theToEnable) { myToAutoStartAnim = theToEnable; }
0094 
0095   //! Return TRUE if camera animation should be done in uninterruptible loop; TRUE by default.
0096   Standard_Boolean IsFixedAnimationLoop() const { return myIsFixedAnimation; }
0097 
0098   //! Set if camera animation should be done in uninterruptible loop.
0099   void SetFixedAnimationLoop(bool theToEnable) { myIsFixedAnimation = theToEnable; }
0100 
0101   //! Reset all size and style parameters to default.
0102   //! @warning It doesn't reset position of View Cube
0103   Standard_EXPORT void ResetStyles();
0104 
0105 protected:
0106   //! Set default visual attributes
0107   Standard_EXPORT void setDefaultAttributes();
0108 
0109   //! Set default dynamic highlight properties
0110   Standard_EXPORT void setDefaultHighlightAttributes();
0111 
0112 public: //! @name Geometry management API
0113   //! @return size (width and height) of View cube sides; 100 by default.
0114   Standard_Real Size() const { return mySize; }
0115 
0116   //! Sets size (width and height) of View cube sides.
0117   //! @param theToAdaptAnother if TRUE, then other parameters will be adapted to specified size
0118   Standard_EXPORT void SetSize(Standard_Real theValue, Standard_Boolean theToAdaptAnother = true);
0119 
0120   //! Return box facet extension to edge/corner facet split; 10 by default.
0121   Standard_Real BoxFacetExtension() const { return myBoxFacetExtension; }
0122 
0123   //! Set new value of box facet extension.
0124   void SetBoxFacetExtension(Standard_Real theValue)
0125   {
0126     if (Abs(myBoxFacetExtension - theValue) > Precision::Confusion())
0127     {
0128       myBoxFacetExtension = theValue;
0129       SetToUpdate();
0130     }
0131   }
0132 
0133   //! Return padding between axes and 3D part (box); 10 by default.
0134   Standard_Real AxesPadding() const { return myAxesPadding; }
0135 
0136   //! Set new value of padding between axes and 3D part (box).
0137   void SetAxesPadding(Standard_Real theValue)
0138   {
0139     if (Abs(myAxesPadding - theValue) > Precision::Confusion())
0140     {
0141       myAxesPadding = theValue;
0142       SetToUpdate();
0143     }
0144   }
0145 
0146   //! Return gap between box edges and box sides; 0 by default.
0147   Standard_Real BoxEdgeGap() const { return myBoxEdgeGap; }
0148 
0149   //! Set new value of box edges gap.
0150   void SetBoxEdgeGap(Standard_Real theValue)
0151   {
0152     if (Abs(myBoxEdgeGap - theValue) > Precision::Confusion())
0153     {
0154       myBoxEdgeGap = theValue;
0155       SetToUpdate();
0156     }
0157   }
0158 
0159   //! Return minimal size of box edge; 2 by default.
0160   Standard_Real BoxEdgeMinSize() const { return myBoxEdgeMinSize; }
0161 
0162   //! Set new value of box edge minimal size.
0163   void SetBoxEdgeMinSize(Standard_Real theValue)
0164   {
0165     if (Abs(myBoxEdgeMinSize - theValue) > Precision::Confusion())
0166     {
0167       myBoxEdgeMinSize = theValue;
0168       SetToUpdate();
0169     }
0170   }
0171 
0172   //! Return minimal size of box corner; 2 by default.
0173   Standard_Real BoxCornerMinSize() const { return myCornerMinSize; }
0174 
0175   //! Set new value of box corner minimal size.
0176   void SetBoxCornerMinSize(Standard_Real theValue)
0177   {
0178     if (Abs(myCornerMinSize - theValue) > Precision::Confusion())
0179     {
0180       myCornerMinSize = theValue;
0181       SetToUpdate();
0182     }
0183   }
0184 
0185   //! Return relative radius of side corners (round rectangle); 0.0 by default.
0186   //! The value in within [0, 0.5] range meaning absolute radius = RoundRadius() / Size().
0187   Standard_Real RoundRadius() const { return myRoundRadius; }
0188 
0189   //! Set relative radius of View Cube sides corners (round rectangle).
0190   //! The value should be within [0, 0.5] range.
0191   Standard_EXPORT void SetRoundRadius(const Standard_Real theValue);
0192 
0193   //! Returns radius of axes of the trihedron; 1.0 by default.
0194   Standard_Real AxesRadius() const { return myAxesRadius; }
0195 
0196   //! Sets radius of axes of the trihedron.
0197   void SetAxesRadius(const Standard_Real theRadius)
0198   {
0199     if (Abs(myAxesRadius - theRadius) > Precision::Confusion())
0200     {
0201       myAxesRadius = theRadius;
0202       SetToUpdate();
0203     }
0204   }
0205 
0206   //! Returns radius of cone of axes of the trihedron; 3.0 by default.
0207   Standard_Real AxesConeRadius() const { return myAxesConeRadius; }
0208 
0209   //! Sets radius of cone of axes of the trihedron.
0210   void SetAxesConeRadius(Standard_Real theRadius)
0211   {
0212     if (Abs(myAxesConeRadius - theRadius) > Precision::Confusion())
0213     {
0214       myAxesConeRadius = theRadius;
0215       SetToUpdate();
0216     }
0217   }
0218 
0219   //! Returns radius of sphere (central point) of the trihedron; 4.0 by default.
0220   Standard_Real AxesSphereRadius() const { return myAxesSphereRadius; }
0221 
0222   //! Sets radius of sphere (central point) of the trihedron.
0223   void SetAxesSphereRadius(Standard_Real theRadius)
0224   {
0225     if (Abs(myAxesSphereRadius - theRadius) > Precision::Confusion())
0226     {
0227       myAxesSphereRadius = theRadius;
0228       SetToUpdate();
0229     }
0230   }
0231 
0232   //! @return TRUE if trihedron is drawn; TRUE by default.
0233   Standard_Boolean ToDrawAxes() const { return myToDisplayAxes; }
0234 
0235   //! Enable/disable drawing of trihedron.
0236   void SetDrawAxes(Standard_Boolean theValue)
0237   {
0238     if (myToDisplayAxes != theValue)
0239     {
0240       myToDisplayAxes = theValue;
0241       SetToUpdate();
0242     }
0243   }
0244 
0245   //! @return TRUE if edges of View Cube is drawn; TRUE by default.
0246   Standard_Boolean ToDrawEdges() const { return myToDisplayEdges; }
0247 
0248   //! Enable/disable drawing of edges of View Cube.
0249   void SetDrawEdges(Standard_Boolean theValue)
0250   {
0251     if (myToDisplayEdges != theValue)
0252     {
0253       myToDisplayEdges = theValue;
0254       SetToUpdate();
0255     }
0256   }
0257 
0258   //! Return TRUE if vertices (vertex) of View Cube is drawn; TRUE by default.
0259   Standard_Boolean ToDrawVertices() const { return myToDisplayVertices; }
0260 
0261   //! Enable/disable drawing of vertices (corners) of View Cube.
0262   void SetDrawVertices(Standard_Boolean theValue)
0263   {
0264     if (myToDisplayVertices != theValue)
0265     {
0266       myToDisplayVertices = theValue;
0267       SetToUpdate();
0268     }
0269   }
0270 
0271   //! Return TRUE if application expects Y-up viewer orientation instead of Z-up; FALSE by default.
0272   Standard_Boolean IsYup() const { return myIsYup; }
0273 
0274   //! Set if application expects Y-up viewer orientation instead of Z-up.
0275   Standard_EXPORT void SetYup(Standard_Boolean theIsYup,
0276                               Standard_Boolean theToUpdateLabels = Standard_True);
0277 
0278 public: //! @name Style management API
0279   //! Return shading style of box sides.
0280   const Handle(Prs3d_ShadingAspect)& BoxSideStyle() const { return myDrawer->ShadingAspect(); }
0281 
0282   //! Return shading style of box edges.
0283   const Handle(Prs3d_ShadingAspect)& BoxEdgeStyle() const { return myBoxEdgeAspect; }
0284 
0285   //! Return shading style of box corners.
0286   const Handle(Prs3d_ShadingAspect)& BoxCornerStyle() const { return myBoxCornerAspect; }
0287 
0288   //! Return value of front color for the 3D part of object.
0289   const Quantity_Color& BoxColor() const { return myDrawer->ShadingAspect()->Color(); }
0290 
0291   //! Set new value of front color for the 3D part of object.
0292   //! @param[in] theColor  input color value.
0293   void SetBoxColor(const Quantity_Color& theColor)
0294   {
0295     if (!myDrawer->ShadingAspect()->Color().IsEqual(theColor)
0296         || !myBoxEdgeAspect->Color().IsEqual(theColor)
0297         || !myBoxCornerAspect->Color().IsEqual(theColor))
0298     {
0299       myDrawer->ShadingAspect()->SetColor(theColor);
0300       myBoxEdgeAspect->SetColor(theColor);
0301       myBoxCornerAspect->SetColor(theColor);
0302       SynchronizeAspects();
0303     }
0304   }
0305 
0306   //! Return transparency for 3D part of object.
0307   Standard_Real BoxTransparency() const { return myDrawer->ShadingAspect()->Transparency(); }
0308 
0309   //! Set new value of transparency for 3D part of object.
0310   //! @param[in] theValue  input transparency value
0311   void SetBoxTransparency(Standard_Real theValue)
0312   {
0313     if (Abs(myDrawer->ShadingAspect()->Transparency() - theValue) > Precision::Confusion()
0314         || Abs(myBoxEdgeAspect->Transparency() - theValue) > Precision::Confusion()
0315         || Abs(myBoxCornerAspect->Transparency() - theValue) > Precision::Confusion())
0316     {
0317       myDrawer->ShadingAspect()->SetTransparency(theValue);
0318       myBoxEdgeAspect->SetTransparency(theValue);
0319       myBoxCornerAspect->SetTransparency(theValue);
0320       SynchronizeAspects();
0321     }
0322   }
0323 
0324   //! Return color of sides back material.
0325   const Quantity_Color& InnerColor() const
0326   {
0327     return myDrawer->ShadingAspect()->Color(Aspect_TOFM_BACK_SIDE);
0328   }
0329 
0330   //! Set color of sides back material. Alias for:
0331   //! @code Attributes()->ShadingAspect()->Aspect()->ChangeBackMaterial().SetColor() @endcode
0332   void SetInnerColor(const Quantity_Color& theColor)
0333   {
0334     myDrawer->ShadingAspect()->SetColor(theColor, Aspect_TOFM_BACK_SIDE);
0335     SynchronizeAspects();
0336   }
0337 
0338   //! Return box side label or empty string if undefined.
0339   //! Default labels: FRONT, BACK, LEFT, RIGHT, TOP, BOTTOM.
0340   TCollection_AsciiString BoxSideLabel(V3d_TypeOfOrientation theSide) const
0341   {
0342     const TCollection_AsciiString* aLabel = myBoxSideLabels.Seek(theSide);
0343     return aLabel != NULL ? *aLabel : TCollection_AsciiString();
0344   }
0345 
0346   //! Set box side label.
0347   void SetBoxSideLabel(const V3d_TypeOfOrientation theSide, const TCollection_AsciiString& theLabel)
0348   {
0349     if (!IsBoxSide(theSide))
0350     {
0351       throw Standard_ProgramError("AIS_ViewCube::SetBoxSideLabel(), invalid enumeration value");
0352     }
0353     myBoxSideLabels.Bind(theSide, theLabel);
0354     SetToUpdate();
0355   }
0356 
0357   //! Return text color of labels of box sides; BLACK by default.
0358   const Quantity_Color& TextColor() const { return myDrawer->TextAspect()->Aspect()->Color(); }
0359 
0360   //! Set color of text labels on box sides. Alias for:
0361   //! @code Attributes()->TextAspect()->SetColor() @endcode
0362   void SetTextColor(const Quantity_Color& theColor)
0363   {
0364     myDrawer->TextAspect()->SetColor(theColor);
0365     SynchronizeAspects();
0366   }
0367 
0368   //! Return font name that is used for displaying of sides and axes text. Alias for:
0369   //! @code Attributes()->TextAspect()->Aspect()->SetFont() @endcode
0370   const TCollection_AsciiString& Font() const { return myDrawer->TextAspect()->Aspect()->Font(); }
0371 
0372   //! Set font name that is used for displaying of sides and axes text. Alias for:
0373   //! @code Attributes()->TextAspect()->SetFont() @endcode
0374   void SetFont(const TCollection_AsciiString& theFont)
0375   {
0376     myDrawer->TextAspect()->Aspect()->SetFont(theFont);
0377     SynchronizeAspects();
0378   }
0379 
0380   //! Return height of font
0381   Standard_Real FontHeight() const { return myDrawer->TextAspect()->Height(); }
0382 
0383   //! Change font height. Alias for:
0384   //! @code Attributes()->TextAspect()->SetHeight() @endcode
0385   void SetFontHeight(Standard_Real theValue)
0386   {
0387     if (Abs(myDrawer->TextAspect()->Height() - theValue) > Precision::Confusion())
0388     {
0389       myDrawer->TextAspect()->SetHeight(theValue);
0390       SetToUpdate();
0391     }
0392   }
0393 
0394   //! Return axes labels or empty string if undefined.
0395   //! Default labels: X, Y, Z.
0396   TCollection_AsciiString AxisLabel(Prs3d_DatumParts theAxis) const
0397   {
0398     const TCollection_AsciiString* aLabel = myAxesLabels.Seek(theAxis);
0399     return aLabel != NULL ? *aLabel : TCollection_AsciiString();
0400   }
0401 
0402   //! Set axes labels.
0403   void SetAxesLabels(const TCollection_AsciiString& theX,
0404                      const TCollection_AsciiString& theY,
0405                      const TCollection_AsciiString& theZ)
0406   {
0407     myAxesLabels.Bind(Prs3d_DatumParts_XAxis, theX);
0408     myAxesLabels.Bind(Prs3d_DatumParts_YAxis, theY);
0409     myAxesLabels.Bind(Prs3d_DatumParts_ZAxis, theZ);
0410     SetToUpdate();
0411   }
0412 
0413 public:
0414   //! Set new value of color for the whole object.
0415   //! @param[in] theColor  input color value.
0416   virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE { SetBoxColor(theColor); }
0417 
0418   //! Reset color for the whole object.
0419   virtual void UnsetColor() Standard_OVERRIDE
0420   {
0421     myDrawer->ShadingAspect()->SetColor(Quantity_NOC_WHITE);
0422     myBoxEdgeAspect->SetColor(Quantity_NOC_GRAY30);
0423     myBoxCornerAspect->SetColor(Quantity_NOC_GRAY30);
0424     SynchronizeAspects();
0425   }
0426 
0427   //! Set new value of transparency for the whole object.
0428   //! @param[in] theValue  input transparency value.
0429   virtual void SetTransparency(const Standard_Real theValue) Standard_OVERRIDE
0430   {
0431     SetBoxTransparency(theValue);
0432   }
0433 
0434   //! Reset transparency for the whole object.
0435   virtual void UnsetTransparency() Standard_OVERRIDE { SetBoxTransparency(0.0f); }
0436 
0437   //! Sets the material for the interactive object.
0438   virtual void SetMaterial(const Graphic3d_MaterialAspect& theMat) Standard_OVERRIDE
0439   {
0440     myDrawer->ShadingAspect()->SetMaterial(theMat);
0441     myBoxEdgeAspect->SetMaterial(theMat);
0442     myBoxCornerAspect->SetMaterial(theMat);
0443     SynchronizeAspects();
0444   }
0445 
0446   //! Sets the material for the interactive object.
0447   virtual void UnsetMaterial() Standard_OVERRIDE
0448   {
0449     Graphic3d_MaterialAspect aMat(Graphic3d_NameOfMaterial_UserDefined);
0450     aMat.SetColor(Quantity_NOC_WHITE);
0451     aMat.SetAmbientColor(Quantity_NOC_GRAY60);
0452     myDrawer->ShadingAspect()->SetMaterial(aMat);
0453     myBoxEdgeAspect->SetMaterial(aMat);
0454     myBoxEdgeAspect->SetColor(Quantity_NOC_GRAY30);
0455     myBoxCornerAspect->SetMaterial(aMat);
0456     myBoxCornerAspect->SetColor(Quantity_NOC_GRAY30);
0457     SynchronizeAspects();
0458   }
0459 
0460 public: //! @name animation methods
0461   //! Return duration of animation in seconds; 0.5 sec by default
0462   Standard_EXPORT Standard_Real Duration() const;
0463 
0464   //! Set duration of animation.
0465   //! @param[in] theValue  input value of duration in seconds
0466   Standard_EXPORT void SetDuration(Standard_Real theValue);
0467 
0468   //! Return TRUE if new camera Up direction should be always set to default value for a new camera
0469   //! Direction; FALSE by default. When this flag is FALSE, the new camera Up will be set as current
0470   //! Up orthogonalized to the new camera Direction, and will set to default Up on second click.
0471   Standard_Boolean ToResetCameraUp() const { return myToResetCameraUp; }
0472 
0473   //! Set if new camera Up direction should be always set to default value for a new camera
0474   //! Direction.
0475   void SetResetCamera(Standard_Boolean theToReset) { myToResetCameraUp = theToReset; }
0476 
0477   //! Return TRUE if animation should fit selected objects and FALSE to fit entire scene; TRUE by
0478   //! default.
0479   Standard_Boolean ToFitSelected() const { return myToFitSelected; }
0480 
0481   //! Set if animation should fit selected objects or to fit entire scene.
0482   void SetFitSelected(Standard_Boolean theToFitSelected) { myToFitSelected = theToFitSelected; }
0483 
0484   //! @return TRUE if View Cube has unfinished animation of view camera.
0485   Standard_EXPORT Standard_Boolean HasAnimation() const;
0486 
0487   //! Start camera transformation corresponding to the input detected owner.
0488   //! @param[in] theOwner  detected owner.
0489   Standard_EXPORT virtual void StartAnimation(const Handle(AIS_ViewCubeOwner)& theOwner);
0490 
0491   //! Perform one step of current camera transformation.
0492   //! theToUpdate[in]  enable/disable update of view.
0493   //! @return TRUE if animation is not stopped.
0494   Standard_EXPORT virtual Standard_Boolean UpdateAnimation(const Standard_Boolean theToUpdate);
0495 
0496   //! Perform camera transformation corresponding to the input detected owner.
0497   Standard_EXPORT virtual void HandleClick(const Handle(AIS_ViewCubeOwner)& theOwner);
0498 
0499 protected:
0500   //! Perform internal single step of animation.
0501   //! @return FALSE if animation has been finished
0502   Standard_EXPORT Standard_Boolean updateAnimation();
0503 
0504   //! Fit selected/all into view.
0505   //! @param[in] theView  view definition to retrieve scene bounding box
0506   //! @param theCamera [in,out] camera definition
0507   Standard_EXPORT virtual void viewFitAll(const Handle(V3d_View)&         theView,
0508                                           const Handle(Graphic3d_Camera)& theCamera);
0509 
0510 protected: //! @name protected virtual API
0511   //! Method that is called after one step of transformation.
0512   virtual void onAfterAnimation() {}
0513 
0514   //! Method that is called after transformation finish.
0515   virtual void onAnimationFinished() {}
0516 
0517 public: //! @name Presentation computation
0518   //! Return TRUE for supported display mode.
0519   virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE
0520   {
0521     return theMode == 0;
0522   }
0523 
0524   //! Global selection has no meaning for this class.
0525   virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const Standard_OVERRIDE
0526   {
0527     return Handle(SelectMgr_EntityOwner)();
0528   }
0529 
0530   //! Compute 3D part of View Cube.
0531   //! @param[in] thePrsMgr  presentation manager.
0532   //! @param[in] thePrs  input presentation that is to be filled with flat presentation primitives.
0533   //! @param[in] theMode  display mode.
0534   //! @warning this object accept only 0 display mode.
0535   Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
0536                                        const Handle(Prs3d_Presentation)&         thePrs,
0537                                        const Standard_Integer theMode = 0) Standard_OVERRIDE;
0538 
0539   //! Redefine computing of sensitive entities for View Cube.
0540   //! @param[in] theSelection  input selection object that is to be filled with sensitive entities.
0541   //! @param[in] theMode  selection mode.
0542   //! @warning object accepts only 0 selection mode.
0543   Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
0544                                                 const Standard_Integer theMode) Standard_OVERRIDE;
0545 
0546   //! Disables auto highlighting to use HilightSelected() and HilightOwnerWithColor() overridden
0547   //! methods.
0548   virtual Standard_Boolean IsAutoHilight() const Standard_OVERRIDE { return Standard_False; }
0549 
0550   //! Method which clear all selected owners belonging to this selectable object.
0551   //! @warning this object does not support selection.
0552   virtual void ClearSelected() Standard_OVERRIDE {}
0553 
0554   //! Method which highlights input owner belonging to this selectable object.
0555   //! @param[in] thePM  presentation manager
0556   //! @param[in] theStyle  style for dynamic highlighting.
0557   //! @param[in] theOwner  input entity owner.
0558   Standard_EXPORT virtual void HilightOwnerWithColor(
0559     const Handle(PrsMgr_PresentationManager)& thePM,
0560     const Handle(Prs3d_Drawer)&               theStyle,
0561     const Handle(SelectMgr_EntityOwner)&      theOwner) Standard_OVERRIDE;
0562 
0563   //! Method which draws selected owners.
0564   Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager)& thePM,
0565                                                const SelectMgr_SequenceOfOwner&          theSeq)
0566     Standard_OVERRIDE;
0567 
0568   //! Set default parameters for visual attributes
0569   //! @sa Attributes()
0570   virtual void UnsetAttributes() Standard_OVERRIDE
0571   {
0572     setDefaultAttributes();
0573     SetToUpdate();
0574   }
0575 
0576   //! Set default parameters for dynamic highlighting attributes, reset highlight attributes
0577   virtual void UnsetHilightAttributes() Standard_OVERRIDE
0578   {
0579     myHilightDrawer.Nullify();
0580     setDefaultHighlightAttributes();
0581     SetToUpdate();
0582   }
0583 
0584 protected: //! @name Auxiliary classes to fill presentation with proper primitives
0585   //! Create triangulation for a box part - for presentation and selection purposes.
0586   //! @param theTris    [in,out] triangulation to fill, or NULL to return size
0587   //! @param theNbNodes [in,out] should be incremented by a number of nodes defining this
0588   //! triangulation
0589   //! @param theNbTris  [in,out] should be incremented by a number of triangles defining this
0590   //! triangulation
0591   //! @param[in] theDir      part to define
0592   Standard_EXPORT virtual void createBoxPartTriangles(
0593     const Handle(Graphic3d_ArrayOfTriangles)& theTris,
0594     Standard_Integer&                         theNbNodes,
0595     Standard_Integer&                         theNbTris,
0596     V3d_TypeOfOrientation                     theDir) const;
0597 
0598   //! Create triangulation for a box side.
0599   //! @param theTris    [in,out] triangulation to fill, or NULL to return size
0600   //! @param theNbNodes [in,out] should be incremented by a number of nodes defining this
0601   //! triangulation
0602   //! @param theNbTris  [in,out] should be incremented by a number of triangles defining this
0603   //! triangulation
0604   //! @param[in] theDir      part to define
0605   Standard_EXPORT virtual void createBoxSideTriangles(
0606     const Handle(Graphic3d_ArrayOfTriangles)& theTris,
0607     Standard_Integer&                         theNbNodes,
0608     Standard_Integer&                         theNbTris,
0609     V3d_TypeOfOrientation                     theDir) const;
0610 
0611   //! Create triangulation for a box edge.
0612   //! @param theTris    [in,out] triangulation to fill, or NULL to return size
0613   //! @param theNbNodes [in,out] should be incremented by a number of nodes defining this
0614   //! triangulation
0615   //! @param theNbTris  [in,out] should be incremented by a number of triangles defining this
0616   //! triangulation
0617   //! @param[in] theDir      part to define
0618   Standard_EXPORT virtual void createBoxEdgeTriangles(
0619     const Handle(Graphic3d_ArrayOfTriangles)& theTris,
0620     Standard_Integer&                         theNbNodes,
0621     Standard_Integer&                         theNbTris,
0622     V3d_TypeOfOrientation                     theDir) const;
0623 
0624   //! Create triangulation for a box corner (vertex).
0625   //! @param theTris    [in,out] triangulation to fill, or NULL to return size
0626   //! @param theNbNodes [in,out] should be incremented by a number of nodes defining this
0627   //! triangulation
0628   //! @param theNbTris  [in,out] should be incremented by a number of triangles defining this
0629   //! triangulation
0630   //! @param[in] theDir      part to define
0631   Standard_EXPORT virtual void createBoxCornerTriangles(
0632     const Handle(Graphic3d_ArrayOfTriangles)& theTris,
0633     Standard_Integer&                         theNbNodes,
0634     Standard_Integer&                         theNbTris,
0635     V3d_TypeOfOrientation                     theDir) const;
0636 
0637 protected:
0638   //! Create triangulation for a rectangle with round corners.
0639   //! @param theTris    [in,out] triangulation to fill, or NULL to return size
0640   //! @param theNbNodes [in,out] should be incremented by a number of nodes defining this
0641   //! triangulation
0642   //! @param theNbTris  [in,out] should be incremented by a number of triangles defining this
0643   //! triangulation
0644   //! @param[in] theSize     rectangle dimensions
0645   //! @param[in] theRadius   radius at corners
0646   //! @param[in] theTrsf     transformation
0647   Standard_EXPORT static void createRoundRectangleTriangles(
0648     const Handle(Graphic3d_ArrayOfTriangles)& theTris,
0649     Standard_Integer&                         theNbNodes,
0650     Standard_Integer&                         theNbTris,
0651     const gp_XY&                              theSize,
0652     Standard_Real                             theRadius,
0653     const gp_Trsf&                            theTrsf);
0654 
0655 protected:
0656   NCollection_DataMap<V3d_TypeOfOrientation, TCollection_AsciiString>
0657     myBoxSideLabels; //!< map with box side labels
0658   NCollection_DataMap<Prs3d_DatumParts, TCollection_AsciiString>
0659                               myAxesLabels;      //!< map with axes labels
0660   Handle(Prs3d_ShadingAspect) myBoxEdgeAspect;   //!< style for box edges
0661   Handle(Prs3d_ShadingAspect) myBoxCornerAspect; //!< style for box corner
0662 
0663   Standard_Real mySize;              //!< size of box side, length of one axis
0664   Standard_Real myBoxEdgeMinSize;    //!< minimal size of box edge
0665   Standard_Real myBoxEdgeGap;        //!< gap between box side and box edge
0666   Standard_Real myBoxFacetExtension; //!< box facet extension
0667   Standard_Real myAxesPadding;       //!< Padding between box and axes
0668   // clang-format off
0669   Standard_Real                 myAxesRadius;        //!< radius of axes of the trihedron; 1.0 by default
0670   Standard_Real                 myAxesConeRadius;    //!< radius of cone of axes of the trihedron; 3.0 by default
0671   Standard_Real                 myAxesSphereRadius;  //!< radius of sphere (central point) of the trihedron; 4.0 by default
0672   Standard_Real                 myCornerMinSize;     //!< minimal size of box corner
0673   Standard_Real                 myRoundRadius;       //!< relative round radius within [0; 0.5] range
0674   Standard_Boolean              myToDisplayAxes;     //!< trihedron visibility
0675   Standard_Boolean              myToDisplayEdges;    //!< box edges visibility
0676   Standard_Boolean              myToDisplayVertices; //!< box corners (vertices) visibility
0677   Standard_Boolean              myIsYup;             //!< flag indicating that application expects Y-up viewer orientation instead of Z-up
0678   // clang-format on
0679 
0680 protected:                                        //! @name Animation options
0681   Handle(AIS_AnimationCamera) myViewAnimation;    //!< Camera animation object
0682   Handle(Graphic3d_Camera)    myStartState;       //!< Start state of view camera
0683   Handle(Graphic3d_Camera)    myEndState;         //!< End state of view camera
0684   Standard_Boolean            myToAutoStartAnim;  //!< start animation automatically on click
0685   Standard_Boolean            myIsFixedAnimation; //!< fixed-loop animation
0686   Standard_Boolean            myToFitSelected;    //!< fit selected or fit entire scene
0687   // clang-format off
0688   Standard_Boolean              myToResetCameraUp;   //!< always reset camera up direction to default
0689   // clang-format on
0690 };
0691 
0692 //! Redefined entity owner that is highlighted when owner is detected,
0693 //! even if Interactive Context highlighted on last detection procedure.
0694 class AIS_ViewCubeOwner : public SelectMgr_EntityOwner
0695 {
0696   DEFINE_STANDARD_RTTIEXT(AIS_ViewCubeOwner, SelectMgr_EntityOwner)
0697 public:
0698   //! Main constructor.
0699   AIS_ViewCubeOwner(const Handle(AIS_ViewCube)& theObject,
0700                     V3d_TypeOfOrientation       theOrient,
0701                     Standard_Integer            thePriority = 5)
0702       : SelectMgr_EntityOwner((const Handle(SelectMgr_SelectableObject)&)theObject, thePriority),
0703         myMainOrient(theOrient)
0704   {
0705     myFromDecomposition = true;
0706   }
0707 
0708   //! @return TRUE. This owner will always call method
0709   //! Hilight for its Selectable Object when the owner is detected.
0710   virtual Standard_Boolean IsForcedHilight() const Standard_OVERRIDE { return Standard_True; }
0711 
0712   //! Return new orientation to set.
0713   V3d_TypeOfOrientation MainOrientation() const { return myMainOrient; }
0714 
0715   //! Handle mouse button click event.
0716   virtual Standard_Boolean HandleMouseClick(const Graphic3d_Vec2i& thePoint,
0717                                             Aspect_VKeyMouse       theButton,
0718                                             Aspect_VKeyFlags       theModifiers,
0719                                             bool theIsDoubleClick) Standard_OVERRIDE
0720   {
0721     (void)thePoint;
0722     (void)theButton;
0723     (void)theModifiers;
0724     (void)theIsDoubleClick;
0725     AIS_ViewCube* aCubePrs = dynamic_cast<AIS_ViewCube*>(mySelectable);
0726     aCubePrs->HandleClick(this);
0727     return Standard_True;
0728   }
0729 
0730 protected:
0731   V3d_TypeOfOrientation myMainOrient; //!< new orientation to set
0732 };
0733 
0734 //! Simple sensitive element for picking by point only.
0735 class AIS_ViewCubeSensitive : public Select3D_SensitivePrimitiveArray
0736 {
0737   DEFINE_STANDARD_RTTIEXT(AIS_ViewCubeSensitive, Select3D_SensitivePrimitiveArray)
0738 public:
0739   //! Constructor.
0740   Standard_EXPORT AIS_ViewCubeSensitive(const Handle(SelectMgr_EntityOwner)&      theOwner,
0741                                         const Handle(Graphic3d_ArrayOfTriangles)& theTris);
0742 
0743   //! Checks whether element overlaps current selecting volume.
0744   Standard_EXPORT virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr,
0745                                                    SelectBasics_PickResult& thePickResult)
0746     Standard_OVERRIDE;
0747 
0748 protected:
0749   //! Checks if picking ray can be used for detection.
0750   Standard_EXPORT bool isValidRay(const SelectBasics_SelectingVolumeManager& theMgr) const;
0751 };
0752 
0753 #endif // _AIS_ViewCube_HeaderFile