Sketcher: fix crash in polyline with autoconstraints, disable arc mode for first polyline segment

This commit is contained in:
logari81 2012-07-09 17:19:02 +02:00
parent 044990333c
commit 47c44af453

View File

@ -508,7 +508,7 @@ public:
virtual void registerPressedKey(bool pressed, int key) virtual void registerPressedKey(bool pressed, int key)
{ {
if (key == SoKeyboardEvent::A && pressed) { if (key == SoKeyboardEvent::A && pressed && previousCurve != -1) {
if (LineMode != LINE_MODE_Arc) { if (LineMode != LINE_MODE_Arc) {
Base::Vector2D onSketchPos = EditCurve[isTangent ? 2 : 1]; Base::Vector2D onSketchPos = EditCurve[isTangent ? 2 : 1];
LineMode = LINE_MODE_Arc; LineMode = LINE_MODE_Arc;
@ -559,7 +559,6 @@ public:
} }
sketchgui->drawEdit(EditCurve); sketchgui->drawEdit(EditCurve);
if (!isTangent) { if (!isTangent) {
sugConstr2 = sugConstr1; // Copy the previously found constraints
if (seekAutoConstraint(sugConstr2, onSketchPos, onSketchPos - EditCurve[0])) { if (seekAutoConstraint(sugConstr2, onSketchPos, onSketchPos - EditCurve[0])) {
renderSuggestConstraintsCursor(sugConstr2); renderSuggestConstraintsCursor(sugConstr2);
return; return;
@ -612,8 +611,8 @@ public:
EditCurve[31] = EditCurve[0]; EditCurve[31] = EditCurve[0];
sketchgui->drawEdit(EditCurve); sketchgui->drawEdit(EditCurve);
if (seekAutoConstraint(sugConstr3, onSketchPos, Base::Vector2D(0.f,0.f))) { if (seekAutoConstraint(sugConstr2, onSketchPos, Base::Vector2D(0.f,0.f))) {
renderSuggestConstraintsCursor(sugConstr3); renderSuggestConstraintsCursor(sugConstr2);
return; return;
} }
} }
@ -739,7 +738,7 @@ public:
Gui::Command::updateActive(); Gui::Command::updateActive();
// Add auto constraints // Add auto constraints
if (sugConstr1.size() > 0) { if (sugConstr1.size() > 0) { // this is relevant only to the very first point
createAutoConstraints(sugConstr1, getHighestCurveIndex(), Sketcher::start); createAutoConstraints(sugConstr1, getHighestCurveIndex(), Sketcher::start);
sugConstr1.clear(); sugConstr1.clear();
} }
@ -800,7 +799,7 @@ protected:
int firstCurve; int firstCurve;
int previousPosId; int previousPosId;
int previousCurve; int previousCurve;
std::vector<AutoConstraint> sugConstr1, sugConstr2, sugConstr3; std::vector<AutoConstraint> sugConstr1, sugConstr2;
Base::Vector2D CenterPoint; Base::Vector2D CenterPoint;
Base::Vector3d dirVec; Base::Vector3d dirVec;