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