]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' of newgeom:newgeom.git
authorsbh <sergey.belash@opencascade.com>
Fri, 25 Jul 2014 07:59:12 +0000 (11:59 +0400)
committersbh <sergey.belash@opencascade.com>
Fri, 25 Jul 2014 07:59:12 +0000 (11:59 +0400)
20 files changed:
src/Model/Model_Document.cpp
src/Model/Model_Document.h
src/Model/Model_Update.cpp
src/Model/Model_Update.h
src/ModelAPI/ModelAPI_Document.h
src/ModelAPI/ModelAPI_Feature.cpp
src/ModelAPI/ModelAPI_Feature.h
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_ResultValidators.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OperationSketch.cpp
src/SketchPlugin/SketchPlugin_Circle.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.h
src/SketchPlugin/SketchPlugin_ConstraintLength.cpp
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_Sketch.h
src/SketchSolver/SketchSolver_Constraint.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Workshop.cpp

index 41c7e79bfa14bf9f26f80494717548ba50e32089..c50b4a05b44f6a52465d4c441b8617d93596e355 100644 (file)
@@ -493,16 +493,29 @@ boost::shared_ptr<ModelAPI_Document> Model_Document::subDocument(std::string the
   return Model_Application::getApplication()->getDocument(theDocID);
 }
 
