]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Debug of construction point with results creation
authormpv <mikhail.ponikarov@opencascade.com>
Tue, 15 Jul 2014 11:24:52 +0000 (15:24 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Tue, 15 Jul 2014 11:24:52 +0000 (15:24 +0400)
12 files changed:
src/ConstructionPlugin/ConstructionPlugin_Point.cpp
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/Model/Model_Document.cpp
src/Model/Model_Document.h
src/ModelAPI/ModelAPI_Document.h
src/PartSetPlugin/PartSetPlugin_Part.cpp
src/SketchPlugin/SketchPlugin_Arc.cpp
src/SketchPlugin/SketchPlugin_Circle.cpp
src/SketchPlugin/SketchPlugin_Line.cpp
src/SketchPlugin/SketchPlugin_Point.cpp
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchSolver/SketchSolver_ConstraintManager.cpp

index 66dfdfdf1dab7c482058eb6b50bf3bb3bbb73016..1838d32d9ca42c1d37710e445d4eabdf2cf18956 100644 (file)
@@ -29,7 +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()));
 
-  boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction();
+  boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction(data());
   aConstr->setShape(GeomAlgoAPI_PointBuilder::point(aPnt));
-  results().push_back(aConstr);
+  setResult(aConstr);
 }
index 31fbe2cc1ac7198789104fbb92662fd487d3de08..0b2f2906b9c8892ebf607da60e03cad720c3c3c2 100644 (file)
@@ -44,8 +44,7 @@ void FeaturesPlugin_Extrusion::execute()
   double aSize = data()->real(EXTRUSION_SIZE)->value();
   if (data()->boolean(EXTRUSION_REVERSE)->value())
     aSize = -aSize;
-  boost::shared_ptr<ModelAPI_ResultBody> aResult = document()->createBody();
+  boost::shared_ptr<ModelAPI_ResultBody> aResult = document()->createBody(data());
   aResult->store(GeomAlgoAPI_Extrusion::makeExtrusion(aFace, aSize));
-  document()->storeResult(data(), aResult);
   setResult(aResult);
 }
index 86097b5e74ca78f15aa699bb418b87958f4b280d..091e70c63c05fb18aeeae78ed5168f0537f52ebb 100644 (file)
@@ -374,13 +374,6 @@ FeaturePtr Model_Document::addFeature(std::string theID)
   return aFeature;
 }
 
-void Model_Document::storeResult(boost::shared_ptr<ModelAPI_Data> theFeatureData,
-  boost::shared_ptr<ModelAPI_Result> theResult, const int theResultIndex)
-{
-  initData(theResult, boost::dynamic_pointer_cast<Model_Data>(theFeatureData)->
-    label().Father().FindChild(TAG_FEATURE_RESULTS), theResultIndex);
-}
-
 /// Appenad to the array of references a new referenced label.
 /// If theIndex is not -1, removes element at thisindex, not theReferenced.
 /// \returns the index of removed element
@@ -697,21 +690,38 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated)
     setCheckTransactions(true);
 }
 
-boost::shared_ptr<ModelAPI_ResultConstruction> Model_Document::createConstruction()
+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);
+  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()
+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()
+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;
 }
 
index f7b757261f20c0b1ac9d1559e0399c3996f9c3e3..db353a93babe0e59fa71ae479b6eceb8652b4091 100644 (file)
@@ -91,16 +91,15 @@ public:
   //! Returns the number of features in the group
   MODEL_EXPORT virtual int size(const std::string& theGroupID);
 
-  //! Allows to store the result in the data tree of the document (attaches 'data' of result to tree)
-  MODEL_EXPORT virtual void storeResult(boost::shared_ptr<ModelAPI_Data> theFeatureData,
-    boost::shared_ptr<ModelAPI_Result> theResult, const int theResultIndex = 0);
-
   /// Creates a construction cresults
-  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_ResultConstruction> createConstruction();
+  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();
+  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();
+  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> 
@@ -130,6 +129,9 @@ protected:
   //! 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;
index de54274044ea0c270f45c9b351892b8eb4846077..0a1a7f5b09c0f839d55fccb88ee08021977554c0 100644 (file)
@@ -88,11 +88,14 @@ public:
   virtual ~ModelAPI_Document() {}
 
   /// Creates a construction cresults
