From 914255f70cf047897212839cbf3a6722703f4457 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Mon, 24 Jun 2019 13:19:16 -0400 Subject: [PATCH] Fix manip window + new icons. --- GroupEditor.java | 310 +++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 237 insertions(+), 73 deletions(-) diff --git a/GroupEditor.java b/GroupEditor.java index 43af894..cce9b1b 100644 --- a/GroupEditor.java +++ b/GroupEditor.java @@ -176,7 +176,6 @@ copyItem.addActionListener(this); pasteItem = menu.add(new MenuItem("Paste")); pasteItem.addActionListener(this); - menu.add("-"); menu.add("-"); pasteIntoItem = menu.add(new MenuItem("Paste into")); @@ -246,7 +245,7 @@ cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug")); toggleDebugItem.addItemListener(this); - toggleDebugItem.setState(CameraPane.DEBUG); + toggleDebugItem.setState(Globals.DEBUG); cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum")); toggleFrustumItem.addItemListener(this); @@ -369,11 +368,11 @@ billboardItem.addActionListener(this); csgItem = menu.add(new MenuItem("CSG")); csgItem.addActionListener(this); - shadowXItem = menu.add(new MenuItem("Shadow X")); + shadowXItem = menu.add(new MenuItem("Shadow Red")); shadowXItem.addActionListener(this); - shadowYItem = menu.add(new MenuItem("Shadow Y")); + shadowYItem = menu.add(new MenuItem("Shadow Green")); shadowYItem.addActionListener(this); - shadowZItem = menu.add(new MenuItem("Shadow Z")); + shadowZItem = menu.add(new MenuItem("Shadow Blue")); shadowZItem.addActionListener(this); if (Globals.ADVANCED) { @@ -470,6 +469,14 @@ markleavesItem.addActionListener(this); unmarkleavesItem = menu.add(new MenuItem("Unmark Leaves")); unmarkleavesItem.addActionListener(this); + rewindleavesItem = menu.add(new MenuItem("Rewind Leaves")); + rewindleavesItem.addActionListener(this); + unrewindleavesItem = menu.add(new MenuItem("Unrewind Leaves")); + unrewindleavesItem.addActionListener(this); + randomleavesItem = menu.add(new MenuItem("Random Leaves")); + randomleavesItem.addActionListener(this); + unrandomleavesItem = menu.add(new MenuItem("Unrandom Leaves")); + unrandomleavesItem.addActionListener(this); menu.add("-"); flipVItem = menu.add(new MenuItem("Flip V")); flipVItem.addActionListener(this); @@ -527,6 +534,18 @@ void SetupUI2(ObjEditor oe) { + // June 2019 + if (oe == null) + { + //super.SetupUI2(this); + //return; + } + + if (copy != group) + { + //super.SetupUI2(this); + } + //new Exception().printStackTrace(); oe.radioPanel = new JPanel(new GridBagLayout()); @@ -557,35 +576,47 @@ */ //this.AddOptions(oe.toolbarPanel, oe.aConstraints); - oe.toolbarPanel.add(undoButton = new cButton("Undo", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + //oe.toolbarPanel.add(minButton = new cButton("Min", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + //minButton.setToolTipText("Minimize window"); + //minButton.addActionListener(this); + + oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + maxButton.setToolTipText("Maximize window"); + maxButton.addActionListener(this); + + oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + fullButton.setToolTipText("Full-screen window"); + fullButton.addActionListener(this); + + oe.toolbarPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); undoButton.setToolTipText("Undo changes"); undoButton.addActionListener(this); - oe.toolbarPanel.add(redoButton = new cButton("Redo", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolbarPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); redoButton.setToolTipText("Redo changes"); redoButton.addActionListener(this); - oe.toolbarPanel.add(saveButton = new cButton("Save", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolbarPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); saveButton.setToolTipText("Save changes"); saveButton.addActionListener(this); - oe.toolbarPanel.add(liveCB = new cCheckBox("Live", Globals.isLIVE())); //, oe.aConstraints); + oe.toolbarPanel.add(liveCB = GetCheckBox("icons/run.png", Globals.isLIVE())); //, oe.aConstraints); liveCB.setToolTipText("Enable animation"); liveCB.addItemListener(this); - oe.toolbarPanel.add(oneStepButton = new cButton("Step", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - oneStepButton.setToolTipText("Animate one step forward"); - oneStepButton.addActionListener(this); - - oe.toolbarPanel.add(fastCB = new cCheckBox("Fast", CameraPane.FAST)); //, constraints); + oe.toolbarPanel.add(fastCB = GetCheckBox("icons/runfast.png", CameraPane.FAST)); //, constraints); fastCB.setToolTipText("Fast mode"); fastCB.addItemListener(this); - oe.toolbarPanel.add(trackCB = new cCheckBox("Track", CameraPane.TRACK)); //, oe.aConstraints); + oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oneStepButton.setToolTipText("Animate one step forward"); + oneStepButton.addActionListener(this); + + oe.toolbarPanel.add(trackCB = GetCheckBox("icons/track.png", CameraPane.TRACK)); //, oe.aConstraints); trackCB.setToolTipText("Enable tracking"); trackCB.addItemListener(this); - oe.toolbarPanel.add(screenfitButton = new cButton("@", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolbarPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); screenfitButton.setToolTipText("Screen fit"); screenfitButton.addActionListener(this); @@ -599,25 +630,25 @@ snapobjectButton.setToolTipText("Snap Object"); } - oe.toolbarPanel.add(flashSelectionButton = new cButton("?", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - flashSelectionButton.setToolTipText("Show selection"); + oe.toolbarPanel.add(flashSelectionButton = GetButton("icons/light-bulb.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + flashSelectionButton.setToolTipText("Highlight selection"); flashSelectionButton.addActionListener(this); oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL)); - oe.toolbarPanel.add(twoButton = new cButton("|+|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolbarPanel.add(twoButton = new cButton("|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); twoButton.setToolTipText("Show center view only"); twoButton.addActionListener(this); - oe.toolbarPanel.add(fourButton = new cButton("+||", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolbarPanel.add(fourButton = new cButton("-||", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); fourButton.addActionListener(this); fourButton.setToolTipText("Show left panel only"); - oe.toolbarPanel.add(sixButton = new cButton("+|+|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolbarPanel.add(sixButton = new cButton("-|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); sixButton.setToolTipText("2-column layout left"); sixButton.addActionListener(this); - oe.toolbarPanel.add(threeButton = new cButton("|+|+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolbarPanel.add(threeButton = new cButton("|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); threeButton.setToolTipText("2-column layout right"); threeButton.addActionListener(this); - oe.toolbarPanel.add(sevenButton = new cButton("+|+|+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); sevenButton.setToolTipText("3-column layout"); sevenButton.addActionListener(this); // @@ -632,32 +663,30 @@ //oe.treePanel.add(clearButton = new cButton("X"), oe.aConstraints); //clearButton.addActionListener(this); - cGridBag commandsPanel = new cGridBag(); - - commandsPanel.add(editButton = new cButton("+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + editCommandsPanel.add(editButton = new cButton("+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); editButton.setToolTipText("Edit selection"); editButton.addActionListener(this); - commandsPanel.add(uneditButton = new cButton("-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + editCommandsPanel.add(uneditButton = new cButton("-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); uneditButton.setToolTipText("Unedit selection"); uneditButton.addActionListener(this); - commandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints); + editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints); allParamsButton.setToolTipText("Edit all params"); allParamsButton.addActionListener(this); - commandsPanel.add(clearPanelButton = new cButton("C", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + editCommandsPanel.add(clearPanelButton = new cButton("C", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); clearPanelButton.setToolTipText("Clear edit panel"); clearPanelButton.addActionListener(this); - commandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); unselectButton.setToolTipText("Unselect"); unselectButton.addActionListener(this); - commandsPanel.preferredHeight = 1; + editCommandsPanel.preferredHeight = 1; - oe.treePanel.add(commandsPanel); - oe.treePanel.Return(); +// oe.treePanel.add(commandsPanel); +// oe.treePanel.Return(); // oe.aConstraints.gridx += 1; // oe.aConstraints.weighty = 0; @@ -779,11 +808,23 @@ // debugCB.addItemListener(this); panel.add(oeilCB = new cCheckBox("Eye", CameraPane.OEIL)); //, constraints); + oeilCB.setToolTipText("Move camera when tracking target"); oeilCB.addItemListener(this); + panel.add(shadowCB = new cCheckBox("Shadow", Globals.COMPUTESHADOWWHENLIVE)); //, constraints); + shadowCB.setToolTipText("Compute shadows when live"); + shadowCB.addItemListener(this); + + panel.add(autosaveCB = new cCheckBox("Auto-save", Globals.SAVEONMAKE)); //, constraints); + autosaveCB.setToolTipText("Auto-save on structure change"); + autosaveCB.addItemListener(this); + + if (Globals.ADVANCED) + { panel.add(lookAtCB = new cCheckBox("Target", CameraPane.LOOKAT)); //, constraints); lookAtCB.setToolTipText("Look-at target"); lookAtCB.addItemListener(this); + } } @@ -798,6 +839,14 @@ void EditObject(Object3D obj) { cRadio radioButton = new cRadio(obj.name); + + // Patch to avoid bug with transparency. + radioButton.hadMaterial = obj.material != null; + if (!radioButton.hadMaterial) + { + obj.material = new cMaterial(); + } + radioButton.SetObject(obj); radioButton.layout = sevenButton; radioButton.SetCamera(cameraView.renderCamera, false); @@ -809,6 +858,8 @@ void SetupViews(ObjEditor oe) { + theFrame = this; + oe.SetupViews(); System.out.println("SetupViews"); @@ -817,23 +868,26 @@ /*DropTarget dropTarget =*/ new DropTarget(oe.cameraView, this); } - JCheckBox liveCB; - JCheckBox supportCB; - JCheckBox localCB; - JCheckBox crowdCB; - JCheckBox smoothCB; - JCheckBox fastCB; - JCheckBox slowCB; - JCheckBox boxCB; - JCheckBox zoomBoxCB; - JCheckBox trackCB; - JCheckBox smoothfocusCB; + cCheckBox liveCB; + cCheckBox supportCB; + cCheckBox localCB; + cCheckBox crowdCB; + cCheckBox smoothCB; + cCheckBox fastCB; + cCheckBox slowCB; + cCheckBox boxCB; + cCheckBox zoomBoxCB; + cCheckBox trackCB; + cCheckBox smoothfocusCB; // JCheckBox speakerMocapCB; - JCheckBox speakerCameraCB; - JCheckBox speakerFocusCB; - JCheckBox debugCB; - JCheckBox oeilCB; - JCheckBox lookAtCB; + cCheckBox speakerCameraCB; + cCheckBox speakerFocusCB; + cCheckBox debugCB; + + cCheckBox oeilCB; + cCheckBox shadowCB; + cCheckBox autosaveCB; + cCheckBox lookAtCB; // static int COLOR = 1; // static int MATERIAL = 2; @@ -841,9 +895,9 @@ int dropAttributes = Object3D.COLOR | Object3D.MATERIAL; - JCheckBox colorCB; - JCheckBox materialCB; - JCheckBox textureCB; + cCheckBox colorCB; + cCheckBox materialCB; + cCheckBox textureCB; public void itemStateChanged(ItemEvent e) { @@ -871,6 +925,7 @@ } else if(e.getSource() == liveCB) { cameraView.ToggleLive(); + refreshContents(false); } else if(e.getSource() == supportCB) { @@ -934,6 +989,14 @@ else if(e.getSource() == oeilCB) { cameraView.ToggleOeil(); + } + else if(e.getSource() == shadowCB) + { + Globals.COMPUTESHADOWWHENLIVE ^= true; + } + else if(e.getSource() == autosaveCB) + { + Globals.SAVEONMAKE ^= true; } else if(e.getSource() == lookAtCB) { @@ -1278,7 +1341,7 @@ memoryItem.addActionListener(this); menu.add(analyzeItem = new MenuItem("Analyze")); analyzeItem.addActionListener(this); - menu.add(dumpItem = new MenuItem("Dump")); + menu.add(dumpItem = new MenuItem("Print")); dumpItem.addActionListener(this); // menu.add(pathItem = new MenuItem("From-to path")); // pathItem.addActionListener(this); @@ -1419,6 +1482,7 @@ shadow.material = new cMaterial(obj.material); shadow.material.diffuse = 0.0001f; shadow.material.specular = 0.0001f; + //shadow.projectedVertices[1].x = 300; makeSomething(shadow); } @@ -1968,6 +2032,18 @@ if (source == dumpItem) { DumpObject(); + } else + if (source == minButton) + { + Minimize(); + } else + if (source == maxButton) + { + Maximize(); + } else + if (source == fullButton) + { + ToggleFullScreen(); } else if (source == undoButton) { @@ -2542,7 +2618,7 @@ } else if (source == genNormalsMESHItem) { - GenNormals(true); // TODO + GenNormalsMESH(); } else if (source == genNormalsORGANItem) { @@ -2607,6 +2683,22 @@ if (source == unmarkleavesItem) { MarkLeaves(false); + } else + if (source == rewindleavesItem) + { + RewindLeaves(true); + } else + if (source == unrewindleavesItem) + { + RewindLeaves(false); + } else + if (source == randomleavesItem) + { + RandomLeaves(true); + } else + if (source == unrandomleavesItem) + { + RandomLeaves(false); } else if (source == flipVItem) { @@ -2874,6 +2966,24 @@ bigThree.ClearUI(); bigThree.add(centralPanel); bigThree.FlushUI(); + + cameraView.requestFocusInWindow(); + +// refreshContents(true); +// +// try +// { +// java.awt.Robot bot = new java.awt.Robot(); +// int mask = InputEvent.BUTTON1_MASK; +// bot.mouseMove(100, 100); +// bot.mousePress(mask); +// bot.mouseRelease(mask); +// } +// catch (Exception e) +// { +// +// } + } else if (source == threeButton) { @@ -2910,6 +3020,8 @@ bigThree.add(centralPanel); bigThree.add(XYZPanel); bigThree.FlushUI(); + + cameraView.requestFocusInWindow(); } else if (source == fourButton) { @@ -2945,6 +3057,8 @@ bigThree.ClearUI(); bigThree.add(scenePanel); bigThree.FlushUI(); + + cameraView.requestFocusInWindow(); } else if (source == sixButton) { @@ -2981,6 +3095,8 @@ bigThree.add(scenePanel); bigThree.add(centralPanel); bigThree.FlushUI(); + + cameraView.requestFocusInWindow(); } else if (source == sevenButton) { @@ -3018,6 +3134,8 @@ bigThree.add(centralPanel); bigThree.add(XYZPanel); bigThree.FlushUI(); + + cameraView.requestFocusInWindow(); } else if (source == rootButton) { @@ -3029,6 +3147,7 @@ EditObject(obj); } + cameraView.requestFocusInWindow(); refreshContents(true); } else if (source == closeButton) @@ -3038,18 +3157,27 @@ for (Enumeration e = buttonGroup.getElements(); e.hasMoreElements();) { ab = (cRadio)e.nextElement(); - if(ab.getModel().isSelected() && ab.GetObject() != client) + if (ab.getModel().isSelected() && ab.GetObject() != client) { + // Patch to avoid bug with transparency. + if (!ab.hadMaterial) + { + ab.object.material = null; + } + buttonGroup.remove(ab); radioPanel.remove(ab); - ab.GetObject().editWindow = null; + //ab.GetObject().editWindow = null; + ab.GetObject().manipWindow = null; // ab.GetObject().objectUI = null; // ????????? ((cRadio)radioPanel.getComponent(radioPanel.getComponentCount() - 1)).doClick(); break; } } + + cameraView.requestFocusInWindow(); refreshContents(true); } else if (source == editItem || source == editButton) @@ -3154,7 +3282,8 @@ } // fix "+" issue - group.editWindow = this; + //group.editWindow = this; + group.manipWindow = this; /* currentLayout = radio.layout; @@ -3167,6 +3296,8 @@ //group.parent = null; // ROOT //group.attributes = -1; ResetModel(); + + cameraView.requestFocusInWindow(); refreshContents(true); } else if (event.getSource() == editCameraItem) { @@ -3190,7 +3321,6 @@ } boolean useclient = false; - cRadio radio; void ToggleRoot() { @@ -3511,6 +3641,13 @@ void GenNormals(boolean crease) { group.GenNormalsS(crease); + + refreshContents(); + } + + void GenNormalsMESH() + { + group.GenNormalsMeshS(); refreshContents(); } @@ -4138,6 +4275,18 @@ refreshContents(); } + void RewindLeaves(boolean hide) + { + group.selection.RewindLeaves(hide); + refreshContents(); + } + + void RandomLeaves(boolean hide) + { + group.selection.RandomLeaves(hide); + refreshContents(); + } + void SetTexRes(int tr) { group.selection.SetTexRes(tr); @@ -4313,7 +4462,6 @@ //case 702: // Event.LIST_DESELECT group.deselectAll(); TreePath tps[] = objEditor.jTree.getSelectionPaths(); - objEditor.ClearInfo(); // .GetMaterial()); if (tps != null) { for (int i=0; i < tps.length; i++) @@ -4322,10 +4470,8 @@ //if (child.parent != null) //child.parent.addSelectee(child); + objEditor.SetMaterial(child); group.addSelectee(child); - objEditor.SetMaterial(child); // .GetMaterial()); - objEditor.AddInfo(child, this, true); // .GetMaterial()); - System.err.println("info : " + child.GetPath()); } } // else @@ -4335,8 +4481,6 @@ // System.err.println("info : " + group.GetPath()); // } - objEditor.SetText(); // jan 2014 - if (flashIt && !Globals.isLIVE() && tps != null && tps.length > 0 && !(tps[0].getLastPathComponent() instanceof Camera)) CameraPane.flash = true; @@ -4360,6 +4504,26 @@ freezemodel = false; } + + void refreshContents(boolean cp) + { + if (!Globals.MOUSEDRAGGED) + { + objEditor.ClearInfo(); // .GetMaterial()); + + for (int i=0; i < group.selection.Size(); i++) + { + Object3D child = (Object3D) group.selection.get(i); + + objEditor.AddInfo(child, this, true); + System.err.println("info : " + child.GetPath()); + } + + objEditor.SetText(); // jan 2014 + } + + super.refreshContents(cp); + } void linkSomething(Object3D thing) { @@ -4442,6 +4606,7 @@ if (cut) { + if (Globals.SAVEONMAKE) Save(); //int indices[] = jList.getSelectedIndices(); //for (int i = indices.length - 1; i >= 0; i--) @@ -5160,9 +5325,12 @@ cButton clearpanelButton; cButton unselectButton; - cButton saveButton; + cButton minButton; + cButton maxButton; + cButton fullButton; cButton undoButton; cButton redoButton; + cButton saveButton; cButton oneStepButton; cButton screenfitButton; @@ -5175,14 +5343,6 @@ cButton closeButton; cButton setsupportButton; - - cButton twoButton; - cButton sixButton; - cButton threeButton; - cButton sevenButton; - cButton fourButton; // full panel - cButton oneButton; // full XYZ - //cButton currentLayout; // //Composite @@ -5260,6 +5420,10 @@ private MenuItem showleavesItem; private MenuItem markleavesItem; private MenuItem unmarkleavesItem; + private MenuItem rewindleavesItem; + private MenuItem unrewindleavesItem; + private MenuItem randomleavesItem; + private MenuItem unrandomleavesItem; private MenuItem flipVItem; private MenuItem unflipVItem; -- Gitblit v1.6.2