Add checkbox to control automatic line constraints
Signed-off-by: Sergiusz Bazanski <q3k@q3k.org>pull/380/head
parent
b2418a0324
commit
9e512882d1
|
@ -33,6 +33,8 @@ New constraint features:
|
||||||
in the text window.
|
in the text window.
|
||||||
* When selecting an entity, the constraints applied to it can be selected
|
* When selecting an entity, the constraints applied to it can be selected
|
||||||
in the text window.
|
in the text window.
|
||||||
|
* It is now possible to turn off automatic creation of horizontal/vertical
|
||||||
|
constraints on line segments.
|
||||||
|
|
||||||
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
|
||||||
|
|
|
@ -93,6 +93,11 @@ void TextWindow::ScreenChangeCheckClosedContour(int link, uint32_t v) {
|
||||||
SS.GW.Invalidate();
|
SS.GW.Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextWindow::ScreenChangeAutomaticLineConstraints(int link, uint32_t v) {
|
||||||
|
SS.automaticLineConstraints = !SS.automaticLineConstraints;
|
||||||
|
SS.GW.Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeShadedTriangles(int link, uint32_t v) {
|
void TextWindow::ScreenChangeShadedTriangles(int link, uint32_t v) {
|
||||||
SS.exportShadedTriangles = !SS.exportShadedTriangles;
|
SS.exportShadedTriangles = !SS.exportShadedTriangles;
|
||||||
SS.GW.Invalidate();
|
SS.GW.Invalidate();
|
||||||
|
@ -301,6 +306,9 @@ void TextWindow::ShowConfiguration() {
|
||||||
Printf(false, " %Fd%f%Ll%s check sketch for closed contour%E",
|
Printf(false, " %Fd%f%Ll%s check sketch for closed contour%E",
|
||||||
&ScreenChangeCheckClosedContour,
|
&ScreenChangeCheckClosedContour,
|
||||||
SS.checkClosedContour ? CHECK_TRUE : CHECK_FALSE);
|
SS.checkClosedContour ? CHECK_TRUE : CHECK_FALSE);
|
||||||
|
Printf(false, " %Fd%f%Ll%s enable automatic line constraints%E",
|
||||||
|
&ScreenChangeAutomaticLineConstraints,
|
||||||
|
SS.automaticLineConstraints ? CHECK_TRUE : CHECK_FALSE);
|
||||||
Printf(false, " %Fd%f%Ll%s show areas of closed contours%E",
|
Printf(false, " %Fd%f%Ll%s show areas of closed contours%E",
|
||||||
&ScreenChangeShowContourAreas,
|
&ScreenChangeShowContourAreas,
|
||||||
SS.showContourAreas ? CHECK_TRUE : CHECK_FALSE);
|
SS.showContourAreas ? CHECK_TRUE : CHECK_FALSE);
|
||||||
|
|
|
@ -1283,26 +1283,27 @@ void GraphicsWindow::ToggleBool(bool *v) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GraphicsWindow::SuggestLineConstraint(hRequest request, Constraint::Type *type) {
|
bool GraphicsWindow::SuggestLineConstraint(hRequest request, Constraint::Type *type) {
|
||||||
if(LockedInWorkplane()) {
|
if(!(LockedInWorkplane() && SS.automaticLineConstraints))
|
||||||
Entity *ptA = SK.GetEntity(request.entity(1)),
|
return false;
|
||||||
*ptB = SK.GetEntity(request.entity(2));
|
|
||||||
|
|
||||||
Expr *au, *av, *bu, *bv;
|
Entity *ptA = SK.GetEntity(request.entity(1)),
|
||||||
|
*ptB = SK.GetEntity(request.entity(2));
|
||||||
|
|
||||||
ptA->PointGetExprsInWorkplane(ActiveWorkplane(), &au, &av);
|
Expr *au, *av, *bu, *bv;
|
||||||
ptB->PointGetExprsInWorkplane(ActiveWorkplane(), &bu, &bv);
|
|
||||||
|
|
||||||
double du = au->Minus(bu)->Eval();
|
ptA->PointGetExprsInWorkplane(ActiveWorkplane(), &au, &av);
|
||||||
double dv = av->Minus(bv)->Eval();
|
ptB->PointGetExprsInWorkplane(ActiveWorkplane(), &bu, &bv);
|
||||||
|
|
||||||
const double TOLERANCE_RATIO = 0.02;
|
double du = au->Minus(bu)->Eval();
|
||||||
if(fabs(dv) > LENGTH_EPS && fabs(du / dv) < TOLERANCE_RATIO) {
|
double dv = av->Minus(bv)->Eval();
|
||||||
*type = Constraint::Type::VERTICAL;
|
|
||||||
return true;
|
const double TOLERANCE_RATIO = 0.02;
|
||||||
} else if(fabs(du) > LENGTH_EPS && fabs(dv / du) < TOLERANCE_RATIO) {
|
if(fabs(dv) > LENGTH_EPS && fabs(du / dv) < TOLERANCE_RATIO) {
|
||||||
*type = Constraint::Type::HORIZONTAL;
|
*type = Constraint::Type::VERTICAL;
|
||||||
return true;
|
return true;
|
||||||
}
|
} else if(fabs(du) > LENGTH_EPS && fabs(dv / du) < TOLERANCE_RATIO) {
|
||||||
|
*type = Constraint::Type::HORIZONTAL;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,8 @@ void SolveSpaceUI::Init() {
|
||||||
drawBackFaces = settings->ThawBool("DrawBackFaces", true);
|
drawBackFaces = settings->ThawBool("DrawBackFaces", true);
|
||||||
// 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
|
||||||
|
automaticLineConstraints = settings->ThawBool("AutomaticLineConstraints", true);
|
||||||
// Draw closed polygons areas
|
// Draw closed polygons areas
|
||||||
showContourAreas = settings->ThawBool("ShowContourAreas", false);
|
showContourAreas = settings->ThawBool("ShowContourAreas", false);
|
||||||
// Export shaded triangles in a 2d view
|
// Export shaded triangles in a 2d view
|
||||||
|
@ -241,6 +243,8 @@ void SolveSpaceUI::Exit() {
|
||||||
settings->FreezeBool("ShowContourAreas", showContourAreas);
|
settings->FreezeBool("ShowContourAreas", showContourAreas);
|
||||||
// Check that contours are closed and not self-intersecting
|
// Check that contours are closed and not self-intersecting
|
||||||
settings->FreezeBool("CheckClosedContour", checkClosedContour);
|
settings->FreezeBool("CheckClosedContour", checkClosedContour);
|
||||||
|
// Enable automatic constrains for lines
|
||||||
|
settings->FreezeBool("AutomaticLineConstraints", automaticLineConstraints);
|
||||||
// Export shaded triangles in a 2d view
|
// Export shaded triangles in a 2d view
|
||||||
settings->FreezeBool("ExportShadedTriangles", exportShadedTriangles);
|
settings->FreezeBool("ExportShadedTriangles", exportShadedTriangles);
|
||||||
// Export pwl curves (instead of exact) always
|
// Export pwl curves (instead of exact) always
|
||||||
|
|
|
@ -590,6 +590,7 @@ public:
|
||||||
bool drawBackFaces;
|
bool drawBackFaces;
|
||||||
bool showContourAreas;
|
bool showContourAreas;
|
||||||
bool checkClosedContour;
|
bool checkClosedContour;
|
||||||
|
bool automaticLineConstraints;
|
||||||
bool showToolbar;
|
bool showToolbar;
|
||||||
Platform::Path screenshotFile;
|
Platform::Path screenshotFile;
|
||||||
RgbaColor backgroundColor;
|
RgbaColor backgroundColor;
|
||||||
|
|
1
src/ui.h
1
src/ui.h
|
@ -425,6 +425,7 @@ public:
|
||||||
static void ScreenChangeBackFaces(int link, uint32_t v);
|
static void ScreenChangeBackFaces(int link, uint32_t v);
|
||||||
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 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);
|
||||||
static void ScreenChangeCanvasSize(int link, uint32_t v);
|
static void ScreenChangeCanvasSize(int link, uint32_t v);
|
||||||
|
|
Loading…
Reference in New Issue