Normand Briere
2019-08-14 0c1f740dd6ddd6432dc29266e42ef851e26027bb
GroupEditor.java
....@@ -31,7 +31,7 @@
3131 final String path = "cubemaps/" + f + "-skyboxes/" + s;
3232 row.add(skyboxButton = GetButton(path + "/preview.jpg", !Grafreed.NIMBUSLAF));
3333 //row.add(skyboxButton = GetButton(path + "/negx.jpg", !Grafreed.NIMBUSLAF));
34
- skyboxButton.setToolTipText(s);
34
+ skyboxButton.setToolTipText(s.equals("") ? "No background" : s);
3535 skyboxButton.addActionListener(new ActionListener()
3636 {
3737 @Override
....@@ -42,12 +42,12 @@
4242 });
4343 }
4444
45
- public void AddTextureButton(String f, final String t, cGridBag row)
45
+ public void AddTextureButton(String f, String c, final String t, int count, cGridBag row)
4646 {
4747 cButton textureButton;
48
- final String path = "textures/" + f + "/"; // + t;
48
+ final String path = "textures/" + f + "/" + c + "/"; // + t;
4949 row.add(textureButton = GetButton(path + "icons/" + t, !Grafreed.NIMBUSLAF));
50
- textureButton.setToolTipText(f + "s");
50
+ textureButton.setToolTipText(c + count);
5151 textureButton.addActionListener(new ActionListener()
5252 {
5353 @Override
....@@ -73,7 +73,7 @@
7373 cGridBag row5 = new cGridBag();
7474 cGridBag row6 = new cGridBag();
7575
76
- AddSkyboxButton("default", "rgb", row0);
76
+ AddSkyboxButton("default", "", row0);
7777 //AddSkyboxButton("default", "cornell", row0);
7878 AddSkyboxButton("penguins", "dust", row0);
7979 AddSkyboxButton("penguins", "tropic", row0);
....@@ -330,10 +330,19 @@
330330
331331 public void ChangeSkybox(String skybox)
332332 {
333
- //cameraView.envyoff = false;
334
- group.skyboxname = skybox;
335
- group.skyboxext = "jpg";
336
- 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
+ }
337346 }
338347
339348 public void CreateSkyboxPanel(cGridBag skyboxPanel)
....@@ -350,7 +359,23 @@
350359
351360 public void ChangeTexture(String texture)
352361 {
353
- cameraView.repaint();
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();
354379 }
355380
356381 //ObjEditor objEditor;
....@@ -394,6 +419,8 @@
394419 {
395420 copy.versionlist = new Object3D[100];
396421 copy.versionindex = -1;
422
+
423
+ Save(true);
397424 }
398425
399426 if(ui)
....@@ -625,11 +652,9 @@
625652 oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest"));
626653 //cameraMenu.add(lookFromItem = new MenuItem("Look From Selection"));
627654 //cameraMenu.add(switchViewItem = new MenuItem("Reverse View"));
628
- editLeafItem = oe.cameraMenu.add(new MenuItem("Edit Leaf"));
629655 oe.cameraMenu.add("-");
630656 openWindowItem = oe.cameraMenu.add(new MenuItem("Edit copy..."));
631657 openWindowItem.addActionListener(this);
632
- editLeafItem.addActionListener(this);
633658 lookAtItem.addActionListener(this);
634659 //lookFromItem.addActinoListener(this);
635660 //switchViewItem.addActionListener(this);
....@@ -877,6 +902,9 @@
877902 shareGeometriesItem.addActionListener(this);
878903 mergeGeometriesItem = menu.add(new MenuItem("Merge Geometries"));
879904 mergeGeometriesItem.addActionListener(this);
905
+ menu.add("-");
906
+ editLeafItem = menu.add(new MenuItem("Edit leaf..."));
907
+ editLeafItem.addActionListener(this);
880908 if (Globals.ADVANCED)
881909 {
882910 // Pretty much the same as duplicate and clone.
....@@ -900,35 +928,41 @@
900928 int tabcount = 0;
901929 int colcount = 0;
902930 int rowcount = 0;
931
+ int texturecount = 0;
903932
904933 int columns = 5;
905934 int rows = 7;
906935
907936 public void ResourceCallBack(String[] path)
908937 {
909
- for (int i = 0; i < path.length; i++)
910
- System.out.print(path[i] + "/");
911
- System.out.println();
912
- if (rowcount == 0)
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)
913944 {
914945 currenttab = new cGridBag();
915946 added = false;
916
- String tabname = String.valueOf((char)('A'+tabcount));
947
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
917948 currenttab.setName(tabname);
918949 rowcount = 1;
950
+ colcount = 0;
951
+ texturecount = 0;
919952 }
920953
921
- if (path.length > 1 && path[1].toLowerCase().endsWith(".jpg"))
954
+ if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
922955 {
923956 if (!added)
924957 {
925958 added = true;
926959 resourcecontainer.add(currenttab);
927
- String tabname = String.valueOf((char)('A'+tabcount));
960
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
928961 resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
929962 }
930963
931
- AddTextureButton(path[0], path[1], currenttab);
964
+ AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
965
+
932966 if (++colcount >= columns)
933967 {
934968 colcount = 0;
....@@ -949,7 +983,7 @@
949983
950984 void CreateTexturePanel(cGridBag container)
951985 {
952
- resourcecontainer = new JTabbedPane();
986
+ resourcecontainer = new JTabbedPane(JTabbedPane.LEFT);
953987 container.add(resourcecontainer);
954988
955989 Grafreed.ParseResources("textures", this);
....@@ -972,11 +1006,6 @@
9721006 //new Exception().printStackTrace();
9731007
9741008 oe.radioPanel = new JPanel(new GridBagLayout());
975
- oe.aConstraints.weightx = 1;
976
- oe.aConstraints.weighty = 0;
977
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
978
- oe.aConstraints.gridwidth = 100;
979
- oe.aConstraints.gridheight = 1;
9801009 // oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
9811010
9821011 oe.buttonGroup = new ButtonGroup();
....@@ -1009,10 +1038,49 @@
10091038
10101039 if (Globals.ADVANCED)
10111040 {
1012
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1013
- maxButton.setToolTipText("Maximize window");
1014
- 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);
10151044 }
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
+ //
10161084
10171085 oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10181086 fullButton.setToolTipText("Full-screen window");
....@@ -1057,14 +1125,14 @@
10571125 nextVersionButton.addActionListener(this);
10581126 nextVersionButton.setEnabled(false);
10591127
1060
- oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
1061
- liveCB.setToolTipText("Enable animation");
1062
- liveCB.addItemListener(this);
1063
-
10641128 oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10651129 oneStepButton.setToolTipText("Animate one step forward");
10661130 oneStepButton.addActionListener(this);
10671131
1132
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
1133
+ liveCB.setToolTipText("Enable animation");
1134
+ liveCB.addItemListener(this);
1135
+
10681136 oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
10691137 fastCB.setToolTipText("Fast mode");
10701138 fastCB.addItemListener(this);
....@@ -1091,21 +1159,6 @@
10911159
10921160 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
10931161
1094
- oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1095
- twoButton.setToolTipText("Show 3D view only");
1096
- twoButton.addActionListener(this);
1097
- this.fullscreenLayout = twoButton;
1098
-
1099
- oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1100
- threeButton.setToolTipText("Show controls and 3D view");
1101
- threeButton.addActionListener(this);
1102
- oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1103
- sixButton.setToolTipText("Show 3D view and controls");
1104
- sixButton.addActionListener(this);
1105
-// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1106
-// sevenButton.setToolTipText("3-column layout");
1107
-// sevenButton.addActionListener(this);
1108
- //
11091162
11101163 oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11111164 rootButton.setToolTipText("Open selection in new tab");
....@@ -1121,7 +1174,7 @@
11211174
11221175 // INSERT
11231176 row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1124
- gridButton.setToolTipText("Create grid");
1177
+ gridButton.setToolTipText("Create ground");
11251178 gridButton.addActionListener(this);
11261179
11271180 row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1413,6 +1466,14 @@
14131466
14141467 void EditObject(Object3D obj)
14151468 {
1469
+ assert(obj instanceof Composite);
1470
+
1471
+// if (obj.versionlist == null)
1472
+// {
1473
+// obj.versionlist = new Object3D[100];
1474
+// obj.versionindex = -1;
1475
+// }
1476
+
14161477 cRadio radioButton = new cRadio(obj.name);
14171478
14181479 // June 2019. Patch to avoid bug with transparency.
....@@ -1803,7 +1864,12 @@
18031864 TreePath path;
18041865
18051866 public TransferableTreePath(TreePath tp) {
1806
- 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);
18071873 }
18081874
18091875 public synchronized DataFlavor[] getTransferDataFlavors() {
....@@ -2696,6 +2762,18 @@
26962762 if (source == fullButton)
26972763 {
26982764 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();
26992777 } else
27002778 if (source == previousVersionButton)
27012779 {
....@@ -3648,38 +3726,7 @@
36483726 if (CameraPane.FULLSCREEN)
36493727 fullscreenLayout = radio.layout;
36503728
3651
- // bug
3652
- //gridPanel.setDividerLocation(1.0);
3653
- //bigPanel.setDividerLocation(0.0);
3654
-// bigThree.remove(scenePanel);
3655
-// bigThree.remove(centralPanel);
3656
-// bigThree.remove(XYZPanel);
3657
-// aWindowConstraints.gridx = 0;
3658
-// aWindowConstraints.gridy = 0;
3659
-// aWindowConstraints.gridwidth = 1;
3660
-// // aConstraints.gridheight = 3;
3661
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3662
-// aWindowConstraints.weightx = 0;
3663
-// aWindowConstraints.weighty = 1;
3664
-// //bigThree.add(jtp, aWindowConstraints);
3665
-// aWindowConstraints.weightx = 1;
3666
-// aWindowConstraints.gridwidth = 3;
3667
-// // aConstraints.gridheight = 3;
3668
-// aWindowConstraints.gridx = 1;
3669
-// aWindowConstraints.fill = GridBagConstraints.BOTH;
3670
-// bigThree.add(centralPanel, aWindowConstraints);
3671
-// aWindowConstraints.weightx = 0;
3672
-// aWindowConstraints.gridx = 4;
3673
-// aWindowConstraints.gridwidth = 1;
3674
-// // aConstraints.gridheight = 3;
3675
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3676
-// //bigThree.add(XYZPanel, aWindowConstraints);
3677
-// scenePanel.setVisible(false);
3678
-// centralPanel.setVisible(true);
3679
-// XYZPanel.setVisible(false);
3680
- bigThree.ClearUI();
3681
- bigThree.add(centralPanel);
3682
- bigThree.FlushUI();
3729
+ Show3DView();
36833730
36843731 cameraView.requestFocusInWindow();
36853732
....@@ -3865,6 +3912,7 @@
38653912 } else
38663913 if (source == rootButton)
38673914 {
3915
+ Replace();
38683916 Object3D obj;
38693917 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
38703918 {
....@@ -4001,8 +4049,6 @@
40014049
40024050 copy = group;
40034051
4004
- SetUndoStates();
4005
-
40064052 //Globals.theRenderer.object = group;
40074053 if(!useclient)
40084054 {
....@@ -4030,6 +4076,18 @@
40304076 */
40314077 radio.layout.doClick();
40324078
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
+
40334091 ClearUnpinned();
40344092
40354093 //Grafreed.Assert(group != null);
....@@ -5264,6 +5322,20 @@
52645322 flashSelectionButton.setEnabled(enabled);
52655323
52665324 clearPanelButton.setEnabled(!listUI.isEmpty());
5325
+
5326
+ boolean allComposites = true;
5327
+
5328
+ if (group.selection != null)
5329
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
5330
+ {
5331
+ if (!(e.nextElement() instanceof Composite))
5332
+ {
5333
+ allComposites = false;
5334
+ break;
5335
+ }
5336
+ }
5337
+
5338
+ rootButton.setEnabled(allComposites);
52675339 }
52685340
52695341 void refreshContents(boolean cp)
....@@ -5278,7 +5350,7 @@
52785350 Object3D child = (Object3D) group.selection.get(i);
52795351
52805352 objEditor.AddInfo(child, this, true);
5281
- System.err.println("info : " + child.GetPath());
5353
+// System.err.println("info : " + child.GetPath());
52825354 }
52835355
52845356 objEditor.SetText(); // jan 2014