From ccee6134bba6f7ede8681a0e3a84615f1ebc4bae Mon Sep 17 00:00:00 2001 From: fruchti Date: Sat, 17 Dec 2022 20:12:21 +0100 Subject: [PATCH] Allow layer switch directly from MultiPlotter --- lib/plot.py | 51 ++++++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/lib/plot.py b/lib/plot.py index 6fddd06..68b0c69 100644 --- a/lib/plot.py +++ b/lib/plot.py @@ -120,29 +120,6 @@ A4_PORTRAIT = Paper(210, 297, 20) A6_PORTRAIT = Paper(105, 148, 8) -class MultiPlotter: - def __init__(self): - self.plotters = [] - - def move_to(self, point): - for plotter in self.plotters: - plotter.move_to(point) - - def line_to(self, point): - for plotter in self.plotters: - plotter.line_to(point) - - def add_layer(self, *args, **kwargs): - for plotter in self.plotters: - plotter.add_layer(*args, **kwargs) - - def finalise(self): - for plotter in self.plotters: - plotter.finalise() - - def register_plotter(self, plotter): - self.plotters.append(plotter) - class Plotter: @@ -286,3 +263,31 @@ class HPGLPlotter(Plotter): for i in range(len(self.layers)): with open(self._layer_file_name(i), 'at') as file: file.write(';PU0,0;IN') + + +class MultiPlotter(Plotter): + def __init__(self): + self.plotters = [] + + def move_to(self, point): + for plotter in self.plotters: + plotter.move_to(point) + + def line_to(self, point): + for plotter in self.plotters: + plotter.line_to(point) + + def add_layer(self, *args, **kwargs): + for plotter in self.plotters: + plotter.add_layer(*args, **kwargs) + + def switch_layers(self, *args, **kwargs): + for plotter in self.plotters: + plotter.switch_layers(*args, **kwargs) + + def finalise(self): + for plotter in self.plotters: + plotter.finalise() + + def register_plotter(self, plotter): + self.plotters.append(plotter) \ No newline at end of file