Files
leocad/common/lc_application.h
T
Leonardo Zide 6a8c05acc5 Initialize stud settings and simplify loader bookkeeping
Pass effective startup stud settings into the library and apply color preferences before loading. Replace the reload toggle with UpdateStudStyleAndColors, preserve configured settings in the fallback library, and save the selected color config before combined preferences updates.

Remove temporary consumer references from synchronous piece waits, the redundant drain mutex, and worker-start queues. Derive loading states from current requests and use explicit piece names for request, queue, and notification storage. Document the updated ownership and settings contracts.

Validated with a Debug build, startup style and color exports, 14 asset export checks, and temporary lifecycle checks covering owned waits, failed and duplicate requirements, regeneration, cancellation, pause/resume, reference cleanup, and shutdown.
2026-10-14 10:57:30 -07:00

234 lines
4.9 KiB
C++

#pragma once
#include "lc_math.h"
class Project;
class lcPiecesLibrary;
enum class lcViewSphereLocation;
enum class lcShadingMode
{
Wireframe,
Flat,
DefaultLights,
Full
};
enum class lcColorTheme
{
Dark,
System
};
enum class lcSelectionRenderMode
{
Outline,
Tint
};
enum class lcAxisIconLocation
{
TopLeft,
TopRight,
BottomLeft,
BottomRight
};
class lcPreferences
{
public:
void LoadDefaults();
void SaveDefaults();
void SetInterfaceColors(lcColorTheme ColorTheme);
int mMouseSensitivity;
lcShadingMode mShadingMode;
lcSelectionRenderMode mSelectionRenderMode;
bool mBackgroundGradient;
quint32 mBackgroundSolidColor;
quint32 mBackgroundGradientColorTop;
quint32 mBackgroundGradientColorBottom;
bool mDrawAxes;
lcAxisIconLocation mAxisIconLocation;
quint32 mTextColor;
quint32 mTextHaloColor;
quint32 mMarqueeBorderColor;
quint32 mMarqueeFillColor;
quint32 mOverlayColor;
quint32 mActiveViewColor;
quint32 mInactiveViewColor;
bool mDrawEdgeLines;
bool mDrawConditionalLines;
float mLineWidth;
bool mAllowLOD;
float mMeshLODDistance;
bool mFadeSteps;
quint32 mFadeStepsColor;
bool mHighlightNewParts;
quint32 mHighlightNewPartsColor;
bool mGridEnabled = true;
bool mDrawGridStuds;
quint32 mGridStudColor;
bool mDrawGridLines;
int mGridLineSpacing;
quint32 mGridLineColor;
bool mDrawGridOrigin;
bool mFixedAxes;
bool mViewSphereEnabled;
lcViewSphereLocation mViewSphereLocation;
int mViewSphereSize;
quint32 mViewSphereColor;
quint32 mViewSphereTextColor;
quint32 mViewSphereHighlightColor;
bool mAutoLoadMostRecent;
bool mRestoreTabLayout;
lcColorTheme mColorTheme;
quint32 mObjectSelectedColor;
quint32 mObjectFocusedColor;
quint32 mCameraColor;
quint32 mLightColor;
quint32 mControlPointColor;
quint32 mControlPointFocusedColor;
int mPreviewViewSphereEnabled;
int mPreviewViewSphereSize;
lcViewSphereLocation mPreviewViewSphereLocation;
int mDrawPreviewAxis;
bool mStudCylinderColorEnabled;
quint32 mStudCylinderColor;
bool mPartEdgeColorEnabled;
quint32 mPartEdgeColor;
bool mBlackEdgeColorEnabled;
quint32 mBlackEdgeColor;
bool mDarkEdgeColorEnabled;
quint32 mDarkEdgeColor;
float mPartEdgeContrast;
float mPartColorValueLDIndex;
bool mAutomateEdgeColor;
};
struct lcCommandLineOptions
{
bool ParseOK = true;
bool Exit = false;
bool SaveImage = false;
bool SaveWavefront = false;
bool Save3DS = false;
bool SaveCOLLADA = false;
bool SaveCSV = false;
bool SaveHTML = false;
bool SetCameraAngles = false;
bool SetCameraPosition = false;
bool Orthographic = false;
bool SetFoV = false;
bool SetZPlanes = false;
bool SetFadeStepsColor = false;
bool SetHighlightColor = false;
bool FadeSteps = false;
bool ImageHighlight = false;
bool AutomateEdgeColor = false;
int ImageWidth;
int ImageHeight;
int AASamples;
lcShadingMode ShadingMode;
float LineWidth;
lcStudStyle StudStyle;
lcStep ImageStart;
lcStep ImageEnd;
lcVector3 CameraPosition[3];
lcVector2 CameraLatLon;
float FoV;
float PartEdgeContrast;
float PartColorValueLDIndex;
lcVector2 ZPlanes;
lcViewpoint Viewpoint;
bool StudCylinderColorEnabled;
quint32 StudCylinderColor;
bool PartEdgeColorEnabled;
quint32 PartEdgeColor;
bool BlackEdgeColorEnabled;
quint32 BlackEdgeColor;
bool DarkEdgeColorEnabled;
quint32 DarkEdgeColor;
quint32 FadeStepsColor;
quint32 HighlightColor;
QString ImageName;
QString ModelName;
QString CameraName;
QString ProjectName;
QString SaveWavefrontName;
QString Save3DSName;
QString SaveCOLLADAName;
QString SaveCSVName;
QString SaveHTMLName;
QList<QPair<QString, bool>> LibraryPaths;
QString StdOut;
QString StdErr;
};
enum class lcStartupMode
{
ShowWindow,
Success,
Error
};
class lcApplication : public QApplication
{
Q_OBJECT
public:
lcApplication(int& Argc, char** Argv);
~lcApplication();
lcApplication(const lcApplication&) = delete;
lcApplication(lcApplication&&) = delete;
lcApplication& operator=(const lcApplication&) = delete;
lcApplication& operator=(lcApplication&&) = delete;
void SetProject(Project* Project);
static lcCommandLineOptions ParseCommandLineOptions();
lcStartupMode Initialize(const QList<QPair<QString, bool>>& LibraryPaths);
void Shutdown();
void ShowPreferencesDialog();
void SaveTabLayout() const;
bool LoadPartsLibrary(const QList<QPair<QString, bool>>& LibraryPaths, bool OnlyUsePaths, lcStudStyle StudStyle, bool StudCylinderColorEnabled);
void SetClipboard(const QByteArray& Clipboard);
void ExportClipboard(const QByteArray& Clipboard);
Project* mProject = nullptr;
lcPiecesLibrary* mLibrary = nullptr;
lcPreferences mPreferences;
QByteArray mClipboard;
signals:
void RendererInitialized();
protected:
void UpdateStyle();
QString GetTabLayoutKey() const;
QString mDefaultStyle;
};
extern lcApplication* gApplication;
inline lcPiecesLibrary* lcGetPiecesLibrary()
{
return gApplication->mLibrary;
}
inline Project* lcGetActiveProject()
{
return gApplication->mProject;
}
inline lcPreferences& lcGetPreferences()
{
return gApplication->mPreferences;
}