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
....@@ -601,42 +608,55 @@
601608 fullButton.setToolTipText("Full-screen window");
602609 fullButton.addActionListener(this);
603610
611
+ oe.toolbarPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
612
+ screenfitButton.setToolTipText("Screen fit");
613
+ screenfitButton.addActionListener(this);
614
+
604615 oe.toolbarPanel.add(restoreCameraButton = GetButton("icons/eye.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
605616 restoreCameraButton.setToolTipText("Restore viewpoint");
606617 restoreCameraButton.addActionListener(this);
607618
619
+ copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
620
+ saveButton.setToolTipText("New version");
621
+ saveButton.addActionListener(this);
622
+
608623 copyOptionsPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
609
- undoButton.setToolTipText("Undo changes");
624
+ undoButton.setToolTipText("Previous version");
610625 undoButton.addActionListener(this);
611626 undoButton.setEnabled(false);
612627
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
+
613641 copyOptionsPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
614
- redoButton.setToolTipText("Redo changes");
642
+ redoButton.setToolTipText("Next version");
615643 redoButton.addActionListener(this);
616644 redoButton.setEnabled(false);
617645
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);
646
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
623647 liveCB.setToolTipText("Enable animation");
624648 liveCB.addItemListener(this);
625649
626
- copyOptionsPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
650
+ oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
627651 oneStepButton.setToolTipText("Animate one step forward");
628652 oneStepButton.addActionListener(this);
629653
630
- copyOptionsPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
654
+ oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
631655 fastCB.setToolTipText("Fast mode");
632656 fastCB.addItemListener(this);
633657
634658 //oe.toolboxPanel.Return();
635659
636
- copyOptionsPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
637
- screenfitButton.setToolTipText("Screen fit");
638
- screenfitButton.addActionListener(this);
639
-
640660 // copyOptionsPanel.add(trackCB = GetToggleButton("icons/track.png", CameraPane.TRACK)); //, oe.aConstraints);
641661 // trackCB.setToolTipText("Enable tracking");
642662 // trackCB.addItemListener(this);
....@@ -814,6 +834,9 @@
814834
815835 oe.treePanel.add(copyOptionsPanel);
816836 oe.treePanel.Return();
837
+ cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 10, 0);
838
+ versionField = (cNumberSlider)sliderPane.getComponent(1);
839
+ sliderPane.preferredHeight = 1;
817840
818841 // mainPanel.setDividerLocation(0.5); //1.0);
819842 // mainPanel.setResizeWeight(0.5);
....@@ -939,9 +962,9 @@
939962 toggleSwitchCB.setToolTipText("Choose a single item");
940963 toggleSwitchCB.addItemListener(this);
941964
942
- panel.add(autosaveCB = new cCheckBox("Auto-save", Globals.SAVEONMAKE)); //, constraints);
943
- autosaveCB.setToolTipText("On structure change");
944
- autosaveCB.addItemListener(this);
965
+ panel.add(autokeepCB = new cCheckBox("Auto-replace", Globals.REPLACEONMAKE)); //, constraints);
966
+ autokeepCB.setToolTipText("On structure change");
967
+ autokeepCB.addItemListener(this);
945968
946969 panel.Return();
947970 if (Globals.ADVANCED)
....@@ -970,7 +993,7 @@
970993 {
971994 cRadio radioButton = new cRadio(obj.name);
972995
973
- // Patch to avoid bug with transparency.
996
+ // June 2019. Patch to avoid bug with transparency.
974997 radioButton.hadMaterial = obj.material != null;
975998 if (!radioButton.hadMaterial)
976999 {
....@@ -1018,7 +1041,7 @@
10181041
10191042 cCheckBox oeilCB;
10201043 cCheckBox shadowCB;
1021
- cCheckBox autosaveCB;
1044
+ cCheckBox autokeepCB;
10221045 cCheckBox lookAtCB;
10231046
10241047 // static int COLOR = 1;
....@@ -1130,9 +1153,9 @@
11301153 {
11311154 Globals.FREEZEONMOVE ^= true;
11321155 }
1133
- else if(e.getSource() == autosaveCB)
1156
+ else if(e.getSource() == autokeepCB)
11341157 {
1135
- Globals.SAVEONMAKE ^= true;
1158
+ Globals.REPLACEONMAKE ^= true;
11361159 }
11371160 else if(e.getSource() == lookAtCB)
11381161 {
....@@ -1214,8 +1237,6 @@
12141237 }
12151238 }
12161239
1217
- String string = (String) object;
1218
-
12191240 System.out.println("Transfer = " + object + "; drop : " + target);
12201241 // if( object instanceof java.io.File[])
12211242 // {
....@@ -1223,6 +1244,8 @@
12231244 // objEditor.DropFile((java.io.File[]) object, true);
12241245 // return;
12251246 // }
1247
+
1248
+ String string = object.toString();
12261249
12271250 // File path for Mac and Windows
12281251 if (string.charAt(0) == '/' || string.charAt(1) == ':')
....@@ -1472,6 +1495,9 @@
14721495 animationItem.addItemListener(this);
14731496 animationItem.setState(Globals.ANIMATION);
14741497
1498
+ menu.add(archiveItem = new MenuItem("Archive3D..."));
1499
+ archiveItem.addActionListener(this);
1500
+
14751501 menu.add("-");
14761502 parseverticesItem = menu.add(new MenuItem("Multiplicity"));
14771503 parseverticesItem.addActionListener(this);
....@@ -1484,6 +1510,8 @@
14841510 reduce34MorphItem = menu.add(new MenuItem("Reduce Morphs (34)"));
14851511 reduce34MorphItem.addActionListener(this);
14861512 menu.add("-");
1513
+ menu.add(memoryItem = new MenuItem("Memory Usage"));
1514
+ memoryItem.addActionListener(this);
14871515 menu.add(computeAOItem = new MenuItem("Compute AO"));
14881516 computeAOItem.addActionListener(this);
14891517
....@@ -1492,8 +1520,6 @@
14921520 mirrorItem = menu.add(new MenuItem("Mirror Poses"));
14931521 mirrorItem.addActionListener(this);
14941522 menu.add("-");
1495
- menu.add(memoryItem = new MenuItem("Memory Usage"));
1496
- memoryItem.addActionListener(this);
14971523 menu.add(analyzeItem = new MenuItem("Analyze"));
14981524 analyzeItem.addActionListener(this);
14991525 menu.add(dumpItem = new MenuItem("Print"));
....@@ -2216,15 +2242,31 @@
22162242 } else
22172243 if (source == undoButton)
22182244 {
2245
+ // Go to previous version
2246
+ //if (!Undo())
2247
+ //java.awt.Toolkit.getDefaultToolkit().beep();
22192248 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();
22202259 } else
22212260 if (source == redoButton)
22222261 {
2262
+ // Go to next version
22232263 Redo();
22242264 } else
22252265 if (source == saveButton)
22262266 {
2227
- Save();
2267
+ // Save a new version
2268
+ if (!Save(true))
2269
+ java.awt.Toolkit.getDefaultToolkit().beep();
22282270 } else
22292271 if (source == oneStepButton)
22302272 {
....@@ -2233,17 +2275,14 @@
22332275 } else
22342276 if (source == screenfitButton)
22352277 {
2236
- //Reload(lastConverter, lastFilename, true);
22372278 ScreenFit();
22382279 } else
22392280 if (source == screenfitpointButton)
22402281 {
2241
- //Reload(lastConverter, lastFilename, true);
22422282 ScreenFitPoint();
22432283 } else
22442284 if (source == snapobjectButton)
22452285 {
2246
- //Reload(lastConverter, lastFilename, true);
22472286 SnapObject();
22482287 } else
22492288 // if (event.getSource() == recompileButton)
....@@ -3471,6 +3510,9 @@
34713510 }
34723511
34733512 copy = group;
3513
+
3514
+ SetUndoStates();
3515
+
34743516 //Globals.theRenderer.object = group;
34753517 if(!useclient)
34763518 {
....@@ -4731,7 +4773,7 @@
47314773 void refreshContents(boolean cp)
47324774 {
47334775 if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Info"))
4734
- if (!Globals.MOUSEDRAGGED) // && !Globals.TIMERRUNNING)
4776
+ if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
47354777 {
47364778 objEditor.ClearInfo(); // .GetMaterial());
47374779
....@@ -4830,8 +4872,8 @@
48304872
48314873 if (cut)
48324874 {
4833
- if (Globals.SAVEONMAKE)
4834
- Save();
4875
+// if (Globals.SAVEONMAKE) // Moved to the clipboard, no need to save.
4876
+// Save();
48354877 //int indices[] = jList.getSelectedIndices();
48364878 //for (int i = indices.length - 1; i >= 0; i--)
48374879 //jList.remove(indices[i]);
....@@ -4934,6 +4976,10 @@
49344976
49354977 void paste(boolean expand)
49364978 {
4979
+ if (Globals.REPLACEONMAKE)
4980
+ Save();
4981
+ boolean keep = Globals.REPLACEONMAKE;
4982
+ Globals.REPLACEONMAKE = false;
49374983 // if (GrafreeD.clipboard == null)
49384984 // return;
49394985 boolean first = true;
....@@ -4993,6 +5039,7 @@
49935039 Grafreed.clipboard.get(0).parent = keepparent;
49945040 }
49955041
5042
+ Globals.REPLACEONMAKE = keep;
49965043 ResetModel();
49975044 refreshContents();
49985045 }
....@@ -5128,6 +5175,10 @@
51285175
51295176 void group(Object3D csg, boolean grab)
51305177 {
5178
+ if (Globals.REPLACEONMAKE)
5179
+ Save();
5180
+ boolean keep = Globals.REPLACEONMAKE;
5181
+ Globals.REPLACEONMAKE = false;
51315182 if (//false) // why??
51325183 !group.selection.isEmpty())
51335184 {
....@@ -5241,10 +5292,15 @@
52415292 //node.add(csg);
52425293 //makeSomething(node);
52435294 makeSomething(csg);
5295
+ Globals.REPLACEONMAKE = keep;
52445296 }
52455297
52465298 void Ungroup(Object3D g)
52475299 {
5300
+ if (Globals.REPLACEONMAKE)
5301
+ Save();
5302
+ boolean keep = Globals.REPLACEONMAKE;
5303
+ Globals.REPLACEONMAKE = false;
52485304 if (g instanceof HiddenObject)
52495305 {
52505306 HiddenObject h = (HiddenObject) g;
....@@ -5261,6 +5317,7 @@
52615317 objEditor.makeSomething(g.get(i), false);
52625318 }
52635319 }
5320
+ Globals.REPLACEONMAKE = keep;
52645321 }
52655322
52665323 void ungroup()