]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' of newgeom:newgeom.git
authorsbh <sergey.belash@opencascade.com>
Tue, 15 Jul 2014 13:17:22 +0000 (17:17 +0400)
committersbh <sergey.belash@opencascade.com>
Tue, 15 Jul 2014 13:17:22 +0000 (17:17 +0400)
Conflicts:
src/Model/Model_Document.cpp
src/Model/Model_Object.h
src/Model/Model_Update.cpp
src/ModelAPI/ModelAPI_Document.h
src/PartSet/PartSet_Listener.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_TestOCC.cpp
src/PartSetPlugin/PartSetPlugin_Duplicate.cpp
src/PartSetPlugin/PartSetPlugin_Remove.cpp
src/SketchPlugin/SketchPlugin_Arc.h
src/SketchPlugin/SketchPlugin_Circle.h
src/SketchPlugin/SketchPlugin_Constraint.h
src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h
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_Line.h
src/SketchPlugin/SketchPlugin_Point.h
src/SketchSolver/SketchSolver_Constraint.cpp
src/SketchSolver/SketchSolver_ConstraintGroup.cpp
src/SketchSolver/SketchSolver_ConstraintManager.cpp
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_DocumentDataModel.cpp
src/XGUI/XGUI_PartDataModel.cpp
src/XGUI/XGUI_Workshop.cpp

134 files changed:
src/ConstructionPlugin/ConstructionPlugin_Point.cpp
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/FeaturesPlugin/FeaturesPlugin_Extrusion.h
src/Model/CMakeLists.txt
src/Model/Model_AttributeRefAttr.cpp
src/Model/Model_AttributeRefAttr.h
src/Model/Model_AttributeRefList.cpp
src/Model/Model_AttributeRefList.h
src/Model/Model_AttributeReference.cpp
src/Model/Model_AttributeReference.h
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.i
src/ModelAPI/ModelAPI_Attribute.h
src/ModelAPI/ModelAPI_AttributeRefAttr.h
src/ModelAPI/ModelAPI_AttributeRefList.h
src/ModelAPI/ModelAPI_AttributeReference.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_ResultParameters.h [new file with mode: 0644]
src/ModelAPI/ModelAPI_ResultPart.h [new file with mode: 0644]
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_Definitions.h
src/ModuleBase/ModuleBase_ISelection.h
src/ModuleBase/ModuleBase_IWorkshop.h
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_Tools.cpp [new file with mode: 0644]
src/ModuleBase/ModuleBase_Tools.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_ViewerPrs.h
src/ModuleBase/ModuleBase_WidgetBoolValue.cpp
src/ModuleBase/ModuleBase_WidgetBoolValue.h
src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp
src/ModuleBase/ModuleBase_WidgetDoubleValue.h
src/ModuleBase/ModuleBase_WidgetFeature.cpp
src/ModuleBase/ModuleBase_WidgetFeature.h
src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp
src/ModuleBase/ModuleBase_WidgetPoint2D.cpp
src/ModuleBase/ModuleBase_WidgetPoint2D.h
src/ModuleBase/ModuleBase_WidgetPoint2dDistance.cpp
src/ModuleBase/ModuleBase_WidgetSelector.cpp
src/ModuleBase/ModuleBase_WidgetSelector.h
src/ModuleBase/ModuleBase_WidgetValueFeature.cpp
src/ModuleBase/ModuleBase_WidgetValueFeature.h
src/PartSet/PartSet_Listener.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationFeatureCreate.cpp
src/PartSet/PartSet_OperationFeatureEdit.cpp
src/PartSet/PartSet_OperationFeatureEditMulti.cpp
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketchBase.cpp
src/PartSet/PartSet_TestOCC.cpp
src/PartSet/PartSet_Tools.cpp
src/PartSet/PartSet_Validators.cpp
src/PartSet/PartSet_Validators.h
src/PartSet/PartSet_WidgetSketchLabel.h
src/PartSetPlugin/PartSetPlugin_Duplicate.cpp
src/PartSetPlugin/PartSetPlugin_Part.cpp
src/PartSetPlugin/PartSetPlugin_Remove.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.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/SketchPlugin/plugin-Sketch.xml
src/SketchSolver/SketchSolver_Constraint.cpp
src/SketchSolver/SketchSolver_ConstraintGroup.cpp
src/SketchSolver/SketchSolver_ConstraintManager.cpp
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_DataTreeModel.h
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_DocumentDataModel.cpp
src/XGUI/XGUI_DocumentDataModel.h
src/XGUI/XGUI_ModuleConnector.cpp
src/XGUI/XGUI_ModuleConnector.h
src/XGUI/XGUI_ObjectsBrowser.cpp
src/XGUI/XGUI_ObjectsBrowser.h
src/XGUI/XGUI_PartDataModel.cpp
src/XGUI/XGUI_PartDataModel.h
src/XGUI/XGUI_Selection.cpp
src/XGUI/XGUI_Selection.h
src/XGUI/XGUI_SelectionMgr.cpp
src/XGUI/XGUI_SelectionMgr.h
src/XGUI/XGUI_Tools.cpp
src/XGUI/XGUI_Tools.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h
src/XGUI/XGUI_pictures.qrc
src/XGUI/pictures/constr_object.png [new file with mode: 0644]

index aaa697dd5684f8c58d26b222f5e798a932ce3357..1838d32d9ca42c1d37710e445d4eabdf2cf18956 100644 (file)
@@ -7,6 +7,7 @@
 #include "ModelAPI_Document.h"
 #include "ModelAPI_Data.h"
 #include "ModelAPI_AttributeDouble.h"
+#include <ModelAPI_ResultConstruction.h>
 #include <GeomAlgoAPI_PointBuilder.h>
 #include <GeomAPI_Pnt.h>
 
@@ -28,5 +29,7 @@ void ConstructionPlugin_Point::execute()
   boost::shared_ptr<GeomAPI_Pnt> aPnt(new GeomAPI_Pnt(
     data()->real(POINT_ATTR_X)->value(), data()->real(POINT_ATTR_Y)->value(), data()->real(POINT_ATTR_Z)->value()));
 
-  data()->store(GeomAlgoAPI_PointBuilder::point(aPnt));
+  boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction(data());
+  aConstr->setShape(GeomAlgoAPI_PointBuilder::point(aPnt));
+  setResult(aConstr);
 }
index 0e8fc0b13b19950298c51601d272d41ae547b4e3..b232f18e7bd732b7f9d0fa8307654beb1b12e3c6 100644 (file)
@@ -6,6 +6,8 @@
 #include <ModelAPI_PluginManager.h>
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Data.h>
+#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_ResultBody.h>
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeReference.h>
 #include <ModelAPI_AttributeBoolean.h>
@@ -31,15 +33,18 @@ void FeaturesPlugin_Extrusion::execute()
     boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(data()->attribute(FeaturesPlugin_Extrusion::FACE_ID()));
   if (!aFaceRef)
     return;
-  FeaturePtr aFaceFeature = aFaceRef->value();
-  if (!aFaceFeature)
+  boost::shared_ptr<ModelAPI_ResultConstruction> aConstr =
+    boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aFaceRef->value());
+  if (!aConstr) 
     return;
-  boost::shared_ptr<GeomAPI_Shape> aFace = aFaceFeature->data()->shape();
+  boost::shared_ptr<GeomAPI_Shape> aFace = aConstr->shape();
   if (!aFace)
     return;
 
   double aSize = data()->real(FeaturesPlugin_Extrusion::SIZE_ID())->value();
   if (data()->boolean(FeaturesPlugin_Extrusion::REVERSE_ID())->value())
     aSize = -aSize;
-  data()->store(GeomAlgoAPI_Extrusion::makeExtrusion(aFace, aSize));
+  boost::shared_ptr<ModelAPI_ResultBody> aResult = document()->createBody(data());
+  aResult->store(GeomAlgoAPI_Extrusion::makeExtrusion(aFace, aSize));
+  setResult(aResult);
 }
index cac857f15052ab652ee56ec593453286fca8519f..c83bead92edebeb6d6bcdcbbdbb03ea4f46c31a5 100644 (file)
@@ -40,10 +40,6 @@ public:
   FEATURESPLUGIN_EXPORT virtual const std::string& getKind() 
   { static std::string MY_KIND = FeaturesPlugin_Extrusion::ID(); return MY_KIND; }
 
-  /// Returns to which group in the document must be added feature
-  FEATURESPLUGIN_EXPORT virtual const std::string& getGroup() 
-  { static std::string MY_GROUP = "Construction";  return MY_GROUP; }
-
   /// Creates a new part document if needed
   FEATURESPLUGIN_EXPORT virtual void execute();
 
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 24bcddec1a7e63378c7ed4e5fd3f24462f323295..77a89ba40868cb6ce030610e3c438b79f9e80ef0 100644 (file)
@@ -9,7 +9,7 @@
 
 using namespace std;
 
-bool Model_AttributeRefAttr::isFeature()
+bool Model_AttributeRefAttr::isObject()
 {
   return myID->Get().Length() == 0;
 }
@@ -19,7 +19,7 @@ void Model_AttributeRefAttr::setAttr(boost::shared_ptr<ModelAPI_Attribute> theAt
   boost::shared_ptr<Model_Data> aData = 
     boost::dynamic_pointer_cast<Model_Data>(theAttr->owner()->data());
   string anID = aData->id(theAttr);
-  if (myIsInitialized && feature() == theAttr->owner() && myID->Get().IsEqual(anID.c_str()))
+  if (myIsInitialized && object() == theAttr->owner() && myID->Get().IsEqual(anID.c_str()))
     return; // nothing is changed
 
   myRef->Set(aData->label());
@@ -29,40 +29,40 @@ void Model_AttributeRefAttr::setAttr(boost::shared_ptr<ModelAPI_Attribute> theAt
 
 boost::shared_ptr<ModelAPI_Attribute> Model_AttributeRefAttr::attr()
 {
-  FeaturePtr aFeature = feature();
-  if (aFeature) {
+  ObjectPtr anObj = object();
+  if (anObj) {
     boost::shared_ptr<Model_Data> aData = 
-      boost::dynamic_pointer_cast<Model_Data>(aFeature->data());
+      boost::dynamic_pointer_cast<Model_Data>(anObj->data());
     return aData->attribute(TCollection_AsciiString(myID->Get()).ToCString());
   }
   // not initialized
   return boost::shared_ptr<ModelAPI_Attribute>();
 }
 
-void Model_AttributeRefAttr::setFeature(FeaturePtr theFeature)
+void Model_AttributeRefAttr::setObject(ObjectPtr theObject)
 {
-  if (!myIsInitialized || myID->Get().Length() != 0 || feature() != theFeature) {
+  if (!myIsInitialized || myID->Get().Length() != 0 || object() != theObject) {
     boost::shared_ptr<Model_Data> aData = 
-      boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
+      boost::dynamic_pointer_cast<Model_Data>(theObject->data());
     myRef->Set(aData->label());
     myID->Set(""); // feature is identified by the empty ID
     owner()->data()->sendAttributeUpdated(this);
   }
 }
 
-FeaturePtr Model_AttributeRefAttr::feature()
+ObjectPtr Model_AttributeRefAttr::object()
 {
   if (myRef->Get() != myRef->Label()) { // initialized
     boost::shared_ptr<Model_Document> aDoc = 
       boost::dynamic_pointer_cast<Model_Document>(owner()->document());
     if (aDoc) {
       TDF_Label aRefLab = myRef->Get();
-      TDF_Label aFeatureLab = aRefLab.Father();
-      return aDoc->feature(aRefLab);
+      TDF_Label anObjLab = aRefLab.Father();
+      return aDoc->object(aRefLab);
     }
   }
   // not initialized
-  return FeaturePtr();
+  return ObjectPtr();
 }
 
 Model_AttributeRefAttr::Model_AttributeRefAttr(TDF_Label& theLabel)
index 69fda0163632dd7a0d858fd7c04c706d73ef4e0d..273cfd544102c0c5e183668e578d2d9914727c78 100644 (file)
@@ -23,8 +23,8 @@ class Model_AttributeRefAttr : public ModelAPI_AttributeRefAttr
    ///< ID of the referenced attirbute (empty if this is a reference to a feature)
   Handle_TDataStd_Comment myID;
 public:
-  /// Returns true if this attribute references to a feature (not to the attribute)
-  MODEL_EXPORT virtual bool isFeature();
+  /// Returns true if this attribute references to a object (not to the attribute)
+  MODEL_EXPORT virtual bool isObject();
 
   /// Defines the reference to the attribute
   MODEL_EXPORT virtual void setAttr(boost::shared_ptr<ModelAPI_Attribute> theAttr);
@@ -32,11 +32,11 @@ public:
   /// Returns attribute referenced from this attribute
   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Attribute> attr();
 
-  /// Defines the reference to the feature
-  MODEL_EXPORT virtual void setFeature(FeaturePtr theFeature);
+  /// Defines the reference to the object
+  MODEL_EXPORT virtual void setObject(ObjectPtr theFeature);
 
-  /// Returns feature referenced from this attribute
-  MODEL_EXPORT virtual FeaturePtr feature();
+  /// Returns object referenced from this attribute
+  MODEL_EXPORT virtual ObjectPtr object();
 
 protected:
   /// Objects are created for features automatically
index cc19ba6cafa5083d5ac6880d4a65db925b1d95e1..0a6eee7c45cb9b66de20009239fc98ccb6eba55a 100644 (file)
 
 using namespace std;
 
-void Model_AttributeRefList::append(FeaturePtr theFeature)
+void Model_AttributeRefList::append(ObjectPtr theObject)
 {
   boost::shared_ptr<Model_Data> aData = 
-    boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
+    boost::dynamic_pointer_cast<Model_Data>(theObject->data());
   myRef->Append(aData->label());
 
   owner()->data()->sendAttributeUpdated(this);
 }
 
-void Model_AttributeRefList::remove(FeaturePtr theFeature)
+void Model_AttributeRefList::remove(ObjectPtr theObject)
 {
   boost::shared_ptr<Model_Data> aData = 
-    boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
+    boost::dynamic_pointer_cast<Model_Data>(theObject->data());
   myRef->Remove(aData->label());
 
   owner()->data()->sendAttributeUpdated(this);
@@ -33,15 +33,15 @@ int Model_AttributeRefList::size()
   return myRef->Extent();
 }
 
-list<FeaturePtr> Model_AttributeRefList::list()
+list<ObjectPtr> Model_AttributeRefList::list()
 {
-  std::list< FeaturePtr > aResult;
+  std::list< ObjectPtr > aResult;
   boost::shared_ptr<Model_Document> aDoc = 
     boost::dynamic_pointer_cast<Model_Document>(owner()->document());
   if (aDoc) {
     const TDF_LabelList& aList = myRef->List();
     for(TDF_ListIteratorOfLabelList aLIter(aList); aLIter.More(); aLIter.Next()) {
-      aResult.push_back(aDoc->feature(aLIter.Value()));
+      aResult.push_back(aDoc->object(aLIter.Value()));
     }
   }
   return aResult;
index 340f5cdf011ad037338248b3a19731b25a8bf46c..7f797e2dec4d6ecbf221869c8a4691f4a9e3d5d0 100644 (file)
@@ -21,16 +21,16 @@ class Model_AttributeRefList : public ModelAPI_AttributeRefList
   Handle_TDataStd_ReferenceList myRef; ///< references to the features labels
 public:
   /// Appends the feature to the end of a list
-  MODEL_EXPORT virtual void append(FeaturePtr theFeature);
+  MODEL_EXPORT virtual void append(ObjectPtr theObject);
 
   /// Erases the first meet of the feature in the list
-  MODEL_EXPORT virtual void remove(FeaturePtr theFeature);
+  MODEL_EXPORT virtual void remove(ObjectPtr theObject);
 
   /// Returns number of features in the list
   MODEL_EXPORT virtual int size();
 
   /// Returns the list of features
-  MODEL_EXPORT virtual std::list<FeaturePtr > list();
+  MODEL_EXPORT virtual std::list<ObjectPtr > list();
 
 protected:
   /// Objects are created for features automatically
index e2ff01ce7798975aa6e11d829c86281f6bfc99f5..9cfd4a91c3ef72ee3df11bdd76f6deadcb5e650f 100644 (file)
 
 using namespace std;
 
-void Model_AttributeReference::setValue(FeaturePtr theFeature)
+void Model_AttributeReference::setValue(ObjectPtr theObject)
 {
-  if (!myIsInitialized || value() != theFeature) {
+  if (!myIsInitialized || value() != theObject) {
     boost::shared_ptr<Model_Data> aData = 
-      boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
+      boost::dynamic_pointer_cast<Model_Data>(theObject->data());
     if (myRef.IsNull()) {
       boost::shared_ptr<Model_Data> aMyData = 
         boost::dynamic_pointer_cast<Model_Data>(owner()->data());
@@ -26,14 +26,14 @@ void Model_AttributeReference::setValue(FeaturePtr theFeature)
   }
 }
 
-FeaturePtr Model_AttributeReference::value()
+ObjectPtr Model_AttributeReference::value()
 {
   if (!myRef.IsNull()) {
     boost::shared_ptr<Model_Document> aDoc = 
       boost::dynamic_pointer_cast<Model_Document>(owner()->document());
     if (aDoc) {
       TDF_Label aRefLab = myRef->Get();
-      return aDoc->feature(aRefLab);
+      return aDoc->object(aRefLab);
     }
   }
   // not initialized
index 6406d0bfbfbf0fd8b828ab4fc0dca034c39423ec..82222550043618c949308fa5ddadb9c9568a3263 100644 (file)
@@ -20,11 +20,11 @@ class Model_AttributeReference : public ModelAPI_AttributeReference
 {
   Handle_TDF_Reference myRef; ///< references to the feature label
 public:
-  /// Defines the feature referenced from this attribute
-  MODEL_EXPORT virtual void setValue(FeaturePtr theFeature);
+  /// Defines the object referenced from this attribute
+  MODEL_EXPORT virtual void setValue(ObjectPtr theObject);
 
-  /// Returns feature referenced from this attribute
-  MODEL_EXPORT virtual FeaturePtr value();
+  /// Returns object referenced from this attribute
+  MODEL_EXPORT virtual ObjectPtr value();
 
 protected:
   /// Objects are created for features automatically
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 1c70153892a95e891c58a31590a38bc7f4556d7c..df5c06b23c880db1f6284de52ab2f5b87b783f9b 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)
 
-using namespace std;
+// 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
 
 /// Returns the file name of this document by the nameof directory and identifuer of a document
-static TCollection_ExtendedString DocFileName(const char* theFileName, const string& theID)
+static TCollection_ExtendedString DocFileName(const char* theFileName, const std::string& theID)
 {
   TCollection_ExtendedString aPath ((const Standard_CString)theFileName);
   aPath += _separator_;
@@ -63,7 +67,7 @@ bool Model_Document::load(const char* theFileName)
   catch (Standard_Failure)
   {
     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    Events_Error::send(string("Exception in opening of document: ") + aFail->GetMessageString());
+    Events_Error::send(std::string("Exception in opening of document: ") + aFail->GetMessageString());
     return false;
   }
   bool isError = aStatus != PCDM_RS_OK;
@@ -72,37 +76,41 @@ bool Model_Document::load(const char* theFileName)
     switch (aStatus)
     {
     case PCDM_RS_UnknownDocument: 
-      Events_Error::send(string("Can not open document: PCDM_RS_UnknownDocument")); break;
+      Events_Error::send(std::string("Can not open document: PCDM_RS_UnknownDocument")); break;
     case PCDM_RS_AlreadyRetrieved: 
-      Events_Error::send(string("Can not open document: PCDM_RS_AlreadyRetrieved")); break;
+      Events_Error::send(std::string("Can not open document: PCDM_RS_AlreadyRetrieved")); break;
     case PCDM_RS_AlreadyRetrievedAndModified:
-      Events_Error::send(string("Can not open document: PCDM_RS_AlreadyRetrievedAndModified")); break;
+      Events_Error::send(
+        std::string("Can not open document: PCDM_RS_AlreadyRetrievedAndModified"));
+      break;
     case PCDM_RS_NoDriver:
-      Events_Error::send(string("Can not open document: PCDM_RS_NoDriver")); break;
+      Events_Error::send(std::string("Can not open document: PCDM_RS_NoDriver")); break;
     case PCDM_RS_UnknownFileDriver:
-      Events_Error::send(string("Can not open document: PCDM_RS_UnknownFileDriver")); break;
+      Events_Error::send(std::string("Can not open document: PCDM_RS_UnknownFileDriver")); break;
     case PCDM_RS_OpenError:
-      Events_Error::send(string("Can not open document: PCDM_RS_OpenError")); break;
+      Events_Error::send(std::string("Can not open document: PCDM_RS_OpenError")); break;
     case PCDM_RS_NoVersion:
-      Events_Error::send(string("Can not open document: PCDM_RS_NoVersion")); break;
+      Events_Error::send(std::string("Can not open document: PCDM_RS_NoVersion")); break;
     case PCDM_RS_NoModel:
-      Events_Error::send(string("Can not open document: PCDM_RS_NoModel")); break;
+      Events_Error::send(std::string("Can not open document: PCDM_RS_NoModel")); break;
     case PCDM_RS_NoDocument:
-      Events_Error::send(string("Can not open document: PCDM_RS_NoDocument")); break;
+      Events_Error::send(std::string("Can not open document: PCDM_RS_NoDocument")); break;
     case PCDM_RS_FormatFailure:
-      Events_Error::send(string("Can not open document: PCDM_RS_FormatFailure")); break;
+      Events_Error::send(std::string("Can not open document: PCDM_RS_FormatFailure")); break;
     case PCDM_RS_TypeNotFoundInSchema:
-      Events_Error::send(string("Can not open document: PCDM_RS_TypeNotFoundInSchema")); break;
+      Events_Error::send(std::string("Can not open document: PCDM_RS_TypeNotFoundInSchema")); 
+      break;
     case PCDM_RS_UnrecognizedFileFormat:
-      Events_Error::send(string("Can not open document: PCDM_RS_UnrecognizedFileFormat")); break;
+      Events_Error::send(std::string("Can not open document: PCDM_RS_UnrecognizedFileFormat")); 
+      break;
     case PCDM_RS_MakeFailure:
-      Events_Error::send(string("Can not open document: PCDM_RS_MakeFailure")); break;
+      Events_Error::send(std::string("Can not open document: PCDM_RS_MakeFailure")); break;
     case PCDM_RS_PermissionDenied:
-      Events_Error::send(string("Can not open document: PCDM_RS_PermissionDenied")); break;
+      Events_Error::send(std::string("Can not open document: PCDM_RS_PermissionDenied")); break;
     case PCDM_RS_DriverFailure:
-      Events_Error::send(string("Can not open document: PCDM_RS_DriverFailure")); break;
+      Events_Error::send(std::string("Can not open document: PCDM_RS_DriverFailure")); break;
     default:
-      Events_Error::send(string("Can not open document: unknown error")); break;
+      Events_Error::send(std::string("Can not open document: unknown error")); break;
     }
   }
   if (!isError) {
@@ -130,7 +138,7 @@ bool Model_Document::save(const char* theFileName)
   }
   catch (Standard_Failure) {
     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    Events_Error::send(string("Exception in saving of document: ") + aFail->GetMessageString());
+    Events_Error::send(std::string("Exception in saving of document: ") + aFail->GetMessageString());
     return false;
   }
   bool isDone = aStatus == PCDM_SS_OK || aStatus == PCDM_SS_No_Obj;
@@ -139,20 +147,20 @@ bool Model_Document::save(const char* theFileName)
     switch (aStatus)
     {
     case PCDM_SS_DriverFailure:
-      Events_Error::send(string("Can not save document: PCDM_SS_DriverFailure"));
+      Events_Error::send(std::string("Can not save document: PCDM_SS_DriverFailure"));
       break;
     case PCDM_SS_WriteFailure:
-      Events_Error::send(string("Can not save document: PCDM_SS_WriteFailure"));
+      Events_Error::send(std::string("Can not save document: PCDM_SS_WriteFailure"));
       break;
     case PCDM_SS_Failure:
     default:
-      Events_Error::send(string("Can not save document: PCDM_SS_Failure"));
+      Events_Error::send(std::string("Can not save document: PCDM_SS_Failure"));
       break;
     }
   }
   myTransactionsAfterSave = 0;
   if (isDone) { // save also sub-documents if any
-    set<string>::iterator aSubIter = mySubs.begin();
+    std::set<std::string>::iterator aSubIter = mySubs.begin();
     for(; aSubIter != mySubs.end() && isDone; aSubIter++)
       isDone = subDocument(*aSubIter)->save(theFileName);
   }
@@ -167,7 +175,7 @@ void Model_Document::close()
     aPM->setCurrentDocument(aPM->rootDocument());
   }
   // close all subs
-  set<string>::iterator aSubIter = mySubs.begin();
+  std::set<std::string>::iterator aSubIter = mySubs.begin();
   for(; aSubIter != mySubs.end(); aSubIter++)
     subDocument(*aSubIter)->close();
   mySubs.clear();
@@ -193,7 +201,7 @@ void Model_Document::startOperation()
     myDoc->NewCommand();
   }
   // new command for all subs
-  set<string>::iterator aSubIter = mySubs.begin();
+  std::set<std::string>::iterator aSubIter = mySubs.begin();
   for(; aSubIter != mySubs.end(); aSubIter++)
     subDocument(*aSubIter)->startOperation();
 }
@@ -212,9 +220,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++;
@@ -230,7 +238,7 @@ void Model_Document::finishOperation()
   }
 
   // finish for all subs
-  set<string>::iterator aSubIter = mySubs.begin();
+  std::set<std::string>::iterator aSubIter = mySubs.begin();
   for(; aSubIter != mySubs.end(); aSubIter++)
     subDocument(*aSubIter)->finishOperation();
 }
@@ -252,7 +260,7 @@ void Model_Document::abortOperation()
   }
   synchronizeFeatures(true);
   // abort for all subs
-  set<string>::iterator aSubIter = mySubs.begin();
+  std::set<std::string>::iterator aSubIter = mySubs.begin();
     for(; aSubIter != mySubs.end(); aSubIter++)
     subDocument(*aSubIter)->abortOperation();
 }
@@ -274,7 +282,7 @@ bool Model_Document::canUndo()
   if (myDoc->GetAvailableUndos() > 0 && myNestedNum != 0 && myTransactionsAfterSave != 0 /* for omitting the first useless transaction */)
     return true;
   // check other subs contains operation that can be undoed
-  set<string>::iterator aSubIter = mySubs.begin();
+  std::set<std::string>::iterator aSubIter = mySubs.begin();
   for(; aSubIter != mySubs.end(); aSubIter++)
     if (subDocument(*aSubIter)->canUndo())
       return true;
@@ -289,7 +297,7 @@ void Model_Document::undo()
     myDoc->Undo();
   synchronizeFeatures(true);
   // undo for all subs
-  set<string>::iterator aSubIter = mySubs.begin();
+  std::set<std::string>::iterator aSubIter = mySubs.begin();
   for(; aSubIter != mySubs.end(); aSubIter++)
     subDocument(*aSubIter)->undo();
 }
@@ -299,7 +307,7 @@ bool Model_Document::canRedo()
   if (myDoc->GetAvailableRedos() > 0)
     return true;
   // check other subs contains operation that can be redoed
-  set<string>::iterator aSubIter = mySubs.begin();
+  std::set<std::string>::iterator aSubIter = mySubs.begin();
   for(; aSubIter != mySubs.end(); aSubIter++)
     if (subDocument(*aSubIter)->canRedo())
       return true;
@@ -314,23 +322,11 @@ void Model_Document::redo()
   myTransactionsAfterSave++;
   synchronizeFeatures(true);
   // redo for all subs
-  set<string>::iterator aSubIter = mySubs.begin();
+  std::set<std::string>::iterator aSubIter = mySubs.begin();
   for(; aSubIter != mySubs.end(); aSubIter++)
     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 +344,33 @@ static void AddToRefArray(TDF_Label& theArrayLab, TDF_Label& theReferenced) {
   }
 }
 
-void Model_Document::addFeature(const FeaturePtr theFeature)
+FeaturePtr Model_Document::addFeature(std::string theID)
 {
-  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(ModelAPI_Document::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);
+  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(ModelAPI_Feature::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());
+      setUniqueName(aFeature);
+      myObjs[ModelAPI_Feature::group()].push_back(aFeature);
+      // store feature in the history of features array
+      if (aFeature->isInHistory()) {
+        AddToRefArray(aFeaturesLab, aFeatureLab);
+      }
+    }
+    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;
 }
 
 /// Appenad to the array of references a new referenced label.
@@ -423,43 +407,73 @@ 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[ModelAPI_Feature::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
   aFeatureLabel.ForgetAllAttributes();
   // remove it from the references array
-  RemoveFromRefArray(groupLabel(ModelAPI_Document::FEATURES_GROUP()), aData->label());
+  RemoveFromRefArray(groupLabel(ModelAPI_Feature::group()), aData->label());
+
+  // event: feature is deleted
+  ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), ModelAPI_Feature::group());
+}
 
-  // event: feature is added
-  ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), theFeature->getGroup());
+/// returns the object group name by the object label
+static std::string groupName(TDF_Label theObjectLabel) {
+  TDF_Label aGroupLab = theObjectLabel.Father();
+  Handle(TDataStd_Comment) aComment;
+  if (aGroupLab.FindAttribute(TDataStd_Comment::GetID(), aComment))
+    return std::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[ModelAPI_Feature::group()];
+  std::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 boost::dynamic_pointer_cast<ModelAPI_Feature>(*aFIter);
+  }
+  return FeaturePtr(); // not found
+}
+
+ObjectPtr Model_Document::object(TDF_Label& theLabel)
+{
+  // iterate all features, may be optimized later by keeping labels-map
+  std::vector<ObjectPtr>& aVec = myObjs[ModelAPI_Feature::group()];
+  std::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;
+    std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = 
+      boost::dynamic_pointer_cast<ModelAPI_Feature>(*aFIter)->results();
+    std::list<boost::shared_ptr<ModelAPI_Result> >::iterator aRIter = aResults.begin();
+    for(; aRIter != aResults.end(); aRIter++) {
+      boost::shared_ptr<Model_Data> aResData = 
+        boost::dynamic_pointer_cast<Model_Data>((*aRIter)->data());
+      if (aResData->label().IsEqual(theLabel))
+        return *aRIter;
+    }
   }
   return FeaturePtr(); // not found
 }
 
