Updates to FX and group localiser (not building)

This commit is contained in:
Jamie Mac 2023-08-10 16:49:04 +01:00
parent 6474311cb2
commit ec48c539ae
14 changed files with 329 additions and 96 deletions

View File

@ -30,6 +30,8 @@ public class ArrayGUIFX extends PamControlledGUIFX {
if (arraySettingsPane==null) {
arraySettingsPane= new ArraySettingsPane();
}
System.out.println("The current array is "+ arrayManager.getCurrentArray());
arraySettingsPane.setParams(arrayManager.getCurrentArray());
return arraySettingsPane;
}

View File

@ -33,7 +33,7 @@ import pamViewFX.fxNodes.PamHBox;
*/
public class ArraySettingsPane extends SettingsPane<PamArray >{
private StreamerPane basicArrayPane;
private StreamerPane streamerPane;
private PamFlipPane mainPane;
@ -88,7 +88,7 @@ public class ArraySettingsPane extends SettingsPane<PamArray >{
arrayLabel.setPadding(new Insets(5,5,5,5));
PamGuiManagerFX.titleFont1style(arrayLabel);
basicArrayPane = new StreamerPane();
streamerPane = new StreamerPane();
Label hydrophoneLabel = new Label("Hydrophone");
PamGuiManagerFX.titleFont1style(hydrophoneLabel);
@ -111,7 +111,7 @@ public class ArraySettingsPane extends SettingsPane<PamArray >{
PamVBox vBox = new PamVBox();
vBox.setSpacing(5);
vBox.getChildren().addAll(arrayLabel, basicArrayPane, hydrophoneLabel,
vBox.getChildren().addAll(arrayLabel, streamerPane, hydrophoneLabel,
hydrophonePane, advancedPane);
return vBox;
@ -126,8 +126,9 @@ public class ArraySettingsPane extends SettingsPane<PamArray >{
@Override
public void setParams(PamArray input) {
System.out.println("Hydrophone array is: "+ input);
hydrophonePane.setParams(input);
streamerPane.setParams(input);
}
@Override

View File

@ -14,7 +14,8 @@ public enum DefaultHydrophone {
* The name of the hydrophones.
*/
private String name;
/**
* The sensitivity of the hydrophone in dB re 1V/uPa.
*/
@ -38,5 +39,20 @@ public enum DefaultHydrophone {
}
/**
* The sensitivity of the hydrophone in dB re 1V/uPa.
*/
public double getSens() {
return sens;
}
/**
* The gain in dB.
*/
public double getGain() {
return gain;
}
}

View File

@ -17,7 +17,7 @@ import javafx.scene.layout.Pane;
import pamViewFX.PamGuiManagerFX;
import pamViewFX.fxNodes.PamVBox;
import pamViewFX.fxNodes.PamGridPane;
import pamViewFX.fxNodes.PamSpinner;
import pamViewFX.validator.PamValidator;
/**
@ -61,8 +61,8 @@ public class HydrophoneSettingsPane extends SettingsPane<Hydrophone> {
private TextField xPosErr;
private TextField zPosErr;
private TextField hSens;
private TextField preampGain;
private PamSpinner<Double> hSens;
private PamSpinner<Double> preampGain;
private ComboBox<String> streamers;
private ChoiceBox<DefaultHydrophone> defaultArrays;
@ -92,9 +92,7 @@ public class HydrophoneSettingsPane extends SettingsPane<Hydrophone> {
private InterpSettingsPane interpPane;
private ComboBox<DefaultHydrophone> defaultHydro;
private ComboBox<String> defaultHydro;
//create the dialog
public HydrophoneSettingsPane() {
@ -228,13 +226,33 @@ public class HydrophoneSettingsPane extends SettingsPane<Hydrophone> {
gridy++;
mainControls.add(recieverTypeLabel = new Label(""), 0, gridy);
recieverTypeLabel.setAlignment(Pos.CENTER_RIGHT);
defaultHydro = new ComboBox<DefaultHydrophone>();
defaultHydro = new ComboBox<String>();
for (int i=0; i<DefaultHydrophone.values().length; i++) {
defaultHydro.getItems().add(DefaultHydrophone.values()[i].toString());
}
defaultHydro.getItems().add(0, "User defined");
defaultHydro.getSelectionModel().select(0);
defaultHydro.setOnAction((action)->{
if (defaultHydro.getSelectionModel().getSelectedIndex() == 0) {
//do nothing.
}
hSens.getValueFactory().setValue(Double.valueOf(DefaultHydrophone.values()[defaultHydro.getSelectionModel().getSelectedIndex()-1].getSens()));
preampGain.getValueFactory().setValue(Double.valueOf(DefaultHydrophone.values()[defaultHydro.getSelectionModel().getSelectedIndex()-1].getGain()));
});
mainControls.add(defaultHydro, 1, gridy);
gridy++;
mainControls.add(recieverSensLabel = new Label(""), 0, gridy);
recieverSensLabel.setAlignment(Pos.CENTER_RIGHT);
hSens = new TextField();
hSens = new PamSpinner<Double>();
hSens.valueProperty().addListener((obs, oldval, newVal)->{
defaultHydro.getSelectionModel().select(0);
});
mainControls.add(hSens, 1, gridy);
mainControls.add(dBSensLabel = new Label(""), 2, gridy);
@ -243,7 +261,11 @@ public class HydrophoneSettingsPane extends SettingsPane<Hydrophone> {
Label preAmpLabel = new Label("Preamplifier gain");
mainControls.add(preAmpLabel, 0, gridy);
preAmpLabel.setAlignment(Pos.CENTER_RIGHT);
preampGain = new TextField();
preampGain =new PamSpinner<Double>();
preampGain.valueProperty().addListener((obs, oldval, newVal)->{
defaultHydro.getSelectionModel().select(0);
});
mainControls.add(preampGain, 1, gridy);
mainControls.add(new Label("dB"), 2, gridy);
@ -396,9 +418,8 @@ public class HydrophoneSettingsPane extends SettingsPane<Hydrophone> {
}
//hydrophone stuff
hSens.setText(String.format("%.1f", hydrophone.getSensitivity()-PamController.getInstance().getGlobalMediumManager().getdBSensOffset()));
preampGain.setText(String.format("%.1f", hydrophone.getPreampGain()));
hSens.getValueFactory().setValue(hydrophone.getSensitivity()-PamController.getInstance().getGlobalMediumManager().getdBSensOffset());
preampGain.getValueFactory().setValue(hydrophone.getPreampGain());
double zCoeff = PamController.getInstance().getGlobalMediumManager().getZCoeff();
setCoordsText();
@ -423,8 +444,8 @@ public class HydrophoneSettingsPane extends SettingsPane<Hydrophone> {
//hydrophone.setType(type.getText());
hydrophone.setStreamerId(streamers.getSelectionModel().getSelectedIndex());
hydrophone.setSensitivity(Double.valueOf(hSens.getText())+PamController.getInstance().getGlobalMediumManager().getdBSensOffset());
hydrophone.setPreampGain(Double.valueOf(preampGain.getText()));
hydrophone.setSensitivity(hSens.getValue()+PamController.getInstance().getGlobalMediumManager().getdBSensOffset());
hydrophone.setPreampGain(preampGain.getValue());
// double[] bw = new double[2];
// bw[0] = Double.valueOf(bandwidth0.getText());
// bw[1] = Double.valueOf(bandwidth1.getText());

View File

@ -14,7 +14,8 @@ import pamViewFX.fxNodes.flipPane.PamFlipPane;
import pamViewFX.fxNodes.table.TableSettingsPane;
/**
* Table which allows users to add and edit hydrophones.
* Table which allows users to add and edit hydrophones.
*
* @author Jamie Macaulay
*
*/
@ -35,7 +36,6 @@ public class HydrophonesPane extends PamBorderPane {
*/
protected PamArray currentArray;
/**
* A list of all the current hydrophones.
*/
@ -142,6 +142,7 @@ public class HydrophonesPane extends PamBorderPane {
pamFlipePane.getAdvLabel().setText("Hydrophone " + data.getID().get() + " Settings");
hydrophonePane.setCurrentArray(currentArray);
hydrophonePane.setParams(data.getHydrophone());
pamFlipePane.flipToBack();
@ -154,6 +155,8 @@ public class HydrophonesPane extends PamBorderPane {
public void setHydrophonePane(HydrophoneProperty data){
hydrophonePane.setCurrentArray(getCurrentArray());
hydrophonePane.setCurrentArray(currentArray);
hydrophonePane.setParams(data.getHydrophone());
//now need to make sure on closing the pane that settings are saved. Need to

View File

@ -1,5 +1,6 @@
package Array.layoutFX;
import Array.PamArray;
import Array.Streamer;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
@ -21,8 +22,9 @@ public class StreamerPane extends PamBorderPane {
BasicArrayTable tableArrayPane;
ObservableList<StreamerProperty> streamerData = FXCollections.observableArrayList();
private PamArray currentArray;
public StreamerPane() {
tableArrayPane = new BasicArrayTable(streamerData);
@ -107,6 +109,10 @@ public class StreamerPane extends PamBorderPane {
}
}
public void setParams(PamArray currentArray) {
this.currentArray=currentArray;
}
}

View File

@ -0,0 +1,57 @@
package Array.layoutFX;
import Array.Streamer;
import PamController.SettingsPane;
import javafx.scene.Node;
import pamViewFX.fxNodes.PamBorderPane;
import javafx.scene.control.Label;
/**
* A javaFX settings pane for a streamer.
*
* @author Jamie Macaulay
*
*/
public class StreamerSettingsPane extends SettingsPane<Streamer> {
public PamBorderPane mainPane;
public StreamerSettingsPane() {
super(null);
mainPane = new PamBorderPane();
mainPane.setCenter(new Label("Hello"));
}
@Override
public Streamer getParams(Streamer currParams) {
// TODO Auto-generated method stub
return null;
}
@Override
public void setParams(Streamer input) {
// TODO Auto-generated method stub
}
@Override
public String getName() {
// TODO Auto-generated method stub
return "Streamer Pane";
}
@Override
public Node getContentNode() {
return mainPane;
}
@Override
public void paneInitialized() {
}
}

View File

@ -5,26 +5,16 @@ import java.awt.Window;
import PamController.SettingsPane;
import group3dlocaliser.algorithm.LocaliserAlgorithmParams;
public abstract class LocaliserPane<T> {
public abstract class LocaliserPane<T> extends SettingsPane<T> {
public LocaliserPane() {
super(null);
// TODO Auto-generated constructor stub
}
/**
* Get the FX pane with settings.
* @return the settings pane for the localiser.
*/
public abstract SettingsPane<T> getSettingsPane();
/**
* Get the dialog for the localiser. This is usually used
* for Swing settings panes
* @return the settings dialog.
*/
public abstract LocaliserAlgorithmParams showAlgorithmDialog(Window awtWindow,
LocaliserAlgorithmParams algorithmPaams);
}

View File

@ -43,6 +43,18 @@ abstract public class LocaliserAlgorithm3D implements LocaliserModel<PamDataUnit
return preGroups;
}
/**
* The loclaiser params. The
* <p>
*
* Note: the localiser params for each model are stored in
* @param localiserParams
*/
public void setLocaliserParams(LocaliserAlgorithmParams localiserParams){
}
// /**
// * Configure parameters for this algorithm. Show a dialog with
// * anything you want ...
@ -57,6 +69,11 @@ abstract public class LocaliserAlgorithm3D implements LocaliserModel<PamDataUnit
// return null;
// }
/**
* Get an algorithm specific settings pane. This holds settings which are specific to the
* localisation algorithm.
*/
@Override
public LocaliserPane<Serializable> getAlgorithmSettingsPane(){
return null;

View File

@ -19,6 +19,15 @@ import annotation.localise.targetmotion.TMAnnotationType;
import generalDatabase.SQLLoggingAddon;
import group3dlocaliser.algorithm.LocaliserAlgorithm3D;
import group3dlocaliser.algorithm.LocaliserAlgorithmParams;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.control.Tooltip;
import pamViewFX.PamGuiManagerFX;
import pamViewFX.fxGlyphs.PamGlyphDude;
import pamViewFX.fxNodes.PamButton;
import pamViewFX.fxNodes.PamHBox;
public class CrossedBearingGroupLocaliser extends LocaliserAlgorithm3D {
@ -152,12 +161,57 @@ public class CrossedBearingGroupLocaliser extends LocaliserAlgorithm3D {
public class CrossedBearingPane extends LocaliserPane<Serializable> {
@Override
public SettingsPane<Serializable> getSettingsPane() {
// TODO Auto-generated method stub
return null;
public CrossedBearingPane() {
PamHBox hBox = new PamHBox();
hBox.setSpacing(5);
hBox.setAlignment(Pos.CENTER);
hBox.setPadding(new Insets(5,5,5,5));
PamButton algoOptsButton = new PamButton("",PamGlyphDude.createPamIcon("mdi2c-cog", PamGuiManagerFX.iconSize));
algoOptsButton.setOnAction((action)->{
moreAlgorithmOptions() ;
});
algoOptsButton.setTooltip(new Tooltip("More Algorithm Options ..."));
hBox.getChildren().addAll(new Label(localiserAlgorithm.getName() + " settings"), algoOptsButton);
mainPane = new PamBordepPane();
mainPane.setCenter
}
/**
* Handle algorithm options ...
*/
protected void moreAlgorithmOptions() {
String algoName = getName();
if (algoName == null) {
return;
}
LocaliserAlgorithm3D localiserAlgorithm = group3dLocaliserControl.findAlgorithm(algoName);
if (localiserAlgorithm == null) {
return;
}
if (localiserAlgorithm.hasParams() == false) {
return;
}
LocaliserAlgorithmParams algorithmPaams = group3dLocaliserControl.getLocaliserAlgorithmParams(localiserAlgorithm);
algorithmPaams = showAlgorithmDialog(getAWTWindow(), algorithmPaams);
if (algorithmPaams != null) {
group3dLocaliserControl.setAlgorithmParams(localiserAlgorithm, algorithmPaams);
}
}
/* (non-Javadoc)
* @see group3dlocaliser.algorithm.LocaliserAlgorithmProvider#showAlgorithmDialog(java.awt.Window, group3dlocaliser.algorithm.LocaliserAlgorithmParams)
*/
@ -177,6 +231,36 @@ public class CrossedBearingGroupLocaliser extends LocaliserAlgorithm3D {
return null;
}
}
@Override
public Serializable getParams(Serializable currParams) {
// TODO Auto-generated method stub
return null;
}
@Override
public void setParams(Serializable input) {
// TODO Auto-generated method stub
}
@Override
public String getName() {
// TODO Auto-generated method stub
return null;
}
@Override
public Node getContentNode() {
// TODO Auto-generated method stub
return null;
}
@Override
public void paneInitialized() {
// TODO Auto-generated method stub
}
}

View File

@ -1,5 +1,6 @@
package group3dlocaliser.algorithm.hyperbolic;
import java.awt.Window;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
@ -15,6 +16,7 @@ import Localiser.LocaliserPane;
import Localiser.algorithms.locErrors.SimpleError;
import Localiser.detectionGroupLocaliser.GroupLocResult;
import Localiser.detectionGroupLocaliser.GroupLocalisation;
import PamController.SettingsPane;
import PamDetection.AbstractLocalisation;
import PamDetection.LocContents;
import PamUtils.LatLong;
@ -47,17 +49,24 @@ public class HyperbolicLocaliser extends TOADBaseAlgorithm {
private double[] lastPosVector;
private LocContents locContents = new LocContents(0);
private HyperbolicParams params = new HyperbolicParams();
private HyperbolicParams params = new HyperbolicParams();
private HyperbolicLocaliserPane hyperbolicLocaliserPane;
public HyperbolicLocaliser(Group3DLocaliserControl group3dLocaliser) {
super(group3dLocaliser);
// TODO Auto-generated constructor stub
}
@Override
public AbstractLocalisation processTOADs(PamDataUnit groupDataUnit, SnapshotGeometry geometry, TOADInformation toadInformation) {
/**
* This module is a little odd in that it stores paramters for each algorithm in it's own has table without acc
*/
params = (HyperbolicParams) group3dLocaliser.getLocaliserAlgorithmParams(this).getAlgorithmParameters();
int shape = geometry.getShape();
GroupLocalisation loclaisation = null;
switch (shape) {
@ -907,8 +916,11 @@ public class HyperbolicLocaliser extends TOADBaseAlgorithm {
* @see Localiser.LocaliserModel#getSettingsPane()
*/
@Override
public LocaliserPane<Serializable> getAlgorithmSettingsPane() {
return null;
public LocaliserPane getAlgorithmSettingsPane() {
if (hyperbolicLocaliserPane == null) {
hyperbolicLocaliserPane= new HyperbolicLocaliserPane();
}
return hyperbolicLocaliserPane;
}
/* (non-Javadoc)
@ -928,7 +940,25 @@ public class HyperbolicLocaliser extends TOADBaseAlgorithm {
}
public class HyperbolicLocaliserPane extends LocaliserPane<HyperbolicParams> {
private HyperbolicSettingsPane hyperBolicSettingsPane;
public HyperbolicLocaliserPane() {
hyperBolicSettingsPane = new HyperbolicSettingsPane();
}
@Override
public SettingsPane getSettingsPane() {
return hyperBolicSettingsPane;
}
@Override
public LocaliserAlgorithmParams showAlgorithmDialog(Window awtWindow, LocaliserAlgorithmParams algorithmPaams) {
return null;
}
}

View File

@ -3,7 +3,13 @@ package group3dlocaliser.algorithm.hyperbolic;
import PamController.SettingsPane;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.geometry.Insets;
import pamViewFX.fxNodes.PamBorderPane;
import pamViewFX.fxNodes.PamHBox;
import pamViewFX.fxNodes.PamSpinner;
import pamViewFX.fxNodes.utilityPanes.PamToggleSwitch;
/**
* Hyperbolic settings pane.
@ -13,24 +19,50 @@ import pamViewFX.fxNodes.PamBorderPane;
public class HyperbolicSettingsPane extends SettingsPane<HyperbolicParams> {
PamBorderPane mainPane;
/**
* The toggle switch.
*/
private PamToggleSwitch hyperbolicToggleSwitch;
private PamSpinner<Integer> numIterations;
public HyperbolicSettingsPane() {
super(null);
mainPane = new PamBorderPane();
mainPane.setCenter(new Label("Hello"));
mainPane.setPadding(new Insets(5,5,5,5));
hyperbolicToggleSwitch = new PamToggleSwitch("Calculate errors");
hyperbolicToggleSwitch.selectedProperty().addListener((obsVal, oldVal, newVal)->{
numIterations.setDisable(!hyperbolicToggleSwitch.isSelected());
});
numIterations = new PamSpinner<Integer>(0,1000,100,1);
numIterations.setDisable(!hyperbolicToggleSwitch.isSelected());
numIterations.setEditable(true);
PamHBox hBox = new PamHBox( );
hBox.setSpacing(5);
hBox.getChildren().addAll(hyperbolicToggleSwitch, numIterations, new Label("Iterations"));
mainPane.setTop(hBox);
}
@Override
public HyperbolicParams getParams(HyperbolicParams currParams) {
currParams.bootStrapN = numIterations.getValue();
currParams.calcErrors = hyperbolicToggleSwitch.isSelected();
return currParams;
}
@Override
public void setParams(HyperbolicParams input) {
// TODO Auto-generated method stub
numIterations.getValueFactory().setValue(input.bootStrapN);
hyperbolicToggleSwitch.setSelected(input.calcErrors);
}
@Override

View File

@ -50,7 +50,7 @@ abstract public class TOADBaseAlgorithm extends LocaliserAlgorithm3D {
private TOADBaseParams toadBaseParams = new TOADBaseParams();
private Group3DLocaliserControl group3dLocaliser;
protected Group3DLocaliserControl group3dLocaliser;
private TOADSettingsPaneWithChannels tspwc;

View File

@ -222,23 +222,23 @@ public class GroupLocSettingPaneFX extends SettingsPane<Group3DParams>{
settingsPane = localiserAlgorithm.getAlgorithmSettingsPane().getSettingsPane().getContentNode();
}
//there must be a dialog - otherwise what is the point of a settings pane that does nothing - it should be null.
else {
PamHBox hBox = new PamHBox();
hBox.setSpacing(5);
hBox.setAlignment(Pos.CENTER);
hBox.setPadding(new Insets(5,5,5,5));
PamButton algoOptsButton = new PamButton("",PamGlyphDude.createPamIcon("mdi2c-cog", PamGuiManagerFX.iconSize));
algoOptsButton.setOnAction((action)->{
moreAlgorithmOptions() ;
});
algoOptsButton.setTooltip(new Tooltip("More Algorithm Options ..."));
hBox.getChildren().addAll(new Label(localiserAlgorithm.getName() + " settings"), algoOptsButton);
settingsPane = hBox;
}
// else {
// PamHBox hBox = new PamHBox();
// hBox.setSpacing(5);
// hBox.setAlignment(Pos.CENTER);
// hBox.setPadding(new Insets(5,5,5,5));
//
// PamButton algoOptsButton = new PamButton("",PamGlyphDude.createPamIcon("mdi2c-cog", PamGuiManagerFX.iconSize));
// algoOptsButton.setOnAction((action)->{
// moreAlgorithmOptions() ;
// });
// algoOptsButton.setTooltip(new Tooltip("More Algorithm Options ..."));
//
// hBox.getChildren().addAll(new Label(localiserAlgorithm.getName() + " settings"), algoOptsButton);
//
// settingsPane = hBox;
// }
//
if (newPane==null) {
System.out.println("Set settings pane: " + settingsPane);
@ -287,33 +287,7 @@ public class GroupLocSettingPaneFX extends SettingsPane<Group3DParams>{
BorderPaneFX2AWT.repackSwingDialog(getContentNode());
}
/**
* Handle algorithm options ...
*/
protected void moreAlgorithmOptions() {
String algoName = algorithms.getSelectionModel().getSelectedItem();
if (algoName == null) {
return;
}
LocaliserAlgorithm3D localiserAlgorithm = group3dLocaliserControl.findAlgorithm(algoName);
if (localiserAlgorithm == null) {
return;
}
if (localiserAlgorithm.hasParams() == false) {
return;
}
LocaliserAlgorithmParams algorithmPaams = group3dLocaliserControl.getLocaliserAlgorithmParams(localiserAlgorithm);
algorithmPaams = localiserAlgorithm.getAlgorithmSettingsPane().showAlgorithmDialog(getAWTWindow(), algorithmPaams);
if (algorithmPaams != null) {
group3dLocaliserControl.setAlgorithmParams(localiserAlgorithm, algorithmPaams);
}
}
@Override
@ -344,7 +318,7 @@ public class GroupLocSettingPaneFX extends SettingsPane<Group3DParams>{
currParams.setAlgorithmName(algoName);
//now iterate through all the algorithms and save both the algorithm source settings and the save settings. If the user has changed multiple
//algorithm settings don't want just the current algorithm settings being saved.
//a settings don't want just the current algorithm settings being saved.
for (int i = 0; i< algorithms.getItems().size(); i++ ) {
LocaliserAlgorithm3D algoProvider = group3dLocaliserControl.findAlgorithm(algorithms.getItems().get(i));
@ -483,14 +457,14 @@ public class GroupLocSettingPaneFX extends SettingsPane<Group3DParams>{
LocaliserAlgorithmParams params = currentParams.getAlgorithmParams(algoProvider);
if (algoProvider.getAlgorithmSettingsPane()!=null && algoProvider.getAlgorithmSettingsPane().getSettingsPane()!=null) {
if (params!=null && algoProvider.getAlgorithmSettingsPane()!=null && algoProvider.getAlgorithmSettingsPane().getSettingsPane()!=null) {
algoProvider.getAlgorithmSettingsPane().getSettingsPane().setParams(params.getAlgorithmParameters());
}
if (algoProvider.getSourceSettingsPane(null, currSource)!=null) {
//get the source pane paramters
algoProvider.getSourceSettingsPane(null, currSource).setParams();
}
// if (algoProvider.getSourceSettingsPane(null, null).useParams(params){