Normand Briere
2019-08-12 8f1afe25ea8fc8801aab66331c32a50859a758c2
GroupEditor.java
....@@ -16,7 +16,7 @@
1616 //import buoy.widget.BFileChooser;
1717
1818 class GroupEditor extends ObjEditor implements //iParse, //iCallBack,
19
- Grafreed.iResourceCallBack,
19
+ Grafreed.iResourceCallBack,
2020 ObjectUI,
2121 Runnable,
2222 ActionListener,
....@@ -42,6 +42,22 @@
4242 });
4343 }
4444
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
+
4561 public void AddSkyboxTab0(JTabbedPane skyboxpanel)
4662 {
4763 cGridBag tab0 = new cGridBag().setVertical(true);
....@@ -312,26 +328,47 @@
312328 }
313329 }
314330
315
- public void CallBack(String[] path)
316
- {
317
- for (int i = 0; i < path.length; i++)
318
- {
319
- System.out.print(path[i] + "/");
320
- }
321
-
322
- System.out.println();
323
- }
324
-
325331 public void ChangeSkybox(String skybox)
326332 {
327333 //cameraView.envyoff = false;
328334 group.skyboxname = skybox;
329335 group.skyboxext = "jpg";
330336 cameraView.repaint();
337
+ }
331338
332
- Grafreed.ParseResources("textures", this);
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);
333349 }
334350
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
+
335372 //ObjEditor objEditor;
336373 public void closeUI2()
337374 {
....@@ -373,6 +410,8 @@
373410 {
374411 copy.versionlist = new Object3D[100];
375412 copy.versionindex = -1;
413
+
414
+ Save(true);
376415 }
377416
378417 if(ui)
....@@ -604,11 +643,9 @@
604643 oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest"));
605644 //cameraMenu.add(lookFromItem = new MenuItem("Look From Selection"));
606645 //cameraMenu.add(switchViewItem = new MenuItem("Reverse View"));
607
- editLeafItem = oe.cameraMenu.add(new MenuItem("Edit Leaf"));
608646 oe.cameraMenu.add("-");
609647 openWindowItem = oe.cameraMenu.add(new MenuItem("Edit copy..."));
610648 openWindowItem.addActionListener(this);
611
- editLeafItem.addActionListener(this);
612649 lookAtItem.addActionListener(this);
613650 //lookFromItem.addActinoListener(this);
614651 //switchViewItem.addActionListener(this);
....@@ -856,6 +893,9 @@
856893 shareGeometriesItem.addActionListener(this);
857894 mergeGeometriesItem = menu.add(new MenuItem("Merge Geometries"));
858895 mergeGeometriesItem.addActionListener(this);
896
+ menu.add("-");
897
+ editLeafItem = menu.add(new MenuItem("Edit leaf..."));
898
+ editLeafItem.addActionListener(this);
859899 if (Globals.ADVANCED)
860900 {
861901 // Pretty much the same as duplicate and clone.
....@@ -872,6 +912,73 @@
872912 buildToolsMenu(menu);
873913 }
874914
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
+ }
875982
876983 void SetupUI2(ObjEditor oe)
877984 {
....@@ -890,11 +997,6 @@
890997 //new Exception().printStackTrace();
891998
892999 oe.radioPanel = new JPanel(new GridBagLayout());
893
- oe.aConstraints.weightx = 1;
894
- oe.aConstraints.weighty = 0;
895
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
896
- oe.aConstraints.gridwidth = 100;
897
- oe.aConstraints.gridheight = 1;
8981000 // oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
8991001
9001002 oe.buttonGroup = new ButtonGroup();
....@@ -927,10 +1029,49 @@
9271029
9281030 if (Globals.ADVANCED)
9291031 {
930
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
931
- maxButton.setToolTipText("Maximize window");
932
- 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);
9331035 }
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
+ //
9341075
9351076 oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9361077 fullButton.setToolTipText("Full-screen window");
....@@ -975,14 +1116,14 @@
9751116 nextVersionButton.addActionListener(this);
9761117 nextVersionButton.setEnabled(false);
9771118
978
- oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
979
- liveCB.setToolTipText("Enable animation");
980
- liveCB.addItemListener(this);
981
-
9821119 oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9831120 oneStepButton.setToolTipText("Animate one step forward");
9841121 oneStepButton.addActionListener(this);
9851122
1123
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
1124
+ liveCB.setToolTipText("Enable animation");
1125
+ liveCB.addItemListener(this);
1126
+
9861127 oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
9871128 fastCB.setToolTipText("Fast mode");
9881129 fastCB.addItemListener(this);
....@@ -1009,21 +1150,6 @@
10091150
10101151 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
10111152
1012
- oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1013
- twoButton.setToolTipText("Show 3D view only");
1014
- twoButton.addActionListener(this);
1015
- this.fullscreenLayout = twoButton;
1016
-
1017
- oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1018
- threeButton.setToolTipText("Show controls and 3D view");
1019
- threeButton.addActionListener(this);
1020
- oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1021
- sixButton.setToolTipText("Show 3D view and controls");
1022
- sixButton.addActionListener(this);
1023
-// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1024
-// sevenButton.setToolTipText("3-column layout");
1025
-// sevenButton.addActionListener(this);
1026
- //
10271153
10281154 oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10291155 rootButton.setToolTipText("Open selection in new tab");
....@@ -1039,7 +1165,7 @@
10391165
10401166 // INSERT
10411167 row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1042
- gridButton.setToolTipText("Create grid");
1168
+ gridButton.setToolTipText("Create ground");
10431169 gridButton.addActionListener(this);
10441170
10451171 row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1107,19 +1233,15 @@
11071233
11081234 oe.toolboxPanel.add(row2);
11091235
1110
- // ENVYMAPS
1111
- cGridBag skyboxpane = new cGridBag();
1112
- skyboxpane.preferredHeight = 100;
1236
+ cGridBag textures = new cGridBag();
11131237
1114
- oe.toolboxPanel.add(skyboxpane);
1238
+ CreateTexturePanel(textures);
11151239
1116
- JTabbedPane skyboxpanel = new JTabbedPane();
1117
- skyboxpane.add(skyboxpanel);
1240
+ oe.toolboxPanel.add(textures);
11181241
1119
- AddSkyboxTab0(skyboxpanel);
1120
- AddSkyboxTab1(skyboxpanel);
1121
- AddSkyboxTab2(skyboxpanel);
1122
- AddSkyboxTab3(skyboxpanel);
1242
+ textures.preferredHeight = 100;
1243
+
1244
+ CreateSkyboxPanel(oe.skyboxPanel);
11231245
11241246 // EDIT panel
11251247 editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1131,16 +1253,16 @@
11311253 uneditButton.addActionListener(this);
11321254
11331255 editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
1134
- allParamsButton.setToolTipText("Show all controle");
1256
+ allParamsButton.setToolTipText("Show all controls");
11351257 allParamsButton.addActionListener(this);
11361258
11371259 editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1138
- clearPanelButton.setToolTipText("Clear edit panel");
1260
+ clearPanelButton.setToolTipText("Clear all controls");
11391261 clearPanelButton.addActionListener(this);
11401262
1141
- editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1142
- unselectButton.setToolTipText("Unselect");
1143
- unselectButton.addActionListener(this);
1263
+ //editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1264
+ //unselectButton.setToolTipText("Unselect");
1265
+ //unselectButton.addActionListener(this);
11441266
11451267 editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11461268 flashSelectionButton.setToolTipText("Highlight selection");
....@@ -1335,6 +1457,14 @@
13351457
13361458 void EditObject(Object3D obj)
13371459 {
1460
+ assert(obj instanceof Composite);
1461
+
1462
+ if (obj.versionlist == null)
1463
+ {
1464
+ obj.versionlist = new Object3D[100];
1465
+ obj.versionindex = -1;
1466
+ }
1467
+
13381468 cRadio radioButton = new cRadio(obj.name);
13391469
13401470 // June 2019. Patch to avoid bug with transparency.
....@@ -1725,7 +1855,12 @@
17251855 TreePath path;
17261856
17271857 public TransferableTreePath(TreePath tp) {
1728
- 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);
17291864 }
17301865
17311866 public synchronized DataFlavor[] getTransferDataFlavors() {
....@@ -2618,6 +2753,18 @@
26182753 if (source == fullButton)
26192754 {
26202755 ToggleFullScreen();
2756
+ } 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();
26212768 } else
26222769 if (source == previousVersionButton)
26232770 {
....@@ -3570,38 +3717,7 @@
35703717 if (CameraPane.FULLSCREEN)
35713718 fullscreenLayout = radio.layout;
35723719
3573
- // bug
3574
- //gridPanel.setDividerLocation(1.0);
3575
- //bigPanel.setDividerLocation(0.0);
3576
-// bigThree.remove(scenePanel);
3577
-// bigThree.remove(centralPanel);
3578
-// bigThree.remove(XYZPanel);
3579
-// aWindowConstraints.gridx = 0;
3580
-// aWindowConstraints.gridy = 0;
3581
-// aWindowConstraints.gridwidth = 1;
3582
-// // aConstraints.gridheight = 3;
3583
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3584
-// aWindowConstraints.weightx = 0;
3585
-// aWindowConstraints.weighty = 1;
3586
-// //bigThree.add(jtp, aWindowConstraints);
3587
-// aWindowConstraints.weightx = 1;
3588
-// aWindowConstraints.gridwidth = 3;
3589
-// // aConstraints.gridheight = 3;
3590
-// aWindowConstraints.gridx = 1;
3591
-// aWindowConstraints.fill = GridBagConstraints.BOTH;
3592
-// bigThree.add(centralPanel, aWindowConstraints);
3593
-// aWindowConstraints.weightx = 0;
3594
-// aWindowConstraints.gridx = 4;
3595
-// aWindowConstraints.gridwidth = 1;
3596
-// // aConstraints.gridheight = 3;
3597
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3598
-// //bigThree.add(XYZPanel, aWindowConstraints);
3599
-// scenePanel.setVisible(false);
3600
-// centralPanel.setVisible(true);
3601
-// XYZPanel.setVisible(false);
3602
- bigThree.ClearUI();
3603
- bigThree.add(centralPanel);
3604
- bigThree.FlushUI();
3720
+ Show3DView();
36053721
36063722 cameraView.requestFocusInWindow();
36073723
....@@ -3787,6 +3903,7 @@
37873903 } else
37883904 if (source == rootButton)
37893905 {
3906
+ Replace();
37903907 Object3D obj;
37913908 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
37923909 {
....@@ -3923,8 +4040,6 @@
39234040
39244041 copy = group;
39254042
3926
- SetUndoStates();
3927
-
39284043 //Globals.theRenderer.object = group;
39294044 if(!useclient)
39304045 {
....@@ -3952,6 +4067,8 @@
39524067 */
39534068 radio.layout.doClick();
39544069
4070
+ SetUndoStates();
4071
+
39554072 ClearUnpinned();
39564073
39574074 //Grafreed.Assert(group != null);
....@@ -5182,15 +5299,28 @@
51825299 {
51835300 editButton.setEnabled(enabled);
51845301 uneditButton.setEnabled(enabled);
5185
- unselectButton.setEnabled(enabled);
5302
+ //unselectButton.setEnabled(enabled);
51865303 flashSelectionButton.setEnabled(enabled);
51875304
51885305 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);
51895319 }
51905320
51915321 void refreshContents(boolean cp)
51925322 {
5193
- if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
5323
+ //if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
51945324 if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
51955325 {
51965326 objEditor.ClearInfo(); // .GetMaterial());
....@@ -5200,7 +5330,7 @@
52005330 Object3D child = (Object3D) group.selection.get(i);
52015331
52025332 objEditor.AddInfo(child, this, true);
5203
- System.err.println("info : " + child.GetPath());
5333
+// System.err.println("info : " + child.GetPath());
52045334 }
52055335
52065336 objEditor.SetText(); // jan 2014