From f1382bc839a74ef1d1534c61ea94e53cf54716df Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Sun, 23 Jun 2019 15:00:47 -0400
Subject: [PATCH] Edit panel

---
 GroupEditor.java |  889 +++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 616 insertions(+), 273 deletions(-)

diff --git a/GroupEditor.java b/GroupEditor.java
index 397b6c7..8646c14 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,8 +148,129 @@
         
     //JTextField nameField;
     
-	void SetupMenu2(ObjEditor oe)
+	void SetupMenu2(GroupEditor oe)
 	{
+		Menu menu;
+		oe.menuBar.add(menu = new Menu("Edit"));
+		//editItem = menu.add(new MenuItem("Edit"));
+		//editItem.addActionListener(this);
+                
+//		undoItem = menu.add(new MenuItem("Undo"));
+//		undoItem.addActionListener(this);
+//		redoItem = menu.add(new MenuItem("Redo"));
+//		redoItem.addActionListener(this);
+//		menu.add("-");
+		duplicateItem = menu.add(new MenuItem("Duplicate"));
+		duplicateItem.addActionListener(this);
+		cloneItem = menu.add(new MenuItem("Clone"));
+		cloneItem.addActionListener(this);
+        if (Globals.ADVANCED)
+        {
+		cloneSupportItem = menu.add(new MenuItem("Clone (+supports)"));
+		cloneSupportItem.addActionListener(this);
+        }
+		menu.add("-");
+		cutItem = menu.add(new MenuItem("Cut"));
+		cutItem.addActionListener(this);
+		copyItem = menu.add(new MenuItem("Copy"));
+		copyItem.addActionListener(this);
+		pasteItem = menu.add(new MenuItem("Paste"));
+		pasteItem.addActionListener(this);
+                
+		menu.add("-");
+		pasteIntoItem = menu.add(new MenuItem("Paste into"));
+		pasteIntoItem.addActionListener(this);
+		pasteLinkItem = menu.add(new MenuItem("Paste link"));
+		pasteLinkItem.addActionListener(this);
+		pasteCloneItem = menu.add(new MenuItem("Paste clone"));
+		pasteCloneItem.addActionListener(this);
+//		pasteExpandItem = menu.add(new MenuItem("Paste expand"));
+//		pasteExpandItem.addActionListener(this);
+		menu.add("-");
+		clearItem = menu.add(new MenuItem("Clear"));
+		clearItem.addActionListener(this);
+                
+        if (Globals.ADVANCED)
+        {
+                // Deletes the cameras...
+		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(revertCameraItem = new MenuItem("Restore Viewpoint"));
+        revertCameraItem.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(switchItem = new MenuItem("Reverse View"));
@@ -161,45 +282,17 @@
 		lookAtItem.addActionListener(this);
 		//lookFromItem.addActinoListener(this);
 		//switchItem.addActionListener(this);
-		Menu menu;
-		oe.menuBar.add(menu = new Menu("Edit"));
-		//editItem = menu.add(new MenuItem("Edit"));
-		//editItem.addActionListener(this);
-		duplicateItem = menu.add(new MenuItem("Duplicate"));
-		duplicateItem.addActionListener(this);
-		menu.add("-");
-		cloneItem = menu.add(new MenuItem("Clone"));
-		cloneItem.addActionListener(this);
-		cloneSupportItem = menu.add(new MenuItem("Clone (+supports)"));
-		cloneSupportItem.addActionListener(this);
-		menu.add("-");
-		cutItem = menu.add(new MenuItem("Cut"));
-		cutItem.addActionListener(this);
-		copyItem = menu.add(new MenuItem("Copy"));
-		copyItem.addActionListener(this);
-		pasteItem = menu.add(new MenuItem("Paste"));
-		pasteItem.addActionListener(this);
-		pasteLinkItem = menu.add(new MenuItem("Paste link"));
-		pasteLinkItem.addActionListener(this);
-		pasteCloneItem = menu.add(new MenuItem("Paste clone"));
-		pasteCloneItem.addActionListener(this);
-//		pasteExpandItem = menu.add(new MenuItem("Paste expand"));
-//		pasteExpandItem.addActionListener(this);
-		clearItem = menu.add(new MenuItem("Clear"));
-		clearItem.addActionListener(this);
-		clearAllItem = menu.add(new MenuItem("Clear All"));
-		clearAllItem.addActionListener(this);
-
+        }
+        
 		oe.menuBar.add(menu = new Menu("Setting"));
-                resetMeshItem = menu.add(new MenuItem("Reset All"));
-		resetMeshItem.addActionListener(this);
-		stepAllItem = menu.add(new MenuItem("Step All"));
-		stepAllItem.addActionListener(this);
+        if (Globals.ADVANCED)
+        {
 		revertMeshItem = menu.add(new MenuItem("Revert Meshes"));
 		revertMeshItem.addActionListener(this);
 		resetreferencesItem = menu.add(new MenuItem("Reset Mesh References"));
 		resetreferencesItem.addActionListener(this);
 		menu.add("-");
+        }
 		overwriteGeoItem = menu.add(new MenuItem("Overwrite Geometry"));
 		overwriteGeoItem.addActionListener(this);
 		overwriteMatItem = menu.add(new MenuItem("Overwrite Material"));
@@ -211,19 +304,26 @@
 		overwriteUVItem = menu.add(new MenuItem("Overwrite UV"));
 		overwriteUVItem.addActionListener(this);
 		menu.add("-");
+        if (Globals.ADVANCED)
+        {
 		generateMeshItem = menu.add(new MenuItem("Generate Meshes"));
 		generateMeshItem.addActionListener(this);
 		poseMeshItem = menu.add(new MenuItem("Set Pose Meshes"));
 		poseMeshItem.addActionListener(this);
 		menu.add("-");
+        }
 		resetsupportItem = menu.add(new MenuItem("Reset support"));
 		resetsupportItem.addActionListener(this);
 		linkverticesItem = menu.add(new MenuItem("Link to Support"));
 		linkverticesItem.addActionListener(this);
 		relinkverticesItem = menu.add(new MenuItem("Re-link to Support"));
 		relinkverticesItem.addActionListener(this);
+                
+        if (Globals.ADVANCED)
+        {
 		setMasterItem = menu.add(new MenuItem("Set Master Mesh"));
 		setMasterItem.addActionListener(this);
+        }
                 
 		oe.menuBar.add(menu = new Menu("Group"));
 		grabItem = menu.add(new MenuItem("Grab"));
@@ -234,7 +334,7 @@
 		frontItem.addActionListener(this);
 		compositeItem = menu.add(new MenuItem("Composite"));
 		compositeItem.addActionListener(this);
-		hideItem = menu.add(new MenuItem("Hide"));
+		hideItem = menu.add(new MenuItem("Hidden Group"));
 		hideItem.addActionListener(this);
 		ungroupItem = menu.add(new MenuItem("Ungroup"));
 		ungroupItem.addActionListener(this);
@@ -245,16 +345,21 @@
 		switchGeoItem.addActionListener(this);
 		switchTransfoItem = menu.add(new MenuItem("Switch Transform"));
 		switchTransfoItem.addActionListener(this);
+		morphItem = menu.add(new MenuItem("Morph Group"));
+		morphItem.addActionListener(this);
+                
+        if (Globals.ADVANCED)
+        {
+		menu.add("-");
 		physicsItem = menu.add(new MenuItem("Physics"));
 		physicsItem.addActionListener(this);
 		frameselectorItem = menu.add(new MenuItem("Frame Selector"));
 		frameselectorItem.addActionListener(this);
-		morphItem = menu.add(new MenuItem("Morph"));
-		morphItem.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"));
@@ -263,27 +368,35 @@
 		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)
+        {
+		menu.add("-");
 		linkerItem = menu.add(new MenuItem("Linker"));
 		linkerItem.addActionListener(this);
-		templateItem = menu.add(new MenuItem("Template"));
-		templateItem.addActionListener(this);
 		attributeItem = menu.add(new MenuItem("Attribute"));
 		attributeItem.addActionListener(this);
+		templateItem = menu.add(new MenuItem("Template"));
+		templateItem.addActionListener(this);
 		pointflowItem = menu.add(new MenuItem("Point Flow"));
 		pointflowItem.addActionListener(this);
+        }
 		menu.add("-");
 		resetTransformItem = menu.add(new MenuItem("Reset Transform"));
 		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"));
@@ -294,8 +407,11 @@
 		genNormalsCADItem.addActionListener(this);
 		genNormalsMESHItem = menu.add(new MenuItem("Mesh Normals"));
 		genNormalsMESHItem.addActionListener(this);
+        if (Globals.ADVANCED)
+        {
 		genNormalsMINEItem = menu.add(new MenuItem("My Normals"));
 		genNormalsMINEItem.addActionListener(this);
+        }
 		stripifyItem = menu.add(new MenuItem("Stripify"));
 		stripifyItem.addActionListener(this);
 		unstripifyItem = menu.add(new MenuItem("Unstripify"));
@@ -317,23 +433,34 @@
 		reduce34MeshItem.addActionListener(this);
 		increaseMeshItem = menu.add(new MenuItem("Increase mesh"));
 		increaseMeshItem.addActionListener(this);
-		smoothMeshItem = menu.add(new MenuItem("Smooth mesh"));
-		smoothMeshItem.addActionListener(this);
 		clipMeshItem = menu.add(new MenuItem("Clip mesh"));
 		clipMeshItem.addActionListener(this);
+                
+        if (Globals.ADVANCED)
+        {
+		smoothMeshItem = menu.add(new MenuItem("Smooth mesh"));
+		smoothMeshItem.addActionListener(this);
+        }
 
                 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);
 		unliveleavesItem = menu.add(new MenuItem("Unlive Leaves"));
 		unliveleavesItem.addActionListener(this);
