From 4113164b3be1e50251ac40d6fd65660f0a6c2e63 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Tue, 11 Jun 2019 18:46:21 -0400 Subject: [PATCH] Compressed undo stack. --- GroupEditor.java | 70 ++++++++++++++++++++++++++++++---- 1 files changed, 61 insertions(+), 9 deletions(-) diff --git a/GroupEditor.java b/GroupEditor.java index acdf1fc..43af894 100644 --- a/GroupEditor.java +++ b/GroupEditor.java @@ -154,6 +154,12 @@ oe.menuBar.add(menu = new Menu("Edit")); //editItem = menu.add(new MenuItem("Edit")); //editItem.addActionListener(this); + +// undoItem = menu.add(new MenuItem("Undo")); +// undoItem.addActionListener(this); +// redoItem = menu.add(new MenuItem("Redo")); +// redoItem.addActionListener(this); +// menu.add("-"); duplicateItem = menu.add(new MenuItem("Duplicate")); duplicateItem.addActionListener(this); cloneItem = menu.add(new MenuItem("Clone")); @@ -197,7 +203,7 @@ //zBufferItem.addActionListener(this); //cameraMenu.add(normalLensItem = new MenuItem("Normal Lens")); //normalLensItem.addActionListener(this); - cameraMenu.add(revertCameraItem = new MenuItem("Revert Camera")); + cameraMenu.add(revertCameraItem = new MenuItem("Restore Viewpoint")); revertCameraItem.addActionListener(this); cameraMenu.add(toggleFullScreenItem = new CheckboxMenuItem("Full Screen")); @@ -261,7 +267,7 @@ // animationItem.addItemListener(this); // animationItem.setState(CameraPane.ANIMATION); cameraMenu.add("-"); - cameraMenu.add(editCameraItem = new MenuItem("Freeze Camera")); + cameraMenu.add(editCameraItem = new MenuItem("Save Viewpoint")); editCameraItem.addActionListener(this); if (Globals.ADVANCED) @@ -550,6 +556,18 @@ oe.buttonGroup.add(dummyButton); */ //this.AddOptions(oe.toolbarPanel, oe.aConstraints); + + oe.toolbarPanel.add(undoButton = new cButton("Undo", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + undoButton.setToolTipText("Undo changes"); + undoButton.addActionListener(this); + + oe.toolbarPanel.add(redoButton = new cButton("Redo", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + redoButton.setToolTipText("Redo changes"); + redoButton.addActionListener(this); + + oe.toolbarPanel.add(saveButton = new cButton("Save", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + saveButton.setToolTipText("Save changes"); + saveButton.addActionListener(this); oe.toolbarPanel.add(liveCB = new cCheckBox("Live", Globals.isLIVE())); //, oe.aConstraints); liveCB.setToolTipText("Enable animation"); @@ -1951,6 +1969,18 @@ { DumpObject(); } else + if (source == undoButton) + { + Undo(); + } else + if (source == redoButton) + { + Redo(); + } else + if (source == saveButton) + { + Save(); + } else if (source == oneStepButton) { Globals.ONESTEP = true; @@ -2004,6 +2034,14 @@ if (source == cutItem || source == clearButton) { loadClipboard(true); + } else + if (source == undoItem) + { + Undo(); + } else + if (source == redoItem) + { + Redo(); } else if (source == duplicateItem) { @@ -3028,7 +3066,7 @@ child.CloseUI(); listUI.remove(child); - child.editWindow = null; // ??????????? + //child.editWindow = null; // ??????????? } objEditor.ctrlPanel.FlushUI(); //objEditor.jTree.clearSelection(); @@ -3115,7 +3153,8 @@ sideView.object = group; } -// fix "+" issue group.editWindow = this; +// fix "+" issue + group.editWindow = this; /* currentLayout = radio.layout; @@ -3390,7 +3429,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) @@ -4297,14 +4337,17 @@ objEditor.SetText(); // jan 2014 - if (flashIt && !Globals.isLIVE() && tps != null && tps.length > 0 && !(((Object3D) tps[0].getLastPathComponent()) instanceof Camera)) + if (flashIt && !Globals.isLIVE() && tps != null && tps.length > 0 && !(tps[0].getLastPathComponent() instanceof Camera)) CameraPane.flash = true; - if (tps != null && tps.length > 0 && ((Object3D) tps[0].getLastPathComponent()) instanceof Camera) + if (tps != null && tps.length > 0 && tps[0].getLastPathComponent() instanceof Camera) // a camera { - CameraPane.camerachangeframe = 0; // don't refuse it - Globals.theRenderer.SetCamera((Camera) tps[0].getLastPathComponent()); + if (tps[0].getLastPathComponent() != Globals.theRenderer.LightCamera()) + { + CameraPane.camerachangeframe = 0; // don't refuse it + Globals.theRenderer.SetCamera((Camera) tps[0].getLastPathComponent()); + } // Globals.theRenderer.renderCamera = Globals.theRenderer.manipCamera; // Globals.theRenderer.eyeCamera = Globals.theRenderer.manipCamera; } @@ -4388,6 +4431,7 @@ { if (group.selection.isEmpty()) return; + Grafreed.clipboardIsTempGroup = false; Composite tGroup = null; if (group.selection.size() > 0) // 1) @@ -4398,6 +4442,7 @@ if (cut) { + Save(); //int indices[] = jList.getSelectedIndices(); //for (int i = indices.length - 1; i >= 0; i--) //jList.remove(indices[i]); @@ -4487,8 +4532,10 @@ } } + if (Grafreed.clipboardIsTempGroup) Grafreed.clipboard = tGroup; + if (cut) { ResetModel(); @@ -5113,6 +5160,9 @@ cButton clearpanelButton; cButton unselectButton; + cButton saveButton; + cButton undoButton; + cButton redoButton; cButton oneStepButton; cButton screenfitButton; @@ -5145,6 +5195,8 @@ private MenuItem lookFromItem; private MenuItem switchItem; private MenuItem cutItem; + private MenuItem undoItem; + private MenuItem redoItem; private MenuItem duplicateItem; private MenuItem cloneItem; private MenuItem cloneSupportItem; -- Gitblit v1.6.2