From cf8a27782526d3d8db9cd3363af0d79d8e8814e6 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sun, 11 Aug 2019 02:18:32 +0300 Subject: [PATCH] - trying to fix reported bugs --- FlatCAMApp.py | 34 ++++++++++++------------------ FlatCAMObj.py | 4 ++-- README.md | 1 + camlib.py | 6 +++--- flatcamEditors/FlatCAMExcEditor.py | 6 +++--- flatcamEditors/FlatCAMGeoEditor.py | 21 ++++-------------- flatcamEditors/FlatCAMGrbEditor.py | 6 +++--- flatcamTools/ToolMeasurement.py | 4 ++-- flatcamTools/ToolPaint.py | 8 +++---- 9 files changed, 36 insertions(+), 54 deletions(-) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 7d1704d4..2416b7d1 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -5555,9 +5555,9 @@ class App(QtCore.QObject): def grid_status(self): if self.ui.grid_snap_btn.isChecked(): - return 1 + return True else: - return 0 + return False def populate_cmenu_grids(self): units = self.ui.general_defaults_form.general_app_group.units_radio.get_value().lower() @@ -5567,7 +5567,7 @@ class App(QtCore.QObject): grid_toggle = self.ui.cmenu_gridmenu.addAction(QtGui.QIcon('share/grid32_menu.png'), _("Grid On/Off")) grid_toggle.setCheckable(True) - if self.grid_status(): + if self.grid_status() == True: grid_toggle.setChecked(True) else: grid_toggle.setChecked(False) @@ -5701,12 +5701,13 @@ class App(QtCore.QObject): self.plotcanvas.vispy_canvas.view.camera.pan_button_setting = self.defaults['global_pan_button'] self.pos_canvas = self.plotcanvas.vispy_canvas.translate_coords(event.pos) - self.pos = (self.pos_canvas[0], self.pos_canvas[1]) - self.app_cursor.enabled = False - if self.grid_status(): + if self.grid_status() == True: self.pos = self.geo_editor.snap(self.pos_canvas[0], self.pos_canvas[1]) self.app_cursor.enabled = True + else: + self.pos = (self.pos_canvas[0], self.pos_canvas[1]) + self.app_cursor.enabled = False try: modifiers = QtWidgets.QApplication.keyboardModifiers() @@ -5831,26 +5832,20 @@ class App(QtCore.QObject): :param event: contains information about the event. :return: """ - + pos = 0, 0 pos_canvas = self.plotcanvas.vispy_canvas.translate_coords(event.pos) - if self.grid_status(): + if self.grid_status() == True: pos = self.geo_editor.snap(pos_canvas[0], pos_canvas[1]) else: pos = (pos_canvas[0], pos_canvas[1]) # if the released mouse button was RMB then test if it was a panning motion or not, if not it was a context # canvas menu - try: - if event.button == 2: # right click - if self.ui.popMenu.mouse_is_panning is False: - - self.cursor = QtGui.QCursor() - self.populate_cmenu_grids() - self.ui.popMenu.popup(self.cursor.pos()) - - except Exception as e: - log.warning("Error: %s" % str(e)) - return + if event.button == 2: # right click + if self.ui.popMenu.mouse_is_panning is False: + self.cursor = QtGui.QCursor() + self.populate_cmenu_grids() + self.ui.popMenu.popup(self.cursor.pos()) # if the released mouse button was LMB then test if we had a right-to-left selection or a left-to-right # selection and then select a type of selection ("enclosing" or "touching") @@ -5866,7 +5861,6 @@ class App(QtCore.QObject): # delete the selection shape(S) as it may be in the way self.delete_selection_shape() self.delete_hover_shape() - else: if self.selection_type is not None: self.selection_area_handler(self.pos, pos, self.selection_type) diff --git a/FlatCAMObj.py b/FlatCAMObj.py index 260f63df..397f89f4 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -894,8 +894,8 @@ class FlatCAMGerber(FlatCAMObj, Gerber): return 'fail' return geom - if float(self.options["isotooldia"]) < 0: - self.options["isotooldia"] = -self.options["isotooldia"] + # if float(self.options["isotooldia"]) < 0: + # self.options["isotooldia"] = -self.options["isotooldia"] if combine: if self.iso_type == 0: diff --git a/README.md b/README.md index 074928dc..08c78261 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ CAD program, and create G-Code for Isolation routing. 11.08.2019 - small changes regarding the Project Title +- trying to fix reported bugs 10.08.2019 diff --git a/camlib.py b/camlib.py index 0c18ec7b..6a898185 100644 --- a/camlib.py +++ b/camlib.py @@ -560,7 +560,7 @@ class Geometry(object): for el in self.solid_geometry: geo_iso.append(el.buffer(offset, int(int(self.geo_steps_per_circle) / 4))) except TypeError: - geo_iso = self.solid_geometry.buffer(offset, int(int(self.geo_steps_per_circle) / 4)) + geo_iso = [self.solid_geometry.buffer(offset, int(int(self.geo_steps_per_circle) / 4))] else: try: __ = iter(self.solid_geometry) @@ -568,8 +568,8 @@ class Geometry(object): geo_iso.append(el.buffer(offset, int(int(self.geo_steps_per_circle) / 4), join_style=corner)) except TypeError: - geo_iso = self.solid_geometry.buffer(offset, int(int(self.geo_steps_per_circle) / 4), - join_style=corner) + geo_iso = [self.solid_geometry.buffer(offset, int(int(self.geo_steps_per_circle) / 4), + join_style=corner)] # end of replaced block if follow: diff --git a/flatcamEditors/FlatCAMExcEditor.py b/flatcamEditors/FlatCAMExcEditor.py index 7c5e8726..6e93cf82 100644 --- a/flatcamEditors/FlatCAMExcEditor.py +++ b/flatcamEditors/FlatCAMExcEditor.py @@ -2169,7 +2169,7 @@ class FlatCAMExcEditor(QtCore.QObject): self.pos = self.canvas.vispy_canvas.translate_coords(event.pos) - if self.app.grid_status(): + if self.app.grid_status() == True: self.pos = self.app.geo_editor.snap(self.pos[0], self.pos[1]) self.app.app_cursor.enabled = True # Update cursor @@ -2300,7 +2300,7 @@ class FlatCAMExcEditor(QtCore.QObject): self.modifiers = QtWidgets.QApplication.keyboardModifiers() pos_canvas = self.canvas.vispy_canvas.translate_coords(event.pos) - if self.app.grid_status(): + if self.app.grid_status() == True: pos = self.app.geo_editor.snap(pos_canvas[0], pos_canvas[1]) else: pos = (pos_canvas[0], pos_canvas[1]) @@ -2432,7 +2432,7 @@ class FlatCAMExcEditor(QtCore.QObject): return # ## Snap coordinates - if self.app.grid_status(): + if self.app.grid_status() == True: x, y = self.app.geo_editor.snap(x, y) self.app.app_cursor.enabled = True # Update cursor diff --git a/flatcamEditors/FlatCAMGeoEditor.py b/flatcamEditors/FlatCAMGeoEditor.py index 1d75114f..b29d8683 100644 --- a/flatcamEditors/FlatCAMGeoEditor.py +++ b/flatcamEditors/FlatCAMGeoEditor.py @@ -3497,7 +3497,7 @@ class FlatCAMGeoEditor(QtCore.QObject): self.pos = self.canvas.vispy_canvas.translate_coords(event.pos) - if self.app.grid_status(): + if self.app.grid_status() == True: self.pos = self.app.geo_editor.snap(self.pos[0], self.pos[1]) self.app.app_cursor.enabled = True # Update cursor @@ -3507,7 +3507,7 @@ class FlatCAMGeoEditor(QtCore.QObject): self.pos = (self.pos[0], self.pos[1]) self.app.app_cursor.enabled = False - if event.button is 1: + if event.button == 1: self.app.ui.rel_position_label.setText("Dx: %.4f   Dy: " "%.4f    " % (0, 0)) @@ -3573,7 +3573,7 @@ class FlatCAMGeoEditor(QtCore.QObject): return # # ## Snap coordinates - if self.app.grid_status(): + if self.app.grid_status() == True: x, y = self.snap(x, y) self.app.app_cursor.enabled = True # Update cursor @@ -3625,7 +3625,7 @@ class FlatCAMGeoEditor(QtCore.QObject): def on_geo_click_release(self, event): pos_canvas = self.canvas.vispy_canvas.translate_coords(event.pos) - if self.app.grid_status(): + if self.app.grid_status() == True: pos = self.snap(pos_canvas[0], pos_canvas[1]) else: pos = (pos_canvas[0], pos_canvas[1]) @@ -3662,19 +3662,6 @@ class FlatCAMGeoEditor(QtCore.QObject): self.app.inform.emit(_("[success] Done.")) self.select_tool(self.active_tool.name) - # MS: always return to the Select Tool if modifier key is not pressed - # else return to the current tool - # key_modifier = QtWidgets.QApplication.keyboardModifiers() - # if self.app.defaults["global_mselect_key"] == 'Control': - # modifier_to_use = Qt.ControlModifier - # else: - # modifier_to_use = Qt.ShiftModifier - # - # if key_modifier == modifier_to_use: - # self.select_tool(self.active_tool.name) - # else: - # self.select_tool("select") - except Exception as e: log.warning("Error: %s" % str(e)) return diff --git a/flatcamEditors/FlatCAMGrbEditor.py b/flatcamEditors/FlatCAMGrbEditor.py index d711ef53..12eebc07 100644 --- a/flatcamEditors/FlatCAMGrbEditor.py +++ b/flatcamEditors/FlatCAMGrbEditor.py @@ -3986,7 +3986,7 @@ class FlatCAMGrbEditor(QtCore.QObject): self.pos = self.canvas.vispy_canvas.translate_coords(event.pos) - if self.app.grid_status(): + if self.app.grid_status() == True: self.pos = self.app.geo_editor.snap(self.pos[0], self.pos[1]) self.app.app_cursor.enabled = True # Update cursor @@ -4048,7 +4048,7 @@ class FlatCAMGrbEditor(QtCore.QObject): self.modifiers = QtWidgets.QApplication.keyboardModifiers() pos_canvas = self.canvas.vispy_canvas.translate_coords(event.pos) - if self.app.grid_status(): + if self.app.grid_status() == True: pos = self.app.geo_editor.snap(pos_canvas[0], pos_canvas[1]) else: pos = (pos_canvas[0], pos_canvas[1]) @@ -4201,7 +4201,7 @@ class FlatCAMGrbEditor(QtCore.QObject): return # # ## Snap coordinates - if self.app.grid_status(): + if self.app.grid_status() == True: x, y = self.app.geo_editor.snap(x, y) self.app.app_cursor.enabled = True # Update cursor diff --git a/flatcamTools/ToolMeasurement.py b/flatcamTools/ToolMeasurement.py index d297650e..81c7eba2 100644 --- a/flatcamTools/ToolMeasurement.py +++ b/flatcamTools/ToolMeasurement.py @@ -249,7 +249,7 @@ class Measurement(FlatCAMTool): if event.button == 1: pos_canvas = self.canvas.vispy_canvas.translate_coords(event.pos) # if GRID is active we need to get the snapped positions - if self.app.grid_status(): + if self.app.grid_status() == True: pos = self.app.geo_editor.snap(pos_canvas[0], pos_canvas[1]) else: pos = pos_canvas[0], pos_canvas[1] @@ -287,7 +287,7 @@ class Measurement(FlatCAMTool): def on_mouse_move_meas(self, event): try: # May fail in case mouse not within axes pos_canvas = self.app.plotcanvas.vispy_canvas.translate_coords(event.pos) - if self.app.grid_status(): + if self.app.grid_status() == True: pos = self.app.geo_editor.snap(pos_canvas[0], pos_canvas[1]) self.app.app_cursor.enabled = True # Update cursor diff --git a/flatcamTools/ToolPaint.py b/flatcamTools/ToolPaint.py index 64650eee..710d6eb4 100644 --- a/flatcamTools/ToolPaint.py +++ b/flatcamTools/ToolPaint.py @@ -807,7 +807,7 @@ class ToolPaint(FlatCAMTool, Gerber): self.app.plotcanvas.vis_disconnect('mouse_press', doit) pos = self.app.plotcanvas.vispy_canvas.translate_coords(event.pos) - if self.app.grid_status(): + if self.app.grid_status() == True: pos = self.app.geo_editor.snap(pos[0], pos[1]) self.paint_poly(self.paint_obj, @@ -836,7 +836,7 @@ class ToolPaint(FlatCAMTool, Gerber): self.app.inform.emit(_("[WARNING_NOTCL] Click the end point of the paint area.")) self.cursor_pos = self.app.plotcanvas.vispy_canvas.translate_coords(event.pos) - if self.app.grid_status(): + 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(_("Done.")) @@ -844,7 +844,7 @@ class ToolPaint(FlatCAMTool, Gerber): self.app.delete_selection_shape() curr_pos = self.app.plotcanvas.vispy_canvas.translate_coords(event.pos) - if self.app.grid_status(): + if self.app.grid_status() == True: curr_pos = self.app.geo_editor.snap(curr_pos[0], curr_pos[1]) x0, y0 = self.cursor_pos[0], self.cursor_pos[1] @@ -874,7 +874,7 @@ class ToolPaint(FlatCAMTool, Gerber): curr_pos = self.app.plotcanvas.vispy_canvas.translate_coords(event.pos) self.app.app_cursor.enabled = False - if self.app.grid_status(): + if self.app.grid_status() == True: self.app.app_cursor.enabled = True # Update cursor curr_pos = self.app.geo_editor.snap(curr_pos[0], curr_pos[1])