]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Working with Construction results in SketchPlugin
authormpv <mikhail.ponikarov@opencascade.com>
Fri, 11 Jul 2014 08:37:48 +0000 (12:37 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Fri, 11 Jul 2014 08:37:48 +0000 (12:37 +0400)
31 files changed:
src/Model/Model_Document.cpp
src/Model/Model_Document.h
src/Model/Model_ResultConstruction.cpp
src/Model/Model_ResultConstruction.h
src/Model/Model_Update.cpp
src/ModelAPI/ModelAPI_Document.h
src/ModelAPI/ModelAPI_Feature.h
src/ModelAPI/ModelAPI_ResultBody.h
src/SketchPlugin/SketchPlugin_Arc.h
src/SketchPlugin/SketchPlugin_Circle.cpp
src/SketchPlugin/SketchPlugin_Circle.h
src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp
src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.h
src/SketchPlugin/SketchPlugin_ConstraintLength.cpp
src/SketchPlugin/SketchPlugin_ConstraintLength.h
src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp
src/SketchPlugin/SketchPlugin_ConstraintParallel.h
src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp
src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h
src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp
src/SketchPlugin/SketchPlugin_ConstraintRadius.h
src/SketchPlugin/SketchPlugin_Feature.cpp
src/SketchPlugin/SketchPlugin_Feature.h
src/SketchPlugin/SketchPlugin_Line.cpp
src/SketchPlugin/SketchPlugin_Line.h
src/SketchPlugin/SketchPlugin_Point.cpp
src/SketchPlugin/SketchPlugin_Point.h
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_Sketch.h

index 68ec29401056acbf1f5aa5303ec6d4e9da633f73..d949574948d19d6f6c4b632730821a2001703d78 100644 (file)
@@ -351,12 +351,12 @@ FeaturePtr Model_Document::addFeature(string theID)
   if (aFeature) {
     TDF_Label aFeatureLab;
     if (!aFeature->isAction()) {// do not add action to the data model
-      TDF_Label aFeaturesLab = groupLabel(FEATURES_GROUP);
+      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());
-      myObjs[FEATURES_GROUP].push_back(aFeature);
+      myObjs[ModelAPI_Feature::group()].push_back(aFeature);
       // store feature in the history of features array
       if (aFeature->isInHistory()) {
         AddToRefArray(aFeaturesLab, aFeatureLab);
@@ -372,10 +372,10 @@ FeaturePtr Model_Document::addFeature(string theID)
   return aFeature;
 }
 
-void Model_Document::storeResult(boost::shared_ptr<ModelAPI_Result> theResult,
-  const int theResultIndex)
+void Model_Document::storeResult(boost::shared_ptr<ModelAPI_Feature> theFeature,
+  boost::shared_ptr<ModelAPI_Result> theResult, const int theResultIndex)
 {
-  initData(theResult, boost::dynamic_pointer_cast<Model_Data>(theResult->owner()->data())->
+  initData(theResult, boost::dynamic_pointer_cast<Model_Data>(theFeature->data())->
     label().Father().FindChild(TAG_FEATURE_RESULTS), theResultIndex);
 }
 
@@ -415,7 +415,7 @@ 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().Father();
   // remove feature from the myObjects list
-  std::vector<ObjectPtr>& aVec = myObjs[FEATURES_GROUP];
+  std::vector<ObjectPtr>& aVec = myObjs[ModelAPI_Feature::group()];
   std::vector<ObjectPtr>::iterator anIter = aVec.begin();
   while(anIter != aVec.end()) {
     if (*anIter == theFeature) {
@@ -427,10 +427,10 @@ void Model_Document::removeFeature(FeaturePtr theFeature)
   // erase all attributes under the label of feature
   aFeatureLabel.ForgetAllAttributes();
   // remove it from the references array
-  RemoveFromRefArray(groupLabel(FEATURES_GROUP), aData->label());
+  RemoveFromRefArray(groupLabel(ModelAPI_Feature::group()), aData->label());
 
   // event: feature is deleted
-  ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), FEATURES_GROUP);
+  ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), ModelAPI_Feature::group());
 }
 
 /// returns the object group name by the object label
