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);
|
||||
*/
|
||||
|
||||
lcGetActiveProject()->UpdateAllViews();
|
||||
gMainWindow->UpdateAllViews();
|
||||
}
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
#include "lc_mainwindow.h"
|
||||
#include "lc_profile.h"
|
||||
#include "preview.h"
|
||||
#include "view.h"
|
||||
|
||||
lcMainWindow* gMainWindow;
|
||||
|
||||
lcMainWindow::lcMainWindow()
|
||||
{
|
||||
mColorIndex = 0;
|
||||
mActiveView = NULL;
|
||||
mPreviewWidget = NULL;
|
||||
|
||||
for (int FileIdx = 0; FileIdx < LC_MAX_RECENT_FILES; FileIdx++)
|
||||
|
@ -24,6 +25,45 @@ lcMainWindow::~lcMainWindow()
|
|||
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)
|
||||
{
|
||||
mColorIndex = ColorIndex;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "lc_basewindow.h"
|
||||
#include "lc_array.h"
|
||||
|
||||
class View;
|
||||
class PiecePreview;
|
||||
|
||||
#define LC_MAX_RECENT_FILES 4
|
||||
|
@ -14,6 +15,21 @@ class lcMainWindow : public lcBaseWindow
|
|||
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 Close();
|
||||
|
||||
|
@ -39,8 +55,8 @@ class lcMainWindow : public lcBaseWindow
|
|||
void UpdateUndoRedo(const char* UndoText, const char* RedoText);
|
||||
void UpdateTransformType(int NewType);
|
||||
void UpdateCurrentCamera(int CameraIndex);
|
||||
void UpdatePerspective(View* view);
|
||||
void UpdateCameraMenu(const lcArray<Camera*>& Cameras, Camera* CurrentCamera);
|
||||
void UpdatePerspective();
|
||||
void UpdateCameraMenu();
|
||||
void UpdateCategories();
|
||||
void UpdateTitle(const char* Title, bool Modified);
|
||||
void UpdateModified(bool Modified);
|
||||
|
@ -52,6 +68,10 @@ class lcMainWindow : public lcBaseWindow
|
|||
char mRecentFiles[LC_MAX_RECENT_FILES][LC_MAXPATH];
|
||||
PiecePreview* mPreviewWidget;
|
||||
int mColorIndex;
|
||||
|
||||
protected:
|
||||
View* mActiveView;
|
||||
lcArray<View*> mViews;
|
||||
};
|
||||
|
||||
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 EndPieceDrop(bool Accept);
|
||||
void BeginColorDrop();
|
||||
void RenderInitialize();
|
||||
|
||||
void GetPiecesUsed(lcArray<lcPiecesUsedEntry>& PiecesUsed) const;
|
||||
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 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
|
||||
lcArray<Piece*> mPieces;
|
||||
lcArray<Camera*> mCameras;
|
||||
|
@ -310,9 +302,6 @@ public:
|
|||
bool m_bModified;
|
||||
|
||||
protected:
|
||||
View* m_ActiveView;
|
||||
lcArray<View*> m_ViewList;
|
||||
|
||||
// Piece library
|
||||
TexFont* m_pScreenFont;
|
||||
|
||||
|
@ -359,7 +348,6 @@ protected:
|
|||
void RenderViewports(View* view);
|
||||
void RenderOverlays(View* view);
|
||||
|
||||
void RenderInitialize();
|
||||
void CreateHTMLPieceList(FILE* f, int nStep, bool bImages, const char* ext);
|
||||
void Export3DStudio();
|
||||
void ExportPOVRay(lcFile& File);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "lc_global.h"
|
||||
#include <stdlib.h>
|
||||
#include "lc_mainwindow.h"
|
||||
#include "project.h"
|
||||
#include "camera.h"
|
||||
#include "view.h"
|
||||
|
@ -12,16 +13,17 @@ View::View(Project *project)
|
|||
mCamera = NULL;
|
||||
m_OverlayScale = 1.0f;
|
||||
|
||||
if (project->GetActiveView())
|
||||
SetCamera(project->GetActiveView()->mCamera, false);
|
||||
View* ActiveView = gMainWindow->GetActiveView();
|
||||
if (ActiveView)
|
||||
SetCamera(ActiveView->mCamera, false);
|
||||
else
|
||||
SetDefaultCamera();
|
||||
}
|
||||
|
||||
View::~View()
|
||||
{
|
||||
if (m_Project != NULL)
|
||||
m_Project->RemoveView(this);
|
||||
if (gMainWindow)
|
||||
gMainWindow->RemoveView(this);
|
||||
|
||||
if (mCamera && mCamera->IsSimple())
|
||||
delete mCamera;
|
||||
|
@ -238,7 +240,7 @@ void View::OnDraw()
|
|||
|
||||
void View::OnInitialUpdate()
|
||||
{
|
||||
m_Project->AddView(this);
|
||||
gMainWindow->AddView(this);
|
||||
}
|
||||
|
||||
void View::OnUpdateCursor()
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define _VIEW_H_
|
||||
|
||||
#include "lc_glwidget.h"
|
||||
#include "camera.h"
|
||||
|
||||
class Project;
|
||||
|
||||
|
|
|
@ -807,7 +807,7 @@ void lcQMainWindow::print(QPrinter *printer)
|
|||
float aspectRatio = (float)stepWidth / (float)stepHeight;
|
||||
|
||||
View view(project);
|
||||
view.SetCamera(project->GetActiveView()->mCamera, false);
|
||||
view.SetCamera(gMainWindow->GetActiveView()->mCamera, false);
|
||||
view.mWidth = tileWidth;
|
||||
view.mHeight = tileHeight;
|
||||
view.SetContext(piecePreview->widget->mContext);
|
||||
|
@ -1219,8 +1219,10 @@ void lcQMainWindow::updateTransformType(int 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;
|
||||
|
||||
for (actionIdx = LC_VIEW_CAMERA_FIRST; actionIdx <= LC_VIEW_CAMERA_LAST; actionIdx++)
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
void updateSnap();
|
||||
void updateUndoRedo(const char* undoText, const char* redoText);
|
||||
void updateTransformType(int newType);
|
||||
void updateCameraMenu(const lcArray<Camera*>& cameras, Camera* currentCamera);
|
||||
void updateCameraMenu();
|
||||
void updateCurrentCamera(int cameraIndex);
|
||||
void updatePerspective(View* view);
|
||||
void updateCategories();
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "lc_qmainwindow.h"
|
||||
#include "lc_qupdatedialog.h"
|
||||
#include "lc_mainwindow.h"
|
||||
#include "view.h"
|
||||
#include <QApplication>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
|
@ -547,12 +548,12 @@ void lcMainWindow::UpdateTransformType(int NewType)
|
|||
window->updateTransformType(NewType);
|
||||
}
|
||||
|
||||
void lcMainWindow::UpdateCameraMenu(const lcArray<Camera*>& Cameras, Camera* CurrentCamera)
|
||||
void lcMainWindow::UpdateCameraMenu()
|
||||
{
|
||||
lcQMainWindow* window = (lcQMainWindow*)mHandle;
|
||||
|
||||
if (window)
|
||||
window->updateCameraMenu(Cameras, CurrentCamera);
|
||||
window->updateCameraMenu();
|
||||
}
|
||||
|
||||
void lcMainWindow::UpdateCurrentCamera(int CameraIndex)
|
||||
|
@ -563,12 +564,12 @@ void lcMainWindow::UpdateCurrentCamera(int CameraIndex)
|
|||
window->updateCurrentCamera(CameraIndex);
|
||||
}
|
||||
|
||||
void lcMainWindow::UpdatePerspective(View* view)
|
||||
void lcMainWindow::UpdatePerspective()
|
||||
{
|
||||
lcQMainWindow* window = (lcQMainWindow*)mHandle;
|
||||
|
||||
if (window)
|
||||
window->updatePerspective(view);
|
||||
window->updatePerspective(mActiveView);
|
||||
}
|
||||
|
||||
void lcMainWindow::UpdateCategories()
|
||||
|
|
Loading…
Reference in a new issue