Skip to content

Commit c3d92ee

Browse files
author
Xing Han Lu
authored
Merge pull request #554 from plotly/improve-vtk-explorer
Improve vtk explorer Former-commit-id: 784dc96
2 parents 02cd473 + 3184efe commit c3d92ee

9 files changed

Lines changed: 178 additions & 197 deletions

File tree

apps/dash-vtk-explorer/demos/pyvista-point-cloud/app.py

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import dash
22
import dash_vtk
3-
import dash_bootstrap_components as dbc
43
import dash_html_components as html
54
import dash_core_components as dcc
65
from dash.dependencies import Input, Output, State
@@ -11,7 +10,7 @@
1110

1211
# Get point cloud data from PyVista
1312
dataset = examples.download_lidar()
14-
subset = 0.5
13+
subset = 0.2
1514
selection = np.random.randint(
1615
low=0, high=dataset.n_points - 1, size=int(dataset.n_points * subset)
1716
)
@@ -24,7 +23,7 @@
2423
print(f"Elevation range: [{min_elevation}, {max_elevation}]")
2524

2625
# Setup VTK rendering of PointCloud
27-
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
26+
app = dash.Dash(__name__)
2827
server = app.server
2928

3029
vtk_view = dash_vtk.View(
@@ -38,25 +37,9 @@
3837
]
3938
)
4039

