Scoped lcTool.

This commit is contained in:
Leonardo 2020-12-04 15:38:49 -08:00
parent 256d3792b1
commit 366018ee8c
9 changed files with 215 additions and 211 deletions

View file

@ -1659,23 +1659,23 @@ lcCommand gCommands[LC_NUM_COMMANDS] =
static_assert(sizeof(gCommands)/sizeof(gCommands[0]) == LC_NUM_COMMANDS, "Array size mismatch."); static_assert(sizeof(gCommands)/sizeof(gCommands[0]) == LC_NUM_COMMANDS, "Array size mismatch.");
const char* gToolNames[LC_NUM_TOOLS] = const char* gToolNames[static_cast<int>(lcTool::Count)] =
{ {
QT_TRANSLATE_NOOP("Mouse", "NewPiece"), // LC_TOOL_INSERT QT_TRANSLATE_NOOP("Mouse", "NewPiece"), // lcTool::Insert
QT_TRANSLATE_NOOP("Mouse", "NewPointLight"), // LC_TOOL_LIGHT QT_TRANSLATE_NOOP("Mouse", "NewPointLight"), // lcTool::Light
QT_TRANSLATE_NOOP("Mouse", "NewSpotLight"), // LC_TOOL_SPOTLIGHT QT_TRANSLATE_NOOP("Mouse", "NewSpotLight"), // lcTool::SpotLight
QT_TRANSLATE_NOOP("Mouse", "NewCamera"), // LC_TOOL_CAMERA QT_TRANSLATE_NOOP("Mouse", "NewCamera"), // lcTool::Camera
QT_TRANSLATE_NOOP("Mouse", "Select"), // LC_TOOL_SELECT QT_TRANSLATE_NOOP("Mouse", "Select"), // lcTool::Select
QT_TRANSLATE_NOOP("Mouse", "Move"), // LC_TOOL_MOVE QT_TRANSLATE_NOOP("Mouse", "Move"), // lcTool::Move
QT_TRANSLATE_NOOP("Mouse", "Rotate"), // LC_TOOL_ROTATE QT_TRANSLATE_NOOP("Mouse", "Rotate"), // lcTool::Rotate
QT_TRANSLATE_NOOP("Mouse", "Delete"), // LC_TOOL_ERASER QT_TRANSLATE_NOOP("Mouse", "Delete"), // lcTool::Eraser
QT_TRANSLATE_NOOP("Mouse", "Paint"), // LC_TOOL_PAINT QT_TRANSLATE_NOOP("Mouse", "Paint"), // lcTool::Paint
QT_TRANSLATE_NOOP("Mouse", "ColorPicker"), // LC_TOOL_COLOR_PICKER QT_TRANSLATE_NOOP("Mouse", "ColorPicker"), // lcTool::ColorPicker
QT_TRANSLATE_NOOP("Mouse", "Zoom"), // LC_TOOL_ZOOM QT_TRANSLATE_NOOP("Mouse", "Zoom"), // lcTool::Zoom
QT_TRANSLATE_NOOP("Mouse", "Pan"), // LC_TOOL_PAN QT_TRANSLATE_NOOP("Mouse", "Pan"), // lcTool::Pan
QT_TRANSLATE_NOOP("Mouse", "Orbit"), // LC_TOOL_ROTATE_VIEW QT_TRANSLATE_NOOP("Mouse", "Orbit"), // lcTool::RotateView
QT_TRANSLATE_NOOP("Mouse", "Roll"), // LC_TOOL_ROLL QT_TRANSLATE_NOOP("Mouse", "Roll"), // lcTool::Roll
QT_TRANSLATE_NOOP("Mouse", "ZoomRegion") // LC_TOOL_ZOOM_REGION 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<int>(lcTool::Count), "Array size mismatch.");

View file

@ -267,25 +267,25 @@ struct lcCommand
extern lcCommand gCommands[LC_NUM_COMMANDS]; extern lcCommand gCommands[LC_NUM_COMMANDS];
enum lcTool enum class lcTool
{ {
LC_TOOL_INSERT, Insert,
LC_TOOL_LIGHT, Light,
LC_TOOL_SPOTLIGHT, SpotLight,
LC_TOOL_CAMERA, Camera,
LC_TOOL_SELECT, Select,
LC_TOOL_MOVE, Move,
LC_TOOL_ROTATE, Rotate,
LC_TOOL_ERASER, Eraser,
LC_TOOL_PAINT, Paint,
LC_TOOL_COLOR_PICKER, ColorPicker,
LC_TOOL_ZOOM, Zoom,
LC_TOOL_PAN, Pan,
LC_TOOL_ROTATE_VIEW, RotateView,
LC_TOOL_ROLL, Roll,
LC_TOOL_ZOOM_REGION, ZoomRegion,
LC_NUM_TOOLS Count
}; };
extern const char* gToolNames[LC_NUM_TOOLS]; extern const char* gToolNames[static_cast<int>(lcTool::Count)];

View file

@ -95,7 +95,7 @@ lcMainWindow::lcMainWindow()
mTransformType = lcTransformType::RelativeTranslation; mTransformType = lcTransformType::RelativeTranslation;
mColorIndex = lcGetColorIndex(7); mColorIndex = lcGetColorIndex(7);
mTool = LC_TOOL_SELECT; mTool = lcTool::Select;
mAddKeys = false; mAddKeys = false;
mMoveSnapEnabled = true; mMoveSnapEnabled = true;
mAngleSnapEnabled = true; mAngleSnapEnabled = true;
@ -1704,7 +1704,7 @@ void lcMainWindow::SetTool(lcTool Tool)
{ {
mTool = Tool; mTool = Tool;
QAction* Action = mActions[LC_EDIT_ACTION_FIRST + mTool]; QAction* Action = mActions[LC_EDIT_ACTION_FIRST + static_cast<int>(mTool)];
if (Action) if (Action)
Action->setChecked(true); Action->setChecked(true);
@ -3303,63 +3303,63 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
break; break;
case LC_EDIT_ACTION_SELECT: case LC_EDIT_ACTION_SELECT:
SetTool(LC_TOOL_SELECT); SetTool(lcTool::Select);
break; break;
case LC_EDIT_ACTION_INSERT: case LC_EDIT_ACTION_INSERT:
SetTool(LC_TOOL_INSERT); SetTool(lcTool::Insert);
break; break;
case LC_EDIT_ACTION_LIGHT: case LC_EDIT_ACTION_LIGHT:
SetTool(LC_TOOL_LIGHT); SetTool(lcTool::Light);
break; break;
case LC_EDIT_ACTION_SPOTLIGHT: case LC_EDIT_ACTION_SPOTLIGHT:
SetTool(LC_TOOL_SPOTLIGHT); SetTool(lcTool::SpotLight);
break; break;
case LC_EDIT_ACTION_CAMERA: case LC_EDIT_ACTION_CAMERA:
SetTool(LC_TOOL_CAMERA); SetTool(lcTool::Camera);
break; break;
case LC_EDIT_ACTION_MOVE: case LC_EDIT_ACTION_MOVE:
SetTool(LC_TOOL_MOVE); SetTool(lcTool::Move);
break; break;
case LC_EDIT_ACTION_ROTATE: case LC_EDIT_ACTION_ROTATE:
SetTool(LC_TOOL_ROTATE); SetTool(lcTool::Rotate);
break; break;
case LC_EDIT_ACTION_DELETE: case LC_EDIT_ACTION_DELETE:
SetTool(LC_TOOL_ERASER); SetTool(lcTool::Eraser);
break; break;
case LC_EDIT_ACTION_PAINT: case LC_EDIT_ACTION_PAINT:
SetTool(LC_TOOL_PAINT); SetTool(lcTool::Paint);
break; break;
case LC_EDIT_ACTION_COLOR_PICKER: case LC_EDIT_ACTION_COLOR_PICKER:
SetTool(LC_TOOL_COLOR_PICKER); SetTool(lcTool::ColorPicker);
break; break;
case LC_EDIT_ACTION_ZOOM: case LC_EDIT_ACTION_ZOOM:
SetTool(LC_TOOL_ZOOM); SetTool(lcTool::Zoom);
break; break;
case LC_EDIT_ACTION_ZOOM_REGION: case LC_EDIT_ACTION_ZOOM_REGION:
SetTool(LC_TOOL_ZOOM_REGION); SetTool(lcTool::ZoomRegion);
break; break;
case LC_EDIT_ACTION_PAN: case LC_EDIT_ACTION_PAN:
SetTool(LC_TOOL_PAN); SetTool(lcTool::Pan);
break; break;
case LC_EDIT_ACTION_ROTATE_VIEW: case LC_EDIT_ACTION_ROTATE_VIEW:
SetTool(LC_TOOL_ROTATE_VIEW); SetTool(lcTool::RotateView);
break; break;
case LC_EDIT_ACTION_ROLL: case LC_EDIT_ACTION_ROLL:
SetTool(LC_TOOL_ROLL); SetTool(lcTool::Roll);
break; break;
case LC_EDIT_CANCEL: case LC_EDIT_CANCEL:

View file

@ -3912,60 +3912,60 @@ void lcModel::EndMouseTool(lcTool Tool, bool Accept)
switch (Tool) switch (Tool)
{ {
case LC_TOOL_INSERT: case lcTool::Insert:
case LC_TOOL_LIGHT: case lcTool::Light:
break; break;
case LC_TOOL_SPOTLIGHT: case lcTool::SpotLight:
SaveCheckpoint(tr("New SpotLight")); SaveCheckpoint(tr("New SpotLight"));
break; break;
case LC_TOOL_CAMERA: case lcTool::Camera:
if (!mIsPreview) if (!mIsPreview)
gMainWindow->UpdateCameraMenu(); gMainWindow->UpdateCameraMenu();
SaveCheckpoint(tr("New Camera")); SaveCheckpoint(tr("New Camera"));
break; break;
case LC_TOOL_SELECT: case lcTool::Select:
break; break;
case LC_TOOL_MOVE: case lcTool::Move:
SaveCheckpoint(tr("Move")); SaveCheckpoint(tr("Move"));
break; break;
case LC_TOOL_ROTATE: case lcTool::Rotate:
SaveCheckpoint(tr("Rotate")); SaveCheckpoint(tr("Rotate"));
break; break;
case LC_TOOL_ERASER: case lcTool::Eraser:
case LC_TOOL_PAINT: case lcTool::Paint:
case LC_TOOL_COLOR_PICKER: case lcTool::ColorPicker:
break; break;
case LC_TOOL_ZOOM: case lcTool::Zoom:
if (!mIsPreview && !gMainWindow->GetActiveView()->GetCamera()->IsSimple()) if (!mIsPreview && !gMainWindow->GetActiveView()->GetCamera()->IsSimple())
SaveCheckpoint(tr("Zoom")); SaveCheckpoint(tr("Zoom"));
break; break;
case LC_TOOL_PAN: case lcTool::Pan:
if (!mIsPreview && !gMainWindow->GetActiveView()->GetCamera()->IsSimple()) if (!mIsPreview && !gMainWindow->GetActiveView()->GetCamera()->IsSimple())
SaveCheckpoint(tr("Pan")); SaveCheckpoint(tr("Pan"));
break; break;
case LC_TOOL_ROTATE_VIEW: case lcTool::RotateView:
if (!mIsPreview && !gMainWindow->GetActiveView()->GetCamera()->IsSimple()) if (!mIsPreview && !gMainWindow->GetActiveView()->GetCamera()->IsSimple())
SaveCheckpoint(tr("Orbit")); SaveCheckpoint(tr("Orbit"));
break; break;
case LC_TOOL_ROLL: case lcTool::Roll:
if (!mIsPreview && !gMainWindow->GetActiveView()->GetCamera()->IsSimple()) if (!mIsPreview && !gMainWindow->GetActiveView()->GetCamera()->IsSimple())
SaveCheckpoint(tr("Roll")); SaveCheckpoint(tr("Roll"));
break; break;
case LC_TOOL_ZOOM_REGION: case lcTool::ZoomRegion:
break; break;
case LC_NUM_TOOLS: case lcTool::Count:
break; break;
} }
} }

View file

@ -83,7 +83,7 @@ lcPreviewWidget::lcPreviewWidget()
: mLoader(new Project(true/*IsPreview*/)), : mLoader(new Project(true/*IsPreview*/)),
mViewSphere(this/*Preview*/) mViewSphere(this/*Preview*/)
{ {
mTool = LC_TOOL_SELECT; mTool = lcTool::Select;
mTrackTool = LC_TRACKTOOL_NONE; mTrackTool = LC_TRACKTOOL_NONE;
mTrackButton = lcTrackButton::None; mTrackButton = lcTrackButton::None;
@ -278,9 +278,9 @@ lcTool lcPreviewWidget::GetCurrentTool() const
{ {
const lcTool ToolFromTrackTool[] = const lcTool ToolFromTrackTool[] =
{ {
LC_TOOL_SELECT, // LC_TRACKTOOL_NONE lcTool::Select, // LC_TRACKTOOL_NONE
LC_TOOL_PAN, // LC_TRACKTOOL_PAN lcTool::Pan, // LC_TRACKTOOL_PAN
LC_TOOL_ROTATE_VIEW, // LC_TRACKTOOL_ORBIT_XY lcTool::RotateView, // LC_TRACKTOOL_ORBIT_XY
}; };
return ToolFromTrackTool[mTrackTool]; return ToolFromTrackTool[mTrackTool];
@ -297,15 +297,15 @@ void lcPreviewWidget::StartTracking(lcTrackButton TrackButton)
switch (Tool) switch (Tool)
{ {
case LC_TOOL_SELECT: case lcTool::Select:
break; break;
case LC_TOOL_PAN: case lcTool::Pan:
case LC_TOOL_ROTATE_VIEW: case lcTool::RotateView:
ActiveModel->BeginMouseTool(); ActiveModel->BeginMouseTool();
break; break;
case LC_NUM_TOOLS: case lcTool::Count:
default: default:
break; break;
} }
@ -323,15 +323,15 @@ void lcPreviewWidget::StopTracking(bool Accept)
switch (Tool) switch (Tool)
{ {
case LC_TOOL_SELECT: case lcTool::Select:
break; break;
case LC_TOOL_PAN: case lcTool::Pan:
case LC_TOOL_ROTATE_VIEW: case lcTool::RotateView:
ActiveModel->EndMouseTool(Tool, Accept); ActiveModel->EndMouseTool(Tool, Accept);
break; break;
case LC_NUM_TOOLS: case lcTool::Count:
default: default:
break; break;
} }

View file

@ -132,23 +132,26 @@ void lcMouseShortcuts::Reset()
{ {
memset(mShortcuts, 0, sizeof(mShortcuts)); memset(mShortcuts, 0, sizeof(mShortcuts));
mShortcuts[LC_TOOL_ROTATE_VIEW].Modifiers1 = Qt::AltModifier; lcToolShortcut& RotateViewShortcut = mShortcuts[static_cast<int>(lcTool::RotateView)];
mShortcuts[LC_TOOL_ROTATE_VIEW].Button1 = Qt::LeftButton; RotateViewShortcut.Modifiers1 = Qt::AltModifier;
mShortcuts[LC_TOOL_ROTATE_VIEW].Modifiers2 = Qt::NoModifier; RotateViewShortcut.Button1 = Qt::LeftButton;
mShortcuts[LC_TOOL_ROTATE_VIEW].Button2 = Qt::RightButton; RotateViewShortcut.Modifiers2 = Qt::NoModifier;
RotateViewShortcut.Button2 = Qt::RightButton;
lcToolShortcut& PanShortcut = mShortcuts[static_cast<int>(lcTool::Pan)];
#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0))
mShortcuts[LC_TOOL_PAN].Modifiers1 = Qt::AltModifier; PanShortcut.Modifiers1 = Qt::AltModifier;
mShortcuts[LC_TOOL_PAN].Button1 = Qt::MiddleButton; PanShortcut.Button1 = Qt::MiddleButton;
mShortcuts[LC_TOOL_PAN].Modifiers2 = Qt::ShiftModifier; PanShortcut.Modifiers2 = Qt::ShiftModifier;
mShortcuts[LC_TOOL_PAN].Button2 = Qt::RightButton; PanShortcut.Button2 = Qt::RightButton;
#else #else
mShortcuts[LC_TOOL_PAN].Modifiers1 = Qt::ShiftModifier; PanShortcut.Modifiers1 = Qt::ShiftModifier;
mShortcuts[LC_TOOL_PAN].Button1 = Qt::RightButton; PanShortcut.Button1 = Qt::RightButton;
#endif #endif
mShortcuts[LC_TOOL_ZOOM].Modifiers1 = Qt::AltModifier; lcToolShortcut& ZoomShortcut = mShortcuts[static_cast<int>(lcTool::Zoom)];
mShortcuts[LC_TOOL_ZOOM].Button1 = Qt::RightButton; ZoomShortcut.Modifiers1 = Qt::AltModifier;
ZoomShortcut.Button1 = Qt::RightButton;
} }
bool lcMouseShortcuts::Save(const QString& FileName) bool lcMouseShortcuts::Save(const QString& FileName)
@ -176,7 +179,7 @@ bool lcMouseShortcuts::Save(QStringList& Shortcuts)
{ {
Shortcuts.clear(); Shortcuts.clear();
for (int ToolIdx = 0; ToolIdx < LC_NUM_TOOLS; ToolIdx++) for (int ToolIdx = 0; ToolIdx < static_cast<int>(lcTool::Count); ToolIdx++)
{ {
int ButtonIndex1 = 0; int ButtonIndex1 = 0;
for (int Button1 = mShortcuts[ToolIdx].Button1; Button1; Button1 >>= 1) for (int Button1 = mShortcuts[ToolIdx].Button1; Button1; Button1 >>= 1)
@ -230,11 +233,11 @@ bool lcMouseShortcuts::Load(const QStringList& FullShortcuts)
QString Key = FullShortcut.left(Equals); QString Key = FullShortcut.left(Equals);
int ToolIdx; int ToolIdx;
for (ToolIdx = 0; ToolIdx < LC_NUM_TOOLS; ToolIdx++) for (ToolIdx = 0; ToolIdx < static_cast<int>(lcTool::Count); ToolIdx++)
if (Key == gToolNames[ToolIdx]) if (Key == gToolNames[ToolIdx])
break; break;
if (ToolIdx == LC_NUM_TOOLS) if (ToolIdx == static_cast<int>(lcTool::Count))
continue; continue;
QStringList Shortcuts = FullShortcut.mid(Equals + 1).split(','); 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 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<int>(lcTool::Count); ToolIdx++)
if ((mShortcuts[ToolIdx].Button1 == Button && mShortcuts[ToolIdx].Modifiers1 == Modifiers) || (mShortcuts[ToolIdx].Button2 == Button && mShortcuts[ToolIdx].Modifiers2 == Modifiers)) if ((mShortcuts[ToolIdx].Button1 == Button && mShortcuts[ToolIdx].Modifiers1 == Modifiers) || (mShortcuts[ToolIdx].Button2 == Button && mShortcuts[ToolIdx].Modifiers2 == Modifiers))
return (lcTool)ToolIdx; return (lcTool)ToolIdx;
return LC_NUM_TOOLS; return lcTool::Count;
} }

View file

@ -31,14 +31,15 @@ public:
lcTool GetTool(Qt::MouseButton Button, Qt::KeyboardModifiers Modifiers) const; lcTool GetTool(Qt::MouseButton Button, Qt::KeyboardModifiers Modifiers) const;
struct struct lcToolShortcut
{ {
Qt::KeyboardModifiers Modifiers1; Qt::KeyboardModifiers Modifiers1;
Qt::MouseButton Button1; Qt::MouseButton Button1;
Qt::KeyboardModifiers Modifiers2; Qt::KeyboardModifiers Modifiers2;
Qt::MouseButton Button2; Qt::MouseButton Button2;
} };
mShortcuts[LC_NUM_TOOLS];
lcToolShortcut mShortcuts[static_cast<int>(lcTool::Count)];
}; };
extern lcMouseShortcuts gMouseShortcuts; extern lcMouseShortcuts gMouseShortcuts;

View file

@ -920,15 +920,15 @@ void View::OnDraw()
lcTool Tool = gMainWindow->GetTool(); lcTool Tool = gMainWindow->GetTool();
lcModel* ActiveModel = GetActiveModel(); 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(); DrawSelectMoveOverlay();
else if (GetCurrentTool() == LC_TOOL_MOVE && mTrackButton != lcTrackButton::None) else if (GetCurrentTool() == lcTool::Move && mTrackButton != lcTrackButton::None)
DrawSelectMoveOverlay(); 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(); DrawRotateOverlay();
else if ((mTrackTool == LC_TRACKTOOL_SELECT || mTrackTool == LC_TRACKTOOL_ZOOM_REGION) && mTrackButton != lcTrackButton::None) else if ((mTrackTool == LC_TRACKTOOL_SELECT || mTrackTool == LC_TRACKTOOL_ZOOM_REGION) && mTrackButton != lcTrackButton::None)
DrawSelectZoomRegionOverlay(); DrawSelectZoomRegionOverlay();
else if (Tool == LC_TOOL_ROTATE_VIEW && mTrackButton == lcTrackButton::None) else if (Tool == lcTool::RotateView && mTrackButton == lcTrackButton::None)
DrawRotateViewOverlay(); DrawRotateViewOverlay();
mViewSphere.Draw(); 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) if (AllowedTransforms & LC_OBJECT_TRANSFORM_ROTATE_X)
{ {
@ -1242,7 +1242,7 @@ void View::DrawRotateOverlay()
} }
// Draw the circles. // 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); lcMatrix44 Mat = lcMatrix44AffineInverse(mCamera->mWorldView);
Mat.SetTranslation(OverlayCenter); Mat.SetTranslation(OverlayCenter);
@ -1286,7 +1286,7 @@ void View::DrawRotateOverlay()
} }
else else
{ {
if (gMainWindow->GetTool() != LC_TOOL_ROTATE || HasAngle || mTrackButton != lcTrackButton::None) if (gMainWindow->GetTool() != lcTool::Rotate || HasAngle || mTrackButton != lcTrackButton::None)
continue; continue;
switch (i) switch (i)
@ -1328,7 +1328,7 @@ void View::DrawRotateOverlay()
break; 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++] = v1 * (OverlayRotateRadius * OverlayScale);
Verts[NumVerts++] = v2 * (OverlayRotateRadius * OverlayScale); Verts[NumVerts++] = v2 * (OverlayRotateRadius * OverlayScale);
@ -1801,36 +1801,36 @@ lcTool View::GetCurrentTool() const
{ {
const lcTool ToolFromTrackTool[] = const lcTool ToolFromTrackTool[] =
{ {
LC_TOOL_SELECT, // LC_TRACKTOOL_NONE lcTool::Select, // LC_TRACKTOOL_NONE
LC_TOOL_INSERT, // LC_TRACKTOOL_INSERT lcTool::Insert, // LC_TRACKTOOL_INSERT
LC_TOOL_LIGHT, // LC_TRACKTOOL_POINTLIGHT lcTool::Light, // LC_TRACKTOOL_POINTLIGHT
LC_TOOL_SPOTLIGHT, // LC_TRACKTOOL_SPOTLIGHT lcTool::SpotLight, // LC_TRACKTOOL_SPOTLIGHT
LC_TOOL_CAMERA, // LC_TRACKTOOL_CAMERA lcTool::Camera, // LC_TRACKTOOL_CAMERA
LC_TOOL_SELECT, // LC_TRACKTOOL_SELECT lcTool::Select, // LC_TRACKTOOL_SELECT
LC_TOOL_MOVE, // LC_TRACKTOOL_MOVE_X lcTool::Move, // LC_TRACKTOOL_MOVE_X
LC_TOOL_MOVE, // LC_TRACKTOOL_MOVE_Y lcTool::Move, // LC_TRACKTOOL_MOVE_Y
LC_TOOL_MOVE, // LC_TRACKTOOL_MOVE_Z lcTool::Move, // LC_TRACKTOOL_MOVE_Z
LC_TOOL_MOVE, // LC_TRACKTOOL_MOVE_XY lcTool::Move, // LC_TRACKTOOL_MOVE_XY
LC_TOOL_MOVE, // LC_TRACKTOOL_MOVE_XZ lcTool::Move, // LC_TRACKTOOL_MOVE_XZ
LC_TOOL_MOVE, // LC_TRACKTOOL_MOVE_YZ lcTool::Move, // LC_TRACKTOOL_MOVE_YZ
LC_TOOL_MOVE, // LC_TRACKTOOL_MOVE_XYZ lcTool::Move, // LC_TRACKTOOL_MOVE_XYZ
LC_TOOL_ROTATE, // LC_TRACKTOOL_ROTATE_X lcTool::Rotate, // LC_TRACKTOOL_ROTATE_X
LC_TOOL_ROTATE, // LC_TRACKTOOL_ROTATE_Y lcTool::Rotate, // LC_TRACKTOOL_ROTATE_Y
LC_TOOL_ROTATE, // LC_TRACKTOOL_ROTATE_Z lcTool::Rotate, // LC_TRACKTOOL_ROTATE_Z
LC_TOOL_ROTATE, // LC_TRACKTOOL_ROTATE_XY lcTool::Rotate, // LC_TRACKTOOL_ROTATE_XY
LC_TOOL_ROTATE, // LC_TRACKTOOL_ROTATE_XYZ lcTool::Rotate, // LC_TRACKTOOL_ROTATE_XYZ
LC_TOOL_MOVE, // LC_TRACKTOOL_SCALE_PLUS lcTool::Move, // LC_TRACKTOOL_SCALE_PLUS
LC_TOOL_MOVE, // LC_TRACKTOOL_SCALE_MINUS lcTool::Move, // LC_TRACKTOOL_SCALE_MINUS
LC_TOOL_ERASER, // LC_TRACKTOOL_ERASER lcTool::Eraser, // LC_TRACKTOOL_ERASER
LC_TOOL_PAINT, // LC_TRACKTOOL_PAINT lcTool::Paint, // LC_TRACKTOOL_PAINT
LC_TOOL_COLOR_PICKER, // LC_TRACKTOOL_COLOR_PICKER lcTool::ColorPicker, // LC_TRACKTOOL_COLOR_PICKER
LC_TOOL_ZOOM, // LC_TRACKTOOL_ZOOM lcTool::Zoom, // LC_TRACKTOOL_ZOOM
LC_TOOL_PAN, // LC_TRACKTOOL_PAN lcTool::Pan, // LC_TRACKTOOL_PAN
LC_TOOL_ROTATE_VIEW, // LC_TRACKTOOL_ORBIT_X lcTool::RotateView, // LC_TRACKTOOL_ORBIT_X
LC_TOOL_ROTATE_VIEW, // LC_TRACKTOOL_ORBIT_Y lcTool::RotateView, // LC_TRACKTOOL_ORBIT_Y
LC_TOOL_ROTATE_VIEW, // LC_TRACKTOOL_ORBIT_XY lcTool::RotateView, // LC_TRACKTOOL_ORBIT_XY
LC_TOOL_ROLL, // LC_TRACKTOOL_ROLL lcTool::Roll, // LC_TRACKTOOL_ROLL
LC_TOOL_ZOOM_REGION // LC_TRACKTOOL_ZOOM_REGION lcTool::ZoomRegion // LC_TRACKTOOL_ZOOM_REGION
}; };
return ToolFromTrackTool[mTrackTool]; return ToolFromTrackTool[mTrackTool];
@ -1843,29 +1843,29 @@ lcTrackTool View::GetOverrideTrackTool(Qt::MouseButton Button) const
lcTool OverrideTool = gMouseShortcuts.GetTool(Button, mInputState.Modifiers); lcTool OverrideTool = gMouseShortcuts.GetTool(Button, mInputState.Modifiers);
if (OverrideTool == LC_NUM_TOOLS) if (OverrideTool == lcTool::Count)
return LC_TRACKTOOL_NONE; return LC_TRACKTOOL_NONE;
lcTrackTool TrackToolFromTool[LC_NUM_TOOLS] = lcTrackTool TrackToolFromTool[static_cast<int>(lcTool::Count)] =
{ {
LC_TRACKTOOL_INSERT, // LC_TOOL_INSERT LC_TRACKTOOL_INSERT, // lcTool::Insert
LC_TRACKTOOL_POINTLIGHT, // LC_TOOL_LIGHT LC_TRACKTOOL_POINTLIGHT, // lcTool::Light
LC_TRACKTOOL_SPOTLIGHT, // LC_TOOL_SPOTLIGHT LC_TRACKTOOL_SPOTLIGHT, // lcTool::SpotLight
LC_TRACKTOOL_CAMERA, // LC_TOOL_CAMERA LC_TRACKTOOL_CAMERA, // lcTool::Camera
LC_TRACKTOOL_SELECT, // LC_TOOL_SELECT LC_TRACKTOOL_SELECT, // lcTool::Select
LC_TRACKTOOL_MOVE_XYZ, // LC_TOOL_MOVE LC_TRACKTOOL_MOVE_XYZ, // lcTool::Move
LC_TRACKTOOL_ROTATE_XYZ, // LC_TOOL_ROTATE LC_TRACKTOOL_ROTATE_XYZ, // lcTool::Rotate
LC_TRACKTOOL_ERASER, // LC_TOOL_ERASER LC_TRACKTOOL_ERASER, // lcTool::Eraser
LC_TRACKTOOL_PAINT, // LC_TOOL_PAINT LC_TRACKTOOL_PAINT, // lcTool::Paint
LC_TRACKTOOL_COLOR_PICKER, // LC_TOOL_COLOR_PICKER LC_TRACKTOOL_COLOR_PICKER, // lcTool::ColorPicker
LC_TRACKTOOL_ZOOM, // LC_TOOL_ZOOM LC_TRACKTOOL_ZOOM, // lcTool::Zoom
LC_TRACKTOOL_PAN, // LC_TOOL_PAN LC_TRACKTOOL_PAN, // lcTool::Pan
LC_TRACKTOOL_ORBIT_XY, // LC_TOOL_ROTATE_VIEW LC_TRACKTOOL_ORBIT_XY, // lcTool::RotateView
LC_TRACKTOOL_ROLL, // LC_TOOL_ROLL LC_TRACKTOOL_ROLL, // lcTool::Roll
LC_TRACKTOOL_ZOOM_REGION // LC_TOOL_ZOOM_REGION LC_TRACKTOOL_ZOOM_REGION // lcTool::ZoomRegion
}; };
return TrackToolFromTool[OverrideTool]; return TrackToolFromTool[static_cast<int>(OverrideTool)];
} }
float View::GetOverlayScale() const float View::GetOverlayScale() const
@ -1975,24 +1975,24 @@ void View::UpdateTrackTool()
switch (CurrentTool) switch (CurrentTool)
{ {
case LC_TOOL_INSERT: case lcTool::Insert:
NewTrackTool = LC_TRACKTOOL_INSERT; NewTrackTool = LC_TRACKTOOL_INSERT;
break; break;
case LC_TOOL_LIGHT: case lcTool::Light:
NewTrackTool = LC_TRACKTOOL_POINTLIGHT; NewTrackTool = LC_TRACKTOOL_POINTLIGHT;
break; break;
case LC_TOOL_SPOTLIGHT: case lcTool::SpotLight:
NewTrackTool = LC_TRACKTOOL_SPOTLIGHT; NewTrackTool = LC_TRACKTOOL_SPOTLIGHT;
break; break;
case LC_TOOL_CAMERA: case lcTool::Camera:
NewTrackTool = LC_TRACKTOOL_CAMERA; NewTrackTool = LC_TRACKTOOL_CAMERA;
break; break;
case LC_TOOL_SELECT: case lcTool::Select:
case LC_TOOL_MOVE: case lcTool::Move:
{ {
const float OverlayScale = GetOverlayScale(); const float OverlayScale = GetOverlayScale();
const float OverlayMovePlaneSize = 0.5f * OverlayScale; const float OverlayMovePlaneSize = 0.5f * OverlayScale;
@ -2002,7 +2002,7 @@ void View::UpdateTrackTool()
const float OverlayRotateArrowEnd = 1.5f * OverlayScale; const float OverlayRotateArrowEnd = 1.5f * OverlayScale;
const float OverlayScaleRadius = 0.125f; 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; mMouseDownPiece = nullptr;
lcVector3 OverlayCenter; 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 }; 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); lcObjectSection ObjectSection = FindObjectUnderPointer(false, false);
lcObject* Object = ObjectSection.Object; lcObject* Object = ObjectSection.Object;
@ -2175,7 +2175,7 @@ void View::UpdateTrackTool()
} }
break; break;
case LC_TOOL_ROTATE: case lcTool::Rotate:
{ {
const float OverlayScale = GetOverlayScale(); const float OverlayScale = GetOverlayScale();
const float OverlayRotateRadius = 2.0f; const float OverlayRotateRadius = 2.0f;
@ -2321,27 +2321,27 @@ void View::UpdateTrackTool()
} }
break; break;
case LC_TOOL_ERASER: case lcTool::Eraser:
NewTrackTool = LC_TRACKTOOL_ERASER; NewTrackTool = LC_TRACKTOOL_ERASER;
break; break;
case LC_TOOL_PAINT: case lcTool::Paint:
NewTrackTool = LC_TRACKTOOL_PAINT; NewTrackTool = LC_TRACKTOOL_PAINT;
break; break;
case LC_TOOL_COLOR_PICKER: case lcTool::ColorPicker:
NewTrackTool = LC_TRACKTOOL_COLOR_PICKER; NewTrackTool = LC_TRACKTOOL_COLOR_PICKER;
break; break;
case LC_TOOL_ZOOM: case lcTool::Zoom:
NewTrackTool = LC_TRACKTOOL_ZOOM; NewTrackTool = LC_TRACKTOOL_ZOOM;
break; break;
case LC_TOOL_PAN: case lcTool::Pan:
NewTrackTool = LC_TRACKTOOL_PAN; NewTrackTool = LC_TRACKTOOL_PAN;
break; break;
case LC_TOOL_ROTATE_VIEW: case lcTool::RotateView:
{ {
int vx, vy, vw, vh; int vx, vy, vw, vh;
@ -2382,15 +2382,15 @@ void View::UpdateTrackTool()
} }
break; break;
case LC_TOOL_ROLL: case lcTool::Roll:
NewTrackTool = LC_TRACKTOOL_ROLL; NewTrackTool = LC_TRACKTOOL_ROLL;
break; break;
case LC_TOOL_ZOOM_REGION: case lcTool::ZoomRegion:
NewTrackTool = LC_TRACKTOOL_ZOOM_REGION; NewTrackTool = LC_TRACKTOOL_ZOOM_REGION;
break; break;
case LC_NUM_TOOLS: case lcTool::Count:
break; break;
} }
@ -2508,11 +2508,11 @@ void View::StartTracking(lcTrackButton TrackButton)
switch (Tool) switch (Tool)
{ {
case LC_TOOL_INSERT: case lcTool::Insert:
case LC_TOOL_LIGHT: case lcTool::Light:
break; break;
case LC_TOOL_SPOTLIGHT: case lcTool::SpotLight:
{ {
lcVector3 Position = GetCameraLightInsertPosition(); lcVector3 Position = GetCameraLightInsertPosition();
lcVector3 Target = Position + lcVector3(0.1f, 0.1f, 0.1f); lcVector3 Target = Position + lcVector3(0.1f, 0.1f, 0.1f);
@ -2520,7 +2520,7 @@ void View::StartTracking(lcTrackButton TrackButton)
} }
break; break;
case LC_TOOL_CAMERA: case lcTool::Camera:
{ {
lcVector3 Position = GetCameraLightInsertPosition(); lcVector3 Position = GetCameraLightInsertPosition();
lcVector3 Target = Position + lcVector3(0.1f, 0.1f, 0.1f); lcVector3 Target = Position + lcVector3(0.1f, 0.1f, 0.1f);
@ -2528,30 +2528,30 @@ void View::StartTracking(lcTrackButton TrackButton)
} }
break; break;
case LC_TOOL_SELECT: case lcTool::Select:
break; break;
case LC_TOOL_MOVE: case lcTool::Move:
case LC_TOOL_ROTATE: case lcTool::Rotate:
ActiveModel->BeginMouseTool(); ActiveModel->BeginMouseTool();
break; break;
case LC_TOOL_ERASER: case lcTool::Eraser:
case LC_TOOL_PAINT: case lcTool::Paint:
case LC_TOOL_COLOR_PICKER: case lcTool::ColorPicker:
break; break;
case LC_TOOL_ZOOM: case lcTool::Zoom:
case LC_TOOL_PAN: case lcTool::Pan:
case LC_TOOL_ROTATE_VIEW: case lcTool::RotateView:
case LC_TOOL_ROLL: case lcTool::Roll:
ActiveModel->BeginMouseTool(); ActiveModel->BeginMouseTool();
break; break;
case LC_TOOL_ZOOM_REGION: case lcTool::ZoomRegion:
break; break;
case LC_NUM_TOOLS: case lcTool::Count:
break; break;
} }
@ -2568,16 +2568,16 @@ void View::StopTracking(bool Accept)
switch (Tool) switch (Tool)
{ {
case LC_TOOL_INSERT: case lcTool::Insert:
case LC_TOOL_LIGHT: case lcTool::Light:
break; break;
case LC_TOOL_SPOTLIGHT: case lcTool::SpotLight:
case LC_TOOL_CAMERA: case lcTool::Camera:
ActiveModel->EndMouseTool(Tool, Accept); ActiveModel->EndMouseTool(Tool, Accept);
break; break;
case LC_TOOL_SELECT: case lcTool::Select:
if (Accept && mMouseDownX != mInputState.x && mMouseDownY != mInputState.y) if (Accept && mMouseDownX != mInputState.x && mMouseDownY != mInputState.y)
{ {
lcArray<lcObject*> Objects = FindObjectsInBox(mMouseDownX, mMouseDownY, mInputState.x, mInputState.y); lcArray<lcObject*> Objects = FindObjectsInBox(mMouseDownX, mMouseDownY, mInputState.x, mInputState.y);
@ -2591,24 +2591,24 @@ void View::StopTracking(bool Accept)
} }
break; break;
case LC_TOOL_MOVE: case lcTool::Move:
case LC_TOOL_ROTATE: case lcTool::Rotate:
ActiveModel->EndMouseTool(Tool, Accept); ActiveModel->EndMouseTool(Tool, Accept);
break; break;
case LC_TOOL_ERASER: case lcTool::Eraser:
case LC_TOOL_PAINT: case lcTool::Paint:
case LC_TOOL_COLOR_PICKER: case lcTool::ColorPicker:
break; break;
case LC_TOOL_ZOOM: case lcTool::Zoom:
case LC_TOOL_PAN: case lcTool::Pan:
case LC_TOOL_ROTATE_VIEW: case lcTool::RotateView:
case LC_TOOL_ROLL: case lcTool::Roll:
ActiveModel->EndMouseTool(Tool, Accept); ActiveModel->EndMouseTool(Tool, Accept);
break; break;
case LC_TOOL_ZOOM_REGION: case lcTool::ZoomRegion:
{ {
if (mInputState.x == mMouseDownX || mInputState.y == mMouseDownY) if (mInputState.x == mMouseDownX || mInputState.y == mMouseDownY)
break; break;
@ -2639,7 +2639,7 @@ void View::StopTracking(bool Accept)
} }
break; break;
case LC_NUM_TOOLS: case lcTool::Count:
break; break;
} }
@ -2679,7 +2679,7 @@ void View::OnButtonDown(lcTrackButton TrackButton)
ActiveModel->InsertPieceToolClicked(GetPieceInsertPosition(false, gMainWindow->GetCurrentPieceInfo())); ActiveModel->InsertPieceToolClicked(GetPieceInsertPosition(false, gMainWindow->GetCurrentPieceInfo()));
if ((mInputState.Modifiers & Qt::ControlModifier) == 0) if ((mInputState.Modifiers & Qt::ControlModifier) == 0)
gMainWindow->SetTool(LC_TOOL_SELECT); gMainWindow->SetTool(lcTool::Select);
UpdateTrackTool(); UpdateTrackTool();
} }
@ -2690,7 +2690,7 @@ void View::OnButtonDown(lcTrackButton TrackButton)
ActiveModel->PointLightToolClicked(GetCameraLightInsertPosition()); ActiveModel->PointLightToolClicked(GetCameraLightInsertPosition());
if ((mInputState.Modifiers & Qt::ControlModifier) == 0) if ((mInputState.Modifiers & Qt::ControlModifier) == 0)
gMainWindow->SetTool(LC_TOOL_SELECT); gMainWindow->SetTool(lcTool::Select);
UpdateTrackTool(); UpdateTrackTool();
} }

View file

@ -1062,7 +1062,7 @@ void lcQPreferencesDialog::UpdateMouseTree()
{ {
ui->mouseTree->clear(); ui->mouseTree->clear();
for (int ToolIdx = 0; ToolIdx < LC_NUM_TOOLS; ToolIdx++) for (int ToolIdx = 0; ToolIdx < static_cast<int>(lcTool::Count); ToolIdx++)
UpdateMouseTreeItem(ToolIdx); UpdateMouseTreeItem(ToolIdx);
} }
@ -1147,7 +1147,7 @@ void lcQPreferencesDialog::on_mouseAssign_clicked()
if (ui->mouseAlt->isChecked()) if (ui->mouseAlt->isChecked())
Modifiers |= Qt::AltModifier; Modifiers |= Qt::AltModifier;
for (int ToolIdx = 0; ToolIdx < LC_NUM_TOOLS; ToolIdx++) for (int ToolIdx = 0; ToolIdx < static_cast<int>(lcTool::Count); ToolIdx++)
{ {
if (ToolIdx == ButtonIndex) if (ToolIdx == ButtonIndex)
continue; continue;