From 47cd0f0a3870d843cb758535316060d30f15c811 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Mon, 24 Jun 2019 19:10:13 -0400
Subject: [PATCH] Toolbox + DnD

---
 GroupEditor.java |  493 +++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 391 insertions(+), 102 deletions(-)

diff --git a/GroupEditor.java b/GroupEditor.java
index 3fdc5c4..9b1b9d3 100644
--- a/GroupEditor.java
+++ b/GroupEditor.java
@@ -150,16 +150,19 @@
     
 	void SetupMenu2(GroupEditor oe)
 	{
+                oe.jTree = new cTree();
+
 		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"));
+                
+//		undoItem = menu.add(new MenuItem("Undo"));
+//		undoItem.addActionListener(this);
+//		redoItem = menu.add(new MenuItem("Redo"));
+//		redoItem.addActionListener(this);
+//		menu.add("-");
+		duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate"));
 		duplicateItem.addActionListener(this);
 		cloneItem = menu.add(new MenuItem("Clone"));
 		cloneItem.addActionListener(this);
@@ -175,7 +178,6 @@
 		copyItem.addActionListener(this);
 		pasteItem = menu.add(new MenuItem("Paste"));
 		pasteItem.addActionListener(this);
-		menu.add("-");
                 
 		menu.add("-");
 		pasteIntoItem = menu.add(new MenuItem("Paste into"));
@@ -202,7 +204,7 @@
         //zBufferItem.addActionListener(this);
         //cameraMenu.add(normalLensItem = new MenuItem("Normal Lens"));
         //normalLensItem.addActionListener(this);
-        cameraMenu.add(revertCameraItem = new MenuItem("Restore Camera"));
+        cameraMenu.add(revertCameraItem = new MenuItem("Restore Viewpoint"));
         revertCameraItem.addActionListener(this);
         
         cameraMenu.add(toggleFullScreenItem = new CheckboxMenuItem("Full Screen"));
@@ -245,7 +247,7 @@
 
                 cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug"));
                 toggleDebugItem.addItemListener(this);
-                toggleDebugItem.setState(CameraPane.DEBUG);
+                toggleDebugItem.setState(Globals.DEBUG);
 
                 cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum"));
                 toggleFrustumItem.addItemListener(this);
@@ -266,7 +268,7 @@
 //		animationItem.addItemListener(this);
 //                    animationItem.setState(CameraPane.ANIMATION);
         cameraMenu.add("-");
-        cameraMenu.add(editCameraItem = new MenuItem("Save Camera"));
+        cameraMenu.add(editCameraItem = new MenuItem("Save Viewpoint"));
         editCameraItem.addActionListener(this);
         
         if (Globals.ADVANCED)
@@ -334,13 +336,21 @@
 		frontItem.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);
+        if (Globals.ADVANCED)
+        {
 		switchGeoItem = menu.add(new MenuItem("Switch Geometry"));
 		switchGeoItem.addActionListener(this);
 		switchTransfoItem = menu.add(new MenuItem("Switch Transform"));
@@ -348,8 +358,6 @@
 		morphItem = menu.add(new MenuItem("Morph Group"));
 		morphItem.addActionListener(this);
                 
-        if (Globals.ADVANCED)
-        {
 		menu.add("-");
 		physicsItem = menu.add(new MenuItem("Physics"));
 		physicsItem.addActionListener(this);
@@ -368,11 +376,11 @@
 		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)
         {
@@ -469,6 +477,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);
@@ -526,6 +542,18 @@
 	
 	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());
@@ -556,23 +584,49 @@
          */
                 //this.AddOptions(oe.toolbarPanel, oe.aConstraints);
                 
-                oe.toolbarPanel.add(liveCB = new cCheckBox("Live", Globals.isLIVE())); //, oe.aConstraints);
+		//oe.toolbarPanel.add(minButton = new cButton("Min", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                //minButton.setToolTipText("Minimize window");
+		//minButton.addActionListener(this);
+                
+		oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                maxButton.setToolTipText("Maximize window");
+		maxButton.addActionListener(this);
+                
+		oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                fullButton.setToolTipText("Full-screen window");
+		fullButton.addActionListener(this);
+                
+		oe.toolboxPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                undoButton.setToolTipText("Undo changes");
+		undoButton.addActionListener(this);
+                
+		oe.toolboxPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                redoButton.setToolTipText("Redo changes");
+		redoButton.addActionListener(this);
+                
+		oe.toolboxPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                saveButton.setToolTipText("Save changes");
+		saveButton.addActionListener(this);
+                
+                oe.toolboxPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
                 liveCB.setToolTipText("Enable animation");
                                 liveCB.addItemListener(this);
 
