Merged selection/focus code in the lcObject class.
This commit is contained in:
+1
-1
@@ -909,7 +909,7 @@ void lcCamera::RemoveKeyFrames()
|
||||
|
||||
bool lcCamera::SaveUndoData(QDataStream& Stream, const lcModel* Model) const
|
||||
{
|
||||
static_assert(sizeof(lcCamera) == 240);
|
||||
static_assert(sizeof(lcCamera) == 248);
|
||||
Q_UNUSED(Model);
|
||||
|
||||
Stream << m_fovy;
|
||||
|
||||
+4
-91
@@ -3,18 +3,9 @@
|
||||
#include "object.h"
|
||||
#include "lc_math.h"
|
||||
|
||||
#define LC_CAMERA_HIDDEN 0x0001
|
||||
#define LC_CAMERA_SIMPLE 0x0002
|
||||
#define LC_CAMERA_ORTHO 0x0004
|
||||
#define LC_CAMERA_POSITION_SELECTED 0x0010
|
||||
#define LC_CAMERA_POSITION_FOCUSED 0x0020
|
||||
#define LC_CAMERA_TARGET_SELECTED 0x0040
|
||||
#define LC_CAMERA_TARGET_FOCUSED 0x0080
|
||||
#define LC_CAMERA_UPVECTOR_SELECTED 0x0100
|
||||
#define LC_CAMERA_UPVECTOR_FOCUSED 0x0200
|
||||
|
||||
#define LC_CAMERA_SELECTION_MASK (LC_CAMERA_POSITION_SELECTED | LC_CAMERA_TARGET_SELECTED | LC_CAMERA_UPVECTOR_SELECTED)
|
||||
#define LC_CAMERA_FOCUS_MASK (LC_CAMERA_POSITION_FOCUSED | LC_CAMERA_TARGET_FOCUSED | LC_CAMERA_UPVECTOR_FOCUSED)
|
||||
#define LC_CAMERA_HIDDEN 0x01
|
||||
#define LC_CAMERA_SIMPLE 0x02
|
||||
#define LC_CAMERA_ORTHO 0x04
|
||||
|
||||
enum class lcViewpoint
|
||||
{
|
||||
@@ -37,7 +28,7 @@ enum class lcCameraType
|
||||
|
||||
enum lcCameraSection : quint32
|
||||
{
|
||||
LC_CAMERA_SECTION_INVALID = ~0U,
|
||||
LC_CAMERA_SECTION_INVALID = LC_OBJECT_SECTION_INVALID,
|
||||
LC_CAMERA_SECTION_POSITION = 0,
|
||||
LC_CAMERA_SECTION_TARGET,
|
||||
LC_CAMERA_SECTION_UPVECTOR
|
||||
@@ -94,84 +85,6 @@ public:
|
||||
mState &= ~LC_CAMERA_ORTHO;
|
||||
}
|
||||
|
||||
bool IsSelected() const override
|
||||
{
|
||||
return (mState & LC_CAMERA_SELECTION_MASK) != 0;
|
||||
}
|
||||
|
||||
void SetSelected(bool Selected) override
|
||||
{
|
||||
if (Selected)
|
||||
mState |= LC_CAMERA_SELECTION_MASK;
|
||||
else
|
||||
mState &= ~(LC_CAMERA_SELECTION_MASK | LC_CAMERA_FOCUS_MASK);
|
||||
}
|
||||
|
||||
bool IsFocused() const override
|
||||
{
|
||||
return (mState & LC_CAMERA_FOCUS_MASK) != 0;
|
||||
}
|
||||
|
||||
bool IsFocused(quint32 Section) const override
|
||||
{
|
||||
switch (Section)
|
||||
{
|
||||
case LC_CAMERA_SECTION_POSITION:
|
||||
return (mState & LC_CAMERA_POSITION_FOCUSED) != 0;
|
||||
break;
|
||||
|
||||
case LC_CAMERA_SECTION_TARGET:
|
||||
return (mState & LC_CAMERA_TARGET_FOCUSED) != 0;
|
||||
break;
|
||||
|
||||
case LC_CAMERA_SECTION_UPVECTOR:
|
||||
return (mState & LC_CAMERA_UPVECTOR_FOCUSED) != 0;
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SetFocused(quint32 Section, bool Focus) override
|
||||
{
|
||||
switch (Section)
|
||||
{
|
||||
case LC_CAMERA_SECTION_POSITION:
|
||||
if (Focus)
|
||||
mState |= LC_CAMERA_SELECTION_MASK | LC_CAMERA_POSITION_FOCUSED;
|
||||
else
|
||||
mState &= ~LC_CAMERA_POSITION_FOCUSED;
|
||||
break;
|
||||
|
||||
case LC_CAMERA_SECTION_TARGET:
|
||||
if (Focus)
|
||||
mState |= LC_CAMERA_SELECTION_MASK | LC_CAMERA_TARGET_FOCUSED;
|
||||
else
|
||||
mState &= ~LC_CAMERA_TARGET_FOCUSED;
|
||||
break;
|
||||
|
||||
case LC_CAMERA_SECTION_UPVECTOR:
|
||||
if (Focus)
|
||||
mState |= LC_CAMERA_SELECTION_MASK | LC_CAMERA_UPVECTOR_FOCUSED;
|
||||
else
|
||||
mState &= ~LC_CAMERA_UPVECTOR_FOCUSED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
quint32 GetFocusSection() const override
|
||||
{
|
||||
if (mState & LC_CAMERA_POSITION_FOCUSED)
|
||||
return LC_CAMERA_SECTION_POSITION;
|
||||
|
||||
if (mState & LC_CAMERA_TARGET_FOCUSED)
|
||||
return LC_CAMERA_SECTION_TARGET;
|
||||
|
||||
if (mState & LC_CAMERA_UPVECTOR_FOCUSED)
|
||||
return LC_CAMERA_SECTION_UPVECTOR;
|
||||
|
||||
return LC_CAMERA_SECTION_INVALID;
|
||||
}
|
||||
|
||||
quint32 GetAllowedTransforms() const override
|
||||
{
|
||||
return LC_OBJECT_TRANSFORM_MOVE_XYZ;
|
||||
|
||||
+1
-42
@@ -8,7 +8,7 @@
|
||||
|
||||
enum lcLightSection : quint32
|
||||
{
|
||||
LC_LIGHT_SECTION_INVALID = ~0U,
|
||||
LC_LIGHT_SECTION_INVALID = LC_OBJECT_SECTION_INVALID,
|
||||
LC_LIGHT_SECTION_POSITION = 0,
|
||||
LC_LIGHT_SECTION_TARGET
|
||||
};
|
||||
@@ -76,45 +76,6 @@ public:
|
||||
|
||||
bool SetLightType(lcLightType LightType);
|
||||
|
||||
bool IsSelected() const override
|
||||
{
|
||||
return mSelected;
|
||||
}
|
||||
|
||||
void SetSelected(bool Selected) override
|
||||
{
|
||||
mSelected = Selected;
|
||||
|
||||
if (!Selected)
|
||||
mFocusedSection = LC_LIGHT_SECTION_INVALID;
|
||||
}
|
||||
|
||||
bool IsFocused() const override
|
||||
{
|
||||
return mFocusedSection != LC_LIGHT_SECTION_INVALID;
|
||||
}
|
||||
|
||||
bool IsFocused(quint32 Section) const override
|
||||
{
|
||||
return mFocusedSection == Section;
|
||||
}
|
||||
|
||||
void SetFocused(quint32 Section, bool Focused) override
|
||||
{
|
||||
if (Focused)
|
||||
{
|
||||
mFocusedSection = Section;
|
||||
mSelected = true;
|
||||
}
|
||||
else
|
||||
mFocusedSection = LC_LIGHT_SECTION_INVALID;
|
||||
}
|
||||
|
||||
quint32 GetFocusSection() const override
|
||||
{
|
||||
return mFocusedSection;
|
||||
}
|
||||
|
||||
quint32 GetAllowedTransforms() const override
|
||||
{
|
||||
if (IsPointLight())
|
||||
@@ -373,8 +334,6 @@ protected:
|
||||
lcObjectProperty<int> mPOVRayAreaGridY = lcObjectProperty<int>(2);
|
||||
|
||||
quint32 mState = 0;
|
||||
bool mSelected = false;
|
||||
quint32 mFocusedSection = LC_LIGHT_SECTION_INVALID;
|
||||
lcVector3 mTargetMovePosition = lcVector3(0.0f, 0.0f, 0.0f);
|
||||
lcMatrix44 mWorldMatrix;
|
||||
|
||||
|
||||
+46
-8
@@ -55,6 +55,8 @@ struct lcObjectBoxTest
|
||||
#define LC_OBJECT_TRANSFORM_SCALE_Z 0x400
|
||||
#define LC_OBJECT_TRANSFORM_SCALE_XYZ (LC_OBJECT_TRANSFORM_SCALE_X | LC_OBJECT_TRANSFORM_SCALE_Y | LC_OBJECT_TRANSFORM_SCALE_Z)
|
||||
|
||||
#define LC_OBJECT_SECTION_INVALID 0xffffffff
|
||||
|
||||
class lcObject
|
||||
{
|
||||
public:
|
||||
@@ -86,14 +88,46 @@ public:
|
||||
{
|
||||
return mObjectType;
|
||||
}
|
||||
|
||||
virtual bool IsSelected() const = 0;
|
||||
virtual void SetSelected(bool Selected) = 0;
|
||||
virtual bool IsFocused() const = 0;
|
||||
virtual bool IsFocused(quint32 Section) const = 0;
|
||||
virtual void SetFocused(quint32 Section, bool Focused) = 0;
|
||||
virtual quint32 GetFocusSection() const = 0;
|
||||
|
||||
|
||||
bool IsSelected() const
|
||||
{
|
||||
return mSelected;
|
||||
}
|
||||
|
||||
void SetSelected(bool Selected)
|
||||
{
|
||||
mSelected = Selected;
|
||||
|
||||
if (!Selected)
|
||||
mFocusedSection = LC_OBJECT_SECTION_INVALID;
|
||||
}
|
||||
|
||||
bool IsFocused() const
|
||||
{
|
||||
return mFocusedSection != LC_OBJECT_SECTION_INVALID;
|
||||
}
|
||||
|
||||
bool IsFocused(quint32 Section) const
|
||||
{
|
||||
return mFocusedSection == Section;
|
||||
}
|
||||
|
||||
void SetFocused(quint32 Section, bool Focused)
|
||||
{
|
||||
if (Focused)
|
||||
{
|
||||
mFocusedSection = Section;
|
||||
mSelected = true;
|
||||
}
|
||||
else
|
||||
mFocusedSection = LC_OBJECT_SECTION_INVALID;
|
||||
}
|
||||
|
||||
quint32 GetFocusSection() const
|
||||
{
|
||||
return mFocusedSection;
|
||||
}
|
||||
|
||||
virtual void UpdatePosition(lcStep Step) = 0;
|
||||
virtual quint32 GetAllowedTransforms() const = 0;
|
||||
virtual lcVector3 GetSectionPosition(quint32 Section) const = 0;
|
||||
@@ -112,4 +146,8 @@ public:
|
||||
|
||||
private:
|
||||
lcObjectType mObjectType;
|
||||
|
||||
protected:
|
||||
bool mSelected = false;
|
||||
quint32 mFocusedSection = LC_OBJECT_SECTION_INVALID;
|
||||
};
|
||||
|
||||
+1
-1
@@ -937,7 +937,7 @@ void lcPiece::RemoveKeyFrames()
|
||||
|
||||
bool lcPiece::SaveUndoData(QDataStream& Stream, const lcModel* Model) const
|
||||
{
|
||||
static_assert(sizeof(lcPiece) == 376);
|
||||
static_assert(sizeof(lcPiece) == 384);
|
||||
|
||||
Stream << mFileLine;
|
||||
Stream << mID;
|
||||
|
||||
+1
-42
@@ -10,7 +10,7 @@ class PieceInfo;
|
||||
|
||||
enum lcPieceSection : quint32
|
||||
{
|
||||
LC_PIECE_SECTION_INVALID = ~0U,
|
||||
LC_PIECE_SECTION_INVALID = LC_OBJECT_SECTION_INVALID,
|
||||
LC_PIECE_SECTION_POSITION = 0,
|
||||
LC_PIECE_SECTION_CONTROL_POINT_FIRST,
|
||||
LC_PIECE_SECTION_CONTROL_POINT_LAST = LC_PIECE_SECTION_CONTROL_POINT_FIRST + LC_MAX_CONTROL_POINTS - 1,
|
||||
@@ -36,45 +36,6 @@ public:
|
||||
|
||||
void CopyProperties(const lcPiece& Other);
|
||||
|
||||
bool IsSelected() const override
|
||||
{
|
||||
return mSelected;
|
||||
}
|
||||
|
||||
void SetSelected(bool Selected) override
|
||||
{
|
||||
mSelected = Selected;
|
||||
|
||||
if (!Selected)
|
||||
mFocusedSection = LC_PIECE_SECTION_INVALID;
|
||||
}
|
||||
|
||||
bool IsFocused() const override
|
||||
{
|
||||
return mFocusedSection != LC_PIECE_SECTION_INVALID;
|
||||
}
|
||||
|
||||
bool IsFocused(quint32 Section) const override
|
||||
{
|
||||
return mFocusedSection == Section;
|
||||
}
|
||||
|
||||
void SetFocused(quint32 Section, bool Focused) override
|
||||
{
|
||||
if (Focused)
|
||||
{
|
||||
mFocusedSection = Section;
|
||||
mSelected = true;
|
||||
}
|
||||
else
|
||||
mFocusedSection = LC_PIECE_SECTION_INVALID;
|
||||
}
|
||||
|
||||
quint32 GetFocusSection() const override
|
||||
{
|
||||
return mFocusedSection;
|
||||
}
|
||||
|
||||
quint32 GetAllowedTransforms() const override;
|
||||
lcVector3 GetSectionPosition(quint32 Section) const override;
|
||||
|
||||
@@ -315,8 +276,6 @@ protected:
|
||||
|
||||
bool mPivotPointValid = false;
|
||||
bool mHidden = false;
|
||||
bool mSelected = false;
|
||||
quint32 mFocusedSection = LC_PIECE_SECTION_INVALID;
|
||||
std::vector<lcPieceControlPoint> mControlPoints;
|
||||
std::vector<bool> mTrainTrackConnections;
|
||||
lcMesh* mMesh = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user