Normand Briere
2019-07-17 a5580a47d246c1272b10adba68070f6e13da5e41
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.
....@@ -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
....@@ -347,7 +350,7 @@
347350 frame.setMenuBar(menuBar = new MenuBar());
348351 menuBar.add(fileMenu = new Menu("File"));
349352 fileMenu.add(newItem = new MenuItem("New"));
350
- fileMenu.add(loadItem = new MenuItem("Open..."));
353
+ fileMenu.add(openItem = new MenuItem("Open..."));
351354
352355 //oe.menuBar.add(menu = new Menu("Include"));
353356 Menu menu = new Menu("Import");
....@@ -379,7 +382,7 @@
379382 }
380383
381384 newItem.addActionListener(this);
382
- loadItem.addActionListener(this);
385
+ openItem.addActionListener(this);
383386 saveItem.addActionListener(this);
384387 saveAsItem.addActionListener(this);
385388 exportAsItem.addActionListener(this);
....@@ -446,7 +449,7 @@
446449 // TEXTAREA infoarea.setLineWrap(true);
447450 // TEXTAREA infoarea.setWrapStyleWord(true);
448451 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
449
- infoPanel.setPreferredSize(new Dimension(50, 200));
452
+ infoPanel.setPreferredSize(new Dimension(1, 1));
450453 infoPanel.setName("Info");
451454 //infoPanel.setLayout(new BorderLayout());
452455 //infoPanel.add(createTextPane());
....@@ -458,7 +461,14 @@
458461 mainPanel.setDividerSize(9);
459462 mainPanel.setDividerLocation(0.5); //1.0);
460463 mainPanel.setResizeWeight(0.5);
461
-
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
+
462472 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
463473 //mainPanel.setLayout(new GridBagLayout());
464474 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -689,8 +699,8 @@
689699 }
690700 }
691701
692
-static GraphicsDevice device = GraphicsEnvironment
693
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
702
+//static GraphicsDevice device = GraphicsEnvironment
703
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
694704
695705 Rectangle keeprect;
696706 cRadio radio;
....@@ -711,10 +721,19 @@
711721 void Minimize()
712722 {
713723 frame.setState(Frame.ICONIFIED);
724
+ frame.validate();
714725 }
715726
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={}
716730 void Maximize()
717731 {
732
+ if (CameraPane.FULLSCREEN)
733
+ {
734
+ ToggleFullScreen();
735
+ }
736
+
718737 if (maximized)
719738 {
720739 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -722,22 +741,36 @@
722741 else
723742 {
724743 keeprect = frame.getBounds();
725
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
726
- Dimension rect2 = frame.getToolkit().getScreenSize();
727
- 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);
728747 // frame.setState(Frame.MAXIMIZED_BOTH);
748
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
729749 }
730750
731751 maximized ^= true;
752
+
753
+ frame.validate();
732754 }
755
+
756
+ cButton minButton;
757
+ cButton maxButton;
758
+ cButton fullButton;
733759
734760 void ToggleFullScreen()
735761 {
762
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
763
+
736764 cameraView.ToggleFullScreen();
737765
738766 if (!CameraPane.FULLSCREEN)
739767 {
740768 device.setFullScreenWindow(null);
769
+ frame.dispose();
770
+ frame.setUndecorated(false);
771
+ frame.validate();
772
+ frame.setVisible(true);
773
+
741774 //frame.setVisible(false);
742775 // frame.removeNotify();
743776 // frame.setUndecorated(false);
....@@ -747,7 +780,7 @@
747780 // X frame.getContentPane().remove(/*"Center",*/bigThree);
748781 // X framePanel.add(bigThree);
749782 // X frame.getContentPane().add(/*"Center",*/framePanel);
750
- framePanel.setDividerLocation(1);
783
+ framePanel.setDividerLocation(46);
751784
752785 //frame.setVisible(true);
753786 radio.layout = keepButton;
....@@ -762,7 +795,12 @@
762795 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
763796 // frame.getToolkit().getScreenSize().height);
764797 //frame.setVisible(false);
798
+
799
+ frame.dispose();
800
+ frame.setUndecorated(true);
765801 device.setFullScreenWindow(frame);
802
+ frame.validate();
803
+ frame.setVisible(true);
766804 // frame.removeNotify();
767805 // frame.setUndecorated(true);
768806 // frame.addNotify();
....@@ -775,7 +813,30 @@
775813 radio.layout.doClick();
776814 //frame.setVisible(true);
777815 }
816
+ frame.validate();
778817 }
818
+
819
+ private byte[] CompressCopy()
820
+ {
821
+ boolean temp = CameraPane.SWITCH;
822
+ CameraPane.SWITCH = false;
823
+
824
+ copy.ExtractBigData(versiontable);
825
+ // if (copy == client)
826
+
827
+ byte[] versions[] = copy.versions;
828
+ copy.versions = null;
829
+
830
+ byte[] compress = Compress(copy);
831
+
832
+ copy.versions = versions;
833
+
834
+ copy.RestoreBigData(versiontable);
835
+
836
+ CameraPane.SWITCH = temp;
837
+
838
+ return compress;
839
+ }
779840
780841 private JTextPane createTextPane()
781842 {
....@@ -1107,7 +1168,7 @@
11071168 namePanel = new cGridBag();
11081169
11091170 nameField = AddText(namePanel, copy.GetName());
1110
- namePanel.add(nameField);
1171
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11111172 oe.ctrlPanel.add(namePanel);
11121173
11131174 oe.ctrlPanel.Return();
....@@ -1125,20 +1186,21 @@
11251186 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11261187 hideCB.setToolTipText("Hide object");
11271188 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1128
- markCB.setToolTipText("Set the animation target transform");
1189
+ markCB.setToolTipText("As animation target transform");
11291190
11301191 setupPanel2 = new cGridBag().setVertical(false);
11311192
11321193 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11331194 rewindCB.setToolTipText("Rewind animation");
11341195
1135
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1136
- randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1196
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1197
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11371198
1199
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1200
+ link2masterCB.setToolTipText("Attach to support");
1201
+
11381202 if (Globals.ADVANCED)
11391203 {
1140
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1141
- link2masterCB.setToolTipText("Attach to support");
11421204 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11431205 speedupCB.setToolTipText("Option motion capture");
11441206 }
....@@ -1454,7 +1516,10 @@
14541516 // north.add(ctrlPanel, BorderLayout.NORTH);
14551517 // objectPanel.add(north);
14561518 objectPanel.add(editPanel);
1457
- objectPanel.add(infoPanel);
1519
+
1520
+ //if (Globals.ADVANCED)
1521
+ objectPanel.add(infoPanel);
1522
+
14581523 objectPanel.add(toolboxPanel);
14591524
14601525 /*
....@@ -1563,9 +1628,9 @@
15631628 // aConstraints.gridheight = 1;
15641629
15651630 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1566
- framePanel.setContinuousLayout(true);
1567
- framePanel.setOneTouchExpandable(true);
1568
- framePanel.setDividerLocation(0.8);
1631
+ framePanel.setContinuousLayout(false);
1632
+ framePanel.setOneTouchExpandable(false);
1633
+ //.setDividerLocation(0.8);
15691634 //framePanel.setDividerSize(15);
15701635 //framePanel.setResizeWeight(0.15);
15711636 framePanel.setName("Frame");
....@@ -1584,12 +1649,13 @@
15841649
15851650 frame.setSize(1280, 860);
15861651
1587
- frame.validate();
1588
- frame.setVisible(true);
1589
-
15901652 cameraView.requestFocusInWindow();
15911653
15921654 gridPanel.setDividerLocation(1.0);
1655
+
1656
+ frame.validate();
1657
+
1658
+ frame.setVisible(true);
15931659
15941660 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
15951661 frame.addWindowListener(new WindowAdapter()
....@@ -1676,24 +1742,6 @@
16761742 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16771743 colorSection.add(texture);
16781744
1679
- cGridBag anisoU = new cGridBag();
1680
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1681
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1682
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1683
- colorSection.add(anisoU);
1684
-
1685
- cGridBag anisoV = new cGridBag();
1686
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1687
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1688
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1689
- colorSection.add(anisoV);
1690
-
1691
- cGridBag shadowbias = new cGridBag();
1692
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1693
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1694
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1695
- colorSection.add(shadowbias);
1696
-
16971745 panel.add(new JSeparator());
16981746
16991747 panel.add(colorSection);
....@@ -1743,6 +1791,12 @@
17431791 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17441792 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17451793 diffuseSection.add(fakedepth);
1794
+
1795
+ cGridBag shadowbias = new cGridBag();
1796
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1797
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1798
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1799
+ diffuseSection.add(shadowbias);
17461800
17471801 panel.add(new JSeparator());
17481802
....@@ -1794,6 +1848,18 @@
17941848 // aConstraints.gridy += 1;
17951849 // aConstraints.gridwidth = 1;
17961850
1851
+ cGridBag anisoU = new cGridBag();
1852
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1853
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1854
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1855
+ specularSection.add(anisoU);
1856
+
1857
+ cGridBag anisoV = new cGridBag();
1858
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1859
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1860
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1861
+ specularSection.add(anisoV);
1862
+
17971863
17981864 panel.add(new JSeparator());
17991865
....@@ -1801,35 +1867,35 @@
18011867
18021868 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18031869
1804
- cGridBag globalSection = new cGridBag().setVertical(true);
1870
+ //cGridBag globalSection = new cGridBag().setVertical(true);
18051871
18061872 cGridBag camera = new cGridBag();
18071873 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
18081874 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18091875 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1810
- globalSection.add(camera);
1876
+ colorSection.add(camera);
18111877
18121878 cGridBag ambient = new cGridBag();
18131879 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18141880 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18151881 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1816
- globalSection.add(ambient);
1882
+ colorSection.add(ambient);
18171883
18181884 cGridBag backlit = new cGridBag();
18191885 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18201886 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18211887 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1822
- globalSection.add(backlit);
1888
+ colorSection.add(backlit);
18231889
18241890 cGridBag opacity = new cGridBag();
18251891 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
18261892 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18271893 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1828
- globalSection.add(opacity);
1894
+ colorSection.add(opacity);
18291895
1830
- panel.add(new JSeparator());
1896
+ //panel.add(new JSeparator());
18311897
1832
- panel.add(globalSection);
1898
+ //panel.add(globalSection);
18331899
18341900 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18351901
....@@ -1936,8 +2002,9 @@
19362002 // 3D models
19372003 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19382004 {
1939
- lastConverter = new com.jmex.model.converters.MaxToJme();
1940
- LoadFile(filename, lastConverter);
2005
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2006
+ //LoadFile(filename, lastConverter);
2007
+ LoadObjFile(filename); // New 3ds loader
19412008 continue;
19422009 }
19432010 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2663,6 +2730,7 @@
26632730 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26642731 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26652732 }
2733
+
26662734 //cJME.count++;
26672735 //cJME.count %= 12;
26682736 if (gc)
....@@ -2846,6 +2914,7 @@
28462914 }
28472915 }
28482916 }
2917
+
28492918 cFileSystemPane FSPane;
28502919
28512920 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2899,6 +2968,7 @@
28992968 }
29002969 }
29012970 }
2971
+
29022972 freezematerial = false;
29032973 }
29042974
....@@ -3017,12 +3087,17 @@
30173087 // }
30183088
30193089 /**/
3020
- if (deselect)
3090
+ if (deselect || child == null)
30213091 {
30223092 //group.deselectAll();
30233093 //freeze = true;
30243094 GetTree().clearSelection();
30253095 //freeze = false;
3096
+
3097
+ if (child == null)
3098
+ {
3099
+ return;
3100
+ }
30263101 }
30273102
30283103 //group.addSelectee(child);
....@@ -3346,9 +3421,9 @@
33463421 {
33473422 Close();
33483423 //return true;
3349
- } else if (source == loadItem)
3424
+ } else if (source == openItem)
33503425 {
3351
- load();
3426
+ Open();
33523427 //return true;
33533428 } else if (source == newItem)
33543429 {
....@@ -3373,6 +3448,10 @@
33733448 {
33743449 generatePOV();
33753450 //return true;
3451
+ } else if (event.getSource() == archiveItem)
3452
+ {
3453
+ cTools.Archive(frame);
3454
+ return;
33763455 } else if (source == zBufferItem)
33773456 {
33783457 try
....@@ -3424,8 +3503,8 @@
34243503 try
34253504 {
34263505 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3427
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3428
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3506
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3507
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34293508
34303509 Object3D parent = o.parent;
34313510 o.parent = null;
....@@ -3436,10 +3515,14 @@
34363515
34373516 out.flush();
34383517
3439
- zstream.close();
3518
+ baos //zstream
3519
+ .close();
34403520 out.close();
34413521
3442
- return baos.toByteArray();
3522
+ byte[] bytes = baos.toByteArray();
3523
+
3524
+ System.out.println("save #bytes = " + bytes.length);
3525
+ return bytes;
34433526 } catch (Exception e)
34443527 {
34453528 System.err.println(e);
....@@ -3449,13 +3532,16 @@
34493532
34503533 static public Object Uncompress(byte[] bytes)
34513534 {
3452
- System.out.println("#bytes = " + bytes.length);
3535
+ System.out.println("restore #bytes = " + bytes.length);
34533536 try
34543537 {
34553538 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3456
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3457
- ObjectInputStream in = new ObjectInputStream(istream);
3539
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3540
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34583541 Object obj = in.readObject();
3542
+
3543
+ bais //istream
3544
+ .close();
34593545 in.close();
34603546
34613547 return obj;
....@@ -3510,31 +3596,67 @@
35103596 return null;
35113597 }
35123598
3513
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35143599
35153600 public void Save()
3601
+ {
3602
+ //Save(true);
3603
+ Replace();
3604
+ }
3605
+
3606
+ private boolean Equal(byte[] compress, byte[] name)
3607
+ {
3608
+ if (compress.length != name.length)
3609
+ {
3610
+ return false;
3611
+ }
3612
+
3613
+ for (int i=compress.length; --i>=0;)
3614
+ {
3615
+ if (compress[i] != name[i])
3616
+ return false;
3617
+ }
3618
+
3619
+ return true;
3620
+ }
3621
+
3622
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3623
+
3624
+ public boolean Save(boolean user)
35163625 {
35173626 System.err.println("Save");
35183627
35193628 cRadio tab = GetCurrentTab();
35203629
3521
- boolean temp = CameraPane.SWITCH;
3522
- CameraPane.SWITCH = false;
3630
+ byte[] compress = CompressCopy();
35233631
3524
- copy.ExtractBigData(hashtable);
3632
+ boolean thesame = false;
3633
+
3634
+ // Quick heuristic using length. Works only when stream is compressed.
3635
+ if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3636
+ {
3637
+ thesame = true;
3638
+ }
35253639
35263640 //EditorFrame.m_MainFrame.requestFocusInWindow();
3527
- tab.graphs[tab.undoindex++] = Compress(copy);
3641
+ if (!thesame)
3642
+ {
3643
+ //tab.user[tab.versionindex] = user;
3644
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
3645
+
3646
+ copy.versions[++copy.versionindex] = compress;
3647
+
3648
+ // if (increment)
3649
+ // tab.versionindex++;
3650
+ }
35283651
3529
- copy.RestoreBigData(hashtable);
3652
+ //copy.RestoreBigData(versiontable);
35303653
3531
- CameraPane.SWITCH = temp;
3532
-
35333654 //assert(hashtable.isEmpty());
35343655
3535
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3656
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
35363657 {
3537
- tab.graphs[i] = null;
3658
+ //tab.user[i] = false;
3659
+ copy.versions[i] = null;
35383660 }
35393661
35403662 SetUndoStates();
....@@ -3544,7 +3666,7 @@
35443666 {
35453667 try
35463668 {
3547
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3669
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35483670 ObjectOutputStream p = new ObjectOutputStream(ostream);
35493671
35503672 p.writeObject(copy);
....@@ -3557,6 +3679,8 @@
35573679 e.printStackTrace();
35583680 }
35593681 }
3682
+
3683
+ return !thesame;
35603684 }
35613685
35623686 void CopyChanged(Object3D obj)
....@@ -3566,7 +3690,7 @@
35663690 boolean temp = CameraPane.SWITCH;
35673691 CameraPane.SWITCH = false;
35683692
3569
- copy.ExtractBigData(hashtable);
3693
+ copy.ExtractBigData(versiontable);
35703694
35713695 copy.clear();
35723696
....@@ -3575,7 +3699,7 @@
35753699 copy.add(obj.get(i));
35763700 }
35773701
3578
- copy.RestoreBigData(hashtable);
3702
+ copy.RestoreBigData(versiontable);
35793703
35803704 CameraPane.SWITCH = temp;
35813705
....@@ -3603,52 +3727,102 @@
36033727 }
36043728
36053729 cButton undoButton;
3730
+ cButton restoreButton;
3731
+ cButton replaceButton;
36063732 cButton redoButton;
36073733
36083734 void SetUndoStates()
36093735 {
36103736 cRadio tab = GetCurrentTab();
36113737
3612
- undoButton.setEnabled(tab.undoindex > 0);
3613
- redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3738
+ restoreButton.setEnabled(copy.versionindex != -1);
3739
+ replaceButton.setEnabled(copy.versionindex != -1);
3740
+ undoButton.setEnabled(copy.versionindex > 0);
3741
+ redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
36143742 }
36153743
3616
- public void Undo()
3744
+ public boolean Undo()
36173745 {
36183746 System.err.println("Undo");
36193747
36203748 cRadio tab = GetCurrentTab();
36213749
3622
- if (tab.undoindex == 0)
3750
+ if (copy.versionindex == 0)
36233751 {
36243752 java.awt.Toolkit.getDefaultToolkit().beep();
3625
- return;
3753
+ return false;
36263754 }
36273755
3628
- if (tab.graphs[tab.undoindex] == null)
3756
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3757
+// {
3758
+// if (Save(false))
3759
+// tab.versionindex -= 1;
3760
+// else
3761
+// {
3762
+// if (tab.versionindex <= 0)
3763
+// return false;
3764
+// else
3765
+// tab.versionindex -= 1;
3766
+// }
3767
+// }
3768
+
3769
+ copy.versionindex -= 1;
3770
+
3771
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3772
+
3773
+ return true;
3774
+ }
3775
+
3776
+ public boolean Restore()
3777
+ {
3778
+ System.err.println("Restore");
3779
+
3780
+ cRadio tab = GetCurrentTab();
3781
+
3782
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
36293783 {
3630
- Save();
3631
- tab.undoindex -= 1;
3784
+ java.awt.Toolkit.getDefaultToolkit().beep();
3785
+ return false;
36323786 }
36333787
3634
- tab.undoindex -= 1;
3788
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3789
+
3790
+ return true;
3791
+ }
36353792
3636
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3793
+ public boolean Replace()
3794
+ {
3795
+ System.err.println("Replace");
3796
+
3797
+ cRadio tab = GetCurrentTab();
3798
+
3799
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3800
+ {
3801
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
3802
+ return false;
3803
+ }
3804
+
3805
+ copy.versions[copy.versionindex] = CompressCopy();
3806
+
3807
+ return true;
36373808 }
36383809
36393810 public void Redo()
36403811 {
36413812 cRadio tab = GetCurrentTab();
36423813
3643
- if (tab.graphs[tab.undoindex + 1] == null)
3814
+ if (copy.versions[copy.versionindex + 1] == null)
36443815 {
36453816 java.awt.Toolkit.getDefaultToolkit().beep();
36463817 return;
36473818 }
36483819
3649
- tab.undoindex += 1;
3820
+ copy.versionindex += 1;
36503821
3651
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3822
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3823
+
3824
+ //if (!tab.user[tab.versionindex])
3825
+ // tab.graphs[tab.versionindex] = null;
36523826 }
36533827
36543828 void ImportGFD()
....@@ -3944,9 +4118,22 @@
39444118 //copy.Touch();
39454119 }
39464120
4121
+ cNumberSlider versionField;
4122
+
39474123 public void stateChanged(ChangeEvent e)
39484124 {
39494125 // assert(false);
4126
+ if (e.getSource() == versionField)
4127
+ {
4128
+ int version = versionField.getInteger();
4129
+
4130
+ if (copy.versions[version] != null)
4131
+ {
4132
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4133
+ }
4134
+
4135
+ return;
4136
+ }
39504137
39514138 if (freezematerial)
39524139 {
....@@ -4295,7 +4482,7 @@
42954482
42964483 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
42974484 {
4298
- if (Globals.SAVEONMAKE) // && resetmodel)
4485
+ if (Globals.REPLACEONMAKE) // && resetmodel)
42994486 Save();
43004487 //Tween.set(thing, 0).target(1).start(tweenManager);
43014488 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4611,8 +4798,8 @@
46114798
46124799 if (readobj != null)
46134800 {
4614
- if (Globals.SAVEONMAKE)
4615
- Save();
4801
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4802
+ // Save();
46164803 try
46174804 {
46184805 //readobj.deepCopySelf(copy);
....@@ -4667,13 +4854,18 @@
46674854 c.addChild(csg);
46684855 }
46694856
4857
+ copy.versions = readobj.versions;
4858
+ copy.versionindex = readobj.versionindex;
4859
+
4860
+ SetUndoStates();
4861
+
46704862 ResetModel();
46714863 copy.HardTouch(); // recompile?
46724864 refreshContents();
46734865 }
46744866 }
46754867
4676
- void load() // throws ClassNotFoundException
4868
+ void Open() // throws ClassNotFoundException
46774869 {
46784870 if (Grafreed.standAlone)
46794871 {
....@@ -4958,7 +5150,7 @@
49585150 MenuBar menuBar;
49595151 Menu fileMenu;
49605152 MenuItem newItem;
4961
- MenuItem loadItem;
5153
+ MenuItem openItem;
49625154 MenuItem saveItem;
49635155 MenuItem saveAsItem;
49645156 MenuItem exportAsItem;
....@@ -4981,6 +5173,7 @@
49815173 CheckboxMenuItem toggleSwitchItem;
49825174 CheckboxMenuItem toggleRootItem;
49835175 CheckboxMenuItem animationItem;
5176
+ MenuItem archiveItem;
49845177 CheckboxMenuItem toggleHandleItem;
49855178 CheckboxMenuItem togglePaintItem;
49865179 JSplitPane mainPanel;