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);
}
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);
}
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
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;
}
//! 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>
//! 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;
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,
}
// 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());
}
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);
}
}
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);
}
// 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);
}
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);
}
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;
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);
}
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)
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);
}
}
}