2014-05-25 03:45:19 +02:00
|
|
|
#ifndef _LC_MODEL_H_
|
|
|
|
#define _LC_MODEL_H_
|
|
|
|
|
2014-07-03 21:10:04 +02:00
|
|
|
#include "lc_file.h"
|
2014-05-25 03:45:19 +02:00
|
|
|
#include "lc_math.h"
|
|
|
|
#include "str.h"
|
|
|
|
#include "object.h"
|
|
|
|
|
2014-08-17 22:44:12 +02:00
|
|
|
#define LC_SEL_NO_PIECES 0x01 // No pieces in model
|
|
|
|
#define LC_SEL_PIECE 0x02 // At last 1 piece selected
|
|
|
|
#define LC_SEL_SELECTED 0x04 // At last 1 object selected
|
|
|
|
#define LC_SEL_UNSELECTED 0x08 // At least 1 piece unselected
|
|
|
|
#define LC_SEL_HIDDEN 0x10 // At least one piece hidden
|
|
|
|
#define LC_SEL_GROUPED 0x20 // At least one piece selected is grouped
|
|
|
|
#define LC_SEL_FOCUS_GROUPED 0x40 // Focused piece is grouped
|
|
|
|
#define LC_SEL_CAN_GROUP 0x80 // Can make a new group
|
|
|
|
|
2014-08-27 18:17:09 +02:00
|
|
|
enum lcTransformType
|
|
|
|
{
|
|
|
|
LC_TRANSFORM_ABSOLUTE_TRANSLATION,
|
|
|
|
LC_TRANSFORM_RELATIVE_TRANSLATION,
|
|
|
|
LC_TRANSFORM_ABSOLUTE_ROTATION,
|
|
|
|
LC_TRANSFORM_RELATIVE_ROTATION
|
|
|
|
};
|
|
|
|
|
2014-05-25 03:45:19 +02:00
|
|
|
enum lcBackgroundType
|
|
|
|
{
|
|
|
|
LC_BACKGROUND_SOLID,
|
|
|
|
LC_BACKGROUND_GRADIENT,
|
2014-09-08 21:42:20 +02:00
|
|
|
LC_BACKGROUND_IMAGE,
|
|
|
|
LC_NUM_BACKGROUND_TYPES
|
2014-05-25 03:45:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class lcModelProperties
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void LoadDefaults();
|
|
|
|
void SaveDefaults();
|
|
|
|
|
|
|
|
bool operator==(const lcModelProperties& Properties)
|
|
|
|
{
|
|
|
|
if (mName != Properties.mName || mAuthor != Properties.mAuthor ||
|
|
|
|
mDescription != Properties.mDescription || mComments != Properties.mComments)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (mBackgroundType != Properties.mBackgroundType || mBackgroundSolidColor != Properties.mBackgroundSolidColor ||
|
|
|
|
mBackgroundGradientColor1 != Properties.mBackgroundGradientColor1 || mBackgroundGradientColor2 != Properties.mBackgroundGradientColor2 ||
|
|
|
|
mBackgroundImage != Properties.mBackgroundImage || mBackgroundImageTile != Properties.mBackgroundImageTile)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (mFogEnabled != Properties.mFogEnabled || mFogDensity != Properties.mFogDensity ||
|
|
|
|
mFogColor != Properties.mFogColor || mAmbientColor != Properties.mAmbientColor)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-09-05 02:24:28 +02:00
|
|
|
void SaveLDraw(QTextStream& Stream) const;
|
2014-09-08 21:42:20 +02:00
|
|
|
void ParseLDrawLine(QTextStream& Stream);
|
2014-09-02 05:44:51 +02:00
|
|
|
|
2014-09-06 03:34:03 +02:00
|
|
|
QString mName;
|
|
|
|
QString mAuthor;
|
|
|
|
QString mDescription;
|
|
|
|
QString mComments;
|
2014-05-25 03:45:19 +02:00
|
|
|
|
|
|
|
lcBackgroundType mBackgroundType;
|
|
|
|
lcVector3 mBackgroundSolidColor;
|
|
|
|
lcVector3 mBackgroundGradientColor1;
|
|
|
|
lcVector3 mBackgroundGradientColor2;
|
2014-09-08 21:42:20 +02:00
|
|
|
QString mBackgroundImage;
|
2014-05-25 03:45:19 +02:00
|
|
|
bool mBackgroundImageTile;
|
|
|
|
|
|
|
|
bool mFogEnabled;
|
|
|
|
float mFogDensity;
|
|
|
|
lcVector3 mFogColor;
|
|
|
|
lcVector3 mAmbientColor;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum lcTool
|
|
|
|
{
|
|
|
|
LC_TOOL_INSERT,
|
|
|
|
LC_TOOL_LIGHT,
|
|
|
|
LC_TOOL_SPOTLIGHT,
|
|
|
|
LC_TOOL_CAMERA,
|
|
|
|
LC_TOOL_SELECT,
|
|
|
|
LC_TOOL_MOVE,
|
|
|
|
LC_TOOL_ROTATE,
|
|
|
|
LC_TOOL_ERASER,
|
|
|
|
LC_TOOL_PAINT,
|
|
|
|
LC_TOOL_ZOOM,
|
|
|
|
LC_TOOL_PAN,
|
|
|
|
LC_TOOL_ROTATE_VIEW,
|
|
|
|
LC_TOOL_ROLL,
|
|
|
|
LC_TOOL_ZOOM_REGION
|
|
|
|
};
|
|
|
|
|
2014-07-03 21:10:04 +02:00
|
|
|
struct lcModelHistoryEntry
|
|
|
|
{
|
2014-09-14 02:45:45 +02:00
|
|
|
QByteArray File;
|
2014-07-03 21:10:04 +02:00
|
|
|
char Description[64];
|
|
|
|
};
|
|
|
|
|
2014-05-25 03:45:19 +02:00
|
|
|
class lcModel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
lcModel();
|
|
|
|
~lcModel();
|
|
|
|
|
2014-07-06 08:04:09 +02:00
|
|
|
bool IsModified() const
|
|
|
|
{
|
|
|
|
return mSavedHistory != mUndoHistory[0];
|
|
|
|
}
|
|
|
|
|
2014-05-27 00:58:08 +02:00
|
|
|
const lcArray<lcPiece*>& GetPieces() const
|
|
|
|
{
|
|
|
|
return mPieces;
|
|
|
|
}
|
|
|
|
|
|
|
|
const lcArray<lcCamera*>& GetCameras() const
|
|
|
|
{
|
|
|
|
return mCameras;
|
|
|
|
}
|
|
|
|
|
|
|
|
const lcArray<lcLight*>& GetLights() const
|
|
|
|
{
|
|
|
|
return mLights;
|
|
|
|
}
|
|
|
|
|
|
|
|
const lcArray<lcGroup*>& GetGroups() const
|
|
|
|
{
|
|
|
|
return mGroups;
|
|
|
|
}
|
|
|
|
|
2014-07-06 08:04:09 +02:00
|
|
|
lcStep GetLastStep() const;
|
2014-08-17 22:44:12 +02:00
|
|
|
|
2014-07-06 08:04:09 +02:00
|
|
|
lcStep GetCurrentStep() const
|
|
|
|
{
|
|
|
|
return mCurrentStep;
|
|
|
|
}
|
|
|
|
|
2014-09-02 05:44:51 +02:00
|
|
|
lcGroup* GetGroup(const char* Name, bool CreateIfMissing);
|
|
|
|
|
2014-09-05 02:24:28 +02:00
|
|
|
void SaveLDraw(QTextStream& Stream) const;
|
2014-09-14 02:45:45 +02:00
|
|
|
void LoadLDraw(QTextStream& Stream);
|
2014-09-02 05:44:51 +02:00
|
|
|
|
2014-09-04 16:27:37 +02:00
|
|
|
void SaveBinary(lcFile& File) const;
|
|
|
|
void LoadBinary(lcFile& File);
|
2014-08-30 01:52:42 +02:00
|
|
|
|
2014-08-17 22:44:12 +02:00
|
|
|
lcObject* GetFocusObject() const;
|
|
|
|
void FocusOrDeselectObject(const lcObjectSection& ObjectSection);
|
|
|
|
void ClearSelectionAndSetFocus(lcObject* Object, lcuint32 Section);
|
|
|
|
void ClearSelectionAndSetFocus(const lcObjectSection& ObjectSection);
|
|
|
|
void SetSelection(const lcArray<lcObjectSection>& ObjectSections);
|
|
|
|
void AddToSelection(const lcArray<lcObjectSection>& ObjectSections);
|
|
|
|
|
2014-05-27 00:58:08 +02:00
|
|
|
protected:
|
2014-09-02 05:44:51 +02:00
|
|
|
void CalculateStep();
|
2014-08-17 22:44:12 +02:00
|
|
|
void UpdateSelection() const;
|
|
|
|
void SelectGroup(lcGroup* TopGroup, bool Select);
|
|
|
|
void ClearSelection(bool UpdateInterface);
|
|
|
|
|
2014-05-25 03:45:19 +02:00
|
|
|
lcModelProperties mProperties;
|
|
|
|
|
2014-07-06 08:04:09 +02:00
|
|
|
lcStep mCurrentStep;
|
|
|
|
|
2014-05-25 03:45:19 +02:00
|
|
|
lcArray<lcPiece*> mPieces;
|
|
|
|
lcArray<lcCamera*> mCameras;
|
|
|
|
lcArray<lcLight*> mLights;
|
|
|
|
lcArray<lcGroup*> mGroups;
|
2014-07-03 21:10:04 +02:00
|
|
|
|
2014-07-04 19:35:52 +02:00
|
|
|
lcModelHistoryEntry* mSavedHistory;
|
2014-07-03 21:10:04 +02:00
|
|
|
lcArray<lcModelHistoryEntry*> mUndoHistory;
|
|
|
|
lcArray<lcModelHistoryEntry*> mRedoHistory;
|
2014-05-25 03:45:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _LC_MODEL_H_
|