Normand Briere
2019-08-15 7f97054d681518416a4ee1c1548ad42cfb489a8f
GroupEditor.java
....@@ -16,6 +16,7 @@
1616 //import buoy.widget.BFileChooser;
1717
1818 class GroupEditor extends ObjEditor implements //iParse, //iCallBack,
19
+ Grafreed.iResourceCallBack,
1920 ObjectUI,
2021 Runnable,
2122 ActionListener,
....@@ -30,7 +31,7 @@
3031 final String path = "cubemaps/" + f + "-skyboxes/" + s;
3132 row.add(skyboxButton = GetButton(path + "/preview.jpg", !Grafreed.NIMBUSLAF));
3233 //row.add(skyboxButton = GetButton(path + "/negx.jpg", !Grafreed.NIMBUSLAF));
33
- skyboxButton.setToolTipText(s);
34
+ skyboxButton.setToolTipText(s.equals("") ? "No background" : s);
3435 skyboxButton.addActionListener(new ActionListener()
3536 {
3637 @Override
....@@ -41,6 +42,22 @@
4142 });
4243 }
4344
45
+ public void AddTextureButton(String f, String c, final String t, int count, cGridBag row)
46
+ {
47
+ cButton textureButton;
48
+ final String path = "textures/" + f + "/" + c + "/"; // + t;
49
+ row.add(textureButton = GetButton(path + "icons/" + t, !Grafreed.NIMBUSLAF));
50
+ textureButton.setToolTipText(c + count);
51
+ textureButton.addActionListener(new ActionListener()
52
+ {
53
+ @Override
54
+ public void actionPerformed(ActionEvent e)
55
+ {
56
+ ChangeTexture(path + t);
57
+ }
58
+ });
59
+ }
60
+
4461 public void AddSkyboxTab0(JTabbedPane skyboxpanel)
4562 {
4663 cGridBag tab0 = new cGridBag().setVertical(true);
....@@ -56,7 +73,7 @@
5673 cGridBag row5 = new cGridBag();
5774 cGridBag row6 = new cGridBag();
5875
59
- AddSkyboxButton("default", "rgb", row0);
76
+ AddSkyboxButton("default", "", row0);
6077 //AddSkyboxButton("default", "cornell", row0);
6178 AddSkyboxButton("penguins", "dust", row0);
6279 AddSkyboxButton("penguins", "tropic", row0);
....@@ -311,14 +328,56 @@
311328 }
312329 }
313330
314
- public void ChangeSkybox(String name)
331
+ public void ChangeSkybox(String skybox)
315332 {
316
- //cameraView.envyoff = false;
317
- group.skyboxname = name;
318
- group.skyboxext = "jpg";
319
- cameraView.repaint();
333
+ if (skybox.endsWith("/"))
334
+ {
335
+ group.skyboxname = null;
336
+ group.skyboxext = null;
337
+ cameraView.repaint();
338
+ }
339
+ else
340
+ {
341
+ //cameraView.envyoff = false;
342
+ group.skyboxname = skybox;
343
+ group.skyboxext = "jpg";
344
+ cameraView.repaint();
345
+ }
346
+ }
347
+
348
+ public void CreateSkyboxPanel(cGridBag skyboxPanel)
349
+ {
350
+ JTabbedPane skyboxpane = new JTabbedPane();
351
+
352
+ AddSkyboxTab0(skyboxpane);
353
+ AddSkyboxTab1(skyboxpane);
354
+ AddSkyboxTab2(skyboxpane);
355
+ AddSkyboxTab3(skyboxpane);
356
+
357
+ skyboxPanel.add(skyboxpane);
320358 }
321359
360
+ public void ChangeTexture(String texture)
361
+ {
362
+ for (int i=0; i<group.selection.size(); i++)
363
+ {
364
+ Object3D obj = group.selection.get(i);
365
+ obj.SetPigmentTexture("@" + texture);
366
+ }
367
+
368
+ refreshContents();
369
+ }
370
+
371
+ public void Show3DView()
372
+ {
373
+ // bug
374
+ //gridPanel.setDividerLocation(1.0);
375
+ //bigPanel.setDividerLocation(0.0);
376
+ bigThree.ClearUI();
377
+ bigThree.add(centralPanel);
378
+ bigThree.FlushUI();
379
+ }
380
+
322381 //ObjEditor objEditor;
323382 public void closeUI2()
324383 {
....@@ -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,73 @@
859926 buildToolsMenu(menu);
860927 }
861928
929
+ JTabbedPane resourcecontainer;
930
+ cGridBag currenttab;
931
+ boolean added; // patch for jar
932
+
933
+ int tabcount = 0;
934
+ int colcount = 0;
935
+ int rowcount = 0;
936
+ int texturecount = 0;
937
+
938
+ int columns = 5;
939
+ int rows = 7;
940
+
941
+ public void ResourceCallBack(String[] path)
942
+ {
943
+ for (int i = 0; i < path.length; i++)
944
+ System.out.print(path[i] + "/");
945
+ System.out.println();
946
+
947
+ if (//rowcount == 0 ||
948
+ path.length == 1)
949
+ {
950
+ currenttab = new cGridBag();
951
+ added = false;
952
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
953
+ currenttab.setName(tabname);
954
+ rowcount = 1;
955
+ colcount = 0;
956
+ texturecount = 0;
957
+ }
958
+
959
+ if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
960
+ {
961
+ if (!added)
962
+ {
963
+ added = true;
964
+ resourcecontainer.add(currenttab);
965
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
966
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
967
+ }
968
+
969
+ AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
970
+
971
+ if (++colcount >= columns)
972
+ {
973
+ colcount = 0;
974
+ currenttab.Return();
975
+
976
+ if (rowcount++ >= rows)
977
+ {
978
+ rowcount = 0;
979
+ }
980
+ }
981
+ }
982
+ else
983
+ {
984
+// if (!path[path.length-1].equals("icons"))
985
+// resourcecontainer.Return();
986
+ }
987
+ }
988
+
989
+ void CreateTexturePanel(cGridBag container)
990
+ {
991
+ resourcecontainer = new JTabbedPane(JTabbedPane.LEFT);
992
+ container.add(resourcecontainer);
993
+
994
+ Grafreed.ParseResources("textures", this);
995
+ }
862996
863997 void SetupUI2(ObjEditor oe)
864998 {
....@@ -877,11 +1011,6 @@
8771011 //new Exception().printStackTrace();
8781012
8791013 oe.radioPanel = new JPanel(new GridBagLayout());
880
- oe.aConstraints.weightx = 1;
881
- oe.aConstraints.weighty = 0;
882
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
883
- oe.aConstraints.gridwidth = 100;
884
- oe.aConstraints.gridheight = 1;
8851014 // oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
8861015
8871016 oe.buttonGroup = new ButtonGroup();
....@@ -914,10 +1043,49 @@
9141043
9151044 if (Globals.ADVANCED)
9161045 {
917
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
918
- maxButton.setToolTipText("Maximize window");
919
- maxButton.addActionListener(this);
1046
+// oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1047
+// maxButton.setToolTipText("Maximize window");
1048
+// maxButton.addActionListener(this);
9201049 }
1050
+
1051
+ cButton gcButton;
1052
+
1053
+// oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1054
+// gcButton.setToolTipText("Garbage collect");
1055
+// gcButton.addActionListener(new ActionListener()
1056
+// {
1057
+// public void actionPerformed(ActionEvent e)
1058
+// {
1059
+// System.gc();
1060
+// }
1061
+// });
1062
+
1063
+ oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1064
+ collapseButton.setToolTipText("Collapse toolbar");
1065
+ collapseButton.addActionListener(this);
1066
+
1067
+ oe.toolbarPanel.add(maximize3DButton = GetButton("", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1068
+ maximize3DButton.setToolTipText("Maximize 3D view");
1069
+ maximize3DButton.addActionListener(this);
1070
+
1071
+ oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1072
+ twoButton.setToolTipText("Show 3D view only");
1073
+ twoButton.addActionListener(this);
1074
+ this.fullscreenLayout = twoButton;
1075
+
1076
+ oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1077
+ threeButton.setToolTipText("Show controls and 3D view");
1078
+ threeButton.addActionListener(this);
1079
+ if (Globals.ADVANCED)
1080
+ {
1081
+ oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1082
+ sixButton.setToolTipText("Show 3D view and controls");
1083
+ sixButton.addActionListener(this);
1084
+ }
1085
+// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1086
+// sevenButton.setToolTipText("3-column layout");
1087
+// sevenButton.addActionListener(this);
1088
+ //
9211089
9221090 oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9231091 fullButton.setToolTipText("Full-screen window");
....@@ -931,41 +1099,45 @@
9311099 restoreCameraButton.setToolTipText("Restore viewpoint");
9321100 restoreCameraButton.addActionListener(this);
9331101
934
- copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
935
- saveButton.setToolTipText("Duplicate current version");
936
- saveButton.addActionListener(this);
1102
+ copyOptionsPanel.add(saveVersionButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1103
+ saveVersionButton.setToolTipText("Duplicate current version");
1104
+ saveVersionButton.addActionListener(this);
9371105
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);
1106
+ copyOptionsPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1107
+ deleteVersionButton.setToolTipText("Delete current version");
1108
+ deleteVersionButton.addActionListener(this);
1109
+
1110
+ copyOptionsPanel.add(previousVersionButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1111
+ previousVersionButton.setToolTipText("Previous version");
1112
+ previousVersionButton.addActionListener(this);
1113
+ previousVersionButton.setEnabled(false);
9421114
9431115 cGridBag updown = new cGridBag().setVertical(true);
9441116 updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
945
- restoreButton.setToolTipText("Restore current version (undo latest change)");
1117
+ restoreButton.setToolTipText("Undo (restore current version)");
9461118 restoreButton.addActionListener(this);
947
- restoreButton.setEnabled(false);
1119
+ //restoreButton.setEnabled(false);
9481120
9491121 updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
950
- replaceButton.setToolTipText("Replace current version (save latest change)");
1122
+ replaceButton.setToolTipText("Save (replace current version)");
9511123 replaceButton.addActionListener(this);
952
- replaceButton.setEnabled(false);
1124
+ //replaceButton.setEnabled(false);
9531125
9541126 copyOptionsPanel.add(updown);
9551127
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);
1128
+ copyOptionsPanel.add(nextVersionButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1129
+ nextVersionButton.setToolTipText("Next version");
1130
+ nextVersionButton.addActionListener(this);
1131
+ nextVersionButton.setEnabled(false);
1132
+
1133
+ oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1134
+ oneStepButton.setToolTipText("Animate one step forward");
1135
+ oneStepButton.addActionListener(this);
9601136
9611137 oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
9621138 liveCB.setToolTipText("Enable animation");
9631139 liveCB.addItemListener(this);
9641140
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
-
9691141 oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
9701142 fastCB.setToolTipText("Fast mode");
9711143 fastCB.addItemListener(this);
....@@ -992,21 +1164,6 @@
9921164
9931165 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
9941166
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
- //
10101167
10111168 oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10121169 rootButton.setToolTipText("Open selection in new tab");
....@@ -1022,7 +1179,7 @@
10221179
10231180 // INSERT
10241181 row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1025
- gridButton.setToolTipText("Create grid");
1182
+ gridButton.setToolTipText("Create ground");
10261183 gridButton.addActionListener(this);
10271184
10281185 row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1090,19 +1247,15 @@
10901247
10911248 oe.toolboxPanel.add(row2);
10921249
1093
- // ENVYMAPS
1094
- cGridBag skyboxpane = new cGridBag();
1095
- skyboxpane.preferredHeight = 100;
1250
+ cGridBag textures = new cGridBag();
10961251
1097
- oe.toolboxPanel.add(skyboxpane);
1252
+ CreateTexturePanel(textures);
10981253
1099
- JTabbedPane skyboxpanel = new JTabbedPane();
1100
- skyboxpane.add(skyboxpanel);
1254
+ oe.toolboxPanel.add(textures);
11011255
1102
- AddSkyboxTab0(skyboxpanel);
1103
- AddSkyboxTab1(skyboxpanel);
1104
- AddSkyboxTab2(skyboxpanel);
1105
- AddSkyboxTab3(skyboxpanel);
1256
+ textures.preferredHeight = 100;
1257
+
1258
+ CreateSkyboxPanel(oe.skyboxPanel);
11061259
11071260 // EDIT panel
11081261 editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1110,20 +1263,20 @@
11101263 editButton.addActionListener(this);
11111264
11121265 editCommandsPanel.add(uneditButton = GetButton("icons/remove.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1113
- uneditButton.setToolTipText("Remove selection controls");
1266
+ uneditButton.setToolTipText("Unpin and remove selection controls");
11141267 uneditButton.addActionListener(this);
11151268
11161269 editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
1117
- allParamsButton.setToolTipText("Show all controle");
1270
+ allParamsButton.setToolTipText("Show all controls");
11181271 allParamsButton.addActionListener(this);
11191272
1120
- editCommandsPanel.add(clearPanelButton = new cButton("C", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1121
- clearPanelButton.setToolTipText("Clear edit panel");
1273
+ editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1274
+ clearPanelButton.setToolTipText("Clear all controls");
11221275 clearPanelButton.addActionListener(this);
11231276
1124
- editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1125
- unselectButton.setToolTipText("Unselect");
1126
- unselectButton.addActionListener(this);
1277
+ //editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1278
+ //unselectButton.setToolTipText("Unselect");
1279
+ //unselectButton.addActionListener(this);
11271280
11281281 editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11291282 flashSelectionButton.setToolTipText("Highlight selection");
....@@ -1318,6 +1471,14 @@
13181471
13191472 void EditObject(Object3D obj)
13201473 {
1474
+ assert(obj instanceof Composite);
1475
+
1476
+// if (obj.versionlist == null)
1477
+// {
1478
+// obj.versionlist = new Object3D[100];
1479
+// obj.versionindex = -1;
1480
+// }
1481
+
13211482 cRadio radioButton = new cRadio(obj.name);
13221483
13231484 // June 2019. Patch to avoid bug with transparency.
....@@ -1708,7 +1869,12 @@
17081869 TreePath path;
17091870
17101871 public TransferableTreePath(TreePath tp) {
1711
- path = tp;
1872
+ Object[] objs = new Object[tp.getPathCount()];
1873
+ for (int i=0; i<objs.length; i++)
1874
+ {
1875
+ objs[i] = ((Object3D)tp.getPathComponent(i)).GetUUID();
1876
+ }
1877
+ path = new TreePath(objs);
17121878 }
17131879
17141880 public synchronized DataFlavor[] getTransferDataFlavors() {
....@@ -2519,27 +2685,35 @@
25192685 } else
25202686 if (source == loopItem || source == loopButton)
25212687 {
2688
+ if (!group.selection.isEmpty())
2689
+ {
25222690 Composite csg = new GroupLeaf();
25232691 csg.count = 5;
2524
- group(csg);
25252692 Composite child = new cGroup("Branch");
25262693 csg.addChild(child);
25272694 child.addChild(csg);
2695
+ group(csg);
2696
+ }
25282697 } else
25292698 if (source == doubleItem)
25302699 {
2700
+ if (!group.selection.isEmpty())
2701
+ {
25312702 Composite csg = new GroupLeaf("Fork");
25322703 csg.count = 5;
2533
- group(csg);
25342704 Composite child = new cGroup("Branch A");
25352705 csg.addChild(child);
25362706 child.addChild(csg);
25372707 child = new cGroup("Branch B");
25382708 csg.addChild(child);
25392709 child.addChild(csg);
2710
+ group(csg);
2711
+ }
25402712 } else
25412713 if (source == tripleItem)
25422714 {
2715
+ if (!group.selection.isEmpty())
2716
+ {
25432717 Composite csg = new GroupLeaf("Trident");
25442718 csg.count = 4;
25452719 group(csg);
....@@ -2552,6 +2726,7 @@
25522726 child = new cGroup();
25532727 csg.addChild(child);
25542728 child.addChild(csg);
2729
+ }
25552730 } else
25562731 if (source == computeAOItem)
25572732 {
....@@ -2571,7 +2746,7 @@
25712746 if (source == invariantsItem)
25722747 {
25732748 System.out.println("Invariants:");
2574
- Grafreed.grafreeD.universe.invariants();
2749
+ Grafreed.grafreed.universe.invariants();
25752750 } else
25762751 if (source == memoryItem)
25772752 {
....@@ -2602,33 +2777,52 @@
26022777 {
26032778 ToggleFullScreen();
26042779 } else
2605
- if (source == undoButton)
2780
+ if (source == collapseButton)
2781
+ {
2782
+ this.expandedLayout = radio.layout;
2783
+ CollapseToolbar();
2784
+ } else
2785
+ if (source == maximize3DButton)
2786
+ {
2787
+ this.expandedLayout = radio.layout;
2788
+ radio.layout = twoButton;
2789
+ Show3DView();
2790
+ CollapseToolbar();
2791
+ } else
2792
+ if (source == previousVersionButton)
26062793 {
26072794 // Go to previous version
26082795 //if (!Undo())
26092796 //java.awt.Toolkit.getDefaultToolkit().beep();
2610
- Undo();
2797
+ PreviousVersion();
26112798 } else
26122799 if (source == restoreButton)
26132800 {
26142801 // Restore current version
26152802 Restore();
2803
+ //restoreButton.setEnabled(false);
26162804 } else
26172805 if (source == replaceButton)
26182806 {
26192807 // Overwrite current version
26202808 Replace();
2809
+ //replaceButton.setEnabled(false);
26212810 } else
2622
- if (source == redoButton)
2811
+ if (source == nextVersionButton)
26232812 {
26242813 // Go to next version
2625
- Redo();
2814
+ NextVersion();
26262815 } else
2627
- if (source == saveButton)
2816
+ if (source == saveVersionButton)
26282817 {
26292818 // Save a new version
26302819 if (!Save(true))
26312820 java.awt.Toolkit.getDefaultToolkit().beep();
2821
+ } else
2822
+ if (source == deleteVersionButton)
2823
+ {
2824
+ // Delete a new version
2825
+ DeleteVersion();
26322826 } else
26332827 if (source == oneStepButton)
26342828 {
....@@ -2683,11 +2877,11 @@
26832877 } else
26842878 if (source == undoItem)
26852879 {
2686
- Undo();
2880
+ PreviousVersion();
26872881 } else
26882882 if (source == redoItem)
26892883 {
2690
- Redo();
2884
+ NextVersion();
26912885 } else
26922886 if (source == duplicateItem)
26932887 {
....@@ -3168,22 +3362,34 @@
31683362 } else
31693363 if (source == ungroupItem || source == ungroupButton)
31703364 {
3171
- boolean hasRoot = false;
3365
+ boolean canUngroup = true;
31723366
31733367 for (int i=0; i<group.selection.size(); i++)
31743368 {
3175
- if (group.selection.get(i) == group)
3369
+ Object3D selectedItem = group.selection.get(i);
3370
+
3371
+ if (selectedItem.Size() == 0)
31763372 {
3177
- hasRoot = true;
3373
+ // Cannot ungroup leaves
3374
+ canUngroup = false;
3375
+ break;
3376
+ }
3377
+
3378
+ if (selectedItem == group)
3379
+ {
3380
+ // Cannot ungroup root
3381
+ canUngroup = false;
31783382 break;
31793383 }
31803384 }
31813385
3182
- if (!hasRoot)
3386
+ if (canUngroup)
31833387 {
31843388 for (int i=0; i<group.selection.size(); i++)
31853389 {
3186
- Ungroup(group.selection.get(i));
3390
+ Object3D selectedItem = group.selection.get(i);
3391
+
3392
+ Ungroup(selectedItem);
31873393 }
31883394
31893395 ClearSelection(false);
....@@ -3546,38 +3752,7 @@
35463752 if (CameraPane.FULLSCREEN)
35473753 fullscreenLayout = radio.layout;
35483754
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();
3755
+ Show3DView();
35813756
35823757 cameraView.requestFocusInWindow();
35833758
....@@ -3763,6 +3938,7 @@
37633938 } else
37643939 if (source == rootButton)
37653940 {
3941
+ Replace();
37663942 Object3D obj;
37673943 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
37683944 {
....@@ -3820,10 +3996,10 @@
38203996 {
38213997 Object3D child = (Object3D)e.nextElement();
38223998 if(child.editWindow != null)
3823
- objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
38243999 child.pinned = false;
38254000 child.CloseUI();
38264001 listUI.remove(child);
4002
+// objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
38274003
38284004 //child.editWindow = null; // ???????????
38294005 }
....@@ -3842,6 +4018,7 @@
38424018 obj.CloseUI();
38434019 }
38444020 listUI.clear();
4021
+ SetPinStates(group.selection.size() > 0);
38454022 refreshContents(true);
38464023 } else
38474024 if (source == allParamsButton)
....@@ -3898,8 +4075,6 @@
38984075
38994076 copy = group;
39004077
3901
- SetUndoStates();
3902
-
39034078 //Globals.theRenderer.object = group;
39044079 if(!useclient)
39054080 {
....@@ -3927,7 +4102,20 @@
39274102 */
39284103 radio.layout.doClick();
39294104
4105
+ assert(copy instanceof Composite);
4106
+
4107
+ if (copy.versionlist == null)
4108
+ {
4109
+ copy.versionlist = new Object3D[100];
4110
+ copy.versionindex = -1;
4111
+
4112
+ Save(true);
4113
+ }
4114
+
4115
+ SetVersionStates();
4116
+
39304117 ClearUnpinned();
4118
+
39314119 //Grafreed.Assert(group != null);
39324120 //Grafreed.Assert(group.selection != null);
39334121 SetPinStates(group.selection == null || group.selection.size() > 0);
....@@ -5083,9 +5271,7 @@
50835271
50845272 freezemodel = false;
50855273 }
5086
-
5087
- boolean flashIt = true;
5088
-
5274
+
50895275 public void valueChanged(TreeSelectionEvent e)
50905276 //public boolean handleEvent(Event event)
50915277 {
....@@ -5158,13 +5344,29 @@
51585344 {
51595345 editButton.setEnabled(enabled);
51605346 uneditButton.setEnabled(enabled);
5161
- unselectButton.setEnabled(enabled);
5347
+ //unselectButton.setEnabled(enabled);
51625348 flashSelectionButton.setEnabled(enabled);
5349
+
5350
+ clearPanelButton.setEnabled(!listUI.isEmpty());
5351
+
5352
+ boolean allComposites = true;
5353
+
5354
+ if (group.selection != null)
5355
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
5356
+ {
5357
+ if (!(e.nextElement() instanceof Composite))
5358
+ {
5359
+ allComposites = false;
5360
+ break;
5361
+ }
5362
+ }
5363
+
5364
+ rootButton.setEnabled(allComposites);
51635365 }
51645366
51655367 void refreshContents(boolean cp)
51665368 {
5167
- if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
5369
+ //if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
51685370 if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
51695371 {
51705372 objEditor.ClearInfo(); // .GetMaterial());
....@@ -5174,7 +5376,7 @@
51745376 Object3D child = (Object3D) group.selection.get(i);
51755377
51765378 objEditor.AddInfo(child, this, true);
5177
- System.err.println("info : " + child.GetPath());
5379
+// System.err.println("info : " + child.GetPath());
51785380 }
51795381
51805382 objEditor.SetText(); // jan 2014
....@@ -6000,7 +6202,6 @@
60006202
60016203 cButton restoreCameraButton;
60026204
6003
- cButton saveButton;
60046205 cButton oneStepButton;
60056206
60066207 cButton groupButton;
....@@ -6058,11 +6259,11 @@
60586259 private MenuItem lookAtItem;
60596260 private MenuItem lookFromItem;
60606261 private MenuItem switchViewItem;
6061
- private MenuItem cutItem;
6262
+ private JMenuItem cutItem;
60626263 private MenuItem undoItem;
60636264 private MenuItem redoItem;
60646265 private JMenuItem duplicateItem;
6065
- private MenuItem cloneItem;
6266
+ private JMenuItem cloneItem;
60666267 private MenuItem cloneSupportItem;
60676268 private MenuItem overwriteGeoItem;
60686269 private MenuItem overwriteMatItem;
....@@ -6083,13 +6284,13 @@
60836284 private MenuItem cloneGeometriesItem;
60846285 private MenuItem shareGeometriesItem;
60856286 private MenuItem mergeGeometriesItem;
6086
- private MenuItem copyItem;
6287
+ private JMenuItem copyItem;
60876288 private MenuItem pasteItem;
6088
- private MenuItem pasteIntoItem;
6089
- private MenuItem pasteLinkItem;
6090
- private MenuItem pasteCloneItem;
6091
- private MenuItem pasteExpandItem;
6092
- private MenuItem deleteItem;
6289
+ private JMenuItem pasteIntoItem;
6290
+ private JMenuItem pasteLinkItem;
6291
+ private JMenuItem pasteCloneItem;
6292
+ private JMenuItem pasteExpandItem;
6293
+ private JMenuItem deleteItem;
60936294 private MenuItem clearAllItem;
60946295 private MenuItem genUVItem;
60956296 private MenuItem genNormalsMESHItem;
....@@ -6157,7 +6358,7 @@
61576358 private MenuItem switchTransfoItem;
61586359 private MenuItem morphItem;
61596360 private MenuItem linkerItem;
6160
- private MenuItem ungroupItem;
6361
+ private JMenuItem ungroupItem;
61616362 private MenuItem editItem;
61626363 private MenuItem openWindowItem;
61636364 private MenuItem editLeafItem;