-boost::shared_ptr<ModelAPI_Document> Model_Document::subDocument(string theDocID)
+boost::shared_ptr<ModelAPI_Document> Model_Document::subDocument(std::string theDocID)
 {
   // just store sub-document identifier here to manage it later
   if (mySubs.find(theDocID) == mySubs.end())
@@ -467,39 +481,67 @@ 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 std::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 == ModelAPI_Document::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 == ModelAPI_Feature::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(ModelAPI_Feature::group());
+    if (aFind != myObjs.end()) {
+      std::vector<ObjectPtr>::iterator aFIter = aFind->second.begin();
+      for(int anIndex = 0; aFIter != aFind->second.end(); aFIter++) {
+        const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = 
+          boost::dynamic_pointer_cast<ModelAPI_Feature>(*aFIter)->results();
+        std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
+        for(; aRIter != aResults.cend(); aRIter++) {
+          if ((*aRIter)->isInHistory() && (*aRIter)->groupName() == theGroupID) {
+            if (anIndex == theIndex)
+              return *aRIter;
+            anIndex++;
+          }
+        }
       }
     }
   }
-
   // not found
-  return FeaturePtr();
+  return ObjectPtr();
 }
 
-int Model_Document::size(const string& theGroupID) 
+int Model_Document::size(const std::string& theGroupID) 
 {
-  Handle(TDataStd_ReferenceArray) aRefs;
-  if (groupLabel(theGroupID).FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs))
-    return aRefs->Length();
+  int aResult = 0;
+  if (theGroupID == ModelAPI_Feature::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(ModelAPI_Feature::group());
+    if (aFind != myObjs.end()) {
+      std::vector<ObjectPtr>::iterator aFIter = aFind->second.begin();
+      for(; aFIter != aFind->second.end(); aFIter++) {
+        const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = 
+          boost::dynamic_pointer_cast<ModelAPI_Feature>(*aFIter)->results();
+        std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
+        for(; aRIter != aResults.cend(); aRIter++) {
+          if ((*aRIter)->isInHistory() && (*aRIter)->groupName() == theGroupID) {
+            aResult++;
+          }
+        }
+      }
+    }
+  }
   // group is not found
-  return 0;
+  return aResult;
 }
 
 Model_Document::Model_Document(const std::string theID)
@@ -516,7 +558,7 @@ Model_Document::Model_Document(const std::string theID)
   myDoc->CommitCommand();
 }
 
-TDF_Label Model_Document::groupLabel(const string theGroup)
+TDF_Label Model_Document::groupLabel(const std::string theGroup)
 {
   // searching for existing
   TCollection_ExtendedString aGroup(theGroup.c_str());
@@ -534,127 +576,176 @@ 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(ModelAPI_Document::FEATURES_GROUP());
-  if (!theFeature->isInHistory()) {
-    aGroups.push_back(theFeature->getGroup());
+  std::string aName; // result
+  // first count all objects of such kind to start with index = count + 1
+  int a, aNumObjects = 0;
+  int aSize = size(ModelAPI_Feature::group());
+  for(a = 0; a < aSize; a++) {
+    if (boost::dynamic_pointer_cast<ModelAPI_Feature>(object(ModelAPI_Feature::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
+  std::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(ModelAPI_Feature::group(), a))
+          ->data()->name() == aName) {
+      aNumObjects++;
+      std::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 + 1));
+  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(ModelAPI_Document::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, ModelAPI_Document::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
+  std::map<std::string, std::vector<ObjectPtr> >::reverse_iterator aGroupIter = myObjs.rbegin();
+  for(; aGroupIter != myObjs.rend(); aGroupIter++) {
+    std::vector<ObjectPtr>::iterator anObjIter = aGroupIter->second.begin();
+    // and in parallel iterate labels of features
+    const std::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);
 }
+
+void Model_Document::storeResult(boost::shared_ptr<ModelAPI_Data> theFeatureData,
+  boost::shared_ptr<ModelAPI_Result> theResult, const int theResultIndex)
+{
+  boost::shared_ptr<ModelAPI_Document> aThis = 
+    Model_Application::getApplication()->getDocument(myID);
+  theResult->setDoc(aThis);
+  initData(theResult, boost::dynamic_pointer_cast<Model_Data>(theFeatureData)->
+    label().Father().FindChild(TAG_FEATURE_RESULTS), theResultIndex);
+  if (theResult->data()->name().empty()) { // if was not initialized, generate event and set a name
+    static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
+    ModelAPI_EventCreator::get()->sendUpdated(theResult, anEvent);
+    theResult->data()->setName(theFeatureData->name());
+  }
+}
+
+boost::shared_ptr<ModelAPI_ResultConstruction> Model_Document::createConstruction(
+  const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
+{
+  boost::shared_ptr<ModelAPI_ResultConstruction> aResult(new Model_ResultConstruction());
+  storeResult(theFeatureData, aResult);
+  return aResult;
+}
+
+boost::shared_ptr<ModelAPI_ResultBody> Model_Document::createBody(
+  const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
+{
+  boost::shared_ptr<ModelAPI_ResultBody> aResult(new Model_ResultBody());
+  storeResult(theFeatureData, aResult);
+  return aResult;
+}
+
+boost::shared_ptr<ModelAPI_ResultPart> Model_Document::createPart(
+  const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
+{
+  boost::shared_ptr<ModelAPI_ResultPart> aResult(new Model_ResultPart());
+  storeResult(theFeatureData, aResult);
+  return aResult;
+}
+
+boost::shared_ptr<ModelAPI_Feature> Model_Document::feature(
+  const boost::shared_ptr<ModelAPI_Result>& theResult)
+{
+  // iterate all features in order to find the needed result
+  std::map<std::string, std::vector<ObjectPtr> >::iterator aFind = 
+    myObjs.find(ModelAPI_Feature::group());
+  if (aFind != myObjs.end()) {
+    std::vector<ObjectPtr>::iterator aFIter = aFind->second.begin();
+    for(; aFIter != aFind->second.end(); aFIter++) {
+      FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(*aFIter);
+      const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
+      std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
+      for(; aRIter != aResults.cend(); aRIter++) {
+        if (*aRIter == theResult) {
+          return aFeature;
+        }
+      }
+    }
+  }
+  return FeaturePtr();
+}
index eaedf13db8a4c6b230f8413e3d69d08d60752319..db353a93babe0e59fa71ae479b6eceb8652b4091 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,13 +65,17 @@ 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
   //! \param theLabel base label of the feature
   MODEL_EXPORT virtual FeaturePtr feature(TDF_Label& theLabel);
 
+  //! Returns the existing object: result or feature
+  //! \param theLabel base label of the object
+  MODEL_EXPORT virtual ObjectPtr object(TDF_Label& theLabel);
+
   //! Adds a new sub-document by the identifier, or returns existing one if it is already exist
   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> subDocument(std::string theDocID);
 
@@ -81,12 +86,26 @@ 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);
 
+  /// Creates a construction cresults
+  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_ResultConstruction> createConstruction(
+    const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
+  /// Creates a body results
+  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_ResultBody> createBody(
+    const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
+  /// Creates a part results
+  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_ResultPart> createPart(
+    const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
+
+  //! Returns a feature by result (owner of result)
+  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> 
+    feature(const boost::shared_ptr<ModelAPI_Result>& theResult);
+
+
 protected:
 
   //! Returns (creates if needed) the group label
@@ -96,13 +115,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 +126,14 @@ 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);
+
+  //! 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_Data> theFeatureData,
+    boost::shared_ptr<ModelAPI_Result> theResult, const int theResultIndex = 0);
+
+
   friend class Model_Application;
   friend class Model_PluginManager;
   friend class DFBrowser;
@@ -125,8 +145,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 1de9238..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 ModelAPI_Document::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..fda4b4d
--- /dev/null
@@ -0,0 +1,52 @@
+// 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()
+{
+}
+
+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..13402b2
--- /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();
+
+  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..8d230ab
--- /dev/null
@@ -0,0 +1,25 @@
+// 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()
+{
+}
diff --git a/src/Model/Model_ResultConstruction.h b/src/Model/Model_ResultConstruction.h
new file mode 100644 (file)
index 0000000..e312f6f
--- /dev/null
@@ -0,0 +1,37 @@
+// 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:
+  /// 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..b3602c0
--- /dev/null
@@ -0,0 +1,21 @@
+// 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()
+{
+}
diff --git a/src/Model/Model_ResultPart.h b/src/Model/Model_ResultPart.h
new file mode 100644 (file)
index 0000000..26c19fc
--- /dev/null
@@ -0,0 +1,33 @@
+// 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 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();
+
+  friend class Model_Document;
+};
+
+#endif
index 2db098aea0193d9af8a0fef4dda8c50478eb6f1f..28048664e146ce06f0ca7211688d565a4dc302e0 100644 (file)
@@ -17,72 +17,77 @@ 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());
   }
   // iterate all features of features-documents to update them
   set<boost::shared_ptr<ModelAPI_Document> >::iterator aDIter = aDocs.begin();
   for(; aDIter != aDocs.end(); aDIter++) {
-    int aNbFeatures = (*aDIter)->size(ModelAPI_Document::FEATURES_GROUP());
+    int aNbFeatures = (*aDIter)->size(ModelAPI_Feature::group());
     for(int aFIndex = 0; aFIndex < aNbFeatures; aFIndex++) {
-      boost::shared_ptr<ModelAPI_Feature> aFeature = (*aDIter)->feature(ModelAPI_Document::FEATURES_GROUP(), aFIndex);
+      boost::shared_ptr<ModelAPI_Object> aFeature = boost::dynamic_pointer_cast<ModelAPI_Object>
+        ((*aDIter)->object(ModelAPI_Feature::group(), aFIndex));
       if (aFeature)
-        updateFeature(aFeature);
+        updateObject(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);
 }
 
-bool Model_Update::updateFeature(boost::shared_ptr<ModelAPI_Feature> theFeature)
+bool Model_Update::updateObject(boost::shared_ptr<ModelAPI_Object> theObject)
 {
   // check it is already processed
-  if (myUpdated.find(theFeature) != myUpdated.end())
-    return myUpdated[theFeature];
+  if (myUpdated.find(theObject) != myUpdated.end())
+    return myUpdated[theObject];
   // check all features this feature depended on (recursive call of updateFeature)
-  bool aMustbeUpdated = myInitial.find(theFeature) != myInitial.end();
-  // references
-  list<boost::shared_ptr<ModelAPI_Attribute> > aRefs = 
-    theFeature->data()->attributes(ModelAPI_AttributeReference::type());
-  list<boost::shared_ptr<ModelAPI_Attribute> >::iterator aRefsIter = aRefs.begin();
-  for(; aRefsIter != aRefs.end(); aRefsIter++) {
-    boost::shared_ptr<ModelAPI_Feature> aSub =
-      boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(*aRefsIter)->value();
-    if (aSub && aSub != theFeature && updateFeature(aSub))
-      aMustbeUpdated = true;
-  }
-  // lists of references
-  aRefs = theFeature->data()->attributes(ModelAPI_AttributeRefList::type());
-  for(aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) {
-    list<FeaturePtr> aListRef = 
-      boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(*aRefsIter)->list();
-    list<FeaturePtr>::iterator aListIter = aListRef.begin();
-    for(; aListIter != aListRef.end(); aListIter++) {
-      boost::shared_ptr<ModelAPI_Feature> aSub = *aListIter;
-      if (aSub && updateFeature(aSub))
+  bool anExecute = myInitial.find(theObject) != myInitial.end();
+  bool aMustbeUpdated = myInitial.find(theObject) != myInitial.end();
+  FeaturePtr aRealFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
+  if (aRealFeature) { // only real feature contains references to other objects
+    // references
+    list<boost::shared_ptr<ModelAPI_Attribute> > aRefs = 
+      theObject->data()->attributes(ModelAPI_AttributeReference::type());
+    list<boost::shared_ptr<ModelAPI_Attribute> >::iterator aRefsIter = aRefs.begin();
+    for(; aRefsIter != aRefs.end(); aRefsIter++) {
+      boost::shared_ptr<ModelAPI_Object> aSub =
+        boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(*aRefsIter)->value();
+      if (aSub && aSub != theObject && updateObject(aSub))
         aMustbeUpdated = true;
     }
+    // lists of references
+    aRefs = theObject->data()->attributes(ModelAPI_AttributeRefList::type());
+    for(aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) {
+      list<ObjectPtr> aListRef = 
+        boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(*aRefsIter)->list();
+      list<ObjectPtr>::iterator aListIter = aListRef.begin();
+      for(; aListIter != aListRef.end(); aListIter++) {
+        boost::shared_ptr<ModelAPI_Object> aSub = *aListIter;
+        if (aSub && updateObject(aSub))
+          aMustbeUpdated = true;
+      }
+    }
+    // execute feature if it must be updated
+    anExecute = aMustbeUpdated || anExecute;
+    if (anExecute) {
+      aRealFeature->execute();
+      static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+      ModelAPI_EventCreator::get()->sendUpdated(theObject, EVENT_DISP);
+    }
   }
-  // execute feature if it must be updated
-  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);
-    ModelAPI_EventCreator::get()->sendUpdated(theFeature, EVENT_DISP);
-  }
-  myUpdated[theFeature] = anExecute;
+  myUpdated[theObject] = anExecute;
   return anExecute;
 }
index d49c1c01e1c74aac7c32c020f5fa85f9979f8be1..f59d891f78609c6cc067908da3eeb02893893e0a 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();
@@ -31,9 +32,9 @@ public:
   MODEL_EXPORT virtual void processEvent(const Events_Message* theMessage);
 
 protected:
-  /// Recoursively checks and updates the feature if needed
-  /// Returns true if feature was updated.
-  bool updateFeature(boost::shared_ptr<ModelAPI_Feature> theFeature);
+  /// Recoursively checks and updates the object if needed
+  /// Returns true if object was updated.
+  bool updateObject(boost::shared_ptr<ModelAPI_Object> theObject);
 };
 
 #endif
index 8b834dd72561b7790f3bde8fa3a7048c8c786983..78d9901e685a9be732fa4c6cc6fafcb288a00361 100644 (file)
@@ -20,6 +20,11 @@ SET(PROJECT_HEADERS
     ModelAPI_Events.h
     ModelAPI_Validator.h
     ModelAPI_FeatureValidator.h
+    ModelAPI_Result.h
+    ModelAPI_ResultBody.h
+    ModelAPI_ResultConstruction.h
+    ModelAPI_ResultPart.h
+       ModelAPI_ResultParameters.h
 )
 
 SET(PROJECT_SOURCES
index 8fd391b2613e5d855528028001d09674cdd14d72..44e9dd81ea4a7c424c5384a3c9033351267082b2 100644 (file)
@@ -4,9 +4,9 @@
   #include "ModelAPI.h"
   #include "ModelAPI_Document.h"
   #include "ModelAPI_PluginManager.h"
+  #include "ModelAPI_Object.h"
   #include "ModelAPI_Feature.h"
   #include "ModelAPI_Data.h"
-  #include "ModelAPI_Object.h"
   #include "ModelAPI_Attribute.h"
   #include "ModelAPI_AttributeDocRef.h"
   #include "ModelAPI_AttributeDouble.h"
@@ -27,9 +27,9 @@
 %include <boost_shared_ptr.i>
 %shared_ptr(ModelAPI_Document)
 %shared_ptr(ModelAPI_PluginManager)
+%shared_ptr(ModelAPI_Object)
 %shared_ptr(ModelAPI_Feature)
 %shared_ptr(ModelAPI_Data)
-%shared_ptr(ModelAPI_Object)
 %shared_ptr(ModelAPI_Attribute)
 %shared_ptr(ModelAPI_AttributeDocRef)
 %shared_ptr(ModelAPI_AttributeDouble)
@@ -39,9 +39,9 @@
 // all supported interfaces
 %include "ModelAPI_Document.h"
 %include "ModelAPI_PluginManager.h"
+%include "ModelAPI_Object.h"
 %include "ModelAPI_Feature.h"
 %include "ModelAPI_Data.h"
-%include "ModelAPI_Object.h"
 %include "ModelAPI_Attribute.h"
 %include "ModelAPI_AttributeDocRef.h"
 %include "ModelAPI_AttributeDouble.h"
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 a16813609520877f62af3b2e996f96486cff5b65..e2b425f0d76915baf6440017dceb5fcb67f34d83 100644 (file)
@@ -17,8 +17,8 @@
 class ModelAPI_AttributeRefAttr : public ModelAPI_Attribute
 {
 public:
-  /// Returns true if this attribute references to a feature (not to the attribute)
-  MODELAPI_EXPORT virtual bool isFeature() = 0;
+  /// Returns true if this attribute references to a object (not to the attribute)
+  MODELAPI_EXPORT virtual bool isObject() = 0;
 
   /// Defines the reference to the attribute
   MODELAPI_EXPORT virtual void setAttr(boost::shared_ptr<ModelAPI_Attribute> theAttr) = 0;
@@ -26,11 +26,11 @@ public:
   /// Returns attribute referenced from this attribute
   MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Attribute> attr() = 0;
 
-  /// Defines the reference to the feature
-  MODELAPI_EXPORT virtual void setFeature(FeaturePtr theFeature) = 0;
+  /// Defines the reference to the object
+  MODELAPI_EXPORT virtual void setObject(ObjectPtr theFeature) = 0;
 
-  /// Returns feature referenced from this attribute
-  MODELAPI_EXPORT virtual FeaturePtr feature() = 0;
+  /// Returns object referenced from this attribute
+  MODELAPI_EXPORT virtual ObjectPtr object() = 0;
 
   /// Returns the type of this class of attributes
   MODELAPI_EXPORT static std::string type() {return "RefAttr";}
index 87800fb3660d0ab102944894dc0093aaf5295138..b897c1b4250e173bb3591bdd0ac425b330f07ff5 100644 (file)
@@ -24,16 +24,16 @@ public:
   MODELAPI_EXPORT virtual std::string attributeType() {return type();}
 
   /// Appends the feature to the end of a list
-  MODELAPI_EXPORT virtual void append(FeaturePtr theFeature) = 0;
+  MODELAPI_EXPORT virtual void append(ObjectPtr theObject) = 0;
 
   /// Erases the first meet of the feature in the list
-  MODELAPI_EXPORT virtual void remove(FeaturePtr theFeature) = 0;
+  MODELAPI_EXPORT virtual void remove(ObjectPtr theObject) = 0;
 
   /// Returns number of features in the list
   MODELAPI_EXPORT virtual int size() = 0;
 
   /// Returns the list of features
-  MODELAPI_EXPORT virtual std::list<FeaturePtr > list() = 0;
+  MODELAPI_EXPORT virtual std::list<ObjectPtr > list() = 0;
 
 protected:
   /// Objects are created for features automatically
index 0af5898ff69c29fb97b555fc619e81e17b754929..89e24798e1a9f085cab44838051d7338371154eb 100644 (file)
 class ModelAPI_AttributeReference : public ModelAPI_Attribute
 {
 public:
-  /// Defines the feature referenced from this attribute
-  MODELAPI_EXPORT virtual void setValue(FeaturePtr theFeature) = 0;
+  /// Defines the object referenced from this attribute
+  MODELAPI_EXPORT virtual void setValue(ObjectPtr theObject) = 0;
 
-  /// Returns feature referenced from this attribute
-  MODELAPI_EXPORT virtual FeaturePtr value() = 0;
+  /// Returns object referenced from this attribute
+  MODELAPI_EXPORT virtual ObjectPtr value() = 0;
 
   /// Returns the type of this class of attributes
   MODELAPI_EXPORT static std::string type() {return "Reference";}
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 42ee9c3acd0859b54831af8e61a5caf6bf8128b6..2aebf34d9d4ad326283d83eeddff0179b49b598d 100644 (file)
 #include <vector>
 
 class ModelAPI_Feature;
+class ModelAPI_Object;
+class ModelAPI_Result;
+class ModelAPI_ResultConstruction;
+class ModelAPI_ResultBody;
+class ModelAPI_ResultPart;
+class ModelAPI_Data;
 
 /**\class Model_Document
  * \ingroup DataModel
@@ -21,93 +27,80 @@ class ModelAPI_Feature;
 class ModelAPI_Document
 {
 public:
-  //! Common groups identifiers
-  //! Group of parameters
-  inline static const std::string& PARAMETERS_GROUP()
-  {
-    static const std::string MY_PARAMETERS_GROUP = "Parameters";
-    return MY_PARAMETERS_GROUP;
-  }
-  //! Group of constructions
-  inline static const std::string& CONSTRUCTIONS_GROUP()
-  {
-    static const std::string MY_CONSTRUCTIONS_GROUP = "Construction";
-    return MY_CONSTRUCTIONS_GROUP;
-  }
-  //! Group of parts
-  inline static const std::string& PARTS_GROUP()
-  {
-    static const std::string MY_PARTS_GROUP = "Parts";
-    return MY_PARTS_GROUP;
-  }
-  //! All created fetaures of the document (a history)
-  inline static const std::string& FEATURES_GROUP()
-  {
-    static const std::string MY_FEATURES_GROUP = "Features";
-    return MY_FEATURES_GROUP;
-  }
-
   //! Loads the OCAF document from the file.
   //! \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(
+    const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
+  /// Creates a body results
+  virtual boost::shared_ptr<ModelAPI_ResultBody> createBody(
+    const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
+  /// Creates a part results
+  virtual boost::shared_ptr<ModelAPI_ResultPart> createPart(
+    const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
+
+  //! Returns a feature by result (owner of result)
+  virtual boost::shared_ptr<ModelAPI_Feature> feature(
+    const boost::shared_ptr<ModelAPI_Result>& theResult) = 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..59c0e453743776ac0ad624b931c5e9211cb4866c 100644 (file)
@@ -5,81 +5,66 @@
 #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 the unique kind of a feature (like "Point")
+  virtual const std::string& getKind() = 0;
+
+  /// Returns the group identifier of all features
+  static std::string group()
+    {static std::string MY_GROUP = "Features"; return MY_GROUP;}
 
-  /// Returns to which group in the document must be added feature
-  MODELAPI_EXPORT virtual const std::string& getGroup() = 0;
+  /// Returns the group identifier of this result
+  virtual std::string groupName() { return group(); }
 
   /// 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 the first result in the list or NULL reference
+  boost::shared_ptr<ModelAPI_Result> firstResult() 
+  {return myResults.size() ? *(myResults.begin()) : boost::shared_ptr<ModelAPI_Result>();}
+  /// sets the alone result
+  void setResult(const boost::shared_ptr<ModelAPI_Result>& theResult) 
+  {myResults.clear(); myResults.push_back(theResult);}
 
   /// 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..9079883933ae2be6ee557374e53d1f4b11f94e92 100644 (file)
@@ -5,33 +5,54 @@
 #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;
-};
+  /// Returns the group identifier of this object
+  virtual std::string groupName() = 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..97077b1
--- /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 groupName() = 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..09ce4d6
--- /dev/null
@@ -0,0 +1,48 @@
+// 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 groupName()
+    { return group(); }
+
+  /// Returns the group identifier of this result
+  static 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..4207ff5
--- /dev/null
@@ -0,0 +1,40 @@
+// 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 group identifier of this result
+  virtual std::string groupName()
+    { return group(); }
+
+  /// Returns the group identifier of this result
+  static std::string group()
+    {static std::string MY_GROUP = "Construction"; return MY_GROUP;}
+
+
+  /// 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_ResultParameters.h b/src/ModelAPI/ModelAPI_ResultParameters.h
new file mode 100644 (file)
index 0000000..ee4c143
--- /dev/null
@@ -0,0 +1,32 @@
+// File:        ModelAPI_ResultParameters.h
+// Created:     07 Jul 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef ModelAPI_ResultParameters_HeaderFile
+#define ModelAPI_ResultParameters_HeaderFile
+
+#include "ModelAPI_Result.h"
+
+/**\class ModelAPI_ResultParameters
+ * \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_ResultParameters : public ModelAPI_Result
+{
+public:
+  /// Returns the group identifier of this result
+  virtual std::string groupName()
+    { return group(); }
+
+  /// Returns the group identifier of this result
+  static std::string group()
+    {static std::string MY_GROUP = "Parameters"; return MY_GROUP;}
+};
+
+//! Pointer on feature object
+typedef boost::shared_ptr<ModelAPI_ResultParameters> ResultParametersPtr;
+
+#endif
diff --git a/src/ModelAPI/ModelAPI_ResultPart.h b/src/ModelAPI/ModelAPI_ResultPart.h
new file mode 100644 (file)
index 0000000..4e3058b
--- /dev/null
@@ -0,0 +1,35 @@
+// 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 group identifier of this result
+  virtual std::string groupName()
+    { return group(); }
+
+  /// Returns the group identifier of this result
+  static std::string group()
+    {static std::string MY_GROUP = "Parts"; return MY_GROUP;}
+
+  /// 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> ResultPartPtr;
+
+#endif
index b21756a5c39ff3dc9c72c13d5cbfd6696a9308cc..350af8c02bd923f2d018b0ecd1300cc84db03312 100644 (file)
@@ -25,6 +25,7 @@ SET(PROJECT_HEADERS
        ModuleBase_SelectionValidator.h
        ModuleBase_ISelection.h
        ModuleBase_ViewerPrs.h
+       ModuleBase_Tools.h
 )
 
 SET(PROJECT_SOURCES
@@ -44,6 +45,7 @@ SET(PROJECT_SOURCES
        ModuleBase_WidgetPoint2dDistance.cpp
        ModuleBase_WidgetValue.cpp
        ModuleBase_WidgetValueFeature.cpp
+       ModuleBase_Tools.cpp
 )
 
 SET(PROJECT_LIBRARIES
index f32657a9edf6605a5141f0cabed0d5e7f996c22e..9e4bfbc025c236ac5ffe9468b8e96e983f6372da 100644 (file)
@@ -4,11 +4,13 @@
 
 #include <QList>
 #include <ModelAPI_Feature.h>
+#include <ModelAPI_Result.h>
 
 typedef QList<int> QIntList;       //!< list of int values
 typedef QList<short> QShortList;     //!< list of short int values
 typedef QList<double> QDoubleList;    //!< list of double values
 typedef QList<FeaturePtr> QFeatureList; //!< List of features
+typedef QList<ResultPtr> QResultList; //!< List of results
 
 
 #endif
\ No newline at end of file
index 0519985025d0496684909227602d4c7f61899a56..9a9e52ed7d94c4c4e290c08160062d22180471e3 100644 (file)
@@ -33,7 +33,12 @@ public:
   /**
   * Returns list of features currently selected in 3d viewer
   */
-  virtual QFeatureList selectedFeatures() const = 0;
+  virtual QList<ObjectPtr> selectedObjects() const = 0;
+
+  /**
+  * Returns list of currently selected results
+  */
+  virtual QResultList selectedResults() const = 0;
   
   //! Returns list of currently selected QModelIndexes
   virtual QModelIndexList selectedIndexes() const = 0;
index 4d6e920b0a504c442fd6a5ffe99f6267c0a93794..134274398bd876d9c10fbdda9433c539c2b21004 100644 (file)
@@ -7,7 +7,7 @@
 
 #include "ModuleBase.h"
 
-#include <ModelAPI_Feature.h>
+#include <ModelAPI_Object.h>
 
 #include <AIS_InteractiveContext.hxx>
 
@@ -30,7 +30,7 @@ public:
   virtual Handle(AIS_InteractiveContext) AISContext() const = 0;
 
   //! Returns list of currently selected data objects
-  virtual QList<FeaturePtr> selectedFeatures() const = 0; 
+  virtual QList<ObjectPtr> selectedObjects() const = 0; 
 
   //! Returns instance of loaded module
   virtual ModuleBase_IModule* module() const = 0;
index 720f089331c08703fe22d3a56f2532e62d63c6d8..178eb5d6316cf0db2bb2cf77c712614f498f7a0c 100644 (file)
@@ -17,9 +17,9 @@ ModuleBase_ModelWidget::ModuleBase_ModelWidget(QObject* theParent, const Config_
   myAttributeID = theData ? theData->widgetId() : "";
 }
 
-bool ModuleBase_ModelWidget::isInitialized(FeaturePtr theFeature) const
+bool ModuleBase_ModelWidget::isInitialized(ObjectPtr theObject) const
 {
-  return theFeature->data()->attribute(attributeID())->isInitialized();
+  return theObject->data()->attribute(attributeID())->isInitialized();
 }
 
 bool ModuleBase_ModelWidget::focusTo()
index 96154b37c4245dc85afd378d12cd29f8b0c19bef..8e4b010f6fce72e933ced50fec39124e07608790 100644 (file)
@@ -43,15 +43,15 @@ public:
   virtual bool setValue(ModuleBase_WidgetValue* theValue) { return false; };
 
   /// Returns the state whether the attribute of the feature is initialized
-  /// \param theFeature a model feature to be checked
+  /// \param theObject a model feature to be checked
   /// \return the boolean result
-  bool isInitialized(FeaturePtr theFeature) const;
+  bool isInitialized(ObjectPtr theObject) const;
 
   /// Saves the internal parameters to the given feature
-  /// \param theFeature a model feature to be changed
-  virtual bool storeValue(FeaturePtr theFeature) const = 0;
+  /// \param theObject a model feature to be changed
+  virtual bool storeValue(ObjectPtr theObject) const = 0;
 
-  virtual bool restoreValue(FeaturePtr theFeature) = 0;
+  virtual bool restoreValue(ObjectPtr theObject) = 0;
 
   /// Set focus to the first control of the current widget. The focus policy of the control is checked.
   /// If the widget has the NonFocus focus policy, it is skipped.
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)
diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp
new file mode 100644 (file)
index 0000000..3f0069e
--- /dev/null
@@ -0,0 +1,26 @@
+// File:        ModuleBase_Tools.cpp
+// Created:     11 July 2014
+// Author:      Vitaly Smetannikov
+
+#include "ModuleBase_Tools.h"
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_ResultConstruction.h>
+
+namespace ModuleBase_Tools
+{
+
+//******************************************************************
+boost::shared_ptr<GeomAPI_Shape> shape(ResultPtr theResult)
+{
+  ResultBodyPtr aBody = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(theResult);
+  if (aBody)
+    return aBody->shape();
+
+  ResultConstructionPtr aConstruct = boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult);
+  if (aConstruct)
+    return aConstruct->shape();
+
+  return boost::shared_ptr<GeomAPI_Shape>();
+}
+
+}
\ No newline at end of file
diff --git a/src/ModuleBase/ModuleBase_Tools.h b/src/ModuleBase/ModuleBase_Tools.h
new file mode 100644 (file)
index 0000000..f326a9e
--- /dev/null
@@ -0,0 +1,25 @@
+// File:        ModuleBase_Tools.h
+// Created:     11 July 2014
+// Author:      Vitaly Smetannikov
+
+
+#ifndef ModuleBase_Tools_H
+#define ModuleBase_Tools_H
+
+#include "ModuleBase.h"
+
+#include <ModelAPI_Result.h>
+
+class GeomAPI_Shape;
+
+namespace ModuleBase_Tools 
+{
+
+  /**
+  * Returns returns a shape if the result has a shape method. Otherwise returns NULL pointer
+  */
+  MODULEBASE_EXPORT boost::shared_ptr<GeomAPI_Shape> shape(ResultPtr theResult);
+
+};
+
+#endif
\ No newline at end of file
index b595ac156cd29cd94212d85d12bc031c5ace1db1..274ec2c2aed7e0d78fc0a785cb2b14f5620feb27 100644 (file)
@@ -11,7 +11,7 @@
 #include <TopoDS_Shape.hxx>
 #include <SelectMgr_EntityOwner.hxx>
 
-#include <ModelAPI_Feature.h>
+#include <ModelAPI_Result.h>
 
 /**\class ModuleBase_ViewerPrs
  * \ingroup Module base
@@ -27,21 +27,21 @@ public:
   /// \param theFeature a model feature
   /// \param theShape a viewer shape
   /// \param theOwner a selection owner
-  ModuleBase_ViewerPrs(FeaturePtr theFeature,
+  ModuleBase_ViewerPrs(ResultPtr theResult,
                  const TopoDS_Shape& theShape,
                  Handle_SelectMgr_EntityOwner theOwner)
-  : myFeature(theFeature), myShape(theShape), myOwner(theOwner) {}
+  : myResult(theResult), myShape(theShape), myOwner(theOwner) {}
   
   /// Destructor
   virtual ~ModuleBase_ViewerPrs() {}
 
   /// Sets the feature.
   /// \param theFeature a feature instance
-  void setFeature(FeaturePtr theFeature) { myFeature = theFeature; }
+  void setFeature(ResultPtr theResult) { myResult = theResult; }
 
   /// Returns the feature.
   /// \return a feature instance
-  FeaturePtr feature() const { return myFeature; }
+  ResultPtr result() const { return myResult; }
 
   /// Returns the presentation owner
   /// \param the owner
@@ -61,14 +61,14 @@ public:
 
   bool operator==(const ModuleBase_ViewerPrs& thePrs)
   {
-    bool aFeature = (myFeature.get() == thePrs.feature().get());
+    bool aResult = (myResult.get() == thePrs.result().get());
     bool aOwner = (myOwner.Access() == thePrs.owner().Access());
     bool aShape = myShape.IsEqual(thePrs.shape());
-    return aFeature && aOwner && aShape;
+    return aResult && aOwner && aShape;
   }
 
 private:
-  FeaturePtr myFeature; /// the feature
+  ResultPtr myResult; /// the feature
   Handle(SelectMgr_EntityOwner) myOwner; /// the selection owner
   TopoDS_Shape myShape; /// the shape
 };
index a34a73d6f02bedf6c2250345486d16cff2c3dff3..81be8438b667393ef320e5b2030f3931002aa6be 100644 (file)
@@ -40,21 +40,21 @@ QWidget* ModuleBase_WidgetBoolValue::getControl() const
   return myCheckBox; 
 }
 
-bool ModuleBase_WidgetBoolValue::storeValue(FeaturePtr theFeature) const
+bool ModuleBase_WidgetBoolValue::storeValue(ObjectPtr theObject) const
 {
-  DataPtr aData = theFeature->data();
+  DataPtr aData = theObject->data();
   boost::shared_ptr<ModelAPI_AttributeBoolean> aBool = aData->boolean(attributeID());
 
   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;
 }
 
-bool ModuleBase_WidgetBoolValue::restoreValue(FeaturePtr theFeature)
+bool ModuleBase_WidgetBoolValue::restoreValue(ObjectPtr theObject)
 {
-  DataPtr aData = theFeature->data();
+  DataPtr aData = theObject->data();
   boost::shared_ptr<ModelAPI_AttributeBoolean> aRef = aData->boolean(attributeID());
 
   bool isBlocked = myCheckBox->blockSignals(true);
index 6f32ef3ef87183b2961ead0fb7389d444a4a77c9..3969e643e47a3dde01d7deac7fb1a6d0b40fc3d0 100644 (file)
@@ -24,10 +24,10 @@ public:
   virtual ~ModuleBase_WidgetBoolValue();
 
   /// Saves the internal parameters to the given feature
-  /// \param theFeature a model feature to be changed
-  virtual bool storeValue(FeaturePtr theFeature) const;
+  /// \param theObject a model feature to be changed
+  virtual bool storeValue(ObjectPtr theObject) const;
 
-  virtual bool restoreValue(FeaturePtr theFeature);
+  virtual bool restoreValue(ObjectPtr theObject);
 
   /// Returns list of widget controls
   /// \return a control list
index ccbb0ad7ebd14a781d8cbee54999d8c636038f65..587e1e04141fd09bb49e167d87b692ca623862c6 100644 (file)
@@ -88,20 +88,20 @@ ModuleBase_WidgetDoubleValue::~ModuleBase_WidgetDoubleValue()
 {
 }
 
-bool ModuleBase_WidgetDoubleValue::storeValue(FeaturePtr theFeature) const
+bool ModuleBase_WidgetDoubleValue::storeValue(ObjectPtr theObject) const
 {
-  DataPtr aData = theFeature->data();
+  DataPtr aData = theObject->data();
   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;
 }
 
-bool ModuleBase_WidgetDoubleValue::restoreValue(FeaturePtr theFeature)
+bool ModuleBase_WidgetDoubleValue::restoreValue(ObjectPtr theObject)
 {
-  DataPtr aData = theFeature->data();
+  DataPtr aData = theObject->data();
   AttributeDoublePtr aRef = aData->real(attributeID());
 
   bool isBlocked = mySpinBox->blockSignals(true);
index 2a5b6c2a1c28b63db3ccc283774c8a347f3b6f7f..909855d18e9712d349fe3794e080839b56e43621 100644 (file)
@@ -25,10 +25,10 @@ public:
   virtual ~ModuleBase_WidgetDoubleValue();
 
   /// Saves the internal parameters to the given feature
-  /// \param theFeature a model feature to be changed
-  virtual bool storeValue(FeaturePtr theFeature) const;
+  /// \param theObject a model feature to be changed
+  virtual bool storeValue(ObjectPtr theObject) const;
 
-  virtual bool restoreValue(FeaturePtr theFeature);
+  virtual bool restoreValue(ObjectPtr theObject);
 
   /// Returns list of widget controls
   /// \return a control list
index d1e2ceea66fc30ea0734f2fd7f534ec6167391da..5f625caeeafd045744a35b8504bd07e43e385445 100644 (file)
@@ -62,46 +62,54 @@ bool ModuleBase_WidgetFeature::setValue(ModuleBase_WidgetValue* theValue)
   if (theValue) {
     ModuleBase_WidgetValueFeature* aFeatureValue = 
                          dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
-    if (aFeatureValue)
-      isDone = setFeature(aFeatureValue->feature());
+    // TODO
+//    if (aFeatureValue)
+//      isDone = setFeature(aFeatureValue->feature());
   }
   return isDone;
 }
 
 bool ModuleBase_WidgetFeature::setFeature(const FeaturePtr& theFeature)
 {
-  if (!theFeature || !myFeatureKinds.contains(theFeature->getKind().c_str()))
+  if (!myFeatureKinds.contains(theFeature->getKind().c_str()))
     return false;
 
   myFeature = theFeature;
-  myEditor->setText(theFeature ? theFeature->data()->getName().c_str() : "");
+  myEditor->setText(theFeature ? theFeature->data()->name().c_str() : "");
   emit valuesChanged();
   return true;
 }
 
-bool ModuleBase_WidgetFeature::storeValue(FeaturePtr theFeature) const
+bool ModuleBase_WidgetFeature::storeValue(ObjectPtr theObject) const
 {
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
+  if (!aFeature)
+    return false;
+  boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
   boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
           boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
 
   ModuleBase_WidgetFeature* that = (ModuleBase_WidgetFeature*) this;
-  aRef->setFeature(myFeature);
-  theFeature->execute();
-  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
+  aRef->setObject(myFeature);
+  aFeature->execute();
+  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
 
   return true;
 }
 
-bool ModuleBase_WidgetFeature::restoreValue(FeaturePtr theFeature)
+bool ModuleBase_WidgetFeature::restoreValue(ObjectPtr theObject)
 {
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  boost::shared_ptr<ModelAPI_Data> aData = theObject->data();
   boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
           boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
 
-  myFeature = aRef->feature();
-  myEditor->setText(myFeature ? myFeature->data()->getName().c_str() : "");
-  return true;
+  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aRef->object());
+  if (aFeature) {
+    myFeature = aFeature;
+    myEditor->setText(myFeature ? myFeature->data()->name().c_str() : "");
+    return true;
+  }
+  return false;
 }
 
 QWidget* ModuleBase_WidgetFeature::getControl() const
index 329079118288b5cf9431cb45044a38d7a60891f4..c57bd531e6c41bcabfb5a96e7c26f8f86b47996b 100644 (file)
@@ -40,9 +40,9 @@ public:
 
   /// Saves the internal parameters to the given feature
   /// \param theFeature a model feature to be changed
-  virtual bool storeValue(FeaturePtr theFeature) const;
+  virtual bool storeValue(ObjectPtr theObject) const;
 
-  virtual bool restoreValue(FeaturePtr theFeature);
+  virtual bool restoreValue(ObjectPtr theObject);
 
   /// Returns the internal parent wiget control, that can be shown anywhere
   /// \returns the widget
@@ -56,11 +56,11 @@ protected:
   /// Fill the widget values by given point
   /// \param thePoint the point
   /// \return the boolean result of the feature set
-  bool setFeature(const FeaturePtr& theFeature);
+  bool setFeature(const FeaturePtr& theObject);
 
   /// Returns current widget feature
   /// \return the feature
-  const FeaturePtr& feature() const { return myFeature; }
+  const FeaturePtr feature() const { return myFeature; }
 
   /// Returns the widget editor
   /// \return the editor
index 0099c993fc5055ab6a36451746b9e3d0a3a3c8db..a26a70d0ac81c569af8b5c72af442f1b1fe28e47 100644 (file)
@@ -47,7 +47,8 @@ bool ModuleBase_WidgetFeatureOrAttribute::setValue(ModuleBase_WidgetValue* theVa
                          dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
     if (aFeatureValue) {
       boost::shared_ptr<GeomAPI_Pnt2d> aValuePoint = aFeatureValue->point();
-      FeaturePtr aValueFeature = aFeatureValue->feature();
+      //TODO
+/*      FeaturePtr aValueFeature = aFeatureValue->feature();
       if (aValueFeature) {
         isDone = setFeature(aValueFeature);
       }
@@ -66,7 +67,7 @@ bool ModuleBase_WidgetFeatureOrAttribute::setValue(ModuleBase_WidgetValue* theVa
         }
         if (aFPoint)
           isDone = setAttribute(aFPoint);
-      }
+      }*/
     }
   }
   return isDone;
@@ -80,12 +81,12 @@ bool ModuleBase_WidgetFeatureOrAttribute::storeValue(FeaturePtr theFeature) cons
 
   ModuleBase_WidgetFeatureOrAttribute* that = (ModuleBase_WidgetFeatureOrAttribute*) this;
   if (feature())
-    aRef->setFeature(feature());
+    aRef->setObject(feature());
   else if (myAttribute)
     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;
 }
@@ -96,18 +97,21 @@ bool ModuleBase_WidgetFeatureOrAttribute::restoreValue(FeaturePtr theFeature)
   boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
           boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
 
-  FeaturePtr aFeature = aRef->feature();
-  setFeature(aFeature);
-  myAttribute = aRef->attr();
+  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aRef->object());
+  if (aFeature) {
+    setFeature(aFeature);
+    myAttribute = aRef->attr();
 
-  std::string aText = "";
-  if (aFeature)
-    aText = aFeature->data()->getName().c_str();
-  else if (myAttribute)
-    aText = myAttribute->attributeType().c_str();
+    std::string aText = "";
+    if (aFeature)
+      aText = aFeature->data()->name().c_str();
+    else if (myAttribute)
+      aText = myAttribute->attributeType().c_str();
 
-  editor()->setText(aText.c_str());
-  return true;
+    editor()->setText(aText.c_str());
+    return true;
+  }
+  return false;
 }
 
 bool ModuleBase_WidgetFeatureOrAttribute::setAttribute(const boost::shared_ptr<ModelAPI_Attribute>& theAttribute)
