void Model_Document::finishOperation()
{
// just to be sure that everybody knows that changes were performed
+
+ if (!myDoc->HasOpenCommand() && myNestedNum != -1)
+ boost::static_pointer_cast<Model_PluginManager>(Model_PluginManager::get())->
+ setCheckTransactions(false); // for nested transaction commit
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
+ if (!myDoc->HasOpenCommand() && myNestedNum != -1)
+ boost::static_pointer_cast<Model_PluginManager>(Model_PluginManager::get())->
+ setCheckTransactions(true); // for nested transaction commit
if (myNestedNum != -1) // this nested transaction is owervritten
myNestedNum++;
return myShape;
}
-/*
-boost::shared_ptr<ModelAPI_Feature> Model_ResultConstruction::owner()
+Model_ResultConstruction::Model_ResultConstruction()
{
- return myOwner;
-}*/
+ myIsInHistory = true;
+}
-Model_ResultConstruction::Model_ResultConstruction()
+void Model_ResultConstruction::setIsInHistory(const bool isInHistory)
{
+ myIsInHistory = isInHistory;
}
{
boost::shared_ptr<ModelAPI_Feature> myOwner; ///< owner of this result
boost::shared_ptr<GeomAPI_Shape> myShape; ///< shape of this result created "on the fly"
+ bool myIsInHistory;
public:
+ /// By default object is displayed in the object browser.
+ MODEL_EXPORT virtual bool isInHistory() {return myIsInHistory;}
+
/// Sets the result
MODEL_EXPORT virtual void setShape(boost::shared_ptr<GeomAPI_Shape> theShape);
/// 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();
+
+ /// Sets the flag that it must be displayed in history (default is true)
+ MODEL_EXPORT virtual void setIsInHistory(const bool myIsInHistory);
protected:
/// Makes a body on the given feature
/// Sets the result
virtual void setShape(boost::shared_ptr<GeomAPI_Shape> theShape) = 0;
+
+ /// Sets the flag that it must be displayed in history (default is true)
+ virtual void setIsInHistory(const bool isInHistory) = 0;
};
//! Pointer on feature object
// compute a circle point in 3D view
boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Arc::CENTER_ID()));
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ data()->attribute(SketchPlugin_Arc::CENTER_ID()));
// compute the arc start point
boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Arc::START_ID()));
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ data()->attribute(SketchPlugin_Arc::START_ID()));
if (aCenterAttr->isInitialized() && aStartAttr->isInitialized()) {
- boost::shared_ptr<GeomAPI_Pnt> aCenter(aSketch->to3D(aCenterAttr->x(), aCenterAttr->y()));
+ boost::shared_ptr<GeomAPI_Pnt> aCenter(
+ aSketch->to3D(aCenterAttr->x(), aCenterAttr->y()));
// make a visible point
boost::shared_ptr<GeomAPI_Shape> aCenterPointShape = GeomAlgoAPI_PointBuilder::point(aCenter);
aShapes.push_back(aCenterPointShape);
// make a visible circle
boost::shared_ptr<GeomDataAPI_Dir> aNDir =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
+ boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
bool aHasPlane = aNDir && !(aNDir->x() == 0 && aNDir->y() == 0 && aNDir->z() == 0);
if (aHasPlane) {
boost::shared_ptr<GeomAPI_Dir> aNormal = aNDir->dir();
// compute and change the arc end point
boost::shared_ptr<GeomDataAPI_Point2D> anEndAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Arc::END_ID()));
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(
+ SketchPlugin_Arc::END_ID()));
if (anEndAttr->isInitialized())
{
boost::shared_ptr<GeomAPI_Circ2d> aCircleForArc(
boost::shared_ptr<ModelAPI_ResultConstruction> aConstr =
document()->createConstruction(data());
aConstr->setShape(aCompound);
+ aConstr->setIsInHistory(false);
setResult(aConstr);
}
}
return;
boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::CENTER_ID()));
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Arc::CENTER_ID()));
aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::START_ID()));
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Arc::START_ID()));
aPoint2->setValue(aPoint2->x() + theDeltaX, aPoint2->y() + theDeltaY);
boost::shared_ptr<GeomDataAPI_Point2D> aPoint3 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::END_ID()));
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Arc::END_ID()));
aPoint3->setValue(aPoint3->x() + theDeltaX, aPoint3->y() + theDeltaY);
}
boost::shared_ptr<ModelAPI_Data> aData = data();
boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::CENTER_ID()));
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Arc::CENTER_ID()));
aDelta = aPoint1->pnt()->distance(thePoint);
boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::START_ID()));
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Arc::START_ID()));
double aDistance = aPoint2->pnt()->distance(thePoint);
if (aDelta < aDistance)
aDelta = aDistance;
boost::shared_ptr<GeomDataAPI_Point2D> aPoint3 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::END_ID()));
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Arc::END_ID()));
aDistance = aPoint3->pnt()->distance(thePoint);
if (aDelta < aDistance)
aDelta = aDistance;
// compute a circle point in 3D view
boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Circle::CENTER_ID()));
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ data()->attribute(SketchPlugin_Circle::CENTER_ID()));
AttributeDoublePtr aRadiusAttr =
- boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Circle::RADIUS_ID()));
+ boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
+ data()->attribute(SketchPlugin_Circle::RADIUS_ID()));
if (aCenterAttr->isInitialized() && aRadiusAttr->isInitialized()) {
boost::shared_ptr<GeomAPI_Pnt> aCenter(aSketch->to3D(aCenterAttr->x(), aCenterAttr->y()));
// make a visible point
// make a visible circle
boost::shared_ptr<GeomDataAPI_Dir> aNDir =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
+ boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aSketch->data()->attribute(
+ SketchPlugin_Sketch::NORM_ID()));
bool aHasPlane = aNDir && !(aNDir->x() == 0 && aNDir->y() == 0 && aNDir->z() == 0);
if (aHasPlane) {
boost::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(aNDir->x(), aNDir->y(), aNDir->z()));
boost::shared_ptr<ModelAPI_ResultConstruction> aConstr =
document()->createConstruction(data());
aConstr->setShape(aCompound);
+ aConstr->setIsInHistory(false);
setResult(aConstr);
}
}
return;
boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Circle::CENTER_ID()));
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Circle::CENTER_ID()));
aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
}
{
boost::shared_ptr<ModelAPI_Data> aData = data();
boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Circle::CENTER_ID()));
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Circle::CENTER_ID()));
return aPoint->pnt()->distance(thePoint);
}
if (aSketch) {
// compute a start point in 3D view
boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Line::START_ID()));
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ data()->attribute(SketchPlugin_Line::START_ID()));
// compute an end point in 3D view
boost::shared_ptr<GeomDataAPI_Point2D> anEndAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Line::END_ID()));
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ data()->attribute(SketchPlugin_Line::END_ID()));
if (aStartAttr->isInitialized() && anEndAttr->isInitialized()) {
boost::shared_ptr<GeomAPI_Pnt> aStart(aSketch->to3D(aStartAttr->x(), aStartAttr->y()));
boost::shared_ptr<GeomAPI_Pnt> anEnd(aSketch->to3D(anEndAttr->x(), anEndAttr->y()));
boost::shared_ptr<ModelAPI_ResultConstruction> aConstr =
document()->createConstruction(data());
aConstr->setShape(anEdge);
+ aConstr->setIsInHistory(false);
setResult(aConstr);
}
}
return;
boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::START_ID()));
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Line::START_ID()));
aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::END_ID()));
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Line::END_ID()));
aPoint2->setValue(aPoint2->x() + theDeltaX, aPoint2->y() + theDeltaY);
}
boost::shared_ptr<ModelAPI_Data> aData = data();
boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::START_ID()));
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Line::START_ID()));
boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::END_ID()));
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Line::END_ID()));
GeomAPI_Lin2d aLin2d(aPoint1->x(), aPoint1->y(), aPoint2->x(), aPoint2->y());
if (aSketch) {
// compute a point in 3D view
boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Point::COORD_ID()));
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ data()->attribute(SketchPlugin_Point::COORD_ID()));
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(data());
aConstr->setShape(aPointShape);
+ aConstr->setIsInHistory(false);
setResult(aConstr);
}
}
return;
boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Point::COORD_ID()));
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Point::COORD_ID()));
aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
}
{
boost::shared_ptr<ModelAPI_Data> aData = data();
boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Point::COORD_ID()));
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Point::COORD_ID()));
return aPoint->pnt()->distance(thePoint);
}