Improve text screen for a selected constraint.

* Show the type of a constraint.
  * Show the workplane a constraint is in, for constraints which can
    be both projected to workplane or be free in 3d space.
  * Clearly distinguish reference from non-reference constraints.
  * Add a checkbox for toggling the reference option.
  * When showing requests a constraint applies to, highlight on hover
    the specific entity being constrained, not just the first one.
pull/661/head
whitequark 2020-07-28 19:13:40 +00:00
parent fef6a39a17
commit afa9e2890e
4 changed files with 102 additions and 13 deletions

View File

@ -28,6 +28,50 @@ bool ConstraintBase::HasLabel() const {
} }
} }
bool ConstraintBase::IsProjectible() const {
switch(type) {
case Type::POINTS_COINCIDENT:
case Type::PT_PT_DISTANCE:
case Type::PT_LINE_DISTANCE:
case Type::PT_ON_LINE:
case Type::EQUAL_LENGTH_LINES:
case Type::EQ_LEN_PT_LINE_D:
case Type::EQ_PT_LN_DISTANCES:
case Type::EQUAL_ANGLE:
case Type::LENGTH_RATIO:
case Type::LENGTH_DIFFERENCE:
case Type::SYMMETRIC:
case Type::SYMMETRIC_HORIZ:
case Type::SYMMETRIC_VERT:
case Type::SYMMETRIC_LINE:
case Type::AT_MIDPOINT:
case Type::HORIZONTAL:
case Type::VERTICAL:
case Type::ANGLE:
case Type::PARALLEL:
case Type::PERPENDICULAR:
case Type::WHERE_DRAGGED:
case Type::COMMENT:
return true;
case Type::PT_PLANE_DISTANCE:
case Type::PT_FACE_DISTANCE:
case Type::PROJ_PT_DISTANCE:
case Type::PT_IN_PLANE:
case Type::PT_ON_FACE:
case Type::EQUAL_LINE_ARC_LEN:
case Type::DIAMETER:
case Type::PT_ON_CIRCLE:
case Type::SAME_ORIENTATION:
case Type::CUBIC_LINE_TANGENT:
case Type::CURVE_CURVE_TANGENT:
case Type::ARC_LINE_TANGENT:
case Type::EQUAL_RADIUS:
return false;
}
ssassert(false, "Impossible");
}
ExprVector ConstraintBase::VectorsParallel3d(ExprVector a, ExprVector b, hParam p) { ExprVector ConstraintBase::VectorsParallel3d(ExprVector a, ExprVector b, hParam p) {
return a.Minus(b.ScaledBy(Expr::From(p))); return a.Minus(b.ScaledBy(Expr::From(p)));
} }

View File

