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,13 +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);
390
+
383391 if (Globals.ADVANCED)
384392 {
385393 menu.add("-");
386394 linkerItem = menu.add(new MenuItem("Linker"));
387395 linkerItem.addActionListener(this);
388
- attributeItem = menu.add(new MenuItem("Attribute"));
389
- attributeItem.addActionListener(this);
390396 templateItem = menu.add(new MenuItem("Template"));
391397 templateItem.addActionListener(this);
392398 pointflowItem = menu.add(new MenuItem("Point Flow"));
....@@ -538,6 +544,7 @@
538544 buildToolsMenu(menu);
539545 }
540546
547
+
541548 void SetupUI2(ObjEditor oe)
542549 {
543550 // June 2019
....@@ -590,50 +597,66 @@
590597 //minButton.setToolTipText("Minimize window");
591598 //minButton.addActionListener(this);
592599
593
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
594
- maxButton.setToolTipText("Maximize window");
595
- maxButton.addActionListener(this);
600
+ if (Globals.ADVANCED)
601
+ {
602
+ oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
603
+ maxButton.setToolTipText("Maximize window");
604
+ maxButton.addActionListener(this);
605
+ }
596606
597607 oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
598608 fullButton.setToolTipText("Full-screen window");
599609 fullButton.addActionListener(this);
600610
611
+ oe.toolbarPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
612
+ screenfitButton.setToolTipText("Screen fit");
613
+ screenfitButton.addActionListener(this);
614
+
601615 oe.toolbarPanel.add(restoreCameraButton = GetButton("icons/eye.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
602616 restoreCameraButton.setToolTipText("Restore viewpoint");
603617 restoreCameraButton.addActionListener(this);
604618
619
+ copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
620
+ saveButton.setToolTipText("New version");
621
+ saveButton.addActionListener(this);
622
+
605623 copyOptionsPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
606
- undoButton.setToolTipText("Undo changes");
624
+ undoButton.setToolTipText("Previous version");
607625 undoButton.addActionListener(this);
608626 undoButton.setEnabled(false);
609627
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
+
610641 copyOptionsPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
611
- redoButton.setToolTipText("Redo changes");
642
+ redoButton.setToolTipText("Next version");
612643 redoButton.addActionListener(this);
613644 redoButton.setEnabled(false);
614645
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);
646
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
620647 liveCB.setToolTipText("Enable animation");
621648 liveCB.addItemListener(this);
622649
623
- copyOptionsPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
650
+ oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
624651 oneStepButton.setToolTipText("Animate one step forward");
625652 oneStepButton.addActionListener(this);
626653
627
- copyOptionsPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
654
+ oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
628655 fastCB.setToolTipText("Fast mode");
629656 fastCB.addItemListener(this);
630657
631658 //oe.toolboxPanel.Return();
632659
633
- copyOptionsPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
634
- screenfitButton.setToolTipText("Screen fit");
635
- screenfitButton.addActionListener(this);
636
-
637660 // copyOptionsPanel.add(trackCB = GetToggleButton("icons/track.png", CameraPane.TRACK)); //, oe.aConstraints);
638661 // trackCB.setToolTipText("Enable tracking");
639662 // trackCB.addItemListener(this);
....@@ -811,6 +834,9 @@
811834
812835 oe.treePanel.add(copyOptionsPanel);
813836 oe.treePanel.Return();
837
+ cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 10, 0);
838
+ versionField = (cNumberSlider)sliderPane.getComponent(1);
839
+ sliderPane.preferredHeight = 1;
814840
815841 // mainPanel.setDividerLocation(0.5); //1.0);
816842 // mainPanel.setResizeWeight(0.5);
....@@ -936,9 +962,9 @@
936962 toggleSwitchCB.setToolTipText("Choose a single item");
937963 toggleSwitchCB.addItemListener(this);
938964
939
- panel.add(autosaveCB = new cCheckBox("Auto-save", Globals.SAVEONMAKE)); //, constraints);
940
- autosaveCB.setToolTipText("On structure change");
941
- autosaveCB.addItemListener(this);
965
+ panel.add(autokeepCB = new cCheckBox("Auto-replace", Globals.REPLACEONMAKE)); //, constraints);
966
+ autokeepCB.setToolTipText("On structure change");
967
+ autokeepCB.addItemListener(this);
942968
943969 panel.Return();
944970 if (Globals.ADVANCED)
....@@ -967,7 +993,7 @@
967993 {
968994 cRadio radioButton = new cRadio(obj.name);
969995
970
- // Patch to avoid bug with transparency.
996
+ // June 2019. Patch to avoid bug with transparency.
971997 radioButton.hadMaterial = obj.material != null;
972998 if (!radioButton.hadMaterial)
973999 {
....@@ -1015,7 +1041,7 @@
10151041
10161042 cCheckBox oeilCB;
10171043 cCheckBox shadowCB;
1018
- cCheckBox autosaveCB;
1044
+ cCheckBox autokeepCB;
10191045 cCheckBox lookAtCB;
10201046
10211047 // static int COLOR = 1;
....@@ -1127,9 +1153,9 @@
11271153 {
11281154 Globals.FREEZEONMOVE ^= true;
11291155 }
1130
- else if(e.getSource() == autosaveCB)
1156
+ else if(e.getSource() == autokeepCB)
11311157 {
1132
- Globals.SAVEONMAKE ^= true;
1158
+ Globals.REPLACEONMAKE ^= true;
11331159 }
11341160 else if(e.getSource() == lookAtCB)
11351161 {
....@@ -1211,8 +1237,6 @@
12111237 }
12121238 }
12131239
1214
- String string = (String) object;
1215
-
12161240 System.out.println("Transfer = " + object + "; drop : " + target);
12171241 // if( object instanceof java.io.File[])
12181242 // {
....@@ -1220,6 +1244,8 @@
12201244 // objEditor.DropFile((java.io.File[]) object, true);
12211245 // return;
12221246 // }
1247
+
1248
+ String string = object.toString();
12231249
12241250 // File path for Mac and Windows
12251251 if (string.charAt(0) == '/' || string.charAt(1) == ':')
....@@ -1469,6 +1495,9 @@
14691495 animationItem.addItemListener(this);
14701496 animationItem.setState(Globals.ANIMATION);
14711497
1498
+ menu.add(archiveItem = new MenuItem("Archive3D..."));
1499
+ archiveItem.addActionListener(this);
1500
+
14721501 menu.add("-");
14731502 parseverticesItem = menu.add(new MenuItem("Multiplicity"));
14741503 parseverticesItem.addActionListener(this);
....@@ -1481,6 +1510,8 @@
14811510 reduce34MorphItem = menu.add(new MenuItem("Reduce Morphs (34)"));
14821511 reduce34MorphItem.addActionListener(this);
14831512 menu.add("-");
1513
+ menu.add(memoryItem = new MenuItem("Memory Usage"));
1514
+ memoryItem.addActionListener(this);
14841515 menu.add(computeAOItem = new MenuItem("Compute AO"));
14851516 computeAOItem.addActionListener(this);
14861517
....@@ -1489,8 +1520,6 @@
14891520 mirrorItem = menu.add(new MenuItem("Mirror Poses"));
14901521 mirrorItem.addActionListener(this);
14911522 menu.add("-");
1492
- menu.add(memoryItem = new MenuItem("Memory Usage"));
1493
- memoryItem.addActionListener(this);
14941523 menu.add(analyzeItem = new MenuItem("Analyze"));
14951524 analyzeItem.addActionListener(this);
14961525 menu.add(dumpItem = new MenuItem("Print"));
....@@ -2213,15 +2242,31 @@
22132242 } else
22142243 if (source == undoButton)
22152244 {
2245
+ // Go to previous version
2246
+ //if (!Undo())
2247
+ //java.awt.Toolkit.getDefaultToolkit().beep();
22162248 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();
22172259 } else
22182260 if (source == redoButton)
22192261 {
2262
+ // Go to next version
22202263 Redo();
22212264 } else
22222265 if (source == saveButton)
22232266 {
2224
- Save();
2267
+ // Save a new version
2268
+ if (!Save(true))
2269
+ java.awt.Toolkit.getDefaultToolkit().beep();
22252270 } else
22262271 if (source == oneStepButton)
22272272 {
....@@ -2230,17 +2275,14 @@
22302275 } else
22312276 if (source == screenfitButton)
22322277 {
2233
- //Reload(lastConverter, lastFilename, true);
22342278 ScreenFit();
22352279 } else
22362280 if (source == screenfitpointButton)
22372281 {
2238
- //Reload(lastConverter, lastFilename, true);
22392282 ScreenFitPoint();
22402283 } else
22412284 if (source == snapobjectButton)
22422285 {
2243
- //Reload(lastConverter, lastFilename, true);
22442286 SnapObject();
22452287 } else
22462288 // if (event.getSource() == recompileButton)
....@@ -3468,6 +3510,9 @@
34683510 }
34693511
34703512 copy = group;
3513
+
3514
+ SetUndoStates();
3515
+
34713516 //Globals.theRenderer.object = group;
34723517 if(!useclient)
34733518 {
....@@ -4728,7 +4773,7 @@
47284773 void refreshContents(boolean cp)
47294774 {
47304775 if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Info"))
4731
- if (!Globals.MOUSEDRAGGED) // && !Globals.TIMERRUNNING)
4776
+ if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
47324777 {
47334778 objEditor.ClearInfo(); // .GetMaterial());
47344779
....@@ -4827,8 +4872,8 @@
48274872
48284873 if (cut)
48294874 {
4830
- if (Globals.SAVEONMAKE)
4831
- Save();
4875
+// if (Globals.SAVEONMAKE) // Moved to the clipboard, no need to save.
4876
+// Save();
48324877 //int indices[] = jList.getSelectedIndices();
48334878 //for (int i = indices.length - 1; i >= 0; i--)
48344879 //jList.remove(indices[i]);
....@@ -4931,6 +4976,10 @@
49314976
49324977 void paste(boolean expand)
49334978 {
4979
+ if (Globals.REPLACEONMAKE)
4980
+ Save();
4981
+ boolean keep = Globals.REPLACEONMAKE;
4982
+ Globals.REPLACEONMAKE = false;
49344983 // if (GrafreeD.clipboard == null)
49354984 // return;
49364985 boolean first = true;
....@@ -4990,6 +5039,7 @@
49905039 Grafreed.clipboard.get(0).parent = keepparent;
49915040 }
49925041
5042
+ Globals.REPLACEONMAKE = keep;
49935043 ResetModel();
49945044 refreshContents();
49955045 }
....@@ -5125,6 +5175,10 @@
51255175
51265176 void group(Object3D csg, boolean grab)
51275177 {
5178
+ if (Globals.REPLACEONMAKE)
5179
+ Save();
5180
+ boolean keep = Globals.REPLACEONMAKE;
5181
+ Globals.REPLACEONMAKE = false;
51285182 if (//false) // why??
51295183 !group.selection.isEmpty())
51305184 {
....@@ -5238,10 +5292,15 @@
52385292 //node.add(csg);
52395293 //makeSomething(node);
52405294 makeSomething(csg);
5295
+ Globals.REPLACEONMAKE = keep;
52415296 }
52425297
52435298 void Ungroup(Object3D g)
52445299 {
5300
+ if (Globals.REPLACEONMAKE)
5301
+ Save();
5302
+ boolean keep = Globals.REPLACEONMAKE;
5303
+ Globals.REPLACEONMAKE = false;
52455304 if (g instanceof HiddenObject)
52465305 {
52475306 HiddenObject h = (HiddenObject) g;
....@@ -5258,6 +5317,7 @@
52585317 objEditor.makeSomething(g.get(i), false);
52595318 }
52605319 }
5320
+ Globals.REPLACEONMAKE = keep;
52615321 }
52625322
52635323 void ungroup()