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,6 +96,10 @@
8496
8597 void CloneSelection(boolean supports)
8698 {
99
+ if (Globals.REPLACEONMAKE)
100
+ Save();
101
+ boolean keep = Globals.REPLACEONMAKE;
102
+ Globals.REPLACEONMAKE = false;
87103 // Object3D keep = GrafreeD.clipboard;
88104 //Object3D obj;
89105 for (int i=0; i<group.selection.size(); i++)// Enumeration e = group.selection.elements(); e.hasMoreElements();)
....@@ -94,6 +110,7 @@
94110
95111 makeSomething(clone, i==group.selection.size()-1);
96112 }
113
+ Globals.REPLACEONMAKE = keep;
97114 }
98115
99116 void CloneClipboard(boolean supports)
....@@ -189,8 +206,8 @@
189206 // pasteExpandItem = menu.add(new MenuItem("Paste expand"));
190207 // pasteExpandItem.addActionListener(this);
191208 menu.add("-");
192
- clearItem = menu.add(new MenuItem("Clear"));
193
- clearItem.addActionListener(this);
209
+ deleteItem = menu.add(new MenuItem("Delete"));
210
+ deleteItem.addActionListener(this);
194211
195212 if (Globals.ADVANCED)
196213 {
....@@ -380,13 +397,14 @@
380397 shadowYItem.addActionListener(this);
381398 shadowZItem = menu.add(new MenuItem("Shadow Blue"));
382399 shadowZItem.addActionListener(this);
400
+ attributeItem = menu.add(new MenuItem("Attribute"));
401
+ attributeItem.addActionListener(this);
402
+
383403 if (Globals.ADVANCED)
384404 {
385405 menu.add("-");
386406 linkerItem = menu.add(new MenuItem("Linker"));
387407 linkerItem.addActionListener(this);
388
- attributeItem = menu.add(new MenuItem("Attribute"));
389
- attributeItem.addActionListener(this);
390408 templateItem = menu.add(new MenuItem("Template"));
391409 templateItem.addActionListener(this);
392410 pointflowItem = menu.add(new MenuItem("Point Flow"));
....@@ -415,7 +433,7 @@
415433 genNormalsMESHItem.addActionListener(this);
416434 if (Globals.ADVANCED)
417435 {
418
- genNormalsMINEItem = menu.add(new MenuItem("My Normals"));
436
+ genNormalsMINEItem = menu.add(new MenuItem("Stitch Normals"));
419437 genNormalsMINEItem.addActionListener(this);
420438 }
421439 stripifyItem = menu.add(new MenuItem("Stripify"));
....@@ -538,6 +556,7 @@
538556 buildToolsMenu(menu);
539557 }
540558
559
+
541560 void SetupUI2(ObjEditor oe)
542561 {
543562 // June 2019
....@@ -601,42 +620,55 @@
601620 fullButton.setToolTipText("Full-screen window");
602621 fullButton.addActionListener(this);
603622
623
+ oe.toolbarPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
624
+ screenfitButton.setToolTipText("Screen fit");
625
+ screenfitButton.addActionListener(this);
626
+
604627 oe.toolbarPanel.add(restoreCameraButton = GetButton("icons/eye.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
605628 restoreCameraButton.setToolTipText("Restore viewpoint");
606629 restoreCameraButton.addActionListener(this);
607630
631
+ copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
632
+ saveButton.setToolTipText("New version");
633
+ saveButton.addActionListener(this);
634
+
608635 copyOptionsPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
609
- undoButton.setToolTipText("Undo changes");
636
+ undoButton.setToolTipText("Previous version");
610637 undoButton.addActionListener(this);
611638 undoButton.setEnabled(false);
612639
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
+
613653 copyOptionsPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
614
- redoButton.setToolTipText("Redo changes");
654
+ redoButton.setToolTipText("Next version");
615655 redoButton.addActionListener(this);
616656 redoButton.setEnabled(false);
617657
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);
658
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
623659 liveCB.setToolTipText("Enable animation");
624660 liveCB.addItemListener(this);
625661
626
- copyOptionsPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
662
+ oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
627663 oneStepButton.setToolTipText("Animate one step forward");
628664 oneStepButton.addActionListener(this);
629665
630
- copyOptionsPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
666
+ oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
631667 fastCB.setToolTipText("Fast mode");
632668 fastCB.addItemListener(this);
633669
634670 //oe.toolboxPanel.Return();
635671
636
- copyOptionsPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
637
- screenfitButton.setToolTipText("Screen fit");
638
- screenfitButton.addActionListener(this);
639
-
640672 // copyOptionsPanel.add(trackCB = GetToggleButton("icons/track.png", CameraPane.TRACK)); //, oe.aConstraints);
641673 // trackCB.setToolTipText("Enable tracking");
642674 // trackCB.addItemListener(this);
....@@ -653,27 +685,28 @@
653685
654686 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
655687
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
-
661688 oe.toolbarPanel.add(fourButton = new cButton("-||", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
662689 fourButton.addActionListener(this);
663690 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
+
664697 oe.toolbarPanel.add(sixButton = new cButton("-|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
665
- sixButton.setToolTipText("2-column layout left");
698
+ sixButton.setToolTipText("Show left and right");
666699 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);
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);
673706 //
674707
675
- oe.toolbarPanel.add(rootButton = GetButton("icons/write.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
676
- 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");
677710 rootButton.addActionListener(this);
678711
679712 oe.toolbarPanel.add(closeButton = GetButton("icons/close-icon.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -814,6 +847,9 @@
814847
815848 oe.treePanel.add(copyOptionsPanel);
816849 oe.treePanel.Return();
850
+ cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
851
+ versionSlider = (cNumberSlider)sliderPane.getComponent(1);
852
+ sliderPane.preferredHeight = 1;
817853
818854 // mainPanel.setDividerLocation(0.5); //1.0);
819855 // mainPanel.setResizeWeight(0.5);
....@@ -836,7 +872,7 @@
836872 dgr.addDragGestureListener(this);
837873 }catch(Exception e) {}
838874 */
839
- radio.layout = sevenButton;
875
+ radio.layout = sixButton; // sevenButton;
840876 oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
841877 }
842878
....@@ -939,9 +975,9 @@
939975 toggleSwitchCB.setToolTipText("Choose a single item");
940976 toggleSwitchCB.addItemListener(this);
941977
942
- panel.add(autosaveCB = new cCheckBox("Auto-save", Globals.SAVEONMAKE)); //, constraints);
943
- autosaveCB.setToolTipText("On structure change");
944
- autosaveCB.addItemListener(this);
978
+ panel.add(autokeepCB = new cCheckBox("Auto-replace", Globals.REPLACEONMAKE)); //, constraints);
979
+ autokeepCB.setToolTipText("On structure change");
980
+ autokeepCB.addItemListener(this);
945981
946982 panel.Return();
947983 if (Globals.ADVANCED)
....@@ -970,7 +1006,7 @@
9701006 {
9711007 cRadio radioButton = new cRadio(obj.name);
9721008
973
- // Patch to avoid bug with transparency.
1009
+ // June 2019. Patch to avoid bug with transparency.
9741010 radioButton.hadMaterial = obj.material != null;
9751011 if (!radioButton.hadMaterial)
9761012 {
....@@ -978,7 +1014,7 @@
9781014 }
9791015
9801016 radioButton.SetObject(obj);
981
- radioButton.layout = sevenButton;
1017
+ radioButton.layout = sixButton; // sevenButton;
9821018 radioButton.SetCamera(cameraView.renderCamera, false);
9831019 radioButton.addActionListener(this);
9841020 radioPanel.add(radioButton);
....@@ -1018,7 +1054,7 @@
10181054
10191055 cCheckBox oeilCB;
10201056 cCheckBox shadowCB;
1021
- cCheckBox autosaveCB;
1057
+ cCheckBox autokeepCB;
10221058 cCheckBox lookAtCB;
10231059
10241060 // static int COLOR = 1;
....@@ -1130,9 +1166,9 @@
11301166 {
11311167 Globals.FREEZEONMOVE ^= true;
11321168 }
1133
- else if(e.getSource() == autosaveCB)
1169
+ else if(e.getSource() == autokeepCB)
11341170 {
1135
- Globals.SAVEONMAKE ^= true;
1171
+ Globals.REPLACEONMAKE ^= true;
11361172 }
11371173 else if(e.getSource() == lookAtCB)
11381174 {
....@@ -1214,8 +1250,6 @@
12141250 }
12151251 }
12161252
1217
- String string = (String) object;
1218
-
12191253 System.out.println("Transfer = " + object + "; drop : " + target);
12201254 // if( object instanceof java.io.File[])
12211255 // {
....@@ -1223,6 +1257,8 @@
12231257 // objEditor.DropFile((java.io.File[]) object, true);
12241258 // return;
12251259 // }
1260
+
1261
+ String string = object.toString();
12261262
12271263 // File path for Mac and Windows
12281264 if (string.charAt(0) == '/' || string.charAt(1) == ':')
....@@ -1487,6 +1523,8 @@
14871523 reduce34MorphItem = menu.add(new MenuItem("Reduce Morphs (34)"));
14881524 reduce34MorphItem.addActionListener(this);
14891525 menu.add("-");
1526
+ menu.add(memoryItem = new MenuItem("Memory Usage"));
1527
+ memoryItem.addActionListener(this);
14901528 menu.add(computeAOItem = new MenuItem("Compute AO"));
14911529 computeAOItem.addActionListener(this);
14921530
....@@ -1495,8 +1533,6 @@
14951533 mirrorItem = menu.add(new MenuItem("Mirror Poses"));
14961534 mirrorItem.addActionListener(this);
14971535 menu.add("-");
1498
- menu.add(memoryItem = new MenuItem("Memory Usage"));
1499
- memoryItem.addActionListener(this);
15001536 menu.add(analyzeItem = new MenuItem("Analyze"));
15011537 analyzeItem.addActionListener(this);
15021538 menu.add(dumpItem = new MenuItem("Print"));
....@@ -1657,6 +1693,16 @@
16571693 listUI.remove(i);
16581694 }
16591695 }
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
16601706 }
16611707
16621708 /**
....@@ -2219,15 +2265,31 @@
22192265 } else
22202266 if (source == undoButton)
22212267 {
2268
+ // Go to previous version
2269
+ //if (!Undo())
2270
+ //java.awt.Toolkit.getDefaultToolkit().beep();
22222271 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();
22232282 } else
22242283 if (source == redoButton)
22252284 {
2285
+ // Go to next version
22262286 Redo();
22272287 } else
22282288 if (source == saveButton)
22292289 {
2230
- Save();
2290
+ // Save a new version
2291
+ if (!Save(true))
2292
+ java.awt.Toolkit.getDefaultToolkit().beep();
22312293 } else
22322294 if (source == oneStepButton)
22332295 {
....@@ -2236,17 +2298,14 @@
22362298 } else
22372299 if (source == screenfitButton)
22382300 {
2239
- //Reload(lastConverter, lastFilename, true);
22402301 ScreenFit();
22412302 } else
22422303 if (source == screenfitpointButton)
22432304 {
2244
- //Reload(lastConverter, lastFilename, true);
22452305 ScreenFitPoint();
22462306 } else
22472307 if (source == snapobjectButton)
22482308 {
2249
- //Reload(lastConverter, lastFilename, true);
22502309 SnapObject();
22512310 } else
22522311 // if (event.getSource() == recompileButton)
....@@ -2610,7 +2669,7 @@
26102669 {
26112670 StepAll();
26122671 } else
2613
- if (source == clearItem) // || event.getSource() == clearButton)
2672
+ if (source == deleteItem) // || event.getSource() == clearButton)
26142673 {
26152674 //int indices[] = jList.getSelectedIndices();
26162675 //for (int i = indices.length - 1; i >= 0; i--)
....@@ -3474,6 +3533,9 @@
34743533 }
34753534
34763535 copy = group;
3536
+
3537
+ SetUndoStates();
3538
+
34773539 //Globals.theRenderer.object = group;
34783540 if(!useclient)
34793541 {
....@@ -3502,8 +3564,10 @@
35023564 radio.layout.doClick();
35033565
35043566 ClearUnpinned();
3505
- SetPinStates(group.selection.size() > 0);
3506
- 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)
35073571 EditSelection(false);
35083572 keepparent = group.parent;
35093573 // PARENT = NULL or not???
....@@ -4574,6 +4638,12 @@
45744638
45754639 void EditSelection(boolean newWindow)
45764640 {
4641
+ if (group.selection == null)
4642
+ {
4643
+ EditElement(group, newWindow); // ? new
4644
+ return;
4645
+ }
4646
+
45774647 // aConstraints.gridy = 0;
45784648 for (int i=0; i<group.selection.size(); i++)
45794649 {
....@@ -4584,12 +4654,7 @@
45844654 Object3D elem = (Object3D)group.selection.elementAt(i);
45854655 if(elem != group || !newWindow)
45864656 {
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
4657
+ EditElement(elem, newWindow); // ? new
45934658 }
45944659 }
45954660 }
....@@ -4833,8 +4898,8 @@
48334898
48344899 if (cut)
48354900 {
4836
- if (Globals.SAVEONMAKE)
4837
- Save();
4901
+// if (Globals.SAVEONMAKE) // Moved to the clipboard, no need to save.
4902
+// Save();
48384903 //int indices[] = jList.getSelectedIndices();
48394904 //for (int i = indices.length - 1; i >= 0; i--)
48404905 //jList.remove(indices[i]);
....@@ -4937,6 +5002,10 @@
49375002
49385003 void paste(boolean expand)
49395004 {
5005
+ if (Globals.REPLACEONMAKE)
5006
+ Save();
5007
+ boolean keep = Globals.REPLACEONMAKE;
5008
+ Globals.REPLACEONMAKE = false;
49405009 // if (GrafreeD.clipboard == null)
49415010 // return;
49425011 boolean first = true;
....@@ -4996,6 +5065,7 @@
49965065 Grafreed.clipboard.get(0).parent = keepparent;
49975066 }
49985067
5068
+ Globals.REPLACEONMAKE = keep;
49995069 ResetModel();
50005070 refreshContents();
50015071 }
....@@ -5131,6 +5201,10 @@
51315201
51325202 void group(Object3D csg, boolean grab)
51335203 {
5204
+ if (Globals.REPLACEONMAKE)
5205
+ Save();
5206
+ boolean keep = Globals.REPLACEONMAKE;
5207
+ Globals.REPLACEONMAKE = false;
51345208 if (//false) // why??
51355209 !group.selection.isEmpty())
51365210 {
....@@ -5244,10 +5318,15 @@
52445318 //node.add(csg);
52455319 //makeSomething(node);
52465320 makeSomething(csg);
5321
+ Globals.REPLACEONMAKE = keep;
52475322 }
52485323
52495324 void Ungroup(Object3D g)
52505325 {
5326
+ if (Globals.REPLACEONMAKE)
5327
+ Save();
5328
+ boolean keep = Globals.REPLACEONMAKE;
5329
+ Globals.REPLACEONMAKE = false;
52515330 if (g instanceof HiddenObject)
52525331 {
52535332 HiddenObject h = (HiddenObject) g;
....@@ -5264,6 +5343,7 @@
52645343 objEditor.makeSomething(g.get(i), false);
52655344 }
52665345 }
5346
+ Globals.REPLACEONMAKE = keep;
52675347 }
52685348
52695349 void ungroup()
....@@ -5627,7 +5707,7 @@
56275707 private MenuItem pasteLinkItem;
56285708 private MenuItem pasteCloneItem;
56295709 private MenuItem pasteExpandItem;
5630
- private MenuItem clearItem;
5710
+ private MenuItem deleteItem;
56315711 private MenuItem clearAllItem;
56325712 private MenuItem genUVItem;
56335713 private MenuItem genNormalsMESHItem;