Normand Briere
2019-06-13 4629090fafbef256abd0686a85ee12042d658868
ObjEditor.java
....@@ -2927,7 +2927,7 @@
29272927 return;
29282928 } else if (event.getSource() == toggleSwitchItem)
29292929 {
2930
- cameraView.ToggleRandom();
2930
+ cameraView.ToggleSwitch();
29312931 cameraView.repaint();
29322932 return;
29332933 } else if (event.getSource() == toggleHandleItem)
....@@ -3214,6 +3214,48 @@
32143214 objEditor.refreshContents();
32153215 }
32163216
3217
+ static public byte[] Compress(Object o)
3218
+ {
3219
+ try
3220
+ {
3221
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3222
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3223
+ ObjectOutputStream out = new ObjectOutputStream(zstream);
3224
+
3225
+ out.writeObject(o);
3226
+
3227
+ out.flush();
3228
+
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);
3248
+ Object obj = in.readObject();
3249
+ in.close();
3250
+
3251
+ return obj;
3252
+ } catch (Exception e)
3253
+ {
3254
+ System.err.println(e);
3255
+ return null;
3256
+ }
3257
+ }
3258
+
32173259 static public Object clone(Object o)
32183260 {
32193261 try
....@@ -3222,12 +3264,19 @@
32223264 ObjectOutputStream out = new ObjectOutputStream(baos);
32233265
32243266 out.writeObject(o);
3267
+
3268
+ out.flush();
3269
+ out.close();
3270
+
3271
+ byte[] bytes = baos.toByteArray();
3272
+
3273
+ System.out.println("clone = " + bytes.length);
32253274
3226
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
3275
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
32273276 ObjectInputStream in = new ObjectInputStream(bais);
32283277 Object obj = in.readObject();
32293278 in.close();
3230
- out.close();
3279
+
32313280 return obj;
32323281 } catch (Exception e)
32333282 {
....@@ -3251,13 +3300,26 @@
32513300 return null;
32523301 }
32533302
3303
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3304
+
32543305 public void Save()
32553306 {
32563307 cRadio tab = GetCurrentTab();
32573308
3309
+ boolean temp = CameraPane.SWITCH;
3310
+ CameraPane.SWITCH = false;
3311
+
3312
+ copy.ExtractBigData(hashtable);
3313
+
32583314 //EditorFrame.m_MainFrame.requestFocusInWindow();
3259
- tab.graphs[tab.undoindex++] = (Object3D)clone(copy);
3315
+ tab.graphs[tab.undoindex++] = Compress(copy);
32603316
3317
+ copy.RestoreBigData(hashtable);
3318
+
3319
+ CameraPane.SWITCH = temp;
3320
+
3321
+ //assert(hashtable.isEmpty());
3322
+
32613323 for (int i = tab.undoindex; i < tab.graphs.length; i++)
32623324 {
32633325 tab.graphs[i] = null;
....@@ -3285,12 +3347,23 @@
32853347
32863348 void CopyChanged(Object3D obj)
32873349 {
3350
+ boolean temp = CameraPane.SWITCH;
3351
+ CameraPane.SWITCH = false;
3352
+
3353
+ copy.ExtractBigData(hashtable);
3354
+
32883355 copy.clear();
32893356
32903357 for (int i=0; i<obj.Size(); i++)
32913358 {
32923359 copy.add(obj.get(i));
32933360 }
3361
+
3362
+ copy.RestoreBigData(hashtable);
3363
+
3364
+ CameraPane.SWITCH = temp;
3365
+
3366
+ //assert(hashtable.isEmpty());
32943367
32953368 copy.Touch();
32963369
....@@ -3331,7 +3404,7 @@
33313404
33323405 tab.undoindex -= 1;
33333406
3334
- CopyChanged(tab.graphs[tab.undoindex]);
3407
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
33353408 }
33363409
33373410 public void Redo()
....@@ -3346,7 +3419,7 @@
33463419
33473420 tab.undoindex += 1;
33483421
3349
- CopyChanged(tab.graphs[tab.undoindex]);
3422
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
33503423 }
33513424
33523425 void ImportGFD()
....@@ -4295,6 +4368,7 @@
42954368
42964369 if (readobj != null)
42974370 {
4371
+ Save();
42984372 try
42994373 {
43004374 //readobj.deepCopySelf(copy);