- code cleanup in Tools

- some GUI structure optimization's
This commit is contained in:
Marius Stanciu
2019-02-02 18:26:01 +02:00
committed by Marius S
parent 4f97e8ae45
commit 0b96cbbac1
15 changed files with 350 additions and 208 deletions

View File

@@ -384,6 +384,24 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.menuproject.addSeparator() self.menuproject.addSeparator()
self.menuprojectproperties = self.menuproject.addAction(QtGui.QIcon('share/properties32.png'), 'Properties') self.menuprojectproperties = self.menuproject.addAction(QtGui.QIcon('share/properties32.png'), 'Properties')
################
### Splitter ###
################
# IMPORTANT #
# The order: SPITTER -> NOTEBOOK -> SNAP TOOLBAR is important and without it the GUI will not be initialized as
# desired.
self.splitter = QtWidgets.QSplitter()
self.setCentralWidget(self.splitter)
self.notebook = QtWidgets.QTabWidget()
self.splitter.addWidget(self.notebook)
self.splitter_left = QtWidgets.QSplitter(Qt.Vertical)
self.splitter.addWidget(self.splitter_left)
self.splitter_left.addWidget(self.notebook)
self.splitter_left.setHandleWidth(0)
############### ###############
### Toolbar ### ### Toolbar ###
############### ###############
@@ -408,24 +426,6 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.geo_edit_toolbar.setObjectName('GeoEditor_TB') self.geo_edit_toolbar.setObjectName('GeoEditor_TB')
self.addToolBar(self.geo_edit_toolbar) self.addToolBar(self.geo_edit_toolbar)
################
### Splitter ###
################
# IMPORTANT #
# The order: SPITTER -> NOTEBOOK -> SNAP TOOLBAR is important and without it the GUI will not be initialized as
# desired.
self.splitter = QtWidgets.QSplitter()
self.setCentralWidget(self.splitter)
self.notebook = QtWidgets.QTabWidget()
self.splitter.addWidget(self.notebook)
self.splitter_left = QtWidgets.QSplitter(Qt.Vertical)
self.splitter.addWidget(self.splitter_left)
self.splitter_left.addWidget(self.notebook)
self.splitter_left.setHandleWidth(0)
self.snap_toolbar = QtWidgets.QToolBar('Grid Toolbar') self.snap_toolbar = QtWidgets.QToolBar('Grid Toolbar')
self.snap_toolbar.setObjectName('Snap_TB') self.snap_toolbar.setObjectName('Snap_TB')
@@ -440,8 +440,114 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
else: else:
self.addToolBar(self.snap_toolbar) self.addToolBar(self.snap_toolbar)
# add the actions/widgets to the toolbars ### File Toolbar ###
self.populate_toolbars() self.file_open_gerber_btn = self.toolbarfile.addAction(QtGui.QIcon('share/flatcam_icon32.png'),
"Open GERBER")
self.file_open_excellon_btn = self.toolbarfile.addAction(QtGui.QIcon('share/drill32.png'), "Open EXCELLON")
self.toolbarfile.addSeparator()
self.file_open_btn = self.toolbarfile.addAction(QtGui.QIcon('share/folder32.png'), "Open project")
self.file_save_btn = self.toolbarfile.addAction(QtGui.QIcon('share/floppy32.png'), "Save project")
### Edit Toolbar ###
self.newgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_geo32_bis.png'), "New Blank Geometry")
self.newexc_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_exc32.png'), "New Blank Excellon")
self.toolbargeo.addSeparator()
self.editgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/edit32.png'), "Editor")
self.update_obj_btn = self.toolbargeo.addAction(
QtGui.QIcon('share/edit_ok32_bis.png'), "Save Object and close the Editor"
)
self.toolbargeo.addSeparator()
self.delete_btn = self.toolbargeo.addAction(QtGui.QIcon('share/cancel_edit32.png'), "&Delete")
### View Toolbar ###
self.replot_btn = self.toolbarview.addAction(QtGui.QIcon('share/replot32.png'), "&Replot")
self.clear_plot_btn = self.toolbarview.addAction(QtGui.QIcon('share/clear_plot32.png'), "&Clear plot")
self.zoom_in_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_in32.png'), "Zoom In")
self.zoom_out_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_out32.png'), "Zoom Out")
self.zoom_fit_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_fit32.png'), "Zoom Fit")
# self.toolbarview.setVisible(False)
### Tools Toolbar ###
self.shell_btn = self.toolbartools.addAction(QtGui.QIcon('share/shell32.png'), "&Command Line")
### Drill Editor Toolbar ###
self.select_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), "Select 'Esc'")
self.add_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/plus16.png'), 'Add Drill Hole')
self.add_drill_array_btn = self.exc_edit_toolbar.addAction(
QtGui.QIcon('share/addarray16.png'), 'Add Drill Hole Array')
self.resize_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/resize16.png'), 'Resize Drill')
self.exc_edit_toolbar.addSeparator()
self.copy_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), 'Copy Drill')
self.delete_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/deleteshape32.png'), "Delete Drill")
self.exc_edit_toolbar.addSeparator()
self.move_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), "Move Drill")
### Geometry Editor Toolbar ###
self.geo_select_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), "Select 'Esc'")
self.geo_add_circle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/circle32.png'), 'Add Circle')
self.geo_add_arc_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/arc32.png'), 'Add Arc')
self.geo_add_rectangle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/rectangle32.png'),
'Add Rectangle')
self.geo_edit_toolbar.addSeparator()
self.geo_add_path_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/path32.png'), 'Add Path')
self.geo_add_polygon_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/polygon32.png'), 'Add Polygon')
self.geo_edit_toolbar.addSeparator()
self.geo_add_text_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/text32.png'), 'Add Text')
self.geo_add_buffer_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/buffer16-2.png'), 'Add Buffer')
self.geo_add_paint_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/paint20_1.png'), 'Paint Shape')
self.geo_edit_toolbar.addSeparator()
self.geo_union_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/union32.png'), 'Polygon Union')
self.geo_intersection_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/intersection32.png'),
'Polygon Intersection')
self.geo_subtract_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/subtract32.png'),
'Polygon Subtraction')
self.geo_edit_toolbar.addSeparator()
self.geo_cutpath_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/cutpath32.png'), 'Cut Path')
self.geo_copy_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), "Copy Objects 'c'")
self.geo_rotate_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/rotate.png'), "Rotate Objects 'Space'")
self.geo_delete_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/deleteshape32.png'),
"Delete Shape '-'")
self.geo_edit_toolbar.addSeparator()
self.geo_move_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), "Move Objects 'm'")
### Snap Toolbar ###
# Snap GRID toolbar is always active to facilitate usage of measurements done on GRID
# self.addToolBar(self.snap_toolbar)
self.grid_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/grid32.png'), 'Snap to grid')
self.grid_gap_x_entry = FCEntry2()
self.grid_gap_x_entry.setMaximumWidth(70)
self.grid_gap_x_entry.setToolTip("Grid X distance")
self.snap_toolbar.addWidget(self.grid_gap_x_entry)
self.grid_gap_y_entry = FCEntry2()
self.grid_gap_y_entry.setMaximumWidth(70)
self.grid_gap_y_entry.setToolTip("Grid Y distance")
self.snap_toolbar.addWidget(self.grid_gap_y_entry)
self.grid_space_label = QtWidgets.QLabel(" ")
self.snap_toolbar.addWidget(self.grid_space_label)
self.grid_gap_link_cb = FCCheckBox()
self.grid_gap_link_cb.setToolTip("When active, value on Grid_X\n"
"is copied to the Grid_Y value.")
self.snap_toolbar.addWidget(self.grid_gap_link_cb)
self.ois_grid = OptionalInputSection(self.grid_gap_link_cb, [self.grid_gap_y_entry], logic=False)
self.corner_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/corner32.png'), 'Snap to corner')
self.snap_max_dist_entry = FCEntry()
self.snap_max_dist_entry.setMaximumWidth(70)
self.snap_max_dist_entry.setToolTip("Max. magnet distance")
self.snap_magnet = self.snap_toolbar.addWidget(self.snap_max_dist_entry)
################ ################
@@ -897,6 +1003,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
# start with GRID activated # start with GRID activated
self.grid_snap_btn.trigger() self.grid_snap_btn.trigger()
self.g_editor_cmenu.setEnabled(False)
self.e_editor_cmenu.setEnabled(False)
# restore the Toolbar State from file # restore the Toolbar State from file
settings = QSettings("Open Source", "FlatCAM") settings = QSettings("Open Source", "FlatCAM")
if settings.contains("saved_gui_state"): if settings.contains("saved_gui_state"):
@@ -912,9 +1021,6 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.geo_edit_toolbar.setVisible(False) self.geo_edit_toolbar.setVisible(False)
self.geo_edit_toolbar.setDisabled(True) self.geo_edit_toolbar.setDisabled(True)
self.g_editor_cmenu.setEnabled(False)
self.e_editor_cmenu.setEnabled(False)
self.corner_snap_btn.setVisible(False) self.corner_snap_btn.setVisible(False)
self.snap_magnet.setVisible(False) self.snap_magnet.setVisible(False)
elif theme == 'compact': elif theme == 'compact':
@@ -922,15 +1028,14 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.geo_edit_toolbar.setDisabled(True) self.geo_edit_toolbar.setDisabled(True)
self.snap_magnet.setVisible(True) self.snap_magnet.setVisible(True)
self.corner_snap_btn.setVisible(True) self.corner_snap_btn.setVisible(True)
self.snap_magnet.setDisabled(True)
self.corner_snap_btn.setDisabled(True)
else: else:
self.exc_edit_toolbar.setVisible(False) self.exc_edit_toolbar.setVisible(False)
self.exc_edit_toolbar.setDisabled(True) self.exc_edit_toolbar.setDisabled(True)
self.geo_edit_toolbar.setVisible(False) self.geo_edit_toolbar.setVisible(False)
self.geo_edit_toolbar.setDisabled(True) self.geo_edit_toolbar.setDisabled(True)
self.g_editor_cmenu.setEnabled(False)
self.e_editor_cmenu.setEnabled(False)
self.corner_snap_btn.setVisible(False) self.corner_snap_btn.setVisible(False)
self.snap_magnet.setVisible(False) self.snap_magnet.setVisible(False)

