]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' of newgeom:newgeom.git
authorsbh <sergey.belash@opencascade.com>
Tue, 15 Jul 2014 13:17:58 +0000 (17:17 +0400)
committersbh <sergey.belash@opencascade.com>
Tue, 15 Jul 2014 13:17:58 +0000 (17:17 +0400)
src/Model/Model_Document.cpp
src/Model/Model_Events.cpp
src/Model/Model_Events.h
src/Model/Model_Update.cpp
src/ModelAPI/ModelAPI_Events.h
src/PartSet/PartSet_Listener.cpp
src/SketchSolver/SketchSolver_ConstraintManager.cpp
src/XGUI/XGUI_DocumentDataModel.cpp
src/XGUI/XGUI_PartDataModel.cpp
src/XGUI/XGUI_Workshop.cpp

index df5c06b23c880db1f6284de52ab2f5b87b783f9b..ed3846d732f593bab3f97c3757ca685ac1a2585a 100644 (file)
@@ -484,11 +484,19 @@ boost::shared_ptr<ModelAPI_Document> Model_Document::subDocument(std::string the
 ObjectPtr Model_Document::object(const std::string& theGroupID, const int theIndex)
 {
   if (theGroupID == ModelAPI_Feature::group()) {
-    std::map<std::string, std::vector<ObjectPtr> >::iterator aFind = myObjs.find(theGroupID);
+    // features may be not in history but in the myObjs, so, iterate all
+    int anIndex = 0;
+    std::map<std::string, std::vector<ObjectPtr> >::iterator aFind = 
+      myObjs.find(ModelAPI_Feature::group());
     if (aFind != myObjs.end()) {
-      int aSize = aFind->second.size();
-      if (theIndex >= 0 && theIndex < aSize)
-        return aFind->second[theIndex];
+      std::vector<ObjectPtr>::iterator aFIter = aFind->second.begin();
+      for(; aFIter != aFind->second.end(); aFIter++) {
+        if ((*aFIter)->isInHistory()) {
+          if (theIndex == anIndex)
+            return *aFIter;
+          anIndex++;
+        }
+      }
     }
   } else {
     // iterate all features in order to find the needed result
@@ -518,9 +526,16 @@ int Model_Document::size(const std::string& theGroupID)
 {
   int aResult = 0;
   if (theGroupID == ModelAPI_Feature::group()) {
-    std::map<std::string, std::vector<ObjectPtr> >::iterator aFind = myObjs.find(theGroupID);
+    // features may be not in history but in the myObjs, so, iterate all
+    std::map<std::string, std::vector<ObjectPtr> >::iterator aFind = 
+      myObjs.find(ModelAPI_Feature::group());
     if (aFind != myObjs.end()) {
-      aResult = aFind->second.size();
+      std::vector<ObjectPtr>::iterator aFIter = aFind->second.begin();
+      for(; aFIter != aFind->second.end(); aFIter++) {
+        if ((*aFIter)->isInHistory()) {
+          aResult++;
+        }
+      }
     }
   } else {
     // iterate all features in order to find the needed result
index 2def67f43e8eb7fdd108a42e91c733055d7ab7eb..4096dd65e3b1ef9a521d494cb1dc5d71f77c17ab 100644 (file)
@@ -36,7 +36,7 @@ Model_ObjectUpdatedMessage::Model_ObjectUpdatedMessage(
   if (theObject) myObjects.insert(theObject);
 }
 
-std::set<ObjectPtr> Model_ObjectUpdatedMessage::features() const 
+std::set<ObjectPtr> Model_ObjectUpdatedMessage::objects() const 
 {
   return myObjects;
 }
index 56e4b141f83743980cc8c3acf1e690688d9d1650..4125cf81c07aaf6cc91909faa012a50b28d370d4 100644 (file)
@@ -36,7 +36,7 @@ class Model_ObjectUpdatedMessage : public ModelAPI_ObjectUpdatedMessage {
 public:
 
   /// Returns the feature that has been updated
-  virtual std::set<ObjectPtr> features() const;
+  virtual std::set<ObjectPtr> objects() const;
 
   //! Creates a new empty group (to store it in the loop before flush)
   virtual Events_MessageGroup* newEmpty();
index 28048664e146ce06f0ca7211688d565a4dc302e0..25ecbbeb5113919893e9da76eadec0bb41a177d0 100644 (file)
@@ -24,7 +24,7 @@ void Model_Update::processEvent(const Events_Message* theMessage)
 {
   const ModelAPI_ObjectUpdatedMessage* aMsg = 
     dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
-  myInitial = aMsg->features();
+  myInitial = aMsg->objects();
   // collect all documents involved into the update
   set<boost::shared_ptr<ModelAPI_Document> > aDocs;
   set<boost::shared_ptr<ModelAPI_Object> >::iterator aFIter = myInitial.begin();
index 773d20b41d23797d4a99536534adc3dbfcb58117..143f45e912e6a87d2560aeb463e602185d8d3d11 100644 (file)
@@ -36,7 +36,7 @@ protected:
 
 public:
   /// Returns the feature that has been updated
-  virtual std::set<ObjectPtr> features() const = 0;
+  virtual std::set<ObjectPtr> objects() const = 0;
 
   //! Creates a new empty group (to store it in the loop before flush)
   virtual Events_MessageGroup* newEmpty() = 0;
index f94e6c24f45d7f0b1ac7e90db35ee94e807899e7..db10764ad1cea8a67ed8e7978d38efb3fa7c7295 100644 (file)
@@ -42,7 +42,7 @@ void PartSet_Listener::processEvent(const Events_Message* theMessage)
   {
     const ModelAPI_ObjectUpdatedMessage* aUpdMsg = 
       dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
-    std::set<ObjectPtr > aFeatures = aUpdMsg->features();
+    std::set<ObjectPtr > aFeatures = aUpdMsg->objects();
     std::set<ObjectPtr >::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
     for (; anIt != aLast; anIt++) {
       ObjectPtr aObject = *anIt;
index dbdc7b92791f83a88e3cc7484a2395c8eac8b4fe..e21bb346acbb9b52dd4613f480b911885637e4e1 100644 (file)
@@ -65,7 +65,7 @@ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessa
   {
     const ModelAPI_ObjectUpdatedMessage* anUpdateMsg = 
       dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
-    std::set< ObjectPtr > aFeatures = anUpdateMsg->features();
+    std::set< ObjectPtr > aFeatures = anUpdateMsg->objects();
 
     bool isModifiedEvt = 
       theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED);
index 1e62ae84e367d05021044188d12ad1cb2d6a232c..778cec850659368c6ed7dc3c8d417628cb39d2fe 100644 (file)
@@ -50,14 +50,18 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
   // Created object event *******************
   if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
     const Model_ObjectUpdatedMessage* aUpdMsg = dynamic_cast<const Model_ObjectUpdatedMessage*>(theMessage);
-    std::set<ObjectPtr> aFeatures = aUpdMsg->features();
+    std::set<ObjectPtr> aObjects = aUpdMsg->objects();
 
     std::set<ObjectPtr>::const_iterator aIt;
-    for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
-      ObjectPtr aFeature = (*aIt);
-      DocumentPtr aDoc = aFeature->document();
+    for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
+      ObjectPtr aObject = (*aIt);
+      FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObject);
+      if (aFeature && (!aFeature->isInHistory()))
+        continue;
+
+      DocumentPtr aDoc = aObject->document();
       if (aDoc == aRootDoc) {  // If root objects
-        if (aFeature->groupName().compare(ModelAPI_ResultPart::group()) == 0) { // Update only Parts group
+        if (aObject->groupName() == ModelAPI_ResultPart::group()) { // Update only Parts group
           // Add a new part
           int aStart = myPartModels.size();
           XGUI_PartDataModel* aModel = new XGUI_PartDataModel(this);
@@ -65,7 +69,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
           myPartModels.append(aModel);
           insertRow(aStart, partFolderNode());
         } else { // Update top groups (other except parts
-          QModelIndex aIndex = myModel->findParent(aFeature);
+          QModelIndex aIndex = myModel->findParent(aObject);
           int aStart = myModel->rowCount(aIndex) - 1;
           aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex));
           insertRow(aStart, aIndex);
@@ -80,7 +84,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
           }
         }
         if (aPartModel) {
-          QModelIndex aIndex = aPartModel->findParent(aFeature);
+          QModelIndex aIndex = aPartModel->findParent(aObject);
           int aStart = aPartModel->rowCount(aIndex) - 1;
           aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex));
           insertRow(aStart, aIndex);
index 521e193c21e966ab5ff64ba9049d996fe981535f..82f8c132bb298b478dc280e8bb1ceb77bf40a016 100644 (file)
@@ -390,7 +390,7 @@ DocumentPtr XGUI_PartDataModel::partDocument() const
 {
   DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
   ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), myId);
-  return aObject->data()->docRef("PartDocument")->value();
+  return aObject->document();
 }
  
 ObjectPtr XGUI_PartDataModel::object(const QModelIndex& theIndex) const
index dddd97fb627b7570ded17519435a9f7138c6aa2e..436803e09bfdc9fa1809d87a9cd17d454ba8e6c8 100644 (file)
@@ -274,7 +274,7 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage)
 //******************************************************
 void XGUI_Workshop::onFeatureUpdatedMsg(const Model_ObjectUpdatedMessage* theMsg)
 {
-  std::set<ObjectPtr> aFeatures = theMsg->features();
+  std::set<ObjectPtr> aFeatures = theMsg->objects();
   if (myOperationMgr->hasOperation())
   {
     FeaturePtr aCurrentFeature = myOperationMgr->currentOperation()->feature();
@@ -292,10 +292,10 @@ void XGUI_Workshop::onFeatureUpdatedMsg(const Model_ObjectUpdatedMessage* theMsg
 //******************************************************
 void XGUI_Workshop::onFeatureRedisplayMsg(const Model_ObjectUpdatedMessage* theMsg)
 {
-  std::set<ObjectPtr> aFeatures = theMsg->features();
+  std::set<ObjectPtr> aObjects = theMsg->objects();
   std::set<ObjectPtr>::const_iterator aIt;
   bool isDisplayed = false;
-  for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
+  for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
     ResultPtr aRes = boost::dynamic_pointer_cast<ModelAPI_Result>(*aIt);
     if (aRes) {
       isDisplayed = myDisplayer->redisplay(aRes, false);
@@ -308,7 +308,7 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const Model_ObjectUpdatedMessage* theM
 //******************************************************
 void XGUI_Workshop::onFeatureCreatedMsg(const Model_ObjectUpdatedMessage* theMsg)
 {
-  std::set<ObjectPtr> aFeatures = theMsg->features();
+  std::set<ObjectPtr> aFeatures = theMsg->objects();
 
   std::set<ObjectPtr>::const_iterator aIt;
   bool aHasPart = false;