Normand Briere
2019-07-23 0f4fa9dc4191aaee9661c1e6d73725436ae64ac2
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,14 +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);
383404
384405 if (Globals.ADVANCED)
385406 {
386407 menu.add("-");
387408 linkerItem = menu.add(new MenuItem("Linker"));
388409 linkerItem.addActionListener(this);
389
- attributeItem = menu.add(new MenuItem("Attribute"));
390
- attributeItem.addActionListener(this);
391410 templateItem = menu.add(new MenuItem("Template"));
392411 templateItem.addActionListener(this);
393412 pointflowItem = menu.add(new MenuItem("Point Flow"));
....@@ -416,7 +435,7 @@
416435 genNormalsMESHItem.addActionListener(this);
417436 if (Globals.ADVANCED)
418437 {
419
- genNormalsMINEItem = menu.add(new MenuItem("My Normals"));
438
+ genNormalsMINEItem = menu.add(new MenuItem("Stitch Normals"));
420439 genNormalsMINEItem.addActionListener(this);
421440 }
422441 stripifyItem = menu.add(new MenuItem("Stripify"));
....@@ -509,10 +528,15 @@
509528 attachBumpItem.addActionListener(this);
510529 pigmentBumpItem = menu.add(new MenuItem("Pigment -> Bump"));
511530 pigmentBumpItem.addActionListener(this);
531
+ //embedTexturesItem
512532 detachPigmentItem = menu.add(new MenuItem("Detach Pigment"));
513533 detachPigmentItem.addActionListener(this);
514534 detachBumpItem = menu.add(new MenuItem("Detach Bump"));
515535 detachBumpItem.addActionListener(this);
536
+ embedTexturesItem = menu.add(new MenuItem("Embed Textures"));
537
+ embedTexturesItem.addActionListener(this);
538
+ deEmbedTexturesItem = menu.add(new MenuItem("De-embed Textures"));
539
+ deEmbedTexturesItem.addActionListener(this);
516540 menu.add("-");
517541 sortbysizeItem = menu.add(new MenuItem("Sort by size"));
518542 sortbysizeItem.addActionListener(this);
....@@ -539,6 +563,7 @@
539563 buildToolsMenu(menu);
540564 }
541565
566
+
542567 void SetupUI2(ObjEditor oe)
543568 {
544569 // June 2019
....@@ -610,29 +635,42 @@
610635 restoreCameraButton.setToolTipText("Restore viewpoint");
611636 restoreCameraButton.addActionListener(this);
612637
638
+ copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
639
+ saveButton.setToolTipText("New version");
640
+ saveButton.addActionListener(this);
641
+
613642 copyOptionsPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
614
- undoButton.setToolTipText("Undo changes");
643
+ undoButton.setToolTipText("Previous version");
615644 undoButton.addActionListener(this);
616645 undoButton.setEnabled(false);
617646
647
+ cGridBag updown = new cGridBag().setVertical(true);
648
+ updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
649
+ restoreButton.setToolTipText("Restore current");
650
+ restoreButton.addActionListener(this);
651
+ restoreButton.setEnabled(false);
652
+
653
+ updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
654
+ replaceButton.setToolTipText("Replace current");
655
+ replaceButton.addActionListener(this);
656
+ replaceButton.setEnabled(false);
657
+
658
+ copyOptionsPanel.add(updown);
659
+
618660 copyOptionsPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
619
- redoButton.setToolTipText("Redo changes");
661
+ redoButton.setToolTipText("Next version");
620662 redoButton.addActionListener(this);
621663 redoButton.setEnabled(false);
622664
623
- copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
624
- saveButton.setToolTipText("Save changes");
625
- saveButton.addActionListener(this);
626
-
627
- copyOptionsPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
665
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
628666 liveCB.setToolTipText("Enable animation");
629667 liveCB.addItemListener(this);
630668
631
- copyOptionsPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
669
+ oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
632670 oneStepButton.setToolTipText("Animate one step forward");
633671 oneStepButton.addActionListener(this);
634672
635
- copyOptionsPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
673
+ oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
636674 fastCB.setToolTipText("Fast mode");
637675 fastCB.addItemListener(this);
638676
....@@ -654,27 +692,28 @@
654692
655693 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
656694
657
- oe.toolbarPanel.add(twoButton = new cButton("|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
658
- twoButton.setToolTipText("Show center view only");
659
- twoButton.addActionListener(this);
660
- this.fullscreenLayout = twoButton;
661
-
662695 oe.toolbarPanel.add(fourButton = new cButton("-||", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
663696 fourButton.addActionListener(this);
664697 fourButton.setToolTipText("Show left panel only");
698
+
699
+ oe.toolbarPanel.add(twoButton = new cButton("|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
700
+ twoButton.setToolTipText("Show right view only");
701
+ twoButton.addActionListener(this);
702
+ this.fullscreenLayout = twoButton;
703
+
665704 oe.toolbarPanel.add(sixButton = new cButton("-|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
666
- sixButton.setToolTipText("2-column layout left");
705
+ sixButton.setToolTipText("Show left and right");
667706 sixButton.addActionListener(this);
668
- oe.toolbarPanel.add(threeButton = new cButton("|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
669
- threeButton.setToolTipText("2-column layout right");
670
- threeButton.addActionListener(this);
671
- oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
672
- sevenButton.setToolTipText("3-column layout");
673
- sevenButton.addActionListener(this);
707
+// oe.toolbarPanel.add(threeButton = new cButton("|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
708
+// threeButton.setToolTipText("2-column layout right");
709
+// threeButton.addActionListener(this);
710
+// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
711
+// sevenButton.setToolTipText("3-column layout");
712
+// sevenButton.addActionListener(this);
674713 //
675714
676
- oe.toolbarPanel.add(rootButton = GetButton("icons/write.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
677
- rootButton.setToolTipText("Edit selection in new tab");
715
+ oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
716
+ rootButton.setToolTipText("Open selection in new tab");
678717 rootButton.addActionListener(this);
679718
680719 oe.toolbarPanel.add(closeButton = GetButton("icons/close-icon.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -815,6 +854,9 @@
815854
816855 oe.treePanel.add(copyOptionsPanel);
817856 oe.treePanel.Return();
857
+ cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
858
+ versionSlider = (cNumberSlider)sliderPane.getComponent(1);
859
+ sliderPane.preferredHeight = 1;
818860
819861 // mainPanel.setDividerLocation(0.5); //1.0);
820862 // mainPanel.setResizeWeight(0.5);
....@@ -837,7 +879,7 @@
837879 dgr.addDragGestureListener(this);
838880 }catch(Exception e) {}
839881 */
840
- radio.layout = sevenButton;
882
+ radio.layout = sixButton; // sevenButton;
841883 oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
842884 }
843885
....@@ -940,9 +982,9 @@
940982 toggleSwitchCB.setToolTipText("Choose a single item");
941983 toggleSwitchCB.addItemListener(this);
942984
943
- panel.add(autosaveCB = new cCheckBox("Auto-save", Globals.SAVEONMAKE)); //, constraints);
944
- autosaveCB.setToolTipText("On structure change");
945
- autosaveCB.addItemListener(this);
985
+ panel.add(autokeepCB = new cCheckBox("Auto-replace", Globals.REPLACEONMAKE)); //, constraints);
986
+ autokeepCB.setToolTipText("On structure change");
987
+ autokeepCB.addItemListener(this);
946988
947989 panel.Return();
948990 if (Globals.ADVANCED)
....@@ -971,7 +1013,7 @@
9711013 {
9721014 cRadio radioButton = new cRadio(obj.name);
9731015
974
- // Patch to avoid bug with transparency.
1016
+ // June 2019. Patch to avoid bug with transparency.
9751017 radioButton.hadMaterial = obj.material != null;
9761018 if (!radioButton.hadMaterial)
9771019 {
....@@ -979,7 +1021,7 @@
9791021 }
9801022
9811023 radioButton.SetObject(obj);
982
- radioButton.layout = sevenButton;
1024
+ radioButton.layout = sixButton; // sevenButton;
9831025 radioButton.SetCamera(cameraView.renderCamera, false);
9841026 radioButton.addActionListener(this);
9851027 radioPanel.add(radioButton);
....@@ -1019,7 +1061,7 @@
10191061
10201062 cCheckBox oeilCB;
10211063 cCheckBox shadowCB;
1022
- cCheckBox autosaveCB;
1064
+ cCheckBox autokeepCB;
10231065 cCheckBox lookAtCB;
10241066
10251067 // static int COLOR = 1;
....@@ -1131,9 +1173,9 @@
11311173 {
11321174 Globals.FREEZEONMOVE ^= true;
11331175 }
1134
- else if(e.getSource() == autosaveCB)
1176
+ else if(e.getSource() == autokeepCB)
11351177 {
1136
- Globals.SAVEONMAKE ^= true;
1178
+ Globals.REPLACEONMAKE ^= true;
11371179 }
11381180 else if(e.getSource() == lookAtCB)
11391181 {
....@@ -1223,7 +1265,7 @@
12231265 // return;
12241266 // }
12251267
1226
- String string = (String) object;
1268
+ String string = object.toString();
12271269
12281270 // File path for Mac and Windows
12291271 if (string.charAt(0) == '/' || string.charAt(1) == ':')
....@@ -1488,6 +1530,8 @@
14881530 reduce34MorphItem = menu.add(new MenuItem("Reduce Morphs (34)"));
14891531 reduce34MorphItem.addActionListener(this);
14901532 menu.add("-");
1533
+ menu.add(memoryItem = new MenuItem("Memory Usage"));
1534
+ memoryItem.addActionListener(this);
14911535 menu.add(computeAOItem = new MenuItem("Compute AO"));
14921536 computeAOItem.addActionListener(this);
14931537
....@@ -1496,8 +1540,6 @@
14961540 mirrorItem = menu.add(new MenuItem("Mirror Poses"));
14971541 mirrorItem.addActionListener(this);
14981542 menu.add("-");
1499
- menu.add(memoryItem = new MenuItem("Memory Usage"));
1500
- memoryItem.addActionListener(this);
15011543 menu.add(analyzeItem = new MenuItem("Analyze"));
15021544 analyzeItem.addActionListener(this);
15031545 menu.add(dumpItem = new MenuItem("Print"));
....@@ -1658,6 +1700,16 @@
16581700 listUI.remove(i);
16591701 }
16601702 }
1703
+ }
1704
+
1705
+ private void EditElement(Object3D elem, boolean newWindow)
1706
+ {
1707
+ // if (!(elem instanceof Composite))
1708
+ // newWindow = false;
1709
+ listUI.add(elem);
1710
+ elem.openEditWindow(this, newWindow); //, false);
1711
+ System.out.println("edit : " + elem);
1712
+ elem.editWindow.refreshContents(true); // ? new
16611713 }
16621714
16631715 /**
....@@ -2220,15 +2272,29 @@
22202272 } else
22212273 if (source == undoButton)
22222274 {
2223
- if (!Undo())
2224
- java.awt.Toolkit.getDefaultToolkit().beep();
2275
+ // Go to previous version
2276
+ //if (!Undo())
2277
+ //java.awt.Toolkit.getDefaultToolkit().beep();
2278
+ Undo();
2279
+ } else
2280
+ if (source == restoreButton)
2281
+ {
2282
+ // Restore current version
2283
+ Restore();
2284
+ } else
2285
+ if (source == replaceButton)
2286
+ {
2287
+ // Overwrite current version
2288
+ Replace();
22252289 } else
22262290 if (source == redoButton)
22272291 {
2292
+ // Go to next version
22282293 Redo();
22292294 } else
22302295 if (source == saveButton)
22312296 {
2297
+ // Save a new version
22322298 if (!Save(true))
22332299 java.awt.Toolkit.getDefaultToolkit().beep();
22342300 } else
....@@ -2610,7 +2676,7 @@
26102676 {
26112677 StepAll();
26122678 } else
2613
- if (source == clearItem) // || event.getSource() == clearButton)
2679
+ if (source == deleteItem) // || event.getSource() == clearButton)
26142680 {
26152681 //int indices[] = jList.getSelectedIndices();
26162682 //for (int i = indices.length - 1; i >= 0; i--)
....@@ -3092,7 +3158,7 @@
30923158 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
30933159 {
30943160 obj = (Object3D)e.nextElement();
3095
- obj.SetBumpTexture(null);
3161
+ obj.ResetBumpTexture();
30963162 }
30973163
30983164 refreshContents();
....@@ -3106,6 +3172,31 @@
31063172 obj.SetBumpTexture(obj.GetPigmentTexture());
31073173 }
31083174
3175
+ refreshContents();
3176
+ } else
3177
+ if (source == embedTexturesItem)
3178
+ {
3179
+ Object3D obj;
3180
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
3181
+ {
3182
+ obj = (Object3D)e.nextElement();
3183
+ obj.EmbedTextures(true);
3184
+ }
3185
+
3186
+ refreshContents();
3187
+ } else
3188
+ if (source == deEmbedTexturesItem)
3189
+ {
3190
+ Object3D obj;
3191
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
3192
+ {
3193
+ obj = (Object3D)e.nextElement();
3194
+ obj.EmbedTextures(false);
3195
+ }
3196
+
3197
+ CameraPane.texturepigment.clear();
3198
+ CameraPane.texturebump.clear();
3199
+
31093200 refreshContents();
31103201 } else
31113202 if (source == flashSelectionButton)
....@@ -3474,6 +3565,9 @@
34743565 }
34753566
34763567 copy = group;
3568
+
3569
+ SetUndoStates();
3570
+
34773571 //Globals.theRenderer.object = group;
34783572 if(!useclient)
34793573 {
....@@ -3502,8 +3596,10 @@
35023596 radio.layout.doClick();
35033597
35043598 ClearUnpinned();
3505
- SetPinStates(group.selection.size() > 0);
3506
- if (group.selection.size() == 1)
3599
+ //Grafreed.Assert(group != null);
3600
+ //Grafreed.Assert(group.selection != null);
3601
+ SetPinStates(group.selection == null || group.selection.size() > 0);
3602
+ if (group.selection == null || group.selection.size() == 1)
35073603 EditSelection(false);
35083604 keepparent = group.parent;
35093605 // PARENT = NULL or not???
....@@ -4097,7 +4193,7 @@
40974193
40984194 try
40994195 {
4100
- texturedata = Globals.theRenderer.GetTextureData(pigment, false, node.texres);
4196
+ texturedata = Globals.theRenderer.GetTextureData(tex, false, node.texres);
41014197 }
41024198 catch (Exception e)
41034199 {
....@@ -4574,6 +4670,12 @@
45744670
45754671 void EditSelection(boolean newWindow)
45764672 {
4673
+ if (group.selection == null)
4674
+ {
4675
+ EditElement(group, newWindow); // ? new
4676
+ return;
4677
+ }
4678
+
45774679 // aConstraints.gridy = 0;
45784680 for (int i=0; i<group.selection.size(); i++)
45794681 {
....@@ -4584,12 +4686,7 @@
45844686 Object3D elem = (Object3D)group.selection.elementAt(i);
45854687 if(elem != group || !newWindow)
45864688 {
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
4689
+ EditElement(elem, newWindow); // ? new
45934690 }
45944691 }
45954692 }
....@@ -4733,7 +4830,7 @@
47334830
47344831 void refreshContents(boolean cp)
47354832 {
4736
- if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Info"))
4833
+ if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
47374834 if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
47384835 {
47394836 objEditor.ClearInfo(); // .GetMaterial());
....@@ -4833,8 +4930,8 @@
48334930
48344931 if (cut)
48354932 {
4836
- if (Globals.SAVEONMAKE)
4837
- Save();
4933
+// if (Globals.SAVEONMAKE) // Moved to the clipboard, no need to save.
4934
+// Save();
48384935 //int indices[] = jList.getSelectedIndices();
48394936 //for (int i = indices.length - 1; i >= 0; i--)
48404937 //jList.remove(indices[i]);
....@@ -4937,6 +5034,10 @@
49375034
49385035 void paste(boolean expand)
49395036 {
5037
+ if (Globals.REPLACEONMAKE)
5038
+ Save();
5039
+ boolean keep = Globals.REPLACEONMAKE;
5040
+ Globals.REPLACEONMAKE = false;
49405041 // if (GrafreeD.clipboard == null)
49415042 // return;
49425043 boolean first = true;
....@@ -4996,6 +5097,7 @@
49965097 Grafreed.clipboard.get(0).parent = keepparent;
49975098 }
49985099
5100
+ Globals.REPLACEONMAKE = keep;
49995101 ResetModel();
50005102 refreshContents();
50015103 }
....@@ -5131,6 +5233,10 @@
51315233
51325234 void group(Object3D csg, boolean grab)
51335235 {
5236
+ if (Globals.REPLACEONMAKE)
5237
+ Save();
5238
+ boolean keep = Globals.REPLACEONMAKE;
5239
+ Globals.REPLACEONMAKE = false;
51345240 if (//false) // why??
51355241 !group.selection.isEmpty())
51365242 {
....@@ -5244,10 +5350,15 @@
52445350 //node.add(csg);
52455351 //makeSomething(node);
52465352 makeSomething(csg);
5353
+ Globals.REPLACEONMAKE = keep;
52475354 }
52485355
52495356 void Ungroup(Object3D g)
52505357 {
5358
+ if (Globals.REPLACEONMAKE)
5359
+ Save();
5360
+ boolean keep = Globals.REPLACEONMAKE;
5361
+ Globals.REPLACEONMAKE = false;
52515362 if (g instanceof HiddenObject)
52525363 {
52535364 HiddenObject h = (HiddenObject) g;
....@@ -5264,6 +5375,7 @@
52645375 objEditor.makeSomething(g.get(i), false);
52655376 }
52665377 }
5378
+ Globals.REPLACEONMAKE = keep;
52675379 }
52685380
52695381 void ungroup()
....@@ -5627,7 +5739,7 @@
56275739 private MenuItem pasteLinkItem;
56285740 private MenuItem pasteCloneItem;
56295741 private MenuItem pasteExpandItem;
5630
- private MenuItem clearItem;
5742
+ private MenuItem deleteItem;
56315743 private MenuItem clearAllItem;
56325744 private MenuItem genUVItem;
56335745 private MenuItem genNormalsMESHItem;
....@@ -5711,6 +5823,8 @@
57115823 private MenuItem attachBumpItem;
57125824 private MenuItem detachBumpItem;
57135825 private MenuItem pigmentBumpItem;
5826
+ private MenuItem embedTexturesItem;
5827
+ private MenuItem deEmbedTexturesItem;
57145828
57155829 private MenuItem particleItem;
57165830 private MenuItem ragdollItem;