Salome HOME
#1334 Show dimensional constraint check-box does not work
authornds <nds@opencascade.com>
Thu, 25 Feb 2016 13:59:17 +0000 (16:59 +0300)
committernds <nds@opencascade.com>
Thu, 25 Feb 2016 14:00:36 +0000 (17:00 +0300)
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h
src/PartSet/PartSet_SketcherReetntrantMgr.cpp
src/PartSet/PartSet_Tools.h
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/PartSet/PartSet_WidgetSketchLabel.h

index cf5c2c7434f6454c83b8a9a59b8c9c02d854df11..297e0ef10301456360b785b2d2ef41857c0878f3 100755 (executable)
@@ -315,7 +315,7 @@ void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
                                                                     aLast = myHasConstraintShown.end();
   for (; anIt != aLast; anIt++) {
     myHasConstraintShown[anIt.key()];
-    mySketchMgr->onShowConstraintsToggle(anIt.value(), myHasConstraintShown[anIt.key()]);
+    mySketchMgr->onShowConstraintsToggle(anIt.key(), anIt.value());
   }
 }
 
@@ -562,11 +562,11 @@ ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& th
   ModuleBase_ModelWidget* aWgt = NULL;
   if (theType == "sketch-start-label") {
     PartSet_WidgetSketchLabel* aLabelWgt = new PartSet_WidgetSketchLabel(theParent, aWorkshop,
-      theWidgetApi, theParentId, mySketchMgr->showConstraintStates());
+      theWidgetApi, theParentId, myHasConstraintShown);
     connect(aLabelWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)),
       mySketchMgr, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
-    connect(aLabelWgt, SIGNAL(showConstraintToggled(bool, int)),
-      mySketchMgr, SLOT(onShowConstraintsToggle(bool, int)));
+    connect(aLabelWgt, SIGNAL(showConstraintToggled(int, bool)),
+      mySketchMgr, SLOT(onShowConstraintsToggle(int, bool)));
     aWgt = aLabelWgt;
   } else if (theType == "sketch-2dpoint_selector") {
     PartSet_WidgetPoint2D* aPointWgt = new PartSet_WidgetPoint2D(theParent, aWorkshop,
@@ -713,13 +713,14 @@ void PartSet_Module::launchOperation(const QString& theCmdId)
 {
   if (myWorkshop->currentOperation() && 
       myWorkshop->currentOperation()->id().toStdString() == SketchPlugin_Sketch::ID()) {
-      const QMap<PartSet_Tools::ConstraintVisibleState, bool>& aShownStates = mySketchMgr->showConstraintStates();
+      const QMap<PartSet_Tools::ConstraintVisibleState, bool>& aShownStates =
+                                                    mySketchMgr->showConstraintStates();
       myHasConstraintShown = aShownStates;
   }
   if (PartSet_SketcherMgr::constraintsIdList().contains(theCmdId)) {
     // Show constraints if a constraint was anOperation
-    mySketchMgr->onShowConstraintsToggle(true, PartSet_Tools::Geometrical);
-    mySketchMgr->onShowConstraintsToggle(true, PartSet_Tools::Dimensional);
+    mySketchMgr->onShowConstraintsToggle(PartSet_Tools::Geometrical, true);
+    mySketchMgr->onShowConstraintsToggle(PartSet_Tools::Dimensional, true);
   }
   ModuleBase_IModule::launchOperation(theCmdId);
 }
index 936c30afcf40d0f48135c87027979881a1a2e5c6..583e132981a1d492063ddf6bb815fcf87c25ed52 100755 (executable)
@@ -1152,31 +1152,87 @@ bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const
       }
     }
   }
