Changeset 702
- Timestamp:
- 08/10/07 17:25:04 (16 months ago)
- Location:
- trunk
- Files:
-
- 16 modified
-
common/lc_flexpiece.cpp (modified) (2 diffs)
-
common/lc_flexpiece.h (modified) (1 diff)
-
common/lc_model.cpp (modified) (1 diff)
-
common/lc_model.h (modified) (2 diffs)
-
common/lc_modelref.cpp (modified) (1 diff)
-
common/lc_modelref.h (modified) (1 diff)
-
common/lc_piece.cpp (modified) (2 diffs)
-
common/lc_piece.h (modified) (1 diff)
-
common/lc_pieceobj.h (modified) (1 diff)
-
common/lc_pivot.cpp (modified) (1 diff)
-
common/lc_pivot.h (modified) (1 diff)
-
common/project.cpp (modified) (4 diffs)
-
common/typedefs.h (modified) (3 diffs)
-
win/Propspgs.cpp (modified) (6 diffs)
-
win/Propspgs.h (modified) (5 diffs)
-
win/System.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/common/lc_flexpiece.cpp
r700 r702 7 7 #include "lc_colors.h" 8 8 #include "pieceinf.h" 9 #include "typedefs.h" 9 10 10 11 lcFlexiblePiece::lcFlexiblePiece(PieceInfo* Info) … … 78 79 if (m_PieceInfo) 79 80 m_PieceInfo->DeRef(); 81 } 82 83 void lcFlexiblePiece::GetPieceList(ObjArray<struct LC_PIECELIST_ENTRY>& Pieces, int Color) const 84 { 85 LC_PIECELIST_ENTRY Entry; 86 87 Entry.Info = m_PieceInfo; 88 Entry.Color = (m_Color == LC_COLOR_DEFAULT) ? Color : m_Color; 89 90 Pieces.Add(Entry); 80 91 } 81 92 -
trunk/common/lc_flexpiece.h
r693 r702 14 14 15 15 // Base class implementation. 16 virtual void GetPieceList(ObjArray<struct LC_PIECELIST_ENTRY>& Pieces, int Color) const; 16 17 virtual void ClosestRayIntersect(LC_CLICK_RAY* Ray) const; 17 18 virtual bool IntersectsVolume(const Vector4* Planes, int NumPlanes) const; -
trunk/common/lc_model.cpp
r688 r702 60 60 61 61 return false; 62 } 63 64 void lcModel::GetPieceList(ObjArray<struct LC_PIECELIST_ENTRY>& Pieces, int Color) const 65 { 66 for (lcPieceObject* Piece = m_Pieces; Piece; Piece = (lcPieceObject*)Piece->m_Next) 67 Piece->GetPieceList(Pieces, Color); 62 68 } 63 69 -
trunk/common/lc_model.h
r688 r702 5 5 #include "config.h" 6 6 #include "algebra.h" 7 #include "array.h" 7 8 8 9 class lcObject; … … 21 22 // Check if a given model is referenced by this model. 22 23 bool IsSubModel(const lcModel* Model) const; 24 25 // Get a list of all actual pieces used by this model. 26 void GetPieceList(ObjArray<struct LC_PIECELIST_ENTRY>& Pieces, int Color) const; 23 27 24 28 // Tell this model it's now the active model or no longer active. -
trunk/common/lc_modelref.cpp
r700 r702 25 25 lcModelRef::~lcModelRef() 26 26 { 27 } 28 29 void lcModelRef::GetPieceList(ObjArray<struct LC_PIECELIST_ENTRY>& Pieces, int Color) const 30 { 31 m_Model->GetPieceList(Pieces, Color); 27 32 } 28 33 -
trunk/common/lc_modelref.h
r700 r702 14 14 15 15 // Base class implementation. 16 virtual void GetPieceList(ObjArray<struct LC_PIECELIST_ENTRY>& Pieces, int Color) const; 16 17 virtual void ClosestRayIntersect(LC_CLICK_RAY* Ray) const; 17 18 virtual bool IntersectsVolume(const Vector4* Planes, int NumPlanes) const; -
trunk/common/lc_piece.cpp
r700 r702 8 8 #include "texture.h" 9 9 #include "lc_colors.h" 10 #include "typedefs.h" 10 11 11 12 lcPiece::lcPiece(PieceInfo* Info) … … 45 46 BuildMesh(); 46 47 } 48 } 49 50 void lcPiece::GetPieceList(ObjArray<struct LC_PIECELIST_ENTRY>& Pieces, int Color) const 51 { 52 LC_PIECELIST_ENTRY Entry; 53 54 Entry.Info = m_PieceInfo; 55 Entry.Color = (m_Color == LC_COLOR_DEFAULT) ? Color : m_Color; 56 57 Pieces.Add(Entry); 47 58 } 48 59 -
trunk/common/lc_piece.h
r700 r702 19 19 20 20 // Base class implementation. 21 virtual void GetPieceList(ObjArray<struct LC_PIECELIST_ENTRY>& Pieces, int Color) const; 21 22 virtual void ClosestRayIntersect(LC_CLICK_RAY* Ray) const; 22 23 virtual bool IntersectsVolume(const Vector4* Planes, int NumPlanes) const; -
trunk/common/lc_pieceobj.h
r691 r702 26 26 // Merges this object's bounding box with another box. 27 27 void MergeBoundingBox(BoundingBox* Box); 28 29 // Get a list of all actual pieces used by this piece. 30 virtual void GetPieceList(ObjArray<struct LC_PIECELIST_ENTRY>& Pieces, int Color) const = 0; 28 31 29 32 // Export this object to an LDraw file. -
trunk/common/lc_pivot.cpp
r700 r702 15 15 16 16 lcPivot::~lcPivot() 17 { 18 // fixme: lcPivot 19 } 20 21 void lcPivot::GetPieceList(ObjArray<struct LC_PIECELIST_ENTRY>& Pieces, int Color) const 17 22 { 18 23 // fixme: lcPivot -
trunk/common/lc_pivot.h
r681 r702 11 11 12 12 // Base class implementation. 13 virtual void GetPieceList(ObjArray<struct LC_PIECELIST_ENTRY>& Pieces, int Color) const; 13 14 virtual void ClosestRayIntersect(LC_CLICK_RAY* Ray) const; 14 15 virtual bool IntersectsVolume(const Vector4* Planes, int NumPlanes) const; -
trunk/common/project.cpp
r700 r702 4259 4259 opts.Name = Name; 4260 4260 opts.Author = Sys_ProfileLoadString("Default", "User", ""); 4261 opts.lines = 0; 4262 opts.count = NULL; 4263 opts.names = NULL; 4261 opts.PiecesUsed = NULL; 4264 4262 4265 4263 if (SystemDoDialog(LC_DLG_PROPERTIES, &opts)) … … 4337 4335 case LC_MODEL_PROPERTIES: 4338 4336 { 4339 /* FIXME: model properties4340 4337 LC_PROPERTIESDLG_OPTS opts; 4341 4338 … … 4346 4343 opts.Comments = m_ActiveModel->m_Comments; 4347 4344 4348 // Piece list. 4349 opts.lines = lcGetPiecesLibrary()->GetPieceCount(); 4350 opts.count = (unsigned short*)malloc(lcGetPiecesLibrary()->GetPieceCount()*LC_MAXCOLORS*sizeof(unsigned short)); 4351 memset (opts.count, 0, lcGetPiecesLibrary()->GetPieceCount()*LC_MAXCOLORS*sizeof(unsigned short)); 4352 opts.names = (char**)malloc(lcGetPiecesLibrary()->GetPieceCount()*sizeof(char*)); 4353 for (int i = 0; i < lcGetPiecesLibrary()->GetPieceCount(); i++) 4354 opts.names[i] = lcGetPiecesLibrary()->GetPieceInfo (i)->m_strDescription; 4355 4356 for (Piece* pPiece = m_ActiveModel->m_Pieces; pPiece; pPiece = (Piece*)pPiece->m_Next) 4357 { 4358 int idx = lcGetPiecesLibrary()->GetPieceIndex (pPiece->GetPieceInfo ()); 4359 opts.count[idx*LC_MAXCOLORS+pPiece->GetColor()]++; 4345 // Pieces list. 4346 PiecesLibrary* Lib = lcGetPiecesLibrary(); 4347 int NumPieces = Lib->GetPieceCount() * lcNumUserColors; 4348 opts.PiecesUsed = new int[NumPieces]; 4349 memset(opts.PiecesUsed, 0, NumPieces * sizeof(int)); 4350 4351 ObjArray<LC_PIECELIST_ENTRY> Pieces; 4352 m_ActiveModel->GetPieceList(Pieces, LC_COLOR_DEFAULT); 4353 4354 for (int i = 0; i < Pieces.GetSize(); i++) 4355 { 4356 int Index = Lib->GetPieceIndex(Pieces[i].Info) * lcNumUserColors + Pieces[i].Color; 4357 opts.PiecesUsed[Index]++; 4360 4358 } 4361 4359 … … 4374 4372 } 4375 4373 4376 free(opts.count); 4377 free(opts.names); 4378 */ 4374 delete[] opts.PiecesUsed; 4379 4375 } break; 4380 4376 -
trunk/common/typedefs.h
r680 r702 202 202 } LC_CURSOR_TYPE; 203 203 204 // Piece connections (complicated and wastes memory but fast). 205 204 struct LC_PIECELIST_ENTRY 205 { 206 PieceInfo* Info; 207 int Color; 208 }; 209 210 // Piece connections. 206 211 struct CONNECTION 207 212 { … … 227 232 228 233 // Select by Name dialog data 229 230 234 typedef enum 231 235 { … … 418 422 String Description; 419 423 String Comments; 420 char** names; 421 unsigned short* count; 422 int lines; 424 int* PiecesUsed; 423 425 }; 424 426 -
trunk/win/Propspgs.cpp
r700 r702 6 6 #include "PropsPgs.h" 7 7 #include "defines.h" 8 #include "lc_colors.h" 9 #include "library.h" 10 #include "lc_application.h" 11 #include "pieceinf.h" 8 12 9 13 #ifdef _DEBUG … … 64 68 // NOTE: the ClassWizard will add member initialization here 65 69 //}}AFX_DATA_INIT 70 71 m_ColorColumn = new int[lcNumUserColors]; 66 72 } 67 73 68 74 CPropertiesPieces::~CPropertiesPieces() 69 75 { 76 delete[] m_ColorColumn; 70 77 } 71 78 … … 77 84 //}}AFX_DATA_MAP 78 85 } 79 80 86 81 87 BEGIN_MESSAGE_MAP(CPropertiesPieces, CPropertyPage) … … 85 91 END_MESSAGE_MAP() 86 92 87 88 BOOL CPropertiesPieces::OnInitDialog() 89 { 90 CPropertyPage::OnInitDialog(); 91 /* FIXME: model pieces 92 char tmp[64]; 93 int i, j; 94 memset (&totalcount, 0, sizeof (totalcount)); 95 for (i = 0; i < lines; i++) 96 for (j = 0; j < LC_MAXCOLORS; j++) 97 totalcount[j] += count[i*LC_MAXCOLORS+j]; 98 99 int ID = 0; 100 m_List.InsertColumn(0, "Piece", LVCFMT_LEFT, 130, 0); 101 for (i = 0; i < LC_MAXCOLORS; i++) 102 if (totalcount[i]) 93 static int CALLBACK ListViewCompareProc(LPARAM lP1, LPARAM lP2, LPARAM lParamData) 94 { 95 CPropertiesPieces* Dlg = (CPropertiesPieces*)lParamData; 96 int* Line1 = (int*)lP1; 97 int* Line2 = (int*)lP2; 98 99 // Keep the total row at the bottom of the list. 100 if (lP1 == -1) 101 return 1; 102 else if (lP2 == -1) 103 return -1; 104 105 if (Dlg->m_SortColumn != 0) 106 { 107 int Num1, Num2; 108 109 if (Dlg->m_SortColumn == Dlg->m_List.GetHeaderCtrl()->GetItemCount() - 1) 103 110 { 104 col[i] = ID; 105 ID++; 106 107 CString str; 108 str.LoadString(IDS_COLOR01 + i); 109 m_List.InsertColumn(ID, (LPCSTR)str, LVCFMT_LEFT, 80, 0); 111 Num1 = 0; 112 Num2 = 0; 113 114 for (int i = 0; i < lcNumUserColors; i++) 115 { 116 Num1 += Line1[i]; 117 Num2 += Line2[i]; 118 } 110 119 } 111 120 else 112 col[i] = -1; 113 ID++; 114 m_List.InsertColumn(ID, "Total", LVCFMT_LEFT, 60, 0); 115 116 for (i = 0; i < lines; i++) 117 { 118 int total = 0; 119 120 for (j = 0; j < LC_MAXCOLORS; j++) 121 total += count[i*LC_MAXCOLORS+j]; 122 123 if (total == 0) 121 { 122 int i; 123 124 for (i = 0; i < lcNumUserColors; i++) 125 if (Dlg->m_ColorColumn[i] == Dlg->m_SortColumn) 126 break; 127 128 Num1 = Line1[i]; 129 Num2 = Line2[i]; 130 } 131 132 if (Num1 < Num2) 133 return Dlg->m_SortAscending ? 1 : -1; 134 else if (Num1 > Num2) 135 return Dlg->m_SortAscending ? -1 : 1; 136 else 137 return 0; 138 } 139 140 int Index1 = (Line1 - Dlg->m_PiecesUsed) / lcNumUserColors; 141 int Index2 = (Line2 - Dlg->m_PiecesUsed) / lcNumUserColors; 142 143 PiecesLibrary* Lib = lcGetPiecesLibrary(); 144 PieceInfo* Info1 = Lib->GetPieceInfo(Index1); 145 PieceInfo* Info2 = Lib->GetPieceInfo(Index2); 146 147 if (Dlg->m_SortAscending) 148 return _strcmpi(Info1->m_strDescription, Info2->m_strDescription); 149 else 150 return - _strcmpi(Info1->m_strDescription, Info2->m_strDescription); 151 } 152 153 BOOL CPropertiesPieces::OnInitDialog() 154 { 155 CPropertyPage::OnInitDialog(); 156 157 int* ColorTotal = new int[lcNumUserColors]; 158 memset(ColorTotal, 0, lcNumUserColors * sizeof(int)); 159 memset(m_ColorColumn, 0, lcNumUserColors * sizeof(int)); 160 int i, j; 161 162 PiecesLibrary* Lib = lcGetPiecesLibrary(); 163 164 // Count the number of pieces used for each color. 165 for (i = 0; i < Lib->GetPieceCount(); i++) 166 for (j = 0; j < lcNumUserColors; j++) 167 ColorTotal[j] += m_PiecesUsed[j + i * lcNumUserColors]; 168 169 // Add columns to the list header. 170 m_List.InsertColumn(0, "Piece", LVCFMT_LEFT, 130, 0); 171 172 int Column = 1; 173 174 for (i = 0; i < lcNumUserColors; i++) 175 { 176 if (!ColorTotal[i]) 124 177 continue; 125 178 126 char name[65]; 179 m_ColorColumn[i] = Column; 180 m_List.InsertColumn(Column, lcColorList[i].Name, LVCFMT_LEFT, 80, 0); 181 Column++; 182 } 183 184 m_List.InsertColumn(Column, "Total", LVCFMT_LEFT, 60, 0); 185 186 m_List.SetRedraw(FALSE); 187 188 // Add pieces to the list. 189 for (i = 0; i < Lib->GetPieceCount(); i++) 190 { 191 int* Line = m_PiecesUsed + i * lcNumUserColors; 192 int LineTotal = 0; 193 194 for (j = 0; j < lcNumUserColors; j++) 195 LineTotal += Line[j]; 196 197 if (!LineTotal) 198 continue; 199 200 char name[256], tmp[256]; 127 201 LV_ITEM lvi; 128 202 lvi.mask = LVIF_TEXT|LVIF_PARAM; … … 130 204 lvi.iSubItem = 0; 131 205 lvi.pszText = name; 132 lvi.lParam = i; 133 strcpy (name, names[i]); 206 lvi.lParam = (LPARAM)Line; 207 strcpy(name, Lib->GetPieceInfo(i)->m_strDescription); 208 134 209 int idx = m_List.InsertItem(&lvi); 135 210 136 for (j = 0; j < LC_MAXCOLORS; j++) 137 // if (totalcount[j]) 138 if (count[i*LC_MAXCOLORS+j]) 139 { 140 sprintf (tmp, "%d", count[i*LC_MAXCOLORS+j]); 141 lvi.iItem = idx; 142 lvi.pszText = tmp; 143 m_List.SetItemText(idx, col[j] + 1, tmp); 144 } 145 146 sprintf (tmp, "%d", total); 147 lvi.iItem = idx; 148 lvi.pszText = tmp; 149 m_List.SetItemText(idx, ID, tmp); 150 } 151 152 m_List.ModifyStyle(LVS_SORTASCENDING | LVS_SORTDESCENDING, 0L); 153 154 char name[65]; 211 for (j = 0; j < lcNumUserColors; j++) 212 { 213 if (!Line[j]) 214 continue; 215 216 sprintf(tmp, "%d", Line[j]); 217 m_List.SetItemText(idx, m_ColorColumn[j], tmp); 218 } 219 220 sprintf (tmp, "%d", LineTotal); 221 m_List.SetItemText(idx, Column, tmp); 222 } 223 224 // Add totals. 225 char name[256], tmp[256]; 155 226 strcpy (name, "Total"); 156 227 LV_ITEM lvi; … … 160 231 lvi.pszText = name; 161 232 lvi.lParam = -1; 233 162 234 int idx = m_List.InsertItem(&lvi), total = 0; 163 164 for (i = 0; i < LC_MAXCOLORS; i++) 165 if (totalcount[i]) 166 { 167 sprintf (tmp, "%d", totalcount[i]); 168 lvi.iItem = idx; 169 lvi.pszText = tmp; 170 m_List.SetItemText(idx, col[i] + 1, tmp); 171 total += totalcount[i]; 172 } 173 174 sprintf (tmp, "%d", total); 175 lvi.iItem = idx; 176 lvi.pszText = tmp; 177 m_List.SetItemText(idx, ID, tmp); 178 */ 235 int Total = 0; 236 237 for (i = 0; i < lcNumUserColors; i++) 238 { 239 if (!ColorTotal[i]) 240 continue; 241 242 Total += ColorTotal[i]; 243 244 sprintf (tmp, "%d", ColorTotal[i]); 245 m_List.SetItemText(idx, m_ColorColumn[i], tmp); 246 } 247 248 sprintf (tmp, "%d", Total); 249 m_List.SetItemText(idx, Column, tmp); 250 251 delete[] ColorTotal; 252 253 m_SortColumn = 0; 254 m_SortAscending = true; 255 256 m_List.SortItems((PFNLVCOMPARE)ListViewCompareProc, (LPARAM)this); 257 258 m_List.SetRedraw(TRUE); 259 m_List.Invalidate(); 260 179 261 return TRUE; 180 262 } 181 263 182 struct COMPARE_DATA 183 { 184 CPropertiesPieces* page; 185 int color; 186 }; 187 188 static int CALLBACK ListViewCompareProc(LPARAM lP1, LPARAM lP2, LPARAM lParamData) 189 { 190 /* FIXME: model pieces 191 int i, a, b; 192 COMPARE_DATA* data = (COMPARE_DATA*)lParamData; 193 194 if (data->color == -1) 195 { 196 // check if we're comparing the "total" row 197 if (lP1 == -1) 198 return 1; 199 else if (lP2 == -1) 200 return -1; 201 202 return _strcmpi(data->page->names[lP1], data->page->names[lP2]); 203 } 204 205 // last column 206 if (data->color == LC_MAXCOLORS) 207 { 208 a = b = 0; 209 for (i = 0; i < LC_MAXCOLORS; i++) 210 { 211 a += data->page->count[lP1*LC_MAXCOLORS+i]; 212 b += data->page->count[lP2*LC_MAXCOLORS+i]; 213 } 214 } 264 void CPropertiesPieces::OnColumnclickPropPiecesList(NMHDR* pNMHDR, LRESULT* pResult) 265 { 266 NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; 267 268 if (m_SortColumn == pNMListView->iSubItem) 269 m_SortAscending = !m_SortAscending; 215 270 else 216 { 217 if (lP1 == -1) 218 a = data->page->totalcount[data->color]; 219 else 220 a = data->page->count[lP1*LC_MAXCOLORS+data->color]; 221 222 if (lP2 == -1) 223 b = data->page->totalcount[data->color]; 224 else 225 b = data->page->count[lP2*LC_MAXCOLORS+data->color]; 226 } 227 228 if (a == b) 229 return 0; 230 231 if (a < b) 232 return -1; 233 else 234 return 1; 235 */ 236 } 237 238 void CPropertiesPieces::OnColumnclickPropPiecesList(NMHDR* pNMHDR, LRESULT* pResult) 239 { 240 /* FIXME: model pieces 241 int i; 242 NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; 243 COMPARE_DATA data; 244 245 data.page = this; 246 247 if (pNMListView->iSubItem == 0) 248 data.color = -1; 249 else 250 { 251 for (i = 0; i < LC_MAXCOLORS; i++) 252 if (col[i] == pNMListView->iSubItem-1) 253 break; 254 255 data.color = i; 256 } 257 258 m_List.SortItems((PFNLVCOMPARE)ListViewCompareProc, (LPARAM)&data); 271 m_SortColumn = pNMListView->iSubItem; 272 273 m_List.SetRedraw(FALSE); 274 275 m_List.SortItems((PFNLVCOMPARE)ListViewCompareProc, (LPARAM)this); 276 277 m_List.SetRedraw(TRUE); 278 m_List.Invalidate(); 259 279 260 280 *pResult = 0; 261 */ 262 } 281 } -
trunk/win/Propspgs.h
r700 r702 1 // PropsPgs.h : header file 2 // 3 4 #ifndef __PROPSPGS_H__ 5 #define __PROPSPGS_H__ 1 #ifndef _PROPSPGS_H_ 2 #define _PROPSPGS_H_ 6 3 7 4 #include "defines.h" … … 45 42 }; 46 43 47 48 44 ///////////////////////////////////////////////////////////////////////////// 49 45 // CPropertiesPieces dialog … … 57 53 CPropertiesPieces(); 58 54 ~CPropertiesPieces(); 59 char** names;60 unsigned short* count;61 int lines;62 // int col[LC_MAXCOLORS];63 // int totalcount[LC_MAXCOLORS];64 55 65 56 // Dialog Data … … 69 60 //}}AFX_DATA 70 61 62 int* m_PiecesUsed; 63 int* m_ColorColumn; 64 int m_SortColumn; 65 bool m_SortAscending; 71 66 72 67 // Overrides … … 85 80 //}}AFX_MSG 86 81 DECLARE_MESSAGE_MAP() 87 88 82 }; 89 83 90 91 92 #endif // __PROPSPGS_H__ 84 #endif // _PROPSPGS_H_ -
trunk/win/System.cpp
r680 r702 1602 1602 { 1603 1603 LC_PROPERTIESDLG_OPTS* opts = (LC_PROPERTIESDLG_OPTS*)param; 1604 CPropertiesSheet ps(opts-> names && opts->count);1604 CPropertiesSheet ps(opts->PiecesUsed != NULL); 1605 1605 1606 1606 ps.SetTitle("Model Properties", 0);
