Normand Briere
2019-08-04 0c85af6e46f48b7425d59fc776b193c06a4a1f52
ObjEditor.java
....@@ -296,9 +296,9 @@
296296 client = inClient;
297297 copy = client;
298298
299
- if (copy.versions == null)
299
+ if (copy.versionlist == null)
300300 {
301
- copy.versions = new Object3D[100];
301
+ copy.versionlist = new Object3D[100];
302302 copy.versionindex = -1;
303303 }
304304
....@@ -315,9 +315,9 @@
315315 client = inClient;
316316 copy = client;
317317
318
- if (copy.versions == null)
318
+ if (copy.versionlist == null)
319319 {
320
- copy.versions = new Object3D[100];
320
+ copy.versionlist = new Object3D[100];
321321 copy.versionindex = -1;
322322 }
323323
....@@ -353,7 +353,7 @@
353353 copy = localCopy;
354354 copy.editWindow = this;
355355
356
- if (copy.versions == null)
356
+ if (copy.versionlist == null)
357357 {
358358 // copy.versions = new byte[100][];
359359 // copy.versionindex = -1;
....@@ -467,7 +467,7 @@
467467 toolboxPanel = new cGridBag().setVertical(true);
468468 //toolboxPanel.setName("Toolbox");
469469
470
- materialPanel = new cGridBag().setVertical(true);
470
+ materialPanel = new cGridBag().setVertical(false);
471471 //materialPanel.setName("Material");
472472
473473 /*JTextPane*/
....@@ -858,13 +858,13 @@
858858 copy.ExtractBigData(versiontable);
859859 // if (copy == client)
860860
861
- Object3D versions[] = copy.versions;
862
- copy.versions = null;
861
+ Object3D versions[] = copy.versionlist;
862
+ copy.versionlist = null;
863863
864864 //byte[] compress = Compress(copy);
865865 Object3D compress = (Object3D)Grafreed.clone(copy);
866866
867
- copy.versions = versions;
867
+ copy.versionlist = versions;
868868
869869 copy.RestoreBigData(versiontable);
870870
....@@ -994,6 +994,7 @@
994994 {
995995 SetupMaterial(materialPanel);
996996 }
997
+
997998 //SetupName();
998999 //SetupViews();
9991000 }
....@@ -1551,7 +1552,7 @@
15511552 //tmp.setName("Edit");
15521553 objectPanel.add(materialPanel);
15531554 objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1554
- objectPanel.setToolTipTextAt(0, "Material panel");
1555
+ objectPanel.setToolTipTextAt(0, "Material");
15551556
15561557 // JPanel north = new JPanel(new BorderLayout());
15571558 // north.setName("Edit");
....@@ -1559,20 +1560,20 @@
15591560 // objectPanel.add(north);
15601561 objectPanel.add(editPanel);
15611562 objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1562
- objectPanel.setToolTipTextAt(1, "Edit panel");
1563
+ objectPanel.setToolTipTextAt(1, "Edit controls");
15631564
15641565 //if (Globals.ADVANCED)
15651566 objectPanel.add(infoPanel);
15661567 objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1567
- objectPanel.setToolTipTextAt(2, "Info panel");
1568
+ objectPanel.setToolTipTextAt(2, "Information");
15681569
15691570 objectPanel.add(XYZPanel);
15701571 objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1571
- objectPanel.setToolTipTextAt(3, "XYZ/RGB panel");
1572
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB transform");
15721573
15731574 objectPanel.add(toolboxPanel);
15741575 objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1575
- objectPanel.setToolTipTextAt(4, "Objects/backgrounds panel");
1576
+ objectPanel.setToolTipTextAt(4, "Objects & backgrounds");
15761577
15771578 /*
15781579 aConstraints.gridx = 0;
....@@ -1734,12 +1735,56 @@
17341735 ctrlPanel.removeAll();
17351736 }
17361737
1737
- void SetupMaterial(cGridBag panel)
1738
+ void SetupMaterial(cGridBag materialpanel)
17381739 {
1739
- /*
1740
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1741
+ cLabel label = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1742
+ label.addMouseListener(new MouseAdapter()
1743
+ {
1744
+ public void mouseClicked(MouseEvent e)
1745
+ {
1746
+ colorField.setFloat(0);
1747
+ saturationField.setFloat(1);
1748
+ materialtouched = true;
1749
+ applySelf();
1750
+ }
1751
+ });
1752
+ presetpanel.add(label);
1753
+
1754
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF));
1755
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF));
1756
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF));
1757
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF));
1758
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF));
1759
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF));
1760
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF));
1761
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF));
1762
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF));
1763
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF));
1764
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF));
1765
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF));
1766
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF));
1767
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF));
1768
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF));
1769
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF));
1770
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF));
1771
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF));
1772
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00019.png", !Grafreed.NIMBUSLAF));
1773
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00020.png", !Grafreed.NIMBUSLAF));
1774
+
1775
+ cGridBag panel = new cGridBag().setVertical(true);
1776
+
1777
+ presetpanel.preferredWidth = 1;
1778
+
1779
+ materialpanel.add(panel);
1780
+ materialpanel.add(presetpanel);
1781
+
1782
+ panel.preferredWidth = 8;
1783
+
1784
+ /*
17401785 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
17411786 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1742
- */
1787
+ */
17431788
17441789 cGridBag editBar = new cGridBag().setVertical(false);
17451790
....@@ -1776,7 +1821,9 @@
17761821
17771822 cGridBag huepanel = new cGridBag();
17781823 cGridBag huelabel = new cGridBag();
1779
- huelabel.add(GetLabel("icons/hue.png", false));
1824
+ label = GetLabel("icons/hue.png", false);
1825
+ label.fit = true;
1826
+ huelabel.add(label);
17801827 huelabel.preferredWidth = 20;
17811828 huepanel.add(new cGridBag()); // Label
17821829 huepanel.add(huelabel); // Field/slider
....@@ -1797,7 +1844,7 @@
17971844 cGridBag modulation = new cGridBag();
17981845 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17991846 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1800
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1847
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
18011848 colorSection.add(modulation);
18021849
18031850 cGridBag opacity = new cGridBag();
....@@ -2990,7 +3037,7 @@
29903037
29913038 freezematerial = true;
29923039 colorField.setFloat(mat.color);
2993
- modulationField.setFloat(mat.modulation);
3040
+ saturationField.setFloat(mat.modulation);
29943041 metalnessField.setFloat(mat.metalness);
29953042 diffuseField.setFloat(mat.diffuse);
29963043 specularField.setFloat(mat.specular);
....@@ -3301,6 +3348,7 @@
33013348 } else if (event.getSource() == liveCB)
33023349 {
33033350 copy.live ^= true;
3351
+ objEditor.refreshContents(true); // To show item colors
33043352 return;
33053353 } else if (event.getSource() == selectableCB)
33063354 {
....@@ -3310,7 +3358,7 @@
33103358 {
33113359 copy.hide ^= true;
33123360 copy.Touch(); // display list issue
3313
- objEditor.refreshContents();
3361
+ objEditor.refreshContents(true); // To show item colors
33143362 return;
33153363 } else if (event.getSource() == link2masterCB)
33163364 {
....@@ -3668,6 +3716,7 @@
36683716 {
36693717 //Save(true);
36703718 Replace();
3719
+ SetUndoStates();
36713720 }
36723721
36733722 private boolean Equal(byte[] compress, byte[] name)
....@@ -3691,6 +3740,7 @@
36913740 public boolean Save(boolean user)
36923741 {
36933742 System.err.println("Save");
3743
+ Replace();
36943744
36953745 cRadio tab = GetCurrentTab();
36963746
....@@ -3709,7 +3759,7 @@
37093759 //tab.user[tab.versionindex] = user;
37103760 //boolean increment = true; // tab.graphs[tab.versionindex] == null;
37113761
3712
- copy.versions[++copy.versionindex] = compress;
3762
+ copy.versionlist[++copy.versionindex] = compress;
37133763
37143764 // if (increment)
37153765 // tab.versionindex++;
....@@ -3719,10 +3769,10 @@
37193769
37203770 //assert(hashtable.isEmpty());
37213771
3722
- for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3772
+ for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
37233773 {
37243774 //tab.user[i] = false;
3725
- copy.versions[i] = null;
3775
+ copy.versionlist[i] = null;
37263776 }
37273777
37283778 SetUndoStates();
....@@ -3748,6 +3798,38 @@
37483798
37493799 return !thesame;
37503800 }
3801
+
3802
+ boolean flashIt = true;
3803
+
3804
+ void RefreshSelection()
3805
+ {
3806
+ Object3D selection = new Object3D();
3807
+
3808
+ for (int i = 0; i < copy.selection.size(); i++)
3809
+ {
3810
+ Object3D elem = copy.selection.elementAt(i);
3811
+
3812
+ Object3D obj = copy.GetObject(elem.GetUUID());
3813
+
3814
+ if (obj == null)
3815
+ {
3816
+ copy.selection.remove(i--);
3817
+ }
3818
+ else
3819
+ {
3820
+ selection.add(obj);
3821
+ copy.selection.setElementAt(obj, i);
3822
+ }
3823
+ }
3824
+
3825
+ flashIt = false;
3826
+ GetTree().clearSelection();
3827
+ for (int i = 0; i < selection.size(); i++)
3828
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
3829
+ flashIt = true;
3830
+
3831
+ refreshContents(false);
3832
+ }
37513833
37523834 void CopyChanged(Object3D obj)
37533835 {
....@@ -3772,6 +3854,7 @@
37723854
37733855 CameraPane.SWITCH = temp;
37743856
3857
+ RefreshSelection();
37753858 //assert(hashtable.isEmpty());
37763859
37773860 copy.Touch();
....@@ -3806,9 +3889,9 @@
38063889 {
38073890 int count = 0;
38083891
3809
- for (int i = copy.versions.length; --i >= 0;)
3892
+ for (int i = copy.versionlist.length; --i >= 0;)
38103893 {
3811
- if (copy.versions[i] != null)
3894
+ if (copy.versionlist[i] != null)
38123895 count++;
38133896 }
38143897
....@@ -3823,7 +3906,7 @@
38233906 replaceButton.setEnabled(copy.versionindex != -1);
38243907
38253908 undoButton.setEnabled(copy.versionindex > 0);
3826
- redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
3909
+ redoButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
38273910
38283911 muteSlider = true;
38293912 versionSlider.setMaximum(VersionCount() - 1);
....@@ -3861,7 +3944,7 @@
38613944
38623945 copy.versionindex -= 1;
38633946
3864
- CopyChanged((Object3D)copy.versions[copy.versionindex]);
3947
+ CopyChanged((Object3D)copy.versionlist[copy.versionindex]);
38653948
38663949 return true;
38673950 }
....@@ -3872,14 +3955,14 @@
38723955
38733956 cRadio tab = GetCurrentTab();
38743957
3875
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3958
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38763959 {
38773960 java.awt.Toolkit.getDefaultToolkit().beep();
38783961 return false;
38793962 }
38803963
38813964 //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3882
- CopyChanged(copy.versions[copy.versionindex]);
3965
+ CopyChanged(copy.versionlist[copy.versionindex]);
38833966
38843967 return true;
38853968 }
....@@ -3890,13 +3973,13 @@
38903973
38913974 cRadio tab = GetCurrentTab();
38923975
3893
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3976
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38943977 {
38953978 // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
38963979 return false;
38973980 }
38983981
3899
- copy.versions[copy.versionindex] = CompressCopy();
3982
+ copy.versionlist[copy.versionindex] = CompressCopy();
39003983
39013984 return true;
39023985 }
....@@ -3908,7 +3991,7 @@
39083991
39093992 cRadio tab = GetCurrentTab();
39103993
3911
- if (copy.versions[copy.versionindex + 1] == null)
3994
+ if (copy.versionlist[copy.versionindex + 1] == null)
39123995 {
39133996 java.awt.Toolkit.getDefaultToolkit().beep();
39143997 return;
....@@ -3916,7 +3999,7 @@
39163999
39174000 copy.versionindex += 1;
39184001
3919
- CopyChanged(copy.versions[copy.versionindex]);
4002
+ CopyChanged(copy.versionlist[copy.versionindex]);
39204003
39214004 //if (!tab.user[tab.versionindex])
39224005 // tab.graphs[tab.versionindex] = null;
....@@ -4130,7 +4213,7 @@
41304213 //copy.material = new cMaterial(copy.GetMaterial());
41314214
41324215 current.color = (float) colorField.getFloat();
4133
- current.modulation = (float) modulationField.getFloat();
4216
+ current.modulation = (float) saturationField.getFloat();
41344217 current.metalness = (float) metalnessField.getFloat();
41354218 current.diffuse = (float) diffuseField.getFloat();
41364219 current.specular = (float) specularField.getFloat();
....@@ -4163,7 +4246,7 @@
41634246 cMaterial mat = copy.material;
41644247
41654248 colorField.SetToolTipValue((mat.color));
4166
- modulationField.SetToolTipValue((mat.modulation));
4249
+ saturationField.SetToolTipValue((mat.modulation));
41674250 metalnessField.SetToolTipValue((mat.metalness));
41684251 diffuseField.SetToolTipValue((mat.diffuse));
41694252 specularField.SetToolTipValue((mat.specular));
....@@ -4227,9 +4310,9 @@
42274310
42284311 int version = versionSlider.getInteger();
42294312
4230
- if (copy.versions[version] != null)
4313
+ if (copy.versionlist[version] != null)
42314314 {
4232
- CopyChanged(copy.versions[copy.versionindex = version]);
4315
+ CopyChanged(copy.versionlist[copy.versionindex = version]);
42334316 }
42344317
42354318 return;
....@@ -4269,6 +4352,12 @@
42694352 {
42704353 //System.out.println("stateChanged = " + this);
42714354 materialtouched = true;
4355
+
4356
+ if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
4357
+ {
4358
+ saturationField.setFloat(1);
4359
+ }
4360
+
42724361 applySelf();
42734362 //System.out.println("this = " + this);
42744363 //System.out.println("PARENT = " + parent);
....@@ -4568,6 +4657,7 @@
45684657 {
45694658 if (GetTree() != null)
45704659 {
4660
+ GetTree().revalidate();
45714661 GetTree().repaint();
45724662 }
45734663
....@@ -4959,12 +5049,12 @@
49595049 c.addChild(csg);
49605050 }
49615051
4962
- copy.versions = readobj.versions;
5052
+ copy.versionlist = readobj.versionlist;
49635053 copy.versionindex = readobj.versionindex;
49645054
4965
- if (copy.versions == null)
5055
+ if (copy.versionlist == null)
49665056 {
4967
- copy.versions = new Object3D[100];
5057
+ copy.versionlist = new Object3D[100];
49685058 copy.versionindex = -1;
49695059 }
49705060
....@@ -5372,7 +5462,7 @@
53725462 JLabel colorLabel;
53735463 cNumberSlider colorField;
53745464 JLabel modulationLabel;
5375
- cNumberSlider modulationField;
5465
+ cNumberSlider saturationField;
53765466 JLabel metalnessLabel;
53775467 cNumberSlider metalnessField;
53785468 JLabel diffuseLabel;