]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Selection modes for constraint objects
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 2 Apr 2015 13:06:19 +0000 (16:06 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 2 Apr 2015 13:06:19 +0000 (16:06 +0300)
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_SketcherMgr.h
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/SketcherPrs/SketcherPrs_Coincident.cpp
src/SketcherPrs/SketcherPrs_LengthDimension.cpp
src/SketcherPrs/SketcherPrs_LengthDimension.h
src/SketcherPrs/SketcherPrs_Radius.cpp
src/SketcherPrs/SketcherPrs_Radius.h
src/SketcherPrs/SketcherPrs_SymbolPrs.cpp
src/SketcherPrs/SketcherPrs_Tools.h
src/XGUI/XGUI_ModuleConnector.cpp

index 4c685683578f2cd490d3964e314fca495da18414..8b16a24cda7eb1339d08d4ef7a65517a53679b2d 100644 (file)
@@ -547,7 +547,7 @@ bool PartSet_Module::deleteObjects()
   // the abort leads to selection lost on constraint objects. It can be corrected after #386 issue
   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
   XGUI_Workshop* aWorkshop = aConnector->workshop();
-  ModuleBase_ISelection* aSel = aConnector->selection();
+  ModuleBase_ISelection* aSel = workshop()->selection();
   QObjectPtrList aSelectedObj = aSel->selectedPresentations();
   // if there are no selected objects in the viewer, that means that the selection in another
   // place cased this method. It is necessary to return the false value to understande in above
index aad09ef0fda92803c1694ca56c514e79711aad5b..be687f220730ef4e12c3b68cc3b8d75d6f978da0 100644 (file)
@@ -146,7 +146,7 @@ public:
   /// \param isChecked if true, the feature is a construction
   void setAuxiliary(const bool isChecked);
 
-
+  /// Returns state of constraints showing flag 
   bool isConstraintsShown() const { return myIsConstraintsShown; }
 
 
index 1b645c062821a47d4190355106ae8cb9fa8989a1..6be038d19d803a84cf839d7dc1e6e7e97e6e7f7f 100644 (file)
@@ -27,6 +27,7 @@
 #include <GeomAPI_XYZ.h>
 
 #include <SketchPlugin_Sketch.h>
+#include <SketcherPrs_Tools.h>
 
 #include <Precision.hxx>
 #include <gp_Pln.hxx>
@@ -360,8 +361,9 @@ void PartSet_WidgetSketchLabel::setSketchingMode()
 
   // Get default selection modes
   QIntList aModes;
-  aModes.append(AIS_DSM_Text);
-  aModes.append(AIS_DSM_Line);
+  aModes.append(SketcherPrs_Tools::Sel_Dimension_Text);
+  aModes.append(SketcherPrs_Tools::Sel_Dimension_Line);
+  aModes.append(SketcherPrs_Tools::Sel_Constraint);
   aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
   aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
 
index f7b61d9600c0fd5e2e53cc6b905efad7438b5bae..3520df99884db5881a6d22137b95cf51e6b08dca 100644 (file)
@@ -70,9 +70,11 @@ void SketcherPrs_Coincident::Compute(const Handle(PrsMgr_PresentationManager3d)&
 void SketcherPrs_Coincident::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
                                             const Standard_Integer aMode)
 {
-  Handle(SelectMgr_EntityOwner) aOwn = new SelectMgr_EntityOwner(this, 10);
-  Handle(Select3D_SensitivePoint) aSp = new Select3D_SensitivePoint(aOwn, myPoint);
-  aSelection->Add(aSp);
+  if ((aMode == 0) || (aMode == SketcherPrs_Tools::Sel_Constraint)) {
+    Handle(SelectMgr_EntityOwner) aOwn = new SelectMgr_EntityOwner(this, 10);
+    Handle(Select3D_SensitivePoint) aSp = new Select3D_SensitivePoint(aOwn, myPoint);
+    aSelection->Add(aSp);
+  }
 }
 
 void SketcherPrs_Coincident::SetColor(const Quantity_NameOfColor aCol)
index a1564129b502605fd0456b6c8bee5b6da81f1fc1..17c316afc3a414b606b02a66dc792276ac62f74b 100644 (file)
@@ -151,3 +151,25 @@ bool SketcherPrs_LengthDimension::getPoints(gp_Pnt& thePnt1, gp_Pnt& thePnt2) co
   }
   return false;
 }
