@@ -160,6 +160,14 @@ def __init__(self, type_: str, reference_path: str = "#", name: str = ""):
160160 super ().__init__ (type_ = type_ , name = name )
161161
162162
163+ class Shape (ReferencedObject ):
164+ """ Shape object. """
165+
166+ def __init__ (self , type_ : str , reference_path : str = "#" , tooltip : str = None , name : str = "" ):
167+ self .tooltip = tooltip
168+ super ().__init__ (type_ = type_ , reference_path = reference_path , name = name )
169+
170+
163171class Sample (ReferencedObject ):
164172 """ Graph Point. """
165173
@@ -426,7 +434,7 @@ def __init__(self, point_color: str, point_index: List[int], name: str = ''):
426434 PlotDataObject .__init__ (self , type_ = None , name = name )
427435
428436
429- class Text (ReferencedObject ):
437+ class Text (Shape ):
430438 """
431439 A class for displaying texts on canvas. Text is a primitive and can be instantiated by PrimitiveGroup.
432440
@@ -450,7 +458,7 @@ class Text(ReferencedObject):
450458
451459 def __init__ (self , comment : str , position_x : float , position_y : float , text_style : TextStyle = None ,
452460 text_scaling : bool = None , max_width : float = None , height : float = None , multi_lines : bool = True ,
453- reference_path : str = "#" , name : str = '' ):
461+ reference_path : str = "#" , tooltip : str = None , name : str = '' ):
454462 self .comment = comment
455463 self .text_style = text_style
456464 self .position_x = position_x
@@ -459,7 +467,7 @@ def __init__(self, comment: str, position_x: float, position_y: float, text_styl
459467 self .max_width = max_width
460468 self .height = height
461469 self .multi_lines = multi_lines
462- super ().__init__ (type_ = 'text' , reference_path = reference_path , name = name )
470+ super ().__init__ (type_ = 'text' , reference_path = reference_path , tooltip = tooltip , name = name )
463471
464472 def mpl_plot (self , ax = None , color = 'k' , alpha = 1. , ** kwargs ):
465473 """ Plots using Matplotlib. """
@@ -469,7 +477,7 @@ def mpl_plot(self, ax=None, color='k', alpha=1., **kwargs):
469477 return ax
470478
471479
472- class Line2D (ReferencedObject ):
480+ class Line2D (Shape ):
473481 """
474482 An infinite line. Line2D is a primitive and can be instantiated by PrimitiveGroups.
475483
@@ -482,12 +490,12 @@ class Line2D(ReferencedObject):
482490 """
483491
484492 def __init__ (self , point1 : List [float ], point2 : List [float ], edge_style : EdgeStyle = None ,
485- reference_path : str = "#" , name : str = '' ):
493+ reference_path : str = "#" , tooltip : str = None , name : str = '' ):
486494 self .data = point1 + point2 # Retrocompatibility
487495 self .point1 = point1
488496 self .point2 = point2
489497 self .edge_style = edge_style
490- super ().__init__ (type_ = 'line2d' , reference_path = reference_path , name = name )
498+ super ().__init__ (type_ = 'line2d' , reference_path = reference_path , tooltip = tooltip , name = name )
491499
492500 def mpl_plot (self , ax = None , edge_style = None , ** kwargs ):
493501 """ Plots using matplotlib. """
@@ -505,7 +513,7 @@ def mpl_plot(self, ax=None, edge_style=None, **kwargs):
505513 return ax
506514
507515
508- class LineSegment2D (ReferencedObject ):
516+ class LineSegment2D (Shape ):
509517 """
510518 A line segment. This is a primitive that can be called by PrimitiveGroup.
511519
@@ -518,7 +526,7 @@ class LineSegment2D(ReferencedObject):
518526 """
519527
520528 def __init__ (self , point1 : List [float ], point2 : List [float ], edge_style : EdgeStyle = None ,
521- reference_path : str = "#" , name : str = '' ):
529+ reference_path : str = "#" , tooltip : str = None , name : str = '' ):
522530 # Data is used in typescript
523531 self .data = point1 + point2
524532 self .point1 = point1
@@ -528,7 +536,7 @@ def __init__(self, point1: List[float], point2: List[float], edge_style: EdgeSty
528536 self .edge_style = EdgeStyle ()
529537 else :
530538 self .edge_style = edge_style
531- super ().__init__ (type_ = 'linesegment2d' , reference_path = reference_path , name = name )
539+ super ().__init__ (type_ = 'linesegment2d' , reference_path = reference_path , tooltip = tooltip , name = name )
532540
533541 def bounding_box (self ):
534542 """ Get 2D bounding box of current LineSegment2D. """
@@ -556,7 +564,7 @@ def mpl_plot(self, ax=None, edge_style=None, **kwargs):
556564 return ax
557565
558566
559- class Wire (ReferencedObject ):
567+ class Wire (Shape ):
560568 """
561569 A set of connected lines. It also provides highlighting feature.
562570
@@ -572,8 +580,7 @@ def __init__(self, lines: List[Tuple[float, float]], edge_style: EdgeStyle = Non
572580 reference_path : str = "#" , name : str = "" ):
573581 self .lines = lines
574582 self .edge_style = edge_style
575- self .tooltip = tooltip
576- super ().__init__ (type_ = "wire" , reference_path = reference_path , name = name )
583+ super ().__init__ (type_ = "wire" , reference_path = reference_path , tooltip = tooltip , name = name )
577584
578585 def mpl_plot (self , ax = None , ** kwargs ):
579586 """ Plots using matplotlib. """
@@ -588,7 +595,7 @@ def mpl_plot(self, ax=None, **kwargs):
588595 return ax
589596
590597
591- class Circle2D (ReferencedObject ):
598+ class Circle2D (Shape ):
592599 """
593600 A circle. It is a primitive and can be instantiated by PrimitiveGroup.
594601
@@ -613,8 +620,7 @@ def __init__(self, cx: float, cy: float, r: float, edge_style: EdgeStyle = None,
613620 self .r = r
614621 self .cx = cx
615622 self .cy = cy
616- self .tooltip = tooltip
617- super ().__init__ (type_ = 'circle' , reference_path = reference_path , name = name )
623+ super ().__init__ (type_ = 'circle' , reference_path = reference_path , tooltip = tooltip , name = name )
618624
619625 def bounding_box (self ):
620626 """ Get 2D bounding box of current Circle2D. """
@@ -644,7 +650,7 @@ def mpl_plot(self, ax=None, **kwargs):
644650 return ax
645651
646652
647- class Rectangle (ReferencedObject ):
653+ class Rectangle (Shape ):
648654 """ Class to draw a rectangle. """
649655
650656 def __init__ (self , x_coord : float , y_coord : float , width : float , height : float , edge_style : EdgeStyle = None ,
@@ -655,8 +661,7 @@ def __init__(self, x_coord: float, y_coord: float, width: float, height: float,
655661 self .height = height
656662 self .surface_style = surface_style
657663 self .edge_style = edge_style
658- self .tooltip = tooltip
659- super ().__init__ (type_ = 'rectangle' , reference_path = reference_path , name = name )
664+ super ().__init__ (type_ = 'rectangle' , reference_path = reference_path , tooltip = tooltip , name = name )
660665
661666 def bounding_box (self ):
662667 """ Get 2D bounding box of current Circle2D. """
@@ -698,7 +703,7 @@ def __init__(self, x_coord: float, y_coord: float, width: float, height: float,
698703 self .radius = radius
699704
700705
701- class Point2D (ReferencedObject ):
706+ class Point2D (Shape ):
702707 """
703708 A class for instantiating a point.
704709
@@ -710,11 +715,12 @@ class Point2D(ReferencedObject):
710715 :type point_style: PointStyle
711716 """
712717
713- def __init__ (self , cx : float , cy : float , point_style : PointStyle = None , reference_path : str = "#" , name : str = '' ):
718+ def __init__ (self , cx : float , cy : float , point_style : PointStyle = None , reference_path : str = "#" ,
719+ tooltip : str = None , name : str = '' ):
714720 self .cx = cx
715721 self .cy = cy
716722 self .point_style = point_style
717- super ().__init__ (type_ = 'point' , reference_path = reference_path , name = name )
723+ super ().__init__ (type_ = 'point' , reference_path = reference_path , tooltip = tooltip , name = name )
718724
719725 def bounding_box (self ):
720726 """ Get 2D bounding box of current Circle2D. """
@@ -1114,7 +1120,7 @@ def _build_multiplot(self):
11141120 for row in sample_attributes for col in sample_attributes ]
11151121
11161122
1117- class Arc2D (ReferencedObject ):
1123+ class Arc2D (Shape ):
11181124 """
11191125 A class for drawing arcs. Arc2D is a primitive and can be instantiated by PrimitiveGroup. By default,
11201126 the arc is drawn anticlockwise.
@@ -1140,15 +1146,15 @@ class Arc2D(ReferencedObject):
11401146 """
11411147
11421148 def __init__ (self , cx : float , cy : float , r : float , start_angle : float , end_angle : float , clockwise : bool = None ,
1143- edge_style : EdgeStyle = None , reference_path : str = "#" , name : str = '' ):
1149+ edge_style : EdgeStyle = None , reference_path : str = "#" , tooltip : str = None , name : str = '' ):
11441150 self .cx = cx
11451151 self .cy = cy
11461152 self .r = r
11471153 self .start_angle = start_angle
11481154 self .end_angle = end_angle
11491155 self .clockwise = clockwise
11501156 self .edge_style = edge_style
1151- super ().__init__ (type_ = 'arc' , reference_path = reference_path , name = name )
1157+ super ().__init__ (type_ = 'arc' , reference_path = reference_path , tooltip = tooltip , name = name )
11521158
11531159 def bounding_box (self ):
11541160 """ Get 2D bounding box of current Circle2D. """
@@ -1182,7 +1188,7 @@ def mpl_plot(self, ax=None, **kwargs):
11821188 return ax
11831189
11841190
1185- class Contour2D (ReferencedObject ):
1191+ class Contour2D (Shape ):
11861192 """
11871193 A Contour2D is a closed polygon that is formed by multiple primitives.
11881194
@@ -1202,9 +1208,8 @@ def __init__(self, plot_data_primitives: List[Union[Arc2D, LineSegment2D]], edge
12021208 self .plot_data_primitives = plot_data_primitives
12031209 self .edge_style = edge_style
12041210 self .surface_style = surface_style
1205- self .tooltip = tooltip
12061211 self .is_filled = surface_style is not None
1207- super ().__init__ (type_ = 'contour' , reference_path = reference_path , name = name )
1212+ super ().__init__ (type_ = 'contour' , reference_path = reference_path , tooltip = tooltip , name = name )
12081213
12091214 def bounding_box (self ):
12101215 """ Get 2D bounding box of current Contour2D. """
@@ -1508,7 +1513,7 @@ def plot_data_path(local: bool = False, version: str = None):
15081513 """ Get path of plot_data package to write it in html file of Figure to draw. """
15091514 version , folder , filename = get_current_link (version = version )
15101515 if local :
1511- core_path = os .sep .join (os . getcwd (). split (os .sep )[:- 1 ] + [folder , filename ])
1516+ core_path = os .sep .join (__file__ . split (os .sep )[:- 2 ] + [folder , filename ])
15121517 if os .path .isfile (core_path ):
15131518 return core_path .replace (" " , "%20" )
15141519 print (f'Local compiled { core_path } not found, fall back to CDN' )
0 commit comments