Normand Briere
2019-07-19 e79247ef52a0bbb3864d46bb1e2c716005b3ecf3
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)
....@@ -194,8 +206,8 @@
194206 // pasteExpandItem = menu.add(new MenuItem("Paste expand"));
195207 // pasteExpandItem.addActionListener(this);
196208 menu.add("-");
197
- clearItem = menu.add(new MenuItem("Clear"));
198
- clearItem.addActionListener(this);
209
+ deleteItem = menu.add(new MenuItem("Delete"));
210
+ deleteItem.addActionListener(this);
199211
200212 if (Globals.ADVANCED)
201213 {
....@@ -421,7 +433,7 @@
421433 genNormalsMESHItem.addActionListener(this);
422434 if (Globals.ADVANCED)
423435 {
424
- genNormalsMINEItem = menu.add(new MenuItem("My Normals"));
436
+ genNormalsMINEItem = menu.add(new MenuItem("Stitch Normals"));
425437 genNormalsMINEItem.addActionListener(this);
426438 }
427439 stripifyItem = menu.add(new MenuItem("Stripify"));
....@@ -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
....@@ -659,27 +685,28 @@
659685
660686 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
661687
662
- oe.toolbarPanel.add(twoButton = new cButton("|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
663
- twoButton.setToolTipText("Show center view only");
664
- twoButton.addActionListener(this);
665
- this.fullscreenLayout = twoButton;
666
-
667688 oe.toolbarPanel.add(fourButton = new cButton("-||", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
668689 fourButton.addActionListener(this);
669690 fourButton.setToolTipText("Show left panel only");
691
+
692
+ oe.toolbarPanel.add(twoButton = new cButton("|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
693
+ twoButton.setToolTipText("Show right view only");
694
+ twoButton.addActionListener(this);
695
+ this.fullscreenLayout = twoButton;
696
+
670697 oe.toolbarPanel.add(sixButton = new cButton("-|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
671
- sixButton.setToolTipText("2-column layout left");
698
+ sixButton.setToolTipText("Show left and right");
672699 sixButton.addActionListener(this);
673
- oe.toolbarPanel.add(threeButton = new cButton("|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
674
- threeButton.setToolTipText("2-column layout right");
675
- threeButton.addActionListener(this);
676
- oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
677
- sevenButton.setToolTipText("3-column layout");
678
- sevenButton.addActionListener(this);
700
+// oe.toolbarPanel.add(threeButton = new cButton("|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
701
+// threeButton.setToolTipText("2-column layout right");
702
+// threeButton.addActionListener(this);
703
+// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
704
+// sevenButton.setToolTipText("3-column layout");
705
+// sevenButton.addActionListener(this);
679706 //
680707
681
- oe.toolbarPanel.add(rootButton = GetButton("icons/write.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
682
- rootButton.setToolTipText("Edit selection in new tab");
708
+ oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
709
+ rootButton.setToolTipText("Open selection in new tab");
683710 rootButton.addActionListener(this);
684711
685712 oe.toolbarPanel.add(closeButton = GetButton("icons/close-icon.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -820,6 +847,9 @@
820847
821848 oe.treePanel.add(copyOptionsPanel);
822849 oe.treePanel.Return();
850
+ cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
851
+ versionSlider = (cNumberSlider)sliderPane.getComponent(1);
852
+ sliderPane.preferredHeight = 1;
823853
824854 // mainPanel.setDividerLocation(0.5); //1.0);
825855 // mainPanel.setResizeWeight(0.5);
....@@ -842,7 +872,7 @@
842872 dgr.addDragGestureListener(this);
843873 }catch(Exception e) {}
844874 */
845
- radio.layout = sevenButton;
875
+ radio.layout = sixButton; // sevenButton;
846876 oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
847877 }
848878
....@@ -945,9 +975,9 @@
945975 toggleSwitchCB.setToolTipText("Choose a single item");
946976 toggleSwitchCB.addItemListener(this);
947977
948
- panel.add(autosaveCB = new cCheckBox("Auto-save", Globals.SAVEONMAKE)); //, constraints);
949
- autosaveCB.setToolTipText("On structure change");
950
- autosaveCB.addItemListener(this);
978
+ panel.add(autokeepCB = new cCheckBox("Auto-replace", Globals.REPLACEONMAKE)); //, constraints);
979
+ autokeepCB.setToolTipText("On structure change");
980
+ autokeepCB.addItemListener(this);
951981
952982 panel.Return();
953983 if (Globals.ADVANCED)
....@@ -984,7 +1014,7 @@
9841014 }
9851015
9861016 radioButton.SetObject(obj);
987
- radioButton.layout = sevenButton;
1017
+ radioButton.layout = sixButton; // sevenButton;
9881018 radioButton.SetCamera(cameraView.renderCamera, false);
9891019 radioButton.addActionListener(this);
9901020 radioPanel.add(radioButton);
....@@ -1024,7 +1054,7 @@
10241054
10251055 cCheckBox oeilCB;
10261056 cCheckBox shadowCB;
1027
- cCheckBox autosaveCB;
1057
+ cCheckBox autokeepCB;
10281058 cCheckBox lookAtCB;
10291059
10301060 // static int COLOR = 1;
....@@ -1136,9 +1166,9 @@
11361166 {
11371167 Globals.FREEZEONMOVE ^= true;
11381168 }
1139
- else if(e.getSource() == autosaveCB)
1169
+ else if(e.getSource() == autokeepCB)
11401170 {
1141
- Globals.SAVEONMAKE ^= true;
1171
+ Globals.REPLACEONMAKE ^= true;
11421172 }
11431173 else if(e.getSource() == lookAtCB)
11441174 {
....@@ -1663,6 +1693,16 @@
16631693 listUI.remove(i);
16641694 }
16651695 }
1696
+ }
1697
+
1698
+ private void EditElement(Object3D elem, boolean newWindow)
1699
+ {
1700
+ // if (!(elem instanceof Composite))
1701
+ // newWindow = false;
1702
+ listUI.add(elem);
1703
+ elem.openEditWindow(this, newWindow); //, false);
1704
+ System.out.println("edit : " + elem);
1705
+ elem.editWindow.refreshContents(true); // ? new
16661706 }
16671707
16681708 /**
....@@ -2225,15 +2265,29 @@
22252265 } else
22262266 if (source == undoButton)
22272267 {
2228
- if (!Undo())
2229
- java.awt.Toolkit.getDefaultToolkit().beep();
2268
+ // Go to previous version
2269
+ //if (!Undo())
2270
+ //java.awt.Toolkit.getDefaultToolkit().beep();
2271
+ Undo();
2272
+ } else
2273
+ if (source == restoreButton)
2274
+ {
2275
+ // Restore current version
2276
+ Restore();
2277
+ } else
2278
+ if (source == replaceButton)
2279
+ {
2280
+ // Overwrite current version
2281
+ Replace();
22302282 } else
22312283 if (source == redoButton)
22322284 {
2285
+ // Go to next version
22332286 Redo();
22342287 } else
22352288 if (source == saveButton)
22362289 {
2290
+ // Save a new version
22372291 if (!Save(true))
22382292 java.awt.Toolkit.getDefaultToolkit().beep();
22392293 } else
....@@ -2615,7 +2669,7 @@
26152669 {
26162670 StepAll();
26172671 } else
2618
- if (source == clearItem) // || event.getSource() == clearButton)
2672
+ if (source == deleteItem) // || event.getSource() == clearButton)
26192673 {
26202674 //int indices[] = jList.getSelectedIndices();
26212675 //for (int i = indices.length - 1; i >= 0; i--)
....@@ -3479,6 +3533,9 @@
34793533 }
34803534
34813535 copy = group;
3536
+
3537
+ SetUndoStates();
3538
+
34823539 //Globals.theRenderer.object = group;
34833540 if(!useclient)
34843541 {
....@@ -3507,8 +3564,10 @@
35073564 radio.layout.doClick();
35083565
35093566 ClearUnpinned();
3510
- SetPinStates(group.selection.size() > 0);
3511
- if (group.selection.size() == 1)
3567
+ //Grafreed.Assert(group != null);
3568
+ //Grafreed.Assert(group.selection != null);
3569
+ SetPinStates(group.selection == null || group.selection.size() > 0);
3570
+ if (group.selection == null || group.selection.size() == 1)
35123571 EditSelection(false);
35133572 keepparent = group.parent;
35143573 // PARENT = NULL or not???
....@@ -4579,6 +4638,12 @@
45794638
45804639 void EditSelection(boolean newWindow)
45814640 {
4641
+ if (group.selection == null)
4642
+ {
4643
+ EditElement(group, newWindow); // ? new
4644
+ return;
4645
+ }
4646
+
45824647 // aConstraints.gridy = 0;
45834648 for (int i=0; i<group.selection.size(); i++)
45844649 {
....@@ -4589,12 +4654,7 @@
45894654 Object3D elem = (Object3D)group.selection.elementAt(i);
45904655 if(elem != group || !newWindow)
45914656 {
4592
- // if (!(elem instanceof Composite))
4593
- // newWindow = false;
4594
- listUI.add(elem);
4595
- elem.openEditWindow(this, newWindow); //, false);
4596
- System.out.println("edit : " + elem);
4597
- elem.editWindow.refreshContents(true); // ? new
4657
+ EditElement(elem, newWindow); // ? new
45984658 }
45994659 }
46004660 }
....@@ -4942,10 +5002,10 @@
49425002
49435003 void paste(boolean expand)
49445004 {
4945
- if (Globals.SAVEONMAKE)
5005
+ if (Globals.REPLACEONMAKE)
49465006 Save();
4947
- boolean keep = Globals.SAVEONMAKE;
4948
- Globals.SAVEONMAKE = false;
5007
+ boolean keep = Globals.REPLACEONMAKE;
5008
+ Globals.REPLACEONMAKE = false;
49495009 // if (GrafreeD.clipboard == null)
49505010 // return;
49515011 boolean first = true;
....@@ -5005,7 +5065,7 @@
50055065 Grafreed.clipboard.get(0).parent = keepparent;
50065066 }
50075067
5008
- Globals.SAVEONMAKE = keep;
5068
+ Globals.REPLACEONMAKE = keep;
50095069 ResetModel();
50105070 refreshContents();
50115071 }
....@@ -5141,10 +5201,10 @@
51415201
51425202 void group(Object3D csg, boolean grab)
51435203 {
5144
- if (Globals.SAVEONMAKE)
5204
+ if (Globals.REPLACEONMAKE)
51455205 Save();
5146
- boolean keep = Globals.SAVEONMAKE;
5147
- Globals.SAVEONMAKE = false;
5206
+ boolean keep = Globals.REPLACEONMAKE;
5207
+ Globals.REPLACEONMAKE = false;
51485208 if (//false) // why??
51495209 !group.selection.isEmpty())
51505210 {
....@@ -5258,15 +5318,15 @@
52585318 //node.add(csg);
52595319 //makeSomething(node);
52605320 makeSomething(csg);
5261
- Globals.SAVEONMAKE = keep;
5321
+ Globals.REPLACEONMAKE = keep;
52625322 }
52635323
52645324 void Ungroup(Object3D g)
52655325 {
5266
- if (Globals.SAVEONMAKE)
5326
+ if (Globals.REPLACEONMAKE)
52675327 Save();
5268
- boolean keep = Globals.SAVEONMAKE;
5269
- Globals.SAVEONMAKE = false;
5328
+ boolean keep = Globals.REPLACEONMAKE;
5329
+ Globals.REPLACEONMAKE = false;
52705330 if (g instanceof HiddenObject)
52715331 {
52725332 HiddenObject h = (HiddenObject) g;
....@@ -5283,7 +5343,7 @@
52835343 objEditor.makeSomething(g.get(i), false);
52845344 }
52855345 }
5286
- Globals.SAVEONMAKE = keep;
5346
+ Globals.REPLACEONMAKE = keep;
52875347 }
52885348
52895349 void ungroup()
....@@ -5647,7 +5707,7 @@
56475707 private MenuItem pasteLinkItem;
56485708 private MenuItem pasteCloneItem;
56495709 private MenuItem pasteExpandItem;
5650
- private MenuItem clearItem;
5710
+ private MenuItem deleteItem;
56515711 private MenuItem clearAllItem;
56525712 private MenuItem genUVItem;
56535713 private MenuItem genNormalsMESHItem;