Normand Briere
2019-07-19 e79247ef52a0bbb3864d46bb1e2c716005b3ecf3
GroupEditor.java
....@@ -60,6 +60,12 @@
6060 this.copy = this.group = group;
6161 //selectees = this.group.selectees;
6262
63
+ if (copy.versions == null)
64
+ {
65
+ copy.versions = new byte[100][];
66
+ copy.versionindex = -1;
67
+ }
68
+
6369 if(ui)
6470 SetupUI(objEditor);
6571 }
....@@ -74,6 +80,12 @@
7480 this.copy = this.group = copy;
7581 //selectees = this.group.selectees;
7682
83
+ if (copy.versions == null)
84
+ {
85
+ copy.versions = new byte[100][];
86
+ copy.versionindex = -1;
87
+ }
88
+
7789 SetupMenu2(this); //objEditor);
7890 SetupUI2(objEditor);
7991 objEditor.SetupUI(true);
....@@ -84,6 +96,10 @@
8496
8597 void CloneSelection(boolean supports)
8698 {
99
+ if (Globals.REPLACEONMAKE)
100
+ Save();
101
+ boolean keep = Globals.REPLACEONMAKE;
102
+ Globals.REPLACEONMAKE = false;
87103 // Object3D keep = GrafreeD.clipboard;
88104 //Object3D obj;
89105 for (int i=0; i<group.selection.size(); i++)// Enumeration e = group.selection.elements(); e.hasMoreElements();)
....@@ -94,6 +110,7 @@
94110
95111 makeSomething(clone, i==group.selection.size()-1);
96112 }
113
+ Globals.REPLACEONMAKE = keep;
97114 }
98115
99116 void CloneClipboard(boolean supports)
....@@ -189,8 +206,8 @@
189206 // pasteExpandItem = menu.add(new MenuItem("Paste expand"));
190207 // pasteExpandItem.addActionListener(this);
191208 menu.add("-");
192
- clearItem = menu.add(new MenuItem("Clear"));
193
- clearItem.addActionListener(this);
209
+ deleteItem = menu.add(new MenuItem("Delete"));
210
+ deleteItem.addActionListener(this);
194211
195212 if (Globals.ADVANCED)
196213 {
....@@ -220,7 +237,7 @@
220237 // toggleSwitchItem.addItemListener(this);
221238 // toggleSwitchItem.setState(CameraPane.SWITCH);
222239
223
- cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Handles"));
240
+ cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Show Handles"));
224241 toggleHandleItem.addItemListener(this);
225242 toggleHandleItem.setState(CameraPane.HANDLES);
226243
....@@ -380,13 +397,14 @@
380397 shadowYItem.addActionListener(this);
381398 shadowZItem = menu.add(new MenuItem("Shadow Blue"));
382399 shadowZItem.addActionListener(this);
400
+ attributeItem = menu.add(new MenuItem("Attribute"));
401
+ attributeItem.addActionListener(this);
402
+
383403 if (Globals.ADVANCED)
384404 {
385405 menu.add("-");
386406 linkerItem = menu.add(new MenuItem("Linker"));
387407 linkerItem.addActionListener(this);
388
- attributeItem = menu.add(new MenuItem("Attribute"));
389
- attributeItem.addActionListener(this);
390408 templateItem = menu.add(new MenuItem("Template"));
391409 templateItem.addActionListener(this);
392410 pointflowItem = menu.add(new MenuItem("Point Flow"));
....@@ -415,7 +433,7 @@
415433 genNormalsMESHItem.addActionListener(this);
416434 if (Globals.ADVANCED)
417435 {
418
- genNormalsMINEItem = menu.add(new MenuItem("My Normals"));
436
+ genNormalsMINEItem = menu.add(new MenuItem("Stitch Normals"));
419437 genNormalsMINEItem.addActionListener(this);
420438 }
421439 stripifyItem = menu.add(new MenuItem("Stripify"));
....@@ -538,6 +556,7 @@
538556 buildToolsMenu(menu);
539557 }
540558
559
+
541560 void SetupUI2(ObjEditor oe)
542561 {
543562 // June 2019
....@@ -582,7 +601,7 @@
582601 */
583602 cGridBag copyOptionsPanel = new cGridBag();
584603
585
- copyOptionsPanel.preferredHeight = 2;
604
+ copyOptionsPanel.preferredHeight = 1;
586605
587606 //this.AddOptions(oe.toolbarPanel, oe.aConstraints);
588607
....@@ -590,48 +609,66 @@
590609 //minButton.setToolTipText("Minimize window");
591610 //minButton.addActionListener(this);
592611
593
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
594
- maxButton.setToolTipText("Maximize window");
595
- maxButton.addActionListener(this);
612
+ if (Globals.ADVANCED)
613
+ {
614
+ oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
615
+ maxButton.setToolTipText("Maximize window");
616
+ maxButton.addActionListener(this);
617
+ }
596618
597619 oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
598620 fullButton.setToolTipText("Full-screen window");
599621 fullButton.addActionListener(this);
600622
623
+ oe.toolbarPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
624
+ screenfitButton.setToolTipText("Screen fit");
625
+ screenfitButton.addActionListener(this);
626
+
601627 oe.toolbarPanel.add(restoreCameraButton = GetButton("icons/eye.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
602628 restoreCameraButton.setToolTipText("Restore viewpoint");
603629 restoreCameraButton.addActionListener(this);
604630
631
+ copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
632
+ saveButton.setToolTipText("New version");
633
+ saveButton.addActionListener(this);
634
+
605635 copyOptionsPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
606
- undoButton.setToolTipText("Undo changes");
636
+ undoButton.setToolTipText("Previous version");
607637 undoButton.addActionListener(this);
638
+ undoButton.setEnabled(false);
639
+
640
+ cGridBag updown = new cGridBag().setVertical(true);
641
+ updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
642
+ restoreButton.setToolTipText("Restore current");
643
+ restoreButton.addActionListener(this);
644
+ restoreButton.setEnabled(false);
645
+
646
+ updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
647
+ replaceButton.setToolTipText("Replace current");
648
+ replaceButton.addActionListener(this);
649
+ replaceButton.setEnabled(false);
650
+
651
+ copyOptionsPanel.add(updown);
608652
609653 copyOptionsPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
610
- redoButton.setToolTipText("Redo changes");
654
+ redoButton.setToolTipText("Next version");
611655 redoButton.addActionListener(this);
656
+ redoButton.setEnabled(false);
612657
613
- copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
614
- saveButton.setToolTipText("Save changes");
615
- saveButton.addActionListener(this);
616
-
617
- copyOptionsPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
658
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
618659 liveCB.setToolTipText("Enable animation");
619660 liveCB.addItemListener(this);
620661
621
- copyOptionsPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
662
+ oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
622663 oneStepButton.setToolTipText("Animate one step forward");
623664 oneStepButton.addActionListener(this);
624665
625
- copyOptionsPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
666
+ oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
626667 fastCB.setToolTipText("Fast mode");
627668 fastCB.addItemListener(this);
628669
629670 //oe.toolboxPanel.Return();
630671
631
- copyOptionsPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
632
- screenfitButton.setToolTipText("Screen fit");
633
- screenfitButton.addActionListener(this);
634
-
635672 // copyOptionsPanel.add(trackCB = GetToggleButton("icons/track.png", CameraPane.TRACK)); //, oe.aConstraints);
636673 // trackCB.setToolTipText("Enable tracking");
637674 // trackCB.addItemListener(this);
....@@ -648,27 +685,28 @@
648685
649686 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
650687
651
- oe.toolbarPanel.add(twoButton = new cButton("|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
652
- twoButton.setToolTipText("Show center view only");
653
- twoButton.addActionListener(this);
654
- this.fullscreenLayout = twoButton;
655
-
656688 oe.toolbarPanel.add(fourButton = new cButton("-||", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
657689 fourButton.addActionListener(this);
658690 fourButton.setToolTipText("Show left panel only");
691
+
692
+ oe.toolbarPanel.add(twoButton = new cButton("|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
693
+ twoButton.setToolTipText("Show right view only");
694
+ twoButton.addActionListener(this);
695
+ this.fullscreenLayout = twoButton;
696
+
659697 oe.toolbarPanel.add(sixButton = new cButton("-|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
660
- sixButton.setToolTipText("2-column layout left");
698
+ sixButton.setToolTipText("Show left and right");
661699 sixButton.addActionListener(this);
662
- oe.toolbarPanel.add(threeButton = new cButton("|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
663
- threeButton.setToolTipText("2-column layout right");
664
- threeButton.addActionListener(this);
665
- oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
666
- sevenButton.setToolTipText("3-column layout");
667
- sevenButton.addActionListener(this);
700
+// oe.toolbarPanel.add(threeButton = new cButton("|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
701
+// threeButton.setToolTipText("2-column layout right");
702
+// threeButton.addActionListener(this);
703
+// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
704
+// sevenButton.setToolTipText("3-column layout");
705
+// sevenButton.addActionListener(this);
668706 //
669707
670
- oe.toolbarPanel.add(rootButton = GetButton("icons/write.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
671
- rootButton.setToolTipText("Edit selection in new tab");
708
+ oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
709
+ rootButton.setToolTipText("Open selection in new tab");
672710 rootButton.addActionListener(this);
673711
674712 oe.toolbarPanel.add(closeButton = GetButton("icons/close-icon.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -724,7 +762,7 @@
724762 compositeButton.addActionListener(this);
725763
726764 oe.toolboxPanel.add(switchButton = GetButton("icons/switch.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
727
- switchButton.setToolTipText("Create switch");
765
+ switchButton.setToolTipText("Create item switcher");
728766 switchButton.addActionListener(this);
729767
730768 oe.toolboxPanel.add(loopButton = GetButton("icons/loop.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -743,17 +781,29 @@
743781 lightButton.setToolTipText("Create light");
744782 lightButton.addActionListener(this);
745783
784
+ for (int i=6; --i>=0;)
785
+ {
786
+ oe.toolboxPanel.Return();
787
+ oe.toolboxPanel.add(new cGridBag());
788
+ oe.toolboxPanel.add(new cGridBag());
789
+ oe.toolboxPanel.add(new cGridBag());
790
+ oe.toolboxPanel.add(new cGridBag());
791
+ oe.toolboxPanel.add(new cGridBag());
792
+ oe.toolboxPanel.add(new cGridBag());
793
+ oe.toolboxPanel.add(new cGridBag());
794
+ }
795
+
746796 // EDIT panel
747
- editCommandsPanel.add(editButton = new cButton("+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
748
- editButton.setToolTipText("Edit selection");
797
+ editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
798
+ editButton.setToolTipText("Pin selection controls");
749799 editButton.addActionListener(this);
750800
751
- editCommandsPanel.add(uneditButton = new cButton("-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
752
- uneditButton.setToolTipText("Unedit selection");
801
+ editCommandsPanel.add(uneditButton = GetButton("icons/remove.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
802
+ uneditButton.setToolTipText("Remove selection controls");
753803 uneditButton.addActionListener(this);
754804
755805 editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
756
- allParamsButton.setToolTipText("Edit all params");
806
+ allParamsButton.setToolTipText("Show all controle");
757807 allParamsButton.addActionListener(this);
758808
759809 editCommandsPanel.add(clearPanelButton = new cButton("C", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -770,6 +820,7 @@
770820
771821 editCommandsPanel.preferredHeight = 1;
772822
823
+ SetPinStates(false);
773824 // oe.treePanel.add(commandsPanel);
774825 // oe.treePanel.Return();
775826
....@@ -796,6 +847,9 @@
796847
797848 oe.treePanel.add(copyOptionsPanel);
798849 oe.treePanel.Return();
850
+ cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
851
+ versionSlider = (cNumberSlider)sliderPane.getComponent(1);
852
+ sliderPane.preferredHeight = 1;
799853
800854 // mainPanel.setDividerLocation(0.5); //1.0);
801855 // mainPanel.setResizeWeight(0.5);
....@@ -818,7 +872,7 @@
818872 dgr.addDragGestureListener(this);
819873 }catch(Exception e) {}
820874 */
821
- radio.layout = sevenButton;
875
+ radio.layout = sixButton; // sevenButton;
822876 oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
823877 }
824878
....@@ -843,14 +897,18 @@
843897 boxCB.addItemListener(this);
844898
845899 panel.add(zoomBoxCB = new cCheckBox("Zoom", CameraPane.ZOOMBOXMODE)); //, constraints);
846
- zoomBoxCB.setToolTipText("Display bounding boxes when moving the wheel");
900
+ zoomBoxCB.setToolTipText("Display only for wheel");
847901 zoomBoxCB.addItemListener(this);
848902
849903 if (true) // Globals.ADVANCED)
850904 {
851
- panel.add(supportCB = new cCheckBox("Support", CameraPane.SUPPORT)); //, constraints);
852
- supportCB.setToolTipText("Enable rigging");
853
- supportCB.addItemListener(this);
905
+// panel.add(supportCB = new cCheckBox("Support", CameraPane.SUPPORT)); //, constraints);
906
+// supportCB.setToolTipText("Enable rigging");
907
+// supportCB.addItemListener(this);
908
+
909
+ panel.add(freezeCB = new cCheckBox("Freeze", Globals.FREEZEONMOVE)); //, constraints);
910
+ freezeCB.setToolTipText("Fast moving camera");
911
+ freezeCB.addItemListener(this);
854912
855913 // panel.add(localCB = new cCheckBox("Local", CameraPane.LOCALTRANSFORM), constraints);
856914 // localCB.addItemListener(this);
....@@ -905,7 +963,7 @@
905963 oeilCB.addItemListener(this);
906964
907965 panel.add(shadowCB = new cCheckBox("Shadow", Globals.COMPUTESHADOWWHENLIVE)); //, constraints);
908
- shadowCB.setToolTipText("Compute shadows when live");
966
+ shadowCB.setToolTipText("When live compute shadows");
909967 shadowCB.addItemListener(this);
910968
911969 panel.Return();
....@@ -914,12 +972,12 @@
914972 toggleTextureCB.addItemListener(this);
915973
916974 panel.add(toggleSwitchCB = new cCheckBox("Switch", CameraPane.SWITCH)); //, constraints);
917
- toggleSwitchCB.setToolTipText("Use switch");
975
+ toggleSwitchCB.setToolTipText("Choose a single item");
918976 toggleSwitchCB.addItemListener(this);
919977
920
- panel.add(autosaveCB = new cCheckBox("Auto-save", Globals.SAVEONMAKE)); //, constraints);
921
- autosaveCB.setToolTipText("Auto-save on structure change");
922
- autosaveCB.addItemListener(this);
978
+ panel.add(autokeepCB = new cCheckBox("Auto-replace", Globals.REPLACEONMAKE)); //, constraints);
979
+ autokeepCB.setToolTipText("On structure change");
980
+ autokeepCB.addItemListener(this);
923981
924982 panel.Return();
925983 if (Globals.ADVANCED)
....@@ -948,7 +1006,7 @@
9481006 {
9491007 cRadio radioButton = new cRadio(obj.name);
9501008
951
- // Patch to avoid bug with transparency.
1009
+ // June 2019. Patch to avoid bug with transparency.
9521010 radioButton.hadMaterial = obj.material != null;
9531011 if (!radioButton.hadMaterial)
9541012 {
....@@ -956,7 +1014,7 @@
9561014 }
9571015
9581016 radioButton.SetObject(obj);
959
- radioButton.layout = sevenButton;
1017
+ radioButton.layout = sixButton; // sevenButton;
9601018 radioButton.SetCamera(cameraView.renderCamera, false);
9611019 radioButton.addActionListener(this);
9621020 radioPanel.add(radioButton);
....@@ -985,6 +1043,7 @@
9851043 cCheckBox slowCB;
9861044 cCheckBox boxCB;
9871045 cCheckBox zoomBoxCB;
1046
+ cCheckBox freezeCB;
9881047 //cToggleButton trackCB;
9891048 cCheckBox trackCB;
9901049 cCheckBox smoothfocusCB;
....@@ -995,7 +1054,7 @@
9951054
9961055 cCheckBox oeilCB;
9971056 cCheckBox shadowCB;
998
- cCheckBox autosaveCB;
1057
+ cCheckBox autokeepCB;
9991058 cCheckBox lookAtCB;
10001059
10011060 // static int COLOR = 1;
....@@ -1103,9 +1162,13 @@
11031162 {
11041163 Globals.COMPUTESHADOWWHENLIVE ^= true;
11051164 }
1106
- else if(e.getSource() == autosaveCB)
1165
+ else if(e.getSource() == freezeCB)
11071166 {
1108
- Globals.SAVEONMAKE ^= true;
1167
+ Globals.FREEZEONMOVE ^= true;
1168
+ }
1169
+ else if(e.getSource() == autokeepCB)
1170
+ {
1171
+ Globals.REPLACEONMAKE ^= true;
11091172 }
11101173 else if(e.getSource() == lookAtCB)
11111174 {
....@@ -1187,8 +1250,6 @@
11871250 }
11881251 }
11891252
1190
- String string = (String) object;
1191
-
11921253 System.out.println("Transfer = " + object + "; drop : " + target);
11931254 // if( object instanceof java.io.File[])
11941255 // {
....@@ -1196,6 +1257,8 @@
11961257 // objEditor.DropFile((java.io.File[]) object, true);
11971258 // return;
11981259 // }
1260
+
1261
+ String string = object.toString();
11991262
12001263 // File path for Mac and Windows
12011264 if (string.charAt(0) == '/' || string.charAt(1) == ':')
....@@ -1445,6 +1508,9 @@
14451508 animationItem.addItemListener(this);
14461509 animationItem.setState(Globals.ANIMATION);
14471510
1511
+ menu.add(archiveItem = new MenuItem("Archive3D..."));
1512
+ archiveItem.addActionListener(this);
1513
+
14481514 menu.add("-");
14491515 parseverticesItem = menu.add(new MenuItem("Multiplicity"));
14501516 parseverticesItem.addActionListener(this);
....@@ -1457,6 +1523,8 @@
14571523 reduce34MorphItem = menu.add(new MenuItem("Reduce Morphs (34)"));
14581524 reduce34MorphItem.addActionListener(this);
14591525 menu.add("-");
1526
+ menu.add(memoryItem = new MenuItem("Memory Usage"));
1527
+ memoryItem.addActionListener(this);
14601528 menu.add(computeAOItem = new MenuItem("Compute AO"));
14611529 computeAOItem.addActionListener(this);
14621530
....@@ -1465,8 +1533,6 @@
14651533 mirrorItem = menu.add(new MenuItem("Mirror Poses"));
14661534 mirrorItem.addActionListener(this);
14671535 menu.add("-");
1468
- menu.add(memoryItem = new MenuItem("Memory Usage"));
1469
- memoryItem.addActionListener(this);
14701536 menu.add(analyzeItem = new MenuItem("Analyze"));
14711537 analyzeItem.addActionListener(this);
14721538 menu.add(dumpItem = new MenuItem("Print"));
....@@ -1614,6 +1680,30 @@
16141680
16151681 makeSomething(shadow);
16161682 }
1683
+
1684
+ private void ClearUnpinned()
1685
+ {
1686
+ //for (Object3D obj : listUI)
1687
+ for (int i=listUI.size(); --i>=0;)
1688
+ {
1689
+ Object3D obj = listUI.elementAt(i);
1690
+ if (!obj.pinned)
1691
+ {
1692
+ obj.CloseUI();
1693
+ listUI.remove(i);
1694
+ }
1695
+ }
1696
+ }
1697
+
1698
+ private void EditElement(Object3D elem, boolean newWindow)
1699
+ {
1700
+ // if (!(elem instanceof Composite))
1701
+ // newWindow = false;
1702
+ listUI.add(elem);
1703
+ elem.openEditWindow(this, newWindow); //, false);
1704
+ System.out.println("edit : " + elem);
1705
+ elem.editWindow.refreshContents(true); // ? new
1706
+ }
16171707
16181708 /**
16191709 * applyExample
....@@ -2093,25 +2183,25 @@
20932183 Composite csg = new GroupLeaf();
20942184 csg.count = 5;
20952185 group(csg);
2096
- Composite child = new cGroup();
2186
+ Composite child = new cGroup("Branch");
20972187 csg.addChild(child);
20982188 child.addChild(csg);
20992189 } else
21002190 if (source == doubleItem)
21012191 {
2102
- Composite csg = new GroupLeaf();
2192
+ Composite csg = new GroupLeaf("Fork");
21032193 csg.count = 5;
21042194 group(csg);
2105
- Composite child = new cGroup();
2195
+ Composite child = new cGroup("Branch A");
21062196 csg.addChild(child);
21072197 child.addChild(csg);
2108
- child = new cGroup();
2198
+ child = new cGroup("Branch B");
21092199 csg.addChild(child);
21102200 child.addChild(csg);
21112201 } else
21122202 if (source == tripleItem)
21132203 {
2114
- Composite csg = new GroupLeaf();
2204
+ Composite csg = new GroupLeaf("Trident");
21152205 csg.count = 4;
21162206 group(csg);
21172207 Composite child = new cGroup();
....@@ -2175,15 +2265,31 @@
21752265 } else
21762266 if (source == undoButton)
21772267 {
2268
+ // Go to previous version
2269
+ //if (!Undo())
2270
+ //java.awt.Toolkit.getDefaultToolkit().beep();
21782271 Undo();
2272
+ } else
2273
+ if (source == restoreButton)
2274
+ {
2275
+ // Restore current version
2276
+ Restore();
2277
+ } else
2278
+ if (source == replaceButton)
2279
+ {
2280
+ // Overwrite current version
2281
+ Replace();
21792282 } else
21802283 if (source == redoButton)
21812284 {
2285
+ // Go to next version
21822286 Redo();
21832287 } else
21842288 if (source == saveButton)
21852289 {
2186
- Save();
2290
+ // Save a new version
2291
+ if (!Save(true))
2292
+ java.awt.Toolkit.getDefaultToolkit().beep();
21872293 } else
21882294 if (source == oneStepButton)
21892295 {
....@@ -2192,17 +2298,14 @@
21922298 } else
21932299 if (source == screenfitButton)
21942300 {
2195
- //Reload(lastConverter, lastFilename, true);
21962301 ScreenFit();
21972302 } else
21982303 if (source == screenfitpointButton)
21992304 {
2200
- //Reload(lastConverter, lastFilename, true);
22012305 ScreenFitPoint();
22022306 } else
22032307 if (source == snapobjectButton)
22042308 {
2205
- //Reload(lastConverter, lastFilename, true);
22062309 SnapObject();
22072310 } else
22082311 // if (event.getSource() == recompileButton)
....@@ -2566,7 +2669,7 @@
25662669 {
25672670 StepAll();
25682671 } else
2569
- if (source == clearItem) // || event.getSource() == clearButton)
2672
+ if (source == deleteItem) // || event.getSource() == clearButton)
25702673 {
25712674 //int indices[] = jList.getSelectedIndices();
25722675 //for (int i = indices.length - 1; i >= 0; i--)
....@@ -2726,15 +2829,28 @@
27262829 } else
27272830 if (source == ungroupItem || source == ungroupButton)
27282831 {
2729
- //ungroup();
2832
+ boolean hasRoot = false;
2833
+
27302834 for (int i=0; i<group.selection.size(); i++)
27312835 {
2732
- Ungroup(group.selection.get(i));
2836
+ if (group.selection.get(i) == group)
2837
+ {
2838
+ hasRoot = true;
2839
+ break;
2840
+ }
27332841 }
27342842
2735
- ClearSelection(false);
2736
-
2737
- refreshContents();
2843
+ if (!hasRoot)
2844
+ {
2845
+ for (int i=0; i<group.selection.size(); i++)
2846
+ {
2847
+ Ungroup(group.selection.get(i));
2848
+ }
2849
+
2850
+ ClearSelection(false);
2851
+
2852
+ refreshContents();
2853
+ }
27382854 } else
27392855 if (source == genUVItem)
27402856 {
....@@ -3326,6 +3442,12 @@
33263442 } else
33273443 if (source == editItem || source == editButton)
33283444 {
3445
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
3446
+ {
3447
+ Object3D child = (Object3D)e.nextElement();
3448
+ child.pinned = true;
3449
+ }
3450
+
33293451 EditSelection(false);
33303452 } else
33313453 if (source == uneditButton)
....@@ -3335,6 +3457,7 @@
33353457 Object3D child = (Object3D)e.nextElement();
33363458 if(child.editWindow != null)
33373459 objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
3460
+ child.pinned = false;
33383461 child.CloseUI();
33393462 listUI.remove(child);
33403463
....@@ -3351,6 +3474,7 @@
33513474 //copy.ClearUI();
33523475 for (Object3D obj : listUI)
33533476 {
3477
+ obj.pinned = false;
33543478 obj.CloseUI();
33553479 }
33563480 listUI.clear();
....@@ -3360,7 +3484,7 @@
33603484 {
33613485 assert(copy == group);
33623486
3363
- objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
3487
+ //objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
33643488
33653489 for (Object3D obj : listUI)
33663490 {
....@@ -3409,6 +3533,9 @@
34093533 }
34103534
34113535 copy = group;
3536
+
3537
+ SetUndoStates();
3538
+
34123539 //Globals.theRenderer.object = group;
34133540 if(!useclient)
34143541 {
....@@ -3435,6 +3562,13 @@
34353562 currentLayout = sevenButton;
34363563 */
34373564 radio.layout.doClick();
3565
+
3566
+ ClearUnpinned();
3567
+ //Grafreed.Assert(group != null);
3568
+ //Grafreed.Assert(group.selection != null);
3569
+ SetPinStates(group.selection == null || group.selection.size() > 0);
3570
+ if (group.selection == null || group.selection.size() == 1)
3571
+ EditSelection(false);
34383572 keepparent = group.parent;
34393573 // PARENT = NULL or not???
34403574 //group.parent = null; // ROOT
....@@ -4502,12 +4636,14 @@
45024636 // }
45034637 // }
45044638
4505
- static boolean allparams = true;
4506
-
4507
- static Vector<Object3D> listUI = new Vector<Object3D>();
4508
-
45094639 void EditSelection(boolean newWindow)
45104640 {
4641
+ if (group.selection == null)
4642
+ {
4643
+ EditElement(group, newWindow); // ? new
4644
+ return;
4645
+ }
4646
+
45114647 // aConstraints.gridy = 0;
45124648 for (int i=0; i<group.selection.size(); i++)
45134649 {
....@@ -4518,12 +4654,7 @@
45184654 Object3D elem = (Object3D)group.selection.elementAt(i);
45194655 if(elem != group || !newWindow)
45204656 {
4521
- // if (!(elem instanceof Composite))
4522
- // newWindow = false;
4523
- listUI.add(elem);
4524
- elem.openEditWindow(this, newWindow); //, false);
4525
- System.out.println("edit : " + elem);
4526
- elem.editWindow.refreshContents(true); // ? new
4657
+ EditElement(elem, newWindow); // ? new
45274658 }
45284659 }
45294660 }
....@@ -4598,7 +4729,8 @@
45984729 //new Exception().printStackTrace();
45994730
46004731 freezemodel = true;
4601
-
4732
+ ClearUnpinned();
4733
+
46024734 /**/
46034735 //switch (event.id)
46044736 {
....@@ -4631,7 +4763,7 @@
46314763 if (tps != null && tps.length > 0 && tps[0].getLastPathComponent() instanceof Camera)
46324764 // a camera
46334765 {
4634
- if (tps[0].getLastPathComponent() != Globals.theRenderer.LightCamera())
4766
+ if (tps[0].getLastPathComponent() != Globals.theRenderer.LightCamera()) // Crash the camera because of invalid lightspace
46354767 {
46364768 CameraPane.camerachangeframe = 0; // don't refuse it
46374769 Globals.theRenderer.SetCamera((Camera) tps[0].getLastPathComponent());
....@@ -4640,6 +4772,13 @@
46404772 // Globals.theRenderer.eyeCamera = Globals.theRenderer.manipCamera;
46414773 }
46424774
4775
+ if (tps != null && tps.length == 1)
4776
+ {
4777
+ EditSelection(false);
4778
+ }
4779
+
4780
+ SetPinStates(tps != null && tps.length > 0);
4781
+
46434782 refreshContents();
46444783 //return true;
46454784 }
....@@ -4649,10 +4788,18 @@
46494788 freezemodel = false;
46504789 }
46514790
4791
+ void SetPinStates(boolean enabled)
4792
+ {
4793
+ editButton.setEnabled(enabled);
4794
+ uneditButton.setEnabled(enabled);
4795
+ unselectButton.setEnabled(enabled);
4796
+ flashSelectionButton.setEnabled(enabled);
4797
+ }
4798
+
46524799 void refreshContents(boolean cp)
46534800 {
46544801 if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Info"))
4655
- if (!Globals.MOUSEDRAGGED) // && !Globals.TIMERRUNNING)
4802
+ if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
46564803 {
46574804 objEditor.ClearInfo(); // .GetMaterial());
46584805
....@@ -4751,8 +4898,8 @@
47514898
47524899 if (cut)
47534900 {
4754
- if (Globals.SAVEONMAKE)
4755
- Save();
4901
+// if (Globals.SAVEONMAKE) // Moved to the clipboard, no need to save.
4902
+// Save();
47564903 //int indices[] = jList.getSelectedIndices();
47574904 //for (int i = indices.length - 1; i >= 0; i--)
47584905 //jList.remove(indices[i]);
....@@ -4855,6 +5002,10 @@
48555002
48565003 void paste(boolean expand)
48575004 {
5005
+ if (Globals.REPLACEONMAKE)
5006
+ Save();
5007
+ boolean keep = Globals.REPLACEONMAKE;
5008
+ Globals.REPLACEONMAKE = false;
48585009 // if (GrafreeD.clipboard == null)
48595010 // return;
48605011 boolean first = true;
....@@ -4914,6 +5065,7 @@
49145065 Grafreed.clipboard.get(0).parent = keepparent;
49155066 }
49165067
5068
+ Globals.REPLACEONMAKE = keep;
49175069 ResetModel();
49185070 refreshContents();
49195071 }
....@@ -5049,6 +5201,10 @@
50495201
50505202 void group(Object3D csg, boolean grab)
50515203 {
5204
+ if (Globals.REPLACEONMAKE)
5205
+ Save();
5206
+ boolean keep = Globals.REPLACEONMAKE;
5207
+ Globals.REPLACEONMAKE = false;
50525208 if (//false) // why??
50535209 !group.selection.isEmpty())
50545210 {
....@@ -5162,10 +5318,15 @@
51625318 //node.add(csg);
51635319 //makeSomething(node);
51645320 makeSomething(csg);
5321
+ Globals.REPLACEONMAKE = keep;
51655322 }
51665323
51675324 void Ungroup(Object3D g)
51685325 {
5326
+ if (Globals.REPLACEONMAKE)
5327
+ Save();
5328
+ boolean keep = Globals.REPLACEONMAKE;
5329
+ Globals.REPLACEONMAKE = false;
51695330 if (g instanceof HiddenObject)
51705331 {
51715332 HiddenObject h = (HiddenObject) g;
....@@ -5182,6 +5343,7 @@
51825343 objEditor.makeSomething(g.get(i), false);
51835344 }
51845345 }
5346
+ Globals.REPLACEONMAKE = keep;
51855347 }
51865348
51875349 void ungroup()
....@@ -5472,11 +5634,6 @@
54725634
54735635 cButton restoreCameraButton;
54745636
5475
- cButton minButton;
5476
- cButton maxButton;
5477
- cButton fullButton;
5478
- cButton undoButton;
5479
- cButton redoButton;
54805637 cButton saveButton;
54815638 cButton oneStepButton;
54825639
....@@ -5550,7 +5707,7 @@
55505707 private MenuItem pasteLinkItem;
55515708 private MenuItem pasteCloneItem;
55525709 private MenuItem pasteExpandItem;
5553
- private MenuItem clearItem;
5710
+ private MenuItem deleteItem;
55545711 private MenuItem clearAllItem;
55555712 private MenuItem genUVItem;
55565713 private MenuItem genNormalsMESHItem;