Renamed view class.

This commit is contained in:
Leonardo Zide 2020-12-25 10:54:33 -08:00
parent 939e80ab4b
commit 7de5d4eb22
15 changed files with 170 additions and 175 deletions

View file

@ -795,7 +795,7 @@ bool lcApplication::Initialize(QList<QPair<QString, bool>>& LibraryPaths, bool&
if (!ModelName.isEmpty()) if (!ModelName.isEmpty())
mProject->SetActiveModel(ModelName); mProject->SetActiveModel(ModelName);
View* ActiveView = gMainWindow->GetActiveView(); lcView* ActiveView = gMainWindow->GetActiveView();
if (!CameraName.isEmpty()) if (!CameraName.isEmpty())
{ {
@ -1134,5 +1134,5 @@ void lcApplication::ShowPreferencesDialog()
*/ */
gMainWindow->SetShadingMode(Options.Preferences.mShadingMode); gMainWindow->SetShadingMode(Options.Preferences.mShadingMode);
View::UpdateAllViews(); lcView::UpdateAllViews();
} }

View file

@ -79,7 +79,7 @@ void lcModelTabWidget::Clear()
{ {
ResetLayout(); ResetLayout();
mModel = nullptr; mModel = nullptr;
for (View* View : mViews) for (lcView* View : mViews)
View->Clear(); View->Clear();
mViews.RemoveAll(); mViews.RemoveAll();
mActiveView = nullptr; mActiveView = nullptr;
@ -768,9 +768,9 @@ void lcMainWindow::CreateToolBars()
mPartsToolBar->raise(); mPartsToolBar->raise();
} }
View* lcMainWindow::CreateView(lcModel* Model) lcView* lcMainWindow::CreateView(lcModel* Model)
{ {
View* NewView = new View(lcViewType::View, Model); lcView* NewView = new lcView(lcViewType::View, Model);
connect(NewView, SIGNAL(CameraChanged()), this, SLOT(ViewCameraChanged())); connect(NewView, SIGNAL(CameraChanged()), this, SLOT(ViewCameraChanged()));
connect(NewView, SIGNAL(FocusReceived()), this, SLOT(ViewFocusReceived())); connect(NewView, SIGNAL(FocusReceived()), this, SLOT(ViewFocusReceived()));
@ -1012,7 +1012,7 @@ void lcMainWindow::UpdateGamepads()
if (!gMainWindow) if (!gMainWindow)
return; return;
View* ActiveView = GetActiveView(); lcView* ActiveView = GetActiveView();
if (!ActiveView) if (!ActiveView)
return; return;
@ -1138,7 +1138,7 @@ void lcMainWindow::ProjectFileChanged(const QString& Path)
QByteArray TabLayout = GetTabLayout(); QByteArray TabLayout = GetTabLayout();
gApplication->SetProject(NewProject); gApplication->SetProject(NewProject);
RestoreTabLayout(TabLayout); RestoreTabLayout(TabLayout);
View::UpdateAllViews(); lcView::UpdateAllViews();
} }
} }
else else
@ -1349,7 +1349,7 @@ void lcMainWindow::SetShadingMode(lcShadingMode ShadingMode)
UpdateShadingMode(); UpdateShadingMode();
View::UpdateAllViews(); lcView::UpdateAllViews();
if (mPartSelectionWidget) if (mPartSelectionWidget)
mPartSelectionWidget->Redraw(); mPartSelectionWidget->Redraw();
@ -1366,28 +1366,28 @@ void lcMainWindow::ToggleViewSphere()
{ {
lcGetPreferences().mViewSphereEnabled = !lcGetPreferences().mViewSphereEnabled; lcGetPreferences().mViewSphereEnabled = !lcGetPreferences().mViewSphereEnabled;
View::UpdateAllViews(); lcView::UpdateAllViews();
} }
void lcMainWindow::ToggleAxisIcon() void lcMainWindow::ToggleAxisIcon()
{ {
lcGetPreferences().mDrawAxes = !lcGetPreferences().mDrawAxes; lcGetPreferences().mDrawAxes = !lcGetPreferences().mDrawAxes;
View::UpdateAllViews(); lcView::UpdateAllViews();
} }
void lcMainWindow::ToggleGrid() void lcMainWindow::ToggleGrid()
{ {
lcGetPreferences().mGridEnabled = !lcGetPreferences().mGridEnabled; lcGetPreferences().mGridEnabled = !lcGetPreferences().mGridEnabled;
View::UpdateAllViews(); lcView::UpdateAllViews();
} }
void lcMainWindow::ToggleFadePreviousSteps() void lcMainWindow::ToggleFadePreviousSteps()
{ {
lcGetPreferences().mFadeSteps = !lcGetPreferences().mFadeSteps; lcGetPreferences().mFadeSteps = !lcGetPreferences().mFadeSteps;
View::UpdateAllViews(); lcView::UpdateAllViews();
} }
QByteArray lcMainWindow::GetTabLayout() QByteArray lcMainWindow::GetTabLayout()
@ -1410,7 +1410,7 @@ QByteArray lcMainWindow::GetTabLayout()
{ {
if (Widget->metaObject() == &lcViewWidget::staticMetaObject) if (Widget->metaObject() == &lcViewWidget::staticMetaObject)
{ {
View* CurrentView = (View*)((lcViewWidget*)Widget)->GetView(); lcView* CurrentView = ((lcViewWidget*)Widget)->GetView();
DataStream << (qint32)0; DataStream << (qint32)0;
DataStream << (qint32)(TabWidget->GetActiveView() == CurrentView ? 1 : 0); DataStream << (qint32)(TabWidget->GetActiveView() == CurrentView ? 1 : 0);
@ -1506,10 +1506,10 @@ void lcMainWindow::RestoreTabLayout(const QByteArray& TabLayout)
qint32 CameraType; qint32 CameraType;
DataStream >> CameraType; DataStream >> CameraType;
View* CurrentView = nullptr; lcView* CurrentView = nullptr;
if (ParentWidget) if (ParentWidget)
CurrentView = (View*)((lcViewWidget*)ParentWidget)->GetView(); CurrentView = ((lcViewWidget*)ParentWidget)->GetView();
if (CameraType == 0) if (CameraType == 0)
{ {
@ -1633,7 +1633,7 @@ void lcMainWindow::SetCurrentModelTab(lcModel* Model)
lcModelTabWidget* TabWidget; lcModelTabWidget* TabWidget;
lcViewWidget* ViewWidget; lcViewWidget* ViewWidget;
View* NewView; lcView* NewView;
if (!EmptyWidget) if (!EmptyWidget)
{ {
@ -1674,7 +1674,7 @@ void lcMainWindow::ResetCameras()
if (!CurrentTab) if (!CurrentTab)
return; return;
const lcArray<View*>* Views = CurrentTab->GetViews(); const lcArray<lcView*>* Views = CurrentTab->GetViews();
for (int ViewIdx = 0; ViewIdx < Views->GetSize(); ViewIdx++) for (int ViewIdx = 0; ViewIdx < Views->GetSize(); ViewIdx++)
(*Views)[ViewIdx]->SetDefaultCamera(); (*Views)[ViewIdx]->SetDefaultCamera();
@ -1682,7 +1682,7 @@ void lcMainWindow::ResetCameras()
lcGetActiveModel()->DeleteAllCameras(); lcGetActiveModel()->DeleteAllCameras();
} }
void lcMainWindow::AddView(View* View) void lcMainWindow::AddView(lcView* View)
{ {
lcModelTabWidget* TabWidget = GetTabWidgetForModel(View->GetModel()); lcModelTabWidget* TabWidget = GetTabWidgetForModel(View->GetModel());
@ -1698,7 +1698,7 @@ void lcMainWindow::AddView(View* View)
} }
} }
void lcMainWindow::RemoveView(View* View) void lcMainWindow::RemoveView(lcView* View)
{ {
lcModelTabWidget* TabWidget = GetTabForView(View); lcModelTabWidget* TabWidget = GetTabForView(View);
@ -1706,10 +1706,10 @@ void lcMainWindow::RemoveView(View* View)
TabWidget->RemoveView(View); TabWidget->RemoveView(View);
} }
void lcMainWindow::SetActiveView(View* ActiveView) void lcMainWindow::SetActiveView(lcView* ActiveView)
{ {
lcModelTabWidget* TabWidget = GetTabForView(ActiveView); lcModelTabWidget* TabWidget = GetTabForView(ActiveView);
View* CurrentActiveView = TabWidget->GetActiveView(); lcView* CurrentActiveView = TabWidget->GetActiveView();
if (!TabWidget || CurrentActiveView == ActiveView) if (!TabWidget || CurrentActiveView == ActiveView)
return; return;
@ -1732,7 +1732,7 @@ void lcMainWindow::SetTool(lcTool Tool)
if (Action) if (Action)
Action->setChecked(true); Action->setChecked(true);
View::UpdateAllViews(); lcView::UpdateAllViews();
} }
void lcMainWindow::SetColorIndex(int ColorIndex) void lcMainWindow::SetColorIndex(int ColorIndex)
@ -1779,7 +1779,7 @@ void lcMainWindow::SetRelativeTransform(bool RelativeTransform)
{ {
mRelativeTransform = RelativeTransform; mRelativeTransform = RelativeTransform;
UpdateLockSnap(); UpdateLockSnap();
View::UpdateAllViews(); lcView::UpdateAllViews();
} }
void lcMainWindow::SetLocalTransform(bool SelectionTransform) void lcMainWindow::SetLocalTransform(bool SelectionTransform)
@ -2179,14 +2179,14 @@ void lcMainWindow::UpdateUndoRedo(const QString& UndoText, const QString& RedoTe
void lcMainWindow::ViewFocusReceived() void lcMainWindow::ViewFocusReceived()
{ {
SetActiveView(dynamic_cast<View*>(sender())); SetActiveView(dynamic_cast<lcView*>(sender()));
} }
void lcMainWindow::ViewCameraChanged() void lcMainWindow::ViewCameraChanged()
{ {
View* _View = dynamic_cast<View*>(sender()); lcView* View = dynamic_cast<lcView*>(sender());
if (!_View || !_View->IsLastFocused()) if (!View || !View->IsLastFocused())
return; return;
UpdateCameraMenu(); UpdateCameraMenu();
@ -2195,7 +2195,7 @@ void lcMainWindow::ViewCameraChanged()
void lcMainWindow::UpdateCameraMenu() void lcMainWindow::UpdateCameraMenu()
{ {
const lcArray<lcCamera*>& Cameras = lcGetActiveModel()->GetCameras(); const lcArray<lcCamera*>& Cameras = lcGetActiveModel()->GetCameras();
View* ActiveView = GetActiveView(); lcView* ActiveView = GetActiveView();
const lcCamera* CurrentCamera = ActiveView ? ActiveView->GetCamera() : nullptr; const lcCamera* CurrentCamera = ActiveView ? ActiveView->GetCamera() : nullptr;
bool CurrentSet = false; bool CurrentSet = false;
@ -2227,7 +2227,7 @@ void lcMainWindow::UpdateCameraMenu()
void lcMainWindow::UpdatePerspective() void lcMainWindow::UpdatePerspective()
{ {
View* ActiveView = GetActiveView(); lcView* ActiveView = GetActiveView();
if (ActiveView) if (ActiveView)
{ {
@ -2401,7 +2401,7 @@ bool lcMainWindow::OpenProjectFile(const QString& FileName)
{ {
gApplication->SetProject(NewProject); gApplication->SetProject(NewProject);
AddRecentFile(FileName); AddRecentFile(FileName);
View::UpdateProjectViews(NewProject); lcView::UpdateProjectViews(NewProject);
return true; return true;
} }
@ -2457,7 +2457,7 @@ void lcMainWindow::ImportLDD()
if (NewProject->ImportLDD(LoadFileName)) if (NewProject->ImportLDD(LoadFileName))
{ {
gApplication->SetProject(NewProject); gApplication->SetProject(NewProject);
View::UpdateProjectViews(NewProject); lcView::UpdateProjectViews(NewProject);
} }
else else
delete NewProject; delete NewProject;
@ -2477,7 +2477,7 @@ void lcMainWindow::ImportInventory()
if (NewProject->ImportInventory(Dialog.GetSetInventory(), Dialog.GetSetName(), Dialog.GetSetDescription())) if (NewProject->ImportInventory(Dialog.GetSetInventory(), Dialog.GetSetName(), Dialog.GetSetDescription()))
{ {
gApplication->SetProject(NewProject); gApplication->SetProject(NewProject);
View::UpdateProjectViews(NewProject); lcView::UpdateProjectViews(NewProject);
} }
else else
delete NewProject; delete NewProject;
@ -2588,13 +2588,13 @@ void lcMainWindow::SetModelFromSelection()
lcModel* lcMainWindow::GetActiveModel() const lcModel* lcMainWindow::GetActiveModel() const
{ {
View* ActiveView = GetActiveView(); lcView* ActiveView = GetActiveView();
return ActiveView ? ActiveView->GetActiveModel() : nullptr; return ActiveView ? ActiveView->GetActiveModel() : nullptr;
} }
void lcMainWindow::HandleCommand(lcCommandId CommandId) void lcMainWindow::HandleCommand(lcCommandId CommandId)
{ {
View* ActiveView = GetActiveView(); lcView* ActiveView = GetActiveView();
lcModel* ActiveModel = ActiveView ? ActiveView->GetActiveModel() : nullptr; lcModel* ActiveModel = ActiveView ? ActiveView->GetActiveModel() : nullptr;
switch (CommandId) switch (CommandId)

View file

@ -6,7 +6,6 @@
#include "lc_commands.h" #include "lc_commands.h"
#include "lc_model.h" #include "lc_model.h"
class View;
class lcPartSelectionWidget; class lcPartSelectionWidget;
class lcPreviewDockWidget; class lcPreviewDockWidget;
class PiecePreview; class PiecePreview;
@ -84,22 +83,22 @@ public:
return Widget; return Widget;
} }
View* GetActiveView() const lcView* GetActiveView() const
{ {
return mActiveView; return mActiveView;
} }
void SetActiveView(View* ActiveView) void SetActiveView(lcView* ActiveView)
{ {
mActiveView = ActiveView; mActiveView = ActiveView;
} }
void AddView(View* View) void AddView(lcView* View)
{ {
mViews.Add(View); mViews.Add(View);
} }
void RemoveView(View* View) void RemoveView(lcView* View)
{ {
if (View == mActiveView) if (View == mActiveView)
mActiveView = nullptr; mActiveView = nullptr;
@ -117,15 +116,15 @@ public:
mModel = Model; mModel = Model;
} }
const lcArray<View*>* GetViews() const const lcArray<lcView*>* GetViews() const
{ {
return &mViews; return &mViews;
} }
protected: protected:
lcModel* mModel; lcModel* mModel;
View* mActiveView; lcView* mActiveView;
lcArray<View*> mViews; lcArray<lcView*> mViews;
}; };
class lcMainWindow : public QMainWindow class lcMainWindow : public QMainWindow
@ -208,7 +207,7 @@ public:
return mCurrentPieceInfo; return mCurrentPieceInfo;
} }
View* GetActiveView() const lcView* GetActiveView() const
{ {
const lcModelTabWidget* const CurrentTab = mModelTabWidget ? (lcModelTabWidget*)mModelTabWidget->currentWidget() : nullptr; const lcModelTabWidget* const CurrentTab = mModelTabWidget ? (lcModelTabWidget*)mModelTabWidget->currentWidget() : nullptr;
return CurrentTab ? CurrentTab->GetActiveView() : nullptr; return CurrentTab ? CurrentTab->GetActiveView() : nullptr;
@ -222,13 +221,13 @@ public:
return CurrentTab ? CurrentTab->GetModel() : nullptr; return CurrentTab ? CurrentTab->GetModel() : nullptr;
} }
const lcArray<View*>* GetViewsForModel(const lcModel* Model) const const lcArray<lcView*>* GetViewsForModel(const lcModel* Model) const
{ {
const lcModelTabWidget* const TabWidget = GetTabWidgetForModel(Model); const lcModelTabWidget* const TabWidget = GetTabWidgetForModel(Model);
return TabWidget ? TabWidget->GetViews() : nullptr; return TabWidget ? TabWidget->GetViews() : nullptr;
} }
lcModelTabWidget* GetTabForView(View* View) const lcModelTabWidget* GetTabForView(lcView* View) const
{ {
for (int TabIdx = 0; TabIdx < mModelTabWidget->count(); TabIdx++) for (int TabIdx = 0; TabIdx < mModelTabWidget->count(); TabIdx++)
{ {
@ -283,8 +282,8 @@ public:
void CloseCurrentModelTab(); void CloseCurrentModelTab();
void SetCurrentModelTab(lcModel* Model); void SetCurrentModelTab(lcModel* Model);
void ResetCameras(); void ResetCameras();
void AddView(View* View); void AddView(lcView* View);
void RemoveView(View* View); void RemoveView(lcView* View);
void SetTool(lcTool Tool); void SetTool(lcTool Tool);
void SetTransformType(lcTransformType TransformType); void SetTransformType(lcTransformType TransformType);
@ -384,8 +383,8 @@ protected:
void CreateMenus(); void CreateMenus();
void CreateToolBars(); void CreateToolBars();
void CreateStatusBar(); void CreateStatusBar();
View* CreateView(lcModel* Model); lcView* CreateView(lcModel* Model);
void SetActiveView(View* ActiveView); void SetActiveView(lcView* ActiveView);
void ToggleDockWidget(QWidget* DockWidget); void ToggleDockWidget(QWidget* DockWidget);
void SplitView(Qt::Orientation Orientation); void SplitView(Qt::Orientation Orientation);
void ShowSearchDialog(); void ShowSearchDialog();

View file

@ -47,7 +47,7 @@ lcMinifigDialog::lcMinifigDialog(QWidget* Parent)
PreviewLayout->setContentsMargins(0, 0, 0, 0); PreviewLayout->setContentsMargins(0, 0, 0, 0);
mMinifigWizard = new MinifigWizard(); mMinifigWizard = new MinifigWizard();
mView = new View(lcViewType::Minifig, mMinifigWizard->GetModel()); mView = new lcView(lcViewType::Minifig, mMinifigWizard->GetModel());
lcViewWidget* ViewWidget = new lcViewWidget(nullptr, mView); lcViewWidget* ViewWidget = new lcViewWidget(nullptr, mView);
ViewWidget->setMinimumWidth(100); ViewWidget->setMinimumWidth(100);

View file

@ -2,9 +2,9 @@
#include "minifig.h" #include "minifig.h"
class lcQColorPicker; class lcQColorPicker;
class View;
namespace Ui { namespace Ui
{
class lcMinifigDialog; class lcMinifigDialog;
} }
@ -33,7 +33,7 @@ protected:
Ui::lcMinifigDialog* ui; Ui::lcMinifigDialog* ui;
View* mView; lcView* mView;
std::array<QComboBox*, LC_MFW_NUMITEMS> mComboBoxes; std::array<QComboBox*, LC_MFW_NUMITEMS> mComboBoxes;
std::array<lcQColorPicker*, LC_MFW_NUMITEMS> mColorPickers; std::array<lcQColorPicker*, LC_MFW_NUMITEMS> mColorPickers;
std::array<QDoubleSpinBox*, LC_MFW_NUMITEMS> mSpinBoxes; std::array<QDoubleSpinBox*, LC_MFW_NUMITEMS> mSpinBoxes;

View file

@ -193,14 +193,14 @@ void lcModel::DeleteModel()
{ {
if (gMainWindow) if (gMainWindow)
{ {
const lcArray<View*>* Views = gMainWindow->GetViewsForModel(this); const lcArray<lcView*>* Views = gMainWindow->GetViewsForModel(this);
// TODO: this is only needed to avoid a dangling pointer during undo/redo if a camera is set to a view but we should find a better solution instead // TODO: this is only needed to avoid a dangling pointer during undo/redo if a camera is set to a view but we should find a better solution instead
if (Views) if (Views)
{ {
for (int ViewIdx = 0; ViewIdx < Views->GetSize(); ViewIdx++) for (int ViewIdx = 0; ViewIdx < Views->GetSize(); ViewIdx++)
{ {
View* View = (*Views)[ViewIdx]; lcView* View = (*Views)[ViewIdx];
lcCamera* Camera = View->GetCamera(); lcCamera* Camera = View->GetCamera();
if (!Camera->IsSimple() && mCameras.FindIndex(Camera) != -1) if (!Camera->IsSimple() && mCameras.FindIndex(Camera) != -1)
@ -231,7 +231,7 @@ void lcModel::UpdateMesh()
void lcModel::UpdateAllViews() const void lcModel::UpdateAllViews() const
{ {
View::UpdateProjectViews(mProject); lcView::UpdateProjectViews(mProject);
} }
void lcModel::UpdatePieceInfo(std::vector<lcModel*>& UpdatedModels) void lcModel::UpdatePieceInfo(std::vector<lcModel*>& UpdatedModels)
@ -1266,7 +1266,7 @@ void lcModel::AddSubModelRenderMeshes(lcScene* Scene, const lcMatrix44& WorldMat
QImage lcModel::GetStepImage(bool Zoom, int Width, int Height, lcStep Step) QImage lcModel::GetStepImage(bool Zoom, int Width, int Height, lcStep Step)
{ {
View* ActiveView = gMainWindow->GetActiveView(); lcView* ActiveView = gMainWindow->GetActiveView();
ActiveView->MakeCurrent(); ActiveView->MakeCurrent();
lcContext* Context = ActiveView->mContext; lcContext* Context = ActiveView->mContext;
@ -1276,7 +1276,7 @@ QImage lcModel::GetStepImage(bool Zoom, int Width, int Height, lcStep Step)
if (Zoom) if (Zoom)
ZoomExtents(Camera, (float)Width / (float)Height); ZoomExtents(Camera, (float)Width / (float)Height);
View View(lcViewType::View, this); lcView View(lcViewType::View, this);
View.SetCamera(Camera, false); View.SetCamera(Camera, false);
View.SetContext(Context); View.SetContext(Context);
@ -1348,7 +1348,7 @@ QImage lcModel::GetPartsListImage(int MaxWidth, lcStep Step) const
std::sort(Images.begin(), Images.end(), ImageCompare); std::sort(Images.begin(), Images.end(), ImageCompare);
View* View = gMainWindow->GetActiveView(); lcView* View = gMainWindow->GetActiveView();
View->MakeCurrent(); View->MakeCurrent();
lcContext* Context = View->mContext; lcContext* Context = View->mContext;
const int ThumbnailSize = qMin(MaxWidth, 512); const int ThumbnailSize = qMin(MaxWidth, 512);
@ -2610,10 +2610,10 @@ bool lcModel::RemoveSelectedObjects()
if (Camera->IsSelected()) if (Camera->IsSelected())
{ {
const lcArray<View*>* Views = gMainWindow->GetViewsForModel(this); const lcArray<lcView*>* Views = gMainWindow->GetViewsForModel(this);
for (int ViewIdx = 0; ViewIdx < Views->GetSize(); ViewIdx++) for (int ViewIdx = 0; ViewIdx < Views->GetSize(); ViewIdx++)
{ {
View* View = (*Views)[ViewIdx]; lcView* View = (*Views)[ViewIdx];
if (Camera == View->GetCamera()) if (Camera == View->GetCamera())
View->SetCamera(Camera, true); View->SetCamera(Camera, true);
@ -4091,10 +4091,10 @@ void lcModel::EraserToolClicked(lcObject* Object)
case lcObjectType::Camera: case lcObjectType::Camera:
{ {
const lcArray<View*>* Views = gMainWindow->GetViewsForModel(this); const lcArray<lcView*>* Views = gMainWindow->GetViewsForModel(this);
for (int ViewIdx = 0; ViewIdx < Views->GetSize(); ViewIdx++) for (int ViewIdx = 0; ViewIdx < Views->GetSize(); ViewIdx++)
{ {
View* View = (*Views)[ViewIdx]; lcView* View = (*Views)[ViewIdx];
lcCamera* Camera = View->GetCamera(); lcCamera* Camera = View->GetCamera();
if (Camera == Object) if (Camera == Object)

View file

@ -387,7 +387,7 @@ void lcPartSelectionListModel::PartLoaded(PieceInfo* Info)
void lcPartSelectionListModel::DrawPreview(int InfoIndex) void lcPartSelectionListModel::DrawPreview(int InfoIndex)
{ {
View* ActiveView = gMainWindow->GetActiveView(); lcView* ActiveView = gMainWindow->GetActiveView();
if (!ActiveView) if (!ActiveView)
return; return;

View file

@ -83,7 +83,7 @@ void lcPreviewDockWidget::SetPreviewLock()
} }
lcPreview::lcPreview() lcPreview::lcPreview()
: View(lcViewType::Preview, nullptr), mLoader(new Project(true)) : lcView(lcViewType::Preview, nullptr), mLoader(new Project(true))
{ {
mLoader->SetActiveModel(0); mLoader->SetActiveModel(0);
mModel = mLoader->GetActiveModel(); mModel = mLoader->GetActiveModel();

View file

@ -26,7 +26,7 @@ protected:
lcViewWidget* mViewWidget; lcViewWidget* mViewWidget;
}; };
class lcPreview : public View class lcPreview : public lcView
{ {
public: public:
lcPreview(); lcPreview();

View file

@ -12,13 +12,13 @@
#include "lc_context.h" #include "lc_context.h"
#include "lc_viewsphere.h" #include "lc_viewsphere.h"
View* View::mLastFocusedView; lcView* lcView::mLastFocusedView;
std::vector<View*> View::mViews; std::vector<lcView*> lcView::mViews;
lcVertexBuffer View::mRotateMoveVertexBuffer; lcVertexBuffer lcView::mRotateMoveVertexBuffer;
lcIndexBuffer View::mRotateMoveIndexBuffer; lcIndexBuffer lcView::mRotateMoveIndexBuffer;
View::View(lcViewType ViewType, lcModel* Model) lcView::lcView(lcViewType ViewType, lcModel* Model)
: mScene(new lcScene()), mModel(Model), mViewType(ViewType) : mScene(new lcScene()), mModel(Model), mViewType(ViewType)
{ {
mContext = new lcContext(); mContext = new lcContext();
@ -30,14 +30,14 @@ View::View(lcViewType ViewType, lcModel* Model)
mDragState = lcDragState::None; mDragState = lcDragState::None;
mTrackToolFromOverlay = false; mTrackToolFromOverlay = false;
View* ActiveView = gMainWindow->GetActiveView(); lcView* ActiveView = gMainWindow->GetActiveView();
if (ActiveView) if (ActiveView)
SetCamera(ActiveView->mCamera, false); SetCamera(ActiveView->mCamera, false);
else else
SetDefaultCamera(); SetDefaultCamera();
} }
View::~View() lcView::~lcView()
{ {
mContext->DestroyVertexBuffer(mGridBuffer); mContext->DestroyVertexBuffer(mGridBuffer);
@ -56,9 +56,9 @@ View::~View()
delete mContext; delete mContext;
} }
void View::UpdateProjectViews(const Project* Project) void lcView::UpdateProjectViews(const Project* Project)
{ {
for (View* View : mViews) for (lcView* View : mViews)
{ {
const lcModel* ViewModel = View->GetActiveModel(); const lcModel* ViewModel = View->GetActiveModel();
@ -67,23 +67,23 @@ void View::UpdateProjectViews(const Project* Project)
} }
} }
void View::UpdateAllViews() void lcView::UpdateAllViews()
{ {
for (View* View : mViews) for (lcView* View : mViews)
View->Redraw(); View->Redraw();
} }
void View::MakeCurrent() void lcView::MakeCurrent()
{ {
mWidget->makeCurrent(); mWidget->makeCurrent();
} }
void View::Redraw() void lcView::Redraw()
{ {
mWidget->update(); mWidget->update();
} }
void View::SetContext(lcContext* Context) void lcView::SetContext(lcContext* Context)
{ {
if (mDeleteContext) if (mDeleteContext)
delete mContext; delete mContext;
@ -92,7 +92,7 @@ void View::SetContext(lcContext* Context)
mDeleteContext = false; mDeleteContext = false;
} }
void View::SetFocus(bool Focus) void lcView::SetFocus(bool Focus)
{ {
if (Focus) if (Focus)
{ {
@ -102,23 +102,23 @@ void View::SetFocus(bool Focus)
} }
} }
void View::SetMousePosition(int MouseX, int MouseY) void lcView::SetMousePosition(int MouseX, int MouseY)
{ {
mMouseX = MouseX; mMouseX = MouseX;
mMouseY = MouseY; mMouseY = MouseY;
} }
void View::SetMouseModifiers(Qt::KeyboardModifiers MouseModifiers) void lcView::SetMouseModifiers(Qt::KeyboardModifiers MouseModifiers)
{ {
mMouseModifiers = MouseModifiers; mMouseModifiers = MouseModifiers;
} }
lcModel* View::GetActiveModel() const lcModel* lcView::GetActiveModel() const
{ {
return !mActiveSubmodelInstance ? mModel : mActiveSubmodelInstance->mPieceInfo->GetModel(); return !mActiveSubmodelInstance ? mModel : mActiveSubmodelInstance->mPieceInfo->GetModel();
} }
void View::SetTopSubmodelActive() void lcView::SetTopSubmodelActive()
{ {
lcModel* ActiveModel = GetActiveModel(); lcModel* ActiveModel = GetActiveModel();
@ -131,7 +131,7 @@ void View::SetTopSubmodelActive()
GetActiveModel()->UpdateInterface(); GetActiveModel()->UpdateInterface();
} }
void View::SetSelectedSubmodelActive() void lcView::SetSelectedSubmodelActive()
{ {
lcModel* ActiveModel = GetActiveModel(); lcModel* ActiveModel = GetActiveModel();
lcObject* Object = ActiveModel->GetFocusObject(); lcObject* Object = ActiveModel->GetFocusObject();
@ -160,7 +160,7 @@ void View::SetSelectedSubmodelActive()
GetActiveModel()->UpdateInterface(); GetActiveModel()->UpdateInterface();
} }
void View::CreateResources(lcContext* Context) void lcView::CreateResources(lcContext* Context)
{ {
gGridTexture = new lcTexture; gGridTexture = new lcTexture;
gGridTexture->CreateGridTexture(); gGridTexture->CreateGridTexture();
@ -168,7 +168,7 @@ void View::CreateResources(lcContext* Context)
CreateSelectMoveOverlayMesh(Context); CreateSelectMoveOverlayMesh(Context);
} }
void View::CreateSelectMoveOverlayMesh(lcContext* Context) void lcView::CreateSelectMoveOverlayMesh(lcContext* Context)
{ {
float Verts[(51 + 138 + 10) * 3]; float Verts[(51 + 138 + 10) * 3];
float* CurVert = Verts; float* CurVert = Verts;
@ -314,7 +314,7 @@ void View::CreateSelectMoveOverlayMesh(lcContext* Context)
mRotateMoveIndexBuffer = Context->CreateIndexBuffer(sizeof(Indices), Indices); mRotateMoveIndexBuffer = Context->CreateIndexBuffer(sizeof(Indices), Indices);
} }
void View::DestroyResources(lcContext* Context) void lcView::DestroyResources(lcContext* Context)
{ {
delete gGridTexture; delete gGridTexture;
gGridTexture = nullptr; gGridTexture = nullptr;
@ -323,7 +323,7 @@ void View::DestroyResources(lcContext* Context)
Context->DestroyIndexBuffer(mRotateMoveIndexBuffer); Context->DestroyIndexBuffer(mRotateMoveIndexBuffer);
} }
void View::RemoveCamera() void lcView::RemoveCamera()
{ {
if (mCamera && mCamera->IsSimple()) if (mCamera && mCamera->IsSimple())
return; return;
@ -340,25 +340,25 @@ void View::RemoveCamera()
Redraw(); Redraw();
} }
lcVector3 View::ProjectPoint(const lcVector3& Point) const lcVector3 lcView::ProjectPoint(const lcVector3& Point) const
{ {
int Viewport[4] = { 0, 0, mWidth, mHeight }; int Viewport[4] = { 0, 0, mWidth, mHeight };
return lcProjectPoint(Point, mCamera->mWorldView, GetProjectionMatrix(), Viewport); return lcProjectPoint(Point, mCamera->mWorldView, GetProjectionMatrix(), Viewport);
} }
lcVector3 View::UnprojectPoint(const lcVector3& Point) const lcVector3 lcView::UnprojectPoint(const lcVector3& Point) const
{ {
int Viewport[4] = { 0, 0, mWidth, mHeight }; int Viewport[4] = { 0, 0, mWidth, mHeight };
return lcUnprojectPoint(Point, mCamera->mWorldView, GetProjectionMatrix(), Viewport); return lcUnprojectPoint(Point, mCamera->mWorldView, GetProjectionMatrix(), Viewport);
} }
void View::UnprojectPoints(lcVector3* Points, int NumPoints) const void lcView::UnprojectPoints(lcVector3* Points, int NumPoints) const
{ {
int Viewport[4] = { 0, 0, mWidth, mHeight }; int Viewport[4] = { 0, 0, mWidth, mHeight };
lcUnprojectPoints(Points, NumPoints, mCamera->mWorldView, GetProjectionMatrix(), Viewport); lcUnprojectPoints(Points, NumPoints, mCamera->mWorldView, GetProjectionMatrix(), Viewport);
} }
lcMatrix44 View::GetProjectionMatrix() const lcMatrix44 lcView::GetProjectionMatrix() const
{ {
float AspectRatio = (float)mWidth / (float)mHeight; float AspectRatio = (float)mWidth / (float)mHeight;
@ -373,7 +373,7 @@ lcMatrix44 View::GetProjectionMatrix() const
return lcMatrix44Perspective(mCamera->m_fovy, AspectRatio, mCamera->m_zNear, mCamera->m_zFar); return lcMatrix44Perspective(mCamera->m_fovy, AspectRatio, mCamera->m_zNear, mCamera->m_zFar);
} }
lcMatrix44 View::GetTileProjectionMatrix(int CurrentRow, int CurrentColumn, int CurrentTileWidth, int CurrentTileHeight) const lcMatrix44 lcView::GetTileProjectionMatrix(int CurrentRow, int CurrentColumn, int CurrentTileWidth, int CurrentTileHeight) const
{ {
int ImageWidth = mRenderImage.width(); int ImageWidth = mRenderImage.width();
int ImageHeight = mRenderImage.height(); int ImageHeight = mRenderImage.height();
@ -420,7 +420,7 @@ lcMatrix44 View::GetTileProjectionMatrix(int CurrentRow, int CurrentColumn, int
return lcMatrix44Frustum(Left, Right, Bottom, Top, Near, Far); return lcMatrix44Frustum(Left, Right, Bottom, Top, Near, Far);
} }
void View::ShowContextMenu() const void lcView::ShowContextMenu() const
{ {
QAction** Actions = gMainWindow->mActions; QAction** Actions = gMainWindow->mActions;
@ -463,7 +463,7 @@ void View::ShowContextMenu() const
delete Popup; delete Popup;
} }
lcVector3 View::GetMoveDirection(const lcVector3& Direction) const lcVector3 lcView::GetMoveDirection(const lcVector3& Direction) const
{ {
if (lcGetPreferences().mFixedAxes) if (lcGetPreferences().mFixedAxes)
return Direction; return Direction;
@ -511,7 +511,7 @@ lcVector3 View::GetMoveDirection(const lcVector3& Direction) const
return axis; return axis;
} }
lcMatrix44 View::GetPieceInsertPosition(bool IgnoreSelected, PieceInfo* Info) const lcMatrix44 lcView::GetPieceInsertPosition(bool IgnoreSelected, PieceInfo* Info) const
{ {
lcPiece* HitPiece = (lcPiece*)FindObjectUnderPointer(true, IgnoreSelected).Object; lcPiece* HitPiece = (lcPiece*)FindObjectUnderPointer(true, IgnoreSelected).Object;
lcModel* ActiveModel = GetActiveModel(); lcModel* ActiveModel = GetActiveModel();
@ -567,7 +567,7 @@ lcMatrix44 View::GetPieceInsertPosition(bool IgnoreSelected, PieceInfo* Info) co
return lcMatrix44Translation(UnprojectPoint(lcVector3((float)mMouseX, (float)mMouseY, 0.9f))); return lcMatrix44Translation(UnprojectPoint(lcVector3((float)mMouseX, (float)mMouseY, 0.9f)));
} }
lcVector3 View::GetCameraLightInsertPosition() const lcVector3 lcView::GetCameraLightInsertPosition() const
{ {
lcModel* ActiveModel = GetActiveModel(); lcModel* ActiveModel = GetActiveModel();
@ -593,7 +593,7 @@ lcVector3 View::GetCameraLightInsertPosition() const
return lcRayPointClosestPoint(Center, ClickPoints[0], ClickPoints[1]); return lcRayPointClosestPoint(Center, ClickPoints[0], ClickPoints[1]);
} }
void View::GetRayUnderPointer(lcVector3& Start, lcVector3& End) const void lcView::GetRayUnderPointer(lcVector3& Start, lcVector3& End) const
{ {
lcVector3 StartEnd[2] = lcVector3 StartEnd[2] =
{ {
@ -607,7 +607,7 @@ void View::GetRayUnderPointer(lcVector3& Start, lcVector3& End) const
End = StartEnd[1]; End = StartEnd[1];
} }
lcObjectSection View::FindObjectUnderPointer(bool PiecesOnly, bool IgnoreSelected) const lcObjectSection lcView::FindObjectUnderPointer(bool PiecesOnly, bool IgnoreSelected) const
{ {
lcVector3 StartEnd[2] = lcVector3 StartEnd[2] =
{ {
@ -643,7 +643,7 @@ lcObjectSection View::FindObjectUnderPointer(bool PiecesOnly, bool IgnoreSelecte
return ObjectRayTest.ObjectSection; return ObjectRayTest.ObjectSection;
} }
lcArray<lcObject*> View::FindObjectsInBox(float x1, float y1, float x2, float y2) const lcArray<lcObject*> lcView::FindObjectsInBox(float x1, float y1, float x2, float y2) const
{ {
float Left, Top, Bottom, Right; float Left, Top, Bottom, Right;
@ -713,7 +713,7 @@ lcArray<lcObject*> View::FindObjectsInBox(float x1, float y1, float x2, float y2
return ObjectBoxTest.Objects; return ObjectBoxTest.Objects;
} }
bool View::BeginRenderToImage(int Width, int Height) bool lcView::BeginRenderToImage(int Width, int Height)
{ {
GLint MaxTexture; GLint MaxTexture;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &MaxTexture); glGetIntegerv(GL_MAX_TEXTURE_SIZE, &MaxTexture);
@ -733,14 +733,14 @@ bool View::BeginRenderToImage(int Width, int Height)
return mRenderFramebuffer.first.IsValid(); return mRenderFramebuffer.first.IsValid();
} }
void View::EndRenderToImage() void lcView::EndRenderToImage()
{ {
mRenderImage = QImage(); mRenderImage = QImage();
mContext->DestroyRenderFramebuffer(mRenderFramebuffer); mContext->DestroyRenderFramebuffer(mRenderFramebuffer);
mContext->ClearFramebuffer(); mContext->ClearFramebuffer();
} }
void View::OnDraw() void lcView::OnDraw()
{ {
if (!mModel) if (!mModel)
return; return;
@ -891,7 +891,7 @@ void View::OnDraw()
mContext->ClearResources(); mContext->ClearResources();
} }
void View::DrawBackground() const void lcView::DrawBackground() const
{ {
const lcPreferences& Preferences = lcGetPreferences(); const lcPreferences& Preferences = lcGetPreferences();
@ -942,7 +942,7 @@ void View::DrawBackground() const
Context->SetDepthWrite(true); Context->SetDepthWrite(true);
} }
void View::DrawViewport() const void lcView::DrawViewport() const
{ {
mContext->SetWorldMatrix(lcMatrix44Identity()); mContext->SetWorldMatrix(lcMatrix44Identity());
mContext->SetViewMatrix(lcMatrix44Translation(lcVector3(0.375, 0.375, 0.0))); mContext->SetViewMatrix(lcMatrix44Translation(lcVector3(0.375, 0.375, 0.0)));
@ -983,7 +983,7 @@ void View::DrawViewport() const
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
} }
void View::DrawAxes() const void lcView::DrawAxes() const
{ {
// glClear(GL_DEPTH_BUFFER_BIT); // glClear(GL_DEPTH_BUFFER_BIT);
@ -1051,7 +1051,7 @@ void View::DrawAxes() const
glDisable(GL_BLEND); glDisable(GL_BLEND);
} }
void View::DrawSelectMoveOverlay() void lcView::DrawSelectMoveOverlay()
{ {
mContext->SetMaterial(lcMaterialType::UnlitColor); mContext->SetMaterial(lcMaterialType::UnlitColor);
mContext->SetViewMatrix(mCamera->mWorldView); mContext->SetViewMatrix(mCamera->mWorldView);
@ -1240,7 +1240,7 @@ void View::DrawSelectMoveOverlay()
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
} }
void View::DrawRotateOverlay() void lcView::DrawRotateOverlay()
{ {
const float OverlayScale = GetOverlayScale(); const float OverlayScale = GetOverlayScale();
const float OverlayRotateRadius = 2.0f; const float OverlayRotateRadius = 2.0f;
@ -1537,7 +1537,7 @@ void View::DrawRotateOverlay()
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
} }
void View::DrawSelectZoomRegionOverlay() void lcView::DrawSelectZoomRegionOverlay()
{ {
mContext->SetMaterial(lcMaterialType::UnlitColor); mContext->SetMaterial(lcMaterialType::UnlitColor);
mContext->SetWorldMatrix(lcMatrix44Identity()); mContext->SetWorldMatrix(lcMatrix44Identity());
@ -1616,7 +1616,7 @@ void View::DrawSelectZoomRegionOverlay()
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
} }
void View::DrawRotateViewOverlay() void lcView::DrawRotateViewOverlay()
{ {
int x, y, w, h; int x, y, w, h;
@ -1682,7 +1682,7 @@ void View::DrawRotateViewOverlay()
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
} }
void View::DrawGrid() void lcView::DrawGrid()
{ {
const lcPreferences& Preferences = lcGetPreferences(); const lcPreferences& Preferences = lcGetPreferences();
@ -1865,7 +1865,7 @@ void View::DrawGrid()
} }
} }
lcTrackTool View::GetOverrideTrackTool(Qt::MouseButton Button) const lcTrackTool lcView::GetOverrideTrackTool(Qt::MouseButton Button) const
{ {
if (mTrackToolFromOverlay) if (mTrackToolFromOverlay)
return lcTrackTool::None; return lcTrackTool::None;
@ -1899,7 +1899,7 @@ lcTrackTool View::GetOverrideTrackTool(Qt::MouseButton Button) const
return TrackToolFromTool[static_cast<int>(OverrideTool)]; return TrackToolFromTool[static_cast<int>(OverrideTool)];
} }
float View::GetOverlayScale() const float lcView::GetOverlayScale() const
{ {
lcVector3 OverlayCenter; lcVector3 OverlayCenter;
lcMatrix33 RelativeRotation; lcMatrix33 RelativeRotation;
@ -1914,13 +1914,13 @@ float View::GetOverlayScale() const
return Dist.Length() * 5.0f; return Dist.Length() * 5.0f;
} }
void View::BeginDrag(lcDragState DragState) void lcView::BeginDrag(lcDragState DragState)
{ {
mDragState = DragState; mDragState = DragState;
UpdateTrackTool(); UpdateTrackTool();
} }
void View::EndDrag(bool Accept) void lcView::EndDrag(bool Accept)
{ {
lcModel* ActiveModel = GetActiveModel(); lcModel* ActiveModel = GetActiveModel();
@ -1949,7 +1949,7 @@ void View::EndDrag(bool Accept)
ActiveModel->UpdateAllViews(); ActiveModel->UpdateAllViews();
} }
void View::SetViewpoint(lcViewpoint Viewpoint) void lcView::SetViewpoint(lcViewpoint Viewpoint)
{ {
if (!mCamera || !mCamera->IsSimple()) if (!mCamera || !mCamera->IsSimple())
{ {
@ -1968,7 +1968,7 @@ void View::SetViewpoint(lcViewpoint Viewpoint)
emit CameraChanged(); emit CameraChanged();
} }
void View::SetViewpoint(const lcVector3& Position) void lcView::SetViewpoint(const lcVector3& Position)
{ {
if (!mCamera || !mCamera->IsSimple()) if (!mCamera || !mCamera->IsSimple())
{ {
@ -1987,7 +1987,7 @@ void View::SetViewpoint(const lcVector3& Position)
emit CameraChanged(); emit CameraChanged();
} }
void View::SetViewpoint(const lcVector3& Position, const lcVector3& Target, const lcVector3& Up) void lcView::SetViewpoint(const lcVector3& Position, const lcVector3& Target, const lcVector3& Up)
{ {
if (!mCamera || !mCamera->IsSimple()) if (!mCamera || !mCamera->IsSimple())
{ {
@ -2005,7 +2005,7 @@ void View::SetViewpoint(const lcVector3& Position, const lcVector3& Target, cons
emit CameraChanged(); emit CameraChanged();
} }
void View::SetCameraAngles(float Latitude, float Longitude) void lcView::SetCameraAngles(float Latitude, float Longitude)
{ {
if (!mCamera || !mCamera->IsSimple()) if (!mCamera || !mCamera->IsSimple())
{ {
@ -2022,7 +2022,7 @@ void View::SetCameraAngles(float Latitude, float Longitude)
Redraw(); Redraw();
} }
void View::SetDefaultCamera() void lcView::SetDefaultCamera()
{ {
if (!mCamera || !mCamera->IsSimple()) if (!mCamera || !mCamera->IsSimple())
mCamera = new lcCamera(true); mCamera = new lcCamera(true);
@ -2032,7 +2032,7 @@ void View::SetDefaultCamera()
emit CameraChanged(); emit CameraChanged();
} }
void View::SetCamera(lcCamera* Camera, bool ForceCopy) void lcView::SetCamera(lcCamera* Camera, bool ForceCopy)
{ {
if (Camera->IsSimple() || ForceCopy) if (Camera->IsSimple() || ForceCopy)
{ {
@ -2050,7 +2050,7 @@ void View::SetCamera(lcCamera* Camera, bool ForceCopy)
} }
} }
void View::SetCamera(const QString& CameraName) void lcView::SetCamera(const QString& CameraName)
{ {
const lcArray<lcCamera*>& Cameras = mModel->GetCameras(); const lcArray<lcCamera*>& Cameras = mModel->GetCameras();
@ -2064,7 +2064,7 @@ void View::SetCamera(const QString& CameraName)
} }
} }
void View::SetCameraIndex(int Index) void lcView::SetCameraIndex(int Index)
{ {
const lcArray<lcCamera*>& Cameras = mModel->GetCameras(); const lcArray<lcCamera*>& Cameras = mModel->GetCameras();
@ -2078,7 +2078,7 @@ void View::SetCameraIndex(int Index)
Redraw(); Redraw();
} }
void View::SetProjection(bool Ortho) void lcView::SetProjection(bool Ortho)
{ {
if (mCamera->IsSimple()) if (mCamera->IsSimple())
{ {
@ -2095,35 +2095,35 @@ void View::SetProjection(bool Ortho)
} }
} }
void View::LookAt() void lcView::LookAt()
{ {
lcModel* ActiveModel = GetActiveModel(); lcModel* ActiveModel = GetActiveModel();
if (ActiveModel) if (ActiveModel)
ActiveModel->LookAt(mCamera); ActiveModel->LookAt(mCamera);
} }
void View::MoveCamera(const lcVector3& Direction) void lcView::MoveCamera(const lcVector3& Direction)
{ {
lcModel* ActiveModel = GetActiveModel(); lcModel* ActiveModel = GetActiveModel();
if (ActiveModel) if (ActiveModel)
ActiveModel->MoveCamera(mCamera, Direction); ActiveModel->MoveCamera(mCamera, Direction);
} }
void View::Zoom(float Amount) void lcView::Zoom(float Amount)
{ {
lcModel* ActiveModel = GetActiveModel(); lcModel* ActiveModel = GetActiveModel();
if (ActiveModel) if (ActiveModel)
ActiveModel->Zoom(mCamera, Amount); ActiveModel->Zoom(mCamera, Amount);
} }
void View::ZoomExtents() void lcView::ZoomExtents()
{ {
lcModel* ActiveModel = GetActiveModel(); lcModel* ActiveModel = GetActiveModel();
if (ActiveModel) if (ActiveModel)
ActiveModel->ZoomExtents(mCamera, (float)mWidth / (float)mHeight); ActiveModel->ZoomExtents(mCamera, (float)mWidth / (float)mHeight);
} }
lcCursor View::GetCursor() const lcCursor lcView::GetCursor() const
{ {
if (mTrackButton != lcTrackButton::None) if (mTrackButton != lcTrackButton::None)
return lcCursor::Hidden; return lcCursor::Hidden;
@ -2179,7 +2179,7 @@ lcCursor View::GetCursor() const
return lcCursor::Select; return lcCursor::Select;
} }
void View::SetCursor(lcCursor CursorType) void lcView::SetCursor(lcCursor CursorType)
{ {
if (mCursor == CursorType) if (mCursor == CursorType)
return; return;
@ -2235,12 +2235,12 @@ void View::SetCursor(lcCursor CursorType)
} }
} }
void View::UpdateCursor() void lcView::UpdateCursor()
{ {
SetCursor(GetCursor()); SetCursor(GetCursor());
} }
lcTool View::GetCurrentTool() const lcTool lcView::GetCurrentTool() const
{ {
constexpr lcTool ToolFromTrackTool[] = constexpr lcTool ToolFromTrackTool[] =
{ {
@ -2284,7 +2284,7 @@ lcTool View::GetCurrentTool() const
return lcTool::Select; return lcTool::Select;
} }
void View::UpdateTrackTool() void lcView::UpdateTrackTool()
{ {
if (mViewType != lcViewType::View) if (mViewType != lcViewType::View)
{ {
@ -2744,7 +2744,7 @@ void View::UpdateTrackTool()
ActiveModel->UpdateAllViews(); ActiveModel->UpdateAllViews();
} }
bool View::IsTrackToolAllowed(lcTrackTool TrackTool, quint32 AllowedTransforms) const bool lcView::IsTrackToolAllowed(lcTrackTool TrackTool, quint32 AllowedTransforms) const
{ {
switch (TrackTool) switch (TrackTool)
{ {
@ -2815,7 +2815,7 @@ bool View::IsTrackToolAllowed(lcTrackTool TrackTool, quint32 AllowedTransforms)
return false; return false;
} }
void View::StartOrbitTracking() void lcView::StartOrbitTracking()
{ {
mTrackTool = lcTrackTool::OrbitXY; mTrackTool = lcTrackTool::OrbitXY;
UpdateCursor(); UpdateCursor();
@ -2823,7 +2823,7 @@ void View::StartOrbitTracking()
} }
void View::StartTracking(lcTrackButton TrackButton) void lcView::StartTracking(lcTrackButton TrackButton)
{ {
mTrackButton = TrackButton; mTrackButton = TrackButton;
mTrackUpdated = false; mTrackUpdated = false;
@ -2884,7 +2884,7 @@ void View::StartTracking(lcTrackButton TrackButton)
UpdateCursor(); UpdateCursor();
} }
void View::StopTracking(bool Accept) void lcView::StopTracking(bool Accept)
{ {
if (mTrackButton == lcTrackButton::None) if (mTrackButton == lcTrackButton::None)
return; return;
@ -2974,7 +2974,7 @@ void View::StopTracking(bool Accept)
ActiveModel->UpdateAllViews(); ActiveModel->UpdateAllViews();
} }
void View::CancelTrackingOrClearSelection() void lcView::CancelTrackingOrClearSelection()
{ {
if (mTrackButton != lcTrackButton::None) if (mTrackButton != lcTrackButton::None)
StopTracking(false); StopTracking(false);
@ -2986,7 +2986,7 @@ void View::CancelTrackingOrClearSelection()
} }
} }
void View::OnButtonDown(lcTrackButton TrackButton) void lcView::OnButtonDown(lcTrackButton TrackButton)
{ {
lcModel* ActiveModel = GetActiveModel(); lcModel* ActiveModel = GetActiveModel();
@ -3095,7 +3095,7 @@ void View::OnButtonDown(lcTrackButton TrackButton)
} }
} }
void View::OnLeftButtonDown() void lcView::OnLeftButtonDown()
{ {
if (mTrackButton != lcTrackButton::None) if (mTrackButton != lcTrackButton::None)
{ {
@ -3117,7 +3117,7 @@ void View::OnLeftButtonDown()
OnButtonDown(lcTrackButton::Left); OnButtonDown(lcTrackButton::Left);
} }
void View::OnLeftButtonUp() void lcView::OnLeftButtonUp()
{ {
StopTracking(mTrackButton == lcTrackButton::Left); StopTracking(mTrackButton == lcTrackButton::Left);
@ -3125,7 +3125,7 @@ void View::OnLeftButtonUp()
return; return;
} }
void View::OnLeftButtonDoubleClick() void lcView::OnLeftButtonDoubleClick()
{ {
lcObjectSection ObjectSection = FindObjectUnderPointer(false, false); lcObjectSection ObjectSection = FindObjectUnderPointer(false, false);
lcModel* ActiveModel = GetActiveModel(); lcModel* ActiveModel = GetActiveModel();
@ -3138,7 +3138,7 @@ void View::OnLeftButtonDoubleClick()
ActiveModel->ClearSelectionAndSetFocus(ObjectSection, true); ActiveModel->ClearSelectionAndSetFocus(ObjectSection, true);
} }
void View::OnMiddleButtonDown() void lcView::OnMiddleButtonDown()
{ {
if (mTrackButton != lcTrackButton::None) if (mTrackButton != lcTrackButton::None)
{ {
@ -3158,12 +3158,12 @@ void View::OnMiddleButtonDown()
OnButtonDown(lcTrackButton::Middle); OnButtonDown(lcTrackButton::Middle);
} }
void View::OnMiddleButtonUp() void lcView::OnMiddleButtonUp()
{ {
StopTracking(mTrackButton == lcTrackButton::Middle); StopTracking(mTrackButton == lcTrackButton::Middle);
} }
void View::OnRightButtonDown() void lcView::OnRightButtonDown()
{ {
if (mTrackButton != lcTrackButton::None) if (mTrackButton != lcTrackButton::None)
{ {
@ -3182,7 +3182,7 @@ void View::OnRightButtonDown()
OnButtonDown(lcTrackButton::Right); OnButtonDown(lcTrackButton::Right);
} }
void View::OnRightButtonUp() void lcView::OnRightButtonUp()
{ {
bool ShowMenu = mTrackButton == lcTrackButton::None || !mTrackUpdated; bool ShowMenu = mTrackButton == lcTrackButton::None || !mTrackUpdated;
@ -3193,25 +3193,25 @@ void View::OnRightButtonUp()
ShowContextMenu(); ShowContextMenu();
} }
void View::OnBackButtonDown() void lcView::OnBackButtonDown()
{ {
} }
void View::OnBackButtonUp() void lcView::OnBackButtonUp()
{ {
gMainWindow->HandleCommand(LC_VIEW_TIME_PREVIOUS); gMainWindow->HandleCommand(LC_VIEW_TIME_PREVIOUS);
} }
void View::OnForwardButtonDown() void lcView::OnForwardButtonDown()
{ {
} }
void View::OnForwardButtonUp() void lcView::OnForwardButtonUp()
{ {
gMainWindow->HandleCommand(LC_VIEW_TIME_NEXT); gMainWindow->HandleCommand(LC_VIEW_TIME_NEXT);
} }
void View::OnMouseMove() void lcView::OnMouseMove()
{ {
lcModel* ActiveModel = GetActiveModel(); lcModel* ActiveModel = GetActiveModel();
@ -3549,7 +3549,7 @@ void View::OnMouseMove()
} }
} }
void View::OnMouseWheel(float Direction) void lcView::OnMouseWheel(float Direction)
{ {
mModel->Zoom(mCamera, (int)(((mMouseModifiers & Qt::ControlModifier) ? 100 : 10) * Direction)); mModel->Zoom(mCamera, (int)(((mMouseModifiers & Qt::ControlModifier) ? 100 : 10) * Direction));
} }

View file

@ -89,16 +89,16 @@ enum class lcViewType
Count Count
}; };
class View : public QObject class lcView : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
View(lcViewType ViewType, lcModel* Model); lcView(lcViewType ViewType, lcModel* Model);
~View(); ~lcView();
View(const View&) = delete; lcView(const lcView&) = delete;
View& operator=(const View&) = delete; lcView& operator=(const lcView&) = delete;
void Clear() void Clear()
{ {
@ -311,8 +311,8 @@ protected:
lcVertexBuffer mGridBuffer; lcVertexBuffer mGridBuffer;
int mGridSettings[7]; int mGridSettings[7];
static View* mLastFocusedView; static lcView* mLastFocusedView;
static std::vector<View*> mViews; static std::vector<lcView*> mViews;
static lcVertexBuffer mRotateMoveVertexBuffer; static lcVertexBuffer mRotateMoveVertexBuffer;
static lcIndexBuffer mRotateMoveIndexBuffer; static lcIndexBuffer mRotateMoveIndexBuffer;

View file

@ -15,7 +15,7 @@ const float lcViewSphere::mRadius = 1.0f;
const float lcViewSphere::mHighlightRadius = 0.35f; const float lcViewSphere::mHighlightRadius = 0.35f;
const int lcViewSphere::mSubdivisions = 7; const int lcViewSphere::mSubdivisions = 7;
lcViewSphere::lcViewSphere(View* View) lcViewSphere::lcViewSphere(lcView* View)
: mView(View) : mView(View)
{ {
UpdateSettings(); UpdateSettings();

View file

@ -4,8 +4,6 @@
#include "lc_context.h" #include "lc_context.h"
#include <bitset> #include <bitset>
class View;
enum class lcViewSphereLocation enum class lcViewSphereLocation
{ {
TopLeft, TopLeft,
@ -17,7 +15,7 @@ enum class lcViewSphereLocation
class lcViewSphere class lcViewSphere
{ {
public: public:
lcViewSphere(View* View); lcViewSphere(lcView* View);
void Draw(); void Draw();
bool OnMouseMove(); bool OnMouseMove();
@ -34,7 +32,7 @@ protected:
lcMatrix44 GetProjectionMatrix() const; lcMatrix44 GetProjectionMatrix() const;
std::bitset<6> GetIntersectionFlags(lcVector3& Intersection) const; std::bitset<6> GetIntersectionFlags(lcVector3& Intersection) const;
View* const mView = nullptr; lcView* const mView = nullptr;
int mSize = 1; int mSize = 1;
bool mEnabled = false; bool mEnabled = false;

View file

@ -18,7 +18,7 @@
static QList<lcViewWidget*> gWidgetList; static QList<lcViewWidget*> gWidgetList;
lcViewWidget::lcViewWidget(QWidget* Parent, View* View) lcViewWidget::lcViewWidget(QWidget* Parent, lcView* View)
: QGLWidget(Parent, gWidgetList.isEmpty() ? nullptr : gWidgetList.first()) : QGLWidget(Parent, gWidgetList.isEmpty() ? nullptr : gWidgetList.first())
{ {
mWheelAccumulator = 0; mWheelAccumulator = 0;
@ -35,7 +35,7 @@ lcViewWidget::lcViewWidget(QWidget* Parent, View* View)
lcInitializeGLExtensions(context()); lcInitializeGLExtensions(context());
lcContext::CreateResources(); lcContext::CreateResources();
View::CreateResources(mView->mContext); lcView::CreateResources(mView->mContext);
lcViewSphere::CreateResources(mView->mContext); lcViewSphere::CreateResources(mView->mContext);
if (!gSupportsShaderObjects && lcGetPreferences().mShadingMode == lcShadingMode::DefaultLights) if (!gSupportsShaderObjects && lcGetPreferences().mShadingMode == lcShadingMode::DefaultLights)
@ -69,7 +69,7 @@ lcViewWidget::~lcViewWidget()
gTexFont.Reset(); gTexFont.Reset();
lcGetPiecesLibrary()->ReleaseBuffers(mView->mContext); lcGetPiecesLibrary()->ReleaseBuffers(mView->mContext);
View::DestroyResources(mView->mContext); lcView::DestroyResources(mView->mContext);
lcContext::DestroyResources(); lcContext::DestroyResources();
lcViewSphere::DestroyResources(mView->mContext); lcViewSphere::DestroyResources(mView->mContext);
@ -85,7 +85,7 @@ QSize lcViewWidget::sizeHint() const
return mPreferredSize.isEmpty() ? QGLWidget::sizeHint() : mPreferredSize; return mPreferredSize.isEmpty() ? QGLWidget::sizeHint() : mPreferredSize;
} }
void lcViewWidget::SetView(View* View) void lcViewWidget::SetView(lcView* View)
{ {
mView = View; mView = View;

View file

@ -1,19 +1,17 @@
#pragma once #pragma once
class View;
class lcViewWidget : public QGLWidget class lcViewWidget : public QGLWidget
{ {
public: public:
lcViewWidget(QWidget* Parent, View* View); lcViewWidget(QWidget* Parent, lcView* View);
~lcViewWidget(); ~lcViewWidget();
View* GetView() const lcView* GetView() const
{ {
return mView; return mView;
} }
void SetView(View* View); void SetView(lcView* View);
void SetPreviewPosition(const QRect& ParentRect); void SetPreviewPosition(const QRect& ParentRect);
QSize sizeHint() const override; QSize sizeHint() const override;
@ -44,7 +42,7 @@ protected:
void dragMoveEvent(QDragMoveEvent* DragMoveEvent) override; void dragMoveEvent(QDragMoveEvent* DragMoveEvent) override;
void dropEvent(QDropEvent* DropEvent) override; void dropEvent(QDropEvent* DropEvent) override;
View* mView; lcView* mView;
QSize mPreferredSize; QSize mPreferredSize;
int mWheelAccumulator; int mWheelAccumulator;
}; };