Normand Briere
2019-08-16 83d0c2fa0bd2e96448f776144e1a89cdb1bb6998
GroupEditor.java
....@@ -415,12 +415,14 @@
415415 this.copy = this.group = group;
416416 //selectees = this.group.selectees;
417417
418
+ assert(false);
419
+
418420 if (copy.versionlist == null)
419421 {
420422 copy.versionlist = new Object3D[100];
421423 copy.versionindex = -1;
422424
423
- Save(true);
425
+ //Save(true);
424426 }
425427
426428 if(ui)
....@@ -449,7 +451,7 @@
449451 copy.versionlist = new Object3D[100];
450452 copy.versionindex = -1;
451453
452
- Save(true);
454
+ //Save(true);
453455 }
454456 }
455457
....@@ -540,33 +542,35 @@
540542 // menu.add("-");
541543 duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate"));
542544 duplicateItem.addActionListener(this);
543
- cloneItem = menu.add(new MenuItem("Clone"));
545
+
546
+ cloneItem = oe.jTree.popup.add(new JMenuItem("Clone"));
544547 cloneItem.addActionListener(this);
545
- if (Globals.ADVANCED)
548
+ //if (Globals.ADVANCED)
546549 {
547550 cloneSupportItem = menu.add(new MenuItem("Clone (+supports)"));
548551 cloneSupportItem.addActionListener(this);
549552 }
553
+ oe.jTree.popup.addSeparator();
550554 menu.add("-");
551
- cutItem = menu.add(new MenuItem("Cut"));
555
+ cutItem = oe.jTree.popup.add(new JMenuItem("Cut"));
552556 cutItem.addActionListener(this);
553
- copyItem = menu.add(new MenuItem("Copy"));
557
+ copyItem = oe.jTree.popup.add(new JMenuItem("Copy"));
554558 copyItem.addActionListener(this);
555559 pasteItem = menu.add(new MenuItem("Paste"));
556560 pasteItem.addActionListener(this);
557561
558
- menu.add("-");
559
- 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"));
560565 pasteIntoItem.addActionListener(this);
561
- pasteLinkItem = menu.add(new MenuItem("Paste link"));
566
+ pasteLinkItem = oe.jTree.popup.add(new JMenuItem("Paste link"));
562567 pasteLinkItem.addActionListener(this);
563
- pasteCloneItem = menu.add(new MenuItem("Paste clone"));
568
+ pasteCloneItem = oe.jTree.popup.add(new JMenuItem("Paste clone"));
564569 pasteCloneItem.addActionListener(this);
565
-// pasteExpandItem = menu.add(new MenuItem("Paste expand"));
570
+// CRASH pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand"));
566571 // pasteExpandItem.addActionListener(this);
567
- menu.add("-");
568
- deleteItem = menu.add(new MenuItem("Delete"));
569
- deleteItem.addActionListener(this);
572
+ //menu.add("-");
573
+ oe.jTree.popup.addSeparator();
570574
571575 if (Globals.ADVANCED)
572576 {
....@@ -701,9 +705,8 @@
701705 setMasterItem.addActionListener(this);
702706 }
703707
704
- oe.menuBar.add(menu = new Menu("Group"));
705
-// grabItem = menu.add(new MenuItem("Grab"));
706
-// grabItem.addActionListener(this);
708
+ oe.menuBar.add(menu = new Menu("Order"));
709
+
707710 backItem = menu.add(new MenuItem("Back"));
708711 backItem.addActionListener(this);
709712 frontItem = menu.add(new MenuItem("Front"));
....@@ -711,13 +714,21 @@
711714 // compositeItem = menu.add(new MenuItem("Composite"));
712715 // compositeItem.addActionListener(this);
713716
717
+ grabItem = oe.jTree.popup.add(new JMenuItem("Group"));
718
+ grabItem.addActionListener(this);
719
+
714720 if (Globals.ADVANCED)
715721 {
716722 hideItem = menu.add(new MenuItem("Hidden Group"));
717723 hideItem.addActionListener(this);
718724 }
719
- ungroupItem = menu.add(new MenuItem("Ungroup"));
725
+ ungroupItem = oe.jTree.popup.add(new JMenuItem("Ungroup"));
720726 ungroupItem.addActionListener(this);
727
+
728
+ oe.jTree.popup.addSeparator();
729
+
730
+ deleteItem = oe.jTree.popup.add(new JMenuItem("Delete"));
731
+ deleteItem.addActionListener(this);
721732
722733 // menu.add("-");
723734 //
....@@ -923,7 +934,7 @@
923934
924935 JTabbedPane resourcecontainer;
925936 cGridBag currenttab;
926
- boolean added; // patch for jar
937
+ //boolean added; // patch for jar
927938
928939 int tabcount = 0;
929940 int colcount = 0;
....@@ -940,12 +951,14 @@
940951 // System.out.println();
941952
942953 if (//rowcount == 0 ||
943
- path.length == 1)
954
+ path.length == 1 && !path[0].equals("") && !path[0].equals(".DS_Store"))
944955 {
945956 currenttab = new cGridBag();
946
- added = false;
947957 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
948958 currenttab.setName(tabname);
959
+ //added = false;
960
+ resourcecontainer.add(currenttab);
961
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
949962 rowcount = 1;
950963 colcount = 0;
951964 texturecount = 0;
....@@ -953,12 +966,11 @@
953966
954967 if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
955968 {
956
- if (!added)
969
+ //if (!added)
957970 {
958
- added = true;
959
- resourcecontainer.add(currenttab);
971
+ //added = true;
960972 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
961
- resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
973
+ currenttab = (cGridBag)resourcecontainer.getComponentAt(resourcecontainer.indexOfTab(tabname));
962974 }
963975
964976 AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
....@@ -1059,7 +1071,7 @@
10591071 collapseButton.setToolTipText("Collapse toolbar");
10601072 collapseButton.addActionListener(this);
10611073
1062
- oe.toolbarPanel.add(maximize3DButton = GetButton("", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1074
+ oe.toolbarPanel.add(maximize3DButton = GetButton("icons/empty.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10631075 maximize3DButton.setToolTipText("Maximize 3D view");
10641076 maximize3DButton.addActionListener(this);
10651077
....@@ -1101,6 +1113,7 @@
11011113 copyOptionsPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11021114 deleteVersionButton.setToolTipText("Delete current version");
11031115 deleteVersionButton.addActionListener(this);
1116
+ deleteVersionButton.setEnabled(false);
11041117
11051118 copyOptionsPanel.add(previousVersionButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11061119 previousVersionButton.setToolTipText("Previous version");
....@@ -1111,12 +1124,12 @@
11111124 updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11121125 restoreButton.setToolTipText("Undo (restore current version)");
11131126 restoreButton.addActionListener(this);
1114
- //restoreButton.setEnabled(false);
1127
+ restoreButton.setEnabled(false);
11151128
11161129 updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11171130 replaceButton.setToolTipText("Save (replace current version)");
11181131 replaceButton.addActionListener(this);
1119
- //replaceButton.setEnabled(false);
1132
+ replaceButton.setEnabled(false);
11201133
11211134 copyOptionsPanel.add(updown);
11221135
....@@ -1181,6 +1194,10 @@
11811194 boxButton.setToolTipText("Create box");
11821195 boxButton.addActionListener(this);
11831196
1197
+ row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1198
+ superButton.setToolTipText("Create superellipsoid");
1199
+ superButton.addActionListener(this);
1200
+
11841201 row1.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11851202 sphereButton.setToolTipText("Create sphere");
11861203 sphereButton.addActionListener(this);
....@@ -1192,10 +1209,6 @@
11921209 row1.add(torusButton = GetButton("icons/torus.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11931210 torusButton.setToolTipText("Create torus");
11941211 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);
11991212
12001213 if (Globals.ADVANCED)
12011214 {
....@@ -1498,6 +1511,7 @@
14981511
14991512 oe.SetupViews();
15001513
1514
+ if (Globals.DEBUG)
15011515 System.out.println("SetupViews");
15021516 DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(
15031517 oe.cameraView, DnDConstants.ACTION_COPY_OR_MOVE, this); // ACTION_LINK ??
....@@ -2159,7 +2173,11 @@
21592173 shadow.material = new cMaterial(obj.material);
21602174 shadow.material.diffuse = 0.0001f;
21612175 shadow.material.specular = 0.0001f;
2162
- //shadow.projectedVertices[1].x = 300;
2176
+ shadow.material.opacity = 0.75f;
2177
+
2178
+ AllocProjectedVertices(shadow);
2179
+
2180
+ shadow.projectedVertices[1].x = 300;
21632181
21642182 makeSomething(shadow);
21652183 }
....@@ -2680,27 +2698,35 @@
26802698 } else
26812699 if (source == loopItem || source == loopButton)
26822700 {
2701
+ if (!group.selection.isEmpty())
2702
+ {
26832703 Composite csg = new GroupLeaf();
26842704 csg.count = 5;
2685
- group(csg);
26862705 Composite child = new cGroup("Branch");
26872706 csg.addChild(child);
26882707 child.addChild(csg);
2708
+ group(csg);
2709
+ }
26892710 } else
26902711 if (source == doubleItem)
26912712 {
2713
+ if (!group.selection.isEmpty())
2714
+ {
26922715 Composite csg = new GroupLeaf("Fork");
26932716 csg.count = 5;
2694
- group(csg);
26952717 Composite child = new cGroup("Branch A");
26962718 csg.addChild(child);
26972719 child.addChild(csg);
26982720 child = new cGroup("Branch B");
26992721 csg.addChild(child);
27002722 child.addChild(csg);
2723
+ group(csg);
2724
+ }
27012725 } else
27022726 if (source == tripleItem)
27032727 {
2728
+ if (!group.selection.isEmpty())
2729
+ {
27042730 Composite csg = new GroupLeaf("Trident");
27052731 csg.count = 4;
27062732 group(csg);
....@@ -2713,6 +2739,7 @@
27132739 child = new cGroup();
27142740 csg.addChild(child);
27152741 child.addChild(csg);
2742
+ }
27162743 } else
27172744 if (source == computeAOItem)
27182745 {
....@@ -3348,22 +3375,34 @@
33483375 } else
33493376 if (source == ungroupItem || source == ungroupButton)
33503377 {
3351
- boolean hasRoot = false;
3378
+ boolean canUngroup = true;
33523379
33533380 for (int i=0; i<group.selection.size(); i++)
33543381 {
3355
- if (group.selection.get(i) == group)
3382
+ Object3D selectedItem = group.selection.get(i);
3383
+
3384
+ if (selectedItem.Size() == 0)
33563385 {
3357
- hasRoot = true;
3386
+ // Cannot ungroup leaves
3387
+ canUngroup = false;
3388
+ break;
3389
+ }
3390
+
3391
+ if (selectedItem == group)
3392
+ {
3393
+ // Cannot ungroup root
3394
+ canUngroup = false;
33583395 break;
33593396 }
33603397 }
33613398
3362
- if (!hasRoot)
3399
+ if (canUngroup)
33633400 {
33643401 for (int i=0; i<group.selection.size(); i++)
33653402 {
3366
- Ungroup(group.selection.get(i));
3403
+ Object3D selectedItem = group.selection.get(i);
3404
+
3405
+ Ungroup(selectedItem);
33673406 }
33683407
33693408 ClearSelection(false);
....@@ -4083,7 +4122,10 @@
40834122 copy.versionlist = new Object3D[100];
40844123 copy.versionindex = -1;
40854124
4086
- Save(true);
4125
+ // Cannot work with loops
4126
+ // To fix this issue, first mark all nodes above the root,
4127
+ // and check if any of these nodes are reachable below the root.
4128
+ //Save(true);
40874129 }
40884130
40894131 SetVersionStates();
....@@ -5328,7 +5370,8 @@
53285370 if (group.selection != null)
53295371 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
53305372 {
5331
- if (!(e.nextElement() instanceof Composite))
5373
+ Object next = e.nextElement();
5374
+ if (!(next instanceof Composite)) // || (next instanceof GroupLeaf))
53325375 {
53335376 allComposites = false;
53345377 break;
....@@ -6233,11 +6276,11 @@
62336276 private MenuItem lookAtItem;
62346277 private MenuItem lookFromItem;
62356278 private MenuItem switchViewItem;
6236
- private MenuItem cutItem;
6279
+ private JMenuItem cutItem;
62376280 private MenuItem undoItem;
62386281 private MenuItem redoItem;
62396282 private JMenuItem duplicateItem;
6240
- private MenuItem cloneItem;
6283
+ private JMenuItem cloneItem;
62416284 private MenuItem cloneSupportItem;
62426285 private MenuItem overwriteGeoItem;
62436286 private MenuItem overwriteMatItem;
....@@ -6258,13 +6301,13 @@
62586301 private MenuItem cloneGeometriesItem;
62596302 private MenuItem shareGeometriesItem;
62606303 private MenuItem mergeGeometriesItem;
6261
- private MenuItem copyItem;
6304
+ private JMenuItem copyItem;
62626305 private MenuItem pasteItem;
6263
- private MenuItem pasteIntoItem;
6264
- private MenuItem pasteLinkItem;
6265
- private MenuItem pasteCloneItem;
6266
- private MenuItem pasteExpandItem;
6267
- private MenuItem deleteItem;
6306
+ private JMenuItem pasteIntoItem;
6307
+ private JMenuItem pasteLinkItem;
6308
+ private JMenuItem pasteCloneItem;
6309
+ private JMenuItem pasteExpandItem;
6310
+ private JMenuItem deleteItem;
62686311 private MenuItem clearAllItem;
62696312 private MenuItem genUVItem;
62706313 private MenuItem genNormalsMESHItem;
....@@ -6319,7 +6362,7 @@
63196362 private MenuItem transformGeometryItem;
63206363 private MenuItem transformChildrenItem;
63216364 private MenuItem hideItem;
6322
- private MenuItem grabItem;
6365
+ private JMenuItem grabItem;
63236366 private MenuItem backItem;
63246367 private MenuItem frontItem;
63256368 private MenuItem cameraItem;
....@@ -6332,7 +6375,7 @@
63326375 private MenuItem switchTransfoItem;
63336376 private MenuItem morphItem;
63346377 private MenuItem linkerItem;
6335
- private MenuItem ungroupItem;
6378
+ private JMenuItem ungroupItem;
63366379 private MenuItem editItem;
63376380 private MenuItem openWindowItem;
63386381 private MenuItem editLeafItem;