Implement turntable (SketchUp-like) mouse navigation.
This commit is contained in:
parent
c2c26e95ad
commit
e67f967933
@ -68,6 +68,7 @@ New measurement/analysis features:
|
|||||||
Other new features:
|
Other new features:
|
||||||
* New command-line interface, for batch exporting and more.
|
* New command-line interface, for batch exporting and more.
|
||||||
* The graphical interface now supports HiDPI screens on every OS.
|
* The graphical interface now supports HiDPI screens on every OS.
|
||||||
|
* New option to lock Z axis to be always vertical, like in SketchUp.
|
||||||
* New link to match the on-screen size of the sketch with its actual size,
|
* New link to match the on-screen size of the sketch with its actual size,
|
||||||
"view → set to full scale".
|
"view → set to full scale".
|
||||||
* When zooming to fit, constraints are also considered.
|
* When zooming to fit, constraints are also considered.
|
||||||
|
@ -83,6 +83,15 @@ void TextWindow::ScreenChangeBackFaces(int link, uint32_t v) {
|
|||||||
SS.GW.Invalidate(/*clearPersistent=*/true);
|
SS.GW.Invalidate(/*clearPersistent=*/true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextWindow::ScreenChangeTurntableNav(int link, uint32_t v) {
|
||||||
|
SS.turntableNav = !SS.turntableNav;
|
||||||
|
if(SS.turntableNav) {
|
||||||
|
// If turntable nav is being turned on, align view so Z is vertical
|
||||||
|
SS.GW.AnimateOnto(Quaternion::From(Vector::From(-1, 0, 0), Vector::From(0, 0, 1)),
|
||||||
|
SS.GW.offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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();
|
||||||
@ -306,13 +315,14 @@ 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);
|
||||||
|
Printf(false, " %Fd%f%Ll%s enable automatic line constraints%E",
|
||||||
|
&ScreenChangeAutomaticLineConstraints,
|
||||||
|
SS.automaticLineConstraints ? CHECK_TRUE : CHECK_FALSE);
|
||||||
|
Printf(false, " %Fd%f%Ll%s use turntable mouse navigation%E", &ScreenChangeTurntableNav,
|
||||||
|
SS.turntableNav ? 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",
|
||||||
|
@ -427,6 +427,21 @@ void GraphicsWindow::AnimateOntoWorkplane() {
|
|||||||
|
|
||||||
Entity *w = SK.GetEntity(ActiveWorkplane());
|
Entity *w = SK.GetEntity(ActiveWorkplane());
|
||||||
Quaternion quatf = w->Normal()->NormalGetNum();
|
Quaternion quatf = w->Normal()->NormalGetNum();
|
||||||
|
|
||||||
|
// Get Z pointing vertical, if we're on turntable nav mode:
|
||||||
|
if(SS.turntableNav) {
|
||||||
|
Vector normalRight = quatf.RotationU();
|
||||||
|
Vector normalUp = quatf.RotationV();
|
||||||
|
Vector normal = normalRight.Cross(normalUp);
|
||||||
|
if(normalRight.z != 0) {
|
||||||
|
double theta = atan2(normalUp.z, normalRight.z);
|
||||||
|
theta -= atan2(1, 0);
|
||||||
|
normalRight = normalRight.RotatedAbout(normal, theta);
|
||||||
|
normalUp = normalUp.RotatedAbout(normal, theta);
|
||||||
|
quatf = Quaternion::From(normalRight, normalUp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Vector offsetf = (SK.GetEntity(w->point[0])->PointGetNum()).ScaledBy(-1);
|
Vector offsetf = (SK.GetEntity(w->point[0])->PointGetNum()).ScaledBy(-1);
|
||||||
|
|
||||||
// If the view screen is open, then we need to refresh it.
|
// If the view screen is open, then we need to refresh it.
|
||||||
|
@ -135,8 +135,14 @@ void GraphicsWindow::MouseMoved(double x, double y, bool leftDown,
|
|||||||
|
|
||||||
if(!(shiftDown || ctrlDown)) {
|
if(!(shiftDown || ctrlDown)) {
|
||||||
double s = 0.3*(PI/180)*scale; // degrees per pixel
|
double s = 0.3*(PI/180)*scale; // degrees per pixel
|
||||||
|
if(SS.turntableNav) { // lock the Z to vertical
|
||||||
|
projRight = orig.projRight.RotatedAbout(Vector::From(0, 0, 1), -s * dx);
|
||||||
|
projUp = orig.projUp.RotatedAbout(
|
||||||
|
Vector::From(orig.projRight.x, orig.projRight.y, orig.projRight.y), s * dy);
|
||||||
|
} else {
|
||||||
projRight = orig.projRight.RotatedAbout(orig.projUp, -s * dx);
|
projRight = orig.projRight.RotatedAbout(orig.projUp, -s * dx);
|
||||||
projUp = orig.projUp.RotatedAbout(orig.projRight, s * dy);
|
projUp = orig.projUp.RotatedAbout(orig.projRight, s * dy);
|
||||||
|
}
|
||||||
|
|
||||||
NormalizeProjectionVectors();
|
NormalizeProjectionVectors();
|
||||||
} else if(ctrlDown) {
|
} else if(ctrlDown) {
|
||||||
|
@ -68,6 +68,8 @@ void SolveSpaceUI::Init() {
|
|||||||
fixExportColors = settings->ThawBool("FixExportColors", true);
|
fixExportColors = settings->ThawBool("FixExportColors", true);
|
||||||
// Draw back faces of triangles (when mesh is leaky/self-intersecting)
|
// Draw back faces of triangles (when mesh is leaky/self-intersecting)
|
||||||
drawBackFaces = settings->ThawBool("DrawBackFaces", true);
|
drawBackFaces = settings->ThawBool("DrawBackFaces", true);
|
||||||
|
// Use turntable mouse navigation
|
||||||
|
turntableNav = settings->ThawBool("TurntableNav", 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
|
||||||
@ -243,6 +245,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);
|
||||||
|
// Use turntable mouse navigation
|
||||||
|
settings->FreezeBool("TurntableNav", turntableNav);
|
||||||
// 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
|
||||||
|
@ -590,6 +590,7 @@ public:
|
|||||||
bool drawBackFaces;
|
bool drawBackFaces;
|
||||||
bool showContourAreas;
|
bool showContourAreas;
|
||||||
bool checkClosedContour;
|
bool checkClosedContour;
|
||||||
|
bool turntableNav;
|
||||||
bool automaticLineConstraints;
|
bool automaticLineConstraints;
|
||||||
bool showToolbar;
|
bool showToolbar;
|
||||||
Platform::Path screenshotFile;
|
Platform::Path screenshotFile;
|
||||||
|
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 ScreenChangeTurntableNav(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);
|
||||||
|
Loading…
Reference in New Issue
Block a user