+        if (Globals.ADVANCED)
+        {
 		supportleavesItem = menu.add(new MenuItem("Support Leaves"));
 		supportleavesItem.addActionListener(this);
 		unsupportleavesItem = menu.add(new MenuItem("Unsupport Leaves"));
 		unsupportleavesItem.addActionListener(this);
+        }
 		hideleavesItem = menu.add(new MenuItem("Hide Leaves"));
 		hideleavesItem.addActionListener(this);
 		showleavesItem = menu.add(new MenuItem("Show Leaves"));
@@ -342,6 +469,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);
@@ -377,35 +512,40 @@
 		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)
+        {
+            // 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());
@@ -436,19 +576,47 @@
          */
                 //this.AddOptions(oe.toolbarPanel, oe.aConstraints);
                 
+		//oe.toolbarPanel.add(minButton = new cButton("Min", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                //minButton.setToolTipText("Minimize window");
+		//minButton.addActionListener(this);
+                
+		oe.toolbarPanel.add(maxButton = new cButton("\u271A", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                maxButton.setToolTipText("Maximize window");
+		maxButton.addActionListener(this);
+                
+		oe.toolbarPanel.add(fullButton = new cButton("\u2b1c", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                fullButton.setToolTipText("Full-screen window");
+		fullButton.addActionListener(this);
+                
+		oe.toolbarPanel.add(undoButton = new cButton("\u21a9", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                undoButton.setToolTipText("Undo changes");
+		undoButton.addActionListener(this);
+                
+		oe.toolbarPanel.add(redoButton = new cButton("\u21aa", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                redoButton.setToolTipText("Redo changes");
+		redoButton.addActionListener(this);
+                
+		oe.toolbarPanel.add(saveButton = new cButton("\u21e3", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                saveButton.setToolTipText("Save changes");
+		saveButton.addActionListener(this);
+                
                 oe.toolbarPanel.add(liveCB = new cCheckBox("Live", Globals.isLIVE())); //, oe.aConstraints);
-                liveCB.setToolTipText("Enabled animation");
+                liveCB.setToolTipText("Enable animation");
                                 liveCB.addItemListener(this);
 
+		oe.toolbarPanel.add(oneStepButton = new cButton("\u29f4", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                oneStepButton.setToolTipText("Animate one step forward");
+		oneStepButton.addActionListener(this);
+                
                 oe.toolbarPanel.add(fastCB = new cCheckBox("Fast", CameraPane.FAST)); //, constraints);
                 fastCB.setToolTipText("Fast mode");
                                 fastCB.addItemListener(this);
                                 
-                oe.toolbarPanel.add(trackCB = new cCheckBox("Track", CameraPane.TRACK)); //, oe.aConstraints);
+                oe.toolbarPanel.add(trackCB = new cCheckBox(":", CameraPane.TRACK)); //, oe.aConstraints);
                 trackCB.setToolTipText("Enable tracking");
                                 trackCB.addItemListener(this);
 
-		oe.toolbarPanel.add(screenfitButton = new cButton("@", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(screenfitButton = new cButton("@", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 screenfitButton.setToolTipText("Screen fit");
 		screenfitButton.addActionListener(this);
 
@@ -457,70 +625,68 @@
 
                 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);
+		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(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);
+		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 = new cButton("o o o", !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 = new cButton("X", !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();
-                
-		commandsPanel.add(editButton = new cButton("+", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints);
+		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(clearPanelButton = new cButton("C", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints);
+		editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
+                allParamsButton.setToolTipText("Edit all params");
+		allParamsButton.addActionListener(this);
+
+		editCommandsPanel.add(clearPanelButton = new cButton("C", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 clearPanelButton.setToolTipText("Clear edit panel");
 		clearPanelButton.addActionListener(this);
 
-		commandsPanel.add(allParamsButton = new cButton("A", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints);
-                allParamsButton.setToolTipText("All params??");
-		allParamsButton.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.preferredHeight = 1;
                 
-                oe.treePanel.add(commandsPanel);
-                oe.treePanel.Return();
+//                oe.treePanel.add(commandsPanel);
+//                oe.treePanel.Return();
                 
 //		oe.aConstraints.gridx += 1;
 //		oe.aConstraints.weighty = 0;
@@ -588,8 +754,18 @@
         
         void AddOptions(cGridBag panel) //, GridBagConstraints constraints)
         {
+                panel.add(boxCB = new cCheckBox("Box", CameraPane.BOXMODE)); //, constraints);
+                boxCB.setToolTipText("Display bounding boxes");
+                                boxCB.addItemListener(this);
+                                
+                panel.add(zoomBoxCB = new cCheckBox("Zoom", CameraPane.ZOOMBOXMODE)); //, constraints);
+                zoomBoxCB.setToolTipText("Display bounding boxes when moving the wheel");
+                                zoomBoxCB.addItemListener(this);
+
+        if (true) // Globals.ADVANCED)
+        {
                 panel.add(supportCB = new cCheckBox("Support", CameraPane.SUPPORT)); //, constraints);
-                supportCB.setToolTipText("Enabled rigging");
+                supportCB.setToolTipText("Enable rigging");
                                 supportCB.addItemListener(this);
 
         //        panel.add(localCB = new cCheckBox("Local", CameraPane.LOCALTRANSFORM), constraints);
@@ -607,14 +783,6 @@
                 slowCB.setToolTipText("Smooth interpolation");
                                 slowCB.addItemListener(this);
                                 
-                panel.add(boxCB = new cCheckBox("Box", CameraPane.BOXMODE)); //, constraints);
-                boxCB.setToolTipText("Display bounding boxes");
-                                boxCB.addItemListener(this);
-                                
-                panel.add(zoomBoxCB = new cCheckBox("Zoom", CameraPane.ZOOMBOXMODE)); //, constraints);
-                zoomBoxCB.setToolTipText("Display bounding boxes when moving the wheel");
-                                zoomBoxCB.addItemListener(this);
-
 //        	constraints.gridy += 1;
 //                panel.add(speakerMocapCB = new cCheckBox("Mocap", CameraPane.SPEAKERMOCAP), constraints);
 //                                speakerMocapCB.addItemListener(this);
@@ -645,6 +813,8 @@
                 panel.add(lookAtCB = new cCheckBox("Target", CameraPane.LOOKAT)); //, constraints);
                 lookAtCB.setToolTipText("Look-at target");
                                 lookAtCB.addItemListener(this);
+                
+        }
                                 
                 cGridBag fill = new cGridBag();
                                 
@@ -665,8 +835,11 @@
             buttonGroup.add(radioButton);
             radioButton.doClick();
         }
+        
         void SetupViews(ObjEditor oe)
         {
+                    theFrame = this;
+                    
             oe.SetupViews();
             
 		System.out.println("SetupViews");
@@ -729,6 +902,7 @@
             } else if(e.getSource() == liveCB)
             {
                 cameraView.ToggleLive();
+                refreshContents(false);
             }
             else if(e.getSource() == supportCB)
             {
@@ -881,7 +1055,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");
@@ -908,7 +1084,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)
@@ -935,11 +1111,11 @@
             {
                 loadClipboard(true);
                 objEditor.jTree.setSelectionPath(destinationPath);
-                pasteInto(false);
+                pasteInto(false, false);
             } else {
                 loadClipboard(false);
                 objEditor.jTree.setSelectionPath(destinationPath);
-                pasteInto(false); // true); // ???
+                pasteInto(false, false); // true); // ???
             }
 	}
 	public void	dropActionChanged(DropTargetDragEvent dtde) 
@@ -1061,27 +1237,33 @@
 		kleinItem.addActionListener(this);
 		particleItem = menu.add(new MenuItem("Particle system"));
 		particleItem.addActionListener(this);
+        if (Globals.ADVANCED)
+        {
 		ragdollItem = menu.add(new MenuItem("Rag Walk"));
 		ragdollItem.addActionListener(this);
 		ragdoll2Item = menu.add(new MenuItem("Rag Fall"));
 		ragdoll2Item.addActionListener(this);
+        }
 		menu.add("-");
-		meshItem = menu.add(new MenuItem("Mesh"));
+		meshItem = menu.add(new MenuItem("Dynamic Mesh"));
 		meshItem.addActionListener(this);
 	//	meshGroupItem = menu.add(new MenuItem("Mesh Group"));
 	//	meshGroupItem.addActionListener(this);
+        if (Globals.ADVANCED)
+        {
 		springItem = menu.add(new MenuItem("Spring"));
 		springItem.addActionListener(this);
 		flagItem = menu.add(new MenuItem("Flag"));
 		flagItem.addActionListener(this);
-		bezierItem = menu.add(new MenuItem("Patch"));
-		bezierItem.addActionListener(this);
-		checkerItem = menu.add(new MenuItem("Checker"));
-		checkerItem.addActionListener(this);
 		blobItem = menu.add(new MenuItem("Blob"));
 		blobItem.addActionListener(this);
 		latheItem = menu.add(new MenuItem("Lathe"));
 		latheItem.addActionListener(this);
+        }
+		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);
 		menu.add("-");
@@ -1091,8 +1273,11 @@
 		loopItem.addActionListener(this);
 		doubleItem = menu.add(new MenuItem("Fork"));
 		doubleItem.addActionListener(this);
+        if (Globals.ADVANCED)
+        {
 		tripleItem = menu.add(new MenuItem("Trident"));
 		tripleItem.addActionListener(this);
+        }
 	}
         
 	void buildToolsMenu(Menu menu)
@@ -1106,24 +1291,26 @@
 		parseverticesItem.addActionListener(this);
 		textureFieldItem = menu.add(new MenuItem("Texture Field"));
 		textureFieldItem.addActionListener(this);
-		alignItem = menu.add(new MenuItem("Align"));
+		alignItem = menu.add(new MenuItem("Align Objects"));
 		alignItem.addActionListener(this);
-		mirrorItem = menu.add(new MenuItem("Mirror Poses"));
-		mirrorItem.addActionListener(this);
 		reduceMorphItem = menu.add(new MenuItem("Reduce Morphs"));
 		reduceMorphItem.addActionListener(this);
 		reduce34MorphItem = menu.add(new MenuItem("Reduce Morphs (34)"));
 		reduce34MorphItem.addActionListener(this);
-                
+		menu.add("-");
 		menu.add(computeAOItem = new MenuItem("Compute AO"));
 		computeAOItem.addActionListener(this);
-		menu.add("-");
                 
+        if (Globals.ADVANCED)
+        {
+		mirrorItem = menu.add(new MenuItem("Mirror Poses"));
+		mirrorItem.addActionListener(this);
+		menu.add("-");
 		menu.add(memoryItem = new MenuItem("Memory Usage"));
 		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);
@@ -1141,6 +1328,7 @@
 		menu.add("-");
 		menu.add(editScriptItem = new MenuItem("Edit Script..."));
 		editScriptItem.addActionListener(this);
+        }
         }
         
         void ScreenFit()
@@ -1263,6 +1451,7 @@
             shadow.material = new cMaterial(obj.material);
             shadow.material.diffuse = 0.0001f;
             shadow.material.specular = 0.0001f;
+            //shadow.projectedVertices[1].x = 300;
             
             makeSomething(shadow);
         }
@@ -1469,9 +1658,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);
@@ -1642,7 +1831,7 @@
 		{
 			makeSomething(new BezierSurface());
 		} else
-		if (source == checkerItem)
+		if (source == overlayItem)
 		{
                     /*
 			Object3D obj = new BezierSurface(5,8);
@@ -1776,23 +1965,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;
@@ -1811,7 +1983,7 @@
 		if (source == invariantsItem)
 		{
                     System.out.println("Invariants:");
-                    GrafreeD.grafreeD.universe.invariants();
+                    Grafreed.grafreeD.universe.invariants();
 		} else
 		if (source == memoryItem)
 		{
@@ -1829,6 +2001,35 @@
 		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)
+		{
+                    Globals.ONESTEP = true;
+                    cameraView.repaint();
 		} else
 		if (source == screenfitButton)
 		{
@@ -1879,12 +2080,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)
 		{
@@ -1902,13 +2111,17 @@
 		{
 			paste(false);
 		} else
+		if (source == pasteIntoItem)
+		{
+			pasteInto(true, false);
+		} else
 		if (source == pasteLinkItem)
 		{
-			pasteInto(false);
+			pasteInto(false, false);
 		} else
 		if (source == pasteCloneItem)
 		{
-			pasteInto(true);
+			pasteInto(true, true);
 		} else
 		if (source == pasteExpandItem)
 		{
@@ -2100,9 +2313,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);
@@ -2110,11 +2323,11 @@
             Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
                         for (int i=0; i<group.selection.size(); i++)
                         {
-                            boolean random = CameraPane.RANDOM;
-                            CameraPane.RANDOM = false; // parse all random nodes
+                            boolean random = CameraPane.SWITCH;
+                            CameraPane.SWITCH = false; // parse all random nodes
                             group.selection.get(i).linkVerticesThis(content);
                       //      group.selection.get(i).setMasterThis(content); // should be identity
-                            CameraPane.RANDOM = random;
+                            CameraPane.SWITCH = random;
                         }
             Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
 		refreshContents();
@@ -2124,20 +2337,20 @@
 		{
                     for (int i=0; i<group.selection.size(); i++)
                     {
-                        boolean random = CameraPane.RANDOM;
-                        CameraPane.RANDOM = false; // parse all random nodes
+                        boolean random = CameraPane.SWITCH;
+                        CameraPane.SWITCH = false; // parse all random nodes
                         group.selection.get(i).linkVerticesThis(null);
-                        CameraPane.RANDOM = random;
+                        CameraPane.SWITCH = random;
                     }
 
                     refreshContents();
 		} else
 		if (source == relinkverticesItem)
 		{
-                    boolean random = CameraPane.RANDOM;
-                    CameraPane.RANDOM = false; // parse all random nodes
+                    boolean random = CameraPane.SWITCH;
+                    CameraPane.SWITCH = false; // parse all random nodes
                     group.selection.RelinkToSupport();
-                    CameraPane.RANDOM = random;
+                    CameraPane.SWITCH = random;
 
                     refreshContents();
 		} else
@@ -2152,9 +2365,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);
@@ -2167,9 +2380,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);
@@ -2186,7 +2399,7 @@
 		{
 			RevertMeshes();
 		} else
-		if (source == resetMeshItem)
+		if (source == resetAllItem)
 		{
 			ResetAll();
 		} else
@@ -2374,7 +2587,7 @@
 		} else
 		if (source == genNormalsMESHItem)
                 {
-			GenNormals(true); // TODO
+			GenNormalsMESH();
 		} else
 		if (source == genNormalsORGANItem)
                 {
@@ -2439,6 +2652,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)
                 {
@@ -2524,9 +2753,13 @@
                 {
 			SmoothMesh();
 		} else
-		if (source == transformgeometryItem)
+		if (source == transformGeometryItem)
 		{
                         TransformGeometry();
+		} else
+		if (source == transformChildrenItem)
+		{
+                        TransformChildren();
 		} else
 		if (source == resetTransformItem)
 		{
@@ -2534,7 +2767,11 @@
 		} else
 		if (source == resetCentroidItem)
 		{
-                        ResetCentroid();
+                        ResetCentroid(true);
+		} else
+		if (source == resetCentroidXZItem)
+		{
+                        ResetCentroid(false);
 		} else
 		if (source == resetParentItem)
 		{
@@ -2698,6 +2935,24 @@
                     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)
 		{
@@ -2734,6 +2989,8 @@
                     bigThree.add(centralPanel);
                     bigThree.add(XYZPanel);
                     bigThree.FlushUI();
+                    
+                    cameraView.requestFocusInWindow();
                 } else
 		if (source == fourButton)
 		{
@@ -2769,6 +3026,8 @@
                     bigThree.ClearUI();
                     bigThree.add(scenePanel);
                     bigThree.FlushUI();
+                    
+                    cameraView.requestFocusInWindow();
                 } else
 		if (source == sixButton)
 		{
@@ -2805,6 +3064,8 @@
                     bigThree.add(scenePanel);
                     bigThree.add(centralPanel);
                     bigThree.FlushUI();
+                    
+                    cameraView.requestFocusInWindow();
                 } else
 		if (source == sevenButton)
 		{
@@ -2842,6 +3103,8 @@
                     bigThree.add(centralPanel);
                     bigThree.add(XYZPanel);
                     bigThree.FlushUI();
+                    
+                    cameraView.requestFocusInWindow();
                 } else
 		if (source == rootButton)
 		{
@@ -2853,6 +3116,7 @@
                                 EditObject(obj);
                     }
 
+                    cameraView.requestFocusInWindow();
                     refreshContents(true);
 		} else
 		if (source == closeButton)
@@ -2874,6 +3138,8 @@
                                 break;
                             }
                     }
+                    
+                    cameraView.requestFocusInWindow();
                     refreshContents(true);
 		} else
 		if (source == editItem || source == editButton)
@@ -2890,9 +3156,9 @@
 				child.CloseUI();
                                 listUI.remove(child);
                                 
-                                child.editWindow = null; // ???????????
+                                //child.editWindow = null; // ???????????
 			}
-			objEditor.ctrlPanel.validate();
+			objEditor.ctrlPanel.FlushUI();
 			//objEditor.jTree.clearSelection();
 			//objEditor.ResetSliders();
                     refreshContents(true);
@@ -2976,7 +3242,10 @@
                         frontView.object = group;
                         sideView.object = group;
                     }
-                    group.editWindow = this;
+                    
+// fix "+" issue
+                    //group.editWindow = this;
+                    
                     /*
                     currentLayout = radio.layout;
                     if (currentLayout == null)
@@ -2988,8 +3257,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() == revertCameraItem)
+                {
+                    cameraView.RevertCamera();
+                    cameraView.repaint();
+                    return;
+        //        } else if (event.getSource() == textureButton)
+        //        {
+        //            return; // true;
+                } 
                 else
                 {
 			//return super.action(event, arg);
@@ -2998,7 +3282,6 @@
 	}
         
         boolean useclient = false;
-        cRadio radio;
         
         void ToggleRoot()
         {
@@ -3050,6 +3333,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()
         {
@@ -3162,7 +3467,7 @@
             refreshContents();
         }
         
-        void ResetCentroid()
+        void ResetCentroid(boolean full)
         {
             Object3D obj;
             for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
@@ -3177,12 +3482,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];
@@ -3211,7 +3520,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)
@@ -3248,9 +3558,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);
                 }
@@ -3292,6 +3602,13 @@
 	void GenNormals(boolean crease)
 	{
 		group.GenNormalsS(crease);
+		
+		refreshContents();
+	}
+	
+	void GenNormalsMESH()
+	{
+		group.GenNormalsMeshS();
 		
 		refreshContents();
 	}
@@ -3464,8 +3781,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++)
             {
@@ -3490,7 +3807,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);
                             }
@@ -3505,7 +3822,7 @@
                 makeSomething(buffer, i==group.selection.size()-1);
             }
             
-            GrafreeD.epsequal = epsequal;
+            Grafreed.epsequal = epsequal;
             
             refreshContents();
 	}
@@ -3523,7 +3840,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;
                             
@@ -3611,11 +3937,11 @@
 
             SwitchNode sn = new SwitchNode(poses, Object3D.GEOMETRY);
 
-            boolean random = CameraPane.RANDOM;
-            CameraPane.RANDOM = false; // parse all random nodes
+            boolean random = CameraPane.SWITCH;
+            CameraPane.SWITCH = false; // parse all random nodes
             lowres.linkVerticesThis(null);
             lowres.linkVerticesThis(sn);
-            CameraPane.RANDOM = random;
+            CameraPane.SWITCH = random;
 
             System.err.flush();
 
@@ -3655,7 +3981,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);
             
@@ -3849,9 +4175,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);
@@ -3860,7 +4186,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.");
@@ -3907,6 +4233,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();
 	}
 	
@@ -3995,7 +4333,7 @@
                     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;
@@ -4085,7 +4423,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++)
@@ -4094,10 +4431,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
@@ -4107,16 +4442,17 @@
 //            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())
+                            {
+                                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;
                         }
@@ -4129,6 +4465,26 @@
 		
 		freezemodel = false;
 	}
+        
+        void refreshContents(boolean cp)
+        {
+            if (!Globals.MOUSEDRAGGED)
+            {
+                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)
 	{
@@ -4200,16 +4556,18 @@
 	{
 		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)
 		{
+                    Save();
 			//int indices[] = jList.getSelectedIndices();
 			//for (int i = indices.length - 1; i >= 0; i--)
 			//jList.remove(indices[i]);
@@ -4245,16 +4603,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();
@@ -4286,21 +4644,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();
@@ -4314,7 +4674,7 @@
 	//		return;
 		boolean first = true;
 		
-		if (GrafreeD.clipboardIsTempGroup)
+		if (Grafreed.clipboardIsTempGroup)
 		{
 			Composite temp;
 			
@@ -4325,7 +4685,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();
                                 
@@ -4359,21 +4719,21 @@
 			//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();
 		refreshContents();
 	}
 	
-	void pasteInto(boolean copyit)
+	void pasteInto(boolean copyit, boolean clone)
 	{
 //		if (GrafreeD.clipboard == null)
 //			return;
@@ -4402,15 +4762,22 @@
 		if (copyit)
 		{
 		//	paste(false);
-                    CloneClipboard(false); // sept 2014
+                        if (clone)
+                        {
+                            CloneClipboard(false); // sept 2014
+                        }
+                        else
+                        {
+                            paste(false);
+                        }
 		}
 		else
 		{
 			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();)
 				{
@@ -4420,7 +4787,7 @@
 				}
 			} else
 			{
-				linkSomething(GrafreeD.clipboard); //.get(0));
+				linkSomething(Grafreed.clipboard); //.get(0));
 			}
 		}
             }
@@ -4825,21 +5192,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)
         {
@@ -4863,26 +5215,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();
@@ -4946,10 +5281,18 @@
 	cButton flashSelectionButton;
 	cButton editButton;
 	cButton uneditButton;
+	JCheckBox allParamsButton;
 	cButton clearpanelButton;
-	cButton allParamsButton;
 	cButton unselectButton;
 	
+	cButton minButton;
+	cButton maxButton;
+	cButton fullButton;
+	cButton undoButton;
+	cButton redoButton;
+	cButton saveButton;
+	cButton oneStepButton;
+        
 	cButton screenfitButton;
 	cButton screenfitpointButton;
 	cButton snapobjectButton;
@@ -4960,14 +5303,6 @@
 	cButton closeButton;
 
 	cButton setsupportButton;
-        
-	cButton twoButton;
-	cButton sixButton;
-	cButton threeButton;
-	cButton sevenButton;
-	cButton fourButton; // full panel
-	cButton oneButton; // full XYZ
-        //cButton currentLayout;
         
 	//
         //Composite
@@ -4980,6 +5315,8 @@
 	private MenuItem lookFromItem;
 	private MenuItem switchItem;
 	private MenuItem cutItem;
+	private MenuItem undoItem;
+	private MenuItem redoItem;
 	private MenuItem duplicateItem;
 	private MenuItem cloneItem;
 	private MenuItem cloneSupportItem;
@@ -4993,7 +5330,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;
@@ -5004,6 +5341,7 @@
 	private MenuItem mergeGeometriesItem;
 	private MenuItem copyItem;
 	private MenuItem pasteItem;
+	private MenuItem pasteIntoItem;
 	private MenuItem pasteLinkItem;
 	private MenuItem pasteCloneItem;
 	private MenuItem pasteExpandItem;
@@ -5042,6 +5380,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;
@@ -5053,8 +5395,10 @@
 	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;
@@ -5101,7 +5445,7 @@
 	private MenuItem blobItem;
 	private MenuItem latheItem;
 	private MenuItem bezierItem;
-	private MenuItem checkerItem;
+	private MenuItem overlayItem;
 	private MenuItem meshItem;
 //	private MenuItem meshGroupItem;
 	private MenuItem springItem;
@@ -5123,11 +5467,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;
@@ -5137,4 +5476,8 @@
 	private MenuItem analyzeItem;
 	private MenuItem dumpItem;
 	//boolean freezemodel = false;
+        
+    Menu cameraMenu;
+    MenuItem editCameraItem;
+    MenuItem revertCameraItem;
 }

--
Gitblit v1.6.2