Normand Briere
2019-07-18 d7a17c35c443e2cb6c09eaa3cfeaf590a571faa1
ObjEditor.java
....@@ -15,6 +15,9 @@
1515 //import javax.swing.plaf.ColorUIResource;
1616 //import javax.swing.plaf.metal.DefaultMetalTheme;
1717
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
20
+
1821 //import javax.media.opengl.GLCanvas;
1922
2023 import //weka.core.
....@@ -279,6 +282,12 @@
279282 client = inClient;
280283 copy = client;
281284
285
+ if (copy.versions == null)
286
+ {
287
+ copy.versions = new byte[100][];
288
+ copy.versionindex = -1;
289
+ }
290
+
282291 // "this" is not called: SetupUI2(objEditor);
283292 }
284293
....@@ -292,6 +301,12 @@
292301 client = inClient;
293302 copy = client;
294303
304
+ if (copy.versions == null)
305
+ {
306
+ copy.versions = new byte[100][];
307
+ copy.versionindex = -1;
308
+ }
309
+
295310 SetupUI2(callee.GetEditor());
296311 }
297312
....@@ -306,7 +321,7 @@
306321 //localCopy.parent = null;
307322
308323 frame = new JFrame();
309
- frame.setUndecorated(true);
324
+ frame.setUndecorated(false);
310325 objEditor = this;
311326 this.callee = callee;
312327
....@@ -324,6 +339,12 @@
324339 copy = localCopy;
325340 copy.editWindow = this;
326341
342
+ if (copy.versions == null)
343
+ {
344
+ copy.versions = new byte[100][];
345
+ copy.versionindex = -1;
346
+ }
347
+
327348 SetupMenu();
328349
329350 //SetupName(objEditor); // new
....@@ -347,7 +368,7 @@
347368 frame.setMenuBar(menuBar = new MenuBar());
348369 menuBar.add(fileMenu = new Menu("File"));
349370 fileMenu.add(newItem = new MenuItem("New"));
350
- fileMenu.add(loadItem = new MenuItem("Open..."));
371
+ fileMenu.add(openItem = new MenuItem("Open..."));
351372
352373 //oe.menuBar.add(menu = new Menu("Include"));
353374 Menu menu = new Menu("Import");
....@@ -379,7 +400,7 @@
379400 }
380401
381402 newItem.addActionListener(this);
382
- loadItem.addActionListener(this);
403
+ openItem.addActionListener(this);
383404 saveItem.addActionListener(this);
384405 saveAsItem.addActionListener(this);
385406 exportAsItem.addActionListener(this);
....@@ -446,7 +467,7 @@
446467 // TEXTAREA infoarea.setLineWrap(true);
447468 // TEXTAREA infoarea.setWrapStyleWord(true);
448469 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
449
- infoPanel.setPreferredSize(new Dimension(50, 200));
470
+ infoPanel.setPreferredSize(new Dimension(1, 1));
450471 infoPanel.setName("Info");
451472 //infoPanel.setLayout(new BorderLayout());
452473 //infoPanel.add(createTextPane());
....@@ -458,7 +479,14 @@
458479 mainPanel.setDividerSize(9);
459480 mainPanel.setDividerLocation(0.5); //1.0);
460481 mainPanel.setResizeWeight(0.5);
461
-
482
+
483
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
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!"));
487
+
488
+ mainPanel.setUI(new BasicSplitPaneUI());
489
+
462490 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
463491 //mainPanel.setLayout(new GridBagLayout());
464492 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -689,8 +717,8 @@
689717 }
690718 }
691719
692
-static GraphicsDevice device = GraphicsEnvironment
693
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
720
+//static GraphicsDevice device = GraphicsEnvironment
721
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
694722
695723 Rectangle keeprect;
696724 cRadio radio;
....@@ -711,10 +739,19 @@
711739 void Minimize()
712740 {
713741 frame.setState(Frame.ICONIFIED);
742
+ frame.validate();
714743 }
715744
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={}
716748 void Maximize()
717749 {
750
+ if (CameraPane.FULLSCREEN)
751
+ {
752
+ ToggleFullScreen();
753
+ }
754
+
718755 if (maximized)
719756 {
720757 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -722,22 +759,36 @@
722759 else
723760 {
724761 keeprect = frame.getBounds();
725
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
726
- Dimension rect2 = frame.getToolkit().getScreenSize();
727
- frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
762
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
763
+// Dimension rect2 = frame.getToolkit().getScreenSize();
764
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
728765 // frame.setState(Frame.MAXIMIZED_BOTH);
766
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
729767 }
730768
731769 maximized ^= true;
770
+
771
+ frame.validate();
732772 }
773
+
774
+ cButton minButton;
775
+ cButton maxButton;
776
+ cButton fullButton;
733777
734778 void ToggleFullScreen()
735779 {
780
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
781
+
736782 cameraView.ToggleFullScreen();
737783
738784 if (!CameraPane.FULLSCREEN)
739785 {
740786 device.setFullScreenWindow(null);
787
+ frame.dispose();
788
+ frame.setUndecorated(false);
789
+ frame.validate();
790
+ frame.setVisible(true);
791
+
741792 //frame.setVisible(false);
742793 // frame.removeNotify();
743794 // frame.setUndecorated(false);
....@@ -747,7 +798,7 @@
747798 // X frame.getContentPane().remove(/*"Center",*/bigThree);
748799 // X framePanel.add(bigThree);
749800 // X frame.getContentPane().add(/*"Center",*/framePanel);
750
- framePanel.setDividerLocation(1);
801
+ framePanel.setDividerLocation(46);
751802
752803 //frame.setVisible(true);
753804 radio.layout = keepButton;
....@@ -762,7 +813,12 @@
762813 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
763814 // frame.getToolkit().getScreenSize().height);
764815 //frame.setVisible(false);
816
+
817
+ frame.dispose();
818
+ frame.setUndecorated(true);
765819 device.setFullScreenWindow(frame);
820
+ frame.validate();
821
+ frame.setVisible(true);
766822 // frame.removeNotify();
767823 // frame.setUndecorated(true);
768824 // frame.addNotify();
....@@ -775,7 +831,30 @@
775831 radio.layout.doClick();
776832 //frame.setVisible(true);
777833 }
834
+ frame.validate();
778835 }
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
+ }
779858
780859 private JTextPane createTextPane()
781860 {
....@@ -1107,7 +1186,7 @@
11071186 namePanel = new cGridBag();
11081187
11091188 nameField = AddText(namePanel, copy.GetName());
1110
- namePanel.add(nameField);
1189
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11111190 oe.ctrlPanel.add(namePanel);
11121191
11131192 oe.ctrlPanel.Return();
....@@ -1125,20 +1204,21 @@
11251204 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11261205 hideCB.setToolTipText("Hide object");
11271206 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1128
- markCB.setToolTipText("Set the animation target transform");
1207
+ markCB.setToolTipText("As animation target transform");
11291208
11301209 setupPanel2 = new cGridBag().setVertical(false);
11311210
11321211 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11331212 rewindCB.setToolTipText("Rewind animation");
11341213
1135
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1136
- randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1214
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1215
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11371216
1217
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1218
+ link2masterCB.setToolTipText("Attach to support");
1219
+
11381220 if (Globals.ADVANCED)
11391221 {
1140
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1141
- link2masterCB.setToolTipText("Attach to support");
11421222 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11431223 speedupCB.setToolTipText("Option motion capture");
11441224 }
....@@ -1454,7 +1534,10 @@
14541534 // north.add(ctrlPanel, BorderLayout.NORTH);
14551535 // objectPanel.add(north);
14561536 objectPanel.add(editPanel);
1457
- objectPanel.add(infoPanel);
1537
+
1538
+ //if (Globals.ADVANCED)
1539
+ objectPanel.add(infoPanel);
1540
+
14581541 objectPanel.add(toolboxPanel);
14591542
14601543 /*
....@@ -1563,9 +1646,9 @@
15631646 // aConstraints.gridheight = 1;
15641647
15651648 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1566
- framePanel.setContinuousLayout(true);
1567
- framePanel.setOneTouchExpandable(true);
1568
- framePanel.setDividerLocation(0.8);
1649
+ framePanel.setContinuousLayout(false);
1650
+ framePanel.setOneTouchExpandable(false);
1651
+ //.setDividerLocation(0.8);
15691652 //framePanel.setDividerSize(15);
15701653 //framePanel.setResizeWeight(0.15);
15711654 framePanel.setName("Frame");
....@@ -1584,12 +1667,13 @@
15841667
15851668 frame.setSize(1280, 860);
15861669
1587
- frame.validate();
1588
- frame.setVisible(true);
1589
-
15901670 cameraView.requestFocusInWindow();
15911671
15921672 gridPanel.setDividerLocation(1.0);
1673
+
1674
+ frame.validate();
1675
+
1676
+ frame.setVisible(true);
15931677
15941678 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
15951679 frame.addWindowListener(new WindowAdapter()
....@@ -1676,24 +1760,6 @@
16761760 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16771761 colorSection.add(texture);
16781762
1679
- cGridBag anisoU = new cGridBag();
1680
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1681
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1682
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1683
- colorSection.add(anisoU);
1684
-
1685
- cGridBag anisoV = new cGridBag();
1686
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1687
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1688
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1689
- colorSection.add(anisoV);
1690
-
1691
- cGridBag shadowbias = new cGridBag();
1692
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1693
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1694
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1695
- colorSection.add(shadowbias);
1696
-
16971763 panel.add(new JSeparator());
16981764
16991765 panel.add(colorSection);
....@@ -1743,6 +1809,12 @@
17431809 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17441810 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17451811 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);
17461818
17471819 panel.add(new JSeparator());
17481820
....@@ -1794,6 +1866,18 @@
17941866 // aConstraints.gridy += 1;
17951867 // aConstraints.gridwidth = 1;
17961868
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
+
17971881
17981882 panel.add(new JSeparator());
17991883
....@@ -1801,35 +1885,35 @@
18011885
18021886 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18031887
1804
- cGridBag globalSection = new cGridBag().setVertical(true);
1888
+ //cGridBag globalSection = new cGridBag().setVertical(true);
18051889
18061890 cGridBag camera = new cGridBag();
18071891 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
18081892 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18091893 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1810
- globalSection.add(camera);
1894
+ colorSection.add(camera);
18111895
18121896 cGridBag ambient = new cGridBag();
18131897 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18141898 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18151899 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1816
- globalSection.add(ambient);
1900
+ colorSection.add(ambient);
18171901
18181902 cGridBag backlit = new cGridBag();
18191903 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18201904 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18211905 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1822
- globalSection.add(backlit);
1906
+ colorSection.add(backlit);
18231907
18241908 cGridBag opacity = new cGridBag();
18251909 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
18261910 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18271911 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1828
- globalSection.add(opacity);
1912
+ colorSection.add(opacity);
18291913
1830
- panel.add(new JSeparator());
1914
+ //panel.add(new JSeparator());
18311915
1832
- panel.add(globalSection);
1916
+ //panel.add(globalSection);
18331917
18341918 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18351919
....@@ -1936,8 +2020,9 @@
19362020 // 3D models
19372021 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19382022 {
1939
- lastConverter = new com.jmex.model.converters.MaxToJme();
1940
- LoadFile(filename, lastConverter);
2023
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2024
+ //LoadFile(filename, lastConverter);
2025
+ LoadObjFile(filename); // New 3ds loader
19412026 continue;
19422027 }
19432028 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2663,6 +2748,7 @@
26632748 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26642749 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26652750 }
2751
+
26662752 //cJME.count++;
26672753 //cJME.count %= 12;
26682754 if (gc)
....@@ -2846,6 +2932,7 @@
28462932 }
28472933 }
28482934 }
2935
+
28492936 cFileSystemPane FSPane;
28502937
28512938 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2899,6 +2986,7 @@
28992986 }
29002987 }
29012988 }
2989
+
29022990 freezematerial = false;
29032991 }
29042992
....@@ -3017,12 +3105,17 @@
30173105 // }
30183106
30193107 /**/
3020
- if (deselect)
3108
+ if (deselect || child == null)
30213109 {
30223110 //group.deselectAll();
30233111 //freeze = true;
30243112 GetTree().clearSelection();
30253113 //freeze = false;
3114
+
3115
+ if (child == null)
3116
+ {
3117
+ return;
3118
+ }
30263119 }
30273120
30283121 //group.addSelectee(child);
....@@ -3346,9 +3439,9 @@
33463439 {
33473440 Close();
33483441 //return true;
3349
- } else if (source == loadItem)
3442
+ } else if (source == openItem)
33503443 {
3351
- load();
3444
+ Open();
33523445 //return true;
33533446 } else if (source == newItem)
33543447 {
....@@ -3373,6 +3466,10 @@
33733466 {
33743467 generatePOV();
33753468 //return true;
3469
+ } else if (event.getSource() == archiveItem)
3470
+ {
3471
+ cTools.Archive(frame);
3472
+ return;
33763473 } else if (source == zBufferItem)
33773474 {
33783475 try
....@@ -3424,8 +3521,8 @@
34243521 try
34253522 {
34263523 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3427
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3428
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3524
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3525
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34293526
34303527 Object3D parent = o.parent;
34313528 o.parent = null;
....@@ -3436,10 +3533,14 @@
34363533
34373534 out.flush();
34383535
3439
- zstream.close();
3536
+ baos //zstream
3537
+ .close();
34403538 out.close();
34413539
3442
- return baos.toByteArray();
3540
+ byte[] bytes = baos.toByteArray();
3541
+
3542
+ System.out.println("save #bytes = " + bytes.length);
3543
+ return bytes;
34433544 } catch (Exception e)
34443545 {
34453546 System.err.println(e);
....@@ -3449,13 +3550,16 @@
34493550
34503551 static public Object Uncompress(byte[] bytes)
34513552 {
3452
- System.out.println("#bytes = " + bytes.length);
3553
+ System.out.println("restore #bytes = " + bytes.length);
34533554 try
34543555 {
34553556 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3456
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3457
- ObjectInputStream in = new ObjectInputStream(istream);
3557
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3558
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34583559 Object obj = in.readObject();
3560
+
3561
+ bais //istream
3562
+ .close();
34593563 in.close();
34603564
34613565 return obj;
....@@ -3510,31 +3614,67 @@
35103614 return null;
35113615 }
35123616
3513
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35143617
35153618 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)
35163643 {
35173644 System.err.println("Save");
35183645
35193646 cRadio tab = GetCurrentTab();
35203647
3521
- boolean temp = CameraPane.SWITCH;
3522
- CameraPane.SWITCH = false;
3648
+ byte[] compress = CompressCopy();
35233649
3524
- 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
+ }
35253657
35263658 //EditorFrame.m_MainFrame.requestFocusInWindow();
3527
- 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
+ }
35283669
3529
- copy.RestoreBigData(hashtable);
3670
+ //copy.RestoreBigData(versiontable);
35303671
3531
- CameraPane.SWITCH = temp;
3532
-
35333672 //assert(hashtable.isEmpty());
35343673
3535
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3674
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
35363675 {
3537
- tab.graphs[i] = null;
3676
+ //tab.user[i] = false;
3677
+ copy.versions[i] = null;
35383678 }
35393679
35403680 SetUndoStates();
....@@ -3544,7 +3684,7 @@
35443684 {
35453685 try
35463686 {
3547
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3687
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35483688 ObjectOutputStream p = new ObjectOutputStream(ostream);
35493689
35503690 p.writeObject(copy);
....@@ -3557,6 +3697,8 @@
35573697 e.printStackTrace();
35583698 }
35593699 }
3700
+
3701
+ return !thesame;
35603702 }
35613703
35623704 void CopyChanged(Object3D obj)
....@@ -3566,7 +3708,7 @@
35663708 boolean temp = CameraPane.SWITCH;
35673709 CameraPane.SWITCH = false;
35683710
3569
- copy.ExtractBigData(hashtable);
3711
+ copy.ExtractBigData(versiontable);
35703712
35713713 copy.clear();
35723714
....@@ -3575,7 +3717,7 @@
35753717 copy.add(obj.get(i));
35763718 }
35773719
3578
- copy.RestoreBigData(hashtable);
3720
+ copy.RestoreBigData(versiontable);
35793721
35803722 CameraPane.SWITCH = temp;
35813723
....@@ -3603,52 +3745,129 @@
36033745 }
36043746
36053747 cButton undoButton;
3748
+ cButton restoreButton;
3749
+ cButton replaceButton;
36063750 cButton redoButton;
36073751
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
+
36083767 void SetUndoStates()
36093768 {
36103769 cRadio tab = GetCurrentTab();
36113770
3612
- undoButton.setEnabled(tab.undoindex > 0);
3613
- 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;
36143781 }
36153782
3616
- public void Undo()
3783
+ public boolean Undo()
36173784 {
3785
+ // Option?
3786
+ Replace();
3787
+
36183788 System.err.println("Undo");
36193789
36203790 cRadio tab = GetCurrentTab();
36213791
3622
- if (tab.undoindex == 0)
3792
+ if (copy.versionindex == 0)
36233793 {
36243794 java.awt.Toolkit.getDefaultToolkit().beep();
3625
- return;
3795
+ return false;
36263796 }
36273797
3628
- 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)
36293825 {
3630
- Save();
3631
- tab.undoindex -= 1;
3826
+ java.awt.Toolkit.getDefaultToolkit().beep();
3827
+ return false;
36323828 }
36333829
3634
- tab.undoindex -= 1;
3830
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3831
+
3832
+ return true;
3833
+ }
36353834
3636
- 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;
36373850 }
36383851
36393852 public void Redo()
36403853 {
3854
+ // Option?
3855
+ Replace();
3856
+
36413857 cRadio tab = GetCurrentTab();
36423858
3643
- if (tab.graphs[tab.undoindex + 1] == null)
3859
+ if (copy.versions[copy.versionindex + 1] == null)
36443860 {
36453861 java.awt.Toolkit.getDefaultToolkit().beep();
36463862 return;
36473863 }
36483864
3649
- tab.undoindex += 1;
3865
+ copy.versionindex += 1;
36503866
3651
- 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;
36523871 }
36533872
36543873 void ImportGFD()
....@@ -3944,9 +4163,25 @@
39444163 //copy.Touch();
39454164 }
39464165
4166
+ cNumberSlider versionSlider;
4167
+
39474168 public void stateChanged(ChangeEvent e)
39484169 {
39494170 // 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
+ }
39504185
39514186 if (freezematerial)
39524187 {
....@@ -4295,7 +4530,7 @@
42954530
42964531 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
42974532 {
4298
- if (Globals.SAVEONMAKE) // && resetmodel)
4533
+ if (Globals.REPLACEONMAKE) // && resetmodel)
42994534 Save();
43004535 //Tween.set(thing, 0).target(1).start(tweenManager);
43014536 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4611,8 +4846,8 @@
46114846
46124847 if (readobj != null)
46134848 {
4614
- if (Globals.SAVEONMAKE)
4615
- Save();
4849
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4850
+ // Save();
46164851 try
46174852 {
46184853 //readobj.deepCopySelf(copy);
....@@ -4667,13 +4902,24 @@
46674902 c.addChild(csg);
46684903 }
46694904
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
+
46704916 ResetModel();
46714917 copy.HardTouch(); // recompile?
46724918 refreshContents();
46734919 }
46744920 }
46754921
4676
- void load() // throws ClassNotFoundException
4922
+ void Open() // throws ClassNotFoundException
46774923 {
46784924 if (Grafreed.standAlone)
46794925 {
....@@ -4958,7 +5204,7 @@
49585204 MenuBar menuBar;
49595205 Menu fileMenu;
49605206 MenuItem newItem;
4961
- MenuItem loadItem;
5207
+ MenuItem openItem;
49625208 MenuItem saveItem;
49635209 MenuItem saveAsItem;
49645210 MenuItem exportAsItem;
....@@ -4981,6 +5227,7 @@
49815227 CheckboxMenuItem toggleSwitchItem;
49825228 CheckboxMenuItem toggleRootItem;
49835229 CheckboxMenuItem animationItem;
5230
+ MenuItem archiveItem;
49845231 CheckboxMenuItem toggleHandleItem;
49855232 CheckboxMenuItem togglePaintItem;
49865233 JSplitPane mainPanel;