-		oe.toolbarPanel.add(oneStepButton = new cButton("Step", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolboxPanel.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.toolboxPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
                 fastCB.setToolTipText("Fast mode");
                                 fastCB.addItemListener(this);
                                 
-                oe.toolbarPanel.add(trackCB = new cCheckBox("Track", CameraPane.TRACK)); //, oe.aConstraints);
+                oe.toolboxPanel.Return();
+                
+                oe.toolboxPanel.add(trackCB = GetToggleButton("icons/track.png", CameraPane.TRACK)); //, oe.aConstraints);
                 trackCB.setToolTipText("Enable tracking");
                                 trackCB.addItemListener(this);
 
-		oe.toolbarPanel.add(screenfitButton = new cButton("@", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolboxPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 screenfitButton.setToolTipText("Screen fit");
 		screenfitButton.addActionListener(this);
 
@@ -586,65 +640,112 @@
                         snapobjectButton.setToolTipText("Snap Object");
                 }
 
-		oe.toolbarPanel.add(flashSelectionButton = new cButton("?", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
-                flashSelectionButton.setToolTipText("Show selection");
+		oe.toolboxPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                flashSelectionButton.setToolTipText("Highlight selection");
 		flashSelectionButton.addActionListener(this);
                 
-		oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
+		//oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
                 
-		oe.toolbarPanel.add(twoButton = new cButton("|+|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(twoButton = new cButton("|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 twoButton.setToolTipText("Show center view only");
 		twoButton.addActionListener(this);
-		oe.toolbarPanel.add(fourButton = new cButton("+||", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                this.fullscreenLayout = twoButton;
+                
+		oe.toolbarPanel.add(fourButton = new cButton("-||", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
 		fourButton.addActionListener(this);
                 fourButton.setToolTipText("Show left panel only");
-		oe.toolbarPanel.add(sixButton = new cButton("+|+|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(sixButton = new cButton("-|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 sixButton.setToolTipText("2-column layout left");
 		sixButton.addActionListener(this);
-		oe.toolbarPanel.add(threeButton = new cButton("|+|+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(threeButton = new cButton("|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 threeButton.setToolTipText("2-column layout right");
 		threeButton.addActionListener(this);
-		oe.toolbarPanel.add(sevenButton = new cButton("+|+|+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 sevenButton.setToolTipText("3-column layout");
 		sevenButton.addActionListener(this);
                 //
 
-		oe.toolbarPanel.add(rootButton = new cButton("o o o", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(rootButton = GetButton("icons/write.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 rootButton.setToolTipText("Edit selection in new tab");
 		rootButton.addActionListener(this);
 
-                oe.toolbarPanel.add(closeButton = new cButton("X", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                oe.toolbarPanel.add(closeButton = GetButton("icons/close-icon.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 closeButton.setToolTipText("Close tab");
 		closeButton.addActionListener(this);
 		//oe.treePanel.add(clearButton = new cButton("X"), oe.aConstraints);
 		//clearButton.addActionListener(this);
-                        
-                cGridBag commandsPanel = new cGridBag();
+
+                // INSERT
+                oe.toolboxPanel.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                gridButton.setToolTipText("Create grid");
+                                gridButton.addActionListener(this);
+
+                oe.toolboxPanel.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                boxButton.setToolTipText("Create box");
+                                boxButton.addActionListener(this);
+
+                oe.toolboxPanel.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                sphereButton.setToolTipText("Create sphere");
+                                sphereButton.addActionListener(this);
+
+                oe.toolboxPanel.Return();
                 
-		commandsPanel.add(editButton = new cButton("+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                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.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);
+
+                // EDIT panel
+		editCommandsPanel.add(editButton = new cButton("+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 editButton.setToolTipText("Edit selection");
 		editButton.addActionListener(this);
 
-		commandsPanel.add(uneditButton = new cButton("-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		editCommandsPanel.add(uneditButton = new cButton("-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 uneditButton.setToolTipText("Unedit selection");
 		uneditButton.addActionListener(this);
 
-		commandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
+		editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
                 allParamsButton.setToolTipText("Edit all params");
 		allParamsButton.addActionListener(this);
 
-		commandsPanel.add(clearPanelButton = new cButton("C", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		editCommandsPanel.add(clearPanelButton = new cButton("C", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 clearPanelButton.setToolTipText("Clear edit panel");
 		clearPanelButton.addActionListener(this);
 
-		commandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 unselectButton.setToolTipText("Unselect");
 		unselectButton.addActionListener(this);
 
-                commandsPanel.preferredHeight = 1;
+                editCommandsPanel.preferredHeight = 1;
                 
-                oe.treePanel.add(commandsPanel);
-                oe.treePanel.Return();
+//                oe.treePanel.add(commandsPanel);
+//                oe.treePanel.Return();
                 
 //		oe.aConstraints.gridx += 1;
 //		oe.aConstraints.weighty = 0;
@@ -661,7 +762,7 @@
 
                 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);
@@ -766,11 +867,23 @@
 //                debugCB.addItemListener(this);
 
                 panel.add(oeilCB = new cCheckBox("Eye", CameraPane.OEIL)); //, constraints);
+                oeilCB.setToolTipText("Move camera when tracking target");
                                 oeilCB.addItemListener(this);
 
+                panel.add(shadowCB = new cCheckBox("Shadow", Globals.COMPUTESHADOWWHENLIVE)); //, constraints);
+                shadowCB.setToolTipText("Compute shadows when live");
+                                shadowCB.addItemListener(this);
+
+                panel.add(autosaveCB = new cCheckBox("Auto-save", Globals.SAVEONMAKE)); //, constraints);
+                autosaveCB.setToolTipText("Auto-save on structure change");
+                                autosaveCB.addItemListener(this);
+
+            if (Globals.ADVANCED)
+            {
                 panel.add(lookAtCB = new cCheckBox("Target", CameraPane.LOOKAT)); //, constraints);
                 lookAtCB.setToolTipText("Look-at target");
                                 lookAtCB.addItemListener(this);
+            }
                 
         }
                                 
@@ -785,6 +898,14 @@
         void EditObject(Object3D obj)
         {
             cRadio radioButton = new cRadio(obj.name);
+            
+            // Patch to avoid bug with transparency.
+            radioButton.hadMaterial = obj.material != null;
+            if (!radioButton.hadMaterial)
+            {
+                obj.material = new cMaterial();
+            }
+            
             radioButton.SetObject(obj);
             radioButton.layout = sevenButton;
             radioButton.SetCamera(cameraView.renderCamera, false);
@@ -796,6 +917,8 @@
         
         void SetupViews(ObjEditor oe)
         {
+                    theFrame = this;
+                    
             oe.SetupViews();
             
 		System.out.println("SetupViews");
@@ -804,23 +927,26 @@
             /*DropTarget dropTarget =*/ new DropTarget(oe.cameraView, this);
         }
 
-        JCheckBox liveCB;
-        JCheckBox supportCB;
-        JCheckBox localCB;
-        JCheckBox crowdCB;
-        JCheckBox smoothCB;
-        JCheckBox fastCB;
-        JCheckBox slowCB;
-        JCheckBox boxCB;
-        JCheckBox zoomBoxCB;
-        JCheckBox trackCB;
-        JCheckBox smoothfocusCB;
+        cToggleButton liveCB;
+        cCheckBox supportCB;
+        cCheckBox localCB;
+        cCheckBox crowdCB;
+        cCheckBox smoothCB;
+        cToggleButton fastCB;
+        cCheckBox slowCB;
+        cCheckBox boxCB;
+        cCheckBox zoomBoxCB;
+        cToggleButton trackCB;
+        cCheckBox smoothfocusCB;
 //        JCheckBox speakerMocapCB;
-        JCheckBox speakerCameraCB;
-        JCheckBox speakerFocusCB;
-        JCheckBox debugCB;
-        JCheckBox oeilCB;
-        JCheckBox lookAtCB;
+        cCheckBox speakerCameraCB;
+        cCheckBox speakerFocusCB;
+        cCheckBox debugCB;
+        
+        cCheckBox oeilCB;
+        cCheckBox shadowCB;
+        cCheckBox autosaveCB;
+        cCheckBox lookAtCB;
         
 //        static int COLOR = 1;
 //        static int MATERIAL = 2;
@@ -828,9 +954,9 @@
         
         int dropAttributes = Object3D.COLOR | Object3D.MATERIAL;
         
-        JCheckBox colorCB;
-        JCheckBox materialCB;
-        JCheckBox textureCB;
+        cCheckBox colorCB;
+        cCheckBox materialCB;
+        cCheckBox textureCB;
         
         public void itemStateChanged(ItemEvent e)
         {
@@ -858,6 +984,7 @@
             } else if(e.getSource() == liveCB)
             {
                 cameraView.ToggleLive();
+                refreshContents(false);
             }
             else if(e.getSource() == supportCB)
             {
@@ -922,6 +1049,14 @@
             {
                 cameraView.ToggleOeil();
             }
+            else if(e.getSource() == shadowCB)
+            {
+                Globals.COMPUTESHADOWWHENLIVE ^= true;
+            }
+            else if(e.getSource() == autosaveCB)
+            {
+                Globals.SAVEONMAKE ^= true;
+            }
             else if(e.getSource() == lookAtCB)
             {
                 cameraView.ToggleLookAt();
@@ -938,7 +1073,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;
@@ -1062,16 +1198,16 @@
                 return;
             }
 
-            if (dtde.getDropAction() == DnDConstants.ACTION_MOVE) // ?? LINK)
-            {
+// 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
@@ -1265,7 +1401,7 @@
 		memoryItem.addActionListener(this);
 		menu.add(analyzeItem = new MenuItem("Analyze"));
 		analyzeItem.addActionListener(this);
-		menu.add(dumpItem = new MenuItem("Dump"));
+		menu.add(dumpItem = new MenuItem("Print"));
 		dumpItem.addActionListener(this);
 //		menu.add(pathItem = new MenuItem("From-to path"));
 //		pathItem.addActionListener(this);
@@ -1406,6 +1542,7 @@
             shadow.material = new cMaterial(obj.material);
             shadow.material.diffuse = 0.0001f;
             shadow.material.specular = 0.0001f;
+            //shadow.projectedVertices[1].x = 300;
             
             makeSomething(shadow);
         }
@@ -1662,11 +1799,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);
@@ -1745,27 +1882,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
@@ -1785,7 +1922,7 @@
 		{
 			makeSomething(new BezierSurface());
 		} else
-		if (source == overlayItem)
+		if (source == overlayItem || source == overlayButton)
 		{
                     /*
 			Object3D obj = new BezierSurface(5,8);
@@ -1833,7 +1970,7 @@
                         s.setup();
 			makeSomething(s);
 		} else
-		if (source == lightItem)
+		if (source == lightItem || source == lightButton)
 		{
 			makeSomething(new Light());
 		} else
@@ -1955,6 +2092,30 @@
 		if (source == dumpItem)
 		{
                     DumpObject();
+		} else
+		if (source == minButton)
+		{
+			Minimize();
+		} else
+		if (source == maxButton)
+		{
+			Maximize();
+		} else
+		if (source == fullButton)
+		{
+			ToggleFullScreen();
+		} else
+		if (source == undoButton)
+		{
+			Undo();
+		} else
+		if (source == redoButton)
+		{
+			Redo();
+		} else
+		if (source == saveButton)
+		{
+			Save();
 		} else
 		if (source == oneStepButton)
 		{
@@ -2495,7 +2656,7 @@
 		{
 			CastShadow(2);
 		} else
-		if (source == ungroupItem)
+		if (source == ungroupItem || source == ungroupButton)
 		{
 			//ungroup();
                     for (int i=0; i<group.selection.size(); i++)
@@ -2517,7 +2678,7 @@
 		} else
 		if (source == genNormalsMESHItem)
                 {
-			GenNormals(true); // TODO
+			GenNormalsMESH();
 		} else
 		if (source == genNormalsORGANItem)
                 {
@@ -2582,6 +2743,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)
                 {
@@ -2817,6 +2994,10 @@
 		if (source == twoButton)
 		{
                     radio.layout = twoButton;
+                    
+                    if (CameraPane.FULLSCREEN)
+                        fullscreenLayout = radio.layout;
+                    
                     // bug
                     //gridPanel.setDividerLocation(1.0);
                     //bigPanel.setDividerLocation(0.0);
@@ -2849,10 +3030,31 @@
                     bigThree.ClearUI();
                     bigThree.add(centralPanel);
                     bigThree.FlushUI();
+                    
+                    cameraView.requestFocusInWindow();
+                    
+//                    refreshContents(true);
+//                    
+//                    try
+//                    {
+//                        java.awt.Robot bot = new java.awt.Robot();
+//                        int mask = InputEvent.BUTTON1_MASK;
+//                        bot.mouseMove(100, 100);           
+//                        bot.mousePress(mask);     
+//                        bot.mouseRelease(mask);                    
+//                    }
+//                    catch (Exception e)
+//                    {
+//                        
+//                    }
+                    
                 } else
 		if (source == threeButton)
 		{
                     radio.layout = threeButton;
+                    
+                    if (CameraPane.FULLSCREEN)
+                        fullscreenLayout = radio.layout;
                     
 //                    bigThree.remove(scenePanel);
 //                    bigThree.remove(centralPanel);
@@ -2885,10 +3087,15 @@
                     bigThree.add(centralPanel);
                     bigThree.add(XYZPanel);
                     bigThree.FlushUI();
+                    
+                    cameraView.requestFocusInWindow();
                 } else
 		if (source == fourButton)
 		{
                     radio.layout = fourButton;
+                    
+                    if (CameraPane.FULLSCREEN)
+                        fullscreenLayout = radio.layout;
                     
 //                    bigThree.remove(scenePanel);
 //                    bigThree.remove(centralPanel);
@@ -2920,10 +3127,15 @@
                     bigThree.ClearUI();
                     bigThree.add(scenePanel);
                     bigThree.FlushUI();
+                    
+                    cameraView.requestFocusInWindow();
                 } else
 		if (source == sixButton)
 		{
                     radio.layout = sixButton;
+                    
+                    if (CameraPane.FULLSCREEN)
+                        fullscreenLayout = radio.layout;
                     
 //                    bigThree.remove(scenePanel);
 //                    bigThree.remove(centralPanel);
@@ -2956,10 +3168,15 @@
                     bigThree.add(scenePanel);
                     bigThree.add(centralPanel);
                     bigThree.FlushUI();
+                    
+                    cameraView.requestFocusInWindow();
                 } else
 		if (source == sevenButton)
 		{
                     radio.layout = sevenButton;
+                    
+                    if (CameraPane.FULLSCREEN)
+                        fullscreenLayout = radio.layout;
                     
 //                    bigThree.remove(scenePanel);
 //                    bigThree.remove(centralPanel);
@@ -2993,6 +3210,8 @@
                     bigThree.add(centralPanel);
                     bigThree.add(XYZPanel);
                     bigThree.FlushUI();
+                    
+                    cameraView.requestFocusInWindow();
                 } else
 		if (source == rootButton)
 		{
@@ -3004,6 +3223,7 @@
                                 EditObject(obj);
                     }
 
+                    cameraView.requestFocusInWindow();
                     refreshContents(true);
 		} else
 		if (source == closeButton)
@@ -3013,18 +3233,27 @@
                     for (Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
                     {
                             ab = (cRadio)e.nextElement();
-                            if(ab.getModel().isSelected() && ab.GetObject() != client)
+                            if (ab.getModel().isSelected() && ab.GetObject() != client)
                             {
+                                // Patch to avoid bug with transparency.
+                                if (!ab.hadMaterial)
+                                {
+                                    ab.object.material = null;
+                                }
+                                
                                 buttonGroup.remove(ab);
                                 radioPanel.remove(ab);
                                 
-                                ab.GetObject().editWindow = null;
+                                //ab.GetObject().editWindow = null;
+                                ab.GetObject().manipWindow = null;
                             //    ab.GetObject().objectUI = null; // ?????????
                                 
                                 ((cRadio)radioPanel.getComponent(radioPanel.getComponentCount() - 1)).doClick();
                                 break;
                             }
                     }
+                    
+                    cameraView.requestFocusInWindow();
                     refreshContents(true);
 		} else
 		if (source == editItem || source == editButton)
@@ -3128,7 +3357,9 @@
                         sideView.object = group;
                     }
                     
-// fix "+" issue                    group.editWindow = this;
+// fix "+" issue
+                    //group.editWindow = this;
+                    group.manipWindow = this;
                     
                     /*
                     currentLayout = radio.layout;
@@ -3141,6 +3372,8 @@
                     //group.parent = null; // ROOT
                     //group.attributes = -1;
                     ResetModel();
+                    
+                    cameraView.requestFocusInWindow();
                     refreshContents(true);
                 } else if (event.getSource() == editCameraItem)
                 {
@@ -3164,7 +3397,6 @@
 	}
         
         boolean useclient = false;
-        cRadio radio;
         
         void ToggleRoot()
         {
@@ -3403,7 +3635,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)
@@ -3484,6 +3717,13 @@
 	void GenNormals(boolean crease)
 	{
 		group.GenNormalsS(crease);
+		
+		refreshContents();
+	}
+	
+	void GenNormalsMESH()
+	{
+		group.GenNormalsMeshS();
 		
 		refreshContents();
 	}
@@ -4111,6 +4351,18 @@
 		refreshContents();
 	}
 	
+	void RewindLeaves(boolean hide)
+	{
+		group.selection.RewindLeaves(hide);
+		refreshContents();
+	}
+	
+	void RandomLeaves(boolean hide)
+	{
+		group.selection.RandomLeaves(hide);
+		refreshContents();
+	}
+	
 	void SetTexRes(int tr)
 	{
 		group.selection.SetTexRes(tr);
@@ -4193,7 +4445,7 @@
 		{
                     //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)
@@ -4286,7 +4538,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++)
@@ -4295,10 +4546,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
@@ -4308,8 +4557,6 @@
 //            System.err.println("info : " + group.GetPath());
 //                        }
 			
-                        objEditor.SetText(); // jan 2014
-                        
 			if (flashIt && !Globals.isLIVE() && tps != null && tps.length > 0 && !(tps[0].getLastPathComponent() instanceof Camera))
 				CameraPane.flash = true;
                         
@@ -4333,6 +4580,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)
 	{
@@ -4404,6 +4671,7 @@
 	{
 		if (group.selection.isEmpty())
 			return;
+                
 		Grafreed.clipboardIsTempGroup = false;
 		Composite tGroup = null;
 		if (group.selection.size() > 0) // 1)
@@ -4414,6 +4682,8 @@
                 
 		if (cut)
 		{
+        if (Globals.SAVEONMAKE)
+                    Save();
 			//int indices[] = jList.getSelectedIndices();
 			//for (int i = indices.length - 1; i >= 0; i--)
 			//jList.remove(indices[i]);
@@ -4503,8 +4773,10 @@
 			}
 			
 		}
+                
 		if (Grafreed.clipboardIsTempGroup)
 			Grafreed.clipboard = tGroup;
+                
 		if (cut)
                 {
                     ResetModel();
@@ -5129,7 +5401,28 @@
 	cButton clearpanelButton;
 	cButton unselectButton;
 	
+	cButton minButton;
+	cButton maxButton;
+	cButton fullButton;
+	cButton undoButton;
+	cButton redoButton;
+	cButton saveButton;
 	cButton oneStepButton;
+        
+        cButton groupButton;
+        cButton ungroupButton;
+        cButton compositeButton;
+        
+        cButton gridButton;
+        cButton boxButton;
+        cButton sphereButton;
+        cButton coneButton;
+        cButton torusButton;
+        cButton superButton;
+        cButton kleinButton;
+        cButton particlesButton;
+        cButton overlayButton;
+        cButton lightButton;
         
 	cButton screenfitButton;
 	cButton screenfitpointButton;
@@ -5141,14 +5434,6 @@
 	cButton closeButton;
 
 	cButton setsupportButton;
-        
-	cButton twoButton;
-	cButton sixButton;
-	cButton threeButton;
-	cButton sevenButton;
-	cButton fourButton; // full panel
-	cButton oneButton; // full XYZ
-        //cButton currentLayout;
         
 	//
         //Composite
@@ -5163,7 +5448,7 @@
 	private MenuItem cutItem;
 	private MenuItem undoItem;
 	private MenuItem redoItem;
-	private MenuItem duplicateItem;
+	private JMenuItem duplicateItem;
 	private MenuItem cloneItem;
 	private MenuItem cloneSupportItem;
 	private MenuItem overwriteGeoItem;
@@ -5226,6 +5511,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;

--
Gitblit v1.6.2