]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Initial version of redesign of working with results
authormpv <mikhail.ponikarov@opencascade.com>
Fri, 11 Jul 2014 07:17:01 +0000 (11:17 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Fri, 11 Jul 2014 07:17:01 +0000 (11:17 +0400)
69 files changed:
src/Model/CMakeLists.txt
src/Model/Model_Data.cpp
src/Model/Model_Data.h
src/Model/Model_Document.cpp
src/Model/Model_Document.h
src/Model/Model_Events.cpp
src/Model/Model_Events.h
src/Model/Model_Object.cpp [deleted file]
src/Model/Model_Object.h [deleted file]
src/Model/Model_PluginManager.cpp
src/Model/Model_ResultBody.cpp [new file with mode: 0644]
src/Model/Model_ResultBody.h [new file with mode: 0644]
src/Model/Model_ResultConstruction.cpp [new file with mode: 0644]
src/Model/Model_ResultConstruction.h [new file with mode: 0644]
src/Model/Model_ResultPart.cpp [new file with mode: 0644]
src/Model/Model_ResultPart.h [new file with mode: 0644]
src/Model/Model_Update.cpp
src/Model/Model_Update.h
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI_Attribute.h
src/ModelAPI/ModelAPI_Data.h
src/ModelAPI/ModelAPI_Document.h
src/ModelAPI/ModelAPI_Events.h
src/ModelAPI/ModelAPI_Feature.h
src/ModelAPI/ModelAPI_Object.h
src/ModelAPI/ModelAPI_Result.h [new file with mode: 0644]
src/ModelAPI/ModelAPI_ResultBody.h [new file with mode: 0644]
src/ModelAPI/ModelAPI_ResultConstruction.h [new file with mode: 0644]
src/ModelAPI/ModelAPI_ResultPart.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_WidgetBoolValue.cpp
src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp
src/ModuleBase/ModuleBase_WidgetFeature.cpp
src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp
src/ModuleBase/ModuleBase_WidgetPoint2D.cpp
src/ModuleBase/ModuleBase_WidgetSelector.cpp
src/PartSet/PartSet_Listener.cpp
src/PartSet/PartSet_OperationFeatureEdit.cpp
src/PartSet/PartSet_OperationFeatureEditMulti.cpp
src/SketchPlugin/SketchPlugin_Arc.cpp
src/SketchPlugin/SketchPlugin_Arc.h
src/SketchPlugin/SketchPlugin_Circle.cpp
src/SketchPlugin/SketchPlugin_Circle.h
src/SketchPlugin/SketchPlugin_Constraint.cpp
src/SketchPlugin/SketchPlugin_Constraint.h
src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp
src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.h
src/SketchPlugin/SketchPlugin_ConstraintLength.cpp
src/SketchPlugin/SketchPlugin_ConstraintLength.h
src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp
src/SketchPlugin/SketchPlugin_ConstraintParallel.h
src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp
src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h
src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp
src/SketchPlugin/SketchPlugin_ConstraintRadius.h
src/SketchPlugin/SketchPlugin_Feature.cpp
src/SketchPlugin/SketchPlugin_Feature.h
src/SketchPlugin/SketchPlugin_Line.cpp
src/SketchPlugin/SketchPlugin_Line.h
src/SketchPlugin/SketchPlugin_Point.cpp
src/SketchPlugin/SketchPlugin_Point.h
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_Sketch.h
src/SketchSolver/SketchSolver_ConstraintGroup.cpp
src/SketchSolver/SketchSolver_ConstraintManager.cpp
src/XGUI/XGUI_DocumentDataModel.cpp
src/XGUI/XGUI_Workshop.cpp

index 9dea7108a082955bc17f6373fa203789abccf5bd..fdfb04ccf2ed7cc77bbac2f32f32d58fb3ea0dc5 100644 (file)
@@ -6,7 +6,6 @@ SET(PROJECT_HEADERS
     Model_Document.h
     Model_PluginManager.h
     Model_Data.h
-    Model_Object.h
     Model_AttributeDouble.h
     Model_AttributeDocRef.h
     Model_AttributeReference.h
@@ -16,6 +15,9 @@ SET(PROJECT_HEADERS
     Model_Events.h
     Model_Update.h
     Model_Validator.h
+    Model_ResultBody.h
+    Model_ResultConstruction.h
+    Model_ResultPart.h
 )
 
 SET(PROJECT_SOURCES
@@ -23,7 +25,6 @@ SET(PROJECT_SOURCES
     Model_Document.cpp
     Model_PluginManager.cpp
     Model_Data.cpp
-    Model_Object.cpp
     Model_AttributeDouble.cpp
     Model_AttributeDocRef.cpp
     Model_AttributeReference.cpp
@@ -33,6 +34,9 @@ SET(PROJECT_SOURCES
     Model_Events.cpp
     Model_Update.cpp
     Model_Validator.cpp
+    Model_ResultBody.cpp
+    Model_ResultConstruction.cpp
+    Model_ResultPart.cpp
 )
 
 SET(PROJECT_LIBRARIES
index 5b3a944c914e5e62828e508b19b5ca4ac7d71167..53e34ce9746f399f5771cb8b4fad3c63091981eb 100644 (file)
@@ -15,6 +15,7 @@
 #include <TDataStd_Name.hxx>
 #include "Model_Events.h"
 #include <Events_Loop.h>
+#include <Events_Error.h>
 
 using namespace std;
 
@@ -27,7 +28,7 @@ void Model_Data::setLabel(TDF_Label& theLab)
   myLab = theLab;
 }
 
-string Model_Data::getName()
+string Model_Data::name()
 {
   Handle(TDataStd_Name) aName;
   if (myLab.FindAttribute(TDataStd_Name::GetID(), aName))
@@ -48,8 +49,8 @@ void Model_Data::setName(string theName)
       aName->Set(theName.c_str());
   }
   if (isModified) {
-    static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
-    ModelAPI_EventCreator::get()->sendUpdated(myFeature, anEvent, false);
+    static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
+    ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent, false);
   }
 }
 
@@ -78,10 +79,11 @@ void Model_Data::addAttribute(string theID, string theAttrType)
 
   if (anAttr) {
     myAttrs[theID] = boost::shared_ptr<ModelAPI_Attribute>(anAttr);
-    anAttr->setFeature(myFeature);
+    anAttr->setObject(myObject);
+  }
+  else {
+    Events_Error::send("Can not create unknown type of attribute " + theAttrType);
   }
-  else
-    ; // TODO: generate error on unknown attribute request and/or add mechanism for customization
 }
 
 boost::shared_ptr<ModelAPI_AttributeDocRef> Model_Data::docRef(const string theID)
@@ -221,37 +223,6 @@ list<boost::shared_ptr<ModelAPI_Attribute> > Model_Data::attributes(const string
 void Model_Data::sendAttributeUpdated(ModelAPI_Attribute* theAttr)
 {
   theAttr->setInitialized();
-  static const Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
-  ModelAPI_EventCreator::get()->sendUpdated(myFeature, anEvent);
-}
-
-#include <TNaming_Builder.hxx>
-#include <TNaming_NamedShape.hxx>
-#include <TopoDS_Shape.hxx>
-#include <GeomAPI_Shape.h>
-
-void Model_Data::store(const boost::shared_ptr<GeomAPI_Shape>& theShape)
-{
-  // the simplest way is to keep this attribute here, on Data
-  // TODO: add naming structure in separated document for shape storage
-  TNaming_Builder aBuilder(myLab);
-  if (!theShape) return; // bad shape
-  TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
-  if (aShape.IsNull()) return; // null shape inside
-
-  aBuilder.Generated(aShape);
-}
-
-boost::shared_ptr<GeomAPI_Shape> Model_Data::shape()
-{
-  Handle(TNaming_NamedShape) aName;
-  if (myLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) {
-    TopoDS_Shape aShape = aName->Get();
-    if (!aShape.IsNull()) {
-      boost::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
-      aRes->setImpl(new TopoDS_Shape(aShape));
-      return aRes;
-    }
-  }
-  return boost::shared_ptr<GeomAPI_Shape>();
+  static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
+  ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent);
 }
index eca52e960c44d99464996994eca977ac8d041634..34f3ec7a98ba3e17ddac4526326e3700a92dc31d 100644 (file)
@@ -26,8 +26,8 @@ class Model_Data: public ModelAPI_Data
   /// All attributes of the object identified by the attribute ID
   std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> > myAttrs;
 
-  /// needed here to emit signal that feature changed on change of the attribute
-  FeaturePtr myFeature;
+  /// needed here to emit signal that object changed on change of the attribute
+  ObjectPtr myObject;
 
   Model_Data();
 
@@ -41,7 +41,7 @@ class Model_Data: public ModelAPI_Data
 
 public:
   /// Returns the name of the feature visible by the user in the object browser
-  MODEL_EXPORT virtual std::string getName();
+  MODEL_EXPORT virtual std::string name();
   /// Defines the name of the feature visible by the user in the object browser
   MODEL_EXPORT virtual void setName(std::string theName);
   /// Returns the attribute that references to another document
@@ -76,10 +76,8 @@ public:
   /// Returns true if it is correctly connected t othe data model
   MODEL_EXPORT virtual bool isValid();
 
-  /// Stores the shape (called by the execution method).
-  MODEL_EXPORT virtual void store(const boost::shared_ptr<GeomAPI_Shape>& theShape);
-  /// Returns the shape-result produced by this feature
-  MODEL_EXPORT virtual boost::shared_ptr<GeomAPI_Shape> shape();
+  /// Returns the label where the shape must be stored (used in ResultBody)
+  TDF_Label& shapeLab() {return myLab;}
 
   /// Initializes object by the attributes: must be called just after the object is created
   /// for each attribute of the object
@@ -94,9 +92,9 @@ public:
   /// Puts feature to the document data sub-structure
   MODEL_EXPORT void setLabel(TDF_Label& theLab);
 
-  /// Sets the feature of this data
-  MODEL_EXPORT virtual void setFeature(FeaturePtr theFeature)
-    {myFeature = theFeature;}
+  /// Sets the object of this data
+  MODEL_EXPORT virtual void setObject(ObjectPtr theObject)
+    {myObject = theObject;}
 };
 
 #endif
index 95cc5a9d1a348a8220f6794db21279fe3d04ac2a..68ec29401056acbf1f5aa5303ec6d4e9da633f73 100644 (file)
@@ -3,12 +3,13 @@
 // Author:      Mikhail PONIKAROV
 
 #include <Model_Document.h>
-#include <ModelAPI_Feature.h>
 #include <Model_Data.h>
-#include <Model_Object.h>
 #include <Model_Application.h>
 #include <Model_PluginManager.h>
 #include <Model_Events.h>
+#include <Model_ResultPart.h>
+#include <Model_ResultConstruction.h>
+#include <Model_ResultBody.h>
 #include <Events_Loop.h>
 #include <Events_Error.h>
 
@@ -18,6 +19,7 @@
 #include <TDataStd_ReferenceArray.hxx>
 #include <TDataStd_HLabelArray1.hxx>
 #include <TDataStd_Name.hxx>
+#include <TDF_Reference.hxx>
 
 #include <climits>
 #ifndef WIN32
 static const int UNDO_LIMIT = 10; // number of possible undo operations
 
 static const int TAG_GENERAL = 1; // general properties tag
-static const int TAG_OBJECTS = 2; // tag of the objects sub-tree (features)
+static const int TAG_OBJECTS = 2; // tag of the objects sub-tree (features, results)
 static const int TAG_HISTORY = 3; // tag of the history sub-tree (python dump)
 
+// feature sub-labels
+static const int TAG_FEATURE_ARGUMENTS = 1; ///< where the arguments are located
+static const int TAG_FEATURE_RESULTS = 2; ///< where the results are located
+
 using namespace std;
 
 /// Returns the file name of this document by the nameof directory and identifuer of a document
@@ -212,9 +218,9 @@ void Model_Document::compactNested() {
 void Model_Document::finishOperation()
 {
   // just to be sure that everybody knows that changes were performed
-  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_CREATED));
-  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
-  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_DELETED));
+  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
+  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
 
   if (myNestedNum != -1) // this nested transaction is owervritten
     myNestedNum++;
@@ -319,18 +325,6 @@ void Model_Document::redo()
     subDocument(*aSubIter)->redo();
 }
 
-FeaturePtr Model_Document::addFeature(string theID)
-{
-  FeaturePtr aFeature = 
-    ModelAPI_PluginManager::get()->createFeature(theID);
-  if (aFeature) {
-    boost::dynamic_pointer_cast<Model_Document>(aFeature->documentToAdd())->addFeature(aFeature);
-  } else {
-    // TODO: generate error that feature is not created
-  }
-  return aFeature;
-}
-
 /// Appenad to the array of references a new referenced label
 static void AddToRefArray(TDF_Label& theArrayLab, TDF_Label& theReferenced) {
   Handle(TDataStd_ReferenceArray) aRefs;
@@ -348,45 +342,41 @@ static void AddToRefArray(TDF_Label& theArrayLab, TDF_Label& theReferenced) {
   }
 }
 
-void Model_Document::addFeature(const FeaturePtr theFeature)
-{
-  if (theFeature->isAction()) return; // do not add action to the data model
-
-  boost::shared_ptr<ModelAPI_Document> aThis = 
-    Model_Application::getApplication()->getDocument(myID);
-  TDF_Label aFeaturesLab = groupLabel(FEATURES_GROUP);
-  TDF_Label aFeatureLab = aFeaturesLab.NewChild();
 
-  // organize feature and data objects
-  boost::shared_ptr<Model_Data> aData(new Model_Data);
-  aData->setFeature(theFeature);
-  aData->setLabel(aFeatureLab);
-  theFeature->setDoc(aThis);
-  theFeature->setData(aData);
-  setUniqueName(theFeature);
-  theFeature->initAttributes();
-
-  // keep the feature ID to restore document later correctly
-  TDataStd_Comment::Set(aFeatureLab, theFeature->getKind().c_str());
-  myFeatures.push_back(theFeature);
-  // store feature in the history of features array
-  if (theFeature->isInHistory()) {
-    AddToRefArray(aFeaturesLab, aFeatureLab);
+FeaturePtr Model_Document::addFeature(string theID)
+{
+  TDF_Label anEmptyLab;
+  FeaturePtr anEmptyFeature;
+  FeaturePtr aFeature = ModelAPI_PluginManager::get()->createFeature(theID);
+  if (aFeature) {
+    TDF_Label aFeatureLab;
+    if (!aFeature->isAction()) {// do not add action to the data model
+      TDF_Label aFeaturesLab = groupLabel(FEATURES_GROUP);
+      aFeatureLab = aFeaturesLab.NewChild();
+      initData(aFeature, aFeatureLab, TAG_FEATURE_ARGUMENTS);
+      // keep the feature ID to restore document later correctly
+      TDataStd_Comment::Set(aFeatureLab, aFeature->getKind().c_str());
+      myObjs[FEATURES_GROUP].push_back(aFeature);
+      // store feature in the history of features array
+      if (aFeature->isInHistory()) {
+        AddToRefArray(aFeaturesLab, aFeatureLab);
+      }
+    }
+    setUniqueName(aFeature);
+    if (!aFeature->isAction()) {// do not add action to the data model
+      // event: feature is added
+      static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
+      ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent);
+    }
   }
-  // add featue to the group
-  const std::string& aGroup = theFeature->getGroup();
-  TDF_Label aGroupLab = groupLabel(aGroup);
-  AddToRefArray(aGroupLab, aFeatureLab);
-  // new name of this feature object by default equal to name of feature
-  TDF_Label anObjLab = aGroupLab.NewChild();
-  TCollection_ExtendedString aName(theFeature->data()->getName().c_str());
-  TDataStd_Name::Set(anObjLab, aName);
-  TDF_Label aGrLabChild = aGroupLab.FindChild(1);
-  AddToRefArray(aGrLabChild, anObjLab); // reference to names is on the first sub
-
-  // event: feature is added
-  static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_CREATED);
-  ModelAPI_EventCreator::get()->sendUpdated(theFeature, anEvent);
+  return aFeature;
+}
+
+void Model_Document::storeResult(boost::shared_ptr<ModelAPI_Result> theResult,
+  const int theResultIndex)
+{
+  initData(theResult, boost::dynamic_pointer_cast<Model_Data>(theResult->owner()->data())->
+    label().Father().FindChild(TAG_FEATURE_RESULTS), theResultIndex);
 }
 
 /// Appenad to the array of references a new referenced label.
