From 73952870fd56b26a6500a7e16aefd35e04cdefb7 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 27 Aug 2014 16:17:09 +0000 Subject: [PATCH] Moved transform type to main window. --- common/lc_mainwindow.cpp | 1 + common/lc_mainwindow.h | 8 +++++++- common/lc_model.h | 8 ++++++++ common/project.cpp | 15 ++++----------- common/project.h | 12 +----------- common/view.cpp | 2 +- qt/lc_qmainwindow.cpp | 1 + qt/qtmain.cpp | 6 ++++-- 8 files changed, 27 insertions(+), 26 deletions(-) diff --git a/common/lc_mainwindow.cpp b/common/lc_mainwindow.cpp index a8ab7216..444e1afb 100644 --- a/common/lc_mainwindow.cpp +++ b/common/lc_mainwindow.cpp @@ -10,6 +10,7 @@ lcMainWindow::lcMainWindow() { mActiveView = NULL; mPreviewWidget = NULL; + mTransformType = LC_TRANSFORM_RELATIVE_TRANSLATION; mAddKeys = false; diff --git a/common/lc_mainwindow.h b/common/lc_mainwindow.h index 75e01aea..6b854205 100644 --- a/common/lc_mainwindow.h +++ b/common/lc_mainwindow.h @@ -21,6 +21,11 @@ class lcMainWindow : public lcBaseWindow return mTool; } + lcTransformType GetTransformType() const + { + return mTransformType; + } + bool GetAddKeys() const { return mAddKeys; @@ -42,6 +47,7 @@ class lcMainWindow : public lcBaseWindow void UpdateAllViews(); void SetTool(lcTool Tool); + void SetTransformType(lcTransformType TransformType); void SetColorIndex(int ColorIndex); void Close(); @@ -65,7 +71,6 @@ class lcMainWindow : public lcBaseWindow void UpdateLockSnap(lcuint32 Snap); void UpdateSnap(); void UpdateUndoRedo(const char* UndoText, const char* RedoText); - void UpdateTransformType(int NewType); void UpdateCurrentCamera(int CameraIndex); void UpdatePerspective(); void UpdateCameraMenu(); @@ -87,6 +92,7 @@ protected: bool mAddKeys; lcTool mTool; + lcTransformType mTransformType; }; extern class lcMainWindow* gMainWindow; diff --git a/common/lc_model.h b/common/lc_model.h index bc31c1f3..9b7c8aa2 100644 --- a/common/lc_model.h +++ b/common/lc_model.h @@ -15,6 +15,14 @@ #define LC_SEL_FOCUS_GROUPED 0x40 // Focused piece is grouped #define LC_SEL_CAN_GROUP 0x80 // Can make a new group +enum lcTransformType +{ + LC_TRANSFORM_ABSOLUTE_TRANSLATION, + LC_TRANSFORM_RELATIVE_TRANSLATION, + LC_TRANSFORM_ABSOLUTE_ROTATION, + LC_TRANSFORM_RELATIVE_ROTATION +}; + enum lcBackgroundType { LC_BACKGROUND_SOLID, diff --git a/common/project.cpp b/common/project.cpp index dc767d00..e641f59e 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -31,7 +31,6 @@ Project::Project() { - mTransformType = LC_TRANSFORM_RELATIVE_TRANSLATION; m_pTerrain = new Terrain(); m_pBackground = new lcTexture(); memset(&mSearchOptions, 0, sizeof(mSearchOptions)); @@ -55,7 +54,7 @@ void Project::UpdateInterface() gMainWindow->SetTool(gMainWindow->GetTool()); gMainWindow->UpdateFocusObject(GetFocusObject()); - gMainWindow->UpdateTransformType(mTransformType); + gMainWindow->SetTransformType(gMainWindow->GetTransformType()); gMainWindow->UpdateLockSnap(m_nSnap); gMainWindow->UpdateSnap(); gMainWindow->UpdateCameraMenu(); @@ -5043,15 +5042,14 @@ void Project::HandleCommand(LC_COMMANDS id) } break; case LC_EDIT_TRANSFORM: - TransformSelectedObjects((LC_TRANSFORM_TYPE)mTransformType, gMainWindow->GetTransformAmount()); + TransformSelectedObjects(gMainWindow->GetTransformType(), gMainWindow->GetTransformAmount()); break; case LC_EDIT_TRANSFORM_ABSOLUTE_TRANSLATION: case LC_EDIT_TRANSFORM_RELATIVE_TRANSLATION: case LC_EDIT_TRANSFORM_ABSOLUTE_ROTATION: case LC_EDIT_TRANSFORM_RELATIVE_ROTATION: - mTransformType = id - LC_EDIT_TRANSFORM_ABSOLUTE_TRANSLATION; - gMainWindow->UpdateTransformType(mTransformType); + gMainWindow->SetTransformType((lcTransformType)(id - LC_EDIT_TRANSFORM_ABSOLUTE_TRANSLATION)); break; case LC_EDIT_ACTION_SELECT: @@ -5761,7 +5759,7 @@ bool Project::RotateSelectedObjects(lcVector3& Delta, lcVector3& Remainder, bool return true; } -void Project::TransformSelectedObjects(LC_TRANSFORM_TYPE Type, const lcVector3& Transform) +void Project::TransformSelectedObjects(lcTransformType Type, const lcVector3& Transform) { switch (Type) { @@ -6388,11 +6386,6 @@ void Project::ZoomRegionToolClicked(lcCamera* Camera, const lcVector3* Points, f CheckPoint("Zoom"); } -void Project::OnMouseWheel(View* view, float Direction) -{ - ZoomActiveView((int)((view->mInputState.Control ? 100 : 10) * Direction)); -} - // Indicates if the existing string represents an instance of the candidate // string in the form " (#)". // diff --git a/common/project.h b/common/project.h index 929d023d..671e9222 100644 --- a/common/project.h +++ b/common/project.h @@ -38,14 +38,6 @@ //#define LC_HTML_HTMLEXT 0x40 //#define LC_HTML_LISTID 0x80 -enum LC_TRANSFORM_TYPE -{ - LC_TRANSFORM_ABSOLUTE_TRANSLATION, - LC_TRANSFORM_RELATIVE_TRANSLATION, - LC_TRANSFORM_ABSOLUTE_ROTATION, - LC_TRANSFORM_RELATIVE_ROTATION -}; - enum LC_MOUSE_TRACK { LC_TRACK_NONE, @@ -183,7 +175,7 @@ public: bool GetFocusPosition(lcVector3& Position) const; bool AnyObjectsSelected(bool PiecesOnly) const; lcGroup* AddGroup(lcGroup* Parent); - void TransformSelectedObjects(LC_TRANSFORM_TYPE Type, const lcVector3& Transform); + void TransformSelectedObjects(lcTransformType Type, const lcVector3& Transform); void ModifyObject(lcObject* Object, lcObjectProperty Property, void* Value); void ZoomActiveView(int Amount); @@ -230,13 +222,11 @@ protected: void RemoveEmptyGroups(); public: - void OnMouseWheel(View* view, float Direction); void HandleCommand(LC_COMMANDS id); lcuint32 m_nSnap; protected: - int mTransformType; PieceInfo* m_pCurPiece; lcuint16 m_nMoveSnap; diff --git a/common/view.cpp b/common/view.cpp index 341a3333..ae02bee8 100644 --- a/common/view.cpp +++ b/common/view.cpp @@ -2142,5 +2142,5 @@ void View::OnMouseMove() void View::OnMouseWheel(float Direction) { - mProject->OnMouseWheel(this, Direction); + mProject->ZoomActiveView((int)((mInputState.Control ? 100 : 10) * Direction)); } diff --git a/qt/lc_qmainwindow.cpp b/qt/lc_qmainwindow.cpp index 5b078305..66d9cb7c 100644 --- a/qt/lc_qmainwindow.cpp +++ b/qt/lc_qmainwindow.cpp @@ -397,6 +397,7 @@ void lcQMainWindow::createToolBars() ((QToolButton*)standardToolBar->widgetForAction(actions[LC_EDIT_LOCK_TOGGLE]))->setPopupMode(QToolButton::InstantPopup); ((QToolButton*)standardToolBar->widgetForAction(actions[LC_EDIT_SNAP_TOGGLE]))->setPopupMode(QToolButton::InstantPopup); ((QToolButton*)standardToolBar->widgetForAction(actions[LC_EDIT_SNAP_ANGLE]))->setPopupMode(QToolButton::InstantPopup); + ((QToolButton*)standardToolBar->widgetForAction(actions[LC_EDIT_TRANSFORM]))->setPopupMode(QToolButton::InstantPopup); QHBoxLayout *transformLayout = new QHBoxLayout; QWidget *transformWidget = new QWidget(); diff --git a/qt/qtmain.cpp b/qt/qtmain.cpp index 5e2da3f6..10f88279 100644 --- a/qt/qtmain.cpp +++ b/qt/qtmain.cpp @@ -542,12 +542,14 @@ void lcMainWindow::UpdateUndoRedo(const char* UndoText, const char* RedoText) window->updateUndoRedo(UndoText, RedoText); } -void lcMainWindow::UpdateTransformType(int NewType) +void lcMainWindow::SetTransformType(lcTransformType TransformType) { lcQMainWindow* window = (lcQMainWindow*)mHandle; + mTransformType = TransformType; + if (window) - window->updateTransformType(NewType); + window->updateTransformType(TransformType); } void lcMainWindow::UpdateCameraMenu()