mirror of
https://github.com/leozide/leocad.git
synced 2026-10-26 22:10:32 +00:00
Replace manual piece-data retain/release bookkeeping with shared copyable asset-reference handles. Pieces, models, selection, minifigs, thumbnails, and stored insertion previews retain their dependencies explicitly, while transient queries continue to borrow pointers. Separate registered lookup and acquisition from asynchronous load requests and explicit readiness waits. Keep loader-held references through work and notification delivery, resetting shared request handles on the UI thread and guarding callback-triggered library teardown. Validated with the Qt 6.10 debug build and 26 offscreen lifecycle checks, including cancellation, stale requests, copy/move operations, model/preview teardown, undo, project merge/export, and loader shutdown.
101 lines
2.0 KiB
C++
101 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include "lc_math.h"
|
|
#include "lc_assettypes.h"
|
|
|
|
enum LC_MFW_TYPES
|
|
{
|
|
LC_MFW_HATS,
|
|
LC_MFW_HATS2,
|
|
LC_MFW_HEAD,
|
|
LC_MFW_NECK,
|
|
LC_MFW_BODY,
|
|
LC_MFW_BODY2,
|
|
LC_MFW_BODY3,
|
|
LC_MFW_RARM,
|
|
LC_MFW_LARM,
|
|
LC_MFW_RHAND,
|
|
LC_MFW_LHAND,
|
|
LC_MFW_RHANDA,
|
|
LC_MFW_LHANDA,
|
|
LC_MFW_RLEG,
|
|
LC_MFW_LLEG,
|
|
LC_MFW_RLEGA,
|
|
LC_MFW_LLEGA,
|
|
LC_MFW_NUMITEMS
|
|
};
|
|
|
|
struct lcMinifigPieceInfo
|
|
{
|
|
char Description[128];
|
|
lcPieceData* PieceData;
|
|
lcMatrix44 Offset;
|
|
};
|
|
|
|
struct lcMinifig
|
|
{
|
|
lcPieceDataRef PieceData[LC_MFW_NUMITEMS];
|
|
int ColorIndices[LC_MFW_NUMITEMS];
|
|
float Angles[LC_MFW_NUMITEMS];
|
|
lcMatrix44 Matrices[LC_MFW_NUMITEMS];
|
|
};
|
|
|
|
struct lcMinifigTemplate
|
|
{
|
|
QString Parts[LC_MFW_NUMITEMS];
|
|
int ColorCodes[LC_MFW_NUMITEMS];
|
|
float Angles[LC_MFW_NUMITEMS];
|
|
};
|
|
|
|
class MinifigWizard
|
|
{
|
|
public:
|
|
MinifigWizard();
|
|
~MinifigWizard();
|
|
|
|
MinifigWizard(const MinifigWizard&) = delete;
|
|
MinifigWizard(MinifigWizard&&) = delete;
|
|
MinifigWizard& operator=(const MinifigWizard&) = delete;
|
|
MinifigWizard& operator=(MinifigWizard&&) = delete;
|
|
|
|
lcModel* GetModel() const
|
|
{
|
|
return mModel.get();
|
|
}
|
|
|
|
const std::map<QString, lcMinifigTemplate>& GetTemplates() const
|
|
{
|
|
return mTemplates;
|
|
}
|
|
|
|
static QString GetDefaultTemplateName();
|
|
|
|
void LoadTemplate(const QString& TemplateName);
|
|
void SaveTemplate(const QString& TemplateName, const lcMinifigTemplate& Template);
|
|
void DeleteTemplate(const QString& TemplateName);
|
|
void AddTemplatesJson(const QByteArray& TemplateData);
|
|
QByteArray GetTemplatesJson() const;
|
|
|
|
void Calculate();
|
|
int GetSelectionIndex(int Type) const;
|
|
void SetPieceData(int Type, lcPieceData* PieceData);
|
|
void SetColorIndex(int Type, int ColorIndex);
|
|
void SetAngle(int Type, float Angle);
|
|
|
|
std::vector<lcMinifigPieceInfo> mSettings[LC_MFW_NUMITEMS];
|
|
|
|
lcMinifig mMinifig;
|
|
|
|
protected:
|
|
void LoadSettings();
|
|
void ParseSettings(lcFile& Settings);
|
|
|
|
void LoadTemplates();
|
|
void SaveTemplates();
|
|
|
|
std::unique_ptr<lcModel> mModel;
|
|
std::map<QString, lcMinifigTemplate> mTemplates;
|
|
static const char* mSectionNames[LC_MFW_NUMITEMS];
|
|
};
|
|
|