@@ -423,18 +413,15 @@ static int RemoveFromRefArray(
 void Model_Document::removeFeature(FeaturePtr theFeature)
 {
   boost::shared_ptr<Model_Data> aData = boost::static_pointer_cast<Model_Data>(theFeature->data());
-  TDF_Label aFeatureLabel = aData->label();
-  // remove the object
-  TDF_Label aGroupLabel = groupLabel(theFeature->getGroup());
-  int aRemovedIndex = RemoveFromRefArray(aGroupLabel, aFeatureLabel);
-  RemoveFromRefArray(aGroupLabel.FindChild(1), TDF_Label(), aRemovedIndex);
-  // remove feature from the myFeatures list
-  std::vector<FeaturePtr >::iterator aFIter = myFeatures.begin();
-  while(aFIter != myFeatures.end()) {
-    if (*aFIter == theFeature) {
-      aFIter = myFeatures.erase(aFIter);
+  TDF_Label aFeatureLabel = aData->label().Father();
+  // remove feature from the myObjects list
+  std::vector<ObjectPtr>& aVec = myObjs[FEATURES_GROUP];
+  std::vector<ObjectPtr>::iterator anIter = aVec.begin();
+  while(anIter != aVec.end()) {
+    if (*anIter == theFeature) {
+      anIter = aVec.erase(anIter);
     } else {
-      aFIter++;
+      anIter++;
     }
   }
   // erase all attributes under the label of feature
@@ -442,19 +429,29 @@ void Model_Document::removeFeature(FeaturePtr theFeature)
   // remove it from the references array
   RemoveFromRefArray(groupLabel(FEATURES_GROUP), aData->label());
 
-  // event: feature is added
-  ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), theFeature->getGroup());
+  // event: feature is deleted
+  ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), FEATURES_GROUP);
+}
+
+/// returns the object group name by the object label
+static string groupName(TDF_Label theObjectLabel) {
+  TDF_Label aGroupLab = theObjectLabel.Father();
+  Handle(TDataStd_Comment) aComment;
+  if (aGroupLab.FindAttribute(TDataStd_Comment::GetID(), aComment))
+    return string(TCollection_AsciiString(aComment->Get()).ToCString());
+  return ""; // not found
 }
 
 FeaturePtr Model_Document::feature(TDF_Label& theLabel)
 {
   // iterate all features, may be optimized later by keeping labels-map
-  vector<FeaturePtr >::iterator aFIter = myFeatures.begin();
-  for(; aFIter != myFeatures.end(); aFIter++) {
+  std::vector<ObjectPtr>& aVec = myObjs[FEATURES_GROUP];
+  vector<ObjectPtr>::iterator aFIter = aVec.begin();
+  for(; aFIter != aVec.end(); aFIter++) {
     boost::shared_ptr<Model_Data> aData = 
       boost::dynamic_pointer_cast<Model_Data>((*aFIter)->data());
     if (aData->label().IsEqual(theLabel))
-      return *aFIter;
+      return boost::dynamic_pointer_cast<ModelAPI_Feature>(*aFIter);
   }
   return FeaturePtr(); // not found
 }
@@ -467,39 +464,65 @@ boost::shared_ptr<ModelAPI_Document> Model_Document::subDocument(string theDocID
   return Model_Application::getApplication()->getDocument(theDocID);
 }
 
-FeaturePtr Model_Document::feature(
-  const string& theGroupID, const int theIndex, const bool isOperation)
+ObjectPtr Model_Document::object(const string& theGroupID, const int theIndex)
 {
-  TDF_Label aGroupLab = groupLabel(theGroupID);
-  Handle(TDataStd_ReferenceArray) aRefs;
-  if (aGroupLab.FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs)) {
-    if (aRefs->Lower() <= theIndex && aRefs->Upper() >= theIndex) {
-      TDF_Label aFeatureLab = aRefs->Value(theIndex);
-      FeaturePtr aFeature = feature(aFeatureLab);
-
-      if (theGroupID == FEATURES_GROUP || isOperation) { // just returns the feature from the history
-        return aFeature;
-      } else { // create a new object from the group to return it
-        Handle(TDataStd_Name) aName; // name of the object
-        if (aGroupLab.FindChild(1).FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs))
-          aRefs->Value(theIndex).FindAttribute(TDataStd_Name::GetID(), aName);
-        boost::shared_ptr<Model_Object> anObj(new Model_Object(aFeature, aName));
-        return anObj;
+  if (theGroupID == FEATURES_GROUP) {
+    std::map<std::string, std::vector<ObjectPtr> >::iterator aFind = myObjs.find(theGroupID);
+    if (aFind != myObjs.end()) {
+      int aSize = aFind->second.size();
+      if (theIndex >= 0 && theIndex < aSize)
+        return aFind->second[theIndex];
+    }
+  } else {
+    // iterate all features in order to find the needed result
+    std::map<std::string, std::vector<ObjectPtr> >::iterator aFind = myObjs.find(FEATURES_GROUP);
+    if (aFind != myObjs.end()) {
+      vector<ObjectPtr>::iterator aFIter = aFind->second.begin();
+      for(int anIndex = 0; aFIter != aFind->second.end(); aFIter++) {
+        const list<boost::shared_ptr<ModelAPI_Result> >& aResults = 
+          boost::dynamic_pointer_cast<ModelAPI_Feature>(*aFIter)->results();
+        list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
+        for(; aRIter != aResults.cend(); aRIter++) {
+          if ((*aRIter)->isInHistory() && (*aRIter)->group() == theGroupID) {
+            if (anIndex == theIndex)
+              return *aRIter;
+            anIndex++;
+          }
+        }
       }
     }
   }
-
   // not found
-  return FeaturePtr();
+  return ObjectPtr();
 }
 
 int Model_Document::size(const string& theGroupID) 
 {
-  Handle(TDataStd_ReferenceArray) aRefs;
-  if (groupLabel(theGroupID).FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs))
-    return aRefs->Length();
+  int aResult = 0;
+  if (theGroupID == FEATURES_GROUP) {
+    std::map<std::string, std::vector<ObjectPtr> >::iterator aFind = myObjs.find(theGroupID);
+    if (aFind != myObjs.end()) {
+      aResult = aFind->second.size();
+    }
+  } else {
+    // iterate all features in order to find the needed result
+    std::map<std::string, std::vector<ObjectPtr> >::iterator aFind = myObjs.find(FEATURES_GROUP);
+    if (aFind != myObjs.end()) {
+      vector<ObjectPtr>::iterator aFIter = aFind->second.begin();
+      for(; aFIter != aFind->second.end(); aFIter++) {
+        const list<boost::shared_ptr<ModelAPI_Result> >& aResults = 
+          boost::dynamic_pointer_cast<ModelAPI_Feature>(*aFIter)->results();
+        list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
+        for(; aRIter != aResults.cend(); aRIter++) {
+          if ((*aRIter)->isInHistory() && (*aRIter)->group() == theGroupID) {
+            aResult++;
+          }
+        }
+      }
+    }
+  }
   // group is not found
-  return 0;
+  return aResult;
 }
 
 Model_Document::Model_Document(const std::string theID)
@@ -535,126 +558,120 @@ TDF_Label Model_Document::groupLabel(const string theGroup)
 void Model_Document::setUniqueName(FeaturePtr theFeature)
 {
   string aName; // result
-  // iterate all features but also iterate group of this feature if object is not in history
-  list<string> aGroups;
-  aGroups.push_back(FEATURES_GROUP);
-  if (!theFeature->isInHistory()) {
-    aGroups.push_back(theFeature->getGroup());
+  // first count all objects of such kind to start with index = count + 1
+  int a, aNumObjects = 0;
+  int aSize = size(FEATURES_GROUP);
+  for(a = 0; a < aSize; a++) {
+    if (boost::dynamic_pointer_cast<ModelAPI_Feature>(object(FEATURES_GROUP, a))->getKind()
+        == theFeature->getKind())
+      aNumObjects++;
   }
-  for(list<string>::iterator aGIter = aGroups.begin(); aGIter != aGroups.end(); aGIter++) {
-    // first count all objects of such kind to start with index = count + 1
-    int a, aNumObjects = 0;
-    int aSize = size(*aGIter);
-    for(a = 0; a < aSize; a++) {
-      if (feature(*aGIter, a)->getKind() == theFeature->getKind())
-        aNumObjects++;
-    }
-    // generate candidate name
-    stringstream aNameStream;
-    aNameStream<<theFeature->getKind()<<"_"<<aNumObjects + 1;
-    aName = aNameStream.str();
-    // check this is unique, if not, increase index by 1
-    for(a = 0; a < aSize;) {
-      if (feature(*aGIter, a, true)->data()->getName() == aName) {
-        aNumObjects++;
-        stringstream aNameStream;
-        aNameStream<<theFeature->getKind()<<"_"<<aNumObjects + 1;
-        aName = aNameStream.str();
-        // reinitialize iterator to make sure a new name is unique
-        a = 0;
-      } else a++;
-    }
+  // generate candidate name
+  stringstream aNameStream;
+  aNameStream<<theFeature->getKind()<<"_"<<aNumObjects + 1;
+  aName = aNameStream.str();
+  // check this is unique, if not, increase index by 1
+  for(a = 0; a < aSize;) {
+    if (boost::dynamic_pointer_cast<ModelAPI_Feature>(object(FEATURES_GROUP, a))
+          ->data()->name() == aName) {
+      aNumObjects++;
+      stringstream aNameStream;
+      aNameStream<<theFeature->getKind()<<"_"<<aNumObjects + 1;
+      aName = aNameStream.str();
+      // reinitialize iterator to make sure a new name is unique
+      a = 0;
+    } else a++;
   }
   theFeature->data()->setName(aName);
 }
 
-//! Returns the object by the feature
-FeaturePtr Model_Document::objectByFeature(
-  const FeaturePtr theFeature)
-{
-  for(int a = 0; a < size(theFeature->getGroup()); a++) {
-    boost::shared_ptr<Model_Object> anObj = 
-      boost::dynamic_pointer_cast<Model_Object>(feature(theFeature->getGroup(), a));
-    if (anObj && anObj->featureRef() == theFeature) {
-      return anObj;
-    }
-  }
-  return FeaturePtr(); // not found
+void Model_Document::initData(ObjectPtr theObj, TDF_Label& theLab, const int theTag) {
+  boost::shared_ptr<ModelAPI_Document> aThis = 
+    Model_Application::getApplication()->getDocument(myID);
+  boost::shared_ptr<Model_Data> aData(new Model_Data);
+  aData->setLabel(theLab.FindChild(theTag));
+  aData->setObject(theObj);
+  theObj->setDoc(aThis);
+  theObj->setData(aData);
+  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObj);
+  if (aFeature) aFeature->initAttributes();
 }
 
 void Model_Document::synchronizeFeatures(const bool theMarkUpdated)
 {
-  boost::shared_ptr<ModelAPI_Document> aThis = Model_Application::getApplication()->getDocument(myID);
-  // update features
-  vector<FeaturePtr >::iterator aFIter = myFeatures.begin();
-  // and in parallel iterate labels of features
-  TDF_ChildIDIterator aFLabIter(groupLabel(FEATURES_GROUP), TDataStd_Comment::GetID());
-  while(aFIter != myFeatures.end() || aFLabIter.More()) {
-    static const int INFINITE_TAG = INT_MAX; // no label means that it exists somwhere in infinite
-    int aFeatureTag = INFINITE_TAG; 
-    if (aFIter != myFeatures.end()) { // existing tag for feature
-      boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>((*aFIter)->data());
-      aFeatureTag = aData->label().Tag();
-    }
-    int aDSTag = INFINITE_TAG; 
-    if (aFLabIter.More()) { // next label in DS is existing
-      aDSTag = aFLabIter.Value()->Label().Tag();
-    }
-    if (aDSTag > aFeatureTag) { // feature is removed
-      FeaturePtr aFeature = *aFIter;
-      aFIter = myFeatures.erase(aFIter);
-      // event: model is updated
-      if (aFeature->isInHistory()) {
-        ModelAPI_EventCreator::get()->sendDeleted(aThis, FEATURES_GROUP);
-      }
-      ModelAPI_EventCreator::get()->sendDeleted(aThis, aFeature->getGroup());
-    } else if (aDSTag < aFeatureTag) { // a new feature is inserted
-      // create a feature
-      FeaturePtr aFeature = ModelAPI_PluginManager::get()->createFeature(
-        TCollection_AsciiString(Handle(TDataStd_Comment)::DownCast(
-        aFLabIter.Value())->Get()).ToCString());
-
-      if (aFIter == myFeatures.end()) { // must be before "setData" to redo the sketch line correctly
-        myFeatures.push_back(aFeature);
-        aFIter = myFeatures.end();
-      } else {
-        aFIter++;
-        myFeatures.insert(aFIter, aFeature);
+  boost::shared_ptr<ModelAPI_Document> aThis = 
+    Model_Application::getApplication()->getDocument(myID);
+  // update all objects: iterate from the end: as they appeared in the list
+  map<string, vector<ObjectPtr> >::reverse_iterator aGroupIter = myObjs.rbegin();
+  for(; aGroupIter != myObjs.rend(); aGroupIter++) {
+    vector<ObjectPtr>::iterator anObjIter = aGroupIter->second.begin();
+    // and in parallel iterate labels of features
+    const string& aGroupName = aGroupIter->first;
+    TDF_ChildIDIterator aLabIter(groupLabel(aGroupName), TDataStd_Comment::GetID());
+    while(anObjIter != aGroupIter->second.end() || aLabIter.More()) {
+      static const int INFINITE_TAG = INT_MAX; // no label means that it exists somwhere in infinite
+      int aFeatureTag = INFINITE_TAG; 
+      if (anObjIter != aGroupIter->second.end()) { // existing tag for feature
+        boost::shared_ptr<Model_Data> aData = 
+          boost::dynamic_pointer_cast<Model_Data>((*anObjIter)->data());
+        aFeatureTag = aData->label().Tag();
       }
-      boost::shared_ptr<Model_Data> aData(new Model_Data);
-      TDF_Label aLab = aFLabIter.Value()->Label();
-      aData->setLabel(aLab);
-      aData->setFeature(aFeature);
-      aFeature->setDoc(aThis);
-      aFeature->setData(aData);
-      aFeature->initAttributes();
-
-      // event: model is updated
-      static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_CREATED);
-      ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent);
-      FeaturePtr anObj = objectByFeature(aFeature);
-      if (anObj) {
-        ModelAPI_EventCreator::get()->sendUpdated(anObj, anEvent);
+      int aDSTag = INFINITE_TAG; 
+      if (aLabIter.More()) { // next label in DS is existing
+        aDSTag = aLabIter.Value()->Label().Tag();
       }
-
-      // feature for this label is added, so go to the next label
-      aFLabIter.Next();
-    } else { // nothing is changed, both iterators are incremented
-      if (theMarkUpdated) {
-        static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
-        ModelAPI_EventCreator::get()->sendUpdated(*aFIter, anEvent);
+      if (aDSTag > aFeatureTag) { // feature is removed
+        ObjectPtr anObj = *anObjIter;
+        anObjIter = aGroupIter->second.erase(anObjIter);
+        // event: model is updated
+        if (anObj->isInHistory()) {
+          ModelAPI_EventCreator::get()->sendDeleted(aThis, aGroupName);
+        }
+        ModelAPI_EventCreator::get()->sendDeleted(aThis, aGroupName);
+      } else if (aDSTag < aFeatureTag) { // a new feature is inserted
+        // create a feature
+        TDF_Label aLab = aLabIter.Value()->Label();
+        ObjectPtr aNewObj = ModelAPI_PluginManager::get()->createFeature(
+          TCollection_AsciiString(Handle(TDataStd_Comment)::DownCast(aLabIter.Value())->Get())
+          .ToCString());
+        // this must be before "setData" to redo the sketch line correctly
+        if (anObjIter == aGroupIter->second.end()) {
+          aGroupIter->second.push_back(aNewObj);
+          anObjIter = aGroupIter->second.end();
+        } else {
+          anObjIter++;
+          aGroupIter->second.insert(anObjIter, aNewObj);
+        }
+        initData(aNewObj, aLab, TAG_FEATURE_ARGUMENTS);
+
+        // 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
+        aLabIter.Next();
+      } else { // nothing is changed, both iterators are incremented
+        if (theMarkUpdated) {
+          static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
+          ModelAPI_EventCreator::get()->sendUpdated(*anObjIter, anEvent);
+        }
+        anObjIter++;
+        aLabIter.Next();
       }
-      aFIter++;
-      aFLabIter.Next();
     }
   }
   // after all updates, sends a message that groups of features were created or updated
   boost::static_pointer_cast<Model_PluginManager>(Model_PluginManager::get())->
     setCheckTransactions(false);
-  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_CREATED));
+  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
   if (theMarkUpdated)
-    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
-  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_DELETED));
+    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
   boost::static_pointer_cast<Model_PluginManager>(Model_PluginManager::get())->
     setCheckTransactions(true);
 }
+
+boost::shared_ptr<ModelAPI_ResultConstruction> createConstruction()
+{
+  boost::shared_ptr<ModelAPI_ResultConstruction> aResult(new Model_ResultConstruction());
+  return aResult;
+}
index eaedf13db8a4c6b230f8413e3d69d08d60752319..f6d59b785a1a19fbe3e77837b73802d534c7a2f0 100644 (file)
@@ -8,6 +8,7 @@
 #include <Model.h>
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Feature.h>
+#include <ModelAPI_Result.h>
 
 #include <TDocStd_Document.hxx>
 #include <map>
@@ -64,7 +65,7 @@ public:
   //! \param creates feature and puts it in the document
   MODEL_EXPORT virtual FeaturePtr addFeature(std::string theID);
 
-  //! Removes the feature from the document
+  //! Removes the feature from the document (with result)
   MODEL_EXPORT virtual void removeFeature(FeaturePtr theFeature);
 
   //! Returns the existing feature by the label
@@ -81,12 +82,18 @@ 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 FeaturePtr 
-    feature(const std::string& theGroupID, const int theIndex, const bool isOperation = false);
+  MODEL_EXPORT virtual ObjectPtr object(const std::string& theGroupID, const int theIndex);
 
   //! Returns the number of features in the group
   MODEL_EXPORT virtual int size(const std::string& theGroupID);
 
+  //! Allows to store the result in the data tree of the document (attaches 'data' of result to tree)
+  MODEL_EXPORT virtual void storeResult(
+    boost::shared_ptr<ModelAPI_Result> theResult, const int theResultIndex);
+
+  /// Creates a construction cresults
+  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_ResultConstruction> createConstruction();
+
 protected:
 
   //! Returns (creates if needed) the group label
@@ -96,13 +103,6 @@ protected:
   //! feature type + "_" + index
   void setUniqueName(FeaturePtr theFeature);
 
-  //! Adds to the document the new feature
-  void addFeature(const FeaturePtr theFeature);
-
-  //! Returns the object by the feature
-  FeaturePtr objectByFeature(
-    const FeaturePtr theFeature);
-
   //! Synchronizes myFeatures list with the updated document
   void synchronizeFeatures(const bool theMarkUpdated = false);
 
@@ -114,6 +114,11 @@ protected:
   //! performas compactification of all nested operations into one
   void compactNested();
 
+  //! Initializes the data fields of the feature
+  void Model_Document::initData(ObjectPtr theObj, TDF_Label& theLab, const int theTag);
+
+
+
   friend class Model_Application;
   friend class Model_PluginManager;
   friend class DFBrowser;
@@ -125,8 +130,8 @@ private:
   int myTransactionsAfterSave;
   /// number of nested transactions performed (or -1 if not nested)
   int myNestedNum;
-  /// All features managed by this document (not only in history of OB)
-  std::vector<FeaturePtr > myFeatures;
+  /// All objects managed by this document (not only in history of OB)
+  std::map<std::string, std::vector<ObjectPtr> > myObjs;
 
   ///< set of identifiers of sub-documents of this document
   std::set<std::string> mySubs;
index fb94001b86aa83d13717f28861f40b63181da385..2def67f43e8eb7fdd108a42e91c733055d7ab7eb 100644 (file)
@@ -10,16 +10,16 @@ Model_EventCreator MY_CREATOR;
 
 /////////////////////// CREATOR /////////////////////////////
 void Model_EventCreator::sendUpdated(
-  const FeaturePtr& theFeature, const Events_ID& theEvent, const bool isGroupped) const
+  const ObjectPtr& theObject, const Events_ID& theEvent, const bool isGroupped) const
 {
-  Model_FeatureUpdatedMessage aMsg(theFeature, theEvent);
+  Model_ObjectUpdatedMessage aMsg(theObject, theEvent);
   Events_Loop::loop()->send(aMsg, isGroupped);
 }
 
 void Model_EventCreator::sendDeleted(
   const boost::shared_ptr<ModelAPI_Document>& theDoc, const std::string& theGroup) const
 {
-  Model_FeatureDeletedMessage aMsg(theDoc, theGroup);
+  Model_ObjectDeletedMessage aMsg(theDoc, theGroup);
   Events_Loop::loop()->send(aMsg, true);
 }
 
@@ -29,56 +29,56 @@ Model_EventCreator::Model_EventCreator()
 }
 
 /////////////////////// UPDATED MESSAGE /////////////////////////////
