diff --git a/src/draw.cpp b/src/draw.cpp index b4fdbc1d..79feb166 100644 --- a/src/draw.cpp +++ b/src/draw.cpp @@ -299,7 +299,7 @@ void GraphicsWindow::GroupSelection(void) { gs.constraint[(gs.constraints)++] = s->constraint; Constraint *c = SK.GetConstraint(s->constraint); if(c->IsStylable()) gs.stylables++; - if(c->type == Constraint::COMMENT) gs.comments++; + if(c->HasLabel()) gs.constraintLabels++; } } } @@ -434,7 +434,7 @@ Vector GraphicsWindow::UnProjectPoint3(Vector p) { double w = 1 + p.z * SS.CameraTangent() * scale; p.x *= w / scale; p.y *= w / scale; - + Vector orig = offset.ScaledBy(-1); orig = orig.Plus(projRight.ScaledBy(p.x)).Plus( projUp. ScaledBy(p.y).Plus( diff --git a/src/drawconstraint.cpp b/src/drawconstraint.cpp index 6ccaa103..32deb981 100644 --- a/src/drawconstraint.cpp +++ b/src/drawconstraint.cpp @@ -1229,3 +1229,21 @@ bool Constraint::IsStylable() { return false; } +bool Constraint::HasLabel() { + switch(type) { + case COMMENT: + case PT_PT_DISTANCE: + case PT_PLANE_DISTANCE: + case PT_LINE_DISTANCE: + case PT_FACE_DISTANCE: + case PROJ_PT_DISTANCE: + case LENGTH_RATIO: + case LENGTH_DIFFERENCE: + case DIAMETER: + case ANGLE: + return true; + + default: + return false; + } +} diff --git a/src/graphicswin.cpp b/src/graphicswin.cpp index 50b7c25a..c9f2be8c 100644 --- a/src/graphicswin.cpp +++ b/src/graphicswin.cpp @@ -888,9 +888,10 @@ void GraphicsWindow::MenuEdit(int id) { break; } SS.GW.GroupSelection(); - if(SS.GW.gs.points == 0 && SS.GW.gs.comments == 0) { - Error("Can't snap these items to grid; select points or " - "text comments. To snap a line, select its endpoints."); + if(SS.GW.gs.points == 0 && SS.GW.gs.constraintLabels == 0) { + Error("Can't snap these items to grid; select points, " + "text comments, or constraints with a label. " + "To snap a line, select its endpoints."); break; } SS.UndoRemember(); @@ -908,8 +909,6 @@ void GraphicsWindow::MenuEdit(int id) { SS.MarkGroupDirty(ep->group); } else if(s->constraint.v) { Constraint *c = SK.GetConstraint(s->constraint); - if(c->type != Constraint::COMMENT) continue; - c->disp.offset = SS.GW.SnapToGrid(c->disp.offset); } } diff --git a/src/mouse.cpp b/src/mouse.cpp index 46b3b747..3c213d54 100644 --- a/src/mouse.cpp +++ b/src/mouse.cpp @@ -571,7 +571,7 @@ void GraphicsWindow::MouseRightUp(double x, double y) { CMNU_OTHER_ANGLE); } } - if(gs.comments > 0 || gs.points > 0) { + if(gs.constraintLabels > 0 || gs.points > 0) { AddContextMenuItem("Snap to Grid", CMNU_SNAP_TO_GRID); } diff --git a/src/sketch.h b/src/sketch.h index 4738e3fa..65e08214 100644 --- a/src/sketch.h +++ b/src/sketch.h @@ -682,6 +682,7 @@ public: void Draw(void); void GetEdges(SEdgeList *sel); bool IsStylable(); + bool HasLabel(); void LineDrawOrGetDistance(Vector a, Vector b); bool IsVisible() const; diff --git a/src/ui.h b/src/ui.h index 1c5e07f2..15f64dd4 100644 --- a/src/ui.h +++ b/src/ui.h @@ -649,7 +649,7 @@ public: int vectors; int constraints; int stylables; - int comments; + int constraintLabels; int withEndpoints; int n; } gs;