Normand Briere
2019-07-18 d7a17c35c443e2cb6c09eaa3cfeaf590a571faa1
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)
....@@ -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"));
....@@ -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,50 +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);
608638 undoButton.setEnabled(false);
609639
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);
652
+
610653 copyOptionsPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
611
- redoButton.setToolTipText("Redo changes");
654
+ redoButton.setToolTipText("Next version");
612655 redoButton.addActionListener(this);
613656 redoButton.setEnabled(false);
614657
615
- copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
616
- saveButton.setToolTipText("Save changes");
617
- saveButton.addActionListener(this);
618
-
619
- copyOptionsPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
658
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
620659 liveCB.setToolTipText("Enable animation");
621660 liveCB.addItemListener(this);
622661
623
- copyOptionsPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
662
+ oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
624663 oneStepButton.setToolTipText("Animate one step forward");
625664 oneStepButton.addActionListener(this);
626665
627
- copyOptionsPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
666
+ oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
628667 fastCB.setToolTipText("Fast mode");
629668 fastCB.addItemListener(this);
630669
631670 //oe.toolboxPanel.Return();
632671
633
- copyOptionsPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
634
- screenfitButton.setToolTipText("Screen fit");
635
- screenfitButton.addActionListener(this);
636
-
637672 // copyOptionsPanel.add(trackCB = GetToggleButton("icons/track.png", CameraPane.TRACK)); //, oe.aConstraints);
638673 // trackCB.setToolTipText("Enable tracking");
639674 // trackCB.addItemListener(this);
....@@ -726,7 +761,7 @@
726761 compositeButton.addActionListener(this);
727762
728763 oe.toolboxPanel.add(switchButton = GetButton("icons/switch.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
729
- switchButton.setToolTipText("Create switch");
764
+ switchButton.setToolTipText("Create item switcher");
730765 switchButton.addActionListener(this);
731766
732767 oe.toolboxPanel.add(loopButton = GetButton("icons/loop.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -811,6 +846,9 @@
811846
812847 oe.treePanel.add(copyOptionsPanel);
813848 oe.treePanel.Return();
849
+ cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
850
+ versionSlider = (cNumberSlider)sliderPane.getComponent(1);
851
+ sliderPane.preferredHeight = 1;
814852
815853 // mainPanel.setDividerLocation(0.5); //1.0);
816854 // mainPanel.setResizeWeight(0.5);
....@@ -863,9 +901,13 @@
863901
864902 if (true) // Globals.ADVANCED)
865903 {
866
- panel.add(supportCB = new cCheckBox("Support", CameraPane.SUPPORT)); //, constraints);
867
- supportCB.setToolTipText("Enable rigging");
868
- supportCB.addItemListener(this);
904
+// panel.add(supportCB = new cCheckBox("Support", CameraPane.SUPPORT)); //, constraints);
905
+// supportCB.setToolTipText("Enable rigging");
906
+// supportCB.addItemListener(this);
907
+
908
+ panel.add(freezeCB = new cCheckBox("Freeze", Globals.FREEZEONMOVE)); //, constraints);
909
+ freezeCB.setToolTipText("Fast moving camera");
910
+ freezeCB.addItemListener(this);
869911
870912 // panel.add(localCB = new cCheckBox("Local", CameraPane.LOCALTRANSFORM), constraints);
871913 // localCB.addItemListener(this);
....@@ -929,12 +971,12 @@
929971 toggleTextureCB.addItemListener(this);
930972
931973 panel.add(toggleSwitchCB = new cCheckBox("Switch", CameraPane.SWITCH)); //, constraints);
932
- toggleSwitchCB.setToolTipText("Use switch");
974
+ toggleSwitchCB.setToolTipText("Choose a single item");
933975 toggleSwitchCB.addItemListener(this);
934976
935
- panel.add(autosaveCB = new cCheckBox("Auto-save", Globals.SAVEONMAKE)); //, constraints);
936
- autosaveCB.setToolTipText("On structure change");
937
- autosaveCB.addItemListener(this);
977
+ panel.add(autokeepCB = new cCheckBox("Auto-replace", Globals.REPLACEONMAKE)); //, constraints);
978
+ autokeepCB.setToolTipText("On structure change");
979
+ autokeepCB.addItemListener(this);
938980
939981 panel.Return();
940982 if (Globals.ADVANCED)
....@@ -963,7 +1005,7 @@
9631005 {
9641006 cRadio radioButton = new cRadio(obj.name);
9651007
966
- // Patch to avoid bug with transparency.
1008
+ // June 2019. Patch to avoid bug with transparency.
9671009 radioButton.hadMaterial = obj.material != null;
9681010 if (!radioButton.hadMaterial)
9691011 {
....@@ -1000,6 +1042,7 @@
10001042 cCheckBox slowCB;
10011043 cCheckBox boxCB;
10021044 cCheckBox zoomBoxCB;
1045
+ cCheckBox freezeCB;
10031046 //cToggleButton trackCB;
10041047 cCheckBox trackCB;
10051048 cCheckBox smoothfocusCB;
....@@ -1010,7 +1053,7 @@
10101053
10111054 cCheckBox oeilCB;
10121055 cCheckBox shadowCB;
1013
- cCheckBox autosaveCB;
1056
+ cCheckBox autokeepCB;
10141057 cCheckBox lookAtCB;
10151058
10161059 // static int COLOR = 1;
....@@ -1118,9 +1161,13 @@
11181161 {
11191162 Globals.COMPUTESHADOWWHENLIVE ^= true;
11201163 }
1121
- else if(e.getSource() == autosaveCB)
1164
+ else if(e.getSource() == freezeCB)
11221165 {
1123
- Globals.SAVEONMAKE ^= true;
1166
+ Globals.FREEZEONMOVE ^= true;
1167
+ }
1168
+ else if(e.getSource() == autokeepCB)
1169
+ {
1170
+ Globals.REPLACEONMAKE ^= true;
11241171 }
11251172 else if(e.getSource() == lookAtCB)
11261173 {
....@@ -1202,8 +1249,6 @@
12021249 }
12031250 }
12041251
1205
- String string = (String) object;
1206
-
12071252 System.out.println("Transfer = " + object + "; drop : " + target);
12081253 // if( object instanceof java.io.File[])
12091254 // {
....@@ -1211,6 +1256,8 @@
12111256 // objEditor.DropFile((java.io.File[]) object, true);
12121257 // return;
12131258 // }
1259
+
1260
+ String string = object.toString();
12141261
12151262 // File path for Mac and Windows
12161263 if (string.charAt(0) == '/' || string.charAt(1) == ':')
....@@ -1460,6 +1507,9 @@
14601507 animationItem.addItemListener(this);
14611508 animationItem.setState(Globals.ANIMATION);
14621509
1510
+ menu.add(archiveItem = new MenuItem("Archive3D..."));
1511
+ archiveItem.addActionListener(this);
1512
+
14631513 menu.add("-");
14641514 parseverticesItem = menu.add(new MenuItem("Multiplicity"));
14651515 parseverticesItem.addActionListener(this);
....@@ -1472,6 +1522,8 @@
14721522 reduce34MorphItem = menu.add(new MenuItem("Reduce Morphs (34)"));
14731523 reduce34MorphItem.addActionListener(this);
14741524 menu.add("-");
1525
+ menu.add(memoryItem = new MenuItem("Memory Usage"));
1526
+ memoryItem.addActionListener(this);
14751527 menu.add(computeAOItem = new MenuItem("Compute AO"));
14761528 computeAOItem.addActionListener(this);
14771529
....@@ -1480,8 +1532,6 @@
14801532 mirrorItem = menu.add(new MenuItem("Mirror Poses"));
14811533 mirrorItem.addActionListener(this);
14821534 menu.add("-");
1483
- menu.add(memoryItem = new MenuItem("Memory Usage"));
1484
- memoryItem.addActionListener(this);
14851535 menu.add(analyzeItem = new MenuItem("Analyze"));
14861536 analyzeItem.addActionListener(this);
14871537 menu.add(dumpItem = new MenuItem("Print"));
....@@ -2122,25 +2172,25 @@
21222172 Composite csg = new GroupLeaf();
21232173 csg.count = 5;
21242174 group(csg);
2125
- Composite child = new cGroup();
2175
+ Composite child = new cGroup("Branch");
21262176 csg.addChild(child);
21272177 child.addChild(csg);
21282178 } else
21292179 if (source == doubleItem)
21302180 {
2131
- Composite csg = new GroupLeaf();
2181
+ Composite csg = new GroupLeaf("Fork");
21322182 csg.count = 5;
21332183 group(csg);
2134
- Composite child = new cGroup();
2184
+ Composite child = new cGroup("Branch A");
21352185 csg.addChild(child);
21362186 child.addChild(csg);
2137
- child = new cGroup();
2187
+ child = new cGroup("Branch B");
21382188 csg.addChild(child);
21392189 child.addChild(csg);
21402190 } else
21412191 if (source == tripleItem)
21422192 {
2143
- Composite csg = new GroupLeaf();
2193
+ Composite csg = new GroupLeaf("Trident");
21442194 csg.count = 4;
21452195 group(csg);
21462196 Composite child = new cGroup();
....@@ -2204,15 +2254,31 @@
22042254 } else
22052255 if (source == undoButton)
22062256 {
2257
+ // Go to previous version
2258
+ //if (!Undo())
2259
+ //java.awt.Toolkit.getDefaultToolkit().beep();
22072260 Undo();
2261
+ } else
2262
+ if (source == restoreButton)
2263
+ {
2264
+ // Restore current version
2265
+ Restore();
2266
+ } else
2267
+ if (source == replaceButton)
2268
+ {
2269
+ // Overwrite current version
2270
+ Replace();
22082271 } else
22092272 if (source == redoButton)
22102273 {
2274
+ // Go to next version
22112275 Redo();
22122276 } else
22132277 if (source == saveButton)
22142278 {
2215
- Save();
2279
+ // Save a new version
2280
+ if (!Save(true))
2281
+ java.awt.Toolkit.getDefaultToolkit().beep();
22162282 } else
22172283 if (source == oneStepButton)
22182284 {
....@@ -2221,17 +2287,14 @@
22212287 } else
22222288 if (source == screenfitButton)
22232289 {
2224
- //Reload(lastConverter, lastFilename, true);
22252290 ScreenFit();
22262291 } else
22272292 if (source == screenfitpointButton)
22282293 {
2229
- //Reload(lastConverter, lastFilename, true);
22302294 ScreenFitPoint();
22312295 } else
22322296 if (source == snapobjectButton)
22332297 {
2234
- //Reload(lastConverter, lastFilename, true);
22352298 SnapObject();
22362299 } else
22372300 // if (event.getSource() == recompileButton)
....@@ -2755,15 +2818,28 @@
27552818 } else
27562819 if (source == ungroupItem || source == ungroupButton)
27572820 {
2758
- //ungroup();
2821
+ boolean hasRoot = false;
2822
+
27592823 for (int i=0; i<group.selection.size(); i++)
27602824 {
2761
- Ungroup(group.selection.get(i));
2825
+ if (group.selection.get(i) == group)
2826
+ {
2827
+ hasRoot = true;
2828
+ break;
2829
+ }
27622830 }
27632831
2764
- ClearSelection(false);
2765
-
2766
- refreshContents();
2832
+ if (!hasRoot)
2833
+ {
2834
+ for (int i=0; i<group.selection.size(); i++)
2835
+ {
2836
+ Ungroup(group.selection.get(i));
2837
+ }
2838
+
2839
+ ClearSelection(false);
2840
+
2841
+ refreshContents();
2842
+ }
27672843 } else
27682844 if (source == genUVItem)
27692845 {
....@@ -3446,6 +3522,9 @@
34463522 }
34473523
34483524 copy = group;
3525
+
3526
+ SetUndoStates();
3527
+
34493528 //Globals.theRenderer.object = group;
34503529 if(!useclient)
34513530 {
....@@ -3474,6 +3553,8 @@
34743553 radio.layout.doClick();
34753554
34763555 ClearUnpinned();
3556
+ Grafreed.Assert(group != null);
3557
+ Grafreed.Assert(group.selection != null);
34773558 SetPinStates(group.selection.size() > 0);
34783559 if (group.selection.size() == 1)
34793560 EditSelection(false);
....@@ -4706,7 +4787,7 @@
47064787 void refreshContents(boolean cp)
47074788 {
47084789 if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Info"))
4709
- if (!Globals.MOUSEDRAGGED) // && !Globals.TIMERRUNNING)
4790
+ if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
47104791 {
47114792 objEditor.ClearInfo(); // .GetMaterial());
47124793
....@@ -4805,8 +4886,8 @@
48054886
48064887 if (cut)
48074888 {
4808
- if (Globals.SAVEONMAKE)
4809
- Save();
4889
+// if (Globals.SAVEONMAKE) // Moved to the clipboard, no need to save.
4890
+// Save();
48104891 //int indices[] = jList.getSelectedIndices();
48114892 //for (int i = indices.length - 1; i >= 0; i--)
48124893 //jList.remove(indices[i]);
....@@ -4909,6 +4990,10 @@
49094990
49104991 void paste(boolean expand)
49114992 {
4993
+ if (Globals.REPLACEONMAKE)
4994
+ Save();
4995
+ boolean keep = Globals.REPLACEONMAKE;
4996
+ Globals.REPLACEONMAKE = false;
49124997 // if (GrafreeD.clipboard == null)
49134998 // return;
49144999 boolean first = true;
....@@ -4968,6 +5053,7 @@
49685053 Grafreed.clipboard.get(0).parent = keepparent;
49695054 }
49705055
5056
+ Globals.REPLACEONMAKE = keep;
49715057 ResetModel();
49725058 refreshContents();
49735059 }
....@@ -5103,6 +5189,10 @@
51035189
51045190 void group(Object3D csg, boolean grab)
51055191 {
5192
+ if (Globals.REPLACEONMAKE)
5193
+ Save();
5194
+ boolean keep = Globals.REPLACEONMAKE;
5195
+ Globals.REPLACEONMAKE = false;
51065196 if (//false) // why??
51075197 !group.selection.isEmpty())
51085198 {
....@@ -5216,10 +5306,15 @@
52165306 //node.add(csg);
52175307 //makeSomething(node);
52185308 makeSomething(csg);
5309
+ Globals.REPLACEONMAKE = keep;
52195310 }
52205311
52215312 void Ungroup(Object3D g)
52225313 {
5314
+ if (Globals.REPLACEONMAKE)
5315
+ Save();
5316
+ boolean keep = Globals.REPLACEONMAKE;
5317
+ Globals.REPLACEONMAKE = false;
52235318 if (g instanceof HiddenObject)
52245319 {
52255320 HiddenObject h = (HiddenObject) g;
....@@ -5236,6 +5331,7 @@
52365331 objEditor.makeSomething(g.get(i), false);
52375332 }
52385333 }
5334
+ Globals.REPLACEONMAKE = keep;
52395335 }
52405336
52415337 void ungroup()
....@@ -5526,9 +5622,6 @@
55265622
55275623 cButton restoreCameraButton;
55285624
5529
- cButton minButton;
5530
- cButton maxButton;
5531
- cButton fullButton;
55325625 cButton saveButton;
55335626 cButton oneStepButton;
55345627