Skip to content

Commit

Permalink
Merge pull request #384 from Dessia-tech/dev
Browse files Browse the repository at this point in the history
v0.25.0
  • Loading branch information
Tanguylo authored May 28, 2024
2 parents 5dd2b86 + a299f28 commit 3c6dec0
Show file tree
Hide file tree
Showing 13 changed files with 144 additions and 84 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.25.0]
### Add
- Shapes: all shapes can now be set as not interacting with mouse
-
### Fix
- Text: Fix text drawing when font is less than 1

## [0.24.0]
### Add
- Allow to directly specify if axes are on or off in Python
Expand Down
2 changes: 1 addition & 1 deletion code_pylint.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
'trailing-whitespace': 11,
'empty-docstring': 7,
'missing-module-docstring': 4,
'too-many-arguments': 24,
'too-many-arguments': 25,
'too-few-public-methods': 5,
'unnecessary-comprehension': 5,
'no-value-for-parameter': 2,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 47 additions & 29 deletions plot_data/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ def __init__(self, type_: str, reference_path: str = "#", name: str = ""):
class Shape(ReferencedObject):
""" Shape object. """

def __init__(self, type_: str, reference_path: str = "#", tooltip: str = None, name: str = ""):
def __init__(self, type_: str, reference_path: str = "#", tooltip: str = None, interactive: bool = True,
name: str = ""):
self.tooltip = tooltip
self.interactive = interactive
super().__init__(type_=type_, reference_path=reference_path, name=name)


Expand Down Expand Up @@ -459,7 +461,7 @@ class Text(Shape):

def __init__(self, comment: str, position_x: float, position_y: float, text_style: TextStyle = None,
text_scaling: bool = None, max_width: float = None, height: float = None, multi_lines: bool = True,
reference_path: str = "#", tooltip: str = None, name: str = ''):
reference_path: str = "#", tooltip: str = None, interactive: bool = False, name: str = ''):
self.comment = comment
self.text_style = text_style
self.position_x = position_x
Expand All @@ -468,7 +470,8 @@ def __init__(self, comment: str, position_x: float, position_y: float, text_styl
self.max_width = max_width
self.height = height
self.multi_lines = multi_lines
super().__init__(type_='text', reference_path=reference_path, tooltip=tooltip, name=name)
super().__init__(type_='text', reference_path=reference_path, tooltip=tooltip, interactive=interactive,
name=name)

def mpl_plot(self, ax=None, color='k', alpha=1., **kwargs):
""" Plots using Matplotlib. """
Expand All @@ -491,12 +494,13 @@ class Line2D(Shape):
"""

def __init__(self, point1: List[float], point2: List[float], edge_style: EdgeStyle = None,
reference_path: str = "#", tooltip: str = None, name: str = ''):
reference_path: str = "#", tooltip: str = None, interactive: bool = True, name: str = ''):
self.data = point1 + point2 # Retrocompatibility
self.point1 = point1
self.point2 = point2
self.edge_style = edge_style
super().__init__(type_='line2d', reference_path=reference_path, tooltip=tooltip, name=name)
super().__init__(type_='line2d', reference_path=reference_path, tooltip=tooltip, interactive=interactive,
name=name)

def mpl_plot(self, ax=None, edge_style=None, **kwargs):
""" Plots using matplotlib. """
Expand Down Expand Up @@ -526,7 +530,7 @@ class LineSegment2D(Shape):
"""

def __init__(self, point1: List[float], point2: List[float], edge_style: EdgeStyle = None,
reference_path: str = "#", tooltip: str = None, name: str = ''):
reference_path: str = "#", tooltip: str = None, interactive: bool = True, name: str = ''):
# Data is used in typescript
self.data = point1 + point2
self.point1 = point1
Expand All @@ -535,7 +539,8 @@ def __init__(self, point1: List[float], point2: List[float], edge_style: EdgeSty
if edge_style is None:
edge_style = EdgeStyle()
self.edge_style = edge_style
super().__init__(type_='linesegment2d', reference_path=reference_path, tooltip=tooltip, name=name)
super().__init__(type_='linesegment2d', reference_path=reference_path, tooltip=tooltip, interactive=interactive,
name=name)

def bounding_box(self):
""" Get 2D bounding box of current LineSegment2D. """
Expand Down Expand Up @@ -577,10 +582,11 @@ class Wire(Shape):
"""

def __init__(self, lines: List[Tuple[float, float]], edge_style: EdgeStyle = None, tooltip: str = None,
reference_path: str = "#", name: str = ""):
reference_path: str = "#", interactive: bool = True, name: str = ""):
self.lines = lines
self.edge_style = edge_style
super().__init__(type_="wire", reference_path=reference_path, tooltip=tooltip, name=name)
super().__init__(type_="wire", reference_path=reference_path, tooltip=tooltip, interactive=interactive,
name=name)

def mpl_plot(self, ax=None, **kwargs):
""" Plots using matplotlib. """
Expand Down Expand Up @@ -614,13 +620,15 @@ class Circle2D(Shape):
"""

def __init__(self, cx: float, cy: float, r: float, edge_style: EdgeStyle = None,
surface_style: SurfaceStyle = None, tooltip: str = None, reference_path: str = "#", name: str = ''):
surface_style: SurfaceStyle = None, tooltip: str = None, reference_path: str = "#",
interactive: bool = True, name: str = ''):
self.edge_style = edge_style
self.surface_style = surface_style
self.r = r
self.cx = cx
self.cy = cy
super().__init__(type_='circle', reference_path=reference_path, tooltip=tooltip, name=name)
super().__init__(type_='circle', reference_path=reference_path, tooltip=tooltip, interactive=interactive,
name=name)

