Allow snapping constraint labels to grid.
This is pretty much the only way to get a sketch with tidily placed dimensions.pull/4/head
parent
1142f85ff5
commit
c17f1160dc
|
@ -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(
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue