def __loadAllShots(self): if ProjectFile() is None: self.setEnabled(False) return self.setEnabled(True) self.__model.clear() # model.clear() removes the header labels self.__model.setHorizontalHeaderLabels(['Name', 'Scene', 'Start', 'End', 'Duration', 'Speed', 'Preroll']) for sceneName in Scenes(): sceneName = os.path.splitext(sceneName)[0] for shot in _deserializeSceneShots(sceneName): self.__model.appendRow(shot.items) self.__table.sortByColumn(2, Qt.AscendingOrder)
def createShot(self, initialSceneName=None): sceneNames = [str(os.path.splitext(scene)[0]) for scene in Scenes()] if not sceneNames: QMessageBox.warning( self, 'Can\'t create shot!', 'Can not create shots before creating at least 1 scene.') return diag = QDialog(self) layout = vlayout() diag.setLayout(layout) diag.setWindowTitle('Create shot') layout.addWidget(QLabel('Name:')) name = QLineEdit(initialSceneName or '') layout.addWidget(name) layout.addWidget(QLabel('Scene:')) scenes = QComboBox() scenes.addItems(sceneNames) scenes.setEditable(False) layout.addWidget(scenes) create = QPushButton('Create') create.clicked.connect(diag.accept) cancel = QPushButton('Cancel') cancel.clicked.connect(diag.reject) buttonBar = hlayout() buttonBar.addStretch(1) buttonBar.addWidget(create) buttonBar.addWidget(cancel) layout.addLayout(buttonBar) if initialSceneName and str(initialSceneName) in sceneNames: scenes.setCurrentIndex(sceneNames.index(initialSceneName)) else: scenes.setCurrentIndex(0) diag.exec_() if diag.result() != QDialog.Accepted: return if not name.text(): QMessageBox.Warning(self, 'Could not create shot', 'Please enter a name.') return start = 0.0 selected = list(self.__selectedShots()) if selected: start = selected[-1].start curves = OrderedDict() curves['uOrigin.x'] = Curve() curves['uOrigin.y'] = Curve() curves['uOrigin.z'] = Curve() curves['uAngles.x'] = Curve() curves['uAngles.y'] = Curve() curves['uAngles.z'] = Curve() # TODO use scenes.currentText() to find the scene object & query it's programs for available uniforms # TODO add an exclusion mechanism for uniforms controlled by animationprocessor.py shot = Shot(name.text(), scenes.currentText(), start, start + 8.0, curves) self.__model.appendRow(shot.items)
def saveAllShots(self): for sceneName in Scenes(): sceneName = os.path.splitext(sceneName)[0] _saveSceneShots(sceneName, self.shots())
def createShot(self, initialSceneName=None): sceneNames = [str(os.path.splitext(scene)[0]) for scene in Scenes()] if not sceneNames: QMessageBox.warning( self, 'Can\'t create shot!', 'Can not create shots before creating at least 1 scene.') return diag = QDialog(self) layout = vlayout() diag.setLayout(layout) diag.setWindowTitle('Create shot') layout.addWidget(QLabel('Name:')) name = QLineEdit(initialSceneName or '') layout.addWidget(name) layout.addWidget(QLabel('Scene:')) scenes = QComboBox() scenes.addItems(sceneNames) scenes.setEditable(False) layout.addWidget(scenes) channelTemplates = readChannelTemplates() channelTemplateNames = channelTemplates.keys() templateIndex = 0 if 'default' in channelTemplateNames: channelTemplateNames.index('default') channelTemplateSelector = None if len(channelTemplateNames) > 1: layout.addWidget(QLabel('Channels:')) channelTemplateSelector = QComboBox() channelTemplateSelector.addItems(channelTemplateNames) channelTemplateSelector.setEditable(False) layout.addWidget(scenes) create = QPushButton('Create') create.clicked.connect(diag.accept) cancel = QPushButton('Cancel') cancel.clicked.connect(diag.reject) buttonBar = hlayout() buttonBar.addStretch(1) buttonBar.addWidget(create) buttonBar.addWidget(cancel) layout.addLayout(buttonBar) if initialSceneName and str(initialSceneName) in sceneNames: scenes.setCurrentIndex(sceneNames.index(initialSceneName)) # if there is a channel template for this scene, default to it if initialSceneName in channelTemplateNames: templateIndex = channelTemplateNames.index(initialSceneName) else: scenes.setCurrentIndex(0) if channelTemplateSelector is not None: channelTemplateSelector.setCurrentIndex(templateIndex) diag.exec_() if diag.result() != QDialog.Accepted: return if not name.text(): QMessageBox.Warning(self, 'Could not create shot', 'Please enter a name.') return start = 0.0 selected = list(self.__selectedShots()) if selected: start = selected[-1].start if channelTemplateSelector is not None: channelTemplateName = channelTemplateSelector.currentText() curves = channelTemplates[channelTemplateName] else: curves = channelTemplates.values()[0] shot = Shot(name.text(), scenes.currentText(), start, start + 8.0, curves) self.__model.appendRow(shot.items)