Normand Briere
2019-08-17 ecc1309a04b527c62ffe97e814daf050dbd025cd
GroupEditor.java
....@@ -16,7 +16,7 @@
1616 //import buoy.widget.BFileChooser;
1717
1818 class GroupEditor extends ObjEditor implements //iParse, //iCallBack,
19
- Grafreed.iResourceCallBack,
19
+ Grafreed.iResourceCallBack,
2020 ObjectUI,
2121 Runnable,
2222 ActionListener,
....@@ -31,7 +31,7 @@
3131 final String path = "cubemaps/" + f + "-skyboxes/" + s;
3232 row.add(skyboxButton = GetButton(path + "/preview.jpg", !Grafreed.NIMBUSLAF));
3333 //row.add(skyboxButton = GetButton(path + "/negx.jpg", !Grafreed.NIMBUSLAF));
34
- skyboxButton.setToolTipText(s);
34
+ skyboxButton.setToolTipText(s.equals("") ? "No background" : s);
3535 skyboxButton.addActionListener(new ActionListener()
3636 {
3737 @Override
....@@ -42,6 +42,22 @@
4242 });
4343 }
4444
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
+
4561 public void AddSkyboxTab0(JTabbedPane skyboxpanel)
4662 {
4763 cGridBag tab0 = new cGridBag().setVertical(true);
....@@ -57,7 +73,7 @@
5773 cGridBag row5 = new cGridBag();
5874 cGridBag row6 = new cGridBag();
5975
60
- AddSkyboxButton("default", "rgb", row0);
76
+ AddSkyboxButton("default", "", row0);
6177 //AddSkyboxButton("default", "cornell", row0);
6278 AddSkyboxButton("penguins", "dust", row0);
6379 AddSkyboxButton("penguins", "tropic", row0);
....@@ -312,26 +328,56 @@
312328 }
313329 }
314330
315
- public void CallBack(String[] path)
316
- {
317
- for (int i = 0; i < path.length; i++)
318
- {
319
- System.out.print(path[i] + "/");
320
- }
321
-
322
- System.out.println();
323
- }
324
-
325331 public void ChangeSkybox(String skybox)
326332 {
327
- //cameraView.envyoff = false;
328
- group.skyboxname = skybox;
329
- group.skyboxext = "jpg";
330
- 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
+ }
331347
332
- Grafreed.ParseResources("textures", this);
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);
333358 }
334359
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
+
335381 //ObjEditor objEditor;
336382 public void closeUI2()
337383 {
....@@ -369,10 +415,14 @@
369415 this.copy = this.group = group;
370416 //selectees = this.group.selectees;
371417
418
+ assert(false);
419
+
372420 if (copy.versionlist == null)
373421 {
374422 copy.versionlist = new Object3D[100];
375423 copy.versionindex = -1;
424
+
425
+ //Save(true);
376426 }
377427
378428 if(ui)
....@@ -401,7 +451,7 @@
401451 copy.versionlist = new Object3D[100];
402452 copy.versionindex = -1;
403453
404
- Save(true);
454
+ //Save(true);
405455 }
406456 }
407457
....@@ -492,33 +542,35 @@
492542 // menu.add("-");
493543 duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate"));
494544 duplicateItem.addActionListener(this);
495
- cloneItem = menu.add(new MenuItem("Clone"));
545
+
546
+ cloneItem = oe.jTree.popup.add(new JMenuItem("Clone"));
496547 cloneItem.addActionListener(this);
497
- if (Globals.ADVANCED)
548
+ //if (Globals.ADVANCED)
498549 {
499550 cloneSupportItem = menu.add(new MenuItem("Clone (+supports)"));
500551 cloneSupportItem.addActionListener(this);
501552 }
553
+ oe.jTree.popup.addSeparator();
502554 menu.add("-");
503
- cutItem = menu.add(new MenuItem("Cut"));
555
+ cutItem = oe.jTree.popup.add(new JMenuItem("Cut"));
504556 cutItem.addActionListener(this);
505
- copyItem = menu.add(new MenuItem("Copy"));
557
+ copyItem = oe.jTree.popup.add(new JMenuItem("Copy"));
506558 copyItem.addActionListener(this);
507559 pasteItem = menu.add(new MenuItem("Paste"));
508560 pasteItem.addActionListener(this);
509561
510
- menu.add("-");
511
- pasteIntoItem = menu.add(new MenuItem("Paste into"));
562
+ oe.jTree.popup.addSeparator();
563
+ //menu.add("-");
564
+ pasteIntoItem = oe.jTree.popup.add(new JMenuItem("Paste into"));
512565 pasteIntoItem.addActionListener(this);
513
- pasteLinkItem = menu.add(new MenuItem("Paste link"));
566
+ pasteLinkItem = oe.jTree.popup.add(new JMenuItem("Paste link"));
514567 pasteLinkItem.addActionListener(this);
515
- pasteCloneItem = menu.add(new MenuItem("Paste clone"));
568
+ pasteCloneItem = oe.jTree.popup.add(new JMenuItem("Paste clone"));
516569 pasteCloneItem.addActionListener(this);
517
-// pasteExpandItem = menu.add(new MenuItem("Paste expand"));
570
+// CRASH pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand"));
518571 // pasteExpandItem.addActionListener(this);
519
- menu.add("-");
520
- deleteItem = menu.add(new MenuItem("Delete"));
521
- deleteItem.addActionListener(this);
572
+ //menu.add("-");
573
+ oe.jTree.popup.addSeparator();
522574
523575 if (Globals.ADVANCED)
524576 {
....@@ -604,11 +656,9 @@
604656 oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest"));
605657 //cameraMenu.add(lookFromItem = new MenuItem("Look From Selection"));
606658 //cameraMenu.add(switchViewItem = new MenuItem("Reverse View"));
607
- editLeafItem = oe.cameraMenu.add(new MenuItem("Edit Leaf"));
608659 oe.cameraMenu.add("-");
609660 openWindowItem = oe.cameraMenu.add(new MenuItem("Edit copy..."));
610661 openWindowItem.addActionListener(this);
611
- editLeafItem.addActionListener(this);
612662 lookAtItem.addActionListener(this);
613663 //lookFromItem.addActinoListener(this);
614664 //switchViewItem.addActionListener(this);
....@@ -655,9 +705,8 @@
655705 setMasterItem.addActionListener(this);
656706 }
657707
658
- oe.menuBar.add(menu = new Menu("Group"));
659
-// grabItem = menu.add(new MenuItem("Grab"));
660
-// grabItem.addActionListener(this);
708
+ oe.menuBar.add(menu = new Menu("Order"));
709
+
661710 backItem = menu.add(new MenuItem("Back"));
662711 backItem.addActionListener(this);
663712 frontItem = menu.add(new MenuItem("Front"));
....@@ -665,13 +714,21 @@
665714 // compositeItem = menu.add(new MenuItem("Composite"));
666715 // compositeItem.addActionListener(this);
667716
717
+ grabItem = oe.jTree.popup.add(new JMenuItem("Group"));
718
+ grabItem.addActionListener(this);
719
+
668720 if (Globals.ADVANCED)
669721 {
670722 hideItem = menu.add(new MenuItem("Hidden Group"));
671723 hideItem.addActionListener(this);
672724 }
673
- ungroupItem = menu.add(new MenuItem("Ungroup"));
725
+ ungroupItem = oe.jTree.popup.add(new JMenuItem("Ungroup"));
674726 ungroupItem.addActionListener(this);
727
+
728
+ oe.jTree.popup.addSeparator();
729
+
730
+ deleteItem = oe.jTree.popup.add(new JMenuItem("Delete"));
731
+ deleteItem.addActionListener(this);
675732
676733 // menu.add("-");
677734 //
....@@ -856,6 +913,9 @@
856913 shareGeometriesItem.addActionListener(this);
857914 mergeGeometriesItem = menu.add(new MenuItem("Merge Geometries"));
858915 mergeGeometriesItem.addActionListener(this);
916
+ menu.add("-");
917
+ editLeafItem = menu.add(new MenuItem("Edit leaf..."));
918
+ editLeafItem.addActionListener(this);
859919 if (Globals.ADVANCED)
860920 {
861921 // Pretty much the same as duplicate and clone.
....@@ -872,6 +932,74 @@
872932 buildToolsMenu(menu);
873933 }
874934
935
+ JTabbedPane resourcecontainer;
936
+ cGridBag currenttab;
937
+ //boolean added; // patch for jar
938
+
939
+ int tabcount = 0;
940
+ int colcount = 0;
941
+ int rowcount = 0;
942
+ int texturecount = 0;
943
+
944
+ int columns = 5;
945
+ int rows = 7;
946
+
947
+ public void ResourceCallBack(String[] path)
948
+ {
949
+// for (int i = 0; i < path.length; i++)
950
+// System.out.print(path[i] + "/");
951
+// System.out.println();
952
+
953
+ if (//rowcount == 0 ||
954
+ path.length == 1 && !path[0].equals("") && !path[0].equals(".DS_Store"))
955
+ {
956
+ currenttab = new cGridBag();
957
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
958
+ currenttab.setName(tabname);
959
+ //added = false;
960
+ resourcecontainer.add(currenttab);
961
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
962
+ rowcount = 1;
963
+ colcount = 0;
964
+ texturecount = 0;
965
+ }
966
+
967
+ if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
968
+ {
969
+ //if (!added)
970
+ {
971
+ //added = true;
972
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
973
+ currenttab = (cGridBag)resourcecontainer.getComponentAt(resourcecontainer.indexOfTab(tabname));
974
+ }
975
+
976
+ AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
977
+
978
+ if (++colcount >= columns)
979
+ {
980
+ colcount = 0;
981
+ currenttab.Return();
982
+
983
+ if (rowcount++ >= rows)
984
+ {
985
+ rowcount = 0;
986
+ }
987
+ }
988
+ }
989
+ else
990
+ {
991
+// if (!path[path.length-1].equals("icons"))
992
+// resourcecontainer.Return();
993
+ }
994
+ }
995
+
996
+ void CreateTexturePanel(cGridBag container)
997
+ {
998
+ resourcecontainer = new JTabbedPane(JTabbedPane.LEFT);
999
+ container.add(resourcecontainer);
1000
+
1001
+ Grafreed.ParseResources("textures", this);
1002
+ }
8751003
8761004 void SetupUI2(ObjEditor oe)
8771005 {
....@@ -890,11 +1018,6 @@
8901018 //new Exception().printStackTrace();
8911019
8921020 oe.radioPanel = new JPanel(new GridBagLayout());
893
- oe.aConstraints.weightx = 1;
894
- oe.aConstraints.weighty = 0;
895
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
896
- oe.aConstraints.gridwidth = 100;
897
- oe.aConstraints.gridheight = 1;
8981021 // oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
8991022
9001023 oe.buttonGroup = new ButtonGroup();
....@@ -927,10 +1050,49 @@
9271050
9281051 if (Globals.ADVANCED)
9291052 {
930
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
931
- maxButton.setToolTipText("Maximize window");
932
- maxButton.addActionListener(this);
1053
+// oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1054
+// maxButton.setToolTipText("Maximize window");
1055
+// maxButton.addActionListener(this);
9331056 }
1057
+
1058
+ cButton gcButton;
1059
+
1060
+// oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1061
+// gcButton.setToolTipText("Garbage collect");
1062
+// gcButton.addActionListener(new ActionListener()
1063
+// {
1064
+// public void actionPerformed(ActionEvent e)
1065
+// {
1066
+// System.gc();
1067
+// }
1068
+// });
1069
+
1070
+ oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1071
+ collapseButton.setToolTipText("Collapse toolbar");
1072
+ collapseButton.addActionListener(this);
1073
+
1074
+ oe.toolbarPanel.add(maximize3DButton = GetButton("icons/empty.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1075
+ maximize3DButton.setToolTipText("Maximize 3D view");
1076
+ maximize3DButton.addActionListener(this);
1077
+
1078
+ oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1079
+ twoButton.setToolTipText("Show 3D view only");
1080
+ twoButton.addActionListener(this);
1081
+ this.fullscreenLayout = twoButton;
1082
+
1083
+ oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1084
+ threeButton.setToolTipText("Show controls and 3D view");
1085
+ threeButton.addActionListener(this);
1086
+ if (Globals.ADVANCED)
1087
+ {
1088
+ oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1089
+ sixButton.setToolTipText("Show 3D view and controls");
1090
+ sixButton.addActionListener(this);
1091
+ }
1092
+// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1093
+// sevenButton.setToolTipText("3-column layout");
1094
+// sevenButton.addActionListener(this);
1095
+ //
9341096
9351097 oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9361098 fullButton.setToolTipText("Full-screen window");
....@@ -951,6 +1113,7 @@
9511113 copyOptionsPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9521114 deleteVersionButton.setToolTipText("Delete current version");
9531115 deleteVersionButton.addActionListener(this);
1116
+ deleteVersionButton.setEnabled(false);
9541117
9551118 copyOptionsPanel.add(previousVersionButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9561119 previousVersionButton.setToolTipText("Previous version");
....@@ -961,12 +1124,12 @@
9611124 updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9621125 restoreButton.setToolTipText("Undo (restore current version)");
9631126 restoreButton.addActionListener(this);
964
- //restoreButton.setEnabled(false);
1127
+ restoreButton.setEnabled(false);
9651128
9661129 updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9671130 replaceButton.setToolTipText("Save (replace current version)");
9681131 replaceButton.addActionListener(this);
969
- //replaceButton.setEnabled(false);
1132
+ replaceButton.setEnabled(false);
9701133
9711134 copyOptionsPanel.add(updown);
9721135
....@@ -975,14 +1138,14 @@
9751138 nextVersionButton.addActionListener(this);
9761139 nextVersionButton.setEnabled(false);
9771140
978
- oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
979
- liveCB.setToolTipText("Enable animation");
980
- liveCB.addItemListener(this);
981
-
9821141 oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9831142 oneStepButton.setToolTipText("Animate one step forward");
9841143 oneStepButton.addActionListener(this);
9851144
1145
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
1146
+ liveCB.setToolTipText("Enable animation");
1147
+ liveCB.addItemListener(this);
1148
+
9861149 oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
9871150 fastCB.setToolTipText("Fast mode");
9881151 fastCB.addItemListener(this);
....@@ -1009,21 +1172,6 @@
10091172
10101173 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
10111174
1012
- oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1013
- twoButton.setToolTipText("Show 3D view only");
1014
- twoButton.addActionListener(this);
1015
- this.fullscreenLayout = twoButton;
1016
-
1017
- oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1018
- threeButton.setToolTipText("Show controls and 3D view");
1019
- threeButton.addActionListener(this);
1020
- oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1021
- sixButton.setToolTipText("Show 3D view and controls");
1022
- sixButton.addActionListener(this);
1023
-// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1024
-// sevenButton.setToolTipText("3-column layout");
1025
-// sevenButton.addActionListener(this);
1026
- //
10271175
10281176 oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10291177 rootButton.setToolTipText("Open selection in new tab");
....@@ -1039,12 +1187,16 @@
10391187
10401188 // INSERT
10411189 row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1042
- gridButton.setToolTipText("Create grid");
1190
+ gridButton.setToolTipText("Create ground");
10431191 gridButton.addActionListener(this);
10441192
10451193 row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10461194 boxButton.setToolTipText("Create box");
10471195 boxButton.addActionListener(this);
1196
+
1197
+ row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1198
+ superButton.setToolTipText("Create superellipsoid");
1199
+ superButton.addActionListener(this);
10481200
10491201 row1.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10501202 sphereButton.setToolTipText("Create sphere");
....@@ -1057,10 +1209,6 @@
10571209 row1.add(torusButton = GetButton("icons/torus.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10581210 torusButton.setToolTipText("Create torus");
10591211 torusButton.addActionListener(this);
1060
-
1061
- row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1062
- superButton.setToolTipText("Create superellipsoid");
1063
- superButton.addActionListener(this);
10641212
10651213 if (Globals.ADVANCED)
10661214 {
....@@ -1107,19 +1255,17 @@
11071255
11081256 oe.toolboxPanel.add(row2);
11091257
1110
- // ENVYMAPS
1111
- cGridBag skyboxpane = new cGridBag();
1112
- skyboxpane.preferredHeight = 100;
1258
+ cGridBag textures = new cGridBag();
11131259
1114
- oe.toolboxPanel.add(skyboxpane);
1260
+ CreateTexturePanel(textures);
11151261
1116
- JTabbedPane skyboxpanel = new JTabbedPane();
1117
- skyboxpane.add(skyboxpanel);
1262
+ resourcecontainer.setSelectedIndex((int)(Math.random() * resourcecontainer.getTabCount()));
11181263
1119
- AddSkyboxTab0(skyboxpanel);
1120
- AddSkyboxTab1(skyboxpanel);
1121
- AddSkyboxTab2(skyboxpanel);
1122
- AddSkyboxTab3(skyboxpanel);
1264
+ oe.toolboxPanel.add(textures);
1265
+
1266
+ textures.preferredHeight = 100;
1267
+
1268
+ CreateSkyboxPanel(oe.skyboxPanel);
11231269
11241270 // EDIT panel
11251271 editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1131,16 +1277,16 @@
11311277 uneditButton.addActionListener(this);
11321278
11331279 editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
1134
- allParamsButton.setToolTipText("Show all controle");
1280
+ allParamsButton.setToolTipText("Show all controls");
11351281 allParamsButton.addActionListener(this);
11361282
11371283 editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1138
- clearPanelButton.setToolTipText("Clear edit panel");
1284
+ clearPanelButton.setToolTipText("Clear all controls");
11391285 clearPanelButton.addActionListener(this);
11401286
1141
- editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1142
- unselectButton.setToolTipText("Unselect");
1143
- unselectButton.addActionListener(this);
1287
+ //editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1288
+ //unselectButton.setToolTipText("Unselect");
1289
+ //unselectButton.addActionListener(this);
11441290
11451291 editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11461292 flashSelectionButton.setToolTipText("Highlight selection");
....@@ -1335,6 +1481,14 @@
13351481
13361482 void EditObject(Object3D obj)
13371483 {
1484
+ assert(obj instanceof Composite);
1485
+
1486
+// if (obj.versionlist == null)
1487
+// {
1488
+// obj.versionlist = new Object3D[100];
1489
+// obj.versionindex = -1;
1490
+// }
1491
+
13381492 cRadio radioButton = new cRadio(obj.name);
13391493
13401494 // June 2019. Patch to avoid bug with transparency.
....@@ -1359,6 +1513,7 @@
13591513
13601514 oe.SetupViews();
13611515
1516
+ if (Globals.DEBUG)
13621517 System.out.println("SetupViews");
13631518 DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(
13641519 oe.cameraView, DnDConstants.ACTION_COPY_OR_MOVE, this); // ACTION_LINK ??
....@@ -1725,7 +1880,12 @@
17251880 TreePath path;
17261881
17271882 public TransferableTreePath(TreePath tp) {
1728
- path = tp;
1883
+ Object[] objs = new Object[tp.getPathCount()];
1884
+ for (int i=0; i<objs.length; i++)
1885
+ {
1886
+ objs[i] = ((Object3D)tp.getPathComponent(i)).GetUUID();
1887
+ }
1888
+ path = new TreePath(objs);
17291889 }
17301890
17311891 public synchronized DataFlavor[] getTransferDataFlavors() {
....@@ -2015,7 +2175,11 @@
20152175 shadow.material = new cMaterial(obj.material);
20162176 shadow.material.diffuse = 0.0001f;
20172177 shadow.material.specular = 0.0001f;
2018
- //shadow.projectedVertices[1].x = 300;
2178
+ shadow.material.opacity = 0.75f;
2179
+
2180
+ AllocProjectedVertices(shadow);
2181
+
2182
+ shadow.projectedVertices[1].x = 300;
20192183
20202184 makeSomething(shadow);
20212185 }
....@@ -2536,27 +2700,35 @@
25362700 } else
25372701 if (source == loopItem || source == loopButton)
25382702 {
2703
+ if (!group.selection.isEmpty())
2704
+ {
25392705 Composite csg = new GroupLeaf();
25402706 csg.count = 5;
2541
- group(csg);
25422707 Composite child = new cGroup("Branch");
25432708 csg.addChild(child);
25442709 child.addChild(csg);
2710
+ group(csg);
2711
+ }
25452712 } else
25462713 if (source == doubleItem)
25472714 {
2715
+ if (!group.selection.isEmpty())
2716
+ {
25482717 Composite csg = new GroupLeaf("Fork");
25492718 csg.count = 5;
2550
- group(csg);
25512719 Composite child = new cGroup("Branch A");
25522720 csg.addChild(child);
25532721 child.addChild(csg);
25542722 child = new cGroup("Branch B");
25552723 csg.addChild(child);
25562724 child.addChild(csg);
2725
+ group(csg);
2726
+ }
25572727 } else
25582728 if (source == tripleItem)
25592729 {
2730
+ if (!group.selection.isEmpty())
2731
+ {
25602732 Composite csg = new GroupLeaf("Trident");
25612733 csg.count = 4;
25622734 group(csg);
....@@ -2569,6 +2741,7 @@
25692741 child = new cGroup();
25702742 csg.addChild(child);
25712743 child.addChild(csg);
2744
+ }
25722745 } else
25732746 if (source == computeAOItem)
25742747 {
....@@ -2618,6 +2791,18 @@
26182791 if (source == fullButton)
26192792 {
26202793 ToggleFullScreen();
2794
+ } else
2795
+ if (source == collapseButton)
2796
+ {
2797
+ this.expandedLayout = radio.layout;
2798
+ CollapseToolbar();
2799
+ } else
2800
+ if (source == maximize3DButton)
2801
+ {
2802
+ this.expandedLayout = radio.layout;
2803
+ radio.layout = twoButton;
2804
+ Show3DView();
2805
+ CollapseToolbar();
26212806 } else
26222807 if (source == previousVersionButton)
26232808 {
....@@ -3192,22 +3377,34 @@
31923377 } else
31933378 if (source == ungroupItem || source == ungroupButton)
31943379 {
3195
- boolean hasRoot = false;
3380
+ boolean canUngroup = true;
31963381
31973382 for (int i=0; i<group.selection.size(); i++)
31983383 {
3199
- if (group.selection.get(i) == group)
3384
+ Object3D selectedItem = group.selection.get(i);
3385
+
3386
+ if (selectedItem.Size() == 0)
32003387 {
3201
- hasRoot = true;
3388
+ // Cannot ungroup leaves
3389
+ canUngroup = false;
3390
+ break;
3391
+ }
3392
+
3393
+ if (selectedItem == group)
3394
+ {
3395
+ // Cannot ungroup root
3396
+ canUngroup = false;
32023397 break;
32033398 }
32043399 }
32053400
3206
- if (!hasRoot)
3401
+ if (canUngroup)
32073402 {
32083403 for (int i=0; i<group.selection.size(); i++)
32093404 {
3210
- Ungroup(group.selection.get(i));
3405
+ Object3D selectedItem = group.selection.get(i);
3406
+
3407
+ Ungroup(selectedItem);
32113408 }
32123409
32133410 ClearSelection(false);
....@@ -3570,38 +3767,7 @@
35703767 if (CameraPane.FULLSCREEN)
35713768 fullscreenLayout = radio.layout;
35723769
3573
- // bug
3574
- //gridPanel.setDividerLocation(1.0);
3575
- //bigPanel.setDividerLocation(0.0);
3576
-// bigThree.remove(scenePanel);
3577
-// bigThree.remove(centralPanel);
3578
-// bigThree.remove(XYZPanel);
3579
-// aWindowConstraints.gridx = 0;
3580
-// aWindowConstraints.gridy = 0;
3581
-// aWindowConstraints.gridwidth = 1;
3582
-// // aConstraints.gridheight = 3;
3583
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3584
-// aWindowConstraints.weightx = 0;
3585
-// aWindowConstraints.weighty = 1;
3586
-// //bigThree.add(jtp, aWindowConstraints);
3587
-// aWindowConstraints.weightx = 1;
3588
-// aWindowConstraints.gridwidth = 3;
3589
-// // aConstraints.gridheight = 3;
3590
-// aWindowConstraints.gridx = 1;
3591
-// aWindowConstraints.fill = GridBagConstraints.BOTH;
3592
-// bigThree.add(centralPanel, aWindowConstraints);
3593
-// aWindowConstraints.weightx = 0;
3594
-// aWindowConstraints.gridx = 4;
3595
-// aWindowConstraints.gridwidth = 1;
3596
-// // aConstraints.gridheight = 3;
3597
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3598
-// //bigThree.add(XYZPanel, aWindowConstraints);
3599
-// scenePanel.setVisible(false);
3600
-// centralPanel.setVisible(true);
3601
-// XYZPanel.setVisible(false);
3602
- bigThree.ClearUI();
3603
- bigThree.add(centralPanel);
3604
- bigThree.FlushUI();
3770
+ Show3DView();
36053771
36063772 cameraView.requestFocusInWindow();
36073773
....@@ -3787,6 +3953,7 @@
37873953 } else
37883954 if (source == rootButton)
37893955 {
3956
+ Replace();
37903957 Object3D obj;
37913958 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
37923959 {
....@@ -3923,8 +4090,6 @@
39234090
39244091 copy = group;
39254092
3926
- SetUndoStates();
3927
-
39284093 //Globals.theRenderer.object = group;
39294094 if(!useclient)
39304095 {
....@@ -3952,6 +4117,21 @@
39524117 */
39534118 radio.layout.doClick();
39544119
4120
+ assert(copy instanceof Composite);
4121
+
4122
+ if (copy.versionlist == null)
4123
+ {
4124
+ copy.versionlist = new Object3D[100];
4125
+ copy.versionindex = -1;
4126
+
4127
+ // Cannot work with loops
4128
+ // To fix this issue, first mark all nodes above the root,
4129
+ // and check if any of these nodes are reachable below the root.
4130
+ //Save(true);
4131
+ }
4132
+
4133
+ SetVersionStates();
4134
+
39554135 ClearUnpinned();
39564136
39574137 //Grafreed.Assert(group != null);
....@@ -5182,15 +5362,30 @@
51825362 {
51835363 editButton.setEnabled(enabled);
51845364 uneditButton.setEnabled(enabled);
5185
- unselectButton.setEnabled(enabled);
5365
+ //unselectButton.setEnabled(enabled);
51865366 flashSelectionButton.setEnabled(enabled);
51875367
51885368 clearPanelButton.setEnabled(!listUI.isEmpty());
5369
+
5370
+ boolean allComposites = true;
5371
+
5372
+ if (group.selection != null)
5373
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
5374
+ {
5375
+ Object next = e.nextElement();
5376
+ if (!(next instanceof Composite)) // || (next instanceof GroupLeaf))
5377
+ {
5378
+ allComposites = false;
5379
+ break;
5380
+ }
5381
+ }
5382
+
5383
+ rootButton.setEnabled(allComposites);
51895384 }
51905385
51915386 void refreshContents(boolean cp)
51925387 {
5193
- if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
5388
+ //if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
51945389 if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
51955390 {
51965391 objEditor.ClearInfo(); // .GetMaterial());
....@@ -5200,7 +5395,7 @@
52005395 Object3D child = (Object3D) group.selection.get(i);
52015396
52025397 objEditor.AddInfo(child, this, true);
5203
- System.err.println("info : " + child.GetPath());
5398
+// System.err.println("info : " + child.GetPath());
52045399 }
52055400
52065401 objEditor.SetText(); // jan 2014
....@@ -6083,11 +6278,11 @@
60836278 private MenuItem lookAtItem;
60846279 private MenuItem lookFromItem;
60856280 private MenuItem switchViewItem;
6086
- private MenuItem cutItem;
6281
+ private JMenuItem cutItem;
60876282 private MenuItem undoItem;
60886283 private MenuItem redoItem;
60896284 private JMenuItem duplicateItem;
6090
- private MenuItem cloneItem;
6285
+ private JMenuItem cloneItem;
60916286 private MenuItem cloneSupportItem;
60926287 private MenuItem overwriteGeoItem;
60936288 private MenuItem overwriteMatItem;
....@@ -6108,13 +6303,13 @@
61086303 private MenuItem cloneGeometriesItem;
61096304 private MenuItem shareGeometriesItem;
61106305 private MenuItem mergeGeometriesItem;
6111
- private MenuItem copyItem;
6306
+ private JMenuItem copyItem;
61126307 private MenuItem pasteItem;
6113
- private MenuItem pasteIntoItem;
6114
- private MenuItem pasteLinkItem;
6115
- private MenuItem pasteCloneItem;
6116
- private MenuItem pasteExpandItem;
6117
- private MenuItem deleteItem;
6308
+ private JMenuItem pasteIntoItem;
6309
+ private JMenuItem pasteLinkItem;
6310
+ private JMenuItem pasteCloneItem;
6311
+ private JMenuItem pasteExpandItem;
6312
+ private JMenuItem deleteItem;
61186313 private MenuItem clearAllItem;
61196314 private MenuItem genUVItem;
61206315 private MenuItem genNormalsMESHItem;
....@@ -6169,7 +6364,7 @@
61696364 private MenuItem transformGeometryItem;
61706365 private MenuItem transformChildrenItem;
61716366 private MenuItem hideItem;
6172
- private MenuItem grabItem;
6367
+ private JMenuItem grabItem;
61736368 private MenuItem backItem;
61746369 private MenuItem frontItem;
61756370 private MenuItem cameraItem;
....@@ -6182,7 +6377,7 @@
61826377 private MenuItem switchTransfoItem;
61836378 private MenuItem morphItem;
61846379 private MenuItem linkerItem;
6185
- private MenuItem ungroupItem;
6380
+ private JMenuItem ungroupItem;
61866381 private MenuItem editItem;
61876382 private MenuItem openWindowItem;
61886383 private MenuItem editLeafItem;