-Model_FeatureUpdatedMessage::Model_FeatureUpdatedMessage(
-  const FeaturePtr& theFeature,
-  const Events_ID& theEvent) : ModelAPI_FeatureUpdatedMessage(theEvent, 0)
+Model_ObjectUpdatedMessage::Model_ObjectUpdatedMessage(
+  const ObjectPtr& theObject,
+  const Events_ID& theEvent) : ModelAPI_ObjectUpdatedMessage(theEvent, 0)
 {
-  if (theFeature) myFeatures.insert(theFeature);
+  if (theObject) myObjects.insert(theObject);
 }
 
-std::set<FeaturePtr> Model_FeatureUpdatedMessage::features() const 
+std::set<ObjectPtr> Model_ObjectUpdatedMessage::features() const 
 {
-  return myFeatures;
+  return myObjects;
 }
 
-Events_MessageGroup* Model_FeatureUpdatedMessage::newEmpty() 
+Events_MessageGroup* Model_ObjectUpdatedMessage::newEmpty() 
 {
-  FeaturePtr anEmptyFeature;
-  return new Model_FeatureUpdatedMessage(anEmptyFeature, eventID());
+  ObjectPtr anEmptyObject;
+  return new Model_ObjectUpdatedMessage(anEmptyObject, eventID());
 }
 
-void Model_FeatureUpdatedMessage::Join(Events_MessageGroup& theJoined) 
+void Model_ObjectUpdatedMessage::Join(Events_MessageGroup& theJoined) 
 {
-  Model_FeatureUpdatedMessage* aJoined = dynamic_cast<Model_FeatureUpdatedMessage*>(&theJoined);
-  std::set<FeaturePtr >::iterator aFIter = aJoined->myFeatures.begin();
-  for(; aFIter != aJoined->myFeatures.end(); aFIter++) {
-    myFeatures.insert(*aFIter);
+  Model_ObjectUpdatedMessage* aJoined = dynamic_cast<Model_ObjectUpdatedMessage*>(&theJoined);
+  std::set<ObjectPtr >::iterator aFIter = aJoined->myObjects.begin();
+  for(; aFIter != aJoined->myObjects.end(); aFIter++) {
+    myObjects.insert(*aFIter);
   }
 }
 
 /////////////////////// DELETED MESSAGE /////////////////////////////
-Model_FeatureDeletedMessage::Model_FeatureDeletedMessage(
+Model_ObjectDeletedMessage::Model_ObjectDeletedMessage(
   const boost::shared_ptr<ModelAPI_Document>& theDoc, const std::string& theGroup)
-  : ModelAPI_FeatureDeletedMessage(messageId(), 0), myDoc(theDoc)
+  : ModelAPI_ObjectDeletedMessage(messageId(), 0), myDoc(theDoc)
 {
   if (!theGroup.empty())
     myGroups.insert(theGroup);
 }
 
-Events_MessageGroup* Model_FeatureDeletedMessage::newEmpty() 
+Events_MessageGroup* Model_ObjectDeletedMessage::newEmpty() 
 {
-  return new Model_FeatureDeletedMessage(myDoc, "");
+  return new Model_ObjectDeletedMessage(myDoc, "");
 }
 
-const Events_ID Model_FeatureDeletedMessage::messageId()
+const Events_ID Model_ObjectDeletedMessage::messageId()
 {
-  static Events_ID MY_ID = Events_Loop::eventByName(EVENT_FEATURE_DELETED);
+  static Events_ID MY_ID = Events_Loop::eventByName(EVENT_OBJECT_DELETED);
   return MY_ID;
 }
 
-void Model_FeatureDeletedMessage::Join(Events_MessageGroup& theJoined)
+void Model_ObjectDeletedMessage::Join(Events_MessageGroup& theJoined)
 {
-  Model_FeatureDeletedMessage* aJoined = dynamic_cast<Model_FeatureDeletedMessage*>(&theJoined);
+  Model_ObjectDeletedMessage* aJoined = dynamic_cast<Model_ObjectDeletedMessage*>(&theJoined);
   std::set<std::string>::iterator aGIter = aJoined->myGroups.begin();
   for(; aGIter != aJoined->myGroups.end(); aGIter++) {
     myGroups.insert(*aGIter);
index a4912648dd62a99db9876a444920b6653362aacf..56e4b141f83743980cc8c3acf1e690688d9d1650 100644 (file)
@@ -13,7 +13,7 @@ class Model_EventCreator : public ModelAPI_EventCreator {
 public:
   /// creates created, updated or moved messages and sends to the loop
   virtual void sendUpdated(
-    const FeaturePtr& theFeature, const Events_ID& theEvent, const bool isGroupped = true) const;
+    const ObjectPtr& theObject, const Events_ID& theEvent, const bool isGroupped = true) const;
   /// creates deleted message and sends to the loop
   virtual void sendDeleted(
     const boost::shared_ptr<ModelAPI_Document>& theDoc, const std::string& theGroup) const;
@@ -23,20 +23,20 @@ public:
 };
 
 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
-class Model_FeatureUpdatedMessage : public ModelAPI_FeatureUpdatedMessage {
-  std::set<FeaturePtr> myFeatures; ///< which feature is changed
+class Model_ObjectUpdatedMessage : public ModelAPI_ObjectUpdatedMessage {
+  std::set<ObjectPtr> myObjects; ///< which feature is changed
 
   /// Sender is not important, all information is located in the feature.
   /// Use ModelAPI for creation of this event. Used for creation, movement and edition events.
-  Model_FeatureUpdatedMessage(
-    const FeaturePtr& theFeature,
+  Model_ObjectUpdatedMessage(
+    const ObjectPtr& theObject,
     const Events_ID& theEvent);
 
   friend class Model_EventCreator;
 public:
 
   /// Returns the feature that has been updated
-  virtual std::set<FeaturePtr> features() const;
+  virtual std::set<ObjectPtr> features() const;
 
   //! Creates a new empty group (to store it in the loop before flush)
   virtual Events_MessageGroup* newEmpty();
@@ -46,12 +46,12 @@ public:
 };
 
 /// Message that feature was deleted (used for Object Browser update)
-class Model_FeatureDeletedMessage : public ModelAPI_FeatureDeletedMessage {
+class Model_ObjectDeletedMessage : public ModelAPI_ObjectDeletedMessage {
   boost::shared_ptr<ModelAPI_Document> myDoc; ///< document owner of the feature
   std::set<std::string> myGroups; ///< group identifiers that contained the deleted feature
 
   /// Use ModelAPI for creation of this event.
-  Model_FeatureDeletedMessage(
+  Model_ObjectDeletedMessage(
     const boost::shared_ptr<ModelAPI_Document>& theDoc, const std::string& theGroup);
 
   friend class Model_EventCreator;
diff --git a/src/Model/Model_Object.cpp b/src/Model/Model_Object.cpp
deleted file mode 100644 (file)
index e0c5b30..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-// File:        Model_Object.cpp
-// Created:     19 May 2014
-// Author:      Mikhail PONIKAROV
-
-#include "Model_Object.h"
-#include <TCollection_AsciiString.hxx>
-#include "Model_Events.h"
-#include <Events_Loop.h>
-
-FeaturePtr Model_Object::featureRef()
-{
-  return myRef;
-}
-
-std::string Model_Object::getName()
-{
-  return TCollection_AsciiString(myName->Get()).ToCString();
-}
-
-void Model_Object::setName(std::string theName)
-{
-  if (myName->Get() != theName.c_str()) {
-    myName->Set(theName.c_str());
-    /*
-    static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
-    Model_FeatureUpdatedMessage aMsg(boost::shared_ptr<ModelAPI_Object>(this), anEvent);
-    Events_Loop::loop()->send(aMsg, false);
-    */
-  }
-}
-
-Model_Object::Model_Object(FeaturePtr theRef,
-                           Handle_TDataStd_Name theName)
-                           : myRef(theRef), myName(theName)
-{
-}
diff --git a/src/Model/Model_Object.h b/src/Model/Model_Object.h
deleted file mode 100644 (file)
index 73975bc..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-// File:        Model_Object.hxx
-// Created:     19 May 2014
-// Author:      Mikhail PONIKAROV
-
-#ifndef Model_Object_HeaderFile
-#define Model_Object_HeaderFile
-
-#include <Model.h>
-#include <ModelAPI_Object.h>
-#include <ModelAPI_Document.h>
-
-#include <TDataStd_Name.hxx>
-
-/**\class ModelAPI_Object
- * \ingroup DataModel
- * \brief Represents the result of some feature in the object browser
- * under the specific folder. Just a reference to specific feature-operation
- * with possibility to rename it.
- */
-class Model_Object : public ModelAPI_Object
-{
-  FeaturePtr myRef; ///< the referenced feature
-  Handle_TDataStd_Name myName; ///< the name of this object that may be changed
-public:
-  /// Reference to the feature-operation that produces this object
-  MODEL_EXPORT virtual FeaturePtr featureRef();
-
-  /// Returns the name of this object (by default equal to the name of feature)
-  MODEL_EXPORT virtual std::string getName();
-
-  /// Defines the name of the object
-  MODEL_EXPORT virtual void setName(std::string theName);
-
-  /// Returns the kind of a feature (like "Point")
-  MODEL_EXPORT virtual const std::string& getKind() {return myRef->getKind();}
-
-  /// Returns to which group in the document must be added feature
-  MODEL_EXPORT virtual const std::string& getGroup() {return FEATURES_GROUP;}
-
-  /// Returns document this feature belongs to
-  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> document()
-  {return myRef->document();}
-
-  /// Returns true if feature refers to the same model data instance
-  MODEL_EXPORT virtual bool isSame(const FeaturePtr& theFeature)
-  {
-    boost::shared_ptr<Model_Object> anObj = boost::dynamic_pointer_cast<Model_Object>(theFeature);
-    return anObj && myRef == anObj->myRef;
-  }
-
-  /// It is just a reference: don't init attributes
-  MODEL_EXPORT virtual void initAttributes() {}
-
-  /// It is just a reference: don't execute
-  MODEL_EXPORT virtual void execute() {}
-
-private:
-
-  /// Constructor fully defines this object
-  Model_Object(FeaturePtr theRef, Handle_TDataStd_Name theName);
-
-  friend class Model_Document;  
-};
-
-#endif
index d26ccd144e6546995c9bf25521cd92b93b0ef0e1..1dabf19905e5e56a0bdf0a2c8bd6619de891b3ed 100644 (file)
@@ -47,6 +47,8 @@ FeaturePtr Model_PluginManager::createFeature(string theFeatureID)
     } else {
       Events_Error::send(string("Can not load plugin '") + myCurrentPluginName + "'");
     }
+  } else {
+      Events_Error::send(string("Feature '") + theFeatureID + "' not found in any plugin");
   }
 
   return FeaturePtr(); // return nothing
@@ -107,9 +109,9 @@ Model_PluginManager::Model_PluginManager()
   Events_Loop* aLoop = Events_Loop::loop();
   static Events_ID FeatureEvent = Events_Loop::eventByName("FeatureRegisterEvent");
   aLoop->registerListener(this, FeatureEvent);
-  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_CREATED));
-  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
-  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_DELETED));
+  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
+  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED));
 }
 
 void Model_PluginManager::processEvent(const Events_Message* theMessage)
