From f4e2b1c72b90a0e5b85dd2e190351acdadcc5baa Mon Sep 17 00:00:00 2001 From: leo Date: Sun, 26 Feb 2006 22:06:29 +0000 Subject: Show selection on the status bar. git-svn-id: http://svn.leocad.org/trunk@497 c7d43263-9d01-0410-8a33-9dba5d9f93d6 --- common/camera.cpp | 5 +++ common/camera.h | 31 ++++++++------- common/curve.cpp | 4 ++ common/light.cpp | 5 +++ common/light.h | 109 ++++++++++++++++++++++++++++------------------------- common/object.h | 1 + common/piece.h | 22 ++++++----- common/project.cpp | 39 +++++++++++++++++-- common/system.h | 2 +- 9 files changed, 141 insertions(+), 77 deletions(-) (limited to 'common') diff --git a/common/camera.cpp b/common/camera.cpp index 65a5bbb..a663037 100644 --- a/common/camera.cpp +++ b/common/camera.cpp @@ -57,6 +57,11 @@ void CameraTarget::Select (bool bSelecting, bool bFocus, bool bMultiple) m_pParent->SelectTarget (bSelecting, bFocus, bMultiple); } +const char* CameraTarget::GetName() const +{ + return m_pParent->GetName(); +} + ///////////////////////////////////////////////////////////////////////////// // Camera construction/destruction diff --git a/common/camera.h b/common/camera.h index c129415..0e3cb2b 100644 --- a/common/camera.h +++ b/common/camera.h @@ -38,24 +38,26 @@ public: CameraTarget (Camera *pParent); virtual ~CameraTarget (); - public: - void MinIntersectDist (LC_CLICKLINE* pLine); +public: + void MinIntersectDist (LC_CLICKLINE* pLine); bool IntersectsVolume(const Vector4* Planes, int NumPlanes) { return false; } - void Select (bool bSelecting, bool bFocus, bool bMultiple); - void Move (unsigned short nTime, bool bAnimation, bool bAddKey, float x, float y, float z) - { - // FIXME: move the position handling to the camera target - } + void Select (bool bSelecting, bool bFocus, bool bMultiple); + void Move (unsigned short nTime, bool bAnimation, bool bAddKey, float x, float y, float z) + { + // FIXME: move the position handling to the camera target + } - Camera* GetParent () const - { return m_pParent; } + const char* GetName() const; - protected: - Camera* m_pParent; + Camera* GetParent () const + { return m_pParent; } - friend class Camera; // FIXME: needed for BoundingBoxCalculate () - // remove and use UpdatePosition instead +protected: + Camera* m_pParent; + + friend class Camera; // FIXME: needed for BoundingBoxCalculate () + // remove and use UpdatePosition instead }; class Camera : public Object @@ -75,6 +77,9 @@ public: inline Vector3 GetUpVector() const { return Vector3(m_fUp[0], m_fUp[1], m_fUp[2]); }; + const char* GetName() const + { return m_strName; }; + CameraTarget* GetTarget () const { return m_pTarget; } diff --git a/common/curve.cpp b/common/curve.cpp index c20b804..c9646a4 100755 --- a/common/curve.cpp +++ b/common/curve.cpp @@ -250,6 +250,7 @@ Curve::Curve () Curve::Curve (PieceInfo *pInfo, const float *pos, unsigned char color) : Object (LC_OBJECT_CURVE) { + /* Initialize (); // FIXME: set the curve type and length based on the PieceInfo @@ -281,13 +282,16 @@ Curve::Curve (PieceInfo *pInfo, const float *pos, unsigned char color) m_Points.Add (pt); UpdatePosition (1, false); +*/ } Curve::~Curve () { + /* for (int i = 0; i < m_Points.GetSize (); i++) delete m_Points[i]; glDeleteLists (m_nDisplayList, 1); + */ } void Curve::Initialize () diff --git a/common/light.cpp b/common/light.cpp index 233658c..11bf8ad 100644 --- a/common/light.cpp +++ b/common/light.cpp @@ -61,6 +61,11 @@ void LightTarget::Select (bool bSelecting, bool bFocus, bool bMultiple) m_pParent->SelectTarget (bSelecting, bFocus, bMultiple); } +const char* LightTarget::GetName() const +{ + return m_pParent->GetName(); +} + // ============================================================================= // Light class diff --git a/common/light.h b/common/light.h index d5d203b..da1cdb6 100644 --- a/common/light.h +++ b/common/light.h @@ -25,70 +25,77 @@ typedef enum class LightTarget : public Object { - public: - LightTarget (Light *pParent); - ~LightTarget (); +public: + LightTarget (Light *pParent); + ~LightTarget (); - public: - void MinIntersectDist (LC_CLICKLINE* pLine); +public: + void MinIntersectDist (LC_CLICKLINE* pLine); bool IntersectsVolume(const Vector4* Planes, int NumPlanes) { return false; } - void Select (bool bSelecting, bool bFocus, bool bMultiple); - void Move (unsigned short nTime, bool bAnimation, bool bAddKey, float x, float y, float z) - { - // FIXME: move the position handling to the light target - } + void Select (bool bSelecting, bool bFocus, bool bMultiple); + void Move (unsigned short nTime, bool bAnimation, bool bAddKey, float x, float y, float z) + { + // FIXME: move the position handling to the light target + } - Light* GetParent () const - { return m_pParent; } + const char* GetName() const; - protected: - Light* m_pParent; + Light* GetParent () const + { return m_pParent; } + +protected: + Light* m_pParent; - friend class Light; // FIXME: needed for BoundingBoxCalculate () - // remove and use UpdatePosition instead + friend class Light; // FIXME: needed for BoundingBoxCalculate () + // remove and use UpdatePosition instead }; class Light : public Object { - public: - Light (float px, float py, float pz); - Light (float px, float py, float pz, float tx, float ty, float tz); - virtual ~Light (); - - void Select (bool bSelecting, bool bFocus, bool bMultiple); - +public: + Light (float px, float py, float pz); + Light (float px, float py, float pz, float tx, float ty, float tz); + virtual ~Light (); - void SelectTarget (bool bSelecting, bool bFocus, bool bMultiple); + void Select (bool bSelecting, bool bFocus, bool bMultiple); + void SelectTarget (bool bSelecting, bool bFocus, bool bMultiple); public: - Light* m_pNext; - - bool IsVisible() - { return (m_nState & LC_LIGHT_HIDDEN) == 0; } - bool IsSelected() - { return (m_nState & (LC_LIGHT_SELECTED|LC_LIGHT_TARGET_SELECTED)) != 0; } - bool IsEyeSelected() - { return (m_nState & LC_LIGHT_SELECTED) != 0; } - bool IsTargetSelected() - { return (m_nState & LC_LIGHT_TARGET_SELECTED) != 0; } - void Select() - { m_nState |= (LC_LIGHT_SELECTED|LC_LIGHT_TARGET_SELECTED); } - void UnSelect() - { m_nState &= ~(LC_LIGHT_SELECTED|LC_LIGHT_FOCUSED|LC_LIGHT_TARGET_SELECTED|LC_LIGHT_TARGET_FOCUSED); } - void UnFocus() - { m_nState &= ~(LC_LIGHT_FOCUSED|LC_LIGHT_TARGET_FOCUSED); } - void FocusEye() - { m_nState |= (LC_LIGHT_FOCUSED|LC_LIGHT_SELECTED); } - void FocusTarget() - { m_nState |= (LC_LIGHT_TARGET_FOCUSED|LC_LIGHT_TARGET_SELECTED); } - const char* GetName() - { return m_strName; } - void GetTargetPos (float *pos) const - { memcpy (pos, m_fTarget, sizeof (float[3])); } - LightTarget* GetTarget () const - { return m_pTarget; } - + Light* m_pNext; + + bool IsVisible() + { return (m_nState & LC_LIGHT_HIDDEN) == 0; } + bool IsSelected() + { return (m_nState & (LC_LIGHT_SELECTED|LC_LIGHT_TARGET_SELECTED)) != 0; } + bool IsEyeSelected() + { return (m_nState & LC_LIGHT_SELECTED) != 0; } + bool IsTargetSelected() + { return (m_nState & LC_LIGHT_TARGET_SELECTED) != 0; } + bool IsEyeFocused() + { return (m_nState & LC_LIGHT_FOCUSED) != 0; } + bool IsTargetFocused() + { return (m_nState & LC_LIGHT_TARGET_FOCUSED) != 0; } + + void Select() + { m_nState |= (LC_LIGHT_SELECTED|LC_LIGHT_TARGET_SELECTED); } + void UnSelect() + { m_nState &= ~(LC_LIGHT_SELECTED|LC_LIGHT_FOCUSED|LC_LIGHT_TARGET_SELECTED|LC_LIGHT_TARGET_FOCUSED); } + void UnFocus() + { m_nState &= ~(LC_LIGHT_FOCUSED|LC_LIGHT_TARGET_FOCUSED); } + void FocusEye() + { m_nState |= (LC_LIGHT_FOCUSED|LC_LIGHT_SELECTED); } + void FocusTarget() + { m_nState |= (LC_LIGHT_TARGET_FOCUSED|LC_LIGHT_TARGET_SELECTED); } + const char* GetName() + { return m_strName; } + void GetTargetPos (float *pos) const + { memcpy (pos, m_fTarget, sizeof (float[3])); } + LightTarget* GetTarget () const + { return m_pTarget; } + + const char* GetName() const + { return m_strName; }; void Render (float fLineWidth); void MinIntersectDist (LC_CLICKLINE* Line); diff --git a/common/object.h b/common/object.h index 10c5f17..24a6cdb 100755 --- a/common/object.h +++ b/common/object.h @@ -143,6 +143,7 @@ public: LC_OBJECT_TYPE GetType () const { return m_nObjectType; } + virtual const char* GetName() const = 0; /* // For linked lists Object* m_pNext; diff --git a/common/piece.h b/common/piece.h index 6304681..48c7f11 100644 --- a/common/piece.h +++ b/common/piece.h @@ -15,21 +15,22 @@ class PieceInfo; #define LC_PIECE_SELECTED 0x02 #define LC_PIECE_FOCUSED 0x04 -typedef enum { - LC_PK_POSITION, - LC_PK_ROTATION, - LC_PK_COUNT +typedef enum +{ + LC_PK_POSITION, + LC_PK_ROTATION, + LC_PK_COUNT } LC_PK_TYPES; class Piece : public Object { public: - Piece (PieceInfo* pPieceInfo); - ~Piece (); + Piece (PieceInfo* pPieceInfo); + ~Piece (); - void Select (bool bSelecting, bool bFocus, bool bMultiple); - virtual void InsertTime (unsigned short start, bool animation, unsigned short time); - virtual void RemoveTime (unsigned short start, bool animation, unsigned short time); + void Select (bool bSelecting, bool bFocus, bool bMultiple); + virtual void InsertTime (unsigned short start, bool animation, unsigned short time); + virtual void RemoveTime (unsigned short start, bool animation, unsigned short time); virtual bool IntersectsVolume(const Vector4* Planes, int NumPlanes); @@ -50,6 +51,9 @@ public: bool IsFocused() { return (m_nState & LC_PIECE_FOCUSED) != 0; } + const char* GetName() const + { return m_strName; }; + void MinIntersectDist(LC_CLICKLINE* pLine); bool IsVisible(unsigned short nTime, bool bAnimation); void Initialize(float x, float y, float z, unsigned char nStep, unsigned short nFrame, unsigned char nColor); diff --git a/common/project.cpp b/common/project.cpp index f6d3239..dfb6582 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -3219,6 +3219,8 @@ bool Project::RemoveSelectedObjects() void Project::UpdateSelection() { unsigned long flags = 0; + int SelectedCount = 0; + Object* Focus = NULL; if (m_pPieces == NULL) flags |= LC_SEL_NO_PIECES; @@ -3232,6 +3234,11 @@ void Project::UpdateSelection() { if (pPiece->IsSelected()) { + SelectedCount++; + + if (pPiece->IsFocused()) + Focus = pPiece; + if (flags & LC_SEL_PIECE) flags |= LC_SEL_MULTIPLE; else @@ -3270,18 +3277,30 @@ void Project::UpdateSelection() for (Camera* pCamera = m_pCameras; pCamera; pCamera = pCamera->m_pNext) if (pCamera->IsSelected()) + { flags |= LC_SEL_CAMERA; + SelectedCount++; + + if (pCamera->IsEyeFocused() || pCamera->IsTargetFocused()) + Focus = pCamera; + } for (Light* pLight = m_pLights; pLight; pLight = pLight->m_pNext) if (pLight->IsSelected()) + { flags |= LC_SEL_LIGHT; + SelectedCount++; + + if (pLight->IsEyeFocused() || pLight->IsTargetFocused()) + Focus = pLight; + } if (m_nTracking == LC_TRACK_NONE) { ActivateOverlay(); } - SystemUpdateSelected(flags); + SystemUpdateSelected(flags, SelectedCount, Focus); } void Project::CheckAutoSave() @@ -7256,7 +7275,8 @@ void Project::MoveSelectedObjects(Vector3& Move, Vector3& Remainder) if (m_OverlayActive) { - GetSelectionCenter(m_OverlayCenter); + if (!GetFocusPosition(m_OverlayCenter)) + GetSelectionCenter(m_OverlayCenter); } } @@ -7385,6 +7405,12 @@ void Project::RotateSelectedObjects(const Vector3& Delta) for (pPiece = m_pPieces; pPiece; pPiece = pPiece->m_pNext) if (pPiece->IsSelected()) pPiece->CalculateConnections(m_pConnections, m_bAnimation ? m_nCurFrame : m_nCurStep, m_bAnimation, false, true); + + if (m_OverlayActive) + { + if (!GetFocusPosition(m_OverlayCenter)) + GetSelectionCenter(m_OverlayCenter); + } } bool Project::OnKeyDown(char nKey, bool bControl, bool bShift) @@ -9156,7 +9182,14 @@ void Project::MouseUpdateOverlays(int x, int y) void Project::ActivateOverlay() { if ((m_nCurAction == LC_ACTION_MOVE) || (m_nCurAction == LC_ACTION_ROTATE)) - m_OverlayActive = GetSelectionCenter(m_OverlayCenter); + { + if (GetFocusPosition(m_OverlayCenter)) + m_OverlayActive = true; + else if (GetSelectionCenter(m_OverlayCenter)) + m_OverlayActive = true; + else + m_OverlayActive = false; + } else if ((m_nCurAction == LC_ACTION_ZOOM_REGION) && (m_nTracking == LC_TRACK_START_LEFT)) m_OverlayActive = true; else if (m_nCurAction == LC_ACTION_ROTATE_VIEW) diff --git a/common/system.h b/common/system.h index ce47b9a..0010bc6 100755 --- a/common/system.h +++ b/common/system.h @@ -91,7 +91,7 @@ void SystemUpdateCameraMenu(Camera* pCamera); void SystemUpdateTime(bool bAnimation, int nTime, int nTotal); void SystemUpdateAnimation(bool bAnimation, bool bAddKeys); void SystemUpdateSnap(unsigned short MoveSnap, unsigned short RotateSnap); -void SystemUpdateSelected(unsigned long flags); +void SystemUpdateSelected(unsigned long flags, int SelectedCount, class Object* Focus); void SystemUpdatePaste(bool enable); void SystemUpdatePlay(bool play, bool stop); void SystemUpdateCategories(bool SearchOnly); -- cgit v1.2.3