#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.h>
+#include <ModelAPI_Tools.h>
#include <GeomAPI_Circ.h>
#include <GeomAPI_Edge.h>
return;
FeaturePtr aProjection = ModelAPI_Feature::feature(aRefAttr->object());
- if (!lastResult().get()) {
+ if (!lastResult().get() && aProjection->lastResult().get()) {
ResultConstructionPtr aConstr = document()->createConstruction(data());
aConstr->setShape(aProjection->lastResult()->shape());
aConstr->setIsInHistory(false);
aProjection->selection(EXTERNAL_ID())->setValue(lastResult(), lastResult()->shape());
}
+
+ // is sketch plane is changed (issue 1791), attribute of projection is not changed, but
+ // projection must be fully recomputed
+ computeProjection(EXTERNAL_FEATURE_ID());
}
void SketchPlugin_Projection::move(double theDeltaX, double theDeltaY)
std::shared_ptr<GeomAPI_Edge> anEdge;
if (aExtFeature && aExtFeature->value() && aExtFeature->value()->isEdge()) {
anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(aExtFeature->value()));
- } else if (aExtFeature->context() && aExtFeature->context()->shape() && aExtFeature->context()->shape()->isEdge()) {
+ } else if (aExtFeature->context() && aExtFeature->context()->shape() &&
+ aExtFeature->context()->shape()->isEdge()) {
anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(aExtFeature->context()->shape()));
}
if (!anEdge.get())
(anEdge->isCircle() && aProjection->getKind() != SketchPlugin_Circle::ID()) ||
(anEdge->isArc() && aProjection->getKind() != SketchPlugin_Arc::ID())) {
DocumentPtr aDoc = sketch()->document();
- aDoc->removeFeature(aProjection);
+
+ std::set<FeaturePtr> aFeaturesToBeRemoved;
+ aFeaturesToBeRemoved.insert(aProjection);
+ ModelAPI_Tools::removeFeaturesAndReferences(aFeaturesToBeRemoved);
aProjection = FeaturePtr();
aRefAttr->setObject(aProjection);
}
aProjection = sketch()->addFeature(SketchPlugin_Circle::ID());
// update attributes of projection
- std::shared_ptr<GeomDataAPI_Point2D> aCenterPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ std::shared_ptr<GeomDataAPI_Point2D> aCenterPnt =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aProjection->attribute(SketchPlugin_Circle::CENTER_ID()));
aCenterPnt->setValue(aCenterInSketch);
aProjection->real(SketchPlugin_Circle::RADIUS_ID())->setValue(aRadius);
aProjection = sketch()->addFeature(SketchPlugin_Arc::ID());
// update attributes of projection
- std::shared_ptr<GeomDataAPI_Point2D> aCenterPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ std::shared_ptr<GeomDataAPI_Point2D> aCenterPnt =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aProjection->attribute(SketchPlugin_Arc::CENTER_ID()));
- std::shared_ptr<GeomDataAPI_Point2D> aStartPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ std::shared_ptr<GeomDataAPI_Point2D> aStartPnt =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aProjection->attribute(SketchPlugin_Arc::START_ID()));
- std::shared_ptr<GeomDataAPI_Point2D> aEndPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ std::shared_ptr<GeomDataAPI_Point2D> aEndPnt =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aProjection->attribute(SketchPlugin_Arc::END_ID()));
aStartPnt->setValue(aFirstInSketch);
aEndPnt->setValue(aLastInSketch);
aCenterPnt->setValue(aCenterInSketch);
}
+ aProjection->boolean(COPY_ID())->setValue(true);
aProjection->execute();
aRefAttr->setObject(aProjection);
}
if (theID == EXTERNAL_FEATURE_ID()) {
- selection(EXTERNAL_ID())->setValue(aExtFeature->context(), aExtFeature->context()->shape());
+ selection(EXTERNAL_ID())->setValue(aExtFeature->context(), aExtFeature->value());
if (aResult) {
aResult->setShape(aProjection->lastResult()->shape());