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
....@@ -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);
....@@ -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);
....@@ -936,9 +974,9 @@
936974 toggleSwitchCB.setToolTipText("Choose a single item");
937975 toggleSwitchCB.addItemListener(this);
938976
939
- panel.add(autosaveCB = new cCheckBox("Auto-save", Globals.SAVEONMAKE)); //, constraints);
940
- autosaveCB.setToolTipText("On structure change");
941
- autosaveCB.addItemListener(this);
977
+ panel.add(autokeepCB = new cCheckBox("Auto-replace", Globals.REPLACEONMAKE)); //, constraints);
978
+ autokeepCB.setToolTipText("On structure change");
979
+ autokeepCB.addItemListener(this);
942980
943981 panel.Return();
944982 if (Globals.ADVANCED)
....@@ -967,7 +1005,7 @@
9671005 {
9681006 cRadio radioButton = new cRadio(obj.name);
9691007
970
- // Patch to avoid bug with transparency.
1008
+ // June 2019. Patch to avoid bug with transparency.
9711009 radioButton.hadMaterial = obj.material != null;
9721010 if (!radioButton.hadMaterial)
9731011 {
....@@ -1015,7 +1053,7 @@
10151053
10161054 cCheckBox oeilCB;
10171055 cCheckBox shadowCB;
1018
- cCheckBox autosaveCB;
1056
+ cCheckBox autokeepCB;
10191057 cCheckBox lookAtCB;
10201058
10211059 // static int COLOR = 1;
....@@ -1127,9 +1165,9 @@
11271165 {
11281166 Globals.FREEZEONMOVE ^= true;
11291167 }
1130
- else if(e.getSource() == autosaveCB)
1168
+ else if(e.getSource() == autokeepCB)
11311169 {
1132
- Globals.SAVEONMAKE ^= true;
1170
+ Globals.REPLACEONMAKE ^= true;
11331171 }
11341172 else if(e.getSource() == lookAtCB)
11351173 {
....@@ -1211,8 +1249,6 @@
12111249 }
12121250 }
12131251
1214
- String string = (String) object;
1215
-
12161252 System.out.println("Transfer = " + object + "; drop : " + target);
12171253 // if( object instanceof java.io.File[])
12181254 // {
....@@ -1220,6 +1256,8 @@
12201256 // objEditor.DropFile((java.io.File[]) object, true);
12211257 // return;
12221258 // }
1259
+
1260
+ String string = object.toString();
12231261
12241262 // File path for Mac and Windows
12251263 if (string.charAt(0) == '/' || string.charAt(1) == ':')
....@@ -1469,6 +1507,9 @@
14691507 animationItem.addItemListener(this);
14701508 animationItem.setState(Globals.ANIMATION);
14711509
1510
+ menu.add(archiveItem = new MenuItem("Archive3D..."));
1511
+ archiveItem.addActionListener(this);
1512
+
14721513 menu.add("-");
14731514 parseverticesItem = menu.add(new MenuItem("Multiplicity"));
14741515 parseverticesItem.addActionListener(this);
....@@ -1481,6 +1522,8 @@
14811522 reduce34MorphItem = menu.add(new MenuItem("Reduce Morphs (34)"));
14821523 reduce34MorphItem.addActionListener(this);
14831524 menu.add("-");
1525
+ menu.add(memoryItem = new MenuItem("Memory Usage"));
1526
+ memoryItem.addActionListener(this);
14841527 menu.add(computeAOItem = new MenuItem("Compute AO"));
14851528 computeAOItem.addActionListener(this);
14861529
....@@ -1489,8 +1532,6 @@
14891532 mirrorItem = menu.add(new MenuItem("Mirror Poses"));
14901533 mirrorItem.addActionListener(this);
14911534 menu.add("-");
1492
- menu.add(memoryItem = new MenuItem("Memory Usage"));
1493
- memoryItem.addActionListener(this);
14941535 menu.add(analyzeItem = new MenuItem("Analyze"));
14951536 analyzeItem.addActionListener(this);
14961537 menu.add(dumpItem = new MenuItem("Print"));
....@@ -2213,15 +2254,31 @@
22132254 } else
22142255 if (source == undoButton)
22152256 {
2257
+ // Go to previous version
2258
+ //if (!Undo())
2259
+ //java.awt.Toolkit.getDefaultToolkit().beep();
22162260 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();
22172271 } else
22182272 if (source == redoButton)
22192273 {
2274
+ // Go to next version
22202275 Redo();
22212276 } else
22222277 if (source == saveButton)
22232278 {
2224
- Save();
2279
+ // Save a new version
2280
+ if (!Save(true))
2281
+ java.awt.Toolkit.getDefaultToolkit().beep();
22252282 } else
22262283 if (source == oneStepButton)
22272284 {
....@@ -2230,17 +2287,14 @@
22302287 } else
22312288 if (source == screenfitButton)
22322289 {
2233
- //Reload(lastConverter, lastFilename, true);
22342290 ScreenFit();
22352291 } else
22362292 if (source == screenfitpointButton)
22372293 {
2238
- //Reload(lastConverter, lastFilename, true);
22392294 ScreenFitPoint();
22402295 } else
22412296 if (source == snapobjectButton)
22422297 {
2243
- //Reload(lastConverter, lastFilename, true);
22442298 SnapObject();
22452299 } else
22462300 // if (event.getSource() == recompileButton)
....@@ -3468,6 +3522,9 @@
34683522 }
34693523
34703524 copy = group;
3525
+
3526
+ SetUndoStates();
3527
+
34713528 //Globals.theRenderer.object = group;
34723529 if(!useclient)
34733530 {
....@@ -3496,6 +3553,8 @@
34963553 radio.layout.doClick();
34973554
34983555 ClearUnpinned();
3556
+ Grafreed.Assert(group != null);
3557
+ Grafreed.Assert(group.selection != null);
34993558 SetPinStates(group.selection.size() > 0);
35003559 if (group.selection.size() == 1)
35013560 EditSelection(false);
....@@ -4728,7 +4787,7 @@
47284787 void refreshContents(boolean cp)
47294788 {
47304789 if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Info"))
4731
- if (!Globals.MOUSEDRAGGED) // && !Globals.TIMERRUNNING)
4790
+ if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
47324791 {
47334792 objEditor.ClearInfo(); // .GetMaterial());
47344793
....@@ -4827,8 +4886,8 @@
48274886
48284887 if (cut)
48294888 {
4830
- if (Globals.SAVEONMAKE)
4831
- Save();
4889
+// if (Globals.SAVEONMAKE) // Moved to the clipboard, no need to save.
4890
+// Save();
48324891 //int indices[] = jList.getSelectedIndices();
48334892 //for (int i = indices.length - 1; i >= 0; i--)
48344893 //jList.remove(indices[i]);
....@@ -4931,6 +4990,10 @@
49314990
49324991 void paste(boolean expand)
49334992 {
4993
+ if (Globals.REPLACEONMAKE)
4994
+ Save();
4995
+ boolean keep = Globals.REPLACEONMAKE;
4996
+ Globals.REPLACEONMAKE = false;
49344997 // if (GrafreeD.clipboard == null)
49354998 // return;
49364999 boolean first = true;
....@@ -4990,6 +5053,7 @@
49905053 Grafreed.clipboard.get(0).parent = keepparent;
49915054 }
49925055
5056
+ Globals.REPLACEONMAKE = keep;
49935057 ResetModel();
49945058 refreshContents();
49955059 }
....@@ -5125,6 +5189,10 @@
51255189
51265190 void group(Object3D csg, boolean grab)
51275191 {
5192
+ if (Globals.REPLACEONMAKE)
5193
+ Save();
5194
+ boolean keep = Globals.REPLACEONMAKE;
5195
+ Globals.REPLACEONMAKE = false;
51285196 if (//false) // why??
51295197 !group.selection.isEmpty())
51305198 {
....@@ -5238,10 +5306,15 @@
52385306 //node.add(csg);
52395307 //makeSomething(node);
52405308 makeSomething(csg);
5309
+ Globals.REPLACEONMAKE = keep;
52415310 }
52425311
52435312 void Ungroup(Object3D g)
52445313 {
5314
+ if (Globals.REPLACEONMAKE)
5315
+ Save();
5316
+ boolean keep = Globals.REPLACEONMAKE;
5317
+ Globals.REPLACEONMAKE = false;
52455318 if (g instanceof HiddenObject)
52465319 {
52475320 HiddenObject h = (HiddenObject) g;
....@@ -5258,6 +5331,7 @@
52585331 objEditor.makeSomething(g.get(i), false);
52595332 }
52605333 }
5334
+ Globals.REPLACEONMAKE = keep;
52615335 }
52625336
52635337 void ungroup()