]> OCCT Git - occt-copy.git/commitdiff
remarks from kgv
authormzernova <mzernova@opencascade.com>
Tue, 29 Sep 2020 12:36:04 +0000 (15:36 +0300)
committermzernova <mzernova@opencascade.com>
Fri, 23 Oct 2020 12:19:13 +0000 (15:19 +0300)
src/AIS/AIS_Manipulator.cxx
src/AIS/AIS_Manipulator.hxx
src/ViewerTest/ViewerTest_ViewerCommands.cxx

index d82af2a2d4c73349a2020af639cdb5db0fb615c7..a805081607bb1397b29c2e2f2147b7016509e2af 100644 (file)
@@ -225,7 +225,7 @@ AIS_Manipulator::AIS_Manipulator()
   myCurrentMode (AIS_MM_None),
   myIsActivationOnDetection (Standard_False),
   myIsZoomPersistentMode (Standard_True),
-  myIsFlatMode (Standard_False),
+  mySkinMode (AIS_SM_Shaded),
   myHasStartedTransformation (Standard_False),
   myStartPosition (gp::XOY()),
   myStartPick (0.0, 0.0, 0.0),
@@ -247,7 +247,7 @@ AIS_Manipulator::AIS_Manipulator (const gp_Ax2& thePosition)
   myCurrentMode (AIS_MM_None),
   myIsActivationOnDetection (Standard_False),
   myIsZoomPersistentMode (Standard_True),
-  myIsFlatMode (Standard_False),
+  mySkinMode (AIS_SM_Shaded),
   myHasStartedTransformation (Standard_False),
   myStartPosition (gp::XOY()),
   myStartPick (0.0, 0.0, 0.0),
@@ -927,16 +927,16 @@ void AIS_Manipulator::SetZoomPersistence (const Standard_Boolean theToEnable)
 }
 
 //=======================================================================
-//function : SetFlatMode
+//function : SetSkinMode
 //purpose  :
 //=======================================================================
-void AIS_Manipulator::SetFlatMode (const Standard_Boolean theIsFlatMode)
+void AIS_Manipulator::SetSkinMode (const AIS_SkinMode theSkinMode)
 {
-  if (myIsFlatMode != theIsFlatMode)
+  if (mySkinMode != theSkinMode)
   {
     SetToUpdate();
   }
-  myIsFlatMode = theIsFlatMode;
+  mySkinMode = theSkinMode;
 }
 
 //=======================================================================
@@ -998,7 +998,7 @@ void AIS_Manipulator::Compute (const Handle(PrsMgr_PresentationManager3d)& thePr
   anAspect->SetTransparency (myDrawer->ShadingAspect()->Transparency());
 
   // Display center
-  myCenter.Init (myAxes[0].AxisRadius() * 2.0f, gp::Origin(), myIsFlatMode);
+  myCenter.Init (myAxes[0].AxisRadius() * 2.0f, gp::Origin(), mySkinMode);
   aGroup = thePrs->NewGroup ();
   aGroup->SetPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
   aGroup->AddPrimitiveArray (myCenter.Array());
@@ -1011,7 +1011,7 @@ void AIS_Manipulator::Compute (const Handle(PrsMgr_PresentationManager3d)& thePr
     Handle(Prs3d_ShadingAspect) anAspectAx = new Prs3d_ShadingAspect (new Graphic3d_AspectFillArea3d(*anAspect->Aspect()));
     anAspectAx->SetColor (myAxes[anIt].Color());
     aGroup->SetGroupPrimitivesAspect (anAspectAx->Aspect());
-    myAxes[anIt].Compute (thePrsMgr, thePrs, anAspectAx, myIsFlatMode);
+    myAxes[anIt].Compute (thePrsMgr, thePrs, anAspectAx, mySkinMode);
     myAxes[anIt].SetTransformPersistence (TransformPersistence());
   }
 
@@ -1049,7 +1049,7 @@ void AIS_Manipulator::HilightSelected (const Handle(PrsMgr_PresentationManager3d
     return;
   }
 
-  if (anOwner->Mode() == AIS_MM_TranslationPlane && !myIsFlatMode)
+  if (anOwner->Mode() == AIS_MM_TranslationPlane && mySkinMode == AIS_SM_Shaded)
   {
     myDraggerHighlight->SetColor(myAxes[anOwner->Index()].Color());
     aGroup->SetGroupPrimitivesAspect(myDraggerHighlight->Aspect());
@@ -1087,7 +1087,7 @@ void AIS_Manipulator::HilightOwnerWithColor (const Handle(PrsMgr_PresentationMan
 
   aPresentation->CStructure()->ViewAffinity = thePM->StructureManager()->ObjectAffinity (Handle(Standard_Transient) (this));
 
-  if (anOwner->Mode() == AIS_MM_TranslationPlane && !myIsFlatMode)
+  if (anOwner->Mode() == AIS_MM_TranslationPlane && mySkinMode == AIS_SM_Shaded)
   {
     Handle(Prs3d_Drawer) aStyle = new Prs3d_Drawer();
     aStyle->SetColor (myAxes[anOwner->Index()].Color());
@@ -1149,7 +1149,7 @@ void AIS_Manipulator::ComputeSelection (const Handle(SelectMgr_Selection)& theSe
       const Axis& anAxis = myAxes[anIt];
       anOwner = new AIS_ManipulatorOwner (this, anIt, AIS_MM_Translation, 9);
 
-      if (!myIsFlatMode)
+      if (mySkinMode == AIS_SM_Shaded)
       {
         // define sensitivity by line
         Handle(Select3D_SensitiveSegment) aLine = new Select3D_SensitiveSegment (anOwner, gp::Origin(), anAxis.TranslatorTipPosition());
@@ -1168,7 +1168,7 @@ void AIS_Manipulator::ComputeSelection (const Handle(SelectMgr_Selection)& theSe
   {
     for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
     {
-      if (!myAxes[anIt].HasRotation() || myIsFlatMode)
+      if (!myAxes[anIt].HasRotation() || mySkinMode == AIS_SM_Flat)
       {
         continue;
       }
@@ -1190,7 +1190,7 @@ void AIS_Manipulator::ComputeSelection (const Handle(SelectMgr_Selection)& theSe
   {
     for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
     {
-      if (!myAxes[anIt].HasScaling() || myIsFlatMode)
+      if (!myAxes[anIt].HasScaling() || mySkinMode == AIS_SM_Flat)
       {
         continue;
       }
@@ -1222,7 +1222,7 @@ void AIS_Manipulator::ComputeSelection (const Handle(SelectMgr_Selection)& theSe
       aP2 = myAxes[((anIt + 2) % 3)].TranslatorTipPosition();
       gp_XYZ aMidP = (aP1.XYZ() + aP2.XYZ()) / 2.0;
 
-      if (!myIsFlatMode)
+      if (mySkinMode == AIS_SM_Shaded)
       {
         Handle(Select3D_SensitiveSegment) aLine1 = new Select3D_SensitiveSegment(anOwner, aP1, aP2);
         aLine1->SetSensitivityFactor(10);
@@ -1269,7 +1269,7 @@ void AIS_Manipulator::Disk::Init (const Standard_ShortReal theInnerRadius,
 //=======================================================================
 void AIS_Manipulator::Sphere::Init (const Standard_ShortReal theRadius,
                                     const gp_Pnt& thePosition,
-                                    const Standard_Boolean theIsFlatSkinMode,
+                                    const AIS_SkinMode theSkinMode,
                                     const Standard_Integer theSlicesNb,
                                     const Standard_Integer theStacksNb)
 {
@@ -1279,7 +1279,7 @@ void AIS_Manipulator::Sphere::Init (const Standard_ShortReal theRadius,
   gp_Trsf aTrsf;
   aTrsf.SetTranslation (gp_Vec(gp::Origin(), thePosition));
 
-  if (theIsFlatSkinMode)
+  if (theSkinMode == AIS_SM_Flat)
   {
     myArray = new Graphic3d_ArrayOfTriangles (3, 3, Graphic3d_ArrayFlags_VertexNormal);
     myTriangulation = new Poly_Triangulation (3, 1, Standard_False);
@@ -1390,7 +1390,7 @@ void AIS_Manipulator::Cube::addTriangle (const Standard_Integer theIndex,
 void AIS_Manipulator::Sector::Init (const Standard_ShortReal theRadius,
                                     const gp_Ax1&            thePosition,
                                     const gp_Dir&            theXDirection,
-                                    const Standard_Boolean   theIsFlatSkinMode,
+                                    const AIS_SkinMode       theSkinMode,
                                     const Standard_Integer   theSlicesNb,
                                     const Standard_Integer   theStacksNb)
 {
@@ -1398,7 +1398,7 @@ void AIS_Manipulator::Sector::Init (const Standard_ShortReal theRadius,
   gp_Trsf aTrsf;
   aTrsf.SetTransformation (aSystem, gp_Ax3());
 
-  if (theIsFlatSkinMode)
+  if (theSkinMode == AIS_SM_Flat)
   {
     myArray = new Graphic3d_ArrayOfTriangles (4, 6, Graphic3d_ArrayFlags_VertexNormal);
     myTriangulation = new Poly_Triangulation (4, 2, Standard_False);
@@ -1471,7 +1471,7 @@ AIS_Manipulator::Axis::Axis (const gp_Ax1& theAxis,
 void AIS_Manipulator::Axis::Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
                                      const Handle(Prs3d_Presentation)& thePrs,
                                      const Handle(Prs3d_ShadingAspect)& theAspect,
-                                     const Standard_Boolean theIsFlatSkinMode)
+                                     const AIS_SkinMode theSkinMode)
 {
   if (myHasTranslation)
   {
@@ -1479,7 +1479,7 @@ void AIS_Manipulator::Axis::Compute (const Handle(PrsMgr_PresentationManager)& t
     const Standard_Real aCylinderLength = myLength - anArrowLength;
     myArrowTipPos = gp_Pnt (0.0, 0.0, 0.0).Translated (myReferenceAxis.Direction().XYZ() * aCylinderLength);
 
-    if (theIsFlatSkinMode)
+    if (theSkinMode == AIS_SM_Flat)
     {
       myTriangleArray = new Graphic3d_ArrayOfTriangles (4, 6, Graphic3d_ArrayFlags_VertexNormal);
       const Standard_Integer aSign = myReferenceAxis.Direction().X() > 0 ? -1 : 1;
@@ -1514,7 +1514,7 @@ void AIS_Manipulator::Axis::Compute (const Handle(PrsMgr_PresentationManager)& t
     }
 
     myTranslatorGroup = thePrs->NewGroup();
-    myTranslatorGroup->SetClosed (!theIsFlatSkinMode);
+    myTranslatorGroup->SetClosed (theSkinMode == AIS_SM_Shaded);
     myTranslatorGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
     myTranslatorGroup->AddPrimitiveArray (myTriangleArray);
 
@@ -1533,7 +1533,7 @@ void AIS_Manipulator::Axis::Compute (const Handle(PrsMgr_PresentationManager)& t
     }
   }
 
-  if (myHasScaling && !theIsFlatSkinMode)
+  if (myHasScaling && theSkinMode == AIS_SM_Shaded)
   {
     myCubePos = myReferenceAxis.Direction().XYZ() * (myLength + myIndent);
     myCube.Init (gp_Ax1 (myCubePos, myReferenceAxis.Direction()), myBoxSize);
@@ -1558,7 +1558,7 @@ void AIS_Manipulator::Axis::Compute (const Handle(PrsMgr_PresentationManager)& t
     }
   }
 
-  if (myHasRotation && !theIsFlatSkinMode)
+  if (myHasRotation && theSkinMode == AIS_SM_Shaded)
   {
     myCircleRadius = myInnerRadius + myIndent * 2 + myDiskThickness * 0.5f;
     myCircle.Init (myInnerRadius + myIndent * 2, myInnerRadius + myDiskThickness + myIndent * 2, gp_Ax1(gp::Origin(), myReferenceAxis.Direction()), myFacettesNumber * 2);
@@ -1591,12 +1591,12 @@ void AIS_Manipulator::Axis::Compute (const Handle(PrsMgr_PresentationManager)& t
     else
       aXDirection = gp::DX();
 
-    gp_Pnt aPosition = theIsFlatSkinMode ? gp_Pnt (myReferenceAxis.Direction().XYZ() * (-myAxisRadius)) : gp::Origin();
-    Standard_ShortReal aRadius = theIsFlatSkinMode ? myLength : myInnerRadius + myIndent * 2;
-    mySector.Init (aRadius, gp_Ax1 (aPosition, myReferenceAxis.Direction()), aXDirection, theIsFlatSkinMode, myFacettesNumber * 2);
+    gp_Pnt aPosition = theSkinMode == AIS_SM_Flat ? gp_Pnt (myReferenceAxis.Direction().XYZ() * (-myAxisRadius)) : gp::Origin();
+    Standard_ShortReal aRadius = theSkinMode == AIS_SM_Flat ? myLength : myInnerRadius + myIndent * 2;
+    mySector.Init (aRadius, gp_Ax1 (aPosition, myReferenceAxis.Direction()), aXDirection, theSkinMode, myFacettesNumber * 2);
     myDraggerGroup = thePrs->NewGroup();
 
-    Handle(Graphic3d_AspectFillArea3d) aFillArea = theIsFlatSkinMode
+    Handle(Graphic3d_AspectFillArea3d) aFillArea = theSkinMode == AIS_SM_Flat
       ? theAspect->Aspect()
       : new Graphic3d_AspectFillArea3d();
 
index 710d9a15f4bcc3a4b737413545ea24838a8d1c2b..d8f4c8fccba9a84856722a6230eae8765c122acd 100644 (file)
@@ -256,12 +256,6 @@ public: //! @name Configuration of graphical transformations
   //! Returns state of zoom persistence mode, whether it turned on or off.
   Standard_Boolean ZoomPersistence() const { return myIsZoomPersistentMode; }
 
-  //! Enable or disable flat skin mode for the manipulator.
-  Standard_EXPORT void SetFlatMode (const Standard_Boolean theIsFlatMode);
-
-  //! Returns state of flat skin mode, whether it turned on or off.
-  Standard_Boolean IsFlatMode() const { return myIsFlatMode; }
-
   //! Redefines transform persistence management to setup transformation for sub-presentation of axes.
   //! @warning this interactive object does not support custom transformation persistence when
   //! using \sa ZoomPersistence mode. In this mode the transformation persistence flags for
@@ -274,6 +268,18 @@ public: //! @name Configuration of graphical transformations
 
 public: //! @name Setters for parameters
 
+  enum AIS_SkinMode
+  {
+    AIS_SM_Shaded,
+    AIS_SM_Flat
+  };
+
+  //! @return current manipulator skin mode.
+  AIS_SkinMode SkinMode() const { return mySkinMode; }
+
+  //! Sets skin mode for the manipulator.
+  Standard_EXPORT void SetSkinMode (const AIS_SkinMode theSkinMode);
+
   AIS_ManipulatorMode ActiveMode() const { return myCurrentMode; }
 
   Standard_Integer ActiveAxisIndex() const { return myCurrentIndex; }
@@ -434,7 +440,7 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
 
     void Init (const Standard_ShortReal theRadius,
                const gp_Pnt& thePosition,
-               const Standard_Boolean theIsFlatSkinMode = Standard_False,
+               const AIS_SkinMode theSkinMode = AIS_SM_Shaded,
                const Standard_Integer theSlicesNb = 20,
                const Standard_Integer theStacksNb = 20);
 
@@ -482,7 +488,7 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
     void Init(const Standard_ShortReal theRadius,
               const gp_Ax1&            thePosition,
               const gp_Dir&            theXDirection,
-              const Standard_Boolean   theIsFlatSkinMode = Standard_False,
+              const AIS_SkinMode       theSkinMode = AIS_SM_Shaded,
               const Standard_Integer   theSlicesNb = 5,
               const Standard_Integer   theStacksNb = 5);
 
@@ -508,7 +514,7 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
     void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
                   const Handle(Prs3d_Presentation)& thePrs,
                   const Handle(Prs3d_ShadingAspect)& theAspect,
-                  const Standard_Boolean theIsFlatSkinMode = Standard_False);
+                  const AIS_SkinMode theSkinMode = AIS_SM_Shaded);
 
     const gp_Ax1& ReferenceAxis() const { return myReferenceAxis; }
 
@@ -694,11 +700,11 @@ protected:
 
   Standard_Integer myCurrentIndex; //!< Index of active axis.
   AIS_ManipulatorMode myCurrentMode; //!< Name of active manipulation mode.
+  AIS_SkinMode mySkinMode; //!< Name of active skin mode.
 
   Standard_Boolean myIsActivationOnDetection; //!< Manual activation of modes (not on parts selection).
-  Standard_Boolean myIsZoomPersistentMode;    //!< Zoom persistence mode activation.
-  Standard_Boolean myIsFlatMode;              //!< Flat skin mode activation.
-  BehaviorOnTransform myBehaviorOnTransform;  //!< Behavior settings applied on manipulator when transforming an object.
+  Standard_Boolean myIsZoomPersistentMode; //!< Zoom persistence mode activation.
+  BehaviorOnTransform myBehaviorOnTransform; //!< Behavior settings applied on manipulator when transforming an object.
 
 protected: //! @name Fields for interactive transformation. Fields only for internal needs. They do not have public interface.
 
index b829ffcf69ee5a2cbafcbc033e51bcac90fabf16..9406853ca2574bf4915abf6152e7a9225ee52ae2 100644 (file)
@@ -13004,7 +13004,7 @@ static int VManipulator (Draw_Interpretor& theDi,
   }
   if (aCmd.HasOption ("flat", 1, Standard_True))
   {
-    aManipulator->SetFlatMode (aCmd.ArgBool ("flat"));
+    aManipulator->SetSkinMode ((AIS_Manipulator::AIS_SkinMode) aCmd.ArgBool ("flat"));
 
     if (ViewerTest::GetAISContext()->IsDisplayed (aManipulator))
     {