- 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
This commit is contained in:
Marius Stanciu 2019-09-29 05:13:36 +03:00 committed by Marius
parent aa7b2426e7
commit bacb8a7184
5 changed files with 51 additions and 24 deletions

View File

@ -2084,7 +2084,7 @@ class App(QtCore.QObject):
# ########################## Other setups ############################################# # ########################## 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 # depending on from where those tools are called different actions can be done
self.call_source = 'app' self.call_source = 'app'
@ -2894,8 +2894,10 @@ class App(QtCore.QObject):
self.dblsidedtool = DblSidedTool(self) self.dblsidedtool = DblSidedTool(self)
self.dblsidedtool.install(icon=QtGui.QIcon('share/doubleside16.png'), separator=True) self.dblsidedtool.install(icon=QtGui.QIcon('share/doubleside16.png'), separator=True)
self.measurement_tool = Measurement(self) self.measurement_tool = Distance(self)
self.measurement_tool.install(icon=QtGui.QIcon('share/measure16.png'), separator=True) 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 = Panelize(self)
self.panelize_tool.install(icon=QtGui.QIcon('share/panel16.png')) 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 = ToolMove(self)
self.move_tool.install(icon=QtGui.QIcon('share/move16.png'), pos=self.ui.menuedit, 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 = CutOut(self)
self.cutout_tool.install(icon=QtGui.QIcon('share/cut16_bis.png'), pos=self.ui.menutool, self.cutout_tool.install(icon=QtGui.QIcon('share/cut16_bis.png'), pos=self.ui.menutool,

View File

@ -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 - 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__() - 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 - 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 27.09.2019

View File

@ -1332,7 +1332,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
_("Open Properties Tool"), _("Rotate by 90 degree CW"), _("Shell Toggle"), _("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"), _("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"), _("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"), _("Open Project"), _("Save Project As"), _("Toggle Plot Area"), _("Copy Obj_Name"),
_("Toggle Code Editor"), _("Toggle the axis"), _("Open Preferences Window"), _("Toggle Code Editor"), _("Toggle the axis"), _("Open Preferences Window"),
_("Rotate by 90 degree CCW"), _("Run a Script"), _("Toggle the workspace"), _("Skew on X axis"), _("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"), _("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"), _("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"), _("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"), _("Rotate Geometry"), _("Finish drawing for certain tools"), _("Abort and return to Select"),
_("Delete Shape") _("Delete Shape")
) )
@ -3366,7 +3366,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
if key == QtCore.Qt.Key_Escape or key == 'Escape': if key == QtCore.Qt.Key_Escape or key == 'Escape':
# abort the measurement action # abort the measurement action
self.app.measurement_tool.deactivate_measure_tool() self.app.measurement_tool.deactivate_measure_tool()
self.app.inform.emit(_("Measurement Tool exit...")) self.app.inform.emit(_("Distance Tool exit..."))
return return
if key == QtCore.Qt.Key_G or key == 'G': if key == QtCore.Qt.Key_G or key == 'G':

View File

@ -21,9 +21,9 @@ if '_' not in builtins.__dict__:
_ = gettext.gettext _ = gettext.gettext
class Measurement(FlatCAMTool): class Distance(FlatCAMTool):
toolName = _("Measurement") toolName = _("Distance Tool")
def __init__(self, app): def __init__(self, app):
FlatCAMTool.__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 = QtWidgets.QLabel('%s:' % _("Dy"))
self.distance_y_label.setToolTip(_("This is the distance measured over the Y axis.")) 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("<b>%s:</b>" % _('DISTANCE')) self.total_distance_label = QtWidgets.QLabel("<b>%s:</b>" % _('DISTANCE'))
self.total_distance_label.setToolTip(_("This is the point to point Euclidian 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.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.distance_y_entry.setToolTip(_("This is the distance measured over the Y axis.")) 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 = FCEntry()
self.total_distance_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.total_distance_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.total_distance_entry.setToolTip(_("This is the point to point Euclidian distance.")) 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.stop_label, self.stop_entry)
form_layout.addRow(self.distance_x_label, self.distance_x_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.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) form_layout.addRow(self.total_distance_label, self.total_distance_entry)
# initial view of the layout # initial view of the layout
self.start_entry.set_value('(0, 0)') self.start_entry.set_value('(0, 0)')
self.stop_entry.set_value('(0, 0)') self.stop_entry.set_value('(0, 0)')
self.distance_x_entry.set_value('0') self.distance_x_entry.set_value('0.0')
self.distance_y_entry.set_value('0') self.distance_y_entry.set_value('0.0')
self.total_distance_entry.set_value('0') self.angle_entry.set_value('0.0')
self.total_distance_entry.set_value('0.0')
self.layout.addStretch() self.layout.addStretch()
@ -122,7 +131,7 @@ class Measurement(FlatCAMTool):
self.measure_btn.clicked.connect(self.activate_measure_tool) self.measure_btn.clicked.connect(self.activate_measure_tool)
def run(self, toggle=False): def run(self, toggle=False):
self.app.report_usage("ToolMeasurement()") self.app.report_usage("ToolDistance()")
self.points[:] = [] self.points[:] = []
@ -132,7 +141,7 @@ class Measurement(FlatCAMTool):
if self.app.tool_tab_locked is True: if self.app.tool_tab_locked is True:
return 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 the splitter is hidden, display it
if self.app.ui.splitter.sizes()[0] == 0: 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.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.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 # initial view of the layout
self.start_entry.set_value('(0, 0)') self.start_entry.set_value('(0, 0)')
self.stop_entry.set_value('(0, 0)') self.stop_entry.set_value('(0, 0)')
self.distance_x_entry.set_value('0') self.distance_x_entry.set_value('0.0')
self.distance_y_entry.set_value('0') self.distance_y_entry.set_value('0.0')
self.total_distance_entry.set_value('0') self.angle_entry.set_value('0.0')
log.debug("Measurement Tool --> tool initialized") self.total_distance_entry.set_value('0.0')
log.debug("Distance Tool --> tool initialized")
def activate_measure_tool(self): def activate_measure_tool(self):
# ENABLE the Measuring TOOL # ENABLE the Measuring TOOL
@ -275,13 +285,13 @@ class Measurement(FlatCAMTool):
# delete the measuring line # delete the measuring line
self.delete_shape() self.delete_shape()
log.debug("Measurement Tool --> exit tool") log.debug("Distance Tool --> exit tool")
def on_mouse_click_release(self, event): def on_mouse_click_release(self, event):
# mouse click releases will be accepted only if the left button is clicked # mouse click releases will be accepted only if the left button is clicked
# this is necessary because right mouse click or middle mouse click # this is necessary because right mouse click or middle mouse click
# are used for panning on the canvas # 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 event.button == 1:
if self.app.is_legacy is False: 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_x_entry.set_value('%.4f' % abs(dx))
self.distance_y_entry.set_value('%.4f' % abs(dy)) 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.total_distance_entry.set_value('%.4f' % abs(d))
self.app.ui.rel_position_label.setText("<b>Dx</b>: {0:.4f}&nbsp;&nbsp; <b>Dy</b>: " self.app.ui.rel_position_label.setText("<b>Dx</b>: {0:.4f}&nbsp;&nbsp; <b>Dy</b>: "
"{0:.4f}&nbsp;&nbsp;&nbsp;&nbsp;".format(pos[0], pos[1])) "{0:.4f}&nbsp;&nbsp;&nbsp;&nbsp;".format(pos[0], pos[1]))
@ -365,11 +382,17 @@ class Measurement(FlatCAMTool):
"{0:.4f}&nbsp;&nbsp;&nbsp;&nbsp;".format(dx, dy)) "{0:.4f}&nbsp;&nbsp;&nbsp;&nbsp;".format(dx, dy))
# update utility geometry # update utility geometry
if len(self.points) == 1: if len(self.points) == 1:
self.utility_geometry(pos=pos) 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: 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.position_label.setText("")
self.app.ui.rel_position_label.setText("") self.app.ui.rel_position_label.setText("")

View File

@ -10,7 +10,7 @@ from flatcamTools.ToolFilm import Film
from flatcamTools.ToolImage import ToolImage from flatcamTools.ToolImage import ToolImage
from flatcamTools.ToolMeasurement import Measurement from flatcamTools.ToolDistance import Distance
from flatcamTools.ToolMove import ToolMove from flatcamTools.ToolMove import ToolMove
from flatcamTools.ToolNonCopperClear import NonCopperClear from flatcamTools.ToolNonCopperClear import NonCopperClear