2012-03-20 01:57:42 +01:00
|
|
|
#include "lc_global.h"
|
2013-08-16 03:25:51 +02:00
|
|
|
#include "lc_mainwindow.h"
|
2013-08-09 06:57:18 +02:00
|
|
|
#include "lc_profile.h"
|
|
|
|
#include "preview.h"
|
2014-05-03 23:16:48 +02:00
|
|
|
#include "view.h"
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2013-08-09 06:57:18 +02:00
|
|
|
lcMainWindow* gMainWindow;
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2013-08-09 06:57:18 +02:00
|
|
|
lcMainWindow::lcMainWindow()
|
2014-05-03 23:16:48 +02:00
|
|
|
{
|
|
|
|
mActiveView = NULL;
|
2013-08-09 06:57:18 +02:00
|
|
|
mPreviewWidget = NULL;
|
2014-08-27 18:17:09 +02:00
|
|
|
mTransformType = LC_TRANSFORM_RELATIVE_TRANSLATION;
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2014-05-21 00:15:42 +02:00
|
|
|
mAddKeys = false;
|
2014-09-21 03:31:01 +02:00
|
|
|
memset(&mSearchOptions, 0, sizeof(mSearchOptions));
|
2014-05-21 00:15:42 +02:00
|
|
|
|
2013-08-09 06:57:18 +02:00
|
|
|
for (int FileIdx = 0; FileIdx < LC_MAX_RECENT_FILES; FileIdx++)
|
|
|
|
strcpy(mRecentFiles[FileIdx], lcGetProfileString((LC_PROFILE_KEY)(LC_PROFILE_RECENT_FILE1 + FileIdx)));
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2013-08-09 06:57:18 +02:00
|
|
|
gMainWindow = this;
|
2011-09-07 23:06:51 +02:00
|
|
|
}
|
|
|
|
|
2013-08-09 06:57:18 +02:00
|
|
|
lcMainWindow::~lcMainWindow()
|
2011-09-07 23:06:51 +02:00
|
|
|
{
|
2013-08-09 06:57:18 +02:00
|
|
|
for (int FileIdx = 0; FileIdx < LC_MAX_RECENT_FILES; FileIdx++)
|
|
|
|
lcSetProfileString((LC_PROFILE_KEY)(LC_PROFILE_RECENT_FILE1 + FileIdx), mRecentFiles[FileIdx]);
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2013-08-09 06:57:18 +02:00
|
|
|
gMainWindow = NULL;
|
|
|
|
}
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2014-05-03 23:16:48 +02:00
|
|
|
void lcMainWindow::AddView(View* View)
|
|
|
|
{
|
|
|
|
mViews.Add(View);
|
|
|
|
|
|
|
|
View->MakeCurrent();
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2014-05-23 02:02:21 +02:00
|
|
|
void lcMainWindow::SetTool(lcTool Tool)
|
|
|
|
{
|
|
|
|
mTool = Tool;
|
|
|
|
|
|
|
|
UpdateAction(mTool);
|
|
|
|
UpdateAllViews();
|
|
|
|
}
|
|
|
|
|
2013-08-09 06:57:18 +02:00
|
|
|
void lcMainWindow::SetColorIndex(int ColorIndex)
|
2014-05-03 23:16:48 +02:00
|
|
|
{
|
2013-08-09 06:57:18 +02:00
|
|
|
mColorIndex = ColorIndex;
|
|
|
|
|
|
|
|
if (mPreviewWidget)
|
|
|
|
mPreviewWidget->Redraw();
|
2011-09-07 23:06:51 +02:00
|
|
|
}
|
|
|
|
|
2013-08-09 06:57:18 +02:00
|
|
|
void lcMainWindow::AddRecentFile(const char* FileName)
|
2011-09-07 23:06:51 +02:00
|
|
|
{
|
2013-08-09 06:57:18 +02:00
|
|
|
int FileIdx;
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2013-08-09 06:57:18 +02:00
|
|
|
for (FileIdx = 0; FileIdx < LC_MAX_RECENT_FILES; FileIdx++)
|
|
|
|
if (!strcmp(mRecentFiles[FileIdx], FileName))
|
2011-09-07 23:06:51 +02:00
|
|
|
break;
|
|
|
|
|
2013-08-09 06:57:18 +02:00
|
|
|
for (FileIdx = lcMin(FileIdx, LC_MAX_RECENT_FILES - 1); FileIdx > 0; FileIdx--)
|
|
|
|
strcpy(mRecentFiles[FileIdx], mRecentFiles[FileIdx - 1]);
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2013-08-09 06:57:18 +02:00
|
|
|
strcpy(mRecentFiles[0], FileName);
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2013-08-09 06:57:18 +02:00
|
|
|
UpdateRecentFiles();
|
2011-09-07 23:06:51 +02:00
|
|
|
}
|
|
|
|
|
2013-08-09 06:57:18 +02:00
|
|
|
void lcMainWindow::RemoveRecentFile(int FileIndex)
|
2011-09-07 23:06:51 +02:00
|
|
|
{
|
2013-08-09 06:57:18 +02:00
|
|
|
for (int FileIdx = FileIndex; FileIdx < LC_MAX_RECENT_FILES - 1; FileIdx++)
|
|
|
|
strcpy(mRecentFiles[FileIdx], mRecentFiles[FileIdx + 1]);
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2013-08-09 06:57:18 +02:00
|
|
|
mRecentFiles[LC_MAX_RECENT_FILES - 1][0] = 0;
|
|
|
|
|
|
|
|
UpdateRecentFiles();
|
2011-09-07 23:06:51 +02:00
|
|
|
}
|
2013-08-09 06:57:18 +02:00
|
|
|
|