41-
app.layout = dbc.Container(
42-
fluid=True,
43-
children=[
44-
html.H1("Demo of dash_vtk.PointCloudRepresentation"),
45-
html.Hr(),
46-
dbc.Row(
47-
[
48-
dbc.Col(
49-
width=12,
50-
children=[
51-
html.Div(
52-
vtk_view,
53-
style={"height": "calc(80vh - 20px)", "width": "100%"},
54-
)
55-
],
56-
),
57-
]
58-
),
59-
],
40+
app.layout = html.Div(
41+
style={"height": "calc(100vh - 16px)"},
42+
children=[html.Div(vtk_view, style={"height": "100%", "width": "100%"})],
6043
)
6144

6245
if __name__ == "__main__":
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# If you skipped `pip install -e ../../`, the package below will be retrieved from pypi:
22
dash-vtk
3-
dash-bootstrap-components
43
pyvista
54
numpy

apps/dash-vtk-explorer/demos/pyvista-terrain-following-mesh/app.py

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -75,48 +75,33 @@ def updateWarp(factor=1):
7575

7676
app.layout = dbc.Container(
7777
fluid=True,
78+
style={"height": "100vh"},
7879
children=[
7980
dbc.Row(
8081
[
81-
dbc.Col(width=6, children=[html.H1("Terrain deformation"),]),
8282
dbc.Col(
83-
width=3,
84-
children=[
85-
dcc.Slider(
86-
id="scale-factor",
87-
min=0.1,
88-
max=5,
89-
step=0.1,
90-
value=1,
91-
marks={0.1: "0.1", 5: "5"},
92-
),
93-
],
83+
children=dcc.Slider(
84+
id="scale-factor",
85+
min=0.1,
86+
max=5,
87+
step=0.1,
88+
value=1,
89+
marks={0.1: "0.1", 5: "5"},
90+
)
9491
),
9592
dbc.Col(
96-
width=3,
97-
children=[
98-
dcc.Dropdown(
99-
id="dropdown-preset",
100-
options=list(map(toDropOption, presets)),
101-
value="erdc_rainbow_bright",
102-
),
103-
],
93+
children=dcc.Dropdown(
94+
id="dropdown-preset",
95+
options=list(map(toDropOption, presets)),
96+
value="erdc_rainbow_bright",
97+
),
10498
),
105-
]
99+
],
100+
style={"height": "12%", "align-items": "center"},
106101
),
107-
html.Hr(),
108-
dbc.Row(
109-
[
110-
dbc.Col(
111-
width=12,
112-
children=[
113-
html.Div(
114-
vtk_view,
115-
style={"height": "calc(80vh - 20px)", "width": "100%"},
116-
)
117-
],
118-
),
119-
]
102+
html.Div(
103+
html.Div(vtk_view, style={"height": "100%", "width": "100%"}),
104+
style={"height": "88%"},
120105
),
121106
],
122107
)

apps/dash-vtk-explorer/demos/slice-rendering/app.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def custom_card(children):
3030
return dbc.Card(
3131
html.Div(children, style={"height": "100%"}),
3232
body=True,
33-
style={"height": "70vh"},
33+
style={"height": "100%"},
3434
)
3535

3636

@@ -106,16 +106,18 @@ def custom_card(children):
106106

107107
app.layout = dbc.Container(
108108
fluid=True,
109+
style={"height": "calc(100vh - 30px)"},
109110
children=[
110-
html.H2("Demo of Slice Rendering"),
111-
html.Br(),
112-
controls,
113-
html.Br(),
111+
html.Div(
112+
style={"height": "20%", "display": "flex", "align-items": "center"},
113+
children=[html.Br(), controls, html.Br(),],
114+
),
114115
dbc.Row(
115-
[
116+
style={"height": "80%"},
117+
children=[
116118
dbc.Col(width=6, children=custom_card(slice_view)),
117119
dbc.Col(width=6, children=custom_card(volume_view)),
118-
]
120+
],
119121
),
120122
],
121123
)

apps/dash-vtk-explorer/demos/synthetic-volume-rendering/app.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,20 @@
99
app = dash.Dash(__name__)
1010
server = app.server
1111

12+
volume_view = dash_vtk.View(
13+
children=dash_vtk.VolumeDataRepresentation(
14+
spacing=[1, 1, 1],
15+
dimensions=[10, 10, 10],
16+
origin=[0, 0, 0],
17+
scalars=[random.random() for _ in range(1000)],
18+
rescaleColorMap=False,
19+
)
20+
)
21+
1222
app.layout = html.Div(
13-
style={"height": "calc(100vh - 30px)", "width": "100%",},
23+
style={"height": "calc(100vh - 16px)"},
1424
children=[
15-
dash_vtk.View(
16-
children=dash_vtk.VolumeDataRepresentation(
17-
spacing=[1, 1, 1],
18-
dimensions=[10, 10, 10],
19-
origin=[0, 0, 0],
20-
scalars=[random.random() for _ in range(1000)],
21-
rescaleColorMap=False,
22-
)
23-
)
25+
html.Div(children=volume_view, style={"height": "100%", "width": "100%"})
2426
],
2527
)
2628

apps/dash-vtk-explorer/demos/usage-algorithm/app.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,19 @@
5555

5656
app.layout = dbc.Container(
5757
fluid=True,
58+
style={"margin-top": "15px", "height": "calc(100vh - 30px)"},
5859
children=[
59-
html.H1("Demo of dash_vtk.Algorithm"),
60-
html.Hr(),
6160
dbc.Row(
6261
[
6362
dbc.Col(width=4, children=controls),
6463
dbc.Col(
6564
width=8,
6665
children=[
67-
html.Div(
68-
vtk_view,
69-
style={"height": "calc(80vh - 20px)", "width": "100%"},
70-
)
66+
html.Div(vtk_view, style={"height": "100%", "width": "100%"},)
7167
],
7268
),
73-
]
69+
],
70+
style={"height": "100%"},
7471
),
7572
],
7673
)

apps/dash-vtk-explorer/demos/usage-vtk-cfd/app.py

Lines changed: 72 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -139,97 +139,93 @@ def getSeedState(self):
139139
# Control UI
140140
# -----------------------------------------------------------------------------
141141

