leocad/common/lc_application.h

178 lines
3.5 KiB
C
Raw Normal View History

#pragma once
2013-08-09 06:57:18 +02:00
2013-08-16 01:43:18 +02:00
#include "lc_array.h"
2021-01-11 02:45:28 +01:00
#include "lc_math.h"
2013-08-09 06:57:18 +02:00
class Project;
class lcPiecesLibrary;
2020-12-05 19:29:39 +01:00
enum class lcViewSphereLocation;
2017-03-17 23:53:26 +01:00
2020-03-22 21:44:20 +01:00
enum class lcShadingMode
2017-03-17 23:53:26 +01:00
{
2020-03-22 21:44:20 +01:00
Wireframe,
Flat,
DefaultLights,
Full
2017-03-17 23:53:26 +01:00
};
2020-07-25 22:21:22 +02:00
enum class lcColorTheme
{
Dark,
System
};
class lcPreferences
{
public:
void LoadDefaults();
void SaveDefaults();
2020-07-25 22:21:22 +02:00
void SetInterfaceColors(lcColorTheme ColorTheme);
int mMouseSensitivity;
2017-08-25 21:57:14 +02:00
lcShadingMode mShadingMode;
bool mBackgroundGradient;
quint32 mBackgroundSolidColor;
quint32 mBackgroundGradientColorTop;
quint32 mBackgroundGradientColorBottom;
bool mDrawAxes;
quint32 mAxesColor;
2020-12-30 22:44:08 +01:00
quint32 mTextColor;
quint32 mMarqueeBorderColor;
quint32 mMarqueeFillColor;
quint32 mOverlayColor;
2020-07-25 22:21:22 +02:00
quint32 mActiveViewColor;
2020-12-12 03:01:04 +01:00
quint32 mInactiveViewColor;
bool mDrawEdgeLines;
float mLineWidth;
bool mAllowLOD;
2020-08-16 01:16:26 +02:00
float mMeshLODDistance;
2020-01-02 02:06:17 +01:00
bool mFadeSteps;
2020-04-25 21:16:37 +02:00
quint32 mFadeStepsColor;
bool mHighlightNewParts;
quint32 mHighlightNewPartsColor;
2020-12-24 04:10:54 +01:00
bool mGridEnabled = true;
bool mDrawGridStuds;
2017-12-02 21:22:04 +01:00
quint32 mGridStudColor;
bool mDrawGridLines;
int mGridLineSpacing;
2017-12-02 21:22:04 +01:00
quint32 mGridLineColor;
bool mDrawGridOrigin;
2014-10-05 07:21:51 +02:00
bool mFixedAxes;
2020-01-05 20:38:24 +01:00
bool mViewSphereEnabled;
2018-10-29 01:59:01 +01:00
lcViewSphereLocation mViewSphereLocation;
int mViewSphereSize;
2019-01-20 20:59:18 +01:00
quint32 mViewSphereColor;
quint32 mViewSphereTextColor;
quint32 mViewSphereHighlightColor;
2019-03-10 01:38:54 +01:00
bool mAutoLoadMostRecent;
2020-01-02 02:06:17 +01:00
bool mRestoreTabLayout;
2020-07-25 22:21:22 +02:00
lcColorTheme mColorTheme;
int mPreviewViewSphereEnabled;
int mPreviewViewSphereSize;
lcViewSphereLocation mPreviewViewSphereLocation;
int mDrawPreviewAxis;
};
2021-01-11 02:45:28 +01:00
struct lcCommandLineOptions
{
bool ParseOK;
bool Exit;
bool SaveImage;
bool SaveWavefront;
bool Save3DS;
bool SaveCOLLADA;
bool SaveHTML;
bool SetCameraAngles;
bool SetCameraPosition;
bool Orthographic;
bool SetFoV;
bool SetZPlanes;
bool SetFadeStepsColor;
bool SetHighlightColor;
bool FadeSteps;
bool ImageHighlight;
int ImageWidth;
int ImageHeight;
int AASamples;
lcStudStyle StudStyle;
2021-01-13 20:39:55 +01:00
lcStep ImageStart;
lcStep ImageEnd;
2021-01-11 02:45:28 +01:00
lcVector3 CameraPosition[3];
lcVector2 CameraLatLon;
float FoV;
lcVector2 ZPlanes;
lcViewpoint Viewpoint;
quint32 FadeStepsColor;
quint32 HighlightColor;
QString ImageName;
QString ModelName;
QString CameraName;
QString ProjectName;
QString SaveWavefrontName;
QString Save3DSName;
QString SaveCOLLADAName;
QString SaveHTMLName;
QList<QPair<QString, bool>> LibraryPaths;
QString StdOut;
QString StdErr;
2021-01-11 02:45:28 +01:00
};
2020-12-31 03:22:02 +01:00
enum class lcStartupMode
{
ShowWindow,
Success,
Error
};
class lcApplication : public QApplication
2013-08-09 06:57:18 +02:00
{
Q_OBJECT
2015-01-30 17:30:13 +01:00
2013-08-09 06:57:18 +02:00
public:
lcApplication(int& Argc, char** Argv);
2013-08-09 06:57:18 +02:00
~lcApplication();
2014-12-04 02:47:28 +01:00
void SetProject(Project* Project);
2021-01-11 02:45:28 +01:00
lcCommandLineOptions ParseCommandLineOptions();
lcStartupMode Initialize(const QList<QPair<QString, bool>>& LibraryPaths);
2013-08-09 06:57:18 +02:00
void Shutdown();
void ShowPreferencesDialog();
void SaveTabLayout() const;
2013-08-09 06:57:18 +02:00
bool LoadPartsLibrary(const QList<QPair<QString, bool>>& LibraryPaths, bool OnlyUsePaths);
2013-08-09 06:57:18 +02:00
2014-12-16 00:55:17 +01:00
void SetClipboard(const QByteArray& Clipboard);
void ExportClipboard(const QByteArray& Clipboard);
2013-08-09 06:57:18 +02:00
Project* mProject = nullptr;
lcPiecesLibrary* mLibrary = nullptr;
lcPreferences mPreferences;
2014-12-16 00:55:17 +01:00
QByteArray mClipboard;
protected:
2021-01-11 02:45:28 +01:00
bool InitializeRenderer();
2021-01-02 19:23:51 +01:00
void ShutdownRenderer();
2020-07-25 22:21:22 +02:00
void UpdateStyle();
QString GetTabLayoutKey() const;
2020-07-25 22:21:22 +02:00
QString mDefaultStyle;
2013-08-09 06:57:18 +02:00
};
extern lcApplication* gApplication;
2013-08-09 06:57:18 +02:00
inline lcPiecesLibrary* lcGetPiecesLibrary()
{
return gApplication->mLibrary;
2013-08-09 06:57:18 +02:00
}
inline Project* lcGetActiveProject()
{
return gApplication->mProject;
2013-08-09 06:57:18 +02:00
}
2014-10-05 07:21:51 +02:00
inline lcPreferences& lcGetPreferences()
{
return gApplication->mPreferences;
}