diff --git a/README.md b/README.md index 4445109e..7579abc9 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ CAD program, and create G-Code for Isolation routing. - replaced setFixedWidth calls with setMinimumWidth - recoded the camlib.Geometry.isolation_geometry() function +- started to work on Paint Area in Paint Tool 6.08.2019 diff --git a/flatcamGUI/FlatCAMGUI.py b/flatcamGUI/FlatCAMGUI.py index 5da3702f..25bebdc9 100644 --- a/flatcamGUI/FlatCAMGUI.py +++ b/flatcamGUI/FlatCAMGUI.py @@ -3255,9 +3255,9 @@ class ToolsPreferencesUI(QtWidgets.QWidget): self.setLayout(self.layout) self.tools_ncc_group = ToolsNCCPrefGroupUI() - self.tools_ncc_group.setMinimumWidth(200) + self.tools_ncc_group.setMinimumWidth(220) self.tools_paint_group = ToolsPaintPrefGroupUI() - self.tools_paint_group.setMinimumWidth(200) + self.tools_paint_group.setMinimumWidth(220) self.tools_cutout_group = ToolsCutoutPrefGroupUI() self.tools_cutout_group.setMinimumWidth(220) @@ -6126,8 +6126,8 @@ class ToolsPaintPrefGroupUI(OptionsGroupUI): grid0.addWidget(selectlabel, 6, 0) self.selectmethod_combo = RadioSet([ {"label": _("Single"), "value": "single"}, - {"label": _("All"), "value": "all"}, - # {"label": "Rectangle", "value": "rectangle"} + {"label": _("Area"), "value": "area"}, + {"label": _("All"), "value": "all"} ]) grid0.addWidget(self.selectmethod_combo, 6, 1) diff --git a/flatcamTools/ToolPaint.py b/flatcamTools/ToolPaint.py index 24678f81..24026d41 100644 --- a/flatcamTools/ToolPaint.py +++ b/flatcamTools/ToolPaint.py @@ -245,8 +245,8 @@ class ToolPaint(FlatCAMTool, Gerber): # grid3 = QtWidgets.QGridLayout() self.selectmethod_combo = RadioSet([ {"label": _("Single"), "value": "single"}, - {"label": _("All"), "value": "all"}, - # {"label": "Rectangle", "value": "rectangle"} + {"label": _("Area"), "value": "area"}, + {"label": _("All"), "value": "all"} ]) grid3.addWidget(self.selectmethod_combo, 7, 1) @@ -353,6 +353,10 @@ class ToolPaint(FlatCAMTool, Gerber): self.addtool_btn.setDisabled(True) self.deltool_btn.setDisabled(True) self.tools_table.setContextMenuPolicy(Qt.NoContextMenu) + if self.selectmethod_combo.get_value() == 'area': + # disable rest-machining for single polygon painting + self.rest_cb.set_value(False) + self.rest_cb.setDisabled(True) else: self.rest_cb.setDisabled(False) self.addtool_entry.setDisabled(False) @@ -433,7 +437,6 @@ class ToolPaint(FlatCAMTool, Gerber): self.tools_table.setContextMenuPolicy(Qt.NoContextMenu) def build_ui(self): - try: # if connected, disconnect the signal from the slot on item_changed as it creates issues self.tools_table.itemChanged.disconnect() @@ -787,7 +790,7 @@ class ToolPaint(FlatCAMTool, Gerber): connect=connect, contour=contour) - if select_method == "single": + elif select_method == "single": self.app.inform.emit(_("[WARNING_NOTCL] Click inside the desired polygon.")) # use the first tool in the tool table; get the diameter @@ -815,6 +818,34 @@ class ToolPaint(FlatCAMTool, Gerber): self.app.plotcanvas.vis_disconnect('mouse_press', self.app.on_mouse_click_over_plot) self.app.plotcanvas.vis_connect('mouse_press', doit) + elif select_method == "area": + self.app.inform.emit(_("[WARNING_NOTCL] Click the start point of the paint area.")) + + # use the first tool in the tool table; get the diameter + tooldia = float('%.4f' % float(self.tools_table.item(0, 1).text())) + + # To be called after clicking on the plot. + def doit(event): + # do paint single only for left mouse clicks + if event.button == 1: + self.app.inform.emit(_("Painting polygon...")) + self.app.plotcanvas.vis_disconnect('mouse_press', doit) + + pos = self.app.plotcanvas.vispy_canvas.translate_coords(event.pos) + if self.app.grid_status(): + pos = self.app.geo_editor.snap(pos[0], pos[1]) + + self.paint_poly(self.paint_obj, + inside_pt=[pos[0], pos[1]], + tooldia=tooldia, + overlap=overlap, + connect=connect, + contour=contour) + self.app.plotcanvas.vis_connect('mouse_press', self.app.on_mouse_click_over_plot) + + self.app.plotcanvas.vis_disconnect('mouse_press', self.app.on_mouse_click_over_plot) + self.app.plotcanvas.vis_connect('mouse_press', doit) + def paint_poly(self, obj, inside_pt, tooldia, overlap, outname=None, connect=True, contour=True): """ Paints a polygon selected by clicking on its interior.