Salome HOME
projects
/
modules
/
shaper.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Meet the coding style (line length <= 100)
[modules/shaper.git]
/
src
/
SketchPlugin
/
SketchPlugin_Projection.cpp
diff --git
a/src/SketchPlugin/SketchPlugin_Projection.cpp
b/src/SketchPlugin/SketchPlugin_Projection.cpp
index 319f200cb3069c54aa30ec91c47907a27d60f2bf..2a034e0f5f72c8bd6db7f6e6ab68263df23e8c41 100644
(file)
--- a/
src/SketchPlugin/SketchPlugin_Projection.cpp
+++ b/
src/SketchPlugin/SketchPlugin_Projection.cpp
@@
-18,6
+18,7
@@
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.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>
#include <GeomAPI_Circ.h>
#include <GeomAPI_Edge.h>
@@
-31,12
+32,6
@@
static const double tolerance = 1.e-7;
static const double tolerance = 1.e-7;
-static std::shared_ptr<GeomAPI_Edge> emptyEdge()
-{
- static std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge);
- return anEdge;
-}
-
SketchPlugin_Projection::SketchPlugin_Projection()
: SketchPlugin_SketchEntity(),
myIsComputing(false)
SketchPlugin_Projection::SketchPlugin_Projection()
: SketchPlugin_SketchEntity(),
myIsComputing(false)
@@
-64,13
+59,17
@@
void SketchPlugin_Projection::execute()
if (!lastResult().get() && aProjection->lastResult().get()) {
ResultConstructionPtr aConstr = document()->createConstruction(data());
if (!lastResult().get() && aProjection->lastResult().get()) {
ResultConstructionPtr aConstr = document()->createConstruction(data());
- aConstr->setShape(
emptyEdg
e());
+ aConstr->setShape(
aProjection->lastResult()->shap
e());
aConstr->setIsInHistory(false);
aConstr->setDisplayed(false);
setResult(aConstr);
aProjection->selection(EXTERNAL_ID())->setValue(lastResult(), lastResult()->shape());
}
aConstr->setIsInHistory(false);
aConstr->setDisplayed(false);
setResult(aConstr);
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)
}
void SketchPlugin_Projection::move(double theDeltaX, double theDeltaY)
@@
-95,7
+94,8
@@
void SketchPlugin_Projection::computeProjection(const std::string& theID)
std::shared_ptr<GeomAPI_Edge> anEdge;
if (aExtFeature && aExtFeature->value() && aExtFeature->value()->isEdge()) {
anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(aExtFeature->value()));
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 = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(aExtFeature->context()->shape()));
}
if (!anEdge.get())
@@
-113,7
+113,10
@@
void SketchPlugin_Projection::computeProjection(const std::string& theID)
(anEdge->isCircle() && aProjection->getKind() != SketchPlugin_Circle::ID()) ||
(anEdge->isArc() && aProjection->getKind() != SketchPlugin_Arc::ID())) {
DocumentPtr aDoc = sketch()->document();
(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 = FeaturePtr();
aRefAttr->setObject(aProjection);
}
@@
-123,7
+126,7
@@
void SketchPlugin_Projection::computeProjection(const std::string& theID)
ResultConstructionPtr aResult =
std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(lastResult());
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());
}
aResult->setShape(std::shared_ptr<GeomAPI_Edge>());
aProjection->selection(EXTERNAL_ID())->setValue(lastResult(), lastResult()->shape());
}
@@
-159,7
+162,8
@@
void SketchPlugin_Projection::computeProjection(const std::string& theID)
aProjection = sketch()->addFeature(SketchPlugin_Circle::ID());
// update attributes of projection
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->attribute(SketchPlugin_Circle::CENTER_ID()));
aCenterPnt->setValue(aCenterInSketch);
aProjection->real(SketchPlugin_Circle::RADIUS_ID())->setValue(aRadius);
@@
-178,31
+182,29
@@
void SketchPlugin_Projection::computeProjection(const std::string& theID)
aProjection = sketch()->addFeature(SketchPlugin_Arc::ID());
// update attributes of projection
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()));
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()));
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->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);
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()) {
if (theID == EXTERNAL_FEATURE_ID()) {
- selection(EXTERNAL_ID())->setValue(aExtFeature->context(), aExtFeature->
context()->shap
e());
+ selection(EXTERNAL_ID())->setValue(aExtFeature->context(), aExtFeature->
valu
e());
if (aResult) {
if (aResult) {
- aResult->setShape(
emptyEdg
e());
+ aResult->setShape(
aProjection->lastResult()->shap
e());
setResult(aResult);
aProjection->selection(EXTERNAL_ID())->setValue(lastResult(), lastResult()->shape());
}
setResult(aResult);
aProjection->selection(EXTERNAL_ID())->setValue(lastResult(), lastResult()->shape());
}