From edb8ff3f48148bd120e68048bcc28885f6db1883 Mon Sep 17 00:00:00 2001 From: Poruri Sai Rahul Date: Mon, 7 Jun 2021 16:45:13 +0530 Subject: [PATCH 1/4] REF : Redefine container_under_layers in OverlayPlotContainer the trait is already defined in BasePlotContainer but we redefine it in the subclass so that we can eventually stop inheriting from it modified: chaco/plot_containers.py --- chaco/plot_containers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/chaco/plot_containers.py b/chaco/plot_containers.py index 179467db1..e847c431d 100644 --- a/chaco/plot_containers.py +++ b/chaco/plot_containers.py @@ -102,6 +102,10 @@ class OverlayPlotContainer(BasePlotContainer): # Cache (width, height) of the container's preferred size. _cached_preferred_size = Tuple + #: Redefine the container layers to name the main layer as "plot" instead + #: of the Enable default of "mainlayer" + container_under_layers = Tuple("background", "image", "underlay", "plot") + def get_preferred_size(self, components=None): """Returns the size (width,height) that is preferred for this component. From 95269b1914c5a76d638481cdbeb37f1dcc9cc85b Mon Sep 17 00:00:00 2001 From: Poruri Sai Rahul Date: Mon, 7 Jun 2021 16:46:38 +0530 Subject: [PATCH 2/4] REF : Redefine draw_layer trait in subclass like before, this trait is already defined in BasePlotContainer but we duplicate it in the subclass so that we can stop inheriting from BasePlotContainer modified: chaco/plot_containers.py --- chaco/plot_containers.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/chaco/plot_containers.py b/chaco/plot_containers.py index e847c431d..e05136024 100644 --- a/chaco/plot_containers.py +++ b/chaco/plot_containers.py @@ -33,6 +33,7 @@ Instance, List, Property, + Str, String, Trait, Tuple, @@ -106,6 +107,8 @@ class OverlayPlotContainer(BasePlotContainer): #: of the Enable default of "mainlayer" container_under_layers = Tuple("background", "image", "underlay", "plot") + draw_layer = Str("plot") + def get_preferred_size(self, components=None): """Returns the size (width,height) that is preferred for this component. From 5ca52e3a2b3ffa5a490e26db6be5fbeda0c307ca Mon Sep 17 00:00:00 2001 From: Poruri Sai Rahul Date: Mon, 7 Jun 2021 16:48:19 +0530 Subject: [PATCH 3/4] REF : Stop inheriting from BasePlotContainer all of the traits defined in BasePlotContainer have been redefined in OverlayPlotContainer. so OverlayPlotContainer can just inherit from Container directly modified: chaco/plot_containers.py --- chaco/plot_containers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chaco/plot_containers.py b/chaco/plot_containers.py index e05136024..8582df3c9 100644 --- a/chaco/plot_containers.py +++ b/chaco/plot_containers.py @@ -39,6 +39,7 @@ Tuple, Int, ) +from enable.api import Container from enable.simple_layout import ( simple_container_get_preferred_size, simple_container_do_layout, @@ -89,7 +90,7 @@ class ConstraintsPlotContainer(ConstraintsContainer): __all__.append("ConstraintsPlotContainer") -class OverlayPlotContainer(BasePlotContainer): +class OverlayPlotContainer(Container): """ A plot container that stretches all its components to fit within its space. All of its components must therefore be resizable. From 6605e872287b46bb736a2ced3902ce9e9540fbc7 Mon Sep 17 00:00:00 2001 From: Poruri Sai Rahul Date: Mon, 7 Jun 2021 16:50:58 +0530 Subject: [PATCH 4/4] REF : Make OverlayPlotContainer inherit from enable OverlayContainer and remove the now redundant definitions of the methods get_preferred_size and _do_layout modified: chaco/plot_containers.py --- chaco/plot_containers.py | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/chaco/plot_containers.py b/chaco/plot_containers.py index 8582df3c9..6ec2d0b79 100644 --- a/chaco/plot_containers.py +++ b/chaco/plot_containers.py @@ -39,11 +39,7 @@ Tuple, Int, ) -from enable.api import Container -from enable.simple_layout import ( - simple_container_get_preferred_size, - simple_container_do_layout, -) +from enable.api import OverlayContainer try: from enable.api import ConstraintsContainer @@ -90,7 +86,7 @@ class ConstraintsPlotContainer(ConstraintsContainer): __all__.append("ConstraintsPlotContainer") -class OverlayPlotContainer(Container): +class OverlayPlotContainer(OverlayContainer): """ A plot container that stretches all its components to fit within its space. All of its components must therefore be resizable. @@ -110,17 +106,6 @@ class OverlayPlotContainer(Container): draw_layer = Str("plot") - def get_preferred_size(self, components=None): - """Returns the size (width,height) that is preferred for this component. - - Overrides PlotComponent - """ - return simple_container_get_preferred_size(self, components=components) - - def _do_layout(self): - """Actually performs a layout (called by do_layout()).""" - simple_container_do_layout(self) - class StackedPlotContainer(BasePlotContainer): """