diff --git a/src/Model/Model_ResultBody.cpp b/src/Model/Model_ResultBody.cpp
new file mode 100644 (file)
index 0000000..687bc11
--- /dev/null
@@ -0,0 +1,53 @@
+// File:        Model_ResultBody.cpp
+// Created:     08 Jul 2014
+// Author:      Mikhail PONIKAROV
+
+#include <Model_ResultBody.h>
+#include <Model_Data.h>
+#include <TNaming_Builder.hxx>
+#include <TNaming_NamedShape.hxx>
+#include <TopoDS_Shape.hxx>
+#include <GeomAPI_Shape.h>
+
+Model_ResultBody::Model_ResultBody(const boost::shared_ptr<ModelAPI_Feature>& theFeature)
+  : myOwner(theFeature)
+{
+}
+
+void Model_ResultBody::store(const boost::shared_ptr<GeomAPI_Shape>& theShape)
+{
+  boost::shared_ptr<Model_Data> aData =  boost::dynamic_pointer_cast<Model_Data>(data());
+  if (aData) {
+    TDF_Label& aShapeLab = aData->shapeLab();
+    // TODO: to add the naming mechanism for shape storage in the next iteration
+    TNaming_Builder aBuilder(aShapeLab);
+    if (!theShape) return; // bad shape
+    TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
+    if (aShape.IsNull()) return; // null shape inside
+
+    aBuilder.Generated(aShape);
+  }
+}
+
+boost::shared_ptr<GeomAPI_Shape> Model_ResultBody::shape()
+{
+  boost::shared_ptr<Model_Data> aData =  boost::dynamic_pointer_cast<Model_Data>(data());
+  if (aData) {
+    TDF_Label& aShapeLab = aData->shapeLab();
+    Handle(TNaming_NamedShape) aName;
+    if (aShapeLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) {
+      TopoDS_Shape aShape = aName->Get();
+      if (!aShape.IsNull()) {
+        boost::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
+        aRes->setImpl(new TopoDS_Shape(aShape));
+        return aRes;
+      }
+    }
+  }
+  return boost::shared_ptr<GeomAPI_Shape>();
+}
+
+boost::shared_ptr<ModelAPI_Feature> Model_ResultBody::owner()
+{
+  return myOwner;
+}
diff --git a/src/Model/Model_ResultBody.h b/src/Model/Model_ResultBody.h
new file mode 100644 (file)
index 0000000..3757e5d
--- /dev/null
@@ -0,0 +1,37 @@
+// File:        Model_ResultBody.h
+// Created:     08 Jul 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef Model_ResultBody_HeaderFile
+#define Model_ResultBody_HeaderFile
+
+#include "Model.h"
+#include <ModelAPI_ResultBody.h>
+
+/**\class ModelAPI_ResultBody
+ * \ingroup DataModel
+ * \brief The body (shape) result of a feature.
+ *
+ * Provides a shape that may be displayed in the viewer.
+ * May provide really huge results, so, working with this kind
+ * of result must be optimized.
+ */
+class Model_ResultBody : public ModelAPI_ResultBody
+{
+  boost::shared_ptr<ModelAPI_Feature> myOwner; ///< owner of this result
+public:
+  /// Stores the shape (called by the execution method).
+  MODEL_EXPORT virtual void store(const boost::shared_ptr<GeomAPI_Shape>& theShape);
+  /// Returns the shape-result produced by this feature
+  MODEL_EXPORT virtual boost::shared_ptr<GeomAPI_Shape> shape();
+  /// Returns the source feature of this result
+  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> owner();
+
+protected:
+  /// Makes a body on the given feature
+  Model_ResultBody(const boost::shared_ptr<ModelAPI_Feature>& theFeature);
+
+  friend class Model_Document;
+};
+
+#endif
diff --git a/src/Model/Model_ResultConstruction.cpp b/src/Model/Model_ResultConstruction.cpp
new file mode 100644 (file)
index 0000000..a5e1ccc
--- /dev/null
@@ -0,0 +1,26 @@
+// File:        ModelAPI_ResultConstruction.cpp
+// Created:     07 Jul 2014
+// Author:      Mikhail PONIKAROV
+
+#include <Model_ResultConstruction.h>
+
+void Model_ResultConstruction::setShape(boost::shared_ptr<GeomAPI_Shape> theShape)
+{
+  myShape = theShape;
+}
+
+boost::shared_ptr<GeomAPI_Shape>& Model_ResultConstruction::shape()
+{
+  return myShape;
+}
+
+boost::shared_ptr<ModelAPI_Feature> Model_ResultConstruction::owner()
+{
+  return myOwner;
+}
+
+Model_ResultConstruction::Model_ResultConstruction(
+  const boost::shared_ptr<ModelAPI_Feature>& theFeature)
+  : myOwner(theFeature)
+{
+}
diff --git a/src/Model/Model_ResultConstruction.h b/src/Model/Model_ResultConstruction.h
new file mode 100644 (file)
index 0000000..b6ca721
--- /dev/null
@@ -0,0 +1,40 @@
+// File:        ModelAPI_ResultConstruction.hxx
+// Created:     07 Jul 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef Model_ResultConstruction_HeaderFile
+#define Model_ResultConstruction_HeaderFile
+
+#include "Model.h"
+#include <ModelAPI_ResultConstruction.h>
+
+/**\class ModelAPI_ResultConstruction
+ * \ingroup DataModel
+ * \brief The construction element result of a feature.
+ *
+ * Provides a shape that may be displayed in the viewer.
+ * Intermediate, light result that in many cases produces a result on the fly.
+ */
+class Model_ResultConstruction : public ModelAPI_ResultConstruction
+{
+  boost::shared_ptr<ModelAPI_Feature> myOwner; ///< owner of this result
+  boost::shared_ptr<GeomAPI_Shape> myShape; ///< shape of this result created "on the fly"
+public:
+  /// Returns the group identifier of this result
+  virtual std::string group()
+    {static std::string MY_GROUP = "Construction"; return MY_GROUP;}
+  /// Sets the result
+  MODEL_EXPORT virtual void setShape(boost::shared_ptr<GeomAPI_Shape> theShape);
+  /// Returns the shape-result produced by this feature
+  MODEL_EXPORT virtual boost::shared_ptr<GeomAPI_Shape>& shape();
+  /// Returns the source feature of this result
+  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> owner();
+
+protected:
+  /// Makes a body on the given feature
+  Model_ResultConstruction();
+
+  friend class Model_Document;
+};
+
+#endif
diff --git a/src/Model/Model_ResultPart.cpp b/src/Model/Model_ResultPart.cpp
new file mode 100644 (file)
index 0000000..38b72fa
--- /dev/null
@@ -0,0 +1,22 @@
+// File:        ModelAPI_ResultPart.cpp
+// Created:     07 Jul 2014
+// Author:      Mikhail PONIKAROV
+
+#include <Model_ResultPart.h>
+#include <ModelAPI_Data.h>
+#include <ModelAPI_AttributeDocRef.h>
+
+boost::shared_ptr<ModelAPI_Document> Model_ResultPart::partDoc()
+{
+  return data()->docRef("PartDocument")->value();
+}
+
+boost::shared_ptr<ModelAPI_Feature> Model_ResultPart::owner()
+{
+  return boost::shared_ptr<ModelAPI_Feature>(); // return empty pointer
+}
+
+Model_ResultPart::Model_ResultPart(
+const boost::shared_ptr<ModelAPI_Feature>& theFeature)
+{
+}
diff --git a/src/Model/Model_ResultPart.h b/src/Model/Model_ResultPart.h
new file mode 100644 (file)
index 0000000..b2daa5d
--- /dev/null
@@ -0,0 +1,36 @@
+// File:        ModelAPI_ResultPart.hxx
+// Created:     07 Jul 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef Model_ResultPart_HeaderFile
+#define Model_ResultPart_HeaderFile
+
+#include "Model.h"
+#include <ModelAPI_ResultPart.h>
+
+/**\class ModelAPI_ResultPart
+ * \ingroup DataModel
+ * \brief The Part document, result of a creation of new part feature.
+ *
+ * This result leaves without feature: no parametricity for this element,
+ * only add/remove, undo/redo.
+ */
+class Model_ResultPart : public ModelAPI_ResultPart
+{
+public:
+  /// Returns the group identifier of this result
+  virtual std::string group()
+    {static std::string MY_GROUP = "Parts"; return MY_GROUP;}
+  /// Returns the part-document of this result
+  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> partDoc();
+  /// Part has no stored feature: this method returns NULL
+  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> owner();
+
+protected:
+  /// makes a result on a temporary feature (an action)
+  Model_ResultPart(const boost::shared_ptr<ModelAPI_Feature>& theFeature);
+
+  friend class Model_Document;
+};
+
+#endif
index 6c8bd6431d3d9a085d069f5791f9209105f176b2..4fd5f29657e336facc26dea124a8ebd505c00f5f 100644 (file)
@@ -17,17 +17,17 @@ 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_FEATURE_UPDATED));
+  Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
 }
 
 void Model_Update::processEvent(const Events_Message* theMessage)
 {
-  const ModelAPI_FeatureUpdatedMessage* aMsg = 
-    dynamic_cast<const ModelAPI_FeatureUpdatedMessage*>(theMessage);
+  const ModelAPI_ObjectUpdatedMessage* aMsg = 
+    dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
   myInitial = aMsg->features();
   // collect all documents involved into the update
   set<boost::shared_ptr<ModelAPI_Document> > aDocs;
-  set<boost::shared_ptr<ModelAPI_Feature> >::iterator aFIter = myInitial.begin();
+  set<boost::shared_ptr<ModelAPI_Object> >::iterator aFIter = myInitial.begin();
   for(; aFIter != myInitial.end(); aFIter++) {
     aDocs.insert((*aFIter)->document());
   }
@@ -36,14 +36,15 @@ void Model_Update::processEvent(const Events_Message* theMessage)
   for(; aDIter != aDocs.end(); aDIter++) {
     int aNbFeatures = (*aDIter)->size(FEATURES_GROUP);
     for(int aFIndex = 0; aFIndex < aNbFeatures; aFIndex++) {
-      boost::shared_ptr<ModelAPI_Feature> aFeature = (*aDIter)->feature(FEATURES_GROUP, aFIndex);
+      boost::shared_ptr<ModelAPI_Feature> aFeature = 
+        boost::dynamic_pointer_cast<ModelAPI_Feature>((*aDIter)->object(FEATURES_GROUP, aFIndex));
       if (aFeature)
         updateFeature(aFeature);
     }
   }
   myUpdated.clear();
   // flush
-  static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_FEATURE_TO_REDISPLAY);
+  static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
   Events_Loop::loop()->flush(EVENT_DISP);
 }
 
@@ -80,7 +81,7 @@ bool Model_Update::updateFeature(boost::shared_ptr<ModelAPI_Feature> theFeature)
   bool anExecute = aMustbeUpdated || myInitial.find(theFeature) != myInitial.end();
   if (anExecute) {
     theFeature->execute();
-    static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_FEATURE_TO_REDISPLAY);
+    static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
     ModelAPI_EventCreator::get()->sendUpdated(theFeature, EVENT_DISP);
   }
   myUpdated[theFeature] = anExecute;
index d49c1c01e1c74aac7c32c020f5fa85f9979f8be1..3d5e58a01b601bc31397feca4017bfb52ef673b6 100644 (file)
@@ -11,6 +11,7 @@
 #include <set>
 #include <map>
 
