Skip to content

Commit

Permalink
Fix gridviewer
Browse files Browse the repository at this point in the history
  • Loading branch information
HansKallekleiv committed Feb 13, 2023
1 parent 2139b30 commit a09d129
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from dash import Input, Output, State, callback, html, no_update
from webviz_config.utils import StrEnum
from webviz_config.webviz_plugin_subclasses import ViewABC

import webviz_subsurface_components as wsc
from webviz_subsurface._providers.ensemble_grid_provider import (
CellFilter,
EnsembleGridProvider,
Expand Down Expand Up @@ -127,7 +127,6 @@ def _set_geometry_and_scalar(
layers: List[Dict],
bounds: Optional[List[float]],
) -> Tuple[List[Dict], Optional[List]]:

if PROPERTYTYPE(proptype) == PROPERTYTYPE.STATIC:
property_spec = PropertySpec(prop_name=prop[0], prop_date=None)
else:
Expand Down Expand Up @@ -192,9 +191,9 @@ def _set_geometry_and_scalar(
else:
value_range = None

layers[1]["pointsUrl"] = f"/grid/points/{geometry_token}"
layers[1]["polysUrl"] = f"/grid/polys/{geometry_token}"
layers[1]["propertiesUrl"] = f"/grid/scalar/{geometry_and_property_token}"
layers[1]["pointsData"] = f"/grid/points/{geometry_token}"
layers[1]["polysData"] = f"/grid/polys/{geometry_token}"
layers[1]["propertiesData"] = f"/grid/scalar/{geometry_and_property_token}"
layers[1]["colorMapRange"] = value_range
layers[1]["colorMapName"] = colormap
return layers, bounds
Expand All @@ -214,13 +213,16 @@ def _set_geometry_and_scalar(
),
)
def _toggle_manual_color(enabled: List[str]) -> Tuple[bool, bool]:

if enabled:
return False, False
return True, True

@callback(
Output(self._view_id(VTKView3D.Ids.INFOBOX), "children"),
Output(
self._view_id(VTKView3D.Ids.VIEW),
"children",
),
Input(
self._data_settings_id(DataSettings.Ids.PROPERTIES),
"value",
Expand All @@ -238,6 +240,10 @@ def _toggle_manual_color(enabled: List[str]) -> Tuple[bool, bool]:
"layers",
),
Input(self.get_store_unique_id(ElementIds.IJK_CROP_STORE), "data"),
Input(
self._color_scale_id(ColorScale.Ids.COLORMAP),
"value",
),
State(
self._data_settings_id(DataSettings.Ids.STATIC_DYNAMIC),
"value",
Expand All @@ -249,6 +255,7 @@ def update_infobox(
realizations: List[int],
layers: List[dict],
grid_range: List[List[int]],
colormap: str,
proptype: str,
) -> list:
"""Updates the information box with information on the visualized data."""
Expand Down Expand Up @@ -286,7 +293,22 @@ def update_infobox(
color_range = layers[1].get("colorMapRange")
if color_range is None:
color_range = actual_value_range

children = [
wsc.ViewAnnotation(
id=f"view_1",
children=[
wsc.WebVizColorLegend(
min=color_range[0],
max=color_range[1],
colorName=colormap,
cssLegendStyles={"top": "0", "right": "0"},
openColorSelector=False,
legendScaleSize=0.1,
legendFontSize=30,
),
],
)
]
return [
html.Div([html.B("Property: "), html.Label(properties[0])]),
html.Div(
Expand All @@ -307,4 +329,4 @@ def update_infobox(
),
]
),
]
], children
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from dash.development.base_component import Component
from webviz_config.utils import StrEnum
from webviz_config.webviz_plugin_subclasses import ViewElementABC
from webviz_subsurface_components import DeckGLMap
from webviz_subsurface_components import DashSubsurfaceViewer


class VTKView3D(ViewElementABC):
Expand All @@ -17,7 +17,6 @@ def __init__(self) -> None:
super().__init__()

def inner_layout(self) -> Component:

return html.Div(
style={"position": "relative", "height": "90vh"},
children=[
Expand Down Expand Up @@ -46,7 +45,7 @@ def inner_layout(self) -> Component:
html.Div(
style={"position": "absolute", "width": "100%", "height": "90%"},
children=[
DeckGLMap(
DashSubsurfaceViewer(
id=self.register_component_unique_id(VTKView3D.Ids.VIEW),
layers=[
{
Expand All @@ -65,11 +64,7 @@ def inner_layout(self) -> Component:
"@@type": "Grid3DLayer",
"id": "Grid3DLayer",
"material": True,
"colorMapName": "Physics reverse",
"scaleZ": 1,
"pointsUrl": "/grid/points/test",
"polysUrl": "/grid/polys/test",
"propertiesUrl": "/grid/scalar/test",
},
],
views={
Expand Down

0 comments on commit a09d129

Please sign in to comment.