Normand Briere
2019-08-15 7f97054d681518416a4ee1c1548ad42cfb489a8f
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)
....@@ -479,32 +540,37 @@
479540 // menu.add("-");
480541 duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate"));
481542 duplicateItem.addActionListener(this);
482
- cloneItem = menu.add(new MenuItem("Clone"));
543
+
544
+ cloneItem = oe.jTree.popup.add(new JMenuItem("Clone"));
483545 cloneItem.addActionListener(this);
484
- if (Globals.ADVANCED)
546
+ //if (Globals.ADVANCED)
485547 {
486548 cloneSupportItem = menu.add(new MenuItem("Clone (+supports)"));
487549 cloneSupportItem.addActionListener(this);
488550 }
551
+ oe.jTree.popup.addSeparator();
489552 menu.add("-");
490
- cutItem = menu.add(new MenuItem("Cut"));
553
+ cutItem = oe.jTree.popup.add(new JMenuItem("Cut"));
491554 cutItem.addActionListener(this);
492
- copyItem = menu.add(new MenuItem("Copy"));
555
+ copyItem = oe.jTree.popup.add(new JMenuItem("Copy"));
493556 copyItem.addActionListener(this);
494557 pasteItem = menu.add(new MenuItem("Paste"));
495558 pasteItem.addActionListener(this);
496559
497
- menu.add("-");
498
- pasteIntoItem = menu.add(new MenuItem("Paste into"));
560
+ oe.jTree.popup.addSeparator();
561
+ //menu.add("-");
562
+ pasteIntoItem = oe.jTree.popup.add(new JMenuItem("Paste into"));
499563 pasteIntoItem.addActionListener(this);
500
- pasteLinkItem = menu.add(new MenuItem("Paste link"));
564
+ pasteLinkItem = oe.jTree.popup.add(new JMenuItem("Paste link"));
501565 pasteLinkItem.addActionListener(this);
502
- pasteCloneItem = menu.add(new MenuItem("Paste clone"));
566
+ pasteCloneItem = oe.jTree.popup.add(new JMenuItem("Paste clone"));
503567 pasteCloneItem.addActionListener(this);
504
-// pasteExpandItem = menu.add(new MenuItem("Paste expand"));
568
+// CRASH pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand"));
505569 // pasteExpandItem.addActionListener(this);
506
- menu.add("-");
507
- deleteItem = menu.add(new MenuItem("Delete"));
570
+ //menu.add("-");
571
+ oe.jTree.popup.addSeparator();
572
+
573
+ deleteItem = oe.jTree.popup.add(new JMenuItem("Delete"));
508574 deleteItem.addActionListener(this);
509575
510576 if (Globals.ADVANCED)
....@@ -591,11 +657,9 @@
591657 oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest"));
592658 //cameraMenu.add(lookFromItem = new MenuItem("Look From Selection"));
593659 //cameraMenu.add(switchViewItem = new MenuItem("Reverse View"));
594
- editLeafItem = oe.cameraMenu.add(new MenuItem("Edit Leaf"));
595660 oe.cameraMenu.add("-");
596661 openWindowItem = oe.cameraMenu.add(new MenuItem("Edit copy..."));
597662 openWindowItem.addActionListener(this);
598
- editLeafItem.addActionListener(this);
599663 lookAtItem.addActionListener(this);
600664 //lookFromItem.addActinoListener(this);
601665 //switchViewItem.addActionListener(this);
....@@ -657,7 +721,7 @@
657721 hideItem = menu.add(new MenuItem("Hidden Group"));
658722 hideItem.addActionListener(this);
659723 }
660
- ungroupItem = menu.add(new MenuItem("Ungroup"));
724
+ ungroupItem = oe.jTree.popup.add(new JMenuItem("Ungroup"));
661725 ungroupItem.addActionListener(this);
662726
663727 // menu.add("-");
....@@ -843,6 +907,9 @@
843907 shareGeometriesItem.addActionListener(this);
844908 mergeGeometriesItem = menu.add(new MenuItem("Merge Geometries"));
845909 mergeGeometriesItem.addActionListener(this);
910
+ menu.add("-");
911
+ editLeafItem = menu.add(new MenuItem("Edit leaf..."));
912
+ editLeafItem.addActionListener(this);
846913 if (Globals.ADVANCED)
847914 {
848915 // Pretty much the same as duplicate and clone.
....@@ -859,6 +926,73 @@
859926 buildToolsMenu(menu);
860927 }
861928
929
+ JTabbedPane resourcecontainer;
930
+ cGridBag currenttab;
931
+ boolean added; // patch for jar
932
+
933
+ int tabcount = 0;
934
+ int colcount = 0;
935
+ int rowcount = 0;
936
+ int texturecount = 0;
937
+
938
+ int columns = 5;
939
+ int rows = 7;
940
+
941
+ public void ResourceCallBack(String[] path)
942
+ {
943
+ for (int i = 0; i < path.length; i++)
944
+ System.out.print(path[i] + "/");
945
+ System.out.println();
946
+
947
+ if (//rowcount == 0 ||
948
+ path.length == 1)
949
+ {
950
+ currenttab = new cGridBag();
951
+ added = false;
952
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
953
+ currenttab.setName(tabname);
954
+ rowcount = 1;
955
+ colcount = 0;
956
+ texturecount = 0;
957
+ }
958
+
959
+ if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
960
+ {
961
+ if (!added)
962
+ {
963
+ added = true;
964
+ resourcecontainer.add(currenttab);
965
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
966
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
967
+ }
968
+
969
+ AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
970
+
971
+ if (++colcount >= columns)
972
+ {
973
+ colcount = 0;
974
+ currenttab.Return();
975
+
976
+ if (rowcount++ >= rows)
977
+ {
978
+ rowcount = 0;
979
+ }
980
+ }
981
+ }
982
+ else
983
+ {
984
+// if (!path[path.length-1].equals("icons"))
985
+// resourcecontainer.Return();
986
+ }
987
+ }
988
+
989
+ void CreateTexturePanel(cGridBag container)
990
+ {
991
+ resourcecontainer = new JTabbedPane(JTabbedPane.LEFT);
992
+ container.add(resourcecontainer);
993
+
994
+ Grafreed.ParseResources("textures", this);
995
+ }
862996
863997 void SetupUI2(ObjEditor oe)
864998 {
....@@ -877,11 +1011,6 @@
8771011 //new Exception().printStackTrace();
8781012
8791013 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;
8851014 // oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
8861015
8871016 oe.buttonGroup = new ButtonGroup();
....@@ -914,10 +1043,49 @@
9141043
9151044 if (Globals.ADVANCED)
9161045 {
917
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
918
- maxButton.setToolTipText("Maximize window");
919
- maxButton.addActionListener(this);
1046
+// oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1047
+// maxButton.setToolTipText("Maximize window");
1048
+// maxButton.addActionListener(this);
9201049 }
1050
+
1051
+ cButton gcButton;
1052
+
1053
+// oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1054
+// gcButton.setToolTipText("Garbage collect");
1055
+// gcButton.addActionListener(new ActionListener()
1056
+// {
1057
+// public void actionPerformed(ActionEvent e)
1058
+// {
1059
+// System.gc();
1060
+// }
1061
+// });
1062
+
1063
+ oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1064
+ collapseButton.setToolTipText("Collapse toolbar");
1065
+ collapseButton.addActionListener(this);
1066
+
1067
+ oe.toolbarPanel.add(maximize3DButton = GetButton("", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1068
+ maximize3DButton.setToolTipText("Maximize 3D view");
1069
+ maximize3DButton.addActionListener(this);
1070
+
1071
+ oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1072
+ twoButton.setToolTipText("Show 3D view only");
1073
+ twoButton.addActionListener(this);
1074
+ this.fullscreenLayout = twoButton;
1075
+
1076
+ oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1077
+ threeButton.setToolTipText("Show controls and 3D view");
1078
+ threeButton.addActionListener(this);
1079
+ if (Globals.ADVANCED)
1080
+ {
1081
+ oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1082
+ sixButton.setToolTipText("Show 3D view and controls");
1083
+ sixButton.addActionListener(this);
1084
+ }
1085
+// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1086
+// sevenButton.setToolTipText("3-column layout");
1087
+// sevenButton.addActionListener(this);
1088
+ //
9211089
9221090 oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9231091 fullButton.setToolTipText("Full-screen window");
....@@ -948,12 +1116,12 @@
9481116 updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9491117 restoreButton.setToolTipText("Undo (restore current version)");
9501118 restoreButton.addActionListener(this);
951
- restoreButton.setEnabled(false);
1119
+ //restoreButton.setEnabled(false);
9521120
9531121 updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9541122 replaceButton.setToolTipText("Save (replace current version)");
9551123 replaceButton.addActionListener(this);
956
- replaceButton.setEnabled(false);
1124
+ //replaceButton.setEnabled(false);
9571125
9581126 copyOptionsPanel.add(updown);
9591127
....@@ -962,14 +1130,14 @@
9621130 nextVersionButton.addActionListener(this);
9631131 nextVersionButton.setEnabled(false);
9641132
965
- oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
966
- liveCB.setToolTipText("Enable animation");
967
- liveCB.addItemListener(this);
968
-
9691133 oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9701134 oneStepButton.setToolTipText("Animate one step forward");
9711135 oneStepButton.addActionListener(this);
9721136
1137
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
1138
+ liveCB.setToolTipText("Enable animation");
1139
+ liveCB.addItemListener(this);
1140
+
9731141 oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
9741142 fastCB.setToolTipText("Fast mode");
9751143 fastCB.addItemListener(this);
....@@ -996,21 +1164,6 @@
9961164
9971165 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
9981166
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
- //
10141167
10151168 oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10161169 rootButton.setToolTipText("Open selection in new tab");
....@@ -1026,7 +1179,7 @@
10261179
10271180 // INSERT
10281181 row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1029
- gridButton.setToolTipText("Create grid");
1182
+ gridButton.setToolTipText("Create ground");
10301183 gridButton.addActionListener(this);
10311184
10321185 row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1094,19 +1247,15 @@
10941247
10951248 oe.toolboxPanel.add(row2);
10961249
1097
- // ENVYMAPS
1098
- cGridBag skyboxpane = new cGridBag();
1099
- skyboxpane.preferredHeight = 100;
1250
+ cGridBag textures = new cGridBag();
11001251
1101
- oe.toolboxPanel.add(skyboxpane);
1252
+ CreateTexturePanel(textures);
11021253
1103
- JTabbedPane skyboxpanel = new JTabbedPane();
1104
- skyboxpane.add(skyboxpanel);
1254
+ oe.toolboxPanel.add(textures);
11051255
1106
- AddSkyboxTab0(skyboxpanel);
1107
- AddSkyboxTab1(skyboxpanel);
1108
- AddSkyboxTab2(skyboxpanel);
1109
- AddSkyboxTab3(skyboxpanel);
1256
+ textures.preferredHeight = 100;
1257
+
1258
+ CreateSkyboxPanel(oe.skyboxPanel);
11101259
11111260 // EDIT panel
11121261 editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1118,16 +1267,16 @@
11181267 uneditButton.addActionListener(this);
11191268
11201269 editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
1121
- allParamsButton.setToolTipText("Show all controle");
1270
+ allParamsButton.setToolTipText("Show all controls");
11221271 allParamsButton.addActionListener(this);
11231272
11241273 editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1125
- clearPanelButton.setToolTipText("Clear edit panel");
1274
+ clearPanelButton.setToolTipText("Clear all controls");
11261275 clearPanelButton.addActionListener(this);
11271276
1128
- editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1129
- unselectButton.setToolTipText("Unselect");
1130
- unselectButton.addActionListener(this);
1277
+ //editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1278
+ //unselectButton.setToolTipText("Unselect");
1279
+ //unselectButton.addActionListener(this);
11311280
11321281 editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11331282 flashSelectionButton.setToolTipText("Highlight selection");
....@@ -1322,6 +1471,14 @@
13221471
13231472 void EditObject(Object3D obj)
13241473 {
1474
+ assert(obj instanceof Composite);
1475
+
1476
+// if (obj.versionlist == null)
1477
+// {
1478
+// obj.versionlist = new Object3D[100];
1479
+// obj.versionindex = -1;
1480
+// }
1481
+
13251482 cRadio radioButton = new cRadio(obj.name);
13261483
13271484 // June 2019. Patch to avoid bug with transparency.
....@@ -1712,7 +1869,12 @@
17121869 TreePath path;
17131870
17141871 public TransferableTreePath(TreePath tp) {
1715
- path = tp;
1872
+ Object[] objs = new Object[tp.getPathCount()];
1873
+ for (int i=0; i<objs.length; i++)
1874
+ {
1875
+ objs[i] = ((Object3D)tp.getPathComponent(i)).GetUUID();
1876
+ }
1877
+ path = new TreePath(objs);
17161878 }
17171879
17181880 public synchronized DataFlavor[] getTransferDataFlavors() {
....@@ -2523,27 +2685,35 @@
25232685 } else
25242686 if (source == loopItem || source == loopButton)
25252687 {
2688
+ if (!group.selection.isEmpty())
2689
+ {
25262690 Composite csg = new GroupLeaf();
25272691 csg.count = 5;
2528
- group(csg);
25292692 Composite child = new cGroup("Branch");
25302693 csg.addChild(child);
25312694 child.addChild(csg);
2695
+ group(csg);
2696
+ }
25322697 } else
25332698 if (source == doubleItem)
25342699 {
2700
+ if (!group.selection.isEmpty())
2701
+ {
25352702 Composite csg = new GroupLeaf("Fork");
25362703 csg.count = 5;
2537
- group(csg);
25382704 Composite child = new cGroup("Branch A");
25392705 csg.addChild(child);
25402706 child.addChild(csg);
25412707 child = new cGroup("Branch B");
25422708 csg.addChild(child);
25432709 child.addChild(csg);
2710
+ group(csg);
2711
+ }
25442712 } else
25452713 if (source == tripleItem)
25462714 {
2715
+ if (!group.selection.isEmpty())
2716
+ {
25472717 Composite csg = new GroupLeaf("Trident");
25482718 csg.count = 4;
25492719 group(csg);
....@@ -2556,6 +2726,7 @@
25562726 child = new cGroup();
25572727 csg.addChild(child);
25582728 child.addChild(csg);
2729
+ }
25592730 } else
25602731 if (source == computeAOItem)
25612732 {
....@@ -2606,6 +2777,18 @@
26062777 {
26072778 ToggleFullScreen();
26082779 } else
2780
+ if (source == collapseButton)
2781
+ {
2782
+ this.expandedLayout = radio.layout;
2783
+ CollapseToolbar();
2784
+ } else
2785
+ if (source == maximize3DButton)
2786
+ {
2787
+ this.expandedLayout = radio.layout;
2788
+ radio.layout = twoButton;
2789
+ Show3DView();
2790
+ CollapseToolbar();
2791
+ } else
26092792 if (source == previousVersionButton)
26102793 {
26112794 // Go to previous version
....@@ -2617,13 +2800,13 @@
26172800 {
26182801 // Restore current version
26192802 Restore();
2620
- restoreButton.setEnabled(false);
2803
+ //restoreButton.setEnabled(false);
26212804 } else
26222805 if (source == replaceButton)
26232806 {
26242807 // Overwrite current version
26252808 Replace();
2626
- replaceButton.setEnabled(false);
2809
+ //replaceButton.setEnabled(false);
26272810 } else
26282811 if (source == nextVersionButton)
26292812 {
....@@ -3179,22 +3362,34 @@
31793362 } else
31803363 if (source == ungroupItem || source == ungroupButton)
31813364 {
3182
- boolean hasRoot = false;
3365
+ boolean canUngroup = true;
31833366
31843367 for (int i=0; i<group.selection.size(); i++)
31853368 {
3186
- if (group.selection.get(i) == group)
3369
+ Object3D selectedItem = group.selection.get(i);
3370
+
3371
+ if (selectedItem.Size() == 0)
31873372 {
3188
- hasRoot = true;
3373
+ // Cannot ungroup leaves
3374
+ canUngroup = false;
3375
+ break;
3376
+ }
3377
+
3378
+ if (selectedItem == group)
3379
+ {
3380
+ // Cannot ungroup root
3381
+ canUngroup = false;
31893382 break;
31903383 }
31913384 }
31923385
3193
- if (!hasRoot)
3386
+ if (canUngroup)
31943387 {
31953388 for (int i=0; i<group.selection.size(); i++)
31963389 {
3197
- Ungroup(group.selection.get(i));
3390
+ Object3D selectedItem = group.selection.get(i);
3391
+
3392
+ Ungroup(selectedItem);
31983393 }
31993394
32003395 ClearSelection(false);
....@@ -3557,38 +3752,7 @@
35573752 if (CameraPane.FULLSCREEN)
35583753 fullscreenLayout = radio.layout;
35593754
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();
3755
+ Show3DView();
35923756
35933757 cameraView.requestFocusInWindow();
35943758
....@@ -3774,6 +3938,7 @@
37743938 } else
37753939 if (source == rootButton)
37763940 {
3941
+ Replace();
37773942 Object3D obj;
37783943 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
37793944 {
....@@ -3910,8 +4075,6 @@
39104075
39114076 copy = group;
39124077
3913
- SetUndoStates();
3914
-
39154078 //Globals.theRenderer.object = group;
39164079 if(!useclient)
39174080 {
....@@ -3939,6 +4102,18 @@
39394102 */
39404103 radio.layout.doClick();
39414104
4105
+ assert(copy instanceof Composite);
4106
+
4107
+ if (copy.versionlist == null)
4108
+ {
4109
+ copy.versionlist = new Object3D[100];
4110
+ copy.versionindex = -1;
4111
+
4112
+ Save(true);
4113
+ }
4114
+
4115
+ SetVersionStates();
4116
+
39424117 ClearUnpinned();
39434118
39444119 //Grafreed.Assert(group != null);
....@@ -5169,15 +5344,29 @@
51695344 {
51705345 editButton.setEnabled(enabled);
51715346 uneditButton.setEnabled(enabled);
5172
- unselectButton.setEnabled(enabled);
5347
+ //unselectButton.setEnabled(enabled);
51735348 flashSelectionButton.setEnabled(enabled);
51745349
51755350 clearPanelButton.setEnabled(!listUI.isEmpty());
5351
+
5352
+ boolean allComposites = true;
5353
+
5354
+ if (group.selection != null)
5355
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
5356
+ {
5357
+ if (!(e.nextElement() instanceof Composite))
5358
+ {
5359
+ allComposites = false;
5360
+ break;
5361
+ }
5362
+ }
5363
+
5364
+ rootButton.setEnabled(allComposites);
51765365 }
51775366
51785367 void refreshContents(boolean cp)
51795368 {
5180
- if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
5369
+ //if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
51815370 if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
51825371 {
51835372 objEditor.ClearInfo(); // .GetMaterial());
....@@ -5187,7 +5376,7 @@
51875376 Object3D child = (Object3D) group.selection.get(i);
51885377
51895378 objEditor.AddInfo(child, this, true);
5190
- System.err.println("info : " + child.GetPath());
5379
+// System.err.println("info : " + child.GetPath());
51915380 }
51925381
51935382 objEditor.SetText(); // jan 2014
....@@ -6070,11 +6259,11 @@
60706259 private MenuItem lookAtItem;
60716260 private MenuItem lookFromItem;
60726261 private MenuItem switchViewItem;
6073
- private MenuItem cutItem;
6262
+ private JMenuItem cutItem;
60746263 private MenuItem undoItem;
60756264 private MenuItem redoItem;
60766265 private JMenuItem duplicateItem;
6077
- private MenuItem cloneItem;
6266
+ private JMenuItem cloneItem;
60786267 private MenuItem cloneSupportItem;
60796268 private MenuItem overwriteGeoItem;
60806269 private MenuItem overwriteMatItem;
....@@ -6095,13 +6284,13 @@
60956284 private MenuItem cloneGeometriesItem;
60966285 private MenuItem shareGeometriesItem;
60976286 private MenuItem mergeGeometriesItem;
6098
- private MenuItem copyItem;
6287
+ private JMenuItem copyItem;
60996288 private MenuItem pasteItem;
6100
- private MenuItem pasteIntoItem;
6101
- private MenuItem pasteLinkItem;
6102
- private MenuItem pasteCloneItem;
6103
- private MenuItem pasteExpandItem;
6104
- private MenuItem deleteItem;
6289
+ private JMenuItem pasteIntoItem;
6290
+ private JMenuItem pasteLinkItem;
6291
+ private JMenuItem pasteCloneItem;
6292
+ private JMenuItem pasteExpandItem;
6293
+ private JMenuItem deleteItem;
61056294 private MenuItem clearAllItem;
61066295 private MenuItem genUVItem;
61076296 private MenuItem genNormalsMESHItem;
....@@ -6169,7 +6358,7 @@
61696358 private MenuItem switchTransfoItem;
61706359 private MenuItem morphItem;
61716360 private MenuItem linkerItem;
6172
- private MenuItem ungroupItem;
6361
+ private JMenuItem ungroupItem;
61736362 private MenuItem editItem;
61746363 private MenuItem openWindowItem;
61756364 private MenuItem editLeafItem;