GroupEditor.java | ●●●●● patch | view | raw | blame | history | |
ObjEditor.java | ●●●●● patch | view | raw | blame | history |
GroupEditor.java
.. .. @@ -154,6 +154,11 @@ 154 154 oe.menuBar.add(menu = new Menu("Edit")); 155 155 //editItem = menu.add(new MenuItem("Edit")); 156 156 //editItem.addActionListener(this); 157 + undoItem = menu.add(new MenuItem("Undo"));158 + undoItem.addActionListener(this);159 + redoItem = menu.add(new MenuItem("Redo"));160 + redoItem.addActionListener(this);161 + menu.add("-");157 162 duplicateItem = menu.add(new MenuItem("Duplicate")); 158 163 duplicateItem.addActionListener(this); 159 164 cloneItem = menu.add(new MenuItem("Clone")); .. .. @@ -197,7 +202,7 @@ 197 202 //zBufferItem.addActionListener(this); 198 203 //cameraMenu.add(normalLensItem = new MenuItem("Normal Lens")); 199 204 //normalLensItem.addActionListener(this); 200 - cameraMenu.add(revertCameraItem = new MenuItem("Revert Camera"));205 + cameraMenu.add(revertCameraItem = new MenuItem("Restore Camera"));201 206 revertCameraItem.addActionListener(this); 202 207 203 208 cameraMenu.add(toggleFullScreenItem = new CheckboxMenuItem("Full Screen")); .. .. @@ -261,7 +266,7 @@ 261 266 // animationItem.addItemListener(this); 262 267 // animationItem.setState(CameraPane.ANIMATION); 263 268 cameraMenu.add("-"); 264 - cameraMenu.add(editCameraItem = new MenuItem("Freeze Camera"));269 + cameraMenu.add(editCameraItem = new MenuItem("Save Camera"));265 270 editCameraItem.addActionListener(this); 266 271 267 272 if (Globals.ADVANCED) .. .. @@ -2004,6 +2009,14 @@ 2004 2009 if (source == cutItem || source == clearButton) 2005 2010 { 2006 2011 loadClipboard(true); 2012 + } else2013 + if (source == undoItem)2014 + {2015 + Undo();2016 + } else2017 + if (source == redoItem)2018 + {2019 + Redo();2007 2020 } else 2008 2021 if (source == duplicateItem) 2009 2022 { .. .. @@ -4297,14 +4310,19 @@ 4297 4310 4298 4311 objEditor.SetText(); // jan 2014 4299 4312 4300 - if (flashIt && !Globals.isLIVE() && tps != null && tps.length > 0 && !(((Object3D) tps[0].getLastPathComponent()) instanceof Camera))4313 + Object3D object = (Object3D) tps[0].getLastPathComponent();4314 +4315 + if (flashIt && !Globals.isLIVE() && tps != null && tps.length > 0 && !(object instanceof Camera))4301 4316 CameraPane.flash = true; 4302 4317 4303 - if (tps != null && tps.length > 0 && ((Object3D) tps[0].getLastPathComponent()) instanceof Camera)4318 + if (tps != null && tps.length > 0 && object instanceof Camera)4304 4319 // a camera 4305 4320 { 4306 - CameraPane.camerachangeframe = 0; // don't refuse it4307 - Globals.theRenderer.SetCamera((Camera) tps[0].getLastPathComponent());4321 + if (object != Globals.theRenderer.LightCamera())4322 + {4323 + CameraPane.camerachangeframe = 0; // don't refuse it4324 + Globals.theRenderer.SetCamera((Camera) tps[0].getLastPathComponent());4325 + }4308 4326 // Globals.theRenderer.renderCamera = Globals.theRenderer.manipCamera; 4309 4327 // Globals.theRenderer.eyeCamera = Globals.theRenderer.manipCamera; 4310 4328 } .. .. @@ -5145,6 +5163,8 @@ 5145 5163 private MenuItem lookFromItem; 5146 5164 private MenuItem switchItem; 5147 5165 private MenuItem cutItem; 5166 + private MenuItem undoItem;5167 + private MenuItem redoItem;5148 5168 private MenuItem duplicateItem; 5149 5169 private MenuItem cloneItem; 5150 5170 private MenuItem cloneSupportItem; ObjEditor.java
.. .. @@ -3207,10 +3207,112 @@ 3207 3207 { 3208 3208 copy.remove(1); 3209 3209 } 3210 +3210 3211 ResetModel(); 3211 3212 objEditor.refreshContents(); 3212 3213 } 3213 3214 3215 + Object3D graphs[] = new Object3D[10000];3216 + int undoindex = 0;3217 +3218 + static public Object clone(Object o)3219 + {3220 + try3221 + {3222 + ByteArrayOutputStream baos = new ByteArrayOutputStream();3223 + ObjectOutputStream out = new ObjectOutputStream(baos);3224 +3225 + out.writeObject(o);3226 +3227 + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());3228 + ObjectInputStream in = new ObjectInputStream(bais);3229 + Object obj = in.readObject();3230 + in.close();3231 + out.close();3232 + return obj;3233 + } catch (Exception e)3234 + {3235 + System.err.println(e);3236 + return null;3237 + }3238 + }3239 +3240 + public void Save()3241 + {3242 + if (true) return;3243 +3244 + //EditorFrame.m_MainFrame.requestFocusInWindow();3245 + graphs[undoindex++] = (Object3D)clone(copy);3246 +3247 + for (int i = undoindex; i < graphs.length; i++)3248 + {3249 + graphs[i] = null;3250 + }3251 +3252 + // test save3253 + if (false)3254 + {3255 + try3256 + {3257 + FileOutputStream ostream = new FileOutputStream("save" + undoindex);3258 + ObjectOutputStream p = new ObjectOutputStream(ostream);3259 +3260 + p.writeObject(copy);3261 +3262 + p.flush();3263 +3264 + ostream.close();3265 + } catch (Exception e)3266 + {3267 + e.printStackTrace();3268 + }3269 + }3270 + }3271 +3272 + public void Undo()3273 + {3274 + if (undoindex == 0)3275 + {3276 + java.awt.Toolkit.getDefaultToolkit().beep();3277 + return;3278 + }3279 +3280 + if (graphs[undoindex] == null)3281 + {3282 + Save();3283 + undoindex -= 1;3284 + }3285 +3286 + undoindex -= 1;3287 +3288 + copy = graphs[undoindex];3289 +3290 + cameraView.object = copy;3291 + copy.Touch();3292 +3293 + ResetModel();3294 + refreshContents();3295 + }3296 +3297 + public void Redo()3298 + {3299 + if (graphs[undoindex + 1] == null)3300 + {3301 + java.awt.Toolkit.getDefaultToolkit().beep();3302 + return;3303 + }3304 +3305 + undoindex += 1;3306 +3307 + copy = graphs[undoindex];3308 +3309 + cameraView.object = copy;3310 + copy.Touch();3311 +3312 + ResetModel();3313 + refreshContents();3314 + }3315 +3214 3316 void ImportGFD() 3215 3317 { 3216 3318 FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD); .. .. @@ -3855,6 +3957,7 @@ 3855 3957 3856 3958 void makeSomething(Object3D thing, boolean resetmodel) // deselect) 3857 3959 { 3960 + Save();3858 3961 //Tween.set(thing, 0).target(1).start(tweenManager); 3859 3962 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); 3860 3963 // if (thing instanceof GenericJointDemo)