Sketcher: New Feature: Avoiding to continuously recompute all the sketch (and dependent objects)

======================================================================================

There is a checkbox, default disabled, that makes the commands NOT to generate a recompute after each.
This means that if you are editing a sketch that is used to generate a pad or pocket, if the checkbox is
disabled, the dependent objects do not get recomputed.

There is a button next to it to force a manual recompute, in case it is needed.

If the user wants the previous behavior, he only needs to activate the checkbox. The previous status of the box
is restored upon entering a sketch in edit mode.

It is remarkable the case of the Fillet and Trim

On changing ActSketch (solvedSketch) to SketchObject and making movePoint not systematically update the geometry, the solving in MovePoint was confronted with solving for "the last solved geometry",
which is the default behaviour, in some situations (Fillet and Trim) where geometry had changed at SketchObject level, and was the subject of the moving actions.

MovePoint has been updated to take an extra optional parameter, to force the change in solved geometry in those situations.

Some other minor bug also fixed in Fillet creation in CommandCreateGeo.cpp

This commit also introduces conditional recompute on some operations of:
- constraints
- geometry creation (reubication of update active to comprise the autoconstraints within a single UpdateActive)
This commit is contained in:
Abdullah Tahiri 2015-06-06 15:27:12 +02:00 committed by wmayer
parent 0e92e6356f
commit a21265f9b6
10 changed files with 481 additions and 117 deletions

View File

