svgwrite_diagram: implement the clear() method
authorAntonio Ospite <ao2@ao2.it>
Tue, 26 Jun 2018 13:45:24 +0000 (15:45 +0200)
committerAntonio Ospite <ao2@ao2.it>
Wed, 27 Jun 2018 13:16:47 +0000 (15:16 +0200)
src/diagram/svgwrite_diagram.py

index bf94541..b9e5a56 100755 (executable)
@@ -82,6 +82,15 @@ class SvgwriteDiagram(Diagram):
         self.svg = InkscapeDrawing(None, profile='full', size=(str(width) + "px", str(height) + "px"))
         self.active_group = self.svg
 
         self.svg = InkscapeDrawing(None, profile='full', size=(str(width) + "px", str(height) + "px"))
         self.active_group = self.svg
 
+    def clear(self):
+        # Reset the SVG object
+        self.svg.elements = []
+        self.svg.add(self.svg.defs)
+
+        rect = self.svg.rect((0, 0), ('100%', '100%'))
+        self._fill(rect, self.background)
+        self.svg.add(rect)
+
     def save_svg(self, filename):
         self.svg.saveas(filename)
 
     def save_svg(self, filename):
         self.svg.saveas(filename)