Normand Briere
2019-06-21 15123b19e7bc8da2869429b07f0fbaa0598e945e
ObjEditor.java
....@@ -168,6 +168,7 @@
168168 // objEditor.ctrlPanel.remove(remarkButton);
169169
170170 objEditor.ctrlPanel.remove(setupPanel);
171
+ objEditor.ctrlPanel.remove(setupPanel2);
171172 objEditor.ctrlPanel.remove(commandsPanel);
172173 objEditor.ctrlPanel.remove(pushPanel);
173174 //objEditor.ctrlPanel.remove(fillPanel);
....@@ -278,7 +279,7 @@
278279 frame.setMenuBar(menuBar = new MenuBar());
279280 menuBar.add(fileMenu = new Menu("File"));
280281 fileMenu.add(newItem = new MenuItem("New"));
281
- fileMenu.add(loadItem = new MenuItem("Load..."));
282
+ fileMenu.add(loadItem = new MenuItem("Open..."));
282283
283284 //oe.menuBar.add(menu = new Menu("Include"));
284285 Menu menu = new Menu("Import");
....@@ -419,10 +420,10 @@
419420 e.printStackTrace();
420421 }
421422
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();
426427 //clipboard.setContents(data, data);
427428 }
428429
....@@ -747,6 +748,7 @@
747748
748749 cGridBag namePanel;
749750 cGridBag setupPanel;
751
+ cGridBag setupPanel2;
750752 cGridBag commandsPanel;
751753 cGridBag pushPanel;
752754 cGridBag fillPanel;
....@@ -939,21 +941,25 @@
939941 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
940942 markCB.setToolTipText("Set the animation target transform");
941943
942
- rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind);
944
+ setupPanel2 = new cGridBag().setVertical(false);
945
+
946
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
943947 rewindCB.setToolTipText("Rewind animation");
944948
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");
947951
948952 if (Globals.ADVANCED)
949953 {
950
- link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master);
954
+ link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
951955 link2masterCB.setToolTipText("Attach to support");
952
- speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup);
956
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
953957 speedupCB.setToolTipText("Option motion capture");
954958 }
955959
956960 oe.ctrlPanel.add(setupPanel);
961
+ oe.ctrlPanel.Return();
962
+ oe.ctrlPanel.add(setupPanel2);
957963 oe.ctrlPanel.Return();
958964
959965 commandsPanel = new cGridBag().setVertical(false);
....@@ -2072,19 +2078,19 @@
20722078
20732079 void LoadObjFile(String fullname)
20742080 {
2075
- /*
2081
+ System.out.println("Loading " + fullname);
2082
+ /**/
20762083 //lastFilename = fullname;
20772084 if(loadObjThread == null)
20782085 {
2079
- loadObjThread = new LoadOBJThread();
2080
- loadObjThread.start();
2086
+ loadObjThread = new LoadOBJThread();
2087
+ loadObjThread.start();
20812088 }
20822089
20832090 loadObjThread.add(fullname);
2084
- */
2091
+ /**/
20852092
2086
- System.out.println("Loading " + fullname);
2087
- makeSomething(new FileObject(fullname, true), true);
2093
+ //makeSomething(new FileObject(fullname, true), true);
20882094 }
20892095
20902096 void LoadGFDFile(String fullname)
....@@ -2927,7 +2933,7 @@
29272933 return;
29282934 } else if (event.getSource() == toggleSwitchItem)
29292935 {
2930
- cameraView.ToggleRandom();
2936
+ cameraView.ToggleSwitch();
29312937 cameraView.repaint();
29322938 return;
29332939 } else if (event.getSource() == toggleHandleItem)
....@@ -3214,6 +3220,53 @@
32143220 objEditor.refreshContents();
32153221 }
32163222
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
+
32173270 static public Object clone(Object o)
32183271 {
32193272 try
....@@ -3222,12 +3275,19 @@
32223275 ObjectOutputStream out = new ObjectOutputStream(baos);
32233276
32243277 out.writeObject(o);
3278
+
3279
+ out.flush();
3280
+ out.close();
3281
+
3282
+ byte[] bytes = baos.toByteArray();
3283
+
3284
+ System.out.println("clone = " + bytes.length);
32253285
3226
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
3286
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
32273287 ObjectInputStream in = new ObjectInputStream(bais);
32283288 Object obj = in.readObject();
32293289 in.close();
3230
- out.close();
3290
+
32313291 return obj;
32323292 } catch (Exception e)
32333293 {
....@@ -3242,7 +3302,7 @@
32423302 for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
32433303 {
32443304 ab = (cRadio)e.nextElement();
3245
- if(ab.GetObject() == client)
3305
+ if(ab.GetObject() == copy)
32463306 {
32473307 return ab;
32483308 }
....@@ -3251,13 +3311,26 @@
32513311 return null;
32523312 }
32533313
3314
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3315
+
32543316 public void Save()
32553317 {
32563318 cRadio tab = GetCurrentTab();
32573319
3320
+ boolean temp = CameraPane.SWITCH;
3321
+ CameraPane.SWITCH = false;
3322
+
3323
+ copy.ExtractBigData(hashtable);
3324
+
32583325 //EditorFrame.m_MainFrame.requestFocusInWindow();
3259
- tab.graphs[tab.undoindex++] = (Object3D)clone(copy);
3326
+ tab.graphs[tab.undoindex++] = Compress(copy);
32603327
3328
+ copy.RestoreBigData(hashtable);
3329
+
3330
+ CameraPane.SWITCH = temp;
3331
+
3332
+ //assert(hashtable.isEmpty());
3333
+
32613334 for (int i = tab.undoindex; i < tab.graphs.length; i++)
32623335 {
32633336 tab.graphs[i] = null;
....@@ -3285,12 +3358,23 @@
32853358
32863359 void CopyChanged(Object3D obj)
32873360 {
3361
+ boolean temp = CameraPane.SWITCH;
3362
+ CameraPane.SWITCH = false;
3363
+
3364
+ copy.ExtractBigData(hashtable);
3365
+
32883366 copy.clear();
32893367
32903368 for (int i=0; i<obj.Size(); i++)
32913369 {
32923370 copy.add(obj.get(i));
32933371 }
3372
+
3373
+ copy.RestoreBigData(hashtable);
3374
+
3375
+ CameraPane.SWITCH = temp;
3376
+
3377
+ //assert(hashtable.isEmpty());
32943378
32953379 copy.Touch();
32963380
....@@ -3331,7 +3415,7 @@
33313415
33323416 tab.undoindex -= 1;
33333417
3334
- CopyChanged(tab.graphs[tab.undoindex]);
3418
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
33353419 }
33363420
33373421 public void Redo()
....@@ -3346,7 +3430,7 @@
33463430
33473431 tab.undoindex += 1;
33483432
3349
- CopyChanged(tab.graphs[tab.undoindex]);
3433
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
33503434 }
33513435
33523436 void ImportGFD()
....@@ -4217,6 +4301,7 @@
42174301
42184302 try
42194303 {
4304
+ // Try compressed version first.
42204305 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
42214306 java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
42224307 java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
....@@ -4286,6 +4371,12 @@
42864371
42874372 void LoadIt(Object obj)
42884373 {
4374
+ if (obj == null)
4375
+ {
4376
+ // Invalid file
4377
+ return;
4378
+ }
4379
+
42894380 System.out.println("Loaded " + obj);
42904381 //new Exception().printStackTrace();
42914382 Object3D readobj = (Object3D) obj;
....@@ -4295,6 +4386,7 @@
42954386
42964387 if (readobj != null)
42974388 {
4389
+ Save();
42984390 try
42994391 {
43004392 //readobj.deepCopySelf(copy);