Normand Briere
2019-04-29 bed42c663d286d76a32f155049f9efabc2fdb73f
ObjEditor.java
....@@ -19,6 +19,8 @@
1919 import //weka.core.
2020 matrix.Matrix;
2121
22
+import grafeme.ui.*;
23
+
2224 class ObjEditor /*extends JFrame*/ implements iCallBack, ObjectUI,
2325 ActionListener, ChangeListener,
2426 InputMethodListener,
....@@ -28,7 +30,12 @@
2830 iSendInfo
2931 //KeyListener
3032 {
33
+ boolean timeline;
34
+ boolean wasFullScreen;
3135
36
+ GroupEditor callee;
37
+ JFrame frame;
38
+
3239 // SCRIPT
3340
3441 transient JFrame textpanel = null;
....@@ -119,14 +126,13 @@
119126 void keyPressed(int key, int modifiers)
120127 {
121128 System.out.println("KEY PRESSED");
122
- CameraPane.theRenderer.keyPressed(key, modifiers);
129
+ Globals.theRenderer.keyPressed(key, modifiers);
123130 }
124131 */
125132
126133 static GridBagConstraints aConstraints;
127134 static GridBagConstraints aWindowConstraints;
128
- GroupEditor callee;
129
- JFrame frame;
135
+
130136 static int GRIDWIDTH = 100; // 4;
131137
132138 public void closeUI()
....@@ -158,12 +164,16 @@
158164 objEditor.ctrlPanel.remove(slowerButton);
159165 objEditor.ctrlPanel.remove(fasterButton);
160166 objEditor.ctrlPanel.remove(remarkButton);
167
+
168
+ Remove(normalpushField);
161169 }
162170
163171 public ObjEditor GetEditor()
164172 {
165173 return objEditor; //.GetEditor();
166174 }
175
+
176
+ // Sometimes myself, sometimes my callee's.
167177 ObjEditor objEditor;
168178
169179 /*
....@@ -238,7 +248,7 @@
238248 //if (!isDisplayable())
239249 //setUndecorated(true);
240250
241
- System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
251
+ //System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
242252 client = inClient;
243253 copy = localCopy;
244254 copy.editWindow = this;
....@@ -292,18 +302,18 @@
292302 //normalLensItem.addActionListener(this);
293303 cameraMenu.add(revertCameraItem = new MenuItem("Revert Camera"));
294304 revertCameraItem.addActionListener(this);
305
+ cameraMenu.add(toggleTimelineItem = new CheckboxMenuItem("Timeline"));
306
+ toggleTimelineItem.addItemListener(this);
295307 cameraMenu.add(toggleFullScreenItem = new CheckboxMenuItem("Full Screen"));
296308 toggleFullScreenItem.addItemListener(this);
297309 toggleFullScreenItem.setState(CameraPane.FULLSCREEN);
298
- cameraMenu.add(toggleTimelineItem = new CheckboxMenuItem("Timeline"));
299
- toggleTimelineItem.addItemListener(this);
300310 cameraMenu.add("-");
301311 cameraMenu.add(toggleTextureItem = new CheckboxMenuItem("Texture"));
302312 toggleTextureItem.addItemListener(this);
303313 toggleTextureItem.setState(CameraPane.textureon);
304314 cameraMenu.add(toggleLiveItem = new CheckboxMenuItem("Live"));
305315 toggleLiveItem.addItemListener(this);
306
- toggleLiveItem.setState(CameraPane.isLIVE());
316
+ toggleLiveItem.setState(Globals.isLIVE());
307317 cameraMenu.add(stepItem = new MenuItem("Step"));
308318 stepItem.addActionListener(this);
309319 // cameraMenu.add(toggleDLItem = new CheckboxMenuItem("Display List"));
....@@ -596,6 +606,22 @@
596606 }
597607 }
598608
609
+ void ToggleFullScreen()
610
+ {
611
+ if (CameraPane.FULLSCREEN)
612
+ {
613
+ frame.getContentPane().remove(/*"Center",*/bigThree);
614
+ framePanel.add(bigThree);
615
+ frame.getContentPane().add(/*"Center",*/framePanel);
616
+ } else
617
+ {
618
+ frame.getContentPane().remove(/*"Center",*/framePanel);
619
+ framePanel.remove(bigThree);
620
+ frame.getContentPane().add(/*"Center",*/bigThree);
621
+ }
622
+ cameraView.ToggleFullScreen();
623
+ }
624
+
599625 private JTextArea createTextPane()
600626 {
601627 String[] initString =
....@@ -796,7 +822,7 @@
796822
797823 aConstraints.fill = GridBagConstraints.VERTICAL;
798824 jlabel.setHorizontalAlignment(SwingConstants.TRAILING);
799
- aConstraints.gridwidth = 2;
825
+ aConstraints.gridwidth = 1;
800826 ctrlPanel.add(jlabel, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
801827 aConstraints.gridx += 1;
802828 aConstraints.fill = GridBagConstraints.HORIZONTAL;
....@@ -965,6 +991,9 @@
965991
966992 Return();
967993
994
+ normalpushField = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, -1);
995
+ Return();
996
+
968997 // oe.ctrlPanel.add(stepButton = new cButton("Step"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2);
969998 // ObjEditor.aConstraints.gridx += 1;
970999
....@@ -1164,6 +1193,13 @@
11641193 timelinePanel = new JPanel(new BorderLayout());
11651194 timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11661195
1196
+ cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
1197
+ cameraPanel.setContinuousLayout(true);
1198
+ cameraPanel.setOneTouchExpandable(true);
1199
+// cameraPanel.setDividerLocation(0.9);
1200
+// cameraPanel.setDividerSize(9);
1201
+ cameraPanel.setResizeWeight(1.0);
1202
+
11671203 centralPanel.add(cameraView);
11681204 //frame.setJMenuBar(timelineMenubar);
11691205 //centralPanel.add(timelinePanel);
....@@ -1183,12 +1219,12 @@
11831219 //frontView.object = copy;
11841220 //sideView.object = copy;
11851221
1186
- XYZPanel = new JPanel();
1187
- XYZPanel.setLayout(new GridLayout(3, 1, 5, 5));
1222
+ XYZPanel = new cGridBag().setVertical(true);
1223
+ //XYZPanel.setLayout(new GridLayout(3, 1, 5, 5));
11881224
1189
- XYZPanel.add(/*BorderLayout.SOUTH,*/sideView); // Scroll);
1190
- XYZPanel.add(/*BorderLayout.CENTER,*/frontView); // Scroll);
1191
- XYZPanel.add(/*BorderLayout.NORTH,*/topView); // Scroll);
1225
+ XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
1226
+ XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
1227
+ XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
11921228
11931229 /*
11941230 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1258,6 +1294,9 @@
12581294 optionsPanel = new JPanel(new GridBagLayout());
12591295
12601296 optionsPanel.setName("Options");
1297
+
1298
+ AddOptions(optionsPanel, aConstraints);
1299
+
12611300 scenePanel.add(optionsPanel);
12621301
12631302
....@@ -1293,6 +1332,7 @@
12931332 //bigPanel.setSize(new Dimension(10,10));
12941333 //bigPanel.add(ctrlPanel);
12951334 //bigPanel.add(gridPanel);
1335
+ /**
12961336 bigThree = new JPanel();
12971337 //big.setLayout(new FlowLayout(FlowLayout.LEFT));
12981338 bigThree.setLayout(new GridBagLayout()); //1,3,5,5));
....@@ -1316,7 +1356,13 @@
13161356 // aConstraints.gridheight = 3;
13171357 aWindowConstraints.fill = GridBagConstraints.VERTICAL;
13181358 bigThree.add(XYZPanel, aWindowConstraints);
1359
+ /**/
13191360
1361
+ bigThree = new cGridBag();
1362
+ bigThree.addComponent(scenePanel);
1363
+ bigThree.addComponent(centralPanel);
1364
+ bigThree.addComponent(XYZPanel);
1365
+
13201366 // // SIDE EFFECT!!!
13211367 // aConstraints.gridx = 0;
13221368 // aConstraints.gridy = 0;
....@@ -1337,7 +1383,8 @@
13371383 //worldPane.add(bigPanel);
13381384 //worldPane.add(worldPanel);
13391385 /**/
1340
- frame.getContentPane().add(/*"Center",*/framePanel);
1386
+ //frame.getContentPane().add(/*"Center",*/framePanel);
1387
+ frame.add(/*"Center",*/framePanel);
13411388 //frame.getContentPane().add(/*"Center",*/ worldPane);
13421389
13431390 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
....@@ -1358,6 +1405,10 @@
13581405 });
13591406 }
13601407
1408
+ void AddOptions(JPanel panel, GridBagConstraints constraints)
1409
+ {
1410
+ }
1411
+
13611412 JTree GetTree()
13621413 {
13631414 return objEditor.jTree;
....@@ -1428,7 +1479,7 @@
14281479 aConstraints.gridx += 1;
14291480 aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
14301481 //aConstraints.weightx = 0;
1431
- ctrlPanel.add(colorField = new NumberSlider(0.001, 1, -0.1), aConstraints);
1482
+ ctrlPanel.add(colorField = new NumberSlider(0.001, 1, -0.5), aConstraints);
14321483 aConstraints.gridx = 0;
14331484 aConstraints.gridy += 1;
14341485 aConstraints.gridwidth = 1;
....@@ -1438,7 +1489,7 @@
14381489 aConstraints.fill = GridBagConstraints.HORIZONTAL;
14391490 aConstraints.gridx += 1;
14401491 aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1441
- ctrlPanel.add(modulationField = new NumberSlider(0.001, 1, -0.1), aConstraints);
1492
+ ctrlPanel.add(modulationField = new NumberSlider(0.001, 1, -0.5), aConstraints);
14421493 aConstraints.gridx = 0;
14431494 aConstraints.gridy += 1;
14441495 aConstraints.gridwidth = 1;
....@@ -1448,7 +1499,7 @@
14481499 aConstraints.fill = GridBagConstraints.HORIZONTAL;
14491500 aConstraints.gridx += 1;
14501501 aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1451
- ctrlPanel.add(textureField = new NumberSlider(0.001, 1, -0.1), aConstraints);
1502
+ ctrlPanel.add(textureField = new NumberSlider(0.001, 1, -0.5), aConstraints);
14521503 aConstraints.gridx = 0;
14531504 aConstraints.gridy += 1;
14541505 aConstraints.gridwidth = 1;
....@@ -1458,7 +1509,7 @@
14581509 aConstraints.fill = GridBagConstraints.HORIZONTAL;
14591510 aConstraints.gridx += 1;
14601511 aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1461
- ctrlPanel.add(anisoField = new NumberSlider(0.001, 1, -0.1), aConstraints);
1512
+ ctrlPanel.add(anisoField = new NumberSlider(0.001, 1, -0.5), aConstraints);
14621513 aConstraints.gridx = 0;
14631514 aConstraints.gridy += 1;
14641515 aConstraints.gridwidth = 1;
....@@ -1468,7 +1519,7 @@
14681519 aConstraints.fill = GridBagConstraints.HORIZONTAL;
14691520 aConstraints.gridx += 1;
14701521 aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1471
- ctrlPanel.add(anisoVField = new NumberSlider(0.001, 1, -0.1), aConstraints);
1522
+ ctrlPanel.add(anisoVField = new NumberSlider(0.001, 1, -0.5), aConstraints);
14721523 aConstraints.gridx = 0;
14731524 aConstraints.gridy += 1;
14741525 aConstraints.gridwidth = 1;
....@@ -1537,7 +1588,7 @@
15371588 aConstraints.fill = GridBagConstraints.HORIZONTAL;
15381589 aConstraints.gridx += 1;
15391590 aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1540
- ctrlPanel.add(subsurfaceField = new NumberSlider(0.001, 1, -0.1), aConstraints);
1591
+ ctrlPanel.add(subsurfaceField = new NumberSlider(0.001, 1, -0.5), aConstraints);
15411592 aConstraints.gridx = 0;
15421593 aConstraints.gridy += 1;
15431594 aConstraints.gridwidth = 1;
....@@ -1606,7 +1657,7 @@
16061657 aConstraints.fill = GridBagConstraints.HORIZONTAL;
16071658 aConstraints.gridx += 1;
16081659 aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1609
- ctrlPanel.add(metalnessField = new NumberSlider(0.001, 1, -0.1), aConstraints);
1660
+ ctrlPanel.add(metalnessField = new NumberSlider(0.001, 1, -0.5), aConstraints);
16101661 aConstraints.gridx = 0;
16111662 aConstraints.gridy += 1;
16121663 aConstraints.gridwidth = 1;
....@@ -1677,7 +1728,7 @@
16771728 aConstraints.fill = GridBagConstraints.HORIZONTAL;
16781729 aConstraints.gridx += 1;
16791730 aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1680
- ctrlPanel.add(opacityField = new NumberSlider(0.001, 1, -0.1), aConstraints);
1731
+ ctrlPanel.add(opacityField = new NumberSlider(0.001, 1, -0.5), aConstraints);
16811732 aConstraints.gridx = 0;
16821733 aConstraints.gridy += 1;
16831734 aConstraints.gridwidth = 1;
....@@ -2966,37 +3017,35 @@
29663017 return;
29673018 } else if (event.getSource() == toggleTimelineItem)
29683019 {
2969
- copy.timeline ^= true;
3020
+ timeline ^= true;
29703021
2971
- if (copy.timeline)
3022
+ if (timeline)
29723023 {
29733024 centralPanel.remove(cameraView);
2974
- centralPanel.add(timelinePanel);
3025
+ cameraPanel.add(cameraView);
3026
+ centralPanel.add(cameraPanel);
29753027 frame.setJMenuBar(timelineMenubar);
3028
+ wasFullScreen = CameraPane.FULLSCREEN;
3029
+ if (!CameraPane.FULLSCREEN)
3030
+ ToggleFullScreen();
3031
+ toggleFullScreenItem.setEnabled(false);
29763032 }
29773033 else
29783034 {
2979
- centralPanel.remove(timelinePanel);
3035
+ centralPanel.remove(cameraPanel);
29803036 centralPanel.add(cameraView);
29813037 frame.setJMenuBar(null);
3038
+ if (!wasFullScreen)
3039
+ ToggleFullScreen();
3040
+ toggleFullScreenItem.setEnabled(true);
29823041 }
29833042
29843043 frame.validate();
29853044 return;
29863045 } else if (event.getSource() == toggleFullScreenItem)
29873046 {
2988
- if (CameraPane.FULLSCREEN)
2989
- {
2990
- frame.getContentPane().remove(/*"Center",*/bigThree);
2991
- framePanel.add(bigThree);
2992
- frame.getContentPane().add(/*"Center",*/framePanel);
2993
- } else
2994
- {
2995
- frame.getContentPane().remove(/*"Center",*/framePanel);
2996
- frame.getContentPane().add(/*"Center",*/bigThree);
2997
- }
3047
+ ToggleFullScreen();
29983048 frame.validate();
2999
- cameraView.ToggleFullScreen();
30003049
30013050 return;
30023051 } else if (event.getSource() == toggleRandomItem)
....@@ -3106,7 +3155,8 @@
31063155 objEditor.refreshContents();
31073156 } else if (event.getSource() == stepItem)
31083157 {
3109
- cameraView.ONESTEP = true;
3158
+ //cameraView.ONESTEP = true;
3159
+ Globals.ONESTEP = true;
31103160 cameraView.repaint();
31113161 return;
31123162 } else if (event.getSource() == stepButton)
....@@ -3263,25 +3313,25 @@
32633313
32643314 void ToggleAnimation()
32653315 {
3266
- if (!CameraPane.ANIMATION)
3316
+ if (!Globals.ANIMATION)
32673317 {
32683318 FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
32693319 browser.show();
32703320 String filename = browser.getFile();
32713321 if (filename != null && filename.length() > 0)
32723322 {
3273
- CameraPane.filename = browser.getDirectory() + filename;
3323
+ Globals.filename = browser.getDirectory() + filename;
32743324 //CameraPane.framecount = 0;
3275
- CameraPane.imagecount = 0;
3325
+ Globals.imagecount = 0;
32763326
3277
- CameraPane.ANIMATION ^= true;
3327
+ Globals.ANIMATION ^= true;
32783328
32793329 GrafreeD.wav.cursor = 0;
32803330 GrafreeD.wav.loop = 0;
32813331 }
32823332 } else
32833333 {
3284
- CameraPane.ANIMATION ^= true;
3334
+ Globals.ANIMATION ^= true;
32853335 }
32863336 }
32873337
....@@ -3534,7 +3584,13 @@
35343584 //System.out.println("PARENT = " + parent);
35353585 //if (parent != null)
35363586 // parent.applySelf();
3537
- refreshContents();
3587
+ if (e.getSource() == normalpushField)
3588
+ {
3589
+ objEditor.refreshContents();
3590
+ //Refresh();
3591
+ }
3592
+ else
3593
+ refreshContents();
35383594 // ??? client.refreshEditWindow();
35393595 }
35403596 //else
....@@ -3546,7 +3602,7 @@
35463602 //group.name = nameField.getText();
35473603 //objEditor.applySelf();
35483604
3549
- assert (objEditor == this);
3605
+ // OCT2018: assert (objEditor == this);
35503606 if (copy.selection == null || copy.selection.size() == 0)
35513607 //super.applySelf()
35523608 ; else
....@@ -3570,12 +3626,18 @@
35703626 objEditor.copy = keep;
35713627 }
35723628 }
3629
+
3630
+ if (normalpushField != null)
3631
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
35733632 }
35743633
35753634 void SnapObject()
35763635 {
3577
- Object3D obj = (Object3D)copy.selection.elementAt(0);
3578
- SnapObject(obj);
3636
+ if (copy.selection.size() > 0)
3637
+ {
3638
+ Object3D obj = (Object3D)copy.selection.elementAt(0);
3639
+ SnapObject(obj);
3640
+ }
35793641 }
35803642
35813643 void SnapObject(Object3D obj)
....@@ -4493,12 +4555,13 @@
44934555 JScrollPane infoPanel;
44944556 JPanel optionsPanel;
44954557 JTabbedPane objectPanel;
4496
- JPanel XYZPanel;
4558
+ cGridBag XYZPanel;
44974559 JSplitPane gridPanel;
44984560 JSplitPane bigPanel;
4499
- JPanel bigThree;
4561
+ cGridBag bigThree;
45004562 JTabbedPane scenePanel;
45014563 JPanel centralPanel;
4564
+ JSplitPane cameraPanel;
45024565 JPanel timelinePanel;
45034566 JMenuBar timelineMenubar;
45044567 JSplitPane framePanel;
....@@ -4611,4 +4674,6 @@
46114674 NumberSlider opacityPowerField;
46124675 JTree jTree;
46134676 //ObjectUI parent;
4677
+
4678
+ NumberSlider normalpushField;
46144679 }