Normand Briere
2019-08-15 33504fc9a180903aace77613264550754fba5706
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,12 @@
356415 this.copy = this.group = group;
357416 //selectees = this.group.selectees;
358417
359
- if (copy.versions == null)
418
+ if (copy.versionlist == null)
360419 {
361
- copy.versions = new byte[100][];
420
+ copy.versionlist = new Object3D[100];
362421 copy.versionindex = -1;
422
+
423
+ Save(true);
363424 }
364425
365426 if(ui)
....@@ -383,9 +444,9 @@
383444
384445 ((cRadio)radioPanel.getComponent(0)).SetCamera(cameraView.renderCamera, true);
385446
386
- if (copy.versions == null)
447
+ if (copy.versionlist == null)
387448 {
388
- copy.versions = new byte[100][];
449
+ copy.versionlist = new Object3D[100];
389450 copy.versionindex = -1;
390451
391452 Save(true);
....@@ -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,74 @@
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 && !path[0].equals("") && !path[0].equals(".DS_Store"))
949
+ {
950
+ currenttab = new cGridBag();
951
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
952
+ currenttab.setName(tabname);
953
+ //added = false;
954
+ resourcecontainer.add(currenttab);
955
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
956
+ rowcount = 1;
957
+ colcount = 0;
958
+ texturecount = 0;
959
+ }
960
+
961
+ if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
962
+ {
963
+ //if (!added)
964
+ {
965
+ //added = true;
966
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
967
+ currenttab = (cGridBag)resourcecontainer.getComponentAt(resourcecontainer.indexOfTab(tabname));
968
+ }
969
+
970
+ AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
971
+
972
+ if (++colcount >= columns)
973
+ {
974
+ colcount = 0;
975
+ currenttab.Return();
976
+
977
+ if (rowcount++ >= rows)
978
+ {
979
+ rowcount = 0;
980
+ }
981
+ }
982
+ }
983
+ else
984
+ {
985
+// if (!path[path.length-1].equals("icons"))
986
+// resourcecontainer.Return();
987
+ }
988
+ }
989
+
990
+ void CreateTexturePanel(cGridBag container)
991
+ {
992
+ resourcecontainer = new JTabbedPane(JTabbedPane.LEFT);
993
+ container.add(resourcecontainer);
994
+
995
+ Grafreed.ParseResources("textures", this);
996
+ }
862997
863998 void SetupUI2(ObjEditor oe)
864999 {
....@@ -877,11 +1012,6 @@
8771012 //new Exception().printStackTrace();
8781013
8791014 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;
8851015 // oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
8861016
8871017 oe.buttonGroup = new ButtonGroup();
....@@ -914,10 +1044,49 @@
9141044
9151045 if (Globals.ADVANCED)
9161046 {
917
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
918
- maxButton.setToolTipText("Maximize window");
919
- maxButton.addActionListener(this);
1047
+// oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1048
+// maxButton.setToolTipText("Maximize window");
1049
+// maxButton.addActionListener(this);
9201050 }
1051
+
1052
+ cButton gcButton;
1053
+
1054
+// oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1055
+// gcButton.setToolTipText("Garbage collect");
1056
+// gcButton.addActionListener(new ActionListener()
1057
+// {
1058
+// public void actionPerformed(ActionEvent e)
1059
+// {
1060
+// System.gc();
1061
+// }
1062
+// });
1063
+
1064
+ oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1065
+ collapseButton.setToolTipText("Collapse toolbar");
1066
+ collapseButton.addActionListener(this);
1067
+
1068
+ oe.toolbarPanel.add(maximize3DButton = GetButton("", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1069
+ maximize3DButton.setToolTipText("Maximize 3D view");
1070
+ maximize3DButton.addActionListener(this);
1071
+
1072
+ oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1073
+ twoButton.setToolTipText("Show 3D view only");
1074
+ twoButton.addActionListener(this);
1075
+ this.fullscreenLayout = twoButton;
1076
+
1077
+ oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1078
+ threeButton.setToolTipText("Show controls and 3D view");
1079
+ threeButton.addActionListener(this);
1080
+ if (Globals.ADVANCED)
1081
+ {
1082
+ oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1083
+ sixButton.setToolTipText("Show 3D view and controls");
1084
+ sixButton.addActionListener(this);
1085
+ }
1086
+// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1087
+// sevenButton.setToolTipText("3-column layout");
1088
+// sevenButton.addActionListener(this);
1089
+ //
9211090
9221091 oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9231092 fullButton.setToolTipText("Full-screen window");
....@@ -931,41 +1100,45 @@
9311100 restoreCameraButton.setToolTipText("Restore viewpoint");
9321101 restoreCameraButton.addActionListener(this);
9331102
934
- copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
935
- saveButton.setToolTipText("New version");
936
- saveButton.addActionListener(this);
1103
+ copyOptionsPanel.add(saveVersionButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1104
+ saveVersionButton.setToolTipText("Duplicate current version");
1105
+ saveVersionButton.addActionListener(this);
9371106
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);
1107
+ copyOptionsPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1108
+ deleteVersionButton.setToolTipText("Delete current version");
1109
+ deleteVersionButton.addActionListener(this);
1110
+
1111
+ copyOptionsPanel.add(previousVersionButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1112
+ previousVersionButton.setToolTipText("Previous version");
1113
+ previousVersionButton.addActionListener(this);
1114
+ previousVersionButton.setEnabled(false);
9421115
9431116 cGridBag updown = new cGridBag().setVertical(true);
9441117 updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
945
- restoreButton.setToolTipText("Restore current");
1118
+ restoreButton.setToolTipText("Undo (restore current version)");
9461119 restoreButton.addActionListener(this);
947
- restoreButton.setEnabled(false);
1120
+ //restoreButton.setEnabled(false);
9481121
9491122 updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
950
- replaceButton.setToolTipText("Replace current");
1123
+ replaceButton.setToolTipText("Save (replace current version)");
9511124 replaceButton.addActionListener(this);
952
- replaceButton.setEnabled(false);
1125
+ //replaceButton.setEnabled(false);
9531126
9541127 copyOptionsPanel.add(updown);
9551128
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);
1129
+ copyOptionsPanel.add(nextVersionButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1130
+ nextVersionButton.setToolTipText("Next version");
1131
+ nextVersionButton.addActionListener(this);
1132
+ nextVersionButton.setEnabled(false);
1133
+
1134
+ oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1135
+ oneStepButton.setToolTipText("Animate one step forward");
1136
+ oneStepButton.addActionListener(this);
9601137
9611138 oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
9621139 liveCB.setToolTipText("Enable animation");
9631140 liveCB.addItemListener(this);
9641141
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
-
9691142 oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
9701143 fastCB.setToolTipText("Fast mode");
9711144 fastCB.addItemListener(this);
....@@ -992,21 +1165,6 @@
9921165
9931166 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
9941167
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
- //
10101168
10111169 oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10121170 rootButton.setToolTipText("Open selection in new tab");
....@@ -1022,12 +1180,16 @@
10221180
10231181 // INSERT
10241182 row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1025
- gridButton.setToolTipText("Create grid");
1183
+ gridButton.setToolTipText("Create ground");
10261184 gridButton.addActionListener(this);
10271185
10281186 row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10291187 boxButton.setToolTipText("Create box");
10301188 boxButton.addActionListener(this);
1189
+
1190
+ row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1191
+ superButton.setToolTipText("Create superellipsoid");
1192
+ superButton.addActionListener(this);
10311193
10321194 row1.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10331195 sphereButton.setToolTipText("Create sphere");
....@@ -1040,10 +1202,6 @@
10401202 row1.add(torusButton = GetButton("icons/torus.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10411203 torusButton.setToolTipText("Create torus");
10421204 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);
10471205
10481206 if (Globals.ADVANCED)
10491207 {
....@@ -1090,19 +1248,15 @@
10901248
10911249 oe.toolboxPanel.add(row2);
10921250
1093
- // ENVYMAPS
1094
- cGridBag skyboxpane = new cGridBag();
1095
- skyboxpane.preferredHeight = 100;
1251
+ cGridBag textures = new cGridBag();
10961252
1097
- oe.toolboxPanel.add(skyboxpane);
1253
+ CreateTexturePanel(textures);
10981254
1099
- JTabbedPane skyboxpanel = new JTabbedPane();
1100
- skyboxpane.add(skyboxpanel);
1255
+ oe.toolboxPanel.add(textures);
11011256
1102
- AddSkyboxTab0(skyboxpanel);
1103
- AddSkyboxTab1(skyboxpanel);
1104
- AddSkyboxTab2(skyboxpanel);
1105
- AddSkyboxTab3(skyboxpanel);
1257
+ textures.preferredHeight = 100;
1258
+
1259
+ CreateSkyboxPanel(oe.skyboxPanel);
11061260
11071261 // EDIT panel
11081262 editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1110,20 +1264,20 @@
11101264 editButton.addActionListener(this);
11111265
11121266 editCommandsPanel.add(uneditButton = GetButton("icons/remove.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1113
- uneditButton.setToolTipText("Remove selection controls");
1267
+ uneditButton.setToolTipText("Unpin and remove selection controls");
11141268 uneditButton.addActionListener(this);
11151269
11161270 editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
1117
- allParamsButton.setToolTipText("Show all controle");
1271
+ allParamsButton.setToolTipText("Show all controls");
11181272 allParamsButton.addActionListener(this);
11191273
1120
- editCommandsPanel.add(clearPanelButton = new cButton("C", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1121
- clearPanelButton.setToolTipText("Clear edit panel");
1274
+ editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1275
+ clearPanelButton.setToolTipText("Clear all controls");
11221276 clearPanelButton.addActionListener(this);
11231277
1124
- editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1125
- unselectButton.setToolTipText("Unselect");
1126
- unselectButton.addActionListener(this);
1278
+ //editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1279
+ //unselectButton.setToolTipText("Unselect");
1280
+ //unselectButton.addActionListener(this);
11271281
11281282 editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11291283 flashSelectionButton.setToolTipText("Highlight selection");
....@@ -1183,7 +1337,7 @@
11831337 dgr.addDragGestureListener(this);
11841338 }catch(Exception e) {}
11851339 */
1186
- radio.layout = sixButton; // sevenButton;
1340
+ radio.layout = threeButton; // sixButton;
11871341 oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
11881342 }
11891343
....@@ -1234,9 +1388,12 @@
12341388 smoothCB.setToolTipText("Snapping delay");
12351389 smoothCB.addItemListener(this);
12361390
1237
- panel.add(slowCB = new cCheckBox("Slow", CameraPane.SLOWPOSE)); //, constraints);
1238
- slowCB.setToolTipText("Smooth interpolation");
1239
- slowCB.addItemListener(this);
1391
+// panel.add(slowCB = new cCheckBox("Slow", CameraPane.SLOWPOSE)); //, constraints);
1392
+// slowCB.setToolTipText("Smooth interpolation");
1393
+// slowCB.addItemListener(this);
1394
+ panel.add(minshaderCB = new cCheckBox("Min shader", Globals.MINSHADER)); //, constraints);
1395
+ minshaderCB.setToolTipText("Minimal fast shader");
1396
+ minshaderCB.addItemListener(this);
12401397
12411398 // constraints.gridy += 1;
12421399 // panel.add(speakerMocapCB = new cCheckBox("Mocap", CameraPane.SPEAKERMOCAP), constraints);
....@@ -1315,6 +1472,14 @@
13151472
13161473 void EditObject(Object3D obj)
13171474 {
1475
+ assert(obj instanceof Composite);
1476
+
1477
+// if (obj.versionlist == null)
1478
+// {
1479
+// obj.versionlist = new Object3D[100];
1480
+// obj.versionindex = -1;
1481
+// }
1482
+
13181483 cRadio radioButton = new cRadio(obj.name);
13191484
13201485 // June 2019. Patch to avoid bug with transparency.
....@@ -1325,7 +1490,7 @@
13251490 }
13261491
13271492 radioButton.SetObject(obj);
1328
- radioButton.layout = sixButton; // sevenButton;
1493
+ radioButton.layout = threeButton; // sixButton;
13291494 radioButton.SetCamera(cameraView.renderCamera, false);
13301495 radioButton.addActionListener(this);
13311496 radioPanel.add(radioButton);
....@@ -1350,6 +1515,8 @@
13501515 cCheckBox localCB;
13511516 cCheckBox crowdCB;
13521517 cCheckBox smoothCB;
1518
+ cCheckBox minshaderCB;
1519
+
13531520 cToggleButton fastCB;
13541521 cCheckBox slowCB;
13551522 cCheckBox boxCB;
....@@ -1420,6 +1587,12 @@
14201587 {
14211588 cameraView.ToggleInertia();
14221589 cameraView.repaint();
1590
+ }
1591
+ else if(e.getSource() == minshaderCB)
1592
+ {
1593
+ Globals.MINSHADER ^= true;
1594
+ cameraView.programInitialized = false;
1595
+ cameraView.repaint();
14231596 }
14241597 else if(e.getSource() == localCB)
14251598 {
....@@ -1697,7 +1870,12 @@
16971870 TreePath path;
16981871
16991872 public TransferableTreePath(TreePath tp) {
1700
- path = tp;
1873
+ Object[] objs = new Object[tp.getPathCount()];
1874
+ for (int i=0; i<objs.length; i++)
1875
+ {
1876
+ objs[i] = ((Object3D)tp.getPathComponent(i)).GetUUID();
1877
+ }
1878
+ path = new TreePath(objs);
17011879 }
17021880
17031881 public synchronized DataFlavor[] getTransferDataFlavors() {
....@@ -1987,7 +2165,11 @@
19872165 shadow.material = new cMaterial(obj.material);
19882166 shadow.material.diffuse = 0.0001f;
19892167 shadow.material.specular = 0.0001f;
1990
- //shadow.projectedVertices[1].x = 300;
2168
+ shadow.material.opacity = 0.75f;
2169
+
2170
+ AllocProjectedVertices(shadow);
2171
+
2172
+ shadow.projectedVertices[1].x = 300;
19912173
19922174 makeSomething(shadow);
19932175 }
....@@ -2508,27 +2690,35 @@
25082690 } else
25092691 if (source == loopItem || source == loopButton)
25102692 {
2693
+ if (!group.selection.isEmpty())
2694
+ {
25112695 Composite csg = new GroupLeaf();
25122696 csg.count = 5;
2513
- group(csg);
25142697 Composite child = new cGroup("Branch");
25152698 csg.addChild(child);
25162699 child.addChild(csg);
2700
+ group(csg);
2701
+ }
25172702 } else
25182703 if (source == doubleItem)
25192704 {
2705
+ if (!group.selection.isEmpty())
2706
+ {
25202707 Composite csg = new GroupLeaf("Fork");
25212708 csg.count = 5;
2522
- group(csg);
25232709 Composite child = new cGroup("Branch A");
25242710 csg.addChild(child);
25252711 child.addChild(csg);
25262712 child = new cGroup("Branch B");
25272713 csg.addChild(child);
25282714 child.addChild(csg);
2715
+ group(csg);
2716
+ }
25292717 } else
25302718 if (source == tripleItem)
25312719 {
2720
+ if (!group.selection.isEmpty())
2721
+ {
25322722 Composite csg = new GroupLeaf("Trident");
25332723 csg.count = 4;
25342724 group(csg);
....@@ -2541,6 +2731,7 @@
25412731 child = new cGroup();
25422732 csg.addChild(child);
25432733 child.addChild(csg);
2734
+ }
25442735 } else
25452736 if (source == computeAOItem)
25462737 {
....@@ -2560,7 +2751,7 @@
25602751 if (source == invariantsItem)
25612752 {
25622753 System.out.println("Invariants:");
2563
- Grafreed.grafreeD.universe.invariants();
2754
+ Grafreed.grafreed.universe.invariants();
25642755 } else
25652756 if (source == memoryItem)
25662757 {
....@@ -2591,33 +2782,52 @@
25912782 {
25922783 ToggleFullScreen();
25932784 } else
2594
- if (source == undoButton)
2785
+ if (source == collapseButton)
2786
+ {
2787
+ this.expandedLayout = radio.layout;
2788
+ CollapseToolbar();
2789
+ } else
2790
+ if (source == maximize3DButton)
2791
+ {
2792
+ this.expandedLayout = radio.layout;
2793
+ radio.layout = twoButton;
2794
+ Show3DView();
2795
+ CollapseToolbar();
2796
+ } else
2797
+ if (source == previousVersionButton)
25952798 {
25962799 // Go to previous version
25972800 //if (!Undo())
25982801 //java.awt.Toolkit.getDefaultToolkit().beep();
2599
- Undo();
2802
+ PreviousVersion();
26002803 } else
26012804 if (source == restoreButton)
26022805 {
26032806 // Restore current version
26042807 Restore();
2808
+ //restoreButton.setEnabled(false);
26052809 } else
26062810 if (source == replaceButton)
26072811 {
26082812 // Overwrite current version
26092813 Replace();
2814
+ //replaceButton.setEnabled(false);
26102815 } else
2611
- if (source == redoButton)
2816
+ if (source == nextVersionButton)
26122817 {
26132818 // Go to next version
2614
- Redo();
2819
+ NextVersion();
26152820 } else
2616
- if (source == saveButton)
2821
+ if (source == saveVersionButton)
26172822 {
26182823 // Save a new version
26192824 if (!Save(true))
26202825 java.awt.Toolkit.getDefaultToolkit().beep();
2826
+ } else
2827
+ if (source == deleteVersionButton)
2828
+ {
2829
+ // Delete a new version
2830
+ DeleteVersion();
26212831 } else
26222832 if (source == oneStepButton)
26232833 {
....@@ -2672,11 +2882,11 @@
26722882 } else
26732883 if (source == undoItem)
26742884 {
2675
- Undo();
2885
+ PreviousVersion();
26762886 } else
26772887 if (source == redoItem)
26782888 {
2679
- Redo();
2889
+ NextVersion();
26802890 } else
26812891 if (source == duplicateItem)
26822892 {
....@@ -3157,22 +3367,34 @@
31573367 } else
31583368 if (source == ungroupItem || source == ungroupButton)
31593369 {
3160
- boolean hasRoot = false;
3370
+ boolean canUngroup = true;
31613371
31623372 for (int i=0; i<group.selection.size(); i++)
31633373 {
3164
- if (group.selection.get(i) == group)
3374
+ Object3D selectedItem = group.selection.get(i);
3375
+
3376
+ if (selectedItem.Size() == 0)
31653377 {
3166
- hasRoot = true;
3378
+ // Cannot ungroup leaves
3379
+ canUngroup = false;
3380
+ break;
3381
+ }
3382
+
3383
+ if (selectedItem == group)
3384
+ {
3385
+ // Cannot ungroup root
3386
+ canUngroup = false;
31673387 break;
31683388 }
31693389 }
31703390
3171
- if (!hasRoot)
3391
+ if (canUngroup)
31723392 {
31733393 for (int i=0; i<group.selection.size(); i++)
31743394 {
3175
- Ungroup(group.selection.get(i));
3395
+ Object3D selectedItem = group.selection.get(i);
3396
+
3397
+ Ungroup(selectedItem);
31763398 }
31773399
31783400 ClearSelection(false);
....@@ -3535,38 +3757,7 @@
35353757 if (CameraPane.FULLSCREEN)
35363758 fullscreenLayout = radio.layout;
35373759
3538
- // bug
3539
- //gridPanel.setDividerLocation(1.0);
3540
- //bigPanel.setDividerLocation(0.0);
3541
-// bigThree.remove(scenePanel);
3542
-// bigThree.remove(centralPanel);
3543
-// bigThree.remove(XYZPanel);
3544
-// aWindowConstraints.gridx = 0;
3545
-// aWindowConstraints.gridy = 0;
3546
-// aWindowConstraints.gridwidth = 1;
3547
-// // aConstraints.gridheight = 3;
3548
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3549
-// aWindowConstraints.weightx = 0;
3550
-// aWindowConstraints.weighty = 1;
3551
-// //bigThree.add(jtp, aWindowConstraints);
3552
-// aWindowConstraints.weightx = 1;
3553
-// aWindowConstraints.gridwidth = 3;
3554
-// // aConstraints.gridheight = 3;
3555
-// aWindowConstraints.gridx = 1;
3556
-// aWindowConstraints.fill = GridBagConstraints.BOTH;
3557
-// bigThree.add(centralPanel, aWindowConstraints);
3558
-// aWindowConstraints.weightx = 0;
3559
-// aWindowConstraints.gridx = 4;
3560
-// aWindowConstraints.gridwidth = 1;
3561
-// // aConstraints.gridheight = 3;
3562
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3563
-// //bigThree.add(XYZPanel, aWindowConstraints);
3564
-// scenePanel.setVisible(false);
3565
-// centralPanel.setVisible(true);
3566
-// XYZPanel.setVisible(false);
3567
- bigThree.ClearUI();
3568
- bigThree.add(centralPanel);
3569
- bigThree.FlushUI();
3760
+ Show3DView();
35703761
35713762 cameraView.requestFocusInWindow();
35723763
....@@ -3752,6 +3943,7 @@
37523943 } else
37533944 if (source == rootButton)
37543945 {
3946
+ Replace();
37553947 Object3D obj;
37563948 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
37573949 {
....@@ -3809,10 +4001,10 @@
38094001 {
38104002 Object3D child = (Object3D)e.nextElement();
38114003 if(child.editWindow != null)
3812
- objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
38134004 child.pinned = false;
38144005 child.CloseUI();
38154006 listUI.remove(child);
4007
+// objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
38164008
38174009 //child.editWindow = null; // ???????????
38184010 }
....@@ -3831,6 +4023,7 @@
38314023 obj.CloseUI();
38324024 }
38334025 listUI.clear();
4026
+ SetPinStates(group.selection.size() > 0);
38344027 refreshContents(true);
38354028 } else
38364029 if (source == allParamsButton)
....@@ -3887,8 +4080,6 @@
38874080
38884081 copy = group;
38894082
3890
- SetUndoStates();
3891
-
38924083 //Globals.theRenderer.object = group;
38934084 if(!useclient)
38944085 {
....@@ -3916,7 +4107,20 @@
39164107 */
39174108 radio.layout.doClick();
39184109
4110
+ assert(copy instanceof Composite);
4111
+
4112
+ if (copy.versionlist == null)
4113
+ {
4114
+ copy.versionlist = new Object3D[100];
4115
+ copy.versionindex = -1;
4116
+
4117
+ Save(true);
4118
+ }
4119
+
4120
+ SetVersionStates();
4121
+
39194122 ClearUnpinned();
4123
+
39204124 //Grafreed.Assert(group != null);
39214125 //Grafreed.Assert(group.selection != null);
39224126 SetPinStates(group.selection == null || group.selection.size() > 0);
....@@ -3933,11 +4137,13 @@
39334137 } else if (event.getSource() == editCameraItem)
39344138 {
39354139 cameraView.ProtectCamera();
4140
+ cameraView.requestFocusInWindow();
39364141 cameraView.repaint();
39374142 return;
39384143 } else if (event.getSource() == restoreCameraItem || event.getSource() == restoreCameraButton)
39394144 {
39404145 cameraView.RevertCamera();
4146
+ cameraView.requestFocusInWindow();
39414147 cameraView.repaint();
39424148 return;
39434149 // } else if (event.getSource() == textureButton)
....@@ -5070,9 +5276,7 @@
50705276
50715277 freezemodel = false;
50725278 }
5073
-
5074
- boolean flashIt = true;
5075
-
5279
+
50765280 public void valueChanged(TreeSelectionEvent e)
50775281 //public boolean handleEvent(Event event)
50785282 {
....@@ -5145,13 +5349,29 @@
51455349 {
51465350 editButton.setEnabled(enabled);
51475351 uneditButton.setEnabled(enabled);
5148
- unselectButton.setEnabled(enabled);
5352
+ //unselectButton.setEnabled(enabled);
51495353 flashSelectionButton.setEnabled(enabled);
5354
+
5355
+ clearPanelButton.setEnabled(!listUI.isEmpty());
5356
+
5357
+ boolean allComposites = true;
5358
+
5359
+ if (group.selection != null)
5360
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
5361
+ {
5362
+ if (!(e.nextElement() instanceof Composite))
5363
+ {
5364
+ allComposites = false;
5365
+ break;
5366
+ }
5367
+ }
5368
+
5369
+ rootButton.setEnabled(allComposites);
51505370 }
51515371
51525372 void refreshContents(boolean cp)
51535373 {
5154
- if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
5374
+ //if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
51555375 if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
51565376 {
51575377 objEditor.ClearInfo(); // .GetMaterial());
....@@ -5161,7 +5381,7 @@
51615381 Object3D child = (Object3D) group.selection.get(i);
51625382
51635383 objEditor.AddInfo(child, this, true);
5164
- System.err.println("info : " + child.GetPath());
5384
+// System.err.println("info : " + child.GetPath());
51655385 }
51665386
51675387 objEditor.SetText(); // jan 2014
....@@ -5987,7 +6207,6 @@
59876207
59886208 cButton restoreCameraButton;
59896209
5990
- cButton saveButton;
59916210 cButton oneStepButton;
59926211
59936212 cButton groupButton;
....@@ -6045,11 +6264,11 @@
60456264 private MenuItem lookAtItem;
60466265 private MenuItem lookFromItem;
60476266 private MenuItem switchViewItem;
6048
- private MenuItem cutItem;
6267
+ private JMenuItem cutItem;
60496268 private MenuItem undoItem;
60506269 private MenuItem redoItem;
60516270 private JMenuItem duplicateItem;
6052
- private MenuItem cloneItem;
6271
+ private JMenuItem cloneItem;
60536272 private MenuItem cloneSupportItem;
60546273 private MenuItem overwriteGeoItem;
60556274 private MenuItem overwriteMatItem;
....@@ -6070,13 +6289,13 @@
60706289 private MenuItem cloneGeometriesItem;
60716290 private MenuItem shareGeometriesItem;
60726291 private MenuItem mergeGeometriesItem;
6073
- private MenuItem copyItem;
6292
+ private JMenuItem copyItem;
60746293 private MenuItem pasteItem;
6075
- private MenuItem pasteIntoItem;
6076
- private MenuItem pasteLinkItem;
6077
- private MenuItem pasteCloneItem;
6078
- private MenuItem pasteExpandItem;
6079
- private MenuItem deleteItem;
6294
+ private JMenuItem pasteIntoItem;
6295
+ private JMenuItem pasteLinkItem;
6296
+ private JMenuItem pasteCloneItem;
6297
+ private JMenuItem pasteExpandItem;
6298
+ private JMenuItem deleteItem;
60806299 private MenuItem clearAllItem;
60816300 private MenuItem genUVItem;
60826301 private MenuItem genNormalsMESHItem;
....@@ -6144,7 +6363,7 @@
61446363 private MenuItem switchTransfoItem;
61456364 private MenuItem morphItem;
61466365 private MenuItem linkerItem;
6147
- private MenuItem ungroupItem;
6366
+ private JMenuItem ungroupItem;
61486367 private MenuItem editItem;
61496368 private MenuItem openWindowItem;
61506369 private MenuItem editLeafItem;