Normand Briere
2019-08-12 8f1afe25ea8fc8801aab66331c32a50859a758c2
GroupEditor.java
....@@ -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
....@@ -350,7 +350,23 @@
350350
351351 public void ChangeTexture(String texture)
352352 {
353
- cameraView.repaint();
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();
354370 }
355371
356372 //ObjEditor objEditor;
....@@ -394,6 +410,8 @@
394410 {
395411 copy.versionlist = new Object3D[100];
396412 copy.versionindex = -1;
413
+
414
+ Save(true);
397415 }
398416
399417 if(ui)
....@@ -625,11 +643,9 @@
625643 oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest"));
626644 //cameraMenu.add(lookFromItem = new MenuItem("Look From Selection"));
627645 //cameraMenu.add(switchViewItem = new MenuItem("Reverse View"));
628
- editLeafItem = oe.cameraMenu.add(new MenuItem("Edit Leaf"));
629646 oe.cameraMenu.add("-");
630647 openWindowItem = oe.cameraMenu.add(new MenuItem("Edit copy..."));
631648 openWindowItem.addActionListener(this);
632
- editLeafItem.addActionListener(this);
633649 lookAtItem.addActionListener(this);
634650 //lookFromItem.addActinoListener(this);
635651 //switchViewItem.addActionListener(this);
....@@ -877,6 +893,9 @@
877893 shareGeometriesItem.addActionListener(this);
878894 mergeGeometriesItem = menu.add(new MenuItem("Merge Geometries"));
879895 mergeGeometriesItem.addActionListener(this);
896
+ menu.add("-");
897
+ editLeafItem = menu.add(new MenuItem("Edit leaf..."));
898
+ editLeafItem.addActionListener(this);
880899 if (Globals.ADVANCED)
881900 {
882901 // Pretty much the same as duplicate and clone.
....@@ -900,35 +919,41 @@
900919 int tabcount = 0;
901920 int colcount = 0;
902921 int rowcount = 0;
922
+ int texturecount = 0;
903923
904924 int columns = 5;
905925 int rows = 7;
906926
907927 public void ResourceCallBack(String[] path)
908928 {
909
- for (int i = 0; i < path.length; i++)
910
- System.out.print(path[i] + "/");
911
- System.out.println();
912
- if (rowcount == 0)
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)
913935 {
914936 currenttab = new cGridBag();
915937 added = false;
916
- String tabname = String.valueOf((char)('A'+tabcount));
938
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
917939 currenttab.setName(tabname);
918940 rowcount = 1;
941
+ colcount = 0;
942
+ texturecount = 0;
919943 }
920944
921
- if (path.length > 1 && path[1].toLowerCase().endsWith(".jpg"))
945
+ if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
922946 {
923947 if (!added)
924948 {
925949 added = true;
926950 resourcecontainer.add(currenttab);
927
- String tabname = String.valueOf((char)('A'+tabcount));
951
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
928952 resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
929953 }
930954
931
- AddTextureButton(path[0], path[1], currenttab);
955
+ AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
956
+
932957 if (++colcount >= columns)
933958 {
934959 colcount = 0;
....@@ -949,7 +974,7 @@
949974
950975 void CreateTexturePanel(cGridBag container)
951976 {
952
- resourcecontainer = new JTabbedPane();
977
+ resourcecontainer = new JTabbedPane(JTabbedPane.LEFT);
953978 container.add(resourcecontainer);
954979
955980 Grafreed.ParseResources("textures", this);
....@@ -972,11 +997,6 @@
972997 //new Exception().printStackTrace();
973998
974999 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;
9801000 // oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
9811001
9821002 oe.buttonGroup = new ButtonGroup();
....@@ -1009,10 +1029,49 @@
10091029
10101030 if (Globals.ADVANCED)
10111031 {
1012
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1013
- maxButton.setToolTipText("Maximize window");
1014
- 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);
10151035 }
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
+ //
10161075
10171076 oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10181077 fullButton.setToolTipText("Full-screen window");
....@@ -1057,14 +1116,14 @@
10571116 nextVersionButton.addActionListener(this);
10581117 nextVersionButton.setEnabled(false);
10591118
1060
- oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
1061
- liveCB.setToolTipText("Enable animation");
1062
- liveCB.addItemListener(this);
1063
-
10641119 oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10651120 oneStepButton.setToolTipText("Animate one step forward");
10661121 oneStepButton.addActionListener(this);
10671122
1123
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
1124
+ liveCB.setToolTipText("Enable animation");
1125
+ liveCB.addItemListener(this);
1126
+
10681127 oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
10691128 fastCB.setToolTipText("Fast mode");
10701129 fastCB.addItemListener(this);
....@@ -1091,21 +1150,6 @@
10911150
10921151 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
10931152
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
- //
11091153
11101154 oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11111155 rootButton.setToolTipText("Open selection in new tab");
....@@ -1121,7 +1165,7 @@
11211165
11221166 // INSERT
11231167 row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1124
- gridButton.setToolTipText("Create grid");
1168
+ gridButton.setToolTipText("Create ground");
11251169 gridButton.addActionListener(this);
11261170
11271171 row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1413,6 +1457,14 @@
14131457
14141458 void EditObject(Object3D obj)
14151459 {
1460
+ assert(obj instanceof Composite);
1461
+
1462
+ if (obj.versionlist == null)
1463
+ {
1464
+ obj.versionlist = new Object3D[100];
1465
+ obj.versionindex = -1;
1466
+ }
1467
+
14161468 cRadio radioButton = new cRadio(obj.name);
14171469
14181470 // June 2019. Patch to avoid bug with transparency.
....@@ -1803,7 +1855,12 @@
18031855 TreePath path;
18041856
18051857 public TransferableTreePath(TreePath tp) {
1806
- 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);
18071864 }
18081865
18091866 public synchronized DataFlavor[] getTransferDataFlavors() {
....@@ -2696,6 +2753,18 @@
26962753 if (source == fullButton)
26972754 {
26982755 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();
26992768 } else
27002769 if (source == previousVersionButton)
27012770 {
....@@ -3648,38 +3717,7 @@
36483717 if (CameraPane.FULLSCREEN)
36493718 fullscreenLayout = radio.layout;
36503719
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();
3720
+ Show3DView();
36833721
36843722 cameraView.requestFocusInWindow();
36853723
....@@ -3865,6 +3903,7 @@
38653903 } else
38663904 if (source == rootButton)
38673905 {
3906
+ Replace();
38683907 Object3D obj;
38693908 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
38703909 {
....@@ -4001,8 +4040,6 @@
40014040
40024041 copy = group;
40034042
4004
- SetUndoStates();
4005
-
40064043 //Globals.theRenderer.object = group;
40074044 if(!useclient)
40084045 {
....@@ -4030,6 +4067,8 @@
40304067 */
40314068 radio.layout.doClick();
40324069
4070
+ SetUndoStates();
4071
+
40334072 ClearUnpinned();
40344073
40354074 //Grafreed.Assert(group != null);
....@@ -5264,6 +5303,19 @@
52645303 flashSelectionButton.setEnabled(enabled);
52655304
52665305 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);
52675319 }
52685320
52695321 void refreshContents(boolean cp)
....@@ -5278,7 +5330,7 @@
52785330 Object3D child = (Object3D) group.selection.get(i);
52795331
52805332 objEditor.AddInfo(child, this, true);
5281
- System.err.println("info : " + child.GetPath());
5333
+// System.err.println("info : " + child.GetPath());
52825334 }
52835335
52845336 objEditor.SetText(); // jan 2014