]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Controlling the current feature of the document if the sketch feature is added.
authorazv <azv@opencascade.com>
Fri, 7 Jun 2019 08:45:02 +0000 (11:45 +0300)
committerazv <azv@opencascade.com>
Fri, 7 Jun 2019 08:45:02 +0000 (11:45 +0300)
src/SketchPlugin/SketchPlugin_Feature.cpp
src/SketchPlugin/SketchPlugin_Feature.h
src/SketchPlugin/SketchPlugin_IntersectionPoint.cpp
src/SketchPlugin/SketchPlugin_Projection.cpp
src/SketchPlugin/SketchPlugin_Split.cpp
src/SketchPlugin/SketchPlugin_Trim.cpp

index 6ad032f18babeb82f14283b8243686072265027f..9663e22c5db4c0bd23129bc759cae82ba2dc24aa 100644 (file)
@@ -57,3 +57,18 @@ SketchPlugin_Sketch* SketchPlugin_Feature::sketch()
   return mySketch;
 }
 
+void SketchPlugin_Feature::keepCurrentFeature()
+{
+  FeaturePtr aCurFeature = document()->currentFeature(true);
+  std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
+      std::dynamic_pointer_cast<SketchPlugin_Feature>(aCurFeature);
+  if (!aSketchFeature || aSketchFeature->sketch() == sketch())
+    myCurrentFeature = aCurFeature;
+}
+
+void SketchPlugin_Feature::restoreCurrentFeature()
+{
+  if (myCurrentFeature)
+    document()->setCurrentFeature(myCurrentFeature, true);
+  myCurrentFeature = FeaturePtr();
+}
index c5403b5c9a3d5cc05b3518b8a70675c0799d0691..7b5eebcbc505ad65af226401566f91f0fa8f325f 100644 (file)
@@ -78,11 +78,18 @@ protected:
   /// initializes mySketch
   SketchPlugin_Feature();
 
+  /// Store current feature of the document if it is not the sub-feature of the current sketch
+  void keepCurrentFeature();
+  /// Restore current feature of the document after adding new feature to the sketch
+  void restoreCurrentFeature();
+
   friend class SketchPlugin_Sketch;
 
- private:
+private:
   std::shared_ptr<GeomAPI_Shape> myPreview;  ///< the preview shape
   SketchPlugin_Sketch* mySketch;  /// sketch that contains this feature
+
+  FeaturePtr myCurrentFeature; /// temporary stored current feature
 };
 
 #endif
index 5563a6bd5cc5d0b483b31b6571c0132cb06713b2..ec038bc965b2d1c3df7b00e60bfd565e94b5a99c 100644 (file)
@@ -105,11 +105,15 @@ void SketchPlugin_IntersectionPoint::computePoint(const std::string& theID)
          aPntIt != anIntersectionsPoints.end(); ++aPntIt, ++aResultIndex) {
       std::shared_ptr<SketchPlugin_Point> aCurSketchPoint;
       if (aExistInterIt == anExistentIntersections.end()) {
+        keepCurrentFeature();
+
         // create new point
         aCurSketchPoint = std::dynamic_pointer_cast<SketchPlugin_Point>(
           sketch()->addFeature(SketchPlugin_Point::ID()));
         aCurSketchPoint->boolean(COPY_ID())->setValue(true);
         anIntersectionsList->append(aCurSketchPoint);
+
+        restoreCurrentFeature();
       } else {
         // update existent point
         aCurSketchPoint = std::dynamic_pointer_cast<SketchPlugin_Point>(*aExistInterIt);
index 0d40b618130d79109470f4f7ad9ef8d9f099180f..0a1a1b96f1a5d1fe4baab9a5263991b28bbbe717 100644 (file)
@@ -168,6 +168,8 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID)
       aProjection->selection(EXTERNAL_ID())->setValue(lastResult(), lastResult()->shape());
   }
 
+  keepCurrentFeature();
+
   if (aVertex) {
     std::shared_ptr<GeomAPI_Pnt> aPrjPnt = aSketchPlane->project(aVertex->point());
     std::shared_ptr<GeomAPI_Pnt2d> aPntInSketch = sketch()->to2D(aPrjPnt);
@@ -264,6 +266,8 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID)
   aProjection->execute();
   aRefAttr->setObject(aProjection);
 
+  restoreCurrentFeature();
+
   if (theID == EXTERNAL_FEATURE_ID()) {
     selection(EXTERNAL_ID())->selectValue(aExtFeature);
 
index 720da74a6f318af71193fc89b3e690462e5679b6..ac6a15d6d78d2094735b93585d9541e29e7ffb9f 100644 (file)
@@ -234,6 +234,8 @@ void SketchPlugin_Split::execute()
   std::cout << std::endl;
 #endif
 
+  keepCurrentFeature();
+
   std::string aFeatureKind = aBaseFeature->getKind();
   FeaturePtr aSplitFeature, anAfterFeature;
   std::set<AttributePoint2DPtr> aFurtherCoincidences;
@@ -246,6 +248,9 @@ void SketchPlugin_Split::execute()
   else if (aFeatureKind == SketchPlugin_Arc::ID())
     aNewFeature = splitArc(aSplitFeature, aBaseFeature, anAfterFeature, aFurtherCoincidences,
                            aCreatedFeatures, aModifiedAttributes);
+
+  restoreCurrentFeature();
+
   if (aFeatureKind == SketchPlugin_Circle::ID()) {
     FeaturePtr aCircleFeature = aBaseFeature;
     aReplacingFeature = splitCircle(aSplitFeature, aBaseFeature, anAfterFeature,
index bfaff6423fae92bfeb04d6cc22fce82228e0b30b..66d7157c1abb0fb372a78cb862de0585aa19a9be 100644 (file)
@@ -295,6 +295,9 @@ void SketchPlugin_Trim::execute()
   std::cout << "[" << aRefsToFeature.size() << "] " << aRefsInfo << std::endl;
   std::cout << "---- getRefAttributes:end ----" << std::endl;
 #endif
+
+  keepCurrentFeature();
+
   std::set<AttributePoint2DPtr> aFurtherCoincidences;
   std::set<std::pair<AttributePtr, AttributePtr>> aModifiedAttributes;
   const std::string& aKind = aBaseFeature->getKind();
@@ -318,6 +321,8 @@ void SketchPlugin_Trim::execute()
                           aFurtherCoincidences, aModifiedAttributes);
   }
 
+  restoreCurrentFeature();
+
   // constraints to end points of trim feature
   if (myObjectToPoints.find(aBaseObject) == myObjectToPoints.end())
     fillObjectShapes(aBaseObject, sketch()->data()->owner(), myCashedShapes, myObjectToPoints);