Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to set animation class settings #1048

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified icons/icon_custom_statistics.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions icons/sliders.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions threedi_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def initGui(self):
self.model.result_checked.connect(self.map_animator.results_changed)
self.model.result_unchecked.connect(self.map_animator.results_changed)
self.model.result_added.connect(self.map_animator.results_changed)
self.model.result_removed.connect(self.map_animator.results_changed)
self.temporal_manager.updated.connect(self.map_animator.update_results)

# flow summary signals
Expand Down Expand Up @@ -237,6 +238,10 @@ def write(self, doc: QDomDocument) -> bool:
if not tool.write(doc, node):
return False

# Also allow animator to persist settings
if not self.map_animator.write(doc, node):
return False

return True

def write_map_layer(self, layer: QgsMapLayer, elem: QDomElement, _: QDomDocument):
Expand All @@ -263,6 +268,11 @@ def read(self, doc: QDomDocument) -> bool:
self.model.clear()
return False

# Also allow animator to read saved settings
if not self.map_animator.read(tool_node):
self.model.clear()
return False

return True

def unload(self):
Expand Down
19 changes: 8 additions & 11 deletions tool_animation/animation_styler.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
from pathlib import Path
from typing import List
import logging

import numpy as np

from qgis.core import QgsFeatureRequest
from qgis.core import QgsMarkerSymbol
from qgis.core import QgsProperty
from qgis.core import QgsSymbolLayer
from qgis.core import QgsVectorLayer
from qgis.utils import iface

from threedi_results_analysis.datasource.result_constants import WET_CROSS_SECTION_AREA
from threedi_results_analysis.utils.color import color_ramp_from_data
from threedi_results_analysis.utils.color import COLOR_RAMP_OCEAN_CURL
from threedi_results_analysis.utils.color import COLOR_RAMP_OCEAN_DEEP
from threedi_results_analysis.utils.color import COLOR_RAMP_OCEAN_HALINE
from threedi_results_analysis.utils.color import color_ramp_from_data
from typing import List

import logging
import numpy as np


STYLES_ROOT = Path(__file__).parent / "layer_styles"
ANIMATION_LAYERS_NR_LEGEND_CLASSES = 24
assert ANIMATION_LAYERS_NR_LEGEND_CLASSES % 2 == 0
DEFAULT_LOWER_THRESHOLD = 1e-6

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -174,7 +171,7 @@ def style_animation_node_current(


def style_animation_node_difference(
lyr: QgsVectorLayer, percentiles: List[float], variable: str, cells: bool, field_postfix=""
lyr: QgsVectorLayer, percentiles: List[float], variable: str, cells: bool, nr_of_classes, field_postfix=""
):
"""Applies styling to Animation Toolbar node layer in 'difference' mode"""

Expand All @@ -201,7 +198,7 @@ def style_animation_node_difference(
stop=abs_high,
step=(
(abs_high - abs_high * -1)
/ (ANIMATION_LAYERS_NR_LEGEND_CLASSES - 2)
/ (nr_of_classes - 2)
),
)
)
Expand Down
Loading
Loading