Normand Briere
2019-07-21 40f408aaee14abd85d391008b4d22977dc586b50
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 }
....@@ -80,14 +86,22 @@
8086 SetupViews(objEditor);
8187
8288 ((cRadio)radioPanel.getComponent(0)).SetCamera(cameraView.renderCamera, true);
89
+
90
+ if (copy.versions == null)
91
+ {
92
+ copy.versions = new byte[100][];
93
+ copy.versionindex = -1;
94
+
95
+ Save(true);
96
+ }
8397 }
8498
8599 void CloneSelection(boolean supports)
86100 {
87
- if (Globals.SAVEONMAKE)
101
+ if (Globals.REPLACEONMAKE)
88102 Save();
89
- boolean keep = Globals.SAVEONMAKE;
90
- Globals.SAVEONMAKE = false;
103
+ boolean keep = Globals.REPLACEONMAKE;
104
+ Globals.REPLACEONMAKE = false;
91105 // Object3D keep = GrafreeD.clipboard;
92106 //Object3D obj;
93107 for (int i=0; i<group.selection.size(); i++)// Enumeration e = group.selection.elements(); e.hasMoreElements();)
....@@ -98,7 +112,7 @@
98112
99113 makeSomething(clone, i==group.selection.size()-1);
100114 }
101
- Globals.SAVEONMAKE = keep;
115
+ Globals.REPLACEONMAKE = keep;
102116 }
103117
104118 void CloneClipboard(boolean supports)
....@@ -194,8 +208,8 @@
194208 // pasteExpandItem = menu.add(new MenuItem("Paste expand"));
195209 // pasteExpandItem.addActionListener(this);
196210 menu.add("-");
197
- clearItem = menu.add(new MenuItem("Clear"));
198
- clearItem.addActionListener(this);
211
+ deleteItem = menu.add(new MenuItem("Delete"));
212
+ deleteItem.addActionListener(this);
199213
200214 if (Globals.ADVANCED)
201215 {
....@@ -421,7 +435,7 @@
421435 genNormalsMESHItem.addActionListener(this);
422436 if (Globals.ADVANCED)
423437 {
424
- genNormalsMINEItem = menu.add(new MenuItem("My Normals"));
438
+ genNormalsMINEItem = menu.add(new MenuItem("Stitch Normals"));
425439 genNormalsMINEItem.addActionListener(this);
426440 }
427441 stripifyItem = menu.add(new MenuItem("Stripify"));
....@@ -544,6 +558,7 @@
544558 buildToolsMenu(menu);
545559 }
546560
561
+
547562 void SetupUI2(ObjEditor oe)
548563 {
549564 // June 2019
....@@ -615,29 +630,42 @@
615630 restoreCameraButton.setToolTipText("Restore viewpoint");
616631 restoreCameraButton.addActionListener(this);
617632
633
+ copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
634
+ saveButton.setToolTipText("New version");
635
+ saveButton.addActionListener(this);
636
+
618637 copyOptionsPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
619
- undoButton.setToolTipText("Undo changes");
638
+ undoButton.setToolTipText("Previous version");
620639 undoButton.addActionListener(this);
621640 undoButton.setEnabled(false);
622641
642
+ cGridBag updown = new cGridBag().setVertical(true);
643
+ updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
644
+ restoreButton.setToolTipText("Restore current");
645
+ restoreButton.addActionListener(this);
646
+ restoreButton.setEnabled(false);
647
+
648
+ updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
649
+ replaceButton.setToolTipText("Replace current");
650
+ replaceButton.addActionListener(this);
651
+ replaceButton.setEnabled(false);
652
+
653
+ copyOptionsPanel.add(updown);
654
+
623655 copyOptionsPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
624
- redoButton.setToolTipText("Redo changes");
656
+ redoButton.setToolTipText("Next version");
625657 redoButton.addActionListener(this);
626658 redoButton.setEnabled(false);
627659
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);
660
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
633661 liveCB.setToolTipText("Enable animation");
634662 liveCB.addItemListener(this);
635663
636
- copyOptionsPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
664
+ oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
637665 oneStepButton.setToolTipText("Animate one step forward");
638666 oneStepButton.addActionListener(this);
639667
640
- copyOptionsPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
668
+ oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
641669 fastCB.setToolTipText("Fast mode");
642670 fastCB.addItemListener(this);
643671
....@@ -659,27 +687,28 @@
659687
660688 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
661689
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
-
667690 oe.toolbarPanel.add(fourButton = new cButton("-||", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
668691 fourButton.addActionListener(this);
669692 fourButton.setToolTipText("Show left panel only");
693
+
694
+ oe.toolbarPanel.add(twoButton = new cButton("|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
695
+ twoButton.setToolTipText("Show right view only");
696
+ twoButton.addActionListener(this);
697
+ this.fullscreenLayout = twoButton;
698
+
670699 oe.toolbarPanel.add(sixButton = new cButton("-|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
671
- sixButton.setToolTipText("2-column layout left");
700
+ sixButton.setToolTipText("Show left and right");
672701 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);
702
+// oe.toolbarPanel.add(threeButton = new cButton("|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
703
+// threeButton.setToolTipText("2-column layout right");
704
+// threeButton.addActionListener(this);
705
+// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
706
+// sevenButton.setToolTipText("3-column layout");
707
+// sevenButton.addActionListener(this);
679708 //
680709
681
- oe.toolbarPanel.add(rootButton = GetButton("icons/write.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
682
- rootButton.setToolTipText("Edit selection in new tab");
710
+ oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
711
+ rootButton.setToolTipText("Open selection in new tab");
683712 rootButton.addActionListener(this);
684713
685714 oe.toolbarPanel.add(closeButton = GetButton("icons/close-icon.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -820,6 +849,9 @@
820849
821850 oe.treePanel.add(copyOptionsPanel);
822851 oe.treePanel.Return();
852
+ cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
853
+ versionSlider = (cNumberSlider)sliderPane.getComponent(1);
854
+ sliderPane.preferredHeight = 1;
823855
824856 // mainPanel.setDividerLocation(0.5); //1.0);
825857 // mainPanel.setResizeWeight(0.5);
....@@ -842,7 +874,7 @@
842874 dgr.addDragGestureListener(this);
843875 }catch(Exception e) {}
844876 */
845
- radio.layout = sevenButton;
877
+ radio.layout = sixButton; // sevenButton;
846878 oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
847879 }
848880
....@@ -945,9 +977,9 @@
945977 toggleSwitchCB.setToolTipText("Choose a single item");
946978 toggleSwitchCB.addItemListener(this);
947979
948
- panel.add(autosaveCB = new cCheckBox("Auto-save", Globals.SAVEONMAKE)); //, constraints);
949
- autosaveCB.setToolTipText("On structure change");
950
- autosaveCB.addItemListener(this);
980
+ panel.add(autokeepCB = new cCheckBox("Auto-replace", Globals.REPLACEONMAKE)); //, constraints);
981
+ autokeepCB.setToolTipText("On structure change");
982
+ autokeepCB.addItemListener(this);
951983
952984 panel.Return();
953985 if (Globals.ADVANCED)
....@@ -984,7 +1016,7 @@
9841016 }
9851017
9861018 radioButton.SetObject(obj);
987
- radioButton.layout = sevenButton;
1019
+ radioButton.layout = sixButton; // sevenButton;
9881020 radioButton.SetCamera(cameraView.renderCamera, false);
9891021 radioButton.addActionListener(this);
9901022 radioPanel.add(radioButton);
....@@ -1024,7 +1056,7 @@
10241056
10251057 cCheckBox oeilCB;
10261058 cCheckBox shadowCB;
1027
- cCheckBox autosaveCB;
1059
+ cCheckBox autokeepCB;
10281060 cCheckBox lookAtCB;
10291061
10301062 // static int COLOR = 1;
....@@ -1136,9 +1168,9 @@
11361168 {
11371169 Globals.FREEZEONMOVE ^= true;
11381170 }
1139
- else if(e.getSource() == autosaveCB)
1171
+ else if(e.getSource() == autokeepCB)
11401172 {
1141
- Globals.SAVEONMAKE ^= true;
1173
+ Globals.REPLACEONMAKE ^= true;
11421174 }
11431175 else if(e.getSource() == lookAtCB)
11441176 {
....@@ -1663,6 +1695,16 @@
16631695 listUI.remove(i);
16641696 }
16651697 }
1698
+ }
1699
+
1700
+ private void EditElement(Object3D elem, boolean newWindow)
1701
+ {
1702
+ // if (!(elem instanceof Composite))
1703
+ // newWindow = false;
1704
+ listUI.add(elem);
1705
+ elem.openEditWindow(this, newWindow); //, false);
1706
+ System.out.println("edit : " + elem);
1707
+ elem.editWindow.refreshContents(true); // ? new
16661708 }
16671709
16681710 /**
....@@ -2225,15 +2267,29 @@
22252267 } else
22262268 if (source == undoButton)
22272269 {
2228
- if (!Undo())
2229
- java.awt.Toolkit.getDefaultToolkit().beep();
2270
+ // Go to previous version
2271
+ //if (!Undo())
2272
+ //java.awt.Toolkit.getDefaultToolkit().beep();
2273
+ Undo();
2274
+ } else
2275
+ if (source == restoreButton)
2276
+ {
2277
+ // Restore current version
2278
+ Restore();
2279
+ } else
2280
+ if (source == replaceButton)
2281
+ {
2282
+ // Overwrite current version
2283
+ Replace();
22302284 } else
22312285 if (source == redoButton)
22322286 {
2287
+ // Go to next version
22332288 Redo();
22342289 } else
22352290 if (source == saveButton)
22362291 {
2292
+ // Save a new version
22372293 if (!Save(true))
22382294 java.awt.Toolkit.getDefaultToolkit().beep();
22392295 } else
....@@ -2615,7 +2671,7 @@
26152671 {
26162672 StepAll();
26172673 } else
2618
- if (source == clearItem) // || event.getSource() == clearButton)
2674
+ if (source == deleteItem) // || event.getSource() == clearButton)
26192675 {
26202676 //int indices[] = jList.getSelectedIndices();
26212677 //for (int i = indices.length - 1; i >= 0; i--)
....@@ -3479,6 +3535,9 @@
34793535 }
34803536
34813537 copy = group;
3538
+
3539
+ SetUndoStates();
3540
+
34823541 //Globals.theRenderer.object = group;
34833542 if(!useclient)
34843543 {
....@@ -3507,8 +3566,10 @@
35073566 radio.layout.doClick();
35083567
35093568 ClearUnpinned();
3510
- SetPinStates(group.selection.size() > 0);
3511
- if (group.selection.size() == 1)
3569
+ //Grafreed.Assert(group != null);
3570
+ //Grafreed.Assert(group.selection != null);
3571
+ SetPinStates(group.selection == null || group.selection.size() > 0);
3572
+ if (group.selection == null || group.selection.size() == 1)
35123573 EditSelection(false);
35133574 keepparent = group.parent;
35143575 // PARENT = NULL or not???
....@@ -4102,7 +4163,7 @@
41024163
41034164 try
41044165 {
4105
- texturedata = Globals.theRenderer.GetTextureData(pigment, false, node.texres);
4166
+ texturedata = Globals.theRenderer.GetTextureData(tex.pigmenttexture, pigment, false, node.texres);
41064167 }
41074168 catch (Exception e)
41084169 {
....@@ -4579,6 +4640,12 @@
45794640
45804641 void EditSelection(boolean newWindow)
45814642 {
4643
+ if (group.selection == null)
4644
+ {
4645
+ EditElement(group, newWindow); // ? new
4646
+ return;
4647
+ }
4648
+
45824649 // aConstraints.gridy = 0;
45834650 for (int i=0; i<group.selection.size(); i++)
45844651 {
....@@ -4589,12 +4656,7 @@
45894656 Object3D elem = (Object3D)group.selection.elementAt(i);
45904657 if(elem != group || !newWindow)
45914658 {
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
4659
+ EditElement(elem, newWindow); // ? new
45984660 }
45994661 }
46004662 }
....@@ -4738,7 +4800,7 @@
47384800
47394801 void refreshContents(boolean cp)
47404802 {
4741
- if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Info"))
4803
+ if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
47424804 if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
47434805 {
47444806 objEditor.ClearInfo(); // .GetMaterial());
....@@ -4942,10 +5004,10 @@
49425004
49435005 void paste(boolean expand)
49445006 {
4945
- if (Globals.SAVEONMAKE)
5007
+ if (Globals.REPLACEONMAKE)
49465008 Save();
4947
- boolean keep = Globals.SAVEONMAKE;
4948
- Globals.SAVEONMAKE = false;
5009
+ boolean keep = Globals.REPLACEONMAKE;
5010
+ Globals.REPLACEONMAKE = false;
49495011 // if (GrafreeD.clipboard == null)
49505012 // return;
49515013 boolean first = true;
....@@ -5005,7 +5067,7 @@
50055067 Grafreed.clipboard.get(0).parent = keepparent;
50065068 }
50075069
5008
- Globals.SAVEONMAKE = keep;
5070
+ Globals.REPLACEONMAKE = keep;
50095071 ResetModel();
50105072 refreshContents();
50115073 }
....@@ -5141,10 +5203,10 @@
51415203
51425204 void group(Object3D csg, boolean grab)
51435205 {
5144
- if (Globals.SAVEONMAKE)
5206
+ if (Globals.REPLACEONMAKE)
51455207 Save();
5146
- boolean keep = Globals.SAVEONMAKE;
5147
- Globals.SAVEONMAKE = false;
5208
+ boolean keep = Globals.REPLACEONMAKE;
5209
+ Globals.REPLACEONMAKE = false;
51485210 if (//false) // why??
51495211 !group.selection.isEmpty())
51505212 {
....@@ -5258,15 +5320,15 @@
52585320 //node.add(csg);
52595321 //makeSomething(node);
52605322 makeSomething(csg);
5261
- Globals.SAVEONMAKE = keep;
5323
+ Globals.REPLACEONMAKE = keep;
52625324 }
52635325
52645326 void Ungroup(Object3D g)
52655327 {
5266
- if (Globals.SAVEONMAKE)
5328
+ if (Globals.REPLACEONMAKE)
52675329 Save();
5268
- boolean keep = Globals.SAVEONMAKE;
5269
- Globals.SAVEONMAKE = false;
5330
+ boolean keep = Globals.REPLACEONMAKE;
5331
+ Globals.REPLACEONMAKE = false;
52705332 if (g instanceof HiddenObject)
52715333 {
52725334 HiddenObject h = (HiddenObject) g;
....@@ -5283,7 +5345,7 @@
52835345 objEditor.makeSomething(g.get(i), false);
52845346 }
52855347 }
5286
- Globals.SAVEONMAKE = keep;
5348
+ Globals.REPLACEONMAKE = keep;
52875349 }
52885350
52895351 void ungroup()
....@@ -5647,7 +5709,7 @@
56475709 private MenuItem pasteLinkItem;
56485710 private MenuItem pasteCloneItem;
56495711 private MenuItem pasteExpandItem;
5650
- private MenuItem clearItem;
5712
+ private MenuItem deleteItem;
56515713 private MenuItem clearAllItem;
56525714 private MenuItem genUVItem;
56535715 private MenuItem genNormalsMESHItem;