Normand Briere
2019-06-25 d2f456cf5280f59425084532bd2397ec625f7577
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
....@@ -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
....@@ -278,7 +342,7 @@
278342 frame.setMenuBar(menuBar = new MenuBar());
279343 menuBar.add(fileMenu = new Menu("File"));
280344 fileMenu.add(newItem = new MenuItem("New"));
281
- fileMenu.add(loadItem = new MenuItem("Load..."));
345
+ fileMenu.add(loadItem = new MenuItem("Open..."));
282346
283347 //oe.menuBar.add(menu = new Menu("Include"));
284348 Menu menu = new Menu("Import");
....@@ -319,14 +383,47 @@
319383 closeItem.addActionListener(this);
320384
321385 objectPanel = new JTabbedPane();
386
+
387
+ ChangeListener changeListener = new ChangeListener()
388
+ {
389
+ public void stateChanged(ChangeEvent changeEvent)
390
+ {
391
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
392
+// {
393
+// if (latestObject != null)
394
+// {
395
+// refreshContents(true);
396
+// SetMaterial(latestObject);
397
+// }
398
+//
399
+// materialFlushed = true;
400
+// }
401
+
402
+ refreshContents(false); // To refresh Info tab
403
+ }
404
+ };
405
+ objectPanel.addChangeListener(changeListener);
406
+
322407 toolbarPanel = new JPanel();
323408 toolbarPanel.setName("Toolbar");
324409 treePanel = new cGridBag();
325410 treePanel.setName("Tree");
411
+
412
+ editPanel = new cGridBag().setVertical(true);
413
+ editPanel.setName("Edit");
414
+
326415 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
327
- ctrlPanel.setName("Edit");
416
+
417
+ editCommandsPanel = new cGridBag();
418
+ editPanel.add(editCommandsPanel);
419
+ editPanel.add(ctrlPanel);
420
+
421
+ toolboxPanel = new cGridBag().setVertical(false);
422
+ toolboxPanel.setName("Toolbox");
423
+
328424 materialPanel = new cGridBag().setVertical(true);
329425 materialPanel.setName("Material");
426
+
330427 /*JTextPane*/
331428 infoarea = createTextPane();
332429 doc = infoarea.getStyledDocument();
....@@ -419,10 +516,10 @@
419516 e.printStackTrace();
420517 }
421518
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();
519
+// String selection = infoarea.getText();
520
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
521
+// java.awt.datatransfer.Clipboard clipboard =
522
+// Toolkit.getDefaultToolkit().getSystemClipboard();
426523 //clipboard.setContents(data, data);
427524 }
428525
....@@ -582,19 +679,91 @@
582679 }
583680 }
584681
682
+static GraphicsDevice device = GraphicsEnvironment
683
+ .getLocalGraphicsEnvironment().getScreenDevices()[0];
684
+
685
+ Rectangle keeprect;
686
+ cRadio radio;
687
+
688
+cButton keepButton;
689
+ cButton twoButton; // Full 3D
690
+ cButton sixButton;
691
+ cButton threeButton;
692
+ cButton sevenButton;
693
+ cButton fourButton; // full panel
694
+ cButton oneButton; // full XYZ
695
+ //cButton currentLayout;
696
+
697
+ boolean maximized;
698
+
699
+ cButton fullscreenLayout;
700
+
701
+ void Minimize()
702
+ {
703
+ frame.setState(Frame.ICONIFIED);
704
+ }
705
+
706
+ void Maximize()
707
+ {
708
+ if (maximized)
709
+ {
710
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
711
+ }
712
+ else
713
+ {
714
+ keeprect = frame.getBounds();
715
+ Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
716
+ Dimension rect2 = frame.getToolkit().getScreenSize();
717
+ frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
718
+// frame.setState(Frame.MAXIMIZED_BOTH);
719
+ }
720
+
721
+ maximized ^= true;
722
+ }
723
+
585724 void ToggleFullScreen()
586725 {
587726 if (CameraPane.FULLSCREEN)
588727 {
589
- frame.getContentPane().remove(/*"Center",*/bigThree);
590
- framePanel.add(bigThree);
591
- frame.getContentPane().add(/*"Center",*/framePanel);
728
+ device.setFullScreenWindow(null);
729
+ //frame.setVisible(false);
730
+// frame.removeNotify();
731
+// frame.setUndecorated(false);
732
+// frame.addNotify();
733
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
734
+
735
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
736
+// X framePanel.add(bigThree);
737
+// X frame.getContentPane().add(/*"Center",*/framePanel);
738
+ framePanel.setDividerLocation(1);
739
+
740
+ //frame.setVisible(true);
741
+ radio.layout = keepButton;
742
+ //theFrame = null;
743
+ keepButton = null;
744
+ radio.layout.doClick();
745
+
592746 } else
593747 {
594
- frame.getContentPane().remove(/*"Center",*/framePanel);
595
- framePanel.remove(bigThree);
596
- frame.getContentPane().add(/*"Center",*/bigThree);
748
+ keepButton = radio.layout;
749
+ //keeprect = frame.getBounds();
750
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
751
+// frame.getToolkit().getScreenSize().height);
752
+ //frame.setVisible(false);
753
+ device.setFullScreenWindow(frame);
754
+// frame.removeNotify();
755
+// frame.setUndecorated(true);
756
+// frame.addNotify();
757
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
758
+// X framePanel.remove(bigThree);
759
+// X frame.getContentPane().add(/*"Center",*/bigThree);
760
+ framePanel.setDividerLocation(0);
761
+
762
+ radio.layout = fullscreenLayout;
763
+ radio.layout.doClick();
764
+ //frame.setVisible(true);
597765 }
766
+
598767 cameraView.ToggleFullScreen();
599768 }
600769
....@@ -736,7 +905,12 @@
736905 JCheckBox speedupCB;
737906 JCheckBox rewindCB;
738907 JCheckBox flipVCB;
908
+
909
+ cCheckBox toggleTextureCB;
910
+ cCheckBox toggleSwitchCB;
911
+
739912 JComboBox texresMenu;
913
+
740914 JButton resetButton;
741915 JButton stepButton;
742916 JButton stepAllButton;
....@@ -745,9 +919,13 @@
745919 JButton fasterButton;
746920 JButton remarkButton;
747921
922
+ cGridBag editPanel;
923
+ cGridBag editCommandsPanel;
924
+
748925 cGridBag namePanel;
749926 cGridBag setupPanel;
750
- cGridBag commandsPanel;
927
+ cGridBag setupPanel2;
928
+ cGridBag objectCommandsPanel;
751929 cGridBag pushPanel;
752930 cGridBag fillPanel;
753931
....@@ -939,40 +1117,44 @@
9391117 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
9401118 markCB.setToolTipText("Set the animation target transform");
9411119
942
- rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind);
1120
+ setupPanel2 = new cGridBag().setVertical(false);
1121
+
1122
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
9431123 rewindCB.setToolTipText("Rewind animation");
9441124
945
- randomCB = AddCheckBox(setupPanel, "Random", copy.random);
946
- randomCB.setToolTipText("Option for switch node");
1125
+ randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1126
+ randomCB.setToolTipText("Randomly Rewind or Go back and forth");
9471127
9481128 if (Globals.ADVANCED)
9491129 {
950
- link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master);
1130
+ link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
9511131 link2masterCB.setToolTipText("Attach to support");
952
- speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup);
1132
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
9531133 speedupCB.setToolTipText("Option motion capture");
9541134 }
9551135
9561136 oe.ctrlPanel.add(setupPanel);
9571137 oe.ctrlPanel.Return();
1138
+ oe.ctrlPanel.add(setupPanel2);
1139
+ oe.ctrlPanel.Return();
9581140
959
- commandsPanel = new cGridBag().setVertical(false);
1141
+ objectCommandsPanel = new cGridBag().setVertical(false);
9601142
961
- resetButton = AddButton(commandsPanel, "Reset");
1143
+ resetButton = AddButton(objectCommandsPanel, "Reset");
9621144 resetButton.setToolTipText("Jump to frame zero");
963
- stepButton = AddButton(commandsPanel, "Step");
1145
+ stepButton = AddButton(objectCommandsPanel, "Step");
9641146 stepButton.setToolTipText("Step one frame");
9651147 // resetAllButton = AddButton(oe, "Reset All");
9661148 // stepAllButton = AddButton(oe, "Step All");
9671149 // Return();
968
- slowerButton = AddButton(commandsPanel, "Slow");
1150
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
9691151 slowerButton.setToolTipText("Decrease animation speed");
970
- fasterButton = AddButton(commandsPanel, "Fast");
1152
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
9711153 fasterButton.setToolTipText("Increase animation speed");
972
- remarkButton = AddButton(commandsPanel, "Remark");
1154
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
9731155 remarkButton.setToolTipText("Set the current transform as the target");
9741156
975
- oe.ctrlPanel.add(commandsPanel);
1157
+ oe.ctrlPanel.add(objectCommandsPanel);
9761158 oe.ctrlPanel.Return();
9771159
9781160 pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
....@@ -1178,8 +1360,11 @@
11781360 //worldPanel.setName("World");
11791361 centralPanel = new cGridBag();
11801362 centralPanel.preferredWidth = 20;
1181
- timelinePanel = new JPanel(new BorderLayout());
1182
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1363
+
1364
+ if (Globals.ADVANCED)
1365
+ {
1366
+ timelinePanel = new JPanel(new BorderLayout());
1367
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11831368
11841369 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11851370 cameraPanel.setContinuousLayout(true);
....@@ -1188,7 +1373,10 @@
11881373 // cameraPanel.setDividerSize(9);
11891374 cameraPanel.setResizeWeight(1.0);
11901375
1376
+ }
1377
+
11911378 centralPanel.add(cameraView);
1379
+ centralPanel.setFocusable(true);
11921380 //frame.setJMenuBar(timelineMenubar);
11931381 //centralPanel.add(timelinePanel);
11941382
....@@ -1251,11 +1439,12 @@
12511439 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
12521440 //tmp.setName("Edit");
12531441 objectPanel.add(materialPanel);
1442
+ objectPanel.add(toolboxPanel);
12541443 // JPanel north = new JPanel(new BorderLayout());
12551444 // north.setName("Edit");
12561445 // north.add(ctrlPanel, BorderLayout.NORTH);
12571446 // objectPanel.add(north);
1258
- objectPanel.add(ctrlPanel);
1447
+ objectPanel.add(editPanel);
12591448 objectPanel.add(infoPanel);
12601449
12611450 /*
....@@ -1282,9 +1471,7 @@
12821471 JTabbedPane tabbedPane = new JTabbedPane();
12831472 tabbedPane.add(scrollpane);
12841473
1285
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1286
-
1287
- optionsPanel = new cGridBag().setVertical(true);
1474
+ optionsPanel = new cGridBag().setVertical(false);
12881475
12891476 optionsPanel.setName("Options");
12901477
....@@ -1292,6 +1479,8 @@
12921479
12931480 tabbedPane.add(optionsPanel);
12941481
1482
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1483
+
12951484 scenePanel.add(tabbedPane);
12961485
12971486 /*
....@@ -1384,8 +1573,12 @@
13841573 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13851574
13861575 frame.setSize(1280, 860);
1576
+
1577
+ frame.validate();
13871578 frame.setVisible(true);
13881579
1580
+ cameraView.requestFocusInWindow();
1581
+
13891582 gridPanel.setDividerLocation(1.0);
13901583
13911584 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
....@@ -1935,6 +2128,7 @@
19352128 e2.printStackTrace();
19362129 }
19372130 }
2131
+
19382132 LoadJMEThread loadThread;
19392133
19402134 class LoadJMEThread extends Thread
....@@ -1992,6 +2186,7 @@
19922186 //LoadFile0(filename, converter);
19932187 }
19942188 }
2189
+
19952190 LoadOBJThread loadObjThread;
19962191
19972192 class LoadOBJThread extends Thread
....@@ -2070,19 +2265,19 @@
20702265
20712266 void LoadObjFile(String fullname)
20722267 {
2073
- /*
2268
+ System.out.println("Loading " + fullname);
2269
+ /**/
20742270 //lastFilename = fullname;
20752271 if(loadObjThread == null)
20762272 {
2077
- loadObjThread = new LoadOBJThread();
2078
- loadObjThread.start();
2273
+ loadObjThread = new LoadOBJThread();
2274
+ loadObjThread.start();
20792275 }
20802276
20812277 loadObjThread.add(fullname);
2082
- */
2278
+ /**/
20832279
2084
- System.out.println("Loading " + fullname);
2085
- makeSomething(new FileObject(fullname, true), true);
2280
+ //makeSomething(new FileObject(fullname, true), true);
20862281 }
20872282
20882283 void LoadGFDFile(String fullname)
....@@ -2699,6 +2894,8 @@
26992894
27002895 void SetMaterial(Object3D object)
27012896 {
2897
+ latestObject = object;
2898
+
27022899 cMaterial mat = object.material;
27032900
27042901 if (mat == null)
....@@ -2884,7 +3081,7 @@
28843081 cameraView.ToggleDL();
28853082 cameraView.repaint();
28863083 return;
2887
- } else if (event.getSource() == toggleTextureItem)
3084
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
28883085 {
28893086 cameraView.ToggleTexture();
28903087 // june 2013 copy.HardTouch();
....@@ -2923,9 +3120,9 @@
29233120 frame.validate();
29243121
29253122 return;
2926
- } else if (event.getSource() == toggleSwitchItem)
3123
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29273124 {
2928
- cameraView.ToggleRandom();
3125
+ cameraView.ToggleSwitch();
29293126 cameraView.repaint();
29303127 return;
29313128 } else if (event.getSource() == toggleHandleItem)
....@@ -3212,23 +3409,45 @@
32123409 objEditor.refreshContents();
32133410 }
32143411
3215
- Object3D graphs[] = new Object3D[10000];
3216
- int undoindex = 0;
3217
-
3218
- static public Object clone(Object o)
3412
+ static public byte[] Compress(Object3D o)
32193413 {
32203414 try
32213415 {
32223416 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3223
- ObjectOutputStream out = new ObjectOutputStream(baos);
3417
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3418
+ ObjectOutputStream out = new ObjectOutputStream(zstream);
32243419
3420
+ Object3D parent = o.parent;
3421
+ o.parent = null;
3422
+
32253423 out.writeObject(o);
3424
+
3425
+ o.parent = parent;
3426
+
3427
+ out.flush();
32263428
3227
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
3228
- ObjectInputStream in = new ObjectInputStream(bais);
3429
+ zstream.close();
3430
+ out.close();
3431
+
3432
+ return baos.toByteArray();
3433
+ } catch (Exception e)
3434
+ {
3435
+ System.err.println(e);
3436
+ return null;
3437
+ }
3438
+ }
3439
+
3440
+ static public Object Uncompress(byte[] bytes)
3441
+ {
3442
+ System.out.println("#bytes = " + bytes.length);
3443
+ try
3444
+ {
3445
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3446
+ java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3447
+ ObjectInputStream in = new ObjectInputStream(istream);
32293448 Object obj = in.readObject();
32303449 in.close();
3231
- out.close();
3450
+
32323451 return obj;
32333452 } catch (Exception e)
32343453 {
....@@ -3237,16 +3456,75 @@
32373456 }
32383457 }
32393458
3459
+ static public Object clone(Object o)
3460
+ {
3461
+ try
3462
+ {
3463
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3464
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3465
+
3466
+ out.writeObject(o);
3467
+
3468
+ out.flush();
3469
+ out.close();
3470
+
3471
+ byte[] bytes = baos.toByteArray();
3472
+
3473
+ System.out.println("clone = " + bytes.length);
3474
+
3475
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3476
+ ObjectInputStream in = new ObjectInputStream(bais);
3477
+ Object obj = in.readObject();
3478
+ in.close();
3479
+
3480
+ return obj;
3481
+ } catch (Exception e)
3482
+ {
3483
+ System.err.println(e);
3484
+ return null;
3485
+ }
3486
+ }
3487
+
3488
+ cRadio GetCurrentTab()
3489
+ {
3490
+ cRadio ab;
3491
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3492
+ {
3493
+ ab = (cRadio)e.nextElement();
3494
+ if(ab.GetObject() == copy)
3495
+ {
3496
+ return ab;
3497
+ }
3498
+ }
3499
+
3500
+ return null;
3501
+ }
3502
+
3503
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3504
+
32403505 public void Save()
32413506 {
3242
- if (true) return;
3507
+ System.err.println("Save");
3508
+
3509
+ cRadio tab = GetCurrentTab();
3510
+
3511
+ boolean temp = CameraPane.SWITCH;
3512
+ CameraPane.SWITCH = false;
3513
+
3514
+ copy.ExtractBigData(hashtable);
32433515
32443516 //EditorFrame.m_MainFrame.requestFocusInWindow();
3245
- graphs[undoindex++] = (Object3D)clone(copy);
3517
+ tab.graphs[tab.undoindex++] = Compress(copy);
32463518
3247
- for (int i = undoindex; i < graphs.length; i++)
3519
+ copy.RestoreBigData(hashtable);
3520
+
3521
+ CameraPane.SWITCH = temp;
3522
+
3523
+ //assert(hashtable.isEmpty());
3524
+
3525
+ for (int i = tab.undoindex; i < tab.graphs.length; i++)
32483526 {
3249
- graphs[i] = null;
3527
+ tab.graphs[i] = null;
32503528 }
32513529
32523530 // test save
....@@ -3254,7 +3532,7 @@
32543532 {
32553533 try
32563534 {
3257
- FileOutputStream ostream = new FileOutputStream("save" + undoindex);
3535
+ FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
32583536 ObjectOutputStream p = new ObjectOutputStream(ostream);
32593537
32603538 p.writeObject(copy);
....@@ -3269,48 +3547,83 @@
32693547 }
32703548 }
32713549
3550
+ void CopyChanged(Object3D obj)
3551
+ {
3552
+ boolean temp = CameraPane.SWITCH;
3553
+ CameraPane.SWITCH = false;
3554
+
3555
+ copy.ExtractBigData(hashtable);
3556
+
3557
+ copy.clear();
3558
+
3559
+ for (int i=0; i<obj.Size(); i++)
3560
+ {
3561
+ copy.add(obj.get(i));
3562
+ }
3563
+
3564
+ copy.RestoreBigData(hashtable);
3565
+
3566
+ CameraPane.SWITCH = temp;
3567
+
3568
+ //assert(hashtable.isEmpty());
3569
+
3570
+ copy.Touch();
3571
+
3572
+ ResetModel();
3573
+ copy.HardTouch(); // recompile?
3574
+
3575
+ cRadio ab;
3576
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3577
+ {
3578
+ ab = (cRadio)e.nextElement();
3579
+ Object3D test = copy.GetObject(ab.object.GetUUID());
3580
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
3581
+ if (test != null)
3582
+ {
3583
+ test.editWindow = ab.object.editWindow;
3584
+ ab.object = test;
3585
+ }
3586
+ }
3587
+
3588
+ refreshContents();
3589
+ }
3590
+
32723591 public void Undo()
32733592 {
3274
- if (undoindex == 0)
3593
+ System.err.println("Undo");
3594
+
3595
+ cRadio tab = GetCurrentTab();
3596
+
3597
+ if (tab.undoindex == 0)
32753598 {
32763599 java.awt.Toolkit.getDefaultToolkit().beep();
32773600 return;
32783601 }
32793602
3280
- if (graphs[undoindex] == null)
3603
+ if (tab.graphs[tab.undoindex] == null)
32813604 {
32823605 Save();
3283
- undoindex -= 1;
3606
+ tab.undoindex -= 1;
32843607 }
32853608
3286
- undoindex -= 1;
3609
+ tab.undoindex -= 1;
32873610
3288
- copy = graphs[undoindex];
3289
-
3290
- cameraView.object = copy;
3291
- copy.Touch();
3292
-
3293
- ResetModel();
3294
- refreshContents();
3611
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
32953612 }
32963613
32973614 public void Redo()
32983615 {
3299
- if (graphs[undoindex + 1] == null)
3616
+ cRadio tab = GetCurrentTab();
3617
+
3618
+ if (tab.graphs[tab.undoindex + 1] == null)
33003619 {
33013620 java.awt.Toolkit.getDefaultToolkit().beep();
33023621 return;
33033622 }
33043623
3305
- undoindex += 1;
3624
+ tab.undoindex += 1;
33063625
3307
- copy = graphs[undoindex];
3308
-
3309
- cameraView.object = copy;
3310
- copy.Touch();
3311
-
3312
- ResetModel();
3313
- refreshContents();
3626
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
33143627 }
33153628
33163629 void ImportGFD()
....@@ -3462,7 +3775,7 @@
34623775 assert false;
34633776 }
34643777
3465
- void EditSelection()
3778
+ void EditSelection(boolean newWindow)
34663779 {
34673780 }
34683781
....@@ -3957,7 +4270,8 @@
39574270
39584271 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
39594272 {
3960
- Save();
4273
+ if (Globals.SAVEONMAKE) // && resetmodel)
4274
+ Save();
39614275 //Tween.set(thing, 0).target(1).start(tweenManager);
39624276 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
39634277 // if (thing instanceof GenericJointDemo)
....@@ -4044,6 +4358,12 @@
40444358 {
40454359 ResetModel();
40464360 Select(thing.GetTreePath(), true, false); // unselect... false);
4361
+
4362
+ if (thing.Size() == 0)
4363
+ {
4364
+ //EditSelection(false);
4365
+ }
4366
+
40474367 refreshContents();
40484368 }
40494369
....@@ -4181,6 +4501,7 @@
41814501
41824502 try
41834503 {
4504
+ // Try compressed version first.
41844505 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
41854506 java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
41864507 java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
....@@ -4250,6 +4571,12 @@
42504571
42514572 void LoadIt(Object obj)
42524573 {
4574
+ if (obj == null)
4575
+ {
4576
+ // Invalid file
4577
+ return;
4578
+ }
4579
+
42534580 System.out.println("Loaded " + obj);
42544581 //new Exception().printStackTrace();
42554582 Object3D readobj = (Object3D) obj;
....@@ -4259,6 +4586,8 @@
42594586
42604587 if (readobj != null)
42614588 {
4589
+ if (Globals.SAVEONMAKE)
4590
+ Save();
42624591 try
42634592 {
42644593 //readobj.deepCopySelf(copy);
....@@ -4629,18 +4958,31 @@
46294958 CheckboxMenuItem togglePaintItem;
46304959 JSplitPane mainPanel;
46314960 JScrollPane scrollpane;
4961
+
46324962 JPanel toolbarPanel;
4963
+
46334964 cGridBag treePanel;
4965
+
46344966 JPanel radioPanel;
46354967 ButtonGroup buttonGroup;
4636
- cGridBag ctrlPanel;
4968
+
4969
+ cGridBag toolboxPanel;
46374970 cGridBag materialPanel;
4971
+ cGridBag ctrlPanel;
4972
+
46384973 JScrollPane infoPanel;
4974
+
46394975 cGridBag optionsPanel;
4976
+
46404977 JTabbedPane objectPanel;
4978
+ boolean materialFlushed;
4979
+ Object3D latestObject;
4980
+
46414981 cGridBag XYZPanel;
4982
+
46424983 JSplitPane gridPanel;
46434984 JSplitPane bigPanel;
4985
+
46444986 cGridBag bigThree;
46454987 cGridBag scenePanel;
46464988 cGridBag centralPanel;
....@@ -4755,7 +5097,7 @@
47555097 cNumberSlider fogField;
47565098 JLabel opacityPowerLabel;
47575099 cNumberSlider opacityPowerField;
4758
- JTree jTree;
5100
+ cTree jTree;
47595101 //ObjectUI parent;
47605102
47615103 cNumberSlider normalpushField;