44
55import dash
66import dash_bootstrap_components as dbc
7+ from dash_bootstrap_components ._components .Col import Col
78import dash_html_components as html
89import dash_core_components as dcc
910
1011from dash .dependencies import Input , Output , State
12+ from dash_html_components .Br import Br
1113
1214import dash_vtk
1315from 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
182230app .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)
319385def probe_data (info ):
320386 cone_state = {"resolution" : 12 }
0 commit comments