From 1af7d3700724834e40ad8636bc9a56cdc3b19b15 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Sat, 27 Jul 2019 11:52:38 -0400
Subject: [PATCH] New layout icons

---
 GroupEditor.java |  826 ++++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 597 insertions(+), 229 deletions(-)

diff --git a/GroupEditor.java b/GroupEditor.java
index 33acfd4..84ef59f 100644
--- a/GroupEditor.java
+++ b/GroupEditor.java
@@ -60,6 +60,12 @@
 		this.copy = this.group = group;
 		//selectees = this.group.selectees;
 		
+        if (copy.versions == null)
+        {
+            copy.versions = new byte[100][];
+            copy.versionindex = -1;
+        }
+        
 		if(ui)
                     SetupUI(objEditor);
 	}
@@ -80,10 +86,22 @@
 		SetupViews(objEditor);
                 
                 ((cRadio)radioPanel.getComponent(0)).SetCamera(cameraView.renderCamera, true);
+                
+        if (copy.versions == null)
+        {
+            copy.versions = new byte[100][];
+            copy.versionindex = -1;
+            
+            Save(true);
+        }
 	}
 
     void CloneSelection(boolean supports)
     {
+        if (Globals.REPLACEONMAKE)
+            Save();
+        boolean keep = Globals.REPLACEONMAKE;
+        Globals.REPLACEONMAKE = false;
         //   Object3D keep = GrafreeD.clipboard;
            //Object3D obj;
            for (int i=0; i<group.selection.size(); i++)// Enumeration e = group.selection.elements(); e.hasMoreElements();)
@@ -94,6 +112,7 @@
                
                makeSomething(clone, i==group.selection.size()-1);
            }
+        Globals.REPLACEONMAKE = keep;
     }
 
     void CloneClipboard(boolean supports)
