From 89b25e7cc97f6fe221dfd41c4d463500f8a31bc1 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Tue, 25 Jun 2019 23:58:09 -0400
Subject: [PATCH] Edit panel pin state.

---
 GroupEditor.java | 1155 +++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 828 insertions(+), 327 deletions(-)

diff --git a/GroupEditor.java b/GroupEditor.java
index e205d0c..502ff05 100644
--- a/GroupEditor.java
+++ b/GroupEditor.java
@@ -74,7 +74,7 @@
 		this.copy = this.group = copy;
 		//selectees = this.group.selectees;
 		
-		SetupMenu2(objEditor);
+		SetupMenu2(this); //objEditor);
 		SetupUI2(objEditor);
 		objEditor.SetupUI(true);
 		SetupViews(objEditor);
@@ -98,14 +98,14 @@
 
     void CloneClipboard(boolean supports)
     {
-        assert(GrafreeD.clipboard.parent == null);
-        Object3D /*Composite*/ keepparent = GrafreeD.clipboard.get(0).parent;
-        GrafreeD.clipboard.get(0).parent = null; // Avoid copy?
-        if (LA.isIdentity(GrafreeD.clipboard.toParent))
-            makeSomething(CloneObject(GrafreeD.clipboard.get(0), false));
+        assert(Grafreed.clipboard.parent == null);
+        Object3D /*Composite*/ keepparent = Grafreed.clipboard.get(0).parent;
+        Grafreed.clipboard.get(0).parent = null; // Avoid copy?
+        if (LA.isIdentity(Grafreed.clipboard.toParent))
+            makeSomething(CloneObject(Grafreed.clipboard.get(0), false));
         else
-            makeSomething(CloneObject(GrafreeD.clipboard, false));
-        GrafreeD.clipboard.get(0).parent = keepparent;
+            makeSomething(CloneObject(Grafreed.clipboard, false));
+        Grafreed.clipboard.get(0).parent = keepparent;
     }
     
     static Object3D CloneObject(Object3D obj, boolean supports)
@@ -119,7 +119,7 @@
         //               obj.support = null;
         if (!supports)
             obj.SaveSupports();
-        Object3D clone = (Object3D)GrafreeD.clone(obj);
+        Object3D clone = (Object3D)Grafreed.clone(obj);
         obj.parent = parent;
         //               obj.support = support;
         //               clone.support = support; // aout 2013
@@ -148,28 +148,21 @@
         
     //JTextField nameField;
     
-	void SetupMenu2(ObjEditor oe)
+	void SetupMenu2(GroupEditor oe)
 	{
-        if (Globals.ADVANCED)
-        {
-		oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest"));
-		//cameraMenu.add(lookFromItem = new MenuItem("Look From Selection"));
-		//cameraMenu.add(switchItem = new MenuItem("Reverse View"));
-		editLeafItem = oe.cameraMenu.add(new MenuItem("Edit Leaf"));
-		oe.cameraMenu.add("-");
-		openWindowItem =  oe.cameraMenu.add(new MenuItem("Edit copy..."));
-		openWindowItem.addActionListener(this);
-		editLeafItem.addActionListener(this);
-		lookAtItem.addActionListener(this);
-		//lookFromItem.addActinoListener(this);
-		//switchItem.addActionListener(this);
-        }
-        
+                oe.jTree = new cTree();
+
 		Menu menu;
 		oe.menuBar.add(menu = new Menu("Edit"));
 		//editItem = menu.add(new MenuItem("Edit"));
 		//editItem.addActionListener(this);
-		duplicateItem = menu.add(new MenuItem("Duplicate"));
+                
+//		undoItem = menu.add(new MenuItem("Undo"));
+//		undoItem.addActionListener(this);
+//		redoItem = menu.add(new MenuItem("Redo"));
+//		redoItem.addActionListener(this);
+//		menu.add("-");
+		duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate"));
 		duplicateItem.addActionListener(this);
 		cloneItem = menu.add(new MenuItem("Clone"));
 		cloneItem.addActionListener(this);
@@ -185,7 +178,6 @@
 		copyItem.addActionListener(this);
 		pasteItem = menu.add(new MenuItem("Paste"));
 		pasteItem.addActionListener(this);
-		menu.add("-");
                 
 		menu.add("-");
 		pasteIntoItem = menu.add(new MenuItem("Paste into"));
@@ -206,14 +198,97 @@
 		clearAllItem = menu.add(new MenuItem("Clear All"));
 		clearAllItem.addActionListener(this);
         }
+        
+        menuBar.add(cameraMenu = new Menu("View"));
+        //cameraMenu.add(zBufferItem = new CheckboxMenuItem("Z Buffer"));
+        //zBufferItem.addActionListener(this);
+        //cameraMenu.add(normalLensItem = new MenuItem("Normal Lens"));
+        //normalLensItem.addActionListener(this);
+        cameraMenu.add(restoreCameraItem = new MenuItem("Restore Viewpoint"));
+        restoreCameraItem.addActionListener(this);
+        
+//        cameraMenu.add(toggleFullScreenItem = new CheckboxMenuItem("Full Screen"));
+//        toggleFullScreenItem.addItemListener(this);
+//        toggleFullScreenItem.setState(CameraPane.FULLSCREEN);
+//        cameraMenu.add("-");
+//        
+//        cameraMenu.add(toggleTextureItem = new CheckboxMenuItem("Texture"));
+//        toggleTextureItem.addItemListener(this);
+//        toggleTextureItem.setState(CameraPane.textureon);
+//        
+//        cameraMenu.add(toggleSwitchItem = new CheckboxMenuItem("Switch"));
+//        toggleSwitchItem.addItemListener(this);
+//        toggleSwitchItem.setState(CameraPane.SWITCH);
+        
+        cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Handles"));
+        toggleHandleItem.addItemListener(this);
+        toggleHandleItem.setState(CameraPane.HANDLES);
+        
+        cameraMenu.add(togglePaintItem = new CheckboxMenuItem("Paint mode"));
+        togglePaintItem.addItemListener(this);
+        togglePaintItem.setState(CameraPane.PAINTMODE);
+        
+        if (Globals.ADVANCED)
+        {
+        cameraMenu.add("-");
+                cameraMenu.add(toggleLiveItem = new CheckboxMenuItem("Live"));
+                toggleLiveItem.addItemListener(this);
+                toggleLiveItem.setState(Globals.isLIVE());
 
+                cameraMenu.add(stepItem = new MenuItem("Step"));
+                stepItem.addActionListener(this);
+        //		cameraMenu.add(toggleDLItem = new CheckboxMenuItem("Display List"));
+        //		toggleDLItem.addItemListener(this);
+        //                toggleDLItem.setState(false);
+
+                cameraMenu.add(toggleRenderItem = new CheckboxMenuItem("Render"));
+                toggleRenderItem.addItemListener(this);
+                toggleRenderItem.setState(!CameraPane.frozen);
+
+                cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug"));
+                toggleDebugItem.addItemListener(this);
+                toggleDebugItem.setState(Globals.DEBUG);
+
+                cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum"));
+                toggleFrustumItem.addItemListener(this);
+                toggleFrustumItem.setState(CameraPane.FRUSTUM);
+
+                cameraMenu.add(toggleFootContactItem = new CheckboxMenuItem("Foot contact"));
+                toggleFootContactItem.addItemListener(this);
+                toggleFootContactItem.setState(CameraPane.FOOTCONTACT);
+                
+                cameraMenu.add(toggleTimelineItem = new CheckboxMenuItem("Timeline"));
+                toggleTimelineItem.addItemListener(this);
+        }
+        
+//		cameraMenu.add(toggleRootItem = new CheckboxMenuItem("Alternate Root"));
+//		toggleRootItem.addItemListener(this);
+//                    toggleRootItem.setState(false);
+//		cameraMenu.add(animationItem = new CheckboxMenuItem("Animation"));
+//		animationItem.addItemListener(this);
+//                    animationItem.setState(CameraPane.ANIMATION);
+        cameraMenu.add("-");
+        cameraMenu.add(editCameraItem = new MenuItem("Save Viewpoint"));
+        editCameraItem.addActionListener(this);
+        
+        if (Globals.ADVANCED)
+        {
+		oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest"));
+		//cameraMenu.add(lookFromItem = new MenuItem("Look From Selection"));
+		//cameraMenu.add(switchViewItem = new MenuItem("Reverse View"));
+		editLeafItem = oe.cameraMenu.add(new MenuItem("Edit Leaf"));
+		oe.cameraMenu.add("-");
+		openWindowItem =  oe.cameraMenu.add(new MenuItem("Edit copy..."));
+		openWindowItem.addActionListener(this);
+		editLeafItem.addActionListener(this);
+		lookAtItem.addActionListener(this);
+		//lookFromItem.addActinoListener(this);
+		//switchViewItem.addActionListener(this);
+        }
+        
 		oe.menuBar.add(menu = new Menu("Setting"));
         if (Globals.ADVANCED)
         {
-                resetMeshItem = menu.add(new MenuItem("Reset All"));
-		resetMeshItem.addActionListener(this);
-		stepAllItem = menu.add(new MenuItem("Step All"));
-		stepAllItem.addActionListener(this);
 		revertMeshItem = menu.add(new MenuItem("Revert Meshes"));
 		revertMeshItem.addActionListener(this);
 		resetreferencesItem = menu.add(new MenuItem("Reset Mesh References"));
@@ -253,21 +328,29 @@
         }
                 
 		oe.menuBar.add(menu = new Menu("Group"));
-		grabItem = menu.add(new MenuItem("Grab"));
-		grabItem.addActionListener(this);
+//		grabItem = menu.add(new MenuItem("Grab"));
+//		grabItem.addActionListener(this);
 		backItem = menu.add(new MenuItem("Back"));
 		backItem.addActionListener(this);
 		frontItem = menu.add(new MenuItem("Front"));
 		frontItem.addActionListener(this);
-		compositeItem = menu.add(new MenuItem("Composite"));
-		compositeItem.addActionListener(this);
+//		compositeItem = menu.add(new MenuItem("Composite"));
+//		compositeItem.addActionListener(this);
+                
+        if (Globals.ADVANCED)
+        {
 		hideItem = menu.add(new MenuItem("Hidden Group"));
 		hideItem.addActionListener(this);
+        }
 		ungroupItem = menu.add(new MenuItem("Ungroup"));
 		ungroupItem.addActionListener(this);
