Merged jpcgt/flatcam into master

This commit is contained in:
Marius Stanciu 2018-06-04 22:35:19 +03:00
commit cae8f35154
5 changed files with 80 additions and 5 deletions

View File

@ -286,6 +286,7 @@ class App(QtCore.QObject):
self.defaults = LoudDict()
self.defaults.set_change_callback(self.on_defaults_dict_change) # When the dictionary changes.
self.defaults.update({
"global_mouse_pan_button": 2,
"serial": 0,
"stats": {},
"units": "IN",
@ -475,6 +476,8 @@ class App(QtCore.QObject):
self.collection = ObjectCollection.ObjectCollection()
self.ui.project_tab_layout.addWidget(self.collection.view)
self.mouse_pan_button = int(self.defaults['global_mouse_pan_button'])
#### End of Data ####
#### Worker ####
@ -1567,6 +1570,11 @@ class App(QtCore.QObject):
if plot:
obj.plot()
# deselect all previously selected objects and select the new one
self.collection.set_all_inactive()
name = obj.options['name']
self.collection.set_active(name)
self.on_zoom_fit(None)
t1 = time.time() # DEBUG
self.log.debug("%f seconds adding object and plotting." % (t1 - t0))

View File

@ -138,6 +138,8 @@ class PlotCanvas(QtCore.QObject):
self.axes = self.figure.add_axes([0.05, 0.05, 0.9, 0.9], label="base", alpha=0.0)
self.axes.set_aspect(1)
self.axes.grid(True)
self.axes.axhline(color='Black')
self.axes.axvline(color='Black')
# The canvas is the top level container (FigureCanvasQTAgg)
self.canvas = FigureCanvas(self.figure)
@ -445,7 +447,7 @@ class PlotCanvas(QtCore.QObject):
def on_mouse_press(self, event):
# Check for middle mouse button press
if event.button == 2:
if event.button == self.app.mouse_pan_button:
# Prepare axes for pan (using 'matplotlib' pan function)
self.pan_axes = []
@ -461,7 +463,7 @@ class PlotCanvas(QtCore.QObject):
def on_mouse_release(self, event):
# Check for middle mouse button release to complete pan procedure
if event.button == 2:
if event.button == self.app.mouse_pan_button:
for a in self.pan_axes:
a.end_pan()

View File

@ -1006,7 +1006,7 @@ class Geometry(object):
def export_svg(self, scale_factor=0.00):
"""
Exports the Gemoetry Object as a SVG Element
Exports the Geometry Object as a SVG Element
:return: SVG Element
"""
@ -1849,7 +1849,7 @@ class Gerber (Geometry):
#log.debug("%3s %s" % (line_num, gline))
### Aperture Macros
# Having this at the beggining will slow things down
# Having this at the beginning will slow things down
# but macros can have complicated statements than could
# be caught by other patterns.
if current_macro is None: # No macro started yet
@ -2228,6 +2228,15 @@ class Gerber (Geometry):
log.debug("Line %d: Aperture change to (%s)" % (line_num, match.group(1)))
log.debug(self.apertures[current_aperture])
# If the aperture value is zero then make it something quite small but with a non-zero value
# so it can be processed by FlatCAM.
# But first test to see if the aperture type is "aperture macro". In that case
# we should not test for "size" key as it does not exist in this case.
if self.apertures[current_aperture]["type"] is not "AM":
if self.apertures[current_aperture]["size"] == 0:
self.apertures[current_aperture]["size"] = 0.0000001
log.debug(self.apertures[current_aperture])
# Take care of the current path with the previous tool
if len(path) > 1:
# --- Buffered ----
@ -2511,7 +2520,6 @@ class Excellon(Geometry):
# self.tools[name] = {"C": diameter<float>}
self.tools = {}
self.drills = []
## IN|MM -> Units are inherited from Geometry

View File

@ -0,0 +1,56 @@
from tclCommands.TclCommand import *
class TclCommandListSys(TclCommand):
"""
Tcl shell command to get the list of system variables
example:
list_sys
"""
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['list_sys', 'listsys']
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('selection', str),
])
# Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value
option_types = collections.OrderedDict([
])
# array of mandatory options for current Tcl command: required = {'name','outname'}
required = []
# structured help for current command, args needs to be ordered
help = {
'main': "Returns the list of the names of system variables.\n"
"Without an argument it will list all the system parameters. "
"As an argument use first letter or first letters from the name "
"of the system variable.\n"
"In that case it will list only the system variables that starts with that string.\n"
"Main categories start with: gerber or excellon or geometry or cncjob or global.\n"
"Note: Use get_sys TclCommand to get the value and set_sys TclCommand to set it.\n",
'args': collections.OrderedDict([
]),
'examples': ['list_sys',
'list_sys ser'
'list_sys gerber',
'list_sys cncj']
}
def execute(self, args, unnamed_args):
"""
:param args:
:param unnamed_args:
:return:
"""
if 'selection' in args:
argument = args['selection']
return str([k for k in self.app.defaults.keys() if str(k).startswith(str(argument))])
else:
return str([*self.app.defaults])

View File

@ -26,6 +26,7 @@ import tclCommands.TclCommandInteriors
import tclCommands.TclCommandIsolate
import tclCommands.TclCommandJoinExcellon
import tclCommands.TclCommandJoinGeometry
import tclCommands.TclCommandListSys
import tclCommands.TclCommandMillHoles
import tclCommands.TclCommandMirror
import tclCommands.TclCommandNew