diff --git a/src/constrainteq.cpp b/src/constrainteq.cpp index 985545c7..965a13d0 100644 --- a/src/constrainteq.cpp +++ b/src/constrainteq.cpp @@ -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) { return a.Minus(b.ScaledBy(Expr::From(p))); } diff --git a/src/describescreen.cpp b/src/describescreen.cpp index 4ebe20e5..f17baaa1 100644 --- a/src/describescreen.cpp +++ b/src/describescreen.cpp @@ -40,6 +40,16 @@ void TextWindow::ScreenSetTtfFont(int link, uint32_t v) { 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) { hConstraint hc = { v }; Constraint *c = SK.GetConstraint(hc); @@ -365,16 +375,45 @@ void TextWindow::DescribeSelection() { Printf(false, "%FtSELECTED:%E comment text"); } else if(gs.n == 0 && gs.constraints == 1) { Constraint *c = SK.GetConstraint(gs.constraint[0]); + const std::string &desc = c->DescriptionString().c_str(); - if(c->type == Constraint::Type::DIAMETER) { - Printf(false, "%FtDIAMETER CONSTRAINT"); - - Printf(true, " %Fd%f%D%Ll%s show as radius", - &ScreenConstraintShowAsRadius, gs.constraint[0].v, - c->other ? CHECK_TRUE : CHECK_FALSE); + 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) { + Printf(false, " %Fd%f%D%Ll%s use radius", + &ScreenConstraintShowAsRadius, gs.constraint[0].v, + c->other ? CHECK_TRUE : CHECK_FALSE); + } } else { - Printf(false, "%FtSELECTED:%E %s", - c->DescriptionString().c_str()); + Printf(false, "%FtCONSTRAINT%E %s", desc.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 lhe = {}; @@ -391,16 +430,20 @@ void TextWindow::DescribeSelection() { lhe.erase(it, lhe.end()); if(!lhe.empty()) { - Printf(true, "%FtCONSTRAINS:%E"); + if(c->reference) { + Printf(true, "%FtMEASURES:%E"); + } else { + Printf(true, "%FtCONSTRAINS:%E"); + } int a = 0; for(hEntity he : lhe) { - Request *r = SK.GetRequest(he.request()); - std::string s = r->DescriptionString(); + Entity *e = SK.GetEntity(he); Printf(false, "%Bp %Fl%Ll%D%f%h%s%E", (a & 1) ? 'd' : 'a', - r->h.v, (&TextWindow::ScreenSelectRequest), - &(TextWindow::ScreenHoverRequest), s.c_str()); + e->h.v, (&TextWindow::ScreenSelectEntity), + &(TextWindow::ScreenHoverEntity), + e->DescriptionString().c_str()); a++; } } diff --git a/src/sketch.h b/src/sketch.h index 72cda7eb..95aebd05 100644 --- a/src/sketch.h +++ b/src/sketch.h @@ -703,6 +703,7 @@ public: } bool HasLabel() const; + bool IsProjectible() const; void Generate(IdList *param); diff --git a/src/ui.h b/src/ui.h index 8f29a73c..a29bad1c 100644 --- a/src/ui.h +++ b/src/ui.h @@ -397,6 +397,7 @@ public: static void ScreenUnselectAll(int link, uint32_t v); // when we're describing a constraint + static void ScreenConstraintToggleReference(int link, uint32_t v); static void ScreenConstraintShowAsRadius(int link, uint32_t v); // and the rest from the stuff in textscreens.cpp