From bacb8a7184d0345835687189abeee5771e09e21d Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sun, 29 Sep 2019 05:13:36 +0300 Subject: [PATCH] - changed the name of the Measurement Tool to Distance Tool. Moved it's location to the Edit Menu - added Angle parameter which is continuously updated to the Distance Tool --- FlatCAMApp.py | 10 ++-- README.md | 2 + flatcamGUI/FlatCAMGUI.py | 6 +- .../{ToolMeasurement.py => ToolDistance.py} | 55 +++++++++++++------ flatcamTools/__init__.py | 2 +- 5 files changed, 51 insertions(+), 24 deletions(-) rename flatcamTools/{ToolMeasurement.py => ToolDistance.py} (90%) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 81c505a9..69783a4b 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -2084,7 +2084,7 @@ class App(QtCore.QObject): # ########################## Other setups ############################################# # ##################################################################################### - # to use for tools like Measurement tool who depends on the event sources who are changed inside the Editors + # to use for tools like Distance tool who depends on the event sources who are changed inside the Editors # depending on from where those tools are called different actions can be done self.call_source = 'app' @@ -2894,8 +2894,10 @@ class App(QtCore.QObject): self.dblsidedtool = DblSidedTool(self) self.dblsidedtool.install(icon=QtGui.QIcon('share/doubleside16.png'), separator=True) - self.measurement_tool = Measurement(self) - self.measurement_tool.install(icon=QtGui.QIcon('share/measure16.png'), separator=True) + self.measurement_tool = Distance(self) + self.measurement_tool.install(icon=QtGui.QIcon('share/measure16.png'), pos=self.ui.menuedit, + before=self.ui.menueditorigin, + separator=True) self.panelize_tool = Panelize(self) self.panelize_tool.install(icon=QtGui.QIcon('share/panel16.png')) @@ -2920,7 +2922,7 @@ class App(QtCore.QObject): self.move_tool = ToolMove(self) self.move_tool.install(icon=QtGui.QIcon('share/move16.png'), pos=self.ui.menuedit, - before=self.ui.menueditorigin) + before=self.ui.menueditorigin, separator=True) self.cutout_tool = CutOut(self) self.cutout_tool.install(icon=QtGui.QIcon('share/cut16_bis.png'), pos=self.ui.menutool, diff --git a/README.md b/README.md index 2ffe63b3..a4351b33 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,8 @@ CAD program, and create G-Code for Isolation routing. - fixed issue #319 where generating a CNCJob from a geometry made with NCC Tool made the app crash - replaced in FlatCAM Tools and in FLatCAMObj.py and in Editors all references to hardcoded decimals in string formats for tools with a variable declared in the __init__() - fixed a small bug that made app crash when the splash screen is disabled: it was trying to close it without being open +- changed the name of the Measurement Tool to Distance Tool. Moved it's location to the Edit Menu +- added Angle parameter which is continuously updated to the Distance Tool 27.09.2019 diff --git a/flatcamGUI/FlatCAMGUI.py b/flatcamGUI/FlatCAMGUI.py index 06153449..adb21c80 100644 --- a/flatcamGUI/FlatCAMGUI.py +++ b/flatcamGUI/FlatCAMGUI.py @@ -1332,7 +1332,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow): _("Open Properties Tool"), _("Rotate by 90 degree CW"), _("Shell Toggle"), _("Add a Tool (when in Geometry Selected Tab or in Tools NCC or Tools Paint)"), _("Zoom Fit"), _("Flip on X_axis"), _("Flip on Y_axis"), _("Zoom Out"), _("Zoom In"), _("Select All"), _("Copy Obj"), - _("Open Excellon File"), _("Open Gerber File"), _("New Project"), _("Measurement Tool"), + _("Open Excellon File"), _("Open Gerber File"), _("New Project"), _("Distance Tool"), _("Open Project"), _("Save Project As"), _("Toggle Plot Area"), _("Copy Obj_Name"), _("Toggle Code Editor"), _("Toggle the axis"), _("Open Preferences Window"), _("Rotate by 90 degree CCW"), _("Run a Script"), _("Toggle the workspace"), _("Skew on X axis"), @@ -1516,7 +1516,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow): _("Draw a Path"), _("Draw Rectangle"), _("Polygon Subtraction Tool"), _("Add Text Tool"), _("Polygon Union Tool"), _("Flip shape on X axis"), _("Flip shape on Y axis"), _("Skew shape on X axis"), _("Skew shape on Y axis"), _("Editor Transformation Tool"), _("Offset shape on X axis"), - _("Offset shape on Y axis"), _("Measurement Tool"), _("Save Object and Exit Editor"), _("Polygon Cut Tool"), + _("Offset shape on Y axis"), _("Distance Tool"), _("Save Object and Exit Editor"), _("Polygon Cut Tool"), _("Rotate Geometry"), _("Finish drawing for certain tools"), _("Abort and return to Select"), _("Delete Shape") ) @@ -3366,7 +3366,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow): if key == QtCore.Qt.Key_Escape or key == 'Escape': # abort the measurement action self.app.measurement_tool.deactivate_measure_tool() - self.app.inform.emit(_("Measurement Tool exit...")) + self.app.inform.emit(_("Distance Tool exit...")) return if key == QtCore.Qt.Key_G or key == 'G': diff --git a/flatcamTools/ToolMeasurement.py b/flatcamTools/ToolDistance.py similarity index 90% rename from flatcamTools/ToolMeasurement.py rename to flatcamTools/ToolDistance.py index 3aa11516..3c1bd13b 100644 --- a/flatcamTools/ToolMeasurement.py +++ b/flatcamTools/ToolDistance.py @@ -21,9 +21,9 @@ if '_' not in builtins.__dict__: _ = gettext.gettext -class Measurement(FlatCAMTool): +class Distance(FlatCAMTool): - toolName = _("Measurement") + toolName = _("Distance Tool") def __init__(self, app): FlatCAMTool.__init__(self, app) @@ -57,6 +57,9 @@ class Measurement(FlatCAMTool): self.distance_y_label = QtWidgets.QLabel('%s:' % _("Dy")) self.distance_y_label.setToolTip(_("This is the distance measured over the Y axis.")) + self.angle_label = QtWidgets.QLabel('%s:' % _("Angle")) + self.angle_label.setToolTip(_("This is orientation angle of the measuring line.")) + self.total_distance_label = QtWidgets.QLabel("%s:" % _('DISTANCE')) self.total_distance_label.setToolTip(_("This is the point to point Euclidian distance.")) @@ -76,6 +79,10 @@ class Measurement(FlatCAMTool): self.distance_y_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.distance_y_entry.setToolTip(_("This is the distance measured over the Y axis.")) + self.angle_entry = FCEntry() + self.angle_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) + self.angle_entry.setToolTip(_("This is orientation angle of the measuring line.")) + self.total_distance_entry = FCEntry() self.total_distance_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.total_distance_entry.setToolTip(_("This is the point to point Euclidian distance.")) @@ -89,14 +96,16 @@ class Measurement(FlatCAMTool): form_layout.addRow(self.stop_label, self.stop_entry) form_layout.addRow(self.distance_x_label, self.distance_x_entry) form_layout.addRow(self.distance_y_label, self.distance_y_entry) + form_layout.addRow(self.angle_label, self.angle_entry) form_layout.addRow(self.total_distance_label, self.total_distance_entry) # initial view of the layout self.start_entry.set_value('(0, 0)') self.stop_entry.set_value('(0, 0)') - self.distance_x_entry.set_value('0') - self.distance_y_entry.set_value('0') - self.total_distance_entry.set_value('0') + self.distance_x_entry.set_value('0.0') + self.distance_y_entry.set_value('0.0') + self.angle_entry.set_value('0.0') + self.total_distance_entry.set_value('0.0') self.layout.addStretch() @@ -122,7 +131,7 @@ class Measurement(FlatCAMTool): self.measure_btn.clicked.connect(self.activate_measure_tool) def run(self, toggle=False): - self.app.report_usage("ToolMeasurement()") + self.app.report_usage("ToolDistance()") self.points[:] = [] @@ -132,7 +141,7 @@ class Measurement(FlatCAMTool): if self.app.tool_tab_locked is True: return - self.app.ui.notebook.setTabText(2, _("Meas. Tool")) + self.app.ui.notebook.setTabText(2, _("Distance Tool")) # if the splitter is hidden, display it if self.app.ui.splitter.sizes()[0] == 0: @@ -159,16 +168,17 @@ class Measurement(FlatCAMTool): self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().lower() - self.app.command_active = "Measurement" + self.app.command_active = "Distance" # initial view of the layout self.start_entry.set_value('(0, 0)') self.stop_entry.set_value('(0, 0)') - self.distance_x_entry.set_value('0') - self.distance_y_entry.set_value('0') - self.total_distance_entry.set_value('0') - log.debug("Measurement Tool --> tool initialized") + self.distance_x_entry.set_value('0.0') + self.distance_y_entry.set_value('0.0') + self.angle_entry.set_value('0.0') + self.total_distance_entry.set_value('0.0') + log.debug("Distance Tool --> tool initialized") def activate_measure_tool(self): # ENABLE the Measuring TOOL @@ -275,13 +285,13 @@ class Measurement(FlatCAMTool): # delete the measuring line self.delete_shape() - log.debug("Measurement Tool --> exit tool") + log.debug("Distance Tool --> exit tool") def on_mouse_click_release(self, event): # mouse click releases will be accepted only if the left button is clicked # this is necessary because right mouse click or middle mouse click # are used for panning on the canvas - log.debug("Measuring Tool --> mouse click release") + log.debug("Distance Tool --> mouse click release") if event.button == 1: if self.app.is_legacy is False: @@ -321,6 +331,13 @@ class Measurement(FlatCAMTool): self.distance_x_entry.set_value('%.4f' % abs(dx)) self.distance_y_entry.set_value('%.4f' % abs(dy)) + + try: + angle = math.degrees(math.atan(dy / dx)) + self.angle_entry.set_value('%.4f' % angle) + except Exception as e: + pass + self.total_distance_entry.set_value('%.4f' % abs(d)) self.app.ui.rel_position_label.setText("Dx: {0:.4f}   Dy: " "{0:.4f}    ".format(pos[0], pos[1])) @@ -365,11 +382,17 @@ class Measurement(FlatCAMTool): "{0:.4f}    ".format(dx, dy)) # update utility geometry - if len(self.points) == 1: self.utility_geometry(pos=pos) + # and display the temporary angle + try: + angle = math.degrees(math.atan(dy / dx)) + self.angle_entry.set_value('%.4f' % angle) + except Exception as e: + pass + except Exception as e: - log.debug("Measurement.on_mouse_move_meas() --> %s" % str(e)) + log.debug("Distance.on_mouse_move_meas() --> %s" % str(e)) self.app.ui.position_label.setText("") self.app.ui.rel_position_label.setText("") diff --git a/flatcamTools/__init__.py b/flatcamTools/__init__.py index 6076b850..953c1774 100644 --- a/flatcamTools/__init__.py +++ b/flatcamTools/__init__.py @@ -10,7 +10,7 @@ from flatcamTools.ToolFilm import Film from flatcamTools.ToolImage import ToolImage -from flatcamTools.ToolMeasurement import Measurement +from flatcamTools.ToolDistance import Distance from flatcamTools.ToolMove import ToolMove from flatcamTools.ToolNonCopperClear import NonCopperClear