]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for the constructions folder on remove sketch did not updated
authormpv <mpv@opencascade.com>
Thu, 28 May 2015 11:16:14 +0000 (14:16 +0300)
committermpv <mpv@opencascade.com>
Thu, 28 May 2015 11:16:14 +0000 (14:16 +0300)
src/Events/Events_Error.h
src/Model/Model_Objects.cpp
src/Model/Model_Objects.h

index e5e611ab24ff7fc80b1d62e9c24d5a66dfdce992..e288f9f55e90a5e80f2f971d03541f2861ae394d 100644 (file)
  * Is generated by any algorithm or GUI of the application to inform the user about
  * the problem. In GUI mode all such errors are collected in the message log window.
  */
-class EVENTS_EXPORT Events_Error : public Events_Message
+class Events_Error : public Events_Message
 {
   std::string myDescription;  ///< the description of the error
 
 public:
   /// default destructor   
-  virtual ~Events_Error();
+  EVENTS_EXPORT virtual ~Events_Error();
 
   /// Identifier of this event (one for all errors)
-  static Events_ID errorID();
+  EVENTS_EXPORT static Events_ID errorID();
   /// Specific error string
-  const char* description() const;
+  EVENTS_EXPORT const char* description() const;
   /// Allows to send an error quickly: it creates and sends the error object automatically
-  static void send(const std::string& theDescription, const void* theSender = 0);
+  EVENTS_EXPORT static void send(const std::string& theDescription, const void* theSender = 0);
 
 protected:
   /// Default constructor. Use "send" message for generation an error.
-  Events_Error(const std::string& theDescription, const void* theSender = 0);
+  EVENTS_EXPORT Events_Error(const std::string& theDescription, const void* theSender = 0);
 };
 
 #endif /* EVENTS_ERROR_H_ */
index 6196ca95390c5353b62ccd0602aaabd1767aeab0..deadfd2a3c8b686c80147f0f0517e5de4135251f 100644 (file)
@@ -218,6 +218,10 @@ void Model_Objects::removeFeature(FeaturePtr theFeature)
         aComposite->removeFeature(theFeature);
       }
     }
+    // this must be before erase since theFeature erasing removes all information about
+    // the feature results and groups of results
+    // To reproduce: create sketch, extrusion, remove sketch => constructions tree is not updated
+    clearHistory(theFeature);
     // erase fields
     theFeature->erase();
 
@@ -225,8 +229,6 @@ void Model_Objects::removeFeature(FeaturePtr theFeature)
     if (myFeatures.IsBound(aFeatureLabel))
       myFeatures.UnBind(aFeatureLabel);
 
-    clearHistory(theFeature);
-
     static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
     ModelAPI_EventCreator::get()->sendUpdated(theFeature, EVENT_DISP);
     // erase all attributes under the label of feature
@@ -250,8 +252,13 @@ void Model_Objects::clearHistory(ObjectPtr theObj)
       myHistory.erase(aHIter); // erase from map => this means that it is not synchronized
     if (theObj->groupName() == ModelAPI_Feature::group()) { // clear results group of the feature
       FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObj);
-      if (aFeature->firstResult().get())
-        clearHistory(aFeature->firstResult());
+      std::string aResultGroup = featureResultGroup(aFeature);
+      if (!aResultGroup.empty()) {
+        std::map<std::string, std::vector<ObjectPtr> >::iterator aHIter = 
+          myHistory.find(aResultGroup);
+        if (aHIter != myHistory.end())
+          myHistory.erase(aHIter); // erase from map => this means that it is not synchronized
+      }
     }
   }
 }
@@ -754,6 +761,22 @@ std::shared_ptr<ModelAPI_Feature> Model_Objects::feature(
   return FeaturePtr();
 }
 
+std::string Model_Objects::featureResultGroup(FeaturePtr theFeature)
+{
+  if (theFeature->data()->isValid()) {
+    TDF_ChildIterator aLabIter(resultLabel(theFeature->data(), 0).Father());
+    if (aLabIter.More()) {
+      TDF_Label anArgLab = aLabIter.Value();
+      Handle(TDataStd_Comment) aGroup;
+      if (aLabIter.Value().FindAttribute(TDataStd_Comment::GetID(), aGroup)) {
+        return TCollection_AsciiString(aGroup->Get()).ToCString();
+      }
+    }
+  }
+  static std::string anEmpty;
+  return anEmpty; // not found
+}
+
 void Model_Objects::updateResults(FeaturePtr theFeature)
 {
   // for not persistent is will be done by parametric updater automatically
index 6cf221e0b498efefc05f81a6818a3984112bfeda..ef1d403b64cdc18275bc0bb93e001d65d61e8a24 100644 (file)
@@ -170,6 +170,10 @@ class Model_Objects
   /// Returns to the last (from the history point of view) feature, any: invisible or disabled
   FeaturePtr lastFeature();
 
+  /// Returns the result group identifier of the given feature (for this at least one result must 
+  /// be created before)
+  std::string featureResultGroup(FeaturePtr theFeature);
+
  private:
   TDF_Label myMain; ///< main label of the data storage