.. | .. |
---|
1935 | 1935 | e2.printStackTrace(); |
---|
1936 | 1936 | } |
---|
1937 | 1937 | } |
---|
| 1938 | + |
---|
1938 | 1939 | LoadJMEThread loadThread; |
---|
1939 | 1940 | |
---|
1940 | 1941 | class LoadJMEThread extends Thread |
---|
.. | .. |
---|
1992 | 1993 | //LoadFile0(filename, converter); |
---|
1993 | 1994 | } |
---|
1994 | 1995 | } |
---|
| 1996 | + |
---|
1995 | 1997 | LoadOBJThread loadObjThread; |
---|
1996 | 1998 | |
---|
1997 | 1999 | class LoadOBJThread extends Thread |
---|
.. | .. |
---|
2925 | 2927 | return; |
---|
2926 | 2928 | } else if (event.getSource() == toggleSwitchItem) |
---|
2927 | 2929 | { |
---|
2928 | | - cameraView.ToggleRandom(); |
---|
| 2930 | + cameraView.ToggleSwitch(); |
---|
2929 | 2931 | cameraView.repaint(); |
---|
2930 | 2932 | return; |
---|
2931 | 2933 | } else if (event.getSource() == toggleHandleItem) |
---|
.. | .. |
---|
3212 | 3214 | objEditor.refreshContents(); |
---|
3213 | 3215 | } |
---|
3214 | 3216 | |
---|
3215 | | - Object3D graphs[] = new Object3D[10000]; |
---|
3216 | | - int undoindex = 0; |
---|
3217 | | - |
---|
3218 | | - static public Object clone(Object o) |
---|
| 3217 | + static public byte[] Compress(Object o) |
---|
3219 | 3218 | { |
---|
3220 | 3219 | try |
---|
3221 | 3220 | { |
---|
3222 | 3221 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
3223 | | - ObjectOutputStream out = new ObjectOutputStream(baos); |
---|
| 3222 | + java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3223 | + ObjectOutputStream out = new ObjectOutputStream(zstream); |
---|
3224 | 3224 | |
---|
3225 | 3225 | out.writeObject(o); |
---|
| 3226 | + |
---|
| 3227 | + out.flush(); |
---|
3226 | 3228 | |
---|
3227 | | - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); |
---|
3228 | | - ObjectInputStream in = new ObjectInputStream(bais); |
---|
| 3229 | + zstream.close(); |
---|
| 3230 | + out.close(); |
---|
| 3231 | + |
---|
| 3232 | + return baos.toByteArray(); |
---|
| 3233 | + } catch (Exception e) |
---|
| 3234 | + { |
---|
| 3235 | + System.err.println(e); |
---|
| 3236 | + return null; |
---|
| 3237 | + } |
---|
| 3238 | + } |
---|
| 3239 | + |
---|
| 3240 | + static public Object Uncompress(byte[] bytes) |
---|
| 3241 | + { |
---|
| 3242 | + System.out.println("#bytes = " + bytes.length); |
---|
| 3243 | + try |
---|
| 3244 | + { |
---|
| 3245 | + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
| 3246 | + java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
| 3247 | + ObjectInputStream in = new ObjectInputStream(istream); |
---|
3229 | 3248 | Object obj = in.readObject(); |
---|
3230 | 3249 | in.close(); |
---|
3231 | | - out.close(); |
---|
| 3250 | + |
---|
3232 | 3251 | return obj; |
---|
3233 | 3252 | } catch (Exception e) |
---|
3234 | 3253 | { |
---|
.. | .. |
---|
3237 | 3256 | } |
---|
3238 | 3257 | } |
---|
3239 | 3258 | |
---|
| 3259 | + static public Object clone(Object o) |
---|
| 3260 | + { |
---|
| 3261 | + try |
---|
| 3262 | + { |
---|
| 3263 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 3264 | + ObjectOutputStream out = new ObjectOutputStream(baos); |
---|
| 3265 | + |
---|
| 3266 | + out.writeObject(o); |
---|
| 3267 | + |
---|
| 3268 | + out.flush(); |
---|
| 3269 | + out.close(); |
---|
| 3270 | + |
---|
| 3271 | + byte[] bytes = baos.toByteArray(); |
---|
| 3272 | + |
---|
| 3273 | + System.out.println("clone = " + bytes.length); |
---|
| 3274 | + |
---|
| 3275 | + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
| 3276 | + ObjectInputStream in = new ObjectInputStream(bais); |
---|
| 3277 | + Object obj = in.readObject(); |
---|
| 3278 | + in.close(); |
---|
| 3279 | + |
---|
| 3280 | + return obj; |
---|
| 3281 | + } catch (Exception e) |
---|
| 3282 | + { |
---|
| 3283 | + System.err.println(e); |
---|
| 3284 | + return null; |
---|
| 3285 | + } |
---|
| 3286 | + } |
---|
| 3287 | + |
---|
| 3288 | + cRadio GetCurrentTab() |
---|
| 3289 | + { |
---|
| 3290 | + cRadio ab; |
---|
| 3291 | + for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();) |
---|
| 3292 | + { |
---|
| 3293 | + ab = (cRadio)e.nextElement(); |
---|
| 3294 | + if(ab.GetObject() == copy) |
---|
| 3295 | + { |
---|
| 3296 | + return ab; |
---|
| 3297 | + } |
---|
| 3298 | + } |
---|
| 3299 | + |
---|
| 3300 | + return null; |
---|
| 3301 | + } |
---|
| 3302 | + |
---|
| 3303 | + java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
| 3304 | + |
---|
3240 | 3305 | public void Save() |
---|
3241 | 3306 | { |
---|
3242 | | - if (true) return; |
---|
| 3307 | + cRadio tab = GetCurrentTab(); |
---|
| 3308 | + |
---|
| 3309 | + copy.ExtractBigData(hashtable); |
---|
3243 | 3310 | |
---|
3244 | 3311 | //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3245 | | - graphs[undoindex++] = (Object3D)clone(copy); |
---|
| 3312 | + tab.graphs[tab.undoindex++] = Compress(copy); |
---|
3246 | 3313 | |
---|
3247 | | - for (int i = undoindex; i < graphs.length; i++) |
---|
| 3314 | + copy.RestoreBigData(hashtable); |
---|
| 3315 | + |
---|
| 3316 | + //assert(hashtable.isEmpty()); |
---|
| 3317 | + |
---|
| 3318 | + for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
3248 | 3319 | { |
---|
3249 | | - graphs[i] = null; |
---|
| 3320 | + tab.graphs[i] = null; |
---|
3250 | 3321 | } |
---|
3251 | 3322 | |
---|
3252 | 3323 | // test save |
---|
.. | .. |
---|
3254 | 3325 | { |
---|
3255 | 3326 | try |
---|
3256 | 3327 | { |
---|
3257 | | - FileOutputStream ostream = new FileOutputStream("save" + undoindex); |
---|
| 3328 | + FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex); |
---|
3258 | 3329 | ObjectOutputStream p = new ObjectOutputStream(ostream); |
---|
3259 | 3330 | |
---|
3260 | 3331 | p.writeObject(copy); |
---|
.. | .. |
---|
3269 | 3340 | } |
---|
3270 | 3341 | } |
---|
3271 | 3342 | |
---|
| 3343 | + void CopyChanged(Object3D obj) |
---|
| 3344 | + { |
---|
| 3345 | + copy.ExtractBigData(hashtable); |
---|
| 3346 | + |
---|
| 3347 | + copy.clear(); |
---|
| 3348 | + |
---|
| 3349 | + for (int i=0; i<obj.Size(); i++) |
---|
| 3350 | + { |
---|
| 3351 | + copy.add(obj.get(i)); |
---|
| 3352 | + } |
---|
| 3353 | + |
---|
| 3354 | + copy.RestoreBigData(hashtable); |
---|
| 3355 | + |
---|
| 3356 | + //assert(hashtable.isEmpty()); |
---|
| 3357 | + |
---|
| 3358 | + copy.Touch(); |
---|
| 3359 | + |
---|
| 3360 | + ResetModel(); |
---|
| 3361 | + copy.HardTouch(); // recompile? |
---|
| 3362 | + |
---|
| 3363 | + cRadio ab; |
---|
| 3364 | + for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();) |
---|
| 3365 | + { |
---|
| 3366 | + ab = (cRadio)e.nextElement(); |
---|
| 3367 | + Object3D test = copy.GetObject(ab.object.GetUUID()); |
---|
| 3368 | + //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID()); |
---|
| 3369 | + if (test != null) |
---|
| 3370 | + { |
---|
| 3371 | + test.editWindow = ab.object.editWindow; |
---|
| 3372 | + ab.object = test; |
---|
| 3373 | + } |
---|
| 3374 | + } |
---|
| 3375 | + |
---|
| 3376 | + refreshContents(); |
---|
| 3377 | + } |
---|
| 3378 | + |
---|
3272 | 3379 | public void Undo() |
---|
3273 | 3380 | { |
---|
3274 | | - if (undoindex == 0) |
---|
| 3381 | + cRadio tab = GetCurrentTab(); |
---|
| 3382 | + |
---|
| 3383 | + if (tab.undoindex == 0) |
---|
3275 | 3384 | { |
---|
3276 | 3385 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3277 | 3386 | return; |
---|
3278 | 3387 | } |
---|
3279 | 3388 | |
---|
3280 | | - if (graphs[undoindex] == null) |
---|
| 3389 | + if (tab.graphs[tab.undoindex] == null) |
---|
3281 | 3390 | { |
---|
3282 | 3391 | Save(); |
---|
3283 | | - undoindex -= 1; |
---|
| 3392 | + tab.undoindex -= 1; |
---|
3284 | 3393 | } |
---|
3285 | 3394 | |
---|
3286 | | - undoindex -= 1; |
---|
| 3395 | + tab.undoindex -= 1; |
---|
3287 | 3396 | |
---|
3288 | | - copy = graphs[undoindex]; |
---|
3289 | | - |
---|
3290 | | - cameraView.object = copy; |
---|
3291 | | - copy.Touch(); |
---|
3292 | | - |
---|
3293 | | - ResetModel(); |
---|
3294 | | - refreshContents(); |
---|
| 3397 | + CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
3295 | 3398 | } |
---|
3296 | 3399 | |
---|
3297 | 3400 | public void Redo() |
---|
3298 | 3401 | { |
---|
3299 | | - if (graphs[undoindex + 1] == null) |
---|
| 3402 | + cRadio tab = GetCurrentTab(); |
---|
| 3403 | + |
---|
| 3404 | + if (tab.graphs[tab.undoindex + 1] == null) |
---|
3300 | 3405 | { |
---|
3301 | 3406 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3302 | 3407 | return; |
---|
3303 | 3408 | } |
---|
3304 | 3409 | |
---|
3305 | | - undoindex += 1; |
---|
| 3410 | + tab.undoindex += 1; |
---|
3306 | 3411 | |
---|
3307 | | - copy = graphs[undoindex]; |
---|
3308 | | - |
---|
3309 | | - cameraView.object = copy; |
---|
3310 | | - copy.Touch(); |
---|
3311 | | - |
---|
3312 | | - ResetModel(); |
---|
3313 | | - refreshContents(); |
---|
| 3412 | + CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
3314 | 3413 | } |
---|
3315 | 3414 | |
---|
3316 | 3415 | void ImportGFD() |
---|
.. | .. |
---|
4259 | 4358 | |
---|
4260 | 4359 | if (readobj != null) |
---|
4261 | 4360 | { |
---|
| 4361 | + Save(); |
---|
4262 | 4362 | try |
---|
4263 | 4363 | { |
---|
4264 | 4364 | //readobj.deepCopySelf(copy); |
---|