]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/SketchPlugin/SketchPlugin_Sketch.cpp
Salome HOME
Initial version of redesign of working with results
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Sketch.cpp
index 7bc0ec60084671eb3367d3baf5f3986fecbec408..b451c99b061f9666c2446bff768bd2383fe8b3b5 100644 (file)
@@ -12,6 +12,7 @@
 #include <GeomAlgoAPI_FaceBuilder.h>
 #include <GeomAlgoAPI_CompoundBuilder.h>
 #include <GeomAlgoAPI_SketchBuilder.h>
+#include <ModelAPI_ResultConstruction.h>
 
 
 const int SKETCH_PLANE_COLOR = Colors::COLOR_BROWN; /// the plane edge color
@@ -35,8 +36,18 @@ void SketchPlugin_Sketch::initAttributes()
   data()->addAttribute(SKETCH_ATTR_FEATURES, ModelAPI_AttributeRefList::type());
 }
 
-void SketchPlugin_Sketch::execute() 
+void SketchPlugin_Sketch::execute(boost::shared_ptr<ModelAPI_Result>& theResult
 {
+  if (!isPlaneSet()) {
+    std::list<boost::shared_ptr<GeomAPI_Shape> > aFaces;
+
+    addPlane(1, 0, 0, aFaces); // YZ plane
+    addPlane(0, 1, 0, aFaces); // XZ plane
+    addPlane(0, 0, 1, aFaces); // XY plane
+    boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces);
+    boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult)->setShape(aCompound);
+    return;
+  }
   if (!data()->isValid())
     return ;
   boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
@@ -62,9 +73,13 @@ void SketchPlugin_Sketch::execute()
   std::list< boost::shared_ptr<GeomAPI_Shape> > aFeaturesPreview;
   for (; anIt != aLast; anIt++) {
     aFeature = boost::dynamic_pointer_cast<SketchPlugin_Feature>(*anIt);
-    boost::shared_ptr<GeomAPI_Shape> aPreview = aFeature->preview();
-    if (aPreview)
-      aFeaturesPreview.push_back(aPreview);
+    boost::shared_ptr<ModelAPI_ResultConstruction> aRes = 
+      boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(document()->result(aFeature));
+    if (aRes) {
+      boost::shared_ptr<GeomAPI_Shape> aShape = aRes->shape();
+      if (aShape)
+        aFeaturesPreview.push_back(aShape);
+    }
   }
 
   if (aFeaturesPreview.empty())
@@ -76,7 +91,7 @@ void SketchPlugin_Sketch::execute()
 
   aLoops.insert(aLoops.end(), aWires.begin(), aWires.end());
   boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aLoops);
-  data()->store(aCompound);
+  boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult)->setShape(aCompound);
 }
 
 boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Sketch::getAISObject(
@@ -89,23 +104,6 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Sketch::getAISObject(
   return anAIS;
 }
 
-const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Sketch::preview()
-{
-  if (isPlaneSet()) {
-    setPreview(boost::shared_ptr<GeomAPI_Shape>());
-  }
-  else {
-    std::list<boost::shared_ptr<GeomAPI_Shape> > aFaces;
-
-    addPlane(1, 0, 0, aFaces); // YZ plane
-    addPlane(0, 1, 0, aFaces); // XZ plane
-    addPlane(0, 0, 1, aFaces); // XY plane
-    boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces);
-    setPreview(aCompound);
-  }
-  return getPreview();
-}
-
 const void SketchPlugin_Sketch::addSub(const FeaturePtr& theFeature)
 {
   boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature)->setSketch(this);