Sketcher: Clean code and adapt previous solution only to non-relative cases

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

Cleaning up ViewProviderSketch, as relative mode is never used for points.

Adapting the recalculation of the initial solution only to non-relative cases.

For relative movement cases (movePoint with relative=true) no cases where such a solution will be advantageous have been identified
and applying a similar solution involves changing the current behaviour too much, as to run the risk of introducing further bugs.

Decision to be revised if such cases where an advantage can be found are discovered.
This commit is contained in:
Abdullah Tahiri
2017-12-10 19:44:08 +01:00
committed by wmayer
parent 7b086ba8b2
commit a014c1cbc1
2 changed files with 12 additions and 10 deletions

View File

@@ -3199,13 +3199,15 @@ int Sketch::movePoint(int geoId, PointPos pos, Base::Vector3d toPoint, bool rela
moveStep = 0;
}
else {
if (moveStep == 0) {
moveStep = (toPoint-initToPoint).Length();
}
else {
if( (toPoint-initToPoint).Length() > 20*moveStep) { // I am getting too far away from the original solution so reinit the solution
initMove(geoId, pos);
initToPoint = toPoint;
if(!relative) {
if (moveStep == 0) {
moveStep = (toPoint-initToPoint).Length();
}
else {
if( (toPoint-initToPoint).Length() > 20*moveStep) { // I am getting too far away from the original solution so reinit the solution
initMove(geoId, pos);
initToPoint = toPoint;
}
}
}
}

View File

@@ -767,7 +767,7 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe
try {
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.movePoint(%i,%i,App.Vector(%f,%f,0),%i)"
,getObject()->getNameInDocument()
,GeoId, PosId, x-xInit, y-yInit, relative ? 1 : 0
,GeoId, PosId, x-xInit, y-yInit, 0
);
Gui::Command::commitCommand();
@@ -1136,9 +1136,9 @@ bool ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventor
int GeoId;
Sketcher::PointPos PosId;
getSketchObject()->getGeoVertexIndex(edit->DragPoint, GeoId, PosId);
Base::Vector3d vec(x-xInit,y-yInit,0);
Base::Vector3d vec(x,y,0);
if (GeoId != Sketcher::Constraint::GeoUndef && PosId != Sketcher::none) {
if (getSketchObject()->getSolvedSketch().movePoint(GeoId, PosId, vec, relative) == 0) {
if (getSketchObject()->getSolvedSketch().movePoint(GeoId, PosId, vec, false) == 0) {
setPositionText(Base::Vector2d(x,y));
draw(true,false);
signalSolved(QString::fromLatin1("Solved in %1 sec").arg(getSketchObject()->getSolvedSketch().SolveTime));