diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp
index 7260fa674327..37e9e8713d2a 100644
--- a/src/Mod/Sketcher/App/SketchObject.cpp
+++ b/src/Mod/Sketcher/App/SketchObject.cpp
@@ -51,8 +51,6 @@
#include
#include
-#include
-
#include
#include "SketchObject.h"
@@ -169,21 +167,8 @@ App::DocumentObjectExecReturn *SketchObject::execute(void)
return App::DocumentObject::StdReturn;
}
-int SketchObject::hasConflicts(void)
-{
- // TODO: This must be reviewed to see if we are not setting an already set geometry again (and calculating again)
- // it is unclear if we need to know if there are conflicts of an updated geometry that has not been already solved
- // or not.
-
- // set up a sketch (including dofs counting and diagnosing of conflicts)
- /*lastDoF = solvedSketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(),
- getExternalGeometryCount());
-
- lastHasConflict = solvedSketch.hasConflicts();
- lastHasRedundancies = solvedSketch.hasRedundancies();
- lastConflicting=solvedSketch.getConflicting();
- lastRedundant=solvedSketch.getRedundant();*/
-
+int SketchObject::hasConflicts(void) const
+{
if (lastDoF < 0) // over-constrained sketch
return -2;
if (solvedSketch.hasConflicts()) // conflicting constraints
@@ -192,8 +177,12 @@ int SketchObject::hasConflicts(void)
return 0;
}
-int SketchObject::solve()
+int SketchObject::solve(bool updateGeoAfterSolving/*=true*/)
{
+ // if updateGeoAfterSolving=false, the solver information is updated, but the Sketch is nothing
+ // updated. It is useful to avoid triggering an OnChange when the goeometry did not change but
+ // the solver needs to be updated.
+
// We should have an updated Sketcher geometry or this solver should not have happened
// therefore we update our sketch object geometry with the SketchObject one.
//
@@ -222,7 +211,7 @@ int SketchObject::solve()
lastRedundant=solvedSketch.getRedundant();
lastSolveTime=solvedSketch.SolveTime;
- if (err == 0) {
+ if (err == 0 && updateGeoAfterSolving) {
// set the newly solved geometry
std::vector geomlist = solvedSketch.extractGeometry();
Geometry.setValues(geomlist);
@@ -360,7 +349,7 @@ int SketchObject::toggleDriving(int ConstrId)
return 0;
}
-int SketchObject::movePoint(int GeoId, PointPos PosId, const Base::Vector3d& toPoint, bool relative, bool updateGeometry)
+int SketchObject::movePoint(int GeoId, PointPos PosId, const Base::Vector3d& toPoint, bool relative, bool updateGeoBeforeMoving)
{
// if we are moving a point at SketchObject level, we need to start from a solved sketch
// if we have conflicts we can forget about moving. However, there is the possibility that we
@@ -370,7 +359,7 @@ int SketchObject::movePoint(int GeoId, PointPos PosId, const Base::Vector3d& toP
// of SketchObject upon moving. => use updateGeometry parameter = true then
- if(updateGeometry || solverNeedsUpdate) {
+ if(updateGeoBeforeMoving || solverNeedsUpdate) {
lastDoF = solvedSketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(),
getExternalGeometryCount());
@@ -493,38 +482,39 @@ void SketchObject::acceptGeometry()
rebuildVertexIndex();
}
-int SketchObject::addGeometry(const std::vector &geoList)
+int SketchObject::addGeometry(const std::vector &geoList, bool construction/*=false*/)
{
const std::vector< Part::Geometry * > &vals = getInternalGeometry();
std::vector< Part::Geometry * > newVals(vals);
for (std::vector::const_iterator it = geoList.begin(); it != geoList.end(); ++it) {
+ if((*it)->getTypeId() != Part::GeomPoint::getClassTypeId())
+ const_cast(*it)->Construction = construction;
+
newVals.push_back(*it);
}
Geometry.setValues(newVals);
Constraints.acceptGeometry(getCompleteGeometry());
rebuildVertexIndex();
- if(noRecomputes) // if we do not have a recompute after the geometry creation, the sketch must be solved to update the DoF of the solver
- solve();
-
return Geometry.getSize()-1;
}
-int SketchObject::addGeometry(const Part::Geometry *geo)
+int SketchObject::addGeometry(const Part::Geometry *geo, bool construction/*=false*/)
{
const std::vector< Part::Geometry * > &vals = getInternalGeometry();
std::vector< Part::Geometry * > newVals(vals);
Part::Geometry *geoNew = geo->clone();
+
+ if(geoNew->getTypeId() != Part::GeomPoint::getClassTypeId())
+ geoNew->Construction = construction;
+
newVals.push_back(geoNew);
Geometry.setValues(newVals);
Constraints.acceptGeometry(getCompleteGeometry());
delete geoNew;
rebuildVertexIndex();
-
- if(noRecomputes) // if we do not have a recompute after the geometry creation, the sketch must be solved to update the DoF of the solver
- solve();
return Geometry.getSize()-1;
}
@@ -1645,6 +1635,9 @@ int SketchObject::ExposeInternalGeometry(int GeoId)
double minord;
Base::Vector3d majdir;
+ std::vector igeo;
+ std::vector icon;
+
if(geo->getTypeId() == Part::GeomEllipse::getClassTypeId()){
const Part::GeomEllipse *ellipse = static_cast(geo);
@@ -1679,9 +1672,7 @@ int SketchObject::ExposeInternalGeometry(int GeoId)
Part::GeomLineSegment *lmajor = new Part::GeomLineSegment();
lmajor->setPoints(majorpositiveend,majornegativeend);
- this->addGeometry(lmajor); // create line for major axis
- this->setConstruction(currentgeoid+incrgeo+1,true);
- delete lmajor;
+ igeo.push_back(lmajor);
Sketcher::Constraint *newConstr = new Sketcher::Constraint();
newConstr->Type = Sketcher::InternalAlignment;
@@ -1689,8 +1680,7 @@ int SketchObject::ExposeInternalGeometry(int GeoId)
newConstr->First = currentgeoid+incrgeo+1;
newConstr->Second = GeoId;
- addConstraint(newConstr);
- delete newConstr;
+ icon.push_back(newConstr);
incrgeo++;
}
if(!minor)
@@ -1698,9 +1688,7 @@ int SketchObject::ExposeInternalGeometry(int GeoId)
Part::GeomLineSegment *lminor = new Part::GeomLineSegment();
lminor->setPoints(minorpositiveend,minornegativeend);
- this->addGeometry(lminor); // create line for major axis
- this->setConstruction(currentgeoid+incrgeo+1,true);
- delete lminor;
+ igeo.push_back(lminor);
Sketcher::Constraint *newConstr = new Sketcher::Constraint();
newConstr->Type = Sketcher::InternalAlignment;
@@ -1708,16 +1696,15 @@ int SketchObject::ExposeInternalGeometry(int GeoId)
newConstr->First = currentgeoid+incrgeo+1;
newConstr->Second = GeoId;
- addConstraint(newConstr);
- delete newConstr;
+ icon.push_back(newConstr);
incrgeo++;
}
if(!focus1)
{
Part::GeomPoint *pf1 = new Part::GeomPoint();
pf1->setPoint(focus1P);
- this->addGeometry(pf1);
- delete pf1;
+
+ igeo.push_back(pf1);
Sketcher::Constraint *newConstr = new Sketcher::Constraint();
newConstr->Type = Sketcher::InternalAlignment;
@@ -1726,16 +1713,14 @@ int SketchObject::ExposeInternalGeometry(int GeoId)
newConstr->FirstPos = Sketcher::start;
newConstr->Second = GeoId;
- addConstraint(newConstr);
- delete newConstr;
+ icon.push_back(newConstr);
incrgeo++;
}
if(!focus2)
{
Part::GeomPoint *pf2 = new Part::GeomPoint();
pf2->setPoint(focus2P);
- this->addGeometry(pf2);
- delete pf2;
+ igeo.push_back(pf2);
Sketcher::Constraint *newConstr = new Sketcher::Constraint();
newConstr->Type = Sketcher::InternalAlignment;
@@ -1744,10 +1729,23 @@ int SketchObject::ExposeInternalGeometry(int GeoId)
newConstr->FirstPos = Sketcher::start;
newConstr->Second = GeoId;
- addConstraint(newConstr);
- delete newConstr;
+ icon.push_back(newConstr);
}
+ this->addGeometry(igeo,true);
+ this->addConstraints(icon);
+
+ for (std::vector::iterator it=igeo.begin(); it != igeo.end(); ++it)
+ if (*it)
+ delete *it;
+
+ for (std::vector::iterator it=icon.begin(); it != icon.end(); ++it)
+ if (*it)
+ delete *it;
+
+ icon.clear();
+ igeo.clear();
+
return incrgeo; //number of added elements
}
else
diff --git a/src/Mod/Sketcher/App/SketchObject.h b/src/Mod/Sketcher/App/SketchObject.h
index 921d606a3e74..1ba4a5148159 100644
--- a/src/Mod/Sketcher/App/SketchObject.h
+++ b/src/Mod/Sketcher/App/SketchObject.h
@@ -51,7 +51,7 @@ class SketcherExport SketchObject : public Part::Part2DObject
App ::PropertyLinkSubList ExternalGeometry;
/** @name methods overide Feature */
//@{
- /// recalculate the Feature (if no recompute is needed see also solve() and updateSolverGeometry() )
+ /// recalculate the Feature (if no recompute is needed see also solve() and solverNeedsUpdate boolean)
App::DocumentObjectExecReturn *execute(void);
/// returns the type name of the ViewProvider
@@ -66,14 +66,15 @@ class SketcherExport SketchObject : public Part::Part2DObject
it is just less efficient.
This flag does not regulate whether this object will recompute or not if execute() or a recompute() is actually executed,
- it just regulates whether the solver is called upon geometry addition or not (relies on the solve of execute for the calculation)
+ it just regulates whether the solver is called or not (i.e. whether it relies on
+ the solve of execute for the calculation)
*/
bool noRecomputes;
/// add unspecified geometry
- int addGeometry(const Part::Geometry *geo);
+ int addGeometry(const Part::Geometry *geo, bool construction=false);
/// add unspecified geometry
- int addGeometry(const std::vector &geoList);
+ int addGeometry(const std::vector &geoList, bool construction=false);
/// delete geometry
int delGeometry(int GeoId);
/// add all constraints in the list
@@ -116,13 +117,14 @@ class SketcherExport SketchObject : public Part::Part2DObject
std::vector getCompleteGeometry(void) const;
/// returns non zero if the sketch contains conflicting constraints
- int hasConflicts(void);
+ int hasConflicts(void) const;
/** solves the sketch and updates the geometry, but not all the dependent features (does not recompute)
When a recompute is necessary, recompute triggers execute() which solves the sketch and updates all dependent features
- When a solve only is necessary (e.g. DoF changed), solve() solves the sketch and updates the geometry, but does not trigger any updates
+ When a solve only is necessary (e.g. DoF changed), solve() solves the sketch and
+ updates the geometry (if updateGeoAfterSolving==true), but does not trigger any updates
*/
- int solve();
+ int solve(bool updateGeoAfterSolving=true);
/// set the datum of a Distance or Angle constraint and solve
int setDatum(int ConstrId, double Datum);
/// set the driving status of this constraint and solve
@@ -132,7 +134,7 @@ class SketcherExport SketchObject : public Part::Part2DObject
/// toggle the driving status of this constraint
int toggleDriving(int ConstrId);
/// move this point to a new location and solve
- int movePoint(int GeoId, PointPos PosId, const Base::Vector3d& toPoint, bool relative=false, bool updateGeometry=false);
+ int movePoint(int GeoId, PointPos PosId, const Base::Vector3d& toPoint, bool relative=false, bool updateGeoBeforeMoving=false);
/// retrieves the coordinates of a point
Base::Vector3d getPoint(int GeoId, PointPos PosId) const;
@@ -227,7 +229,7 @@ class SketcherExport SketchObject : public Part::Part2DObject
/// get called by the container when a property has changed
virtual void onChanged(const App::Property* /*prop*/);
virtual void onDocumentRestored();
-
+
private:
std::vector ExternalGeo;
diff --git a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp
index 7e7d2c5faf39..3e1195c5f321 100644
--- a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp
+++ b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp
@@ -64,9 +64,19 @@ PyObject* SketchObjectPy::solve(PyObject *args)
PyObject* SketchObjectPy::addGeometry(PyObject *args)
{
- PyObject *pcObj;
- if (!PyArg_ParseTuple(args, "O", &pcObj))
- return 0;
+ PyObject *pcObj;
+ PyObject* construction; // this is an optional argument default false
+ bool isConstruction;
+ if (!PyArg_ParseTuple(args, "OO!", &pcObj, &PyBool_Type, &construction)) {
+ PyErr_Clear();
+ if (!PyArg_ParseTuple(args, "O", &pcObj))
+ return 0;
+ else
+ isConstruction=false;
+ }
+ else {
+ isConstruction = PyObject_IsTrue(construction) ? true : false;
+ }
if (PyObject_TypeCheck(pcObj, &(Part::GeometryPy::Type))) {
Part::Geometry *geo = static_cast(pcObj)->getGeometryPtr();
@@ -80,13 +90,13 @@ PyObject* SketchObjectPy::addGeometry(PyObject *args)
// create the definition struct for that geom
Part::GeomArcOfCircle aoc;
aoc.setHandle(trim);
- ret = this->getSketchObjectPtr()->addGeometry(&aoc);
+ ret = this->getSketchObjectPtr()->addGeometry(&aoc,isConstruction);
}
else if (!ellipse.IsNull()) {
// create the definition struct for that geom
Part::GeomArcOfEllipse aoe;
aoe.setHandle(trim);
- ret = this->getSketchObjectPtr()->addGeometry(&aoe);
+ ret = this->getSketchObjectPtr()->addGeometry(&aoe,isConstruction);
}
else {
std::stringstream str;
@@ -101,7 +111,7 @@ PyObject* SketchObjectPy::addGeometry(PyObject *args)
geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId() ||
geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() ||
geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) {
- ret = this->getSketchObjectPtr()->addGeometry(geo);
+ ret = this->getSketchObjectPtr()->addGeometry(geo,isConstruction);
}
else {
std::stringstream str;
@@ -163,7 +173,7 @@ PyObject* SketchObjectPy::addGeometry(PyObject *args)
}
}
- int ret = this->getSketchObjectPtr()->addGeometry(geoList) + 1;
+ int ret = this->getSketchObjectPtr()->addGeometry(geoList,isConstruction) + 1;
std::size_t numGeo = geoList.size();
Py::Tuple tuple(numGeo);
for (std::size_t i=0; igetObject()->getNameInDocument(),
- EditCurve[0].fX,EditCurve[0].fY,EditCurve[1].fX,EditCurve[1].fY);
-
- if(geometryCreationMode==Construction) {
- Gui::Command::doCommand(Gui::Command::Doc,
- "App.ActiveDocument.%s.toggleConstruction(%d) ",
- sketchgui->getObject()->getNameInDocument(),
- currentgeoid+1);
- }
-
+ EditCurve[0].fX,EditCurve[0].fY,EditCurve[1].fX,EditCurve[1].fY,
+ geometryCreationMode==Construction?"True":"False");
+
Gui::Command::commitCommand();
// add auto constraints for the line segment start
@@ -273,6 +267,8 @@ class DrawSketchHandlerLine: public DrawSketchHandler
if(autoRecompute)
Gui::Command::updateActive();
+ else
+ static_cast(sketchgui->getObject())->solve();
EditCurve.clear();
sketchgui->drawEdit(EditCurve);
@@ -452,65 +448,38 @@ class DrawSketchHandlerBox: public DrawSketchHandler
resetPositionText();
Gui::Command::openCommand("Add sketch box");
int firstCurve = getHighestCurveIndex() + 1;
- // add the four line geos
- Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))",
- sketchgui->getObject()->getNameInDocument(),
- EditCurve[0].fX,EditCurve[0].fY,EditCurve[1].fX,EditCurve[1].fY);
- Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))",
- sketchgui->getObject()->getNameInDocument(),
- EditCurve[1].fX,EditCurve[1].fY,EditCurve[2].fX,EditCurve[2].fY);
- Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))",
- sketchgui->getObject()->getNameInDocument(),
- EditCurve[2].fX,EditCurve[2].fY,EditCurve[3].fX,EditCurve[3].fY);
- Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))",
- sketchgui->getObject()->getNameInDocument(),
- EditCurve[3].fX,EditCurve[3].fY,EditCurve[0].fX,EditCurve[0].fY);
- // add the four coincidents to ty them together
- Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Coincident',%i,2,%i,1)) "
- ,sketchgui->getObject()->getNameInDocument()
- ,firstCurve,firstCurve+1);
- Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Coincident',%i,2,%i,1)) "
- ,sketchgui->getObject()->getNameInDocument()
- ,firstCurve+1,firstCurve+2);
- Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Coincident',%i,2,%i,1)) "
- ,sketchgui->getObject()->getNameInDocument()
- ,firstCurve+2,firstCurve+3);
- Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Coincident',%i,2,%i,1)) "
- ,sketchgui->getObject()->getNameInDocument()
- ,firstCurve+3,firstCurve);
- // add the horizontal constraints
- Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Horizontal',%i)) "
- ,sketchgui->getObject()->getNameInDocument()
- ,firstCurve);
- Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Horizontal',%i)) "
- ,sketchgui->getObject()->getNameInDocument()
- ,firstCurve+2);
- // add the vertical constraints
- Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Vertical',%i)) "
- ,sketchgui->getObject()->getNameInDocument()
- ,firstCurve+1);
- Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Vertical',%i)) "
- ,sketchgui->getObject()->getNameInDocument()
- ,firstCurve+3);
-
- if(geometryCreationMode==Construction) {
- Gui::Command::doCommand(Gui::Command::Doc,
- "App.ActiveDocument.%s.toggleConstruction(%d) ",
- sketchgui->getObject()->getNameInDocument(),
- firstCurve);
- Gui::Command::doCommand(Gui::Command::Doc,
- "App.ActiveDocument.%s.toggleConstruction(%d) ",
- sketchgui->getObject()->getNameInDocument(),
- firstCurve+1);
- Gui::Command::doCommand(Gui::Command::Doc,
- "App.ActiveDocument.%s.toggleConstruction(%d) ",
- sketchgui->getObject()->getNameInDocument(),
- firstCurve+2);
- Gui::Command::doCommand(Gui::Command::Doc,
- "App.ActiveDocument.%s.toggleConstruction(%d) ",
- sketchgui->getObject()->getNameInDocument(),
- firstCurve+3);
- }
+ Gui::Command::doCommand(Gui::Command::Doc,
+ "geoList = []\n"
+ "geoList.append(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
+ "geoList.append(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
+ "geoList.append(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
+ "geoList.append(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
+ "App.ActiveDocument.%s.addGeometry(geoList,%s)\n"
+ "conList = []\n"
+ "conList.append(Sketcher.Constraint('Coincident',%i,2,%i,1))\n"
+ "conList.append(Sketcher.Constraint('Coincident',%i,2,%i,1))\n"
+ "conList.append(Sketcher.Constraint('Coincident',%i,2,%i,1))\n"
+ "conList.append(Sketcher.Constraint('Coincident',%i,2,%i,1))\n"
+ "conList.append(Sketcher.Constraint('Horizontal',%i))\n"
+ "conList.append(Sketcher.Constraint('Horizontal',%i))\n"
+ "conList.append(Sketcher.Constraint('Vertical',%i))\n"
+ "conList.append(Sketcher.Constraint('Vertical',%i))\n"
+ "App.ActiveDocument.%s.addConstraint(conList)\n",
+ EditCurve[0].fX,EditCurve[0].fY,EditCurve[1].fX,EditCurve[1].fY, // line 1
+ EditCurve[1].fX,EditCurve[1].fY,EditCurve[2].fX,EditCurve[2].fY, // line 2
+ EditCurve[2].fX,EditCurve[2].fY,EditCurve[3].fX,EditCurve[3].fY, // line 3
+ EditCurve[3].fX,EditCurve[3].fY,EditCurve[0].fX,EditCurve[0].fY, // line 4
+ sketchgui->getObject()->getNameInDocument(), // the sketch
+ geometryCreationMode==Construction?"True":"False", // geometry as construction or not
+ firstCurve,firstCurve+1, // coincident1
+ firstCurve+1,firstCurve+2, // coincident2
+ firstCurve+2,firstCurve+3, // coincident3
+ firstCurve+3,firstCurve, // coincident4
+ firstCurve, // horizontal1
+ firstCurve+2, // horizontal2
+ firstCurve+1, // vertical1
+ firstCurve+3, // vertical2
+ sketchgui->getObject()->getNameInDocument()); // the sketch
Gui::Command::commitCommand();
@@ -531,6 +500,8 @@ class DrawSketchHandlerBox: public DrawSketchHandler
if(autoRecompute)
Gui::Command::updateActive();
+ else
+ static_cast(sketchgui->getObject())->solve();
//ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
@@ -966,10 +937,10 @@ class DrawSketchHandlerLineSet: public DrawSketchHandler
// issue the geometry
try {
Gui::Command::doCommand(Gui::Command::Doc,
- "App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))",
+ "App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)),%s)",
sketchgui->getObject()->getNameInDocument(),
- EditCurve[0].fX,EditCurve[0].fY,EditCurve[1].fX,EditCurve[1].fY);
-
+ EditCurve[0].fX,EditCurve[0].fY,EditCurve[1].fX,EditCurve[1].fY,
+ geometryCreationMode==Construction?"True":"False");
}
catch (const Base::Exception& e) {
addedGeometry = false;
@@ -986,10 +957,11 @@ class DrawSketchHandlerLineSet: public DrawSketchHandler
try {
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.ArcOfCircle"
- "(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),%f,%f))",
+ "(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),%f,%f),%s)",
sketchgui->getObject()->getNameInDocument(),
CenterPoint.fX, CenterPoint.fY, std::abs(arcRadius),
- std::min(startAngle,endAngle), std::max(startAngle,endAngle));
+ std::min(startAngle,endAngle), std::max(startAngle,endAngle),
+ geometryCreationMode==Construction?"True":"False");
}
catch (const Base::Exception& e) {
addedGeometry = false;
@@ -1031,13 +1003,8 @@ class DrawSketchHandlerLineSet: public DrawSketchHandler
if(autoRecompute)
Gui::Command::updateActive();
- }
-
- if(addedGeometry && geometryCreationMode==Construction) {
- Gui::Command::doCommand(Gui::Command::Doc,
- "App.ActiveDocument.%s.toggleConstruction(%d) ",
- sketchgui->getObject()->getNameInDocument(),
- lastCurve);
+ else
+ static_cast(sketchgui->getObject())->solve();
}
if (Mode == STATUS_Close) {
@@ -1100,7 +1067,9 @@ class DrawSketchHandlerLineSet: public DrawSketchHandler
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
- Gui::Command::updateActive();
+ Gui::Command::updateActive();
+ else
+ static_cast(sketchgui->getObject())->solve();
// remember the vertex for the next rounds constraint..
previousCurve = getHighestCurveIndex();
@@ -1389,17 +1358,11 @@ class DrawSketchHandlerArc : public DrawSketchHandler
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.ArcOfCircle"
"(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),"
- "%f,%f))",
+ "%f,%f),%s)",
sketchgui->getObject()->getNameInDocument(),
CenterPoint.fX, CenterPoint.fY, sqrt(rx*rx + ry*ry),
- startAngle, endAngle); //arcAngle > 0 ? 0 : 1);
-
- if(geometryCreationMode==Construction) {
- Gui::Command::doCommand(Gui::Command::Doc,
- "App.ActiveDocument.%s.toggleConstruction(%d) ",
- sketchgui->getObject()->getNameInDocument(),
- currentgeoid+1);
- }
+ startAngle, endAngle,
+ geometryCreationMode==Construction?"True":"False"); //arcAngle > 0 ? 0 : 1);
Gui::Command::commitCommand();
@@ -1425,7 +1388,9 @@ class DrawSketchHandlerArc : public DrawSketchHandler
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
- Gui::Command::updateActive();
+ Gui::Command::updateActive();
+ else
+ static_cast(sketchgui->getObject())->solve();
//ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
@@ -1691,17 +1656,11 @@ class DrawSketchHandler3PointArc : public DrawSketchHandler
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.ArcOfCircle"
"(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),"
- "%f,%f))",
+ "%f,%f),%s)",
sketchgui->getObject()->getNameInDocument(),
CenterPoint.fX, CenterPoint.fY, radius,
- startAngle, endAngle);
-
- if(geometryCreationMode==Construction) {
- Gui::Command::doCommand(Gui::Command::Doc,
- "App.ActiveDocument.%s.toggleConstruction(%d) ",
- sketchgui->getObject()->getNameInDocument(),
- currentgeoid+1);
- }
+ startAngle, endAngle,
+ geometryCreationMode==Construction?"True":"False");
Gui::Command::commitCommand();
@@ -1727,7 +1686,9 @@ class DrawSketchHandler3PointArc : public DrawSketchHandler
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
- Gui::Command::updateActive();
+ Gui::Command::updateActive();
+ else
+ static_cast(sketchgui->getObject())->solve();
//ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
@@ -2002,17 +1963,11 @@ class DrawSketchHandlerCircle : public DrawSketchHandler
Gui::Command::openCommand("Add sketch circle");
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.Circle"
- "(App.Vector(%f,%f,0),App.Vector(0,0,1),%f))",
+ "(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),%s)",
sketchgui->getObject()->getNameInDocument(),
EditCurve[0].fX, EditCurve[0].fY,
- sqrt(rx*rx + ry*ry));
-
- if(geometryCreationMode==Construction) {
- Gui::Command::doCommand(Gui::Command::Doc,
- "App.ActiveDocument.%s.toggleConstruction(%d) ",
- sketchgui->getObject()->getNameInDocument(),
- currentgeoid+1);
- }
+ sqrt(rx*rx + ry*ry),
+ geometryCreationMode==Construction?"True":"False");
Gui::Command::commitCommand();
@@ -2032,7 +1987,9 @@ class DrawSketchHandlerCircle : public DrawSketchHandler
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
- Gui::Command::updateActive();
+ Gui::Command::updateActive();
+ else
+ static_cast(sketchgui->getObject())->solve();
//ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
@@ -2802,21 +2759,15 @@ class DrawSketchHandlerEllipse : public DrawSketchHandler
Gui::Command::openCommand("Add sketch ellipse");
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.Ellipse"
- "(App.Vector(%f,%f,0),App.Vector(%f,%f,0),App.Vector(%f,%f,0)))",
+ "(App.Vector(%f,%f,0),App.Vector(%f,%f,0),App.Vector(%f,%f,0)),%s)",
sketchgui->getObject()->getNameInDocument(),
periapsis.fX, periapsis.fY,
positiveB.fX, positiveB.fY,
- centroid.fX, centroid.fY);
+ centroid.fX, centroid.fY,
+ geometryCreationMode==Construction?"True":"False");
currentgeoid++;
- if(geometryCreationMode==Construction) {
- Gui::Command::doCommand(Gui::Command::Doc,
- "App.ActiveDocument.%s.toggleConstruction(%d) ",
- sketchgui->getObject()->getNameInDocument(),
- currentgeoid);
- }
-
try {
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.ExposeInternalGeometry(%d)",
@@ -2832,6 +2783,8 @@ class DrawSketchHandlerEllipse : public DrawSketchHandler
if(autoRecompute)
Gui::Command::updateActive();
+ else
+ static_cast(sketchgui->getObject())->solve();
return;
}
@@ -2874,6 +2827,8 @@ class DrawSketchHandlerEllipse : public DrawSketchHandler
if(autoRecompute)
Gui::Command::updateActive();
+ else
+ static_cast(sketchgui->getObject())->solve();
// This code enables the continuous creation mode.
if (constrMethod == 0) {
@@ -3223,23 +3178,16 @@ class DrawSketchHandlerArcOfEllipse : public DrawSketchHandler
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.ArcOfEllipse"
"(Part.Ellipse(App.Vector(%f,%f,0),App.Vector(%f,%f,0),App.Vector(%f,%f,0)),"
- "%f,%f))",
+ "%f,%f),%s)",
sketchgui->getObject()->getNameInDocument(),
majAxisPoint.fX, majAxisPoint.fY,
minAxisPoint.fX, minAxisPoint.fY,
centerPoint.fX, centerPoint.fY,
- startAngle, endAngle);
+ startAngle, endAngle,
+ geometryCreationMode==Construction?"True":"False");
currentgeoid++;
-
- if(geometryCreationMode==Construction) {
- Gui::Command::doCommand(Gui::Command::Doc,
- "App.ActiveDocument.%s.toggleConstruction(%d) ",
- sketchgui->getObject()->getNameInDocument(),
- currentgeoid);
- }
-
-
+
try {
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.ExposeInternalGeometry(%d)",
@@ -3255,6 +3203,8 @@ class DrawSketchHandlerArcOfEllipse : public DrawSketchHandler
if(autoRecompute)
Gui::Command::updateActive();
+ else
+ static_cast(sketchgui->getObject())->solve();
return false;
}
@@ -3289,7 +3239,9 @@ class DrawSketchHandlerArcOfEllipse : public DrawSketchHandler
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
- Gui::Command::updateActive();
+ Gui::Command::updateActive();
+ else
+ static_cast(sketchgui->getObject())->solve();
//ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
@@ -3620,18 +3572,12 @@ class DrawSketchHandler3PointCircle : public DrawSketchHandler
Gui::Command::openCommand("Add sketch circle");
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.Circle"
- "(App.Vector(%f,%f,0),App.Vector(0,0,1),%f))",
+ "(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),%s)",
sketchgui->getObject()->getNameInDocument(),
CenterPoint.fX, CenterPoint.fY,
- radius);
+ radius,
+ geometryCreationMode==Construction?"True":"False");
- if(geometryCreationMode==Construction) {
- Gui::Command::doCommand(Gui::Command::Doc,
- "App.ActiveDocument.%s.toggleConstruction(%d) ",
- sketchgui->getObject()->getNameInDocument(),
- currentgeoid+1);
- }
-
Gui::Command::commitCommand();
// Auto Constraint first picked point
@@ -3656,7 +3602,9 @@ class DrawSketchHandler3PointCircle : public DrawSketchHandler
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
- Gui::Command::updateActive();
+ Gui::Command::updateActive();
+ else
+ static_cast(sketchgui->getObject())->solve();
//ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
@@ -3904,7 +3852,9 @@ class DrawSketchHandlerPoint: public DrawSketchHandler
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
- Gui::Command::updateActive();
+ Gui::Command::updateActive();
+ else
+ static_cast(sketchgui->getObject())->solve();
//ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
@@ -4183,6 +4133,8 @@ class DrawSketchHandlerFillet: public DrawSketchHandler
if(autoRecompute)
Gui::Command::updateActive();
+ else
+ static_cast(sketchgui->getObject())->solve();
}
return true;
}
@@ -4236,7 +4188,7 @@ class DrawSketchHandlerFillet: public DrawSketchHandler
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
- Gui::Command::updateActive();
+ Gui::Command::updateActive();
if(construction) {
Gui::Command::doCommand(Gui::Command::Doc,
@@ -4413,7 +4365,7 @@ class DrawSketchHandlerTrimming: public DrawSketchHandler
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
- Gui::Command::updateActive();
+ Gui::Command::updateActive();
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
@@ -4780,72 +4732,39 @@ class DrawSketchHandlerSlot: public DrawSketchHandler
}
try {
- Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.ArcOfCircle(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),%f,%f))",
- sketchgui->getObject()->getNameInDocument(),
- StartPos.fX,StartPos.fY, // center of the arc
- fabs(r), // radius
- start,end // start and end angle
- );
- Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.ArcOfCircle(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),%f,%f))",
- sketchgui->getObject()->getNameInDocument(),
- StartPos.fX+lx,StartPos.fY+ly, // center of the arc
- fabs(r), // radius
- end,start // start and end angle
- );
-
- Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))",
- sketchgui->getObject()->getNameInDocument(),
- EditCurve[16].fX,EditCurve[16].fY,EditCurve[17].fX,EditCurve[17].fY);
- Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))",
- sketchgui->getObject()->getNameInDocument(),
- EditCurve[0].fX,EditCurve[0].fY,EditCurve[34].fX,EditCurve[34].fY);
-
- Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Tangent',%i,1,%i,1)) "
- ,sketchgui->getObject()->getNameInDocument()
- ,firstCurve,firstCurve+3);
- Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Tangent',%i,2,%i,1)) "
- ,sketchgui->getObject()->getNameInDocument()
- ,firstCurve,firstCurve+2);
- Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Tangent',%i,2,%i,1)) "
- ,sketchgui->getObject()->getNameInDocument()
- ,firstCurve+2,firstCurve+1);
- Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Tangent',%i,2,%i,2)) "
- ,sketchgui->getObject()->getNameInDocument()
- ,firstCurve+3,firstCurve+1);
-
- //// add the either horizontal or vertical constraints
- if(fabs(lx)>fabs(ly))
- Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Horizontal',%i)) "
- ,sketchgui->getObject()->getNameInDocument()
- ,firstCurve+2);
- else
- Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Vertical',%i)) "
- ,sketchgui->getObject()->getNameInDocument()
- ,firstCurve+2);
- // make the two arcs equal
- Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Equal',%i,%i)) "
- ,sketchgui->getObject()->getNameInDocument()
- ,firstCurve,firstCurve+1);
+ Gui::Command::doCommand(Gui::Command::Doc,
+ "geoList = []\n"
+ "geoList.append(Part.ArcOfCircle(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),%f,%f))\n"
+ "geoList.append(Part.ArcOfCircle(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),%f,%f))\n"
+ "geoList.append(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
+ "geoList.append(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
+ "App.ActiveDocument.%s.addGeometry(geoList,%s)\n"
+ "conList = []\n"
+ "conList.append(Sketcher.Constraint('Tangent',%i,1,%i,1))\n"
+ "conList.append(Sketcher.Constraint('Tangent',%i,2,%i,1))\n"
+ "conList.append(Sketcher.Constraint('Tangent',%i,2,%i,1))\n"
+ "conList.append(Sketcher.Constraint('Tangent',%i,2,%i,2))\n"
+ "conList.append(Sketcher.Constraint('%s',%i))\n"
+ "conList.append(Sketcher.Constraint('Equal',%i,%i))\n"
+ "App.ActiveDocument.%s.addConstraint(conList)\n",
+ StartPos.fX,StartPos.fY, // center of the arc1
+ fabs(r), // radius arc1
+ start,end, // start and end angle of arc1
+ StartPos.fX+lx,StartPos.fY+ly, // center of the arc2
+ fabs(r), // radius arc2
+ end,start, // start and end angle of arc2
+ EditCurve[16].fX,EditCurve[16].fY,EditCurve[17].fX,EditCurve[17].fY, // line1
+ EditCurve[0].fX,EditCurve[0].fY,EditCurve[34].fX,EditCurve[34].fY, // line2
+ sketchgui->getObject()->getNameInDocument(), // the sketch
+ geometryCreationMode==Construction?"True":"False", // geometry as construction or not
+ firstCurve,firstCurve+3, // tangent1
+ firstCurve,firstCurve+2, // tangent2
+ firstCurve+2,firstCurve+1, // tangent3
+ firstCurve+3,firstCurve+1, // tangent4
+ (fabs(lx)>fabs(ly))?"Horizontal":"Vertical", firstCurve+2, // vertical or horizontal constraint
+ firstCurve,firstCurve+1, // equal constraint
+ sketchgui->getObject()->getNameInDocument()); // the sketch
- if(geometryCreationMode==Construction) {
- Gui::Command::doCommand(Gui::Command::Doc,
- "App.ActiveDocument.%s.toggleConstruction(%d) ",
- sketchgui->getObject()->getNameInDocument(),
- firstCurve);
- Gui::Command::doCommand(Gui::Command::Doc,
- "App.ActiveDocument.%s.toggleConstruction(%d) ",
- sketchgui->getObject()->getNameInDocument(),
- firstCurve+1);
- Gui::Command::doCommand(Gui::Command::Doc,
- "App.ActiveDocument.%s.toggleConstruction(%d) ",
- sketchgui->getObject()->getNameInDocument(),
- firstCurve+2);
- Gui::Command::doCommand(Gui::Command::Doc,
- "App.ActiveDocument.%s.toggleConstruction(%d) ",
- sketchgui->getObject()->getNameInDocument(),
- firstCurve+3);
- }
-
Gui::Command::commitCommand();
// add auto constraints at the start of the first side
@@ -4864,7 +4783,9 @@ class DrawSketchHandlerSlot: public DrawSketchHandler
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
- Gui::Command::updateActive();
+ Gui::Command::updateActive();
+ else
+ static_cast(sketchgui->getObject())->solve();
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
@@ -4873,7 +4794,7 @@ class DrawSketchHandlerSlot: public DrawSketchHandler
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
- Gui::Command::updateActive();
+ Gui::Command::updateActive();
}
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
@@ -5075,20 +4996,11 @@ class DrawSketchHandlerRegularPolygon: public DrawSketchHandler
try {
Gui::Command::doCommand(Gui::Command::Doc,
"import ProfileLib.RegularPolygon\n"
- "ProfileLib.RegularPolygon.makeRegularPolygon('%s',%i,App.Vector(%f,%f,0),App.Vector(%f,%f,0))",
+ "ProfileLib.RegularPolygon.makeRegularPolygon('%s',%i,App.Vector(%f,%f,0),App.Vector(%f,%f,0),%s)",
sketchgui->getObject()->getNameInDocument(),
Corners,
- StartPos.fX,StartPos.fY,EditCurve[0].fX,EditCurve[0].fY);
-
- if(geometryCreationMode==Construction) {
- int i;
- for(i=0;igetObject()->getNameInDocument(),
- currentgeoid+1+i);
- }
- }
+ StartPos.fX,StartPos.fY,EditCurve[0].fX,EditCurve[0].fY,
+ geometryCreationMode==Construction?"True":"False");
Gui::Command::commitCommand();
@@ -5108,7 +5020,9 @@ class DrawSketchHandlerRegularPolygon: public DrawSketchHandler
}
if(autoRecompute)
- Gui::Command::updateActive();
+ Gui::Command::updateActive();
+ else
+ static_cast(sketchgui->getObject())->solve();
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
diff --git a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp
index 58d6f10bc887..329890b7ca2f 100644
--- a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp
+++ b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp
@@ -896,7 +896,7 @@ void CmdSketcherRestoreInternalAlignmentGeometry::activated(int iMsg)
try{
if(!major)
{
- Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))",
+ Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)),True)",
Obj->getNameInDocument(),
majorpositiveend.x,majorpositiveend.y,majornegativeend.x,majornegativeend.y); // create line for major axis
@@ -907,7 +907,7 @@ void CmdSketcherRestoreInternalAlignmentGeometry::activated(int iMsg)
}
if(!minor)
{
- Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))",
+ Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)),True)",
Obj->getNameInDocument(),
minorpositiveend.x,minorpositiveend.y,minornegativeend.x,minornegativeend.y); // create line for minor axis
@@ -936,15 +936,6 @@ void CmdSketcherRestoreInternalAlignmentGeometry::activated(int iMsg)
Obj->getNameInDocument(),currentgeoid+incrgeo+1,Sketcher::start,GeoId); // constrain major axis
}
- // Make lines construction lines
- if(majorindex!=-1){
- doCommand(Doc,"App.ActiveDocument.%s.toggleConstruction(%d) ",Obj->getNameInDocument(),majorindex);
- }
-
- if(minorindex!=-1){
- doCommand(Doc,"App.ActiveDocument.%s.toggleConstruction(%d) ",Obj->getNameInDocument(),minorindex);
- }
-
Gui::Command::commitCommand();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp
index 9cbaaf855333..55df779bb460 100644
--- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp
+++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp
@@ -4084,21 +4084,17 @@ void ViewProviderSketch::updateData(const App::Property *prop)
if (edit && (prop == &(getSketchObject()->Geometry) ||
prop == &(getSketchObject()->Constraints))) {
edit->FullyConstrained = false;
+ // At this point, we do not need to solve the Sketch
+ // If we are adding geometry an update can be triggered before the sketch is actually solved.
+ // Because a solve is mandatory to any addition (at least to update the DoF of the solver),
+ // only when the solver geometry is the same in number than the sketch geometry an update
+ // should trigger a redraw. This reduces even more the number of redraws per insertion of geometry
- // UpdateData is only called as a consequence of SketchObject having changed
- // and triggered from SketchObject::onChanged. Therefore we have to assume that
- // SketchObject is updated and solved , or will soon be updated and solved in the
- // still to be processed recompute (SketchObject::execute() that will trigger a
- // SketchObject::onChanged).
- //
- // At this point, we do not need to solve the Sketch and we can draw directly from
- // the SketchObject geometry.
- //
- // This SketchObject::
- //solveSketch();
- //draw(true);
- UpdateSolverInformation(); // just update the solver window with the last SketchObject solving information
- draw();
+ if(getSketchObject()->getExternalGeometryCount()+getSketchObject()->getHighestCurveIndex() + 1 ==
+ getSketchObject()->getSolvedSketch().getGeometrySize()) {
+ UpdateSolverInformation(); // just update the solver window with the last SketchObject solving information
+ draw(false);
+ }
}
if (edit && &(getSketchObject()->Constraints)) {
// send the signal for the TaskDlg.
@@ -4223,8 +4219,13 @@ bool ViewProviderSketch::setEdit(int ModNum)
else
Gui::Control().showDialog(new TaskDlgEditSketch(this));
- getSketchObject()->solve(); // This call to the solver is needed to initialize the DoF and solve time controls
- //draw(); is not necessary, because a solve triggers an updateData.
+ // This call to the solver is needed to initialize the DoF and solve time controls
+ // The false parameter indicates that the geometry of the SketchObject shall not be updateData
+ // so as not to trigger an onChanged that would set the document as modified and trigger a recompute
+ // if we just close the sketch without touching anything.
+ getSketchObject()->solve(false);
+ draw(false);
+ UpdateSolverInformation();
connectUndoDocument = Gui::Application::Instance->activeDocument()
->signalUndoDocument.connect(boost::bind(&ViewProviderSketch::slotUndoDocument, this, _1));
@@ -4781,7 +4782,7 @@ bool ViewProviderSketch::onDelete(const std::vector &subList)
}
}
- getSketchObject()->getSolvedSketch().solve();
+ getSketchObject()->solve();
this->drawConstraintIcons();
this->updateColor();
diff --git a/src/Mod/Sketcher/ProfileLib/RegularPolygon.py b/src/Mod/Sketcher/ProfileLib/RegularPolygon.py
index 053bbeea510f..a877c1edd128 100644
--- a/src/Mod/Sketcher/ProfileLib/RegularPolygon.py
+++ b/src/Mod/Sketcher/ProfileLib/RegularPolygon.py
@@ -35,7 +35,8 @@ def makeRegularPolygon(
sketchName,
sides,
centerPoint=App.Vector(0,0,0),
- firstCornerPoint=App.Vector(-20.00,34.64,0)):
+ firstCornerPoint=App.Vector(-20.00,34.64,0),
+ construction=False):
if not sketchName:
App.Console.PrintError("No sketch specified in 'makeRegularPolygon'")
@@ -64,7 +65,7 @@ def makeRegularPolygon(
geoList.append(Part.Line(pointList[i],pointList[i+1]))
geoList.append(Part.Line(pointList[sides-1],pointList[0]))
geoList.append(Part.Circle(centerPoint,App.Vector(0,0,1),diffVec.Length))
- geoIndices = sketch.addGeometry(geoList)
+ geoIndices = sketch.addGeometry(geoList,construction)
sketch.setConstruction(geoIndices[-1],True)