Normand Briere
2019-06-29 a69bb4474a3264a9a7a7f8b8d8154ea771f167c8
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);
....@@ -337,6 +340,11 @@
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());
....@@ -383,6 +391,32 @@
383391 closeItem.addActionListener(this);
384392
385393 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
+
386420 toolbarPanel = new JPanel();
387421 toolbarPanel.setName("Toolbar");
388422 treePanel = new cGridBag();
....@@ -415,7 +449,7 @@
415449 // TEXTAREA infoarea.setLineWrap(true);
416450 // TEXTAREA infoarea.setWrapStyleWord(true);
417451 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
418
- infoPanel.setPreferredSize(new Dimension(50, 200));
452
+ //infoPanel.setPreferredSize(new Dimension(50, 200));
419453 infoPanel.setName("Info");
420454 //infoPanel.setLayout(new BorderLayout());
421455 //infoPanel.add(createTextPane());
....@@ -427,7 +461,14 @@
427461 mainPanel.setDividerSize(9);
428462 mainPanel.setDividerLocation(0.5); //1.0);
429463 mainPanel.setResizeWeight(0.5);
430
-
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
+
431472 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
432473 //mainPanel.setLayout(new GridBagLayout());
433474 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -680,10 +721,19 @@
680721 void Minimize()
681722 {
682723 frame.setState(Frame.ICONIFIED);
724
+ frame.validate();
683725 }
684726
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={}
685730 void Maximize()
686731 {
732
+ if (CameraPane.FULLSCREEN)
733
+ {
734
+ ToggleFullScreen();
735
+ }
736
+
687737 if (maximized)
688738 {
689739 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -698,13 +748,23 @@
698748 }
699749
700750 maximized ^= true;
751
+
752
+ frame.validate();
701753 }
754
+
755
+ cButton minButton;
756
+ cButton maxButton;
757
+ cButton fullButton;
702758
703759 void ToggleFullScreen()
704760 {
705
- if (CameraPane.FULLSCREEN)
761
+ cameraView.ToggleFullScreen();
762
+
763
+ if (!CameraPane.FULLSCREEN)
706764 {
707765 device.setFullScreenWindow(null);
766
+ frame.validate();
767
+
708768 //frame.setVisible(false);
709769 // frame.removeNotify();
710770 // frame.setUndecorated(false);
....@@ -730,6 +790,7 @@
730790 // frame.getToolkit().getScreenSize().height);
731791 //frame.setVisible(false);
732792 device.setFullScreenWindow(frame);
793
+ frame.validate();
733794 // frame.removeNotify();
734795 // frame.setUndecorated(true);
735796 // frame.addNotify();
....@@ -742,8 +803,7 @@
742803 radio.layout.doClick();
743804 //frame.setVisible(true);
744805 }
745
-
746
- cameraView.ToggleFullScreen();
806
+ frame.validate();
747807 }
748808
749809 private JTextPane createTextPane()
....@@ -884,7 +944,12 @@
884944 JCheckBox speedupCB;
885945 JCheckBox rewindCB;
886946 JCheckBox flipVCB;
947
+
948
+ cCheckBox toggleTextureCB;
949
+ cCheckBox toggleSwitchCB;
950
+
887951 JComboBox texresMenu;
952
+
888953 JButton resetButton;
889954 JButton stepButton;
890955 JButton stepAllButton;
....@@ -1071,12 +1136,12 @@
10711136 namePanel = new cGridBag();
10721137
10731138 nameField = AddText(namePanel, copy.GetName());
1074
- namePanel.add(nameField);
1139
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
10751140 oe.ctrlPanel.add(namePanel);
10761141
10771142 oe.ctrlPanel.Return();
10781143
1079
- if (!GroupEditor.allparams)
1144
+ if (!allparams)
10801145 return;
10811146
10821147 setupPanel = new cGridBag().setVertical(false);
....@@ -1089,15 +1154,15 @@
10891154 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
10901155 hideCB.setToolTipText("Hide object");
10911156 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1092
- markCB.setToolTipText("Set the animation target transform");
1157
+ markCB.setToolTipText("As animation target transform");
10931158
10941159 setupPanel2 = new cGridBag().setVertical(false);
10951160
10961161 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
10971162 rewindCB.setToolTipText("Rewind animation");
10981163
1099
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1100
- randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1164
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1165
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11011166
11021167 if (Globals.ADVANCED)
11031168 {
....@@ -1412,7 +1477,6 @@
14121477
14131478 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14141479 //tmp.setName("Edit");
1415
- objectPanel.add(toolboxPanel);
14161480 objectPanel.add(materialPanel);
14171481 // JPanel north = new JPanel(new BorderLayout());
14181482 // north.setName("Edit");
....@@ -1420,6 +1484,7 @@
14201484 // objectPanel.add(north);
14211485 objectPanel.add(editPanel);
14221486 objectPanel.add(infoPanel);
1487
+ objectPanel.add(toolboxPanel);
14231488
14241489 /*
14251490 aConstraints.gridx = 0;
....@@ -1428,7 +1493,7 @@
14281493 aConstraints.gridy += 1;
14291494 aConstraints.gridwidth = 1;
14301495 mainPanel.add(objectPanel, aConstraints);
1431
- */
1496
+ */
14321497
14331498 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
14341499 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1445,9 +1510,7 @@
14451510 JTabbedPane tabbedPane = new JTabbedPane();
14461511 tabbedPane.add(scrollpane);
14471512
1448
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1449
-
1450
- optionsPanel = new cGridBag().setVertical(true);
1513
+ optionsPanel = new cGridBag().setVertical(false);
14511514
14521515 optionsPanel.setName("Options");
14531516
....@@ -1455,6 +1518,8 @@
14551518
14561519 tabbedPane.add(optionsPanel);
14571520
1521
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1522
+
14581523 scenePanel.add(tabbedPane);
14591524
14601525 /*
....@@ -1547,6 +1612,8 @@
15471612 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
15481613
15491614 frame.setSize(1280, 860);
1615
+
1616
+ frame.validate();
15501617 frame.setVisible(true);
15511618
15521619 cameraView.requestFocusInWindow();
....@@ -1638,24 +1705,6 @@
16381705 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16391706 colorSection.add(texture);
16401707
1641
- cGridBag anisoU = new cGridBag();
1642
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1643
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1644
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1645
- colorSection.add(anisoU);
1646
-
1647
- cGridBag anisoV = new cGridBag();
1648
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1649
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1650
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1651
- colorSection.add(anisoV);
1652
-
1653
- cGridBag shadowbias = new cGridBag();
1654
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1655
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1656
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1657
- colorSection.add(shadowbias);
1658
-
16591708 panel.add(new JSeparator());
16601709
16611710 panel.add(colorSection);
....@@ -1705,6 +1754,12 @@
17051754 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17061755 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17071756 diffuseSection.add(fakedepth);
1757
+
1758
+ cGridBag shadowbias = new cGridBag();
1759
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1760
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1761
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1762
+ diffuseSection.add(shadowbias);
17081763
17091764 panel.add(new JSeparator());
17101765
....@@ -1756,6 +1811,18 @@
17561811 // aConstraints.gridy += 1;
17571812 // aConstraints.gridwidth = 1;
17581813
1814
+ cGridBag anisoU = new cGridBag();
1815
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1816
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1817
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1818
+ specularSection.add(anisoU);
1819
+
1820
+ cGridBag anisoV = new cGridBag();
1821
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1822
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1823
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1824
+ specularSection.add(anisoV);
1825
+
17591826
17601827 panel.add(new JSeparator());
17611828
....@@ -1763,35 +1830,35 @@
17631830
17641831 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17651832
1766
- cGridBag globalSection = new cGridBag().setVertical(true);
1833
+ //cGridBag globalSection = new cGridBag().setVertical(true);
17671834
17681835 cGridBag camera = new cGridBag();
17691836 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
17701837 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17711838 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1772
- globalSection.add(camera);
1839
+ colorSection.add(camera);
17731840
17741841 cGridBag ambient = new cGridBag();
17751842 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
17761843 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17771844 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1778
- globalSection.add(ambient);
1845
+ colorSection.add(ambient);
17791846
17801847 cGridBag backlit = new cGridBag();
17811848 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
17821849 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17831850 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1784
- globalSection.add(backlit);
1851
+ colorSection.add(backlit);
17851852
17861853 cGridBag opacity = new cGridBag();
17871854 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
17881855 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17891856 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1790
- globalSection.add(opacity);
1857
+ colorSection.add(opacity);
17911858
1792
- panel.add(new JSeparator());
1859
+ //panel.add(new JSeparator());
17931860
1794
- panel.add(globalSection);
1861
+ //panel.add(globalSection);
17951862
17961863 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17971864
....@@ -2866,6 +2933,8 @@
28662933
28672934 void SetMaterial(Object3D object)
28682935 {
2936
+ latestObject = object;
2937
+
28692938 cMaterial mat = object.material;
28702939
28712940 if (mat == null)
....@@ -2977,12 +3046,17 @@
29773046 // }
29783047
29793048 /**/
2980
- if (deselect)
3049
+ if (deselect || child == null)
29813050 {
29823051 //group.deselectAll();
29833052 //freeze = true;
29843053 GetTree().clearSelection();
29853054 //freeze = false;
3055
+
3056
+ if (child == null)
3057
+ {
3058
+ return;
3059
+ }
29863060 }
29873061
29883062 //group.addSelectee(child);
....@@ -3051,7 +3125,7 @@
30513125 cameraView.ToggleDL();
30523126 cameraView.repaint();
30533127 return;
3054
- } else if (event.getSource() == toggleTextureItem)
3128
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
30553129 {
30563130 cameraView.ToggleTexture();
30573131 // june 2013 copy.HardTouch();
....@@ -3090,7 +3164,7 @@
30903164 frame.validate();
30913165
30923166 return;
3093
- } else if (event.getSource() == toggleSwitchItem)
3167
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
30943168 {
30953169 cameraView.ToggleSwitch();
30963170 cameraView.repaint();
....@@ -3483,8 +3557,10 @@
34833557
34843558 copy.ExtractBigData(hashtable);
34853559
3560
+ byte[] compress = Compress(copy);
3561
+
34863562 //EditorFrame.m_MainFrame.requestFocusInWindow();
3487
- tab.graphs[tab.undoindex++] = Compress(copy);
3563
+ tab.graphs[tab.undoindex++] = compress;
34883564
34893565 copy.RestoreBigData(hashtable);
34903566
....@@ -3497,6 +3573,8 @@
34973573 tab.graphs[i] = null;
34983574 }
34993575
3576
+ SetUndoStates();
3577
+
35003578 // test save
35013579 if (false)
35023580 {
....@@ -3519,6 +3597,8 @@
35193597
35203598 void CopyChanged(Object3D obj)
35213599 {
3600
+ SetUndoStates();
3601
+
35223602 boolean temp = CameraPane.SWITCH;
35233603 CameraPane.SWITCH = false;
35243604
....@@ -3556,6 +3636,17 @@
35563636 }
35573637
35583638 refreshContents();
3639
+ }
3640
+
3641
+ cButton undoButton;
3642
+ cButton redoButton;
3643
+
3644
+ void SetUndoStates()
3645
+ {
3646
+ cRadio tab = GetCurrentTab();
3647
+
3648
+ undoButton.setEnabled(tab.undoindex > 0);
3649
+ redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
35593650 }
35603651
35613652 public void Undo()
....@@ -4735,6 +4826,8 @@
47354826 String filename = browser.getFile();
47364827 if (filename != null && filename.length() > 0)
47374828 {
4829
+ if (!filename.endsWith(".gfd"))
4830
+ filename += ".gfd";
47384831 lastname = browser.getDirectory() + filename;
47394832 save();
47404833 }
....@@ -4945,6 +5038,8 @@
49455038 cGridBag optionsPanel;
49465039
49475040 JTabbedPane objectPanel;
5041
+ boolean materialFlushed;
5042
+ Object3D latestObject;
49485043
49495044 cGridBag XYZPanel;
49505045