+class ModelAPI_Object;
 class ModelAPI_Feature;
 
 /**\class Model_Update
@@ -20,9 +21,9 @@ class ModelAPI_Feature;
 class Model_Update : public Events_Listener
 {
   ///< initial set of updated features that must be processed
-  std::set<boost::shared_ptr<ModelAPI_Feature> > myInitial;
+  std::set<boost::shared_ptr<ModelAPI_Object> > myInitial;
   ///< already updated and processed features and modificated feature flag
-  std::map<boost::shared_ptr<ModelAPI_Feature>, bool> myUpdated;
+  std::map<boost::shared_ptr<ModelAPI_Object>, bool> myUpdated;
 public:
   /// Is called only once, on startup of the application
   Model_Update();
index 8b834dd72561b7790f3bde8fa3a7048c8c786983..80ec6cd74fb12a4f5a3b4a98c4cd11f49a8e9da3 100644 (file)
@@ -20,6 +20,10 @@ SET(PROJECT_HEADERS
     ModelAPI_Events.h
     ModelAPI_Validator.h
     ModelAPI_FeatureValidator.h
+    ModelAPI_Result.h
+    ModelAPI_ResultBody.h
+    ModelAPI_ResultConstruction.h
+    ModelAPI_ResultPart.h
 )
 
 SET(PROJECT_SOURCES
index 4a15abb88c718b680beeff2b45d323c3020426e2..55cbb7cfd9c1d8fc82b2c3ee3ccff5980db91c46 100644 (file)
@@ -9,7 +9,7 @@
 #include <string>
 #include <boost/shared_ptr.hpp>
 
-class ModelAPI_Feature;
+class ModelAPI_Object;
 
 /**\class ModelAPI_Attribute
  * \ingroup DataModel
@@ -18,7 +18,7 @@ class ModelAPI_Feature;
 class ModelAPI_Attribute
 {
   ///< needed here to emit signal that feature changed on change of the attribute
-  boost::shared_ptr<ModelAPI_Feature> myFeature;
+  boost::shared_ptr<ModelAPI_Object> myObject;
 protected: // accessible from the attributes
   bool myIsInitialized;
 public:
@@ -30,12 +30,12 @@ public:
   MODELAPI_EXPORT virtual ~ModelAPI_Attribute() {}
 
   /// Sets the owner of this attribute
-  MODELAPI_EXPORT void setFeature(const boost::shared_ptr<ModelAPI_Feature>& theFeature)
-    {myFeature = theFeature;}
+  MODELAPI_EXPORT void setObject(const boost::shared_ptr<ModelAPI_Object>& theObject)
+    {myObject = theObject;}
 
   /// Returns the owner of this attribute
-  MODELAPI_EXPORT const boost::shared_ptr<ModelAPI_Feature>& owner()
-  {return myFeature;}
+  MODELAPI_EXPORT const boost::shared_ptr<ModelAPI_Object>& owner()
+  {return myObject;}
 
   /// Returns true if attribute was  initialized by some value
   MODELAPI_EXPORT bool isInitialized() {return myIsInitialized;}
index 5d6e36d5f8e7a9293b47180b3f84a85c3c76be23..eea1d1ae87ac75bbc9f4c614edb2907467d4cc14 100644 (file)
@@ -31,7 +31,7 @@ class MODELAPI_EXPORT ModelAPI_Data
 public:
 
   /// Returns the name of the feature visible by the user in the object browser
-  virtual std::string getName() = 0;
+  virtual std::string name() = 0;
 
   /// Defines the name of the feature visible by the user in the object browser
   virtual void setName(std::string theName) = 0;
@@ -64,11 +64,6 @@ public:
   /// Returns true if it is correctly connected t othe data model
   virtual bool isValid() = 0;
 
-  /// Stores the shape (called by the execution method).
-  virtual void store(const boost::shared_ptr<GeomAPI_Shape>& theShape) = 0;
-  /// Returns the shape-result produced by this feature
-  virtual boost::shared_ptr<GeomAPI_Shape> shape() = 0;
-
   /// Initializes object by the attributes: must be called just after the object is created
   /// for each attribute of the object
   /// \param theID identifier of the attribute that can be referenced by this ID later
index 9070718b48974151d3b0a4ea2332f65438340f71..36342b3dd2dee6cb3b0adfe2e7183cdd574a7afa 100644 (file)
@@ -11,6 +11,9 @@
 #include <vector>
 
 class ModelAPI_Feature;
+class ModelAPI_Object;
+class ModelAPI_Result;
+class ModelAPI_ResultConstruction;
 
 /// Common groups identifiers
 /// Group of parameters
@@ -19,6 +22,8 @@ static const std::string PARAMETERS_GROUP = "Parameters";
 static const std::string CONSTRUCTIONS_GROUP = "Construction";
 /// Group of parts
 static const std::string PARTS_GROUP = "Parts";
+/// Group of bodies
+static const std::string BODIES_GROUP = "Bodies";
 /// All created fetaures of the document (a history)
 static const std::string FEATURES_GROUP = "Features";
 
@@ -35,63 +40,65 @@ public:
   //! \param theFileName full name of the file to load
   //! \param theStudyID identifier of the SALOME study to associate with loaded file
   //! \returns true if file was loaded successfully
-  MODELAPI_EXPORT virtual bool load(const char* theFileName) = 0;
+  virtual bool load(const char* theFileName) = 0;
 
   //! Saves the OCAF document to the file.
   //! \param theFileName full name of the file to store
   //! \returns true if file was stored successfully
-  MODELAPI_EXPORT virtual bool save(const char* theFileName) = 0;
+  virtual bool save(const char* theFileName) = 0;
 
   //! Removes document data
-  MODELAPI_EXPORT virtual void close() = 0;
+  virtual void close() = 0;
 
   //! Starts a new operation (opens a tansaction)
-  MODELAPI_EXPORT virtual void startOperation() = 0;
+  virtual void startOperation() = 0;
   //! Finishes the previously started operation (closes the transaction)
-  MODELAPI_EXPORT virtual void finishOperation() = 0;
+  virtual void finishOperation() = 0;
   //! Aborts the operation 
-  MODELAPI_EXPORT virtual void abortOperation() = 0;
+  virtual void abortOperation() = 0;
   //! Returns true if operation has been started, but not yet finished or aborted
-  MODELAPI_EXPORT virtual bool isOperation() = 0;
+  virtual bool isOperation() = 0;
   //! Returns true if document was modified (since creation/opening)
-  MODELAPI_EXPORT virtual bool isModified() = 0;
+  virtual bool isModified() = 0;
 
   //! Returns True if there are available Undos
-  MODELAPI_EXPORT virtual bool canUndo() = 0;
+  virtual bool canUndo() = 0;
   //! Undoes last operation
-  MODELAPI_EXPORT virtual void undo() = 0;
+  virtual void undo() = 0;
   //! Returns True if there are available Redos
-  MODELAPI_EXPORT virtual bool canRedo() = 0;
+  virtual bool canRedo() = 0;
   //! Redoes last operation
-  MODELAPI_EXPORT virtual void redo() = 0;
+  virtual void redo() = 0;
 
   //! Adds to the document the new feature of the given feature id
-  //! \param creates feature and puts it in the document
-  MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> addFeature(std::string theID) = 0;
+  //! \param creates feature and puts it in the document (if it is not action)
+  virtual boost::shared_ptr<ModelAPI_Feature> addFeature(std::string theID) = 0;
 
   //! Removes the feature from the document
-  MODELAPI_EXPORT virtual void removeFeature(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
+  virtual void removeFeature(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
 
   ///! Adds a new sub-document by the identifier, or returns existing one if it is already exist
-  MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Document> 
+  virtual boost::shared_ptr<ModelAPI_Document> 
     subDocument(std::string theDocID) = 0;
 
-  ///! Returns the id of hte document
-  MODELAPI_EXPORT virtual const std::string& id() const = 0;
+  ///! Returns the id of the document
+  virtual const std::string& id() const = 0;
 
-  //! Returns the feature in the group by the index (started from zero)
-  //! \param theGroupID group that contains a feature
+  //! 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 isOperation if it is true, returns feature (not Object)
-  MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> 
-    feature(const std::string& theGroupID, const int theIndex, const bool isOperation = false) = 0;
+  virtual boost::shared_ptr<ModelAPI_Object> 
+    object(const std::string& theGroupID, const int theIndex) = 0;
 
-  //! Returns the number of features in the group
-  MODELAPI_EXPORT virtual int size(const std::string& theGroupID) = 0;
+  //! Returns the number of objects in the group of objects
+  virtual int size(const std::string& theGroupID) = 0;
 
   /// To virtually destroy the fields of successors
   virtual ~ModelAPI_Document() {}
 
+  /// Creates a construction cresults
+  virtual boost::shared_ptr<ModelAPI_ResultConstruction> createConstruction() = 0;
+
 protected:
   /// Only for SWIG wrapping it is here
   MODELAPI_EXPORT ModelAPI_Document()
index 215c34c7148ea83f36a3fcb32c596746819b1e66..773d20b41d23797d4a99536534adc3dbfcb58117 100644 (file)
 #include <string>
 #include <set>
 
-#include "ModelAPI_Feature.h"
+#include "ModelAPI_Object.h"
 
 class ModelAPI_Document;
 
-/// Event ID that feature is created (comes with ModelAPI_FeatureUpdatedMessage)
-static const char * EVENT_FEATURE_CREATED = "FeatureCreated";
-/// Event ID that data of feature is updated (comes with Model_FeatureUpdatedMessage)
-static const char * EVENT_FEATURE_UPDATED = "FeatureUpdated";
-/// Event ID that data of feature is deleted (comes with Model_FeatureDeletedMessage)
-static const char * EVENT_FEATURE_DELETED = "FeatureDeleted";
-/// Event ID that data of feature is updated (comes with ModelAPI_FeatureUpdatedMessage)
-static const char * EVENT_FEATURE_MOVED = "FeaturesMoved";
-/// Event ID that visualization must be redisplayed (comes with ModelAPI_FeatureUpdatedMessage)
-static const char * EVENT_FEATURE_TO_REDISPLAY = "FeaturesToRedisplay";
-/// Event ID that visualization must be redisplayed (comes with ModelAPI_FeatureUpdatedMessage)
+/// Event ID that feature is created (comes with ModelAPI_ObjectUpdatedMessage)
+static const char * EVENT_OBJECT_CREATED = "ObjectCreated";
+/// Event ID that data of feature is updated (comes with Model_ObjectUpdatedMessage)
+static const char * EVENT_OBJECT_UPDATED = "ObjectUpdated";
+/// Event ID that data of feature is deleted (comes with Model_ObjectDeletedMessage)
+static const char * EVENT_OBJECT_DELETED = "ObjectDeleted";
+/// Event ID that data of feature is updated (comes with ModelAPI_ObjectUpdatedMessage)
+static const char * EVENT_OBJECT_MOVED = "ObjectsMoved";
+/// Event ID that visualization must be redisplayed (comes with ModelAPI_ObjectUpdatedMessage)
+static const char * EVENT_OBJECT_TO_REDISPLAY = "ObjectsToRedisplay";
+/// Event ID that visualization must be redisplayed (comes with ModelAPI_ObjectUpdatedMessage)
 static const char * EVENT_OPERATION_LAUNCHED = "OperationLaunched";
 
 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
-class ModelAPI_FeatureUpdatedMessage : public Events_MessageGroup {
+class ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup {
 protected:
-  ModelAPI_FeatureUpdatedMessage(const Events_ID theID, const void* theSender = 0)
+  ModelAPI_ObjectUpdatedMessage(const Events_ID theID, const void* theSender = 0)
     : Events_MessageGroup(theID, theSender) {}
 
 public:
   /// Returns the feature that has been updated
-  virtual std::set<FeaturePtr> features() const = 0;
+  virtual std::set<ObjectPtr> features() const = 0;
 
   //! Creates a new empty group (to store it in the loop before flush)
   virtual Events_MessageGroup* newEmpty() = 0;
@@ -46,9 +46,9 @@ public:
 };
 
 /// Message that feature was deleted (used for Object Browser update)
-class ModelAPI_FeatureDeletedMessage : public Events_MessageGroup {
+class ModelAPI_ObjectDeletedMessage : public Events_MessageGroup {
 protected:
-  ModelAPI_FeatureDeletedMessage(const Events_ID theID, const void* theSender = 0)
+  ModelAPI_ObjectDeletedMessage(const Events_ID theID, const void* theSender = 0)
     : Events_MessageGroup(theID, theSender) {}
 
 public:
@@ -69,7 +69,7 @@ public:
 class MODELAPI_EXPORT ModelAPI_EventCreator {
 public:
   /// creates created, updated or moved messages and sends to the loop
-  virtual void sendUpdated(const FeaturePtr& theFeature, const Events_ID& theEvent,
+  virtual void sendUpdated(const ObjectPtr& theObject, const Events_ID& theEvent,
                            const bool isGroupped = true) const = 0;
   /// creates deleted message and sends to the loop
   virtual void sendDeleted(
index 6d7955f4b1dee713b9149faa581656770c1f5155..0bdb7817ee43550a266a43b57ac998319eea0686 100644 (file)
@@ -5,81 +5,53 @@
 #ifndef ModelAPI_Feature_HeaderFile
 #define ModelAPI_Feature_HeaderFile
 
-#include "ModelAPI.h"
+#include "ModelAPI_Object.h"
 #include "ModelAPI_PluginManager.h"
 
 #include <string>
+#include <list>
 #include <boost/shared_ptr.hpp>
 
 class ModelAPI_Data;
 class ModelAPI_Document;
+class ModelAPI_Result;
 
 /**\class ModelAPI_Feature
  * \ingroup DataModel
- * \brief Functionality of the model object: to update result,
- * to initialize attributes, etc.
+ * \brief Feature function that represents the particular functionality
+ * of this operation. Produces results by the arguments.
  */
-class ModelAPI_Feature
+class ModelAPI_Feature : public ModelAPI_Object
 {
-  boost::shared_ptr<ModelAPI_Data> myData; ///< manager of the data model of a feature
-  boost::shared_ptr<ModelAPI_Document> myDoc; ///< document this feature belongs to
-
+  ///< list of current results of this feature
+  std::list<boost::shared_ptr<ModelAPI_Result> > myResults;
 public:
-  /// Returns the kind of a feature (like "Point")
-  MODELAPI_EXPORT virtual const std::string& getKind() = 0;
-
-  /// Returns to which group in the document must be added feature
-  MODELAPI_EXPORT virtual const std::string& getGroup() = 0;
+  /// Returns the unique kind of a feature (like "Point")
+  virtual const std::string& getKind() = 0;
 
   /// Request for initialization of data model of the feature: adding all attributes
-  MODELAPI_EXPORT virtual void initAttributes() = 0;
+  virtual void initAttributes() = 0;
 
-  /// Computes or recomputes the result
-  MODELAPI_EXPORT virtual void execute() = 0;
+  /// Computes or recomputes the results
+  virtual void execute() = 0;
 
-  /// Returns true if this feature must be displayed in the history (top level of Part tree)
-  MODELAPI_EXPORT virtual bool isInHistory() {return true;}
+  // returns the current results of the feature
+  std::list<boost::shared_ptr<ModelAPI_Result> >& results() {return myResults;}
 
   /// Returns true if this feature must not be created: this is just an action
-  /// that is not stored in the features history (like delete part).
-  MODELAPI_EXPORT virtual bool isAction() {return false;}
-
-  /// Returns the data manager of this feature
-  MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Data> data() {return myData;}
+  /// that is not stored in the features history and data model (like "delete part").
+  virtual bool isAction() {return false;}
 
   /// Must return document where the new feature must be added to
   /// By default it is current document
-  MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Document> documentToAdd()
+  virtual boost::shared_ptr<ModelAPI_Document> documentToAdd()
   {return ModelAPI_PluginManager::get()->currentDocument();}
 
-  /// Returns document this feature belongs to
-  MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Document> document()
-  {return myDoc;}
-
-  /// Returns true if feature refers to the same model data instance
-  MODELAPI_EXPORT virtual bool isSame(const boost::shared_ptr<ModelAPI_Feature>& theFeature)
-  {return theFeature.get() == this;}
-
   /// To virtually destroy the fields of successors
   virtual ~ModelAPI_Feature() {}
-
-protected:
-  /// Use plugin manager for features creation: this method is 
-  /// defined here only for SWIG-wrapping
-  ModelAPI_Feature()
-  {}
-
-  /// Sets the data manager of an object (document does)
-  MODELAPI_EXPORT virtual void setData(boost::shared_ptr<ModelAPI_Data> theData) 
-  {myData = theData;}
-  /// Sets the data manager of an object (document does)
-  MODELAPI_EXPORT void setDoc(boost::shared_ptr<ModelAPI_Document> theDoc) {myDoc = theDoc;}
-
-  friend class Model_Document;
 };
 
 //! Pointer on feature object
 typedef boost::shared_ptr<ModelAPI_Feature> FeaturePtr;
 
-
 #endif
