Normand Briere
2019-07-19 e79247ef52a0bbb3864d46bb1e2c716005b3ecf3
GroupEditor.java
....@@ -60,6 +60,12 @@
6060 this.copy = this.group = group;
6161 //selectees = this.group.selectees;
6262
63
+ if (copy.versions == null)
64
+ {
65
+ copy.versions = new byte[100][];
66
+ copy.versionindex = -1;
67
+ }
68
+
6369 if(ui)
6470 SetupUI(objEditor);
6571 }
....@@ -74,6 +80,12 @@
7480 this.copy = this.group = copy;
7581 //selectees = this.group.selectees;
7682
83
+ if (copy.versions == null)
84
+ {
85
+ copy.versions = new byte[100][];
86
+ copy.versionindex = -1;
87
+ }
88
+
7789 SetupMenu2(this); //objEditor);
7890 SetupUI2(objEditor);
7991 objEditor.SetupUI(true);
....@@ -84,6 +96,10 @@
8496
8597 void CloneSelection(boolean supports)
8698 {
99
+ if (Globals.REPLACEONMAKE)
100
+ Save();
101
+ boolean keep = Globals.REPLACEONMAKE;
102
+ Globals.REPLACEONMAKE = false;
87103 // Object3D keep = GrafreeD.clipboard;
88104 //Object3D obj;
89105 for (int i=0; i<group.selection.size(); i++)// Enumeration e = group.selection.elements(); e.hasMoreElements();)
....@@ -94,6 +110,7 @@
94110
95111 makeSomething(clone, i==group.selection.size()-1);
96112 }
113
+ Globals.REPLACEONMAKE = keep;
97114 }
98115
99116 void CloneClipboard(boolean supports)
....@@ -150,6 +167,8 @@
150167
151168 void SetupMenu2(GroupEditor oe)
152169 {
170
+ oe.jTree = new cTree();
171
+
153172 Menu menu;
154173 oe.menuBar.add(menu = new Menu("Edit"));
155174 //editItem = menu.add(new MenuItem("Edit"));
....@@ -160,7 +179,7 @@
160179 // redoItem = menu.add(new MenuItem("Redo"));
161180 // redoItem.addActionListener(this);
162181 // menu.add("-");
163
- duplicateItem = menu.add(new MenuItem("Duplicate"));
182
+ duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate"));
164183 duplicateItem.addActionListener(this);
165184 cloneItem = menu.add(new MenuItem("Clone"));
166185 cloneItem.addActionListener(this);
....@@ -176,7 +195,6 @@
176195 copyItem.addActionListener(this);
177196 pasteItem = menu.add(new MenuItem("Paste"));
178197 pasteItem.addActionListener(this);
179
- menu.add("-");
180198
181199 menu.add("-");
182200 pasteIntoItem = menu.add(new MenuItem("Paste into"));
....@@ -188,8 +206,8 @@
188206 // pasteExpandItem = menu.add(new MenuItem("Paste expand"));
189207 // pasteExpandItem.addActionListener(this);
190208 menu.add("-");
191
- clearItem = menu.add(new MenuItem("Clear"));
192
- clearItem.addActionListener(this);
209
+ deleteItem = menu.add(new MenuItem("Delete"));
210
+ deleteItem.addActionListener(this);
193211
194212 if (Globals.ADVANCED)
195213 {
....@@ -203,23 +221,23 @@
203221 //zBufferItem.addActionListener(this);
204222 //cameraMenu.add(normalLensItem = new MenuItem("Normal Lens"));
205223 //normalLensItem.addActionListener(this);
206
- cameraMenu.add(revertCameraItem = new MenuItem("Restore Viewpoint"));
207
- revertCameraItem.addActionListener(this);
224
+ cameraMenu.add(restoreCameraItem = new MenuItem("Restore Viewpoint"));
225
+ restoreCameraItem.addActionListener(this);
208226
209
- cameraMenu.add(toggleFullScreenItem = new CheckboxMenuItem("Full Screen"));
210
- toggleFullScreenItem.addItemListener(this);
211
- toggleFullScreenItem.setState(CameraPane.FULLSCREEN);
212
- cameraMenu.add("-");
227
+// cameraMenu.add(toggleFullScreenItem = new CheckboxMenuItem("Full Screen"));
228
+// toggleFullScreenItem.addItemListener(this);
229
+// toggleFullScreenItem.setState(CameraPane.FULLSCREEN);
230
+// cameraMenu.add("-");
231
+//
232
+// cameraMenu.add(toggleTextureItem = new CheckboxMenuItem("Texture"));
233
+// toggleTextureItem.addItemListener(this);
234
+// toggleTextureItem.setState(CameraPane.textureon);
235
+//
236
+// cameraMenu.add(toggleSwitchItem = new CheckboxMenuItem("Switch"));
237
+// toggleSwitchItem.addItemListener(this);
238
+// toggleSwitchItem.setState(CameraPane.SWITCH);
213239
214
- cameraMenu.add(toggleTextureItem = new CheckboxMenuItem("Texture"));
215
- toggleTextureItem.addItemListener(this);
216
- toggleTextureItem.setState(CameraPane.textureon);
217
-
218
- cameraMenu.add(toggleSwitchItem = new CheckboxMenuItem("Switch"));
219
- toggleSwitchItem.addItemListener(this);
220
- toggleSwitchItem.setState(CameraPane.SWITCH);
221
-
222
- cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Handles"));
240
+ cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Show Handles"));
223241 toggleHandleItem.addItemListener(this);
224242 toggleHandleItem.setState(CameraPane.HANDLES);
225243
....@@ -274,7 +292,7 @@
274292 {
275293 oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest"));
276294 //cameraMenu.add(lookFromItem = new MenuItem("Look From Selection"));
277
- //cameraMenu.add(switchItem = new MenuItem("Reverse View"));
295
+ //cameraMenu.add(switchViewItem = new MenuItem("Reverse View"));
278296 editLeafItem = oe.cameraMenu.add(new MenuItem("Edit Leaf"));
279297 oe.cameraMenu.add("-");
280298 openWindowItem = oe.cameraMenu.add(new MenuItem("Edit copy..."));
....@@ -282,7 +300,7 @@
282300 editLeafItem.addActionListener(this);
283301 lookAtItem.addActionListener(this);
284302 //lookFromItem.addActinoListener(this);
285
- //switchItem.addActionListener(this);
303
+ //switchViewItem.addActionListener(this);
286304 }
287305
288306 oe.menuBar.add(menu = new Menu("Setting"));
....@@ -327,21 +345,29 @@
327345 }
328346
329347 oe.menuBar.add(menu = new Menu("Group"));
330
- grabItem = menu.add(new MenuItem("Grab"));
331
- grabItem.addActionListener(this);
348
+// grabItem = menu.add(new MenuItem("Grab"));
349
+// grabItem.addActionListener(this);
332350 backItem = menu.add(new MenuItem("Back"));
333351 backItem.addActionListener(this);
334352 frontItem = menu.add(new MenuItem("Front"));
335353 frontItem.addActionListener(this);
336
- compositeItem = menu.add(new MenuItem("Composite"));
337
- compositeItem.addActionListener(this);
354
+// compositeItem = menu.add(new MenuItem("Composite"));
355
+// compositeItem.addActionListener(this);
356
+
357
+ if (Globals.ADVANCED)
358
+ {
338359 hideItem = menu.add(new MenuItem("Hidden Group"));
339360 hideItem.addActionListener(this);
361
+ }
340362 ungroupItem = menu.add(new MenuItem("Ungroup"));
341363 ungroupItem.addActionListener(this);
342
- menu.add("-");
343
- randomItem = menu.add(new MenuItem("Switch node"));
344
- randomItem.addActionListener(this);
364
+
365
+// menu.add("-");
366
+//
367
+// switchItem = menu.add(new MenuItem("Switch node"));
368
+// switchItem.addActionListener(this);
369
+ if (Globals.ADVANCED)
370
+ {
345371 switchGeoItem = menu.add(new MenuItem("Switch Geometry"));
346372 switchGeoItem.addActionListener(this);
347373 switchTransfoItem = menu.add(new MenuItem("Switch Transform"));
....@@ -349,8 +375,6 @@
349375 morphItem = menu.add(new MenuItem("Morph Group"));
350376 morphItem.addActionListener(this);
351377
352
- if (Globals.ADVANCED)
353
- {
354378 menu.add("-");
355379 physicsItem = menu.add(new MenuItem("Physics"));
356380 physicsItem.addActionListener(this);
....@@ -358,30 +382,29 @@
358382 frameselectorItem.addActionListener(this);
359383 scriptNodeItem = menu.add(new MenuItem("Script Node"));
360384 scriptNodeItem.addActionListener(this);
361
- cameraItem = menu.add(new MenuItem("Camera"));
362
- cameraItem.addActionListener(this);
363385 }
364386
365387 oe.menuBar.add(menu = new Menu("Object"));
366
- textureItem = menu.add(new MenuItem("Texture"));
367
- textureItem.addActionListener(this);
388
+// textureItem = menu.add(new MenuItem("Texture"));
389
+// textureItem.addActionListener(this);
368390 billboardItem = menu.add(new MenuItem("Billboard"));
369391 billboardItem.addActionListener(this);
370392 csgItem = menu.add(new MenuItem("CSG"));
371393 csgItem.addActionListener(this);
372
- shadowXItem = menu.add(new MenuItem("Shadow X"));
394
+ shadowXItem = menu.add(new MenuItem("Shadow Red"));
373395 shadowXItem.addActionListener(this);
374
- shadowYItem = menu.add(new MenuItem("Shadow Y"));
396
+ shadowYItem = menu.add(new MenuItem("Shadow Green"));
375397 shadowYItem.addActionListener(this);
376
- shadowZItem = menu.add(new MenuItem("Shadow Z"));
398
+ shadowZItem = menu.add(new MenuItem("Shadow Blue"));
377399 shadowZItem.addActionListener(this);
400
+ attributeItem = menu.add(new MenuItem("Attribute"));
401
+ attributeItem.addActionListener(this);
402
+
378403 if (Globals.ADVANCED)
379404 {
380405 menu.add("-");
381406 linkerItem = menu.add(new MenuItem("Linker"));
382407 linkerItem.addActionListener(this);
383
- attributeItem = menu.add(new MenuItem("Attribute"));
384
- attributeItem.addActionListener(this);
385408 templateItem = menu.add(new MenuItem("Template"));
386409 templateItem.addActionListener(this);
387410 pointflowItem = menu.add(new MenuItem("Point Flow"));
....@@ -410,7 +433,7 @@
410433 genNormalsMESHItem.addActionListener(this);
411434 if (Globals.ADVANCED)
412435 {
413
- genNormalsMINEItem = menu.add(new MenuItem("My Normals"));
436
+ genNormalsMINEItem = menu.add(new MenuItem("Stitch Normals"));
414437 genNormalsMINEItem.addActionListener(this);
415438 }
416439 stripifyItem = menu.add(new MenuItem("Stripify"));
....@@ -533,6 +556,7 @@
533556 buildToolsMenu(menu);
534557 }
535558
559
+
536560 void SetupUI2(ObjEditor oe)
537561 {
538562 // June 2019
....@@ -575,51 +599,79 @@
575599 oe.radioPanel.add(dummyButton);
576600 oe.buttonGroup.add(dummyButton);
577601 */
602
+ cGridBag copyOptionsPanel = new cGridBag();
603
+
604
+ copyOptionsPanel.preferredHeight = 1;
605
+
578606 //this.AddOptions(oe.toolbarPanel, oe.aConstraints);
579607
580608 //oe.toolbarPanel.add(minButton = new cButton("Min", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
581609 //minButton.setToolTipText("Minimize window");
582610 //minButton.addActionListener(this);
583611
584
- oe.toolbarPanel.add(maxButton = new cButton("\u271A", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
585
- maxButton.setToolTipText("Maximize window");
586
- maxButton.addActionListener(this);
612
+ if (Globals.ADVANCED)
613
+ {
614
+ oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
615
+ maxButton.setToolTipText("Maximize window");
616
+ maxButton.addActionListener(this);
617
+ }
587618
588
- oe.toolbarPanel.add(fullButton = new cButton("\u2b1c", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
619
+ oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
589620 fullButton.setToolTipText("Full-screen window");
590621 fullButton.addActionListener(this);
591622
592
- oe.toolbarPanel.add(undoButton = new cButton("\u21a9", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
593
- undoButton.setToolTipText("Undo changes");
594
- undoButton.addActionListener(this);
623
+ oe.toolbarPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
624
+ screenfitButton.setToolTipText("Screen fit");
625
+ screenfitButton.addActionListener(this);
626
+
627
+ oe.toolbarPanel.add(restoreCameraButton = GetButton("icons/eye.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
628
+ restoreCameraButton.setToolTipText("Restore viewpoint");
629
+ restoreCameraButton.addActionListener(this);
595630
596
- oe.toolbarPanel.add(redoButton = new cButton("\u21aa", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
597
- redoButton.setToolTipText("Redo changes");
598
- redoButton.addActionListener(this);
599
-
600
- oe.toolbarPanel.add(saveButton = new cButton("\u21e3", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
601
- saveButton.setToolTipText("Save changes");
631
+ copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
632
+ saveButton.setToolTipText("New version");
602633 saveButton.addActionListener(this);
634
+
635
+ copyOptionsPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
636
+ undoButton.setToolTipText("Previous version");
637
+ undoButton.addActionListener(this);
638
+ undoButton.setEnabled(false);
603639
604
- oe.toolbarPanel.add(liveCB = new cCheckBox("Live", Globals.isLIVE())); //, oe.aConstraints);
640
+ cGridBag updown = new cGridBag().setVertical(true);
641
+ updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
642
+ restoreButton.setToolTipText("Restore current");
643
+ restoreButton.addActionListener(this);
644
+ restoreButton.setEnabled(false);
645
+
646
+ updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
647
+ replaceButton.setToolTipText("Replace current");
648
+ replaceButton.addActionListener(this);
649
+ replaceButton.setEnabled(false);
650
+
651
+ copyOptionsPanel.add(updown);
652
+
653
+ copyOptionsPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
654
+ redoButton.setToolTipText("Next version");
655
+ redoButton.addActionListener(this);
656
+ redoButton.setEnabled(false);
657
+
658
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
605659 liveCB.setToolTipText("Enable animation");
606660 liveCB.addItemListener(this);
607661
608
- oe.toolbarPanel.add(oneStepButton = new cButton("\u29f4", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
662
+ oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
609663 oneStepButton.setToolTipText("Animate one step forward");
610664 oneStepButton.addActionListener(this);
611665
612
- oe.toolbarPanel.add(fastCB = new cCheckBox("Fast", CameraPane.FAST)); //, constraints);
666
+ oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
613667 fastCB.setToolTipText("Fast mode");
614668 fastCB.addItemListener(this);
615669
616
- oe.toolbarPanel.add(trackCB = new cCheckBox(":", CameraPane.TRACK)); //, oe.aConstraints);
617
- trackCB.setToolTipText("Enable tracking");
618
- trackCB.addItemListener(this);
619
-
620
- oe.toolbarPanel.add(screenfitButton = new cButton("@", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
621
- screenfitButton.setToolTipText("Screen fit");
622
- screenfitButton.addActionListener(this);
670
+ //oe.toolboxPanel.Return();
671
+
672
+// copyOptionsPanel.add(trackCB = GetToggleButton("icons/track.png", CameraPane.TRACK)); //, oe.aConstraints);
673
+// trackCB.setToolTipText("Enable tracking");
674
+// trackCB.addItemListener(this);
623675
624676 // oe.toolbarPanel.add(screenfitpointButton = new cButton(" @+ ")); //, oe.aConstraints);
625677 // screenfitpointButton.addActionListener(this);
....@@ -631,65 +683,146 @@
631683 snapobjectButton.setToolTipText("Snap Object");
632684 }
633685
634
- oe.toolbarPanel.add(flashSelectionButton = new cButton("?", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
635
- flashSelectionButton.setToolTipText("Show selection");
636
- flashSelectionButton.addActionListener(this);
686
+ //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
637687
638
- oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
639
-
640
- oe.toolbarPanel.add(twoButton = new cButton("|+|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
641
- twoButton.setToolTipText("Show center view only");
642
- twoButton.addActionListener(this);
643
- oe.toolbarPanel.add(fourButton = new cButton("+||", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
688
+ oe.toolbarPanel.add(fourButton = new cButton("-||", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
644689 fourButton.addActionListener(this);
645690 fourButton.setToolTipText("Show left panel only");
646
- oe.toolbarPanel.add(sixButton = new cButton("+|+|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
647
- sixButton.setToolTipText("2-column layout left");
691
+
692
+ oe.toolbarPanel.add(twoButton = new cButton("|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
693
+ twoButton.setToolTipText("Show right view only");
694
+ twoButton.addActionListener(this);
695
+ this.fullscreenLayout = twoButton;
696
+
697
+ oe.toolbarPanel.add(sixButton = new cButton("-|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
698
+ sixButton.setToolTipText("Show left and right");
648699 sixButton.addActionListener(this);
649
- oe.toolbarPanel.add(threeButton = new cButton("|+|+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
650
- threeButton.setToolTipText("2-column layout right");
651
- threeButton.addActionListener(this);
652
- oe.toolbarPanel.add(sevenButton = new cButton("+|+|+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
653
- sevenButton.setToolTipText("3-column layout");
654
- sevenButton.addActionListener(this);
700
+// oe.toolbarPanel.add(threeButton = new cButton("|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
701
+// threeButton.setToolTipText("2-column layout right");
702
+// threeButton.addActionListener(this);
703
+// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
704
+// sevenButton.setToolTipText("3-column layout");
705
+// sevenButton.addActionListener(this);
655706 //
656707
657
- oe.toolbarPanel.add(rootButton = new cButton("o o o", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
658
- rootButton.setToolTipText("Edit selection in new tab");
708
+ oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
709
+ rootButton.setToolTipText("Open selection in new tab");
659710 rootButton.addActionListener(this);
660711
661
- oe.toolbarPanel.add(closeButton = new cButton("X", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
712
+ oe.toolbarPanel.add(closeButton = GetButton("icons/close-icon.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
662713 closeButton.setToolTipText("Close tab");
663714 closeButton.addActionListener(this);
664715 //oe.treePanel.add(clearButton = new cButton("X"), oe.aConstraints);
665716 //clearButton.addActionListener(this);
666
-
667
- cGridBag commandsPanel = new cGridBag();
717
+
718
+ // INSERT
719
+ oe.toolboxPanel.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
720
+ gridButton.setToolTipText("Create grid");
721
+ gridButton.addActionListener(this);
722
+
723
+ oe.toolboxPanel.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
724
+ boxButton.setToolTipText("Create box");
725
+ boxButton.addActionListener(this);
726
+
727
+ oe.toolboxPanel.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
728
+ sphereButton.setToolTipText("Create sphere");
729
+ sphereButton.addActionListener(this);
730
+
731
+ oe.toolboxPanel.add(coneButton = GetButton("icons/cone.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
732
+ coneButton.setToolTipText("Create cone");
733
+ coneButton.addActionListener(this);
734
+
735
+ oe.toolboxPanel.add(torusButton = GetButton("icons/torus.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
736
+ torusButton.setToolTipText("Create torus");
737
+ torusButton.addActionListener(this);
738
+
739
+ oe.toolboxPanel.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
740
+ superButton.setToolTipText("Create superellipsoid");
741
+ superButton.addActionListener(this);
742
+
743
+ if (Globals.ADVANCED)
744
+ {
745
+ oe.toolboxPanel.add(kleinButton = GetButton("icons/klein.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
746
+ kleinButton.setToolTipText("Create Klein bottle");
747
+ kleinButton.addActionListener(this);
748
+ }
668749
669
- commandsPanel.add(editButton = new cButton("+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
670
- editButton.setToolTipText("Edit selection");
750
+ oe.toolboxPanel.add(particlesButton = GetButton("icons/particles.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
751
+ particlesButton.setToolTipText("Create particle system");
752
+ particlesButton.addActionListener(this);
753
+
754
+ oe.toolboxPanel.Return();
755
+
756
+ oe.toolboxPanel.add(groupButton = GetButton("icons/group.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
757
+ groupButton.setToolTipText("Create group");
758
+ groupButton.addActionListener(this);
759
+
760
+ oe.toolboxPanel.add(compositeButton = GetButton("icons/composite.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
761
+ compositeButton.setToolTipText("Create composite");
762
+ compositeButton.addActionListener(this);
763
+
764
+ oe.toolboxPanel.add(switchButton = GetButton("icons/switch.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
765
+ switchButton.setToolTipText("Create item switcher");
766
+ switchButton.addActionListener(this);
767
+
768
+ oe.toolboxPanel.add(loopButton = GetButton("icons/loop.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
769
+ loopButton.setToolTipText("Create loop");
770
+ loopButton.addActionListener(this);
771
+
772
+ oe.toolboxPanel.add(textureButton = GetButton("icons/texture.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
773
+ textureButton.setToolTipText("Create texture");
774
+ textureButton.addActionListener(this);
775
+
776
+ oe.toolboxPanel.add(overlayButton = GetButton("icons/overlay.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
777
+ overlayButton.setToolTipText("Create overlay");
778
+ overlayButton.addActionListener(this);
779
+
780
+ oe.toolboxPanel.add(lightButton = GetButton("icons/light-bulb.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
781
+ lightButton.setToolTipText("Create light");
782
+ lightButton.addActionListener(this);
783
+
784
+ for (int i=6; --i>=0;)
785
+ {
786
+ oe.toolboxPanel.Return();
787
+ oe.toolboxPanel.add(new cGridBag());
788
+ oe.toolboxPanel.add(new cGridBag());
789
+ oe.toolboxPanel.add(new cGridBag());
790
+ oe.toolboxPanel.add(new cGridBag());
791
+ oe.toolboxPanel.add(new cGridBag());
792
+ oe.toolboxPanel.add(new cGridBag());
793
+ oe.toolboxPanel.add(new cGridBag());
794
+ }
795
+
796
+ // EDIT panel
797
+ editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
798
+ editButton.setToolTipText("Pin selection controls");
671799 editButton.addActionListener(this);
672800
673
- commandsPanel.add(uneditButton = new cButton("-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
674
- uneditButton.setToolTipText("Unedit selection");
801
+ editCommandsPanel.add(uneditButton = GetButton("icons/remove.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
802
+ uneditButton.setToolTipText("Remove selection controls");
675803 uneditButton.addActionListener(this);
676804
677
- commandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
678
- allParamsButton.setToolTipText("Edit all params");
805
+ editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
806
+ allParamsButton.setToolTipText("Show all controle");
679807 allParamsButton.addActionListener(this);
680808
681
- commandsPanel.add(clearPanelButton = new cButton("C", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
809
+ editCommandsPanel.add(clearPanelButton = new cButton("C", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
682810 clearPanelButton.setToolTipText("Clear edit panel");
683811 clearPanelButton.addActionListener(this);
684812
685
- commandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
813
+ editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
686814 unselectButton.setToolTipText("Unselect");
687815 unselectButton.addActionListener(this);
688816
689
- commandsPanel.preferredHeight = 1;
817
+ editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
818
+ flashSelectionButton.setToolTipText("Highlight selection");
819
+ flashSelectionButton.addActionListener(this);
690820
691
- oe.treePanel.add(commandsPanel);
692
- oe.treePanel.Return();
821
+ editCommandsPanel.preferredHeight = 1;
822
+
823
+ SetPinStates(false);
824
+// oe.treePanel.add(commandsPanel);
825
+// oe.treePanel.Return();
693826
694827 // oe.aConstraints.gridx += 1;
695828 // oe.aConstraints.weighty = 0;
....@@ -706,29 +839,17 @@
706839
707840 JScrollPane jSP;
708841 //ctrlPanel.add(new JScrollPane(jTree = new cTree(new cTreeModel(this))), aConstraints);
709
- jSPPanel.add(jSP = new JScrollPane(oe.jTree = new cTree(null))); //, oe.aConstraints);
842
+ jSPPanel.add(jSP = new JScrollPane(oe.jTree)); //, oe.aConstraints);
710843 ResetModel();
711844
712845 oe.treePanel.add(jSPPanel);
713846 oe.treePanel.Return();
714847
715
- cGridBag copyOptionsPanel = new cGridBag();
716
-
717
- copyOptionsPanel.add(colorCB = new cCheckBox("Color", (dropAttributes&Object3D.COLOR)!=0)); //, oe.aConstraints);
718
- colorCB.setToolTipText("Copy color when dropped");
719
- colorCB.addItemListener(this);
720
-
721
- copyOptionsPanel.add(materialCB = new cCheckBox("Material", (dropAttributes&Object3D.MATERIAL)!=0)); //, oe.aConstraints);
722
- materialCB.setToolTipText("Copy material when dropped");
723
- materialCB.addItemListener(this);
724
-
725
- copyOptionsPanel.add(textureCB = new cCheckBox("Texture", (dropAttributes&Object3D.TEXTURE)!=0)); //, oe.aConstraints);
726
- textureCB.setToolTipText("Copy texture when dropped");
727
- textureCB.addItemListener(this);
728
-
729
- copyOptionsPanel.preferredHeight = 1;
730848 oe.treePanel.add(copyOptionsPanel);
731849 oe.treePanel.Return();
850
+ cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
851
+ versionSlider = (cNumberSlider)sliderPane.getComponent(1);
852
+ sliderPane.preferredHeight = 1;
732853
733854 // mainPanel.setDividerLocation(0.5); //1.0);
734855 // mainPanel.setResizeWeight(0.5);
....@@ -751,29 +872,49 @@
751872 dgr.addDragGestureListener(this);
752873 }catch(Exception e) {}
753874 */
754
- radio.layout = sevenButton;
875
+ radio.layout = sixButton; // sevenButton;
755876 oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
756877 }
757878
758879 void AddOptions(cGridBag panel) //, GridBagConstraints constraints)
759880 {
881
+ panel.add(colorCB = new cCheckBox("Color", (dropAttributes&Object3D.COLOR)!=0)); //, oe.aConstraints);
882
+ colorCB.setToolTipText("Copy color when dropped");
883
+ colorCB.addItemListener(this);
884
+
885
+ panel.add(materialCB = new cCheckBox("Material", (dropAttributes&Object3D.MATERIAL)!=0)); //, oe.aConstraints);
886
+ materialCB.setToolTipText("Copy material when dropped");
887
+ materialCB.addItemListener(this);
888
+
889
+ panel.add(textureCB = new cCheckBox("Texture", (dropAttributes&Object3D.TEXTURE)!=0)); //, oe.aConstraints);
890
+ textureCB.setToolTipText("Copy texture when dropped");
891
+ textureCB.addItemListener(this);
892
+
893
+ panel.Return();
894
+
760895 panel.add(boxCB = new cCheckBox("Box", CameraPane.BOXMODE)); //, constraints);
761896 boxCB.setToolTipText("Display bounding boxes");
762897 boxCB.addItemListener(this);
763898
764899 panel.add(zoomBoxCB = new cCheckBox("Zoom", CameraPane.ZOOMBOXMODE)); //, constraints);
765
- zoomBoxCB.setToolTipText("Display bounding boxes when moving the wheel");
900
+ zoomBoxCB.setToolTipText("Display only for wheel");
766901 zoomBoxCB.addItemListener(this);
767902
768903 if (true) // Globals.ADVANCED)
769904 {
770
- panel.add(supportCB = new cCheckBox("Support", CameraPane.SUPPORT)); //, constraints);
771
- supportCB.setToolTipText("Enable rigging");
772
- supportCB.addItemListener(this);
905
+// panel.add(supportCB = new cCheckBox("Support", CameraPane.SUPPORT)); //, constraints);
906
+// supportCB.setToolTipText("Enable rigging");
907
+// supportCB.addItemListener(this);
908
+
909
+ panel.add(freezeCB = new cCheckBox("Freeze", Globals.FREEZEONMOVE)); //, constraints);
910
+ freezeCB.setToolTipText("Fast moving camera");
911
+ freezeCB.addItemListener(this);
773912
774913 // panel.add(localCB = new cCheckBox("Local", CameraPane.LOCALTRANSFORM), constraints);
775914 // localCB.addItemListener(this);
776915
916
+ panel.Return();
917
+
777918 panel.add(crowdCB = new cCheckBox("Crowd", Globals.CROWD)); //, constraints);
778919 crowdCB.setToolTipText("Used for crowds");
779920 crowdCB.addItemListener(this);
....@@ -790,6 +931,8 @@
790931 // panel.add(speakerMocapCB = new cCheckBox("Mocap", CameraPane.SPEAKERMOCAP), constraints);
791932 // speakerMocapCB.addItemListener(this);
792933
934
+ panel.Return();
935
+
793936 if (false)
794937 {
795938 // handled in scripts
....@@ -804,34 +947,74 @@
804947 //constraints.gridy += 1;
805948 panel.add(smoothfocusCB = new cCheckBox("Smooth", CameraPane.SMOOTHFOCUS)); //, constraints);
806949 smoothfocusCB.addItemListener(this);
950
+ panel.Return();
807951 }
808952
809953 //constraints.gridx += 1;
810954 //panel.add(debugCB = new cCheckBox("Debug", CameraPane.DEBUG), constraints);
811955 // debugCB.addItemListener(this);
812956
957
+ panel.add(trackCB = new cCheckBox("Track", CameraPane.TRACK)); //, oe.aConstraints);
958
+ trackCB.setToolTipText("Enable tracking target");
959
+ trackCB.addItemListener(this);
960
+
813961 panel.add(oeilCB = new cCheckBox("Eye", CameraPane.OEIL)); //, constraints);
962
+ oeilCB.setToolTipText("Move camera when tracking");
814963 oeilCB.addItemListener(this);
815964
965
+ panel.add(shadowCB = new cCheckBox("Shadow", Globals.COMPUTESHADOWWHENLIVE)); //, constraints);
966
+ shadowCB.setToolTipText("When live compute shadows");
967
+ shadowCB.addItemListener(this);
968
+
969
+ panel.Return();
970
+ panel.add(toggleTextureCB = new cCheckBox("Textures", CameraPane.textureon)); //, constraints);
971
+ toggleTextureCB.setToolTipText("Load textures");
972
+ toggleTextureCB.addItemListener(this);
973
+
974
+ panel.add(toggleSwitchCB = new cCheckBox("Switch", CameraPane.SWITCH)); //, constraints);
975
+ toggleSwitchCB.setToolTipText("Choose a single item");
976
+ toggleSwitchCB.addItemListener(this);
977
+
978
+ panel.add(autokeepCB = new cCheckBox("Auto-replace", Globals.REPLACEONMAKE)); //, constraints);
979
+ autokeepCB.setToolTipText("On structure change");
980
+ autokeepCB.addItemListener(this);
981
+
982
+ panel.Return();
983
+ if (Globals.ADVANCED)
984
+ {
816985 panel.add(lookAtCB = new cCheckBox("Target", CameraPane.LOOKAT)); //, constraints);
817986 lookAtCB.setToolTipText("Look-at target");
818987 lookAtCB.addItemListener(this);
988
+ }
819989
820990 }
821991
822992 cGridBag fill = new cGridBag();
823
-
824993 fill.preferredHeight = 200;
994
+ cGridBag fill2 = new cGridBag();
995
+ fill2.preferredHeight = 200;
996
+ cGridBag fill3 = new cGridBag();
997
+ fill3.preferredHeight = 200;
825998
826999 panel.add(fill);
1000
+ panel.add(fill2);
1001
+ panel.add(fill3);
8271002
8281003 }
8291004
8301005 void EditObject(Object3D obj)
8311006 {
8321007 cRadio radioButton = new cRadio(obj.name);
1008
+
1009
+ // June 2019. Patch to avoid bug with transparency.
1010
+ radioButton.hadMaterial = obj.material != null;
1011
+ if (!radioButton.hadMaterial)
1012
+ {
1013
+ obj.material = new cMaterial();
1014
+ }
1015
+
8331016 radioButton.SetObject(obj);
834
- radioButton.layout = sevenButton;
1017
+ radioButton.layout = sixButton; // sevenButton;
8351018 radioButton.SetCamera(cameraView.renderCamera, false);
8361019 radioButton.addActionListener(this);
8371020 radioPanel.add(radioButton);
....@@ -851,23 +1034,28 @@
8511034 /*DropTarget dropTarget =*/ new DropTarget(oe.cameraView, this);
8521035 }
8531036
854
- JCheckBox liveCB;
855
- JCheckBox supportCB;
856
- JCheckBox localCB;
857
- JCheckBox crowdCB;
858
- JCheckBox smoothCB;
859
- JCheckBox fastCB;
860
- JCheckBox slowCB;
861
- JCheckBox boxCB;
862
- JCheckBox zoomBoxCB;
863
- JCheckBox trackCB;
864
- JCheckBox smoothfocusCB;
1037
+ cToggleButton liveCB;
1038
+ cCheckBox supportCB;
1039
+ cCheckBox localCB;
1040
+ cCheckBox crowdCB;
1041
+ cCheckBox smoothCB;
1042
+ cToggleButton fastCB;
1043
+ cCheckBox slowCB;
1044
+ cCheckBox boxCB;
1045
+ cCheckBox zoomBoxCB;
1046
+ cCheckBox freezeCB;
1047
+ //cToggleButton trackCB;
1048
+ cCheckBox trackCB;
1049
+ cCheckBox smoothfocusCB;
8651050 // JCheckBox speakerMocapCB;
866
- JCheckBox speakerCameraCB;
867
- JCheckBox speakerFocusCB;
868
- JCheckBox debugCB;
869
- JCheckBox oeilCB;
870
- JCheckBox lookAtCB;
1051
+ cCheckBox speakerCameraCB;
1052
+ cCheckBox speakerFocusCB;
1053
+ cCheckBox debugCB;
1054
+
1055
+ cCheckBox oeilCB;
1056
+ cCheckBox shadowCB;
1057
+ cCheckBox autokeepCB;
1058
+ cCheckBox lookAtCB;
8711059
8721060 // static int COLOR = 1;
8731061 // static int MATERIAL = 2;
....@@ -875,9 +1063,9 @@
8751063
8761064 int dropAttributes = Object3D.COLOR | Object3D.MATERIAL;
8771065
878
- JCheckBox colorCB;
879
- JCheckBox materialCB;
880
- JCheckBox textureCB;
1066
+ cCheckBox colorCB;
1067
+ cCheckBox materialCB;
1068
+ cCheckBox textureCB;
8811069
8821070 public void itemStateChanged(ItemEvent e)
8831071 {
....@@ -970,6 +1158,18 @@
9701158 {
9711159 cameraView.ToggleOeil();
9721160 }
1161
+ else if(e.getSource() == shadowCB)
1162
+ {
1163
+ Globals.COMPUTESHADOWWHENLIVE ^= true;
1164
+ }
1165
+ else if(e.getSource() == freezeCB)
1166
+ {
1167
+ Globals.FREEZEONMOVE ^= true;
1168
+ }
1169
+ else if(e.getSource() == autokeepCB)
1170
+ {
1171
+ Globals.REPLACEONMAKE ^= true;
1172
+ }
9731173 else if(e.getSource() == lookAtCB)
9741174 {
9751175 cameraView.ToggleLookAt();
....@@ -986,7 +1186,8 @@
9861186
9871187 /**/
9881188 //DragSource.getDefaultDragSource().startDrag(dge, DragSource.DefaultMoveNoDrop, new StringSelection("Allo"), this);
989
- TreePath path = new TreePath(objEditor.jTree.getSelectionPath().getLastPathComponent());
1189
+ //TreePath path = new TreePath(objEditor.jTree.getSelectionPath().getLastPathComponent());
1190
+ TreePath path = objEditor.jTree.getSelectionPath();
9901191 if ((path == null) || (path.getPathCount() <= 1)) {
9911192 // We can't move the root node or an empty selection
9921193 return;
....@@ -1049,8 +1250,6 @@
10491250 }
10501251 }
10511252
1052
- String string = (String) object;
1053
-
10541253 System.out.println("Transfer = " + object + "; drop : " + target);
10551254 // if( object instanceof java.io.File[])
10561255 // {
....@@ -1058,6 +1257,8 @@
10581257 // objEditor.DropFile((java.io.File[]) object, true);
10591258 // return;
10601259 // }
1260
+
1261
+ String string = object.toString();
10611262
10621263 // File path for Mac and Windows
10631264 if (string.charAt(0) == '/' || string.charAt(1) == ':')
....@@ -1103,23 +1304,33 @@
11031304
11041305 assert target == objEditor.jTree;
11051306 TreePath destinationPath = objEditor.jTree.getPathForLocation(objEditor.location.x, objEditor.location.y);
1307
+ Object3D destinationLeaf;
11061308 try {
1107
- Object3D dummy = (Composite) destinationPath.getLastPathComponent();
1309
+ destinationLeaf = (Composite) destinationPath.getLastPathComponent();
11081310 } catch (Exception e) {
11091311 System.out.println("destinationPath : " + destinationPath);
11101312 return;
11111313 }
11121314
1113
- if (dtde.getDropAction() == DnDConstants.ACTION_MOVE) // ?? LINK)
1315
+ for (int i=group.selection.size(); --i>=0;)
11141316 {
1317
+ Object3D child = (Object3D)group.selection.elementAt(i);
1318
+
1319
+ // Cannot move into itself
1320
+ if (child == destinationLeaf)
1321
+ return;
1322
+ }
1323
+
1324
+// june 2019 if (dtde.getDropAction() == DnDConstants.ACTION_MOVE) // ?? LINK)
1325
+// {
11151326 loadClipboard(true);
11161327 objEditor.jTree.setSelectionPath(destinationPath);
11171328 pasteInto(false, false);
1118
- } else {
1119
- loadClipboard(false);
1120
- objEditor.jTree.setSelectionPath(destinationPath);
1121
- pasteInto(false, false); // true); // ???
1122
- }
1329
+// } else {
1330
+// loadClipboard(false);
1331
+// objEditor.jTree.setSelectionPath(destinationPath);
1332
+// pasteInto(false, false); // true); // ???
1333
+// }
11231334 }
11241335 public void dropActionChanged(DropTargetDragEvent dtde)
11251336 // Called if the user has modified the current drop gesture
....@@ -1224,22 +1435,30 @@
12241435 {
12251436 //heightFieldItem = menu.add(new MenuItem("Height Field"));
12261437 //heightFieldItem.addActionListener(this);
1227
- gridItem = menu.add(new MenuItem("Grid"));
1228
- gridItem.addActionListener(this);
1229
- rectoidItem = menu.add(new MenuItem("Box"));
1230
- rectoidItem.addActionListener(this);
1231
- ellipsoidItem = menu.add(new MenuItem("Sphere"));
1232
- ellipsoidItem.addActionListener(this);
1233
- coneItem = menu.add(new MenuItem("Cone"));
1234
- coneItem.addActionListener(this);
1235
- torusItem = menu.add(new MenuItem("Torus"));
1236
- torusItem.addActionListener(this);
1237
- superItem = menu.add(new MenuItem("Superellipsoid"));
1238
- superItem.addActionListener(this);
1438
+// gridItem = menu.add(new MenuItem("Grid"));
1439
+// gridItem.addActionListener(this);
1440
+// rectoidItem = menu.add(new MenuItem("Box"));
1441
+// rectoidItem.addActionListener(this);
1442
+// ellipsoidItem = menu.add(new MenuItem("Sphere"));
1443
+// ellipsoidItem.addActionListener(this);
1444
+// coneItem = menu.add(new MenuItem("Cone"));
1445
+// coneItem.addActionListener(this);
1446
+// torusItem = menu.add(new MenuItem("Torus"));
1447
+// torusItem.addActionListener(this);
1448
+// superItem = menu.add(new MenuItem("Superellipsoid"));
1449
+// superItem.addActionListener(this);
1450
+
1451
+ cameraItem = menu.add(new MenuItem("Camera"));
1452
+ cameraItem.addActionListener(this);
1453
+
1454
+ if (!Globals.ADVANCED)
1455
+ {
12391456 kleinItem = menu.add(new MenuItem("Klein Bottle"));
12401457 kleinItem.addActionListener(this);
1241
- particleItem = menu.add(new MenuItem("Particle system"));
1242
- particleItem.addActionListener(this);
1458
+ }
1459
+
1460
+// particleItem = menu.add(new MenuItem("Particle system"));
1461
+// particleItem.addActionListener(this);
12431462 if (Globals.ADVANCED)
12441463 {
12451464 ragdollItem = menu.add(new MenuItem("Rag Walk"));
....@@ -1265,15 +1484,15 @@
12651484 }
12661485 bezierItem = menu.add(new MenuItem("Bezier Patch"));
12671486 bezierItem.addActionListener(this);
1268
- overlayItem = menu.add(new MenuItem("Overlay"));
1269
- overlayItem.addActionListener(this);
1270
- lightItem = menu.add(new MenuItem("Light"));
1271
- lightItem.addActionListener(this);
1487
+// overlayItem = menu.add(new MenuItem("Overlay"));
1488
+// overlayItem.addActionListener(this);
1489
+// lightItem = menu.add(new MenuItem("Light"));
1490
+// lightItem.addActionListener(this);
12721491 menu.add("-");
12731492 //superLoopItem = menu.add(new MenuItem("Super Loop"));
12741493 //superLoopItem.addActionListener(this);
1275
- loopItem = menu.add(new MenuItem("Loop"));
1276
- loopItem.addActionListener(this);
1494
+// loopItem = menu.add(new MenuItem("Loop"));
1495
+// loopItem.addActionListener(this);
12771496 doubleItem = menu.add(new MenuItem("Fork"));
12781497 doubleItem.addActionListener(this);
12791498 if (Globals.ADVANCED)
....@@ -1289,6 +1508,9 @@
12891508 animationItem.addItemListener(this);
12901509 animationItem.setState(Globals.ANIMATION);
12911510
1511
+ menu.add(archiveItem = new MenuItem("Archive3D..."));
1512
+ archiveItem.addActionListener(this);
1513
+
12921514 menu.add("-");
12931515 parseverticesItem = menu.add(new MenuItem("Multiplicity"));
12941516 parseverticesItem.addActionListener(this);
....@@ -1301,6 +1523,8 @@
13011523 reduce34MorphItem = menu.add(new MenuItem("Reduce Morphs (34)"));
13021524 reduce34MorphItem.addActionListener(this);
13031525 menu.add("-");
1526
+ menu.add(memoryItem = new MenuItem("Memory Usage"));
1527
+ memoryItem.addActionListener(this);
13041528 menu.add(computeAOItem = new MenuItem("Compute AO"));
13051529 computeAOItem.addActionListener(this);
13061530
....@@ -1309,8 +1533,6 @@
13091533 mirrorItem = menu.add(new MenuItem("Mirror Poses"));
13101534 mirrorItem.addActionListener(this);
13111535 menu.add("-");
1312
- menu.add(memoryItem = new MenuItem("Memory Usage"));
1313
- memoryItem.addActionListener(this);
13141536 menu.add(analyzeItem = new MenuItem("Analyze"));
13151537 analyzeItem.addActionListener(this);
13161538 menu.add(dumpItem = new MenuItem("Print"));
....@@ -1454,9 +1676,34 @@
14541676 shadow.material = new cMaterial(obj.material);
14551677 shadow.material.diffuse = 0.0001f;
14561678 shadow.material.specular = 0.0001f;
1679
+ //shadow.projectedVertices[1].x = 300;
14571680
14581681 makeSomething(shadow);
14591682 }
1683
+
1684
+ private void ClearUnpinned()
1685
+ {
1686
+ //for (Object3D obj : listUI)
1687
+ for (int i=listUI.size(); --i>=0;)
1688
+ {
1689
+ Object3D obj = listUI.elementAt(i);
1690
+ if (!obj.pinned)
1691
+ {
1692
+ obj.CloseUI();
1693
+ listUI.remove(i);
1694
+ }
1695
+ }
1696
+ }
1697
+
1698
+ private void EditElement(Object3D elem, boolean newWindow)
1699
+ {
1700
+ // if (!(elem instanceof Composite))
1701
+ // newWindow = false;
1702
+ listUI.add(elem);
1703
+ elem.openEditWindow(this, newWindow); //, false);
1704
+ System.out.println("edit : " + elem);
1705
+ elem.editWindow.refreshContents(true); // ? new
1706
+ }
14601707
14611708 /**
14621709 * applyExample
....@@ -1701,7 +1948,7 @@
17011948 {
17021949 ScreenFit();
17031950 } else
1704
- if (source == switchItem)
1951
+ if (source == switchViewItem)
17051952 {
17061953 cVector v1 = new cVector();
17071954 cVector v2 = new cVector();
....@@ -1710,11 +1957,11 @@
17101957 objEditor.cameraView.renderCamera.setAim(v2, v1);
17111958 objEditor.cameraView.repaint();
17121959 } else
1713
- if (source == rectoidItem)
1960
+ if (source == rectoidItem || source == boxButton)
17141961 {
17151962 makeSomething(new Box());
17161963 } else
1717
- if (source == particleItem)
1964
+ if (source == particleItem || source == particlesButton)
17181965 {
17191966 ParticleNode particleGeom = new ParticleNode("Particles", 1000); //, particleType);
17201967 ParticleController particleController = new ParticleController(particleGeom);
....@@ -1793,27 +2040,27 @@
17932040
17942041 makeSomething(obj);
17952042 } else
1796
- if (source == gridItem)
2043
+ if (source == gridItem || source == gridButton)
17972044 {
17982045 makeSomething(new Grid());
17992046 } else
1800
- if (source == ellipsoidItem)
2047
+ if (source == ellipsoidItem || source == sphereButton)
18012048 {
18022049 makeSomething(new Sphere());
18032050 } else
1804
- if (source == coneItem)
2051
+ if (source == coneItem || source == coneButton)
18052052 {
18062053 makeSomething(new Cone());
18072054 } else
1808
- if (source == torusItem)
2055
+ if (source == torusItem || source == torusButton)
18092056 {
18102057 makeSomething(new Torus());
18112058 } else
1812
- if (source == superItem)
2059
+ if (source == superItem || source == superButton)
18132060 {
18142061 makeSomething(new Superellipsoid());
18152062 } else
1816
- if (source == kleinItem)
2063
+ if (source == kleinItem || source == kleinButton)
18172064 {
18182065 makeSomething(new Klein());
18192066 } else
....@@ -1833,7 +2080,7 @@
18332080 {
18342081 makeSomething(new BezierSurface());
18352082 } else
1836
- if (source == overlayItem)
2083
+ if (source == overlayItem || source == overlayButton)
18372084 {
18382085 /*
18392086 Object3D obj = new BezierSurface(5,8);
....@@ -1881,7 +2128,7 @@
18812128 s.setup();
18822129 makeSomething(s);
18832130 } else
1884
- if (source == lightItem)
2131
+ if (source == lightItem || source == lightButton)
18852132 {
18862133 makeSomething(new Light());
18872134 } else
....@@ -1931,30 +2178,30 @@
19312178
19322179 group(g);
19332180 } else
1934
- if (source == loopItem)
2181
+ if (source == loopItem || source == loopButton)
19352182 {
19362183 Composite csg = new GroupLeaf();
19372184 csg.count = 5;
19382185 group(csg);
1939
- Composite child = new cGroup();
2186
+ Composite child = new cGroup("Branch");
19402187 csg.addChild(child);
19412188 child.addChild(csg);
19422189 } else
19432190 if (source == doubleItem)
19442191 {
1945
- Composite csg = new GroupLeaf();
2192
+ Composite csg = new GroupLeaf("Fork");
19462193 csg.count = 5;
19472194 group(csg);
1948
- Composite child = new cGroup();
2195
+ Composite child = new cGroup("Branch A");
19492196 csg.addChild(child);
19502197 child.addChild(csg);
1951
- child = new cGroup();
2198
+ child = new cGroup("Branch B");
19522199 csg.addChild(child);
19532200 child.addChild(csg);
19542201 } else
19552202 if (source == tripleItem)
19562203 {
1957
- Composite csg = new GroupLeaf();
2204
+ Composite csg = new GroupLeaf("Trident");
19582205 csg.count = 4;
19592206 group(csg);
19602207 Composite child = new cGroup();
....@@ -2018,15 +2265,31 @@
20182265 } else
20192266 if (source == undoButton)
20202267 {
2268
+ // Go to previous version
2269
+ //if (!Undo())
2270
+ //java.awt.Toolkit.getDefaultToolkit().beep();
20212271 Undo();
2272
+ } else
2273
+ if (source == restoreButton)
2274
+ {
2275
+ // Restore current version
2276
+ Restore();
2277
+ } else
2278
+ if (source == replaceButton)
2279
+ {
2280
+ // Overwrite current version
2281
+ Replace();
20222282 } else
20232283 if (source == redoButton)
20242284 {
2285
+ // Go to next version
20252286 Redo();
20262287 } else
20272288 if (source == saveButton)
20282289 {
2029
- Save();
2290
+ // Save a new version
2291
+ if (!Save(true))
2292
+ java.awt.Toolkit.getDefaultToolkit().beep();
20302293 } else
20312294 if (source == oneStepButton)
20322295 {
....@@ -2035,17 +2298,14 @@
20352298 } else
20362299 if (source == screenfitButton)
20372300 {
2038
- //Reload(lastConverter, lastFilename, true);
20392301 ScreenFit();
20402302 } else
20412303 if (source == screenfitpointButton)
20422304 {
2043
- //Reload(lastConverter, lastFilename, true);
20442305 ScreenFitPoint();
20452306 } else
20462307 if (source == snapobjectButton)
20472308 {
2048
- //Reload(lastConverter, lastFilename, true);
20492309 SnapObject();
20502310 } else
20512311 // if (event.getSource() == recompileButton)
....@@ -2409,7 +2669,7 @@
24092669 {
24102670 StepAll();
24112671 } else
2412
- if (source == clearItem) // || event.getSource() == clearButton)
2672
+ if (source == deleteItem) // || event.getSource() == clearButton)
24132673 {
24142674 //int indices[] = jList.getSelectedIndices();
24152675 //for (int i = indices.length - 1; i >= 0; i--)
....@@ -2421,9 +2681,9 @@
24212681 {
24222682 ClearSelection(true);
24232683 } else
2424
- if (source == grabItem)
2684
+ if (source == grabItem || source == groupButton)
24252685 {
2426
- group(new cGroup(), true);
2686
+ group(new cGroup(), false); // true);
24272687 } else
24282688 if (source == hideItem)
24292689 {
....@@ -2441,11 +2701,11 @@
24412701 {
24422702 makeSomething(new Camera());
24432703 } else
2444
- if (source == compositeItem)
2704
+ if (source == compositeItem || source == compositeButton)
24452705 {
24462706 group(new Composite());
24472707 } else
2448
- if (source == randomItem)
2708
+ if (source == switchItem || source == switchButton)
24492709 {
24502710 RandomNode random = new RandomNode();
24512711 group(random);
....@@ -2547,7 +2807,7 @@
25472807 {
25482808 group(new cLinker());
25492809 } else
2550
- if (source == textureItem)
2810
+ if (source == textureItem || source == textureButton)
25512811 {
25522812 group(new TextureNode());
25532813 } else
....@@ -2567,17 +2827,30 @@
25672827 {
25682828 CastShadow(2);
25692829 } else
2570
- if (source == ungroupItem)
2830
+ if (source == ungroupItem || source == ungroupButton)
25712831 {
2572
- //ungroup();
2832
+ boolean hasRoot = false;
2833
+
25732834 for (int i=0; i<group.selection.size(); i++)
25742835 {
2575
- Ungroup(group.selection.get(i));
2836
+ if (group.selection.get(i) == group)
2837
+ {
2838
+ hasRoot = true;
2839
+ break;
2840
+ }
25762841 }
25772842
2578
- ClearSelection(false);
2579
-
2580
- refreshContents();
2843
+ if (!hasRoot)
2844
+ {
2845
+ for (int i=0; i<group.selection.size(); i++)
2846
+ {
2847
+ Ungroup(group.selection.get(i));
2848
+ }
2849
+
2850
+ ClearSelection(false);
2851
+
2852
+ refreshContents();
2853
+ }
25812854 } else
25822855 if (source == genUVItem)
25832856 {
....@@ -2905,6 +3178,10 @@
29053178 if (source == twoButton)
29063179 {
29073180 radio.layout = twoButton;
3181
+
3182
+ if (CameraPane.FULLSCREEN)
3183
+ fullscreenLayout = radio.layout;
3184
+
29083185 // bug
29093186 //gridPanel.setDividerLocation(1.0);
29103187 //bigPanel.setDividerLocation(0.0);
....@@ -2960,6 +3237,9 @@
29603237 {
29613238 radio.layout = threeButton;
29623239
3240
+ if (CameraPane.FULLSCREEN)
3241
+ fullscreenLayout = radio.layout;
3242
+
29633243 // bigThree.remove(scenePanel);
29643244 // bigThree.remove(centralPanel);
29653245 // bigThree.remove(XYZPanel);
....@@ -2998,6 +3278,9 @@
29983278 {
29993279 radio.layout = fourButton;
30003280
3281
+ if (CameraPane.FULLSCREEN)
3282
+ fullscreenLayout = radio.layout;
3283
+
30013284 // bigThree.remove(scenePanel);
30023285 // bigThree.remove(centralPanel);
30033286 // bigThree.remove(XYZPanel);
....@@ -3034,6 +3317,9 @@
30343317 if (source == sixButton)
30353318 {
30363319 radio.layout = sixButton;
3320
+
3321
+ if (CameraPane.FULLSCREEN)
3322
+ fullscreenLayout = radio.layout;
30373323
30383324 // bigThree.remove(scenePanel);
30393325 // bigThree.remove(centralPanel);
....@@ -3072,6 +3358,9 @@
30723358 if (source == sevenButton)
30733359 {
30743360 radio.layout = sevenButton;
3361
+
3362
+ if (CameraPane.FULLSCREEN)
3363
+ fullscreenLayout = radio.layout;
30753364
30763365 // bigThree.remove(scenePanel);
30773366 // bigThree.remove(centralPanel);
....@@ -3128,12 +3417,19 @@
31283417 for (Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
31293418 {
31303419 ab = (cRadio)e.nextElement();
3131
- if(ab.getModel().isSelected() && ab.GetObject() != client)
3420
+ if (ab.getModel().isSelected() && ab.GetObject() != client)
31323421 {
3422
+ // Patch to avoid bug with transparency.
3423
+ if (!ab.hadMaterial)
3424
+ {
3425
+ ab.object.material = null;
3426
+ }
3427
+
31333428 buttonGroup.remove(ab);
31343429 radioPanel.remove(ab);
31353430
3136
- ab.GetObject().editWindow = null;
3431
+ //ab.GetObject().editWindow = null;
3432
+ ab.GetObject().manipWindow = null;
31373433 // ab.GetObject().objectUI = null; // ?????????
31383434
31393435 ((cRadio)radioPanel.getComponent(radioPanel.getComponentCount() - 1)).doClick();
....@@ -3146,6 +3442,12 @@
31463442 } else
31473443 if (source == editItem || source == editButton)
31483444 {
3445
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
3446
+ {
3447
+ Object3D child = (Object3D)e.nextElement();
3448
+ child.pinned = true;
3449
+ }
3450
+
31493451 EditSelection(false);
31503452 } else
31513453 if (source == uneditButton)
....@@ -3155,6 +3457,7 @@
31553457 Object3D child = (Object3D)e.nextElement();
31563458 if(child.editWindow != null)
31573459 objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
3460
+ child.pinned = false;
31583461 child.CloseUI();
31593462 listUI.remove(child);
31603463
....@@ -3171,6 +3474,7 @@
31713474 //copy.ClearUI();
31723475 for (Object3D obj : listUI)
31733476 {
3477
+ obj.pinned = false;
31743478 obj.CloseUI();
31753479 }
31763480 listUI.clear();
....@@ -3180,7 +3484,7 @@
31803484 {
31813485 assert(copy == group);
31823486
3183
- objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
3487
+ //objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
31843488
31853489 for (Object3D obj : listUI)
31863490 {
....@@ -3229,6 +3533,9 @@
32293533 }
32303534
32313535 copy = group;
3536
+
3537
+ SetUndoStates();
3538
+
32323539 //Globals.theRenderer.object = group;
32333540 if(!useclient)
32343541 {
....@@ -3247,6 +3554,7 @@
32473554
32483555 // fix "+" issue
32493556 //group.editWindow = this;
3557
+ group.manipWindow = this;
32503558
32513559 /*
32523560 currentLayout = radio.layout;
....@@ -3254,6 +3562,13 @@
32543562 currentLayout = sevenButton;
32553563 */
32563564 radio.layout.doClick();
3565
+
3566
+ ClearUnpinned();
3567
+ //Grafreed.Assert(group != null);
3568
+ //Grafreed.Assert(group.selection != null);
3569
+ SetPinStates(group.selection == null || group.selection.size() > 0);
3570
+ if (group.selection == null || group.selection.size() == 1)
3571
+ EditSelection(false);
32573572 keepparent = group.parent;
32583573 // PARENT = NULL or not???
32593574 //group.parent = null; // ROOT
....@@ -3267,7 +3582,7 @@
32673582 cameraView.ProtectCamera();
32683583 cameraView.repaint();
32693584 return;
3270
- } else if (event.getSource() == revertCameraItem)
3585
+ } else if (event.getSource() == restoreCameraItem || event.getSource() == restoreCameraButton)
32713586 {
32723587 cameraView.RevertCamera();
32733588 cameraView.repaint();
....@@ -4321,28 +4636,25 @@
43214636 // }
43224637 // }
43234638
4324
- static boolean allparams = true;
4325
-
4326
- static Vector<Object3D> listUI = new Vector<Object3D>();
4327
-
43284639 void EditSelection(boolean newWindow)
43294640 {
4641
+ if (group.selection == null)
4642
+ {
4643
+ EditElement(group, newWindow); // ? new
4644
+ return;
4645
+ }
4646
+
43304647 // aConstraints.gridy = 0;
43314648 for (int i=0; i<group.selection.size(); i++)
43324649 {
43334650 //System.out.println("edit : " + objectPanel.indexOfTab("Material"));
43344651 //objectPanel.setEnabledAt(objectPanel.indexOfTab("Material"), false);
4335
- objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
4652
+ //objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
43364653
43374654 Object3D elem = (Object3D)group.selection.elementAt(i);
43384655 if(elem != group || !newWindow)
43394656 {
4340
- // if (!(elem instanceof Composite))
4341
- // newWindow = false;
4342
- listUI.add(elem);
4343
- elem.openEditWindow(this, newWindow); //, false);
4344
- System.out.println("edit : " + elem);
4345
- elem.editWindow.refreshContents(true); // ? new
4657
+ EditElement(elem, newWindow); // ? new
43464658 }
43474659 }
43484660 }
....@@ -4417,7 +4729,8 @@
44174729 //new Exception().printStackTrace();
44184730
44194731 freezemodel = true;
4420
-
4732
+ ClearUnpinned();
4733
+
44214734 /**/
44224735 //switch (event.id)
44234736 {
....@@ -4450,7 +4763,7 @@
44504763 if (tps != null && tps.length > 0 && tps[0].getLastPathComponent() instanceof Camera)
44514764 // a camera
44524765 {
4453
- if (tps[0].getLastPathComponent() != Globals.theRenderer.LightCamera())
4766
+ if (tps[0].getLastPathComponent() != Globals.theRenderer.LightCamera()) // Crash the camera because of invalid lightspace
44544767 {
44554768 CameraPane.camerachangeframe = 0; // don't refuse it
44564769 Globals.theRenderer.SetCamera((Camera) tps[0].getLastPathComponent());
....@@ -4459,6 +4772,13 @@
44594772 // Globals.theRenderer.eyeCamera = Globals.theRenderer.manipCamera;
44604773 }
44614774
4775
+ if (tps != null && tps.length == 1)
4776
+ {
4777
+ EditSelection(false);
4778
+ }
4779
+
4780
+ SetPinStates(tps != null && tps.length > 0);
4781
+
44624782 refreshContents();
44634783 //return true;
44644784 }
....@@ -4468,9 +4788,18 @@
44684788 freezemodel = false;
44694789 }
44704790
4791
+ void SetPinStates(boolean enabled)
4792
+ {
4793
+ editButton.setEnabled(enabled);
4794
+ uneditButton.setEnabled(enabled);
4795
+ unselectButton.setEnabled(enabled);
4796
+ flashSelectionButton.setEnabled(enabled);
4797
+ }
4798
+
44714799 void refreshContents(boolean cp)
44724800 {
4473
- if (!Globals.MOUSEDRAGGED)
4801
+ if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Info"))
4802
+ if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
44744803 {
44754804 objEditor.ClearInfo(); // .GetMaterial());
44764805
....@@ -4569,7 +4898,8 @@
45694898
45704899 if (cut)
45714900 {
4572
- Save();
4901
+// if (Globals.SAVEONMAKE) // Moved to the clipboard, no need to save.
4902
+// Save();
45734903 //int indices[] = jList.getSelectedIndices();
45744904 //for (int i = indices.length - 1; i >= 0; i--)
45754905 //jList.remove(indices[i]);
....@@ -4672,6 +5002,10 @@
46725002
46735003 void paste(boolean expand)
46745004 {
5005
+ if (Globals.REPLACEONMAKE)
5006
+ Save();
5007
+ boolean keep = Globals.REPLACEONMAKE;
5008
+ Globals.REPLACEONMAKE = false;
46755009 // if (GrafreeD.clipboard == null)
46765010 // return;
46775011 boolean first = true;
....@@ -4731,6 +5065,7 @@
47315065 Grafreed.clipboard.get(0).parent = keepparent;
47325066 }
47335067
5068
+ Globals.REPLACEONMAKE = keep;
47345069 ResetModel();
47355070 refreshContents();
47365071 }
....@@ -4866,6 +5201,10 @@
48665201
48675202 void group(Object3D csg, boolean grab)
48685203 {
5204
+ if (Globals.REPLACEONMAKE)
5205
+ Save();
5206
+ boolean keep = Globals.REPLACEONMAKE;
5207
+ Globals.REPLACEONMAKE = false;
48695208 if (//false) // why??
48705209 !group.selection.isEmpty())
48715210 {
....@@ -4979,10 +5318,15 @@
49795318 //node.add(csg);
49805319 //makeSomething(node);
49815320 makeSomething(csg);
5321
+ Globals.REPLACEONMAKE = keep;
49825322 }
49835323
49845324 void Ungroup(Object3D g)
49855325 {
5326
+ if (Globals.REPLACEONMAKE)
5327
+ Save();
5328
+ boolean keep = Globals.REPLACEONMAKE;
5329
+ Globals.REPLACEONMAKE = false;
49865330 if (g instanceof HiddenObject)
49875331 {
49885332 HiddenObject h = (HiddenObject) g;
....@@ -4999,6 +5343,7 @@
49995343 objEditor.makeSomething(g.get(i), false);
50005344 }
50015345 }
5346
+ Globals.REPLACEONMAKE = keep;
50025347 }
50035348
50045349 void ungroup()
....@@ -5287,13 +5632,28 @@
52875632 cButton clearpanelButton;
52885633 cButton unselectButton;
52895634
5290
- cButton minButton;
5291
- cButton maxButton;
5292
- cButton fullButton;
5293
- cButton undoButton;
5294
- cButton redoButton;
5635
+ cButton restoreCameraButton;
5636
+
52955637 cButton saveButton;
52965638 cButton oneStepButton;
5639
+
5640
+ cButton groupButton;
5641
+ cButton ungroupButton;
5642
+ cButton compositeButton;
5643
+ cButton switchButton;
5644
+ cButton loopButton;
5645
+ cButton textureButton;
5646
+
5647
+ cButton gridButton;
5648
+ cButton boxButton;
5649
+ cButton sphereButton;
5650
+ cButton coneButton;
5651
+ cButton torusButton;
5652
+ cButton superButton;
5653
+ cButton kleinButton;
5654
+ cButton particlesButton;
5655
+ cButton overlayButton;
5656
+ cButton lightButton;
52975657
52985658 cButton screenfitButton;
52995659 cButton screenfitpointButton;
....@@ -5315,11 +5675,11 @@
53155675 //JTree jTree;
53165676 private MenuItem lookAtItem;
53175677 private MenuItem lookFromItem;
5318
- private MenuItem switchItem;
5678
+ private MenuItem switchViewItem;
53195679 private MenuItem cutItem;
53205680 private MenuItem undoItem;
53215681 private MenuItem redoItem;
5322
- private MenuItem duplicateItem;
5682
+ private JMenuItem duplicateItem;
53235683 private MenuItem cloneItem;
53245684 private MenuItem cloneSupportItem;
53255685 private MenuItem overwriteGeoItem;
....@@ -5347,7 +5707,7 @@
53475707 private MenuItem pasteLinkItem;
53485708 private MenuItem pasteCloneItem;
53495709 private MenuItem pasteExpandItem;
5350
- private MenuItem clearItem;
5710
+ private MenuItem deleteItem;
53515711 private MenuItem clearAllItem;
53525712 private MenuItem genUVItem;
53535713 private MenuItem genNormalsMESHItem;
....@@ -5407,7 +5767,7 @@
54075767 private MenuItem frontItem;
54085768 private MenuItem cameraItem;
54095769 private MenuItem compositeItem;
5410
- private MenuItem randomItem;
5770
+ private MenuItem switchItem;
54115771 private MenuItem physicsItem;
54125772 private MenuItem frameselectorItem;
54135773 private MenuItem scriptNodeItem;
....@@ -5481,5 +5841,5 @@
54815841
54825842 Menu cameraMenu;
54835843 MenuItem editCameraItem;
5484
- MenuItem revertCameraItem;
5844
+ MenuItem restoreCameraItem;
54855845 }