- modified the Paint Tool UI

This commit is contained in:
Marius Stanciu 2020-02-16 03:11:46 +02:00 committed by Marius
parent 25c9a31179
commit 64912949c6
4 changed files with 64 additions and 65 deletions

View File

@ -799,7 +799,7 @@ class App(QtCore.QObject):
"tools_paintorder": 'rev', "tools_paintorder": 'rev',
"tools_paintoverlap": 20, "tools_paintoverlap": 20,
"tools_paintmargin": 0.0, "tools_paintmargin": 0.0,
"tools_paintmethod": "seed", "tools_paintmethod": _("Seed-based"),
"tools_selectmethod": "all", "tools_selectmethod": "all",
"tools_pathconnect": True, "tools_pathconnect": True,
"tools_paintcontour": True, "tools_paintcontour": True,

View File

@ -14,6 +14,7 @@ CAD program, and create G-Code for Isolation routing.
- in Paint Tool added a new method of painting named Combo who will pass through all the methods until the polygon is cleared - in Paint Tool added a new method of painting named Combo who will pass through all the methods until the polygon is cleared
- in Paint Tool attempting to add a new mode suitable for Laser usage - in Paint Tool attempting to add a new mode suitable for Laser usage
- more work in the new Laser Mode in the Paint Tool - more work in the new Laser Mode in the Paint Tool
- modified the Paint Tool UI
14.02.2020 14.02.2020

View File

@ -5761,17 +5761,25 @@ class ToolsPaintPrefGroupUI(OptionsGroupUI):
# Method # Method
methodlabel = QtWidgets.QLabel('%s:' % _('Method')) methodlabel = QtWidgets.QLabel('%s:' % _('Method'))
methodlabel.setToolTip( methodlabel.setToolTip(
_("Algorithm for non-copper clearing:<BR>" _("Algorithm for painting:\n"
"<B>Standard</B>: Fixed step inwards.<BR>" "- Standard: Fixed step inwards.\n"
"<B>Seed-based</B>: Outwards from seed.<BR>" "- Seed-based: Outwards from seed.\n"
"<B>Line-based</B>: Parallel lines.") "- Line-based: Parallel lines.\n"
"- Laser-lines: Active only for Gerber objects.\n"
"Will create lines that follow the traces.\n"
"- Combo: In case of failure a new method will be picked from the above\n"
"in the order specified.")
) )
self.paintmethod_combo = RadioSet([ # self.paintmethod_combo = RadioSet([
{"label": _("Standard"), "value": "standard"}, # {"label": _("Standard"), "value": "standard"},
{"label": _("Seed-based"), "value": "seed"}, # {"label": _("Seed-based"), "value": "seed"},
{"label": _("Straight lines"), "value": "lines"} # {"label": _("Straight lines"), "value": "lines"}
], orientation='vertical', stretch=False) # ], orientation='vertical', stretch=False)
self.paintmethod_combo = FCComboBox()
self.paintmethod_combo.addItems(
[_("Standard"), _("Seed-based"), _("Straight lines"), _("Laser lines"), _("Combo")]
)
grid0.addWidget(methodlabel, 11, 0) grid0.addWidget(methodlabel, 11, 0)
grid0.addWidget(self.paintmethod_combo, 11, 1) grid0.addWidget(self.paintmethod_combo, 11, 1)

View File

