Skip to content

Commit 7809073

Browse files
fix: Cleanup
1 parent 54cbd7c commit 7809073

File tree

1 file changed

+48
-146
lines changed

1 file changed

+48
-146
lines changed

src/ansys/tools/visualization_interface/backends/plotly/widgets/button_manager.py

Lines changed: 48 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,12 @@ def show_hide_bbox_dict(self, toggle: bool = True):
142142
"scene.zaxis.showbackground": toggle
143143
}
144144

145-
def add_coordinate_system_toggle_button(self,
146-
label: str = "Toggle Axes",
147-
x: float = 0.08,
148-
y: float = 1.02) -> None:
145+
def add_coordinate_system_toggle_button(
146+
self,
147+
label: str = "Toggle Axes",
148+
x: float = 0.08,
149+
y: float = 1.02
150+
) -> None:
149151
"""Add a button to toggle the coordinate system (axes, grid, labels) on/off.
150152
151153
Parameters
@@ -166,19 +168,18 @@ def add_coordinate_system_toggle_button(self,
166168
y=y
167169
)
168170

169-
def add_dropdown_menu(self,
170-
label: str,
171-
options: List[dict],
172-
x: float = 0.02,
173-
y: float = 1.02,
174-
xanchor: str = "left",
175-
yanchor: str = "bottom") -> None:
171+
def add_dropdown_menu(
172+
self,
173+
options: List[dict],
174+
x: float = 0.02,
175+
y: float = 1.02,
176+
xanchor: str = "left",
177+
yanchor: str = "bottom"
178+
) -> None:
176179
"""Add a dropdown menu to the Plotly figure.
177180
178181
Parameters
179182
----------
180-
label : str
181-
The label for the dropdown menu.
182183
options : List[dict]
183184
List of dropdown options, each containing 'label', 'method', and 'args'.
184185
x : float, optional
@@ -249,14 +250,15 @@ def _update_dropdowns(self) -> None:
249250

250251
self._fig.update_layout(updatemenus=updatemenus)
251252

252-
def add_plane_view_buttons(self,
253-
xy_label: str = "XY View",
254-
xz_label: str = "XZ View",
255-
yz_label: str = "YZ View",
256-
iso_label: str = "ISO View",
257-
x: float = 0.02,
258-
y: float = 1.02,
259-
spacing: float = 0.12) -> None:
253+
def add_plane_view_buttons(
254+
self,
255+
xy_label: str = "XY View",
256+
xz_label: str = "XZ View",
257+
yz_label: str = "YZ View",
258+
iso_label: str = "ISO View",
259+
x: float = 0.02,
260+
y: float = 1.02,
261+
) -> None:
260262
"""Add a dropdown menu for standard plane views (XY, XZ, YZ) and isometric view.
261263
262264
Parameters
@@ -326,11 +328,13 @@ def clear_buttons(self) -> None:
326328
self._buttons.clear()
327329
self._fig.update_layout(updatemenus=[])
328330

329-
def add_visibility_toggle_button(self,
330-
trace_indices: List[int],
331-
label: str = "Toggle Visibility",
332-
x: float = 0.02,
333-
y: float = 0.95) -> None:
331+
def add_visibility_toggle_button(
332+
self,
333+
trace_indices: List[int],
334+
label: str = "Toggle Visibility",
335+
x: float = 0.02,
336+
y: float = 0.95
337+
) -> None:
334338
"""Add a button to toggle visibility of specific traces.
335339
336340
Parameters
@@ -357,10 +361,12 @@ def add_visibility_toggle_button(self,
357361
y=y
358362
)
359363

360-
def add_reset_view_button(self,
361-
label: str = "Reset View",
362-
x: float = 0.02,
363-
y: float = 0.95) -> None:
364+
def add_reset_view_button(
365+
self,
366+
label: str = "Reset View",
367+
x: float = 0.02,
368+
y: float = 0.95
369+
) -> None:
364370
"""Add a button to reset the 3D view to default.
365371
366372
Parameters
@@ -384,10 +390,12 @@ def add_reset_view_button(self,
384390
y=y
385391
)
386392

387-
def add_measurement_toggle_button(self,
388-
label: str = "Toggle Measurement",
389-
x: float = 0.02,
390-
y: float = 0.87) -> None:
393+
def add_measurement_toggle_button(
394+
self,
395+
label: str = "Toggle Measurement",
396+
x: float = 0.02,
397+
y: float = 0.87
398+
) -> None:
391399
"""Add a button to toggle the measurement widget on/off.
392400
393401
Parameters
@@ -424,118 +432,12 @@ def add_measurement_toggle_button(self,
424432
y=y
425433
)
426434

