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());
....@@ -699,8 +699,8 @@
699699 }
700700 }
701701
702
-static GraphicsDevice device = GraphicsEnvironment
703
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
702
+//static GraphicsDevice device = GraphicsEnvironment
703
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
704704
705705 Rectangle keeprect;
706706 cRadio radio;
....@@ -721,10 +721,19 @@
721721 void Minimize()
722722 {
723723 frame.setState(Frame.ICONIFIED);
724
+ frame.validate();
724725 }
725726
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={}
726730 void Maximize()
727731 {
732
+ if (CameraPane.FULLSCREEN)
733
+ {
734
+ ToggleFullScreen();
735
+ }
736
+
728737 if (maximized)
729738 {
730739 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -732,22 +741,36 @@
732741 else
733742 {
734743 keeprect = frame.getBounds();
735
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
736
- Dimension rect2 = frame.getToolkit().getScreenSize();
737
- 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);
738747 // frame.setState(Frame.MAXIMIZED_BOTH);
748
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
739749 }
740750
741751 maximized ^= true;
752
+
753
+ frame.validate();
742754 }
755
+
756
+ cButton minButton;
757
+ cButton maxButton;
758
+ cButton fullButton;
743759
744760 void ToggleFullScreen()
745761 {
762
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
763
+
746764 cameraView.ToggleFullScreen();
747765
748766 if (!CameraPane.FULLSCREEN)
749767 {
750768 device.setFullScreenWindow(null);
769
+ frame.dispose();
770
+ frame.setUndecorated(false);
771
+ frame.validate();
772
+ frame.setVisible(true);
773
+
751774 //frame.setVisible(false);
752775 // frame.removeNotify();
753776 // frame.setUndecorated(false);
....@@ -757,7 +780,7 @@
757780 // X frame.getContentPane().remove(/*"Center",*/bigThree);
758781 // X framePanel.add(bigThree);
759782 // X frame.getContentPane().add(/*"Center",*/framePanel);
760
- framePanel.setDividerLocation(1);
783
+ framePanel.setDividerLocation(46);
761784
762785 //frame.setVisible(true);
763786 radio.layout = keepButton;
....@@ -772,7 +795,12 @@
772795 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
773796 // frame.getToolkit().getScreenSize().height);
774797 //frame.setVisible(false);
798
+
799
+ frame.dispose();
800
+ frame.setUndecorated(true);
775801 device.setFullScreenWindow(frame);
802
+ frame.validate();
803
+ frame.setVisible(true);
776804 // frame.removeNotify();
777805 // frame.setUndecorated(true);
778806 // frame.addNotify();
....@@ -785,7 +813,30 @@
785813 radio.layout.doClick();
786814 //frame.setVisible(true);
787815 }
816
+ frame.validate();
788817 }
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
+ }
789840
790841 private JTextPane createTextPane()
791842 {
....@@ -1117,7 +1168,7 @@
11171168 namePanel = new cGridBag();
11181169
11191170 nameField = AddText(namePanel, copy.GetName());
1120
- namePanel.add(nameField);
1171
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11211172 oe.ctrlPanel.add(namePanel);
11221173
11231174 oe.ctrlPanel.Return();
....@@ -1142,13 +1193,14 @@
11421193 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11431194 rewindCB.setToolTipText("Rewind animation");
11441195
1145
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1196
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
11461197 randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11471198
1199
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1200
+ link2masterCB.setToolTipText("Attach to support");
1201
+
11481202 if (Globals.ADVANCED)
11491203 {
1150
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1151
- link2masterCB.setToolTipText("Attach to support");
11521204 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11531205 speedupCB.setToolTipText("Option motion capture");
11541206 }
....@@ -1464,7 +1516,10 @@
14641516 // north.add(ctrlPanel, BorderLayout.NORTH);
14651517 // objectPanel.add(north);
14661518 objectPanel.add(editPanel);
1467
- objectPanel.add(infoPanel);
1519
+
1520
+ //if (Globals.ADVANCED)
1521
+ objectPanel.add(infoPanel);
1522
+
14681523 objectPanel.add(toolboxPanel);
14691524
14701525 /*
....@@ -1573,9 +1628,9 @@
15731628 // aConstraints.gridheight = 1;
15741629
15751630 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1576
- framePanel.setContinuousLayout(true);
1577
- framePanel.setOneTouchExpandable(true);
1578
- framePanel.setDividerLocation(0.8);
1631
+ framePanel.setContinuousLayout(false);
1632
+ framePanel.setOneTouchExpandable(false);
1633
+ //.setDividerLocation(0.8);
15791634 //framePanel.setDividerSize(15);
15801635 //framePanel.setResizeWeight(0.15);
15811636 framePanel.setName("Frame");
....@@ -1594,12 +1649,13 @@
15941649
15951650 frame.setSize(1280, 860);
15961651
1597
- frame.validate();
1598
- frame.setVisible(true);
1599
-
16001652 cameraView.requestFocusInWindow();
16011653
16021654 gridPanel.setDividerLocation(1.0);
1655
+
1656
+ frame.validate();
1657
+
1658
+ frame.setVisible(true);
16031659
16041660 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16051661 frame.addWindowListener(new WindowAdapter()
....@@ -1686,24 +1742,6 @@
16861742 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16871743 colorSection.add(texture);
16881744
1689
- cGridBag anisoU = new cGridBag();
1690
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1691
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1692
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1693
- colorSection.add(anisoU);
1694
-
1695
- cGridBag anisoV = new cGridBag();
1696
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1697
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1698
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1699
- colorSection.add(anisoV);
1700
-
1701
- cGridBag shadowbias = new cGridBag();
1702
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1703
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1704
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1705
- colorSection.add(shadowbias);
1706
-
17071745 panel.add(new JSeparator());
17081746
17091747 panel.add(colorSection);
....@@ -1753,6 +1791,12 @@
17531791 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17541792 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17551793 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);
17561800
17571801 panel.add(new JSeparator());
17581802
....@@ -1804,6 +1848,18 @@
18041848 // aConstraints.gridy += 1;
18051849 // aConstraints.gridwidth = 1;
18061850
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
+
18071863
18081864 panel.add(new JSeparator());
18091865
....@@ -1811,35 +1867,35 @@
18111867
18121868 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18131869
1814
- cGridBag globalSection = new cGridBag().setVertical(true);
1870
+ //cGridBag globalSection = new cGridBag().setVertical(true);
18151871
18161872 cGridBag camera = new cGridBag();
18171873 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
18181874 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18191875 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1820
- globalSection.add(camera);
1876
+ colorSection.add(camera);
18211877
18221878 cGridBag ambient = new cGridBag();
18231879 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18241880 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18251881 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1826
- globalSection.add(ambient);
1882
+ colorSection.add(ambient);
18271883
18281884 cGridBag backlit = new cGridBag();
18291885 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18301886 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18311887 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1832
- globalSection.add(backlit);
1888
+ colorSection.add(backlit);
18331889
18341890 cGridBag opacity = new cGridBag();
18351891 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
18361892 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18371893 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1838
- globalSection.add(opacity);
1894
+ colorSection.add(opacity);
18391895
1840
- panel.add(new JSeparator());
1896
+ //panel.add(new JSeparator());
18411897
1842
- panel.add(globalSection);
1898
+ //panel.add(globalSection);
18431899
18441900 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18451901
....@@ -1946,8 +2002,9 @@
19462002 // 3D models
19472003 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19482004 {
1949
- lastConverter = new com.jmex.model.converters.MaxToJme();
1950
- LoadFile(filename, lastConverter);
2005
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2006
+ //LoadFile(filename, lastConverter);
2007
+ LoadObjFile(filename); // New 3ds loader
19512008 continue;
19522009 }
19532010 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2673,6 +2730,7 @@
26732730 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26742731 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26752732 }
2733
+
26762734 //cJME.count++;
26772735 //cJME.count %= 12;
26782736 if (gc)
....@@ -2856,6 +2914,7 @@
28562914 }
28572915 }
28582916 }
2917
+
28592918 cFileSystemPane FSPane;
28602919
28612920 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2909,6 +2968,7 @@
29092968 }
29102969 }
29112970 }
2971
+
29122972 freezematerial = false;
29132973 }
29142974
....@@ -3361,9 +3421,9 @@
33613421 {
33623422 Close();
33633423 //return true;
3364
- } else if (source == loadItem)
3424
+ } else if (source == openItem)
33653425 {
3366
- load();
3426
+ Open();
33673427 //return true;
33683428 } else if (source == newItem)
33693429 {
....@@ -3388,6 +3448,10 @@
33883448 {
33893449 generatePOV();
33903450 //return true;
3451
+ } else if (event.getSource() == archiveItem)
3452
+ {
3453
+ cTools.Archive(frame);
3454
+ return;
33913455 } else if (source == zBufferItem)
33923456 {
33933457 try
....@@ -3439,8 +3503,8 @@
34393503 try
34403504 {
34413505 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3442
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3443
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3506
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3507
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34443508
34453509 Object3D parent = o.parent;
34463510 o.parent = null;
....@@ -3451,10 +3515,14 @@
34513515
34523516 out.flush();
34533517
3454
- zstream.close();
3518
+ baos //zstream
3519
+ .close();
34553520 out.close();
34563521
3457
- return baos.toByteArray();
3522
+ byte[] bytes = baos.toByteArray();
3523
+
3524
+ System.out.println("save #bytes = " + bytes.length);
3525
+ return bytes;
34583526 } catch (Exception e)
34593527 {
34603528 System.err.println(e);
....@@ -3464,13 +3532,16 @@
34643532
34653533 static public Object Uncompress(byte[] bytes)
34663534 {
3467
- System.out.println("#bytes = " + bytes.length);
3535
+ System.out.println("restore #bytes = " + bytes.length);
34683536 try
34693537 {
34703538 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3471
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3472
- ObjectInputStream in = new ObjectInputStream(istream);
3539
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3540
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34733541 Object obj = in.readObject();
3542
+
3543
+ bais //istream
3544
+ .close();
34743545 in.close();
34753546
34763547 return obj;
....@@ -3525,31 +3596,67 @@
35253596 return null;
35263597 }
35273598
3528
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35293599
35303600 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)
35313625 {
35323626 System.err.println("Save");
35333627
35343628 cRadio tab = GetCurrentTab();
35353629
3536
- boolean temp = CameraPane.SWITCH;
3537
- CameraPane.SWITCH = false;
3630
+ byte[] compress = CompressCopy();
35383631
3539
- 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
+ }
35403639
35413640 //EditorFrame.m_MainFrame.requestFocusInWindow();
3542
- 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
+ }
35433651
3544
- copy.RestoreBigData(hashtable);
3652
+ //copy.RestoreBigData(versiontable);
35453653
3546
- CameraPane.SWITCH = temp;
3547
-
35483654 //assert(hashtable.isEmpty());
35493655
3550
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3656
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
35513657 {
3552
- tab.graphs[i] = null;
3658
+ //tab.user[i] = false;
3659
+ copy.versions[i] = null;
35533660 }
35543661
35553662 SetUndoStates();
....@@ -3559,7 +3666,7 @@
35593666 {
35603667 try
35613668 {
3562
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3669
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35633670 ObjectOutputStream p = new ObjectOutputStream(ostream);
35643671
35653672 p.writeObject(copy);
....@@ -3572,6 +3679,8 @@
35723679 e.printStackTrace();
35733680 }
35743681 }
3682
+
3683
+ return !thesame;
35753684 }
35763685
35773686 void CopyChanged(Object3D obj)
....@@ -3581,7 +3690,7 @@
35813690 boolean temp = CameraPane.SWITCH;
35823691 CameraPane.SWITCH = false;
35833692
3584
- copy.ExtractBigData(hashtable);
3693
+ copy.ExtractBigData(versiontable);
35853694
35863695 copy.clear();
35873696
....@@ -3590,7 +3699,7 @@
35903699 copy.add(obj.get(i));
35913700 }
35923701
3593
- copy.RestoreBigData(hashtable);
3702
+ copy.RestoreBigData(versiontable);
35943703
35953704 CameraPane.SWITCH = temp;
35963705
....@@ -3618,52 +3727,102 @@
36183727 }
36193728
36203729 cButton undoButton;
3730
+ cButton restoreButton;
3731
+ cButton replaceButton;
36213732 cButton redoButton;
36223733
36233734 void SetUndoStates()
36243735 {
36253736 cRadio tab = GetCurrentTab();
36263737
3627
- undoButton.setEnabled(tab.undoindex > 0);
3628
- 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);
36293742 }
36303743
3631
- public void Undo()
3744
+ public boolean Undo()
36323745 {
36333746 System.err.println("Undo");
36343747
36353748 cRadio tab = GetCurrentTab();
36363749
3637
- if (tab.undoindex == 0)
3750
+ if (copy.versionindex == 0)
36383751 {
36393752 java.awt.Toolkit.getDefaultToolkit().beep();
3640
- return;
3753
+ return false;
36413754 }
36423755
3643
- 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)
36443783 {
3645
- Save();
3646
- tab.undoindex -= 1;
3784
+ java.awt.Toolkit.getDefaultToolkit().beep();
3785
+ return false;
36473786 }
36483787
3649
- tab.undoindex -= 1;
3788
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3789
+
3790
+ return true;
3791
+ }
36503792
3651
- 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;
36523808 }
36533809
36543810 public void Redo()
36553811 {
36563812 cRadio tab = GetCurrentTab();
36573813
3658
- if (tab.graphs[tab.undoindex + 1] == null)
3814
+ if (copy.versions[copy.versionindex + 1] == null)
36593815 {
36603816 java.awt.Toolkit.getDefaultToolkit().beep();
36613817 return;
36623818 }
36633819
3664
- tab.undoindex += 1;
3820
+ copy.versionindex += 1;
36653821
3666
- 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;
36673826 }
36683827
36693828 void ImportGFD()
....@@ -3959,9 +4118,22 @@
39594118 //copy.Touch();
39604119 }
39614120
4121
+ cNumberSlider versionField;
4122
+
39624123 public void stateChanged(ChangeEvent e)
39634124 {
39644125 // 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
+ }
39654137
39664138 if (freezematerial)
39674139 {
....@@ -4310,7 +4482,7 @@
43104482
43114483 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
43124484 {
4313
- if (Globals.SAVEONMAKE) // && resetmodel)
4485
+ if (Globals.REPLACEONMAKE) // && resetmodel)
43144486 Save();
43154487 //Tween.set(thing, 0).target(1).start(tweenManager);
43164488 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4626,8 +4798,8 @@
46264798
46274799 if (readobj != null)
46284800 {
4629
- if (Globals.SAVEONMAKE)
4630
- Save();
4801
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4802
+ // Save();
46314803 try
46324804 {
46334805 //readobj.deepCopySelf(copy);
....@@ -4682,13 +4854,18 @@
46824854 c.addChild(csg);
46834855 }
46844856
4857
+ copy.versions = readobj.versions;
4858
+ copy.versionindex = readobj.versionindex;
4859
+
4860
+ SetUndoStates();
4861
+
46854862 ResetModel();
46864863 copy.HardTouch(); // recompile?
46874864 refreshContents();
46884865 }
46894866 }
46904867
4691
- void load() // throws ClassNotFoundException
4868
+ void Open() // throws ClassNotFoundException
46924869 {
46934870 if (Grafreed.standAlone)
46944871 {
....@@ -4973,7 +5150,7 @@
49735150 MenuBar menuBar;
49745151 Menu fileMenu;
49755152 MenuItem newItem;
4976
- MenuItem loadItem;
5153
+ MenuItem openItem;
49775154 MenuItem saveItem;
49785155 MenuItem saveAsItem;
49795156 MenuItem exportAsItem;
....@@ -4996,6 +5173,7 @@
49965173 CheckboxMenuItem toggleSwitchItem;
49975174 CheckboxMenuItem toggleRootItem;
49985175 CheckboxMenuItem animationItem;
5176
+ MenuItem archiveItem;
49995177 CheckboxMenuItem toggleHandleItem;
50005178 CheckboxMenuItem togglePaintItem;
50015179 JSplitPane mainPanel;