- fixed zoom directions legacy graphic engine (previous commit)

- fixed display of MultiGeo geometries in legacy graphic engine
- fixed Paint tool to work in legacy graphic engine
This commit is contained in:
Marius Stanciu 2019-09-22 02:38:56 +03:00 committed by Marius
parent e8109d2007
commit 5a4f5dbe2f
4 changed files with 69 additions and 60 deletions

View File

@ -5364,7 +5364,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
return factor
def plot_element(self, element, color='red', visible=None):
def plot_element(self, element, color='#FF0000FF', visible=None):
visible = visible if visible else self.options['plot']
@ -5375,19 +5375,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
except TypeError: # Element is not iterable...
# if self.app.is_legacy is False:
self.add_shape(shape=element, color=color, visible=visible, layer=0)
# else:
# if type(element) == Polygon:
# x, y = element.exterior.coords.xy
# self.axes.plot(x, y, 'r-')
# for ints in element.interiors:
# x, y = ints.coords.xy
# self.axes.plot(x, y, 'r-')
# return
#
# if type(element) == LineString or type(element) == LinearRing:
# x, y = element.coords.xy
# self.axes.plot(x, y, 'r-')
# return
def plot(self, visible=None, kind=None):
"""

View File

@ -9,6 +9,12 @@ CAD program, and create G-Code for Isolation routing.
=================================================
22.09.2019
- fixed zoom directions legacy graphic engine (previous commit)
- fixed display of MultiGeo geometries in legacy graphic engine
- fixed Paint tool to work in legacy graphic engine
21.09.2019
- fixed Measuring Tool in legacy graphic engine
@ -24,7 +30,7 @@ CAD program, and create G-Code for Isolation routing.
- fixed Geometry Editor to work in legacy graphic engine
- fixed Excellon Editor to work in legacy graphic engine
- fixed Gerber Editor to work in legacy graphic engine
- fixed NCC tool to work in egacy graphic engine
- fixed NCC tool to work in legacy graphic engine
20.09.2019

View File

@ -154,7 +154,6 @@ class PlotCanvasLegacy(QtCore.QObject):
self.canvas.setFocus()
self.native = self.canvas
# self.canvas.set_can_focus(True) # For key press
# Attach to parent
@ -686,7 +685,7 @@ class MplCursor(Cursor):
self._update()
class ShapeCollectionLegacy():
class ShapeCollectionLegacy:
def __init__(self, obj, app, name=None):
@ -702,6 +701,8 @@ class ShapeCollectionLegacy():
self._visible = True
self._update = False
self._alpha = None
self._tool_tolerance = None
self._tooldia = None
self._obj = None
self._gcode_parsed = None
@ -783,6 +784,7 @@ class ShapeCollectionLegacy():
obj_type = self.obj.kind
except AttributeError:
obj_type = 'utility'
if self._visible:
for element in local_shapes:
if obj_type == 'excellon':
@ -800,17 +802,19 @@ class ShapeCollectionLegacy():
for ints in local_shapes[element]['shape'].interiors:
x, y = ints.coords.xy
self.axes.plot(x, y, 'o-')
elif obj_type== 'geometry':
elif obj_type == 'geometry':
if type(local_shapes[element]['shape']) == Polygon:
x, y = local_shapes[element]['shape'].exterior.coords.xy
self.axes.plot(x, y, local_shapes[element]['color'], linestyle='-')
for ints in local_shapes[element]['shape'].interiors:
x, y = ints.coords.xy
self.axes.plot(x, y, local_shapes[element]['color'], linestyle='-')
elif type(element) == LineString or type(element) == LinearRing:
x, y = element.coords.xy
self.axes.plot(x, y, local_shapes[element]['color'], marker='-')
return
elif type(local_shapes[element]['shape']) == LineString or \
type(local_shapes[element]['shape']) == LinearRing:
x, y = local_shapes[element]['shape'].coords.xy
self.axes.plot(x, y, local_shapes[element]['color'], linestyle='-')
elif obj_type == 'gerber':
if self.obj.options["multicolored"]:
linespec = '-'

View File

@ -364,6 +364,9 @@ class ToolPaint(FlatCAMTool, Gerber):
self.cursor_pos = None
self.mouse_is_dragging = False
self.mm = None
self.mp = None
self.sel_rect = []
# store here the default data for Geometry Data
@ -1005,7 +1008,10 @@ class ToolPaint(FlatCAMTool, Gerber):
# do paint single only for left mouse clicks
if event.button == 1:
self.app.inform.emit(_("Painting polygon..."))
self.app.plotcanvas.graph_event_disconnect('mouse_press', doit)
if self.app.is_legacy:
self.app.plotcanvas.graph_event_disconnect('mouse_press', doit)
else:
self.app.plotcanvas.graph_event_disconnect(self.mp)
pos = self.app.plotcanvas.translate_coords(event.pos)
if self.app.grid_status() == True:
@ -1039,6 +1045,23 @@ class ToolPaint(FlatCAMTool, Gerber):
# To be called after clicking on the plot.
def on_mouse_release(event):
if self.app.is_legacy is False:
event_pos = event.pos
event_is_dragging = event.is_dragging
right_button = 2
else:
event_pos = (event.xdata, event.ydata)
event_is_dragging = self.app.plotcanvas.is_dragging
right_button = 3
try:
x = float(event_pos[0])
y = float(event_pos[1])
except TypeError:
return
event_pos = (x, y)
# do paint single only for left mouse clicks
if event.button == 1:
if not self.first_click:
@ -1046,14 +1069,14 @@ class ToolPaint(FlatCAMTool, Gerber):
self.app.inform.emit('[WARNING_NOTCL] %s' %
_("Click the end point of the paint area."))
self.cursor_pos = self.app.plotcanvas.translate_coords(event.pos)
self.cursor_pos = self.app.plotcanvas.translate_coords(event_pos)
if self.app.grid_status() == True:
self.cursor_pos = self.app.geo_editor.snap(self.cursor_pos[0], self.cursor_pos[1])
else:
self.app.inform.emit(_("Zone added. Click to start adding next zone or right click to finish."))
self.app.delete_selection_shape()
curr_pos = self.app.plotcanvas.translate_coords(event.pos)
curr_pos = self.app.plotcanvas.translate_coords(event_pos)
if self.app.grid_status() == True:
curr_pos = self.app.geo_editor.snap(curr_pos[0], curr_pos[1])
@ -1066,35 +1089,8 @@ class ToolPaint(FlatCAMTool, Gerber):
self.sel_rect.append(Polygon([pt1, pt2, pt3, pt4]))
self.first_click = False
return
# modifiers = QtWidgets.QApplication.keyboardModifiers()
#
# if modifiers == QtCore.Qt.ShiftModifier:
# mod_key = 'Shift'
# elif modifiers == QtCore.Qt.ControlModifier:
# mod_key = 'Control'
# else:
# mod_key = None
#
# if mod_key == self.app.defaults["global_mselect_key"]:
# self.first_click = False
# return
#
# self.sel_rect = cascaded_union(self.sel_rect)
# self.paint_poly_area(obj=self.paint_obj,
# tooldia=tooldia_list,
# sel_obj= self.sel_rect,
# outname=o_name,
# overlap=overlap,
# connect=connect,
# contour=contour)
#
# self.app.plotcanvas.graph_event_disconnect('mouse_release', on_mouse_release)
# self.app.plotcanvas.graph_event_disconnect('mouse_move', on_mouse_move)
#
# self.app.plotcanvas.graph_event_connect('mouse_press', self.app.on_mouse_click_over_plot)
# self.app.plotcanvas.graph_event_connect('mouse_move', self.app.on_mouse_move_over_plot)
# self.app.plotcanvas.graph_event_connect('mouse_release', self.app.on_mouse_click_release_over_plot)
elif event.button == 2 and self.mouse_is_dragging is False:
elif event.button == right_button and self.mouse_is_dragging is False:
self.first_click = False
if self.app.is_legacy is False:
@ -1125,10 +1121,25 @@ class ToolPaint(FlatCAMTool, Gerber):
# called on mouse move
def on_mouse_move(event):
curr_pos = self.app.plotcanvas.translate_coords(event.pos)
if self.app.is_legacy is False:
event_pos = event.pos
event_is_dragging = event.is_dragging
right_button = 2
else:
event_pos = (event.xdata, event.ydata)
event_is_dragging = self.app.plotcanvas.is_dragging
right_button = 3
try:
x = float(event_pos[0])
y = float(event_pos[1])
except TypeError:
return
curr_pos = self.app.plotcanvas.translate_coords((x, y))
# detect mouse dragging motion
if event.is_dragging is True:
if event_is_dragging == 1:
self.mouse_is_dragging = True
else:
self.mouse_is_dragging = False
@ -1137,15 +1148,15 @@ class ToolPaint(FlatCAMTool, Gerber):
if self.app.grid_status() == True:
# Update cursor
curr_pos = self.app.geo_editor.snap(curr_pos[0], curr_pos[1])
self.app.app_cursor.set_data(np.asarray([(curr_pos[0], curr_pos[1])]),
symbol='++', edge_color='black', size=20)
if self.app.is_legacy is False:
self.app.app_cursor.set_data(np.asarray([(curr_pos[0], curr_pos[1])]),
symbol='++', edge_color='black', size=20)
# draw the utility geometry
if self.first_click:
self.app.delete_selection_shape()
self.app.draw_moving_selection_shape(old_coords=(self.cursor_pos[0], self.cursor_pos[1]),
coords=(curr_pos[0], curr_pos[1]),
face_alpha=0.0)
coords=(curr_pos[0], curr_pos[1]))
if self.app.is_legacy is False:
self.app.plotcanvas.graph_event_disconnect('mouse_press', self.app.on_mouse_click_over_plot)