-  if (!isObjectFound) 
-    return aCanDisplay;
-  
-  // 4. For created nested feature operation do not display the created feature if
-  // the mouse curstor leaves the OCC window.
-  // The correction cases, which ignores this condition:
-  // a. the property panel values modification
-  // b. the popup menu activated
-  // c. widget editor control
-  #ifndef DEBUG_DO_NOT_BY_ENTER
-  if (aCanDisplay && isNestedCreateOperation(getCurrentOperation())) {
-    ModuleBase_ModelWidget* anActiveWidget = getActiveWidget();
-    ModuleBase_WidgetEditor* anEditorWdg = anActiveWidget ? dynamic_cast<ModuleBase_WidgetEditor*>(anActiveWidget) : 0;
-    // the active widget editor should not influence here. The presentation should be visible always
-    // when this widget is active.
-    if (!anEditorWdg && !myIsPopupMenuActive) {
-      // during a nested create operation, the feature is redisplayed only if the mouse over view
-      // of there was a value modified in the property panel after the mouse left the view
-      aCanDisplay = canDisplayCurrentCreatedFeature();
+  if (isObjectFound) {
+    // 4. For created nested feature operation do not display the created feature if
+    // the mouse curstor leaves the OCC window.
+    // The correction cases, which ignores this condition:
+    // a. the property panel values modification
+    // b. the popup menu activated
+    // c. widget editor control
+    #ifndef DEBUG_DO_NOT_BY_ENTER
+    if (aCanDisplay && isNestedCreateOperation(getCurrentOperation())) {
+      ModuleBase_ModelWidget* anActiveWidget = getActiveWidget();
+      ModuleBase_WidgetEditor* anEditorWdg = anActiveWidget ? dynamic_cast<ModuleBase_WidgetEditor*>(anActiveWidget) : 0;
+      // the active widget editor should not influence here. The presentation should be visible always
+      // when this widget is active.
+      if (!anEditorWdg && !myIsPopupMenuActive) {
+        // during a nested create operation, the feature is redisplayed only if the mouse over view
+        // of there was a value modified in the property panel after the mouse left the view
+        aCanDisplay = canDisplayCurrentCreatedFeature();
+      }
     }
+    #endif
   }
-  #endif
+
+  // checks the sketcher constraints visibility according to active sketch check box states
+  if (aCanDisplay) {
+    bool aProcessed = false;
+    FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+    if (aFeature.get()) {
+      bool aConstraintDisplayed = canDisplayConstraint(aFeature, PartSet_Tools::Any, aProcessed);
+      if (aProcessed)
+        aCanDisplay = aConstraintDisplayed;
+    }
+  }
+
   return aCanDisplay;
 }
 
+bool PartSet_SketcherMgr::canDisplayConstraint(const FeaturePtr& theFeature,
+                                             const PartSet_Tools::ConstraintVisibleState& theState,
+                                             bool& isProcessed) const
+{
+  bool aSwitchedOn = true;
+
+  const QStringList& aConstrIds = constraintsIdList();
+
+  std::string aKind = theFeature->getKind();
+  if (aConstrIds.contains(QString(aKind.c_str()))) {
+    bool isTypedConstraint = false;
+
+    switch (theState) {
+      case PartSet_Tools::Dimensional: {
+        bool isDistance = isDistanceKind(aKind);
+        if (isDistance) {
+          isProcessed = true;
+          aSwitchedOn = myIsConstraintsShown[theState];
+        }
+      }
+      break;
+      case PartSet_Tools::Geometrical: {
+        bool isGeometrical = !isDistanceKind(aKind);
+        if (isGeometrical) {
+          isProcessed = true;
+          aSwitchedOn = myIsConstraintsShown[theState];
+        }
+      }
+      break;
+      case PartSet_Tools::Any: {
+        isProcessed = true;
+        bool isDistance = isDistanceKind(aKind);
+        if (isDistance)
+          aSwitchedOn = myIsConstraintsShown[PartSet_Tools::Dimensional];
+        else
+          aSwitchedOn = myIsConstraintsShown[PartSet_Tools::Geometrical];
+      }
+      break;
+    default:
+      break;
+    }
+  }
+  return aSwitchedOn;
+}
+
 void PartSet_SketcherMgr::processHiddenObject(const std::list<ObjectPtr>& theObjects)
 {
   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
@@ -1544,7 +1600,7 @@ void PartSet_SketcherMgr::restoreSelection()
   }
 }
 
-void PartSet_SketcherMgr::onShowConstraintsToggle(bool theState, int theType)
+void PartSet_SketcherMgr::onShowConstraintsToggle(int theType, bool theState)
 {
   PartSet_Tools::ConstraintVisibleState aType = (PartSet_Tools::ConstraintVisibleState)theType;
   if (myIsConstraintsShown.contains(aType) && myIsConstraintsShown[aType] == theState)
@@ -1557,25 +1613,12 @@ void PartSet_SketcherMgr::onShowConstraintsToggle(bool theState, int theType)
   ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
 
-  const QStringList& aConstrIds = constraintsIdList();
   for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
     FeaturePtr aSubFeature = myCurrentSketch->subFeature(i);
-    std::string aKind = aSubFeature->getKind();
-    if (aConstrIds.contains(QString(aKind.c_str()))) {
-      bool isTypedConstraint = false;
-      if (aType == PartSet_Tools::Dimensional) {
-        isTypedConstraint = isDistanceKind(aKind);
-      }
-      else
-        isTypedConstraint = !isDistanceKind(aKind);
-
-      if (isTypedConstraint) {
-        if (theState)
-          aSubFeature->setDisplayed(true);
-        else
-          aSubFeature->setDisplayed(false);
-      }
-    }
+    bool aProcessed = false;
+    bool aConstraintDisplayed = canDisplayConstraint(aSubFeature, aType, aProcessed);
+    if (aProcessed)
+      aSubFeature->setDisplayed(aConstraintDisplayed);
   }
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
 }
