Skip to content

Commit f01f44a

Browse files
author
Xing Han Lu
authored
Refactor demos - Remove unused files, change requirements linking, remove headers (#16)
* Update demo's component ID Changing it to avoid duplicate in multi-page (wrt other apps with the same ID) * Remove unused files Procfile and runtime.txt are not needed to run those demo, only for hosting * Update requirements linking in demos Move the requirements.txt to demos, and link to that file from tests/requirements.txt * Add missing requirements to the demos * Refactor pyvista-point-cloud - Remove bootstrap dependencies - Decrease subset - Remove Columns/Rows * Refactor terrain mesh demo - Change row heights to % - Remove title - Change vtk height/width to % * Refactor synthetic volume rendering demo - Change vtk height/width to % * Refactor usage algorithm - Change row heights to % - Remove title - Change vtk height/width to % * Refactor VTK-CFD demo - Change row heights to % - Remove title - Change vtk height/width to % * Refactor volume rendering demo - Change vtk height/width to % * Refactor slice rendering demo - change card style from vh to % - change row height to % - Remove title - change controls to vertically centered * Run black on demos
1 parent 92186a6 commit f01f44a

File tree

25 files changed

+143
-190
lines changed

25 files changed

+143
-190
lines changed

demos/pyvista-point-cloud/Procfile

Lines changed: 0 additions & 1 deletion
This file was deleted.

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

demos/pyvista-point-cloud/runtime.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

demos/pyvista-terrain-following-mesh/Procfile

Lines changed: 0 additions & 1 deletion
This file was deleted.

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
)

demos/pyvista-terrain-following-mesh/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ dash-vtk
33
dash-bootstrap-components
44
pyvista
55
numpy
6+
vtk

demos/pyvista-terrain-following-mesh/runtime.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

demos/requirements.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-r ./usage-algorithm/requirements.txt
2+
-r ./pyvista-terrain-following-mesh/requirements.txt
3+
-r ./slice-rendering/requirements.txt
4+
-r ./pyvista-point-cloud/requirements.txt
5+
-r ./volume-rendering/requirements.txt
6+
-r ./usage-vtk-cfd/requirements.txt
7+
-r ./usage-algorithm/requirements.txt
8+
-r ./synthetic-volume-rendering/requirements.txt

demos/slice-rendering/Procfile

Lines changed: 0 additions & 1 deletion
This file was deleted.

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
)

demos/slice-rendering/runtime.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

demos/synthetic-volume-rendering/Procfile

Lines changed: 0 additions & 1 deletion
This file was deleted.

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

demos/synthetic-volume-rendering/runtime.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

demos/usage-algorithm/app.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
server = app.server
1414

1515
vtk_view = dash_vtk.View(
16-
id="vtk-view",
16+
id="geometry-view",
1717
children=[
1818
dash_vtk.GeometryRepresentation(
1919
[
@@ -55,29 +55,26 @@
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
)
7774

7875

7976
@app.callback(
80-
[Output("vtk-algorithm", "state"), Output("vtk-view", "triggerResetCamera")],
77+
[Output("vtk-algorithm", "state"), Output("geometry-view", "triggerResetCamera")],
8178
[Input("slider-resolution", "value"), Input("capping-checklist", "value")],
8279
)
8380
def update_cone(slider_val, checked_values):

demos/usage-vtk-cfd/Procfile

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)