Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.1.3
current_version = 0.1.5
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "quickview"
version = "0.1.3"
version = "0.1.5"
description = "An application to explore/analyze data for atmosphere component for E3SM"
authors = [
{name = "Kitware Inc."},
Expand Down
2 changes: 1 addition & 1 deletion quickview/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""QuickView: Visual Analysis for E3SM Atmosphere Data."""

__version__ = "0.1.3"
__version__ = "0.1.5"
__author__ = "Kitware Inc."
__license__ = "Apache-2.0"
91 changes: 58 additions & 33 deletions quickview/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@

# Build color cache here
from quickview.view_manager import build_color_information

from quickview.utilities import EventType

from quickview.view_manager import ViewManager

from paraview.simple import ImportPresets, GetLookupTableNames
Expand Down Expand Up @@ -83,7 +80,6 @@
# Color options from toolbar
"use_cvd_colors",
"use_standard_colors",
"show_color_bar",
# Grid layout
"layout",
]
Expand Down Expand Up @@ -189,6 +185,7 @@ def __init__(
state.varmin = []
state.varmax = []
state.override_range = []
state.colorbar_images = []

ctrl.view_update = self.viewmanager.render_all_views
ctrl.view_reset_camera = self.viewmanager.reset_camera
Expand Down Expand Up @@ -401,6 +398,7 @@ def load_variables(self):
state.varmin = [np.nan] * len(vars)
state.varmax = [np.nan] * len(vars)
state.override_range = [False] * len(vars)
state.colorbar_images = [""] * len(vars) # Initialize empty images

self.viewmanager.rebuild_visualization_layout(self._cached_layout)
# Update cached layout after rebuild
Expand All @@ -418,18 +416,17 @@ def load_variables(self):
"h": item.get("h", 3),
}

def update_view_color_settings(self, index, type, value):
with self.state as state:
if type == EventType.COL.value:
state.varcolor[index] = value
state.dirty("varcolor")
elif type == EventType.LOG.value:
state.uselogscale[index] = value
state.dirty("uselogscale")
elif type == EventType.INV.value:
state.invert[index] = value
state.dirty("invert")
self.viewmanager.update_view_color_settings(index, type, value)
def update_colormap(self, index, value):
"""Update the colormap for a variable."""
self.viewmanager.update_colormap(index, value)

def update_log_scale(self, index, value):
"""Update the log scale setting for a variable."""
self.viewmanager.update_log_scale(index, value)

def update_invert_colors(self, index, value):
"""Update the color inversion setting for a variable."""
self.viewmanager.update_invert_colors(index, value)

def update_scalar_bars(self, event):
self.viewmanager.update_scalar_bars(event)
Expand All @@ -448,16 +445,11 @@ def update_available_color_maps(self):
state.colormaps = noncvd

def set_manual_color_range(self, index, type, value):
with self.state as state:
if type.lower() == "min":
state.varmin[index] = value
state.dirty("varmin")
elif type.lower() == "max":
state.varmax[index] = value
state.dirty("varmax")
self.viewmanager.set_manual_color_range(
index, state.varmin[index], state.varmax[index]
)
# Get current values from state to handle min/max independently
min_val = self.state.varmin[index] if type.lower() == "max" else value
max_val = self.state.varmax[index] if type.lower() == "min" else value
# Delegate to view manager which will update both the view and sync state
self.viewmanager.set_manual_color_range(index, min_val, max_val)

def revert_to_auto_color_range(self, index):
self.viewmanager.revert_to_auto_color_range(index)
Expand Down Expand Up @@ -606,7 +598,6 @@ def ui(self) -> SinglePageWithDrawerLayout:
load_state=self.load_state,
load_variables=self.load_variables,
update_available_color_maps=self.update_available_color_maps,
update_scalar_bars=self.update_scalar_bars,
generate_state=self.generate_state,
)

Expand Down Expand Up @@ -695,9 +686,10 @@ def ui(self) -> SinglePageWithDrawerLayout:
style="height: calc(100% - 0.66rem); position: relative;",
classes="pa-0",
) as cardcontent:
# VTK View takes up most of the space
cardcontent.add_child(
"""
<vtk-remote-view :ref="(el) => ($refs[vref] = el)" :viewId="get(`${vref}Id`)" class="pa-0 drag-ignore" style="width: 100%; height: 100%;" interactiveRatio="1" >
<vtk-remote-view :ref="(el) => ($refs[vref] = el)" :viewId="get(`${vref}Id`)" class="pa-0 drag-ignore" style="width: 100%; height: calc(100% - 30px);" interactiveRatio="1" >
</vtk-remote-view>
""",
)
Expand All @@ -719,17 +711,50 @@ def ui(self) -> SinglePageWithDrawerLayout:
# height: $refs[vref].vtkContainer.getBoundingClientRect().height}]
# ''')
)
# Mask to prevent VTK view from getting scroll/mouse events
html.Div(
style="position:absolute; top: 0; left: 0; width: 100%; height: calc(100% - 0.66rem); z-index: 1;"
style="position:absolute; top: 0; left: 0; width: 100%; height: calc(100% - 30px); z-index: 1;"
)
# with v2.VCardActions(classes="pa-0"):
# View Properties
with html.Div(
style="position:absolute; bottom: 1rem; left: 1rem; height: 2rem; z-index: 2;"
style="position:absolute; bottom: 40px; left: 1rem; height: 2rem; z-index: 2;"
):
ViewProperties(
apply=self.update_view_color_settings,
update=self.set_manual_color_range,
update_colormap=self.update_colormap,
update_log_scale=self.update_log_scale,
update_invert=self.update_invert_colors,
update_range=self.set_manual_color_range,
reset=self.revert_to_auto_color_range,
)

# Colorbar container (horizontal layout at bottom)
with html.Div(
style="position: absolute; bottom: 0; left: 0; right: 0; display: flex; align-items: center; padding: 4px 12px; background-color: rgba(255, 255, 255, 0.9); height: 30px; z-index: 3; overflow: visible;",
classes="drag-ignore",
):
# Color min value
html.Span(
"{{ varmin[idx] !== null && !isNaN(varmin[idx]) ? (uselogscale[idx] && varmin[idx] > 0 ? 'log₁₀(' + Math.log10(varmin[idx]).toFixed(3) + ')' : varmin[idx].toFixed(3)) : 'Auto' }}",
style="font-size: 12px; color: #333; white-space: nowrap;",
)
# Colorbar
with html.Div(
style="flex: 1; position: relative; margin: 0 12px; height: 0.75rem;",
classes="drag-ignore",
):
# Colorbar image
html.Img(
src=(
"colorbar_images[idx] || 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg=='",
None,
),
style="height: 100%; width: 100%; object-fit: fill;",
classes="rounded-lg border-thin",
)
# Color max value
html.Span(
"{{ varmax[idx] !== null && !isNaN(varmax[idx]) ? (uselogscale[idx] && varmax[idx] > 0 ? 'log₁₀(' + Math.log10(varmax[idx]).toFixed(3) + ')' : varmax[idx].toFixed(3)) : 'Auto' }}",
style="font-size: 12px; color: #333; white-space: nowrap;",
)

return self._ui
48 changes: 15 additions & 33 deletions quickview/ui/toolbar.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
from trame.decorators import TrameApp, task
from trame.widgets import html, vuetify2 as v2, tauri
from trame.widgets import html, vuetify2 as v2

try:
from trame.widgets import tauri
except ImportError:
# Fallback if tauri is not available
tauri = None

import json

Expand Down Expand Up @@ -71,13 +77,6 @@ def _update_color_maps(self):
# Directly call update_available_color_maps without parameters
self._update_available_color_maps()

def _handle_color_bar_toggle(self):
"""Toggle the color bar visibility"""
with self.state:
self.state.show_color_bar = not self.state.show_color_bar
if self._update_scalar_bars is not None:
self._update_scalar_bars(self.state.show_color_bar)

def __init__(
self,
layout_toolbar,
Expand All @@ -86,32 +85,30 @@ def __init__(
load_state=None,
load_variables=None,
update_available_color_maps=None,
update_scalar_bars=None,
generate_state=None,
**kwargs,
):
self.server = server
with tauri.Dialog() as dialog:
self.ctrl.open = dialog.open
self.ctrl.save = dialog.save
if tauri:
with tauri.Dialog() as dialog:
self.ctrl.open = dialog.open
self.ctrl.save = dialog.save
else:
# Fallback for non-tauri environments
self.ctrl.open = lambda title: None
self.ctrl.save = lambda title: None
self._generate_state = generate_state
self._load_state = load_state
self._update_available_color_maps = update_available_color_maps
self._update_scalar_bars = update_scalar_bars

# Initialize toggle states
with self.state:
self.state.use_cvd_colors = False
self.state.use_standard_colors = True
self.state.show_color_bar = True

# Set initial color maps based on default toggle states
self._update_color_maps()

# Apply initial scalar bar visibility
if self._update_scalar_bars is not None:
self._update_scalar_bars(True)

with layout_toolbar as toolbar:
toolbar.density = "compact"
toolbar.style = "overflow-x: auto; overflow-y: hidden;"
Expand Down Expand Up @@ -162,21 +159,6 @@ def __init__(
):
v2.VIcon("mdi-palette")
html.Span("Standard colors")
v2.VDivider(vertical=True, classes="mx-2", style="height: 24px;")
with v2.VTooltip(bottom=True):
with html.Template(v_slot_activator="{ on, attrs }"):
with v2.VBtn(
icon=True,
dense=True,
small=True,
v_bind="attrs",
v_on="on",
click=self._handle_color_bar_toggle,
color=("show_color_bar ? 'primary' : ''",),
classes="mx-1",
):
v2.VIcon("mdi-format-color-fill")
html.Span("Show color bar")
v2.VDivider(vertical=True, classes="mx-2")
with v2.VCard(
flat=True,
Expand Down
28 changes: 17 additions & 11 deletions quickview/ui/view_settings.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
from trame.widgets import vuetify2 as v2, html
from trame.decorators import TrameApp

from quickview.utilities import EventType


@TrameApp()
class ViewProperties(v2.VMenu):
def __init__(self, apply=None, update=None, reset=None, **kwargs):
def __init__(
self,
update_colormap=None,
update_log_scale=None,
update_invert=None,
update_range=None,
reset=None,
**kwargs,
):
super().__init__(
transition="slide-y-transition",
close_on_content_click=False,
Expand Down Expand Up @@ -37,8 +43,8 @@ def __init__(self, apply=None, update=None, reset=None, **kwargs):
items=("colormaps",),
outlined=True,
change=(
apply,
f"[idx, {EventType.COL.value}, $event]",
update_colormap,
"[idx, $event]",
),
**style,
)
Expand All @@ -49,8 +55,8 @@ def __init__(self, apply=None, update=None, reset=None, **kwargs):
label="Log Scale",
v_model=("uselogscale[idx]",),
change=(
apply,
f"[idx, {EventType.LOG.value}, $event]",
update_log_scale,
"[idx, $event]",
),
**style,
)
Expand All @@ -59,8 +65,8 @@ def __init__(self, apply=None, update=None, reset=None, **kwargs):
label="Revert Colors",
v_model=("invert[idx]",),
change=(
apply,
f"[idx, {EventType.INV.value}, $event]",
update_invert,
"[idx, $event]",
),
**style,
)
Expand All @@ -82,7 +88,7 @@ def __init__(self, apply=None, update=None, reset=None, **kwargs):
label="min",
outlined=True,
change=(
update,
update_range,
"[idx, 'min', $event]",
),
style="height=50px",
Expand All @@ -95,7 +101,7 @@ def __init__(self, apply=None, update=None, reset=None, **kwargs):
label="max",
outlined=True,
change=(
update,
update_range,
"[idx, 'max', $event]",
),
style="height=50px",
Expand Down
Loading
Loading