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)
....@@ -380,14 +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);
383402
384403 if (Globals.ADVANCED)
385404 {
386405 menu.add("-");
387406 linkerItem = menu.add(new MenuItem("Linker"));
388407 linkerItem.addActionListener(this);
389
- attributeItem = menu.add(new MenuItem("Attribute"));
390
- attributeItem.addActionListener(this);
391408 templateItem = menu.add(new MenuItem("Template"));
392409 templateItem.addActionListener(this);
393410 pointflowItem = menu.add(new MenuItem("Point Flow"));
....@@ -539,6 +556,7 @@
539556 buildToolsMenu(menu);
540557 }
541558
559
+
542560 void SetupUI2(ObjEditor oe)
543561 {
544562 // June 2019
....@@ -610,29 +628,42 @@
610628 restoreCameraButton.setToolTipText("Restore viewpoint");
611629 restoreCameraButton.addActionListener(this);
612630
631
+ copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
632
+ saveButton.setToolTipText("New version");
633
+ saveButton.addActionListener(this);
634
+
613635 copyOptionsPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
614
- undoButton.setToolTipText("Undo changes");
636
+ undoButton.setToolTipText("Previous version");
615637 undoButton.addActionListener(this);
616638 undoButton.setEnabled(false);
617639
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
+
618653 copyOptionsPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
619
- redoButton.setToolTipText("Redo changes");
654
+ redoButton.setToolTipText("Next version");
620655 redoButton.addActionListener(this);
621656 redoButton.setEnabled(false);
622657
623
- copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
624
- saveButton.setToolTipText("Save changes");
625
- saveButton.addActionListener(this);
626
-
627
- copyOptionsPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
658
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
628659 liveCB.setToolTipText("Enable animation");
629660 liveCB.addItemListener(this);
630661
631
- copyOptionsPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
662
+ oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
632663 oneStepButton.setToolTipText("Animate one step forward");
633664 oneStepButton.addActionListener(this);
634665
635
- copyOptionsPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
666
+ oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
636667 fastCB.setToolTipText("Fast mode");
637668 fastCB.addItemListener(this);
638669
....@@ -815,6 +846,9 @@
815846
816847 oe.treePanel.add(copyOptionsPanel);
817848 oe.treePanel.Return();
849
+ cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
850
+ versionSlider = (cNumberSlider)sliderPane.getComponent(1);
851
+ sliderPane.preferredHeight = 1;
818852
819853 // mainPanel.setDividerLocation(0.5); //1.0);
820854 // mainPanel.setResizeWeight(0.5);
....@@ -940,9 +974,9 @@
940974 toggleSwitchCB.setToolTipText("Choose a single item");
941975 toggleSwitchCB.addItemListener(this);
942976
943
- panel.add(autosaveCB = new cCheckBox("Auto-save", Globals.SAVEONMAKE)); //, constraints);
944
- autosaveCB.setToolTipText("On structure change");
945
- autosaveCB.addItemListener(this);
977
+ panel.add(autokeepCB = new cCheckBox("Auto-replace", Globals.REPLACEONMAKE)); //, constraints);
978
+ autokeepCB.setToolTipText("On structure change");
979
+ autokeepCB.addItemListener(this);
946980
947981 panel.Return();
948982 if (Globals.ADVANCED)
....@@ -971,7 +1005,7 @@
9711005 {
9721006 cRadio radioButton = new cRadio(obj.name);
9731007
974
- // Patch to avoid bug with transparency.
1008
+ // June 2019. Patch to avoid bug with transparency.
9751009 radioButton.hadMaterial = obj.material != null;
9761010 if (!radioButton.hadMaterial)
9771011 {
....@@ -1019,7 +1053,7 @@
10191053
10201054 cCheckBox oeilCB;
10211055 cCheckBox shadowCB;
1022
- cCheckBox autosaveCB;
1056
+ cCheckBox autokeepCB;
10231057 cCheckBox lookAtCB;
10241058
10251059 // static int COLOR = 1;
....@@ -1131,9 +1165,9 @@
11311165 {
11321166 Globals.FREEZEONMOVE ^= true;
11331167 }
1134
- else if(e.getSource() == autosaveCB)
1168
+ else if(e.getSource() == autokeepCB)
11351169 {
1136
- Globals.SAVEONMAKE ^= true;
1170
+ Globals.REPLACEONMAKE ^= true;
11371171 }
11381172 else if(e.getSource() == lookAtCB)
11391173 {
....@@ -1223,7 +1257,7 @@
12231257 // return;
12241258 // }
12251259
1226
- String string = (String) object;
1260
+ String string = object.toString();
12271261
12281262 // File path for Mac and Windows
12291263 if (string.charAt(0) == '/' || string.charAt(1) == ':')
....@@ -1488,6 +1522,8 @@
14881522 reduce34MorphItem = menu.add(new MenuItem("Reduce Morphs (34)"));
14891523 reduce34MorphItem.addActionListener(this);
14901524 menu.add("-");
1525
+ menu.add(memoryItem = new MenuItem("Memory Usage"));
1526
+ memoryItem.addActionListener(this);
14911527 menu.add(computeAOItem = new MenuItem("Compute AO"));
14921528 computeAOItem.addActionListener(this);
14931529
....@@ -1496,8 +1532,6 @@
14961532 mirrorItem = menu.add(new MenuItem("Mirror Poses"));
14971533 mirrorItem.addActionListener(this);
14981534 menu.add("-");
1499
- menu.add(memoryItem = new MenuItem("Memory Usage"));
1500
- memoryItem.addActionListener(this);
15011535 menu.add(analyzeItem = new MenuItem("Analyze"));
15021536 analyzeItem.addActionListener(this);
15031537 menu.add(dumpItem = new MenuItem("Print"));
....@@ -2220,15 +2254,29 @@
22202254 } else
22212255 if (source == undoButton)
22222256 {
2223
- if (!Undo())
2224
- java.awt.Toolkit.getDefaultToolkit().beep();
2257
+ // Go to previous version
2258
+ //if (!Undo())
2259
+ //java.awt.Toolkit.getDefaultToolkit().beep();
2260
+ 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();
22252271 } else
22262272 if (source == redoButton)
22272273 {
2274
+ // Go to next version
22282275 Redo();
22292276 } else
22302277 if (source == saveButton)
22312278 {
2279
+ // Save a new version
22322280 if (!Save(true))
22332281 java.awt.Toolkit.getDefaultToolkit().beep();
22342282 } else
....@@ -3474,6 +3522,9 @@
34743522 }
34753523
34763524 copy = group;
3525
+
3526
+ SetUndoStates();
3527
+
34773528 //Globals.theRenderer.object = group;
34783529 if(!useclient)
34793530 {
....@@ -3502,6 +3553,8 @@
35023553 radio.layout.doClick();
35033554
35043555 ClearUnpinned();
3556
+ Grafreed.Assert(group != null);
3557
+ Grafreed.Assert(group.selection != null);
35053558 SetPinStates(group.selection.size() > 0);
35063559 if (group.selection.size() == 1)
35073560 EditSelection(false);
....@@ -4833,8 +4886,8 @@
48334886
48344887 if (cut)
48354888 {
4836
- if (Globals.SAVEONMAKE)
4837
- Save();
4889
+// if (Globals.SAVEONMAKE) // Moved to the clipboard, no need to save.
4890
+// Save();
48384891 //int indices[] = jList.getSelectedIndices();
48394892 //for (int i = indices.length - 1; i >= 0; i--)
48404893 //jList.remove(indices[i]);
....@@ -4937,6 +4990,10 @@
49374990
49384991 void paste(boolean expand)
49394992 {
4993
+ if (Globals.REPLACEONMAKE)
4994
+ Save();
4995
+ boolean keep = Globals.REPLACEONMAKE;
4996
+ Globals.REPLACEONMAKE = false;
49404997 // if (GrafreeD.clipboard == null)
49414998 // return;
49424999 boolean first = true;
....@@ -4996,6 +5053,7 @@
49965053 Grafreed.clipboard.get(0).parent = keepparent;
49975054 }
49985055
5056
+ Globals.REPLACEONMAKE = keep;
49995057 ResetModel();
50005058 refreshContents();
50015059 }
....@@ -5131,6 +5189,10 @@
51315189
51325190 void group(Object3D csg, boolean grab)
51335191 {
5192
+ if (Globals.REPLACEONMAKE)
5193
+ Save();
5194
+ boolean keep = Globals.REPLACEONMAKE;
5195
+ Globals.REPLACEONMAKE = false;
51345196 if (//false) // why??
51355197 !group.selection.isEmpty())
51365198 {
....@@ -5244,10 +5306,15 @@
52445306 //node.add(csg);
52455307 //makeSomething(node);
52465308 makeSomething(csg);
5309
+ Globals.REPLACEONMAKE = keep;
52475310 }
52485311
52495312 void Ungroup(Object3D g)
52505313 {
5314
+ if (Globals.REPLACEONMAKE)
5315
+ Save();
5316
+ boolean keep = Globals.REPLACEONMAKE;
5317
+ Globals.REPLACEONMAKE = false;
52515318 if (g instanceof HiddenObject)
52525319 {
52535320 HiddenObject h = (HiddenObject) g;
....@@ -5264,6 +5331,7 @@
52645331 objEditor.makeSomething(g.get(i), false);
52655332 }
52665333 }
5334
+ Globals.REPLACEONMAKE = keep;
52675335 }
52685336
52695337 void ungroup()