- working on a new feature: adding interdiction area for Gcode generation. They will be added in the Geometry Object

This commit is contained in:
Marius Stanciu
2020-05-02 22:53:48 +03:00
committed by Marius
parent e159bc3b45
commit 2da0853b23
22 changed files with 468 additions and 26 deletions

View File

@@ -4146,6 +4146,29 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
# Jump to coords
if key == QtCore.Qt.Key_J:
self.app.on_jump_to()
elif self.app.call_source == 'geometry':
if modifiers == QtCore.Qt.ControlModifier:
pass
elif modifiers == QtCore.Qt.AltModifier:
pass
elif modifiers == QtCore.Qt.ShiftModifier:
pass
# NO MODIFIER
elif modifiers == QtCore.Qt.NoModifier:
if key == QtCore.Qt.Key_Escape or key == 'Escape':
sel_obj = self.app.collection.get_active()
assert sel_obj.kind == 'geometry', "Expected a Geometry Object, got %s" % type(sel_obj)
sel_obj.area_disconnect()
return
if key == QtCore.Qt.Key_G or key == 'G':
self.app.ui.grid_snap_btn.trigger()
return
# Jump to coords
if key == QtCore.Qt.Key_J or key == 'J':
self.app.on_jump_to()
def createPopupMenu(self):
menu = super().createPopupMenu()

View File

