@@ -134,14 +134,14 @@ def _to_html(self, local: bool = False, canvas_id: str = 'canvas', version: str
134134
135135 def to_html_stream (self , stream , local : bool = False , canvas_id : str = 'canvas' , version : str = None ):
136136 """ Export current Figure to its equivalent html stream file. """
137- html = self ._to_html (local = local , canvas_id = canvas_id , version = version )
138- stream .write (html . encode ( 'utf-8' ) )
137+ html = self ._to_html (debug_mode = debug_mode , canvas_id = canvas_id , version = version )
138+ stream .write (html )
139139
140140 def to_html (self , filepath : str = None , local : bool = False , canvas_id : str = 'canvas' , version : str = None ):
141141 """ Export current Figure to an HTML file given by the filepath. """
142142 filepath = make_filepath (filepath = filepath )
143- with open (filepath , 'wb' ) as file :
144- self .to_html_stream (file , local = local , canvas_id = canvas_id , version = version )
143+ with open (filepath , 'w' , encoding = "utf-8" ) as file :
144+ self .to_html_stream (file , debug_mode = debug_mode , canvas_id = canvas_id , version = version )
145145 return filepath
146146
147147 def plot_data (self , ** kwargs ):
@@ -152,13 +152,21 @@ def plot(self, filepath: str = None, **kwargs):
152152 webbrowser .open ('file://' + os .path .realpath (filepath ))
153153
154154
155- class Sample (PlotDataObject ):
155+ class ReferencedObject (PlotDataObject ):
156+ """ PlotData object with reference_path. """
157+
158+ def __init__ (self , type_ : str , reference_path : str = "#" , name : str = "" ):
159+ self .reference_path = reference_path
160+ super ().__init__ (type_ = type_ , name = name )
161+
162+
163+ class Sample (ReferencedObject ):
156164 """ Graph Point. """
157165
158166 def __init__ (self , values , reference_path : str = "#" , name : str = "" ):
159167 self .values = values
160168 self .reference_path = reference_path
161- super ().__init__ (type_ = "sample" , name = name )
169+ super ().__init__ (type_ = "sample" , reference_path = reference_path , name = name )
162170
163171 def to_dict (self , use_pointers : bool = True , memo = None , path : str = '#' , id_method = True ,
164172 id_memo = None ) -> JsonSerializable :
@@ -419,7 +427,7 @@ def __init__(self, point_color: str, point_index: List[int], name: str = ''):
419427 PlotDataObject .__init__ (self , type_ = None , name = name )
420428
421429
422- class Text (PlotDataObject ):
430+ class Text (ReferencedObject ):
423431 """
424432 A class for displaying texts on canvas. Text is a primitive and can be instantiated by PrimitiveGroup.
425433
@@ -443,7 +451,7 @@ class Text(PlotDataObject):
443451
444452 def __init__ (self , comment : str , position_x : float , position_y : float , text_style : TextStyle = None ,
445453 text_scaling : bool = None , max_width : float = None , height : float = None , multi_lines : bool = True ,
446- name : str = '' ):
454+ reference_path : str = "#" , name : str = '' ):
447455 self .comment = comment
448456 self .text_style = text_style
449457 self .position_x = position_x
@@ -452,7 +460,7 @@ def __init__(self, comment: str, position_x: float, position_y: float, text_styl
452460 self .max_width = max_width
453461 self .height = height
454462 self .multi_lines = multi_lines
455- PlotDataObject .__init__ (self , type_ = 'text' , name = name )
463+ super () .__init__ (type_ = 'text' , reference_path = reference_path , name = name )
456464
457465 def mpl_plot (self , ax = None , color = 'k' , alpha = 1. , ** kwargs ):
458466 """ Plots using Matplotlib. """
@@ -462,7 +470,7 @@ def mpl_plot(self, ax=None, color='k', alpha=1., **kwargs):
462470 return ax
463471
464472
465- class Line2D (PlotDataObject ):
473+ class Line2D (ReferencedObject ):
466474 """
467475 An infinite line. Line2D is a primitive and can be instantiated by PrimitiveGroups.
468476
@@ -474,12 +482,13 @@ class Line2D(PlotDataObject):
474482 :type edge_style: EdgeStyle
475483 """
476484
477- def __init__ (self , point1 : List [float ], point2 : List [float ], edge_style : EdgeStyle = None , name : str = '' ):
485+ def __init__ (self , point1 : List [float ], point2 : List [float ], edge_style : EdgeStyle = None ,
486+ reference_path : str = "#" , name : str = '' ):
478487 self .data = point1 + point2 # Retrocompatibility
479488 self .point1 = point1
480489 self .point2 = point2
481490 self .edge_style = edge_style
482- PlotDataObject .__init__ (self , type_ = 'line2d' , name = name )
491+ super () .__init__ (type_ = 'line2d' , reference_path = reference_path , name = name )
483492
484493 def mpl_plot (self , ax = None , edge_style = None , ** kwargs ):
485494 """ Plots using matplotlib. """
@@ -497,7 +506,7 @@ def mpl_plot(self, ax=None, edge_style=None, **kwargs):
497506 return ax
498507
499508
500- class LineSegment2D (PlotDataObject ):
509+ class LineSegment2D (ReferencedObject ):
501510 """
502511 A line segment. This is a primitive that can be called by PrimitiveGroup.
503512
@@ -509,7 +518,8 @@ class LineSegment2D(PlotDataObject):
509518 :type edge_style: EdgeStyle
510519 """
511520
512- def __init__ (self , point1 : List [float ], point2 : List [float ], edge_style : EdgeStyle = None , name : str = '' ):
521+ def __init__ (self , point1 : List [float ], point2 : List [float ], edge_style : EdgeStyle = None ,
522+ reference_path : str = "#" , name : str = '' ):
513523 # Data is used in typescript
514524 self .data = point1 + point2
515525 self .point1 = point1
@@ -519,7 +529,7 @@ def __init__(self, point1: List[float], point2: List[float], edge_style: EdgeSty
519529 self .edge_style = EdgeStyle ()
520530 else :
521531 self .edge_style = edge_style
522- PlotDataObject .__init__ (self , type_ = 'linesegment2d' , name = name )
532+ super () .__init__ (type_ = 'linesegment2d' , reference_path = reference_path , name = name )
523533
524534 def bounding_box (self ):
525535 """ Get 2D bounding box of current LineSegment2D. """
@@ -547,7 +557,7 @@ def mpl_plot(self, ax=None, edge_style=None, **kwargs):
547557 return ax
548558
549559
550- class Wire (PlotDataObject ):
560+ class Wire (ReferencedObject ):
551561 """
552562 A set of connected lines. It also provides highlighting feature.
553563
@@ -560,11 +570,11 @@ class Wire(PlotDataObject):
560570 """
561571
562572 def __init__ (self , lines : List [Tuple [float , float ]], edge_style : EdgeStyle = None , tooltip : str = None ,
563- name : str = "" ):
573+ reference_path : str = "#" , name : str = "" ):
564574 self .lines = lines
565575 self .edge_style = edge_style
566576 self .tooltip = tooltip
567- PlotDataObject .__init__ (self , type_ = "wire" , name = name )
577+ super () .__init__ (type_ = "wire" , reference_path = reference_path , name = name )
568578
569579 def mpl_plot (self , ax = None , ** kwargs ):
570580 """ Plots using matplotlib. """
@@ -579,7 +589,7 @@ def mpl_plot(self, ax=None, **kwargs):
579589 return ax
580590
581591
582- class Circle2D (PlotDataObject ):
592+ class Circle2D (ReferencedObject ):
583593 """
584594 A circle. It is a primitive and can be instantiated by PrimitiveGroup.
585595
@@ -598,14 +608,14 @@ class Circle2D(PlotDataObject):
598608 """
599609
600610 def __init__ (self , cx : float , cy : float , r : float , edge_style : EdgeStyle = None ,
601- surface_style : SurfaceStyle = None , tooltip : str = None , name : str = '' ):
611+ surface_style : SurfaceStyle = None , tooltip : str = None , reference_path : str = "#" , name : str = '' ):
602612 self .edge_style = edge_style
603613 self .surface_style = surface_style
604614 self .r = r
605615 self .cx = cx
606616 self .cy = cy
607617 self .tooltip = tooltip
608- PlotDataObject .__init__ (self , type_ = 'circle' , name = name )
618+ super () .__init__ (type_ = 'circle' , reference_path = reference_path , name = name )
609619
610620 def bounding_box (self ):
611621 """ Get 2D bounding box of current Circle2D. """
@@ -635,19 +645,19 @@ def mpl_plot(self, ax=None, **kwargs):
635645 return ax
636646
637647
638- class Rectangle (PlotDataObject ):
648+ class Rectangle (ReferencedObject ):
639649 """ Class to draw a rectangle. """
640650
641651 def __init__ (self , x_coord : float , y_coord : float , width : float , height : float , edge_style : EdgeStyle = None ,
642- surface_style : SurfaceStyle = None , tooltip : str = None , name : str = '' ):
652+ surface_style : SurfaceStyle = None , tooltip : str = None , reference_path : str = "#" , name : str = '' ):
643653 self .x_coord = x_coord
644654 self .y_coord = y_coord
645655 self .width = width
646656 self .height = height
647657 self .surface_style = surface_style
648658 self .edge_style = edge_style
649659 self .tooltip = tooltip
650- PlotDataObject .__init__ (self , type_ = 'rectangle' , name = name )
660+ super () .__init__ (type_ = 'rectangle' , reference_path = reference_path , name = name )
651661
652662 def bounding_box (self ):
653663 """ Get 2D bounding box of current Circle2D. """
@@ -681,13 +691,15 @@ class RoundRectangle(Rectangle):
681691 """ Class to draw a round rectangle. """
682692
683693 def __init__ (self , x_coord : float , y_coord : float , width : float , height : float , radius : float = 2 ,
684- edge_style : EdgeStyle = None , surface_style : SurfaceStyle = None , tooltip : str = None , name : str = '' ):
685- super ().__init__ (x_coord , y_coord , width , height , edge_style , surface_style , tooltip , name = name )
694+ edge_style : EdgeStyle = None , surface_style : SurfaceStyle = None , tooltip : str = None ,
695+ reference_path : str = "#" , name : str = '' ):
696+ super ().__init__ (x_coord , y_coord , width , height , edge_style , surface_style , tooltip ,
697+ reference_path = reference_path , name = name )
686698 self .type_ = "roundrectangle"
687699 self .radius = radius
688700
689701
690- class Point2D (PlotDataObject ):
702+ class Point2D (ReferencedObject ):
691703 """
692704 A class for instantiating a point.
693705
@@ -699,11 +711,11 @@ class Point2D(PlotDataObject):
699711 :type point_style: PointStyle
700712 """
701713
702- def __init__ (self , cx : float , cy : float , point_style : PointStyle = None , name : str = '' ):
714+ def __init__ (self , cx : float , cy : float , point_style : PointStyle = None , reference_path : str = "#" , name : str = '' ):
703715 self .cx = cx
704716 self .cy = cy
705717 self .point_style = point_style
706- PlotDataObject .__init__ (self , type_ = 'point' , name = name )
718+ super () .__init__ (type_ = 'point' , reference_path = reference_path , name = name )
707719
708720 def bounding_box (self ):
709721 """ Get 2D bounding box of current Circle2D. """
@@ -1103,7 +1115,7 @@ def _build_multiplot(self):
11031115 for row in sample_attributes for col in sample_attributes ]
11041116
11051117
1106- class Arc2D (PlotDataObject ):
1118+ class Arc2D (ReferencedObject ):
11071119 """
11081120 A class for drawing arcs. Arc2D is a primitive and can be instantiated by PrimitiveGroup. By default,
11091121 the arc is drawn anticlockwise.
@@ -1122,25 +1134,22 @@ class Arc2D(PlotDataObject):
11221134 BSPline method. This argument is useless unless the arc2D is part of\
11231135 a Contour2D. In such case, the arc must be instantiated by volmdlr.
11241136 :type data: List[dict]
1125- :param anticlockwise: True if you want the arc the be drawn \
1126- anticlockwise, False otherwise
1127- :type anticlockwise: bool
1137+ :param clockwise: True if you want the arc the be drawn clockwise, False otherwise
1138+ :type clockwise: bool
11281139 :param edge_style: for customization
11291140 :type edge_style: EdgeStyle
11301141 """
11311142
1132- def __init__ (self , cx : float , cy : float , r : float , start_angle : float , end_angle : float , data = None ,
1133- clockwise : bool = None , edge_style : EdgeStyle = None , name : str = '' ):
1143+ def __init__ (self , cx : float , cy : float , r : float , start_angle : float , end_angle : float , clockwise : bool = None ,
1144+ edge_style : EdgeStyle = None , reference_path : str = "#" , name : str = '' ):
11341145 self .cx = cx
11351146 self .cy = cy
11361147 self .r = r
11371148 self .start_angle = start_angle
11381149 self .end_angle = end_angle
1139- self .data = data
1140- self .anticlockwise = not clockwise
11411150 self .clockwise = clockwise
11421151 self .edge_style = edge_style
1143- PlotDataObject .__init__ (self , type_ = 'arc' , name = name )
1152+ super () .__init__ (type_ = 'arc' , reference_path = reference_path , name = name )
11441153
11451154 def bounding_box (self ):
11461155 """ Get 2D bounding box of current Circle2D. """
@@ -1174,7 +1183,7 @@ def mpl_plot(self, ax=None, **kwargs):
11741183 return ax
11751184
11761185
1177- class Contour2D (PlotDataObject ):
1186+ class Contour2D (ReferencedObject ):
11781187 """
11791188 A Contour2D is a closed polygon that is formed by multiple primitives.
11801189
@@ -1190,13 +1199,13 @@ class Contour2D(PlotDataObject):
11901199 """
11911200
11921201 def __init__ (self , plot_data_primitives : List [Union [Arc2D , LineSegment2D ]], edge_style : EdgeStyle = None ,
1193- surface_style : SurfaceStyle = None , tooltip : str = None , name : str = '' ):
1202+ surface_style : SurfaceStyle = None , tooltip : str = None , reference_path : str = "#" , name : str = '' ):
11941203 self .plot_data_primitives = plot_data_primitives
11951204 self .edge_style = edge_style
11961205 self .surface_style = surface_style
11971206 self .tooltip = tooltip
11981207 self .is_filled = surface_style is not None
1199- PlotDataObject .__init__ (self , type_ = 'contour' , name = name )
1208+ super () .__init__ (type_ = 'contour' , reference_path = reference_path , name = name )
12001209
12011210 def bounding_box (self ):
12021211 """ Get 2D bounding box of current Contour2D. """
0 commit comments