Normand Briere
2019-07-17 a5580a47d246c1272b10adba68070f6e13da5e41
ObjEditor.java
....@@ -309,7 +309,7 @@
309309 //localCopy.parent = null;
310310
311311 frame = new JFrame();
312
- frame.setUndecorated(true);
312
+ frame.setUndecorated(false);
313313 objEditor = this;
314314 this.callee = callee;
315315
....@@ -350,7 +350,7 @@
350350 frame.setMenuBar(menuBar = new MenuBar());
351351 menuBar.add(fileMenu = new Menu("File"));
352352 fileMenu.add(newItem = new MenuItem("New"));
353
- fileMenu.add(loadItem = new MenuItem("Open..."));
353
+ fileMenu.add(openItem = new MenuItem("Open..."));
354354
355355 //oe.menuBar.add(menu = new Menu("Include"));
356356 Menu menu = new Menu("Import");
....@@ -382,7 +382,7 @@
382382 }
383383
384384 newItem.addActionListener(this);
385
- loadItem.addActionListener(this);
385
+ openItem.addActionListener(this);
386386 saveItem.addActionListener(this);
387387 saveAsItem.addActionListener(this);
388388 exportAsItem.addActionListener(this);
....@@ -449,7 +449,7 @@
449449 // TEXTAREA infoarea.setLineWrap(true);
450450 // TEXTAREA infoarea.setWrapStyleWord(true);
451451 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
452
- infoPanel.setPreferredSize(new Dimension(50, 200));
452
+ infoPanel.setPreferredSize(new Dimension(1, 1));
453453 infoPanel.setName("Info");
454454 //infoPanel.setLayout(new BorderLayout());
455455 //infoPanel.add(createTextPane());
....@@ -463,10 +463,11 @@
463463 mainPanel.setResizeWeight(0.5);
464464
465465 //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!"));
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!"));
469469
470
+ mainPanel.setUI(new BasicSplitPaneUI());
470471
471472 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
472473 //mainPanel.setLayout(new GridBagLayout());
....@@ -698,8 +699,8 @@
698699 }
699700 }
700701
701
-static GraphicsDevice device = GraphicsEnvironment
702
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
702
+//static GraphicsDevice device = GraphicsEnvironment
703
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
703704
704705 Rectangle keeprect;
705706 cRadio radio;
....@@ -720,10 +721,19 @@
720721 void Minimize()
721722 {
722723 frame.setState(Frame.ICONIFIED);
724
+ frame.validate();
723725 }
724726
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={}
725730 void Maximize()
726731 {
732
+ if (CameraPane.FULLSCREEN)
733
+ {
734
+ ToggleFullScreen();
735
+ }
736
+
727737 if (maximized)
728738 {
729739 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -731,22 +741,36 @@
731741 else
732742 {
733743 keeprect = frame.getBounds();
734
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
735
- Dimension rect2 = frame.getToolkit().getScreenSize();
736
- 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);
737747 // frame.setState(Frame.MAXIMIZED_BOTH);
748
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
738749 }
739750
740751 maximized ^= true;
752
+
753
+ frame.validate();
741754 }
755
+
756
+ cButton minButton;
757
+ cButton maxButton;
758
+ cButton fullButton;
742759
743760 void ToggleFullScreen()
744761 {
762
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
763
+
745764 cameraView.ToggleFullScreen();
746765
747766 if (!CameraPane.FULLSCREEN)
748767 {
749768 device.setFullScreenWindow(null);
769
+ frame.dispose();
770
+ frame.setUndecorated(false);
771
+ frame.validate();
772
+ frame.setVisible(true);
773
+
750774 //frame.setVisible(false);
751775 // frame.removeNotify();
752776 // frame.setUndecorated(false);
....@@ -756,7 +780,7 @@
756780 // X frame.getContentPane().remove(/*"Center",*/bigThree);
757781 // X framePanel.add(bigThree);
758782 // X frame.getContentPane().add(/*"Center",*/framePanel);
759
- framePanel.setDividerLocation(1);
783
+ framePanel.setDividerLocation(46);
760784
761785 //frame.setVisible(true);
762786 radio.layout = keepButton;
....@@ -771,7 +795,12 @@
771795 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
772796 // frame.getToolkit().getScreenSize().height);
773797 //frame.setVisible(false);
798
+
799
+ frame.dispose();
800
+ frame.setUndecorated(true);
774801 device.setFullScreenWindow(frame);
802
+ frame.validate();
803
+ frame.setVisible(true);
775804 // frame.removeNotify();
776805 // frame.setUndecorated(true);
777806 // frame.addNotify();
....@@ -784,7 +813,30 @@
784813 radio.layout.doClick();
785814 //frame.setVisible(true);
786815 }
816
+ frame.validate();
787817 }
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
+ }
788840
789841 private JTextPane createTextPane()
790842 {
....@@ -1116,7 +1168,7 @@
11161168 namePanel = new cGridBag();
11171169
11181170 nameField = AddText(namePanel, copy.GetName());
1119
- namePanel.add(nameField);
1171
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11201172 oe.ctrlPanel.add(namePanel);
11211173
11221174 oe.ctrlPanel.Return();
....@@ -1141,13 +1193,14 @@
11411193 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11421194 rewindCB.setToolTipText("Rewind animation");
11431195
1144
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1196
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
11451197 randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11461198
1199
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1200
+ link2masterCB.setToolTipText("Attach to support");
1201
+
11471202 if (Globals.ADVANCED)
11481203 {
1149
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1150
- link2masterCB.setToolTipText("Attach to support");
11511204 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11521205 speedupCB.setToolTipText("Option motion capture");
11531206 }
....@@ -1463,7 +1516,10 @@
14631516 // north.add(ctrlPanel, BorderLayout.NORTH);
14641517 // objectPanel.add(north);
14651518 objectPanel.add(editPanel);
1466
- objectPanel.add(infoPanel);
1519
+
1520
+ //if (Globals.ADVANCED)
1521
+ objectPanel.add(infoPanel);
1522
+
14671523 objectPanel.add(toolboxPanel);
14681524
14691525 /*
....@@ -1572,9 +1628,9 @@
15721628 // aConstraints.gridheight = 1;
15731629
15741630 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1575
- framePanel.setContinuousLayout(true);
1576
- framePanel.setOneTouchExpandable(true);
1577
- framePanel.setDividerLocation(0.8);
1631
+ framePanel.setContinuousLayout(false);
1632
+ framePanel.setOneTouchExpandable(false);
1633
+ //.setDividerLocation(0.8);
15781634 //framePanel.setDividerSize(15);
15791635 //framePanel.setResizeWeight(0.15);
15801636 framePanel.setName("Frame");
....@@ -1593,12 +1649,13 @@
15931649
15941650 frame.setSize(1280, 860);
15951651
1596
- frame.validate();
1597
- frame.setVisible(true);
1598
-
15991652 cameraView.requestFocusInWindow();
16001653
16011654 gridPanel.setDividerLocation(1.0);
1655
+
1656
+ frame.validate();
1657
+
1658
+ frame.setVisible(true);
16021659
16031660 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16041661 frame.addWindowListener(new WindowAdapter()
....@@ -1685,24 +1742,6 @@
16851742 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16861743 colorSection.add(texture);
16871744
1688
- cGridBag anisoU = new cGridBag();
1689
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1690
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1691
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1692
- colorSection.add(anisoU);
1693
-
1694
- cGridBag anisoV = new cGridBag();
1695
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1696
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1697
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1698
- colorSection.add(anisoV);
1699
-
1700
- cGridBag shadowbias = new cGridBag();
1701
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1702
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1703
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1704
- colorSection.add(shadowbias);
1705
-
17061745 panel.add(new JSeparator());
17071746
17081747 panel.add(colorSection);
....@@ -1752,6 +1791,12 @@
17521791 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17531792 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17541793 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);
17551800
17561801 panel.add(new JSeparator());
17571802
....@@ -1803,6 +1848,18 @@
18031848 // aConstraints.gridy += 1;
18041849 // aConstraints.gridwidth = 1;
18051850
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
+
18061863
18071864 panel.add(new JSeparator());
18081865
....@@ -1810,35 +1867,35 @@
18101867
18111868 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18121869
1813
- cGridBag globalSection = new cGridBag().setVertical(true);
1870
+ //cGridBag globalSection = new cGridBag().setVertical(true);
18141871
18151872 cGridBag camera = new cGridBag();
18161873 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
18171874 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18181875 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1819
- globalSection.add(camera);
1876
+ colorSection.add(camera);
18201877
18211878 cGridBag ambient = new cGridBag();
18221879 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18231880 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18241881 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1825
- globalSection.add(ambient);
1882
+ colorSection.add(ambient);
18261883
18271884 cGridBag backlit = new cGridBag();
18281885 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18291886 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18301887 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1831
- globalSection.add(backlit);
1888
+ colorSection.add(backlit);
18321889
18331890 cGridBag opacity = new cGridBag();
18341891 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
18351892 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18361893 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1837
- globalSection.add(opacity);
1894
+ colorSection.add(opacity);
18381895
1839
- panel.add(new JSeparator());
1896
+ //panel.add(new JSeparator());
18401897
1841
- panel.add(globalSection);
1898
+ //panel.add(globalSection);
18421899
18431900 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18441901
....@@ -1945,8 +2002,9 @@
19452002 // 3D models
19462003 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19472004 {
1948
- lastConverter = new com.jmex.model.converters.MaxToJme();
1949
- LoadFile(filename, lastConverter);
2005
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2006
+ //LoadFile(filename, lastConverter);
2007
+ LoadObjFile(filename); // New 3ds loader
19502008 continue;
19512009 }
19522010 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2672,6 +2730,7 @@
26722730 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26732731 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26742732 }
2733
+
26752734 //cJME.count++;
26762735 //cJME.count %= 12;
26772736 if (gc)
....@@ -2855,6 +2914,7 @@
28552914 }
28562915 }
28572916 }
2917
+
28582918 cFileSystemPane FSPane;
28592919
28602920 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2908,6 +2968,7 @@
29082968 }
29092969 }
29102970 }
2971
+
29112972 freezematerial = false;
29122973 }
29132974
....@@ -3360,9 +3421,9 @@
33603421 {
33613422 Close();
33623423 //return true;
3363
- } else if (source == loadItem)
3424
+ } else if (source == openItem)
33643425 {
3365
- load();
3426
+ Open();
33663427 //return true;
33673428 } else if (source == newItem)
33683429 {
....@@ -3387,6 +3448,10 @@
33873448 {
33883449 generatePOV();
33893450 //return true;
3451
+ } else if (event.getSource() == archiveItem)
3452
+ {
3453
+ cTools.Archive(frame);
3454
+ return;
33903455 } else if (source == zBufferItem)
33913456 {
33923457 try
....@@ -3438,8 +3503,8 @@
34383503 try
34393504 {
34403505 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3441
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3442
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3506
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3507
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34433508
34443509 Object3D parent = o.parent;
34453510 o.parent = null;
....@@ -3450,10 +3515,14 @@
34503515
34513516 out.flush();
34523517
3453
- zstream.close();
3518
+ baos //zstream
3519
+ .close();
34543520 out.close();
34553521
3456
- return baos.toByteArray();
3522
+ byte[] bytes = baos.toByteArray();
3523
+
3524
+ System.out.println("save #bytes = " + bytes.length);
3525
+ return bytes;
34573526 } catch (Exception e)
34583527 {
34593528 System.err.println(e);
....@@ -3463,13 +3532,16 @@
34633532
34643533 static public Object Uncompress(byte[] bytes)
34653534 {
3466
- System.out.println("#bytes = " + bytes.length);
3535
+ System.out.println("restore #bytes = " + bytes.length);
34673536 try
34683537 {
34693538 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3470
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3471
- ObjectInputStream in = new ObjectInputStream(istream);
3539
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3540
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34723541 Object obj = in.readObject();
3542
+
3543
+ bais //istream
3544
+ .close();
34733545 in.close();
34743546
34753547 return obj;
....@@ -3524,31 +3596,67 @@
35243596 return null;
35253597 }
35263598
3527
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35283599
35293600 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)
35303625 {
35313626 System.err.println("Save");
35323627
35333628 cRadio tab = GetCurrentTab();
35343629
3535
- boolean temp = CameraPane.SWITCH;
3536
- CameraPane.SWITCH = false;
3630
+ byte[] compress = CompressCopy();
35373631
3538
- 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
+ }
35393639
35403640 //EditorFrame.m_MainFrame.requestFocusInWindow();
3541
- 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
+ }
35423651
3543
- copy.RestoreBigData(hashtable);
3652
+ //copy.RestoreBigData(versiontable);
35443653
3545
- CameraPane.SWITCH = temp;
3546
-
35473654 //assert(hashtable.isEmpty());
35483655
3549
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3656
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
35503657 {
3551
- tab.graphs[i] = null;
3658
+ //tab.user[i] = false;
3659
+ copy.versions[i] = null;
35523660 }
35533661
35543662 SetUndoStates();
....@@ -3558,7 +3666,7 @@
35583666 {
35593667 try
35603668 {
3561
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3669
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35623670 ObjectOutputStream p = new ObjectOutputStream(ostream);
35633671
35643672 p.writeObject(copy);
....@@ -3571,6 +3679,8 @@
35713679 e.printStackTrace();
35723680 }
35733681 }
3682
+
3683
+ return !thesame;
35743684 }
35753685
35763686 void CopyChanged(Object3D obj)
....@@ -3580,7 +3690,7 @@
35803690 boolean temp = CameraPane.SWITCH;
35813691 CameraPane.SWITCH = false;
35823692
3583
- copy.ExtractBigData(hashtable);
3693
+ copy.ExtractBigData(versiontable);
35843694
35853695 copy.clear();
35863696
....@@ -3589,7 +3699,7 @@
35893699 copy.add(obj.get(i));
35903700 }
35913701
3592
- copy.RestoreBigData(hashtable);
3702
+ copy.RestoreBigData(versiontable);
35933703
35943704 CameraPane.SWITCH = temp;
35953705
....@@ -3617,52 +3727,102 @@
36173727 }
36183728
36193729 cButton undoButton;
3730
+ cButton restoreButton;
3731
+ cButton replaceButton;
36203732 cButton redoButton;
36213733
36223734 void SetUndoStates()
36233735 {
36243736 cRadio tab = GetCurrentTab();
36253737
3626
- undoButton.setEnabled(tab.undoindex > 0);
3627
- 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);
36283742 }
36293743
3630
- public void Undo()
3744
+ public boolean Undo()
36313745 {
36323746 System.err.println("Undo");
36333747
36343748 cRadio tab = GetCurrentTab();
36353749
3636
- if (tab.undoindex == 0)
3750
+ if (copy.versionindex == 0)
36373751 {
36383752 java.awt.Toolkit.getDefaultToolkit().beep();
3639
- return;
3753
+ return false;
36403754 }
36413755
3642
- 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)
36433783 {
3644
- Save();
3645
- tab.undoindex -= 1;
3784
+ java.awt.Toolkit.getDefaultToolkit().beep();
3785
+ return false;
36463786 }
36473787
3648
- tab.undoindex -= 1;
3788
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3789
+
3790
+ return true;
3791
+ }
36493792
3650
- 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;
36513808 }
36523809
36533810 public void Redo()
36543811 {
36553812 cRadio tab = GetCurrentTab();
36563813
3657
- if (tab.graphs[tab.undoindex + 1] == null)
3814
+ if (copy.versions[copy.versionindex + 1] == null)
36583815 {
36593816 java.awt.Toolkit.getDefaultToolkit().beep();
36603817 return;
36613818 }
36623819
3663
- tab.undoindex += 1;
3820
+ copy.versionindex += 1;
36643821
3665
- 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;
36663826 }
36673827
36683828 void ImportGFD()
....@@ -3958,9 +4118,22 @@
39584118 //copy.Touch();
39594119 }
39604120
4121
+ cNumberSlider versionField;
4122
+
39614123 public void stateChanged(ChangeEvent e)
39624124 {
39634125 // 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
+ }
39644137
39654138 if (freezematerial)
39664139 {
....@@ -4309,7 +4482,7 @@
43094482
43104483 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
43114484 {
4312
- if (Globals.SAVEONMAKE) // && resetmodel)
4485
+ if (Globals.REPLACEONMAKE) // && resetmodel)
43134486 Save();
43144487 //Tween.set(thing, 0).target(1).start(tweenManager);
43154488 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4625,8 +4798,8 @@
46254798
46264799 if (readobj != null)
46274800 {
4628
- if (Globals.SAVEONMAKE)
4629
- Save();
4801
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4802
+ // Save();
46304803 try
46314804 {
46324805 //readobj.deepCopySelf(copy);
....@@ -4681,13 +4854,18 @@
46814854 c.addChild(csg);
46824855 }
46834856
4857
+ copy.versions = readobj.versions;
4858
+ copy.versionindex = readobj.versionindex;
4859
+
4860
+ SetUndoStates();
4861
+
46844862 ResetModel();
46854863 copy.HardTouch(); // recompile?
46864864 refreshContents();
46874865 }
46884866 }
46894867
4690
- void load() // throws ClassNotFoundException
4868
+ void Open() // throws ClassNotFoundException
46914869 {
46924870 if (Grafreed.standAlone)
46934871 {
....@@ -4972,7 +5150,7 @@
49725150 MenuBar menuBar;
49735151 Menu fileMenu;
49745152 MenuItem newItem;
4975
- MenuItem loadItem;
5153
+ MenuItem openItem;
49765154 MenuItem saveItem;
49775155 MenuItem saveAsItem;
49785156 MenuItem exportAsItem;
....@@ -4995,6 +5173,7 @@
49955173 CheckboxMenuItem toggleSwitchItem;
49965174 CheckboxMenuItem toggleRootItem;
49975175 CheckboxMenuItem animationItem;
5176
+ MenuItem archiveItem;
49985177 CheckboxMenuItem toggleHandleItem;
49995178 CheckboxMenuItem togglePaintItem;
50005179 JSplitPane mainPanel;