+
+
+
+void SketcherPrs_LengthDimension::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+                                                   const Standard_Integer theMode)
+{
+  Standard_Integer aMode;
+  switch (theMode) {
+  case SketcherPrs_Tools::Sel_Dimension_All:
+    aMode = 0;
+    break;
+  case SketcherPrs_Tools::Sel_Dimension_Line:
+    aMode = 1;
+    break;
+  case SketcherPrs_Tools::Sel_Dimension_Text:
+    aMode = 2;
+    break;
+  default:
+    aMode = theMode;
+  }
+  AIS_LengthDimension::ComputeSelection(aSelection, aMode);
+}
index ea4832e7ea1f1cfcddfa5317bcf7ab62a31d4de5..5fde8d7aa0e094f1599a18f752c4d9c1b1138e81 100644 (file)
@@ -38,6 +38,10 @@ protected:
   Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
     const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
 
+  /// Redefinition of virtual function
+  Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+    const Standard_Integer aMode);
+
 private:
   bool getPoints(gp_Pnt& thePnt1, gp_Pnt& thePnt2) const;
 
index cd6e32f39719bce6d7735a2eda93fc31246eaed1..a3643fe08698926dd83629401a1afe6adeeb77b6 100644 (file)
@@ -99,3 +99,23 @@ void SketcherPrs_Radius::Compute(const Handle(PrsMgr_PresentationManager3d)& the
 
   AIS_RadiusDimension::Compute(thePresentationManager, thePresentation, theMode);
 }
+
+void SketcherPrs_Radius::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+                                                   const Standard_Integer theMode)
+{
+  Standard_Integer aMode;
+  switch (theMode) {
+  case SketcherPrs_Tools::Sel_Dimension_All:
+    aMode = 0;
+    break;
+  case SketcherPrs_Tools::Sel_Dimension_Line:
+    aMode = 1;
+    break;
+  case SketcherPrs_Tools::Sel_Dimension_Text:
+    aMode = 2;
+    break;
+  default:
+    aMode = theMode;
+  }
+  AIS_RadiusDimension::ComputeSelection(aSelection, aMode);
+}
index 7b75569da8ff69c31c96995391ddda09d2699717..88a3c613c219d445c55f95b06e018bd38682e8b2 100644 (file)
@@ -35,6 +35,10 @@ protected:
   Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
     const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
 
+  /// Redefinition of virtual function
+  Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+    const Standard_Integer aMode);
+
 private:
   /// Constraint feature
   ModelAPI_Feature* myConstraint;
index f73556bacb13623e4b3dab8ae7f508c47f42dc48..fad57104d01a27cb599452b4e9137b4cffd406df 100644 (file)
@@ -353,9 +353,11 @@ void SketcherPrs_SymbolPrs::Compute(const Handle(PrsMgr_PresentationManager3d)&
 void SketcherPrs_SymbolPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
                                             const Standard_Integer aMode)
 {
-  ClearSelected();
-  for (int i = 1; i <= mySPoints.Length(); i++)
-    aSelection->Add(mySPoints.Value(i));
+  //ClearSelected();
+  if ((aMode == 0) || (aMode == SketcherPrs_Tools::Sel_Constraint)) {
+    for (int i = 1; i <= mySPoints.Length(); i++)
+      aSelection->Add(mySPoints.Value(i));
+  }
 }
 
 
index c040fff59fc2e346477f491279f094fa41a0e9f7..00a2e96630948e82c01f8d29523879ae78e0f760 100644 (file)
@@ -20,8 +20,26 @@ class GeomDataAPI_Point2D;
 
 namespace SketcherPrs_Tools {
 
+/// Enumeration with modes for activation of selection custom presentations
+enum SelectionModes {
+  /// Start of enumeration
+  Sel_Mode_First = 100, 
+  
+  /// Selection mode for all constraints exclude dimensions
+  Sel_Constraint,
+  
+  /// Selection mode for whole dimension
+  Sel_Dimension_All,
+  
+  /// Selection mode for line of dimension
+  Sel_Dimension_Line,
+
+  /// Selection mode foe text of dimension
+  Sel_Dimension_Text
+};
+
   SKETCHERPRS_EXPORT ObjectPtr getResult(ModelAPI_Feature* theFeature,
-                      const std::string& theAttrName);
+                                         const std::string& theAttrName);
 
   SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Shape> getShape(ObjectPtr theObject);
 
index ab9991d503365ecb453e9c9b020e00e6e68d74bd..fdc407f7be5fa95b5a577b800f2748d43d346f16 100644 (file)
@@ -68,7 +68,10 @@ void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes)
   // Convert shape types to selection types
   QIntList aModes;
   foreach(int aType, theTypes) {
-    aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)aType));
+    if (aType > TopAbs_SHAPE) 
+      aModes.append(aType);
+    else
+      aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)aType));
   }
   aDisp->activateObjects(aModes);
   //TODO: We have to open Local context because at neutral point filters don't work (bug 25340)