]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Make sketch features invisible in constructions and fix the nested commit warning
authormpv <mikhail.ponikarov@opencascade.com>
Mon, 21 Jul 2014 09:04:50 +0000 (13:04 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Mon, 21 Jul 2014 09:04:50 +0000 (13:04 +0400)
src/Model/Model_Document.cpp
src/Model/Model_ResultConstruction.cpp
src/Model/Model_ResultConstruction.h
src/ModelAPI/ModelAPI_ResultConstruction.h
src/SketchPlugin/SketchPlugin_Arc.cpp
src/SketchPlugin/SketchPlugin_Circle.cpp
src/SketchPlugin/SketchPlugin_Line.cpp
src/SketchPlugin/SketchPlugin_Point.cpp

index 30bd5e293cceef5d1a5cdf336c346a7665d5c6b2..4ca962723f80c34bbdcc8d4a444e5fb8e1536756 100644 (file)
@@ -222,10 +222,17 @@ void Model_Document::compactNested() {
 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++;
index 8d230ab37c13f2881717dced37421cfd825fbe6c..0b6d56612c64ffd89b2e735e8f45f67788a29f97 100644 (file)
@@ -14,12 +14,12 @@ boost::shared_ptr<GeomAPI_Shape>& Model_ResultConstruction::shape()
   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;
 }
index e312f6fdab9e4bed0c14aeadbdcbef63fab614a1..fd04f2f7c642950909027891a55dd82537178a86 100644 (file)
@@ -19,13 +19,18 @@ class Model_ResultConstruction : public ModelAPI_ResultConstruction
 {
   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
index bd9220ae515033e8ef0c0392bb9b0456990eaa2d..231476e3c36c220125ce580eac3fc6b7a3da02c0 100644 (file)
@@ -34,6 +34,9 @@ public:
 
   /// 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
index 1445df99b718c0c335f0e43da15c61d987895ef3..d66b52dbec7571c4af3d3e716ad016b74625d9da 100644 (file)
@@ -37,19 +37,23 @@ void SketchPlugin_Arc::execute()
 
     // 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();
@@ -57,7 +61,8 @@ void SketchPlugin_Arc::execute()
 
         // 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(
@@ -78,6 +83,7 @@ void SketchPlugin_Arc::execute()
       boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = 
         document()->createConstruction(data());
       aConstr->setShape(aCompound);
+      aConstr->setIsInHistory(false);
       setResult(aConstr);
     }
   }
@@ -90,15 +96,18 @@ void SketchPlugin_Arc::move(double theDeltaX, double theDeltaY)
     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);
 }
 
@@ -108,17 +117,20 @@ double SketchPlugin_Arc::distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>&
   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;
index 60fd29daf7d9cf6714576c5d08aa4f5cf68af642..35371ff9dea7dd90994a7f78f0d83393224532e1 100644 (file)
@@ -34,9 +34,11 @@ void SketchPlugin_Circle::execute()
 
     // 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
@@ -45,7 +47,8 @@ void SketchPlugin_Circle::execute()
 
       // 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()));
@@ -62,6 +65,7 @@ void SketchPlugin_Circle::execute()
       boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = 
         document()->createConstruction(data());
       aConstr->setShape(aCompound);
+      aConstr->setIsInHistory(false);
       setResult(aConstr);
   }
 }
@@ -73,7 +77,8 @@ void SketchPlugin_Circle::move(double theDeltaX, double theDeltaY)
     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);
 }
 
@@ -81,7 +86,8 @@ double SketchPlugin_Circle::distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2
 {
   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);
 }
index 63577ef08b4605525090f6ce1e6e7641c17d0dc7..1a44e28605da683a8a4e7e8b19e426a9c645568c 100644 (file)
@@ -36,10 +36,12 @@ void SketchPlugin_Line::execute()
   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()));
@@ -49,6 +51,7 @@ void SketchPlugin_Line::execute()
       boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = 
         document()->createConstruction(data());
       aConstr->setShape(anEdge);
+      aConstr->setIsInHistory(false);
       setResult(aConstr);
     }
   }
@@ -61,11 +64,13 @@ void SketchPlugin_Line::move(double theDeltaX, double theDeltaY)
     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);
 }
 
@@ -75,9 +80,11 @@ double SketchPlugin_Line::distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>
 
   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());
 
index 5143b20a56626beb11434220a8cfa3509f4cbbfc..14efc4f6a3e5608c7f6ceb9cea72ab293600ee13 100644 (file)
@@ -30,12 +30,14 @@ void SketchPlugin_Point::execute()
   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);
   }
 }
@@ -47,7 +49,8 @@ void SketchPlugin_Point::move(double theDeltaX, double theDeltaY)
     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);
 }
 
@@ -55,7 +58,8 @@ double SketchPlugin_Point::distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d
 {
   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);
 }