@@ -445,7 +445,7 @@ static string groupName(TDF_Label theObjectLabel) {
 FeaturePtr Model_Document::feature(TDF_Label& theLabel)
 {
   // iterate all features, may be optimized later by keeping labels-map
-  std::vector<ObjectPtr>& aVec = myObjs[FEATURES_GROUP];
+  std::vector<ObjectPtr>& aVec = myObjs[ModelAPI_Feature::group()];
   vector<ObjectPtr>::iterator aFIter = aVec.begin();
   for(; aFIter != aVec.end(); aFIter++) {
     boost::shared_ptr<Model_Data> aData = 
@@ -466,7 +466,7 @@ boost::shared_ptr<ModelAPI_Document> Model_Document::subDocument(string theDocID
 
 ObjectPtr Model_Document::object(const string& theGroupID, const int theIndex)
 {
-  if (theGroupID == FEATURES_GROUP) {
+  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();
@@ -475,7 +475,7 @@ ObjectPtr Model_Document::object(const string& theGroupID, const int theIndex)
     }
   } else {
     // iterate all features in order to find the needed result
-    std::map<std::string, std::vector<ObjectPtr> >::iterator aFind = myObjs.find(FEATURES_GROUP);
+    std::map<std::string, std::vector<ObjectPtr> >::iterator aFind = myObjs.find(ModelAPI_Feature::group());
     if (aFind != myObjs.end()) {
       vector<ObjectPtr>::iterator aFIter = aFind->second.begin();
       for(int anIndex = 0; aFIter != aFind->second.end(); aFIter++) {
@@ -499,14 +499,14 @@ ObjectPtr Model_Document::object(const string& theGroupID, const int theIndex)
 int Model_Document::size(const string& theGroupID) 
 {
   int aResult = 0;
-  if (theGroupID == FEATURES_GROUP) {
+  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(FEATURES_GROUP);
+    std::map<std::string, std::vector<ObjectPtr> >::iterator aFind = myObjs.find(ModelAPI_Feature::group());
     if (aFind != myObjs.end()) {
       vector<ObjectPtr>::iterator aFIter = aFind->second.begin();
       for(; aFIter != aFind->second.end(); aFIter++) {
@@ -560,9 +560,9 @@ void Model_Document::setUniqueName(FeaturePtr theFeature)
   string aName; // result
   // first count all objects of such kind to start with index = count + 1
   int a, aNumObjects = 0;
-  int aSize = size(FEATURES_GROUP);
+  int aSize = size(ModelAPI_Feature::group());
   for(a = 0; a < aSize; a++) {
-    if (boost::dynamic_pointer_cast<ModelAPI_Feature>(object(FEATURES_GROUP, a))->getKind()
+    if (boost::dynamic_pointer_cast<ModelAPI_Feature>(object(ModelAPI_Feature::group(), a))->getKind()
         == theFeature->getKind())
       aNumObjects++;
   }
@@ -572,7 +572,7 @@ void Model_Document::setUniqueName(FeaturePtr theFeature)
   aName = aNameStream.str();
   // check this is unique, if not, increase index by 1
   for(a = 0; a < aSize;) {
-    if (boost::dynamic_pointer_cast<ModelAPI_Feature>(object(FEATURES_GROUP, a))
+    if (boost::dynamic_pointer_cast<ModelAPI_Feature>(object(ModelAPI_Feature::group(), a))
           ->data()->name() == aName) {
       aNumObjects++;
       stringstream aNameStream;
@@ -670,7 +670,7 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated)
     setCheckTransactions(true);
 }
 
-boost::shared_ptr<ModelAPI_ResultConstruction> createConstruction()
+boost::shared_ptr<ModelAPI_ResultConstruction> Model_Document::createConstruction()
 {
   boost::shared_ptr<ModelAPI_ResultConstruction> aResult(new Model_ResultConstruction());
   return aResult;
index f6d59b785a1a19fbe3e77837b73802d534c7a2f0..ec69667b70f37d928a4c46fa1daae25f07ab7b92 100644 (file)
@@ -88,7 +88,7 @@ public:
   MODEL_EXPORT virtual int size(const std::string& theGroupID);
 
   //! Allows to store the result in the data tree of the document (attaches 'data' of result to tree)
-  MODEL_EXPORT virtual void storeResult(
+  MODEL_EXPORT virtual void storeResult(boost::shared_ptr<ModelAPI_Feature> theFeature,
     boost::shared_ptr<ModelAPI_Result> theResult, const int theResultIndex);
 
   /// Creates a construction cresults
index a5e1ccc9bad7f3ec07530f19dc01e724bcf5a846..8d230ab37c13f2881717dced37421cfd825fbe6c 100644 (file)
@@ -14,13 +14,12 @@ boost::shared_ptr<GeomAPI_Shape>& Model_ResultConstruction::shape()
   return myShape;
 }
 
+/*
 boost::shared_ptr<ModelAPI_Feature> Model_ResultConstruction::owner()
 {
   return myOwner;
-}
+}*/
 
-Model_ResultConstruction::Model_ResultConstruction(
-  const boost::shared_ptr<ModelAPI_Feature>& theFeature)
-  : myOwner(theFeature)
+Model_ResultConstruction::Model_ResultConstruction()
 {
 }
index b6ca72156ef3c57ca568ebe4111ff6d8b2172cca..b24c2f31076d8febe821b74c5e461ea6ebad43f2 100644 (file)
@@ -28,7 +28,7 @@ public:
   /// 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();
+  //MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> owner();
 
 protected:
   /// Makes a body on the given feature
index 4fd5f29657e336facc26dea124a8ebd505c00f5f..0700c826bc38d44975aac980f11cc1ddf5bae8e1 100644 (file)
@@ -34,10 +34,10 @@ void Model_Update::processEvent(const Events_Message* theMessage)
   // 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(FEATURES_GROUP);
+    int aNbFeatures = (*aDIter)->size(ModelAPI_Feature::group());
     for(int aFIndex = 0; aFIndex < aNbFeatures; aFIndex++) {
       boost::shared_ptr<ModelAPI_Feature> aFeature = 
-        boost::dynamic_pointer_cast<ModelAPI_Feature>((*aDIter)->object(FEATURES_GROUP, aFIndex));
+        boost::dynamic_pointer_cast<ModelAPI_Feature>((*aDIter)->object(ModelAPI_Feature::group(), aFIndex));
       if (aFeature)
         updateFeature(aFeature);
     }
index 36342b3dd2dee6cb3b0adfe2e7183cdd574a7afa..740a4545e9eb27297c495ba54f697457bfdf9c81 100644 (file)
@@ -15,18 +15,6 @@ class ModelAPI_Object;
 class ModelAPI_Result;
 class ModelAPI_ResultConstruction;
 
-/// Common groups identifiers
-/// Group of parameters
-static const std::string PARAMETERS_GROUP = "Parameters";
-/// Group of constructions
-static const std::string CONSTRUCTIONS_GROUP = "Construction";
-/// Group of parts
-static const std::string PARTS_GROUP = "Parts";
-/// Group of bodies
-static const std::string BODIES_GROUP = "Bodies";
-/// All created fetaures of the document (a history)
-static const std::string FEATURES_GROUP = "Features";
-
 /**\class Model_Document
  * \ingroup DataModel
  * \brief Document for internal data structure of any object storage.
index 0bdb7817ee43550a266a43b57ac998319eea0686..daa59c05ca89f93762f514ff06d48b33f430af0d 100644 (file)
@@ -29,6 +29,10 @@ public:
   /// 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;}
+
   /// Request for initialization of data model of the feature: adding all attributes
   virtual void initAttributes() = 0;
 
@@ -37,6 +41,9 @@ public:
 
   // 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>();}
 
   /// Returns true if this feature must not be created: this is just an action
   /// that is not stored in the features history and data model (like "delete part").
index f801ad45cd8e8f36e9cbf9743b74e03932a0670a..336e6ccd412bab754deb7838219a99af1f25a268 100644 (file)
@@ -21,7 +21,7 @@ class ModelAPI_ResultBody : public ModelAPI_Result
 public:
   /// Returns the group identifier of this result
   virtual std::string group()
-    {static std::string MY_GROUP = "Bodies"; return MY_GROUP;}
+  {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;
index 5a4c6ed78b5d4a07ed9d4e36654ff50c62b57646..4603dd922012eac6d05b427dedba5e20b748f84c 100644 (file)
@@ -37,13 +37,9 @@ public:
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
 
   /// 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 d962d4cfa0dcaf1bb0a9de8148da8e04701ff126..1fec7a86a0a2c83866c58f45b84a973b260525a0 100644 (file)
@@ -26,7 +26,7 @@ void SketchPlugin_Circle::initAttributes()
   data()->addAttribute(CIRCLE_ATTR_RADIUS, ModelAPI_AttributeDouble::type());
 }
 
-void SketchPlugin_Circle::execute(boost::shared_ptr<ModelAPI_Result>& theResult)
+void SketchPlugin_Circle::execute()
 {
   SketchPlugin_Sketch* aSketch = sketch();
   if (aSketch) {
@@ -59,7 +59,9 @@ void SketchPlugin_Circle::execute(boost::shared_ptr<ModelAPI_Result>& theResult)
     }
     boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes);
       // store the result
-    boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult)->setShape(aCompound);
+      boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction();
+      aConstr->setShape(aCompound);
+      results().push_back(aConstr);
   }
 }
 
index 2f2f01e429d9ded50294e61bab3286c925b5bcb9..c02c79e21941ce1838c581b9c9f69be80abd55bd 100644 (file)
@@ -29,17 +29,15 @@ public:
   {static std::string MY_KIND = SKETCH_CIRCLE_KIND; return MY_KIND;}
 
   /// Creates a new part document if needed
-  SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr<ModelAPI_Result>& theResult);
+  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 0fd8b0bfff173a00dd3d13a21f09380abed65e01..e052d1acee3838ab90e0b28e60d8ce68018a0238 100644 (file)
@@ -18,7 +18,7 @@ void SketchPlugin_ConstraintCoincidence::initAttributes()
   data()->addAttribute(CONSTRAINT_ATTR_ENTITY_B, ModelAPI_AttributeRefAttr::type());
 }
 
-void SketchPlugin_ConstraintCoincidence::execute(boost::shared_ptr<ModelAPI_Result>& theResult)
+void SketchPlugin_ConstraintCoincidence::execute()
 {
 }
 
index f227d4cf828b86a447c76a03b9241ba3732191f1..3af35adfe9b8c3a6101ccde868025ab0bcee28e6 100644 (file)
@@ -28,7 +28,7 @@ public:
   {static std::string MY_KIND = SKETCH_CONSTRAINT_COINCIDENCE_KIND; return MY_KIND;}
 
   /// \brief Creates a new part document if needed
-  SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr<ModelAPI_Result>& theResult);
+  SKETCHPLUGIN_EXPORT virtual void execute();
 
   /// \brief Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
index 23ecc6435351e42f82a3a4b3cc80af997e5b5981..faa2d7b62270e966b31fd6b295149e2111d4628d 100644 (file)
@@ -30,7 +30,7 @@ void SketchPlugin_ConstraintDistance::initAttributes()
   data()->addAttribute(CONSTRAINT_ATTR_ENTITY_B, ModelAPI_AttributeRefAttr::type());
 }
 
-void SketchPlugin_ConstraintDistance::execute(boost::shared_ptr<ModelAPI_Result>& theResult)
+void SketchPlugin_ConstraintDistance::execute()
 {
   boost::shared_ptr<ModelAPI_Data> aData = data();
 
index e633e9fe42e391b5b8b6f63d9aa6ae76757e9092..bb324f75b263707ac6b31827412b8189f65ea10d 100644 (file)
@@ -29,7 +29,7 @@ public:
   {static std::string MY_KIND = SKETCH_CONSTRAINT_DISTANCE_KIND; return MY_KIND;}
 
   /// \brief Creates a new part document if needed
-  SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr<ModelAPI_Result>& theResult);
+  SKETCHPLUGIN_EXPORT virtual void execute();
 
   /// \brief Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
index 0a5a11fcc3272f7c09b139712b4d63361a71e357..71a35c4f189624649c2501a7f66d36799a437ad2 100644 (file)
@@ -26,7 +26,7 @@ void SketchPlugin_ConstraintLength::initAttributes()
   data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type());
 }
 
-void SketchPlugin_ConstraintLength::execute(boost::shared_ptr<ModelAPI_Result>& theResult)
+void SketchPlugin_ConstraintLength::execute()
 {
   if (data()->attribute(CONSTRAINT_ATTR_ENTITY_A)->isInitialized() &&
       !data()->attribute(CONSTRAINT_ATTR_VALUE)->isInitialized()) {
index 3ad18ea20503bb2ca15be070be6be23aa3272716..8e8cd5a478a16104a6a6687018e561031052ecd0 100644 (file)
@@ -29,7 +29,7 @@ public:
   {static std::string MY_KIND = SKETCH_CONSTRAINT_LENGTH_KIND; return MY_KIND;}
 
   /// \brief Creates a new part document if needed
-  SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr<ModelAPI_Result>& theResult);
+  SKETCHPLUGIN_EXPORT virtual void execute();
 
   /// \brief Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
index 45713e1240fc39e6054b40b0cde76142e8fba542..85d34d9c7bcff9b1421d9e8b2bcf5e650e3ca682 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>
@@ -25,7 +26,7 @@ void SketchPlugin_ConstraintParallel::initAttributes()
   data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT, GeomDataAPI_Point2D::type());
 }
 
-void SketchPlugin_ConstraintParallel::execute(boost::shared_ptr<ModelAPI_Result>& theResult)
+void SketchPlugin_ConstraintParallel::execute()
 {
 }
 
@@ -51,8 +52,13 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintParallel::getAISObje
     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(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT));
index 9fd42ba88686dc8cf82804102e23d09478a2c15c..651016248b8d87aac9c164e6dd0cb847c640397b 100644 (file)
@@ -27,14 +27,11 @@ public:
   {static std::string MY_KIND = SKETCH_CONSTRAINT_PARALLEL_KIND; return MY_KIND;}
 
   /// \brief Creates a new part document if needed
-  SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr<ModelAPI_Result>& theResult);
+  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 b6b9de72a484af098cf3f455726672ea148dafe4..ddd8308586b14f0554ff808e5de256858b43c796 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>
@@ -25,7 +26,7 @@ void SketchPlugin_ConstraintPerpendicular::initAttributes()
   data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT, GeomDataAPI_Point2D::type());
 }
 
-void SketchPlugin_ConstraintPerpendicular::execute(boost::shared_ptr<ModelAPI_Result>& theResult)
+void SketchPlugin_ConstraintPerpendicular::execute()
 {
 }
 
@@ -51,8 +52,13 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintPerpendicular::getAI
     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 9f6956d9188f507fc51991bd0f05386337860c6b..231be46996814081d83328f8bb69a3412796e64f 100644 (file)
@@ -27,14 +27,11 @@ public:
   {static std::string MY_KIND = SKETCH_CONSTRAINT_PERPENDICULAR_KIND; return MY_KIND;}
 
   /// \brief Creates a new part document if needed
-  SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr<ModelAPI_Result>& theResult);
+  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 ee05e7c9c443ee13f5f02a8dd2a0146ea6a1dc35..65ab125b5474f361543530bdc5dd2a79539e0ac0 100644 (file)
@@ -30,7 +30,7 @@ void SketchPlugin_ConstraintRadius::initAttributes()
   data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT, GeomDataAPI_Point2D::type());
 }
 
-void SketchPlugin_ConstraintRadius::execute(boost::shared_ptr<ModelAPI_Result>& theResult)
+void SketchPlugin_ConstraintRadius::execute()
 {
   if (data()->attribute(CONSTRAINT_ATTR_ENTITY_A)->isInitialized() &&
       !data()->attribute(CONSTRAINT_ATTR_VALUE)->isInitialized()) {
index c11757dfbc6364920957dfe2935d6dd1eb603dd6..26642a49fd43178a50d1920687930565cfc35577 100644 (file)
@@ -28,7 +28,7 @@ public:
   {static std::string MY_KIND = SKETCH_CONSTRAINT_RADIUS_KIND; return MY_KIND;}
 
   /// \brief Creates a new part document if needed
-  SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr<ModelAPI_Result>& theResult);
+  SKETCHPLUGIN_EXPORT virtual void execute();
 
   /// \brief Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
index 7195bb706614e5923c465c29737feb5935df4da4..99d5684d36fdd6d307cbce0e2e84b0c7007b49ba 100644 (file)
@@ -4,6 +4,7 @@
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_AttributeRefList.h>
+#include <ModelAPI_ResultConstruction.h>
 
 SketchPlugin_Feature::SketchPlugin_Feature()
 {
@@ -34,11 +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)
 {
-  document()->result();
-  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 3d9cbf9a0a0fc9894a1e6c59bce8eecae4229638..6f1b3a66c691cdd62749826ac90fa460844c3af1 100644 (file)
@@ -23,17 +23,18 @@ class Handle_AIS_InteractiveObject;
 class SketchPlugin_Feature: public ModelAPI_Feature
 {
 public:
-  /// Returns the type of the feature result: it is allways construction element
-  virtual const std::string& getResultType() {return CONSTRUCTIONS_GROUP;}
-
   /// Returns the AIS preview
   SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
                                 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;}
index c15a8b62fa7331186fcf072d015913faf4582b28..f61f24c0ea28a44779170b10955270b09a45d069 100644 (file)
@@ -30,7 +30,7 @@ void SketchPlugin_Line::initAttributes()
   data()->addAttribute(LINE_ATTR_END, GeomDataAPI_Point2D::type());
 }
 
-void SketchPlugin_Line::execute(boost::shared_ptr<ModelAPI_Result>& theResult
+void SketchPlugin_Line::execute() 
 {
   SketchPlugin_Sketch* aSketch = sketch();
   if (aSketch) {
@@ -46,7 +46,9 @@ void SketchPlugin_Line::execute(boost::shared_ptr<ModelAPI_Result>& theResult)
       // make linear edge
       boost::shared_ptr<GeomAPI_Shape> anEdge = GeomAlgoAPI_EdgeBuilder::line(aStart, anEnd);
       // store the result
-      boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult)->setShape(anEdge);
+      boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction();
+      aConstr->setShape(anEdge);
+      results().push_back(aConstr);
     }
   }
 }
index af454d8c942401f9ab7afa40b6c6eda05a238751..cce6a25eb781049a404f602b7a9b2ef560fefc32 100644 (file)
@@ -30,19 +30,15 @@ public:
   {static std::string MY_KIND = SKETCH_LINE_KIND; return MY_KIND;}
 
   /// Creates a new part document if needed
-  SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr<ModelAPI_Result>& theResult);
+  SKETCHPLUGIN_EXPORT virtual void execute();
 
   /// Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
 
   /// 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 3a24b7a8769b44cad7751b23aead9dd8a46685fd..c910c6522bf24efed80834738ef8e0ae7b91e6ce 100644 (file)
@@ -24,7 +24,7 @@ void SketchPlugin_Point::initAttributes()
   data()->addAttribute(POINT_ATTR_COORD, GeomDataAPI_Point2D::type());
 }
 
-void SketchPlugin_Point::execute(boost::shared_ptr<ModelAPI_Result>& theResult
+void SketchPlugin_Point::execute() 
 {
   SketchPlugin_Sketch* aSketch = sketch();
   if (aSketch) {
@@ -34,7 +34,9 @@ void SketchPlugin_Point::execute(boost::shared_ptr<ModelAPI_Result>& theResult)
     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);
-    boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult)->setShape(aPointShape);
+    boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction();
+    aConstr->setShape(aPointShape);
+    results().push_back(aConstr);
   }
 }
 
index ea3e125b7bbbe73b49b4848d13a23b2d525878d9..4efb76d7c7d980cad1f7b58690feb4899ee9478c 100644 (file)
@@ -28,19 +28,15 @@ public:
   {static std::string MY_KIND = SKETCH_POINT_KIND; return MY_KIND;}
 
   /// Creates a new part document if needed
-  SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr<ModelAPI_Result>& theResult);
+  SKETCHPLUGIN_EXPORT virtual void execute();
 
   /// Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
 
   /// 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 b451c99b061f9666c2446bff768bd2383fe8b3b5..813271dfaa644d7f1f30d31c9d966a32daa0fc08 100644 (file)
@@ -36,7 +36,7 @@ void SketchPlugin_Sketch::initAttributes()
   data()->addAttribute(SKETCH_ATTR_FEATURES, ModelAPI_AttributeRefList::type());
 }
 
-void SketchPlugin_Sketch::execute(boost::shared_ptr<ModelAPI_Result>& theResult
+void SketchPlugin_Sketch::execute() 
 {
   if (!isPlaneSet()) {
     std::list<boost::shared_ptr<GeomAPI_Shape> > aFaces;
@@ -45,7 +45,9 @@ void SketchPlugin_Sketch::execute(boost::shared_ptr<ModelAPI_Result>& theResult)
     addPlane(0, 1, 0, aFaces); // XZ plane
     addPlane(0, 0, 1, aFaces); // XY plane
     boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces);
-    boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult)->setShape(aCompound);
+    boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction();
+    aConstr->setShape(aCompound);
+    results().push_back(aConstr);
     return;
   }
   if (!data()->isValid())
@@ -74,7 +76,7 @@ void SketchPlugin_Sketch::execute(boost::shared_ptr<ModelAPI_Result>& theResult)
   for (; anIt != aLast; anIt++) {
     aFeature = boost::dynamic_pointer_cast<SketchPlugin_Feature>(*anIt);
     boost::shared_ptr<ModelAPI_ResultConstruction> aRes = 
-      boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(document()->result(aFeature));
+      boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aFeature->firstResult());
     if (aRes) {
       boost::shared_ptr<GeomAPI_Shape> aShape = aRes->shape();
       if (aShape)
@@ -91,17 +93,19 @@ void SketchPlugin_Sketch::execute(boost::shared_ptr<ModelAPI_Result>& theResult)
 
   aLoops.insert(aLoops.end(), aWires.begin(), aWires.end());
   boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aLoops);
-  boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult)->setShape(aCompound);
+  boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction();
+  aConstr->setShape(aCompound);
+  results().push_back(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;
+  return aResult;
 }
 
 const void SketchPlugin_Sketch::addSub(const FeaturePtr& theFeature)
index 798019b181b19afacd6855d4d71f3af0d147201e..c1dd3ecc1489fb78cb83a6fab472a924589c87d3 100644 (file)
@@ -36,12 +36,8 @@ public:
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
   {static std::string MY_KIND = SKETCH_KIND; return MY_KIND;}
 
-  /// Returns to which group in the document must be added feature
-  SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
-  {static std::string MY_GROUP = "Construction"; return MY_GROUP;}
-
   /// Creates a new part document if needed
-  SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr<ModelAPI_Result>& theResult);
+  SKETCHPLUGIN_EXPORT virtual void execute();
 
   /// Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();