- work on ShapeCollectionLegacy
This commit is contained in:
parent
3f70c156a0
commit
14bc9f2dfc
|
@ -1595,6 +1595,9 @@ class App(QtCore.QObject):
|
|||
else:
|
||||
self.is_legacy = True
|
||||
|
||||
# Matplotlib axis
|
||||
self.axes = None
|
||||
|
||||
if show_splash:
|
||||
self.splash.showMessage(_("FlatCAM is initializing ...\n"
|
||||
"Canvas initialization started."),
|
||||
|
@ -1604,7 +1607,9 @@ class App(QtCore.QObject):
|
|||
self.plotcanvas = None
|
||||
self.app_cursor = None
|
||||
self.hover_shapes = None
|
||||
|
||||
self.on_plotcanvas_setup()
|
||||
|
||||
end_plot_time = time.time()
|
||||
self.used_time = end_plot_time - start_plot_time
|
||||
self.log.debug("Finished Canvas initialization in %s seconds." % str(self.used_time))
|
||||
|
@ -10971,6 +10976,7 @@ class App(QtCore.QObject):
|
|||
if self.is_legacy is False:
|
||||
self.hover_shapes = ShapeCollection(parent=self.plotcanvas.view.scene, layers=1)
|
||||
else:
|
||||
# will use the default Matplotlib axes
|
||||
self.hover_shapes = ShapeCollectionLegacy()
|
||||
|
||||
def on_zoom_fit(self, event):
|
||||
|
|
|
@ -12,6 +12,7 @@ from datetime import datetime
|
|||
|
||||
from flatcamGUI.ObjectUI import *
|
||||
from FlatCAMCommon import LoudDict
|
||||
from flatcamGUI.PlotCanvasLegacy import ShapeCollectionLegacy
|
||||
from camlib import *
|
||||
import itertools
|
||||
|
||||
|
@ -74,13 +75,17 @@ class FlatCAMObj(QtCore.QObject):
|
|||
# store here the default data for Geometry Data
|
||||
self.default_data = {}
|
||||
|
||||
if self.app.is_legacy:
|
||||
self.axes = None # Matplotlib axes; usefull only in Legacy Mode
|
||||
# 2D mode
|
||||
# Axes must exist and be attached to canvas.
|
||||
self.axes = None
|
||||
|
||||
self.kind = None # Override with proper name
|
||||
|
||||
# self.shapes = ShapeCollection(parent=self.app.plotcanvas.view.scene)
|
||||
self.shapes = self.app.plotcanvas.new_shape_group()
|
||||
if self.app.is_legacy is False:
|
||||
self.shapes = self.app.plotcanvas.new_shape_group()
|
||||
else:
|
||||
self.shapes = ShapeCollectionLegacy()
|
||||
|
||||
# self.mark_shapes = self.app.plotcanvas.new_shape_collection(layers=2)
|
||||
self.mark_shapes = {}
|
||||
|
|
|
@ -648,9 +648,8 @@ class MplCursor(Cursor):
|
|||
|
||||
class ShapeCollectionLegacy():
|
||||
|
||||
def __init__(self, obj):
|
||||
def __init__(self):
|
||||
self._shapes = []
|
||||
self.setup_axes(obj=obj)
|
||||
|
||||
def add(self, shape):
|
||||
try:
|
||||
|
@ -668,17 +667,4 @@ class ShapeCollectionLegacy():
|
|||
def redraw(self):
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue