Skip to content

Commit cfcc5b3

Browse files
author
KPhans
committed
add buttons, logo, ui change
1 parent 517db2d commit cfcc5b3

File tree

3 files changed

+72
-6
lines changed

3 files changed

+72
-6
lines changed

apps/dash-vehicle-geometry/app.py

Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44

55
import dash
66
import dash_bootstrap_components as dbc
7+
from dash_bootstrap_components._components.Col import Col
78
import dash_html_components as html
89
import dash_core_components as dcc
910

1011
from dash.dependencies import Input, Output, State
12+
from dash_html_components.Br import Br
1113

1214
import dash_vtk
1315
from dash_vtk.utils import to_mesh_state, preset_as_options
@@ -173,16 +175,72 @@ def cache_mesh(filepath, di, fieldname=None, point_arrays=[], cell_arrays=[]):
173175
),
174176
]
175177
),
178+
html.Br(),
179+
dbc.Alert(
180+
"Please click on the vehicle to display the cones",
181+
color="info",
182+
dismissable=True,
183+
),
176184
]
177185

186+
external_buttons = html.Div(
187+
[
188+
html.A(
189+
dbc.Button(
190+
"Enterprise Demo",
191+
color="primary",
192+
size="md",
193+
className="mr-1",
194+
),
195+
href="https://plotly.com/get-demo/",
196+
target="_blank",
197+
),
198+
html.A(
199+
dbc.Button(
200+
"Source Code",
201+
size="md",
202+
className="mr-1",
203+
color="secondary",
204+
),
205+
href="https://github.com/plotly/dash-sample-apps/tree/main/apps/dash-vehicle-geometry",
206+
target="_blank",
207+
),
208+
html.A(
209+
html.Img(
210+
src=app.get_asset_url("dash-logo.png"),
211+
alt="MIT Logo",
212+
height="100%",
213+
style={"margin-left": "15px"},
214+
),
215+
href="https://plotly.com/dash/",
216+
target="_blank",
217+
),
218+
],
219+
style={
220+
"float": "right",
221+
"height": "60px",
222+
"padding-bottom": "0px",
223+
},
224+
)
225+
178226
# -----------------------------------------------------------------------------
179227
# App UI
180228
# -----------------------------------------------------------------------------
181229

182230
app.layout = dbc.Container(
183231
fluid=True,
184232
children=[
185-
html.H2("Vehicle Geometry with OpenFOAM"),
233+
dbc.Row(
234+
[
235+
dbc.Col(
236+
[html.H2("Vehicle Geometry with OpenFOAM")],
237+
width=7,
238+
style={"padding-top": "10px"},
239+
),
240+
dbc.Col([external_buttons], width=5),
241+
],
242+
style={"margin-bottom": "1px"},
243+
),
186244
html.Hr(),
187245
dbc.Row(
188246
[
@@ -204,7 +262,10 @@ def cache_mesh(filepath, di, fieldname=None, point_arrays=[], cell_arrays=[]):
204262
),
205263
],
206264
id="vtk-view-container",
207-
style={"height": "calc(100vh - 230px)", "width": "100%",},
265+
style={
266+
"height": "calc(100vh - 230px)",
267+
"width": "100%",
268+
},
208269
),
209270
],
210271
),
@@ -246,7 +307,7 @@ def initial_loading(geometry):
246307
return dash_vtk.View(
247308
id="vtk-view",
248309
children=vehicle_vtk + isosurfs_vtk + [cone_pointer, tooltip],
249-
pickingModes=["hover"],
310+
pickingModes=["click"],
250311
)
251312

252313

@@ -313,8 +374,13 @@ def update_scene(geometry, isosurfaces, surfcolor):
313374

314375

315376
@app.callback(
316-
[Output("tooltip", "children"), Output("pointer", "state"),],
317-
[Input("vtk-view", "hoverInfo"),],
377+
[
378+
Output("tooltip", "children"),
379+
Output("pointer", "state"),
380+
],
381+
[
382+
Input("vtk-view", "clickInfo"),
383+
],
318384
)
319385
def probe_data(info):
320386
cone_state = {"resolution": 12}
16.9 KB
Loading

apps/dash-vehicle-geometry/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ scooby==0.5.6
2727
six==1.15.0
2828
transforms3d==0.3.1
2929
typing-extensions==3.7.4.3
30-
vtk==9.0.1
30+
vtk==9.0.*
3131
Werkzeug==1.0.1
3232
zipp==3.4.1

0 commit comments

Comments
 (0)