- fixed Measuring Tool in legacy graphic engine
- fixed Gerber plotting - fixed Geometry plotting
This commit is contained in:
parent
01e2755676
commit
9aef293a26
|
@ -6777,6 +6777,10 @@ class App(QtCore.QObject):
|
||||||
"""
|
"""
|
||||||
self.report_usage("on_jump_to()")
|
self.report_usage("on_jump_to()")
|
||||||
|
|
||||||
|
if self.is_legacy is True:
|
||||||
|
self.inform.emit(_("Not available with the current Graphic Engine Legacy(2D)."))
|
||||||
|
return
|
||||||
|
|
||||||
if not custom_location:
|
if not custom_location:
|
||||||
dia_box = Dialog_box(title=_("Jump to ..."),
|
dia_box = Dialog_box(title=_("Jump to ..."),
|
||||||
label=_("Enter the coordinates in format X,Y:"),
|
label=_("Enter the coordinates in format X,Y:"),
|
||||||
|
@ -6796,14 +6800,27 @@ class App(QtCore.QObject):
|
||||||
location = custom_location
|
location = custom_location
|
||||||
|
|
||||||
if fit_center:
|
if fit_center:
|
||||||
self.plotcanvas.fit_center(loc=location)
|
if self.is_legacy is False:
|
||||||
|
self.plotcanvas.fit_center(loc=location)
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
# self.plotcanvas.fit_view()
|
||||||
|
|
||||||
cursor = QtGui.QCursor()
|
cursor = QtGui.QCursor()
|
||||||
|
|
||||||
canvas_origin = self.plotcanvas.native.mapToGlobal(QtCore.QPoint(0, 0))
|
if self.is_legacy is False:
|
||||||
jump_loc = self.plotcanvas.translate_coords_2((location[0], location[1]))
|
canvas_origin = self.plotcanvas.native.mapToGlobal(QtCore.QPoint(0, 0))
|
||||||
|
jump_loc = self.plotcanvas.translate_coords_2((location[0], location[1]))
|
||||||
|
cursor.setPos(canvas_origin.x() + jump_loc[0], (canvas_origin.y() + jump_loc[1]))
|
||||||
|
else:
|
||||||
|
# the origin finding works but not mapping the location to pixels
|
||||||
|
canvas_origin = self.plotcanvas.native.mapToGlobal(QtCore.QPoint(0, 0))
|
||||||
|
x0, y0 = canvas_origin.x(), canvas_origin.y() + self.ui.right_layout.geometry().height()
|
||||||
|
x0, y0 = x0 + self.plotcanvas.axes.transData.transform((0, 0))[0], y0 - \
|
||||||
|
self.plotcanvas.axes.transData.transform((0, 0))[1]
|
||||||
|
loc = self.plotcanvas.axes.transData.transform(location)
|
||||||
|
cursor.setPos(x0 + loc[0]/50, y0 - loc[1]/50)
|
||||||
|
|
||||||
cursor.setPos(canvas_origin.x() + jump_loc[0], (canvas_origin.y() + jump_loc[1]))
|
|
||||||
self.inform.emit('[success] %s' %
|
self.inform.emit('[success] %s' %
|
||||||
_("Done."))
|
_("Done."))
|
||||||
return location
|
return location
|
||||||
|
|
124
FlatCAMObj.py
124
FlatCAMObj.py
|
@ -650,8 +650,12 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
|
||||||
self.ui.create_buffer_button.hide()
|
self.ui.create_buffer_button.hide()
|
||||||
|
|
||||||
# add the shapes storage for marking apertures
|
# add the shapes storage for marking apertures
|
||||||
for ap_code in self.apertures:
|
if self.app.is_legacy is False:
|
||||||
self.mark_shapes[ap_code] = self.app.plotcanvas.new_shape_collection(layers=2)
|
for ap_code in self.apertures:
|
||||||
|
self.mark_shapes[ap_code] = self.app.plotcanvas.new_shape_collection(layers=2)
|
||||||
|
else:
|
||||||
|
for ap_code in self.apertures:
|
||||||
|
self.mark_shapes[ap_code] = ShapeCollectionLegacy()
|
||||||
|
|
||||||
# set initial state of the aperture table and associated widgets
|
# set initial state of the aperture table and associated widgets
|
||||||
self.on_aperture_table_visibility_change()
|
self.on_aperture_table_visibility_change()
|
||||||
|
@ -1365,44 +1369,73 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
|
||||||
except TypeError:
|
except TypeError:
|
||||||
geometry = [geometry]
|
geometry = [geometry]
|
||||||
|
|
||||||
def random_color():
|
if self.app.is_legacy is False:
|
||||||
color = np.random.rand(4)
|
def random_color():
|
||||||
color[3] = 1
|
color = np.random.rand(4)
|
||||||
return color
|
color[3] = 1
|
||||||
|
return color
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if self.options["solid"]:
|
if self.options["solid"]:
|
||||||
for g in geometry:
|
for g in geometry:
|
||||||
if type(g) == Polygon or type(g) == LineString:
|
if type(g) == Polygon or type(g) == LineString:
|
||||||
self.add_shape(shape=g, color=color,
|
|
||||||
face_color=random_color() if self.options['multicolored']
|
|
||||||
else face_color, visible=visible)
|
|
||||||
elif type(g) == Point:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
for el in g:
|
|
||||||
self.add_shape(shape=el, color=color,
|
|
||||||
face_color=random_color() if self.options['multicolored']
|
|
||||||
else face_color, visible=visible)
|
|
||||||
except TypeError:
|
|
||||||
self.add_shape(shape=g, color=color,
|
self.add_shape(shape=g, color=color,
|
||||||
face_color=random_color() if self.options['multicolored']
|
face_color=random_color() if self.options['multicolored']
|
||||||
else face_color, visible=visible)
|
else face_color, visible=visible)
|
||||||
else:
|
elif type(g) == Point:
|
||||||
for g in geometry:
|
pass
|
||||||
if type(g) == Polygon or type(g) == LineString:
|
else:
|
||||||
self.add_shape(shape=g, color=random_color() if self.options['multicolored'] else 'black',
|
try:
|
||||||
visible=visible)
|
for el in g:
|
||||||
elif type(g) == Point:
|
self.add_shape(shape=el, color=color,
|
||||||
pass
|
face_color=random_color() if self.options['multicolored']
|
||||||
else:
|
else face_color, visible=visible)
|
||||||
for el in g:
|
except TypeError:
|
||||||
self.add_shape(shape=el, color=random_color() if self.options['multicolored'] else 'black',
|
self.add_shape(shape=g, color=color,
|
||||||
|
face_color=random_color() if self.options['multicolored']
|
||||||
|
else face_color, visible=visible)
|
||||||
|
else:
|
||||||
|
for g in geometry:
|
||||||
|
if type(g) == Polygon or type(g) == LineString:
|
||||||
|
self.add_shape(shape=g, color=random_color() if self.options['multicolored'] else 'black',
|
||||||
visible=visible)
|
visible=visible)
|
||||||
self.shapes.redraw()
|
elif type(g) == Point:
|
||||||
except (ObjectDeleted, AttributeError):
|
pass
|
||||||
self.shapes.clear(update=True)
|
else:
|
||||||
|
for el in g:
|
||||||
|
self.add_shape(shape=el, color=random_color() if self.options['multicolored'] else 'black',
|
||||||
|
visible=visible)
|
||||||
|
self.shapes.redraw()
|
||||||
|
except (ObjectDeleted, AttributeError):
|
||||||
|
self.shapes.clear(update=True)
|
||||||
|
else:
|
||||||
|
if self.options["multicolored"]:
|
||||||
|
linespec = '-'
|
||||||
|
else:
|
||||||
|
linespec = 'k-'
|
||||||
|
|
||||||
|
if self.options["solid"]:
|
||||||
|
for poly in geometry:
|
||||||
|
# TODO: Too many things hardcoded.
|
||||||
|
try:
|
||||||
|
patch = PolygonPatch(poly,
|
||||||
|
facecolor="#BBF268",
|
||||||
|
edgecolor="#006E20",
|
||||||
|
alpha=0.75,
|
||||||
|
zorder=2)
|
||||||
|
self.axes.add_patch(patch)
|
||||||
|
except AssertionError:
|
||||||
|
FlatCAMApp.App.log.warning("A geometry component was not a polygon:")
|
||||||
|
FlatCAMApp.App.log.warning(str(poly))
|
||||||
|
else:
|
||||||
|
for poly in geometry:
|
||||||
|
x, y = poly.exterior.xy
|
||||||
|
self.axes.plot(x, y, linespec)
|
||||||
|
for ints in poly.interiors:
|
||||||
|
x, y = ints.coords.xy
|
||||||
|
self.axes.plot(x, y, linespec)
|
||||||
|
|
||||||
|
self.app.plotcanvas.auto_adjust_axes()
|
||||||
|
|
||||||
# experimental plot() when the solid_geometry is stored in the self.apertures
|
# experimental plot() when the solid_geometry is stored in the self.apertures
|
||||||
def plot_aperture(self, **kwargs):
|
def plot_aperture(self, **kwargs):
|
||||||
|
@ -5401,7 +5434,21 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
|
||||||
self.plot_element(sub_el)
|
self.plot_element(sub_el)
|
||||||
|
|
||||||
except TypeError: # Element is not iterable...
|
except TypeError: # Element is not iterable...
|
||||||
self.add_shape(shape=element, color=color, visible=visible, layer=0)
|
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):
|
def plot(self, visible=None, kind=None):
|
||||||
"""
|
"""
|
||||||
|
@ -5432,7 +5479,10 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
|
||||||
self.plot_element(self.solid_geometry, visible=visible)
|
self.plot_element(self.solid_geometry, visible=visible)
|
||||||
|
|
||||||
# self.plot_element(self.solid_geometry, visible=self.options['plot'])
|
# self.plot_element(self.solid_geometry, visible=self.options['plot'])
|
||||||
self.shapes.redraw()
|
if self.app.is_legacy is False:
|
||||||
|
self.shapes.redraw()
|
||||||
|
else:
|
||||||
|
self.app.plotcanvas.auto_adjust_axes()
|
||||||
except (ObjectDeleted, AttributeError):
|
except (ObjectDeleted, AttributeError):
|
||||||
self.shapes.clear(update=True)
|
self.shapes.clear(update=True)
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,12 @@ CAD program, and create G-Code for Isolation routing.
|
||||||
|
|
||||||
=================================================
|
=================================================
|
||||||
|
|
||||||
|
21.09.2019
|
||||||
|
|
||||||
|
- fixed Measuring Tool in legacy graphic engine
|
||||||
|
- fixed Gerber plotting
|
||||||
|
- fixed Geometry plotting
|
||||||
|
|
||||||
20.09.2019
|
20.09.2019
|
||||||
|
|
||||||
- final fix for the --shellvar having spaces within the assigned value; now they are retained
|
- final fix for the --shellvar having spaces within the assigned value; now they are retained
|
||||||
|
|
|
@ -366,6 +366,9 @@ class PlotCanvasLegacy(QtCore.QObject):
|
||||||
ymin, ymax = self.axes.get_ylim()
|
ymin, ymax = self.axes.get_ylim()
|
||||||
self.adjust_axes(xmin, ymin, xmax, ymax)
|
self.adjust_axes(xmin, ymin, xmax, ymax)
|
||||||
|
|
||||||
|
def fit_view(self):
|
||||||
|
self.auto_adjust_axes()
|
||||||
|
|
||||||
def zoom(self, factor, center=None):
|
def zoom(self, factor, center=None):
|
||||||
"""
|
"""
|
||||||
Zooms the plot by factor around a given
|
Zooms the plot by factor around a given
|
||||||
|
|
|
@ -284,7 +284,13 @@ class Measurement(FlatCAMTool):
|
||||||
log.debug("Measuring Tool --> mouse click release")
|
log.debug("Measuring Tool --> mouse click release")
|
||||||
|
|
||||||
if event.button == 1:
|
if event.button == 1:
|
||||||
pos_canvas = self.canvas.translate_coords(event.pos)
|
if self.app.is_legacy is False:
|
||||||
|
event_pos = event.pos
|
||||||
|
else:
|
||||||
|
event_pos = (event.xdata, event.ydata)
|
||||||
|
|
||||||
|
pos_canvas = self.canvas.translate_coords(event_pos)
|
||||||
|
|
||||||
# if GRID is active we need to get the snapped positions
|
# if GRID is active we need to get the snapped positions
|
||||||
if self.app.grid_status() == True:
|
if self.app.grid_status() == True:
|
||||||
pos = self.app.geo_editor.snap(pos_canvas[0], pos_canvas[1])
|
pos = self.app.geo_editor.snap(pos_canvas[0], pos_canvas[1])
|
||||||
|
@ -323,7 +329,12 @@ class Measurement(FlatCAMTool):
|
||||||
|
|
||||||
def on_mouse_move_meas(self, event):
|
def on_mouse_move_meas(self, event):
|
||||||
try: # May fail in case mouse not within axes
|
try: # May fail in case mouse not within axes
|
||||||
pos_canvas = self.app.plotcanvas.translate_coords(event.pos)
|
if self.app.is_legacy is False:
|
||||||
|
event_pos = event.pos
|
||||||
|
else:
|
||||||
|
event_pos = (event.xdata, event.ydata)
|
||||||
|
|
||||||
|
pos_canvas = self.app.plotcanvas.translate_coords(event_pos)
|
||||||
if self.app.grid_status() == True:
|
if self.app.grid_status() == True:
|
||||||
pos = self.app.geo_editor.snap(pos_canvas[0], pos_canvas[1])
|
pos = self.app.geo_editor.snap(pos_canvas[0], pos_canvas[1])
|
||||||
# Update cursor
|
# Update cursor
|
||||||
|
|
Loading…
Reference in New Issue