def bounding_box(self):
""" Get 2D bounding box of current Circle2D. """
Expand Down Expand Up @@ -653,14 +661,16 @@ class Rectangle(Shape):
""" Class to draw a rectangle. """

def __init__(self, x_coord: float, y_coord: float, width: float, height: float, edge_style: EdgeStyle = None,
surface_style: SurfaceStyle = None, tooltip: str = None, reference_path: str = "#", name: str = ''):
surface_style: SurfaceStyle = None, tooltip: str = None, reference_path: str = "#",
interactive: bool = True, name: str = ''):
self.x_coord = x_coord
self.y_coord = y_coord
self.width = width
self.height = height
self.surface_style = surface_style
self.edge_style = edge_style
super().__init__(type_='rectangle', reference_path=reference_path, tooltip=tooltip, name=name)
super().__init__(type_='rectangle', reference_path=reference_path, tooltip=tooltip, interactive=interactive,
name=name)

def bounding_box(self):
""" Get 2D bounding box of current Circle2D. """
Expand Down Expand Up @@ -694,9 +704,9 @@ class RoundRectangle(Rectangle):

def __init__(self, x_coord: float, y_coord: float, width: float, height: float, radius: float = 2,
edge_style: EdgeStyle = None, surface_style: SurfaceStyle = None, tooltip: str = None,
reference_path: str = "#", name: str = ''):
reference_path: str = "#", interactive: bool = True, name: str = ''):
super().__init__(x_coord, y_coord, width, height, edge_style, surface_style, tooltip,
reference_path=reference_path, name=name)
reference_path=reference_path, interactive=interactive, name=name)
self.type_ = "roundrectangle"
self.radius = radius

Expand All @@ -714,11 +724,12 @@ class Point2D(Shape):
"""

def __init__(self, cx: float, cy: float, point_style: PointStyle = None, reference_path: str = "#",
tooltip: str = None, name: str = ''):
tooltip: str = None, interactive: bool = True, name: str = ''):
self.cx = cx
self.cy = cy
self.point_style = point_style
super().__init__(type_='point', reference_path=reference_path, tooltip=tooltip, name=name)
super().__init__(type_='point', reference_path=reference_path, tooltip=tooltip,
interactive=interactive, name=name)

def bounding_box(self):
""" Get 2D bounding box of current Circle2D. """
Expand Down Expand Up @@ -1145,15 +1156,17 @@ class Arc2D(Shape):
"""