@ -88,6 +88,8 @@ SketchObject::SketchObject()
lastHasRedundancies=false;
lastSolverStatus=0;
lastSolveTime=0;
noRecomputes=false;
}
SketchObject::~SketchObject()
@ -344,18 +346,25 @@ int SketchObject::toggleDriving(int ConstrId)
return 0;
}
int SketchObject::movePoint(int GeoId, PointPos PosId, const Base::Vector3d& toPoint, bool relative)
int SketchObject::movePoint(int GeoId, PointPos PosId, const Base::Vector3d& toPoint, bool relative, bool updateGeometry)
{
// if we are moving a point, we need to start from a solved sketch
// if we have conflicts we can forget about moving
// 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
// need to do programatically moves of new geometry that has not been solved yet and that because
// they were programmetically generated won't generate a conflict. This is the case of Fillet for
// example. This is why exceptionally, it may be required to update the sketch geometry to that of
// of SketchObject upon moving. => use updateGeometry parameter = true then
/*lastDoF = solvedSketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(),
getExternalGeometryCount());
lastHasConflict = solvedSketch.hasConflicts();
lastHasRedundancies = solvedSketch.hasRedundancies();
lastConflicting=solvedSketch.getConflicting();
lastRedundant=solvedSketch.getRedundant();*/
if(updateGeometry) {
lastDoF = solvedSketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(),
getExternalGeometryCount());
lastHasConflict = solvedSketch.hasConflicts();
lastHasRedundancies = solvedSketch.hasRedundancies();
lastConflicting=solvedSketch.getConflicting();
lastRedundant=solvedSketch.getRedundant();
}
if (lastDoF < 0) // over-constrained sketch
return -1;
@ -479,6 +488,10 @@ int SketchObject::addGeometry(const std::vector<Part::Geometry *> &geoList)
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;
}
@ -493,6 +506,10 @@ int SketchObject::addGeometry(const Part::Geometry *geo)
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;
}
@ -871,14 +888,14 @@ int SketchObject::fillet(int GeoId1, int GeoId2,
if (dist1.Length() < dist2.Length()) {
tangent1->SecondPos = start;
tangent2->SecondPos = end;
movePoint(GeoId1, PosId1, arc->getStartPoint(/*emulateCCW=*/true));
movePoint(GeoId2, PosId2, arc->getEndPoint(/*emulateCCW=*/true));
movePoint(GeoId1, PosId1, arc->getStartPoint(/*emulateCCW=*/true),false,true);
movePoint(GeoId2, PosId2, arc->getEndPoint(/*emulateCCW=*/true),false,true);
}
else {
tangent1->SecondPos = end;
tangent2->SecondPos = start;
movePoint(GeoId1, PosId1, arc->getEndPoint(/*emulateCCW=*/true));
movePoint(GeoId2, PosId2, arc->getStartPoint(/*emulateCCW=*/true));
movePoint(GeoId1, PosId1, arc->getEndPoint(/*emulateCCW=*/true),false,true);
movePoint(GeoId2, PosId2, arc->getStartPoint(/*emulateCCW=*/true),false,true);
}
addConstraint(tangent1);
@ -887,6 +904,10 @@ int SketchObject::fillet(int GeoId1, int GeoId2,
delete tangent2;
}
delete arc;
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 0;
}
return -1;
@ -930,8 +951,8 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
// go through all constraints and replace the point (GeoId,end) with (newGeoId,end)
transferConstraints(GeoId, end, newGeoId, end);
movePoint(GeoId, end, point1);
movePoint(newGeoId, start, point2);
movePoint(GeoId, end, point1,false,true);
movePoint(newGeoId, start, point2,false,true);
PointPos secondPos1 = Sketcher::none, secondPos2 = Sketcher::none;
ConstraintType constrType1 = Sketcher::PointOnObject, constrType2 = Sketcher::PointOnObject;
@ -1017,7 +1038,7 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
if (x1 > x0) { // trim line start
delConstraintOnPoint(GeoId, start, false);
movePoint(GeoId, start, point1);
movePoint(GeoId, start, point1,false,true);
// constrain the trimming point on the corresponding geometry
Sketcher::Constraint *newConstr = new Sketcher::Constraint();
@ -1035,7 +1056,7 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
}
else if (x1 < x0) { // trim line end
delConstraintOnPoint(GeoId, end, false);
movePoint(GeoId, end, point1);
movePoint(GeoId, end, point1,false,true);
Sketcher::Constraint *newConstr = new Sketcher::Constraint();
newConstr->Type = constrType;
newConstr->First = GeoId;
@ -2459,11 +2480,18 @@ double SketchObject::calculateAngleViaPoint(int GeoId1, int GeoId2, double px, d
{
// Temporary sketch based calculation. Slow, but guaranteed consistency with constraints.
Sketcher::Sketch sk;
int i1 = sk.addGeometry(this->getGeometry(GeoId1));
int i2 = sk.addGeometry(this->getGeometry(GeoId2));
return sk.calculateAngleViaPoint(i1,i2,px,py);
const Part::Geometry *p1=this->getGeometry(GeoId1);
const Part::Geometry *p2=this->getGeometry(GeoId2);
if(p1!=0 && p2!=0) {
int i1 = sk.addGeometry(this->getGeometry(GeoId1));
int i2 = sk.addGeometry(this->getGeometry(GeoId2));
return sk.calculateAngleViaPoint(i1,i2,px,py);
}
else
throw Base::Exception("Null geometry in calculateAngleViaPoint");
/*
// OCC-based calculation. It is faster, but it was removed due to problems

View File

@ -60,6 +60,16 @@ public:
}
//@}
/** SketchObject can work in two modes: Recompute Mode and noRecomputes Mode
- In Recompute Mode, a recompute is necessary after each geometry addition to update the solver DoF (default)
- In NoRecomputes Mode, no recompute is necessary after a geometry addition. If a recompute is triggered
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)
*/
bool noRecomputes;
/// add unspecified geometry
int addGeometry(const Part::Geometry *geo);
/// add unspecified geometry
@ -119,7 +129,7 @@ public:
/// 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);
int movePoint(int GeoId, PointPos PosId, const Base::Vector3d& toPoint, bool relative=false, bool updateGeometry=false);
/// retrieves the coordinates of a point
Base::Vector3d getPoint(int GeoId, PointPos PosId) const;

View File

@ -155,7 +155,12 @@ void openEditDatumDialog(Sketcher::SketchObject* sketch, int ConstrNbr)
sketch->getNameInDocument(),
ConstrNbr, newDatum, (const char*)newQuant.getUnit().getString().toUtf8());
Gui::Command::commitCommand();
Gui::Command::updateActive();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
}
catch (const Base::Exception& e) {
QMessageBox::critical(qApp->activeWindow(), QObject::tr("Dimensional constraint"), QString::fromUtf8(e.what()));
@ -201,7 +206,12 @@ void finishDistanceConstraint(Gui::Command* cmd, Sketcher::SketchObject* sketch,
cmd->commitCommand();
}
//updateActive();
//ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
cmd->getSelection().clearSelection();
}
@ -344,7 +354,12 @@ void SketcherGui::makeTangentToEllipseviaNewPoint(const Sketcher::SketchObject*
}
Gui::Command::commitCommand();
Gui::Command::updateActive();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
}
/// Makes a simple tangency constraint using extra point + tangent via point
/// geom1 => an arc of ellipse
@ -406,7 +421,12 @@ void SketcherGui::makeTangentToArcOfEllipseviaNewPoint(const Sketcher::SketchObj
}
Gui::Command::commitCommand();
Gui::Command::updateActive();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
}
namespace SketcherGui {
@ -581,7 +601,12 @@ void CmdSketcherConstrainHorizontal::activated(int iMsg)
}
// finish the transaction and update
commitCommand();
updateActive();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
// clear the selection (convenience)
getSelection().clearSelection();
@ -673,7 +698,12 @@ void CmdSketcherConstrainVertical::activated(int iMsg)
}
// finish the transaction and update
commitCommand();
updateActive();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
// clear the selection (convenience)
getSelection().clearSelection();
@ -755,7 +785,12 @@ void CmdSketcherConstrainLock::activated(int iMsg)
// finish the transaction and update
commitCommand();
updateActive();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
// clear the selection (convenience)
getSelection().clearSelection();
@ -867,7 +902,11 @@ void CmdSketcherConstrainCoincident::activated(int iMsg)
else
abortCommand();
//updateActive(); on adding constraints the updateActive's are unnecessary and introduce extra recomputes
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
// clear the selection (convenience)
getSelection().clearSelection();
@ -1553,7 +1592,12 @@ void CmdSketcherConstrainParallel::activated(int iMsg)
}
// finish the transaction and update
commitCommand();
//updateActive(); on adding constraints the updateActive's are unnecessary and introduce extra recomputes
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
// clear the selection (convenience)
@ -1675,7 +1719,12 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg)
}
commitCommand();
//updateActive(); on adding constraints the updateActive's are unnecessary and introduce extra recomputes
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
getSelection().clearSelection();
@ -1700,7 +1749,12 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg)
Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Perpendicular',%d,%d,%d,%d)) ",
selection[0].getFeatName(),GeoId1,PosId1,GeoId2,PosId2);
commitCommand();
//updateActive(); on adding constraints the updateActive's are unnecessary and introduce extra recomputes
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
getSelection().clearSelection();
return;
@ -1723,7 +1777,13 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg)
Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Perpendicular',%d,%d,%d)) ",
selection[0].getFeatName(),GeoId1,PosId1,GeoId2);
commitCommand();
//updateActive(); on adding constraints the updateActive's are unnecessary and introduce extra recomputes
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
getSelection().clearSelection();
return;
}
@ -1810,7 +1870,13 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg)
}
commitCommand();
//updateActive(); on adding constraints the updateActive's are unnecessary and introduce extra recomputes
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
getSelection().clearSelection();
return;
@ -1821,7 +1887,13 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg)
Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Perpendicular',%d,%d)) ",
selection[0].getFeatName(),GeoId1,GeoId2);
commitCommand();
//updateActive(); on adding constraints the updateActive's are unnecessary and introduce extra recomputes
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
getSelection().clearSelection();
return;
}
@ -1949,7 +2021,13 @@ void CmdSketcherConstrainTangent::activated(int iMsg)
}
commitCommand();
//updateActive(); on adding constraints the updateActive's are unnecessary and introduce extra recomputes
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
getSelection().clearSelection();
return;
@ -1973,7 +2051,13 @@ void CmdSketcherConstrainTangent::activated(int iMsg)
Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Tangent',%d,%d,%d,%d)) ",
selection[0].getFeatName(),GeoId1,PosId1,GeoId2,PosId2);
commitCommand();
//updateActive(); on adding constraints the updateActive's are unnecessary and introduce extra recomputes
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
getSelection().clearSelection();
return;
}
@ -1995,7 +2079,13 @@ void CmdSketcherConstrainTangent::activated(int iMsg)
Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Tangent',%d,%d,%d)) ",
selection[0].getFeatName(),GeoId1,PosId1,GeoId2);
commitCommand();
//updateActive(); on adding constraints the updateActive's are unnecessary and introduce extra recomputes
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
getSelection().clearSelection();
return;
}
@ -2055,7 +2145,13 @@ void CmdSketcherConstrainTangent::activated(int iMsg)
Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Tangent',%d,%d)) ",
selection[0].getFeatName(),GeoId1,GeoId2);
commitCommand();
//updateActive(); on adding constraints the updateActive's are unnecessary and introduce extra recomputes
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
getSelection().clearSelection();
return;
}
@ -2305,7 +2401,13 @@ void CmdSketcherConstrainRadius::activated(int iMsg)
}
}
commitCommand();
//updateActive(); on adding constraints the updateActive's are unnecessary and introduce extra recomputes
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
commitNeeded=false;
updateNeeded=false;
}
@ -2332,8 +2434,13 @@ void CmdSketcherConstrainRadius::activated(int iMsg)
if(commitNeeded)
commitCommand();
//if(updateNeeded)
//updateActive(); on adding constraints the updateActive's are unnecessary and introduce extra recomputes
if(updateNeeded) {
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
}
}
@ -2721,8 +2828,12 @@ void CmdSketcherConstrainEqual::activated(int iMsg)
}
// finish the transaction and update
commitCommand();
//updateActive(); on adding constraints the updateActive's are unnecessary and introduce extra recomputes
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
// clear the selection (convenience)
getSelection().clearSelection();
@ -2802,7 +2913,12 @@ void CmdSketcherConstrainSymmetric::activated(int iMsg)
// finish the transaction and update
commitCommand();
//updateActive(); on adding constraints the updateActive's are unnecessary and introduce extra recomputes
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
// clear the selection (convenience)
@ -2854,7 +2970,12 @@ void CmdSketcherConstrainSymmetric::activated(int iMsg)
// finish the transaction and update
commitCommand();
//updateActive(); on adding constraints the updateActive's are unnecessary and introduce extra recomputes
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
// clear the selection (convenience)
@ -2871,7 +2992,12 @@ void CmdSketcherConstrainSymmetric::activated(int iMsg)
// finish the transaction and update
commitCommand();
//updateActive(); on adding constraints the updateActive's are unnecessary and introduce extra recomputes
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
// clear the selection (convenience)
@ -3013,7 +3139,12 @@ void CmdSketcherConstrainSnellsLaw::activated(int iMsg)
}*/
commitCommand();
//updateActive(); on adding constraints the updateActive's are unnecessary and introduce extra recomputes
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
// clear the selection (convenience)
@ -3256,7 +3387,12 @@ void CmdSketcherConstrainInternalAlignment::activated(int iMsg)
// finish the transaction and update
commitCommand();
//updateActive(); on adding constraints the updateActive's are unnecessary and introduce extra recomputes
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
if(extra_elements){
@ -3413,7 +3549,11 @@ void CmdSketcherConstrainInternalAlignment::activated(int iMsg)
// finish the transaction and update
commitCommand();
//updateActive(); on adding constraints the updateActive's are unnecessary and introduce extra recomputes
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
if(extra_elements){
@ -3553,8 +3693,11 @@ void CmdSketcherToggleDrivingConstraint::activated(int iMsg)
else
abortCommand();
//updateActive(); on adding constraints the updateActive's are unnecessary and introduce extra recomputes
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
// clear the selection (convenience)
getSelection().clearSelection();

View File

@ -255,7 +255,6 @@ public:
}
Gui::Command::commitCommand();
Gui::Command::updateActive();
// add auto constraints for the line segment start
if (sugConstr1.size() > 0) {
@ -269,10 +268,16 @@ public:
sugConstr2.clear();
}
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
EditCurve.clear();
sketchgui->drawEdit(EditCurve);
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
//ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
if(continuousMode){
@ -507,9 +512,7 @@ public:
firstCurve+3);
}
Gui::Command::commitCommand();
Gui::Command::updateActive();
// add auto constraints at the start of the first side
if (sugConstr1.size() > 0) {
@ -524,6 +527,12 @@ public:
}
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
//ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
if(continuousMode){
@ -1016,7 +1025,12 @@ public:
lastCurve,lastEndPosId,firstCurve,firstPosId);
}
Gui::Command::commitCommand();
Gui::Command::updateActive();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
}
if(addedGeometry && geometryCreationMode==Construction) {
@ -1070,7 +1084,6 @@ public:
}
else {
Gui::Command::commitCommand();
Gui::Command::updateActive();
// Add auto constraints
if (sugConstr1.size() > 0) { // this is relevant only to the very first point
@ -1083,6 +1096,12 @@ public:
sugConstr2.clear();
}
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
// remember the vertex for the next rounds constraint..
previousCurve = getHighestCurveIndex();
previousPosId = (SegmentMode == SEGMENT_MODE_Arc && startAngle > endAngle) ?
@ -1383,7 +1402,6 @@ public:
}
Gui::Command::commitCommand();
Gui::Command::updateActive();
// Auto Constraint center point
if (sugConstr1.size() > 0) {
@ -1404,6 +1422,12 @@ public:
}
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
//ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
if(continuousMode){
@ -1680,7 +1704,6 @@ public:
}
Gui::Command::commitCommand();
Gui::Command::updateActive();
// Auto Constraint first picked point
if (sugConstr1.size() > 0) {
@ -1701,6 +1724,12 @@ public:
}
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
//ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
if(continuousMode){
@ -1986,7 +2015,6 @@ public:
}
Gui::Command::commitCommand();
Gui::Command::updateActive();
// add auto constraints for the center point
if (sugConstr1.size() > 0) {
@ -2001,6 +2029,12 @@ public:
}
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
//ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
if(continuousMode){
@ -2797,7 +2831,6 @@ private:
}
Gui::Command::commitCommand();
Gui::Command::updateActive();
if (method == CENTER_PERIAPSIS_B) {
// add auto constraints for the center point
@ -2830,33 +2863,39 @@ private:
}
}
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
// This code enables the continuous creation mode.
if (constrMethod == 0) {
method = CENTER_PERIAPSIS_B;
mode = STATUS_SEEK_CENTROID;
} else {
method = PERIAPSIS_APOAPSIS_B;
mode = STATUS_SEEK_PERIAPSIS;
}
editCurve.clear();
sketchgui->drawEdit(editCurve);
//ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
if(continuousMode){
// This code enables the continuous creation mode.
if (constrMethod == 0) {
method = CENTER_PERIAPSIS_B;
mode = STATUS_SEEK_CENTROID;
} else {
method = PERIAPSIS_APOAPSIS_B;
mode = STATUS_SEEK_PERIAPSIS;
}
editCurve.clear();
sketchgui->drawEdit(editCurve);
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
if(continuousMode){
// This code enables the continuous creation mode.
editCurve.resize(33);
applyCursor();
/* It is ok not to call to purgeHandler
* in continuous creation mode because the
* handler is destroyed by the quit() method on pressing the
* right button of the mouse */
}
else{
sketchgui->purgeHandler(); // no code after this line, Handler get deleted in ViewProvider
}
editCurve.resize(33);
applyCursor();
/* It is ok not to call to purgeHandler
* in continuous creation mode because the
* handler is destroyed by the quit() method on pressing the
* right button of the mouse */
}
else{
sketchgui->purgeHandler(); // no code after this line, Handler get deleted in ViewProvider
}
}
};
@ -3209,7 +3248,6 @@ public:
}
Gui::Command::commitCommand();
Gui::Command::updateActive();
// add auto constraints for the center point
if (sugConstr1.size() > 0) {
@ -3236,6 +3274,12 @@ public:
}
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
//ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
if(continuousMode){
@ -3577,7 +3621,6 @@ public:
}
Gui::Command::commitCommand();
Gui::Command::updateActive();
// Auto Constraint first picked point
if (sugConstr1.size() > 0) {
@ -3598,6 +3641,12 @@ public:
}
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
//ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
if(continuousMode){
@ -3832,7 +3881,6 @@ public:
EditPoint.fX,EditPoint.fY);
Gui::Command::commitCommand();
Gui::Command::updateActive();
// add auto constraints for the line segment start
if (sugConstr.size() > 0) {
@ -3840,7 +3888,13 @@ public:
sugConstr.clear();
}
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
//ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
if(continuousMode){
@ -4058,10 +4112,10 @@ public:
virtual bool releaseButton(Base::Vector2D onSketchPos)
{
bool construction=false;
int VtId = sketchgui->getPreselectPoint();
if (Mode == STATUS_SEEK_First && VtId != -1) {
int GeoId;
bool construction=false;
Sketcher::PointPos PosId=Sketcher::none;
sketchgui->getSketchObject()->getGeoVertexIndex(VtId,GeoId,PosId);
const Part::Geometry *geom = sketchgui->getSketchObject()->getGeometry(GeoId);
@ -4111,7 +4165,12 @@ public:
}
Gui::Command::commitCommand();
Gui::Command::updateActive();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
}
return true;
}
@ -4149,6 +4208,8 @@ public:
if (radius < 0)
return false;
construction=lineSeg1->Construction && lineSeg2->Construction;
// create fillet between lines
Gui::Command::openCommand("Create fillet");
int currentgeoid= getHighestCurveIndex();
@ -4158,9 +4219,14 @@ public:
firstPos.fX, firstPos.fY,
secondPos.fX, secondPos.fY, radius);
Gui::Command::commitCommand();
Gui::Command::updateActive();
if(lineSeg1->Construction && lineSeg2->Construction) {
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
if(construction) {
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.toggleConstruction(%d) ",
sketchgui->getObject()->getNameInDocument(),
@ -4330,7 +4396,12 @@ public:
sketchgui->getObject()->getNameInDocument(),
GeoId, onSketchPos.fX, onSketchPos.fY);
Gui::Command::commitCommand();
Gui::Command::updateActive();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
@ -4504,7 +4575,13 @@ public:
sketchgui->getObject()->getNameInDocument(),
msg.pObjectName, msg.pSubName);
Gui::Command::commitCommand();
Gui::Command::updateActive();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
Gui::Selection().clearSelection();
/* this is ok not to call to purgeHandler
* in continuous creation mode because the
@ -4758,7 +4835,6 @@ public:
}
Gui::Command::commitCommand();
Gui::Command::updateActive();
// add auto constraints at the start of the first side
if (sugConstr1.size() > 0) {
@ -4771,6 +4847,12 @@ public:
createAutoConstraints(sugConstr2, getHighestCurveIndex() - 2, Sketcher::end);
sugConstr2.clear();
}
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
@ -4993,7 +5075,9 @@ public:
}
Gui::Command::commitCommand();
Gui::Command::updateActive();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
// add auto constraints at the center of the polygon
if (sugConstr1.size() > 0) {
@ -5006,6 +5090,9 @@ public:
createAutoConstraints(sugConstr2, getHighestCurveIndex() - 1, Sketcher::end);
sugConstr2.clear();
}
if(autoRecompute)
Gui::Command::updateActive();
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());

View File

@ -500,7 +500,7 @@ void DrawSketchHandler::createAutoConstraints(const std::vector<AutoConstraint>
}
Gui::Command::commitCommand();
Gui::Command::updateActive();
//Gui::Command::updateActive(); // There is already an recompute in each command creation, this is redundant.
}
}
}

View File

@ -161,7 +161,12 @@ void EditDatumDialog::exec(bool atCursor)
sketch->getNameInDocument(),
ConstrNbr, newDatum, (const char*)newQuant.getUnit().getString().toUtf8());
Gui::Command::commitCommand();
Gui::Command::updateActive();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
}
catch (const Base::Exception& e) {
QMessageBox::critical(qApp->activeWindow(), QObject::tr("Dimensional constraint"), QString::fromUtf8(e.what()));

View File

@ -38,6 +38,8 @@
#include <boost/bind.hpp>
#include <Mod/Sketcher/App/SketchObject.h>
#include "ViewProviderSketch.h"
using namespace SketcherGui;
@ -60,10 +62,25 @@ TaskSketcherMessages::TaskSketcherMessages(ViewProviderSketch *sketchView)
ui->labelConstrainStatus->setOpenExternalLinks(false);
QObject::connect(
ui->autoUpdate->onRestore();
if(ui->autoUpdate->isChecked())
sketchView->getSketchObject()->noRecomputes=false;
else
sketchView->getSketchObject()->noRecomputes=true;
/*QObject::connect(
ui->labelConstrainStatus, SIGNAL(linkActivated(const QString &)),
this , SLOT (on_labelConstrainStatus_linkActivated(const QString &))
);
QObject::connect(
ui->autoUpdate, SIGNAL(stateChanged(int)),
this , SLOT (on_autoUpdate_stateChanged(int))
);
QObject::connect(
ui->manualUpdate, SIGNAL(clicked(bool)),
this , SLOT (on_manualUpdate_clicked(bool))
);*/
}
TaskSketcherMessages::~TaskSketcherMessages()
@ -92,5 +109,21 @@ void TaskSketcherMessages::on_labelConstrainStatus_linkActivated(const QString &
Gui::Application::Instance->commandManager().runCommandByName("Sketcher_SelectRedundantConstraints");
}
void TaskSketcherMessages::on_autoUpdate_stateChanged(int state)
{
if(state==Qt::Checked) {
sketchView->getSketchObject()->noRecomputes=false;
ui->autoUpdate->onSave();
}
else if (state==Qt::Unchecked) {
sketchView->getSketchObject()->noRecomputes=true;
ui->autoUpdate->onSave();
}
}
void TaskSketcherMessages::on_manualUpdate_clicked(bool checked)
{
Gui::Command::updateActive();
}
#include "moc_TaskSketcherMessages.cpp"