142-
controls = dbc.Col(
143-
children=[
144-
dbc.Card(
145-
[
146-
dbc.CardHeader("Seeds"),
147-
dbc.CardBody(
148-
[
149-
html.P("Seed line:"),
150-
dcc.Slider(
151-
id="point-1",
152-
min=-1,
153-
max=1,
154-
step=0.01,
155-
value=0,
156-
marks={-1: "-1", 1: "+1"},
157-
),
158-
dcc.Slider(
159-
id="point-2",
160-
min=-1,
161-
max=1,
162-
step=0.01,
163-
value=0,
164-
marks={-1: "-1", 1: "+1"},
165-
),
166-
html.Br(),
167-
html.P("Line resolution:"),
168-
dcc.Slider(
169-
id="seed-resolution",
170-
min=5,
171-
max=50,
172-
step=1,
173-
value=10,
174-
marks={5: "5", 50: "50"},
175-
),
176-
]
177-
),
178-
]
179-
),
180-
dbc.Card(
181-
[
182-
dbc.CardHeader("Color By"),
183-
dbc.CardBody(
184-
[
185-
html.P("Field name"),
186-
dcc.Dropdown(
187-
id="color-by",
188-
options=[
189-
{"label": "p", "value": "p"},
190-
{"label": "Rotation", "value": "Rotation"},
191-
{"label": "U", "value": "U"},
192-
{"label": "Vorticity", "value": "Vorticity"},
193-
{"label": "k", "value": "k"},
194-
],
195-
value="p",
196-
),
197-
html.Br(),
198-
html.P("Color Preset"),
199-
dcc.Dropdown(
200-
id="preset",
201-
options=preset_as_options,
202-
value="erdc_rainbow_bright",
203-
),
204-
]
205-
),
206-
]
207-
),
208-
]
209-
)
142+
controls = [
143+
dbc.Card(
144+
[
145+
dbc.CardHeader("Seeds"),
146+
dbc.CardBody(
147+
[
148+
html.P("Seed line:"),
149+
dcc.Slider(
150+
id="point-1",
151+
min=-1,
152+
max=1,
153+
step=0.01,
154+
value=0,
155+
marks={-1: "-1", 1: "+1"},
156+
),
157+
dcc.Slider(
158+
id="point-2",
159+
min=-1,
160+
max=1,
161+
step=0.01,
162+
value=0,
163+
marks={-1: "-1", 1: "+1"},
164+
),
165+
html.Br(),
166+
html.P("Line resolution:"),
167+
dcc.Slider(
168+
id="seed-resolution",
169+
min=5,
170+
max=50,
171+
step=1,
172+
value=10,
173+
marks={5: "5", 50: "50"},
174+
),
175+
]
176+
),
177+
]
178+
),
179+
html.Br(),
180+
dbc.Card(
181+
[
182+
dbc.CardHeader("Color By"),
183+
dbc.CardBody(
184+
[
185+
html.P("Field name"),
186+
dcc.Dropdown(
187+
id="color-by",
188+
options=[
189+
{"label": "p", "value": "p"},
190+
{"label": "Rotation", "value": "Rotation"},
191+
{"label": "U", "value": "U"},
192+
{"label": "Vorticity", "value": "Vorticity"},
193+
{"label": "k", "value": "k"},
194+
],
195+
value="p",
196+
),
197+
html.Br(),
198+
html.P("Color Preset"),
199+
dcc.Dropdown(
200+
id="preset",
201+
options=preset_as_options,
202+
value="erdc_rainbow_bright",
203+
),
204+
]
205+
),
206+
]
207+
),
208+
]
210209

211210
# -----------------------------------------------------------------------------
212211
# App UI
213212
# -----------------------------------------------------------------------------
214213

215214
app.layout = dbc.Container(
216215
fluid=True,
216+
style={"margin-top": "15px", "height": "calc(100vh - 30px)"},
217217
children=[
218-
html.H1("dash_vtk rendering with VTK processing"),
219-
html.Hr(),
220218
dbc.Row(
221219
[
222-
dbc.Col(width=4, children=[controls],),
220+
dbc.Col(width=4, children=controls),
223221
dbc.Col(
224222
width=8,
225223
children=[
226-
html.Div(
227-
vtk_view,
228-
style={"height": "calc(80vh - 20px)", "width": "100%"},
229-
)
224+
html.Div(vtk_view, style={"height": "100%", "width": "100%"})
230225
],
231226
),
232-
]
227+
],
228+
style={"height": "100%"},
233229
),
234230
],
235231
)

0 commit comments

Comments
 (0)