Skip to content

Commit 3c6dec0

Browse files
authored
Merge pull request #384 from Dessia-tech/dev
v0.25.0
2 parents 5dd2b86 + a299f28 commit 3c6dec0

13 files changed

+144
-84
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.25.0]
9+
### Add
10+
- Shapes: all shapes can now be set as not interacting with mouse
11+
-
12+
### Fix
13+
- Text: Fix text drawing when font is less than 1
14+
815
## [0.24.0]
916
### Add
1017
- Allow to directly specify if axes are on or off in Python

code_pylint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
'trailing-whitespace': 11,
3636
'empty-docstring': 7,
3737
'missing-module-docstring': 4,
38-
'too-many-arguments': 24,
38+
'too-many-arguments': 25,
3939
'too-few-public-methods': 5,
4040
'unnecessary-comprehension': 5,
4141
'no-value-for-parameter': 2,
Lines changed: 2 additions & 2 deletions
Loading
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading

plot_data/core.py

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,10 @@ def __init__(self, type_: str, reference_path: str = "#", name: str = ""):
164164
class Shape(ReferencedObject):
165165
""" Shape object. """
166166

167-
def __init__(self, type_: str, reference_path: str = "#", tooltip: str = None, name: str = ""):
167+
def __init__(self, type_: str, reference_path: str = "#", tooltip: str = None, interactive: bool = True,
168+
name: str = ""):
168169
self.tooltip = tooltip
170+
self.interactive = interactive
169171
super().__init__(type_=type_, reference_path=reference_path, name=name)
170172

171173

@@ -459,7 +461,7 @@ class Text(Shape):
459461

460462
def __init__(self, comment: str, position_x: float, position_y: float, text_style: TextStyle = None,
461463
text_scaling: bool = None, max_width: float = None, height: float = None, multi_lines: bool = True,
462-
reference_path: str = "#", tooltip: str = None, name: str = ''):
464+
reference_path: str = "#", tooltip: str = None, interactive: bool = False, name: str = ''):
463465
self.comment = comment
464466
self.text_style = text_style
465467
self.position_x = position_x
@@ -468,7 +470,8 @@ def __init__(self, comment: str, position_x: float, position_y: float, text_styl
468470
self.max_width = max_width
469471
self.height = height
470472
self.multi_lines = multi_lines
471-
super().__init__(type_='text', reference_path=reference_path, tooltip=tooltip, name=name)
473+
super().__init__(type_='text', reference_path=reference_path, tooltip=tooltip, interactive=interactive,
474+
name=name)
472475

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

493496
def __init__(self, point1: List[float], point2: List[float], edge_style: EdgeStyle = None,
494-
reference_path: str = "#", tooltip: str = None, name: str = ''):
497+
reference_path: str = "#", tooltip: str = None, interactive: bool = True, name: str = ''):
495498
self.data = point1 + point2 # Retrocompatibility
496499
self.point1 = point1
497500
self.point2 = point2
498501
self.edge_style = edge_style
499-
super().__init__(type_='line2d', reference_path=reference_path, tooltip=tooltip, name=name)
502+
super().__init__(type_='line2d', reference_path=reference_path, tooltip=tooltip, interactive=interactive,
503+
name=name)
500504

501505
def mpl_plot(self, ax=None, edge_style=None, **kwargs):
502506
""" Plots using matplotlib. """
@@ -526,7 +530,7 @@ class LineSegment2D(Shape):
526530
"""
527531

528532
def __init__(self, point1: List[float], point2: List[float], edge_style: EdgeStyle = None,
529-
reference_path: str = "#", tooltip: str = None, name: str = ''):
533+
reference_path: str = "#", tooltip: str = None, interactive: bool = True, name: str = ''):
530534
# Data is used in typescript
531535
self.data = point1 + point2
532536
self.point1 = point1
@@ -535,7 +539,8 @@ def __init__(self, point1: List[float], point2: List[float], edge_style: EdgeSty
535539
if edge_style is None:
536540
edge_style = EdgeStyle()
537541
self.edge_style = edge_style
538-
super().__init__(type_='linesegment2d', reference_path=reference_path, tooltip=tooltip, name=name)
542+
super().__init__(type_='linesegment2d', reference_path=reference_path, tooltip=tooltip, interactive=interactive,
543+
name=name)
539544

540545
def bounding_box(self):
541546
""" Get 2D bounding box of current LineSegment2D. """
@@ -577,10 +582,11 @@ class Wire(Shape):
577582
"""
578583

