Normand Briere
2019-08-15 7f97054d681518416a4ee1c1548ad42cfb489a8f
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)
....@@ -357,6 +366,16 @@
357366 }
358367
359368 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();
360379 }
361380
362381 //ObjEditor objEditor;
....@@ -400,6 +419,8 @@
400419 {
401420 copy.versionlist = new Object3D[100];
402421 copy.versionindex = -1;
422
+
423
+ Save(true);
403424 }
404425
405426 if(ui)
....@@ -519,32 +540,37 @@
519540 // menu.add("-");
520541 duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate"));
521542 duplicateItem.addActionListener(this);
522
- cloneItem = menu.add(new MenuItem("Clone"));
543
+
544
+ cloneItem = oe.jTree.popup.add(new JMenuItem("Clone"));
523545 cloneItem.addActionListener(this);
524
- if (Globals.ADVANCED)
546
+ //if (Globals.ADVANCED)
525547 {
526548 cloneSupportItem = menu.add(new MenuItem("Clone (+supports)"));
527549 cloneSupportItem.addActionListener(this);
528550 }
551
+ oe.jTree.popup.addSeparator();
529552 menu.add("-");
530
- cutItem = menu.add(new MenuItem("Cut"));
553
+ cutItem = oe.jTree.popup.add(new JMenuItem("Cut"));
531554 cutItem.addActionListener(this);
532
- copyItem = menu.add(new MenuItem("Copy"));
555
+ copyItem = oe.jTree.popup.add(new JMenuItem("Copy"));
533556 copyItem.addActionListener(this);
534557 pasteItem = menu.add(new MenuItem("Paste"));
535558 pasteItem.addActionListener(this);
536559
537
- menu.add("-");
538
- 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"));
539563 pasteIntoItem.addActionListener(this);
540
- pasteLinkItem = menu.add(new MenuItem("Paste link"));
564
+ pasteLinkItem = oe.jTree.popup.add(new JMenuItem("Paste link"));
541565 pasteLinkItem.addActionListener(this);
542
- pasteCloneItem = menu.add(new MenuItem("Paste clone"));
566
+ pasteCloneItem = oe.jTree.popup.add(new JMenuItem("Paste clone"));
543567 pasteCloneItem.addActionListener(this);
544
-// pasteExpandItem = menu.add(new MenuItem("Paste expand"));
568
+// CRASH pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand"));
545569 // pasteExpandItem.addActionListener(this);
546
- menu.add("-");
547
- deleteItem = menu.add(new MenuItem("Delete"));
570
+ //menu.add("-");
571
+ oe.jTree.popup.addSeparator();
572
+
573
+ deleteItem = oe.jTree.popup.add(new JMenuItem("Delete"));
548574 deleteItem.addActionListener(this);
549575
550576 if (Globals.ADVANCED)
....@@ -631,11 +657,9 @@
631657 oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest"));
632658 //cameraMenu.add(lookFromItem = new MenuItem("Look From Selection"));
633659 //cameraMenu.add(switchViewItem = new MenuItem("Reverse View"));
634
- editLeafItem = oe.cameraMenu.add(new MenuItem("Edit Leaf"));
635660 oe.cameraMenu.add("-");
636661 openWindowItem = oe.cameraMenu.add(new MenuItem("Edit copy..."));
637662 openWindowItem.addActionListener(this);
638
- editLeafItem.addActionListener(this);
639663 lookAtItem.addActionListener(this);
640664 //lookFromItem.addActinoListener(this);
641665 //switchViewItem.addActionListener(this);
....@@ -697,7 +721,7 @@
697721 hideItem = menu.add(new MenuItem("Hidden Group"));
698722 hideItem.addActionListener(this);
699723 }
700
- ungroupItem = menu.add(new MenuItem("Ungroup"));
724
+ ungroupItem = oe.jTree.popup.add(new JMenuItem("Ungroup"));
701725 ungroupItem.addActionListener(this);
702726
703727 // menu.add("-");
....@@ -883,6 +907,9 @@
883907 shareGeometriesItem.addActionListener(this);
884908 mergeGeometriesItem = menu.add(new MenuItem("Merge Geometries"));
885909 mergeGeometriesItem.addActionListener(this);
910
+ menu.add("-");
911
+ editLeafItem = menu.add(new MenuItem("Edit leaf..."));
912
+ editLeafItem.addActionListener(this);
886913 if (Globals.ADVANCED)
887914 {
888915 // Pretty much the same as duplicate and clone.
....@@ -913,9 +940,9 @@
913940
914941 public void ResourceCallBack(String[] path)
915942 {
916
-// for (int i = 0; i < path.length; i++)
917
-// System.out.print(path[i] + "/");
918
-// System.out.println();
943
+ for (int i = 0; i < path.length; i++)
944
+ System.out.print(path[i] + "/");
945
+ System.out.println();
919946
920947 if (//rowcount == 0 ||
921948 path.length == 1)
....@@ -984,11 +1011,6 @@
9841011 //new Exception().printStackTrace();
9851012
9861013 oe.radioPanel = new JPanel(new GridBagLayout());
987
- oe.aConstraints.weightx = 1;
988
- oe.aConstraints.weighty = 0;
989
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
990
- oe.aConstraints.gridwidth = 100;
991
- oe.aConstraints.gridheight = 1;
9921014 // oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
9931015
9941016 oe.buttonGroup = new ButtonGroup();
....@@ -1021,10 +1043,49 @@
10211043
10221044 if (Globals.ADVANCED)
10231045 {
1024
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1025
- maxButton.setToolTipText("Maximize window");
1026
- 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);
10271049 }
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
+ //
10281089
10291090 oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10301091 fullButton.setToolTipText("Full-screen window");
....@@ -1069,14 +1130,14 @@
10691130 nextVersionButton.addActionListener(this);
10701131 nextVersionButton.setEnabled(false);
10711132
1072
- oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
1073
- liveCB.setToolTipText("Enable animation");
1074
- liveCB.addItemListener(this);
1075
-
10761133 oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10771134 oneStepButton.setToolTipText("Animate one step forward");
10781135 oneStepButton.addActionListener(this);
10791136
1137
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
1138
+ liveCB.setToolTipText("Enable animation");
1139
+ liveCB.addItemListener(this);
1140
+
10801141 oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
10811142 fastCB.setToolTipText("Fast mode");
10821143 fastCB.addItemListener(this);
....@@ -1103,21 +1164,6 @@
11031164
11041165 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
11051166
1106
- oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1107
- twoButton.setToolTipText("Show 3D view only");
1108
- twoButton.addActionListener(this);
1109
- this.fullscreenLayout = twoButton;
1110
-
1111
- oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1112
- threeButton.setToolTipText("Show controls and 3D view");
1113
- threeButton.addActionListener(this);
1114
- oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1115
- sixButton.setToolTipText("Show 3D view and controls");
1116
- sixButton.addActionListener(this);
1117
-// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1118
-// sevenButton.setToolTipText("3-column layout");
1119
-// sevenButton.addActionListener(this);
1120
- //
11211167
11221168 oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11231169 rootButton.setToolTipText("Open selection in new tab");
....@@ -1133,7 +1179,7 @@
11331179
11341180 // INSERT
11351181 row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1136
- gridButton.setToolTipText("Create grid");
1182
+ gridButton.setToolTipText("Create ground");
11371183 gridButton.addActionListener(this);
11381184
11391185 row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1425,6 +1471,14 @@
14251471
14261472 void EditObject(Object3D obj)
14271473 {
1474
+ assert(obj instanceof Composite);
1475
+
1476
+// if (obj.versionlist == null)
1477
+// {
1478
+// obj.versionlist = new Object3D[100];
1479
+// obj.versionindex = -1;
1480
+// }
1481
+
14281482 cRadio radioButton = new cRadio(obj.name);
14291483
14301484 // June 2019. Patch to avoid bug with transparency.
....@@ -1815,7 +1869,12 @@
18151869 TreePath path;
18161870
18171871 public TransferableTreePath(TreePath tp) {
1818
- 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);
18191878 }
18201879
18211880 public synchronized DataFlavor[] getTransferDataFlavors() {
....@@ -2626,27 +2685,35 @@
26262685 } else
26272686 if (source == loopItem || source == loopButton)
26282687 {
2688
+ if (!group.selection.isEmpty())
2689
+ {
26292690 Composite csg = new GroupLeaf();
26302691 csg.count = 5;
2631
- group(csg);
26322692 Composite child = new cGroup("Branch");
26332693 csg.addChild(child);
26342694 child.addChild(csg);
2695
+ group(csg);
2696
+ }
26352697 } else
26362698 if (source == doubleItem)
26372699 {
2700
+ if (!group.selection.isEmpty())
2701
+ {
26382702 Composite csg = new GroupLeaf("Fork");
26392703 csg.count = 5;
2640
- group(csg);
26412704 Composite child = new cGroup("Branch A");
26422705 csg.addChild(child);
26432706 child.addChild(csg);
26442707 child = new cGroup("Branch B");
26452708 csg.addChild(child);
26462709 child.addChild(csg);
2710
+ group(csg);
2711
+ }
26472712 } else
26482713 if (source == tripleItem)
26492714 {
2715
+ if (!group.selection.isEmpty())
2716
+ {
26502717 Composite csg = new GroupLeaf("Trident");
26512718 csg.count = 4;
26522719 group(csg);
....@@ -2659,6 +2726,7 @@
26592726 child = new cGroup();
26602727 csg.addChild(child);
26612728 child.addChild(csg);
2729
+ }
26622730 } else
26632731 if (source == computeAOItem)
26642732 {
....@@ -2708,6 +2776,18 @@
27082776 if (source == fullButton)
27092777 {
27102778 ToggleFullScreen();
2779
+ } else
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();
27112791 } else
27122792 if (source == previousVersionButton)
27132793 {
....@@ -3282,22 +3362,34 @@
32823362 } else
32833363 if (source == ungroupItem || source == ungroupButton)
32843364 {
3285
- boolean hasRoot = false;
3365
+ boolean canUngroup = true;
32863366
32873367 for (int i=0; i<group.selection.size(); i++)
32883368 {
3289
- if (group.selection.get(i) == group)
3369
+ Object3D selectedItem = group.selection.get(i);
3370
+
3371
+ if (selectedItem.Size() == 0)
32903372 {
3291
- 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;
32923382 break;
32933383 }
32943384 }
32953385
3296
- if (!hasRoot)
3386
+ if (canUngroup)
32973387 {
32983388 for (int i=0; i<group.selection.size(); i++)
32993389 {
3300
- Ungroup(group.selection.get(i));
3390
+ Object3D selectedItem = group.selection.get(i);
3391
+
3392
+ Ungroup(selectedItem);
33013393 }
33023394
33033395 ClearSelection(false);
....@@ -3660,38 +3752,7 @@
36603752 if (CameraPane.FULLSCREEN)
36613753 fullscreenLayout = radio.layout;
36623754
3663
- // bug
3664
- //gridPanel.setDividerLocation(1.0);
3665
- //bigPanel.setDividerLocation(0.0);
3666
-// bigThree.remove(scenePanel);
3667
-// bigThree.remove(centralPanel);
3668
-// bigThree.remove(XYZPanel);
3669
-// aWindowConstraints.gridx = 0;
3670
-// aWindowConstraints.gridy = 0;
3671
-// aWindowConstraints.gridwidth = 1;
3672
-// // aConstraints.gridheight = 3;
3673
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3674
-// aWindowConstraints.weightx = 0;
3675
-// aWindowConstraints.weighty = 1;
3676
-// //bigThree.add(jtp, aWindowConstraints);
3677
-// aWindowConstraints.weightx = 1;
3678
-// aWindowConstraints.gridwidth = 3;
3679
-// // aConstraints.gridheight = 3;
3680
-// aWindowConstraints.gridx = 1;
3681
-// aWindowConstraints.fill = GridBagConstraints.BOTH;
3682
-// bigThree.add(centralPanel, aWindowConstraints);
3683
-// aWindowConstraints.weightx = 0;
3684
-// aWindowConstraints.gridx = 4;
3685
-// aWindowConstraints.gridwidth = 1;
3686
-// // aConstraints.gridheight = 3;
3687
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3688
-// //bigThree.add(XYZPanel, aWindowConstraints);
3689
-// scenePanel.setVisible(false);
3690
-// centralPanel.setVisible(true);
3691
-// XYZPanel.setVisible(false);
3692
- bigThree.ClearUI();
3693
- bigThree.add(centralPanel);
3694
- bigThree.FlushUI();
3755
+ Show3DView();
36953756
36963757 cameraView.requestFocusInWindow();
36973758
....@@ -3877,6 +3938,7 @@
38773938 } else
38783939 if (source == rootButton)
38793940 {
3941
+ Replace();
38803942 Object3D obj;
38813943 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
38823944 {
....@@ -4013,8 +4075,6 @@
40134075
40144076 copy = group;
40154077
4016
- SetUndoStates();
4017
-
40184078 //Globals.theRenderer.object = group;
40194079 if(!useclient)
40204080 {
....@@ -4042,6 +4102,18 @@
40424102 */
40434103 radio.layout.doClick();
40444104
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
+
40454117 ClearUnpinned();
40464118
40474119 //Grafreed.Assert(group != null);
....@@ -5276,6 +5348,20 @@
52765348 flashSelectionButton.setEnabled(enabled);
52775349
52785350 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);
52795365 }
52805366
52815367 void refreshContents(boolean cp)
....@@ -5290,7 +5376,7 @@
52905376 Object3D child = (Object3D) group.selection.get(i);
52915377
52925378 objEditor.AddInfo(child, this, true);
5293
- System.err.println("info : " + child.GetPath());
5379
+// System.err.println("info : " + child.GetPath());
52945380 }
52955381
52965382 objEditor.SetText(); // jan 2014
....@@ -6173,11 +6259,11 @@
61736259 private MenuItem lookAtItem;
61746260 private MenuItem lookFromItem;
61756261 private MenuItem switchViewItem;
6176
- private MenuItem cutItem;
6262
+ private JMenuItem cutItem;
61776263 private MenuItem undoItem;
61786264 private MenuItem redoItem;
61796265 private JMenuItem duplicateItem;
6180
- private MenuItem cloneItem;
6266
+ private JMenuItem cloneItem;
61816267 private MenuItem cloneSupportItem;
61826268 private MenuItem overwriteGeoItem;
61836269 private MenuItem overwriteMatItem;
....@@ -6198,13 +6284,13 @@
61986284 private MenuItem cloneGeometriesItem;
61996285 private MenuItem shareGeometriesItem;
62006286 private MenuItem mergeGeometriesItem;
6201
- private MenuItem copyItem;
6287
+ private JMenuItem copyItem;
62026288 private MenuItem pasteItem;
6203
- private MenuItem pasteIntoItem;
6204
- private MenuItem pasteLinkItem;
6205
- private MenuItem pasteCloneItem;
6206
- private MenuItem pasteExpandItem;
6207
- private MenuItem deleteItem;
6289
+ private JMenuItem pasteIntoItem;
6290
+ private JMenuItem pasteLinkItem;
6291
+ private JMenuItem pasteCloneItem;
6292
+ private JMenuItem pasteExpandItem;
6293
+ private JMenuItem deleteItem;
62086294 private MenuItem clearAllItem;
62096295 private MenuItem genUVItem;
62106296 private MenuItem genNormalsMESHItem;
....@@ -6272,7 +6358,7 @@
62726358 private MenuItem switchTransfoItem;
62736359 private MenuItem morphItem;
62746360 private MenuItem linkerItem;
6275
- private MenuItem ungroupItem;
6361
+ private JMenuItem ungroupItem;
62766362 private MenuItem editItem;
62776363 private MenuItem openWindowItem;
62786364 private MenuItem editLeafItem;