.. | .. |
---|
168 | 168 | // objEditor.ctrlPanel.remove(remarkButton); |
---|
169 | 169 | |
---|
170 | 170 | objEditor.ctrlPanel.remove(setupPanel); |
---|
| 171 | + objEditor.ctrlPanel.remove(setupPanel2); |
---|
171 | 172 | objEditor.ctrlPanel.remove(commandsPanel); |
---|
172 | 173 | objEditor.ctrlPanel.remove(pushPanel); |
---|
173 | 174 | //objEditor.ctrlPanel.remove(fillPanel); |
---|
.. | .. |
---|
278 | 279 | frame.setMenuBar(menuBar = new MenuBar()); |
---|
279 | 280 | menuBar.add(fileMenu = new Menu("File")); |
---|
280 | 281 | fileMenu.add(newItem = new MenuItem("New")); |
---|
281 | | - fileMenu.add(loadItem = new MenuItem("Load...")); |
---|
| 282 | + fileMenu.add(loadItem = new MenuItem("Open...")); |
---|
282 | 283 | |
---|
283 | 284 | //oe.menuBar.add(menu = new Menu("Include")); |
---|
284 | 285 | Menu menu = new Menu("Import"); |
---|
.. | .. |
---|
419 | 420 | e.printStackTrace(); |
---|
420 | 421 | } |
---|
421 | 422 | |
---|
422 | | - String selection = infoarea.getText(); |
---|
423 | | - java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection); |
---|
424 | | - java.awt.datatransfer.Clipboard clipboard = |
---|
425 | | - Toolkit.getDefaultToolkit().getSystemClipboard(); |
---|
| 423 | +// String selection = infoarea.getText(); |
---|
| 424 | +// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection); |
---|
| 425 | +// java.awt.datatransfer.Clipboard clipboard = |
---|
| 426 | +// Toolkit.getDefaultToolkit().getSystemClipboard(); |
---|
426 | 427 | //clipboard.setContents(data, data); |
---|
427 | 428 | } |
---|
428 | 429 | |
---|
.. | .. |
---|
747 | 748 | |
---|
748 | 749 | cGridBag namePanel; |
---|
749 | 750 | cGridBag setupPanel; |
---|
| 751 | + cGridBag setupPanel2; |
---|
750 | 752 | cGridBag commandsPanel; |
---|
751 | 753 | cGridBag pushPanel; |
---|
752 | 754 | cGridBag fillPanel; |
---|
.. | .. |
---|
939 | 941 | markCB = AddCheckBox(setupPanel, "Mark", copy.marked); |
---|
940 | 942 | markCB.setToolTipText("Set the animation target transform"); |
---|
941 | 943 | |
---|
942 | | - rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind); |
---|
| 944 | + setupPanel2 = new cGridBag().setVertical(false); |
---|
| 945 | + |
---|
| 946 | + rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind); |
---|
943 | 947 | rewindCB.setToolTipText("Rewind animation"); |
---|
944 | 948 | |
---|
945 | | - randomCB = AddCheckBox(setupPanel, "Random", copy.random); |
---|
946 | | - randomCB.setToolTipText("Option for switch node"); |
---|
| 949 | + randomCB = AddCheckBox(setupPanel2, "Rand", copy.random); |
---|
| 950 | + randomCB.setToolTipText("Rewind or Go back and forth randomly"); |
---|
947 | 951 | |
---|
948 | 952 | if (Globals.ADVANCED) |
---|
949 | 953 | { |
---|
950 | | - link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master); |
---|
| 954 | + link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master); |
---|
951 | 955 | link2masterCB.setToolTipText("Attach to support"); |
---|
952 | | - speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup); |
---|
| 956 | + speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); |
---|
953 | 957 | speedupCB.setToolTipText("Option motion capture"); |
---|
954 | 958 | } |
---|
955 | 959 | |
---|
956 | 960 | oe.ctrlPanel.add(setupPanel); |
---|
| 961 | + oe.ctrlPanel.Return(); |
---|
| 962 | + oe.ctrlPanel.add(setupPanel2); |
---|
957 | 963 | oe.ctrlPanel.Return(); |
---|
958 | 964 | |
---|
959 | 965 | commandsPanel = new cGridBag().setVertical(false); |
---|
.. | .. |
---|
2072 | 2078 | |
---|
2073 | 2079 | void LoadObjFile(String fullname) |
---|
2074 | 2080 | { |
---|
2075 | | - /* |
---|
| 2081 | + System.out.println("Loading " + fullname); |
---|
| 2082 | + /**/ |
---|
2076 | 2083 | //lastFilename = fullname; |
---|
2077 | 2084 | if(loadObjThread == null) |
---|
2078 | 2085 | { |
---|
2079 | | - loadObjThread = new LoadOBJThread(); |
---|
2080 | | - loadObjThread.start(); |
---|
| 2086 | + loadObjThread = new LoadOBJThread(); |
---|
| 2087 | + loadObjThread.start(); |
---|
2081 | 2088 | } |
---|
2082 | 2089 | |
---|
2083 | 2090 | loadObjThread.add(fullname); |
---|
2084 | | - */ |
---|
| 2091 | + /**/ |
---|
2085 | 2092 | |
---|
2086 | | - System.out.println("Loading " + fullname); |
---|
2087 | | - makeSomething(new FileObject(fullname, true), true); |
---|
| 2093 | + //makeSomething(new FileObject(fullname, true), true); |
---|
2088 | 2094 | } |
---|
2089 | 2095 | |
---|
2090 | 2096 | void LoadGFDFile(String fullname) |
---|
.. | .. |
---|
2927 | 2933 | return; |
---|
2928 | 2934 | } else if (event.getSource() == toggleSwitchItem) |
---|
2929 | 2935 | { |
---|
2930 | | - cameraView.ToggleRandom(); |
---|
| 2936 | + cameraView.ToggleSwitch(); |
---|
2931 | 2937 | cameraView.repaint(); |
---|
2932 | 2938 | return; |
---|
2933 | 2939 | } else if (event.getSource() == toggleHandleItem) |
---|
.. | .. |
---|
3214 | 3220 | objEditor.refreshContents(); |
---|
3215 | 3221 | } |
---|
3216 | 3222 | |
---|
| 3223 | + static public byte[] Compress(Object3D o) |
---|
| 3224 | + { |
---|
| 3225 | + try |
---|
| 3226 | + { |
---|
| 3227 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 3228 | + java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3229 | + ObjectOutputStream out = new ObjectOutputStream(zstream); |
---|
| 3230 | + |
---|
| 3231 | + Object3D parent = o.parent; |
---|
| 3232 | + o.parent = null; |
---|
| 3233 | + |
---|
| 3234 | + out.writeObject(o); |
---|
| 3235 | + |
---|
| 3236 | + o.parent = parent; |
---|
| 3237 | + |
---|
| 3238 | + out.flush(); |
---|
| 3239 | + |
---|
| 3240 | + zstream.close(); |
---|
| 3241 | + out.close(); |
---|
| 3242 | + |
---|
| 3243 | + return baos.toByteArray(); |
---|
| 3244 | + } catch (Exception e) |
---|
| 3245 | + { |
---|
| 3246 | + System.err.println(e); |
---|
| 3247 | + return null; |
---|
| 3248 | + } |
---|
| 3249 | + } |
---|
| 3250 | + |
---|
| 3251 | + static public Object Uncompress(byte[] bytes) |
---|
| 3252 | + { |
---|
| 3253 | + System.out.println("#bytes = " + bytes.length); |
---|
| 3254 | + try |
---|
| 3255 | + { |
---|
| 3256 | + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
| 3257 | + java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
| 3258 | + ObjectInputStream in = new ObjectInputStream(istream); |
---|
| 3259 | + Object obj = in.readObject(); |
---|
| 3260 | + in.close(); |
---|
| 3261 | + |
---|
| 3262 | + return obj; |
---|
| 3263 | + } catch (Exception e) |
---|
| 3264 | + { |
---|
| 3265 | + System.err.println(e); |
---|
| 3266 | + return null; |
---|
| 3267 | + } |
---|
| 3268 | + } |
---|
| 3269 | + |
---|
3217 | 3270 | static public Object clone(Object o) |
---|
3218 | 3271 | { |
---|
3219 | 3272 | try |
---|
.. | .. |
---|
3222 | 3275 | ObjectOutputStream out = new ObjectOutputStream(baos); |
---|
3223 | 3276 | |
---|
3224 | 3277 | out.writeObject(o); |
---|
| 3278 | + |
---|
| 3279 | + out.flush(); |
---|
| 3280 | + out.close(); |
---|
| 3281 | + |
---|
| 3282 | + byte[] bytes = baos.toByteArray(); |
---|
| 3283 | + |
---|
| 3284 | + System.out.println("clone = " + bytes.length); |
---|
3225 | 3285 | |
---|
3226 | | - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); |
---|
| 3286 | + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
3227 | 3287 | ObjectInputStream in = new ObjectInputStream(bais); |
---|
3228 | 3288 | Object obj = in.readObject(); |
---|
3229 | 3289 | in.close(); |
---|
3230 | | - out.close(); |
---|
| 3290 | + |
---|
3231 | 3291 | return obj; |
---|
3232 | 3292 | } catch (Exception e) |
---|
3233 | 3293 | { |
---|
.. | .. |
---|
3251 | 3311 | return null; |
---|
3252 | 3312 | } |
---|
3253 | 3313 | |
---|
| 3314 | + java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
| 3315 | + |
---|
3254 | 3316 | public void Save() |
---|
3255 | 3317 | { |
---|
3256 | 3318 | cRadio tab = GetCurrentTab(); |
---|
3257 | 3319 | |
---|
| 3320 | + boolean temp = CameraPane.SWITCH; |
---|
| 3321 | + CameraPane.SWITCH = false; |
---|
| 3322 | + |
---|
| 3323 | + copy.ExtractBigData(hashtable); |
---|
| 3324 | + |
---|
3258 | 3325 | //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3259 | | - tab.graphs[tab.undoindex++] = (Object3D)clone(copy); |
---|
| 3326 | + tab.graphs[tab.undoindex++] = Compress(copy); |
---|
3260 | 3327 | |
---|
| 3328 | + copy.RestoreBigData(hashtable); |
---|
| 3329 | + |
---|
| 3330 | + CameraPane.SWITCH = temp; |
---|
| 3331 | + |
---|
| 3332 | + //assert(hashtable.isEmpty()); |
---|
| 3333 | + |
---|
3261 | 3334 | for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
3262 | 3335 | { |
---|
3263 | 3336 | tab.graphs[i] = null; |
---|
.. | .. |
---|
3285 | 3358 | |
---|
3286 | 3359 | void CopyChanged(Object3D obj) |
---|
3287 | 3360 | { |
---|
| 3361 | + boolean temp = CameraPane.SWITCH; |
---|
| 3362 | + CameraPane.SWITCH = false; |
---|
| 3363 | + |
---|
| 3364 | + copy.ExtractBigData(hashtable); |
---|
| 3365 | + |
---|
3288 | 3366 | copy.clear(); |
---|
3289 | 3367 | |
---|
3290 | 3368 | for (int i=0; i<obj.Size(); i++) |
---|
3291 | 3369 | { |
---|
3292 | 3370 | copy.add(obj.get(i)); |
---|
3293 | 3371 | } |
---|
| 3372 | + |
---|
| 3373 | + copy.RestoreBigData(hashtable); |
---|
| 3374 | + |
---|
| 3375 | + CameraPane.SWITCH = temp; |
---|
| 3376 | + |
---|
| 3377 | + //assert(hashtable.isEmpty()); |
---|
3294 | 3378 | |
---|
3295 | 3379 | copy.Touch(); |
---|
3296 | 3380 | |
---|
.. | .. |
---|
3331 | 3415 | |
---|
3332 | 3416 | tab.undoindex -= 1; |
---|
3333 | 3417 | |
---|
3334 | | - CopyChanged(tab.graphs[tab.undoindex]); |
---|
| 3418 | + CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
3335 | 3419 | } |
---|
3336 | 3420 | |
---|
3337 | 3421 | public void Redo() |
---|
.. | .. |
---|
3346 | 3430 | |
---|
3347 | 3431 | tab.undoindex += 1; |
---|
3348 | 3432 | |
---|
3349 | | - CopyChanged(tab.graphs[tab.undoindex]); |
---|
| 3433 | + CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
3350 | 3434 | } |
---|
3351 | 3435 | |
---|
3352 | 3436 | void ImportGFD() |
---|
.. | .. |
---|
4217 | 4301 | |
---|
4218 | 4302 | try |
---|
4219 | 4303 | { |
---|
| 4304 | + // Try compressed version first. |
---|
4220 | 4305 | java.io.FileInputStream istream = new java.io.FileInputStream(fullname); |
---|
4221 | 4306 | java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream); |
---|
4222 | 4307 | java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream); |
---|
.. | .. |
---|
4286 | 4371 | |
---|
4287 | 4372 | void LoadIt(Object obj) |
---|
4288 | 4373 | { |
---|
| 4374 | + if (obj == null) |
---|
| 4375 | + { |
---|
| 4376 | + // Invalid file |
---|
| 4377 | + return; |
---|
| 4378 | + } |
---|
| 4379 | + |
---|
4289 | 4380 | System.out.println("Loaded " + obj); |
---|
4290 | 4381 | //new Exception().printStackTrace(); |
---|
4291 | 4382 | Object3D readobj = (Object3D) obj; |
---|
.. | .. |
---|
4295 | 4386 | |
---|
4296 | 4387 | if (readobj != null) |
---|
4297 | 4388 | { |
---|
| 4389 | + Save(); |
---|
4298 | 4390 | try |
---|
4299 | 4391 | { |
---|
4300 | 4392 | //readobj.deepCopySelf(copy); |
---|