]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2027 Modification of data strtucture outside of transaction when create circle...
authornds <nds@opencascade.com>
Thu, 30 Mar 2017 08:58:53 +0000 (11:58 +0300)
committernds <nds@opencascade.com>
Thu, 30 Mar 2017 08:58:53 +0000 (11:58 +0300)
Modification is proposed by MPV

src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OverconstraintListener.cpp
src/PartSet/PartSet_OverconstraintListener.h
src/XGUI/XGUI_Displayer.cpp

index edd895a4089d50860f52b487be3509433a71a010..4382fca68cb83d42f93e640f775004b734061e97 100755 (executable)
@@ -1014,36 +1014,11 @@ bool PartSet_Module::customisePresentation(ResultPtr theResult, AISObjectPtr the
   if (!anObject)
     return aCustomized;
 
-  std::vector<int> aColor;
-  //bool aCustomColor = myOverconstraintListener->hasCustomColor(anObject, aColor);
-
   if (!theResult.get()) {
-    /*// customize sketch symbol presentation
-    if (thePrs.get()) {
-      Handle(AIS_InteractiveObject) anAISIO = thePrs->impl<Handle(AIS_InteractiveObject)>();
-      if (!anAISIO.IsNull()) {
-        if (!Handle(SketcherPrs_SymbolPrs)::DownCast(anAISIO).IsNull()) {
-          Handle(SketcherPrs_SymbolPrs) aPrs = Handle(SketcherPrs_SymbolPrs)::DownCast(anAISIO);
-          if (!aPrs.IsNull()) {
-            aPrs->SetCustomColor(aColor);
-            aCustomized = true;
-          }
-        } else if (!Handle(SketcherPrs_Coincident)::DownCast(anAISIO).IsNull()) {
-          Handle(SketcherPrs_Coincident) aPrs = Handle(SketcherPrs_Coincident)::DownCast(anAISIO);
-          if (!aPrs.IsNull()) {
-            aPrs->SetCustomColor(aColor);
-            aCustomized = true;
-          }
-        }
-      }
-    }*/
-    // customize sketch dimension constraint presentation
-    //if (!aCustomized) {
-    //  if (!aCustomColor)
+    std::vector<int> aColor;
     XGUI_CustomPrs::getDefaultColor(anObject, true, aColor);
     if (!aColor.empty()) {
       aCustomized = thePrs->setColor(aColor[0], aColor[1], aColor[2]);
-    //  }
     }
   }
   // customize dimentional constrains
@@ -1065,47 +1040,32 @@ bool PartSet_Module::afterCustomisePresentation(std::shared_ptr<ModelAPI_Result>
     return aCustomized;
 
   std::vector<int> aColor;
-  bool aCustomColorChanged = myOverconstraintListener->isNeedUpdateCustomColor();
-  if (aCustomColorChanged) {
-    bool aUseCustomColor = true;
-    // do not use fully constrained color if create operation is started
-    /*if (aWorkshop->operationMgr()->hasOperation()) {
-      ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
-                                           (aWorkshop->operationMgr()->currentOperation());
-      if (aFOperation && !aFOperation->isEditOperation())
-        aUseCustomColor = false;
-    }*/
-    if (aUseCustomColor)
-      myOverconstraintListener->getCustomColor(anObject, aColor);
-    //if (!theResult.get()) {
-    // customize sketch symbol presentation
-    //if (thePrs.get()) {
-      Handle(AIS_InteractiveObject) anAISIO = thePrs->impl<Handle(AIS_InteractiveObject)>();
-      if (!anAISIO.IsNull()) {
-        if (!Handle(SketcherPrs_SymbolPrs)::DownCast(anAISIO).IsNull()) {
-          Handle(SketcherPrs_SymbolPrs) aPrs = Handle(SketcherPrs_SymbolPrs)::DownCast(anAISIO);
-          if (!aPrs.IsNull()) {
-            aPrs->SetCustomColor(aColor);
-            aCustomized = true;
-          }
-        } else if (!Handle(SketcherPrs_Coincident)::DownCast(anAISIO).IsNull()) {
-          Handle(SketcherPrs_Coincident) aPrs = Handle(SketcherPrs_Coincident)::DownCast(anAISIO);
-          if (!aPrs.IsNull()) {
-            aPrs->SetCustomColor(aColor);
-            aCustomized = true;
-          }
-        }
+  bool aUseCustomColor = true;
+  if (aUseCustomColor)
+    myOverconstraintListener->getCustomColor(anObject, aColor);
+  // customize sketch symbol presentation
+  Handle(AIS_InteractiveObject) anAISIO = thePrs->impl<Handle(AIS_InteractiveObject)>();
+  if (!anAISIO.IsNull()) {
+    if (!Handle(SketcherPrs_SymbolPrs)::DownCast(anAISIO).IsNull()) {
+      Handle(SketcherPrs_SymbolPrs) aPrs = Handle(SketcherPrs_SymbolPrs)::DownCast(anAISIO);
+      if (!aPrs.IsNull()) {
+        aPrs->SetCustomColor(aColor);
+        aCustomized = true;
       }
-    //}
-    // customize sketch dimension constraint presentation
-    if (!aCustomized) {
-      //if (!aCustomColor)
-      //  XGUI_CustomPrs::getDefaultColor(anObject, true, aColor);
-      if (!aColor.empty()) { // otherwise presentation has the default color
-        aCustomized = thePrs->setColor(aColor[0], aColor[1], aColor[2]);
+    } else if (!Handle(SketcherPrs_Coincident)::DownCast(anAISIO).IsNull()) {
+      Handle(SketcherPrs_Coincident) aPrs = Handle(SketcherPrs_Coincident)::DownCast(anAISIO);
+      if (!aPrs.IsNull()) {
+        aPrs->SetCustomColor(aColor);
+        aCustomized = true;
       }
     }
   }
+  // customize sketch dimension constraint presentation
+  if (!aCustomized) {
+    if (!aColor.empty()) { // otherwise presentation has the default color
+      aCustomized = thePrs->setColor(aColor[0], aColor[1], aColor[2]);
+    }
+  }
   return aCustomized;
 }
 
index 0e74b06001dd247194d8be3e5d85a91431aedf16..18125ad34cfb25b8bf623c5957f79eb4469ec84a 100755 (executable)
@@ -30,7 +30,7 @@
 //#define DEBUG_FEATURE_OVERCONSTRAINT_LISTENER
 
 PartSet_OverconstraintListener::PartSet_OverconstraintListener(ModuleBase_IWorkshop* theWorkshop)
-: myWorkshop(theWorkshop), myIsFullyConstrained(false)//, myIsNeedUpdateCustomColor(false)
+: myWorkshop(theWorkshop), myIsFullyConstrained(false)
 {
   Events_Loop* aLoop = Events_Loop::loop();
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SOLVER_FAILED));
@@ -54,7 +54,8 @@ void PartSet_OverconstraintListener::getCustomColor(const ObjectPtr& theObject,
   }
   if (myIsFullyConstrained) {
     FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
-    if (aFeature.get()) {
+    // only entity features has custom color when sketch is fully constrained
+    if (aFeature.get() && PartSet_SketcherMgr::isEntity(aFeature->getKind())) {
       PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
       CompositeFeaturePtr aCompositeFeature = aModule->sketchMgr()->activeSketch();
       // the given object is sub feature of the current sketch(created or edited)
@@ -114,7 +115,6 @@ void PartSet_OverconstraintListener::processEvent(
     myIsFullyConstrained = anEventID == Events_Loop::eventByName(EVENT_SKETCH_FULLY_CONSTRAINED);
 
     if (aPrevFullyConstrained != myIsFullyConstrained) {
-      //myIsNeedUpdateCustomColor = true;
       std::set<ObjectPtr> aModifiedObjects;
       PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
       CompositeFeaturePtr aSketch = aModule->sketchMgr()->activeSketch();
@@ -130,7 +130,6 @@ void PartSet_OverconstraintListener::processEvent(
         }
         redisplayObjects(aModifiedObjects);
       }
-      //myIsNeedUpdateCustomColor = false;
     }
   }
   else if (anEventID == Events_Loop::eventByName(EVENT_OBJECT_CREATED)) {
index 4051c0c9558c175f5f4e7abbc6bf8a257c62fbc7..9ce9a4e4cce7d9c9b85bba51cf1d23df497ba0af 100755 (executable)
@@ -44,10 +44,6 @@ public:
   /// \return boolean result
   void getCustomColor(const ObjectPtr& theObject, std::vector<int>& theColor);
 
-  /// Returns true if custom color of presentations is changed and it should be redisplayed
-  /// \return boolean value
-  bool isNeedUpdateCustomColor() const { return true;/*myIsNeedUpdateCustomColor;*/ }
-
   /// Redefinition of Events_Listener method
   virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
 
@@ -81,7 +77,6 @@ private:
   std::set<ObjectPtr> myConflictingObjects;
   ModuleBase_IWorkshop* myWorkshop;
   bool myIsFullyConstrained; /// state if Solver is fully constrained, DOF = 0
-  bool myIsNeedUpdateCustomColor;
 };
 
 #endif
index 26672b4726b4cf94ac9210dfb0d184d1c9f02d34..dafd6dd98246261e97fd705e1bee84c3c9d399e4 100644 (file)
@@ -1351,7 +1351,6 @@ bool XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO,
   return isActivationChanged;
 }
 
-//#define DEBUG_FULLY_CONSTRAINED
 bool XGUI_Displayer::customizeObject(ObjectPtr theObject)
 {
   AISObjectPtr anAISObj = getAISObject(theObject);
@@ -1374,10 +1373,8 @@ bool XGUI_Displayer::customizeObject(ObjectPtr theObject)
   }
   bool isCustomized = aCustomPrs.get() &&
                       aCustomPrs->customisePresentation(aResult, anAISObj, myCustomPrs);
-#ifdef DEBUG_FULLY_CONSTRAINED
   isCustomized = myWorkshop->module()->afterCustomisePresentation(aResult, anAISObj, myCustomPrs)
                  || isCustomized;
-#endif
   return isCustomized;
 }