View File

@@ -46,57 +46,66 @@ class KeySensitiveListView(QtWidgets.QTreeView):
event.ignore() event.ignore()
def dragMoveEvent(self, event): def dragMoveEvent(self, event):
self.setDropIndicatorShown(True)
if event.mimeData().hasUrls: if event.mimeData().hasUrls:
event.accept() event.accept()
else: else:
event.ignore() event.ignore()
def dropEvent(self, event): def dropEvent(self, event):
if event.mimeData().hasUrls: drop_indicator = self.dropIndicatorPosition()
event.setDropAction(QtCore.Qt.CopyAction)
m = event.mimeData()
if m.hasUrls:
event.accept() event.accept()
for url in event.mimeData().urls():
for url in m.urls():
self.filename = str(url.toLocalFile()) self.filename = str(url.toLocalFile())
if self.filename == "": # file drop from outside application
self.app.inform.emit("Open cancelled.") if drop_indicator == QtWidgets.QAbstractItemView.OnItem:
if self.filename == "":
self.app.inform.emit("Open cancelled.")
else:
if self.filename.lower().rpartition('.')[-1] in self.app.grb_list:
self.app.worker_task.emit({'fcn': self.app.open_gerber,
'params': [self.filename]})
else:
event.ignore()
if self.filename.lower().rpartition('.')[-1] in self.app.exc_list:
self.app.worker_task.emit({'fcn': self.app.open_excellon,
'params': [self.filename]})
else:
event.ignore()
if self.filename.lower().rpartition('.')[-1] in self.app.gcode_list:
self.app.worker_task.emit({'fcn': self.app.open_gcode,
'params': [self.filename]})
else:
event.ignore()
if self.filename.lower().rpartition('.')[-1] in self.app.svg_list:
object_type = 'geometry'
self.app.worker_task.emit({'fcn': self.app.import_svg,
'params': [self.filename, object_type, None]})
if self.filename.lower().rpartition('.')[-1] in self.app.dxf_list:
object_type = 'geometry'
self.app.worker_task.emit({'fcn': self.app.import_dxf,
'params': [self.filename, object_type, None]})
if self.filename.lower().rpartition('.')[-1] in self.app.prj_list:
# self.app.open_project() is not Thread Safe
self.app.open_project(self.filename)
else:
event.ignore()
else: else:
if self.filename.lower().rpartition('.')[-1] in self.app.grb_list: pass
self.app.worker_task.emit({'fcn': self.app.open_gerber,
'params': [self.filename]})
else:
event.ignore()
if self.filename.lower().rpartition('.')[-1] in self.app.exc_list:
self.app.worker_task.emit({'fcn': self.app.open_excellon,
'params': [self.filename]})
else:
event.ignore()
if self.filename.lower().rpartition('.')[-1] in self.app.gcode_list:
self.app.worker_task.emit({'fcn': self.app.open_gcode,
'params': [self.filename]})
else:
event.ignore()
if self.filename.lower().rpartition('.')[-1] in self.app.svg_list:
object_type = 'geometry'
self.app.worker_task.emit({'fcn': self.app.import_svg,
'params': [self.filename, object_type, None]})
if self.filename.lower().rpartition('.')[-1] in self.app.dxf_list:
object_type = 'geometry'
self.app.worker_task.emit({'fcn': self.app.import_dxf,
'params': [self.filename, object_type, None]})
if self.filename.lower().rpartition('.')[-1] in self.app.prj_list:
# self.app.open_project() is not Thread Safe
self.app.open_project(self.filename)
else:
event.ignore()
else: else:
event.ignore() event.ignore()
class TreeItem: class TreeItem:
""" """
Item of a tree model Item of a tree model
@@ -221,9 +230,15 @@ class ObjectCollection(QtCore.QAbstractItemModel):
### View ### View
self.view = KeySensitiveListView(app) self.view = KeySensitiveListView(app)
self.view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
self.view.setModel(self) self.view.setModel(self)
self.view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
# self.view.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove)
# self.view.setDragEnabled(True)
# self.view.setAcceptDrops(True)
# self.view.setDropIndicatorShown(True)
font = QtGui.QFont() font = QtGui.QFont()
font.setPixelSize(12) font.setPixelSize(12)
font.setFamily("Seagoe UI") font.setFamily("Seagoe UI")
@@ -501,13 +516,13 @@ class ObjectCollection(QtCore.QAbstractItemModel):
if not self.hasIndex(row, column, parent): if not self.hasIndex(row, column, parent):
return QtCore.QModelIndex() return QtCore.QModelIndex()
if not parent.isValid(): # if not parent.isValid():
parent_item = self.root_item # parent_item = self.root_item
else: # else:
parent_item = parent.internalPointer() # parent_item = parent.internalPointer()
parent_item = parent.internalPointer() if parent.isValid() else self.root_item
child_item = parent_item.child(row) child_item = parent_item.child(row)
if child_item: if child_item:
return self.createIndex(row, column, child_item) return self.createIndex(row, column, child_item)
else: else:
@@ -587,39 +602,27 @@ class ObjectCollection(QtCore.QAbstractItemModel):
"setData() --> Could not remove the old object name from auto-completer model list") "setData() --> Could not remove the old object name from auto-completer model list")
obj.build_ui() obj.build_ui()
self.app.inform.emit("Object renamed from %s to %s" % (old_name, new_name)) self.app.inform.emit("Object renamed from %s to %s" % (old_name, new_name))
return True return True
def supportedDropActions(self):
return Qt.MoveAction
def flags(self, index): def flags(self, index):
default_flags = QtCore.QAbstractItemModel.flags(self, index)
if not index.isValid(): if not index.isValid():
return 0 return Qt.ItemIsEnabled | default_flags
# Prevent groups from selection # Prevent groups from selection
if not index.internalPointer().obj: if not index.internalPointer().obj:
return Qt.ItemIsEnabled return Qt.ItemIsEnabled
else: else:
return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsEditable return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsEditable | \
Qt.ItemIsDragEnabled | Qt.ItemIsDropEnabled
return QtWidgets.QAbstractItemModel.flags(self, index) # return QtWidgets.QAbstractItemModel.flags(self, index)
# def data(self, index, role=Qt.Qt.DisplayRole):
# if not index.isValid() or not 0 <= index.row() < self.rowCount():
# return QtCore.QVariant()
# row = index.row()
# if role == Qt.Qt.DisplayRole:
# return self.object_list[row].options["name"]
# if role == Qt.Qt.DecorationRole:
# return self.icons[self.object_list[row].kind]
# # if role == Qt.Qt.CheckStateRole:
# # if row in self.checked_indexes:
# # return Qt.Qt.Checked
# # else:
# # return Qt.Qt.Unchecked
def print_list(self):
for obj in self.get_list():
print(obj)
def append(self, obj, active=False): def append(self, obj, active=False):
FlatCAMApp.App.log.debug(str(inspect.stack()[1][3]) + " --> OC.append()") FlatCAMApp.App.log.debug(str(inspect.stack()[1][3]) + " --> OC.append()")
@@ -629,8 +632,8 @@ class ObjectCollection(QtCore.QAbstractItemModel):
# Check promises and clear if exists # Check promises and clear if exists
if name in self.promises: if name in self.promises:
self.promises.remove(name) self.promises.remove(name)
FlatCAMApp.App.log.debug("Promised object %s became available." % name) # FlatCAMApp.App.log.debug("Promised object %s became available." % name)
FlatCAMApp.App.log.debug("%d promised objects remaining." % len(self.promises)) # FlatCAMApp.App.log.debug("%d promised objects remaining." % len(self.promises))
# Prevent same name # Prevent same name
while name in self.get_names(): while name in self.get_names():
## Create a new name ## Create a new name

View File

@@ -9,6 +9,11 @@ CAD program, and create G-Code for Isolation routing.
================================================= =================================================
2.2.2019
- code cleanup in Tools
- some GUI structure optimization's
1.02.2019 1.02.2019
- fixed postprocessor files so now the bounds values are right aligned (assuming max string length of 9 chars which means 4 digits and 4 decimals) - fixed postprocessor files so now the bounds values are right aligned (assuming max string length of 9 chars which means 4 digits and 4 decimals)
@@ -21,7 +26,6 @@ CAD program, and create G-Code for Isolation routing.
- replaced the pop-up window for the shortcut list with a new detachable tab - replaced the pop-up window for the shortcut list with a new detachable tab
- removed the pop-up messages from the rotate, skew, flip commands - removed the pop-up messages from the rotate, skew, flip commands
31.01.2019 31.01.2019
- added a parameter ('Fast plunge' in Edit -> Preferences -> Geometry Options and Excellon Options) to control if the fast move to Z_move is done or not - added a parameter ('Fast plunge' in Edit -> Preferences -> Geometry Options and Excellon Options) to control if the fast move to Z_move is done or not

View File

@@ -212,17 +212,16 @@ class ToolCalculator(FlatCAMTool):
self.calculate_plate_button.clicked.connect(self.on_calculate_eplate) self.calculate_plate_button.clicked.connect(self.on_calculate_eplate)
self.set_ui()
def run(self): def run(self):
FlatCAMTool.run(self) FlatCAMTool.run(self)
self.set_ui() self.set_tool_ui()
self.app.ui.notebook.setTabText(2, "Calc. Tool") self.app.ui.notebook.setTabText(2, "Calc. Tool")
def install(self, icon=None, separator=None, **kwargs): def install(self, icon=None, separator=None, **kwargs):
FlatCAMTool.install(self, icon, separator, shortcut='ALT+C', **kwargs) FlatCAMTool.install(self, icon, separator, shortcut='ALT+C', **kwargs)
def set_ui(self): def set_tool_ui(self):
## Initialize form ## Initialize form
self.mm_entry.set_value('0') self.mm_entry.set_value('0')
self.inch_entry.set_value('0') self.inch_entry.set_value('0')

View File

@@ -7,6 +7,7 @@ from GUIElements import IntEntry, RadioSet, LengthEntry
from FlatCAMObj import FlatCAMGeometry, FlatCAMExcellon, FlatCAMGerber from FlatCAMObj import FlatCAMGeometry, FlatCAMExcellon, FlatCAMGerber
class ToolCutout(FlatCAMTool): class ToolCutout(FlatCAMTool):
toolName = "Cutout PCB" toolName = "Cutout PCB"
@@ -47,7 +48,6 @@ class ToolCutout(FlatCAMTool):
self.obj_combo = QtWidgets.QComboBox() self.obj_combo = QtWidgets.QComboBox()
self.obj_combo.setModel(self.app.collection) self.obj_combo.setModel(self.app.collection)
self.obj_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) self.obj_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
self.obj_combo.setCurrentIndex(1)
self.object_label = QtWidgets.QLabel("Object:") self.object_label = QtWidgets.QLabel("Object:")
self.object_label.setToolTip( self.object_label.setToolTip(
"Object to be cutout. " "Object to be cutout. "
@@ -172,11 +172,11 @@ class ToolCutout(FlatCAMTool):
self.layout.addStretch() self.layout.addStretch()
## Init GUI ## Init GUI
self.dia.set_value(1) # self.dia.set_value(1)
self.margin.set_value(0) # self.margin.set_value(0)
self.gapsize.set_value(1) # self.gapsize.set_value(1)
self.gaps.set_value(4) # self.gaps.set_value(4)
self.gaps_rect_radio.set_value("4") # self.gaps_rect_radio.set_value("4")
## Signals ## Signals
self.ff_cutout_object_btn.clicked.connect(self.on_freeform_cutout) self.ff_cutout_object_btn.clicked.connect(self.on_freeform_cutout)
@@ -191,13 +191,16 @@ class ToolCutout(FlatCAMTool):
def run(self): def run(self):
FlatCAMTool.run(self) FlatCAMTool.run(self)
self.set_ui() self.set_tool_ui()
self.app.ui.notebook.setTabText(2, "Cutout Tool") self.app.ui.notebook.setTabText(2, "Cutout Tool")
def install(self, icon=None, separator=None, **kwargs): def install(self, icon=None, separator=None, **kwargs):
FlatCAMTool.install(self, icon, separator, shortcut='ALT+U', **kwargs) FlatCAMTool.install(self, icon, separator, shortcut='ALT+U', **kwargs)
def set_ui(self): def set_tool_ui(self):
self.reset_fields()
self.obj_combo.setCurrentIndex(1)
self.dia.set_value(float(self.app.defaults["tools_cutouttooldia"])) self.dia.set_value(float(self.app.defaults["tools_cutouttooldia"]))
self.margin.set_value(float(self.app.defaults["tools_cutoutmargin"])) self.margin.set_value(float(self.app.defaults["tools_cutoutmargin"]))
self.gapsize.set_value(float(self.app.defaults["tools_cutoutgapsize"])) self.gapsize.set_value(float(self.app.defaults["tools_cutoutgapsize"]))

View File

@@ -28,7 +28,6 @@ class DblSidedTool(FlatCAMTool):
self.gerber_object_combo = QtWidgets.QComboBox() self.gerber_object_combo = QtWidgets.QComboBox()
self.gerber_object_combo.setModel(self.app.collection) self.gerber_object_combo.setModel(self.app.collection)
self.gerber_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) self.gerber_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
self.gerber_object_combo.setCurrentIndex(1)
self.botlay_label = QtWidgets.QLabel("<b>GERBER:</b>") self.botlay_label = QtWidgets.QLabel("<b>GERBER:</b>")
self.botlay_label.setToolTip( self.botlay_label.setToolTip(
@@ -52,7 +51,6 @@ class DblSidedTool(FlatCAMTool):
self.exc_object_combo = QtWidgets.QComboBox() self.exc_object_combo = QtWidgets.QComboBox()
self.exc_object_combo.setModel(self.app.collection) self.exc_object_combo.setModel(self.app.collection)
self.exc_object_combo.setRootModelIndex(self.app.collection.index(1, 0, QtCore.QModelIndex())) self.exc_object_combo.setRootModelIndex(self.app.collection.index(1, 0, QtCore.QModelIndex()))
self.exc_object_combo.setCurrentIndex(1)
self.excobj_label = QtWidgets.QLabel("<b>EXCELLON:</b>") self.excobj_label = QtWidgets.QLabel("<b>EXCELLON:</b>")
self.excobj_label.setToolTip( self.excobj_label.setToolTip(
@@ -249,20 +247,20 @@ class DblSidedTool(FlatCAMTool):
self.drill_values = "" self.drill_values = ""
self.set_ui()
def install(self, icon=None, separator=None, **kwargs): def install(self, icon=None, separator=None, **kwargs):
FlatCAMTool.install(self, icon, separator, shortcut='ALT+D', **kwargs) FlatCAMTool.install(self, icon, separator, shortcut='ALT+D', **kwargs)
def run(self): def run(self):
FlatCAMTool.run(self) FlatCAMTool.run(self)
self.set_tool_ui()
self.app.ui.notebook.setTabText(2, "2-Sided Tool") self.app.ui.notebook.setTabText(2, "2-Sided Tool")
self.reset_fields()
self.set_ui()
def set_ui(self): def set_tool_ui(self):
## Initialize form self.reset_fields()
self.gerber_object_combo.setCurrentIndex(1)
self.exc_object_combo.setCurrentIndex(1)
self.point_entry.set_value("") self.point_entry.set_value("")
self.alignment_holes.set_value("") self.alignment_holes.set_value("")

View File

@@ -43,7 +43,6 @@ class Film(FlatCAMTool):
self.tf_object_combo = QtWidgets.QComboBox() self.tf_object_combo = QtWidgets.QComboBox()
self.tf_object_combo.setModel(self.app.collection) self.tf_object_combo.setModel(self.app.collection)
self.tf_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) self.tf_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
self.tf_object_combo.setCurrentIndex(1)
self.tf_object_label = QtWidgets.QLabel("Film Object:") self.tf_object_label = QtWidgets.QLabel("Film Object:")
self.tf_object_label.setToolTip( self.tf_object_label.setToolTip(
"Object for which to create the film." "Object for which to create the film."
@@ -75,7 +74,6 @@ class Film(FlatCAMTool):
self.tf_box_combo = QtWidgets.QComboBox() self.tf_box_combo = QtWidgets.QComboBox()
self.tf_box_combo.setModel(self.app.collection) self.tf_box_combo.setModel(self.app.collection)
self.tf_box_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) self.tf_box_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
self.tf_box_combo.setCurrentIndex(1)
self.tf_box_combo_label = QtWidgets.QLabel("Box Object:") self.tf_box_combo_label = QtWidgets.QLabel("Box Object:")
self.tf_box_combo_label.setToolTip( self.tf_box_combo_label.setToolTip(
@@ -136,10 +134,6 @@ class Film(FlatCAMTool):
self.tf_type_obj_combo.currentIndexChanged.connect(self.on_type_obj_index_changed) self.tf_type_obj_combo.currentIndexChanged.connect(self.on_type_obj_index_changed)
self.tf_type_box_combo.currentIndexChanged.connect(self.on_type_box_index_changed) self.tf_type_box_combo.currentIndexChanged.connect(self.on_type_box_index_changed)
## Initialize form
self.film_type.set_value('neg')
self.boundary_entry.set_value(0.0)
def on_type_obj_index_changed(self, index): def on_type_obj_index_changed(self, index):
obj_type = self.tf_type_obj_combo.currentIndex() obj_type = self.tf_type_obj_combo.currentIndex()
self.tf_object_combo.setRootModelIndex(self.app.collection.index(obj_type, 0, QtCore.QModelIndex())) self.tf_object_combo.setRootModelIndex(self.app.collection.index(obj_type, 0, QtCore.QModelIndex()))
@@ -152,11 +146,20 @@ class Film(FlatCAMTool):
def run(self): def run(self):
FlatCAMTool.run(self) FlatCAMTool.run(self)
self.set_tool_ui()
self.app.ui.notebook.setTabText(2, "Film Tool") self.app.ui.notebook.setTabText(2, "Film Tool")
def install(self, icon=None, separator=None, **kwargs): def install(self, icon=None, separator=None, **kwargs):
FlatCAMTool.install(self, icon, separator, shortcut='ALT+L', **kwargs) FlatCAMTool.install(self, icon, separator, shortcut='ALT+L', **kwargs)
def set_tool_ui(self):
self.reset_fields()
self.tf_object_combo.setCurrentIndex(1)
self.tf_box_combo.setCurrentIndex(1)
self.film_type.set_value('neg')
self.boundary_entry.set_value(0.0)
def on_film_creation(self): def on_film_creation(self):
try: try:
name = self.tf_object_combo.currentText() name = self.tf_object_combo.currentText()

View File

@@ -124,6 +124,15 @@ class ToolImage(FlatCAMTool):
## Signals ## Signals
self.import_button.clicked.connect(self.on_file_importimage) self.import_button.clicked.connect(self.on_file_importimage)
def run(self):
FlatCAMTool.run(self)
self.set_tool_ui()
self.app.ui.notebook.setTabText(2, "Image Tool")
def install(self, icon=None, separator=None, **kwargs):
FlatCAMTool.install(self, icon, separator, **kwargs)
def set_tool_ui(self):
## Initialize form ## Initialize form
self.dpi_entry.set_value(96) self.dpi_entry.set_value(96)
self.image_type.set_value('black') self.image_type.set_value('black')
@@ -132,10 +141,6 @@ class ToolImage(FlatCAMTool):
self.mask_g_entry.set_value(250) self.mask_g_entry.set_value(250)
self.mask_b_entry.set_value(250) self.mask_b_entry.set_value(250)
def run(self):
FlatCAMTool.run(self)
self.app.ui.notebook.setTabText(2, "Image Tool")
def on_file_importimage(self): def on_file_importimage(self):
""" """
Callback for menu item File->Import IMAGE. Callback for menu item File->Import IMAGE.

View File

@@ -154,9 +154,15 @@ class Measurement(FlatCAMTool):
def run(self): def run(self):
if self.app.tool_tab_locked is True: if self.app.tool_tab_locked is True:
return return
self.toggle() self.toggle()
self.set_tool_ui()
self.app.ui.notebook.setTabText(2, "Meas. Tool")
def install(self, icon=None, separator=None, **kwargs):
FlatCAMTool.install(self, icon, separator, shortcut='CTRL+M', **kwargs)
def set_tool_ui(self):
# Remove anything else in the GUI # Remove anything else in the GUI
self.app.ui.tool_scroll_area.takeWidget() self.app.ui.tool_scroll_area.takeWidget()
@@ -167,21 +173,6 @@ 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.general_options_form.general_app_group.units_radio.get_value().lower() self.units = self.app.general_options_form.general_app_group.units_radio.get_value().lower()
self.show() self.show()
self.app.ui.notebook.setTabText(2, "Meas. Tool")
def install(self, icon=None, separator=None, **kwargs):
FlatCAMTool.install(self, icon, separator, shortcut='CTRL+M', **kwargs)
def on_key_release_meas(self, event):
if event.key == 'escape':
# abort the measurement action
self.toggle()
return
if event.key == 'G':
# toggle grid status
self.app.ui.grid_snap_btn.trigger()
return
def toggle(self): def toggle(self):
# the self.active var is doing the 'toggle' # the self.active var is doing the 'toggle'
@@ -264,6 +255,17 @@ class Measurement(FlatCAMTool):
self.app.inform.emit("MEASURING: Click on the Start point ...") self.app.inform.emit("MEASURING: Click on the Start point ...")
def on_key_release_meas(self, event):
if event.key == 'escape':
# abort the measurement action
self.toggle()
return
if event.key == 'G':
# toggle grid status
self.app.ui.grid_snap_btn.trigger()
return
def on_click_meas(self, event): def on_click_meas(self, event):
# mouse click will be accepted only if the left button is clicked # mouse click will be accepted only if the left button is clicked
# this is necessary because right mouse click and middle mouse click # this is necessary because right mouse click and middle mouse click

View File

@@ -38,6 +38,38 @@ class ToolMove(FlatCAMTool):
return return
self.toggle() self.toggle()
def toggle(self):
if self.isVisible():
self.setVisible(False)
self.app.plotcanvas.vis_disconnect('mouse_move', self.on_move)
self.app.plotcanvas.vis_disconnect('mouse_press', self.on_left_click)
self.app.plotcanvas.vis_disconnect('key_release', self.on_key_press)
self.app.plotcanvas.vis_connect('key_press', self.app.on_key_over_plot)
self.clicked_move = 0
# signal that there is no command active
self.app.command_active = None
# delete the selection box
self.delete_shape()
return
else:
self.setVisible(True)
# signal that there is a command active and it is 'Move'
self.app.command_active = "Move"
if self.app.collection.get_selected():
self.app.inform.emit("MOVE: Click on the Start point ...")
# draw the selection box
self.draw_sel_bbox()
else:
self.setVisible(False)
# signal that there is no command active
self.app.command_active = None
self.app.inform.emit("[warning_notcl]MOVE action cancelled. No object(s) to move.")
def on_left_click(self, event): def on_left_click(self, event):
# mouse click will be accepted only if the left button is clicked # mouse click will be accepted only if the left button is clicked
# this is necessary because right mouse click and middle mouse click # this is necessary because right mouse click and middle mouse click
@@ -146,38 +178,6 @@ class ToolMove(FlatCAMTool):
self.toggle() self.toggle()
return return
def toggle(self):
if self.isVisible():
self.setVisible(False)
self.app.plotcanvas.vis_disconnect('mouse_move', self.on_move)
self.app.plotcanvas.vis_disconnect('mouse_press', self.on_left_click)
self.app.plotcanvas.vis_disconnect('key_release', self.on_key_press)
self.app.plotcanvas.vis_connect('key_press', self.app.on_key_over_plot)
self.clicked_move = 0
# signal that there is no command active
self.app.command_active = None
# delete the selection box
self.delete_shape()
return
else:
self.setVisible(True)
# signal that there is a command active and it is 'Move'
self.app.command_active = "Move"
if self.app.collection.get_selected():
self.app.inform.emit("MOVE: Click on the Start point ...")
# draw the selection box
self.draw_sel_bbox()
else:
self.setVisible(False)
# signal that there is no command active
self.app.command_active = None
self.app.inform.emit("[warning_notcl]MOVE action cancelled. No object(s) to move.")
def draw_sel_bbox(self): def draw_sel_bbox(self):
xminlist = [] xminlist = []
yminlist = [] yminlist = []

View File

@@ -34,7 +34,6 @@ class NonCopperClear(FlatCAMTool, Gerber):
self.object_combo = QtWidgets.QComboBox() self.object_combo = QtWidgets.QComboBox()
self.object_combo.setModel(self.app.collection) self.object_combo.setModel(self.app.collection)
self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
self.object_combo.setCurrentIndex(1)
self.object_label = QtWidgets.QLabel("Gerber:") self.object_label = QtWidgets.QLabel("Gerber:")
self.object_label.setToolTip( self.object_label.setToolTip(
"Gerber object to be cleared of excess copper. " "Gerber object to be cleared of excess copper. "
@@ -238,12 +237,15 @@ class NonCopperClear(FlatCAMTool, Gerber):
def run(self): def run(self):
FlatCAMTool.run(self) FlatCAMTool.run(self)
self.tools_frame.show() self.set_tool_ui()
self.set_ui()
self.build_ui() self.build_ui()
self.app.ui.notebook.setTabText(2, "NCC Tool") self.app.ui.notebook.setTabText(2, "NCC Tool")
def set_ui(self): def set_tool_ui(self):
self.tools_frame.show()
self.object_combo.setCurrentIndex(1)
self.ncc_overlap_entry.set_value(self.app.defaults["tools_nccoverlap"]) self.ncc_overlap_entry.set_value(self.app.defaults["tools_nccoverlap"])
self.ncc_margin_entry.set_value(self.app.defaults["tools_nccmargin"]) self.ncc_margin_entry.set_value(self.app.defaults["tools_nccmargin"])
self.ncc_method_radio.set_value(self.app.defaults["tools_nccmethod"]) self.ncc_method_radio.set_value(self.app.defaults["tools_nccmethod"])
@@ -882,3 +884,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
# Background # Background
self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]}) self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]})
def reset_fields(self):
self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))

View File

@@ -32,7 +32,6 @@ class ToolPaint(FlatCAMTool, Gerber):
self.object_combo = QtWidgets.QComboBox() self.object_combo = QtWidgets.QComboBox()
self.object_combo.setModel(self.app.collection) self.object_combo.setModel(self.app.collection)
self.object_combo.setRootModelIndex(self.app.collection.index(2, 0, QtCore.QModelIndex())) self.object_combo.setRootModelIndex(self.app.collection.index(2, 0, QtCore.QModelIndex()))
self.object_combo.setCurrentIndex(1)
self.object_label = QtWidgets.QLabel("Geometry:") self.object_label = QtWidgets.QLabel("Geometry:")
self.object_label.setToolTip( self.object_label.setToolTip(
"Geometry object to be painted. " "Geometry object to be painted. "
@@ -295,8 +294,7 @@ class ToolPaint(FlatCAMTool, Gerber):
def run(self): def run(self):
FlatCAMTool.run(self) FlatCAMTool.run(self)
self.tools_frame.show() self.set_tool_ui()
self.set_ui()
self.app.ui.notebook.setTabText(2, "Paint Tool") self.app.ui.notebook.setTabText(2, "Paint Tool")
def on_radio_selection(self): def on_radio_selection(self):
@@ -320,7 +318,11 @@ class ToolPaint(FlatCAMTool, Gerber):
self.deltool_btn.setDisabled(False) self.deltool_btn.setDisabled(False)
self.tools_table.setContextMenuPolicy(Qt.ActionsContextMenu) self.tools_table.setContextMenuPolicy(Qt.ActionsContextMenu)
def set_ui(self): def set_tool_ui(self):
self.tools_frame.show()
self.reset_fields()
self.object_combo.setCurrentIndex(1)
## Init the GUI interface ## Init the GUI interface
self.paintmargin_entry.set_value(self.default_data["paintmargin"]) self.paintmargin_entry.set_value(self.default_data["paintmargin"])
self.paintmethod_combo.set_value(self.default_data["paintmethod"]) self.paintmethod_combo.set_value(self.default_data["paintmethod"])
@@ -1125,3 +1127,6 @@ class ToolPaint(FlatCAMTool, Gerber):
# Background # Background
self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]}) self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]})
def reset_fields(self):
self.object_combo.setRootModelIndex(self.app.collection.index(2, 0, QtCore.QModelIndex()))

View File

@@ -43,7 +43,6 @@ class Panelize(FlatCAMTool):
self.object_combo = QtWidgets.QComboBox() self.object_combo = QtWidgets.QComboBox()
self.object_combo.setModel(self.app.collection) self.object_combo.setModel(self.app.collection)
self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
self.object_combo.setCurrentIndex(1)
self.object_label = QtWidgets.QLabel("Object:") self.object_label = QtWidgets.QLabel("Object:")
self.object_label.setToolTip( self.object_label.setToolTip(
"Object to be panelized. This means that it will\n" "Object to be panelized. This means that it will\n"
@@ -75,7 +74,6 @@ class Panelize(FlatCAMTool):
self.box_combo = QtWidgets.QComboBox() self.box_combo = QtWidgets.QComboBox()
self.box_combo.setModel(self.app.collection) self.box_combo.setModel(self.app.collection)
self.box_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) self.box_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
self.box_combo.setCurrentIndex(1)
self.box_combo_label = QtWidgets.QLabel("Box Object:") self.box_combo_label = QtWidgets.QLabel("Box Object:")
self.box_combo_label.setToolTip( self.box_combo_label.setToolTip(
"The actual object that is used a container for the\n " "The actual object that is used a container for the\n "
@@ -85,7 +83,6 @@ class Panelize(FlatCAMTool):
## Spacing Columns ## Spacing Columns
self.spacing_columns = FloatEntry() self.spacing_columns = FloatEntry()
self.spacing_columns.set_value(0.0)
self.spacing_columns_label = QtWidgets.QLabel("Spacing cols:") self.spacing_columns_label = QtWidgets.QLabel("Spacing cols:")
self.spacing_columns_label.setToolTip( self.spacing_columns_label.setToolTip(
"Spacing between columns of the desired panel.\n" "Spacing between columns of the desired panel.\n"
@@ -95,7 +92,6 @@ class Panelize(FlatCAMTool):
## Spacing Rows ## Spacing Rows
self.spacing_rows = FloatEntry() self.spacing_rows = FloatEntry()
self.spacing_rows.set_value(0.0)
self.spacing_rows_label = QtWidgets.QLabel("Spacing rows:") self.spacing_rows_label = QtWidgets.QLabel("Spacing rows:")
self.spacing_rows_label.setToolTip( self.spacing_rows_label.setToolTip(
"Spacing between rows of the desired panel.\n" "Spacing between rows of the desired panel.\n"
@@ -105,7 +101,6 @@ class Panelize(FlatCAMTool):
## Columns ## Columns
self.columns = IntEntry() self.columns = IntEntry()
self.columns.set_value(1)
self.columns_label = QtWidgets.QLabel("Columns:") self.columns_label = QtWidgets.QLabel("Columns:")
self.columns_label.setToolTip( self.columns_label.setToolTip(
"Number of columns of the desired panel" "Number of columns of the desired panel"
@@ -114,7 +109,6 @@ class Panelize(FlatCAMTool):
## Rows ## Rows
self.rows = IntEntry() self.rows = IntEntry()
self.rows.set_value(1)
self.rows_label = QtWidgets.QLabel("Rows:") self.rows_label = QtWidgets.QLabel("Rows:")
self.rows_label.setToolTip( self.rows_label.setToolTip(
"Number of rows of the desired panel" "Number of rows of the desired panel"
@@ -133,7 +127,6 @@ class Panelize(FlatCAMTool):
form_layout.addRow(self.constrain_cb) form_layout.addRow(self.constrain_cb)
self.x_width_entry = FloatEntry() self.x_width_entry = FloatEntry()
self.x_width_entry.set_value(0.0)
self.x_width_lbl = QtWidgets.QLabel("Width (DX):") self.x_width_lbl = QtWidgets.QLabel("Width (DX):")
self.x_width_lbl.setToolTip( self.x_width_lbl.setToolTip(
"The width (DX) within which the panel must fit.\n" "The width (DX) within which the panel must fit.\n"
@@ -142,7 +135,6 @@ class Panelize(FlatCAMTool):
form_layout.addRow(self.x_width_lbl, self.x_width_entry) form_layout.addRow(self.x_width_lbl, self.x_width_entry)
self.y_height_entry = FloatEntry() self.y_height_entry = FloatEntry()
self.y_height_entry.set_value(0.0)
self.y_height_lbl = QtWidgets.QLabel("Height (DY):") self.y_height_lbl = QtWidgets.QLabel("Height (DY):")
self.y_height_lbl.setToolTip( self.y_height_lbl.setToolTip(
"The height (DY)within which the panel must fit.\n" "The height (DY)within which the panel must fit.\n"
@@ -183,6 +175,28 @@ class Panelize(FlatCAMTool):
# flag to signal the constrain was activated # flag to signal the constrain was activated
self.constrain_flag = False self.constrain_flag = False
def run(self):
FlatCAMTool.run(self)
self.set_tool_ui()
self.app.ui.notebook.setTabText(2, "Panel. Tool")
def install(self, icon=None, separator=None, **kwargs):
FlatCAMTool.install(self, icon, separator, shortcut='ALT+Z', **kwargs)
def set_tool_ui(self):
self.reset_fields()
self.object_combo.setCurrentIndex(1)
self.box_combo.setCurrentIndex(1)
self.spacing_columns.set_value(0.0)
self.spacing_rows.set_value(0.0)
self.rows.set_value(1)
self.columns.set_value(1)
self.x_width_entry.set_value(0.0)
self.y_height_entry.set_value(0.0)
def on_type_obj_index_changed(self): def on_type_obj_index_changed(self):
obj_type = self.type_obj_combo.currentIndex() obj_type = self.type_obj_combo.currentIndex()
self.object_combo.setRootModelIndex(self.app.collection.index(obj_type, 0, QtCore.QModelIndex())) self.object_combo.setRootModelIndex(self.app.collection.index(obj_type, 0, QtCore.QModelIndex()))
@@ -193,13 +207,6 @@ class Panelize(FlatCAMTool):
self.box_combo.setRootModelIndex(self.app.collection.index(obj_type, 0, QtCore.QModelIndex())) self.box_combo.setRootModelIndex(self.app.collection.index(obj_type, 0, QtCore.QModelIndex()))
self.box_combo.setCurrentIndex(0) self.box_combo.setCurrentIndex(0)
def run(self):
FlatCAMTool.run(self)
self.app.ui.notebook.setTabText(2, "Panel. Tool")
def install(self, icon=None, separator=None, **kwargs):
FlatCAMTool.install(self, icon, separator, shortcut='ALT+Z', **kwargs)
def on_panelize(self): def on_panelize(self):
name = self.object_combo.currentText() name = self.object_combo.currentText()

View File

@@ -45,17 +45,18 @@ class Properties(FlatCAMTool):
if self.app.tool_tab_locked is True: if self.app.tool_tab_locked is True:
return return
self.set_tool_ui()
# this reset the TreeWidget
self.treeWidget.clear()
self.properties_frame.show()
FlatCAMTool.run(self) FlatCAMTool.run(self)
self.properties() self.properties()
def install(self, icon=None, separator=None, **kwargs): def install(self, icon=None, separator=None, **kwargs):
FlatCAMTool.install(self, icon, separator, shortcut='P', **kwargs) FlatCAMTool.install(self, icon, separator, shortcut='P', **kwargs)
def set_tool_ui(self):
# this reset the TreeWidget
self.treeWidget.clear()
self.properties_frame.show()
def properties(self): def properties(self):
obj_list = self.app.collection.get_selected() obj_list = self.app.collection.get_selected()
if not obj_list: if not obj_list:

View File

@@ -355,7 +355,15 @@ class ToolTransform(FlatCAMTool):
self.offx_entry.returnPressed.connect(self.on_offx) self.offx_entry.returnPressed.connect(self.on_offx)
self.offy_entry.returnPressed.connect(self.on_offy) self.offy_entry.returnPressed.connect(self.on_offy)
def run(self):
FlatCAMTool.run(self)
self.set_tool_ui()
self.app.ui.notebook.setTabText(2, "Transform Tool")
def install(self, icon=None, separator=None, **kwargs):
FlatCAMTool.install(self, icon, separator, shortcut='ALT+R', **kwargs)
def set_tool_ui(self):
## Initialize form ## Initialize form
self.rotate_entry.set_value('0') self.rotate_entry.set_value('0')
self.skewx_entry.set_value('0') self.skewx_entry.set_value('0')
@@ -366,13 +374,6 @@ class ToolTransform(FlatCAMTool):
self.offy_entry.set_value('0') self.offy_entry.set_value('0')
self.flip_ref_cb.setChecked(False) self.flip_ref_cb.setChecked(False)
def run(self):
FlatCAMTool.run(self)
self.app.ui.notebook.setTabText(2, "Transform Tool")
def install(self, icon=None, separator=None, **kwargs):
FlatCAMTool.install(self, icon, separator, shortcut='ALT+R', **kwargs)
def on_rotate(self): def on_rotate(self):
try: try:
value = float(self.rotate_entry.get_value()) value = float(self.rotate_entry.get_value())