-  virtual boost::shared_ptr<ModelAPI_ResultConstruction> createConstruction() = 0;
+  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() = 0;
+  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() = 0;
+  virtual boost::shared_ptr<ModelAPI_ResultPart> createPart(
+    const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
 
   //! Allows to store the result in the data tree of the document (attaches 'data' of result to tree)
   virtual void storeResult(boost::shared_ptr<ModelAPI_Data> theFeatureData,
index ebd970ca510786a3f23567e91de0546c23bcfaf3..4c0d0dc110f08f808fcc743a0e42c35099028914 100644 (file)
@@ -30,7 +30,7 @@ void PartSetPlugin_Part::execute()
   }
   // create a result only once
   if (results().empty()) {
-    boost::shared_ptr<ModelAPI_ResultPart> aResult = document()->createPart();
+    boost::shared_ptr<ModelAPI_ResultPart> aResult = document()->createPart(data());
     document()->storeResult(data(), aResult);
     if (aResult->data()->name().empty())
       aResult->data()->setName(data()->name());
index 4b8e0e995f0ebed1521d4669190fe6c6f1191c7d..7e2e10979ac1588b777acc982ffc7e602c9007b9 100644 (file)
@@ -75,7 +75,8 @@ void SketchPlugin_Arc::execute()
       }
       boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes);
       // store the result
-      boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction();
+      boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = 
+        document()->createConstruction(data());
       aConstr->setShape(aCompound);
       results().push_back(aConstr);
     }
index a99677bf870d14cbb594bafd482c1e38e69eb01b..0d8b5516bf37bcc87ac0d8e7558c0281f966c7ef 100644 (file)
@@ -59,7 +59,8 @@ void SketchPlugin_Circle::execute()
     }
     boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes);
       // store the result
-      boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction();
+      boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = 
+        document()->createConstruction(data());
       aConstr->setShape(aCompound);
       setResult(aConstr);
   }
index aaad3a61fe0877b4ea85b6da805e3f507cfe22ce..08289d7de79ee5a32697aae24085e599d7ad794c 100644 (file)
@@ -46,7 +46,8 @@ void SketchPlugin_Line::execute()
       // make linear edge
       boost::shared_ptr<GeomAPI_Shape> anEdge = GeomAlgoAPI_EdgeBuilder::line(aStart, anEnd);
       // store the result
-      boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction();
+      boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = 
+        document()->createConstruction(data());
       aConstr->setShape(anEdge);
       setResult(aConstr);
     }
index 87a3ac08f654ea0b030a1d16d0c598a68191d69a..cf57a6c33884bc8d699aaca4435bd3d09f31306b 100644 (file)
@@ -34,7 +34,7 @@ void SketchPlugin_Point::execute()
     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::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction();
+    boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction(data());
     aConstr->setShape(aPointShape);
     setResult(aConstr);
   }
index 9874ec763a0fa30a7202ec30ee597a78acc23a18..d5e208d5ffbff72e01cfa9500b3d584737c9912f 100644 (file)
@@ -45,7 +45,8 @@ void SketchPlugin_Sketch::execute()
     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();
+    boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = 
+      document()->createConstruction(data());
     aConstr->setShape(aCompound);
     setResult(aConstr);
     return;
@@ -91,7 +92,7 @@ void SketchPlugin_Sketch::execute()
 
   aLoops.insert(aLoops.end(), aWires.begin(), aWires.end());
   boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aLoops);
-  boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction();
+  boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction(data());
   aConstr->setShape(aCompound);
   setResult(aConstr);
 }
index 0ff4507b854c0b690a2f05a20b8439459baf36c9..3bc8bb0859573ddd7bb96c1905b0533fa1dc52d8 100644 (file)
@@ -75,6 +75,7 @@ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessa
       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 = aFeature->getKind();
         if (aFeatureKind.compare(SKETCH_KIND) == 0)
@@ -92,10 +93,10 @@ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessa
         else
         {
           // Sketch plugin features can be only updated
-          boost::shared_ptr<SketchPlugin_Feature> aFeature =
+          boost::shared_ptr<SketchPlugin_Feature> aSFeature =
             boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
-          if (aFeature)
-            updateEntity(aFeature);
+          if (aSFeature)
+            updateEntity(aSFeature);
         }
       }
     }