@ -40,6 +40,16 @@ void TextWindow::ScreenSetTtfFont(int link, uint32_t v) {
SS.ScheduleShowTW(); SS.ScheduleShowTW();
} }
void TextWindow::ScreenConstraintToggleReference(int link, uint32_t v) {
hConstraint hc = { v };
Constraint *c = SK.GetConstraint(hc);
SS.UndoRemember();
c->reference = !c->reference;
SS.ScheduleShowTW();
}
void TextWindow::ScreenConstraintShowAsRadius(int link, uint32_t v) { void TextWindow::ScreenConstraintShowAsRadius(int link, uint32_t v) {
hConstraint hc = { v }; hConstraint hc = { v };
Constraint *c = SK.GetConstraint(hc); Constraint *c = SK.GetConstraint(hc);
@ -365,16 +375,45 @@ void TextWindow::DescribeSelection() {
Printf(false, "%FtSELECTED:%E comment text"); Printf(false, "%FtSELECTED:%E comment text");
} else if(gs.n == 0 && gs.constraints == 1) { } else if(gs.n == 0 && gs.constraints == 1) {
Constraint *c = SK.GetConstraint(gs.constraint[0]); Constraint *c = SK.GetConstraint(gs.constraint[0]);
const std::string &desc = c->DescriptionString().c_str();
if(c->type == Constraint::Type::COMMENT) {
Printf(false, "%FtCOMMENT%E %s", desc.c_str());
} else if(c->HasLabel()) {
if(c->reference) {
Printf(false, "%FtREFERENCE%E %s", desc.c_str());
} else {
Printf(false, "%FtDIMENSION%E %s", desc.c_str());
}
Printf(true, " %Fd%f%D%Ll%s reference",
&ScreenConstraintToggleReference, gs.constraint[0].v,
c->reference ? CHECK_TRUE : CHECK_FALSE);
if(c->type == Constraint::Type::DIAMETER) { if(c->type == Constraint::Type::DIAMETER) {
Printf(false, "%FtDIAMETER CONSTRAINT"); Printf(false, " %Fd%f%D%Ll%s use radius",
Printf(true, " %Fd%f%D%Ll%s show as radius",
&ScreenConstraintShowAsRadius, gs.constraint[0].v, &ScreenConstraintShowAsRadius, gs.constraint[0].v,
c->other ? CHECK_TRUE : CHECK_FALSE); c->other ? CHECK_TRUE : CHECK_FALSE);
}
} else { } else {
Printf(false, "%FtSELECTED:%E %s", Printf(false, "%FtCONSTRAINT%E %s", desc.c_str());
c->DescriptionString().c_str()); }
if(c->IsProjectible()) {
if(c->workplane == Entity::FREE_IN_3D) {
Printf(true, "%FtNOT PROJECTED TO WORKPLANE%E");
} else {
Entity *w = SK.GetEntity(c->workplane);
if(w->h.isFromRequest()) {
Printf(true, "%FtIN WORKPLANE%E %Fl%Ll%D%f%h%s%E",
w->h.request().v,
(&TextWindow::ScreenSelectRequest), &(TextWindow::ScreenHoverRequest),
w->DescriptionString().c_str());
} else {
Printf(true, "%FtIN WORKPLANE%E %Fl%Ll%D%f%h%s%E",
w->h.group().v,
(&TextWindow::ScreenSelectGroup), (&TextWindow::ScreenHoverGroupWorkplane),
w->DescriptionString().c_str());
}
}
} }
std::vector<hEntity> lhe = {}; std::vector<hEntity> lhe = {};
@ -391,16 +430,20 @@ void TextWindow::DescribeSelection() {
lhe.erase(it, lhe.end()); lhe.erase(it, lhe.end());
if(!lhe.empty()) { if(!lhe.empty()) {
if(c->reference) {
Printf(true, "%FtMEASURES:%E");
} else {
Printf(true, "%FtCONSTRAINS:%E"); Printf(true, "%FtCONSTRAINS:%E");
}
int a = 0; int a = 0;
for(hEntity he : lhe) { for(hEntity he : lhe) {
Request *r = SK.GetRequest(he.request()); Entity *e = SK.GetEntity(he);
std::string s = r->DescriptionString();
Printf(false, "%Bp %Fl%Ll%D%f%h%s%E", Printf(false, "%Bp %Fl%Ll%D%f%h%s%E",
(a & 1) ? 'd' : 'a', (a & 1) ? 'd' : 'a',
r->h.v, (&TextWindow::ScreenSelectRequest), e->h.v, (&TextWindow::ScreenSelectEntity),
&(TextWindow::ScreenHoverRequest), s.c_str()); &(TextWindow::ScreenHoverEntity),
e->DescriptionString().c_str());
a++; a++;
} }
} }

View File

@ -703,6 +703,7 @@ public:
} }
bool HasLabel() const; bool HasLabel() const;
bool IsProjectible() const;
void Generate(IdList<Param, hParam> *param); void Generate(IdList<Param, hParam> *param);

View File

@ -397,6 +397,7 @@ public:
static void ScreenUnselectAll(int link, uint32_t v); static void ScreenUnselectAll(int link, uint32_t v);
// when we're describing a constraint // when we're describing a constraint
static void ScreenConstraintToggleReference(int link, uint32_t v);
static void ScreenConstraintShowAsRadius(int link, uint32_t v); static void ScreenConstraintShowAsRadius(int link, uint32_t v);
// and the rest from the stuff in textscreens.cpp // and the rest from the stuff in textscreens.cpp