mirror of
https://github.com/leozide/leocad
synced 2025-01-17 18:11:42 +01:00
Moved view list to main window.
This commit is contained in:
parent
9292816f89
commit
fe2e759bc0
10 changed files with 298 additions and 287 deletions
|
@ -467,5 +467,5 @@ void lcApplication::ShowPreferencesDialog()
|
||||||
strcpy(opts.strHeader, m_strHeader);
|
strcpy(opts.strHeader, m_strHeader);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
lcGetActiveProject()->UpdateAllViews();
|
gMainWindow->UpdateAllViews();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,13 @@
|
||||||
#include "lc_mainwindow.h"
|
#include "lc_mainwindow.h"
|
||||||
#include "lc_profile.h"
|
#include "lc_profile.h"
|
||||||
#include "preview.h"
|
#include "preview.h"
|
||||||
|
#include "view.h"
|
||||||
|
|
||||||
lcMainWindow* gMainWindow;
|
lcMainWindow* gMainWindow;
|
||||||
|
|
||||||
lcMainWindow::lcMainWindow()
|
lcMainWindow::lcMainWindow()
|
||||||
{
|
{
|
||||||
mColorIndex = 0;
|
mActiveView = NULL;
|
||||||
mPreviewWidget = NULL;
|
mPreviewWidget = NULL;
|
||||||
|
|
||||||
for (int FileIdx = 0; FileIdx < LC_MAX_RECENT_FILES; FileIdx++)
|
for (int FileIdx = 0; FileIdx < LC_MAX_RECENT_FILES; FileIdx++)
|
||||||
|
@ -24,8 +25,47 @@ lcMainWindow::~lcMainWindow()
|
||||||
gMainWindow = NULL;
|
gMainWindow = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lcMainWindow::AddView(View* View)
|
||||||
|
{
|
||||||
|
mViews.Add(View);
|
||||||
|
|
||||||
|
View->MakeCurrent();
|
||||||
|
lcGetActiveProject()->RenderInitialize();
|
||||||
|
|
||||||
|
if (!mActiveView)
|
||||||
|
{
|
||||||
|
mActiveView = View;
|
||||||
|
UpdatePerspective();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcMainWindow::RemoveView(View* View)
|
||||||
|
{
|
||||||
|
if (View == mActiveView)
|
||||||
|
mActiveView = NULL;
|
||||||
|
|
||||||
|
mViews.Remove(View);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcMainWindow::SetActiveView(View* ActiveView)
|
||||||
|
{
|
||||||
|
if (mActiveView == ActiveView)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mActiveView = ActiveView;
|
||||||
|
|
||||||
|
UpdateCameraMenu();
|
||||||
|
UpdatePerspective();
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcMainWindow::UpdateAllViews()
|
||||||
|
{
|
||||||
|
for (int ViewIdx = 0; ViewIdx < mViews.GetSize(); ViewIdx++)
|
||||||
|
mViews[ViewIdx]->Redraw();
|
||||||
|
}
|
||||||
|
|
||||||
void lcMainWindow::SetColorIndex(int ColorIndex)
|
void lcMainWindow::SetColorIndex(int ColorIndex)
|
||||||
{
|
{
|
||||||
mColorIndex = ColorIndex;
|
mColorIndex = ColorIndex;
|
||||||
|
|
||||||
if (mPreviewWidget)
|
if (mPreviewWidget)
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "lc_basewindow.h"
|
#include "lc_basewindow.h"
|
||||||
#include "lc_array.h"
|
#include "lc_array.h"
|
||||||
|
|
||||||
|
class View;
|
||||||
class PiecePreview;
|
class PiecePreview;
|
||||||
|
|
||||||
#define LC_MAX_RECENT_FILES 4
|
#define LC_MAX_RECENT_FILES 4
|
||||||
|
@ -14,6 +15,21 @@ class lcMainWindow : public lcBaseWindow
|
||||||
lcMainWindow();
|
lcMainWindow();
|
||||||
~lcMainWindow();
|
~lcMainWindow();
|
||||||
|
|
||||||
|
View* GetActiveView() const
|
||||||
|
{
|
||||||
|
return mActiveView;
|
||||||
|
}
|
||||||
|
|
||||||
|
const lcArray<View*>& GetViews()
|
||||||
|
{
|
||||||
|
return mViews;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddView(View* View);
|
||||||
|
void RemoveView(View* View);
|
||||||
|
void SetActiveView(View* ActiveView);
|
||||||
|
void UpdateAllViews();
|
||||||
|
|
||||||
void SetColorIndex(int ColorIndex);
|
void SetColorIndex(int ColorIndex);
|
||||||
void Close();
|
void Close();
|
||||||
|
|
||||||
|
@ -39,8 +55,8 @@ class lcMainWindow : public lcBaseWindow
|
||||||
void UpdateUndoRedo(const char* UndoText, const char* RedoText);
|
void UpdateUndoRedo(const char* UndoText, const char* RedoText);
|
||||||
void UpdateTransformType(int NewType);
|
void UpdateTransformType(int NewType);
|
||||||
void UpdateCurrentCamera(int CameraIndex);
|
void UpdateCurrentCamera(int CameraIndex);
|
||||||
void UpdatePerspective(View* view);
|
void UpdatePerspective();
|
||||||
void UpdateCameraMenu(const lcArray<Camera*>& Cameras, Camera* CurrentCamera);
|
void UpdateCameraMenu();
|
||||||
void UpdateCategories();
|
void UpdateCategories();
|
||||||
void UpdateTitle(const char* Title, bool Modified);
|
void UpdateTitle(const char* Title, bool Modified);
|
||||||
void UpdateModified(bool Modified);
|
void UpdateModified(bool Modified);
|
||||||
|
@ -52,6 +68,10 @@ class lcMainWindow : public lcBaseWindow
|
||||||
char mRecentFiles[LC_MAX_RECENT_FILES][LC_MAXPATH];
|
char mRecentFiles[LC_MAX_RECENT_FILES][LC_MAXPATH];
|
||||||
PiecePreview* mPreviewWidget;
|
PiecePreview* mPreviewWidget;
|
||||||
int mColorIndex;
|
int mColorIndex;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
View* mActiveView;
|
||||||
|
lcArray<View*> mViews;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern class lcMainWindow* gMainWindow;
|
extern class lcMainWindow* gMainWindow;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -273,6 +273,7 @@ public:
|
||||||
void OnPieceDropMove(int x, int y);
|
void OnPieceDropMove(int x, int y);
|
||||||
void EndPieceDrop(bool Accept);
|
void EndPieceDrop(bool Accept);
|
||||||
void BeginColorDrop();
|
void BeginColorDrop();
|
||||||
|
void RenderInitialize();
|
||||||
|
|
||||||
void GetPiecesUsed(lcArray<lcPiecesUsedEntry>& PiecesUsed) const;
|
void GetPiecesUsed(lcArray<lcPiecesUsedEntry>& PiecesUsed) const;
|
||||||
void CreateImages(Image* images, int width, int height, unsigned short from, unsigned short to, bool hilite);
|
void CreateImages(Image* images, int width, int height, unsigned short from, unsigned short to, bool hilite);
|
||||||
|
@ -289,15 +290,6 @@ public:
|
||||||
void RayTest(lcObjectRayTest& ObjectRayTest) const;
|
void RayTest(lcObjectRayTest& ObjectRayTest) const;
|
||||||
void BoxTest(lcObjectBoxTest& ObjectBoxTest) const;
|
void BoxTest(lcObjectBoxTest& ObjectBoxTest) const;
|
||||||
|
|
||||||
void AddView(View* view);
|
|
||||||
void RemoveView(View* view);
|
|
||||||
void UpdateAllViews();
|
|
||||||
bool SetActiveView(View* view);
|
|
||||||
View* GetActiveView() const
|
|
||||||
{
|
|
||||||
return m_ActiveView;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Objects
|
// Objects
|
||||||
lcArray<Piece*> mPieces;
|
lcArray<Piece*> mPieces;
|
||||||
lcArray<Camera*> mCameras;
|
lcArray<Camera*> mCameras;
|
||||||
|
@ -310,9 +302,6 @@ public:
|
||||||
bool m_bModified;
|
bool m_bModified;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
View* m_ActiveView;
|
|
||||||
lcArray<View*> m_ViewList;
|
|
||||||
|
|
||||||
// Piece library
|
// Piece library
|
||||||
TexFont* m_pScreenFont;
|
TexFont* m_pScreenFont;
|
||||||
|
|
||||||
|
@ -359,7 +348,6 @@ protected:
|
||||||
void RenderViewports(View* view);
|
void RenderViewports(View* view);
|
||||||
void RenderOverlays(View* view);
|
void RenderOverlays(View* view);
|
||||||
|
|
||||||
void RenderInitialize();
|
|
||||||
void CreateHTMLPieceList(FILE* f, int nStep, bool bImages, const char* ext);
|
void CreateHTMLPieceList(FILE* f, int nStep, bool bImages, const char* ext);
|
||||||
void Export3DStudio();
|
void Export3DStudio();
|
||||||
void ExportPOVRay(lcFile& File);
|
void ExportPOVRay(lcFile& File);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "lc_global.h"
|
#include "lc_global.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include "lc_mainwindow.h"
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
|
@ -12,16 +13,17 @@ View::View(Project *project)
|
||||||
mCamera = NULL;
|
mCamera = NULL;
|
||||||
m_OverlayScale = 1.0f;
|
m_OverlayScale = 1.0f;
|
||||||
|
|
||||||
if (project->GetActiveView())
|
View* ActiveView = gMainWindow->GetActiveView();
|
||||||
SetCamera(project->GetActiveView()->mCamera, false);
|
if (ActiveView)
|
||||||
|
SetCamera(ActiveView->mCamera, false);
|
||||||
else
|
else
|
||||||
SetDefaultCamera();
|
SetDefaultCamera();
|
||||||
}
|
}
|
||||||
|
|
||||||
View::~View()
|
View::~View()
|
||||||
{
|
{
|
||||||
if (m_Project != NULL)
|
if (gMainWindow)
|
||||||
m_Project->RemoveView(this);
|
gMainWindow->RemoveView(this);
|
||||||
|
|
||||||
if (mCamera && mCamera->IsSimple())
|
if (mCamera && mCamera->IsSimple())
|
||||||
delete mCamera;
|
delete mCamera;
|
||||||
|
@ -238,7 +240,7 @@ void View::OnDraw()
|
||||||
|
|
||||||
void View::OnInitialUpdate()
|
void View::OnInitialUpdate()
|
||||||
{
|
{
|
||||||
m_Project->AddView(this);
|
gMainWindow->AddView(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::OnUpdateCursor()
|
void View::OnUpdateCursor()
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define _VIEW_H_
|
#define _VIEW_H_
|
||||||
|
|
||||||
#include "lc_glwidget.h"
|
#include "lc_glwidget.h"
|
||||||
|
#include "camera.h"
|
||||||
|
|
||||||
class Project;
|
class Project;
|
||||||
|
|
||||||
|
|
|
@ -807,7 +807,7 @@ void lcQMainWindow::print(QPrinter *printer)
|
||||||
float aspectRatio = (float)stepWidth / (float)stepHeight;
|
float aspectRatio = (float)stepWidth / (float)stepHeight;
|
||||||
|
|
||||||
View view(project);
|
View view(project);
|
||||||
view.SetCamera(project->GetActiveView()->mCamera, false);
|
view.SetCamera(gMainWindow->GetActiveView()->mCamera, false);
|
||||||
view.mWidth = tileWidth;
|
view.mWidth = tileWidth;
|
||||||
view.mHeight = tileHeight;
|
view.mHeight = tileHeight;
|
||||||
view.SetContext(piecePreview->widget->mContext);
|
view.SetContext(piecePreview->widget->mContext);
|
||||||
|
@ -1219,8 +1219,10 @@ void lcQMainWindow::updateTransformType(int newType)
|
||||||
actions[LC_EDIT_TRANSFORM]->setIcon(QIcon(iconNames[newType]));
|
actions[LC_EDIT_TRANSFORM]->setIcon(QIcon(iconNames[newType]));
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcQMainWindow::updateCameraMenu(const lcArray<Camera*>& cameras, Camera* currentCamera)
|
void lcQMainWindow::updateCameraMenu()
|
||||||
{
|
{
|
||||||
|
const lcArray<Camera*>& cameras = lcGetActiveProject()->mCameras;
|
||||||
|
Camera* currentCamera = gMainWindow->GetActiveView()->mCamera;
|
||||||
int actionIdx, currentIndex = -1;
|
int actionIdx, currentIndex = -1;
|
||||||
|
|
||||||
for (actionIdx = LC_VIEW_CAMERA_FIRST; actionIdx <= LC_VIEW_CAMERA_LAST; actionIdx++)
|
for (actionIdx = LC_VIEW_CAMERA_FIRST; actionIdx <= LC_VIEW_CAMERA_LAST; actionIdx++)
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
void updateSnap();
|
void updateSnap();
|
||||||
void updateUndoRedo(const char* undoText, const char* redoText);
|
void updateUndoRedo(const char* undoText, const char* redoText);
|
||||||
void updateTransformType(int newType);
|
void updateTransformType(int newType);
|
||||||
void updateCameraMenu(const lcArray<Camera*>& cameras, Camera* currentCamera);
|
void updateCameraMenu();
|
||||||
void updateCurrentCamera(int cameraIndex);
|
void updateCurrentCamera(int cameraIndex);
|
||||||
void updatePerspective(View* view);
|
void updatePerspective(View* view);
|
||||||
void updateCategories();
|
void updateCategories();
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "lc_qmainwindow.h"
|
#include "lc_qmainwindow.h"
|
||||||
#include "lc_qupdatedialog.h"
|
#include "lc_qupdatedialog.h"
|
||||||
#include "lc_mainwindow.h"
|
#include "lc_mainwindow.h"
|
||||||
|
#include "view.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
@ -547,12 +548,12 @@ void lcMainWindow::UpdateTransformType(int NewType)
|
||||||
window->updateTransformType(NewType);
|
window->updateTransformType(NewType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcMainWindow::UpdateCameraMenu(const lcArray<Camera*>& Cameras, Camera* CurrentCamera)
|
void lcMainWindow::UpdateCameraMenu()
|
||||||
{
|
{
|
||||||
lcQMainWindow* window = (lcQMainWindow*)mHandle;
|
lcQMainWindow* window = (lcQMainWindow*)mHandle;
|
||||||
|
|
||||||
if (window)
|
if (window)
|
||||||
window->updateCameraMenu(Cameras, CurrentCamera);
|
window->updateCameraMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcMainWindow::UpdateCurrentCamera(int CameraIndex)
|
void lcMainWindow::UpdateCurrentCamera(int CameraIndex)
|
||||||
|
@ -563,12 +564,12 @@ void lcMainWindow::UpdateCurrentCamera(int CameraIndex)
|
||||||
window->updateCurrentCamera(CameraIndex);
|
window->updateCurrentCamera(CameraIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcMainWindow::UpdatePerspective(View* view)
|
void lcMainWindow::UpdatePerspective()
|
||||||
{
|
{
|
||||||
lcQMainWindow* window = (lcQMainWindow*)mHandle;
|
lcQMainWindow* window = (lcQMainWindow*)mHandle;
|
||||||
|
|
||||||
if (window)
|
if (window)
|
||||||
window->updatePerspective(view);
|
window->updatePerspective(mActiveView);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcMainWindow::UpdateCategories()
|
void lcMainWindow::UpdateCategories()
|
||||||
|
|
Loading…
Reference in a new issue