leocad/common/project.h

137 lines
3.2 KiB
C
Raw Normal View History

#pragma once
2011-09-07 23:06:51 +02:00
#include "object.h"
2013-08-16 01:43:18 +02:00
#include "lc_array.h"
#include "lc_application.h"
2013-08-09 06:57:18 +02:00
#define LC_SCENE_BG 0x010 // Draw bg image
#define LC_SCENE_BG_TILE 0x040 // Tile bg image
#define LC_SCENE_GRADIENT 0x100 // Draw gradient
#define LC_HTML_SINGLEPAGE 0x01
#define LC_HTML_INDEX 0x02
#define LC_HTML_IMAGES 0x04
#define LC_HTML_LISTEND 0x08
#define LC_HTML_LISTSTEP 0x10
#define LC_HTML_HIGHLIGHT 0x20
#define LC_HTML_SUBMODELS 0x40
#define LC_HTML_CURRENT_ONLY 0x80
2013-08-09 06:57:18 +02:00
class lcHTMLExportOptions
{
public:
lcHTMLExportOptions(const Project* Project);
void SaveDefaults();
QString PathName;
bool TransparentImages;
bool SubModels;
bool CurrentOnly;
bool SinglePage;
bool IndexPage;
int StepImagesWidth;
int StepImagesHeight;
bool HighlightNewParts;
bool PartsListStep;
bool PartsListEnd;
bool PartsListImages;
int PartImagesColor;
int PartImagesWidth;
int PartImagesHeight;
};
2012-10-18 20:57:21 +02:00
enum LC_MOUSE_TRACK
2011-09-07 23:06:51 +02:00
{
LC_TRACK_NONE,
LC_TRACK_LEFT,
LC_TRACK_RIGHT
2012-10-18 20:57:21 +02:00
};
2011-09-07 23:06:51 +02:00
class Project
2011-09-07 23:06:51 +02:00
{
public:
Project();
~Project();
2014-12-10 00:56:29 +01:00
const lcArray<lcModel*>& GetModels() const
{
return mModels;
}
lcModel* GetModel(const QString& Name) const;
lcModel* GetActiveModel() const
{
return mActiveModel;
}
int GetActiveModelIndex() const
{
return mModels.FindIndex(mActiveModel);
}
lcModel* GetMainModel() const
{
return !mModels.IsEmpty() ? mModels[0] : nullptr;
}
2014-12-13 00:42:09 +01:00
bool IsModified() const;
2014-12-04 02:47:28 +01:00
QString GetTitle() const;
2014-12-13 00:42:09 +01:00
2014-12-04 02:47:28 +01:00
QString GetFileName() const
{
return mFileName;
}
QString GetImageFileName(bool AllowCurrentFolder) const;
2017-12-27 22:55:37 +01:00
2014-12-13 00:42:09 +01:00
void SetActiveModel(int ModelIndex);
void SetActiveModel(const QString& ModelName);
2014-12-13 00:42:09 +01:00
lcModel* CreateNewModel(bool ShowModel);
2016-09-09 00:34:51 +02:00
QString GetNewModelName(QWidget* ParentWidget, const QString& DialogTitle, const QString& CurrentName, const QStringList& ExistingModels) const;
2014-12-13 00:42:09 +01:00
void ShowModelListDialog();
2014-12-04 02:47:28 +01:00
bool Load(const QString& FileName);
bool Save(const QString& FileName);
bool Save(QTextStream& Stream);
2014-12-23 18:02:23 +01:00
void Merge(Project* Other);
2017-06-26 03:20:34 +02:00
bool ImportLDD(const QString& FileName);
2017-08-20 22:47:53 +02:00
bool ImportInventory(const QByteArray& Inventory, const QString& Name, const QString& Description);
2014-12-04 02:47:28 +01:00
2015-01-12 06:02:50 +01:00
void SaveImage();
bool ExportModel(const QString& FileName, lcModel* Model);
void Export3DStudio(const QString& FileName);
2014-12-30 17:30:12 +01:00
void ExportBrickLink();
void ExportCOLLADA(const QString& FileName);
2014-12-30 17:30:12 +01:00
void ExportCSV();
void ExportHTML(const lcHTMLExportOptions& Options);
2017-09-22 19:08:02 +02:00
bool ExportPOVRay(const QString& FileName);
void ExportWavefront(const QString& FileName);
2014-12-30 17:30:12 +01:00
void UpdatePieceInfo(PieceInfo* Info) const;
protected:
QString GetExportFileName(const QString& FileName, const QString& DefaultExtension, const QString& DialogTitle, const QString& DialogFilter) const;
2014-12-30 17:30:12 +01:00
void GetModelParts(lcArray<lcModelPartsEntry>& ModelParts);
QImage CreatePartsListImage(lcModel* Model, lcStep Step);
void CreateHTMLPieceList(QTextStream& Stream, lcModel* Model, lcStep Step, bool Images);
void SetFileName(const QString& FileName);
2014-12-30 17:30:12 +01:00
bool mModified;
QString mFileName;
QFileSystemWatcher mFileWatcher;
2014-12-04 02:47:28 +01:00
lcArray<lcModel*> mModels;
lcModel* mActiveModel;
Q_DECLARE_TR_FUNCTIONS(Project);
2011-09-07 23:06:51 +02:00
};
inline lcModel* lcGetActiveModel()
{
Project* Project = lcGetActiveProject();
return Project ? Project->GetActiveModel() : nullptr;
}