- made hover shapes work in legacy graphic engine
- fixed bug in display of the apertures marked in the Aperture table found in the Gerber Selected tab and through this made it to also work with the legacy graphic engine - fixed annotation in Mark Area Tool in Gerber Editor to work in legacy graphic engine
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
# Author: Juan Pablo Caram (c) #
|
||||
# Date: 2/5/2014 #
|
||||
# MIT Licence #
|
||||
# Modified by Marius Stanciu 09/21/2019 #
|
||||
############################################################
|
||||
|
||||
from PyQt5 import QtGui, QtCore, QtWidgets
|
||||
@@ -26,6 +27,14 @@ import FlatCAMApp
|
||||
from copy import deepcopy
|
||||
import logging
|
||||
|
||||
import gettext
|
||||
import FlatCAMTranslation as fcTranslate
|
||||
import builtins
|
||||
|
||||
fcTranslate.apply_language('strings')
|
||||
if '_' not in builtins.__dict__:
|
||||
_ = gettext.gettext
|
||||
|
||||
mpl_use("Qt5Agg")
|
||||
log = logging.getLogger('base')
|
||||
|
||||
@@ -617,7 +626,12 @@ class PlotCanvasLegacy(QtCore.QObject):
|
||||
return width / xpx, height / ypx
|
||||
|
||||
|
||||
class FakeCursor():
|
||||
class FakeCursor:
|
||||
"""
|
||||
This is a fake cursor to ensure compatibility with the OpenGL engine (VisPy).
|
||||
This way I don't have to chane (disable) things related to the cursor all over when
|
||||
using the low performance Matplotlib 2D graphic engine.
|
||||
"""
|
||||
def __init__(self):
|
||||
self._enabled = True
|
||||
|
||||
@@ -629,9 +643,17 @@ class FakeCursor():
|
||||
def enabled(self, value):
|
||||
self._enabled = value
|
||||
|
||||
def set_data(self, pos, **kwargs):
|
||||
"""Internal event handler to draw the cursor when the mouse moves."""
|
||||
pass
|
||||
|
||||
|
||||
class MplCursor(Cursor):
|
||||
|
||||
"""
|
||||
Unfortunately this gets attached to the current axes and if a new axes is added
|
||||
it will not be showed until that axes is deleted.
|
||||
Not the kind of behavior needed here so I don't use it anymore.
|
||||
"""
|
||||
def __init__(self, axes, color='red', linewidth=1):
|
||||
|
||||
super().__init__(ax=axes, useblit=True, color=color, linewidth=linewidth)
|
||||
@@ -687,11 +709,23 @@ class MplCursor(Cursor):
|
||||
|
||||
|
||||
class ShapeCollectionLegacy:
|
||||
"""
|
||||
This will create the axes for each collection of shapes and will also
|
||||
hold the collection of shapes into a dict self._shapes.
|
||||
This handles the shapes redraw on canvas.
|
||||
"""
|
||||
def __init__(self, obj, app, name=None, annotation_job=None):
|
||||
"""
|
||||
|
||||
def __init__(self, obj, app, name=None):
|
||||
|
||||
:param obj: this is the object to which the shapes collection is attached and for
|
||||
which it will have to draw shapes
|
||||
:param app: this is the FLatCAM.App usually, needed because we have to access attributes there
|
||||
:param name: this is the name given to the Matplotlib axes; it needs to be unique due of Matplotlib requurements
|
||||
:param annotation_job: make this True if the job needed is just for annotation
|
||||
"""
|
||||
self.obj = obj
|
||||
self.app = app
|
||||
self.annotation_job = annotation_job
|
||||
|
||||
self._shapes = dict()
|
||||
self.shape_dict = dict()
|
||||
@@ -730,7 +764,7 @@ class ShapeCollectionLegacy:
|
||||
self._visible = visible
|
||||
self._update = update
|
||||
|
||||
# CNCJob oject related arguments
|
||||
# CNCJob object related arguments
|
||||
self._obj = obj
|
||||
self._gcode_parsed = gcode_parsed
|
||||
self._tool_tolerance = tool_tolerance
|
||||
@@ -887,6 +921,28 @@ class ShapeCollectionLegacy:
|
||||
|
||||
self.app.plotcanvas.auto_adjust_axes()
|
||||
|
||||
def set(self, text, pos, visible=True, font_size=16, color=None):
|
||||
|
||||
if color is None:
|
||||
color = "#000000FF"
|
||||
|
||||
if visible is not True:
|
||||
self.clear()
|
||||
return
|
||||
|
||||
if len(text) != len(pos):
|
||||
self.app.inform.emit('[ERROR_NOTCL] %s' % _("Could not annotate due of a difference between the number "
|
||||
"of text elements and the number of text positions."))
|
||||
return
|
||||
|
||||
for idx in range(len(text)):
|
||||
try:
|
||||
self.axes.annotate(text[idx], xy=pos[idx], xycoords='data', fontsize=font_size, color=color)
|
||||
except Exception as e:
|
||||
log.debug("ShapeCollectionLegacy.set() --> %s" % str(e))
|
||||
|
||||
self.app.plotcanvas.auto_adjust_axes()
|
||||
|
||||
@property
|
||||
def visible(self):
|
||||
return self._visible
|
||||
@@ -900,3 +956,17 @@ class ShapeCollectionLegacy:
|
||||
if self._visible is False:
|
||||
self.redraw()
|
||||
self._visible = value
|
||||
|
||||
@property
|
||||
def enabled(self):
|
||||
return self._visible
|
||||
|
||||
@enabled.setter
|
||||
def enabled(self, value):
|
||||
if value is False:
|
||||
self.axes.cla()
|
||||
self.app.plotcanvas.auto_adjust_axes()
|
||||
else:
|
||||
if self._visible is False:
|
||||
self.redraw()
|
||||
self._visible = value
|
||||
|
||||
Reference in New Issue
Block a user