forked from SynapseWeb/Reconstruct
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobjects_menu.cpp
More file actions
executable file
·2786 lines (2495 loc) · 106 KB
/
objects_menu.cpp
File metadata and controls
executable file
·2786 lines (2495 loc) · 106 KB
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
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
////////////////////////////////////////////////////////////////////////////////
// This file contains the routines for processing the Objects menu operations
//
// Copyright (C) 2003-2007 John Fiala (fiala@bu.edu)
//
// This is free software created with funding from the NIH. You may
// redistribute it and/or modify it under the terms of the GNU General
// Public License published by the Free Software Foundation (www.gnu.org).
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License version 2 for more details.
//
//
// modified 02/08/05 by JCF (fiala@bu.edu)
// -+- change: Added check for object != NULL after CurrObject match to prevent fatal when list out of date
// -+- change: Added proper deletion of object_list at end of all list processing operations
// -+- change: Added CopyObjects on Object List; extracted AddObjectToList from CompleteObjectList to use in CopyObjects
// -+- change: Added message after Trace Attributes changed to indicate list should be reopened.
// modified 3/07/05 by JCF (fiala@bu.edu)
// -+- change: Switched ZTrace list operations to use ZTrace Id parameter for identification.
// modified 3/10/05 by JCF (fiala@bu.edu)
// -+- change: Modified SimplifyObjects to report when nothing changes.
// modified 7/7/05 by JCF (fiala@bu.edu)
// -+- change: Fixed order of processing in ObjectAttributes() to only load each section once.
// modified 7/8/05 by JCF (fiala@bu.edu)
// -+- change: Reorganized Object List menus and added HideObject and ZTraceObject.
// modified 7/13/05 by JCF (fiala@bu.edu)
// -+- change: Added ResetSceneIcons and Reset to AddSelectedZTracesToScene().
// ztraceList col widths set by user are remember when refill list.
// fixed Reset, update display, and icons when change scene from z-trace list.
// modified 11/1/05 by JCF (fiala@bu.edu)
// -+- change: Added Rename Objects command, and customized Object Attributes dialog.
// modified 11/2/05 by JCF (fiala@bu.edu)
// -+- change: Fixed Rename Objects to work over a selected range.
// modified 11/7/05 by JCF (fiala@bu.edu)
// -+- change: Fixed bug in generating 3D objects while thread still working on selectedObjects.
// modified 11/17/05 by JCF (fiala@bu.edu)
// -+- change: Added progress to object list reading.
// modified 1/26/06 by JCF (fiala@bu.edu)
// -+- change: Modified RenameObject to delete old item names from list after renaming to prevent crash if use them.
// modified 2/28/06 by JCF (fiala@bu.edu)
// -+- change: Modified SetDefaultName params.
// modified 3/15/06 by JCF (fiala@bu.edu)
// -+- change: Fixed dialog modes for Object List dialogs so user can't run multiple dialogs simultaneously.
// modified 3/28/06 by JCF (fiala@bu.edu)
// -+- change: Remove object from scene when rename.
// modified 4/25/06 by JCF (fiala@bu.edu)
// -+- change: Added CM_REFRESHLIST and CM_INFOLIST to ZTrace List, Object List, and Distances List.
// modified 5/2/06 by JCF (fiala@bu.edu)
// -+- change: Complete addition of Create Z Tracce from Object List item.
// modified 5/4/06 by JCF (fiala@bu.edu)
// -+- change: Added CopyZTraces, SmoothZTraces to ZTrace List, SmoothObjects to Object List.
// modified 5/11/06 by JCF (fiala@bu.edu)
// -+- change: Added GridAtZTraces to create grids at z-trace points.
// modified 6/8/06 by JCF (fiala@bu.edu)
// -+- change: Changed message at end of Rename Objects.
// modified 6/14/06 by JCF (fiala@bu.edu)
// -+- change: Fixed bug that caused ObjectList reading to appear to hang after ztraceWindow closed.
// modified 6/23/06 by JCF (fiala@bu.edu)
// -+- change: Changed name of SetFillMode() to SetFillModeObject() to avoid conflict with trace_menu.cpp
// modified 2/5/07 by JCF (fiala@bu.edu)
// -+- change: Added some debug logging to look for the Object List hanging problem.
// modified 4/23/07 by JCF (fiala@bu.edu)
// -+- change: Modified CmFindObjectNamed() to Object List. (SHOULD THIS BE FIRST MENU ITEM?)
// modified 5/8/07 by JCF (fiala@bu.edu)
// -+- change: Fixed ObjectList (and DistancesList?) hanging by having thread procedure post to appWnd only.
// modified 7/16/07 by JCF (fiala@bu.edu)
// -+- change: Added enable of Maximize sys menu cmd in WM_CREATE of Object, Z-Trace, and Distances Windows.
//
#include "reconstruct.h"
void AddSelectedObjectsToScene( HWND list ) // add listview selections to CurrScene and display them
{
VRMLObject *object, *selected;
LV_ITEM lvi;
char name[MAX_CONTOUR_NAME];
if ( selectedObjects ) return; // do nothing if selectedObjects still processing
selectedObjects = new VRMLObjects();
lvi.iItem = SendMessage(list, LVM_GETNEXTITEM, -1, (LPARAM)(LVNI_ALL | LVNI_SELECTED) );
while ( lvi.iItem >= 0 )
{ // an item was selected, retrieve object name
lvi.mask = LVIF_TEXT;
lvi.iSubItem = 0; lvi.pszText = name; lvi.cchTextMax = MAX_CONTOUR_NAME;
SendMessage(list, LVM_GETITEM, 0, (LPARAM)(&lvi));
object = CurrObjects->Match( name ); // find object info in list
selected = new VRMLObject();
strcpy(selected->name,object->name); // copy info to scene object
selected->firstSection = max(object->firstSection,CurrSeries->first3Dsection);
selected->lastSection = min(object->lastSection,CurrSeries->last3Dsection);
selectedObjects->Add( selected ); // add to selected list
lvi.iItem = SendMessage(list, LVM_GETNEXTITEM, lvi.iItem, (LPARAM)(LVNI_ALL | LVNI_SELECTED) );
}
if ( selectedObjects->Number() ) Generate3DThreadBegin();
else { delete selectedObjects; selectedObjects = NULL; }
}
void ResetSceneIcons( HWND list ) // reset all list icons to reflect status in scene
{
VRMLObject *sceneObject;
LV_ITEM lvi;
char name[MAX_CONTOUR_NAME];
lvi.iItem = SendMessage(list, LVM_GETNEXTITEM, -1, (LPARAM)(LVNI_ALL) );
while ( lvi.iItem >= 0 )
{
lvi.iSubItem = 0; lvi.iImage = 0; // change back to object icon
if ( CurrScene )
if ( CurrScene->objects )
{
lvi.mask = LVIF_TEXT; lvi.pszText = name; lvi.cchTextMax = MAX_CONTOUR_NAME;
SendMessage(list, LVM_GETITEM, 0, (LPARAM)(&lvi));
sceneObject = CurrScene->objects->Match( name );// object already exists in scene!
if ( sceneObject ) lvi.iImage = 1; // change back to object icon
}
lvi.mask = LVIF_IMAGE;
SendMessage(list, LVM_SETITEM, 0, (LPARAM)(&lvi));
lvi.iItem = SendMessage(list, LVM_GETNEXTITEM, lvi.iItem, (LPARAM)(LVNI_ALL) );
}
}
void RemoveSelectedObjectsFromScene( HWND list ) // remove listview selections from CurrScene
{
VRMLObject *sceneObject;
LV_ITEM lvi;
char name[MAX_CONTOUR_NAME];
if ( CurrScene ) // if there is a scene, search for matching selected objects
{
lvi.iItem = SendMessage(list, LVM_GETNEXTITEM, -1, (LPARAM)(LVNI_ALL | LVNI_SELECTED) );
while ( lvi.iItem >= 0 )
{ // an item was selected, retrieve object name
lvi.mask = LVIF_TEXT;
lvi.iSubItem = 0; lvi.pszText = name; lvi.cchTextMax = MAX_CONTOUR_NAME;
SendMessage(list, LVM_GETITEM, 0, (LPARAM)(&lvi));
if ( CurrScene->objects )
{
sceneObject = CurrScene->objects->Match( name );// object already exists in scene!
if ( sceneObject )
{
CurrScene->objects->Extract( sceneObject ); // remove and delete it
delete sceneObject;
}
}
lvi.iItem = SendMessage(list, LVM_GETNEXTITEM, lvi.iItem, (LPARAM)(LVNI_ALL | LVNI_SELECTED) );
}
if ( IsWindow( openGLWindow ) )
{
CurrScene->Compile(); // recompile scene to OpenGL
InvalidateRect(openGLWindow,NULL,FALSE);
}
ResetSceneIcons( list ); // update icons in list
}
}
void CmFindObjectNamed( HWND list ) // remove listview selections from CurrScene
{
VRMLObject *object;
LV_ITEM lvi;
char name[MAX_CONTOUR_NAME];
lvi.iItem = SendMessage(list, LVM_GETNEXTITEM, -1, (LPARAM)(LVNI_ALL | LVNI_SELECTED) );
if ( lvi.iItem >= 0 )
{ // an item was selected, retrieve object name
lvi.mask = LVIF_TEXT;
lvi.iSubItem = 0; lvi.pszText = name; lvi.cchTextMax = MAX_CONTOUR_NAME;
SendMessage(list, LVM_GETITEM, 0, (LPARAM)(&lvi));
object = CurrObjects->Match( name ); // find object info in list
if ( object )
ShowSectionTrace( object->firstSection, name ); // jump to first trace of object in series
}
}
void HideObjects( HWND list, bool hide ) // modify traces of listview selections to set hidden==hide
{
VRMLObjects *object_list;
VRMLObject *object, *todo_object;
Section *section;
Transform *transform;
Contour *contour;
int i, sectnum, first, last;
LV_ITEM lvi;
HCURSOR cur;
bool changed;
char name[MAX_CONTOUR_NAME];
object_list = new VRMLObjects(); // create a list of objects to modify
first = MAX_INT32;
last = 0; // remember total section range of objects
lvi.iItem = SendMessage(list, LVM_GETNEXTITEM, -1, (LPARAM)(LVNI_ALL | LVNI_SELECTED) );
while ( lvi.iItem >= 0 )
{ // an item was selected, retrieve object name
lvi.mask = LVIF_TEXT;
lvi.iSubItem = 0; lvi.pszText = name; lvi.cchTextMax = MAX_CONTOUR_NAME;
SendMessage(list, LVM_GETITEM, 0, (LPARAM)(&lvi));
object = CurrObjects->Match( name ); // find object info in list
if ( object )
{
todo_object = new VRMLObject();
strcpy(todo_object->name,object->name); // copy info to object to be modified
todo_object->firstSection = object->firstSection;
todo_object->lastSection = object->lastSection;
object_list->Add( todo_object );
if ( first > todo_object->firstSection ) first = todo_object->firstSection;
if ( last < todo_object->lastSection ) last = todo_object->lastSection;
}
lvi.iItem = SendMessage(list, LVM_GETNEXTITEM, lvi.iItem, (LPARAM)(LVNI_ALL | LVNI_SELECTED) );
}
i = object_list->Number();
if ( i > 0 ) // have at least one object to modify
{
cur = SetCursor( LoadCursor( 0, IDC_WAIT ) );// show hourglass, file access could be slow
sectnum = first-1;
section = GetNextSectionBetween( sectnum, last ); // fetch section
while ( section )
{
changed = false; // initially, no changes to section
object = object_list->first;
while ( object ) // search object list for objects to do
{
if ( (sectnum <= object->lastSection) && (sectnum >= object->firstSection) )
{
if ( section->transforms ) // object could be in section, search contours
{
transform = section->transforms->first;
while ( transform ) // check each transform for contours
{
if ( transform->contours )
{ // for all contours, look for object contours
contour = transform->contours->first;
while ( contour )
{
if ( strcmp(contour->name,object->name) == 0 ) // FOUND! change it!
{
if ( contour->hidden != hide ) changed = true;
contour->hidden = hide; // change hidden state
}
contour = contour->next; // do next contour in section
}
}
transform = transform->next;
}
}
} // end if sectnum
object = object->next;
} // end while object
PutSection( section, changed, false, changed ); // save or delete section and redraw if current
section = GetNextSectionBetween( sectnum, last );
}
SetCursor( cur ); // restore cursor
if ( CurrSection ) CurrSection->UnselectHidden(); // remove any just hidden traces
if ( PrevSection ) PrevSection->UnselectHidden(); // from activ ones in sections
if ( IsWindow(traceWindow) ) PostMessage( traceWindow, UM_UPDATESECTION, 0, 0 );
}
delete object_list; // free memory
}
void SetFillModeObject( HWND hwndDlg, int nofill, int maskfill, int copyfill, int mergefill )
{
SendDlgItemMessage(hwndDlg, ID_NOFILL, BM_SETCHECK, (WPARAM)nofill, 0);
SendDlgItemMessage(hwndDlg, ID_MASKFILL, BM_SETCHECK, (WPARAM)maskfill, 0);
SendDlgItemMessage(hwndDlg, ID_COPYFILL, BM_SETCHECK, (WPARAM)copyfill, 0);
SendDlgItemMessage(hwndDlg, ID_MERGEFILL, BM_SETCHECK, (WPARAM)mergefill, 0);
}
void FillDlgObject( HWND hwndDlg )
{
SendDlgItemMessage(hwndDlg, ID_COMMENT, WM_SETTEXT, 0, (LPARAM)DlgContour->comment);
ColorButton( GetDlgItem( hwndDlg, ID_BORDERCOLOR ), DlgContour->border );
ColorButton( GetDlgItem( hwndDlg, ID_FILLCOLOR ), DlgContour->fill );
if ( !ChangeClosed ) // gray fill selected state
SendDlgItemMessage(hwndDlg, ID_CLOSED, BM_SETCHECK, (WPARAM)BST_INDETERMINATE, 0);
else if ( DlgContour->closed ) // or match DlgContour state
SendDlgItemMessage(hwndDlg, ID_CLOSED, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
else SendDlgItemMessage(hwndDlg, ID_CLOSED, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
if ( !ChangeHidden ) // gray fill selected state
SendDlgItemMessage(hwndDlg, ID_HIDDEN, BM_SETCHECK, (WPARAM)BST_INDETERMINATE, 0);
else if ( DlgContour->hidden ) // or match DlgContour state
SendDlgItemMessage(hwndDlg, ID_HIDDEN, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
else SendDlgItemMessage(hwndDlg, ID_HIDDEN, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
if ( !ChangeSimplified ) // gray fill selected state
SendDlgItemMessage(hwndDlg, ID_SIMPLIFIED, BM_SETCHECK, (WPARAM)BST_INDETERMINATE, 0);
else if ( DlgContour->simplified ) // or match DlgContour state
SendDlgItemMessage(hwndDlg, ID_SIMPLIFIED, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
else SendDlgItemMessage(hwndDlg, ID_SIMPLIFIED, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
if ( !ChangeSelected ) // gray fill selected state
SendDlgItemMessage(hwndDlg, ID_FILLSELECTED, BM_SETCHECK, (WPARAM)BST_INDETERMINATE, 0);
else if ( DlgContour->mode > 0 ) // or match DlgContour state
SendDlgItemMessage(hwndDlg, ID_FILLSELECTED, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
else SendDlgItemMessage(hwndDlg, ID_FILLSELECTED, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
if ( abs(DlgContour->mode) == R2_NOP )
SetFillModeObject( hwndDlg, BST_CHECKED, BST_UNCHECKED, BST_UNCHECKED, BST_UNCHECKED );
else if ( abs(DlgContour->mode) == R2_MASKPEN )
SetFillModeObject( hwndDlg, BST_UNCHECKED, BST_CHECKED, BST_UNCHECKED, BST_UNCHECKED );
else if ( abs(DlgContour->mode) == R2_COPYPEN )
SetFillModeObject( hwndDlg, BST_UNCHECKED, BST_UNCHECKED, BST_CHECKED, BST_UNCHECKED );
else if ( abs(DlgContour->mode) == R2_MERGEPEN )
SetFillModeObject( hwndDlg, BST_UNCHECKED, BST_UNCHECKED, BST_UNCHECKED, BST_CHECKED );
else SetFillModeObject( hwndDlg, BST_INDETERMINATE, BST_INDETERMINATE, BST_INDETERMINATE, BST_INDETERMINATE );
}
BOOL CALLBACK ObjectAttributesDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM)
{
CHOOSECOLOR cc;
Contour *c;
int i;
char txt[64];
switch (message) // enter with CurrContour set from first active contour so can set values after OK
{
case WM_INITDIALOG:
SendDlgItemMessage(hwndDlg, ID_CONTOURNAME, WM_SETTEXT, 0, (LPARAM)InputDlgName);
FillDlgObject( hwndDlg );
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case ID_BORDERCOLOR:
ZeroMemory(&cc, sizeof(CHOOSECOLOR)); // setup color dialog structure
cc.lStructSize = sizeof(CHOOSECOLOR);
cc.hwndOwner = hwndDlg;
cc.Flags = CC_FULLOPEN | CC_RGBINIT;
cc.rgbResult = DlgContour->border.ref(); // set current color
for (i=0; i<16; i++) CustomColors[i] = CurrSeries->borderColors[i].ref();
cc.lpCustColors = CustomColors; // set custom colors
if ( ChooseColor(&cc) ) // open color dialog
{
DlgContour->border = Color( cc.rgbResult );// reset default color
ColorButton( GetDlgItem( hwndDlg, ID_BORDERCOLOR ), DlgContour->border );
for (i=0; i<16; i++) CurrSeries->borderColors[i] = Color( CustomColors[i] );
}
return TRUE;
case ID_FILLCOLOR:
ZeroMemory(&cc, sizeof(CHOOSECOLOR)); // setup color dialog structure
cc.lStructSize = sizeof(CHOOSECOLOR);
cc.hwndOwner = hwndDlg;
cc.Flags = CC_FULLOPEN | CC_RGBINIT;
cc.rgbResult = DlgContour->fill.ref(); // set current color
for (i=0; i<16; i++) CustomColors[i] = CurrSeries->fillColors[i].ref();
cc.lpCustColors = CustomColors; // set custom colors
if ( ChooseColor(&cc) ) // open color dialog
{
DlgContour->fill = Color( cc.rgbResult ); // reset default color
ColorButton( GetDlgItem( hwndDlg, ID_FILLCOLOR ), DlgContour->fill );
for (i=0; i<16; i++) CurrSeries->fillColors[i] = Color( CustomColors[i] );
}
return TRUE;
case ID_CLOSED: // if user clicks on INDETERMINATE state then must change it
i = SendDlgItemMessage(hwndDlg, ID_CLOSED, BM_GETCHECK, 0, 0);
if ( i == BST_INDETERMINATE ) ChangeClosed = true;
if ( i == BST_CHECKED )
{
SendDlgItemMessage(hwndDlg, ID_CLOSED, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
DlgContour->closed = false;
}
else {
SendDlgItemMessage(hwndDlg, ID_CLOSED, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
DlgContour->closed = true;
}
return TRUE;
case ID_HIDDEN: // if user clicks on INDETERMINATE state then must change it
i = SendDlgItemMessage(hwndDlg, ID_HIDDEN, BM_GETCHECK, 0, 0);
if ( i == BST_INDETERMINATE ) ChangeHidden = true;
if ( i == BST_CHECKED )
{
SendDlgItemMessage(hwndDlg, ID_HIDDEN, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
DlgContour->hidden = false;
}
else {
SendDlgItemMessage(hwndDlg, ID_HIDDEN, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
DlgContour->hidden = true;
}
return TRUE;
case ID_SIMPLIFIED: // if user clicks on INDETERMINATE state then must change it
i = SendDlgItemMessage(hwndDlg, ID_SIMPLIFIED, BM_GETCHECK, 0, 0);
if ( i == BST_INDETERMINATE ) ChangeSimplified = true;
if ( i == BST_CHECKED )
{
SendDlgItemMessage(hwndDlg, ID_SIMPLIFIED, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
DlgContour->simplified = false;
}
else {
SendDlgItemMessage(hwndDlg, ID_SIMPLIFIED, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
DlgContour->simplified = true;
}
return TRUE;
case ID_FILLSELECTED:
i = SendDlgItemMessage(hwndDlg, ID_FILLSELECTED, BM_GETCHECK, 0, 0);
if ( i == BST_INDETERMINATE ) ChangeSelected = true;
if ( i == BST_CHECKED )
SendDlgItemMessage(hwndDlg, ID_FILLSELECTED, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
else SendDlgItemMessage(hwndDlg, ID_FILLSELECTED, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
return TRUE;
case ID_NOFILL:
DlgContour->mode = R2_NOP;
SetFillModeObject( hwndDlg, BST_CHECKED, BST_UNCHECKED, BST_UNCHECKED, BST_UNCHECKED );
return TRUE;
case ID_MASKFILL:
DlgContour->mode = R2_MASKPEN;
SetFillModeObject( hwndDlg, BST_UNCHECKED, BST_CHECKED, BST_UNCHECKED, BST_UNCHECKED );
return TRUE;
case ID_COPYFILL:
DlgContour->mode = R2_COPYPEN;
SetFillModeObject( hwndDlg, BST_UNCHECKED, BST_UNCHECKED, BST_CHECKED, BST_UNCHECKED );
return TRUE;
case ID_MERGEFILL:
DlgContour->mode = R2_MERGEPEN;
SetFillModeObject( hwndDlg, BST_UNCHECKED, BST_UNCHECKED, BST_UNCHECKED, BST_CHECKED );
return TRUE;
case ID_GETDEFAULTS: // copy default attributes into dialog
DlgContour->border = CurrSeries->defaultBorder;
DlgContour->fill = CurrSeries->defaultFill;
DlgContour->mode = CurrSeries->defaultMode;
ChangeSelected = true;
FillDlgObject( hwndDlg );
return TRUE;
case ID_GETCLIPBOARD: // copy clipboard attributes into dialog
if ( ClipboardTransform )
if ( ClipboardTransform->contours )
{
c = ClipboardTransform->contours->first;
DlgContour->border = c->border;
DlgContour->fill = c->fill;
DlgContour->mode = c->mode;
ChangeSelected = true;
FillDlgObject( hwndDlg );
}
return TRUE;
// user says OK, so store values from dialog in DlgContour
case IDOK:
SendDlgItemMessage(hwndDlg, ID_COMMENT, WM_GETTEXT, (WPARAM)MAX_COMMENT, (LPARAM)DlgContour->comment);
RemoveIllegalChars( DlgContour->comment );
if ( ChangeSelected )
if ( SendDlgItemMessage(hwndDlg, ID_FILLSELECTED, BM_GETCHECK, 0, 0) == BST_CHECKED )
DlgContour->mode = -abs(DlgContour->mode);
else DlgContour->mode = abs(DlgContour->mode); // change this here so can add it to mode
EndDialog(hwndDlg, 1);
return TRUE;
case IDCANCEL:
EndDialog(hwndDlg, 0);
return TRUE;
}
}
return FALSE;
}
void ObjectAttributes( HWND list ) // modify traces of listview selections
{
VRMLObjects *object_list;
VRMLObject *object, *todo_object;
Section *section;
Transform *transform;
Contour *contour;
int i, sectnum, first, last;
LV_ITEM lvi;
HCURSOR cur;
bool changed, msg_changed;
char name[MAX_CONTOUR_NAME], filename[MAX_PATH];
object_list = new VRMLObjects(); // create a list of objects to modify
first = MAX_INT32;
last = 0; // remember total section range of objects
msg_changed = false;
lvi.iItem = SendMessage(list, LVM_GETNEXTITEM, -1, (LPARAM)(LVNI_ALL | LVNI_SELECTED) );
while ( lvi.iItem >= 0 )
{ // an item was selected, retrieve object name
lvi.mask = LVIF_TEXT;
lvi.iSubItem = 0; lvi.pszText = name; lvi.cchTextMax = MAX_CONTOUR_NAME;
SendMessage(list, LVM_GETITEM, 0, (LPARAM)(&lvi));
object = CurrObjects->Match( name ); // find object info in list
if ( object )
{
todo_object = new VRMLObject();
strcpy(todo_object->name,object->name); // copy info to object to be modified
todo_object->firstSection = object->firstSection;
todo_object->lastSection = object->lastSection;
object_list->Add( todo_object );
if ( first > todo_object->firstSection ) first = todo_object->firstSection;
if ( last < todo_object->lastSection ) last = todo_object->lastSection;
}
lvi.iItem = SendMessage(list, LVM_GETNEXTITEM, lvi.iItem, (LPARAM)(LVNI_ALL | LVNI_SELECTED) );
}
i = object_list->Number();
if ( i > 0 ) // have at least one object to modify
{
DlgContour = new Contour(); // use it here as global value holder
if ( i > 1 )
{
strcpy(DlgContour->name,"*"); // so use wildcard to match all names
sprintf(InputDlgName,"Changing %d objects to...",i);
}
else {
strcpy(DlgContour->name,todo_object->name);// just use object name
sprintf(InputDlgName,"Changing object \"%s\" to...",todo_object->name);
}
strcpy(DlgContour->comment,"*"); // use wildcard so don't change comments
DlgContour->border.negate(); // dont change border color
DlgContour->fill.negate(); // dont change fill color
ChangeHidden = false; // dont change closure state
ChangeClosed = false; // dont change closure state
ChangeSelected = false; // dont change fill selected
ChangeSimplified = false;
DlgContour->mode = R2_BLACK; // dont change fill mode
if ( DialogBox( appInstance, "ObjectAttributesDlg", list, (DLGPROC)ObjectAttributesDlgProc ) == IDOK )
{
cur = SetCursor( LoadCursor( 0, IDC_WAIT ) );// show hourglass, file access could be slow
sectnum = first-1;
section = GetNextSectionBetween( sectnum, last ); // fetch section
while ( section )
{
changed = false; // initially, no changes to section
object = object_list->first;
while ( object ) // search object list for objects to do
{
if ( (sectnum <= object->lastSection) && (sectnum >= object->firstSection) )
{
if ( section->transforms ) // object could be in section, search contours
{
transform = section->transforms->first;
while ( transform ) // check each transform for contours
{
if ( transform->contours )
{ // for all contours, look for object contours
contour = transform->contours->first;
while ( contour )
{
if ( strcmp(contour->name,object->name) == 0 ) // FOUND! change it!
{
changed = true;
if ( DlgContour->comment[0] == '*' ) // concatenate if wild card was used
strncat(contour->comment,DlgContour->comment+1,MAX_COMMENT-strlen(contour->comment));
else strcpy(contour->comment,DlgContour->comment); // otherwise just copy comment
if ( ChangeClosed )
contour->closed = DlgContour->closed; // change open/close state
if ( ChangeHidden )
contour->hidden = DlgContour->hidden; // change hidden state
if ( ChangeSimplified )
contour->simplified = DlgContour->simplified;// change simplified state
if ( !DlgContour->border.invalid() )
contour->border = DlgContour->border; // set border color
if ( !DlgContour->fill.invalid() )
contour->fill = DlgContour->fill; // set fill color
if ( abs(DlgContour->mode) != R2_BLACK )
contour->mode = abs(DlgContour->mode); // set fill mode
if ( ChangeSelected )
if ( DlgContour->mode < 0 ) // set fill selected to match DlgContour
contour->mode = -abs(contour->mode);
else contour->mode = abs(contour->mode);
}
contour = contour->next; // do next contour in section
}
}
transform = transform->next;
}
}
} // end if sectnum
object = object->next;
} // end while object
PutSection( section, changed, false, changed ); // save or delete section and redraw if current
section = GetNextSectionBetween( sectnum, last );
}
SetCursor( cur ); // restore cursor
if ( CurrSection ) CurrSection->UnselectHidden(); // remove any just hidden traces
if ( PrevSection ) PrevSection->UnselectHidden(); // from activ ones in sections
if ( IsWindow(traceWindow) ) PostMessage( traceWindow, UM_UPDATESECTION, 0, 0 );
msg_changed = true;
}
delete DlgContour;
}
delete object_list; // free memory and tell user things were changes
if ( msg_changed ) MessageBox(list,"Attributes have been changed.","Object Attributes",MB_OK);
}
BOOL CALLBACK ObjectRenameDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM)
{
char dlgItemTxt[64];
switch (message) // enter with CurrContour set from first active contour so can set values after OK
{
case WM_INITDIALOG:
SetWindowText( hwndDlg, InputDlgName ); // fill in the values that will result from user OK
SendDlgItemMessage(hwndDlg, ID_CONTOURNAME, WM_SETTEXT, 0, (LPARAM)DlgContour->name);
sprintf(dlgItemTxt,"%d",FirstSection);
SetDlgItemText( hwndDlg, ID_FIRSTSECTION, dlgItemTxt );
sprintf(dlgItemTxt,"%d",LastSection);
SetDlgItemText( hwndDlg, ID_LASTSECTION, dlgItemTxt );
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{ // user says OK, so store values from dialog in DlgContour
case IDOK:
SendDlgItemMessage(hwndDlg, ID_CONTOURNAME, WM_GETTEXT, (WPARAM)MAX_CONTOUR_NAME, (LPARAM)DlgContour->name);
RemoveIllegalChars( DlgContour->name );
GetDlgItemText( hwndDlg, ID_FIRSTSECTION, dlgItemTxt, sizeof(dlgItemTxt) );
FirstSection = atoi(dlgItemTxt);
GetDlgItemText( hwndDlg, ID_LASTSECTION, dlgItemTxt, sizeof(dlgItemTxt) );
LastSection = atoi(dlgItemTxt);
EndDialog(hwndDlg, 1);
return TRUE;
case IDCANCEL:
EndDialog(hwndDlg, 0);
return TRUE;
}
}
return FALSE;
}
void ObjectRename( HWND list ) // modify traces of listview selections over a selected range of sections
{
VRMLObjects *object_list;
VRMLObject *object, *todo_object, *sceneObject;
Section *section;
Transform *transform;
Contour *contour;
int i, sectnum, first, last;
LV_ITEM lvi;
HCURSOR cur;
bool changed, msg_changed, scene_changed;
char name[MAX_CONTOUR_NAME];
object_list = new VRMLObjects(); // create a list of objects to modify
first = MAX_INT32;
last = 0; // remember total section range of objects
msg_changed = false;
scene_changed = false;
lvi.iItem = SendMessage(list, LVM_GETNEXTITEM, -1, (LPARAM)(LVNI_ALL | LVNI_SELECTED) );
while ( lvi.iItem >= 0 )
{ // an item was selected, retrieve object name
lvi.mask = LVIF_TEXT;
lvi.iSubItem = 0; lvi.pszText = name; lvi.cchTextMax = MAX_CONTOUR_NAME;
SendMessage(list, LVM_GETITEM, 0, (LPARAM)(&lvi));
object = CurrObjects->Match( name ); // find object info in list
if ( object )
{
todo_object = new VRMLObject();
strcpy(todo_object->name,object->name); // copy info to object to be modified
todo_object->firstSection = object->firstSection;
todo_object->lastSection = object->lastSection;
object_list->Add( todo_object );
if ( first > todo_object->firstSection ) first = todo_object->firstSection;
if ( last < todo_object->lastSection ) last = todo_object->lastSection;
}
lvi.iItem = SendMessage(list, LVM_GETNEXTITEM, lvi.iItem, (LPARAM)(LVNI_ALL | LVNI_SELECTED) );
}
i = object_list->Number();
if ( i > 0 ) // have at least one object to modify
{
DlgContour = new Contour(); // use it here as global value holder
if ( i > 1 )
{
strcpy(DlgContour->name,"*"); // so use wildcard to match all names
sprintf(InputDlgName,"Renaming %d objects to...",i);
}
else {
strcpy(DlgContour->name,todo_object->name);// just use object name
sprintf(InputDlgName,"Renaming 1 object to...");
}
FirstSection = first; // set section range to change whole of all objects
LastSection = last;
if ( DialogBox( appInstance, "ObjectRenameDlg", list, (DLGPROC)ObjectRenameDlgProc ) == IDOK )
{
cur = SetCursor( LoadCursor( 0, IDC_WAIT ) );// show hourglass, file access could be slow
sectnum = FirstSection-1;
section = GetNextSectionBetween( sectnum, LastSection ); // fetch section
while ( section )
{
changed = false; // initially, no changes to section
object = object_list->first;
while ( object ) // search object list for objects to do
{
if ( (sectnum <= object->lastSection) && (sectnum >= object->firstSection) )
{
if ( section->transforms ) // object could be in section, search contours
{
transform = section->transforms->first;
while ( transform ) // check each transform for contours
{
if ( transform->contours )
{ // for all contours, look for object contours
contour = transform->contours->first;
while ( contour )
{
if ( strcmp(contour->name,object->name) == 0 ) // FOUND! change it!
{
changed = true;
section->SetDefaultName(name,DlgContour->name,false);
if ( name[0] == '*' ) // concatenate if wild card was used
strncat(contour->name,name+1,MAX_CONTOUR_NAME-strlen(contour->name));
else strcpy(contour->name,name); // otherwise just copy contour name
}
contour = contour->next; // do next contour in section
}
}
transform = transform->next; // do next transform
}
}
} // end if sectnum
object = object->next;
} // end while object
PutSection( section, changed, false, changed ); // save or delete section and redraw if current
section = GetNextSectionBetween( sectnum, LastSection ); // keep going to limit of section range
}
SetCursor( cur ); // restore cursor
if ( CurrSection ) CurrSection->UnselectHidden(); // remove any just hidden traces
if ( PrevSection ) PrevSection->UnselectHidden(); // from activ ones in sections
if ( IsWindow(traceWindow) ) PostMessage( traceWindow, UM_UPDATESECTION, 0, 0 );
lvi.iItem = SendMessage(list, LVM_GETNEXTITEM, -1, (LPARAM)(LVNI_ALL | LVNI_SELECTED) );
while ( lvi.iItem >= 0 )
{ // deleted selected items from list
lvi.mask = LVIF_TEXT;
lvi.iSubItem = 0; lvi.pszText = name; lvi.cchTextMax = MAX_CONTOUR_NAME;
SendMessage(list, LVM_GETITEM, 0, (LPARAM)(&lvi));
object = object_list->first;
while ( object ) // search object list for object name to be sure
{
if ( strcmp(name,object->name) == 0 ) // found in listview AND in object_list
{
SendMessage(list, LVM_DELETEITEM, lvi.iItem, 0);// delete it from list!
lvi.iItem--; // backup so next item will be considered
if ( CurrScene )
if ( CurrScene->objects )
{ // check if object in 3D scene
sceneObject = CurrScene->objects->Match( name );
if ( sceneObject ) // found it so...
{
CurrScene->objects->Extract( sceneObject ); // remove and delete it
delete sceneObject; // otherwise won't be able to later
scene_changed = true;
}
}
break; // break out of while( object ) loop
}
object = object->next; // after searching object list, go to next list item
}
lvi.iItem = SendMessage(list, LVM_GETNEXTITEM, lvi.iItem, (LPARAM)(LVNI_ALL | LVNI_SELECTED) );
}
msg_changed = true;
}
delete DlgContour;
}
delete object_list; // free memory
if ( scene_changed && IsWindow( openGLWindow ) ) // if scene changed redraw it
{
CurrScene->Compile(); // recompile scene to OpenGL
InvalidateRect(openGLWindow,NULL,FALSE);
} // tell user things changed
if ( msg_changed ) MessageBox(list,"Objects have been renamed.\n\nRefresh list to see name changes.","Rename Objects",MB_OK);
}
BOOL CALLBACK SceneDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM)
{
CHOOSECOLOR cc;
Contour *c;
int i;
char txt[MAX_DIGITS];
switch (message) // enter with CurrContour set from first active contour so can set values after OK
{
case WM_INITDIALOG:
SetWindowText( hwndDlg, InputDlgName ); // fill in the values that will result from user OK
ColorButton( GetDlgItem( hwndDlg, ID_DIFFUSECOLOR ), DlgObject->diffuseColor );
ColorButton( GetDlgItem( hwndDlg, ID_EMISSIVECOLOR ), DlgObject->emissiveColor );
ColorButton( GetDlgItem( hwndDlg, ID_SPECULARCOLOR ), DlgObject->specularColor );
sprintf(txt,"%g",DlgObject->ambientIntensity);
SetDlgItemText( hwndDlg, ID_AMBIENTINTENSITY, txt );
sprintf(txt,"%g",DlgObject->transparency);
SetDlgItemText( hwndDlg, ID_TRANSPARENCY, txt );
sprintf(txt,"%g",DlgObject->shininess);
SetDlgItemText( hwndDlg, ID_SHININESS, txt );
if ( DlgObject->frontFill ) SendDlgItemMessage(hwndDlg, ID_FRONTFILL, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
else SendDlgItemMessage(hwndDlg, ID_FRONTFILL, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
if ( DlgObject->backFill ) SendDlgItemMessage(hwndDlg, ID_BACKFILL, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
else SendDlgItemMessage(hwndDlg, ID_BACKFILL, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case ID_DIFFUSECOLOR:
ZeroMemory(&cc, sizeof(CHOOSECOLOR)); // setup color dialog structure
cc.lStructSize = sizeof(CHOOSECOLOR);
cc.hwndOwner = hwndDlg;
cc.Flags = CC_FULLOPEN | CC_RGBINIT;
cc.rgbResult = DlgObject->diffuseColor.ref(); // set current color
cc.lpCustColors = CustomColors; // set custom colors
if ( ChooseColor(&cc) ) // open color dialog
{
DlgObject->diffuseColor = Color( cc.rgbResult );// reset default color
ColorButton( GetDlgItem( hwndDlg, ID_DIFFUSECOLOR ), DlgObject->diffuseColor );
}
return TRUE;
case ID_EMISSIVECOLOR:
ZeroMemory(&cc, sizeof(CHOOSECOLOR)); // setup color dialog structure
cc.lStructSize = sizeof(CHOOSECOLOR);
cc.hwndOwner = hwndDlg;
cc.Flags = CC_FULLOPEN | CC_RGBINIT;
cc.rgbResult = DlgObject->emissiveColor.ref(); // set current color
cc.lpCustColors = CustomColors; // set custom colors
if ( ChooseColor(&cc) ) // open color dialog
{
DlgObject->emissiveColor = Color( cc.rgbResult );// reset default color
ColorButton( GetDlgItem( hwndDlg, ID_EMISSIVECOLOR ), DlgObject->emissiveColor );
}
return TRUE;
case ID_SPECULARCOLOR:
ZeroMemory(&cc, sizeof(CHOOSECOLOR)); // setup color dialog structure
cc.lStructSize = sizeof(CHOOSECOLOR);
cc.hwndOwner = hwndDlg;
cc.Flags = CC_FULLOPEN | CC_RGBINIT;
cc.rgbResult = DlgObject->specularColor.ref(); // set current color
cc.lpCustColors = CustomColors; // set custom colors
if ( ChooseColor(&cc) ) // open color dialog
{
DlgObject->specularColor = Color( cc.rgbResult );// reset default color
ColorButton( GetDlgItem( hwndDlg, ID_SPECULARCOLOR ), DlgObject->specularColor );
}
return TRUE;
// user says OK, so store values from dialog in DlgContour
case IDOK:
SendDlgItemMessage(hwndDlg, ID_AMBIENTINTENSITY, WM_GETTEXT, MAX_DIGITS, (LPARAM)txt);
DlgObject->ambientIntensity = atof(txt);
if ( DlgObject->ambientIntensity < 0.0 ) DlgObject->ambientIntensity = 0.0;
if ( DlgObject->ambientIntensity > 1.0 ) DlgObject->ambientIntensity = 1.0;
SendDlgItemMessage(hwndDlg, ID_TRANSPARENCY, WM_GETTEXT, MAX_DIGITS, (LPARAM)txt);
DlgObject->transparency = atof(txt);
if ( DlgObject->transparency < 0.0 ) DlgObject->transparency = 0.0;
if ( DlgObject->transparency > 1.0 ) DlgObject->transparency = 1.0;
SendDlgItemMessage(hwndDlg, ID_SHININESS, WM_GETTEXT, MAX_DIGITS, (LPARAM)txt);
DlgObject->shininess = atof(txt);
if ( DlgObject->shininess < 0.0 ) DlgObject->shininess = 0.0;
if ( DlgObject->shininess > 1.0 ) DlgObject->shininess = 1.0;
if ( SendDlgItemMessage(hwndDlg, ID_FRONTFILL, BM_GETCHECK, 0, 0) == BST_CHECKED )
DlgObject->frontFill = true;
else DlgObject->frontFill = false;
if ( SendDlgItemMessage(hwndDlg, ID_BACKFILL, BM_GETCHECK, 0, 0) == BST_CHECKED )
DlgObject->backFill = true;
else DlgObject->backFill = false;
EndDialog(hwndDlg, 1);
return TRUE;
case IDCANCEL:
EndDialog(hwndDlg, 0);
return TRUE;
}
}
return FALSE;
}
void SceneAttributes( HWND list ) // add listview selections to CurrScene and display them
{
VRMLObjects *object_list;
VRMLObject *object, *todo_object;
int n;
char name[MAX_CONTOUR_NAME];
LV_ITEM lvi;
HCURSOR cur;
object_list = new VRMLObjects(); // create a list of objects to modify
DlgObject = new VRMLObject();
lvi.iItem = SendMessage(list, LVM_GETNEXTITEM, -1, (LPARAM)(LVNI_ALL | LVNI_SELECTED) );
while ( lvi.iItem >= 0 )
{ // an item was selected, retrieve object name
lvi.mask = LVIF_TEXT;
lvi.iSubItem = 0; lvi.pszText = name; lvi.cchTextMax = MAX_CONTOUR_NAME;
SendMessage(list, LVM_GETITEM, 0, (LPARAM)(&lvi));
if ( CurrScene )
if ( CurrScene->objects )
{
object = CurrScene->objects->Match( name ); // only modify objects in scene
if ( object )
{
todo_object = new VRMLObject();
strcpy(todo_object->name,object->name); // copy name of object to be modified
DlgObject->diffuseColor = object->diffuseColor;
DlgObject->emissiveColor = object->emissiveColor;
DlgObject->specularColor = object->specularColor;
DlgObject->ambientIntensity = object->ambientIntensity;
DlgObject->transparency = object->transparency;
DlgObject->shininess = object->shininess;
DlgObject->frontFill = object->frontFill;
DlgObject->backFill = object->backFill;
object_list->Add( todo_object );
}
}
lvi.iItem = SendMessage(list, LVM_GETNEXTITEM, lvi.iItem, (LPARAM)(LVNI_ALL | LVNI_SELECTED) );
}
n = object_list->Number();
if ( n > 0 ) // have at least one object to modify
{
sprintf(InputDlgName,"Changing %d scene objects to...",n);
if ( DialogBox( appInstance, "SceneDlg", list, (DLGPROC)SceneDlgProc ) == IDOK )
{
cur = SetCursor( LoadCursor( 0, IDC_WAIT ) );// show hourglass, file access could be slow
object = object_list->first;
while ( object )
{ // find this object name in scene objects
todo_object = CurrScene->objects->Match( object->name );
todo_object->diffuseColor = DlgObject->diffuseColor;
todo_object->emissiveColor = DlgObject->emissiveColor;
todo_object->specularColor = DlgObject->specularColor;
todo_object->ambientIntensity = DlgObject->ambientIntensity;
todo_object->transparency = DlgObject->transparency;
todo_object->shininess = DlgObject->shininess;
todo_object->frontFill = DlgObject->frontFill;
todo_object->backFill = DlgObject->backFill;
object = object->next;
}
if ( IsWindow( openGLWindow ) )
{
CurrScene->Compile(); // recompile scene to OpenGL
InvalidateRect(openGLWindow,NULL,FALSE);
}
SetCursor( cur );
} // restore cursor
} // end if
delete object_list; // free memory
delete DlgObject;
}
void SimplifyObjects( HWND list ) // simplify all traces of selected objects
{
VRMLObjects *object_list;
VRMLObject *object, *sobject;
Section *section;
Transform *transform;
Contour *contour;
LV_ITEM lvi;
HCURSOR cur;
int num_selected, first_sect, last_sect, sectnum;
bool changed, simplified;
char name[MAX_CONTOUR_NAME], warntxt[100];
num_selected = SendMessage(list, LVM_GETSELECTEDCOUNT, 0, 0 );
if ( num_selected )
{
sprintf(warntxt,"All unsimplified traces of %d objects will be\npermanently altered! Continue?",num_selected);
if ( MessageBox(list,warntxt,"WARNING!",MB_YESNO|MB_DEFBUTTON2|MB_ICONEXCLAMATION) == IDYES )
{