From 132f3bb332bf2d150951f76b9e752a4b089e8822 Mon Sep 17 00:00:00 2001 From: Nicolas Roduit Date: Fri, 13 Sep 2024 10:50:54 +0200 Subject: [PATCH] MPR preferences are not persistent #589 --- .../core/ui/editor/image/DefaultView2d.java | 8 ------ .../weasis/dicom/viewer2d/EventManager.java | 10 +++++++ .../dicom/viewer2d/mpr/pref/MprPrefView.java | 27 ++++++++++--------- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/weasis-core/src/main/java/org/weasis/core/ui/editor/image/DefaultView2d.java b/weasis-core/src/main/java/org/weasis/core/ui/editor/image/DefaultView2d.java index 29ba0d47a..dbda4530b 100755 --- a/weasis-core/src/main/java/org/weasis/core/ui/editor/image/DefaultView2d.java +++ b/weasis-core/src/main/java/org/weasis/core/ui/editor/image/DefaultView2d.java @@ -933,14 +933,6 @@ public void propertyChange(SynchCineEvent synch) { } } else { double location = synch.getLocation().doubleValue(); - // TODO add a way in GUI to resynchronize series. Offset should be in Series tag and - // related - // to - // a specific series - // Double offset = (Double) actionsInView.get(ActionW.STACK_OFFSET.cmd()); - // if (offset != null) { - // location += offset; - // } imgElement = series.getNearestImage( location, diff --git a/weasis-dicom/weasis-dicom-viewer2d/src/main/java/org/weasis/dicom/viewer2d/EventManager.java b/weasis-dicom/weasis-dicom-viewer2d/src/main/java/org/weasis/dicom/viewer2d/EventManager.java index 66d3d6b19..ef29def3d 100755 --- a/weasis-dicom/weasis-dicom-viewer2d/src/main/java/org/weasis/dicom/viewer2d/EventManager.java +++ b/weasis-dicom/weasis-dicom-viewer2d/src/main/java/org/weasis/dicom/viewer2d/EventManager.java @@ -223,6 +223,9 @@ private EventManager() { options, WindowOp.P_APPLY_WL_COLOR, prefNode, Boolean.TRUE.toString()); WProperties.setProperty(options, WindowOp.P_INVERSE_LEVEL, prefNode, Boolean.TRUE.toString()); WProperties.setProperty(options, PRManager.PR_APPLY, prefNode, Boolean.FALSE.toString()); + + WProperties.setProperty(options, View2d.P_CROSSHAIR_MODE, prefNode, "1"); + WProperties.setProperty(options, View2d.P_CROSSHAIR_CENTER_GAP, prefNode, "40"); } initializeParameters(); @@ -1440,6 +1443,13 @@ public void savePreferences(BundleContext bundleContext) { BundlePreferences.putBooleanPreferences( prefNode, PRManager.PR_APPLY, options.getBooleanProperty(PRManager.PR_APPLY, false)); + BundlePreferences.putIntPreferences( + prefNode, View2d.P_CROSSHAIR_MODE, options.getIntProperty(View2d.P_CROSSHAIR_MODE, 1)); + BundlePreferences.putIntPreferences( + prefNode, + View2d.P_CROSSHAIR_CENTER_GAP, + options.getIntProperty(View2d.P_CROSSHAIR_CENTER_GAP, 40)); + Preferences containerNode = prefs.node(View2dContainer.UI.clazz.getSimpleName().toLowerCase()); InsertableUtil.savePreferences(View2dContainer.UI.toolBars, containerNode, Type.TOOLBAR); diff --git a/weasis-dicom/weasis-dicom-viewer2d/src/main/java/org/weasis/dicom/viewer2d/mpr/pref/MprPrefView.java b/weasis-dicom/weasis-dicom-viewer2d/src/main/java/org/weasis/dicom/viewer2d/mpr/pref/MprPrefView.java index fb634fcef..3cefd5eec 100755 --- a/weasis-dicom/weasis-dicom-viewer2d/src/main/java/org/weasis/dicom/viewer2d/mpr/pref/MprPrefView.java +++ b/weasis-dicom/weasis-dicom-viewer2d/src/main/java/org/weasis/dicom/viewer2d/mpr/pref/MprPrefView.java @@ -108,29 +108,30 @@ private void setDefaultLayout() { @Override public void closeAdditionalWindow() { - EventManager eventManager = EventManager.getInstance(); + WProperties properties = EventManager.getInstance().getOptions(); int mode = comboBox3DCursorMode.getSelectedIndex(); - eventManager.getOptions().putIntProperty(View2d.P_CROSSHAIR_MODE, mode); + properties.putIntProperty(View2d.P_CROSSHAIR_MODE, mode); int gapSize = (int) spinnerCrossGapSize.getValue(); - eventManager.getOptions().putIntProperty(View2d.P_CROSSHAIR_CENTER_GAP, gapSize); - GuiUtils.getUICore() - .getSystemPreferences() - .put( - MprFactory.P_DEFAULT_LAYOUT, - ((GridBagLayoutModel) comboBoxLayouts.getSelectedItem()).getId()); - + properties.putIntProperty(View2d.P_CROSSHAIR_CENTER_GAP, gapSize); + GridBagLayoutModel layout = (GridBagLayoutModel) comboBoxLayouts.getSelectedItem(); + if (layout != null) { + GuiUtils.getUICore().getSystemPreferences().put(MprFactory.P_DEFAULT_LAYOUT, layout.getId()); + } GuiUtils.getUICore().saveSystemPreferences(); } @Override public void resetToDefaultValues() { - - comboBox3DCursorMode.setSelectedIndex(1); - // Get the default server configuration and if no value take the default value in parameter. WProperties properties = EventManager.getInstance().getOptions(); - properties.resetProperty(View2d.P_CROSSHAIR_CENTER_GAP, null); + properties.resetProperty(View2d.P_CROSSHAIR_MODE, "1"); + int mode = properties.getIntProperty(View2d.P_CROSSHAIR_MODE, 1); + comboBox3DCursorMode.setSelectedIndex(mode); + if (comboBox3DCursorMode.getSelectedIndex() < 0) { + comboBox3DCursorMode.setSelectedItem(1); + } + properties.resetProperty(View2d.P_CROSSHAIR_CENTER_GAP, "40"); int gapSize = properties.getIntProperty(View2d.P_CROSSHAIR_CENTER_GAP, 40); spinnerCrossGapSize.setValue(gapSize); GuiUtils.getUICore()