.. | .. |
---|
15 | 15 | //import javax.swing.plaf.ColorUIResource; |
---|
16 | 16 | //import javax.swing.plaf.metal.DefaultMetalTheme; |
---|
17 | 17 | |
---|
| 18 | +import javax.swing.plaf.basic.BasicSplitPaneDivider; |
---|
| 19 | +import javax.swing.plaf.basic.BasicSplitPaneUI; |
---|
| 20 | + |
---|
18 | 21 | //import javax.media.opengl.GLCanvas; |
---|
19 | 22 | |
---|
20 | 23 | import //weka.core. |
---|
.. | .. |
---|
41 | 44 | |
---|
42 | 45 | cButton GetButton(String name, boolean border) |
---|
43 | 46 | { |
---|
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 | | - } |
---|
| 47 | + ImageIcon icon = GetIcon(name); |
---|
| 48 | + return new cButton(icon, border); |
---|
| 49 | + } |
---|
| 50 | + |
---|
| 51 | + cToggleButton GetToggleButton(String name, boolean border) |
---|
| 52 | + { |
---|
| 53 | + ImageIcon icon = GetIcon(name); |
---|
| 54 | + return new cToggleButton(icon, border); |
---|
53 | 55 | } |
---|
54 | 56 | |
---|
55 | 57 | cCheckBox GetCheckBox(String name, boolean border) |
---|
56 | 58 | { |
---|
| 59 | + ImageIcon icon = GetIcon(name); |
---|
| 60 | + return new cCheckBox(icon, border); |
---|
| 61 | + } |
---|
| 62 | + |
---|
| 63 | + private ImageIcon GetIcon(String name) |
---|
| 64 | + { |
---|
57 | 65 | try |
---|
58 | 66 | { |
---|
59 | | - ImageIcon icon = GetIcon(name); |
---|
60 | | - return new cCheckBox(icon, border); |
---|
| 67 | + BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name)); |
---|
| 68 | + |
---|
| 69 | + if (image.getWidth() != 24 && image.getHeight() != 24) |
---|
| 70 | + { |
---|
| 71 | + BufferedImage resized = new BufferedImage(24, 24, image.getType()); |
---|
| 72 | + Graphics2D g = resized.createGraphics(); |
---|
| 73 | + g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); |
---|
| 74 | + //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
---|
| 75 | + g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null); |
---|
| 76 | + g.dispose(); |
---|
| 77 | + |
---|
| 78 | + image = resized; |
---|
| 79 | + } |
---|
| 80 | + |
---|
| 81 | + javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image); |
---|
| 82 | + return icon; |
---|
61 | 83 | } |
---|
62 | 84 | catch (Exception e) |
---|
63 | 85 | { |
---|
64 | | - return new cCheckBox(name, border); |
---|
| 86 | + return null; |
---|
65 | 87 | } |
---|
66 | | - } |
---|
67 | | - |
---|
68 | | - private ImageIcon GetIcon(String name) throws IOException |
---|
69 | | - { |
---|
70 | | - BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name)); |
---|
71 | | - |
---|
72 | | - if (image.getWidth() != 24 && image.getHeight() != 24) |
---|
73 | | - { |
---|
74 | | - BufferedImage resized = new BufferedImage(24, 24, image.getType()); |
---|
75 | | - Graphics2D g = resized.createGraphics(); |
---|
76 | | - g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); |
---|
77 | | - //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
---|
78 | | - g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null); |
---|
79 | | - g.dispose(); |
---|
80 | | - |
---|
81 | | - image = resized; |
---|
82 | | - } |
---|
83 | | - |
---|
84 | | - javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image); |
---|
85 | | - return icon; |
---|
86 | 88 | } |
---|
87 | 89 | |
---|
88 | 90 | // SCRIPT |
---|
.. | .. |
---|
194 | 196 | |
---|
195 | 197 | objEditor.ctrlPanel.remove(namePanel); |
---|
196 | 198 | |
---|
197 | | - if (!GroupEditor.allparams) |
---|
| 199 | + if (!allparams) |
---|
198 | 200 | return; |
---|
199 | 201 | |
---|
200 | 202 | // objEditor.ctrlPanel.remove(liveCB); |
---|
.. | .. |
---|
266 | 268 | client = inClient; |
---|
267 | 269 | copy = client; |
---|
268 | 270 | |
---|
| 271 | + if (copy.versions == null) |
---|
| 272 | + { |
---|
| 273 | + copy.versions = new byte[100][]; |
---|
| 274 | + copy.versionindex = -1; |
---|
| 275 | + } |
---|
| 276 | + |
---|
269 | 277 | // "this" is not called: SetupUI2(objEditor); |
---|
270 | 278 | } |
---|
271 | 279 | |
---|
.. | .. |
---|
279 | 287 | client = inClient; |
---|
280 | 288 | copy = client; |
---|
281 | 289 | |
---|
| 290 | + if (copy.versions == null) |
---|
| 291 | + { |
---|
| 292 | + copy.versions = new byte[100][]; |
---|
| 293 | + copy.versionindex = -1; |
---|
| 294 | + } |
---|
| 295 | + |
---|
282 | 296 | SetupUI2(callee.GetEditor()); |
---|
283 | 297 | } |
---|
284 | 298 | |
---|
.. | .. |
---|
293 | 307 | //localCopy.parent = null; |
---|
294 | 308 | |
---|
295 | 309 | frame = new JFrame(); |
---|
296 | | - frame.setUndecorated(true); |
---|
| 310 | + frame.setUndecorated(false); |
---|
297 | 311 | objEditor = this; |
---|
298 | 312 | this.callee = callee; |
---|
299 | 313 | |
---|
.. | .. |
---|
311 | 325 | copy = localCopy; |
---|
312 | 326 | copy.editWindow = this; |
---|
313 | 327 | |
---|
| 328 | + if (copy.versions == null) |
---|
| 329 | + { |
---|
| 330 | +// copy.versions = new byte[100][]; |
---|
| 331 | +// copy.versionindex = -1; |
---|
| 332 | + } |
---|
| 333 | + |
---|
314 | 334 | SetupMenu(); |
---|
315 | 335 | |
---|
316 | 336 | //SetupName(objEditor); // new |
---|
.. | .. |
---|
324 | 344 | return frame.action(event, obj); |
---|
325 | 345 | } |
---|
326 | 346 | |
---|
| 347 | + // Cannot work without static |
---|
| 348 | + static boolean allparams = true; |
---|
| 349 | + |
---|
| 350 | + static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>(); |
---|
| 351 | + |
---|
327 | 352 | void SetupMenu() |
---|
328 | 353 | { |
---|
329 | 354 | frame.setMenuBar(menuBar = new MenuBar()); |
---|
330 | 355 | menuBar.add(fileMenu = new Menu("File")); |
---|
331 | 356 | fileMenu.add(newItem = new MenuItem("New")); |
---|
332 | | - fileMenu.add(loadItem = new MenuItem("Open...")); |
---|
| 357 | + fileMenu.add(openItem = new MenuItem("Open...")); |
---|
333 | 358 | |
---|
334 | 359 | //oe.menuBar.add(menu = new Menu("Include")); |
---|
335 | 360 | Menu menu = new Menu("Import"); |
---|
.. | .. |
---|
361 | 386 | } |
---|
362 | 387 | |
---|
363 | 388 | newItem.addActionListener(this); |
---|
364 | | - loadItem.addActionListener(this); |
---|
| 389 | + openItem.addActionListener(this); |
---|
365 | 390 | saveItem.addActionListener(this); |
---|
366 | 391 | saveAsItem.addActionListener(this); |
---|
367 | 392 | exportAsItem.addActionListener(this); |
---|
.. | .. |
---|
370 | 395 | closeItem.addActionListener(this); |
---|
371 | 396 | |
---|
372 | 397 | objectPanel = new JTabbedPane(); |
---|
| 398 | + |
---|
| 399 | + ChangeListener changeListener = new ChangeListener() |
---|
| 400 | + { |
---|
| 401 | + public void stateChanged(ChangeEvent changeEvent) |
---|
| 402 | + { |
---|
| 403 | +// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed) |
---|
| 404 | +// { |
---|
| 405 | +// if (latestObject != null) |
---|
| 406 | +// { |
---|
| 407 | +// refreshContents(true); |
---|
| 408 | +// SetMaterial(latestObject); |
---|
| 409 | +// } |
---|
| 410 | +// |
---|
| 411 | +// materialFlushed = true; |
---|
| 412 | +// } |
---|
| 413 | +// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit")) |
---|
| 414 | +// { |
---|
| 415 | +// if (listUI.size() == 0) |
---|
| 416 | +// EditSelection(false); |
---|
| 417 | +// } |
---|
| 418 | + |
---|
| 419 | + refreshContents(false); // To refresh Info tab |
---|
| 420 | + } |
---|
| 421 | + }; |
---|
| 422 | + objectPanel.addChangeListener(changeListener); |
---|
| 423 | + |
---|
373 | 424 | toolbarPanel = new JPanel(); |
---|
374 | 425 | toolbarPanel.setName("Toolbar"); |
---|
| 426 | + |
---|
375 | 427 | treePanel = new cGridBag(); |
---|
376 | 428 | treePanel.setName("Tree"); |
---|
377 | 429 | |
---|
378 | 430 | editPanel = new cGridBag().setVertical(true); |
---|
379 | | - editPanel.setName("Edit"); |
---|
| 431 | + //editPanel.setName("Edit"); |
---|
380 | 432 | |
---|
381 | 433 | ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout()); |
---|
382 | 434 | |
---|
.. | .. |
---|
384 | 436 | editPanel.add(editCommandsPanel); |
---|
385 | 437 | editPanel.add(ctrlPanel); |
---|
386 | 438 | |
---|
387 | | - materialPanel = new cGridBag().setVertical(true); |
---|
| 439 | + toolboxPanel = new cGridBag().setVertical(false); |
---|
| 440 | + //toolboxPanel.setName("Toolbox"); |
---|
388 | 441 | |
---|
389 | | - materialPanel.setName("Material"); |
---|
| 442 | + materialPanel = new cGridBag().setVertical(true); |
---|
| 443 | + //materialPanel.setName("Material"); |
---|
| 444 | + |
---|
390 | 445 | /*JTextPane*/ |
---|
391 | 446 | infoarea = createTextPane(); |
---|
392 | 447 | doc = infoarea.getStyledDocument(); |
---|
393 | 448 | |
---|
394 | 449 | infoarea.setEditable(true); |
---|
395 | 450 | SetText(); |
---|
| 451 | + |
---|
396 | 452 | // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f)); |
---|
397 | 453 | // infoarea.setOpaque(false); |
---|
398 | 454 | // //infoarea.setForeground(textcolor); |
---|
399 | 455 | // TEXTAREA infoarea.setLineWrap(true); |
---|
400 | 456 | // TEXTAREA infoarea.setWrapStyleWord(true); |
---|
401 | 457 | infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED); |
---|
402 | | - infoPanel.setPreferredSize(new Dimension(50, 200)); |
---|
403 | | - infoPanel.setName("Info"); |
---|
| 458 | + infoPanel.setPreferredSize(new Dimension(1, 1)); |
---|
| 459 | + //infoPanel.setName("Info"); |
---|
404 | 460 | //infoPanel.setLayout(new BorderLayout()); |
---|
405 | 461 | //infoPanel.add(createTextPane()); |
---|
406 | 462 | |
---|
.. | .. |
---|
411 | 467 | mainPanel.setDividerSize(9); |
---|
412 | 468 | mainPanel.setDividerLocation(0.5); //1.0); |
---|
413 | 469 | mainPanel.setResizeWeight(0.5); |
---|
414 | | - |
---|
| 470 | + |
---|
| 471 | +//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5)); |
---|
| 472 | + BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider(); |
---|
| 473 | + divider.setDividerSize(15); |
---|
| 474 | + divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!")); |
---|
| 475 | + |
---|
| 476 | + mainPanel.setUI(new BasicSplitPaneUI()); |
---|
| 477 | + |
---|
415 | 478 | //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5)); |
---|
416 | 479 | //mainPanel.setLayout(new GridBagLayout()); |
---|
417 | 480 | toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); |
---|
.. | .. |
---|
642 | 705 | } |
---|
643 | 706 | } |
---|
644 | 707 | |
---|
645 | | -static GraphicsDevice device = GraphicsEnvironment |
---|
646 | | - .getLocalGraphicsEnvironment().getScreenDevices()[0]; |
---|
| 708 | +//static GraphicsDevice device = GraphicsEnvironment |
---|
| 709 | +// .getLocalGraphicsEnvironment().getScreenDevices()[0]; |
---|
647 | 710 | |
---|
648 | 711 | Rectangle keeprect; |
---|
649 | 712 | cRadio radio; |
---|
.. | .. |
---|
659 | 722 | |
---|
660 | 723 | boolean maximized; |
---|
661 | 724 | |
---|
| 725 | + cButton fullscreenLayout; |
---|
| 726 | + |
---|
662 | 727 | void Minimize() |
---|
663 | 728 | { |
---|
664 | 729 | frame.setState(Frame.ICONIFIED); |
---|
| 730 | + frame.validate(); |
---|
665 | 731 | } |
---|
666 | 732 | |
---|
| 733 | +// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={} |
---|
| 734 | +// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={} |
---|
| 735 | +// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={} |
---|
667 | 736 | void Maximize() |
---|
668 | 737 | { |
---|
| 738 | + if (CameraPane.FULLSCREEN) |
---|
| 739 | + { |
---|
| 740 | + ToggleFullScreen(); |
---|
| 741 | + } |
---|
| 742 | + |
---|
669 | 743 | if (maximized) |
---|
670 | 744 | { |
---|
671 | 745 | frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height); |
---|
.. | .. |
---|
673 | 747 | else |
---|
674 | 748 | { |
---|
675 | 749 | keeprect = frame.getBounds(); |
---|
676 | | - Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); |
---|
677 | | - Dimension rect2 = frame.getToolkit().getScreenSize(); |
---|
678 | | - frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height); |
---|
| 750 | +// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); |
---|
| 751 | +// Dimension rect2 = frame.getToolkit().getScreenSize(); |
---|
| 752 | +// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height); |
---|
679 | 753 | // frame.setState(Frame.MAXIMIZED_BOTH); |
---|
| 754 | + frame.setBounds(frame.getGraphicsConfiguration().getBounds()); |
---|
680 | 755 | } |
---|
681 | 756 | |
---|
682 | 757 | maximized ^= true; |
---|
| 758 | + |
---|
| 759 | + frame.validate(); |
---|
683 | 760 | } |
---|
| 761 | + |
---|
| 762 | + cButton minButton; |
---|
| 763 | + cButton maxButton; |
---|
| 764 | + cButton fullButton; |
---|
684 | 765 | |
---|
685 | 766 | void ToggleFullScreen() |
---|
686 | 767 | { |
---|
687 | | - if (CameraPane.FULLSCREEN) |
---|
| 768 | +GraphicsDevice device = frame.getGraphicsConfiguration().getDevice(); |
---|
| 769 | + |
---|
| 770 | + cameraView.ToggleFullScreen(); |
---|
| 771 | + |
---|
| 772 | + if (!CameraPane.FULLSCREEN) |
---|
688 | 773 | { |
---|
689 | 774 | device.setFullScreenWindow(null); |
---|
| 775 | + frame.dispose(); |
---|
| 776 | + frame.setUndecorated(false); |
---|
| 777 | + frame.validate(); |
---|
| 778 | + frame.setVisible(true); |
---|
| 779 | + |
---|
690 | 780 | //frame.setVisible(false); |
---|
691 | 781 | // frame.removeNotify(); |
---|
692 | 782 | // frame.setUndecorated(false); |
---|
.. | .. |
---|
696 | 786 | // X frame.getContentPane().remove(/*"Center",*/bigThree); |
---|
697 | 787 | // X framePanel.add(bigThree); |
---|
698 | 788 | // X frame.getContentPane().add(/*"Center",*/framePanel); |
---|
699 | | - framePanel.setDividerLocation(1); |
---|
| 789 | + framePanel.setDividerLocation(46); |
---|
700 | 790 | |
---|
701 | 791 | //frame.setVisible(true); |
---|
702 | 792 | radio.layout = keepButton; |
---|
.. | .. |
---|
711 | 801 | // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width, |
---|
712 | 802 | // frame.getToolkit().getScreenSize().height); |
---|
713 | 803 | //frame.setVisible(false); |
---|
| 804 | + |
---|
| 805 | + frame.dispose(); |
---|
| 806 | + frame.setUndecorated(true); |
---|
714 | 807 | device.setFullScreenWindow(frame); |
---|
| 808 | + frame.validate(); |
---|
| 809 | + frame.setVisible(true); |
---|
715 | 810 | // frame.removeNotify(); |
---|
716 | 811 | // frame.setUndecorated(true); |
---|
717 | 812 | // frame.addNotify(); |
---|
.. | .. |
---|
720 | 815 | // X frame.getContentPane().add(/*"Center",*/bigThree); |
---|
721 | 816 | framePanel.setDividerLocation(0); |
---|
722 | 817 | |
---|
723 | | - radio.layout = twoButton; |
---|
| 818 | + radio.layout = fullscreenLayout; |
---|
724 | 819 | radio.layout.doClick(); |
---|
725 | 820 | //frame.setVisible(true); |
---|
726 | 821 | } |
---|
727 | | - |
---|
728 | | - cameraView.ToggleFullScreen(); |
---|
| 822 | + frame.validate(); |
---|
729 | 823 | } |
---|
| 824 | + |
---|
| 825 | + private byte[] CompressCopy() |
---|
| 826 | + { |
---|
| 827 | + boolean temp = CameraPane.SWITCH; |
---|
| 828 | + CameraPane.SWITCH = false; |
---|
| 829 | + |
---|
| 830 | + copy.ExtractBigData(versiontable); |
---|
| 831 | + // if (copy == client) |
---|
| 832 | + |
---|
| 833 | + byte[] versions[] = copy.versions; |
---|
| 834 | + copy.versions = null; |
---|
| 835 | + |
---|
| 836 | + byte[] compress = Compress(copy); |
---|
| 837 | + |
---|
| 838 | + copy.versions = versions; |
---|
| 839 | + |
---|
| 840 | + copy.RestoreBigData(versiontable); |
---|
| 841 | + |
---|
| 842 | + CameraPane.SWITCH = temp; |
---|
| 843 | + |
---|
| 844 | + return compress; |
---|
| 845 | + } |
---|
730 | 846 | |
---|
731 | 847 | private JTextPane createTextPane() |
---|
732 | 848 | { |
---|
.. | .. |
---|
858 | 974 | // NumberSlider vDivsField; |
---|
859 | 975 | // JCheckBox endcaps; |
---|
860 | 976 | JCheckBox liveCB; |
---|
861 | | - JCheckBox selectCB; |
---|
| 977 | + JCheckBox selectableCB; |
---|
862 | 978 | JCheckBox hideCB; |
---|
863 | 979 | JCheckBox link2masterCB; |
---|
864 | 980 | JCheckBox markCB; |
---|
.. | .. |
---|
866 | 982 | JCheckBox speedupCB; |
---|
867 | 983 | JCheckBox rewindCB; |
---|
868 | 984 | JCheckBox flipVCB; |
---|
| 985 | + |
---|
| 986 | + cCheckBox toggleTextureCB; |
---|
| 987 | + cCheckBox toggleSwitchCB; |
---|
| 988 | + |
---|
869 | 989 | JComboBox texresMenu; |
---|
| 990 | + |
---|
870 | 991 | JButton resetButton; |
---|
871 | 992 | JButton stepButton; |
---|
872 | 993 | JButton stepAllButton; |
---|
.. | .. |
---|
1053 | 1174 | namePanel = new cGridBag(); |
---|
1054 | 1175 | |
---|
1055 | 1176 | nameField = AddText(namePanel, copy.GetName()); |
---|
1056 | | - namePanel.add(nameField); |
---|
| 1177 | + namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)); |
---|
1057 | 1178 | oe.ctrlPanel.add(namePanel); |
---|
1058 | 1179 | |
---|
1059 | 1180 | oe.ctrlPanel.Return(); |
---|
1060 | 1181 | |
---|
1061 | | - if (!GroupEditor.allparams) |
---|
| 1182 | + if (!allparams) |
---|
1062 | 1183 | return; |
---|
1063 | 1184 | |
---|
1064 | 1185 | setupPanel = new cGridBag().setVertical(false); |
---|
1065 | 1186 | |
---|
1066 | 1187 | liveCB = AddCheckBox(setupPanel, "Live", copy.live); |
---|
1067 | 1188 | liveCB.setToolTipText("Animate object"); |
---|
1068 | | - selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect); |
---|
1069 | | - selectCB.setToolTipText("Make object selectable"); |
---|
| 1189 | + selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect); |
---|
| 1190 | + selectableCB.setToolTipText("Make object selectable"); |
---|
1070 | 1191 | // Return(); |
---|
| 1192 | + |
---|
1071 | 1193 | hideCB = AddCheckBox(setupPanel, "Hide", copy.hide); |
---|
1072 | 1194 | hideCB.setToolTipText("Hide object"); |
---|
1073 | 1195 | markCB = AddCheckBox(setupPanel, "Mark", copy.marked); |
---|
1074 | | - markCB.setToolTipText("Set the animation target transform"); |
---|
| 1196 | + markCB.setToolTipText("As animation target transform"); |
---|
1075 | 1197 | |
---|
1076 | 1198 | setupPanel2 = new cGridBag().setVertical(false); |
---|
1077 | 1199 | |
---|
1078 | 1200 | rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind); |
---|
1079 | 1201 | rewindCB.setToolTipText("Rewind animation"); |
---|
1080 | 1202 | |
---|
1081 | | - randomCB = AddCheckBox(setupPanel2, "Rand", copy.random); |
---|
1082 | | - randomCB.setToolTipText("Randomly Rewind or Go back and forth"); |
---|
| 1203 | + randomCB = AddCheckBox(setupPanel2, "Random", copy.random); |
---|
| 1204 | + randomCB.setToolTipText("Randomly Rewind (or Go back and forth)"); |
---|
1083 | 1205 | |
---|
| 1206 | + link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master); |
---|
| 1207 | + link2masterCB.setToolTipText("Attach to support"); |
---|
| 1208 | + |
---|
1084 | 1209 | if (Globals.ADVANCED) |
---|
1085 | 1210 | { |
---|
1086 | | - link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master); |
---|
1087 | | - link2masterCB.setToolTipText("Attach to support"); |
---|
1088 | 1211 | speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); |
---|
1089 | 1212 | speedupCB.setToolTipText("Option motion capture"); |
---|
1090 | 1213 | } |
---|
.. | .. |
---|
1358 | 1481 | XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll); |
---|
1359 | 1482 | XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll); |
---|
1360 | 1483 | XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll); |
---|
| 1484 | + //XYZPanel.setName("XYZ"); |
---|
1361 | 1485 | |
---|
1362 | 1486 | /* |
---|
1363 | 1487 | gridPanel = new JPanel(); //new BorderLayout()); |
---|
.. | .. |
---|
1395 | 1519 | //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); |
---|
1396 | 1520 | //tmp.setName("Edit"); |
---|
1397 | 1521 | objectPanel.add(materialPanel); |
---|
| 1522 | + objectPanel.setIconAt(0, GetIcon("icons/material.png")); |
---|
1398 | 1523 | // JPanel north = new JPanel(new BorderLayout()); |
---|
1399 | 1524 | // north.setName("Edit"); |
---|
1400 | 1525 | // north.add(ctrlPanel, BorderLayout.NORTH); |
---|
1401 | 1526 | // objectPanel.add(north); |
---|
1402 | 1527 | objectPanel.add(editPanel); |
---|
1403 | | - objectPanel.add(infoPanel); |
---|
| 1528 | + objectPanel.setIconAt(1, GetIcon("icons/write.png")); |
---|
| 1529 | + |
---|
| 1530 | + //if (Globals.ADVANCED) |
---|
| 1531 | + objectPanel.add(infoPanel); |
---|
| 1532 | + objectPanel.setIconAt(2, GetIcon("icons/info.png")); |
---|
| 1533 | + |
---|
| 1534 | + objectPanel.add(XYZPanel); |
---|
| 1535 | + objectPanel.setIconAt(3, GetIcon("icons/XYZ.png")); |
---|
| 1536 | + |
---|
| 1537 | + objectPanel.add(toolboxPanel); |
---|
| 1538 | + objectPanel.setIconAt(4, GetIcon("icons/primitives.png")); |
---|
1404 | 1539 | |
---|
1405 | 1540 | /* |
---|
1406 | 1541 | aConstraints.gridx = 0; |
---|
.. | .. |
---|
1409 | 1544 | aConstraints.gridy += 1; |
---|
1410 | 1545 | aConstraints.gridwidth = 1; |
---|
1411 | 1546 | mainPanel.add(objectPanel, aConstraints); |
---|
1412 | | - */ |
---|
| 1547 | + */ |
---|
1413 | 1548 | |
---|
1414 | 1549 | scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS, |
---|
1415 | 1550 | VERTICAL_SCROLLBAR_AS_NEEDED, |
---|
.. | .. |
---|
1421 | 1556 | scrollpane.addMouseWheelListener(this); // Default not fast enough |
---|
1422 | 1557 | |
---|
1423 | 1558 | /*JTabbedPane*/ scenePanel = new cGridBag(); |
---|
1424 | | - scenePanel.preferredWidth = 6; |
---|
| 1559 | + scenePanel.preferredWidth = 5; |
---|
1425 | 1560 | |
---|
1426 | 1561 | JTabbedPane tabbedPane = new JTabbedPane(); |
---|
1427 | 1562 | tabbedPane.add(scrollpane); |
---|
1428 | 1563 | |
---|
1429 | | - tabbedPane.add(FSPane = new cFileSystemPane(this)); |
---|
1430 | | - |
---|
1431 | | - optionsPanel = new cGridBag().setVertical(true); |
---|
| 1564 | + optionsPanel = new cGridBag().setVertical(false); |
---|
1432 | 1565 | |
---|
1433 | 1566 | optionsPanel.setName("Options"); |
---|
1434 | 1567 | |
---|
.. | .. |
---|
1436 | 1569 | |
---|
1437 | 1570 | tabbedPane.add(optionsPanel); |
---|
1438 | 1571 | |
---|
| 1572 | + tabbedPane.add(FSPane = new cFileSystemPane(this)); |
---|
| 1573 | + |
---|
1439 | 1574 | scenePanel.add(tabbedPane); |
---|
1440 | 1575 | |
---|
1441 | 1576 | /* |
---|
.. | .. |
---|
1499 | 1634 | bigThree = new cGridBag(); |
---|
1500 | 1635 | bigThree.addComponent(scenePanel); |
---|
1501 | 1636 | bigThree.addComponent(centralPanel); |
---|
1502 | | - bigThree.addComponent(XYZPanel); |
---|
| 1637 | + //bigThree.addComponent(XYZPanel); |
---|
1503 | 1638 | |
---|
1504 | 1639 | // // SIDE EFFECT!!! |
---|
1505 | 1640 | // aConstraints.gridx = 0; |
---|
.. | .. |
---|
1508 | 1643 | // aConstraints.gridheight = 1; |
---|
1509 | 1644 | |
---|
1510 | 1645 | framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree); |
---|
1511 | | - framePanel.setContinuousLayout(true); |
---|
1512 | | - framePanel.setOneTouchExpandable(true); |
---|
1513 | | - framePanel.setDividerLocation(0.8); |
---|
| 1646 | + framePanel.setContinuousLayout(false); |
---|
| 1647 | + framePanel.setOneTouchExpandable(false); |
---|
| 1648 | + //.setDividerLocation(0.8); |
---|
1514 | 1649 | //framePanel.setDividerSize(15); |
---|
1515 | 1650 | //framePanel.setResizeWeight(0.15); |
---|
1516 | 1651 | framePanel.setName("Frame"); |
---|
.. | .. |
---|
1528 | 1663 | // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc); |
---|
1529 | 1664 | |
---|
1530 | 1665 | frame.setSize(1280, 860); |
---|
1531 | | - frame.setVisible(true); |
---|
1532 | | - |
---|
| 1666 | + |
---|
1533 | 1667 | cameraView.requestFocusInWindow(); |
---|
1534 | 1668 | |
---|
1535 | 1669 | gridPanel.setDividerLocation(1.0); |
---|
| 1670 | + |
---|
| 1671 | + frame.validate(); |
---|
| 1672 | + |
---|
| 1673 | + frame.setVisible(true); |
---|
1536 | 1674 | |
---|
1537 | 1675 | frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); |
---|
1538 | 1676 | frame.addWindowListener(new WindowAdapter() |
---|
.. | .. |
---|
1619 | 1757 | texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1620 | 1758 | colorSection.add(texture); |
---|
1621 | 1759 | |
---|
1622 | | - cGridBag anisoU = new cGridBag(); |
---|
1623 | | - anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints); |
---|
1624 | | - anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1625 | | - anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1626 | | - colorSection.add(anisoU); |
---|
1627 | | - |
---|
1628 | | - cGridBag anisoV = new cGridBag(); |
---|
1629 | | - anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints); |
---|
1630 | | - anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1631 | | - anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1632 | | - colorSection.add(anisoV); |
---|
1633 | | - |
---|
1634 | | - cGridBag shadowbias = new cGridBag(); |
---|
1635 | | - shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints); |
---|
1636 | | - shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1637 | | - shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1638 | | - colorSection.add(shadowbias); |
---|
1639 | | - |
---|
1640 | 1760 | panel.add(new JSeparator()); |
---|
1641 | 1761 | |
---|
1642 | 1762 | panel.add(colorSection); |
---|
.. | .. |
---|
1686 | 1806 | fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1687 | 1807 | fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1688 | 1808 | diffuseSection.add(fakedepth); |
---|
| 1809 | + |
---|
| 1810 | + cGridBag shadowbias = new cGridBag(); |
---|
| 1811 | + shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints); |
---|
| 1812 | + shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
| 1813 | + shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
| 1814 | + diffuseSection.add(shadowbias); |
---|
1689 | 1815 | |
---|
1690 | 1816 | panel.add(new JSeparator()); |
---|
1691 | 1817 | |
---|
.. | .. |
---|
1737 | 1863 | // aConstraints.gridy += 1; |
---|
1738 | 1864 | // aConstraints.gridwidth = 1; |
---|
1739 | 1865 | |
---|
| 1866 | + cGridBag anisoU = new cGridBag(); |
---|
| 1867 | + anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints); |
---|
| 1868 | + anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
| 1869 | + anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
| 1870 | + specularSection.add(anisoU); |
---|
| 1871 | + |
---|
| 1872 | + cGridBag anisoV = new cGridBag(); |
---|
| 1873 | + anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints); |
---|
| 1874 | + anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
| 1875 | + anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
| 1876 | + specularSection.add(anisoV); |
---|
| 1877 | + |
---|
1740 | 1878 | |
---|
1741 | 1879 | panel.add(new JSeparator()); |
---|
1742 | 1880 | |
---|
.. | .. |
---|
1744 | 1882 | |
---|
1745 | 1883 | //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints); |
---|
1746 | 1884 | |
---|
1747 | | - cGridBag globalSection = new cGridBag().setVertical(true); |
---|
| 1885 | + //cGridBag globalSection = new cGridBag().setVertical(true); |
---|
1748 | 1886 | |
---|
1749 | 1887 | cGridBag camera = new cGridBag(); |
---|
1750 | 1888 | camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints); |
---|
1751 | 1889 | cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1752 | 1890 | camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1753 | | - globalSection.add(camera); |
---|
| 1891 | + colorSection.add(camera); |
---|
1754 | 1892 | |
---|
1755 | 1893 | cGridBag ambient = new cGridBag(); |
---|
1756 | 1894 | ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints); |
---|
1757 | 1895 | ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1758 | 1896 | ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1759 | | - globalSection.add(ambient); |
---|
| 1897 | + colorSection.add(ambient); |
---|
1760 | 1898 | |
---|
1761 | 1899 | cGridBag backlit = new cGridBag(); |
---|
1762 | 1900 | backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints); |
---|
1763 | 1901 | backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1764 | 1902 | backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1765 | | - globalSection.add(backlit); |
---|
| 1903 | + colorSection.add(backlit); |
---|
1766 | 1904 | |
---|
1767 | 1905 | cGridBag opacity = new cGridBag(); |
---|
1768 | 1906 | opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints); |
---|
1769 | 1907 | opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1770 | 1908 | opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1771 | | - globalSection.add(opacity); |
---|
| 1909 | + colorSection.add(opacity); |
---|
1772 | 1910 | |
---|
1773 | | - panel.add(new JSeparator()); |
---|
| 1911 | + //panel.add(new JSeparator()); |
---|
1774 | 1912 | |
---|
1775 | | - panel.add(globalSection); |
---|
| 1913 | + //panel.add(globalSection); |
---|
1776 | 1914 | |
---|
1777 | 1915 | //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints); |
---|
1778 | 1916 | |
---|
.. | .. |
---|
1879 | 2017 | // 3D models |
---|
1880 | 2018 | if (filename.endsWith(".3ds") || filename.endsWith(".3DS")) |
---|
1881 | 2019 | { |
---|
1882 | | - lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
1883 | | - LoadFile(filename, lastConverter); |
---|
| 2020 | + //lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
| 2021 | + //LoadFile(filename, lastConverter); |
---|
| 2022 | + LoadObjFile(filename); // New 3ds loader |
---|
1884 | 2023 | continue; |
---|
1885 | 2024 | } |
---|
1886 | 2025 | if (filename.endsWith(".dae") || filename.endsWith(".DAE")) |
---|
.. | .. |
---|
2606 | 2745 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2); |
---|
2607 | 2746 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2); |
---|
2608 | 2747 | } |
---|
| 2748 | + |
---|
2609 | 2749 | //cJME.count++; |
---|
2610 | 2750 | //cJME.count %= 12; |
---|
2611 | 2751 | if (gc) |
---|
.. | .. |
---|
2789 | 2929 | } |
---|
2790 | 2930 | } |
---|
2791 | 2931 | } |
---|
| 2932 | + |
---|
2792 | 2933 | cFileSystemPane FSPane; |
---|
2793 | 2934 | |
---|
2794 | 2935 | void SetMaterial(cMaterial mat, Object3D.cVector2[] others) |
---|
.. | .. |
---|
2842 | 2983 | } |
---|
2843 | 2984 | } |
---|
2844 | 2985 | } |
---|
| 2986 | + |
---|
2845 | 2987 | freezematerial = false; |
---|
2846 | 2988 | } |
---|
2847 | 2989 | |
---|
2848 | 2990 | void SetMaterial(Object3D object) |
---|
2849 | 2991 | { |
---|
| 2992 | + latestObject = object; |
---|
| 2993 | + |
---|
2850 | 2994 | cMaterial mat = object.material; |
---|
2851 | 2995 | |
---|
2852 | 2996 | if (mat == null) |
---|
.. | .. |
---|
2958 | 3102 | // } |
---|
2959 | 3103 | |
---|
2960 | 3104 | /**/ |
---|
2961 | | - if (deselect) |
---|
| 3105 | + if (deselect || child == null) |
---|
2962 | 3106 | { |
---|
2963 | 3107 | //group.deselectAll(); |
---|
2964 | 3108 | //freeze = true; |
---|
2965 | 3109 | GetTree().clearSelection(); |
---|
2966 | 3110 | //freeze = false; |
---|
| 3111 | + |
---|
| 3112 | + if (child == null) |
---|
| 3113 | + { |
---|
| 3114 | + return; |
---|
| 3115 | + } |
---|
2967 | 3116 | } |
---|
2968 | 3117 | |
---|
2969 | 3118 | //group.addSelectee(child); |
---|
.. | .. |
---|
3032 | 3181 | cameraView.ToggleDL(); |
---|
3033 | 3182 | cameraView.repaint(); |
---|
3034 | 3183 | return; |
---|
3035 | | - } else if (event.getSource() == toggleTextureItem) |
---|
| 3184 | + } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB) |
---|
3036 | 3185 | { |
---|
3037 | 3186 | cameraView.ToggleTexture(); |
---|
3038 | 3187 | // june 2013 copy.HardTouch(); |
---|
.. | .. |
---|
3071 | 3220 | frame.validate(); |
---|
3072 | 3221 | |
---|
3073 | 3222 | return; |
---|
3074 | | - } else if (event.getSource() == toggleSwitchItem) |
---|
| 3223 | + } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB) |
---|
3075 | 3224 | { |
---|
3076 | 3225 | cameraView.ToggleSwitch(); |
---|
3077 | 3226 | cameraView.repaint(); |
---|
.. | .. |
---|
3102 | 3251 | { |
---|
3103 | 3252 | copy.live ^= true; |
---|
3104 | 3253 | return; |
---|
3105 | | - } else if (event.getSource() == selectCB) |
---|
| 3254 | + } else if (event.getSource() == selectableCB) |
---|
3106 | 3255 | { |
---|
3107 | 3256 | copy.dontselect ^= true; |
---|
3108 | 3257 | return; |
---|
.. | .. |
---|
3287 | 3436 | { |
---|
3288 | 3437 | Close(); |
---|
3289 | 3438 | //return true; |
---|
3290 | | - } else if (source == loadItem) |
---|
| 3439 | + } else if (source == openItem) |
---|
3291 | 3440 | { |
---|
3292 | | - load(); |
---|
| 3441 | + Open(); |
---|
3293 | 3442 | //return true; |
---|
3294 | 3443 | } else if (source == newItem) |
---|
3295 | 3444 | { |
---|
.. | .. |
---|
3314 | 3463 | { |
---|
3315 | 3464 | generatePOV(); |
---|
3316 | 3465 | //return true; |
---|
| 3466 | + } else if (event.getSource() == archiveItem) |
---|
| 3467 | + { |
---|
| 3468 | + cTools.Archive(frame); |
---|
| 3469 | + return; |
---|
3317 | 3470 | } else if (source == zBufferItem) |
---|
3318 | 3471 | { |
---|
3319 | 3472 | try |
---|
.. | .. |
---|
3365 | 3518 | try |
---|
3366 | 3519 | { |
---|
3367 | 3520 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
3368 | | - java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
3369 | | - ObjectOutputStream out = new ObjectOutputStream(zstream); |
---|
| 3521 | +// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3522 | + ObjectOutputStream out = new ObjectOutputStream(baos); //zstream); |
---|
3370 | 3523 | |
---|
3371 | 3524 | Object3D parent = o.parent; |
---|
3372 | 3525 | o.parent = null; |
---|
.. | .. |
---|
3377 | 3530 | |
---|
3378 | 3531 | out.flush(); |
---|
3379 | 3532 | |
---|
3380 | | - zstream.close(); |
---|
| 3533 | + baos //zstream |
---|
| 3534 | + .close(); |
---|
3381 | 3535 | out.close(); |
---|
3382 | 3536 | |
---|
3383 | | - return baos.toByteArray(); |
---|
| 3537 | + byte[] bytes = baos.toByteArray(); |
---|
| 3538 | + |
---|
| 3539 | + System.out.println("save #bytes = " + bytes.length); |
---|
| 3540 | + return bytes; |
---|
3384 | 3541 | } catch (Exception e) |
---|
3385 | 3542 | { |
---|
3386 | 3543 | System.err.println(e); |
---|
.. | .. |
---|
3390 | 3547 | |
---|
3391 | 3548 | static public Object Uncompress(byte[] bytes) |
---|
3392 | 3549 | { |
---|
3393 | | - System.out.println("#bytes = " + bytes.length); |
---|
| 3550 | + System.out.println("restore #bytes = " + bytes.length); |
---|
3394 | 3551 | try |
---|
3395 | 3552 | { |
---|
3396 | 3553 | ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
3397 | | - java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
3398 | | - ObjectInputStream in = new ObjectInputStream(istream); |
---|
| 3554 | + //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
| 3555 | + ObjectInputStream in = new ObjectInputStream(bais); // istream); |
---|
3399 | 3556 | Object obj = in.readObject(); |
---|
| 3557 | + |
---|
| 3558 | + bais //istream |
---|
| 3559 | + .close(); |
---|
3400 | 3560 | in.close(); |
---|
3401 | 3561 | |
---|
3402 | 3562 | return obj; |
---|
.. | .. |
---|
3451 | 3611 | return null; |
---|
3452 | 3612 | } |
---|
3453 | 3613 | |
---|
3454 | | - java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
3455 | 3614 | |
---|
3456 | 3615 | public void Save() |
---|
| 3616 | + { |
---|
| 3617 | + //Save(true); |
---|
| 3618 | + Replace(); |
---|
| 3619 | + } |
---|
| 3620 | + |
---|
| 3621 | + private boolean Equal(byte[] compress, byte[] name) |
---|
| 3622 | + { |
---|
| 3623 | + if (compress.length != name.length) |
---|
| 3624 | + { |
---|
| 3625 | + return false; |
---|
| 3626 | + } |
---|
| 3627 | + |
---|
| 3628 | + for (int i=compress.length; --i>=0;) |
---|
| 3629 | + { |
---|
| 3630 | + if (compress[i] != name[i]) |
---|
| 3631 | + return false; |
---|
| 3632 | + } |
---|
| 3633 | + |
---|
| 3634 | + return true; |
---|
| 3635 | + } |
---|
| 3636 | + |
---|
| 3637 | + java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
| 3638 | + |
---|
| 3639 | + public boolean Save(boolean user) |
---|
3457 | 3640 | { |
---|
3458 | 3641 | System.err.println("Save"); |
---|
3459 | 3642 | |
---|
3460 | 3643 | cRadio tab = GetCurrentTab(); |
---|
3461 | 3644 | |
---|
3462 | | - boolean temp = CameraPane.SWITCH; |
---|
3463 | | - CameraPane.SWITCH = false; |
---|
| 3645 | + byte[] compress = CompressCopy(); |
---|
3464 | 3646 | |
---|
3465 | | - copy.ExtractBigData(hashtable); |
---|
| 3647 | + boolean thesame = false; |
---|
| 3648 | + |
---|
| 3649 | + // Quick heuristic using length. Works only when stream is compressed. |
---|
| 3650 | + if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1])) |
---|
| 3651 | + { |
---|
| 3652 | + thesame = true; |
---|
| 3653 | + } |
---|
3466 | 3654 | |
---|
3467 | 3655 | //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3468 | | - tab.graphs[tab.undoindex++] = Compress(copy); |
---|
3469 | | - |
---|
3470 | | - copy.RestoreBigData(hashtable); |
---|
3471 | | - |
---|
3472 | | - CameraPane.SWITCH = temp; |
---|
3473 | | - |
---|
3474 | | - //assert(hashtable.isEmpty()); |
---|
3475 | | - |
---|
3476 | | - for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
| 3656 | + if (!thesame) |
---|
3477 | 3657 | { |
---|
3478 | | - tab.graphs[i] = null; |
---|
| 3658 | + //tab.user[tab.versionindex] = user; |
---|
| 3659 | + //boolean increment = true; // tab.graphs[tab.versionindex] == null; |
---|
| 3660 | + |
---|
| 3661 | + copy.versions[++copy.versionindex] = compress; |
---|
| 3662 | + |
---|
| 3663 | + // if (increment) |
---|
| 3664 | + // tab.versionindex++; |
---|
3479 | 3665 | } |
---|
3480 | 3666 | |
---|
| 3667 | + //copy.RestoreBigData(versiontable); |
---|
| 3668 | + |
---|
| 3669 | + //assert(hashtable.isEmpty()); |
---|
| 3670 | + |
---|
| 3671 | + for (int i = copy.versionindex+1; i < copy.versions.length; i++) |
---|
| 3672 | + { |
---|
| 3673 | + //tab.user[i] = false; |
---|
| 3674 | + copy.versions[i] = null; |
---|
| 3675 | + } |
---|
| 3676 | + |
---|
| 3677 | + SetUndoStates(); |
---|
| 3678 | + |
---|
3481 | 3679 | // test save |
---|
3482 | 3680 | if (false) |
---|
3483 | 3681 | { |
---|
3484 | 3682 | try |
---|
3485 | 3683 | { |
---|
3486 | | - FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex); |
---|
| 3684 | + FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex); |
---|
3487 | 3685 | ObjectOutputStream p = new ObjectOutputStream(ostream); |
---|
3488 | 3686 | |
---|
3489 | 3687 | p.writeObject(copy); |
---|
.. | .. |
---|
3496 | 3694 | e.printStackTrace(); |
---|
3497 | 3695 | } |
---|
3498 | 3696 | } |
---|
| 3697 | + |
---|
| 3698 | + return !thesame; |
---|
3499 | 3699 | } |
---|
3500 | 3700 | |
---|
3501 | 3701 | void CopyChanged(Object3D obj) |
---|
3502 | 3702 | { |
---|
| 3703 | + SetUndoStates(); |
---|
| 3704 | + |
---|
3503 | 3705 | boolean temp = CameraPane.SWITCH; |
---|
3504 | 3706 | CameraPane.SWITCH = false; |
---|
3505 | 3707 | |
---|
3506 | | - copy.ExtractBigData(hashtable); |
---|
| 3708 | + copy.ExtractBigData(versiontable); |
---|
3507 | 3709 | |
---|
3508 | 3710 | copy.clear(); |
---|
3509 | 3711 | |
---|
.. | .. |
---|
3512 | 3714 | copy.add(obj.get(i)); |
---|
3513 | 3715 | } |
---|
3514 | 3716 | |
---|
3515 | | - copy.RestoreBigData(hashtable); |
---|
| 3717 | + copy.RestoreBigData(versiontable); |
---|
3516 | 3718 | |
---|
3517 | 3719 | CameraPane.SWITCH = temp; |
---|
3518 | 3720 | |
---|
.. | .. |
---|
3539 | 3741 | refreshContents(); |
---|
3540 | 3742 | } |
---|
3541 | 3743 | |
---|
3542 | | - public void Undo() |
---|
| 3744 | + cButton undoButton; |
---|
| 3745 | + cButton restoreButton; |
---|
| 3746 | + cButton replaceButton; |
---|
| 3747 | + cButton redoButton; |
---|
| 3748 | + |
---|
| 3749 | + boolean muteSlider; |
---|
| 3750 | + |
---|
| 3751 | + int VersionCount() |
---|
3543 | 3752 | { |
---|
| 3753 | + int count = 0; |
---|
| 3754 | + |
---|
| 3755 | + for (int i = copy.versions.length; --i >= 0;) |
---|
| 3756 | + { |
---|
| 3757 | + if (copy.versions[i] != null) |
---|
| 3758 | + count++; |
---|
| 3759 | + } |
---|
| 3760 | + |
---|
| 3761 | + return count; |
---|
| 3762 | + } |
---|
| 3763 | + |
---|
| 3764 | + void SetUndoStates() |
---|
| 3765 | + { |
---|
| 3766 | + cRadio tab = GetCurrentTab(); |
---|
| 3767 | + |
---|
| 3768 | + restoreButton.setEnabled(copy.versionindex != -1); |
---|
| 3769 | + replaceButton.setEnabled(copy.versionindex != -1); |
---|
| 3770 | + |
---|
| 3771 | + undoButton.setEnabled(copy.versionindex > 0); |
---|
| 3772 | + redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null); |
---|
| 3773 | + |
---|
| 3774 | + muteSlider = true; |
---|
| 3775 | + versionSlider.setMaximum(VersionCount() - 1); |
---|
| 3776 | + versionSlider.setInteger(copy.versionindex); |
---|
| 3777 | + muteSlider = false; |
---|
| 3778 | + } |
---|
| 3779 | + |
---|
| 3780 | + public boolean Undo() |
---|
| 3781 | + { |
---|
| 3782 | + // Option? |
---|
| 3783 | + Replace(); |
---|
| 3784 | + |
---|
3544 | 3785 | System.err.println("Undo"); |
---|
3545 | 3786 | |
---|
3546 | 3787 | cRadio tab = GetCurrentTab(); |
---|
3547 | 3788 | |
---|
3548 | | - if (tab.undoindex == 0) |
---|
| 3789 | + if (copy.versionindex == 0) |
---|
3549 | 3790 | { |
---|
3550 | 3791 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3551 | | - return; |
---|
| 3792 | + return false; |
---|
3552 | 3793 | } |
---|
3553 | 3794 | |
---|
3554 | | - if (tab.graphs[tab.undoindex] == null) |
---|
| 3795 | +// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex]) |
---|
| 3796 | +// { |
---|
| 3797 | +// if (Save(false)) |
---|
| 3798 | +// tab.versionindex -= 1; |
---|
| 3799 | +// else |
---|
| 3800 | +// { |
---|
| 3801 | +// if (tab.versionindex <= 0) |
---|
| 3802 | +// return false; |
---|
| 3803 | +// else |
---|
| 3804 | +// tab.versionindex -= 1; |
---|
| 3805 | +// } |
---|
| 3806 | +// } |
---|
| 3807 | + |
---|
| 3808 | + copy.versionindex -= 1; |
---|
| 3809 | + |
---|
| 3810 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3811 | + |
---|
| 3812 | + return true; |
---|
| 3813 | + } |
---|
| 3814 | + |
---|
| 3815 | + public boolean Restore() |
---|
| 3816 | + { |
---|
| 3817 | + System.err.println("Restore"); |
---|
| 3818 | + |
---|
| 3819 | + cRadio tab = GetCurrentTab(); |
---|
| 3820 | + |
---|
| 3821 | + if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null) |
---|
3555 | 3822 | { |
---|
3556 | | - Save(); |
---|
3557 | | - tab.undoindex -= 1; |
---|
| 3823 | + java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3824 | + return false; |
---|
3558 | 3825 | } |
---|
3559 | 3826 | |
---|
3560 | | - tab.undoindex -= 1; |
---|
| 3827 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3828 | + |
---|
| 3829 | + return true; |
---|
| 3830 | + } |
---|
3561 | 3831 | |
---|
3562 | | - CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3832 | + public boolean Replace() |
---|
| 3833 | + { |
---|
| 3834 | + System.err.println("Replace"); |
---|
| 3835 | + |
---|
| 3836 | + cRadio tab = GetCurrentTab(); |
---|
| 3837 | + |
---|
| 3838 | + if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null) |
---|
| 3839 | + { |
---|
| 3840 | + // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3841 | + return false; |
---|
| 3842 | + } |
---|
| 3843 | + |
---|
| 3844 | + copy.versions[copy.versionindex] = CompressCopy(); |
---|
| 3845 | + |
---|
| 3846 | + return true; |
---|
3563 | 3847 | } |
---|
3564 | 3848 | |
---|
3565 | 3849 | public void Redo() |
---|
3566 | 3850 | { |
---|
| 3851 | + // Option? |
---|
| 3852 | + Replace(); |
---|
| 3853 | + |
---|
3567 | 3854 | cRadio tab = GetCurrentTab(); |
---|
3568 | 3855 | |
---|
3569 | | - if (tab.graphs[tab.undoindex + 1] == null) |
---|
| 3856 | + if (copy.versions[copy.versionindex + 1] == null) |
---|
3570 | 3857 | { |
---|
3571 | 3858 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3572 | 3859 | return; |
---|
3573 | 3860 | } |
---|
3574 | 3861 | |
---|
3575 | | - tab.undoindex += 1; |
---|
| 3862 | + copy.versionindex += 1; |
---|
3576 | 3863 | |
---|
3577 | | - CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3864 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3865 | + |
---|
| 3866 | + //if (!tab.user[tab.versionindex]) |
---|
| 3867 | + // tab.graphs[tab.versionindex] = null; |
---|
3578 | 3868 | } |
---|
3579 | 3869 | |
---|
3580 | 3870 | void ImportGFD() |
---|
.. | .. |
---|
3726 | 4016 | assert false; |
---|
3727 | 4017 | } |
---|
3728 | 4018 | |
---|
3729 | | - void EditSelection() |
---|
| 4019 | + void EditSelection(boolean newWindow) |
---|
3730 | 4020 | { |
---|
3731 | 4021 | } |
---|
3732 | 4022 | |
---|
.. | .. |
---|
3870 | 4160 | //copy.Touch(); |
---|
3871 | 4161 | } |
---|
3872 | 4162 | |
---|
| 4163 | + cNumberSlider versionSlider; |
---|
| 4164 | + |
---|
3873 | 4165 | public void stateChanged(ChangeEvent e) |
---|
3874 | 4166 | { |
---|
3875 | 4167 | // assert(false); |
---|
| 4168 | + if (e.getSource() == versionSlider) |
---|
| 4169 | + { |
---|
| 4170 | + if (muteSlider) |
---|
| 4171 | + return; |
---|
| 4172 | + |
---|
| 4173 | + int version = versionSlider.getInteger(); |
---|
| 4174 | + |
---|
| 4175 | + if (copy.versions[version] != null) |
---|
| 4176 | + { |
---|
| 4177 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version])); |
---|
| 4178 | + } |
---|
| 4179 | + |
---|
| 4180 | + return; |
---|
| 4181 | + } |
---|
3876 | 4182 | |
---|
3877 | 4183 | if (freezematerial) |
---|
3878 | 4184 | { |
---|
.. | .. |
---|
4221 | 4527 | |
---|
4222 | 4528 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
4223 | 4529 | { |
---|
4224 | | - if (Globals.SAVEONMAKE) |
---|
| 4530 | + if (Globals.REPLACEONMAKE) // && resetmodel) |
---|
4225 | 4531 | Save(); |
---|
4226 | 4532 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
4227 | 4533 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
.. | .. |
---|
4309 | 4615 | { |
---|
4310 | 4616 | ResetModel(); |
---|
4311 | 4617 | Select(thing.GetTreePath(), true, false); // unselect... false); |
---|
| 4618 | + |
---|
| 4619 | + if (thing.Size() == 0) |
---|
| 4620 | + { |
---|
| 4621 | + //EditSelection(false); |
---|
| 4622 | + } |
---|
| 4623 | + |
---|
4312 | 4624 | refreshContents(); |
---|
4313 | 4625 | } |
---|
4314 | 4626 | |
---|
.. | .. |
---|
4457 | 4769 | readobj.ResetDisplayList(); |
---|
4458 | 4770 | } catch (Exception e) |
---|
4459 | 4771 | { |
---|
4460 | | - //e.printStackTrace(); |
---|
| 4772 | + e.printStackTrace(); |
---|
4461 | 4773 | try |
---|
4462 | 4774 | { |
---|
4463 | 4775 | java.io.FileInputStream istream = new java.io.FileInputStream(fullname); |
---|
.. | .. |
---|
4531 | 4843 | |
---|
4532 | 4844 | if (readobj != null) |
---|
4533 | 4845 | { |
---|
4534 | | - if (Globals.SAVEONMAKE) |
---|
4535 | | - Save(); |
---|
| 4846 | + //if (Globals.SAVEONMAKE) // A new object cannot share meshes |
---|
| 4847 | + // Save(); |
---|
4536 | 4848 | try |
---|
4537 | 4849 | { |
---|
4538 | 4850 | //readobj.deepCopySelf(copy); |
---|
.. | .. |
---|
4587 | 4899 | c.addChild(csg); |
---|
4588 | 4900 | } |
---|
4589 | 4901 | |
---|
| 4902 | + copy.versions = readobj.versions; |
---|
| 4903 | + copy.versionindex = readobj.versionindex; |
---|
| 4904 | + |
---|
| 4905 | + if (copy.versions == null) |
---|
| 4906 | + { |
---|
| 4907 | + copy.versions = new byte[100][]; |
---|
| 4908 | + copy.versionindex = -1; |
---|
| 4909 | + } |
---|
| 4910 | + |
---|
| 4911 | + //? SetUndoStates(); |
---|
| 4912 | + |
---|
4590 | 4913 | ResetModel(); |
---|
4591 | 4914 | copy.HardTouch(); // recompile? |
---|
4592 | 4915 | refreshContents(); |
---|
4593 | 4916 | } |
---|
4594 | 4917 | } |
---|
4595 | 4918 | |
---|
4596 | | - void load() // throws ClassNotFoundException |
---|
| 4919 | + void Open() // throws ClassNotFoundException |
---|
4597 | 4920 | { |
---|
4598 | 4921 | if (Grafreed.standAlone) |
---|
4599 | 4922 | { |
---|
.. | .. |
---|
4710 | 5033 | String filename = browser.getFile(); |
---|
4711 | 5034 | if (filename != null && filename.length() > 0) |
---|
4712 | 5035 | { |
---|
| 5036 | + if (!filename.endsWith(".gfd")) |
---|
| 5037 | + filename += ".gfd"; |
---|
4713 | 5038 | lastname = browser.getDirectory() + filename; |
---|
4714 | 5039 | save(); |
---|
4715 | 5040 | } |
---|
.. | .. |
---|
4876 | 5201 | MenuBar menuBar; |
---|
4877 | 5202 | Menu fileMenu; |
---|
4878 | 5203 | MenuItem newItem; |
---|
4879 | | - MenuItem loadItem; |
---|
| 5204 | + MenuItem openItem; |
---|
4880 | 5205 | MenuItem saveItem; |
---|
4881 | 5206 | MenuItem saveAsItem; |
---|
4882 | 5207 | MenuItem exportAsItem; |
---|
.. | .. |
---|
4899 | 5224 | CheckboxMenuItem toggleSwitchItem; |
---|
4900 | 5225 | CheckboxMenuItem toggleRootItem; |
---|
4901 | 5226 | CheckboxMenuItem animationItem; |
---|
| 5227 | + MenuItem archiveItem; |
---|
4902 | 5228 | CheckboxMenuItem toggleHandleItem; |
---|
4903 | 5229 | CheckboxMenuItem togglePaintItem; |
---|
4904 | 5230 | JSplitPane mainPanel; |
---|
4905 | 5231 | JScrollPane scrollpane; |
---|
| 5232 | + |
---|
4906 | 5233 | JPanel toolbarPanel; |
---|
| 5234 | + |
---|
4907 | 5235 | cGridBag treePanel; |
---|
| 5236 | + |
---|
4908 | 5237 | JPanel radioPanel; |
---|
4909 | 5238 | ButtonGroup buttonGroup; |
---|
4910 | | - cGridBag ctrlPanel; |
---|
| 5239 | + |
---|
| 5240 | + cGridBag toolboxPanel; |
---|
4911 | 5241 | cGridBag materialPanel; |
---|
| 5242 | + cGridBag ctrlPanel; |
---|
| 5243 | + |
---|
4912 | 5244 | JScrollPane infoPanel; |
---|
| 5245 | + |
---|
4913 | 5246 | cGridBag optionsPanel; |
---|
| 5247 | + |
---|
4914 | 5248 | JTabbedPane objectPanel; |
---|
| 5249 | + boolean materialFlushed; |
---|
| 5250 | + Object3D latestObject; |
---|
| 5251 | + |
---|
4915 | 5252 | cGridBag XYZPanel; |
---|
| 5253 | + |
---|
4916 | 5254 | JSplitPane gridPanel; |
---|
4917 | 5255 | JSplitPane bigPanel; |
---|
| 5256 | + |
---|
4918 | 5257 | cGridBag bigThree; |
---|
4919 | 5258 | cGridBag scenePanel; |
---|
4920 | 5259 | cGridBag centralPanel; |
---|
.. | .. |
---|
5029 | 5368 | cNumberSlider fogField; |
---|
5030 | 5369 | JLabel opacityPowerLabel; |
---|
5031 | 5370 | cNumberSlider opacityPowerField; |
---|
5032 | | - JTree jTree; |
---|
| 5371 | + cTree jTree; |
---|
5033 | 5372 | //ObjectUI parent; |
---|
5034 | 5373 | |
---|
5035 | 5374 | cNumberSlider normalpushField; |
---|