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());
....@@ -463,10 +481,11 @@
463481 mainPanel.setResizeWeight(0.5);
464482
465483 //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!"));
484
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
485
+ divider.setDividerSize(15);
486
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
469487
488
+ mainPanel.setUI(new BasicSplitPaneUI());
470489
471490 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
472491 //mainPanel.setLayout(new GridBagLayout());
....@@ -698,8 +717,8 @@
698717 }
699718 }
700719
701
-static GraphicsDevice device = GraphicsEnvironment
702
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
720
+//static GraphicsDevice device = GraphicsEnvironment
721
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
703722
704723 Rectangle keeprect;
705724 cRadio radio;
....@@ -720,10 +739,19 @@
720739 void Minimize()
721740 {
722741 frame.setState(Frame.ICONIFIED);
742
+ frame.validate();
723743 }
724744
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={}
725748 void Maximize()
726749 {
750
+ if (CameraPane.FULLSCREEN)
751
+ {
752
+ ToggleFullScreen();
753
+ }
754
+
727755 if (maximized)
728756 {
729757 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -731,22 +759,36 @@
731759 else
732760 {
733761 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);
762
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
763
+// Dimension rect2 = frame.getToolkit().getScreenSize();
764
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
737765 // frame.setState(Frame.MAXIMIZED_BOTH);
766
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
738767 }
739768
740769 maximized ^= true;
770
+
771
+ frame.validate();
741772 }
773
+
774
+ cButton minButton;
775
+ cButton maxButton;
776
+ cButton fullButton;
742777
743778 void ToggleFullScreen()
744779 {
780
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
781
+
745782 cameraView.ToggleFullScreen();
746783
747784 if (!CameraPane.FULLSCREEN)
748785 {
749786 device.setFullScreenWindow(null);
787
+ frame.dispose();
788
+ frame.setUndecorated(false);
789
+ frame.validate();
790
+ frame.setVisible(true);
791
+
750792 //frame.setVisible(false);
751793 // frame.removeNotify();
752794 // frame.setUndecorated(false);
....@@ -756,7 +798,7 @@
756798 // X frame.getContentPane().remove(/*"Center",*/bigThree);
757799 // X framePanel.add(bigThree);
758800 // X frame.getContentPane().add(/*"Center",*/framePanel);
759
- framePanel.setDividerLocation(1);
801
+ framePanel.setDividerLocation(46);
760802
761803 //frame.setVisible(true);
762804 radio.layout = keepButton;
....@@ -771,7 +813,12 @@
771813 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
772814 // frame.getToolkit().getScreenSize().height);
773815 //frame.setVisible(false);
816
+
817
+ frame.dispose();
818
+ frame.setUndecorated(true);
774819 device.setFullScreenWindow(frame);
820
+ frame.validate();
821
+ frame.setVisible(true);
775822 // frame.removeNotify();
776823 // frame.setUndecorated(true);
777824 // frame.addNotify();
....@@ -784,7 +831,30 @@
784831 radio.layout.doClick();
785832 //frame.setVisible(true);
786833 }
834
+ frame.validate();
787835 }
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
+ }
788858
789859 private JTextPane createTextPane()
790860 {
....@@ -1116,7 +1186,7 @@
11161186 namePanel = new cGridBag();
11171187
11181188 nameField = AddText(namePanel, copy.GetName());
1119
- namePanel.add(nameField);
1189
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11201190 oe.ctrlPanel.add(namePanel);
11211191
11221192 oe.ctrlPanel.Return();
....@@ -1141,13 +1211,14 @@
11411211 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11421212 rewindCB.setToolTipText("Rewind animation");
11431213
1144
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1214
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
11451215 randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11461216
1217
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1218
+ link2masterCB.setToolTipText("Attach to support");
1219
+
11471220 if (Globals.ADVANCED)
11481221 {
1149
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1150
- link2masterCB.setToolTipText("Attach to support");
11511222 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11521223 speedupCB.setToolTipText("Option motion capture");
11531224 }
....@@ -1463,7 +1534,10 @@
14631534 // north.add(ctrlPanel, BorderLayout.NORTH);
14641535 // objectPanel.add(north);
14651536 objectPanel.add(editPanel);
1466
- objectPanel.add(infoPanel);
1537
+
1538
+ //if (Globals.ADVANCED)
1539
+ objectPanel.add(infoPanel);
1540
+
14671541 objectPanel.add(toolboxPanel);
14681542
14691543 /*
....@@ -1572,9 +1646,9 @@
15721646 // aConstraints.gridheight = 1;
15731647
15741648 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1575
- framePanel.setContinuousLayout(true);
1576
- framePanel.setOneTouchExpandable(true);
1577
- framePanel.setDividerLocation(0.8);
1649
+ framePanel.setContinuousLayout(false);
1650
+ framePanel.setOneTouchExpandable(false);
1651
+ //.setDividerLocation(0.8);
15781652 //framePanel.setDividerSize(15);
15791653 //framePanel.setResizeWeight(0.15);
15801654 framePanel.setName("Frame");
....@@ -1593,12 +1667,13 @@
15931667
15941668 frame.setSize(1280, 860);
15951669
1596
- frame.validate();
1597
- frame.setVisible(true);
1598
-
15991670 cameraView.requestFocusInWindow();
16001671
16011672 gridPanel.setDividerLocation(1.0);
1673
+
1674
+ frame.validate();
1675
+
1676
+ frame.setVisible(true);
16021677
16031678 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16041679 frame.addWindowListener(new WindowAdapter()
....@@ -1685,24 +1760,6 @@
16851760 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16861761 colorSection.add(texture);
16871762
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
-
17061763 panel.add(new JSeparator());
17071764
17081765 panel.add(colorSection);
....@@ -1752,6 +1809,12 @@
17521809 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17531810 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17541811 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);
17551818
17561819 panel.add(new JSeparator());
17571820
....@@ -1803,6 +1866,18 @@
18031866 // aConstraints.gridy += 1;
18041867 // aConstraints.gridwidth = 1;
18051868
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
+
18061881
18071882 panel.add(new JSeparator());
18081883
....@@ -1810,35 +1885,35 @@
18101885
18111886 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18121887
1813
- cGridBag globalSection = new cGridBag().setVertical(true);
1888
+ //cGridBag globalSection = new cGridBag().setVertical(true);
18141889
18151890 cGridBag camera = new cGridBag();
18161891 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
18171892 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18181893 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1819
- globalSection.add(camera);
1894
+ colorSection.add(camera);
18201895
18211896 cGridBag ambient = new cGridBag();
18221897 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18231898 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18241899 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1825
- globalSection.add(ambient);
1900
+ colorSection.add(ambient);
18261901
18271902 cGridBag backlit = new cGridBag();
18281903 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18291904 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18301905 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1831
- globalSection.add(backlit);
1906
+ colorSection.add(backlit);
18321907
18331908 cGridBag opacity = new cGridBag();
18341909 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
18351910 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18361911 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1837
- globalSection.add(opacity);
1912
+ colorSection.add(opacity);
18381913
1839
- panel.add(new JSeparator());
1914
+ //panel.add(new JSeparator());
18401915
1841
- panel.add(globalSection);
1916
+ //panel.add(globalSection);
18421917
18431918 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18441919
....@@ -1945,8 +2020,9 @@
19452020 // 3D models
19462021 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19472022 {
1948
- lastConverter = new com.jmex.model.converters.MaxToJme();
1949
- LoadFile(filename, lastConverter);
2023
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2024
+ //LoadFile(filename, lastConverter);
2025
+ LoadObjFile(filename); // New 3ds loader
19502026 continue;
19512027 }
19522028 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2672,6 +2748,7 @@
26722748 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26732749 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26742750 }
2751
+
26752752 //cJME.count++;
26762753 //cJME.count %= 12;
26772754 if (gc)
....@@ -2855,6 +2932,7 @@
28552932 }
28562933 }
28572934 }
2935
+
28582936 cFileSystemPane FSPane;
28592937
28602938 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2908,6 +2986,7 @@
29082986 }
29092987 }
29102988 }
2989
+
29112990 freezematerial = false;
29122991 }
29132992
....@@ -3360,9 +3439,9 @@
33603439 {
33613440 Close();
33623441 //return true;
3363
- } else if (source == loadItem)
3442
+ } else if (source == openItem)
33643443 {
3365
- load();
3444
+ Open();
33663445 //return true;
33673446 } else if (source == newItem)
33683447 {
....@@ -3387,6 +3466,10 @@
33873466 {
33883467 generatePOV();
33893468 //return true;
3469
+ } else if (event.getSource() == archiveItem)
3470
+ {
3471
+ cTools.Archive(frame);
3472
+ return;
33903473 } else if (source == zBufferItem)
33913474 {
33923475 try
....@@ -3438,8 +3521,8 @@
34383521 try
34393522 {
34403523 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3441
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3442
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3524
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3525
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34433526
34443527 Object3D parent = o.parent;
34453528 o.parent = null;
....@@ -3450,10 +3533,14 @@
34503533
34513534 out.flush();
34523535
3453
- zstream.close();
3536
+ baos //zstream
3537
+ .close();
34543538 out.close();
34553539
3456
- return baos.toByteArray();
3540
+ byte[] bytes = baos.toByteArray();
3541
+
3542
+ System.out.println("save #bytes = " + bytes.length);
3543
+ return bytes;
34573544 } catch (Exception e)
34583545 {
34593546 System.err.println(e);
....@@ -3463,13 +3550,16 @@
34633550
34643551 static public Object Uncompress(byte[] bytes)
34653552 {
3466
- System.out.println("#bytes = " + bytes.length);
3553
+ System.out.println("restore #bytes = " + bytes.length);
34673554 try
34683555 {
34693556 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3470
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3471
- ObjectInputStream in = new ObjectInputStream(istream);
3557
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3558
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34723559 Object obj = in.readObject();
3560
+
3561
+ bais //istream
3562
+ .close();
34733563 in.close();
34743564
34753565 return obj;
....@@ -3524,31 +3614,67 @@
35243614 return null;
35253615 }
35263616
3527
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35283617
35293618 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)
35303643 {
35313644 System.err.println("Save");
35323645
35333646 cRadio tab = GetCurrentTab();
35343647
3535
- boolean temp = CameraPane.SWITCH;
3536
- CameraPane.SWITCH = false;
3648
+ byte[] compress = CompressCopy();
35373649
3538
- 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
+ }
35393657
35403658 //EditorFrame.m_MainFrame.requestFocusInWindow();
3541
- 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
+ }
35423669
3543
- copy.RestoreBigData(hashtable);
3670
+ //copy.RestoreBigData(versiontable);
35443671
3545
- CameraPane.SWITCH = temp;
3546
-
35473672 //assert(hashtable.isEmpty());
35483673
3549
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3674
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
35503675 {
3551
- tab.graphs[i] = null;
3676
+ //tab.user[i] = false;
3677
+ copy.versions[i] = null;
35523678 }
35533679
35543680 SetUndoStates();
....@@ -3558,7 +3684,7 @@
35583684 {
35593685 try
35603686 {
3561
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3687
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35623688 ObjectOutputStream p = new ObjectOutputStream(ostream);
35633689
35643690 p.writeObject(copy);
....@@ -3571,6 +3697,8 @@
35713697 e.printStackTrace();
35723698 }
35733699 }
3700
+
3701
+ return !thesame;
35743702 }
35753703
35763704 void CopyChanged(Object3D obj)
....@@ -3580,7 +3708,7 @@
35803708 boolean temp = CameraPane.SWITCH;
35813709 CameraPane.SWITCH = false;
35823710
3583
- copy.ExtractBigData(hashtable);
3711
+ copy.ExtractBigData(versiontable);
35843712
35853713 copy.clear();
35863714
....@@ -3589,7 +3717,7 @@
35893717 copy.add(obj.get(i));
35903718 }
35913719
3592
- copy.RestoreBigData(hashtable);
3720
+ copy.RestoreBigData(versiontable);
35933721
35943722 CameraPane.SWITCH = temp;
35953723
....@@ -3617,52 +3745,129 @@
36173745 }
36183746
36193747 cButton undoButton;
3748
+ cButton restoreButton;
3749
+ cButton replaceButton;
36203750 cButton redoButton;
36213751
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
+
36223767 void SetUndoStates()
36233768 {
36243769 cRadio tab = GetCurrentTab();
36253770
3626
- undoButton.setEnabled(tab.undoindex > 0);
3627
- 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;
36283781 }
36293782
3630
- public void Undo()
3783
+ public boolean Undo()
36313784 {
3785
+ // Option?
3786
+ Replace();
3787
+
36323788 System.err.println("Undo");
36333789
36343790 cRadio tab = GetCurrentTab();
36353791
3636
- if (tab.undoindex == 0)
3792
+ if (copy.versionindex == 0)
36373793 {
36383794 java.awt.Toolkit.getDefaultToolkit().beep();
3639
- return;
3795
+ return false;
36403796 }
36413797
3642
- 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)
36433825 {
3644
- Save();
3645
- tab.undoindex -= 1;
3826
+ java.awt.Toolkit.getDefaultToolkit().beep();
3827
+ return false;
36463828 }
36473829
3648
- tab.undoindex -= 1;
3830
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3831
+
3832
+ return true;
3833
+ }
36493834
3650
- 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;
36513850 }
36523851
36533852 public void Redo()
36543853 {
3854
+ // Option?
3855
+ Replace();
3856
+
36553857 cRadio tab = GetCurrentTab();
36563858
3657
- if (tab.graphs[tab.undoindex + 1] == null)
3859
+ if (copy.versions[copy.versionindex + 1] == null)
36583860 {
36593861 java.awt.Toolkit.getDefaultToolkit().beep();
36603862 return;
36613863 }
36623864
3663
- tab.undoindex += 1;
3865
+ copy.versionindex += 1;
36643866
3665
- 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;
36663871 }
36673872
36683873 void ImportGFD()
....@@ -3958,9 +4163,25 @@
39584163 //copy.Touch();
39594164 }
39604165
4166
+ cNumberSlider versionSlider;
4167
+
39614168 public void stateChanged(ChangeEvent e)
39624169 {
39634170 // 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
+ }
39644185
39654186 if (freezematerial)
39664187 {
....@@ -4309,7 +4530,7 @@
43094530
43104531 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
43114532 {
4312
- if (Globals.SAVEONMAKE) // && resetmodel)
4533
+ if (Globals.REPLACEONMAKE) // && resetmodel)
43134534 Save();
43144535 //Tween.set(thing, 0).target(1).start(tweenManager);
43154536 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4625,8 +4846,8 @@
46254846
46264847 if (readobj != null)
46274848 {
4628
- if (Globals.SAVEONMAKE)
4629
- Save();
4849
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4850
+ // Save();
46304851 try
46314852 {
46324853 //readobj.deepCopySelf(copy);
....@@ -4681,13 +4902,24 @@
46814902 c.addChild(csg);
46824903 }
46834904
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
+
46844916 ResetModel();
46854917 copy.HardTouch(); // recompile?
46864918 refreshContents();
46874919 }
46884920 }
46894921
4690
- void load() // throws ClassNotFoundException
4922
+ void Open() // throws ClassNotFoundException
46914923 {
46924924 if (Grafreed.standAlone)
46934925 {
....@@ -4972,7 +5204,7 @@
49725204 MenuBar menuBar;
49735205 Menu fileMenu;
49745206 MenuItem newItem;
4975
- MenuItem loadItem;
5207
+ MenuItem openItem;
49765208 MenuItem saveItem;
49775209 MenuItem saveAsItem;
49785210 MenuItem exportAsItem;
....@@ -4995,6 +5227,7 @@
49955227 CheckboxMenuItem toggleSwitchItem;
49965228 CheckboxMenuItem toggleRootItem;
49975229 CheckboxMenuItem animationItem;
5230
+ MenuItem archiveItem;
49985231 CheckboxMenuItem toggleHandleItem;
49995232 CheckboxMenuItem togglePaintItem;
50005233 JSplitPane mainPanel;