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,10 +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 {
101
+ if (Globals.REPLACEONMAKE)
102
+ Save();
103
+ boolean keep = Globals.REPLACEONMAKE;
104
+ Globals.REPLACEONMAKE = false;
87105 // Object3D keep = GrafreeD.clipboard;
88106 //Object3D obj;
89107 for (int i=0; i<group.selection.size(); i++)// Enumeration e = group.selection.elements(); e.hasMoreElements();)
....@@ -94,6 +112,7 @@
94112
95113 makeSomething(clone, i==group.selection.size()-1);
96114 }
115
+ Globals.REPLACEONMAKE = keep;
97116 }
98117
99118 void CloneClipboard(boolean supports)
....@@ -189,8 +208,8 @@
189208 // pasteExpandItem = menu.add(new MenuItem("Paste expand"));
190209 // pasteExpandItem.addActionListener(this);
191210 menu.add("-");
192
- clearItem = menu.add(new MenuItem("Clear"));
193
- clearItem.addActionListener(this);
211
+ deleteItem = menu.add(new MenuItem("Delete"));
212
+ deleteItem.addActionListener(this);
194213
195214 if (Globals.ADVANCED)
196215 {
....@@ -380,13 +399,14 @@
380399 shadowYItem.addActionListener(this);
381400 shadowZItem = menu.add(new MenuItem("Shadow Blue"));
382401 shadowZItem.addActionListener(this);
402
+ attributeItem = menu.add(new MenuItem("Attribute"));
403
+ attributeItem.addActionListener(this);
404
+
383405 if (Globals.ADVANCED)
384406 {
385407 menu.add("-");
386408 linkerItem = menu.add(new MenuItem("Linker"));
387409 linkerItem.addActionListener(this);
388
- attributeItem = menu.add(new MenuItem("Attribute"));
389
- attributeItem.addActionListener(this);
390410 templateItem = menu.add(new MenuItem("Template"));
391411 templateItem.addActionListener(this);
392412 pointflowItem = menu.add(new MenuItem("Point Flow"));
....@@ -415,7 +435,7 @@
415435 genNormalsMESHItem.addActionListener(this);
416436 if (Globals.ADVANCED)
417437 {
418
- genNormalsMINEItem = menu.add(new MenuItem("My Normals"));
438
+ genNormalsMINEItem = menu.add(new MenuItem("Stitch Normals"));
419439 genNormalsMINEItem.addActionListener(this);
420440 }
421441 stripifyItem = menu.add(new MenuItem("Stripify"));
....@@ -538,6 +558,7 @@
538558 buildToolsMenu(menu);
539559 }
540560
561
+
541562 void SetupUI2(ObjEditor oe)
542563 {
543564 // June 2019
....@@ -601,42 +622,55 @@
601622 fullButton.setToolTipText("Full-screen window");
602623 fullButton.addActionListener(this);
603624
625
+ oe.toolbarPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
626
+ screenfitButton.setToolTipText("Screen fit");
627
+ screenfitButton.addActionListener(this);
628
+
604629 oe.toolbarPanel.add(restoreCameraButton = GetButton("icons/eye.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
605630 restoreCameraButton.setToolTipText("Restore viewpoint");
606631 restoreCameraButton.addActionListener(this);
607632
633
+ copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
634
+ saveButton.setToolTipText("New version");
635
+ saveButton.addActionListener(this);
636
+
608637 copyOptionsPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
609
- undoButton.setToolTipText("Undo changes");
638
+ undoButton.setToolTipText("Previous version");
610639 undoButton.addActionListener(this);
611640 undoButton.setEnabled(false);
612641
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
+
613655 copyOptionsPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
614
- redoButton.setToolTipText("Redo changes");
656
+ redoButton.setToolTipText("Next version");
615657 redoButton.addActionListener(this);
616658 redoButton.setEnabled(false);
617659
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);
660
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
623661 liveCB.setToolTipText("Enable animation");
624662 liveCB.addItemListener(this);
625663
626
- copyOptionsPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
664
+ oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
627665 oneStepButton.setToolTipText("Animate one step forward");
628666 oneStepButton.addActionListener(this);
629667
630
- copyOptionsPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
668
+ oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
631669 fastCB.setToolTipText("Fast mode");
632670 fastCB.addItemListener(this);
633671
634672 //oe.toolboxPanel.Return();
635673
636
- copyOptionsPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
637
- screenfitButton.setToolTipText("Screen fit");
638
- screenfitButton.addActionListener(this);
639
-
640674 // copyOptionsPanel.add(trackCB = GetToggleButton("icons/track.png", CameraPane.TRACK)); //, oe.aConstraints);
641675 // trackCB.setToolTipText("Enable tracking");
642676 // trackCB.addItemListener(this);
....@@ -653,27 +687,28 @@
653687
654688 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
655689
656
- oe.toolbarPanel.add(twoButton = new cButton("|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
657
- twoButton.setToolTipText("Show center view only");
658
- twoButton.addActionListener(this);
659
- this.fullscreenLayout = twoButton;
660
-
661690 oe.toolbarPanel.add(fourButton = new cButton("-||", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
662691 fourButton.addActionListener(this);
663692 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
+
664699 oe.toolbarPanel.add(sixButton = new cButton("-|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
665
- sixButton.setToolTipText("2-column layout left");
700
+ sixButton.setToolTipText("Show left and right");
666701 sixButton.addActionListener(this);
667
- oe.toolbarPanel.add(threeButton = new cButton("|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
668
- threeButton.setToolTipText("2-column layout right");
669
- threeButton.addActionListener(this);
670
- oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
671
- sevenButton.setToolTipText("3-column layout");
672
- 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);
673708 //
674709
675
- oe.toolbarPanel.add(rootButton = GetButton("icons/write.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
676
- 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");
677712 rootButton.addActionListener(this);
678713
679714 oe.toolbarPanel.add(closeButton = GetButton("icons/close-icon.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -814,6 +849,9 @@
814849
815850 oe.treePanel.add(copyOptionsPanel);
816851 oe.treePanel.Return();
852
+ cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
853
+ versionSlider = (cNumberSlider)sliderPane.getComponent(1);
854
+ sliderPane.preferredHeight = 1;
817855
818856 // mainPanel.setDividerLocation(0.5); //1.0);
819857 // mainPanel.setResizeWeight(0.5);
....@@ -836,7 +874,7 @@
836874 dgr.addDragGestureListener(this);
837875 }catch(Exception e) {}
838876 */
839
- radio.layout = sevenButton;
877
+ radio.layout = sixButton; // sevenButton;
840878 oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
841879 }
842880
....@@ -939,9 +977,9 @@
939977 toggleSwitchCB.setToolTipText("Choose a single item");
940978 toggleSwitchCB.addItemListener(this);
941979
942
- panel.add(autosaveCB = new cCheckBox("Auto-save", Globals.SAVEONMAKE)); //, constraints);
943
- autosaveCB.setToolTipText("On structure change");
944
- autosaveCB.addItemListener(this);
980
+ panel.add(autokeepCB = new cCheckBox("Auto-replace", Globals.REPLACEONMAKE)); //, constraints);
981
+ autokeepCB.setToolTipText("On structure change");
982
+ autokeepCB.addItemListener(this);
945983
946984 panel.Return();
947985 if (Globals.ADVANCED)
....@@ -970,7 +1008,7 @@
9701008 {
9711009 cRadio radioButton = new cRadio(obj.name);
9721010
973
- // Patch to avoid bug with transparency.
1011
+ // June 2019. Patch to avoid bug with transparency.
9741012 radioButton.hadMaterial = obj.material != null;
9751013 if (!radioButton.hadMaterial)
9761014 {
....@@ -978,7 +1016,7 @@
9781016 }
9791017
9801018 radioButton.SetObject(obj);
981
- radioButton.layout = sevenButton;
1019
+ radioButton.layout = sixButton; // sevenButton;
9821020 radioButton.SetCamera(cameraView.renderCamera, false);
9831021 radioButton.addActionListener(this);
9841022 radioPanel.add(radioButton);
....@@ -1018,7 +1056,7 @@
10181056
10191057 cCheckBox oeilCB;
10201058 cCheckBox shadowCB;
1021
- cCheckBox autosaveCB;
1059
+ cCheckBox autokeepCB;
10221060 cCheckBox lookAtCB;
10231061
10241062 // static int COLOR = 1;
....@@ -1130,9 +1168,9 @@
11301168 {
11311169 Globals.FREEZEONMOVE ^= true;
11321170 }
1133
- else if(e.getSource() == autosaveCB)
1171
+ else if(e.getSource() == autokeepCB)
11341172 {
1135
- Globals.SAVEONMAKE ^= true;
1173
+ Globals.REPLACEONMAKE ^= true;
11361174 }
11371175 else if(e.getSource() == lookAtCB)
11381176 {
....@@ -1214,8 +1252,6 @@
12141252 }
12151253 }
12161254
1217
- String string = (String) object;
1218
-
12191255 System.out.println("Transfer = " + object + "; drop : " + target);
12201256 // if( object instanceof java.io.File[])
12211257 // {
....@@ -1223,6 +1259,8 @@
12231259 // objEditor.DropFile((java.io.File[]) object, true);
12241260 // return;
12251261 // }
1262
+
1263
+ String string = object.toString();
12261264
12271265 // File path for Mac and Windows
12281266 if (string.charAt(0) == '/' || string.charAt(1) == ':')
....@@ -1487,6 +1525,8 @@
14871525 reduce34MorphItem = menu.add(new MenuItem("Reduce Morphs (34)"));
14881526 reduce34MorphItem.addActionListener(this);
14891527 menu.add("-");
1528
+ menu.add(memoryItem = new MenuItem("Memory Usage"));
1529
+ memoryItem.addActionListener(this);
14901530 menu.add(computeAOItem = new MenuItem("Compute AO"));
14911531 computeAOItem.addActionListener(this);
14921532
....@@ -1495,8 +1535,6 @@
14951535 mirrorItem = menu.add(new MenuItem("Mirror Poses"));
14961536 mirrorItem.addActionListener(this);
14971537 menu.add("-");
1498
- menu.add(memoryItem = new MenuItem("Memory Usage"));
1499
- memoryItem.addActionListener(this);
15001538 menu.add(analyzeItem = new MenuItem("Analyze"));
15011539 analyzeItem.addActionListener(this);
15021540 menu.add(dumpItem = new MenuItem("Print"));
....@@ -1657,6 +1695,16 @@
16571695 listUI.remove(i);
16581696 }
16591697 }
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
16601708 }
16611709
16621710 /**
....@@ -2219,15 +2267,31 @@
22192267 } else
22202268 if (source == undoButton)
22212269 {
2270
+ // Go to previous version
2271
+ //if (!Undo())
2272
+ //java.awt.Toolkit.getDefaultToolkit().beep();
22222273 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();
22232284 } else
22242285 if (source == redoButton)
22252286 {
2287
+ // Go to next version
22262288 Redo();
22272289 } else
22282290 if (source == saveButton)
22292291 {
2230
- Save();
2292
+ // Save a new version
2293
+ if (!Save(true))
2294
+ java.awt.Toolkit.getDefaultToolkit().beep();
22312295 } else
22322296 if (source == oneStepButton)
22332297 {
....@@ -2236,17 +2300,14 @@
22362300 } else
22372301 if (source == screenfitButton)
22382302 {
2239
- //Reload(lastConverter, lastFilename, true);
22402303 ScreenFit();
22412304 } else
22422305 if (source == screenfitpointButton)
22432306 {
2244
- //Reload(lastConverter, lastFilename, true);
22452307 ScreenFitPoint();
22462308 } else
22472309 if (source == snapobjectButton)
22482310 {
2249
- //Reload(lastConverter, lastFilename, true);
22502311 SnapObject();
22512312 } else
22522313 // if (event.getSource() == recompileButton)
....@@ -2610,7 +2671,7 @@
26102671 {
26112672 StepAll();
26122673 } else
2613
- if (source == clearItem) // || event.getSource() == clearButton)
2674
+ if (source == deleteItem) // || event.getSource() == clearButton)
26142675 {
26152676 //int indices[] = jList.getSelectedIndices();
26162677 //for (int i = indices.length - 1; i >= 0; i--)
....@@ -3474,6 +3535,9 @@
34743535 }
34753536
34763537 copy = group;
3538
+
3539
+ SetUndoStates();
3540
+
34773541 //Globals.theRenderer.object = group;
34783542 if(!useclient)
34793543 {
....@@ -3502,8 +3566,10 @@
35023566 radio.layout.doClick();
35033567
35043568 ClearUnpinned();
3505
- SetPinStates(group.selection.size() > 0);
3506
- 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)
35073573 EditSelection(false);
35083574 keepparent = group.parent;
35093575 // PARENT = NULL or not???
....@@ -4097,7 +4163,7 @@
40974163
40984164 try
40994165 {
4100
- texturedata = Globals.theRenderer.GetTextureData(pigment, false, node.texres);
4166
+ texturedata = Globals.theRenderer.GetTextureData(tex.pigmenttexture, pigment, false, node.texres);
41014167 }
41024168 catch (Exception e)
41034169 {
....@@ -4574,6 +4640,12 @@
45744640
45754641 void EditSelection(boolean newWindow)
45764642 {
4643
+ if (group.selection == null)
4644
+ {
4645
+ EditElement(group, newWindow); // ? new
4646
+ return;
4647
+ }
4648
+
45774649 // aConstraints.gridy = 0;
45784650 for (int i=0; i<group.selection.size(); i++)
45794651 {
....@@ -4584,12 +4656,7 @@
45844656 Object3D elem = (Object3D)group.selection.elementAt(i);
45854657 if(elem != group || !newWindow)
45864658 {
4587
- // if (!(elem instanceof Composite))
4588
- // newWindow = false;
4589
- listUI.add(elem);
4590
- elem.openEditWindow(this, newWindow); //, false);
4591
- System.out.println("edit : " + elem);
4592
- elem.editWindow.refreshContents(true); // ? new
4659
+ EditElement(elem, newWindow); // ? new
45934660 }
45944661 }
45954662 }
....@@ -4733,7 +4800,7 @@
47334800
47344801 void refreshContents(boolean cp)
47354802 {
4736
- if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Info"))
4803
+ if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
47374804 if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
47384805 {
47394806 objEditor.ClearInfo(); // .GetMaterial());
....@@ -4833,8 +4900,8 @@
48334900
48344901 if (cut)
48354902 {
4836
- if (Globals.SAVEONMAKE)
4837
- Save();
4903
+// if (Globals.SAVEONMAKE) // Moved to the clipboard, no need to save.
4904
+// Save();
48384905 //int indices[] = jList.getSelectedIndices();
48394906 //for (int i = indices.length - 1; i >= 0; i--)
48404907 //jList.remove(indices[i]);
....@@ -4937,6 +5004,10 @@
49375004
49385005 void paste(boolean expand)
49395006 {
5007
+ if (Globals.REPLACEONMAKE)
5008
+ Save();
5009
+ boolean keep = Globals.REPLACEONMAKE;
5010
+ Globals.REPLACEONMAKE = false;
49405011 // if (GrafreeD.clipboard == null)
49415012 // return;
49425013 boolean first = true;
....@@ -4996,6 +5067,7 @@
49965067 Grafreed.clipboard.get(0).parent = keepparent;
49975068 }
49985069
5070
+ Globals.REPLACEONMAKE = keep;
49995071 ResetModel();
50005072 refreshContents();
50015073 }
....@@ -5131,6 +5203,10 @@
51315203
51325204 void group(Object3D csg, boolean grab)
51335205 {
5206
+ if (Globals.REPLACEONMAKE)
5207
+ Save();
5208
+ boolean keep = Globals.REPLACEONMAKE;
5209
+ Globals.REPLACEONMAKE = false;
51345210 if (//false) // why??
51355211 !group.selection.isEmpty())
51365212 {
....@@ -5244,10 +5320,15 @@
52445320 //node.add(csg);
52455321 //makeSomething(node);
52465322 makeSomething(csg);
5323
+ Globals.REPLACEONMAKE = keep;
52475324 }
52485325
52495326 void Ungroup(Object3D g)
52505327 {
5328
+ if (Globals.REPLACEONMAKE)
5329
+ Save();
5330
+ boolean keep = Globals.REPLACEONMAKE;
5331
+ Globals.REPLACEONMAKE = false;
52515332 if (g instanceof HiddenObject)
52525333 {
52535334 HiddenObject h = (HiddenObject) g;
....@@ -5264,6 +5345,7 @@
52645345 objEditor.makeSomething(g.get(i), false);
52655346 }
52665347 }
5348
+ Globals.REPLACEONMAKE = keep;
52675349 }
52685350
52695351 void ungroup()
....@@ -5627,7 +5709,7 @@
56275709 private MenuItem pasteLinkItem;
56285710 private MenuItem pasteCloneItem;
56295711 private MenuItem pasteExpandItem;
5630
- private MenuItem clearItem;
5712
+ private MenuItem deleteItem;
56315713 private MenuItem clearAllItem;
56325714 private MenuItem genUVItem;
56335715 private MenuItem genNormalsMESHItem;