From 85ae261a4c40855be03773dc2ec332954c9a3a9d Mon Sep 17 00:00:00 2001 From: Jamie Mac Date: Mon, 22 Apr 2024 10:49:59 +0100 Subject: [PATCH] Bug fix fro Group loclaiser Stopped channel error dialog showing for all algorithms --- .classpath | 3 +-- .gitignore | 1 + src/group3dlocaliser/ToadManagedSettingsPane.java | 10 ++++++++++ .../toadbase/TOADSettingsPaneWithChannels.java | 14 +++++++++++++- .../dialog/GroupLocSettingPaneFX.java | 13 +++++++++++-- 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/.classpath b/.classpath index 576b210a..924124d8 100644 --- a/.classpath +++ b/.classpath @@ -6,9 +6,8 @@ - + - diff --git a/.gitignore b/.gitignore index b916a1cd..e14af36b 100644 --- a/.gitignore +++ b/.gitignore @@ -107,3 +107,4 @@ settings.xml .classpath .classpath .classpath +.classpath diff --git a/src/group3dlocaliser/ToadManagedSettingsPane.java b/src/group3dlocaliser/ToadManagedSettingsPane.java index d3f9e0a6..53f39b14 100644 --- a/src/group3dlocaliser/ToadManagedSettingsPane.java +++ b/src/group3dlocaliser/ToadManagedSettingsPane.java @@ -10,4 +10,14 @@ public abstract class ToadManagedSettingsPane extends ManagedSettingsPane{ * @return the main tab pane. */ public abstract TabPane getTabPane(); + + /** + * Set whether the pane should show errors. Because there are multiple algorithms that + * will use this pane we do not want to warn for every algorithm only the user selected one. + * @param warn = true to warn errors e.g. show an dialog - false and there are no error warnings. + */ + public abstract void setErrorWarn(boolean warn); + + + } diff --git a/src/group3dlocaliser/algorithm/toadbase/TOADSettingsPaneWithChannels.java b/src/group3dlocaliser/algorithm/toadbase/TOADSettingsPaneWithChannels.java index 949a626c..d3ef1a02 100644 --- a/src/group3dlocaliser/algorithm/toadbase/TOADSettingsPaneWithChannels.java +++ b/src/group3dlocaliser/algorithm/toadbase/TOADSettingsPaneWithChannels.java @@ -34,6 +34,8 @@ public class TOADSettingsPaneWithChannels extends ToadManagedSettingsPane private Object parent; private TOADOptionsPane toadOptionsPane; + private boolean warnError = true; + public TOADSettingsPaneWithChannels(Object parent, TOADBaseAlgorithm toadBaseAlgorithm, ManagedSettingsPane toadSettingsPane) { this.parent = parent; @@ -54,7 +56,11 @@ public class TOADSettingsPaneWithChannels extends ToadManagedSettingsPane int chMap = channelPanel.getChannelMap(); toadBaseAlgorithm.getToadBaseParams().setChannelBitmap(chMap); int nSelChannels = PamUtils.getNumChannels(chMap); - if (nSelChannels < 3) { + if (nSelChannels < 3 && warnError) { + /** + * TODO - This is a nasty way of doing this. There should be a validator in this pane which is checked before getParams is called ] + * but that would require a lot of restructuring. + */ return SwingFXDialogWarning.showWarning(parent, "Channel selection", "Not enough channels selected"); } TOADBaseParams ans = toadOptionsPane.getParams(toadBaseAlgorithm.getToadBaseParams()); @@ -138,4 +144,10 @@ public class TOADSettingsPaneWithChannels extends ToadManagedSettingsPane public ChannelPanelFX getChannelPanel() { return channelPanel; } + + @Override + public void setErrorWarn(boolean warn) { + this.warnError = warn; + + } } diff --git a/src/group3dlocaliser/dialog/GroupLocSettingPaneFX.java b/src/group3dlocaliser/dialog/GroupLocSettingPaneFX.java index 09bb3ec2..af0872a7 100644 --- a/src/group3dlocaliser/dialog/GroupLocSettingPaneFX.java +++ b/src/group3dlocaliser/dialog/GroupLocSettingPaneFX.java @@ -338,7 +338,16 @@ public class GroupLocSettingPaneFX extends SettingsPane{ if (algoProvider.getSourceSettingsPane(null, currSource)!=null) { - //get the source pane paramters + //set only the selected algorithm to show the user warning sif settings are wrong + if (algorithms.getSelectionModel().getSelectedIndex()==i) { + //this is the currently selected algorithm + algoProvider.getSourceSettingsPane(null, currSource).setErrorWarn(true); + } + else { + algoProvider.getSourceSettingsPane(null, currSource).setErrorWarn(false); + } + + //get the source pane paramters. Serializable newSourceParams = algoProvider.getSourceSettingsPane(null, currSource).getParams(); if (locAlgorithmParams==null) locAlgorithmParams = new LocaliserAlgorithmParams(); @@ -350,7 +359,7 @@ public class GroupLocSettingPaneFX extends SettingsPane{ currParams.setAlgorithmParams(algoProvider, locAlgorithmParams); - System.out.println("Get params" + algoProvider.getName() + " " + currParams.getAlgorithmParams(algoProvider)); + //System.out.println("Get params" + algoProvider.getName() + " " + currParams.getAlgorithmParams(algoProvider)); }