Normand Briere
2019-07-17 a5580a47d246c1272b10adba68070f6e13da5e41
GroupEditor.java
....@@ -84,6 +84,10 @@
8484
8585 void CloneSelection(boolean supports)
8686 {
87
+ if (Globals.REPLACEONMAKE)
88
+ Save();
89
+ boolean keep = Globals.REPLACEONMAKE;
90
+ Globals.REPLACEONMAKE = false;
8791 // Object3D keep = GrafreeD.clipboard;
8892 //Object3D obj;
8993 for (int i=0; i<group.selection.size(); i++)// Enumeration e = group.selection.elements(); e.hasMoreElements();)
....@@ -94,6 +98,7 @@
9498
9599 makeSomething(clone, i==group.selection.size()-1);
96100 }
101
+ Globals.REPLACEONMAKE = keep;
97102 }
98103
99104 void CloneClipboard(boolean supports)
....@@ -380,14 +385,14 @@
380385 shadowYItem.addActionListener(this);
381386 shadowZItem = menu.add(new MenuItem("Shadow Blue"));
382387 shadowZItem.addActionListener(this);
388
+ attributeItem = menu.add(new MenuItem("Attribute"));
389
+ attributeItem.addActionListener(this);
383390
384391 if (Globals.ADVANCED)
385392 {
386393 menu.add("-");
387394 linkerItem = menu.add(new MenuItem("Linker"));
388395 linkerItem.addActionListener(this);
389
- attributeItem = menu.add(new MenuItem("Attribute"));
390
- attributeItem.addActionListener(this);
391396 templateItem = menu.add(new MenuItem("Template"));
392397 templateItem.addActionListener(this);
393398 pointflowItem = menu.add(new MenuItem("Point Flow"));
....@@ -539,6 +544,7 @@
539544 buildToolsMenu(menu);
540545 }
541546
547
+
542548 void SetupUI2(ObjEditor oe)
543549 {
544550 // June 2019
....@@ -610,29 +616,42 @@
610616 restoreCameraButton.setToolTipText("Restore viewpoint");
611617 restoreCameraButton.addActionListener(this);
612618
619
+ copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
620
+ saveButton.setToolTipText("New version");
621
+ saveButton.addActionListener(this);
622
+
613623 copyOptionsPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
614
- undoButton.setToolTipText("Undo changes");
624
+ undoButton.setToolTipText("Previous version");
615625 undoButton.addActionListener(this);
616626 undoButton.setEnabled(false);
617627
628
+ cGridBag updown = new cGridBag().setVertical(true);
629
+ updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
630
+ restoreButton.setToolTipText("Restore current");
631
+ restoreButton.addActionListener(this);
632
+ restoreButton.setEnabled(false);
633
+
634
+ updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
635
+ replaceButton.setToolTipText("Replace current");
636
+ replaceButton.addActionListener(this);
637
+ replaceButton.setEnabled(false);
638
+
639
+ copyOptionsPanel.add(updown);
640
+
618641 copyOptionsPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
619
- redoButton.setToolTipText("Redo changes");
642
+ redoButton.setToolTipText("Next version");
620643 redoButton.addActionListener(this);
621644 redoButton.setEnabled(false);
622645
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);
646
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
628647 liveCB.setToolTipText("Enable animation");
629648 liveCB.addItemListener(this);
630649
631
- copyOptionsPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
650
+ oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
632651 oneStepButton.setToolTipText("Animate one step forward");
633652 oneStepButton.addActionListener(this);
634653
635
- copyOptionsPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
654
+ oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
636655 fastCB.setToolTipText("Fast mode");
637656 fastCB.addItemListener(this);
638657
....@@ -815,6 +834,9 @@
815834
816835 oe.treePanel.add(copyOptionsPanel);
817836 oe.treePanel.Return();
837
+ cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 10, 0);
838
+ versionField = (cNumberSlider)sliderPane.getComponent(1);
839
+ sliderPane.preferredHeight = 1;
818840
819841 // mainPanel.setDividerLocation(0.5); //1.0);
820842 // mainPanel.setResizeWeight(0.5);
....@@ -940,9 +962,9 @@
940962 toggleSwitchCB.setToolTipText("Choose a single item");
941963 toggleSwitchCB.addItemListener(this);
942964
943
- panel.add(autosaveCB = new cCheckBox("Auto-save", Globals.SAVEONMAKE)); //, constraints);
944
- autosaveCB.setToolTipText("On structure change");
945
- autosaveCB.addItemListener(this);
965
+ panel.add(autokeepCB = new cCheckBox("Auto-replace", Globals.REPLACEONMAKE)); //, constraints);
966
+ autokeepCB.setToolTipText("On structure change");
967
+ autokeepCB.addItemListener(this);
946968
947969 panel.Return();
948970 if (Globals.ADVANCED)
....@@ -971,7 +993,7 @@
971993 {
972994 cRadio radioButton = new cRadio(obj.name);
973995
974
- // Patch to avoid bug with transparency.
996
+ // June 2019. Patch to avoid bug with transparency.
975997 radioButton.hadMaterial = obj.material != null;
976998 if (!radioButton.hadMaterial)
977999 {
....@@ -1019,7 +1041,7 @@
10191041
10201042 cCheckBox oeilCB;
10211043 cCheckBox shadowCB;
1022
- cCheckBox autosaveCB;
1044
+ cCheckBox autokeepCB;
10231045 cCheckBox lookAtCB;
10241046
10251047 // static int COLOR = 1;
....@@ -1131,9 +1153,9 @@
11311153 {
11321154 Globals.FREEZEONMOVE ^= true;
11331155 }
1134
- else if(e.getSource() == autosaveCB)
1156
+ else if(e.getSource() == autokeepCB)
11351157 {
1136
- Globals.SAVEONMAKE ^= true;
1158
+ Globals.REPLACEONMAKE ^= true;
11371159 }
11381160 else if(e.getSource() == lookAtCB)
11391161 {
....@@ -1223,7 +1245,7 @@
12231245 // return;
12241246 // }
12251247
1226
- String string = (String) object;
1248
+ String string = object.toString();
12271249
12281250 // File path for Mac and Windows
12291251 if (string.charAt(0) == '/' || string.charAt(1) == ':')
....@@ -1488,6 +1510,8 @@
14881510 reduce34MorphItem = menu.add(new MenuItem("Reduce Morphs (34)"));
14891511 reduce34MorphItem.addActionListener(this);
14901512 menu.add("-");
1513
+ menu.add(memoryItem = new MenuItem("Memory Usage"));
1514
+ memoryItem.addActionListener(this);
14911515 menu.add(computeAOItem = new MenuItem("Compute AO"));
14921516 computeAOItem.addActionListener(this);
14931517
....@@ -1496,8 +1520,6 @@
14961520 mirrorItem = menu.add(new MenuItem("Mirror Poses"));
14971521 mirrorItem.addActionListener(this);
14981522 menu.add("-");
1499
- menu.add(memoryItem = new MenuItem("Memory Usage"));
1500
- memoryItem.addActionListener(this);
15011523 menu.add(analyzeItem = new MenuItem("Analyze"));
15021524 analyzeItem.addActionListener(this);
15031525 menu.add(dumpItem = new MenuItem("Print"));
....@@ -2220,15 +2242,29 @@
22202242 } else
22212243 if (source == undoButton)
22222244 {
2223
- if (!Undo())
2224
- java.awt.Toolkit.getDefaultToolkit().beep();
2245
+ // Go to previous version
2246
+ //if (!Undo())
2247
+ //java.awt.Toolkit.getDefaultToolkit().beep();
2248
+ Undo();
2249
+ } else
2250
+ if (source == restoreButton)
2251
+ {
2252
+ // Restore current version
2253
+ Restore();
2254
+ } else
2255
+ if (source == replaceButton)
2256
+ {
2257
+ // Overwrite current version
2258
+ Replace();
22252259 } else
22262260 if (source == redoButton)
22272261 {
2262
+ // Go to next version
22282263 Redo();
22292264 } else
22302265 if (source == saveButton)
22312266 {
2267
+ // Save a new version
22322268 if (!Save(true))
22332269 java.awt.Toolkit.getDefaultToolkit().beep();
22342270 } else
....@@ -3474,6 +3510,9 @@
34743510 }
34753511
34763512 copy = group;
3513
+
3514
+ SetUndoStates();
3515
+
34773516 //Globals.theRenderer.object = group;
34783517 if(!useclient)
34793518 {
....@@ -4833,8 +4872,8 @@
48334872
48344873 if (cut)
48354874 {
4836
- if (Globals.SAVEONMAKE)
4837
- Save();
4875
+// if (Globals.SAVEONMAKE) // Moved to the clipboard, no need to save.
4876
+// Save();
48384877 //int indices[] = jList.getSelectedIndices();
48394878 //for (int i = indices.length - 1; i >= 0; i--)
48404879 //jList.remove(indices[i]);
....@@ -4937,6 +4976,10 @@
49374976
49384977 void paste(boolean expand)
49394978 {
4979
+ if (Globals.REPLACEONMAKE)
4980
+ Save();
4981
+ boolean keep = Globals.REPLACEONMAKE;
4982
+ Globals.REPLACEONMAKE = false;
49404983 // if (GrafreeD.clipboard == null)
49414984 // return;
49424985 boolean first = true;
....@@ -4996,6 +5039,7 @@
49965039 Grafreed.clipboard.get(0).parent = keepparent;
49975040 }
49985041
5042
+ Globals.REPLACEONMAKE = keep;
49995043 ResetModel();
50005044 refreshContents();
50015045 }
....@@ -5131,6 +5175,10 @@
51315175
51325176 void group(Object3D csg, boolean grab)
51335177 {
5178
+ if (Globals.REPLACEONMAKE)
5179
+ Save();
5180
+ boolean keep = Globals.REPLACEONMAKE;
5181
+ Globals.REPLACEONMAKE = false;
51345182 if (//false) // why??
51355183 !group.selection.isEmpty())
51365184 {
....@@ -5244,10 +5292,15 @@
52445292 //node.add(csg);
52455293 //makeSomething(node);
52465294 makeSomething(csg);
5295
+ Globals.REPLACEONMAKE = keep;
52475296 }
52485297
52495298 void Ungroup(Object3D g)
52505299 {
5300
+ if (Globals.REPLACEONMAKE)
5301
+ Save();
5302
+ boolean keep = Globals.REPLACEONMAKE;
5303
+ Globals.REPLACEONMAKE = false;
52515304 if (g instanceof HiddenObject)
52525305 {
52535306 HiddenObject h = (HiddenObject) g;
....@@ -5264,6 +5317,7 @@
52645317 objEditor.makeSomething(g.get(i), false);
52655318 }
52665319 }
5320
+ Globals.REPLACEONMAKE = keep;
52675321 }
52685322
52695323 void ungroup()