mirror of
https://github.com/leozide/leocad.git
synced 2026-10-26 22:10:32 +00:00
Full before-and-after model snapshots accumulate large amounts of memory during editing, even when an operation changes only one object. Compact completed edits to retain only added, removed, or modified object states, with ordering metadata kept only for structural changes. Restore objects by stable IDs, including group relationships, and detach views before removing cameras. Compose merged edits from their deltas and compare animation keys as well as current property values so keyframe-only edits remain undoable.
116 lines
2.0 KiB
C++
116 lines
2.0 KiB
C++
#pragma once
|
|
|
|
enum class lcObjectPropertyId
|
|
{
|
|
PieceId,
|
|
PieceColor,
|
|
PieceStepShow,
|
|
PieceStepHide,
|
|
CameraName,
|
|
CameraProjection,
|
|
CameraFOV,
|
|
CameraNear,
|
|
CameraFar,
|
|
CameraPositionX,
|
|
CameraPositionY,
|
|
CameraPositionZ,
|
|
CameraTargetX,
|
|
CameraTargetY,
|
|
CameraTargetZ,
|
|
CameraUpX,
|
|
CameraUpY,
|
|
CameraUpZ,
|
|
LightName,
|
|
LightType,
|
|
LightColor,
|
|
LightBlenderPower,
|
|
LightPOVRayPower,
|
|
LightCastShadow,
|
|
LightPOVRayFadeDistance,
|
|
LightPOVRayFadePower,
|
|
LightBlenderRadius,
|
|
LightBlenderAngle,
|
|
LightAreaSizeX,
|
|
LightAreaSizeY,
|
|
LightSpotConeAngle,
|
|
LightSpotPenumbraAngle,
|
|
LightPOVRaySpotTightness,
|
|
LightAreaShape,
|
|
LightPOVRayAreaGridX,
|
|
LightPOVRayAreaGridY,
|
|
ObjectPositionX,
|
|
ObjectPositionY,
|
|
ObjectPositionZ,
|
|
ObjectRotationX,
|
|
ObjectRotationY,
|
|
ObjectRotationZ,
|
|
Count
|
|
};
|
|
|
|
enum class lcFloatPropertySnap
|
|
{
|
|
Auto,
|
|
PiecePositionXY,
|
|
PiecePositionZ,
|
|
Position,
|
|
Rotation
|
|
};
|
|
|
|
template<typename T>
|
|
struct lcObjectPropertyKey
|
|
{
|
|
lcStep Step;
|
|
T Value;
|
|
|
|
bool operator==(const lcObjectPropertyKey& Other) const
|
|
{
|
|
return Step == Other.Step && Value == Other.Value;
|
|
}
|
|
};
|
|
|
|
template<typename T>
|
|
class lcObjectProperty
|
|
{
|
|
public:
|
|
lcObjectProperty() = default;
|
|
|
|
explicit lcObjectProperty(const T& DefaultValue)
|
|
: mValue(DefaultValue)
|
|
{
|
|
}
|
|
|
|
operator const T& () const
|
|
{
|
|
return mValue;
|
|
}
|
|
|
|
bool operator==(const lcObjectProperty& Other) const
|
|
{
|
|
return mValue == Other.mValue && mKeys == Other.mKeys;
|
|
}
|
|
|
|
void SetValue(const T& Value)
|
|
{
|
|
mValue = Value;
|
|
}
|
|
|
|
void RemoveAllKeys()
|
|
{
|
|
mKeys.clear();
|
|
}
|
|
|
|
void Update(lcStep Step);
|
|
bool ChangeKey(const T& Value, lcStep Step, bool AddKey);
|
|
void InsertTime(lcStep Start, lcStep Time);
|
|
void RemoveTime(lcStep Start, lcStep Time);
|
|
bool HasKeyFrame(lcStep Time) const;
|
|
bool SetKeyFrame(lcStep Time, bool KeyFrame);
|
|
|
|
void Save(QTextStream& Stream, const char* ObjectName, const char* VariableName, bool SaveEmpty) const;
|
|
bool Load(QTextStream& Stream, const QString& Token, const char* VariableName);
|
|
|
|
protected:
|
|
T mValue;
|
|
std::vector<lcObjectPropertyKey<T>> mKeys;
|
|
};
|