From: mpv Date: Tue, 15 Jul 2014 11:24:52 +0000 (+0400) Subject: Debug of construction point with results creation X-Git-Tag: V_0.4.4~190 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4d6f0ea359901682c24d70cb40346306f703c252;p=modules%2Fshaper.git Debug of construction point with results creation --- diff --git a/src/ConstructionPlugin/ConstructionPlugin_Point.cpp b/src/ConstructionPlugin/ConstructionPlugin_Point.cpp index 66dfdfdf1..1838d32d9 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Point.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Point.cpp @@ -29,7 +29,7 @@ void ConstructionPlugin_Point::execute() boost::shared_ptr 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 aConstr = document()->createConstruction(); + boost::shared_ptr aConstr = document()->createConstruction(data()); aConstr->setShape(GeomAlgoAPI_PointBuilder::point(aPnt)); - results().push_back(aConstr); + setResult(aConstr); } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp index 31fbe2cc1..0b2f2906b 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp @@ -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 aResult = document()->createBody(); + boost::shared_ptr aResult = document()->createBody(data()); aResult->store(GeomAlgoAPI_Extrusion::makeExtrusion(aFace, aSize)); - document()->storeResult(data(), aResult); setResult(aResult); } diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 86097b5e7..091e70c63 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -374,13 +374,6 @@ FeaturePtr Model_Document::addFeature(std::string theID) return aFeature; } -void Model_Document::storeResult(boost::shared_ptr theFeatureData, - boost::shared_ptr theResult, const int theResultIndex) -{ - initData(theResult, boost::dynamic_pointer_cast(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 Model_Document::createConstruction() +void Model_Document::storeResult(boost::shared_ptr theFeatureData, + boost::shared_ptr theResult, const int theResultIndex) +{ + boost::shared_ptr aThis = + Model_Application::getApplication()->getDocument(myID); + theResult->setDoc(aThis); + initData(theResult, boost::dynamic_pointer_cast(theFeatureData)-> + label().Father().FindChild(TAG_FEATURE_RESULTS), theResultIndex); + theResult->data()->setName(theFeatureData->name()); +} + +boost::shared_ptr Model_Document::createConstruction( + const boost::shared_ptr& theFeatureData, const int theIndex) { boost::shared_ptr aResult(new Model_ResultConstruction()); + storeResult(theFeatureData, aResult); return aResult; } -boost::shared_ptr Model_Document::createBody() +boost::shared_ptr Model_Document::createBody( + const boost::shared_ptr& theFeatureData, const int theIndex) { boost::shared_ptr aResult(new Model_ResultBody()); + storeResult(theFeatureData, aResult); return aResult; } -boost::shared_ptr Model_Document::createPart() +boost::shared_ptr Model_Document::createPart( + const boost::shared_ptr& theFeatureData, const int theIndex) { boost::shared_ptr aResult(new Model_ResultPart()); + storeResult(theFeatureData, aResult); return aResult; } diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index f7b757261..db353a93b 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -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 theFeatureData, - boost::shared_ptr theResult, const int theResultIndex = 0); - /// Creates a construction cresults - MODEL_EXPORT virtual boost::shared_ptr createConstruction(); + MODEL_EXPORT virtual boost::shared_ptr createConstruction( + const boost::shared_ptr& theFeatureData, const int theIndex = 0); /// Creates a body results - MODEL_EXPORT virtual boost::shared_ptr createBody(); + MODEL_EXPORT virtual boost::shared_ptr createBody( + const boost::shared_ptr& theFeatureData, const int theIndex = 0); /// Creates a part results - MODEL_EXPORT virtual boost::shared_ptr createPart(); + MODEL_EXPORT virtual boost::shared_ptr createPart( + const boost::shared_ptr& theFeatureData, const int theIndex = 0); //! Returns a feature by result (owner of result) MODEL_EXPORT virtual boost::shared_ptr @@ -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 theFeatureData, + boost::shared_ptr theResult, const int theResultIndex = 0); friend class Model_Application; diff --git a/src/ModelAPI/ModelAPI_Document.h b/src/ModelAPI/ModelAPI_Document.h index de5427404..0a1a7f5b0 100644 --- a/src/ModelAPI/ModelAPI_Document.h +++ b/src/ModelAPI/ModelAPI_Document.h @@ -88,11 +88,14 @@ public: virtual ~ModelAPI_Document() {} /// Creates a construction cresults - virtual boost::shared_ptr createConstruction() = 0; + virtual boost::shared_ptr createConstruction( + const boost::shared_ptr& theFeatureData, const int theIndex = 0) = 0; /// Creates a body results - virtual boost::shared_ptr createBody() = 0; + virtual boost::shared_ptr createBody( + const boost::shared_ptr& theFeatureData, const int theIndex = 0) = 0; /// Creates a part results - virtual boost::shared_ptr createPart() = 0; + virtual boost::shared_ptr createPart( + const boost::shared_ptr& 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 theFeatureData, diff --git a/src/PartSetPlugin/PartSetPlugin_Part.cpp b/src/PartSetPlugin/PartSetPlugin_Part.cpp index ebd970ca5..4c0d0dc11 100644 --- a/src/PartSetPlugin/PartSetPlugin_Part.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Part.cpp @@ -30,7 +30,7 @@ void PartSetPlugin_Part::execute() } // create a result only once if (results().empty()) { - boost::shared_ptr aResult = document()->createPart(); + boost::shared_ptr aResult = document()->createPart(data()); document()->storeResult(data(), aResult); if (aResult->data()->name().empty()) aResult->data()->setName(data()->name()); diff --git a/src/SketchPlugin/SketchPlugin_Arc.cpp b/src/SketchPlugin/SketchPlugin_Arc.cpp index 4b8e0e995..7e2e10979 100644 --- a/src/SketchPlugin/SketchPlugin_Arc.cpp +++ b/src/SketchPlugin/SketchPlugin_Arc.cpp @@ -75,7 +75,8 @@ void SketchPlugin_Arc::execute() } boost::shared_ptr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes); // store the result - boost::shared_ptr aConstr = document()->createConstruction(); + boost::shared_ptr aConstr = + document()->createConstruction(data()); aConstr->setShape(aCompound); results().push_back(aConstr); } diff --git a/src/SketchPlugin/SketchPlugin_Circle.cpp b/src/SketchPlugin/SketchPlugin_Circle.cpp index a99677bf8..0d8b5516b 100644 --- a/src/SketchPlugin/SketchPlugin_Circle.cpp +++ b/src/SketchPlugin/SketchPlugin_Circle.cpp @@ -59,7 +59,8 @@ void SketchPlugin_Circle::execute() } boost::shared_ptr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes); // store the result - boost::shared_ptr aConstr = document()->createConstruction(); + boost::shared_ptr aConstr = + document()->createConstruction(data()); aConstr->setShape(aCompound); setResult(aConstr); } diff --git a/src/SketchPlugin/SketchPlugin_Line.cpp b/src/SketchPlugin/SketchPlugin_Line.cpp index aaad3a61f..08289d7de 100644 --- a/src/SketchPlugin/SketchPlugin_Line.cpp +++ b/src/SketchPlugin/SketchPlugin_Line.cpp @@ -46,7 +46,8 @@ void SketchPlugin_Line::execute() // make linear edge boost::shared_ptr anEdge = GeomAlgoAPI_EdgeBuilder::line(aStart, anEnd); // store the result - boost::shared_ptr aConstr = document()->createConstruction(); + boost::shared_ptr aConstr = + document()->createConstruction(data()); aConstr->setShape(anEdge); setResult(aConstr); } diff --git a/src/SketchPlugin/SketchPlugin_Point.cpp b/src/SketchPlugin/SketchPlugin_Point.cpp index 87a3ac08f..cf57a6c33 100644 --- a/src/SketchPlugin/SketchPlugin_Point.cpp +++ b/src/SketchPlugin/SketchPlugin_Point.cpp @@ -34,7 +34,7 @@ void SketchPlugin_Point::execute() boost::shared_ptr aPoint3D(aSketch->to3D(aPoint->x(), aPoint->y())); // make a visible point boost::shared_ptr aPointShape = GeomAlgoAPI_PointBuilder::point(aPoint3D); - boost::shared_ptr aConstr = document()->createConstruction(); + boost::shared_ptr aConstr = document()->createConstruction(data()); aConstr->setShape(aPointShape); setResult(aConstr); } diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 9874ec763..d5e208d5f 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -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 aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces); - boost::shared_ptr aConstr = document()->createConstruction(); + boost::shared_ptr 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 aCompound = GeomAlgoAPI_CompoundBuilder::compound(aLoops); - boost::shared_ptr aConstr = document()->createConstruction(); + boost::shared_ptr aConstr = document()->createConstruction(data()); aConstr->setShape(aCompound); setResult(aConstr); } diff --git a/src/SketchSolver/SketchSolver_ConstraintManager.cpp b/src/SketchSolver/SketchSolver_ConstraintManager.cpp index 0ff4507b8..3bc8bb085 100644 --- a/src/SketchSolver/SketchSolver_ConstraintManager.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintManager.cpp @@ -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(*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 aFeature = + boost::shared_ptr aSFeature = boost::dynamic_pointer_cast(aFeature); - if (aFeature) - updateEntity(aFeature); + if (aSFeature) + updateEntity(aSFeature); } } }