579584
def __init__(self, lines: List[Tuple[float, float]], edge_style: EdgeStyle = None, tooltip: str = None,
580-
reference_path: str = "#", name: str = ""):
585+
reference_path: str = "#", interactive: bool = True, name: str = ""):
581586
self.lines = lines
582587
self.edge_style = edge_style
583-
super().__init__(type_="wire", reference_path=reference_path, tooltip=tooltip, name=name)
588+
super().__init__(type_="wire", reference_path=reference_path, tooltip=tooltip, interactive=interactive,
589+
name=name)
584590

585591
def mpl_plot(self, ax=None, **kwargs):
586592
""" Plots using matplotlib. """
@@ -614,13 +620,15 @@ class Circle2D(Shape):
614620
"""
615621

616622
def __init__(self, cx: float, cy: float, r: float, edge_style: EdgeStyle = None,
617-
surface_style: SurfaceStyle = None, tooltip: str = None, reference_path: str = "#", name: str = ''):
623+
surface_style: SurfaceStyle = None, tooltip: str = None, reference_path: str = "#",
624+
interactive: bool = True, name: str = ''):
618625
self.edge_style = edge_style
619626
self.surface_style = surface_style
620627
self.r = r
621628
self.cx = cx
622629
self.cy = cy
623-
super().__init__(type_='circle', reference_path=reference_path, tooltip=tooltip, name=name)
630+
super().__init__(type_='circle', reference_path=reference_path, tooltip=tooltip, interactive=interactive,
631+
name=name)
624632

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

655663
def __init__(self, x_coord: float, y_coord: float, width: float, height: float, edge_style: EdgeStyle = None,
656-
surface_style: SurfaceStyle = None, tooltip: str = None, reference_path: str = "#", name: str = ''):
664+
surface_style: SurfaceStyle = None, tooltip: str = None, reference_path: str = "#",
665+
interactive: bool = True, name: str = ''):
657666
self.x_coord = x_coord
658667
self.y_coord = y_coord
659668
self.width = width
660669
self.height = height
661670
self.surface_style = surface_style
662671
self.edge_style = edge_style
663-
super().__init__(type_='rectangle', reference_path=reference_path, tooltip=tooltip, name=name)
672+
super().__init__(type_='rectangle', reference_path=reference_path, tooltip=tooltip, interactive=interactive,
673+
name=name)
664674

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

695705
def __init__(self, x_coord: float, y_coord: float, width: float, height: float, radius: float = 2,
696706
edge_style: EdgeStyle = None, surface_style: SurfaceStyle = None, tooltip: str = None,
697-
reference_path: str = "#", name: str = ''):
707+
reference_path: str = "#", interactive: bool = True, name: str = ''):
698708
super().__init__(x_coord, y_coord, width, height, edge_style, surface_style, tooltip,
699-
reference_path=reference_path, name=name)
709+
reference_path=reference_path, interactive=interactive, name=name)
700710
self.type_ = "roundrectangle"
701711
self.radius = radius
702712

@@ -714,11 +724,12 @@ class Point2D(Shape):
714724
"""
715725

716726
def __init__(self, cx: float, cy: float, point_style: PointStyle = None, reference_path: str = "#",
717-
tooltip: str = None, name: str = ''):
727+
tooltip: str = None, interactive: bool = True, name: str = ''):
718728
self.cx = cx
719729
self.cy = cy
720730
self.point_style = point_style
721-
super().__init__(type_='point', reference_path=reference_path, tooltip=tooltip, name=name)
731+
super().__init__(type_='point', reference_path=reference_path, tooltip=tooltip,
732+
interactive=interactive, name=name)
722733