@@ -2022,14 +2022,94 @@ class GeometryObjectUI(ObjectUI):
grid4.addWidget(pp_label, 11, 0)
grid4.addWidget(self.pp_geometry_name_cb, 11, 1)
grid4.addWidget(QtWidgets.QLabel(''), 12, 0, 1, 2)
# grid4.addWidget(QtWidgets.QLabel(''), 12, 0, 1, 2)
# Exclusion Areas
self.exclusion_cb = FCCheckBox('%s:' % _("Exclusion areas"))
self.exclusion_cb.setToolTip(
_(
"Include exclusion areas.\n"
"In those areas the travel of the tools\n"
"is forbidden."
)
)
grid4.addWidget(self.exclusion_cb, 12, 0, 1, 2)
# ------------------------------------------------------------------------------------------------------------
# ------------------------- EXCLUSION AREAS ------------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------------
self.exclusion_frame = QtWidgets.QFrame()
self.exclusion_frame.setContentsMargins(0, 0, 0, 0)
grid4.addWidget(self.exclusion_frame, 14, 0, 1, 2)
self.exclusion_box = QtWidgets.QVBoxLayout()
self.exclusion_box.setContentsMargins(0, 0, 0, 0)
self.exclusion_frame.setLayout(self.exclusion_box)
h_lay = QtWidgets.QHBoxLayout()
self.exclusion_box.addLayout(h_lay)
# Button Add Area
self.add_area_button = QtWidgets.QPushButton(_('Add area'))
self.add_area_button.setToolTip(_("Add an Exclusion Area."))
h_lay.addWidget(self.add_area_button)
# Button Delete Area
self.delete_area_button = QtWidgets.QPushButton(_('Clear areas'))
self.delete_area_button.setToolTip(_("Delete all exclusion areas."))
h_lay.addWidget(self.delete_area_button)
grid_l = QtWidgets.QGridLayout()
grid_l.setColumnStretch(0, 0)
grid_l.setColumnStretch(1, 1)
self.exclusion_box.addLayout(grid_l)
# Area Selection shape
self.area_shape_label = QtWidgets.QLabel('%s:' % _("Shape"))
self.area_shape_label.setToolTip(
_("The kind of selection shape used for area selection.")
)
self.area_shape_radio = RadioSet([{'label': _("Square"), 'value': 'square'},
{'label': _("Polygon"), 'value': 'polygon'}])
grid_l.addWidget(self.area_shape_label, 0, 0)
grid_l.addWidget(self.area_shape_radio, 0, 1)
# Chose Strategy
self.strategy_label = FCLabel('%s:' % _("Strategy"))
self.strategy_label.setToolTip(_("The strategy followed when encountering an exclusion area.\n"
"Can be:\n"
"- Over -> when encountering the area, the tool will go to a set height\n"
"- Around -> will avoid the exclusion area by going around the area"))
self.strategy_radio = RadioSet([{'label': _('Over'), 'value': 'over'},
{'label': _('Around'), 'value': 'around'}])
grid_l.addWidget(self.strategy_label, 1, 0)
grid_l.addWidget(self.strategy_radio, 1, 1)
# Over Z
self.over_z_label = FCLabel('%s:' % _("Over Z"))
self.over_z_label.setToolTip(_("The height Z to which the tool will rise in order to avoid\n"
"an interdiction area."))
self.over_z_entry = FCDoubleSpinner()
self.over_z_entry.set_range(0.000, 9999.9999)
self.over_z_entry.set_precision(self.decimals)
grid_l.addWidget(self.over_z_label, 2, 0)
grid_l.addWidget(self.over_z_entry, 2, 1)
# -------------------------- EXCLUSION AREAS END -------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------------
self.ois_exclusion_geo = OptionalInputSection(self.exclusion_cb, [self.exclusion_frame])
warning_lbl = QtWidgets.QLabel(
_(
"Add / Select at least one tool in the tool-table.\n"
"Click the # header to select all, or Ctrl + LMB\n"
"for custom selection of tools."
))
grid4.addWidget(warning_lbl, 13, 0, 1, 2)
grid4.addWidget(warning_lbl, 15, 0, 1, 2)
# Button
self.generate_cnc_button = QtWidgets.QPushButton(_('Generate CNCJob object'))
@@ -2042,9 +2122,9 @@ class GeometryObjectUI(ObjectUI):
font-weight: bold;
}
""")
grid4.addWidget(self.generate_cnc_button, 14, 0, 1, 2)
grid4.addWidget(self.generate_cnc_button, 17, 0, 1, 2)
grid4.addWidget(QtWidgets.QLabel(''), 15, 0, 1, 2)
grid4.addWidget(QtWidgets.QLabel(''), 19, 0, 1, 2)
# ##############
# Paint area ##
@@ -2053,7 +2133,7 @@ class GeometryObjectUI(ObjectUI):
self.tools_label.setToolTip(
_("Launch Paint Tool in Tools Tab.")
)
grid4.addWidget(self.tools_label, 16, 0, 1, 2)
grid4.addWidget(self.tools_label, 20, 0, 1, 2)
# Paint Button
self.paint_tool_button = QtWidgets.QPushButton(_('Paint Tool'))
@@ -2071,7 +2151,7 @@ class GeometryObjectUI(ObjectUI):
font-weight: bold;
}
""")
grid4.addWidget(self.paint_tool_button, 17, 0, 1, 2)
grid4.addWidget(self.paint_tool_button, 22, 0, 1, 2)
# NCC Tool
self.generate_ncc_button = QtWidgets.QPushButton(_('NCC Tool'))
@@ -2085,7 +2165,7 @@ class GeometryObjectUI(ObjectUI):
font-weight: bold;
}
""")
grid4.addWidget(self.generate_ncc_button, 18, 0, 1, 2)
grid4.addWidget(self.generate_ncc_button, 24, 0, 1, 2)
class CNCObjectUI(ObjectUI):

View File

@@ -303,6 +303,10 @@ class PreferencesUIManager:
"geometry_f_plunge": self.ui.geometry_defaults_form.geometry_adv_opt_group.fplunge_cb,
"geometry_segx": self.ui.geometry_defaults_form.geometry_adv_opt_group.segx_entry,
"geometry_segy": self.ui.geometry_defaults_form.geometry_adv_opt_group.segy_entry,
"geometry_area_exclusion": self.ui.geometry_defaults_form.geometry_adv_opt_group.exclusion_cb,
"geometry_area_shape": self.ui.geometry_defaults_form.geometry_adv_opt_group.area_shape_radio,
"geometry_area_strategy": self.ui.geometry_defaults_form.geometry_adv_opt_group.strategy_radio,
"geometry_area_overz": self.ui.geometry_defaults_form.geometry_adv_opt_group.over_z_entry,
# Geometry Editor
"geometry_editor_sel_limit": self.ui.geometry_defaults_form.geometry_editor_group.sel_limit_entry,

View File

@@ -1,7 +1,7 @@
from PyQt5 import QtWidgets
from PyQt5.QtCore import QSettings
from flatcamGUI.GUIElements import FCEntry, FloatEntry, FCDoubleSpinner, FCCheckBox, RadioSet
from flatcamGUI.GUIElements import FCEntry, FloatEntry, FCDoubleSpinner, FCCheckBox, RadioSet, FCLabel
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI
import gettext
@@ -186,4 +186,61 @@ class GeometryAdvOptPrefGroupUI(OptionsGroupUI):
grid1.addWidget(segy_label, 11, 0)
grid1.addWidget(self.segy_entry, 11, 1)
# -----------------------------
# --- Area Exclusion ----------
# -----------------------------
self.adv_label = QtWidgets.QLabel('<b>%s:</b>' % _('Area Exclusion'))
self.adv_label.setToolTip(
_("Area exclusion parameters.\n"
"Those parameters are available only for\n"
"Advanced App. Level.")
)
grid1.addWidget(self.adv_label, 12, 0, 1, 2)
# Exclusion Area CB
self.exclusion_cb = FCCheckBox('%s:' % _("Exclusion areas"))
self.exclusion_cb.setToolTip(
_(
"Include exclusion areas.\n"
"In those areas the travel of the tools\n"
"is forbidden."
)
)
grid1.addWidget(self.exclusion_cb, 13, 0, 1, 2)
# Area Selection shape
self.area_shape_label = QtWidgets.QLabel('%s:' % _("Shape"))
self.area_shape_label.setToolTip(
_("The kind of selection shape used for area selection.")
)
self.area_shape_radio = RadioSet([{'label': _("Square"), 'value': 'square'},
{'label': _("Polygon"), 'value': 'polygon'}])
grid1.addWidget(self.area_shape_label, 14, 0)
grid1.addWidget(self.area_shape_radio, 14, 1)
# Chose Strategy
self.strategy_label = FCLabel('%s:' % _("Strategy"))
self.strategy_label.setToolTip(_("The strategy followed when encountering an exclusion area.\n"
"Can be:\n"
"- Over -> when encountering the area, the tool will go to a set height\n"
"- Around -> will avoid the exclusion area by going around the area"))
self.strategy_radio = RadioSet([{'label': _('Over'), 'value': 'over'},
{'label': _('Around'), 'value': 'around'}])
grid1.addWidget(self.strategy_label, 15, 0)
grid1.addWidget(self.strategy_radio, 15, 1)
# Over Z
self.over_z_label = FCLabel('%s:' % _("Over Z"))
self.over_z_label.setToolTip(_("The height Z to which the tool will rise in order to avoid\n"
"an interdiction area."))
self.over_z_entry = FCDoubleSpinner()
self.over_z_entry.set_range(0.000, 9999.9999)
self.over_z_entry.set_precision(self.decimals)
grid1.addWidget(self.over_z_label, 18, 0)
grid1.addWidget(self.over_z_entry, 18, 1)
self.layout.addStretch()