Normand Briere
2019-07-27 1af7d3700724834e40ad8636bc9a56cdc3b19b15
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"));
....@@ -514,10 +528,15 @@
514528 attachBumpItem.addActionListener(this);
515529 pigmentBumpItem = menu.add(new MenuItem("Pigment -> Bump"));
516530 pigmentBumpItem.addActionListener(this);
531
+ //embedTexturesItem
517532 detachPigmentItem = menu.add(new MenuItem("Detach Pigment"));
518533 detachPigmentItem.addActionListener(this);
519534 detachBumpItem = menu.add(new MenuItem("Detach Bump"));
520535 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);
521540 menu.add("-");
522541 sortbysizeItem = menu.add(new MenuItem("Sort by size"));
523542 sortbysizeItem.addActionListener(this);
....@@ -544,6 +563,7 @@
544563 buildToolsMenu(menu);
545564 }
546565
566
+
547567 void SetupUI2(ObjEditor oe)
548568 {
549569 // June 2019
....@@ -615,29 +635,42 @@
615635 restoreCameraButton.setToolTipText("Restore viewpoint");
616636 restoreCameraButton.addActionListener(this);
617637
638
+ copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
639
+ saveButton.setToolTipText("New version");
640
+ saveButton.addActionListener(this);
641
+
618642 copyOptionsPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
619
- undoButton.setToolTipText("Undo changes");
643
+ undoButton.setToolTipText("Previous version");
620644 undoButton.addActionListener(this);
621645 undoButton.setEnabled(false);
622646
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
+
623660 copyOptionsPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
624
- redoButton.setToolTipText("Redo changes");
661
+ redoButton.setToolTipText("Next version");
625662 redoButton.addActionListener(this);
626663 redoButton.setEnabled(false);
627664
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);
665
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
633666 liveCB.setToolTipText("Enable animation");
634667 liveCB.addItemListener(this);
635668
636
- copyOptionsPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
669
+ oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
637670 oneStepButton.setToolTipText("Animate one step forward");
638671 oneStepButton.addActionListener(this);
639672
640
- copyOptionsPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
673
+ oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
641674 fastCB.setToolTipText("Fast mode");
642675 fastCB.addItemListener(this);
643676
....@@ -655,31 +688,32 @@
655688 oe.toolbarPanel.add(snapobjectButton = new cButton("O+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
656689 snapobjectButton.addActionListener(this);
657690 snapobjectButton.setToolTipText("Snap Object");
691
+
692
+ oe.toolbarPanel.add(fourButton = GetButton("icons/controls-horizontal.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
693
+ fourButton.addActionListener(this);
694
+ fourButton.setToolTipText("Show control panel only");
658695 }
659696
660697 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
661698
662
- oe.toolbarPanel.add(twoButton = new cButton("|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
663
- twoButton.setToolTipText("Show center view only");
699
+ oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
700
+ twoButton.setToolTipText("Show 3D view only");
664701 twoButton.addActionListener(this);
665702 this.fullscreenLayout = twoButton;
666703
667
- oe.toolbarPanel.add(fourButton = new cButton("-||", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
668
- fourButton.addActionListener(this);
669
- fourButton.setToolTipText("Show left panel only");
670
- oe.toolbarPanel.add(sixButton = new cButton("-|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
671
- sixButton.setToolTipText("2-column layout left");
672
- sixButton.addActionListener(this);
673
- oe.toolbarPanel.add(threeButton = new cButton("|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
674
- threeButton.setToolTipText("2-column layout right");
704
+ oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
705
+ threeButton.setToolTipText("Show controls and 3D view");
675706 threeButton.addActionListener(this);
676
- oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
677
- sevenButton.setToolTipText("3-column layout");
678
- sevenButton.addActionListener(this);
707
+ oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
708
+ sixButton.setToolTipText("Show 3D view and controls");
709
+ sixButton.addActionListener(this);
710
+// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
711
+// sevenButton.setToolTipText("3-column layout");
712
+// sevenButton.addActionListener(this);
679713 //
680714
681
- oe.toolbarPanel.add(rootButton = GetButton("icons/write.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
682
- 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");
683717 rootButton.addActionListener(this);
684718
685719 oe.toolbarPanel.add(closeButton = GetButton("icons/close-icon.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -820,6 +854,9 @@
820854
821855 oe.treePanel.add(copyOptionsPanel);
822856 oe.treePanel.Return();
857
+ cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
858
+ versionSlider = (cNumberSlider)sliderPane.getComponent(1);
859
+ sliderPane.preferredHeight = 1;
823860
824861 // mainPanel.setDividerLocation(0.5); //1.0);
825862 // mainPanel.setResizeWeight(0.5);
....@@ -842,7 +879,7 @@
842879 dgr.addDragGestureListener(this);
843880 }catch(Exception e) {}
844881 */
845
- radio.layout = sevenButton;
882
+ radio.layout = sixButton; // sevenButton;
846883 oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
847884 }
848885
....@@ -945,9 +982,9 @@
945982 toggleSwitchCB.setToolTipText("Choose a single item");
946983 toggleSwitchCB.addItemListener(this);
947984
948
- panel.add(autosaveCB = new cCheckBox("Auto-save", Globals.SAVEONMAKE)); //, constraints);
949
- autosaveCB.setToolTipText("On structure change");
950
- autosaveCB.addItemListener(this);
985
+ panel.add(autokeepCB = new cCheckBox("Auto-replace", Globals.REPLACEONMAKE)); //, constraints);
986
+ autokeepCB.setToolTipText("On structure change");
987
+ autokeepCB.addItemListener(this);
951988
952989 panel.Return();
953990 if (Globals.ADVANCED)
....@@ -984,7 +1021,7 @@
9841021 }
9851022
9861023 radioButton.SetObject(obj);
987
- radioButton.layout = sevenButton;
1024
+ radioButton.layout = sixButton; // sevenButton;
9881025 radioButton.SetCamera(cameraView.renderCamera, false);
9891026 radioButton.addActionListener(this);
9901027 radioPanel.add(radioButton);
....@@ -1024,7 +1061,7 @@
10241061
10251062 cCheckBox oeilCB;
10261063 cCheckBox shadowCB;
1027
- cCheckBox autosaveCB;
1064
+ cCheckBox autokeepCB;
10281065 cCheckBox lookAtCB;
10291066
10301067 // static int COLOR = 1;
....@@ -1136,9 +1173,9 @@
11361173 {
11371174 Globals.FREEZEONMOVE ^= true;
11381175 }
1139
- else if(e.getSource() == autosaveCB)
1176
+ else if(e.getSource() == autokeepCB)
11401177 {
1141
- Globals.SAVEONMAKE ^= true;
1178
+ Globals.REPLACEONMAKE ^= true;
11421179 }
11431180 else if(e.getSource() == lookAtCB)
11441181 {
....@@ -1663,6 +1700,16 @@
16631700 listUI.remove(i);
16641701 }
16651702 }
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
16661713 }
16671714
16681715 /**
....@@ -2225,15 +2272,29 @@
22252272 } else
22262273 if (source == undoButton)
22272274 {
2228
- if (!Undo())
2229
- 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();
22302289 } else
22312290 if (source == redoButton)
22322291 {
2292
+ // Go to next version
22332293 Redo();
22342294 } else
22352295 if (source == saveButton)
22362296 {
2297
+ // Save a new version
22372298 if (!Save(true))
22382299 java.awt.Toolkit.getDefaultToolkit().beep();
22392300 } else
....@@ -2615,7 +2676,7 @@
26152676 {
26162677 StepAll();
26172678 } else
2618
- if (source == clearItem) // || event.getSource() == clearButton)
2679
+ if (source == deleteItem) // || event.getSource() == clearButton)
26192680 {
26202681 //int indices[] = jList.getSelectedIndices();
26212682 //for (int i = indices.length - 1; i >= 0; i--)
....@@ -3097,7 +3158,7 @@
30973158 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
30983159 {
30993160 obj = (Object3D)e.nextElement();
3100
- obj.SetBumpTexture(null);
3161
+ obj.ResetBumpTexture();
31013162 }
31023163
31033164 refreshContents();
....@@ -3111,6 +3172,31 @@
31113172 obj.SetBumpTexture(obj.GetPigmentTexture());
31123173 }
31133174
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
+
31143200 refreshContents();
31153201 } else
31163202 if (source == flashSelectionButton)
....@@ -3214,8 +3300,8 @@
32143300 // centralPanel.setVisible(true);
32153301 // XYZPanel.setVisible(true);
32163302 bigThree.ClearUI();
3303
+ bigThree.add(scenePanel);
32173304 bigThree.add(centralPanel);
3218
- bigThree.add(XYZPanel);
32193305 bigThree.FlushUI();
32203306
32213307 cameraView.requestFocusInWindow();
....@@ -3295,8 +3381,8 @@
32953381 // centralPanel.setVisible(true);
32963382 // XYZPanel.setVisible(false);
32973383 bigThree.ClearUI();
3298
- bigThree.add(scenePanel);
32993384 bigThree.add(centralPanel);
3385
+ bigThree.add(scenePanel);
33003386 bigThree.FlushUI();
33013387
33023388 cameraView.requestFocusInWindow();
....@@ -3479,6 +3565,9 @@
34793565 }
34803566
34813567 copy = group;
3568
+
3569
+ SetUndoStates();
3570
+
34823571 //Globals.theRenderer.object = group;
34833572 if(!useclient)
34843573 {
....@@ -3507,8 +3596,10 @@
35073596 radio.layout.doClick();
35083597
35093598 ClearUnpinned();
3510
- SetPinStates(group.selection.size() > 0);
3511
- 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)
35123603 EditSelection(false);
35133604 keepparent = group.parent;
35143605 // PARENT = NULL or not???
....@@ -4102,7 +4193,7 @@
41024193
41034194 try
41044195 {
4105
- texturedata = Globals.theRenderer.GetTextureData(pigment, false, node.texres);
4196
+ texturedata = Globals.theRenderer.GetTextureData(tex, false, node.texres);
41064197 }
41074198 catch (Exception e)
41084199 {
....@@ -4579,6 +4670,12 @@
45794670
45804671 void EditSelection(boolean newWindow)
45814672 {
4673
+ if (group.selection == null)
4674
+ {
4675
+ EditElement(group, newWindow); // ? new
4676
+ return;
4677
+ }
4678
+
45824679 // aConstraints.gridy = 0;
45834680 for (int i=0; i<group.selection.size(); i++)
45844681 {
....@@ -4589,12 +4686,7 @@
45894686 Object3D elem = (Object3D)group.selection.elementAt(i);
45904687 if(elem != group || !newWindow)
45914688 {
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
4689
+ EditElement(elem, newWindow); // ? new
45984690 }
45994691 }
46004692 }
....@@ -4738,7 +4830,7 @@
47384830
47394831 void refreshContents(boolean cp)
47404832 {
4741
- if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Info"))
4833
+ if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
47424834 if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
47434835 {
47444836 objEditor.ClearInfo(); // .GetMaterial());
....@@ -4942,10 +5034,10 @@
49425034
49435035 void paste(boolean expand)
49445036 {
4945
- if (Globals.SAVEONMAKE)
5037
+ if (Globals.REPLACEONMAKE)
49465038 Save();
4947
- boolean keep = Globals.SAVEONMAKE;
4948
- Globals.SAVEONMAKE = false;
5039
+ boolean keep = Globals.REPLACEONMAKE;
5040
+ Globals.REPLACEONMAKE = false;
49495041 // if (GrafreeD.clipboard == null)
49505042 // return;
49515043 boolean first = true;
....@@ -5005,7 +5097,7 @@
50055097 Grafreed.clipboard.get(0).parent = keepparent;
50065098 }
50075099
5008
- Globals.SAVEONMAKE = keep;
5100
+ Globals.REPLACEONMAKE = keep;
50095101 ResetModel();
50105102 refreshContents();
50115103 }
....@@ -5141,10 +5233,10 @@
51415233
51425234 void group(Object3D csg, boolean grab)
51435235 {
5144
- if (Globals.SAVEONMAKE)
5236
+ if (Globals.REPLACEONMAKE)
51455237 Save();
5146
- boolean keep = Globals.SAVEONMAKE;
5147
- Globals.SAVEONMAKE = false;
5238
+ boolean keep = Globals.REPLACEONMAKE;
5239
+ Globals.REPLACEONMAKE = false;
51485240 if (//false) // why??
51495241 !group.selection.isEmpty())
51505242 {
....@@ -5258,15 +5350,15 @@
52585350 //node.add(csg);
52595351 //makeSomething(node);
52605352 makeSomething(csg);
5261
- Globals.SAVEONMAKE = keep;
5353
+ Globals.REPLACEONMAKE = keep;
52625354 }
52635355
52645356 void Ungroup(Object3D g)
52655357 {
5266
- if (Globals.SAVEONMAKE)
5358
+ if (Globals.REPLACEONMAKE)
52675359 Save();
5268
- boolean keep = Globals.SAVEONMAKE;
5269
- Globals.SAVEONMAKE = false;
5360
+ boolean keep = Globals.REPLACEONMAKE;
5361
+ Globals.REPLACEONMAKE = false;
52705362 if (g instanceof HiddenObject)
52715363 {
52725364 HiddenObject h = (HiddenObject) g;
....@@ -5283,7 +5375,7 @@
52835375 objEditor.makeSomething(g.get(i), false);
52845376 }
52855377 }
5286
- Globals.SAVEONMAKE = keep;
5378
+ Globals.REPLACEONMAKE = keep;
52875379 }
52885380
52895381 void ungroup()
....@@ -5647,7 +5739,7 @@
56475739 private MenuItem pasteLinkItem;
56485740 private MenuItem pasteCloneItem;
56495741 private MenuItem pasteExpandItem;
5650
- private MenuItem clearItem;
5742
+ private MenuItem deleteItem;
56515743 private MenuItem clearAllItem;
56525744 private MenuItem genUVItem;
56535745 private MenuItem genNormalsMESHItem;
....@@ -5731,6 +5823,8 @@
57315823 private MenuItem attachBumpItem;
57325824 private MenuItem detachBumpItem;
57335825 private MenuItem pigmentBumpItem;
5826
+ private MenuItem embedTexturesItem;
5827
+ private MenuItem deEmbedTexturesItem;
57345828
57355829 private MenuItem particleItem;
57365830 private MenuItem ragdollItem;