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,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
....@@ -601,42 +620,55 @@
601620 fullButton.setToolTipText("Full-screen window");
602621 fullButton.addActionListener(this);
603622
623
+ oe.toolbarPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
624
+ screenfitButton.setToolTipText("Screen fit");
625
+ screenfitButton.addActionListener(this);
626
+
604627 oe.toolbarPanel.add(restoreCameraButton = GetButton("icons/eye.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
605628 restoreCameraButton.setToolTipText("Restore viewpoint");
606629 restoreCameraButton.addActionListener(this);
607630
631
+ copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
632
+ saveButton.setToolTipText("New version");
633
+ saveButton.addActionListener(this);
634
+
608635 copyOptionsPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
609
- undoButton.setToolTipText("Undo changes");
636
+ undoButton.setToolTipText("Previous version");
610637 undoButton.addActionListener(this);
611638 undoButton.setEnabled(false);
612639
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
+
613653 copyOptionsPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
614
- redoButton.setToolTipText("Redo changes");
654
+ redoButton.setToolTipText("Next version");
615655 redoButton.addActionListener(this);
616656 redoButton.setEnabled(false);
617657
618
- copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
619
- saveButton.setToolTipText("Save changes");
620
- saveButton.addActionListener(this);
621
-
622
- copyOptionsPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
658
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
623659 liveCB.setToolTipText("Enable animation");
624660 liveCB.addItemListener(this);
625661
626
- copyOptionsPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
662
+ oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
627663 oneStepButton.setToolTipText("Animate one step forward");
628664 oneStepButton.addActionListener(this);
629665
630
- copyOptionsPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
666
+ oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
631667 fastCB.setToolTipText("Fast mode");
632668 fastCB.addItemListener(this);
633669
634670 //oe.toolboxPanel.Return();
635671
636
- copyOptionsPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
637
- screenfitButton.setToolTipText("Screen fit");
638
- screenfitButton.addActionListener(this);
639
-
640672 // copyOptionsPanel.add(trackCB = GetToggleButton("icons/track.png", CameraPane.TRACK)); //, oe.aConstraints);
641673 // trackCB.setToolTipText("Enable tracking");
642674 // trackCB.addItemListener(this);
....@@ -814,6 +846,9 @@
814846
815847 oe.treePanel.add(copyOptionsPanel);
816848 oe.treePanel.Return();
849
+ cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
850
+ versionSlider = (cNumberSlider)sliderPane.getComponent(1);
851
+ sliderPane.preferredHeight = 1;
817852
818853 // mainPanel.setDividerLocation(0.5); //1.0);
819854 // mainPanel.setResizeWeight(0.5);
....@@ -939,9 +974,9 @@
939974 toggleSwitchCB.setToolTipText("Choose a single item");
940975 toggleSwitchCB.addItemListener(this);
941976
942
- panel.add(autosaveCB = new cCheckBox("Auto-save", Globals.SAVEONMAKE)); //, constraints);
943
- autosaveCB.setToolTipText("On structure change");
944
- autosaveCB.addItemListener(this);
977
+ panel.add(autokeepCB = new cCheckBox("Auto-replace", Globals.REPLACEONMAKE)); //, constraints);
978
+ autokeepCB.setToolTipText("On structure change");
979
+ autokeepCB.addItemListener(this);
945980
946981 panel.Return();
947982 if (Globals.ADVANCED)
....@@ -970,7 +1005,7 @@
9701005 {
9711006 cRadio radioButton = new cRadio(obj.name);
9721007
973
- // Patch to avoid bug with transparency.
1008
+ // June 2019. Patch to avoid bug with transparency.
9741009 radioButton.hadMaterial = obj.material != null;
9751010 if (!radioButton.hadMaterial)
9761011 {
....@@ -1018,7 +1053,7 @@
10181053
10191054 cCheckBox oeilCB;
10201055 cCheckBox shadowCB;
1021
- cCheckBox autosaveCB;
1056
+ cCheckBox autokeepCB;
10221057 cCheckBox lookAtCB;
10231058
10241059 // static int COLOR = 1;
....@@ -1130,9 +1165,9 @@
11301165 {
11311166 Globals.FREEZEONMOVE ^= true;
11321167 }
1133
- else if(e.getSource() == autosaveCB)
1168
+ else if(e.getSource() == autokeepCB)
11341169 {
1135
- Globals.SAVEONMAKE ^= true;
1170
+ Globals.REPLACEONMAKE ^= true;
11361171 }
11371172 else if(e.getSource() == lookAtCB)
11381173 {
....@@ -1214,8 +1249,6 @@
12141249 }
12151250 }
12161251
1217
- String string = (String) object;
1218
-
12191252 System.out.println("Transfer = " + object + "; drop : " + target);
12201253 // if( object instanceof java.io.File[])
12211254 // {
....@@ -1223,6 +1256,8 @@
12231256 // objEditor.DropFile((java.io.File[]) object, true);
12241257 // return;
12251258 // }
1259
+
1260
+ String string = object.toString();
12261261
12271262 // File path for Mac and Windows
12281263 if (string.charAt(0) == '/' || string.charAt(1) == ':')
....@@ -1472,6 +1507,9 @@
14721507 animationItem.addItemListener(this);
14731508 animationItem.setState(Globals.ANIMATION);
14741509
1510
+ menu.add(archiveItem = new MenuItem("Archive3D..."));
1511
+ archiveItem.addActionListener(this);
1512
+
14751513 menu.add("-");
14761514 parseverticesItem = menu.add(new MenuItem("Multiplicity"));
14771515 parseverticesItem.addActionListener(this);
....@@ -1484,6 +1522,8 @@
14841522 reduce34MorphItem = menu.add(new MenuItem("Reduce Morphs (34)"));
14851523 reduce34MorphItem.addActionListener(this);
14861524 menu.add("-");
1525
+ menu.add(memoryItem = new MenuItem("Memory Usage"));
1526
+ memoryItem.addActionListener(this);
14871527 menu.add(computeAOItem = new MenuItem("Compute AO"));
14881528 computeAOItem.addActionListener(this);
14891529
....@@ -1492,8 +1532,6 @@
14921532 mirrorItem = menu.add(new MenuItem("Mirror Poses"));
14931533 mirrorItem.addActionListener(this);
14941534 menu.add("-");
1495
- menu.add(memoryItem = new MenuItem("Memory Usage"));
1496
- memoryItem.addActionListener(this);
14971535 menu.add(analyzeItem = new MenuItem("Analyze"));
14981536 analyzeItem.addActionListener(this);
14991537 menu.add(dumpItem = new MenuItem("Print"));
....@@ -2216,15 +2254,31 @@
22162254 } else
22172255 if (source == undoButton)
22182256 {
2257
+ // Go to previous version
2258
+ //if (!Undo())
2259
+ //java.awt.Toolkit.getDefaultToolkit().beep();
22192260 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();
22202271 } else
22212272 if (source == redoButton)
22222273 {
2274
+ // Go to next version
22232275 Redo();
22242276 } else
22252277 if (source == saveButton)
22262278 {
2227
- Save();
2279
+ // Save a new version
2280
+ if (!Save(true))
2281
+ java.awt.Toolkit.getDefaultToolkit().beep();
22282282 } else
22292283 if (source == oneStepButton)
22302284 {
....@@ -2233,17 +2287,14 @@
22332287 } else
22342288 if (source == screenfitButton)
22352289 {
2236
- //Reload(lastConverter, lastFilename, true);
22372290 ScreenFit();
22382291 } else
22392292 if (source == screenfitpointButton)
22402293 {
2241
- //Reload(lastConverter, lastFilename, true);
22422294 ScreenFitPoint();
22432295 } else
22442296 if (source == snapobjectButton)
22452297 {
2246
- //Reload(lastConverter, lastFilename, true);
22472298 SnapObject();
22482299 } else
22492300 // if (event.getSource() == recompileButton)
....@@ -3471,6 +3522,9 @@
34713522 }
34723523
34733524 copy = group;
3525
+
3526
+ SetUndoStates();
3527
+
34743528 //Globals.theRenderer.object = group;
34753529 if(!useclient)
34763530 {
....@@ -3499,6 +3553,8 @@
34993553 radio.layout.doClick();
35003554
35013555 ClearUnpinned();
3556
+ Grafreed.Assert(group != null);
3557
+ Grafreed.Assert(group.selection != null);
35023558 SetPinStates(group.selection.size() > 0);
35033559 if (group.selection.size() == 1)
35043560 EditSelection(false);
....@@ -4731,7 +4787,7 @@
47314787 void refreshContents(boolean cp)
47324788 {
47334789 if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Info"))
4734
- if (!Globals.MOUSEDRAGGED) // && !Globals.TIMERRUNNING)
4790
+ if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
47354791 {
47364792 objEditor.ClearInfo(); // .GetMaterial());
47374793
....@@ -4830,8 +4886,8 @@
48304886
48314887 if (cut)
48324888 {
4833
- if (Globals.SAVEONMAKE)
4834
- Save();
4889
+// if (Globals.SAVEONMAKE) // Moved to the clipboard, no need to save.
4890
+// Save();
48354891 //int indices[] = jList.getSelectedIndices();
48364892 //for (int i = indices.length - 1; i >= 0; i--)
48374893 //jList.remove(indices[i]);
....@@ -4934,6 +4990,10 @@
49344990
49354991 void paste(boolean expand)
49364992 {
4993
+ if (Globals.REPLACEONMAKE)
4994
+ Save();
4995
+ boolean keep = Globals.REPLACEONMAKE;
4996
+ Globals.REPLACEONMAKE = false;
49374997 // if (GrafreeD.clipboard == null)
49384998 // return;
49394999 boolean first = true;
....@@ -4993,6 +5053,7 @@
49935053 Grafreed.clipboard.get(0).parent = keepparent;
49945054 }
49955055
5056
+ Globals.REPLACEONMAKE = keep;
49965057 ResetModel();
49975058 refreshContents();
49985059 }
....@@ -5128,6 +5189,10 @@
51285189
51295190 void group(Object3D csg, boolean grab)
51305191 {
5192
+ if (Globals.REPLACEONMAKE)
5193
+ Save();
5194
+ boolean keep = Globals.REPLACEONMAKE;
5195
+ Globals.REPLACEONMAKE = false;
51315196 if (//false) // why??
51325197 !group.selection.isEmpty())
51335198 {
....@@ -5241,10 +5306,15 @@
52415306 //node.add(csg);
52425307 //makeSomething(node);
52435308 makeSomething(csg);
5309
+ Globals.REPLACEONMAKE = keep;
52445310 }
52455311
52465312 void Ungroup(Object3D g)
52475313 {
5314
+ if (Globals.REPLACEONMAKE)
5315
+ Save();
5316
+ boolean keep = Globals.REPLACEONMAKE;
5317
+ Globals.REPLACEONMAKE = false;
52485318 if (g instanceof HiddenObject)
52495319 {
52505320 HiddenObject h = (HiddenObject) g;
....@@ -5261,6 +5331,7 @@
52615331 objEditor.makeSomething(g.get(i), false);
52625332 }
52635333 }
5334
+ Globals.REPLACEONMAKE = keep;
52645335 }
52655336
52665337 void ungroup()