- updated the new shortcut list with the shortcuts added lately

- now the special messages in the Shell are color coded according to the level. Before they all were RED. Now the WARNINGS are yellow, ERRORS are red and SUCCESS is a dark green. Also the level is in CAPS LOCK to make them more obvious
- some more changes to GUI interface (solved issues)
- added some status bar messages in the Geometry Editor to guide the user when using the Geometry Tools
- now the '`' shortcut key that shows the 'shortcut key list' in Editors points to the same window which is created in a tab no longer as a pop-up window. This tab can be detached if needed.
This commit is contained in:
Marius Stanciu
2019-02-03 15:13:09 +02:00
committed by Marius S
parent e5ebfac3ce
commit 6ea3499d39
22 changed files with 428 additions and 409 deletions

View File

@@ -590,6 +590,7 @@ class FCCircle(FCShapeTool):
self.points.append(point)
if len(self.points) == 1:
self.draw_app.app.inform.emit("Click on Circle perimeter point to complete ...")
return "Click on perimeter to complete ..."
if len(self.points) == 2:
@@ -638,9 +639,11 @@ class FCArc(FCShapeTool):
self.points.append(point)
if len(self.points) == 1:
self.draw_app.app.inform.emit("Click on Start arc point ...")
return "Click on 1st point ..."
if len(self.points) == 2:
self.draw_app.app.inform.emit("Click on End arc point to complete ...")
return "Click on 2nd point to complete ..."
if len(self.points) == 3:
@@ -850,6 +853,7 @@ class FCPolygon(FCShapeTool):
self.points.append(point)
if len(self.points) > 0:
self.draw_app.app.inform.emit("Click on next Point or click Right mouse button to complete ...")
return "Click on next point or hit ENTER to complete ..."
return ""
@@ -1239,7 +1243,7 @@ class FCText(FCShapeTool):
self.geometry = DrawToolShape(affinity.translate(self.text_gui.text_path, xoff=dx, yoff=dy))
except Exception as e:
log.debug("Font geometry is empty or incorrect: %s" % str(e))
self.draw_app.app.inform.emit("[error]Font not supported. Only Regular, Bold, Italic and BoldItalic are "
self.draw_app.app.inform.emit("[ERROR]Font not supported. Only Regular, Bold, Italic and BoldItalic are "
"supported. Error: %s" % str(e))
self.text_gui.text_path = []
self.text_gui.hide_tool()
@@ -1416,7 +1420,7 @@ class FCDrillAdd(FCShapeTool):
self.draw_app.tools_table_exc.setCurrentItem(item)
except KeyError:
self.draw_app.app.inform.emit("[warning_notcl] To add a drill first select a tool")
self.draw_app.app.inform.emit("[WARNING_NOTCL] To add a drill first select a tool")
self.draw_app.select_tool("select")
return
@@ -1500,7 +1504,7 @@ class FCDrillArray(FCShapeTool):
item = self.draw_app.tools_table_exc.item((self.draw_app.last_tool_selected - 1), 1)
self.draw_app.tools_table_exc.setCurrentItem(item)
except KeyError:
self.draw_app.app.inform.emit("[warning_notcl] To add an Drill Array first select a tool in Tool Table")
self.draw_app.app.inform.emit("[WARNING_NOTCL] To add an Drill Array first select a tool in Tool Table")
return
geo = self.utility_geometry(data=(self.draw_app.snap_x, self.draw_app.snap_y), static=True)
@@ -1525,7 +1529,7 @@ class FCDrillArray(FCShapeTool):
self.flag_for_circ_array = True
self.set_origin(point)
self.draw_app.app.inform.emit("Click on the circular array Start position")
self.draw_app.app.inform.emit("Click on the Drill Circular Array Start position")
else:
self.destination = point
self.make()
@@ -1547,10 +1551,10 @@ class FCDrillArray(FCShapeTool):
self.drill_angle = float(self.draw_app.drill_angle_entry.get_value())
except TypeError:
self.draw_app.app.inform.emit(
"[error_notcl] The value is not Float. Check for comma instead of dot separator.")
"[ERROR_NOTCL] The value is not Float. Check for comma instead of dot separator.")
return
except Exception as e:
self.draw_app.app.inform.emit("[error_notcl] The value is mistyped. Check the value.")
self.draw_app.app.inform.emit("[ERROR_NOTCL] The value is mistyped. Check the value.")
return
if self.drill_array == 'Linear':
@@ -1630,7 +1634,7 @@ class FCDrillArray(FCShapeTool):
self.geometry.append(DrawToolShape(geo))
else:
if (self.drill_angle * self.drill_array_size) > 360:
self.draw_app.app.inform.emit("[warning_notcl]Too many drills for the selected spacing angle.")
self.draw_app.app.inform.emit("[WARNING_NOTCL]Too many drills for the selected spacing angle.")
return
radius = distance(self.destination, self.origin)
@@ -1676,7 +1680,7 @@ class FCDrillResize(FCShapeTool):
try:
new_dia = self.draw_app.resdrill_entry.get_value()
except:
self.draw_app.app.inform.emit("[error_notcl]Resize drill(s) failed. Please enter a diameter for resize.")
self.draw_app.app.inform.emit("[ERROR_NOTCL]Resize drill(s) failed. Please enter a diameter for resize.")
return
if new_dia not in self.draw_app.olddia_newdia:
@@ -2080,15 +2084,18 @@ class FlatCAMGeoEditor(QtCore.QObject):
theme = settings.value('theme', type=str)
if theme == 'standard':
self.app.ui.geo_edit_toolbar.setVisible(False)
self.app.ui.snap_max_dist_entry.setEnabled(False)
self.app.ui.corner_snap_btn.setEnabled(False)
self.app.ui.snap_magnet.setVisible(False)
self.app.ui.corner_snap_btn.setVisible(False)
elif theme == 'compact':
self.app.ui.snap_max_dist_entry.setEnabled(False)
self.app.ui.corner_snap_btn.setEnabled(False)
else:
self.app.ui.geo_edit_toolbar.setVisible(False)
self.app.ui.snap_magnet.setVisible(False)
self.app.ui.corner_snap_btn.setVisible(False)
self.app.ui.snap_max_dist_entry.setEnabled(False)
@@ -2102,6 +2109,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
self.app.ui.geo_editor_menu.setDisabled(True)
self.app.ui.geo_editor_menu.menuAction().setVisible(False)
self.app.ui.update_obj_btn.setEnabled(False)
self.app.ui.g_editor_cmenu.setEnabled(False)
self.app.ui.e_editor_cmenu.setEnabled(False)
@@ -2594,7 +2602,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
if event.key.name == 'Escape':
# TODO: ...?
# self.on_tool_select("select")
self.app.inform.emit("[warning_notcl]Cancelled.")
self.app.inform.emit("[WARNING_NOTCL]Cancelled.")
self.delete_utility_geometry()
@@ -2756,47 +2764,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
# Show Shortcut list
if event.key.name == '`':
self.on_shortcut_list()
def on_shortcut_list(self):
msg = '''<b>Shortcut list in Geometry Editor</b><br>
<br>
<b>1:</b> Zoom Fit<br>
<b>2:</b> Zoom Out<br>
<b>3:</b> Zoom In<br>
<b>A:</b> Add an 'Arc'<br>
<b>B:</b> Add a Buffer Geo<br>
<b>C:</b> Copy Geo Item<br>
<b>E:</b> Intersection Tool<br>
<b>G:</b> Grid Snap On/Off<br>
<b>I:</b> Paint Tool<br>
<b>K:</b> Corner Snap On/Off<br>
<b>M:</b> Move Geo Item<br>
<br>
<b>N:</b> Add an 'Polygon'<br>
<b>O:</b> Add a 'Circle'<br>
<b>P:</b> Add a 'Path'<br>
<b>R:</b> Add an 'Rectangle'<br>
<b>S:</b> Substraction Tool<br>
<b>T:</b> Add Text Geometry<br>
<b>U:</b> Union Tool<br>
<br>
<b>X:</b> Cut Path<br>
<br>
<b>~:</b> Show Shortcut List<br>
<br>
<b>Space:</b> Rotate selected Geometry<br>
<b>Enter:</b> Finish Current Action<br>
<b>Escape:</b> Select Tool (Exit any other Tool)<br>
<b>Delete:</b> Delete Obj'''
helpbox =QtWidgets.QMessageBox()
helpbox.setText(msg)
helpbox.setWindowTitle("Help")
helpbox.setWindowIcon(QtGui.QIcon('share/help.png'))
helpbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
helpbox.setDefaultButton(QtWidgets.QMessageBox.Ok)
helpbox.exec_()
self.app.on_shortcut_list()
def on_canvas_key_release(self, event):
self.key = None
@@ -3070,7 +3038,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
results = shapes[0].geo
except Exception as e:
log.debug("FlatCAMGeoEditor.intersection() --> %s" % str(e))
self.app.inform.emit("[warning_notcl]A selection of at least 2 geo items is required to do Intersection.")
self.app.inform.emit("[WARNING_NOTCL]A selection of at least 2 geo items is required to do Intersection.")
self.select_tool('select')
return
@@ -3108,7 +3076,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
if buf_distance < 0:
self.app.inform.emit(
"[error_notcl]Negative buffer value is not accepted. Use Buffer interior to generate an 'inside' shape")
"[ERROR_NOTCL]Negative buffer value is not accepted. Use Buffer interior to generate an 'inside' shape")
# deselect everything
self.selected = []
@@ -3116,11 +3084,11 @@ class FlatCAMGeoEditor(QtCore.QObject):
return
if len(selected) == 0:
self.app.inform.emit("[warning_notcl] Nothing selected for buffering.")
self.app.inform.emit("[WARNING_NOTCL] Nothing selected for buffering.")
return
if not isinstance(buf_distance, float):
self.app.inform.emit("[warning_notcl] Invalid distance for buffering.")
self.app.inform.emit("[WARNING_NOTCL] Invalid distance for buffering.")
# deselect everything
self.selected = []
@@ -3130,7 +3098,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
pre_buffer = cascaded_union([t.geo for t in selected])
results = pre_buffer.buffer(buf_distance - 1e-10, resolution=32, join_style=join_style)
if results.is_empty:
self.app.inform.emit("[error_notcl]Failed, the result is empty. Choose a different buffer value.")
self.app.inform.emit("[ERROR_NOTCL]Failed, the result is empty. Choose a different buffer value.")
# deselect everything
self.selected = []
self.replot()
@@ -3145,18 +3113,18 @@ class FlatCAMGeoEditor(QtCore.QObject):
if buf_distance < 0:
self.app.inform.emit(
"[error_notcl]Negative buffer value is not accepted. Use Buffer interior to generate an 'inside' shape")
"[ERROR_NOTCL]Negative buffer value is not accepted. Use Buffer interior to generate an 'inside' shape")
# deselect everything
self.selected = []
self.replot()
return
if len(selected) == 0:
self.app.inform.emit("[warning_notcl] Nothing selected for buffering.")
self.app.inform.emit("[WARNING_NOTCL] Nothing selected for buffering.")
return
if not isinstance(buf_distance, float):
self.app.inform.emit("[warning_notcl] Invalid distance for buffering.")
self.app.inform.emit("[WARNING_NOTCL] Invalid distance for buffering.")
# deselect everything
self.selected = []
self.replot()
@@ -3165,7 +3133,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
pre_buffer = cascaded_union([t.geo for t in selected])
results = pre_buffer.buffer(-buf_distance + 1e-10, resolution=32, join_style=join_style)
if results.is_empty:
self.app.inform.emit("[error_notcl]Failed, the result is empty. Choose a smaller buffer value.")
self.app.inform.emit("[ERROR_NOTCL]Failed, the result is empty. Choose a smaller buffer value.")
# deselect everything
self.selected = []
self.replot()
@@ -3185,7 +3153,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
# return
#
# if not isinstance(buf_distance, float):
# self.app.inform.emit("[warning] Invalid distance for buffering.")
# self.app.inform.emit("[WARNING] Invalid distance for buffering.")
# return
#
# pre_buffer = cascaded_union([t.geo for t in selected])
@@ -3215,7 +3183,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
selected = self.get_selected()
if buf_distance < 0:
self.app.inform.emit("[error_notcl]Negative buffer value is not accepted. "
self.app.inform.emit("[ERROR_NOTCL]Negative buffer value is not accepted. "
"Use Buffer interior to generate an 'inside' shape")
# deselect everything
self.selected = []
@@ -3223,11 +3191,11 @@ class FlatCAMGeoEditor(QtCore.QObject):
return
if len(selected) == 0:
self.app.inform.emit("[warning_notcl] Nothing selected for buffering.")
self.app.inform.emit("[WARNING_NOTCL] Nothing selected for buffering.")
return
if not isinstance(buf_distance, float):
self.app.inform.emit("[warning_notcl] Invalid distance for buffering.")
self.app.inform.emit("[WARNING_NOTCL] Invalid distance for buffering.")
# deselect everything
self.selected = []
self.replot()
@@ -3236,7 +3204,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
pre_buffer = cascaded_union([t.geo for t in selected])
results = pre_buffer.buffer(buf_distance - 1e-10, resolution=32, join_style=join_style)
if results.is_empty:
self.app.inform.emit("[error_notcl]Failed, the result is empty. Choose a different buffer value.")
self.app.inform.emit("[ERROR_NOTCL]Failed, the result is empty. Choose a different buffer value.")
# deselect everything
self.selected = []
self.replot()
@@ -3254,13 +3222,13 @@ class FlatCAMGeoEditor(QtCore.QObject):
# selected = self.get_selected()
#
# if len(selected) == 0:
# self.app.inform.emit("[warning] Nothing selected for painting.")
# self.app.inform.emit("[WARNING] Nothing selected for painting.")
# return
#
# for param in [tooldia, overlap, margin]:
# if not isinstance(param, float):
# param_name = [k for k, v in locals().items() if v is param][0]
# self.app.inform.emit("[warning] Invalid value for {}".format(param))
# self.app.inform.emit("[WARNING] Invalid value for {}".format(param))
#
# # Todo: Check for valid method.
#
@@ -3312,19 +3280,19 @@ class FlatCAMGeoEditor(QtCore.QObject):
selected = self.get_selected()
if len(selected) == 0:
self.app.inform.emit("[warning_notcl]Nothing selected for painting.")
self.app.inform.emit("[WARNING_NOTCL]Nothing selected for painting.")
return
for param in [tooldia, overlap, margin]:
if not isinstance(param, float):
param_name = [k for k, v in locals().items() if v is param][0]
self.app.inform.emit("[warning] Invalid value for {}".format(param))
self.app.inform.emit("[WARNING] Invalid value for {}".format(param))
results = []
if tooldia >= overlap:
self.app.inform.emit(
"[error_notcl] Could not do Paint. Overlap value has to be less than Tool Dia value.")
"[ERROR_NOTCL] Could not do Paint. Overlap value has to be less than Tool Dia value.")
return
def recurse(geometry, reset=True):
@@ -3383,7 +3351,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
except Exception as e:
log.debug("Could not Paint the polygons. %s" % str(e))
self.app.inform.emit(
"[error] Could not do Paint. Try a different combination of parameters. "
"[ERROR] Could not do Paint. Try a different combination of parameters. "
"Or a different method of Paint\n%s" % str(e))
return
@@ -4090,7 +4058,7 @@ class FlatCAMExcEditor(QtCore.QObject):
# each time a tool diameter is edited or added
self.olddia_newdia[tool_dia] = tool_dia
else:
self.app.inform.emit("[warning_notcl]Tool already in the original or actual tool list.\n"
self.app.inform.emit("[WARNING_NOTCL]Tool already in the original or actual tool list.\n"
"Save and reedit Excellon if you need to add this tool. ")
return
@@ -4128,7 +4096,7 @@ class FlatCAMExcEditor(QtCore.QObject):
else:
deleted_tool_dia_list.append(float('%.4f' % dia))
except:
self.app.inform.emit("[warning_notcl]Select a tool in Tool Table")
self.app.inform.emit("[WARNING_NOTCL]Select a tool in Tool Table")
return
for deleted_tool_dia in deleted_tool_dia_list:
@@ -4248,18 +4216,21 @@ class FlatCAMExcEditor(QtCore.QObject):
theme = settings.value('theme', type=str)
if theme == 'standard':
self.app.ui.exc_edit_toolbar.setVisible(False)
self.app.ui.snap_max_dist_entry.setEnabled(False)
self.app.ui.corner_snap_btn.setEnabled(False)
self.app.ui.snap_magnet.setVisible(False)
self.app.ui.corner_snap_btn.setVisible(False)
elif theme == 'compact':
self.app.ui.exc_edit_toolbar.setVisible(False)
self.app.ui.exc_edit_toolbar.setVisible(True)
self.app.ui.snap_max_dist_entry.setEnabled(False)
self.app.ui.corner_snap_btn.setEnabled(False)
self.app.ui.snap_magnet.setVisible(True)
self.app.ui.corner_snap_btn.setVisible(True)
else:
self.app.ui.exc_edit_toolbar.setVisible(False)
self.app.ui.snap_max_dist_entry.setEnabled(False)
self.app.ui.corner_snap_btn.setEnabled(False)
self.app.ui.snap_magnet.setVisible(False)
@@ -4275,7 +4246,9 @@ class FlatCAMExcEditor(QtCore.QObject):
self.app.ui.exc_editor_menu.setDisabled(True)
self.app.ui.exc_editor_menu.menuAction().setVisible(False)
self.app.ui.update_obj_btn.setEnabled(False)
self.app.ui.g_editor_cmenu.setEnabled(False)
self.app.ui.e_editor_cmenu.setEnabled(False)
@@ -4494,6 +4467,10 @@ class FlatCAMExcEditor(QtCore.QObject):
try:
if not obj.options:
obj.options = {}
obj.options['xmin'] = 0
obj.options['ymin'] = 0
obj.options['xmax'] = 0
obj.options['ymax'] = 0
return True
else:
return False
@@ -4526,9 +4503,9 @@ class FlatCAMExcEditor(QtCore.QObject):
excellon_obj.create_geometry()
except KeyError:
self.app.inform.emit(
"[error_notcl] There are no Tools definitions in the file. Aborting Excellon creation.")
"[ERROR_NOTCL] There are no Tools definitions in the file. Aborting Excellon creation.")
except:
msg = "[error] An internal error has ocurred. See shell.\n"
msg = "[ERROR] An internal error has ocurred. See shell.\n"
msg += traceback.format_exc()
app_obj.inform.emit(msg)
raise
@@ -4560,7 +4537,7 @@ class FlatCAMExcEditor(QtCore.QObject):
# self.draw_app.select_tool('select')
self.complete = True
current_tool = 'select'
self.app.inform.emit("[warning_notcl]Cancelled. There is no Tool/Drill selected")
self.app.inform.emit("[WARNING_NOTCL]Cancelled. There is no Tool/Drill selected")
# This is to make the group behave as radio group
if current_tool in self.tools_exc:
@@ -4904,7 +4881,7 @@ class FlatCAMExcEditor(QtCore.QObject):
if event.key.name == 'Escape':
# TODO: ...?
# self.on_tool_select("select")
self.app.inform.emit("[warning_notcl]Cancelled.")
self.app.inform.emit("[WARNING_NOTCL]Cancelled.")
self.delete_utility_geometry()
@@ -4921,7 +4898,7 @@ class FlatCAMExcEditor(QtCore.QObject):
self.delete_selected()
self.replot()
else:
self.app.inform.emit("[warning_notcl]Cancelled. Nothing selected to delete.")
self.app.inform.emit("[WARNING_NOTCL]Cancelled. Nothing selected to delete.")
return
if event.key == '1':
@@ -4953,7 +4930,7 @@ class FlatCAMExcEditor(QtCore.QObject):
self.on_tool_select('copy')
self.active_tool.set_origin((self.snap_x, self.snap_y))
else:
self.app.inform.emit("[warning_notcl]Cancelled. Nothing selected to copy.")
self.app.inform.emit("[WARNING_NOTCL]Cancelled. Nothing selected to copy.")
return
# Add Drill Hole Tool
@@ -4990,7 +4967,7 @@ class FlatCAMExcEditor(QtCore.QObject):
self.on_tool_select('move')
self.active_tool.set_origin((self.snap_x, self.snap_y))
else:
self.app.inform.emit("[warning_notcl]Cancelled. Nothing selected to move.")
self.app.inform.emit("[WARNING_NOTCL]Cancelled. Nothing selected to move.")
return
# Resize Tool
@@ -5014,39 +4991,9 @@ class FlatCAMExcEditor(QtCore.QObject):
# Show Shortcut list
if event.key.name == '`':
self.on_shortcut_list()
self.app.on_shortcut_list()
return
def on_shortcut_list(self):
msg = '''<b>Shortcut list in Geometry Editor</b><br>
<br>
<b>1:</b> Zoom Fit<br>
<b>2:</b> Zoom Out<br>
<b>3:</b> Zoom In<br>
<b>A:</b> Add an 'Drill Array'<br>
<b>C:</b> Copy Drill Hole<br>
<b>D:</b> Add an Drill Hole<br>
<b>G:</b> Grid Snap On/Off<br>
<b>K:</b> Corner Snap On/Off<br>
<b>M:</b> Move Drill Hole<br>
<br>
<b>R:</b> Resize a 'Drill Hole'<br>
<b>S:</b> Select Tool Active<br>
<br>
<b>~:</b> Show Shortcut List<br>
<br>
<b>Enter:</b> Finish Current Action<br>
<b>Escape:</b> Abort Current Action<br>
<b>Delete:</b> Delete Drill Hole'''
helpbox =QtWidgets.QMessageBox()
helpbox.setText(msg)
helpbox.setWindowTitle("Help")
helpbox.setWindowIcon(QtGui.QIcon('share/help.png'))
helpbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
helpbox.setDefaultButton(QtWidgets.QMessageBox.Ok)
helpbox.exec_()
def on_canvas_key_release(self, event):
self.key = None