Actually do the smoothing when drawing a smoothed freehand shape

Originally committed to SVN as r6759.
This commit is contained in:
Thomas Goyne 2012-05-11 02:47:18 +00:00
parent c4e36e00a5
commit a05d469741
2 changed files with 17 additions and 13 deletions

View file

@ -248,17 +248,15 @@ void VisualTool<FeatureType>::OnMouseEvent(wxMouseEvent &event) {
}
}
else if (holding) {
if (event.LeftIsDown()) {
UpdateHold();
need_render = true;
}
// end hold
else {
if (!event.LeftIsDown()) {
holding = false;
parent->ReleaseMouse();
parent->SetFocus();
}
UpdateHold();
need_render = true;
Commit();
}

View file

@ -333,6 +333,8 @@ bool VisualToolVectorClip::InitializeHold() {
}
void VisualToolVectorClip::UpdateHold() {
bool needs_save = true;
if (mode == 1) {
spline.back().EndPoint() = mouse_pos;
features.back().pos = mouse_pos;
@ -360,19 +362,23 @@ void VisualToolVectorClip::UpdateHold() {
// See if distance is enough
Vector2D const& last = spline.back().EndPoint();
float len = (last - mouse_pos).SquareLen();
if (mode == 6 && len < 900) return;
if (mode == 7 && len < 3600) return;
if ((mode == 6 && len >= 900) || (mode == 7 && len >= 3600)) {
spline.push_back(SplineCurve(last, mouse_pos));
MakeFeature(--spline.end());
}
else
needs_save = false;
}
if (mode == 3 || mode == 4) return;
// Smooth spline
if (!holding && mode == 7)
if (!holding && mode == 7) {
spline.Smooth();
needs_save = true;
}
if (needs_save)
Save();
// End freedraw