Normand Briere
2019-07-14 bc829f47837b5a001f911542140b0b8e63c2bb0c
ObjEditor.java
....@@ -15,6 +15,9 @@
1515 //import javax.swing.plaf.ColorUIResource;
1616 //import javax.swing.plaf.metal.DefaultMetalTheme;
1717
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
20
+
1821 //import javax.media.opengl.GLCanvas;
1922
2023 import //weka.core.
....@@ -207,7 +210,7 @@
207210
208211 objEditor.ctrlPanel.remove(namePanel);
209212
210
- if (!GroupEditor.allparams)
213
+ if (!allparams)
211214 return;
212215
213216 // objEditor.ctrlPanel.remove(liveCB);
....@@ -306,7 +309,7 @@
306309 //localCopy.parent = null;
307310
308311 frame = new JFrame();
309
- frame.setUndecorated(true);
312
+ frame.setUndecorated(false);
310313 objEditor = this;
311314 this.callee = callee;
312315
....@@ -337,12 +340,17 @@
337340 return frame.action(event, obj);
338341 }
339342
343
+ // Cannot work without static
344
+ static boolean allparams = true;
345
+
346
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
347
+
340348 void SetupMenu()
341349 {
342350 frame.setMenuBar(menuBar = new MenuBar());
343351 menuBar.add(fileMenu = new Menu("File"));
344352 fileMenu.add(newItem = new MenuItem("New"));
345
- fileMenu.add(loadItem = new MenuItem("Open..."));
353
+ fileMenu.add(openItem = new MenuItem("Open..."));
346354
347355 //oe.menuBar.add(menu = new Menu("Include"));
348356 Menu menu = new Menu("Import");
....@@ -374,7 +382,7 @@
374382 }
375383
376384 newItem.addActionListener(this);
377
- loadItem.addActionListener(this);
385
+ openItem.addActionListener(this);
378386 saveItem.addActionListener(this);
379387 saveAsItem.addActionListener(this);
380388 exportAsItem.addActionListener(this);
....@@ -397,6 +405,11 @@
397405 // }
398406 //
399407 // materialFlushed = true;
408
+// }
409
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
410
+// {
411
+// if (listUI.size() == 0)
412
+// EditSelection(false);
400413 // }
401414
402415 refreshContents(false); // To refresh Info tab
....@@ -436,7 +449,7 @@
436449 // TEXTAREA infoarea.setLineWrap(true);
437450 // TEXTAREA infoarea.setWrapStyleWord(true);
438451 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
439
- infoPanel.setPreferredSize(new Dimension(50, 200));
452
+ infoPanel.setPreferredSize(new Dimension(1, 1));
440453 infoPanel.setName("Info");
441454 //infoPanel.setLayout(new BorderLayout());
442455 //infoPanel.add(createTextPane());
....@@ -448,7 +461,14 @@
448461 mainPanel.setDividerSize(9);
449462 mainPanel.setDividerLocation(0.5); //1.0);
450463 mainPanel.setResizeWeight(0.5);
451
-
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
+
452472 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
453473 //mainPanel.setLayout(new GridBagLayout());
454474 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -679,8 +699,8 @@
679699 }
680700 }
681701
682
-static GraphicsDevice device = GraphicsEnvironment
683
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
702
+//static GraphicsDevice device = GraphicsEnvironment
703
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
684704
685705 Rectangle keeprect;
686706 cRadio radio;
....@@ -701,10 +721,19 @@
701721 void Minimize()
702722 {
703723 frame.setState(Frame.ICONIFIED);
724
+ frame.validate();
704725 }
705726
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={}
706730 void Maximize()
707731 {
732
+ if (CameraPane.FULLSCREEN)
733
+ {
734
+ ToggleFullScreen();
735
+ }
736
+
708737 if (maximized)
709738 {
710739 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -712,20 +741,36 @@
712741 else
713742 {
714743 keeprect = frame.getBounds();
715
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
716
- Dimension rect2 = frame.getToolkit().getScreenSize();
717
- frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
744
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
745
+// Dimension rect2 = frame.getToolkit().getScreenSize();
746
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
718747 // frame.setState(Frame.MAXIMIZED_BOTH);
748
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
719749 }
720750
721751 maximized ^= true;
752
+
753
+ frame.validate();
722754 }
755
+
756
+ cButton minButton;
757
+ cButton maxButton;
758
+ cButton fullButton;
723759
724760 void ToggleFullScreen()
725761 {
726
- if (CameraPane.FULLSCREEN)
762
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
763
+
764
+ cameraView.ToggleFullScreen();
765
+
766
+ if (!CameraPane.FULLSCREEN)
727767 {
728768 device.setFullScreenWindow(null);
769
+ frame.dispose();
770
+ frame.setUndecorated(false);
771
+ frame.validate();
772
+ frame.setVisible(true);
773
+
729774 //frame.setVisible(false);
730775 // frame.removeNotify();
731776 // frame.setUndecorated(false);
....@@ -735,7 +780,7 @@
735780 // X frame.getContentPane().remove(/*"Center",*/bigThree);
736781 // X framePanel.add(bigThree);
737782 // X frame.getContentPane().add(/*"Center",*/framePanel);
738
- framePanel.setDividerLocation(1);
783
+ framePanel.setDividerLocation(46);
739784
740785 //frame.setVisible(true);
741786 radio.layout = keepButton;
....@@ -750,7 +795,12 @@
750795 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
751796 // frame.getToolkit().getScreenSize().height);
752797 //frame.setVisible(false);
798
+
799
+ frame.dispose();
800
+ frame.setUndecorated(true);
753801 device.setFullScreenWindow(frame);
802
+ frame.validate();
803
+ frame.setVisible(true);
754804 // frame.removeNotify();
755805 // frame.setUndecorated(true);
756806 // frame.addNotify();
....@@ -763,8 +813,7 @@
763813 radio.layout.doClick();
764814 //frame.setVisible(true);
765815 }
766
-
767
- cameraView.ToggleFullScreen();
816
+ frame.validate();
768817 }
769818
770819 private JTextPane createTextPane()
....@@ -1097,12 +1146,12 @@
10971146 namePanel = new cGridBag();
10981147
10991148 nameField = AddText(namePanel, copy.GetName());
1100
- namePanel.add(nameField);
1149
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11011150 oe.ctrlPanel.add(namePanel);
11021151
11031152 oe.ctrlPanel.Return();
11041153
1105
- if (!GroupEditor.allparams)
1154
+ if (!allparams)
11061155 return;
11071156
11081157 setupPanel = new cGridBag().setVertical(false);
....@@ -1115,20 +1164,21 @@
11151164 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11161165 hideCB.setToolTipText("Hide object");
11171166 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1118
- markCB.setToolTipText("Set the animation target transform");
1167
+ markCB.setToolTipText("As animation target transform");
11191168
11201169 setupPanel2 = new cGridBag().setVertical(false);
11211170
11221171 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11231172 rewindCB.setToolTipText("Rewind animation");
11241173
1125
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1126
- 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)");
11271176
1177
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1178
+ link2masterCB.setToolTipText("Attach to support");
1179
+
11281180 if (Globals.ADVANCED)
11291181 {
1130
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1131
- link2masterCB.setToolTipText("Attach to support");
11321182 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11331183 speedupCB.setToolTipText("Option motion capture");
11341184 }
....@@ -1439,13 +1489,16 @@
14391489 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14401490 //tmp.setName("Edit");
14411491 objectPanel.add(materialPanel);
1442
- objectPanel.add(toolboxPanel);
14431492 // JPanel north = new JPanel(new BorderLayout());
14441493 // north.setName("Edit");
14451494 // north.add(ctrlPanel, BorderLayout.NORTH);
14461495 // objectPanel.add(north);
14471496 objectPanel.add(editPanel);
1448
- objectPanel.add(infoPanel);
1497
+
1498
+ //if (Globals.ADVANCED)
1499
+ objectPanel.add(infoPanel);
1500
+
1501
+ objectPanel.add(toolboxPanel);
14491502
14501503 /*
14511504 aConstraints.gridx = 0;
....@@ -1454,7 +1507,7 @@
14541507 aConstraints.gridy += 1;
14551508 aConstraints.gridwidth = 1;
14561509 mainPanel.add(objectPanel, aConstraints);
1457
- */
1510
+ */
14581511
14591512 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
14601513 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1553,9 +1606,9 @@
15531606 // aConstraints.gridheight = 1;
15541607
15551608 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1556
- framePanel.setContinuousLayout(true);
1557
- framePanel.setOneTouchExpandable(true);
1558
- framePanel.setDividerLocation(0.8);
1609
+ framePanel.setContinuousLayout(false);
1610
+ framePanel.setOneTouchExpandable(false);
1611
+ //.setDividerLocation(0.8);
15591612 //framePanel.setDividerSize(15);
15601613 //framePanel.setResizeWeight(0.15);
15611614 framePanel.setName("Frame");
....@@ -1574,12 +1627,13 @@
15741627
15751628 frame.setSize(1280, 860);
15761629
1577
- frame.validate();
1578
- frame.setVisible(true);
1579
-
15801630 cameraView.requestFocusInWindow();
15811631
15821632 gridPanel.setDividerLocation(1.0);
1633
+
1634
+ frame.validate();
1635
+
1636
+ frame.setVisible(true);
15831637
15841638 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
15851639 frame.addWindowListener(new WindowAdapter()
....@@ -1666,24 +1720,6 @@
16661720 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16671721 colorSection.add(texture);
16681722
1669
- cGridBag anisoU = new cGridBag();
1670
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1671
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1672
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1673
- colorSection.add(anisoU);
1674
-
1675
- cGridBag anisoV = new cGridBag();
1676
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1677
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1678
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1679
- colorSection.add(anisoV);
1680
-
1681
- cGridBag shadowbias = new cGridBag();
1682
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1683
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1684
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1685
- colorSection.add(shadowbias);
1686
-
16871723 panel.add(new JSeparator());
16881724
16891725 panel.add(colorSection);
....@@ -1733,6 +1769,12 @@
17331769 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17341770 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17351771 diffuseSection.add(fakedepth);
1772
+
1773
+ cGridBag shadowbias = new cGridBag();
1774
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1775
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1776
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1777
+ diffuseSection.add(shadowbias);
17361778
17371779 panel.add(new JSeparator());
17381780
....@@ -1784,6 +1826,18 @@
17841826 // aConstraints.gridy += 1;
17851827 // aConstraints.gridwidth = 1;
17861828
1829
+ cGridBag anisoU = new cGridBag();
1830
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1831
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1832
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1833
+ specularSection.add(anisoU);
1834
+
1835
+ cGridBag anisoV = new cGridBag();
1836
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1837
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1838
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1839
+ specularSection.add(anisoV);
1840
+
17871841
17881842 panel.add(new JSeparator());
17891843
....@@ -1791,35 +1845,35 @@
17911845
17921846 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17931847
1794
- cGridBag globalSection = new cGridBag().setVertical(true);
1848
+ //cGridBag globalSection = new cGridBag().setVertical(true);
17951849
17961850 cGridBag camera = new cGridBag();
17971851 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
17981852 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17991853 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1800
- globalSection.add(camera);
1854
+ colorSection.add(camera);
18011855
18021856 cGridBag ambient = new cGridBag();
18031857 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18041858 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18051859 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1806
- globalSection.add(ambient);
1860
+ colorSection.add(ambient);
18071861
18081862 cGridBag backlit = new cGridBag();
18091863 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18101864 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18111865 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1812
- globalSection.add(backlit);
1866
+ colorSection.add(backlit);
18131867
18141868 cGridBag opacity = new cGridBag();
18151869 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
18161870 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18171871 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1818
- globalSection.add(opacity);
1872
+ colorSection.add(opacity);
18191873
1820
- panel.add(new JSeparator());
1874
+ //panel.add(new JSeparator());
18211875
1822
- panel.add(globalSection);
1876
+ //panel.add(globalSection);
18231877
18241878 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18251879
....@@ -1926,8 +1980,9 @@
19261980 // 3D models
19271981 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19281982 {
1929
- lastConverter = new com.jmex.model.converters.MaxToJme();
1930
- LoadFile(filename, lastConverter);
1983
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
1984
+ //LoadFile(filename, lastConverter);
1985
+ LoadObjFile(filename); // New 3ds loader
19311986 continue;
19321987 }
19331988 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2653,6 +2708,7 @@
26532708 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26542709 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26552710 }
2711
+
26562712 //cJME.count++;
26572713 //cJME.count %= 12;
26582714 if (gc)
....@@ -2836,6 +2892,7 @@
28362892 }
28372893 }
28382894 }
2895
+
28392896 cFileSystemPane FSPane;
28402897
28412898 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2889,6 +2946,7 @@
28892946 }
28902947 }
28912948 }
2949
+
28922950 freezematerial = false;
28932951 }
28942952
....@@ -3007,12 +3065,17 @@
30073065 // }
30083066
30093067 /**/
3010
- if (deselect)
3068
+ if (deselect || child == null)
30113069 {
30123070 //group.deselectAll();
30133071 //freeze = true;
30143072 GetTree().clearSelection();
30153073 //freeze = false;
3074
+
3075
+ if (child == null)
3076
+ {
3077
+ return;
3078
+ }
30163079 }
30173080
30183081 //group.addSelectee(child);
....@@ -3336,9 +3399,9 @@
33363399 {
33373400 Close();
33383401 //return true;
3339
- } else if (source == loadItem)
3402
+ } else if (source == openItem)
33403403 {
3341
- load();
3404
+ Open();
33423405 //return true;
33433406 } else if (source == newItem)
33443407 {
....@@ -3363,6 +3426,10 @@
33633426 {
33643427 generatePOV();
33653428 //return true;
3429
+ } else if (event.getSource() == archiveItem)
3430
+ {
3431
+ cTools.Archive(frame);
3432
+ return;
33663433 } else if (source == zBufferItem)
33673434 {
33683435 try
....@@ -3414,8 +3481,8 @@
34143481 try
34153482 {
34163483 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3417
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3418
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3484
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3485
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34193486
34203487 Object3D parent = o.parent;
34213488 o.parent = null;
....@@ -3426,10 +3493,14 @@
34263493
34273494 out.flush();
34283495
3429
- zstream.close();
3496
+ baos //zstream
3497
+ .close();
34303498 out.close();
34313499
3432
- return baos.toByteArray();
3500
+ byte[] bytes = baos.toByteArray();
3501
+
3502
+ System.out.println("save #bytes = " + bytes.length);
3503
+ return bytes;
34333504 } catch (Exception e)
34343505 {
34353506 System.err.println(e);
....@@ -3439,13 +3510,16 @@
34393510
34403511 static public Object Uncompress(byte[] bytes)
34413512 {
3442
- System.out.println("#bytes = " + bytes.length);
3513
+ System.out.println("restore #bytes = " + bytes.length);
34433514 try
34443515 {
34453516 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3446
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3447
- ObjectInputStream in = new ObjectInputStream(istream);
3517
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3518
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34483519 Object obj = in.readObject();
3520
+
3521
+ bais //istream
3522
+ .close();
34493523 in.close();
34503524
34513525 return obj;
....@@ -3504,6 +3578,27 @@
35043578
35053579 public void Save()
35063580 {
3581
+ Save(true);
3582
+ }
3583
+
3584
+ private boolean Equal(byte[] compress, byte[] name)
3585
+ {
3586
+ if (compress.length != name.length)
3587
+ {
3588
+ return false;
3589
+ }
3590
+
3591
+ for (int i=compress.length; --i>=0;)
3592
+ {
3593
+ if (compress[i] != name[i])
3594
+ return false;
3595
+ }
3596
+
3597
+ return true;
3598
+ }
3599
+
3600
+ public boolean Save(boolean user)
3601
+ {
35073602 System.err.println("Save");
35083603
35093604 cRadio tab = GetCurrentTab();
....@@ -3513,20 +3608,42 @@
35133608
35143609 copy.ExtractBigData(hashtable);
35153610
3516
- //EditorFrame.m_MainFrame.requestFocusInWindow();
3517
- tab.graphs[tab.undoindex++] = Compress(copy);
3518
-
3519
- copy.RestoreBigData(hashtable);
3611
+ byte[] compress = Compress(copy);
35203612
35213613 CameraPane.SWITCH = temp;
35223614
3615
+ boolean thesame = false;
3616
+
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
+ }
3622
+
3623
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3624
+ if (!thesame)
3625
+ {
3626
+ //tab.user[tab.undoindex] = user;
3627
+ boolean increment = tab.graphs[tab.undoindex] == null;
3628
+
3629
+ tab.graphs[tab.undoindex] = compress;
3630
+
3631
+ if (increment)
3632
+ tab.undoindex++;
3633
+ }
3634
+
3635
+ copy.RestoreBigData(hashtable);
3636
+
35233637 //assert(hashtable.isEmpty());
35243638
35253639 for (int i = tab.undoindex; i < tab.graphs.length; i++)
35263640 {
3527
- tab.graphs[i] = null;
3641
+ //tab.user[i] = false;
3642
+ // tab.graphs[i] = null;
35283643 }
35293644
3645
+ SetUndoStates();
3646
+
35303647 // test save
35313648 if (false)
35323649 {
....@@ -3545,10 +3662,14 @@
35453662 e.printStackTrace();
35463663 }
35473664 }
3665
+
3666
+ return !thesame;
35483667 }
35493668
35503669 void CopyChanged(Object3D obj)
35513670 {
3671
+ SetUndoStates();
3672
+
35523673 boolean temp = CameraPane.SWITCH;
35533674 CameraPane.SWITCH = false;
35543675
....@@ -3588,7 +3709,18 @@
35883709 refreshContents();
35893710 }
35903711
3591
- public void Undo()
3712
+ cButton undoButton;
3713
+ cButton redoButton;
3714
+
3715
+ void SetUndoStates()
3716
+ {
3717
+ cRadio tab = GetCurrentTab();
3718
+
3719
+ undoButton.setEnabled(tab.undoindex > 0);
3720
+ redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3721
+ }
3722
+
3723
+ public boolean Undo()
35923724 {
35933725 System.err.println("Undo");
35943726
....@@ -3597,18 +3729,27 @@
35973729 if (tab.undoindex == 0)
35983730 {
35993731 java.awt.Toolkit.getDefaultToolkit().beep();
3600
- return;
3732
+ return false;
36013733 }
36023734
3603
- if (tab.graphs[tab.undoindex] == null)
3735
+ if (tab.graphs[tab.undoindex] == null) // || !tab.user[tab.undoindex])
36043736 {
3605
- Save();
3606
- tab.undoindex -= 1;
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
+ }
36073746 }
36083747
36093748 tab.undoindex -= 1;
36103749
36113750 CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3751
+
3752
+ return true;
36123753 }
36133754
36143755 public void Redo()
....@@ -3624,6 +3765,9 @@
36243765 tab.undoindex += 1;
36253766
36263767 CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3768
+
3769
+ //if (!tab.user[tab.undoindex])
3770
+ // tab.graphs[tab.undoindex] = null;
36273771 }
36283772
36293773 void ImportGFD()
....@@ -4586,8 +4730,8 @@
45864730
45874731 if (readobj != null)
45884732 {
4589
- if (Globals.SAVEONMAKE)
4590
- Save();
4733
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4734
+ // Save();
45914735 try
45924736 {
45934737 //readobj.deepCopySelf(copy);
....@@ -4648,7 +4792,7 @@
46484792 }
46494793 }
46504794
4651
- void load() // throws ClassNotFoundException
4795
+ void Open() // throws ClassNotFoundException
46524796 {
46534797 if (Grafreed.standAlone)
46544798 {
....@@ -4765,6 +4909,8 @@
47654909 String filename = browser.getFile();
47664910 if (filename != null && filename.length() > 0)
47674911 {
4912
+ if (!filename.endsWith(".gfd"))
4913
+ filename += ".gfd";
47684914 lastname = browser.getDirectory() + filename;
47694915 save();
47704916 }
....@@ -4931,7 +5077,7 @@
49315077 MenuBar menuBar;
49325078 Menu fileMenu;
49335079 MenuItem newItem;
4934
- MenuItem loadItem;
5080
+ MenuItem openItem;
49355081 MenuItem saveItem;
49365082 MenuItem saveAsItem;
49375083 MenuItem exportAsItem;
....@@ -4954,6 +5100,7 @@
49545100 CheckboxMenuItem toggleSwitchItem;
49555101 CheckboxMenuItem toggleRootItem;
49565102 CheckboxMenuItem animationItem;
5103
+ MenuItem archiveItem;
49575104 CheckboxMenuItem toggleHandleItem;
49585105 CheckboxMenuItem togglePaintItem;
49595106 JSplitPane mainPanel;