Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #123: implement turntable mouse navigation #144

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
f6fa135
Issue #123: implement turntable mouse navigation along with config ch…
dynamodan Dec 29, 2016
d11ba14
Issue #123: correct checkTurntableNav variable naming, minor coding s…
dynamodan Dec 30, 2016
fa482fc
Issue #123: correct tabs to spaces per style guide
dynamodan Dec 31, 2016
9ad1cbe
Issue #123: make Z axis the vertical axis for turntable rotation, ins…
dynamodan Jan 9, 2017
048d5b3
Just merging to stay up to date with upstream.
dynamodan Jan 12, 2017
bf7d844
Merge branch 'master' of github.com:solvespace/solvespace
dynamodan Jan 14, 2017
fc31c31
Issue #123: fix a bug affecting horizon tilt when facing toward Y
dynamodan Jan 14, 2017
f5466c5
Merge branch 'master' of github.com:solvespace/solvespace
dynamodan Jan 17, 2017
48de924
Merge branch 'master' of github.com:solvespace/solvespace
dynamodan Jan 24, 2017
9d55b0b
Issue #123: Keep Z pointing vertical when animating onto workplane
dynamodan Jan 24, 2017
5f78905
Merge branch 'master' of github.com:solvespace/solvespace
dynamodan Feb 16, 2017
d3d3a62
Merge branch 'master' of github.com:solvespace/solvespace
dynamodan Mar 7, 2017
2a2b5e4
Merge branch 'master' of github.com:solvespace/solvespace
dynamodan Apr 21, 2017
2e2f9d5
Merge branch 'master' of github.com:solvespace/solvespace
dynamodan Nov 3, 2017
4b30642
Merge branch 'master' of github.com:solvespace/solvespace
dynamodan Jul 12, 2018
17c37df
Bring turntable changes up to date with current
dynamodan Apr 4, 2019
5631967
keep extlib/libdxfrw folder
dynamodan Apr 4, 2019
39851ba
libdxfrw re-added as submodule
dynamodan Apr 4, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/confscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,23 @@ void TextWindow::ScreenChangeBackFaces(int link, uint32_t v) {
InvalidateGraphics();
}

void TextWindow::ScreenChangeTurntableNav(int link, uint32_t v) {
SS.turntableNav = !SS.turntableNav;

// if turntable nav is being toggled to ON, align view so Z is vertical
if(SS.turntableNav) {
SS.GW.AnimateOnto(
Quaternion::From(
Vector::From(1,0,0),
Vector::From(0,1,0)
),
SS.GW.offset
);
}

InvalidateGraphics(); // not sure if this is needed after the AnimateOnto, but hey
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, AnimateOnto implies InvalidateGraphics.

}

void TextWindow::ScreenChangeCheckClosedContour(int link, uint32_t v) {
SS.checkClosedContour = !SS.checkClosedContour;
InvalidateGraphics();
Expand Down Expand Up @@ -297,6 +314,9 @@ 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 use turntable mouse navigation%E",
&ScreenChangeTurntableNav,
SS.turntableNav ? CHECK_TRUE : CHECK_FALSE);

Printf(false, "");
Printf(false, "%Ft autosave interval (in minutes)%E");
Expand Down
12 changes: 10 additions & 2 deletions src/mouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,16 @@ 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) {
projRight = orig.projRight.RotatedAbout(Vector::From(0, 1, 0), -s*dx);
projUp = orig.projUp.RotatedAbout( // lock the Z to vertical
Vector::From(orig.projRight.x, orig.projRight.y, 0),
s*dy
);
} else {
projRight = orig.projRight.RotatedAbout(orig.projUp, -s*dx);
projUp = orig.projUp.RotatedAbout(orig.projRight, s*dy);
}

NormalizeProjectionVectors();
} else if(ctrlDown) {
Expand Down
4 changes: 4 additions & 0 deletions src/solvespace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ void SolveSpaceUI::Init() {
drawBackFaces = CnfThawBool(true, "DrawBackFaces");
// Check that contours are closed and not self-intersecting
checkClosedContour = CnfThawBool(true, "CheckClosedContour");
// Use turntable mouse navigation
turntableNav = CnfThawBool(false, "TurntableNav");
// Export shaded triangles in a 2d view
exportShadedTriangles = CnfThawBool(true, "ExportShadedTriangles");
// Export pwl curves (instead of exact) always
Expand Down Expand Up @@ -188,6 +190,8 @@ void SolveSpaceUI::Exit() {
CnfFreezeBool(drawBackFaces, "DrawBackFaces");
// Check that contours are closed and not self-intersecting
CnfFreezeBool(checkClosedContour, "CheckClosedContour");
// Use turntable mouse navigation
CnfFreezeBool(turntableNav, "TurntableNav");
// Export shaded triangles in a 2d view
CnfFreezeBool(exportShadedTriangles, "ExportShadedTriangles");
// Export pwl curves (instead of exact) always
Expand Down
5 changes: 3 additions & 2 deletions src/solvespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ class StepFileWriter {
public:
void ExportSurfacesTo(const std::string &filename);
void WriteHeader();
void WriteProductHeader();
void WriteProductHeader();
int ExportCurve(SBezier *sb);
int ExportCurveLoop(SBezierLoop *loop, bool inner);
void ExportSurface(SSurface *ss, SBezierList *sbl);
Expand Down Expand Up @@ -723,6 +723,7 @@ class SolveSpaceUI {
bool fixExportColors;
bool drawBackFaces;
bool checkClosedContour;
bool turntableNav;
bool showToolbar;
RgbaColor backgroundColor;
bool exportShadedTriangles;
Expand Down Expand Up @@ -804,7 +805,7 @@ class SolveSpaceUI {
Style s;
} sv;
static void MenuFile(Command id);
bool Autosave();
bool Autosave();
void RemoveAutosave();
bool GetFilenameAndSave(bool saveAs);
bool OkayToStartNewFile();
Expand Down
1 change: 1 addition & 0 deletions src/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ class TextWindow {
static void ScreenChangeFixExportColors(int link, uint32_t v);
static void ScreenChangeBackFaces(int link, uint32_t v);
static void ScreenChangeCheckClosedContour(int link, uint32_t v);
static void ScreenChangeTurntableNav(int link, uint32_t v);
static void ScreenChangePwlCurves(int link, uint32_t v);
static void ScreenChangeCanvasSizeAuto(int link, uint32_t v);
static void ScreenChangeCanvasSize(int link, uint32_t v);
Expand Down