index 581f045884c0e45f2bf4efc43271fbfa47634611..04a281b8f985d5809c972762e78e097c7c7237e1 100644 (file)
@@ -5,33 +5,51 @@
 #ifndef ModelAPI_Object_HeaderFile
 #define ModelAPI_Object_HeaderFile
 
-#include "ModelAPI_Feature.h"
+#include "ModelAPI.h"
 
 #include <boost/shared_ptr.hpp>
 
+class ModelAPI_Data;
+class ModelAPI_Document;
+
 /**\class ModelAPI_Object
  * \ingroup DataModel
- * \brief Represents the result of some feature in the object browser
- * under the specific folder. Just a reference to specific feature-operation
- * with possibility to rename it.
+ * \brief Represents any object in the data model and in the object browser.
+ *
+ * It may be feature or result of the feature. User just may set name for it
+ * or change this name later. Generic class for Feature, Body, Parameter and other
+ * objects related to the features and their results. Contains attributes of this 
+ * object in the "Data".
  */
-class ModelAPI_Object : public ModelAPI_Feature
+class ModelAPI_Object
 {
+  boost::shared_ptr<ModelAPI_Data> myData; ///< manager of the data model of a feature
+  boost::shared_ptr<ModelAPI_Document> myDoc; ///< document this feature belongs to
 public:
+  /// By default object is displayed in the object browser.
+  virtual bool isInHistory() {return true;}
 
-  /// It is never located in history
-  MODELAPI_EXPORT virtual bool isInHistory() {return false;}
+  /// Returns the data manager of this object: attributes
+  virtual boost::shared_ptr<ModelAPI_Data> data() {return myData;}
 
-  /// Reference to the feature-operation that produces this object
-  MODELAPI_EXPORT virtual FeaturePtr featureRef() = 0;
+  /// Returns true if feature refers to the same data model instance
+  virtual bool isSame(const boost::shared_ptr<ModelAPI_Object>& theObject)
+    {return theObject.get() == this;}
 
-  /// Returns the name of this object (by default equal to the name of feature)
-  MODELAPI_EXPORT virtual std::string getName() = 0;
+  /// Returns document this feature belongs to
+  virtual boost::shared_ptr<ModelAPI_Document> document()
+    {return myDoc;}
 
-  /// Defines the name of the object
-  MODELAPI_EXPORT virtual void setName(std::string theName) = 0;
-};
+protected:
+  /// Sets the data manager of an object (document does)
+  virtual void setData(boost::shared_ptr<ModelAPI_Data> theData) 
+    {myData = theData;}
 
+  /// Sets the data manager of an object (document does)
+  virtual void setDoc(boost::shared_ptr<ModelAPI_Document> theDoc) {myDoc = theDoc;}
+
+  friend class Model_Document;
+};
 
 typedef boost::shared_ptr<ModelAPI_Object> ObjectPtr;
 
diff --git a/src/ModelAPI/ModelAPI_Result.h b/src/ModelAPI/ModelAPI_Result.h
new file mode 100644 (file)
index 0000000..b84cd0b
--- /dev/null
@@ -0,0 +1,31 @@
+// File:        ModelAPI_Result.hxx
+// Created:     07 Jul 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef ModelAPI_Result_HeaderFile
+#define ModelAPI_Result_HeaderFile
+
+#include "ModelAPI_Object.h"
+
+class ModelAPI_Feature;
+
+/**\class ModelAPI_Result
+ * \ingroup DataModel
+ * \brief The result of a feature.
+ *
+ * A generic class that .
+ */
+class ModelAPI_Result : public ModelAPI_Object
+{
+public:
+  /// Returns the source feature of this result
+  //virtual boost::shared_ptr<ModelAPI_Feature> owner() = 0;
+
+  /// Returns the group identifier of this result
+  virtual std::string group() = 0;
+};
+
+//! Pointer on feature object
+typedef boost::shared_ptr<ModelAPI_Result> ResultPtr;
+
+#endif
diff --git a/src/ModelAPI/ModelAPI_ResultBody.h b/src/ModelAPI/ModelAPI_ResultBody.h
new file mode 100644 (file)
index 0000000..f801ad4
--- /dev/null
@@ -0,0 +1,44 @@
+// File:        ModelAPI_ResultBody.hxx
+// Created:     07 Jul 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef ModelAPI_ResultBody_HeaderFile
+#define ModelAPI_ResultBody_HeaderFile
+
+#include "ModelAPI_Result.h"
+#include <GeomAPI_Shape.h>
+
+/**\class ModelAPI_ResultBody
+ * \ingroup DataModel
+ * \brief The body (shape) result of a feature.
+ *
+ * Provides a shape that may be displayed in the viewer.
+ * May provide really huge results, so, working with this kind
+ * of result must be optimized.
+ */
+class ModelAPI_ResultBody : public ModelAPI_Result
+{
+public:
+  /// Returns the group identifier of this result
+  virtual std::string group()
+    {static std::string MY_GROUP = "Bodies"; return MY_GROUP;}
+
+  /// Stores the shape (called by the execution method).
+  virtual void store(const boost::shared_ptr<GeomAPI_Shape>& theShape) = 0;
+  /// Returns the shape-result produced by this feature
+  virtual boost::shared_ptr<GeomAPI_Shape> shape() = 0;
+
+  /// To virtually destroy the fields of successors
+  virtual ~ModelAPI_ResultBody() {}
+
+protected:
+  /// Use plugin manager for features creation: this method is 
+  /// defined here only for SWIG-wrapping
+  ModelAPI_ResultBody()
+  {}
+};
+
+//! Pointer on feature object
+typedef boost::shared_ptr<ModelAPI_ResultBody> ResultBodyPtr;
+
+#endif
diff --git a/src/ModelAPI/ModelAPI_ResultConstruction.h b/src/ModelAPI/ModelAPI_ResultConstruction.h
new file mode 100644 (file)
index 0000000..ede2f73
--- /dev/null
@@ -0,0 +1,31 @@
+// File:        ModelAPI_ResultConstruction.h
+// Created:     07 Jul 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef ModelAPI_ResultConstruction_HeaderFile
+#define ModelAPI_ResultConstruction_HeaderFile
+
+#include "ModelAPI_Result.h"
+#include <GeomAPI_Shape.h>
+
+/**\class ModelAPI_ResultConstruction
+ * \ingroup DataModel
+ * \brief The construction element result of a feature.
+ *
+ * Provides a shape that may be displayed in the viewer.
+ * Intermediate, light result that in many cases produces a result on the fly.
+ */
+class ModelAPI_ResultConstruction : public ModelAPI_Result
+{
+public:
+  /// Returns the shape-result produced by this feature
+  virtual boost::shared_ptr<GeomAPI_Shape>& shape() = 0;
+
+  /// Sets the result
+  virtual void setShape(boost::shared_ptr<GeomAPI_Shape> theShape) = 0;
+};
+
+//! Pointer on feature object
+typedef boost::shared_ptr<ModelAPI_ResultConstruction> ResultConstructionPtr;
+
+#endif
diff --git a/src/ModelAPI/ModelAPI_ResultPart.h b/src/ModelAPI/ModelAPI_ResultPart.h
new file mode 100644 (file)
index 0000000..575328b
--- /dev/null
@@ -0,0 +1,27 @@
+// File:        ModelAPI_ResultPart.h
+// Created:     07 Jul 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef ModelAPI_ResultPart_HeaderFile
+#define ModelAPI_ResultPart_HeaderFile
+
+#include "ModelAPI_Result.h"
+
+/**\class ModelAPI_ResultPart
+ * \ingroup DataModel
+ * \brief The Part document, result of a creation of new part feature.
+ *
+ * This result leaves without feature: no parametricity for this element,
+ * only add/remove, undo/redo.
+ */
+class ModelAPI_ResultPart : public ModelAPI_Result
+{
+public:
+  /// Returns the part-document of this result
+  virtual boost::shared_ptr<ModelAPI_Document> partDoc() = 0;
+};
+
+//! Pointer on feature object
+typedef boost::shared_ptr<ModelAPI_ResultPart> ResultPart;
+
+#endif
index c1ed4b0d0b2648f55ac2922302a3f79c296bbd78..ba757565d4dd40614e5cbe2292f65cf62bc34a2d 100644 (file)
@@ -93,12 +93,12 @@ void ModuleBase_Operation::afterCommitOperation()
 
 void ModuleBase_Operation::flushUpdated()
 {
-  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
+  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
 }
 
 void ModuleBase_Operation::flushCreated()
 {
-  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_CREATED));
+  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
 }
 
 FeaturePtr ModuleBase_Operation::createFeature(const bool theFlushMessage)
index a34a73d6f02bedf6c2250345486d16cff2c3dff3..58a7f371dccd94e57d8b198c6ca936208fa57de3 100644 (file)
@@ -47,7 +47,7 @@ bool ModuleBase_WidgetBoolValue::storeValue(FeaturePtr theFeature) const
 
   if (aBool->value() != myCheckBox->isChecked()) {
     aBool->setValue(myCheckBox->isChecked());
-    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
+    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
   }
   return true;
 }
index ccbb0ad7ebd14a781d8cbee54999d8c636038f65..19828f008bd3ab8028c93a5ce055d864ee2bc8c1 100644 (file)
@@ -94,7 +94,7 @@ bool ModuleBase_WidgetDoubleValue::storeValue(FeaturePtr theFeature) const
   AttributeDoublePtr aReal = aData->real(attributeID());
   if (aReal->value() != mySpinBox->value()) {
     aReal->setValue(mySpinBox->value());
-    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
+    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
   }
   return true;
 }
index d1e2ceea66fc30ea0734f2fd7f534ec6167391da..7e43f4f5506b512cb5ff690b1413b9946885a61a 100644 (file)
@@ -88,7 +88,7 @@ bool ModuleBase_WidgetFeature::storeValue(FeaturePtr theFeature) const
   ModuleBase_WidgetFeature* that = (ModuleBase_WidgetFeature*) this;
   aRef->setFeature(myFeature);
   theFeature->execute();
-  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
+  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
 
   return true;
 }
index 0099c993fc5055ab6a36451746b9e3d0a3a3c8db..6fd65bf96e58d58f63e7795d58013913d6ee14e4 100644 (file)
@@ -85,7 +85,7 @@ bool ModuleBase_WidgetFeatureOrAttribute::storeValue(FeaturePtr theFeature) cons
     aRef->setAttr(myAttribute);
 
   theFeature->execute();
-  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
+  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
 
   return true;
 }
index baa7285b054873ef2bf7f8c59defbac16ebd0f05..8407084edf44b233cac4b5341a19d9c33e8e462b 100644 (file)
@@ -110,7 +110,7 @@ bool ModuleBase_WidgetPoint2D::storeValue(FeaturePtr theFeature) const
   ModuleBase_WidgetPoint2D* that = (ModuleBase_WidgetPoint2D*) this;
   bool isBlocked = that->blockSignals(true);
   aPoint->setValue(myXSpin->value(), myYSpin->value());
-  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
+  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
   that->blockSignals(isBlocked);
 
   return true;
index df7b431fbabc2b71000692c297d7bffcca9766dc..08e9eb0201a51080d472b68c4cd629116d983090 100644 (file)
@@ -106,7 +106,7 @@ bool ModuleBase_WidgetSelector::storeValue(FeaturePtr theFeature) const
   FeaturePtr aFeature = aRef->value();
   if (!(aFeature && aFeature->isSame(mySelectedFeature))) {
     aRef->setValue(mySelectedFeature);
-    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
+    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
   }
   return true;
 }
index f9229d38324340d5935cf40df2893d900b73a91d..1b357fadb927e1e004dc916812cbad2f170ee863 100644 (file)
@@ -24,9 +24,9 @@ PartSet_Listener::PartSet_Listener(PartSet_Module* theModule)
 : myModule(theModule)
 {
   Events_Loop* aLoop = Events_Loop::loop();
-  aLoop->registerListener(this, aLoop->eventByName(EVENT_FEATURE_UPDATED));
-  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_CREATED));
-  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_DELETED));
+  aLoop->registerListener(this, aLoop->eventByName(EVENT_OBJECT_UPDATED));
+  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
+  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED));
 }
 
 PartSet_Listener::~PartSet_Listener()
