def __init__( self, parent ): Qt.QWidget.__init__( self, parent ) # Actions # Actions.createGraphEditorActions( self ) # Menus # #menuBar = Qt.QMenuBar( self ) # #fileMenu = menuBar.addMenu( 'File' ) #viewMenu = menuBar.addMenu( 'View' ) # #fileMenu.addAction( Actions.graphEditor.loadDynamicNode ) #viewMenu.addAction( Actions.graphEditor.frameAll ) # Graph editor # graphEditor = Cellule.appli.createGraphEditor( Cellule.fromSIP( self ) ) graphEditorSIP = Cellule.toSIP( graphEditor, Qt.QWidget ) # Layout # layout = Qt.QVBoxLayout( self ) #layout.addWidget( menuBar ) layout.addWidget( graphEditorSIP )
def openScene(): mainWinSIP = Cellule.toSIP( Cellule.appli.mainWin, Qt.QMainWindow ) fileName = Qt.QFileDialog.getOpenFileName( mainWinSIP, 'Open Scene', '', 'Cellule scenes (*.cel)' ) if not fileName.isEmpty(): Cellule.appli.scene.load( Cellule.fromSIP( fileName ) )
def loadDynamicNode(): mainWinSIP = Cellule.toSIP( Cellule.appli.mainWin, Qt.QMainWindow ) fileName = Qt.QFileDialog.getOpenFileName( mainWinSIP, 'Load dynamic node', '', 'Dynamic nodes (*.cpp)' ) if not fileName.isEmpty(): Cellule.appli.scene.loadDynamicNode( Cellule.fromSIP( fileName ) )
def saveImageAs( view2D ): mainWinSIP = Cellule.toSIP( Cellule.appli.mainWin, Qt.QMainWindow ) fileName = Qt.QFileDialog.getSaveFileName( mainWinSIP, 'Save Rendered Image', '', 'Image files(*.png *.tiff *.bmp)' ) if not fileName.isEmpty(): view2D.renderArea.saveAs( Cellule.fromSIP( fileName ) )
def saveSceneAs(): mainWinSIP = Cellule.toSIP( Cellule.appli.mainWin, Qt.QMainWindow ) fileName = Qt.QFileDialog.getSaveFileName( mainWinSIP, 'Save Scene', '', 'Cellule scenes (*.cel)' ) if not fileName.isEmpty(): Cellule.appli.scene.saveAs( Cellule.fromSIP( fileName ) )
def __init__( self, parent ): # Create an input command line and an output line # separated by an adjustable splitter # Qt.QSplitter.__init__( self, parent ) inputLine = Qt.QLineEdit( self ) outputLine = Qt.QLineEdit( self ) # Configure the widgets # self.setSizePolicy( Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Fixed ) inputLine.palette().setColor( Qt.QPalette.Base, Qt.QColor( 200, 200, 200 ) ) inputLine.palette().setColor( Qt.QPalette.Text, Qt.QColor( 0, 0, 0 ) ) outputLine.setReadOnly( True ) # Signals / Slots # logSIP = Cellule.toSIP( Cellule.appli.log ) Qt.QObject.connect( logSIP, Qt.SIGNAL( 'textAdded(const QString&)' ), outputLine, Qt.SLOT( 'setText(const QString&)' ) )
def __init__(self, parent): Qt.QWidget.__init__(self, parent) menuBar = Qt.QMenuBar(self) # Display menu # displayMenu = menuBar.addMenu("Display") displayLevelGroup = Qt.QActionGroup(displayMenu) displayLevelPointAction = Qt.QAction("Point", displayLevelGroup) displayLevelWireframeAction = Qt.QAction("Wireframe", displayLevelGroup) displayLevelBSplineAction = Qt.QAction("BSpline", displayLevelGroup) displayLevelShadedAction = Qt.QAction("Shaded", displayLevelGroup) displayLevelPointAction.setCheckable(True) displayLevelWireframeAction.setCheckable(True) displayLevelBSplineAction.setCheckable(True) displayLevelShadedAction.setCheckable(True) displayLevelShadedAction.setChecked(True) showSeedsAction = Qt.QAction("Show seeds", displayMenu) showDelauneyAction = Qt.QAction("Show Delauney", displayMenu) showSeedsAction.setCheckable(True) showDelauneyAction.setCheckable(True) displayMenu.addAction(displayLevelPointAction) displayMenu.addAction(displayLevelWireframeAction) displayMenu.addAction(displayLevelBSplineAction) displayMenu.addAction(displayLevelShadedAction) displayMenu.addAction(showSeedsAction) displayMenu.addAction(showDelauneyAction) # Render menu # renderMenu = menuBar.addMenu("Render") showRenderSettingsAction = Qt.QAction("Settings...", renderMenu) saveRenderedImageAsAction = Qt.QAction("Save image as...", renderMenu) # renderMenu.addAction( showRenderSettingsAction ) renderMenu.addAction(saveRenderedImageAsAction) # 2D View # self.view2D = Cellule.appli.createView2D(Cellule.fromSIP(self)) view2DSIP = Cellule.toSIP(self.view2D, Qt.QWidget) # Layout # layout = Qt.QVBoxLayout(self) layout.addWidget(menuBar) layout.addWidget(view2DSIP) # Signals / Slots # Qt.QObject.connect(displayLevelPointAction, Qt.SIGNAL("triggered()"), self.view2D.setDisplayLevelPoint) Qt.QObject.connect(displayLevelWireframeAction, Qt.SIGNAL("triggered()"), self.view2D.setDisplayLevelWireframe) Qt.QObject.connect(displayLevelShadedAction, Qt.SIGNAL("triggered()"), self.view2D.setDisplayLevelShaded) Qt.QObject.connect(displayLevelBSplineAction, Qt.SIGNAL("triggered()"), self.view2D.setDisplayLevelBSpline) Qt.QObject.connect(showSeedsAction, Qt.SIGNAL("toggled(bool)"), self.view2D.displaySeeds) Qt.QObject.connect(showDelauneyAction, Qt.SIGNAL("toggled(bool)"), self.view2D.displayDelauney) Qt.QObject.connect(showRenderSettingsAction, Qt.SIGNAL("triggered()"), self.showRenderSettings) Qt.QObject.connect(saveRenderedImageAsAction, Qt.SIGNAL("triggered()"), self.saveRenderedImageAs)
def __init__( self, parent ): Qt.QWidget.__init__( self, parent ) # Menus # menuBar = Qt.QMenuBar( self ) fileMenu = menuBar.addMenu( 'File' ) editMenu = menuBar.addMenu( 'Edit' ) optionsMenu = menuBar.addMenu( 'Options' ) openScriptAction = fileMenu .addAction( 'Open script...' ) saveScriptAction = fileMenu .addAction( 'Save script as...' ) executeAction = editMenu .addAction( 'Execute' ) clearOutputAction = editMenu .addAction( 'Clear output' ) clearInputAction = editMenu .addAction( 'Clear input' ) clearAllAction = editMenu .addAction( 'Clear all' ) self.showStackTrace = optionsMenu.addAction( 'Show stack trace' ) self.showStackTrace.setCheckable( True ) self.showStackTrace.setChecked ( False ) openScriptAction .setIcon ( Qt.QIcon( 'icons/16x16/document-open.png' ) ) saveScriptAction .setIcon ( Qt.QIcon( 'icons/16x16/document-save-as.png' ) ) executeAction .setIcon ( Qt.QIcon( 'icons/16x16/go-jump-locationbar.png' ) ) clearOutputAction .setIcon ( Qt.QIcon( 'icons/16x16/edit-clear-locationbar-ltr.png' ) ) clearInputAction .setIcon ( Qt.QIcon( 'icons/16x16/edit-clear-locationbar-rtl.png' ) ) clearAllAction .setIcon ( Qt.QIcon( 'icons/16x16/trash-empty.png' ) ) openScriptAction .setStatusTip( 'Load a script file into the console' ) saveScriptAction .setStatusTip( 'Save the console input to a file' ) executeAction .setStatusTip( 'Execute console input selected code ( whole if no selection )' ) clearOutputAction .setStatusTip( 'Clear console output' ) clearInputAction .setStatusTip( 'Clear console input' ) clearAllAction .setStatusTip( 'Clear console input and output' ) self.showStackTrace.setStatusTip( 'Detail error location when printing error messages' ) executeAction .setShortcut ( Qt.QKeySequence( 'Ctrl+Return' ) ) # Output and Input # splitter = Qt.QSplitter( Qt.Qt.Vertical, self ) self.output = Qt.QTextEdit( splitter ) self.input = InputWidget ( splitter ) self.output.setReadOnly ( True ) self.input.setAcceptRichText( False ) # Layout # layout = Qt.QVBoxLayout( self ) layout.addWidget( menuBar ) layout.addWidget( splitter ) # Signal / Slots # logSIP = Cellule.toSIP( Cellule.appli.log ) scriptEngineSIP = Cellule.toSIP( Cellule.appli.scriptEngine ) Qt.QObject.connect( openScriptAction, Qt.SIGNAL( 'triggered()' ), self.openScript ) Qt.QObject.connect( saveScriptAction, Qt.SIGNAL( 'triggered()' ), self.saveScript ) Qt.QObject.connect( executeAction, Qt.SIGNAL( 'triggered()' ), self.input.requestExecution ) Qt.QObject.connect( clearOutputAction, Qt.SIGNAL( 'triggered()' ), self.output, Qt.SLOT( 'clear()' ) ) Qt.QObject.connect( clearInputAction, Qt.SIGNAL( 'triggered()' ), self.input, Qt.SLOT( 'clear()' ) ) Qt.QObject.connect( clearAllAction, Qt.SIGNAL( 'triggered()' ), self.output, Qt.SLOT( 'clear()' ) ) Qt.QObject.connect( clearAllAction, Qt.SIGNAL( 'triggered()' ), self.input, Qt.SLOT( 'clear()' ) ) Qt.QObject.connect( logSIP, Qt.SIGNAL( 'htmlAdded(const QString&)' ), self.output, Qt.SLOT( 'append(const QString&)' ) ) Qt.QObject.connect( self.input, Qt.SIGNAL( 'executionRequested' ), self.execute )
import Cellule import Actions import MainMenuBar import MainToolBar import View2D import GraphEditor import Console import CommandLine from PyQt4 import Qt # Get application main window as a SIP object # mainWinSIP = Cellule.toSIP( Cellule.appli.mainWin, Qt.QMainWindow ) Actions.createMainWindowActions( mainWinSIP ) # Create menus # mainMenuBar = MainMenuBar.Widget( mainWinSIP ) mainWinSIP.setMenuBar( mainMenuBar ) # Create main toolbar # MainToolBar.init( mainWinSIP ) # Create 2D view # view2D = View2D.Widget( mainWinSIP )