@ -14,7 +14,7 @@ from copy import deepcopy
from flatcamParsers.ParseGerber import Gerber from flatcamParsers.ParseGerber import Gerber
from FlatCAMObj import FlatCAMGerber, FlatCAMGeometry from FlatCAMObj import FlatCAMGerber, FlatCAMGeometry
from camlib import Geometry, FlatCAMRTreeStorage from camlib import Geometry, FlatCAMRTreeStorage
from flatcamGUI.GUIElements import FCTable, FCDoubleSpinner, FCCheckBox, FCInputDialog, RadioSet, FCButton from flatcamGUI.GUIElements import FCTable, FCDoubleSpinner, FCCheckBox, FCInputDialog, RadioSet, FCButton, FCComboBox
import FlatCAMApp import FlatCAMApp
from shapely.geometry import base, Polygon, MultiPolygon, LinearRing, Point, MultiLineString from shapely.geometry import base, Polygon, MultiPolygon, LinearRing, Point, MultiLineString
@ -75,15 +75,6 @@ class ToolPaint(FlatCAMTool, Gerber):
# ################################################ # ################################################
# ##### Type of object to be painted ############# # ##### Type of object to be painted #############
# ################################################ # ################################################
self.type_obj_combo = QtWidgets.QComboBox()
self.type_obj_combo.addItem("Gerber")
self.type_obj_combo.addItem("Excellon")
self.type_obj_combo.addItem("Geometry")
# we get rid of item1 ("Excellon") as it is not suitable
self.type_obj_combo.view().setRowHidden(1, True)
self.type_obj_combo.setItemIcon(0, QtGui.QIcon(self.app.resource_location + "/flatcam_icon16.png"))
self.type_obj_combo.setItemIcon(2, QtGui.QIcon(self.app.resource_location + "/geometry16.png"))
self.type_obj_combo_label = QtWidgets.QLabel('%s:' % _("Obj Type")) self.type_obj_combo_label = QtWidgets.QLabel('%s:' % _("Obj Type"))
self.type_obj_combo_label.setToolTip( self.type_obj_combo_label.setToolTip(
@ -93,6 +84,10 @@ class ToolPaint(FlatCAMTool, Gerber):
"of objects that will populate the 'Object' combobox.") "of objects that will populate the 'Object' combobox.")
) )
self.type_obj_combo_label.setMinimumWidth(60) self.type_obj_combo_label.setMinimumWidth(60)
self.type_obj_combo = RadioSet([{'label': "Geometry", 'value': 'geometry'},
{'label': "Gerber", 'value': 'gerber'}])
grid0.addWidget(self.type_obj_combo_label, 1, 0) grid0.addWidget(self.type_obj_combo_label, 1, 0)
grid0.addWidget(self.type_obj_combo, 1, 1) grid0.addWidget(self.type_obj_combo, 1, 1)
@ -371,23 +366,38 @@ class ToolPaint(FlatCAMTool, Gerber):
"- Standard: Fixed step inwards.\n" "- Standard: Fixed step inwards.\n"
"- Seed-based: Outwards from seed.\n" "- Seed-based: Outwards from seed.\n"
"- Line-based: Parallel lines.\n" "- Line-based: Parallel lines.\n"
"- Laser-lines: Active only when Laser Mode is active and only for Gerber objects.\n" "- Laser-lines: Active only for Gerber objects.\n"
"Will create lines that follow the traces.\n" "Will create lines that follow the traces.\n"
"- Combo: In case of failure a new method will be picked from the above\n" "- Combo: In case of failure a new method will be picked from the above\n"
"in the order specified.") "in the order specified.")
) )
self.paintmethod_combo = RadioSet([ # self.paintmethod_combo = RadioSet([
{"label": _("Standard"), "value": "standard"}, # {"label": _("Standard"), "value": "standard"},
{"label": _("Seed-based"), "value": "seed"}, # {"label": _("Seed-based"), "value": "seed"},
{"label": _("Straight lines"), "value": "lines"}, # {"label": _("Straight lines"), "value": "lines"},
{"label": _("Laser lines"), "value": "laser_lines"}, # {"label": _("Laser lines"), "value": "laser_lines"},
{"label": _("Combo"), "value": "combo"} # {"label": _("Combo"), "value": "combo"}
], orientation='vertical', stretch=False) # ], orientation='vertical', stretch=False)
self.paintmethod_combo.setObjectName(_("Method"))
for choice in self.paintmethod_combo.choices: # for choice in self.paintmethod_combo.choices:
if choice['value'] == "laser_lines": # if choice['value'] == "laser_lines":
choice["radio"].setEnabled(False) # choice["radio"].setEnabled(False)
self.paintmethod_combo = FCComboBox()
self.paintmethod_combo.addItems(
[_("Standard"), _("Seed-based"), _("Straight lines"), _("Laser lines"), _("Combo")]
)
self.p_mth = {
_("Standard"): "standard",
_("Seed-based"): "seed",
_("Straight lines"): "lines",
_("Laser lines"): "laser_lines",
_("Combo"): "combo"
}
idx = self.paintmethod_combo.findText(_("Laser lines"))
self.paintmethod_combo.model().item(idx).setEnabled(False)
self.paintmethod_combo.setObjectName(_("Method"))
grid4.addWidget(methodlabel, 7, 0) grid4.addWidget(methodlabel, 7, 0)
grid4.addWidget(self.paintmethod_combo, 7, 1) grid4.addWidget(self.paintmethod_combo, 7, 1)
@ -447,15 +457,6 @@ class ToolPaint(FlatCAMTool, Gerber):
) )
grid4.addWidget(self.rest_cb, 16, 0, 1, 2) grid4.addWidget(self.rest_cb, 16, 0, 1, 2)
# Laser Mode
self.laser_cb = FCCheckBox(_("Laser Mode"))
self.laser_cb.setToolTip(
_("This control is enabled only for Gerber objects.\n"
"If checked then a new method is shown in Methods,\n"
"and it is also added to the Combo Method sequence.")
)
grid4.addWidget(self.laser_cb, 17, 0, 1, 2)
# Polygon selection # Polygon selection
selectlabel = QtWidgets.QLabel('%s:' % _('Selection')) selectlabel = QtWidgets.QLabel('%s:' % _('Selection'))
selectlabel.setToolTip( selectlabel.setToolTip(
@ -635,8 +636,7 @@ class ToolPaint(FlatCAMTool, Gerber):
self.rest_cb.stateChanged.connect(self.on_rest_machining_check) self.rest_cb.stateChanged.connect(self.on_rest_machining_check)
self.box_combo_type.currentIndexChanged.connect(self.on_combo_box_type) self.box_combo_type.currentIndexChanged.connect(self.on_combo_box_type)
self.type_obj_combo.currentIndexChanged.connect(self.on_type_obj_index_changed) self.type_obj_combo.activated_custom.connect(self.on_type_obj_index_changed)
self.laser_cb.stateChanged.connect(self.on_laser_mode_toggled)
self.reset_button.clicked.connect(self.set_tool_ui) self.reset_button.clicked.connect(self.set_tool_ui)
# ############################################################################# # #############################################################################
@ -655,25 +655,18 @@ class ToolPaint(FlatCAMTool, Gerber):
icon=QtGui.QIcon(self.app.resource_location + "/delete32.png") icon=QtGui.QIcon(self.app.resource_location + "/delete32.png")
) )
def on_type_obj_index_changed(self, index): def on_type_obj_index_changed(self, val):
obj_type = self.type_obj_combo.currentIndex() obj_type = 0 if val == 'gerber' else 2
self.obj_combo.setRootModelIndex(self.app.collection.index(obj_type, 0, QtCore.QModelIndex())) self.obj_combo.setRootModelIndex(self.app.collection.index(obj_type, 0, QtCore.QModelIndex()))
self.obj_combo.setCurrentIndex(0) self.obj_combo.setCurrentIndex(0)
if self.type_obj_combo.currentText().lower() == 'gerber': idx = self.paintmethod_combo.findText(_("Laser lines"))
self.laser_cb.setEnabled(True) if self.type_obj_combo.get_value().lower() == 'gerber':
self.paintmethod_combo.model().item(idx).setEnabled(True)
else: else:
self.laser_cb.setEnabled(False) self.paintmethod_combo.model().item(idx).setEnabled(False)
if self.paintmethod_combo.get_value() == _("Laser lines"):
def on_laser_mode_toggled(self, val): self.paintmethod_combo.set_value(_("Straight lines"))
for choice in self.paintmethod_combo.choices:
if choice['value'] == "laser_lines":
if val:
choice["radio"].setEnabled(True)
else:
choice["radio"].setEnabled(False)
if self.paintmethod_combo.get_value() == "laser_lines":
self.paintmethod_combo.set_value('lines')
def install(self, icon=None, separator=None, **kwargs): def install(self, icon=None, separator=None, **kwargs):
FlatCAMTool.install(self, icon, separator, shortcut='ALT+P', **kwargs) FlatCAMTool.install(self, icon, separator, shortcut='ALT+P', **kwargs)
@ -1015,10 +1008,7 @@ class ToolPaint(FlatCAMTool, Gerber):
self.on_tool_type(val=self.tool_type_radio.get_value()) self.on_tool_type(val=self.tool_type_radio.get_value())
# make the default object type, "Geometry" # make the default object type, "Geometry"
self.type_obj_combo.setCurrentIndex(2) self.type_obj_combo.set_value("geometry")
# make the Laser Mode disabled because the Geometry object is default
self.laser_cb.setEnabled(False)
try: try:
diameters = [float(self.app.defaults["tools_painttooldia"])] diameters = [float(self.app.defaults["tools_painttooldia"])]
@ -1727,7 +1717,7 @@ class ToolPaint(FlatCAMTool, Gerber):
self.app.inform.emit('[WARNING] %s' % _('No polygon found.')) self.app.inform.emit('[WARNING] %s' % _('No polygon found.'))
return return
paint_method = method if method is not None else self.paintmethod_combo.get_value() paint_method = method if method is not None else self.p_mth[self.paintmethod_combo.get_value()]
paint_margin = float(self.paintmargin_entry.get_value()) if margin is None else margin paint_margin = float(self.paintmargin_entry.get_value()) if margin is None else margin
# determine if to use the progressive plotting # determine if to use the progressive plotting
prog_plot = True if self.app.defaults["tools_paint_plotting"] == 'progressive' else False prog_plot = True if self.app.defaults["tools_paint_plotting"] == 'progressive' else False
@ -2142,7 +2132,7 @@ class ToolPaint(FlatCAMTool, Gerber):
Usage of the different one is related to when this function is called from a TcL command. Usage of the different one is related to when this function is called from a TcL command.
:return: :return:
""" """
paint_method = method if method is not None else self.paintmethod_combo.get_value() paint_method = method if method is not None else self.p_mth[self.paintmethod_combo.get_value()]
if margin is not None: if margin is not None:
paint_margin = margin paint_margin = margin
@ -3207,7 +3197,7 @@ class ToolPaint(FlatCAMTool, Gerber):
Usage of the different one is related to when this function is called from a TcL command. Usage of the different one is related to when this function is called from a TcL command.
:return: :return:
""" """
paint_method = method if method is not None else self.paintmethod_combo.get_value() paint_method = method if method is not None else self.p_mth[self.paintmethod_combo.get_value()]
if margin is not None: if margin is not None:
paint_margin = margin paint_margin = margin