Normand Briere
2019-08-13 c67de8aca04d988179191ccb52461af00125920e
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,
....@@ -30,7 +31,7 @@
3031 final String path = "cubemaps/" + f + "-skyboxes/" + s;
3132 row.add(skyboxButton = GetButton(path + "/preview.jpg", !Grafreed.NIMBUSLAF));
3233 //row.add(skyboxButton = GetButton(path + "/negx.jpg", !Grafreed.NIMBUSLAF));
33
- skyboxButton.setToolTipText(s);
34
+ skyboxButton.setToolTipText(s.equals("") ? "No background" : s);
3435 skyboxButton.addActionListener(new ActionListener()
3536 {
3637 @Override
....@@ -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);
....@@ -56,7 +73,7 @@
5673 cGridBag row5 = new cGridBag();
5774 cGridBag row6 = new cGridBag();
5875
59
- AddSkyboxButton("default", "rgb", row0);
76
+ AddSkyboxButton("default", "", row0);
6077 //AddSkyboxButton("default", "cornell", row0);
6178 AddSkyboxButton("penguins", "dust", row0);
6279 AddSkyboxButton("penguins", "tropic", row0);
....@@ -311,14 +328,56 @@
311328 }
312329 }
313330
314
- public void ChangeSkybox(String name)
331
+ public void ChangeSkybox(String skybox)
315332 {
316
- //cameraView.envyoff = false;
317
- group.skyboxname = name;
318
- group.skyboxext = "jpg";
319
- cameraView.repaint();
333
+ if (skybox.endsWith("/"))
334
+ {
335
+ group.skyboxname = null;
336
+ group.skyboxext = null;
337
+ cameraView.repaint();
338
+ }
339
+ else
340
+ {
341
+ //cameraView.envyoff = false;
342
+ group.skyboxname = skybox;
343
+ group.skyboxext = "jpg";
344
+ cameraView.repaint();
345
+ }
346
+ }
347
+
348
+ public void CreateSkyboxPanel(cGridBag skyboxPanel)
349
+ {
350
+ JTabbedPane skyboxpane = new JTabbedPane();
351
+
352
+ AddSkyboxTab0(skyboxpane);
353
+ AddSkyboxTab1(skyboxpane);
354
+ AddSkyboxTab2(skyboxpane);
355
+ AddSkyboxTab3(skyboxpane);
356
+
357
+ skyboxPanel.add(skyboxpane);
320358 }
321359
360
+ public void ChangeTexture(String texture)
361
+ {
362
+ for (int i=0; i<group.selection.size(); i++)
363
+ {
364
+ Object3D obj = group.selection.get(i);
365
+ obj.SetPigmentTexture("@" + texture);
366
+ }
367
+
368
+ refreshContents();
369
+ }
370
+
371
+ public void Show3DView()
372
+ {
373
+ // bug
374
+ //gridPanel.setDividerLocation(1.0);
375
+ //bigPanel.setDividerLocation(0.0);
376
+ bigThree.ClearUI();
377
+ bigThree.add(centralPanel);
378
+ bigThree.FlushUI();
379
+ }
380
+
322381 //ObjEditor objEditor;
323382 public void closeUI2()
324383 {
....@@ -360,6 +419,8 @@
360419 {
361420 copy.versionlist = new Object3D[100];
362421 copy.versionindex = -1;
422
+
423
+ Save(true);
363424 }
364425
365426 if(ui)
....@@ -591,11 +652,9 @@
591652 oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest"));
592653 //cameraMenu.add(lookFromItem = new MenuItem("Look From Selection"));
593654 //cameraMenu.add(switchViewItem = new MenuItem("Reverse View"));
594
- editLeafItem = oe.cameraMenu.add(new MenuItem("Edit Leaf"));
595655 oe.cameraMenu.add("-");
596656 openWindowItem = oe.cameraMenu.add(new MenuItem("Edit copy..."));
597657 openWindowItem.addActionListener(this);
598
- editLeafItem.addActionListener(this);
599658 lookAtItem.addActionListener(this);
600659 //lookFromItem.addActinoListener(this);
601660 //switchViewItem.addActionListener(this);
....@@ -843,6 +902,9 @@
843902 shareGeometriesItem.addActionListener(this);
844903 mergeGeometriesItem = menu.add(new MenuItem("Merge Geometries"));
845904 mergeGeometriesItem.addActionListener(this);
905
+ menu.add("-");
906
+ editLeafItem = menu.add(new MenuItem("Edit leaf..."));
907
+ editLeafItem.addActionListener(this);
846908 if (Globals.ADVANCED)
847909 {
848910 // Pretty much the same as duplicate and clone.
....@@ -859,6 +921,73 @@
859921 buildToolsMenu(menu);
860922 }
861923
924
+ JTabbedPane resourcecontainer;
925
+ cGridBag currenttab;
926
+ boolean added; // patch for jar
927
+
928
+ int tabcount = 0;
929
+ int colcount = 0;
930
+ int rowcount = 0;
931
+ int texturecount = 0;
932
+
933
+ int columns = 5;
934
+ int rows = 7;
935
+
936
+ public void ResourceCallBack(String[] path)
937
+ {
938
+// for (int i = 0; i < path.length; i++)
939
+// System.out.print(path[i] + "/");
940
+// System.out.println();
941
+
942
+ if (//rowcount == 0 ||
943
+ path.length == 1)
944
+ {
945
+ currenttab = new cGridBag();
946
+ added = false;
947
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
948
+ currenttab.setName(tabname);
949
+ rowcount = 1;
950
+ colcount = 0;
951
+ texturecount = 0;
952
+ }
953
+
954
+ if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
955
+ {
956
+ if (!added)
957
+ {
958
+ added = true;
959
+ resourcecontainer.add(currenttab);
960
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
961
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
962
+ }
963
+
964
+ AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
965
+
966
+ if (++colcount >= columns)
967
+ {
968
+ colcount = 0;
969
+ currenttab.Return();
970
+
971
+ if (rowcount++ >= rows)
972
+ {
973
+ rowcount = 0;
974
+ }
975
+ }
976
+ }
977
+ else
978
+ {
979
+// if (!path[path.length-1].equals("icons"))
980
+// resourcecontainer.Return();
981
+ }
982
+ }
983
+
984
+ void CreateTexturePanel(cGridBag container)
985
+ {
986
+ resourcecontainer = new JTabbedPane(JTabbedPane.LEFT);
987
+ container.add(resourcecontainer);
988
+
989
+ Grafreed.ParseResources("textures", this);
990
+ }
862991
863992 void SetupUI2(ObjEditor oe)
864993 {
....@@ -877,11 +1006,6 @@
8771006 //new Exception().printStackTrace();
8781007
8791008 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;
8851009 // oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
8861010
8871011 oe.buttonGroup = new ButtonGroup();
....@@ -914,10 +1038,49 @@
9141038
9151039 if (Globals.ADVANCED)
9161040 {
917
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
918
- maxButton.setToolTipText("Maximize window");
919
- maxButton.addActionListener(this);
1041
+// oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1042
+// maxButton.setToolTipText("Maximize window");
1043
+// maxButton.addActionListener(this);
9201044 }
1045
+
1046
+// cButton gcButton;
1047
+//
1048
+// oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1049
+// gcButton.setToolTipText("Garbage collect");
1050
+// gcButton.addActionListener(new ActionListener()
1051
+// {
1052
+// public void actionPerformed(ActionEvent e)
1053
+// {
1054
+// System.gc();
1055
+// }
1056
+// });
1057
+
1058
+ oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1059
+ collapseButton.setToolTipText("Collapse toolbar");
1060
+ collapseButton.addActionListener(this);
1061
+
1062
+ oe.toolbarPanel.add(maximize3DButton = GetButton("", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1063
+ maximize3DButton.setToolTipText("Maximize 3D view");
1064
+ maximize3DButton.addActionListener(this);
1065
+
1066
+ oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1067
+ twoButton.setToolTipText("Show 3D view only");
1068
+ twoButton.addActionListener(this);
1069
+ this.fullscreenLayout = twoButton;
1070
+
1071
+ oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1072
+ threeButton.setToolTipText("Show controls and 3D view");
1073
+ threeButton.addActionListener(this);
1074
+ if (Globals.ADVANCED)
1075
+ {
1076
+ oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1077
+ sixButton.setToolTipText("Show 3D view and controls");
1078
+ sixButton.addActionListener(this);
1079
+ }
1080
+// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1081
+// sevenButton.setToolTipText("3-column layout");
1082
+// sevenButton.addActionListener(this);
1083
+ //
9211084
9221085 oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9231086 fullButton.setToolTipText("Full-screen window");
....@@ -962,14 +1125,14 @@
9621125 nextVersionButton.addActionListener(this);
9631126 nextVersionButton.setEnabled(false);
9641127
965
- oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
966
- liveCB.setToolTipText("Enable animation");
967
- liveCB.addItemListener(this);
968
-
9691128 oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9701129 oneStepButton.setToolTipText("Animate one step forward");
9711130 oneStepButton.addActionListener(this);
9721131
1132
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
1133
+ liveCB.setToolTipText("Enable animation");
1134
+ liveCB.addItemListener(this);
1135
+
9731136 oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
9741137 fastCB.setToolTipText("Fast mode");
9751138 fastCB.addItemListener(this);
....@@ -996,21 +1159,6 @@
9961159
9971160 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
9981161
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
- //
10141162
10151163 oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10161164 rootButton.setToolTipText("Open selection in new tab");
....@@ -1026,7 +1174,7 @@
10261174
10271175 // INSERT
10281176 row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1029
- gridButton.setToolTipText("Create grid");
1177
+ gridButton.setToolTipText("Create ground");
10301178 gridButton.addActionListener(this);
10311179
10321180 row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1094,19 +1242,15 @@
10941242
10951243 oe.toolboxPanel.add(row2);
10961244
1097
- // ENVYMAPS
1098
- cGridBag skyboxpane = new cGridBag();
1099
- skyboxpane.preferredHeight = 100;
1245
+ cGridBag textures = new cGridBag();
11001246
1101
- oe.toolboxPanel.add(skyboxpane);
1247
+ CreateTexturePanel(textures);
11021248
1103
- JTabbedPane skyboxpanel = new JTabbedPane();
1104
- skyboxpane.add(skyboxpanel);
1249
+ oe.toolboxPanel.add(textures);
11051250
1106
- AddSkyboxTab0(skyboxpanel);
1107
- AddSkyboxTab1(skyboxpanel);
1108
- AddSkyboxTab2(skyboxpanel);
1109
- AddSkyboxTab3(skyboxpanel);
1251
+ textures.preferredHeight = 100;
1252
+
1253
+ CreateSkyboxPanel(oe.skyboxPanel);
11101254
11111255 // EDIT panel
11121256 editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1118,16 +1262,16 @@
11181262 uneditButton.addActionListener(this);
11191263
11201264 editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
1121
- allParamsButton.setToolTipText("Show all controle");
1265
+ allParamsButton.setToolTipText("Show all controls");
11221266 allParamsButton.addActionListener(this);
11231267
11241268 editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1125
- clearPanelButton.setToolTipText("Clear edit panel");
1269
+ clearPanelButton.setToolTipText("Clear all controls");
11261270 clearPanelButton.addActionListener(this);
11271271
1128
- editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1129
- unselectButton.setToolTipText("Unselect");
1130
- unselectButton.addActionListener(this);
1272
+ //editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1273
+ //unselectButton.setToolTipText("Unselect");
1274
+ //unselectButton.addActionListener(this);
11311275
11321276 editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11331277 flashSelectionButton.setToolTipText("Highlight selection");
....@@ -1322,6 +1466,14 @@
13221466
13231467 void EditObject(Object3D obj)
13241468 {
1469
+ assert(obj instanceof Composite);
1470
+
1471
+// if (obj.versionlist == null)
1472
+// {
1473
+// obj.versionlist = new Object3D[100];
1474
+// obj.versionindex = -1;
1475
+// }
1476
+
13251477 cRadio radioButton = new cRadio(obj.name);
13261478
13271479 // June 2019. Patch to avoid bug with transparency.
....@@ -1712,7 +1864,12 @@
17121864 TreePath path;
17131865
17141866 public TransferableTreePath(TreePath tp) {
1715
- path = tp;
1867
+ Object[] objs = new Object[tp.getPathCount()];
1868
+ for (int i=0; i<objs.length; i++)
1869
+ {
1870
+ objs[i] = ((Object3D)tp.getPathComponent(i)).GetUUID();
1871
+ }
1872
+ path = new TreePath(objs);
17161873 }
17171874
17181875 public synchronized DataFlavor[] getTransferDataFlavors() {
....@@ -2605,6 +2762,18 @@
26052762 if (source == fullButton)
26062763 {
26072764 ToggleFullScreen();
2765
+ } else
2766
+ if (source == collapseButton)
2767
+ {
2768
+ this.expandedLayout = radio.layout;
2769
+ CollapseToolbar();
2770
+ } else
2771
+ if (source == maximize3DButton)
2772
+ {
2773
+ this.expandedLayout = radio.layout;
2774
+ radio.layout = twoButton;
2775
+ Show3DView();
2776
+ CollapseToolbar();
26082777 } else
26092778 if (source == previousVersionButton)
26102779 {
....@@ -3557,38 +3726,7 @@
35573726 if (CameraPane.FULLSCREEN)
35583727 fullscreenLayout = radio.layout;
35593728
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();
3729
+ Show3DView();
35923730
35933731 cameraView.requestFocusInWindow();
35943732
....@@ -3774,6 +3912,7 @@
37743912 } else
37753913 if (source == rootButton)
37763914 {
3915
+ Replace();
37773916 Object3D obj;
37783917 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
37793918 {
....@@ -3910,8 +4049,6 @@
39104049
39114050 copy = group;
39124051
3913
- SetUndoStates();
3914
-
39154052 //Globals.theRenderer.object = group;
39164053 if(!useclient)
39174054 {
....@@ -3939,6 +4076,18 @@
39394076 */
39404077 radio.layout.doClick();
39414078
4079
+ assert(copy instanceof Composite);
4080
+
4081
+ if (copy.versionlist == null)
4082
+ {
4083
+ copy.versionlist = new Object3D[100];
4084
+ copy.versionindex = -1;
4085
+
4086
+ Save(true);
4087
+ }
4088
+
4089
+ SetVersionStates();
4090
+
39424091 ClearUnpinned();
39434092
39444093 //Grafreed.Assert(group != null);
....@@ -5169,15 +5318,28 @@
51695318 {
51705319 editButton.setEnabled(enabled);
51715320 uneditButton.setEnabled(enabled);
5172
- unselectButton.setEnabled(enabled);
5321
+ //unselectButton.setEnabled(enabled);
51735322 flashSelectionButton.setEnabled(enabled);
51745323
51755324 clearPanelButton.setEnabled(!listUI.isEmpty());
5325
+
5326
+ boolean allComposites = true;
5327
+
5328
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
5329
+ {
5330
+ if (!(e.nextElement() instanceof Composite))
5331
+ {
5332
+ allComposites = false;
5333
+ break;
5334
+ }
5335
+ }
5336
+
5337
+ rootButton.setEnabled(allComposites);
51765338 }
51775339
51785340 void refreshContents(boolean cp)
51795341 {
5180
- if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
5342
+ //if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
51815343 if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
51825344 {
51835345 objEditor.ClearInfo(); // .GetMaterial());
....@@ -5187,7 +5349,7 @@
51875349 Object3D child = (Object3D) group.selection.get(i);
51885350
51895351 objEditor.AddInfo(child, this, true);
5190
- System.err.println("info : " + child.GetPath());
5352
+// System.err.println("info : " + child.GetPath());
51915353 }
51925354
51935355 objEditor.SetText(); // jan 2014