@@ -42,8 +42,8 @@ def __init__(
42
42
spring = 3
43
43
),
44
44
title : str = "Pynite - Simple Finite Element Analysis for Python" ,
45
- height : int = 800 ,
46
- width : int = 800 ,
45
+ window_height : int = 800 ,
46
+ window_width : int = 800 ,
47
47
):
48
48
self .model = model
49
49
@@ -61,21 +61,16 @@ def __init__(
61
61
self ._scalar_bar_text_size = 24
62
62
self .theme = "default"
63
63
self .colors = colors
64
- self .line_widths = dict (
65
- member = 4 ,
66
- loads = 2 ,
67
- deformed_member = 2 ,
68
- spring = 3
69
- )
70
-
64
+ self .line_widths = line_widths
71
65
self ._title = "Pynite - Simple Finite Element Analysis for Python"
72
-
66
+ self ._window_width = window_width
67
+ self ._window_height = window_height
73
68
self .plotter = None
74
69
75
70
76
71
self ._layout = default_layout (self ._title )
77
- self .window_width = width
78
- self .window_height = height
72
+ self ._layout . width = window_width
73
+ self ._layout . height = window_height
79
74
80
75
# self.plotter.set_background('white') # Setting background color
81
76
# # self.plotter.add_logo_widget('./Resources/Full Logo No Buffer - Transparent.png')
@@ -90,6 +85,7 @@ def __init__(
90
85
# Initialize spring labels
91
86
self ._spring_label_points = []
92
87
self ._spring_labels = []
88
+ self ._annotations = []
93
89
94
90
## Get Figure Size
95
91
@@ -225,7 +221,6 @@ def render_model(self, reset_camera=True):
225
221
self .update (reset_camera )
226
222
227
223
# Render the model (code execution will pause here until the user closes the window)
228
- self .plotter .show ()
229
224
return self .plotter
230
225
231
226
def screenshot (
@@ -289,8 +284,7 @@ def update(self, reset_camera=True):
289
284
# Clear out the old plot (if any)
290
285
self .plotter = go .Figure ()
291
286
292
- layout = default_layout (self ._title )
293
- self ._layout = layout
287
+ layout = self ._layout
294
288
295
289
## Set the layout
296
290
self .plotter .layout = self ._layout
@@ -1689,6 +1683,8 @@ def add_point_labels(
1689
1683
point_size : int = 5 ,
1690
1684
shape : str = None ,
1691
1685
render_points_as_spheres = False ,
1686
+ x_shift = 0 ,
1687
+ y_shift = 0
1692
1688
):
1693
1689
assert len (points ) == len (labels )
1694
1690
# if show_points or render_points_as_spheres or shape:
@@ -1703,17 +1699,14 @@ def add_point_labels(
1703
1699
label = labels [idx ]
1704
1700
x , y , z = point
1705
1701
text_label = f"{ start_bold_tag } { label } { end_bold_tag } "
1706
- # annotations.append(
1707
- # dict(
1708
- # x=x,
1709
- # y=y,
1710
- # z=z,
1711
- # text=text_label,
1712
- # font=dict(
1713
- # color=self.colors['point_label_text']
1714
- # ),
1715
- # )
1716
- # )
1702
+ if render_points_as_spheres :
1703
+ ...
1704
+ self .plotter .add_trace (
1705
+ go .Scatter3d (
1706
+ x = [x ], y = [y ], z = [z ], marker = dict (color = point_color , size = self .annotation_size / 30 )
1707
+ )
1708
+ )
1709
+ # print(f"Annotation: {text_label=} | {point=}")
1717
1710
annotations .append (
1718
1711
dict (
1719
1712
x = x ,
@@ -1722,15 +1715,15 @@ def add_point_labels(
1722
1715
text = text_label ,
1723
1716
showarrow = False ,
1724
1717
font = dict (
1725
- color = self . colors [ 'point_label_text' ] ,
1718
+ color = text_color ,
1726
1719
size = 16
1727
1720
),
1728
- yshift = 5 ,
1729
- xshift = 5
1721
+ yshift = y_shift ,
1722
+ xshift = x_shift ,
1730
1723
)
1731
1724
)
1732
-
1733
- self .plotter .update_layout (scene = dict (annotations = annotations ))
1725
+ self . _annotations += annotations
1726
+ self .plotter .update_layout (scene = dict (annotations = self . _annotations ))
1734
1727
# TODO: Show points
1735
1728
1736
1729
0 commit comments