def __init__(self, cx: float, cy: float, r: float, start_angle: float, end_angle: float, clockwise: bool = None,
edge_style: EdgeStyle = None, reference_path: str = "#", tooltip: str = None, name: str = ''):
edge_style: EdgeStyle = None, reference_path: str = "#", tooltip: str = None, interactive: bool = True,
name: str = ''):
self.cx = cx
self.cy = cy
self.r = r
self.start_angle = start_angle
self.end_angle = end_angle
self.clockwise = clockwise
self.edge_style = edge_style
super().__init__(type_='arc', reference_path=reference_path, tooltip=tooltip, name=name)
super().__init__(type_='arc', reference_path=reference_path, tooltip=tooltip, interactive=interactive,
name=name)

def bounding_box(self):
""" Get 2D bounding box of current Circle2D. """
Expand Down Expand Up @@ -1206,12 +1219,14 @@ class Contour2D(Shape):
"""

def __init__(self, plot_data_primitives: List[Union[Arc2D, LineSegment2D]], edge_style: EdgeStyle = None,
surface_style: SurfaceStyle = None, tooltip: str = None, reference_path: str = "#", name: str = ''):
surface_style: SurfaceStyle = None, tooltip: str = None, reference_path: str = "#",
interactive: bool = True, name: str = ''):
self.plot_data_primitives = plot_data_primitives
self.edge_style = edge_style
self.surface_style = surface_style
self.is_filled = surface_style is not None
super().__init__(type_='contour', reference_path=reference_path, tooltip=tooltip, name=name)
super().__init__(type_='contour', reference_path=reference_path, tooltip=tooltip, interactive=interactive,
name=name)

def bounding_box(self):
""" Get 2D bounding box of current Contour2D. """
Expand Down Expand Up @@ -1264,13 +1279,14 @@ class Label(PlotDataObject):
"""

def __init__(self, title: str, text_style: TextStyle = None, rectangle_surface_style: SurfaceStyle = None,
rectangle_edge_style: EdgeStyle = None, shape: PlotDataObject = None, name: str = ''):
rectangle_edge_style: EdgeStyle = None, shape: PlotDataObject = None, interactive: bool = False,
name: str = ''):
self.title = title
self.text_style = text_style
self.rectangle_surface_style = rectangle_surface_style
self.rectangle_edge_style = rectangle_edge_style
self.shape = shape
PlotDataObject.__init__(self, type_='label', name=name)
PlotDataObject.__init__(self, type_='label', interactive=interactive, name=name)