427-
def add_xy_view_button(self,
428-
label: str = "XY View",
429-
x: float = 0.02,
430-
y: float = 0.79) -> None:
431-
"""Add a button for XY plane view (looking down the Z-axis).
432-
433-
Parameters
434-
----------
435-
label : str, optional
436-
The text to display on the button, by default "XY View".
437-
x : float, optional
438-
X position of the button (0-1), by default 0.02.
439-
y : float, optional
440-
Y position of the button (0-1), by default 0.79.
441-
"""
442-
self.add_button(
443-
label=label,
444-
method="relayout",
445-
args=[{
446-
"scene.camera.eye": {"x": 0, "y": 0, "z": 2.5},
447-
"scene.camera.center": {"x": 0, "y": 0, "z": 0},
448-
"scene.camera.up": {"x": 0, "y": 1, "z": 0}
449-
}],
450-
x=x,
451-
y=y
452-
)
453-
454-
def add_xz_view_button(self,
455-
label: str = "XZ View",
456-
x: float = 0.02,
457-
y: float = 0.71) -> None:
458-
"""Add a button for XZ plane view (looking along the Y-axis).
459-
460-
Parameters
461-
----------
462-
label : str, optional
463-
The text to display on the button, by default "XZ View".
464-
x : float, optional
465-
X position of the button (0-1), by default 0.02.
466-
y : float, optional
467-
Y position of the button (0-1), by default 0.71.
468-
"""
469-
self.add_button(
470-
label=label,
471-
method="relayout",
472-
args=[{
473-
"scene.camera.eye": {"x": 0, "y": -2.5, "z": 0},
474-
"scene.camera.center": {"x": 0, "y": 0, "z": 0},
475-
"scene.camera.up": {"x": 0, "y": 0, "z": 1}
476-
}],
477-
x=x,
478-
y=y
479-
)
480-
481-
def add_yz_view_button(self,
482-
label: str = "YZ View",
483-
x: float = 0.02,
484-
y: float = 0.63) -> None:
485-
"""Add a button for YZ plane view (looking along the X-axis).
486-
487-
Parameters
488-
----------
489-
label : str, optional
490-
The text to display on the button, by default "YZ View".
491-
x : float, optional
492-
X position of the button (0-1), by default 0.02.
493-
y : float, optional
494-
Y position of the button (0-1), by default 0.63.
495-
"""
496-
self.add_button(
497-
label=label,
498-
method="relayout",
499-
args=[{
500-
"scene.camera.eye": {"x": 2.5, "y": 0, "z": 0},
501-
"scene.camera.center": {"x": 0, "y": 0, "z": 0},
502-
"scene.camera.up": {"x": 0, "y": 0, "z": 1}
503-
}],
504-
x=x,
505-
y=y
506-
)
507-
508-
def add_isometric_view_button(self,
509-
label: str = "ISO View",
510-
x: float = 0.02,
511-
y: float = 0.55) -> None:
512-
"""Add a button for isometric view (diagonal 3D perspective).
513-
514-
Parameters
515-
----------
516-
label : str, optional
517-
The text to display on the button, by default "ISO View".
518-
x : float, optional
519-
X position of the button (0-1), by default 0.02.
520-
y : float, optional
521-
Y position of the button (0-1), by default 0.55.
522-
"""
523-
self.add_button(
524-
label=label,
525-
method="relayout",
526-
args=[{
527-
"scene.camera.eye": {"x": 1.25, "y": 1.25, "z": 1.25},
528-
"scene.camera.center": {"x": 0, "y": 0, "z": 0},
529-
"scene.camera.up": {"x": 0, "y": 0, "z": 1}
530-
}],
531-
x=x,
532-
y=y
533-
)
534-
535-
def add_projection_toggle_button(self,
536-
label: str = "Toggle Projection",
537-
x: float = 0.14,
538-
y: float = 1.02) -> None:
435+
def add_projection_toggle_button(
436+
self,
437+
label: str = "Toggle Projection",
438+
x: float = 0.14,
439+
y: float = 1.02
440+
) -> None:
539441
"""Add a button to toggle between perspective and orthographic projection.
540442
541443
Parameters

0 commit comments

Comments
 (0)