Normand Briere
2019-08-17 5892f05411c3d4dce2d8a59e0966dc2e1843a971
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 {
....@@ -356,10 +415,14 @@
356415 this.copy = this.group = group;
357416 //selectees = this.group.selectees;
358417
359
- if (copy.versions == null)
418
+ assert(false);
419
+
420
+ if (copy.versionlist == null)
360421 {
361
- copy.versions = new byte[100][];
422
+ copy.versionlist = new Object3D[100];
362423 copy.versionindex = -1;
424
+
425
+ //Save(true);
363426 }
364427
365428 if(ui)
....@@ -383,12 +446,12 @@
383446
384447 ((cRadio)radioPanel.getComponent(0)).SetCamera(cameraView.renderCamera, true);
385448
386
- if (copy.versions == null)
449
+ if (copy.versionlist == null)
387450 {
388
- copy.versions = new byte[100][];
451
+ copy.versionlist = new Object3D[100];
389452 copy.versionindex = -1;
390453
391
- Save(true);
454
+ //Save(true);
392455 }
393456 }
394457
....@@ -479,33 +542,35 @@
479542 // menu.add("-");
480543 duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate"));
481544 duplicateItem.addActionListener(this);
482
- cloneItem = menu.add(new MenuItem("Clone"));
545
+
546
+ cloneItem = oe.jTree.popup.add(new JMenuItem("Clone"));
483547 cloneItem.addActionListener(this);
484
- if (Globals.ADVANCED)
548
+ //if (Globals.ADVANCED)
485549 {
486550 cloneSupportItem = menu.add(new MenuItem("Clone (+supports)"));
487551 cloneSupportItem.addActionListener(this);
488552 }
553
+ oe.jTree.popup.addSeparator();
489554 menu.add("-");
490
- cutItem = menu.add(new MenuItem("Cut"));
555
+ cutItem = oe.jTree.popup.add(new JMenuItem("Cut"));
491556 cutItem.addActionListener(this);
492
- copyItem = menu.add(new MenuItem("Copy"));
557
+ copyItem = oe.jTree.popup.add(new JMenuItem("Copy"));
493558 copyItem.addActionListener(this);
494559 pasteItem = menu.add(new MenuItem("Paste"));
495560 pasteItem.addActionListener(this);
496561
497
- menu.add("-");
498
- pasteIntoItem = menu.add(new MenuItem("Paste into"));
562
+ oe.jTree.popup.addSeparator();
563
+ //menu.add("-");
564
+ pasteIntoItem = oe.jTree.popup.add(new JMenuItem("Paste into"));
499565 pasteIntoItem.addActionListener(this);
500
- pasteLinkItem = menu.add(new MenuItem("Paste link"));
566
+ pasteLinkItem = oe.jTree.popup.add(new JMenuItem("Paste link"));
501567 pasteLinkItem.addActionListener(this);
502
- pasteCloneItem = menu.add(new MenuItem("Paste clone"));
568
+ pasteCloneItem = oe.jTree.popup.add(new JMenuItem("Paste clone"));
503569 pasteCloneItem.addActionListener(this);
504
-// pasteExpandItem = menu.add(new MenuItem("Paste expand"));
570
+// CRASH pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand"));
505571 // pasteExpandItem.addActionListener(this);
506
- menu.add("-");
507
- deleteItem = menu.add(new MenuItem("Delete"));
508
- deleteItem.addActionListener(this);
572
+ //menu.add("-");
573
+ oe.jTree.popup.addSeparator();
509574
510575 if (Globals.ADVANCED)
511576 {
....@@ -591,11 +656,9 @@
591656 oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest"));
592657 //cameraMenu.add(lookFromItem = new MenuItem("Look From Selection"));
593658 //cameraMenu.add(switchViewItem = new MenuItem("Reverse View"));
594
- editLeafItem = oe.cameraMenu.add(new MenuItem("Edit Leaf"));
595659 oe.cameraMenu.add("-");
596660 openWindowItem = oe.cameraMenu.add(new MenuItem("Edit copy..."));
597661 openWindowItem.addActionListener(this);
598
- editLeafItem.addActionListener(this);
599662 lookAtItem.addActionListener(this);
600663 //lookFromItem.addActinoListener(this);
601664 //switchViewItem.addActionListener(this);
....@@ -642,9 +705,8 @@
642705 setMasterItem.addActionListener(this);
643706 }
644707
645
- oe.menuBar.add(menu = new Menu("Group"));
646
-// grabItem = menu.add(new MenuItem("Grab"));
647
-// grabItem.addActionListener(this);
708
+ oe.menuBar.add(menu = new Menu("Order"));
709
+
648710 backItem = menu.add(new MenuItem("Back"));
649711 backItem.addActionListener(this);
650712 frontItem = menu.add(new MenuItem("Front"));
....@@ -652,13 +714,21 @@
652714 // compositeItem = menu.add(new MenuItem("Composite"));
653715 // compositeItem.addActionListener(this);
654716
717
+ grabItem = oe.jTree.popup.add(new JMenuItem("Group"));
718
+ grabItem.addActionListener(this);
719
+
655720 if (Globals.ADVANCED)
656721 {
657722 hideItem = menu.add(new MenuItem("Hidden Group"));
658723 hideItem.addActionListener(this);
659724 }
660
- ungroupItem = menu.add(new MenuItem("Ungroup"));
725
+ ungroupItem = oe.jTree.popup.add(new JMenuItem("Ungroup"));
661726 ungroupItem.addActionListener(this);
727
+
728
+ oe.jTree.popup.addSeparator();
729
+
730
+ deleteItem = oe.jTree.popup.add(new JMenuItem("Delete"));
731
+ deleteItem.addActionListener(this);
662732
663733 // menu.add("-");
664734 //
....@@ -843,6 +913,9 @@
843913 shareGeometriesItem.addActionListener(this);
844914 mergeGeometriesItem = menu.add(new MenuItem("Merge Geometries"));
845915 mergeGeometriesItem.addActionListener(this);
916
+ menu.add("-");
917
+ editLeafItem = menu.add(new MenuItem("Edit leaf..."));
918
+ editLeafItem.addActionListener(this);
846919 if (Globals.ADVANCED)
847920 {
848921 // Pretty much the same as duplicate and clone.
....@@ -859,6 +932,74 @@
859932 buildToolsMenu(menu);
860933 }
861934
935
+ JTabbedPane resourcecontainer;
936
+ cGridBag currenttab;
937
+ //boolean added; // patch for jar
938
+
939
+ int tabcount = 0;
940
+ int colcount = 0;
941
+ int rowcount = 0;
942
+ int texturecount = 0;
943
+
944
+ int columns = 5;
945
+ int rows = 7;
946
+
947
+ public void ResourceCallBack(String[] path)
948
+ {
949
+// for (int i = 0; i < path.length; i++)
950
+// System.out.print(path[i] + "/");
951
+// System.out.println();
952
+
953
+ if (//rowcount == 0 ||
954
+ path.length == 1 && !path[0].equals("") && !path[0].equals(".DS_Store"))
955
+ {
956
+ currenttab = new cGridBag();
957
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
958
+ currenttab.setName(tabname);
959
+ //added = false;
960
+ resourcecontainer.add(currenttab);
961
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
962
+ rowcount = 1;
963
+ colcount = 0;
964
+ texturecount = 0;
965
+ }
966
+
967
+ if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
968
+ {
969
+ //if (!added)
970
+ {
971
+ //added = true;
972
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
973
+ currenttab = (cGridBag)resourcecontainer.getComponentAt(resourcecontainer.indexOfTab(tabname));
974
+ }
975
+
976
+ AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
977
+
978
+ if (++colcount >= columns)
979
+ {
980
+ colcount = 0;
981
+ currenttab.Return();
982
+
983
+ if (rowcount++ >= rows)
984
+ {
985
+ rowcount = 0;
986
+ }
987
+ }
988
+ }
989
+ else
990
+ {
991
+// if (!path[path.length-1].equals("icons"))
992
+// resourcecontainer.Return();
993
+ }
994
+ }
995
+
996
+ void CreateTexturePanel(cGridBag container)
997
+ {
998
+ resourcecontainer = new JTabbedPane(JTabbedPane.LEFT);
999
+ container.add(resourcecontainer);
1000
+
1001
+ Grafreed.ParseResources("textures", this);
1002
+ }
8621003
8631004 void SetupUI2(ObjEditor oe)
8641005 {
....@@ -877,11 +1018,6 @@
8771018 //new Exception().printStackTrace();
8781019
8791020 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;
8851021 // oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
8861022
8871023 oe.buttonGroup = new ButtonGroup();
....@@ -904,7 +1040,7 @@
9041040 */
9051041 cGridBag copyOptionsPanel = new cGridBag();
9061042
907
- copyOptionsPanel.preferredHeight = 2;
1043
+ copyOptionsPanel.preferredHeight = 3;
9081044
9091045 //this.AddOptions(oe.toolbarPanel, oe.aConstraints);
9101046
....@@ -914,10 +1050,49 @@
9141050
9151051 if (Globals.ADVANCED)
9161052 {
917
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
918
- maxButton.setToolTipText("Maximize window");
919
- maxButton.addActionListener(this);
1053
+// oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1054
+// maxButton.setToolTipText("Maximize window");
1055
+// maxButton.addActionListener(this);
9201056 }
1057
+
1058
+ cButton gcButton;
1059
+
1060
+// oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1061
+// gcButton.setToolTipText("Garbage collect");
1062
+// gcButton.addActionListener(new ActionListener()
1063
+// {
1064
+// public void actionPerformed(ActionEvent e)
1065
+// {
1066
+// System.gc();
1067
+// }
1068
+// });
1069
+
1070
+ oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1071
+ collapseButton.setToolTipText("Collapse toolbar");
1072
+ collapseButton.addActionListener(this);
1073
+
1074
+ oe.toolbarPanel.add(maximize3DButton = GetButton("icons/empty.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1075
+ maximize3DButton.setToolTipText("Maximize 3D view");
1076
+ maximize3DButton.addActionListener(this);
1077
+
1078
+ oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1079
+ twoButton.setToolTipText("Show 3D view only");
1080
+ twoButton.addActionListener(this);
1081
+ this.fullscreenLayout = twoButton;
1082
+
1083
+ oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1084
+ threeButton.setToolTipText("Show controls and 3D view");
1085
+ threeButton.addActionListener(this);
1086
+ if (Globals.ADVANCED)
1087
+ {
1088
+ oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1089
+ sixButton.setToolTipText("Show 3D view and controls");
1090
+ sixButton.addActionListener(this);
1091
+ }
1092
+// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1093
+// sevenButton.setToolTipText("3-column layout");
1094
+// sevenButton.addActionListener(this);
1095
+ //
9211096
9221097 oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9231098 fullButton.setToolTipText("Full-screen window");
....@@ -931,41 +1106,46 @@
9311106 restoreCameraButton.setToolTipText("Restore viewpoint");
9321107 restoreCameraButton.addActionListener(this);
9331108
934
- copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
935
- saveButton.setToolTipText("New version");
936
- saveButton.addActionListener(this);
1109
+ copyOptionsPanel.add(saveVersionButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1110
+ saveVersionButton.setToolTipText("Duplicate current version");
1111
+ saveVersionButton.addActionListener(this);
9371112
938
- copyOptionsPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
939
- undoButton.setToolTipText("Previous version");
940
- undoButton.addActionListener(this);
941
- undoButton.setEnabled(false);
1113
+ copyOptionsPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1114
+ deleteVersionButton.setToolTipText("Delete current version");
1115
+ deleteVersionButton.addActionListener(this);
1116
+ deleteVersionButton.setEnabled(false);
1117
+
1118
+ copyOptionsPanel.add(previousVersionButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1119
+ previousVersionButton.setToolTipText("Previous version");
1120
+ previousVersionButton.addActionListener(this);
1121
+ previousVersionButton.setEnabled(false);
9421122
9431123 cGridBag updown = new cGridBag().setVertical(true);
9441124 updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
945
- restoreButton.setToolTipText("Restore current");
1125
+ restoreButton.setToolTipText("Undo (restore current version)");
9461126 restoreButton.addActionListener(this);
9471127 restoreButton.setEnabled(false);
9481128
9491129 updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
950
- replaceButton.setToolTipText("Replace current");
1130
+ replaceButton.setToolTipText("Save (replace current version)");
9511131 replaceButton.addActionListener(this);
9521132 replaceButton.setEnabled(false);
9531133
9541134 copyOptionsPanel.add(updown);
9551135
956
- copyOptionsPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
957
- redoButton.setToolTipText("Next version");
958
- redoButton.addActionListener(this);
959
- redoButton.setEnabled(false);
1136
+ copyOptionsPanel.add(nextVersionButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1137
+ nextVersionButton.setToolTipText("Next version");
1138
+ nextVersionButton.addActionListener(this);
1139
+ nextVersionButton.setEnabled(false);
1140
+
1141
+ oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1142
+ oneStepButton.setToolTipText("Animate one step forward");
1143
+ oneStepButton.addActionListener(this);
9601144
9611145 oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
9621146 liveCB.setToolTipText("Enable animation");
9631147 liveCB.addItemListener(this);
9641148
965
- oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
966
- oneStepButton.setToolTipText("Animate one step forward");
967
- oneStepButton.addActionListener(this);
968
-
9691149 oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
9701150 fastCB.setToolTipText("Fast mode");
9711151 fastCB.addItemListener(this);
....@@ -992,21 +1172,6 @@
9921172
9931173 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
9941174
995
- oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
996
- twoButton.setToolTipText("Show 3D view only");
997
- twoButton.addActionListener(this);
998
- this.fullscreenLayout = twoButton;
999
-
1000
- oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1001
- threeButton.setToolTipText("Show controls and 3D view");
1002
- threeButton.addActionListener(this);
1003
- oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1004
- sixButton.setToolTipText("Show 3D view and controls");
1005
- sixButton.addActionListener(this);
1006
-// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1007
-// sevenButton.setToolTipText("3-column layout");
1008
-// sevenButton.addActionListener(this);
1009
- //
10101175
10111176 oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10121177 rootButton.setToolTipText("Open selection in new tab");
....@@ -1022,12 +1187,16 @@
10221187
10231188 // INSERT
10241189 row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1025
- gridButton.setToolTipText("Create grid");
1190
+ gridButton.setToolTipText("Create ground");
10261191 gridButton.addActionListener(this);
10271192
10281193 row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10291194 boxButton.setToolTipText("Create box");
10301195 boxButton.addActionListener(this);
1196
+
1197
+ row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1198
+ superButton.setToolTipText("Create superellipsoid");
1199
+ superButton.addActionListener(this);
10311200
10321201 row1.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10331202 sphereButton.setToolTipText("Create sphere");
....@@ -1040,10 +1209,6 @@
10401209 row1.add(torusButton = GetButton("icons/torus.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10411210 torusButton.setToolTipText("Create torus");
10421211 torusButton.addActionListener(this);
1043
-
1044
- row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1045
- superButton.setToolTipText("Create superellipsoid");
1046
- superButton.addActionListener(this);
10471212
10481213 if (Globals.ADVANCED)
10491214 {
....@@ -1090,19 +1255,17 @@
10901255
10911256 oe.toolboxPanel.add(row2);
10921257
1093
- // ENVYMAPS
1094
- cGridBag skyboxpane = new cGridBag();
1095
- skyboxpane.preferredHeight = 100;
1258
+ cGridBag textures = new cGridBag();
10961259
1097
- oe.toolboxPanel.add(skyboxpane);
1260
+ CreateTexturePanel(textures);
10981261
1099
- JTabbedPane skyboxpanel = new JTabbedPane();
1100
- skyboxpane.add(skyboxpanel);
1262
+ resourcecontainer.setSelectedIndex((int)(Math.random() * resourcecontainer.getTabCount()));
11011263
1102
- AddSkyboxTab0(skyboxpanel);
1103
- AddSkyboxTab1(skyboxpanel);
1104
- AddSkyboxTab2(skyboxpanel);
1105
- AddSkyboxTab3(skyboxpanel);
1264
+ oe.toolboxPanel.add(textures);
1265
+
1266
+ textures.preferredHeight = 100;
1267
+
1268
+ CreateSkyboxPanel(oe.skyboxPanel);
11061269
11071270 // EDIT panel
11081271 editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1110,20 +1273,20 @@
11101273 editButton.addActionListener(this);
11111274
11121275 editCommandsPanel.add(uneditButton = GetButton("icons/remove.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1113
- uneditButton.setToolTipText("Remove selection controls");
1276
+ uneditButton.setToolTipText("Unpin and remove selection controls");
11141277 uneditButton.addActionListener(this);
11151278
11161279 editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
1117
- allParamsButton.setToolTipText("Show all controle");
1280
+ allParamsButton.setToolTipText("Show all controls");
11181281 allParamsButton.addActionListener(this);
11191282
1120
- editCommandsPanel.add(clearPanelButton = new cButton("C", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1121
- clearPanelButton.setToolTipText("Clear edit panel");
1283
+ editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1284
+ clearPanelButton.setToolTipText("Clear all controls");
11221285 clearPanelButton.addActionListener(this);
11231286
1124
- editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1125
- unselectButton.setToolTipText("Unselect");
1126
- unselectButton.addActionListener(this);
1287
+ //editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1288
+ //unselectButton.setToolTipText("Unselect");
1289
+ //unselectButton.addActionListener(this);
11271290
11281291 editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11291292 flashSelectionButton.setToolTipText("Highlight selection");
....@@ -1160,7 +1323,7 @@
11601323 oe.treePanel.Return();
11611324 cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
11621325 versionSlider = (cNumberSlider)sliderPane.getComponent(1);
1163
- sliderPane.preferredHeight = 1;
1326
+ sliderPane.preferredHeight = 2;
11641327
11651328 // mainPanel.setDividerLocation(0.1); //1.0);
11661329 mainPanel.setResizeWeight(0.4);
....@@ -1183,7 +1346,7 @@
11831346 dgr.addDragGestureListener(this);
11841347 }catch(Exception e) {}
11851348 */
1186
- radio.layout = sixButton; // sevenButton;
1349
+ radio.layout = threeButton; // sixButton;
11871350 oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
11881351 }
11891352
....@@ -1318,6 +1481,14 @@
13181481
13191482 void EditObject(Object3D obj)
13201483 {
1484
+ assert(obj instanceof Composite);
1485
+
1486
+// if (obj.versionlist == null)
1487
+// {
1488
+// obj.versionlist = new Object3D[100];
1489
+// obj.versionindex = -1;
1490
+// }
1491
+
13211492 cRadio radioButton = new cRadio(obj.name);
13221493
13231494 // June 2019. Patch to avoid bug with transparency.
....@@ -1328,7 +1499,7 @@
13281499 }
13291500
13301501 radioButton.SetObject(obj);
1331
- radioButton.layout = sixButton; // sevenButton;
1502
+ radioButton.layout = threeButton; // sixButton;
13321503 radioButton.SetCamera(cameraView.renderCamera, false);
13331504 radioButton.addActionListener(this);
13341505 radioPanel.add(radioButton);
....@@ -1342,6 +1513,7 @@
13421513
13431514 oe.SetupViews();
13441515
1516
+ if (Globals.DEBUG)
13451517 System.out.println("SetupViews");
13461518 DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(
13471519 oe.cameraView, DnDConstants.ACTION_COPY_OR_MOVE, this); // ACTION_LINK ??
....@@ -1708,7 +1880,12 @@
17081880 TreePath path;
17091881
17101882 public TransferableTreePath(TreePath tp) {
1711
- path = tp;
1883
+ Object[] objs = new Object[tp.getPathCount()];
1884
+ for (int i=0; i<objs.length; i++)
1885
+ {
1886
+ objs[i] = ((Object3D)tp.getPathComponent(i)).GetUUID();
1887
+ }
1888
+ path = new TreePath(objs);
17121889 }
17131890
17141891 public synchronized DataFlavor[] getTransferDataFlavors() {
....@@ -1998,7 +2175,11 @@
19982175 shadow.material = new cMaterial(obj.material);
19992176 shadow.material.diffuse = 0.0001f;
20002177 shadow.material.specular = 0.0001f;
2001
- //shadow.projectedVertices[1].x = 300;
2178
+ shadow.material.opacity = 0.75f;
2179
+
2180
+ AllocProjectedVertices(shadow);
2181
+
2182
+ shadow.projectedVertices[1].x = 300;
20022183
20032184 makeSomething(shadow);
20042185 }
....@@ -2519,27 +2700,35 @@
25192700 } else
25202701 if (source == loopItem || source == loopButton)
25212702 {
2703
+ if (!group.selection.isEmpty())
2704
+ {
25222705 Composite csg = new GroupLeaf();
25232706 csg.count = 5;
2524
- group(csg);
25252707 Composite child = new cGroup("Branch");
25262708 csg.addChild(child);
25272709 child.addChild(csg);
2710
+ group(csg);
2711
+ }
25282712 } else
25292713 if (source == doubleItem)
25302714 {
2715
+ if (!group.selection.isEmpty())
2716
+ {
25312717 Composite csg = new GroupLeaf("Fork");
25322718 csg.count = 5;
2533
- group(csg);
25342719 Composite child = new cGroup("Branch A");
25352720 csg.addChild(child);
25362721 child.addChild(csg);
25372722 child = new cGroup("Branch B");
25382723 csg.addChild(child);
25392724 child.addChild(csg);
2725
+ group(csg);
2726
+ }
25402727 } else
25412728 if (source == tripleItem)
25422729 {
2730
+ if (!group.selection.isEmpty())
2731
+ {
25432732 Composite csg = new GroupLeaf("Trident");
25442733 csg.count = 4;
25452734 group(csg);
....@@ -2552,6 +2741,7 @@
25522741 child = new cGroup();
25532742 csg.addChild(child);
25542743 child.addChild(csg);
2744
+ }
25552745 } else
25562746 if (source == computeAOItem)
25572747 {
....@@ -2571,7 +2761,7 @@
25712761 if (source == invariantsItem)
25722762 {
25732763 System.out.println("Invariants:");
2574
- Grafreed.grafreeD.universe.invariants();
2764
+ Grafreed.grafreed.universe.invariants();
25752765 } else
25762766 if (source == memoryItem)
25772767 {
....@@ -2602,33 +2792,52 @@
26022792 {
26032793 ToggleFullScreen();
26042794 } else
2605
- if (source == undoButton)
2795
+ if (source == collapseButton)
2796
+ {
2797
+ this.expandedLayout = radio.layout;
2798
+ CollapseToolbar();
2799
+ } else
2800
+ if (source == maximize3DButton)
2801
+ {
2802
+ this.expandedLayout = radio.layout;
2803
+ radio.layout = twoButton;
2804
+ Show3DView();
2805
+ CollapseToolbar();
2806
+ } else
2807
+ if (source == previousVersionButton)
26062808 {
26072809 // Go to previous version
26082810 //if (!Undo())
26092811 //java.awt.Toolkit.getDefaultToolkit().beep();
2610
- Undo();
2812
+ PreviousVersion();
26112813 } else
26122814 if (source == restoreButton)
26132815 {
26142816 // Restore current version
26152817 Restore();
2818
+ //restoreButton.setEnabled(false);
26162819 } else
26172820 if (source == replaceButton)
26182821 {
26192822 // Overwrite current version
26202823 Replace();
2824
+ //replaceButton.setEnabled(false);
26212825 } else
2622
- if (source == redoButton)
2826
+ if (source == nextVersionButton)
26232827 {
26242828 // Go to next version
2625
- Redo();
2829
+ NextVersion();
26262830 } else
2627
- if (source == saveButton)
2831
+ if (source == saveVersionButton)
26282832 {
26292833 // Save a new version
26302834 if (!Save(true))
26312835 java.awt.Toolkit.getDefaultToolkit().beep();
2836
+ } else
2837
+ if (source == deleteVersionButton)
2838
+ {
2839
+ // Delete a new version
2840
+ DeleteVersion();
26322841 } else
26332842 if (source == oneStepButton)
26342843 {
....@@ -2683,11 +2892,11 @@
26832892 } else
26842893 if (source == undoItem)
26852894 {
2686
- Undo();
2895
+ PreviousVersion();
26872896 } else
26882897 if (source == redoItem)
26892898 {
2690
- Redo();
2899
+ NextVersion();
26912900 } else
26922901 if (source == duplicateItem)
26932902 {
....@@ -3168,22 +3377,34 @@
31683377 } else
31693378 if (source == ungroupItem || source == ungroupButton)
31703379 {
3171
- boolean hasRoot = false;
3380
+ boolean canUngroup = true;
31723381
31733382 for (int i=0; i<group.selection.size(); i++)
31743383 {
3175
- if (group.selection.get(i) == group)
3384
+ Object3D selectedItem = group.selection.get(i);
3385
+
3386
+ if (selectedItem.Size() == 0)
31763387 {
3177
- hasRoot = true;
3388
+ // Cannot ungroup leaves
3389
+ canUngroup = false;
3390
+ break;
3391
+ }
3392
+
3393
+ if (selectedItem == group)
3394
+ {
3395
+ // Cannot ungroup root
3396
+ canUngroup = false;
31783397 break;
31793398 }
31803399 }
31813400
3182
- if (!hasRoot)
3401
+ if (canUngroup)
31833402 {
31843403 for (int i=0; i<group.selection.size(); i++)
31853404 {
3186
- Ungroup(group.selection.get(i));
3405
+ Object3D selectedItem = group.selection.get(i);
3406
+
3407
+ Ungroup(selectedItem);
31873408 }
31883409
31893410 ClearSelection(false);
....@@ -3546,38 +3767,7 @@
35463767 if (CameraPane.FULLSCREEN)
35473768 fullscreenLayout = radio.layout;
35483769
3549
- // bug
3550
- //gridPanel.setDividerLocation(1.0);
3551
- //bigPanel.setDividerLocation(0.0);
3552
-// bigThree.remove(scenePanel);
3553
-// bigThree.remove(centralPanel);
3554
-// bigThree.remove(XYZPanel);
3555
-// aWindowConstraints.gridx = 0;
3556
-// aWindowConstraints.gridy = 0;
3557
-// aWindowConstraints.gridwidth = 1;
3558
-// // aConstraints.gridheight = 3;
3559
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3560
-// aWindowConstraints.weightx = 0;
3561
-// aWindowConstraints.weighty = 1;
3562
-// //bigThree.add(jtp, aWindowConstraints);
3563
-// aWindowConstraints.weightx = 1;
3564
-// aWindowConstraints.gridwidth = 3;
3565
-// // aConstraints.gridheight = 3;
3566
-// aWindowConstraints.gridx = 1;
3567
-// aWindowConstraints.fill = GridBagConstraints.BOTH;
3568
-// bigThree.add(centralPanel, aWindowConstraints);
3569
-// aWindowConstraints.weightx = 0;
3570
-// aWindowConstraints.gridx = 4;
3571
-// aWindowConstraints.gridwidth = 1;
3572
-// // aConstraints.gridheight = 3;
3573
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3574
-// //bigThree.add(XYZPanel, aWindowConstraints);
3575
-// scenePanel.setVisible(false);
3576
-// centralPanel.setVisible(true);
3577
-// XYZPanel.setVisible(false);
3578
- bigThree.ClearUI();
3579
- bigThree.add(centralPanel);
3580
- bigThree.FlushUI();
3770
+ Show3DView();
35813771
35823772 cameraView.requestFocusInWindow();
35833773
....@@ -3763,6 +3953,7 @@
37633953 } else
37643954 if (source == rootButton)
37653955 {
3956
+ Replace();
37663957 Object3D obj;
37673958 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
37683959 {
....@@ -3820,10 +4011,10 @@
38204011 {
38214012 Object3D child = (Object3D)e.nextElement();
38224013 if(child.editWindow != null)
3823
- objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
38244014 child.pinned = false;
38254015 child.CloseUI();
38264016 listUI.remove(child);
4017
+// objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
38274018
38284019 //child.editWindow = null; // ???????????
38294020 }
....@@ -3842,6 +4033,7 @@
38424033 obj.CloseUI();
38434034 }
38444035 listUI.clear();
4036
+ SetPinStates(group.selection.size() > 0);
38454037 refreshContents(true);
38464038 } else
38474039 if (source == allParamsButton)
....@@ -3898,8 +4090,6 @@
38984090
38994091 copy = group;
39004092
3901
- SetUndoStates();
3902
-
39034093 //Globals.theRenderer.object = group;
39044094 if(!useclient)
39054095 {
....@@ -3927,7 +4117,23 @@
39274117 */
39284118 radio.layout.doClick();
39294119
4120
+ assert(copy instanceof Composite);
4121
+
4122
+ if (copy.versionlist == null)
4123
+ {
4124
+ copy.versionlist = new Object3D[100];
4125
+ copy.versionindex = -1;
4126
+
4127
+ // Cannot work with loops
4128
+ // To fix this issue, first mark all nodes above the root,
4129
+ // and check if any of these nodes are reachable below the root.
4130
+ //Save(true);
4131
+ }
4132
+
4133
+ SetVersionStates();
4134
+
39304135 ClearUnpinned();
4136
+
39314137 //Grafreed.Assert(group != null);
39324138 //Grafreed.Assert(group.selection != null);
39334139 SetPinStates(group.selection == null || group.selection.size() > 0);
....@@ -3944,11 +4150,13 @@
39444150 } else if (event.getSource() == editCameraItem)
39454151 {
39464152 cameraView.ProtectCamera();
4153
+ cameraView.requestFocusInWindow();
39474154 cameraView.repaint();
39484155 return;
39494156 } else if (event.getSource() == restoreCameraItem || event.getSource() == restoreCameraButton)
39504157 {
39514158 cameraView.RevertCamera();
4159
+ cameraView.requestFocusInWindow();
39524160 cameraView.repaint();
39534161 return;
39544162 // } else if (event.getSource() == textureButton)
....@@ -5081,9 +5289,7 @@
50815289
50825290 freezemodel = false;
50835291 }
5084
-
5085
- boolean flashIt = true;
5086
-
5292
+
50875293 public void valueChanged(TreeSelectionEvent e)
50885294 //public boolean handleEvent(Event event)
50895295 {
....@@ -5156,13 +5362,30 @@
51565362 {
51575363 editButton.setEnabled(enabled);
51585364 uneditButton.setEnabled(enabled);
5159
- unselectButton.setEnabled(enabled);
5365
+ //unselectButton.setEnabled(enabled);
51605366 flashSelectionButton.setEnabled(enabled);
5367
+
5368
+ clearPanelButton.setEnabled(!listUI.isEmpty());
5369
+
5370
+ boolean allComposites = true;
5371
+
5372
+ if (group.selection != null)
5373
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
5374
+ {
5375
+ Object next = e.nextElement();
5376
+ if (!(next instanceof Composite)) // || (next instanceof GroupLeaf))
5377
+ {
5378
+ allComposites = false;
5379
+ break;
5380
+ }
5381
+ }
5382
+
5383
+ rootButton.setEnabled(allComposites);
51615384 }
51625385
51635386 void refreshContents(boolean cp)
51645387 {
5165
- if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
5388
+ //if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
51665389 if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
51675390 {
51685391 objEditor.ClearInfo(); // .GetMaterial());
....@@ -5172,7 +5395,7 @@
51725395 Object3D child = (Object3D) group.selection.get(i);
51735396
51745397 objEditor.AddInfo(child, this, true);
5175
- System.err.println("info : " + child.GetPath());
5398
+// System.err.println("info : " + child.GetPath());
51765399 }
51775400
51785401 objEditor.SetText(); // jan 2014
....@@ -5998,7 +6221,6 @@
59986221
59996222 cButton restoreCameraButton;
60006223
6001
- cButton saveButton;
60026224 cButton oneStepButton;
60036225
60046226 cButton groupButton;
....@@ -6056,11 +6278,11 @@
60566278 private MenuItem lookAtItem;
60576279 private MenuItem lookFromItem;
60586280 private MenuItem switchViewItem;
6059
- private MenuItem cutItem;
6281
+ private JMenuItem cutItem;
60606282 private MenuItem undoItem;
60616283 private MenuItem redoItem;
60626284 private JMenuItem duplicateItem;
6063
- private MenuItem cloneItem;
6285
+ private JMenuItem cloneItem;
60646286 private MenuItem cloneSupportItem;
60656287 private MenuItem overwriteGeoItem;
60666288 private MenuItem overwriteMatItem;
....@@ -6081,13 +6303,13 @@
60816303 private MenuItem cloneGeometriesItem;
60826304 private MenuItem shareGeometriesItem;
60836305 private MenuItem mergeGeometriesItem;
6084
- private MenuItem copyItem;
6306
+ private JMenuItem copyItem;
60856307 private MenuItem pasteItem;
6086
- private MenuItem pasteIntoItem;
6087
- private MenuItem pasteLinkItem;
6088
- private MenuItem pasteCloneItem;
6089
- private MenuItem pasteExpandItem;
6090
- private MenuItem deleteItem;
6308
+ private JMenuItem pasteIntoItem;
6309
+ private JMenuItem pasteLinkItem;
6310
+ private JMenuItem pasteCloneItem;
6311
+ private JMenuItem pasteExpandItem;
6312
+ private JMenuItem deleteItem;
60916313 private MenuItem clearAllItem;
60926314 private MenuItem genUVItem;
60936315 private MenuItem genNormalsMESHItem;
....@@ -6142,7 +6364,7 @@
61426364 private MenuItem transformGeometryItem;
61436365 private MenuItem transformChildrenItem;
61446366 private MenuItem hideItem;
6145
- private MenuItem grabItem;
6367
+ private JMenuItem grabItem;
61466368 private MenuItem backItem;
61476369 private MenuItem frontItem;
61486370 private MenuItem cameraItem;
....@@ -6155,7 +6377,7 @@
61556377 private MenuItem switchTransfoItem;
61566378 private MenuItem morphItem;
61576379 private MenuItem linkerItem;
6158
- private MenuItem ungroupItem;
6380
+ private JMenuItem ungroupItem;
61596381 private MenuItem editItem;
61606382 private MenuItem openWindowItem;
61616383 private MenuItem editLeafItem;