Merged in codeZonkey/flatcam/plotToggle (pull request #77)
PlotToggle - From the Project tab
This commit is contained in:
@@ -24,7 +24,7 @@ class DblSidedTool(FlatCAMTool):
|
|||||||
|
|
||||||
## Layer to mirror
|
## Layer to mirror
|
||||||
self.object_combo = QtGui.QComboBox()
|
self.object_combo = QtGui.QComboBox()
|
||||||
self.object_combo.setModel(self.app.collection)
|
self.object_combo.setModel(self.app.collection.model)
|
||||||
self.botlay_label = QtGui.QLabel("Bottom Layer:")
|
self.botlay_label = QtGui.QLabel("Bottom Layer:")
|
||||||
self.botlay_label.setToolTip(
|
self.botlay_label.setToolTip(
|
||||||
"Layer to be mirrorer."
|
"Layer to be mirrorer."
|
||||||
@@ -68,7 +68,7 @@ class DblSidedTool(FlatCAMTool):
|
|||||||
self.point = EvalEntry()
|
self.point = EvalEntry()
|
||||||
self.point_box_container.addWidget(self.point)
|
self.point_box_container.addWidget(self.point)
|
||||||
self.box_combo = QtGui.QComboBox()
|
self.box_combo = QtGui.QComboBox()
|
||||||
self.box_combo.setModel(self.app.collection)
|
self.box_combo.setModel(self.app.collection.model)
|
||||||
self.point_box_container.addWidget(self.box_combo)
|
self.point_box_container.addWidget(self.box_combo)
|
||||||
self.box_combo.hide()
|
self.box_combo.hide()
|
||||||
|
|
||||||
@@ -180,6 +180,12 @@ class DblSidedTool(FlatCAMTool):
|
|||||||
px = 0.5 * (xmin + xmax)
|
px = 0.5 * (xmin + xmax)
|
||||||
py = 0.5 * (ymin + ymax)
|
py = 0.5 * (ymin + ymax)
|
||||||
|
|
||||||
|
# Ensure that the selected object will display when it is mirrored.
|
||||||
|
# If an object's plot setting is False it will still be available in
|
||||||
|
# the combo box. If the plot is not enforced to True then the user
|
||||||
|
# gets no feedback of the operation.
|
||||||
|
fcobj.options["plot"] = True;
|
||||||
|
|
||||||
fcobj.mirror(axis, [px, py])
|
fcobj.mirror(axis, [px, py])
|
||||||
fcobj.plot()
|
fcobj.plot()
|
||||||
|
|
||||||
|
|||||||
@@ -554,6 +554,7 @@ class App(QtCore.QObject):
|
|||||||
# Options
|
# Options
|
||||||
self.ui.options_combo.activated.connect(self.on_options_combo_change)
|
self.ui.options_combo.activated.connect(self.on_options_combo_change)
|
||||||
self.options_form.units_radio.group_toggle_fn = self.on_toggle_units
|
self.options_form.units_radio.group_toggle_fn = self.on_toggle_units
|
||||||
|
#Notebook tabs
|
||||||
|
|
||||||
####################
|
####################
|
||||||
### Other setups ###
|
### Other setups ###
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
# Date: 2/5/2014 #
|
# Date: 2/5/2014 #
|
||||||
# MIT Licence #
|
# MIT Licence #
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
from PyQt4 import QtGui, QtCore, Qt
|
from PyQt4 import QtGui, QtCore, Qt
|
||||||
from GUIElements import *
|
from GUIElements import *
|
||||||
|
|
||||||
@@ -152,6 +151,7 @@ class FlatCAMGUI(QtGui.QMainWindow):
|
|||||||
### Notebook ###
|
### Notebook ###
|
||||||
################
|
################
|
||||||
self.notebook = QtGui.QTabWidget()
|
self.notebook = QtGui.QTabWidget()
|
||||||
|
|
||||||
# self.notebook.setMinimumWidth(250)
|
# self.notebook.setMinimumWidth(250)
|
||||||
|
|
||||||
### Projet ###
|
### Projet ###
|
||||||
@@ -268,6 +268,7 @@ class FlatCAMGUI(QtGui.QMainWindow):
|
|||||||
QtGui.qApp.quit()
|
QtGui.qApp.quit()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class FlatCAMActivityView(QtGui.QWidget):
|
class FlatCAMActivityView(QtGui.QWidget):
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
@@ -375,6 +376,7 @@ class GerberOptionsGroupUI(OptionsGroupUI):
|
|||||||
self.plot_options_label.setToolTip(
|
self.plot_options_label.setToolTip(
|
||||||
"Plot (show) this object."
|
"Plot (show) this object."
|
||||||
)
|
)
|
||||||
|
|
||||||
grid0.addWidget(self.plot_cb, 0, 0)
|
grid0.addWidget(self.plot_cb, 0, 0)
|
||||||
|
|
||||||
# Solid CB
|
# Solid CB
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ class FlatCAMObj(QtCore.QObject):
|
|||||||
# The app should set this value.
|
# The app should set this value.
|
||||||
app = None
|
app = None
|
||||||
|
|
||||||
|
option_changed = QtCore.pyqtSignal(QtCore.QObject, str)
|
||||||
|
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
"""
|
"""
|
||||||
Constructor.
|
Constructor.
|
||||||
@@ -79,7 +81,8 @@ class FlatCAMObj(QtCore.QObject):
|
|||||||
setattr(self, attr, d[attr])
|
setattr(self, attr, d[attr])
|
||||||
|
|
||||||
def on_options_change(self, key):
|
def on_options_change(self, key):
|
||||||
self.emit(QtCore.SIGNAL("optionChanged"), key)
|
#self.emit(QtCore.SIGNAL("optionChanged()"), key)
|
||||||
|
self.option_changed.emit(self, key)
|
||||||
|
|
||||||
def set_ui(self, ui):
|
def set_ui(self, ui):
|
||||||
self.ui = ui
|
self.ui = ui
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ class KeySensitiveListView(QtGui.QListView):
|
|||||||
self.keyPressed.emit(event.key())
|
self.keyPressed.emit(event.key())
|
||||||
|
|
||||||
|
|
||||||
class ObjectCollection(QtCore.QAbstractListModel):
|
#class ObjectCollection(QtCore.QAbstractListModel):
|
||||||
|
class ObjectCollection():
|
||||||
"""
|
"""
|
||||||
Object storage and management.
|
Object storage and management.
|
||||||
"""
|
"""
|
||||||
@@ -45,7 +46,7 @@ class ObjectCollection(QtCore.QAbstractListModel):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
QtCore.QAbstractListModel.__init__(self, parent=parent)
|
#QtCore.QAbstractListModel.__init__(self, parent=parent)
|
||||||
### Icons for the list view
|
### Icons for the list view
|
||||||
self.icons = {}
|
self.icons = {}
|
||||||
for kind in ObjectCollection.icon_files:
|
for kind in ObjectCollection.icon_files:
|
||||||
@@ -66,7 +67,10 @@ class ObjectCollection(QtCore.QAbstractListModel):
|
|||||||
#self.view = QtGui.QListView()
|
#self.view = QtGui.QListView()
|
||||||
self.view = KeySensitiveListView()
|
self.view = KeySensitiveListView()
|
||||||
self.view.setSelectionMode(Qt.QAbstractItemView.ExtendedSelection)
|
self.view.setSelectionMode(Qt.QAbstractItemView.ExtendedSelection)
|
||||||
self.view.setModel(self)
|
self.model = QtGui.QStandardItemModel(self.view)
|
||||||
|
self.view.setModel(self.model)
|
||||||
|
self.model.itemChanged.connect(self.on_item_changed)
|
||||||
|
#self.view.setModel(self)
|
||||||
|
|
||||||
self.click_modifier = None
|
self.click_modifier = None
|
||||||
|
|
||||||
@@ -96,8 +100,13 @@ class ObjectCollection(QtCore.QAbstractListModel):
|
|||||||
self.get_active().ui.plot_cb.toggle()
|
self.get_active().ui.plot_cb.toggle()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def print_list(self):
|
||||||
|
for obj in self.object_list:
|
||||||
|
print obj
|
||||||
|
|
||||||
def on_mouse_down(self, event):
|
def on_mouse_down(self, event):
|
||||||
FlatCAMApp.App.log.debug("Mouse button pressed on list")
|
FlatCAMApp.App.log.debug("Mouse button pressed on list")
|
||||||
|
#self.print_list()
|
||||||
|
|
||||||
def rowCount(self, parent=QtCore.QModelIndex(), *args, **kwargs):
|
def rowCount(self, parent=QtCore.QModelIndex(), *args, **kwargs):
|
||||||
return len(self.object_list)
|
return len(self.object_list)
|
||||||
@@ -119,10 +128,6 @@ class ObjectCollection(QtCore.QAbstractListModel):
|
|||||||
# else:
|
# else:
|
||||||
# return Qt.Qt.Unchecked
|
# return Qt.Qt.Unchecked
|
||||||
|
|
||||||
def print_list(self):
|
|
||||||
for obj in self.object_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()")
|
||||||
|
|
||||||
@@ -151,13 +156,42 @@ class ObjectCollection(QtCore.QAbstractListModel):
|
|||||||
obj.set_ui(obj.ui_type())
|
obj.set_ui(obj.ui_type())
|
||||||
|
|
||||||
# Required before appending (Qt MVC)
|
# Required before appending (Qt MVC)
|
||||||
self.beginInsertRows(QtCore.QModelIndex(), len(self.object_list), len(self.object_list))
|
#self.beginInsertRows(QtCore.QModelIndex(), len(self.object_list), len(self.object_list))
|
||||||
|
|
||||||
# Simply append to the python list
|
# Simply append to the python list
|
||||||
self.object_list.append(obj)
|
self.object_list.append(obj)
|
||||||
|
|
||||||
|
# Create the model item to insert into the QListView
|
||||||
|
icon = QtGui.QIcon(self.icons[obj.kind])#self.icons["gerber"])
|
||||||
|
item = QtGui.QStandardItem(icon, name)
|
||||||
|
item.setCheckable(True)
|
||||||
|
if obj.options["plot"] == True:
|
||||||
|
item.setCheckState(2)#Qt.Checked)
|
||||||
|
else:
|
||||||
|
item.setCheckState(0) #Qt.Unchecked)
|
||||||
|
|
||||||
|
self.model.appendRow(item)
|
||||||
|
|
||||||
|
obj.option_changed.connect(self.on_object_option_changed)
|
||||||
|
|
||||||
# Required after appending (Qt MVC)
|
# Required after appending (Qt MVC)
|
||||||
self.endInsertRows()
|
#self.endInsertRows()
|
||||||
|
|
||||||
|
def on_object_option_changed(self, obj, key):
|
||||||
|
if key == "plot":
|
||||||
|
self.model.blockSignals(True)
|
||||||
|
name = obj.options["name"]
|
||||||
|
state = 0 #Qt.Unchecked
|
||||||
|
for index in range(self.model.rowCount()):
|
||||||
|
item = self.model.item(index)
|
||||||
|
if self.object_list[item.row()].options["name"] == name:
|
||||||
|
if obj.options["plot"] == True:
|
||||||
|
state = 2 #Qt.Checked
|
||||||
|
|
||||||
|
item.setCheckState(state)
|
||||||
|
obj.ui.plot_cb.set_value(state)
|
||||||
|
break
|
||||||
|
self.model.blockSignals(False)
|
||||||
|
|
||||||
def get_names(self):
|
def get_names(self):
|
||||||
"""
|
"""
|
||||||
@@ -220,11 +254,12 @@ class ObjectCollection(QtCore.QAbstractListModel):
|
|||||||
return
|
return
|
||||||
row = selections[0].row()
|
row = selections[0].row()
|
||||||
|
|
||||||
self.beginRemoveRows(QtCore.QModelIndex(), row, row)
|
#self.beginRemoveRows(QtCore.QModelIndex(), row, row)
|
||||||
|
|
||||||
self.object_list.pop(row)
|
self.object_list.pop(row)
|
||||||
|
self.model.removeRow(row)
|
||||||
|
|
||||||
self.endRemoveRows()
|
#self.endRemoveRows()
|
||||||
|
|
||||||
def get_active(self):
|
def get_active(self):
|
||||||
"""
|
"""
|
||||||
@@ -289,6 +324,16 @@ class ObjectCollection(QtCore.QAbstractListModel):
|
|||||||
|
|
||||||
self.object_list[selection_index].build_ui()
|
self.object_list[selection_index].build_ui()
|
||||||
|
|
||||||
|
def on_item_changed(self, item):
|
||||||
|
FlatCAMApp.App.log.debug("on_item_changed(): " + str(item.row()) + " " + self.object_list[item.row()].options["name"])
|
||||||
|
if item.checkState() == QtCore.Qt.Checked:
|
||||||
|
self.object_list[item.row()].options["plot"] = True #(item.checkState() == QtCore.Qt.Checked)
|
||||||
|
else:
|
||||||
|
self.object_list[item.row()].options["plot"] = False #(item.checkState() == QtCore.Qt.Checked)
|
||||||
|
|
||||||
|
self.object_list[item.row()].plot()
|
||||||
|
return
|
||||||
|
|
||||||
def on_item_activated(self, index):
|
def on_item_activated(self, index):
|
||||||
"""
|
"""
|
||||||
Double-click or Enter on item.
|
Double-click or Enter on item.
|
||||||
@@ -301,12 +346,13 @@ class ObjectCollection(QtCore.QAbstractListModel):
|
|||||||
def delete_all(self):
|
def delete_all(self):
|
||||||
FlatCAMApp.App.log.debug(str(inspect.stack()[1][3]) + "--> OC.delete_all()")
|
FlatCAMApp.App.log.debug(str(inspect.stack()[1][3]) + "--> OC.delete_all()")
|
||||||
|
|
||||||
self.beginResetModel()
|
# self.beginResetModel()
|
||||||
|
|
||||||
|
self.model.removeRows(0, self.model.rowCount())
|
||||||
self.object_list = []
|
self.object_list = []
|
||||||
self.checked_indexes = []
|
self.checked_indexes = []
|
||||||
|
|
||||||
self.endResetModel()
|
# self.endResetModel()
|
||||||
|
|
||||||
def get_list(self):
|
def get_list(self):
|
||||||
return self.object_list
|
return self.object_list
|
||||||
|
|||||||
Reference in New Issue
Block a user