Normand Briere
2019-08-01 c99d954f5e2bffa601c599142371cfeb45630f40
ObjEditor.java
....@@ -4,6 +4,7 @@
44
55 import java.awt.*;
66 import java.awt.event.*;
7
+import java.awt.image.BufferedImage;
78 import javax.swing.*;
89 import javax.swing.event.*;
910 import javax.swing.text.*;
....@@ -13,6 +14,9 @@
1314 import javax.swing.plaf.metal.MetalLookAndFeel;
1415 //import javax.swing.plaf.ColorUIResource;
1516 //import javax.swing.plaf.metal.DefaultMetalTheme;
17
+
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
1620
1721 //import javax.media.opengl.GLCanvas;
1822
....@@ -35,6 +39,81 @@
3539
3640 GroupEditor callee;
3741 JFrame frame;
42
+
43
+ static ObjEditor theFrame;
44
+
45
+ public cGridBag GetSeparator()
46
+ {
47
+ cGridBag separator = new cGridBag();
48
+ separator.add(new JSeparator());
49
+ separator.preferredHeight = 5;
50
+ return separator;
51
+ }
52
+
53
+ cButton GetButton(String name, boolean border)
54
+ {
55
+ ImageIcon icon = GetIcon(name);
56
+ return new cButton(icon, border);
57
+ }
58
+
59
+ cLabel GetLabel(String name, boolean border)
60
+ {
61
+ //ImageIcon icon = GetIcon(name);
62
+ return new cLabel(GetImage(name), border);
63
+ }
64
+
65
+ cToggleButton GetToggleButton(String name, boolean border)
66
+ {
67
+ ImageIcon icon = GetIcon(name);
68
+ return new cToggleButton(icon, border);
69
+ }
70
+
71
+ cCheckBox GetCheckBox(String name, boolean border)
72
+ {
73
+ ImageIcon icon = GetIcon(name);
74
+ return new cCheckBox(icon, border);
75
+ }
76
+
77
+ ImageIcon GetIcon(String name)
78
+ {
79
+ try
80
+ {
81
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
82
+
83
+// if (image.getWidth() > 48 && image.getHeight() > 48)
84
+// {
85
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
86
+// Graphics2D g = resized.createGraphics();
87
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
88
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
89
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
90
+// g.dispose();
91
+//
92
+// image = resized;
93
+// }
94
+
95
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
96
+ return icon;
97
+ }
98
+ catch (Exception e)
99
+ {
100
+ return null;
101
+ }
102
+ }
103
+
104
+ BufferedImage GetImage(String name)
105
+ {
106
+ try
107
+ {
108
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
109
+
110
+ return image;
111
+ }
112
+ catch (Exception e)
113
+ {
114
+ return null;
115
+ }
116
+ }
38117
39118 // SCRIPT
40119
....@@ -145,7 +224,7 @@
145224
146225 objEditor.ctrlPanel.remove(namePanel);
147226
148
- if (!GroupEditor.allparams)
227
+ if (!allparams)
149228 return;
150229
151230 // objEditor.ctrlPanel.remove(liveCB);
....@@ -169,7 +248,7 @@
169248
170249 objEditor.ctrlPanel.remove(setupPanel);
171250 objEditor.ctrlPanel.remove(setupPanel2);
172
- objEditor.ctrlPanel.remove(commandsPanel);
251
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
173252 objEditor.ctrlPanel.remove(pushPanel);
174253 //objEditor.ctrlPanel.remove(fillPanel);
175254
....@@ -217,6 +296,12 @@
217296 client = inClient;
218297 copy = client;
219298
299
+ if (copy.versions == null)
300
+ {
301
+ copy.versions = new byte[100][];
302
+ copy.versionindex = -1;
303
+ }
304
+
220305 // "this" is not called: SetupUI2(objEditor);
221306 }
222307
....@@ -230,6 +315,12 @@
230315 client = inClient;
231316 copy = client;
232317
318
+ if (copy.versions == null)
319
+ {
320
+ copy.versions = new byte[100][];
321
+ copy.versionindex = -1;
322
+ }
323
+
233324 SetupUI2(callee.GetEditor());
234325 }
235326
....@@ -244,6 +335,7 @@
244335 //localCopy.parent = null;
245336
246337 frame = new JFrame();
338
+ frame.setUndecorated(false);
247339 objEditor = this;
248340 this.callee = callee;
249341
....@@ -261,6 +353,12 @@
261353 copy = localCopy;
262354 copy.editWindow = this;
263355
356
+ if (copy.versions == null)
357
+ {
358
+// copy.versions = new byte[100][];
359
+// copy.versionindex = -1;
360
+ }
361
+
264362 SetupMenu();
265363
266364 //SetupName(objEditor); // new
....@@ -274,12 +372,17 @@
274372 return frame.action(event, obj);
275373 }
276374
375
+ // Cannot work without static
376
+ static boolean allparams = true;
377
+
378
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
379
+
277380 void SetupMenu()
278381 {
279382 frame.setMenuBar(menuBar = new MenuBar());
280383 menuBar.add(fileMenu = new Menu("File"));
281384 fileMenu.add(newItem = new MenuItem("New"));
282
- fileMenu.add(loadItem = new MenuItem("Open..."));
385
+ fileMenu.add(openItem = new MenuItem("Open..."));
283386
284387 //oe.menuBar.add(menu = new Menu("Include"));
285388 Menu menu = new Menu("Import");
....@@ -311,7 +414,7 @@
311414 }
312415
313416 newItem.addActionListener(this);
314
- loadItem.addActionListener(this);
417
+ openItem.addActionListener(this);
315418 saveItem.addActionListener(this);
316419 saveAsItem.addActionListener(this);
317420 exportAsItem.addActionListener(this);
....@@ -320,28 +423,68 @@
320423 closeItem.addActionListener(this);
321424
322425 objectPanel = new JTabbedPane();
426
+
427
+ ChangeListener changeListener = new ChangeListener()
428
+ {
429
+ public void stateChanged(ChangeEvent changeEvent)
430
+ {
431
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
432
+// {
433
+// if (latestObject != null)
434
+// {
435
+// refreshContents(true);
436
+// SetMaterial(latestObject);
437
+// }
438
+//
439
+// materialFlushed = true;
440
+// }
441
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
442
+// {
443
+// if (listUI.size() == 0)
444
+// EditSelection(false);
445
+// }
446
+
447
+ refreshContents(false); // To refresh Info tab
448
+ }
449
+ };
450
+ objectPanel.addChangeListener(changeListener);
451
+
323452 toolbarPanel = new JPanel();
324453 toolbarPanel.setName("Toolbar");
454
+
325455 treePanel = new cGridBag();
326456 treePanel.setName("Tree");
457
+
458
+ editPanel = new cGridBag().setVertical(true);
459
+ //editPanel.setName("Edit");
460
+
327461 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
328
- ctrlPanel.setName("Edit");
462
+
463
+ editCommandsPanel = new cGridBag();
464
+ editPanel.add(editCommandsPanel);
465
+ editPanel.add(ctrlPanel);
466
+
467
+ toolboxPanel = new cGridBag().setVertical(true);
468
+ //toolboxPanel.setName("Toolbox");
469
+
329470 materialPanel = new cGridBag().setVertical(true);
330
- materialPanel.setName("Material");
471
+ //materialPanel.setName("Material");
472
+
331473 /*JTextPane*/
332474 infoarea = createTextPane();
333475 doc = infoarea.getStyledDocument();
334476
335477 infoarea.setEditable(true);
336478 SetText();
479
+
337480 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
338481 // infoarea.setOpaque(false);
339482 // //infoarea.setForeground(textcolor);
340483 // TEXTAREA infoarea.setLineWrap(true);
341484 // TEXTAREA infoarea.setWrapStyleWord(true);
342485 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
343
- infoPanel.setPreferredSize(new Dimension(50, 200));
344
- infoPanel.setName("Info");
486
+ infoPanel.setPreferredSize(new Dimension(1, 1));
487
+ //infoPanel.setName("Info");
345488 //infoPanel.setLayout(new BorderLayout());
346489 //infoPanel.add(createTextPane());
347490
....@@ -352,7 +495,14 @@
352495 mainPanel.setDividerSize(9);
353496 mainPanel.setDividerLocation(0.5); //1.0);
354497 mainPanel.setResizeWeight(0.5);
355
-
498
+
499
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
500
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
501
+ divider.setDividerSize(15);
502
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
503
+
504
+ mainPanel.setUI(new BasicSplitPaneUI());
505
+
356506 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
357507 //mainPanel.setLayout(new GridBagLayout());
358508 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -583,21 +733,144 @@
583733 }
584734 }
585735
736
+//static GraphicsDevice device = GraphicsEnvironment
737
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
738
+
739
+ Rectangle keeprect;
740
+ cRadio radio;
741
+
742
+cButton keepButton;
743
+ cButton twoButton; // Full 3D
744
+ cButton sixButton;
745
+ cButton threeButton;
746
+ cButton sevenButton;
747
+ cButton fourButton; // full panel
748
+ cButton oneButton; // full XYZ
749
+ //cButton currentLayout;
750
+
751
+ boolean maximized;
752
+
753
+ cButton fullscreenLayout;
754
+
755
+ void Minimize()
756
+ {
757
+ frame.setState(Frame.ICONIFIED);
758
+ frame.validate();
759
+ }
760
+
761
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
762
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
763
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
764
+ void Maximize()
765
+ {
766
+ if (CameraPane.FULLSCREEN)
767
+ {
768
+ ToggleFullScreen();
769
+ }
770
+
771
+ if (maximized)
772
+ {
773
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
774
+ }
775
+ else
776
+ {
777
+ keeprect = frame.getBounds();
778
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
779
+// Dimension rect2 = frame.getToolkit().getScreenSize();
780
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
781
+// frame.setState(Frame.MAXIMIZED_BOTH);
782
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
783
+ }
784
+
785
+ maximized ^= true;
786
+
787
+ frame.validate();
788
+ }
789
+
790
+ cButton minButton;
791
+ cButton maxButton;
792
+ cButton fullButton;
793
+
586794 void ToggleFullScreen()
587795 {
588
- if (CameraPane.FULLSCREEN)
796
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
797
+
798
+ cameraView.ToggleFullScreen();
799
+
800
+ if (!CameraPane.FULLSCREEN)
589801 {
590
- frame.getContentPane().remove(/*"Center",*/bigThree);
591
- framePanel.add(bigThree);
592
- frame.getContentPane().add(/*"Center",*/framePanel);
802
+ device.setFullScreenWindow(null);
803
+ frame.dispose();
804
+ frame.setUndecorated(false);
805
+ frame.validate();
806
+ frame.setVisible(true);
807
+
808
+ //frame.setVisible(false);
809
+// frame.removeNotify();
810
+// frame.setUndecorated(false);
811
+// frame.addNotify();
812
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
813
+
814
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
815
+// X framePanel.add(bigThree);
816
+// X frame.getContentPane().add(/*"Center",*/framePanel);
817
+ framePanel.setDividerLocation(46);
818
+
819
+ //frame.setVisible(true);
820
+ radio.layout = keepButton;
821
+ //theFrame = null;
822
+ keepButton = null;
823
+ radio.layout.doClick();
824
+
593825 } else
594826 {
595
- frame.getContentPane().remove(/*"Center",*/framePanel);
596
- framePanel.remove(bigThree);
597
- frame.getContentPane().add(/*"Center",*/bigThree);
827
+ keepButton = radio.layout;
828
+ //keeprect = frame.getBounds();
829
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
830
+// frame.getToolkit().getScreenSize().height);
831
+ //frame.setVisible(false);
832
+
833
+ frame.dispose();
834
+ frame.setUndecorated(true);
835
+ device.setFullScreenWindow(frame);
836
+ frame.validate();
837
+ frame.setVisible(true);
838
+// frame.removeNotify();
839
+// frame.setUndecorated(true);
840
+// frame.addNotify();
841
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
842
+// X framePanel.remove(bigThree);
843
+// X frame.getContentPane().add(/*"Center",*/bigThree);
844
+ framePanel.setDividerLocation(0);
845
+
846
+ radio.layout = fullscreenLayout;
847
+ radio.layout.doClick();
848
+ //frame.setVisible(true);
598849 }
599
- cameraView.ToggleFullScreen();
850
+ frame.validate();
600851 }
852
+
853
+ private byte[] CompressCopy()
854
+ {
855
+ boolean temp = CameraPane.SWITCH;
856
+ CameraPane.SWITCH = false;
857
+
858
+ copy.ExtractBigData(versiontable);
859
+ // if (copy == client)
860
+
861
+ byte[] versions[] = copy.versions;
862
+ copy.versions = null;
863
+
864
+ byte[] compress = Compress(copy);
865
+
866
+ copy.versions = versions;
867
+
868
+ copy.RestoreBigData(versiontable);
869
+
870
+ CameraPane.SWITCH = temp;
871
+
872
+ return compress;
873
+ }
601874
602875 private JTextPane createTextPane()
603876 {
....@@ -729,7 +1002,7 @@
7291002 // NumberSlider vDivsField;
7301003 // JCheckBox endcaps;
7311004 JCheckBox liveCB;
732
- JCheckBox selectCB;
1005
+ JCheckBox selectableCB;
7331006 JCheckBox hideCB;
7341007 JCheckBox link2masterCB;
7351008 JCheckBox markCB;
....@@ -737,7 +1010,12 @@
7371010 JCheckBox speedupCB;
7381011 JCheckBox rewindCB;
7391012 JCheckBox flipVCB;
1013
+
1014
+ cCheckBox toggleTextureCB;
1015
+ cCheckBox toggleSwitchCB;
1016
+
7401017 JComboBox texresMenu;
1018
+
7411019 JButton resetButton;
7421020 JButton stepButton;
7431021 JButton stepAllButton;
....@@ -746,10 +1024,13 @@
7461024 JButton fasterButton;
7471025 JButton remarkButton;
7481026
1027
+ cGridBag editPanel;
1028
+ cGridBag editCommandsPanel;
1029
+
7491030 cGridBag namePanel;
7501031 cGridBag setupPanel;
7511032 cGridBag setupPanel2;
752
- cGridBag commandsPanel;
1033
+ cGridBag objectCommandsPanel;
7531034 cGridBag pushPanel;
7541035 cGridBag fillPanel;
7551036
....@@ -921,38 +1202,42 @@
9211202 namePanel = new cGridBag();
9221203
9231204 nameField = AddText(namePanel, copy.GetName());
924
- namePanel.add(nameField);
1205
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
9251206 oe.ctrlPanel.add(namePanel);
9261207
9271208 oe.ctrlPanel.Return();
9281209
929
- if (!GroupEditor.allparams)
1210
+ if (!allparams)
9301211 return;
9311212
9321213 setupPanel = new cGridBag().setVertical(false);
9331214
9341215 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
9351216 liveCB.setToolTipText("Animate object");
936
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
937
- selectCB.setToolTipText("Make object selectable");
1217
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1218
+ selectableCB.setToolTipText("Make object selectable");
9381219 // Return();
1220
+
9391221 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
9401222 hideCB.setToolTipText("Hide object");
9411223 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
942
- markCB.setToolTipText("Set the animation target transform");
1224
+ markCB.setToolTipText("As animation target transform");
1225
+
1226
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
9431227
9441228 setupPanel2 = new cGridBag().setVertical(false);
9451229
9461230 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
9471231 rewindCB.setToolTipText("Rewind animation");
9481232
949
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
950
- randomCB.setToolTipText("Rewind or Go back and forth randomly");
1233
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1234
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
9511235
1236
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1237
+ link2masterCB.setToolTipText("Attach to support");
1238
+
9521239 if (Globals.ADVANCED)
9531240 {
954
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
955
- link2masterCB.setToolTipText("Attach to support");
9561241 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
9571242 speedupCB.setToolTipText("Option motion capture");
9581243 }
....@@ -962,23 +1247,23 @@
9621247 oe.ctrlPanel.add(setupPanel2);
9631248 oe.ctrlPanel.Return();
9641249
965
- commandsPanel = new cGridBag().setVertical(false);
1250
+ objectCommandsPanel = new cGridBag().setVertical(false);
9661251
967
- resetButton = AddButton(commandsPanel, "Reset");
1252
+ resetButton = AddButton(objectCommandsPanel, "Reset");
9681253 resetButton.setToolTipText("Jump to frame zero");
969
- stepButton = AddButton(commandsPanel, "Step");
1254
+ stepButton = AddButton(objectCommandsPanel, "Step");
9701255 stepButton.setToolTipText("Step one frame");
9711256 // resetAllButton = AddButton(oe, "Reset All");
9721257 // stepAllButton = AddButton(oe, "Step All");
9731258 // Return();
974
- slowerButton = AddButton(commandsPanel, "Slow");
1259
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
9751260 slowerButton.setToolTipText("Decrease animation speed");
976
- fasterButton = AddButton(commandsPanel, "Fast");
1261
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
9771262 fasterButton.setToolTipText("Increase animation speed");
978
- remarkButton = AddButton(commandsPanel, "Remark");
1263
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
9791264 remarkButton.setToolTipText("Set the current transform as the target");
9801265
981
- oe.ctrlPanel.add(commandsPanel);
1266
+ oe.ctrlPanel.add(objectCommandsPanel);
9821267 oe.ctrlPanel.Return();
9831268
9841269 pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
....@@ -1184,8 +1469,11 @@
11841469 //worldPanel.setName("World");
11851470 centralPanel = new cGridBag();
11861471 centralPanel.preferredWidth = 20;
1187
- timelinePanel = new JPanel(new BorderLayout());
1188
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1472
+
1473
+ if (Globals.ADVANCED)
1474
+ {
1475
+ timelinePanel = new JPanel(new BorderLayout());
1476
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11891477
11901478 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11911479 cameraPanel.setContinuousLayout(true);
....@@ -1194,7 +1482,10 @@
11941482 // cameraPanel.setDividerSize(9);
11951483 cameraPanel.setResizeWeight(1.0);
11961484
1485
+ }
1486
+
11971487 centralPanel.add(cameraView);
1488
+ centralPanel.setFocusable(true);
11981489 //frame.setJMenuBar(timelineMenubar);
11991490 //centralPanel.add(timelinePanel);
12001491
....@@ -1220,6 +1511,7 @@
12201511 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
12211512 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
12221513 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1514
+ //XYZPanel.setName("XYZ");
12231515
12241516 /*
12251517 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1257,12 +1549,29 @@
12571549 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
12581550 //tmp.setName("Edit");
12591551 objectPanel.add(materialPanel);
1552
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1553
+ objectPanel.setToolTipTextAt(0, "Material panel");
1554
+
12601555 // JPanel north = new JPanel(new BorderLayout());
12611556 // north.setName("Edit");
12621557 // north.add(ctrlPanel, BorderLayout.NORTH);
12631558 // objectPanel.add(north);
1264
- objectPanel.add(ctrlPanel);
1265
- objectPanel.add(infoPanel);
1559
+ objectPanel.add(editPanel);
1560
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1561
+ objectPanel.setToolTipTextAt(1, "Edit panel");
1562
+
1563
+ //if (Globals.ADVANCED)
1564
+ objectPanel.add(infoPanel);
1565
+ objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1566
+ objectPanel.setToolTipTextAt(2, "Info panel");
1567
+
1568
+ objectPanel.add(XYZPanel);
1569
+ objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1570
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB panel");
1571
+
1572
+ objectPanel.add(toolboxPanel);
1573
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1574
+ objectPanel.setToolTipTextAt(4, "Objects/backgrounds panel");
12661575
12671576 /*
12681577 aConstraints.gridx = 0;
....@@ -1271,7 +1580,7 @@
12711580 aConstraints.gridy += 1;
12721581 aConstraints.gridwidth = 1;
12731582 mainPanel.add(objectPanel, aConstraints);
1274
- */
1583
+ */
12751584
12761585 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12771586 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1283,14 +1592,12 @@
12831592 scrollpane.addMouseWheelListener(this); // Default not fast enough
12841593
12851594 /*JTabbedPane*/ scenePanel = new cGridBag();
1286
- scenePanel.preferredWidth = 6;
1595
+ scenePanel.preferredWidth = 5;
12871596
12881597 JTabbedPane tabbedPane = new JTabbedPane();
12891598 tabbedPane.add(scrollpane);
12901599
1291
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1292
-
1293
- optionsPanel = new cGridBag().setVertical(true);
1600
+ optionsPanel = new cGridBag().setVertical(false);
12941601
12951602 optionsPanel.setName("Options");
12961603
....@@ -1298,6 +1605,8 @@
12981605
12991606 tabbedPane.add(optionsPanel);
13001607
1608
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1609
+
13011610 scenePanel.add(tabbedPane);
13021611
13031612 /*
....@@ -1361,7 +1670,7 @@
13611670 bigThree = new cGridBag();
13621671 bigThree.addComponent(scenePanel);
13631672 bigThree.addComponent(centralPanel);
1364
- bigThree.addComponent(XYZPanel);
1673
+ //bigThree.addComponent(XYZPanel);
13651674
13661675 // // SIDE EFFECT!!!
13671676 // aConstraints.gridx = 0;
....@@ -1370,9 +1679,9 @@
13701679 // aConstraints.gridheight = 1;
13711680
13721681 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1373
- framePanel.setContinuousLayout(true);
1374
- framePanel.setOneTouchExpandable(true);
1375
- framePanel.setDividerLocation(0.8);
1682
+ framePanel.setContinuousLayout(false);
1683
+ framePanel.setOneTouchExpandable(false);
1684
+ //.setDividerLocation(0.8);
13761685 //framePanel.setDividerSize(15);
13771686 //framePanel.setResizeWeight(0.15);
13781687 framePanel.setName("Frame");
....@@ -1390,14 +1699,18 @@
13901699 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13911700
13921701 frame.setSize(1280, 860);
1393
- frame.setVisible(true);
1394
-
1702
+
1703
+ cameraView.requestFocusInWindow();
1704
+
13951705 gridPanel.setDividerLocation(1.0);
1706
+
1707
+ frame.validate();
1708
+
1709
+ frame.setVisible(true);
13961710
13971711 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
13981712 frame.addWindowListener(new WindowAdapter()
13991713 {
1400
-
14011714 public void windowClosing(WindowEvent e)
14021715 {
14031716 Close();
....@@ -1459,45 +1772,48 @@
14591772 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14601773
14611774 cGridBag colorSection = new cGridBag().setVertical(true);
1775
+
1776
+ cGridBag huepanel = new cGridBag();
1777
+ cGridBag huelabel = new cGridBag();
1778
+ huelabel.add(GetLabel("icons/hue.png", false));
1779
+ huelabel.preferredWidth = 20;
1780
+ huepanel.add(new cGridBag()); // Label
1781
+ huepanel.add(huelabel); // Field/slider
1782
+
1783
+ huepanel.preferredHeight = 7;
1784
+
1785
+ colorSection.add(huepanel);
14621786
14631787 cGridBag color = new cGridBag();
1464
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1465
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1466
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1788
+
1789
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1790
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1791
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1792
+
14671793 //colorField.preferredWidth = 200;
14681794 colorSection.add(color);
14691795
14701796 cGridBag modulation = new cGridBag();
14711797 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
14721798 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1473
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1799
+ modulation.add(modulationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
14741800 colorSection.add(modulation);
14751801
1802
+ cGridBag opacity = new cGridBag();
1803
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1804
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1805
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1806
+ colorSection.add(opacity);
1807
+
1808
+ colorSection.add(GetSeparator());
1809
+
14761810 cGridBag texture = new cGridBag();
14771811 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
14781812 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
14791813 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
14801814 colorSection.add(texture);
14811815
1482
- cGridBag anisoU = new cGridBag();
1483
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1484
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1485
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1486
- colorSection.add(anisoU);
1487
-
1488
- cGridBag anisoV = new cGridBag();
1489
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1490
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1491
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1492
- colorSection.add(anisoV);
1493
-
1494
- cGridBag shadowbias = new cGridBag();
1495
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1496
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1497
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1498
- colorSection.add(shadowbias);
1499
-
1500
- panel.add(new JSeparator());
1816
+ panel.add(GetSeparator());
15011817
15021818 panel.add(colorSection);
15031819
....@@ -1547,7 +1863,13 @@
15471863 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15481864 diffuseSection.add(fakedepth);
15491865
1550
- panel.add(new JSeparator());
1866
+ cGridBag shadowbias = new cGridBag();
1867
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1868
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1869
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1870
+ diffuseSection.add(shadowbias);
1871
+
1872
+ panel.add(GetSeparator());
15511873
15521874 panel.add(diffuseSection);
15531875
....@@ -1597,42 +1919,48 @@
15971919 // aConstraints.gridy += 1;
15981920 // aConstraints.gridwidth = 1;
15991921
1922
+ cGridBag anisoU = new cGridBag();
1923
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1924
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1925
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1926
+ specularSection.add(anisoU);
16001927
1601
- panel.add(new JSeparator());
1928
+ cGridBag anisoV = new cGridBag();
1929
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1930
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1931
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1932
+ specularSection.add(anisoV);
1933
+
1934
+
1935
+ panel.add(GetSeparator());
16021936
16031937 panel.add(specularSection);
16041938
16051939 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16061940
1607
- cGridBag globalSection = new cGridBag().setVertical(true);
1941
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16081942
16091943 cGridBag camera = new cGridBag();
16101944 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16111945 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16121946 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1613
- globalSection.add(camera);
1947
+ colorSection.add(camera);
16141948
16151949 cGridBag ambient = new cGridBag();
16161950 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16171951 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16181952 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1619
- globalSection.add(ambient);
1953
+ colorSection.add(ambient);
16201954
16211955 cGridBag backlit = new cGridBag();
16221956 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16231957 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16241958 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1625
- globalSection.add(backlit);
1959
+ colorSection.add(backlit);
16261960
1627
- cGridBag opacity = new cGridBag();
1628
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1629
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1630
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1631
- globalSection.add(opacity);
1632
-
1633
- panel.add(new JSeparator());
1961
+ //panel.add(new JSeparator());
16341962
1635
- panel.add(globalSection);
1963
+ //panel.add(globalSection);
16361964
16371965 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16381966
....@@ -1674,7 +2002,7 @@
16742002 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
16752003 textureSection.add(opacityPower);
16762004
1677
- panel.add(new JSeparator());
2005
+ panel.add(GetSeparator());
16782006
16792007 panel.add(textureSection);
16802008
....@@ -1739,8 +2067,9 @@
17392067 // 3D models
17402068 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
17412069 {
1742
- lastConverter = new com.jmex.model.converters.MaxToJme();
1743
- LoadFile(filename, lastConverter);
2070
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2071
+ //LoadFile(filename, lastConverter);
2072
+ LoadObjFile(filename); // New 3ds loader
17442073 continue;
17452074 }
17462075 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2466,6 +2795,7 @@
24662795 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
24672796 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
24682797 }
2798
+
24692799 //cJME.count++;
24702800 //cJME.count %= 12;
24712801 if (gc)
....@@ -2649,6 +2979,7 @@
26492979 }
26502980 }
26512981 }
2982
+
26522983 cFileSystemPane FSPane;
26532984
26542985 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2702,11 +3033,14 @@
27023033 }
27033034 }
27043035 }
3036
+
27053037 freezematerial = false;
27063038 }
27073039
27083040 void SetMaterial(Object3D object)
27093041 {
3042
+ latestObject = object;
3043
+
27103044 cMaterial mat = object.material;
27113045
27123046 if (mat == null)
....@@ -2818,12 +3152,17 @@
28183152 // }
28193153
28203154 /**/
2821
- if (deselect)
3155
+ if (deselect || child == null)
28223156 {
28233157 //group.deselectAll();
28243158 //freeze = true;
28253159 GetTree().clearSelection();
28263160 //freeze = false;
3161
+
3162
+ if (child == null)
3163
+ {
3164
+ return;
3165
+ }
28273166 }
28283167
28293168 //group.addSelectee(child);
....@@ -2892,7 +3231,7 @@
28923231 cameraView.ToggleDL();
28933232 cameraView.repaint();
28943233 return;
2895
- } else if (event.getSource() == toggleTextureItem)
3234
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
28963235 {
28973236 cameraView.ToggleTexture();
28983237 // june 2013 copy.HardTouch();
....@@ -2931,7 +3270,7 @@
29313270 frame.validate();
29323271
29333272 return;
2934
- } else if (event.getSource() == toggleSwitchItem)
3273
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29353274 {
29363275 cameraView.ToggleSwitch();
29373276 cameraView.repaint();
....@@ -2962,7 +3301,7 @@
29623301 {
29633302 copy.live ^= true;
29643303 return;
2965
- } else if (event.getSource() == selectCB)
3304
+ } else if (event.getSource() == selectableCB)
29663305 {
29673306 copy.dontselect ^= true;
29683307 return;
....@@ -3147,9 +3486,9 @@
31473486 {
31483487 Close();
31493488 //return true;
3150
- } else if (source == loadItem)
3489
+ } else if (source == openItem)
31513490 {
3152
- load();
3491
+ Open();
31533492 //return true;
31543493 } else if (source == newItem)
31553494 {
....@@ -3174,6 +3513,10 @@
31743513 {
31753514 generatePOV();
31763515 //return true;
3516
+ } else if (event.getSource() == archiveItem)
3517
+ {
3518
+ cTools.Archive(frame);
3519
+ return;
31773520 } else if (source == zBufferItem)
31783521 {
31793522 try
....@@ -3225,8 +3568,8 @@
32253568 try
32263569 {
32273570 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3228
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3229
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3571
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3572
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
32303573
32313574 Object3D parent = o.parent;
32323575 o.parent = null;
....@@ -3237,10 +3580,14 @@
32373580
32383581 out.flush();
32393582
3240
- zstream.close();
3583
+ baos //zstream
3584
+ .close();
32413585 out.close();
32423586
3243
- return baos.toByteArray();
3587
+ byte[] bytes = baos.toByteArray();
3588
+
3589
+ System.out.println("save #bytes = " + bytes.length);
3590
+ return bytes;
32443591 } catch (Exception e)
32453592 {
32463593 System.err.println(e);
....@@ -3250,13 +3597,16 @@
32503597
32513598 static public Object Uncompress(byte[] bytes)
32523599 {
3253
- System.out.println("#bytes = " + bytes.length);
3600
+ System.out.println("restore #bytes = " + bytes.length);
32543601 try
32553602 {
32563603 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3257
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3258
- ObjectInputStream in = new ObjectInputStream(istream);
3604
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3605
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
32593606 Object obj = in.readObject();
3607
+
3608
+ bais //istream
3609
+ .close();
32603610 in.close();
32613611
32623612 return obj;
....@@ -3311,37 +3661,77 @@
33113661 return null;
33123662 }
33133663
3314
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
33153664
33163665 public void Save()
33173666 {
3667
+ //Save(true);
3668
+ Replace();
3669
+ }
3670
+
3671
+ private boolean Equal(byte[] compress, byte[] name)
3672
+ {
3673
+ if (compress.length != name.length)
3674
+ {
3675
+ return false;
3676
+ }
3677
+
3678
+ for (int i=compress.length; --i>=0;)
3679
+ {
3680
+ if (compress[i] != name[i])
3681
+ return false;
3682
+ }
3683
+
3684
+ return true;
3685
+ }
3686
+
3687
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3688
+
3689
+ public boolean Save(boolean user)
3690
+ {
3691
+ System.err.println("Save");
3692
+
33183693 cRadio tab = GetCurrentTab();
33193694
3320
- boolean temp = CameraPane.SWITCH;
3321
- CameraPane.SWITCH = false;
3695
+ byte[] compress = CompressCopy(); // Saved version. No need for "Replace".
33223696
3323
- copy.ExtractBigData(hashtable);
3697
+ boolean thesame = false;
3698
+
3699
+ // Quick heuristic using length. Works only when stream is compressed.
3700
+ if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3701
+ {
3702
+ thesame = true;
3703
+ }
33243704
33253705 //EditorFrame.m_MainFrame.requestFocusInWindow();
3326
- tab.graphs[tab.undoindex++] = Compress(copy);
3327
-
3328
- copy.RestoreBigData(hashtable);
3329
-
3330
- CameraPane.SWITCH = temp;
3331
-
3332
- //assert(hashtable.isEmpty());
3333
-
3334
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3706
+ if (!thesame)
33353707 {
3336
- tab.graphs[i] = null;
3708
+ //tab.user[tab.versionindex] = user;
3709
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
3710
+
3711
+ copy.versions[++copy.versionindex] = compress;
3712
+
3713
+ // if (increment)
3714
+ // tab.versionindex++;
33373715 }
33383716
3717
+ //copy.RestoreBigData(versiontable);
3718
+
3719
+ //assert(hashtable.isEmpty());
3720
+
3721
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3722
+ {
3723
+ //tab.user[i] = false;
3724
+ copy.versions[i] = null;
3725
+ }
3726
+
3727
+ SetUndoStates();
3728
+
33393729 // test save
33403730 if (false)
33413731 {
33423732 try
33433733 {
3344
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3734
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
33453735 ObjectOutputStream p = new ObjectOutputStream(ostream);
33463736
33473737 p.writeObject(copy);
....@@ -3354,23 +3744,30 @@
33543744 e.printStackTrace();
33553745 }
33563746 }
3747
+
3748
+ return !thesame;
33573749 }
33583750
33593751 void CopyChanged(Object3D obj)
33603752 {
3753
+ SetUndoStates();
3754
+
33613755 boolean temp = CameraPane.SWITCH;
33623756 CameraPane.SWITCH = false;
33633757
3364
- copy.ExtractBigData(hashtable);
3758
+ copy.ExtractBigData(versiontable);
33653759
33663760 copy.clear();
33673761
3762
+ copy.skyboxname = obj.skyboxname;
3763
+ copy.skyboxext = obj.skyboxext;
3764
+
33683765 for (int i=0; i<obj.Size(); i++)
33693766 {
33703767 copy.add(obj.get(i));
33713768 }
33723769
3373
- copy.RestoreBigData(hashtable);
3770
+ copy.RestoreBigData(versiontable);
33743771
33753772 CameraPane.SWITCH = temp;
33763773
....@@ -3397,40 +3794,130 @@
33973794 refreshContents();
33983795 }
33993796
3400
- public void Undo()
3797
+ cButton undoButton;
3798
+ cButton restoreButton;
3799
+ cButton replaceButton;
3800
+ cButton redoButton;
3801
+
3802
+ boolean muteSlider;
3803
+
3804
+ int VersionCount()
3805
+ {
3806
+ int count = 0;
3807
+
3808
+ for (int i = copy.versions.length; --i >= 0;)
3809
+ {
3810
+ if (copy.versions[i] != null)
3811
+ count++;
3812
+ }
3813
+
3814
+ return count;
3815
+ }
3816
+
3817
+ void SetUndoStates()
34013818 {
34023819 cRadio tab = GetCurrentTab();
34033820
3404
- if (tab.undoindex == 0)
3821
+ restoreButton.setEnabled(copy.versionindex != -1);
3822
+ replaceButton.setEnabled(copy.versionindex != -1);
3823
+
3824
+ undoButton.setEnabled(copy.versionindex > 0);
3825
+ redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
3826
+
3827
+ muteSlider = true;
3828
+ versionSlider.setMaximum(VersionCount() - 1);
3829
+ versionSlider.setInteger(copy.versionindex);
3830
+ muteSlider = false;
3831
+ }
3832
+
3833
+ public boolean Undo()
3834
+ {
3835
+ // Option?
3836
+ Replace();
3837
+
3838
+ System.err.println("Undo");
3839
+
3840
+ cRadio tab = GetCurrentTab();
3841
+
3842
+ if (copy.versionindex == 0)
34053843 {
34063844 java.awt.Toolkit.getDefaultToolkit().beep();
3407
- return;
3845
+ return false;
34083846 }
34093847
3410
- if (tab.graphs[tab.undoindex] == null)
3848
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3849
+// {
3850
+// if (Save(false))
3851
+// tab.versionindex -= 1;
3852
+// else
3853
+// {
3854
+// if (tab.versionindex <= 0)
3855
+// return false;
3856
+// else
3857
+// tab.versionindex -= 1;
3858
+// }
3859
+// }
3860
+
3861
+ copy.versionindex -= 1;
3862
+
3863
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3864
+
3865
+ return true;
3866
+ }
3867
+
3868
+ public boolean Restore()
3869
+ {
3870
+ System.err.println("Restore");
3871
+
3872
+ cRadio tab = GetCurrentTab();
3873
+
3874
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
34113875 {
3412
- Save();
3413
- tab.undoindex -= 1;
3876
+ java.awt.Toolkit.getDefaultToolkit().beep();
3877
+ return false;
34143878 }
34153879
3416
- tab.undoindex -= 1;
3880
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3881
+
3882
+ return true;
3883
+ }
34173884
3418
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3885
+ public boolean Replace()
3886
+ {
3887
+ System.err.println("Replace");
3888
+
3889
+ cRadio tab = GetCurrentTab();
3890
+
3891
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3892
+ {
3893
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
3894
+ return false;
3895
+ }
3896
+
3897
+ copy.versions[copy.versionindex] = CompressCopy();
3898
+
3899
+ return true;
34193900 }
34203901
34213902 public void Redo()
34223903 {
3904
+ // Option?
3905
+ Replace();
3906
+
34233907 cRadio tab = GetCurrentTab();
34243908
3425
- if (tab.graphs[tab.undoindex + 1] == null)
3909
+ if (copy.versions[copy.versionindex + 1] == null)
34263910 {
34273911 java.awt.Toolkit.getDefaultToolkit().beep();
34283912 return;
34293913 }
34303914
3431
- tab.undoindex += 1;
3915
+ copy.versionindex += 1;
34323916
3433
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3917
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3918
+
3919
+ //if (!tab.user[tab.versionindex])
3920
+ // tab.graphs[tab.versionindex] = null;
34343921 }
34353922
34363923 void ImportGFD()
....@@ -3582,7 +4069,7 @@
35824069 assert false;
35834070 }
35844071
3585
- void EditSelection()
4072
+ void EditSelection(boolean newWindow)
35864073 {
35874074 }
35884075
....@@ -3726,9 +4213,25 @@
37264213 //copy.Touch();
37274214 }
37284215
4216
+ cNumberSlider versionSlider;
4217
+
37294218 public void stateChanged(ChangeEvent e)
37304219 {
37314220 // assert(false);
4221
+ if (e.getSource() == versionSlider)
4222
+ {
4223
+ if (muteSlider)
4224
+ return;
4225
+
4226
+ int version = versionSlider.getInteger();
4227
+
4228
+ if (copy.versions[version] != null)
4229
+ {
4230
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4231
+ }
4232
+
4233
+ return;
4234
+ }
37324235
37334236 if (freezematerial)
37344237 {
....@@ -4077,7 +4580,8 @@
40774580
40784581 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
40794582 {
4080
- Save();
4583
+ if (Globals.REPLACEONMAKE) // && resetmodel)
4584
+ Save();
40814585 //Tween.set(thing, 0).target(1).start(tweenManager);
40824586 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
40834587 // if (thing instanceof GenericJointDemo)
....@@ -4164,6 +4668,12 @@
41644668 {
41654669 ResetModel();
41664670 Select(thing.GetTreePath(), true, false); // unselect... false);
4671
+
4672
+ if (thing.Size() == 0)
4673
+ {
4674
+ //EditSelection(false);
4675
+ }
4676
+
41674677 refreshContents();
41684678 }
41694679
....@@ -4312,7 +4822,9 @@
43124822 readobj.ResetDisplayList();
43134823 } catch (Exception e)
43144824 {
4315
- //e.printStackTrace();
4825
+ if (!e.toString().contains("GZIP"))
4826
+ e.printStackTrace();
4827
+
43164828 try
43174829 {
43184830 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4386,11 +4898,14 @@
43864898
43874899 if (readobj != null)
43884900 {
4389
- Save();
4901
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4902
+ // Save();
43904903 try
43914904 {
43924905 //readobj.deepCopySelf(copy);
43934906 copy.clear(); // june 2014
4907
+ copy.skyboxname = readobj.skyboxname;
4908
+ copy.skyboxext = readobj.skyboxext;
43944909 for (int i = 0; i < readobj.size(); i++)
43954910 {
43964911 Object3D child = readobj.get(i); // reserve(i);
....@@ -4431,6 +4946,7 @@
44314946 }
44324947 } catch (ClassCastException e)
44334948 {
4949
+ e.printStackTrace();
44344950 assert (false);
44354951 Composite c = (Composite) copy;
44364952 c.children.clear();
....@@ -4441,13 +4957,24 @@
44414957 c.addChild(csg);
44424958 }
44434959
4960
+ copy.versions = readobj.versions;
4961
+ copy.versionindex = readobj.versionindex;
4962
+
4963
+ if (copy.versions == null)
4964
+ {
4965
+ copy.versions = new byte[100][];
4966
+ copy.versionindex = -1;
4967
+ }
4968
+
4969
+ //? SetUndoStates();
4970
+
44444971 ResetModel();
44454972 copy.HardTouch(); // recompile?
44464973 refreshContents();
44474974 }
44484975 }
44494976
4450
- void load() // throws ClassNotFoundException
4977
+ void Open() // throws ClassNotFoundException
44514978 {
44524979 if (Grafreed.standAlone)
44534980 {
....@@ -4550,6 +5077,7 @@
45505077 //ps.print(buffer.toString());
45515078 } catch (IOException e)
45525079 {
5080
+ e.printStackTrace();
45535081 }
45545082 }
45555083
....@@ -4564,6 +5092,8 @@
45645092 String filename = browser.getFile();
45655093 if (filename != null && filename.length() > 0)
45665094 {
5095
+ if (!filename.endsWith(".gfd"))
5096
+ filename += ".gfd";
45675097 lastname = browser.getDirectory() + filename;
45685098 save();
45695099 }
....@@ -4730,7 +5260,7 @@
47305260 MenuBar menuBar;
47315261 Menu fileMenu;
47325262 MenuItem newItem;
4733
- MenuItem loadItem;
5263
+ MenuItem openItem;
47345264 MenuItem saveItem;
47355265 MenuItem saveAsItem;
47365266 MenuItem exportAsItem;
....@@ -4753,22 +5283,36 @@
47535283 CheckboxMenuItem toggleSwitchItem;
47545284 CheckboxMenuItem toggleRootItem;
47555285 CheckboxMenuItem animationItem;
5286
+ MenuItem archiveItem;
47565287 CheckboxMenuItem toggleHandleItem;
47575288 CheckboxMenuItem togglePaintItem;
47585289 JSplitPane mainPanel;
47595290 JScrollPane scrollpane;
5291
+
47605292 JPanel toolbarPanel;
5293
+
47615294 cGridBag treePanel;
5295
+
47625296 JPanel radioPanel;
47635297 ButtonGroup buttonGroup;
4764
- cGridBag ctrlPanel;
5298
+
5299
+ cGridBag toolboxPanel;
47655300 cGridBag materialPanel;
5301
+ cGridBag ctrlPanel;
5302
+
47665303 JScrollPane infoPanel;
5304
+
47675305 cGridBag optionsPanel;
5306
+
47685307 JTabbedPane objectPanel;
5308
+ boolean materialFlushed;
5309
+ Object3D latestObject;
5310
+
47695311 cGridBag XYZPanel;
5312
+
47705313 JSplitPane gridPanel;
47715314 JSplitPane bigPanel;
5315
+
47725316 cGridBag bigThree;
47735317 cGridBag scenePanel;
47745318 cGridBag centralPanel;
....@@ -4883,7 +5427,7 @@
48835427 cNumberSlider fogField;
48845428 JLabel opacityPowerLabel;
48855429 cNumberSlider opacityPowerField;
4886
- JTree jTree;
5430
+ cTree jTree;
48875431 //ObjectUI parent;
48885432
48895433 cNumberSlider normalpushField;