From 8558ae86e65457c512a26339d3660d79eee16ae6 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sun, 09 Jun 2019 16:33:38 -0400 Subject: [PATCH] Multi-tab undo. --- ObjEditor.java | 92 +++++++++++++++++++++--------- CameraPane.java | 2 cRadio.java | 3 + GroupEditor.java | 10 +-- Object3D.java | 41 +++++++++++++ 5 files changed, 113 insertions(+), 35 deletions(-) diff --git a/CameraPane.java b/CameraPane.java index 9794f67..0cda80d 100644 --- a/CameraPane.java +++ b/CameraPane.java @@ -11552,7 +11552,7 @@ return; } - String string = obj.GetToolTip(); + String string = obj.toString(); //.GetToolTip(); GL gl = GetGL(); diff --git a/GroupEditor.java b/GroupEditor.java index 5d4b4bf..3fdc5c4 100644 --- a/GroupEditor.java +++ b/GroupEditor.java @@ -3041,7 +3041,7 @@ child.CloseUI(); listUI.remove(child); - child.editWindow = null; // ??????????? + //child.editWindow = null; // ??????????? } objEditor.ctrlPanel.FlushUI(); //objEditor.jTree.clearSelection(); @@ -4310,15 +4310,13 @@ objEditor.SetText(); // jan 2014 - Object3D object = (Object3D) tps[0].getLastPathComponent(); - - if (flashIt && !Globals.isLIVE() && tps != null && tps.length > 0 && !(object instanceof Camera)) + if (flashIt && !Globals.isLIVE() && tps != null && tps.length > 0 && !(tps[0].getLastPathComponent() instanceof Camera)) CameraPane.flash = true; - if (tps != null && tps.length > 0 && object instanceof Camera) + if (tps != null && tps.length > 0 && tps[0].getLastPathComponent() instanceof Camera) // a camera { - if (object != Globals.theRenderer.LightCamera()) + if (tps[0].getLastPathComponent() != Globals.theRenderer.LightCamera()) { CameraPane.camerachangeframe = 0; // don't refuse it Globals.theRenderer.SetCamera((Camera) tps[0].getLastPathComponent()); diff --git a/ObjEditor.java b/ObjEditor.java index 05b548c..422d126 100644 --- a/ObjEditor.java +++ b/ObjEditor.java @@ -1935,6 +1935,7 @@ e2.printStackTrace(); } } + LoadJMEThread loadThread; class LoadJMEThread extends Thread @@ -1992,6 +1993,7 @@ //LoadFile0(filename, converter); } } + LoadOBJThread loadObjThread; class LoadOBJThread extends Thread @@ -3212,9 +3214,6 @@ objEditor.refreshContents(); } - Object3D graphs[] = new Object3D[10000]; - int undoindex = 0; - static public Object clone(Object o) { try @@ -3237,16 +3236,31 @@ } } + cRadio GetCurrentTab() + { + cRadio ab; + for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();) + { + ab = (cRadio)e.nextElement(); + if(ab.GetObject() == client) + { + return ab; + } + } + + return null; + } + public void Save() { - if (true) return; + cRadio tab = GetCurrentTab(); //EditorFrame.m_MainFrame.requestFocusInWindow(); - graphs[undoindex++] = (Object3D)clone(copy); + tab.graphs[tab.undoindex++] = (Object3D)clone(copy); - for (int i = undoindex; i < graphs.length; i++) + for (int i = tab.undoindex; i < tab.graphs.length; i++) { - graphs[i] = null; + tab.graphs[i] = null; } // test save @@ -3254,7 +3268,7 @@ { try { - FileOutputStream ostream = new FileOutputStream("save" + undoindex); + FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex); ObjectOutputStream p = new ObjectOutputStream(ostream); p.writeObject(copy); @@ -3269,48 +3283,70 @@ } } + void CopyChanged(Object3D obj) + { + copy.clear(); + + for (int i=0; i<obj.Size(); i++) + { + copy.add(obj.get(i)); + } + + copy.Touch(); + + ResetModel(); + copy.HardTouch(); // recompile? + + cRadio ab; + for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();) + { + ab = (cRadio)e.nextElement(); + Object3D test = copy.GetObject(ab.object.GetUUID()); + //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID()); + if (test != null) + { + test.editWindow = ab.object.editWindow; + ab.object = test; + } + } + + refreshContents(); + } + public void Undo() { - if (undoindex == 0) + cRadio tab = GetCurrentTab(); + + if (tab.undoindex == 0) { java.awt.Toolkit.getDefaultToolkit().beep(); return; } - if (graphs[undoindex] == null) + if (tab.graphs[tab.undoindex] == null) { Save(); - undoindex -= 1; + tab.undoindex -= 1; } - undoindex -= 1; + tab.undoindex -= 1; - copy = graphs[undoindex]; - - cameraView.object = copy; - copy.Touch(); - - ResetModel(); - refreshContents(); + CopyChanged(tab.graphs[tab.undoindex]); } public void Redo() { - if (graphs[undoindex + 1] == null) + cRadio tab = GetCurrentTab(); + + if (tab.graphs[tab.undoindex + 1] == null) { java.awt.Toolkit.getDefaultToolkit().beep(); return; } - undoindex += 1; + tab.undoindex += 1; - copy = graphs[undoindex]; - - cameraView.object = copy; - copy.Touch(); - - ResetModel(); - refreshContents(); + CopyChanged(tab.graphs[tab.undoindex]); } void ImportGFD() diff --git a/Object3D.java b/Object3D.java index 8205153..2c2cf4d 100644 --- a/Object3D.java +++ b/Object3D.java @@ -14,11 +14,15 @@ import //weka.core. matrix.Matrix; +import java.util.UUID; + //import net.sourceforge.sizeof.SizeOf; public class Object3D extends Vector<Object3D> implements java.io.Serializable, iSendInfo //, aurelienribon.tweenengine.TweenAccessor<Object3D> { //static final long serialVersionUID = -607422624994562685L; static final long serialVersionUID = 5022536242724664900L; + + private UUID uuid = UUID.randomUUID(); ScriptNode scriptnode; @@ -5371,6 +5375,43 @@ } } + UUID GetUUID() + { + if (uuid == null) + { + // Serial + uuid = UUID.randomUUID(); + } + + return uuid; + } + + Object3D GetObject(UUID uid) + { + if (blockloop) + return null; + + if (GetUUID().equals(uid)) + return this; + + int nb = Size(); + for (int i = 0; i < nb; i++) + { + Object3D child = (Object3D) get(i); + + if (child == null) + continue; + + blockloop = true; + Object3D obj = child.GetObject(uid); + blockloop = false; + if (obj != null) + return obj; + } + + return null; + } + void SetBumpTexture(String tex) { if (GetTextures() == null) diff --git a/cRadio.java b/cRadio.java index 0714434..54e8a60 100644 --- a/cRadio.java +++ b/cRadio.java @@ -35,6 +35,9 @@ camera = (Camera)Grafreed.clone(c); } + Object3D graphs[] = new Object3D[10000]; + int undoindex = 0; + Object3D object; Camera camera; cButton layout; -- Gitblit v1.6.2