723734
def bounding_box(self):
724735
""" Get 2D bounding box of current Circle2D. """
@@ -1145,15 +1156,17 @@ class Arc2D(Shape):
11451156
"""
11461157

11471158
def __init__(self, cx: float, cy: float, r: float, start_angle: float, end_angle: float, clockwise: bool = None,
1148-
edge_style: EdgeStyle = None, reference_path: str = "#", tooltip: str = None, name: str = ''):
1159+
edge_style: EdgeStyle = None, reference_path: str = "#", tooltip: str = None, interactive: bool = True,
1160+
name: str = ''):
11491161
self.cx = cx
11501162
self.cy = cy
11511163
self.r = r
11521164
self.start_angle = start_angle
11531165
self.end_angle = end_angle
11541166
self.clockwise = clockwise
11551167
self.edge_style = edge_style
1156-
super().__init__(type_='arc', reference_path=reference_path, tooltip=tooltip, name=name)
1168+
super().__init__(type_='arc', reference_path=reference_path, tooltip=tooltip, interactive=interactive,
1169+
name=name)
11571170

11581171
def bounding_box(self):
11591172
""" Get 2D bounding box of current Circle2D. """
@@ -1206,12 +1219,14 @@ class Contour2D(Shape):
12061219
"""
12071220

12081221
def __init__(self, plot_data_primitives: List[Union[Arc2D, LineSegment2D]], edge_style: EdgeStyle = None,
1209-
surface_style: SurfaceStyle = None, tooltip: str = None, reference_path: str = "#", name: str = ''):
1222+
surface_style: SurfaceStyle = None, tooltip: str = None, reference_path: str = "#",
1223+
interactive: bool = True, name: str = ''):
12101224
self.plot_data_primitives = plot_data_primitives
12111225
self.edge_style = edge_style
12121226
self.surface_style = surface_style
12131227
self.is_filled = surface_style is not None
1214-
super().__init__(type_='contour', reference_path=reference_path, tooltip=tooltip, name=name)
1228+
super().__init__(type_='contour', reference_path=reference_path, tooltip=tooltip, interactive=interactive,
1229+
name=name)
12151230

12161231
def bounding_box(self):
12171232
""" Get 2D bounding box of current Contour2D. """
@@ -1264,13 +1279,14 @@ class Label(PlotDataObject):
12641279
"""
12651280

12661281
def __init__(self, title: str, text_style: TextStyle = None, rectangle_surface_style: SurfaceStyle = None,
1267-
rectangle_edge_style: EdgeStyle = None, shape: PlotDataObject = None, name: str = ''):
1282+
rectangle_edge_style: EdgeStyle = None, shape: PlotDataObject = None, interactive: bool = False,
1283+
name: str = ''):
12681284
self.title = title
12691285
self.text_style = text_style
12701286
self.rectangle_surface_style = rectangle_surface_style
12711287
self.rectangle_edge_style = rectangle_edge_style
12721288
self.shape = shape
1273-
PlotDataObject.__init__(self, type_='label', name=name)
1289+
PlotDataObject.__init__(self, type_='label', interactive=interactive, name=name)
12741290

12751291

12761292
class MultipleLabels(PlotDataObject):
@@ -1281,9 +1297,9 @@ class MultipleLabels(PlotDataObject):
12811297
:type labels: List[Label]
12821298
"""
12831299

1284-
def __init__(self, labels: List[Label], name: str = ''):
1300+
def __init__(self, labels: List[Label], interactive: bool = False, name: str = ''):
12851301
self.labels = labels
1286-
PlotDataObject.__init__(self, type_='multiplelabels', name=name)
1302+
PlotDataObject.__init__(self, type_='multiplelabels', interactive=interactive, name=name)
12871303

12881304

12891305
class PrimitiveGroup(Figure):
@@ -1301,10 +1317,11 @@ class PrimitiveGroup(Figure):
13011317

