2121
2222# local
2323from protograf import globals
24- from protograf .shapes_utils import set_cached_dir , draw_line
24+ from protograf .shapes_utils import set_cached_dir , draw_line , draw_line_curve
2525from protograf .base import (
2626 BaseShape ,
2727 get_cache ,
@@ -1187,7 +1187,7 @@ def draw(self, cnv=None, off_x=0, off_y=0, ID=None, **kwargs):
11871187 kwargs = self .kwargs | kwargs
11881188 cnv = cnv if cnv else globals .canvas # a new Page/Shape may now exist
11891189 super ().draw (cnv , off_x , off_y , ID , ** kwargs ) # unit-based props
1190- x , y , x_1 , y_1 = None , None , None , None
1190+ x , y , x_1 , y_1 , ccx , ccy = None , None , None , None , None , None
11911191 # ---- EITHER connections draw
11921192 if self .connections :
11931193 conns = self .draw_connections (
@@ -1249,9 +1249,18 @@ def draw(self, cnv=None, off_x=0, off_y=0, ID=None, **kwargs):
12491249 raise ValueError (
12501250 f'Cannot calculate rotation point "{ self .rotation_point } "' , True
12511251 )
1252- # ---- draw line
1253- # breakpoint()
1254- klargs = draw_line (cnv , Point (x , y ), Point (x_1 , y_1 ), shape = self , ** kwargs )
1252+ # ---- draw straight line
1253+ if not self .curve :
1254+ klargs = draw_line (
1255+ cnv , Point (x , y ), Point (x_1 , y_1 ), shape = self , ** kwargs
1256+ )
1257+ else :
1258+ # ---- draw curve line
1259+ if kwargs .get ("wave_height" ) or kwargs .get ("wave_style" ):
1260+ feedback ("A line cannot use a wave and curve together" , True )
1261+ klargs , ccx , ccy = draw_line_curve (
1262+ cnv , Point (x , y ), Point (x_1 , y_1 ), self .curve , ** kwargs
1263+ )
12551264 self .set_canvas_props (cnv = cnv , index = ID , ** klargs ) # shape.finish()
12561265 # ---- arrowhead
12571266 self .draw_arrow (cnv , Point (x , y ), Point (x_1 , y_1 ), ** kwargs )
@@ -1262,7 +1271,10 @@ def draw(self, cnv=None, off_x=0, off_y=0, ID=None, **kwargs):
12621271 conn = conns [0 ]
12631272 x , y = conn [0 ].x , conn [0 ].y
12641273 x_1 , y_1 = conn [1 ].x , conn [1 ].y
1265- cx , cy = (x_1 + x ) / 2.0 , (y_1 + y ) / 2.0
1274+ if ccx and ccy :
1275+ cx , cy = ccx , ccy # centre of point of curve line
1276+ else :
1277+ cx , cy = (x_1 + x ) / 2.0 , (y_1 + y ) / 2.0
12661278 # ---- * centre shapes (with offsets)
12671279 if self .centre_shapes :
12681280 _ , _angle = geoms .angles_from_points (Point (x_1 , y_1 ), Point (x , y ))
0 commit comments