Skip to content

Commit 9a0591c

Browse files
committed
Indicate diameter symbol on diameter dimensions, instead of just a
bare number. [git-p4: depot-paths = "//depot/solvespace/": change = 2157]
1 parent 5ba5371 commit 9a0591c

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

drawconstraint.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ char *Constraint::Label(void) {
5757
sprintf(Ret, "%.3f:1", valA);
5858
} else if(type == COMMENT) {
5959
strcpy(Ret, comment.str);
60+
} else if(type == DIAMETER) {
61+
// leading spaces for diameter symbol
62+
sprintf(Ret, " %s", SS.MmToString(valA));
6063
} else {
6164
// valA has units of distance
6265
strcpy(Ret, SS.MmToString(fabs(valA)));
@@ -506,7 +509,31 @@ void Constraint::DrawOrGetDistance(Vector *labelPos) {
506509
mark = mark.WithMagnitude(mark.Magnitude()-r);
507510
DoLineTrimmedAgainstBox(ref, ref, ref.Minus(mark));
508511

509-
DoLabel(ref, labelPos, gr, gu);
512+
Vector topLeft;
513+
DoLabel(ref, &topLeft, gr, gu);
514+
if(labelPos) *labelPos = topLeft;
515+
516+
// Draw the diameter symbol
517+
Vector dc = topLeft;
518+
dc = dc.Plus(gu.WithMagnitude(5/SS.GW.scale));
519+
dc = dc.Plus(gr.WithMagnitude(9/SS.GW.scale));
520+
double dr = 5/SS.GW.scale;
521+
double theta, dtheta = (2*PI)/12;
522+
for(theta = 0; theta < 2*PI-0.01; theta += dtheta) {
523+
LineDrawOrGetDistance(
524+
dc.Plus(gu.WithMagnitude(cos(theta)*dr)).Plus(
525+
gr.WithMagnitude(sin(theta)*dr)),
526+
dc.Plus(gu.WithMagnitude(cos(theta+dtheta)*dr)).Plus(
527+
gr.WithMagnitude(sin(theta+dtheta)*dr)));
528+
}
529+
theta = 25*(PI/180);
530+
dr *= 1.7;
531+
dtheta = PI;
532+
LineDrawOrGetDistance(
533+
dc.Plus(gu.WithMagnitude(cos(theta)*dr)).Plus(
534+
gr.WithMagnitude(sin(theta)*dr)),
535+
dc.Plus(gu.WithMagnitude(cos(theta+dtheta)*dr)).Plus(
536+
gr.WithMagnitude(sin(theta+dtheta)*dr)));
510537
break;
511538
}
512539

wishlist.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
O(n*log(n)) assembly of edges into contours
22
good color picker
3+
crude DXF, HPGL import
4+
a request to import a plane thing
35

46
-----
57
rounding, as a special group

0 commit comments

Comments
 (0)