13021318
def __init__(self, primitives: List[Union[Contour2D, Arc2D, LineSegment2D, Circle2D,
13031319
Line2D, MultipleLabels, Wire, Point2D]], width: int = 750,
1304-
height: int = 400, attribute_names: List[str] = None, axis_on: bool = False, name: str = ''):
1320+
height: int = 400, attribute_names: List[str] = None, axis_on: bool = False, interactive: bool = True,
1321+
name: str = ''):
13051322
self.primitives = primitives
13061323
self.attribute_names = attribute_names
1307-
super().__init__(width=width, height=height, type_='draw', axis_on=axis_on, name=name)
1324+
super().__init__(width=width, height=height, type_='draw', axis_on=axis_on, interactive=interactive, name=name)
13081325

13091326
def mpl_plot(self, ax=None, equal_aspect=True, **kwargs):
13101327
""" Plots using matplotlib. """
@@ -1363,7 +1380,7 @@ class PrimitiveGroupsContainer(Figure):
13631380
def __init__(self, primitive_groups: List[PrimitiveGroup], sizes: List[Tuple[float, float]] = None,
13641381
coords: List[Tuple[float, float]] = None, associated_elements: List[int] = None,
13651382
x_variable: str = None, y_variable: str = None, width: int = 750, height: int = 400,
1366-
axis_on: bool = True, name: str = ''):
1383+
axis_on: bool = True, interactive: bool = True, name: str = ''):
13671384
for i, value in enumerate(primitive_groups):
13681385
if not isinstance(value, PrimitiveGroup):
13691386
primitive_groups[i] = PrimitiveGroup(primitives=value)
@@ -1381,7 +1398,8 @@ def __init__(self, primitive_groups: List[PrimitiveGroup], sizes: List[Tuple[flo
13811398
if y_variable:
13821399
attribute_names.append(y_variable)
13831400
self.association['attribute_names'] = attribute_names
1384-
super().__init__(width=width, height=height, type_='primitivegroupcontainer', axis_on=axis_on, name=name)
1401+
super().__init__(width=width, height=height, type_='primitivegroupcontainer', axis_on=axis_on,
1402+
interactive=interactive, name=name)
13851403

13861404

13871405
class ParallelPlot(Figure):

script/test_objects/primitive_group_test.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@
6161
points_text_shapes = plot_data.Text(comment="Shapes: ", text_scaling=True, position_x=24, position_y=37.2, text_style=title_style)
6262

6363
# Arcs
64-
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")
64+
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)
6565
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")
6666
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")
67-
line_segment_1 = plot_data.LineSegment2D(point1=[50, 1], point2=[53, 20], edge_style=edge_style_black, tooltip="linesegment")
67+
line_segment_1 = plot_data.LineSegment2D(point1=[50, 1], point2=[53, 20], edge_style=edge_style_black, tooltip="linesegment", interactive=False)
6868
line_segment_2 = plot_data.LineSegment2D(point1=[75, 20], point2=[78, 1], edge_style=edge_style_black, tooltip="linesegment")
69-
rectangle = plot_data.Rectangle(57, 26, 25, 9, surface_style=surface_style_green, edge_style=edge_style_red, tooltip="rectangle")
69+
rectangle = plot_data.Rectangle(57, 26, 25, 9, surface_style=surface_style_green, edge_style=edge_style_red, tooltip="rectangle", interactive=False)
7070

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

8888
contour_filled = plot_data.Contour2D(plot_data_primitives=star_lines_closed, edge_style=edge_style_blue,
8989
surface_style=surface_style_green,
90-
tooltip="It looks like a green star but it is a contour.")
90+
tooltip="It looks like a green star but it is a contour.",
91+
interactive=False)
9192
contour_empty = plot_data.Contour2D(plot_data_primitives=polygon_lines_open, edge_style=edge_style_purple_plain,
9293
tooltip="It is a Contour with no filling.")
9394

0 commit comments

Comments
 (0)