- minor changes in the Distance Plugin
This commit is contained in:
@@ -4147,7 +4147,7 @@ class MainGUI(QtWidgets.QMainWindow):
|
|||||||
elif modifiers == QtCore.Qt.KeyboardModifier.NoModifier:
|
elif modifiers == QtCore.Qt.KeyboardModifier.NoModifier:
|
||||||
if key == QtCore.Qt.Key.Key_Escape or key == 'Escape':
|
if key == QtCore.Qt.Key.Key_Escape or key == 'Escape':
|
||||||
# abort the measurement action
|
# abort the measurement action
|
||||||
self.app.distance_tool.deactivate_measure_tool()
|
self.app.distance_tool.ui_disconnect()
|
||||||
self.app.inform.emit(_("Distance Tool exit..."))
|
self.app.inform.emit(_("Distance Tool exit..."))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class Distance(AppTool):
|
|||||||
self.sel_shapes = ShapeCollectionLegacy(obj=self, app=self.app, name='measurement')
|
self.sel_shapes = ShapeCollectionLegacy(obj=self, app=self.app, name='measurement')
|
||||||
|
|
||||||
# Signals
|
# Signals
|
||||||
self.ui.measure_btn.clicked.connect(self.activate_measure_tool)
|
self.ui.measure_btn.clicked.connect(self.ui_connect)
|
||||||
|
|
||||||
def run(self, toggle=False):
|
def run(self, toggle=False):
|
||||||
self.app.defaults.report_usage("ToolDistance()")
|
self.app.defaults.report_usage("ToolDistance()")
|
||||||
@@ -104,9 +104,9 @@ class Distance(AppTool):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
if self.active is False:
|
if self.active is False:
|
||||||
self.activate_measure_tool()
|
self.ui_connect()
|
||||||
else:
|
else:
|
||||||
self.deactivate_measure_tool()
|
self.ui_disconnect()
|
||||||
|
|
||||||
def install(self, icon=None, separator=None, **kwargs):
|
def install(self, icon=None, separator=None, **kwargs):
|
||||||
AppTool.install(self, icon, separator, shortcut='Ctrl+M', **kwargs)
|
AppTool.install(self, icon, separator, shortcut='Ctrl+M', **kwargs)
|
||||||
@@ -161,15 +161,13 @@ class Distance(AppTool):
|
|||||||
|
|
||||||
# snap center works only for Gerber and Execellon Editor's
|
# snap center works only for Gerber and Execellon Editor's
|
||||||
if self.original_call_source == 'exc_editor' or self.original_call_source == 'grb_editor':
|
if self.original_call_source == 'exc_editor' or self.original_call_source == 'grb_editor':
|
||||||
self.ui.param_label.show()
|
self.ui.snap_center_cb.show()
|
||||||
self.ui.par_frame.show()
|
|
||||||
snap_center = self.app.defaults['tools_dist_snap_center']
|
snap_center = self.app.defaults['tools_dist_snap_center']
|
||||||
self.on_snap_toggled(snap_center)
|
self.on_snap_toggled(snap_center)
|
||||||
|
|
||||||
self.ui.snap_center_cb.toggled.connect(self.on_snap_toggled)
|
self.ui.snap_center_cb.toggled.connect(self.on_snap_toggled)
|
||||||
else:
|
else:
|
||||||
self.ui.param_label.hide()
|
self.ui.snap_center_cb.hide()
|
||||||
self.ui.par_frame.hide()
|
|
||||||
try:
|
try:
|
||||||
self.ui.snap_center_cb.toggled.disconnect(self.on_snap_toggled)
|
self.ui.snap_center_cb.toggled.disconnect(self.on_snap_toggled)
|
||||||
except (TypeError, AttributeError):
|
except (TypeError, AttributeError):
|
||||||
@@ -192,7 +190,7 @@ class Distance(AppTool):
|
|||||||
if self.app.ui.grid_snap_btn.isChecked():
|
if self.app.ui.grid_snap_btn.isChecked():
|
||||||
self.app.ui.grid_snap_btn.trigger()
|
self.app.ui.grid_snap_btn.trigger()
|
||||||
|
|
||||||
def activate_measure_tool(self):
|
def ui_connect(self):
|
||||||
# ENABLE the Measuring TOOL
|
# ENABLE the Measuring TOOL
|
||||||
self.active = True
|
self.active = True
|
||||||
|
|
||||||
@@ -256,7 +254,7 @@ class Distance(AppTool):
|
|||||||
|
|
||||||
self.set_tool_ui()
|
self.set_tool_ui()
|
||||||
|
|
||||||
def deactivate_measure_tool(self):
|
def ui_disconnect(self):
|
||||||
# DISABLE the Measuring TOOL
|
# DISABLE the Measuring TOOL
|
||||||
self.active = False
|
self.active = False
|
||||||
self.points = []
|
self.points = []
|
||||||
@@ -384,7 +382,7 @@ class Distance(AppTool):
|
|||||||
|
|
||||||
if len(clicked_pads) > 1:
|
if len(clicked_pads) > 1:
|
||||||
self.tool_done = True
|
self.tool_done = True
|
||||||
self.deactivate_measure_tool()
|
self.ui_disconnect()
|
||||||
self.app.inform.emit('[WARNING_NOTCL] %s' % _("Pads overlapped. Aborting."))
|
self.app.inform.emit('[WARNING_NOTCL] %s' % _("Pads overlapped. Aborting."))
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -413,7 +411,7 @@ class Distance(AppTool):
|
|||||||
|
|
||||||
self.calculate_distance(pos=pos)
|
self.calculate_distance(pos=pos)
|
||||||
elif event.button == right_button and event_is_dragging is False:
|
elif event.button == right_button and event_is_dragging is False:
|
||||||
self.deactivate_measure_tool()
|
self.ui_disconnect()
|
||||||
self.app.inform.emit(_("Distance Tool cancelled."))
|
self.app.inform.emit(_("Distance Tool cancelled."))
|
||||||
|
|
||||||
def calculate_distance(self, pos):
|
def calculate_distance(self, pos):
|
||||||
@@ -454,7 +452,7 @@ class Distance(AppTool):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.tool_done = True
|
self.tool_done = True
|
||||||
self.deactivate_measure_tool()
|
self.ui_disconnect()
|
||||||
|
|
||||||
def on_mouse_move_meas(self, event):
|
def on_mouse_move_meas(self, event):
|
||||||
try: # May fail in case mouse not within axes
|
try: # May fail in case mouse not within axes
|
||||||
@@ -605,6 +603,12 @@ class DistUI:
|
|||||||
)
|
)
|
||||||
param_grid.addWidget(self.snap_center_cb, 0, 0, 1, 2)
|
param_grid.addWidget(self.snap_center_cb, 0, 0, 1, 2)
|
||||||
|
|
||||||
|
self.multipoint_cb = FCCheckBox(_("Segmented"))
|
||||||
|
self.multipoint_cb.setToolTip(
|
||||||
|
_("Make a measurement over multiple distance segments.")
|
||||||
|
)
|
||||||
|
param_grid.addWidget(self.multipoint_cb, 2, 0, 1, 2)
|
||||||
|
|
||||||
# #############################################################################################################
|
# #############################################################################################################
|
||||||
# Coordinates Frame
|
# Coordinates Frame
|
||||||
# #############################################################################################################
|
# #############################################################################################################
|
||||||
|
|||||||
Reference in New Issue
Block a user