diff --git a/common/lc_application.cpp b/common/lc_application.cpp index 17a75843..476342e4 100644 --- a/common/lc_application.cpp +++ b/common/lc_application.cpp @@ -16,7 +16,6 @@ lcApplication* g_App; void lcPreferences::LoadDefaults() { - mForceGlobalTransforms = lcGetProfileInt(LC_PROFILE_FORCE_GLOBAL_TRANSFORMS); mFixedAxes = lcGetProfileInt(LC_PROFILE_FIXED_AXES); mMouseSensitivity = lcGetProfileInt(LC_PROFILE_MOUSE_SENSITIVITY); mLightingMode = (lcLightingMode)lcGetProfileInt(LC_PROFILE_LIGHTING_MODE); @@ -32,7 +31,6 @@ void lcPreferences::LoadDefaults() void lcPreferences::SaveDefaults() { - lcSetProfileInt(LC_PROFILE_FORCE_GLOBAL_TRANSFORMS, mForceGlobalTransforms); lcSetProfileInt(LC_PROFILE_FIXED_AXES, mFixedAxes); lcSetProfileInt(LC_PROFILE_MOUSE_SENSITIVITY, mMouseSensitivity); lcSetProfileInt(LC_PROFILE_LIGHTING_MODE, mLightingMode); @@ -46,14 +44,6 @@ void lcPreferences::SaveDefaults() lcSetProfileInt(LC_PROFILE_GRID_LINE_COLOR, mGridLineColor); } -void lcPreferences::SetForceGlobalTransforms(bool ForceGlobalTransforms) -{ - mForceGlobalTransforms = ForceGlobalTransforms; - lcSetProfileInt(LC_PROFILE_FORCE_GLOBAL_TRANSFORMS, mForceGlobalTransforms); - gMainWindow->UpdateLockSnap(); - gMainWindow->UpdateAllViews(); -} - lcApplication::lcApplication() { mProject = NULL; diff --git a/common/lc_application.h b/common/lc_application.h index 18c8d014..568943e2 100644 --- a/common/lc_application.h +++ b/common/lc_application.h @@ -20,8 +20,6 @@ public: void LoadDefaults(); void SaveDefaults(); - void SetForceGlobalTransforms(bool ForceGlobalTransforms); - int mMouseSensitivity; lcLightingMode mLightingMode; bool mDrawAxes; @@ -32,7 +30,6 @@ public: bool mDrawGridLines; int mGridLineSpacing; lcuint32 mGridLineColor; - bool mForceGlobalTransforms; bool mFixedAxes; }; diff --git a/common/lc_commands.cpp b/common/lc_commands.cpp index 74e871ce..f6c637b3 100644 --- a/common/lc_commands.cpp +++ b/common/lc_commands.cpp @@ -256,11 +256,11 @@ lcCommand gCommands[LC_NUM_COMMANDS] = QT_TRANSLATE_NOOP("Status", "Allows movement and rotation in all directions"), QT_TRANSLATE_NOOP("Shortcut", "") }, - // LC_EDIT_SNAP_RELATIVE + // LC_EDIT_TRANSFORM_RELATIVE { - "Edit.SnapRelative", - QT_TRANSLATE_NOOP("Menu", "Relative Snap"), - QT_TRANSLATE_NOOP("Status", "Enable relative movement and rotation"), + "Edit.TransformRelative", + QT_TRANSLATE_NOOP("Menu", "Relative Transforms"), + QT_TRANSLATE_NOOP("Status", "Move and rotate objects relative to the one that currently has focus"), QT_TRANSLATE_NOOP("Shortcut", "") }, // LC_EDIT_SNAP_MOVE_XY0 diff --git a/common/lc_commands.h b/common/lc_commands.h index 19b8b197..dccc457a 100644 --- a/common/lc_commands.h +++ b/common/lc_commands.h @@ -41,7 +41,7 @@ enum lcCommandId LC_EDIT_LOCK_Y, LC_EDIT_LOCK_Z, LC_EDIT_LOCK_NONE, - LC_EDIT_SNAP_RELATIVE, + LC_EDIT_TRANSFORM_RELATIVE, LC_EDIT_SNAP_MOVE_XY0, LC_EDIT_SNAP_MOVE_XY1, LC_EDIT_SNAP_MOVE_XY2, diff --git a/common/lc_mainwindow.cpp b/common/lc_mainwindow.cpp index a1821bd9..b03f8fd7 100644 --- a/common/lc_mainwindow.cpp +++ b/common/lc_mainwindow.cpp @@ -23,6 +23,7 @@ lcMainWindow::lcMainWindow() mLockX = false; mLockY = false; mLockZ = false; + mRelativeTransform = true; memset(&mSearchOptions, 0, sizeof(mSearchOptions)); @@ -143,6 +144,13 @@ void lcMainWindow::SetLockZ(bool LockZ) UpdateLockSnap(); } +void lcMainWindow::SetRelativeTransform(bool RelativeTransform) +{ + mRelativeTransform = RelativeTransform; + UpdateLockSnap(); + UpdateAllViews(); +} + void lcMainWindow::AddRecentFile(const QString& FileName) { QString SavedName = FileName; @@ -728,8 +736,8 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId) SetAddKeys(!GetAddKeys()); break; - case LC_EDIT_SNAP_RELATIVE: - lcGetPreferences().SetForceGlobalTransforms(!lcGetPreferences().mForceGlobalTransforms); + case LC_EDIT_TRANSFORM_RELATIVE: + SetRelativeTransform(!GetRelativeTransform()); break; case LC_EDIT_LOCK_X: diff --git a/common/lc_mainwindow.h b/common/lc_mainwindow.h index 865f2e85..1b7667f0 100644 --- a/common/lc_mainwindow.h +++ b/common/lc_mainwindow.h @@ -102,6 +102,11 @@ public: return mLockZ; } + bool GetRelativeTransform() const + { + return mRelativeTransform; + } + View* GetActiveView() const { return mActiveView; @@ -127,6 +132,7 @@ public: void SetLockX(bool LockX); void SetLockY(bool LockY); void SetLockZ(bool LockZ); + void SetRelativeTransform(bool RelativeTransform); void Close(); void NewProject(); @@ -187,6 +193,7 @@ protected: bool mLockX; bool mLockY; bool mLockZ; + bool mRelativeTransform; }; extern class lcMainWindow* gMainWindow; diff --git a/common/lc_model.cpp b/common/lc_model.cpp index efabe570..0b4d5013 100644 --- a/common/lc_model.cpp +++ b/common/lc_model.cpp @@ -1767,9 +1767,7 @@ lcVector3 lcModel::SnapRotation(const lcVector3& Angles) const lcMatrix44 lcModel::GetRelativeRotation() const { - const lcPreferences& Preferences = lcGetPreferences(); - - if (!Preferences.mForceGlobalTransforms) + if (gMainWindow->GetRelativeTransform()) { lcObject* Focus = GetFocusObject(); @@ -2082,8 +2080,7 @@ void lcModel::RotateSelectedPieces(const lcVector3& Angles, bool Relative, bool if (Angles[2] != 0.0f) RotationMatrix = lcMul(lcMatrix33RotationZ(Angles[2] * LC_DTOR), RotationMatrix); - const lcPreferences& Preferences = lcGetPreferences(); - if (Preferences.mForceGlobalTransforms) + if (!gMainWindow->GetRelativeTransform()) Focus = NULL; if (Focus && Relative) diff --git a/common/lc_profile.cpp b/common/lc_profile.cpp index 89405cfe..29f09c71 100644 --- a/common/lc_profile.cpp +++ b/common/lc_profile.cpp @@ -47,7 +47,6 @@ lcProfileEntry::lcProfileEntry(const char* Section, const char* Key) lcProfileEntry gProfileEntries[LC_NUM_PROFILE_KEYS] = { - lcProfileEntry("Settings", "ForceGlobalTransforms", false), // LC_PROFILE_FORCE_GLOBAL_TRANSFORMS lcProfileEntry("Settings", "FixedAxes", false), // LC_PROFILE_FIXED_AXES lcProfileEntry("Settings", "LineWidth", 1.0f), // LC_PROFILE_LINE_WIDTH lcProfileEntry("Settings", "LightingMode", LC_LIGHTING_FLAT), // LC_PROFILE_LIGHTING_MODE diff --git a/common/lc_profile.h b/common/lc_profile.h index f68708d6..5c6bd2bf 100644 --- a/common/lc_profile.h +++ b/common/lc_profile.h @@ -4,7 +4,6 @@ enum LC_PROFILE_KEY { // Settings. - LC_PROFILE_FORCE_GLOBAL_TRANSFORMS, LC_PROFILE_FIXED_AXES, LC_PROFILE_LINE_WIDTH, LC_PROFILE_LIGHTING_MODE, diff --git a/leocad.qrc b/leocad.qrc index 38b84df3..8a9fc578 100644 --- a/leocad.qrc +++ b/leocad.qrc @@ -59,6 +59,7 @@ resources/view_split_horizontal.png resources/view_split_vertical.png resources/file_picture.png + resources/edit_transform_relative.png resources/edit_transform_absolute_rotation.png resources/edit_transform_absolute_translation.png resources/edit_transform_relative_rotation.png diff --git a/qt/lc_qmainwindow.cpp b/qt/lc_qmainwindow.cpp index 273fc759..2e56e2fe 100644 --- a/qt/lc_qmainwindow.cpp +++ b/qt/lc_qmainwindow.cpp @@ -128,6 +128,7 @@ void lcQMainWindow::createActions() actions[LC_EDIT_ACTION_ROTATE_VIEW]->setIcon(QIcon(":/resources/action_rotate_view.png")); actions[LC_EDIT_ACTION_ROLL]->setIcon(QIcon(":/resources/action_roll.png")); actions[LC_EDIT_ACTION_ZOOM_REGION]->setIcon(QIcon(":/resources/action_zoom_region.png")); + actions[LC_EDIT_TRANSFORM_RELATIVE]->setIcon(QIcon(":/resources/edit_transform_relative.png")); actions[LC_PIECE_SHOW_EARLIER]->setIcon(QIcon(":/resources/piece_show_earlier.png")); actions[LC_PIECE_SHOW_LATER]->setIcon(QIcon(":/resources/piece_show_later.png")); actions[LC_VIEW_SPLIT_HORIZONTAL]->setIcon(QIcon(":/resources/view_split_horizontal.png")); @@ -146,7 +147,7 @@ void lcQMainWindow::createActions() actions[LC_EDIT_LOCK_X]->setCheckable(true); actions[LC_EDIT_LOCK_Y]->setCheckable(true); actions[LC_EDIT_LOCK_Z]->setCheckable(true); - actions[LC_EDIT_SNAP_RELATIVE]->setCheckable(true); + actions[LC_EDIT_TRANSFORM_RELATIVE]->setCheckable(true); actions[LC_VIEW_CAMERA_NONE]->setCheckable(true); actions[LC_VIEW_TIME_ADD_KEYS]->setCheckable(true); @@ -401,7 +402,7 @@ void lcQMainWindow::createToolBars() standardToolBar->addAction(actions[LC_EDIT_COPY]); standardToolBar->addAction(actions[LC_EDIT_PASTE]); standardToolBar->addSeparator(); -// standardToolBar->addAction(actions[LC_EDIT_SNAP_RELATIVE]); todo + standardToolBar->addAction(actions[LC_EDIT_TRANSFORM_RELATIVE]); standardToolBar->addAction(lockAction); standardToolBar->addAction(moveAction); standardToolBar->addAction(angleAction); @@ -1163,9 +1164,7 @@ void lcQMainWindow::setAddKeys(bool addKeys) void lcQMainWindow::updateLockSnap() { - const lcPreferences& Preferences = lcGetPreferences(); - - actions[LC_EDIT_SNAP_RELATIVE]->setChecked(!Preferences.mForceGlobalTransforms); + actions[LC_EDIT_TRANSFORM_RELATIVE]->setChecked(gMainWindow->GetRelativeTransform()); actions[LC_EDIT_LOCK_X]->setChecked(gMainWindow->GetLockX()); actions[LC_EDIT_LOCK_Y]->setChecked(gMainWindow->GetLockY()); actions[LC_EDIT_LOCK_Z]->setChecked(gMainWindow->GetLockZ()); diff --git a/qt/lc_qpreferencesdialog.cpp b/qt/lc_qpreferencesdialog.cpp index cbaa71b6..d6c20272 100644 --- a/qt/lc_qpreferencesdialog.cpp +++ b/qt/lc_qpreferencesdialog.cpp @@ -30,7 +30,6 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget *parent, void *data) : ui->lgeoPath->setText(options->LGEOPath); ui->mouseSensitivity->setValue(options->Preferences.mMouseSensitivity); ui->checkForUpdates->setCurrentIndex(options->CheckForUpdates); - ui->noRelativeSnap->setChecked(options->Preferences.mForceGlobalTransforms); ui->fixedDirectionKeys->setChecked((options->Preferences.mFixedAxes) != 0); ui->antiAliasing->setChecked(options->AASamples != 1); @@ -91,7 +90,6 @@ void lcQPreferencesDialog::accept() strcpy(options->LGEOPath, ui->lgeoPath->text().toLocal8Bit().data()); options->Preferences.mMouseSensitivity = ui->mouseSensitivity->value(); options->CheckForUpdates = ui->checkForUpdates->currentIndex(); - options->Preferences.mForceGlobalTransforms = ui->noRelativeSnap->isChecked(); options->Preferences.mFixedAxes = ui->fixedDirectionKeys->isChecked(); if (!ui->antiAliasing->isChecked()) diff --git a/qt/lc_qpreferencesdialog.ui b/qt/lc_qpreferencesdialog.ui index a8dabcc1..09eb2e4e 100644 --- a/qt/lc_qpreferencesdialog.ui +++ b/qt/lc_qpreferencesdialog.ui @@ -192,13 +192,6 @@ - - - Don't allow relative snap - - - - Fixed direction keys @@ -717,7 +710,6 @@ lgeoPathBrowse mouseSensitivity checkForUpdates - noRelativeSnap fixedDirectionKeys antiAliasing antiAliasingSamples diff --git a/resources/edit_transform_relative.png b/resources/edit_transform_relative.png new file mode 100644 index 00000000..0dd63139 Binary files /dev/null and b/resources/edit_transform_relative.png differ