index baa7285b054873ef2bf7f8c59defbac16ebd0f05..51db5770b64f28dc04fb1aa6b88423e1fb7bcf1f 100644 (file)
@@ -101,24 +101,24 @@ void ModuleBase_WidgetPoint2D::setPoint(const boost::shared_ptr<GeomAPI_Pnt2d>&
   emit valuesChanged();
 }
 
-bool ModuleBase_WidgetPoint2D::storeValue(FeaturePtr theFeature) const
+bool ModuleBase_WidgetPoint2D::storeValue(ObjectPtr theObject) const
 {
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  boost::shared_ptr<ModelAPI_Data> aData = theObject->data();
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
     boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(attributeID()));
 
   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;
 }
 
-bool ModuleBase_WidgetPoint2D::restoreValue(FeaturePtr theFeature)
+bool ModuleBase_WidgetPoint2D::restoreValue(ObjectPtr theObject)
 {
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  boost::shared_ptr<ModelAPI_Data> aData = theObject->data();
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
     boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(attributeID()));
 
@@ -158,11 +158,11 @@ bool ModuleBase_WidgetPoint2D::eventFilter(QObject *theObject, QEvent *theEvent)
   return ModuleBase_ModelWidget::eventFilter(theObject, theEvent);
 }
 
-bool ModuleBase_WidgetPoint2D::initFromPrevious(FeaturePtr theFeature)
+bool ModuleBase_WidgetPoint2D::initFromPrevious(ObjectPtr theObject)
 {
   if (myOptionParam.length() == 0)
     return false;
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  boost::shared_ptr<ModelAPI_Data> aData = theObject->data();
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
     boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(myOptionParam));
   if (aPoint) {
@@ -172,7 +172,7 @@ bool ModuleBase_WidgetPoint2D::initFromPrevious(FeaturePtr theFeature)
     this->blockSignals(isBlocked);
 
     emit valuesChanged();
-    emit storedPoint2D(theFeature, myOptionParam);
+    emit storedPoint2D(theObject, myOptionParam);
     return true;
   }
   return false;
index 4a34641a7683888d3f42a109959070dff53e645f..5c72695209625ec94169c2c433678a4e745ae571 100644 (file)
@@ -39,10 +39,10 @@ public:
   virtual bool setValue(ModuleBase_WidgetValue* theValue);
 
   /// Saves the internal parameters to the given feature
-  /// \param theFeature a model feature to be changed
-  virtual bool storeValue(FeaturePtr theFeature) const;
+  /// \param theObject a model feature to be changed
+  virtual bool storeValue(ObjectPtr theObject) const;
 
-  virtual bool restoreValue(FeaturePtr theFeature);
+  virtual bool restoreValue(ObjectPtr theObject);
 
   /// Returns the internal parent wiget control, that can be shown anywhere
   /// \returns the widget
@@ -57,13 +57,13 @@ public:
   /// \param theEvent the processed event
   virtual bool eventFilter(QObject *theObject, QEvent *theEvent);
 
-  bool initFromPrevious(FeaturePtr theFeature);
+  bool initFromPrevious(ObjectPtr theObject);
 
 signals:
   /// Signal about the point 2d set to the feature
   /// \param the feature
   /// \param the attribute of the feature
-  void storedPoint2D(FeaturePtr theFeature, const std::string& theAttribute);
+  void storedPoint2D(ObjectPtr theObject, const std::string& theAttribute);
 
 protected:
   /// Fill the widget values by given point
index 303d4508e07d04c6cf45b8cf8872ac837204c9ad..e43f341e5797432d8542ee3d4f7d9eb5eb7c478e 100644 (file)
@@ -33,11 +33,12 @@ bool ModuleBase_WidgetPoint2dDistance::setValue(ModuleBase_WidgetValue* theValue
                          dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
     if (aFeatureValue) {
       boost::shared_ptr<GeomAPI_Pnt2d> aPnt = aFeatureValue->point();
-      FeaturePtr aFeature = aFeatureValue->feature();
+      // TODO
+      /*FeaturePtr aFeature = aFeatureValue->feature();
       if (aFeature && aPnt) {
         setPoint(aFeature, aPnt);
         isDone = true;
-      }
+      }*/
     }
   }
   return isDone;
index df7b431fbabc2b71000692c297d7bffcca9766dc..88aa9c3816570569346f60c04b4290928558197c 100644 (file)
@@ -5,12 +5,14 @@
 
 #include "ModuleBase_WidgetSelector.h"
 #include "ModuleBase_IWorkshop.h"
+#include "ModuleBase_Tools.h"
 
 #include <Events_Loop.h>
 #include <Model_Events.h>
 
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Object.h>
+#include <ModelAPI_Result.h>
 #include <ModelAPI_AttributeReference.h>
 #include <Config_WidgetAPI.h>
 
@@ -97,28 +99,28 @@ ModuleBase_WidgetSelector::~ModuleBase_WidgetSelector()
 }
 
 //********************************************************************
-bool ModuleBase_WidgetSelector::storeValue(FeaturePtr theFeature) const
+bool ModuleBase_WidgetSelector::storeValue(ObjectPtr theObject) const
 {
-  DataPtr aData = theFeature->data();
+  DataPtr aData = theObject->data();
   boost::shared_ptr<ModelAPI_AttributeReference> aRef = 
     boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(aData->attribute(attributeID()));
 
-  FeaturePtr aFeature = aRef->value();
-  if (!(aFeature && aFeature->isSame(mySelectedFeature))) {
-    aRef->setValue(mySelectedFeature);
-    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
+  ObjectPtr aObject = aRef->value();
+  if (!(aObject && aObject->isSame(mySelectedObject))) {
+    aRef->setValue(mySelectedObject);
+    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
   }
   return true;
 }
 
 //********************************************************************
-bool ModuleBase_WidgetSelector::restoreValue(FeaturePtr theFeature)
+bool ModuleBase_WidgetSelector::restoreValue(ObjectPtr theObject)
 {
-  DataPtr aData = theFeature->data();
+  DataPtr aData = theObject->data();
   boost::shared_ptr<ModelAPI_AttributeReference> aRef = aData->reference(attributeID());
 
   bool isBlocked = this->blockSignals(true);
-  mySelectedFeature = aRef->value();
+  mySelectedObject = aRef->value();
   updateSelectionName(); 
 
   this->blockSignals(isBlocked);
@@ -138,19 +140,19 @@ QList<QWidget*> ModuleBase_WidgetSelector::getControls() const
 //********************************************************************
 void ModuleBase_WidgetSelector::onSelectionChanged()
 {
-  QList<FeaturePtr> aFeatures = myWorkshop->selectedFeatures();
-  if (aFeatures.size() > 0) {
-    FeaturePtr aFeature = aFeatures.first();
-    if ((!mySelectedFeature) && (!aFeature))
+  QList<ObjectPtr> aObjects = myWorkshop->selectedObjects();
+  if (aObjects.size() > 0) {
+    ObjectPtr aObject = aObjects.first();
+    if ((!mySelectedObject) && (!aObject))
       return;
-    if (mySelectedFeature && aFeature && mySelectedFeature->isSame(aFeature))
+    if (mySelectedObject && aObject && mySelectedObject->isSame(aObject))
       return;
 
     // Check that the selection corresponds to selection type
-    if (!isAccepted(aFeature)) return;
+    if (!isAccepted(aObject)) return;
 
-    mySelectedFeature = aFeature;
-    if (mySelectedFeature) {
+    mySelectedObject = aObject;
+    if (mySelectedObject) {
       updateSelectionName();
       activateSelection(false);
       raisePanel();
@@ -162,9 +164,10 @@ void ModuleBase_WidgetSelector::onSelectionChanged()
 }
 
 //********************************************************************
-bool ModuleBase_WidgetSelector::isAccepted(const FeaturePtr theFeature) const
+bool ModuleBase_WidgetSelector::isAccepted(const ObjectPtr theResult) const
 {
-  boost::shared_ptr<GeomAPI_Shape> aShapePtr = theFeature->data()->shape();
+  ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theResult);
+  boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModuleBase_Tools::shape(aResult);
   if (!aShapePtr) return false;
   TopoDS_Shape aShape = aShapePtr->impl<TopoDS_Shape>();
   if (aShape.IsNull()) return false;
@@ -188,12 +191,8 @@ bool ModuleBase_WidgetSelector::isAccepted(const FeaturePtr theFeature) const
 //********************************************************************
 void ModuleBase_WidgetSelector::updateSelectionName()
 {
-  if (mySelectedFeature) {
-    std::string aName;
-    if (mySelectedFeature->data())
-      aName = mySelectedFeature->data()->getName();
-    else 
-      aName = boost::dynamic_pointer_cast<ModelAPI_Object>(mySelectedFeature)->getName();
+  if (mySelectedObject) {
+    std::string aName = mySelectedObject->data()->name();
  
     myTextLine->setText(QString::fromStdString(aName));
   } else 
index 0d411f3b742b4f747bcb105120827446cf735cb4..b1782d072b43765f68cf8588b5ca917f69c03209 100644 (file)
@@ -8,7 +8,7 @@
 #include "ModuleBase.h"
 #include "ModuleBase_ModelWidget.h"
 
-#include <ModelAPI_Feature.h>
+#include <ModelAPI_Object.h>
 
 #include <TopAbs_ShapeEnum.hxx>
 
@@ -33,10 +33,10 @@ public:
   virtual ~ModuleBase_WidgetSelector();
 
   /// Saves the internal parameters to the given feature
-  /// \param theFeature a model feature to be changed
-  virtual bool storeValue(FeaturePtr theFeature) const;
+  /// \param theObject a model feature to be changed
+  virtual bool storeValue(ObjectPtr theObject) const;
 
-  virtual bool restoreValue(FeaturePtr theFeature);
+  virtual bool restoreValue(ObjectPtr theObject);
 
   /// Returns the internal parent wiget control, that can be shown anywhere
   /// \returns the widget
@@ -49,7 +49,7 @@ public:
   void setActivationOnStart(bool toActivate) { myActivateOnStart = toActivate; }
   bool activateOnStart() const { return myActivateOnStart; }
 
-  FeaturePtr selectedFeature() const { return mySelectedFeature; }
+  ObjectPtr selectedFeature() const { return mySelectedObject; }
 
 public slots:
 
@@ -66,7 +66,7 @@ private:
   void enableOthersControls(bool toEnable) const;
   void updateSelectionName();
   void raisePanel() const;
-  bool isAccepted(const FeaturePtr theFeature) const;
+  bool isAccepted(const ObjectPtr theObject) const;
 
   static TopAbs_ShapeEnum shapeType(const QString& theType);
 
@@ -79,7 +79,7 @@ private:
 
   bool myActivateOnStart;
 
-  FeaturePtr mySelectedFeature;
+  ObjectPtr mySelectedObject;
   QStringList myShapeTypes;
 };
 
index 51b39e181a98424f1023333158ab51980c40083a..da9fe5fd354f7c2f5ca58178a398f60233dfcd38 100644 (file)
@@ -14,14 +14,14 @@ ModuleBase_WidgetValueFeature::~ModuleBase_WidgetValueFeature()
 {
 }
 
-void ModuleBase_WidgetValueFeature::setFeature(const FeaturePtr& theFeature)
+void ModuleBase_WidgetValueFeature::setResult(const ResultPtr& theFeature)
 {
-  myFeature = theFeature;
+  myResult = theFeature;
 }
 
-const FeaturePtr& ModuleBase_WidgetValueFeature::feature() const
+const ResultPtr& ModuleBase_WidgetValueFeature::result() const
 {
-  return myFeature;
+  return myResult;
 }
 
 void ModuleBase_WidgetValueFeature::setPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint)
index 9bdaeb619ac76c9fa76beb82ddecabadb4b5d42d..2de332108f08e3186498abd6d2cab38e70a46d50 100644 (file)
@@ -8,7 +8,7 @@
 #include <ModuleBase.h>
 #include <ModuleBase_WidgetValue.h>
 
-#include <ModelAPI_Feature.h>
+#include <ModelAPI_Result.h>
 
 #include <boost/shared_ptr.hpp>
 
@@ -28,11 +28,11 @@ public:
 
   /// Fill the widget values by given point
   /// \param thePoint the point
-  void setFeature(const FeaturePtr& theFeature);
+  void setResult(const ResultPtr& theFeature);
 
   /// Returns the widget values by given point
   /// \return theFeature the current feature
-  const FeaturePtr& feature() const;
+  const ResultPtr& result() const;
 
   /// Fill the widget values by given point
   /// \param thePoint the point
@@ -43,7 +43,7 @@ public:
   const boost::shared_ptr<GeomAPI_Pnt2d>& point() const;
 
 private:
-  FeaturePtr myFeature;
+  ResultPtr myResult;
   boost::shared_ptr<GeomAPI_Pnt2d> myPoint;
 };
 
index 7b642812d32b10da0fc42a46b29a67afc4fd7125..f94e6c24f45d7f0b1ac7e90db35ee94e807899e7 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,28 +37,31 @@ 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);
-    std::set<FeaturePtr > aFeatures = aUpdMsg->features();
-    std::set<FeaturePtr >::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
+    const ModelAPI_ObjectUpdatedMessage* aUpdMsg = 
+      dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
+    std::set<ObjectPtr > aFeatures = aUpdMsg->features();
+    std::set<ObjectPtr >::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) {
-        myModule->visualizePreview(aFeature, true, false);
-        //if (aType == EVENT_FEATURE_CREATED)
+      ObjectPtr aObject = *anIt;
+      FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObject);
+      if (aFeature) {
+        if (myModule->workshop()->displayer()->isVisible(aFeature->firstResult()) ||
+            aType == EVENT_OBJECT_CREATED) {
+          myModule->visualizePreview(aFeature->firstResult(), true, false);
+          //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);
+    const ModelAPI_ObjectDeletedMessage* aDelMsg = 
+      dynamic_cast<const ModelAPI_ObjectDeletedMessage*>(theMessage);
     boost::shared_ptr<ModelAPI_Document> aDoc = aDelMsg->document();
 
     std::set<std::string> aGroups = aDelMsg->groups();
@@ -66,7 +69,7 @@ void PartSet_Listener::processEvent(const Events_Message* theMessage)
     for (; anIt != aLast; anIt++) {
       std::string aGroup = *anIt;
       if (aGroup.compare(SketchPlugin_Sketch::ID()) == 0) { // Update only Sketch group
-        myModule->workshop()->displayer()->eraseDeletedFeatures();
+        myModule->workshop()->displayer()->eraseDeletedResults();
         myModule->updateCurrentPreview(aGroup);
       }
     }
index 5f903b0eded4d0f8adf70a9ecf6eccd4dc385ae7..b52edee63b7be64f4a160c94421bf1e053c3daa0 100644 (file)
@@ -108,12 +108,11 @@ void PartSet_Module::createFeatures()
   //!! Test registering of validators
   PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
-  
   aFactory->registerValidator("PartSet_DistanceValidator", new PartSet_DistanceValidator);
-  aFactory->assignValidator("PartSet_DistanceValidator", "SketchConstraintDistance");
-
   aFactory->registerValidator("PartSet_LengthValidator", new PartSet_LengthValidator);
-  aFactory->assignValidator("PartSet_LengthValidator", "SketchConstraintLength");
+  aFactory->registerValidator("PartSet_PerpendicularValidator", new PartSet_PerpendicularValidator);
+  aFactory->registerValidator("PartSet_ParallelValidator", new PartSet_ParallelValidator);
+  aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator);
 }
 
 void PartSet_Module::featureCreated(QAction* theFeature)
@@ -187,9 +186,11 @@ void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
 
 void PartSet_Module::onContextMenuCommand(const QString& theId, bool isChecked)
 {
-  QFeatureList aFeatures = myWorkshop->selector()->selection()->selectedFeatures();
+  QList<ObjectPtr> aFeatures = myWorkshop->selector()->selection()->selectedObjects();
   if (theId == "EDIT_CMD" && (aFeatures.size() > 0)) {
-    editFeature(aFeatures.first());
+    FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aFeatures.first());
+    if (aFeature)
+      editFeature(aFeature);
   }
 }
 
@@ -302,7 +303,16 @@ void PartSet_Module::onStopSelection(const QFeatureList& theFeatures, const bool
       activateFeature((*anIt), false);
     }
   }
-  aDisplayer->stopSelection(theFeatures, isStop, false);
+  QResultList aResults;
+  foreach(FeaturePtr aFeature, theFeatures) {
+    if (aFeature->results().size() > 0) {
+      std::list<ResultPtr>& aResList = aFeature->results();
+      std::list<ResultPtr>::iterator aIt;
+      for (aIt = aResList.begin(); aIt != aResList.end(); ++aIt)
+        aResults.append(*aIt);
+    }
+  }
+  aDisplayer->stopSelection(aResults, isStop, false);
 
   XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
   aViewer->enableSelection(!isStop);
@@ -310,7 +320,7 @@ void PartSet_Module::onStopSelection(const QFeatureList& theFeatures, const bool
   aDisplayer->updateViewer();
 }
 
-void PartSet_Module::onSetSelection(const QFeatureList& theFeatures)
+void PartSet_Module::onSetSelection(const QResultList& theFeatures)
 {
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
   aDisplayer->setSelected(theFeatures, false);
@@ -326,7 +336,7 @@ void PartSet_Module::onCloseLocalContext()
 void PartSet_Module::onFeatureConstructed(FeaturePtr theFeature, int theMode)
 {
   bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
-  visualizePreview(theFeature, isDisplay, false);
+  // TODO visualizePreview(theFeature, isDisplay, false);
   if (!isDisplay) {
     ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
     FeaturePtr aSketch;
@@ -339,7 +349,7 @@ void PartSet_Module::onFeatureConstructed(FeaturePtr theFeature, int theMode)
       std::list<FeaturePtr>::const_iterator anIt = aList.begin(),
                                             aLast = aList.end();
       for (; anIt != aLast; anIt++)
-        visualizePreview(*anIt, false, false);
+        visualizePreview((*anIt)->firstResult(), false, false);
       aDisplayer->updateViewer();
     }
   }
@@ -434,7 +444,7 @@ void PartSet_Module::sendOperation(ModuleBase_Operation* theOperation)
   Events_Loop::loop()->send(aMessage);
 }
 
-void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay,
+void PartSet_Module::visualizePreview(ResultPtr theFeature, bool isDisplay,
                                       const bool isUpdateViewer)
 {
   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
@@ -469,7 +479,7 @@ void PartSet_Module::activateFeature(FeaturePtr theFeature, const bool isUpdateV
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
   if (aPreviewOp) {
     XGUI_Displayer* aDisplayer = myWorkshop->displayer();
-    aDisplayer->activateInLocalContext(theFeature, aPreviewOp->getSelectionModes(theFeature),
+    aDisplayer->activateInLocalContext(theFeature->firstResult(), aPreviewOp->getSelectionModes(theFeature),
                                        isUpdateViewer);
   }
 }
@@ -499,8 +509,8 @@ void PartSet_Module::updateCurrentPreview(const std::string& theCmdId)
       boost::dynamic_pointer_cast<SketchPlugin_Feature>(*anIt);
     if (!aSPFeature)
       continue;
-    visualizePreview(*anIt, true, false);
-    aDisplayer->activateInLocalContext(*anIt, aModes, false);
+    visualizePreview((*anIt)->firstResult(), true, false);
+    aDisplayer->activateInLocalContext((*anIt)->firstResult(), aModes, false);
   }
   aDisplayer->updateViewer();
 }
@@ -510,17 +520,17 @@ void PartSet_Module::editFeature(FeaturePtr theFeature)
   if (!theFeature)
     return;
 
-//  if (theFeature->getKind() == SketchPlugin_Sketch::ID()) {
-    FeaturePtr aFeature = theFeature;
-    if (XGUI_Tools::isModelObject(aFeature)) {
-      ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
-      aFeature = aObject->featureRef();
-    }
-
-    if (aFeature) {
-      onLaunchOperation(aFeature->getKind(), aFeature);
-      updateCurrentPreview(aFeature->getKind());
-    }
+//  if (theFeature->getKind() == SKETCH_KIND) {
+    //FeaturePtr aFeature = theFeature;
+    //if (XGUI_Tools::isModelObject(aFeature)) {
+    //  ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
+    //  aFeature = aObject->featureRef();
+    //}
+
+    //if (aFeature) {
+      onLaunchOperation(theFeature->getKind(), theFeature);
+      updateCurrentPreview(theFeature->getKind());
+    //}
 //  }
 }
 