View File

@ -52,6 +52,8 @@ public:
private Q_SLOTS:
void on_labelConstrainStatus_linkActivated(const QString &);
void on_autoUpdate_stateChanged(int state);
void on_manualUpdate_clicked(bool checked);
protected:
ViewProviderSketch *sketchView;

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>228</width>
<height>89</height>
<width>253</width>
<height>115</height>
</rect>
</property>
<property name="windowTitle">
@ -46,8 +46,55 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="Gui::PrefCheckBox" name="autoUpdate">
<property name="text">
<string>Auto Update</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>AutoRecompute</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher</cstring>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="manualUpdate">
<property name="text">
<string>Update</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -706,7 +706,12 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe
,GeoId, PosId, x-xInit, y-yInit, relative ? 1 : 0
);
Gui::Command::commitCommand();
Gui::Command::updateActive();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
}
catch (const Base::Exception& e) {
Gui::Command::abortCommand();
@ -735,7 +740,11 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe
,edit->DragCurve, Sketcher::none, x-xInit, y-yInit, relative ? 1 : 0
);
Gui::Command::commitCommand();
Gui::Command::updateActive();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
}
catch (const Base::Exception& e) {
Gui::Command::abortCommand();
@ -4744,7 +4753,7 @@ bool ViewProviderSketch::onDelete(const std::vector<std::string> &subList)
}
}
Gui::Command::updateActive();
getSketchObject()->getSolvedSketch().solve();
this->drawConstraintIcons();
this->updateColor();