class TransformationHistoryWidget(QWidget): """ TransformationHistoryWidget shows a list of applied transformations. """ def __init__(self): super(TransformationHistoryWidget, self).__init__() self.actionContainer = ButtonContainer() self.transformationModel = TransformationModel() self.transformationView = TransformationListView() self.transformationView.setRootIsDecorated(False) self.transformationView.setModel(self.transformationModel) layout = QVBoxLayout() layout.setSpacing(0) layout.setAlignment(Qt.AlignTop) layout.addWidget(self.transformationView) layout.addWidget(self.actionContainer) self.setLayout(layout) removeButton = QPushButton() removeButton.setIcon(QIcon(AppVars.imagePath() + "RemoveButton.png")) removeButton.clicked.connect(self.removeButtonClicked) self.actionContainer.addButton(removeButton) def setMultiRenderWidget(self, widget): self.renderWidget = widget self.renderWidget.transformations.transformationChanged.connect(self.updateTransformations) def updateTransformations(self, transformations): self.transformationModel.setTransformations(transformations) def removeButtonClicked(self): self.transformationView.removeSelectedRow()
class ParameterWidget(QWidget): """ Widget that displays parameters. Holds buttons for acting on the parameters. """ def __init__(self): super(ParameterWidget, self).__init__() self.initUI() def initUI(self): # Create container for action buttons self.actionContainer = ButtonContainer() self.parameterModel = ParameterModel() self.parameterView = ParameterListView() self.parameterView.setAttribute(Qt.WA_MacShowFocusRect, False) self.parameterView.setRootIsDecorated(False) self.parameterView.setModel(self.parameterModel) # Create a main layout (vertical) for this widget self.layout = QVBoxLayout() self.layout.setSpacing(0) self.layout.setContentsMargins(0, 0, 0, 0) self.layout.addWidget(self.parameterView) self.layout.addWidget(self.actionContainer) self.setLayout(self.layout) # Add a button to the container addButton = QPushButton() addButton.setIcon(QIcon(AppVars.imagePath() + "AddButton.png")) addButton.clicked.connect(self.addButtonClicked) self.actionContainer.addButton(addButton) removeButton = QPushButton() removeButton.setIcon(QIcon(AppVars.imagePath() + "RemoveButton.png")) removeButton.clicked.connect(self.removeButtonClicked) self.actionContainer.addButton(removeButton) def addButtonClicked(self): self.parameterView.addParameter() def removeButtonClicked(self): self.parameterView.removeSelectedParameter()
class TransformationHistoryWidget(QWidget): """ TransformationHistoryWidget shows a list of applied transformations. """ def __init__(self): super(TransformationHistoryWidget, self).__init__() self.actionContainer = ButtonContainer() self.transformationModel = TransformationModel() self.transformationView = TransformationListView() self.transformationView.setRootIsDecorated(False) self.transformationView.setModel(self.transformationModel) self.transformationView.setAttribute(Qt.WA_MacShowFocusRect, False) self.transformationView.clicked.connect(self.clickedTransformation) self._transformCount = 0 layout = QVBoxLayout() layout.setSpacing(0) layout.setAlignment(Qt.AlignTop) layout.addWidget(self.transformationView) layout.addWidget(self.actionContainer) self.setLayout(layout) removeButton = QPushButton() removeButton.setIcon(QIcon(AppVars.imagePath() + "RemoveButton.png")) removeButton.clicked.connect(self.removeButtonClicked) removeButton.setToolTip("Remove the last transformation") self.actionContainer.addButton(removeButton) def setMultiRenderWidget(self, widget): self.renderWidget = widget self.renderWidget.transformations.transformationChanged.connect(self.updateTransformations) def updateTransformations(self, transformations): """ Update the model. If the number of transformations is bigger than last time: clear the selection. """ if len(transformations) > self._transformCount: self.transformationView.clearSelection() self._transformCount = len(transformations) self.transformationModel.setTransformations(transformations) def removeButtonClicked(self): """ Remove the last transformation in the list. """ messageBox = QMessageBox() messageBox.setText("The last transformation is about to be removed.") messageBox.setInformativeText("Do you want to proceed?") messageBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) messageBox.setDefaultButton(QMessageBox.Ok) res = messageBox.exec_() if res == QMessageBox.Ok: self.transformationView.removeLastRow() def clickedTransformation(self, index): """ Activate the transformation from the complete list. """ self.renderWidget.transformations.activateTransformationAtIndex(index.row())
class TransformationHistoryWidget(QWidget): """ TransformationHistoryWidget shows a list of applied transformations. """ def __init__(self): super(TransformationHistoryWidget, self).__init__() self.actionContainer = ButtonContainer() self.transformationModel = TransformationModel() self.transformationView = TransformationListView() self.transformationView.setRootIsDecorated(False) self.transformationView.setModel(self.transformationModel) self.transformationView.setAttribute(Qt.WA_MacShowFocusRect, False) self.transformationView.clicked.connect(self.clickedTransformation) self._transformCount = 0 layout = QVBoxLayout() layout.setSpacing(0) layout.setAlignment(Qt.AlignTop) layout.addWidget(self.transformationView) layout.addWidget(self.actionContainer) self.setLayout(layout) removeButton = QPushButton() removeButton.setIcon(QIcon(AppVars.imagePath() + "RemoveButton.png")) removeButton.clicked.connect(self.removeButtonClicked) removeButton.setToolTip("Remove the last transformation") self.actionContainer.addButton(removeButton) def setMultiRenderWidget(self, widget): self.renderWidget = widget self.renderWidget.transformations.transformationChanged.connect( self.updateTransformations) def updateTransformations(self, transformations): """ Update the model. If the number of transformations is bigger than last time: clear the selection. """ if len(transformations) > self._transformCount: self.transformationView.clearSelection() self._transformCount = len(transformations) self.transformationModel.setTransformations(transformations) def removeButtonClicked(self): """ Remove the last transformation in the list. """ messageBox = QMessageBox() messageBox.setText("The last transformation is about to be removed.") messageBox.setInformativeText("Do you want to proceed?") messageBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) messageBox.setDefaultButton(QMessageBox.Ok) res = messageBox.exec_() if res == QMessageBox.Ok: self.transformationView.removeLastRow() def clickedTransformation(self, index): """ Activate the transformation from the complete list. """ self.renderWidget.transformations.activateTransformationAtIndex( index.row())