index 627d088b15bf30c63627d5b317449d3a1191d41b..eaec86601bf7f913335699a9f04cdee09c0e8b06 100644 (file)
@@ -55,7 +55,7 @@ public:
   /// \param theFeature the feature instance to be displayed
   /// \param isDisplay the state whether the presentation should be displayed or erased
   /// \param isUpdateViewer the flag whether the viewer should be updated
-  void visualizePreview(FeaturePtr theFeature, bool isDisplay,
+  void visualizePreview(ResultPtr theResult, bool isDisplay,
                         const bool isUpdateViewer = true);
 
   /// Activates the feature in the displayer
@@ -125,7 +125,7 @@ public slots:
 
   /// SLOT, to set selection
   /// \param theFeatures a list of features to be selected
-  void onSetSelection(const QFeatureList& theFeatures);
+  void onSetSelection(const QResultList& theFeatures);
 
   /// SLOT, to close the viewer local context
   void onCloseLocalContext();
index 9b7039ae33c7ce34acbd1fca91ac388d1ea95135..f08d83972f67e4fd554625036240b6962221400a 100644 (file)
@@ -145,19 +145,21 @@ void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle
       }
     }
   }
-  FeaturePtr aFeature;
+  ResultPtr aFeature;
   if (!theSelected.empty()) {
     ModuleBase_ViewerPrs aPrs = theSelected.front();
-    aFeature = aPrs.feature();
+    aFeature = aPrs.result();
   }
-  else
-    aFeature = feature(); // for the widget distance only
+  // TODO
+  //else
+  //  aFeature = feature(); // for the widget distance only
 
-  bool isApplyed = setWidgetValue(aFeature, aX, anY);
+  // TODO
+  /*bool isApplyed = setWidgetValue(aFeature, aX, anY);
   if (isApplyed) {
     flushUpdated();
     emit activateNextWidget(myActiveWidget);
-  }
+  }*/
 }
 
 void PartSet_OperationFeatureCreate::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
@@ -192,7 +194,7 @@ void PartSet_OperationFeatureCreate::onWidgetActivated(ModuleBase_ModelWidget* t
   if ((myPreSelection.size() > 0) && myActiveWidget) {
     const ModuleBase_ViewerPrs& aPrs = myPreSelection.front();
     ModuleBase_WidgetValueFeature aValue;
-    aValue.setFeature(aPrs.feature());
+    aValue.setResult(aPrs.result());
     if (myActiveWidget->setValue(&aValue)) {
       myPreSelection.remove(aPrs);
       emit activateNextWidget(myActiveWidget);
@@ -281,7 +283,7 @@ FeaturePtr PartSet_OperationFeatureCreate::createFeature(const bool theFlushMess
 bool PartSet_OperationFeatureCreate::setWidgetValue(FeaturePtr theFeature, double theX, double theY)
 {
   ModuleBase_WidgetValueFeature* aValue = new ModuleBase_WidgetValueFeature();
-  aValue->setFeature(theFeature);
+  aValue->setResult(theFeature->firstResult());
   aValue->setPoint(boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY)));
   bool isApplyed = myActiveWidget->setValue(aValue);
 
index 5782ca1ba5d974b38d26410b77c32d19e694f500..f3b27594e6362b6cc24dc16c30bd6fac8a940657 100644 (file)
@@ -73,28 +73,30 @@ void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, Handle(V3
                                              const std::list<ModuleBase_ViewerPrs>& theSelected,
                                              const std::list<ModuleBase_ViewerPrs>& theHighlighted)
 {
-  FeaturePtr aFeature;
+  ResultPtr aFeature;
   if (!theHighlighted.empty())
-    aFeature = theHighlighted.front().feature();
+    aFeature = theHighlighted.front().result();
   if (!aFeature && !theSelected.empty()) // changed for a constrain
-    aFeature = theSelected.front().feature();
-
-  if (!aFeature || aFeature != feature())
+    aFeature = theSelected.front().result();
+  // TODO
+  /*if (!aFeature || aFeature != feature())
   {
     commit();
     emit featureConstructed(feature(), FM_Deactivation);
 
     bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
     if(aHasShift && !theHighlighted.empty()) {
-      QFeatureList aSelected;
+      QResultList aSelected;
+      // TODO
       aSelected.push_back(feature());
-      aSelected.push_back(theHighlighted.front().feature());
+      aSelected.push_back(theHighlighted.front().result());
       emit setSelection(aSelected);
     }
+    // TODO
     else if (aFeature) {
       restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature);
     }
-  }
+  }*/
 }
 
 void PartSet_OperationFeatureEdit::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
@@ -195,7 +197,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..d66acf804a2ba1cbe435c259ec1bce70da234afe 100644 (file)
@@ -58,9 +58,10 @@ void PartSet_OperationFeatureEditMulti::initSelection(const std::list<ModuleBase
     // deselected in the viewer by blockSelection signal in the startOperation method.
     bool isSelected = false;
     std::list<ModuleBase_ViewerPrs>::const_iterator anIt = theSelected.begin(), aLast = theSelected.end();
-    for (; anIt != aLast && !isSelected; anIt++) {
+    // TODO
+    /*for (; anIt != aLast && !isSelected; anIt++) {
       isSelected = (*anIt).feature() == feature();
-    }
+    }*/
     if (!isSelected)
       myFeatures = theHighlighted;
     else
@@ -109,13 +110,14 @@ void PartSet_OperationFeatureEditMulti::mouseMoved(QMouseEvent* theEvent, Handle
     aSketchFeature->move(aDeltaX, aDeltaY);
 
     std::list<ModuleBase_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
-    for (; anIt != aLast; anIt++) {
+    // TODO
+    /*for (; anIt != aLast; anIt++) {
       FeaturePtr aFeature = (*anIt).feature();
       if (!aFeature || aFeature == feature())
         continue;
       aSketchFeature = boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
       aSketchFeature->move(aDeltaX, aDeltaY);
-    }
+    }*/
   }
   sendFeatures();
 
@@ -129,12 +131,13 @@ void PartSet_OperationFeatureEditMulti::mouseReleased(QMouseEvent* theEvent, Han
   std::list<ModuleBase_ViewerPrs> aFeatures = myFeatures;
   commit();
   std::list<ModuleBase_ViewerPrs>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
-  for (; anIt != aLast; anIt++) {
+  // TODO
+  /*for (; anIt != aLast; anIt++) {
     FeaturePtr aFeature = (*anIt).feature();
     if (aFeature) {
       emit featureConstructed(aFeature, FM_Deactivation);
        }
-  }
+  }*/
 }
 
 void PartSet_OperationFeatureEditMulti::startOperation()
@@ -165,8 +168,8 @@ void PartSet_OperationFeatureEditMulti::blockSelection(bool isBlocked, const boo
   QFeatureList aFeatureList;
   std::list<ModuleBase_ViewerPrs>::const_iterator anIt = myFeatures.begin(),
                                             aLast = myFeatures.end();
-  for(; anIt != aLast; anIt++)
-    aFeatureList.append((*anIt).feature());
+  /*for(; anIt != aLast; anIt++)
+    aFeatureList.append((*anIt).feature());*/
   if (isBlocked) {
     emit setSelection(QFeatureList());
     emit stopSelection(aFeatureList, true);
@@ -181,17 +184,18 @@ 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();
-  for (; anIt != aLast; anIt++) {
+  // TODO
+  /*for (; anIt != aLast; anIt++) {
     FeaturePtr aFeature = (*anIt).feature();
     if (!aFeature)
       continue;
 
     ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent);
-  }
+  }*/
   Events_Loop::loop()->flush(anEvent);
   flushUpdated();
 }
index df4408dd58f345353a3b325464e3aa1a8c1a150c..c3391efb91641d8bd248b15d0b24e16ba7f12c45 100644 (file)
@@ -91,12 +91,12 @@ void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_Vie
       return;
 
     if (theHighlighted.size() == 1) {
-      FeaturePtr aFeature = theHighlighted.front().feature();
+      ResultPtr aFeature = theHighlighted.front().result();
       if (aFeature) {
         std::string anOperationType = PartSet_OperationFeatureEdit::Type();
         if (theSelected.size() > 1)
           anOperationType = PartSet_OperationFeatureEditMulti::Type();
-        restartOperation(anOperationType, aFeature);
+        // TODO restartOperation(anOperationType, aFeature);
       }
     }
     else
@@ -117,9 +117,10 @@ void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_Vi
     /// It is empty and we have to use the process mouse release to start edition operation
     /// for these objects
     if (theSelected.size() == 1) {
-      FeaturePtr aFeature = theSelected.front().feature();
-      if (aFeature)
-        restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature);
+      ResultPtr aFeature = theSelected.front().result();
+      // TODO
+      //if (aFeature)
+      //  restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature);
     }
   }
 }
@@ -145,7 +146,15 @@ std::list<FeaturePtr> PartSet_OperationSketch::subFeatures() const
   boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
         boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aData->attribute(SketchPlugin_Sketch::FEATURES_ID()));
 
-  return aRefList->list();
+  std::list<ObjectPtr> aList = aRefList->list();
+  std::list<ObjectPtr>::iterator aIt;
+  std::list<FeaturePtr> aFeaList;
+  for (aIt = aList.begin(); aIt != aList.end(); ++aIt) {
+    FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(*aIt);
+    if (aFeature)
+      aFeaList.push_back(aFeature);
+  }
+  return aFeaList;
 }
 
 void PartSet_OperationSketch::stopOperation()
index bef1dfde5cde9d2d426d81de989e99b2c5cb228c..7c6864f7cc7d4ffc9c6941bbd44056cc5e9f1b53 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <PartSet_OperationSketchBase.h>
 #include <PartSet_Tools.h>
+#include <ModelAPI_ResultBody.h>
 
 #include <SketchPlugin_Feature.h>
 #include <V3d_View.hxx>
@@ -35,9 +36,13 @@ boost::shared_ptr<GeomAPI_Shape> PartSet_OperationSketchBase::preview(
 {
   boost::shared_ptr<SketchPlugin_Feature> aFeature = 
                               boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
-  if (!aFeature)
-    return boost::shared_ptr<GeomAPI_Shape>();
-  return aFeature->preview();
+  if (aFeature) {
+    ResultPtr aRes = aFeature->firstResult();
+    ResultBodyPtr aBody = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(aRes);
+    if (aBody)
+      return aBody->shape();
+  }
+  return boost::shared_ptr<GeomAPI_Shape>();
 }
 
 std::list<FeaturePtr> PartSet_OperationSketchBase::subFeatures() const
index aaa3c3c590a9b777ce65361c8e9571c080bf216e..df5567aee9e6ffc55b1d4dd64b3d3cc4678ead72 100644 (file)
@@ -18,7 +18,7 @@
 #include <ModelAPI_Document.h>
 
 static double myTestDelta;
-static FeaturePtr myTestFeature;
+static ResultPtr myTestObject;
 
 #include <AIS_InteractiveContext.hxx>
 #include <AIS_Shape.hxx>
@@ -31,13 +31,13 @@ static FeaturePtr myTestFeature;
 
 void PartSet_TestOCC::testSelection(XGUI_Workshop* theWorkshop)
 {
-  if (!myTestFeature) {
+  if (!myTestObject) {
     PartSet_TestOCC::createTestLine(theWorkshop);
     PartSet_TestOCC::moveMouse(theWorkshop->viewer()->AISContext(),
                                theWorkshop->viewer()->activeView());
     PartSet_TestOCC::changeTestLine(theWorkshop);
   }
-  boost::shared_ptr<GeomAPI_AISObject> anIO = theWorkshop->displayer()->getAISObject(myTestFeature);
+  boost::shared_ptr<GeomAPI_AISObject> anIO = theWorkshop->displayer()->getAISObject(myTestObject);
   if (!anIO->empty()) {
     theWorkshop->viewer()->AISContext()->MoveTo(0, 0, theWorkshop->viewer()->activeView());
     theWorkshop->viewer()->AISContext()->Select(0, 0, 2500, 2500, theWorkshop->viewer()->activeView());
@@ -152,12 +152,12 @@ void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop)
       boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
     boost::shared_ptr<GeomAPI_AISObject> anAIS = aSPFeature->getAISObject(aPrevAIS);
     if (!anAIS->empty())
-      aDisplayer->redisplay(aFeature, anAIS, false);
+      aDisplayer->redisplay(aFeature->firstResult(), anAIS, false);
 
     std::list<int> aModes;
     aModes.push_back(TopAbs_VERTEX);
     aModes.push_back(TopAbs_EDGE);
-    aDisplayer->activateInLocalContext(aFeature, aModes, true);
+    aDisplayer->activateInLocalContext(aFeature->firstResult(), aModes, true);
 
     // change the line
     /*double aDelta = -200;
@@ -182,10 +182,10 @@ void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop)
     //aModes.push_back(TopAbs_VERTEX);
     //aModes.push_back(TopAbs_EDGE);
     //aDisplayer->activateInLocalContext(aFeature, aModes, true);
-    myTestFeature = aFeature;
+    myTestObject = aFeature->firstResult();
 
-    QFeatureList aFeatureList;
-    aFeatureList.append(myTestFeature);
+    QResultList aFeatureList;
+    aFeatureList.append(myTestObject);
     aDisplayer->setSelected(aFeatureList, true);
   }
 }
@@ -193,15 +193,16 @@ void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop)
 void PartSet_TestOCC::changeTestLine(XGUI_Workshop* theWorkshop)
 {
   // change the line
-  if (!myTestFeature)
+  if (!myTestObject)
     return;
-  FeaturePtr aFeature = myTestFeature;
+  ResultPtr aFeature = myTestObject;
 
   myTestDelta = myTestDelta - 50;
   double aDelta = myTestDelta;
-  PartSet_Tools::setFeaturePoint(aFeature, -100/*aDelta*/, -100/*aDelta*/, SketchPlugin_Line::START_ID());
-  PartSet_Tools::setFeaturePoint(aFeature, 200/*aDelta*2*/, 200/*aDelta*2*/, SketchPlugin_Line::END_ID());
-  boost::shared_ptr<GeomAPI_Shape> aPreview = PartSet_OperationSketchBase::preview(aFeature);
+  // TODO
+  //PartSet_Tools::setFeaturePoint(aFeature, -100/*aDelta*/, -100/*aDelta*/, LINE_ATTR_START);
+  //PartSet_Tools::setFeaturePoint(aFeature, 200/*aDelta*2*/, 200/*aDelta*2*/, LINE_ATTR_END);
+  //boost::shared_ptr<GeomAPI_Shape> aPreview = PartSet_OperationSketchBase::preview(aFeature);
 
   boost::shared_ptr<GeomAPI_AISObject> aPrevAIS;
   boost::shared_ptr<SketchPlugin_Feature> aSPFeature = 
@@ -216,7 +217,7 @@ void PartSet_TestOCC::changeTestLine(XGUI_Workshop* theWorkshop)
   //aDisplayer->activateInLocalContext(aFeature, aModes, true);
 
   /*QFeatureList aFeatureList;
-  aFeatureList.append(myTestFeature);
+  aFeatureList.append(myTestObject);
   theWorkshop->displayer()->setSelected(aFeatureList, true);*/
 
   theWorkshop->displayer()->updateViewer();
@@ -226,4 +227,4 @@ void PartSet_TestOCC::moveMouse(Handle(AIS_InteractiveContext) theContext, Handl
 {
   theContext->MoveTo(10, 10, theView);
   theContext->Select();
-}
\ No newline at end of file
+}
index eb07e5baa11d0f0bd7e15eaaa5490e2726b058c1..d0097bd4dedf3036aec6e942ef4894ea3175b513 100644 (file)
@@ -152,17 +152,17 @@ FeaturePtr PartSet_Tools::nearestFeature(QPoint thePoint, Handle_V3d_View theVie
   ModuleBase_ViewerPrs aPrs;
   for (; anIt != aLast; anIt++) {
     aPrs = *anIt;
-    if (!aPrs.feature())
+    if (!aPrs.result())
       continue;
     boost::shared_ptr<SketchPlugin_Feature> aSketchFeature = 
-                           boost::dynamic_pointer_cast<SketchPlugin_Feature>(aPrs.feature());
+                           boost::dynamic_pointer_cast<SketchPlugin_Feature>(aPrs.result());
     if (!aSketchFeature)
       continue;
     double aDelta = aSketchFeature->distanceToPoint(
                                boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, anY)));
     if (aMinDelta < 0 || aMinDelta > aDelta) {
       aMinDelta = aDelta;
-      aDeltaFeature = aPrs.feature();
+      // TODO aDeltaFeature = aPrs.result();
     }
   }
   return aDeltaFeature;
@@ -225,7 +225,7 @@ FeaturePtr PartSet_Tools::feature(FeaturePtr theFeature, const std::string& theA
   boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
           boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(theAttribute));
   if (anAttr) {
-    aFeature = anAttr->feature();
+    aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->object());
     if (!theKind.empty() && aFeature && aFeature->getKind() != theKind) {
       aFeature = FeaturePtr();
     }
@@ -277,14 +277,14 @@ void PartSet_Tools::setConstraints(FeaturePtr theSketch, FeaturePtr theFeature,
   boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
         boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aData->attribute(SketchPlugin_Sketch::FEATURES_ID()));
 
-  std::list<FeaturePtr > aFeatures = aRefList->list();
-  std::list<FeaturePtr >::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
+  std::list<ObjectPtr > aFeatures = aRefList->list();
+  std::list<ObjectPtr >::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
   std::list<boost::shared_ptr<ModelAPI_Attribute> > anAttiributes;
   boost::shared_ptr<GeomAPI_Pnt2d> aClickedPoint = boost::shared_ptr<GeomAPI_Pnt2d>
                                                      (new GeomAPI_Pnt2d(theClickedX, theClickedY));
   for (; anIt != aLast; anIt++)
   {
-    FeaturePtr aFeature = *anIt;
+    FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(*anIt);
     // find the given point in the feature attributes
     anAttiributes = aFeature->data()->attributes(GeomDataAPI_Point2D::type());
     std::list<boost::shared_ptr<ModelAPI_Attribute> >::const_iterator anIt = anAttiributes.begin(),
index 296f8daa6e8e44a8c49b56444befb1e539063cb4..1d6250afe4c3245bffd2b1be651f7af52b089a3b 100644 (file)
@@ -4,10 +4,16 @@
 
 #include "PartSet_Validators.h"
 
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <BRep_Tool.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <GeomAbs_CurveType.hxx>
+
 #include <list>
 
 
-int shapesNb(const ModuleBase_ISelection* theSelection, TopAbs_ShapeEnum theType)
+int shapesNbPoints(const ModuleBase_ISelection* theSelection)
 {
   std::list<ModuleBase_ViewerPrs> aList = theSelection->getSelected();
   std::list<ModuleBase_ViewerPrs>::iterator it;
@@ -17,21 +23,79 @@ int shapesNb(const ModuleBase_ISelection* theSelection, TopAbs_ShapeEnum theType
     aPrs = *it;
     const TopoDS_Shape& aShape = aPrs.shape();
     if (!aShape.IsNull()) {
-      if (aShape.ShapeType() == theType)
+      if (aShape.ShapeType() == TopAbs_VERTEX)
         aCount++;
     }
   }
   return aCount;
 }
 
+int shapesNbLines(const ModuleBase_ISelection* theSelection)
+{
+  std::list<ModuleBase_ViewerPrs> aList = theSelection->getSelected();
+  std::list<ModuleBase_ViewerPrs>::iterator it;
+  ModuleBase_ViewerPrs aPrs;
+  int aCount = 0;
+  for (it = aList.begin(); it != aList.end(); ++it) {
+    aPrs = *it;
+    const TopoDS_Shape& aShape = aPrs.shape();
+    if (!aShape.IsNull()) {
+      if (aShape.ShapeType() == TopAbs_EDGE) {
+        TopoDS_Edge aEdge = TopoDS::Edge(aShape);
+        Standard_Real aStart, aEnd;
+        Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aStart, aEnd);
+        GeomAdaptor_Curve aAdaptor(aCurve);
+        if (aAdaptor.GetType() == GeomAbs_Line)
+          aCount++;
+      }
+    }
+  }
+  return aCount;
+}
+
 bool PartSet_DistanceValidator::isValid(const ModuleBase_ISelection* theSelection) const
 {
-  int aCount = shapesNb(theSelection, TopAbs_VERTEX);
+  int aCount = shapesNbPoints(theSelection);
   return (aCount > 0) && (aCount < 3);
 }
 
 bool PartSet_LengthValidator::isValid(const ModuleBase_ISelection* theSelection) const
 {
-  int aCount = shapesNb(theSelection, TopAbs_EDGE);
-  return (aCount == 1);
-}
\ No newline at end of file
+  int aCount = shapesNbLines(theSelection);
+  return (aCount > 0) && (aCount < 2);
+}
+
+bool PartSet_PerpendicularValidator::isValid(const ModuleBase_ISelection* theSelection) const
+{
+  int aCount = shapesNbLines(theSelection);
+  return (aCount > 0) && (aCount < 3);
+}
+
+bool PartSet_ParallelValidator::isValid(const ModuleBase_ISelection* theSelection) const
+{
+  int aCount = shapesNbLines(theSelection);
+  return (aCount > 0) && (aCount < 3);
+}
+
+bool PartSet_RadiusValidator::isValid(const ModuleBase_ISelection* theSelection) const
+{
+  std::list<ModuleBase_ViewerPrs> aList = theSelection->getSelected();
+  std::list<ModuleBase_ViewerPrs>::iterator it;
+  ModuleBase_ViewerPrs aPrs;
+  int aCount = 0;
+  for (it = aList.begin(); it != aList.end(); ++it) {
+    aPrs = *it;
+    const TopoDS_Shape& aShape = aPrs.shape();
+    if (!aShape.IsNull()) {
+      if (aShape.ShapeType() == TopAbs_EDGE) {
+        TopoDS_Edge aEdge = TopoDS::Edge(aShape);
+        Standard_Real aStart, aEnd;
+        Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aStart, aEnd);
+        GeomAdaptor_Curve aAdaptor(aCurve);
+        if (aAdaptor.GetType() == GeomAbs_Circle)
+          aCount++;
+      }
+    }
+  }
+  return (aCount > 0) && (aCount < 2);
+}
index 10cdcf26a72e3fd5064ea39a6abbefc210746818..90487fe4f722de683f0cdee5caab1d4b69e4df83 100644 (file)
 #include <ModuleBase_SelectionValidator.h>
 #include <ModuleBase_ISelection.h>
 
+//! A class to validate a selection for Distance constraint operation
 class PartSet_DistanceValidator: public ModuleBase_SelectionValidator
 {
 public:
   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
 };
 
+//! A class to validate a selection for Length constraint operation
 class PartSet_LengthValidator: public ModuleBase_SelectionValidator
 {
 public:
   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
 };
 
+//! A class to validate a selection for Perpendicular constraint operation
+class PartSet_PerpendicularValidator: public ModuleBase_SelectionValidator
+{
+public:
+  PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
+};
+
+//! A class to validate a selection for Perpendicular constraint operation
+class PartSet_ParallelValidator: public ModuleBase_SelectionValidator
+{
+public:
+  PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
+};
+
+//! A class to validate a selection for Perpendicular constraint operation
+class PartSet_RadiusValidator: public ModuleBase_SelectionValidator
+{
+public:
+  PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
+};
+
 #endif
index 30cdaace39917bcbd8e9d58be4c8b06352435198..839b3ec57826adee4982677712e40741b255bab3 100644 (file)
@@ -23,9 +23,9 @@ public:
 
   /// Saves the internal parameters to the given feature
   /// \param theFeature a model feature to be changed
-  virtual bool storeValue(FeaturePtr theFeature) const { return true;}
+  virtual bool storeValue(ObjectPtr theFeature) const { return true;}
 
-  virtual bool restoreValue(FeaturePtr theFeature) { return true;}
+  virtual bool restoreValue(ObjectPtr theFeature) { return true;}
 
   /// Returns list of widget controls
   /// \return a control list
index 726f6487b7a1d8810b02219b4885fb3efd9669aa..d1032abf8a29e9c792adbb9cb842f903923c093f 100644 (file)
@@ -26,15 +26,15 @@ void PartSetPlugin_Duplicate::initAttributes()
     boost::shared_ptr<PartSetPlugin_Part> aSource; // searching for source document attribute
     for(int a = aRoot->size(getGroup()) - 1; a >= 0; a--) {
       aSource = boost::dynamic_pointer_cast<PartSetPlugin_Part>(
-        aRoot->feature(getGroup(), a, true));
+        aRoot->object(ModelAPI_Feature::group(), a));
       if (aSource->data()->docRef(PartSetPlugin_Part::DOC_REF())->value() == aPManager->currentDocument())
         break;
       aSource.reset();
     }
     if (aSource) {
       boost::shared_ptr<ModelAPI_Document> aCopy = 
-        aPManager->copy(aSource->data()->docRef(PartSetPlugin_Part::DOC_REF())->value(), data()->getName());
-      aRef->setFeature(aSource);
+        aPManager->copy(aSource->data()->docRef(PartSetPlugin_Part::DOC_REF())->value(), data()->name());
+      aRef->setObject(aSource);
     }
   }
 }
index 4fff734b89a53bcd5832e695875be50f8718a726..c8beaeac9bf40be39d76146398cc72cc0a0848fa 100644 (file)
@@ -7,6 +7,7 @@
 #include "ModelAPI_Document.h"
 #include "ModelAPI_Data.h"
 #include "ModelAPI_AttributeDocRef.h"
+#include <ModelAPI_ResultPart.h>
 
 using namespace std;
 
