- editing a multi geometry will no longer pop-up a Tcl window

- solved issue #292 where a new geometry renamed with many underscores failed to store the name in a saved project
- the name for the saved projects are updated to the current time and not to the time of the app startup
- some PEP8 changes related to comments starting with only one '#' symbol
This commit is contained in:
Marius Stanciu
2019-05-30 21:05:12 +03:00
parent ad7222a768
commit 8ee516ec14
55 changed files with 695 additions and 684 deletions

View File

@@ -726,11 +726,11 @@ class FlatCAMExcEditor(QtCore.QObject):
self.app = app
self.canvas = self.app.plotcanvas
## Current application units in Upper Case
# ## Current application units in Upper Case
self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
self.exc_edit_widget = QtWidgets.QWidget()
## Box for custom widgets
# ## Box for custom widgets
# This gets populated in offspring implementations.
layout = QtWidgets.QVBoxLayout()
self.exc_edit_widget.setLayout(layout)
@@ -744,22 +744,22 @@ class FlatCAMExcEditor(QtCore.QObject):
self.tools_box.setContentsMargins(0, 0, 0, 0)
self.drills_frame.setLayout(self.tools_box)
## Page Title box (spacing between children)
# ## Page Title box (spacing between children)
self.title_box = QtWidgets.QHBoxLayout()
self.tools_box.addLayout(self.title_box)
## Page Title icon
# ## Page Title icon
pixmap = QtGui.QPixmap('share/flatcam_icon32.png')
self.icon = QtWidgets.QLabel()
self.icon.setPixmap(pixmap)
self.title_box.addWidget(self.icon, stretch=0)
## Title label
# ## Title label
self.title_label = QtWidgets.QLabel("<font size=5><b>%s</b></font>" % _('Excellon Editor'))
self.title_label.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
self.title_box.addWidget(self.title_label, stretch=1)
## Object name
# ## Object name
self.name_box = QtWidgets.QHBoxLayout()
self.tools_box.addLayout(self.name_box)
name_label = QtWidgets.QLabel(_("Name:"))
@@ -767,7 +767,7 @@ class FlatCAMExcEditor(QtCore.QObject):
self.name_entry = FCEntry()
self.name_box.addWidget(self.name_entry)
#### Tools Drills ####
#### Tools Drills ## ##
self.tools_table_label = QtWidgets.QLabel("<b>%s</b>" % _('Tools Table'))
self.tools_table_label.setToolTip(
_( "Tools in this Excellon object\n"
@@ -789,7 +789,7 @@ class FlatCAMExcEditor(QtCore.QObject):
self.empty_label = QtWidgets.QLabel('')
self.tools_box.addWidget(self.empty_label)
#### Add a new Tool ####
#### Add a new Tool ## ##
self.addtool_label = QtWidgets.QLabel('<b>%s</b>' % _('Add/Delete Tool'))
self.addtool_label.setToolTip(
_("Add/Delete a tool to the tool list\n"
@@ -839,7 +839,7 @@ class FlatCAMExcEditor(QtCore.QObject):
self.resize_box.setContentsMargins(0, 0, 0, 0)
self.resize_frame.setLayout(self.resize_box)
#### Resize a drill ####
#### Resize a drill ## ##
self.emptyresize_label = QtWidgets.QLabel('')
self.resize_box.addWidget(self.emptyresize_label)
@@ -882,7 +882,7 @@ class FlatCAMExcEditor(QtCore.QObject):
self.array_box.setContentsMargins(0, 0, 0, 0)
self.array_frame.setLayout(self.array_box)
#### Add DRILL Array ####
#### Add DRILL Array ## ##
self.emptyarray_label = QtWidgets.QLabel('')
self.array_box.addWidget(self.emptyarray_label)
@@ -1001,7 +1001,7 @@ class FlatCAMExcEditor(QtCore.QObject):
self.array_frame.hide()
self.tools_box.addStretch()
## Toolbar events and properties
# ## Toolbar events and properties
self.tools_exc = {
"drill_select": {"button": self.app.ui.select_drill_btn,
"constructor": FCDrillSelect},
@@ -1017,7 +1017,7 @@ class FlatCAMExcEditor(QtCore.QObject):
"constructor": FCDrillMove},
}
### Data
# ## Data
self.active_tool = None
self.in_action = False
@@ -1090,7 +1090,7 @@ class FlatCAMExcEditor(QtCore.QObject):
self.shapes.enabled = False
self.tool_shape.enabled = False
## List of selected shapes.
# ## List of selected shapes.
self.selected = []
self.move_timer = QtCore.QTimer()
@@ -1160,7 +1160,7 @@ class FlatCAMExcEditor(QtCore.QObject):
@staticmethod
def make_storage():
## Shape storage.
# ## Shape storage.
storage = FlatCAMRTreeStorage()
storage.get_points = DrawToolShape.get_pts
@@ -1739,7 +1739,7 @@ class FlatCAMExcEditor(QtCore.QObject):
self.drills_frame.hide()
def connect_canvas_event_handlers(self):
## Canvas events
# ## Canvas events
# first connect to new, then disconnect the old handlers
# don't ask why but if there is nothing connected I've seen issues
@@ -2394,7 +2394,7 @@ class FlatCAMExcEditor(QtCore.QObject):
if self.active_tool is None:
return
### Snap coordinates
# ## Snap coordinates
if self.app.grid_status():
x, y = self.app.geo_editor.snap(x, y)
self.app.app_cursor.enabled = True
@@ -2419,7 +2419,7 @@ class FlatCAMExcEditor(QtCore.QObject):
self.app.ui.rel_position_label.setText("<b>Dx</b>: %.4f&nbsp;&nbsp; <b>Dy</b>: "
"%.4f&nbsp;&nbsp;&nbsp;&nbsp;" % (dx, dy))
### Utility geometry (animated)
# ## Utility geometry (animated)
geo = self.active_tool.utility_geometry(data=(x, y))
if isinstance(geo, DrawToolShape) and geo.geo is not None:
@@ -2427,7 +2427,7 @@ class FlatCAMExcEditor(QtCore.QObject):
self.tool_shape.clear(update=True)
self.draw_utility_geometry(geo=geo)
### Selection area on canvas section ###
# ## Selection area on canvas section # ##
if event.is_dragging == 1 and event.button == 1:
# I make an exception for FCDrillAdd and FCDrillArray because clicking and dragging while making regions
# can create strange issues
@@ -2553,13 +2553,13 @@ class FlatCAMExcEditor(QtCore.QObject):
for geo in geometry:
plot_elements += self.plot_shape(geometry=geo, color=color, linewidth=linewidth)
## Non-iterable
# ## Non-iterable
except TypeError:
## DrawToolShape
# ## DrawToolShape
if isinstance(geometry, DrawToolShape):
plot_elements += self.plot_shape(geometry=geometry.geo, color=color, linewidth=linewidth)
## Polygon: Descend into exterior and each interior.
# ## Polygon: Descend into exterior and each interior.
if type(geometry) == Polygon:
plot_elements += self.plot_shape(geometry=geometry.exterior, color=color, linewidth=linewidth)
plot_elements += self.plot_shape(geometry=geometry.interiors, color=color, linewidth=linewidth)

View File

@@ -1,15 +1,15 @@
# ###########################################################
# ######################################################### ##
# FlatCAM: 2D Post-processing for Manufacturing #
# http://flatcam.org #
# Author: Juan Pablo Caram (c) #
# Date: 2/5/2014 #
# MIT Licence #
# ###########################################################
# ######################################################### ##
# ########################################################### #
# File Modified: Marius Adrian Stanciu (c) #
# Date: 3/10/2019 #
# ###########################################################
# ######################################################### ##
from PyQt5 import QtGui, QtCore, QtWidgets
from PyQt5.QtCore import Qt, QSettings
@@ -629,7 +629,7 @@ class TransformEditorTool(FlatCAMTool):
self.transform_lay = QtWidgets.QVBoxLayout()
self.layout.addLayout(self.transform_lay)
## Title
# ## Title
title_label = QtWidgets.QLabel("%s" % (_('Editor %s') % self.toolName))
title_label.setStyleSheet("""
QLabel
@@ -2917,9 +2917,9 @@ class FCTransform(FCShapeTool):
self.draw_app.transform_tool.run()
# #######################
# ## Main Application ###
# #######################
# ##################### ##
# # ## Main Application # ##
# ##################### ##
class FlatCAMGeoEditor(QtCore.QObject):
transform_complete = QtCore.pyqtSignal()
@@ -2935,7 +2935,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
self.app = app
self.canvas = app.plotcanvas
## Toolbar events and properties
# ## Toolbar events and properties
self.tools = {
"select": {"button": self.app.ui.geo_select_btn,
"constructor": FCSelect},
@@ -2965,7 +2965,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
"constructor": FCCopy}
}
# ## Data
# # ## Data
self.active_tool = None
self.storage = FlatCAMGeoEditor.make_storage()
@@ -3413,7 +3413,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
if multigeo_tool:
self.multigeo_tool = multigeo_tool
geo_to_edit = fcgeometry.flatten(geometry=fcgeometry.tools[self.multigeo_tool]['solid_geometry'])
self.app.inform.emit(_("[WARNING] Editing MultiGeo Geometry, tool: {tool} with diameter: {dia}").
self.app.inform.emit(_("[WARNING_NOTCL] Editing MultiGeo Geometry, tool: {tool} with diameter: {dia}").
format(tool=self.multigeo_tool, dia=fcgeometry.tools[self.multigeo_tool]['tooldia']))
else:
geo_to_edit = fcgeometry.flatten()
@@ -3569,7 +3569,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
if self.active_tool is None:
return
# ## Snap coordinates
# # ## Snap coordinates
if self.app.grid_status():
x, y = self.snap(x, y)
self.app.app_cursor.enabled = True
@@ -3597,14 +3597,14 @@ class FlatCAMGeoEditor(QtCore.QObject):
if event.button == 1 and event.is_dragging == 1 and isinstance(self.active_tool, FCEraser):
pass
else:
# ## Utility geometry (animated)
# # ## Utility geometry (animated)
geo = self.active_tool.utility_geometry(data=(x, y))
if isinstance(geo, DrawToolShape) and geo.geo is not None:
# Remove any previous utility shape
self.tool_shape.clear(update=True)
self.draw_utility_geometry(geo=geo)
# ## Selection area on canvas section ###
# # ## Selection area on canvas section # ##
dx = pos[0] - self.pos[0]
if event.is_dragging == 1 and event.button == 1:
self.app.delete_selection_shape()
@@ -3938,9 +3938,9 @@ class FlatCAMGeoEditor(QtCore.QObject):
snap_x, snap_y = (x, y)
snap_distance = Inf
# ## Object (corner?) snap
# ## No need for the objects, just the coordinates
# ## in the index.
# # ## Object (corner?) snap
# # ## No need for the objects, just the coordinates
# # ## in the index.
if self.options["corner_snap"]:
try:
nearest_pt, shape = self.storage.nearest((x, y))
@@ -3952,7 +3952,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
except (StopIteration, AssertionError):
pass
# ## Grid snap
# # ## Grid snap
if self.options["grid_snap"]:
if self.options["global_gridx"] != 0:
snap_x_ = round(x / self.options["global_gridx"]) * self.options['global_gridx']

View File

@@ -52,7 +52,7 @@ class DrawToolShape(object):
"""
pts = []
## Iterable: descend into each item.
# ## Iterable: descend into each item.
try:
for sub_o in o:
pts += DrawToolShape.get_pts(sub_o)
@@ -64,7 +64,7 @@ class DrawToolShape(object):
if isinstance(o, DrawToolShape):
pts += DrawToolShape.get_pts(o.geo)
## Descend into .exerior and .interiors
# ## Descend into .exerior and .interiors
elif type(o) == Polygon:
pts += DrawToolShape.get_pts(o.exterior)
for i in o.interiors:
@@ -72,7 +72,7 @@ class DrawToolShape(object):
elif type(o) == MultiLineString:
for line in o:
pts += DrawToolShape.get_pts(line)
## Has .coords: list them.
# ## Has .coords: list them.
else:
if DrawToolShape.tolerance is not None:
pts += list(o.simplify(DrawToolShape.tolerance).coords)
@@ -2274,7 +2274,7 @@ class FlatCAMGrbEditor(QtCore.QObject):
layout.addLayout(self.custom_box)
# ### Gerber Apertures ####
# # ## Gerber Apertures ## ##
self.apertures_table_label = QtWidgets.QLabel(_('<b>Apertures:</b>'))
self.apertures_table_label.setToolTip(
_("Apertures Table for the Gerber Object.")
@@ -2316,7 +2316,7 @@ class FlatCAMGrbEditor(QtCore.QObject):
self.apertures_box.setContentsMargins(0, 0, 0, 0)
self.apertures_frame.setLayout(self.apertures_box)
# ### Add/Delete an new Aperture ####
# # ## Add/Delete an new Aperture ## ##
grid1 = QtWidgets.QGridLayout()
self.apertures_box.addLayout(grid1)
@@ -2390,7 +2390,7 @@ class FlatCAMGrbEditor(QtCore.QObject):
hlay_ad.addWidget(self.addaperture_btn)
hlay_ad.addWidget(self.delaperture_btn)
# ## BUFFER TOOL ###
# # ## BUFFER TOOL # ##
self.buffer_tool_frame = QtWidgets.QFrame()
self.buffer_tool_frame.setContentsMargins(0, 0, 0, 0)
@@ -2434,7 +2434,7 @@ class FlatCAMGrbEditor(QtCore.QObject):
self.buffer_button = QtWidgets.QPushButton(_("Buffer"))
hlay_buf.addWidget(self.buffer_button)
# ## SCALE TOOL ###
# # ## SCALE TOOL # ##
self.scale_tool_frame = QtWidgets.QFrame()
self.scale_tool_frame.setContentsMargins(0, 0, 0, 0)
@@ -2481,7 +2481,7 @@ class FlatCAMGrbEditor(QtCore.QObject):
self.array_box.setContentsMargins(0, 0, 0, 0)
self.array_frame.setLayout(self.array_box)
# ### Add Pad Array ####
# # ## Add Pad Array ## ##
self.emptyarray_label = QtWidgets.QLabel('')
self.array_box.addWidget(self.emptyarray_label)
@@ -2633,7 +2633,7 @@ class FlatCAMGrbEditor(QtCore.QObject):
"constructor": FCApertureMove},
}
# ## Data
# # ## Data
self.active_tool = None
self.storage_dict = {}
@@ -3479,9 +3479,9 @@ class FlatCAMGrbEditor(QtCore.QObject):
self.gerber_obj.apertures = conv_apertures
# ###############################################################
# ############################################################# ##
# APPLY CLEAR_GEOMETRY on the SOLID_GEOMETRY
# ###############################################################
# ############################################################# ##
# log.warning("Applying clear geometry in the apertures dict.")
# list of clear geos that are to be applied to the entire file
@@ -4079,7 +4079,7 @@ class FlatCAMGrbEditor(QtCore.QObject):
if self.active_tool is None:
return
# ## Snap coordinates
# # ## Snap coordinates
if self.app.grid_status():
x, y = self.app.geo_editor.snap(x, y)
self.app.app_cursor.enabled = True
@@ -4104,7 +4104,7 @@ class FlatCAMGrbEditor(QtCore.QObject):
self.app.ui.rel_position_label.setText("<b>Dx</b>: %.4f&nbsp;&nbsp; <b>Dy</b>: "
"%.4f&nbsp;&nbsp;&nbsp;&nbsp;" % (dx, dy))
# ## Utility geometry (animated)
# # ## Utility geometry (animated)
geo = self.active_tool.utility_geometry(data=(x, y))
if isinstance(geo, DrawToolShape) and geo.geo is not None:
@@ -4112,7 +4112,7 @@ class FlatCAMGrbEditor(QtCore.QObject):
self.tool_shape.clear(update=True)
self.draw_utility_geometry(geo=geo)
# ## Selection area on canvas section ###
# # ## Selection area on canvas section # ##
if event.is_dragging == 1 and event.button == 1:
# I make an exception for FCRegion and FCTrack because clicking and dragging while making regions can
# create strange issues like missing a point in a track/region