Allow snapping constraint labels to grid.
This is pretty much the only way to get a sketch with tidily placed dimensions.
This commit is contained in:
parent
1142f85ff5
commit
c17f1160dc
@ -299,7 +299,7 @@ void GraphicsWindow::GroupSelection(void) {
|
|||||||
gs.constraint[(gs.constraints)++] = s->constraint;
|
gs.constraint[(gs.constraints)++] = s->constraint;
|
||||||
Constraint *c = SK.GetConstraint(s->constraint);
|
Constraint *c = SK.GetConstraint(s->constraint);
|
||||||
if(c->IsStylable()) gs.stylables++;
|
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;
|
double w = 1 + p.z * SS.CameraTangent() * scale;
|
||||||
p.x *= w / scale;
|
p.x *= w / scale;
|
||||||
p.y *= w / scale;
|
p.y *= w / scale;
|
||||||
|
|
||||||
Vector orig = offset.ScaledBy(-1);
|
Vector orig = offset.ScaledBy(-1);
|
||||||
orig = orig.Plus(projRight.ScaledBy(p.x)).Plus(
|
orig = orig.Plus(projRight.ScaledBy(p.x)).Plus(
|
||||||
projUp. ScaledBy(p.y).Plus(
|
projUp. ScaledBy(p.y).Plus(
|
||||||
|
@ -1229,3 +1229,21 @@ bool Constraint::IsStylable() {
|
|||||||
return false;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
SS.GW.GroupSelection();
|
SS.GW.GroupSelection();
|
||||||
if(SS.GW.gs.points == 0 && SS.GW.gs.comments == 0) {
|
if(SS.GW.gs.points == 0 && SS.GW.gs.constraintLabels == 0) {
|
||||||
Error("Can't snap these items to grid; select points or "
|
Error("Can't snap these items to grid; select points, "
|
||||||
"text comments. To snap a line, select its endpoints.");
|
"text comments, or constraints with a label. "
|
||||||
|
"To snap a line, select its endpoints.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SS.UndoRemember();
|
SS.UndoRemember();
|
||||||
@ -908,8 +909,6 @@ void GraphicsWindow::MenuEdit(int id) {
|
|||||||
SS.MarkGroupDirty(ep->group);
|
SS.MarkGroupDirty(ep->group);
|
||||||
} else if(s->constraint.v) {
|
} else if(s->constraint.v) {
|
||||||
Constraint *c = SK.GetConstraint(s->constraint);
|
Constraint *c = SK.GetConstraint(s->constraint);
|
||||||
if(c->type != Constraint::COMMENT) continue;
|
|
||||||
|
|
||||||
c->disp.offset = SS.GW.SnapToGrid(c->disp.offset);
|
c->disp.offset = SS.GW.SnapToGrid(c->disp.offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -571,7 +571,7 @@ void GraphicsWindow::MouseRightUp(double x, double y) {
|
|||||||
CMNU_OTHER_ANGLE);
|
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);
|
AddContextMenuItem("Snap to Grid", CMNU_SNAP_TO_GRID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -682,6 +682,7 @@ public:
|
|||||||
void Draw(void);
|
void Draw(void);
|
||||||
void GetEdges(SEdgeList *sel);
|
void GetEdges(SEdgeList *sel);
|
||||||
bool IsStylable();
|
bool IsStylable();
|
||||||
|
bool HasLabel();
|
||||||
|
|
||||||
void LineDrawOrGetDistance(Vector a, Vector b);
|
void LineDrawOrGetDistance(Vector a, Vector b);
|
||||||
bool IsVisible() const;
|
bool IsVisible() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user