@@ -25,7 +26,12 @@ void PartSetPlugin_Part::execute()
   if (!aDocRef->value()) { // create a document if not yet created
     boost::shared_ptr<ModelAPI_Document> aPartSetDoc = 
       ModelAPI_PluginManager::get()->rootDocument();
-    aDocRef->setValue(aPartSetDoc->subDocument(data()->getName()));
+    aDocRef->setValue(aPartSetDoc->subDocument(data()->name()));
+  }
+  // create a result only once
+  if (results().empty()) {
+    boost::shared_ptr<ModelAPI_ResultPart> aResult = document()->createPart(data());
+    setResult(aResult);
   }
 }
 
index 2aea700f2a61f4a3e0fdaad6f2d9e485f20dee29..ca31737285e7b2c7b83ad9342b57fe4a7d2db1c9 100644 (file)
@@ -15,7 +15,8 @@ void PartSetPlugin_Remove::execute()
   boost::shared_ptr<ModelAPI_Document> aCurrent;
   boost::shared_ptr<PartSetPlugin_Part> a;
   for(int a = aRoot->size(getGroup()) - 1; a >= 0; a--) {
-    FeaturePtr aFeature = aRoot->feature(getGroup(), a, true);
+    FeaturePtr aFeature = 
+      boost::dynamic_pointer_cast<ModelAPI_Feature>(aRoot->object(ModelAPI_Feature::group(), a));
     if (aFeature->getKind() == PartSetPlugin_Part::ID()) {
       boost::shared_ptr<PartSetPlugin_Part> aPart = 
         boost::static_pointer_cast<PartSetPlugin_Part>(aFeature);
index 89e2185de2fb6031e8dc48730987cd049b364dbd..e5eb1f301197d75ec6452a0acc4a73849004dbfb 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,13 @@ 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(data());
+      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 cf57516a598a2811b877a2a33ab9731223529524..df87c1e3c2b616895a1ddcdaaa9acda36ba5fad4 100644 (file)
@@ -46,27 +46,16 @@ public:
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
   {static std::string MY_KIND = SketchPlugin_Arc::ID(); 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 = SketchPlugin_Sketch::ID(); 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);
-
-  /// 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) {};
+  virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
+                                boost::shared_ptr<GeomAPI_AISObject> thePrevious)
+  {return simpleAISObject(firstResult(), thePrevious);}
 
   /// Moves the feature
   /// \param theDeltaX the delta for X coordinate is moved
index 5438c216de51425caa7ee45c6d9671a92e709aae..60fd29daf7d9cf6714576c5d08aa4f5cf68af642 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()
@@ -29,10 +27,6 @@ void SketchPlugin_Circle::initAttributes()
 }
 
 void SketchPlugin_Circle::execute()
-{
-}
-
-const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Circle::preview()
 {
   SketchPlugin_Sketch* aSketch = sketch();
   if (aSketch) {
@@ -64,15 +58,12 @@ 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::shared_ptr<ModelAPI_ResultConstruction> aConstr = 
+        document()->createConstruction(data());
+      aConstr->setShape(aCompound);
+      setResult(aConstr);
   }
-  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 cf7de0330075a5167f17e752fba1ba1ba36ec4c6..43c2c982acb95976e9aa555b4badfd9a173c9439 100644 (file)
@@ -41,22 +41,16 @@ public:
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
   {static std::string MY_KIND = SketchPlugin_Circle::ID(); 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 = SketchPlugin_Sketch::ID(); return MY_GROUP;}
-
   /// Creates a new part document if needed
   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);
+  virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
+                                boost::shared_ptr<GeomAPI_AISObject> thePrevious)
+  {return simpleAISObject(firstResult(), thePrevious);}
 
   /// Adds sub-feature of the higher level feature (sub-element of the sketch)
   /// \param theFeature sub-feature
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 b46214fb8c8985a03bb66e4383f2d052e3905161..d0a76b1cfd6a7d51fb2fdad963c809d051481147 100644 (file)
@@ -97,9 +97,6 @@ public:
   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 3a5c2c31daecc9cee3a6005eaec32bc4aeb64855..3670b45ed41c8e5858ea9bccaae22bce112528d3 100644 (file)
@@ -30,10 +30,6 @@ public:
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
   {static std::string MY_KIND = SketchPlugin_ConstraintCoincidence::ID(); 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 = SketchPlugin_Sketch::ID(); return MY_GROUP;}
-
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
 
index 2896843c5a9a386bd773ef03cde6c43911b10fd1..4818f6608be77bf57e34471bd414b73c520edb16 100644 (file)
@@ -104,7 +104,7 @@ boost::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
   boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theData->attribute(theAttribute));
   if (anAttr)
-    aFeature = anAttr->feature();
+    aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->object());
 
   if (aFeature && aFeature->getKind() == SketchPlugin_Point::ID())
     aPointAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
index 9a538ab4a9f9619fe19e0cadd0cdbeb945bbcfd3..456ff056943eebb5946a8277da84dd386d724a84 100644 (file)
@@ -32,10 +32,6 @@ public:
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
   {static std::string MY_KIND = SketchPlugin_ConstraintDistance::ID(); 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 = SketchPlugin_Sketch::ID(); return MY_GROUP;}
-
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
 
index 1953add2b2477ddb974d8a800d5a8d954379fb44..f21aa9979389169d7ad90477c555952b0cf1403a 100644 (file)
@@ -33,7 +33,7 @@ void SketchPlugin_ConstraintLength::execute()
 
     boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
       boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
-    FeaturePtr aFeature = aRef->feature();
+    ObjectPtr aFeature = aRef->object();
     if (aFeature) {
       // set length value
       boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
@@ -62,7 +62,7 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintLength::getAISObject
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
   if (!anAttr)
     return thePrevious;
-  FeaturePtr aFeature = anAttr->feature();
+  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->object());
   if (!aFeature || aFeature->getKind() != SketchPlugin_Line::ID())
     return thePrevious;
 
index 237dc8e86c539e607a2bd163c0f924542da3a2f9..342bdf1f56e631da377950fb5800d14f02575bb0 100644 (file)
@@ -31,10 +31,6 @@ public:
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
   {static std::string MY_KIND = SketchPlugin_ConstraintLength::ID(); 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 = SketchPlugin_Sketch::ID(); return MY_GROUP;}
-
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
 
index 15cc861adfcdc6874905818d2d48d5b69926050d..aba3df37071afd63ec6d27605cb2c4a730ac0351 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_Data.h>
+#include <ModelAPI_ResultConstruction.h>
 
 #include <SketchPlugin_Line.h>
 #include <SketchPlugin_Sketch.h>
@@ -29,13 +30,6 @@ void SketchPlugin_ConstraintParallel::execute()
 {
 }
 
-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)
 {
@@ -47,19 +41,24 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintParallel::getAISObje
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
   boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr2 = 
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_B()));
-  if (!anAttr1 || !anAttr1->isFeature() || 
-      !anAttr2 || !anAttr2->isFeature())
+  if (!anAttr1 || !anAttr1->isObject() || 
+      !anAttr2 || !anAttr2->isObject())
     return thePrevious;
   boost::shared_ptr<SketchPlugin_Line> aLine1Feature = 
-    boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr1->feature());
+    boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr1->object());
   boost::shared_ptr<SketchPlugin_Line> aLine2Feature = 
-    boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr2->feature());
+    boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr2->object());
   if (!aLine1Feature || !aLine2Feature)
     return thePrevious;
 
   boost::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
-  boost::shared_ptr<GeomAPI_Shape> aLine1 = aLine1Feature->preview();
-  boost::shared_ptr<GeomAPI_Shape> aLine2 = aLine2Feature->preview();
+  boost::shared_ptr<GeomAPI_Shape> aLine1, aLine2;
+  boost::shared_ptr<ModelAPI_ResultConstruction> aConst1 = 
+    boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aLine1Feature->firstResult());
+  if (aConst1) aLine1 = aConst1->shape();
+  boost::shared_ptr<ModelAPI_ResultConstruction> aConst2 = 
+    boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aLine1Feature->firstResult());
+  if (aConst2) aLine2 = aConst2->shape();
 
   boost::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr = 
     boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
index 52e68fcd01cabea396019da5e03519f59aacd424..acfab864f1c5d93aacbd95cb0aa6ac3318fe7bad 100644 (file)
@@ -29,19 +29,12 @@ public:
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
   {static std::string MY_KIND = SketchPlugin_ConstraintParallel::ID(); 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 = SketchPlugin_Sketch::ID(); return MY_GROUP;}
-
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
 
   /// \brief Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
 
-  /// \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 0122202319de359e0ac029aece8f3ab9b5233b60..3f8281208ac998a224fcb6a31633ef40fe6262b1 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_Data.h>
+#include <ModelAPI_ResultConstruction.h>
 
 #include <SketchPlugin_Line.h>
 #include <SketchPlugin_Sketch.h>
@@ -29,12 +30,6 @@ void SketchPlugin_ConstraintPerpendicular::execute()
 {
 }
 
-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)
 {
@@ -46,19 +41,24 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintPerpendicular::getAI
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
   boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr2 = 
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_B()));
-  if (!anAttr1 || !anAttr1->isFeature() || 
-      !anAttr2 || !anAttr2->isFeature())
+  if (!anAttr1 || !anAttr1->isObject() || 
+      !anAttr2 || !anAttr2->isObject())
     return thePrevious;
   boost::shared_ptr<SketchPlugin_Line> aLine1Feature = 
-    boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr1->feature());
+    boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr1->object());
   boost::shared_ptr<SketchPlugin_Line> aLine2Feature = 
-    boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr2->feature());
+    boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr2->object());
   if (!aLine1Feature || !aLine2Feature)
     return thePrevious;
 
   boost::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
-  boost::shared_ptr<GeomAPI_Shape> aLine1 = aLine1Feature->preview();
-  boost::shared_ptr<GeomAPI_Shape> aLine2 = aLine2Feature->preview();
+  boost::shared_ptr<GeomAPI_Shape> aLine1, aLine2;
+  boost::shared_ptr<ModelAPI_ResultConstruction> aConst1 = 
+    boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aLine1Feature->firstResult());
+  if (aConst1) aLine1 = aConst1->shape();
+  boost::shared_ptr<ModelAPI_ResultConstruction> aConst2 = 
+    boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aLine1Feature->firstResult());
+  if (aConst2) aLine2 = aConst2->shape();
 
   boost::shared_ptr<GeomAPI_AISObject> anAIS = thePrevious;
   if (!anAIS)
index f6970a8952475241c9056875fe38b788fa29c252..eb82abd6fc700ebad7a4300b8e92c7786568585c 100644 (file)
@@ -29,19 +29,12 @@ public:
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
   {static std::string MY_KIND = SketchPlugin_ConstraintPerpendicular::ID(); 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 = SketchPlugin_Sketch::ID(); return MY_GROUP;}
-
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
 
   /// \brief Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
 
-  /// \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 0b4cd5a9b072899ebc69a792d9aeac7344906a27..9b412d1c615e44c882f756f091e073903ad43c0a 100644 (file)
@@ -37,7 +37,7 @@ void SketchPlugin_ConstraintRadius::execute()
 
     boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
       boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
-    FeaturePtr aFeature = aRef->feature();
+    FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aRef->object());
     if (aFeature) {
       double aRadius = 0;
       boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
@@ -73,7 +73,7 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintRadius::getAISObject
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
   if (!anAttr)
     return thePrevious;
-  FeaturePtr aFeature = anAttr->feature();
+  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->object());
   std::string aKind = aFeature ? aFeature->getKind() : "";
   if (aKind != SketchPlugin_Circle::ID() && aKind != SketchPlugin_Arc::ID())
     return thePrevious;
@@ -130,7 +130,7 @@ void SketchPlugin_ConstraintRadius::move(double theDeltaX, double theDeltaY)
 
   boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
-  FeaturePtr aFeature = aRef->feature();
+  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aRef->object());
   if (!aFeature)
     return;
   std::string aCenterAttrName;
index a3a85d8782c3f92c1cbd50c206464ea803b9c99f..a604ef1202de0fae5442817ab734e7b9cb4f6321 100644 (file)
@@ -29,10 +29,6 @@ public:
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
   {static std::string MY_KIND = SketchPlugin_ConstraintRadius::ID(); 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 = SketchPlugin_Sketch::ID(); return MY_GROUP;}
-
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
 
index d264007e3a6ff69b69530145a37b7c8fd73e5228..ee292a645dd5e1b5e6cd9d35cea28db66c262c2d 100644 (file)
@@ -4,22 +4,13 @@
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_AttributeRefList.h>
+#include <ModelAPI_ResultConstruction.h>
 
 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,11 +18,11 @@ 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 = 
+        std::list<ObjectPtr> aList =
           aSketch->data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->list();
-        std::list<FeaturePtr >::iterator aSub = aList.begin();
+        std::list<ObjectPtr>::iterator aSub = aList.begin();
         for(; aSub != aList.end(); aSub++) {
           if ((*aSub)->data()->isEqual(data())) {
             mySketch = aSketch.get();
@@ -44,10 +35,15 @@ SketchPlugin_Sketch* SketchPlugin_Feature::sketch()
   return mySketch;
 }
 
-boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Feature::prepareAISShape(
-                        boost::shared_ptr<GeomAPI_AISObject> thePrevious)
+boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Feature::simpleAISObject(
+    boost::shared_ptr<ModelAPI_Result> theRes, boost::shared_ptr<GeomAPI_AISObject> thePrevious)
 {
-  boost::shared_ptr<GeomAPI_Shape> aPreview = preview();
+  boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = 
+    boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theRes);
+
+  boost::shared_ptr<GeomAPI_Shape> aPreview;
+  if (aConstr) aPreview = aConstr->shape();
+
   boost::shared_ptr<GeomAPI_AISObject> aResult = thePrevious;
   if (!aResult)
     aResult = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject());
index 1cddba03f6f54600fe7abd634387d3fc96c83fde..6f1b3a66c691cdd62749826ac90fa460844c3af1 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,19 +23,18 @@ 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 AIS preview
   SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
                                 boost::shared_ptr<GeomAPI_AISObject> thePrevious) = 0;
 
+  /// Simple creation of interactive object by the result of the object
+  static boost::shared_ptr<GeomAPI_AISObject> simpleAISObject(
+    boost::shared_ptr<ModelAPI_Result> theRes, boost::shared_ptr<GeomAPI_AISObject> thePrevious);
+
   /// 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) = 0;
+    const FeaturePtr& theFeature) {};
 
   /// Returns true if this feature must be displayed in the history (top level of Part tree)
   SKETCHPLUGIN_EXPORT virtual bool isInHistory() {return false;}
@@ -49,15 +49,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 db0e86c86ada9afae4129ce96ef0f17579f1bb19..63577ef08b4605525090f6ce1e6e7641c17d0dc7 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>
@@ -30,10 +31,6 @@ void SketchPlugin_Line::initAttributes()
 }
 
 void SketchPlugin_Line::execute() 
-{
-}
-
-const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Line::preview()
 {
   SketchPlugin_Sketch* aSketch = sketch();
   if (aSketch) {
@@ -48,19 +45,15 @@ 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::shared_ptr<ModelAPI_ResultConstruction> aConstr = 
+        document()->createConstruction(data());
+      aConstr->setShape(anEdge);
+      setResult(aConstr);
     }
   }
-  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 2adb9a83320140d9cecb62921a9c1160a05b2124..ae301f82feb38f55a4fe3de2cfa27a8dac8d2f66 100644 (file)
@@ -40,27 +40,16 @@ public:
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
   {static std::string MY_KIND = SketchPlugin_Line::ID(); 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 = SketchPlugin_Sketch::ID(); return MY_GROUP;}
-
   /// Creates a new part document if needed
   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);
-
-  /// 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) {};
+                                boost::shared_ptr<GeomAPI_AISObject> thePrevious)
+  {return simpleAISObject(firstResult(), thePrevious);}
 
   /// Moves the feature
   /// \param theDeltaX the delta for X coordinate is moved
index fd60230de19c55fc1a343770269b42ec745afe05..5143b20a56626beb11434220a8cfa3509f4cbbfc 100644 (file)
@@ -6,6 +6,7 @@
 #include "SketchPlugin_Sketch.h"
 
 #include <ModelAPI_Data.h>
+#include <ModelAPI_ResultConstruction.h>
 
 #include <GeomAPI_Pnt2d.h>
 
@@ -24,10 +25,6 @@ void SketchPlugin_Point::initAttributes()
 }
 
 void SketchPlugin_Point::execute() 
-{
-}
-
-const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Point::preview()
 {
   SketchPlugin_Sketch* aSketch = sketch();
   if (aSketch) {
@@ -37,15 +34,10 @@ 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::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction(data());
+    aConstr->setShape(aPointShape);
+    setResult(aConstr);
   }
-  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 f4bf4f6a7d93c79723f8769ff5a77783ea363dc1..33ec0467e244f3ceabf491f40194f3dceed103ca 100644 (file)
@@ -33,27 +33,16 @@ public:
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
   {static std::string MY_KIND = SketchPlugin_Point::ID(); 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 = SketchPlugin_Sketch::ID(); return MY_GROUP;}
-
   /// Creates a new part document if needed
   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);
-
-  /// 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) {};
+  virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
+                                boost::shared_ptr<GeomAPI_AISObject> thePrevious)
+  {return simpleAISObject(firstResult(), thePrevious);}
 
   /// Moves the feature
   /// \param theDeltaX the delta for X coordinate is moved
index b0bf6e9f6f9f75fe3d8572f2312045263c2fdd80..dbfb247824c0f6c6fed9a1ab6e5cb5edd8fe1721 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
@@ -37,6 +38,19 @@ void SketchPlugin_Sketch::initAttributes()
 
 void SketchPlugin_Sketch::execute() 
 {
+  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::shared_ptr<ModelAPI_ResultConstruction> aConstr = 
+      document()->createConstruction(data());
+    aConstr->setShape(aCompound);
+    setResult(aConstr);
+    return;
+  }
   if (!data()->isValid())
     return ;
   boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
@@ -51,20 +65,22 @@ void SketchPlugin_Sketch::execute()
   boost::shared_ptr<GeomDataAPI_Dir> aNorm = 
     boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SketchPlugin_Sketch::NORM_ID()));
 
-  std::list<boost::shared_ptr<ModelAPI_Feature> > aFeatures = aRefList->list();
+  std::list<ObjectPtr> aFeatures = aRefList->list();
   if (aFeatures.empty())
     return ;
 
-  std::list<boost::shared_ptr<ModelAPI_Feature> >::const_iterator anIt = aFeatures.begin(),
-                                                                  aLast = aFeatures.end();
-
+  std::list<ObjectPtr>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
   boost::shared_ptr<SketchPlugin_Feature> aFeature;
   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>(aFeature->firstResult());
+    if (aRes) {
+      boost::shared_ptr<GeomAPI_Shape> aShape = aRes->shape();
+      if (aShape)
+        aFeaturesPreview.push_back(aShape);
+    }
   }
 
   if (aFeaturesPreview.empty())
@@ -76,34 +92,19 @@ 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::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction(data());
+  aConstr->setShape(aCompound);
+  setResult(aConstr);
 }
 
 boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Sketch::getAISObject(
                                 boost::shared_ptr<GeomAPI_AISObject> thePrevious)
 {
-  boost::shared_ptr<GeomAPI_AISObject> anAIS = prepareAISShape(thePrevious);
-  anAIS->setColor(SKETCH_PLANE_COLOR);
-  anAIS->setWidth(SKETCH_WIDTH);
+  boost::shared_ptr<GeomAPI_AISObject> aResult = simpleAISObject(firstResult(), thePrevious);
+  aResult->setColor(SKETCH_PLANE_COLOR);
+  aResult->setWidth(SKETCH_WIDTH);
   //anAIS->Redisplay();
-  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();
+  return aResult;
 }
 
 const void SketchPlugin_Sketch::addSub(const FeaturePtr& theFeature)
index 5cde6adadcb174fe0b8541fd21655b02262c615e..5fcab3c8b826ab83255979e70b7f4028acbf0124 100644 (file)
@@ -59,19 +59,12 @@ public:
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
   {static std::string MY_KIND = SketchPlugin_Sketch::ID(); 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 = "Construction"; return MY_GROUP;}
-
   /// Creates a new part document if needed
   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 3b5801e77067d33e723241a99add6bbbce914219..999d742d2d97ee4652cac06c8fec0cc8ad35cad2 100644 (file)
         <feature_or_attribute_selector id="ConstraintEntityB" label="Last point" tooltip="Select an point in the viewer" keysequence="SketchPoint Point2D"/>
         <point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
         <doublevalue_editor label="Value" tooltip="Constraint value" id="ConstraintValue"/>
+        <validator id="PartSet_DistanceValidator"/> 
       </feature>
       <feature id="SketchConstraintLength" title="Length" tooltip="Create constraint for the given length of a line segment">
         <label title="Select a line on which to calculate lenght" tooltip="Select a line on which to calculate lenght"/>
         <feature_selector id="ConstraintEntityA" label="Line" tooltip="Select an line in the viewer" keysequence="SketchLine"/>
         <point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
         <doublevalue_editor label="Value" tooltip="Constraint value" id="ConstraintValue"/>
+        <validator id="PartSet_LengthValidator"/> 
       </feature>
       <feature id="SketchConstraintRadius" title="Radius" tooltip="Create constraint for the given radius of a circle or an arc">
         <label title="Select a circle or an arc on which to calculate radius" tooltip="Select a circle or an arc on which to calculate radius"/>
         <feature_selector id="ConstraintEntityA" label="Circle or Arc" tooltip="Select a circle or an arc in the viewer" keysequence="SketchCircle SketchArc"/>
         <point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
         <doublevalue_editor label="Value" tooltip="Constraint value" id="ConstraintValue"/>
+        <validator id="PartSet_RadiusValidator"/>
       </feature>
       <feature id="SketchConstraintParallel" title="Parallel" tooltip="Create constraint defining two parallel lines">
         <feature_selector id="ConstraintEntityA" label="First line" tooltip="Select an line in the viewer" keysequence="SketchLine"/>
         <feature_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer" keysequence="SketchLine"/>
         <point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
+        <validator id="PartSet_ParallelValidator"/>
       </feature>
       <feature id="SketchConstraintPerpendicular" title="Perpendicular" tooltip="Create constraint defining two perpendicular lines">
         <feature_selector id="ConstraintEntityA" label="First line" tooltip="Select an line in the viewer" keysequence="SketchLine"/>
         <feature_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer" keysequence="SketchLine"/>
         <point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
+        <validator id="PartSet_PerpendicularValidator"/>
       </feature>
     </group>
   </workbench>
index 18bd68e2b4bffc73bdd0cc0264d44c91f3364619..05f261a69f11f1033e8773ceb0b81b496260f8cd 100644 (file)
@@ -104,9 +104,10 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
           theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr))
         );
       if (!anAttr) continue;
-      if (anAttr->isFeature() && anAttr->feature())
+      if (anAttr->isObject() && anAttr->object())
       { // verify posiible entities
-        const std::string& aKind = anAttr->feature()->getKind();
+        const std::string& aKind = boost::dynamic_pointer_cast<ModelAPI_Feature>
+          (anAttr->object())->getKind();
         if (aKind.compare(SketchPlugin_Point::ID()) == 0)
         {
           myAttributesList[aNbPoints++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr);
@@ -159,8 +160,9 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
           theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr))
         );
       if (!anAttr) continue;
-      if (anAttr->isFeature() && anAttr->feature() &&
-          anAttr->feature()->getKind().compare(SketchPlugin_Line::ID()) == 0)
+      if (anAttr->isObject() && anAttr->object() &&
+        boost::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->object())->getKind().
+        compare(SketchPlugin_Line::ID()) == 0)
       {
         myAttributesList[aNbLines++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr);
         break;
@@ -183,8 +185,9 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
         boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
           theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr))
         );
-      if (!anAttr || !anAttr->isFeature() || !anAttr->feature()) continue;
-      const std::string& aKind = anAttr->feature()->getKind();
+      if (!anAttr || !anAttr->isObject() || !anAttr->object()) continue;
+      const std::string& aKind = boost::dynamic_pointer_cast<ModelAPI_Feature>
+        (anAttr->object())->getKind();
       if (aKind.compare(SketchPlugin_Line::ID()) == 0)
       {
         myAttributesList[aNbEntities++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr);
@@ -206,8 +209,9 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
         boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
           theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr))
         );
-      if (!anAttr || !anAttr->isFeature() || !anAttr->feature()) continue;
-      const std::string& aKind = anAttr->feature()->getKind();
+      if (!anAttr || !anAttr->isObject() || !anAttr->object()) continue;
+      const std::string& aKind = boost::dynamic_pointer_cast<ModelAPI_Feature>
+        (anAttr->object())->getKind();
       if (aKind.compare(SketchPlugin_Circle::ID()) == 0 || aKind.compare(SketchPlugin_Arc::ID()) == 0)
       {
         myAttributesList[aNbEntities++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr);
index d2f1dcc424774f93882a28074cf94c6ad11294b9..7a06355f46a8675171b9cfe72d6652bf602b2cb4 100644 (file)
@@ -134,11 +134,12 @@ bool SketchSolver_ConstraintGroup::isInteract(
         theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(i))
       );
     if (!aCAttrRef) continue;
-    if (!aCAttrRef->isFeature() && 
+    if (!aCAttrRef->isObject() && 
         myEntityAttrMap.find(aCAttrRef->attr()) != myEntityAttrMap.end())
       return true;
-    if (aCAttrRef->isFeature() && 
-        myEntityFeatMap.find(aCAttrRef->feature()) != myEntityFeatMap.end())
+    if (aCAttrRef->isObject() && 
+        myEntityFeatMap.find(boost::dynamic_pointer_cast<ModelAPI_Feature>(aCAttrRef->object())) 
+        != myEntityFeatMap.end())
       return true;
   }
 
@@ -206,14 +207,15 @@ bool SketchSolver_ConstraintGroup::changeConstraint(
     // For the length constraint the start and end points of the line should be added to the entities list instead of line
     if (aConstrType == SLVS_C_PT_PT_DISTANCE && theConstraint->getKind().compare(SketchPlugin_ConstraintLength::ID()) == 0)
     {
-      boost::shared_ptr<ModelAPI_Data> aData = aConstrAttr->feature()->data();
+      boost::shared_ptr<ModelAPI_Data> aData = aConstrAttr->object()->data();
       aConstrEnt[indAttr]   = changeEntity(aData->attribute(SketchPlugin_Line::START_ID()));
       aConstrEnt[indAttr+1] = changeEntity(aData->attribute(SketchPlugin_Line::END_ID()));
-      myEntityFeatMap[aConstrAttr->feature()] = 0; // measured object is added into the map of objects to avoid problems with interaction betwee constraint and group
+       // measured object is added into the map of objects to avoid problems with interaction betwee constraint and group
+      myEntityFeatMap[boost::dynamic_pointer_cast<ModelAPI_Feature>(aConstrAttr->object())] = 0;
       break; // there should be no other entities
     }
-    else if (aConstrAttr->isFeature())
-      aConstrEnt[indAttr] = changeEntity(aConstrAttr->feature());
+    else if (aConstrAttr->isObject())
+      aConstrEnt[indAttr] = changeEntity(boost::dynamic_pointer_cast<ModelAPI_Feature>(aConstrAttr->object()));
     else
       aConstrEnt[indAttr] = changeEntity(aConstrAttr->attr());
   }
@@ -1155,12 +1157,12 @@ void SketchSolver_ConstraintGroup::updateRelatedConstraints(
       bool isUpd = (*anAttrIter == theEntity);
       boost::shared_ptr<ModelAPI_AttributeRefAttr> aRefAttr = 
         boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttrIter);
-      if (aRefAttr && !aRefAttr->isFeature() && aRefAttr->attr() == theEntity)
+      if (aRefAttr && !aRefAttr->isObject() && aRefAttr->attr() == theEntity)
         isUpd = true;
 
       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;
       }
@@ -1184,9 +1186,9 @@ void SketchSolver_ConstraintGroup::updateRelatedConstraints(
     {
       boost::shared_ptr<ModelAPI_AttributeRefAttr> aRefAttr = 
         boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttrIter);
-      if (aRefAttr && aRefAttr->isFeature() && aRefAttr->feature() == theFeature)
+      if (aRefAttr && aRefAttr->isObject() && aRefAttr->object() == 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 2976eca8f3ea7a35745adef7d4520c763fc0cb74..dbdc7b92791f83a88e3cc7484a2395c8eac8b4fe 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,42 +59,44 @@ 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);
-    std::set< FeaturePtr > aFeatures = anUpdateMsg->features();
+    const ModelAPI_ObjectUpdatedMessage* anUpdateMsg = 
+      dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
+    std::set< ObjectPtr > 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;
+      std::set< ObjectPtr >::iterator aFeatIter;
       for (aFeatIter = aFeatures.begin(); aFeatIter != aFeatures.end(); aFeatIter++)
       {
+        FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(*aFeatIter);
+        if (!aFeature) continue;
         // Only sketches and constraints can be added by Create event
-        const std::string& aFeatureKind = (*aFeatIter)->getKind();
+        const std::string& aFeatureKind = aFeature->getKind();
         if (aFeatureKind.compare(SketchPlugin_Sketch::ID()) == 0)
         {
           boost::shared_ptr<SketchPlugin_Feature> aSketch =
-            boost::dynamic_pointer_cast<SketchPlugin_Feature>(*aFeatIter);
+            boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
           if (aSketch)
             changeWorkplane(aSketch);
           continue;
         }
         boost::shared_ptr<SketchPlugin_Constraint> aConstraint =
-          boost::dynamic_pointer_cast<SketchPlugin_Constraint>(*aFeatIter);
+          boost::dynamic_pointer_cast<SketchPlugin_Constraint>(aFeature);
         if (aConstraint)
           changeConstraint(aConstraint);
         else
         {
           // Sketch plugin features can be only updated
-          boost::shared_ptr<SketchPlugin_Feature> aFeature =
-            boost::dynamic_pointer_cast<SketchPlugin_Feature>(*aFeatIter);
-          if (aFeature)
-            updateEntity(aFeature);
+          boost::shared_ptr<SketchPlugin_Feature> aSFeature =
+            boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+          if (aSFeature)
+            updateEntity(aSFeature);
         }
       }
     }
@@ -102,10 +104,10 @@ 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);
+    const ModelAPI_ObjectDeletedMessage* aDeleteMsg = 
+      dynamic_cast<const ModelAPI_ObjectDeletedMessage*>(theMessage);
     const std::set<std::string>& aFeatureGroups = aDeleteMsg->groups();
 
     // Find SketchPlugin_Sketch::ID() in groups. The constraint groups should be updated when an object removed from Sketch
@@ -351,8 +353,8 @@ boost::shared_ptr<SketchPlugin_Feature> SketchSolver_ConstraintManager::findWork
 
     boost::shared_ptr<ModelAPI_AttributeRefList> aWPFeatures =
       boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aWP->data()->attribute(SketchPlugin_Sketch::FEATURES_ID()));
-    std::list< FeaturePtr > aFeaturesList = aWPFeatures->list();
-    std::list< FeaturePtr >::const_iterator anIter;
+    std::list< ObjectPtr >& aFeaturesList = aWPFeatures->list();
+    std::list< ObjectPtr >::const_iterator anIter;
     for (anIter = aFeaturesList.begin(); anIter != aFeaturesList.end(); anIter++)
       if (*anIter == theConstraint)
         return aWP; // workplane is found
@@ -374,6 +376,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 58fb6809077b7559d4530428749cca2dcf8e7a4a..d7dcfce78ad8b04ea0c56d449391c2cfeaf5e8d2 100644 (file)
@@ -13,6 +13,7 @@
 #include <ModelAPI_Data.h>
 #include <ModelAPI_AttributeDocRef.h>
 #include <ModelAPI_Object.h>
+#include <ModelAPI_ResultPart.h>
 
 #include <QAction>
 #include <QContextMenuEvent>
