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.
....@@ -49,6 +52,19 @@
4952 catch (Exception e)
5053 {
5154 return new cButton(name, border);
55
+ }
56
+ }
57
+
58
+ cToggleButton GetToggleButton(String name, boolean border)
59
+ {
60
+ try
61
+ {
62
+ ImageIcon icon = GetIcon(name);
63
+ return new cToggleButton(icon, border);
64
+ }
65
+ catch (Exception e)
66
+ {
67
+ return new cToggleButton(name, border);
5268 }
5369 }
5470
....@@ -194,7 +210,7 @@
194210
195211 objEditor.ctrlPanel.remove(namePanel);
196212
197
- if (!GroupEditor.allparams)
213
+ if (!allparams)
198214 return;
199215
200216 // objEditor.ctrlPanel.remove(liveCB);
....@@ -293,7 +309,7 @@
293309 //localCopy.parent = null;
294310
295311 frame = new JFrame();
296
- frame.setUndecorated(true);
312
+ frame.setUndecorated(false);
297313 objEditor = this;
298314 this.callee = callee;
299315
....@@ -324,12 +340,17 @@
324340 return frame.action(event, obj);
325341 }
326342
343
+ // Cannot work without static
344
+ static boolean allparams = true;
345
+
346
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
347
+
327348 void SetupMenu()
328349 {
329350 frame.setMenuBar(menuBar = new MenuBar());
330351 menuBar.add(fileMenu = new Menu("File"));
331352 fileMenu.add(newItem = new MenuItem("New"));
332
- fileMenu.add(loadItem = new MenuItem("Open..."));
353
+ fileMenu.add(openItem = new MenuItem("Open..."));
333354
334355 //oe.menuBar.add(menu = new Menu("Include"));
335356 Menu menu = new Menu("Import");
....@@ -361,7 +382,7 @@
361382 }
362383
363384 newItem.addActionListener(this);
364
- loadItem.addActionListener(this);
385
+ openItem.addActionListener(this);
365386 saveItem.addActionListener(this);
366387 saveAsItem.addActionListener(this);
367388 exportAsItem.addActionListener(this);
....@@ -370,6 +391,32 @@
370391 closeItem.addActionListener(this);
371392
372393 objectPanel = new JTabbedPane();
394
+
395
+ ChangeListener changeListener = new ChangeListener()
396
+ {
397
+ public void stateChanged(ChangeEvent changeEvent)
398
+ {
399
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
400
+// {
401
+// if (latestObject != null)
402
+// {
403
+// refreshContents(true);
404
+// SetMaterial(latestObject);
405
+// }
406
+//
407
+// materialFlushed = true;
408
+// }
409
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
410
+// {
411
+// if (listUI.size() == 0)
412
+// EditSelection(false);
413
+// }
414
+
415
+ refreshContents(false); // To refresh Info tab
416
+ }
417
+ };
418
+ objectPanel.addChangeListener(changeListener);
419
+
373420 toolbarPanel = new JPanel();
374421 toolbarPanel.setName("Toolbar");
375422 treePanel = new cGridBag();
....@@ -384,9 +431,12 @@
384431 editPanel.add(editCommandsPanel);
385432 editPanel.add(ctrlPanel);
386433
387
- materialPanel = new cGridBag().setVertical(true);
434
+ toolboxPanel = new cGridBag().setVertical(false);
435
+ toolboxPanel.setName("Toolbox");
388436
437
+ materialPanel = new cGridBag().setVertical(true);
389438 materialPanel.setName("Material");
439
+
390440 /*JTextPane*/
391441 infoarea = createTextPane();
392442 doc = infoarea.getStyledDocument();
....@@ -399,7 +449,7 @@
399449 // TEXTAREA infoarea.setLineWrap(true);
400450 // TEXTAREA infoarea.setWrapStyleWord(true);
401451 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
402
- infoPanel.setPreferredSize(new Dimension(50, 200));
452
+ infoPanel.setPreferredSize(new Dimension(1, 1));
403453 infoPanel.setName("Info");
404454 //infoPanel.setLayout(new BorderLayout());
405455 //infoPanel.add(createTextPane());
....@@ -411,7 +461,14 @@
411461 mainPanel.setDividerSize(9);
412462 mainPanel.setDividerLocation(0.5); //1.0);
413463 mainPanel.setResizeWeight(0.5);
414
-
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
+
415472 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
416473 //mainPanel.setLayout(new GridBagLayout());
417474 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -642,8 +699,8 @@
642699 }
643700 }
644701
645
-static GraphicsDevice device = GraphicsEnvironment
646
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
702
+//static GraphicsDevice device = GraphicsEnvironment
703
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
647704
648705 Rectangle keeprect;
649706 cRadio radio;
....@@ -659,13 +716,24 @@
659716
660717 boolean maximized;
661718
719
+ cButton fullscreenLayout;
720
+
662721 void Minimize()
663722 {
664723 frame.setState(Frame.ICONIFIED);
724
+ frame.validate();
665725 }
666726
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={}
667730 void Maximize()
668731 {
732
+ if (CameraPane.FULLSCREEN)
733
+ {
734
+ ToggleFullScreen();
735
+ }
736
+
669737 if (maximized)
670738 {
671739 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -673,20 +741,36 @@
673741 else
674742 {
675743 keeprect = frame.getBounds();
676
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
677
- Dimension rect2 = frame.getToolkit().getScreenSize();
678
- 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);
679747 // frame.setState(Frame.MAXIMIZED_BOTH);
748
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
680749 }
681750
682751 maximized ^= true;
752
+
753
+ frame.validate();
683754 }
755
+
756
+ cButton minButton;
757
+ cButton maxButton;
758
+ cButton fullButton;
684759
685760 void ToggleFullScreen()
686761 {
687
- if (CameraPane.FULLSCREEN)
762
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
763
+
764
+ cameraView.ToggleFullScreen();
765
+
766
+ if (!CameraPane.FULLSCREEN)
688767 {
689768 device.setFullScreenWindow(null);
769
+ frame.dispose();
770
+ frame.setUndecorated(false);
771
+ frame.validate();
772
+ frame.setVisible(true);
773
+
690774 //frame.setVisible(false);
691775 // frame.removeNotify();
692776 // frame.setUndecorated(false);
....@@ -696,7 +780,7 @@
696780 // X frame.getContentPane().remove(/*"Center",*/bigThree);
697781 // X framePanel.add(bigThree);
698782 // X frame.getContentPane().add(/*"Center",*/framePanel);
699
- framePanel.setDividerLocation(1);
783
+ framePanel.setDividerLocation(46);
700784
701785 //frame.setVisible(true);
702786 radio.layout = keepButton;
....@@ -711,7 +795,12 @@
711795 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
712796 // frame.getToolkit().getScreenSize().height);
713797 //frame.setVisible(false);
798
+
799
+ frame.dispose();
800
+ frame.setUndecorated(true);
714801 device.setFullScreenWindow(frame);
802
+ frame.validate();
803
+ frame.setVisible(true);
715804 // frame.removeNotify();
716805 // frame.setUndecorated(true);
717806 // frame.addNotify();
....@@ -720,13 +809,34 @@
720809 // X frame.getContentPane().add(/*"Center",*/bigThree);
721810 framePanel.setDividerLocation(0);
722811
723
- radio.layout = twoButton;
812
+ radio.layout = fullscreenLayout;
724813 radio.layout.doClick();
725814 //frame.setVisible(true);
726815 }
727
-
728
- cameraView.ToggleFullScreen();
816
+ frame.validate();
729817 }
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
+ }
730840
731841 private JTextPane createTextPane()
732842 {
....@@ -866,7 +976,12 @@
866976 JCheckBox speedupCB;
867977 JCheckBox rewindCB;
868978 JCheckBox flipVCB;
979
+
980
+ cCheckBox toggleTextureCB;
981
+ cCheckBox toggleSwitchCB;
982
+
869983 JComboBox texresMenu;
984
+
870985 JButton resetButton;
871986 JButton stepButton;
872987 JButton stepAllButton;
....@@ -1053,12 +1168,12 @@
10531168 namePanel = new cGridBag();
10541169
10551170 nameField = AddText(namePanel, copy.GetName());
1056
- namePanel.add(nameField);
1171
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
10571172 oe.ctrlPanel.add(namePanel);
10581173
10591174 oe.ctrlPanel.Return();
10601175
1061
- if (!GroupEditor.allparams)
1176
+ if (!allparams)
10621177 return;
10631178
10641179 setupPanel = new cGridBag().setVertical(false);
....@@ -1071,20 +1186,21 @@
10711186 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
10721187 hideCB.setToolTipText("Hide object");
10731188 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1074
- markCB.setToolTipText("Set the animation target transform");
1189
+ markCB.setToolTipText("As animation target transform");
10751190
10761191 setupPanel2 = new cGridBag().setVertical(false);
10771192
10781193 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
10791194 rewindCB.setToolTipText("Rewind animation");
10801195
1081
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1082
- 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)");
10831198
1199
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1200
+ link2masterCB.setToolTipText("Attach to support");
1201
+
10841202 if (Globals.ADVANCED)
10851203 {
1086
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1087
- link2masterCB.setToolTipText("Attach to support");
10881204 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
10891205 speedupCB.setToolTipText("Option motion capture");
10901206 }
....@@ -1400,7 +1516,11 @@
14001516 // north.add(ctrlPanel, BorderLayout.NORTH);
14011517 // objectPanel.add(north);
14021518 objectPanel.add(editPanel);
1403
- objectPanel.add(infoPanel);
1519
+
1520
+ //if (Globals.ADVANCED)
1521
+ objectPanel.add(infoPanel);
1522
+
1523
+ objectPanel.add(toolboxPanel);
14041524
14051525 /*
14061526 aConstraints.gridx = 0;
....@@ -1409,7 +1529,7 @@
14091529 aConstraints.gridy += 1;
14101530 aConstraints.gridwidth = 1;
14111531 mainPanel.add(objectPanel, aConstraints);
1412
- */
1532
+ */
14131533
14141534 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
14151535 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1426,9 +1546,7 @@
14261546 JTabbedPane tabbedPane = new JTabbedPane();
14271547 tabbedPane.add(scrollpane);
14281548
1429
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1430
-
1431
- optionsPanel = new cGridBag().setVertical(true);
1549
+ optionsPanel = new cGridBag().setVertical(false);
14321550
14331551 optionsPanel.setName("Options");
14341552
....@@ -1436,6 +1554,8 @@
14361554
14371555 tabbedPane.add(optionsPanel);
14381556
1557
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1558
+
14391559 scenePanel.add(tabbedPane);
14401560
14411561 /*
....@@ -1508,9 +1628,9 @@
15081628 // aConstraints.gridheight = 1;
15091629
15101630 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1511
- framePanel.setContinuousLayout(true);
1512
- framePanel.setOneTouchExpandable(true);
1513
- framePanel.setDividerLocation(0.8);
1631
+ framePanel.setContinuousLayout(false);
1632
+ framePanel.setOneTouchExpandable(false);
1633
+ //.setDividerLocation(0.8);
15141634 //framePanel.setDividerSize(15);
15151635 //framePanel.setResizeWeight(0.15);
15161636 framePanel.setName("Frame");
....@@ -1528,11 +1648,14 @@
15281648 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
15291649
15301650 frame.setSize(1280, 860);
1531
- frame.setVisible(true);
1532
-
1651
+
15331652 cameraView.requestFocusInWindow();
15341653
15351654 gridPanel.setDividerLocation(1.0);
1655
+
1656
+ frame.validate();
1657
+
1658
+ frame.setVisible(true);
15361659
15371660 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
15381661 frame.addWindowListener(new WindowAdapter()
....@@ -1619,24 +1742,6 @@
16191742 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16201743 colorSection.add(texture);
16211744
1622
- cGridBag anisoU = new cGridBag();
1623
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1624
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1625
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1626
- colorSection.add(anisoU);
1627
-
1628
- cGridBag anisoV = new cGridBag();
1629
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1630
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1631
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1632
- colorSection.add(anisoV);
1633
-
1634
- cGridBag shadowbias = new cGridBag();
1635
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1636
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1637
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1638
- colorSection.add(shadowbias);
1639
-
16401745 panel.add(new JSeparator());
16411746
16421747 panel.add(colorSection);
....@@ -1686,6 +1791,12 @@
16861791 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16871792 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
16881793 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);
16891800
16901801 panel.add(new JSeparator());
16911802
....@@ -1737,6 +1848,18 @@
17371848 // aConstraints.gridy += 1;
17381849 // aConstraints.gridwidth = 1;
17391850
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
+
17401863
17411864 panel.add(new JSeparator());
17421865
....@@ -1744,35 +1867,35 @@
17441867
17451868 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17461869
1747
- cGridBag globalSection = new cGridBag().setVertical(true);
1870
+ //cGridBag globalSection = new cGridBag().setVertical(true);
17481871
17491872 cGridBag camera = new cGridBag();
17501873 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
17511874 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17521875 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1753
- globalSection.add(camera);
1876
+ colorSection.add(camera);
17541877
17551878 cGridBag ambient = new cGridBag();
17561879 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
17571880 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17581881 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1759
- globalSection.add(ambient);
1882
+ colorSection.add(ambient);
17601883
17611884 cGridBag backlit = new cGridBag();
17621885 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
17631886 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17641887 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1765
- globalSection.add(backlit);
1888
+ colorSection.add(backlit);
17661889
17671890 cGridBag opacity = new cGridBag();
17681891 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
17691892 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17701893 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1771
- globalSection.add(opacity);
1894
+ colorSection.add(opacity);
17721895
1773
- panel.add(new JSeparator());
1896
+ //panel.add(new JSeparator());
17741897
1775
- panel.add(globalSection);
1898
+ //panel.add(globalSection);
17761899
17771900 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17781901
....@@ -1879,8 +2002,9 @@
18792002 // 3D models
18802003 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
18812004 {
1882
- lastConverter = new com.jmex.model.converters.MaxToJme();
1883
- LoadFile(filename, lastConverter);
2005
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2006
+ //LoadFile(filename, lastConverter);
2007
+ LoadObjFile(filename); // New 3ds loader
18842008 continue;
18852009 }
18862010 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2606,6 +2730,7 @@
26062730 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26072731 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26082732 }
2733
+
26092734 //cJME.count++;
26102735 //cJME.count %= 12;
26112736 if (gc)
....@@ -2789,6 +2914,7 @@
27892914 }
27902915 }
27912916 }
2917
+
27922918 cFileSystemPane FSPane;
27932919
27942920 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2842,11 +2968,14 @@
28422968 }
28432969 }
28442970 }
2971
+
28452972 freezematerial = false;
28462973 }
28472974
28482975 void SetMaterial(Object3D object)
28492976 {
2977
+ latestObject = object;
2978
+
28502979 cMaterial mat = object.material;
28512980
28522981 if (mat == null)
....@@ -2958,12 +3087,17 @@
29583087 // }
29593088
29603089 /**/
2961
- if (deselect)
3090
+ if (deselect || child == null)
29623091 {
29633092 //group.deselectAll();
29643093 //freeze = true;
29653094 GetTree().clearSelection();
29663095 //freeze = false;
3096
+
3097
+ if (child == null)
3098
+ {
3099
+ return;
3100
+ }
29673101 }
29683102
29693103 //group.addSelectee(child);
....@@ -3032,7 +3166,7 @@
30323166 cameraView.ToggleDL();
30333167 cameraView.repaint();
30343168 return;
3035
- } else if (event.getSource() == toggleTextureItem)
3169
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
30363170 {
30373171 cameraView.ToggleTexture();
30383172 // june 2013 copy.HardTouch();
....@@ -3071,7 +3205,7 @@
30713205 frame.validate();
30723206
30733207 return;
3074
- } else if (event.getSource() == toggleSwitchItem)
3208
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
30753209 {
30763210 cameraView.ToggleSwitch();
30773211 cameraView.repaint();
....@@ -3287,9 +3421,9 @@
32873421 {
32883422 Close();
32893423 //return true;
3290
- } else if (source == loadItem)
3424
+ } else if (source == openItem)
32913425 {
3292
- load();
3426
+ Open();
32933427 //return true;
32943428 } else if (source == newItem)
32953429 {
....@@ -3314,6 +3448,10 @@
33143448 {
33153449 generatePOV();
33163450 //return true;
3451
+ } else if (event.getSource() == archiveItem)
3452
+ {
3453
+ cTools.Archive(frame);
3454
+ return;
33173455 } else if (source == zBufferItem)
33183456 {
33193457 try
....@@ -3365,8 +3503,8 @@
33653503 try
33663504 {
33673505 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3368
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3369
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3506
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3507
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
33703508
33713509 Object3D parent = o.parent;
33723510 o.parent = null;
....@@ -3377,10 +3515,14 @@
33773515
33783516 out.flush();
33793517
3380
- zstream.close();
3518
+ baos //zstream
3519
+ .close();
33813520 out.close();
33823521
3383
- return baos.toByteArray();
3522
+ byte[] bytes = baos.toByteArray();
3523
+
3524
+ System.out.println("save #bytes = " + bytes.length);
3525
+ return bytes;
33843526 } catch (Exception e)
33853527 {
33863528 System.err.println(e);
....@@ -3390,13 +3532,16 @@
33903532
33913533 static public Object Uncompress(byte[] bytes)
33923534 {
3393
- System.out.println("#bytes = " + bytes.length);
3535
+ System.out.println("restore #bytes = " + bytes.length);
33943536 try
33953537 {
33963538 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3397
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3398
- ObjectInputStream in = new ObjectInputStream(istream);
3539
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3540
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
33993541 Object obj = in.readObject();
3542
+
3543
+ bais //istream
3544
+ .close();
34003545 in.close();
34013546
34023547 return obj;
....@@ -3451,39 +3596,77 @@
34513596 return null;
34523597 }
34533598
3454
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
34553599
34563600 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)
34573625 {
34583626 System.err.println("Save");
34593627
34603628 cRadio tab = GetCurrentTab();
34613629
3462
- boolean temp = CameraPane.SWITCH;
3463
- CameraPane.SWITCH = false;
3630
+ byte[] compress = CompressCopy();
34643631
3465
- 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
+ }
34663639
34673640 //EditorFrame.m_MainFrame.requestFocusInWindow();
3468
- tab.graphs[tab.undoindex++] = Compress(copy);
3469
-
3470
- copy.RestoreBigData(hashtable);
3471
-
3472
- CameraPane.SWITCH = temp;
3473
-
3474
- //assert(hashtable.isEmpty());
3475
-
3476
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3641
+ if (!thesame)
34773642 {
3478
- 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++;
34793650 }
34803651
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
+
34813664 // test save
34823665 if (false)
34833666 {
34843667 try
34853668 {
3486
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3669
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
34873670 ObjectOutputStream p = new ObjectOutputStream(ostream);
34883671
34893672 p.writeObject(copy);
....@@ -3496,14 +3679,18 @@
34963679 e.printStackTrace();
34973680 }
34983681 }
3682
+
3683
+ return !thesame;
34993684 }
35003685
35013686 void CopyChanged(Object3D obj)
35023687 {
3688
+ SetUndoStates();
3689
+
35033690 boolean temp = CameraPane.SWITCH;
35043691 CameraPane.SWITCH = false;
35053692
3506
- copy.ExtractBigData(hashtable);
3693
+ copy.ExtractBigData(versiontable);
35073694
35083695 copy.clear();
35093696
....@@ -3512,7 +3699,7 @@
35123699 copy.add(obj.get(i));
35133700 }
35143701
3515
- copy.RestoreBigData(hashtable);
3702
+ copy.RestoreBigData(versiontable);
35163703
35173704 CameraPane.SWITCH = temp;
35183705
....@@ -3539,42 +3726,103 @@
35393726 refreshContents();
35403727 }
35413728
3542
- 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()
35433745 {
35443746 System.err.println("Undo");
35453747
35463748 cRadio tab = GetCurrentTab();
35473749
3548
- if (tab.undoindex == 0)
3750
+ if (copy.versionindex == 0)
35493751 {
35503752 java.awt.Toolkit.getDefaultToolkit().beep();
3551
- return;
3753
+ return false;
35523754 }
35533755
3554
- 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)
35553783 {
3556
- Save();
3557
- tab.undoindex -= 1;
3784
+ java.awt.Toolkit.getDefaultToolkit().beep();
3785
+ return false;
35583786 }
35593787
3560
- tab.undoindex -= 1;
3788
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3789
+
3790
+ return true;
3791
+ }
35613792
3562
- 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;
35633808 }
35643809
35653810 public void Redo()
35663811 {
35673812 cRadio tab = GetCurrentTab();
35683813
3569
- if (tab.graphs[tab.undoindex + 1] == null)
3814
+ if (copy.versions[copy.versionindex + 1] == null)
35703815 {
35713816 java.awt.Toolkit.getDefaultToolkit().beep();
35723817 return;
35733818 }
35743819
3575
- tab.undoindex += 1;
3820
+ copy.versionindex += 1;
35763821
3577
- 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;
35783826 }
35793827
35803828 void ImportGFD()
....@@ -3726,7 +3974,7 @@
37263974 assert false;
37273975 }
37283976
3729
- void EditSelection()
3977
+ void EditSelection(boolean newWindow)
37303978 {
37313979 }
37323980
....@@ -3870,9 +4118,22 @@
38704118 //copy.Touch();
38714119 }
38724120
4121
+ cNumberSlider versionField;
4122
+
38734123 public void stateChanged(ChangeEvent e)
38744124 {
38754125 // 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
+ }
38764137
38774138 if (freezematerial)
38784139 {
....@@ -4221,7 +4482,7 @@
42214482
42224483 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
42234484 {
4224
- if (Globals.SAVEONMAKE)
4485
+ if (Globals.REPLACEONMAKE) // && resetmodel)
42254486 Save();
42264487 //Tween.set(thing, 0).target(1).start(tweenManager);
42274488 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4309,6 +4570,12 @@
43094570 {
43104571 ResetModel();
43114572 Select(thing.GetTreePath(), true, false); // unselect... false);
4573
+
4574
+ if (thing.Size() == 0)
4575
+ {
4576
+ //EditSelection(false);
4577
+ }
4578
+
43124579 refreshContents();
43134580 }
43144581
....@@ -4531,8 +4798,8 @@
45314798
45324799 if (readobj != null)
45334800 {
4534
- if (Globals.SAVEONMAKE)
4535
- Save();
4801
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4802
+ // Save();
45364803 try
45374804 {
45384805 //readobj.deepCopySelf(copy);
....@@ -4587,13 +4854,18 @@
45874854 c.addChild(csg);
45884855 }
45894856
4857
+ copy.versions = readobj.versions;
4858
+ copy.versionindex = readobj.versionindex;
4859
+
4860
+ SetUndoStates();
4861
+
45904862 ResetModel();
45914863 copy.HardTouch(); // recompile?
45924864 refreshContents();
45934865 }
45944866 }
45954867
4596
- void load() // throws ClassNotFoundException
4868
+ void Open() // throws ClassNotFoundException
45974869 {
45984870 if (Grafreed.standAlone)
45994871 {
....@@ -4710,6 +4982,8 @@
47104982 String filename = browser.getFile();
47114983 if (filename != null && filename.length() > 0)
47124984 {
4985
+ if (!filename.endsWith(".gfd"))
4986
+ filename += ".gfd";
47134987 lastname = browser.getDirectory() + filename;
47144988 save();
47154989 }
....@@ -4876,7 +5150,7 @@
48765150 MenuBar menuBar;
48775151 Menu fileMenu;
48785152 MenuItem newItem;
4879
- MenuItem loadItem;
5153
+ MenuItem openItem;
48805154 MenuItem saveItem;
48815155 MenuItem saveAsItem;
48825156 MenuItem exportAsItem;
....@@ -4899,22 +5173,36 @@
48995173 CheckboxMenuItem toggleSwitchItem;
49005174 CheckboxMenuItem toggleRootItem;
49015175 CheckboxMenuItem animationItem;
5176
+ MenuItem archiveItem;
49025177 CheckboxMenuItem toggleHandleItem;
49035178 CheckboxMenuItem togglePaintItem;
49045179 JSplitPane mainPanel;
49055180 JScrollPane scrollpane;
5181
+
49065182 JPanel toolbarPanel;
5183
+
49075184 cGridBag treePanel;
5185
+
49085186 JPanel radioPanel;
49095187 ButtonGroup buttonGroup;
4910
- cGridBag ctrlPanel;
5188
+
5189
+ cGridBag toolboxPanel;
49115190 cGridBag materialPanel;
5191
+ cGridBag ctrlPanel;
5192
+
49125193 JScrollPane infoPanel;
5194
+
49135195 cGridBag optionsPanel;
5196
+
49145197 JTabbedPane objectPanel;
5198
+ boolean materialFlushed;
5199
+ Object3D latestObject;
5200
+
49155201 cGridBag XYZPanel;
5202
+
49165203 JSplitPane gridPanel;
49175204 JSplitPane bigPanel;
5205
+
49185206 cGridBag bigThree;
49195207 cGridBag scenePanel;
49205208 cGridBag centralPanel;
....@@ -5029,7 +5317,7 @@
50295317 cNumberSlider fogField;
50305318 JLabel opacityPowerLabel;
50315319 cNumberSlider opacityPowerField;
5032
- JTree jTree;
5320
+ cTree jTree;
50335321 //ObjectUI parent;
50345322
50355323 cNumberSlider normalpushField;