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);
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);
}
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) {
// 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
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 =
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();
}
} 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++) {
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++) {
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++;
}
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;
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;
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
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()
{
}
/// 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
// 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);
}
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.
/// 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;
// 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").
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;
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
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) {
}
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);
}
}
{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
data()->addAttribute(CONSTRAINT_ATTR_ENTITY_B, ModelAPI_AttributeRefAttr::type());
}
-void SketchPlugin_ConstraintCoincidence::execute(boost::shared_ptr<ModelAPI_Result>& theResult)
+void SketchPlugin_ConstraintCoincidence::execute()
{
}
{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();
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();
{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();
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()) {
{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();
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_Data.h>
+#include <ModelAPI_ResultConstruction.h>
#include <SketchPlugin_Line.h>
#include <SketchPlugin_Sketch.h>
data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT, GeomDataAPI_Point2D::type());
}
-void SketchPlugin_ConstraintParallel::execute(boost::shared_ptr<ModelAPI_Result>& theResult)
+void SketchPlugin_ConstraintParallel::execute()
{
}
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));
{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);
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_Data.h>
+#include <ModelAPI_ResultConstruction.h>
#include <SketchPlugin_Line.h>
#include <SketchPlugin_Sketch.h>
data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT, GeomDataAPI_Point2D::type());
}
-void SketchPlugin_ConstraintPerpendicular::execute(boost::shared_ptr<ModelAPI_Result>& theResult)
+void SketchPlugin_ConstraintPerpendicular::execute()
{
}
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)
{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);
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()) {
{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();
#include <ModelAPI_Data.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_AttributeRefList.h>
+#include <ModelAPI_ResultConstruction.h>
SketchPlugin_Feature::SketchPlugin_Feature()
{
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());
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;}
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) {
// 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);
}
}
}
{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
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) {
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);
}
}
{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
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;
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())
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)
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)
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();