1 #pragma once
2
3 #include "lc_array.h"
4 #include "lc_math.h"
5
6 class Project;
7 class lcPiecesLibrary;
8 enum class lcViewSphereLocation;
9
10 enum class lcShadingMode
11 {
12 Wireframe,
13 Flat,
14 DefaultLights,
15 Full
16 };
17
18 enum class lcColorTheme
19 {
20 Dark,
21 System
22 };
23
24 enum class lcAxisIconLocation
25 {
26 TopLeft,
27 TopRight,
28 BottomLeft,
29 BottomRight
30 };
31
32 class lcPreferences
33 {
34 public:
35 void LoadDefaults();
36 void SaveDefaults();
37 void SetInterfaceColors(lcColorTheme ColorTheme);
38
39 int mMouseSensitivity;
40 lcShadingMode mShadingMode;
41 bool mBackgroundGradient;
42 quint32 mBackgroundSolidColor;
43 quint32 mBackgroundGradientColorTop;
44 quint32 mBackgroundGradientColorBottom;
45 bool mDrawAxes;
46 lcAxisIconLocation mAxisIconLocation;
47 quint32 mAxesColor;
48 quint32 mTextColor;
49 quint32 mMarqueeBorderColor;
50 quint32 mMarqueeFillColor;
51 quint32 mOverlayColor;
52 quint32 mActiveViewColor;
53 quint32 mInactiveViewColor;
54 bool mDrawEdgeLines;
55 bool mDrawConditionalLines;
56 float mLineWidth;
57 bool mAllowLOD;
58 float mMeshLODDistance;
59 bool mFadeSteps;
60 quint32 mFadeStepsColor;
61 bool mHighlightNewParts;
62 quint32 mHighlightNewPartsColor;
63 bool mGridEnabled = true;
64 bool mDrawGridStuds;
65 quint32 mGridStudColor;
66 bool mDrawGridLines;
67 int mGridLineSpacing;
68 quint32 mGridLineColor;
69 bool mDrawGridOrigin;
70 bool mFixedAxes;
71 bool mViewSphereEnabled;
72 lcViewSphereLocation mViewSphereLocation;
73 int mViewSphereSize;
74 quint32 mViewSphereColor;
75 quint32 mViewSphereTextColor;
76 quint32 mViewSphereHighlightColor;
77 bool mAutoLoadMostRecent;
78 bool mRestoreTabLayout;
79 lcColorTheme mColorTheme;
80
81 int mPreviewViewSphereEnabled;
82 int mPreviewViewSphereSize;
83 lcViewSphereLocation mPreviewViewSphereLocation;
84 int mDrawPreviewAxis;
85
86 quint32 mStudCylinderColor;
87 quint32 mPartEdgeColor;
88 quint32 mBlackEdgeColor;
89 quint32 mDarkEdgeColor;
90 float mPartEdgeContrast;
91 float mPartColorValueLDIndex;
92 bool mAutomateEdgeColor;
93 };
94
95 struct lcCommandLineOptions
96 {
97 bool ParseOK;
98 bool Exit;
99 bool SaveImage;
100 bool SaveWavefront;
101 bool Save3DS;
102 bool SaveCOLLADA;
103 bool SaveHTML;
104 bool SetCameraAngles;
105 bool SetCameraPosition;
106 bool Orthographic;
107 bool SetFoV;
108 bool SetZPlanes;
109 bool SetFadeStepsColor;
110 bool SetHighlightColor;
111 bool FadeSteps;
112 bool ImageHighlight;
113 bool AutomateEdgeColor;
114 int ImageWidth;
115 int ImageHeight;
116 int AASamples;
117 lcShadingMode ShadingMode;
118 float LineWidth;
119 lcStudStyle StudStyle;
120 lcStep ImageStart;
121 lcStep ImageEnd;
122 lcVector3 CameraPosition[3];
123 lcVector2 CameraLatLon;
124 float FoV;
125 float PartEdgeContrast;
126 float PartColorValueLDIndex;
127 lcVector2 ZPlanes;
128 lcViewpoint Viewpoint;
129 quint32 StudCylinderColor;
130 quint32 PartEdgeColor;
131 quint32 BlackEdgeColor;
132 quint32 DarkEdgeColor;
133 quint32 FadeStepsColor;
134 quint32 HighlightColor;
135 QString ImageName;
136 QString ModelName;
137 QString CameraName;
138 QString ProjectName;
139 QString SaveWavefrontName;
140 QString Save3DSName;
141 QString SaveCOLLADAName;
142 QString SaveHTMLName;
143 QList<QPair<QString, bool>> LibraryPaths;
144 QString StdOut;
145 QString StdErr;
146 };
147
148 enum class lcStartupMode
149 {
150 ShowWindow,
151 Success,
152 Error
153 };
154
155 class lcApplication : public QApplication
156 {
157 Q_OBJECT
158
159 public:
160 lcApplication(int& Argc, char** Argv);
161 ~lcApplication();
162
163 void SetProject(Project* Project);
164 static lcCommandLineOptions ParseCommandLineOptions();
165 lcStartupMode Initialize(const QList<QPair<QString, bool>>& LibraryPaths);
166 void Shutdown();
167 void ShowPreferencesDialog();
168 void SaveTabLayout() const;
169
170 bool LoadPartsLibrary(const QList<QPair<QString, bool>>& LibraryPaths, bool OnlyUsePaths);
171
172 void SetClipboard(const QByteArray& Clipboard);
173 void ExportClipboard(const QByteArray& Clipboard);
174
175 Project* mProject = nullptr;
176 lcPiecesLibrary* mLibrary = nullptr;
177 lcPreferences mPreferences;
178 QByteArray mClipboard;
179
180 protected:
181 void UpdateStyle();
182 QString GetTabLayoutKey() const;
183
184 QString mDefaultStyle;
185 };
186
187 extern lcApplication* gApplication;
188
lcGetPiecesLibrary()189 inline lcPiecesLibrary* lcGetPiecesLibrary()
190 {
191 return gApplication->mLibrary;
192 }
193
lcGetActiveProject()194 inline Project* lcGetActiveProject()
195 {
196 return gApplication->mProject;
197 }
198
lcGetPreferences()199 inline lcPreferences& lcGetPreferences()
200 {
201 return gApplication->mPreferences;
202 }
203