Просмотр исходного кода

- work on ShapeCollectionLegacy

Marius Stanciu 6 лет назад
Родитель
Сommit
3f70c156a0
2 измененных файлов с 18 добавлено и 1 удалено
  1. 1 0
      README.md
  2. 17 1
      flatcamGUI/PlotCanvasLegacy.py

+ 1 - 0
README.md

@@ -17,6 +17,7 @@ CAD program, and create G-Code for Isolation routing.
 - legacy graphic engine - made the mouse cursor work (enabled/disabled, position report); snapping is not moving the cursor yet
 - legacy graphic engine - made the mouse cursor work (enabled/disabled, position report); snapping is not moving the cursor yet
 - made the mouse cursor snap to the grid when grid snapping is active
 - made the mouse cursor snap to the grid when grid snapping is active
 - changed the axis color to the one used in the OpenGL graphic engine
 - changed the axis color to the one used in the OpenGL graphic engine
+- work on ShapeCollectionLegacy
 
 
 19.09.2019
 19.09.2019
 
 

+ 17 - 1
flatcamGUI/PlotCanvasLegacy.py

@@ -648,8 +648,9 @@ class MplCursor(Cursor):
 
 
 class ShapeCollectionLegacy():
 class ShapeCollectionLegacy():
 
 
-    def __init__(self):
+    def __init__(self, obj):
         self._shapes = []
         self._shapes = []
+        self.setup_axes(obj=obj)
 
 
     def add(self, shape):
     def add(self, shape):
         try:
         try:
@@ -666,3 +667,18 @@ class ShapeCollectionLegacy():
 
 
     def redraw(self):
     def redraw(self):
         pass
         pass
+
+    def setup_axes(self, obj):
+                # Axes must exist and be attached to canvas.
+        if obj.axes is None or obj.axes not in obj.app.plotcanvas.figure.axes:
+            obj.axes = obj.app.plotcanvas.new_axes(obj.options['name'])
+
+        if not obj.options["plot"]:
+            obj.axes.cla()
+            obj.app.plotcanvas.auto_adjust_axes()
+            return False
+
+        # Clear axes or we will plot on top of them.
+        obj.axes.cla()  # TODO: Thread safe?
+        return True
+