-		menu.add("-");
-		randomItem = menu.add(new MenuItem("Switch node"));
-		randomItem.addActionListener(this);
+                
+//		menu.add("-");
+//                
+//		switchItem = menu.add(new MenuItem("Switch node"));
+//		switchItem.addActionListener(this);
+        if (Globals.ADVANCED)
+        {
 		switchGeoItem = menu.add(new MenuItem("Switch Geometry"));
 		switchGeoItem.addActionListener(this);
 		switchTransfoItem = menu.add(new MenuItem("Switch Transform"));
@@ -275,8 +358,6 @@
 		morphItem = menu.add(new MenuItem("Morph Group"));
 		morphItem.addActionListener(this);
                 
-        if (Globals.ADVANCED)
-        {
 		menu.add("-");
 		physicsItem = menu.add(new MenuItem("Physics"));
 		physicsItem.addActionListener(this);
@@ -284,22 +365,20 @@
 		frameselectorItem.addActionListener(this);
 		scriptNodeItem = menu.add(new MenuItem("Script Node"));
 		scriptNodeItem.addActionListener(this);
-		cameraItem = menu.add(new MenuItem("Camera"));
-		cameraItem.addActionListener(this);
         }
                 
 		oe.menuBar.add(menu = new Menu("Object"));
-		textureItem = menu.add(new MenuItem("Texture"));
-		textureItem.addActionListener(this);
+//		textureItem = menu.add(new MenuItem("Texture"));
+//		textureItem.addActionListener(this);
 		billboardItem = menu.add(new MenuItem("Billboard"));
 		billboardItem.addActionListener(this);
 		csgItem = menu.add(new MenuItem("CSG"));
 		csgItem.addActionListener(this);
-                shadowXItem = menu.add(new MenuItem("Shadow X"));
+                shadowXItem = menu.add(new MenuItem("Shadow Red"));
 		shadowXItem.addActionListener(this);
-                shadowYItem = menu.add(new MenuItem("Shadow Y"));
+                shadowYItem = menu.add(new MenuItem("Shadow Green"));
 		shadowYItem.addActionListener(this);
-                shadowZItem = menu.add(new MenuItem("Shadow Z"));
+                shadowZItem = menu.add(new MenuItem("Shadow Blue"));
 		shadowZItem.addActionListener(this);
         if (Globals.ADVANCED)
         {
@@ -318,8 +397,12 @@
 		resetTransformItem.addActionListener(this);
 		resetCentroidItem = menu.add(new MenuItem("Reset Centroid"));
 		resetCentroidItem.addActionListener(this);
-		transformgeometryItem = menu.add(new MenuItem("Transform Geometry"));
-		transformgeometryItem.addActionListener(this);
+		resetCentroidXZItem = menu.add(new MenuItem("Reset Centroid XY"));
+		resetCentroidXZItem.addActionListener(this);
+		transformGeometryItem = menu.add(new MenuItem("Transform Geometry"));
+		transformGeometryItem.addActionListener(this);
+		transformChildrenItem = menu.add(new MenuItem("Transform Children"));
+		transformChildrenItem.addActionListener(this);
                 
 		oe.menuBar.add(menu = new Menu("Geometry"));
 		genUVItem = menu.add(new MenuItem("Generate UV"));
@@ -368,6 +451,10 @@
                 oe.menuBar.add(menu = new Menu("Attributes"));
 		clearMaterialsItem = menu.add(new MenuItem("Clear Materials"));
 		clearMaterialsItem.addActionListener(this);
+                resetAllItem = menu.add(new MenuItem("Reset All"));
+		resetAllItem.addActionListener(this);
+		stepAllItem = menu.add(new MenuItem("Step All"));
+		stepAllItem.addActionListener(this);
 		menu.add("-");
 		liveleavesItem = menu.add(new MenuItem("Live Leaves"));
 		liveleavesItem.addActionListener(this);
@@ -388,6 +475,14 @@
 		markleavesItem.addActionListener(this);
 		unmarkleavesItem = menu.add(new MenuItem("Unmark Leaves"));
 		unmarkleavesItem.addActionListener(this);
+		rewindleavesItem = menu.add(new MenuItem("Rewind Leaves"));
+		rewindleavesItem.addActionListener(this);
+		unrewindleavesItem = menu.add(new MenuItem("Unrewind Leaves"));
+		unrewindleavesItem.addActionListener(this);
+		randomleavesItem = menu.add(new MenuItem("Random Leaves"));
+		randomleavesItem.addActionListener(this);
+		unrandomleavesItem = menu.add(new MenuItem("Unrandom Leaves"));
+		unrandomleavesItem.addActionListener(this);
 		menu.add("-");
 		flipVItem = menu.add(new MenuItem("Flip V"));
 		flipVItem.addActionListener(this);
@@ -422,38 +517,41 @@
 		sortbysizeItem.addActionListener(this);
 		sortbynameItem = menu.add(new MenuItem("Sort by name"));
 		sortbynameItem.addActionListener(this);
+		menu.add("-");
+		shareGeometriesItem = menu.add(new MenuItem("Share Geometries"));
+		shareGeometriesItem.addActionListener(this);
+		mergeGeometriesItem = menu.add(new MenuItem("Merge Geometries"));
+		mergeGeometriesItem.addActionListener(this);
         if (Globals.ADVANCED)
         {
-		menu.add("-");
+            // Pretty much the same as duplicate and clone.
 		extractGeometriesItem = menu.add(new MenuItem("Link Geometry"));
 		extractGeometriesItem.addActionListener(this);
 		cloneGeometriesItem = menu.add(new MenuItem("Clone Geometry"));
 		cloneGeometriesItem.addActionListener(this);
-		shareGeometriesItem = menu.add(new MenuItem("Share Geometry"));
-		shareGeometriesItem.addActionListener(this);
-		mergeGeometriesItem = menu.add(new MenuItem("Merge Geometry"));
-		mergeGeometriesItem.addActionListener(this);
         }
                 
 		oe.menuBar.add(menu = new Menu("Insert"));
 		buildCreateMenu(menu);
                 
-                oe.menuBar.add(menu = new Menu("Include"));
-		importGFDItem = menu.add(new MenuItem("GrafreeD Object..."));
-		importGFDItem.addActionListener(this);
-		importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D Object..."));
-		importVRMLX3DItem.addActionListener(this);
-		importOBJItem = menu.add(new MenuItem("OBJ Object..."));
-		importOBJItem.addActionListener(this);
-		import3DSItem = menu.add(new MenuItem("3DS Object..."));
-		import3DSItem.addActionListener(this);
-
                 oe.menuBar.add(menu = new Menu("Tools"));
 		buildToolsMenu(menu);
 	}
 	
 	void SetupUI2(ObjEditor oe)
 	{
+            // June 2019
+            if (oe == null)
+            {
+                //super.SetupUI2(this);
+                //return;
+            }
+            
+            if (copy != group)
+            {
+                //super.SetupUI2(this);
+            }
+            
             //new Exception().printStackTrace();
                 
         oe.radioPanel = new JPanel(new GridBagLayout());
@@ -482,97 +580,212 @@
         oe.radioPanel.add(dummyButton);
         oe.buttonGroup.add(dummyButton);
          */
+                cGridBag copyOptionsPanel = new cGridBag();
+                                        
+                copyOptionsPanel.preferredHeight = 2;
+                
                 //this.AddOptions(oe.toolbarPanel, oe.aConstraints);
                 
-                oe.toolbarPanel.add(liveCB = new cCheckBox("Live", Globals.isLIVE())); //, oe.aConstraints);
-                liveCB.setToolTipText("Enabled animation");
+		//oe.toolbarPanel.add(minButton = new cButton("Min", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                //minButton.setToolTipText("Minimize window");
+		//minButton.addActionListener(this);
+                
+		oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                maxButton.setToolTipText("Maximize window");
+		maxButton.addActionListener(this);
+                
+		oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                fullButton.setToolTipText("Full-screen window");
+		fullButton.addActionListener(this);
+                
+		oe.toolbarPanel.add(restoreCameraButton = GetButton("icons/eye.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                restoreCameraButton.setToolTipText("Restore viewpoint");
+		restoreCameraButton.addActionListener(this);
+                
+		copyOptionsPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                undoButton.setToolTipText("Undo changes");
+		undoButton.addActionListener(this);
+                undoButton.setEnabled(false);
+                
+		copyOptionsPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                redoButton.setToolTipText("Redo changes");
+		redoButton.addActionListener(this);
+                redoButton.setEnabled(false);
+                
+		copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                saveButton.setToolTipText("Save changes");
+		saveButton.addActionListener(this);
+                
+                copyOptionsPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
+                liveCB.setToolTipText("Enable animation");
                                 liveCB.addItemListener(this);
 
-		oe.toolbarPanel.add(oneStepButton = new cButton("Step", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints);
+		copyOptionsPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 oneStepButton.setToolTipText("Animate one step forward");
 		oneStepButton.addActionListener(this);
                 
-                oe.toolbarPanel.add(fastCB = new cCheckBox("Fast", CameraPane.FAST)); //, constraints);
+                copyOptionsPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
                 fastCB.setToolTipText("Fast mode");
                                 fastCB.addItemListener(this);
                                 
-                oe.toolbarPanel.add(trackCB = new cCheckBox("Track", CameraPane.TRACK)); //, oe.aConstraints);
-                trackCB.setToolTipText("Enable tracking");
-                                trackCB.addItemListener(this);
-
-		oe.toolbarPanel.add(screenfitButton = new cButton("@", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints);
+                //oe.toolboxPanel.Return();
+                
+		copyOptionsPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 screenfitButton.setToolTipText("Screen fit");
 		screenfitButton.addActionListener(this);
+
+//                copyOptionsPanel.add(trackCB = GetToggleButton("icons/track.png", CameraPane.TRACK)); //, oe.aConstraints);
+//                trackCB.setToolTipText("Enable tracking");
+//                                trackCB.addItemListener(this);
 
 //		oe.toolbarPanel.add(screenfitpointButton = new cButton(" @+ ")); //, oe.aConstraints);
 //		screenfitpointButton.addActionListener(this);
 
                 if (Globals.ADVANCED)
                 {
-                        oe.toolbarPanel.add(snapobjectButton = new cButton("O+", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints);
+                        oe.toolbarPanel.add(snapobjectButton = new cButton("O+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                         snapobjectButton.addActionListener(this);
                         snapobjectButton.setToolTipText("Snap Object");
                 }
 
-		oe.toolbarPanel.add(flashSelectionButton = new cButton("?", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints);
-                flashSelectionButton.setToolTipText("Show selection");
-		flashSelectionButton.addActionListener(this);
+		//oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
                 
-		oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
-                
-		oe.toolbarPanel.add(twoButton = new cButton("|+|", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(twoButton = new cButton("|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 twoButton.setToolTipText("Show center view only");
 		twoButton.addActionListener(this);
-		oe.toolbarPanel.add(fourButton = new cButton("+||", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints);
+                this.fullscreenLayout = twoButton;
+                
+		oe.toolbarPanel.add(fourButton = new cButton("-||", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
 		fourButton.addActionListener(this);
                 fourButton.setToolTipText("Show left panel only");
-		oe.toolbarPanel.add(sixButton = new cButton("+|+|", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(sixButton = new cButton("-|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 sixButton.setToolTipText("2-column layout left");
 		sixButton.addActionListener(this);
-		oe.toolbarPanel.add(threeButton = new cButton("|+|+", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(threeButton = new cButton("|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 threeButton.setToolTipText("2-column layout right");
 		threeButton.addActionListener(this);
-		oe.toolbarPanel.add(sevenButton = new cButton("+|+|+", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 sevenButton.setToolTipText("3-column layout");
 		sevenButton.addActionListener(this);
                 //
 
-		oe.toolbarPanel.add(rootButton = new cButton("o o o", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(rootButton = GetButton("icons/write.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 rootButton.setToolTipText("Edit selection in new tab");
 		rootButton.addActionListener(this);
 
-                oe.toolbarPanel.add(closeButton = new cButton("X", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints);
+                oe.toolbarPanel.add(closeButton = GetButton("icons/close-icon.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 closeButton.setToolTipText("Close tab");
 		closeButton.addActionListener(this);
 		//oe.treePanel.add(clearButton = new cButton("X"), oe.aConstraints);
 		//clearButton.addActionListener(this);
-                        
-                cGridBag commandsPanel = new cGridBag();
+
+                // INSERT
+                oe.toolboxPanel.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                gridButton.setToolTipText("Create grid");
+                                gridButton.addActionListener(this);
+
+                oe.toolboxPanel.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                boxButton.setToolTipText("Create box");
+                                boxButton.addActionListener(this);
+
+                oe.toolboxPanel.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                sphereButton.setToolTipText("Create sphere");
+                                sphereButton.addActionListener(this);
+
+                oe.toolboxPanel.add(coneButton = GetButton("icons/cone.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                coneButton.setToolTipText("Create cone");
+                                coneButton.addActionListener(this);
+
+                oe.toolboxPanel.add(torusButton = GetButton("icons/torus.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                torusButton.setToolTipText("Create torus");
+                                torusButton.addActionListener(this);
+
+                oe.toolboxPanel.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                superButton.setToolTipText("Create superellipsoid");
+                                superButton.addActionListener(this);
+
+                if (Globals.ADVANCED)
+                {
+                    oe.toolboxPanel.add(kleinButton = GetButton("icons/klein.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                    kleinButton.setToolTipText("Create Klein bottle");
+                                    kleinButton.addActionListener(this);
+                }
                 
-		commandsPanel.add(editButton = new cButton("+", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints);
+                oe.toolboxPanel.add(particlesButton = GetButton("icons/particles.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                particlesButton.setToolTipText("Create particle system");
+                               particlesButton.addActionListener(this);
+
+                oe.toolboxPanel.Return();
+                
+                oe.toolboxPanel.add(groupButton = GetButton("icons/group.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                groupButton.setToolTipText("Create group");
+                               groupButton.addActionListener(this);
+
+                oe.toolboxPanel.add(compositeButton = GetButton("icons/composite.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                compositeButton.setToolTipText("Create composite");
+                               compositeButton.addActionListener(this);
+
+                oe.toolboxPanel.add(switchButton = GetButton("icons/switch.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                switchButton.setToolTipText("Create switch");
+                               switchButton.addActionListener(this);
+
+                oe.toolboxPanel.add(loopButton = GetButton("icons/loop.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                loopButton.setToolTipText("Create loop");
+                               loopButton.addActionListener(this);
+
+                oe.toolboxPanel.add(textureButton = GetButton("icons/texture.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                textureButton.setToolTipText("Create texture");
+                               textureButton.addActionListener(this);
+
+                oe.toolboxPanel.add(overlayButton = GetButton("icons/overlay.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                overlayButton.setToolTipText("Create overlay");
+                               overlayButton.addActionListener(this);
+
+                oe.toolboxPanel.add(lightButton = GetButton("icons/light-bulb.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                lightButton.setToolTipText("Create light");
+                               lightButton.addActionListener(this);
+
+                for (int i=6; --i>=0;)
+                {
+                oe.toolboxPanel.Return();
+                oe.toolboxPanel.add(new cGridBag());
+                oe.toolboxPanel.add(new cGridBag());
+                oe.toolboxPanel.add(new cGridBag());
+                oe.toolboxPanel.add(new cGridBag());
+                oe.toolboxPanel.add(new cGridBag());
+                oe.toolboxPanel.add(new cGridBag());
+                oe.toolboxPanel.add(new cGridBag());
+                }
+                
+                // EDIT panel
+		editCommandsPanel.add(editButton = new cButton("+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 editButton.setToolTipText("Edit selection");
 		editButton.addActionListener(this);
 
-		commandsPanel.add(uneditButton = new cButton("-", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints);
+		editCommandsPanel.add(uneditButton = new cButton("-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 uneditButton.setToolTipText("Unedit selection");
 		uneditButton.addActionListener(this);
 
-		commandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
+		editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
                 allParamsButton.setToolTipText("Edit all params");
 		allParamsButton.addActionListener(this);
 
-		commandsPanel.add(clearPanelButton = new cButton("C", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints);
+		editCommandsPanel.add(clearPanelButton = new cButton("C", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 clearPanelButton.setToolTipText("Clear edit panel");
 		clearPanelButton.addActionListener(this);
 
-		commandsPanel.add(unselectButton = new cButton("U", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints);
+		editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 unselectButton.setToolTipText("Unselect");
 		unselectButton.addActionListener(this);
 
-                commandsPanel.preferredHeight = 1;
+		editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                flashSelectionButton.setToolTipText("Highlight selection");
+		flashSelectionButton.addActionListener(this);
                 
-                oe.treePanel.add(commandsPanel);
-                oe.treePanel.Return();
+                editCommandsPanel.preferredHeight = 1;
+                
+//                oe.treePanel.add(commandsPanel);
+//                oe.treePanel.Return();
                 
 //		oe.aConstraints.gridx += 1;
 //		oe.aConstraints.weighty = 0;
@@ -589,27 +802,12 @@
 
                 JScrollPane jSP;
 		//ctrlPanel.add(new JScrollPane(jTree = new cTree(new cTreeModel(this))), aConstraints);
-		jSPPanel.add(jSP = new JScrollPane(oe.jTree = new cTree(null))); //, oe.aConstraints);
+		jSPPanel.add(jSP = new JScrollPane(oe.jTree)); //, oe.aConstraints);
                 ResetModel();
                 
                 oe.treePanel.add(jSPPanel);
                 oe.treePanel.Return();
 
-                cGridBag copyOptionsPanel = new cGridBag();
-                
-                copyOptionsPanel.add(colorCB = new cCheckBox("Color", (dropAttributes&Object3D.COLOR)!=0)); //, oe.aConstraints);
-                colorCB.setToolTipText("Copy color when dropped");
-                colorCB.addItemListener(this);
-
-                copyOptionsPanel.add(materialCB = new cCheckBox("Material", (dropAttributes&Object3D.MATERIAL)!=0)); //, oe.aConstraints);
-                materialCB.setToolTipText("Copy material when dropped");
-                materialCB.addItemListener(this);
-
-                copyOptionsPanel.add(textureCB = new cCheckBox("Texture", (dropAttributes&Object3D.TEXTURE)!=0)); //, oe.aConstraints);
-                textureCB.setToolTipText("Copy texture when dropped");
-                textureCB.addItemListener(this);
-                        
-                copyOptionsPanel.preferredHeight = 1;
                 oe.treePanel.add(copyOptionsPanel);
                 oe.treePanel.Return();
                 
@@ -640,6 +838,20 @@
         
         void AddOptions(cGridBag panel) //, GridBagConstraints constraints)
         {
+                panel.add(colorCB = new cCheckBox("Color", (dropAttributes&Object3D.COLOR)!=0)); //, oe.aConstraints);
+                colorCB.setToolTipText("Copy color when dropped");
+                colorCB.addItemListener(this);
+
+                panel.add(materialCB = new cCheckBox("Material", (dropAttributes&Object3D.MATERIAL)!=0)); //, oe.aConstraints);
+                materialCB.setToolTipText("Copy material when dropped");
+                materialCB.addItemListener(this);
+
+                panel.add(textureCB = new cCheckBox("Texture", (dropAttributes&Object3D.TEXTURE)!=0)); //, oe.aConstraints);
+                textureCB.setToolTipText("Copy texture when dropped");
+                textureCB.addItemListener(this);
+                
+                panel.Return();
+                
                 panel.add(boxCB = new cCheckBox("Box", CameraPane.BOXMODE)); //, constraints);
                 boxCB.setToolTipText("Display bounding boxes");
                                 boxCB.addItemListener(this);
@@ -648,7 +860,7 @@
                 zoomBoxCB.setToolTipText("Display bounding boxes when moving the wheel");
                                 zoomBoxCB.addItemListener(this);
 
-        if (Globals.ADVANCED)
+        if (true) // Globals.ADVANCED)
         {
                 panel.add(supportCB = new cCheckBox("Support", CameraPane.SUPPORT)); //, constraints);
                 supportCB.setToolTipText("Enable rigging");
@@ -657,6 +869,8 @@
         //        panel.add(localCB = new cCheckBox("Local", CameraPane.LOCALTRANSFORM), constraints);
         //                        localCB.addItemListener(this);
 
+                panel.Return();
+                
                 panel.add(crowdCB = new cCheckBox("Crowd", Globals.CROWD)); //, constraints);
                 crowdCB.setToolTipText("Used for crowds");
                                 crowdCB.addItemListener(this);
@@ -673,6 +887,8 @@
 //                panel.add(speakerMocapCB = new cCheckBox("Mocap", CameraPane.SPEAKERMOCAP), constraints);
 //                                speakerMocapCB.addItemListener(this);
 
+                panel.Return();
+                
             if (false)
             {
                 // handled in scripts
@@ -687,32 +903,72 @@
         	//constraints.gridy += 1;
                 panel.add(smoothfocusCB = new cCheckBox("Smooth", CameraPane.SMOOTHFOCUS)); //, constraints);
                                 smoothfocusCB.addItemListener(this);
+                panel.Return();
             }
 
 //constraints.gridx += 1;
 //panel.add(debugCB = new cCheckBox("Debug", CameraPane.DEBUG), constraints);
 //                debugCB.addItemListener(this);
 
+                panel.add(trackCB = new cCheckBox("Track", CameraPane.TRACK)); //, oe.aConstraints);
+                trackCB.setToolTipText("Enable tracking target");
+                                trackCB.addItemListener(this);
+                                
                 panel.add(oeilCB = new cCheckBox("Eye", CameraPane.OEIL)); //, constraints);
+                oeilCB.setToolTipText("Move camera when tracking");
                                 oeilCB.addItemListener(this);
 
+                panel.add(shadowCB = new cCheckBox("Shadow", Globals.COMPUTESHADOWWHENLIVE)); //, constraints);
+                shadowCB.setToolTipText("Compute shadows when live");
+                                shadowCB.addItemListener(this);
+
+                panel.Return();
+                panel.add(toggleTextureCB = new cCheckBox("Textures", CameraPane.textureon)); //, constraints);
+                toggleTextureCB.setToolTipText("Load textures");
+                                toggleTextureCB.addItemListener(this);
+                                
+                panel.add(toggleSwitchCB = new cCheckBox("Switch", CameraPane.SWITCH)); //, constraints);
+                toggleSwitchCB.setToolTipText("Use switch");
+                                toggleSwitchCB.addItemListener(this);
+                                
+                panel.add(autosaveCB = new cCheckBox("Auto-save", Globals.SAVEONMAKE)); //, constraints);
+                autosaveCB.setToolTipText("Auto-save on structure change");
+                                autosaveCB.addItemListener(this);
+
+                panel.Return();
+            if (Globals.ADVANCED)
+            {
                 panel.add(lookAtCB = new cCheckBox("Target", CameraPane.LOOKAT)); //, constraints);
                 lookAtCB.setToolTipText("Look-at target");
                                 lookAtCB.addItemListener(this);
+            }
                 
         }
                                 
                 cGridBag fill = new cGridBag();
-                                
                 fill.preferredHeight = 200;
+                cGridBag fill2 = new cGridBag();
+                fill2.preferredHeight = 200;
+                cGridBag fill3 = new cGridBag();
+                fill3.preferredHeight = 200;
                 
                 panel.add(fill);
+                panel.add(fill2);
+                panel.add(fill3);
 
         }
 	
         void EditObject(Object3D obj)
         {
             cRadio radioButton = new cRadio(obj.name);
+            
+            // Patch to avoid bug with transparency.
+            radioButton.hadMaterial = obj.material != null;
+            if (!radioButton.hadMaterial)
+            {
+                obj.material = new cMaterial();
+            }
+            
             radioButton.SetObject(obj);
             radioButton.layout = sevenButton;
             radioButton.SetCamera(cameraView.renderCamera, false);
@@ -721,8 +977,11 @@
             buttonGroup.add(radioButton);
             radioButton.doClick();
         }
+        
         void SetupViews(ObjEditor oe)
         {
+                    theFrame = this;
+                    
             oe.SetupViews();
             
 		System.out.println("SetupViews");
@@ -731,23 +990,27 @@
             /*DropTarget dropTarget =*/ new DropTarget(oe.cameraView, this);
         }
 
-        JCheckBox liveCB;
-        JCheckBox supportCB;
-        JCheckBox localCB;
-        JCheckBox crowdCB;
-        JCheckBox smoothCB;
-        JCheckBox fastCB;
-        JCheckBox slowCB;
-        JCheckBox boxCB;
-        JCheckBox zoomBoxCB;
-        JCheckBox trackCB;
-        JCheckBox smoothfocusCB;
+        cToggleButton liveCB;
+        cCheckBox supportCB;
+        cCheckBox localCB;
+        cCheckBox crowdCB;
+        cCheckBox smoothCB;
+        cToggleButton fastCB;
+        cCheckBox slowCB;
+        cCheckBox boxCB;
+        cCheckBox zoomBoxCB;
+        //cToggleButton trackCB;
+        cCheckBox trackCB;
+        cCheckBox smoothfocusCB;
 //        JCheckBox speakerMocapCB;
-        JCheckBox speakerCameraCB;
-        JCheckBox speakerFocusCB;
-        JCheckBox debugCB;
-        JCheckBox oeilCB;
-        JCheckBox lookAtCB;
+        cCheckBox speakerCameraCB;
+        cCheckBox speakerFocusCB;
+        cCheckBox debugCB;
+        
+        cCheckBox oeilCB;
+        cCheckBox shadowCB;
+        cCheckBox autosaveCB;
+        cCheckBox lookAtCB;
         
 //        static int COLOR = 1;
 //        static int MATERIAL = 2;
@@ -755,9 +1018,9 @@
         
         int dropAttributes = Object3D.COLOR | Object3D.MATERIAL;
         
-        JCheckBox colorCB;
-        JCheckBox materialCB;
-        JCheckBox textureCB;
+        cCheckBox colorCB;
+        cCheckBox materialCB;
+        cCheckBox textureCB;
         
         public void itemStateChanged(ItemEvent e)
         {
@@ -785,6 +1048,7 @@
             } else if(e.getSource() == liveCB)
             {
                 cameraView.ToggleLive();
+                refreshContents(false);
             }
             else if(e.getSource() == supportCB)
             {
@@ -849,6 +1113,14 @@
             {
                 cameraView.ToggleOeil();
             }
+            else if(e.getSource() == shadowCB)
+            {
+                Globals.COMPUTESHADOWWHENLIVE ^= true;
+            }
+            else if(e.getSource() == autosaveCB)
+            {
+                Globals.SAVEONMAKE ^= true;
+            }
             else if(e.getSource() == lookAtCB)
             {
                 cameraView.ToggleLookAt();
@@ -865,7 +1137,8 @@
 		
                 /**/
 		//DragSource.getDefaultDragSource().startDrag(dge, DragSource.DefaultMoveNoDrop, new StringSelection("Allo"), this);
-		TreePath path = new TreePath(objEditor.jTree.getSelectionPath().getLastPathComponent());
+		//TreePath path = new TreePath(objEditor.jTree.getSelectionPath().getLastPathComponent());
+		TreePath path = objEditor.jTree.getSelectionPath();
 		if ((path == null) || (path.getPathCount() <= 1)) {
 		  // We can't move the root node or an empty selection
 		  return;
@@ -937,7 +1210,9 @@
 //                        objEditor.DropFile((java.io.File[]) object, true);
 //                        return;
 //                    }
-                    if (string.charAt(0) == '/')
+                    
+                    // File path for Mac and Windows
+                    if (string.charAt(0) == '/' || string.charAt(1) == ':')
                     {
                         // file(s)
                         String[] names = string.split("\n");
@@ -964,7 +1239,7 @@
                     
                     flashIt = false;
                     CameraPane pane = (CameraPane) target;
-                    pane.clickStart(objEditor.location.x, objEditor.location.y, 0);
+                    pane.clickStart(objEditor.location.x, objEditor.location.y, 0, 0);
                     pane.clickEnd(objEditor.location.x, objEditor.location.y, 0, true);
                     
                     if (group.selection.size() == 1)
@@ -980,23 +1255,33 @@
                 
                 assert target == objEditor.jTree;
             TreePath destinationPath = objEditor.jTree.getPathForLocation(objEditor.location.x, objEditor.location.y);
+            Object3D destinationLeaf;
             try {
-                Object3D dummy = (Composite) destinationPath.getLastPathComponent();
+                destinationLeaf = (Composite) destinationPath.getLastPathComponent();
             } catch (Exception e) {
                 System.out.println("destinationPath : " + destinationPath);
                 return;
             }
 
-            if (dtde.getDropAction() == DnDConstants.ACTION_MOVE) // ?? LINK)
+            for (int i=group.selection.size(); --i>=0;) 
             {
+                    Object3D child = (Object3D)group.selection.elementAt(i);
+                    
+                    // Cannot move into itself
+                    if (child == destinationLeaf)
+                        return;
+            }
+                        
+// june 2019            if (dtde.getDropAction() == DnDConstants.ACTION_MOVE) // ?? LINK)
+//            {
                 loadClipboard(true);
                 objEditor.jTree.setSelectionPath(destinationPath);
                 pasteInto(false, false);
-            } else {
-                loadClipboard(false);
-                objEditor.jTree.setSelectionPath(destinationPath);
-                pasteInto(false, false); // true); // ???
-            }
+//            } else {
+//                loadClipboard(false);
+//                objEditor.jTree.setSelectionPath(destinationPath);
+//                pasteInto(false, false); // true); // ???
+//            }
 	}
 	public void	dropActionChanged(DropTargetDragEvent dtde) 
 	// Called if the user has modified the current drop gesture
@@ -1101,22 +1386,30 @@
 	{
 		//heightFieldItem = menu.add(new MenuItem("Height Field"));
 		//heightFieldItem.addActionListener(this);
-		gridItem = menu.add(new MenuItem("Grid"));
-		gridItem.addActionListener(this);
-		rectoidItem = menu.add(new MenuItem("Box"));
-		rectoidItem.addActionListener(this);
-		ellipsoidItem = menu.add(new MenuItem("Sphere"));
-		ellipsoidItem.addActionListener(this);
-		coneItem = menu.add(new MenuItem("Cone"));
-		coneItem.addActionListener(this);
-		torusItem = menu.add(new MenuItem("Torus"));
-		torusItem.addActionListener(this);
-		superItem = menu.add(new MenuItem("Superellipsoid"));
-		superItem.addActionListener(this);
+//		gridItem = menu.add(new MenuItem("Grid"));
+//		gridItem.addActionListener(this);
+//		rectoidItem = menu.add(new MenuItem("Box"));
+//		rectoidItem.addActionListener(this);
+//		ellipsoidItem = menu.add(new MenuItem("Sphere"));
+//		ellipsoidItem.addActionListener(this);
+//		coneItem = menu.add(new MenuItem("Cone"));
+//		coneItem.addActionListener(this);
+//		torusItem = menu.add(new MenuItem("Torus"));
+//		torusItem.addActionListener(this);
+//		superItem = menu.add(new MenuItem("Superellipsoid"));
+//		superItem.addActionListener(this);
+                
+		cameraItem = menu.add(new MenuItem("Camera"));
+		cameraItem.addActionListener(this);
+                
+                if (!Globals.ADVANCED)
+                {
 		kleinItem = menu.add(new MenuItem("Klein Bottle"));
 		kleinItem.addActionListener(this);
-		particleItem = menu.add(new MenuItem("Particle system"));
-		particleItem.addActionListener(this);
+                }
+                
+//		particleItem = menu.add(new MenuItem("Particle system"));
+//		particleItem.addActionListener(this);
         if (Globals.ADVANCED)
         {
 		ragdollItem = menu.add(new MenuItem("Rag Walk"));
@@ -1142,15 +1435,15 @@
         }
 		bezierItem = menu.add(new MenuItem("Bezier Patch"));
 		bezierItem.addActionListener(this);
-		overlayItem = menu.add(new MenuItem("Overlay"));
-		overlayItem.addActionListener(this);
-		lightItem = menu.add(new MenuItem("Light"));
-		lightItem.addActionListener(this);
+//		overlayItem = menu.add(new MenuItem("Overlay"));
+//		overlayItem.addActionListener(this);
+//		lightItem = menu.add(new MenuItem("Light"));
+//		lightItem.addActionListener(this);
 		menu.add("-");
 		//superLoopItem = menu.add(new MenuItem("Super Loop"));
 		//superLoopItem.addActionListener(this);
-		loopItem = menu.add(new MenuItem("Loop"));
-		loopItem.addActionListener(this);
+//		loopItem = menu.add(new MenuItem("Loop"));
+//		loopItem.addActionListener(this);
 		doubleItem = menu.add(new MenuItem("Fork"));
 		doubleItem.addActionListener(this);
         if (Globals.ADVANCED)
@@ -1190,7 +1483,7 @@
 		memoryItem.addActionListener(this);
 		menu.add(analyzeItem = new MenuItem("Analyze"));
 		analyzeItem.addActionListener(this);
-		menu.add(dumpItem = new MenuItem("Dump"));
+		menu.add(dumpItem = new MenuItem("Print"));
 		dumpItem.addActionListener(this);
 //		menu.add(pathItem = new MenuItem("From-to path"));
 //		pathItem.addActionListener(this);
@@ -1331,6 +1624,7 @@
             shadow.material = new cMaterial(obj.material);
             shadow.material.diffuse = 0.0001f;
             shadow.material.specular = 0.0001f;
+            //shadow.projectedVertices[1].x = 300;
             
             makeSomething(shadow);
         }
@@ -1537,9 +1831,9 @@
     
     void Overwrite(int mask)
     {
-        if (/*group.selection.size() == 1 &&*/ GrafreeD.clipboard.size() == 1)
+        if (/*group.selection.size() == 1 &&*/ Grafreed.clipboard.size() == 1)
         {
-            Object3D content = GrafreeD.clipboard.get(0);
+            Object3D content = Grafreed.clipboard.get(0);
 
             if (content instanceof cGroup && ((cGroup)content).transientlink )
                 content = ((cGroup)content).get(0);
@@ -1578,7 +1872,7 @@
 		{
                     ScreenFit();
                 } else
-		if (source == switchItem)
+		if (source == switchViewItem)
 		{
 			cVector v1 = new cVector();
 			cVector v2 = new cVector();
@@ -1587,11 +1881,11 @@
 			objEditor.cameraView.renderCamera.setAim(v2, v1);
 			objEditor.cameraView.repaint();
 		} else
-		if (source == rectoidItem)
+		if (source == rectoidItem || source == boxButton)
 		{
 			makeSomething(new Box());
 		} else
-		if (source == particleItem)
+		if (source == particleItem || source == particlesButton)
 		{
         ParticleNode particleGeom = new ParticleNode("Particles", 1000); //, particleType);
         ParticleController particleController = new ParticleController(particleGeom);
@@ -1670,27 +1964,27 @@
                     
                     makeSomething(obj);
 		} else
-		if (source == gridItem)
+		if (source == gridItem || source == gridButton)
 		{
 			makeSomething(new Grid());
 		} else
-		if (source == ellipsoidItem)
+		if (source == ellipsoidItem || source == sphereButton)
 		{
 			makeSomething(new Sphere());
 		} else
-		if (source == coneItem)
+		if (source == coneItem || source == coneButton)
 		{
 			makeSomething(new Cone());
 		} else
-		if (source == torusItem)
+		if (source == torusItem || source == torusButton)
 		{
 			makeSomething(new Torus());
 		} else
-		if (source == superItem)
+		if (source == superItem || source == superButton)
 		{
 			makeSomething(new Superellipsoid());
 		} else
-		if (source == kleinItem)
+		if (source == kleinItem || source == kleinButton)
 		{
 			makeSomething(new Klein());
 		} else
@@ -1710,7 +2004,7 @@
 		{
 			makeSomething(new BezierSurface());
 		} else
-		if (source == overlayItem)
+		if (source == overlayItem || source == overlayButton)
 		{
                     /*
 			Object3D obj = new BezierSurface(5,8);
@@ -1758,7 +2052,7 @@
                         s.setup();
 			makeSomething(s);
 		} else
-		if (source == lightItem)
+		if (source == lightItem || source == lightButton)
 		{
 			makeSomething(new Light());
 		} else
@@ -1808,7 +2102,7 @@
                             
 			group(g);
 		} else
-		if (source == loopItem)
+		if (source == loopItem || source == loopButton)
 		{
                         Composite csg = new GroupLeaf();
                         csg.count = 5;
@@ -1844,23 +2138,6 @@
                         csg.addChild(child);
                         child.addChild(csg);
 		} else
-                    
-		if (source == importGFDItem)
-		{
-			ImportGFD();
-		} else
-		if (source == importVRMLX3DItem)
-		{
-			ImportVRMLX3D();
-		} else
-		if (source == import3DSItem)
-		{
-			objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
-		} else
-		if (source == importOBJItem)
-		{
-			objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
-		} else
 		if (source == computeAOItem)
 		{
                     Globals.drawMode = CameraPane.OCCLUSION;
@@ -1879,7 +2156,7 @@
 		if (source == invariantsItem)
 		{
                     System.out.println("Invariants:");
-                    GrafreeD.grafreeD.universe.invariants();
+                    Grafreed.grafreeD.universe.invariants();
 		} else
 		if (source == memoryItem)
 		{
@@ -1897,6 +2174,30 @@
 		if (source == dumpItem)
 		{
                     DumpObject();
+		} else
+		if (source == minButton)
+		{
+			Minimize();
+		} else
+		if (source == maxButton)
+		{
+			Maximize();
+		} else
+		if (source == fullButton)
+		{
+			ToggleFullScreen();
+		} else
+		if (source == undoButton)
+		{
+			Undo();
+		} else
+		if (source == redoButton)
+		{
+			Redo();
+		} else
+		if (source == saveButton)
+		{
+			Save();
 		} else
 		if (source == oneStepButton)
 		{
@@ -1952,12 +2253,20 @@
 		{
 			loadClipboard(true);
 		} else
+		if (source == undoItem)
+		{
+			Undo();
+		} else
+		if (source == redoItem)
+		{
+			Redo();
+		} else
 		if (source == duplicateItem)
 		{
-                    Object3D keep = GrafreeD.clipboard;
+                    Object3D keep = Grafreed.clipboard;
 			loadClipboard(false);
 			paste(false);
-                    GrafreeD.clipboard = keep;
+                    Grafreed.clipboard = keep;
 		} else
 		if (source == cloneItem)
 		{
@@ -2177,9 +2486,9 @@
 //                        group.selection.get(0).setMasterThis(content); // should be identity
 //		refreshContents();
 //                    }
-                    if (/*group.selection.size() == 1 &&*/ GrafreeD.clipboard.size() == 1)
+                    if (/*group.selection.size() == 1 &&*/ Grafreed.clipboard.size() == 1)
                     {
-                        Object3D content = GrafreeD.clipboard.get(0);
+                        Object3D content = Grafreed.clipboard.get(0);
                         
                         if (content instanceof cGroup && ((cGroup)content).transientlink )
                             content = ((cGroup)content).get(0);
@@ -2229,9 +2538,9 @@
 		} else
 		if (source == setMasterItem)
 		{
-                    if (group.selection.size() == 1 && GrafreeD.clipboard.size() == 1)
+                    if (group.selection.size() == 1 && Grafreed.clipboard.size() == 1)
                     {
-                        Object3D content = GrafreeD.clipboard.get(0);
+                        Object3D content = Grafreed.clipboard.get(0);
                         
                         if (content instanceof cGroup && ((cGroup)content).transientlink )
                             content = ((cGroup)content).get(0);
@@ -2244,9 +2553,9 @@
 		{
                     if (group.selection.size() == 1)
                     {
-                        if (GrafreeD.clipboard.size() == 1)
+                        if (Grafreed.clipboard.size() == 1)
                         {
-                            Object3D content = GrafreeD.clipboard.get(0);
+                            Object3D content = Grafreed.clipboard.get(0);
 
                             if (content instanceof cGroup && ((cGroup)content).transientlink )
                                 content = ((cGroup)content).get(0);
@@ -2263,7 +2572,7 @@
 		{
 			RevertMeshes();
 		} else
-		if (source == resetMeshItem)
+		if (source == resetAllItem)
 		{
 			ResetAll();
 		} else
@@ -2283,9 +2592,9 @@
 		{
 			ClearSelection(true);
 		} else
-		if (source == grabItem)
+		if (source == grabItem || source == groupButton)
 		{
-			group(new cGroup(), true);
+			group(new cGroup(), false); // true);
 		} else
 		if (source == hideItem)
 		{
@@ -2303,11 +2612,11 @@
 		{
 			makeSomething(new Camera());
 		} else
-		if (source == compositeItem)
+		if (source == compositeItem || source == compositeButton)
 		{
 			group(new Composite());
 		} else
-		if (source == randomItem)
+		if (source == switchItem || source == switchButton)
 		{
                         RandomNode random = new RandomNode();
 			group(random);
@@ -2409,7 +2718,7 @@
 		{
 			group(new cLinker());
 		} else
-		if (source == textureItem)
+		if (source == textureItem || source == textureButton)
 		{
 			group(new TextureNode());
 		} else
@@ -2429,7 +2738,7 @@
 		{
 			CastShadow(2);
 		} else
-		if (source == ungroupItem)
+		if (source == ungroupItem || source == ungroupButton)
 		{
 			//ungroup();
                     for (int i=0; i<group.selection.size(); i++)
@@ -2451,7 +2760,7 @@
 		} else
 		if (source == genNormalsMESHItem)
                 {
-			GenNormals(true); // TODO
+			GenNormalsMESH();
 		} else
 		if (source == genNormalsORGANItem)
                 {
@@ -2516,6 +2825,22 @@
 		if (source == unmarkleavesItem)
                 {
 			MarkLeaves(false);
+		} else
+		if (source == rewindleavesItem)
+                {
+			RewindLeaves(true);
+		} else
+		if (source == unrewindleavesItem)
+                {
+			RewindLeaves(false);
+		} else
+		if (source == randomleavesItem)
+                {
+			RandomLeaves(true);
+		} else
+		if (source == unrandomleavesItem)
+                {
+			RandomLeaves(false);
 		} else
 		if (source == flipVItem)
                 {
@@ -2601,9 +2926,13 @@
                 {
 			SmoothMesh();
 		} else
-		if (source == transformgeometryItem)
+		if (source == transformGeometryItem)
 		{
                         TransformGeometry();
+		} else
+		if (source == transformChildrenItem)
+		{
+                        TransformChildren();
 		} else
 		if (source == resetTransformItem)
 		{
@@ -2611,7 +2940,11 @@
 		} else
 		if (source == resetCentroidItem)
 		{
-                        ResetCentroid();
+                        ResetCentroid(true);
+		} else
+		if (source == resetCentroidXZItem)
+		{
+                        ResetCentroid(false);
 		} else
 		if (source == resetParentItem)
 		{
@@ -2743,6 +3076,10 @@
 		if (source == twoButton)
 		{
                     radio.layout = twoButton;
+                    
+                    if (CameraPane.FULLSCREEN)
+                        fullscreenLayout = radio.layout;
+                    
                     // bug
                     //gridPanel.setDividerLocation(1.0);
                     //bigPanel.setDividerLocation(0.0);
@@ -2775,10 +3112,31 @@
                     bigThree.ClearUI();
                     bigThree.add(centralPanel);
                     bigThree.FlushUI();
+                    
+                    cameraView.requestFocusInWindow();
+                    
+//                    refreshContents(true);
+//                    
+//                    try
+//                    {
+//                        java.awt.Robot bot = new java.awt.Robot();
+//                        int mask = InputEvent.BUTTON1_MASK;
+//                        bot.mouseMove(100, 100);           
+//                        bot.mousePress(mask);     
+//                        bot.mouseRelease(mask);                    
+//                    }
+//                    catch (Exception e)
+//                    {
+//                        
+//                    }
+                    
                 } else
 		if (source == threeButton)
 		{
                     radio.layout = threeButton;
+                    
+                    if (CameraPane.FULLSCREEN)
+                        fullscreenLayout = radio.layout;
                     
 //                    bigThree.remove(scenePanel);
 //                    bigThree.remove(centralPanel);
@@ -2811,10 +3169,15 @@
                     bigThree.add(centralPanel);
                     bigThree.add(XYZPanel);
                     bigThree.FlushUI();
+                    
+                    cameraView.requestFocusInWindow();
                 } else
 		if (source == fourButton)
 		{
                     radio.layout = fourButton;
+                    
+                    if (CameraPane.FULLSCREEN)
+                        fullscreenLayout = radio.layout;
                     
 //                    bigThree.remove(scenePanel);
 //                    bigThree.remove(centralPanel);
@@ -2846,10 +3209,15 @@
                     bigThree.ClearUI();
                     bigThree.add(scenePanel);
                     bigThree.FlushUI();
+                    
+                    cameraView.requestFocusInWindow();
                 } else
 		if (source == sixButton)
 		{
                     radio.layout = sixButton;
+                    
+                    if (CameraPane.FULLSCREEN)
+                        fullscreenLayout = radio.layout;
                     
 //                    bigThree.remove(scenePanel);
 //                    bigThree.remove(centralPanel);
@@ -2882,10 +3250,15 @@
                     bigThree.add(scenePanel);
                     bigThree.add(centralPanel);
                     bigThree.FlushUI();
+                    
+                    cameraView.requestFocusInWindow();
                 } else
 		if (source == sevenButton)
 		{
                     radio.layout = sevenButton;
+                    
+                    if (CameraPane.FULLSCREEN)
+                        fullscreenLayout = radio.layout;
                     
 //                    bigThree.remove(scenePanel);
 //                    bigThree.remove(centralPanel);
@@ -2919,6 +3292,8 @@
                     bigThree.add(centralPanel);
                     bigThree.add(XYZPanel);
                     bigThree.FlushUI();
+                    
+                    cameraView.requestFocusInWindow();
                 } else
 		if (source == rootButton)
 		{
@@ -2930,6 +3305,7 @@
                                 EditObject(obj);
                     }
 
+                    cameraView.requestFocusInWindow();
                     refreshContents(true);
 		} else
 		if (source == closeButton)
@@ -2939,22 +3315,37 @@
                     for (Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
                     {
                             ab = (cRadio)e.nextElement();
-                            if(ab.getModel().isSelected() && ab.GetObject() != client)
+                            if (ab.getModel().isSelected() && ab.GetObject() != client)
                             {
+                                // Patch to avoid bug with transparency.
+                                if (!ab.hadMaterial)
+                                {
+                                    ab.object.material = null;
+                                }
+                                
                                 buttonGroup.remove(ab);
                                 radioPanel.remove(ab);
                                 
-                                ab.GetObject().editWindow = null;
+                                //ab.GetObject().editWindow = null;
+                                ab.GetObject().manipWindow = null;
                             //    ab.GetObject().objectUI = null; // ?????????
                                 
                                 ((cRadio)radioPanel.getComponent(radioPanel.getComponentCount() - 1)).doClick();
                                 break;
                             }
                     }
+                    
+                    cameraView.requestFocusInWindow();
                     refreshContents(true);
 		} else
 		if (source == editItem || source == editButton)
 		{
+			for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
+			{
+				Object3D child = (Object3D)e.nextElement();
+                                child.pinned = true;
+                        }
+                        
 			EditSelection(false);
 		} else
 		if (source == uneditButton)
@@ -2964,10 +3355,11 @@
 				Object3D child = (Object3D)e.nextElement();
                                 if(child.editWindow != null)
                                     objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
+                                child.pinned = false;
 				child.CloseUI();
                                 listUI.remove(child);
                                 
-                                child.editWindow = null; // ???????????
+                                //child.editWindow = null; // ???????????
 			}
 			objEditor.ctrlPanel.FlushUI();
 			//objEditor.jTree.clearSelection();
@@ -2980,6 +3372,7 @@
                     //copy.ClearUI();
                     for (Object3D obj : listUI)
                     {
+                        obj.pinned = true;
                         obj.CloseUI();
                     }
                     listUI.clear();
@@ -2989,7 +3382,7 @@
 		{
                     assert(copy == group);
                     
-                    objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
+                    //objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
                     
                     for (Object3D obj : listUI)
                     {
@@ -3053,7 +3446,11 @@
                         frontView.object = group;
                         sideView.object = group;
                     }
-                    group.editWindow = this;
+                    
+// fix "+" issue
+                    //group.editWindow = this;
+                    group.manipWindow = this;
+                    
                     /*
                     currentLayout = radio.layout;
                     if (currentLayout == null)
@@ -3065,8 +3462,23 @@
                     //group.parent = null; // ROOT
                     //group.attributes = -1;
                     ResetModel();
+                    
+                    cameraView.requestFocusInWindow();
                     refreshContents(true);
-                }
+                } else if (event.getSource() == editCameraItem)
+                {
+                    cameraView.ProtectCamera();
+                    cameraView.repaint();
+                    return;
+                } else if (event.getSource() == restoreCameraItem || event.getSource() == restoreCameraButton)
+                {
+                    cameraView.RevertCamera();
+                    cameraView.repaint();
+                    return;
+        //        } else if (event.getSource() == textureButton)
+        //        {
+        //            return; // true;
+                } 
                 else
                 {
 			//return super.action(event, arg);
@@ -3075,7 +3487,6 @@
 	}
         
         boolean useclient = false;
-        cRadio radio;
         
         void ToggleRoot()
         {
@@ -3127,6 +3538,28 @@
             refreshContents();
         }
         
+        void TransformChildren()
+        {
+            Object3D obj;
+            for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
+            {
+                    obj = (Object3D)e.nextElement();
+                    obj.KeepTextureMatrices();
+                    obj.TransformChildren();
+                    obj.RestoreTextureMatrices();
+                                        
+//                    if (obj.parent == null)
+//                    {
+//                        System.out.println("NULL PARENT!");
+//                        new Exception().printStackTrace();
+//                    }
+//                    else
+//                        TouchTransform(obj);
+//                        //obj.parent.Touch();
+            }
+
+            refreshContents();
+        }
         
         void ResetTransform()
         {
@@ -3239,7 +3672,7 @@
             refreshContents();
         }
         
-        void ResetCentroid()
+        void ResetCentroid(boolean full)
         {
             Object3D obj;
             for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
@@ -3254,12 +3687,16 @@
                     LA.matIdentity(Object3D.mat);
                     obj.getBounds(minima, maxima, false);
                     Object3D.mat[3][0] = -(minima.x + maxima.x)/2;
-                    Object3D.mat[3][1] = -(minima.y + maxima.y)/2;
+                    if (full)
+                        Object3D.mat[3][1] = -(minima.y + maxima.y)/2;
                     Object3D.mat[3][2] = -(minima.z + maxima.z)/2;
                     obj.TransformMesh(Object3D.mat);
+                    
                     Object3D.mat[3][0] = (minima.x + maxima.x)/2;
-                    Object3D.mat[3][1] = (minima.y + maxima.y)/2;
+                    if (full)
+                        Object3D.mat[3][1] = (minima.y + maxima.y)/2;
                     Object3D.mat[3][2] = (minima.z + maxima.z)/2;
+                    
                     LA.matConcat(Object3D.mat, obj.toParent, obj.toParent);
                     //Object3D.mat[3][0] = -Object3D.mat[3][0];
                     //Object3D.mat[3][1] = -Object3D.mat[3][1];
@@ -3288,7 +3725,8 @@
                     
                     int size = obj.MemorySize();
                     
-                    System.err.println((size/1024) + " KB is the size of " + obj);
+                    //System.err.println((size/1024) + " KB is the size of " + obj);
+                    System.err.println("the size of " + obj + " is " + size + " (" + (size/1024) + "KB)");
                 }
             }
             catch (Exception e)
@@ -3325,9 +3763,9 @@
                     obj = (Object3D)e.nextElement();
                     
                     System.out.println("Object is: " + obj);
-                    GrafreeD.AnalyzeObject(obj);
+                    Grafreed.AnalyzeObject(obj);
                     System.out.println("Boundary rep: " + obj.bRep);
-                    GrafreeD.AnalyzeObject(obj.bRep);
+                    Grafreed.AnalyzeObject(obj.bRep);
                     
 //                    System.err.println((size/1024) + " KB is the size of " + obj);
                 }
@@ -3369,6 +3807,13 @@
 	void GenNormals(boolean crease)
 	{
 		group.GenNormalsS(crease);
+		
+		refreshContents();
+	}
+	
+	void GenNormalsMESH()
+	{
+		group.GenNormalsMeshS();
 		
 		refreshContents();
 	}
@@ -3541,8 +3986,8 @@
 	
 	void ParseVertices()
 	{
-            boolean epsequal = GrafreeD.epsequal;
-            GrafreeD.epsequal = true;
+            boolean epsequal = Grafreed.epsequal;
+            Grafreed.epsequal = true;
             
             for (int i=0; i<group.selection.size(); i++)
             {
@@ -3567,7 +4012,7 @@
                                 LA.matTranslate(g.toParent, temp.x, temp.y, temp.z);
                                 LA.matTranslate(g.fromParent, -temp.x, -temp.y, -temp.z);
 
-                                g.add(GrafreeD.clipboard);
+                                g.add(Grafreed.clipboard);
 
                                 buffer.add(g);
                             }
@@ -3582,7 +4027,7 @@
                 makeSomething(buffer, i==group.selection.size()-1);
             }
             
-            GrafreeD.epsequal = epsequal;
+            Grafreed.epsequal = epsequal;
             
             refreshContents();
 	}
@@ -3600,7 +4045,16 @@
                             String pigment = Object3D.GetPigment(tex);
                             //String bump = Object3D.GetBump(tex);
                             
-                            com.sun.opengl.util.texture.TextureData texturedata = Globals.theRenderer.GetTextureData(pigment, false, node.texres);
+                            com.sun.opengl.util.texture.TextureData texturedata = null;
+                            
+                            try
+                            {
+                                texturedata = Globals.theRenderer.GetTextureData(pigment, false, node.texres);
+                            }
+                            catch (Exception e)
+                            {
+                                System.err.println("FAIL: " + node);
+                            }
                             
                             double s = v.s;
                             
@@ -3732,7 +4186,7 @@
                 return;
             
             Object3D poses = group.selection.get(0);
-            Object3D ref = GrafreeD.clipboard.get(0);
+            Object3D ref = Grafreed.clipboard.get(0);
             
             Object3D newgroup = new Object3D("Po:" + poses.name);
             
@@ -3926,9 +4380,9 @@
 	
 	void ClipMesh()
 	{
-            if (/*group.selection.size() == 1 &&*/ GrafreeD.clipboard.size() == 1)
+            if (/*group.selection.size() == 1 &&*/ Grafreed.clipboard.size() == 1)
             {
-                Object3D content = GrafreeD.clipboard.get(0);
+                Object3D content = Grafreed.clipboard.get(0);
 
                 if (content instanceof cGroup && ((cGroup)content).transientlink )
                     content = ((cGroup)content).get(0);
@@ -3937,7 +4391,7 @@
 //                {
 //                    group.selection.get(i).ClipMesh(GrafreeD.clipboard);
 //                }
-                  group.selection.ClipMesh(GrafreeD.clipboard);
+                  group.selection.ClipMesh(Grafreed.clipboard);
             }
 //		group.selection.ClipMesh(GrafreeD.clipboard);
             System.out.println("DONE.");
@@ -3984,6 +4438,18 @@
 	void MarkLeaves(boolean hide)
 	{
 		group.selection.MarkLeaves(hide);
+		refreshContents();
+	}
+	
+	void RewindLeaves(boolean hide)
+	{
+		group.selection.RewindLeaves(hide);
+		refreshContents();
+	}
+	
+	void RandomLeaves(boolean hide)
+	{
+		group.selection.RandomLeaves(hide);
 		refreshContents();
 	}
 	
@@ -4058,10 +4524,6 @@
 //		}
 //	}
 	
-        static boolean allparams = true;
-        
-        static Vector<Object3D> listUI = new Vector<Object3D>();
-        
 	void EditSelection(boolean newWindow)
 	{
         //    aConstraints.gridy = 0;
@@ -4069,10 +4531,10 @@
 		{
                     //System.out.println("edit : " + objectPanel.indexOfTab("Material"));
                     //objectPanel.setEnabledAt(objectPanel.indexOfTab("Material"), false);
-                    objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
+                    //objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
                     
 			Object3D elem = (Object3D)group.selection.elementAt(i);
-                        if(elem != group)
+                        if(elem != group || !newWindow)
                         {
                         //    if (!(elem instanceof Composite))
                         //        newWindow = false;
@@ -4155,6 +4617,17 @@
 
 		freezemodel = true;
 		
+                //for (Object3D obj : listUI)
+                for (int i=listUI.size(); --i>=0;)
+                {
+                    Object3D obj = listUI.elementAt(i);
+                    if (!obj.pinned)
+                    {
+                        obj.CloseUI();
+                        listUI.remove(i);
+                    }
+                }
+                    
 		/**/
 		//switch (event.id)
 		{
@@ -4162,7 +4635,6 @@
 			//case 702: // Event.LIST_DESELECT
 			group.deselectAll();
 			TreePath tps[] = objEditor.jTree.getSelectionPaths();
-			objEditor.ClearInfo(); // .GetMaterial());
 			if (tps != null)
 			{
 				for (int i=0; i < tps.length; i++)
@@ -4171,10 +4643,8 @@
 					
 					//if (child.parent != null)
 						//child.parent.addSelectee(child);
+                    objEditor.SetMaterial(child);
 					group.addSelectee(child);
-					objEditor.SetMaterial(child); // .GetMaterial());
-					objEditor.AddInfo(child, this, true); // .GetMaterial());
-            System.err.println("info : " + child.GetPath());
 				}
 			}
 //			else
@@ -4184,20 +4654,28 @@
 //            System.err.println("info : " + group.GetPath());
 //                        }
 			
-                        objEditor.SetText(); // jan 2014
-                        
-			if (flashIt && !Globals.isLIVE() && tps != null && tps.length > 0 && !(((Object3D) tps[0].getLastPathComponent()) instanceof Camera))
+			if (flashIt && !Globals.isLIVE() && tps != null && tps.length > 0 && !(tps[0].getLastPathComponent() instanceof Camera))
 				CameraPane.flash = true;
                         
-			if (tps != null && tps.length > 0 && ((Object3D) tps[0].getLastPathComponent()) instanceof Camera)
+			if (tps != null && tps.length > 0 && tps[0].getLastPathComponent() instanceof Camera)
                             // a camera
                         {
-                            CameraPane.camerachangeframe = 0; // don't refuse it
-                            Globals.theRenderer.SetCamera((Camera) tps[0].getLastPathComponent());
+                            if (tps[0].getLastPathComponent() != Globals.theRenderer.LightCamera()) // Crash the camera because of invalid lightspace
+                            {
+                                CameraPane.camerachangeframe = 0; // don't refuse it
+                                Globals.theRenderer.SetCamera((Camera) tps[0].getLastPathComponent());
+                            }
                          //   Globals.theRenderer.renderCamera = Globals.theRenderer.manipCamera;
                          //   Globals.theRenderer.eyeCamera = Globals.theRenderer.manipCamera;
                         }
                             
+                        if (tps != null && tps.length == 1)
+                        {
+                            EditSelection(false);
+                        }
+                        
+                        SetPinStates(tps != null && tps.length > 0);
+                        
 			refreshContents();
 			//return true;
 		}
@@ -4206,6 +4684,33 @@
 		
 		freezemodel = false;
 	}
+        
+        void SetPinStates(boolean enabled)
+        {
+            editButton.setEnabled(enabled);
+            uneditButton.setEnabled(enabled);
+        }
+
+        void refreshContents(boolean cp)
+        {
+            if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Info"))
+            if (!Globals.MOUSEDRAGGED) // && !Globals.TIMERRUNNING)
+            {
+                objEditor.ClearInfo(); // .GetMaterial());
+
+                for (int i=0; i < group.selection.Size(); i++)
+                {
+                    Object3D child = (Object3D) group.selection.get(i);
+
+                    objEditor.AddInfo(child, this, true);
+    System.err.println("info : " + child.GetPath());
+                }
+
+                objEditor.SetText(); // jan 2014
+            }
+                        
+            super.refreshContents(cp);
+        }
 	
 	void linkSomething(Object3D thing)
 	{
@@ -4277,16 +4782,19 @@
 	{
 		if (group.selection.isEmpty())
 			return;
-		GrafreeD.clipboardIsTempGroup = false;
+                
+		Grafreed.clipboardIsTempGroup = false;
 		Composite tGroup = null;
 		if (group.selection.size() > 0) // 1)
 		{
 			tGroup = new cGroup();
-			GrafreeD.clipboardIsTempGroup = true;
+			Grafreed.clipboardIsTempGroup = true;
 		}
                 
 		if (cut)
 		{
+        if (Globals.SAVEONMAKE)
+                    Save();
 			//int indices[] = jList.getSelectedIndices();
 			//for (int i = indices.length - 1; i >= 0; i--)
 			//jList.remove(indices[i]);
@@ -4322,16 +4830,16 @@
 		//System.out.println("cut " + child);
 		//System.out.println("parent = " + child.parent);
                 //                   tmp.addChild(child);
-                                    if (GrafreeD.clipboardIsTempGroup)
+                                    if (Grafreed.clipboardIsTempGroup)
                                             tGroup.add/*Child*/(tmp);
                                     else
-                                            GrafreeD.clipboard = tmp;
+                                            Grafreed.clipboard = tmp;
                                 }
                                 else
-                                    if (GrafreeD.clipboardIsTempGroup)
+                                    if (Grafreed.clipboardIsTempGroup)
                                             tGroup.add/*Child*/(child);
                                     else
-                                            GrafreeD.clipboard = child;
+                                            Grafreed.clipboard = child;
 			}
 			
 			//ResetModel();
@@ -4363,21 +4871,23 @@
 		//System.out.println("cut " + elem);
 		//System.out.println("parent = " + elem.parent);
                 //                    tmp.addChild(elem);
-                                    if (GrafreeD.clipboardIsTempGroup)
+                                    if (Grafreed.clipboardIsTempGroup)
                                             tGroup.add/*Child*/(tmp);
                                     else
-                                            GrafreeD.clipboard = tmp;
+                                            Grafreed.clipboard = tmp;
                                 }
                                 else
-                                    if (GrafreeD.clipboardIsTempGroup)
+                                    if (Grafreed.clipboardIsTempGroup)
                                             tGroup.add/*Child*/(child);
                                     else
-                                            GrafreeD.clipboard = child;
+                                            Grafreed.clipboard = child;
 			}
 			
 		}
-		if (GrafreeD.clipboardIsTempGroup)
-			GrafreeD.clipboard = tGroup;
+                
+		if (Grafreed.clipboardIsTempGroup)
+			Grafreed.clipboard = tGroup;
+                
 		if (cut)
                 {
                     ResetModel();
@@ -4391,7 +4901,7 @@
 	//		return;
 		boolean first = true;
 		
-		if (GrafreeD.clipboardIsTempGroup)
+		if (Grafreed.clipboardIsTempGroup)
 		{
 			Composite temp;
 			
@@ -4402,7 +4912,7 @@
 				temp = (Composite)Applet3D.clipboard.deepCopy();
                          */
 			Object3D elem;
-			for (Enumeration e = /*temp.children*/GrafreeD.clipboard.elements(); e.hasMoreElements();) // objList.add(copy.name))
+			for (Enumeration e = /*temp.children*/Grafreed.clipboard.elements(); e.hasMoreElements();) // objList.add(copy.name))
 			{
 				Object3D child = (Object3D)e.nextElement();
                                 
@@ -4436,14 +4946,14 @@
 			//Object3D cb = Applet3D.clipboard;
 			//temp.addChild(cb);
 			//makeSomething((expand?temp.copyExpand():temp.deepCopy()).get(0));
-                    assert(GrafreeD.clipboard.parent == null);
-                        Object3D /*Composite*/ keepparent = GrafreeD.clipboard.get(0).parent;
-                        GrafreeD.clipboard.get(0).parent = null; // Avoid copy?
-                        if (LA.isIdentity(GrafreeD.clipboard.toParent))
-                            makeSomething(expand?GrafreeD.clipboard.get(0).copyExpand():GrafreeD.clipboard.get(0).deepCopy());
+                    assert(Grafreed.clipboard.parent == null);
+                        Object3D /*Composite*/ keepparent = Grafreed.clipboard.get(0).parent;
+                        Grafreed.clipboard.get(0).parent = null; // Avoid copy?
+                        if (LA.isIdentity(Grafreed.clipboard.toParent))
+                            makeSomething(expand?Grafreed.clipboard.get(0).copyExpand():Grafreed.clipboard.get(0).deepCopy());
                         else
-                            makeSomething(expand?GrafreeD.clipboard.copyExpand():GrafreeD.clipboard.deepCopy());
-                        GrafreeD.clipboard.get(0).parent = keepparent;
+                            makeSomething(expand?Grafreed.clipboard.copyExpand():Grafreed.clipboard.deepCopy());
+                        Grafreed.clipboard.get(0).parent = keepparent;
 		}
 		
 		ResetModel();
@@ -4492,9 +5002,9 @@
 		{
 			boolean first = true;
 			
-			if (GrafreeD.clipboardIsTempGroup)
+			if (Grafreed.clipboardIsTempGroup)
 			{
-				Composite temp = (Composite)GrafreeD.clipboard;
+				Composite temp = (Composite)Grafreed.clipboard;
 				Object3D copy;
 				for (Enumeration e = temp.children.elements(); e.hasMoreElements();)
 				{
@@ -4504,7 +5014,7 @@
 				}
 			} else
 			{
-				linkSomething(GrafreeD.clipboard); //.get(0));
+				linkSomething(Grafreed.clipboard); //.get(0));
 			}
 		}
             }
@@ -4909,21 +5419,6 @@
         }
          */
 
-        void ImportGFD()
-        {
-            FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
-            browser.show();
-            String filename = browser.getFile();
-            if (filename != null && filename.length() > 0)
-            {
-                String fullname = browser.getDirectory() + filename;
-
-                //Object3D readobj =
-                        objEditor.ReadGFD(fullname, objEditor);
-                //makeSomething(readobj);
-            }
-        }
-        
         /*
         public void Callback(Object obj)
         {
@@ -4947,26 +5442,9 @@
         }
          */
 
-	void ImportVRMLX3D()
-	{
-		if (GrafreeD.standAlone)
-		{
-                    /**/
-			FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
-			browser.show();
-			String filename = browser.getFile();
-			if (filename != null && filename.length() > 0)
-			{
-				String fullname = browser.getDirectory() + filename;
-                                LoadVRMLX3D(fullname);
-			}
-                     /**/
-		}
-	}
-				
 	String GetFile(String dialogName)
 	{
-		if (GrafreeD.standAlone)
+		if (Grafreed.standAlone)
 		{
 			FileDialog browser = new FileDialog(objEditor.frame, dialogName, FileDialog.LOAD);
 			browser.show();
@@ -5034,7 +5512,31 @@
 	cButton clearpanelButton;
 	cButton unselectButton;
 	
+	cButton restoreCameraButton;
+        
+	cButton minButton;
+	cButton maxButton;
+	cButton fullButton;
+	cButton saveButton;
 	cButton oneStepButton;
+        
+        cButton groupButton;
+        cButton ungroupButton;
+        cButton compositeButton;
+        cButton switchButton;
+        cButton loopButton;
+        cButton textureButton;
+        
+        cButton gridButton;
+        cButton boxButton;
+        cButton sphereButton;
+        cButton coneButton;
+        cButton torusButton;
+        cButton superButton;
+        cButton kleinButton;
+        cButton particlesButton;
+        cButton overlayButton;
+        cButton lightButton;
         
 	cButton screenfitButton;
 	cButton screenfitpointButton;
@@ -5047,14 +5549,6 @@
 
 	cButton setsupportButton;
         
-	cButton twoButton;
-	cButton sixButton;
-	cButton threeButton;
-	cButton sevenButton;
-	cButton fourButton; // full panel
-	cButton oneButton; // full XYZ
-        //cButton currentLayout;
-        
 	//
         //Composite
         Object3D // to do !!
@@ -5064,9 +5558,11 @@
 	//JTree jTree;
 	private MenuItem lookAtItem;
 	private MenuItem lookFromItem;
-	private MenuItem switchItem;
+	private MenuItem switchViewItem;
 	private MenuItem cutItem;
-	private MenuItem duplicateItem;
+	private MenuItem undoItem;
+	private MenuItem redoItem;
+	private JMenuItem duplicateItem;
 	private MenuItem cloneItem;
 	private MenuItem cloneSupportItem;
 	private MenuItem overwriteGeoItem;
@@ -5079,7 +5575,7 @@
 	private MenuItem linkverticesItem;
 	private MenuItem relinkverticesItem;
 	private MenuItem setMasterItem;
-	private MenuItem resetMeshItem;
+	private MenuItem resetAllItem;
 	private MenuItem stepAllItem;
 	private MenuItem revertMeshItem;
 	private MenuItem poseMeshItem;
@@ -5129,6 +5625,10 @@
 	private MenuItem showleavesItem;
 	private MenuItem markleavesItem;
 	private MenuItem unmarkleavesItem;
+	private MenuItem rewindleavesItem;
+	private MenuItem unrewindleavesItem;
+	private MenuItem randomleavesItem;
+	private MenuItem unrandomleavesItem;
         
 	private MenuItem flipVItem;
 	private MenuItem unflipVItem;
@@ -5140,15 +5640,17 @@
 	private MenuItem panoTexturesItem;
         
 	private MenuItem resetCentroidItem;
-	private MenuItem transformgeometryItem;
+	private MenuItem resetCentroidXZItem;
 	private MenuItem resetTransformItem;
+	private MenuItem transformGeometryItem;
+	private MenuItem transformChildrenItem;
 	private MenuItem hideItem;
 	private MenuItem grabItem;
 	private MenuItem backItem;
 	private MenuItem frontItem;
 	private MenuItem cameraItem;
 	private MenuItem compositeItem;
-	private MenuItem randomItem;
+	private MenuItem switchItem;
 	private MenuItem physicsItem;
 	private MenuItem frameselectorItem;
 	private MenuItem scriptNodeItem;
@@ -5210,11 +5712,6 @@
 	private MenuItem doubleItem;
 	private MenuItem tripleItem;
         
-	private MenuItem importGFDItem;
-	private MenuItem importVRMLX3DItem;
-	private MenuItem import3DSItem;
-	private MenuItem importOBJItem;
-
 	private MenuItem computeAOItem;
 	private MenuItem recompileItem;
 	private MenuItem editScriptItem;
@@ -5224,4 +5721,8 @@
 	private MenuItem analyzeItem;
 	private MenuItem dumpItem;
 	//boolean freezemodel = false;
+        
+    Menu cameraMenu;
+    MenuItem editCameraItem;
+    MenuItem restoreCameraItem;
 }

--
Gitblit v1.6.2