Implement turntable (SketchUp-like) mouse navigation.
parent
c2c26e95ad
commit
e67f967933
|
@ -46,7 +46,7 @@ New export/import features:
|
|||
exported. This format allows to easily hack on triangle mesh data created
|
||||
in SolveSpace, supports colour information and is more space efficient than
|
||||
most other formats.
|
||||
* Export 2d section: custom styled entities that lie in the same
|
||||
* Export 2d section: custom styled entities that lie in the same
|
||||
plane as the exported section are included.
|
||||
|
||||
New rendering features:
|
||||
|
@ -68,6 +68,7 @@ New measurement/analysis features:
|
|||
Other new features:
|
||||
* New command-line interface, for batch exporting and more.
|
||||
* 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,
|
||||
"view → set to full scale".
|
||||
* 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);
|
||||
}
|
||||
|
||||
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) {
|
||||
SS.showContourAreas = !SS.showContourAreas;
|
||||
SS.GW.Invalidate();
|
||||
|
@ -306,13 +315,14 @@ void TextWindow::ShowConfiguration() {
|
|||
Printf(false, " %Fd%f%Ll%s check sketch for closed contour%E",
|
||||
&ScreenChangeCheckClosedContour,
|
||||
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",
|
||||
&ScreenChangeShowContourAreas,
|
||||
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, "%Ft autosave interval (in minutes)%E");
|
||||
Printf(false, "%Ba %d %Fl%Ll%f[change]%E",
|
||||
|
|
|
@ -427,6 +427,21 @@ void GraphicsWindow::AnimateOntoWorkplane() {
|
|||
|
||||
Entity *w = SK.GetEntity(ActiveWorkplane());
|
||||
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);
|
||||
|
||||
// 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)) {
|
||||
double s = 0.3*(PI/180)*scale; // degrees per pixel
|
||||
projRight = orig.projRight.RotatedAbout(orig.projUp, -s*dx);
|
||||
projUp = orig.projUp.RotatedAbout(orig.projRight, s*dy);
|
||||
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);
|
||||
projUp = orig.projUp.RotatedAbout(orig.projRight, s * dy);
|
||||
}
|
||||
|
||||
NormalizeProjectionVectors();
|
||||
} else if(ctrlDown) {
|
||||
|
|
|
@ -68,6 +68,8 @@ void SolveSpaceUI::Init() {
|
|||
fixExportColors = settings->ThawBool("FixExportColors", true);
|
||||
// Draw back faces of triangles (when mesh is leaky/self-intersecting)
|
||||
drawBackFaces = settings->ThawBool("DrawBackFaces", true);
|
||||
// Use turntable mouse navigation
|
||||
turntableNav = settings->ThawBool("TurntableNav", false);
|
||||
// Check that contours are closed and not self-intersecting
|
||||
checkClosedContour = settings->ThawBool("CheckClosedContour", true);
|
||||
// Enable automatic constrains for lines
|
||||
|
@ -243,6 +245,8 @@ void SolveSpaceUI::Exit() {
|
|||
settings->FreezeBool("ShowContourAreas", showContourAreas);
|
||||
// Check that contours are closed and not self-intersecting
|
||||
settings->FreezeBool("CheckClosedContour", checkClosedContour);
|
||||
// Use turntable mouse navigation
|
||||
settings->FreezeBool("TurntableNav", turntableNav);
|
||||
// Enable automatic constrains for lines
|
||||
settings->FreezeBool("AutomaticLineConstraints", automaticLineConstraints);
|
||||
// Export shaded triangles in a 2d view
|
||||
|
|
|
@ -324,7 +324,7 @@ class StepFileWriter {
|
|||
public:
|
||||
void ExportSurfacesTo(const Platform::Path &filename);
|
||||
void WriteHeader();
|
||||
void WriteProductHeader();
|
||||
void WriteProductHeader();
|
||||
int ExportCurve(SBezier *sb);
|
||||
int ExportCurveLoop(SBezierLoop *loop, bool inner);
|
||||
void ExportSurface(SSurface *ss, SBezierList *sbl);
|
||||
|
@ -590,6 +590,7 @@ public:
|
|||
bool drawBackFaces;
|
||||
bool showContourAreas;
|
||||
bool checkClosedContour;
|
||||
bool turntableNav;
|
||||
bool automaticLineConstraints;
|
||||
bool showToolbar;
|
||||
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 ScreenChangeShowContourAreas(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 ScreenChangePwlCurves(int link, uint32_t v);
|
||||
static void ScreenChangeCanvasSizeAuto(int link, uint32_t v);
|
||||
|
|
Loading…
Reference in New Issue