index f13c3cfdff815382ec6acbfdf6bc81ac615add32..113abadd2a852ba76c0aeb0d28396c1211e18ff1 100644 (file)
@@ -173,6 +173,16 @@ public:
   /// \param theObject a model object
   bool canDisplayObject(const ObjectPtr& theObject) const;
 
+  /// Returns whether the constraint object can be displayed. It depends on the sketch check
+  /// box states
+  /// \param theObject a model object
+  /// \param theState the constraint visible state state to be checked
+  /// \param isProcessed an output parameter if it is processed
+  /// \return result value
+  bool canDisplayConstraint(const FeaturePtr& theObject,
+                            const PartSet_Tools::ConstraintVisibleState& theState,
+                            bool& isProcessed) const;
+
   /// Check the given objects either there are some results of the current sketch. If so,
   /// it suggests to delete them as there are no functionality to show back hidden sketch objects
   /// \param theObjects a list of hidden objects
@@ -240,7 +250,7 @@ public slots:
   void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
 
   /// Toggle show constraints
-  void onShowConstraintsToggle(bool theState, int theType);
+  void onShowConstraintsToggle(int theType, bool theState);
 
 private slots:
   /// Process the enter mouse to the view port. If the current operation is a create of
index 3bd8a61b1a9830fd0076832867ddcca2dcd0bee1..197f4df0f56567cfd7ce4871c8122abffbcd3979 100755 (executable)
@@ -115,7 +115,7 @@ bool PartSet_SketcherReetntrantMgr::processMouseMoved(ModuleBase_IViewWindow* /*
       bool aWidgetIsFilled = false;
 
       //bool aCanBeActivatedByMove = false;
-      FeaturePtr aCurrentFeature = anActiveWidget->feature();
+      FeaturePtr aCurrentFeature = aFOperation->feature();
       bool isLineFeature = false, isArcFeature = false;
       if (aCurrentFeature->getKind() == SketchPlugin_Line::ID())
         isLineFeature = anActiveWidget->attributeID() == SketchPlugin_Line::START_ID();
index 310ac57a7ae929a9792bb6cddfa7665335b7d888..1b35d9068e9a39d226a06954cae465c250b7c1b0 100755 (executable)
@@ -46,7 +46,8 @@ public:
   enum ConstraintVisibleState
   {
     Geometrical = 0, // all constrains excepting dimensional
-    Dimensional // lenght, distance, radius and angle constraints
+    Dimensional,     // lenght, distance, radius and angle constraints
+    Any              // both, geometrical and dimensional, types of constraints
   };
 
  public:
index b8c78602c9726a482baac5d078488197c274f0e8..fa2f50750acce400899cc456d12f211e19119333 100644 (file)
@@ -182,7 +182,7 @@ void PartSet_WidgetSketchLabel::onShowConstraint(bool theOn)
       aState = anIt.key();
   }
   if (aFound)
-    emit showConstraintToggled(theOn, aState);
+    emit showConstraintToggled(aState, theOn);
 }
 
 void PartSet_WidgetSketchLabel::blockAttribute(const bool& theToBlock, bool& isFlushesActived,
index 600147ed4c87cada0beb8376c5b2fb9133c8de58..0d1d4405642f93de202cbd9490a92dba3537846e 100644 (file)
@@ -86,9 +86,9 @@ signals:
   void planeSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
 
   /// A show constraint toggled signal
-  /// \param theState a state of the check box
   /// \param theType a ConstraintVisibleState value
-  void showConstraintToggled(bool theState, int theType);
+  /// \param theState a state of the check box
+  void showConstraintToggled(int theType, bool theState);
 
 protected:
   /// Creates a backup of the current values of the attribute