From 366018ee8cc45e73f7a8d805ddc7b1a5b21d240e Mon Sep 17 00:00:00 2001 From: Leonardo Date: Fri, 4 Dec 2020 15:38:49 -0800 Subject: [PATCH] Scoped lcTool. --- common/lc_commands.cpp | 34 +++--- common/lc_commands.h | 36 +++--- common/lc_mainwindow.cpp | 34 +++--- common/lc_model.cpp | 32 ++--- common/lc_previewwidget.cpp | 24 ++-- common/lc_shortcuts.cpp | 37 +++--- common/lc_shortcuts.h | 7 +- common/view.cpp | 218 +++++++++++++++++------------------ qt/lc_qpreferencesdialog.cpp | 4 +- 9 files changed, 215 insertions(+), 211 deletions(-) diff --git a/common/lc_commands.cpp b/common/lc_commands.cpp index e54fa87e..6a9548c3 100644 --- a/common/lc_commands.cpp +++ b/common/lc_commands.cpp @@ -1659,23 +1659,23 @@ lcCommand gCommands[LC_NUM_COMMANDS] = static_assert(sizeof(gCommands)/sizeof(gCommands[0]) == LC_NUM_COMMANDS, "Array size mismatch."); -const char* gToolNames[LC_NUM_TOOLS] = +const char* gToolNames[static_cast(lcTool::Count)] = { - QT_TRANSLATE_NOOP("Mouse", "NewPiece"), // LC_TOOL_INSERT - QT_TRANSLATE_NOOP("Mouse", "NewPointLight"), // LC_TOOL_LIGHT - QT_TRANSLATE_NOOP("Mouse", "NewSpotLight"), // LC_TOOL_SPOTLIGHT - QT_TRANSLATE_NOOP("Mouse", "NewCamera"), // LC_TOOL_CAMERA - QT_TRANSLATE_NOOP("Mouse", "Select"), // LC_TOOL_SELECT - QT_TRANSLATE_NOOP("Mouse", "Move"), // LC_TOOL_MOVE - QT_TRANSLATE_NOOP("Mouse", "Rotate"), // LC_TOOL_ROTATE - QT_TRANSLATE_NOOP("Mouse", "Delete"), // LC_TOOL_ERASER - QT_TRANSLATE_NOOP("Mouse", "Paint"), // LC_TOOL_PAINT - QT_TRANSLATE_NOOP("Mouse", "ColorPicker"), // LC_TOOL_COLOR_PICKER - QT_TRANSLATE_NOOP("Mouse", "Zoom"), // LC_TOOL_ZOOM - QT_TRANSLATE_NOOP("Mouse", "Pan"), // LC_TOOL_PAN - QT_TRANSLATE_NOOP("Mouse", "Orbit"), // LC_TOOL_ROTATE_VIEW - QT_TRANSLATE_NOOP("Mouse", "Roll"), // LC_TOOL_ROLL - QT_TRANSLATE_NOOP("Mouse", "ZoomRegion") // LC_TOOL_ZOOM_REGION + QT_TRANSLATE_NOOP("Mouse", "NewPiece"), // lcTool::Insert + QT_TRANSLATE_NOOP("Mouse", "NewPointLight"), // lcTool::Light + QT_TRANSLATE_NOOP("Mouse", "NewSpotLight"), // lcTool::SpotLight + QT_TRANSLATE_NOOP("Mouse", "NewCamera"), // lcTool::Camera + QT_TRANSLATE_NOOP("Mouse", "Select"), // lcTool::Select + QT_TRANSLATE_NOOP("Mouse", "Move"), // lcTool::Move + QT_TRANSLATE_NOOP("Mouse", "Rotate"), // lcTool::Rotate + QT_TRANSLATE_NOOP("Mouse", "Delete"), // lcTool::Eraser + QT_TRANSLATE_NOOP("Mouse", "Paint"), // lcTool::Paint + QT_TRANSLATE_NOOP("Mouse", "ColorPicker"), // lcTool::ColorPicker + QT_TRANSLATE_NOOP("Mouse", "Zoom"), // lcTool::Zoom + QT_TRANSLATE_NOOP("Mouse", "Pan"), // lcTool::Pan + QT_TRANSLATE_NOOP("Mouse", "Orbit"), // lcTool::RotateView + QT_TRANSLATE_NOOP("Mouse", "Roll"), // lcTool::Roll + QT_TRANSLATE_NOOP("Mouse", "ZoomRegion") // lcTool::ZoomRegion }; -static_assert(LC_ARRAY_COUNT(gToolNames) == LC_NUM_TOOLS, "Array size mismatch."); +static_assert(LC_ARRAY_COUNT(gToolNames) == static_cast(lcTool::Count), "Array size mismatch."); diff --git a/common/lc_commands.h b/common/lc_commands.h index f4a2a099..acc56cf2 100644 --- a/common/lc_commands.h +++ b/common/lc_commands.h @@ -267,25 +267,25 @@ struct lcCommand extern lcCommand gCommands[LC_NUM_COMMANDS]; -enum lcTool +enum class lcTool { - LC_TOOL_INSERT, - LC_TOOL_LIGHT, - LC_TOOL_SPOTLIGHT, - LC_TOOL_CAMERA, - LC_TOOL_SELECT, - LC_TOOL_MOVE, - LC_TOOL_ROTATE, - LC_TOOL_ERASER, - LC_TOOL_PAINT, - LC_TOOL_COLOR_PICKER, - LC_TOOL_ZOOM, - LC_TOOL_PAN, - LC_TOOL_ROTATE_VIEW, - LC_TOOL_ROLL, - LC_TOOL_ZOOM_REGION, - LC_NUM_TOOLS + Insert, + Light, + SpotLight, + Camera, + Select, + Move, + Rotate, + Eraser, + Paint, + ColorPicker, + Zoom, + Pan, + RotateView, + Roll, + ZoomRegion, + Count }; -extern const char* gToolNames[LC_NUM_TOOLS]; +extern const char* gToolNames[static_cast(lcTool::Count)]; diff --git a/common/lc_mainwindow.cpp b/common/lc_mainwindow.cpp index 8dd0c410..1897ffb1 100644 --- a/common/lc_mainwindow.cpp +++ b/common/lc_mainwindow.cpp @@ -95,7 +95,7 @@ lcMainWindow::lcMainWindow() mTransformType = lcTransformType::RelativeTranslation; mColorIndex = lcGetColorIndex(7); - mTool = LC_TOOL_SELECT; + mTool = lcTool::Select; mAddKeys = false; mMoveSnapEnabled = true; mAngleSnapEnabled = true; @@ -1704,7 +1704,7 @@ void lcMainWindow::SetTool(lcTool Tool) { mTool = Tool; - QAction* Action = mActions[LC_EDIT_ACTION_FIRST + mTool]; + QAction* Action = mActions[LC_EDIT_ACTION_FIRST + static_cast(mTool)]; if (Action) Action->setChecked(true); @@ -3303,63 +3303,63 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId) break; case LC_EDIT_ACTION_SELECT: - SetTool(LC_TOOL_SELECT); + SetTool(lcTool::Select); break; case LC_EDIT_ACTION_INSERT: - SetTool(LC_TOOL_INSERT); + SetTool(lcTool::Insert); break; case LC_EDIT_ACTION_LIGHT: - SetTool(LC_TOOL_LIGHT); + SetTool(lcTool::Light); break; case LC_EDIT_ACTION_SPOTLIGHT: - SetTool(LC_TOOL_SPOTLIGHT); + SetTool(lcTool::SpotLight); break; case LC_EDIT_ACTION_CAMERA: - SetTool(LC_TOOL_CAMERA); + SetTool(lcTool::Camera); break; case LC_EDIT_ACTION_MOVE: - SetTool(LC_TOOL_MOVE); + SetTool(lcTool::Move); break; case LC_EDIT_ACTION_ROTATE: - SetTool(LC_TOOL_ROTATE); + SetTool(lcTool::Rotate); break; case LC_EDIT_ACTION_DELETE: - SetTool(LC_TOOL_ERASER); + SetTool(lcTool::Eraser); break; case LC_EDIT_ACTION_PAINT: - SetTool(LC_TOOL_PAINT); + SetTool(lcTool::Paint); break; case LC_EDIT_ACTION_COLOR_PICKER: - SetTool(LC_TOOL_COLOR_PICKER); + SetTool(lcTool::ColorPicker); break; case LC_EDIT_ACTION_ZOOM: - SetTool(LC_TOOL_ZOOM); + SetTool(lcTool::Zoom); break; case LC_EDIT_ACTION_ZOOM_REGION: - SetTool(LC_TOOL_ZOOM_REGION); + SetTool(lcTool::ZoomRegion); break; case LC_EDIT_ACTION_PAN: - SetTool(LC_TOOL_PAN); + SetTool(lcTool::Pan); break; case LC_EDIT_ACTION_ROTATE_VIEW: - SetTool(LC_TOOL_ROTATE_VIEW); + SetTool(lcTool::RotateView); break; case LC_EDIT_ACTION_ROLL: - SetTool(LC_TOOL_ROLL); + SetTool(lcTool::Roll); break; case LC_EDIT_CANCEL: diff --git a/common/lc_model.cpp b/common/lc_model.cpp index 4e4673ed..0d0d4c11 100644 --- a/common/lc_model.cpp +++ b/common/lc_model.cpp @@ -3912,60 +3912,60 @@ void lcModel::EndMouseTool(lcTool Tool, bool Accept) switch (Tool) { - case LC_TOOL_INSERT: - case LC_TOOL_LIGHT: + case lcTool::Insert: + case lcTool::Light: break; - case LC_TOOL_SPOTLIGHT: + case lcTool::SpotLight: SaveCheckpoint(tr("New SpotLight")); break; - case LC_TOOL_CAMERA: + case lcTool::Camera: if (!mIsPreview) gMainWindow->UpdateCameraMenu(); SaveCheckpoint(tr("New Camera")); break; - case LC_TOOL_SELECT: + case lcTool::Select: break; - case LC_TOOL_MOVE: + case lcTool::Move: SaveCheckpoint(tr("Move")); break; - case LC_TOOL_ROTATE: + case lcTool::Rotate: SaveCheckpoint(tr("Rotate")); break; - case LC_TOOL_ERASER: - case LC_TOOL_PAINT: - case LC_TOOL_COLOR_PICKER: + case lcTool::Eraser: + case lcTool::Paint: + case lcTool::ColorPicker: break; - case LC_TOOL_ZOOM: + case lcTool::Zoom: if (!mIsPreview && !gMainWindow->GetActiveView()->GetCamera()->IsSimple()) SaveCheckpoint(tr("Zoom")); break; - case LC_TOOL_PAN: + case lcTool::Pan: if (!mIsPreview && !gMainWindow->GetActiveView()->GetCamera()->IsSimple()) SaveCheckpoint(tr("Pan")); break; - case LC_TOOL_ROTATE_VIEW: + case lcTool::RotateView: if (!mIsPreview && !gMainWindow->GetActiveView()->GetCamera()->IsSimple()) SaveCheckpoint(tr("Orbit")); break; - case LC_TOOL_ROLL: + case lcTool::Roll: if (!mIsPreview && !gMainWindow->GetActiveView()->GetCamera()->IsSimple()) SaveCheckpoint(tr("Roll")); break; - case LC_TOOL_ZOOM_REGION: + case lcTool::ZoomRegion: break; - case LC_NUM_TOOLS: + case lcTool::Count: break; } } diff --git a/common/lc_previewwidget.cpp b/common/lc_previewwidget.cpp index 5986f2b2..b6ed8b28 100644 --- a/common/lc_previewwidget.cpp +++ b/common/lc_previewwidget.cpp @@ -83,7 +83,7 @@ lcPreviewWidget::lcPreviewWidget() : mLoader(new Project(true/*IsPreview*/)), mViewSphere(this/*Preview*/) { - mTool = LC_TOOL_SELECT; + mTool = lcTool::Select; mTrackTool = LC_TRACKTOOL_NONE; mTrackButton = lcTrackButton::None; @@ -278,9 +278,9 @@ lcTool lcPreviewWidget::GetCurrentTool() const { const lcTool ToolFromTrackTool[] = { - LC_TOOL_SELECT, // LC_TRACKTOOL_NONE - LC_TOOL_PAN, // LC_TRACKTOOL_PAN - LC_TOOL_ROTATE_VIEW, // LC_TRACKTOOL_ORBIT_XY + lcTool::Select, // LC_TRACKTOOL_NONE + lcTool::Pan, // LC_TRACKTOOL_PAN + lcTool::RotateView, // LC_TRACKTOOL_ORBIT_XY }; return ToolFromTrackTool[mTrackTool]; @@ -297,15 +297,15 @@ void lcPreviewWidget::StartTracking(lcTrackButton TrackButton) switch (Tool) { - case LC_TOOL_SELECT: + case lcTool::Select: break; - case LC_TOOL_PAN: - case LC_TOOL_ROTATE_VIEW: + case lcTool::Pan: + case lcTool::RotateView: ActiveModel->BeginMouseTool(); break; - case LC_NUM_TOOLS: + case lcTool::Count: default: break; } @@ -323,15 +323,15 @@ void lcPreviewWidget::StopTracking(bool Accept) switch (Tool) { - case LC_TOOL_SELECT: + case lcTool::Select: break; - case LC_TOOL_PAN: - case LC_TOOL_ROTATE_VIEW: + case lcTool::Pan: + case lcTool::RotateView: ActiveModel->EndMouseTool(Tool, Accept); break; - case LC_NUM_TOOLS: + case lcTool::Count: default: break; } diff --git a/common/lc_shortcuts.cpp b/common/lc_shortcuts.cpp index 20e91d9b..3e1c8b41 100644 --- a/common/lc_shortcuts.cpp +++ b/common/lc_shortcuts.cpp @@ -132,23 +132,26 @@ void lcMouseShortcuts::Reset() { memset(mShortcuts, 0, sizeof(mShortcuts)); - mShortcuts[LC_TOOL_ROTATE_VIEW].Modifiers1 = Qt::AltModifier; - mShortcuts[LC_TOOL_ROTATE_VIEW].Button1 = Qt::LeftButton; - mShortcuts[LC_TOOL_ROTATE_VIEW].Modifiers2 = Qt::NoModifier; - mShortcuts[LC_TOOL_ROTATE_VIEW].Button2 = Qt::RightButton; + lcToolShortcut& RotateViewShortcut = mShortcuts[static_cast(lcTool::RotateView)]; + RotateViewShortcut.Modifiers1 = Qt::AltModifier; + RotateViewShortcut.Button1 = Qt::LeftButton; + RotateViewShortcut.Modifiers2 = Qt::NoModifier; + RotateViewShortcut.Button2 = Qt::RightButton; + lcToolShortcut& PanShortcut = mShortcuts[static_cast(lcTool::Pan)]; #if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) - mShortcuts[LC_TOOL_PAN].Modifiers1 = Qt::AltModifier; - mShortcuts[LC_TOOL_PAN].Button1 = Qt::MiddleButton; - mShortcuts[LC_TOOL_PAN].Modifiers2 = Qt::ShiftModifier; - mShortcuts[LC_TOOL_PAN].Button2 = Qt::RightButton; + PanShortcut.Modifiers1 = Qt::AltModifier; + PanShortcut.Button1 = Qt::MiddleButton; + PanShortcut.Modifiers2 = Qt::ShiftModifier; + PanShortcut.Button2 = Qt::RightButton; #else - mShortcuts[LC_TOOL_PAN].Modifiers1 = Qt::ShiftModifier; - mShortcuts[LC_TOOL_PAN].Button1 = Qt::RightButton; + PanShortcut.Modifiers1 = Qt::ShiftModifier; + PanShortcut.Button1 = Qt::RightButton; #endif - mShortcuts[LC_TOOL_ZOOM].Modifiers1 = Qt::AltModifier; - mShortcuts[LC_TOOL_ZOOM].Button1 = Qt::RightButton; + lcToolShortcut& ZoomShortcut = mShortcuts[static_cast(lcTool::Zoom)]; + ZoomShortcut.Modifiers1 = Qt::AltModifier; + ZoomShortcut.Button1 = Qt::RightButton; } bool lcMouseShortcuts::Save(const QString& FileName) @@ -176,7 +179,7 @@ bool lcMouseShortcuts::Save(QStringList& Shortcuts) { Shortcuts.clear(); - for (int ToolIdx = 0; ToolIdx < LC_NUM_TOOLS; ToolIdx++) + for (int ToolIdx = 0; ToolIdx < static_cast(lcTool::Count); ToolIdx++) { int ButtonIndex1 = 0; for (int Button1 = mShortcuts[ToolIdx].Button1; Button1; Button1 >>= 1) @@ -230,11 +233,11 @@ bool lcMouseShortcuts::Load(const QStringList& FullShortcuts) QString Key = FullShortcut.left(Equals); int ToolIdx; - for (ToolIdx = 0; ToolIdx < LC_NUM_TOOLS; ToolIdx++) + for (ToolIdx = 0; ToolIdx < static_cast(lcTool::Count); ToolIdx++) if (Key == gToolNames[ToolIdx]) break; - if (ToolIdx == LC_NUM_TOOLS) + if (ToolIdx == static_cast(lcTool::Count)) continue; QStringList Shortcuts = FullShortcut.mid(Equals + 1).split(','); @@ -270,9 +273,9 @@ bool lcMouseShortcuts::Load(const QStringList& FullShortcuts) lcTool lcMouseShortcuts::GetTool(Qt::MouseButton Button, Qt::KeyboardModifiers Modifiers) const { - for (int ToolIdx = 0; ToolIdx < LC_NUM_TOOLS; ToolIdx++) + for (int ToolIdx = 0; ToolIdx < static_cast(lcTool::Count); ToolIdx++) if ((mShortcuts[ToolIdx].Button1 == Button && mShortcuts[ToolIdx].Modifiers1 == Modifiers) || (mShortcuts[ToolIdx].Button2 == Button && mShortcuts[ToolIdx].Modifiers2 == Modifiers)) return (lcTool)ToolIdx; - return LC_NUM_TOOLS; + return lcTool::Count; } diff --git a/common/lc_shortcuts.h b/common/lc_shortcuts.h index a0e159cf..49f55db0 100644 --- a/common/lc_shortcuts.h +++ b/common/lc_shortcuts.h @@ -31,14 +31,15 @@ public: lcTool GetTool(Qt::MouseButton Button, Qt::KeyboardModifiers Modifiers) const; - struct + struct lcToolShortcut { Qt::KeyboardModifiers Modifiers1; Qt::MouseButton Button1; Qt::KeyboardModifiers Modifiers2; Qt::MouseButton Button2; - } - mShortcuts[LC_NUM_TOOLS]; + }; + + lcToolShortcut mShortcuts[static_cast(lcTool::Count)]; }; extern lcMouseShortcuts gMouseShortcuts; diff --git a/common/view.cpp b/common/view.cpp index 8088a234..46fcccf6 100644 --- a/common/view.cpp +++ b/common/view.cpp @@ -920,15 +920,15 @@ void View::OnDraw() lcTool Tool = gMainWindow->GetTool(); lcModel* ActiveModel = GetActiveModel(); - if ((Tool == LC_TOOL_SELECT || Tool == LC_TOOL_MOVE) && mTrackButton == lcTrackButton::None && ActiveModel->AnyObjectsSelected()) + if ((Tool == lcTool::Select || Tool == lcTool::Move) && mTrackButton == lcTrackButton::None && ActiveModel->AnyObjectsSelected()) DrawSelectMoveOverlay(); - else if (GetCurrentTool() == LC_TOOL_MOVE && mTrackButton != lcTrackButton::None) + else if (GetCurrentTool() == lcTool::Move && mTrackButton != lcTrackButton::None) DrawSelectMoveOverlay(); - else if ((Tool == LC_TOOL_ROTATE || (Tool == LC_TOOL_SELECT && mTrackButton != lcTrackButton::None && mTrackTool >= LC_TRACKTOOL_ROTATE_X && mTrackTool <= LC_TRACKTOOL_ROTATE_XYZ)) && ActiveModel->AnyPiecesSelected()) + else if ((Tool == lcTool::Rotate || (Tool == lcTool::Select && mTrackButton != lcTrackButton::None && mTrackTool >= LC_TRACKTOOL_ROTATE_X && mTrackTool <= LC_TRACKTOOL_ROTATE_XYZ)) && ActiveModel->AnyPiecesSelected()) DrawRotateOverlay(); else if ((mTrackTool == LC_TRACKTOOL_SELECT || mTrackTool == LC_TRACKTOOL_ZOOM_REGION) && mTrackButton != lcTrackButton::None) DrawSelectZoomRegionOverlay(); - else if (Tool == LC_TOOL_ROTATE_VIEW && mTrackButton == lcTrackButton::None) + else if (Tool == lcTool::RotateView && mTrackButton == lcTrackButton::None) DrawRotateViewOverlay(); mViewSphere.Draw(); @@ -1014,7 +1014,7 @@ void View::DrawSelectMoveOverlay() } } - if (gMainWindow->GetTool() == LC_TOOL_SELECT && mTrackButton == lcTrackButton::None && AnyPiecesSelected) + if (gMainWindow->GetTool() == lcTool::Select && mTrackButton == lcTrackButton::None && AnyPiecesSelected) { if (AllowedTransforms & LC_OBJECT_TRANSFORM_ROTATE_X) { @@ -1242,7 +1242,7 @@ void View::DrawRotateOverlay() } // Draw the circles. - if (gMainWindow->GetTool() == LC_TOOL_ROTATE && !HasAngle && mTrackButton == lcTrackButton::None) + if (gMainWindow->GetTool() == lcTool::Rotate && !HasAngle && mTrackButton == lcTrackButton::None) { lcMatrix44 Mat = lcMatrix44AffineInverse(mCamera->mWorldView); Mat.SetTranslation(OverlayCenter); @@ -1286,7 +1286,7 @@ void View::DrawRotateOverlay() } else { - if (gMainWindow->GetTool() != LC_TOOL_ROTATE || HasAngle || mTrackButton != lcTrackButton::None) + if (gMainWindow->GetTool() != lcTool::Rotate || HasAngle || mTrackButton != lcTrackButton::None) continue; switch (i) @@ -1328,7 +1328,7 @@ void View::DrawRotateOverlay() break; } - if (gMainWindow->GetTool() != LC_TOOL_ROTATE || HasAngle || mTrackButton != lcTrackButton::None || lcDot(ViewDir, v1 + v2) <= 0.0f) + if (gMainWindow->GetTool() != lcTool::Rotate || HasAngle || mTrackButton != lcTrackButton::None || lcDot(ViewDir, v1 + v2) <= 0.0f) { Verts[NumVerts++] = v1 * (OverlayRotateRadius * OverlayScale); Verts[NumVerts++] = v2 * (OverlayRotateRadius * OverlayScale); @@ -1801,36 +1801,36 @@ lcTool View::GetCurrentTool() const { const lcTool ToolFromTrackTool[] = { - LC_TOOL_SELECT, // LC_TRACKTOOL_NONE - LC_TOOL_INSERT, // LC_TRACKTOOL_INSERT - LC_TOOL_LIGHT, // LC_TRACKTOOL_POINTLIGHT - LC_TOOL_SPOTLIGHT, // LC_TRACKTOOL_SPOTLIGHT - LC_TOOL_CAMERA, // LC_TRACKTOOL_CAMERA - LC_TOOL_SELECT, // LC_TRACKTOOL_SELECT - LC_TOOL_MOVE, // LC_TRACKTOOL_MOVE_X - LC_TOOL_MOVE, // LC_TRACKTOOL_MOVE_Y - LC_TOOL_MOVE, // LC_TRACKTOOL_MOVE_Z - LC_TOOL_MOVE, // LC_TRACKTOOL_MOVE_XY - LC_TOOL_MOVE, // LC_TRACKTOOL_MOVE_XZ - LC_TOOL_MOVE, // LC_TRACKTOOL_MOVE_YZ - LC_TOOL_MOVE, // LC_TRACKTOOL_MOVE_XYZ - LC_TOOL_ROTATE, // LC_TRACKTOOL_ROTATE_X - LC_TOOL_ROTATE, // LC_TRACKTOOL_ROTATE_Y - LC_TOOL_ROTATE, // LC_TRACKTOOL_ROTATE_Z - LC_TOOL_ROTATE, // LC_TRACKTOOL_ROTATE_XY - LC_TOOL_ROTATE, // LC_TRACKTOOL_ROTATE_XYZ - LC_TOOL_MOVE, // LC_TRACKTOOL_SCALE_PLUS - LC_TOOL_MOVE, // LC_TRACKTOOL_SCALE_MINUS - LC_TOOL_ERASER, // LC_TRACKTOOL_ERASER - LC_TOOL_PAINT, // LC_TRACKTOOL_PAINT - LC_TOOL_COLOR_PICKER, // LC_TRACKTOOL_COLOR_PICKER - LC_TOOL_ZOOM, // LC_TRACKTOOL_ZOOM - LC_TOOL_PAN, // LC_TRACKTOOL_PAN - LC_TOOL_ROTATE_VIEW, // LC_TRACKTOOL_ORBIT_X - LC_TOOL_ROTATE_VIEW, // LC_TRACKTOOL_ORBIT_Y - LC_TOOL_ROTATE_VIEW, // LC_TRACKTOOL_ORBIT_XY - LC_TOOL_ROLL, // LC_TRACKTOOL_ROLL - LC_TOOL_ZOOM_REGION // LC_TRACKTOOL_ZOOM_REGION + lcTool::Select, // LC_TRACKTOOL_NONE + lcTool::Insert, // LC_TRACKTOOL_INSERT + lcTool::Light, // LC_TRACKTOOL_POINTLIGHT + lcTool::SpotLight, // LC_TRACKTOOL_SPOTLIGHT + lcTool::Camera, // LC_TRACKTOOL_CAMERA + lcTool::Select, // LC_TRACKTOOL_SELECT + lcTool::Move, // LC_TRACKTOOL_MOVE_X + lcTool::Move, // LC_TRACKTOOL_MOVE_Y + lcTool::Move, // LC_TRACKTOOL_MOVE_Z + lcTool::Move, // LC_TRACKTOOL_MOVE_XY + lcTool::Move, // LC_TRACKTOOL_MOVE_XZ + lcTool::Move, // LC_TRACKTOOL_MOVE_YZ + lcTool::Move, // LC_TRACKTOOL_MOVE_XYZ + lcTool::Rotate, // LC_TRACKTOOL_ROTATE_X + lcTool::Rotate, // LC_TRACKTOOL_ROTATE_Y + lcTool::Rotate, // LC_TRACKTOOL_ROTATE_Z + lcTool::Rotate, // LC_TRACKTOOL_ROTATE_XY + lcTool::Rotate, // LC_TRACKTOOL_ROTATE_XYZ + lcTool::Move, // LC_TRACKTOOL_SCALE_PLUS + lcTool::Move, // LC_TRACKTOOL_SCALE_MINUS + lcTool::Eraser, // LC_TRACKTOOL_ERASER + lcTool::Paint, // LC_TRACKTOOL_PAINT + lcTool::ColorPicker, // LC_TRACKTOOL_COLOR_PICKER + lcTool::Zoom, // LC_TRACKTOOL_ZOOM + lcTool::Pan, // LC_TRACKTOOL_PAN + lcTool::RotateView, // LC_TRACKTOOL_ORBIT_X + lcTool::RotateView, // LC_TRACKTOOL_ORBIT_Y + lcTool::RotateView, // LC_TRACKTOOL_ORBIT_XY + lcTool::Roll, // LC_TRACKTOOL_ROLL + lcTool::ZoomRegion // LC_TRACKTOOL_ZOOM_REGION }; return ToolFromTrackTool[mTrackTool]; @@ -1843,29 +1843,29 @@ lcTrackTool View::GetOverrideTrackTool(Qt::MouseButton Button) const lcTool OverrideTool = gMouseShortcuts.GetTool(Button, mInputState.Modifiers); - if (OverrideTool == LC_NUM_TOOLS) + if (OverrideTool == lcTool::Count) return LC_TRACKTOOL_NONE; - lcTrackTool TrackToolFromTool[LC_NUM_TOOLS] = + lcTrackTool TrackToolFromTool[static_cast(lcTool::Count)] = { - LC_TRACKTOOL_INSERT, // LC_TOOL_INSERT - LC_TRACKTOOL_POINTLIGHT, // LC_TOOL_LIGHT - LC_TRACKTOOL_SPOTLIGHT, // LC_TOOL_SPOTLIGHT - LC_TRACKTOOL_CAMERA, // LC_TOOL_CAMERA - LC_TRACKTOOL_SELECT, // LC_TOOL_SELECT - LC_TRACKTOOL_MOVE_XYZ, // LC_TOOL_MOVE - LC_TRACKTOOL_ROTATE_XYZ, // LC_TOOL_ROTATE - LC_TRACKTOOL_ERASER, // LC_TOOL_ERASER - LC_TRACKTOOL_PAINT, // LC_TOOL_PAINT - LC_TRACKTOOL_COLOR_PICKER, // LC_TOOL_COLOR_PICKER - LC_TRACKTOOL_ZOOM, // LC_TOOL_ZOOM - LC_TRACKTOOL_PAN, // LC_TOOL_PAN - LC_TRACKTOOL_ORBIT_XY, // LC_TOOL_ROTATE_VIEW - LC_TRACKTOOL_ROLL, // LC_TOOL_ROLL - LC_TRACKTOOL_ZOOM_REGION // LC_TOOL_ZOOM_REGION + LC_TRACKTOOL_INSERT, // lcTool::Insert + LC_TRACKTOOL_POINTLIGHT, // lcTool::Light + LC_TRACKTOOL_SPOTLIGHT, // lcTool::SpotLight + LC_TRACKTOOL_CAMERA, // lcTool::Camera + LC_TRACKTOOL_SELECT, // lcTool::Select + LC_TRACKTOOL_MOVE_XYZ, // lcTool::Move + LC_TRACKTOOL_ROTATE_XYZ, // lcTool::Rotate + LC_TRACKTOOL_ERASER, // lcTool::Eraser + LC_TRACKTOOL_PAINT, // lcTool::Paint + LC_TRACKTOOL_COLOR_PICKER, // lcTool::ColorPicker + LC_TRACKTOOL_ZOOM, // lcTool::Zoom + LC_TRACKTOOL_PAN, // lcTool::Pan + LC_TRACKTOOL_ORBIT_XY, // lcTool::RotateView + LC_TRACKTOOL_ROLL, // lcTool::Roll + LC_TRACKTOOL_ZOOM_REGION // lcTool::ZoomRegion }; - return TrackToolFromTool[OverrideTool]; + return TrackToolFromTool[static_cast(OverrideTool)]; } float View::GetOverlayScale() const @@ -1975,24 +1975,24 @@ void View::UpdateTrackTool() switch (CurrentTool) { - case LC_TOOL_INSERT: + case lcTool::Insert: NewTrackTool = LC_TRACKTOOL_INSERT; break; - case LC_TOOL_LIGHT: + case lcTool::Light: NewTrackTool = LC_TRACKTOOL_POINTLIGHT; break; - case LC_TOOL_SPOTLIGHT: + case lcTool::SpotLight: NewTrackTool = LC_TRACKTOOL_SPOTLIGHT; break; - case LC_TOOL_CAMERA: + case lcTool::Camera: NewTrackTool = LC_TRACKTOOL_CAMERA; break; - case LC_TOOL_SELECT: - case LC_TOOL_MOVE: + case lcTool::Select: + case lcTool::Move: { const float OverlayScale = GetOverlayScale(); const float OverlayMovePlaneSize = 0.5f * OverlayScale; @@ -2002,7 +2002,7 @@ void View::UpdateTrackTool() const float OverlayRotateArrowEnd = 1.5f * OverlayScale; const float OverlayScaleRadius = 0.125f; - NewTrackTool = (CurrentTool == LC_TOOL_MOVE) ? LC_TRACKTOOL_MOVE_XYZ : LC_TRACKTOOL_SELECT; + NewTrackTool = (CurrentTool == lcTool::Move) ? LC_TRACKTOOL_MOVE_XYZ : LC_TRACKTOOL_SELECT; mMouseDownPiece = nullptr; lcVector3 OverlayCenter; @@ -2074,7 +2074,7 @@ void View::UpdateTrackTool() } } - if (CurrentTool == LC_TOOL_SELECT && Proj1 > OverlayRotateArrowStart && Proj1 < OverlayRotateArrowEnd && Proj2 > OverlayRotateArrowStart && Proj2 < OverlayRotateArrowEnd && ActiveModel->AnyPiecesSelected()) + if (CurrentTool == lcTool::Select && Proj1 > OverlayRotateArrowStart && Proj1 < OverlayRotateArrowEnd && Proj2 > OverlayRotateArrowStart && Proj2 < OverlayRotateArrowEnd && ActiveModel->AnyPiecesSelected()) { lcTrackTool PlaneModes[] = { LC_TRACKTOOL_ROTATE_X, LC_TRACKTOOL_ROTATE_Y, LC_TRACKTOOL_ROTATE_Z }; @@ -2156,7 +2156,7 @@ void View::UpdateTrackTool() } } - if (CurrentTool == LC_TOOL_SELECT && NewTrackTool == LC_TRACKTOOL_SELECT && mInputState.Modifiers == Qt::NoModifier) + if (CurrentTool == lcTool::Select && NewTrackTool == LC_TRACKTOOL_SELECT && mInputState.Modifiers == Qt::NoModifier) { lcObjectSection ObjectSection = FindObjectUnderPointer(false, false); lcObject* Object = ObjectSection.Object; @@ -2175,7 +2175,7 @@ void View::UpdateTrackTool() } break; - case LC_TOOL_ROTATE: + case lcTool::Rotate: { const float OverlayScale = GetOverlayScale(); const float OverlayRotateRadius = 2.0f; @@ -2321,27 +2321,27 @@ void View::UpdateTrackTool() } break; - case LC_TOOL_ERASER: + case lcTool::Eraser: NewTrackTool = LC_TRACKTOOL_ERASER; break; - case LC_TOOL_PAINT: + case lcTool::Paint: NewTrackTool = LC_TRACKTOOL_PAINT; break; - case LC_TOOL_COLOR_PICKER: + case lcTool::ColorPicker: NewTrackTool = LC_TRACKTOOL_COLOR_PICKER; break; - case LC_TOOL_ZOOM: + case lcTool::Zoom: NewTrackTool = LC_TRACKTOOL_ZOOM; break; - case LC_TOOL_PAN: + case lcTool::Pan: NewTrackTool = LC_TRACKTOOL_PAN; break; - case LC_TOOL_ROTATE_VIEW: + case lcTool::RotateView: { int vx, vy, vw, vh; @@ -2382,15 +2382,15 @@ void View::UpdateTrackTool() } break; - case LC_TOOL_ROLL: + case lcTool::Roll: NewTrackTool = LC_TRACKTOOL_ROLL; break; - case LC_TOOL_ZOOM_REGION: + case lcTool::ZoomRegion: NewTrackTool = LC_TRACKTOOL_ZOOM_REGION; break; - case LC_NUM_TOOLS: + case lcTool::Count: break; } @@ -2508,11 +2508,11 @@ void View::StartTracking(lcTrackButton TrackButton) switch (Tool) { - case LC_TOOL_INSERT: - case LC_TOOL_LIGHT: + case lcTool::Insert: + case lcTool::Light: break; - case LC_TOOL_SPOTLIGHT: + case lcTool::SpotLight: { lcVector3 Position = GetCameraLightInsertPosition(); lcVector3 Target = Position + lcVector3(0.1f, 0.1f, 0.1f); @@ -2520,7 +2520,7 @@ void View::StartTracking(lcTrackButton TrackButton) } break; - case LC_TOOL_CAMERA: + case lcTool::Camera: { lcVector3 Position = GetCameraLightInsertPosition(); lcVector3 Target = Position + lcVector3(0.1f, 0.1f, 0.1f); @@ -2528,30 +2528,30 @@ void View::StartTracking(lcTrackButton TrackButton) } break; - case LC_TOOL_SELECT: + case lcTool::Select: break; - case LC_TOOL_MOVE: - case LC_TOOL_ROTATE: + case lcTool::Move: + case lcTool::Rotate: ActiveModel->BeginMouseTool(); break; - case LC_TOOL_ERASER: - case LC_TOOL_PAINT: - case LC_TOOL_COLOR_PICKER: + case lcTool::Eraser: + case lcTool::Paint: + case lcTool::ColorPicker: break; - case LC_TOOL_ZOOM: - case LC_TOOL_PAN: - case LC_TOOL_ROTATE_VIEW: - case LC_TOOL_ROLL: + case lcTool::Zoom: + case lcTool::Pan: + case lcTool::RotateView: + case lcTool::Roll: ActiveModel->BeginMouseTool(); break; - case LC_TOOL_ZOOM_REGION: + case lcTool::ZoomRegion: break; - case LC_NUM_TOOLS: + case lcTool::Count: break; } @@ -2568,16 +2568,16 @@ void View::StopTracking(bool Accept) switch (Tool) { - case LC_TOOL_INSERT: - case LC_TOOL_LIGHT: + case lcTool::Insert: + case lcTool::Light: break; - case LC_TOOL_SPOTLIGHT: - case LC_TOOL_CAMERA: + case lcTool::SpotLight: + case lcTool::Camera: ActiveModel->EndMouseTool(Tool, Accept); break; - case LC_TOOL_SELECT: + case lcTool::Select: if (Accept && mMouseDownX != mInputState.x && mMouseDownY != mInputState.y) { lcArray Objects = FindObjectsInBox(mMouseDownX, mMouseDownY, mInputState.x, mInputState.y); @@ -2591,24 +2591,24 @@ void View::StopTracking(bool Accept) } break; - case LC_TOOL_MOVE: - case LC_TOOL_ROTATE: + case lcTool::Move: + case lcTool::Rotate: ActiveModel->EndMouseTool(Tool, Accept); break; - case LC_TOOL_ERASER: - case LC_TOOL_PAINT: - case LC_TOOL_COLOR_PICKER: + case lcTool::Eraser: + case lcTool::Paint: + case lcTool::ColorPicker: break; - case LC_TOOL_ZOOM: - case LC_TOOL_PAN: - case LC_TOOL_ROTATE_VIEW: - case LC_TOOL_ROLL: + case lcTool::Zoom: + case lcTool::Pan: + case lcTool::RotateView: + case lcTool::Roll: ActiveModel->EndMouseTool(Tool, Accept); break; - case LC_TOOL_ZOOM_REGION: + case lcTool::ZoomRegion: { if (mInputState.x == mMouseDownX || mInputState.y == mMouseDownY) break; @@ -2639,7 +2639,7 @@ void View::StopTracking(bool Accept) } break; - case LC_NUM_TOOLS: + case lcTool::Count: break; } @@ -2679,7 +2679,7 @@ void View::OnButtonDown(lcTrackButton TrackButton) ActiveModel->InsertPieceToolClicked(GetPieceInsertPosition(false, gMainWindow->GetCurrentPieceInfo())); if ((mInputState.Modifiers & Qt::ControlModifier) == 0) - gMainWindow->SetTool(LC_TOOL_SELECT); + gMainWindow->SetTool(lcTool::Select); UpdateTrackTool(); } @@ -2690,7 +2690,7 @@ void View::OnButtonDown(lcTrackButton TrackButton) ActiveModel->PointLightToolClicked(GetCameraLightInsertPosition()); if ((mInputState.Modifiers & Qt::ControlModifier) == 0) - gMainWindow->SetTool(LC_TOOL_SELECT); + gMainWindow->SetTool(lcTool::Select); UpdateTrackTool(); } diff --git a/qt/lc_qpreferencesdialog.cpp b/qt/lc_qpreferencesdialog.cpp index c0c84b14..0579fc21 100644 --- a/qt/lc_qpreferencesdialog.cpp +++ b/qt/lc_qpreferencesdialog.cpp @@ -1062,7 +1062,7 @@ void lcQPreferencesDialog::UpdateMouseTree() { ui->mouseTree->clear(); - for (int ToolIdx = 0; ToolIdx < LC_NUM_TOOLS; ToolIdx++) + for (int ToolIdx = 0; ToolIdx < static_cast(lcTool::Count); ToolIdx++) UpdateMouseTreeItem(ToolIdx); } @@ -1147,7 +1147,7 @@ void lcQPreferencesDialog::on_mouseAssign_clicked() if (ui->mouseAlt->isChecked()) Modifiers |= Qt::AltModifier; - for (int ToolIdx = 0; ToolIdx < LC_NUM_TOOLS; ToolIdx++) + for (int ToolIdx = 0; ToolIdx < static_cast(lcTool::Count); ToolIdx++) { if (ToolIdx == ButtonIndex) continue;