本文整理汇总了C++中Constraint::GetLabelPos方法的典型用法代码示例。如果您正苦于以下问题:C++ Constraint::GetLabelPos方法的具体用法?C++ Constraint::GetLabelPos怎么用?C++ Constraint::GetLabelPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Constraint
的用法示例。
在下文中一共展示了Constraint::GetLabelPos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MouseLeftDoubleClick
void GraphicsWindow::MouseLeftDoubleClick(double mx, double my) {
if(GraphicsEditControlIsVisible()) return;
SS.TW.HideEditControl();
if(hover.constraint.v) {
constraintBeingEdited = hover.constraint;
ClearSuper();
Constraint *c = SK.GetConstraint(constraintBeingEdited);
if(!c->HasLabel()) {
// Not meaningful to edit a constraint without a dimension
return;
}
if(c->reference) {
// Not meaningful to edit a reference dimension
return;
}
Vector p3 = c->GetLabelPos();
Point2d p2 = ProjectPoint(p3);
char s[1024];
switch(c->type) {
case Constraint::COMMENT:
strcpy(s, c->comment.str);
break;
case Constraint::ANGLE:
case Constraint::LENGTH_RATIO:
sprintf(s, "%.3f", c->valA);
break;
default: {
double v = fabs(c->valA);
// If displayed as radius, also edit as radius.
if(c->type == Constraint::DIAMETER && c->disp.toggleA)
v /= 2;
char *def = SS.MmToString(v);
double eps = 1e-12;
if(fabs(SS.StringToMm(def) - v) < eps) {
// Show value with default number of digits after decimal,
// which is at least enough to represent it exactly.
strcpy(s, def);
} else {
// Show value with as many digits after decimal as
// required to represent it exactly, up to 10.
v /= SS.MmPerUnit();
int i;
for(i = 0; i <= 10; i++) {
sprintf(s, "%.*f", i, v);
if(fabs(atof(s) - v) < eps) break;
}
}
break;
}
}
ShowGraphicsEditControl((int)p2.x, (int)p2.y-4, s);
}
}