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();
+}
/// 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
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);
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);
aProjection->execute();
aRefAttr->setObject(aProjection);
+ restoreCurrentFeature();
+
if (theID == EXTERNAL_FEATURE_ID()) {
selection(EXTERNAL_ID())->selectValue(aExtFeature);
std::cout << std::endl;
#endif
+ keepCurrentFeature();
+
std::string aFeatureKind = aBaseFeature->getKind();
FeaturePtr aSplitFeature, anAfterFeature;
std::set<AttributePoint2DPtr> aFurtherCoincidences;
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,
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();
aFurtherCoincidences, aModifiedAttributes);
}
+ restoreCurrentFeature();
+
// constraints to end points of trim feature
if (myObjectToPoints.find(aBaseObject) == myObjectToPoints.end())
fillObjectShapes(aBaseObject, sketch()->data()->owner(), myCashedShapes, myObjectToPoints);