Normand Briere
2019-08-01 c49ad213b600f844e9070cb09390c3e6d3d13db4
ObjEditor.java
....@@ -41,64 +41,78 @@
4141 JFrame frame;
4242
4343 static ObjEditor theFrame;
44
+
45
+ public cGridBag GetSeparator()
46
+ {
47
+ cGridBag separator = new cGridBag();
48
+ separator.add(new JSeparator());
49
+ separator.preferredHeight = 5;
50
+ return separator;
51
+ }
4452
4553 cButton GetButton(String name, boolean border)
4654 {
47
- try
48
- {
49
- ImageIcon icon = GetIcon(name);
50
- return new cButton(icon, border);
51
- }
52
- catch (Exception e)
53
- {
54
- return new cButton(name, border);
55
- }
55
+ ImageIcon icon = GetIcon(name);
56
+ return new cButton(icon, border);
57
+ }
58
+
59
+ cLabel GetLabel(String name, boolean border)
60
+ {
61
+ //ImageIcon icon = GetIcon(name);
62
+ return new cLabel(GetImage(name), border);
5663 }
5764
5865 cToggleButton GetToggleButton(String name, boolean border)
5966 {
60
- try
61
- {
62
- ImageIcon icon = GetIcon(name);
63
- return new cToggleButton(icon, border);
64
- }
65
- catch (Exception e)
66
- {
67
- return new cToggleButton(name, border);
68
- }
67
+ ImageIcon icon = GetIcon(name);
68
+ return new cToggleButton(icon, border);
6969 }
7070
7171 cCheckBox GetCheckBox(String name, boolean border)
7272 {
73
+ ImageIcon icon = GetIcon(name);
74
+ return new cCheckBox(icon, border);
75
+ }
76
+
77
+ ImageIcon GetIcon(String name)
78
+ {
7379 try
7480 {
75
- ImageIcon icon = GetIcon(name);
76
- return new cCheckBox(icon, border);
81
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
82
+
83
+// if (image.getWidth() > 48 && image.getHeight() > 48)
84
+// {
85
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
86
+// Graphics2D g = resized.createGraphics();
87
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
88
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
89
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
90
+// g.dispose();
91
+//
92
+// image = resized;
93
+// }
94
+
95
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
96
+ return icon;
7797 }
7898 catch (Exception e)
7999 {
80
- return new cCheckBox(name, border);
100
+ return null;
81101 }
82102 }
83
-
84
- private ImageIcon GetIcon(String name) throws IOException
103
+
104
+ BufferedImage GetImage(String name)
85105 {
86
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
87
-
88
- if (image.getWidth() != 24 && image.getHeight() != 24)
106
+ try
89107 {
90
- BufferedImage resized = new BufferedImage(24, 24, image.getType());
91
- Graphics2D g = resized.createGraphics();
92
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
93
- //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
94
- g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
95
- g.dispose();
96
-
97
- image = resized;
108
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
109
+
110
+ return image;
98111 }
99
-
100
- javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
101
- return icon;
112
+ catch (Exception e)
113
+ {
114
+ return null;
115
+ }
102116 }
103117
104118 // SCRIPT
....@@ -282,6 +296,12 @@
282296 client = inClient;
283297 copy = client;
284298
299
+ if (copy.versions == null)
300
+ {
301
+ copy.versions = new Object3D[100];
302
+ copy.versionindex = -1;
303
+ }
304
+
285305 // "this" is not called: SetupUI2(objEditor);
286306 }
287307
....@@ -295,6 +315,12 @@
295315 client = inClient;
296316 copy = client;
297317
318
+ if (copy.versions == null)
319
+ {
320
+ copy.versions = new Object3D[100];
321
+ copy.versionindex = -1;
322
+ }
323
+
298324 SetupUI2(callee.GetEditor());
299325 }
300326
....@@ -327,6 +353,12 @@
327353 copy = localCopy;
328354 copy.editWindow = this;
329355
356
+ if (copy.versions == null)
357
+ {
358
+// copy.versions = new byte[100][];
359
+// copy.versionindex = -1;
360
+ }
361
+
330362 SetupMenu();
331363
332364 //SetupName(objEditor); // new
....@@ -419,11 +451,12 @@
419451
420452 toolbarPanel = new JPanel();
421453 toolbarPanel.setName("Toolbar");
454
+
422455 treePanel = new cGridBag();
423456 treePanel.setName("Tree");
424457
425458 editPanel = new cGridBag().setVertical(true);
426
- editPanel.setName("Edit");
459
+ //editPanel.setName("Edit");
427460
428461 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
429462
....@@ -431,11 +464,11 @@
431464 editPanel.add(editCommandsPanel);
432465 editPanel.add(ctrlPanel);
433466
434
- toolboxPanel = new cGridBag().setVertical(false);
435
- toolboxPanel.setName("Toolbox");
467
+ toolboxPanel = new cGridBag().setVertical(true);
468
+ //toolboxPanel.setName("Toolbox");
436469
437470 materialPanel = new cGridBag().setVertical(true);
438
- materialPanel.setName("Material");
471
+ //materialPanel.setName("Material");
439472
440473 /*JTextPane*/
441474 infoarea = createTextPane();
....@@ -443,6 +476,7 @@
443476
444477 infoarea.setEditable(true);
445478 SetText();
479
+
446480 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
447481 // infoarea.setOpaque(false);
448482 // //infoarea.setForeground(textcolor);
....@@ -450,7 +484,7 @@
450484 // TEXTAREA infoarea.setWrapStyleWord(true);
451485 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
452486 infoPanel.setPreferredSize(new Dimension(1, 1));
453
- infoPanel.setName("Info");
487
+ //infoPanel.setName("Info");
454488 //infoPanel.setLayout(new BorderLayout());
455489 //infoPanel.add(createTextPane());
456490
....@@ -816,6 +850,29 @@
816850 frame.validate();
817851 }
818852
853
+ private Object3D CompressCopy()
854
+ {
855
+ boolean temp = CameraPane.SWITCH;
856
+ CameraPane.SWITCH = false;
857
+
858
+ copy.ExtractBigData(versiontable);
859
+ // if (copy == client)
860
+
861
+ Object3D versions[] = copy.versions;
862
+ copy.versions = null;
863
+
864
+ //byte[] compress = Compress(copy);
865
+ Object3D compress = (Object3D)Grafreed.clone(copy);
866
+
867
+ copy.versions = versions;
868
+
869
+ copy.RestoreBigData(versiontable);
870
+
871
+ CameraPane.SWITCH = temp;
872
+
873
+ return compress;
874
+ }
875
+
819876 private JTextPane createTextPane()
820877 {
821878 // TEXTAREA String[] initString =
....@@ -946,7 +1003,7 @@
9461003 // NumberSlider vDivsField;
9471004 // JCheckBox endcaps;
9481005 JCheckBox liveCB;
949
- JCheckBox selectCB;
1006
+ JCheckBox selectableCB;
9501007 JCheckBox hideCB;
9511008 JCheckBox link2masterCB;
9521009 JCheckBox markCB;
....@@ -1158,13 +1215,16 @@
11581215
11591216 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11601217 liveCB.setToolTipText("Animate object");
1161
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1162
- selectCB.setToolTipText("Make object selectable");
1218
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1219
+ selectableCB.setToolTipText("Make object selectable");
11631220 // Return();
1221
+
11641222 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11651223 hideCB.setToolTipText("Hide object");
11661224 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
11671225 markCB.setToolTipText("As animation target transform");
1226
+
1227
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11681228
11691229 setupPanel2 = new cGridBag().setVertical(false);
11701230
....@@ -1452,6 +1512,7 @@
14521512 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14531513 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14541514 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1515
+ //XYZPanel.setName("XYZ");
14551516
14561517 /*
14571518 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1489,16 +1550,29 @@
14891550 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14901551 //tmp.setName("Edit");
14911552 objectPanel.add(materialPanel);
1553
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1554
+ objectPanel.setToolTipTextAt(0, "Material panel");
1555
+
14921556 // JPanel north = new JPanel(new BorderLayout());
14931557 // north.setName("Edit");
14941558 // north.add(ctrlPanel, BorderLayout.NORTH);
14951559 // objectPanel.add(north);
14961560 objectPanel.add(editPanel);
1561
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1562
+ objectPanel.setToolTipTextAt(1, "Edit panel");
14971563
14981564 //if (Globals.ADVANCED)
14991565 objectPanel.add(infoPanel);
1566
+ objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1567
+ objectPanel.setToolTipTextAt(2, "Info panel");
1568
+
1569
+ objectPanel.add(XYZPanel);
1570
+ objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1571
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB panel");
15001572
15011573 objectPanel.add(toolboxPanel);
1574
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1575
+ objectPanel.setToolTipTextAt(4, "Objects/backgrounds panel");
15021576
15031577 /*
15041578 aConstraints.gridx = 0;
....@@ -1519,7 +1593,7 @@
15191593 scrollpane.addMouseWheelListener(this); // Default not fast enough
15201594
15211595 /*JTabbedPane*/ scenePanel = new cGridBag();
1522
- scenePanel.preferredWidth = 6;
1596
+ scenePanel.preferredWidth = 5;
15231597
15241598 JTabbedPane tabbedPane = new JTabbedPane();
15251599 tabbedPane.add(scrollpane);
....@@ -1597,7 +1671,7 @@
15971671 bigThree = new cGridBag();
15981672 bigThree.addComponent(scenePanel);
15991673 bigThree.addComponent(centralPanel);
1600
- bigThree.addComponent(XYZPanel);
1674
+ //bigThree.addComponent(XYZPanel);
16011675
16021676 // // SIDE EFFECT!!!
16031677 // aConstraints.gridx = 0;
....@@ -1638,7 +1712,6 @@
16381712 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16391713 frame.addWindowListener(new WindowAdapter()
16401714 {
1641
-
16421715 public void windowClosing(WindowEvent e)
16431716 {
16441717 Close();
....@@ -1700,27 +1773,48 @@
17001773 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17011774
17021775 cGridBag colorSection = new cGridBag().setVertical(true);
1776
+
1777
+ cGridBag huepanel = new cGridBag();
1778
+ cGridBag huelabel = new cGridBag();
1779
+ huelabel.add(GetLabel("icons/hue.png", false));
1780
+ huelabel.preferredWidth = 20;
1781
+ huepanel.add(new cGridBag()); // Label
1782
+ huepanel.add(huelabel); // Field/slider
1783
+
1784
+ huepanel.preferredHeight = 7;
1785
+
1786
+ colorSection.add(huepanel);
17031787
17041788 cGridBag color = new cGridBag();
1705
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1706
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1707
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1789
+
1790
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1791
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1792
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1793
+
17081794 //colorField.preferredWidth = 200;
17091795 colorSection.add(color);
17101796
17111797 cGridBag modulation = new cGridBag();
17121798 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17131799 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1714
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1800
+ modulation.add(modulationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17151801 colorSection.add(modulation);
17161802
1803
+ cGridBag opacity = new cGridBag();
1804
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1805
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1806
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1807
+ colorSection.add(opacity);
1808
+
1809
+ colorSection.add(GetSeparator());
1810
+
17171811 cGridBag texture = new cGridBag();
17181812 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17191813 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17201814 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17211815 colorSection.add(texture);
17221816
1723
- panel.add(new JSeparator());
1817
+ panel.add(GetSeparator());
17241818
17251819 panel.add(colorSection);
17261820
....@@ -1776,7 +1870,7 @@
17761870 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17771871 diffuseSection.add(shadowbias);
17781872
1779
- panel.add(new JSeparator());
1873
+ panel.add(GetSeparator());
17801874
17811875 panel.add(diffuseSection);
17821876
....@@ -1839,7 +1933,7 @@
18391933 specularSection.add(anisoV);
18401934
18411935
1842
- panel.add(new JSeparator());
1936
+ panel.add(GetSeparator());
18431937
18441938 panel.add(specularSection);
18451939
....@@ -1864,12 +1958,6 @@
18641958 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18651959 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18661960 colorSection.add(backlit);
1867
-
1868
- cGridBag opacity = new cGridBag();
1869
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1870
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1871
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1872
- colorSection.add(opacity);
18731961
18741962 //panel.add(new JSeparator());
18751963
....@@ -1915,7 +2003,7 @@
19152003 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19162004 textureSection.add(opacityPower);
19172005
1918
- panel.add(new JSeparator());
2006
+ panel.add(GetSeparator());
19192007
19202008 panel.add(textureSection);
19212009
....@@ -3214,7 +3302,7 @@
32143302 {
32153303 copy.live ^= true;
32163304 return;
3217
- } else if (event.getSource() == selectCB)
3305
+ } else if (event.getSource() == selectableCB)
32183306 {
32193307 copy.dontselect ^= true;
32203308 return;
....@@ -3478,6 +3566,7 @@
34783566
34793567 static public byte[] Compress(Object3D o)
34803568 {
3569
+ // Slower to actually compress.
34813570 try
34823571 {
34833572 ByteArrayOutputStream baos = new ByteArrayOutputStream();
....@@ -3574,11 +3663,11 @@
35743663 return null;
35753664 }
35763665
3577
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35783666
35793667 public void Save()
35803668 {
3581
- Save(true);
3669
+ //Save(true);
3670
+ Replace();
35823671 }
35833672
35843673 private boolean Equal(byte[] compress, byte[] name)
....@@ -3597,49 +3686,43 @@
35973686 return true;
35983687 }
35993688
3689
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3690
+
36003691 public boolean Save(boolean user)
36013692 {
36023693 System.err.println("Save");
36033694
36043695 cRadio tab = GetCurrentTab();
36053696
3606
- boolean temp = CameraPane.SWITCH;
3607
- CameraPane.SWITCH = false;
3608
-
3609
- copy.ExtractBigData(hashtable);
3610
-
3611
- byte[] compress = Compress(copy);
3612
-
3613
- CameraPane.SWITCH = temp;
3697
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace".
36143698
36153699 boolean thesame = false;
36163700
3617
- // Quick heuristic using length. Works only when stream is compressed.
3618
- if (tab.undoindex > 0 && tab.graphs[tab.undoindex-1] != null && Equal(compress, tab.graphs[tab.undoindex-1]))
3619
- {
3620
- thesame = true;
3621
- }
3701
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3702
+// {
3703
+// thesame = true;
3704
+// }
36223705
36233706 //EditorFrame.m_MainFrame.requestFocusInWindow();
36243707 if (!thesame)
36253708 {
3626
- //tab.user[tab.undoindex] = user;
3627
- boolean increment = tab.graphs[tab.undoindex] == null;
3709
+ //tab.user[tab.versionindex] = user;
3710
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
36283711
3629
- tab.graphs[tab.undoindex] = compress;
3712
+ copy.versions[++copy.versionindex] = compress;
36303713
3631
- if (increment)
3632
- tab.undoindex++;
3714
+ // if (increment)
3715
+ // tab.versionindex++;
36333716 }
36343717
3635
- copy.RestoreBigData(hashtable);
3718
+ //copy.RestoreBigData(versiontable);
36363719
36373720 //assert(hashtable.isEmpty());
36383721
3639
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3722
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
36403723 {
36413724 //tab.user[i] = false;
3642
- // tab.graphs[i] = null;
3725
+ copy.versions[i] = null;
36433726 }
36443727
36453728 SetUndoStates();
....@@ -3649,7 +3732,7 @@
36493732 {
36503733 try
36513734 {
3652
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3735
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
36533736 ObjectOutputStream p = new ObjectOutputStream(ostream);
36543737
36553738 p.writeObject(copy);
....@@ -3673,16 +3756,19 @@
36733756 boolean temp = CameraPane.SWITCH;
36743757 CameraPane.SWITCH = false;
36753758
3676
- copy.ExtractBigData(hashtable);
3759
+ copy.ExtractBigData(versiontable);
36773760
36783761 copy.clear();
36793762
3763
+ copy.skyboxname = obj.skyboxname;
3764
+ copy.skyboxext = obj.skyboxext;
3765
+
36803766 for (int i=0; i<obj.Size(); i++)
36813767 {
36823768 copy.add(obj.get(i));
36833769 }
36843770
3685
- copy.RestoreBigData(hashtable);
3771
+ copy.RestoreBigData(versiontable);
36863772
36873773 CameraPane.SWITCH = temp;
36883774
....@@ -3710,64 +3796,130 @@
37103796 }
37113797
37123798 cButton undoButton;
3799
+ cButton restoreButton;
3800
+ cButton replaceButton;
37133801 cButton redoButton;
37143802
3803
+ boolean muteSlider;
3804
+
3805
+ int VersionCount()
3806
+ {
3807
+ int count = 0;
3808
+
3809
+ for (int i = copy.versions.length; --i >= 0;)
3810
+ {
3811
+ if (copy.versions[i] != null)
3812
+ count++;
3813
+ }
3814
+
3815
+ return count;
3816
+ }
3817
+
37153818 void SetUndoStates()
37163819 {
37173820 cRadio tab = GetCurrentTab();
37183821
3719
- undoButton.setEnabled(tab.undoindex > 0);
3720
- redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3822
+ restoreButton.setEnabled(copy.versionindex != -1);
3823
+ replaceButton.setEnabled(copy.versionindex != -1);
3824
+
3825
+ undoButton.setEnabled(copy.versionindex > 0);
3826
+ redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
3827
+
3828
+ muteSlider = true;
3829
+ versionSlider.setMaximum(VersionCount() - 1);
3830
+ versionSlider.setInteger(copy.versionindex);
3831
+ muteSlider = false;
37213832 }
37223833
37233834 public boolean Undo()
37243835 {
3836
+ // Option?
3837
+ Replace();
3838
+
37253839 System.err.println("Undo");
37263840
37273841 cRadio tab = GetCurrentTab();
37283842
3729
- if (tab.undoindex == 0)
3843
+ if (copy.versionindex == 0)
37303844 {
37313845 java.awt.Toolkit.getDefaultToolkit().beep();
37323846 return false;
37333847 }
37343848
3735
- if (tab.graphs[tab.undoindex] == null) // || !tab.user[tab.undoindex])
3849
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3850
+// {
3851
+// if (Save(false))
3852
+// tab.versionindex -= 1;
3853
+// else
3854
+// {
3855
+// if (tab.versionindex <= 0)
3856
+// return false;
3857
+// else
3858
+// tab.versionindex -= 1;
3859
+// }
3860
+// }
3861
+
3862
+ copy.versionindex -= 1;
3863
+
3864
+ CopyChanged((Object3D)copy.versions[copy.versionindex]);
3865
+
3866
+ return true;
3867
+ }
3868
+
3869
+ public boolean Restore()
3870
+ {
3871
+ System.err.println("Restore");
3872
+
3873
+ cRadio tab = GetCurrentTab();
3874
+
3875
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
37363876 {
3737
- if (Save(false))
3738
- tab.undoindex -= 1;
3739
- else
3740
- {
3741
- if (tab.undoindex <= 0)
3742
- return false;
3743
- else
3744
- tab.undoindex -= 1;
3745
- }
3877
+ java.awt.Toolkit.getDefaultToolkit().beep();
3878
+ return false;
37463879 }
37473880
3748
- tab.undoindex -= 1;
3881
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3882
+ CopyChanged(copy.versions[copy.versionindex]);
3883
+
3884
+ return true;
3885
+ }
37493886
3750
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3887
+ public boolean Replace()
3888
+ {
3889
+ System.err.println("Replace");
3890
+
3891
+ cRadio tab = GetCurrentTab();
3892
+
3893
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3894
+ {
3895
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
3896
+ return false;
3897
+ }
3898
+
3899
+ copy.versions[copy.versionindex] = CompressCopy();
37513900
37523901 return true;
37533902 }
37543903
37553904 public void Redo()
37563905 {
3906
+ // Option?
3907
+ Replace();
3908
+
37573909 cRadio tab = GetCurrentTab();
37583910
3759
- if (tab.graphs[tab.undoindex + 1] == null)
3911
+ if (copy.versions[copy.versionindex + 1] == null)
37603912 {
37613913 java.awt.Toolkit.getDefaultToolkit().beep();
37623914 return;
37633915 }
37643916
3765
- tab.undoindex += 1;
3917
+ copy.versionindex += 1;
37663918
3767
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3919
+ CopyChanged(copy.versions[copy.versionindex]);
37683920
3769
- //if (!tab.user[tab.undoindex])
3770
- // tab.graphs[tab.undoindex] = null;
3921
+ //if (!tab.user[tab.versionindex])
3922
+ // tab.graphs[tab.versionindex] = null;
37713923 }
37723924
37733925 void ImportGFD()
....@@ -4063,9 +4215,25 @@
40634215 //copy.Touch();
40644216 }
40654217
4218
+ cNumberSlider versionSlider;
4219
+
40664220 public void stateChanged(ChangeEvent e)
40674221 {
40684222 // assert(false);
4223
+ if (e.getSource() == versionSlider)
4224
+ {
4225
+ if (muteSlider)
4226
+ return;
4227
+
4228
+ int version = versionSlider.getInteger();
4229
+
4230
+ if (copy.versions[version] != null)
4231
+ {
4232
+ CopyChanged(copy.versions[copy.versionindex = version]);
4233
+ }
4234
+
4235
+ return;
4236
+ }
40694237
40704238 if (freezematerial)
40714239 {
....@@ -4414,7 +4582,7 @@
44144582
44154583 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
44164584 {
4417
- if (Globals.SAVEONMAKE) // && resetmodel)
4585
+ if (Globals.REPLACEONMAKE) // && resetmodel)
44184586 Save();
44194587 //Tween.set(thing, 0).target(1).start(tweenManager);
44204588 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4656,7 +4824,9 @@
46564824 readobj.ResetDisplayList();
46574825 } catch (Exception e)
46584826 {
4659
- //e.printStackTrace();
4827
+ if (!e.toString().contains("GZIP"))
4828
+ e.printStackTrace();
4829
+
46604830 try
46614831 {
46624832 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4736,6 +4906,8 @@
47364906 {
47374907 //readobj.deepCopySelf(copy);
47384908 copy.clear(); // june 2014
4909
+ copy.skyboxname = readobj.skyboxname;
4910
+ copy.skyboxext = readobj.skyboxext;
47394911 for (int i = 0; i < readobj.size(); i++)
47404912 {
47414913 Object3D child = readobj.get(i); // reserve(i);
....@@ -4776,6 +4948,7 @@
47764948 }
47774949 } catch (ClassCastException e)
47784950 {
4951
+ e.printStackTrace();
47794952 assert (false);
47804953 Composite c = (Composite) copy;
47814954 c.children.clear();
....@@ -4786,6 +4959,17 @@
47864959 c.addChild(csg);
47874960 }
47884961
4962
+ copy.versions = readobj.versions;
4963
+ copy.versionindex = readobj.versionindex;
4964
+
4965
+ if (copy.versions == null)
4966
+ {
4967
+ copy.versions = new Object3D[100];
4968
+ copy.versionindex = -1;
4969
+ }
4970
+
4971
+ //? SetUndoStates();
4972
+
47894973 ResetModel();
47904974 copy.HardTouch(); // recompile?
47914975 refreshContents();
....@@ -4895,6 +5079,7 @@
48955079 //ps.print(buffer.toString());
48965080 } catch (IOException e)
48975081 {
5082
+ e.printStackTrace();
48985083 }
48995084 }
49005085