.. | .. |
---|
41 | 41 | JFrame frame; |
---|
42 | 42 | |
---|
43 | 43 | 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 | + } |
---|
44 | 52 | |
---|
45 | 53 | cButton GetButton(String name, boolean border) |
---|
46 | 54 | { |
---|
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); |
---|
56 | 63 | } |
---|
57 | 64 | |
---|
58 | 65 | cToggleButton GetToggleButton(String name, boolean border) |
---|
59 | 66 | { |
---|
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); |
---|
69 | 69 | } |
---|
70 | 70 | |
---|
71 | 71 | cCheckBox GetCheckBox(String name, boolean border) |
---|
72 | 72 | { |
---|
| 73 | + ImageIcon icon = GetIcon(name); |
---|
| 74 | + return new cCheckBox(icon, border); |
---|
| 75 | + } |
---|
| 76 | + |
---|
| 77 | + ImageIcon GetIcon(String name) |
---|
| 78 | + { |
---|
73 | 79 | try |
---|
74 | 80 | { |
---|
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; |
---|
77 | 97 | } |
---|
78 | 98 | catch (Exception e) |
---|
79 | 99 | { |
---|
80 | | - return new cCheckBox(name, border); |
---|
| 100 | + return null; |
---|
81 | 101 | } |
---|
82 | 102 | } |
---|
83 | | - |
---|
84 | | - private ImageIcon GetIcon(String name) throws IOException |
---|
| 103 | + |
---|
| 104 | + BufferedImage GetImage(String name) |
---|
85 | 105 | { |
---|
86 | | - BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name)); |
---|
87 | | - |
---|
88 | | - if (image.getWidth() != 24 && image.getHeight() != 24) |
---|
| 106 | + try |
---|
89 | 107 | { |
---|
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; |
---|
98 | 111 | } |
---|
99 | | - |
---|
100 | | - javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image); |
---|
101 | | - return icon; |
---|
| 112 | + catch (Exception e) |
---|
| 113 | + { |
---|
| 114 | + return null; |
---|
| 115 | + } |
---|
102 | 116 | } |
---|
103 | 117 | |
---|
104 | 118 | // SCRIPT |
---|
.. | .. |
---|
282 | 296 | client = inClient; |
---|
283 | 297 | copy = client; |
---|
284 | 298 | |
---|
| 299 | + if (copy.versions == null) |
---|
| 300 | + { |
---|
| 301 | + copy.versions = new Object3D[100]; |
---|
| 302 | + copy.versionindex = -1; |
---|
| 303 | + } |
---|
| 304 | + |
---|
285 | 305 | // "this" is not called: SetupUI2(objEditor); |
---|
286 | 306 | } |
---|
287 | 307 | |
---|
.. | .. |
---|
295 | 315 | client = inClient; |
---|
296 | 316 | copy = client; |
---|
297 | 317 | |
---|
| 318 | + if (copy.versions == null) |
---|
| 319 | + { |
---|
| 320 | + copy.versions = new Object3D[100]; |
---|
| 321 | + copy.versionindex = -1; |
---|
| 322 | + } |
---|
| 323 | + |
---|
298 | 324 | SetupUI2(callee.GetEditor()); |
---|
299 | 325 | } |
---|
300 | 326 | |
---|
.. | .. |
---|
327 | 353 | copy = localCopy; |
---|
328 | 354 | copy.editWindow = this; |
---|
329 | 355 | |
---|
| 356 | + if (copy.versions == null) |
---|
| 357 | + { |
---|
| 358 | +// copy.versions = new byte[100][]; |
---|
| 359 | +// copy.versionindex = -1; |
---|
| 360 | + } |
---|
| 361 | + |
---|
330 | 362 | SetupMenu(); |
---|
331 | 363 | |
---|
332 | 364 | //SetupName(objEditor); // new |
---|
.. | .. |
---|
419 | 451 | |
---|
420 | 452 | toolbarPanel = new JPanel(); |
---|
421 | 453 | toolbarPanel.setName("Toolbar"); |
---|
| 454 | + |
---|
422 | 455 | treePanel = new cGridBag(); |
---|
423 | 456 | treePanel.setName("Tree"); |
---|
424 | 457 | |
---|
425 | 458 | editPanel = new cGridBag().setVertical(true); |
---|
426 | | - editPanel.setName("Edit"); |
---|
| 459 | + //editPanel.setName("Edit"); |
---|
427 | 460 | |
---|
428 | 461 | ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout()); |
---|
429 | 462 | |
---|
.. | .. |
---|
431 | 464 | editPanel.add(editCommandsPanel); |
---|
432 | 465 | editPanel.add(ctrlPanel); |
---|
433 | 466 | |
---|
434 | | - toolboxPanel = new cGridBag().setVertical(false); |
---|
435 | | - toolboxPanel.setName("Toolbox"); |
---|
| 467 | + toolboxPanel = new cGridBag().setVertical(true); |
---|
| 468 | + //toolboxPanel.setName("Toolbox"); |
---|
436 | 469 | |
---|
437 | 470 | materialPanel = new cGridBag().setVertical(true); |
---|
438 | | - materialPanel.setName("Material"); |
---|
| 471 | + //materialPanel.setName("Material"); |
---|
439 | 472 | |
---|
440 | 473 | /*JTextPane*/ |
---|
441 | 474 | infoarea = createTextPane(); |
---|
.. | .. |
---|
443 | 476 | |
---|
444 | 477 | infoarea.setEditable(true); |
---|
445 | 478 | SetText(); |
---|
| 479 | + |
---|
446 | 480 | // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f)); |
---|
447 | 481 | // infoarea.setOpaque(false); |
---|
448 | 482 | // //infoarea.setForeground(textcolor); |
---|
.. | .. |
---|
450 | 484 | // TEXTAREA infoarea.setWrapStyleWord(true); |
---|
451 | 485 | infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED); |
---|
452 | 486 | infoPanel.setPreferredSize(new Dimension(1, 1)); |
---|
453 | | - infoPanel.setName("Info"); |
---|
| 487 | + //infoPanel.setName("Info"); |
---|
454 | 488 | //infoPanel.setLayout(new BorderLayout()); |
---|
455 | 489 | //infoPanel.add(createTextPane()); |
---|
456 | 490 | |
---|
.. | .. |
---|
816 | 850 | frame.validate(); |
---|
817 | 851 | } |
---|
818 | 852 | |
---|
| 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 | + |
---|
819 | 876 | private JTextPane createTextPane() |
---|
820 | 877 | { |
---|
821 | 878 | // TEXTAREA String[] initString = |
---|
.. | .. |
---|
946 | 1003 | // NumberSlider vDivsField; |
---|
947 | 1004 | // JCheckBox endcaps; |
---|
948 | 1005 | JCheckBox liveCB; |
---|
949 | | - JCheckBox selectCB; |
---|
| 1006 | + JCheckBox selectableCB; |
---|
950 | 1007 | JCheckBox hideCB; |
---|
951 | 1008 | JCheckBox link2masterCB; |
---|
952 | 1009 | JCheckBox markCB; |
---|
.. | .. |
---|
1158 | 1215 | |
---|
1159 | 1216 | liveCB = AddCheckBox(setupPanel, "Live", copy.live); |
---|
1160 | 1217 | 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"); |
---|
1163 | 1220 | // Return(); |
---|
| 1221 | + |
---|
1164 | 1222 | hideCB = AddCheckBox(setupPanel, "Hide", copy.hide); |
---|
1165 | 1223 | hideCB.setToolTipText("Hide object"); |
---|
1166 | 1224 | markCB = AddCheckBox(setupPanel, "Mark", copy.marked); |
---|
1167 | 1225 | markCB.setToolTipText("As animation target transform"); |
---|
| 1226 | + |
---|
| 1227 | + ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); |
---|
1168 | 1228 | |
---|
1169 | 1229 | setupPanel2 = new cGridBag().setVertical(false); |
---|
1170 | 1230 | |
---|
.. | .. |
---|
1452 | 1512 | XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll); |
---|
1453 | 1513 | XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll); |
---|
1454 | 1514 | XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll); |
---|
| 1515 | + //XYZPanel.setName("XYZ"); |
---|
1455 | 1516 | |
---|
1456 | 1517 | /* |
---|
1457 | 1518 | gridPanel = new JPanel(); //new BorderLayout()); |
---|
.. | .. |
---|
1489 | 1550 | //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); |
---|
1490 | 1551 | //tmp.setName("Edit"); |
---|
1491 | 1552 | objectPanel.add(materialPanel); |
---|
| 1553 | + objectPanel.setIconAt(0, GetIcon("icons/material.png")); |
---|
| 1554 | + objectPanel.setToolTipTextAt(0, "Material panel"); |
---|
| 1555 | + |
---|
1492 | 1556 | // JPanel north = new JPanel(new BorderLayout()); |
---|
1493 | 1557 | // north.setName("Edit"); |
---|
1494 | 1558 | // north.add(ctrlPanel, BorderLayout.NORTH); |
---|
1495 | 1559 | // objectPanel.add(north); |
---|
1496 | 1560 | objectPanel.add(editPanel); |
---|
| 1561 | + objectPanel.setIconAt(1, GetIcon("icons/write.png")); |
---|
| 1562 | + objectPanel.setToolTipTextAt(1, "Edit panel"); |
---|
1497 | 1563 | |
---|
1498 | 1564 | //if (Globals.ADVANCED) |
---|
1499 | 1565 | 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"); |
---|
1500 | 1572 | |
---|
1501 | 1573 | objectPanel.add(toolboxPanel); |
---|
| 1574 | + objectPanel.setIconAt(4, GetIcon("icons/primitives.png")); |
---|
| 1575 | + objectPanel.setToolTipTextAt(4, "Objects/backgrounds panel"); |
---|
1502 | 1576 | |
---|
1503 | 1577 | /* |
---|
1504 | 1578 | aConstraints.gridx = 0; |
---|
.. | .. |
---|
1519 | 1593 | scrollpane.addMouseWheelListener(this); // Default not fast enough |
---|
1520 | 1594 | |
---|
1521 | 1595 | /*JTabbedPane*/ scenePanel = new cGridBag(); |
---|
1522 | | - scenePanel.preferredWidth = 6; |
---|
| 1596 | + scenePanel.preferredWidth = 5; |
---|
1523 | 1597 | |
---|
1524 | 1598 | JTabbedPane tabbedPane = new JTabbedPane(); |
---|
1525 | 1599 | tabbedPane.add(scrollpane); |
---|
.. | .. |
---|
1597 | 1671 | bigThree = new cGridBag(); |
---|
1598 | 1672 | bigThree.addComponent(scenePanel); |
---|
1599 | 1673 | bigThree.addComponent(centralPanel); |
---|
1600 | | - bigThree.addComponent(XYZPanel); |
---|
| 1674 | + //bigThree.addComponent(XYZPanel); |
---|
1601 | 1675 | |
---|
1602 | 1676 | // // SIDE EFFECT!!! |
---|
1603 | 1677 | // aConstraints.gridx = 0; |
---|
.. | .. |
---|
1638 | 1712 | frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); |
---|
1639 | 1713 | frame.addWindowListener(new WindowAdapter() |
---|
1640 | 1714 | { |
---|
1641 | | - |
---|
1642 | 1715 | public void windowClosing(WindowEvent e) |
---|
1643 | 1716 | { |
---|
1644 | 1717 | Close(); |
---|
.. | .. |
---|
1700 | 1773 | //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints); |
---|
1701 | 1774 | |
---|
1702 | 1775 | 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); |
---|
1703 | 1787 | |
---|
1704 | 1788 | 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 | + |
---|
1708 | 1794 | //colorField.preferredWidth = 200; |
---|
1709 | 1795 | colorSection.add(color); |
---|
1710 | 1796 | |
---|
1711 | 1797 | cGridBag modulation = new cGridBag(); |
---|
1712 | 1798 | modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints); |
---|
1713 | 1799 | 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); |
---|
1715 | 1801 | colorSection.add(modulation); |
---|
1716 | 1802 | |
---|
| 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 | + |
---|
1717 | 1811 | cGridBag texture = new cGridBag(); |
---|
1718 | 1812 | texture.add(textureLabel = new JLabel("Texture")); // , aConstraints); |
---|
1719 | 1813 | textureLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1720 | 1814 | texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1721 | 1815 | colorSection.add(texture); |
---|
1722 | 1816 | |
---|
1723 | | - panel.add(new JSeparator()); |
---|
| 1817 | + panel.add(GetSeparator()); |
---|
1724 | 1818 | |
---|
1725 | 1819 | panel.add(colorSection); |
---|
1726 | 1820 | |
---|
.. | .. |
---|
1776 | 1870 | shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1777 | 1871 | diffuseSection.add(shadowbias); |
---|
1778 | 1872 | |
---|
1779 | | - panel.add(new JSeparator()); |
---|
| 1873 | + panel.add(GetSeparator()); |
---|
1780 | 1874 | |
---|
1781 | 1875 | panel.add(diffuseSection); |
---|
1782 | 1876 | |
---|
.. | .. |
---|
1839 | 1933 | specularSection.add(anisoV); |
---|
1840 | 1934 | |
---|
1841 | 1935 | |
---|
1842 | | - panel.add(new JSeparator()); |
---|
| 1936 | + panel.add(GetSeparator()); |
---|
1843 | 1937 | |
---|
1844 | 1938 | panel.add(specularSection); |
---|
1845 | 1939 | |
---|
.. | .. |
---|
1864 | 1958 | backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1865 | 1959 | backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1866 | 1960 | 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); |
---|
1873 | 1961 | |
---|
1874 | 1962 | //panel.add(new JSeparator()); |
---|
1875 | 1963 | |
---|
.. | .. |
---|
1915 | 2003 | opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints); |
---|
1916 | 2004 | textureSection.add(opacityPower); |
---|
1917 | 2005 | |
---|
1918 | | - panel.add(new JSeparator()); |
---|
| 2006 | + panel.add(GetSeparator()); |
---|
1919 | 2007 | |
---|
1920 | 2008 | panel.add(textureSection); |
---|
1921 | 2009 | |
---|
.. | .. |
---|
3214 | 3302 | { |
---|
3215 | 3303 | copy.live ^= true; |
---|
3216 | 3304 | return; |
---|
3217 | | - } else if (event.getSource() == selectCB) |
---|
| 3305 | + } else if (event.getSource() == selectableCB) |
---|
3218 | 3306 | { |
---|
3219 | 3307 | copy.dontselect ^= true; |
---|
3220 | 3308 | return; |
---|
.. | .. |
---|
3478 | 3566 | |
---|
3479 | 3567 | static public byte[] Compress(Object3D o) |
---|
3480 | 3568 | { |
---|
| 3569 | + // Slower to actually compress. |
---|
3481 | 3570 | try |
---|
3482 | 3571 | { |
---|
3483 | 3572 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
.. | .. |
---|
3574 | 3663 | return null; |
---|
3575 | 3664 | } |
---|
3576 | 3665 | |
---|
3577 | | - java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
3578 | 3666 | |
---|
3579 | 3667 | public void Save() |
---|
3580 | 3668 | { |
---|
3581 | | - Save(true); |
---|
| 3669 | + //Save(true); |
---|
| 3670 | + Replace(); |
---|
3582 | 3671 | } |
---|
3583 | 3672 | |
---|
3584 | 3673 | private boolean Equal(byte[] compress, byte[] name) |
---|
.. | .. |
---|
3597 | 3686 | return true; |
---|
3598 | 3687 | } |
---|
3599 | 3688 | |
---|
| 3689 | + java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
| 3690 | + |
---|
3600 | 3691 | public boolean Save(boolean user) |
---|
3601 | 3692 | { |
---|
3602 | 3693 | System.err.println("Save"); |
---|
3603 | 3694 | |
---|
3604 | 3695 | cRadio tab = GetCurrentTab(); |
---|
3605 | 3696 | |
---|
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". |
---|
3614 | 3698 | |
---|
3615 | 3699 | boolean thesame = false; |
---|
3616 | 3700 | |
---|
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 | +// } |
---|
3622 | 3705 | |
---|
3623 | 3706 | //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3624 | 3707 | if (!thesame) |
---|
3625 | 3708 | { |
---|
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; |
---|
3628 | 3711 | |
---|
3629 | | - tab.graphs[tab.undoindex] = compress; |
---|
| 3712 | + copy.versions[++copy.versionindex] = compress; |
---|
3630 | 3713 | |
---|
3631 | | - if (increment) |
---|
3632 | | - tab.undoindex++; |
---|
| 3714 | + // if (increment) |
---|
| 3715 | + // tab.versionindex++; |
---|
3633 | 3716 | } |
---|
3634 | 3717 | |
---|
3635 | | - copy.RestoreBigData(hashtable); |
---|
| 3718 | + //copy.RestoreBigData(versiontable); |
---|
3636 | 3719 | |
---|
3637 | 3720 | //assert(hashtable.isEmpty()); |
---|
3638 | 3721 | |
---|
3639 | | - for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
| 3722 | + for (int i = copy.versionindex+1; i < copy.versions.length; i++) |
---|
3640 | 3723 | { |
---|
3641 | 3724 | //tab.user[i] = false; |
---|
3642 | | - // tab.graphs[i] = null; |
---|
| 3725 | + copy.versions[i] = null; |
---|
3643 | 3726 | } |
---|
3644 | 3727 | |
---|
3645 | 3728 | SetUndoStates(); |
---|
.. | .. |
---|
3649 | 3732 | { |
---|
3650 | 3733 | try |
---|
3651 | 3734 | { |
---|
3652 | | - FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex); |
---|
| 3735 | + FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex); |
---|
3653 | 3736 | ObjectOutputStream p = new ObjectOutputStream(ostream); |
---|
3654 | 3737 | |
---|
3655 | 3738 | p.writeObject(copy); |
---|
.. | .. |
---|
3673 | 3756 | boolean temp = CameraPane.SWITCH; |
---|
3674 | 3757 | CameraPane.SWITCH = false; |
---|
3675 | 3758 | |
---|
3676 | | - copy.ExtractBigData(hashtable); |
---|
| 3759 | + copy.ExtractBigData(versiontable); |
---|
3677 | 3760 | |
---|
3678 | 3761 | copy.clear(); |
---|
3679 | 3762 | |
---|
| 3763 | + copy.skyboxname = obj.skyboxname; |
---|
| 3764 | + copy.skyboxext = obj.skyboxext; |
---|
| 3765 | + |
---|
3680 | 3766 | for (int i=0; i<obj.Size(); i++) |
---|
3681 | 3767 | { |
---|
3682 | 3768 | copy.add(obj.get(i)); |
---|
3683 | 3769 | } |
---|
3684 | 3770 | |
---|
3685 | | - copy.RestoreBigData(hashtable); |
---|
| 3771 | + copy.RestoreBigData(versiontable); |
---|
3686 | 3772 | |
---|
3687 | 3773 | CameraPane.SWITCH = temp; |
---|
3688 | 3774 | |
---|
.. | .. |
---|
3710 | 3796 | } |
---|
3711 | 3797 | |
---|
3712 | 3798 | cButton undoButton; |
---|
| 3799 | + cButton restoreButton; |
---|
| 3800 | + cButton replaceButton; |
---|
3713 | 3801 | cButton redoButton; |
---|
3714 | 3802 | |
---|
| 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 | + |
---|
3715 | 3818 | void SetUndoStates() |
---|
3716 | 3819 | { |
---|
3717 | 3820 | cRadio tab = GetCurrentTab(); |
---|
3718 | 3821 | |
---|
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; |
---|
3721 | 3832 | } |
---|
3722 | 3833 | |
---|
3723 | 3834 | public boolean Undo() |
---|
3724 | 3835 | { |
---|
| 3836 | + // Option? |
---|
| 3837 | + Replace(); |
---|
| 3838 | + |
---|
3725 | 3839 | System.err.println("Undo"); |
---|
3726 | 3840 | |
---|
3727 | 3841 | cRadio tab = GetCurrentTab(); |
---|
3728 | 3842 | |
---|
3729 | | - if (tab.undoindex == 0) |
---|
| 3843 | + if (copy.versionindex == 0) |
---|
3730 | 3844 | { |
---|
3731 | 3845 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3732 | 3846 | return false; |
---|
3733 | 3847 | } |
---|
3734 | 3848 | |
---|
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) |
---|
3736 | 3876 | { |
---|
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; |
---|
3746 | 3879 | } |
---|
3747 | 3880 | |
---|
3748 | | - tab.undoindex -= 1; |
---|
| 3881 | + //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3882 | + CopyChanged(copy.versions[copy.versionindex]); |
---|
| 3883 | + |
---|
| 3884 | + return true; |
---|
| 3885 | + } |
---|
3749 | 3886 | |
---|
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(); |
---|
3751 | 3900 | |
---|
3752 | 3901 | return true; |
---|
3753 | 3902 | } |
---|
3754 | 3903 | |
---|
3755 | 3904 | public void Redo() |
---|
3756 | 3905 | { |
---|
| 3906 | + // Option? |
---|
| 3907 | + Replace(); |
---|
| 3908 | + |
---|
3757 | 3909 | cRadio tab = GetCurrentTab(); |
---|
3758 | 3910 | |
---|
3759 | | - if (tab.graphs[tab.undoindex + 1] == null) |
---|
| 3911 | + if (copy.versions[copy.versionindex + 1] == null) |
---|
3760 | 3912 | { |
---|
3761 | 3913 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3762 | 3914 | return; |
---|
3763 | 3915 | } |
---|
3764 | 3916 | |
---|
3765 | | - tab.undoindex += 1; |
---|
| 3917 | + copy.versionindex += 1; |
---|
3766 | 3918 | |
---|
3767 | | - CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3919 | + CopyChanged(copy.versions[copy.versionindex]); |
---|
3768 | 3920 | |
---|
3769 | | - //if (!tab.user[tab.undoindex]) |
---|
3770 | | - // tab.graphs[tab.undoindex] = null; |
---|
| 3921 | + //if (!tab.user[tab.versionindex]) |
---|
| 3922 | + // tab.graphs[tab.versionindex] = null; |
---|
3771 | 3923 | } |
---|
3772 | 3924 | |
---|
3773 | 3925 | void ImportGFD() |
---|
.. | .. |
---|
4063 | 4215 | //copy.Touch(); |
---|
4064 | 4216 | } |
---|
4065 | 4217 | |
---|
| 4218 | + cNumberSlider versionSlider; |
---|
| 4219 | + |
---|
4066 | 4220 | public void stateChanged(ChangeEvent e) |
---|
4067 | 4221 | { |
---|
4068 | 4222 | // 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 | + } |
---|
4069 | 4237 | |
---|
4070 | 4238 | if (freezematerial) |
---|
4071 | 4239 | { |
---|
.. | .. |
---|
4414 | 4582 | |
---|
4415 | 4583 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
4416 | 4584 | { |
---|
4417 | | - if (Globals.SAVEONMAKE) // && resetmodel) |
---|
| 4585 | + if (Globals.REPLACEONMAKE) // && resetmodel) |
---|
4418 | 4586 | Save(); |
---|
4419 | 4587 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
4420 | 4588 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
.. | .. |
---|
4656 | 4824 | readobj.ResetDisplayList(); |
---|
4657 | 4825 | } catch (Exception e) |
---|
4658 | 4826 | { |
---|
4659 | | - //e.printStackTrace(); |
---|
| 4827 | + if (!e.toString().contains("GZIP")) |
---|
| 4828 | + e.printStackTrace(); |
---|
| 4829 | + |
---|
4660 | 4830 | try |
---|
4661 | 4831 | { |
---|
4662 | 4832 | java.io.FileInputStream istream = new java.io.FileInputStream(fullname); |
---|
.. | .. |
---|
4736 | 4906 | { |
---|
4737 | 4907 | //readobj.deepCopySelf(copy); |
---|
4738 | 4908 | copy.clear(); // june 2014 |
---|
| 4909 | + copy.skyboxname = readobj.skyboxname; |
---|
| 4910 | + copy.skyboxext = readobj.skyboxext; |
---|
4739 | 4911 | for (int i = 0; i < readobj.size(); i++) |
---|
4740 | 4912 | { |
---|
4741 | 4913 | Object3D child = readobj.get(i); // reserve(i); |
---|
.. | .. |
---|
4776 | 4948 | } |
---|
4777 | 4949 | } catch (ClassCastException e) |
---|
4778 | 4950 | { |
---|
| 4951 | + e.printStackTrace(); |
---|
4779 | 4952 | assert (false); |
---|
4780 | 4953 | Composite c = (Composite) copy; |
---|
4781 | 4954 | c.children.clear(); |
---|
.. | .. |
---|
4786 | 4959 | c.addChild(csg); |
---|
4787 | 4960 | } |
---|
4788 | 4961 | |
---|
| 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 | + |
---|
4789 | 4973 | ResetModel(); |
---|
4790 | 4974 | copy.HardTouch(); // recompile? |
---|
4791 | 4975 | refreshContents(); |
---|
.. | .. |
---|
4895 | 5079 | //ps.print(buffer.toString()); |
---|
4896 | 5080 | } catch (IOException e) |
---|
4897 | 5081 | { |
---|
| 5082 | + e.printStackTrace(); |
---|
4898 | 5083 | } |
---|
4899 | 5084 | } |
---|
4900 | 5085 | |
---|