mirror of
https://github.com/leozide/leocad
synced 2024-12-27 21:58:37 +01:00
102 lines
2 KiB
C++
102 lines
2 KiB
C++
#include "lc_global.h"
|
|
#include "lc_mainwindow.h"
|
|
#include "lc_profile.h"
|
|
#include "preview.h"
|
|
#include "view.h"
|
|
|
|
lcMainWindow* gMainWindow;
|
|
|
|
lcMainWindow::lcMainWindow()
|
|
{
|
|
mActiveView = NULL;
|
|
mPreviewWidget = NULL;
|
|
|
|
mAddKeys = false;
|
|
|
|
for (int FileIdx = 0; FileIdx < LC_MAX_RECENT_FILES; FileIdx++)
|
|
strcpy(mRecentFiles[FileIdx], lcGetProfileString((LC_PROFILE_KEY)(LC_PROFILE_RECENT_FILE1 + FileIdx)));
|
|
|
|
gMainWindow = this;
|
|
}
|
|
|
|
lcMainWindow::~lcMainWindow()
|
|
{
|
|
for (int FileIdx = 0; FileIdx < LC_MAX_RECENT_FILES; FileIdx++)
|
|
lcSetProfileString((LC_PROFILE_KEY)(LC_PROFILE_RECENT_FILE1 + FileIdx), mRecentFiles[FileIdx]);
|
|
|
|
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;
|
|
|
|
if (mPreviewWidget)
|
|
mPreviewWidget->Redraw();
|
|
}
|
|
|
|
void lcMainWindow::AddRecentFile(const char* FileName)
|
|
{
|
|
int FileIdx;
|
|
|
|
for (FileIdx = 0; FileIdx < LC_MAX_RECENT_FILES; FileIdx++)
|
|
if (!strcmp(mRecentFiles[FileIdx], FileName))
|
|
break;
|
|
|
|
for (FileIdx = lcMin(FileIdx, LC_MAX_RECENT_FILES - 1); FileIdx > 0; FileIdx--)
|
|
strcpy(mRecentFiles[FileIdx], mRecentFiles[FileIdx - 1]);
|
|
|
|
strcpy(mRecentFiles[0], FileName);
|
|
|
|
UpdateRecentFiles();
|
|
}
|
|
|
|
void lcMainWindow::RemoveRecentFile(int FileIndex)
|
|
{
|
|
for (int FileIdx = FileIndex; FileIdx < LC_MAX_RECENT_FILES - 1; FileIdx++)
|
|
strcpy(mRecentFiles[FileIdx], mRecentFiles[FileIdx + 1]);
|
|
|
|
mRecentFiles[LC_MAX_RECENT_FILES - 1][0] = 0;
|
|
|
|
UpdateRecentFiles();
|
|
}
|
|
|