summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorleo2006-02-26 22:06:29 +0000
committerleo2006-02-26 22:06:29 +0000
commitf4e2b1c72b90a0e5b85dd2e190351acdadcc5baa (patch)
treee3b6086d09054ed5569ca22df4e8729f6ee58107
parent4e11b17e7365ba4bb8bedddc96576562cd635d75 (diff)
Show selection on the status bar.
git-svn-id: http://svn.leocad.org/trunk@497 c7d43263-9d01-0410-8a33-9dba5d9f93d6
-rw-r--r--common/camera.cpp5
-rw-r--r--common/camera.h31
-rwxr-xr-xcommon/curve.cpp4
-rw-r--r--common/light.cpp5
-rw-r--r--common/light.h109
-rwxr-xr-xcommon/object.h1
-rw-r--r--common/piece.h22
-rw-r--r--common/project.cpp39
-rwxr-xr-xcommon/system.h2
-rw-r--r--linux/system.cpp2
-rw-r--r--win/Mainfrm.cpp13
-rw-r--r--win/System.cpp27
12 files changed, 174 insertions, 86 deletions
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);
diff --git a/linux/system.cpp b/linux/system.cpp
index 2683b3f..50fd357 100644
--- a/linux/system.cpp
+++ b/linux/system.cpp
@@ -477,7 +477,7 @@ void SystemUpdateSnap(unsigned short move_snap, unsigned short RotateSnap)
gtk_label_set (GTK_LABEL (label_snap), text);
}
-void SystemUpdateSelected(unsigned long flags)
+void SystemUpdateSelected(unsigned long flags, int SelectedCount, Object* Focus)
{
GtkWidget *item;
diff --git a/win/Mainfrm.cpp b/win/Mainfrm.cpp
index 6754379..cb980ab 100644
--- a/win/Mainfrm.cpp
+++ b/win/Mainfrm.cpp
@@ -1082,16 +1082,12 @@ LRESULT CMainFrame::OnSetMessageString(WPARAM wParam, LPARAM lParam)
CString strMessage;
// set the message bar text
- if (!m_strStatusBar.IsEmpty())
- {
- lpsz = m_strStatusBar;
- }
- else if (lParam != 0)
+ if (lParam != 0)
{
ASSERT(wParam == 0); // can't have both an ID and a string
lpsz = (LPCTSTR)lParam; // set an explicit string
}
- else if (wParam != 0)
+ else if ((wParam != 0) && !(wParam == AFX_IDS_IDLEMESSAGE && !m_strStatusBar.IsEmpty()))
{
// map SC_CLOSE to PREVIEW_CLOSE when in print preview mode
if (wParam == AFX_IDS_SCCLOSE && m_lpfnCloseProc != NULL)
@@ -1101,6 +1097,11 @@ LRESULT CMainFrame::OnSetMessageString(WPARAM wParam, LPARAM lParam)
GetMessageString(wParam, strMessage);
lpsz = strMessage;
}
+ else if (!m_strStatusBar.IsEmpty())
+ {
+ lpsz = m_strStatusBar;
+ }
+
pMessageBar->SetWindowText(lpsz);
// update owner of the bar in terms of last message selected
diff --git a/win/System.cpp b/win/System.cpp
index 89b57ca..47db92b 100644
--- a/win/System.cpp
+++ b/win/System.cpp
@@ -586,10 +586,10 @@ void SystemUpdateSnap(const unsigned long nSnap)
// TODO: change Snap None & All (or maybe not ?)
}
-void SystemUpdateSelected(unsigned long flags)
+void SystemUpdateSelected(unsigned long flags, int SelectedCount, Object* Focus)
{
CMenu* pMenu;
- CFrameWnd* pFrame = (CFrameWnd*)AfxGetMainWnd();
+ CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
if (!pFrame)
return;
CToolBar* pBar = (CToolBar*)pFrame->GetControlBar(AFX_IDW_TOOLBAR);
@@ -655,6 +655,29 @@ void SystemUpdateSelected(unsigned long flags)
pCtrl->EnableButton(ID_PIECE_PREVIOUS, flags & LC_SEL_PIECE ? TRUE : FALSE);
pCtrl->EnableButton(ID_PIECE_NEXT, flags & LC_SEL_PIECE ? TRUE : FALSE);
+
+ // Status bar text.
+ if (SelectedCount == 0)
+ {
+ pFrame->SetStatusBarMessage("");
+ pFrame->SetMessageText(AFX_IDS_IDLEMESSAGE);
+ }
+ else if ((SelectedCount == 1) && (Focus != NULL))
+ {
+ pFrame->SetStatusBarMessage(Focus->GetName());
+ pFrame->SetMessageText(Focus->GetName());
+ }
+ else
+ {
+ char Message[256];
+ if (SelectedCount == 1)
+ strcpy(Message, "1 Object selected.");
+ else
+ sprintf(Message, "%d Objects selected.", SelectedCount);
+
+ pFrame->SetStatusBarMessage(Message);
+ pFrame->SetMessageText(Message);
+ }
}
// Changed current step/frame