Normand Briere
2019-06-26 89b25e7cc97f6fe221dfd41c4d463500f8a31bc1
ObjEditor.java
....@@ -4,6 +4,7 @@
44
55 import java.awt.*;
66 import java.awt.event.*;
7
+import java.awt.image.BufferedImage;
78 import javax.swing.*;
89 import javax.swing.event.*;
910 import javax.swing.text.*;
....@@ -35,6 +36,67 @@
3536
3637 GroupEditor callee;
3738 JFrame frame;
39
+
40
+ static ObjEditor theFrame;
41
+
42
+ cButton GetButton(String name, boolean border)
43
+ {
44
+ try
45
+ {
46
+ ImageIcon icon = GetIcon(name);
47
+ return new cButton(icon, border);
48
+ }
49
+ catch (Exception e)
50
+ {
51
+ return new cButton(name, border);
52
+ }
53
+ }
54
+
55
+ cToggleButton GetToggleButton(String name, boolean border)
56
+ {
57
+ try
58
+ {
59
+ ImageIcon icon = GetIcon(name);
60
+ return new cToggleButton(icon, border);
61
+ }
62
+ catch (Exception e)
63
+ {
64
+ return new cToggleButton(name, border);
65
+ }
66
+ }
67
+
68
+ cCheckBox GetCheckBox(String name, boolean border)
69
+ {
70
+ try
71
+ {
72
+ ImageIcon icon = GetIcon(name);
73
+ return new cCheckBox(icon, border);
74
+ }
75
+ catch (Exception e)
76
+ {
77
+ return new cCheckBox(name, border);
78
+ }
79
+ }
80
+
81
+ private ImageIcon GetIcon(String name) throws IOException
82
+ {
83
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
84
+
85
+ if (image.getWidth() != 24 && image.getHeight() != 24)
86
+ {
87
+ BufferedImage resized = new BufferedImage(24, 24, image.getType());
88
+ Graphics2D g = resized.createGraphics();
89
+ g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
90
+ //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
91
+ g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
92
+ g.dispose();
93
+
94
+ image = resized;
95
+ }
96
+
97
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
98
+ return icon;
99
+ }
38100
39101 // SCRIPT
40102
....@@ -145,7 +207,7 @@
145207
146208 objEditor.ctrlPanel.remove(namePanel);
147209
148
- if (!GroupEditor.allparams)
210
+ if (!allparams)
149211 return;
150212
151213 // objEditor.ctrlPanel.remove(liveCB);
....@@ -168,7 +230,8 @@
168230 // objEditor.ctrlPanel.remove(remarkButton);
169231
170232 objEditor.ctrlPanel.remove(setupPanel);
171
- objEditor.ctrlPanel.remove(commandsPanel);
233
+ objEditor.ctrlPanel.remove(setupPanel2);
234
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
172235 objEditor.ctrlPanel.remove(pushPanel);
173236 //objEditor.ctrlPanel.remove(fillPanel);
174237
....@@ -243,6 +306,7 @@
243306 //localCopy.parent = null;
244307
245308 frame = new JFrame();
309
+ frame.setUndecorated(true);
246310 objEditor = this;
247311 this.callee = callee;
248312
....@@ -273,12 +337,17 @@
273337 return frame.action(event, obj);
274338 }
275339
340
+ // Cannot work without static
341
+ static boolean allparams = true;
342
+
343
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
344
+
276345 void SetupMenu()
277346 {
278347 frame.setMenuBar(menuBar = new MenuBar());
279348 menuBar.add(fileMenu = new Menu("File"));
280349 fileMenu.add(newItem = new MenuItem("New"));
281
- fileMenu.add(loadItem = new MenuItem("Load..."));
350
+ fileMenu.add(loadItem = new MenuItem("Open..."));
282351
283352 //oe.menuBar.add(menu = new Menu("Include"));
284353 Menu menu = new Menu("Import");
....@@ -319,14 +388,52 @@
319388 closeItem.addActionListener(this);
320389
321390 objectPanel = new JTabbedPane();
391
+
392
+ ChangeListener changeListener = new ChangeListener()
393
+ {
394
+ public void stateChanged(ChangeEvent changeEvent)
395
+ {
396
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
397
+// {
398
+// if (latestObject != null)
399
+// {
400
+// refreshContents(true);
401
+// SetMaterial(latestObject);
402
+// }
403
+//
404
+// materialFlushed = true;
405
+// }
406
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
407
+// {
408
+// if (listUI.size() == 0)
409
+// EditSelection(false);
410
+// }
411
+
412
+ refreshContents(false); // To refresh Info tab
413
+ }
414
+ };
415
+ objectPanel.addChangeListener(changeListener);
416
+
322417 toolbarPanel = new JPanel();
323418 toolbarPanel.setName("Toolbar");
324419 treePanel = new cGridBag();
325420 treePanel.setName("Tree");
421
+
422
+ editPanel = new cGridBag().setVertical(true);
423
+ editPanel.setName("Edit");
424
+
326425 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
327
- ctrlPanel.setName("Edit");
426
+
427
+ editCommandsPanel = new cGridBag();
428
+ editPanel.add(editCommandsPanel);
429
+ editPanel.add(ctrlPanel);
430
+
431
+ toolboxPanel = new cGridBag().setVertical(false);
432
+ toolboxPanel.setName("Toolbox");
433
+
328434 materialPanel = new cGridBag().setVertical(true);
329435 materialPanel.setName("Material");
436
+
330437 /*JTextPane*/
331438 infoarea = createTextPane();
332439 doc = infoarea.getStyledDocument();
....@@ -419,10 +526,10 @@
419526 e.printStackTrace();
420527 }
421528
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();
529
+// String selection = infoarea.getText();
530
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
531
+// java.awt.datatransfer.Clipboard clipboard =
532
+// Toolkit.getDefaultToolkit().getSystemClipboard();
426533 //clipboard.setContents(data, data);
427534 }
428535
....@@ -582,20 +689,92 @@
582689 }
583690 }
584691
692
+static GraphicsDevice device = GraphicsEnvironment
693
+ .getLocalGraphicsEnvironment().getScreenDevices()[0];
694
+
695
+ Rectangle keeprect;
696
+ cRadio radio;
697
+
698
+cButton keepButton;
699
+ cButton twoButton; // Full 3D
700
+ cButton sixButton;
701
+ cButton threeButton;
702
+ cButton sevenButton;
703
+ cButton fourButton; // full panel
704
+ cButton oneButton; // full XYZ
705
+ //cButton currentLayout;
706
+
707
+ boolean maximized;
708
+
709
+ cButton fullscreenLayout;
710
+
711
+ void Minimize()
712
+ {
713
+ frame.setState(Frame.ICONIFIED);
714
+ }
715
+
716
+ void Maximize()
717
+ {
718
+ if (maximized)
719
+ {
720
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
721
+ }
722
+ else
723
+ {
724
+ keeprect = frame.getBounds();
725
+ Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
726
+ Dimension rect2 = frame.getToolkit().getScreenSize();
727
+ frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
728
+// frame.setState(Frame.MAXIMIZED_BOTH);
729
+ }
730
+
731
+ maximized ^= true;
732
+ }
733
+
585734 void ToggleFullScreen()
586735 {
587
- if (CameraPane.FULLSCREEN)
736
+ cameraView.ToggleFullScreen();
737
+
738
+ if (!CameraPane.FULLSCREEN)
588739 {
589
- frame.getContentPane().remove(/*"Center",*/bigThree);
590
- framePanel.add(bigThree);
591
- frame.getContentPane().add(/*"Center",*/framePanel);
740
+ device.setFullScreenWindow(null);
741
+ //frame.setVisible(false);
742
+// frame.removeNotify();
743
+// frame.setUndecorated(false);
744
+// frame.addNotify();
745
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
746
+
747
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
748
+// X framePanel.add(bigThree);
749
+// X frame.getContentPane().add(/*"Center",*/framePanel);
750
+ framePanel.setDividerLocation(1);
751
+
752
+ //frame.setVisible(true);
753
+ radio.layout = keepButton;
754
+ //theFrame = null;
755
+ keepButton = null;
756
+ radio.layout.doClick();
757
+
592758 } else
593759 {
594
- frame.getContentPane().remove(/*"Center",*/framePanel);
595
- framePanel.remove(bigThree);
596
- frame.getContentPane().add(/*"Center",*/bigThree);
760
+ keepButton = radio.layout;
761
+ //keeprect = frame.getBounds();
762
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
763
+// frame.getToolkit().getScreenSize().height);
764
+ //frame.setVisible(false);
765
+ device.setFullScreenWindow(frame);
766
+// frame.removeNotify();
767
+// frame.setUndecorated(true);
768
+// frame.addNotify();
769
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
770
+// X framePanel.remove(bigThree);
771
+// X frame.getContentPane().add(/*"Center",*/bigThree);
772
+ framePanel.setDividerLocation(0);
773
+
774
+ radio.layout = fullscreenLayout;
775
+ radio.layout.doClick();
776
+ //frame.setVisible(true);
597777 }
598
- cameraView.ToggleFullScreen();
599778 }
600779
601780 private JTextPane createTextPane()
....@@ -736,7 +915,12 @@
736915 JCheckBox speedupCB;
737916 JCheckBox rewindCB;
738917 JCheckBox flipVCB;
918
+
919
+ cCheckBox toggleTextureCB;
920
+ cCheckBox toggleSwitchCB;
921
+
739922 JComboBox texresMenu;
923
+
740924 JButton resetButton;
741925 JButton stepButton;
742926 JButton stepAllButton;
....@@ -745,9 +929,13 @@
745929 JButton fasterButton;
746930 JButton remarkButton;
747931
932
+ cGridBag editPanel;
933
+ cGridBag editCommandsPanel;
934
+
748935 cGridBag namePanel;
749936 cGridBag setupPanel;
750
- cGridBag commandsPanel;
937
+ cGridBag setupPanel2;
938
+ cGridBag objectCommandsPanel;
751939 cGridBag pushPanel;
752940 cGridBag fillPanel;
753941
....@@ -924,7 +1112,7 @@
9241112
9251113 oe.ctrlPanel.Return();
9261114
927
- if (!GroupEditor.allparams)
1115
+ if (!allparams)
9281116 return;
9291117
9301118 setupPanel = new cGridBag().setVertical(false);
....@@ -939,40 +1127,44 @@
9391127 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
9401128 markCB.setToolTipText("Set the animation target transform");
9411129
942
- rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind);
1130
+ setupPanel2 = new cGridBag().setVertical(false);
1131
+
1132
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
9431133 rewindCB.setToolTipText("Rewind animation");
9441134
945
- randomCB = AddCheckBox(setupPanel, "Random", copy.random);
946
- randomCB.setToolTipText("Option for switch node");
1135
+ randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1136
+ randomCB.setToolTipText("Randomly Rewind or Go back and forth");
9471137
9481138 if (Globals.ADVANCED)
9491139 {
950
- link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master);
1140
+ link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
9511141 link2masterCB.setToolTipText("Attach to support");
952
- speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup);
1142
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
9531143 speedupCB.setToolTipText("Option motion capture");
9541144 }
9551145
9561146 oe.ctrlPanel.add(setupPanel);
9571147 oe.ctrlPanel.Return();
1148
+ oe.ctrlPanel.add(setupPanel2);
1149
+ oe.ctrlPanel.Return();
9581150
959
- commandsPanel = new cGridBag().setVertical(false);
1151
+ objectCommandsPanel = new cGridBag().setVertical(false);
9601152
961
- resetButton = AddButton(commandsPanel, "Reset");
1153
+ resetButton = AddButton(objectCommandsPanel, "Reset");
9621154 resetButton.setToolTipText("Jump to frame zero");
963
- stepButton = AddButton(commandsPanel, "Step");
1155
+ stepButton = AddButton(objectCommandsPanel, "Step");
9641156 stepButton.setToolTipText("Step one frame");
9651157 // resetAllButton = AddButton(oe, "Reset All");
9661158 // stepAllButton = AddButton(oe, "Step All");
9671159 // Return();
968
- slowerButton = AddButton(commandsPanel, "Slow");
1160
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
9691161 slowerButton.setToolTipText("Decrease animation speed");
970
- fasterButton = AddButton(commandsPanel, "Fast");
1162
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
9711163 fasterButton.setToolTipText("Increase animation speed");
972
- remarkButton = AddButton(commandsPanel, "Remark");
1164
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
9731165 remarkButton.setToolTipText("Set the current transform as the target");
9741166
975
- oe.ctrlPanel.add(commandsPanel);
1167
+ oe.ctrlPanel.add(objectCommandsPanel);
9761168 oe.ctrlPanel.Return();
9771169
9781170 pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
....@@ -1178,8 +1370,11 @@
11781370 //worldPanel.setName("World");
11791371 centralPanel = new cGridBag();
11801372 centralPanel.preferredWidth = 20;
1181
- timelinePanel = new JPanel(new BorderLayout());
1182
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1373
+
1374
+ if (Globals.ADVANCED)
1375
+ {
1376
+ timelinePanel = new JPanel(new BorderLayout());
1377
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11831378
11841379 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11851380 cameraPanel.setContinuousLayout(true);
....@@ -1188,7 +1383,10 @@
11881383 // cameraPanel.setDividerSize(9);
11891384 cameraPanel.setResizeWeight(1.0);
11901385
1386
+ }
1387
+
11911388 centralPanel.add(cameraView);
1389
+ centralPanel.setFocusable(true);
11921390 //frame.setJMenuBar(timelineMenubar);
11931391 //centralPanel.add(timelinePanel);
11941392
....@@ -1255,8 +1453,9 @@
12551453 // north.setName("Edit");
12561454 // north.add(ctrlPanel, BorderLayout.NORTH);
12571455 // objectPanel.add(north);
1258
- objectPanel.add(ctrlPanel);
1456
+ objectPanel.add(editPanel);
12591457 objectPanel.add(infoPanel);
1458
+ objectPanel.add(toolboxPanel);
12601459
12611460 /*
12621461 aConstraints.gridx = 0;
....@@ -1265,7 +1464,7 @@
12651464 aConstraints.gridy += 1;
12661465 aConstraints.gridwidth = 1;
12671466 mainPanel.add(objectPanel, aConstraints);
1268
- */
1467
+ */
12691468
12701469 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12711470 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1282,9 +1481,7 @@
12821481 JTabbedPane tabbedPane = new JTabbedPane();
12831482 tabbedPane.add(scrollpane);
12841483
1285
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1286
-
1287
- optionsPanel = new cGridBag().setVertical(true);
1484
+ optionsPanel = new cGridBag().setVertical(false);
12881485
12891486 optionsPanel.setName("Options");
12901487
....@@ -1292,6 +1489,8 @@
12921489
12931490 tabbedPane.add(optionsPanel);
12941491
1492
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1493
+
12951494 scenePanel.add(tabbedPane);
12961495
12971496 /*
....@@ -1384,8 +1583,12 @@
13841583 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13851584
13861585 frame.setSize(1280, 860);
1586
+
1587
+ frame.validate();
13871588 frame.setVisible(true);
13881589
1590
+ cameraView.requestFocusInWindow();
1591
+
13891592 gridPanel.setDividerLocation(1.0);
13901593
13911594 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
....@@ -1935,6 +2138,7 @@
19352138 e2.printStackTrace();
19362139 }
19372140 }
2141
+
19382142 LoadJMEThread loadThread;
19392143
19402144 class LoadJMEThread extends Thread
....@@ -1992,6 +2196,7 @@
19922196 //LoadFile0(filename, converter);
19932197 }
19942198 }
2199
+
19952200 LoadOBJThread loadObjThread;
19962201
19972202 class LoadOBJThread extends Thread
....@@ -2070,19 +2275,19 @@
20702275
20712276 void LoadObjFile(String fullname)
20722277 {
2073
- /*
2278
+ System.out.println("Loading " + fullname);
2279
+ /**/
20742280 //lastFilename = fullname;
20752281 if(loadObjThread == null)
20762282 {
2077
- loadObjThread = new LoadOBJThread();
2078
- loadObjThread.start();
2283
+ loadObjThread = new LoadOBJThread();
2284
+ loadObjThread.start();
20792285 }
20802286
20812287 loadObjThread.add(fullname);
2082
- */
2288
+ /**/
20832289
2084
- System.out.println("Loading " + fullname);
2085
- makeSomething(new FileObject(fullname, true), true);
2290
+ //makeSomething(new FileObject(fullname, true), true);
20862291 }
20872292
20882293 void LoadGFDFile(String fullname)
....@@ -2699,6 +2904,8 @@
26992904
27002905 void SetMaterial(Object3D object)
27012906 {
2907
+ latestObject = object;
2908
+
27022909 cMaterial mat = object.material;
27032910
27042911 if (mat == null)
....@@ -2884,7 +3091,7 @@
28843091 cameraView.ToggleDL();
28853092 cameraView.repaint();
28863093 return;
2887
- } else if (event.getSource() == toggleTextureItem)
3094
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
28883095 {
28893096 cameraView.ToggleTexture();
28903097 // june 2013 copy.HardTouch();
....@@ -2923,9 +3130,9 @@
29233130 frame.validate();
29243131
29253132 return;
2926
- } else if (event.getSource() == toggleSwitchItem)
3133
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29273134 {
2928
- cameraView.ToggleRandom();
3135
+ cameraView.ToggleSwitch();
29293136 cameraView.repaint();
29303137 return;
29313138 } else if (event.getSource() == toggleHandleItem)
....@@ -3212,23 +3419,45 @@
32123419 objEditor.refreshContents();
32133420 }
32143421
3215
- Object3D graphs[] = new Object3D[10000];
3216
- int undoindex = 0;
3217
-
3218
- static public Object clone(Object o)
3422
+ static public byte[] Compress(Object3D o)
32193423 {
32203424 try
32213425 {
32223426 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3223
- ObjectOutputStream out = new ObjectOutputStream(baos);
3427
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3428
+ ObjectOutputStream out = new ObjectOutputStream(zstream);
32243429
3430
+ Object3D parent = o.parent;
3431
+ o.parent = null;
3432
+
32253433 out.writeObject(o);
3434
+
3435
+ o.parent = parent;
3436
+
3437
+ out.flush();
32263438
3227
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
3228
- ObjectInputStream in = new ObjectInputStream(bais);
3439
+ zstream.close();
3440
+ out.close();
3441
+
3442
+ return baos.toByteArray();
3443
+ } catch (Exception e)
3444
+ {
3445
+ System.err.println(e);
3446
+ return null;
3447
+ }
3448
+ }
3449
+
3450
+ static public Object Uncompress(byte[] bytes)
3451
+ {
3452
+ System.out.println("#bytes = " + bytes.length);
3453
+ try
3454
+ {
3455
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3456
+ java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3457
+ ObjectInputStream in = new ObjectInputStream(istream);
32293458 Object obj = in.readObject();
32303459 in.close();
3231
- out.close();
3460
+
32323461 return obj;
32333462 } catch (Exception e)
32343463 {
....@@ -3237,24 +3466,85 @@
32373466 }
32383467 }
32393468
3469
+ static public Object clone(Object o)
3470
+ {
3471
+ try
3472
+ {
3473
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3474
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3475
+
3476
+ out.writeObject(o);
3477
+
3478
+ out.flush();
3479
+ out.close();
3480
+
3481
+ byte[] bytes = baos.toByteArray();
3482
+
3483
+ System.out.println("clone = " + bytes.length);
3484
+
3485
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3486
+ ObjectInputStream in = new ObjectInputStream(bais);
3487
+ Object obj = in.readObject();
3488
+ in.close();
3489
+
3490
+ return obj;
3491
+ } catch (Exception e)
3492
+ {
3493
+ System.err.println(e);
3494
+ return null;
3495
+ }
3496
+ }
3497
+
3498
+ cRadio GetCurrentTab()
3499
+ {
3500
+ cRadio ab;
3501
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3502
+ {
3503
+ ab = (cRadio)e.nextElement();
3504
+ if(ab.GetObject() == copy)
3505
+ {
3506
+ return ab;
3507
+ }
3508
+ }
3509
+
3510
+ return null;
3511
+ }
3512
+
3513
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3514
+
32403515 public void Save()
32413516 {
3242
- if (true) return;
3517
+ System.err.println("Save");
3518
+
3519
+ cRadio tab = GetCurrentTab();
3520
+
3521
+ boolean temp = CameraPane.SWITCH;
3522
+ CameraPane.SWITCH = false;
3523
+
3524
+ copy.ExtractBigData(hashtable);
32433525
32443526 //EditorFrame.m_MainFrame.requestFocusInWindow();
3245
- graphs[undoindex++] = (Object3D)clone(copy);
3527
+ tab.graphs[tab.undoindex++] = Compress(copy);
32463528
3247
- for (int i = undoindex; i < graphs.length; i++)
3529
+ copy.RestoreBigData(hashtable);
3530
+
3531
+ CameraPane.SWITCH = temp;
3532
+
3533
+ //assert(hashtable.isEmpty());
3534
+
3535
+ for (int i = tab.undoindex; i < tab.graphs.length; i++)
32483536 {
3249
- graphs[i] = null;
3537
+ tab.graphs[i] = null;
32503538 }
32513539
3540
+ SetUndoStates();
3541
+
32523542 // test save
32533543 if (false)
32543544 {
32553545 try
32563546 {
3257
- FileOutputStream ostream = new FileOutputStream("save" + undoindex);
3547
+ FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
32583548 ObjectOutputStream p = new ObjectOutputStream(ostream);
32593549
32603550 p.writeObject(copy);
....@@ -3269,48 +3559,96 @@
32693559 }
32703560 }
32713561
3562
+ void CopyChanged(Object3D obj)
3563
+ {
3564
+ SetUndoStates();
3565
+
3566
+ boolean temp = CameraPane.SWITCH;
3567
+ CameraPane.SWITCH = false;
3568
+
3569
+ copy.ExtractBigData(hashtable);
3570
+
3571
+ copy.clear();
3572
+
3573
+ for (int i=0; i<obj.Size(); i++)
3574
+ {
3575
+ copy.add(obj.get(i));
3576
+ }
3577
+
3578
+ copy.RestoreBigData(hashtable);
3579
+
3580
+ CameraPane.SWITCH = temp;
3581
+
3582
+ //assert(hashtable.isEmpty());
3583
+
3584
+ copy.Touch();
3585
+
3586
+ ResetModel();
3587
+ copy.HardTouch(); // recompile?
3588
+
3589
+ cRadio ab;
3590
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3591
+ {
3592
+ ab = (cRadio)e.nextElement();
3593
+ Object3D test = copy.GetObject(ab.object.GetUUID());
3594
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
3595
+ if (test != null)
3596
+ {
3597
+ test.editWindow = ab.object.editWindow;
3598
+ ab.object = test;
3599
+ }
3600
+ }
3601
+
3602
+ refreshContents();
3603
+ }
3604
+
3605
+ cButton undoButton;
3606
+ cButton redoButton;
3607
+
3608
+ void SetUndoStates()
3609
+ {
3610
+ cRadio tab = GetCurrentTab();
3611
+
3612
+ undoButton.setEnabled(tab.undoindex > 0);
3613
+ redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3614
+ }
3615
+
32723616 public void Undo()
32733617 {
3274
- if (undoindex == 0)
3618
+ System.err.println("Undo");
3619
+
3620
+ cRadio tab = GetCurrentTab();
3621
+
3622
+ if (tab.undoindex == 0)
32753623 {
32763624 java.awt.Toolkit.getDefaultToolkit().beep();
32773625 return;
32783626 }
32793627
3280
- if (graphs[undoindex] == null)
3628
+ if (tab.graphs[tab.undoindex] == null)
32813629 {
32823630 Save();
3283
- undoindex -= 1;
3631
+ tab.undoindex -= 1;
32843632 }
32853633
3286
- undoindex -= 1;
3634
+ tab.undoindex -= 1;
32873635
3288
- copy = graphs[undoindex];
3289
-
3290
- cameraView.object = copy;
3291
- copy.Touch();
3292
-
3293
- ResetModel();
3294
- refreshContents();
3636
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
32953637 }
32963638
32973639 public void Redo()
32983640 {
3299
- if (graphs[undoindex + 1] == null)
3641
+ cRadio tab = GetCurrentTab();
3642
+
3643
+ if (tab.graphs[tab.undoindex + 1] == null)
33003644 {
33013645 java.awt.Toolkit.getDefaultToolkit().beep();
33023646 return;
33033647 }
33043648
3305
- undoindex += 1;
3649
+ tab.undoindex += 1;
33063650
3307
- copy = graphs[undoindex];
3308
-
3309
- cameraView.object = copy;
3310
- copy.Touch();
3311
-
3312
- ResetModel();
3313
- refreshContents();
3651
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
33143652 }
33153653
33163654 void ImportGFD()
....@@ -3462,7 +3800,7 @@
34623800 assert false;
34633801 }
34643802
3465
- void EditSelection()
3803
+ void EditSelection(boolean newWindow)
34663804 {
34673805 }
34683806
....@@ -3957,7 +4295,8 @@
39574295
39584296 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
39594297 {
3960
- Save();
4298
+ if (Globals.SAVEONMAKE) // && resetmodel)
4299
+ Save();
39614300 //Tween.set(thing, 0).target(1).start(tweenManager);
39624301 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
39634302 // if (thing instanceof GenericJointDemo)
....@@ -4044,6 +4383,12 @@
40444383 {
40454384 ResetModel();
40464385 Select(thing.GetTreePath(), true, false); // unselect... false);
4386
+
4387
+ if (thing.Size() == 0)
4388
+ {
4389
+ //EditSelection(false);
4390
+ }
4391
+
40474392 refreshContents();
40484393 }
40494394
....@@ -4181,6 +4526,7 @@
41814526
41824527 try
41834528 {
4529
+ // Try compressed version first.
41844530 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
41854531 java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
41864532 java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
....@@ -4250,6 +4596,12 @@
42504596
42514597 void LoadIt(Object obj)
42524598 {
4599
+ if (obj == null)
4600
+ {
4601
+ // Invalid file
4602
+ return;
4603
+ }
4604
+
42534605 System.out.println("Loaded " + obj);
42544606 //new Exception().printStackTrace();
42554607 Object3D readobj = (Object3D) obj;
....@@ -4259,6 +4611,8 @@
42594611
42604612 if (readobj != null)
42614613 {
4614
+ if (Globals.SAVEONMAKE)
4615
+ Save();
42624616 try
42634617 {
42644618 //readobj.deepCopySelf(copy);
....@@ -4436,6 +4790,8 @@
44364790 String filename = browser.getFile();
44374791 if (filename != null && filename.length() > 0)
44384792 {
4793
+ if (!filename.endsWith(".gfd"))
4794
+ filename += ".gfd";
44394795 lastname = browser.getDirectory() + filename;
44404796 save();
44414797 }
....@@ -4629,18 +4985,31 @@
46294985 CheckboxMenuItem togglePaintItem;
46304986 JSplitPane mainPanel;
46314987 JScrollPane scrollpane;
4988
+
46324989 JPanel toolbarPanel;
4990
+
46334991 cGridBag treePanel;
4992
+
46344993 JPanel radioPanel;
46354994 ButtonGroup buttonGroup;
4636
- cGridBag ctrlPanel;
4995
+
4996
+ cGridBag toolboxPanel;
46374997 cGridBag materialPanel;
4998
+ cGridBag ctrlPanel;
4999
+
46385000 JScrollPane infoPanel;
5001
+
46395002 cGridBag optionsPanel;
5003
+
46405004 JTabbedPane objectPanel;
5005
+ boolean materialFlushed;
5006
+ Object3D latestObject;
5007
+
46415008 cGridBag XYZPanel;
5009
+
46425010 JSplitPane gridPanel;
46435011 JSplitPane bigPanel;
5012
+
46445013 cGridBag bigThree;
46455014 cGridBag scenePanel;
46465015 cGridBag centralPanel;
....@@ -4755,7 +5124,7 @@
47555124 cNumberSlider fogField;
47565125 JLabel opacityPowerLabel;
47575126 cNumberSlider opacityPowerField;
4758
- JTree jTree;
5127
+ cTree jTree;
47595128 //ObjectUI parent;
47605129
47615130 cNumberSlider normalpushField;