def runAndGetCellEvents(self, useDefaultValues=False): spreadsheetController.setEchoMode(True) # will run to get Spreadsheet Cell events cellEvents = [] errors = [] try: (res, errors) = self.run(useDefaultValues) if res: cellEvents = spreadsheetController.getEchoCellEvents() except Exception, e: debug.unexpected_exception(e) print "Executing pipeline failed:", debug.format_exc()
def runAndGetCellEvents(self, useDefaultValues=False): spreadsheetController.setEchoMode(True) #will run to get Spreadsheet Cell events cellEvents = [] errors = [] try: (res, errors) = self.run(useDefaultValues) if res: cellEvents = spreadsheetController.getEchoCellEvents() except Exception, e: debug.unexpected_exception(e) print "Executing pipeline failed:", debug.format_exc()
def __init__(self, parent=None, vistrail_view=None, dumpcells=False, controller=None, version=-1): """ QMashupAppMainWindow() Initialize an app window from a mashup. """ # Constructing the main widget QtGui.QMainWindow.__init__(self, parent) self.vtkCells = [] self.setStatusBar(QtGui.QStatusBar(self)) # Central widget centralWidget = QtGui.QWidget() self.mainLayout = QtGui.QVBoxLayout() self.mainLayout.setMargin(0) self.mainLayout.setSpacing(5) centralWidget.setLayout(self.mainLayout) self.setCentralWidget(centralWidget) self.numberOfCells = 0 self.is_executing = False self.sequenceOption = False self.steps = [] self.isLooping = False # self.resize(100,100) self.dumpcells = dumpcells self.view = vistrail_view if controller: self.controller = controller self.mshptrail = controller.mshptrail if version == -1: self.currentMashup = self.controller.currentMashup else: self.currentMashup = self.mshptrail.getMashup(version) self.setWindowTitle("%s Mashup" % self.controller.getMashupName(version)) else: self.setWindowTitle("Mashup") # Assign "hidden" shortcut self.editingModeAct = QtGui.QAction( "Chang&e Layout", self, shortcut="Ctrl+E", statusTip="Change the layout of the widgets", triggered=self.toggleEditingMode, ) # self.editingModeShortcut = QtGui.QShortcut(QtGui.QKeySequence('Ctrl+E'), self) # self.connect(self.editingModeShortcut, QtCore.SIGNAL('activated()'), # self.toggleEditingMode) self.editing = False # Constructing alias controls self.controlDocks = [] # Show here to make sure XDisplay info is correct (for VTKCell) self.show() spreadsheetController.setEchoMode(True) # will run to get Spreadsheet Cell events (cellEvents, errors) = self.runAndGetCellEvents(useDefaultValues=True) if cellEvents: self.numberOfCells = len(cellEvents) self.initCells(cellEvents) if len(errors) > 0: show_warning("VisTrails::Mashup Preview", "There was a problem executing the pipeline: %s." % errors) # Construct the controllers for aliases self.controlDocks = {} self.cellControls = {} self.aliasWidgets = {} self.initControls() if self.currentMashup.layout is not None: self.restoreState(QtCore.QByteArray.fromPercentEncoding(QtCore.QByteArray(self.currentMashup.layout))) if self.currentMashup.geometry is not None: self.restoreGeometry(QtCore.QByteArray.fromPercentEncoding(QtCore.QByteArray(self.currentMashup.geometry))) else: self.resize(self.sizeHint()) # Constructing buttons buttonDock = QCustomDockWidget("Control Buttons", self) buttonWidget = QtGui.QWidget(buttonDock) buttonWidget.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) buttonLayout = QtGui.QGridLayout() buttonWidget.setLayout(buttonLayout) buttonLayout.setMargin(5) self.cb_auto_update = QtGui.QCheckBox("Turn on auto-update", self.centralWidget()) self.cb_auto_update.setChecked(False) self.cb_loop_sequence = QtGui.QCheckBox( "Render all steps in '%s'" % (self.sequenceOption.alias.name if self.sequenceOption else "None"), self.centralWidget(), ) self.cb_loop_sequence.setChecked(False) self.cb_loop_sequence.setVisible(self.sequenceOption is not False) self.cb_loop_sequence.setToolTip("Render each step of this stepper for fast switching") self.cb_loop_int = QtGui.QCheckBox("Interactive Steps", self.centralWidget()) self.cb_loop_int.setChecked(False) self.cb_loop_int.setVisible(False) self.cb_loop_int.setToolTip("Show complete result of each step instead of static images") self.cb_loop_sequence.clicked.connect(self.cb_loop_int.setVisible) self.cb_keep_camera = QtGui.QCheckBox("Keep camera position", self.centralWidget()) self.cb_keep_camera.setChecked(True) self.connect(self.cb_auto_update, QtCore.SIGNAL("stateChanged(int)"), self.auto_update_changed) self.connect(self.cb_loop_int, QtCore.SIGNAL("stateChanged(int)"), self.loop_int_changed) self.loopButton = QtGui.QPushButton("&Loop", self.centralWidget()) self.loopButton.setToolTip("Loop automatically through steps") self.loopButton.setCheckable(True) self.loopButton.setVisible(self.sequenceOption is not False) self.updateButton = QtGui.QPushButton("&Update", self.centralWidget()) if self.dumpcells: self.quitButton = QtGui.QPushButton("&Save", self.centralWidget()) self.connect(self.quitButton, QtCore.SIGNAL("clicked(bool)"), self.saveAndExport) else: self.quitButton = QtGui.QPushButton("&Quit", self.centralWidget()) self.connect(self.quitButton, QtCore.SIGNAL("clicked(bool)"), self.close) buttonLayout.setColumnStretch(0, 1) if self.sequenceOption: sequenceLayout = QtGui.QHBoxLayout() sequenceLayout.setMargin(5) sequenceLayout.addWidget(self.cb_loop_int) sequenceLayout.addWidget(self.cb_loop_sequence) buttonLayout.addLayout(sequenceLayout, 0, 0, QtCore.Qt.AlignRight) buttonLayout.addWidget(self.cb_auto_update, 0, 1, QtCore.Qt.AlignLeft) buttonLayout.addWidget(self.cb_keep_camera, 0, 2, 1, 2, QtCore.Qt.AlignLeft) if self.sequenceOption: buttonLayout.addWidget(self.loopButton, 1, 1, QtCore.Qt.AlignRight) self.loopButton.setEnabled(False) buttonLayout.addWidget(self.updateButton, 1, 2, QtCore.Qt.AlignRight) buttonLayout.addWidget(self.quitButton, 1, 3, QtCore.Qt.AlignRight) self.connect(self.updateButton, QtCore.SIGNAL("clicked(bool)"), self.updateButtonClick) if self.sequenceOption: self.connect(self.loopButton, QtCore.SIGNAL("clicked(bool)"), self.loopButtonClick) buttonDock.setWidget(buttonWidget) self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, buttonDock) self.controlDocks["__buttons__"] = buttonDock self.saveAllAct = QtGui.QAction( "S&ave Combined", self, shortcut=QtGui.QKeySequence.SelectAll, statusTip="Save combined images to disk", triggered=self.saveAllEvent, ) self.saveAct = QtGui.QAction( "&Save Each", self, shortcut=QtGui.QKeySequence.Save, statusTip="Save separate images to disk", triggered=self.saveEventAction, ) self.showBuilderAct = QtGui.QAction( "VisTrails Main Window", self, statusTip="Show VisTrails Main Window", triggered=self.showBuilderWindow ) self.createMenus() self.lastExportPath = ""
self.windowMenu.addAction(self.showBuilderAct) def runAndGetCellEvents(self, useDefaultValues=False): spreadsheetController.setEchoMode(True) # will run to get Spreadsheet Cell events cellEvents = [] errors = [] try: (res, errors) = self.run(useDefaultValues) if res: cellEvents = spreadsheetController.getEchoCellEvents() except Exception, e: debug.unexpected_exception(e) print "Executing pipeline failed:", debug.format_exc() finally: spreadsheetController.setEchoMode(False) return (cellEvents, errors) def updateCells(self, info=None): # check if we should create a sequence if self.cb_loop_sequence.isChecked(): return self.updateCellsLoop(info) self.is_executing = True (cellEvents, errors) = self.runAndGetCellEvents() self.is_executing = False if len(cellEvents) != self.numberOfCells: raise RuntimeError( "The number of cells has changed (unexpectedly) " "(%d vs. %d)!\n" "Pipeline results: %s" % (len(cellEvents), self.numberOfCells, errors)
def __init__(self, parent=None, vistrail_view=None, dumpcells=False, controller=None, version=-1): """ QMashupAppMainWindow() Initialize an app window from a mashup. """ # Constructing the main widget QtGui.QMainWindow.__init__(self, parent) self.vtkCells = [] self.setStatusBar(QtGui.QStatusBar(self)) # Central widget centralWidget = QtGui.QWidget() self.mainLayout = QtGui.QVBoxLayout() self.mainLayout.setMargin(0) self.mainLayout.setSpacing(5) centralWidget.setLayout(self.mainLayout) self.setCentralWidget(centralWidget) self.numberOfCells = 0 self.is_executing = False self.sequenceOption = False self.steps = [] self.isLooping = False #self.resize(100,100) self.dumpcells = dumpcells self.view = vistrail_view if controller: self.controller = controller self.mshptrail = controller.mshptrail if version == -1: self.currentMashup = self.controller.currentMashup else: self.currentMashup = self.mshptrail.getMashup(version) self.setWindowTitle('%s Mashup' % self.controller.getMashupName(version)) else: self.setWindowTitle('Mashup') # Assign "hidden" shortcut self.editingModeAct = QtGui.QAction( "Chang&e Layout", self, shortcut="Ctrl+E", statusTip="Change the layout of the widgets", triggered=self.toggleEditingMode) #self.editingModeShortcut = QtGui.QShortcut(QtGui.QKeySequence('Ctrl+E'), self) #self.connect(self.editingModeShortcut, QtCore.SIGNAL('activated()'), # self.toggleEditingMode) self.editing = False # Constructing alias controls self.controlDocks = [] # Show here to make sure XDisplay info is correct (for VTKCell) self.show() spreadsheetController.setEchoMode(True) #will run to get Spreadsheet Cell events (cellEvents, errors) = self.runAndGetCellEvents(useDefaultValues=True) if cellEvents: self.numberOfCells = len(cellEvents) self.initCells(cellEvents) if len(errors) > 0: show_warning( "VisTrails::Mashup Preview", "There was a problem executing the pipeline: %s." % errors) # Construct the controllers for aliases self.controlDocks = {} self.cellControls = {} self.aliasWidgets = {} self.initControls() if self.currentMashup.layout is not None: self.restoreState( QtCore.QByteArray.fromPercentEncoding( QtCore.QByteArray(self.currentMashup.layout))) if self.currentMashup.geometry is not None: self.restoreGeometry( QtCore.QByteArray.fromPercentEncoding( QtCore.QByteArray(self.currentMashup.geometry))) else: self.resize(self.sizeHint()) # Constructing buttons buttonDock = QCustomDockWidget('Control Buttons', self) buttonWidget = QtGui.QWidget(buttonDock) buttonWidget.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) buttonLayout = QtGui.QGridLayout() buttonWidget.setLayout(buttonLayout) buttonLayout.setMargin(5) self.cb_auto_update = QtGui.QCheckBox("Turn on auto-update", self.centralWidget()) self.cb_auto_update.setChecked(False) self.cb_loop_sequence = QtGui.QCheckBox("Render all steps in '%s'" % \ (self.sequenceOption.alias.name if self.sequenceOption else 'None'), self.centralWidget()) self.cb_loop_sequence.setChecked(False) self.cb_loop_sequence.setVisible(self.sequenceOption is not False) self.cb_loop_sequence.setToolTip( "Render each step of this stepper for fast switching") self.cb_loop_int = QtGui.QCheckBox("Interactive Steps", self.centralWidget()) self.cb_loop_int.setChecked(False) self.cb_loop_int.setVisible(False) self.cb_loop_int.setToolTip( "Show complete result of each step instead of static images") self.cb_loop_sequence.clicked.connect(self.cb_loop_int.setVisible) self.cb_keep_camera = QtGui.QCheckBox("Keep camera position", self.centralWidget()) self.cb_keep_camera.setChecked(True) self.connect(self.cb_auto_update, QtCore.SIGNAL("stateChanged(int)"), self.auto_update_changed) self.connect(self.cb_loop_int, QtCore.SIGNAL("stateChanged(int)"), self.loop_int_changed) self.loopButton = QtGui.QPushButton("&Loop", self.centralWidget()) self.loopButton.setToolTip("Loop automatically through steps") self.loopButton.setCheckable(True) self.loopButton.setVisible(self.sequenceOption is not False) self.updateButton = QtGui.QPushButton("&Update", self.centralWidget()) if self.dumpcells: self.quitButton = QtGui.QPushButton("&Save", self.centralWidget()) self.connect(self.quitButton, QtCore.SIGNAL('clicked(bool)'), self.saveAndExport) else: self.quitButton = QtGui.QPushButton("&Quit", self.centralWidget()) self.connect(self.quitButton, QtCore.SIGNAL('clicked(bool)'), self.close) buttonLayout.setColumnStretch(0, 1) if self.sequenceOption: sequenceLayout = QtGui.QHBoxLayout() sequenceLayout.setMargin(5) sequenceLayout.addWidget(self.cb_loop_int) sequenceLayout.addWidget(self.cb_loop_sequence) buttonLayout.addLayout(sequenceLayout, 0, 0, QtCore.Qt.AlignRight) buttonLayout.addWidget(self.cb_auto_update, 0, 1, QtCore.Qt.AlignLeft) buttonLayout.addWidget(self.cb_keep_camera, 0, 2, 1, 2, QtCore.Qt.AlignLeft) if self.sequenceOption: buttonLayout.addWidget(self.loopButton, 1, 1, QtCore.Qt.AlignRight) self.loopButton.setEnabled(False) buttonLayout.addWidget(self.updateButton, 1, 2, QtCore.Qt.AlignRight) buttonLayout.addWidget(self.quitButton, 1, 3, QtCore.Qt.AlignRight) self.connect(self.updateButton, QtCore.SIGNAL('clicked(bool)'), self.updateButtonClick) if self.sequenceOption: self.connect(self.loopButton, QtCore.SIGNAL('clicked(bool)'), self.loopButtonClick) buttonDock.setWidget(buttonWidget) self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, buttonDock) self.controlDocks["__buttons__"] = buttonDock self.saveAllAct = QtGui.QAction( "S&ave Combined", self, shortcut=QtGui.QKeySequence.SelectAll, statusTip="Save combined images to disk", triggered=self.saveAllEvent) self.saveAct = QtGui.QAction("&Save Each", self, shortcut=QtGui.QKeySequence.Save, statusTip="Save separate images to disk", triggered=self.saveEventAction) self.showBuilderAct = QtGui.QAction( "VisTrails Main Window", self, statusTip="Show VisTrails Main Window", triggered=self.showBuilderWindow) self.createMenus() self.lastExportPath = ''
self.windowMenu.addAction(self.showBuilderAct) def runAndGetCellEvents(self, useDefaultValues=False): spreadsheetController.setEchoMode(True) #will run to get Spreadsheet Cell events cellEvents = [] errors = [] try: (res, errors) = self.run(useDefaultValues) if res: cellEvents = spreadsheetController.getEchoCellEvents() except Exception, e: debug.unexpected_exception(e) print "Executing pipeline failed:", debug.format_exc() finally: spreadsheetController.setEchoMode(False) return (cellEvents, errors) def updateCells(self, info=None): # check if we should create a sequence if self.cb_loop_sequence.isChecked(): return self.updateCellsLoop(info) self.is_executing = True (cellEvents, errors) = self.runAndGetCellEvents() self.is_executing = False if len(cellEvents) != self.numberOfCells: raise RuntimeError( "The number of cells has changed (unexpectedly) " "(%d vs. %d)!\n" "Pipeline results: %s" %