Normand Briere
2019-08-16 64e20f390e4b8e58bd0006dde8fa10fba1dac1d5
GroupEditor.java
....@@ -540,33 +540,35 @@
540540 // menu.add("-");
541541 duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate"));
542542 duplicateItem.addActionListener(this);
543
- cloneItem = menu.add(new MenuItem("Clone"));
543
+
544
+ cloneItem = oe.jTree.popup.add(new JMenuItem("Clone"));
544545 cloneItem.addActionListener(this);
545
- if (Globals.ADVANCED)
546
+ //if (Globals.ADVANCED)
546547 {
547548 cloneSupportItem = menu.add(new MenuItem("Clone (+supports)"));
548549 cloneSupportItem.addActionListener(this);
549550 }
551
+ oe.jTree.popup.addSeparator();
550552 menu.add("-");
551
- cutItem = menu.add(new MenuItem("Cut"));
553
+ cutItem = oe.jTree.popup.add(new JMenuItem("Cut"));
552554 cutItem.addActionListener(this);
553
- copyItem = menu.add(new MenuItem("Copy"));
555
+ copyItem = oe.jTree.popup.add(new JMenuItem("Copy"));
554556 copyItem.addActionListener(this);
555557 pasteItem = menu.add(new MenuItem("Paste"));
556558 pasteItem.addActionListener(this);
557559
558
- menu.add("-");
559
- 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"));
560563 pasteIntoItem.addActionListener(this);
561
- pasteLinkItem = menu.add(new MenuItem("Paste link"));
564
+ pasteLinkItem = oe.jTree.popup.add(new JMenuItem("Paste link"));
562565 pasteLinkItem.addActionListener(this);
563
- pasteCloneItem = menu.add(new MenuItem("Paste clone"));
566
+ pasteCloneItem = oe.jTree.popup.add(new JMenuItem("Paste clone"));
564567 pasteCloneItem.addActionListener(this);
565
-// pasteExpandItem = menu.add(new MenuItem("Paste expand"));
568
+// CRASH pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand"));
566569 // pasteExpandItem.addActionListener(this);
567
- menu.add("-");
568
- deleteItem = menu.add(new MenuItem("Delete"));
569
- deleteItem.addActionListener(this);
570
+ //menu.add("-");
571
+ oe.jTree.popup.addSeparator();
570572
571573 if (Globals.ADVANCED)
572574 {
....@@ -701,9 +703,8 @@
701703 setMasterItem.addActionListener(this);
702704 }
703705
704
- oe.menuBar.add(menu = new Menu("Group"));
705
-// grabItem = menu.add(new MenuItem("Grab"));
706
-// grabItem.addActionListener(this);
706
+ oe.menuBar.add(menu = new Menu("Order"));
707
+
707708 backItem = menu.add(new MenuItem("Back"));
708709 backItem.addActionListener(this);
709710 frontItem = menu.add(new MenuItem("Front"));
....@@ -711,13 +712,21 @@
711712 // compositeItem = menu.add(new MenuItem("Composite"));
712713 // compositeItem.addActionListener(this);
713714
715
+ grabItem = oe.jTree.popup.add(new JMenuItem("Group"));
716
+ grabItem.addActionListener(this);
717
+
714718 if (Globals.ADVANCED)
715719 {
716720 hideItem = menu.add(new MenuItem("Hidden Group"));
717721 hideItem.addActionListener(this);
718722 }
719
- ungroupItem = menu.add(new MenuItem("Ungroup"));
723
+ ungroupItem = oe.jTree.popup.add(new JMenuItem("Ungroup"));
720724 ungroupItem.addActionListener(this);
725
+
726
+ oe.jTree.popup.addSeparator();
727
+
728
+ deleteItem = oe.jTree.popup.add(new JMenuItem("Delete"));
729
+ deleteItem.addActionListener(this);
721730
722731 // menu.add("-");
723732 //
....@@ -923,7 +932,7 @@
923932
924933 JTabbedPane resourcecontainer;
925934 cGridBag currenttab;
926
- boolean added; // patch for jar
935
+ //boolean added; // patch for jar
927936
928937 int tabcount = 0;
929938 int colcount = 0;
....@@ -940,12 +949,14 @@
940949 // System.out.println();
941950
942951 if (//rowcount == 0 ||
943
- path.length == 1)
952
+ path.length == 1 && !path[0].equals("") && !path[0].equals(".DS_Store"))
944953 {
945954 currenttab = new cGridBag();
946
- added = false;
947955 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
948956 currenttab.setName(tabname);
957
+ //added = false;
958
+ resourcecontainer.add(currenttab);
959
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
949960 rowcount = 1;
950961 colcount = 0;
951962 texturecount = 0;
....@@ -953,12 +964,11 @@
953964
954965 if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
955966 {
956
- if (!added)
967
+ //if (!added)
957968 {
958
- added = true;
959
- resourcecontainer.add(currenttab);
969
+ //added = true;
960970 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
961
- resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
971
+ currenttab = (cGridBag)resourcecontainer.getComponentAt(resourcecontainer.indexOfTab(tabname));
962972 }
963973
964974 AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
....@@ -1043,8 +1053,8 @@
10431053 // maxButton.addActionListener(this);
10441054 }
10451055
1046
-// cButton gcButton;
1047
-//
1056
+ cButton gcButton;
1057
+
10481058 // oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10491059 // gcButton.setToolTipText("Garbage collect");
10501060 // gcButton.addActionListener(new ActionListener()
....@@ -1059,7 +1069,7 @@
10591069 collapseButton.setToolTipText("Collapse toolbar");
10601070 collapseButton.addActionListener(this);
10611071
1062
- oe.toolbarPanel.add(maximize3DButton = GetButton("", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1072
+ oe.toolbarPanel.add(maximize3DButton = GetButton("icons/empty.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10631073 maximize3DButton.setToolTipText("Maximize 3D view");
10641074 maximize3DButton.addActionListener(this);
10651075
....@@ -1181,6 +1191,10 @@
11811191 boxButton.setToolTipText("Create box");
11821192 boxButton.addActionListener(this);
11831193
1194
+ row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1195
+ superButton.setToolTipText("Create superellipsoid");
1196
+ superButton.addActionListener(this);
1197
+
11841198 row1.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11851199 sphereButton.setToolTipText("Create sphere");
11861200 sphereButton.addActionListener(this);
....@@ -1192,10 +1206,6 @@
11921206 row1.add(torusButton = GetButton("icons/torus.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11931207 torusButton.setToolTipText("Create torus");
11941208 torusButton.addActionListener(this);
1195
-
1196
- row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1197
- superButton.setToolTipText("Create superellipsoid");
1198
- superButton.addActionListener(this);
11991209
12001210 if (Globals.ADVANCED)
12011211 {
....@@ -1498,6 +1508,7 @@
14981508
14991509 oe.SetupViews();
15001510
1511
+ if (Globals.DEBUG)
15011512 System.out.println("SetupViews");
15021513 DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(
15031514 oe.cameraView, DnDConstants.ACTION_COPY_OR_MOVE, this); // ACTION_LINK ??
....@@ -2159,7 +2170,11 @@
21592170 shadow.material = new cMaterial(obj.material);
21602171 shadow.material.diffuse = 0.0001f;
21612172 shadow.material.specular = 0.0001f;
2162
- //shadow.projectedVertices[1].x = 300;
2173
+ shadow.material.opacity = 0.75f;
2174
+
2175
+ AllocProjectedVertices(shadow);
2176
+
2177
+ shadow.projectedVertices[1].x = 300;
21632178
21642179 makeSomething(shadow);
21652180 }
....@@ -2680,27 +2695,35 @@
26802695 } else
26812696 if (source == loopItem || source == loopButton)
26822697 {
2698
+ if (!group.selection.isEmpty())
2699
+ {
26832700 Composite csg = new GroupLeaf();
26842701 csg.count = 5;
2685
- group(csg);
26862702 Composite child = new cGroup("Branch");
26872703 csg.addChild(child);
26882704 child.addChild(csg);
2705
+ group(csg);
2706
+ }
26892707 } else
26902708 if (source == doubleItem)
26912709 {
2710
+ if (!group.selection.isEmpty())
2711
+ {
26922712 Composite csg = new GroupLeaf("Fork");
26932713 csg.count = 5;
2694
- group(csg);
26952714 Composite child = new cGroup("Branch A");
26962715 csg.addChild(child);
26972716 child.addChild(csg);
26982717 child = new cGroup("Branch B");
26992718 csg.addChild(child);
27002719 child.addChild(csg);
2720
+ group(csg);
2721
+ }
27012722 } else
27022723 if (source == tripleItem)
27032724 {
2725
+ if (!group.selection.isEmpty())
2726
+ {
27042727 Composite csg = new GroupLeaf("Trident");
27052728 csg.count = 4;
27062729 group(csg);
....@@ -2713,6 +2736,7 @@
27132736 child = new cGroup();
27142737 csg.addChild(child);
27152738 child.addChild(csg);
2739
+ }
27162740 } else
27172741 if (source == computeAOItem)
27182742 {
....@@ -3348,22 +3372,34 @@
33483372 } else
33493373 if (source == ungroupItem || source == ungroupButton)
33503374 {
3351
- boolean hasRoot = false;
3375
+ boolean canUngroup = true;
33523376
33533377 for (int i=0; i<group.selection.size(); i++)
33543378 {
3355
- if (group.selection.get(i) == group)
3379
+ Object3D selectedItem = group.selection.get(i);
3380
+
3381
+ if (selectedItem.Size() == 0)
33563382 {
3357
- hasRoot = true;
3383
+ // Cannot ungroup leaves
3384
+ canUngroup = false;
3385
+ break;
3386
+ }
3387
+
3388
+ if (selectedItem == group)
3389
+ {
3390
+ // Cannot ungroup root
3391
+ canUngroup = false;
33583392 break;
33593393 }
33603394 }
33613395
3362
- if (!hasRoot)
3396
+ if (canUngroup)
33633397 {
33643398 for (int i=0; i<group.selection.size(); i++)
33653399 {
3366
- Ungroup(group.selection.get(i));
3400
+ Object3D selectedItem = group.selection.get(i);
3401
+
3402
+ Ungroup(selectedItem);
33673403 }
33683404
33693405 ClearSelection(false);
....@@ -4083,7 +4119,10 @@
40834119 copy.versionlist = new Object3D[100];
40844120 copy.versionindex = -1;
40854121
4086
- Save(true);
4122
+ // Cannot work with loops
4123
+ // To fix this issue, first mark all nodes above the root,
4124
+ // and check if any of these nodes are reachable below the root.
4125
+ //Save(true);
40874126 }
40884127
40894128 SetVersionStates();
....@@ -5325,9 +5364,11 @@
53255364
53265365 boolean allComposites = true;
53275366
5367
+ if (group.selection != null)
53285368 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
53295369 {
5330
- if (!(e.nextElement() instanceof Composite))
5370
+ Object next = e.nextElement();
5371
+ if (!(next instanceof Composite)) // || (next instanceof GroupLeaf))
53315372 {
53325373 allComposites = false;
53335374 break;
....@@ -6232,11 +6273,11 @@
62326273 private MenuItem lookAtItem;
62336274 private MenuItem lookFromItem;
62346275 private MenuItem switchViewItem;
6235
- private MenuItem cutItem;
6276
+ private JMenuItem cutItem;
62366277 private MenuItem undoItem;
62376278 private MenuItem redoItem;
62386279 private JMenuItem duplicateItem;
6239
- private MenuItem cloneItem;
6280
+ private JMenuItem cloneItem;
62406281 private MenuItem cloneSupportItem;
62416282 private MenuItem overwriteGeoItem;
62426283 private MenuItem overwriteMatItem;
....@@ -6257,13 +6298,13 @@
62576298 private MenuItem cloneGeometriesItem;
62586299 private MenuItem shareGeometriesItem;
62596300 private MenuItem mergeGeometriesItem;
6260
- private MenuItem copyItem;
6301
+ private JMenuItem copyItem;
62616302 private MenuItem pasteItem;
6262
- private MenuItem pasteIntoItem;
6263
- private MenuItem pasteLinkItem;
6264
- private MenuItem pasteCloneItem;
6265
- private MenuItem pasteExpandItem;
6266
- private MenuItem deleteItem;
6303
+ private JMenuItem pasteIntoItem;
6304
+ private JMenuItem pasteLinkItem;
6305
+ private JMenuItem pasteCloneItem;
6306
+ private JMenuItem pasteExpandItem;
6307
+ private JMenuItem deleteItem;
62676308 private MenuItem clearAllItem;
62686309 private MenuItem genUVItem;
62696310 private MenuItem genNormalsMESHItem;
....@@ -6318,7 +6359,7 @@
63186359 private MenuItem transformGeometryItem;
63196360 private MenuItem transformChildrenItem;
63206361 private MenuItem hideItem;
6321
- private MenuItem grabItem;
6362
+ private JMenuItem grabItem;
63226363 private MenuItem backItem;
63236364 private MenuItem frontItem;
63246365 private MenuItem cameraItem;
....@@ -6331,7 +6372,7 @@
63316372 private MenuItem switchTransfoItem;
63326373 private MenuItem morphItem;
63336374 private MenuItem linkerItem;
6334
- private MenuItem ungroupItem;
6375
+ private JMenuItem ungroupItem;
63356376 private MenuItem editItem;
63366377 private MenuItem openWindowItem;
63376378 private MenuItem editLeafItem;