Added shortcut to toggle the grid.

This commit is contained in:
Leonardo Zide 2020-12-23 19:10:54 -08:00
parent 95bf7e43ff
commit 72bb41e8aa
6 changed files with 25 additions and 0 deletions

View file

@ -61,6 +61,7 @@ public:
quint32 mFadeStepsColor; quint32 mFadeStepsColor;
bool mHighlightNewParts; bool mHighlightNewParts;
quint32 mHighlightNewPartsColor; quint32 mHighlightNewPartsColor;
bool mGridEnabled = true;
bool mDrawGridStuds; bool mDrawGridStuds;
quint32 mGridStudColor; quint32 mGridStudColor;
bool mDrawGridLines; bool mDrawGridLines;

View file

@ -1137,6 +1137,13 @@ const lcCommand gCommands[] =
QT_TRANSLATE_NOOP("Status", "Toggle axis icon"), 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 // LC_VIEW_FADE_PREVIOUS_STEPS
{ {
QT_TRANSLATE_NOOP("Action", "View.FadePreviousSteps"), QT_TRANSLATE_NOOP("Action", "View.FadePreviousSteps"),

View file

@ -178,6 +178,7 @@ enum lcCommandId
LC_VIEW_PROJECTION_LAST = LC_VIEW_PROJECTION_ORTHO, LC_VIEW_PROJECTION_LAST = LC_VIEW_PROJECTION_ORTHO,
LC_VIEW_TOGGLE_VIEW_SPHERE, LC_VIEW_TOGGLE_VIEW_SPHERE,
LC_VIEW_TOGGLE_AXIS_ICON, LC_VIEW_TOGGLE_AXIS_ICON,
LC_VIEW_TOGGLE_GRID,
LC_VIEW_FADE_PREVIOUS_STEPS, LC_VIEW_FADE_PREVIOUS_STEPS,
LC_PIECE_INSERT, LC_PIECE_INSERT,
LC_PIECE_DELETE, LC_PIECE_DELETE,

View file

@ -1370,6 +1370,13 @@ void lcMainWindow::ToggleAxisIcon()
lcGLWidget::UpdateAllViews(); lcGLWidget::UpdateAllViews();
} }
void lcMainWindow::ToggleGrid()
{
lcGetPreferences().mGridEnabled = !lcGetPreferences().mGridEnabled;
lcGLWidget::UpdateAllViews();
}
void lcMainWindow::ToggleFadePreviousSteps() void lcMainWindow::ToggleFadePreviousSteps()
{ {
lcGetPreferences().mFadeSteps = !lcGetPreferences().mFadeSteps; lcGetPreferences().mFadeSteps = !lcGetPreferences().mFadeSteps;
@ -2843,6 +2850,10 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
ToggleAxisIcon(); ToggleAxisIcon();
break; break;
case LC_VIEW_TOGGLE_GRID:
ToggleGrid();
break;
case LC_VIEW_FADE_PREVIOUS_STEPS: case LC_VIEW_FADE_PREVIOUS_STEPS:
ToggleFadePreviousSteps(); ToggleFadePreviousSteps();
break; break;

View file

@ -301,6 +301,7 @@ public:
void SetSelectionMode(lcSelectionMode SelectionMode); void SetSelectionMode(lcSelectionMode SelectionMode);
void ToggleViewSphere(); void ToggleViewSphere();
void ToggleAxisIcon(); void ToggleAxisIcon();
void ToggleGrid();
void ToggleFadePreviousSteps(); void ToggleFadePreviousSteps();
void NewProject(); void NewProject();

View file

@ -1390,9 +1390,13 @@ void View::DrawRotateViewOverlay()
void View::DrawGrid() void View::DrawGrid()
{ {
const lcPreferences& Preferences = lcGetPreferences(); const lcPreferences& Preferences = lcGetPreferences();
if (!Preferences.mDrawGridStuds && !Preferences.mDrawGridLines) if (!Preferences.mDrawGridStuds && !Preferences.mDrawGridLines)
return; return;
if (!Preferences.mGridEnabled)
return;
const int Spacing = lcMax(Preferences.mGridLineSpacing, 1); const int Spacing = lcMax(Preferences.mGridLineSpacing, 1);
int MinX, MaxX, MinY, MaxY; int MinX, MaxX, MinY, MaxY;
lcVector3 Min(FLT_MAX, FLT_MAX, FLT_MAX), Max(-FLT_MAX, -FLT_MAX, -FLT_MAX); lcVector3 Min(FLT_MAX, FLT_MAX, FLT_MAX), Max(-FLT_MAX, -FLT_MAX, -FLT_MAX);