From c6a1cffdd8ba91a96bf8dacc6695cb5f8e1b1fe9 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Thu, 15 Apr 2021 12:35:48 -0700 Subject: [PATCH 1/5] use draw_marker_at_points if we have the marker, other wise fall back to draw_path_at_points --- chaco/colormapped_scatterplot.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/chaco/colormapped_scatterplot.py b/chaco/colormapped_scatterplot.py index 66896a84d..3b2a39040 100644 --- a/chaco/colormapped_scatterplot.py +++ b/chaco/colormapped_scatterplot.py @@ -398,8 +398,13 @@ def _render_bruteforce(self, gc, points): gc, "draw_marker_at_points" ) and self.marker not in ( "custom", - "circle", - "diamond", + "left_triangle", + "right_triangle", + "pentagon", + "hexagon", + "hexagon2", + "star", + "cross_plus" ): draw_func = lambda x, y, size: gc.draw_marker_at_points( [[x, y]], size, marker_cls.kiva_marker From bcf8a13b0a3104af63efb283227a34a14fc49c98 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Thu, 15 Apr 2021 12:36:52 -0700 Subject: [PATCH 2/5] same change in _render_banded --- chaco/colormapped_scatterplot.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/chaco/colormapped_scatterplot.py b/chaco/colormapped_scatterplot.py index 3b2a39040..247c43d67 100644 --- a/chaco/colormapped_scatterplot.py +++ b/chaco/colormapped_scatterplot.py @@ -317,8 +317,13 @@ def _render_banded(self, gc, points): if hasattr(gc, "draw_marker_at_points") and self.marker not in ( "custom", - "circle", - "diamond", + "left_triangle", + "right_triangle", + "pentagon", + "hexagon", + "hexagon2", + "star", + "cross_plus" ): # This is the fastest method: we use one of the built-in markers. color_bands = cmap.color_bands From b9c5beb095f56575c73016190d3cdf2f901067d1 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Thu, 15 Apr 2021 12:49:07 -0700 Subject: [PATCH 3/5] make the fix moer robust --- chaco/colormapped_scatterplot.py | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/chaco/colormapped_scatterplot.py b/chaco/colormapped_scatterplot.py index 247c43d67..a7e83fd07 100644 --- a/chaco/colormapped_scatterplot.py +++ b/chaco/colormapped_scatterplot.py @@ -17,7 +17,7 @@ ) # Enthought library imports -from kiva.constants import STROKE +from kiva.api import NO_MARKER, STROKE from traits.api import Dict, Enum, Float, Instance, observe from traitsui.api import Item, RangeEditor @@ -315,16 +315,8 @@ def _render_banded(self, gc, points): cmap = self.color_mapper - if hasattr(gc, "draw_marker_at_points") and self.marker not in ( - "custom", - "left_triangle", - "right_triangle", - "pentagon", - "hexagon", - "hexagon2", - "star", - "cross_plus" - ): + if hasattr(gc, "draw_marker_at_points") and \ + (marker.kiva_marker != NO_MARKER): # This is the fastest method: we use one of the built-in markers. color_bands = cmap.color_bands # Initial setup of drawing parameters @@ -401,16 +393,7 @@ def _render_bruteforce(self, gc, points): if marker_cls != "custom": if hasattr( gc, "draw_marker_at_points" - ) and self.marker not in ( - "custom", - "left_triangle", - "right_triangle", - "pentagon", - "hexagon", - "hexagon2", - "star", - "cross_plus" - ): + ) and marker_cls.kiva_marker != NO_MARKER: draw_func = lambda x, y, size: gc.draw_marker_at_points( [[x, y]], size, marker_cls.kiva_marker ) From 7f6542432b4aeb27d7912c140f9278e4de7ce92f Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Fri, 16 Apr 2021 08:24:05 -0700 Subject: [PATCH 4/5] fix test_scatter_custom --- chaco/colormapped_scatterplot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chaco/colormapped_scatterplot.py b/chaco/colormapped_scatterplot.py index a7e83fd07..085cd8a13 100644 --- a/chaco/colormapped_scatterplot.py +++ b/chaco/colormapped_scatterplot.py @@ -390,7 +390,7 @@ def _render_bruteforce(self, gc, points): marker_size = marker_size[self._cached_point_mask] mode = marker_cls.draw_mode - if marker_cls != "custom": + if self.marker != "custom": if hasattr( gc, "draw_marker_at_points" ) and marker_cls.kiva_marker != NO_MARKER: @@ -427,7 +427,7 @@ def draw_func(x, y, size): draw_func(x[i], y[i], size) else: - path = marker_cls.custom_symbol + path = self.custom_symbol for i in range(len(x)): gc.set_fill_color(colors[i]) gc.draw_path_at_points([[x[i], y[i]]], path, STROKE) From 2013ec06ac5977215c9d96be8f341c68638a221c Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Fri, 16 Apr 2021 08:29:45 -0700 Subject: [PATCH 5/5] add a regression test --- chaco/tests/test_colormapped_scatterplot.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/chaco/tests/test_colormapped_scatterplot.py b/chaco/tests/test_colormapped_scatterplot.py index 63fe1599c..3adf8a9c1 100644 --- a/chaco/tests/test_colormapped_scatterplot.py +++ b/chaco/tests/test_colormapped_scatterplot.py @@ -86,3 +86,11 @@ def test_colormap_updated(self): """ If colormapper updated then we need to redraw """ self.color_mapper.updated = True self.assertFalse(self.scatterplot.draw_valid) + + # regression test for enthought/chaco#425 + def test_non_kiva_marker(self): + self.scatterplot.marker = "star" + + self.gc.render_component(self.scatterplot) + actual = self.gc.bmp_array[:, :, :] + self.assertFalse(alltrue(actual == 255))