Normand Briere
2019-07-18 d7a17c35c443e2cb6c09eaa3cfeaf590a571faa1
ObjEditor.java
....@@ -282,6 +282,12 @@
282282 client = inClient;
283283 copy = client;
284284
285
+ if (copy.versions == null)
286
+ {
287
+ copy.versions = new byte[100][];
288
+ copy.versionindex = -1;
289
+ }
290
+
285291 // "this" is not called: SetupUI2(objEditor);
286292 }
287293
....@@ -295,6 +301,12 @@
295301 client = inClient;
296302 copy = client;
297303
304
+ if (copy.versions == null)
305
+ {
306
+ copy.versions = new byte[100][];
307
+ copy.versionindex = -1;
308
+ }
309
+
298310 SetupUI2(callee.GetEditor());
299311 }
300312
....@@ -309,7 +321,7 @@
309321 //localCopy.parent = null;
310322
311323 frame = new JFrame();
312
- frame.setUndecorated(true);
324
+ frame.setUndecorated(false);
313325 objEditor = this;
314326 this.callee = callee;
315327
....@@ -327,6 +339,12 @@
327339 copy = localCopy;
328340 copy.editWindow = this;
329341
342
+ if (copy.versions == null)
343
+ {
344
+ copy.versions = new byte[100][];
345
+ copy.versionindex = -1;
346
+ }
347
+
330348 SetupMenu();
331349
332350 //SetupName(objEditor); // new
....@@ -350,7 +368,7 @@
350368 frame.setMenuBar(menuBar = new MenuBar());
351369 menuBar.add(fileMenu = new Menu("File"));
352370 fileMenu.add(newItem = new MenuItem("New"));
353
- fileMenu.add(loadItem = new MenuItem("Open..."));
371
+ fileMenu.add(openItem = new MenuItem("Open..."));
354372
355373 //oe.menuBar.add(menu = new Menu("Include"));
356374 Menu menu = new Menu("Import");
....@@ -382,7 +400,7 @@
382400 }
383401
384402 newItem.addActionListener(this);
385
- loadItem.addActionListener(this);
403
+ openItem.addActionListener(this);
386404 saveItem.addActionListener(this);
387405 saveAsItem.addActionListener(this);
388406 exportAsItem.addActionListener(this);
....@@ -449,7 +467,7 @@
449467 // TEXTAREA infoarea.setLineWrap(true);
450468 // TEXTAREA infoarea.setWrapStyleWord(true);
451469 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
452
- infoPanel.setPreferredSize(new Dimension(50, 200));
470
+ infoPanel.setPreferredSize(new Dimension(1, 1));
453471 infoPanel.setName("Info");
454472 //infoPanel.setLayout(new BorderLayout());
455473 //infoPanel.add(createTextPane());
....@@ -699,8 +717,8 @@
699717 }
700718 }
701719
702
-static GraphicsDevice device = GraphicsEnvironment
703
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
720
+//static GraphicsDevice device = GraphicsEnvironment
721
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
704722
705723 Rectangle keeprect;
706724 cRadio radio;
....@@ -721,10 +739,19 @@
721739 void Minimize()
722740 {
723741 frame.setState(Frame.ICONIFIED);
742
+ frame.validate();
724743 }
725744
745
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
746
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
747
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
726748 void Maximize()
727749 {
750
+ if (CameraPane.FULLSCREEN)
751
+ {
752
+ ToggleFullScreen();
753
+ }
754
+
728755 if (maximized)
729756 {
730757 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -732,22 +759,36 @@
732759 else
733760 {
734761 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);
762
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
763
+// Dimension rect2 = frame.getToolkit().getScreenSize();
764
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
738765 // frame.setState(Frame.MAXIMIZED_BOTH);
766
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
739767 }
740768
741769 maximized ^= true;
770
+
771
+ frame.validate();
742772 }
773
+
774
+ cButton minButton;
775
+ cButton maxButton;
776
+ cButton fullButton;
743777
744778 void ToggleFullScreen()
745779 {
780
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
781
+
746782 cameraView.ToggleFullScreen();
747783
748784 if (!CameraPane.FULLSCREEN)
749785 {
750786 device.setFullScreenWindow(null);
787
+ frame.dispose();
788
+ frame.setUndecorated(false);
789
+ frame.validate();
790
+ frame.setVisible(true);
791
+
751792 //frame.setVisible(false);
752793 // frame.removeNotify();
753794 // frame.setUndecorated(false);
....@@ -757,7 +798,7 @@
757798 // X frame.getContentPane().remove(/*"Center",*/bigThree);
758799 // X framePanel.add(bigThree);
759800 // X frame.getContentPane().add(/*"Center",*/framePanel);
760
- framePanel.setDividerLocation(1);
801
+ framePanel.setDividerLocation(46);
761802
762803 //frame.setVisible(true);
763804 radio.layout = keepButton;
....@@ -772,7 +813,12 @@
772813 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
773814 // frame.getToolkit().getScreenSize().height);
774815 //frame.setVisible(false);
816
+
817
+ frame.dispose();
818
+ frame.setUndecorated(true);
775819 device.setFullScreenWindow(frame);
820
+ frame.validate();
821
+ frame.setVisible(true);
776822 // frame.removeNotify();
777823 // frame.setUndecorated(true);
778824 // frame.addNotify();
....@@ -785,7 +831,30 @@
785831 radio.layout.doClick();
786832 //frame.setVisible(true);
787833 }
834
+ frame.validate();
788835 }
836
+
837
+ private byte[] CompressCopy()
838
+ {
839
+ boolean temp = CameraPane.SWITCH;
840
+ CameraPane.SWITCH = false;
841
+
842
+ copy.ExtractBigData(versiontable);
843
+ // if (copy == client)
844
+
845
+ byte[] versions[] = copy.versions;
846
+ copy.versions = null;
847
+
848
+ byte[] compress = Compress(copy);
849
+
850
+ copy.versions = versions;
851
+
852
+ copy.RestoreBigData(versiontable);
853
+
854
+ CameraPane.SWITCH = temp;
855
+
856
+ return compress;
857
+ }
789858
790859 private JTextPane createTextPane()
791860 {
....@@ -1117,7 +1186,7 @@
11171186 namePanel = new cGridBag();
11181187
11191188 nameField = AddText(namePanel, copy.GetName());
1120
- namePanel.add(nameField);
1189
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11211190 oe.ctrlPanel.add(namePanel);
11221191
11231192 oe.ctrlPanel.Return();
....@@ -1142,13 +1211,14 @@
11421211 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11431212 rewindCB.setToolTipText("Rewind animation");
11441213
1145
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1214
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
11461215 randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11471216
1217
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1218
+ link2masterCB.setToolTipText("Attach to support");
1219
+
11481220 if (Globals.ADVANCED)
11491221 {
1150
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1151
- link2masterCB.setToolTipText("Attach to support");
11521222 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11531223 speedupCB.setToolTipText("Option motion capture");
11541224 }
....@@ -1464,7 +1534,10 @@
14641534 // north.add(ctrlPanel, BorderLayout.NORTH);
14651535 // objectPanel.add(north);
14661536 objectPanel.add(editPanel);
1467
- objectPanel.add(infoPanel);
1537
+
1538
+ //if (Globals.ADVANCED)
1539
+ objectPanel.add(infoPanel);
1540
+
14681541 objectPanel.add(toolboxPanel);
14691542
14701543 /*
....@@ -1573,9 +1646,9 @@
15731646 // aConstraints.gridheight = 1;
15741647
15751648 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1576
- framePanel.setContinuousLayout(true);
1577
- framePanel.setOneTouchExpandable(true);
1578
- framePanel.setDividerLocation(0.8);
1649
+ framePanel.setContinuousLayout(false);
1650
+ framePanel.setOneTouchExpandable(false);
1651
+ //.setDividerLocation(0.8);
15791652 //framePanel.setDividerSize(15);
15801653 //framePanel.setResizeWeight(0.15);
15811654 framePanel.setName("Frame");
....@@ -1594,12 +1667,13 @@
15941667
15951668 frame.setSize(1280, 860);
15961669
1597
- frame.validate();
1598
- frame.setVisible(true);
1599
-
16001670 cameraView.requestFocusInWindow();
16011671
16021672 gridPanel.setDividerLocation(1.0);
1673
+
1674
+ frame.validate();
1675
+
1676
+ frame.setVisible(true);
16031677
16041678 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16051679 frame.addWindowListener(new WindowAdapter()
....@@ -1686,24 +1760,6 @@
16861760 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16871761 colorSection.add(texture);
16881762
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
-
17071763 panel.add(new JSeparator());
17081764
17091765 panel.add(colorSection);
....@@ -1753,6 +1809,12 @@
17531809 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17541810 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17551811 diffuseSection.add(fakedepth);
1812
+
1813
+ cGridBag shadowbias = new cGridBag();
1814
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1815
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1816
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1817
+ diffuseSection.add(shadowbias);
17561818
17571819 panel.add(new JSeparator());
17581820
....@@ -1804,6 +1866,18 @@
18041866 // aConstraints.gridy += 1;
18051867 // aConstraints.gridwidth = 1;
18061868
1869
+ cGridBag anisoU = new cGridBag();
1870
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1871
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1872
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1873
+ specularSection.add(anisoU);
1874
+
1875
+ cGridBag anisoV = new cGridBag();
1876
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1877
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1878
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1879
+ specularSection.add(anisoV);
1880
+
18071881
18081882 panel.add(new JSeparator());
18091883
....@@ -1811,35 +1885,35 @@
18111885
18121886 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18131887
1814
- cGridBag globalSection = new cGridBag().setVertical(true);
1888
+ //cGridBag globalSection = new cGridBag().setVertical(true);
18151889
18161890 cGridBag camera = new cGridBag();
18171891 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
18181892 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18191893 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1820
- globalSection.add(camera);
1894
+ colorSection.add(camera);
18211895
18221896 cGridBag ambient = new cGridBag();
18231897 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18241898 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18251899 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1826
- globalSection.add(ambient);
1900
+ colorSection.add(ambient);
18271901
18281902 cGridBag backlit = new cGridBag();
18291903 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18301904 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18311905 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1832
- globalSection.add(backlit);
1906
+ colorSection.add(backlit);
18331907
18341908 cGridBag opacity = new cGridBag();
18351909 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
18361910 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18371911 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1838
- globalSection.add(opacity);
1912
+ colorSection.add(opacity);
18391913
1840
- panel.add(new JSeparator());
1914
+ //panel.add(new JSeparator());
18411915
1842
- panel.add(globalSection);
1916
+ //panel.add(globalSection);
18431917
18441918 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18451919
....@@ -1946,8 +2020,9 @@
19462020 // 3D models
19472021 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19482022 {
1949
- lastConverter = new com.jmex.model.converters.MaxToJme();
1950
- LoadFile(filename, lastConverter);
2023
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2024
+ //LoadFile(filename, lastConverter);
2025
+ LoadObjFile(filename); // New 3ds loader
19512026 continue;
19522027 }
19532028 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2673,6 +2748,7 @@
26732748 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26742749 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26752750 }
2751
+
26762752 //cJME.count++;
26772753 //cJME.count %= 12;
26782754 if (gc)
....@@ -2856,6 +2932,7 @@
28562932 }
28572933 }
28582934 }
2935
+
28592936 cFileSystemPane FSPane;
28602937
28612938 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2909,6 +2986,7 @@
29092986 }
29102987 }
29112988 }
2989
+
29122990 freezematerial = false;
29132991 }
29142992
....@@ -3361,9 +3439,9 @@
33613439 {
33623440 Close();
33633441 //return true;
3364
- } else if (source == loadItem)
3442
+ } else if (source == openItem)
33653443 {
3366
- load();
3444
+ Open();
33673445 //return true;
33683446 } else if (source == newItem)
33693447 {
....@@ -3388,6 +3466,10 @@
33883466 {
33893467 generatePOV();
33903468 //return true;
3469
+ } else if (event.getSource() == archiveItem)
3470
+ {
3471
+ cTools.Archive(frame);
3472
+ return;
33913473 } else if (source == zBufferItem)
33923474 {
33933475 try
....@@ -3439,8 +3521,8 @@
34393521 try
34403522 {
34413523 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3442
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3443
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3524
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3525
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34443526
34453527 Object3D parent = o.parent;
34463528 o.parent = null;
....@@ -3451,10 +3533,14 @@
34513533
34523534 out.flush();
34533535
3454
- zstream.close();
3536
+ baos //zstream
3537
+ .close();
34553538 out.close();
34563539
3457
- return baos.toByteArray();
3540
+ byte[] bytes = baos.toByteArray();
3541
+
3542
+ System.out.println("save #bytes = " + bytes.length);
3543
+ return bytes;
34583544 } catch (Exception e)
34593545 {
34603546 System.err.println(e);
....@@ -3464,13 +3550,16 @@
34643550
34653551 static public Object Uncompress(byte[] bytes)
34663552 {
3467
- System.out.println("#bytes = " + bytes.length);
3553
+ System.out.println("restore #bytes = " + bytes.length);
34683554 try
34693555 {
34703556 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3471
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3472
- ObjectInputStream in = new ObjectInputStream(istream);
3557
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3558
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34733559 Object obj = in.readObject();
3560
+
3561
+ bais //istream
3562
+ .close();
34743563 in.close();
34753564
34763565 return obj;
....@@ -3525,31 +3614,67 @@
35253614 return null;
35263615 }
35273616
3528
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35293617
35303618 public void Save()
3619
+ {
3620
+ //Save(true);
3621
+ Replace();
3622
+ }
3623
+
3624
+ private boolean Equal(byte[] compress, byte[] name)
3625
+ {
3626
+ if (compress.length != name.length)
3627
+ {
3628
+ return false;
3629
+ }
3630
+
3631
+ for (int i=compress.length; --i>=0;)
3632
+ {
3633
+ if (compress[i] != name[i])
3634
+ return false;
3635
+ }
3636
+
3637
+ return true;
3638
+ }
3639
+
3640
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3641
+
3642
+ public boolean Save(boolean user)
35313643 {
35323644 System.err.println("Save");
35333645
35343646 cRadio tab = GetCurrentTab();
35353647
3536
- boolean temp = CameraPane.SWITCH;
3537
- CameraPane.SWITCH = false;
3648
+ byte[] compress = CompressCopy();
35383649
3539
- copy.ExtractBigData(hashtable);
3650
+ boolean thesame = false;
3651
+
3652
+ // Quick heuristic using length. Works only when stream is compressed.
3653
+ if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3654
+ {
3655
+ thesame = true;
3656
+ }
35403657
35413658 //EditorFrame.m_MainFrame.requestFocusInWindow();
3542
- tab.graphs[tab.undoindex++] = Compress(copy);
3659
+ if (!thesame)
3660
+ {
3661
+ //tab.user[tab.versionindex] = user;
3662
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
3663
+
3664
+ copy.versions[++copy.versionindex] = compress;
3665
+
3666
+ // if (increment)
3667
+ // tab.versionindex++;
3668
+ }
35433669
3544
- copy.RestoreBigData(hashtable);
3670
+ //copy.RestoreBigData(versiontable);
35453671
3546
- CameraPane.SWITCH = temp;
3547
-
35483672 //assert(hashtable.isEmpty());
35493673
3550
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3674
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
35513675 {
3552
- tab.graphs[i] = null;
3676
+ //tab.user[i] = false;
3677
+ copy.versions[i] = null;
35533678 }
35543679
35553680 SetUndoStates();
....@@ -3559,7 +3684,7 @@
35593684 {
35603685 try
35613686 {
3562
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3687
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35633688 ObjectOutputStream p = new ObjectOutputStream(ostream);
35643689
35653690 p.writeObject(copy);
....@@ -3572,6 +3697,8 @@
35723697 e.printStackTrace();
35733698 }
35743699 }
3700
+
3701
+ return !thesame;
35753702 }
35763703
35773704 void CopyChanged(Object3D obj)
....@@ -3581,7 +3708,7 @@
35813708 boolean temp = CameraPane.SWITCH;
35823709 CameraPane.SWITCH = false;
35833710
3584
- copy.ExtractBigData(hashtable);
3711
+ copy.ExtractBigData(versiontable);
35853712
35863713 copy.clear();
35873714
....@@ -3590,7 +3717,7 @@
35903717 copy.add(obj.get(i));
35913718 }
35923719
3593
- copy.RestoreBigData(hashtable);
3720
+ copy.RestoreBigData(versiontable);
35943721
35953722 CameraPane.SWITCH = temp;
35963723
....@@ -3618,52 +3745,129 @@
36183745 }
36193746
36203747 cButton undoButton;
3748
+ cButton restoreButton;
3749
+ cButton replaceButton;
36213750 cButton redoButton;
36223751
3752
+ boolean muteSlider;
3753
+
3754
+ int VersionCount()
3755
+ {
3756
+ int count = 0;
3757
+
3758
+ for (int i = copy.versions.length; --i >= 0;)
3759
+ {
3760
+ if (copy.versions[i] != null)
3761
+ count++;
3762
+ }
3763
+
3764
+ return count;
3765
+ }
3766
+
36233767 void SetUndoStates()
36243768 {
36253769 cRadio tab = GetCurrentTab();
36263770
3627
- undoButton.setEnabled(tab.undoindex > 0);
3628
- redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3771
+ restoreButton.setEnabled(copy.versionindex != -1);
3772
+ replaceButton.setEnabled(copy.versionindex != -1);
3773
+
3774
+ undoButton.setEnabled(copy.versionindex > 0);
3775
+ redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
3776
+
3777
+ muteSlider = true;
3778
+ versionSlider.setMaximum(VersionCount() - 1);
3779
+ versionSlider.setInteger(copy.versionindex);
3780
+ muteSlider = false;
36293781 }
36303782
3631
- public void Undo()
3783
+ public boolean Undo()
36323784 {
3785
+ // Option?
3786
+ Replace();
3787
+
36333788 System.err.println("Undo");
36343789
36353790 cRadio tab = GetCurrentTab();
36363791
3637
- if (tab.undoindex == 0)
3792
+ if (copy.versionindex == 0)
36383793 {
36393794 java.awt.Toolkit.getDefaultToolkit().beep();
3640
- return;
3795
+ return false;
36413796 }
36423797
3643
- if (tab.graphs[tab.undoindex] == null)
3798
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3799
+// {
3800
+// if (Save(false))
3801
+// tab.versionindex -= 1;
3802
+// else
3803
+// {
3804
+// if (tab.versionindex <= 0)
3805
+// return false;
3806
+// else
3807
+// tab.versionindex -= 1;
3808
+// }
3809
+// }
3810
+
3811
+ copy.versionindex -= 1;
3812
+
3813
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3814
+
3815
+ return true;
3816
+ }
3817
+
3818
+ public boolean Restore()
3819
+ {
3820
+ System.err.println("Restore");
3821
+
3822
+ cRadio tab = GetCurrentTab();
3823
+
3824
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
36443825 {
3645
- Save();
3646
- tab.undoindex -= 1;
3826
+ java.awt.Toolkit.getDefaultToolkit().beep();
3827
+ return false;
36473828 }
36483829
3649
- tab.undoindex -= 1;
3830
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3831
+
3832
+ return true;
3833
+ }
36503834
3651
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3835
+ public boolean Replace()
3836
+ {
3837
+ System.err.println("Replace");
3838
+
3839
+ cRadio tab = GetCurrentTab();
3840
+
3841
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3842
+ {
3843
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
3844
+ return false;
3845
+ }
3846
+
3847
+ copy.versions[copy.versionindex] = CompressCopy();
3848
+
3849
+ return true;
36523850 }
36533851
36543852 public void Redo()
36553853 {
3854
+ // Option?
3855
+ Replace();
3856
+
36563857 cRadio tab = GetCurrentTab();
36573858
3658
- if (tab.graphs[tab.undoindex + 1] == null)
3859
+ if (copy.versions[copy.versionindex + 1] == null)
36593860 {
36603861 java.awt.Toolkit.getDefaultToolkit().beep();
36613862 return;
36623863 }
36633864
3664
- tab.undoindex += 1;
3865
+ copy.versionindex += 1;
36653866
3666
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3867
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3868
+
3869
+ //if (!tab.user[tab.versionindex])
3870
+ // tab.graphs[tab.versionindex] = null;
36673871 }
36683872
36693873 void ImportGFD()
....@@ -3959,9 +4163,25 @@
39594163 //copy.Touch();
39604164 }
39614165
4166
+ cNumberSlider versionSlider;
4167
+
39624168 public void stateChanged(ChangeEvent e)
39634169 {
39644170 // assert(false);
4171
+ if (e.getSource() == versionSlider)
4172
+ {
4173
+ if (muteSlider)
4174
+ return;
4175
+
4176
+ int version = versionSlider.getInteger();
4177
+
4178
+ if (copy.versions[version] != null)
4179
+ {
4180
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4181
+ }
4182
+
4183
+ return;
4184
+ }
39654185
39664186 if (freezematerial)
39674187 {
....@@ -4310,7 +4530,7 @@
43104530
43114531 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
43124532 {
4313
- if (Globals.SAVEONMAKE) // && resetmodel)
4533
+ if (Globals.REPLACEONMAKE) // && resetmodel)
43144534 Save();
43154535 //Tween.set(thing, 0).target(1).start(tweenManager);
43164536 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4626,8 +4846,8 @@
46264846
46274847 if (readobj != null)
46284848 {
4629
- if (Globals.SAVEONMAKE)
4630
- Save();
4849
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4850
+ // Save();
46314851 try
46324852 {
46334853 //readobj.deepCopySelf(copy);
....@@ -4682,13 +4902,24 @@
46824902 c.addChild(csg);
46834903 }
46844904
4905
+ copy.versions = readobj.versions;
4906
+ copy.versionindex = readobj.versionindex;
4907
+
4908
+ if (copy.versions == null)
4909
+ {
4910
+ copy.versions = new byte[100][];
4911
+ copy.versionindex = -1;
4912
+ }
4913
+
4914
+ //? SetUndoStates();
4915
+
46854916 ResetModel();
46864917 copy.HardTouch(); // recompile?
46874918 refreshContents();
46884919 }
46894920 }
46904921
4691
- void load() // throws ClassNotFoundException
4922
+ void Open() // throws ClassNotFoundException
46924923 {
46934924 if (Grafreed.standAlone)
46944925 {
....@@ -4973,7 +5204,7 @@
49735204 MenuBar menuBar;
49745205 Menu fileMenu;
49755206 MenuItem newItem;
4976
- MenuItem loadItem;
5207
+ MenuItem openItem;
49775208 MenuItem saveItem;
49785209 MenuItem saveAsItem;
49795210 MenuItem exportAsItem;
....@@ -4996,6 +5227,7 @@
49965227 CheckboxMenuItem toggleSwitchItem;
49975228 CheckboxMenuItem toggleRootItem;
49985229 CheckboxMenuItem animationItem;
5230
+ MenuItem archiveItem;
49995231 CheckboxMenuItem toggleHandleItem;
50005232 CheckboxMenuItem togglePaintItem;
50015233 JSplitPane mainPanel;