Normand Briere
2019-08-15 24a2a946b35279605e645349bd6b82e9e60aac88
GroupEditor.java
....@@ -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
....@@ -73,7 +73,7 @@
7373 cGridBag row5 = new cGridBag();
7474 cGridBag row6 = new cGridBag();
7575
76
- AddSkyboxButton("default", "rgb", row0);
76
+ AddSkyboxButton("default", "", row0);
7777 //AddSkyboxButton("default", "cornell", row0);
7878 AddSkyboxButton("penguins", "dust", row0);
7979 AddSkyboxButton("penguins", "tropic", row0);
....@@ -330,10 +330,19 @@
330330
331331 public void ChangeSkybox(String skybox)
332332 {
333
- //cameraView.envyoff = false;
334
- group.skyboxname = skybox;
335
- group.skyboxext = "jpg";
336
- 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
+ }
337346 }
338347
339348 public void CreateSkyboxPanel(cGridBag skyboxPanel)
....@@ -410,6 +419,8 @@
410419 {
411420 copy.versionlist = new Object3D[100];
412421 copy.versionindex = -1;
422
+
423
+ Save(true);
413424 }
414425
415426 if(ui)
....@@ -529,32 +540,37 @@
529540 // menu.add("-");
530541 duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate"));
531542 duplicateItem.addActionListener(this);
532
- cloneItem = menu.add(new MenuItem("Clone"));
543
+
544
+ cloneItem = oe.jTree.popup.add(new JMenuItem("Clone"));
533545 cloneItem.addActionListener(this);
534
- if (Globals.ADVANCED)
546
+ //if (Globals.ADVANCED)
535547 {
536548 cloneSupportItem = menu.add(new MenuItem("Clone (+supports)"));
537549 cloneSupportItem.addActionListener(this);
538550 }
551
+ oe.jTree.popup.addSeparator();
539552 menu.add("-");
540
- cutItem = menu.add(new MenuItem("Cut"));
553
+ cutItem = oe.jTree.popup.add(new JMenuItem("Cut"));
541554 cutItem.addActionListener(this);
542
- copyItem = menu.add(new MenuItem("Copy"));
555
+ copyItem = oe.jTree.popup.add(new JMenuItem("Copy"));
543556 copyItem.addActionListener(this);
544557 pasteItem = menu.add(new MenuItem("Paste"));
545558 pasteItem.addActionListener(this);
546559
547
- menu.add("-");
548
- 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"));
549563 pasteIntoItem.addActionListener(this);
550
- pasteLinkItem = menu.add(new MenuItem("Paste link"));
564
+ pasteLinkItem = oe.jTree.popup.add(new JMenuItem("Paste link"));
551565 pasteLinkItem.addActionListener(this);
552
- pasteCloneItem = menu.add(new MenuItem("Paste clone"));
566
+ pasteCloneItem = oe.jTree.popup.add(new JMenuItem("Paste clone"));
553567 pasteCloneItem.addActionListener(this);
554
-// pasteExpandItem = menu.add(new MenuItem("Paste expand"));
568
+// CRASH pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand"));
555569 // pasteExpandItem.addActionListener(this);
556
- menu.add("-");
557
- deleteItem = menu.add(new MenuItem("Delete"));
570
+ //menu.add("-");
571
+ oe.jTree.popup.addSeparator();
572
+
573
+ deleteItem = oe.jTree.popup.add(new JMenuItem("Delete"));
558574 deleteItem.addActionListener(this);
559575
560576 if (Globals.ADVANCED)
....@@ -641,11 +657,9 @@
641657 oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest"));
642658 //cameraMenu.add(lookFromItem = new MenuItem("Look From Selection"));
643659 //cameraMenu.add(switchViewItem = new MenuItem("Reverse View"));
644
- editLeafItem = oe.cameraMenu.add(new MenuItem("Edit Leaf"));
645660 oe.cameraMenu.add("-");
646661 openWindowItem = oe.cameraMenu.add(new MenuItem("Edit copy..."));
647662 openWindowItem.addActionListener(this);
648
- editLeafItem.addActionListener(this);
649663 lookAtItem.addActionListener(this);
650664 //lookFromItem.addActinoListener(this);
651665 //switchViewItem.addActionListener(this);
....@@ -707,7 +721,7 @@
707721 hideItem = menu.add(new MenuItem("Hidden Group"));
708722 hideItem.addActionListener(this);
709723 }
710
- ungroupItem = menu.add(new MenuItem("Ungroup"));
724
+ ungroupItem = oe.jTree.popup.add(new JMenuItem("Ungroup"));
711725 ungroupItem.addActionListener(this);
712726
713727 // menu.add("-");
....@@ -893,6 +907,9 @@
893907 shareGeometriesItem.addActionListener(this);
894908 mergeGeometriesItem = menu.add(new MenuItem("Merge Geometries"));
895909 mergeGeometriesItem.addActionListener(this);
910
+ menu.add("-");
911
+ editLeafItem = menu.add(new MenuItem("Edit leaf..."));
912
+ editLeafItem.addActionListener(this);
896913 if (Globals.ADVANCED)
897914 {
898915 // Pretty much the same as duplicate and clone.
....@@ -911,7 +928,7 @@
911928
912929 JTabbedPane resourcecontainer;
913930 cGridBag currenttab;
914
- boolean added; // patch for jar
931
+ //boolean added; // patch for jar
915932
916933 int tabcount = 0;
917934 int colcount = 0;
....@@ -928,12 +945,14 @@
928945 // System.out.println();
929946
930947 if (//rowcount == 0 ||
931
- path.length == 1)
948
+ path.length == 1 && !path[0].equals("") && !path[0].equals(".DS_Store"))
932949 {
933950 currenttab = new cGridBag();
934
- added = false;
935951 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
936952 currenttab.setName(tabname);
953
+ //added = false;
954
+ resourcecontainer.add(currenttab);
955
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
937956 rowcount = 1;
938957 colcount = 0;
939958 texturecount = 0;
....@@ -941,12 +960,11 @@
941960
942961 if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
943962 {
944
- if (!added)
963
+ //if (!added)
945964 {
946
- added = true;
947
- resourcecontainer.add(currenttab);
965
+ //added = true;
948966 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
949
- resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
967
+ currenttab = (cGridBag)resourcecontainer.getComponentAt(resourcecontainer.indexOfTab(tabname));
950968 }
951969
952970 AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
....@@ -1026,22 +1044,22 @@
10261044
10271045 if (Globals.ADVANCED)
10281046 {
1029
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1030
- maxButton.setToolTipText("Maximize window");
1031
- maxButton.addActionListener(this);
1047
+// oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1048
+// maxButton.setToolTipText("Maximize window");
1049
+// maxButton.addActionListener(this);
10321050 }
10331051
10341052 cButton gcButton;
10351053
1036
- oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1037
- gcButton.setToolTipText("Garbage collect");
1038
- gcButton.addActionListener(new ActionListener()
1039
- {
1040
- public void actionPerformed(ActionEvent e)
1041
- {
1042
- System.gc();
1043
- }
1044
- });
1054
+// oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1055
+// gcButton.setToolTipText("Garbage collect");
1056
+// gcButton.addActionListener(new ActionListener()
1057
+// {
1058
+// public void actionPerformed(ActionEvent e)
1059
+// {
1060
+// System.gc();
1061
+// }
1062
+// });
10451063
10461064 oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10471065 collapseButton.setToolTipText("Collapse toolbar");
....@@ -1162,7 +1180,7 @@
11621180
11631181 // INSERT
11641182 row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1165
- gridButton.setToolTipText("Create grid");
1183
+ gridButton.setToolTipText("Create ground");
11661184 gridButton.addActionListener(this);
11671185
11681186 row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1454,6 +1472,14 @@
14541472
14551473 void EditObject(Object3D obj)
14561474 {
1475
+ assert(obj instanceof Composite);
1476
+
1477
+// if (obj.versionlist == null)
1478
+// {
1479
+// obj.versionlist = new Object3D[100];
1480
+// obj.versionindex = -1;
1481
+// }
1482
+
14571483 cRadio radioButton = new cRadio(obj.name);
14581484
14591485 // June 2019. Patch to avoid bug with transparency.
....@@ -2660,27 +2686,35 @@
26602686 } else
26612687 if (source == loopItem || source == loopButton)
26622688 {
2689
+ if (!group.selection.isEmpty())
2690
+ {
26632691 Composite csg = new GroupLeaf();
26642692 csg.count = 5;
2665
- group(csg);
26662693 Composite child = new cGroup("Branch");
26672694 csg.addChild(child);
26682695 child.addChild(csg);
2696
+ group(csg);
2697
+ }
26692698 } else
26702699 if (source == doubleItem)
26712700 {
2701
+ if (!group.selection.isEmpty())
2702
+ {
26722703 Composite csg = new GroupLeaf("Fork");
26732704 csg.count = 5;
2674
- group(csg);
26752705 Composite child = new cGroup("Branch A");
26762706 csg.addChild(child);
26772707 child.addChild(csg);
26782708 child = new cGroup("Branch B");
26792709 csg.addChild(child);
26802710 child.addChild(csg);
2711
+ group(csg);
2712
+ }
26812713 } else
26822714 if (source == tripleItem)
26832715 {
2716
+ if (!group.selection.isEmpty())
2717
+ {
26842718 Composite csg = new GroupLeaf("Trident");
26852719 csg.count = 4;
26862720 group(csg);
....@@ -2693,6 +2727,7 @@
26932727 child = new cGroup();
26942728 csg.addChild(child);
26952729 child.addChild(csg);
2730
+ }
26962731 } else
26972732 if (source == computeAOItem)
26982733 {
....@@ -3328,22 +3363,34 @@
33283363 } else
33293364 if (source == ungroupItem || source == ungroupButton)
33303365 {
3331
- boolean hasRoot = false;
3366
+ boolean canUngroup = true;
33323367
33333368 for (int i=0; i<group.selection.size(); i++)
33343369 {
3335
- if (group.selection.get(i) == group)
3370
+ Object3D selectedItem = group.selection.get(i);
3371
+
3372
+ if (selectedItem.Size() == 0)
33363373 {
3337
- hasRoot = true;
3374
+ // Cannot ungroup leaves
3375
+ canUngroup = false;
3376
+ break;
3377
+ }
3378
+
3379
+ if (selectedItem == group)
3380
+ {
3381
+ // Cannot ungroup root
3382
+ canUngroup = false;
33383383 break;
33393384 }
33403385 }
33413386
3342
- if (!hasRoot)
3387
+ if (canUngroup)
33433388 {
33443389 for (int i=0; i<group.selection.size(); i++)
33453390 {
3346
- Ungroup(group.selection.get(i));
3391
+ Object3D selectedItem = group.selection.get(i);
3392
+
3393
+ Ungroup(selectedItem);
33473394 }
33483395
33493396 ClearSelection(false);
....@@ -3892,6 +3939,7 @@
38923939 } else
38933940 if (source == rootButton)
38943941 {
3942
+ Replace();
38953943 Object3D obj;
38963944 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
38973945 {
....@@ -4028,8 +4076,6 @@
40284076
40294077 copy = group;
40304078
4031
- SetUndoStates();
4032
-
40334079 //Globals.theRenderer.object = group;
40344080 if(!useclient)
40354081 {
....@@ -4057,6 +4103,18 @@
40574103 */
40584104 radio.layout.doClick();
40594105
4106
+ assert(copy instanceof Composite);
4107
+
4108
+ if (copy.versionlist == null)
4109
+ {
4110
+ copy.versionlist = new Object3D[100];
4111
+ copy.versionindex = -1;
4112
+
4113
+ Save(true);
4114
+ }
4115
+
4116
+ SetVersionStates();
4117
+
40604118 ClearUnpinned();
40614119
40624120 //Grafreed.Assert(group != null);
....@@ -5291,6 +5349,20 @@
52915349 flashSelectionButton.setEnabled(enabled);
52925350
52935351 clearPanelButton.setEnabled(!listUI.isEmpty());
5352
+
5353
+ boolean allComposites = true;
5354
+
5355
+ if (group.selection != null)
5356
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
5357
+ {
5358
+ if (!(e.nextElement() instanceof Composite))
5359
+ {
5360
+ allComposites = false;
5361
+ break;
5362
+ }
5363
+ }
5364
+
5365
+ rootButton.setEnabled(allComposites);
52945366 }
52955367
52965368 void refreshContents(boolean cp)
....@@ -6188,11 +6260,11 @@
61886260 private MenuItem lookAtItem;
61896261 private MenuItem lookFromItem;
61906262 private MenuItem switchViewItem;
6191
- private MenuItem cutItem;
6263
+ private JMenuItem cutItem;
61926264 private MenuItem undoItem;
61936265 private MenuItem redoItem;
61946266 private JMenuItem duplicateItem;
6195
- private MenuItem cloneItem;
6267
+ private JMenuItem cloneItem;
61966268 private MenuItem cloneSupportItem;
61976269 private MenuItem overwriteGeoItem;
61986270 private MenuItem overwriteMatItem;
....@@ -6213,13 +6285,13 @@
62136285 private MenuItem cloneGeometriesItem;
62146286 private MenuItem shareGeometriesItem;
62156287 private MenuItem mergeGeometriesItem;
6216
- private MenuItem copyItem;
6288
+ private JMenuItem copyItem;
62176289 private MenuItem pasteItem;
6218
- private MenuItem pasteIntoItem;
6219
- private MenuItem pasteLinkItem;
6220
- private MenuItem pasteCloneItem;
6221
- private MenuItem pasteExpandItem;
6222
- private MenuItem deleteItem;
6290
+ private JMenuItem pasteIntoItem;
6291
+ private JMenuItem pasteLinkItem;
6292
+ private JMenuItem pasteCloneItem;
6293
+ private JMenuItem pasteExpandItem;
6294
+ private JMenuItem deleteItem;
62236295 private MenuItem clearAllItem;
62246296 private MenuItem genUVItem;
62256297 private MenuItem genNormalsMESHItem;
....@@ -6287,7 +6359,7 @@
62876359 private MenuItem switchTransfoItem;
62886360 private MenuItem morphItem;
62896361 private MenuItem linkerItem;
6290
- private MenuItem ungroupItem;
6362
+ private JMenuItem ungroupItem;
62916363 private MenuItem editItem;
62926364 private MenuItem openWindowItem;
62936365 private MenuItem editLeafItem;