Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-24 09:13:01

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