@@ -99,27 +100,30 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const
 {
   QMenu* aMenu = new QMenu();
   XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
-  QFeatureList aFeatures = aSelMgr->selection()->selectedFeatures();
-  if (aFeatures.size() == 1) {
+  QList<ObjectPtr> aObjects = aSelMgr->selection()->selectedObjects();
+  if (aObjects.size() == 1) {
     PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
-    FeaturePtr aFeature = aFeatures.first();
+    ObjectPtr aObject = aObjects.first();
     //Process Feature
-    if (aFeature) {
-      if (aFeature->getKind() == PartSetPlugin_Part::ID()) {
-        ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
-        DocumentPtr aFeaDoc = aObject->featureRef()->data()->docRef("PartDocument")->value();
+    if (aObject) {
+      ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObject);
+      if (aPart) {
+        DocumentPtr aFeaDoc = aPart->document();
         if (aMgr->currentDocument() == aFeaDoc)
           aMenu->addAction(action("DEACTIVATE_PART_CMD"));
         else 
           aMenu->addAction(action("ACTIVATE_PART_CMD"));
       } else {
-        aMenu->addAction(action("EDIT_CMD"));
-
-        XGUI_Displayer* aDisplayer = myWorkshop->displayer();
-        if (aDisplayer->isVisible(aFeature))
-          aMenu->addAction(action("HIDE_CMD"));
-        else
-          aMenu->addAction(action("SHOW_CMD"));
+        ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(aObject);
+        if (aResult) {
+          aMenu->addAction(action("EDIT_CMD"));
+
+          XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+          if (aDisplayer->isVisible(aResult))
+            aMenu->addAction(action("HIDE_CMD"));
+          else
+            aMenu->addAction(action("SHOW_CMD"));
+        }
       }
       aMenu->addAction(action("DELETE_CMD"));
       aMenu->addSeparator();
@@ -153,13 +157,14 @@ QMenu* XGUI_ContextMenuMgr::viewerMenu() const
 void XGUI_ContextMenuMgr::addViewerItems(QMenu* theMenu) const
 {
   XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
-  QFeatureList aFeatures = aSelMgr->selection()->selectedFeatures();
-  if (aFeatures.size() > 0) {
-    if (aFeatures.size() == 1)
+  QList<ObjectPtr> aObjects = aSelMgr->selection()->selectedObjects();
+  if (aObjects.size() > 0) {
+    if (aObjects.size() == 1)
       theMenu->addAction(action("EDIT_CMD"));
     bool isVisible = false;
-    foreach(FeaturePtr aFeature, aFeatures) {
-      if (myWorkshop->displayer()->isVisible(aFeature)) {
+    foreach(ObjectPtr aObject, aObjects) {
+      ResultPtr aRes = boost::dynamic_pointer_cast<ModelAPI_Result>(aObject);
+      if (aRes && myWorkshop->displayer()->isVisible(aRes)) {
         isVisible = true;
         break;
       }
index 5b9f5a8394f4c2ec8c6d8fc74cab6db593ba8252..0b8844e2f494414f3874424e701b3c5ccadd1fe7 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Feature.h>
+#include <ModelAPI_ResultPart.h>
 
 #include <QAbstractItemModel>
 #include <QColor>
@@ -23,14 +24,14 @@ public:
 
   //! Returns Feature object by the given Model index.
   //! Returns 0 if the given index is not index of a feature
-  virtual FeaturePtr feature(const QModelIndex& theIndex) const = 0;
+  virtual ObjectPtr object(const QModelIndex& theIndex) const = 0;
 
   //! Returns QModelIndex which corresponds to the given feature
   //! If the feature is not found then index is not valid
-  virtual QModelIndex featureIndex(const FeaturePtr& theFeature) const = 0;
+  virtual QModelIndex objectIndex(const ObjectPtr& theFeature) const = 0;
 
   //! Returns parent index of the given feature
-  virtual QModelIndex findParent(const FeaturePtr& theFeature) const = 0;
+  virtual QModelIndex findParent(const ObjectPtr& theObject) const = 0;
 
   //! Returns index corresponded to the group
   virtual QModelIndex findGroup(const std::string& theGroup) const = 0;
@@ -60,7 +61,7 @@ public:
   virtual bool hasDocument(const DocumentPtr& theDoc) const = 0;
 
   //! Return a Part object
-  virtual FeaturePtr part() const = 0;
+  virtual ResultPartPtr part() const = 0;
 
 protected:
   //! Id of the current part object in the document
index 83f70bf14547149dfb23246cc61dce5aef25c2f1..ac6b3af89c6029d0d1712861addda58985ca1b57 100644 (file)
@@ -6,7 +6,7 @@
 #include "XGUI_Viewer.h"
 #include "XGUI_Workshop.h"
 #include "XGUI_ViewerProxy.h"
-#include "XGUI_Tools.h"
+#include "ModuleBase_Tools.h"
 
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Data.h>
@@ -35,33 +35,31 @@ XGUI_Displayer::~XGUI_Displayer()
 {
 }
 
-bool XGUI_Displayer::isVisible(FeaturePtr theFeature)
+bool XGUI_Displayer::isVisible(ResultPtr theResult)
 {
-  FeaturePtr aFeature = XGUI_Tools::realFeature(theFeature);
-  return myFeature2AISObjectMap.find(aFeature) != myFeature2AISObjectMap.end();
+  return myResult2AISObjectMap.find(theResult) != myResult2AISObjectMap.end();
 }
 
-bool XGUI_Displayer::display(FeaturePtr theFeature, bool isUpdateViewer)
+bool XGUI_Displayer::display(ResultPtr theResult, bool isUpdateViewer)
 {
-  FeaturePtr aFeature = XGUI_Tools::realFeature(theFeature);
-  boost::shared_ptr<GeomAPI_Shape> aShapePtr = aFeature->data()->shape();
+  boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModuleBase_Tools::shape(theResult);
 
   if (aShapePtr) {
     boost::shared_ptr<GeomAPI_AISObject> anAIS(new GeomAPI_AISObject());
     anAIS->createShape(aShapePtr);
-    return display(aFeature, anAIS, isUpdateViewer);
+    return display(theResult, anAIS, isUpdateViewer);
   }
   return false;
 }
 
-bool XGUI_Displayer::display(FeaturePtr theFeature,
+bool XGUI_Displayer::display(ResultPtr theResult,
                              boost::shared_ptr<GeomAPI_AISObject> theAIS, bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
 
   Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
   if (!anAISIO.IsNull()) {
-    myFeature2AISObjectMap[theFeature] = theAIS;
+    myResult2AISObjectMap[theResult] = theAIS;
     aContext->Display(anAISIO, isUpdateViewer);
     return true;
   }
@@ -70,16 +68,14 @@ bool XGUI_Displayer::display(FeaturePtr theFeature,
 
 
 
-void XGUI_Displayer::erase(FeaturePtr theFeature,
+void XGUI_Displayer::erase(ResultPtr theResult,
                            const bool isUpdateViewer)
 {
-  FeaturePtr aFeature = XGUI_Tools::realFeature(theFeature);
-
-  if (myFeature2AISObjectMap.find(aFeature) == myFeature2AISObjectMap.end())
+  if (myResult2AISObjectMap.find(theResult) == myResult2AISObjectMap.end())
     return;
 
   Handle(AIS_InteractiveContext) aContext = AISContext();
-  boost::shared_ptr<GeomAPI_AISObject> anObject = myFeature2AISObjectMap[aFeature];
+  boost::shared_ptr<GeomAPI_AISObject> anObject = myResult2AISObjectMap[theResult];
   if (anObject)  {
     Handle(AIS_InteractiveObject) anAIS = anObject->impl<Handle(AIS_InteractiveObject)>();
     if (!anAIS.IsNull()) {
@@ -87,11 +83,11 @@ void XGUI_Displayer::erase(FeaturePtr theFeature,
       
     }
   }
-  myFeature2AISObjectMap.erase(aFeature);
+  myResult2AISObjectMap.erase(theResult);
 }
 
 
-bool XGUI_Displayer::redisplay(FeaturePtr theFeature,
+bool XGUI_Displayer::redisplay(ResultPtr theFeature,
                                boost::shared_ptr<GeomAPI_AISObject> theAIS,
                                const bool isUpdateViewer)
 {
@@ -108,12 +104,12 @@ bool XGUI_Displayer::redisplay(FeaturePtr theFeature,
     //aContext->SetPixelTolerance(MOUSE_SENSITIVITY_IN_PIXEL);
   }
   // display or redisplay presentation
-  boost::shared_ptr<GeomAPI_AISObject> anObj = myFeature2AISObjectMap[theFeature];
+  boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[theFeature];
   if (isVisible(theFeature) && anObj && !anObj->empty()) {
       aContext->RecomputeSelectionOnly(anAIS);
   }
   else {
-    myFeature2AISObjectMap[theFeature] = theAIS;
+    myResult2AISObjectMap[theFeature] = theAIS;
     aContext->Display(anAIS, false);
     isCreated = true;
   }
@@ -123,15 +119,14 @@ bool XGUI_Displayer::redisplay(FeaturePtr theFeature,
   return isCreated;
 }
 
-bool XGUI_Displayer::redisplay(FeaturePtr theFeature, bool isUpdateViewer)
+bool XGUI_Displayer::redisplay(ResultPtr theResult, bool isUpdateViewer)
 {
-  FeaturePtr aFeature = XGUI_Tools::realFeature(theFeature);
-  if (!isVisible(aFeature))
+  if (!isVisible(theResult))
     return false;
 
-  boost::shared_ptr<GeomAPI_Shape> aShapePtr = aFeature->data()->shape();
+  boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModuleBase_Tools::shape(theResult);
   if (aShapePtr) {
-    boost::shared_ptr<GeomAPI_AISObject> aAISObj = getAISObject(aFeature);
+    boost::shared_ptr<GeomAPI_AISObject> aAISObj = getAISObject(theResult);
     Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(aAISObj->impl<Handle(AIS_InteractiveObject)>());
     if (!aAISShape.IsNull()) {
       aAISShape->Set(aShapePtr->impl<TopoDS_Shape>());
@@ -142,7 +137,7 @@ bool XGUI_Displayer::redisplay(FeaturePtr theFeature, bool isUpdateViewer)
   return false;
 }
 
-void XGUI_Displayer::activateInLocalContext(FeaturePtr theFeature,
+void XGUI_Displayer::activateInLocalContext(ResultPtr theResult,
                                          const std::list<int>& theModes, const bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
@@ -153,9 +148,9 @@ void XGUI_Displayer::activateInLocalContext(FeaturePtr theFeature,
   }
   // display or redisplay presentation
   Handle(AIS_InteractiveObject) anAIS;
-  if (isVisible(theFeature))
+  if (isVisible(theResult))
   {
-    boost::shared_ptr<GeomAPI_AISObject> anObj = myFeature2AISObjectMap[theFeature];
+    boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[theResult];
     if (anObj)
       anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
   }
@@ -176,18 +171,18 @@ void XGUI_Displayer::activateInLocalContext(FeaturePtr theFeature,
     updateViewer();
 }
 
-void XGUI_Displayer::stopSelection(const QFeatureList& theFeatures, const bool isStop,
+void XGUI_Displayer::stopSelection(const QResultList& theResults, const bool isStop,
                                    const bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
 
   Handle(AIS_Shape) anAIS;
-  QFeatureList::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
-  FeaturePtr aFeature;
+  QResultList::const_iterator anIt = theResults.begin(), aLast = theResults.end();
+  ResultPtr aFeature;
   for (; anIt != aLast; anIt++) {
     aFeature = *anIt;
     if (isVisible(aFeature))
-      anAIS = Handle(AIS_Shape)::DownCast(myFeature2AISObjectMap[aFeature]->impl<Handle(AIS_InteractiveObject)>());
+      anAIS = Handle(AIS_Shape)::DownCast(myResult2AISObjectMap[aFeature]->impl<Handle(AIS_InteractiveObject)>());
     if (anAIS.IsNull())
       continue;
 
@@ -206,7 +201,7 @@ void XGUI_Displayer::stopSelection(const QFeatureList& theFeatures, const bool i
     updateViewer();
 }
 
-void XGUI_Displayer::setSelected(const QFeatureList& theFeatures, const bool isUpdateViewer)
+void XGUI_Displayer::setSelected(const QResultList& theResults, const bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
   // we need to unhighligth objects manually in the current local context
@@ -216,12 +211,11 @@ void XGUI_Displayer::setSelected(const QFeatureList& theFeatures, const bool isU
     aLocalContext->UnhilightLastDetected(myWorkshop->viewer()->activeView());
 
   aContext->ClearSelected();
-  foreach(FeaturePtr aFeature, theFeatures) {
-    FeaturePtr aRFeature = XGUI_Tools::realFeature(aFeature);
-    if (myFeature2AISObjectMap.find(aRFeature) == myFeature2AISObjectMap.end()) 
+  foreach(ResultPtr aResult, theResults) {
+    if (myResult2AISObjectMap.find(aResult) == myResult2AISObjectMap.end()) 
       return;
 
-    boost::shared_ptr<GeomAPI_AISObject> anObj = myFeature2AISObjectMap[aRFeature];
+    boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[aResult];
     if (anObj)
     {
       Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
@@ -249,21 +243,21 @@ void XGUI_Displayer::setSelected(const QFeatureList& theFeatures, const bool isU
     Handle(AIS_InteractiveObject) anIO = anIter.Value();
     ic->Erase(anIO, false);
   }
-  myFeature2AISObjectMap.clear();
+  myResult2AISObjectMap.clear();
   if (isUpdateViewer)
     updateViewer();
 }*/
 
-void XGUI_Displayer::eraseDeletedFeatures(const bool isUpdateViewer)
+void XGUI_Displayer::eraseDeletedResults(const bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
 
-  FeatureToAISMap::const_iterator aFIt = myFeature2AISObjectMap.begin(),
-                                  aFLast = myFeature2AISObjectMap.end();
-  std::list<FeaturePtr> aRemoved;
+  ResultToAISMap::const_iterator aFIt = myResult2AISObjectMap.begin(),
+                                 aFLast = myResult2AISObjectMap.end();
+  std::list<ResultPtr> aRemoved;
   for (; aFIt != aFLast; aFIt++)
   {
-    FeaturePtr aFeature = (*aFIt).first;
+    ResultPtr aFeature = (*aFIt).first;
     if (!aFeature || !aFeature->data() || !aFeature->data()->isValid()) {
       boost::shared_ptr<GeomAPI_AISObject> anObj = (*aFIt).second;
       if (!anObj) continue;
@@ -274,10 +268,10 @@ void XGUI_Displayer::eraseDeletedFeatures(const bool isUpdateViewer)
       }
     }
   }
-  std::list<FeaturePtr>::const_iterator anIt = aRemoved.begin(),
+  std::list<ResultPtr>::const_iterator anIt = aRemoved.begin(),
                                                                  aLast = aRemoved.end();
   for (; anIt != aLast; anIt++) {
-    myFeature2AISObjectMap.erase(myFeature2AISObjectMap.find(*anIt));
+    myResult2AISObjectMap.erase(myResult2AISObjectMap.find(*anIt));
   }
 
   if (isUpdateViewer)
@@ -290,19 +284,19 @@ void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer)
 }
 
 boost::shared_ptr<GeomAPI_AISObject> XGUI_Displayer::getAISObject(
-                                              FeaturePtr theFeature) const
+                                              ResultPtr theFeature) const
 {
   boost::shared_ptr<GeomAPI_AISObject> anIO;
-  if (myFeature2AISObjectMap.find(theFeature) != myFeature2AISObjectMap.end())
-    anIO = (myFeature2AISObjectMap.find(theFeature))->second;
+  if (myResult2AISObjectMap.find(theFeature) != myResult2AISObjectMap.end())
+    anIO = (myResult2AISObjectMap.find(theFeature))->second;
   return anIO;
 }
 
-FeaturePtr XGUI_Displayer::getFeature(Handle(AIS_InteractiveObject) theIO) const
+ResultPtr XGUI_Displayer::getResult(Handle(AIS_InteractiveObject) theIO) const
 {
-  FeaturePtr aFeature;
-  FeatureToAISMap::const_iterator aFIt = myFeature2AISObjectMap.begin(),
-                                  aFLast = myFeature2AISObjectMap.end();
+  ResultPtr aFeature;
+  ResultToAISMap::const_iterator aFIt = myResult2AISObjectMap.begin(),
+                                 aFLast = myResult2AISObjectMap.end();
   for (; aFIt != aFLast && !aFeature; aFIt++) {
     boost::shared_ptr<GeomAPI_AISObject> anObj = (*aFIt).second;
     if (!anObj) continue;
index 2c730c9e8b01ee60ef8b9a119512dd912bcc69e0..e047af515d0da44e9ec35017b378781364b47018 100644 (file)
@@ -17,7 +17,7 @@
 #include <AIS_InteractiveContext.hxx>
 #include <NCollection_List.hxx>
 
-#include <ModelAPI_Feature.h>
+#include <ModelAPI_Result.h>
 
 #include <ModuleBase_Definitions.h>
 #include <ModuleBase_ViewerPrs.h>
@@ -49,27 +49,27 @@ public:
 
   /// Returns the feature visibility state.
   /// \param theFeature a feature instance
-  bool isVisible(FeaturePtr theFeature);
+  bool isVisible(ResultPtr theResult);
 
   /// Display the feature. Obtain the visualized object from the feature.
   /// \param theFeature a feature instance
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
   /// Returns true if the Feature succesfully displayed
-  bool display(FeaturePtr theFeature, bool isUpdateViewer = true);
+  bool display(ResultPtr theFeature, bool isUpdateViewer = true);
 
   /// Display the feature and a shape. This shape would be associated to the given feature
   /// \param theFeature a feature instance
   /// \param theAIS AIS presentation
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
   /// Returns true if the Feature succesfully displayed
-  bool display(FeaturePtr theFeature, boost::shared_ptr<GeomAPI_AISObject> theAIS, bool isUpdateViewer = true);
+  bool display(ResultPtr theResult, boost::shared_ptr<GeomAPI_AISObject> theAIS, bool isUpdateViewer = true);
   
   /// Display the shape and activate selection of sub-shapes
   /// \param theFeature a feature instance
   /// \param theAIS an AIS object
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
   /// \returns true if the presentation is created
-  bool redisplay(FeaturePtr theFeature,
+  bool redisplay(ResultPtr theFeature,
                  boost::shared_ptr<GeomAPI_AISObject> theAIS, 
                  const bool isUpdateViewer = true);
 
@@ -77,7 +77,7 @@ public:
   * \param theFeature a feature instance
   * \param isUpdateViewer the parameter whether the viewer should be update immediatelly
   */
-  bool redisplay(FeaturePtr theFeature, bool isUpdateViewer = true);
+  bool redisplay(ResultPtr theFeature, bool isUpdateViewer = true);
 
   /// Redisplay the shape and activate selection of sub-shapes
   /// \param theFeature a feature instance
@@ -89,14 +89,14 @@ public:
   /// \param theShape a shape
   /// \param theMode a list of local selection modes
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  void activateInLocalContext(FeaturePtr theFeature,
+  void activateInLocalContext(ResultPtr theFeature,
                               const std::list<int>& theModes, const bool isUpdateViewer = true);
 
   /// Stop the current selection and color the given features to the selection color
   /// \param theFeatures a list of features to be disabled
   /// \param theToStop the boolean state whether it it stopped or non stopped
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  void stopSelection(const QFeatureList& theFeatures, const bool isStop,
+  void stopSelection(const QResultList& theFeatures, const bool isStop,
                      const bool isUpdateViewer);
 
   /**
@@ -104,12 +104,12 @@ public:
   * \param theFeatures a list of features to be selected
   * isUpdateViewer the parameter whether the viewer should be update immediatelly
   */
-  void setSelected(const QFeatureList& theFeatures, bool isUpdateViewer = true);
+  void setSelected(const QResultList& theFeatures, bool isUpdateViewer = true);
 
   /// Erase the feature and a shape.
   /// \param theFeature a feature instance
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  void erase(FeaturePtr theFeature, const bool isUpdateViewer = true);
+  void erase(ResultPtr theResult, const bool isUpdateViewer = true);
 
   /// Erase all presentations
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
@@ -117,7 +117,7 @@ public:
 
   /// Erase AIS interactive objects, which has an empty feature in the internal map
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  void eraseDeletedFeatures(const bool isUpdateViewer = true);
+  void eraseDeletedResults(const bool isUpdateViewer = true);
 
   /// Deactivates selection of sub-shapes
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
@@ -129,12 +129,12 @@ public:
   /// Searches the interactive object by feature
   /// \param theFeature the feature or NULL if it not visualized
   /// \return theIO an interactive object
-  boost::shared_ptr<GeomAPI_AISObject> getAISObject(FeaturePtr theFeature) const;
+  boost::shared_ptr<GeomAPI_AISObject> getAISObject(ResultPtr theFeature) const;
 
   /// Searches the feature by interactive object
   /// \param theIO an interactive object
   /// \return feature the feature or NULL if it not visualized
-  FeaturePtr getFeature(Handle(AIS_InteractiveObject) theIO) const;
+  ResultPtr getResult(Handle(AIS_InteractiveObject) theIO) const;
 
 protected:
   /// Deactivate local selection
@@ -147,8 +147,8 @@ protected:
 protected:
   XGUI_Workshop* myWorkshop;
 
-  typedef std::map<FeaturePtr, boost::shared_ptr<GeomAPI_AISObject> > FeatureToAISMap;
-  FeatureToAISMap myFeature2AISObjectMap;
+  typedef std::map<ResultPtr, boost::shared_ptr<GeomAPI_AISObject> > ResultToAISMap;
+  ResultToAISMap myResult2AISObjectMap;
 };
 
 
index a7d6c3c8b46bd9a87204bcc99e0a146ed87a4320..1e62ae84e367d05021044188d12ad1cb2d6a232c 100644 (file)
@@ -7,6 +7,7 @@
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Data.h>
+#include <ModelAPI_ResultPart.h>
 #include <Model_Events.h>
 #include <ModelAPI_Object.h>
 
@@ -26,9 +27,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,16 +48,16 @@ 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)) {
-    const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
-    std::set<FeaturePtr> aFeatures = aUpdMsg->features();
+  if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
+    const Model_ObjectUpdatedMessage* aUpdMsg = dynamic_cast<const Model_ObjectUpdatedMessage*>(theMessage);
+    std::set<ObjectPtr> aFeatures = aUpdMsg->features();
 
-    std::set<FeaturePtr>::const_iterator aIt;
+    std::set<ObjectPtr>::const_iterator aIt;
     for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
-      FeaturePtr aFeature = (*aIt);
+      ObjectPtr aFeature = (*aIt);
       DocumentPtr aDoc = aFeature->document();
       if (aDoc == aRootDoc) {  // If root objects
-        if (aFeature->getGroup().compare(ModelAPI_Document::PARTS_GROUP()) == 0) { // Update only Parts group
+        if (aFeature->groupName().compare(ModelAPI_ResultPart::group()) == 0) { // Update only Parts group
           // Add a new part
           int aStart = myPartModels.size();
           XGUI_PartDataModel* aModel = new XGUI_PartDataModel(this);
@@ -87,8 +88,8 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
       }
     }
   // Deleted object event ***********************
-  } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_DELETED)) {
-    const Model_FeatureDeletedMessage* aUpdMsg = dynamic_cast<const Model_FeatureDeletedMessage*>(theMessage);
+  } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
+    const Model_ObjectDeletedMessage* aUpdMsg = dynamic_cast<const Model_ObjectDeletedMessage*>(theMessage);
     DocumentPtr aDoc = aUpdMsg->document();
     std::set<std::string> aGroups = aUpdMsg->groups();
 
@@ -96,7 +97,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
     for (aIt = aGroups.begin(); aIt != aGroups.end(); ++aIt) {
       std::string aGroup = (*aIt);
       if (aDoc == aRootDoc) {  // If root objects
-        if (aGroup.compare(ModelAPI_Document::PARTS_GROUP()) == 0) { // Updsate only Parts group
+        if (aGroup.compare(ModelAPI_ResultPart::group()) == 0) { // Updsate only Parts group
           int aStart = myPartModels.size() - 1;
           removeSubModel(aStart);
           removeRow(aStart, partFolderNode());
@@ -129,9 +130,9 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
       }
     }
   // Deleted object event ***********************
-  } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_UPDATED)) {
-    //const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
-    //FeaturePtr aFeature = aUpdMsg->feature();
+  } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {
+    //const Model_ObjectUpdatedMessage* aUpdMsg = dynamic_cast<const Model_ObjectUpdatedMessage*>(theMessage);
+    //ObjectPtr aFeature = aUpdMsg->feature();
     //DocumentPtr aDoc = aFeature->document();
     
     // TODO: Identify the necessary index by the modified feature
@@ -151,7 +152,7 @@ void XGUI_DocumentDataModel::rebuildDataTree()
   beginResetModel();
   clearModelIndexes();
 
-  int aNbParts = aRootDoc->size(ModelAPI_Document::PARTS_GROUP());
+  int aNbParts = aRootDoc->size(ModelAPI_ResultPart::group());
   if (myPartModels.size() != aNbParts) { // resize internal models
     while (myPartModels.size() > aNbParts) {
       delete myPartModels.last();
@@ -192,13 +193,14 @@ QVariant XGUI_DocumentDataModel::data(const QModelIndex& theIndex, int theRole)
     {
       int aOffset = historyOffset();
       DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-      FeaturePtr aFeature = aRootDoc->feature(ModelAPI_Document::FEATURES_GROUP(), theIndex.row() - aOffset);
+      ObjectPtr aObj = aRootDoc->object(ModelAPI_Feature::group(), theIndex.row() - aOffset);
+      FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
       if (!aFeature)
         return QVariant();
       switch (theRole) {
       case Qt::DisplayRole:
         if (aFeature)
-          return aFeature->data()->getName().c_str();
+          return aFeature->data()->name().c_str();
         else 
           return QVariant();
       case Qt::DecorationRole:
@@ -236,7 +238,7 @@ int XGUI_DocumentDataModel::rowCount(const QModelIndex& theParent) const
     // Size of external models
     int aVal = historyOffset();
     // Plus history size
-    aVal += aRootDoc->size(ModelAPI_Document::FEATURES_GROUP());
+    aVal += aRootDoc->size(ModelAPI_Feature::group());
     return aVal;
   }
   if (theParent.internalId() == PartsFolder) {
@@ -357,21 +359,21 @@ void XGUI_DocumentDataModel::clearModelIndexes()
   myIndexes.clear();
 }
 
-FeaturePtr XGUI_DocumentDataModel::feature(const QModelIndex& theIndex) const
+ObjectPtr XGUI_DocumentDataModel::object(const QModelIndex& theIndex) const
 {
   if (theIndex.internalId() == PartsFolder)
-    return FeaturePtr();
+    return ObjectPtr();
   if (theIndex.internalId() == HistoryNode) {
     DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
     int aOffset = historyOffset();
-    return aRootDoc->feature(ModelAPI_Document::FEATURES_GROUP(), theIndex.row() - aOffset);
+    return aRootDoc->object(ModelAPI_Feature::group(), theIndex.row() - aOffset);
   }
   QModelIndex* aIndex = toSourceModelIndex(theIndex);
   if (!isSubModel(aIndex->model())) 
-    return FeaturePtr();
+    return ObjectPtr();
 
   const XGUI_FeaturesModel* aModel = dynamic_cast<const XGUI_FeaturesModel*>(aIndex->model());
-  return aModel->feature(*aIndex);
+  return aModel->object(*aIndex);
 }
 
 bool XGUI_DocumentDataModel::insertRows(int theRow, int theCount, const QModelIndex& theParent)
@@ -474,11 +476,11 @@ bool XGUI_DocumentDataModel::activatedIndex(const QModelIndex& theIndex)
   return false;
 }
 
-FeaturePtr XGUI_DocumentDataModel::activePart() const
+ResultPartPtr XGUI_DocumentDataModel::activePart() const
 {
   if (myActivePart) 
     return myActivePart->part();
-  return FeaturePtr();
+  return ResultPartPtr();
 }
 
 void XGUI_DocumentDataModel::deactivatePart() 
@@ -493,21 +495,19 @@ void XGUI_DocumentDataModel::deactivatePart()
 Qt::ItemFlags XGUI_DocumentDataModel::flags(const QModelIndex& theIndex) const
 {
   Qt::ItemFlags aFlags = QAbstractItemModel::flags(theIndex);
-  if (feature(theIndex)) {
+  if (object(theIndex)) {
     aFlags |= Qt::ItemIsEditable;
   }
   return aFlags;
 }
 
-QModelIndex XGUI_DocumentDataModel::partIndex(const FeaturePtr& theFeature) const 
+QModelIndex XGUI_DocumentDataModel::partIndex(const ResultPartPtr& theObject) const 
 {
-  FeaturePtr aFeature = XGUI_Tools::realFeature(theFeature);
-
   int aRow = -1;
   XGUI_PartModel* aModel = 0;
   foreach (XGUI_PartModel* aPartModel, myPartModels) {
     aRow++;
-    if (aPartModel->part() == aFeature) {
+    if (aPartModel->part() == theObject) {
       aModel = aPartModel;
       break;
     }
@@ -518,22 +518,22 @@ QModelIndex XGUI_DocumentDataModel::partIndex(const FeaturePtr& theFeature) cons
   return QModelIndex();
 }
 
-QModelIndex XGUI_DocumentDataModel::featureIndex(const FeaturePtr theFeature) const
+QModelIndex XGUI_DocumentDataModel::objectIndex(const ObjectPtr theObject) const
 {
   // Check that this feature belongs to root document
   DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-  DocumentPtr aDoc = theFeature->document();
+  DocumentPtr aDoc = theObject->document();
   if (aDoc == aRootDoc) {
     // This feature belongs to histrory or top model
-    if (theFeature->isInHistory()) {
+    if (theObject->isInHistory()) {
       int aId;
-      for (aId = 0; aId < aRootDoc->size(ModelAPI_Document::FEATURES_GROUP()); aId++) {
-        if (theFeature == aRootDoc->feature(ModelAPI_Document::FEATURES_GROUP(), aId))
+      for (aId = 0; aId < aRootDoc->size(ModelAPI_Feature::group()); aId++) {
+        if (theObject == aRootDoc->object(ModelAPI_Feature::group(), aId))
           break;
       }
       return index(aId + historyOffset(), 0, QModelIndex());
     } else {
-      QModelIndex aIndex = myModel->featureIndex(theFeature);
+      QModelIndex aIndex = myModel->objectIndex(theObject);
       return aIndex.isValid()? 
         createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex)) :
         QModelIndex();
@@ -547,7 +547,7 @@ QModelIndex XGUI_DocumentDataModel::featureIndex(const FeaturePtr theFeature) co
       }
     }
     if (aPartModel) {
-      QModelIndex aIndex = aPartModel->featureIndex(theFeature);
+      QModelIndex aIndex = aPartModel->objectIndex(theObject);
       return aIndex.isValid()? 
         createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex)) :
         QModelIndex();
index c6b924bb438889be075bd0dee34ba7ea40a445fc..c49c6696535871e683459407e8214527a01de0a4 100644 (file)
@@ -4,10 +4,11 @@
 
 #include "XGUI.h"
 #include <ModuleBase_Definitions.h>
+#include <ModelAPI_ResultPart.h>
 
-#include <QAbstractItemModel>
 #include <Events_Listener.h>
 
+#include <QAbstractItemModel>
 #include <QList>
 
 class ModelAPI_Document;
@@ -52,22 +53,22 @@ public:
 
   Qt::ItemFlags flags(const QModelIndex& theIndex) const;
 
-  //! Returns Feature object by the given Model index.
-  //! Returns 0 if the given index is not index of a feature
-  FeaturePtr feature(const QModelIndex& theIndex) const;
+  //! Returns an object by the given Model index.
+  //! Returns 0 if the given index is not index of an object
+  ObjectPtr object(const QModelIndex& theIndex) const;
 
-  QModelIndex featureIndex(const FeaturePtr theFeature) const;
+  QModelIndex objectIndex(const ObjectPtr theObject) const;
 
-  //! Returns QModelIndex which corresponds to the given feature if this is a part
-  //! If the feature is not found then index is not valid
-  QModelIndex partIndex(const FeaturePtr& theFeature) const;
+  //! Returns QModelIndex which corresponds to the given part
+  //! If the object is not found then index is not valid
+  QModelIndex partIndex(const ResultPartPtr& thePart) const;
 
   //! Activates a part data model if the index is a Part node index. 
   //! Returns true if active part changed.
   bool activatedIndex(const QModelIndex& theIndex);
 
-  //! Retrurns Feature which corresponds to active part
-  FeaturePtr activePart() const;
+  //! Retrurns active part
+  ResultPartPtr activePart() const;
 
   //! Retrurns QModelIndex of active part
   QModelIndex activePartIndex() const { return myActivePartIndex; }
index 9cb80fa224e46d212bd1fd4524d198df0f976934..e0a73617035736ea89f879d93330433aaa97f683 100644 (file)
@@ -28,9 +28,9 @@ Handle(AIS_InteractiveContext) XGUI_ModuleConnector::AISContext() const
 }
 
 
-QFeatureList XGUI_ModuleConnector::selectedFeatures() const
+QList<ObjectPtr> XGUI_ModuleConnector::selectedObjects() const
 {
-  return myWorkshop->selector()->selection()->selectedFeatures();
+  return myWorkshop->selector()->selection()->selectedObjects();
 }
 
 ModuleBase_IModule* XGUI_ModuleConnector::module() const
index 8ef06b3217cd9abced8e794b33bb1324701c53e3..c7119b79ee7494de674dc2fbd690048e269ce184 100644 (file)
@@ -29,7 +29,7 @@ public:
   virtual Handle(AIS_InteractiveContext) AISContext() const;
 
   //! Returns list of currently selected data objects
-  virtual QFeatureList selectedFeatures() const; 
+  virtual QList<ObjectPtr> selectedObjects() const; 
 
   //! Returns instance of loaded module
   virtual ModuleBase_IModule* module() const;
index 27b92756283b4e6304239e698a03adb627b4ba26..6e61fef19bb19e453c7b639dcfff76a50b73d550 100644 (file)
@@ -46,9 +46,9 @@ void XGUI_DataTree::onSelectionChanged(const QItemSelection& theSelected,
   XGUI_DocumentDataModel* aModel = dataModel();
   QModelIndexList::const_iterator aIt;
   for (aIt = aIndexes.constBegin(); aIt != aIndexes.constEnd(); ++aIt) {
-    FeaturePtr aFeature = aModel->feature(*aIt);
-    if (aFeature)
-      mySelectedData.append(aFeature);
+    ObjectPtr aObject = aModel->object(*aIt);
+    if (aObject)
+      mySelectedData.append(aObject);
   }
   emit selectionChanged();
 }
@@ -83,13 +83,10 @@ void XGUI_DataTree::commitData(QWidget* theEditor)
   QLineEdit* aEditor = dynamic_cast<QLineEdit*>(theEditor);
   if (aEditor) {
     QString aRes = aEditor->text();
-    FeaturePtr aFeature = mySelectedData.first();
+    ObjectPtr aFeature = mySelectedData.first();
     PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
     aMgr->rootDocument()->startOperation();
-    if (!XGUI_Tools::isModelObject(aFeature))
-      aFeature->data()->setName(qPrintable(aRes));
-    else
-      boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature)->setName(qPrintable(aRes));
+    aFeature->data()->setName(qPrintable(aRes));
     aMgr->rootDocument()->finishOperation();
   }
 }
@@ -147,15 +144,15 @@ XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent)
   aLabelWgt->setFrameShadow(myTreeView->frameShadow());
 
   connect(myTreeView, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
-  connect(myTreeView, SIGNAL(activePartChanged(FeaturePtr)), this, SLOT(onActivePartChanged(FeaturePtr)));
-  connect(myTreeView, SIGNAL(activePartChanged(FeaturePtr)), this, SIGNAL(activePartChanged(FeaturePtr)));
+  connect(myTreeView, SIGNAL(activePartChanged(ObjectPtr)), this, SLOT(onActivePartChanged(ObjectPtr)));
+  connect(myTreeView, SIGNAL(activePartChanged(ObjectPtr)), this, SIGNAL(activePartChanged(ObjectPtr)));
 
   connect(myActiveDocLbl, SIGNAL(customContextMenuRequested(const QPoint&)), 
           this, SLOT(onLabelContextMenuRequested(const QPoint&)));
   connect(myTreeView, SIGNAL(contextMenuRequested(QContextMenuEvent*)), 
           this, SLOT(onContextMenuRequested(QContextMenuEvent*)));
   
-  onActivePartChanged(FeaturePtr());
+  onActivePartChanged(ObjectPtr());
 
   // Create internal actions
   QAction* aAction = new QAction(QIcon(":pictures/rename_edit.png"), tr("Rename"), this);
@@ -170,7 +167,7 @@ XGUI_ObjectsBrowser::~XGUI_ObjectsBrowser()
 }
 
 //***************************************************
-void XGUI_ObjectsBrowser::onActivePartChanged(FeaturePtr thePart)
+void XGUI_ObjectsBrowser::onActivePartChanged(ObjectPtr thePart)
 {
   QPalette aPalet = myActiveDocLbl->palette();
   if (thePart) {
@@ -191,8 +188,8 @@ bool XGUI_ObjectsBrowser::eventFilter(QObject* obj, QEvent* theEvent)
           myTreeView->setExpanded(myDocModel->activePartIndex(), false);
         }
         myDocModel->deactivatePart();
-        onActivePartChanged(FeaturePtr());
-        emit activePartChanged(FeaturePtr());
+        onActivePartChanged(ObjectPtr());
+        emit activePartChanged(ObjectPtr());
       }
     } else {
       // End of editing by mouse click
@@ -235,7 +232,7 @@ void XGUI_ObjectsBrowser::closeDocNameEditing(bool toSave)
 }
 
 //***************************************************
-void XGUI_ObjectsBrowser::activatePart(const FeaturePtr& thePart)
+void XGUI_ObjectsBrowser::activatePart(const ResultPartPtr& thePart)
 {
   if (thePart) {
     QModelIndex aIndex = myDocModel->partIndex(thePart);
@@ -248,9 +245,9 @@ void XGUI_ObjectsBrowser::activatePart(const FeaturePtr& thePart)
       if (myDocModel->activePartIndex().isValid()) {
         myTreeView->setExpanded(aIndex.parent(), true);
         myTreeView->setExpanded(aIndex, true);
-        onActivePartChanged(myDocModel->feature(aIndex));
+        onActivePartChanged(myDocModel->object(aIndex));
       } else {
-        onActivePartChanged(FeaturePtr());
+        onActivePartChanged(ObjectPtr());
       }
     }
   } else {
@@ -258,7 +255,7 @@ void XGUI_ObjectsBrowser::activatePart(const FeaturePtr& thePart)
     if (aIndex.isValid()) {
       myDocModel->activatedIndex(aIndex);
       myTreeView->setExpanded(aIndex, false);
-      onActivePartChanged(FeaturePtr());
+      onActivePartChanged(ObjectPtr());
     }
   }
 }
@@ -266,8 +263,8 @@ void XGUI_ObjectsBrowser::activatePart(const FeaturePtr& thePart)
 //***************************************************
 void XGUI_ObjectsBrowser::onContextMenuRequested(QContextMenuEvent* theEvent) 
 {
-  myFeaturesList = myTreeView->selectedFeatures();
-  bool toEnable = myFeaturesList.size() > 0;
+  myObjectsList = myTreeView->selectedObjects();
+  bool toEnable = myObjectsList.size() > 0;
   foreach(QAction* aCmd, actions()) {
     aCmd->setEnabled(toEnable);
   }
@@ -277,9 +274,9 @@ void XGUI_ObjectsBrowser::onContextMenuRequested(QContextMenuEvent* theEvent)
 //***************************************************
 void XGUI_ObjectsBrowser::onLabelContextMenuRequested(const QPoint& thePnt)
 {
-  myFeaturesList.clear();
+  myObjectsList.clear();
   //Empty feature pointer means that selected root document
-  myFeaturesList.append(FeaturePtr()); 
+  myObjectsList.append(ObjectPtr()); 
 
   foreach(QAction* aCmd, actions()) {
     aCmd->setEnabled(true);
@@ -291,14 +288,14 @@ void XGUI_ObjectsBrowser::onLabelContextMenuRequested(const QPoint& thePnt)
 //***************************************************
 void XGUI_ObjectsBrowser::onEditItem()
 {
-  if (myFeaturesList.size() > 0) {
-    FeaturePtr aFeature = myFeaturesList.first();
+  if (myObjectsList.size() > 0) {
+    ObjectPtr aFeature = myObjectsList.first();
     if (aFeature) { // Selection happens in TreeView
       // Find index which corresponds the feature
       QModelIndex aIndex;
       foreach(QModelIndex aIdx, selectedIndexes()) {
-        FeaturePtr aFea = dataModel()->feature(aIdx);
-        if (dataModel()->feature(aIdx)->isSame(aFeature)) {
+        ObjectPtr aFea = dataModel()->object(aIdx);
+        if (dataModel()->object(aIdx)->isSame(aFeature)) {
           aIndex = aIdx;
           break;
         }
@@ -320,7 +317,7 @@ void XGUI_ObjectsBrowser::onEditItem()
 //***************************************************
 void XGUI_ObjectsBrowser::onSelectionChanged()
 {
-  myFeaturesList = myTreeView->selectedFeatures();
+  myObjectsList = myTreeView->selectedObjects();
   emit selectionChanged();
 }
 
@@ -332,14 +329,14 @@ void XGUI_ObjectsBrowser::rebuildDataTree()
 }
 
 //***************************************************
-void XGUI_ObjectsBrowser::setFeaturesSelected(const QFeatureList& theFeatures)
+void XGUI_ObjectsBrowser::setObjectsSelected(const QList<ObjectPtr>& theObjects)
 {
   QList<QModelIndex> theIndexes;
   QItemSelectionModel* aSelectModel = myTreeView->selectionModel();
   aSelectModel->clear();
 
-  foreach(FeaturePtr aFeature, theFeatures) {
-    QModelIndex aIndex = myDocModel->featureIndex(aFeature);
+  foreach(ObjectPtr aFeature, theObjects) {
+    QModelIndex aIndex = myDocModel->objectIndex(aFeature);
     if (aIndex.isValid()) {
       aSelectModel->select(aIndex, QItemSelectionModel::Select);
     }
index a1e5c5ef1dd4b5bfbc04684db0424fb5cb07cbef..05a539566d5a8bdd438314ae52c8a61a8f94b4bc 100644 (file)
@@ -4,6 +4,8 @@
 
 #include "XGUI.h"
 #include <ModuleBase_Definitions.h>
+#include <ModelAPI_Object.h>
+#include <ModelAPI_ResultPart.h>
 
 #include <QWidget>
 #include <QTreeView>
@@ -19,15 +21,15 @@ public:
   XGUI_DataTree(QWidget* theParent);
   virtual ~XGUI_DataTree();
 
-  //! Returns list of currently selected features
-  QFeatureList selectedFeatures() const { return mySelectedData; }
+  //! Returns list of currently selected objects
+  QList<ObjectPtr> selectedObjects() const { return mySelectedData; }
 
   XGUI_DocumentDataModel* dataModel() const;
 
 signals:
   //! Emited when selection is changed
   void selectionChanged();
-  void activePartChanged(FeaturePtr thePart); 
+  void activePartChanged(ObjectPtr thePart); 
  
   //! Emited on context menu request
   void contextMenuRequested(QContextMenuEvent* theEvent);
@@ -45,7 +47,7 @@ private slots:
 
 private:
   //! List of currently selected data
-  QFeatureList mySelectedData;
+  QList<ObjectPtr> mySelectedData;
 };
 
 
@@ -63,10 +65,10 @@ public:
   //! Returns Model which provides access to data objects
   XGUI_DocumentDataModel* dataModel() const { return myDocModel; }
 
-  //! Returns list of currently selected features
-  QFeatureList selectedFeatures() const { return myFeaturesList; }
+  //! Returns list of currently selected objects
+  QList<ObjectPtr> selectedObjects() const { return myObjectsList; }
 
-  void setFeaturesSelected(const QFeatureList& theFeatures);
+  void setObjectsSelected(const QList<ObjectPtr>& theObjects);
 
   //! Returns currently selected indexes
   QModelIndexList selectedIndexes() const { return myTreeView->selectionModel()->selectedIndexes(); }
@@ -75,7 +77,7 @@ public:
   XGUI_DataTree* treeView() const { return myTreeView; }
 
   //! Activates currently selected part. Signal activePartChanged will not be sent
-  void activatePart(const FeaturePtr& thePart);
+  void activatePart(const ResultPartPtr& thePart);
 
   void rebuildDataTree();
 
@@ -84,7 +86,7 @@ signals:
   void selectionChanged();
 
   //! Emited when current active document is changed
-  void activePartChanged(FeaturePtr thePart); 
+  void activePartChanged(ObjectPtr thePart); 
  
   //! Emited on context menu request
   void contextMenuRequested(QContextMenuEvent* theEvent);
@@ -93,7 +95,7 @@ protected:
   virtual bool eventFilter(QObject* obj, QEvent* theEvent);
 
 private slots:
-  void onActivePartChanged(FeaturePtr thePart);
+  void onActivePartChanged(ObjectPtr thePart);
   void onContextMenuRequested(QContextMenuEvent* theEvent);
   void onLabelContextMenuRequested(const QPoint& thePnt);
 
@@ -111,7 +113,7 @@ private:
   QLineEdit* myActiveDocLbl;
   XGUI_DataTree* myTreeView;
 
-  QFeatureList myFeaturesList;
+  QList<ObjectPtr> myObjectsList;
 };
 
 #endif
\ No newline at end of file
index 82dcc853209a70dcd63ecdac56af5df14c182336..521e193c21e966ab5ff64ba9049d996fe981535f 100644 (file)
@@ -4,15 +4,19 @@
 #include <ModelAPI_PluginManager.h>
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Feature.h>
+#include <ModelAPI_Result.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_AttributeDocRef.h>
 #include <ModelAPI_Object.h>
+#include <ModelAPI_ResultPart.h>
+#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_ResultParameters.h>
 
 #include <QIcon>
 #include <QBrush>
 
 
-//FeaturePtr featureObj(const FeaturePtr& theFeature)
+//ObjectPtr featureObj(const ObjectPtr& theFeature)
 //{
 //  ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(theFeature);
 //  if (aObject)
@@ -42,18 +46,18 @@ QVariant XGUI_TopDataModel::data(const QModelIndex& theIndex, int theRole) const
     case ParamObject:
       {
         DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-        FeaturePtr aFeature = aRootDoc->feature(ModelAPI_Document::PARAMETERS_GROUP(), theIndex.row());
-        if (aFeature)
-          return boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature)->getName().c_str();
+        ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultParameters::group(), theIndex.row());
+        if (aObject)
+          return boost::dynamic_pointer_cast<ModelAPI_Object>(aObject)->data()->name().c_str();
       } 
     case ConstructFolder:
         return tr("Constructions") + QString(" (%1)").arg(rowCount(theIndex));
     case ConstructObject:
       {
         DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-        FeaturePtr aFeature = aRootDoc->feature(ModelAPI_Document::CONSTRUCTIONS_GROUP(), theIndex.row());
-        if (aFeature)
-          return boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature)->getName().c_str();
+        ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row());
+        if (aObject)
+          return boost::dynamic_pointer_cast<ModelAPI_Object>(aObject)->data()->name().c_str();
       }
     }
     break;
@@ -66,12 +70,13 @@ QVariant XGUI_TopDataModel::data(const QModelIndex& theIndex, int theRole) const
     case ConstructFolder:
       return QIcon(":pictures/constr_folder.png");
     case ConstructObject:
-      {
-        DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-        FeaturePtr aFeature = aRootDoc->feature(ModelAPI_Document::CONSTRUCTIONS_GROUP(), theIndex.row());
-        if (aFeature)
-          return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind()));
-      }
+      return QIcon(":pictures/constr_object.png");
+      //{
+      //  DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
+      //  ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row());
+      //  if (aObject)
+      //    return QIcon(XGUI_Workshop::featureIcon(aObject->getKind()));
+      //}
     }
     break;
 
@@ -97,11 +102,10 @@ int XGUI_TopDataModel::rowCount(const QModelIndex& theParent) const
 
   DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
   if (theParent.internalId() == ParamsFolder)
-    return aRootDoc->size(ModelAPI_Document::PARAMETERS_GROUP());
+    return aRootDoc->size(ModelAPI_ResultParameters::group());
 
   if (theParent.internalId() == ConstructFolder)
-    return aRootDoc->size(ModelAPI_Document::CONSTRUCTIONS_GROUP());
-
+    return aRootDoc->size(ModelAPI_ResultConstruction::group());
   return 0;
 }
 
@@ -149,59 +153,59 @@ bool XGUI_TopDataModel::hasChildren(const QModelIndex& theParent) const
   return rowCount(theParent) > 0;
 }
 
-FeaturePtr XGUI_TopDataModel::feature(const QModelIndex& theIndex) const
+ObjectPtr XGUI_TopDataModel::object(const QModelIndex& theIndex) const
 {
   switch (theIndex.internalId()) {
   case ParamsFolder:
   case ConstructFolder:
-    return FeaturePtr();
+    return ObjectPtr();
   case ParamObject:
     {
       DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-      return aRootDoc->feature(ModelAPI_Document::PARAMETERS_GROUP(), theIndex.row());
+      return aRootDoc->object(ModelAPI_ResultParameters::group(), theIndex.row());
     }
   case ConstructObject:
     {
       DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-      return aRootDoc->feature(ModelAPI_Document::CONSTRUCTIONS_GROUP(), theIndex.row());
+      return aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row());
     }
   }
-  return FeaturePtr();
+  return ObjectPtr();
 }
 
 
-QModelIndex XGUI_TopDataModel::findParent(const FeaturePtr& theFeature) const
+QModelIndex XGUI_TopDataModel::findParent(const ObjectPtr& theObject) const
 {
-  return findGroup(theFeature->getGroup().c_str());
+  return findGroup(theObject->groupName().c_str());
 }
 
 QModelIndex XGUI_TopDataModel::findGroup(const std::string& theGroup) const
 {
-  if (theGroup.compare(ModelAPI_Document::PARAMETERS_GROUP()) == 0)
+  if (theGroup.compare(ModelAPI_ResultParameters::group()) == 0)
     return createIndex(0, 0, (qint32) ParamsFolder);
-  if (theGroup.compare(ModelAPI_Document::CONSTRUCTIONS_GROUP()) == 0)
+  if (theGroup.compare(ModelAPI_ResultConstruction::group()) == 0)
     return createIndex(1, 0, (qint32) ConstructFolder);
   return QModelIndex();
 }
 
-QModelIndex XGUI_TopDataModel::featureIndex(const FeaturePtr& theFeature) const
+QModelIndex XGUI_TopDataModel::objectIndex(const ObjectPtr& theObject) const
 {
   QModelIndex aIndex;
-  if (theFeature) {
+  if (theObject) {
     DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-    std::string aGroup = theFeature->getGroup();
+    std::string aGroup = theObject->groupName();
     int aNb = aRootDoc->size(aGroup);
     int aRow = -1;
     for (int i = 0; i < aNb; i++) {
-      if (aRootDoc->feature(aGroup, i) == theFeature) {
+      if (aRootDoc->object(aGroup, i) == theObject) {
         aRow = i;
         break;
       }
     }
     if (aRow != -1) {
-      if (aGroup.compare(ModelAPI_Document::PARAMETERS_GROUP()) == 0)
+      if (aGroup.compare(ModelAPI_ResultParameters::group()) == 0)
         return createIndex(aRow, 0, (qint32) ParamObject);
-      if (aGroup.compare(ModelAPI_Document::CONSTRUCTIONS_GROUP()) == 0)
+      if (aGroup.compare(ModelAPI_ResultConstruction::group()) == 0)
         return createIndex(aRow, 0, (qint32) ConstructObject);
     }
   }
@@ -232,9 +236,9 @@ QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) cons
     case MyRoot:
       {
         DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-        FeaturePtr aFeature = aRootDoc->feature(ModelAPI_Document::PARTS_GROUP(), myId);
-        if (aFeature)
-          return boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature)->getName().c_str();
+        ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), myId);
+        if (aObject)
+          return boost::dynamic_pointer_cast<ModelAPI_Object>(aObject)->data()->name().c_str();
       }
     case ParamsFolder:
       return tr("Parameters") + QString(" (%1)").arg(rowCount(theIndex));
@@ -244,21 +248,21 @@ QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) cons
       return tr("Bodies") + QString(" (%1)").arg(rowCount(theIndex));
     case ParamObject:
       {
-        FeaturePtr aFeature = featureDocument()->feature(ModelAPI_Document::PARAMETERS_GROUP(), theIndex.row());
-        if (aFeature)
-          return boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature)->getName().c_str();
+        ObjectPtr aObject = partDocument()->object(ModelAPI_ResultParameters::group(), theIndex.row());
+        if (aObject)
+          return boost::dynamic_pointer_cast<ModelAPI_Object>(aObject)->data()->name().c_str();
       }
     case ConstructObject:
       {
-        FeaturePtr aFeature = featureDocument()->feature(ModelAPI_Document::CONSTRUCTIONS_GROUP(), theIndex.row());
-        if (aFeature)
-          return boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature)->getName().c_str();
+        ObjectPtr aObject = partDocument()->object(ModelAPI_ResultConstruction::group(), theIndex.row());
+        if (aObject)
+          return boost::dynamic_pointer_cast<ModelAPI_Object>(aObject)->data()->name().c_str();
       }
     case HistoryObject:
       {
-        FeaturePtr aFeature = featureDocument()->feature(ModelAPI_Document::FEATURES_GROUP(), theIndex.row() - 3);
-        if (aFeature)
-          return aFeature->data()->getName().c_str();
+        ObjectPtr aObject = partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - 3);
+        if (aObject)
+          return aObject->data()->name().c_str();
       }
     }
     break;
@@ -273,14 +277,16 @@ QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) cons
     case BodiesFolder:
       return QIcon(":pictures/constr_folder.png");
     case ConstructObject:
-      {
-        FeaturePtr aFeature = featureDocument()->feature(ModelAPI_Document::CONSTRUCTIONS_GROUP(), theIndex.row());
-        if (aFeature)
-          return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind()));
-      }
+      return QIcon(":pictures/constr_object.png");
+      //{
+      //  ObjectPtr aObject = partDocument()->object(ModelAPI_ResultConstruction::group(), theIndex.row());
+      //  if (aObject)
+      //    return QIcon(XGUI_Workshop::featureIcon(aObject->getKind()));
+      //}
     case HistoryObject:
       {
-        FeaturePtr aFeature = featureDocument()->feature(ModelAPI_Document::FEATURES_GROUP(), theIndex.row() - 3);
+        ObjectPtr aObject = partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - 3);
+        FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObject);
         if (aFeature)
           return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind()));
       }
@@ -305,18 +311,18 @@ int XGUI_PartDataModel::rowCount(const QModelIndex& parent) const
 {
   if (!parent.isValid()) {
     DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-    if (aRootDoc->feature(ModelAPI_Document::PARTS_GROUP(), myId))
+    if (aRootDoc->object(ModelAPI_ResultPart::group(), myId))
       return 1;
     else 
       return 0;
   }
   switch (parent.internalId()) {
   case MyRoot:
-    return 3 + featureDocument()->size(ModelAPI_Document::FEATURES_GROUP());
+    return 3 + partDocument()->size(ModelAPI_Feature::group());
   case ParamsFolder:
-    return featureDocument()->size(ModelAPI_Document::PARAMETERS_GROUP());
+    return partDocument()->size(ModelAPI_ResultParameters::group());
   case ConstructFolder:
-    return featureDocument()->size(ModelAPI_Document::CONSTRUCTIONS_GROUP());
+    return partDocument()->size(ModelAPI_ResultConstruction::group());
   case BodiesFolder:
     return 0;
   }
@@ -380,85 +386,86 @@ bool XGUI_PartDataModel::hasChildren(const QModelIndex& theParent) const
 }
 
 
-DocumentPtr XGUI_PartDataModel::featureDocument() const
+DocumentPtr XGUI_PartDataModel::partDocument() const
 {
   DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-  FeaturePtr aFeature = aRootDoc->feature(ModelAPI_Document::PARTS_GROUP(), myId, true);
-  return aFeature->data()->docRef("PartDocument")->value();
+  ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), myId);
+  return aObject->data()->docRef("PartDocument")->value();
 }
  
-FeaturePtr XGUI_PartDataModel::feature(const QModelIndex& theIndex) const
+ObjectPtr XGUI_PartDataModel::object(const QModelIndex& theIndex) const
 {
   switch (theIndex.internalId()) {
   case MyRoot:
     {
       DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-      return aRootDoc->feature(ModelAPI_Document::PARTS_GROUP(), myId);
+      return aRootDoc->object(ModelAPI_ResultPart::group(), myId);
     }
   case ParamsFolder:
   case ConstructFolder:
   case BodiesFolder:
-    return FeaturePtr();
+    return ObjectPtr();
   case ParamObject:
-    return featureDocument()->feature(ModelAPI_Document::PARAMETERS_GROUP(), theIndex.row());
+    return partDocument()->object(ModelAPI_ResultParameters::group(), theIndex.row());
   case ConstructObject:
-    return featureDocument()->feature(ModelAPI_Document::CONSTRUCTIONS_GROUP(), theIndex.row());
+    return partDocument()->object(ModelAPI_ResultConstruction::group(), theIndex.row());
   //case BodiesObject:
-  //  return featureDocument()->feature(ModelAPI_Document::CONSTRUCTIONS_GROUP(), theIndex.row());
+  //  return partDocument()->feature(ModelAPI_ResultConstruction::group(), theIndex.row());
   case HistoryObject:
-    return featureDocument()->feature(ModelAPI_Document::FEATURES_GROUP(), theIndex.row() - 3);
+    return partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - 3); 
   }
-  return FeaturePtr();
+  return ObjectPtr();
 }
 
 bool XGUI_PartDataModel::hasDocument(const DocumentPtr& theDoc) const
 {
-  return (featureDocument() == theDoc);
+  return (partDocument() == theDoc);
 }
 
 
-QModelIndex XGUI_PartDataModel::findParent(const FeaturePtr& theFeature) const
+QModelIndex XGUI_PartDataModel::findParent(const ObjectPtr& theObject) const
 {
-  return findGroup(theFeature->getGroup().c_str());
+  return findGroup(theObject->groupName().c_str());
 }
 
 QModelIndex XGUI_PartDataModel::findGroup(const std::string& theGroup) const
 {
-  if (theGroup.compare(ModelAPI_Document::PARAMETERS_GROUP()) == 0)
+  if (theGroup.compare(ModelAPI_ResultParameters::group()) == 0)
     return createIndex(0, 0, (qint32) ParamsFolder);
-  if (theGroup.compare(ModelAPI_Document::CONSTRUCTIONS_GROUP()) == 0)
+  if (theGroup.compare(ModelAPI_ResultConstruction::group()) == 0)
     return createIndex(1, 0, (qint32) ConstructFolder);
   return QModelIndex();
 }
 
-FeaturePtr XGUI_PartDataModel::part() const
+ResultPartPtr XGUI_PartDataModel::part() const
 {
   DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-  return aRootDoc->feature(ModelAPI_Document::PARTS_GROUP(), myId, true);
+  ObjectPtr aObj = aRootDoc->object(ModelAPI_ResultPart::group(), myId);
+  return boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
 }
 
-QModelIndex XGUI_PartDataModel::featureIndex(const FeaturePtr& theFeature) const
+QModelIndex XGUI_PartDataModel::objectIndex(const ObjectPtr& theObject) const
 {
   QModelIndex aIndex;
-  if (theFeature) {
-    if (part() == theFeature
+  if (theObject) {
+    if (part() == theObject
       return aIndex;
 
     //std::string aGroup = theFeature->getGroup();
-    DocumentPtr aDoc = theFeature->document();
-    int aNb = aDoc->size(ModelAPI_Document::FEATURES_GROUP());
+    DocumentPtr aDoc = theObject->document();
+    int aNb = aDoc->size(ModelAPI_Feature::group());
     int aRow = -1;
     for (int i = 0; i < aNb; i++) {
-      if (aDoc->feature(ModelAPI_Document::FEATURES_GROUP(), i) == theFeature) {
+      if (aDoc->object(ModelAPI_Feature::group(), i) == theObject) {
         aRow = i;
         break;
       }
     }
     if (aRow != -1) {
       return createIndex(aRow + 3, 0, (qint32) HistoryObject);
-/*      if (aGroup.compare(PARAMETERS_GROUP) == 0)
+/*      if (aGroup.compare(ModelAPI_ResultParameters::group()) == 0)
         return createIndex(aRow, 0, (qint32) ParamObject);
-      if (aGroup.compare(CONSTRUCTIONS_GROUP) == 0)
+      if (aGroup.compare(ModelAPI_ResultConstruction::group()) == 0)
         return createIndex(aRow, 0, (qint32) ConstructObject);*/
     }
   }
index fabadeb8b076829ac42f27163cb0b9d36b373316..b170ec1cd701b96f0890a193e0d41ab42874b59d 100644 (file)
@@ -32,16 +32,16 @@ public:
 
   virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
 
-  //! Returns Feature object by the given Model index.
-  //! Returns 0 if the given index is not index of a feature
-  virtual FeaturePtr feature(const QModelIndex& theIndex) const;
+  //! Returns object by the given Model index.
+  //! Returns 0 if the given index is not index of a object
+  virtual ObjectPtr object(const QModelIndex& theIndex) const;
 
-  //! Returns QModelIndex which corresponds to the given feature
-  //! If the feature is not found then index is not valid
-  virtual QModelIndex featureIndex(const FeaturePtr& theFeature) const;
+  //! Returns QModelIndex which corresponds to the given object
+  //! If the object is not found then index is not valid
+  virtual QModelIndex objectIndex(const ObjectPtr& theObject) const;
 
-  //! Returns parent index of the given feature
-  virtual QModelIndex findParent(const FeaturePtr& theFeature) const;
+  //! Returns parent index of the given object
+  virtual QModelIndex findParent(const ObjectPtr& theObject) const;
 
   //! Returns index corresponded to the group
   virtual QModelIndex findGroup(const std::string& theGroup) const;
@@ -85,30 +85,30 @@ public:
 
   virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
 
-  //! Returns Feature object by the given Model index.
-  //! Returns 0 if the given index is not index of a feature
-  virtual FeaturePtr feature(const QModelIndex& theIndex) const;
+  //! Returns object by the given Model index.
+  //! Returns 0 if the given index is not index of a object
+  virtual ObjectPtr object(const QModelIndex& theIndex) const;
 
-  //! Returns QModelIndex which corresponds to the given feature
-  //! If the feature is not found then index is not valid
-  virtual QModelIndex featureIndex(const FeaturePtr& theFeature) const;
+  //! Returns QModelIndex which corresponds to the given object
+  //! If the object is not found then index is not valid
+  virtual QModelIndex objectIndex(const ObjectPtr& theObject) const;
 
   //! Returns true if the given document is a sub-document of this tree
   virtual bool hasDocument(const DocumentPtr& theDoc) const;
 
-  //! Returns parent index of the given feature
-  virtual QModelIndex findParent(const FeaturePtr& theFeature) const;
+  //! Returns parent index of the given object
+  virtual QModelIndex findParent(const ObjectPtr& theObject) const;
 
   //! Returns index corresponded to the group
   virtual QModelIndex findGroup(const std::string& theGroup) const;
 
   //! Return a Part object
-  virtual FeaturePtr part() const;
+  virtual ResultPartPtr part() const;
 
 private: 
 
   //! Returns document of the current part
-  DocumentPtr featureDocument() const;
+  DocumentPtr partDocument() const;
 
   //! Types of QModelIndexes
   enum DataIds {
index 5900aefea0c8c4143c3163403816db009f18c9fb..05b4e0ea6d95cf5b8886669138589ef70a0b2339 100644 (file)
@@ -22,7 +22,7 @@ XGUI_Selection::XGUI_Selection(XGUI_Workshop* theWorkshop)
 
 std::list<ModuleBase_ViewerPrs> XGUI_Selection::getSelected(int theShapeTypeToSkip) const
 {
-  std::set<FeaturePtr> aPrsFeatures;
+  std::set<ResultPtr> aPrsFeatures;
   std::list<ModuleBase_ViewerPrs> aPresentations;
 
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
@@ -33,7 +33,7 @@ std::list<ModuleBase_ViewerPrs> XGUI_Selection::getSelected(int theShapeTypeToSk
     if (theShapeTypeToSkip >= 0 && !aShape.IsNull() && aShape.ShapeType() == theShapeTypeToSkip)
       continue;
 
-    FeaturePtr aFeature = myWorkshop->displayer()->getFeature(anIO);
+    ResultPtr aFeature = myWorkshop->displayer()->getResult(anIO);
     if (aPrsFeatures.find(aFeature) != aPrsFeatures.end())
       continue;
     Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
@@ -45,7 +45,7 @@ std::list<ModuleBase_ViewerPrs> XGUI_Selection::getSelected(int theShapeTypeToSk
 
 std::list<ModuleBase_ViewerPrs> XGUI_Selection::getHighlighted(int theShapeTypeToSkip) const
 {
-  std::set<FeaturePtr > aPrsFeatures;
+  std::set<ResultPtr> aPrsFeatures;
   std::list<ModuleBase_ViewerPrs> aPresentations;
 
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
@@ -55,29 +55,33 @@ std::list<ModuleBase_ViewerPrs> XGUI_Selection::getHighlighted(int theShapeTypeT
     if (theShapeTypeToSkip >= 0 && !aShape.IsNull() && aShape.ShapeType() == theShapeTypeToSkip)
       continue;
 
-    FeaturePtr aFeature = myWorkshop->displayer()->getFeature(anIO);
-    if (aPrsFeatures.find(aFeature) != aPrsFeatures.end())
+    ResultPtr aResult = myWorkshop->displayer()->getResult(anIO);
+    if (aPrsFeatures.find(aResult) != aPrsFeatures.end())
       continue;
-    aPresentations.push_back(ModuleBase_ViewerPrs(aFeature, aShape, NULL));
-    aPrsFeatures.insert(aFeature);
+    aPresentations.push_back(ModuleBase_ViewerPrs(aResult, aShape, NULL));
+    aPrsFeatures.insert(aResult);
   }
 
   return aPresentations;
 }
 
-QFeatureList XGUI_Selection::selectedFeatures() const
+QList<ObjectPtr> XGUI_Selection::selectedObjects() const
 {
-  return myWorkshop->objectBrowser()->selectedFeatures();
-  //QFeatureList aSelectedList;
-
-  //Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
-  //for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
-  //  Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
-  //  FeaturePtr aFeature = myWorkshop->displayer()->getFeature(anIO);
-  //  if (aFeature)
-  //    aSelectedList.append(aFeature);
-  //}
-  //return aSelectedList;
+  return myWorkshop->objectBrowser()->selectedObjects();
+}
+  
+QResultList XGUI_Selection::selectedResults() const
+{
+  QResultList aSelectedList;
+
+  Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+  for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
+    Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
+    ResultPtr aResult = myWorkshop->displayer()->getResult(anIO);
+    if (aResult)
+      aSelectedList.append(aResult);
+  }
+  return aSelectedList;
 }
 
 
index c6f92f5ff6d7cca053a2c8ef7efc8684800eabab..9202e97bb748fb8d9a8a8337fc11f96979e1f9d9 100644 (file)
@@ -28,26 +28,31 @@ public:
   /// Returns a list of viewer selected presentations
   /// \param theShapeTypeToSkip the shapes with this type will be skipped during the result list build
   /// \return list of presentations
-  std::list<ModuleBase_ViewerPrs> getSelected(int theShapeTypeToSkip = -1) const;
+  virtual std::list<ModuleBase_ViewerPrs> getSelected(int theShapeTypeToSkip = -1) const;
 
   /// Returns a list of viewer highlited presentations
   /// \param theShapeTypeToSkip the shapes with this type will be skipped during the result list build
   /// \return list of presentations
-  std::list<ModuleBase_ViewerPrs> getHighlighted(int theShapeTypeToSkip = -1) const;
+  virtual std::list<ModuleBase_ViewerPrs> getHighlighted(int theShapeTypeToSkip = -1) const;
 
   /**
-  * Returns list of features currently selected in 3d viewer
+  * Returns list of currently selected objects
   */
-  QFeatureList selectedFeatures() const;
+  virtual QList<ObjectPtr> selectedObjects() const;
+
+  /**
+  * Returns list of currently selected results
+  */
+  virtual QResultList selectedResults() const;
   
   //! Returns list of currently selected QModelIndexes
-  QModelIndexList selectedIndexes() const;
+  virtual QModelIndexList selectedIndexes() const;
 
   //! Returns list of currently selected AIS objects
-  void selectedAISObjects(AIS_ListOfInteractive& theList) const;
+  virtual void selectedAISObjects(AIS_ListOfInteractive& theList) const;
 
   //! Returns list of currently selected shapes
-  void selectedShapes(NCollection_List<TopoDS_Shape>& theList) const;
+  virtual void selectedShapes(NCollection_List<TopoDS_Shape>& theList) const;
 
 private:
   XGUI_Workshop* myWorkshop;
index d1d9f83a0a008f3c01f825b84c7dcd43ca1c84c1..dc5db4e2b604334dac71bceb7ca3f5a1a7e7babd 100644 (file)
@@ -12,6 +12,8 @@
 #include <ModelAPI_PluginManager.h>
 #include <ModelAPI_AttributeDocRef.h>
 #include <ModelAPI_Data.h>
+#include <ModelAPI_Result.h>
+#include <ModelAPI_Object.h>
 
 
 
@@ -40,24 +42,30 @@ void XGUI_SelectionMgr::connectViewers()
 //**************************************************************
 void XGUI_SelectionMgr::onObjectBrowserSelection()
 {
-  QFeatureList aFeatures = myWorkshop->objectBrowser()->selectedFeatures();
+  QList<ObjectPtr> aObjects = myWorkshop->objectBrowser()->selectedObjects();
+  QResultList aResults;
+  foreach(ObjectPtr aObject, aObjects) {
+    ResultPtr aRes = boost::dynamic_pointer_cast<ModelAPI_Result>(aObject);
+    if (aRes)
+      aResults.append(aRes);
+  }
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
-  aDisplayer->setSelected(aFeatures);
+  aDisplayer->setSelected(aResults);
   emit selectionChanged();
 }
 
 //**************************************************************
 void XGUI_SelectionMgr::onViewerSelection()
 {
-  QFeatureList aFeatures;
+  QList<ObjectPtr> aFeatures;
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
   for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
     Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
-    FeaturePtr aFeature = myWorkshop->displayer()->getFeature(anIO);
-    if (aFeature)
-      aFeatures.append(aFeature);
+    ResultPtr aResult = myWorkshop->displayer()->getResult(anIO);
+    if (aResult)
+      aFeatures.append(aResult);
   }
-  myWorkshop->objectBrowser()->setFeaturesSelected(aFeatures);
+  myWorkshop->objectBrowser()->setObjectsSelected(aFeatures);
   emit selectionChanged();
 }
 
index 93f19284c72f34fdfe66899494b2933a578c6c86..0519e29d019ef11b8f750ef3e6363b43de055e71 100644 (file)
@@ -28,18 +28,6 @@ public:
 
   XGUI_Selection* selection() const { return mySelection; }
 
-  //! Returns list of currently selected data objects
-  //QFeatureList selectedFeatures() const; 
-  
-  //! Returns list of currently selected QModelIndexes
-  //QModelIndexList selectedIndexes() const;
-
-  //! Returns list of currently selected AIS objects
-  //void selectedAISObjects(AIS_ListOfInteractive& theList) const;
-
-  //! Returns list of currently selected shapes
-  //void selectedShapes(NCollection_List<TopoDS_Shape>& theList) const;
-
   //! Connects the manager to all viewers accessible by Workshop
   void connectViewers();
 
index 5cf560636b93be6c263d9eea048d6b664f0c32b6..5672163dcf06273e50eaa790bec519328784fb9b 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <TopoDS_Shape.hxx>
 #include <ModelAPI_Object.h>
+#include <GeomAPI_Shape.h>
 
 #include <QDir>
 
@@ -71,7 +72,7 @@ std::string featureInfo(FeaturePtr theFeature)
 }
 
 //******************************************************************
-FeaturePtr realFeature(const FeaturePtr theFeature)
+/*FeaturePtr realFeature(const FeaturePtr theFeature)
 {
   if (theFeature->data()) {
     return theFeature;
@@ -79,6 +80,7 @@ FeaturePtr realFeature(const FeaturePtr theFeature)
     ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(theFeature);
     return aObject->featureRef();
   }
-}
+}*/
+
 
 }
index fa1c78af5652a8760b24c5639f76099e8d8a08bb..0ad21160aed3d7d068e7d48cc9a910a192158ba4 100644 (file)
@@ -9,7 +9,6 @@
 
 #include <boost/shared_ptr.hpp>
 
-class TopoDS_Shape;
 /*!
  \brief Return directory part of the file path.
 
@@ -72,11 +71,6 @@ namespace XGUI_Tools
    \param theFeature a feature
   */
   std::string XGUI_EXPORT featureInfo(FeaturePtr theFeature);
-
-  /**
-  * Returns pointer on real feature
-  */
-  FeaturePtr realFeature(const FeaturePtr theFeature);
 }
 
 #endif
index 1044a403aba85a059ed1f3e5c5a9a13a9d38c333..dddd97fb627b7570ded17519435a9f7138c6aa2e 100644 (file)
@@ -30,6 +30,7 @@
 #include <ModelAPI_AttributeDocRef.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_ResultPart.h>
 
 #include <PartSetPlugin_Part.h>
 
@@ -129,9 +130,9 @@ 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_FEATURE_TO_REDISPLAY));
+  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_OBJECT_TO_REDISPLAY));
 
   activateModule();
   if (myMainWindow) {
@@ -229,22 +230,22 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage)
   }
 
   // Process creation of Part
-  if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_CREATED)) {
-    const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
+  if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
+    const Model_ObjectUpdatedMessage* aUpdMsg = dynamic_cast<const Model_ObjectUpdatedMessage*>(theMessage);
     onFeatureCreatedMsg(aUpdMsg);
   }
 
   // Redisplay feature
-  if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_TO_REDISPLAY)) {
-    const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
+  if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) {
+    const Model_ObjectUpdatedMessage* aUpdMsg = dynamic_cast<const Model_ObjectUpdatedMessage*>(theMessage);
     onFeatureRedisplayMsg(aUpdMsg);
   }
 
   //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)) {
-    const Model_FeatureUpdatedMessage* anUpdateMsg =
-        dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
+  if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {
+    const Model_ObjectUpdatedMessage* anUpdateMsg =
+        dynamic_cast<const Model_ObjectUpdatedMessage*>(theMessage);
     onFeatureUpdatedMsg(anUpdateMsg);
   }
 
@@ -271,15 +272,15 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage)
 }
 
 //******************************************************
-void XGUI_Workshop::onFeatureUpdatedMsg(const Model_FeatureUpdatedMessage* theMsg)
+void XGUI_Workshop::onFeatureUpdatedMsg(const Model_ObjectUpdatedMessage* theMsg)
 {
-  std::set<FeaturePtr> aFeatures = theMsg->features();
+  std::set<ObjectPtr> aFeatures = theMsg->features();
   if (myOperationMgr->hasOperation())
   {
     FeaturePtr aCurrentFeature = myOperationMgr->currentOperation()->feature();
-    std::set<FeaturePtr>::const_iterator aIt;
+    std::set<ObjectPtr>::const_iterator aIt;
     for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
-      FeaturePtr aNewFeature = (*aIt);
+      ObjectPtr aNewFeature = (*aIt);
       if(aNewFeature == aCurrentFeature) {
         myPropertyPanel->updateContentWidget(aCurrentFeature);
         break;
@@ -289,15 +290,15 @@ void XGUI_Workshop::onFeatureUpdatedMsg(const Model_FeatureUpdatedMessage* theMs
 }
 
 //******************************************************
-void XGUI_Workshop::onFeatureRedisplayMsg(const Model_FeatureUpdatedMessage* theMsg)
+void XGUI_Workshop::onFeatureRedisplayMsg(const Model_ObjectUpdatedMessage* theMsg)
 {
-  std::set<FeaturePtr> aFeatures = theMsg->features();
-  std::set<FeaturePtr>::const_iterator aIt;
+  std::set<ObjectPtr> aFeatures = theMsg->features();
+  std::set<ObjectPtr>::const_iterator aIt;
   bool isDisplayed = false;
   for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
-    FeaturePtr aFeature = (*aIt);
-    if (aFeature->getKind() != PartSetPlugin_Part::ID()) {
-      isDisplayed = myDisplayer->redisplay(aFeature, false);
+    ResultPtr aRes = boost::dynamic_pointer_cast<ModelAPI_Result>(*aIt);
+    if (aRes) {
+      isDisplayed = myDisplayer->redisplay(aRes, false);
     }
   }
   if (isDisplayed)
@@ -305,20 +306,22 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const Model_FeatureUpdatedMessage* the
 }
 
 //******************************************************
-void XGUI_Workshop::onFeatureCreatedMsg(const Model_FeatureUpdatedMessage* theMsg)
+void XGUI_Workshop::onFeatureCreatedMsg(const Model_ObjectUpdatedMessage* theMsg)
 {
-  std::set<FeaturePtr> aFeatures = theMsg->features();
+  std::set<ObjectPtr> aFeatures = theMsg->features();
 
-  std::set<FeaturePtr>::const_iterator aIt;
+  std::set<ObjectPtr>::const_iterator aIt;
   bool aHasPart = false;
   bool isDisplayed = false;
   for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
-    FeaturePtr aFeature = (*aIt);
-    if (aFeature->getKind() == PartSetPlugin_Part::ID()) {
+     ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(*aIt);
+    if (aPart) {
       aHasPart = true;
       //break;
     } else {
-      isDisplayed = myDisplayer->display(aFeature, false);
+      ResultPtr aRes = boost::dynamic_pointer_cast<ModelAPI_Result>(*aIt);
+      if (aRes)
+        isDisplayed = myDisplayer->display(aRes, false);
     }
   }
   if (isDisplayed)
@@ -824,19 +827,13 @@ void XGUI_Workshop::onFeatureTriggered()
 }
 
 //******************************************************
-void XGUI_Workshop::changeCurrentDocument(FeaturePtr thePart)
+void XGUI_Workshop::changeCurrentDocument(ObjectPtr theObj)
 {
   PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
-  if (thePart) {
-    DocumentPtr aFeaDoc;
-    if (!XGUI_Tools::isModelObject(thePart)) {
-      aFeaDoc = thePart->data()->docRef("PartDocument")->value();
-    } else {
-      ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(thePart);
-      aFeaDoc = aObject->featureRef()->data()->docRef("PartDocument")->value();
-    }
-    if (aFeaDoc)
-      aMgr->setCurrentDocument(aFeaDoc);
+  if (theObj) {
+    DocumentPtr aPartDoc = theObj->document();
+    if (aPartDoc)
+      aMgr->setCurrentDocument(aPartDoc);
   } else {
     aMgr->setCurrentDocument(aMgr->rootDocument());
   }
@@ -858,17 +855,19 @@ XGUI_SalomeViewer* XGUI_Workshop::salomeViewer() const
 //**************************************************************
 void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
 {
-  QFeatureList aFeatures = mySelector->selection()->selectedFeatures();
-  if ((theId == "ACTIVATE_PART_CMD") && (aFeatures.size() > 0))
-    activatePart(aFeatures.first());
-  else if (theId == "DEACTIVATE_PART_CMD") 
-    activatePart(FeaturePtr());
+  QList<ObjectPtr> aObjects = mySelector->selection()->selectedObjects();
+  if ((theId == "ACTIVATE_PART_CMD") && (aObjects.size() > 0)) {
+    ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObjects.first());
+    if (aPart)
+      activatePart(aPart);
+  } else if (theId == "DEACTIVATE_PART_CMD") 
+    activatePart(ResultPartPtr());
   else if (theId == "DELETE_CMD")
-    deleteFeatures(aFeatures);
+    deleteObjects(aObjects);
   else if (theId == "SHOW_CMD")
-    showFeatures(aFeatures, true);
+    showObjects(aObjects, true);
   else if (theId == "HIDE_CMD")
-    showFeatures(aFeatures, false);
+    showObjects(aObjects, false);
 }
 
 //**************************************************************
@@ -892,7 +891,7 @@ void XGUI_Workshop::onWidgetValuesChanged()
 }
 
 //**************************************************************
-void XGUI_Workshop::activatePart(FeaturePtr theFeature)
+void XGUI_Workshop::activatePart(ResultPartPtr theFeature)
 {
   changeCurrentDocument(theFeature);
   myObjectBrowser->activatePart(theFeature);
@@ -903,59 +902,52 @@ void XGUI_Workshop::activateLastPart()
 {
   PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
   DocumentPtr aDoc = aMgr->rootDocument();
-  FeaturePtr aLastPart = aDoc->feature(ModelAPI_Document::PARTS_GROUP(),
-                                       aDoc->size(ModelAPI_Document::PARTS_GROUP()) - 1, true);
-  activatePart(aLastPart);
+  std::string aGrpName = ModelAPI_ResultPart::group();
+  ObjectPtr aLastPart = aDoc->object(aGrpName, aDoc->size(aGrpName) - 1);
+  ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aLastPart);
+  if (aPart)
+    activatePart(aPart);
 }
 
 //**************************************************************
-void XGUI_Workshop::deleteFeatures(QFeatureList theList)
+void XGUI_Workshop::deleteObjects(const QList<ObjectPtr>& theList)
 {
   QMainWindow* aDesktop = isSalomeMode()? salomeConnector()->desktop() : myMainWindow;
   QMessageBox::StandardButton aRes = QMessageBox::warning(aDesktop, tr("Delete features"), 
                                                           tr("Seleted features will be deleted. Continue?"), 
                                                           QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
-  if (aRes == QMessageBox::Yes) {
+  // ToDo: definbe deleting method
+  /*  if (aRes == QMessageBox::Yes) {
     PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
     aMgr->rootDocument()->startOperation();
-    foreach (FeaturePtr aFeature, theList) {
-      if (aFeature->getKind() == PartSetPlugin_Part::ID()) {
-        DocumentPtr aDoc;
-        if (!XGUI_Tools::isModelObject(aFeature)) {
-          aDoc = aFeature->data()->docRef("PartDocument")->value();
-        } else {
-          ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
-          aDoc = aObject->featureRef()->data()->docRef("PartDocument")->value();
-          aFeature = aObject->featureRef();
-        }
+    foreach (ObjectPtr aObj, theList) {
+      ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
+      if (aPart) {
+        DocumentPtr aDoc = aPart->document();
         if (aDoc == aMgr->currentDocument()) {
           aDoc->close();
         }
+        aMgr->rootDocument()->removeFeature(aPart->owner());
       } else {
-        if (XGUI_Tools::isModelObject(aFeature)) {
-          ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
-          aFeature = aObject->featureRef();
-        }
+        aObj->document()->removeFeature(aObj);
       }
-      if (myDisplayer->isVisible(aFeature))
-        myDisplayer->erase(aFeature, false);
-      aFeature->document()->removeFeature(aFeature);
     }
     myDisplayer->updateViewer();
     aMgr->rootDocument()->finishOperation();
-  }
+  }*/
 }
 
 //**************************************************************
-void XGUI_Workshop::showFeatures(QFeatureList theList, bool isVisible)
+void XGUI_Workshop::showObjects(const QList<ObjectPtr>& theList, bool isVisible)
 {
-  if (isVisible) {
-    foreach (FeaturePtr aFeature, theList) {
-      myDisplayer->display(aFeature, false);
-    }
-  } else {
-    foreach (FeaturePtr aFeature, theList) {
-      myDisplayer->erase(aFeature, false);
+  foreach (ObjectPtr aObj, theList) {
+    ResultPtr aRes = boost::dynamic_pointer_cast<ModelAPI_Result>(aObj);
+    if (aRes) {
+      if (isVisible) {
+        myDisplayer->display(aRes, false);
+      } else {
+        myDisplayer->erase(aRes, false);
+      }
     }
   }
   myDisplayer->updateViewer();
index 960c4dd89e5b5e4ab191c7c8f41c18897f510efc..1b85fbc0c417f318e6563492203f5742d7441808 100644 (file)
@@ -5,6 +5,7 @@
 #include "XGUI_Constants.h"
 #include <Events_Listener.h>
 #include <ModuleBase_Definitions.h>
+#include <ModelAPI_ResultPart.h>
 
 #include <QObject>
 #include <QMap>
@@ -37,7 +38,7 @@ class Config_PointerMessage;
 class QWidget;
 class QDockWidget;
 
-class Model_FeatureUpdatedMessage;
+class Model_ObjectUpdatedMessage;
 class QAction;
 
 /**\class XGUI_Workshop
@@ -110,13 +111,13 @@ public:
 
   //! Activates or deactivates a part
   //! If PartPtr is Null pointer then PartSet will be activated
-  void activatePart(FeaturePtr theFeature);
+  void activatePart(ResultPartPtr theFeature);
 
   //! Delete features
-  void deleteFeatures(QFeatureList theList);
+  void deleteObjects(const QList<ObjectPtr>& theList);
 
   //! Show the given features in 3d Viewer
-  void showFeatures(QFeatureList theList, bool isVisible);
+  void showObjects(const QList<ObjectPtr>& theList, bool isVisible);
 
   ModuleBase_IModule* module() const { return myModule; }
 
@@ -142,7 +143,7 @@ public slots:
   void hideObjectBrowser();
 
   void onFeatureTriggered();
-  void changeCurrentDocument(FeaturePtr thePart);
+  void changeCurrentDocument(ObjectPtr theObj);
 
   void activateLastPart();
 
@@ -152,9 +153,9 @@ protected:
   void connectWithOperation(ModuleBase_Operation* theOperation);
   void saveDocument(QString theName);
 
-  void onFeatureUpdatedMsg(const Model_FeatureUpdatedMessage* theMsg);
-  void onFeatureCreatedMsg(const Model_FeatureUpdatedMessage* theMsg);
-  void onFeatureRedisplayMsg(const Model_FeatureUpdatedMessage* theMsg);
+  void onFeatureUpdatedMsg(const Model_ObjectUpdatedMessage* theMsg);
+  void onFeatureCreatedMsg(const Model_ObjectUpdatedMessage* theMsg);
+  void onFeatureRedisplayMsg(const Model_ObjectUpdatedMessage* theMsg);
 
   QList<QAction*> getModuleCommands() const;
 
index 065663ecfc1c94e73dcd67d3e90680962153e62f..efd946fcb86823b56fba8584e79c39bf0c2edbd9 100644 (file)
@@ -32,6 +32,7 @@
      
      <file>pictures/params_folder.png</file>
      <file>pictures/constr_folder.png</file>
+     <file>pictures/constr_object.png</file>
      <file>pictures/part_ico.png</file>
      <file>pictures/properties.png</file>
      <file>pictures/features.png</file>
diff --git a/src/XGUI/pictures/constr_object.png b/src/XGUI/pictures/constr_object.png
new file mode 100644 (file)
index 0000000..dd6dc98
Binary files /dev/null and b/src/XGUI/pictures/constr_object.png differ