@@ -37,25 +37,25 @@ PartSet_Listener::~PartSet_Listener()
 void PartSet_Listener::processEvent(const Events_Message* theMessage)
 {
   QString aType = QString(theMessage->eventID().eventText());
-  if (aType == EVENT_FEATURE_UPDATED ||
-      aType == EVENT_FEATURE_CREATED)
+  if (aType == EVENT_OBJECT_UPDATED ||
+      aType == EVENT_OBJECT_CREATED)
   {
-    const ModelAPI_FeatureUpdatedMessage* aUpdMsg = 
-      dynamic_cast<const ModelAPI_FeatureUpdatedMessage*>(theMessage);
+    const ModelAPI_ObjectUpdatedMessage* aUpdMsg = 
+      dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
     std::set<FeaturePtr > aFeatures = aUpdMsg->features();
     std::set<FeaturePtr >::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
     for (; anIt != aLast; anIt++) {
       FeaturePtr aFeature = *anIt;
       if (myModule->workshop()->displayer()->isVisible(aFeature) ||
-          aType == EVENT_FEATURE_CREATED) {
+          aType == EVENT_OBJECT_CREATED) {
         myModule->visualizePreview(aFeature, true, false);
-        //if (aType == EVENT_FEATURE_CREATED)
+        //if (aType == EVENT_OBJECT_CREATED)
           myModule->activateFeature(aFeature, true);
       }
     }
     myModule->workshop()->displayer()->updateViewer();
   }
-  if (aType == EVENT_FEATURE_DELETED)
+  if (aType == EVENT_OBJECT_DELETED)
   {
     const ModelAPI_FeatureDeletedMessage* aDelMsg = 
       dynamic_cast<const ModelAPI_FeatureDeletedMessage*>(theMessage);
index c6ad6130ecb2902f917ec9247192110e79d12a93..468eb635c558ace6f0fe60dffdb2694109af33c3 100644 (file)
@@ -195,7 +195,7 @@ FeaturePtr PartSet_OperationFeatureEdit::createFeature(const bool /*theFlushMess
 
 void PartSet_OperationFeatureEdit::sendFeatures()
 {
-  static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_MOVED);
+  static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
 
   FeaturePtr aFeature = feature();
   ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent);
index ac2cd698268690709d071e4cea9565324222ddf2..960cab6b481cb917bfc602f28930b86af507b23b 100644 (file)
@@ -181,7 +181,7 @@ void PartSet_OperationFeatureEditMulti::blockSelection(bool isBlocked, const boo
 
 void PartSet_OperationFeatureEditMulti::sendFeatures()
 {
-  static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_MOVED);
+  static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
 
   std::list<FeaturePtr > aFeatures;
   std::list<ModuleBase_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
index e166608d14d5c0347845dad6aa07d0c79ab6a376..4b8e0e995f0ebed1521d4669190fe6c6f1191c7d 100644 (file)
@@ -5,13 +5,12 @@
 #include "SketchPlugin_Arc.h"
 #include "SketchPlugin_Sketch.h"
 #include <ModelAPI_Data.h>
+#include <ModelAPI_ResultConstruction.h>
 
 #include <GeomAPI_Circ2d.h>
 #include <GeomAPI_Pnt2d.h>
-
 #include <GeomDataAPI_Point2D.h>
 #include <GeomDataAPI_Dir.h>
-
 #include <GeomAlgoAPI_PointBuilder.h>
 #include <GeomAlgoAPI_EdgeBuilder.h>
 #include <GeomAlgoAPI_CompoundBuilder.h>
@@ -31,10 +30,6 @@ void SketchPlugin_Arc::initAttributes()
 }
 
 void SketchPlugin_Arc::execute() 
-{
-}
-
-const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Arc::preview()
 {
   SketchPlugin_Sketch* aSketch = sketch();
   if (aSketch) {
@@ -79,16 +74,12 @@ const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Arc::preview()
           aShapes.push_back(aCircleShape);
       }
       boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes);
-      setPreview(aCompound);
+      // store the result
+      boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction();
+      aConstr->setShape(aCompound);
+      results().push_back(aConstr);
     }
   }
-  return getPreview();
-}
-
-boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Arc::getAISObject(
-                                boost::shared_ptr<GeomAPI_AISObject> thePrevious)
-{
-  return prepareAISShape(thePrevious);
 }
 
 void SketchPlugin_Arc::move(double theDeltaX, double theDeltaY)
index 94660779572dff92f9044b4d74d06a056b68d7bb..5a4c6ed78b5d4a07ed9d4e36654ff50c62b57646 100644 (file)
@@ -30,19 +30,12 @@ public:
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
   {static std::string MY_KIND = SKETCH_ARC_KIND; return MY_KIND;}
 
-  /// Returns to which group in the document must be added feature
-  SKETCHPLUGIN_EXPORT virtual const std::string& getGroup()
-  {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
-
-  /// Creates a new part document if needed
+  /// Creates an arc-shape
   SKETCHPLUGIN_EXPORT virtual void execute();
 
   /// Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
 
-  /// Returns the sketch preview
-  SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
-
   /// Returns the AIS preview
   SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
                                 boost::shared_ptr<GeomAPI_AISObject> thePrevious);
index 593716ed9f2c6cea4cebf9eb3719950cdabbef1e..d962d4cfa0dcaf1bb0a9de8148da8e04701ff126 100644 (file)
@@ -5,16 +5,14 @@
 #include "SketchPlugin_Circle.h"
 #include "SketchPlugin_Sketch.h"
 #include <ModelAPI_Data.h>
+#include <ModelAPI_ResultConstruction.h>
 
 #include <GeomAPI_Pnt2d.h>
-
 #include <GeomDataAPI_Point2D.h>
 #include <GeomDataAPI_Dir.h>
-
 #include <GeomAlgoAPI_PointBuilder.h>
 #include <GeomAlgoAPI_EdgeBuilder.h>
 #include <GeomAlgoAPI_CompoundBuilder.h>
-
 #include <ModelAPI_AttributeDouble.h>
 
 SketchPlugin_Circle::SketchPlugin_Circle()
@@ -28,11 +26,7 @@ void SketchPlugin_Circle::initAttributes()
   data()->addAttribute(CIRCLE_ATTR_RADIUS, ModelAPI_AttributeDouble::type());
 }
 
-void SketchPlugin_Circle::execute()
-{
-}
-
-const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Circle::preview()
+void SketchPlugin_Circle::execute(boost::shared_ptr<ModelAPI_Result>& theResult)
 {
   SketchPlugin_Sketch* aSketch = sketch();
   if (aSketch) {
@@ -64,15 +58,9 @@ const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Circle::preview()
       }
     }
     boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes);
-    setPreview(aCompound);
+      // store the result
+    boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult)->setShape(aCompound);
   }
-  return getPreview();
-}
-
-boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Circle::getAISObject(
-                                boost::shared_ptr<GeomAPI_AISObject> thePrevious)
-{
-  return prepareAISShape(thePrevious);
 }
 
 void SketchPlugin_Circle::move(double theDeltaX, double theDeltaY)
index bb47c214de03db6987bb77b26d0346aa1ddbc172..2f2f01e429d9ded50294e61bab3286c925b5bcb9 100644 (file)
@@ -28,12 +28,8 @@ public:
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
   {static std::string MY_KIND = SKETCH_CIRCLE_KIND; return MY_KIND;}
 
-  /// Returns to which group in the document must be added feature
-  SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
-  {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
-
   /// Creates a new part document if needed
-  SKETCHPLUGIN_EXPORT virtual void execute();
+  SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr<ModelAPI_Result>& theResult);
 
   /// Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
index 5e8727687f0407e6cfb4fb7dd119b6382691f7b9..70e4d7be6d96affc0c23c53d8980c3fdee2082ce 100644 (file)
@@ -9,9 +9,3 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Constraint::getAISObject(
 { 
   return thePrevious;
 }
-
-const boost::shared_ptr<GeomAPI_Shape>&  SketchPlugin_Constraint::preview()
-{
-  return getPreview();
-}
-
index 5db923562970fa009ed3939fc100e20c5d53c083..9b6878b33e5f2e0e86e83e3195e868ac5015c4b7 100644 (file)
@@ -52,19 +52,12 @@ const std::string CONSTRAINT_ATTRIBUTES[CONSTRAINT_ATTR_SIZE] =
 class SketchPlugin_Constraint: public SketchPlugin_Feature
 {
 public:
-  /// \brief Returns to which group in the document must be added feature
-  SKETCHPLUGIN_EXPORT virtual const std::string& getGroup()
-  {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
-
   /** \brief Adds sub-feature of the higher level feature (sub-element of the sketch)
    *  \param theFeature sub-feature
    */
   SKETCHPLUGIN_EXPORT virtual const void addSub(
     const FeaturePtr& theFeature) {}
 
-  /// \brief Returns the sketch preview
-  SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
-
   /// Returns the AIS preview
   SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
                                 boost::shared_ptr<GeomAPI_AISObject> thePrevious);
index e052d1acee3838ab90e0b28e60d8ce68018a0238..0fd8b0bfff173a00dd3d13a21f09380abed65e01 100644 (file)
@@ -18,7 +18,7 @@ void SketchPlugin_ConstraintCoincidence::initAttributes()
   data()->addAttribute(CONSTRAINT_ATTR_ENTITY_B, ModelAPI_AttributeRefAttr::type());
 }
 
-void SketchPlugin_ConstraintCoincidence::execute()
+void SketchPlugin_ConstraintCoincidence::execute(boost::shared_ptr<ModelAPI_Result>& theResult)
 {
 }
 
index 9ed0e9653b6811c249e2f59ad7a7af9ef6c4c46a..f227d4cf828b86a447c76a03b9241ba3732191f1 100644 (file)
@@ -27,12 +27,8 @@ public:
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
   {static std::string MY_KIND = SKETCH_CONSTRAINT_COINCIDENCE_KIND; return MY_KIND;}
 
-  /// \brief Returns to which group in the document must be added feature
-  SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
-  {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
-
   /// \brief Creates a new part document if needed
-  SKETCHPLUGIN_EXPORT virtual void execute();
+  SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr<ModelAPI_Result>& theResult);
 
   /// \brief Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
index faa2d7b62270e966b31fd6b295149e2111d4628d..23ecc6435351e42f82a3a4b3cc80af997e5b5981 100644 (file)
@@ -30,7 +30,7 @@ void SketchPlugin_ConstraintDistance::initAttributes()
   data()->addAttribute(CONSTRAINT_ATTR_ENTITY_B, ModelAPI_AttributeRefAttr::type());
 }
 
-void SketchPlugin_ConstraintDistance::execute()
+void SketchPlugin_ConstraintDistance::execute(boost::shared_ptr<ModelAPI_Result>& theResult)
 {
   boost::shared_ptr<ModelAPI_Data> aData = data();
 
index 4350e3cb4b528c82d279c6e9d0801e875ff0621c..e633e9fe42e391b5b8b6f63d9aa6ae76757e9092 100644 (file)
@@ -28,12 +28,8 @@ public:
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
   {static std::string MY_KIND = SKETCH_CONSTRAINT_DISTANCE_KIND; return MY_KIND;}
 
-  /// \brief Returns to which group in the document must be added feature
-  SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
-  {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
-
   /// \brief Creates a new part document if needed
-  SKETCHPLUGIN_EXPORT virtual void execute();
+  SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr<ModelAPI_Result>& theResult);
 
   /// \brief Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
index 71a35c4f189624649c2501a7f66d36799a437ad2..0a5a11fcc3272f7c09b139712b4d63361a71e357 100644 (file)
@@ -26,7 +26,7 @@ void SketchPlugin_ConstraintLength::initAttributes()
   data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type());
 }
 
-void SketchPlugin_ConstraintLength::execute()
+void SketchPlugin_ConstraintLength::execute(boost::shared_ptr<ModelAPI_Result>& theResult)
 {
   if (data()->attribute(CONSTRAINT_ATTR_ENTITY_A)->isInitialized() &&
       !data()->attribute(CONSTRAINT_ATTR_VALUE)->isInitialized()) {
index 3d07ce186929081c2db4997500e57c724e5ebec2..3ad18ea20503bb2ca15be070be6be23aa3272716 100644 (file)
@@ -28,12 +28,8 @@ public:
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
   {static std::string MY_KIND = SKETCH_CONSTRAINT_LENGTH_KIND; return MY_KIND;}
 
-  /// \brief Returns to which group in the document must be added feature
-  SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
-  {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
-
   /// \brief Creates a new part document if needed
-  SKETCHPLUGIN_EXPORT virtual void execute();
+  SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr<ModelAPI_Result>& theResult);
 
   /// \brief Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
index e45980582cfeb4eee9aa8817d17dd31ef3ee4f24..45713e1240fc39e6054b40b0cde76142e8fba542 100644 (file)
@@ -25,17 +25,10 @@ void SketchPlugin_ConstraintParallel::initAttributes()
   data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT, GeomDataAPI_Point2D::type());
 }
 
-void SketchPlugin_ConstraintParallel::execute()
+void SketchPlugin_ConstraintParallel::execute(boost::shared_ptr<ModelAPI_Result>& theResult)
 {
 }
 
-const boost::shared_ptr<GeomAPI_Shape>&  SketchPlugin_ConstraintParallel::preview()
-{
-  /// \todo Preview for parallel constraint
-  return getPreview();
-}
-
-
 boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintParallel::getAISObject(
                     boost::shared_ptr<GeomAPI_AISObject> thePrevious)
 {
index 7f92e2e568c8202e24321684490b3ec965d43298..9fd42ba88686dc8cf82804102e23d09478a2c15c 100644 (file)
@@ -26,12 +26,8 @@ public:
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
   {static std::string MY_KIND = SKETCH_CONSTRAINT_PARALLEL_KIND; return MY_KIND;}
 
-  /// \brief Returns to which group in the document must be added feature
-  SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
-  {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
-
   /// \brief Creates a new part document if needed
-  SKETCHPLUGIN_EXPORT virtual void execute();
+  SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr<ModelAPI_Result>& theResult);
 
   /// \brief Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
index d4d73b0030663c7297aceef84687864f7606666b..b6b9de72a484af098cf3f455726672ea148dafe4 100644 (file)
@@ -25,16 +25,10 @@ void SketchPlugin_ConstraintPerpendicular::initAttributes()
   data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT, GeomDataAPI_Point2D::type());
 }
 
-void SketchPlugin_ConstraintPerpendicular::execute()
+void SketchPlugin_ConstraintPerpendicular::execute(boost::shared_ptr<ModelAPI_Result>& theResult)
 {
 }
 
-const boost::shared_ptr<GeomAPI_Shape>&  SketchPlugin_ConstraintPerpendicular::preview()
-{
-  /// \todo Preview for perpendicular constraint
-  return getPreview();
-}
-
 boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintPerpendicular::getAISObject(
                     boost::shared_ptr<GeomAPI_AISObject> thePrevious)
 {
index 2bb4a7b63fed77fdbed361b65d058502ce284c94..9f6956d9188f507fc51991bd0f05386337860c6b 100644 (file)
@@ -26,12 +26,8 @@ public:
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
   {static std::string MY_KIND = SKETCH_CONSTRAINT_PERPENDICULAR_KIND; return MY_KIND;}
 
-  /// \brief Returns to which group in the document must be added feature
-  SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
-  {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
-
   /// \brief Creates a new part document if needed
-  SKETCHPLUGIN_EXPORT virtual void execute();
+  SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr<ModelAPI_Result>& theResult);
 
   /// \brief Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
index 65ab125b5474f361543530bdc5dd2a79539e0ac0..ee05e7c9c443ee13f5f02a8dd2a0146ea6a1dc35 100644 (file)
@@ -30,7 +30,7 @@ void SketchPlugin_ConstraintRadius::initAttributes()
   data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT, GeomDataAPI_Point2D::type());
 }
 
