Normand Briere
2019-08-16 64e20f390e4b8e58bd0006dde8fa10fba1dac1d5
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 Object3D[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 Object3D[100];
449
+ copy.versionlist = new Object3D[100];
389450 copy.versionindex = -1;
390451
391452 Save(true);
....@@ -479,33 +540,35 @@
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"));
508
- deleteItem.addActionListener(this);
570
+ //menu.add("-");
571
+ oe.jTree.popup.addSeparator();
509572
510573 if (Globals.ADVANCED)
511574 {
....@@ -591,11 +654,9 @@
591654 oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest"));
592655 //cameraMenu.add(lookFromItem = new MenuItem("Look From Selection"));
593656 //cameraMenu.add(switchViewItem = new MenuItem("Reverse View"));
594
- editLeafItem = oe.cameraMenu.add(new MenuItem("Edit Leaf"));
595657 oe.cameraMenu.add("-");
596658 openWindowItem = oe.cameraMenu.add(new MenuItem("Edit copy..."));
597659 openWindowItem.addActionListener(this);
598
- editLeafItem.addActionListener(this);
599660 lookAtItem.addActionListener(this);
600661 //lookFromItem.addActinoListener(this);
601662 //switchViewItem.addActionListener(this);
....@@ -642,9 +703,8 @@
642703 setMasterItem.addActionListener(this);
643704 }
644705
645
- oe.menuBar.add(menu = new Menu("Group"));
646
-// grabItem = menu.add(new MenuItem("Grab"));
647
-// grabItem.addActionListener(this);
706
+ oe.menuBar.add(menu = new Menu("Order"));
707
+
648708 backItem = menu.add(new MenuItem("Back"));
649709 backItem.addActionListener(this);
650710 frontItem = menu.add(new MenuItem("Front"));
....@@ -652,13 +712,21 @@
652712 // compositeItem = menu.add(new MenuItem("Composite"));
653713 // compositeItem.addActionListener(this);
654714
715
+ grabItem = oe.jTree.popup.add(new JMenuItem("Group"));
716
+ grabItem.addActionListener(this);
717
+
655718 if (Globals.ADVANCED)
656719 {
657720 hideItem = menu.add(new MenuItem("Hidden Group"));
658721 hideItem.addActionListener(this);
659722 }
660
- ungroupItem = menu.add(new MenuItem("Ungroup"));
723
+ ungroupItem = oe.jTree.popup.add(new JMenuItem("Ungroup"));
661724 ungroupItem.addActionListener(this);
725
+
726
+ oe.jTree.popup.addSeparator();
727
+
728
+ deleteItem = oe.jTree.popup.add(new JMenuItem("Delete"));
729
+ deleteItem.addActionListener(this);
662730
663731 // menu.add("-");
664732 //
....@@ -843,6 +911,9 @@
843911 shareGeometriesItem.addActionListener(this);
844912 mergeGeometriesItem = menu.add(new MenuItem("Merge Geometries"));
845913 mergeGeometriesItem.addActionListener(this);
914
+ menu.add("-");
915
+ editLeafItem = menu.add(new MenuItem("Edit leaf..."));
916
+ editLeafItem.addActionListener(this);
846917 if (Globals.ADVANCED)
847918 {
848919 // Pretty much the same as duplicate and clone.
....@@ -859,6 +930,74 @@
859930 buildToolsMenu(menu);
860931 }
861932
933
+ JTabbedPane resourcecontainer;
934
+ cGridBag currenttab;
935
+ //boolean added; // patch for jar
936
+
937
+ int tabcount = 0;
938
+ int colcount = 0;
939
+ int rowcount = 0;
940
+ int texturecount = 0;
941
+
942
+ int columns = 5;
943
+ int rows = 7;
944
+
945
+ public void ResourceCallBack(String[] path)
946
+ {
947
+// for (int i = 0; i < path.length; i++)
948
+// System.out.print(path[i] + "/");
949
+// System.out.println();
950
+
951
+ if (//rowcount == 0 ||
952
+ path.length == 1 && !path[0].equals("") && !path[0].equals(".DS_Store"))
953
+ {
954
+ currenttab = new cGridBag();
955
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
956
+ currenttab.setName(tabname);
957
+ //added = false;
958
+ resourcecontainer.add(currenttab);
959
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
960
+ rowcount = 1;
961
+ colcount = 0;
962
+ texturecount = 0;
963
+ }
964
+
965
+ if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
966
+ {
967
+ //if (!added)
968
+ {
969
+ //added = true;
970
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
971
+ currenttab = (cGridBag)resourcecontainer.getComponentAt(resourcecontainer.indexOfTab(tabname));
972
+ }
973
+
974
+ AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
975
+
976
+ if (++colcount >= columns)
977
+ {
978
+ colcount = 0;
979
+ currenttab.Return();
980
+
981
+ if (rowcount++ >= rows)
982
+ {
983
+ rowcount = 0;
984
+ }
985
+ }
986
+ }
987
+ else
988
+ {
989
+// if (!path[path.length-1].equals("icons"))
990
+// resourcecontainer.Return();
991
+ }
992
+ }
993
+
994
+ void CreateTexturePanel(cGridBag container)
995
+ {
996
+ resourcecontainer = new JTabbedPane(JTabbedPane.LEFT);
997
+ container.add(resourcecontainer);
998
+
999
+ Grafreed.ParseResources("textures", this);
1000
+ }
8621001
8631002 void SetupUI2(ObjEditor oe)
8641003 {
....@@ -877,11 +1016,6 @@
8771016 //new Exception().printStackTrace();
8781017
8791018 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;
8851019 // oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
8861020
8871021 oe.buttonGroup = new ButtonGroup();
....@@ -914,10 +1048,49 @@
9141048
9151049 if (Globals.ADVANCED)
9161050 {
917
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
918
- maxButton.setToolTipText("Maximize window");
919
- maxButton.addActionListener(this);
1051
+// oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1052
+// maxButton.setToolTipText("Maximize window");
1053
+// maxButton.addActionListener(this);
9201054 }
1055
+
1056
+ cButton gcButton;
1057
+
1058
+// oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1059
+// gcButton.setToolTipText("Garbage collect");
1060
+// gcButton.addActionListener(new ActionListener()
1061
+// {
1062
+// public void actionPerformed(ActionEvent e)
1063
+// {
1064
+// System.gc();
1065
+// }
1066
+// });
1067
+
1068
+ oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1069
+ collapseButton.setToolTipText("Collapse toolbar");
1070
+ collapseButton.addActionListener(this);
1071
+
1072
+ oe.toolbarPanel.add(maximize3DButton = GetButton("icons/empty.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1073
+ maximize3DButton.setToolTipText("Maximize 3D view");
1074
+ maximize3DButton.addActionListener(this);
1075
+
1076
+ oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1077
+ twoButton.setToolTipText("Show 3D view only");
1078
+ twoButton.addActionListener(this);
1079
+ this.fullscreenLayout = twoButton;
1080
+
1081
+ oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1082
+ threeButton.setToolTipText("Show controls and 3D view");
1083
+ threeButton.addActionListener(this);
1084
+ if (Globals.ADVANCED)
1085
+ {
1086
+ oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1087
+ sixButton.setToolTipText("Show 3D view and controls");
1088
+ sixButton.addActionListener(this);
1089
+ }
1090
+// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1091
+// sevenButton.setToolTipText("3-column layout");
1092
+// sevenButton.addActionListener(this);
1093
+ //
9211094
9221095 oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9231096 fullButton.setToolTipText("Full-screen window");
....@@ -931,41 +1104,45 @@
9311104 restoreCameraButton.setToolTipText("Restore viewpoint");
9321105 restoreCameraButton.addActionListener(this);
9331106
934
- copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
935
- saveButton.setToolTipText("Duplicate current version");
936
- saveButton.addActionListener(this);
1107
+ copyOptionsPanel.add(saveVersionButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1108
+ saveVersionButton.setToolTipText("Duplicate current version");
1109
+ saveVersionButton.addActionListener(this);
9371110
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);
1111
+ copyOptionsPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1112
+ deleteVersionButton.setToolTipText("Delete current version");
1113
+ deleteVersionButton.addActionListener(this);
1114
+
1115
+ copyOptionsPanel.add(previousVersionButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1116
+ previousVersionButton.setToolTipText("Previous version");
1117
+ previousVersionButton.addActionListener(this);
1118
+ previousVersionButton.setEnabled(false);
9421119
9431120 cGridBag updown = new cGridBag().setVertical(true);
9441121 updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
945
- restoreButton.setToolTipText("Restore current version (undo latest change)");
1122
+ restoreButton.setToolTipText("Undo (restore current version)");
9461123 restoreButton.addActionListener(this);
947
- restoreButton.setEnabled(false);
1124
+ //restoreButton.setEnabled(false);
9481125
9491126 updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
950
- replaceButton.setToolTipText("Replace current version (save latest change)");
1127
+ replaceButton.setToolTipText("Save (replace current version)");
9511128 replaceButton.addActionListener(this);
952
- replaceButton.setEnabled(false);
1129
+ //replaceButton.setEnabled(false);
9531130
9541131 copyOptionsPanel.add(updown);
9551132
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);
1133
+ copyOptionsPanel.add(nextVersionButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1134
+ nextVersionButton.setToolTipText("Next version");
1135
+ nextVersionButton.addActionListener(this);
1136
+ nextVersionButton.setEnabled(false);
1137
+
1138
+ oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1139
+ oneStepButton.setToolTipText("Animate one step forward");
1140
+ oneStepButton.addActionListener(this);
9601141
9611142 oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
9621143 liveCB.setToolTipText("Enable animation");
9631144 liveCB.addItemListener(this);
9641145
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
-
9691146 oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
9701147 fastCB.setToolTipText("Fast mode");
9711148 fastCB.addItemListener(this);
....@@ -992,21 +1169,6 @@
9921169
9931170 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
9941171
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
- //
10101172
10111173 oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10121174 rootButton.setToolTipText("Open selection in new tab");
....@@ -1022,12 +1184,16 @@
10221184
10231185 // INSERT
10241186 row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1025
- gridButton.setToolTipText("Create grid");
1187
+ gridButton.setToolTipText("Create ground");
10261188 gridButton.addActionListener(this);
10271189
10281190 row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10291191 boxButton.setToolTipText("Create box");
10301192 boxButton.addActionListener(this);
1193
+
1194
+ row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1195
+ superButton.setToolTipText("Create superellipsoid");
1196
+ superButton.addActionListener(this);
10311197
10321198 row1.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10331199 sphereButton.setToolTipText("Create sphere");
....@@ -1040,10 +1206,6 @@
10401206 row1.add(torusButton = GetButton("icons/torus.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10411207 torusButton.setToolTipText("Create torus");
10421208 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);
10471209
10481210 if (Globals.ADVANCED)
10491211 {
....@@ -1090,19 +1252,15 @@
10901252
10911253 oe.toolboxPanel.add(row2);
10921254
1093
- // ENVYMAPS
1094
- cGridBag skyboxpane = new cGridBag();
1095
- skyboxpane.preferredHeight = 100;
1255
+ cGridBag textures = new cGridBag();
10961256
1097
- oe.toolboxPanel.add(skyboxpane);
1257
+ CreateTexturePanel(textures);
10981258
1099
- JTabbedPane skyboxpanel = new JTabbedPane();
1100
- skyboxpane.add(skyboxpanel);
1259
+ oe.toolboxPanel.add(textures);
11011260
1102
- AddSkyboxTab0(skyboxpanel);
1103
- AddSkyboxTab1(skyboxpanel);
1104
- AddSkyboxTab2(skyboxpanel);
1105
- AddSkyboxTab3(skyboxpanel);
1261
+ textures.preferredHeight = 100;
1262
+
1263
+ CreateSkyboxPanel(oe.skyboxPanel);
11061264
11071265 // EDIT panel
11081266 editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1110,20 +1268,20 @@
11101268 editButton.addActionListener(this);
11111269
11121270 editCommandsPanel.add(uneditButton = GetButton("icons/remove.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1113
- uneditButton.setToolTipText("Remove selection controls");
1271
+ uneditButton.setToolTipText("Unpin and remove selection controls");
11141272 uneditButton.addActionListener(this);
11151273
11161274 editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
1117
- allParamsButton.setToolTipText("Show all controle");
1275
+ allParamsButton.setToolTipText("Show all controls");
11181276 allParamsButton.addActionListener(this);
11191277
1120
- editCommandsPanel.add(clearPanelButton = new cButton("C", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1121
- clearPanelButton.setToolTipText("Clear edit panel");
1278
+ editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1279
+ clearPanelButton.setToolTipText("Clear all controls");
11221280 clearPanelButton.addActionListener(this);
11231281
1124
- editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1125
- unselectButton.setToolTipText("Unselect");
1126
- unselectButton.addActionListener(this);
1282
+ //editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1283
+ //unselectButton.setToolTipText("Unselect");
1284
+ //unselectButton.addActionListener(this);
11271285
11281286 editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11291287 flashSelectionButton.setToolTipText("Highlight selection");
....@@ -1318,6 +1476,14 @@
13181476
13191477 void EditObject(Object3D obj)
13201478 {
1479
+ assert(obj instanceof Composite);
1480
+
1481
+// if (obj.versionlist == null)
1482
+// {
1483
+// obj.versionlist = new Object3D[100];
1484
+// obj.versionindex = -1;
1485
+// }
1486
+
13211487 cRadio radioButton = new cRadio(obj.name);
13221488
13231489 // June 2019. Patch to avoid bug with transparency.
....@@ -1342,6 +1508,7 @@
13421508
13431509 oe.SetupViews();
13441510
1511
+ if (Globals.DEBUG)
13451512 System.out.println("SetupViews");
13461513 DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(
13471514 oe.cameraView, DnDConstants.ACTION_COPY_OR_MOVE, this); // ACTION_LINK ??
....@@ -1708,7 +1875,12 @@
17081875 TreePath path;
17091876
17101877 public TransferableTreePath(TreePath tp) {
1711
- path = tp;
1878
+ Object[] objs = new Object[tp.getPathCount()];
1879
+ for (int i=0; i<objs.length; i++)
1880
+ {
1881
+ objs[i] = ((Object3D)tp.getPathComponent(i)).GetUUID();
1882
+ }
1883
+ path = new TreePath(objs);
17121884 }
17131885
17141886 public synchronized DataFlavor[] getTransferDataFlavors() {
....@@ -1998,7 +2170,11 @@
19982170 shadow.material = new cMaterial(obj.material);
19992171 shadow.material.diffuse = 0.0001f;
20002172 shadow.material.specular = 0.0001f;
2001
- //shadow.projectedVertices[1].x = 300;
2173
+ shadow.material.opacity = 0.75f;
2174
+
2175
+ AllocProjectedVertices(shadow);
2176
+
2177
+ shadow.projectedVertices[1].x = 300;
20022178
20032179 makeSomething(shadow);
20042180 }
....@@ -2519,27 +2695,35 @@
25192695 } else
25202696 if (source == loopItem || source == loopButton)
25212697 {
2698
+ if (!group.selection.isEmpty())
2699
+ {
25222700 Composite csg = new GroupLeaf();
25232701 csg.count = 5;
2524
- group(csg);
25252702 Composite child = new cGroup("Branch");
25262703 csg.addChild(child);
25272704 child.addChild(csg);
2705
+ group(csg);
2706
+ }
25282707 } else
25292708 if (source == doubleItem)
25302709 {
2710
+ if (!group.selection.isEmpty())
2711
+ {
25312712 Composite csg = new GroupLeaf("Fork");
25322713 csg.count = 5;
2533
- group(csg);
25342714 Composite child = new cGroup("Branch A");
25352715 csg.addChild(child);
25362716 child.addChild(csg);
25372717 child = new cGroup("Branch B");
25382718 csg.addChild(child);
25392719 child.addChild(csg);
2720
+ group(csg);
2721
+ }
25402722 } else
25412723 if (source == tripleItem)
25422724 {
2725
+ if (!group.selection.isEmpty())
2726
+ {
25432727 Composite csg = new GroupLeaf("Trident");
25442728 csg.count = 4;
25452729 group(csg);
....@@ -2552,6 +2736,7 @@
25522736 child = new cGroup();
25532737 csg.addChild(child);
25542738 child.addChild(csg);
2739
+ }
25552740 } else
25562741 if (source == computeAOItem)
25572742 {
....@@ -2571,7 +2756,7 @@
25712756 if (source == invariantsItem)
25722757 {
25732758 System.out.println("Invariants:");
2574
- Grafreed.grafreeD.universe.invariants();
2759
+ Grafreed.grafreed.universe.invariants();
25752760 } else
25762761 if (source == memoryItem)
25772762 {
....@@ -2602,33 +2787,52 @@
26022787 {
26032788 ToggleFullScreen();
26042789 } else
2605
- if (source == undoButton)
2790
+ if (source == collapseButton)
2791
+ {
2792
+ this.expandedLayout = radio.layout;
2793
+ CollapseToolbar();
2794
+ } else
2795
+ if (source == maximize3DButton)
2796
+ {
2797
+ this.expandedLayout = radio.layout;
2798
+ radio.layout = twoButton;
2799
+ Show3DView();
2800
+ CollapseToolbar();
2801
+ } else
2802
+ if (source == previousVersionButton)
26062803 {
26072804 // Go to previous version
26082805 //if (!Undo())
26092806 //java.awt.Toolkit.getDefaultToolkit().beep();
2610
- Undo();
2807
+ PreviousVersion();
26112808 } else
26122809 if (source == restoreButton)
26132810 {
26142811 // Restore current version
26152812 Restore();
2813
+ //restoreButton.setEnabled(false);
26162814 } else
26172815 if (source == replaceButton)
26182816 {
26192817 // Overwrite current version
26202818 Replace();
2819
+ //replaceButton.setEnabled(false);
26212820 } else
2622
- if (source == redoButton)
2821
+ if (source == nextVersionButton)
26232822 {
26242823 // Go to next version
2625
- Redo();
2824
+ NextVersion();
26262825 } else
2627
- if (source == saveButton)
2826
+ if (source == saveVersionButton)
26282827 {
26292828 // Save a new version
26302829 if (!Save(true))
26312830 java.awt.Toolkit.getDefaultToolkit().beep();
2831
+ } else
2832
+ if (source == deleteVersionButton)
2833
+ {
2834
+ // Delete a new version
2835
+ DeleteVersion();
26322836 } else
26332837 if (source == oneStepButton)
26342838 {
....@@ -2683,11 +2887,11 @@
26832887 } else
26842888 if (source == undoItem)
26852889 {
2686
- Undo();
2890
+ PreviousVersion();
26872891 } else
26882892 if (source == redoItem)
26892893 {
2690
- Redo();
2894
+ NextVersion();
26912895 } else
26922896 if (source == duplicateItem)
26932897 {
....@@ -3168,22 +3372,34 @@
31683372 } else
31693373 if (source == ungroupItem || source == ungroupButton)
31703374 {
3171
- boolean hasRoot = false;
3375
+ boolean canUngroup = true;
31723376
31733377 for (int i=0; i<group.selection.size(); i++)
31743378 {
3175
- if (group.selection.get(i) == group)
3379
+ Object3D selectedItem = group.selection.get(i);
3380
+
3381
+ if (selectedItem.Size() == 0)
31763382 {
3177
- hasRoot = true;
3383
+ // Cannot ungroup leaves
3384
+ canUngroup = false;
3385
+ break;
3386
+ }
3387
+
3388
+ if (selectedItem == group)
3389
+ {
3390
+ // Cannot ungroup root
3391
+ canUngroup = false;
31783392 break;
31793393 }
31803394 }
31813395
3182
- if (!hasRoot)
3396
+ if (canUngroup)
31833397 {
31843398 for (int i=0; i<group.selection.size(); i++)
31853399 {
3186
- Ungroup(group.selection.get(i));
3400
+ Object3D selectedItem = group.selection.get(i);
3401
+
3402
+ Ungroup(selectedItem);
31873403 }
31883404
31893405 ClearSelection(false);
....@@ -3546,38 +3762,7 @@
35463762 if (CameraPane.FULLSCREEN)
35473763 fullscreenLayout = radio.layout;
35483764
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();
3765
+ Show3DView();
35813766
35823767 cameraView.requestFocusInWindow();
35833768
....@@ -3763,6 +3948,7 @@
37633948 } else
37643949 if (source == rootButton)
37653950 {
3951
+ Replace();
37663952 Object3D obj;
37673953 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
37683954 {
....@@ -3820,10 +4006,10 @@
38204006 {
38214007 Object3D child = (Object3D)e.nextElement();
38224008 if(child.editWindow != null)
3823
- objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
38244009 child.pinned = false;
38254010 child.CloseUI();
38264011 listUI.remove(child);
4012
+// objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
38274013
38284014 //child.editWindow = null; // ???????????
38294015 }
....@@ -3842,6 +4028,7 @@
38424028 obj.CloseUI();
38434029 }
38444030 listUI.clear();
4031
+ SetPinStates(group.selection.size() > 0);
38454032 refreshContents(true);
38464033 } else
38474034 if (source == allParamsButton)
....@@ -3898,8 +4085,6 @@
38984085
38994086 copy = group;
39004087
3901
- SetUndoStates();
3902
-
39034088 //Globals.theRenderer.object = group;
39044089 if(!useclient)
39054090 {
....@@ -3927,7 +4112,23 @@
39274112 */
39284113 radio.layout.doClick();
39294114
4115
+ assert(copy instanceof Composite);
4116
+
4117
+ if (copy.versionlist == null)
4118
+ {
4119
+ copy.versionlist = new Object3D[100];
4120
+ copy.versionindex = -1;
4121
+
4122
+ // Cannot work with loops
4123
+ // To fix this issue, first mark all nodes above the root,
4124
+ // and check if any of these nodes are reachable below the root.
4125
+ //Save(true);
4126
+ }
4127
+
4128
+ SetVersionStates();
4129
+
39304130 ClearUnpinned();
4131
+
39314132 //Grafreed.Assert(group != null);
39324133 //Grafreed.Assert(group.selection != null);
39334134 SetPinStates(group.selection == null || group.selection.size() > 0);
....@@ -5083,9 +5284,7 @@
50835284
50845285 freezemodel = false;
50855286 }
5086
-
5087
- boolean flashIt = true;
5088
-
5287
+
50895288 public void valueChanged(TreeSelectionEvent e)
50905289 //public boolean handleEvent(Event event)
50915290 {
....@@ -5158,13 +5357,30 @@
51585357 {
51595358 editButton.setEnabled(enabled);
51605359 uneditButton.setEnabled(enabled);
5161
- unselectButton.setEnabled(enabled);
5360
+ //unselectButton.setEnabled(enabled);
51625361 flashSelectionButton.setEnabled(enabled);
5362
+
5363
+ clearPanelButton.setEnabled(!listUI.isEmpty());
5364
+
5365
+ boolean allComposites = true;
5366
+
5367
+ if (group.selection != null)
5368
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
5369
+ {
5370
+ Object next = e.nextElement();
5371
+ if (!(next instanceof Composite)) // || (next instanceof GroupLeaf))
5372
+ {
5373
+ allComposites = false;
5374
+ break;
5375
+ }
5376
+ }
5377
+
5378
+ rootButton.setEnabled(allComposites);
51635379 }
51645380
51655381 void refreshContents(boolean cp)
51665382 {
5167
- if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
5383
+ //if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
51685384 if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
51695385 {
51705386 objEditor.ClearInfo(); // .GetMaterial());
....@@ -5174,7 +5390,7 @@
51745390 Object3D child = (Object3D) group.selection.get(i);
51755391
51765392 objEditor.AddInfo(child, this, true);
5177
- System.err.println("info : " + child.GetPath());
5393
+// System.err.println("info : " + child.GetPath());
51785394 }
51795395
51805396 objEditor.SetText(); // jan 2014
....@@ -6000,7 +6216,6 @@
60006216
60016217 cButton restoreCameraButton;
60026218
6003
- cButton saveButton;
60046219 cButton oneStepButton;
60056220
60066221 cButton groupButton;
....@@ -6058,11 +6273,11 @@
60586273 private MenuItem lookAtItem;
60596274 private MenuItem lookFromItem;
60606275 private MenuItem switchViewItem;
6061
- private MenuItem cutItem;
6276
+ private JMenuItem cutItem;
60626277 private MenuItem undoItem;
60636278 private MenuItem redoItem;
60646279 private JMenuItem duplicateItem;
6065
- private MenuItem cloneItem;
6280
+ private JMenuItem cloneItem;
60666281 private MenuItem cloneSupportItem;
60676282 private MenuItem overwriteGeoItem;
60686283 private MenuItem overwriteMatItem;
....@@ -6083,13 +6298,13 @@
60836298 private MenuItem cloneGeometriesItem;
60846299 private MenuItem shareGeometriesItem;
60856300 private MenuItem mergeGeometriesItem;
6086
- private MenuItem copyItem;
6301
+ private JMenuItem copyItem;
60876302 private MenuItem pasteItem;
6088
- private MenuItem pasteIntoItem;
6089
- private MenuItem pasteLinkItem;
6090
- private MenuItem pasteCloneItem;
6091
- private MenuItem pasteExpandItem;
6092
- private MenuItem deleteItem;
6303
+ private JMenuItem pasteIntoItem;
6304
+ private JMenuItem pasteLinkItem;
6305
+ private JMenuItem pasteCloneItem;
6306
+ private JMenuItem pasteExpandItem;
6307
+ private JMenuItem deleteItem;
60936308 private MenuItem clearAllItem;
60946309 private MenuItem genUVItem;
60956310 private MenuItem genNormalsMESHItem;
....@@ -6144,7 +6359,7 @@
61446359 private MenuItem transformGeometryItem;
61456360 private MenuItem transformChildrenItem;
61466361 private MenuItem hideItem;
6147
- private MenuItem grabItem;
6362
+ private JMenuItem grabItem;
61486363 private MenuItem backItem;
61496364 private MenuItem frontItem;
61506365 private MenuItem cameraItem;
....@@ -6157,7 +6372,7 @@
61576372 private MenuItem switchTransfoItem;
61586373 private MenuItem morphItem;
61596374 private MenuItem linkerItem;
6160
- private MenuItem ungroupItem;
6375
+ private JMenuItem ungroupItem;
61616376 private MenuItem editItem;
61626377 private MenuItem openWindowItem;
61636378 private MenuItem editLeafItem;