summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorleo2002-03-16 00:51:24 +0000
committerleo2002-03-16 00:51:24 +0000
commit9c26a3e985e6d449860debe3b466cb18ca25d4d1 (patch)
treec4cfc5eee66020f8cb33e036be6967635e821347
parent6dd63e41ece8c1eb73c1708963ab9ff4988e0dba (diff)
Added a new group button to the Edit Groups Dialog.
git-svn-id: http://svn.leocad.org/trunk@287 c7d43263-9d01-0410-8a33-9dba5d9f93d6
-rw-r--r--common/project.cpp32
-rw-r--r--common/project.h11
-rw-r--r--win/EdGrpDlg.cpp51
-rw-r--r--win/EdGrpDlg.h1
-rw-r--r--win/LeoCAD.rc1
-rw-r--r--win/resource.h3
6 files changed, 92 insertions, 7 deletions
diff --git a/common/project.cpp b/common/project.cpp
index c2c8c4f..cf1d53c 100644
--- a/common/project.cpp
+++ b/common/project.cpp
@@ -5823,6 +5823,38 @@ void Project::RemoveEmptyGroups()
RemoveEmptyGroups();
}
+Group* Project::AddGroup (const char* name, Group* pParent, float x, float y, float z)
+{
+ Group *pNewGroup = new Group();
+
+ if (name == NULL)
+ {
+ int i, max = 0;
+ char str[65];
+
+ for (Group *pGroup = m_pGroups; pGroup; pGroup = pGroup->m_pNext)
+ if (strncmp (pGroup->m_strName, "Group #", 7) == 0)
+ if (sscanf(pGroup->m_strName, "Group #%d", &i) == 1)
+ if (i > max)
+ max = i;
+ sprintf (str, "Group #%.2d", max+1);
+
+ strcpy (pNewGroup->m_strName, str);
+ }
+ else
+ strcpy (pNewGroup->m_strName, name);
+
+ pNewGroup->m_pNext = m_pGroups;
+ m_pGroups = pNewGroup;
+
+ pNewGroup->m_fCenter[0] = x;
+ pNewGroup->m_fCenter[1] = y;
+ pNewGroup->m_fCenter[2] = z;
+ pNewGroup->m_pGroup = pParent;
+
+ return pNewGroup;
+}
+
void Project::SelectAndFocusNone(bool bFocusOnly)
{
Piece* pPiece;
diff --git a/common/project.h b/common/project.h
index a9bb1e8..95e26f3 100644
--- a/common/project.h
+++ b/common/project.h
@@ -64,8 +64,10 @@ public:
{ return m_LibraryPath; }
void SetCurrentPiece(PieceInfo* pInfo)
{ m_pCurPiece = pInfo; }
- int GetCurrentColor()
+ int GetCurrentColor () const
{ return m_nCurColor; }
+ int GetCurrentGroup () const
+ { return m_nCurGroup; }
float* GetBackgroundColor()
{ return m_fBackground; }
Camera* GetCamera(int i);
@@ -99,10 +101,11 @@ public:
PieceInfo* FindPieceInfo (const char* name) const;
void CheckAutoSave();
void GetFocusPosition(float* pos);
+ Group* AddGroup (const char* name, Group* pParent, float x, float y, float z);
- void AddView (View* pView);
- void RemoveView (View* pView);
- void UpdateAllViews (View* pSender = NULL);
+ void AddView (View* pView);
+ void RemoveView (View* pView);
+ void UpdateAllViews (View* pSender = NULL);
// Implementation
protected:
diff --git a/win/EdGrpDlg.cpp b/win/EdGrpDlg.cpp
index c1b9b19..48c894d 100644
--- a/win/EdGrpDlg.cpp
+++ b/win/EdGrpDlg.cpp
@@ -4,6 +4,8 @@
#include "stdafx.h"
#include "leocad.h"
#include "EdGrpDlg.h"
+#include "globals.h"
+#include "project.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@@ -36,6 +38,7 @@ void CEditGroupsDlg::DoDataExchange(CDataExchange* pDX)
BEGIN_MESSAGE_MAP(CEditGroupsDlg, CDialog)
//{{AFX_MSG_MAP(CEditGroupsDlg)
+ ON_BN_CLICKED(IDC_EDITGRP_NEWGROUP, OnEditgrpNewgroup)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
@@ -52,6 +55,50 @@ BOOL CEditGroupsDlg::OnInitDialog()
m_Tree.DeleteAllItems();
m_Tree.AddChildren(NULL, NULL);
-
- return TRUE;
+
+ return TRUE;
+}
+
+void CEditGroupsDlg::OnEditgrpNewgroup()
+{
+ HTREEITEM hItem, hParent = NULL;
+ Group *pGroup, *pParent = NULL;
+ TVITEM item;
+
+ hItem = m_Tree.GetSelectedItem ();
+
+ if (hItem != NULL)
+ {
+ item.hItem = hItem;
+ item.mask = TVIF_HANDLE | TVIF_PARAM;
+
+ if (m_Tree.GetItem (&item))
+ {
+ if (item.lParam < 0xFFFF)
+ hParent = m_Tree.GetParentItem (hItem);
+ else
+ hParent = hItem;
+ }
+ }
+
+ if (hParent)
+ {
+ item.hItem = hParent;
+ item.mask = TVIF_HANDLE | TVIF_PARAM;
+
+ if (m_Tree.GetItem (&item))
+ pParent = m_Tree.opts->groups[item.lParam - 0xFFFF];
+ }
+
+ pGroup = project->AddGroup (NULL, pParent, 0, 0, 0);
+
+ m_Tree.opts->groupcount++;
+ m_Tree.opts->groups = (Group**)realloc(m_Tree.opts->groups, m_Tree.opts->groupcount*sizeof(Group*));
+ m_Tree.opts->groupsgroups = (Group**)realloc(m_Tree.opts->groupsgroups, m_Tree.opts->groupcount*sizeof(Group*));
+
+ m_Tree.opts->groups[m_Tree.opts->groupcount-1] = pGroup;
+ m_Tree.opts->groupsgroups[m_Tree.opts->groupcount-1] = pParent;
+
+ m_Tree.DeleteAllItems();
+ m_Tree.AddChildren(NULL, NULL);
}
diff --git a/win/EdGrpDlg.h b/win/EdGrpDlg.h
index 3e72ae4..4a03cf3 100644
--- a/win/EdGrpDlg.h
+++ b/win/EdGrpDlg.h
@@ -39,6 +39,7 @@ protected:
// Generated message map functions
//{{AFX_MSG(CEditGroupsDlg)
virtual BOOL OnInitDialog();
+ afx_msg void OnEditgrpNewgroup();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
diff --git a/win/LeoCAD.rc b/win/LeoCAD.rc
index 4b6b923..ef6d7c8 100644
--- a/win/LeoCAD.rc
+++ b/win/LeoCAD.rc
@@ -1379,6 +1379,7 @@ BEGIN
CONTROL "Tree1",IDC_TREE,"SysTreeView32",TVS_HASBUTTONS |
TVS_HASLINES | TVS_LINESATROOT | TVS_EDITLABELS |
WS_BORDER | WS_TABSTOP,7,7,179,122
+ PUSHBUTTON "New",IDC_EDITGRP_NEWGROUP,7,136,41,14
END
diff --git a/win/resource.h b/win/resource.h
index 779ebab..a9210d4 100644
--- a/win/resource.h
+++ b/win/resource.h
@@ -6,6 +6,7 @@
#define IDC_HTMDLG_IMAGEOPTIONS 3
#define ID_EDITOR_PREV 3
#define ID_EDITOR_FLIP 4
+#define IDC_EDITGRP_NEWGROUP 4
#define ID_EDITOR_NEXT 5
#define IDD_ABOUTBOX 100
#define ID_INDICATOR_POSITION 102
@@ -650,7 +651,7 @@
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 234
#define _APS_NEXT_COMMAND_VALUE 33155
-#define _APS_NEXT_CONTROL_VALUE 1224
+#define _APS_NEXT_CONTROL_VALUE 1225
#define _APS_NEXT_SYMED_VALUE 121
#endif
#endif