Skip to content

Commit

Permalink
Sketcher: Polyline continuous mode support
Browse files Browse the repository at this point in the history
  • Loading branch information
abdullahtahiriyo authored and wwmayer committed Feb 2, 2017
1 parent b708957 commit 66982e2
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/Mod/Sketcher/Gui/CommandCreateGeo.cpp
Expand Up @@ -650,6 +650,7 @@ class DrawSketchHandlerLineSet: public DrawSketchHandler
, startAngle(0)
, endAngle(0)
, arcRadius(0)
, firstsegment(true)
{
}
virtual ~DrawSketchHandlerLineSet() {}
Expand Down Expand Up @@ -928,6 +929,8 @@ class DrawSketchHandlerLineSet: public DrawSketchHandler
previousCurve=-1;
firstPosId=Sketcher::none;
previousPosId=Sketcher::none;
EditCurve.clear();
sketchgui->drawEdit(EditCurve);
EditCurve.resize(2);
applyCursor();
/* this is ok not to call to purgeHandler
Expand Down Expand Up @@ -979,6 +982,8 @@ class DrawSketchHandlerLineSet: public DrawSketchHandler
Base::Console().Error("Failed to add line: %s\n", e.what());
Gui::Command::abortCommand();
}

firstsegment=false;
}
else if (SegmentMode == SEGMENT_MODE_Arc) { // We're dealing with an Arc
if (!boost::math::isnormal(arcRadius)) {
Expand All @@ -1001,6 +1006,8 @@ class DrawSketchHandlerLineSet: public DrawSketchHandler
Base::Console().Error("Failed to add arc: %s\n", e.what());
Gui::Command::abortCommand();
}

firstsegment=false;
}

int lastCurve = getHighestCurveIndex();
Expand Down Expand Up @@ -1072,6 +1079,8 @@ class DrawSketchHandlerLineSet: public DrawSketchHandler
previousCurve=-1;
firstPosId=Sketcher::none;
previousPosId=Sketcher::none;
EditCurve.clear();
sketchgui->drawEdit(EditCurve);
EditCurve.resize(2);
applyCursor();
/* this is ok not to call to purgeHandler
Expand Down Expand Up @@ -1132,6 +1141,43 @@ class DrawSketchHandlerLineSet: public DrawSketchHandler
}
return true;
}

virtual void quit(void) {
// We must see if we need to create a BSpline before cancelling everything
// and now just like any other Handler,

ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");

bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);

if (firstsegment) {
// user when right-clicking with no segment in really wants to exit
DrawSketchHandler::quit();
}
else {

if(!continuousMode){
DrawSketchHandler::quit();
}
else {
// This code disregards existing data and enables the continuous creation mode.
Mode=STATUS_SEEK_First;
SegmentMode=SEGMENT_MODE_Line;
TransitionMode=TRANSITION_MODE_Free;
suppressTransition=false;
firstCurve=-1;
previousCurve=-1;
firstPosId=Sketcher::none;
previousPosId=Sketcher::none;
firstsegment=true;
EditCurve.clear();
sketchgui->drawEdit(EditCurve);
EditCurve.resize(2);
applyCursor();
}
}
}

protected:
SELECT_MODE Mode;
SEGMENT_MODE SegmentMode;
Expand All @@ -1148,6 +1194,8 @@ class DrawSketchHandlerLineSet: public DrawSketchHandler
Base::Vector2d CenterPoint;
Base::Vector3d dirVec;
double startAngle, endAngle, arcRadius;

bool firstsegment;

void updateTransitionData(int GeoId, Sketcher::PointPos PosId) {

Expand Down

0 comments on commit 66982e2

Please sign in to comment.