@@ -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. """
@@ -504,7 +512,7 @@ def mpl_plot(self, ax=None, edge_style=None, **kwargs):
504512 return ax
505513
506514
507- class LineSegment2D (ReferencedObject ):
515+ class LineSegment2D (Shape ):
508516 """
509517 A line segment. This is a primitive that can be called by PrimitiveGroup.
510518
@@ -517,7 +525,7 @@ class LineSegment2D(ReferencedObject):
517525 """
518526
519527 def __init__ (self , point1 : List [float ], point2 : List [float ], edge_style : EdgeStyle = None ,
520- reference_path : str = "#" , name : str = '' ):
528+ reference_path : str = "#" , tooltip : str = None , name : str = '' ):
521529 # Data is used in typescript
522530 self .data = point1 + point2
523531 self .point1 = point1
@@ -526,7 +534,7 @@ def __init__(self, point1: List[float], point2: List[float], edge_style: EdgeSty
526534 if edge_style is None :
527535 edge_style = EdgeStyle ()
528536 self .edge_style = edge_style
529- super ().__init__ (type_ = 'linesegment2d' , reference_path = reference_path , name = name )
537+ super ().__init__ (type_ = 'linesegment2d' , reference_path = reference_path , tooltip = tooltip , name = name )
530538
531539 def bounding_box (self ):
532540 """ Get 2D bounding box of current LineSegment2D. """
@@ -555,7 +563,7 @@ def mpl_plot(self, ax=None, edge_style=None, **kwargs):
555563 return ax
556564
557565
558- class Wire (ReferencedObject ):
566+ class Wire (Shape ):
559567 """
560568 A set of connected lines. It also provides highlighting feature.
561569
@@ -571,8 +579,7 @@ def __init__(self, lines: List[Tuple[float, float]], edge_style: EdgeStyle = Non
571579 reference_path : str = "#" , name : str = "" ):
572580 self .lines = lines
573581 self .edge_style = edge_style
574- self .tooltip = tooltip
575- super ().__init__ (type_ = "wire" , reference_path = reference_path , name = name )
582+ super ().__init__ (type_ = "wire" , reference_path = reference_path , tooltip = tooltip , name = name )
576583
577584 def mpl_plot (self , ax = None , ** kwargs ):
578585 """ Plots using matplotlib. """
@@ -587,7 +594,7 @@ def mpl_plot(self, ax=None, **kwargs):
587594 return ax
588595
589596
590- class Circle2D (ReferencedObject ):
597+ class Circle2D (Shape ):
591598 """
592599 A circle. It is a primitive and can be instantiated by PrimitiveGroup.
593600
@@ -612,8 +619,7 @@ def __init__(self, cx: float, cy: float, r: float, edge_style: EdgeStyle = None,
612619 self .r = r
613620 self .cx = cx
614621 self .cy = cy
615- self .tooltip = tooltip
616- super ().__init__ (type_ = 'circle' , reference_path = reference_path , name = name )
622+ super ().__init__ (type_ = 'circle' , reference_path = reference_path , tooltip = tooltip , name = name )
617623
618624 def bounding_box (self ):
619625 """ Get 2D bounding box of current Circle2D. """
@@ -642,7 +648,7 @@ def mpl_plot(self, ax=None, **kwargs):
642648 return ax
643649
644650
645- class Rectangle (ReferencedObject ):
651+ class Rectangle (Shape ):
646652 """ Class to draw a rectangle. """
647653
648654 def __init__ (self , x_coord : float , y_coord : float , width : float , height : float , edge_style : EdgeStyle = None ,
@@ -653,8 +659,7 @@ def __init__(self, x_coord: float, y_coord: float, width: float, height: float,
653659 self .height = height
654660 self .surface_style = surface_style
655661 self .edge_style = edge_style
656- self .tooltip = tooltip
657- super ().__init__ (type_ = 'rectangle' , reference_path = reference_path , name = name )
662+ super ().__init__ (type_ = 'rectangle' , reference_path = reference_path , tooltip = tooltip , name = name )
658663
659664 def bounding_box (self ):
660665 """ Get 2D bounding box of current Circle2D. """
@@ -695,7 +700,7 @@ def __init__(self, x_coord: float, y_coord: float, width: float, height: float,
695700 self .radius = radius
696701
697702
698- class Point2D (ReferencedObject ):
703+ class Point2D (Shape ):
699704 """
700705 A class for instantiating a point.
701706
@@ -707,11 +712,12 @@ class Point2D(ReferencedObject):
707712 :type point_style: PointStyle
708713 """
709714
710- def __init__ (self , cx : float , cy : float , point_style : PointStyle = None , reference_path : str = "#" , name : str = '' ):
715+ def __init__ (self , cx : float , cy : float , point_style : PointStyle = None , reference_path : str = "#" ,
716+ tooltip : str = None , name : str = '' ):
711717 self .cx = cx
712718 self .cy = cy
713719 self .point_style = point_style
714- super ().__init__ (type_ = 'point' , reference_path = reference_path , name = name )
720+ super ().__init__ (type_ = 'point' , reference_path = reference_path , tooltip = tooltip , name = name )
715721
716722 def bounding_box (self ):
717723 """ Get 2D bounding box of current Circle2D. """
@@ -1111,7 +1117,7 @@ def _build_multiplot(self):
11111117 for row in sample_attributes for col in sample_attributes ]
11121118
11131119
1114- class Arc2D (ReferencedObject ):
1120+ class Arc2D (Shape ):
11151121 """
11161122 A class for drawing arcs. Arc2D is a primitive and can be instantiated by PrimitiveGroup. By default,
11171123 the arc is drawn anticlockwise.
@@ -1137,15 +1143,15 @@ class Arc2D(ReferencedObject):
11371143 """
11381144
11391145 def __init__ (self , cx : float , cy : float , r : float , start_angle : float , end_angle : float , clockwise : bool = None ,
1140- edge_style : EdgeStyle = None , reference_path : str = "#" , name : str = '' ):
1146+ edge_style : EdgeStyle = None , reference_path : str = "#" , tooltip : str = None , name : str = '' ):
11411147 self .cx = cx
11421148 self .cy = cy
11431149 self .r = r
11441150 self .start_angle = start_angle
11451151 self .end_angle = end_angle
11461152 self .clockwise = clockwise
11471153 self .edge_style = edge_style
1148- super ().__init__ (type_ = 'arc' , reference_path = reference_path , name = name )
1154+ super ().__init__ (type_ = 'arc' , reference_path = reference_path , tooltip = tooltip , name = name )
11491155
11501156 def bounding_box (self ):
11511157 """ Get 2D bounding box of current Circle2D. """
@@ -1179,7 +1185,7 @@ def mpl_plot(self, ax=None, **kwargs):
11791185 return ax
11801186
11811187
1182- class Contour2D (ReferencedObject ):
1188+ class Contour2D (Shape ):
11831189 """
11841190 A Contour2D is a closed polygon that is formed by multiple primitives.
11851191
@@ -1199,9 +1205,8 @@ def __init__(self, plot_data_primitives: List[Union[Arc2D, LineSegment2D]], edge
11991205 self .plot_data_primitives = plot_data_primitives
12001206 self .edge_style = edge_style
12011207 self .surface_style = surface_style
1202- self .tooltip = tooltip
12031208 self .is_filled = surface_style is not None
1204- super ().__init__ (type_ = 'contour' , reference_path = reference_path , name = name )
1209+ super ().__init__ (type_ = 'contour' , reference_path = reference_path , tooltip = tooltip , name = name )
12051210
12061211 def bounding_box (self ):
12071212 """ Get 2D bounding box of current Contour2D. """
@@ -1505,7 +1510,7 @@ def plot_data_path(local: bool = False, version: str = None):
15051510 """ Get path of plot_data package to write it in html file of Figure to draw. """
15061511 version , folder , filename = get_current_link (version = version )
15071512 if local :
1508- core_path = os .sep .join (os . getcwd (). split (os .sep )[:- 1 ] + [folder , filename ])
1513+ core_path = os .sep .join (__file__ . split (os .sep )[:- 2 ] + [folder , filename ])
15091514 if os .path .isfile (core_path ):
15101515 return core_path .replace (" " , "%20" )
15111516 print (f'Local compiled { core_path } not found, fall back to CDN' )
0 commit comments