@@ -150,6 +169,8 @@
     
 	void SetupMenu2(GroupEditor oe)
 	{
+                oe.jTree = new cTree();
+
 		Menu menu;
 		oe.menuBar.add(menu = new Menu("Edit"));
 		//editItem = menu.add(new MenuItem("Edit"));
@@ -160,7 +181,7 @@
 //		redoItem = menu.add(new MenuItem("Redo"));
 //		redoItem.addActionListener(this);
 //		menu.add("-");
-		duplicateItem = menu.add(new MenuItem("Duplicate"));
+		duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate"));
 		duplicateItem.addActionListener(this);
 		cloneItem = menu.add(new MenuItem("Clone"));
 		cloneItem.addActionListener(this);
@@ -187,8 +208,8 @@
 //		pasteExpandItem = menu.add(new MenuItem("Paste expand"));
 //		pasteExpandItem.addActionListener(this);
 		menu.add("-");
-		clearItem = menu.add(new MenuItem("Clear"));
-		clearItem.addActionListener(this);
+		deleteItem = menu.add(new MenuItem("Delete"));
+		deleteItem.addActionListener(this);
                 
         if (Globals.ADVANCED)
         {
@@ -202,23 +223,23 @@
         //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(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(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(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"));
+        cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Show Handles"));
         toggleHandleItem.addItemListener(this);
         toggleHandleItem.setState(CameraPane.HANDLES);
         
@@ -273,7 +294,7 @@
         {
 		oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest"));
 		//cameraMenu.add(lookFromItem = new MenuItem("Look From Selection"));
-		//cameraMenu.add(switchItem = new MenuItem("Reverse View"));
+		//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..."));
@@ -281,7 +302,7 @@
 		editLeafItem.addActionListener(this);
 		lookAtItem.addActionListener(this);
 		//lookFromItem.addActinoListener(this);
-		//switchItem.addActionListener(this);
+		//switchViewItem.addActionListener(this);
         }
         
 		oe.menuBar.add(menu = new Menu("Setting"));
@@ -326,21 +347,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"));
@@ -348,8 +377,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);
@@ -357,13 +384,11 @@
 		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"));
@@ -374,13 +399,14 @@
 		shadowYItem.addActionListener(this);
                 shadowZItem = menu.add(new MenuItem("Shadow Blue"));
 		shadowZItem.addActionListener(this);
+		attributeItem = menu.add(new MenuItem("Attribute"));
+		attributeItem.addActionListener(this);
+                
         if (Globals.ADVANCED)
         {
 		menu.add("-");
 		linkerItem = menu.add(new MenuItem("Linker"));
 		linkerItem.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"));
@@ -409,7 +435,7 @@
 		genNormalsMESHItem.addActionListener(this);
         if (Globals.ADVANCED)
         {
-		genNormalsMINEItem = menu.add(new MenuItem("My Normals"));
+		genNormalsMINEItem = menu.add(new MenuItem("Stitch Normals"));
 		genNormalsMINEItem.addActionListener(this);
         }
 		stripifyItem = menu.add(new MenuItem("Stripify"));
@@ -502,10 +528,15 @@
 		attachBumpItem.addActionListener(this);
 		pigmentBumpItem = menu.add(new MenuItem("Pigment -> Bump"));
 		pigmentBumpItem.addActionListener(this);
+                //embedTexturesItem
 		detachPigmentItem = menu.add(new MenuItem("Detach Pigment"));
 		detachPigmentItem.addActionListener(this);
 		detachBumpItem = menu.add(new MenuItem("Detach Bump"));
 		detachBumpItem.addActionListener(this);
+		embedTexturesItem = menu.add(new MenuItem("Embed Textures"));
+		embedTexturesItem.addActionListener(this);
+		deEmbedTexturesItem = menu.add(new MenuItem("De-embed Textures"));
+		deEmbedTexturesItem.addActionListener(this);
 		menu.add("-");
 		sortbysizeItem = menu.add(new MenuItem("Sort by size"));
 		sortbysizeItem.addActionListener(this);
@@ -532,6 +563,7 @@
 		buildToolsMenu(menu);
 	}
 	
+        
 	void SetupUI2(ObjEditor oe)
 	{
             // June 2019
@@ -574,51 +606,79 @@
         oe.radioPanel.add(dummyButton);
         oe.buttonGroup.add(dummyButton);
          */
+                cGridBag copyOptionsPanel = new cGridBag();
+                                        
+                copyOptionsPanel.preferredHeight = 1;
+                
                 //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);
+                if (Globals.ADVANCED)
+                {
+                    oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                    maxButton.setToolTipText("Maximize window");
+                    maxButton.addActionListener(this);
+                }
                 
-		oe.toolbarPanel.add(fullButton = new cButton("\u2b1c", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !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(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                screenfitButton.setToolTipText("Screen fit");
+		screenfitButton.addActionListener(this);
+
+		oe.toolbarPanel.add(restoreCameraButton = GetButton("icons/eye.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                restoreCameraButton.setToolTipText("Restore viewpoint");
+		restoreCameraButton.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");
+		copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                saveButton.setToolTipText("New version");
 		saveButton.addActionListener(this);
+                                                
+		copyOptionsPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                undoButton.setToolTipText("Previous version");
+		undoButton.addActionListener(this);
+                undoButton.setEnabled(false);
                 
-                oe.toolbarPanel.add(liveCB = new cCheckBox("Live", Globals.isLIVE())); //, oe.aConstraints);
+                cGridBag updown = new cGridBag().setVertical(true);
+		updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                restoreButton.setToolTipText("Restore current");
+		restoreButton.addActionListener(this);
+                restoreButton.setEnabled(false);
+                
+		updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                replaceButton.setToolTipText("Replace current");
+		replaceButton.addActionListener(this);
+                replaceButton.setEnabled(false);
+                
+                copyOptionsPanel.add(updown);
+                
+		copyOptionsPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                redoButton.setToolTipText("Next version");
+		redoButton.addActionListener(this);
+                redoButton.setEnabled(false);
+                
+                oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
                 liveCB.setToolTipText("Enable animation");
                                 liveCB.addItemListener(this);
 
-		oe.toolbarPanel.add(oneStepButton = new cButton("\u29f4", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.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);
+                oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
                 fastCB.setToolTipText("Fast mode");
                                 fastCB.addItemListener(this);
                                 
-                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);
-                screenfitButton.setToolTipText("Screen fit");
-		screenfitButton.addActionListener(this);
+                //oe.toolboxPanel.Return();
+                
+//                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);
@@ -628,51 +688,129 @@
                         oe.toolbarPanel.add(snapobjectButton = new cButton("O+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                         snapobjectButton.addActionListener(this);
                         snapobjectButton.setToolTipText("Snap Object");
+                        
+		oe.toolbarPanel.add(fourButton = GetButton("icons/controls-horizontal.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		fourButton.addActionListener(this);
+                fourButton.setToolTipText("Show control panel only");
                 }
 
-		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);
-                twoButton.setToolTipText("Show center view only");
+		oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                twoButton.setToolTipText("Show 3D view only");
 		twoButton.addActionListener(this);
-		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);
-                sixButton.setToolTipText("2-column layout left");
-		sixButton.addActionListener(this);
-		oe.toolbarPanel.add(threeButton = new cButton("|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
-                threeButton.setToolTipText("2-column layout right");
+                this.fullscreenLayout = twoButton;
+                
+		oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                threeButton.setToolTipText("Show controls and 3D view");
 		threeButton.addActionListener(this);
-		oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
-                sevenButton.setToolTipText("3-column layout");
-		sevenButton.addActionListener(this);
+		oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                sixButton.setToolTipText("Show 3D view and controls");
+		sixButton.addActionListener(this);
+//		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);
-                rootButton.setToolTipText("Edit selection in new tab");
+		oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                rootButton.setToolTipText("Open 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);
-                        
-		editCommandsPanel.add(editButton = new cButton("+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
-                editButton.setToolTipText("Edit selection");
+
+                // 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);
+                }
+                
+                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 item switcher");
+                               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 = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                editButton.setToolTipText("Pin selection controls");
 		editButton.addActionListener(this);
 
-		editCommandsPanel.add(uneditButton = new cButton("-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
-                uneditButton.setToolTipText("Unedit selection");
+		editCommandsPanel.add(uneditButton = GetButton("icons/remove.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                uneditButton.setToolTipText("Remove selection controls");
 		uneditButton.addActionListener(this);
 
 		editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
-                allParamsButton.setToolTipText("Edit all params");
+                allParamsButton.setToolTipText("Show all controle");
 		allParamsButton.addActionListener(this);
 
 		editCommandsPanel.add(clearPanelButton = new cButton("C", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
@@ -683,8 +821,13 @@
                 unselectButton.setToolTipText("Unselect");
 		unselectButton.addActionListener(this);
 
+		editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                flashSelectionButton.setToolTipText("Highlight selection");
+		flashSelectionButton.addActionListener(this);
+                
                 editCommandsPanel.preferredHeight = 1;
                 
+                SetPinStates(false);
 //                oe.treePanel.add(commandsPanel);
 //                oe.treePanel.Return();
                 
@@ -703,29 +846,17 @@
 
                 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();
+        cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
+            versionSlider = (cNumberSlider)sliderPane.getComponent(1);
+            sliderPane.preferredHeight = 1;
                 
 //        mainPanel.setDividerLocation(0.5); //1.0);
 //        mainPanel.setResizeWeight(0.5);
@@ -748,29 +879,49 @@
 		dgr.addDragGestureListener(this);
 		}catch(Exception e) {}
 		*/
-        radio.layout = sevenButton;
+        radio.layout = sixButton; // sevenButton;
         oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
 	}
         
         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);
                                 
                 panel.add(zoomBoxCB = new cCheckBox("Zoom", CameraPane.ZOOMBOXMODE)); //, constraints);
-                zoomBoxCB.setToolTipText("Display bounding boxes when moving the wheel");
+                zoomBoxCB.setToolTipText("Display only for wheel");
                                 zoomBoxCB.addItemListener(this);
 
         if (true) // Globals.ADVANCED)
         {
-                panel.add(supportCB = new cCheckBox("Support", CameraPane.SUPPORT)); //, constraints);
-                supportCB.setToolTipText("Enable rigging");
-                                supportCB.addItemListener(this);
+//                panel.add(supportCB = new cCheckBox("Support", CameraPane.SUPPORT)); //, constraints);
+//                supportCB.setToolTipText("Enable rigging");
+//                                supportCB.addItemListener(this);
+
+                panel.add(freezeCB = new cCheckBox("Freeze", Globals.FREEZEONMOVE)); //, constraints);
+                freezeCB.setToolTipText("Fast moving camera");
+                                freezeCB.addItemListener(this);
 
         //        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);
@@ -787,6 +938,8 @@
 //                panel.add(speakerMocapCB = new cCheckBox("Mocap", CameraPane.SPEAKERMOCAP), constraints);
 //                                speakerMocapCB.addItemListener(this);
 
+                panel.Return();
+                
             if (false)
             {
                 // handled in scripts
@@ -801,20 +954,39 @@
         	//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 target");
+                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.setToolTipText("When live compute shadows");
                                 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("Choose a single item");
+                                toggleSwitchCB.addItemListener(this);
+                                
+                panel.add(autokeepCB = new cCheckBox("Auto-replace", Globals.REPLACEONMAKE)); //, constraints);
+                autokeepCB.setToolTipText("On structure change");
+                                autokeepCB.addItemListener(this);
+
+                panel.Return();
             if (Globals.ADVANCED)
             {
                 panel.add(lookAtCB = new cCheckBox("Target", CameraPane.LOOKAT)); //, constraints);
@@ -825,10 +997,15 @@
         }
                                 
                 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);
 
         }
 	
@@ -836,7 +1013,7 @@
         {
             cRadio radioButton = new cRadio(obj.name);
             
-            // Patch to avoid bug with transparency.
+            // June 2019. Patch to avoid bug with transparency.
             radioButton.hadMaterial = obj.material != null;
             if (!radioButton.hadMaterial)
             {
@@ -844,7 +1021,7 @@
             }
             
             radioButton.SetObject(obj);
-            radioButton.layout = sevenButton;
+            radioButton.layout = sixButton; // sevenButton;
             radioButton.SetCamera(cameraView.renderCamera, false);
             radioButton.addActionListener(this);
             radioPanel.add(radioButton);
@@ -864,25 +1041,28 @@
             /*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;
+        cCheckBox freezeCB;
+        //cToggleButton trackCB;
+        cCheckBox trackCB;
+        cCheckBox smoothfocusCB;
 //        JCheckBox speakerMocapCB;
-        JCheckBox speakerCameraCB;
-        JCheckBox speakerFocusCB;
-        JCheckBox debugCB;
+        cCheckBox speakerCameraCB;
+        cCheckBox speakerFocusCB;
+        cCheckBox debugCB;
         
-        JCheckBox oeilCB;
-        JCheckBox shadowCB;
-        JCheckBox lookAtCB;
+        cCheckBox oeilCB;
+        cCheckBox shadowCB;
+        cCheckBox autokeepCB;
+        cCheckBox lookAtCB;
         
 //        static int COLOR = 1;
 //        static int MATERIAL = 2;
@@ -890,9 +1070,9 @@
         
         int dropAttributes = Object3D.COLOR | Object3D.MATERIAL;
         
-        JCheckBox colorCB;
-        JCheckBox materialCB;
-        JCheckBox textureCB;
+        cCheckBox colorCB;
+        cCheckBox materialCB;
+        cCheckBox textureCB;
         
         public void itemStateChanged(ItemEvent e)
         {
@@ -989,6 +1169,14 @@
             {
                 Globals.COMPUTESHADOWWHENLIVE ^= true;
             }
+            else if(e.getSource() == freezeCB)
+            {
+                Globals.FREEZEONMOVE ^= true;
+            }
+            else if(e.getSource() == autokeepCB)
+            {
+                Globals.REPLACEONMAKE ^= true;
+            }
             else if(e.getSource() == lookAtCB)
             {
                 cameraView.ToggleLookAt();
@@ -1005,7 +1193,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;
@@ -1068,8 +1257,6 @@
                         }
                     }
                     
-                    String string = (String) object;
-                    
                     System.out.println("Transfer = " + object + "; drop : " + target);
 //                    if( object instanceof java.io.File[])
 //                    {
@@ -1077,6 +1264,8 @@
 //                        objEditor.DropFile((java.io.File[]) object, true);
 //                        return;
 //                    }
+                    
+                    String string = object.toString();
                     
                     // File path for Mac and Windows
                     if (string.charAt(0) == '/' || string.charAt(1) == ':')
@@ -1122,23 +1311,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
@@ -1243,22 +1442,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"));
@@ -1284,15 +1491,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)
@@ -1308,6 +1515,9 @@
 		animationItem.addItemListener(this);
                 animationItem.setState(Globals.ANIMATION);
                 
+		menu.add(archiveItem = new MenuItem("Archive3D..."));
+		archiveItem.addActionListener(this);
+                
 		menu.add("-");
 		parseverticesItem = menu.add(new MenuItem("Multiplicity"));
 		parseverticesItem.addActionListener(this);
@@ -1320,6 +1530,8 @@
 		reduce34MorphItem = menu.add(new MenuItem("Reduce Morphs (34)"));
 		reduce34MorphItem.addActionListener(this);
 		menu.add("-");
+		menu.add(memoryItem = new MenuItem("Memory Usage"));
+		memoryItem.addActionListener(this);
 		menu.add(computeAOItem = new MenuItem("Compute AO"));
 		computeAOItem.addActionListener(this);
                 
@@ -1328,8 +1540,6 @@
 		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("Print"));
@@ -1477,6 +1687,30 @@
             
             makeSomething(shadow);
         }
+
+    private void ClearUnpinned()
+    {
+        //for (Object3D obj : listUI)
+        for (int i=listUI.size(); --i>=0;)
+        {
+            Object3D obj = listUI.elementAt(i);
+            if (!obj.pinned)
+            {
+                obj.CloseUI();
+                listUI.remove(i);
+            }
+        }
+    }
+
+    private void EditElement(Object3D elem, boolean newWindow)
+    {
+        //    if (!(elem instanceof Composite))
+        //        newWindow = false;
+            listUI.add(elem);
+            elem.openEditWindow(this, newWindow); //, false);
+            System.out.println("edit : " + elem);
+            elem.editWindow.refreshContents(true); // ? new
+    }
         
     /**
      * applyExample
@@ -1721,7 +1955,7 @@
 		{
                     ScreenFit();
                 } else
-		if (source == switchItem)
+		if (source == switchViewItem)
 		{
 			cVector v1 = new cVector();
 			cVector v2 = new cVector();
@@ -1730,11 +1964,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);
@@ -1813,27 +2047,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
@@ -1853,7 +2087,7 @@
 		{
 			makeSomething(new BezierSurface());
 		} else
-		if (source == overlayItem)
+		if (source == overlayItem || source == overlayButton)
 		{
                     /*
 			Object3D obj = new BezierSurface(5,8);
@@ -1901,7 +2135,7 @@
                         s.setup();
 			makeSomething(s);
 		} else
-		if (source == lightItem)
+		if (source == lightItem || source == lightButton)
 		{
 			makeSomething(new Light());
 		} else
@@ -1951,30 +2185,30 @@
                             
 			group(g);
 		} else
-		if (source == loopItem)
+		if (source == loopItem || source == loopButton)
 		{
                         Composite csg = new GroupLeaf();
                         csg.count = 5;
 			group(csg);
-                        Composite child = new cGroup();
+                        Composite child = new cGroup("Branch");
                         csg.addChild(child);
                         child.addChild(csg);
 		} else
 		if (source == doubleItem)
 		{
-                        Composite csg = new GroupLeaf();
+                        Composite csg = new GroupLeaf("Fork");
                         csg.count = 5;
 			group(csg);
-                        Composite child = new cGroup();
+                        Composite child = new cGroup("Branch A");
                         csg.addChild(child);
                         child.addChild(csg);
-                        child = new cGroup();
+                        child = new cGroup("Branch B");
                         csg.addChild(child);
                         child.addChild(csg);
 		} else
 		if (source == tripleItem)
 		{
-                        Composite csg = new GroupLeaf();
+                        Composite csg = new GroupLeaf("Trident");
                         csg.count = 4;
 			group(csg);
                         Composite child = new cGroup();
@@ -2038,15 +2272,31 @@
 		} else
 		if (source == undoButton)
 		{
+                        // Go to previous version
+			//if (!Undo())
+                            //java.awt.Toolkit.getDefaultToolkit().beep();
 			Undo();
+		} else
+		if (source == restoreButton)
+		{
+                        // Restore current version
+			Restore();
+		} else
+		if (source == replaceButton)
+		{
+                        // Overwrite current version
+			Replace();
 		} else
 		if (source == redoButton)
 		{
+                        // Go to next version
 			Redo();
 		} else
 		if (source == saveButton)
 		{
-			Save();
+                        // Save a new version
+			if (!Save(true))
+                            java.awt.Toolkit.getDefaultToolkit().beep();
 		} else
 		if (source == oneStepButton)
 		{
@@ -2055,17 +2305,14 @@
 		} else
 		if (source == screenfitButton)
 		{
-			//Reload(lastConverter, lastFilename, true);
                     ScreenFit();
 		} else
 		if (source == screenfitpointButton)
 		{
-			//Reload(lastConverter, lastFilename, true);
                     ScreenFitPoint();
 		} else
 		if (source == snapobjectButton)
 		{
-			//Reload(lastConverter, lastFilename, true);
                     SnapObject();
 		} else
 //		if (event.getSource() == recompileButton)
@@ -2429,7 +2676,7 @@
 		{
 			StepAll();
 		} else
-		if (source == clearItem) // || event.getSource() == clearButton)
+		if (source == deleteItem) // || event.getSource() == clearButton)
 		{
 			//int indices[] = jList.getSelectedIndices();
 			//for (int i = indices.length - 1; i >= 0; i--)
@@ -2441,9 +2688,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)
 		{
@@ -2461,11 +2708,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);
@@ -2567,7 +2814,7 @@
 		{
 			group(new cLinker());
 		} else
-		if (source == textureItem)
+		if (source == textureItem || source == textureButton)
 		{
 			group(new TextureNode());
 		} else
@@ -2587,17 +2834,30 @@
 		{
 			CastShadow(2);
 		} else
-		if (source == ungroupItem)
+		if (source == ungroupItem || source == ungroupButton)
 		{
-			//ungroup();
+                    boolean hasRoot = false;
+                    
                     for (int i=0; i<group.selection.size(); i++)
                     {
-                        Ungroup(group.selection.get(i));
+                        if (group.selection.get(i) == group)
+                        {
+                            hasRoot = true;
+                            break;
+                        }
                     }
 
-                    ClearSelection(false);
-                    
-                    refreshContents();
+                    if (!hasRoot)
+                    {
+                        for (int i=0; i<group.selection.size(); i++)
+                        {
+                            Ungroup(group.selection.get(i));
+                        }
+
+                        ClearSelection(false);
+
+                        refreshContents();
+                    }
 		} else
 		if (source == genUVItem)
                 {
@@ -2898,7 +3158,7 @@
 			for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
 			{
 				obj = (Object3D)e.nextElement();
-                                obj.SetBumpTexture(null);
+                                obj.ResetBumpTexture();
 			}
 			
 			refreshContents();
@@ -2914,6 +3174,31 @@
 			
 			refreshContents();
 		} else
+		if (source == embedTexturesItem)
+		{
+			Object3D obj;
+			for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
+			{
+				obj = (Object3D)e.nextElement();
+                                obj.EmbedTextures(true);
+			}
+			
+			refreshContents();
+		} else
+		if (source == deEmbedTexturesItem)
+		{
+			Object3D obj;
+			for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
+			{
+				obj = (Object3D)e.nextElement();
+                                obj.EmbedTextures(false);
+			}
+			
+                CameraPane.texturepigment.clear();
+                CameraPane.texturebump.clear();
+                
+			refreshContents();
+		} else
 		if (source == flashSelectionButton)
 		{
 			CameraPane.flash = true;
@@ -2925,6 +3210,10 @@
 		if (source == twoButton)
 		{
                     radio.layout = twoButton;
+                    
+                    if (CameraPane.FULLSCREEN)
+                        fullscreenLayout = radio.layout;
+                    
                     // bug
                     //gridPanel.setDividerLocation(1.0);
                     //bigPanel.setDividerLocation(0.0);
@@ -2980,6 +3269,9 @@
 		{
                     radio.layout = threeButton;
                     
+                    if (CameraPane.FULLSCREEN)
+                        fullscreenLayout = radio.layout;
+                    
 //                    bigThree.remove(scenePanel);
 //                    bigThree.remove(centralPanel);
 //                    bigThree.remove(XYZPanel);
@@ -3008,8 +3300,8 @@
 //                    centralPanel.setVisible(true);
 //                    XYZPanel.setVisible(true);
                     bigThree.ClearUI();
+                    bigThree.add(scenePanel);
                     bigThree.add(centralPanel);
-                    bigThree.add(XYZPanel);
                     bigThree.FlushUI();
                     
                     cameraView.requestFocusInWindow();
@@ -3017,6 +3309,9 @@
 		if (source == fourButton)
 		{
                     radio.layout = fourButton;
+                    
+                    if (CameraPane.FULLSCREEN)
+                        fullscreenLayout = radio.layout;
                     
 //                    bigThree.remove(scenePanel);
 //                    bigThree.remove(centralPanel);
@@ -3055,6 +3350,9 @@
 		{
                     radio.layout = sixButton;
                     
+                    if (CameraPane.FULLSCREEN)
+                        fullscreenLayout = radio.layout;
+                    
 //                    bigThree.remove(scenePanel);
 //                    bigThree.remove(centralPanel);
 //                    bigThree.remove(XYZPanel);
@@ -3083,8 +3381,8 @@
 //                    centralPanel.setVisible(true);
 //                    XYZPanel.setVisible(false);
                     bigThree.ClearUI();
-                    bigThree.add(scenePanel);
                     bigThree.add(centralPanel);
+                    bigThree.add(scenePanel);
                     bigThree.FlushUI();
                     
                     cameraView.requestFocusInWindow();
@@ -3092,6 +3390,9 @@
 		if (source == sevenButton)
 		{
                     radio.layout = sevenButton;
+                    
+                    if (CameraPane.FULLSCREEN)
+                        fullscreenLayout = radio.layout;
                     
 //                    bigThree.remove(scenePanel);
 //                    bigThree.remove(centralPanel);
@@ -3159,7 +3460,8 @@
                                 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();
@@ -3172,6 +3474,12 @@
 		} 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)
@@ -3181,6 +3489,7 @@
 				Object3D child = (Object3D)e.nextElement();
                                 if(child.editWindow != null)
                                     objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
+                                child.pinned = false;
 				child.CloseUI();
                                 listUI.remove(child);
                                 
@@ -3197,6 +3506,7 @@
                     //copy.ClearUI();
                     for (Object3D obj : listUI)
                     {
+                        obj.pinned = false;
                         obj.CloseUI();
                     }
                     listUI.clear();
@@ -3206,7 +3516,7 @@
 		{
                     assert(copy == group);
                     
-                    objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
+                    //objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
                     
                     for (Object3D obj : listUI)
                     {
@@ -3255,6 +3565,9 @@
                     }
                     
                     copy = group;
+                    
+                    SetUndoStates();
+
                     //Globals.theRenderer.object = group;
                     if(!useclient)
                     {
@@ -3273,6 +3586,7 @@
                     
 // fix "+" issue
                     //group.editWindow = this;
+                    group.manipWindow = this;
                     
                     /*
                     currentLayout = radio.layout;
@@ -3280,6 +3594,13 @@
                         currentLayout = sevenButton;
                      */
                     radio.layout.doClick();
+                    
+                    ClearUnpinned();
+                    //Grafreed.Assert(group != null);
+                    //Grafreed.Assert(group.selection != null);
+                    SetPinStates(group.selection == null || group.selection.size() > 0);
+                    if (group.selection == null || group.selection.size() == 1)
+                        EditSelection(false);
                     keepparent = group.parent;
                     // PARENT = NULL or not???
                     //group.parent = null; // ROOT
@@ -3293,7 +3614,7 @@
                     cameraView.ProtectCamera();
                     cameraView.repaint();
                     return;
-                } else if (event.getSource() == revertCameraItem)
+                } else if (event.getSource() == restoreCameraItem || event.getSource() == restoreCameraButton)
                 {
                     cameraView.RevertCamera();
                     cameraView.repaint();
@@ -3872,7 +4193,7 @@
                             
                             try
                             {
-                                texturedata = Globals.theRenderer.GetTextureData(pigment, false, node.texres);
+                                texturedata = Globals.theRenderer.GetTextureData(tex, false, node.texres);
                             }
                             catch (Exception e)
                             {
@@ -4347,28 +4668,25 @@
 //		}
 //	}
 	
-        static boolean allparams = true;
-        
-        static Vector<Object3D> listUI = new Vector<Object3D>();
-        
 	void EditSelection(boolean newWindow)
 	{
+                if (group.selection == null)
+                {
+                     EditElement(group, newWindow); // ? new
+                     return;
+                }
+                
         //    aConstraints.gridy = 0;
 		for (int i=0; i<group.selection.size(); i++)
 		{
                     //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 || !newWindow)
                         {
-                        //    if (!(elem instanceof Composite))
-                        //        newWindow = false;
-                            listUI.add(elem);
-                            elem.openEditWindow(this, newWindow); //, false);
-                            System.out.println("edit : " + elem);
-                            elem.editWindow.refreshContents(true); // ? new
+                            EditElement(elem, newWindow); // ? new
                         }
 		}
 	}
@@ -4443,7 +4761,8 @@
 		//new Exception().printStackTrace();
 
 		freezemodel = true;
-		
+        ClearUnpinned();
+                    
 		/**/
 		//switch (event.id)
 		{
@@ -4476,7 +4795,7 @@
 			if (tps != null && tps.length > 0 && tps[0].getLastPathComponent() instanceof Camera)
                             // a camera
                         {
-                            if (tps[0].getLastPathComponent() != Globals.theRenderer.LightCamera())
+                            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());
@@ -4485,6 +4804,13 @@
                          //   Globals.theRenderer.eyeCamera = Globals.theRenderer.manipCamera;
                         }
                             
+                        if (tps != null && tps.length == 1)
+                        {
+                            EditSelection(false);
+                        }
+                        
+                        SetPinStates(tps != null && tps.length > 0);
+                        
 			refreshContents();
 			//return true;
 		}
@@ -4494,9 +4820,18 @@
 		freezemodel = false;
 	}
         
+        void SetPinStates(boolean enabled)
+        {
+            editButton.setEnabled(enabled);
+            uneditButton.setEnabled(enabled);
+            unselectButton.setEnabled(enabled);
+            flashSelectionButton.setEnabled(enabled);
+        }
+
         void refreshContents(boolean cp)
         {
-            if (!Globals.MOUSEDRAGGED)
+            if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
+            if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
             {
                 objEditor.ClearInfo(); // .GetMaterial());
 
@@ -4595,7 +4930,8 @@
                 
 		if (cut)
 		{
-                    Save();
+//        if (Globals.SAVEONMAKE) // Moved to the clipboard, no need to save.
+//                    Save();
 			//int indices[] = jList.getSelectedIndices();
 			//for (int i = indices.length - 1; i >= 0; i--)
 			//jList.remove(indices[i]);
@@ -4698,6 +5034,10 @@
 	
 	void paste(boolean expand)
 	{
+        if (Globals.REPLACEONMAKE)
+            Save();
+        boolean keep = Globals.REPLACEONMAKE;
+        Globals.REPLACEONMAKE = false;
 	//	if (GrafreeD.clipboard == null)
 	//		return;
 		boolean first = true;
@@ -4757,6 +5097,7 @@
                         Grafreed.clipboard.get(0).parent = keepparent;
 		}
 		
+        Globals.REPLACEONMAKE = keep;
 		ResetModel();
 		refreshContents();
 	}
@@ -4892,6 +5233,10 @@
         
 	void group(Object3D csg, boolean grab)
 	{
+        if (Globals.REPLACEONMAKE)
+            Save();
+        boolean keep = Globals.REPLACEONMAKE;
+        Globals.REPLACEONMAKE = false;
 		if (//false) // why??
                     !group.selection.isEmpty())
                 {
@@ -5005,10 +5350,15 @@
                 //node.add(csg);
 		//makeSomething(node);
 		makeSomething(csg);
+        Globals.REPLACEONMAKE = keep;
 	}
 	
         void Ungroup(Object3D g)
         {
+        if (Globals.REPLACEONMAKE)
+            Save();
+        boolean keep = Globals.REPLACEONMAKE;
+        Globals.REPLACEONMAKE = false;
             if (g instanceof HiddenObject)
             {
                 HiddenObject h = (HiddenObject) g;
@@ -5025,6 +5375,7 @@
                     objEditor.makeSomething(g.get(i), false);
                 }
             }
+        Globals.REPLACEONMAKE = keep;
         }
         
 	void ungroup()
@@ -5313,13 +5664,28 @@
 	cButton clearpanelButton;
 	cButton unselectButton;
 	
-	cButton minButton;
-	cButton maxButton;
-	cButton fullButton;
-	cButton undoButton;
-	cButton redoButton;
+	cButton restoreCameraButton;
+        
 	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;
@@ -5341,11 +5707,11 @@
 	//JTree jTree;
 	private MenuItem lookAtItem;
 	private MenuItem lookFromItem;
-	private MenuItem switchItem;
+	private MenuItem switchViewItem;
 	private MenuItem cutItem;
 	private MenuItem undoItem;
 	private MenuItem redoItem;
-	private MenuItem duplicateItem;
+	private JMenuItem duplicateItem;
 	private MenuItem cloneItem;
 	private MenuItem cloneSupportItem;
 	private MenuItem overwriteGeoItem;
@@ -5373,7 +5739,7 @@
 	private MenuItem pasteLinkItem;
 	private MenuItem pasteCloneItem;
 	private MenuItem pasteExpandItem;
-	private MenuItem clearItem;
+	private MenuItem deleteItem;
 	private MenuItem clearAllItem;
 	private MenuItem genUVItem;
 	private MenuItem genNormalsMESHItem;
@@ -5433,7 +5799,7 @@
 	private MenuItem frontItem;
 	private MenuItem cameraItem;
 	private MenuItem compositeItem;
-	private MenuItem randomItem;
+	private MenuItem switchItem;
 	private MenuItem physicsItem;
 	private MenuItem frameselectorItem;
 	private MenuItem scriptNodeItem;
@@ -5457,6 +5823,8 @@
 	private MenuItem attachBumpItem;
 	private MenuItem detachBumpItem;
 	private MenuItem pigmentBumpItem;
+	private MenuItem embedTexturesItem;
+	private MenuItem deEmbedTexturesItem;
 
 	private MenuItem particleItem;
 	private MenuItem ragdollItem;
@@ -5507,5 +5875,5 @@
         
     Menu cameraMenu;
     MenuItem editCameraItem;
-    MenuItem revertCameraItem;
+    MenuItem restoreCameraItem;
 }

--
Gitblit v1.6.2