-void SketchPlugin_ConstraintRadius::execute()
+void SketchPlugin_ConstraintRadius::execute(boost::shared_ptr<ModelAPI_Result>& theResult)
 {
   if (data()->attribute(CONSTRAINT_ATTR_ENTITY_A)->isInitialized() &&
       !data()->attribute(CONSTRAINT_ATTR_VALUE)->isInitialized()) {
index a2e9abad84379c431137fe3d4cbc4ebe3cdcb08d..c11757dfbc6364920957dfe2935d6dd1eb603dd6 100644 (file)
@@ -27,12 +27,8 @@ public:
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
   {static std::string MY_KIND = SKETCH_CONSTRAINT_RADIUS_KIND; return MY_KIND;}
 
-  /// \brief Returns to which group in the document must be added feature
-  SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
-  {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
-
   /// \brief Creates a new part document if needed
-  SKETCHPLUGIN_EXPORT virtual void execute();
+  SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr<ModelAPI_Result>& theResult);
 
   /// \brief Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
index 4404ea1b80cb0fa5947abf5c718c5d99037bcfaf..7195bb706614e5923c465c29737feb5935df4da4 100644 (file)
@@ -10,16 +10,6 @@ SketchPlugin_Feature::SketchPlugin_Feature()
   mySketch = 0;
 }
 
-void SketchPlugin_Feature::setPreview(const boost::shared_ptr<GeomAPI_Shape>& theShape)
-{
-  myPreview = theShape;
-}
-
-const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Feature::getPreview() const
-{
-  return myPreview;
-}
-
 SketchPlugin_Sketch* SketchPlugin_Feature::sketch()
 {
   if (!mySketch) {
@@ -27,7 +17,7 @@ SketchPlugin_Sketch* SketchPlugin_Feature::sketch()
     int aSketches = document()->size("Construction");
     for(int a = 0; a < aSketches && !mySketch; a++) {
       boost::shared_ptr<SketchPlugin_Sketch> aSketch = boost::
-        dynamic_pointer_cast<SketchPlugin_Sketch>(document()->feature("Construction", a, true));
+        dynamic_pointer_cast<SketchPlugin_Sketch>(document()->object("Construction", a));
       if (aSketch) {
         std::list<FeaturePtr > aList = 
           aSketch->data()->reflist(SKETCH_ATTR_FEATURES)->list();
@@ -47,6 +37,7 @@ SketchPlugin_Sketch* SketchPlugin_Feature::sketch()
 boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Feature::prepareAISShape(
                         boost::shared_ptr<GeomAPI_AISObject> thePrevious)
 {
+  document()->result();
   boost::shared_ptr<GeomAPI_Shape> aPreview = preview();
   boost::shared_ptr<GeomAPI_AISObject> aResult = thePrevious;
   if (!aResult)
index 1cddba03f6f54600fe7abd634387d3fc96c83fde..3d9cbf9a0a0fc9894a1e6c59bce8eecae4229638 100644 (file)
@@ -9,6 +9,7 @@
 #include <ModelAPI_Feature.h>
 #include <GeomAPI_Shape.h>
 #include <GeomAPI_AISObject.h>
+#include <ModelAPI_Document.h>
 
 class SketchPlugin_Sketch;
 class GeomAPI_Pnt2d;
@@ -22,10 +23,8 @@ class Handle_AIS_InteractiveObject;
 class SketchPlugin_Feature: public ModelAPI_Feature
 {
 public:
-  /// Returns the sketch preview
-  /// \param theSketch the owner of this feature
-  /// \return the built preview
-  SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview() = 0;
+  /// Returns the type of the feature result: it is allways construction element
+  virtual const std::string& getResultType() {return CONSTRUCTIONS_GROUP;}
 
   /// Returns the AIS preview
   SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
@@ -49,15 +48,6 @@ public:
   virtual double distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) = 0;
 
 protected:
-  /// Set the shape to the internal preview field
-  /// \param theShape a preview shape
-  void setPreview(const boost::shared_ptr<GeomAPI_Shape>& theShape); ///< the preview shape
-  /// Return the shape from the internal preview field
-  /// \return theShape a preview shape
-  const boost::shared_ptr<GeomAPI_Shape>& getPreview() const;
-  /// Common method for other features to produce AIS shape
-  boost::shared_ptr<GeomAPI_AISObject> prepareAISShape(
-                      boost::shared_ptr<GeomAPI_AISObject> thePrevious);
   /// Sets the higher-level feature for the sub-feature (sketch for line)
   void setSketch(SketchPlugin_Sketch* theSketch) {mySketch = theSketch;}
   /// Returns the sketch of this feature
index 3175ac13f0cb7277a3d33776028d43519f01ac3f..c15a8b62fa7331186fcf072d015913faf4582b28 100644 (file)
@@ -5,6 +5,7 @@
 #include "SketchPlugin_Line.h"
 #include "SketchPlugin_Sketch.h"
 #include <ModelAPI_Data.h>
+#include <ModelAPI_ResultConstruction.h>
 
 #include <GeomAPI_Pnt.h>
 #include <GeomAPI_Lin2d.h>
@@ -29,11 +30,7 @@ void SketchPlugin_Line::initAttributes()
   data()->addAttribute(LINE_ATTR_END, GeomDataAPI_Point2D::type());
 }
 
-void SketchPlugin_Line::execute() 
-{
-}
-
-const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Line::preview()
+void SketchPlugin_Line::execute(boost::shared_ptr<ModelAPI_Result>& theResult) 
 {
   SketchPlugin_Sketch* aSketch = sketch();
   if (aSketch) {
@@ -48,19 +45,12 @@ const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Line::preview()
       boost::shared_ptr<GeomAPI_Pnt> anEnd(aSketch->to3D(anEndAttr->x(), anEndAttr->y()));
       // make linear edge
       boost::shared_ptr<GeomAPI_Shape> anEdge = GeomAlgoAPI_EdgeBuilder::line(aStart, anEnd);
-      setPreview(anEdge);
+      // store the result
+      boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult)->setShape(anEdge);
     }
   }
-  return getPreview();
 }
 
-boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Line::getAISObject(
-                                boost::shared_ptr<GeomAPI_AISObject> thePrevious)
-{
-  return prepareAISShape(thePrevious);
-}
-
-
 void SketchPlugin_Line::move(double theDeltaX, double theDeltaY)
 {
   boost::shared_ptr<ModelAPI_Data> aData = data();
index f440bac1dfa0b3d6d479a159701484187897939e..af454d8c942401f9ab7afa40b6c6eda05a238751 100644 (file)
@@ -29,19 +29,12 @@ public:
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
   {static std::string MY_KIND = SKETCH_LINE_KIND; return MY_KIND;}
 
-  /// Returns to which group in the document must be added feature
-  SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
-  {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
-
   /// Creates a new part document if needed
-  SKETCHPLUGIN_EXPORT virtual void execute();
+  SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr<ModelAPI_Result>& theResult);
 
   /// Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
 
-  /// Returns the sketch preview
-  SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
-
   /// Returns the AIS preview
   SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
                                 boost::shared_ptr<GeomAPI_AISObject> thePrevious);
index 984d98919a8b6c7fc323f7350e2a3e351804080f..3a24b7a8769b44cad7751b23aead9dd8a46685fd 100644 (file)
@@ -6,6 +6,7 @@
 #include "SketchPlugin_Sketch.h"
 
 #include <ModelAPI_Data.h>
+#include <ModelAPI_ResultConstruction.h>
 
 #include <GeomAPI_Pnt2d.h>
 
@@ -23,11 +24,7 @@ void SketchPlugin_Point::initAttributes()
   data()->addAttribute(POINT_ATTR_COORD, GeomDataAPI_Point2D::type());
 }
 
-void SketchPlugin_Point::execute() 
-{
-}
-
-const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Point::preview()
+void SketchPlugin_Point::execute(boost::shared_ptr<ModelAPI_Result>& theResult) 
 {
   SketchPlugin_Sketch* aSketch = sketch();
   if (aSketch) {
@@ -37,15 +34,8 @@ const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Point::preview()
     boost::shared_ptr<GeomAPI_Pnt> aPoint3D(aSketch->to3D(aPoint->x(), aPoint->y()));
     // make a visible point
     boost::shared_ptr<GeomAPI_Shape> aPointShape = GeomAlgoAPI_PointBuilder::point(aPoint3D);
-    setPreview(aPointShape);
+    boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult)->setShape(aPointShape);
   }
-  return getPreview();
-}
-
-boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Point::getAISObject(
-                                boost::shared_ptr<GeomAPI_AISObject> thePrevious)
-{
-  return prepareAISShape(thePrevious);
 }
 
 void SketchPlugin_Point::move(double theDeltaX, double theDeltaY)
index 31fad0ea488fa7a703bb490b1a938e8d250e3f5d..ea3e125b7bbbe73b49b4848d13a23b2d525878d9 100644 (file)
@@ -27,19 +27,12 @@ public:
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
   {static std::string MY_KIND = SKETCH_POINT_KIND; return MY_KIND;}
 
-  /// Returns to which group in the document must be added feature
-  SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
-  {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
-
   /// Creates a new part document if needed
-  SKETCHPLUGIN_EXPORT virtual void execute();
+  SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr<ModelAPI_Result>& theResult);
 
   /// Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
 
-  /// Returns the sketch preview
-  SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
-
   /// Returns the AIS preview
   SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
                                 boost::shared_ptr<GeomAPI_AISObject> thePrevious);
index 7bc0ec60084671eb3367d3baf5f3986fecbec408..b451c99b061f9666c2446bff768bd2383fe8b3b5 100644 (file)
@@ -12,6 +12,7 @@
 #include <GeomAlgoAPI_FaceBuilder.h>
 #include <GeomAlgoAPI_CompoundBuilder.h>
 #include <GeomAlgoAPI_SketchBuilder.h>
+#include <ModelAPI_ResultConstruction.h>
 
 
 const int SKETCH_PLANE_COLOR = Colors::COLOR_BROWN; /// the plane edge color
@@ -35,8 +36,18 @@ void SketchPlugin_Sketch::initAttributes()
   data()->addAttribute(SKETCH_ATTR_FEATURES, ModelAPI_AttributeRefList::type());
 }
 
-void SketchPlugin_Sketch::execute() 
+void SketchPlugin_Sketch::execute(boost::shared_ptr<ModelAPI_Result>& theResult
 {
+  if (!isPlaneSet()) {
+    std::list<boost::shared_ptr<GeomAPI_Shape> > aFaces;
+
+    addPlane(1, 0, 0, aFaces); // YZ plane
+    addPlane(0, 1, 0, aFaces); // XZ plane
+    addPlane(0, 0, 1, aFaces); // XY plane
+    boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces);
+    boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult)->setShape(aCompound);
+    return;
+  }
   if (!data()->isValid())
     return ;
   boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
@@ -62,9 +73,13 @@ void SketchPlugin_Sketch::execute()
   std::list< boost::shared_ptr<GeomAPI_Shape> > aFeaturesPreview;
   for (; anIt != aLast; anIt++) {
     aFeature = boost::dynamic_pointer_cast<SketchPlugin_Feature>(*anIt);
-    boost::shared_ptr<GeomAPI_Shape> aPreview = aFeature->preview();
-    if (aPreview)
-      aFeaturesPreview.push_back(aPreview);
+    boost::shared_ptr<ModelAPI_ResultConstruction> aRes = 
+      boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(document()->result(aFeature));
+    if (aRes) {
+      boost::shared_ptr<GeomAPI_Shape> aShape = aRes->shape();
+      if (aShape)
+        aFeaturesPreview.push_back(aShape);
+    }
   }
 
   if (aFeaturesPreview.empty())
@@ -76,7 +91,7 @@ void SketchPlugin_Sketch::execute()
 
   aLoops.insert(aLoops.end(), aWires.begin(), aWires.end());
   boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aLoops);
-  data()->store(aCompound);
+  boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult)->setShape(aCompound);
 }
 
 boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Sketch::getAISObject(
@@ -89,23 +104,6 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Sketch::getAISObject(
   return anAIS;
 }
 
-const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Sketch::preview()
-{
-  if (isPlaneSet()) {
-    setPreview(boost::shared_ptr<GeomAPI_Shape>());
-  }
-  else {
-    std::list<boost::shared_ptr<GeomAPI_Shape> > aFaces;
-
-    addPlane(1, 0, 0, aFaces); // YZ plane
-    addPlane(0, 1, 0, aFaces); // XZ plane
-    addPlane(0, 0, 1, aFaces); // XY plane
-    boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces);
-    setPreview(aCompound);
-  }
-  return getPreview();
-}
-
 const void SketchPlugin_Sketch::addSub(const FeaturePtr& theFeature)
 {
   boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature)->setSketch(this);
index d88267bed29d83b43bec9b3c963ca73bfedb039e..798019b181b19afacd6855d4d71f3af0d147201e 100644 (file)
@@ -41,14 +41,11 @@ public:
   {static std::string MY_GROUP = "Construction"; return MY_GROUP;}
 
   /// Creates a new part document if needed
-  SKETCHPLUGIN_EXPORT virtual void execute();
+  SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr<ModelAPI_Result>& theResult);
 
   /// Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
 
-  /// Returns the sketch preview
-  SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
-
   /// Returns the AIS preview
   SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
                                 boost::shared_ptr<GeomAPI_AISObject> thePrevious);
index 2f7931f9b59c87b53491a52b3ad251fab1737ffb..29d21da0a7f25c411c3ef5640e7d725bbc947453 100644 (file)
@@ -1147,7 +1147,7 @@ void SketchSolver_ConstraintGroup::updateRelatedConstraints(
 
       if (isUpd)
       {
-        static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
+        static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
         ModelAPI_EventCreator::get()->sendUpdated(aConstrIter->first, anEvent);
         break;
       }
@@ -1173,7 +1173,7 @@ void SketchSolver_ConstraintGroup::updateRelatedConstraints(
         boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttrIter);
       if (aRefAttr && aRefAttr->isFeature() && aRefAttr->feature() == theFeature)
       {
-        static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
+        static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
         ModelAPI_EventCreator::get()->sendUpdated(aConstrIter->first, anEvent);
         break;
       }
index ff571878b964b567331ea2949d5efdb6fe9c38fd..985688043d769f986fb747334a829574ce0bc866 100644 (file)
@@ -41,10 +41,10 @@ SketchSolver_ConstraintManager::SketchSolver_ConstraintManager()
   myGroups.clear();
 
   // Register in event loop
-  Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_CREATED));
-  Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
-  Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_DELETED));
-  Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_MOVED));
+  Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
+  Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+  Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED));
+  Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_MOVED));
 }
 
 SketchSolver_ConstraintManager::~SketchSolver_ConstraintManager()
@@ -59,16 +59,16 @@ SketchSolver_ConstraintManager::~SketchSolver_ConstraintManager()
 // ============================================================================
 void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessage)
 {
-  if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_CREATED) ||
-      theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_UPDATED) || 
-      theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_MOVED))
+  if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED) ||
+      theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED) || 
+      theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED))
   {
-    const ModelAPI_FeatureUpdatedMessage* anUpdateMsg = 
-      dynamic_cast<const ModelAPI_FeatureUpdatedMessage*>(theMessage);
+    const ModelAPI_ObjectUpdatedMessage* anUpdateMsg = 
+      dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
     std::set< FeaturePtr > aFeatures = anUpdateMsg->features();
 
     bool isModifiedEvt = 
-      theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_MOVED);
+      theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED);
     if (!isModifiedEvt)
     {
       std::set< FeaturePtr >::iterator aFeatIter;
@@ -102,7 +102,7 @@ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessa
     // Solve the set of constraints
     resolveConstraints();
   }
-  else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_DELETED))
+  else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED))
   {
     const ModelAPI_FeatureDeletedMessage* aDeleteMsg = 
       dynamic_cast<const ModelAPI_FeatureDeletedMessage*>(theMessage);
@@ -374,6 +374,6 @@ void SketchSolver_ConstraintManager::resolveConstraints()
     (*aGroupIter)->resolveConstraints();
 
   // Features may be updated => send events
-  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
+  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
 }
 
index b4cc62c0c9f4d5f8bc6a6fba6cd41dffd6301903..7857bd7a41724ba2985fd82db59a256268687030 100644 (file)
@@ -26,9 +26,9 @@ XGUI_DocumentDataModel::XGUI_DocumentDataModel(QObject* theParent)
   : QAbstractItemModel(theParent), myActivePart(0)
 {
   // Register in event loop
-  Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_CREATED));
-  Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
-  Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_DELETED));
+  Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
+  Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+  Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED));
 
   // Create a top part of data tree model
   myModel = new XGUI_TopDataModel(this);
@@ -47,7 +47,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
   DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
 
   // Created object event *******************
-  if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_CREATED)) {
+  if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
     const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
     std::set<FeaturePtr> aFeatures = aUpdMsg->features();
 
@@ -87,7 +87,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
       }
     }
   // Deleted object event ***********************
-  } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_DELETED)) {
+  } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
     const Model_FeatureDeletedMessage* aUpdMsg = dynamic_cast<const Model_FeatureDeletedMessage*>(theMessage);
     DocumentPtr aDoc = aUpdMsg->document();
     std::set<std::string> aGroups = aUpdMsg->groups();
@@ -129,7 +129,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
       }
     }
   // Deleted object event ***********************
-  } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_UPDATED)) {
+  } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {
     //const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
     //FeaturePtr aFeature = aUpdMsg->feature();
     //DocumentPtr aDoc = aFeature->document();
index b5b0b5f6baeeb50b95d9cd621859c12dd4d9cfdf..d480ef3489ddd925705ad5d8b2d5da9a2195378d 100644 (file)
@@ -129,8 +129,8 @@ void XGUI_Workshop::startApplication()
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_LOADED));
   // TODO Is it good to use non standard event within workshop?
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED));
-  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
-  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_CREATED));
+  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_TO_REDISPLAY));
 
   activateModule();
@@ -229,7 +229,7 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage)
   }
 
   // Process creation of Part
-  if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_CREATED)) {
+  if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
     const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
     onFeatureCreatedMsg(aUpdMsg);
   }
@@ -242,7 +242,7 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage)
 
   //Update property panel on corresponding message. If there is no current operation (no
   //property panel), or received message has different feature to the current - do nothing.
-  if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_UPDATED)) {
+  if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {
     const Model_FeatureUpdatedMessage* anUpdateMsg =
         dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
     onFeatureUpdatedMsg(anUpdateMsg);