From b8a8cfe1fd360af292065f20802f9f0305b80204 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Fri, 25 May 2018 12:41:17 +0300 Subject: [PATCH 1/7] - added support for Gerber files that have apertures with size zero Basically it test the "size" value for the current aperture and if it's found with zero value it will replace with a really small value (0.0000001)that for all practical purposes is "zero" (0.0000001 in inch is really small and in mm is even smaller) - correcting small typos --- camlib.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/camlib.py b/camlib.py index d79b4532..ab070333 100644 --- a/camlib.py +++ b/camlib.py @@ -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} self.tools = {} - self.drills = [] ## IN|MM -> Units are inherited from Geometry From f30b44d63745733891839f243733f9f32cd18f30 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Fri, 1 Jun 2018 14:50:29 +0300 Subject: [PATCH 2/7] - automatically select the object on every new_object while previously selected objects are deselected leaving the new object as the only one selected. --- FlatCAMApp.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index f2d6f500..0d2b4048 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -1567,6 +1567,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)) From b63c3219a77d9524538e099910365394946e1750 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Fri, 1 Jun 2018 21:05:51 +0300 Subject: [PATCH 3/7] - added a new global setting only accessible through the Tcl Shell, named: global_mouse_pan_button It can be set through set_sys TclCommand or the value getted through get_sys TclCommand. Values are 1 for left mouse button, 2 for middle mouse button and 3 for right mouse button. It does hurt my hand (wrist) keeping the middle mouse button pressed when panning and I very much preffer panning with RMB. The default setting is pan_button = middle mouse button. --- FlatCAMApp.py | 3 +++ PlotCanvas.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index f2d6f500..5aed5e12 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -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 #### diff --git a/PlotCanvas.py b/PlotCanvas.py index 94469d2b..6d94b042 100644 --- a/PlotCanvas.py +++ b/PlotCanvas.py @@ -445,7 +445,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 +461,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() From f026d8cae6e070ebc432695125393b2dc76e8bdc Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sat, 2 Jun 2018 15:06:20 +0300 Subject: [PATCH 4/7] - addded a new TclCommand that list the names of the system parameters. It is useful if we don't remember correctly the name of the system parameter or if we want to look for a certain system parameter as the list is big and it grows. --- tclCommands/TclCommandListSys.py | 43 ++++++++++++++++++++++++++++++++ tclCommands/__init__.py | 1 + 2 files changed, 44 insertions(+) create mode 100644 tclCommands/TclCommandListSys.py diff --git a/tclCommands/TclCommandListSys.py b/tclCommands/TclCommandListSys.py new file mode 100644 index 00000000..d0e2b9ca --- /dev/null +++ b/tclCommands/TclCommandListSys.py @@ -0,0 +1,43 @@ +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([ + ]) + + # 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" + "Note: Use get_sys command to get the value and set_sys command to set it.", + 'args': collections.OrderedDict([ + ]), + 'examples': [] + } + + def execute(self, args, unnamed_args): + """ + + :param args: + :param unnamed_args: + :return: + """ + return str([*self.app.defaults]) \ No newline at end of file diff --git a/tclCommands/__init__.py b/tclCommands/__init__.py index c1ffc809..bb646c84 100644 --- a/tclCommands/__init__.py +++ b/tclCommands/__init__.py @@ -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 From ddda4773e3ec61251da7275f791e6b1d26e6940d Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sat, 2 Jun 2018 16:11:40 +0300 Subject: [PATCH 5/7] - added the possibility of selecting which system parameters to list starting with the letter(s) offered as argument. It's a way to narrow the list down. If no selection letters are offered it will list on screen the entire list of system parameters. --- tclCommands/TclCommandListSys.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tclCommands/TclCommandListSys.py b/tclCommands/TclCommandListSys.py index d0e2b9ca..179be874 100644 --- a/tclCommands/TclCommandListSys.py +++ b/tclCommands/TclCommandListSys.py @@ -14,6 +14,7 @@ class TclCommandListSys(TclCommand): # 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 @@ -27,10 +28,17 @@ class TclCommandListSys(TclCommand): # structured help for current command, args needs to be ordered help = { 'main': "Returns the list of the names of system variables.\n" - "Note: Use get_sys command to get the value and set_sys command to set it.", + "Without a parameter it will list all the system parameters. " + "As a parameter 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 command to get the value and set_sys command to set it.\n", 'args': collections.OrderedDict([ ]), - 'examples': [] + 'examples': ['list_sys', + 'list_sys gerber', + 'list_sys cncjob'] } def execute(self, args, unnamed_args): @@ -40,4 +48,9 @@ class TclCommandListSys(TclCommand): :param unnamed_args: :return: """ - return str([*self.app.defaults]) \ No newline at end of file + if 'selection' in args: + argument = args['selection'] + print(argument) + return str([k for k in self.app.defaults.keys() if str(k).startswith(str(argument))]) + else: + return str([*self.app.defaults]) \ No newline at end of file From 21406fcccfcd971e89afbfbbe5933c4bf5cfdf22 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sat, 2 Jun 2018 16:17:46 +0300 Subject: [PATCH 6/7] - some small corrections --- tclCommands/TclCommandListSys.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tclCommands/TclCommandListSys.py b/tclCommands/TclCommandListSys.py index 179be874..87d5a761 100644 --- a/tclCommands/TclCommandListSys.py +++ b/tclCommands/TclCommandListSys.py @@ -28,17 +28,18 @@ class TclCommandListSys(TclCommand): # structured help for current command, args needs to be ordered help = { 'main': "Returns the list of the names of system variables.\n" - "Without a parameter it will list all the system parameters. " - "As a parameter use first letter or first letters from the name " + "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 command to get the value and set_sys command to set it.\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 cncjob'] + 'list_sys cncj'] } def execute(self, args, unnamed_args): @@ -50,7 +51,6 @@ class TclCommandListSys(TclCommand): """ if 'selection' in args: argument = args['selection'] - print(argument) return str([k for k in self.app.defaults.keys() if str(k).startswith(str(argument))]) else: return str([*self.app.defaults]) \ No newline at end of file From 6bf38eb00e0281464e7f53aeaf09045fe62ed7cc Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sat, 2 Jun 2018 17:32:12 +0300 Subject: [PATCH 7/7] - added infinite lines on X and Y axis centered in origin, (0,0) coords It add a visual marker and it helps in judging the position of the plotted object in relation to the origin. --- PlotCanvas.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PlotCanvas.py b/PlotCanvas.py index 94469d2b..ae882cfb 100644 --- a/PlotCanvas.py +++ b/PlotCanvas.py @@ -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)