Normand Briere
2019-07-17 a5580a47d246c1272b10adba68070f6e13da5e41
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.
....@@ -207,7 +210,7 @@
207210
208211 objEditor.ctrlPanel.remove(namePanel);
209212
210
- if (!GroupEditor.allparams)
213
+ if (!allparams)
211214 return;
212215
213216 // objEditor.ctrlPanel.remove(liveCB);
....@@ -306,7 +309,7 @@
306309 //localCopy.parent = null;
307310
308311 frame = new JFrame();
309
- frame.setUndecorated(true);
312
+ frame.setUndecorated(false);
310313 objEditor = this;
311314 this.callee = callee;
312315
....@@ -337,12 +340,17 @@
337340 return frame.action(event, obj);
338341 }
339342
343
+ // Cannot work without static
344
+ static boolean allparams = true;
345
+
346
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
347
+
340348 void SetupMenu()
341349 {
342350 frame.setMenuBar(menuBar = new MenuBar());
343351 menuBar.add(fileMenu = new Menu("File"));
344352 fileMenu.add(newItem = new MenuItem("New"));
345
- fileMenu.add(loadItem = new MenuItem("Open..."));
353
+ fileMenu.add(openItem = new MenuItem("Open..."));
346354
347355 //oe.menuBar.add(menu = new Menu("Include"));
348356 Menu menu = new Menu("Import");
....@@ -374,7 +382,7 @@
374382 }
375383
376384 newItem.addActionListener(this);
377
- loadItem.addActionListener(this);
385
+ openItem.addActionListener(this);
378386 saveItem.addActionListener(this);
379387 saveAsItem.addActionListener(this);
380388 exportAsItem.addActionListener(this);
....@@ -397,6 +405,11 @@
397405 // }
398406 //
399407 // materialFlushed = true;
408
+// }
409
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
410
+// {
411
+// if (listUI.size() == 0)
412
+// EditSelection(false);
400413 // }
401414
402415 refreshContents(false); // To refresh Info tab
....@@ -436,7 +449,7 @@
436449 // TEXTAREA infoarea.setLineWrap(true);
437450 // TEXTAREA infoarea.setWrapStyleWord(true);
438451 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
439
- infoPanel.setPreferredSize(new Dimension(50, 200));
452
+ infoPanel.setPreferredSize(new Dimension(1, 1));
440453 infoPanel.setName("Info");
441454 //infoPanel.setLayout(new BorderLayout());
442455 //infoPanel.add(createTextPane());
....@@ -448,7 +461,14 @@
448461 mainPanel.setDividerSize(9);
449462 mainPanel.setDividerLocation(0.5); //1.0);
450463 mainPanel.setResizeWeight(0.5);
451
-
464
+
465
+//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!"));
469
+
470
+ mainPanel.setUI(new BasicSplitPaneUI());
471
+
452472 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
453473 //mainPanel.setLayout(new GridBagLayout());
454474 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -679,8 +699,8 @@
679699 }
680700 }
681701
682
-static GraphicsDevice device = GraphicsEnvironment
683
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
702
+//static GraphicsDevice device = GraphicsEnvironment
703
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
684704
685705 Rectangle keeprect;
686706 cRadio radio;
....@@ -701,10 +721,19 @@
701721 void Minimize()
702722 {
703723 frame.setState(Frame.ICONIFIED);
724
+ frame.validate();
704725 }
705726
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={}
706730 void Maximize()
707731 {
732
+ if (CameraPane.FULLSCREEN)
733
+ {
734
+ ToggleFullScreen();
735
+ }
736
+
708737 if (maximized)
709738 {
710739 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -712,20 +741,36 @@
712741 else
713742 {
714743 keeprect = frame.getBounds();
715
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
716
- Dimension rect2 = frame.getToolkit().getScreenSize();
717
- 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);
718747 // frame.setState(Frame.MAXIMIZED_BOTH);
748
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
719749 }
720750
721751 maximized ^= true;
752
+
753
+ frame.validate();
722754 }
755
+
756
+ cButton minButton;
757
+ cButton maxButton;
758
+ cButton fullButton;
723759
724760 void ToggleFullScreen()
725761 {
726
- if (CameraPane.FULLSCREEN)
762
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
763
+
764
+ cameraView.ToggleFullScreen();
765
+
766
+ if (!CameraPane.FULLSCREEN)
727767 {
728768 device.setFullScreenWindow(null);
769
+ frame.dispose();
770
+ frame.setUndecorated(false);
771
+ frame.validate();
772
+ frame.setVisible(true);
773
+
729774 //frame.setVisible(false);
730775 // frame.removeNotify();
731776 // frame.setUndecorated(false);
....@@ -735,7 +780,7 @@
735780 // X frame.getContentPane().remove(/*"Center",*/bigThree);
736781 // X framePanel.add(bigThree);
737782 // X frame.getContentPane().add(/*"Center",*/framePanel);
738
- framePanel.setDividerLocation(1);
783
+ framePanel.setDividerLocation(46);
739784
740785 //frame.setVisible(true);
741786 radio.layout = keepButton;
....@@ -750,7 +795,12 @@
750795 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
751796 // frame.getToolkit().getScreenSize().height);
752797 //frame.setVisible(false);
798
+
799
+ frame.dispose();
800
+ frame.setUndecorated(true);
753801 device.setFullScreenWindow(frame);
802
+ frame.validate();
803
+ frame.setVisible(true);
754804 // frame.removeNotify();
755805 // frame.setUndecorated(true);
756806 // frame.addNotify();
....@@ -763,9 +813,30 @@
763813 radio.layout.doClick();
764814 //frame.setVisible(true);
765815 }
766
-
767
- cameraView.ToggleFullScreen();
816
+ frame.validate();
768817 }
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
+ }
769840
770841 private JTextPane createTextPane()
771842 {
....@@ -1097,12 +1168,12 @@
10971168 namePanel = new cGridBag();
10981169
10991170 nameField = AddText(namePanel, copy.GetName());
1100
- namePanel.add(nameField);
1171
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11011172 oe.ctrlPanel.add(namePanel);
11021173
11031174 oe.ctrlPanel.Return();
11041175
1105
- if (!GroupEditor.allparams)
1176
+ if (!allparams)
11061177 return;
11071178
11081179 setupPanel = new cGridBag().setVertical(false);
....@@ -1115,20 +1186,21 @@
11151186 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11161187 hideCB.setToolTipText("Hide object");
11171188 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1118
- markCB.setToolTipText("Set the animation target transform");
1189
+ markCB.setToolTipText("As animation target transform");
11191190
11201191 setupPanel2 = new cGridBag().setVertical(false);
11211192
11221193 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11231194 rewindCB.setToolTipText("Rewind animation");
11241195
1125
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1126
- randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1196
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1197
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11271198
1199
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1200
+ link2masterCB.setToolTipText("Attach to support");
1201
+
11281202 if (Globals.ADVANCED)
11291203 {
1130
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1131
- link2masterCB.setToolTipText("Attach to support");
11321204 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11331205 speedupCB.setToolTipText("Option motion capture");
11341206 }
....@@ -1439,13 +1511,16 @@
14391511 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14401512 //tmp.setName("Edit");
14411513 objectPanel.add(materialPanel);
1442
- objectPanel.add(toolboxPanel);
14431514 // JPanel north = new JPanel(new BorderLayout());
14441515 // north.setName("Edit");
14451516 // north.add(ctrlPanel, BorderLayout.NORTH);
14461517 // objectPanel.add(north);
14471518 objectPanel.add(editPanel);
1448
- objectPanel.add(infoPanel);
1519
+
1520
+ //if (Globals.ADVANCED)
1521
+ objectPanel.add(infoPanel);
1522
+
1523
+ objectPanel.add(toolboxPanel);
14491524
14501525 /*
14511526 aConstraints.gridx = 0;
....@@ -1454,7 +1529,7 @@
14541529 aConstraints.gridy += 1;
14551530 aConstraints.gridwidth = 1;
14561531 mainPanel.add(objectPanel, aConstraints);
1457
- */
1532
+ */
14581533
14591534 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
14601535 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1553,9 +1628,9 @@
15531628 // aConstraints.gridheight = 1;
15541629
15551630 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1556
- framePanel.setContinuousLayout(true);
1557
- framePanel.setOneTouchExpandable(true);
1558
- framePanel.setDividerLocation(0.8);
1631
+ framePanel.setContinuousLayout(false);
1632
+ framePanel.setOneTouchExpandable(false);
1633
+ //.setDividerLocation(0.8);
15591634 //framePanel.setDividerSize(15);
15601635 //framePanel.setResizeWeight(0.15);
15611636 framePanel.setName("Frame");
....@@ -1574,12 +1649,13 @@
15741649
15751650 frame.setSize(1280, 860);
15761651
1577
- frame.validate();
1578
- frame.setVisible(true);
1579
-
15801652 cameraView.requestFocusInWindow();
15811653
15821654 gridPanel.setDividerLocation(1.0);
1655
+
1656
+ frame.validate();
1657
+
1658
+ frame.setVisible(true);
15831659
15841660 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
15851661 frame.addWindowListener(new WindowAdapter()
....@@ -1666,24 +1742,6 @@
16661742 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16671743 colorSection.add(texture);
16681744
1669
- cGridBag anisoU = new cGridBag();
1670
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1671
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1672
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1673
- colorSection.add(anisoU);
1674
-
1675
- cGridBag anisoV = new cGridBag();
1676
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1677
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1678
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1679
- colorSection.add(anisoV);
1680
-
1681
- cGridBag shadowbias = new cGridBag();
1682
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1683
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1684
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1685
- colorSection.add(shadowbias);
1686
-
16871745 panel.add(new JSeparator());
16881746
16891747 panel.add(colorSection);
....@@ -1733,6 +1791,12 @@
17331791 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17341792 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17351793 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);
17361800
17371801 panel.add(new JSeparator());
17381802
....@@ -1784,6 +1848,18 @@
17841848 // aConstraints.gridy += 1;
17851849 // aConstraints.gridwidth = 1;
17861850
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
+
17871863
17881864 panel.add(new JSeparator());
17891865
....@@ -1791,35 +1867,35 @@
17911867
17921868 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17931869
1794
- cGridBag globalSection = new cGridBag().setVertical(true);
1870
+ //cGridBag globalSection = new cGridBag().setVertical(true);
17951871
17961872 cGridBag camera = new cGridBag();
17971873 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
17981874 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17991875 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1800
- globalSection.add(camera);
1876
+ colorSection.add(camera);
18011877
18021878 cGridBag ambient = new cGridBag();
18031879 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18041880 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18051881 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1806
- globalSection.add(ambient);
1882
+ colorSection.add(ambient);
18071883
18081884 cGridBag backlit = new cGridBag();
18091885 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18101886 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18111887 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1812
- globalSection.add(backlit);
1888
+ colorSection.add(backlit);
18131889
18141890 cGridBag opacity = new cGridBag();
18151891 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
18161892 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18171893 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1818
- globalSection.add(opacity);
1894
+ colorSection.add(opacity);
18191895
1820
- panel.add(new JSeparator());
1896
+ //panel.add(new JSeparator());
18211897
1822
- panel.add(globalSection);
1898
+ //panel.add(globalSection);
18231899
18241900 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18251901
....@@ -1926,8 +2002,9 @@
19262002 // 3D models
19272003 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19282004 {
1929
- lastConverter = new com.jmex.model.converters.MaxToJme();
1930
- LoadFile(filename, lastConverter);
2005
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2006
+ //LoadFile(filename, lastConverter);
2007
+ LoadObjFile(filename); // New 3ds loader
19312008 continue;
19322009 }
19332010 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2653,6 +2730,7 @@
26532730 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26542731 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26552732 }
2733
+
26562734 //cJME.count++;
26572735 //cJME.count %= 12;
26582736 if (gc)
....@@ -2836,6 +2914,7 @@
28362914 }
28372915 }
28382916 }
2917
+
28392918 cFileSystemPane FSPane;
28402919
28412920 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2889,6 +2968,7 @@
28892968 }
28902969 }
28912970 }
2971
+
28922972 freezematerial = false;
28932973 }
28942974
....@@ -3007,12 +3087,17 @@
30073087 // }
30083088
30093089 /**/
3010
- if (deselect)
3090
+ if (deselect || child == null)
30113091 {
30123092 //group.deselectAll();
30133093 //freeze = true;
30143094 GetTree().clearSelection();
30153095 //freeze = false;
3096
+
3097
+ if (child == null)
3098
+ {
3099
+ return;
3100
+ }
30163101 }
30173102
30183103 //group.addSelectee(child);
....@@ -3336,9 +3421,9 @@
33363421 {
33373422 Close();
33383423 //return true;
3339
- } else if (source == loadItem)
3424
+ } else if (source == openItem)
33403425 {
3341
- load();
3426
+ Open();
33423427 //return true;
33433428 } else if (source == newItem)
33443429 {
....@@ -3363,6 +3448,10 @@
33633448 {
33643449 generatePOV();
33653450 //return true;
3451
+ } else if (event.getSource() == archiveItem)
3452
+ {
3453
+ cTools.Archive(frame);
3454
+ return;
33663455 } else if (source == zBufferItem)
33673456 {
33683457 try
....@@ -3414,8 +3503,8 @@
34143503 try
34153504 {
34163505 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3417
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3418
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3506
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3507
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34193508
34203509 Object3D parent = o.parent;
34213510 o.parent = null;
....@@ -3426,10 +3515,14 @@
34263515
34273516 out.flush();
34283517
3429
- zstream.close();
3518
+ baos //zstream
3519
+ .close();
34303520 out.close();
34313521
3432
- return baos.toByteArray();
3522
+ byte[] bytes = baos.toByteArray();
3523
+
3524
+ System.out.println("save #bytes = " + bytes.length);
3525
+ return bytes;
34333526 } catch (Exception e)
34343527 {
34353528 System.err.println(e);
....@@ -3439,13 +3532,16 @@
34393532
34403533 static public Object Uncompress(byte[] bytes)
34413534 {
3442
- System.out.println("#bytes = " + bytes.length);
3535
+ System.out.println("restore #bytes = " + bytes.length);
34433536 try
34443537 {
34453538 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3446
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3447
- ObjectInputStream in = new ObjectInputStream(istream);
3539
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3540
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34483541 Object obj = in.readObject();
3542
+
3543
+ bais //istream
3544
+ .close();
34493545 in.close();
34503546
34513547 return obj;
....@@ -3500,39 +3596,77 @@
35003596 return null;
35013597 }
35023598
3503
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35043599
35053600 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)
35063625 {
35073626 System.err.println("Save");
35083627
35093628 cRadio tab = GetCurrentTab();
35103629
3511
- boolean temp = CameraPane.SWITCH;
3512
- CameraPane.SWITCH = false;
3630
+ byte[] compress = CompressCopy();
35133631
3514
- 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
+ }
35153639
35163640 //EditorFrame.m_MainFrame.requestFocusInWindow();
3517
- tab.graphs[tab.undoindex++] = Compress(copy);
3518
-
3519
- copy.RestoreBigData(hashtable);
3520
-
3521
- CameraPane.SWITCH = temp;
3522
-
3523
- //assert(hashtable.isEmpty());
3524
-
3525
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3641
+ if (!thesame)
35263642 {
3527
- tab.graphs[i] = null;
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++;
35283650 }
35293651
3652
+ //copy.RestoreBigData(versiontable);
3653
+
3654
+ //assert(hashtable.isEmpty());
3655
+
3656
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3657
+ {
3658
+ //tab.user[i] = false;
3659
+ copy.versions[i] = null;
3660
+ }
3661
+
3662
+ SetUndoStates();
3663
+
35303664 // test save
35313665 if (false)
35323666 {
35333667 try
35343668 {
3535
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3669
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35363670 ObjectOutputStream p = new ObjectOutputStream(ostream);
35373671
35383672 p.writeObject(copy);
....@@ -3545,14 +3679,18 @@
35453679 e.printStackTrace();
35463680 }
35473681 }
3682
+
3683
+ return !thesame;
35483684 }
35493685
35503686 void CopyChanged(Object3D obj)
35513687 {
3688
+ SetUndoStates();
3689
+
35523690 boolean temp = CameraPane.SWITCH;
35533691 CameraPane.SWITCH = false;
35543692
3555
- copy.ExtractBigData(hashtable);
3693
+ copy.ExtractBigData(versiontable);
35563694
35573695 copy.clear();
35583696
....@@ -3561,7 +3699,7 @@
35613699 copy.add(obj.get(i));
35623700 }
35633701
3564
- copy.RestoreBigData(hashtable);
3702
+ copy.RestoreBigData(versiontable);
35653703
35663704 CameraPane.SWITCH = temp;
35673705
....@@ -3588,42 +3726,103 @@
35883726 refreshContents();
35893727 }
35903728
3591
- public void Undo()
3729
+ cButton undoButton;
3730
+ cButton restoreButton;
3731
+ cButton replaceButton;
3732
+ cButton redoButton;
3733
+
3734
+ void SetUndoStates()
3735
+ {
3736
+ cRadio tab = GetCurrentTab();
3737
+
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);
3742
+ }
3743
+
3744
+ public boolean Undo()
35923745 {
35933746 System.err.println("Undo");
35943747
35953748 cRadio tab = GetCurrentTab();
35963749
3597
- if (tab.undoindex == 0)
3750
+ if (copy.versionindex == 0)
35983751 {
35993752 java.awt.Toolkit.getDefaultToolkit().beep();
3600
- return;
3753
+ return false;
36013754 }
36023755
3603
- 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)
36043783 {
3605
- Save();
3606
- tab.undoindex -= 1;
3784
+ java.awt.Toolkit.getDefaultToolkit().beep();
3785
+ return false;
36073786 }
36083787
3609
- tab.undoindex -= 1;
3788
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3789
+
3790
+ return true;
3791
+ }
36103792
3611
- 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;
36123808 }
36133809
36143810 public void Redo()
36153811 {
36163812 cRadio tab = GetCurrentTab();
36173813
3618
- if (tab.graphs[tab.undoindex + 1] == null)
3814
+ if (copy.versions[copy.versionindex + 1] == null)
36193815 {
36203816 java.awt.Toolkit.getDefaultToolkit().beep();
36213817 return;
36223818 }
36233819
3624
- tab.undoindex += 1;
3820
+ copy.versionindex += 1;
36253821
3626
- 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;
36273826 }
36283827
36293828 void ImportGFD()
....@@ -3919,9 +4118,22 @@
39194118 //copy.Touch();
39204119 }
39214120
4121
+ cNumberSlider versionField;
4122
+
39224123 public void stateChanged(ChangeEvent e)
39234124 {
39244125 // 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
+ }
39254137
39264138 if (freezematerial)
39274139 {
....@@ -4270,7 +4482,7 @@
42704482
42714483 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
42724484 {
4273
- if (Globals.SAVEONMAKE) // && resetmodel)
4485
+ if (Globals.REPLACEONMAKE) // && resetmodel)
42744486 Save();
42754487 //Tween.set(thing, 0).target(1).start(tweenManager);
42764488 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4586,8 +4798,8 @@
45864798
45874799 if (readobj != null)
45884800 {
4589
- if (Globals.SAVEONMAKE)
4590
- Save();
4801
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4802
+ // Save();
45914803 try
45924804 {
45934805 //readobj.deepCopySelf(copy);
....@@ -4642,13 +4854,18 @@
46424854 c.addChild(csg);
46434855 }
46444856
4857
+ copy.versions = readobj.versions;
4858
+ copy.versionindex = readobj.versionindex;
4859
+
4860
+ SetUndoStates();
4861
+
46454862 ResetModel();
46464863 copy.HardTouch(); // recompile?
46474864 refreshContents();
46484865 }
46494866 }
46504867
4651
- void load() // throws ClassNotFoundException
4868
+ void Open() // throws ClassNotFoundException
46524869 {
46534870 if (Grafreed.standAlone)
46544871 {
....@@ -4765,6 +4982,8 @@
47654982 String filename = browser.getFile();
47664983 if (filename != null && filename.length() > 0)
47674984 {
4985
+ if (!filename.endsWith(".gfd"))
4986
+ filename += ".gfd";
47684987 lastname = browser.getDirectory() + filename;
47694988 save();
47704989 }
....@@ -4931,7 +5150,7 @@
49315150 MenuBar menuBar;
49325151 Menu fileMenu;
49335152 MenuItem newItem;
4934
- MenuItem loadItem;
5153
+ MenuItem openItem;
49355154 MenuItem saveItem;
49365155 MenuItem saveAsItem;
49375156 MenuItem exportAsItem;
....@@ -4954,6 +5173,7 @@
49545173 CheckboxMenuItem toggleSwitchItem;
49555174 CheckboxMenuItem toggleRootItem;
49565175 CheckboxMenuItem animationItem;
5176
+ MenuItem archiveItem;
49575177 CheckboxMenuItem toggleHandleItem;
49585178 CheckboxMenuItem togglePaintItem;
49595179 JSplitPane mainPanel;