Normand Briere
2019-08-12 8f1afe25ea8fc8801aab66331c32a50859a758c2
GroupEditor.java
....@@ -16,6 +16,7 @@
1616 //import buoy.widget.BFileChooser;
1717
1818 class GroupEditor extends ObjEditor implements //iParse, //iCallBack,
19
+ Grafreed.iResourceCallBack,
1920 ObjectUI,
2021 Runnable,
2122 ActionListener,
....@@ -41,6 +42,22 @@
4142 });
4243 }
4344
45
+ public void AddTextureButton(String f, String c, final String t, int count, cGridBag row)
46
+ {
47
+ cButton textureButton;
48
+ final String path = "textures/" + f + "/" + c + "/"; // + t;
49
+ row.add(textureButton = GetButton(path + "icons/" + t, !Grafreed.NIMBUSLAF));
50
+ textureButton.setToolTipText(c + count);
51
+ textureButton.addActionListener(new ActionListener()
52
+ {
53
+ @Override
54
+ public void actionPerformed(ActionEvent e)
55
+ {
56
+ ChangeTexture(path + t);
57
+ }
58
+ });
59
+ }
60
+
4461 public void AddSkyboxTab0(JTabbedPane skyboxpanel)
4562 {
4663 cGridBag tab0 = new cGridBag().setVertical(true);
....@@ -311,14 +328,47 @@
311328 }
312329 }
313330
314
- public void ChangeSkybox(String name)
331
+ public void ChangeSkybox(String skybox)
315332 {
316333 //cameraView.envyoff = false;
317
- group.skyboxname = name;
334
+ group.skyboxname = skybox;
318335 group.skyboxext = "jpg";
319336 cameraView.repaint();
320337 }
338
+
339
+ public void CreateSkyboxPanel(cGridBag skyboxPanel)
340
+ {
341
+ JTabbedPane skyboxpane = new JTabbedPane();
342
+
343
+ AddSkyboxTab0(skyboxpane);
344
+ AddSkyboxTab1(skyboxpane);
345
+ AddSkyboxTab2(skyboxpane);
346
+ AddSkyboxTab3(skyboxpane);
347
+
348
+ skyboxPanel.add(skyboxpane);
349
+ }
321350
351
+ public void ChangeTexture(String texture)
352
+ {
353
+ for (int i=0; i<group.selection.size(); i++)
354
+ {
355
+ Object3D obj = group.selection.get(i);
356
+ obj.SetPigmentTexture("@" + texture);
357
+ }
358
+
359
+ refreshContents();
360
+ }
361
+
362
+ public void Show3DView()
363
+ {
364
+ // bug
365
+ //gridPanel.setDividerLocation(1.0);
366
+ //bigPanel.setDividerLocation(0.0);
367
+ bigThree.ClearUI();
368
+ bigThree.add(centralPanel);
369
+ bigThree.FlushUI();
370
+ }
371
+
322372 //ObjEditor objEditor;
323373 public void closeUI2()
324374 {
....@@ -360,6 +410,8 @@
360410 {
361411 copy.versionlist = new Object3D[100];
362412 copy.versionindex = -1;
413
+
414
+ Save(true);
363415 }
364416
365417 if(ui)
....@@ -591,11 +643,9 @@
591643 oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest"));
592644 //cameraMenu.add(lookFromItem = new MenuItem("Look From Selection"));
593645 //cameraMenu.add(switchViewItem = new MenuItem("Reverse View"));
594
- editLeafItem = oe.cameraMenu.add(new MenuItem("Edit Leaf"));
595646 oe.cameraMenu.add("-");
596647 openWindowItem = oe.cameraMenu.add(new MenuItem("Edit copy..."));
597648 openWindowItem.addActionListener(this);
598
- editLeafItem.addActionListener(this);
599649 lookAtItem.addActionListener(this);
600650 //lookFromItem.addActinoListener(this);
601651 //switchViewItem.addActionListener(this);
....@@ -843,6 +893,9 @@
843893 shareGeometriesItem.addActionListener(this);
844894 mergeGeometriesItem = menu.add(new MenuItem("Merge Geometries"));
845895 mergeGeometriesItem.addActionListener(this);
896
+ menu.add("-");
897
+ editLeafItem = menu.add(new MenuItem("Edit leaf..."));
898
+ editLeafItem.addActionListener(this);
846899 if (Globals.ADVANCED)
847900 {
848901 // Pretty much the same as duplicate and clone.
....@@ -859,6 +912,73 @@
859912 buildToolsMenu(menu);
860913 }
861914
915
+ JTabbedPane resourcecontainer;
916
+ cGridBag currenttab;
917
+ boolean added; // patch for jar
918
+
919
+ int tabcount = 0;
920
+ int colcount = 0;
921
+ int rowcount = 0;
922
+ int texturecount = 0;
923
+
924
+ int columns = 5;
925
+ int rows = 7;
926
+
927
+ public void ResourceCallBack(String[] path)
928
+ {
929
+// for (int i = 0; i < path.length; i++)
930
+// System.out.print(path[i] + "/");
931
+// System.out.println();
932
+
933
+ if (//rowcount == 0 ||
934
+ path.length == 1)
935
+ {
936
+ currenttab = new cGridBag();
937
+ added = false;
938
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
939
+ currenttab.setName(tabname);
940
+ rowcount = 1;
941
+ colcount = 0;
942
+ texturecount = 0;
943
+ }
944
+
945
+ if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
946
+ {
947
+ if (!added)
948
+ {
949
+ added = true;
950
+ resourcecontainer.add(currenttab);
951
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
952
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
953
+ }
954
+
955
+ AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
956
+
957
+ if (++colcount >= columns)
958
+ {
959
+ colcount = 0;
960
+ currenttab.Return();
961
+
962
+ if (rowcount++ >= rows)
963
+ {
964
+ rowcount = 0;
965
+ }
966
+ }
967
+ }
968
+ else
969
+ {
970
+// if (!path[path.length-1].equals("icons"))
971
+// resourcecontainer.Return();
972
+ }
973
+ }
974
+
975
+ void CreateTexturePanel(cGridBag container)
976
+ {
977
+ resourcecontainer = new JTabbedPane(JTabbedPane.LEFT);
978
+ container.add(resourcecontainer);
979
+
980
+ Grafreed.ParseResources("textures", this);
981
+ }
862982
863983 void SetupUI2(ObjEditor oe)
864984 {
....@@ -877,11 +997,6 @@
877997 //new Exception().printStackTrace();
878998
879999 oe.radioPanel = new JPanel(new GridBagLayout());
880
- oe.aConstraints.weightx = 1;
881
- oe.aConstraints.weighty = 0;
882
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
883
- oe.aConstraints.gridwidth = 100;
884
- oe.aConstraints.gridheight = 1;
8851000 // oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
8861001
8871002 oe.buttonGroup = new ButtonGroup();
....@@ -914,10 +1029,49 @@
9141029
9151030 if (Globals.ADVANCED)
9161031 {
917
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
918
- maxButton.setToolTipText("Maximize window");
919
- maxButton.addActionListener(this);
1032
+// oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1033
+// maxButton.setToolTipText("Maximize window");
1034
+// maxButton.addActionListener(this);
9201035 }
1036
+
1037
+// cButton gcButton;
1038
+//
1039
+// oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1040
+// gcButton.setToolTipText("Garbage collect");
1041
+// gcButton.addActionListener(new ActionListener()
1042
+// {
1043
+// public void actionPerformed(ActionEvent e)
1044
+// {
1045
+// System.gc();
1046
+// }
1047
+// });
1048
+
1049
+ oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1050
+ collapseButton.setToolTipText("Collapse toolbar");
1051
+ collapseButton.addActionListener(this);
1052
+
1053
+ oe.toolbarPanel.add(maximize3DButton = GetButton("", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1054
+ maximize3DButton.setToolTipText("Maximize 3D view");
1055
+ maximize3DButton.addActionListener(this);
1056
+
1057
+ oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1058
+ twoButton.setToolTipText("Show 3D view only");
1059
+ twoButton.addActionListener(this);
1060
+ this.fullscreenLayout = twoButton;
1061
+
1062
+ oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1063
+ threeButton.setToolTipText("Show controls and 3D view");
1064
+ threeButton.addActionListener(this);
1065
+ if (Globals.ADVANCED)
1066
+ {
1067
+ oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1068
+ sixButton.setToolTipText("Show 3D view and controls");
1069
+ sixButton.addActionListener(this);
1070
+ }
1071
+// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1072
+// sevenButton.setToolTipText("3-column layout");
1073
+// sevenButton.addActionListener(this);
1074
+ //
9211075
9221076 oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9231077 fullButton.setToolTipText("Full-screen window");
....@@ -948,12 +1102,12 @@
9481102 updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9491103 restoreButton.setToolTipText("Undo (restore current version)");
9501104 restoreButton.addActionListener(this);
951
- restoreButton.setEnabled(false);
1105
+ //restoreButton.setEnabled(false);
9521106
9531107 updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9541108 replaceButton.setToolTipText("Save (replace current version)");
9551109 replaceButton.addActionListener(this);
956
- replaceButton.setEnabled(false);
1110
+ //replaceButton.setEnabled(false);
9571111
9581112 copyOptionsPanel.add(updown);
9591113
....@@ -962,14 +1116,14 @@
9621116 nextVersionButton.addActionListener(this);
9631117 nextVersionButton.setEnabled(false);
9641118
965
- oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
966
- liveCB.setToolTipText("Enable animation");
967
- liveCB.addItemListener(this);
968
-
9691119 oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9701120 oneStepButton.setToolTipText("Animate one step forward");
9711121 oneStepButton.addActionListener(this);
9721122
1123
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
1124
+ liveCB.setToolTipText("Enable animation");
1125
+ liveCB.addItemListener(this);
1126
+
9731127 oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
9741128 fastCB.setToolTipText("Fast mode");
9751129 fastCB.addItemListener(this);
....@@ -996,21 +1150,6 @@
9961150
9971151 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
9981152
999
- oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1000
- twoButton.setToolTipText("Show 3D view only");
1001
- twoButton.addActionListener(this);
1002
- this.fullscreenLayout = twoButton;
1003
-
1004
- oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1005
- threeButton.setToolTipText("Show controls and 3D view");
1006
- threeButton.addActionListener(this);
1007
- oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1008
- sixButton.setToolTipText("Show 3D view and controls");
1009
- sixButton.addActionListener(this);
1010
-// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1011
-// sevenButton.setToolTipText("3-column layout");
1012
-// sevenButton.addActionListener(this);
1013
- //
10141153
10151154 oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10161155 rootButton.setToolTipText("Open selection in new tab");
....@@ -1026,7 +1165,7 @@
10261165
10271166 // INSERT
10281167 row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1029
- gridButton.setToolTipText("Create grid");
1168
+ gridButton.setToolTipText("Create ground");
10301169 gridButton.addActionListener(this);
10311170
10321171 row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1094,19 +1233,15 @@
10941233
10951234 oe.toolboxPanel.add(row2);
10961235
1097
- // ENVYMAPS
1098
- cGridBag skyboxpane = new cGridBag();
1099
- skyboxpane.preferredHeight = 100;
1236
+ cGridBag textures = new cGridBag();
11001237
1101
- oe.toolboxPanel.add(skyboxpane);
1238
+ CreateTexturePanel(textures);
11021239
1103
- JTabbedPane skyboxpanel = new JTabbedPane();
1104
- skyboxpane.add(skyboxpanel);
1240
+ oe.toolboxPanel.add(textures);
11051241
1106
- AddSkyboxTab0(skyboxpanel);
1107
- AddSkyboxTab1(skyboxpanel);
1108
- AddSkyboxTab2(skyboxpanel);
1109
- AddSkyboxTab3(skyboxpanel);
1242
+ textures.preferredHeight = 100;
1243
+
1244
+ CreateSkyboxPanel(oe.skyboxPanel);
11101245
11111246 // EDIT panel
11121247 editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1118,16 +1253,16 @@
11181253 uneditButton.addActionListener(this);
11191254
11201255 editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
1121
- allParamsButton.setToolTipText("Show all controle");
1256
+ allParamsButton.setToolTipText("Show all controls");
11221257 allParamsButton.addActionListener(this);
11231258
11241259 editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1125
- clearPanelButton.setToolTipText("Clear edit panel");
1260
+ clearPanelButton.setToolTipText("Clear all controls");
11261261 clearPanelButton.addActionListener(this);
11271262
1128
- editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1129
- unselectButton.setToolTipText("Unselect");
1130
- unselectButton.addActionListener(this);
1263
+ //editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1264
+ //unselectButton.setToolTipText("Unselect");
1265
+ //unselectButton.addActionListener(this);
11311266
11321267 editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11331268 flashSelectionButton.setToolTipText("Highlight selection");
....@@ -1322,6 +1457,14 @@
13221457
13231458 void EditObject(Object3D obj)
13241459 {
1460
+ assert(obj instanceof Composite);
1461
+
1462
+ if (obj.versionlist == null)
1463
+ {
1464
+ obj.versionlist = new Object3D[100];
1465
+ obj.versionindex = -1;
1466
+ }
1467
+
13251468 cRadio radioButton = new cRadio(obj.name);
13261469
13271470 // June 2019. Patch to avoid bug with transparency.
....@@ -1712,7 +1855,12 @@
17121855 TreePath path;
17131856
17141857 public TransferableTreePath(TreePath tp) {
1715
- path = tp;
1858
+ Object[] objs = new Object[tp.getPathCount()];
1859
+ for (int i=0; i<objs.length; i++)
1860
+ {
1861
+ objs[i] = ((Object3D)tp.getPathComponent(i)).GetUUID();
1862
+ }
1863
+ path = new TreePath(objs);
17161864 }
17171865
17181866 public synchronized DataFlavor[] getTransferDataFlavors() {
....@@ -2606,6 +2754,18 @@
26062754 {
26072755 ToggleFullScreen();
26082756 } else
2757
+ if (source == collapseButton)
2758
+ {
2759
+ this.expandedLayout = radio.layout;
2760
+ CollapseToolbar();
2761
+ } else
2762
+ if (source == maximize3DButton)
2763
+ {
2764
+ this.expandedLayout = radio.layout;
2765
+ radio.layout = twoButton;
2766
+ Show3DView();
2767
+ CollapseToolbar();
2768
+ } else
26092769 if (source == previousVersionButton)
26102770 {
26112771 // Go to previous version
....@@ -2617,13 +2777,13 @@
26172777 {
26182778 // Restore current version
26192779 Restore();
2620
- restoreButton.setEnabled(false);
2780
+ //restoreButton.setEnabled(false);
26212781 } else
26222782 if (source == replaceButton)
26232783 {
26242784 // Overwrite current version
26252785 Replace();
2626
- replaceButton.setEnabled(false);
2786
+ //replaceButton.setEnabled(false);
26272787 } else
26282788 if (source == nextVersionButton)
26292789 {
....@@ -3557,38 +3717,7 @@
35573717 if (CameraPane.FULLSCREEN)
35583718 fullscreenLayout = radio.layout;
35593719
3560
- // bug
3561
- //gridPanel.setDividerLocation(1.0);
3562
- //bigPanel.setDividerLocation(0.0);
3563
-// bigThree.remove(scenePanel);
3564
-// bigThree.remove(centralPanel);
3565
-// bigThree.remove(XYZPanel);
3566
-// aWindowConstraints.gridx = 0;
3567
-// aWindowConstraints.gridy = 0;
3568
-// aWindowConstraints.gridwidth = 1;
3569
-// // aConstraints.gridheight = 3;
3570
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3571
-// aWindowConstraints.weightx = 0;
3572
-// aWindowConstraints.weighty = 1;
3573
-// //bigThree.add(jtp, aWindowConstraints);
3574
-// aWindowConstraints.weightx = 1;
3575
-// aWindowConstraints.gridwidth = 3;
3576
-// // aConstraints.gridheight = 3;
3577
-// aWindowConstraints.gridx = 1;
3578
-// aWindowConstraints.fill = GridBagConstraints.BOTH;
3579
-// bigThree.add(centralPanel, aWindowConstraints);
3580
-// aWindowConstraints.weightx = 0;
3581
-// aWindowConstraints.gridx = 4;
3582
-// aWindowConstraints.gridwidth = 1;
3583
-// // aConstraints.gridheight = 3;
3584
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3585
-// //bigThree.add(XYZPanel, aWindowConstraints);
3586
-// scenePanel.setVisible(false);
3587
-// centralPanel.setVisible(true);
3588
-// XYZPanel.setVisible(false);
3589
- bigThree.ClearUI();
3590
- bigThree.add(centralPanel);
3591
- bigThree.FlushUI();
3720
+ Show3DView();
35923721
35933722 cameraView.requestFocusInWindow();
35943723
....@@ -3774,6 +3903,7 @@
37743903 } else
37753904 if (source == rootButton)
37763905 {
3906
+ Replace();
37773907 Object3D obj;
37783908 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
37793909 {
....@@ -3910,8 +4040,6 @@
39104040
39114041 copy = group;
39124042
3913
- SetUndoStates();
3914
-
39154043 //Globals.theRenderer.object = group;
39164044 if(!useclient)
39174045 {
....@@ -3939,6 +4067,8 @@
39394067 */
39404068 radio.layout.doClick();
39414069
4070
+ SetUndoStates();
4071
+
39424072 ClearUnpinned();
39434073
39444074 //Grafreed.Assert(group != null);
....@@ -5169,15 +5299,28 @@
51695299 {
51705300 editButton.setEnabled(enabled);
51715301 uneditButton.setEnabled(enabled);
5172
- unselectButton.setEnabled(enabled);
5302
+ //unselectButton.setEnabled(enabled);
51735303 flashSelectionButton.setEnabled(enabled);
51745304
51755305 clearPanelButton.setEnabled(!listUI.isEmpty());
5306
+
5307
+ boolean allComposites = true;
5308
+
5309
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
5310
+ {
5311
+ if (!(e.nextElement() instanceof Composite))
5312
+ {
5313
+ allComposites = false;
5314
+ break;
5315
+ }
5316
+ }
5317
+
5318
+ rootButton.setEnabled(allComposites);
51765319 }
51775320
51785321 void refreshContents(boolean cp)
51795322 {
5180
- if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
5323
+ //if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
51815324 if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
51825325 {
51835326 objEditor.ClearInfo(); // .GetMaterial());
....@@ -5187,7 +5330,7 @@
51875330 Object3D child = (Object3D) group.selection.get(i);
51885331
51895332 objEditor.AddInfo(child, this, true);
5190
- System.err.println("info : " + child.GetPath());
5333
+// System.err.println("info : " + child.GetPath());
51915334 }
51925335
51935336 objEditor.SetText(); // jan 2014