class MultipleLabels(PlotDataObject):
Expand All @@ -1281,9 +1297,9 @@ class MultipleLabels(PlotDataObject):
:type labels: List[Label]
"""

def __init__(self, labels: List[Label], name: str = ''):
def __init__(self, labels: List[Label], interactive: bool = False, name: str = ''):
self.labels = labels
PlotDataObject.__init__(self, type_='multiplelabels', name=name)
PlotDataObject.__init__(self, type_='multiplelabels', interactive=interactive, name=name)


class PrimitiveGroup(Figure):
Expand All @@ -1301,10 +1317,11 @@ class PrimitiveGroup(Figure):

def __init__(self, primitives: List[Union[Contour2D, Arc2D, LineSegment2D, Circle2D,
Line2D, MultipleLabels, Wire, Point2D]], width: int = 750,
height: int = 400, attribute_names: List[str] = None, axis_on: bool = False, name: str = ''):
height: int = 400, attribute_names: List[str] = None, axis_on: bool = False, interactive: bool = True,
name: str = ''):
self.primitives = primitives
self.attribute_names = attribute_names
super().__init__(width=width, height=height, type_='draw', axis_on=axis_on, name=name)
super().__init__(width=width, height=height, type_='draw', axis_on=axis_on, interactive=interactive, name=name)

def mpl_plot(self, ax=None, equal_aspect=True, **kwargs):
""" Plots using matplotlib. """
Expand Down Expand Up @@ -1363,7 +1380,7 @@ class PrimitiveGroupsContainer(Figure):
def __init__(self, primitive_groups: List[PrimitiveGroup], sizes: List[Tuple[float, float]] = None,
coords: List[Tuple[float, float]] = None, associated_elements: List[int] = None,
x_variable: str = None, y_variable: str = None, width: int = 750, height: int = 400,
axis_on: bool = True, name: str = ''):
axis_on: bool = True, interactive: bool = True, name: str = ''):
for i, value in enumerate(primitive_groups):
if not isinstance(value, PrimitiveGroup):
primitive_groups[i] = PrimitiveGroup(primitives=value)
Expand All @@ -1381,7 +1398,8 @@ def __init__(self, primitive_groups: List[PrimitiveGroup], sizes: List[Tuple[flo
if y_variable:
attribute_names.append(y_variable)
self.association['attribute_names'] = attribute_names
super().__init__(width=width, height=height, type_='primitivegroupcontainer', axis_on=axis_on, name=name)
super().__init__(width=width, height=height, type_='primitivegroupcontainer', axis_on=axis_on,
interactive=interactive, name=name)


class ParallelPlot(Figure):
Expand Down
9 changes: 5 additions & 4 deletions script/test_objects/primitive_group_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@
points_text_shapes = plot_data.Text(comment="Shapes: ", text_scaling=True, position_x=24, position_y=37.2, text_style=title_style)

# Arcs
circle = plot_data.Circle2D(cx=31, cy=10.5, r=5, edge_style=edge_style_red, surface_style=surface_style_yellow, tooltip="It's a circle")
circle = plot_data.Circle2D(cx=31, cy=10.5, r=5, edge_style=edge_style_red, surface_style=surface_style_yellow, tooltip="It's a circle", interactive=False)
arc = plot_data.Arc2D(cx=43, cy=10.5, r=5, start_angle=math.pi/4, end_angle=2*math.pi/3, edge_style=edge_style_red, clockwise=True, tooltip="arc2d")
arc_anti = plot_data.Arc2D(cx=43, cy=10.5, r=5, start_angle=math.pi/4, end_angle=2*math.pi/3, edge_style=edge_style_blue, clockwise=False, tooltip="arc2d_anticlockwise")
line_segment_1 = plot_data.LineSegment2D(point1=[50, 1], point2=[53, 20], edge_style=edge_style_black, tooltip="linesegment")
line_segment_1 = plot_data.LineSegment2D(point1=[50, 1], point2=[53, 20], edge_style=edge_style_black, tooltip="linesegment", interactive=False)
line_segment_2 = plot_data.LineSegment2D(point1=[75, 20], point2=[78, 1], edge_style=edge_style_black, tooltip="linesegment")
rectangle = plot_data.Rectangle(57, 26, 25, 9, surface_style=surface_style_green, edge_style=edge_style_red, tooltip="rectangle")
rectangle = plot_data.Rectangle(57, 26, 25, 9, surface_style=surface_style_green, edge_style=edge_style_red, tooltip="rectangle", interactive=False)

# Contours
star_lines_closed = [plot_data.LineSegment2D([57, 1.5], [60, 8.5]),
Expand All @@ -87,7 +87,8 @@

contour_filled = plot_data.Contour2D(plot_data_primitives=star_lines_closed, edge_style=edge_style_blue,
surface_style=surface_style_green,
tooltip="It looks like a green star but it is a contour.")
tooltip="It looks like a green star but it is a contour.",
interactive=False)
contour_empty = plot_data.Contour2D(plot_data_primitives=polygon_lines_open, edge_style=edge_style_purple_plain,
tooltip="It is a Contour with no filling.")

Expand Down
Loading

0 comments on commit 3c6dec0

Please sign in to comment.