- added ability to use line width when adding shapes for both Legacy and OpenGL graphic engines
- added the linewidth=2 parameter for the Tool Distance utility geometry - fixed a selection issue in Legacy graphic mode for single click
This commit is contained in:
parent
26ec98d64b
commit
dc1a198235
@ -2670,6 +2670,10 @@ class App(QtCore.QObject):
|
|||||||
# variable to store mouse coordinates
|
# variable to store mouse coordinates
|
||||||
self.mouse = [0, 0]
|
self.mouse = [0, 0]
|
||||||
|
|
||||||
|
# variable to store the delta positions on cavnas
|
||||||
|
self.dx = 0
|
||||||
|
self.dy = 0
|
||||||
|
|
||||||
# decide if we have a double click or single click
|
# decide if we have a double click or single click
|
||||||
self.doubleclick = False
|
self.doubleclick = False
|
||||||
|
|
||||||
@ -7635,10 +7639,10 @@ class App(QtCore.QObject):
|
|||||||
self.ui.position_label.setText(" <b>X</b>: %.4f "
|
self.ui.position_label.setText(" <b>X</b>: %.4f "
|
||||||
"<b>Y</b>: %.4f" % (location[0], location[1]))
|
"<b>Y</b>: %.4f" % (location[0], location[1]))
|
||||||
# Set the relative position label
|
# Set the relative position label
|
||||||
dx = location[0] - float(self.rel_point1[0])
|
self.dx = location[0] - float(self.rel_point1[0])
|
||||||
dy = location[1] - float(self.rel_point1[1])
|
self.dy = location[1] - float(self.rel_point1[1])
|
||||||
self.ui.rel_position_label.setText("<b>Dx</b>: %.4f <b>Dy</b>: "
|
self.ui.rel_position_label.setText("<b>Dx</b>: %.4f <b>Dy</b>: "
|
||||||
"%.4f " % (dx, dy))
|
"%.4f " % (self.dx, self.dy))
|
||||||
|
|
||||||
self.inform.emit('[success] %s' % _("Done."))
|
self.inform.emit('[success] %s' % _("Done."))
|
||||||
return location
|
return location
|
||||||
@ -8823,24 +8827,26 @@ class App(QtCore.QObject):
|
|||||||
self.ui.position_label.setText(" <b>X</b>: %.4f "
|
self.ui.position_label.setText(" <b>X</b>: %.4f "
|
||||||
"<b>Y</b>: %.4f" % (pos[0], pos[1]))
|
"<b>Y</b>: %.4f" % (pos[0], pos[1]))
|
||||||
|
|
||||||
dx = pos[0] - float(self.rel_point1[0])
|
self.dx = pos[0] - float(self.rel_point1[0])
|
||||||
dy = pos[1] - float(self.rel_point1[1])
|
self.dy = pos[1] - float(self.rel_point1[1])
|
||||||
self.ui.rel_position_label.setText("<b>Dx</b>: %.4f <b>Dy</b>: "
|
self.ui.rel_position_label.setText("<b>Dx</b>: %.4f <b>Dy</b>: "
|
||||||
"%.4f " % (dx, dy))
|
"%.4f " % (self.dx, self.dy))
|
||||||
self.mouse = [pos[0], pos[1]]
|
self.mouse = [pos[0], pos[1]]
|
||||||
|
|
||||||
# if the mouse is moved and the LMB is clicked then the action is a selection
|
# if the mouse is moved and the LMB is clicked then the action is a selection
|
||||||
if self.event_is_dragging == 1 and event.button == 1:
|
if self.event_is_dragging == 1 and event.button == 1:
|
||||||
self.delete_selection_shape()
|
self.delete_selection_shape()
|
||||||
if dx < 0:
|
if self.dx < 0:
|
||||||
self.draw_moving_selection_shape(self.pos, pos, color=self.defaults['global_alt_sel_line'],
|
self.draw_moving_selection_shape(self.pos, pos, color=self.defaults['global_alt_sel_line'],
|
||||||
face_color=self.defaults['global_alt_sel_fill'])
|
face_color=self.defaults['global_alt_sel_fill'])
|
||||||
self.selection_type = False
|
self.selection_type = False
|
||||||
elif dx >= 0:
|
elif self.dx >= 0:
|
||||||
self.draw_moving_selection_shape(self.pos, pos)
|
self.draw_moving_selection_shape(self.pos, pos)
|
||||||
self.selection_type = True
|
self.selection_type = True
|
||||||
else:
|
else:
|
||||||
self.selection_type = None
|
self.selection_type = None
|
||||||
|
else:
|
||||||
|
self.selection_type = None
|
||||||
|
|
||||||
# hover effect - enabled in Preferences -> General -> GUI Settings
|
# hover effect - enabled in Preferences -> General -> GUI Settings
|
||||||
if self.defaults['global_hover']:
|
if self.defaults['global_hover']:
|
||||||
@ -8940,6 +8946,12 @@ class App(QtCore.QObject):
|
|||||||
log.warning("FlatCAMApp.on_mouse_click_release_over_plot() double click --> Error: %s" % str(e))
|
log.warning("FlatCAMApp.on_mouse_click_release_over_plot() double click --> Error: %s" % str(e))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
# WORKAROUND for LEGACY MODE
|
||||||
|
if self.is_legacy is True:
|
||||||
|
# if there is no move on canvas then we have no dragging selection
|
||||||
|
if self.dx == 0 or self.dy == 0:
|
||||||
|
self.selection_type = None
|
||||||
|
|
||||||
if self.selection_type is not None:
|
if self.selection_type is not None:
|
||||||
try:
|
try:
|
||||||
self.selection_area_handler(self.pos, pos, self.selection_type)
|
self.selection_area_handler(self.pos, pos, self.selection_type)
|
||||||
@ -8948,6 +8960,7 @@ class App(QtCore.QObject):
|
|||||||
log.warning("FlatCAMApp.on_mouse_click_release_over_plot() select area --> Error: %s" % str(e))
|
log.warning("FlatCAMApp.on_mouse_click_release_over_plot() select area --> Error: %s" % str(e))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
|
||||||
key_modifier = QtWidgets.QApplication.keyboardModifiers()
|
key_modifier = QtWidgets.QApplication.keyboardModifiers()
|
||||||
|
|
||||||
if key_modifier == QtCore.Qt.ShiftModifier:
|
if key_modifier == QtCore.Qt.ShiftModifier:
|
||||||
|
@ -13,6 +13,9 @@ CAD program, and create G-Code for Isolation routing.
|
|||||||
|
|
||||||
- made the Grid icon in the status bar clickable and it will toggle the snap to grid function
|
- made the Grid icon in the status bar clickable and it will toggle the snap to grid function
|
||||||
- some mods in the Distance Tool
|
- some mods in the Distance Tool
|
||||||
|
- added ability to use line width when adding shapes for both Legacy and OpenGL graphic engines
|
||||||
|
- added the linewidth=2 parameter for the Tool Distance utility geometry
|
||||||
|
- fixed a selection issue in Legacy graphic mode for single click
|
||||||
|
|
||||||
19.04.2020
|
19.04.2020
|
||||||
|
|
||||||
|
@ -3807,12 +3807,12 @@ class FlatCAMExcEditor(QtCore.QObject):
|
|||||||
|
|
||||||
if self.pos is None:
|
if self.pos is None:
|
||||||
self.pos = (0, 0)
|
self.pos = (0, 0)
|
||||||
dx = x - self.pos[0]
|
self.app.dx = x - self.pos[0]
|
||||||
dy = y - self.pos[1]
|
self.app.dy = y - self.pos[1]
|
||||||
|
|
||||||
# update the reference position label in the infobar since the APP mouse event handlers are disconnected
|
# update the reference position label in the infobar since the APP mouse event handlers are disconnected
|
||||||
self.app.ui.rel_position_label.setText("<b>Dx</b>: %.4f <b>Dy</b>: "
|
self.app.ui.rel_position_label.setText("<b>Dx</b>: %.4f <b>Dy</b>: "
|
||||||
"%.4f " % (dx, dy))
|
"%.4f " % (self.app.dx, self.app.dy))
|
||||||
|
|
||||||
# ## Utility geometry (animated)
|
# ## Utility geometry (animated)
|
||||||
self.update_utility_geometry(data=(x, y))
|
self.update_utility_geometry(data=(x, y))
|
||||||
|
@ -4267,12 +4267,12 @@ class FlatCAMGeoEditor(QtCore.QObject):
|
|||||||
|
|
||||||
if self.pos is None:
|
if self.pos is None:
|
||||||
self.pos = (0, 0)
|
self.pos = (0, 0)
|
||||||
dx = x - self.pos[0]
|
self.app.dx = x - self.pos[0]
|
||||||
dy = y - self.pos[1]
|
self.app.dy = y - self.pos[1]
|
||||||
|
|
||||||
# update the reference position label in the infobar since the APP mouse event handlers are disconnected
|
# update the reference position label in the infobar since the APP mouse event handlers are disconnected
|
||||||
self.app.ui.rel_position_label.setText("<b>Dx</b>: %.4f <b>Dy</b>: "
|
self.app.ui.rel_position_label.setText("<b>Dx</b>: %.4f <b>Dy</b>: "
|
||||||
"%.4f " % (dx, dy))
|
"%.4f " % (self.app.dx, self.app.dy))
|
||||||
|
|
||||||
if event.button == 1 and event_is_dragging and isinstance(self.active_tool, FCEraser):
|
if event.button == 1 and event_is_dragging and isinstance(self.active_tool, FCEraser):
|
||||||
pass
|
pass
|
||||||
|
@ -4648,12 +4648,12 @@ class FlatCAMGrbEditor(QtCore.QObject):
|
|||||||
|
|
||||||
if self.pos is None:
|
if self.pos is None:
|
||||||
self.pos = (0, 0)
|
self.pos = (0, 0)
|
||||||
dx = x - self.pos[0]
|
self.app.dx = x - self.pos[0]
|
||||||
dy = y - self.pos[1]
|
self.app.dy = y - self.pos[1]
|
||||||
|
|
||||||
# update the reference position label in the infobar since the APP mouse event handlers are disconnected
|
# update the reference position label in the infobar since the APP mouse event handlers are disconnected
|
||||||
self.app.ui.rel_position_label.setText("<b>Dx</b>: %.4f <b>Dy</b>: "
|
self.app.ui.rel_position_label.setText("<b>Dx</b>: %.4f <b>Dy</b>: "
|
||||||
"%.4f " % (dx, dy))
|
"%.4f " % (self.app.dx, self.app.dy))
|
||||||
|
|
||||||
self.update_utility_geometry(data=(x, y))
|
self.update_utility_geometry(data=(x, y))
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ from PyQt5.QtCore import pyqtSignal
|
|||||||
# Used for solid polygons in Matplotlib
|
# Used for solid polygons in Matplotlib
|
||||||
from descartes.patch import PolygonPatch
|
from descartes.patch import PolygonPatch
|
||||||
|
|
||||||
from shapely.geometry import Polygon, LineString, LinearRing, Point, MultiPolygon, MultiLineString
|
from shapely.geometry import Polygon, LineString, LinearRing
|
||||||
|
|
||||||
import FlatCAMApp
|
import FlatCAMApp
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ class PlotCanvasLegacy(QtCore.QObject):
|
|||||||
self.container = container
|
self.container = container
|
||||||
|
|
||||||
# Plots go onto a single matplotlib.figure
|
# Plots go onto a single matplotlib.figure
|
||||||
self.figure = Figure(dpi=50) # TODO: dpi needed?
|
self.figure = Figure(dpi=50)
|
||||||
self.figure.patch.set_visible(True)
|
self.figure.patch.set_visible(True)
|
||||||
self.figure.set_facecolor(theme_color)
|
self.figure.set_facecolor(theme_color)
|
||||||
|
|
||||||
@ -254,7 +254,7 @@ class PlotCanvasLegacy(QtCore.QObject):
|
|||||||
# self.canvas.set_can_focus(True) # For key press
|
# self.canvas.set_can_focus(True) # For key press
|
||||||
|
|
||||||
# Attach to parent
|
# Attach to parent
|
||||||
# self.container.attach(self.canvas, 0, 0, 600, 400) # TODO: Height and width are num. columns??
|
# self.container.attach(self.canvas, 0, 0, 600, 400)
|
||||||
self.container.addWidget(self.canvas) # Qt
|
self.container.addWidget(self.canvas) # Qt
|
||||||
|
|
||||||
# Copy a bitmap of the canvas for quick animation.
|
# Copy a bitmap of the canvas for quick animation.
|
||||||
@ -430,7 +430,7 @@ class PlotCanvasLegacy(QtCore.QObject):
|
|||||||
# Pointer (snapped)
|
# Pointer (snapped)
|
||||||
# The size of the cursor is multiplied by 1.65 because that value made the cursor similar with the
|
# The size of the cursor is multiplied by 1.65 because that value made the cursor similar with the
|
||||||
# one in the OpenGL(3D) graphic engine
|
# one in the OpenGL(3D) graphic engine
|
||||||
pointer_size = int(float(self.app.defaults["global_cursor_size"] ) * 1.65)
|
pointer_size = int(float(self.app.defaults["global_cursor_size"]) * 1.65)
|
||||||
elements = self.axes.plot(x, y, '+', color=color, ms=pointer_size,
|
elements = self.axes.plot(x, y, '+', color=color, ms=pointer_size,
|
||||||
mew=self.app.defaults["global_cursor_width"], animated=True)
|
mew=self.app.defaults["global_cursor_width"], animated=True)
|
||||||
for el in elements:
|
for el in elements:
|
||||||
@ -946,14 +946,16 @@ class ShapeCollectionLegacy:
|
|||||||
hold the collection of shapes into a dict self._shapes.
|
hold the collection of shapes into a dict self._shapes.
|
||||||
This handles the shapes redraw on canvas.
|
This handles the shapes redraw on canvas.
|
||||||
"""
|
"""
|
||||||
def __init__(self, obj, app, name=None, annotation_job=None):
|
def __init__(self, obj, app, name=None, annotation_job=None, linewidth=1):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
:param obj: this is the object to which the shapes collection is attached and for
|
:param obj: This is the object to which the shapes collection is attached and for
|
||||||
which it will have to draw shapes
|
which it will have to draw shapes
|
||||||
:param app: this is the FLatCAM.App usually, needed because we have to access attributes there
|
: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 name: This is the name given to the Matplotlib axes; it needs to be unique due of
|
||||||
:param annotation_job: make this True if the job needed is just for annotation
|
Matplotlib requurements
|
||||||
|
:param annotation_job: Make this True if the job needed is just for annotation
|
||||||
|
:param linewidth: THe width of the line (outline where is the case)
|
||||||
"""
|
"""
|
||||||
self.obj = obj
|
self.obj = obj
|
||||||
self.app = app
|
self.app = app
|
||||||
@ -974,6 +976,8 @@ class ShapeCollectionLegacy:
|
|||||||
self._obj = None
|
self._obj = None
|
||||||
self._gcode_parsed = None
|
self._gcode_parsed = None
|
||||||
|
|
||||||
|
self._linewidth = linewidth
|
||||||
|
|
||||||
if name is None:
|
if name is None:
|
||||||
axes_name = self.obj.options['name']
|
axes_name = self.obj.options['name']
|
||||||
else:
|
else:
|
||||||
@ -1005,14 +1009,21 @@ class ShapeCollectionLegacy:
|
|||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
self._color = color if color is not None else "#006E20"
|
self._color = color if color is not None else "#006E20"
|
||||||
self._face_color = face_color if face_color is not None else "#BBF268"
|
# self._face_color = face_color if face_color is not None else "#BBF268"
|
||||||
|
self._face_color = face_color
|
||||||
|
|
||||||
|
if linewidth is None:
|
||||||
|
line_width = self._linewidth
|
||||||
|
else:
|
||||||
|
line_width = linewidth
|
||||||
|
|
||||||
if len(self._color) > 7:
|
if len(self._color) > 7:
|
||||||
self._color = self._color[:7]
|
self._color = self._color[:7]
|
||||||
|
|
||||||
if len(self._face_color) > 7:
|
if self._face_color is not None:
|
||||||
self._face_color = self._face_color[:7]
|
if len(self._face_color) > 7:
|
||||||
# self._alpha = int(self._face_color[-2:], 16) / 255
|
self._face_color = self._face_color[:7]
|
||||||
|
# self._alpha = int(self._face_color[-2:], 16) / 255
|
||||||
|
|
||||||
self._alpha = 0.75
|
self._alpha = 0.75
|
||||||
|
|
||||||
@ -1037,7 +1048,7 @@ class ShapeCollectionLegacy:
|
|||||||
self.shape_dict.update({
|
self.shape_dict.update({
|
||||||
'color': self._color,
|
'color': self._color,
|
||||||
'face_color': self._face_color,
|
'face_color': self._face_color,
|
||||||
'linewidth': linewidth,
|
'linewidth': line_width,
|
||||||
'alpha': self._alpha,
|
'alpha': self._alpha,
|
||||||
'shape': sh
|
'shape': sh
|
||||||
})
|
})
|
||||||
@ -1050,7 +1061,7 @@ class ShapeCollectionLegacy:
|
|||||||
self.shape_dict.update({
|
self.shape_dict.update({
|
||||||
'color': self._color,
|
'color': self._color,
|
||||||
'face_color': self._face_color,
|
'face_color': self._face_color,
|
||||||
'linewidth': linewidth,
|
'linewidth': line_width,
|
||||||
'alpha': self._alpha,
|
'alpha': self._alpha,
|
||||||
'shape': shape
|
'shape': shape
|
||||||
})
|
})
|
||||||
@ -1112,36 +1123,50 @@ class ShapeCollectionLegacy:
|
|||||||
if obj_type == 'excellon':
|
if obj_type == 'excellon':
|
||||||
# Plot excellon (All polygons?)
|
# Plot excellon (All polygons?)
|
||||||
if self.obj.options["solid"] and isinstance(local_shapes[element]['shape'], Polygon):
|
if self.obj.options["solid"] and isinstance(local_shapes[element]['shape'], Polygon):
|
||||||
patch = PolygonPatch(local_shapes[element]['shape'],
|
try:
|
||||||
facecolor="#C40000",
|
patch = PolygonPatch(local_shapes[element]['shape'],
|
||||||
edgecolor="#750000",
|
facecolor="#C40000",
|
||||||
alpha=local_shapes[element]['alpha'],
|
edgecolor="#750000",
|
||||||
zorder=3)
|
alpha=local_shapes[element]['alpha'],
|
||||||
self.axes.add_patch(patch)
|
zorder=3,
|
||||||
|
linewidth=local_shapes[element]['linewidth']
|
||||||
|
)
|
||||||
|
self.axes.add_patch(patch)
|
||||||
|
except Exception as e:
|
||||||
|
log.debug("ShapeCollectionLegacy.redraw() excellon poly --> %s" % str(e))
|
||||||
else:
|
else:
|
||||||
x, y = local_shapes[element]['shape'].exterior.coords.xy
|
try:
|
||||||
self.axes.plot(x, y, 'r-')
|
x, y = local_shapes[element]['shape'].exterior.coords.xy
|
||||||
for ints in local_shapes[element]['shape'].interiors:
|
self.axes.plot(x, y, 'r-', linewidth=local_shapes[element]['linewidth'])
|
||||||
x, y = ints.coords.xy
|
for ints in local_shapes[element]['shape'].interiors:
|
||||||
self.axes.plot(x, y, 'o-')
|
x, y = ints.coords.xy
|
||||||
|
self.axes.plot(x, y, 'o-', linewidth=local_shapes[element]['linewidth'])
|
||||||
|
except Exception as e:
|
||||||
|
log.debug("ShapeCollectionLegacy.redraw() excellon no poly --> %s" % str(e))
|
||||||
elif obj_type == 'geometry':
|
elif obj_type == 'geometry':
|
||||||
if type(local_shapes[element]['shape']) == Polygon:
|
if type(local_shapes[element]['shape']) == Polygon:
|
||||||
x, y = local_shapes[element]['shape'].exterior.coords.xy
|
try:
|
||||||
self.axes.plot(x, y, local_shapes[element]['color'],
|
x, y = local_shapes[element]['shape'].exterior.coords.xy
|
||||||
linestyle='-',
|
|
||||||
linewidth=local_shapes[element]['linewidth'])
|
|
||||||
for ints in local_shapes[element]['shape'].interiors:
|
|
||||||
x, y = ints.coords.xy
|
|
||||||
self.axes.plot(x, y, local_shapes[element]['color'],
|
self.axes.plot(x, y, local_shapes[element]['color'],
|
||||||
linestyle='-',
|
linestyle='-',
|
||||||
linewidth=local_shapes[element]['linewidth'])
|
linewidth=local_shapes[element]['linewidth'])
|
||||||
|
for ints in local_shapes[element]['shape'].interiors:
|
||||||
|
x, y = ints.coords.xy
|
||||||
|
self.axes.plot(x, y, local_shapes[element]['color'],
|
||||||
|
linestyle='-',
|
||||||
|
linewidth=local_shapes[element]['linewidth'])
|
||||||
|
except Exception as e:
|
||||||
|
log.debug("ShapeCollectionLegacy.redraw() geometry poly --> %s" % str(e))
|
||||||
elif type(local_shapes[element]['shape']) == LineString or \
|
elif type(local_shapes[element]['shape']) == LineString or \
|
||||||
type(local_shapes[element]['shape']) == LinearRing:
|
type(local_shapes[element]['shape']) == LinearRing:
|
||||||
|
|
||||||
x, y = local_shapes[element]['shape'].coords.xy
|
try:
|
||||||
self.axes.plot(x, y, local_shapes[element]['color'],
|
x, y = local_shapes[element]['shape'].coords.xy
|
||||||
linestyle='-',
|
self.axes.plot(x, y, local_shapes[element]['color'],
|
||||||
linewidth=local_shapes[element]['linewidth'])
|
linestyle='-',
|
||||||
|
linewidth=local_shapes[element]['linewidth'])
|
||||||
|
except Exception as e:
|
||||||
|
log.debug("ShapeCollectionLegacy.redraw() geometry no poly --> %s" % str(e))
|
||||||
elif obj_type == 'gerber':
|
elif obj_type == 'gerber':
|
||||||
if self.obj.options["multicolored"]:
|
if self.obj.options["multicolored"]:
|
||||||
linespec = '-'
|
linespec = '-'
|
||||||
@ -1161,47 +1186,60 @@ class ShapeCollectionLegacy:
|
|||||||
facecolor=gerber_fill_color,
|
facecolor=gerber_fill_color,
|
||||||
edgecolor=gerber_outline_color,
|
edgecolor=gerber_outline_color,
|
||||||
alpha=local_shapes[element]['alpha'],
|
alpha=local_shapes[element]['alpha'],
|
||||||
zorder=2)
|
zorder=2,
|
||||||
|
linewidth=local_shapes[element]['linewidth'])
|
||||||
self.axes.add_patch(patch)
|
self.axes.add_patch(patch)
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
FlatCAMApp.App.log.warning("A geometry component was not a polygon:")
|
FlatCAMApp.App.log.warning("A geometry component was not a polygon:")
|
||||||
FlatCAMApp.App.log.warning(str(element))
|
FlatCAMApp.App.log.warning(str(element))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
FlatCAMApp.App.log.debug("PlotCanvasLegacy.ShepeCollectionLegacy.redraw() --> %s" % str(e))
|
FlatCAMApp.App.log.debug(
|
||||||
|
"PlotCanvasLegacy.ShepeCollectionLegacy.redraw() gerber 'solid' --> %s" % str(e))
|
||||||
else:
|
else:
|
||||||
x, y = local_shapes[element]['shape'].exterior.xy
|
try:
|
||||||
self.axes.plot(x, y, linespec)
|
x, y = local_shapes[element]['shape'].exterior.xy
|
||||||
for ints in local_shapes[element]['shape'].interiors:
|
self.axes.plot(x, y, linespec, linewidth=local_shapes[element]['linewidth'])
|
||||||
x, y = ints.coords.xy
|
for ints in local_shapes[element]['shape'].interiors:
|
||||||
self.axes.plot(x, y, linespec)
|
x, y = ints.coords.xy
|
||||||
|
self.axes.plot(x, y, linespec, linewidth=local_shapes[element]['linewidth'])
|
||||||
|
except Exception as e:
|
||||||
|
log.debug("ShapeCollectionLegacy.redraw() gerber no 'solid' --> %s" % str(e))
|
||||||
elif obj_type == 'cncjob':
|
elif obj_type == 'cncjob':
|
||||||
|
|
||||||
if local_shapes[element]['face_color'] is None:
|
if local_shapes[element]['face_color'] is None:
|
||||||
linespec = '--'
|
try:
|
||||||
linecolor = local_shapes[element]['color']
|
linespec = '--'
|
||||||
# if geo['kind'][0] == 'C':
|
linecolor = local_shapes[element]['color']
|
||||||
# linespec = 'k-'
|
# if geo['kind'][0] == 'C':
|
||||||
x, y = local_shapes[element]['shape'].coords.xy
|
# linespec = 'k-'
|
||||||
self.axes.plot(x, y, linespec, color=linecolor)
|
x, y = local_shapes[element]['shape'].coords.xy
|
||||||
|
self.axes.plot(x, y, linespec, color=linecolor,
|
||||||
|
linewidth=local_shapes[element]['linewidth'])
|
||||||
|
except Exception as e:
|
||||||
|
log.debug("ShapeCollectionLegacy.redraw() cncjob with face_color --> %s" % str(e))
|
||||||
else:
|
else:
|
||||||
path_num += 1
|
try:
|
||||||
if self.obj.ui.annotation_cb.get_value():
|
path_num += 1
|
||||||
if isinstance(local_shapes[element]['shape'], Polygon):
|
if self.obj.ui.annotation_cb.get_value():
|
||||||
self.axes.annotate(
|
if isinstance(local_shapes[element]['shape'], Polygon):
|
||||||
str(path_num),
|
self.axes.annotate(
|
||||||
xy=local_shapes[element]['shape'].exterior.coords[0],
|
str(path_num),
|
||||||
xycoords='data', fontsize=20)
|
xy=local_shapes[element]['shape'].exterior.coords[0],
|
||||||
else:
|
xycoords='data', fontsize=20)
|
||||||
self.axes.annotate(
|
else:
|
||||||
str(path_num),
|
self.axes.annotate(
|
||||||
xy=local_shapes[element]['shape'].coords[0],
|
str(path_num),
|
||||||
xycoords='data', fontsize=20)
|
xy=local_shapes[element]['shape'].coords[0],
|
||||||
|
xycoords='data', fontsize=20)
|
||||||
|
|
||||||
patch = PolygonPatch(local_shapes[element]['shape'],
|
patch = PolygonPatch(local_shapes[element]['shape'],
|
||||||
facecolor=local_shapes[element]['face_color'],
|
facecolor=local_shapes[element]['face_color'],
|
||||||
edgecolor=local_shapes[element]['color'],
|
edgecolor=local_shapes[element]['color'],
|
||||||
alpha=local_shapes[element]['alpha'], zorder=2)
|
alpha=local_shapes[element]['alpha'], zorder=2,
|
||||||
self.axes.add_patch(patch)
|
linewidth=local_shapes[element]['linewidth'])
|
||||||
|
self.axes.add_patch(patch)
|
||||||
|
except Exception as e:
|
||||||
|
log.debug("ShapeCollectionLegacy.redraw() cncjob no face_color --> %s" % str(e))
|
||||||
elif obj_type == 'utility':
|
elif obj_type == 'utility':
|
||||||
# not a FlatCAM object, must be utility
|
# not a FlatCAM object, must be utility
|
||||||
if local_shapes[element]['face_color']:
|
if local_shapes[element]['face_color']:
|
||||||
@ -1210,26 +1248,35 @@ class ShapeCollectionLegacy:
|
|||||||
facecolor=local_shapes[element]['face_color'],
|
facecolor=local_shapes[element]['face_color'],
|
||||||
edgecolor=local_shapes[element]['color'],
|
edgecolor=local_shapes[element]['color'],
|
||||||
alpha=local_shapes[element]['alpha'],
|
alpha=local_shapes[element]['alpha'],
|
||||||
zorder=2)
|
zorder=2,
|
||||||
|
linewidth=local_shapes[element]['linewidth'])
|
||||||
|
|
||||||
self.axes.add_patch(patch)
|
self.axes.add_patch(patch)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.debug("ShapeCollectionLegacy.redraw() --> %s" % str(e))
|
log.debug("ShapeCollectionLegacy.redraw() utility poly with face_color --> %s" % str(e))
|
||||||
else:
|
else:
|
||||||
if isinstance(local_shapes[element]['shape'], Polygon):
|
if isinstance(local_shapes[element]['shape'], Polygon):
|
||||||
ext_shape = local_shapes[element]['shape'].exterior
|
try:
|
||||||
if ext_shape is not None:
|
ext_shape = local_shapes[element]['shape'].exterior
|
||||||
x, y = ext_shape.xy
|
if ext_shape is not None:
|
||||||
self.axes.plot(x, y, local_shapes[element]['color'], linestyle='-')
|
x, y = ext_shape.xy
|
||||||
for ints in local_shapes[element]['shape'].interiors:
|
self.axes.plot(x, y, local_shapes[element]['color'], linestyle='-',
|
||||||
if ints is not None:
|
linewidth=local_shapes[element]['linewidth'])
|
||||||
x, y = ints.coords.xy
|
for ints in local_shapes[element]['shape'].interiors:
|
||||||
self.axes.plot(x, y, local_shapes[element]['color'], linestyle='-')
|
if ints is not None:
|
||||||
|
x, y = ints.coords.xy
|
||||||
|
self.axes.plot(x, y, local_shapes[element]['color'], linestyle='-',
|
||||||
|
linewidth=local_shapes[element]['linewidth'])
|
||||||
|
except Exception as e:
|
||||||
|
log.debug("ShapeCollectionLegacy.redraw() utility poly no face_color --> %s" % str(e))
|
||||||
else:
|
else:
|
||||||
if local_shapes[element]['shape'] is not None:
|
try:
|
||||||
x, y = local_shapes[element]['shape'].coords.xy
|
if local_shapes[element]['shape'] is not None:
|
||||||
self.axes.plot(x, y, local_shapes[element]['color'], linestyle='-')
|
x, y = local_shapes[element]['shape'].coords.xy
|
||||||
|
self.axes.plot(x, y, local_shapes[element]['color'], linestyle='-',
|
||||||
|
linewidth=local_shapes[element]['linewidth'])
|
||||||
|
except Exception as e:
|
||||||
|
log.debug("ShapeCollectionLegacy.redraw() utility lines no face_color --> %s" % str(e))
|
||||||
self.app.plotcanvas.auto_adjust_axes()
|
self.app.plotcanvas.auto_adjust_axes()
|
||||||
|
|
||||||
def set(self, text, pos, visible=True, font_size=16, color=None):
|
def set(self, text, pos, visible=True, font_size=16, color=None):
|
||||||
|
@ -193,10 +193,10 @@ class ShapeGroup(object):
|
|||||||
|
|
||||||
class ShapeCollectionVisual(CompoundVisual):
|
class ShapeCollectionVisual(CompoundVisual):
|
||||||
|
|
||||||
def __init__(self, line_width=1, triangulation='vispy', layers=3, pool=None, **kwargs):
|
def __init__(self, linewidth=1, triangulation='vispy', layers=3, pool=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
Represents collection of shapes to draw on VisPy scene
|
Represents collection of shapes to draw on VisPy scene
|
||||||
:param line_width: float
|
:param linewidth: float
|
||||||
Width of lines/edges
|
Width of lines/edges
|
||||||
:param triangulation: str
|
:param triangulation: str
|
||||||
Triangulation method used for polygons translation
|
Triangulation method used for polygons translation
|
||||||
@ -223,7 +223,7 @@ class ShapeCollectionVisual(CompoundVisual):
|
|||||||
# self._lines = [LineVisual(antialias=True) for _ in range(0, layers)]
|
# self._lines = [LineVisual(antialias=True) for _ in range(0, layers)]
|
||||||
self._lines = [FlatCAMLineVisual(antialias=True) for _ in range(0, layers)]
|
self._lines = [FlatCAMLineVisual(antialias=True) for _ in range(0, layers)]
|
||||||
|
|
||||||
self._line_width = line_width
|
self._line_width = linewidth
|
||||||
self._triangulation = triangulation
|
self._triangulation = triangulation
|
||||||
|
|
||||||
visuals_ = [self._lines[i // 2] if i % 2 else self._meshes[i // 2] for i in range(0, layers * 2)]
|
visuals_ = [self._lines[i // 2] if i % 2 else self._meshes[i // 2] for i in range(0, layers * 2)]
|
||||||
@ -262,7 +262,7 @@ class ShapeCollectionVisual(CompoundVisual):
|
|||||||
:param tolerance: float
|
:param tolerance: float
|
||||||
Geometry simplifying tolerance
|
Geometry simplifying tolerance
|
||||||
:param linewidth: int
|
:param linewidth: int
|
||||||
Not used, for compatibility
|
Width of the line
|
||||||
:return: int
|
:return: int
|
||||||
Index of shape
|
Index of shape
|
||||||
"""
|
"""
|
||||||
@ -276,6 +276,9 @@ class ShapeCollectionVisual(CompoundVisual):
|
|||||||
self.data[key] = {'geometry': shape, 'color': color, 'alpha': alpha, 'face_color': face_color,
|
self.data[key] = {'geometry': shape, 'color': color, 'alpha': alpha, 'face_color': face_color,
|
||||||
'visible': visible, 'layer': layer, 'tolerance': tolerance}
|
'visible': visible, 'layer': layer, 'tolerance': tolerance}
|
||||||
|
|
||||||
|
if linewidth:
|
||||||
|
self._line_width = linewidth
|
||||||
|
|
||||||
# Add data to process pool if pool exists
|
# Add data to process pool if pool exists
|
||||||
try:
|
try:
|
||||||
self.results[key] = self.pool.map_async(_update_shape_buffers, [self.data[key]])
|
self.results[key] = self.pool.map_async(_update_shape_buffers, [self.data[key]])
|
||||||
@ -459,7 +462,7 @@ class ShapeCollectionVisual(CompoundVisual):
|
|||||||
self.update_lock.acquire(True)
|
self.update_lock.acquire(True)
|
||||||
|
|
||||||
# Merge shapes buffers
|
# Merge shapes buffers
|
||||||
for data in list(self.data.values()):
|
for data in self.data.values():
|
||||||
if data['visible'] and 'line_pts' in data:
|
if data['visible'] and 'line_pts' in data:
|
||||||
try:
|
try:
|
||||||
line_pts[data['layer']] += data['line_pts']
|
line_pts[data['layer']] += data['line_pts']
|
||||||
|
@ -917,10 +917,10 @@ class ToolCopperThieving(FlatCAMTool):
|
|||||||
if self.cursor_pos is None:
|
if self.cursor_pos is None:
|
||||||
self.cursor_pos = (0, 0)
|
self.cursor_pos = (0, 0)
|
||||||
|
|
||||||
dx = curr_pos[0] - float(self.cursor_pos[0])
|
self.app.dx = curr_pos[0] - float(self.cursor_pos[0])
|
||||||
dy = curr_pos[1] - float(self.cursor_pos[1])
|
self.app.dy = curr_pos[1] - float(self.cursor_pos[1])
|
||||||
self.app.ui.rel_position_label.setText("<b>Dx</b>: %.4f <b>Dy</b>: "
|
self.app.ui.rel_position_label.setText("<b>Dx</b>: %.4f <b>Dy</b>: "
|
||||||
"%.4f " % (dx, dy))
|
"%.4f " % (self.app.dx, self.app.dy))
|
||||||
|
|
||||||
# draw the utility geometry
|
# draw the utility geometry
|
||||||
if self.first_click:
|
if self.first_click:
|
||||||
|
@ -598,7 +598,7 @@ class Distance(FlatCAMTool):
|
|||||||
else:
|
else:
|
||||||
color = '#FFFFFFFF'
|
color = '#FFFFFFFF'
|
||||||
|
|
||||||
self.sel_shapes.add(meas_line, color=color, update=True, layer=0, tolerance=None)
|
self.sel_shapes.add(meas_line, color=color, update=True, layer=0, tolerance=None, linewidth=2)
|
||||||
|
|
||||||
if self.app.is_legacy is True:
|
if self.app.is_legacy is True:
|
||||||
self.sel_shapes.redraw()
|
self.sel_shapes.redraw()
|
||||||
|
@ -1835,10 +1835,10 @@ class NonCopperClear(FlatCAMTool, Gerber):
|
|||||||
if self.cursor_pos is None:
|
if self.cursor_pos is None:
|
||||||
self.cursor_pos = (0, 0)
|
self.cursor_pos = (0, 0)
|
||||||
|
|
||||||
dx = curr_pos[0] - float(self.cursor_pos[0])
|
self.app.dx = curr_pos[0] - float(self.cursor_pos[0])
|
||||||
dy = curr_pos[1] - float(self.cursor_pos[1])
|
self.app.dy = curr_pos[1] - float(self.cursor_pos[1])
|
||||||
self.app.ui.rel_position_label.setText("<b>Dx</b>: %.4f <b>Dy</b>: "
|
self.app.ui.rel_position_label.setText("<b>Dx</b>: %.4f <b>Dy</b>: "
|
||||||
"%.4f " % (dx, dy))
|
"%.4f " % (self.app.dx, self.app.dy))
|
||||||
|
|
||||||
# draw the utility geometry
|
# draw the utility geometry
|
||||||
if shape_type == "square":
|
if shape_type == "square":
|
||||||
|
@ -1718,10 +1718,10 @@ class ToolPaint(FlatCAMTool, Gerber):
|
|||||||
if self.cursor_pos is None:
|
if self.cursor_pos is None:
|
||||||
self.cursor_pos = (0, 0)
|
self.cursor_pos = (0, 0)
|
||||||
|
|
||||||
dx = curr_pos[0] - float(self.cursor_pos[0])
|
self.app.dx = curr_pos[0] - float(self.cursor_pos[0])
|
||||||
dy = curr_pos[1] - float(self.cursor_pos[1])
|
self.app.dy = curr_pos[1] - float(self.cursor_pos[1])
|
||||||
self.app.ui.rel_position_label.setText("<b>Dx</b>: %.4f <b>Dy</b>: "
|
self.app.ui.rel_position_label.setText("<b>Dx</b>: %.4f <b>Dy</b>: "
|
||||||
"%.4f " % (dx, dy))
|
"%.4f " % (self.app.dx, self.app.dy))
|
||||||
|
|
||||||
# draw the utility geometry
|
# draw the utility geometry
|
||||||
if shape_type == "square":
|
if shape_type == "square":
|
||||||
|
Loading…
Reference in New Issue
Block a user