From c3c47406ac43dafd51e6ad1d7b92a794bd69b7d6 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Fri, 27 Sep 2019 20:03:29 -0400 Subject: [PATCH] Fix/patch click flicking. --- ObjEditor.java | 675 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 548 insertions(+), 127 deletions(-) diff --git a/ObjEditor.java b/ObjEditor.java index 3f3be5b..c8eff94 100644 --- a/ObjEditor.java +++ b/ObjEditor.java @@ -24,6 +24,7 @@ matrix.Matrix; import grafeme.ui.*; +import org.xj3d.ui.swt.widgets.ImageLoader; class ObjEditor /*extends JFrame*/ implements iCallBack, ObjectUI, ActionListener, ChangeListener, @@ -97,9 +98,11 @@ cButton GetButton(String name, boolean border) { - ImageIcon icon = GetIcon(name); - if (icon != null || name.contains("/")) - return new cButton(icon, border); + //ImageIcon icon = GetIcon(name); + boolean fit = !name.startsWith("icons"); + if (//icon != null || + name.contains("/")) + return new cButton(name, border, fit); else return new cButton(name, border); } @@ -136,9 +139,18 @@ { BufferedImage image; - if (name.endsWith("jpg")) - // Much faster! - image = new sun.awt.image.codec.JPEGImageDecoderImpl(ObjEditor.class.getClassLoader().getResourceAsStream(name)).decodeAsBufferedImage(); + if (!Grafreed.isWindows && name.endsWith("jpg")) + { + try + { + // Much faster! + image = JpegLoader.load(name); + } + catch (Exception e) + { + image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name)); + } + } else image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name)); @@ -316,6 +328,8 @@ objEditor.ctrlPanel.remove(setupPanel2); objEditor.ctrlPanel.remove(objectCommandsPanel); objEditor.ctrlPanel.remove(pushPanel); + if (versionPanel != null) + objEditor.ctrlPanel.remove(versionPanel); //objEditor.ctrlPanel.remove(fillPanel); //Remove(normalpushField); @@ -383,14 +397,6 @@ client = inClient; copy = client; - if (copy.versionlist == null) - { - copy.versionlist = new Object3D[100]; - copy.versionindex = -1; - -// Save(true); - } - SetupUI2(callee.GetEditor()); } @@ -501,7 +507,7 @@ //povItem.addActionListener(this); closeItem.addActionListener(this); - objectPanel = new JTabbedPane(); + objectTabbedPane = new JTabbedPane(); ChangeListener changeListener = new ChangeListener() { @@ -552,13 +558,13 @@ // } // } // } - cameraView.transformMode = objectPanel.getSelectedIndex() == 4; + cameraView.transformMode = objectTabbedPane.getSelectedIndex() == 5; // refreshContents(false); // To refresh Info tab cameraView.repaint(); } }; - objectPanel.addChangeListener(changeListener); + objectTabbedPane.addChangeListener(changeListener); toolbarPanel = new JPanel(); toolbarPanel.setName("Toolbar"); @@ -601,7 +607,7 @@ //infoPanel.setLayout(new BorderLayout()); //infoPanel.add(createTextPane()); - mainPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, treePanel, objectPanel); + mainPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, treePanel, objectTabbedPane); mainPanel.setName("Main"); mainPanel.setContinuousLayout(true); mainPanel.setOneTouchExpandable(true); @@ -793,6 +799,8 @@ // SendInfo(" delay: " + sel.delay + newline, "regular"); // live, hide, ... //?? SendInfo(" Orig: " + maxima + newline, "regular"); + if (sel.GetTextures().pigmentdata != null) + si.SendInfo(" EMBEDDED ", "regular"); si.SendInfo((debug ? " Texture: " : " ") + sel.GetTextures(), "bold"); // SendInfo((debug ? " Material: " : " ") + sel.material + newline, "regular"); if (sel instanceof cMesh) @@ -903,10 +911,20 @@ cButton minButton; cButton maxButton; - cButton fullButton; + cButton fullScreenButton; cButton collapseButton; cButton maximize3DButton; + public void Show3DView() + { + // bug + //gridPanel.setDividerLocation(1.0); + //bigPanel.setDividerLocation(0.0); + bigThree.ClearUI(); + bigThree.add(centralPanel); + bigThree.FlushUI(); + } + void ToggleFullScreen() { GraphicsDevice device = frame.getGraphicsConfiguration().getDevice(); @@ -933,14 +951,18 @@ // framePanel.setDividerLocation(46); // icons are 24x24 //frame.setVisible(true); -// radio.layout = keepButton; + radio.layout = keepButton; //theFrame = null; keepButton = null; -// radio.layout.doClick(); + radio.layout.doClick(); } else { keepButton = radio.layout; + + radio.layout = twoButton; + Show3DView(); + //keeprect = frame.getBounds(); // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width, // frame.getToolkit().getScreenSize().height); @@ -962,6 +984,7 @@ // radio.layout = fullscreenLayout; // radio.layout.doClick(); //frame.setVisible(true); + CollapseToolbar(); } frame.validate(); @@ -987,6 +1010,8 @@ object.ExtractBigData(Grafreed.grafreed.universe.versiontable); // if (copy == client) + assert(!object.HasBigData()); + Object3D versions[] = object.versionlist; java.util.Hashtable<java.util.UUID, Object3D> versiontable = object.versiontable; // if Grafreed.grafreed.universe object.versionlist = null; @@ -997,6 +1022,8 @@ //byte[] compress = Compress(copy); Object3D compress = (Object3D)Grafreed.clone(object); + + assert(!compress.HasBigData()); object.parent = parent; @@ -1144,6 +1171,7 @@ JCheckBox selectableCB; JCheckBox hideCB; JCheckBox link2masterCB; + JCheckBox sortCB; JCheckBox markCB; JCheckBox randomCB; JCheckBox speedupCB; @@ -1171,6 +1199,7 @@ cGridBag setupPanel2; cGridBag objectCommandsPanel; cGridBag pushPanel; + cGridBag versionPanel; cGridBag fillPanel; JCheckBox AddCheckBox(cGridBag panel, String label, boolean on) @@ -1333,6 +1362,11 @@ obj = o; } } + + String GetSupportText() + { + return "Support"; + } void SetupUI2(ObjEditor oe) { @@ -1381,11 +1415,14 @@ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind); rewindCB.setToolTipText("Rewind animation"); + sortCB = AddCheckBox(setupPanel2, "Sort", copy.sort); + sortCB.setToolTipText("Display from back to front"); + randomCB = AddCheckBox(setupPanel2, "Random", copy.random); randomCB.setToolTipText("Randomly Rewind (or Go back and forth)"); - link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master); - link2masterCB.setToolTipText("Attach to support"); + link2masterCB = AddCheckBox(setupPanel2, GetSupportText(), copy.link2master); + link2masterCB.setToolTipText("Link to support"); if (Globals.ADVANCED) { @@ -1417,9 +1454,14 @@ oe.ctrlPanel.add(objectCommandsPanel); oe.ctrlPanel.Return(); - pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons + pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH * 100, 1.1); // To have the buttons normalpushField = (cNumberSlider)pushPanel.getComponent(1); - //Return(); + if (false && copy.versionlist != null && copy.versionindex != -1) + { + oe.ctrlPanel.Return(); + versionPanel = AddSlider(oe.ctrlPanel, "Version", 0, copy.VersionCount() - 1, copy.versionindex); + versionField = (cNumberSlider)versionPanel.getComponent(1); + } oe.ctrlPanel.Return(); @@ -1556,6 +1598,8 @@ return null; } + + int objectTabCount; void SetupViews() { @@ -1691,6 +1735,12 @@ //XYZPanel.setName("XYZ"); transformPanel.add(resetTransformPanel); + + cGridBag scalePanel = AddSlider(transformPanel, "Scale", 1, 10, 1); + scalePanel.preferredHeight = 2; + scaleSlider = (cNumberSlider)scalePanel.getComponent(1); + transformPanel.add(scalePanel); + transformPanel.add(XYZPanel); /* @@ -1728,33 +1778,42 @@ //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //tmp.setName("Edit"); - objectPanel.add(skyboxPanel); - objectPanel.setIconAt(0, GetIcon("icons/skybox.jpg")); - objectPanel.setToolTipTextAt(0, "Backgrounds"); - objectPanel.add(toolboxPanel); - objectPanel.setIconAt(1, GetIcon("icons/primitives.png")); - objectPanel.setToolTipTextAt(1, "Objects & textures"); + objectTabCount = 0; + + objectTabbedPane.add(skyboxPanel); + objectTabbedPane.setIconAt(objectTabCount, GetIcon("icons/skybox.jpg")); + objectTabbedPane.setToolTipTextAt(objectTabCount++, "Backgrounds"); + + objectTabbedPane.add(toolboxPanel); + objectTabbedPane.setIconAt(objectTabCount, GetIcon("icons/primitives.png")); + objectTabbedPane.setToolTipTextAt(objectTabCount++, "Objects & textures"); - objectPanel.add(materialPanel); - objectPanel.setIconAt(2, GetIcon("icons/material.png")); - objectPanel.setToolTipTextAt(2, "Material"); + objectTabbedPane.add(materialPanel); + objectTabbedPane.setIconAt(objectTabCount, GetIcon("icons/material.png")); + objectTabbedPane.setToolTipTextAt(objectTabCount++, "Material"); + figurePanel = new cGridBag(); + figurePanel.add(new cButton("FIGURES and POSES coming soon!")); + objectTabbedPane.add(figurePanel); + objectTabbedPane.setIconAt(objectTabCount, GetIcon("icons/figure.png")); + objectTabbedPane.setToolTipTextAt(objectTabCount++, "Figures and poses"); + // JPanel north = new JPanel(new BorderLayout()); // north.setName("Edit"); // north.add(ctrlPanel, BorderLayout.NORTH); // objectPanel.add(north); - objectPanel.add(editPanel); - objectPanel.setIconAt(3, GetIcon("icons/writewhite.png")); - objectPanel.setToolTipTextAt(3, "Edit controls"); + objectTabbedPane.add(editPanel); + objectTabbedPane.setIconAt(objectTabCount, GetIcon("icons/writewhite.png")); + objectTabbedPane.setToolTipTextAt(objectTabCount++, "Edit controls"); - objectPanel.add(transformPanel); - objectPanel.setIconAt(4, GetIcon("icons/XYZ.png")); - objectPanel.setToolTipTextAt(4, "TRS transform"); + objectTabbedPane.add(transformPanel); + objectTabbedPane.setIconAt(objectTabCount, GetIcon("icons/XYZ.png")); + objectTabbedPane.setToolTipTextAt(objectTabCount++, "TRS transform"); patchMaterial = true; cameraView.patchMaterial = this; - objectPanel.setSelectedIndex(2); + objectTabbedPane.setSelectedIndex(2); /* aConstraints.gridx = 0; @@ -1777,8 +1836,8 @@ /*JTabbedPane*/ scenePanel = new cGridBag(); scenePanel.preferredWidth = 6; - JTabbedPane tabbedPane = new JTabbedPane(); - tabbedPane.add(scrollpane); + JTabbedPane sceneTabbedPane = new JTabbedPane(); + sceneTabbedPane.add(scrollpane); optionsPanel = new cGridBag().setVertical(false); @@ -1786,11 +1845,207 @@ AddOptions(optionsPanel); //, aConstraints); - tabbedPane.add(FSPane = new cFileSystemPane(this)); + sceneTabbedPane.add(FSPane = new cFileSystemPane(this)); - tabbedPane.add(optionsPanel); + fullscenePanel = new cGridBag(); + fullscenePanel.setName("Download"); + sceneTabbedPane.add(fullscenePanel); - scenePanel.add(tabbedPane); + cButton fullsceneButton; + + fullscenePanel.add(fullsceneButton = GetButton("fullscenes/alsace.png", !Globals.NIMBUSLAF)); + fullsceneButton.setToolTipText("Alsace!"); + fullsceneButton.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + ReadGFD("https://www.noaofarc.ca/akeeba/categories/Applications/Alsace.gfd", new iCallBack() + { + + public void Callback(Object obj) + { + LoadIt(obj); + } + + public void DragGesture() + { + } + }); + } + }); + + fullscenePanel.add(fullsceneButton = GetButton("fullscenes/desertmotel.png", !Globals.NIMBUSLAF)); + fullsceneButton.setToolTipText("Desert Motel!"); + fullsceneButton.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + ReadGFD("https://www.noaofarc.ca/akeeba/categories/Applications/DesertMotel.gfd", new iCallBack() + { + + public void Callback(Object obj) + { + LoadIt(obj); + } + + public void DragGesture() + { + } + }); + } + }); + + fullscenePanel.Return(); + + fullscenePanel.add(fullsceneButton = GetButton("fullscenes/london.png", !Globals.NIMBUSLAF)); + fullsceneButton.setToolTipText("Old London!"); + fullsceneButton.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + ReadGFD("https://www.noaofarc.ca/akeeba/categories/Applications/oldlondon.gfd", new iCallBack() + { + + public void Callback(Object obj) + { + LoadIt(obj); + } + + public void DragGesture() + { + } + }); + } + }); + + fullscenePanel.add(fullsceneButton = GetButton("fullscenes/skullcove.png", !Globals.NIMBUSLAF)); + fullsceneButton.setToolTipText("Skull Cove Island!"); + fullsceneButton.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + ReadGFD("https://www.noaofarc.ca/akeeba/categories/Applications/SkullCoveIsland.gfd", new iCallBack() + { + + public void Callback(Object obj) + { + LoadIt(obj); + } + + public void DragGesture() + { + } + }); + } + }); + + fullscenePanel.Return(); + + fullscenePanel.add(fullsceneButton = GetButton("fullscenes/tuscany.png", !Globals.NIMBUSLAF)); + fullsceneButton.setToolTipText("Tuscany!"); + fullsceneButton.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + ReadGFD("https://www.noaofarc.ca/akeeba/categories/Applications/Tuscany.gfd", new iCallBack() + { + + public void Callback(Object obj) + { + LoadIt(obj); + } + + public void DragGesture() + { + } + }); + } + }); + + fullscenePanel.add(fullsceneButton = GetButton("fullscenes/venice.png", !Globals.NIMBUSLAF)); + fullsceneButton.setToolTipText("Venice!"); + fullsceneButton.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + ReadGFD("https://www.noaofarc.ca/akeeba/categories/Applications/Venice.gfd", new iCallBack() + { + + public void Callback(Object obj) + { + LoadIt(obj); + } + + public void DragGesture() + { + } + }); + } + }); + + fullscenePanel.Return(); + + fullscenePanel.add(fullsceneButton = GetButton("fullscenes/viking.png", !Globals.NIMBUSLAF)); + fullsceneButton.setToolTipText("Viking Village!"); + fullsceneButton.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + ReadGFD("https://www.noaofarc.ca/akeeba/categories/Applications/VikingVillage.gfd", new iCallBack() + { + + public void Callback(Object obj) + { + LoadIt(obj); + } + + public void DragGesture() + { + } + }); + } + }); + + fullscenePanel.add(fullsceneButton = GetButton("fullscenes/yvoire.png", !Globals.NIMBUSLAF)); + fullsceneButton.setToolTipText("Yvoire!"); + fullsceneButton.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + ReadGFD("https://www.noaofarc.ca/akeeba/categories/Applications/Yvoire.gfd", new iCallBack() + { + + public void Callback(Object obj) + { + LoadIt(obj); + } + + public void DragGesture() + { + } + }); + } + }); + + fullscenePanel.Return(); + + fullscenePanel.add(new cGridBag()); + fullscenePanel.add(new cGridBag()); + fullscenePanel.Return(); + fullscenePanel.add(new cGridBag()); + fullscenePanel.add(new cGridBag()); + + sceneTabbedPane.add(optionsPanel); + + scenePanel.add(sceneTabbedPane); cGridBag creditsPanel = new cGridBag().setVertical(true); creditsPanel.setName("Credits"); @@ -1879,14 +2134,14 @@ creditsPanel.add(new cGridBag()); } - tabbedPane.add(creditsPanel); - tabbedPane.setToolTipTextAt(3, "Credits"); + sceneTabbedPane.add(creditsPanel); + sceneTabbedPane.setToolTipTextAt(3, "Credits"); - if (Globals.ADVANCED) + if (Globals.SHOWINFO) { - tabbedPane.add(infoPanel); - tabbedPane.setIconAt(4, GetIcon("icons/info.png")); - tabbedPane.setToolTipTextAt(4, "Information"); + objectTabbedPane.add(infoPanel); + objectTabbedPane.setIconAt(objectTabCount, GetIcon("icons/info.png")); + objectTabbedPane.setToolTipTextAt(objectTabCount++, "Information"); } /* @@ -1967,11 +2222,16 @@ { if ((Integer)pce.getOldValue() == 1) { - if (radio.layout != expandedLayout) + if (CameraPane.FULLSCREEN) { - radio.layout = expandedLayout; - radio.layout.doClick(); + ToggleFullScreen(); } + +// if (radio.layout != expandedLayout) +// { +// radio.layout = expandedLayout; +// radio.layout.doClick(); +// } } } }); @@ -1995,7 +2255,7 @@ // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc); - frame.setSize(1280, 860); + frame.setSize(1280, 900); cameraView.requestFocusInWindow(); @@ -2370,7 +2630,7 @@ { public void mouseClicked(MouseEvent e) { - borderfadeField.setFloat(0.5); + borderfadeField.setFloat(0.4); opacityField.setFloat(0.75); materialtouched = true; @@ -2429,13 +2689,55 @@ cameraField.setFloat(0.001); specularField.setFloat(0.001); fakedepthField.setFloat(0.001); - opacityField.setFloat(0.6); + opacityField.setFloat(0.4); materialtouched = true; applySelf(); } }); presetpanel.add(shadowShader); + + cLabel para0 = GetLabel("icons/shadericons/parallax0.png", !Globals.NIMBUSLAF); + para0.setToolTipText("No parallax"); + para0.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + parallaxField.setFloat(0.125); + + materialtouched = true; + applySelf(); + } + }); + presetpanel.add(para0); + + cLabel para1 = GetLabel("icons/shadericons/parallax1.png", !Globals.NIMBUSLAF); + para1.setToolTipText("With parallax"); + para1.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + parallaxField.setFloat(0.13); + + materialtouched = true; + applySelf(); + } + }); + presetpanel.add(para1); + + cLabel para2 = GetLabel("icons/shadericons/parallax2.png", !Globals.NIMBUSLAF); + para2.setToolTipText("Reset parallax"); + para2.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + parallaxField.setFloat(0.14); + + materialtouched = true; + applySelf(); + } + }); + presetpanel.add(para2); cGridBag panel = new cGridBag().setVertical(true); @@ -2685,7 +2987,7 @@ cGridBag parallax = new cGridBag(); parallax.add(parallaxLabel = new JLabel("Parallax")); // , aConstraints); parallaxLabel.setHorizontalAlignment(SwingConstants.TRAILING); - parallax.add(parallaxField = new cNumberSlider(this, 0.001, 0.5, -0.25)); // , aConstraints); + parallax.add(parallaxField = new cNumberSlider(this, 0.001, 0.25, -0.125)); // , aConstraints); colorSection.add(parallax); //panel.add(new JSeparator()); @@ -3739,7 +4041,7 @@ shadowField.setFloat(mat.shadow); textureField.setFloat(mat.texture); opacityField.setFloat(mat.opacity); - parallaxField.setFloat(mat.parallax + 0.25f); + parallaxField.setFloat(mat.parallax + 0.125f); fakedepthField.setFloat(mat.fakedepth); shadowbiasField.setFloat(mat.shadowbias); bumpField.setInteger(1); // dec 2013 @@ -4030,14 +4332,34 @@ copy.Touch(); // display list issue objEditor.refreshContents(true); // To show item colors return; + } else if (event.getSource() == sortCB) + { + copy.sort ^= true; + objEditor.refreshContents(); + return; } else if (event.getSource() == link2masterCB) { copy.link2master ^= true; + objEditor.refreshContents(); return; } if (event.getSource() == randomCB) { copy.random ^= true; + if (this instanceof RandomEditor) + { + cGridBag itemPanel = ((RandomEditor)this).itemPanel; + itemPanel.getComponent(0).setEnabled(!copy.random); + + // Tooltip? + if (copy.random) + { + } + else + { + } + } + objEditor.refreshContents(); return; } @@ -4273,6 +4595,12 @@ void New() { + copy.skyboxname = "cubemaps/penguins-skyboxes/yonder"; + copy.skyboxext = "jpg"; + + copy.versionlist = null; + copy.versionindex = -1; + while (copy.Size() > 0) { copy.remove(0); @@ -4283,9 +4611,15 @@ if (copy == Grafreed.grafreed.universe) { CreateCameras(); - cameraView.SetCamera(GetCamera(copy, 0)); + cameraView.SetCamera(GetCamera(copy, 0), true); + cameraView.SetLight(GetCamera(copy, 4)); } + ResetModel(); + + //DuplicateVersion(); + + this.SetVersionStates(); objEditor.refreshContents(); } @@ -4423,17 +4757,23 @@ copy.versionindex -= 1; if (copy.versionindex != -1) - CopyChanged(); + CopyChanged(copy); SetVersionStates(); + + SetCameras(false); } - public boolean Save(boolean user) + public boolean DuplicateVersion() // boolean user) { System.err.println("Save"); - Replace(); + //Replace(); - //cRadio tab = GetCurrentTab(); + if (copy.versionlist == null) + { + copy.versionlist = new Object3D[100]; + copy.versionindex = -1; + } Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"? @@ -4501,20 +4841,25 @@ { Object3D selection = new Object3D(); - for (int i = 0; i < copy.selection.size(); i++) + if (objEditor.copy.selection == null) { - Object3D elem = copy.selection.elementAt(i); + objEditor.copy.selection = new Object3D(); + } + + for (int i = 0; i < objEditor.copy.selection.size(); i++) + { + Object3D elem = objEditor.copy.selection.elementAt(i); - Object3D obj = copy.GetObject(elem.GetUUID()); + Object3D obj = objEditor.copy.GetObject(elem.GetUUID()); if (obj == null) { - copy.selection.remove(i--); + objEditor.copy.selection.remove(i--); } else { selection.add(obj); - copy.selection.setElementAt(obj, i); + objEditor.copy.selection.setElementAt(obj, i); } } @@ -4527,44 +4872,44 @@ //refreshContents(false); } - void CopyChanged() + void CopyChanged(Object3D changed) { - Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]); + Object3D obj = (Object3D)Grafreed.clone(changed.versionlist[copy.versionindex]); - SetVersionStates(); + assert(!obj.HasBigData()); boolean temp = CameraPane.SWITCH; CameraPane.SWITCH = false; - copy.ExtractBigData(Grafreed.grafreed.universe.versiontable); + changed.ExtractBigData(Grafreed.grafreed.universe.versiontable); - copy.clear(); - - copy.skyboxname = obj.skyboxname; - copy.skyboxext = obj.skyboxext; + changed.clear(); + + obj.deepCopyNode(changed); for (int i=0; i<obj.Size(); i++) { - copy.add(obj.get(i)); + changed.add(obj.get(i)); } - copy.RestoreBigData(Grafreed.grafreed.universe.versiontable); + changed.RestoreBigData(Grafreed.grafreed.universe.versiontable); CameraPane.SWITCH = temp; - RefreshSelection(); + if (objEditor == this) + RefreshSelection(); //assert(hashtable.isEmpty()); - copy.Touch(); + objEditor.copy.Touch(); ResetModel(); - copy.HardTouch(); // recompile? + objEditor.copy.HardTouch(); // recompile? cRadio ab; - for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();) + for (java.util.Enumeration e = objEditor.buttonGroup.getElements(); e.hasMoreElements();) { ab = (cRadio)e.nextElement(); - Object3D test = copy.GetObject(ab.object.GetUUID()); + Object3D test = objEditor.copy.GetObject(ab.object.GetUUID()); //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID()); if (test != null) { @@ -4573,7 +4918,7 @@ } } - refreshContents(true); + objEditor.refreshContents(true); } cButton previousVersionButton; @@ -4587,15 +4932,7 @@ int VersionCount() { - int count = 0; - - for (int i = copy.versionlist.length; --i >= 0;) - { - if (copy.versionlist[i] != null) - count++; - } - - return count; + return copy.VersionCount(); } public cGridBag versionSliderPane; @@ -4607,7 +4944,7 @@ //cRadio tab = GetCurrentTab(); - if (copy.versionlist == null) + if (copy.versionindex == -2) { saveVersionButton.setEnabled(false); restoreButton.setEnabled(false); @@ -4623,7 +4960,7 @@ replaceButton.setEnabled(copy.versionindex != -1); previousVersionButton.setEnabled(copy.versionindex > 0); - nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null); + nextVersionButton.setEnabled(copy.versionlist != null && copy.versionlist[copy.versionindex + 1] != null); deleteVersionButton.setEnabled(copy.versionindex != -1); //copy.versionlist[copy.versionindex + 1] != null); @@ -4644,7 +4981,7 @@ // Option? Replace(); - System.err.println("Undo"); + //System.err.println("Previous"); //cRadio tab = GetCurrentTab(); @@ -4669,7 +5006,11 @@ copy.versionindex -= 1; - CopyChanged(); + CopyChanged(copy); + + SetVersionStates(); + + SetCameras(false); return true; } @@ -4687,7 +5028,11 @@ } //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); - CopyChanged(); + CopyChanged(copy); + + SetVersionStates(); + + SetCameras(false); return true; } @@ -4698,7 +5043,8 @@ //cRadio tab = GetCurrentTab(); - if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null) + // < 0 means == -2 || == -1 + if (copy.versionindex < 0 || copy.versionlist[copy.versionindex] == null) { // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep(); return false; @@ -4724,24 +5070,46 @@ copy.versionindex += 1; - CopyChanged(); + CopyChanged(copy); //if (!tab.user[tab.versionindex]) // tab.graphs[tab.versionindex] = null; + + SetVersionStates(); + + SetCameras(false); } + void SetCameras(boolean set) + { + if (copy == Grafreed.grafreed.universe) + { + Camera neweye = (Camera)copy.GetObject(cameraView.cameras[cameraView.cameracount^1].GetUUID()); + Camera newlight = (Camera)copy.GetObject(cameraView.LightCamera().GetUUID()); + + cameraView.SetCamera(neweye, set); + cameraView.SetLight(newlight); + } + } + + void ImportGFD(String url) + { + objEditor.ReadGFD(url, objEditor); + } + void ImportGFD() { FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD); - browser.show(); + browser.setVisible(true); String filename = browser.getFile(); if (filename != null && filename.length() > 0) { String fullname = browser.getDirectory() + filename; //Object3D readobj = - objEditor.ReadGFD(fullname, objEditor); + // objEditor.ReadGFD(fullname, objEditor); //makeSomething(readobj); + ImportGFD(fullname); } } @@ -4964,7 +5332,7 @@ current.shadow = (float) shadowField.getFloat(); current.texture = (float) textureField.getFloat(); current.opacity = (float) opacityField.getFloat(); - current.parallax = (float) parallaxField.getFloat() - 0.25f; + current.parallax = (float) parallaxField.getFloat() - 0.125f; current.fakedepth = (float) fakedepthField.getFloat(); current.shadowbias = (float) shadowbiasField.getFloat(); @@ -5056,10 +5424,18 @@ } cNumberSlider versionSlider; + cNumberSlider versionField; + cNumberSlider scaleSlider; + + void ScaleSelection(int scale) + { + } + public void stateChanged(ChangeEvent e) { // assert(false); + // Main version slider if (e.getSource() == versionSlider) { if (muteSlider) @@ -5072,9 +5448,33 @@ if (version != -1 && copy.versionlist[version] != null) { copy.versionindex = version; - CopyChanged(); + CopyChanged(copy); + SetVersionStates(); + SetCameras(false); } + return; + } + + // Version slider of edited object + if (e.getSource() == versionField) + { + int version = versionField.getInteger(); + + if (version != -1 && copy.versionindex != version && copy.versionlist[version] != null) + { + copy.versionindex = version; + CopyChanged(copy); + } + + return; + } + + if (e.getSource() == scaleSlider) + { + int scale = scaleSlider.getInteger(); + + ScaleSelection(scale); return; } @@ -5167,7 +5567,7 @@ } if (normalpushField != null) - copy.NORMALPUSH = (float)normalpushField.getFloat()/100; + copy.NORMALPUSH = (float)normalpushField.getFloat() / 100; } void SnapObject() @@ -5315,7 +5715,7 @@ interest.y = k * interest.y + (1 - k) * height; } - CameraPane.zoomonce = true; + // CameraPane.zoomonce = true; // june 2014 Camera parentcam = cameraView.manipCamera; @@ -5389,7 +5789,7 @@ objEditor.ScreenFit(obj, false); - cameraView.pingthread.StepToTarget(true); // aout 2013 + cameraView.pingthread.StepToTarget(); //true); // aout 2013 refreshContents(); } @@ -5541,7 +5941,7 @@ void ResetModel() { //assert(copy instanceof Composite); - Object3D /*Composite*/ group = (Object3D /*Composite*/) copy; + Object3D /*Composite*/ group = (Object3D /*Composite*/) objEditor.copy; // necessary? group.selection = new Object3D(); // java.util.Vector(); @@ -5552,14 +5952,14 @@ //group.refreshEditWindow(); //refreshContents(); - if (copy.selection == null) + if (objEditor.copy.selection == null) { - copy.selection = new Object3D(); + objEditor.copy.selection = new Object3D(); } - for (int j = 0; j < copy.selection.size(); j++) + for (int j = 0; j < objEditor.copy.selection.size(); j++) { - Object3D item = copy.selection.get(j); + Object3D item = objEditor.copy.selection.get(j); if (item instanceof cGroup && ((cGroup) item).transientlink) { @@ -5568,15 +5968,15 @@ if (item.count <= 1) // ??? == 0) { - copy.selection.remove(item); + objEditor.copy.selection.remove(item); } } boolean first = true; - for (int i = copy.selection.size(); --i >= 0;) + for (int i = objEditor.copy.selection.size(); --i >= 0;) { - Object3D item = copy.selection.get(i); + Object3D item = objEditor.copy.selection.get(i); if (item instanceof cGroup && ((cGroup) item).transientlink) { @@ -5666,10 +6066,27 @@ { Object3D readobj = null; + java.net.URL url = null; + + try + { + url = new java.net.URL(fullname); + } catch (Exception e) + { + try + { + url = new java.net.URL("file:///" + fullname); + } catch (Exception e2) + { + e2.printStackTrace(); + } + } + try { // Try compressed version first. - java.io.FileInputStream istream = new java.io.FileInputStream(fullname); + java.io.InputStream istream //= new java.io.FileInputStream(fullname); + = url.openStream(); java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream); java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream); @@ -5684,7 +6101,8 @@ try { - java.io.FileInputStream istream = new java.io.FileInputStream(fullname); + java.io.InputStream istream //= new java.io.FileInputStream(fullname); + = url.openStream(); java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream); readobj = (Object3D) p.readObject(); @@ -5782,12 +6200,11 @@ // // oct 2012 if(cam.parent == null) // cam.parent = copy.get(0); // cams; // } - cameraView.SetCamera((Camera) cams.get(0)); - // MAJOR CRASH!! - cameraView.SetLight((Camera) cams.get(4)); - topView.SetCamera((Camera) cams.get(1)); - frontView.SetCamera((Camera) cams.get(2)); - sideView.SetCamera((Camera) cams.get(3)); + cameraView.SetCamera((Camera) cams.get(0), true); + cameraView.SetLight((Camera) cams.get(4)); // MAJOR CRASH!! + topView.SetCamera((Camera) cams.get(1), true); + frontView.SetCamera((Camera) cams.get(2), true); + sideView.SetCamera((Camera) cams.get(3), true); // copy.get(0).clear(); // copy.get(0).addAll(cams); @@ -5829,6 +6246,8 @@ //? SetUndoStates(); + cameraView.RevertCamera(); + ResetModel(); copy.HardTouch(); // recompile? refreshContents(); @@ -5840,7 +6259,7 @@ if (Grafreed.standAlone) { FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD); - browser.show(); + browser.setVisible(true); String filename = browser.getFile(); if (filename != null && filename.length() > 0) { @@ -6163,12 +6582,14 @@ cGridBag skyboxPanel; cGridBag materialPanel; cGridBag ctrlPanel; + cGridBag figurePanel; + cGridBag fullscenePanel; JScrollPane infoPanel; cGridBag optionsPanel; - JTabbedPane objectPanel; + JTabbedPane objectTabbedPane; boolean materialFlushed; Object3D latestObject; -- Gitblit v1.6.2