-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-// File: SketchPlugin_Projection.cpp
-// Created: 07 May 2014
-// Author: Artem ZHIDKOV
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
#include <SketchPlugin_Projection.h>
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.h>
+#include <ModelAPI_Tools.h>
#include <GeomAPI_Circ.h>
#include <GeomAPI_Edge.h>
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);
}
ResultConstructionPtr aResult =
std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(lastResult());
- if (aResult && aResult->shape()) {
+ if (aResult && aResult->shape() && theID == EXTERNAL_FEATURE_ID()) {
aResult->setShape(std::shared_ptr<GeomAPI_Edge>());
aProjection->selection(EXTERNAL_ID())->setValue(lastResult(), lastResult()->shape());
}
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 (!hasPrevProj) {
- FeaturePtr aFixed = sketch()->addFeature(SketchPlugin_ConstraintRigid::ID());
- aFixed->refattr(SketchPlugin_Constraint::ENTITY_A())->setObject(aProjection->lastResult());
- aFixed->execute();
- }
-
if (theID == EXTERNAL_FEATURE_ID()) {
selection(EXTERNAL_ID())->setValue(aExtFeature->context(), aExtFeature->value());