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
....@@ -590,50 +609,66 @@
590609 //minButton.setToolTipText("Minimize window");
591610 //minButton.addActionListener(this);
592611
593
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
594
- maxButton.setToolTipText("Maximize window");
595
- maxButton.addActionListener(this);
612
+ if (Globals.ADVANCED)
613
+ {
614
+ oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
615
+ maxButton.setToolTipText("Maximize window");
616
+ maxButton.addActionListener(this);
617
+ }
596618
597619 oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
598620 fullButton.setToolTipText("Full-screen window");
599621 fullButton.addActionListener(this);
600622
623
+ oe.toolbarPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
624
+ screenfitButton.setToolTipText("Screen fit");
625
+ screenfitButton.addActionListener(this);
626
+
601627 oe.toolbarPanel.add(restoreCameraButton = GetButton("icons/eye.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
602628 restoreCameraButton.setToolTipText("Restore viewpoint");
603629 restoreCameraButton.addActionListener(this);
604630
631
+ copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
632
+ saveButton.setToolTipText("New version");
633
+ saveButton.addActionListener(this);
634
+
605635 copyOptionsPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
606
- undoButton.setToolTipText("Undo changes");
636
+ undoButton.setToolTipText("Previous version");
607637 undoButton.addActionListener(this);
608638 undoButton.setEnabled(false);
609639
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
+
610653 copyOptionsPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
611
- redoButton.setToolTipText("Redo changes");
654
+ redoButton.setToolTipText("Next version");
612655 redoButton.addActionListener(this);
613656 redoButton.setEnabled(false);
614657
615
- copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
616
- saveButton.setToolTipText("Save changes");
617
- saveButton.addActionListener(this);
618
-
619
- copyOptionsPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
658
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
620659 liveCB.setToolTipText("Enable animation");
621660 liveCB.addItemListener(this);
622661
623
- copyOptionsPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
662
+ oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
624663 oneStepButton.setToolTipText("Animate one step forward");
625664 oneStepButton.addActionListener(this);
626665
627
- copyOptionsPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
666
+ oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
628667 fastCB.setToolTipText("Fast mode");
629668 fastCB.addItemListener(this);
630669
631670 //oe.toolboxPanel.Return();
632671
633
- copyOptionsPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
634
- screenfitButton.setToolTipText("Screen fit");
635
- screenfitButton.addActionListener(this);
636
-
637672 // copyOptionsPanel.add(trackCB = GetToggleButton("icons/track.png", CameraPane.TRACK)); //, oe.aConstraints);
638673 // trackCB.setToolTipText("Enable tracking");
639674 // trackCB.addItemListener(this);
....@@ -650,27 +685,28 @@
650685
651686 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
652687
653
- oe.toolbarPanel.add(twoButton = new cButton("|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
654
- twoButton.setToolTipText("Show center view only");
655
- twoButton.addActionListener(this);
656
- this.fullscreenLayout = twoButton;
657
-
658688 oe.toolbarPanel.add(fourButton = new cButton("-||", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
659689 fourButton.addActionListener(this);
660690 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
+
661697 oe.toolbarPanel.add(sixButton = new cButton("-|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
662
- sixButton.setToolTipText("2-column layout left");
698
+ sixButton.setToolTipText("Show left and right");
663699 sixButton.addActionListener(this);
664
- oe.toolbarPanel.add(threeButton = new cButton("|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
665
- threeButton.setToolTipText("2-column layout right");
666
- threeButton.addActionListener(this);
667
- oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
668
- sevenButton.setToolTipText("3-column layout");
669
- 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);
670706 //
671707
672
- oe.toolbarPanel.add(rootButton = GetButton("icons/write.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
673
- 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");
674710 rootButton.addActionListener(this);
675711
676712 oe.toolbarPanel.add(closeButton = GetButton("icons/close-icon.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -811,6 +847,9 @@
811847
812848 oe.treePanel.add(copyOptionsPanel);
813849 oe.treePanel.Return();
850
+ cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
851
+ versionSlider = (cNumberSlider)sliderPane.getComponent(1);
852
+ sliderPane.preferredHeight = 1;
814853
815854 // mainPanel.setDividerLocation(0.5); //1.0);
816855 // mainPanel.setResizeWeight(0.5);
....@@ -833,7 +872,7 @@
833872 dgr.addDragGestureListener(this);
834873 }catch(Exception e) {}
835874 */
836
- radio.layout = sevenButton;
875
+ radio.layout = sixButton; // sevenButton;
837876 oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
838877 }
839878
....@@ -936,9 +975,9 @@
936975 toggleSwitchCB.setToolTipText("Choose a single item");
937976 toggleSwitchCB.addItemListener(this);
938977
939
- panel.add(autosaveCB = new cCheckBox("Auto-save", Globals.SAVEONMAKE)); //, constraints);
940
- autosaveCB.setToolTipText("On structure change");
941
- autosaveCB.addItemListener(this);
978
+ panel.add(autokeepCB = new cCheckBox("Auto-replace", Globals.REPLACEONMAKE)); //, constraints);
979
+ autokeepCB.setToolTipText("On structure change");
980
+ autokeepCB.addItemListener(this);
942981
943982 panel.Return();
944983 if (Globals.ADVANCED)
....@@ -967,7 +1006,7 @@
9671006 {
9681007 cRadio radioButton = new cRadio(obj.name);
9691008
970
- // Patch to avoid bug with transparency.
1009
+ // June 2019. Patch to avoid bug with transparency.
9711010 radioButton.hadMaterial = obj.material != null;
9721011 if (!radioButton.hadMaterial)
9731012 {
....@@ -975,7 +1014,7 @@
9751014 }
9761015
9771016 radioButton.SetObject(obj);
978
- radioButton.layout = sevenButton;
1017
+ radioButton.layout = sixButton; // sevenButton;
9791018 radioButton.SetCamera(cameraView.renderCamera, false);
9801019 radioButton.addActionListener(this);
9811020 radioPanel.add(radioButton);
....@@ -1015,7 +1054,7 @@
10151054
10161055 cCheckBox oeilCB;
10171056 cCheckBox shadowCB;
1018
- cCheckBox autosaveCB;
1057
+ cCheckBox autokeepCB;
10191058 cCheckBox lookAtCB;
10201059
10211060 // static int COLOR = 1;
....@@ -1127,9 +1166,9 @@
11271166 {
11281167 Globals.FREEZEONMOVE ^= true;
11291168 }
1130
- else if(e.getSource() == autosaveCB)
1169
+ else if(e.getSource() == autokeepCB)
11311170 {
1132
- Globals.SAVEONMAKE ^= true;
1171
+ Globals.REPLACEONMAKE ^= true;
11331172 }
11341173 else if(e.getSource() == lookAtCB)
11351174 {
....@@ -1211,8 +1250,6 @@
12111250 }
12121251 }
12131252
1214
- String string = (String) object;
1215
-
12161253 System.out.println("Transfer = " + object + "; drop : " + target);
12171254 // if( object instanceof java.io.File[])
12181255 // {
....@@ -1220,6 +1257,8 @@
12201257 // objEditor.DropFile((java.io.File[]) object, true);
12211258 // return;
12221259 // }
1260
+
1261
+ String string = object.toString();
12231262
12241263 // File path for Mac and Windows
12251264 if (string.charAt(0) == '/' || string.charAt(1) == ':')
....@@ -1469,6 +1508,9 @@
14691508 animationItem.addItemListener(this);
14701509 animationItem.setState(Globals.ANIMATION);
14711510
1511
+ menu.add(archiveItem = new MenuItem("Archive3D..."));
1512
+ archiveItem.addActionListener(this);
1513
+
14721514 menu.add("-");
14731515 parseverticesItem = menu.add(new MenuItem("Multiplicity"));
14741516 parseverticesItem.addActionListener(this);
....@@ -1481,6 +1523,8 @@
14811523 reduce34MorphItem = menu.add(new MenuItem("Reduce Morphs (34)"));
14821524 reduce34MorphItem.addActionListener(this);
14831525 menu.add("-");
1526
+ menu.add(memoryItem = new MenuItem("Memory Usage"));
1527
+ memoryItem.addActionListener(this);
14841528 menu.add(computeAOItem = new MenuItem("Compute AO"));
14851529 computeAOItem.addActionListener(this);
14861530
....@@ -1489,8 +1533,6 @@
14891533 mirrorItem = menu.add(new MenuItem("Mirror Poses"));
14901534 mirrorItem.addActionListener(this);
14911535 menu.add("-");
1492
- menu.add(memoryItem = new MenuItem("Memory Usage"));
1493
- memoryItem.addActionListener(this);
14941536 menu.add(analyzeItem = new MenuItem("Analyze"));
14951537 analyzeItem.addActionListener(this);
14961538 menu.add(dumpItem = new MenuItem("Print"));
....@@ -1651,6 +1693,16 @@
16511693 listUI.remove(i);
16521694 }
16531695 }
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
16541706 }
16551707
16561708 /**
....@@ -2213,15 +2265,31 @@
22132265 } else
22142266 if (source == undoButton)
22152267 {
2268
+ // Go to previous version
2269
+ //if (!Undo())
2270
+ //java.awt.Toolkit.getDefaultToolkit().beep();
22162271 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();
22172282 } else
22182283 if (source == redoButton)
22192284 {
2285
+ // Go to next version
22202286 Redo();
22212287 } else
22222288 if (source == saveButton)
22232289 {
2224
- Save();
2290
+ // Save a new version
2291
+ if (!Save(true))
2292
+ java.awt.Toolkit.getDefaultToolkit().beep();
22252293 } else
22262294 if (source == oneStepButton)
22272295 {
....@@ -2230,17 +2298,14 @@
22302298 } else
22312299 if (source == screenfitButton)
22322300 {
2233
- //Reload(lastConverter, lastFilename, true);
22342301 ScreenFit();
22352302 } else
22362303 if (source == screenfitpointButton)
22372304 {
2238
- //Reload(lastConverter, lastFilename, true);
22392305 ScreenFitPoint();
22402306 } else
22412307 if (source == snapobjectButton)
22422308 {
2243
- //Reload(lastConverter, lastFilename, true);
22442309 SnapObject();
22452310 } else
22462311 // if (event.getSource() == recompileButton)
....@@ -2604,7 +2669,7 @@
26042669 {
26052670 StepAll();
26062671 } else
2607
- if (source == clearItem) // || event.getSource() == clearButton)
2672
+ if (source == deleteItem) // || event.getSource() == clearButton)
26082673 {
26092674 //int indices[] = jList.getSelectedIndices();
26102675 //for (int i = indices.length - 1; i >= 0; i--)
....@@ -3468,6 +3533,9 @@
34683533 }
34693534
34703535 copy = group;
3536
+
3537
+ SetUndoStates();
3538
+
34713539 //Globals.theRenderer.object = group;
34723540 if(!useclient)
34733541 {
....@@ -3496,8 +3564,10 @@
34963564 radio.layout.doClick();
34973565
34983566 ClearUnpinned();
3499
- SetPinStates(group.selection.size() > 0);
3500
- 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)
35013571 EditSelection(false);
35023572 keepparent = group.parent;
35033573 // PARENT = NULL or not???
....@@ -4568,6 +4638,12 @@
45684638
45694639 void EditSelection(boolean newWindow)
45704640 {
4641
+ if (group.selection == null)
4642
+ {
4643
+ EditElement(group, newWindow); // ? new
4644
+ return;
4645
+ }
4646
+
45714647 // aConstraints.gridy = 0;
45724648 for (int i=0; i<group.selection.size(); i++)
45734649 {
....@@ -4578,12 +4654,7 @@
45784654 Object3D elem = (Object3D)group.selection.elementAt(i);
45794655 if(elem != group || !newWindow)
45804656 {
4581
- // if (!(elem instanceof Composite))
4582
- // newWindow = false;
4583
- listUI.add(elem);
4584
- elem.openEditWindow(this, newWindow); //, false);
4585
- System.out.println("edit : " + elem);
4586
- elem.editWindow.refreshContents(true); // ? new
4657
+ EditElement(elem, newWindow); // ? new
45874658 }
45884659 }
45894660 }
....@@ -4728,7 +4799,7 @@
47284799 void refreshContents(boolean cp)
47294800 {
47304801 if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Info"))
4731
- if (!Globals.MOUSEDRAGGED) // && !Globals.TIMERRUNNING)
4802
+ if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
47324803 {
47334804 objEditor.ClearInfo(); // .GetMaterial());
47344805
....@@ -4827,8 +4898,8 @@
48274898
48284899 if (cut)
48294900 {
4830
- if (Globals.SAVEONMAKE)
4831
- Save();
4901
+// if (Globals.SAVEONMAKE) // Moved to the clipboard, no need to save.
4902
+// Save();
48324903 //int indices[] = jList.getSelectedIndices();
48334904 //for (int i = indices.length - 1; i >= 0; i--)
48344905 //jList.remove(indices[i]);
....@@ -4931,6 +5002,10 @@
49315002
49325003 void paste(boolean expand)
49335004 {
5005
+ if (Globals.REPLACEONMAKE)
5006
+ Save();
5007
+ boolean keep = Globals.REPLACEONMAKE;
5008
+ Globals.REPLACEONMAKE = false;
49345009 // if (GrafreeD.clipboard == null)
49355010 // return;
49365011 boolean first = true;
....@@ -4990,6 +5065,7 @@
49905065 Grafreed.clipboard.get(0).parent = keepparent;
49915066 }
49925067
5068
+ Globals.REPLACEONMAKE = keep;
49935069 ResetModel();
49945070 refreshContents();
49955071 }
....@@ -5125,6 +5201,10 @@
51255201
51265202 void group(Object3D csg, boolean grab)
51275203 {
5204
+ if (Globals.REPLACEONMAKE)
5205
+ Save();
5206
+ boolean keep = Globals.REPLACEONMAKE;
5207
+ Globals.REPLACEONMAKE = false;
51285208 if (//false) // why??
51295209 !group.selection.isEmpty())
51305210 {
....@@ -5238,10 +5318,15 @@
52385318 //node.add(csg);
52395319 //makeSomething(node);
52405320 makeSomething(csg);
5321
+ Globals.REPLACEONMAKE = keep;
52415322 }
52425323
52435324 void Ungroup(Object3D g)
52445325 {
5326
+ if (Globals.REPLACEONMAKE)
5327
+ Save();
5328
+ boolean keep = Globals.REPLACEONMAKE;
5329
+ Globals.REPLACEONMAKE = false;
52455330 if (g instanceof HiddenObject)
52465331 {
52475332 HiddenObject h = (HiddenObject) g;
....@@ -5258,6 +5343,7 @@
52585343 objEditor.makeSomething(g.get(i), false);
52595344 }
52605345 }
5346
+ Globals.REPLACEONMAKE = keep;
52615347 }
52625348
52635349 void ungroup()
....@@ -5621,7 +5707,7 @@
56215707 private MenuItem pasteLinkItem;
56225708 private MenuItem pasteCloneItem;
56235709 private MenuItem pasteExpandItem;
5624
- private MenuItem clearItem;
5710
+ private MenuItem deleteItem;
56255711 private MenuItem clearAllItem;
56265712 private MenuItem genUVItem;
56275713 private MenuItem genNormalsMESHItem;