-ObjectPtr Model_Document::object(const std::string& theGroupID, const int theIndex)
+ObjectPtr Model_Document::object(const std::string& theGroupID, 
+  const int theIndex, const bool theHidden)
 {
   if (theGroupID == ModelAPI_Feature::group()) {
-    Handle(TDataStd_ReferenceArray) aRefs;
-    if (!featuresLabel().FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs))
-      return ObjectPtr();
-    if (aRefs->Lower() > theIndex || aRefs->Upper() < theIndex)
-      return ObjectPtr();
-    TDF_Label aFeatureLabel = aRefs->Value(theIndex);
-    return feature(aFeatureLabel);
+    if (theHidden) {
+      int anIndex = 0;
+      TDF_ChildIDIterator aLabIter(featuresLabel(), TDataStd_Comment::GetID());
+      for(; aLabIter.More(); aLabIter.Next()) {
+        if (theIndex == anIndex) {
+          TDF_Label aFLabel = aLabIter.Value()->Label();
+          return feature(aFLabel);
+        }
+        anIndex++;
+      }
+    } else {
+      Handle(TDataStd_ReferenceArray) aRefs;
+      if (!featuresLabel().FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs))
+        return ObjectPtr();
+      if (aRefs->Lower() > theIndex || aRefs->Upper() < theIndex)
+        return ObjectPtr();
+      TDF_Label aFeatureLabel = aRefs->Value(theIndex);
+      return feature(aFeatureLabel);
+    }
   } else {
     // comment must be in any feature: it is kind
     int anIndex = 0;
@@ -513,7 +526,7 @@ ObjectPtr Model_Document::object(const std::string& theGroupID, const int theInd
       const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
       std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
       for(; aRIter != aResults.cend(); aRIter++) {
-        if ((*aRIter)->isInHistory() && (*aRIter)->groupName() == theGroupID) {
+        if ((theHidden || (*aRIter)->isInHistory()) && (*aRIter)->groupName() == theGroupID) {
           if (anIndex == theIndex)
             return *aRIter;
           anIndex++;
@@ -525,13 +538,17 @@ ObjectPtr Model_Document::object(const std::string& theGroupID, const int theInd
   return ObjectPtr();
 }
 
-int Model_Document::size(const std::string& theGroupID) 
+int Model_Document::size(const std::string& theGroupID, const bool theHidden
 {
   int aResult = 0;
   if (theGroupID == ModelAPI_Feature::group()) {
-    Handle(TDataStd_ReferenceArray) aRefs;
-    if (featuresLabel().FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs))
-      return aRefs->Length();
+    if (theHidden) {
+      return myObjs.Size();
+    } else {
+      Handle(TDataStd_ReferenceArray) aRefs;
+      if (featuresLabel().FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs))
+        return aRefs->Length();
+    }
   } else {
     // comment must be in any feature: it is kind
     TDF_ChildIDIterator aLabIter(featuresLabel(), TDataStd_Comment::GetID());
@@ -541,7 +558,7 @@ int Model_Document::size(const std::string& theGroupID)
       const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
       std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
       for(; aRIter != aResults.cend(); aRIter++) {
-        if ((*aRIter)->isInHistory() && (*aRIter)->groupName() == theGroupID) {
+        if ((theHidden || (*aRIter)->isInHistory()) && (*aRIter)->groupName() == theGroupID) {
           aResult++;
         }
       }
@@ -614,7 +631,7 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated)
   boost::shared_ptr<ModelAPI_Document> aThis = 
     Model_Application::getApplication()->getDocument(myID);
   // update all objects by checking are they of labels or not
-  std::set<FeaturePtr> aCheckedFeatures;
+  std::set<FeaturePtr> aNewFeatures, aKeptFeatures;
   TDF_ChildIDIterator aLabIter(featuresLabel(), TDataStd_Comment::GetID());
   for(; aLabIter.More(); aLabIter.Next()) {
     TDF_Label aFeatureLabel = aLabIter.Value()->Label();
@@ -625,26 +642,31 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated)
         .ToCString());
       // this must be before "setData" to redo the sketch line correctly
       myObjs.Bind(aFeatureLabel, aNewObj);
-      aCheckedFeatures.insert(aNewObj);
+      aNewFeatures.insert(aNewObj);
       initData(aNewObj, aFeatureLabel, TAG_FEATURE_ARGUMENTS);
-      aNewObj->execute(); // to restore results list
 
       // event: model is updated
       static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
       ModelAPI_EventCreator::get()->sendUpdated(aNewObj, anEvent);
       // feature for this label is added, so go to the next label
     } else { // nothing is changed, both iterators are incremented
-      aCheckedFeatures.insert(myObjs.Find(aFeatureLabel));
+      aKeptFeatures.insert(myObjs.Find(aFeatureLabel));
       if (theMarkUpdated) {
         static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
         ModelAPI_EventCreator::get()->sendUpdated(myObjs.Find(aFeatureLabel), anEvent);
       }
     }
   }
+  // execute new features to restore results: after features creation to make all references valid
+  /*std::set<FeaturePtr>::iterator aNewIter = aNewFeatures.begin();
+  for(; aNewIter != aNewFeatures.end(); aNewIter++) {
+      (*aNewIter)->execute();
+  }*/
   // check all features are checked: if not => it was removed
   NCollection_DataMap<TDF_Label, FeaturePtr>::Iterator aFIter(myObjs);
   while(aFIter.More()) {
-    if (aCheckedFeatures.find(aFIter.Value()) == aCheckedFeatures.end()) {
+    if (aKeptFeatures.find(aFIter.Value()) == aKeptFeatures.end() &&
+        aNewFeatures.find(aFIter.Value()) == aNewFeatures.end()) {
       FeaturePtr aFeature = aFIter.Value();
       TDF_Label aLab = aFIter.Key();
       aFIter.Next();
index 340ecd4ccf9d662be95224b9c883686c01a1ac99..8bb19057c8ef1aea4c60479fa68aecbcc12017e6 100644 (file)
@@ -92,10 +92,13 @@ public:
   //! \param theGroupID group that contains a feature
   //! \param theIndex zero-based index of feature in the group
   //! \param isOperation if it is true, returns feature (not Object)
-  MODEL_EXPORT virtual ObjectPtr object(const std::string& theGroupID, const int theIndex);
+  //! \param theHidden if it is true, it counts also the features that are not in tree
+  MODEL_EXPORT virtual ObjectPtr object(const std::string& theGroupID, const int theIndex,
+    const bool theHidden = false);
 
   //! Returns the number of features in the group
-  MODEL_EXPORT virtual int size(const std::string& theGroupID);
+  //! If theHidden is true, it counts also the features that are not in tree
+  MODEL_EXPORT virtual int size(const std::string& theGroupID, const bool theHidden = false);
 
   /// Creates a construction cresults
   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_ResultConstruction> createConstruction(
index 15b8139ec1138a7c1c6528e3bf9707e25821387c..a50f19c6a2ba91767aee44ca7ad51e17b4b03349 100644 (file)
@@ -18,6 +18,7 @@ Model_Update MY_INSTANCE; /// the only one instance initialized on load of the l
 
 Model_Update::Model_Update()
 {
+  Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
   Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
 }
 
@@ -32,15 +33,15 @@ void Model_Update::processEvent(const Events_Message* theMessage)
   for(; aFIter != myInitial.end(); aFIter++) {
     aDocs.insert((*aFIter)->document());
   }
-  // iterate all features of features-documents to update them
+  // iterate all features of features-documents to update them (including hidden)
   set<boost::shared_ptr<ModelAPI_Document> >::iterator aDIter = aDocs.begin();
   for(; aDIter != aDocs.end(); aDIter++) {
-    int aNbFeatures = (*aDIter)->size(ModelAPI_Feature::group());
+    int aNbFeatures = (*aDIter)->size(ModelAPI_Feature::group(), true);
     for(int aFIndex = 0; aFIndex < aNbFeatures; aFIndex++) {
-      boost::shared_ptr<ModelAPI_Object> aFeature = boost::dynamic_pointer_cast<ModelAPI_Object>
-        ((*aDIter)->object(ModelAPI_Feature::group(), aFIndex));
+      FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>
+        ((*aDIter)->object(ModelAPI_Feature::group(), aFIndex, true));
       if (aFeature)
-        updateObject(aFeature);
+        updateFeature(aFeature);
     }
   }
   myUpdated.clear();
@@ -49,52 +50,85 @@ void Model_Update::processEvent(const Events_Message* theMessage)
   Events_Loop::loop()->flush(EVENT_DISP);
 }
 
-bool Model_Update::updateObject(boost::shared_ptr<ModelAPI_Object> theObject)
+bool Model_Update::updateFeature(FeaturePtr theFeature)
 {
   // check it is already processed
-  if (myUpdated.find(theObject) != myUpdated.end())
-    return myUpdated[theObject];
+  if (myUpdated.find(theFeature) != myUpdated.end())
+    return myUpdated[theFeature];
   // check all features this feature depended on (recursive call of updateFeature)
-  bool anExecute = myInitial.find(theObject) != myInitial.end();
-  bool aMustbeUpdated = myInitial.find(theObject) != myInitial.end();
-  FeaturePtr aRealFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
-  if (aRealFeature) { // only real feature contains references to other objects
+  bool aMustbeUpdated = myInitial.find(theFeature) != myInitial.end();
+  if (theFeature) { // only real feature contains references to other objects
     // references
     list<boost::shared_ptr<ModelAPI_Attribute> > aRefs = 
-      theObject->data()->attributes(ModelAPI_AttributeReference::type());
+      theFeature->data()->attributes(ModelAPI_AttributeReference::type());
     list<boost::shared_ptr<ModelAPI_Attribute> >::iterator aRefsIter = aRefs.begin();
     for(; aRefsIter != aRefs.end(); aRefsIter++) {
       boost::shared_ptr<ModelAPI_Object> aSub =
         boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(*aRefsIter)->value();
-      if (aSub && aSub != theObject && updateObject(aSub))
+      if (updateObject(aSub)) {
         aMustbeUpdated = true;
+      }
     }
     // lists of references
-    aRefs = theObject->data()->attributes(ModelAPI_AttributeRefList::type());
+    aRefs = theFeature->data()->attributes(ModelAPI_AttributeRefList::type());
     for(aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) {
       list<ObjectPtr> aListRef = 
         boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(*aRefsIter)->list();
       list<ObjectPtr>::iterator aListIter = aListRef.begin();
       for(; aListIter != aListRef.end(); aListIter++) {
         boost::shared_ptr<ModelAPI_Object> aSub = *aListIter;
-        if (aSub && updateObject(aSub))
+        if (updateObject(aSub)) {
           aMustbeUpdated = true;
+        }
       }
     }
     // execute feature if it must be updated
-    anExecute = aMustbeUpdated || anExecute;
-    if (anExecute) {
-      aRealFeature->execute();
+    if (aMustbeUpdated) {
+      theFeature->execute();
       // redisplay all results
       static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
-      const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = aRealFeature->results();
+      const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = theFeature->results();
       std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
       for(; aRIter != aResults.cend(); aRIter++) {
         boost::shared_ptr<ModelAPI_Result> aRes = *aRIter;
+        myUpdated[aRes] = true;
         ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP);
       }
+    } else { // returns also true is results were updated: for sketch that refers to sub-features but results of sub-features were changed
+      const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = theFeature->results();
+      std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
+      for(; aRIter != aResults.cend(); aRIter++) {
+        if (myInitial.find(*aRIter) != myInitial.end()) {
+          aMustbeUpdated = true;
+          break;
+        }
+      }
+    }
+  }
+  myUpdated[theFeature] = aMustbeUpdated;
+  return aMustbeUpdated;
+}
+
+bool Model_Update::updateObject(boost::shared_ptr<ModelAPI_Object> theObject)
+{
+  if (!theObject) 
+    return false;
+  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
+  if (aFeature) { // for feature just call update Feature
+    return updateFeature(aFeature);
+  }
+  // check general object, possible just a result
+  if (myUpdated.find(theObject) != myUpdated.end())
+    return myUpdated[theObject]; // already processed
+  // check the feature of this object must be executed
+  ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+  if (aResult) {
+    FeaturePtr aResFeature = aResult->document()->feature(aResult);
+    if (aResFeature) {
+      return updateFeature(aResFeature);
     }
   }
-  myUpdated[theObject] = anExecute;
-  return anExecute;
+  if (myInitial.find(theObject) != myInitial.end())
+    return true;
+  return false; // nothing is known
 }
index f59d891f78609c6cc067908da3eeb02893893e0a..f96bbf8adaed2c069f054122de127c2d699907ff 100644 (file)
@@ -32,7 +32,11 @@ public:
   MODEL_EXPORT virtual void processEvent(const Events_Message* theMessage);
 
 protected:
-  /// Recoursively checks and updates the object if needed
+  /// Recoursively checks and updates the feature if needed (calls the execute method)
+  /// Returns true if feature was updated.
+  bool updateFeature(boost::shared_ptr<ModelAPI_Feature> theFeature);
+
+  /// Recoursively checks and updates the object (result or feature) if needed (calls updateFeature)
   /// Returns true if object was updated.
   bool updateObject(boost::shared_ptr<ModelAPI_Object> theObject);
 };
index 2aebf34d9d4ad326283d83eeddff0179b49b598d..ab055f32484a4db83d9d447192709832bd74c31f 100644 (file)
@@ -78,11 +78,13 @@ public:
   //! Returns the object in the group by the index (started from zero)
   //! \param theGroupID group that contains an object
   //! \param theIndex zero-based index of feature in the group
+  //! \param theHidden if it is true, it counts also the features that are not in tree
   virtual boost::shared_ptr<ModelAPI_Object> 
-    object(const std::string& theGroupID, const int theIndex) = 0;
+    object(const std::string& theGroupID, const int theIndex, const bool theHidden = false) = 0;
 
   //! Returns the number of objects in the group of objects
-  virtual int size(const std::string& theGroupID) = 0;
+  //! If theHidden is true, it counts also the features that are not in tree
+  virtual int size(const std::string& theGroupID, const bool theHidden = false) = 0;
 
   /// To virtually destroy the fields of successors
   virtual ~ModelAPI_Document() {}
index fa4651408dd513c906e83528f53b41141ee8c085..5617cedd9a9fffdb5747edd7b6269a688dd0309d 100644 (file)
@@ -37,6 +37,26 @@ void ModelAPI_Feature::setResult(const boost::shared_ptr<ModelAPI_Result>& theRe
   Events_Loop::loop()->flush(anEvent);
 }
 
+void ModelAPI_Feature::setResult(
+  const boost::shared_ptr<ModelAPI_Result>& theResult, const int theIndex) 
+{
+  std::list<boost::shared_ptr<ModelAPI_Result> >::iterator aResIter = myResults.begin();
+  for(int anIndex = 0; anIndex < theIndex; anIndex++) {
+    aResIter++;
+  }
+  if (aResIter == myResults.end()) { // append
+    myResults.push_back(theResult);
+    static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
+    ModelAPI_EventCreator::get()->sendUpdated(theResult, anEvent);
+    // Create event for first Feature, send it to make "created" earlier than "updated"
+    Events_Loop::loop()->flush(anEvent);
+  } else { // update
+    *aResIter = theResult;
+    static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
+    ModelAPI_EventCreator::get()->sendUpdated(theResult, anEvent);
+  }
+}
+
 boost::shared_ptr<ModelAPI_Document> ModelAPI_Feature::documentToAdd()
 {
   return ModelAPI_PluginManager::get()->currentDocument();
index 2305044edd546e0905e5e07d2d6b8daff88dba3f..b42266074ba9bb3a2e54e2a015194de812a8539f 100644 (file)
@@ -48,6 +48,9 @@ public:
   MODELAPI_EXPORT boost::shared_ptr<ModelAPI_Result> firstResult();
   /// sets the alone result
   MODELAPI_EXPORT void setResult(const boost::shared_ptr<ModelAPI_Result>& theResult);
+  /// sets the result by index (zero based), results before this must be set before
+  MODELAPI_EXPORT void setResult(
+    const boost::shared_ptr<ModelAPI_Result>& theResult, const int theIndex);
 
   /// Returns true if this feature must not be created: this is just an action
   /// that is not stored in the features history and data model (like "delete part").
index 0387105b784b57acc96c4ddb5ce475f42b48692f..f3a657548a6fcf25bf613f9cb9b4662d02f2074b 100644 (file)
@@ -137,12 +137,12 @@ bool ModuleBase_Operation::hasObject(ObjectPtr theObj) const
 {
   FeaturePtr aFeature = feature();
   if (aFeature) {
-    if (aFeature.get() == theObj.get())
+    if (aFeature == theObj)
       return true;
     std::list<ResultPtr> aResults = aFeature->results();
     std::list<ResultPtr>::const_iterator aIt;
     for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
-      if ((*aIt).get() == theObj.get())
+      if ((*aIt) == theObj)
         return true;
     }
   }
index 631857d15c8cc4a28c58f74406e178b7c9d93f89..548fc549cf307a3557b4cf2c4585c4c1c07c6d60 100644 (file)
@@ -71,6 +71,7 @@ bool ModuleBase_ResulArcValidator::isValid(const ObjectPtr theObject) const
   if (aShape.IsNull())
     return false;
 
+  TopAbs_ShapeEnum aa = aShape.ShapeType();
   if (aShape.ShapeType() == TopAbs_EDGE) {
     TopoDS_Edge aEdge = TopoDS::Edge(aShape);
     Standard_Real aStart, aEnd;
index e3f4117e6175291803102a7d46faebbc41aef2bf..ba88c8251297c949d651855c5fb487dc3edff51a 100644 (file)
@@ -346,28 +346,28 @@ void PartSet_Module::onCloseLocalContext()
 
 void PartSet_Module::onFeatureConstructed(ObjectPtr theFeature, int theMode)
 {
-//  bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
-//  if (isDisplay) {
-    ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
-    PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
-    if (aPrevOp) {
-      std::list<FeaturePtr> aList = aPrevOp->subFeatures();
-      XGUI_Displayer* aDisplayer = myWorkshop->displayer();
-      std::list<int> aModes = aPrevOp->getSelectionModes(aPrevOp->feature());
-      std::list<FeaturePtr>::iterator aSFIt; 
-      for (aSFIt = aList.begin(); aSFIt != aList.end(); ++aSFIt) {
-        std::list<ResultPtr> aResults = (*aSFIt)->results();
-        std::list<ResultPtr>::iterator aIt;
-        for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
+  bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
+  ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
+  PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
+  if (aPrevOp) {
+    std::list<FeaturePtr> aList = aPrevOp->subFeatures();
+    XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+    std::list<int> aModes = aPrevOp->getSelectionModes(aPrevOp->feature());
+    std::list<FeaturePtr>::iterator aSFIt; 
+    for (aSFIt = aList.begin(); aSFIt != aList.end(); ++aSFIt) {
+      std::list<ResultPtr> aResults = (*aSFIt)->results();
+      std::list<ResultPtr>::iterator aIt;
+      for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
+        if (isDisplay)
           aDisplayer->activateInLocalContext((*aIt), aModes, false);
-        }
+        else
+          aDisplayer->erase((*aIt), false);
       }
     }
+  }
+  if (isDisplay)
     ModelAPI_EventCreator::get()->sendUpdated(theFeature, 
         Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
-//  }
-//  else
-//    ->erase(theFeature->firstResult(), true);
 /*  bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
   // TODO visualizePreview(theFeature, isDisplay, false);
   if (!isDisplay) {
@@ -543,8 +543,13 @@ void PartSet_Module::updateCurrentPreview(const std::string& theCmdId)
       boost::dynamic_pointer_cast<SketchPlugin_Feature>(*anIt);
     if (!aSPFeature)
       continue;
-    //visualizePreview((*anIt), true, false);
-    aDisplayer->activateInLocalContext((*anIt), aModes, false);
+    std::list<ResultPtr> aResults = aSPFeature->results();
+    std::list<ResultPtr>::const_iterator aRIt;
+    for (aRIt = aResults.cbegin(); aRIt != aResults.cend(); ++aRIt) {
+      aDisplayer->display((*aRIt), false);
+      aDisplayer->activateInLocalContext((*aRIt), aModes, false);
+    }
+    aDisplayer->display(aSPFeature, false);
   }
   aDisplayer->updateViewer();
 }
index 5adc7e0354de481ef8255cc24f14ceb98194009a..81ba69a079ed80f19ec060c3fe2421f137378751 100644 (file)
@@ -14,6 +14,7 @@
 #include <ModelAPI_Data.h>
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeRefList.h>
+#include <ModelAPI_Events.h>
 
 #include <GeomAlgoAPI_FaceBuilder.h>
 #include <GeomDataAPI_Point.h>
@@ -21,6 +22,7 @@
 #include <GeomAPI_XYZ.h>
 
 #include <ModuleBase_ViewerPrs.h>
+#include <Events_Loop.h>
 
 #include <AIS_Shape.hxx>
 #include <AIS_ListOfInteractive.hxx>
@@ -163,6 +165,16 @@ void PartSet_OperationSketch::stopOperation()
   PartSet_OperationSketchBase::stopOperation();
   emit featureConstructed(feature(), FM_Hide);
   emit closeLocalContext();
+
+  FeaturePtr aFeature = feature();
+  std::list<ResultPtr> aResults = aFeature->results();
+  std::list<ResultPtr>::const_iterator aIt;
+  for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
+    ModelAPI_EventCreator::get()->sendUpdated(*aIt, 
+      Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
+  }
+  //ModelAPI_EventCreator::get()->sendUpdated(aFeature, 
+  //  Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
 }
 
 bool PartSet_OperationSketch::isNestedOperationsEnabled() const
index 35371ff9dea7dd90994a7f78f0d83393224532e1..d8be73285033ba3efff5efe4db974950b42c5e15 100644 (file)
@@ -43,7 +43,12 @@ void SketchPlugin_Circle::execute()
       boost::shared_ptr<GeomAPI_Pnt> aCenter(aSketch->to3D(aCenterAttr->x(), aCenterAttr->y()));
       // make a visible point
       boost::shared_ptr<GeomAPI_Shape> aCenterPointShape = GeomAlgoAPI_PointBuilder::point(aCenter);
-      aShapes.push_back(aCenterPointShape);
+      //aShapes.push_back(aCenterPointShape);
+      boost::shared_ptr<ModelAPI_ResultConstruction> aConstr1 = 
+        document()->createConstruction(data());
+      aConstr1->setShape(aCenterPointShape);
+      aConstr1->setIsInHistory(false);
+      setResult(aConstr1, 0);
 
       // make a visible circle
       boost::shared_ptr<GeomDataAPI_Dir> aNDir = 
@@ -58,8 +63,14 @@ void SketchPlugin_Circle::execute()
         boost::shared_ptr<GeomAPI_Shape> aCircleShape = 
                                 GeomAlgoAPI_EdgeBuilder::lineCircle(aCenter, aNormal, aRadius);
         aShapes.push_back(aCircleShape);
+        boost::shared_ptr<ModelAPI_ResultConstruction> aConstr2 = 
+          document()->createConstruction(data());
+        aConstr2->setShape(aCircleShape);
+        aConstr2->setIsInHistory(false);
+        setResult(aConstr2, 1);
       }
     }
+    /*
     boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes);
       // store the result
       boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = 
@@ -67,6 +78,7 @@ void SketchPlugin_Circle::execute()
       aConstr->setShape(aCompound);
       aConstr->setIsInHistory(false);
       setResult(aConstr);
+      */
   }
 }
 
index fe1faa56db70f3b18e20855641ce48e3963da796..b46cf90967b30b86bf225e4baa781bd40931bea3 100644 (file)
@@ -104,7 +104,7 @@ boost::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
   boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theData->attribute(theAttribute));
   if (anAttr)
-    aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->object());
+    aFeature = SketchPlugin_Sketch::getFeature(anAttr->object());
 
   if (aFeature && aFeature->getKind() == SketchPlugin_Point::ID())
     aPointAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
index 456ff056943eebb5946a8277da84dd386d724a84..a112da05c7394e6d83c5efdaadaf6f01520dd559 100644 (file)
@@ -7,7 +7,9 @@
 
 #include "SketchPlugin.h"
 #include "SketchPlugin_Constraint.h"
-#include <SketchPlugin_Sketch.h>
+#include "SketchPlugin_Sketch.h"
+
+#include <GeomAPI_IPresentable.h>
 #include <list>
 
 /** \class SketchPlugin_ConstraintDistance
@@ -18,7 +20,8 @@
  *  These constraint has three attributes:
  *  SketchPlugin_Constraint::VALUE(), SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B()
  */
-class SketchPlugin_ConstraintDistance: public SketchPlugin_Constraint
+class SketchPlugin_ConstraintDistance: public SketchPlugin_Constraint, 
+                                       public GeomAPI_IPresentable
 {
 public:
   /// Distance constraint kind
index f21aa9979389169d7ad90477c555952b0cf1403a..1a82f07250a180008166d883e1f6adce84140ad7 100644 (file)
@@ -9,12 +9,15 @@
 
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_Data.h>
+#include <ModelAPI_Result.h>
 
 #include <GeomDataAPI_Point2D.h>
 
 #include <GeomAPI_Lin2d.h>
 #include <GeomAPI_Pnt2d.h>
 
+
+
 SketchPlugin_ConstraintLength::SketchPlugin_ConstraintLength()
 {
 }
@@ -33,7 +36,7 @@ void SketchPlugin_ConstraintLength::execute()
 
     boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
       boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
-    ObjectPtr aFeature = aRef->object();
+    FeaturePtr aFeature = SketchPlugin_Sketch::getFeature(aRef->object());
     if (aFeature) {
       // set length value
       boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
index 9cd5ccff43a88e807def5aab6a57d98b8ea335bc..76e48e0760ce6f565de147baa5d92159f07c37c9 100644 (file)
@@ -159,3 +159,17 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Sketch::
   }
   return boost::shared_ptr<GeomAPI_AISObject>();
 }
+
+FeaturePtr SketchPlugin_Sketch::getFeature(ObjectPtr theObject)
+{
+  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
+  if (!aFeature) {
+    ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+    if (aResult) {
+      PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+      DocumentPtr aDoc = aMgr->rootDocument();
+      return aDoc->feature(aResult);
+    }
+  }
+  return aFeature;
+}
\ No newline at end of file
index 8a1d22db4701ad7fa263979b921ebc1058e9b67b..374f8a9e1d9cf1ae62458093272301f17b6cdb1f 100644 (file)
@@ -96,6 +96,8 @@ public:
   virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
                             boost::shared_ptr<GeomAPI_AISObject> thePrevious);
 
+  static FeaturePtr getFeature(ObjectPtr theObject);
+
 protected:
   /// Creates a plane and append it to the list
   /// \param theX the X normal value
index f831c170b530197631577a77e3955334bff83615..e44e1390b8b17e078077cd03cf0297fc827c3d23 100644 (file)
@@ -81,6 +81,7 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
     {
       boost::shared_ptr<ModelAPI_Attribute> anAttr =
         theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr));
+      if (!anAttr) continue;
       switch (typeOfAttribute(anAttr))
       {
       case POINT2D: // the attribute is a 2D point
index 38f6181fcac558aa00e560b29eba1de62d749493..f51afd3a9f7d435710212174467574bdc2d1a13f 100644 (file)
@@ -89,7 +89,7 @@ void XGUI_Displayer::erase(ObjectPtr theObject, const bool isUpdateViewer)
   if (anObject)  {
     Handle(AIS_InteractiveObject) anAIS = anObject->impl<Handle(AIS_InteractiveObject)>();
     if (!anAIS.IsNull()) {
-      aContext->Erase(anAIS, isUpdateViewer);
+      aContext->Remove(anAIS, isUpdateViewer);
     }
   }
   myResult2AISObjectMap.erase(theObject);
@@ -299,7 +299,7 @@ void XGUI_Displayer::eraseDeletedResults(const bool isUpdateViewer)
       if (!anObj) continue;
       Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
       if (!anAIS.IsNull()) {
-        aContext->Erase(anAIS, false);
+        aContext->Remove(anAIS, false);
         aRemoved.push_back(aFeature);
       }
     }
index 27eee74701d21f716bc7f1b6a43ba4059287590f..9080ebfaa6d71674647e1b4932e2651a7138b94a 100644 (file)
@@ -312,7 +312,13 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const ModelAPI_ObjectUpdatedMessage* t
     if (!aObj->data() )
       myDisplayer->erase(aObj, false);
     else {
-      if (myDisplayer->isVisible(aObj)) // TODO VSV: Correction sketch drawing
+      //if (myDisplayer->isVisible(aObj)) // TODO VSV: Correction sketch drawing
+      if(myOperationMgr->hasOperation()) {
+        ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
+        if (aOperation->hasObject(aObj)) { // Display only current operation results
+          myDisplayer->display(aObj, false);        
+        }
+      } else if (myDisplayer->isVisible(aObj))
         myDisplayer->display(aObj, false); // In order to update presentation
     }
   }
@@ -988,6 +994,8 @@ void XGUI_Workshop::updateCommandsOnViewSelection()
   PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
   XGUI_Selection* aSelection = mySelector->selection();
+  if (aSelection->getSelected().size() == 0)
+    return;
 
   QList<QAction*> aActions = getModuleCommands();
   foreach(QAction* aAction, aActions) {