From c8902bbe102e7a4f292499e81c8242237cd20dd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20L=C3=B6sler?= Date: Sun, 5 Jan 2025 19:11:24 +0100 Subject: [PATCH] Layer visible state (#544) - event handling of (global) layer(s) visible state corrected - version number increased v20250105 --- .../layer/dialog/LayerManagerDialog.java | 73 +++++++++++-------- .../version/jag3d/Version.java | 2 +- 2 files changed, 43 insertions(+), 32 deletions(-) diff --git a/JAG3D/src/org/applied_geodesy/jag3d/ui/graphic/layer/dialog/LayerManagerDialog.java b/JAG3D/src/org/applied_geodesy/jag3d/ui/graphic/layer/dialog/LayerManagerDialog.java index 228bf10e..79bb5b83 100644 --- a/JAG3D/src/org/applied_geodesy/jag3d/ui/graphic/layer/dialog/LayerManagerDialog.java +++ b/JAG3D/src/org/applied_geodesy/jag3d/ui/graphic/layer/dialog/LayerManagerDialog.java @@ -83,11 +83,16 @@ public LayersVisibleChangeListener(CheckBox checkBox, Set layerSet) { @Override public void changed(ObservableValue observable, Boolean oldValue, Boolean newValue) { + if (!ignoreVisibleEvent) + updateLayerVisibleState(newValue); + } + + private void updateLayerVisibleState(boolean select) { try { ignoreVisibleEvent = true; for (Layer layer : layerSet) - layer.setVisible(newValue); - this.checkBox.setSelected(newValue); + layer.setVisible(select); + this.checkBox.setSelected(select); } finally { ignoreVisibleEvent = false; @@ -458,36 +463,42 @@ private void save() { } private void updateGlobalLayerVisibleState(LayerType type) { - int numberOfVisibleLayers = 0; - switch (type) { - case NEW_POINT_APRIORI: - case DATUM_POINT_APRIORI: - case STOCHASTIC_POINT_APRIORI: - case REFERENCE_POINT_APRIORI: - case OBSERVATION_APRIORI: - for (Layer layer : this.aPrioriLayerSet) { - if (layer.isVisible()) - numberOfVisibleLayers++; - } - this.allAprioriLayersVisibleCheckBox.setSelected(this.aPrioriLayerSet.size() == numberOfVisibleLayers); - this.allAprioriLayersVisibleCheckBox.setIndeterminate(numberOfVisibleLayers > 0 && numberOfVisibleLayers < this.aPrioriLayerSet.size()); - - break; - case NEW_POINT_APOSTERIORI: - case DATUM_POINT_APOSTERIORI: - case STOCHASTIC_POINT_APOSTERIORI: - case REFERENCE_POINT_APOSTERIORI: - case OBSERVATION_APOSTERIORI: - for (Layer layer : this.aPosterioriLayerSet) { - if (layer.isVisible()) - numberOfVisibleLayers++; - } - this.allAPosterioriLayersVisibleCheckBox.setSelected(this.aPosterioriLayerSet.size() == numberOfVisibleLayers); - this.allAPosterioriLayersVisibleCheckBox.setIndeterminate(numberOfVisibleLayers > 0 && numberOfVisibleLayers < this.aPosterioriLayerSet.size()); + try { + this.ignoreVisibleEvent = true; + int numberOfVisibleLayers = 0; + switch (type) { + case NEW_POINT_APRIORI: + case DATUM_POINT_APRIORI: + case STOCHASTIC_POINT_APRIORI: + case REFERENCE_POINT_APRIORI: + case OBSERVATION_APRIORI: + for (Layer layer : this.aPrioriLayerSet) { + if (layer.isVisible()) + numberOfVisibleLayers++; + } + this.allAprioriLayersVisibleCheckBox.setSelected(this.aPrioriLayerSet.size() == numberOfVisibleLayers); + this.allAprioriLayersVisibleCheckBox.setIndeterminate(numberOfVisibleLayers > 0 && numberOfVisibleLayers < this.aPrioriLayerSet.size()); - break; - default: - break; + break; + case NEW_POINT_APOSTERIORI: + case DATUM_POINT_APOSTERIORI: + case STOCHASTIC_POINT_APOSTERIORI: + case REFERENCE_POINT_APOSTERIORI: + case OBSERVATION_APOSTERIORI: + for (Layer layer : this.aPosterioriLayerSet) { + if (layer.isVisible()) + numberOfVisibleLayers++; + } + this.allAPosterioriLayersVisibleCheckBox.setSelected(this.aPosterioriLayerSet.size() == numberOfVisibleLayers); + this.allAPosterioriLayersVisibleCheckBox.setIndeterminate(numberOfVisibleLayers > 0 && numberOfVisibleLayers < this.aPosterioriLayerSet.size()); + + break; + default: + break; + } + } + finally { + this.ignoreVisibleEvent = false; } } diff --git a/JAG3D/src/org/applied_geodesy/version/jag3d/Version.java b/JAG3D/src/org/applied_geodesy/version/jag3d/Version.java index 12401dd4..f73c75bd 100644 --- a/JAG3D/src/org/applied_geodesy/version/jag3d/Version.java +++ b/JAG3D/src/org/applied_geodesy/version/jag3d/Version.java @@ -29,7 +29,7 @@ public class Version { private final static Map versions = Map.of( VersionType.ADJUSTMENT_CORE, 20231208, VersionType.DATABASE, 20240417, - VersionType.USER_INTERFACE, 20250102 + VersionType.USER_INTERFACE, 20250105 ); private Version() {}