diff --git a/common/lc_application.h b/common/lc_application.h index 744043f6..7e320277 100644 --- a/common/lc_application.h +++ b/common/lc_application.h @@ -61,6 +61,7 @@ public: quint32 mFadeStepsColor; bool mHighlightNewParts; quint32 mHighlightNewPartsColor; + bool mGridEnabled = true; bool mDrawGridStuds; quint32 mGridStudColor; bool mDrawGridLines; diff --git a/common/lc_commands.cpp b/common/lc_commands.cpp index 831cb3b7..1a4c2d04 100644 --- a/common/lc_commands.cpp +++ b/common/lc_commands.cpp @@ -1137,6 +1137,13 @@ const lcCommand gCommands[] = QT_TRANSLATE_NOOP("Status", "Toggle axis icon"), "" }, + // LC_VIEW_TOGGLE_GRID + { + QT_TRANSLATE_NOOP("Action", "View.ToggleGrid"), + QT_TRANSLATE_NOOP("Menu", "Grid"), + QT_TRANSLATE_NOOP("Status", "Toggle grid"), + "" + }, // LC_VIEW_FADE_PREVIOUS_STEPS { QT_TRANSLATE_NOOP("Action", "View.FadePreviousSteps"), diff --git a/common/lc_commands.h b/common/lc_commands.h index cf4d978a..13bcec6c 100644 --- a/common/lc_commands.h +++ b/common/lc_commands.h @@ -178,6 +178,7 @@ enum lcCommandId LC_VIEW_PROJECTION_LAST = LC_VIEW_PROJECTION_ORTHO, LC_VIEW_TOGGLE_VIEW_SPHERE, LC_VIEW_TOGGLE_AXIS_ICON, + LC_VIEW_TOGGLE_GRID, LC_VIEW_FADE_PREVIOUS_STEPS, LC_PIECE_INSERT, LC_PIECE_DELETE, diff --git a/common/lc_mainwindow.cpp b/common/lc_mainwindow.cpp index fecacf97..72f9cd22 100644 --- a/common/lc_mainwindow.cpp +++ b/common/lc_mainwindow.cpp @@ -1370,6 +1370,13 @@ void lcMainWindow::ToggleAxisIcon() lcGLWidget::UpdateAllViews(); } +void lcMainWindow::ToggleGrid() +{ + lcGetPreferences().mGridEnabled = !lcGetPreferences().mGridEnabled; + + lcGLWidget::UpdateAllViews(); +} + void lcMainWindow::ToggleFadePreviousSteps() { lcGetPreferences().mFadeSteps = !lcGetPreferences().mFadeSteps; @@ -2843,6 +2850,10 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId) ToggleAxisIcon(); break; + case LC_VIEW_TOGGLE_GRID: + ToggleGrid(); + break; + case LC_VIEW_FADE_PREVIOUS_STEPS: ToggleFadePreviousSteps(); break; diff --git a/common/lc_mainwindow.h b/common/lc_mainwindow.h index 0591857d..96d92818 100644 --- a/common/lc_mainwindow.h +++ b/common/lc_mainwindow.h @@ -301,6 +301,7 @@ public: void SetSelectionMode(lcSelectionMode SelectionMode); void ToggleViewSphere(); void ToggleAxisIcon(); + void ToggleGrid(); void ToggleFadePreviousSteps(); void NewProject(); diff --git a/common/view.cpp b/common/view.cpp index 304ee601..e3c31ab3 100644 --- a/common/view.cpp +++ b/common/view.cpp @@ -1390,9 +1390,13 @@ void View::DrawRotateViewOverlay() void View::DrawGrid() { const lcPreferences& Preferences = lcGetPreferences(); + if (!Preferences.mDrawGridStuds && !Preferences.mDrawGridLines) return; + if (!Preferences.mGridEnabled) + return; + const int Spacing = lcMax(Preferences.mGridLineSpacing, 1); int MinX, MaxX, MinY, MaxY; lcVector3 Min(FLT_MAX, FLT_MAX, FLT_MAX), Max(-FLT_MAX, -FLT_MAX, -FLT_MAX);