Add an option to edit dimension immediately after adding.
This commit is contained in:
parent
58f23aa061
commit
dcdfdec564
@ -42,6 +42,8 @@ New constraint features:
|
|||||||
constraints on line segments.
|
constraints on line segments.
|
||||||
* Automatic creation of constraints no longer happens if the constraint
|
* Automatic creation of constraints no longer happens if the constraint
|
||||||
would have been redundant with other ones.
|
would have been redundant with other ones.
|
||||||
|
* New option to open the constraint editor for newly created constraints
|
||||||
|
with a value.
|
||||||
|
|
||||||
New export/import features:
|
New export/import features:
|
||||||
* Three.js: allow configuring projection for exported model, and initially
|
* Three.js: allow configuring projection for exported model, and initially
|
||||||
|
@ -102,6 +102,11 @@ void TextWindow::ScreenChangeTurntableNav(int link, uint32_t v) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextWindow::ScreenChangeImmediatelyEditDimension(int link, uint32_t v) {
|
||||||
|
SS.immediatelyEditDimension = !SS.immediatelyEditDimension;
|
||||||
|
SS.GW.Invalidate(/*clearPersistent=*/true);
|
||||||
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeShowContourAreas(int link, uint32_t v) {
|
void TextWindow::ScreenChangeShowContourAreas(int link, uint32_t v) {
|
||||||
SS.showContourAreas = !SS.showContourAreas;
|
SS.showContourAreas = !SS.showContourAreas;
|
||||||
SS.GW.Invalidate();
|
SS.GW.Invalidate();
|
||||||
@ -342,6 +347,9 @@ void TextWindow::ShowConfiguration() {
|
|||||||
SS.automaticLineConstraints ? CHECK_TRUE : CHECK_FALSE);
|
SS.automaticLineConstraints ? CHECK_TRUE : CHECK_FALSE);
|
||||||
Printf(false, " %Fd%f%Ll%s use turntable mouse navigation%E", &ScreenChangeTurntableNav,
|
Printf(false, " %Fd%f%Ll%s use turntable mouse navigation%E", &ScreenChangeTurntableNav,
|
||||||
SS.turntableNav ? CHECK_TRUE : CHECK_FALSE);
|
SS.turntableNav ? CHECK_TRUE : CHECK_FALSE);
|
||||||
|
Printf(false, " %Fd%f%Ll%s edit newly added dimensions%E",
|
||||||
|
&ScreenChangeImmediatelyEditDimension,
|
||||||
|
SS.immediatelyEditDimension ? CHECK_TRUE : CHECK_FALSE);
|
||||||
Printf(false, "");
|
Printf(false, "");
|
||||||
Printf(false, "%Ft autosave interval (in minutes)%E");
|
Printf(false, "%Ft autosave interval (in minutes)%E");
|
||||||
Printf(false, "%Ba %d %Fl%Ll%f[change]%E",
|
Printf(false, "%Ba %d %Fl%Ll%f[change]%E",
|
||||||
|
@ -196,6 +196,9 @@ void Constraint::MenuConstrain(Command id) {
|
|||||||
c.valA = 0;
|
c.valA = 0;
|
||||||
c.ModifyToSatisfy();
|
c.ModifyToSatisfy();
|
||||||
AddConstraint(&c);
|
AddConstraint(&c);
|
||||||
|
if (SS.immediatelyEditDimension) {
|
||||||
|
SS.GW.EditConstraint(c.h);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -607,6 +610,9 @@ void Constraint::MenuConstrain(Command id) {
|
|||||||
|
|
||||||
c.ModifyToSatisfy();
|
c.ModifyToSatisfy();
|
||||||
AddConstraint(&c);
|
AddConstraint(&c);
|
||||||
|
if (SS.immediatelyEditDimension) {
|
||||||
|
SS.GW.EditConstraint(c.h);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
128
src/mouse.cpp
128
src/mouse.cpp
@ -1339,73 +1339,77 @@ void GraphicsWindow::MouseLeftUp(double mx, double my, bool shiftDown, bool ctrl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphicsWindow::EditConstraint(hConstraint constraint) {
|
||||||
|
constraintBeingEdited = 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(GetCamera());
|
||||||
|
Point2d p2 = ProjectPoint(p3);
|
||||||
|
|
||||||
|
std::string editValue;
|
||||||
|
std::string editPlaceholder;
|
||||||
|
switch(c->type) {
|
||||||
|
case Constraint::Type::COMMENT:
|
||||||
|
editValue = c->comment;
|
||||||
|
editPlaceholder = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: {
|
||||||
|
double value = fabs(c->valA);
|
||||||
|
|
||||||
|
// If displayed as radius, also edit as radius.
|
||||||
|
if(c->type == Constraint::Type::DIAMETER && c->other)
|
||||||
|
value /= 2;
|
||||||
|
|
||||||
|
// Try showing value with default number of digits after decimal first.
|
||||||
|
if(c->type == Constraint::Type::LENGTH_RATIO) {
|
||||||
|
editValue = ssprintf("%.3f", value);
|
||||||
|
} else if(c->type == Constraint::Type::ANGLE) {
|
||||||
|
editValue = SS.DegreeToString(value);
|
||||||
|
} else {
|
||||||
|
editValue = SS.MmToString(value);
|
||||||
|
value /= SS.MmPerUnit();
|
||||||
|
}
|
||||||
|
// If that's not enough to represent it exactly, show the value with as many
|
||||||
|
// digits after decimal as required, up to 10.
|
||||||
|
int digits = 0;
|
||||||
|
while(fabs(std::stod(editValue) - value) > 1e-10) {
|
||||||
|
editValue = ssprintf("%.*f", digits, value);
|
||||||
|
digits++;
|
||||||
|
}
|
||||||
|
editPlaceholder = "10.000000";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double width, height;
|
||||||
|
window->GetContentSize(&width, &height);
|
||||||
|
hStyle hs = c->disp.style;
|
||||||
|
if(hs.v == 0) hs.v = Style::CONSTRAINT;
|
||||||
|
double capHeight = Style::TextHeight(hs);
|
||||||
|
double fontHeight = VectorFont::Builtin()->GetHeight(capHeight);
|
||||||
|
double editMinWidth = VectorFont::Builtin()->GetWidth(capHeight, editPlaceholder);
|
||||||
|
window->ShowEditor(p2.x + width / 2, height / 2 - p2.y,
|
||||||
|
fontHeight, editMinWidth,
|
||||||
|
/*isMonospace=*/false, editValue);
|
||||||
|
}
|
||||||
|
|
||||||
void GraphicsWindow::MouseLeftDoubleClick(double mx, double my) {
|
void GraphicsWindow::MouseLeftDoubleClick(double mx, double my) {
|
||||||
if(window->IsEditorVisible()) return;
|
if(window->IsEditorVisible()) return;
|
||||||
SS.TW.HideEditControl();
|
SS.TW.HideEditControl();
|
||||||
|
|
||||||
if(hover.constraint.v) {
|
if(hover.constraint.v) {
|
||||||
constraintBeingEdited = hover.constraint;
|
EditConstraint(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(GetCamera());
|
|
||||||
Point2d p2 = ProjectPoint(p3);
|
|
||||||
|
|
||||||
std::string editValue;
|
|
||||||
std::string editPlaceholder;
|
|
||||||
switch(c->type) {
|
|
||||||
case Constraint::Type::COMMENT:
|
|
||||||
editValue = c->comment;
|
|
||||||
editPlaceholder = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
|
||||||
break;
|
|
||||||
|
|
||||||
default: {
|
|
||||||
double value = fabs(c->valA);
|
|
||||||
|
|
||||||
// If displayed as radius, also edit as radius.
|
|
||||||
if(c->type == Constraint::Type::DIAMETER && c->other)
|
|
||||||
value /= 2;
|
|
||||||
|
|
||||||
// Try showing value with default number of digits after decimal first.
|
|
||||||
if(c->type == Constraint::Type::LENGTH_RATIO) {
|
|
||||||
editValue = ssprintf("%.3f", value);
|
|
||||||
} else if(c->type == Constraint::Type::ANGLE) {
|
|
||||||
editValue = SS.DegreeToString(value);
|
|
||||||
} else {
|
|
||||||
editValue = SS.MmToString(value);
|
|
||||||
value /= SS.MmPerUnit();
|
|
||||||
}
|
|
||||||
// If that's not enough to represent it exactly, show the value with as many
|
|
||||||
// digits after decimal as required, up to 10.
|
|
||||||
int digits = 0;
|
|
||||||
while(fabs(std::stod(editValue) - value) > 1e-10) {
|
|
||||||
editValue = ssprintf("%.*f", digits, value);
|
|
||||||
digits++;
|
|
||||||
}
|
|
||||||
editPlaceholder = "10.000000";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
double width, height;
|
|
||||||
window->GetContentSize(&width, &height);
|
|
||||||
hStyle hs = c->disp.style;
|
|
||||||
if(hs.v == 0) hs.v = Style::CONSTRAINT;
|
|
||||||
double capHeight = Style::TextHeight(hs);
|
|
||||||
double fontHeight = VectorFont::Builtin()->GetHeight(capHeight);
|
|
||||||
double editMinWidth = VectorFont::Builtin()->GetWidth(capHeight, editPlaceholder);
|
|
||||||
window->ShowEditor(p2.x + width / 2, height / 2 - p2.y,
|
|
||||||
fontHeight, editMinWidth,
|
|
||||||
/*isMonospace=*/false, editValue);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +72,8 @@ void SolveSpaceUI::Init() {
|
|||||||
drawBackFaces = settings->ThawBool("DrawBackFaces", true);
|
drawBackFaces = settings->ThawBool("DrawBackFaces", true);
|
||||||
// Use turntable mouse navigation
|
// Use turntable mouse navigation
|
||||||
turntableNav = settings->ThawBool("TurntableNav", false);
|
turntableNav = settings->ThawBool("TurntableNav", false);
|
||||||
|
// Immediately edit dimension
|
||||||
|
immediatelyEditDimension = settings->ThawBool("ImmediatelyEditDimension", false);
|
||||||
// Check that contours are closed and not self-intersecting
|
// Check that contours are closed and not self-intersecting
|
||||||
checkClosedContour = settings->ThawBool("CheckClosedContour", true);
|
checkClosedContour = settings->ThawBool("CheckClosedContour", true);
|
||||||
// Enable automatic constrains for lines
|
// Enable automatic constrains for lines
|
||||||
@ -251,6 +253,8 @@ void SolveSpaceUI::Exit() {
|
|||||||
settings->FreezeBool("CheckClosedContour", checkClosedContour);
|
settings->FreezeBool("CheckClosedContour", checkClosedContour);
|
||||||
// Use turntable mouse navigation
|
// Use turntable mouse navigation
|
||||||
settings->FreezeBool("TurntableNav", turntableNav);
|
settings->FreezeBool("TurntableNav", turntableNav);
|
||||||
|
// Immediately edit dimensions
|
||||||
|
settings->FreezeBool("ImmediatelyEditDimension", immediatelyEditDimension);
|
||||||
// Enable automatic constrains for lines
|
// Enable automatic constrains for lines
|
||||||
settings->FreezeBool("AutomaticLineConstraints", automaticLineConstraints);
|
settings->FreezeBool("AutomaticLineConstraints", automaticLineConstraints);
|
||||||
// Export shaded triangles in a 2d view
|
// Export shaded triangles in a 2d view
|
||||||
|
@ -587,6 +587,7 @@ public:
|
|||||||
bool showContourAreas;
|
bool showContourAreas;
|
||||||
bool checkClosedContour;
|
bool checkClosedContour;
|
||||||
bool turntableNav;
|
bool turntableNav;
|
||||||
|
bool immediatelyEditDimension;
|
||||||
bool automaticLineConstraints;
|
bool automaticLineConstraints;
|
||||||
bool showToolbar;
|
bool showToolbar;
|
||||||
Platform::Path screenshotFile;
|
Platform::Path screenshotFile;
|
||||||
|
2
src/ui.h
2
src/ui.h
@ -430,6 +430,7 @@ public:
|
|||||||
static void ScreenChangeShowContourAreas(int link, uint32_t v);
|
static void ScreenChangeShowContourAreas(int link, uint32_t v);
|
||||||
static void ScreenChangeCheckClosedContour(int link, uint32_t v);
|
static void ScreenChangeCheckClosedContour(int link, uint32_t v);
|
||||||
static void ScreenChangeTurntableNav(int link, uint32_t v);
|
static void ScreenChangeTurntableNav(int link, uint32_t v);
|
||||||
|
static void ScreenChangeImmediatelyEditDimension(int link, uint32_t v);
|
||||||
static void ScreenChangeAutomaticLineConstraints(int link, uint32_t v);
|
static void ScreenChangeAutomaticLineConstraints(int link, uint32_t v);
|
||||||
static void ScreenChangePwlCurves(int link, uint32_t v);
|
static void ScreenChangePwlCurves(int link, uint32_t v);
|
||||||
static void ScreenChangeCanvasSizeAuto(int link, uint32_t v);
|
static void ScreenChangeCanvasSizeAuto(int link, uint32_t v);
|
||||||
@ -690,6 +691,7 @@ public:
|
|||||||
void RemoveConstraintsForPointBeingDeleted(hEntity hpt);
|
void RemoveConstraintsForPointBeingDeleted(hEntity hpt);
|
||||||
void FixConstraintsForRequestBeingDeleted(hRequest hr);
|
void FixConstraintsForRequestBeingDeleted(hRequest hr);
|
||||||
void FixConstraintsForPointBeingDeleted(hEntity hpt);
|
void FixConstraintsForPointBeingDeleted(hEntity hpt);
|
||||||
|
void EditConstraint(hConstraint constraint);
|
||||||
|
|
||||||
// A selected entity.
|
// A selected entity.
|
||||||
class Selection {
|
class Selection {
|
||||||
|
Loading…
Reference in New Issue
Block a user