Commit 81f4cb73 authored by Gregor Pintar's avatar Gregor Pintar

Annoying GUI value overwriting bug fixed.

parent 8f8dfb89
......@@ -127,10 +127,26 @@ public final class AperiodicPanel extends javax.swing.JPanel implements ISpeaker
Graph vent;
@Override
public void refresh(Speaker speaker)
public void show(Speaker speaker)
{
this.speaker = speaker;
listen = false;
vbField.setValue(speaker.Aperiodic.Vb * 1000);
qlField.setValue(speaker.Aperiodic.Ql);
qaField.setValue(speaker.Aperiodic.Qa);
portPositionXField.setValue(speaker.Aperiodic.VentPosition.X * 100);
portPositionYField.setValue(speaker.Aperiodic.VentPosition.Y * 100);
portPositionZField.setValue(speaker.Aperiodic.VentPosition.Z * 100);
portPositionDistanceField.setValue(main.project.ListeningPosition.distance(speaker.Aperiodic.VentPosition) * 100);
listen = true;
}
@Override
public void addGraphs(final JTabbedPane tabs)
{
BassReflexSimulation sim = (BassReflexSimulation) speaker.getSimulation();
box = new Graph("Enclosure response", "Hz", "dB");
......@@ -147,26 +163,10 @@ public final class AperiodicPanel extends javax.swing.JPanel implements ISpeaker
box.setYRange(box.getMaxY() - main.project.Settings.dBRange, box.getMaxY() + 1);
cone.setYRange(cone.getMaxY() - main.project.Settings.dBRange, cone.getMaxY() + 1);
vent.setYRange(vent.getMaxY() - main.project.Settings.dBRange, vent.getMaxY() + 1);
}
@Override
public void addGraphs(final JTabbedPane tabs)
{
listen = false;
vbField.setValue(speaker.Aperiodic.Vb * 1000);
qlField.setValue(speaker.Aperiodic.Ql);
qaField.setValue(speaker.Aperiodic.Qa);
portPositionXField.setValue(speaker.Aperiodic.VentPosition.X * 100);
portPositionYField.setValue(speaker.Aperiodic.VentPosition.Y * 100);
portPositionZField.setValue(speaker.Aperiodic.VentPosition.Z * 100);
portPositionDistanceField.setValue(main.project.ListeningPosition.distance(speaker.Aperiodic.VentPosition) * 100);
tabs.addTab("Enclosure response", box.getGraph());
tabs.addTab("Cone response", cone.getGraph());
tabs.addTab("Vent response", vent.getGraph());
listen = true;
}
@SuppressWarnings("unchecked")
......
......@@ -152,10 +152,28 @@ public final class BassReflexPanel extends javax.swing.JPanel implements ISpeake
Graph port;
@Override
public void refresh(Speaker speaker)
public void show(Speaker speaker)
{
this.speaker = speaker;
listen = false;
vbField.setValue(speaker.BassReflex.Vb * 1000);
fbField.setValue(speaker.BassReflex.Fb);
qlField.setValue(speaker.BassReflex.Ql);
qaField.setValue(speaker.BassReflex.Qa);
qpField.setValue(speaker.BassReflex.Qp);
portPositionXField.setValue(speaker.BassReflex.PortPosition.X * 100);
portPositionYField.setValue(speaker.BassReflex.PortPosition.Y * 100);
portPositionZField.setValue(speaker.BassReflex.PortPosition.Z * 100);
portPositionDistanceField.setValue(main.project.ListeningPosition.distance(speaker.BassReflex.PortPosition) * 100);
listen = true;
}
@Override
public void addGraphs(final JTabbedPane tabs)
{
BassReflexSimulation sim = (BassReflexSimulation) speaker.getSimulation();
box = new Graph("Enclosure response", "Hz", "dB");
......@@ -172,28 +190,10 @@ public final class BassReflexPanel extends javax.swing.JPanel implements ISpeake
box.setYRange(box.getMaxY() - main.project.Settings.dBRange, box.getMaxY() + 1);
cone.setYRange(cone.getMaxY() - main.project.Settings.dBRange, cone.getMaxY() + 1);
port.setYRange(port.getMaxY() - main.project.Settings.dBRange, port.getMaxY() + 1);
}
@Override
public void addGraphs(final JTabbedPane tabs)
{
listen = false;
vbField.setValue(speaker.BassReflex.Vb * 1000);
fbField.setValue(speaker.BassReflex.Fb);
qlField.setValue(speaker.BassReflex.Ql);
qaField.setValue(speaker.BassReflex.Qa);
qpField.setValue(speaker.BassReflex.Qp);
portPositionXField.setValue(speaker.BassReflex.PortPosition.X * 100);
portPositionYField.setValue(speaker.BassReflex.PortPosition.Y * 100);
portPositionZField.setValue(speaker.BassReflex.PortPosition.Z * 100);
portPositionDistanceField.setValue(main.project.ListeningPosition.distance(speaker.BassReflex.PortPosition) * 100);
tabs.addTab("Enclosure response", box.getGraph());
tabs.addTab("Cone response", cone.getGraph());
tabs.addTab("Port response", port.getGraph());
listen = true;
}
@SuppressWarnings("unchecked")
......
......@@ -77,10 +77,23 @@ public final class ClosedPanel extends javax.swing.JPanel implements ISpeakerPan
Graph box;
@Override
public void refresh(Speaker speaker)
public void show(Speaker speaker)
{
this.speaker = speaker;
listen = false;
vbField.setValue(speaker.ClosedBox.Vb * 1000);
qlField.setValue(speaker.ClosedBox.Ql);
qaField.setValue(speaker.ClosedBox.Qa);
qtcField.setValue(ClosedBoxSimulation.calcQtc(speaker.ClosedBox.Vb, speaker.Driver.Vas, speaker.Driver.Qts));
listen = true;
}
@Override
public void addGraphs(final JTabbedPane tabs)
{
ClosedBoxSimulation sim = (ClosedBoxSimulation) speaker.getSimulation();
box = new Graph("Enclosure response", "Hz", "dB");
......@@ -91,21 +104,8 @@ public final class ClosedPanel extends javax.swing.JPanel implements ISpeakerPan
}
box.setYRange(box.getMaxY() - main.project.Settings.dBRange, box.getMaxY() + 1);
}
@Override
public void addGraphs(final JTabbedPane tabs)
{
listen = false;
vbField.setValue(speaker.ClosedBox.Vb * 1000);
qlField.setValue(speaker.ClosedBox.Ql);
qaField.setValue(speaker.ClosedBox.Qa);
qtcField.setValue(ClosedBoxSimulation.calcQtc(speaker.ClosedBox.Vb, speaker.Driver.Vas, speaker.Driver.Qts));
tabs.addTab("Enclosure response", box.getGraph());
listen = true;
}
@SuppressWarnings("unchecked")
......
......@@ -22,6 +22,6 @@ import javax.swing.JTabbedPane;
public interface ISpeakerPanel
{
public void refresh(Speaker speaker);
public void show(Speaker speaker);
public void addGraphs(JTabbedPane tabs);
}
......@@ -1525,6 +1525,29 @@ public class MainWindow extends javax.swing.JFrame
private void showNode(final DefaultMutableTreeNode node)
{
// update properties panel
final IItem item = (IItem) node.getUserObject();
showPanels(item);
if (bafflePanel != null)
{
((BafflePanel) bafflePanel).show(((Speaker) item).Baffle);
}
if (driverPositionPanel != null)
{
((DriverPositionPanel) driverPositionPanel).show(((Speaker) item).Position);
}
if (enclosurePanel != null)
{
((ISpeakerPanel) enclosurePanel).show((Speaker) item);
}
propertiesPanel.revalidate();
propertiesPanel.repaint();
// stop worker, if running
if (worker != null && worker.isAlive())
{
worker.interrupt();
......@@ -1667,27 +1690,14 @@ public class MainWindow extends javax.swing.JFrame
{
tabs.addTab("Impedance", graphImpedance.getGraph());
}
showPanels(item);
if (bafflePanel != null)
{
((BafflePanel) bafflePanel).show(((Speaker) item).Baffle);
}
if (driverPositionPanel != null)
{
((DriverPositionPanel) driverPositionPanel).show(((Speaker) item).Position);
}
if (enclosurePanel != null)
{
((ISpeakerPanel) enclosurePanel).refresh((Speaker) item); // shoud be done in worker thread (without invoke)?
((ISpeakerPanel) enclosurePanel).addGraphs(tabs);
((ISpeakerPanel) enclosurePanel).addGraphs(tabs); // graphs shoud be done in worker thread?
}
rightPanel.revalidate();
rightPanel.repaint();
tabs.revalidate();
tabs.repaint();
UI.setSelectedTab(tabs, selectedTab);
}
});
......@@ -1716,10 +1726,8 @@ public class MainWindow extends javax.swing.JFrame
tabs.addTab("Impedance", graphImpedance.getGraph());
}
showPanels(item);
rightPanel.revalidate();
rightPanel.repaint();
tabs.revalidate();
tabs.repaint();
UI.setSelectedTab(tabs, selectedTab);
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment