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,10 +96,10 @@
8496
8597 void CloneSelection(boolean supports)
8698 {
87
- if (Globals.SAVEONMAKE)
99
+ if (Globals.REPLACEONMAKE)
88100 Save();
89
- boolean keep = Globals.SAVEONMAKE;
90
- Globals.SAVEONMAKE = false;
101
+ boolean keep = Globals.REPLACEONMAKE;
102
+ Globals.REPLACEONMAKE = false;
91103 // Object3D keep = GrafreeD.clipboard;
92104 //Object3D obj;
93105 for (int i=0; i<group.selection.size(); i++)// Enumeration e = group.selection.elements(); e.hasMoreElements();)
....@@ -98,7 +110,7 @@
98110
99111 makeSomething(clone, i==group.selection.size()-1);
100112 }
101
- Globals.SAVEONMAKE = keep;
113
+ Globals.REPLACEONMAKE = keep;
102114 }
103115
104116 void CloneClipboard(boolean supports)
....@@ -544,6 +556,7 @@
544556 buildToolsMenu(menu);
545557 }
546558
559
+
547560 void SetupUI2(ObjEditor oe)
548561 {
549562 // June 2019
....@@ -615,29 +628,42 @@
615628 restoreCameraButton.setToolTipText("Restore viewpoint");
616629 restoreCameraButton.addActionListener(this);
617630
631
+ copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
632
+ saveButton.setToolTipText("New version");
633
+ saveButton.addActionListener(this);
634
+
618635 copyOptionsPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
619
- undoButton.setToolTipText("Undo changes");
636
+ undoButton.setToolTipText("Previous version");
620637 undoButton.addActionListener(this);
621638 undoButton.setEnabled(false);
622639
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
+
623653 copyOptionsPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
624
- redoButton.setToolTipText("Redo changes");
654
+ redoButton.setToolTipText("Next version");
625655 redoButton.addActionListener(this);
626656 redoButton.setEnabled(false);
627657
628
- copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
629
- saveButton.setToolTipText("Save changes");
630
- saveButton.addActionListener(this);
631
-
632
- copyOptionsPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
658
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
633659 liveCB.setToolTipText("Enable animation");
634660 liveCB.addItemListener(this);
635661
636
- copyOptionsPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
662
+ oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
637663 oneStepButton.setToolTipText("Animate one step forward");
638664 oneStepButton.addActionListener(this);
639665
640
- copyOptionsPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
666
+ oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
641667 fastCB.setToolTipText("Fast mode");
642668 fastCB.addItemListener(this);
643669
....@@ -820,6 +846,9 @@
820846
821847 oe.treePanel.add(copyOptionsPanel);
822848 oe.treePanel.Return();
849
+ cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
850
+ versionSlider = (cNumberSlider)sliderPane.getComponent(1);
851
+ sliderPane.preferredHeight = 1;
823852
824853 // mainPanel.setDividerLocation(0.5); //1.0);
825854 // mainPanel.setResizeWeight(0.5);
....@@ -945,9 +974,9 @@
945974 toggleSwitchCB.setToolTipText("Choose a single item");
946975 toggleSwitchCB.addItemListener(this);
947976
948
- panel.add(autosaveCB = new cCheckBox("Auto-save", Globals.SAVEONMAKE)); //, constraints);
949
- autosaveCB.setToolTipText("On structure change");
950
- autosaveCB.addItemListener(this);
977
+ panel.add(autokeepCB = new cCheckBox("Auto-replace", Globals.REPLACEONMAKE)); //, constraints);
978
+ autokeepCB.setToolTipText("On structure change");
979
+ autokeepCB.addItemListener(this);
951980
952981 panel.Return();
953982 if (Globals.ADVANCED)
....@@ -1024,7 +1053,7 @@
10241053
10251054 cCheckBox oeilCB;
10261055 cCheckBox shadowCB;
1027
- cCheckBox autosaveCB;
1056
+ cCheckBox autokeepCB;
10281057 cCheckBox lookAtCB;
10291058
10301059 // static int COLOR = 1;
....@@ -1136,9 +1165,9 @@
11361165 {
11371166 Globals.FREEZEONMOVE ^= true;
11381167 }
1139
- else if(e.getSource() == autosaveCB)
1168
+ else if(e.getSource() == autokeepCB)
11401169 {
1141
- Globals.SAVEONMAKE ^= true;
1170
+ Globals.REPLACEONMAKE ^= true;
11421171 }
11431172 else if(e.getSource() == lookAtCB)
11441173 {
....@@ -2225,15 +2254,29 @@
22252254 } else
22262255 if (source == undoButton)
22272256 {
2228
- if (!Undo())
2229
- 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();
22302271 } else
22312272 if (source == redoButton)
22322273 {
2274
+ // Go to next version
22332275 Redo();
22342276 } else
22352277 if (source == saveButton)
22362278 {
2279
+ // Save a new version
22372280 if (!Save(true))
22382281 java.awt.Toolkit.getDefaultToolkit().beep();
22392282 } else
....@@ -3479,6 +3522,9 @@
34793522 }
34803523
34813524 copy = group;
3525
+
3526
+ SetUndoStates();
3527
+
34823528 //Globals.theRenderer.object = group;
34833529 if(!useclient)
34843530 {
....@@ -3507,6 +3553,8 @@
35073553 radio.layout.doClick();
35083554
35093555 ClearUnpinned();
3556
+ Grafreed.Assert(group != null);
3557
+ Grafreed.Assert(group.selection != null);
35103558 SetPinStates(group.selection.size() > 0);
35113559 if (group.selection.size() == 1)
35123560 EditSelection(false);
....@@ -4942,10 +4990,10 @@
49424990
49434991 void paste(boolean expand)
49444992 {
4945
- if (Globals.SAVEONMAKE)
4993
+ if (Globals.REPLACEONMAKE)
49464994 Save();
4947
- boolean keep = Globals.SAVEONMAKE;
4948
- Globals.SAVEONMAKE = false;
4995
+ boolean keep = Globals.REPLACEONMAKE;
4996
+ Globals.REPLACEONMAKE = false;
49494997 // if (GrafreeD.clipboard == null)
49504998 // return;
49514999 boolean first = true;
....@@ -5005,7 +5053,7 @@
50055053 Grafreed.clipboard.get(0).parent = keepparent;
50065054 }
50075055
5008
- Globals.SAVEONMAKE = keep;
5056
+ Globals.REPLACEONMAKE = keep;
50095057 ResetModel();
50105058 refreshContents();
50115059 }
....@@ -5141,10 +5189,10 @@
51415189
51425190 void group(Object3D csg, boolean grab)
51435191 {
5144
- if (Globals.SAVEONMAKE)
5192
+ if (Globals.REPLACEONMAKE)
51455193 Save();
5146
- boolean keep = Globals.SAVEONMAKE;
5147
- Globals.SAVEONMAKE = false;
5194
+ boolean keep = Globals.REPLACEONMAKE;
5195
+ Globals.REPLACEONMAKE = false;
51485196 if (//false) // why??
51495197 !group.selection.isEmpty())
51505198 {
....@@ -5258,15 +5306,15 @@
52585306 //node.add(csg);
52595307 //makeSomething(node);
52605308 makeSomething(csg);
5261
- Globals.SAVEONMAKE = keep;
5309
+ Globals.REPLACEONMAKE = keep;
52625310 }
52635311
52645312 void Ungroup(Object3D g)
52655313 {
5266
- if (Globals.SAVEONMAKE)
5314
+ if (Globals.REPLACEONMAKE)
52675315 Save();
5268
- boolean keep = Globals.SAVEONMAKE;
5269
- Globals.SAVEONMAKE = false;
5316
+ boolean keep = Globals.REPLACEONMAKE;
5317
+ Globals.REPLACEONMAKE = false;
52705318 if (g instanceof HiddenObject)
52715319 {
52725320 HiddenObject h = (HiddenObject) g;
....@@ -5283,7 +5331,7 @@
52835331 objEditor.makeSomething(g.get(i), false);
52845332 }
52855333 }
5286
- Globals.SAVEONMAKE = keep;
5334
+ Globals.REPLACEONMAKE = keep;
52875335 }
52885336
52895337 void ungroup()