From 6266c8a4b2485b29a7d5bcb217460d7aad3e1c4a Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Sun, 25 Aug 2019 20:58:10 -0400
Subject: [PATCH] Proto version slider.

---
 GroupEditor.java |   96 +++++++++++++++++++++++++++---------------------
 1 files changed, 54 insertions(+), 42 deletions(-)

diff --git a/GroupEditor.java b/GroupEditor.java
index 83301a6..c1f3bea 100644
--- a/GroupEditor.java
+++ b/GroupEditor.java
@@ -765,11 +765,11 @@
 		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)
         {
+		attributeItem = menu.add(new MenuItem("Attribute"));
+		attributeItem.addActionListener(this);
 		menu.add("-");
 		linkerItem = menu.add(new MenuItem("Linker"));
 		linkerItem.addActionListener(this);
@@ -779,11 +779,18 @@
 		pointflowItem.addActionListener(this);
         }
 		menu.add("-");
+		textureRatioRItem = menu.add(new MenuItem("Texture Ratio Red"));
+		textureRatioRItem.addActionListener(this);
+		textureRatioGItem = menu.add(new MenuItem("Texture Ratio Green"));
+		textureRatioGItem.addActionListener(this);
+		textureRatioBItem = menu.add(new MenuItem("Texture Ratio Blue"));
+		textureRatioBItem.addActionListener(this);
+		menu.add("-");
 		resetTransformItem = menu.add(new MenuItem("Reset Transform"));
 		resetTransformItem.addActionListener(this);
 		resetCentroidItem = menu.add(new MenuItem("Reset Centroid"));
 		resetCentroidItem.addActionListener(this);
-		resetCentroidXZItem = menu.add(new MenuItem("Reset Centroid XY"));
+		resetCentroidXZItem = menu.add(new MenuItem("Reset Centroid XZ"));
 		resetCentroidXZItem.addActionListener(this);
 		transformGeometryItem = menu.add(new MenuItem("Transform Geometry"));
 		transformGeometryItem.addActionListener(this);
@@ -1217,7 +1224,7 @@
                 torusButton.setToolTipText("Create torus");
                                 torusButton.addActionListener(this);
 
-                if (Globals.ADVANCED)
+                if (false) //Globals.ADVANCED)
                 {
                     oe.toolboxPanel.add(kleinButton = GetButton("icons/klein.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                     kleinButton.setToolTipText("Create Klein bottle");
@@ -1493,7 +1500,7 @@
 	
         void EditObject(Object3D obj)
         {
-            assert(obj instanceof Composite);
+            //assert(obj instanceof Composite);
             
 //            if (obj.versionlist == null)
 //            {
@@ -3612,6 +3619,18 @@
 		{
                         TransformChildren();
 		} else
+		if (source == textureRatioRItem)
+		{
+                        TextureRatio(0);
+		} else
+		if (source == textureRatioGItem)
+		{
+                        TextureRatio(1);
+		} else
+		if (source == textureRatioBItem)
+		{
+                        TextureRatio(2);
+		} else
 		if (source == resetTransformItem)
 		{
                         ResetTransform();
@@ -3984,7 +4003,8 @@
 		if (source == closeButton)
 		{
 //System.out.println("CLOSE: " + buttonGroup.getSelection());
-                    Replace();
+                    if (copy.versionlist != null)
+                        Replace();
                     
                     cRadio ab;
                     for (Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
@@ -4084,7 +4104,8 @@
 		} else
                 if(source instanceof cRadio)
 		{
-                    Replace();
+                    if (copy.versionlist != null)
+                        Replace();
                     
                     group.parent = keepparent;
                         group.attributes = 0;
@@ -4137,7 +4158,7 @@
                      */
                     radio.layout.doClick();
                     
-                    assert(copy instanceof Composite);
+                    //assert(copy instanceof Composite);
                     
         if (copy.versionlist == null)
         {
@@ -4148,7 +4169,7 @@
             // and check if any of these nodes are reachable below the root.
             Grafreed.grafreed.universe.TagObjects(copy, true);
             
-            if (copy.versionlist == null && !copy.HasTags())
+            if (copy instanceof Composite && copy.versionlist == null && !copy.HasTags())
             {
                 copy.versionlist = new Object3D[100];
                 
@@ -4275,6 +4296,18 @@
             refreshContents();
         }
         
+        void TextureRatio(int axis)
+        {
+            Object3D obj;
+            for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
+            {
+                    obj = (Object3D)e.nextElement();
+                    obj.TextureRatio(axis);
+            }
+
+            refreshContents();
+        }
+        
         void ResetTransform()
         {
             ResetTransform(-1);
@@ -4290,38 +4323,8 @@
                     if (obj.toParent == null)
                         continue;
                     
-                    if (mask == -1)
-                    {
-                        if (obj instanceof Camera) // jan 2014
-                        {
-                            LA.matIdentity(obj.toParent);
-                            LA.matIdentity(obj.fromParent);
-                        }
-                        else
-                        {
-                            obj.toParent = null; // jan 2014 LA.matIdentity(obj.toParent);
-                            obj.fromParent = null; // LA.matIdentity(obj.fromParent);
-                        }
-                        TouchTransform(obj);
-                        continue;
-                    }
-                    if ((mask&2) != 0) // Scale/rotation
-                    {
-                        obj.toParent[0][0] = obj.toParent[1][1] = obj.toParent[2][2] = 1;
-                        obj.toParent[0][1] = obj.toParent[1][0] = obj.toParent[2][0] = 0;
-                        obj.toParent[0][2] = obj.toParent[1][2] = obj.toParent[2][1] = 0;
-                        obj.fromParent[0][0] = obj.fromParent[1][1] = obj.fromParent[2][2] = 1;
-                        obj.fromParent[0][1] = obj.fromParent[1][0] = obj.fromParent[2][0] = 0;
-                        obj.fromParent[0][2] = obj.fromParent[1][2] = obj.fromParent[2][1] = 0;
-                    }
-                    if ((mask&1) != 0) // Translation
-                    {
-                        if (obj.toParent != null)
-                        {
-                            obj.toParent[3][0] = obj.toParent[3][1] = obj.toParent[3][2] = 0;
-                            obj.fromParent[3][0] = obj.fromParent[3][1] = obj.fromParent[3][2] = 0;
-                        }
-                    }
+                    obj.ResetTransform(mask);
+                    
                     if (obj.parent == null)
                     {
                         System.out.println("NULL PARENT!");
@@ -4829,6 +4832,12 @@
             for (int i=0; i<group.selection.size(); i++)
             {
 		Object3D obj = group.selection.get(i);
+                
+                if (obj.toParent == null)
+                {
+                    obj.toParent = LA.newMatrix();
+                    obj.fromParent = LA.newMatrix();
+                }
                 
                 LA.matTranslate(obj.toParent, i * scale, 0, 0);
                 LA.matTranslateInv(obj.fromParent, -i * scale, 0, 0);
@@ -5412,7 +5421,7 @@
                     }
             }
             
-            rootButton.setEnabled(allComposites);
+            rootButton.setEnabled(true); // allComposites);
         }
 
         void refreshContents(boolean cp)
@@ -6392,6 +6401,9 @@
 	private MenuItem maxTexturesItem;
 	private MenuItem panoTexturesItem;
         
+	private MenuItem textureRatioRItem;
+	private MenuItem textureRatioGItem;
+	private MenuItem textureRatioBItem;
 	private MenuItem resetCentroidItem;
 	private MenuItem resetCentroidXZItem;
 	private MenuItem resetTransformItem;

--
Gitblit v1.6.2