-
Notifications
You must be signed in to change notification settings - Fork 0
/
AP210ProdView.cpp
897 lines (763 loc) · 33.2 KB
/
AP210ProdView.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
// AP210ProdView.cpp : implementation file
//
#include "stdafx.h"
#include "AP210Viewer.h"
#include "AP210ProdView.h"
#include "PWBDataBase.h"
#include "Sdai/PackagedComponent.h"
#include "Sdai/MountingRestrictionArea.h"
#include "Sdai/NonPlatedThruHole.h"
// GUI
#include "ComponentPlacementRestriction.h"
#include "AssemblyPropertiesSheet.h"
#include "InterconnectModulePropertiesSheet.h"
#include "ComponentPropertiesSheet.h"
#include "ComponentDefinitionSheet.h"
#include "PackagePropertiesSheet.h"
#include "PackagedPartPropertiesSheet.h"
#include "NonPlatedThruHoleSheet.h"
#include "ComponentPlacementRestrictionAreaSheet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAP210ProdView
IMPLEMENT_DYNCREATE(CAP210ProdView, CTreeView)
CAP210ProdView::CAP210ProdView() {
pImageList = NULL;
}
CAP210ProdView::~CAP210ProdView() {
if (pImageList) {
pImageList->DeleteImageList();
delete pImageList;
}
}
BEGIN_MESSAGE_MAP(CAP210ProdView, CTreeView)
//{{AFX_MSG_MAP(CAP210ProdView)
ON_NOTIFY_REFLECT(TVN_SELCHANGED, OnSelchanged)
ON_WM_RBUTTONDBLCLK()
ON_WM_RBUTTONDOWN()
ON_COMMAND(ID_COMPONENT_RESTRICTION_AREA, OnComponentRestrictionArea)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAP210ProdView drawing
/////////////////////////////////////////////////////////////////////////////
// CAP210ProdView diagnostics
#ifdef _DEBUG
void CAP210ProdView::AssertValid() const
{
CTreeView::AssertValid();
}
void CAP210ProdView::Dump(CDumpContext& dc) const
{
CTreeView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CAP210ProdView message handlers
void CAP210ProdView::OnInitialUpdate() {
TRACE("In CAP210ProdView::OnInitialUpdate()\r\n");
// TODO: Add your specialized code here and/or call the base class
#if 0
// This should work some place!
// fill the view with the specified color
CDC *pDC = GetDC();
CRect rect;
GetClientRect(rect);
CBrush br(GetSysColor(COLOR_BTNFACE)); // bright grey
pDC->FillRect(rect, &br);
#endif
PopulateTree();
CTreeView::OnInitialUpdate();
}
/*
* PopulateTree()
*
* Populates the view tree with the assembly, packages and packaged_parts
*
* Bitmap Image List
* 0 - IDB_FULLPARENT
* 1 - IDB_EMPTYPARENT
* 2 - IDB_OPENPARENT
* 3 - IDB_PACKAGED_COMPONENT
* 4 - IDB_PWB
* 5 - IDB_PACKAGED_PART
* 6 - IDB_PACKAGE
*
* From resources.h
* #define IDB_FULLPARENT 156
* #define IDB_EMPTYPARENT 157
* #define IDB_OPENPARENT 158
* #define IDB_PACKAGED_COMPONENT 159
* #define IDB_PWB 161
* #define IDB_PACKAGED_PART 162
* #define IDB_PACKAGE 163
*/
void CAP210ProdView::PopulateTree() {
// Get the data to display
PWBDataBase *pDoc = (PWBDataBase *)GetDocument();
// Unselect everything
pDoc->UnSelectAll();
// get the tree control
CTreeCtrl &TreeCtrl = GetTreeCtrl();
// build the image list.
pImageList = new CImageList();
pImageList->Create(16, 15, TRUE, 3, 2);
CBitmap bitmap;
for(UINT iCnt=IDB_FULLPARENT; iCnt<=IDB_PACKAGE; iCnt++) {
bitmap.LoadBitmap(iCnt);
pImageList->Add(&bitmap, (COLORREF)0xFFFFFF);
bitmap.DeleteObject();
}
TreeCtrl.SetImageList(pImageList, TVSIL_NORMAL);
// item insert structure
TV_INSERTSTRUCT tvstruct;
tvstruct.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT;
// Create the Assembly Tree
populateAssemblyTree(pDoc, tvstruct, TreeCtrl);
// Create the Packaged Part Tree
populatePackagedPartTree(pDoc, tvstruct, TreeCtrl);
// Create the Package Tree
populatePackagesTree(pDoc, tvstruct, TreeCtrl);
// Create the PhysicalUnit Tree
populatePhysicalUnitTree(pDoc, tvstruct, TreeCtrl);
// Create the MountingRestricitonArea Tree
populateMountingRestrictionAreaTree(pDoc, tvstruct, TreeCtrl);
// Create the NonPlatedThruHole Tree
populateNonPlatedThruHoleTree(pDoc, tvstruct, TreeCtrl);
}
void CAP210ProdView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) {
// TODO: Add your specialized code here and/or call the base class
TRACE("In CAP210ProdView::OnUpdate()\r\n");
#if 0
// get the tree control and delete any existing items
CTreeCtrl &TreeCtrl = GetTreeCtrl();
VERIFY(TreeCtrl.DeleteAllItems());
// Repopulate the tree
PopulateTree();
#endif
}
BOOL CAP210ProdView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) {
// TODO: Add your specialized code here and/or call the base class
// Add the '+' and '-' and line graphics to the tree
dwStyle |= TVS_HASLINES | TVS_LINESATROOT;
return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
}
void CAP210ProdView::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult) {
// TODO: Add your control notification handler code here
// Get the data to display
PWBDataBase *pDoc = (PWBDataBase *)GetDocument();
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
// TODO: Add your control notification handler code here
HTREEITEM SelectedItem = pNMTreeView->itemNew.hItem;
// get the tree control
CTreeCtrl &TreeCtrl = GetTreeCtrl();
// Get the select items Parent
HTREEITEM ParentItem = TreeCtrl.GetParentItem(SelectedItem);
if (ParentItem) {
AP210ObjectListItor CDitor(&(pDoc->ComponentDefinitions));
// unselect everything
pDoc->UnSelectAll();
// Get the selected items OID
int SelectedItemOID = TreeCtrl.GetItemData(SelectedItem);
if (ParentItem == AssemblyTreeItem) {
// look to see what was selected
// Was it the board?
if (pDoc->PWB->GetOID() == SelectedItemOID) {
pDoc->PWB->Select();
}
else {
// Search for components
ComponentDefinition *cd;
CDitor.Reset();
while((cd = (ComponentDefinition *)CDitor.NextInstanceOf(ComponentDefinition::TypeID())) != NULL) {
if (cd->GetOID() == SelectedItemOID) {
cd->Select();
break;
}
}
}
}
else if (ParentItem == PackagesTreeItem) {
// Search for packages
AP210ObjectListItor Pitor(&(pDoc->Packages));
Package *p;
Pitor.Reset();
while((p = (Package *)Pitor.NextDirectInstanceOf(Package::TypeID())) != NULL) {
if (p->GetOID() == SelectedItemOID) {
p->Select(&CDitor);
break;
}
}
}
else if (ParentItem == PackagedPartsTreeItem) {
// Search for packaged_parts
AP210ObjectListItor PPitor(&(pDoc->PackagedParts));
PackagedPart *pp;
PPitor.Reset();
while((pp = (PackagedPart *)PPitor.NextDirectInstanceOf(PackagedPart::TypeID())) != NULL) {
if (pp->GetOID() == SelectedItemOID) {
pp->Select(&CDitor);
break;
}
}
}
else if (ParentItem == PhysicalUnitsTreeItem) {
// Search for packaged_parts
AP210ObjectListItor PUitor(&(pDoc->PhysicalUnits));
PhysicalUnit *pu;
PUitor.Reset();
while((pu = (PhysicalUnit *)PUitor.NextDirectInstanceOf(PhysicalUnit::TypeID())) != NULL) {
if (pu->GetOID() == SelectedItemOID) {
pu->Select(&CDitor);
break;
}
}
}
else if (ParentItem == MountingRestrictionAreaItem) {
// Search for mounting restriction areas
AP210ObjectListItor MRAitor(&(pDoc->MountingRestrictionAreas));
MountingRestrictionArea *mra;
MRAitor.Reset();
while((mra = (MountingRestrictionArea *)MRAitor.NextDirectInstanceOf(MountingRestrictionArea::TypeID())) != NULL) {
if (mra->GetOID() == SelectedItemOID) {
mra->Select();
break;
}
}
}
else if (ParentItem == NonPlatedThruHoleItem) {
// Search for non-plated thru holes
AP210ObjectListItor NPTHitor(&(pDoc->NonPlatedThruHoles));
NonPlatedThruHole *npth;
NPTHitor.Reset();
while((npth = (NonPlatedThruHole *)NPTHitor.NextDirectInstanceOf(NonPlatedThruHole::TypeID())) != NULL) {
if (npth->GetOID() == SelectedItemOID) {
npth->Select();
break;
}
}
}
// Have the document handle the selected items.
pDoc->OnSelection();
// Update all the views to highlight what was selected.
pDoc->UpdateAllViews(NULL);
}
*pResult = 0;
}
void CAP210ProdView::OnRButtonDblClk(UINT nFlags, CPoint point) {
// TODO: Add your message handler code here and/or call default
PWBDataBase *pDoc = (PWBDataBase *)GetDocument();
CTreeCtrl &TreeCtrl = GetTreeCtrl();
HTREEITEM SelectedItem = TreeCtrl.GetSelectedItem();
if (SelectedItem && (pDoc->AP210Model != sdaiNULL)) {
// Get the select items Parent
if (SelectedItem == AssemblyTreeItem) {
TRACE("Assembly Item seleted\n");
// Display properties dialog box
// create the dialog box
CAssemblyPropertiesSheet assemblypropDlg("Assembly Properties", this);
// display the dialog box
assemblypropDlg.DoModal();
}
else {
HTREEITEM ParentItem = TreeCtrl.GetParentItem(SelectedItem);
if (ParentItem) {
AP210ObjectListItor CDitor(&(pDoc->ComponentDefinitions));
// Get the selected items OID
int SelectedItemOID = TreeCtrl.GetItemData(SelectedItem);
if (ParentItem == AssemblyTreeItem) {
// look to see what was selected
// Was it the board?
if (pDoc->PWB->GetOID() == SelectedItemOID) {
// Display properties dialog box
// create the dialog box
CInterconnectModulePropertiesSheet interconnectmodulepropDlg("Interconnect Module Properties", this);
// set the dialog boxes values
interconnectmodulepropDlg.setValues(pDoc->AP210Model, pDoc->PWB);
interconnectmodulepropDlg.setReadOnly(pDoc->ReadOnly);
// display the dialog box
interconnectmodulepropDlg.DoModal();
}
else {
// Search for packaged components
ComponentDefinition *cd;
CDitor.Reset();
while((cd = (ComponentDefinition *)CDitor.NextInstanceOf(ComponentDefinition::TypeID())) != NULL) {
if (cd->GetOID() == SelectedItemOID) {
if (cd->DynamicType(PackagedComponent::TypeID())) {
PackagedComponent *pc = (PackagedComponent *)cd;
// Display properties dialog box
// create the dialog box
CComponentPropertiesSheet comppropDlg("Packaged Component Properties", this);
// set the dialog boxes values
comppropDlg.setValues(pDoc->AP210Model, pc);
comppropDlg.setReadOnly(pDoc->ReadOnly);
// display the dialog box
comppropDlg.DoModal();
}
else {
// Display properties dialog box
// create the dialog box
CComponentDefinitionSheet comppropDlg("Mechanical Part Properties", this);
// set the dialog boxes values
comppropDlg.setValues(pDoc->AP210Model, cd);
comppropDlg.setReadOnly(pDoc->ReadOnly);
// display the dialog box
comppropDlg.DoModal();
}
break;
}
}
}
}
else if (ParentItem == UnPlacedComponentTreeItem) {
// Search for packaged components
ComponentDefinition *cd;
CDitor.Reset();
while((cd = (ComponentDefinition *)CDitor.NextInstanceOf(ComponentDefinition::TypeID())) != NULL) {
if (cd->GetOID() == SelectedItemOID) {
if (cd->DynamicType(PackagedComponent::TypeID())) {
PackagedComponent *pc = (PackagedComponent *)cd;
// Display properties dialog box
// create the dialog box
CComponentPropertiesSheet comppropDlg("Packaged Component Properties", this);
// set the dialog boxes values
comppropDlg.setValues(pDoc->AP210Model, pc);
comppropDlg.setReadOnly(pDoc->ReadOnly);
// display the dialog box
comppropDlg.DoModal();
}
else {
// Display properties dialog box
// create the dialog box
CComponentDefinitionSheet comppropDlg("Mechanical Part Properties", this);
// set the dialog boxes values
comppropDlg.setValues(pDoc->AP210Model, cd);
comppropDlg.setReadOnly(pDoc->ReadOnly);
// display the dialog box
comppropDlg.DoModal();
}
break;
}
}
}
else if (ParentItem == PackagesTreeItem) {
// Search for packages
AP210ObjectListItor Pitor(&(pDoc->Packages));
Package *p;
Pitor.Reset();
while((p = (Package *)Pitor.NextDirectInstanceOf(Package::TypeID())) != NULL) {
if (p->GetOID() == SelectedItemOID) {
// Display properties dialog box
// create the dialog box
CPackagePropertiesSheet packagepropDlg("Package Properties", this);
// set the dialog boxes values
packagepropDlg.setValues(pDoc->AP210Model, p);
packagepropDlg.setReadOnly(pDoc->ReadOnly);
// display the dialog box
packagepropDlg.DoModal();
break;
}
}
}
else if (ParentItem == PackagedPartsTreeItem) {
// Search for packaged_parts
AP210ObjectListItor PPitor(&(pDoc->PackagedParts));
PackagedPart *pp;
PPitor.Reset();
while((pp = (PackagedPart *)PPitor.NextDirectInstanceOf(PackagedPart::TypeID())) != NULL) {
if (pp->GetOID() == SelectedItemOID) {
// Display properties dialog box
// create the dialog box
CPackagedPartPropertiesSheet packagedpartpropDlg("Packaged Part Properties", this);
// set the dialog boxes values
packagedpartpropDlg.setValues(pDoc->AP210Model, pp);
// display the dialog box
packagedpartpropDlg.DoModal();
break;
}
}
}
else if (ParentItem == PhysicalUnitsTreeItem) {
// Search for physical_units
AP210ObjectListItor PUitor(&(pDoc->PhysicalUnits));
PhysicalUnit *pu;
PUitor.Reset();
while((pu = (PhysicalUnit *)PUitor.NextDirectInstanceOf(PhysicalUnit::TypeID())) != NULL) {
if (pu->GetOID() == SelectedItemOID) {
// Display properties dialog box
// create the dialog box
CPackagePropertiesSheet packagepropDlg("PhysicalUnit Properties", this, ID_PHYSICAL_UNIT);
// set the dialog boxes values
packagepropDlg.setValues(pDoc->AP210Model, pu);
packagepropDlg.setReadOnly(pDoc->ReadOnly);
// display the dialog box
packagepropDlg.DoModal();
break;
}
}
}
else if (ParentItem == NonPlatedThruHoleItem) {
// Search for physical_units
AP210ObjectListItor NPTHitor(&(pDoc->NonPlatedThruHoles));
NonPlatedThruHole *npth;
NPTHitor.Reset();
while((npth = (NonPlatedThruHole *)NPTHitor.NextDirectInstanceOf(NonPlatedThruHole::TypeID())) != NULL) {
if (npth->GetOID() == SelectedItemOID) {
// Display properties dialog box
// create the dialog box
CNonPlatedThruHoleSheet npthpropDlg("Non-Plated Thru Hole Properties", this);
// set the dialog boxes values
npthpropDlg.setValues(pDoc->AP210Model, npth);
npthpropDlg.setReadOnly(pDoc->ReadOnly);
// display the dialog box
npthpropDlg.DoModal();
break;
}
}
}
else if (ParentItem == MountingRestrictionAreaItem) {
// Search for physical_units
AP210ObjectListItor MRAitor(&(pDoc->MountingRestrictionAreas));
MountingRestrictionArea *mra;
MRAitor.Reset();
while((mra = (MountingRestrictionArea *)MRAitor.NextDirectInstanceOf(MountingRestrictionArea::TypeID())) != NULL) {
if (mra->GetOID() == SelectedItemOID) {
// Display properties dialog box
// create the dialog box
CComponentPlacementRestrictionAreaSheet mrapropDlg("Component Placement Restriction Area Properties", this);
// set the dialog boxes values
mrapropDlg.setValues(pDoc, mra);
mrapropDlg.setReadOnly(pDoc->ReadOnly);
// display the dialog box
mrapropDlg.DoModal();
break;
}
}
}
}
}
}
CTreeView::OnRButtonDblClk(nFlags, point);
}
void CAP210ProdView::OnRButtonDown(UINT nFlags, CPoint point) {
// TODO: Add your message handler code here and/or call default
UINT pFlags;
CTreeCtrl &TreeCtrl = GetTreeCtrl();
HTREEITEM TreeItem = TreeCtrl.HitTest(point, &pFlags);
if (TreeItem) {
TreeCtrl.SelectItem(TreeItem);
}
CTreeView::OnRButtonDown(nFlags, point);
}
void CAP210ProdView::UpdateTree() {
TRACE("CAP210ProdView::UpdateTree\r\n");
PWBDataBase *pDoc = (PWBDataBase *)GetDocument();
// get the tree control and delete any existing items
CTreeCtrl &TreeCtrl = GetTreeCtrl();
VERIFY(TreeCtrl.DeleteAllItems());
// Repopulate the tree
PopulateTree();
// Update all the views.
pDoc->UpdateAllViews(NULL);
}
void CAP210ProdView::populatePackagesTree(PWBDataBase *pDoc,
TV_INSERTSTRUCT tvstruct,
CTreeCtrl &TreeCtrl) {
HTREEITEM NewTreeItem;
AP210ObjectListItor Pitor(&(pDoc->Packages));
Package *p;
//
// Create the root of the Package list
tvstruct.hParent = NULL;
tvstruct.item.pszText = _T("Packages");
tvstruct.hInsertAfter = TVI_LAST;
// add the items if they are in the list
if (pDoc->Packages.SizeOf() > 0) {
tvstruct.item.iImage = 0; // IDB_FULLPARENT
tvstruct.item.iSelectedImage = 2; // IDB_OPENPARENT
// save this as the parts tree
PackagesTreeItem = TreeCtrl.InsertItem(&tvstruct);
// all the parts have this has there root.
// and we want to sort them
tvstruct.hParent = PackagesTreeItem;
tvstruct.hInsertAfter = TVI_SORT;
// Add the parts to the tree
tvstruct.item.iImage = 6; // IDB_PACKAGE
tvstruct.item.iSelectedImage = 6; // IDB_PACKAGE
Pitor.Reset();
while((p = (Package *)Pitor.NextDirectInstanceOf(Package::TypeID())) != NULL) {
tvstruct.item.pszText = _T(p->PartNumber);
tvstruct.item.lParam = p->GetOID();
// save this in p
NewTreeItem = TreeCtrl.InsertItem(&tvstruct);
TreeCtrl.SetItemData(NewTreeItem, p->GetOID());
}
}
else { // use empty icons since the list is empty
tvstruct.item.iImage = 1; // IDF_EMPTYPARENT
tvstruct.item.iSelectedImage = 1; // IDF_EMPTYPARENT
// save this as the parts tree
PackagesTreeItem = TreeCtrl.InsertItem(&tvstruct);
}
}
void CAP210ProdView::populatePhysicalUnitTree(PWBDataBase *pDoc,
TV_INSERTSTRUCT tvstruct,
CTreeCtrl &TreeCtrl) {
HTREEITEM NewTreeItem;
AP210ObjectListItor PUitor(&(pDoc->PhysicalUnits));
PhysicalUnit *pu;
//
// Create the root of the PhysicalUnit list
tvstruct.hParent = NULL;
tvstruct.item.pszText = _T("Physical Units");
tvstruct.hInsertAfter = TVI_LAST;
// add the items if they are in the list
if (pDoc->PhysicalUnits.SizeOf() > 0) {
tvstruct.item.iImage = 0; // IDB_FULLPARENT
tvstruct.item.iSelectedImage = 2; // IDB_OPENPARENT
// save this as the parts tree
PhysicalUnitsTreeItem = TreeCtrl.InsertItem(&tvstruct);
// all the parts have this has there root.
// and we want to sort them
tvstruct.hParent = PhysicalUnitsTreeItem;
tvstruct.hInsertAfter = TVI_SORT;
// Add the physical_units to the tree
tvstruct.item.iImage = 6; // IDB_PACKAGE
tvstruct.item.iSelectedImage = 6; // IDB_PACKAGE
PUitor.Reset();
while((pu = (PhysicalUnit *)PUitor.NextDirectInstanceOf(PhysicalUnit::TypeID())) != NULL) {
tvstruct.item.pszText = _T(pu->getPartNumber());
tvstruct.item.lParam = pu->GetOID();
// save this in pu
NewTreeItem = TreeCtrl.InsertItem(&tvstruct);
TreeCtrl.SetItemData(NewTreeItem, pu->GetOID());
}
}
else { // use empty icons since the list is empty
tvstruct.item.iImage = 1; // IDF_EMPTYPARENT
tvstruct.item.iSelectedImage = 1; // IDF_EMPTYPARENT
PhysicalUnitsTreeItem = TreeCtrl.InsertItem(&tvstruct);
}
}
void CAP210ProdView::populatePackagedPartTree(PWBDataBase *pDoc,
TV_INSERTSTRUCT tvstruct,
CTreeCtrl &TreeCtrl) {
HTREEITEM NewTreeItem;
AP210ObjectListItor PPitor(&(pDoc->PackagedParts));
PackagedPart *pp;
// Create the root of the Packaged Part list
tvstruct.hParent = NULL;
tvstruct.item.pszText = _T("Packaged Parts");
tvstruct.hInsertAfter = TVI_LAST;
// add the items if they are in the list
if (pDoc->PackagedParts.SizeOf() > 0) {
tvstruct.item.iImage = 0; // IDB_FULLPARENT
tvstruct.item.iSelectedImage = 2; // IDB_OPENPARENT
// save this as the packaged parts tree
// and we want to sort them
PackagedPartsTreeItem = TreeCtrl.InsertItem(&tvstruct);
tvstruct.hInsertAfter = TVI_SORT;
// all the packaged_parts have this has there root.
tvstruct.hParent = PackagedPartsTreeItem;
// Add the packaged parts to the tree
tvstruct.item.iImage = 5; // IDB_PACKAGED_PART
tvstruct.item.iSelectedImage = 5; // IDB_PACKAGED_PART
PPitor.Reset();
while((pp = (PackagedPart *)PPitor.NextDirectInstanceOf(PackagedPart::TypeID())) != NULL) {
tvstruct.item.pszText = _T(pp->PartNumber);
tvstruct.item.lParam = pp->GetOID();
// save this in pc
NewTreeItem = TreeCtrl.InsertItem(&tvstruct);
TreeCtrl.SetItemData(NewTreeItem, pp->GetOID());
}
}
else { // use empty icons since the list is empty
tvstruct.item.iImage = 1; // IDF_EMPTYPARENT
tvstruct.item.iSelectedImage = 1; // IDF_EMPTYPARENT
// save this as the packaged parts tree
PackagedPartsTreeItem = TreeCtrl.InsertItem(&tvstruct);
}
}
void CAP210ProdView::populateAssemblyTree(PWBDataBase *pDoc,
TV_INSERTSTRUCT tvstruct,
CTreeCtrl &TreeCtrl) {
// Setup iteration for assembly
HTREEITEM NewTreeItem;
int UnPlacedCount = 0;
AP210ObjectListItor CDitor(&(pDoc->ComponentDefinitions));
ComponentDefinition *cd;
PackagedComponent *pc;
// Create the root of the tree Assembly.
tvstruct.hParent = NULL;
tvstruct.hInsertAfter = TVI_FIRST;
tvstruct.item.pszText = _T("Assembly");
// save this as the assembly tree
tvstruct.item.iImage = 0; // IDB_FULLPARENT
tvstruct.item.iSelectedImage = 2; // IDB_OPENPARENT
AssemblyTreeItem = TreeCtrl.InsertItem(&tvstruct);
// all the components have this has there root.
// and we want to sort them.
tvstruct.hParent = AssemblyTreeItem;
tvstruct.hInsertAfter = TVI_SORT;
// Add the placed components to the tree
tvstruct.item.iImage = 3; // IDB_COMPONENT
tvstruct.item.iSelectedImage = 3; // IDB_COMPONENT
CDitor.Reset();
while((pc = (PackagedComponent *)CDitor.NextDirectInstanceOf(PackagedComponent::TypeID())) != NULL) {
if (pc->getComponentLocationRef() != sdaiNULL) {
tvstruct.item.pszText = _T(pc->getName());
tvstruct.item.lParam = pc->GetOID();
// save this in pc
NewTreeItem = TreeCtrl.InsertItem(&tvstruct);
TreeCtrl.SetItemData(NewTreeItem, pc->GetOID());
}
else {
UnPlacedCount++;
}
}
// Add the placed Component_Definitons (e.g. Mechanical Parts) to the tree
CDitor.Reset();
while((cd = (ComponentDefinition *)CDitor.NextDirectInstanceOf(ComponentDefinition::TypeID())) != NULL) {
if (cd->getComponentLocationRef() != sdaiNULL) {
tvstruct.item.pszText = _T(cd->getName());
tvstruct.item.lParam = cd->GetOID();
// save this in pc
NewTreeItem = TreeCtrl.InsertItem(&tvstruct);
TreeCtrl.SetItemData(NewTreeItem, cd->GetOID());
}
else {
UnPlacedCount++; // Not sure about this?
}
}
// Add the PWB to the start of the list!
if (pDoc->PWB != NULL) {
tvstruct.item.iImage = 4; // IDB_PWB
tvstruct.item.iSelectedImage = 4; // IDB_PWB
tvstruct.hInsertAfter = TVI_FIRST; // or TVI_FIRST, TVI_SORT
tvstruct.item.pszText = _T(pDoc->PWB->getName());
tvstruct.item.lParam = pDoc->PWB->GetOID();
// save this in pwb
NewTreeItem = TreeCtrl.InsertItem(&tvstruct);
TreeCtrl.SetItemData(NewTreeItem, pDoc->PWB->GetOID());
// Add the placed components to the assembly tree
// Create the root of the Unplaced Component Tree.
tvstruct.hInsertAfter = TVI_FIRST; // or TVI_FIRST, TVI_SORT
tvstruct.item.pszText = _T("Unplaced");
}
// save this as the unplaced component tree
if (UnPlacedCount > 0) {
tvstruct.item.iImage = 0; // IDB_FULLPARENT
tvstruct.item.iSelectedImage = 2; // IDB_OPENPARENT
UnPlacedComponentTreeItem = TreeCtrl.InsertItem(&tvstruct);
// all the unplaced components have this has there root.
tvstruct.hParent = UnPlacedComponentTreeItem;
tvstruct.hInsertAfter = TVI_SORT; // or TVI_FIRST, TVI_SORT
// Add the unplaced components to the tree
tvstruct.item.iImage = 3; // IDB_COMPONENT
tvstruct.item.iSelectedImage = 3; // IDB_COMPONENT
CDitor.Reset();
while((pc = (PackagedComponent *)CDitor.NextDirectInstanceOf(PackagedComponent::TypeID())) != NULL) {
if (pc->getComponentLocationRef() == sdaiNULL) {
tvstruct.item.pszText = _T(pc->getName());
tvstruct.item.lParam = pc->GetOID();
// save this in pc
NewTreeItem = TreeCtrl.InsertItem(&tvstruct);
TreeCtrl.SetItemData(NewTreeItem, pc->GetOID());
}
}
}
else {
tvstruct.item.iImage = 1; // IDF_EMPTYPARENT
tvstruct.item.iSelectedImage = 1; // IDF_EMPTYPARENT
UnPlacedComponentTreeItem = TreeCtrl.InsertItem(&tvstruct);
}
}
void CAP210ProdView::populateMountingRestrictionAreaTree(PWBDataBase *pDoc,
TV_INSERTSTRUCT tvstruct,
CTreeCtrl &TreeCtrl) {
HTREEITEM NewTreeItem;
AP210ObjectListItor MRAitor(&(pDoc->MountingRestrictionAreas));
MountingRestrictionArea *mra;
// Create the root of the Restriction Area list
tvstruct.hParent = NULL;
tvstruct.item.pszText = _T("Restriction Areas");
tvstruct.hInsertAfter = TVI_LAST;
// add the items if they are in the list
if (pDoc->MountingRestrictionAreas.SizeOf() > 0) {
tvstruct.item.iImage = 0; // IDB_FULLPARENT
tvstruct.item.iSelectedImage = 2; // IDB_OPENPARENT
// save this as the parts tree
MountingRestrictionAreaItem = TreeCtrl.InsertItem(&tvstruct);
// all the parts have this has there root.
// and we want to sort them
tvstruct.hParent = MountingRestrictionAreaItem;
tvstruct.hInsertAfter = TVI_SORT;
// Add the physical_units to the tree
tvstruct.item.iImage = 6; // IDB_PACKAGE
tvstruct.item.iSelectedImage = 6; // IDB_PACKAGE
MRAitor.Reset();
while((mra = (MountingRestrictionArea *)MRAitor.NextDirectInstanceOf(MountingRestrictionArea::TypeID())) != NULL) {
tvstruct.item.pszText = _T("MRA");
tvstruct.item.lParam = mra->GetOID();
// save this in pu
NewTreeItem = TreeCtrl.InsertItem(&tvstruct);
TreeCtrl.SetItemData(NewTreeItem, mra->GetOID());
}
}
else { // use empty icons since the list is empty
tvstruct.item.iImage = 1; // IDF_EMPTYPARENT
tvstruct.item.iSelectedImage = 1; // IDF_EMPTYPARENT
MountingRestrictionAreaItem = TreeCtrl.InsertItem(&tvstruct);
}
}
void CAP210ProdView::populateNonPlatedThruHoleTree(PWBDataBase *pDoc,
TV_INSERTSTRUCT tvstruct,
CTreeCtrl &TreeCtrl) {
HTREEITEM NewTreeItem;
AP210ObjectListItor NPTHitor(&(pDoc->NonPlatedThruHoles));
NonPlatedThruHole *npth;
// Create the root of the Non-Plated Thru Hole list
tvstruct.hParent = NULL;
tvstruct.item.pszText = _T("Non-Plated Thru-Holes");
tvstruct.hInsertAfter = TVI_LAST;
// add the items if they are in the list
if (pDoc->NonPlatedThruHoles.SizeOf() > 0) {
tvstruct.item.iImage = 0; // IDB_FULLPARENT
tvstruct.item.iSelectedImage = 2; // IDB_OPENPARENT
// save this as the non-plated thru-hole tree
NonPlatedThruHoleItem = TreeCtrl.InsertItem(&tvstruct);
// all the parts have this has there root.
// and we want to sort them
tvstruct.hParent = NonPlatedThruHoleItem;
tvstruct.hInsertAfter = TVI_SORT;
// Add the physical_units to the tree
tvstruct.item.iImage = 6; // IDB_PACKAGE
tvstruct.item.iSelectedImage = 6; // IDB_PACKAGE
NPTHitor.Reset();
while((npth = (NonPlatedThruHole *)NPTHitor.NextDirectInstanceOf(NonPlatedThruHole::TypeID())) != NULL) {
tvstruct.item.pszText = _T(npth->getId());
tvstruct.item.lParam = npth->GetOID();
// save this in pu
NewTreeItem = TreeCtrl.InsertItem(&tvstruct);
TreeCtrl.SetItemData(NewTreeItem, npth->GetOID());
}
}
else { // use empty icons since the list is empty
tvstruct.item.iImage = 1; // IDF_EMPTYPARENT
tvstruct.item.iSelectedImage = 1; // IDF_EMPTYPARENT
NonPlatedThruHoleItem = TreeCtrl.InsertItem(&tvstruct);
}
}
void CAP210ProdView::OnComponentRestrictionArea() {
// TODO: Add your command handler code here
// create the dialog box
CComponentPlacementRestriction craDlg;
// display the dialog box
craDlg.setValues((PWBDataBase *)GetDocument());
craDlg.DoModal();
}