Normand Briere
2019-07-01 9079880942d022ee32fd3a543843e132e52deb1a
ObjEditor.java
....@@ -4,6 +4,7 @@
44
55 import java.awt.*;
66 import java.awt.event.*;
7
+import java.awt.image.BufferedImage;
78 import javax.swing.*;
89 import javax.swing.event.*;
910 import javax.swing.text.*;
....@@ -13,6 +14,9 @@
1314 import javax.swing.plaf.metal.MetalLookAndFeel;
1415 //import javax.swing.plaf.ColorUIResource;
1516 //import javax.swing.plaf.metal.DefaultMetalTheme;
17
+
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
1620
1721 //import javax.media.opengl.GLCanvas;
1822
....@@ -37,6 +41,65 @@
3741 JFrame frame;
3842
3943 static ObjEditor theFrame;
44
+
45
+ cButton GetButton(String name, boolean border)
46
+ {
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
+ }
56
+ }
57
+
58
+ cToggleButton GetToggleButton(String name, boolean border)
59
+ {
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
+ }
69
+ }
70
+
71
+ cCheckBox GetCheckBox(String name, boolean border)
72
+ {
73
+ try
74
+ {
75
+ ImageIcon icon = GetIcon(name);
76
+ return new cCheckBox(icon, border);
77
+ }
78
+ catch (Exception e)
79
+ {
80
+ return new cCheckBox(name, border);
81
+ }
82
+ }
83
+
84
+ private ImageIcon GetIcon(String name) throws IOException
85
+ {
86
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
87
+
88
+ if (image.getWidth() != 24 && image.getHeight() != 24)
89
+ {
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;
98
+ }
99
+
100
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
101
+ return icon;
102
+ }
40103
41104 // SCRIPT
42105
....@@ -147,7 +210,7 @@
147210
148211 objEditor.ctrlPanel.remove(namePanel);
149212
150
- if (!GroupEditor.allparams)
213
+ if (!allparams)
151214 return;
152215
153216 // objEditor.ctrlPanel.remove(liveCB);
....@@ -246,7 +309,7 @@
246309 //localCopy.parent = null;
247310
248311 frame = new JFrame();
249
- frame.setUndecorated(true);
312
+ frame.setUndecorated(false);
250313 objEditor = this;
251314 this.callee = callee;
252315
....@@ -277,12 +340,17 @@
277340 return frame.action(event, obj);
278341 }
279342
343
+ // Cannot work without static
344
+ static boolean allparams = true;
345
+
346
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
347
+
280348 void SetupMenu()
281349 {
282350 frame.setMenuBar(menuBar = new MenuBar());
283351 menuBar.add(fileMenu = new Menu("File"));
284352 fileMenu.add(newItem = new MenuItem("New"));
285
- fileMenu.add(loadItem = new MenuItem("Open..."));
353
+ fileMenu.add(openItem = new MenuItem("Open..."));
286354
287355 //oe.menuBar.add(menu = new Menu("Include"));
288356 Menu menu = new Menu("Import");
....@@ -314,7 +382,7 @@
314382 }
315383
316384 newItem.addActionListener(this);
317
- loadItem.addActionListener(this);
385
+ openItem.addActionListener(this);
318386 saveItem.addActionListener(this);
319387 saveAsItem.addActionListener(this);
320388 exportAsItem.addActionListener(this);
....@@ -323,6 +391,32 @@
323391 closeItem.addActionListener(this);
324392
325393 objectPanel = new JTabbedPane();
394
+
395
+ ChangeListener changeListener = new ChangeListener()
396
+ {
397
+ public void stateChanged(ChangeEvent changeEvent)
398
+ {
399
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
400
+// {
401
+// if (latestObject != null)
402
+// {
403
+// refreshContents(true);
404
+// SetMaterial(latestObject);
405
+// }
406
+//
407
+// materialFlushed = true;
408
+// }
409
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
410
+// {
411
+// if (listUI.size() == 0)
412
+// EditSelection(false);
413
+// }
414
+
415
+ refreshContents(false); // To refresh Info tab
416
+ }
417
+ };
418
+ objectPanel.addChangeListener(changeListener);
419
+
326420 toolbarPanel = new JPanel();
327421 toolbarPanel.setName("Toolbar");
328422 treePanel = new cGridBag();
....@@ -337,9 +431,12 @@
337431 editPanel.add(editCommandsPanel);
338432 editPanel.add(ctrlPanel);
339433
340
- materialPanel = new cGridBag().setVertical(true);
434
+ toolboxPanel = new cGridBag().setVertical(false);
435
+ toolboxPanel.setName("Toolbox");
341436
437
+ materialPanel = new cGridBag().setVertical(true);
342438 materialPanel.setName("Material");
439
+
343440 /*JTextPane*/
344441 infoarea = createTextPane();
345442 doc = infoarea.getStyledDocument();
....@@ -352,7 +449,7 @@
352449 // TEXTAREA infoarea.setLineWrap(true);
353450 // TEXTAREA infoarea.setWrapStyleWord(true);
354451 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
355
- infoPanel.setPreferredSize(new Dimension(50, 200));
452
+ //infoPanel.setPreferredSize(new Dimension(50, 200));
356453 infoPanel.setName("Info");
357454 //infoPanel.setLayout(new BorderLayout());
358455 //infoPanel.add(createTextPane());
....@@ -364,7 +461,14 @@
364461 mainPanel.setDividerSize(9);
365462 mainPanel.setDividerLocation(0.5); //1.0);
366463 mainPanel.setResizeWeight(0.5);
367
-
464
+
465
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
466
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
467
+ divider.setDividerSize(15);
468
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
469
+
470
+ mainPanel.setUI(new BasicSplitPaneUI());
471
+
368472 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
369473 //mainPanel.setLayout(new GridBagLayout());
370474 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -595,8 +699,8 @@
595699 }
596700 }
597701
598
-static GraphicsDevice device = GraphicsEnvironment
599
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
702
+//static GraphicsDevice device = GraphicsEnvironment
703
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
600704
601705 Rectangle keeprect;
602706 cRadio radio;
....@@ -612,13 +716,24 @@
612716
613717 boolean maximized;
614718
719
+ cButton fullscreenLayout;
720
+
615721 void Minimize()
616722 {
617723 frame.setState(Frame.ICONIFIED);
724
+ frame.validate();
618725 }
619726
727
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
728
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
729
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
620730 void Maximize()
621731 {
732
+ if (CameraPane.FULLSCREEN)
733
+ {
734
+ ToggleFullScreen();
735
+ }
736
+
622737 if (maximized)
623738 {
624739 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -626,20 +741,36 @@
626741 else
627742 {
628743 keeprect = frame.getBounds();
629
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
630
- Dimension rect2 = frame.getToolkit().getScreenSize();
631
- frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
744
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
745
+// Dimension rect2 = frame.getToolkit().getScreenSize();
746
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
632747 // frame.setState(Frame.MAXIMIZED_BOTH);
748
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
633749 }
634750
635751 maximized ^= true;
752
+
753
+ frame.validate();
636754 }
755
+
756
+ cButton minButton;
757
+ cButton maxButton;
758
+ cButton fullButton;
637759
638760 void ToggleFullScreen()
639761 {
640
- if (CameraPane.FULLSCREEN)
762
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
763
+
764
+ cameraView.ToggleFullScreen();
765
+
766
+ if (!CameraPane.FULLSCREEN)
641767 {
642768 device.setFullScreenWindow(null);
769
+ frame.dispose();
770
+ frame.setUndecorated(false);
771
+ frame.validate();
772
+ frame.setVisible(true);
773
+
643774 //frame.setVisible(false);
644775 // frame.removeNotify();
645776 // frame.setUndecorated(false);
....@@ -649,7 +780,7 @@
649780 // X frame.getContentPane().remove(/*"Center",*/bigThree);
650781 // X framePanel.add(bigThree);
651782 // X frame.getContentPane().add(/*"Center",*/framePanel);
652
- framePanel.setDividerLocation(1);
783
+ framePanel.setDividerLocation(46);
653784
654785 //frame.setVisible(true);
655786 radio.layout = keepButton;
....@@ -664,7 +795,12 @@
664795 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
665796 // frame.getToolkit().getScreenSize().height);
666797 //frame.setVisible(false);
798
+
799
+ frame.dispose();
800
+ frame.setUndecorated(true);
667801 device.setFullScreenWindow(frame);
802
+ frame.validate();
803
+ frame.setVisible(true);
668804 // frame.removeNotify();
669805 // frame.setUndecorated(true);
670806 // frame.addNotify();
....@@ -673,12 +809,11 @@
673809 // X frame.getContentPane().add(/*"Center",*/bigThree);
674810 framePanel.setDividerLocation(0);
675811
676
- radio.layout = twoButton;
812
+ radio.layout = fullscreenLayout;
677813 radio.layout.doClick();
678814 //frame.setVisible(true);
679815 }
680
-
681
- cameraView.ToggleFullScreen();
816
+ frame.validate();
682817 }
683818
684819 private JTextPane createTextPane()
....@@ -819,7 +954,12 @@
819954 JCheckBox speedupCB;
820955 JCheckBox rewindCB;
821956 JCheckBox flipVCB;
957
+
958
+ cCheckBox toggleTextureCB;
959
+ cCheckBox toggleSwitchCB;
960
+
822961 JComboBox texresMenu;
962
+
823963 JButton resetButton;
824964 JButton stepButton;
825965 JButton stepAllButton;
....@@ -1006,12 +1146,12 @@
10061146 namePanel = new cGridBag();
10071147
10081148 nameField = AddText(namePanel, copy.GetName());
1009
- namePanel.add(nameField);
1149
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
10101150 oe.ctrlPanel.add(namePanel);
10111151
10121152 oe.ctrlPanel.Return();
10131153
1014
- if (!GroupEditor.allparams)
1154
+ if (!allparams)
10151155 return;
10161156
10171157 setupPanel = new cGridBag().setVertical(false);
....@@ -1024,15 +1164,15 @@
10241164 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
10251165 hideCB.setToolTipText("Hide object");
10261166 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1027
- markCB.setToolTipText("Set the animation target transform");
1167
+ markCB.setToolTipText("As animation target transform");
10281168
10291169 setupPanel2 = new cGridBag().setVertical(false);
10301170
10311171 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
10321172 rewindCB.setToolTipText("Rewind animation");
10331173
1034
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1035
- randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1174
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1175
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
10361176
10371177 if (Globals.ADVANCED)
10381178 {
....@@ -1353,7 +1493,11 @@
13531493 // north.add(ctrlPanel, BorderLayout.NORTH);
13541494 // objectPanel.add(north);
13551495 objectPanel.add(editPanel);
1356
- objectPanel.add(infoPanel);
1496
+
1497
+ if (Globals.ADVANCED)
1498
+ objectPanel.add(infoPanel);
1499
+
1500
+ objectPanel.add(toolboxPanel);
13571501
13581502 /*
13591503 aConstraints.gridx = 0;
....@@ -1362,7 +1506,7 @@
13621506 aConstraints.gridy += 1;
13631507 aConstraints.gridwidth = 1;
13641508 mainPanel.add(objectPanel, aConstraints);
1365
- */
1509
+ */
13661510
13671511 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
13681512 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1379,9 +1523,7 @@
13791523 JTabbedPane tabbedPane = new JTabbedPane();
13801524 tabbedPane.add(scrollpane);
13811525
1382
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1383
-
1384
- optionsPanel = new cGridBag().setVertical(true);
1526
+ optionsPanel = new cGridBag().setVertical(false);
13851527
13861528 optionsPanel.setName("Options");
13871529
....@@ -1389,6 +1531,8 @@
13891531
13901532 tabbedPane.add(optionsPanel);
13911533
1534
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1535
+
13921536 scenePanel.add(tabbedPane);
13931537
13941538 /*
....@@ -1461,9 +1605,9 @@
14611605 // aConstraints.gridheight = 1;
14621606
14631607 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1464
- framePanel.setContinuousLayout(true);
1465
- framePanel.setOneTouchExpandable(true);
1466
- framePanel.setDividerLocation(0.8);
1608
+ framePanel.setContinuousLayout(false);
1609
+ framePanel.setOneTouchExpandable(false);
1610
+ //.setDividerLocation(0.8);
14671611 //framePanel.setDividerSize(15);
14681612 //framePanel.setResizeWeight(0.15);
14691613 framePanel.setName("Frame");
....@@ -1481,11 +1625,14 @@
14811625 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
14821626
14831627 frame.setSize(1280, 860);
1484
- frame.setVisible(true);
1485
-
1628
+
14861629 cameraView.requestFocusInWindow();
14871630
14881631 gridPanel.setDividerLocation(1.0);
1632
+
1633
+ frame.validate();
1634
+
1635
+ frame.setVisible(true);
14891636
14901637 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
14911638 frame.addWindowListener(new WindowAdapter()
....@@ -1572,24 +1719,6 @@
15721719 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
15731720 colorSection.add(texture);
15741721
1575
- cGridBag anisoU = new cGridBag();
1576
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1577
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1578
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1579
- colorSection.add(anisoU);
1580
-
1581
- cGridBag anisoV = new cGridBag();
1582
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1583
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1584
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1585
- colorSection.add(anisoV);
1586
-
1587
- cGridBag shadowbias = new cGridBag();
1588
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1589
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1590
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1591
- colorSection.add(shadowbias);
1592
-
15931722 panel.add(new JSeparator());
15941723
15951724 panel.add(colorSection);
....@@ -1639,6 +1768,12 @@
16391768 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16401769 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
16411770 diffuseSection.add(fakedepth);
1771
+
1772
+ cGridBag shadowbias = new cGridBag();
1773
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1774
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1775
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1776
+ diffuseSection.add(shadowbias);
16421777
16431778 panel.add(new JSeparator());
16441779
....@@ -1690,6 +1825,18 @@
16901825 // aConstraints.gridy += 1;
16911826 // aConstraints.gridwidth = 1;
16921827
1828
+ cGridBag anisoU = new cGridBag();
1829
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1830
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1831
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1832
+ specularSection.add(anisoU);
1833
+
1834
+ cGridBag anisoV = new cGridBag();
1835
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1836
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1837
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1838
+ specularSection.add(anisoV);
1839
+
16931840
16941841 panel.add(new JSeparator());
16951842
....@@ -1697,35 +1844,35 @@
16971844
16981845 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16991846
1700
- cGridBag globalSection = new cGridBag().setVertical(true);
1847
+ //cGridBag globalSection = new cGridBag().setVertical(true);
17011848
17021849 cGridBag camera = new cGridBag();
17031850 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
17041851 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17051852 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1706
- globalSection.add(camera);
1853
+ colorSection.add(camera);
17071854
17081855 cGridBag ambient = new cGridBag();
17091856 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
17101857 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17111858 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1712
- globalSection.add(ambient);
1859
+ colorSection.add(ambient);
17131860
17141861 cGridBag backlit = new cGridBag();
17151862 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
17161863 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17171864 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1718
- globalSection.add(backlit);
1865
+ colorSection.add(backlit);
17191866
17201867 cGridBag opacity = new cGridBag();
17211868 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
17221869 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17231870 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1724
- globalSection.add(opacity);
1871
+ colorSection.add(opacity);
17251872
1726
- panel.add(new JSeparator());
1873
+ //panel.add(new JSeparator());
17271874
1728
- panel.add(globalSection);
1875
+ //panel.add(globalSection);
17291876
17301877 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17311878
....@@ -2800,6 +2947,8 @@
28002947
28012948 void SetMaterial(Object3D object)
28022949 {
2950
+ latestObject = object;
2951
+
28032952 cMaterial mat = object.material;
28042953
28052954 if (mat == null)
....@@ -2911,12 +3060,17 @@
29113060 // }
29123061
29133062 /**/
2914
- if (deselect)
3063
+ if (deselect || child == null)
29153064 {
29163065 //group.deselectAll();
29173066 //freeze = true;
29183067 GetTree().clearSelection();
29193068 //freeze = false;
3069
+
3070
+ if (child == null)
3071
+ {
3072
+ return;
3073
+ }
29203074 }
29213075
29223076 //group.addSelectee(child);
....@@ -2985,7 +3139,7 @@
29853139 cameraView.ToggleDL();
29863140 cameraView.repaint();
29873141 return;
2988
- } else if (event.getSource() == toggleTextureItem)
3142
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
29893143 {
29903144 cameraView.ToggleTexture();
29913145 // june 2013 copy.HardTouch();
....@@ -3024,7 +3178,7 @@
30243178 frame.validate();
30253179
30263180 return;
3027
- } else if (event.getSource() == toggleSwitchItem)
3181
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
30283182 {
30293183 cameraView.ToggleSwitch();
30303184 cameraView.repaint();
....@@ -3046,6 +3200,10 @@
30463200 } else if (event.getSource() == animationItem)
30473201 {
30483202 ToggleAnimation();
3203
+ return;
3204
+ } else if (event.getSource() == archiveItem)
3205
+ {
3206
+ cTools.Archive(frame);
30493207 return;
30503208 } else if (event.getSource() == flipVCB)
30513209 {
....@@ -3240,9 +3398,9 @@
32403398 {
32413399 Close();
32423400 //return true;
3243
- } else if (source == loadItem)
3401
+ } else if (source == openItem)
32443402 {
3245
- load();
3403
+ Open();
32463404 //return true;
32473405 } else if (source == newItem)
32483406 {
....@@ -3408,6 +3566,8 @@
34083566
34093567 public void Save()
34103568 {
3569
+ System.err.println("Save");
3570
+
34113571 cRadio tab = GetCurrentTab();
34123572
34133573 boolean temp = CameraPane.SWITCH;
....@@ -3415,8 +3575,10 @@
34153575
34163576 copy.ExtractBigData(hashtable);
34173577
3578
+ byte[] compress = Compress(copy);
3579
+
34183580 //EditorFrame.m_MainFrame.requestFocusInWindow();
3419
- tab.graphs[tab.undoindex++] = Compress(copy);
3581
+ tab.graphs[tab.undoindex++] = compress;
34203582
34213583 copy.RestoreBigData(hashtable);
34223584
....@@ -3429,6 +3591,8 @@
34293591 tab.graphs[i] = null;
34303592 }
34313593
3594
+ SetUndoStates();
3595
+
34323596 // test save
34333597 if (false)
34343598 {
....@@ -3451,6 +3615,8 @@
34513615
34523616 void CopyChanged(Object3D obj)
34533617 {
3618
+ SetUndoStates();
3619
+
34543620 boolean temp = CameraPane.SWITCH;
34553621 CameraPane.SWITCH = false;
34563622
....@@ -3490,8 +3656,21 @@
34903656 refreshContents();
34913657 }
34923658
3659
+ cButton undoButton;
3660
+ cButton redoButton;
3661
+
3662
+ void SetUndoStates()
3663
+ {
3664
+ cRadio tab = GetCurrentTab();
3665
+
3666
+ undoButton.setEnabled(tab.undoindex > 0);
3667
+ redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3668
+ }
3669
+
34933670 public void Undo()
34943671 {
3672
+ System.err.println("Undo");
3673
+
34953674 cRadio tab = GetCurrentTab();
34963675
34973676 if (tab.undoindex == 0)
....@@ -3675,7 +3854,7 @@
36753854 assert false;
36763855 }
36773856
3678
- void EditSelection()
3857
+ void EditSelection(boolean newWindow)
36793858 {
36803859 }
36813860
....@@ -4170,7 +4349,8 @@
41704349
41714350 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
41724351 {
4173
- Save();
4352
+ if (Globals.SAVEONMAKE) // && resetmodel)
4353
+ Save();
41744354 //Tween.set(thing, 0).target(1).start(tweenManager);
41754355 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
41764356 // if (thing instanceof GenericJointDemo)
....@@ -4257,6 +4437,12 @@
42574437 {
42584438 ResetModel();
42594439 Select(thing.GetTreePath(), true, false); // unselect... false);
4440
+
4441
+ if (thing.Size() == 0)
4442
+ {
4443
+ //EditSelection(false);
4444
+ }
4445
+
42604446 refreshContents();
42614447 }
42624448
....@@ -4479,6 +4665,7 @@
44794665
44804666 if (readobj != null)
44814667 {
4668
+ if (Globals.SAVEONMAKE)
44824669 Save();
44834670 try
44844671 {
....@@ -4540,7 +4727,7 @@
45404727 }
45414728 }
45424729
4543
- void load() // throws ClassNotFoundException
4730
+ void Open() // throws ClassNotFoundException
45444731 {
45454732 if (Grafreed.standAlone)
45464733 {
....@@ -4657,6 +4844,8 @@
46574844 String filename = browser.getFile();
46584845 if (filename != null && filename.length() > 0)
46594846 {
4847
+ if (!filename.endsWith(".gfd"))
4848
+ filename += ".gfd";
46604849 lastname = browser.getDirectory() + filename;
46614850 save();
46624851 }
....@@ -4823,7 +5012,7 @@
48235012 MenuBar menuBar;
48245013 Menu fileMenu;
48255014 MenuItem newItem;
4826
- MenuItem loadItem;
5015
+ MenuItem openItem;
48275016 MenuItem saveItem;
48285017 MenuItem saveAsItem;
48295018 MenuItem exportAsItem;
....@@ -4846,22 +5035,36 @@
48465035 CheckboxMenuItem toggleSwitchItem;
48475036 CheckboxMenuItem toggleRootItem;
48485037 CheckboxMenuItem animationItem;
5038
+ CheckboxMenuItem archiveItem;
48495039 CheckboxMenuItem toggleHandleItem;
48505040 CheckboxMenuItem togglePaintItem;
48515041 JSplitPane mainPanel;
48525042 JScrollPane scrollpane;
5043
+
48535044 JPanel toolbarPanel;
5045
+
48545046 cGridBag treePanel;
5047
+
48555048 JPanel radioPanel;
48565049 ButtonGroup buttonGroup;
4857
- cGridBag ctrlPanel;
5050
+
5051
+ cGridBag toolboxPanel;
48585052 cGridBag materialPanel;
5053
+ cGridBag ctrlPanel;
5054
+
48595055 JScrollPane infoPanel;
5056
+
48605057 cGridBag optionsPanel;
5058
+
48615059 JTabbedPane objectPanel;
5060
+ boolean materialFlushed;
5061
+ Object3D latestObject;
5062
+
48625063 cGridBag XYZPanel;
5064
+
48635065 JSplitPane gridPanel;
48645066 JSplitPane bigPanel;
5067
+
48655068 cGridBag bigThree;
48665069 cGridBag scenePanel;
48675070 cGridBag centralPanel;
....@@ -4976,7 +5179,7 @@
49765179 cNumberSlider fogField;
49775180 JLabel opacityPowerLabel;
49785181 cNumberSlider opacityPowerField;
4979
- JTree jTree;
5182
+ cTree jTree;
49805183 //ObjectUI parent;
49815184
49825185 cNumberSlider normalpushField;