From 727c57ccf35039d2026252f035f0120c29b5f3d0 Mon Sep 17 00:00:00 2001 From: ymesh Date: Wed, 23 Sep 2015 21:16:17 +0300 Subject: [PATCH 1/6] Initial commit with PyQt5 compatibility --- core/meCommon.py | 428 ++--- core/mePyQt.py | 65 + core/meRendererPreset.py | 8 +- core/node.py | 4 +- core/nodeLibrary.py | 214 ++- core/nodeLink.py | 2 +- core/nodeNetwork.py | 4 +- core/nodeParam.py | 2 +- core/nodes/connectorNode.py | 63 +- core/nodes/imageNode.py | 59 +- core/nodes/noteNode.py | 56 +- core/nodes/ribCodeNode.py | 277 ++- core/nodes/ribNode.py | 310 ++-- core/nodes/rslNode.py | 514 +++--- core/nodes/swatchNode.py | 69 +- core/params/colorNodeParam.py | 252 +-- core/params/controlParam.py | 223 +-- core/params/displacementNodeParam.py | 47 +- core/params/floatNodeParam.py | 157 +- core/params/imageNodeParam.py | 9 +- core/params/intNodeParam.py | 153 +- core/params/lightNodeParam.py | 47 +- core/params/matrixNodeParam.py | 202 +-- core/params/normalNodeParam.py | 188 +- core/params/pointNodeParam.py | 198 +-- core/params/ribNodeParam.py | 47 +- core/params/rslCodeNode.py | 39 +- core/params/shaderNodeParam.py | 115 +- core/params/stringNodeParam.py | 115 +- core/params/surfaceNodeParam.py | 47 +- core/params/textNodeParam.py | 63 +- core/params/transformNodeParam.py | 72 +- core/params/vectorNodeParam.py | 192 +-- core/params/volumeNodeParam.py | 47 +- core/swatchInfo.py | 6 +- core/utils/ShaderInfo.py | 1184 ++++++------- gfx/WorkArea.py | 1913 +++++++++++---------- gfx/gfxLink.py | 480 +++--- gfx/gfxNode.py | 1105 ++++++------ gfx/gfxNodeConnector.py | 783 ++++----- gfx/gfxNodeLabel.py | 470 ++--- gfx/gfxNote.py | 477 ++--- gfx/gfxSwatchNode.py | 593 +++---- gfx/imageView.py | 344 ++-- global_vars.py | 2 +- gui/MainWindow.py | 1791 +++++++++---------- gui/ProjectSetup.py | 264 +-- gui/SettingsSetup.py | 264 +-- gui/ViewComputedCodeDialog.py | 68 +- gui/exportShader/ExportShaderDialog.py | 554 +++--- gui/exportShader/ui_exportShaderDialog.py | 2 +- gui/imageViewWidget.py | 293 ++-- gui/meRendererSetup.py | 391 ++--- gui/nodeEditor/NodeEditorDialog.py | 1224 ++++++------- gui/nodeEditor/codeSyntaxHighlighter.py | 2 +- gui/nodeEditor/nodeCodeEditor.py | 110 +- gui/nodeEditor/nodeLinkEditor.py | 121 +- gui/nodeEditor/nodeNamesEditor.py | 178 +- gui/nodeEditor/nodeParamEditor.py | 585 +++---- gui/nodeEditor/nodePropertiesEditor.py | 312 ++-- gui/nodeEditor/ui_nodeCodeEditor.py | 2 +- gui/nodeEditor/ui_nodeEditorDialog.py | 2 +- gui/nodeEditor/ui_nodeLinkEditor.py | 2 +- gui/nodeEditor/ui_nodeNamesEditor.py | 2 +- gui/nodeEditor/ui_nodeParamEditor.py | 2 +- gui/nodeEditor/ui_nodePropertiesEditor.py | 2 +- gui/nodeLibraryView.py | 99 +- gui/nodeList.py | 273 +-- gui/nodeParamList.py | 514 +++--- gui/nodeParamView.py | 354 ++-- gui/nodeSwatchParam.py | 67 +- gui/nodeTreeView.py | 97 +- gui/params/ColorWidget.py | 2 +- gui/params/ControlWidget.py | 2 +- gui/params/FloatWidget.py | 2 +- gui/params/IntWidget.py | 2 +- gui/params/MatrixWidget.py | 2 +- gui/params/NormalWidget.py | 2 +- gui/params/PointWidget.py | 2 +- gui/params/StringWidget.py | 2 +- gui/params/TextWidget.py | 2 +- gui/params/VectorWidget.py | 2 +- gui/params/linkWidget.py | 2 +- gui/params/paramLabel.py | 287 ++-- gui/params/paramWidget.py | 359 ++-- gui/resources_rc.py | 2 +- gui/ui_MainWindow.py | 227 +-- gui/ui_imageViewWidget.py | 125 +- gui/ui_meRendererSetup.py | 2 +- gui/ui_nodeLibraryView.py | 78 +- gui/ui_nodeList.py | 106 +- gui/ui_nodeParam.py | 2 +- gui/ui_nodeSwatchParam.py | 172 +- gui/ui_projectSetup.py | 2 +- gui/ui_settingsSetup.py | 2 +- gui/ui_viewComputedCodeDialog.py | 2 +- gui/ui_workArea.py | 2 +- meShaderEd.py | 349 ++-- 98 files changed, 10637 insertions(+), 10322 deletions(-) create mode 100644 core/mePyQt.py diff --git a/core/meCommon.py b/core/meCommon.py index 1eba954..6e3fc70 100644 --- a/core/meCommon.py +++ b/core/meCommon.py @@ -1,278 +1,286 @@ """ + meCommon.py """ import os, sys - -from PyQt4 import QtCore +from core.mePyQt import QtCore # # findExecutable # def findExecutable ( executable, path = None ) : - """Try to find 'executable' in the directories listed in 'path' (a - string listing directories separated by 'os.pathsep'; defaults to - os.environ['PATH']). Returns the complete filename or None if not - found - """ - if path is None: - path = os.environ [ 'PATH' ] - paths = path.split(os.pathsep) - extlist = [ '' ] - if os.name == 'os2' : - ( base, ext ) = os.path.splitext ( executable ) - # executable files on OS/2 can have an arbitrary extension, but - # .exe is automatically appended if no dot is present in the name - if not ext: - executable = executable + ".exe" - elif sys.platform == 'win32' : - pathext = os.environ [ 'PATHEXT' ].lower ().split ( os.pathsep ) - (base, ext) = os.path.splitext(executable) - if ext.lower() not in pathext: - extlist = pathext - for ext in extlist: - execname = executable + ext - if os.path.isfile( execname ): - return execname - else: - for p in paths: - f = os.path.join(p, execname) - if os.path.isfile(f): - return f - else: - return None + """Try to find 'executable' in the directories listed in 'path' (a + string listing directories separated by 'os.pathsep'; defaults to + os.environ['PATH']). Returns the complete filename or None if not + found + """ + if path is None: + path = os.environ [ 'PATH' ] + paths = path.split(os.pathsep) + extlist = [ '' ] + if os.name == 'os2' : + ( base, ext ) = os.path.splitext ( executable ) + # executable files on OS/2 can have an arbitrary extension, but + # .exe is automatically appended if no dot is present in the name + if not ext: + executable = executable + ".exe" + elif sys.platform == 'win32' : + pathext = os.environ [ 'PATHEXT' ].lower ().split ( os.pathsep ) + (base, ext) = os.path.splitext(executable) + if ext.lower() not in pathext: + extlist = pathext + for ext in extlist: + execname = executable + ext + if os.path.isfile( execname ): + return execname + else: + for p in paths: + f = os.path.join(p, execname) + if os.path.isfile(f): + return f + else: + return None # # createMissingDirs # def createMissingDirs ( dirList = None ): - # - for dirName in dirList : - #print '-> Check dir %s' % dirName - if not os.path.exists ( dirName ) : - print '-> Create missing dir %s' % dirName - os.makedirs ( dirName ) + # + for dirName in dirList : + #print '-> Check dir %s' % dirName + if not os.path.exists ( dirName ) : + print '-> Create missing dir %s' % dirName + os.makedirs ( dirName ) # # Use this hack, as os.path.normpath doesn't work on windooze, # but QtCore.QDir works fine ... # def normPath ( pathName ) : - result = '' - if pathName != '' : - if ( sys.platform == 'win32' ) : - result = str ( QtCore.QDir( pathName ).absolutePath() ) - else : - result = os.path.normpath ( str( pathName ) ) - return result + result = '' + if pathName != '' : + if ( sys.platform == 'win32' ) : + result = str ( QtCore.QDir( pathName ).absolutePath() ) + else : + result = os.path.normpath ( str( pathName ) ) + return result # # replace C:/ with //C/ for RIB search path names # def sanitizeSearchPath ( pathName ) : - #print ':: sanitizeSearchPath %s' % pathName - sanitizedPath = pathName - if ( sys.platform == 'win32' ) : - if pathName[1:2] == ':' : - sanitizedPath = ( '//' + pathName[0:1] + pathName[2:] ) - return sanitizedPath + #print ':: sanitizeSearchPath %s' % pathName + sanitizedPath = pathName + if ( sys.platform == 'win32' ) : + if pathName[1:2] == ':' : + sanitizedPath = ( '//' + pathName[0:1] + pathName[2:] ) + return sanitizedPath # # is pathname relative ? # def isRelativePath ( pathName ) : - isRelative = True - if ( sys.platform == 'win32' ) : - if pathName[1:2] == ':' : isRelative = False - if pathName[0:1] == '\\' or pathName[0:1] == '/' : - isRelative = False - return isRelative + isRelative = True + if ( sys.platform == 'win32' ) : + if pathName[1:2] == ':' : isRelative = False + if pathName[0:1] == '\\' or pathName[0:1] == '/' : + isRelative = False + return isRelative # # get pathName relative to rootPath # def toRelativePath ( rootPath, pathName ) : - #print ':: toRelativePath %s' % pathName - relativePath = pathName - if not isRelativePath ( pathName ) : - if pathName.find ( rootPath ) != -1 : - relativePath = pathName[ len( rootPath ) + 1 : ] - - return relativePath + #print ':: toRelativePath %s' % pathName + relativePath = pathName + if not isRelativePath ( pathName ) : + if pathName.find ( rootPath ) != -1 : + relativePath = pathName[ len( rootPath ) + 1 : ] + + return relativePath # # get full pathName from relative to rootPath # def fromRelativePath ( rootPath, pathName ) : - #print ':: fromRelativePath %s' % pathName - fullPath = pathName - if isRelativePath ( pathName ) : - fullPath = os.path.join ( rootPath, pathName ) - - return normPath ( fullPath ) + #print ':: fromRelativePath %s' % pathName + fullPath = pathName + if isRelativePath ( pathName ) : + fullPath = os.path.join ( rootPath, pathName ) + + return normPath ( fullPath ) # # launch process # def launchProcess ( cmdList, stdoutLog = None, stderrLog = None ) : - # - # subprocess.Popen(args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, - # - import subprocess, errno - - stdout = None - stderr = None - if stdoutLog is not None : stdout = file ( stdoutLog, 'w' ) - if stderrLog is not None : stderr = file ( stderrLog, 'w' ) - - try: - if sys.platform.startswith ( 'linux' ) : - ( sysname, nodename, release, version, machine ) = os.uname() - #print 'sysname = %s' % sysname - #print 'release = %s' % release - #print 'version = %s' % version - if version.find ( 'Ubuntu' ) != -1 : - print 'Ubuntu' - #retval = os.popen ( ' '.join ( cmdList ), 0, None, None, stdout, stderr ) - retval = subprocess.Popen ( ' '.join ( cmdList ), 0, None, None, stdout, stderr ) - else : - retval = subprocess.call ( cmdList, 0, None, None, stdout, stderr ) - else: - retval = subprocess.call ( cmdList, 0, None, None, stdout, stderr ) - except OSError, e : - if e.errno != errno.EINTR : raise - - if stdout is not None : stdout.close () - if stderr is not None : stderr.close () + # + # subprocess.Popen(args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, + # + import subprocess, errno + + stdout = None + stderr = None + if stdoutLog is not None : stdout = file ( stdoutLog, 'w' ) + if stderrLog is not None : stderr = file ( stderrLog, 'w' ) + + try: + if sys.platform.startswith ( 'linux' ) : + ( sysname, nodename, release, version, machine ) = os.uname() + #print 'sysname = %s' % sysname + #print 'release = %s' % release + #print 'version = %s' % version + if version.find ( 'Ubuntu' ) != -1 : + print 'Ubuntu' + #retval = os.popen ( ' '.join ( cmdList ), 0, None, None, stdout, stderr ) + retval = subprocess.Popen ( ' '.join ( cmdList ), 0, None, None, stdout, stderr ) + else : + retval = subprocess.call ( cmdList, 0, None, None, stdout, stderr ) + else: + retval = subprocess.call ( cmdList, 0, None, None, stdout, stderr ) + except OSError, e : + if e.errno != errno.EINTR : raise + + if stdout is not None : stdout.close () + if stderr is not None : stderr.close () - return retval + return retval # # getUniqueName # def getUniqueName ( name, nameList ) : - # - newName = name - sfx = 0 - while newName in nameList : - newName = name + str ( sfx ) - sfx += 1 - return str( newName ) + # + newName = name + sfx = 0 + while newName in nameList : + newName = name + str ( sfx ) + sfx += 1 + return str( newName ) # # getParsedLabel # def getParsedLabel ( text ) : - # - newLabel = str ( text ).strip () - newLabel = newLabel.replace ( ' ', "_" ) - return newLabel + # + newLabel = str ( text ).strip () + newLabel = newLabel.replace ( ' ', "_" ) + return newLabel +# +# getSettingsStrValue +# +def getSettingsStrValue ( settings, key ) : + if QtCore.QT_VERSION < 50000 : + return str ( settings.value ( key ).toString () ) + else : + return str ( settings.value ( key ) ) # # createDefaultProject # def createDefaultProject ( settings, check_if_exist = False ) : - # - project_filename = str ( settings.value ( 'project_filename' ).toString () ) - project = str ( settings.value ( 'project' ).toString () ) - project_shaders = str ( settings.value ( 'project_shaders' ).toString () ) - project_textures = str ( settings.value ( 'project_textures' ).toString () ) - shader_networks = str ( settings.value ( 'shader_networks' ).toString () ) - shader_sources = str ( settings.value ( 'shader_sources' ).toString () ) - - filename = normPath ( os.path.join ( project, project_filename ) ) - if check_if_exist : - if os.path.exists ( filename ) : - print '>> DefaultProject %s already exists...' % filename - return - - print '>> createDefaultProject %s' % filename - - with open ( filename , 'w') as f : - f.write ( 'project_shaders=%s\n' % toRelativePath ( project, project_shaders ) ) - f.write ( 'project_textures=%s\n' % toRelativePath ( project, project_textures ) ) - f.write ( 'shader_networks=%s\n' % toRelativePath ( project, shader_networks ) ) - f.write ( 'shader_sources=%s\n' % toRelativePath ( project, shader_sources ) ) - f.closed + # + project_filename = getSettingsStrValue ( settings, 'project_filename' ) + project = getSettingsStrValue ( settings, 'project' ) + project_shaders = getSettingsStrValue ( settings, 'project_shaders' ) + project_textures = getSettingsStrValue ( settings, 'project_textures' ) + shader_networks = getSettingsStrValue ( settings, 'shader_networks' ) + shader_sources = getSettingsStrValue ( settings, 'shader_sources' ) + + filename = normPath ( os.path.join ( project, project_filename ) ) + if check_if_exist : + if os.path.exists ( filename ) : + print '>> DefaultProject %s already exists...' % filename + return + + print '>> createDefaultProject %s' % filename + + with open ( filename , 'w') as f : + f.write ( 'project_shaders=%s\n' % toRelativePath ( project, project_shaders ) ) + f.write ( 'project_textures=%s\n' % toRelativePath ( project, project_textures ) ) + f.write ( 'shader_networks=%s\n' % toRelativePath ( project, shader_networks ) ) + f.write ( 'shader_sources=%s\n' % toRelativePath ( project, shader_sources ) ) + f.closed # # openDefaultProject # def openDefaultProject ( settings, global_vars, project ) : - # - ret = False - if os.path.exists ( project ) : - project_filename = str ( settings.value ( 'project_filename' ).toString () ) - filename = normPath ( os.path.join ( project, project_filename ) ) - project_dir = normPath ( project ) - # setup default setting - project_shaders = normPath ( os.path.join ( project_dir,'shaders' ) ) - project_textures = normPath ( os.path.join ( project_dir,'textures' ) ) - shader_networks_dir = normPath ( os.path.join ( project_shaders,'shn' ) ) - shader_sources_dir = normPath ( os.path.join ( project_shaders,'src' ) ) - if os.path.exists ( filename ) : - # read settings from existing project file - f = open ( filename, 'r' ) - for line in f : - ( key, value ) = line.split ( '=' ) - name = key.strip() - if name in [ 'project_shaders', 'project_textures', 'shader_networks', 'shader_sources' ] : - print 'name = %s value = %s' % ( name, fromRelativePath ( project_dir, value.strip() ) ) - settings.setValue ( name, fromRelativePath ( project_dir, value.strip() ) ) - f.close () - else : - # setup default settings and create default file - settings.setValue ( 'project', project_dir ) - settings.setValue ( 'project_shaders', project_shaders ) - settings.setValue ( 'project_textures', project_textures ) - settings.setValue ( 'shader_networks', shader_networks_dir ) - settings.setValue ( 'shader_sources', shader_sources_dir ) - - createDefaultProject ( settings ) - - global_vars [ 'ProjectPath' ] = project_dir - - global_vars [ 'ProjectShaders' ] = project_shaders - global_vars [ 'ProjectTextures' ] = project_textures - - global_vars [ 'ProjectNetworks' ] = shader_networks_dir - global_vars [ 'ProjectSources' ] = shader_sources_dir - - global_vars [ 'ProjectSearchPath' ] = sanitizeSearchPath ( project_dir ) - global_vars [ 'ProjectSearchShaders' ] = sanitizeSearchPath ( project_shaders ) - global_vars [ 'ProjectSearchTextures' ] = sanitizeSearchPath ( project_textures ) - - createMissingDirs ( [ project_shaders, project_textures, shader_networks_dir, shader_sources_dir ] ) - - ret = True + # + ret = False + if os.path.exists ( project ) : + project_filename = str ( settings.value ( 'project_filename' ).toString () ) + filename = normPath ( os.path.join ( project, project_filename ) ) + project_dir = normPath ( project ) + # setup default setting + project_shaders = normPath ( os.path.join ( project_dir,'shaders' ) ) + project_textures = normPath ( os.path.join ( project_dir,'textures' ) ) + shader_networks_dir = normPath ( os.path.join ( project_shaders,'shn' ) ) + shader_sources_dir = normPath ( os.path.join ( project_shaders,'src' ) ) + if os.path.exists ( filename ) : + # read settings from existing project file + f = open ( filename, 'r' ) + for line in f : + ( key, value ) = line.split ( '=' ) + name = key.strip() + if name in [ 'project_shaders', 'project_textures', 'shader_networks', 'shader_sources' ] : + print 'name = %s value = %s' % ( name, fromRelativePath ( project_dir, value.strip() ) ) + settings.setValue ( name, fromRelativePath ( project_dir, value.strip() ) ) + f.close () + else : + # setup default settings and create default file + settings.setValue ( 'project', project_dir ) + settings.setValue ( 'project_shaders', project_shaders ) + settings.setValue ( 'project_textures', project_textures ) + settings.setValue ( 'shader_networks', shader_networks_dir ) + settings.setValue ( 'shader_sources', shader_sources_dir ) + + createDefaultProject ( settings ) + + global_vars [ 'ProjectPath' ] = project_dir + + global_vars [ 'ProjectShaders' ] = project_shaders + global_vars [ 'ProjectTextures' ] = project_textures + + global_vars [ 'ProjectNetworks' ] = shader_networks_dir + global_vars [ 'ProjectSources' ] = shader_sources_dir + + global_vars [ 'ProjectSearchPath' ] = sanitizeSearchPath ( project_dir ) + global_vars [ 'ProjectSearchShaders' ] = sanitizeSearchPath ( project_shaders ) + global_vars [ 'ProjectSearchTextures' ] = sanitizeSearchPath ( project_textures ) + + createMissingDirs ( [ project_shaders, project_textures, shader_networks_dir, shader_sources_dir ] ) + + ret = True - return ret + return ret # # parseGlobalVars # def parseGlobalVars ( inputStr ) : - # - from global_vars import app_global_vars, DEBUG_MODE - #if DEBUG_MODE : print '-> parseGlobalVars in %s' % parsedStr - resultStr = '' - parserStart = 0 - parserPos = 0 - parsedStr = str ( inputStr ) + # + from global_vars import app_global_vars, DEBUG_MODE + #if DEBUG_MODE : print '-> parseGlobalVars in %s' % parsedStr + resultStr = '' + parserStart = 0 + parserPos = 0 + parsedStr = str ( inputStr ) - while parserPos != -1 : - parserPos = parsedStr.find ( '$', parserStart ) - if parserPos != -1 : - # - if parserPos != 0 : - resultStr += parsedStr [ parserStart : parserPos ] + while parserPos != -1 : + parserPos = parsedStr.find ( '$', parserStart ) + if parserPos != -1 : + # + if parserPos != 0 : + resultStr += parsedStr [ parserStart : parserPos ] - # check global vars first - if parsedStr [ ( parserPos + 1 ) : ( parserPos + 2 ) ] == '{' : - globStart = parserPos + 2 - parserPos = parsedStr.find ( '}', globStart ) - global_var_name = parsedStr [ globStart : ( parserPos ) ] + # check global vars first + if parsedStr [ ( parserPos + 1 ) : ( parserPos + 2 ) ] == '{' : + globStart = parserPos + 2 + parserPos = parsedStr.find ( '}', globStart ) + global_var_name = parsedStr [ globStart : ( parserPos ) ] - #print '-> found global var %s' % global_var_name + #print '-> found global var %s' % global_var_name - if global_var_name in app_global_vars.keys () : - resultStr += app_global_vars [ global_var_name ] - else : - # keep $ sign for otheer, non ${...} cases - resultStr += '$' + if global_var_name in app_global_vars.keys () : + resultStr += app_global_vars [ global_var_name ] + else : + # keep $ sign for otheer, non ${...} cases + resultStr += '$' - #print 'parserPos = %d parserStart = %d' % ( parserPos, parserStart ) - if parserPos != -1 : - parserStart = parserPos + 1 + #print 'parserPos = %d parserStart = %d' % ( parserPos, parserStart ) + if parserPos != -1 : + parserStart = parserPos + 1 - resultStr += parsedStr [ parserStart: ] + resultStr += parsedStr [ parserStart: ] - return resultStr \ No newline at end of file + return resultStr \ No newline at end of file diff --git a/core/mePyQt.py b/core/mePyQt.py new file mode 100644 index 0000000..bb9bba4 --- /dev/null +++ b/core/mePyQt.py @@ -0,0 +1,65 @@ +""" + + mePyQt.py + + PyQt wrapper allows to use the same code (almost) with different + PyQt implementation: PySide, PyQt4, PyQt5 + + This code is based on cgrupyqt.py from CGRU project +""" +List = [ 'QtCore', + 'QtGui', + #'QtNetwork', + 'QtXml', + 'QtWidgets', + 'Qt' + ] + +PythonQtType = None +PySide = True + +try: + PythonQt = __import__( 'PySide', globals(), locals(), List ) + PythonQtType = 'PySide' +except ImportError: + try: + PythonQt = __import__( 'PyQt5', globals(), locals(), List ) + PythonQtType = 'PyQt5' + except ImportError: + PythonQt = __import__( 'PyQt4', globals(), locals(), List ) + PythonQtType = 'PyQt4' + +Qt = PythonQt.Qt +QtCore = PythonQt.QtCore +QtGui = PythonQt.QtGui +QtXml = PythonQt.QtXml +QtWidgets = PythonQt.QtWidgets +#QtNetwork = PythonQt.QtNetwork + +print ( '* ' + PythonQtType + ' module imported' ) + +if PythonQtType == 'PyQt4' or PythonQtType == 'PyQt5': + #print('You can install PySide if interested in LGPL license.') + PySide = False +# +# GetOpenFileName +# +def GetOpenFileName ( i_qwidget, i_title, i_path = None ) : + if i_path is None : + i_path = '.' + if PySide : + afile, filter = \ + QtGui.QFileDialog.getOpenFileName ( i_qwidget, i_title, i_path ) + return afile + return str ( QtGui.QFileDialog.getOpenFileName ( i_qwidget, i_title, i_path ) ) +# +# GetSaveFileName +# +def GetSaveFileName ( i_qwdget, i_title, i_path = None ) : + if i_path is None : + i_path = '.' + if PySide : + afile, filter = \ + QtGui.QFileDialog.getSaveFileName ( i_qwdget, i_title, i_path ) + return afile + return str ( QtGui.QFileDialog.getSaveFileName ( i_qwdget, i_title, i_path ) ) diff --git a/core/meRendererPreset.py b/core/meRendererPreset.py index 8fd4b03..4469f9e 100644 --- a/core/meRendererPreset.py +++ b/core/meRendererPreset.py @@ -4,8 +4,8 @@ """ import os, sys -from PyQt4 import QtCore, QtXml -from PyQt4.QtCore import QDir, QFile, QVariant +from core.mePyQt import QtCore, QtXml +#from core.mePyQt.QtCore import QDir, QFile, QVariant # # meRendererInfo # @@ -169,7 +169,7 @@ def readSettings ( self, fileName ) : # dom = QtXml.QDomDocument ( 'renderers' ) - file = QFile ( fileName ) + file = QtCore.QFile ( fileName ) if file.open ( QtCore.QIODevice.ReadOnly ) : if dom.setContent ( file ) : self.fileName = fileName @@ -197,7 +197,7 @@ def saveSettings ( self ) : root.appendChild ( xml_preset ) dom.appendChild ( root ) - file = QFile ( self.fileName ) + file = QtCore.QFile ( self.fileName ) if file.open ( QtCore.QIODevice.WriteOnly | QtCore.QIODevice.Text ) : if file.write ( dom.toByteArray () ) != -1 : result = True diff --git a/core/node.py b/core/node.py index 5789be6..90bd634 100644 --- a/core/node.py +++ b/core/node.py @@ -5,8 +5,8 @@ """ import os, sys, copy -from PyQt4 import QtCore, QtXml -from PyQt4.QtCore import QDir, QFile, QVariant +from core.mePyQt import QtCore, QtXml +#from PyQt4.QtCore import QDir, QFile, QVariant from global_vars import app_global_vars, DEBUG_MODE, VALID_RIB_NODE_TYPES from core.node_global_vars import node_global_vars diff --git a/core/nodeLibrary.py b/core/nodeLibrary.py index 24a5cb3..e491780 100644 --- a/core/nodeLibrary.py +++ b/core/nodeLibrary.py @@ -1,119 +1,115 @@ -#=============================================================================== -# nodeLibrary.py -# -# -# -#=============================================================================== -import os, sys -from PyQt4 import QtCore, QtGui, QtXml +""" -from PyQt4.QtCore import QDir, QFile, QVariant -from PyQt4.QtGui import QStandardItemModel, QStandardItem + nodeLibrary.py + +""" +from core.mePyQt import QtCore, QtGui, QtXml +#from QtCore import QDir, QFile, QVariant +#from QtGui import QStandardItemModel, QStandardItem from global_vars import app_global_vars from core.node import Node from core.nodeParam import NodeParam - # # NodeLibrary # class NodeLibrary ( QtCore.QObject ) : # QtCore.QObject - # - # __init__ - # - def __init__ ( self, dirName ) : - # - self.dirName = dirName - self.libdir = QDir ( dirName ); - self.model = QStandardItemModel () - self.parentItem = self.model.invisibleRootItem () - - print '>> NodeLibrary: libdir = %s' % dirName - - self.liblevel = '' - self.scanLibDir () - # - # scanLibDir - # - def scanLibDir ( self ) : - # process directories - sortFlags = QDir.Name - filterFlags = ( QDir.AllDirs | QDir.NoDotAndDotDot ) - fileList = self.libdir.entryInfoList ( filterFlags, sortFlags ) - - for f in fileList : - item = QStandardItem ( f.fileName () ) - item.setEditable ( False ) - item.setDragEnabled ( False ) - - # set bold font for folders - font = item.font() - font.setBold ( True ) - item.setFont ( font ) - - item.setWhatsThis ( 'folder' ) - - currparent = self.parentItem - self.parentItem.appendRow ( item ) - self.parentItem = item - - currlevel = self.liblevel # store current level - self.liblevel = self.liblevel + f.fileName () + '/' - self.libdir.cd ( f.fileName () ) - - self.scanLibDir () # recurcive call itself - - self.liblevel = currlevel # restore current level - self.libdir.cdUp () - - self.parentItem = currparent - - # process XML files - filterFlags = QDir.Files - fileList = self.libdir.entryInfoList ( [ '*.xml' ], filterFlags, sortFlags ) - for f in fileList : - self.scanXmlNodes ( f.fileName () ) - # - # scanXmlNodes - # - def scanXmlNodes ( self, filename ) : - # - dom = QtXml.QDomDocument ( '' ) - nodeFilename = self.dirName + '/' + self.liblevel + filename - - file = QFile ( self.libdir.filePath ( filename ) ) - - if file.open ( QtCore.QIODevice.ReadOnly ) : - if dom.setContent ( file ) : - node = dom.documentElement () - if node.nodeName () == 'nodenet' or node.nodeName () == 'node' : - nodeName = node.attributes ().namedItem ( 'name' ).nodeValue () - nodeType = node.attributes ().namedItem ( 'type' ).nodeValue () - nodeAuthor = node.attributes ().namedItem ( 'author' ).nodeValue () - nodeIcon = node.attributes ().namedItem ( 'icon' ).nodeValue () - nodeHelp = '' - help_tag = node.namedItem ('help') - - if not help_tag.isNull() : nodeHelp = help_tag.toElement ().text () - - item = QStandardItem ( nodeName ) - item.setEditable ( False ) - - item.setData ( QVariant ( nodeAuthor ), QtCore.Qt.UserRole + 1 ) - item.setData ( QVariant ( nodeType ), QtCore.Qt.UserRole + 2 ) - item.setData ( QVariant ( nodeHelp ), QtCore.Qt.UserRole + 3 ) - item.setData ( QVariant ( nodeFilename ), QtCore.Qt.UserRole + 4 ) - item.setData ( QVariant ( nodeIcon ), QtCore.Qt.UserRole + 5 ) - - if node.nodeName () == 'nodenet' : - # set Blue color for nodenet items - brush = QtGui.QBrush () - brush.setColor ( QtCore.Qt.blue ) - item.setForeground ( brush ) - item.setWhatsThis ( 'nodenet' ) - else: - item.setWhatsThis ( 'node' ) - - self.parentItem.appendRow ( item ) - file.close () + # + # __init__ + # + def __init__ ( self, dirName ) : + # + self.dirName = dirName + self.libdir = QtCore.QDir ( dirName ); + self.model = QtGui.QStandardItemModel () + self.parentItem = self.model.invisibleRootItem () + + print '>> NodeLibrary: libdir = %s' % dirName + + self.liblevel = '' + self.scanLibDir () + # + # scanLibDir + # + def scanLibDir ( self ) : + # process directories + sortFlags = QtCore.QDir.Name + filterFlags = ( QtCore.QDir.AllDirs | QtCore.QDir.NoDotAndDotDot ) + fileList = self.libdir.entryInfoList ( filterFlags, sortFlags ) + + for f in fileList : + item = QtGui.QStandardItem ( f.fileName () ) + item.setEditable ( False ) + item.setDragEnabled ( False ) + + # set bold font for folders + font = item.font() + font.setBold ( True ) + item.setFont ( font ) + + item.setWhatsThis ( 'folder' ) + + currparent = self.parentItem + self.parentItem.appendRow ( item ) + self.parentItem = item + + currlevel = self.liblevel # store current level + self.liblevel = self.liblevel + f.fileName () + '/' + self.libdir.cd ( f.fileName () ) + + self.scanLibDir () # recurcive call itself + + self.liblevel = currlevel # restore current level + self.libdir.cdUp () + + self.parentItem = currparent + + # process XML files + filterFlags = QtCore.QDir.Files + fileList = self.libdir.entryInfoList ( [ '*.xml' ], filterFlags, sortFlags ) + for f in fileList : + self.scanXmlNodes ( f.fileName () ) + # + # scanXmlNodes + # + def scanXmlNodes ( self, filename ) : + # + dom = QtXml.QDomDocument ( '' ) + nodeFilename = self.dirName + '/' + self.liblevel + filename + + file = QtCore.QFile ( self.libdir.filePath ( filename ) ) + + if file.open ( QtCore.QIODevice.ReadOnly ) : + if dom.setContent ( file ) : + node = dom.documentElement () + if node.nodeName () == 'nodenet' or node.nodeName () == 'node' : + nodeName = node.attributes ().namedItem ( 'name' ).nodeValue () + nodeType = node.attributes ().namedItem ( 'type' ).nodeValue () + nodeAuthor = node.attributes ().namedItem ( 'author' ).nodeValue () + nodeIcon = node.attributes ().namedItem ( 'icon' ).nodeValue () + nodeHelp = '' + help_tag = node.namedItem ('help') + + if not help_tag.isNull() : nodeHelp = help_tag.toElement ().text () + + item = QtGui.QStandardItem ( nodeName ) + item.setEditable ( False ) + + item.setData ( QtCore.QVariant ( nodeAuthor ), QtCore.Qt.UserRole + 1 ) + item.setData ( QtCore.QVariant ( nodeType ), QtCore.Qt.UserRole + 2 ) + item.setData ( QtCore.QVariant ( nodeHelp ), QtCore.Qt.UserRole + 3 ) + item.setData ( QtCore.QVariant ( nodeFilename ), QtCore.Qt.UserRole + 4 ) + item.setData ( QtCore.QVariant ( nodeIcon ), QtCore.Qt.UserRole + 5 ) + + if node.nodeName () == 'nodenet' : + # set Blue color for nodenet items + brush = QtGui.QBrush () + brush.setColor ( QtCore.Qt.blue ) + item.setForeground ( brush ) + item.setWhatsThis ( 'nodenet' ) + else: + item.setWhatsThis ( 'node' ) + + self.parentItem.appendRow ( item ) + file.close () diff --git a/core/nodeLink.py b/core/nodeLink.py index a47a204..1a558be 100644 --- a/core/nodeLink.py +++ b/core/nodeLink.py @@ -5,7 +5,7 @@ # #=============================================================================== import os, sys -from PyQt4 import QtCore +from core.mePyQt import QtCore from global_vars import app_global_vars, DEBUG_MODE from node import Node diff --git a/core/nodeNetwork.py b/core/nodeNetwork.py index 4c22bc8..243162f 100644 --- a/core/nodeNetwork.py +++ b/core/nodeNetwork.py @@ -5,8 +5,8 @@ """ import os, sys -from PyQt4 import QtCore, QtXml -from PyQt4.QtCore import QDir, QFile, QVariant +from core.mePyQt import QtCore, QtXml +#from PyQt4.QtCore import QDir, QFile, QVariant from node import * from nodes.rslNode import RSLNode diff --git a/core/nodeParam.py b/core/nodeParam.py index a0f9b95..01cc717 100644 --- a/core/nodeParam.py +++ b/core/nodeParam.py @@ -6,7 +6,7 @@ import os, sys import re import copy -from PyQt4 import QtCore +from core.mePyQt import QtCore from core.node import Node from global_vars import app_global_vars, DEBUG_MODE, VALID_RIB_NODE_TYPES diff --git a/core/nodes/connectorNode.py b/core/nodes/connectorNode.py index 240a934..b4c4736 100644 --- a/core/nodes/connectorNode.py +++ b/core/nodes/connectorNode.py @@ -1,38 +1,39 @@ -#=============================================================================== -# coonectorNode.py -#=============================================================================== -import os, sys -from PyQt4 import QtCore +""" + + connectorNode.py + +""" +from core.mePyQt import QtCore from core.node import Node from core.nodeParam import NodeParam from global_vars import app_global_vars, DEBUG_MODE # -# ImageNode +# ConnectorNode # class ConnectorNode( Node ) : - # - # __init__ - # - def __init__ ( self, xml_node = None ) : - # - Node.__init__( self, xml_node ) - if xml_node is None : - self.type = 'connector' - self.name = self.label = self.type - if DEBUG_MODE : print ">> ConnectorNode( %s ).__init__" % self.label - # - # copy - # - def copy ( self ) : - # - if DEBUG_MODE : print '>> ConnectorNode( %s ).copy' % self.label - newNode = ConnectorNode () - self.copySetup ( newNode ) - return newNode - # - # computeNode - # - def computeNode ( self ) : - # - print '>> ConnectorNode( %s ).computeNode (dummy call)' % self.label + # + # __init__ + # + def __init__ ( self, xml_node = None ) : + # + Node.__init__( self, xml_node ) + if xml_node is None : + self.type = 'connector' + self.name = self.label = self.type + if DEBUG_MODE : print ">> ConnectorNode( %s ).__init__" % self.label + # + # copy + # + def copy ( self ) : + # + if DEBUG_MODE : print '>> ConnectorNode( %s ).copy' % self.label + newNode = ConnectorNode () + self.copySetup ( newNode ) + return newNode + # + # computeNode + # + def computeNode ( self ) : + # + print '>> ConnectorNode( %s ).computeNode (dummy call)' % self.label diff --git a/core/nodes/imageNode.py b/core/nodes/imageNode.py index e91f906..739d5e7 100644 --- a/core/nodes/imageNode.py +++ b/core/nodes/imageNode.py @@ -3,8 +3,7 @@ imageNode.py """ -import os, sys -from PyQt4 import QtCore +from core.mePyQt import QtCore from core.node import Node @@ -13,31 +12,31 @@ # ImageNode # class ImageNode ( Node ) : - # - # __init__ - # - def __init__ ( self, xml_node = None ) : - # - Node.__init__ ( self, xml_node ) - - self.imageName = '' - if DEBUG_MODE : print '>> ImageNode( %s ).__init__' % self.label - # - # copy - # - def copy ( self ) : - # - if DEBUG_MODE : print '>> ImageNode( %s ).copy' % self.label - newNode = ImageNode () - self.copySetup ( newNode ) - return newNode - # - # computeNode - # - def computeNode ( self ) : - # - print '>> ImageNode( %s ).computeNode' % self.label - # inside control_code, imageName value can be assigned from different - # input parameters - self.execControlCode () - return self.imageName + # + # __init__ + # + def __init__ ( self, xml_node = None ) : + # + Node.__init__ ( self, xml_node ) + + self.imageName = '' + if DEBUG_MODE : print '>> ImageNode( %s ).__init__' % self.label + # + # copy + # + def copy ( self ) : + # + if DEBUG_MODE : print '>> ImageNode( %s ).copy' % self.label + newNode = ImageNode () + self.copySetup ( newNode ) + return newNode + # + # computeNode + # + def computeNode ( self ) : + # + print '>> ImageNode( %s ).computeNode' % self.label + # inside control_code, imageName value can be assigned from different + # input parameters + self.execControlCode () + return self.imageName diff --git a/core/nodes/noteNode.py b/core/nodes/noteNode.py index 57f1951..af38058 100644 --- a/core/nodes/noteNode.py +++ b/core/nodes/noteNode.py @@ -1,36 +1,34 @@ -#=============================================================================== -# noteNode.py -# -# -# -#=============================================================================== -import os, sys -from PyQt4 import QtCore +""" + + noteNode.py + +""" +from core.mePyQt import QtCore from core.node import Node from core.nodeParam import NodeParam from global_vars import app_global_vars, DEBUG_MODE # -# ImageNode +# NoteNode # class NoteNode( Node ) : - # - # __init__ - # - def __init__ ( self, xml_node = None ) : - # - Node.__init__( self, xml_node ) - if DEBUG_MODE : print ">> NoteNode __init__" - # - # copy - # - def copy ( self ) : - if DEBUG_MODE : print '>> NoteNode::copy (%s)' % self.label - newNode = NoteNode () - self.copySetup ( newNode ) - return newNode - # - # computeNode - # - def computeNode ( self ) : - print '>> NoteNode (%s).computeNode' % self.label + # + # __init__ + # + def __init__ ( self, xml_node = None ) : + # + Node.__init__( self, xml_node ) + if DEBUG_MODE : print ">> NoteNode __init__" + # + # copy + # + def copy ( self ) : + if DEBUG_MODE : print '>> NoteNode::copy (%s)' % self.label + newNode = NoteNode () + self.copySetup ( newNode ) + return newNode + # + # computeNode + # + def computeNode ( self ) : + print '>> NoteNode (%s).computeNode' % self.label diff --git a/core/nodes/ribCodeNode.py b/core/nodes/ribCodeNode.py index b0d3b95..d66013e 100644 --- a/core/nodes/ribCodeNode.py +++ b/core/nodes/ribCodeNode.py @@ -3,8 +3,7 @@ ribCodeNode.py """ -import os, sys -from PyQt4 import QtCore +from core.mePyQt import QtCore from core.node import Node from core.nodeParam import NodeParam @@ -15,148 +14,148 @@ # RIBCodeNode # class RIBCodeNode ( Node ) : - # - # __init__ - # - def __init__ ( self, xml_node = None ) : - # - Node.__init__ ( self, xml_node ) - self.ribName = '' - # - # copy - # - def copy ( self ): - # - if DEBUG_MODE : print '>> RIBCodeNode( %s ).copy' % self.label - newNode = RIBCodeNode () - self.copySetup ( newNode ) - return newNode - # - # getParamDeclaration - # - def getParamDeclaration ( self, param ) : - # - paramValueStr = param.getValueToStr () - if param.type == 'string' : - paramValueStr = '"' + paramValueStr + '"' - result = '"' + param.typeToStr () + ' ' + self.getParamName ( param ) + '" ' - result += '[ ' + paramValueStr + ' ]' - return result - # - # getRiCallForShaderType - # - def getRiCallForShaderType ( self, shader_type ) : - # - result = '' - shaderRiCall = { 'surface' : 'Surface' - ,'displacement' : 'Displacement' - ,'light' : 'LightSource' - ,'volume' : 'Volume' - ,'shader' : 'Shader' - } - if shader_type in shaderRiCall.keys () : - result = shaderRiCall [ shader_type ] - return result - # - # parseLocalVars - # - def parseLocalVars ( self, parsedStr, CodeOnly = False ) : - #print '-> parseLocalVars in %s' % parsedStr - resultStr = '' - parserStart = 0 - parserPos = 0 + # + # __init__ + # + def __init__ ( self, xml_node = None ) : + # + Node.__init__ ( self, xml_node ) + self.ribName = '' + # + # copy + # + def copy ( self ): + # + if DEBUG_MODE : print '>> RIBCodeNode( %s ).copy' % self.label + newNode = RIBCodeNode () + self.copySetup ( newNode ) + return newNode + # + # getParamDeclaration + # + def getParamDeclaration ( self, param ) : + # + paramValueStr = param.getValueToStr () + if param.type == 'string' : + paramValueStr = '"' + paramValueStr + '"' + result = '"' + param.typeToStr () + ' ' + self.getParamName ( param ) + '" ' + result += '[ ' + paramValueStr + ' ]' + return result + # + # getRiCallForShaderType + # + def getRiCallForShaderType ( self, shader_type ) : + # + result = '' + shaderRiCall = { 'surface' : 'Surface' + ,'displacement' : 'Displacement' + ,'light' : 'LightSource' + ,'volume' : 'Volume' + ,'shader' : 'Shader' + } + if shader_type in shaderRiCall.keys () : + result = shaderRiCall [ shader_type ] + return result + # + # parseLocalVars + # + def parseLocalVars ( self, parsedStr, CodeOnly = False ) : + #print '-> parseLocalVars in %s' % parsedStr + resultStr = '' + parserStart = 0 + parserPos = 0 - while parserPos != -1 : - parserPos = parsedStr.find ( '$', parserStart ) - if parserPos != -1 : - # - if parserPos != 0 : - resultStr += parsedStr [ parserStart : parserPos ] + while parserPos != -1 : + parserPos = parsedStr.find ( '$', parserStart ) + if parserPos != -1 : + # + if parserPos != 0 : + resultStr += parsedStr [ parserStart : parserPos ] - # check local variables - if parsedStr [ ( parserPos + 1 ) : ( parserPos + 2 ) ] == '(' : - globStart = parserPos + 2 - parserPos = parsedStr.find ( ')', globStart ) - local_var_name = parsedStr [ globStart : ( parserPos ) ] + # check local variables + if parsedStr [ ( parserPos + 1 ) : ( parserPos + 2 ) ] == '(' : + globStart = parserPos + 2 + parserPos = parsedStr.find ( ')', globStart ) + local_var_name = parsedStr [ globStart : ( parserPos ) ] - #print '-> found local var %s' % local_var_name + #print '-> found local var %s' % local_var_name - param = self.getInputParamByName ( local_var_name ) - if param is not None : - value = self.getInputParamValueByName ( local_var_name, CodeOnly ) - resultStr += value - else : - param = self.getOutputParamByName ( local_var_name ) - if param is not None : - resultStr += param.getValueToStr () - else : - print '-> ERRPR: local var %s is not defined !' % local_var_name - else : - # keep $ sign for otheer, non $(...) cases - resultStr += '$' + param = self.getInputParamByName ( local_var_name ) + if param is not None : + value = self.getInputParamValueByName ( local_var_name, CodeOnly ) + resultStr += value + else : + param = self.getOutputParamByName ( local_var_name ) + if param is not None : + resultStr += param.getValueToStr () + else : + print '-> ERRPR: local var %s is not defined !' % local_var_name + else : + # keep $ sign for otheer, non $(...) cases + resultStr += '$' - #print 'parserPos = %d parserStart = %d' % ( parserPos, parserStart ) - if parserPos != -1 : - parserStart = parserPos + 1 + #print 'parserPos = %d parserStart = %d' % ( parserPos, parserStart ) + if parserPos != -1 : + parserStart = parserPos + 1 - resultStr += parsedStr [ parserStart: ] - - if resultStr != '' : - resultStr = self.getHeader () + resultStr - - return resultStr - # - # getInputParamValueByName - # - def getInputParamValueByName ( self, name, CodeOnly = False ) : - # - result = None - param = self.getInputParamByName ( name ) + resultStr += parsedStr [ parserStart: ] + + if resultStr != '' : + resultStr = self.getHeader () + resultStr + + return resultStr + # + # getInputParamValueByName + # + def getInputParamValueByName ( self, name, CodeOnly = False ) : + # + result = None + param = self.getInputParamByName ( name ) - if self.isInputParamLinked ( param ) : - link = self.inputLinks [ param ] - #link.printInfo () - link.srcNode.computeNode ( CodeOnly ) - #if self.computed_code is not None : - # self.computed_code += link.srcNode.computed_code - if link.srcNode.type in [ 'rib', 'rib_code' ] : - #result = '## start code from :' + link.srcNode.label - result = link.srcNode.parseLocalVars ( link.srcNode.code, CodeOnly ) - #result += '## end code from :' + link.srcNode.label - else : - result = link.srcNode.parseGlobalVars ( link.srcParam.getValueToStr () ) - else : - result = param.getValueToStr () - - return result - # - # getHeader - # - def getHeader ( self ) : - # - rslHeader = '\n' - rslHeader += '#\n' - rslHeader += '# RIB node: %s (%s)\n' % ( self.label, self.name ) - rslHeader += '#\n' - return rslHeader - # - # getComputedCode - # - def getComputedCode ( self, CodeOnly = False ) : - # - computedCode = '' - - self.execControlCode () - - computedCode = self.parseLocalVars ( self.code, CodeOnly ) - computedCode = self.parseGlobalVars ( computedCode ) - - return computedCode - # - # computeNode - # - def computeNode ( self, CodeOnly = False ) : - # - self.execControlCode () - + if self.isInputParamLinked ( param ) : + link = self.inputLinks [ param ] + #link.printInfo () + link.srcNode.computeNode ( CodeOnly ) + #if self.computed_code is not None : + # self.computed_code += link.srcNode.computed_code + if link.srcNode.type in [ 'rib', 'rib_code' ] : + #result = '## start code from :' + link.srcNode.label + result = link.srcNode.parseLocalVars ( link.srcNode.code, CodeOnly ) + #result += '## end code from :' + link.srcNode.label + else : + result = link.srcNode.parseGlobalVars ( link.srcParam.getValueToStr () ) + else : + result = param.getValueToStr () + + return result + # + # getHeader + # + def getHeader ( self ) : + # + rslHeader = '\n' + rslHeader += '#\n' + rslHeader += '# RIB node: %s (%s)\n' % ( self.label, self.name ) + rslHeader += '#\n' + return rslHeader + # + # getComputedCode + # + def getComputedCode ( self, CodeOnly = False ) : + # + computedCode = '' + + self.execControlCode () + + computedCode = self.parseLocalVars ( self.code, CodeOnly ) + computedCode = self.parseGlobalVars ( computedCode ) + + return computedCode + # + # computeNode + # + def computeNode ( self, CodeOnly = False ) : + # + self.execControlCode () + diff --git a/core/nodes/ribNode.py b/core/nodes/ribNode.py index 56a49de..b79b17d 100644 --- a/core/nodes/ribNode.py +++ b/core/nodes/ribNode.py @@ -7,7 +7,7 @@ """ import os, sys -from PyQt4 import QtCore +from core.mePyQt import QtCore from core.node import Node from core.nodeParam import NodeParam @@ -19,158 +19,158 @@ # RIBNode # class RIBNode ( Node ) : - # - # __init__ - # - def __init__ ( self, xml_node = None ) : - # - Node.__init__ ( self, xml_node ) - self.ribName = '' - # - # copy - # - def copy ( self ) : - # - if DEBUG_MODE : print '>> RIBNode( %s ).copy' % self.label - newNode = RIBNode () - self.copySetup ( newNode ) - return newNode - # - # parseLocalVars - # - def parseLocalVars ( self, parsedStr, CodeOnly = False ) : - #print '-> parseLocalVars in %s' % parsedStr - resultStr = '' - parserStart = 0 - parserPos = 0 - - while parserPos != -1 : - parserPos = parsedStr.find ( '$', parserStart ) - if parserPos != -1 : - # - if parserPos != 0 : - resultStr += parsedStr [ parserStart : parserPos ] - - # check local variables - if parsedStr [ ( parserPos + 1 ) : ( parserPos + 2 ) ] == '(' : - globStart = parserPos + 2 - parserPos = parsedStr.find ( ')', globStart ) - local_var_name = parsedStr [ globStart : ( parserPos ) ] - - # print '-> found local var %s' % local_var_name - - param = self.getInputParamByName ( local_var_name ) - if param is not None : - value = self.getInputParamValueByName ( local_var_name, CodeOnly ) - resultStr += value - else : - param = self.getOutputParamByName ( local_var_name ) - if param is not None : - resultStr += param.getValueToStr () - else : - print '!! local var %s is not defined !' % local_var_name - else : - # keep $ sign for otheer, non $(...) cases - resultStr += '$' - - #print 'parserPos = %d parserStart = %d' % ( parserPos, parserStart ) - if parserPos != -1 : - parserStart = parserPos + 1 - - resultStr += parsedStr [ parserStart: ] - - if resultStr != '' : - resultStr = self.getHeader () + resultStr - - return resultStr - # - # getInputParamValueByName - # - def getInputParamValueByName ( self, name, CodeOnly = False ) : - # - result = None - srcNode = srcParam = None - param = self.getInputParamByName ( name ) - ( srcNode, srcParam ) = self.getLinkedSrcNode ( param ) - if srcNode is not None : - srcNode.computeNode ( CodeOnly ) - #if self.computed_code is not None : - # self.computed_code += link.srcNode.computed_code - - if srcNode.type in [ 'rib', 'rib_code' ] : - #result = '## start code from :' + link.srcNode.label - result = srcNode.parseLocalVars ( srcNode.code, CodeOnly ) - #result += '## end code from :' + link.srcNode.label - else : - result = srcNode.parseGlobalVars ( srcParam.getValueToStr () ) - else : - result = param.getValueToStr () - - return result - # - # getHeader - # - def getHeader ( self ) : - # - ribHeader = '#\n' - ribHeader += '# %s\n' % ( self.getInstanceName () + '.rib' ) - ribHeader += '# Generated by meShaderEd ver.${version}\n' - ribHeader += '#\n\n' - return ribHeader - # - # getComputedCode - # - def getComputedCode ( self, CodeOnly = False ) : - # - computedCode = '' - - self.execControlCode () - - computedCode = self.parseLocalVars ( self.code, CodeOnly ) - computedCode = self.parseGlobalVars ( computedCode ) - - return computedCode - # - # writeRIB - # - def writeRIB ( self, ribCode, ribName ) : - # - self.ribName = normPath ( ribName ) - f = open ( self.ribName, 'w+t' ) - f.write ( ribCode ) - f.close () - # - # renderRIB - # - def renderRIB ( self ) : - # - #from meShaderEd import app_renderer - - renderer = app_global_vars [ 'RendererName' ] - flags = app_global_vars [ 'RendererFlags' ] - renderCmd = [ renderer ] - if flags != '' : renderCmd.append ( flags ) - renderCmd.append ( self.ribName ) - - print '>> RIBNode renderCmd = %s' % ' '.join ( renderCmd ) - - # call the process - from core.meCommon import launchProcess - - launchProcess ( renderCmd ) - # - # computeNode - # - def computeNode ( self, CodeOnly = False ) : - # - ribCode = self.getComputedCode ( CodeOnly ) - - if ribCode != '' and not CodeOnly : - - ribName = os.path.join ( app_global_vars [ 'TempPath' ], self.getNodenetName () + '_' + self.getInstanceName () + '.rib' ) - self.writeRIB ( ribCode, ribName ) - self.renderRIB () - - return self.ribName - + # + # __init__ + # + def __init__ ( self, xml_node = None ) : + # + Node.__init__ ( self, xml_node ) + self.ribName = '' + # + # copy + # + def copy ( self ) : + # + if DEBUG_MODE : print '>> RIBNode( %s ).copy' % self.label + newNode = RIBNode () + self.copySetup ( newNode ) + return newNode + # + # parseLocalVars + # + def parseLocalVars ( self, parsedStr, CodeOnly = False ) : + #print '-> parseLocalVars in %s' % parsedStr + resultStr = '' + parserStart = 0 + parserPos = 0 + + while parserPos != -1 : + parserPos = parsedStr.find ( '$', parserStart ) + if parserPos != -1 : + # + if parserPos != 0 : + resultStr += parsedStr [ parserStart : parserPos ] + + # check local variables + if parsedStr [ ( parserPos + 1 ) : ( parserPos + 2 ) ] == '(' : + globStart = parserPos + 2 + parserPos = parsedStr.find ( ')', globStart ) + local_var_name = parsedStr [ globStart : ( parserPos ) ] + + # print '-> found local var %s' % local_var_name + + param = self.getInputParamByName ( local_var_name ) + if param is not None : + value = self.getInputParamValueByName ( local_var_name, CodeOnly ) + resultStr += value + else : + param = self.getOutputParamByName ( local_var_name ) + if param is not None : + resultStr += param.getValueToStr () + else : + print '!! local var %s is not defined !' % local_var_name + else : + # keep $ sign for otheer, non $(...) cases + resultStr += '$' + + #print 'parserPos = %d parserStart = %d' % ( parserPos, parserStart ) + if parserPos != -1 : + parserStart = parserPos + 1 + + resultStr += parsedStr [ parserStart: ] + + if resultStr != '' : + resultStr = self.getHeader () + resultStr + + return resultStr + # + # getInputParamValueByName + # + def getInputParamValueByName ( self, name, CodeOnly = False ) : + # + result = None + srcNode = srcParam = None + param = self.getInputParamByName ( name ) + ( srcNode, srcParam ) = self.getLinkedSrcNode ( param ) + if srcNode is not None : + srcNode.computeNode ( CodeOnly ) + #if self.computed_code is not None : + # self.computed_code += link.srcNode.computed_code + + if srcNode.type in [ 'rib', 'rib_code' ] : + #result = '## start code from :' + link.srcNode.label + result = srcNode.parseLocalVars ( srcNode.code, CodeOnly ) + #result += '## end code from :' + link.srcNode.label + else : + result = srcNode.parseGlobalVars ( srcParam.getValueToStr () ) + else : + result = param.getValueToStr () + + return result + # + # getHeader + # + def getHeader ( self ) : + # + ribHeader = '#\n' + ribHeader += '# %s\n' % ( self.getInstanceName () + '.rib' ) + ribHeader += '# Generated by meShaderEd ver.${version}\n' + ribHeader += '#\n\n' + return ribHeader + # + # getComputedCode + # + def getComputedCode ( self, CodeOnly = False ) : + # + computedCode = '' + + self.execControlCode () + + computedCode = self.parseLocalVars ( self.code, CodeOnly ) + computedCode = self.parseGlobalVars ( computedCode ) + + return computedCode + # + # writeRIB + # + def writeRIB ( self, ribCode, ribName ) : + # + self.ribName = normPath ( ribName ) + f = open ( self.ribName, 'w+t' ) + f.write ( ribCode ) + f.close () + # + # renderRIB + # + def renderRIB ( self ) : + # + #from meShaderEd import app_renderer + + renderer = app_global_vars [ 'RendererName' ] + flags = app_global_vars [ 'RendererFlags' ] + renderCmd = [ renderer ] + if flags != '' : renderCmd.append ( flags ) + renderCmd.append ( self.ribName ) + + print '>> RIBNode renderCmd = %s' % ' '.join ( renderCmd ) + + # call the process + from core.meCommon import launchProcess + + launchProcess ( renderCmd ) + # + # computeNode + # + def computeNode ( self, CodeOnly = False ) : + # + ribCode = self.getComputedCode ( CodeOnly ) + + if ribCode != '' and not CodeOnly : + + ribName = os.path.join ( app_global_vars [ 'TempPath' ], self.getNodenetName () + '_' + self.getInstanceName () + '.rib' ) + self.writeRIB ( ribCode, ribName ) + self.renderRIB () + + return self.ribName + diff --git a/core/nodes/rslNode.py b/core/nodes/rslNode.py index f3c0ed3..084aea0 100644 --- a/core/nodes/rslNode.py +++ b/core/nodes/rslNode.py @@ -7,7 +7,7 @@ """ import os, sys -from PyQt4 import QtCore +from core.mePyQt import QtCore from core.node import Node from core.nodeParam import NodeParam @@ -19,282 +19,282 @@ # RSLNode # class RSLNode ( Node ) : - # - # __init__ - # - def __init__ ( self, xml_node = None ) : - # - Node.__init__ ( self, xml_node ) - self.shaderName = '' - # - # copy - # - def copy ( self ) : - if DEBUG_MODE : print '>> RSLNode( %s ).copy' % self.label - newNode = RSLNode () - self.copySetup ( newNode ) - return newNode - # - # collectComputed - # - def collectComputed ( self, computedCode, visitedNodes, CodeOnly = False ) : - # - self.computedInputParamsList = [] - self.computedOutputParamsList = [] - self.computedLocalParamsList = [] - self.computedIncludesList = [] + # + # __init__ + # + def __init__ ( self, xml_node = None ) : + # + Node.__init__ ( self, xml_node ) + self.shaderName = '' + # + # copy + # + def copy ( self ) : + if DEBUG_MODE : print '>> RSLNode( %s ).copy' % self.label + newNode = RSLNode () + self.copySetup ( newNode ) + return newNode + # + # collectComputed + # + def collectComputed ( self, computedCode, visitedNodes, CodeOnly = False ) : + # + self.computedInputParamsList = [] + self.computedOutputParamsList = [] + self.computedLocalParamsList = [] + self.computedIncludesList = [] - for param in self.inputParams : - ( srcNode, srcParam ) = self.getLinkedSrcNode ( param ) - if srcNode is not None : - if not srcNode in visitedNodes : - computedCode = srcNode.collectComputed ( computedCode, visitedNodes, CodeOnly ) + for param in self.inputParams : + ( srcNode, srcParam ) = self.getLinkedSrcNode ( param ) + if srcNode is not None : + if not srcNode in visitedNodes : + computedCode = srcNode.collectComputed ( computedCode, visitedNodes, CodeOnly ) - self.computedInputParamsList = srcNode.computedInputParamsList + self.computedInputParamsList - self.computedLocalParamsList = srcNode.computedLocalParamsList + self.computedLocalParamsList - self.computedOutputParamsList += srcNode.computedOutputParamsList - self.computedIncludesList += srcNode.computedIncludesList + self.computedInputParamsList = srcNode.computedInputParamsList + self.computedInputParamsList + self.computedLocalParamsList = srcNode.computedLocalParamsList + self.computedLocalParamsList + self.computedOutputParamsList += srcNode.computedOutputParamsList + self.computedIncludesList += srcNode.computedIncludesList - else : - if param.shaderParam : - self.computedInputParamsList.append ( ( param, self ) ) # += declare - else : - self.computedLocalParamsList.append ( ( param, self ) ) # += declare + else : + if param.shaderParam : + self.computedInputParamsList.append ( ( param, self ) ) # += declare + else : + self.computedLocalParamsList.append ( ( param, self ) ) # += declare - for param in self.outputParams : - if not param.type in ['rib', 'surface', 'displacement', 'light', 'volume'] : - if param.provider == 'primitive' or param.shaderParam : - self.computedOutputParamsList.append ( ( param, self ) ) # += ( 'output ' + declare ) - else : - self.computedLocalParamsList.append ( ( param, self ) ) # += declare + for param in self.outputParams : + if not param.type in ['rib', 'surface', 'displacement', 'light', 'volume'] : + if param.provider == 'primitive' or param.shaderParam : + self.computedOutputParamsList.append ( ( param, self ) ) # += ( 'output ' + declare ) + else : + self.computedLocalParamsList.append ( ( param, self ) ) # += declare - for inc_name in self.includes : - self.computedIncludesList.append ( inc_name ) + for inc_name in self.includes : + self.computedIncludesList.append ( inc_name ) - visitedNodes.add ( self ) + visitedNodes.add ( self ) - if self.code is not None : - node_code = str ( self.parseLocalVars ( self.code ) ) - - if self.type in [ 'surface', 'displacement', 'light', 'volume' ] : - # find begin block position '{' for inserting computed code - block_begin_pos = 0 - parserStart = 0 - parserPos = 0 - - while parserPos != -1 : - parserPos = node_code.find ( '{', parserStart ) - if parserPos != -1 : - # skip global vars case defined as ${VARNAME} - if node_code[ parserPos-1:parserPos ] != '$' : - block_begin_pos = parserPos + 1 - break - parserStart = parserPos + 1 - - #print '> Code insert position = %d' % block_begin_pos - #print '> insert code at %s' % node_code[ block_begin_pos: ] - - begin_code = node_code [ 0:block_begin_pos ] - end_code = node_code[ block_begin_pos + 1 : ] - - shaderCode = self.getHeader () - shaderCode += begin_code + '\n' - shaderCode += self.getComputedLocals () - shaderCode += computedCode - shaderCode += end_code - else : - shaderCode = computedCode + self.getHeader () + node_code - - return shaderCode - # - # RSL specific parser - # - def parseLocalVars ( self, parsedStr ) : - # - resultStr = '' - parserStart = 0 - parserPos = 0 + if self.code is not None : + node_code = str ( self.parseLocalVars ( self.code ) ) + + if self.type in [ 'surface', 'displacement', 'light', 'volume' ] : + # find begin block position '{' for inserting computed code + block_begin_pos = 0 + parserStart = 0 + parserPos = 0 + + while parserPos != -1 : + parserPos = node_code.find ( '{', parserStart ) + if parserPos != -1 : + # skip global vars case defined as ${VARNAME} + if node_code[ parserPos-1:parserPos ] != '$' : + block_begin_pos = parserPos + 1 + break + parserStart = parserPos + 1 + + #print '> Code insert position = %d' % block_begin_pos + #print '> insert code at %s' % node_code[ block_begin_pos: ] + + begin_code = node_code [ 0:block_begin_pos ] + end_code = node_code[ block_begin_pos + 1 : ] + + shaderCode = self.getHeader () + shaderCode += begin_code + '\n' + shaderCode += self.getComputedLocals () + shaderCode += computedCode + shaderCode += end_code + else : + shaderCode = computedCode + self.getHeader () + node_code + + return shaderCode + # + # RSL specific parser + # + def parseLocalVars ( self, parsedStr ) : + # + resultStr = '' + parserStart = 0 + parserPos = 0 - while parserPos != -1 : - parserPos = parsedStr.find ( '$', parserStart ) - if parserPos != -1 : - # - if parserPos != 0 : - resultStr += parsedStr [ parserStart : parserPos ] + while parserPos != -1 : + parserPos = parsedStr.find ( '$', parserStart ) + if parserPos != -1 : + # + if parserPos != 0 : + resultStr += parsedStr [ parserStart : parserPos ] - # check local variables - if parsedStr [ ( parserPos + 1 ) : ( parserPos + 2 ) ] == '(' : - globStart = parserPos + 2 - parserPos = parsedStr.find ( ')', globStart ) - local_var_name = parsedStr [ globStart : ( parserPos ) ] + # check local variables + if parsedStr [ ( parserPos + 1 ) : ( parserPos + 2 ) ] == '(' : + globStart = parserPos + 2 + parserPos = parsedStr.find ( ')', globStart ) + local_var_name = parsedStr [ globStart : ( parserPos ) ] - #print '> Node(%s).parseLocalVars: found local var %s' % ( self.label, local_var_name ) - # - # check if variable is input parameter name - # - param = self.getInputParamByName ( local_var_name ) - if param is not None : - ( srcNode, srcParam ) = self.getLinkedSrcNode ( param ) - if srcNode is not None : - resultStr += srcNode.getParamName ( srcParam ) - else : - resultStr += self.getParamName ( param ) - else : - # - # check if variable is output parameter name - # - param = self.getOutputParamByName ( local_var_name ) - if param is not None : - resultStr += self.getParamName ( param ) - else : - # - # check if this is just local variable - # - if local_var_name in self.internals : - resultStr += self.getInstanceName () + '_' + local_var_name - else : - print '> Node(%s).parseLocalVars: ERROR. Local var %s is not defined !' % ( self.label, local_var_name ) - else : - # keep $ sign for otheer, non $(...) cases - resultStr += '$' + #print '> Node(%s).parseLocalVars: found local var %s' % ( self.label, local_var_name ) + # + # check if variable is input parameter name + # + param = self.getInputParamByName ( local_var_name ) + if param is not None : + ( srcNode, srcParam ) = self.getLinkedSrcNode ( param ) + if srcNode is not None : + resultStr += srcNode.getParamName ( srcParam ) + else : + resultStr += self.getParamName ( param ) + else : + # + # check if variable is output parameter name + # + param = self.getOutputParamByName ( local_var_name ) + if param is not None : + resultStr += self.getParamName ( param ) + else : + # + # check if this is just local variable + # + if local_var_name in self.internals : + resultStr += self.getInstanceName () + '_' + local_var_name + else : + print '> Node(%s).parseLocalVars: ERROR. Local var %s is not defined !' % ( self.label, local_var_name ) + else : + # keep $ sign for otheer, non $(...) cases + resultStr += '$' - #print 'parserPos = %d parserStart = %d' % ( parserPos, parserStart ) - if parserPos != -1 : - parserStart = parserPos + 1 + #print 'parserPos = %d parserStart = %d' % ( parserPos, parserStart ) + if parserPos != -1 : + parserStart = parserPos + 1 - resultStr += parsedStr [ parserStart: ] + resultStr += parsedStr [ parserStart: ] - return resultStr - # - # getComputedInputParams - # called from Node.parseGlobalVars - # - def getComputedInputParams ( self ) : - # - params_set = set () - params_str = '' - for ( param, node ) in self.computedInputParamsList : - params_set.add ( node.getParamDeclaration ( param ) ) - # getting rid from duplicates - for param in params_set : - params_str += param - return params_str - # - # getComputedOutputParams - # called from Node.parseGlobalVars - # - def getComputedOutputParams ( self ) : - # - params_set = set () - params_str = '' - for ( param, node ) in self.computedOutputParamsList : - params_set.add ( 'output ' + node.getParamDeclaration ( param ) ) - # getting rid from duplicates - for param in params_set : - params_str += param - return params_str - # - # getComputedLocals - # - def getComputedLocals ( self ) : - # - params_str = '' - for ( param, node ) in self.computedLocalParamsList : - params_str += node.getParamDeclaration ( param ) - return params_str - # - # getHeader - # - def getHeader ( self ) : - # - if self.type in VALID_RSL_SHADER_TYPES : - rslHeader = '/*\n' - rslHeader += ' * %s\n' % ( self.getInstanceName () + '.sl' ) - rslHeader += ' * Generated by meShaderEd ver.${version}\n' - rslHeader += ' */\n\n' - # includes are stored in set to prevent duplication - for include in set ( self.computedIncludesList ) : - rslHeader += '#include \"' + include + '\"\n' - else : - rslHeader = '\n' - rslHeader += '/*\n' - rslHeader += ' * RSL code node: %s (%s)\n' % ( self.label, self.name ) - rslHeader += ' */\n' - - return rslHeader - # - # getComputedCode - # - def getComputedCode ( self, CodeOnly = False ) : - # - computedCode = '' - - self.execControlCode () + return resultStr + # + # getComputedInputParams + # called from Node.parseGlobalVars + # + def getComputedInputParams ( self ) : + # + params_set = set () + params_str = '' + for ( param, node ) in self.computedInputParamsList : + params_set.add ( node.getParamDeclaration ( param ) ) + # getting rid from duplicates + for param in params_set : + params_str += param + return params_str + # + # getComputedOutputParams + # called from Node.parseGlobalVars + # + def getComputedOutputParams ( self ) : + # + params_set = set () + params_str = '' + for ( param, node ) in self.computedOutputParamsList : + params_set.add ( 'output ' + node.getParamDeclaration ( param ) ) + # getting rid from duplicates + for param in params_set : + params_str += param + return params_str + # + # getComputedLocals + # + def getComputedLocals ( self ) : + # + params_str = '' + for ( param, node ) in self.computedLocalParamsList : + params_str += node.getParamDeclaration ( param ) + return params_str + # + # getHeader + # + def getHeader ( self ) : + # + if self.type in VALID_RSL_SHADER_TYPES : + rslHeader = '/*\n' + rslHeader += ' * %s\n' % ( self.getInstanceName () + '.sl' ) + rslHeader += ' * Generated by meShaderEd ver.${version}\n' + rslHeader += ' */\n\n' + # includes are stored in set to prevent duplication + for include in set ( self.computedIncludesList ) : + rslHeader += '#include \"' + include + '\"\n' + else : + rslHeader = '\n' + rslHeader += '/*\n' + rslHeader += ' * RSL code node: %s (%s)\n' % ( self.label, self.name ) + rslHeader += ' */\n' + + return rslHeader + # + # getComputedCode + # + def getComputedCode ( self, CodeOnly = False ) : + # + computedCode = '' + + self.execControlCode () - self.visitedNodes = set () + self.visitedNodes = set () - computedCode = self.collectComputed ( computedCode, self.visitedNodes, CodeOnly ) - computedCode = self.parseGlobalVars ( computedCode ) - - return computedCode - # - # writeShader - # - def writeShader ( self, shaderCode, shaderName ) : - # - self.shaderName = normPath ( shaderName ) - f = open ( self.shaderName, 'w+t' ) - f.write ( shaderCode ) - f.close () - # - # compileShader - # - def compileShader ( self, compileDir = '' ) : - # - #from meShaderEd import app_renderer - - compiler = app_global_vars [ 'ShaderCompiler' ] - defines_str = app_global_vars [ 'ShaderDefines' ] - includes_str = app_global_vars [ 'IncludePath' ] + computedCode = self.collectComputed ( computedCode, self.visitedNodes, CodeOnly ) + computedCode = self.parseGlobalVars ( computedCode ) + + return computedCode + # + # writeShader + # + def writeShader ( self, shaderCode, shaderName ) : + # + self.shaderName = normPath ( shaderName ) + f = open ( self.shaderName, 'w+t' ) + f.write ( shaderCode ) + f.close () + # + # compileShader + # + def compileShader ( self, compileDir = '' ) : + # + #from meShaderEd import app_renderer + + compiler = app_global_vars [ 'ShaderCompiler' ] + defines_str = app_global_vars [ 'ShaderDefines' ] + includes_str = app_global_vars [ 'IncludePath' ] - shaderCmd = [ compiler ] + shaderCmd = [ compiler ] - if includes_str != '' : - includes_lst = includes_str.split ( ',' ) - for include in includes_lst : - shaderCmd.append ( '-I' + include.strip () ) + if includes_str != '' : + includes_lst = includes_str.split ( ',' ) + for include in includes_lst : + shaderCmd.append ( '-I' + include.strip () ) - if defines_str != '' : - defines_lst = defines_str.split( ',' ) - for define in defines_lst : - shaderCmd.append ( '-D' + define.strip () ) - - shaderCmd.append ( self.shaderName ) + if defines_str != '' : + defines_lst = defines_str.split( ',' ) + for define in defines_lst : + shaderCmd.append ( '-D' + define.strip () ) + + shaderCmd.append ( self.shaderName ) - if compileDir == '' : compileDir = app_global_vars[ 'ProjectShaders' ] - os.chdir ( compileDir ) + if compileDir == '' : compileDir = app_global_vars[ 'ProjectShaders' ] + os.chdir ( compileDir ) - print '>> RSLNode shaderCmd = %s' % ' '.join ( shaderCmd ) - print '>> compileDir = %s' % compileDir + print '>> RSLNode shaderCmd = %s' % ' '.join ( shaderCmd ) + print '>> compileDir = %s' % compileDir - from core.meCommon import launchProcess + from core.meCommon import launchProcess - launchProcess ( shaderCmd ) - - # - # computeNode - # - def computeNode ( self, CodeOnly = False ) : - # - print '>> RSLNode (%s).computeNode CodeOnly = %s' % ( self.label, CodeOnly ) - # - shaderCode = self.getComputedCode () - - if shaderCode != '' and not CodeOnly : - - shaderName = os.path.join ( app_global_vars [ 'ProjectSources' ], self.getInstanceName () + '.sl' ) - self.writeShader ( shaderCode, shaderName ) - self.compileShader () - - return self.shaderName + launchProcess ( shaderCmd ) + + # + # computeNode + # + def computeNode ( self, CodeOnly = False ) : + # + print '>> RSLNode (%s).computeNode CodeOnly = %s' % ( self.label, CodeOnly ) + # + shaderCode = self.getComputedCode () + + if shaderCode != '' and not CodeOnly : + + shaderName = os.path.join ( app_global_vars [ 'ProjectSources' ], self.getInstanceName () + '.sl' ) + self.writeShader ( shaderCode, shaderName ) + self.compileShader () + + return self.shaderName diff --git a/core/nodes/swatchNode.py b/core/nodes/swatchNode.py index 0fc5c30..b01a167 100644 --- a/core/nodes/swatchNode.py +++ b/core/nodes/swatchNode.py @@ -1,46 +1,45 @@ -#=============================================================================== -# swatchNode.py -#=============================================================================== -import os, sys -from PyQt4 import QtCore +""" + + swatchNode.py + +""" +from core.mePyQt import QtCore from core.node import Node from core.nodeParam import NodeParam from core.nodes.imageNode import ImageNode from global_vars import app_global_vars, DEBUG_MODE - import gui.ui_settings as UI - # # SwatchNode # class SwatchNode ( ImageNode ) : - # - # __init__ - # - def __init__ ( self, xml_node = None ) : - # - ImageNode.__init__ ( self, xml_node ) - - self.size = UI.SWATCH_SIZE - if DEBUG_MODE : print '>> SwatchNode( %s ).__init__' % self.label - # - # copy - # - def copy ( self ) : - # - if DEBUG_MODE : print '>> SwatchNode( %s ).copy' % self.label - newNode = SwatchNode () - self.copySetup ( newNode ) - return newNode - # - # computeNode - # - def computeNode ( self ) : - # - if DEBUG_MODE : print '>> SwatchNode( %s ).computeNode' % self.label - # inside control_code, imageName value can be assigned from different - # input parameters - self.execControlCode () - return self.imageName + # + # __init__ + # + def __init__ ( self, xml_node = None ) : + # + ImageNode.__init__ ( self, xml_node ) + + self.size = UI.SWATCH_SIZE + if DEBUG_MODE : print '>> SwatchNode( %s ).__init__' % self.label + # + # copy + # + def copy ( self ) : + # + if DEBUG_MODE : print '>> SwatchNode( %s ).copy' % self.label + newNode = SwatchNode () + self.copySetup ( newNode ) + return newNode + # + # computeNode + # + def computeNode ( self ) : + # + if DEBUG_MODE : print '>> SwatchNode( %s ).computeNode' % self.label + # inside control_code, imageName value can be assigned from different + # input parameters + self.execControlCode () + return self.imageName diff --git a/core/params/colorNodeParam.py b/core/params/colorNodeParam.py index 20b26c0..156d6e6 100644 --- a/core/params/colorNodeParam.py +++ b/core/params/colorNodeParam.py @@ -1,141 +1,141 @@ -#=============================================================================== -# colorNodeParam.py -#=============================================================================== -import os, sys -import re +""" + + colorNodeParam.py -from PyQt4 import QtCore +""" +import re from core.node import Node from core.nodeParam import NodeParam + from global_vars import app_global_vars, DEBUG_MODE from core.meCommon import parseGlobalVars # # Color # class ColorNodeParam ( NodeParam ) : - # - # __init__ - # - def __init__ ( self, xml_param = None, isRibParam = False ) : - # - NodeParam.__init__ ( self, xml_param, isRibParam ) - self.type = 'color' - # - # encodedTypeStr - # - def encodedTypeStr ( self ) : return 'c' - # - # copy - # - def copy ( self ) : - # - newParam = ColorNodeParam () - self.copySetup ( newParam ) - return newParam - # - # valueFromStr - # - def valueFromStr ( self, strValue ) : - # - if self.isRibParam : - return self.valueFromRIB ( strValue ) - else : - return self.valueFromRSL ( strValue ) - # - # valueFromRSL - # - def valueFromRSL ( self, strValue ) : - # - value = [ 0.0, 0.0, 0.0 ] + # + # __init__ + # + def __init__ ( self, xml_param = None, isRibParam = False ) : + # + NodeParam.__init__ ( self, xml_param, isRibParam ) + self.type = 'color' + # + # encodedTypeStr + # + def encodedTypeStr ( self ) : return 'c' + # + # copy + # + def copy ( self ) : + # + newParam = ColorNodeParam () + self.copySetup ( newParam ) + return newParam + # + # valueFromStr + # + def valueFromStr ( self, strValue ) : + # + if self.isRibParam : + return self.valueFromRIB ( strValue ) + else : + return self.valueFromRSL ( strValue ) + # + # valueFromRSL + # + def valueFromRSL ( self, strValue ) : + # + value = [ 0.0, 0.0, 0.0 ] - if strValue != '' : - strValue = strValue.replace ( ' ', '' ) - color3_pattern_str = 'color\(([+]?([0-9]*\.)?[0-9]+,){2}[+]?([0-9]*\.)?[0-9]+\)' - color1_pattern_str = 'color\(([+]?([0-9]*\.)?[0-9]+\))' - color3_space_pattern_str = 'color"[A-z]*"\(([+]?([0-9]*\.)?[0-9]+,){2}[+]?([0-9]*\.)?[0-9]+\)' - color1_space_pattern_str = 'color"[A-z]*"\(([+]?([0-9]*\.)?[0-9]+\))' - float_pattern_str = '[+]?[0-9]*\.?[0-9]+' - space_pattern_str = '"[A-z]*"' + if strValue != '' : + strValue = strValue.replace ( ' ', '' ) + color3_pattern_str = 'color\(([+]?([0-9]*\.)?[0-9]+,){2}[+]?([0-9]*\.)?[0-9]+\)' + color1_pattern_str = 'color\(([+]?([0-9]*\.)?[0-9]+\))' + color3_space_pattern_str = 'color"[A-z]*"\(([+]?([0-9]*\.)?[0-9]+,){2}[+]?([0-9]*\.)?[0-9]+\)' + color1_space_pattern_str = 'color"[A-z]*"\(([+]?([0-9]*\.)?[0-9]+\))' + float_pattern_str = '[+]?[0-9]*\.?[0-9]+' + space_pattern_str = '"[A-z]*"' - p = re.compile ( color3_pattern_str ) - match = p.match ( strValue ) - if match : - p = re.compile ( float_pattern_str ) - f = p.findall ( strValue ) - f = map ( float, f ) - value = [ f [0], f [1], f [2] ] - else : - p = re.compile ( color1_pattern_str ) - match = p.match( strValue ) - if match : - p = re.compile ( float_pattern_str ) - f = p.findall( strValue ) - f = map ( float, f ) - value = [ f [0], f [0], f [0] ] - else : - p = re.compile ( color3_space_pattern_str ) - match = p.match( strValue ) - if match : - p = re.compile ( float_pattern_str ) - f = p.findall ( strValue ) - f = map ( float, f ) - value = [ f [0], f [1], f [2] ] + p = re.compile ( color3_pattern_str ) + match = p.match ( strValue ) + if match : + p = re.compile ( float_pattern_str ) + f = p.findall ( strValue ) + f = map ( float, f ) + value = [ f [0], f [1], f [2] ] + else : + p = re.compile ( color1_pattern_str ) + match = p.match( strValue ) + if match : + p = re.compile ( float_pattern_str ) + f = p.findall( strValue ) + f = map ( float, f ) + value = [ f [0], f [0], f [0] ] + else : + p = re.compile ( color3_space_pattern_str ) + match = p.match( strValue ) + if match : + p = re.compile ( float_pattern_str ) + f = p.findall ( strValue ) + f = map ( float, f ) + value = [ f [0], f [1], f [2] ] - p = re.compile ( space_pattern_str ) - s = p.findall ( strValue ) - self.space = s [0].strip ( '"' ) - else : - p = re.compile ( color1_space_pattern_str ) - match = p.match( strValue ) - if match : - p = re.compile ( float_pattern_str ) - f = p.findall ( strValue ) - f = map ( float, f ) - value = [ f [0], f [0], f [0] ] + p = re.compile ( space_pattern_str ) + s = p.findall ( strValue ) + self.space = s [0].strip ( '"' ) + else : + p = re.compile ( color1_space_pattern_str ) + match = p.match( strValue ) + if match : + p = re.compile ( float_pattern_str ) + f = p.findall ( strValue ) + f = map ( float, f ) + value = [ f [0], f [0], f [0] ] - p = re.compile ( space_pattern_str ) - s = p.findall ( strValue ) - self.space = s [0].strip ( '"' ) - else : - err = 'Cannot parse color %s values' % self.name - raise Exception ( err ) - return value - # - # valueFromRIB - # - def valueFromRIB ( self, strValue ) : - # - value = [ 0.0, 0.0, 0.0 ] + p = re.compile ( space_pattern_str ) + s = p.findall ( strValue ) + self.space = s [0].strip ( '"' ) + else : + err = 'Cannot parse color %s values' % self.name + raise Exception ( err ) + return value + # + # valueFromRIB + # + def valueFromRIB ( self, strValue ) : + # + value = [ 0.0, 0.0, 0.0 ] - if strValue != '' : - #str = str.replace( ' ', '' ) - color_values = strValue.split ( ' ' ) - f = map ( float, color_values ) - value = [ f [0], f [1], f [2] ] - return value - # - # valueToStr - # - def valueToStr ( self, value ) : - # - if self.isRibParam : - return self.getValueToRIB ( value ) - else : - return self.getValueToRSL ( value ) - # - # getValueToRSL - # - def getValueToRSL ( self, value ) : - # - ret_str = 'color' - if self.space != None : - if self.space != '' : - ret_str += ' "' + self.space + '" ' - return ret_str + '(' + ''.join ( '%.3f' % f + ',' for f in value [: - 1] ) + '%.3f' % value [ - 1] + ')' - # - # getValueToRIB - # - def getValueToRIB ( self, value ) : - # - return ''.join ( '%.3f' % f + ' ' for f in value [: - 1] ) + '%.3f' % value [ - 1] + if strValue != '' : + #str = str.replace( ' ', '' ) + color_values = strValue.split ( ' ' ) + f = map ( float, color_values ) + value = [ f [0], f [1], f [2] ] + return value + # + # valueToStr + # + def valueToStr ( self, value ) : + # + if self.isRibParam : + return self.getValueToRIB ( value ) + else : + return self.getValueToRSL ( value ) + # + # getValueToRSL + # + def getValueToRSL ( self, value ) : + # + ret_str = 'color' + if self.space != None : + if self.space != '' : + ret_str += ' "' + self.space + '" ' + return ret_str + '(' + ''.join ( '%.3f' % f + ',' for f in value [: - 1] ) + '%.3f' % value [ - 1] + ')' + # + # getValueToRIB + # + def getValueToRIB ( self, value ) : + # + return ''.join ( '%.3f' % f + ' ' for f in value [: - 1] ) + '%.3f' % value [ - 1] diff --git a/core/params/controlParam.py b/core/params/controlParam.py index 712ade8..3cdf5d4 100644 --- a/core/params/controlParam.py +++ b/core/params/controlParam.py @@ -1,127 +1,128 @@ -#=============================================================================== -# controlParam.py -#=============================================================================== -import os, sys +""" + + controlParam.py + +""" import re import copy -from PyQt4 import QtCore from core.node import Node from core.nodeParam import NodeParam + from global_vars import app_global_vars, DEBUG_MODE from core.meCommon import parseGlobalVars # # ControlParam # class ControlParam ( NodeParam ) : - # - # __init__ - # - def __init__ ( self, xml_param = None, isRibParam = False ) : - # - self.btext = '' # button text - self.type = 'control' - self.code = '' - NodeParam.__init__ ( self, xml_param, isRibParam ) + # + # __init__ + # + def __init__ ( self, xml_param = None, isRibParam = False ) : + # + self.btext = '' # button text + self.type = 'control' + self.code = '' + NodeParam.__init__ ( self, xml_param, isRibParam ) - if DEBUG_MODE : print '>> ControlParam ( %s ).__init__ btext = "%s"' % ( self.label, self.btext ) - # - # encodedTypeStr - # - def encodedTypeStr ( self ) : return 'l' - # - # copy - # - def copy ( self ) : - # - newParam = ControlParam () - self.copySetup ( newParam ) - return newParam - # - # copySetup - # - def copySetup ( self, newParam ) : - # - if DEBUG_MODE : print '>> ControlParam ( %s ).copySetup' % self.label - NodeParam.copySetup ( self, newParam ) - newParam.code = self.code - newParam.btext = self.btext - # - # valueFromStr - # - def valueFromStr ( self, str ) : return str - # - # valueToStr - # - def valueToStr ( self, value ) : - # - ret_str = str ( value ) - if not self.isRibParam : ret_str = str ( "\"" + value + "\"" ) - return ret_str - # - # getRangeValues - # - # if subtype == selector then return list of (label,value) pairs - # It's supposed, that range is defined as "value1:value2:value3" - # or "label1=value1:label2=value2:label3=value3:" - # - def getRangeValues ( self ) : - # - rangeList = [] + if DEBUG_MODE : print '>> ControlParam ( %s ).__init__ btext = "%s"' % ( self.label, self.btext ) + # + # encodedTypeStr + # + def encodedTypeStr ( self ) : return 'l' + # + # copy + # + def copy ( self ) : + # + newParam = ControlParam () + self.copySetup ( newParam ) + return newParam + # + # copySetup + # + def copySetup ( self, newParam ) : + # + if DEBUG_MODE : print '>> ControlParam ( %s ).copySetup' % self.label + NodeParam.copySetup ( self, newParam ) + newParam.code = self.code + newParam.btext = self.btext + # + # valueFromStr + # + def valueFromStr ( self, str ) : return str + # + # valueToStr + # + def valueToStr ( self, value ) : + # + ret_str = str ( value ) + if not self.isRibParam : ret_str = str ( "\"" + value + "\"" ) + return ret_str + # + # getRangeValues + # + # if subtype == selector then return list of (label,value) pairs + # It's supposed, that range is defined as "value1:value2:value3" + # or "label1=value1:label2=value2:label3=value3:" + # + def getRangeValues ( self ) : + # + rangeList = [] - if self.range != '' : # and self.subtype == 'selector': - tmp_list = str ( self.range ).split ( ':' ) - for s in tmp_list : - pair = s.split ( '=' ) - if len ( pair ) > 1 : - label = pair [0] - value = pair [1] - else : - label = s - value = s - rangeList.append ( ( parseGlobalVars ( label ), parseGlobalVars ( value ) ) ) - return rangeList - # - # parseFromXML - # - def parseFromXML ( self, xml_param ) : - # - if DEBUG_MODE : print '>> ControlParam ( %s ).parseFromXML' % self.label - NodeParam.parseFromXML ( self, xml_param ) + if self.range != '' : # and self.subtype == 'selector': + tmp_list = str ( self.range ).split ( ':' ) + for s in tmp_list : + pair = s.split ( '=' ) + if len ( pair ) > 1 : + label = pair [0] + value = pair [1] + else : + label = s + value = s + rangeList.append ( ( parseGlobalVars ( label ), parseGlobalVars ( value ) ) ) + return rangeList + # + # parseFromXML + # + def parseFromXML ( self, xml_param ) : + # + if DEBUG_MODE : print '>> ControlParam ( %s ).parseFromXML' % self.label + NodeParam.parseFromXML ( self, xml_param ) - control_code_tag = xml_param.namedItem ( 'code' ) - if not control_code_tag.isNull () : - self.code = str ( control_code_tag.toElement ().text () ) - else : - # for temp. backward compatibility check 'control_code' also - control_code_tag = xml_param.namedItem ( 'control_code' ) - if not control_code_tag.isNull () : - code_str = str ( control_code_tag.toElement ().text () ).lstrip () - if code_str == '' : code_str = None - self.code = code_str - - self.btext = str ( xml_param.attributes ().namedItem ( 'btext' ).nodeValue () ) - # - # parseToXML - # - def parseToXML ( self, dom ) : - # - if DEBUG_MODE : print '>> ControlParam ( %s ).parseToXML' % self.label - xmlnode = NodeParam.parseToXML ( self, dom ) + control_code_tag = xml_param.namedItem ( 'code' ) + if not control_code_tag.isNull () : + self.code = str ( control_code_tag.toElement ().text () ) + else : + # for temp. backward compatibility check 'control_code' also + control_code_tag = xml_param.namedItem ( 'control_code' ) + if not control_code_tag.isNull () : + code_str = str ( control_code_tag.toElement ().text () ).lstrip () + if code_str == '' : code_str = None + self.code = code_str + + self.btext = str ( xml_param.attributes ().namedItem ( 'btext' ).nodeValue () ) + # + # parseToXML + # + def parseToXML ( self, dom ) : + # + if DEBUG_MODE : print '>> ControlParam ( %s ).parseToXML' % self.label + xmlnode = NodeParam.parseToXML ( self, dom ) - if self.code is not None : - code_tag = dom.createElement ( 'code' ) - code_text = dom.createTextNode ( self.code ) - code_tag.appendChild ( code_text ) - xmlnode.appendChild ( code_tag ) - - if self.btext != '' : xmlnode.setAttribute ( 'btext', self.btext ) + if self.code is not None : + code_tag = dom.createElement ( 'code' ) + code_text = dom.createTextNode ( self.code ) + code_tag.appendChild ( code_text ) + xmlnode.appendChild ( code_tag ) + + if self.btext != '' : xmlnode.setAttribute ( 'btext', self.btext ) - return xmlnode - # - # execControlCode - # - def execControlCode ( self, node ) : - # - if self.code is not None : - exec ( self.code, { 'node' : node, 'self' : self } ) + return xmlnode + # + # execControlCode + # + def execControlCode ( self, node ) : + # + if self.code is not None : + exec ( self.code, { 'node' : node, 'self' : self } ) diff --git a/core/params/displacementNodeParam.py b/core/params/displacementNodeParam.py index e6f3a3b..2c58e10 100644 --- a/core/params/displacementNodeParam.py +++ b/core/params/displacementNodeParam.py @@ -1,34 +1,33 @@ -#=============================================================================== -# displacementNodeParam.py -#=============================================================================== -import os, sys +""" -from PyQt4 import QtCore + displacementNodeParam.py +""" from core.node import Node from core.nodeParam import NodeParam + from global_vars import app_global_vars, DEBUG_MODE from core.meCommon import parseGlobalVars # # Displacement # class DisplacementNodeParam ( NodeParam ) : - # - # __init__ - # - def __init__ ( self, xml_param = None, isRibParam = False ) : - # - NodeParam.__init__ ( self, xml_param, isRibParam ) - self.type = 'displacement' - # - # encodedTypeStr - # - def encodedTypeStr ( self ) : return 'D' - # - # copy - # - def copy ( self ): - # - newParam = DisplacementNodeParam () - self.copySetup ( newParam ) - return newParam + # + # __init__ + # + def __init__ ( self, xml_param = None, isRibParam = False ) : + # + NodeParam.__init__ ( self, xml_param, isRibParam ) + self.type = 'displacement' + # + # encodedTypeStr + # + def encodedTypeStr ( self ) : return 'D' + # + # copy + # + def copy ( self ): + # + newParam = DisplacementNodeParam () + self.copySetup ( newParam ) + return newParam diff --git a/core/params/floatNodeParam.py b/core/params/floatNodeParam.py index 63f7974..441a398 100644 --- a/core/params/floatNodeParam.py +++ b/core/params/floatNodeParam.py @@ -1,89 +1,88 @@ -#=============================================================================== -# floatNodeParam.py -#=============================================================================== -import os, sys - -from PyQt4 import QtCore +""" + + floatNodeParam.py +""" from core.nodeParam import NodeParam + from global_vars import app_global_vars, DEBUG_MODE from core.meCommon import parseGlobalVars # # Float # class FloatNodeParam ( NodeParam ) : - # - # __init__ - # - def __init__ ( self, xml_param = None, isRibParam = False ) : - # - super ( FloatNodeParam, self ).__init__ ( xml_param, isRibParam ) - self.type = 'float' - # - # encodedTypeStr - # - def encodedTypeStr ( self ) : return 'f' - # - # copy - # - def copy ( self ) : - # - newParam = FloatNodeParam () - self.copySetup ( newParam ) - return newParam - # - # valueFromStr - # - def valueFromStr ( self, str ) : - # - value = 0.0 + # + # __init__ + # + def __init__ ( self, xml_param = None, isRibParam = False ) : + # + super ( FloatNodeParam, self ).__init__ ( xml_param, isRibParam ) + self.type = 'float' + # + # encodedTypeStr + # + def encodedTypeStr ( self ) : return 'f' + # + # copy + # + def copy ( self ) : + # + newParam = FloatNodeParam () + self.copySetup ( newParam ) + return newParam + # + # valueFromStr + # + def valueFromStr ( self, str ) : + # + value = 0.0 - if str != '': - try: value = float ( str ) - except: raise Exception ( 'Cannot parse float value for parameter %s' % ( self.name ) ) - return value - # - # valueToStr - # - def valueToStr ( self, value ) : return '%.3f' % float ( value ) - # - # getRangeValues - # - def getRangeValues ( self ) : - # if subtype == selector then return list of (label,value) pairs - # It's supposed, that range is defined as "value1:value2:value3" - # or "label1=value1:label2=value2:label3=value3:" - # - # if subtype == slider then return list [min, max, step] from - # space separated string range="min max step" - # - rangeList = [] - i = 0 - if self.range != '' : - # - # get range for selector - # - if self.subtype == 'selector' : - tmp_list = str ( self.range ).split ( ':' ) - for s in tmp_list : - pair = s.split ( '=' ) - if len ( pair ) > 1 : - label = pair [0] - value = float ( pair [1] ) - else : - label = s - value = float ( i ) - i += 1 - rangeList.append ( ( parseGlobalVars ( label ), value ) ) - # - # get range for slider - # - elif self.subtype == 'slider' or self.subtype == 'vslider' : - tmp_list = str ( self.range ).split () - for i in range ( 0, 3 ) : - value = 0.0 - if i < len ( tmp_list ) : - value = float ( tmp_list[ i ] ) - rangeList.append ( value ) + if str != '': + try: value = float ( str ) + except: raise Exception ( 'Cannot parse float value for parameter %s' % ( self.name ) ) + return value + # + # valueToStr + # + def valueToStr ( self, value ) : return '%.3f' % float ( value ) + # + # getRangeValues + # + def getRangeValues ( self ) : + # if subtype == selector then return list of (label,value) pairs + # It's supposed, that range is defined as "value1:value2:value3" + # or "label1=value1:label2=value2:label3=value3:" + # + # if subtype == slider then return list [min, max, step] from + # space separated string range="min max step" + # + rangeList = [] + i = 0 + if self.range != '' : + # + # get range for selector + # + if self.subtype == 'selector' : + tmp_list = str ( self.range ).split ( ':' ) + for s in tmp_list : + pair = s.split ( '=' ) + if len ( pair ) > 1 : + label = pair [0] + value = float ( pair [1] ) + else : + label = s + value = float ( i ) + i += 1 + rangeList.append ( ( parseGlobalVars ( label ), value ) ) + # + # get range for slider + # + elif self.subtype == 'slider' or self.subtype == 'vslider' : + tmp_list = str ( self.range ).split () + for i in range ( 0, 3 ) : + value = 0.0 + if i < len ( tmp_list ) : + value = float ( tmp_list[ i ] ) + rangeList.append ( value ) - return rangeList + return rangeList diff --git a/core/params/imageNodeParam.py b/core/params/imageNodeParam.py index 6cf398e..476866d 100644 --- a/core/params/imageNodeParam.py +++ b/core/params/imageNodeParam.py @@ -1,12 +1,11 @@ -#=============================================================================== -# imageNodeParam.py -#=============================================================================== -import os, sys +""" -from PyQt4 import QtCore + imageNodeParam.py +""" from core.node import Node from core.nodeParam import NodeParam + from global_vars import app_global_vars, DEBUG_MODE from core.meCommon import parseGlobalVars # diff --git a/core/params/intNodeParam.py b/core/params/intNodeParam.py index 36ff5d6..aa3d7db 100644 --- a/core/params/intNodeParam.py +++ b/core/params/intNodeParam.py @@ -1,86 +1,85 @@ -#=============================================================================== -# intNodeParam.py -#=============================================================================== -import os, sys +""" -from PyQt4 import QtCore + intNodeParam.py +""" from core.nodeParam import NodeParam + from global_vars import app_global_vars, DEBUG_MODE # # Integer # class IntNodeParam ( NodeParam ) : - # - # __init__ - # - def __init__ ( self, xml_param = None, isRibParam = False ) : - # - NodeParam.__init__ ( self, xml_param, isRibParam ) - self.type = 'int' - # - # encodedTypeStr - # - def encodedTypeStr ( self ) : return 'i' - # - # copy - # - def copy ( self ) : - # - newParam = IntNodeParam () - self.copySetup ( newParam ) - return newParam - # - # valueFromStr - # - def valueFromStr ( self, str ) : - # - value = 0 - - if str != '' : - try: value = int ( str ) - except: raise Exception ( 'Cannot parse integer value for parameter %s' % ( self.name ) ) - return value - # - # valueToStr - # - def valueToStr ( self, value ) : return '%d'% value - # - # getRangeValues - # - # if subtype == selector then return list of (label,value) pairs - # It's supposed, that range is defined as "value1:value2:value3" - # or "label1=value1:label2=value2:label3=value3:" - # - def getRangeValues ( self ) : - # - rangeList = [] - i = 0 - if self.range != '' : - # - # get range for selector - # - if self.subtype == 'selector' : - tmp_list = str ( self.range ).split ( ':' ) - for s in tmp_list : - pair = s.split ( '=' ) - if len ( pair ) > 1 : - label = pair [0] - value = int ( pair [1] ) - else : - label = s - value = int ( i ) - i += 1 - rangeList.append ( (label, value) ) - # - # get range for slider - # - elif self.subtype == 'slider' or self.subtype == 'vslider' : - tmp_list = str ( self.range ).split () - for i in range ( 0, 3 ) : - value = 0 - if i < len ( tmp_list ) : - value = int ( tmp_list [ i ] ) - rangeList.append ( value ) + # + # __init__ + # + def __init__ ( self, xml_param = None, isRibParam = False ) : + # + NodeParam.__init__ ( self, xml_param, isRibParam ) + self.type = 'int' + # + # encodedTypeStr + # + def encodedTypeStr ( self ) : return 'i' + # + # copy + # + def copy ( self ) : + # + newParam = IntNodeParam () + self.copySetup ( newParam ) + return newParam + # + # valueFromStr + # + def valueFromStr ( self, str ) : + # + value = 0 + + if str != '' : + try: value = int ( str ) + except: raise Exception ( 'Cannot parse integer value for parameter %s' % ( self.name ) ) + return value + # + # valueToStr + # + def valueToStr ( self, value ) : return '%d'% value + # + # getRangeValues + # + # if subtype == selector then return list of (label,value) pairs + # It's supposed, that range is defined as "value1:value2:value3" + # or "label1=value1:label2=value2:label3=value3:" + # + def getRangeValues ( self ) : + # + rangeList = [] + i = 0 + if self.range != '' : + # + # get range for selector + # + if self.subtype == 'selector' : + tmp_list = str ( self.range ).split ( ':' ) + for s in tmp_list : + pair = s.split ( '=' ) + if len ( pair ) > 1 : + label = pair [0] + value = int ( pair [1] ) + else : + label = s + value = int ( i ) + i += 1 + rangeList.append ( (label, value) ) + # + # get range for slider + # + elif self.subtype == 'slider' or self.subtype == 'vslider' : + tmp_list = str ( self.range ).split () + for i in range ( 0, 3 ) : + value = 0 + if i < len ( tmp_list ) : + value = int ( tmp_list [ i ] ) + rangeList.append ( value ) - return rangeList + return rangeList diff --git a/core/params/lightNodeParam.py b/core/params/lightNodeParam.py index de3b443..9c5d9a9 100644 --- a/core/params/lightNodeParam.py +++ b/core/params/lightNodeParam.py @@ -1,34 +1,33 @@ -#=============================================================================== -# lightNodeParam.py -#=============================================================================== -import os, sys +""" -from PyQt4 import QtCore + lightNodeParam.py +""" from core.node import Node from core.nodeParam import NodeParam + from global_vars import app_global_vars, DEBUG_MODE from core.meCommon import parseGlobalVars # # Light # class LightNodeParam ( NodeParam ) : - # - # __init__ - # - def __init__ ( self, xml_param = None, isRibParam = False ) : - # - NodeParam.__init__ ( self, xml_param, isRibParam ) - self.type = 'light' - # - # encodedTypeStr - # - def encodedTypeStr ( self ) : return 'L' - # - # copy - # - def copy ( self ) : - # - newParam = LightNodeParam () - self.copySetup ( newParam ) - return newParam \ No newline at end of file + # + # __init__ + # + def __init__ ( self, xml_param = None, isRibParam = False ) : + # + NodeParam.__init__ ( self, xml_param, isRibParam ) + self.type = 'light' + # + # encodedTypeStr + # + def encodedTypeStr ( self ) : return 'L' + # + # copy + # + def copy ( self ) : + # + newParam = LightNodeParam () + self.copySetup ( newParam ) + return newParam \ No newline at end of file diff --git a/core/params/matrixNodeParam.py b/core/params/matrixNodeParam.py index b488838..e02fda0 100644 --- a/core/params/matrixNodeParam.py +++ b/core/params/matrixNodeParam.py @@ -1,115 +1,115 @@ -#=============================================================================== -# matrixNodeParam.py -#=============================================================================== -import os, sys -import re +""" + + matrixNodeParam.py -from PyQt4 import QtCore +""" +import re from core.node import Node from core.nodeParam import NodeParam + from global_vars import app_global_vars, DEBUG_MODE # # Matrix # class MatrixNodeParam ( NodeParam ) : - # - # __init__ - # - def __init__ ( self, xml_param = None, isRibParam = False ) : - NodeParam.__init__ ( self, xml_param, isRibParam ) - self.type = 'matrix' - # - # encodedTypeStr - # - def encodedTypeStr ( self ) : return 'm' - # - # copy - # - def copy ( self ) : - # - newParam = MatrixNodeParam () - self.copySetup ( newParam ) - return newParam - # - # valueFromStr - # - def valueFromStr ( self, strValue ) : - # - value = [ [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0] ] + # + # __init__ + # + def __init__ ( self, xml_param = None, isRibParam = False ) : + NodeParam.__init__ ( self, xml_param, isRibParam ) + self.type = 'matrix' + # + # encodedTypeStr + # + def encodedTypeStr ( self ) : return 'm' + # + # copy + # + def copy ( self ) : + # + newParam = MatrixNodeParam () + self.copySetup ( newParam ) + return newParam + # + # valueFromStr + # + def valueFromStr ( self, strValue ) : + # + value = [ [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0] ] - if strValue != '' and strValue != '0' : - if strValue == '1' : - value = [ [1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0] ] # default - else: - strValue = str.replace ( ' ', '' ) + if strValue != '' and strValue != '0' : + if strValue == '1' : + value = [ [1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0] ] # default + else: + strValue = str.replace ( ' ', '' ) - matrix16_pattern_str = 'matrix\(([-+]?([0-9]*\.)?[0-9]+,){15}[-+]?([0-9]*\.)?[0-9]+\)' - matrix1_pattern_str = 'matrix\(([-+]?([0-9]*\.)?[0-9]+\))' - matrix16_space_pattern_str = 'matrix"[a-z]*"\(([-+]?([0-9]*\.)?[0-9]+,){15}[-+]?([0-9]*\.)?[0-9]+\)' - matrix1_space_pattern_str = 'matrix"[a-z]*"\(([-+]?([0-9]*\.)?[0-9]+\))' - float_pattern_str = '[-+]?[0-9]*\.?[0-9]+' - space_pattern_str = '"[a-z]*"' + matrix16_pattern_str = 'matrix\(([-+]?([0-9]*\.)?[0-9]+,){15}[-+]?([0-9]*\.)?[0-9]+\)' + matrix1_pattern_str = 'matrix\(([-+]?([0-9]*\.)?[0-9]+\))' + matrix16_space_pattern_str = 'matrix"[a-z]*"\(([-+]?([0-9]*\.)?[0-9]+,){15}[-+]?([0-9]*\.)?[0-9]+\)' + matrix1_space_pattern_str = 'matrix"[a-z]*"\(([-+]?([0-9]*\.)?[0-9]+\))' + float_pattern_str = '[-+]?[0-9]*\.?[0-9]+' + space_pattern_str = '"[a-z]*"' - p = re.compile ( matrix16_pattern_str ) - match = p.match ( strValue) - if match : - p = re.compile ( float_pattern_str ) - f = p.findall ( strValue ) - f = map ( float, f ) - value = [ f[0:4], f[4:8], f[8:12], f[12:16] ] - else : - p = re.compile ( matrix1_pattern_str ) - match = p.match ( strValue ) - if match : - p = re.compile ( float_pattern_str ) - f = p.findall ( strValue ) - f = map ( float, f ) - value = [ [f[0], 0.0, 0.0, 0.0], [0.0, f[0], 0.0, 0.0], [0.0, 0.0, f[0], 0.0], [0.0, 0.0, 0.0, f[0]] ] - else : - p = re.compile ( matrix16_space_pattern_str ) - match = p.match ( strValue ) - if match : - p = re.compile ( float_pattern_str ) - f = p.findall ( strValue ) - f = map ( float, f ) - value = [ f[0:4], f[4:8], f[8:12], f[12:16] ] + p = re.compile ( matrix16_pattern_str ) + match = p.match ( strValue) + if match : + p = re.compile ( float_pattern_str ) + f = p.findall ( strValue ) + f = map ( float, f ) + value = [ f[0:4], f[4:8], f[8:12], f[12:16] ] + else : + p = re.compile ( matrix1_pattern_str ) + match = p.match ( strValue ) + if match : + p = re.compile ( float_pattern_str ) + f = p.findall ( strValue ) + f = map ( float, f ) + value = [ [f[0], 0.0, 0.0, 0.0], [0.0, f[0], 0.0, 0.0], [0.0, 0.0, f[0], 0.0], [0.0, 0.0, 0.0, f[0]] ] + else : + p = re.compile ( matrix16_space_pattern_str ) + match = p.match ( strValue ) + if match : + p = re.compile ( float_pattern_str ) + f = p.findall ( strValue ) + f = map ( float, f ) + value = [ f[0:4], f[4:8], f[8:12], f[12:16] ] - p = re.compile ( space_pattern_str ) - s = p.findall ( strValue ) - self.space = s[0].strip ( '"' ) - else : - p = re.compile ( matrix1_space_pattern_str ) - match = p.match ( strValue ) - if match : - p = re.compile ( float_pattern_str ) - f = p.findall ( strValue ) - f = map ( float, f ) - value = [ [f[0], 0.0, 0.0, 0.0], [0.0, f[0], 0.0, 0.0], [0.0, 0.0, f[0], 0.0], [0.0, 0.0, 0.0, f[0]] ] + p = re.compile ( space_pattern_str ) + s = p.findall ( strValue ) + self.space = s[0].strip ( '"' ) + else : + p = re.compile ( matrix1_space_pattern_str ) + match = p.match ( strValue ) + if match : + p = re.compile ( float_pattern_str ) + f = p.findall ( strValue ) + f = map ( float, f ) + value = [ [f[0], 0.0, 0.0, 0.0], [0.0, f[0], 0.0, 0.0], [0.0, 0.0, f[0], 0.0], [0.0, 0.0, 0.0, f[0]] ] - p = re.compile ( space_pattern_str ) - s = p.findall ( strValue ) - self.space = s[0].strip ( '"' ) - else : - err = 'Cannot parse matrix %s values' % self.name - raise Exception ( err ) - return value - # - # valueToStr - # - def valueToStr ( self, value ) : - # - flatMat = sum ( value, [] ) - ret_str = 'matrix' - if self.space != None : - if self.space != '' : - ret_str += ' "' + self.space + '" ' - return ret_str +'(' + ''.join ('%.3f' % f + ',' for f in flatMat[: - 1]) + '%.3f' % flatMat[ - 1] + ')' - # - # setValue - # - def setValue ( self, value ) : - # - if self.value != value : - self.value = value - self.paramChanged () + p = re.compile ( space_pattern_str ) + s = p.findall ( strValue ) + self.space = s[0].strip ( '"' ) + else : + err = 'Cannot parse matrix %s values' % self.name + raise Exception ( err ) + return value + # + # valueToStr + # + def valueToStr ( self, value ) : + # + flatMat = sum ( value, [] ) + ret_str = 'matrix' + if self.space != None : + if self.space != '' : + ret_str += ' "' + self.space + '" ' + return ret_str +'(' + ''.join ('%.3f' % f + ',' for f in flatMat[: - 1]) + '%.3f' % flatMat[ - 1] + ')' + # + # setValue + # + def setValue ( self, value ) : + # + if self.value != value : + self.value = value + self.paramChanged () diff --git a/core/params/normalNodeParam.py b/core/params/normalNodeParam.py index cc5d16d..b954448 100644 --- a/core/params/normalNodeParam.py +++ b/core/params/normalNodeParam.py @@ -1,108 +1,108 @@ -#=============================================================================== -# normalNodeParam.py -#=============================================================================== -import os, sys -import re +""" + + normalNodeParam.py -from PyQt4 import QtCore +""" +import re from core.node import Node from core.nodeParam import NodeParam + from global_vars import app_global_vars, DEBUG_MODE # # Normal # class NormalNodeParam ( NodeParam ) : - # - # __init__ - # - def __init__ ( self, xml_param = None, isRibParam = False ) : - # - NodeParam.__init__ ( self, xml_param, isRibParam ) - self.type = 'normal' - # - # encodedTypeStr - # - def encodedTypeStr ( self ) : return 'n' - # - # copy - # - def copy ( self ) : - # - newParam = NormalNodeParam () - self.copySetup ( newParam ) - return newParam - # - # valueFromStr - # - def valueFromStr ( self, strValue ) : - # - value = [ 0.0, 0.0, 0.0 ] + # + # __init__ + # + def __init__ ( self, xml_param = None, isRibParam = False ) : + # + NodeParam.__init__ ( self, xml_param, isRibParam ) + self.type = 'normal' + # + # encodedTypeStr + # + def encodedTypeStr ( self ) : return 'n' + # + # copy + # + def copy ( self ) : + # + newParam = NormalNodeParam () + self.copySetup ( newParam ) + return newParam + # + # valueFromStr + # + def valueFromStr ( self, strValue ) : + # + value = [ 0.0, 0.0, 0.0 ] - if strValue != '' : - strValue = strValue.replace ( ' ', '' ) - normal3_pattern_str = 'normal\(([-+]?([0-9]*\.)?[0-9]+,){2}[-+]?([0-9]*\.)?[0-9]+\)' - normal1_pattern_str = 'normal\(([-+]?([0-9]*\.)?[0-9]+\))' - normal3_space_pattern_str = 'normal"[a-z]*"\(([-+]?([0-9]*\.)?[0-9]+,){2}[-+]?([0-9]*\.)?[0-9]+\)' - normal1_space_pattern_str = 'normal"[a-z]*"\(([-+]?([0-9]*\.)?[0-9]+\))' - float_pattern_str = '[-+]?[0-9]*\.?[0-9]+' - space_pattern_str = '"[a-z]*"' + if strValue != '' : + strValue = strValue.replace ( ' ', '' ) + normal3_pattern_str = 'normal\(([-+]?([0-9]*\.)?[0-9]+,){2}[-+]?([0-9]*\.)?[0-9]+\)' + normal1_pattern_str = 'normal\(([-+]?([0-9]*\.)?[0-9]+\))' + normal3_space_pattern_str = 'normal"[a-z]*"\(([-+]?([0-9]*\.)?[0-9]+,){2}[-+]?([0-9]*\.)?[0-9]+\)' + normal1_space_pattern_str = 'normal"[a-z]*"\(([-+]?([0-9]*\.)?[0-9]+\))' + float_pattern_str = '[-+]?[0-9]*\.?[0-9]+' + space_pattern_str = '"[a-z]*"' - p = re.compile ( normal3_pattern_str ) - match = p.match ( strValue ) - if match : - # normal(0,0,0) - p = re.compile ( float_pattern_str ) - f = p.findall ( strValue ) - f = map ( float, f ) - value = [ f [0], f [1], f [2] ] - else : - # normal(0) - p = re.compile ( normal1_pattern_str ) - match = p.match ( strValue ) - if match : - p = re.compile ( float_pattern_str ) - f = p.findall ( strValue ) - f = map ( float, f ) - value = [ f [0], f [0], f [0] ] - else : - # normal "space" (0,0,0) - p = re.compile ( normal3_space_pattern_str ) - match = p.match ( strValue ) - if match : - p = re.compile ( float_pattern_str ) - f = p.findall ( strValue ) - f = map ( float, f ) - value = [ f [0], f [1], f [2] ] + p = re.compile ( normal3_pattern_str ) + match = p.match ( strValue ) + if match : + # normal(0,0,0) + p = re.compile ( float_pattern_str ) + f = p.findall ( strValue ) + f = map ( float, f ) + value = [ f [0], f [1], f [2] ] + else : + # normal(0) + p = re.compile ( normal1_pattern_str ) + match = p.match ( strValue ) + if match : + p = re.compile ( float_pattern_str ) + f = p.findall ( strValue ) + f = map ( float, f ) + value = [ f [0], f [0], f [0] ] + else : + # normal "space" (0,0,0) + p = re.compile ( normal3_space_pattern_str ) + match = p.match ( strValue ) + if match : + p = re.compile ( float_pattern_str ) + f = p.findall ( strValue ) + f = map ( float, f ) + value = [ f [0], f [1], f [2] ] - p = re.compile ( space_pattern_str ) - s = p.findall ( strValue ) - self.space = s [0].strip ( '"' ) - else : - # normal "space" (0) - p = re.compile ( normal1_space_pattern_str ) - match = p.match ( strValue ) - if match : - p = re.compile ( float_pattern_str ) - f = p.findall ( strValue ) - f = map ( float, f ) - value = [ f [0], f [0], f [0] ] + p = re.compile ( space_pattern_str ) + s = p.findall ( strValue ) + self.space = s [0].strip ( '"' ) + else : + # normal "space" (0) + p = re.compile ( normal1_space_pattern_str ) + match = p.match ( strValue ) + if match : + p = re.compile ( float_pattern_str ) + f = p.findall ( strValue ) + f = map ( float, f ) + value = [ f [0], f [0], f [0] ] - p = re.compile ( space_pattern_str ) - s = p.findall ( strValue ) - self.space = s [0].strip ( '"' ) - else : - err = 'Cannot parse normal %s values' % self.name - raise Exception ( err ) - return value - # - # valueToStr - # - def valueToStr ( self, value ) : - # - ret_str = 'normal' + p = re.compile ( space_pattern_str ) + s = p.findall ( strValue ) + self.space = s [0].strip ( '"' ) + else : + err = 'Cannot parse normal %s values' % self.name + raise Exception ( err ) + return value + # + # valueToStr + # + def valueToStr ( self, value ) : + # + ret_str = 'normal' - if self.space != None : - if self.space != '' : - ret_str += ' "' + self.space + '" ' - return ret_str + '(' + ''.join ( '%.3f' % f + ',' for f in value [: - 1] ) + '%.3f' % value [ - 1] + ')' + if self.space != None : + if self.space != '' : + ret_str += ' "' + self.space + '" ' + return ret_str + '(' + ''.join ( '%.3f' % f + ',' for f in value [: - 1] ) + '%.3f' % value [ - 1] + ')' diff --git a/core/params/pointNodeParam.py b/core/params/pointNodeParam.py index 657437a..ebe7d04 100644 --- a/core/params/pointNodeParam.py +++ b/core/params/pointNodeParam.py @@ -1,111 +1,111 @@ -#=============================================================================== -# pointNodeParam.py -#=============================================================================== -import os, sys -import re +""" + + pointNodeParam.py -from PyQt4 import QtCore +""" +import re from core.node import Node from core.nodeParam import NodeParam + from global_vars import app_global_vars, DEBUG_MODE # # Point # class PointNodeParam ( NodeParam ) : - # - # __init__ - # - def __init__ ( self, xml_param = None, isRibParam = False ) : - # - NodeParam.__init__ ( self, xml_param, isRibParam ) - self.type = 'point' - # - # encodedTypeStr - # - def encodedTypeStr ( self ) : return 'p' - # - # copy - # - def copy ( self ) : - # - newParam = PointNodeParam () - self.copySetup ( newParam ) - return newParam - # - # valueFromStr - # - def valueFromStr ( self, strValue ) : - # - value = [ 0.0, 0.0, 0.0 ] + # + # __init__ + # + def __init__ ( self, xml_param = None, isRibParam = False ) : + # + NodeParam.__init__ ( self, xml_param, isRibParam ) + self.type = 'point' + # + # encodedTypeStr + # + def encodedTypeStr ( self ) : return 'p' + # + # copy + # + def copy ( self ) : + # + newParam = PointNodeParam () + self.copySetup ( newParam ) + return newParam + # + # valueFromStr + # + def valueFromStr ( self, strValue ) : + # + value = [ 0.0, 0.0, 0.0 ] - if strValue != '' : - strValue = strValue.replace ( ' ', '' ) - - point3_pattern_str = 'point\(([-+]?([0-9]*\.)?[0-9]+,){2}[-+]?([0-9]*\.)?[0-9]+\)' - point1_pattern_str = 'point\(([-+]?([0-9]*\.)?[0-9]+\))' - point3_space_pattern_str = 'point"[a-z]*"\(([-+]?([0-9]*\.)?[0-9]+,){2}[-+]?([0-9]*\.)?[0-9]+\)' - point1_space_pattern_str = 'point"[a-z]*"\(([-+]?([0-9]*\.)?[0-9]+\))' - float_pattern_str = '[-+]?[0-9]*\.?[0-9]+' - space_pattern_str = '"[a-z]*"' - - p = re.compile ( point3_pattern_str ) - match = p.match ( strValue ) - if match : - # point(0,0,0) - p = re.compile ( float_pattern_str ) - f = p.findall ( strValue ) - f = map ( float, f ) - value = [ f [0], f [1], f [2] ] - else : - # point(0) - p = re.compile ( point1_pattern_str ) - match = p.match ( strValue ) - if match : - p = re.compile ( float_pattern_str ) - f = p.findall ( strValue ) - f = map ( float, f ) - value = [ f [0], f [0], f [0] ] - else : - # point "space" (0,0,0) - p = re.compile ( point3_space_pattern_str ) - match = p.match ( strValue ) - if match : - p = re.compile ( float_pattern_str ) - f = p.findall ( strValue ) - f = map ( float, f ) - value = [ f [0], f [1], f [2] ] + if strValue != '' : + strValue = strValue.replace ( ' ', '' ) + + point3_pattern_str = 'point\(([-+]?([0-9]*\.)?[0-9]+,){2}[-+]?([0-9]*\.)?[0-9]+\)' + point1_pattern_str = 'point\(([-+]?([0-9]*\.)?[0-9]+\))' + point3_space_pattern_str = 'point"[a-z]*"\(([-+]?([0-9]*\.)?[0-9]+,){2}[-+]?([0-9]*\.)?[0-9]+\)' + point1_space_pattern_str = 'point"[a-z]*"\(([-+]?([0-9]*\.)?[0-9]+\))' + float_pattern_str = '[-+]?[0-9]*\.?[0-9]+' + space_pattern_str = '"[a-z]*"' + + p = re.compile ( point3_pattern_str ) + match = p.match ( strValue ) + if match : + # point(0,0,0) + p = re.compile ( float_pattern_str ) + f = p.findall ( strValue ) + f = map ( float, f ) + value = [ f [0], f [1], f [2] ] + else : + # point(0) + p = re.compile ( point1_pattern_str ) + match = p.match ( strValue ) + if match : + p = re.compile ( float_pattern_str ) + f = p.findall ( strValue ) + f = map ( float, f ) + value = [ f [0], f [0], f [0] ] + else : + # point "space" (0,0,0) + p = re.compile ( point3_space_pattern_str ) + match = p.match ( strValue ) + if match : + p = re.compile ( float_pattern_str ) + f = p.findall ( strValue ) + f = map ( float, f ) + value = [ f [0], f [1], f [2] ] - p = re.compile ( space_pattern_str ) - s = p.findall ( strValue ) - sp = str ( s[0] ) - self.space = sp.strip ( '"' ) - else : - # point "space" (0) - p = re.compile ( point1_space_pattern_str ) - match = p.match ( strValue ) - if match : - p = re.compile ( float_pattern_str ) - f = p.findall ( strValue ) - f = map ( float, f ) - value = [ f [0], f [0], f [0] ] + p = re.compile ( space_pattern_str ) + s = p.findall ( strValue ) + sp = str ( s[0] ) + self.space = sp.strip ( '"' ) + else : + # point "space" (0) + p = re.compile ( point1_space_pattern_str ) + match = p.match ( strValue ) + if match : + p = re.compile ( float_pattern_str ) + f = p.findall ( strValue ) + f = map ( float, f ) + value = [ f [0], f [0], f [0] ] - p = re.compile ( space_pattern_str ) - s = p.findall ( strValue ) - sp = str ( s[0] ) - self.space = sp.strip ( '"' ) - else : - err = 'Cannot parse point %s values' % self.name - raise Exception ( err ) - return value - # - # valueToStr - # - def valueToStr ( self, value ) : - # - ret_str = 'point' - - if self.space != None : - if self.space != '' : - ret_str += ' "' + self.space + '" ' - return ret_str + '(' + ''.join ( '%.3f' % f + ',' for f in value [: - 1] ) + '%.3f' % value [ - 1] + ')' + p = re.compile ( space_pattern_str ) + s = p.findall ( strValue ) + sp = str ( s[0] ) + self.space = sp.strip ( '"' ) + else : + err = 'Cannot parse point %s values' % self.name + raise Exception ( err ) + return value + # + # valueToStr + # + def valueToStr ( self, value ) : + # + ret_str = 'point' + + if self.space != None : + if self.space != '' : + ret_str += ' "' + self.space + '" ' + return ret_str + '(' + ''.join ( '%.3f' % f + ',' for f in value [: - 1] ) + '%.3f' % value [ - 1] + ')' diff --git a/core/params/ribNodeParam.py b/core/params/ribNodeParam.py index 9495d0f..c826dfa 100644 --- a/core/params/ribNodeParam.py +++ b/core/params/ribNodeParam.py @@ -1,34 +1,33 @@ -#=============================================================================== -# ribNodeParam.py -#=============================================================================== -import os, sys +""" -from PyQt4 import QtCore + ribNodeParam.py +""" from core.node import Node from core.nodeParam import NodeParam + from global_vars import app_global_vars, DEBUG_MODE from core.meCommon import parseGlobalVars # # RIB # class RibNodeParam ( NodeParam ) : - # - # __init__ - # - def __init__ ( self, xml_param = None, isRibParam = False ) : - # - NodeParam.__init__ ( self, xml_param, isRibParam ) - self.type = 'rib' - # - # encodedTypeStr - # - def encodedTypeStr ( self ) : return 'R' - # - # copy - # - def copy ( self ) : - # - newParam = RibNodeParam () - self.copySetup ( newParam ) - return newParam \ No newline at end of file + # + # __init__ + # + def __init__ ( self, xml_param = None, isRibParam = False ) : + # + NodeParam.__init__ ( self, xml_param, isRibParam ) + self.type = 'rib' + # + # encodedTypeStr + # + def encodedTypeStr ( self ) : return 'R' + # + # copy + # + def copy ( self ) : + # + newParam = RibNodeParam () + self.copySetup ( newParam ) + return newParam \ No newline at end of file diff --git a/core/params/rslCodeNode.py b/core/params/rslCodeNode.py index f3c89ad..5edc72b 100644 --- a/core/params/rslCodeNode.py +++ b/core/params/rslCodeNode.py @@ -1,9 +1,8 @@ -#=============================================================================== -# rslCodeNode.py -#=============================================================================== -import os, sys -from PyQt4 import QtCore +""" + rslCodeNode.py + +""" from core.node import Node from core.nodeParam import NodeParam @@ -13,18 +12,18 @@ # RSLCodeNode # class RSLCodeNode ( Node ) : - # - # __init__ - # - def __init__ ( self, xml_node = None ) : - # - Node.__init__ ( self, xml_node ) - self.shaderName = '' - # - # copy - # - def copy ( self ) : - if DEBUG_MODE : print '>> RSL_code( %s ).copy' % self.label - newNode = RSLCodeNode () - self.copySetup ( newNode ) - return newNode \ No newline at end of file + # + # __init__ + # + def __init__ ( self, xml_node = None ) : + # + Node.__init__ ( self, xml_node ) + self.shaderName = '' + # + # copy + # + def copy ( self ) : + if DEBUG_MODE : print '>> RSL_code( %s ).copy' % self.label + newNode = RSLCodeNode () + self.copySetup ( newNode ) + return newNode \ No newline at end of file diff --git a/core/params/shaderNodeParam.py b/core/params/shaderNodeParam.py index 5fbe4db..35c2d3c 100644 --- a/core/params/shaderNodeParam.py +++ b/core/params/shaderNodeParam.py @@ -1,69 +1,68 @@ -#=============================================================================== -# shaderNodeParam.py -#=============================================================================== -import os, sys +""" -from PyQt4 import QtCore + shaderNodeParam.py +""" from core.node import Node from core.nodeParam import NodeParam + from global_vars import app_global_vars, DEBUG_MODE from core.meCommon import parseGlobalVars # # Shader # class ShaderNodeParam ( NodeParam ) : - # - # __init__ - # - def __init__ ( self, xml_param = None, isRibParam = False ) : - # - NodeParam.__init__ ( self, xml_param, isRibParam ) - self.type = 'shader' - # - # encodedTypeStr - # - def encodedTypeStr ( self ) : return 'S' - # - # copy - # - def copy ( self ) : - # - newParam = ShaderNodeParam () - self.copySetup ( newParam ) - return newParam - # - # valueFromStr - # - def valueFromStr ( self, str ) : return str - # - # valueToStr - # - def valueToStr ( self, value ) : - # - ret_str = str ( value ) - if not self.isRibParam : ret_str = str ( "\"" + value + "\"" ) - return ret_str - # - # getRangeValues - # - # if subtype == selector then return list of (label,value) pairs - # It's supposed, that range is defined as "value1:value2:value3" - # or "label1=value1:label2=value2:label3=value3:" - # - def getRangeValues ( self ) : - # - rangeList = [] + # + # __init__ + # + def __init__ ( self, xml_param = None, isRibParam = False ) : + # + NodeParam.__init__ ( self, xml_param, isRibParam ) + self.type = 'shader' + # + # encodedTypeStr + # + def encodedTypeStr ( self ) : return 'S' + # + # copy + # + def copy ( self ) : + # + newParam = ShaderNodeParam () + self.copySetup ( newParam ) + return newParam + # + # valueFromStr + # + def valueFromStr ( self, str ) : return str + # + # valueToStr + # + def valueToStr ( self, value ) : + # + ret_str = str ( value ) + if not self.isRibParam : ret_str = str ( "\"" + value + "\"" ) + return ret_str + # + # getRangeValues + # + # if subtype == selector then return list of (label,value) pairs + # It's supposed, that range is defined as "value1:value2:value3" + # or "label1=value1:label2=value2:label3=value3:" + # + def getRangeValues ( self ) : + # + rangeList = [] - if self.range != '' : # and self.subtype == 'selector': - tmp_list = str ( self.range ).split ( ':' ) - for s in tmp_list : - pair = s.split ( '=' ) - if len ( pair ) > 1 : - label = pair [0] - value = pair [1] - else : - label = s - value = s - rangeList.append ( ( parseGlobalVars ( label ), parseGlobalVars ( value ) ) ) - return rangeList + if self.range != '' : # and self.subtype == 'selector': + tmp_list = str ( self.range ).split ( ':' ) + for s in tmp_list : + pair = s.split ( '=' ) + if len ( pair ) > 1 : + label = pair [0] + value = pair [1] + else : + label = s + value = s + rangeList.append ( ( parseGlobalVars ( label ), parseGlobalVars ( value ) ) ) + return rangeList diff --git a/core/params/stringNodeParam.py b/core/params/stringNodeParam.py index 1b2eab7..3e60e14 100644 --- a/core/params/stringNodeParam.py +++ b/core/params/stringNodeParam.py @@ -1,69 +1,68 @@ -#=============================================================================== -# stringNodeParam.py -#=============================================================================== -import os, sys +""" -from PyQt4 import QtCore + stringNodeParam.py +""" from core.node import Node from core.nodeParam import NodeParam + from global_vars import app_global_vars, DEBUG_MODE from core.meCommon import parseGlobalVars # # String # class StringNodeParam ( NodeParam ) : - # - # __init__ - # - def __init__ ( self, xml_param = None, isRibParam = False ) : - # - NodeParam.__init__ ( self, xml_param, isRibParam ) - self.type = 'string' - # - # encodedTypeStr - # - def encodedTypeStr ( self ) : return 's' - # - # copy - # - def copy ( self ) : - # - newParam = StringNodeParam () - self.copySetup ( newParam ) - return newParam - # - # valueFromStr - # - def valueFromStr ( self, strInput ) : return parseGlobalVars ( strInput ) - # - # valueToStr - # - def valueToStr ( self, value ) : - # - ret_str = parseGlobalVars ( value ) - if not self.isRibParam : ret_str = str ( "\"" + value + "\"" ) - return ret_str - # - # getRangeValues - # - # if subtype == selector then return list of (label,value) pairs - # It's supposed, that range is defined as "value1:value2:value3" - # or "label1=value1:label2=value2:label3=value3:" - # - def getRangeValues ( self ) : - # - rangeList = [] + # + # __init__ + # + def __init__ ( self, xml_param = None, isRibParam = False ) : + # + NodeParam.__init__ ( self, xml_param, isRibParam ) + self.type = 'string' + # + # encodedTypeStr + # + def encodedTypeStr ( self ) : return 's' + # + # copy + # + def copy ( self ) : + # + newParam = StringNodeParam () + self.copySetup ( newParam ) + return newParam + # + # valueFromStr + # + def valueFromStr ( self, strInput ) : return parseGlobalVars ( strInput ) + # + # valueToStr + # + def valueToStr ( self, value ) : + # + ret_str = parseGlobalVars ( value ) + if not self.isRibParam : ret_str = str ( "\"" + value + "\"" ) + return ret_str + # + # getRangeValues + # + # if subtype == selector then return list of (label,value) pairs + # It's supposed, that range is defined as "value1:value2:value3" + # or "label1=value1:label2=value2:label3=value3:" + # + def getRangeValues ( self ) : + # + rangeList = [] - if self.range != '' : # and self.subtype == 'selector': - tmp_list = str ( self.range ).split ( ':' ) - for s in tmp_list : - pair = s.split ( '=' ) - if len ( pair ) > 1 : - label = pair [0] - value = pair [1] - else : - label = s - value = s - rangeList.append ( ( parseGlobalVars ( label ), parseGlobalVars ( value ) ) ) - return rangeList + if self.range != '' : # and self.subtype == 'selector': + tmp_list = str ( self.range ).split ( ':' ) + for s in tmp_list : + pair = s.split ( '=' ) + if len ( pair ) > 1 : + label = pair [0] + value = pair [1] + else : + label = s + value = s + rangeList.append ( ( parseGlobalVars ( label ), parseGlobalVars ( value ) ) ) + return rangeList diff --git a/core/params/surfaceNodeParam.py b/core/params/surfaceNodeParam.py index b9f7936..b2a0801 100644 --- a/core/params/surfaceNodeParam.py +++ b/core/params/surfaceNodeParam.py @@ -1,34 +1,33 @@ -#=============================================================================== -# surfaceNodeParam.py -#=============================================================================== -import os, sys +""" -from PyQt4 import QtCore + surfaceNodeParam.py +""" from core.node import Node from core.nodeParam import NodeParam + from global_vars import app_global_vars, DEBUG_MODE from core.meCommon import parseGlobalVars # # Surface # class SurfaceNodeParam ( NodeParam ) : - # - # __init__ - # - def __init__ ( self, xml_param = None, isRibParam = False ) : - # - NodeParam.__init__ ( self, xml_param, isRibParam ) - self.type = 'surface' - # - # encodedTypeStr - # - def encodedTypeStr ( self ): return 'S' - # - # copy - # - def copy ( self ) : - # - newParam = SurfaceNodeParam () - self.copySetup ( newParam ) - return newParam \ No newline at end of file + # + # __init__ + # + def __init__ ( self, xml_param = None, isRibParam = False ) : + # + NodeParam.__init__ ( self, xml_param, isRibParam ) + self.type = 'surface' + # + # encodedTypeStr + # + def encodedTypeStr ( self ): return 'S' + # + # copy + # + def copy ( self ) : + # + newParam = SurfaceNodeParam () + self.copySetup ( newParam ) + return newParam \ No newline at end of file diff --git a/core/params/textNodeParam.py b/core/params/textNodeParam.py index 89a49c7..aaa9855 100644 --- a/core/params/textNodeParam.py +++ b/core/params/textNodeParam.py @@ -1,42 +1,41 @@ -#=============================================================================== -# textNodeParam.py -#=============================================================================== -import os, sys +""" -from PyQt4 import QtCore + textNodeParam.py +""" from core.node import Node from core.nodeParam import NodeParam + from global_vars import app_global_vars, DEBUG_MODE from core.meCommon import parseGlobalVars # # Text # class TextNodeParam ( NodeParam ) : - # - # __init__ - # - def __init__ ( self, xml_param = None, isRibParam = False ) : - # - NodeParam.__init__ ( self, xml_param, isRibParam ) - self.type = 'text' - # - # encodedTypeStr - # - def encodedTypeStr ( self ) : return 'X' - # - # copy - # - def copy ( self ) : - # - newParam = TextNodeParam () - self.copySetup ( newParam ) - return newParam - # - # valueToStr - # - # Skip here conversation to str because text - # can contain unicode characters - # - def valueToStr ( self, value ) : - return unicode ( value ) \ No newline at end of file + # + # __init__ + # + def __init__ ( self, xml_param = None, isRibParam = False ) : + # + NodeParam.__init__ ( self, xml_param, isRibParam ) + self.type = 'text' + # + # encodedTypeStr + # + def encodedTypeStr ( self ) : return 'X' + # + # copy + # + def copy ( self ) : + # + newParam = TextNodeParam () + self.copySetup ( newParam ) + return newParam + # + # valueToStr + # + # Skip here conversation to str because text + # can contain unicode characters + # + def valueToStr ( self, value ) : + return unicode ( value ) \ No newline at end of file diff --git a/core/params/transformNodeParam.py b/core/params/transformNodeParam.py index c80cb25..c75ebd9 100644 --- a/core/params/transformNodeParam.py +++ b/core/params/transformNodeParam.py @@ -1,12 +1,12 @@ -#=============================================================================== -# transformNodeParam.py -#=============================================================================== -import os, sys +""" -from PyQt4 import QtCore + transformNodeParam.py + +""" from core.node import Node from core.nodeParam import NodeParam + from global_vars import app_global_vars, DEBUG_MODE from core.meCommon import parseGlobalVars @@ -14,34 +14,34 @@ # Transform parameter that used in RIB # class TransformNodeParam ( NodeParam ) : - # - # - def __init__ ( self, xml_param = None, isRibParam = True ) : - # - NodeParam.__init__ ( self, xml_param, isRibParam ) - self.type = 'transform' - # - # - def encodedTypeStr ( self ) : return 'T' - # - # - def copy ( self ) : - # - newParam = TransformNodeParam () - self.copySetup ( newParam ) - return newParam - # - # - def valueFromStr ( self, strValue ) : - # - value = [ 0.0, 0.0, 0.0 ] - if strValue != '' : - #str = str.replace( ' ', '' ) - transform_values = strValue.split ( ' ' ) - f = map ( float, transform_values ) - value = [ f[0], f[1], f[2] ] - return value - # - # - def valueToStr ( self, value ): - return ''.join ( '%.3f' % f + ' ' for f in value[: - 1] ) + '%.3f' % value [ - 1] \ No newline at end of file + # + # + def __init__ ( self, xml_param = None, isRibParam = True ) : + # + NodeParam.__init__ ( self, xml_param, isRibParam ) + self.type = 'transform' + # + # + def encodedTypeStr ( self ) : return 'T' + # + # + def copy ( self ) : + # + newParam = TransformNodeParam () + self.copySetup ( newParam ) + return newParam + # + # + def valueFromStr ( self, strValue ) : + # + value = [ 0.0, 0.0, 0.0 ] + if strValue != '' : + #str = str.replace( ' ', '' ) + transform_values = strValue.split ( ' ' ) + f = map ( float, transform_values ) + value = [ f[0], f[1], f[2] ] + return value + # + # + def valueToStr ( self, value ): + return ''.join ( '%.3f' % f + ' ' for f in value[: - 1] ) + '%.3f' % value [ - 1] diff --git a/core/params/vectorNodeParam.py b/core/params/vectorNodeParam.py index e23c275..5cfbd98 100644 --- a/core/params/vectorNodeParam.py +++ b/core/params/vectorNodeParam.py @@ -1,110 +1,110 @@ -#=============================================================================== -# vectorNodeParam.py -#=============================================================================== -import os, sys -import re +""" + + vectorNodeParam.py -from PyQt4 import QtCore +""" +import re from core.node import Node from core.nodeParam import NodeParam + from global_vars import app_global_vars, DEBUG_MODE # # Vector # class VectorNodeParam ( NodeParam ) : - # - # __init__ - # - def __init__ ( self, xml_param = None, isRibParam = False ) : - # - NodeParam.__init__ ( self, xml_param, isRibParam ) - self.type = 'vector' - # - # encodedTypeStr - # - def encodedTypeStr ( self ) : return 'v' - # - # copy - # - def copy ( self ) : - # - newParam = VectorNodeParam () - self.copySetup ( newParam ) - return newParam - # - # valueFromStr - # - def valueFromStr ( self, strValue ) : - # - value = [ 0.0, 0.0, 0.0 ] + # + # __init__ + # + def __init__ ( self, xml_param = None, isRibParam = False ) : + # + NodeParam.__init__ ( self, xml_param, isRibParam ) + self.type = 'vector' + # + # encodedTypeStr + # + def encodedTypeStr ( self ) : return 'v' + # + # copy + # + def copy ( self ) : + # + newParam = VectorNodeParam () + self.copySetup ( newParam ) + return newParam + # + # valueFromStr + # + def valueFromStr ( self, strValue ) : + # + value = [ 0.0, 0.0, 0.0 ] - if strValue != '' : - strValue = strValue.replace ( ' ', '' ) - vector3_pattern_str = 'vector\(([-+]?([0-9]*\.)?[0-9]+,){2}[-+]?([0-9]*\.)?[0-9]+\)' - vector1_pattern_str = 'vector\(([-+]?([0-9]*\.)?[0-9]+\))' - vector3_space_pattern_str = 'vector"[a-z]*"\(([-+]?([0-9]*\.)?[0-9]+,){2}[-+]?([0-9]*\.)?[0-9]+\)' - vector1_space_pattern_str = 'vector"[a-z]*"\(([-+]?([0-9]*\.)?[0-9]+\))' - float_pattern_str = '[-+]?[0-9]*\.?[0-9]+' - space_pattern_str = '"[a-z]*"' + if strValue != '' : + strValue = strValue.replace ( ' ', '' ) + vector3_pattern_str = 'vector\(([-+]?([0-9]*\.)?[0-9]+,){2}[-+]?([0-9]*\.)?[0-9]+\)' + vector1_pattern_str = 'vector\(([-+]?([0-9]*\.)?[0-9]+\))' + vector3_space_pattern_str = 'vector"[a-z]*"\(([-+]?([0-9]*\.)?[0-9]+,){2}[-+]?([0-9]*\.)?[0-9]+\)' + vector1_space_pattern_str = 'vector"[a-z]*"\(([-+]?([0-9]*\.)?[0-9]+\))' + float_pattern_str = '[-+]?[0-9]*\.?[0-9]+' + space_pattern_str = '"[a-z]*"' - p = re.compile ( vector3_pattern_str ) - match = p.match ( strValue ) - if match : - # vector(0,0,0) - p = re.compile ( float_pattern_str ) - f = p.findall ( strValue ) - f = map ( float, f ) - value = [ f[0], f[1], f[2] ] - else : - # vector(0) - p = re.compile ( vector1_pattern_str ) - match = p.match ( strValue ) - if match : - p = re.compile ( float_pattern_str ) - f = p.findall ( strValue ) - f = map ( float, f ) - value = [ f[0], f[0], f[0] ] - else : - # vector "space" (0,0,0) - p = re.compile ( vector3_space_pattern_str ) - match = p.match ( strValue ) - if match : - p = re.compile ( float_pattern_str ) - f = p.findall ( strValue ) - f = map ( float, f ) - value = [ f[0], f[1], f[2] ] + p = re.compile ( vector3_pattern_str ) + match = p.match ( strValue ) + if match : + # vector(0,0,0) + p = re.compile ( float_pattern_str ) + f = p.findall ( strValue ) + f = map ( float, f ) + value = [ f[0], f[1], f[2] ] + else : + # vector(0) + p = re.compile ( vector1_pattern_str ) + match = p.match ( strValue ) + if match : + p = re.compile ( float_pattern_str ) + f = p.findall ( strValue ) + f = map ( float, f ) + value = [ f[0], f[0], f[0] ] + else : + # vector "space" (0,0,0) + p = re.compile ( vector3_space_pattern_str ) + match = p.match ( strValue ) + if match : + p = re.compile ( float_pattern_str ) + f = p.findall ( strValue ) + f = map ( float, f ) + value = [ f[0], f[1], f[2] ] - p = re.compile ( space_pattern_str ) - s = p.findall ( strValue ) - sp = str ( s[0] ) - self.space = sp.strip ( '"' ) - else : - # vector "space" (0) - p = re.compile ( vector1_space_pattern_str ) - match = p.match ( strValue ) - if match : - p = re.compile ( float_pattern_str ) - f = p.findall ( strValue ) - f = map ( float, f ) - value = [ f[0], f[0], f[0] ] + p = re.compile ( space_pattern_str ) + s = p.findall ( strValue ) + sp = str ( s[0] ) + self.space = sp.strip ( '"' ) + else : + # vector "space" (0) + p = re.compile ( vector1_space_pattern_str ) + match = p.match ( strValue ) + if match : + p = re.compile ( float_pattern_str ) + f = p.findall ( strValue ) + f = map ( float, f ) + value = [ f[0], f[0], f[0] ] - p = re.compile ( space_pattern_str ) - s = p.findall ( strValue ) - sp = str ( s[0] ) - self.space = sp.strip ( '"' ) - else : - err = 'Cannot parse vector %s values' % self.name - raise Exception ( err ) - return value - # - # valueToStr - # - def valueToStr ( self, value ) : - # - ret_str = 'vector' + p = re.compile ( space_pattern_str ) + s = p.findall ( strValue ) + sp = str ( s[0] ) + self.space = sp.strip ( '"' ) + else : + err = 'Cannot parse vector %s values' % self.name + raise Exception ( err ) + return value + # + # valueToStr + # + def valueToStr ( self, value ) : + # + ret_str = 'vector' - if self.space != None : - if self.space != '' : - ret_str += ' "' + self.space + '" ' - return ret_str +'(' + ''.join ( '%.3f' % f + ',' for f in value[: - 1] ) + '%.3f' % value [ - 1] + ')' + if self.space != None : + if self.space != '' : + ret_str += ' "' + self.space + '" ' + return ret_str +'(' + ''.join ( '%.3f' % f + ',' for f in value[: - 1] ) + '%.3f' % value [ - 1] + ')' diff --git a/core/params/volumeNodeParam.py b/core/params/volumeNodeParam.py index 6b882ab..65754cd 100644 --- a/core/params/volumeNodeParam.py +++ b/core/params/volumeNodeParam.py @@ -1,34 +1,33 @@ -#=============================================================================== -# volumeNodeParam.py -#=============================================================================== -import os, sys +""" -from PyQt4 import QtCore + volumeNodeParam.py +""" from core.node import Node from core.nodeParam import NodeParam + from global_vars import app_global_vars, DEBUG_MODE from core.meCommon import parseGlobalVars # # Volume # class VolumeNodeParam ( NodeParam ) : - # - # __init__ - # - def __init__ ( self, xml_param = None, isRibParam = False ) : - # - NodeParam.__init__ ( self, xml_param, isRibParam ) - self.type = 'volume' - # - # encodedTypeStr - # - def encodedTypeStr ( self ): return 'V' - # - # copy - # - def copy ( self ): - # - newParam = VolumeNodeParam() - self.copySetup ( newParam ) - return newParam \ No newline at end of file + # + # __init__ + # + def __init__ ( self, xml_param = None, isRibParam = False ) : + # + NodeParam.__init__ ( self, xml_param, isRibParam ) + self.type = 'volume' + # + # encodedTypeStr + # + def encodedTypeStr ( self ): return 'V' + # + # copy + # + def copy ( self ): + # + newParam = VolumeNodeParam() + self.copySetup ( newParam ) + return newParam \ No newline at end of file diff --git a/core/swatchInfo.py b/core/swatchInfo.py index 09481de..1041322 100644 --- a/core/swatchInfo.py +++ b/core/swatchInfo.py @@ -1,17 +1,17 @@ #=============================================================================== -# swatch.py +# swatchinfo.py # # # #=============================================================================== import os, sys -from PyQt4 import QtCore +from core.mePyQt import QtCore from global_vars import app_global_vars, DEBUG_MODE from core.node_global_vars import node_global_vars import gui.ui_settings as UI # -# Node +# SwatchInfo # class SwatchInfo ( QtCore.QObject ) : # diff --git a/core/utils/ShaderInfo.py b/core/utils/ShaderInfo.py index 072561a..65a0845 100644 --- a/core/utils/ShaderInfo.py +++ b/core/utils/ShaderInfo.py @@ -1,12 +1,12 @@ -#=============================================================================== -# ShaderInfo.py -#=============================================================================== +""" + + ShaderInfo.py + +""" import os, sys import re -from PyQt4 import QtCore from global_vars import app_global_vars, DEBUG_MODE, VALID_RSL_PARAM_TYPES - from core.meCommon import parseGlobalVars from core.params.floatNodeParam import FloatNodeParam @@ -22,590 +22,590 @@ # ShaderInfo # class ShaderInfo () : - # - # __init__ - # - def __init__ ( self, shaderFileName = None ) : - # - self.fileName = parseGlobalVars ( shaderFileName ) - self.name = None - self.type = None - self.inputParams = [] - self.outputParams = [] - - self.parseParamLineProc = self.parseParamLine - self.parseValueLineProc = self.parseValueLine_prman - - parseParamLineProcTable = { - 'prman' : self.parseParamLine - ,'renderdl' : self.parseParamLine - ,'air' : self.parseParamLine_air - ,'aqsis' : self.parseParamLine - ,'rndr' : self.parseParamLine_pixie - ,'renderdc' : self.parseParamLine_pixie - } - - parseValueLineProcTable = { - 'prman' : self.parseValueLine_prman - ,'renderdl' : self.parseValueLine_delight - ,'air' : self.parseValueLine_air - ,'aqsis' : self.parseValueLine_aqsis - ,'rndr' : self.parseValueLine_pixie - ,'renderdc' : self.parseValueLine_prman - } - - self.renderer = app_global_vars [ 'RendererName' ] - - if self.renderer in parseParamLineProcTable.keys () : self.parseParamLineProc = parseParamLineProcTable [ self.renderer ] - if self.renderer in parseValueLineProcTable.keys () : self.parseValueLineProc = parseValueLineProcTable [ self.renderer ] - - if self.fileName is not None : - self.parseParamsInfo ( self.getShaderInfo () ) - if self.renderer == 'rndr' : - # Pixie's sdrinfo outputs parameters in reverse order. - # Hence, lets reverse them again - self.inputParams.reverse () - self.outputParams.reverse () - # - # getShaderInfo - # - def getShaderInfo ( self, methods = False ) : - # - inputLines = [] - if DEBUG_MODE : print '>> ShaderInfo.get ( %s ) by "%s"' % ( self.fileName, app_global_vars [ 'ShaderInfo' ] ) - from core.meCommon import launchProcess - curDir = os.getcwd () - - cmdList = [] - cmdList.append ( app_global_vars [ 'ShaderInfo' ] ) - if methods : - cmdList.append ( '--methods' ) - if self.renderer == 'renderdc' : - dirName = os.path.dirname ( self.fileName ) - fileName = os.path.basename ( self.fileName ) - ( fileName, ext ) = os.path.splitext ( fileName ) - cmdList.append ( fileName ) - os.chdir ( dirName ) - else : - cmdList.append ( self.fileName ) - - tmpDir = app_global_vars [ 'TempPath' ] - - stdoutLog = os.path.join ( tmpDir, 'stdout-%s.log' % os.path.basename ( self.fileName ) ) - stderrLog = os.path.join ( tmpDir, 'stderr-%s.log' % os.path.basename ( self.fileName ) ) - - launchProcess ( cmdList, stdoutLog, stderrLog ) - - stdout = file ( stdoutLog, 'r' ) - stderr = file ( stderrLog, 'r' ) - - inputLines = stdout.read ().split ( '\n' ) - - stdout.close () - stderr.close () - if self.renderer == 'renderdc' : os.chdir ( curDir ) - return inputLines - # - # parseParamsInfo - # - def parseParamsInfo ( self, inputLines ) : - # - self.name = None - self.type = None - - paramName = None - paramType = None - isOutput = False - paramDetail = None - paramValue = None - paramSpace = None - paramArraySize = None - - param = None - createParamTable = { 'float' : FloatNodeParam - ,'color' : ColorNodeParam - ,'string' : StringNodeParam - ,'shader' : ShaderNodeParam - ,'normal' : NormalNodeParam - ,'point' : PointNodeParam - ,'vector' : VectorNodeParam - ,'matrix' : MatrixNodeParam - } - - valueIdx = 0 - valueNum = 1 - accumLine = '' - accumLinesNum = 0 - - state = 'GET_TYPE' - - for line in inputLines : - line = line.strip () - if line != '' : - if state == 'GET_TYPE' : - # get shader name and type - ( self.name, self.type ) = self.parseShaderNameLine ( line ) - print '>> shader name = %s type = %s' % ( self.name, self.type ) - state = 'GET_PARAM' - elif state == 'GET_PARAM' : - # get parameter description - ( paramName, paramType, paramDetail, isOutput, paramArraySize ) = self.parseParamLineProc ( line ) - print '>> paramName = %s type = "%s %s" output = %s ArraySize = %s' % ( paramName, paramDetail, paramType, isOutput, paramArraySize ) - - if paramType in createParamTable.keys () : - param = createParamTable [ paramType ] ( isRibParam = True ) - print '** created "%s" param "%s"' % ( paramType, paramName ) - param.setup ( paramName, paramName, paramDetail, 'attribute' ) - param.arraySize = paramArraySize - param.isInput = not isOutput - if param.isInput : - self.inputParams.append ( param ) - else : - self.outputParams.append ( param ) - else : - param = None - print '* Error: unknown param type !' - - valueNum = 1 - if self.renderer in [ 'prman', 'aqsis', 'renderdc' ] : - if paramArraySize is not None : - valueNum = paramArraySize - if paramType == 'matrix' and self.renderer in [ 'prman', 'renderdc' ] : - accumLine = '' - accumLinesNum = 3 - valueIdx = 0 - if self.renderer != 'air' : - state = 'GET_VALUE' - else : - # in AIR case, default value is in the same line, as parameter name - if paramArraySize is None : - ( paramValue, paramSpace ) = self.parseValueLineProc ( line, paramType ) - print '>> paramValue = "%s" paramSpace = "%s"' % ( paramValue, paramSpace ) - if param is not None : - param.default = paramValue - param.value = paramValue - param.space = paramSpace - else : - for valueIdx in range ( paramArraySize ) : - ( paramValue, paramSpace ) = self.parseValueLineProc ( line, paramType, valueIdx, True ) - print '>> paramValue = "%s" paramSpace = "%s"' % ( paramValue, paramSpace ) - if param is not None : - param.defaultArray.append ( paramValue ) - param.valueArray.append ( paramValue ) - elif state == 'GET_VALUE' : - # get value ( or arrays elements ) - if accumLinesNum > 0 : - accumLinesNum -= 1 - accumLine += ( line + ' ' ) - continue - if self.renderer in [ 'prman', 'renderdc' ] and paramType == 'matrix' : - line = accumLine + line - if paramArraySize is None : - ( paramValue, paramSpace ) = self.parseValueLineProc ( line, paramType ) - print '>> paramValue = "%s" paramSpace = "%s"' % ( paramValue, paramSpace ) - if param is not None : - param.default = paramValue - param.value = paramValue - param.space = paramSpace - else : - print '* Warning: Arrays are not fully supported yet !' - if self.renderer in [ 'prman', 'aqsis', 'renderdc' ] : - ( paramValue, paramSpace ) = self.parseValueLineProc ( line, paramType, valueIdx ) - print '>> paramValue = "%s" paramSpace = "%s"' % ( paramValue, paramSpace ) - if param is not None : - param.defaultArray.append ( paramValue ) - param.valueArray.append ( paramValue ) - else : - for valueIdx in range ( paramArraySize ) : - ( paramValue, paramSpace ) = self.parseValueLineProc ( line, paramType, valueIdx, True ) - print '>> paramValue = "%s" paramSpace = "%s"' % ( paramValue, paramSpace ) - if param is not None : - param.defaultArray.append ( paramValue ) - param.valueArray.append ( paramValue ) - valueIdx = valueIdx + 1 - if valueIdx >= valueNum : - state = 'GET_PARAM' - else : - if self.renderer in [ 'prman', 'renderdc' ] and paramType == 'matrix' : - accumLine = '' - accumLinesNum = 3 - # - # parseShaderNameLine - # - def parseShaderNameLine ( self, inputStr ) : - # - s = inputStr.split ( ' ' ) - type = s[0] - name = s[1] - if self.renderer == 'air' : - airShaderType = { 'Surface' : 'surface' - ,'Displacement' : 'displacement' - ,'LightSource' : 'light' - ,'Volume' : 'volume' - ,'Shader' : 'shader' - } - type = airShaderType [ type ] - - return ( name.strip ( '"' ), type ) - # - # parseParamLine - # - def parseParamLine ( self, inputStr ) : - # - # print 'parsing param: %s ...' % inputStr - paramName = None - paramType = None - paramDetail = None - isOutput = False - paramArraySize = None - - name_pattern_str = '"\w*"' # '"[a-zA-Z0-9_]*"' - type_pattern_str = '"[][\w\s]*"' - type_prefix = '(output )?parameter [uniformvaryg ]+ ' #'[\w\s]*' # '*[uniformvaryg ]+ ' - - p = re.compile ( name_pattern_str ) - if p.match ( inputStr ) : - paramName = ( p.findall ( inputStr ) [ 0 ] ).strip ( '"' ) - p = re.compile ( type_pattern_str ) - if p.match ( inputStr ) : - typeStr = ( p.findall ( inputStr ) [ 1 ] ).strip ( '"' ) - - if 'output' in typeStr : isOutput = True - - for param_type in VALID_RSL_PARAM_TYPES : - p = re.compile ( type_prefix + param_type ) - if p.match ( typeStr ) : - paramType = param_type - break - - for param_detail in [ 'uniform', 'varying' ] : - if param_detail in typeStr : - paramDetail = param_detail - break - - match = re.search ( r'\[[\d]*\]$', typeStr ) - - if match : - arr_size_str = match.group ().strip ( '[]' ) - if arr_size_str == '' : arr_size_str = '0' - paramArraySize = int ( arr_size_str ) - - return ( paramName, paramType, paramDetail, isOutput, paramArraySize ) - # - # parseParamLine_air - # - def parseParamLine_air ( self, inputStr ) : - # - # print 'parsing param: %s ...' % inputStr - paramName = None - paramType = None - paramDetail = 'uniform' - isOutput = False - paramArraySize = None - - match = re.search ( r'\A"[][\w\s]*"', inputStr ) - - if match : - paramStr = match.group ().strip ( '"' ) - match = re.search ( r'(output )?(varying)?', paramStr ) - if match : - type_prefix = match.group () - if 'output' in type_prefix : isOutput = True - if 'varying' in type_prefix : paramDetail = 'varying' - paramStr = paramStr.replace ( type_prefix, '' ) - match = re.search ( r'[][a-zA-Z0-9]+ [\w]+', paramStr ) - if match : - s = match.group ().split ( ' ' ) - paramName = s[1] - typeStr = s[0] - for param_type in VALID_RSL_PARAM_TYPES : - p = re.compile ( param_type + '*' ) - if p.match ( typeStr ) : - paramType = param_type - break - match = re.search ( r'\[[\d]*\]', typeStr ) - if match : - arr_size_str = match.group ().strip ( '[]' ) - if arr_size_str == '' : arr_size_str = '0' - paramArraySize = int ( arr_size_str ) - - return ( paramName, paramType, paramDetail, isOutput, paramArraySize ) - # - # parseParamLine_pixie - # - def parseParamLine_pixie ( self, inputStr ) : - # - # print 'parsing param: %s ...' % inputStr - paramName = None - paramType = None - paramDetail = None - isOutput = False - paramArraySize = None - - name_pattern_str = '"\w*"' - type_pattern_str = '"[][\w\s]*"' - type_prefix = '(output )?[uniformvaryg ]+ ' - - p = re.compile ( name_pattern_str ) - if p.match ( inputStr ) : - paramName = ( p.findall ( inputStr ) [ 0 ] ).strip ( '"' ) - p = re.compile ( type_pattern_str ) - if p.match ( inputStr ) : - typeStr = ( p.findall ( inputStr ) [ 1 ] ).strip ( '"' ) - - if 'output' in typeStr : isOutput = True - - for param_type in VALID_RSL_PARAM_TYPES : - p = re.compile ( type_prefix + param_type ) - if p.match ( typeStr ) : - paramType = param_type - break - - for param_detail in [ 'uniform', 'varying' ] : - if param_detail in typeStr : - paramDetail = param_detail - break - - match = re.search ( r'\[[\d]*\]$', typeStr ) - - if match : - arr_size_str = match.group ().strip ( '[]' ) - if arr_size_str == '' : arr_size_str = '0' - paramArraySize = int ( arr_size_str ) - - return ( paramName, paramType, paramDetail, isOutput, paramArraySize ) - # - # parseValueLine_prman - # - def parseValueLine_prman ( self, inputStr, paramType, idxInArray = 0, isArray = False ) : - # idxInArray is dummy parameter here and used only for compatibility - # with other renderers parseValueLine functions - # - print 'parsing prman value:%s ...' % inputStr - - paramValue = None - paramSpace = None - isValid = False - - match = re.search ( r'\ADefault value: ', inputStr ) - if match : - isValid = True - else : - match = re.search ( r'\AUniform default value: ', inputStr ) - if match : - isValid = True - if isValid : - valueStr = inputStr.replace ( match.group (), '' ) - if paramType in [ 'string', 'shader' ] : - paramValue = valueStr.strip ( '"' ) - elif paramType == 'float' : - paramValue = float ( valueStr ) - elif paramType in [ 'color', 'point', 'vector', 'normal', 'matrix' ] : - match = re.search ( r'\A"[a-zA-Z]+"', valueStr ) - if match : - paramSpace = match.group ().strip ( '"' ) - s = re.findall ( r'[+-]?[\d\.]+', valueStr ) - f = map ( float, s ) - if paramType != 'matrix' : - paramValue = [ f[0], f[1], f[2] ] - else : - print '*** ', s - paramValue = [ f[0:4], f[4:8], f[8:12], f[12:16] ] - - return ( paramValue, paramSpace ) - # - # parseValueLine_delight - # - def parseValueLine_delight ( self, inputStr, paramType, idxInArray = 0, isArray = False ) : - # - print 'parsing value: %s ...' % inputStr - - paramValue = None - paramSpace = None - - match = re.search ( r'\ADefault value: ', inputStr ) - if match : - valueStr = inputStr.replace ( match.group (), '' ) - if paramType in [ 'string', 'shader' ] : - if not isArray : - paramValue = valueStr.strip ( ' "' ) - else : - valueArrayStr = valueStr.strip ( '{}' ) - valueArray = valueArrayStr.split ( ',' ) - paramValue = valueArray [ idxInArray ] .strip ( ' "' ) - elif paramType == 'float' : - if not isArray : - paramValue = float ( valueStr ) - else : - valueArrayStr = valueStr.strip ( '{}' ) - valueArray = valueArrayStr.split ( ',' ) - paramValue = float ( valueArray [ idxInArray ] ) - elif paramType in [ 'color', 'point', 'vector', 'normal', 'matrix' ] : - match = re.search ( r'\A"[a-zA-Z]+"', valueStr ) - if match : - paramSpace = match.group ().strip ( '"' ) - if not isArray : - s = re.findall ( r'[+-]?[\d\.]+', valueStr ) - f = map ( float, s ) - if paramType != 'matrix' : - if len ( f ) == 3 : - paramValue = [ f[0], f[1], f[2] ] - else : - paramValue = [ f[0], f[0], f[0] ] - else : - paramValue = [ f[0:4], f[4:8], f[8:12], f[12:16] ] - else : - valueArrayStr = valueStr.strip ( '{}' ) - valueArray = valueArrayStr.split ( ',' ) - s = re.findall ( r'[+-]?[\d\.]+', valueArray [ idxInArray ] ) - f = map ( float, s ) - if paramType != 'matrix' : - paramValue = [ f[0], f[1], f[2] ] - else : - paramValue = [ f[0:4], f[4:8], f[8:12], f[12:16] ] - - return ( paramValue, paramSpace ) - # - # parseValueLine_air - # - def parseValueLine_air ( self, inputStr, paramType, idxInArray = 0, isArray = False ) : - # - # print 'parsing value: %s ...' % inputStr - - paramValue = None - paramSpace = None - - match = re.search ( r'\[[+-]?[a-zA-Z\d \."]+\]$', inputStr ) - if match : - valueStr = match.group ().strip ( '[]' ) - if paramType in [ 'string', 'shader' ] : - if not isArray : - paramValue = valueStr.strip ( ' "' ) - else : - valueArray = re.findall ( r'"[\w\s\d]*"', valueStr ) - paramValue = valueArray [ idxInArray ] .strip ( ' "' ) - elif paramType == 'float' : - if not isArray : - paramValue = float ( valueStr ) - else : - valueArray = valueStr.split ( ' ' ) - paramValue = float ( valueArray [ idxInArray ].strip ( ' ' ) ) - elif paramType in [ 'color', 'point', 'vector', 'normal', 'matrix' ] : - if not isArray : - s = re.findall ( r'[+-]?[\d\.]+', valueStr ) - f = map ( float, s ) - if paramType != 'matrix' : - if len ( f ) == 3 : - paramValue = [ f[0], f[1], f[2] ] - else : - paramValue = [ f[0], f[0], f[0] ] - else : - paramValue = [ f[0:4], f[4:8], f[8:12], f[12:16] ] - else : - s = re.findall ( r'[+-]?[\d\.]+', valueStr ) - print s - f = map ( float, s ) - if paramType != 'matrix' : - paramValue = [ f[0 + idxInArray*3], f[1 + idxInArray*3], f[2 + idxInArray*3] ] - else : - paramValue = [ f[0 + idxInArray*16:4 + idxInArray*16], f[4 + idxInArray*16:8 + idxInArray*16], f[8 + idxInArray*16:12 + idxInArray*16], f[12 + idxInArray*16:16 + idxInArray*16] ] - - - return ( paramValue, paramSpace ) - # - # parseValueLine_aqsis - # - def parseValueLine_aqsis ( self, inputStr, paramType, idxInArray = 0, isArray = False ) : - # idxInArray is dummy parameter here and used only for compatibility - # with other renderers parseValueLine functions - # - print 'parsing aqsis value: %s ...' % inputStr - - paramValue = None - paramSpace = None - - match = re.search ( r'\ADefault value: ', inputStr ) - if match : - valueStr = inputStr.replace ( match.group (), '' ) - if paramType in [ 'string', 'shader' ] : - paramValue = valueStr.strip ( ' "' ) - elif paramType == 'float' : - paramValue = float ( valueStr ) - elif paramType in [ 'color', 'point', 'vector', 'normal', 'matrix' ] : - match = re.search ( r'\A"[a-zA-Z]+"', valueStr ) - if match : - paramSpace = match.group ().strip ( '"' ) - s = re.findall ( r'[+-]?[\d\.]+', valueStr ) - f = map ( float, s ) - if paramType != 'matrix' : - if len ( f ) == 3 : - paramValue = [ f[0], f[1], f[2] ] - else : - paramValue = [ f[0], f[0], f[0] ] - else : - paramValue = [ f[0:4], f[4:8], f[8:12], f[12:16] ] - - return ( paramValue, paramSpace ) - # - # parseValueLine_pixie - # - def parseValueLine_pixie ( self, inputStr, paramType, idxInArray = 0, isArray = False ) : - # - print 'parsing value: %s ...' % inputStr - - paramValue = None - paramSpace = None - - match = re.search ( r'\ADefault value: ', inputStr ) - if match : - valueStr = inputStr.replace ( match.group (), '' ) - if paramType in [ 'string', 'shader' ] : - if not isArray : - paramValue = valueStr.strip ( ' "' ) - else : - valueArray = re.findall ( r'"[\w\s\d]*"', valueStr ) - paramValue = valueArray [ idxInArray ] .strip ( ' "' ) - elif paramType == 'float' : - if not isArray : - paramValue = float ( valueStr ) - else : - valueArray = valueStr.split ( ' ' ) - print valueArray - paramValue = float ( valueArray [ idxInArray ] ) - elif paramType in [ 'color', 'point', 'vector', 'normal', 'matrix' ] : - match = re.search ( r'\A"[a-zA-Z]+"', valueStr ) - if match : - paramSpace = match.group ().strip ( '"' ) - if not isArray : - s = re.findall ( r'[+-]?[\d\.]+', valueStr ) - f = map ( float, s ) - if paramType != 'matrix' : - if len ( f ) == 3 : - paramValue = [ f[0], f[1], f[2] ] - else : - paramValue = [ f[0], f[0], f[0] ] - else : - paramValue = [ f[0:4], f[4:8], f[8:12], f[12:16] ] - else : - valueArray = re.findall ( r'\[[+-]?[\d\s\.]+\]', valueStr ) - print valueArray - s = re.findall ( r'[+-]?[\d\.]+', valueArray [ idxInArray ].strip ( '[]' ) ) - print s - f = map ( float, s ) - if paramType != 'matrix' : - paramValue = [ f[0], f[1], f[2] ] - else : - paramValue = [ f[0:4], f[4:8], f[8:12], f[12:16] ] - - return ( paramValue, paramSpace ) - # - # parseValueLine_rdc - # - def parseValueLine_rdc ( self, inputStr, paramType, idxInArray = 0, isArray = False ) : - # - print 'parsing value: %s ...' % inputStr - - paramValue = None - paramSpace = None - - return ( paramValue, paramSpace ) + # + # __init__ + # + def __init__ ( self, shaderFileName = None ) : + # + self.fileName = parseGlobalVars ( shaderFileName ) + self.name = None + self.type = None + self.inputParams = [] + self.outputParams = [] + + self.parseParamLineProc = self.parseParamLine + self.parseValueLineProc = self.parseValueLine_prman + + parseParamLineProcTable = { + 'prman' : self.parseParamLine + ,'renderdl' : self.parseParamLine + ,'air' : self.parseParamLine_air + ,'aqsis' : self.parseParamLine + ,'rndr' : self.parseParamLine_pixie + ,'renderdc' : self.parseParamLine_pixie + } + + parseValueLineProcTable = { + 'prman' : self.parseValueLine_prman + ,'renderdl' : self.parseValueLine_delight + ,'air' : self.parseValueLine_air + ,'aqsis' : self.parseValueLine_aqsis + ,'rndr' : self.parseValueLine_pixie + ,'renderdc' : self.parseValueLine_prman + } + + self.renderer = app_global_vars [ 'RendererName' ] + + if self.renderer in parseParamLineProcTable.keys () : self.parseParamLineProc = parseParamLineProcTable [ self.renderer ] + if self.renderer in parseValueLineProcTable.keys () : self.parseValueLineProc = parseValueLineProcTable [ self.renderer ] + + if self.fileName is not None : + self.parseParamsInfo ( self.getShaderInfo () ) + if self.renderer == 'rndr' : + # Pixie's sdrinfo outputs parameters in reverse order. + # Hence, lets reverse them again + self.inputParams.reverse () + self.outputParams.reverse () + # + # getShaderInfo + # + def getShaderInfo ( self, methods = False ) : + # + inputLines = [] + if DEBUG_MODE : print '>> ShaderInfo.get ( %s ) by "%s"' % ( self.fileName, app_global_vars [ 'ShaderInfo' ] ) + from core.meCommon import launchProcess + curDir = os.getcwd () + + cmdList = [] + cmdList.append ( app_global_vars [ 'ShaderInfo' ] ) + if methods : + cmdList.append ( '--methods' ) + if self.renderer == 'renderdc' : + dirName = os.path.dirname ( self.fileName ) + fileName = os.path.basename ( self.fileName ) + ( fileName, ext ) = os.path.splitext ( fileName ) + cmdList.append ( fileName ) + os.chdir ( dirName ) + else : + cmdList.append ( self.fileName ) + + tmpDir = app_global_vars [ 'TempPath' ] + + stdoutLog = os.path.join ( tmpDir, 'stdout-%s.log' % os.path.basename ( self.fileName ) ) + stderrLog = os.path.join ( tmpDir, 'stderr-%s.log' % os.path.basename ( self.fileName ) ) + + launchProcess ( cmdList, stdoutLog, stderrLog ) + + stdout = file ( stdoutLog, 'r' ) + stderr = file ( stderrLog, 'r' ) + + inputLines = stdout.read ().split ( '\n' ) + + stdout.close () + stderr.close () + if self.renderer == 'renderdc' : os.chdir ( curDir ) + return inputLines + # + # parseParamsInfo + # + def parseParamsInfo ( self, inputLines ) : + # + self.name = None + self.type = None + + paramName = None + paramType = None + isOutput = False + paramDetail = None + paramValue = None + paramSpace = None + paramArraySize = None + + param = None + createParamTable = { 'float' : FloatNodeParam + ,'color' : ColorNodeParam + ,'string' : StringNodeParam + ,'shader' : ShaderNodeParam + ,'normal' : NormalNodeParam + ,'point' : PointNodeParam + ,'vector' : VectorNodeParam + ,'matrix' : MatrixNodeParam + } + + valueIdx = 0 + valueNum = 1 + accumLine = '' + accumLinesNum = 0 + + state = 'GET_TYPE' + + for line in inputLines : + line = line.strip () + if line != '' : + if state == 'GET_TYPE' : + # get shader name and type + ( self.name, self.type ) = self.parseShaderNameLine ( line ) + print '>> shader name = %s type = %s' % ( self.name, self.type ) + state = 'GET_PARAM' + elif state == 'GET_PARAM' : + # get parameter description + ( paramName, paramType, paramDetail, isOutput, paramArraySize ) = self.parseParamLineProc ( line ) + print '>> paramName = %s type = "%s %s" output = %s ArraySize = %s' % ( paramName, paramDetail, paramType, isOutput, paramArraySize ) + + if paramType in createParamTable.keys () : + param = createParamTable [ paramType ] ( isRibParam = True ) + print '** created "%s" param "%s"' % ( paramType, paramName ) + param.setup ( paramName, paramName, paramDetail, 'attribute' ) + param.arraySize = paramArraySize + param.isInput = not isOutput + if param.isInput : + self.inputParams.append ( param ) + else : + self.outputParams.append ( param ) + else : + param = None + print '* Error: unknown param type !' + + valueNum = 1 + if self.renderer in [ 'prman', 'aqsis', 'renderdc' ] : + if paramArraySize is not None : + valueNum = paramArraySize + if paramType == 'matrix' and self.renderer in [ 'prman', 'renderdc' ] : + accumLine = '' + accumLinesNum = 3 + valueIdx = 0 + if self.renderer != 'air' : + state = 'GET_VALUE' + else : + # in AIR case, default value is in the same line, as parameter name + if paramArraySize is None : + ( paramValue, paramSpace ) = self.parseValueLineProc ( line, paramType ) + print '>> paramValue = "%s" paramSpace = "%s"' % ( paramValue, paramSpace ) + if param is not None : + param.default = paramValue + param.value = paramValue + param.space = paramSpace + else : + for valueIdx in range ( paramArraySize ) : + ( paramValue, paramSpace ) = self.parseValueLineProc ( line, paramType, valueIdx, True ) + print '>> paramValue = "%s" paramSpace = "%s"' % ( paramValue, paramSpace ) + if param is not None : + param.defaultArray.append ( paramValue ) + param.valueArray.append ( paramValue ) + elif state == 'GET_VALUE' : + # get value ( or arrays elements ) + if accumLinesNum > 0 : + accumLinesNum -= 1 + accumLine += ( line + ' ' ) + continue + if self.renderer in [ 'prman', 'renderdc' ] and paramType == 'matrix' : + line = accumLine + line + if paramArraySize is None : + ( paramValue, paramSpace ) = self.parseValueLineProc ( line, paramType ) + print '>> paramValue = "%s" paramSpace = "%s"' % ( paramValue, paramSpace ) + if param is not None : + param.default = paramValue + param.value = paramValue + param.space = paramSpace + else : + print '* Warning: Arrays are not fully supported yet !' + if self.renderer in [ 'prman', 'aqsis', 'renderdc' ] : + ( paramValue, paramSpace ) = self.parseValueLineProc ( line, paramType, valueIdx ) + print '>> paramValue = "%s" paramSpace = "%s"' % ( paramValue, paramSpace ) + if param is not None : + param.defaultArray.append ( paramValue ) + param.valueArray.append ( paramValue ) + else : + for valueIdx in range ( paramArraySize ) : + ( paramValue, paramSpace ) = self.parseValueLineProc ( line, paramType, valueIdx, True ) + print '>> paramValue = "%s" paramSpace = "%s"' % ( paramValue, paramSpace ) + if param is not None : + param.defaultArray.append ( paramValue ) + param.valueArray.append ( paramValue ) + valueIdx = valueIdx + 1 + if valueIdx >= valueNum : + state = 'GET_PARAM' + else : + if self.renderer in [ 'prman', 'renderdc' ] and paramType == 'matrix' : + accumLine = '' + accumLinesNum = 3 + # + # parseShaderNameLine + # + def parseShaderNameLine ( self, inputStr ) : + # + s = inputStr.split ( ' ' ) + type = s[0] + name = s[1] + if self.renderer == 'air' : + airShaderType = { 'Surface' : 'surface' + ,'Displacement' : 'displacement' + ,'LightSource' : 'light' + ,'Volume' : 'volume' + ,'Shader' : 'shader' + } + type = airShaderType [ type ] + + return ( name.strip ( '"' ), type ) + # + # parseParamLine + # + def parseParamLine ( self, inputStr ) : + # + # print 'parsing param: %s ...' % inputStr + paramName = None + paramType = None + paramDetail = None + isOutput = False + paramArraySize = None + + name_pattern_str = '"\w*"' # '"[a-zA-Z0-9_]*"' + type_pattern_str = '"[][\w\s]*"' + type_prefix = '(output )?parameter [uniformvaryg ]+ ' #'[\w\s]*' # '*[uniformvaryg ]+ ' + + p = re.compile ( name_pattern_str ) + if p.match ( inputStr ) : + paramName = ( p.findall ( inputStr ) [ 0 ] ).strip ( '"' ) + p = re.compile ( type_pattern_str ) + if p.match ( inputStr ) : + typeStr = ( p.findall ( inputStr ) [ 1 ] ).strip ( '"' ) + + if 'output' in typeStr : isOutput = True + + for param_type in VALID_RSL_PARAM_TYPES : + p = re.compile ( type_prefix + param_type ) + if p.match ( typeStr ) : + paramType = param_type + break + + for param_detail in [ 'uniform', 'varying' ] : + if param_detail in typeStr : + paramDetail = param_detail + break + + match = re.search ( r'\[[\d]*\]$', typeStr ) + + if match : + arr_size_str = match.group ().strip ( '[]' ) + if arr_size_str == '' : arr_size_str = '0' + paramArraySize = int ( arr_size_str ) + + return ( paramName, paramType, paramDetail, isOutput, paramArraySize ) + # + # parseParamLine_air + # + def parseParamLine_air ( self, inputStr ) : + # + # print 'parsing param: %s ...' % inputStr + paramName = None + paramType = None + paramDetail = 'uniform' + isOutput = False + paramArraySize = None + + match = re.search ( r'\A"[][\w\s]*"', inputStr ) + + if match : + paramStr = match.group ().strip ( '"' ) + match = re.search ( r'(output )?(varying)?', paramStr ) + if match : + type_prefix = match.group () + if 'output' in type_prefix : isOutput = True + if 'varying' in type_prefix : paramDetail = 'varying' + paramStr = paramStr.replace ( type_prefix, '' ) + match = re.search ( r'[][a-zA-Z0-9]+ [\w]+', paramStr ) + if match : + s = match.group ().split ( ' ' ) + paramName = s[1] + typeStr = s[0] + for param_type in VALID_RSL_PARAM_TYPES : + p = re.compile ( param_type + '*' ) + if p.match ( typeStr ) : + paramType = param_type + break + match = re.search ( r'\[[\d]*\]', typeStr ) + if match : + arr_size_str = match.group ().strip ( '[]' ) + if arr_size_str == '' : arr_size_str = '0' + paramArraySize = int ( arr_size_str ) + + return ( paramName, paramType, paramDetail, isOutput, paramArraySize ) + # + # parseParamLine_pixie + # + def parseParamLine_pixie ( self, inputStr ) : + # + # print 'parsing param: %s ...' % inputStr + paramName = None + paramType = None + paramDetail = None + isOutput = False + paramArraySize = None + + name_pattern_str = '"\w*"' + type_pattern_str = '"[][\w\s]*"' + type_prefix = '(output )?[uniformvaryg ]+ ' + + p = re.compile ( name_pattern_str ) + if p.match ( inputStr ) : + paramName = ( p.findall ( inputStr ) [ 0 ] ).strip ( '"' ) + p = re.compile ( type_pattern_str ) + if p.match ( inputStr ) : + typeStr = ( p.findall ( inputStr ) [ 1 ] ).strip ( '"' ) + + if 'output' in typeStr : isOutput = True + + for param_type in VALID_RSL_PARAM_TYPES : + p = re.compile ( type_prefix + param_type ) + if p.match ( typeStr ) : + paramType = param_type + break + + for param_detail in [ 'uniform', 'varying' ] : + if param_detail in typeStr : + paramDetail = param_detail + break + + match = re.search ( r'\[[\d]*\]$', typeStr ) + + if match : + arr_size_str = match.group ().strip ( '[]' ) + if arr_size_str == '' : arr_size_str = '0' + paramArraySize = int ( arr_size_str ) + + return ( paramName, paramType, paramDetail, isOutput, paramArraySize ) + # + # parseValueLine_prman + # + def parseValueLine_prman ( self, inputStr, paramType, idxInArray = 0, isArray = False ) : + # idxInArray is dummy parameter here and used only for compatibility + # with other renderers parseValueLine functions + # + print 'parsing prman value:%s ...' % inputStr + + paramValue = None + paramSpace = None + isValid = False + + match = re.search ( r'\ADefault value: ', inputStr ) + if match : + isValid = True + else : + match = re.search ( r'\AUniform default value: ', inputStr ) + if match : + isValid = True + if isValid : + valueStr = inputStr.replace ( match.group (), '' ) + if paramType in [ 'string', 'shader' ] : + paramValue = valueStr.strip ( '"' ) + elif paramType == 'float' : + paramValue = float ( valueStr ) + elif paramType in [ 'color', 'point', 'vector', 'normal', 'matrix' ] : + match = re.search ( r'\A"[a-zA-Z]+"', valueStr ) + if match : + paramSpace = match.group ().strip ( '"' ) + s = re.findall ( r'[+-]?[\d\.]+', valueStr ) + f = map ( float, s ) + if paramType != 'matrix' : + paramValue = [ f[0], f[1], f[2] ] + else : + print '*** ', s + paramValue = [ f[0:4], f[4:8], f[8:12], f[12:16] ] + + return ( paramValue, paramSpace ) + # + # parseValueLine_delight + # + def parseValueLine_delight ( self, inputStr, paramType, idxInArray = 0, isArray = False ) : + # + print 'parsing value: %s ...' % inputStr + + paramValue = None + paramSpace = None + + match = re.search ( r'\ADefault value: ', inputStr ) + if match : + valueStr = inputStr.replace ( match.group (), '' ) + if paramType in [ 'string', 'shader' ] : + if not isArray : + paramValue = valueStr.strip ( ' "' ) + else : + valueArrayStr = valueStr.strip ( '{}' ) + valueArray = valueArrayStr.split ( ',' ) + paramValue = valueArray [ idxInArray ] .strip ( ' "' ) + elif paramType == 'float' : + if not isArray : + paramValue = float ( valueStr ) + else : + valueArrayStr = valueStr.strip ( '{}' ) + valueArray = valueArrayStr.split ( ',' ) + paramValue = float ( valueArray [ idxInArray ] ) + elif paramType in [ 'color', 'point', 'vector', 'normal', 'matrix' ] : + match = re.search ( r'\A"[a-zA-Z]+"', valueStr ) + if match : + paramSpace = match.group ().strip ( '"' ) + if not isArray : + s = re.findall ( r'[+-]?[\d\.]+', valueStr ) + f = map ( float, s ) + if paramType != 'matrix' : + if len ( f ) == 3 : + paramValue = [ f[0], f[1], f[2] ] + else : + paramValue = [ f[0], f[0], f[0] ] + else : + paramValue = [ f[0:4], f[4:8], f[8:12], f[12:16] ] + else : + valueArrayStr = valueStr.strip ( '{}' ) + valueArray = valueArrayStr.split ( ',' ) + s = re.findall ( r'[+-]?[\d\.]+', valueArray [ idxInArray ] ) + f = map ( float, s ) + if paramType != 'matrix' : + paramValue = [ f[0], f[1], f[2] ] + else : + paramValue = [ f[0:4], f[4:8], f[8:12], f[12:16] ] + + return ( paramValue, paramSpace ) + # + # parseValueLine_air + # + def parseValueLine_air ( self, inputStr, paramType, idxInArray = 0, isArray = False ) : + # + # print 'parsing value: %s ...' % inputStr + + paramValue = None + paramSpace = None + + match = re.search ( r'\[[+-]?[a-zA-Z\d \."]+\]$', inputStr ) + if match : + valueStr = match.group ().strip ( '[]' ) + if paramType in [ 'string', 'shader' ] : + if not isArray : + paramValue = valueStr.strip ( ' "' ) + else : + valueArray = re.findall ( r'"[\w\s\d]*"', valueStr ) + paramValue = valueArray [ idxInArray ] .strip ( ' "' ) + elif paramType == 'float' : + if not isArray : + paramValue = float ( valueStr ) + else : + valueArray = valueStr.split ( ' ' ) + paramValue = float ( valueArray [ idxInArray ].strip ( ' ' ) ) + elif paramType in [ 'color', 'point', 'vector', 'normal', 'matrix' ] : + if not isArray : + s = re.findall ( r'[+-]?[\d\.]+', valueStr ) + f = map ( float, s ) + if paramType != 'matrix' : + if len ( f ) == 3 : + paramValue = [ f[0], f[1], f[2] ] + else : + paramValue = [ f[0], f[0], f[0] ] + else : + paramValue = [ f[0:4], f[4:8], f[8:12], f[12:16] ] + else : + s = re.findall ( r'[+-]?[\d\.]+', valueStr ) + print s + f = map ( float, s ) + if paramType != 'matrix' : + paramValue = [ f[0 + idxInArray*3], f[1 + idxInArray*3], f[2 + idxInArray*3] ] + else : + paramValue = [ f[0 + idxInArray*16:4 + idxInArray*16], f[4 + idxInArray*16:8 + idxInArray*16], f[8 + idxInArray*16:12 + idxInArray*16], f[12 + idxInArray*16:16 + idxInArray*16] ] + + + return ( paramValue, paramSpace ) + # + # parseValueLine_aqsis + # + def parseValueLine_aqsis ( self, inputStr, paramType, idxInArray = 0, isArray = False ) : + # idxInArray is dummy parameter here and used only for compatibility + # with other renderers parseValueLine functions + # + print 'parsing aqsis value: %s ...' % inputStr + + paramValue = None + paramSpace = None + + match = re.search ( r'\ADefault value: ', inputStr ) + if match : + valueStr = inputStr.replace ( match.group (), '' ) + if paramType in [ 'string', 'shader' ] : + paramValue = valueStr.strip ( ' "' ) + elif paramType == 'float' : + paramValue = float ( valueStr ) + elif paramType in [ 'color', 'point', 'vector', 'normal', 'matrix' ] : + match = re.search ( r'\A"[a-zA-Z]+"', valueStr ) + if match : + paramSpace = match.group ().strip ( '"' ) + s = re.findall ( r'[+-]?[\d\.]+', valueStr ) + f = map ( float, s ) + if paramType != 'matrix' : + if len ( f ) == 3 : + paramValue = [ f[0], f[1], f[2] ] + else : + paramValue = [ f[0], f[0], f[0] ] + else : + paramValue = [ f[0:4], f[4:8], f[8:12], f[12:16] ] + + return ( paramValue, paramSpace ) + # + # parseValueLine_pixie + # + def parseValueLine_pixie ( self, inputStr, paramType, idxInArray = 0, isArray = False ) : + # + print 'parsing value: %s ...' % inputStr + + paramValue = None + paramSpace = None + + match = re.search ( r'\ADefault value: ', inputStr ) + if match : + valueStr = inputStr.replace ( match.group (), '' ) + if paramType in [ 'string', 'shader' ] : + if not isArray : + paramValue = valueStr.strip ( ' "' ) + else : + valueArray = re.findall ( r'"[\w\s\d]*"', valueStr ) + paramValue = valueArray [ idxInArray ] .strip ( ' "' ) + elif paramType == 'float' : + if not isArray : + paramValue = float ( valueStr ) + else : + valueArray = valueStr.split ( ' ' ) + print valueArray + paramValue = float ( valueArray [ idxInArray ] ) + elif paramType in [ 'color', 'point', 'vector', 'normal', 'matrix' ] : + match = re.search ( r'\A"[a-zA-Z]+"', valueStr ) + if match : + paramSpace = match.group ().strip ( '"' ) + if not isArray : + s = re.findall ( r'[+-]?[\d\.]+', valueStr ) + f = map ( float, s ) + if paramType != 'matrix' : + if len ( f ) == 3 : + paramValue = [ f[0], f[1], f[2] ] + else : + paramValue = [ f[0], f[0], f[0] ] + else : + paramValue = [ f[0:4], f[4:8], f[8:12], f[12:16] ] + else : + valueArray = re.findall ( r'\[[+-]?[\d\s\.]+\]', valueStr ) + print valueArray + s = re.findall ( r'[+-]?[\d\.]+', valueArray [ idxInArray ].strip ( '[]' ) ) + print s + f = map ( float, s ) + if paramType != 'matrix' : + paramValue = [ f[0], f[1], f[2] ] + else : + paramValue = [ f[0:4], f[4:8], f[8:12], f[12:16] ] + + return ( paramValue, paramSpace ) + # + # parseValueLine_rdc + # + def parseValueLine_rdc ( self, inputStr, paramType, idxInArray = 0, isArray = False ) : + # + print 'parsing value: %s ...' % inputStr + + paramValue = None + paramSpace = None + + return ( paramValue, paramSpace ) diff --git a/gfx/WorkArea.py b/gfx/WorkArea.py index 15d5e6b..760db12 100644 --- a/gfx/WorkArea.py +++ b/gfx/WorkArea.py @@ -2,10 +2,8 @@ WorkArea.py - """ -import os, sys -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui from core.meCommon import * @@ -22,956 +20,965 @@ from meShaderEd import app_settings from global_vars import DEBUG_MODE -#from ui_workArea import Ui_workArea +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + # # WorkArea # -class WorkArea ( QtGui.QGraphicsView ) : - # - # __init__ - # - def __init__ ( self ) : - # - QtGui.QGraphicsView.__init__ ( self ) - - self.drawGrid = True - self.gridSnap = False - self.straightLinks = False - self.reverseFlow = False - - self.gridSize = 10 - self.minGap = 120 - self.current_Z = 1 - - self.state = 'idle' - self.pressed = False - self.startPos = None - - self.lastConnectCandidate = None - self.currentGfxLink = None - - self.inspectedNode = None - self.nodeNet = None - - self.selectedNodes = [] - self.selectedLinks = [] - - # set scene - scene = QtGui.QGraphicsScene ( self ) - - scene.setSceneRect ( -10000, -10000, 20000, 20000 ) - #scene.setItemIndexMethod ( QtGui.QGraphicsScene.NoIndex ) - self.setScene ( scene ) - - # qt graphics stuff - self.setCacheMode ( QtGui.QGraphicsView.CacheBackground ) - self.setRenderHint ( QtGui.QPainter.Antialiasing ) - - self.setTransformationAnchor ( QtGui.QGraphicsView.AnchorUnderMouse ) # QtGui.QGraphicsView.AnchorUnderMouse - self.setResizeAnchor ( QtGui.QGraphicsView.AnchorUnderMouse ) # AnchorViewCenter - self.setDragMode ( QtGui.QGraphicsView.RubberBandDrag ) - - self.setMouseTracking ( False ) - self.setAcceptDrops ( True ) - """ - viewport = self.viewport() - if viewport is not None : - print ">> WorkArea viewport.setAcceptTouchEvents" - #proxy = QtGui.QGraphicsProxyWidget () - proxy = viewport.graphicsProxyWidget () - if proxy is not None : - proxy.setAcceptTouchEvents ( True ) - - #self.setAttribute ( QtGui.AcceptTouchEvents, True ) - #viewport()->setAttribute(Qt::WA_AcceptTouchEvents); - #setDragMode(ScrollHandDrag); - #Qt::WA_AcceptTouchEvents - """ - self.viewBrush = QtGui.QBrush ( QtGui.QColor ( 148, 148, 148 ) ) - self.setBackgroundBrush ( self.viewBrush ) - - QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'selectionChanged()' ), self.onSelectionChanged ) - - QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'startNodeLink' ), self.onStartNodeLink ) - QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'traceNodeLink' ), self.onTraceNodeLink ) - QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'endNodeLink' ), self.onEndNodeLink ) - - QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'startNodeConnector' ), self.onStartNodeConnector ) - QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'traceNodeConnector' ), self.onTraceNodeConnector ) - QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'endNodeConnector' ), self.onEndNodeConnector ) - - QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'onGfxNodeRemoved' ), self.onRemoveNode ) - QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'onGfxLinkRemoved' ), self.onRemoveLink ) - - if DEBUG_MODE : print ">> WorkArea. __init__" - # - # drawBackground - # - def drawBackground ( self, painter, rect ) : - # - sc_rect = self.sceneRect () - bbrush = QtGui.QBrush( QtGui.QColor ( 148, 148, 148 ) ) ## painter.background() - painter.fillRect ( rect, bbrush ) - - if self.drawGrid : - # print( "grid size = %d" % self.gridSize ) - gr_pen = QtGui.QPen ( QtGui.QColor ( 180, 180, 180 ) ) - gr_pen.setWidth ( 0 ) - painter.setPen ( gr_pen ) - for x in range ( int ( sc_rect.x () ), int ( sc_rect.right () ), self.gridSize ): - painter.drawLine ( x, sc_rect.y (), x, sc_rect.bottom () ) - for y in range ( int ( sc_rect.y () ), int ( sc_rect.bottom () ), self.gridSize ): - painter.drawLine ( sc_rect.x (), y, sc_rect.right (), y ) - # - # Returns a list of GfxNodes in the scene for given type - # or all nodes if type == None - # - def getGfxNodesByType ( self, type = None ) : - # - resultList = [] - for item in self.scene ().items () : - if ( isinstance ( item, GfxNode ) or - isinstance ( item, GfxSwatchNode ) or - ( isinstance ( item, GfxNodeConnector ) and item.isNode () ) ) : - if type is None or item.node.type == type : - resultList.append ( item ) - return resultList - # - # Returns GfxNodes for given Node - # - def getGfxNodesByNode ( self, node = None ) : - # - gfxNode = None - for item in self.scene ().items () : - if ( isinstance ( item, GfxNode ) or - isinstance ( item, GfxSwatchNode ) or - ( isinstance ( item, GfxNodeConnector ) and item.isNode () ) ) : - if item.node == node : - gfxNode = item - break - return gfxNode - # - # selectAllNodes - # - def getAllGfxNodes ( self ) : return self.getGfxNodesByType ( None ) - # - # selectAllNodes - # - def selectAllNodes ( self ) : - # - for item in self.getAllGfxNodes () : item.setSelected ( True ) - # - # selectAbove - # - def selectAbove ( self, upperGfxNode ) : - # - if DEBUG_MODE : print '>> WorkArea::selectAbove node (%s) links:' % upperGfxNode.node.label - for link_list in upperGfxNode.node.outputLinks.values () : - for link in link_list : - # link.printInfo () - if self.nodeNet.hasThisLink ( link ) : - gfxNode = self.getGfxNodesByNode ( link.dstNode ) - gfxNode.setSelected ( True ) - self.selectAbove ( gfxNode ) - else : - if DEBUG_MODE : print '!! invalid link ...' - # - # updateBelow - # - def updateBelow ( self, upperGfxNode, removeLinks = False ) : - # - if DEBUG_MODE : print '>> WorkArea::updateBelow upperGfxNode.node (%s) children:' % upperGfxNode.node.label - for node in upperGfxNode.node.childs : - if DEBUG_MODE : print '* %s' % node.label - gfxNode = self.getGfxNodesByNode ( node ) - gfxNode.updateGfxNode ( removeLinks ) - self.updateBelow ( gfxNode, removeLinks ) - # - # selectBelow - # - def selectBelow ( self, upperGfxNode ) : - # - if DEBUG_MODE : print '>> WorkArea::selectBelow upperGfxNode.node (%s) children:' % upperGfxNode.node.label - for node in upperGfxNode.node.childs : - if DEBUG_MODE : print '* %s' % node.label - gfxNode = self.getGfxNodesByNode ( node ) - gfxNode.setSelected ( True ) - self.selectBelow ( gfxNode ) - # - # setNodeNetwork - # - def setNodeNetwork ( self, nodeNet ) : self.nodeNet = nodeNet - # - # clear - # - def clear ( self ): - # - if DEBUG_MODE : print '>> WorkArea:: clearing nodes ...' - for item in self.scene ().items () : self.scene ().removeItem ( item ) - self.nodeNet.clear () - self.state = 'idle' - self.panStartPos = None - self.lastConnectCandidate = None - self.currentGfxLink = None - self.inspectedNode = None - # - # addGfxLink - # - def addGfxLink ( self, link ) : - # - if DEBUG_MODE : print '>> WorkArea::addGfxLink (id=%d)' % link.id - gfxLink = GfxLink ( link ) - ( srcNode, srcParam ) = link.getSrc () - ( dstNode, dstParam ) = link.getDst () - srcConnector = None - dstConnector = None - for item in self.scene ().items (): - if isinstance ( item, GfxNode ) or isinstance ( item, GfxSwatchNode ) : - if item.node == srcNode : - srcConnector = item.getOutputConnectorByParam ( srcParam ) - elif item.node == dstNode : - dstConnector = item.getInputConnectorByParam ( dstParam ) - elif isinstance ( item, GfxNodeConnector ) and item.isNode () : - if item.node == srcNode : - srcConnector = item - elif item.node == dstNode : - dstConnector = item - if ( srcConnector != None and dstConnector != None ) : - break - gfxLink.setSrcConnector ( srcConnector ) - gfxLink.setDstConnector ( dstConnector ) - gfxLink.adjust () - self.scene ().addItem ( gfxLink ) - # - # Node already in NodeNet, so add new GfxNode to scene - # - def addGfxNode ( self, node, pos = None ) : - # - #print ( ">> WorkArea: addGfxNode %s" % node.label ) - if node.type == 'connector' : - gfxNode = GfxNodeConnector ( node.inputParams [ 0 ], node = node ) - elif node.type == 'note' : - gfxNode = GfxNote ( node ) - elif node.type == 'swatch' : - gfxNode = GfxSwatchNode ( node ) - else : - gfxNode = GfxNode ( node ) - scene = self.scene () - if pos != None : gfxNode.moveBy ( pos.x(), pos.y() ) - #for item in scene.selectedItems (): item.setSelected ( False ) - scene.addItem ( gfxNode ) - gfxNode.setSelected ( True ) - self.emit ( QtCore.SIGNAL ( 'gfxNodeAdded' ), gfxNode ) - # - # adjustLinks - # - def adjustLinks ( self ) : - # - for item in self.scene ().items () : - if isinstance ( item, GfxLink ): item.adjust () - # - # fitGfxNodesInView - # - def fitGfxNodesInView ( self, gfxNodeList ) : - # - nodeNetRect = QtCore.QRectF () - for gfxNode in gfxNodeList : - nodeRect = gfxNode.sceneBoundingRect () - if nodeNetRect.isNull () : - nodeNetRect = nodeRect - nodeNetRect = nodeNetRect.united ( nodeRect ) - if nodeNetRect.isValid () : - self.fitInView ( nodeNetRect, QtCore.Qt.KeepAspectRatio ) - # - # onSelectionChanged - # - def onSelectionChanged ( self ) : - # - #print ">> WorkArea: onSelectionChanged " - self.selectedNodes = [] - self.selectedLinks = [] - selected = self.scene ().selectedItems () - - for item in selected: - if isinstance ( item, GfxNode ) : self.selectedNodes.append ( item ) - elif isinstance ( item, GfxNote ) : self.selectedNodes.append ( item ) - elif isinstance ( item, GfxNodeConnector ) : self.selectedNodes.append ( item ) - elif isinstance ( item, GfxSwatchNode ) : self.selectedNodes.append ( item ) - elif isinstance ( item, GfxLink ) : self.selectedLinks.append ( item ) - - self.emit ( QtCore.SIGNAL ( 'selectNodes' ), self.selectedNodes, self.selectedLinks ) - # - # lastConnectCandidateReset - # - def lastConnectCandidateReset ( self ) : - # - if self.lastConnectCandidate is not None : - self.lastConnectCandidate.hilite( False ) - self.lastConnectCandidate = None - # - # isLinkAcceptable - # - def isLinkAcceptable ( self, connector, connectCandidate ) : - # - isAcceptable = False - if isinstance ( connectCandidate, GfxNodeConnector ): - # do not connect to itself - if connectCandidate != connector : - # do not connect to the same node - if connectCandidate.parentItem () != connector.parentItem () : - # do not connect the same link to connector twice - if not connectCandidate.hasThisLink ( self.currentGfxLink ) : - # connect only to similar type - if connector.param.encodedTypeStr() == connectCandidate.param.encodedTypeStr () : - if not connectCandidate.isNode () : - # connect only input with output and vice versa - if connector.param.isInput != connectCandidate.param.isInput : - isAcceptable = True - else : - # we have nodeConnector - isAcceptable = True - - return isAcceptable - # - # onStartNodeLink - # - def onStartNodeLink ( self, connector ): - # - srcNode = connector.getNode () - srcParam = connector.param - if DEBUG_MODE : print '>> WorkArea::onStartNodeLink from %s (%s)' % ( srcNode.label, srcParam.label ) - - srcConnector = connector - self.state = 'traceNodeLink' - self.lastConnectCandidate = None - - if connector.isInput () and connector.isLinked () : - oldLink = connector.getFirstGfxLink () - srcConnector = oldLink.srcConnector - oldLink.remove () - - gfxLink = GfxLink ( None, srcConnector ) - self.scene ().addItem ( gfxLink ) - self.currentGfxLink = gfxLink - self.currentGfxLink.isLinkSelected = True - # - # onTraceNodeLink - # - def onTraceNodeLink ( self, connector, scenePos ) : - # node = connector.parentItem().node - # print ">> WorkArea: onDrawNodeLink from %s (%d %d)" % ( node.label, scenePos.x(), scenePos.y() ) - connectCandidate = self.scene ().itemAt ( scenePos ) - srcConnector = self.currentGfxLink.srcConnector - swappedLink = False - if srcConnector is None : # link has swapped connectors - srcConnector = self.currentGfxLink.dstConnector - swappedLink = True - - if self.isLinkAcceptable ( srcConnector, connectCandidate ) : - if connectCandidate != self.lastConnectCandidate : - self.lastConnectCandidateReset () - connectCandidate.hilite ( True ) - self.lastConnectCandidate = connectCandidate - # link_node = connectCandidate.parentItem ().node - # print ">> WorkArea: onDrawNodeLink to %s" % link_node.label - else : - scenePos = self.lastConnectCandidate.getCenterPoint () # snap to last position - pass - # self.lastConnectCandidateReset () - else : - self.lastConnectCandidateReset () - - #if self.currentGfxLink is not None : - if swappedLink : - self.currentGfxLink.setSrcPoint ( scenePos ) - else : - self.currentGfxLink.setDstPoint ( scenePos ) - # - # onEndNodeLink - # - def onEndNodeLink ( self, connector, scenePos ) : - # - srcConnector = self.currentGfxLink.srcConnector - dstConnector = self.currentGfxLink.dstConnector - swappedLink = False - if srcConnector is None : # link has swapped connectors - swappedLink = True - - if self.lastConnectCandidate is None : - self.currentGfxLink.remove () - #self.emit( QtCore.SIGNAL( 'nodeParamChanged' ), srcConnector.parentItem(), srcConnector.param ) - #self.emit( QtCore.SIGNAL( 'nodeParamChanged' ), dstConnector.parentItem(), dstConnector.param ) - else : - if self.lastConnectCandidate.isNode () : - # if connection was made to ConnectorNode - if dstConnector is None : - self.lastConnectCandidate.removeInputGfxLinks () - else : - # remove old link first if it exists - if self.lastConnectCandidate.isInput () and self.lastConnectCandidate.isLinked () : - #oldLink = self.lastConnectCandidate.getFirstLink () - #oldLink.remove () - self.lastConnectCandidate.removeInputGfxLinks () - - self.currentGfxLink.isLinkSelected = False - self.currentGfxLink.update () - - srcNode = dstNode = None - srcParam = dstParam = None - - if swappedLink : - srcNode = self.lastConnectCandidate.getNode () - srcParam = self.lastConnectCandidate.param - if self.lastConnectCandidate.isNode () : - srcParam = self.lastConnectCandidate.getFirstOutputParam () - dstNode = dstConnector.getNode () - dstParam = dstConnector.param - self.currentGfxLink.setSrcConnector ( self.lastConnectCandidate ) - else : - srcNode = srcConnector.getNode () - srcParam = srcConnector.param - dstNode = self.lastConnectCandidate.getNode () - dstParam = self.lastConnectCandidate.param - if self.lastConnectCandidate.isNode () : - dstParam = self.lastConnectCandidate.getFirstInputParam () - self.currentGfxLink.setDstConnector ( self.lastConnectCandidate ) - - link = NodeLink.build ( srcNode, dstNode, srcParam, dstParam ) - - #if not dstParam.isInput : - # swap source and destination - # self.currentGfxLink.swapConnectors () - # link.swapNodes () - - self.currentGfxLink.link = link - self.nodeNet.addLink ( link ) - #self.emit ( QtCore.SIGNAL ( 'nodeConnectionChanged' ), self.currentGfxLink.srcConnector.getGfxNode (), self.currentGfxLink.srcConnector.param ) - self.emit ( QtCore.SIGNAL ( 'nodeConnectionChanged' ), self.currentGfxLink.dstConnector.getGfxNode (), self.currentGfxLink.dstConnector.param ) - - self.lastConnectCandidateReset () - self.currentGfxLink = None - self.state = 'idle' - # - # onStartNodeConnector - # - def onStartNodeConnector ( self, connector, scenePos ) : - # - if DEBUG_MODE : print '>> WorkArea::onStartNodeConnector' - self.state = 'traceNodeConnector' - - newNode = ConnectorNode () - self.nodeNet.addNode ( newNode ) - - newParam = connector.param.copy () - newParam.isInput = False - newInParam = newParam.copy () - newOutParam = newParam.copy () - - newNode.addInputParam ( newInParam ) - newNode.addOutputParam ( newOutParam ) - - newConnector = GfxNodeConnector ( newParam, connector.radius, node = newNode ) - newConnector.brush = connector.brush - newConnector.setPos ( scenePos ) - newConnector.moveBy ( -connector.radius, -connector.radius ) - - self.lastConnectCandidate = newConnector - self.scene ().addItem ( newConnector ) - newConnector.hilite ( True ) - - srcNode = connector.getNode () - srcParam = connector.getOutputParam () - dstNode = newConnector.getNode () - dstParam = newConnector.getInputParam () - - # - # swap link direction only for connectors - # in open chain connected to input node parameter - # - swappedLink = False - if connector.isConnectedToInput () and not connector.isConnectedToOutput () : - if DEBUG_MODE : print '*** swap link direction ***' - swappedLink = True - srcNode = newConnector.getNode () - srcParam = newConnector.getOutputParam () - dstNode = connector.getNode () - dstParam = connector.getInputParam () - - link = NodeLink.build ( srcNode, dstNode, srcParam, dstParam ) - # if swappedLink : link.swapNodes () - self.nodeNet.addLink ( link ) - - #if DEBUG_MODE : self.nodeNet.printInfo () - - # preserve existing links for parameter connectors - if connector.isLinked () and not connector.isNode () : - if connector.isInput () : - #print '*** preserve input ***' - # TODO!!! - # This is very rough code -- needs to be wrapped in functions - gfxLinks = connector.getInputGfxLinks () - - for gfxLink in gfxLinks : - gfxLink.setDstConnector ( newConnector ) - - # remove gfxLink from previouse connector - connector.removeGfxLink ( gfxLink ) - - # adjust destination for node link - newConnector.getNode ().attachInputParamToLink ( newConnector.getInputParam (), gfxLink.link ) - newConnector.getNode ().addChild ( gfxLink.link.srcNode ) - connector.getNode ().removeChild ( gfxLink.link.srcNode ) - - gfxLink.link.dstNode = newConnector.getNode () - gfxLink.link.dstParam = newConnector.getInputParam () - else : - #print '*** preserve output ***' - gfxLinks = connector.getOutputGfxLinks () - - for gfxLink in gfxLinks : - gfxLink.setSrcConnector ( newConnector ) - - # remove gfxLink from previouse connector - connector.removeGfxLink ( gfxLink ) - - # adjust source for node link - connector.getNode ().detachOutputParamFromLink ( gfxLink.link.srcParam, gfxLink.link ) - newConnector.getNode ().attachOutputParamToLink ( newConnector.getOutputParam (), gfxLink.link ) - #newConnector.getNode ().childs.add ( connector.getNode () ) - gfxLink.link.dstNode.addChild ( newConnector.getNode () ) - gfxLink.link.dstNode.removeChild ( connector.getNode () ) - - gfxLink.link.srcNode = newConnector.getNode () - gfxLink.link.srcParam = newConnector.getOutputParam () - - #if DEBUG_MODE : self.nodeNet.printInfo () - - gfxLink = GfxLink ( link, connector, newConnector ) - self.scene ().addItem ( gfxLink ) - # - # onTraceNodeConnector - # - def onTraceNodeConnector ( self, connector, scenePos ) : - # - #if DEBUG_MODE : print '>> WorkArea::onTraceNodeConnector' - if self.lastConnectCandidate is not None : - self.lastConnectCandidate.setPos ( scenePos ) - self.lastConnectCandidate.moveBy ( -connector.radius, -connector.radius ) - # - # onEndNodeConnector - # - def onEndNodeConnector ( self, connector, scenePos ) : - # - if DEBUG_MODE : print '>> WorkArea::onEndNodeConnector' - print '>> lastConnectCandidate.node.type = %s' % self.lastConnectCandidate.node.type - self.lastConnectCandidateReset () - self.state = 'idle' - # - # onRemoveNode - # - def onRemoveNode ( self, gfxNode ) : - # - print ">> WorkArea.onRemoveNode %s (id = %d)" % ( gfxNode.node.label, gfxNode.node.id ) - self.emit ( QtCore.SIGNAL ( 'gfxNodeRemoved' ), gfxNode ) - self.scene ().removeItem ( gfxNode ) - self.nodeNet.removeNode ( gfxNode.node ) - - #if DEBUG_MODE : self.nodeNet.printInfo () - # - # onRemoveLink - # - def onRemoveLink ( self, gfxLink ) : - # - print ">> WorkArea.onRemoveLink ..." - self.scene ().removeItem ( gfxLink ) - - if gfxLink.link is not None : - print "*** (id = %d)" % ( gfxLink.link.id ) - srcConnector = gfxLink.srcConnector - dstConnector = gfxLink.dstConnector - self.nodeNet.removeLink ( gfxLink.link ) - if srcConnector is not None : - if DEBUG_MODE : print '*** srcConnector.parentItem().node.label = %s ' % srcConnector.getNode ().label - #self.emit( QtCore.SIGNAL( 'nodeConnectionChanged' ), srcConnector.parentItem(), srcConnector.param ) - if dstConnector is not None : - if DEBUG_MODE : print '*** dstConnector.parentItem().node.label = %s ' % dstConnector.getNode ().label - self.emit ( QtCore.SIGNAL ( 'nodeConnectionChanged' ), dstConnector.getGfxNode (), dstConnector.param ) - - # - # removeSelected - # - def removeSelected ( self ) : - # - if DEBUG_MODE : print '>> WorkArea.removeSelected: (before) nodes = %d links = %d' % ( len ( self.nodeNet.nodes.values () ), len ( self.nodeNet.links.values () ) ) - selected = self.scene().selectedItems() - - for item in selected: - if ( isinstance ( item, GfxLink ) or - isinstance ( item, GfxNode ) or - isinstance ( item, GfxNote ) or - isinstance ( item, GfxSwatchNode ) or - ( isinstance ( item, GfxNodeConnector ) and item.isNode () ) ) : item.remove () - - if DEBUG_MODE : print '>> WorkArea.removeSelected (after) nodes = %d links = %d' % ( len ( self.nodeNet.nodes.values ()), len ( self.nodeNet.links.values ()) ) - # - # dragEnterEvent - # - def dragEnterEvent ( self, event ) : - # - print '>> WorkArea.onDragEnterEvent' - #for form_str in event.mimeData().formats(): - # print str ( form_str ) - # if form_str == 'text/uri-list' : - # print event.mimeData().data( 'text/uri-list' ) - mimedata = event.mimeData () - - if mimedata.hasFormat ( 'application/x-text' ) or mimedata.hasFormat ( 'text/uri-list' ): - event.accept () - else: - event.ignore () - # - # dragMoveEvent - # - def dragMoveEvent ( self, event ) : - #print ">> WorkArea: onDragMoveEvent" - mimedata = event.mimeData () - if mimedata.hasFormat ( 'application/x-text' ) or mimedata.hasFormat ( 'text/uri-list' ): - event.setDropAction ( QtCore.Qt.CopyAction ) - event.accept () - else: - event.ignore () - # - # dropEvent - # - def dropEvent ( self, event ) : - # - if DEBUG_MODE : print ">> WorkArea.onDropEvent" - file_list = [] - mimedata = event.mimeData () - - if mimedata.hasFormat ( 'application/x-text' ) : - # decode drop stuff - data = mimedata.data ( 'application/x-text' ) - stream = QtCore.QDataStream ( data, QtCore.QIODevice.ReadOnly ) - filename = QtCore.QString () - stream >> filename - - if DEBUG_MODE : print 'itemFilename = %s' % ( filename ) - - file_list.append ( filename ) - event.setDropAction ( QtCore.Qt.CopyAction ) - event.accept () - elif mimedata.hasFormat ( 'text/uri-list' ) : - data = str ( mimedata.data( 'text/uri-list' ).data() ) - #print data - for item in data.split () : - filename = str ( QtCore.QUrl( item ).toLocalFile () ) - - ( name, ext ) = os.path.splitext( os.path.basename( filename ) ) - if DEBUG_MODE : print ':: %s (%s)' % ( filename, ext ) - if ext == '.xml' : - file_list.append ( filename ) - else: - event.ignore () - - for file_name in file_list : self.insertNodeNet ( file_name, self.mapToScene( event.pos () ) ) - # - # keyPressEvent - # - def keyPressEvent ( self, event ) : - #print ">> WorkArea.keyPressEvent" - QtGui.QGraphicsView.keyPressEvent ( self, event) - # - # wheelEvent - # - def wheelEvent ( self, event ) : - #print ">> WorkArea.wheelEvent" - # QtGui.QGraphicsView.wheelEvent( self, event) - scale = -1.0 - if 'linux' in sys.platform: scale = 1.0 - import math - scaleFactor = math.pow( 2.0, scale * event.delta() / 600.0 ) - factor = self.matrix().scale( scaleFactor, scaleFactor ).mapRect( QtCore.QRectF( -1, -1, 2, 2 ) ).width () - if factor < 0.07 or factor > 100: return - self.scale ( scaleFactor, scaleFactor ) - # - # mousePressEvent - # - def mousePressEvent ( self, event ) : - #print ">> WorkArea.mousePressEvent" - #self.setFocus () - self.startPos = self.mapToScene ( event.pos () ) - self.pressed = True - button = event.button () - modifiers = event.modifiers () - - if ( button == QtCore.Qt.MidButton or ( button == QtCore.Qt.LeftButton and modifiers == QtCore.Qt.ShiftModifier ) ) : - self.state = 'pan' - return - if button == QtCore.Qt.RightButton and modifiers == QtCore.Qt.ShiftModifier : - self.state = 'zoom' - return - QtGui.QGraphicsView.mousePressEvent ( self, event ) - # - # mouseDoubleClickEvent - # - def mouseDoubleClickEvent ( self, event ) : - # - #print ">> WorkArea.mouseDoubleClickEvent" - selected = self.scene ().selectedItems () - - QtGui.QGraphicsView.mouseDoubleClickEvent ( self, event ) - # - # mouseMoveEvent - # - def mouseMoveEvent ( self, event ) : - #print ">> WorkArea.mouseMoveEvent" - #if self.pressed : - currentPos = self.mapToScene( event.pos() ) - if self.state == 'pan' : - deltaPos = currentPos - self.startPos - self.setInteractive ( False ) - self.translate ( deltaPos.x (), deltaPos.y () ) - self.setInteractive ( True ) - - elif self.state == 'zoom' : - deltaPos = currentPos - self.startPos - - scale = -1.0 - if 'linux' in sys.platform: scale = 1.0 - import math - scaleFactor = math.pow ( 2.0, scale * max ( deltaPos.x (), deltaPos.y () ) / 200.0 ) # - factor = self.matrix().scale( scaleFactor, scaleFactor ).mapRect( QtCore.QRectF( -1, -1, 2, 2 ) ).width() - - if factor < 0.07 or factor > 100: return - # update view matrix - self.setInteractive ( False ) - self.scale ( scaleFactor, scaleFactor ) - self.translate ( -deltaPos.x () * scaleFactor, -deltaPos.y () * scaleFactor ) - self.setInteractive ( True ) - #self.startPos = currentPos - else : - QtGui.QGraphicsView.mouseMoveEvent ( self, event ) - # - # mouseReleaseEvent - # - def mouseReleaseEvent ( self, event ) : - #print ">> WorkArea.mouseReleaseEvent" - if self.state in [ 'pan', 'zoom' ] : - self.state = 'idle' - self.startPos = None - self.pressed = False - QtGui.QGraphicsView.mouseReleaseEvent ( self, event ) - # - # resetZoom - # - def resetZoom ( self ) : - # - if DEBUG_MODE : print ">> WorkArea.resetZoom" - self.setInteractive ( False ) - self.resetTransform() - self.centerOn ( 0.0, 0.0 ) - self.setInteractive ( True ) - # - # viewportEvent - # - def viewportEvent ( self, event ) : - #case QEvent::TouchBegin: - # case QEvent::TouchUpdate: - # case QEvent::TouchEnd: - if event.type() == QtCore.QEvent.TouchBegin : - if DEBUG_MODE : print ">> WorkArea.QEvent.TouchBegin" - return QtGui.QGraphicsView.viewportEvent ( self, event ) - # - # deselectAllNodes - # - def deselectAllNodes ( self ) : - selected = self.scene().selectedItems() - for item in selected : item.setSelected ( False ) - # - # openNodeNet - # - def openNodeNet ( self, filename, pos = None ) : - # - ( nodes, links ) = self.nodeNet.open ( normPath ( filename ) ) - for node in nodes : self.addGfxNode ( node ) - for link in links : self.addGfxLink ( link ) - # - # insertNodeNet - # - def insertNodeNet ( self, filename, pos = None ) : - # - if DEBUG_MODE : print ">> WorkArea.insertNodeNet (before) nodes = %d links = %d" % ( len(self.nodeNet.nodes.values()), len(self.nodeNet.links.values()) ) - - ( nodes, links ) = self.nodeNet.insert ( normPath ( filename ) ) - - if pos == None : - # on dblclk -- insert node at left border of sceneBound - sceneBound = self.scene().itemsBoundingRect () - if not sceneBound.isNull () : - x_offset = sceneBound.x() - self.minGap - pos = QtCore.QPointF ( x_offset, 0 ) - - self.deselectAllNodes () - - for node in nodes : self.addGfxNode ( node, pos ) - for link in links : self.addGfxLink ( link ) - - if DEBUG_MODE : print '>> WorkArea.insertNodeNet (after) nodes = %d links = %d' % ( len ( self.nodeNet.nodes.values ()), len ( self.nodeNet.links.values () ) ) - # - # copyNodes - # - def copyNodes ( self, clipboard, cutNodes = False ) : - # - if DEBUG_MODE : print '>> WorkArea.copyNodes ( cutNodes = %s )' % str ( cutNodes ) - - dupNodeNet = NodeNetwork ( 'clipboard' ) - - for gfxNode in self.selectedNodes : - dupNode = gfxNode.node.copy () - dupNodeNet.addNode ( dupNode ) - - for gfxNode in self.selectedNodes : - for link in gfxNode.node.getInputLinks () : - #link.printInfo () - dupLink = link.copy () - dupDstNode = dupNodeNet.getNodeByID ( gfxNode.node.id ) - - if dupDstNode is not None : - dupDstParam = dupDstNode.getInputParamByName ( link.dstParam.name ) - dupLink.setDst ( dupDstNode, dupDstParam ) - - ( srcNode, srcParam ) = dupLink.getSrc () - dupSrcNode = dupNodeNet.getNodeByID ( srcNode.id ) - - if dupSrcNode is not None : - # if srcNode is inside dupNodeNet - dupSrcParam = dupSrcNode.getOutputParamByName ( srcParam.name ) - dupLink.setSrc ( dupSrcNode, dupSrcParam ) - dupNodeNet.addLink ( dupLink ) - - - dom = QtXml.QDomDocument ( dupNodeNet.name ) - dupNodeNet.parseToXML ( dom ) - - clipboard.clear () - clipboard.setText ( dom.toString () ) # . fromUtf16 () .fromUtf8 () encode( 'utf-8' ) unicode ( dom.toByteArray () ) toString () - - if cutNodes : self.removeSelected () - # - # pasteNodes - # - def pasteNodes ( self, clipboard ) : - # - if DEBUG_MODE : print '>> WorkArea.pasteNodes ...' - nodes = [] - links = [] - - dom = QtXml.QDomDocument ( 'clipboard' ) - dom.setContent ( clipboard.text () ) - root = dom.documentElement () - if root.nodeName () == 'node' : - nodes.append ( self.nodeNet.addNodeFromXML ( root ) ) - self.nodeNet.correct_id ( nodes, links ) - elif root.nodeName () == 'nodenet' : - #print ':: parsing nodenet from XML ...' - nodeNet = NodeNetwork ( 'tmp', root ) - ( nodes, links ) = self.nodeNet.add ( nodeNet ) - else : - print '!! unknown XML document format' - return - - offsetPos = QtCore.QPointF ( self.minGap, self.minGap / 2 ) - self.deselectAllNodes () - - for node in nodes : self.addGfxNode ( node, offsetPos ) - for link in links : self.addGfxLink ( link ) - # - # duplicateNodes - # - def duplicateNodes ( self, preserveLinks = False ) : - # - if DEBUG_MODE : print '>> WorkArea.duplicateNode ( preserveLinks = %s )' % str ( preserveLinks ) - - dupNodeNet = NodeNetwork ( 'duplicate' ) - - for gfxNode in self.selectedNodes : - dupNode = gfxNode.node.copy () - dupNodeNet.addNode ( dupNode ) - - - for gfxNode in self.selectedNodes : - for link in gfxNode.node.getInputLinks () : - #link.printInfo () - dupLink = link.copy () - dupDstNode = dupNodeNet.getNodeByID ( gfxNode.node.id ) - - if dupDstNode is not None : - dupDstParam = dupDstNode.getInputParamByName ( link.dstParam.name ) - dupLink.setDst ( dupDstNode, dupDstParam ) - - ( srcNode, srcParam ) = dupLink.getSrc () - dupSrcNode = dupNodeNet.getNodeByID ( srcNode.id ) - - if dupSrcNode is not None : - # if srcNode is inside dupNodeNet - dupSrcParam = dupSrcNode.getOutputParamByName ( srcParam.name ) - dupLink.setSrc ( dupSrcNode, dupSrcParam ) - dupNodeNet.addLink ( dupLink ) - else : - # if this is outside links - if preserveLinks : - dupNodeNet.addLink ( dupLink ) - else : - dupLink.setSrc ( None, None ) - dupLink.setDst ( None, None ) - - #if DEBUG_MODE : dupNodeNet.printInfo () - ( nodes, links ) = self.nodeNet.add ( dupNodeNet ) - - offsetPos = QtCore.QPointF ( self.minGap, self.minGap / 2 ) - - self.deselectAllNodes () - - for node in nodes : self.addGfxNode ( node, offsetPos ) - for link in links : self.addGfxLink ( link ) - # - # newNodeNetFromList - # - def nodeNetFromSelected ( self, nodeNetName, preserveLinks = False ) : - # - if DEBUG_MODE : print '>> WorkArea.nodeNetFromSelected ( preserveLinks = %s )' % str ( preserveLinks ) - dupNodeNet = NodeNetwork ( nodeNetName ) - - for gfxNode in self.selectedNodes : - dupNode = gfxNode.node.copy () - dupNodeNet.addNode ( dupNode ) - - - for gfxNode in self.selectedNodes : - for link in gfxNode.node.getInputLinks () : - #link.printInfo () - dupLink = link.copy () - dupDstNode = dupNodeNet.getNodeByID ( gfxNode.node.id ) - - if dupDstNode is not None : - dupDstParam = dupDstNode.getInputParamByName ( link.dstParam.name ) - dupLink.setDst ( dupDstNode, dupDstParam ) - - ( srcNode, srcParam ) = dupLink.getSrc () - dupSrcNode = dupNodeNet.getNodeByID ( srcNode.id ) - - if dupSrcNode is not None : - # if srcNode is inside dupNodeNet - dupSrcParam = dupSrcNode.getOutputParamByName ( srcParam.name ) - dupLink.setSrc ( dupSrcNode, dupSrcParam ) - dupNodeNet.addLink ( dupLink ) - else : - # if this is outside links - if preserveLinks : - dupNodeNet.addLink ( dupLink ) - else : - dupLink.setSrc ( None, None ) - dupLink.setDst ( None, None ) - - return dupNodeNet \ No newline at end of file +class WorkArea ( QtModule.QGraphicsView ) : + # + # __init__ + # + def __init__ ( self ) : + # + QtModule.QGraphicsView.__init__ ( self ) + + self.drawGrid = True + self.gridSnap = False + self.straightLinks = False + self.reverseFlow = False + + self.gridSize = 10 + self.minGap = 120 + self.current_Z = 1 + + self.state = 'idle' + self.pressed = False + self.startPos = None + + self.lastConnectCandidate = None + self.currentGfxLink = None + + self.inspectedNode = None + self.nodeNet = None + + self.selectedNodes = [] + self.selectedLinks = [] + + # set scene + scene = QtModule.QGraphicsScene ( self ) + + scene.setSceneRect ( -10000, -10000, 20000, 20000 ) + #scene.setItemIndexMethod ( QtGui.QGraphicsScene.NoIndex ) + self.setScene ( scene ) + + # qt graphics stuff + self.setCacheMode ( QtModule.QGraphicsView.CacheBackground ) + self.setRenderHint ( QtGui.QPainter.Antialiasing ) + + self.setTransformationAnchor ( QtModule.QGraphicsView.AnchorUnderMouse ) # QtGui.QGraphicsView.AnchorUnderMouse + self.setResizeAnchor ( QtModule.QGraphicsView.AnchorUnderMouse ) # AnchorViewCenter + self.setDragMode ( QtModule.QGraphicsView.RubberBandDrag ) + + self.setMouseTracking ( False ) + self.setAcceptDrops ( True ) + """ + viewport = self.viewport() + if viewport is not None : + print ">> WorkArea viewport.setAcceptTouchEvents" + #proxy = QtGui.QGraphicsProxyWidget () + proxy = viewport.graphicsProxyWidget () + if proxy is not None : + proxy.setAcceptTouchEvents ( True ) + + #self.setAttribute ( QtGui.AcceptTouchEvents, True ) + #viewport()->setAttribute(Qt::WA_AcceptTouchEvents); + #setDragMode(ScrollHandDrag); + #Qt::WA_AcceptTouchEvents + """ + self.viewBrush = QtGui.QBrush ( QtGui.QColor ( 148, 148, 148 ) ) + self.setBackgroundBrush ( self.viewBrush ) + + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'selectionChanged()' ), self.onSelectionChanged ) + + QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'startNodeLink' ), self.onStartNodeLink ) + QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'traceNodeLink' ), self.onTraceNodeLink ) + QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'endNodeLink' ), self.onEndNodeLink ) + + QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'startNodeConnector' ), self.onStartNodeConnector ) + QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'traceNodeConnector' ), self.onTraceNodeConnector ) + QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'endNodeConnector' ), self.onEndNodeConnector ) + + QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'onGfxNodeRemoved' ), self.onRemoveNode ) + QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'onGfxLinkRemoved' ), self.onRemoveLink ) + + if DEBUG_MODE : print ">> WorkArea. __init__" + # + # drawBackground + # + def drawBackground ( self, painter, rect ) : + # + sc_rect = self.sceneRect () + bbrush = QtGui.QBrush( QtGui.QColor ( 148, 148, 148 ) ) ## painter.background() + painter.fillRect ( rect, bbrush ) + + if self.drawGrid : + # print( "grid size = %d" % self.gridSize ) + gr_pen = QtGui.QPen ( QtGui.QColor ( 180, 180, 180 ) ) + gr_pen.setWidth ( 0 ) + painter.setPen ( gr_pen ) + for x in range ( int ( sc_rect.x () ), int ( sc_rect.right () ), self.gridSize ): + painter.drawLine ( x, sc_rect.y (), x, sc_rect.bottom () ) + for y in range ( int ( sc_rect.y () ), int ( sc_rect.bottom () ), self.gridSize ): + painter.drawLine ( sc_rect.x (), y, sc_rect.right (), y ) + # + # Returns a list of GfxNodes in the scene for given type + # or all nodes if type == None + # + def getGfxNodesByType ( self, type = None ) : + # + resultList = [] + for item in self.scene ().items () : + if ( isinstance ( item, GfxNode ) or + isinstance ( item, GfxSwatchNode ) or + ( isinstance ( item, GfxNodeConnector ) and item.isNode () ) ) : + if type is None or item.node.type == type : + resultList.append ( item ) + return resultList + # + # Returns GfxNodes for given Node + # + def getGfxNodesByNode ( self, node = None ) : + # + gfxNode = None + for item in self.scene ().items () : + if ( isinstance ( item, GfxNode ) or + isinstance ( item, GfxSwatchNode ) or + ( isinstance ( item, GfxNodeConnector ) and item.isNode () ) ) : + if item.node == node : + gfxNode = item + break + return gfxNode + # + # selectAllNodes + # + def getAllGfxNodes ( self ) : return self.getGfxNodesByType ( None ) + # + # selectAllNodes + # + def selectAllNodes ( self ) : + # + for item in self.getAllGfxNodes () : item.setSelected ( True ) + # + # selectAbove + # + def selectAbove ( self, upperGfxNode ) : + # + if DEBUG_MODE : print '>> WorkArea::selectAbove node (%s) links:' % upperGfxNode.node.label + for link_list in upperGfxNode.node.outputLinks.values () : + for link in link_list : + # link.printInfo () + if self.nodeNet.hasThisLink ( link ) : + gfxNode = self.getGfxNodesByNode ( link.dstNode ) + gfxNode.setSelected ( True ) + self.selectAbove ( gfxNode ) + else : + if DEBUG_MODE : print '!! invalid link ...' + # + # updateBelow + # + def updateBelow ( self, upperGfxNode, removeLinks = False ) : + # + if DEBUG_MODE : print '>> WorkArea::updateBelow upperGfxNode.node (%s) children:' % upperGfxNode.node.label + for node in upperGfxNode.node.childs : + if DEBUG_MODE : print '* %s' % node.label + gfxNode = self.getGfxNodesByNode ( node ) + gfxNode.updateGfxNode ( removeLinks ) + self.updateBelow ( gfxNode, removeLinks ) + # + # selectBelow + # + def selectBelow ( self, upperGfxNode ) : + # + if DEBUG_MODE : print '>> WorkArea::selectBelow upperGfxNode.node (%s) children:' % upperGfxNode.node.label + for node in upperGfxNode.node.childs : + if DEBUG_MODE : print '* %s' % node.label + gfxNode = self.getGfxNodesByNode ( node ) + gfxNode.setSelected ( True ) + self.selectBelow ( gfxNode ) + # + # setNodeNetwork + # + def setNodeNetwork ( self, nodeNet ) : self.nodeNet = nodeNet + # + # clear + # + def clear ( self ): + # + if DEBUG_MODE : print '>> WorkArea:: clearing nodes ...' + for item in self.scene ().items () : self.scene ().removeItem ( item ) + self.nodeNet.clear () + self.state = 'idle' + self.panStartPos = None + self.lastConnectCandidate = None + self.currentGfxLink = None + self.inspectedNode = None + # + # addGfxLink + # + def addGfxLink ( self, link ) : + # + if DEBUG_MODE : print '>> WorkArea::addGfxLink (id=%d)' % link.id + gfxLink = GfxLink ( link ) + ( srcNode, srcParam ) = link.getSrc () + ( dstNode, dstParam ) = link.getDst () + srcConnector = None + dstConnector = None + for item in self.scene ().items (): + if isinstance ( item, GfxNode ) or isinstance ( item, GfxSwatchNode ) : + if item.node == srcNode : + srcConnector = item.getOutputConnectorByParam ( srcParam ) + elif item.node == dstNode : + dstConnector = item.getInputConnectorByParam ( dstParam ) + elif isinstance ( item, GfxNodeConnector ) and item.isNode () : + if item.node == srcNode : + srcConnector = item + elif item.node == dstNode : + dstConnector = item + if ( srcConnector != None and dstConnector != None ) : + break + gfxLink.setSrcConnector ( srcConnector ) + gfxLink.setDstConnector ( dstConnector ) + gfxLink.adjust () + self.scene ().addItem ( gfxLink ) + # + # Node already in NodeNet, so add new GfxNode to scene + # + def addGfxNode ( self, node, pos = None ) : + # + #print ( ">> WorkArea: addGfxNode %s" % node.label ) + if node.type == 'connector' : + gfxNode = GfxNodeConnector ( node.inputParams [ 0 ], node = node ) + elif node.type == 'note' : + gfxNode = GfxNote ( node ) + elif node.type == 'swatch' : + gfxNode = GfxSwatchNode ( node ) + else : + gfxNode = GfxNode ( node ) + scene = self.scene () + if pos != None : gfxNode.moveBy ( pos.x(), pos.y() ) + #for item in scene.selectedItems (): item.setSelected ( False ) + scene.addItem ( gfxNode ) + gfxNode.setSelected ( True ) + self.emit ( QtCore.SIGNAL ( 'gfxNodeAdded' ), gfxNode ) + # + # adjustLinks + # + def adjustLinks ( self ) : + # + for item in self.scene ().items () : + if isinstance ( item, GfxLink ): item.adjust () + # + # fitGfxNodesInView + # + def fitGfxNodesInView ( self, gfxNodeList ) : + # + nodeNetRect = QtCore.QRectF () + for gfxNode in gfxNodeList : + nodeRect = gfxNode.sceneBoundingRect () + if nodeNetRect.isNull () : + nodeNetRect = nodeRect + nodeNetRect = nodeNetRect.united ( nodeRect ) + if nodeNetRect.isValid () : + self.fitInView ( nodeNetRect, QtCore.Qt.KeepAspectRatio ) + # + # onSelectionChanged + # + def onSelectionChanged ( self ) : + # + #print ">> WorkArea: onSelectionChanged " + self.selectedNodes = [] + self.selectedLinks = [] + selected = self.scene ().selectedItems () + + for item in selected: + if isinstance ( item, GfxNode ) : self.selectedNodes.append ( item ) + elif isinstance ( item, GfxNote ) : self.selectedNodes.append ( item ) + elif isinstance ( item, GfxNodeConnector ) : self.selectedNodes.append ( item ) + elif isinstance ( item, GfxSwatchNode ) : self.selectedNodes.append ( item ) + elif isinstance ( item, GfxLink ) : self.selectedLinks.append ( item ) + + self.emit ( QtCore.SIGNAL ( 'selectNodes' ), self.selectedNodes, self.selectedLinks ) + # + # lastConnectCandidateReset + # + def lastConnectCandidateReset ( self ) : + # + if self.lastConnectCandidate is not None : + self.lastConnectCandidate.hilite( False ) + self.lastConnectCandidate = None + # + # isLinkAcceptable + # + def isLinkAcceptable ( self, connector, connectCandidate ) : + # + isAcceptable = False + if isinstance ( connectCandidate, GfxNodeConnector ): + # do not connect to itself + if connectCandidate != connector : + # do not connect to the same node + if connectCandidate.parentItem () != connector.parentItem () : + # do not connect the same link to connector twice + if not connectCandidate.hasThisLink ( self.currentGfxLink ) : + # connect only to similar type + if connector.param.encodedTypeStr() == connectCandidate.param.encodedTypeStr () : + if not connectCandidate.isNode () : + # connect only input with output and vice versa + if connector.param.isInput != connectCandidate.param.isInput : + isAcceptable = True + else : + # we have nodeConnector + isAcceptable = True + + return isAcceptable + # + # onStartNodeLink + # + def onStartNodeLink ( self, connector ): + # + srcNode = connector.getNode () + srcParam = connector.param + if DEBUG_MODE : print '>> WorkArea::onStartNodeLink from %s (%s)' % ( srcNode.label, srcParam.label ) + + srcConnector = connector + self.state = 'traceNodeLink' + self.lastConnectCandidate = None + + if connector.isInput () and connector.isLinked () : + oldLink = connector.getFirstGfxLink () + srcConnector = oldLink.srcConnector + oldLink.remove () + + gfxLink = GfxLink ( None, srcConnector ) + self.scene ().addItem ( gfxLink ) + self.currentGfxLink = gfxLink + self.currentGfxLink.isLinkSelected = True + # + # onTraceNodeLink + # + def onTraceNodeLink ( self, connector, scenePos ) : + # node = connector.parentItem().node + # print ">> WorkArea: onDrawNodeLink from %s (%d %d)" % ( node.label, scenePos.x(), scenePos.y() ) + connectCandidate = self.scene ().itemAt ( scenePos ) + srcConnector = self.currentGfxLink.srcConnector + swappedLink = False + if srcConnector is None : # link has swapped connectors + srcConnector = self.currentGfxLink.dstConnector + swappedLink = True + + if self.isLinkAcceptable ( srcConnector, connectCandidate ) : + if connectCandidate != self.lastConnectCandidate : + self.lastConnectCandidateReset () + connectCandidate.hilite ( True ) + self.lastConnectCandidate = connectCandidate + # link_node = connectCandidate.parentItem ().node + # print ">> WorkArea: onDrawNodeLink to %s" % link_node.label + else : + scenePos = self.lastConnectCandidate.getCenterPoint () # snap to last position + pass + # self.lastConnectCandidateReset () + else : + self.lastConnectCandidateReset () + + #if self.currentGfxLink is not None : + if swappedLink : + self.currentGfxLink.setSrcPoint ( scenePos ) + else : + self.currentGfxLink.setDstPoint ( scenePos ) + # + # onEndNodeLink + # + def onEndNodeLink ( self, connector, scenePos ) : + # + srcConnector = self.currentGfxLink.srcConnector + dstConnector = self.currentGfxLink.dstConnector + swappedLink = False + if srcConnector is None : # link has swapped connectors + swappedLink = True + + if self.lastConnectCandidate is None : + self.currentGfxLink.remove () + #self.emit( QtCore.SIGNAL( 'nodeParamChanged' ), srcConnector.parentItem(), srcConnector.param ) + #self.emit( QtCore.SIGNAL( 'nodeParamChanged' ), dstConnector.parentItem(), dstConnector.param ) + else : + if self.lastConnectCandidate.isNode () : + # if connection was made to ConnectorNode + if dstConnector is None : + self.lastConnectCandidate.removeInputGfxLinks () + else : + # remove old link first if it exists + if self.lastConnectCandidate.isInput () and self.lastConnectCandidate.isLinked () : + #oldLink = self.lastConnectCandidate.getFirstLink () + #oldLink.remove () + self.lastConnectCandidate.removeInputGfxLinks () + + self.currentGfxLink.isLinkSelected = False + self.currentGfxLink.update () + + srcNode = dstNode = None + srcParam = dstParam = None + + if swappedLink : + srcNode = self.lastConnectCandidate.getNode () + srcParam = self.lastConnectCandidate.param + if self.lastConnectCandidate.isNode () : + srcParam = self.lastConnectCandidate.getFirstOutputParam () + dstNode = dstConnector.getNode () + dstParam = dstConnector.param + self.currentGfxLink.setSrcConnector ( self.lastConnectCandidate ) + else : + srcNode = srcConnector.getNode () + srcParam = srcConnector.param + dstNode = self.lastConnectCandidate.getNode () + dstParam = self.lastConnectCandidate.param + if self.lastConnectCandidate.isNode () : + dstParam = self.lastConnectCandidate.getFirstInputParam () + self.currentGfxLink.setDstConnector ( self.lastConnectCandidate ) + + link = NodeLink.build ( srcNode, dstNode, srcParam, dstParam ) + + #if not dstParam.isInput : + # swap source and destination + # self.currentGfxLink.swapConnectors () + # link.swapNodes () + + self.currentGfxLink.link = link + self.nodeNet.addLink ( link ) + #self.emit ( QtCore.SIGNAL ( 'nodeConnectionChanged' ), self.currentGfxLink.srcConnector.getGfxNode (), self.currentGfxLink.srcConnector.param ) + self.emit ( QtCore.SIGNAL ( 'nodeConnectionChanged' ), self.currentGfxLink.dstConnector.getGfxNode (), self.currentGfxLink.dstConnector.param ) + + self.lastConnectCandidateReset () + self.currentGfxLink = None + self.state = 'idle' + # + # onStartNodeConnector + # + def onStartNodeConnector ( self, connector, scenePos ) : + # + if DEBUG_MODE : print '>> WorkArea::onStartNodeConnector' + self.state = 'traceNodeConnector' + + newNode = ConnectorNode () + self.nodeNet.addNode ( newNode ) + + newParam = connector.param.copy () + newParam.isInput = False + newInParam = newParam.copy () + newOutParam = newParam.copy () + + newNode.addInputParam ( newInParam ) + newNode.addOutputParam ( newOutParam ) + + newConnector = GfxNodeConnector ( newParam, connector.radius, node = newNode ) + newConnector.brush = connector.brush + newConnector.setPos ( scenePos ) + newConnector.moveBy ( -connector.radius, -connector.radius ) + + self.lastConnectCandidate = newConnector + self.scene ().addItem ( newConnector ) + newConnector.hilite ( True ) + + srcNode = connector.getNode () + srcParam = connector.getOutputParam () + dstNode = newConnector.getNode () + dstParam = newConnector.getInputParam () + + # + # swap link direction only for connectors + # in open chain connected to input node parameter + # + swappedLink = False + if connector.isConnectedToInput () and not connector.isConnectedToOutput () : + if DEBUG_MODE : print '*** swap link direction ***' + swappedLink = True + srcNode = newConnector.getNode () + srcParam = newConnector.getOutputParam () + dstNode = connector.getNode () + dstParam = connector.getInputParam () + + link = NodeLink.build ( srcNode, dstNode, srcParam, dstParam ) + # if swappedLink : link.swapNodes () + self.nodeNet.addLink ( link ) + + #if DEBUG_MODE : self.nodeNet.printInfo () + + # preserve existing links for parameter connectors + if connector.isLinked () and not connector.isNode () : + if connector.isInput () : + #print '*** preserve input ***' + # TODO!!! + # This is very rough code -- needs to be wrapped in functions + gfxLinks = connector.getInputGfxLinks () + + for gfxLink in gfxLinks : + gfxLink.setDstConnector ( newConnector ) + + # remove gfxLink from previouse connector + connector.removeGfxLink ( gfxLink ) + + # adjust destination for node link + newConnector.getNode ().attachInputParamToLink ( newConnector.getInputParam (), gfxLink.link ) + newConnector.getNode ().addChild ( gfxLink.link.srcNode ) + connector.getNode ().removeChild ( gfxLink.link.srcNode ) + + gfxLink.link.dstNode = newConnector.getNode () + gfxLink.link.dstParam = newConnector.getInputParam () + else : + #print '*** preserve output ***' + gfxLinks = connector.getOutputGfxLinks () + + for gfxLink in gfxLinks : + gfxLink.setSrcConnector ( newConnector ) + + # remove gfxLink from previouse connector + connector.removeGfxLink ( gfxLink ) + + # adjust source for node link + connector.getNode ().detachOutputParamFromLink ( gfxLink.link.srcParam, gfxLink.link ) + newConnector.getNode ().attachOutputParamToLink ( newConnector.getOutputParam (), gfxLink.link ) + #newConnector.getNode ().childs.add ( connector.getNode () ) + gfxLink.link.dstNode.addChild ( newConnector.getNode () ) + gfxLink.link.dstNode.removeChild ( connector.getNode () ) + + gfxLink.link.srcNode = newConnector.getNode () + gfxLink.link.srcParam = newConnector.getOutputParam () + + #if DEBUG_MODE : self.nodeNet.printInfo () + + gfxLink = GfxLink ( link, connector, newConnector ) + self.scene ().addItem ( gfxLink ) + # + # onTraceNodeConnector + # + def onTraceNodeConnector ( self, connector, scenePos ) : + # + #if DEBUG_MODE : print '>> WorkArea::onTraceNodeConnector' + if self.lastConnectCandidate is not None : + self.lastConnectCandidate.setPos ( scenePos ) + self.lastConnectCandidate.moveBy ( -connector.radius, -connector.radius ) + # + # onEndNodeConnector + # + def onEndNodeConnector ( self, connector, scenePos ) : + # + if DEBUG_MODE : print '>> WorkArea::onEndNodeConnector' + print '>> lastConnectCandidate.node.type = %s' % self.lastConnectCandidate.node.type + self.lastConnectCandidateReset () + self.state = 'idle' + # + # onRemoveNode + # + def onRemoveNode ( self, gfxNode ) : + # + print ">> WorkArea.onRemoveNode %s (id = %d)" % ( gfxNode.node.label, gfxNode.node.id ) + self.emit ( QtCore.SIGNAL ( 'gfxNodeRemoved' ), gfxNode ) + self.scene ().removeItem ( gfxNode ) + self.nodeNet.removeNode ( gfxNode.node ) + + #if DEBUG_MODE : self.nodeNet.printInfo () + # + # onRemoveLink + # + def onRemoveLink ( self, gfxLink ) : + # + print ">> WorkArea.onRemoveLink ..." + self.scene ().removeItem ( gfxLink ) + + if gfxLink.link is not None : + print "*** (id = %d)" % ( gfxLink.link.id ) + srcConnector = gfxLink.srcConnector + dstConnector = gfxLink.dstConnector + self.nodeNet.removeLink ( gfxLink.link ) + if srcConnector is not None : + if DEBUG_MODE : print '*** srcConnector.parentItem().node.label = %s ' % srcConnector.getNode ().label + #self.emit( QtCore.SIGNAL( 'nodeConnectionChanged' ), srcConnector.parentItem(), srcConnector.param ) + if dstConnector is not None : + if DEBUG_MODE : print '*** dstConnector.parentItem().node.label = %s ' % dstConnector.getNode ().label + self.emit ( QtCore.SIGNAL ( 'nodeConnectionChanged' ), dstConnector.getGfxNode (), dstConnector.param ) + + # + # removeSelected + # + def removeSelected ( self ) : + # + if DEBUG_MODE : print '>> WorkArea.removeSelected: (before) nodes = %d links = %d' % ( len ( self.nodeNet.nodes.values () ), len ( self.nodeNet.links.values () ) ) + selected = self.scene().selectedItems() + + for item in selected: + if ( isinstance ( item, GfxLink ) or + isinstance ( item, GfxNode ) or + isinstance ( item, GfxNote ) or + isinstance ( item, GfxSwatchNode ) or + ( isinstance ( item, GfxNodeConnector ) and item.isNode () ) ) : item.remove () + + if DEBUG_MODE : print '>> WorkArea.removeSelected (after) nodes = %d links = %d' % ( len ( self.nodeNet.nodes.values ()), len ( self.nodeNet.links.values ()) ) + # + # dragEnterEvent + # + def dragEnterEvent ( self, event ) : + # + print '>> WorkArea.onDragEnterEvent' + #for form_str in event.mimeData().formats(): + # print str ( form_str ) + # if form_str == 'text/uri-list' : + # print event.mimeData().data( 'text/uri-list' ) + mimedata = event.mimeData () + + if mimedata.hasFormat ( 'application/x-text' ) or mimedata.hasFormat ( 'text/uri-list' ): + event.accept () + else: + event.ignore () + # + # dragMoveEvent + # + def dragMoveEvent ( self, event ) : + #print ">> WorkArea: onDragMoveEvent" + mimedata = event.mimeData () + if mimedata.hasFormat ( 'application/x-text' ) or mimedata.hasFormat ( 'text/uri-list' ): + event.setDropAction ( QtCore.Qt.CopyAction ) + event.accept () + else: + event.ignore () + # + # dropEvent + # + def dropEvent ( self, event ) : + # + import os + if DEBUG_MODE : print ">> WorkArea.onDropEvent" + file_list = [] + mimedata = event.mimeData () + + if mimedata.hasFormat ( 'application/x-text' ) : + # decode drop stuff + data = mimedata.data ( 'application/x-text' ) + stream = QtCore.QDataStream ( data, QtCore.QIODevice.ReadOnly ) + filename = QtCore.QString () + stream >> filename + + if DEBUG_MODE : print 'itemFilename = %s' % ( filename ) + + file_list.append ( filename ) + event.setDropAction ( QtCore.Qt.CopyAction ) + event.accept () + elif mimedata.hasFormat ( 'text/uri-list' ) : + data = str ( mimedata.data( 'text/uri-list' ).data() ) + #print data + for item in data.split () : + filename = str ( QtCore.QUrl( item ).toLocalFile () ) + + ( name, ext ) = os.path.splitext( os.path.basename( filename ) ) + if DEBUG_MODE : print ':: %s (%s)' % ( filename, ext ) + if ext == '.xml' : + file_list.append ( filename ) + else: + event.ignore () + + for file_name in file_list : self.insertNodeNet ( file_name, self.mapToScene( event.pos () ) ) + # + # keyPressEvent + # + def keyPressEvent ( self, event ) : + #print ">> WorkArea.keyPressEvent" + QtModule.QGraphicsView.keyPressEvent ( self, event) + # + # wheelEvent + # + def wheelEvent ( self, event ) : + #print ">> WorkArea.wheelEvent" + # QtGui.QGraphicsView.wheelEvent( self, event) + import sys + scale = -1.0 + if 'linux' in sys.platform: scale = 1.0 + import math + scaleFactor = math.pow( 2.0, scale * event.delta() / 600.0 ) + factor = self.matrix().scale( scaleFactor, scaleFactor ).mapRect( QtCore.QRectF( -1, -1, 2, 2 ) ).width () + if factor < 0.07 or factor > 100: return + self.scale ( scaleFactor, scaleFactor ) + # + # mousePressEvent + # + def mousePressEvent ( self, event ) : + #print ">> WorkArea.mousePressEvent" + #self.setFocus () + self.startPos = self.mapToScene ( event.pos () ) + self.pressed = True + button = event.button () + modifiers = event.modifiers () + + if ( button == QtCore.Qt.MidButton or ( button == QtCore.Qt.LeftButton and modifiers == QtCore.Qt.ShiftModifier ) ) : + self.state = 'pan' + return + if button == QtCore.Qt.RightButton and modifiers == QtCore.Qt.ShiftModifier : + self.state = 'zoom' + return + QtModule.QGraphicsView.mousePressEvent ( self, event ) + # + # mouseDoubleClickEvent + # + def mouseDoubleClickEvent ( self, event ) : + # + #print ">> WorkArea.mouseDoubleClickEvent" + selected = self.scene ().selectedItems () + + QtModule.QGraphicsView.mouseDoubleClickEvent ( self, event ) + # + # mouseMoveEvent + # + def mouseMoveEvent ( self, event ) : + #print ">> WorkArea.mouseMoveEvent" + #if self.pressed : + currentPos = self.mapToScene( event.pos() ) + if self.state == 'pan' : + deltaPos = currentPos - self.startPos + self.setInteractive ( False ) + self.translate ( deltaPos.x (), deltaPos.y () ) + self.setInteractive ( True ) + + elif self.state == 'zoom' : + # + import sys + deltaPos = currentPos - self.startPos + scale = -1.0 + if 'linux' in sys.platform: scale = 1.0 + import math + scaleFactor = math.pow ( 2.0, scale * max ( deltaPos.x (), deltaPos.y () ) / 200.0 ) # + factor = self.matrix().scale( scaleFactor, scaleFactor ).mapRect( QtCore.QRectF( -1, -1, 2, 2 ) ).width() + + if factor < 0.07 or factor > 100: return + # update view matrix + self.setInteractive ( False ) + self.scale ( scaleFactor, scaleFactor ) + self.translate ( -deltaPos.x () * scaleFactor, -deltaPos.y () * scaleFactor ) + self.setInteractive ( True ) + #self.startPos = currentPos + else : + QtModule.QGraphicsView.mouseMoveEvent ( self, event ) + # + # mouseReleaseEvent + # + def mouseReleaseEvent ( self, event ) : + #print ">> WorkArea.mouseReleaseEvent" + if self.state in [ 'pan', 'zoom' ] : + self.state = 'idle' + self.startPos = None + self.pressed = False + QtModule.QGraphicsView.mouseReleaseEvent ( self, event ) + # + # resetZoom + # + def resetZoom ( self ) : + # + if DEBUG_MODE : print ">> WorkArea.resetZoom" + self.setInteractive ( False ) + self.resetTransform() + self.centerOn ( 0.0, 0.0 ) + self.setInteractive ( True ) + # + # viewportEvent + # + def viewportEvent ( self, event ) : + #case QEvent::TouchBegin: + # case QEvent::TouchUpdate: + # case QEvent::TouchEnd: + if event.type() == QtCore.QEvent.TouchBegin : + if DEBUG_MODE : print ">> WorkArea.QEvent.TouchBegin" + return QtModule.QGraphicsView.viewportEvent ( self, event ) + # + # deselectAllNodes + # + def deselectAllNodes ( self ) : + selected = self.scene().selectedItems() + for item in selected : item.setSelected ( False ) + # + # openNodeNet + # + def openNodeNet ( self, filename, pos = None ) : + # + ( nodes, links ) = self.nodeNet.open ( normPath ( filename ) ) + for node in nodes : self.addGfxNode ( node ) + for link in links : self.addGfxLink ( link ) + # + # insertNodeNet + # + def insertNodeNet ( self, filename, pos = None ) : + # + if DEBUG_MODE : print ">> WorkArea.insertNodeNet (before) nodes = %d links = %d" % ( len(self.nodeNet.nodes.values()), len(self.nodeNet.links.values()) ) + + ( nodes, links ) = self.nodeNet.insert ( normPath ( filename ) ) + + if pos == None : + # on dblclk -- insert node at left border of sceneBound + sceneBound = self.scene().itemsBoundingRect () + if not sceneBound.isNull () : + x_offset = sceneBound.x() - self.minGap + pos = QtCore.QPointF ( x_offset, 0 ) + + self.deselectAllNodes () + + for node in nodes : self.addGfxNode ( node, pos ) + for link in links : self.addGfxLink ( link ) + + if DEBUG_MODE : print '>> WorkArea.insertNodeNet (after) nodes = %d links = %d' % ( len ( self.nodeNet.nodes.values ()), len ( self.nodeNet.links.values () ) ) + # + # copyNodes + # + def copyNodes ( self, clipboard, cutNodes = False ) : + # + if DEBUG_MODE : print '>> WorkArea.copyNodes ( cutNodes = %s )' % str ( cutNodes ) + + dupNodeNet = NodeNetwork ( 'clipboard' ) + + for gfxNode in self.selectedNodes : + dupNode = gfxNode.node.copy () + dupNodeNet.addNode ( dupNode ) + + for gfxNode in self.selectedNodes : + for link in gfxNode.node.getInputLinks () : + #link.printInfo () + dupLink = link.copy () + dupDstNode = dupNodeNet.getNodeByID ( gfxNode.node.id ) + + if dupDstNode is not None : + dupDstParam = dupDstNode.getInputParamByName ( link.dstParam.name ) + dupLink.setDst ( dupDstNode, dupDstParam ) + + ( srcNode, srcParam ) = dupLink.getSrc () + dupSrcNode = dupNodeNet.getNodeByID ( srcNode.id ) + + if dupSrcNode is not None : + # if srcNode is inside dupNodeNet + dupSrcParam = dupSrcNode.getOutputParamByName ( srcParam.name ) + dupLink.setSrc ( dupSrcNode, dupSrcParam ) + dupNodeNet.addLink ( dupLink ) + + + dom = QtXml.QDomDocument ( dupNodeNet.name ) + dupNodeNet.parseToXML ( dom ) + + clipboard.clear () + clipboard.setText ( dom.toString () ) # . fromUtf16 () .fromUtf8 () encode( 'utf-8' ) unicode ( dom.toByteArray () ) toString () + + if cutNodes : self.removeSelected () + # + # pasteNodes + # + def pasteNodes ( self, clipboard ) : + # + if DEBUG_MODE : print '>> WorkArea.pasteNodes ...' + nodes = [] + links = [] + + dom = QtXml.QDomDocument ( 'clipboard' ) + dom.setContent ( clipboard.text () ) + root = dom.documentElement () + if root.nodeName () == 'node' : + nodes.append ( self.nodeNet.addNodeFromXML ( root ) ) + self.nodeNet.correct_id ( nodes, links ) + elif root.nodeName () == 'nodenet' : + #print ':: parsing nodenet from XML ...' + nodeNet = NodeNetwork ( 'tmp', root ) + ( nodes, links ) = self.nodeNet.add ( nodeNet ) + else : + print '!! unknown XML document format' + return + + offsetPos = QtCore.QPointF ( self.minGap, self.minGap / 2 ) + self.deselectAllNodes () + + for node in nodes : self.addGfxNode ( node, offsetPos ) + for link in links : self.addGfxLink ( link ) + # + # duplicateNodes + # + def duplicateNodes ( self, preserveLinks = False ) : + # + if DEBUG_MODE : print '>> WorkArea.duplicateNode ( preserveLinks = %s )' % str ( preserveLinks ) + + dupNodeNet = NodeNetwork ( 'duplicate' ) + + for gfxNode in self.selectedNodes : + dupNode = gfxNode.node.copy () + dupNodeNet.addNode ( dupNode ) + + + for gfxNode in self.selectedNodes : + for link in gfxNode.node.getInputLinks () : + #link.printInfo () + dupLink = link.copy () + dupDstNode = dupNodeNet.getNodeByID ( gfxNode.node.id ) + + if dupDstNode is not None : + dupDstParam = dupDstNode.getInputParamByName ( link.dstParam.name ) + dupLink.setDst ( dupDstNode, dupDstParam ) + + ( srcNode, srcParam ) = dupLink.getSrc () + dupSrcNode = dupNodeNet.getNodeByID ( srcNode.id ) + + if dupSrcNode is not None : + # if srcNode is inside dupNodeNet + dupSrcParam = dupSrcNode.getOutputParamByName ( srcParam.name ) + dupLink.setSrc ( dupSrcNode, dupSrcParam ) + dupNodeNet.addLink ( dupLink ) + else : + # if this is outside links + if preserveLinks : + dupNodeNet.addLink ( dupLink ) + else : + dupLink.setSrc ( None, None ) + dupLink.setDst ( None, None ) + + #if DEBUG_MODE : dupNodeNet.printInfo () + ( nodes, links ) = self.nodeNet.add ( dupNodeNet ) + + offsetPos = QtCore.QPointF ( self.minGap, self.minGap / 2 ) + + self.deselectAllNodes () + + for node in nodes : self.addGfxNode ( node, offsetPos ) + for link in links : self.addGfxLink ( link ) + # + # newNodeNetFromList + # + def nodeNetFromSelected ( self, nodeNetName, preserveLinks = False ) : + # + if DEBUG_MODE : print '>> WorkArea.nodeNetFromSelected ( preserveLinks = %s )' % str ( preserveLinks ) + dupNodeNet = NodeNetwork ( nodeNetName ) + + for gfxNode in self.selectedNodes : + dupNode = gfxNode.node.copy () + dupNodeNet.addNode ( dupNode ) + + + for gfxNode in self.selectedNodes : + for link in gfxNode.node.getInputLinks () : + #link.printInfo () + dupLink = link.copy () + dupDstNode = dupNodeNet.getNodeByID ( gfxNode.node.id ) + + if dupDstNode is not None : + dupDstParam = dupDstNode.getInputParamByName ( link.dstParam.name ) + dupLink.setDst ( dupDstNode, dupDstParam ) + + ( srcNode, srcParam ) = dupLink.getSrc () + dupSrcNode = dupNodeNet.getNodeByID ( srcNode.id ) + + if dupSrcNode is not None : + # if srcNode is inside dupNodeNet + dupSrcParam = dupSrcNode.getOutputParamByName ( srcParam.name ) + dupLink.setSrc ( dupSrcNode, dupSrcParam ) + dupNodeNet.addLink ( dupLink ) + else : + # if this is outside links + if preserveLinks : + dupNodeNet.addLink ( dupLink ) + else : + dupLink.setSrc ( None, None ) + dupLink.setDst ( None, None ) + + return dupNodeNet \ No newline at end of file diff --git a/gfx/gfxLink.py b/gfx/gfxLink.py index 018e0c2..c753b44 100644 --- a/gfx/gfxLink.py +++ b/gfx/gfxLink.py @@ -1,244 +1,248 @@ -#=============================================================================== -# gfxLink.py -# -# -# -#=============================================================================== -import os, sys -from PyQt4 import QtCore, QtGui +""" + + gfxLink.py + +""" +from core.mePyQt import QtCore, QtGui from global_vars import DEBUG_MODE, GFX_LINK_TYPE from meShaderEd import app_settings + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets # # GfxLink # -class GfxLink ( QtGui.QGraphicsItem ) : - # - Type = GFX_LINK_TYPE - isStraight = True - # - # createFromPoints - # - @staticmethod - def createFromPoints ( srcP, dstP ) : - gfxLink = GfxLink () - gfxLink.srcPoint = gfxLink.mapToItem ( gfxLink, srcP ) - gfxLink.dstPoint = gfxLink.mapToItem ( gfxLink, dstP ) - gfxLink.adjust () - - return gfxLink - # - # createFromLink - # - @staticmethod - def createFromLink ( link ): - gfxLink = GfxLink () - gfxLink.link = link - gfxLink.path = QtGui.QPainterPath () - gfxLink.adjust () - - return gfxLink - # - # __init__ - # - def __init__ ( self, link = None, srcConnector = None, dstConnector = None ) : - # - QtGui.QGraphicsItem.__init__ ( self ) - - from meShaderEd import getDefaultValue - self.isStraight = getDefaultValue ( app_settings, 'WorkArea', 'straight_links' ) - - # qt graphics stuff - self.brushSelected = QtGui.QBrush ( QtGui.QColor ( 250, 250, 250 ) ) - self.brushNormal = QtGui.QBrush ( QtGui.QColor ( 20, 20, 20 ) ) - self.setFlag ( QtGui.QGraphicsItem.ItemIsSelectable ) - self.setZValue( 0 ) - - self.link = link - - self.rect = QtCore.QRectF () - self.points = [] - self.path = None - self.isLinkSelected = False - self.srcPoint = self.dstPoint = None - self.srcConnector = self.dstConnector = None - - self.setSrcConnector ( srcConnector ) - self.setDstConnector ( dstConnector) - - if srcConnector != None : - if srcConnector.isConnectedToInput () and not srcConnector.isConnectedToOutput (): - self.swapConnectors () - # - # remove - # - def remove ( self ) : - if DEBUG_MODE : print ">> GfxLink::remove" - - if self.srcConnector is not None : - self.srcConnector.removeGfxLink ( self ) - #self.srcConnector = None - if self.dstConnector is not None : - self.dstConnector.removeGfxLink ( self ) - #self.dstConnector = None - #if self.link is not None : - scene = self.scene () - if scene != None : - if DEBUG_MODE : print ">> GfxLink::remove emit( onGfxLinkRemoved )" - scene.emit ( QtCore.SIGNAL ( 'onGfxLinkRemoved' ), self ) - # - # type - # - def type ( self ) : return GfxLink.Type - # - # boundingRect - # - def boundingRect ( self ) : return self.rect - # - # shape - # - def shape ( self ) : return self.path - # - # swapConnectors - # - def swapConnectors ( self ): - # swap source and destination - src = self.srcConnector - self.srcConnector = self.dstConnector - self.dstConnector = src - # - # isDstConnectedTo - # - def isDstConnectedTo ( self, connector ) : - connected = False - if connector == self.dstConnector : - connected = True - return connected - # - # isEqual - # - def isEqual ( self, link ) : - equal = False - if self.srcConnector == link.srcConnector and self.dstConnector == link.dstConnector : - equal = True - elif self.srcConnector == link.dstConnector and self.dstConnector == link.srcConnector : - equal = True - return equal - # - # setSrcConnector - # - def setSrcConnector ( self, srcConnector ) : - if srcConnector is not None : - self.srcPoint = srcConnector.getCenterPoint () - self.srcConnector = srcConnector - self.srcConnector.addGfxLink ( self ) - # - # setDstConnector - # - def setDstConnector ( self, dstConnector ) : - if dstConnector is not None : - self.dstPoint = dstConnector.getCenterPoint () - self.dstConnector = dstConnector - self.dstConnector.addGfxLink ( self ) - # - # itemChange - # - def itemChange ( self, change, value ) : - if change == QtGui.QGraphicsItem.ItemSelectedChange : - self.isLinkSelected = value.toBool () - return QtGui.QGraphicsItem.itemChange ( self, change, value ) - # - # setPoints - # - def setPoints ( self, srcP, dstP ) : - self.srcPoint = self.mapToItem ( self, srcP ) - self.dstPoint = self.mapToItem ( self, dstP ) - self.adjust () - # - # setSrcPoint - # - def setSrcPoint ( self, p ) : - self.srcPoint = self.mapToItem ( self, p ) - self.adjust () - # - # setDstPoint - # - def setDstPoint ( self, p ) : - self.dstPoint = self.mapToItem ( self, p ) - self.adjust () - # - # adjust - # - def adjust ( self ) : - from meShaderEd import getDefaultValue - self.isStraight = getDefaultValue ( app_settings, 'WorkArea', 'straight_links' ) - - if self.srcConnector is not None : self.srcPoint = self.srcConnector.getCenterPoint () - if self.dstConnector is not None : self.dstPoint = self.dstConnector.getCenterPoint () - - self.prepareGeometryChange () - - del self.points [ : ] # clear bezier points - self.path = None - if self.srcPoint is not None and self.dstPoint is not None : - self.path = QtGui.QPainterPath () - # first point - self.points.append ( self.srcPoint ) - self.path.moveTo ( self.points [ 0 ] ) - - # draw curved spline if isStraight is False - if not self.isStraight : - # hull spline - hull = QtCore.QRectF ( self.srcPoint, self.dstPoint ) - centerX = hull.center ().x () - centerY = hull.center ().y () - # second point - offsetVX = min ( abs ( hull.topRight ().x () - hull.topLeft ().x () ) * 0.1, 40 ) - offsetVY = 0.0 - - p1 = self.srcPoint + QtCore.QPointF ( offsetVX, offsetVY ) - self.points.append ( p1 ) - # third point - p2 = QtCore.QPointF ( centerX, self.srcPoint.y() ) - self.points.append ( p2 ) - # fourth point - p3 = QtCore.QPointF ( centerX, centerY ) - self.points.append ( p3 ) - # fifth point (bezier tangent) - p4 = QtCore.QPointF ( centerX, centerY ) - self.points.append ( p4 ) - # sixth point - p5 = QtCore.QPointF ( centerX, self.dstPoint.y() ) - self.points.append ( p5 ) - # seventh point - p6 = self.dstPoint - QtCore.QPointF ( offsetVX, offsetVY ) - self.points.append ( p6 ) - # last point - self.points.append ( self.dstPoint ) - if self.isStraight : - #if DEBUG_MODE : print '* GfxLink: Straight mode' - self.path.lineTo ( self.dstPoint ) - else: - #if DEBUG_MODE : print '* GfxLink: Curved mode' - #self.path.cubicTo ( self.points[1], self.points[2], self.points[3] ) - #self.path.cubicTo ( self.points[5], self.points[6], self.points[7] ) - self.path.cubicTo ( p1, p1, p3 ) - self.path.cubicTo ( p6, p6, self.dstPoint ) - self.rect = self.path.boundingRect () - # - # paint - # - def paint ( self, painter, option, widget ) : - # - if self.path is not None : - painter.setRenderHint ( QtGui.QPainter.Antialiasing ) - brush = self.brushNormal - if self.isLinkSelected : brush = self.brushSelected - painter.setPen( QtGui.QPen ( brush, - 1.25, - QtCore.Qt.SolidLine, - QtCore.Qt.RoundCap, - QtCore.Qt.RoundJoin - ) - ) - painter.drawPath ( self.path ) +class GfxLink ( QtModule.QGraphicsItem ) : + # + Type = GFX_LINK_TYPE + isStraight = True + # + # createFromPoints + # + @staticmethod + def createFromPoints ( srcP, dstP ) : + gfxLink = GfxLink () + gfxLink.srcPoint = gfxLink.mapToItem ( gfxLink, srcP ) + gfxLink.dstPoint = gfxLink.mapToItem ( gfxLink, dstP ) + gfxLink.adjust () + + return gfxLink + # + # createFromLink + # + @staticmethod + def createFromLink ( link ): + gfxLink = GfxLink () + gfxLink.link = link + gfxLink.path = QtGui.QPainterPath () + gfxLink.adjust () + + return gfxLink + # + # __init__ + # + def __init__ ( self, link = None, srcConnector = None, dstConnector = None ) : + # + QtModule.QGraphicsItem.__init__ ( self ) + + from meShaderEd import getDefaultValue + self.isStraight = getDefaultValue ( app_settings, 'WorkArea', 'straight_links' ) + + # qt graphics stuff + self.brushSelected = QtGui.QBrush ( QtGui.QColor ( 250, 250, 250 ) ) + self.brushNormal = QtGui.QBrush ( QtGui.QColor ( 20, 20, 20 ) ) + self.setFlag ( QtGui.QGraphicsItem.ItemIsSelectable ) + self.setZValue( 0 ) + + self.link = link + + self.rect = QtCore.QRectF () + self.points = [] + self.path = None + self.isLinkSelected = False + self.srcPoint = self.dstPoint = None + self.srcConnector = self.dstConnector = None + + self.setSrcConnector ( srcConnector ) + self.setDstConnector ( dstConnector) + + if srcConnector != None : + if srcConnector.isConnectedToInput () and not srcConnector.isConnectedToOutput (): + self.swapConnectors () + # + # remove + # + def remove ( self ) : + if DEBUG_MODE : print ">> GfxLink::remove" + + if self.srcConnector is not None : + self.srcConnector.removeGfxLink ( self ) + #self.srcConnector = None + if self.dstConnector is not None : + self.dstConnector.removeGfxLink ( self ) + #self.dstConnector = None + #if self.link is not None : + scene = self.scene () + if scene != None : + if DEBUG_MODE : print ">> GfxLink::remove emit( onGfxLinkRemoved )" + scene.emit ( QtCore.SIGNAL ( 'onGfxLinkRemoved' ), self ) + # + # type + # + def type ( self ) : return GfxLink.Type + # + # boundingRect + # + def boundingRect ( self ) : return self.rect + # + # shape + # + def shape ( self ) : return self.path + # + # swapConnectors + # + def swapConnectors ( self ): + # swap source and destination + src = self.srcConnector + self.srcConnector = self.dstConnector + self.dstConnector = src + # + # isDstConnectedTo + # + def isDstConnectedTo ( self, connector ) : + connected = False + if connector == self.dstConnector : + connected = True + return connected + # + # isEqual + # + def isEqual ( self, link ) : + equal = False + if self.srcConnector == link.srcConnector and self.dstConnector == link.dstConnector : + equal = True + elif self.srcConnector == link.dstConnector and self.dstConnector == link.srcConnector : + equal = True + return equal + # + # setSrcConnector + # + def setSrcConnector ( self, srcConnector ) : + if srcConnector is not None : + self.srcPoint = srcConnector.getCenterPoint () + self.srcConnector = srcConnector + self.srcConnector.addGfxLink ( self ) + # + # setDstConnector + # + def setDstConnector ( self, dstConnector ) : + if dstConnector is not None : + self.dstPoint = dstConnector.getCenterPoint () + self.dstConnector = dstConnector + self.dstConnector.addGfxLink ( self ) + # + # itemChange + # + def itemChange ( self, change, value ) : + if change == QtGui.QGraphicsItem.ItemSelectedChange : + self.isLinkSelected = value.toBool () + return QtGui.QGraphicsItem.itemChange ( self, change, value ) + # + # setPoints + # + def setPoints ( self, srcP, dstP ) : + self.srcPoint = self.mapToItem ( self, srcP ) + self.dstPoint = self.mapToItem ( self, dstP ) + self.adjust () + # + # setSrcPoint + # + def setSrcPoint ( self, p ) : + self.srcPoint = self.mapToItem ( self, p ) + self.adjust () + # + # setDstPoint + # + def setDstPoint ( self, p ) : + self.dstPoint = self.mapToItem ( self, p ) + self.adjust () + # + # adjust + # + def adjust ( self ) : + from meShaderEd import getDefaultValue + self.isStraight = getDefaultValue ( app_settings, 'WorkArea', 'straight_links' ) + + if self.srcConnector is not None : self.srcPoint = self.srcConnector.getCenterPoint () + if self.dstConnector is not None : self.dstPoint = self.dstConnector.getCenterPoint () + + self.prepareGeometryChange () + + del self.points [ : ] # clear bezier points + self.path = None + if self.srcPoint is not None and self.dstPoint is not None : + self.path = QtGui.QPainterPath () + # first point + self.points.append ( self.srcPoint ) + self.path.moveTo ( self.points [ 0 ] ) + + # draw curved spline if isStraight is False + if not self.isStraight : + # hull spline + hull = QtCore.QRectF ( self.srcPoint, self.dstPoint ) + centerX = hull.center ().x () + centerY = hull.center ().y () + # second point + offsetVX = min ( abs ( hull.topRight ().x () - hull.topLeft ().x () ) * 0.1, 40 ) + offsetVY = 0.0 + + p1 = self.srcPoint + QtCore.QPointF ( offsetVX, offsetVY ) + self.points.append ( p1 ) + # third point + p2 = QtCore.QPointF ( centerX, self.srcPoint.y() ) + self.points.append ( p2 ) + # fourth point + p3 = QtCore.QPointF ( centerX, centerY ) + self.points.append ( p3 ) + # fifth point (bezier tangent) + p4 = QtCore.QPointF ( centerX, centerY ) + self.points.append ( p4 ) + # sixth point + p5 = QtCore.QPointF ( centerX, self.dstPoint.y() ) + self.points.append ( p5 ) + # seventh point + p6 = self.dstPoint - QtCore.QPointF ( offsetVX, offsetVY ) + self.points.append ( p6 ) + # last point + self.points.append ( self.dstPoint ) + if self.isStraight : + #if DEBUG_MODE : print '* GfxLink: Straight mode' + self.path.lineTo ( self.dstPoint ) + else: + #if DEBUG_MODE : print '* GfxLink: Curved mode' + #self.path.cubicTo ( self.points[1], self.points[2], self.points[3] ) + #self.path.cubicTo ( self.points[5], self.points[6], self.points[7] ) + self.path.cubicTo ( p1, p1, p3 ) + self.path.cubicTo ( p6, p6, self.dstPoint ) + self.rect = self.path.boundingRect () + # + # paint + # + def paint ( self, painter, option, widget ) : + # + if self.path is not None : + painter.setRenderHint ( QtGui.QPainter.Antialiasing ) + brush = self.brushNormal + if self.isLinkSelected : brush = self.brushSelected + painter.setPen( QtGui.QPen ( brush, + 1.25, + QtCore.Qt.SolidLine, + QtCore.Qt.RoundCap, + QtCore.Qt.RoundJoin + ) + ) + painter.drawPath ( self.path ) diff --git a/gfx/gfxNode.py b/gfx/gfxNode.py index 6def1c2..87d595d 100644 --- a/gfx/gfxNode.py +++ b/gfx/gfxNode.py @@ -3,8 +3,7 @@ gfxNode.py """ -import os, sys -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui from gfx.gfxNodeLabel import GfxNodeLabel from gfx.gfxNodeConnector import GfxNodeConnector @@ -13,555 +12,561 @@ from global_vars import app_colors, DEBUG_MODE, GFX_NODE_TYPE, VALID_RSL_PARAM_TYPES, VALID_RIB_NODE_TYPES, VALID_RSL_NODE_TYPES from meShaderEd import app_settings import gui.ui_settings as UI + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets # # GfxNode # -class GfxNode ( QtGui.QGraphicsItem ) : - # - Type = GFX_NODE_TYPE - # - # __init__ - # - def __init__ ( self, node ) : - # - QtGui.QGraphicsItem.__init__ ( self ) - - self.node = node - self.header = {} - - self.outputParamLabels = [] - self.inputParamLabels = [] - - self.outputConnectors = [] - self.inputConnectors = [] - - self.headerFont = QtGui.QFont () - self.paramsFont = QtGui.QFont () - - self.x_offset = 10 - self.y_offset = 10 - self.radius = UI.NODE_RADIUS - - self.swatchSize = UI.SWATCH_SIZE - self.hasSwatch = False - - self.shadow_offset = UI.SHADOW_OFFSET - self.shadow_opacity = UI.SHADOW_OPACITY - - self.normalColor = QtGui.QColor ( 0, 0, 0 ) - self.selectedColor = QtGui.QColor ( 250, 250, 250 ) - alternateColor = QtGui.QColor ( 240, 140, 0 ) - self.bgColor = self.get_bg_color () - - self.shadowColor = QtGui.QColor ( 0, 0, 0 ) - self.shadowColor.setAlphaF ( self.shadow_opacity ) - - self.PenBorderNormal = QtGui.QPen( QtGui.QBrush ( self.normalColor ), - 1.0, - QtCore.Qt.SolidLine, - QtCore.Qt.RoundCap, - QtCore.Qt.RoundJoin ) - - self.PenBorderSelected = QtGui.QPen( QtGui.QBrush ( self.selectedColor ), - 2.0, - QtCore.Qt.SolidLine, - QtCore.Qt.RoundCap, - QtCore.Qt.RoundJoin ) - - self.PenNodeShaderParam = QtGui.QPen( QtGui.QColor( 250, 250, 250 ) ) - - self.BrushNodeNormal = QtGui.QBrush ( self.bgColor ) - self.BrushShadow = QtGui.QBrush ( self.shadowColor ) - self.PenShadow = QtGui.QPen ( self.shadowColor ) - - - - self.collapse = None # 'input' 'output' 'all' - - if self.node is not None : - QtCore.QObject.connect ( self.node, QtCore.SIGNAL ( 'nodeUpdated' ), self.onUpdateNode ) - QtCore.QObject.connect ( self.node, QtCore.SIGNAL ( 'nodeParamsUpdated' ), self.onUpdateNodeParams ) - self.updateGfxNode () - ( x, y ) = self.node.offset - self.setPos ( x, y ) - - # flag (new from QT 4.6...) - self.setFlag ( QtGui.QGraphicsItem.ItemSendsScenePositionChanges ) - self.setFlag ( QtGui.QGraphicsItem.ItemSendsGeometryChanges ) - - # qt graphics stuff - self.setFlag ( QtGui.QGraphicsItem.ItemIsMovable ) - self.setFlag ( QtGui.QGraphicsItem.ItemIsSelectable ) - self.setZValue ( 1 ) - # - # type - # - def type ( self ) : return GfxNode.Type - # - # - # - def get_bg_color ( self ) : - # - bg = QtGui.QColor ( 128, 128, 128 ) - - if self.node.type in VALID_RSL_NODE_TYPES : - bg = app_colors [ 'rsl_node_bg' ] - elif self.node.type in VALID_RIB_NODE_TYPES : - bg = app_colors [ 'rib_node_bg' ] - elif self.node.type == 'image' : - bg = app_colors [ 'image_node_bg' ] - return bg - # - # onUpdateNode - # - def onUpdateNode ( self ) : - # - if DEBUG_MODE : print '>> GfxNode( %s ).updateNode' % ( self.node.label ) - self.updateGfxNodeParams ( True ) - self.scene().emit ( QtCore.SIGNAL ( 'nodeUpdated' ), self ) - # - # onUpdateNodeParams - # - def onUpdateNodeParams ( self, forceUpdate = False ) : - # - if DEBUG_MODE : print '>> GfxNode( %s ).onUpdateNodeParams' % ( self.node.label ) - self.updateGfxNodeParams ( forceUpdate ) - self.scene().emit ( QtCore.SIGNAL ( 'gfxNodeParamChanged' ), self ) - - # - # updateGfxNodeParams - # - def updateGfxNodeParams ( self, forceUpdate = False ) : - # - if DEBUG_MODE : print '>> GfxNode( %s ).updateGfxNodeParams' % ( self.node.label ) - inpGeomChanged = self.updateInputParams () - outGeomChanged = self.updateOutputParams () - if forceUpdate or inpGeomChanged or outGeomChanged : - self.setupGeometry () - self.update () - self.adjustLinks () - # - # updateGfxNode - # - def updateGfxNode ( self, removeLinks = True ) : - # - if DEBUG_MODE : print '>> GfxNode( %s ).updateGfxNode' % ( self.node.label ) - if removeLinks : - # remove all GfxLinks - for connect in self.inputConnectors : connect.removeAllLinks () - for connect in self.outputConnectors : connect.removeAllLinks () - self.outputConnectors = [] - self.inputConnectors = [] - # remove all children - for item in self.childItems () : self.scene ().removeItem ( item ) - self.header = {} - self.setupHeader () - self.outputParamLabels = [] - self.inputParamLabels = [] - - self.setupParams ( self.node.outputParams, self.outputParamLabels, self.outputConnectors, removeLinks ) - self.setupParams ( self.node.inputParams, self.inputParamLabels, self.inputConnectors, removeLinks ) - self.setupGeometry () - self.update () - # - # getInputConnectorByParam - # - def getInputConnectorByParam ( self, param ) : - # - connector = None - for cnt in self.inputConnectors : - if cnt.param == param : - connector = cnt - break - return connector - # - # getOutputConnectorByParam - # - def getOutputConnectorByParam ( self, param ) : - # - connector = None - for cnt in self.outputConnectors : - if cnt.param == param : - connector = cnt - break - return connector - # - # remove - # - def remove ( self ) : - # - if DEBUG_MODE : print '>> GfxNode.remove' - QtCore.QObject.disconnect ( self.node, QtCore.SIGNAL ( 'nodeUpdated' ), self.onUpdateNode ) - for connect in self.inputConnectors : connect.removeAllLinks () - for connect in self.outputConnectors : connect.removeAllLinks () - self.scene().emit ( QtCore.SIGNAL ( 'onGfxNodeRemoved' ), self ) - # - # updateNodeLabel - # - def updateNodeLabel ( self ) : - # - self.header [ 'label' ].setText ( self.node.label ) - self.setupGeometry () - self.update () - self.adjustLinks () - # - # updateInputParams - # - def updateInputParams ( self ) : return self.updateParams ( self.node.inputParams, self.inputParamLabels ) - # - # updateOutputParams - # - def updateOutputParams ( self ) : return self.updateParams ( self.node.outputParams, self.outputParamLabels ) - # - # updateParams - # - def updateParams ( self, params, labels ) : - # - if DEBUG_MODE : print '>> GfxNode.updateParams' - geomChanged = False - i = 0 - for param in params : # for i in range( len( self.node.inputParams )) : - if param.type != 'control' : - if param.provider != 'attribute' : - if i >= len ( labels ) : - label = self.addGfxNodeParam ( param ) - geomChanged = True - else : - label = labels [ i ] - if param.label != label.text : - label.setText ( param.label ) - geomChanged = True - self.updateGfxNodeParamLabel ( param, label ) - i += 1 - return geomChanged - # - # setupGeometry - # - def setupGeometry ( self ) : - # - ( wi_header, hi_header ) = self.getHeaderSize () - ( wi_output, hi_output ) = self.getParamsSize ( self.outputParamLabels ) - ( wi_input, hi_input ) = self.getParamsSize ( self.inputParamLabels ) - - wi_max = max ( wi_header, wi_output, wi_input ) + 2 * self.x_offset - hi_max = hi_header + hi_output + hi_input + 3 * self.y_offset - - self.rect = QtCore.QRectF ( 0, 0, wi_max, hi_max ) - self.setupHeaderGeometry ( self.x_offset, self.y_offset ) - self.setupOutputParamsGeometry ( wi_max - self.x_offset, hi_header + 2 * self.y_offset ) - self.setupInputParamsGeometry ( self.x_offset, hi_header + 2 * self.y_offset + hi_output ) - # - # shadowRect - # - def shadowRect ( self ) : - # - shadowRect = QtCore.QRectF ( self.rect ) - shadowRect.translate ( self.shadow_offset, self.shadow_offset ) - return shadowRect - # - # boundingRect - # - def boundingRect ( self ) : - # - bound_rect = QtCore.QRectF ( self.rect ).united( self.shadowRect () ) - bound_rect.adjust( -8, 0, 8, 0 ) - return bound_rect - # - # shape - # - def shape ( self ) : - # - shape = QtGui.QPainterPath () - shape.addRect ( self.boundingRect () ) - return shape - # - # setupHeader - # - def setupHeader ( self ) : - # - if self.node.type != 'variable' : - self.header [ 'label' ] = GfxNodeLabel ( self.node.label ) - - self.header [ 'label' ].setBgColor ( self.bgColor ) - self.header [ 'label' ].setNormalColor ( self.normalColor ) - self.header [ 'label' ].setBold () - self.header [ 'label' ].setSelected ( self.isSelected () ) - - if self.node.help is not None : - self.header [ 'label' ].setWhatsThis ( self.node.help ) - - self.header [ 'name' ] = GfxNodeLabel ( self.node.name ) - - self.header [ 'name' ].setBgColor ( self.bgColor ) - self.header [ 'name' ].setNormalColor ( self.normalColor ) - self.header [ 'name' ].setItalic () - self.header [ 'name' ].setProcessEvents ( False ) - - if self.hasSwatch : self.header [ 'swatch' ] = GfxNodeSwatch ( self.swatchSize ) - - #self.header['input'] = GfxNodeConnector( 6 ) - #self.header['output'] = GfxNodeConnector( 6 ) - # - # getHeaderSize - # - def getHeaderSize ( self ) : - # - wi = 80 # minimal node width - hi = 0 - if self.node.type != 'variable' : - ( wi_label, hi_label ) = self.header [ 'label' ].getLabelSize () - ( wi_name, hi_name ) = self.header [ 'name' ].getLabelSize() - hi = ( hi_label + hi_name ) - wi = max ( wi, ( self.x_offset + max ( wi_label, wi_name ) ) ) - - if self.hasSwatch : - hi = max ( self.swatchSize, hi ) - wi += self.swatchSize - - return ( wi, hi ) - # - # setupHeaderGeometry - # - def setupHeaderGeometry ( self, x, y ) : - # - if self.node.type != 'variable' : - wi_header = self.rect.width () - if self.hasSwatch : - self.header [ 'swatch' ].rect.moveTo ( x, y ) - #self.header['input'].rect.moveTo( x - self.x_offset - self.header['input'].radius, - # y + self.swatchSize / 2 - self.header['input'].radius ) - #self.header['output'].rect.moveTo( wi_header - self.header['output'].radius, - # y + self.swatchSize / 2 - self.header['output'].radius ) - x += self.header [ 'swatch' ].rect.width () + self.x_offset - - ( wi, hi ) = self.header [ 'label' ].getLabelSize () - self.header [ 'label' ].rect = QtCore.QRectF ( x, y, wi, hi ) - y += hi - ( wi, hi ) = self.header [ 'name' ].getLabelSize() - self.header [ 'name' ].rect = QtCore.QRectF ( x, y, wi, hi ) - - # parent controls from header - for ctrl in self.header.keys() : self.header [ ctrl ].setParentItem ( self ) - # - # setupOutputParamsGeometry - # - def setupOutputParamsGeometry ( self, xs, ys ) : - # - y = ys - hi = 0 - for label in self.outputParamLabels : - ( wi, hi ) = label.getLabelSize () - label.rect = QtCore.QRectF ( xs - wi, y, wi, hi ) - y += hi - label.setParentItem ( self ) - # wi_header = self.rect.width() - y = ys - x = xs + self.x_offset - for connector in self.outputConnectors : - connector.rect.moveTo ( x - connector.radius, y + hi / 2 - connector.radius ) - y += hi - connector.setParentItem ( self ) - # - # setupInputParamsGeometry - # - def setupInputParamsGeometry ( self, xs, ys ) : - # - y = ys - hi = 0 - for label in self.inputParamLabels : - ( wi, hi ) = label.getLabelSize () - label.rect = QtCore.QRectF ( xs, y, wi, hi ) - y += hi - label.setParentItem ( self ) - - y = ys - x = xs - self.x_offset - for connector in self.inputConnectors : - connector.rect.moveTo ( x - connector.radius, y + hi / 2 - connector.radius ) - y += hi - connector.setParentItem ( self ) - # - # getParamsSize - # - def getParamsSize ( self, paramLabels ) : - # - wi = 0 - hi = 0 - for label in paramLabels : - ( wi_label, hi_label ) = label.getLabelSize() - hi += hi_label - wi = max ( wi, wi_label ) - return ( wi, hi ) - # - # updateGfxNodeParamLabel - # - def updateGfxNodeParamLabel ( self, param, label, forceUpdate = False ) : - # - if param.type in VALID_RSL_PARAM_TYPES : - label.setNormal () - isVarying = ( param.detail == 'varying' ) - isPrimitive = ( param.provider == 'primitive' ) - label.setItalic ( isVarying ) - label.setSelected ( param.shaderParam ) - label.setAlternate ( isPrimitive ) - # this allows to change param.shaderParam attribute by CTRL-click on label - # and switch param.provide to "primitive" by ALT-click - label.setProcessEvents ( True ) - if forceUpdate : - self.update () - self.scene().emit ( QtCore.SIGNAL ( 'gfxNodeParamChanged' ), self, param ) - # - # addGfxNodeParam - # - def addGfxNodeParam ( self, param ) : - # - if param.isInput : - labels = self.inputParamLabels - connectors = self.inputConnectors - else : - labels = self.outputParamLabels - connectors = self.outputConnectors - label = GfxNodeLabel ( param.label, param ) - label.setBgColor ( self.bgColor ) - label.setNormalColor ( self.normalColor ) - if not param.isInput : label.setBold () - - if param.help is not None : - label.setWhatsThis ( self.node.help ) - - self.updateGfxNodeParamLabel ( param, label ) - - labels.append ( label ) - - connector = GfxNodeConnector ( param, UI.CONNECTOR_RADIUS, node = None ) - if not param.isInput : connector.singleLinkOnly = False - connectors.append ( connector ) - # - # removeGfxNodeParam - # - def removeGfxNodeParam ( self, param ) : - # - if DEBUG_MODE : print ">> GfxNode.removeGfxNodeParam (%s)" % param.label - if param.isInput : - labels = self.inputParamLabels - connectors = self.inputConnectors - else : - labels = self.outputParamLabels - connectors = self.outputConnectors - i = 0 - for label in list ( labels ) : - if label.param == param : - labels.pop ( i ) - self.scene ().removeItem ( label ) - - connector = connectors.pop ( i ) - connector.remove () - self.scene ().removeItem ( connector ) - - i += 1 - # - # setupParams - # - def setupParams ( self, params, labels, connectors, updateConnectors = True ): - # - for param in params : - # ignore attributes - if param.provider != 'attribute' : - label = GfxNodeLabel ( param.label, param ) - label.setBgColor ( self.bgColor ) - label.setNormalColor ( self.normalColor ) - if not param.isInput : label.setBold () - - if param.help is not None : - label.setWhatsThis ( self.node.help ) - - if param.type in VALID_RSL_PARAM_TYPES : - label.setNormal () - isVarying = ( param.detail == 'varying' ) - isPrimitive = ( param.provider == 'primitive' ) - label.setItalic ( isVarying ) - label.setSelected ( param.shaderParam ) - label.setAlternate ( isPrimitive ) - # this allows to change param.shaderParam attribute by CTRL-click on label - # and switch param.provide to "primitive" by ALT-click - label.setProcessEvents ( True ) - labels.append ( label ) - if updateConnectors : - connector = GfxNodeConnector ( param, UI.CONNECTOR_RADIUS, node = None ) - if not param.isInput : connector.singleLinkOnly = False - connectors.append ( connector ) - # - # adjustLinks - # - def adjustLinks ( self ) : - # invalidate all the links attached - for connect in self.inputConnectors : connect.adjustLinks () - for connect in self.outputConnectors : connect.adjustLinks () - # - # itemChange - # - def itemChange ( self, change, value ) : - # - if change == QtGui.QGraphicsItem.ItemSelectedHasChanged : #ItemSelectedChange: - if self.node.type != 'variable' : - # variable node has not header - self.header [ 'label' ].setSelected ( value.toBool () ) - #self.header['swatch'].isNodeSelected = self.isNodeSelected - if value.toBool () : - items = self.scene ().items () - for i in range ( len ( items ) - 1, -1, -1 ) : - if items [ i ].parentItem() is None : - if items [ i ] != self : - items [ i ].stackBefore ( self ) - #scene.setFocusItem ( self ) - elif change == QtGui.QGraphicsItem.ItemPositionHasChanged : - from meShaderEd import getDefaultValue - grid_snap = getDefaultValue ( app_settings, 'WorkArea', 'grid_snap' ) - grid_size = int ( getDefaultValue ( app_settings, 'WorkArea', 'grid_size' ) ) - x = self.x () - y = self.y () - if grid_snap : - #if DEBUG_MODE : print '* snap to grid (size = %d)' % grid_size - x -= ( x % grid_size ) - y -= ( y % grid_size ) - self.setPos ( x, y ) - #if DEBUG_MODE : print '* GfxNode.itemChange = ItemPositionHasChanged (%f, %f)' % ( x, y ) - self.node.offset = ( x, y ) - self.adjustLinks () - return QtGui.QGraphicsItem.itemChange ( self, change, value ) - # - # paint - # - def paint ( self, painter, option, widget ) : - # print ( ">> GfxNode.paint" ) - painter.setRenderHint ( QtGui.QPainter.Antialiasing ) - painter.setRenderHint ( QtGui.QPainter.SmoothPixmapTransform ) - - self.paintShadow ( painter ) - self.paintFrame ( painter ) - # - # paintShadow - # - def paintShadow ( self, painter ) : - # - painter.setBrush ( self.BrushShadow ) - painter.setPen ( self.PenShadow ) - painter.drawRoundedRect ( self.shadowRect (), self.radius, self.radius, QtCore.Qt.AbsoluteSize ) - # - # paintFrame - # - def paintFrame ( self, painter ) : - #print ( ">> GfxNode.paintWindowFrame" ) - pen = self.PenBorderNormal - brush = self.BrushNodeNormal - if self.isSelected () : - pen = self.PenBorderSelected - # brush = self.BrushNodeSelected - - painter.setPen ( pen ) - painter.setBrush ( brush ) - - # painter.drawRect ( self.rect ) - painter.drawRoundedRect ( self.rect, self.radius, self.radius, QtCore.Qt.AbsoluteSize ) - # Qt::SizeMode mode = Qt::AbsoluteSize Qt.RelativeSize +class GfxNode ( QtModule.QGraphicsItem ) : + # + Type = GFX_NODE_TYPE + # + # __init__ + # + def __init__ ( self, node ) : + # + QtModule.QGraphicsItem.__init__ ( self ) + + self.node = node + self.header = {} + + self.outputParamLabels = [] + self.inputParamLabels = [] + + self.outputConnectors = [] + self.inputConnectors = [] + + self.headerFont = QtGui.QFont () + self.paramsFont = QtGui.QFont () + + self.x_offset = 10 + self.y_offset = 10 + self.radius = UI.NODE_RADIUS + + self.swatchSize = UI.SWATCH_SIZE + self.hasSwatch = False + + self.shadow_offset = UI.SHADOW_OFFSET + self.shadow_opacity = UI.SHADOW_OPACITY + + self.normalColor = QtGui.QColor ( 0, 0, 0 ) + self.selectedColor = QtGui.QColor ( 250, 250, 250 ) + alternateColor = QtGui.QColor ( 240, 140, 0 ) + self.bgColor = self.get_bg_color () + + self.shadowColor = QtGui.QColor ( 0, 0, 0 ) + self.shadowColor.setAlphaF ( self.shadow_opacity ) + + self.PenBorderNormal = QtGui.QPen( QtGui.QBrush ( self.normalColor ), + 1.0, + QtCore.Qt.SolidLine, + QtCore.Qt.RoundCap, + QtCore.Qt.RoundJoin ) + + self.PenBorderSelected = QtGui.QPen( QtGui.QBrush ( self.selectedColor ), + 2.0, + QtCore.Qt.SolidLine, + QtCore.Qt.RoundCap, + QtCore.Qt.RoundJoin ) + + self.PenNodeShaderParam = QtGui.QPen( QtGui.QColor( 250, 250, 250 ) ) + + self.BrushNodeNormal = QtGui.QBrush ( self.bgColor ) + self.BrushShadow = QtGui.QBrush ( self.shadowColor ) + self.PenShadow = QtGui.QPen ( self.shadowColor ) + + + + self.collapse = None # 'input' 'output' 'all' + + if self.node is not None : + QtCore.QObject.connect ( self.node, QtCore.SIGNAL ( 'nodeUpdated' ), self.onUpdateNode ) + QtCore.QObject.connect ( self.node, QtCore.SIGNAL ( 'nodeParamsUpdated' ), self.onUpdateNodeParams ) + self.updateGfxNode () + ( x, y ) = self.node.offset + self.setPos ( x, y ) + + # flag (new from QT 4.6...) + self.setFlag ( QtGui.QGraphicsItem.ItemSendsScenePositionChanges ) + self.setFlag ( QtGui.QGraphicsItem.ItemSendsGeometryChanges ) + + # qt graphics stuff + self.setFlag ( QtGui.QGraphicsItem.ItemIsMovable ) + self.setFlag ( QtGui.QGraphicsItem.ItemIsSelectable ) + self.setZValue ( 1 ) + # + # type + # + def type ( self ) : return GfxNode.Type + # + # + # + def get_bg_color ( self ) : + # + bg = QtGui.QColor ( 128, 128, 128 ) + + if self.node.type in VALID_RSL_NODE_TYPES : + bg = app_colors [ 'rsl_node_bg' ] + elif self.node.type in VALID_RIB_NODE_TYPES : + bg = app_colors [ 'rib_node_bg' ] + elif self.node.type == 'image' : + bg = app_colors [ 'image_node_bg' ] + return bg + # + # onUpdateNode + # + def onUpdateNode ( self ) : + # + if DEBUG_MODE : print '>> GfxNode( %s ).updateNode' % ( self.node.label ) + self.updateGfxNodeParams ( True ) + self.scene().emit ( QtCore.SIGNAL ( 'nodeUpdated' ), self ) + # + # onUpdateNodeParams + # + def onUpdateNodeParams ( self, forceUpdate = False ) : + # + if DEBUG_MODE : print '>> GfxNode( %s ).onUpdateNodeParams' % ( self.node.label ) + self.updateGfxNodeParams ( forceUpdate ) + self.scene().emit ( QtCore.SIGNAL ( 'gfxNodeParamChanged' ), self ) + + # + # updateGfxNodeParams + # + def updateGfxNodeParams ( self, forceUpdate = False ) : + # + if DEBUG_MODE : print '>> GfxNode( %s ).updateGfxNodeParams' % ( self.node.label ) + inpGeomChanged = self.updateInputParams () + outGeomChanged = self.updateOutputParams () + if forceUpdate or inpGeomChanged or outGeomChanged : + self.setupGeometry () + self.update () + self.adjustLinks () + # + # updateGfxNode + # + def updateGfxNode ( self, removeLinks = True ) : + # + if DEBUG_MODE : print '>> GfxNode( %s ).updateGfxNode' % ( self.node.label ) + if removeLinks : + # remove all GfxLinks + for connect in self.inputConnectors : connect.removeAllLinks () + for connect in self.outputConnectors : connect.removeAllLinks () + self.outputConnectors = [] + self.inputConnectors = [] + # remove all children + for item in self.childItems () : self.scene ().removeItem ( item ) + self.header = {} + self.setupHeader () + self.outputParamLabels = [] + self.inputParamLabels = [] + + self.setupParams ( self.node.outputParams, self.outputParamLabels, self.outputConnectors, removeLinks ) + self.setupParams ( self.node.inputParams, self.inputParamLabels, self.inputConnectors, removeLinks ) + self.setupGeometry () + self.update () + # + # getInputConnectorByParam + # + def getInputConnectorByParam ( self, param ) : + # + connector = None + for cnt in self.inputConnectors : + if cnt.param == param : + connector = cnt + break + return connector + # + # getOutputConnectorByParam + # + def getOutputConnectorByParam ( self, param ) : + # + connector = None + for cnt in self.outputConnectors : + if cnt.param == param : + connector = cnt + break + return connector + # + # remove + # + def remove ( self ) : + # + if DEBUG_MODE : print '>> GfxNode.remove' + QtCore.QObject.disconnect ( self.node, QtCore.SIGNAL ( 'nodeUpdated' ), self.onUpdateNode ) + for connect in self.inputConnectors : connect.removeAllLinks () + for connect in self.outputConnectors : connect.removeAllLinks () + self.scene().emit ( QtCore.SIGNAL ( 'onGfxNodeRemoved' ), self ) + # + # updateNodeLabel + # + def updateNodeLabel ( self ) : + # + self.header [ 'label' ].setText ( self.node.label ) + self.setupGeometry () + self.update () + self.adjustLinks () + # + # updateInputParams + # + def updateInputParams ( self ) : return self.updateParams ( self.node.inputParams, self.inputParamLabels ) + # + # updateOutputParams + # + def updateOutputParams ( self ) : return self.updateParams ( self.node.outputParams, self.outputParamLabels ) + # + # updateParams + # + def updateParams ( self, params, labels ) : + # + if DEBUG_MODE : print '>> GfxNode.updateParams' + geomChanged = False + i = 0 + for param in params : # for i in range( len( self.node.inputParams )) : + if param.type != 'control' : + if param.provider != 'attribute' : + if i >= len ( labels ) : + label = self.addGfxNodeParam ( param ) + geomChanged = True + else : + label = labels [ i ] + if param.label != label.text : + label.setText ( param.label ) + geomChanged = True + self.updateGfxNodeParamLabel ( param, label ) + i += 1 + return geomChanged + # + # setupGeometry + # + def setupGeometry ( self ) : + # + ( wi_header, hi_header ) = self.getHeaderSize () + ( wi_output, hi_output ) = self.getParamsSize ( self.outputParamLabels ) + ( wi_input, hi_input ) = self.getParamsSize ( self.inputParamLabels ) + + wi_max = max ( wi_header, wi_output, wi_input ) + 2 * self.x_offset + hi_max = hi_header + hi_output + hi_input + 3 * self.y_offset + + self.rect = QtCore.QRectF ( 0, 0, wi_max, hi_max ) + self.setupHeaderGeometry ( self.x_offset, self.y_offset ) + self.setupOutputParamsGeometry ( wi_max - self.x_offset, hi_header + 2 * self.y_offset ) + self.setupInputParamsGeometry ( self.x_offset, hi_header + 2 * self.y_offset + hi_output ) + # + # shadowRect + # + def shadowRect ( self ) : + # + shadowRect = QtCore.QRectF ( self.rect ) + shadowRect.translate ( self.shadow_offset, self.shadow_offset ) + return shadowRect + # + # boundingRect + # + def boundingRect ( self ) : + # + bound_rect = QtCore.QRectF ( self.rect ).united( self.shadowRect () ) + bound_rect.adjust( -8, 0, 8, 0 ) + return bound_rect + # + # shape + # + def shape ( self ) : + # + shape = QtGui.QPainterPath () + shape.addRect ( self.boundingRect () ) + return shape + # + # setupHeader + # + def setupHeader ( self ) : + # + if self.node.type != 'variable' : + self.header [ 'label' ] = GfxNodeLabel ( self.node.label ) + + self.header [ 'label' ].setBgColor ( self.bgColor ) + self.header [ 'label' ].setNormalColor ( self.normalColor ) + self.header [ 'label' ].setBold () + self.header [ 'label' ].setSelected ( self.isSelected () ) + + if self.node.help is not None : + self.header [ 'label' ].setWhatsThis ( self.node.help ) + + self.header [ 'name' ] = GfxNodeLabel ( self.node.name ) + + self.header [ 'name' ].setBgColor ( self.bgColor ) + self.header [ 'name' ].setNormalColor ( self.normalColor ) + self.header [ 'name' ].setItalic () + self.header [ 'name' ].setProcessEvents ( False ) + + if self.hasSwatch : self.header [ 'swatch' ] = GfxNodeSwatch ( self.swatchSize ) + + #self.header['input'] = GfxNodeConnector( 6 ) + #self.header['output'] = GfxNodeConnector( 6 ) + # + # getHeaderSize + # + def getHeaderSize ( self ) : + # + wi = 80 # minimal node width + hi = 0 + if self.node.type != 'variable' : + ( wi_label, hi_label ) = self.header [ 'label' ].getLabelSize () + ( wi_name, hi_name ) = self.header [ 'name' ].getLabelSize() + hi = ( hi_label + hi_name ) + wi = max ( wi, ( self.x_offset + max ( wi_label, wi_name ) ) ) + + if self.hasSwatch : + hi = max ( self.swatchSize, hi ) + wi += self.swatchSize + + return ( wi, hi ) + # + # setupHeaderGeometry + # + def setupHeaderGeometry ( self, x, y ) : + # + if self.node.type != 'variable' : + wi_header = self.rect.width () + if self.hasSwatch : + self.header [ 'swatch' ].rect.moveTo ( x, y ) + #self.header['input'].rect.moveTo( x - self.x_offset - self.header['input'].radius, + # y + self.swatchSize / 2 - self.header['input'].radius ) + #self.header['output'].rect.moveTo( wi_header - self.header['output'].radius, + # y + self.swatchSize / 2 - self.header['output'].radius ) + x += self.header [ 'swatch' ].rect.width () + self.x_offset + + ( wi, hi ) = self.header [ 'label' ].getLabelSize () + self.header [ 'label' ].rect = QtCore.QRectF ( x, y, wi, hi ) + y += hi + ( wi, hi ) = self.header [ 'name' ].getLabelSize() + self.header [ 'name' ].rect = QtCore.QRectF ( x, y, wi, hi ) + + # parent controls from header + for ctrl in self.header.keys() : self.header [ ctrl ].setParentItem ( self ) + # + # setupOutputParamsGeometry + # + def setupOutputParamsGeometry ( self, xs, ys ) : + # + y = ys + hi = 0 + for label in self.outputParamLabels : + ( wi, hi ) = label.getLabelSize () + label.rect = QtCore.QRectF ( xs - wi, y, wi, hi ) + y += hi + label.setParentItem ( self ) + # wi_header = self.rect.width() + y = ys + x = xs + self.x_offset + for connector in self.outputConnectors : + connector.rect.moveTo ( x - connector.radius, y + hi / 2 - connector.radius ) + y += hi + connector.setParentItem ( self ) + # + # setupInputParamsGeometry + # + def setupInputParamsGeometry ( self, xs, ys ) : + # + y = ys + hi = 0 + for label in self.inputParamLabels : + ( wi, hi ) = label.getLabelSize () + label.rect = QtCore.QRectF ( xs, y, wi, hi ) + y += hi + label.setParentItem ( self ) + + y = ys + x = xs - self.x_offset + for connector in self.inputConnectors : + connector.rect.moveTo ( x - connector.radius, y + hi / 2 - connector.radius ) + y += hi + connector.setParentItem ( self ) + # + # getParamsSize + # + def getParamsSize ( self, paramLabels ) : + # + wi = 0 + hi = 0 + for label in paramLabels : + ( wi_label, hi_label ) = label.getLabelSize() + hi += hi_label + wi = max ( wi, wi_label ) + return ( wi, hi ) + # + # updateGfxNodeParamLabel + # + def updateGfxNodeParamLabel ( self, param, label, forceUpdate = False ) : + # + if param.type in VALID_RSL_PARAM_TYPES : + label.setNormal () + isVarying = ( param.detail == 'varying' ) + isPrimitive = ( param.provider == 'primitive' ) + label.setItalic ( isVarying ) + label.setSelected ( param.shaderParam ) + label.setAlternate ( isPrimitive ) + # this allows to change param.shaderParam attribute by CTRL-click on label + # and switch param.provide to "primitive" by ALT-click + label.setProcessEvents ( True ) + if forceUpdate : + self.update () + self.scene().emit ( QtCore.SIGNAL ( 'gfxNodeParamChanged' ), self, param ) + # + # addGfxNodeParam + # + def addGfxNodeParam ( self, param ) : + # + if param.isInput : + labels = self.inputParamLabels + connectors = self.inputConnectors + else : + labels = self.outputParamLabels + connectors = self.outputConnectors + label = GfxNodeLabel ( param.label, param ) + label.setBgColor ( self.bgColor ) + label.setNormalColor ( self.normalColor ) + if not param.isInput : label.setBold () + + if param.help is not None : + label.setWhatsThis ( self.node.help ) + + self.updateGfxNodeParamLabel ( param, label ) + + labels.append ( label ) + + connector = GfxNodeConnector ( param, UI.CONNECTOR_RADIUS, node = None ) + if not param.isInput : connector.singleLinkOnly = False + connectors.append ( connector ) + # + # removeGfxNodeParam + # + def removeGfxNodeParam ( self, param ) : + # + if DEBUG_MODE : print ">> GfxNode.removeGfxNodeParam (%s)" % param.label + if param.isInput : + labels = self.inputParamLabels + connectors = self.inputConnectors + else : + labels = self.outputParamLabels + connectors = self.outputConnectors + i = 0 + for label in list ( labels ) : + if label.param == param : + labels.pop ( i ) + self.scene ().removeItem ( label ) + + connector = connectors.pop ( i ) + connector.remove () + self.scene ().removeItem ( connector ) + + i += 1 + # + # setupParams + # + def setupParams ( self, params, labels, connectors, updateConnectors = True ): + # + for param in params : + # ignore attributes + if param.provider != 'attribute' : + label = GfxNodeLabel ( param.label, param ) + label.setBgColor ( self.bgColor ) + label.setNormalColor ( self.normalColor ) + if not param.isInput : label.setBold () + + if param.help is not None : + label.setWhatsThis ( self.node.help ) + + if param.type in VALID_RSL_PARAM_TYPES : + label.setNormal () + isVarying = ( param.detail == 'varying' ) + isPrimitive = ( param.provider == 'primitive' ) + label.setItalic ( isVarying ) + label.setSelected ( param.shaderParam ) + label.setAlternate ( isPrimitive ) + # this allows to change param.shaderParam attribute by CTRL-click on label + # and switch param.provide to "primitive" by ALT-click + label.setProcessEvents ( True ) + labels.append ( label ) + if updateConnectors : + connector = GfxNodeConnector ( param, UI.CONNECTOR_RADIUS, node = None ) + if not param.isInput : connector.singleLinkOnly = False + connectors.append ( connector ) + # + # adjustLinks + # + def adjustLinks ( self ) : + # invalidate all the links attached + for connect in self.inputConnectors : connect.adjustLinks () + for connect in self.outputConnectors : connect.adjustLinks () + # + # itemChange + # + def itemChange ( self, change, value ) : + # + if change == QtGui.QGraphicsItem.ItemSelectedHasChanged : #ItemSelectedChange: + if self.node.type != 'variable' : + # variable node has not header + self.header [ 'label' ].setSelected ( value.toBool () ) + #self.header['swatch'].isNodeSelected = self.isNodeSelected + if value.toBool () : + items = self.scene ().items () + for i in range ( len ( items ) - 1, -1, -1 ) : + if items [ i ].parentItem() is None : + if items [ i ] != self : + items [ i ].stackBefore ( self ) + #scene.setFocusItem ( self ) + elif change == QtGui.QGraphicsItem.ItemPositionHasChanged : + from meShaderEd import getDefaultValue + grid_snap = getDefaultValue ( app_settings, 'WorkArea', 'grid_snap' ) + grid_size = int ( getDefaultValue ( app_settings, 'WorkArea', 'grid_size' ) ) + x = self.x () + y = self.y () + if grid_snap : + #if DEBUG_MODE : print '* snap to grid (size = %d)' % grid_size + x -= ( x % grid_size ) + y -= ( y % grid_size ) + self.setPos ( x, y ) + #if DEBUG_MODE : print '* GfxNode.itemChange = ItemPositionHasChanged (%f, %f)' % ( x, y ) + self.node.offset = ( x, y ) + self.adjustLinks () + return QtGui.QGraphicsItem.itemChange ( self, change, value ) + # + # paint + # + def paint ( self, painter, option, widget ) : + # print ( ">> GfxNode.paint" ) + painter.setRenderHint ( QtGui.QPainter.Antialiasing ) + painter.setRenderHint ( QtGui.QPainter.SmoothPixmapTransform ) + + self.paintShadow ( painter ) + self.paintFrame ( painter ) + # + # paintShadow + # + def paintShadow ( self, painter ) : + # + painter.setBrush ( self.BrushShadow ) + painter.setPen ( self.PenShadow ) + painter.drawRoundedRect ( self.shadowRect (), self.radius, self.radius, QtCore.Qt.AbsoluteSize ) + # + # paintFrame + # + def paintFrame ( self, painter ) : + #print ( ">> GfxNode.paintWindowFrame" ) + pen = self.PenBorderNormal + brush = self.BrushNodeNormal + if self.isSelected () : + pen = self.PenBorderSelected + # brush = self.BrushNodeSelected + + painter.setPen ( pen ) + painter.setBrush ( brush ) + + # painter.drawRect ( self.rect ) + painter.drawRoundedRect ( self.rect, self.radius, self.radius, QtCore.Qt.AbsoluteSize ) + # Qt::SizeMode mode = Qt::AbsoluteSize Qt.RelativeSize diff --git a/gfx/gfxNodeConnector.py b/gfx/gfxNodeConnector.py index 4b9f676..a9e7b74 100644 --- a/gfx/gfxNodeConnector.py +++ b/gfx/gfxNodeConnector.py @@ -1,410 +1,415 @@ -#=============================================================================== -# gfxNodeConnector.py -# -# -# -#=============================================================================== -import os, sys, copy -from PyQt4 import QtCore, QtGui +""" + + gfxNodeConnector.py + +""" +import copy +from core.mePyQt import QtCore, QtGui from meShaderEd import app_settings from global_vars import DEBUG_MODE, GFX_NODE_CONNECTOR_TYPE import gui.ui_settings as UI + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets # # GfxNodeConnector # -class GfxNodeConnector ( QtGui.QGraphicsItem ) : - # - Type = GFX_NODE_CONNECTOR_TYPE - isRound = True - # - # __init__ - # - def __init__ ( self, param = None, radius = UI.CONNECTOR_RADIUS, isRound = True, node = None ) : - # - QtGui.QGraphicsItem.__init__ ( self ) - self.paramsBrushes = { 'c' : QtGui.QBrush ( QtGui.QColor ( QtCore.Qt.darkRed ) ) - ,'f' : QtGui.QBrush ( QtGui.QColor ( QtCore.Qt.lightGray ) ) - ,'m' : QtGui.QBrush ( QtGui.QColor ( QtCore.Qt.darkYellow ) ) - ,'p' : QtGui.QBrush ( QtGui.QColor ( QtCore.Qt.darkCyan ) ) - ,'s' : QtGui.QBrush ( QtGui.QColor ( QtCore.Qt.darkGreen ) ) - ,'v' : QtGui.QBrush ( QtGui.QColor ( QtCore.Qt.darkMagenta ) ) - ,'n' : QtGui.QBrush ( QtGui.QColor ( QtCore.Qt.darkBlue ) ) - ,'I' : QtGui.QBrush ( QtGui.QColor ( 'white' ) ) - ,'G' : QtGui.QBrush ( QtGui.QColor ( 'red' ) ) - ,'R' : QtGui.QBrush ( QtGui.QColor ( 'orange' ) ) - } - self.brush = QtGui.QBrush ( QtGui.QColor ( 140, 140, 140 ) ) # ( 128, 128, 128 ) ( 132, 132, 132 ) - self.PenBorderNormal = QtGui.QPen ( QtGui.QColor ( 0, 0, 0 ) ) - self.PenBorderSelected = QtGui.QPen ( QtGui.QColor ( 240, 240, 240 ), 2.0 ) +class GfxNodeConnector ( QtModule.QGraphicsItem ) : + # + Type = GFX_NODE_CONNECTOR_TYPE + isRound = True + # + # __init__ + # + def __init__ ( self, param = None, radius = UI.CONNECTOR_RADIUS, isRound = True, node = None ) : + # + QtModule.QGraphicsItem.__init__ ( self ) + self.paramsBrushes = { 'c' : QtGui.QBrush ( QtGui.QColor ( QtCore.Qt.darkRed ) ) + ,'f' : QtGui.QBrush ( QtGui.QColor ( QtCore.Qt.lightGray ) ) + ,'m' : QtGui.QBrush ( QtGui.QColor ( QtCore.Qt.darkYellow ) ) + ,'p' : QtGui.QBrush ( QtGui.QColor ( QtCore.Qt.darkCyan ) ) + ,'s' : QtGui.QBrush ( QtGui.QColor ( QtCore.Qt.darkGreen ) ) + ,'v' : QtGui.QBrush ( QtGui.QColor ( QtCore.Qt.darkMagenta ) ) + ,'n' : QtGui.QBrush ( QtGui.QColor ( QtCore.Qt.darkBlue ) ) + ,'I' : QtGui.QBrush ( QtGui.QColor ( 'white' ) ) + ,'G' : QtGui.QBrush ( QtGui.QColor ( 'red' ) ) + ,'R' : QtGui.QBrush ( QtGui.QColor ( 'orange' ) ) + } + self.brush = QtGui.QBrush ( QtGui.QColor ( 140, 140, 140 ) ) # ( 128, 128, 128 ) ( 132, 132, 132 ) + self.PenBorderNormal = QtGui.QPen ( QtGui.QColor ( 0, 0, 0 ) ) + self.PenBorderSelected = QtGui.QPen ( QtGui.QColor ( 240, 240, 240 ), 2.0 ) - self.isNodeSelected = False - self.isRound = isRound - self.radius = radius - self.rect = QtCore.QRectF ( 0, 0, radius*2, radius*2 ) - self.param = param # Node parameter - self.links = [] # gfxLinks list - self.singleLinkOnly = True - self.state = 'idle' + self.isNodeSelected = False + self.isRound = isRound + self.radius = radius + self.rect = QtCore.QRectF ( 0, 0, radius*2, radius*2 ) + self.param = param # Node parameter + self.links = [] # gfxLinks list + self.singleLinkOnly = True + self.state = 'idle' - self.node = node # is not None if this "ConnectorNode" - if node is not None : - # flag (new from QT 4.6...) - self.setFlag ( QtGui.QGraphicsItem.ItemSendsScenePositionChanges ) - self.setFlag ( QtGui.QGraphicsItem.ItemSendsGeometryChanges ) + self.node = node # is not None if this "ConnectorNode" + if node is not None : + # flag (new from QT 4.6...) + self.setFlag ( QtGui.QGraphicsItem.ItemSendsScenePositionChanges ) + self.setFlag ( QtGui.QGraphicsItem.ItemSendsGeometryChanges ) - # qt graphics stuff - self.setFlag ( QtGui.QGraphicsItem.ItemIsMovable ) - self.setFlag ( QtGui.QGraphicsItem.ItemIsSelectable ) - self.setZValue ( 1 ) - ( x, y ) = self.node.offset - self.setPos ( x, y ) - # - # setup connector color - # - paramTypeStr = self.getInputParam ().encodedTypeStr () - if paramTypeStr in self.paramsBrushes.keys () : - self.brush = self.paramsBrushes [ paramTypeStr ] + # qt graphics stuff + self.setFlag ( QtGui.QGraphicsItem.ItemIsMovable ) + self.setFlag ( QtGui.QGraphicsItem.ItemIsSelectable ) + self.setZValue ( 1 ) + ( x, y ) = self.node.offset + self.setPos ( x, y ) + # + # setup connector color + # + paramTypeStr = self.getInputParam ().encodedTypeStr () + if paramTypeStr in self.paramsBrushes.keys () : + self.brush = self.paramsBrushes [ paramTypeStr ] - #self.setFlag ( QtGui.QGraphicsItem.ItemIsSelectable ) - # - # type - # - def type ( self ) : return GfxNodeConnector.Type - # - # boundingRect - # - def boundingRect ( self ) : return self.rect - # - # shape - # - def shape ( self ) : - # - shape = QtGui.QPainterPath () - shape_rect = QtCore.QRectF ( self.rect ) - shape.addEllipse ( shape_rect ) - return shape - # - # paint - # - def paint ( self, painter, option, widget ) : - # - pen = self.PenBorderNormal - if self.isNodeSelected : # isSelected() - pen = self.PenBorderSelected - # brush = self.BrushNodeSelected + #self.setFlag ( QtGui.QGraphicsItem.ItemIsSelectable ) + # + # type + # + def type ( self ) : return GfxNodeConnector.Type + # + # boundingRect + # + def boundingRect ( self ) : return self.rect + # + # shape + # + def shape ( self ) : + # + shape = QtGui.QPainterPath () + shape_rect = QtCore.QRectF ( self.rect ) + shape.addEllipse ( shape_rect ) + return shape + # + # paint + # + def paint ( self, painter, option, widget ) : + # + pen = self.PenBorderNormal + if self.isNodeSelected : # isSelected() + pen = self.PenBorderSelected + # brush = self.BrushNodeSelected - painter.setPen ( pen ) - painter.setBrush ( self.brush ) - painter.drawEllipse ( self.rect ) - # print ( ">> GfxNodeConnector.paint" ) - # - # getCenterPoint - # - def getCenterPoint ( self ) : return self.mapToScene ( self.rect.center () ) - # - # addLink (GfxLink) - # - def addGfxLink ( self, link ) : self.links.append ( link ) - # - # getFirstGfxLink - # - def getFirstGfxLink ( self ) : return self.links [ 0 ] ##copy.copy( self.links[0] ) - # - # getFirstInputParam - # - def getFirstInputParam ( self ) : return self.getNode ().inputParams [ 0 ] - # - # getInputParam - # - def getInputParam ( self ) : - # - param = self.param - if self.isNode () : - param = self.node.inputParams [ 0 ] - return param - # - # getFirstOutputParam - # - def getFirstOutputParam ( self ) : return self.getNode ().outputParams [ 0 ] - # - # getOutputParam - # - def getOutputParam ( self ) : - # - param = self.param - if self.isNode () : - param = self.node.outputParams [ 0 ] - return param - # - # removeGfxLink - # - def removeGfxLink ( self, gfxLink ) : - # - if DEBUG_MODE : print '>> GfxNodeConnector::removeGfxLink' - if gfxLink in self.links : self.links.remove ( gfxLink ) - # - # removeAllLinks - # - def removeAllLinks ( self ) : - # - if DEBUG_MODE : print '>> GfxNodeConnector::removeAllLinks (count = %d)' % len ( self.links ) - for gfxLink in list ( self.links ) : gfxLink.remove () - # - # removeInputGfxLinks - # - def removeInputGfxLinks ( self ) : - # - for gfxLink in self.getInputGfxLinks () : gfxLink.remove () - # - # - def remove ( self ) : - # - if DEBUG_MODE : print '>> GfxNodeConnector::remove' - if self.isNode () : - inputGfxLinks = self.getInputGfxLinks () - outputGfxLinks = self.getOutputGfxLinks () - # - # check if node is connected - # - if len ( inputGfxLinks ) > 0 and len ( outputGfxLinks ) > 0 : - # - # and try to preserve existing links - # - inputLink = inputGfxLinks [0] # it's supposed that only 1 input connecion allowed - srcConnector = inputLink.srcConnector - ( srcNode, srcParam ) = inputLink.link.getSrc () - # - # inputLink and corresponding node link will be removed from nodeNet - # - self.scene().emit ( QtCore.SIGNAL ( 'onGfxLinkRemoved' ), inputLink ) + painter.setPen ( pen ) + painter.setBrush ( self.brush ) + painter.drawEllipse ( self.rect ) + # print ( ">> GfxNodeConnector.paint" ) + # + # getCenterPoint + # + def getCenterPoint ( self ) : return self.mapToScene ( self.rect.center () ) + # + # addLink (GfxLink) + # + def addGfxLink ( self, link ) : self.links.append ( link ) + # + # getFirstGfxLink + # + def getFirstGfxLink ( self ) : return self.links [ 0 ] ##copy.copy( self.links[0] ) + # + # getFirstInputParam + # + def getFirstInputParam ( self ) : return self.getNode ().inputParams [ 0 ] + # + # getInputParam + # + def getInputParam ( self ) : + # + param = self.param + if self.isNode () : + param = self.node.inputParams [ 0 ] + return param + # + # getFirstOutputParam + # + def getFirstOutputParam ( self ) : return self.getNode ().outputParams [ 0 ] + # + # getOutputParam + # + def getOutputParam ( self ) : + # + param = self.param + if self.isNode () : + param = self.node.outputParams [ 0 ] + return param + # + # removeGfxLink + # + def removeGfxLink ( self, gfxLink ) : + # + if DEBUG_MODE : print '>> GfxNodeConnector::removeGfxLink' + if gfxLink in self.links : self.links.remove ( gfxLink ) + # + # removeAllLinks + # + def removeAllLinks ( self ) : + # + if DEBUG_MODE : print '>> GfxNodeConnector::removeAllLinks (count = %d)' % len ( self.links ) + for gfxLink in list ( self.links ) : gfxLink.remove () + # + # removeInputGfxLinks + # + def removeInputGfxLinks ( self ) : + # + for gfxLink in self.getInputGfxLinks () : gfxLink.remove () + # + # + def remove ( self ) : + # + if DEBUG_MODE : print '>> GfxNodeConnector::remove' + if self.isNode () : + inputGfxLinks = self.getInputGfxLinks () + outputGfxLinks = self.getOutputGfxLinks () + # + # check if node is connected + # + if len ( inputGfxLinks ) > 0 and len ( outputGfxLinks ) > 0 : + # + # and try to preserve existing links + # + inputLink = inputGfxLinks [0] # it's supposed that only 1 input connecion allowed + srcConnector = inputLink.srcConnector + ( srcNode, srcParam ) = inputLink.link.getSrc () + # + # inputLink and corresponding node link will be removed from nodeNet + # + self.scene().emit ( QtCore.SIGNAL ( 'onGfxLinkRemoved' ), inputLink ) - for gfxLink in outputGfxLinks : - gfxLink.setSrcConnector ( srcConnector ) - srcNode.attachOutputParamToLink ( srcParam, gfxLink.link ) - gfxLink.link.setSrc ( srcNode, srcParam ) + for gfxLink in outputGfxLinks : + gfxLink.setSrcConnector ( srcConnector ) + srcNode.attachOutputParamToLink ( srcParam, gfxLink.link ) + gfxLink.link.setSrc ( srcNode, srcParam ) - gfxLink.link.dstNode.addChild ( srcNode ) - gfxLink.link.dstNode.removeChild ( self.getNode () ) + gfxLink.link.dstNode.addChild ( srcNode ) + gfxLink.link.dstNode.removeChild ( self.getNode () ) - srcConnector.adjustLinks () - else : - self.removeAllLinks () - self.scene().emit ( QtCore.SIGNAL ( 'onGfxNodeRemoved' ), self ) - else : - self.removeAllLinks () - # - # isInput - # - def isInput ( self ) : return self.param.isInput - # - # isOutput - # - def isOutput ( self ) : return not self.isInput () - # - # isConnectedToInput - # - def isConnectedToInput ( self ) : - # - result = False - if self.isNode () : - #if DEBUG_MODE : print '* isConnectedToInput isNode' - outputGfxLinks = self.getOutputGfxLinks () - for gfxLink in outputGfxLinks : - dstConnector = gfxLink.dstConnector - if dstConnector is not None : - result = dstConnector.isConnectedToInput () - if result is True : - break - else : - result = self.isInput () - return result - # - # isConnectedToOutput - # - def isConnectedToOutput ( self ) : - # - result = False - if self.isNode () : - #if DEBUG_MODE : print '* isConnectedToOutput isNode' - inputGfxLinks = self.getInputGfxLinks () - for gfxLink in inputGfxLinks : - srcConnector = gfxLink.srcConnector - if srcConnector is not None : - result = srcConnector.isConnectedToOutput () - if result is True : - break - else : - result = self.isOutput () - return result - # - # isNode - # - def isNode ( self ) : return ( self.node is not None ) - # - # getNode - # - def getNode ( self ) : return self.getGfxNode ().node - # - # getGfxNode - # - def getGfxNode ( self ) : - # - node = self - if not self.isNode () : - node = self.parentItem () - return node - # - # isLinked - # - def isLinked ( self ) : - # - isLinked = False - if len ( self.links ) > 0 : isLinked = True - return isLinked - # - # hasThisLink - # - def hasThisLink ( self, tstLink ) : - # - hasLink = False - cpyLink = copy.copy ( tstLink ) - cpyLink.dstConnector = self + srcConnector.adjustLinks () + else : + self.removeAllLinks () + self.scene().emit ( QtCore.SIGNAL ( 'onGfxNodeRemoved' ), self ) + else : + self.removeAllLinks () + # + # isInput + # + def isInput ( self ) : return self.param.isInput + # + # isOutput + # + def isOutput ( self ) : return not self.isInput () + # + # isConnectedToInput + # + def isConnectedToInput ( self ) : + # + result = False + if self.isNode () : + #if DEBUG_MODE : print '* isConnectedToInput isNode' + outputGfxLinks = self.getOutputGfxLinks () + for gfxLink in outputGfxLinks : + dstConnector = gfxLink.dstConnector + if dstConnector is not None : + result = dstConnector.isConnectedToInput () + if result is True : + break + else : + result = self.isInput () + return result + # + # isConnectedToOutput + # + def isConnectedToOutput ( self ) : + # + result = False + if self.isNode () : + #if DEBUG_MODE : print '* isConnectedToOutput isNode' + inputGfxLinks = self.getInputGfxLinks () + for gfxLink in inputGfxLinks : + srcConnector = gfxLink.srcConnector + if srcConnector is not None : + result = srcConnector.isConnectedToOutput () + if result is True : + break + else : + result = self.isOutput () + return result + # + # isNode + # + def isNode ( self ) : return ( self.node is not None ) + # + # getNode + # + def getNode ( self ) : return self.getGfxNode ().node + # + # getGfxNode + # + def getGfxNode ( self ) : + # + node = self + if not self.isNode () : + node = self.parentItem () + return node + # + # isLinked + # + def isLinked ( self ) : + # + isLinked = False + if len ( self.links ) > 0 : isLinked = True + return isLinked + # + # hasThisLink + # + def hasThisLink ( self, tstLink ) : + # + hasLink = False + cpyLink = copy.copy ( tstLink ) + cpyLink.dstConnector = self - for link in self.links : - if link.isEqual ( cpyLink ) : - hasLink = True - break - return hasLink - # - # getInputLinks - # - def getInputLinks ( self ) : return self.getNode ().getInputLinks () - # - # getOutputLinks - # - def getOutputLinks ( self ) : return self.getNode ().getOutputLinks () - # - # getInputGfxLinks - # - def getInputGfxLinks ( self ) : - # - inputGfxLinks = [] - for gfxLink in self.links : - if gfxLink.dstConnector == self : - inputGfxLinks.append ( gfxLink ) - return inputGfxLinks - # - # getOutputGfxLinks - # - def getOutputGfxLinks ( self ) : - # - outputGfxLinks = [] - for gfxLink in self.links : - if gfxLink.srcConnector == self : - outputGfxLinks.append ( gfxLink ) - return outputGfxLinks - # - # adjustLinks - # - def adjustLinks ( self ) : - # - for link in self.links : link.adjust () - # - # getScene - # - def getScene ( self ) : - # - scene = self.scene () - if not self.isNode () : - scene = self.parentItem ().scene () - return scene - # - # itemChange - # - def itemChange ( self, change, value ) : - # - if change == QtGui.QGraphicsItem.ItemSelectedHasChanged : - self.isNodeSelected = value.toBool () - #if self.isNodeSelected : - # node = self.parentItem ().node - # if node is not None : - # if DEBUG_MODE : print ">> selected conector for node %s (id = %d)" % ( node.label, node.id ) - elif change == QtGui.QGraphicsItem.ItemPositionHasChanged: - if self.isNode () : - #if DEBUG_MODE : print ">> ItemPositionHasChanged conector for node %s ( %d, %d )" % ( self.node.label, self.x(), self.y() ) - from meShaderEd import getDefaultValue - grid_snap = getDefaultValue ( app_settings, 'WorkArea', 'grid_snap' ) - grid_size = int ( getDefaultValue ( app_settings, 'WorkArea', 'grid_size' ) ) + for link in self.links : + if link.isEqual ( cpyLink ) : + hasLink = True + break + return hasLink + # + # getInputLinks + # + def getInputLinks ( self ) : return self.getNode ().getInputLinks () + # + # getOutputLinks + # + def getOutputLinks ( self ) : return self.getNode ().getOutputLinks () + # + # getInputGfxLinks + # + def getInputGfxLinks ( self ) : + # + inputGfxLinks = [] + for gfxLink in self.links : + if gfxLink.dstConnector == self : + inputGfxLinks.append ( gfxLink ) + return inputGfxLinks + # + # getOutputGfxLinks + # + def getOutputGfxLinks ( self ) : + # + outputGfxLinks = [] + for gfxLink in self.links : + if gfxLink.srcConnector == self : + outputGfxLinks.append ( gfxLink ) + return outputGfxLinks + # + # adjustLinks + # + def adjustLinks ( self ) : + # + for link in self.links : link.adjust () + # + # getScene + # + def getScene ( self ) : + # + scene = self.scene () + if not self.isNode () : + scene = self.parentItem ().scene () + return scene + # + # itemChange + # + def itemChange ( self, change, value ) : + # + if change == QtGui.QGraphicsItem.ItemSelectedHasChanged : + self.isNodeSelected = value.toBool () + #if self.isNodeSelected : + # node = self.parentItem ().node + # if node is not None : + # if DEBUG_MODE : print ">> selected conector for node %s (id = %d)" % ( node.label, node.id ) + elif change == QtGui.QGraphicsItem.ItemPositionHasChanged: + if self.isNode () : + #if DEBUG_MODE : print ">> ItemPositionHasChanged conector for node %s ( %d, %d )" % ( self.node.label, self.x(), self.y() ) + from meShaderEd import getDefaultValue + grid_snap = getDefaultValue ( app_settings, 'WorkArea', 'grid_snap' ) + grid_size = int ( getDefaultValue ( app_settings, 'WorkArea', 'grid_size' ) ) - x = self.x() - y = self.y() - if grid_snap : - #if DEBUG_MODE : print '* snap to grid (size = %d)' % grid_size - x -= ( x % grid_size ) - y -= ( y % grid_size ) - self.setPos ( x, y ) + x = self.x() + y = self.y() + if grid_snap : + #if DEBUG_MODE : print '* snap to grid (size = %d)' % grid_size + x -= ( x % grid_size ) + y -= ( y % grid_size ) + self.setPos ( x, y ) - #if DEBUG_MODE : print '* GfxNode.itemChange = ItemPositionHasChanged (%f, %f)' % ( x, y ) - self.node.offset = ( x, y ) - self.adjustLinks () + #if DEBUG_MODE : print '* GfxNode.itemChange = ItemPositionHasChanged (%f, %f)' % ( x, y ) + self.node.offset = ( x, y ) + self.adjustLinks () - return QtGui.QGraphicsItem.itemChange ( self, change, value ) - # - # hilite - # - def hilite ( self, state ) : - # - self.isNodeSelected = state - self.update() - # - # mousePressEvent - # - def mousePressEvent ( self, event ) : - #print ">> mousePressEvent" - self.hilite( True ) - if event.modifiers () == QtCore.Qt.ControlModifier : - # start new ConnectorNode - self.state = 'traceNodeConnector' - self.getScene ().emit ( QtCore.SIGNAL ( 'startNodeConnector' ), self, event.scenePos () ) - else : - if not self.isNode () : - # start new link - self.state = 'traceNodeLink' - self.getScene ().emit ( QtCore.SIGNAL ( 'startNodeLink' ), self ) + return QtGui.QGraphicsItem.itemChange ( self, change, value ) + # + # hilite + # + def hilite ( self, state ) : + # + self.isNodeSelected = state + self.update() + # + # mousePressEvent + # + def mousePressEvent ( self, event ) : + #print ">> mousePressEvent" + self.hilite( True ) + if event.modifiers () == QtCore.Qt.ControlModifier : + # start new ConnectorNode + self.state = 'traceNodeConnector' + self.getScene ().emit ( QtCore.SIGNAL ( 'startNodeConnector' ), self, event.scenePos () ) + else : + if not self.isNode () : + # start new link + self.state = 'traceNodeLink' + self.getScene ().emit ( QtCore.SIGNAL ( 'startNodeLink' ), self ) - if self.state != 'idle' : - self.grabMouse () - event.accept () - else : - QtGui.QGraphicsItem.mousePressEvent ( self, event ) - # - # mouseMoveEvent - # - def mouseMoveEvent ( self, event ) : - #print ">> mouseMoveEvent at %d %d" % ( event.scenePos().x(), event.scenePos().y() ) - if self.state == 'traceNodeLink' : - self.getScene ().emit ( QtCore.SIGNAL ( 'traceNodeLink' ), self, event.scenePos () ) - elif self.state == 'traceNodeConnector' : - self.getScene ().emit ( QtCore.SIGNAL ( 'traceNodeConnector' ), self, event.scenePos () ) - if self.state != 'idle' : - event.accept() - else : - QtGui.QGraphicsItem.mouseMoveEvent ( self, event ) - # - # mouseReleaseEvent - # - def mouseReleaseEvent ( self, event ) : - #print ">> mouseReleaseEvent" - if self.state == 'traceNodeLink' : - self.getScene ().emit ( QtCore.SIGNAL ( 'endNodeLink' ), self, event.scenePos () ) - elif self.state == 'traceNodeConnector' : - self.getScene ().emit ( QtCore.SIGNAL ( 'endNodeConnector' ), self, event.scenePos () ) - if self.state != 'idle' : - self.hilite ( False ) - self.state = 'idle' - self.ungrabMouse () - event.accept () - else : - QtGui.QGraphicsItem.mouseReleaseEvent ( self, event ) + if self.state != 'idle' : + self.grabMouse () + event.accept () + else : + QtGui.QGraphicsItem.mousePressEvent ( self, event ) + # + # mouseMoveEvent + # + def mouseMoveEvent ( self, event ) : + #print ">> mouseMoveEvent at %d %d" % ( event.scenePos().x(), event.scenePos().y() ) + if self.state == 'traceNodeLink' : + self.getScene ().emit ( QtCore.SIGNAL ( 'traceNodeLink' ), self, event.scenePos () ) + elif self.state == 'traceNodeConnector' : + self.getScene ().emit ( QtCore.SIGNAL ( 'traceNodeConnector' ), self, event.scenePos () ) + if self.state != 'idle' : + event.accept() + else : + QtGui.QGraphicsItem.mouseMoveEvent ( self, event ) + # + # mouseReleaseEvent + # + def mouseReleaseEvent ( self, event ) : + #print ">> mouseReleaseEvent" + if self.state == 'traceNodeLink' : + self.getScene ().emit ( QtCore.SIGNAL ( 'endNodeLink' ), self, event.scenePos () ) + elif self.state == 'traceNodeConnector' : + self.getScene ().emit ( QtCore.SIGNAL ( 'endNodeConnector' ), self, event.scenePos () ) + if self.state != 'idle' : + self.hilite ( False ) + self.state = 'idle' + self.ungrabMouse () + event.accept () + else : + QtGui.QGraphicsItem.mouseReleaseEvent ( self, event ) diff --git a/gfx/gfxNodeLabel.py b/gfx/gfxNodeLabel.py index e871566..c298103 100644 --- a/gfx/gfxNodeLabel.py +++ b/gfx/gfxNodeLabel.py @@ -1,245 +1,251 @@ """ - gfxNodeLabel.py + gfxNodeLabel.py """ -from PyQt4 import Qt, QtCore, QtGui +from core.mePyQt import Qt, QtCore, QtGui from global_vars import app_colors, DEBUG_MODE, GFX_NODE_LABEL_TYPE from meShaderEd import app_settings + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets # # GfxNodeLabel # -class GfxNodeLabel ( QtGui.QGraphicsItem ) : # QGraphicsWidget QGraphicsItem - # - Type = GFX_NODE_LABEL_TYPE - # - # __init__ - # - def __init__ ( self, text, param = None, bgFill = True ) : - # - QtGui.QGraphicsItem.__init__ ( self ) +class GfxNodeLabel ( QtModule.QGraphicsItem ) : # QGraphicsWidget QGraphicsItem + # + Type = GFX_NODE_LABEL_TYPE + # + # __init__ + # + def __init__ ( self, text, param = None, bgFill = True ) : + # + QtModule.QGraphicsItem.__init__ ( self ) - self.text = text - self.param = param - self.help = None + self.text = text + self.param = param + self.help = None - self.normalColor = QtGui.QColor ( 0, 0, 0 ) - self.selectedColor = QtGui.QColor ( 240, 240, 240 ) - self.alternateColor = QtGui.QColor ( 250, 170, 0 ) - self.bgColor = QtGui.QColor ( 140, 140, 140 ) - - self.PenNormal = QtGui.QPen ( self.normalColor ) - self.PenSelected = QtGui.QPen ( self.selectedColor ) - self.PenAlternate = QtGui.QPen ( self.alternateColor ) - self.bgBrush = QtGui.QBrush ( self.bgColor ) - - self.pen = self.PenNormal + self.normalColor = QtGui.QColor ( 0, 0, 0 ) + self.selectedColor = QtGui.QColor ( 240, 240, 240 ) + self.alternateColor = QtGui.QColor ( 250, 170, 0 ) + self.bgColor = QtGui.QColor ( 140, 140, 140 ) + + self.PenNormal = QtGui.QPen ( self.normalColor ) + self.PenSelected = QtGui.QPen ( self.selectedColor ) + self.PenAlternate = QtGui.QPen ( self.alternateColor ) + self.bgBrush = QtGui.QBrush ( self.bgColor ) + + self.pen = self.PenNormal - self.font = QtGui.QFont () - - self.justify = QtCore.Qt.AlignLeft - - self.bgFill = bgFill - self.selected = False - self.alternate = False - self.bold = False - self.italic = False - - self.editable = False - self.processEvents = False - self.setFlag ( QtGui.QGraphicsItem.ItemIsMovable, False ) # QGraphicsItem QGraphicsWidget - self.setFlag ( QtGui.QGraphicsItem.ItemIsSelectable, False ) - - self.rect = QtCore.QRectF () - # - # type - # - def type ( self ) : return GfxNodeLabel.Type - # - # boundingRect - # - def boundingRect ( self ) : return self.rect - # - # setWhatsThis - # - def setWhatsThis ( self, helpString ) : - # - self.help = helpString - #self.setAttribute ( QtCore.Qt.WA_CustomWhatsThis, ( self.help is not None ) ) - #print '** setWhatsThis = %s' % self.testAttribute ( QtCore.Qt.WA_CustomWhatsThis ) - # PyQt4.QtCore.Qt.WhatsThisCursor - # PyQt4.QtCore.Qt.WhatsThisRole - # - # setNormal - # - def setNormal ( self, normal = True ) : - # - if normal : - self.pen = self.PenNormal - self.selected = False - self.alternate = False - # - # setSelected - # - def setSelected ( self, selected = True ) : - # - self.selected = selected - if selected : - self.pen = self.PenSelected - self.alternate = False - else : - self.setNormal () - # - # setAlternate - # - def setAlternate ( self, alternate = True ) : - # - self.alternate = alternate - if alternate : - self.pen = self.PenAlternate - self.selected = False - # - # setNormalColor - # - def setNormalColor ( self, color ) : self.PenNormal = QtGui.QPen ( color ) - # - # setSelectedColor - # - def setSelectedColor ( self, color ) : self.PenSelected = QtGui.QPen ( color ) - # - # setAlternateColor - # - def setAlternateColor ( self, color ) : self.PenAlternate = QtGui.QPen ( color ) - # - # setBgColor - # - def setBgColor ( self, color ) : - self.bgColor = color - self.bgBrush.setColor ( self.bgColor ) - # - # setBold - # - def setBold ( self, bold = True ) : self.font.setBold ( bold ) - # - # setItalic - # - def setItalic ( self, italic = True ) : self.font.setItalic ( italic ) - # - # setText - # - def setText ( self, text ) : self.text = text - # - # getLabelSize - # - def getLabelSize ( self ) : - # - labelFontMetric = QtGui.QFontMetricsF ( self.font ) - lines = self.text.split ( '\n' ) - height = 0 - width = 0 - for line in lines : - height += labelFontMetric.height () + 1 - width = max ( width, labelFontMetric.width ( line ) ) + 1 - return ( width, height ) - # - # paint - # - def paint ( self, painter, option, widget ) : - # - painter.setFont ( self.font ) - if self.bgFill : - painter.fillRect ( self.rect, self.bgBrush ) - painter.setPen ( self.pen ) - painter.drawText ( self.rect, self.justify, self.text ) - # - # setProcessEvents - # - def setProcessEvents ( self, process = True ) : - # - self.processEvents = process - #self.setFlag ( QtGui.QGraphicsItem.ItemIsMovable, process ) - self.setFlag ( QtGui.QGraphicsItem.ItemIsSelectable, process ) - #self.setFlag ( QtGui.QGraphicsWidget.ItemIsSelectable, process ) - # - # mouseDoubleClickEvent - # - """ - def mouseDoubleClickEvent ( self, event ) : - # - if self.processEvents : - print ">> GfxNodeLabel.mouseDoubleClickEvent" - if event.button () == QtCore.Qt.LeftButton : - if event.modifiers () == QtCore.Qt.ControlModifier : - print '* CTRL dblclick' - elif event.modifiers () == QtCore.Qt.AltModifier : - print '* Alt dblclick' - QtGui.QGraphicsItem.mouseDoubleClickEvent ( self, event ) - """ - # - # mousePressEvent - # - def mousePressEvent ( self, event ) : - if self.processEvents : - #print ">> GfxNodeLabel.mousePressEvent" - inWhatsThisMode = QtGui.QWhatsThis.inWhatsThisMode () - #if inWhatsThisMode : - # print '** inWhatsThisMode active' - from gfx.gfxNode import GfxNode - parentNode = self.parentItem () - if isinstance ( parentNode, GfxNode ) : - print '* label "%s" of GfxNode "%s"' % ( self.text, parentNode.node.label ) - button = event.button () - modifiers = event.modifiers () - if button == QtCore.Qt.LeftButton : - if modifiers == QtCore.Qt.ControlModifier : - print '* CTRL+LMB (change in shaderParam)' - self.param.shaderParam = not self.param.shaderParam - parentNode.updateGfxNodeParamLabel ( self.param, self, True ) - return - elif modifiers == QtCore.Qt.AltModifier : - print '* ALT+LMB ( change detail "uniform/varying")' - if self.param.detail == 'varying' : - self.param.detail = 'uniform' - else : - self.param.detail = 'varying' - parentNode.updateGfxNodeParamLabel ( self.param, self, True ) - #return - elif button == QtCore.Qt.RightButton : - if modifiers == QtCore.Qt.ControlModifier : - print '* CTRL+RMB change provider "primitive"/"internal"' - if self.param.provider == 'primitive' : - self.param.provider = '' - else : - self.param.provider = 'primitive' - parentNode.updateGfxNodeParamLabel ( self.param, self, True ) - return - QtCore.QEvent.ignore ( event ) - QtGui.QGraphicsItem.mousePressEvent ( self, event ) - #QtGui.QGraphicsWidget.mousePressEvent ( self, event ) - """ - # - # mouseMoveEvent - # - def mouseMoveEvent ( self, event ) : - # - print ">> GfxNodeLabel.mouseMoveEvent" - inWhatsThisMode = QtGui.QWhatsThis.inWhatsThisMode () - if inWhatsThisMode : - print '** inWhatsThisMode active' - #QtCore.QEvent.ignore ( event ) - QtGui.QGraphicsItem.mouseMoveEvent ( self, event ) - - # - # event - # The type() can be either QEvent::ToolTip or QEvent::WhatsThis. QWhatsThisClickedEvent. - def event ( self, event ) : - # - print ">> GfxNodeLabel.event" - if inWhatsThisMode : - print '** inWhatsThisMode active' - return QtGui.QGraphicsItem.event ( self, event ) - # - # - # - """ \ No newline at end of file + self.font = QtGui.QFont () + + self.justify = QtCore.Qt.AlignLeft + + self.bgFill = bgFill + self.selected = False + self.alternate = False + self.bold = False + self.italic = False + + self.editable = False + self.processEvents = False + self.setFlag ( QtGui.QGraphicsItem.ItemIsMovable, False ) # QGraphicsItem QGraphicsWidget + self.setFlag ( QtGui.QGraphicsItem.ItemIsSelectable, False ) + + self.rect = QtCore.QRectF () + # + # type + # + def type ( self ) : return GfxNodeLabel.Type + # + # boundingRect + # + def boundingRect ( self ) : return self.rect + # + # setWhatsThis + # + def setWhatsThis ( self, helpString ) : + # + self.help = helpString + #self.setAttribute ( QtCore.Qt.WA_CustomWhatsThis, ( self.help is not None ) ) + #print '** setWhatsThis = %s' % self.testAttribute ( QtCore.Qt.WA_CustomWhatsThis ) + # PyQt4.QtCore.Qt.WhatsThisCursor + # PyQt4.QtCore.Qt.WhatsThisRole + # + # setNormal + # + def setNormal ( self, normal = True ) : + # + if normal : + self.pen = self.PenNormal + self.selected = False + self.alternate = False + # + # setSelected + # + def setSelected ( self, selected = True ) : + # + self.selected = selected + if selected : + self.pen = self.PenSelected + self.alternate = False + else : + self.setNormal () + # + # setAlternate + # + def setAlternate ( self, alternate = True ) : + # + self.alternate = alternate + if alternate : + self.pen = self.PenAlternate + self.selected = False + # + # setNormalColor + # + def setNormalColor ( self, color ) : self.PenNormal = QtGui.QPen ( color ) + # + # setSelectedColor + # + def setSelectedColor ( self, color ) : self.PenSelected = QtGui.QPen ( color ) + # + # setAlternateColor + # + def setAlternateColor ( self, color ) : self.PenAlternate = QtGui.QPen ( color ) + # + # setBgColor + # + def setBgColor ( self, color ) : + self.bgColor = color + self.bgBrush.setColor ( self.bgColor ) + # + # setBold + # + def setBold ( self, bold = True ) : self.font.setBold ( bold ) + # + # setItalic + # + def setItalic ( self, italic = True ) : self.font.setItalic ( italic ) + # + # setText + # + def setText ( self, text ) : self.text = text + # + # getLabelSize + # + def getLabelSize ( self ) : + # + labelFontMetric = QtGui.QFontMetricsF ( self.font ) + lines = self.text.split ( '\n' ) + height = 0 + width = 0 + for line in lines : + height += labelFontMetric.height () + 1 + width = max ( width, labelFontMetric.width ( line ) ) + 1 + return ( width, height ) + # + # paint + # + def paint ( self, painter, option, widget ) : + # + painter.setFont ( self.font ) + if self.bgFill : + painter.fillRect ( self.rect, self.bgBrush ) + painter.setPen ( self.pen ) + painter.drawText ( self.rect, self.justify, self.text ) + # + # setProcessEvents + # + def setProcessEvents ( self, process = True ) : + # + self.processEvents = process + #self.setFlag ( QtGui.QGraphicsItem.ItemIsMovable, process ) + self.setFlag ( QtGui.QGraphicsItem.ItemIsSelectable, process ) + #self.setFlag ( QtGui.QGraphicsWidget.ItemIsSelectable, process ) + # + # mouseDoubleClickEvent + # + """ + def mouseDoubleClickEvent ( self, event ) : + # + if self.processEvents : + print ">> GfxNodeLabel.mouseDoubleClickEvent" + if event.button () == QtCore.Qt.LeftButton : + if event.modifiers () == QtCore.Qt.ControlModifier : + print '* CTRL dblclick' + elif event.modifiers () == QtCore.Qt.AltModifier : + print '* Alt dblclick' + QtGui.QGraphicsItem.mouseDoubleClickEvent ( self, event ) + """ + # + # mousePressEvent + # + def mousePressEvent ( self, event ) : + if self.processEvents : + #print ">> GfxNodeLabel.mousePressEvent" + inWhatsThisMode = QtGui.QWhatsThis.inWhatsThisMode () + #if inWhatsThisMode : + # print '** inWhatsThisMode active' + from gfx.gfxNode import GfxNode + parentNode = self.parentItem () + if isinstance ( parentNode, GfxNode ) : + print '* label "%s" of GfxNode "%s"' % ( self.text, parentNode.node.label ) + button = event.button () + modifiers = event.modifiers () + if button == QtCore.Qt.LeftButton : + if modifiers == QtCore.Qt.ControlModifier : + print '* CTRL+LMB (change in shaderParam)' + self.param.shaderParam = not self.param.shaderParam + parentNode.updateGfxNodeParamLabel ( self.param, self, True ) + return + elif modifiers == QtCore.Qt.AltModifier : + print '* ALT+LMB ( change detail "uniform/varying")' + if self.param.detail == 'varying' : + self.param.detail = 'uniform' + else : + self.param.detail = 'varying' + parentNode.updateGfxNodeParamLabel ( self.param, self, True ) + #return + elif button == QtCore.Qt.RightButton : + if modifiers == QtCore.Qt.ControlModifier : + print '* CTRL+RMB change provider "primitive"/"internal"' + if self.param.provider == 'primitive' : + self.param.provider = '' + else : + self.param.provider = 'primitive' + parentNode.updateGfxNodeParamLabel ( self.param, self, True ) + return + QtCore.QEvent.ignore ( event ) + QtGui.QGraphicsItem.mousePressEvent ( self, event ) + #QtGui.QGraphicsWidget.mousePressEvent ( self, event ) + """ + # + # mouseMoveEvent + # + def mouseMoveEvent ( self, event ) : + # + print ">> GfxNodeLabel.mouseMoveEvent" + inWhatsThisMode = QtGui.QWhatsThis.inWhatsThisMode () + if inWhatsThisMode : + print '** inWhatsThisMode active' + #QtCore.QEvent.ignore ( event ) + QtGui.QGraphicsItem.mouseMoveEvent ( self, event ) + + # + # event + # The type() can be either QEvent::ToolTip or QEvent::WhatsThis. QWhatsThisClickedEvent. + def event ( self, event ) : + # + print ">> GfxNodeLabel.event" + if inWhatsThisMode : + print '** inWhatsThisMode active' + return QtGui.QGraphicsItem.event ( self, event ) + # + # + # + """ \ No newline at end of file diff --git a/gfx/gfxNote.py b/gfx/gfxNote.py index 1252d7a..70331d6 100644 --- a/gfx/gfxNote.py +++ b/gfx/gfxNote.py @@ -1,253 +1,258 @@ -#=============================================================================== -# gfxNote.py -# -# -# -#=============================================================================== -import os, sys -from PyQt4 import QtCore, QtGui +""" + + gfxNote.py + +""" +from core.mePyQt import QtCore, QtGui from gfx.gfxNodeLabel import GfxNodeLabel from global_vars import DEBUG_MODE, GFX_NOTE_TYPE from meShaderEd import app_settings + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + # # GfxNote # -class GfxNote ( QtGui.QGraphicsItem ): - # - Type = GFX_NOTE_TYPE - # - # __init__ - # - def __init__ ( self, node ) : - # - QtGui.QGraphicsItem.__init__ ( self ) +class GfxNote ( QtModule.QGraphicsItem ): + # + Type = GFX_NOTE_TYPE + # + # __init__ + # + def __init__ ( self, node ) : + # + QtModule.QGraphicsItem.__init__ ( self ) - self.label_widget = None - self.text_widget = None - - self.headerFont = QtGui.QFont () - self.paramsFont = QtGui.QFont () - - self.x_offset = 10 - self.y_offset = 10 - self.radius = 10 + self.label_widget = None + self.text_widget = None + + self.headerFont = QtGui.QFont () + self.paramsFont = QtGui.QFont () + + self.x_offset = 10 + self.y_offset = 10 + self.radius = 10 - # node parameters - self.showBorder = True - self.justify = QtCore.Qt.AlignLeft # left:center:right - self.text = '' - self.opacity = 0.5 - self.bgColor = QtGui.QColor ( 128, 128, 128 ) - self.textColor = QtGui.QColor ( 0, 0, 0 ) - self.selectedColor = QtGui.QColor ( 250, 250, 250 ) - - self.node = node - - if self.node is not None : - self.updateGfxNode () - ( x, y ) = self.node.offset - self.setPos ( x, y ) - - self.PenBorderNormal = QtGui.QPen( QtGui.QBrush ( self.textColor ), - 1.0, - QtCore.Qt.SolidLine, - QtCore.Qt.RoundCap, - QtCore.Qt.RoundJoin ) + # node parameters + self.showBorder = True + self.justify = QtCore.Qt.AlignLeft # left:center:right + self.text = '' + self.opacity = 0.5 + self.bgColor = QtGui.QColor ( 128, 128, 128 ) + self.textColor = QtGui.QColor ( 0, 0, 0 ) + self.selectedColor = QtGui.QColor ( 250, 250, 250 ) + + self.node = node + + if self.node is not None : + self.updateGfxNode () + ( x, y ) = self.node.offset + self.setPos ( x, y ) + + self.PenBorderNormal = QtGui.QPen( QtGui.QBrush ( self.textColor ), + 1.0, + QtCore.Qt.SolidLine, + QtCore.Qt.RoundCap, + QtCore.Qt.RoundJoin ) - self.PenBorderSelected = QtGui.QPen( QtGui.QBrush ( self.selectedColor ), - 2.0, - QtCore.Qt.SolidLine, - QtCore.Qt.RoundCap, - QtCore.Qt.RoundJoin ) + self.PenBorderSelected = QtGui.QPen( QtGui.QBrush ( self.selectedColor ), + 2.0, + QtCore.Qt.SolidLine, + QtCore.Qt.RoundCap, + QtCore.Qt.RoundJoin ) - self.bgColor.setAlphaF ( self.opacity ) - - self.BrushNodeNormal = QtGui.QBrush ( self.bgColor ) + self.bgColor.setAlphaF ( self.opacity ) + + self.BrushNodeNormal = QtGui.QBrush ( self.bgColor ) - # flag (new from QT 4.6...) - self.setFlag ( QtGui.QGraphicsItem.ItemSendsScenePositionChanges ) - self.setFlag ( QtGui.QGraphicsItem.ItemSendsGeometryChanges ) - #self.setFlag ( QtGui.QGraphicsItem.ItemIsFocusable ) + # flag (new from QT 4.6...) + self.setFlag ( QtGui.QGraphicsItem.ItemSendsScenePositionChanges ) + self.setFlag ( QtGui.QGraphicsItem.ItemSendsGeometryChanges ) + #self.setFlag ( QtGui.QGraphicsItem.ItemIsFocusable ) - # qt graphics stuff - self.setFlag ( QtGui.QGraphicsItem.ItemIsMovable ) - self.setFlag ( QtGui.QGraphicsItem.ItemIsSelectable ) - self.setZValue ( 1 ) - # - # type - # - def type ( self ) : return GfxNote.Type - # - # remove - # - def remove ( self ) : - # - if DEBUG_MODE : print '>> GfxNote remove gfxNode (temp)' - self.scene().emit ( QtCore.SIGNAL ( 'onGfxNodeRemoved' ), self ) - # - # updateNodeLabel - # - def updateNodeLabel ( self ) : - # - self.label_widget.setText ( self.node.label ) - self.setupGeometry () - self.update () - # - # updateGfxNode - # - def updateGfxNode ( self ) : - # remove all children - for item in self.childItems () : self.scene ().removeItem ( item ) - self.setupParameters () - self.setupGeometry () - # - # setupParameters - # - def setupParameters ( self ) : - # - if self.node is not None : - # - # get known node parametres - # - for name in [ 'text_color', 'bg_color', 'opacity', 'border', 'justify', 'text' ] : - param = self.node.getInputParamByName ( name ) - if param is not None : - if name == 'text' : - self.text = param.value - #print '* text = %s' % self.text - elif name == 'border' : - self.showBorder = param.value - #print '* showBorder = %s' % self.showBorder - elif name == 'opacity' : - self.opacity = param.value - #print '* opacity = %f' % self.opacity - elif name == 'bg_color' : - r = param.value [0] - g = param.value [1] - b = param.value [2] - self.bgColor = QtGui.QColor ( r * 255, g * 255, b * 255 ) - elif name == 'text_color' : - r = param.value [0] - g = param.value [1] - b = param.value [2] - self.textColor = QtGui.QColor ( r * 255, g * 255, b * 255 ) - #print '* text_color = %f %f %f' % ( r, g, b ) - elif name == 'justify' : - if param.value == 0 : - self.justify = QtCore.Qt.AlignLeft - elif param.value == 1 : - self.justify = QtCore.Qt.AlignHCenter - elif param.value == 2 : - self.justify = QtCore.Qt.AlignRight - - self.label_widget = GfxNodeLabel ( self.node.label, bgFill = False ) - self.label_widget.setBold () - self.label_widget.setNormalColor ( self.textColor ) - if self.isSelected () : self.label_widget.setSelected () + # qt graphics stuff + self.setFlag ( QtGui.QGraphicsItem.ItemIsMovable ) + self.setFlag ( QtGui.QGraphicsItem.ItemIsSelectable ) + self.setZValue ( 1 ) + # + # type + # + def type ( self ) : return GfxNote.Type + # + # remove + # + def remove ( self ) : + # + if DEBUG_MODE : print '>> GfxNote remove gfxNode (temp)' + self.scene().emit ( QtCore.SIGNAL ( 'onGfxNodeRemoved' ), self ) + # + # updateNodeLabel + # + def updateNodeLabel ( self ) : + # + self.label_widget.setText ( self.node.label ) + self.setupGeometry () + self.update () + # + # updateGfxNode + # + def updateGfxNode ( self ) : + # remove all children + for item in self.childItems () : self.scene ().removeItem ( item ) + self.setupParameters () + self.setupGeometry () + # + # setupParameters + # + def setupParameters ( self ) : + # + if self.node is not None : + # + # get known node parametres + # + for name in [ 'text_color', 'bg_color', 'opacity', 'border', 'justify', 'text' ] : + param = self.node.getInputParamByName ( name ) + if param is not None : + if name == 'text' : + self.text = param.value + #print '* text = %s' % self.text + elif name == 'border' : + self.showBorder = param.value + #print '* showBorder = %s' % self.showBorder + elif name == 'opacity' : + self.opacity = param.value + #print '* opacity = %f' % self.opacity + elif name == 'bg_color' : + r = param.value [0] + g = param.value [1] + b = param.value [2] + self.bgColor = QtGui.QColor ( r * 255, g * 255, b * 255 ) + elif name == 'text_color' : + r = param.value [0] + g = param.value [1] + b = param.value [2] + self.textColor = QtGui.QColor ( r * 255, g * 255, b * 255 ) + #print '* text_color = %f %f %f' % ( r, g, b ) + elif name == 'justify' : + if param.value == 0 : + self.justify = QtCore.Qt.AlignLeft + elif param.value == 1 : + self.justify = QtCore.Qt.AlignHCenter + elif param.value == 2 : + self.justify = QtCore.Qt.AlignRight + + self.label_widget = GfxNodeLabel ( self.node.label, bgFill = False ) + self.label_widget.setBold () + self.label_widget.setNormalColor ( self.textColor ) + if self.isSelected () : self.label_widget.setSelected () - self.text_widget = GfxNodeLabel ( self.text, bgFill = False ) - self.text_widget.setNormalColor ( self.textColor ) - self.text_widget.setNormal ( True ) - self.text_widget.justify = self.justify - - self.label_widget.setParentItem ( self ) - self.text_widget.setParentItem ( self ) - # - # setupGeometry - # - def setupGeometry ( self ) : - # - wi = 80 # minimal node width - hi = 0 - x = self.x_offset - y = self.y_offset - - ( wi_label, hi_label ) = self.label_widget.getLabelSize () - self.label_widget.rect = QtCore.QRectF ( x, y, wi_label, hi_label ) - - ( wi_text, hi_text ) = self.text_widget.getLabelSize () - self.text_widget.rect = QtCore.QRectF ( x, y + hi_label + self.y_offset , wi_text, hi_text ) - - wi_max = max ( wi, wi_label, wi_text ) + 2 * self.x_offset - hi_max = hi_label + hi_text + 3 * self.y_offset - - self.rect = QtCore.QRectF ( 0, 0, wi_max, hi_max ) - # - # boundingRect - # - def boundingRect ( self ) : - #print ( "GfxNode.boundingRect" ) - bound_rect = QtCore.QRectF ( self.rect ) - #bound_rect.adjust( -8, 0, 8, 0 ) - return bound_rect - # - # shape - # - def shape ( self ) : - # - shape = QtGui.QPainterPath () - shape.addRect ( self.boundingRect () ) - #shape += self.header['input'].shape() - #shape += self.header['output'].shape() - return shape - # - # itemChange - # - def itemChange ( self, change, value ) : - # - if change == QtGui.QGraphicsItem.ItemSelectedHasChanged : #ItemSelectedChange: - self.label_widget.setSelected ( value.toBool () ) - if value.toBool () : - items = self.scene ().items () - for i in range ( len ( items ) - 1, -1, -1 ) : - if items [ i ].parentItem() is None : - if items [ i ] != self : - items [ i ].stackBefore ( self ) - #scene.setFocusItem ( self ) - elif change == QtGui.QGraphicsItem.ItemPositionHasChanged: - from meShaderEd import getDefaultValue - grid_snap = getDefaultValue ( app_settings, 'WorkArea', 'grid_snap' ) - grid_size = int ( getDefaultValue ( app_settings, 'WorkArea', 'grid_size' ) ) - x = self.x () - y = self.y () - if grid_snap : - #if DEBUG_MODE : print '* snap to grid (size = %d)' % grid_size - x -= ( x % grid_size ) - y -= ( y % grid_size ) - self.setPos ( x, y ) - #if DEBUG_MODE : print '* GfxNode.itemChange = ItemPositionHasChanged (%f, %f)' % ( x, y ) - self.node.offset = ( x, y ) - #self.adjustLinks () - return QtGui.QGraphicsItem.itemChange ( self, change, value ) - # - # paint - # - def paint ( self, painter, option, widget ) : - # print ( ">> GfxNode.paint" ) - painter.setRenderHint ( QtGui.QPainter.Antialiasing ) - painter.setRenderHint ( QtGui.QPainter.SmoothPixmapTransform ) + self.text_widget = GfxNodeLabel ( self.text, bgFill = False ) + self.text_widget.setNormalColor ( self.textColor ) + self.text_widget.setNormal ( True ) + self.text_widget.justify = self.justify + + self.label_widget.setParentItem ( self ) + self.text_widget.setParentItem ( self ) + # + # setupGeometry + # + def setupGeometry ( self ) : + # + wi = 80 # minimal node width + hi = 0 + x = self.x_offset + y = self.y_offset + + ( wi_label, hi_label ) = self.label_widget.getLabelSize () + self.label_widget.rect = QtCore.QRectF ( x, y, wi_label, hi_label ) + + ( wi_text, hi_text ) = self.text_widget.getLabelSize () + self.text_widget.rect = QtCore.QRectF ( x, y + hi_label + self.y_offset , wi_text, hi_text ) + + wi_max = max ( wi, wi_label, wi_text ) + 2 * self.x_offset + hi_max = hi_label + hi_text + 3 * self.y_offset + + self.rect = QtCore.QRectF ( 0, 0, wi_max, hi_max ) + # + # boundingRect + # + def boundingRect ( self ) : + #print ( "GfxNode.boundingRect" ) + bound_rect = QtCore.QRectF ( self.rect ) + #bound_rect.adjust( -8, 0, 8, 0 ) + return bound_rect + # + # shape + # + def shape ( self ) : + # + shape = QtGui.QPainterPath () + shape.addRect ( self.boundingRect () ) + #shape += self.header['input'].shape() + #shape += self.header['output'].shape() + return shape + # + # itemChange + # + def itemChange ( self, change, value ) : + # + if change == QtGui.QGraphicsItem.ItemSelectedHasChanged : #ItemSelectedChange: + self.label_widget.setSelected ( value.toBool () ) + if value.toBool () : + items = self.scene ().items () + for i in range ( len ( items ) - 1, -1, -1 ) : + if items [ i ].parentItem() is None : + if items [ i ] != self : + items [ i ].stackBefore ( self ) + #scene.setFocusItem ( self ) + elif change == QtGui.QGraphicsItem.ItemPositionHasChanged: + from meShaderEd import getDefaultValue + grid_snap = getDefaultValue ( app_settings, 'WorkArea', 'grid_snap' ) + grid_size = int ( getDefaultValue ( app_settings, 'WorkArea', 'grid_size' ) ) + x = self.x () + y = self.y () + if grid_snap : + #if DEBUG_MODE : print '* snap to grid (size = %d)' % grid_size + x -= ( x % grid_size ) + y -= ( y % grid_size ) + self.setPos ( x, y ) + #if DEBUG_MODE : print '* GfxNode.itemChange = ItemPositionHasChanged (%f, %f)' % ( x, y ) + self.node.offset = ( x, y ) + #self.adjustLinks () + return QtGui.QGraphicsItem.itemChange ( self, change, value ) + # + # paint + # + def paint ( self, painter, option, widget ) : + # print ( ">> GfxNode.paint" ) + painter.setRenderHint ( QtGui.QPainter.Antialiasing ) + painter.setRenderHint ( QtGui.QPainter.SmoothPixmapTransform ) - self.paintFrame ( painter ) - # - # paintFrame - # - def paintFrame ( self, painter ) : - #print ( ">> GfxNode.paintWindowFrame" ) - pen = self.PenBorderNormal - brush = self.BrushNodeNormal - - self.bgColor.setAlphaF ( self.opacity ) - brush.setColor ( self.bgColor ) - - if self.isSelected () : pen = self.PenBorderSelected + self.paintFrame ( painter ) + # + # paintFrame + # + def paintFrame ( self, painter ) : + #print ( ">> GfxNode.paintWindowFrame" ) + pen = self.PenBorderNormal + brush = self.BrushNodeNormal + + self.bgColor.setAlphaF ( self.opacity ) + brush.setColor ( self.bgColor ) + + if self.isSelected () : pen = self.PenBorderSelected - if not self.showBorder : - pen.setStyle ( QtCore.Qt.NoPen ) - else : - pen.setStyle ( QtCore.Qt.SolidLine ) - - painter.setPen ( pen ) - painter.setBrush ( brush ) - painter.drawRoundedRect ( self.rect, self.radius, self.radius, QtCore.Qt.AbsoluteSize ) + if not self.showBorder : + pen.setStyle ( QtCore.Qt.NoPen ) + else : + pen.setStyle ( QtCore.Qt.SolidLine ) + + painter.setPen ( pen ) + painter.setBrush ( brush ) + painter.drawRoundedRect ( self.rect, self.radius, self.radius, QtCore.Qt.AbsoluteSize ) diff --git a/gfx/gfxSwatchNode.py b/gfx/gfxSwatchNode.py index d2cfef4..78e9eae 100644 --- a/gfx/gfxSwatchNode.py +++ b/gfx/gfxSwatchNode.py @@ -1,11 +1,9 @@ -#=============================================================================== -# gfxSwatchNode.py -# -# -# -#=============================================================================== -import os, sys -from PyQt4 import QtCore, QtGui +""" + + gfxSwatchNode.py + +""" +from core.mePyQt import QtCore, QtGui from gfx.gfxNodeLabel import GfxNodeLabel from gfx.gfxNodeConnector import GfxNodeConnector @@ -14,295 +12,302 @@ from global_vars import DEBUG_MODE, GFX_SWATCH_NODE_TYPE from meShaderEd import app_settings import gui.ui_settings as UI + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + # # GfxNodeSwatch # -class GfxSwatchNode ( QtGui.QGraphicsItem ) : - # - Type = GFX_SWATCH_NODE_TYPE - # - # __init__ - # - def __init__ ( self, node = None, swatchSize = UI.SWATCH_SIZE ) : - # - QtGui.QGraphicsItem.__init__ ( self ) - - self.brush = QtGui.QBrush ( QtGui.QColor( 128, 128, 128 ) ) - self.PenBorderNormal = QtGui.QPen( QtGui.QBrush( QtGui.QColor( 0, 0, 0 ) ), - 1.0, - QtCore.Qt.SolidLine, - QtCore.Qt.RoundCap, - QtCore.Qt.RoundJoin ) - - self.PenBorderSelected = QtGui.QPen( QtGui.QBrush( QtGui.QColor( 250, 250, 250 ) ), - 2.0, - QtCore.Qt.SolidLine, - QtCore.Qt.RoundCap, - QtCore.Qt.RoundJoin ) - - self.node = node - self.inputConnectors = [] - - self.isNodeSelected = False - - self.radius = UI.NODE_RADIUS - self.swatchSize = UI.SWATCH_SIZE - - self.shadow_offset = UI.SHADOW_OFFSET - self.shadow_opacity = UI.SHADOW_OPACITY - - shadowColor = QtGui.QColor( 0, 0, 0 ) - shadowColor.setAlphaF ( self.shadow_opacity ) - self.BrushShadow = QtGui.QBrush ( shadowColor ) - self.PenShadow = QtGui.QPen ( shadowColor ) - - self.rect = QtCore.QRectF ( 0, 0, self.swatchSize, self.swatchSize ) - self.pixmap = None - - if self.node is not None : - self.updateGfxNode () - ( x, y ) = self.node.offset - self.setPos ( x, y ) - - # flag (new from QT 4.6...) - self.setFlag ( QtGui.QGraphicsItem.ItemSendsScenePositionChanges ) - self.setFlag ( QtGui.QGraphicsItem.ItemSendsGeometryChanges ) - - # qt graphics stuff - self.setFlag ( QtGui.QGraphicsItem.ItemIsMovable ) - self.setFlag ( QtGui.QGraphicsItem.ItemIsSelectable ) - self.setZValue ( 1 ) - - #self.connectSignals () - # - # connectSignals - # - def connectSignals ( self ) : - # - if self.scene () is not None : - QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'updateSwatch' ), self.updateSwatch ) - # - # disconnectSignals - # - def disconnectSignals ( self ) : - # - if self.scene () is not None : - QtCore.QObject.disconnect ( self.scene (), QtCore.SIGNAL ( 'updateSwatch' ), self.updateSwatch ) - # - # type - # - def type ( self ) : return GfxSwatchNode.Type - # - # remove - # - def remove ( self ) : - # - if DEBUG_MODE : print '>> GfxSwatchNode.remove' - for connect in self.inputConnectors : connect.removeAllLinks () - self.scene().emit ( QtCore.SIGNAL ( 'onGfxNodeRemoved' ), self ) - # - # getInputConnectorByParam - # - def getInputConnectorByParam ( self, param ) : - # - connector = None - for cnt in self.inputConnectors : - if cnt.param == param : - connector = cnt - break - return connector - # - # updateGfxNode - # - def updateGfxNode ( self ) : - # remove all GfxLinks - for connect in self.inputConnectors : connect.removeAllLinks () - # remove all children - for item in self.childItems () : self.scene ().removeItem ( item ) - - #self.rect = QtCore.QRectF ( 0, 0, self.swatchSize, self.swatchSize ) - self.inputConnectors = [] - self.setupSwatchParams () - self.setupConnectors () - self.setupGeometry () - # - # setupSwatchParams - # - def setupSwatchParams ( self ) : - # - # get known node parameters - # - for name in [ 'size' ] : - param = self.node.getInputParamByName ( name ) - if param is not None : - if name == 'size' : - self.swatchSize = int ( param.value ) - # - # setupConnectors - # - def setupConnectors ( self ) : - # - for param in self.node.inputParams : - # ignore attributes - if param.provider != 'attribute' : - connector = GfxNodeConnector ( param, UI.CONNECTOR_RADIUS, node = None ) - self.inputConnectors.append ( connector ) - # - # setupGeometry - # - def setupGeometry ( self ) : - # - self.rect = QtCore.QRectF ( 0, 0, self.swatchSize, self.swatchSize ) - ( x, y ) = ( 0, 0 ) - hi = self.rect.height () / ( len ( self.inputConnectors) + 1 ) - - for connector in self.inputConnectors : - connector.rect.moveTo ( x - connector.radius, y + hi - connector.radius ) - y += hi - connector.setParentItem ( self ) - # - # shadowRect - # - def shadowRect ( self ) : - # - shadowRect = QtCore.QRectF ( self.rect ) - shadowRect.translate ( self.shadow_offset, self.shadow_offset ) - return shadowRect - # - # boundingRect - # - def boundingRect ( self ) : - # - bound_rect = QtCore.QRectF ( self.rect ).united( self.shadowRect () ) - return bound_rect - # - # shape - # - def shape ( self ) : - # - shape = QtGui.QPainterPath () - shape.addRect ( self.boundingRect () ) - return shape - # - # adjustLinks - # - def adjustLinks ( self ) : - # invalidate all the links attached - for connect in self.inputConnectors : connect.adjustLinks () - # - # itemChange - # - def itemChange ( self, change, value ) : - # - if change == QtGui.QGraphicsItem.ItemSelectedHasChanged : #ItemSelectedChange: - if value.toBool () : - items = self.scene ().items () - for i in range ( len ( items ) - 1, -1, -1 ) : - if items [ i ].parentItem() is None : - if items [ i ] != self : - items [ i ].stackBefore ( self ) - elif change == QtGui.QGraphicsItem.ItemPositionHasChanged : - from meShaderEd import getDefaultValue - grid_snap = getDefaultValue ( app_settings, 'WorkArea', 'grid_snap' ) - grid_size = int ( getDefaultValue ( app_settings, 'WorkArea', 'grid_size' ) ) - x = self.x () - y = self.y () - if grid_snap : - x -= ( x % grid_size ) - y -= ( y % grid_size ) - self.setPos ( x, y ) - self.node.offset = ( x, y ) - self.adjustLinks () - return QtGui.QGraphicsItem.itemChange ( self, change, value ) - # - # paint - # - def paint ( self, painter, option, widget ) : - # print ( ">> GfxSwatchNode.paint" ) - painter.setRenderHint ( QtGui.QPainter.Antialiasing ) - painter.setRenderHint ( QtGui.QPainter.SmoothPixmapTransform ) - - self.paintShadow ( painter ) - - pen = self.PenBorderNormal - - if self.isSelected () : pen = self.PenBorderSelected - - painter.setPen ( QtCore.Qt.NoPen ) - painter.setBrush ( self.brush ) # QtCore.Qt.NoBrush - painter.drawRoundedRect ( self.rect, self.radius, self.radius, QtCore.Qt.AbsoluteSize ) - - if self.pixmap is not None : - if not self.pixmap.isNull () : - #painter.drawPixmap ( 0, 0, self.pixmap.scaled ( self.swatchSize, self.swatchSize, transformMode = QtCore.Qt.SmoothTransformation ) ) - imageBrush = QtGui.QBrush ( self.pixmap.scaled ( self.swatchSize, self.swatchSize, transformMode = QtCore.Qt.SmoothTransformation ) ) - painter.setBrush ( imageBrush ) - - painter.setPen ( pen ) - painter.drawRoundedRect ( self.rect, self.radius, self.radius, QtCore.Qt.AbsoluteSize ) - # - # paintShadow - # - def paintShadow ( self, painter ) : - # - painter.setBrush ( self.BrushShadow ) - painter.setPen ( self.PenShadow ) - painter.drawRoundedRect ( self.shadowRect (), self.radius, self.radius, QtCore.Qt.AbsoluteSize ) - # - # mouseDoubleClickEvent - # - def mouseDoubleClickEvent ( self, event ) : - # - print ">> GfxSwatchNode.mouseDoubleClickEvent" - #QtCore.QObject.emit ( self.toGraphicsObject (), QtCore.SIGNAL ( 'updateSwatch' ) ) - #self.connectSignals () - #self.scene ().emit ( QtCore.SIGNAL ( 'updateSwatch' ) ) - self.updateSwatch () - #QtGui.QGraphicsView.mouseDoubleClickEvent ( self.scene (), event ) - event.accept() - # - # updateSwatch - # - def updateSwatch ( self ) : - # - print ">> GfxSwatchNode.updateSwatch" - - #self.disconnectSignals () - - self.pixmap = None - self.imageName = self.node.computeNode () - - if self.imageName != '' : - print ">> GfxSwatchNode.setImage name = %s" % self.imageName - - imageReader = QtGui.QImageReader ( self.imageName ) - self.pixmap = QtGui.QPixmap () - if imageReader.canRead () : - image = imageReader.read () - if not self.pixmap.convertFromImage ( image ) : - print "!! QPixmap can't convert %s" % self.imageName - else: - print "!! QImageReader can't read %s..." % self.imageName - # print imageReader.supportedImageFormats () - print "!! Lets try PIL module ..." - import Image - image = Image.open ( self.imageName ) - # image.verify() - - import os - from global_vars import app_global_vars - - tmpname = app_global_vars [ 'TempPath' ] + '/' + os.path.basename ( self.imageName + '.png' ) - print "** Save %s ..." % tmpname - image.save ( tmpname ) - - self.pixmap = QtGui.QPixmap ( tmpname ) - - self.update () - #self.scene ().setSceneRect ( self.rect () ) - #self.scene ().update ( self.mapRectToParent ( self.rect () ) ) # self.mapRectToScene - - #self.connectSignals () +class GfxSwatchNode ( QtModule.QGraphicsItem ) : + # + Type = GFX_SWATCH_NODE_TYPE + # + # __init__ + # + def __init__ ( self, node = None, swatchSize = UI.SWATCH_SIZE ) : + # + QtModule.QGraphicsItem.__init__ ( self ) + + self.brush = QtGui.QBrush ( QtGui.QColor( 128, 128, 128 ) ) + self.PenBorderNormal = QtGui.QPen( QtGui.QBrush( QtGui.QColor( 0, 0, 0 ) ), + 1.0, + QtCore.Qt.SolidLine, + QtCore.Qt.RoundCap, + QtCore.Qt.RoundJoin ) + + self.PenBorderSelected = QtGui.QPen( QtGui.QBrush( QtGui.QColor( 250, 250, 250 ) ), + 2.0, + QtCore.Qt.SolidLine, + QtCore.Qt.RoundCap, + QtCore.Qt.RoundJoin ) + + self.node = node + self.inputConnectors = [] + + self.isNodeSelected = False + + self.radius = UI.NODE_RADIUS + self.swatchSize = UI.SWATCH_SIZE + + self.shadow_offset = UI.SHADOW_OFFSET + self.shadow_opacity = UI.SHADOW_OPACITY + + shadowColor = QtGui.QColor( 0, 0, 0 ) + shadowColor.setAlphaF ( self.shadow_opacity ) + self.BrushShadow = QtGui.QBrush ( shadowColor ) + self.PenShadow = QtGui.QPen ( shadowColor ) + + self.rect = QtCore.QRectF ( 0, 0, self.swatchSize, self.swatchSize ) + self.pixmap = None + + if self.node is not None : + self.updateGfxNode () + ( x, y ) = self.node.offset + self.setPos ( x, y ) + + # flag (new from QT 4.6...) + self.setFlag ( QtGui.QGraphicsItem.ItemSendsScenePositionChanges ) + self.setFlag ( QtGui.QGraphicsItem.ItemSendsGeometryChanges ) + + # qt graphics stuff + self.setFlag ( QtGui.QGraphicsItem.ItemIsMovable ) + self.setFlag ( QtGui.QGraphicsItem.ItemIsSelectable ) + self.setZValue ( 1 ) + + #self.connectSignals () + # + # connectSignals + # + def connectSignals ( self ) : + # + if self.scene () is not None : + QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'updateSwatch' ), self.updateSwatch ) + # + # disconnectSignals + # + def disconnectSignals ( self ) : + # + if self.scene () is not None : + QtCore.QObject.disconnect ( self.scene (), QtCore.SIGNAL ( 'updateSwatch' ), self.updateSwatch ) + # + # type + # + def type ( self ) : return GfxSwatchNode.Type + # + # remove + # + def remove ( self ) : + # + if DEBUG_MODE : print '>> GfxSwatchNode.remove' + for connect in self.inputConnectors : connect.removeAllLinks () + self.scene().emit ( QtCore.SIGNAL ( 'onGfxNodeRemoved' ), self ) + # + # getInputConnectorByParam + # + def getInputConnectorByParam ( self, param ) : + # + connector = None + for cnt in self.inputConnectors : + if cnt.param == param : + connector = cnt + break + return connector + # + # updateGfxNode + # + def updateGfxNode ( self ) : + # remove all GfxLinks + for connect in self.inputConnectors : connect.removeAllLinks () + # remove all children + for item in self.childItems () : self.scene ().removeItem ( item ) + + #self.rect = QtCore.QRectF ( 0, 0, self.swatchSize, self.swatchSize ) + self.inputConnectors = [] + self.setupSwatchParams () + self.setupConnectors () + self.setupGeometry () + # + # setupSwatchParams + # + def setupSwatchParams ( self ) : + # + # get known node parameters + # + for name in [ 'size' ] : + param = self.node.getInputParamByName ( name ) + if param is not None : + if name == 'size' : + self.swatchSize = int ( param.value ) + # + # setupConnectors + # + def setupConnectors ( self ) : + # + for param in self.node.inputParams : + # ignore attributes + if param.provider != 'attribute' : + connector = GfxNodeConnector ( param, UI.CONNECTOR_RADIUS, node = None ) + self.inputConnectors.append ( connector ) + # + # setupGeometry + # + def setupGeometry ( self ) : + # + self.rect = QtCore.QRectF ( 0, 0, self.swatchSize, self.swatchSize ) + ( x, y ) = ( 0, 0 ) + hi = self.rect.height () / ( len ( self.inputConnectors) + 1 ) + + for connector in self.inputConnectors : + connector.rect.moveTo ( x - connector.radius, y + hi - connector.radius ) + y += hi + connector.setParentItem ( self ) + # + # shadowRect + # + def shadowRect ( self ) : + # + shadowRect = QtCore.QRectF ( self.rect ) + shadowRect.translate ( self.shadow_offset, self.shadow_offset ) + return shadowRect + # + # boundingRect + # + def boundingRect ( self ) : + # + bound_rect = QtCore.QRectF ( self.rect ).united( self.shadowRect () ) + return bound_rect + # + # shape + # + def shape ( self ) : + # + shape = QtGui.QPainterPath () + shape.addRect ( self.boundingRect () ) + return shape + # + # adjustLinks + # + def adjustLinks ( self ) : + # invalidate all the links attached + for connect in self.inputConnectors : connect.adjustLinks () + # + # itemChange + # + def itemChange ( self, change, value ) : + # + if change == QtGui.QGraphicsItem.ItemSelectedHasChanged : #ItemSelectedChange: + if value.toBool () : + items = self.scene ().items () + for i in range ( len ( items ) - 1, -1, -1 ) : + if items [ i ].parentItem() is None : + if items [ i ] != self : + items [ i ].stackBefore ( self ) + elif change == QtGui.QGraphicsItem.ItemPositionHasChanged : + from meShaderEd import getDefaultValue + grid_snap = getDefaultValue ( app_settings, 'WorkArea', 'grid_snap' ) + grid_size = int ( getDefaultValue ( app_settings, 'WorkArea', 'grid_size' ) ) + x = self.x () + y = self.y () + if grid_snap : + x -= ( x % grid_size ) + y -= ( y % grid_size ) + self.setPos ( x, y ) + self.node.offset = ( x, y ) + self.adjustLinks () + return QtGui.QGraphicsItem.itemChange ( self, change, value ) + # + # paint + # + def paint ( self, painter, option, widget ) : + # print ( ">> GfxSwatchNode.paint" ) + painter.setRenderHint ( QtGui.QPainter.Antialiasing ) + painter.setRenderHint ( QtGui.QPainter.SmoothPixmapTransform ) + + self.paintShadow ( painter ) + + pen = self.PenBorderNormal + + if self.isSelected () : pen = self.PenBorderSelected + + painter.setPen ( QtCore.Qt.NoPen ) + painter.setBrush ( self.brush ) # QtCore.Qt.NoBrush + painter.drawRoundedRect ( self.rect, self.radius, self.radius, QtCore.Qt.AbsoluteSize ) + + if self.pixmap is not None : + if not self.pixmap.isNull () : + #painter.drawPixmap ( 0, 0, self.pixmap.scaled ( self.swatchSize, self.swatchSize, transformMode = QtCore.Qt.SmoothTransformation ) ) + imageBrush = QtGui.QBrush ( self.pixmap.scaled ( self.swatchSize, self.swatchSize, transformMode = QtCore.Qt.SmoothTransformation ) ) + painter.setBrush ( imageBrush ) + + painter.setPen ( pen ) + painter.drawRoundedRect ( self.rect, self.radius, self.radius, QtCore.Qt.AbsoluteSize ) + # + # paintShadow + # + def paintShadow ( self, painter ) : + # + painter.setBrush ( self.BrushShadow ) + painter.setPen ( self.PenShadow ) + painter.drawRoundedRect ( self.shadowRect (), self.radius, self.radius, QtCore.Qt.AbsoluteSize ) + # + # mouseDoubleClickEvent + # + def mouseDoubleClickEvent ( self, event ) : + # + print ">> GfxSwatchNode.mouseDoubleClickEvent" + #QtCore.QObject.emit ( self.toGraphicsObject (), QtCore.SIGNAL ( 'updateSwatch' ) ) + #self.connectSignals () + #self.scene ().emit ( QtCore.SIGNAL ( 'updateSwatch' ) ) + self.updateSwatch () + #QtGui.QGraphicsView.mouseDoubleClickEvent ( self.scene (), event ) + event.accept() + # + # updateSwatch + # + def updateSwatch ( self ) : + # + print ">> GfxSwatchNode.updateSwatch" + + #self.disconnectSignals () + + self.pixmap = None + self.imageName = self.node.computeNode () + + if self.imageName != '' : + print ">> GfxSwatchNode.setImage name = %s" % self.imageName + + imageReader = QtGui.QImageReader ( self.imageName ) + self.pixmap = QtGui.QPixmap () + if imageReader.canRead () : + image = imageReader.read () + if not self.pixmap.convertFromImage ( image ) : + print "!! QPixmap can't convert %s" % self.imageName + else: + print "!! QImageReader can't read %s..." % self.imageName + # print imageReader.supportedImageFormats () + print "!! Lets try PIL module ..." + import Image + image = Image.open ( self.imageName ) + # image.verify() + + import os + from global_vars import app_global_vars + + tmpname = app_global_vars [ 'TempPath' ] + '/' + os.path.basename ( self.imageName + '.png' ) + print "** Save %s ..." % tmpname + image.save ( tmpname ) + + self.pixmap = QtGui.QPixmap ( tmpname ) + + self.update () + #self.scene ().setSceneRect ( self.rect () ) + #self.scene ().update ( self.mapRectToParent ( self.rect () ) ) # self.mapRectToScene + + #self.connectSignals () diff --git a/gfx/imageView.py b/gfx/imageView.py index 9771f80..185cf78 100644 --- a/gfx/imageView.py +++ b/gfx/imageView.py @@ -1,180 +1,186 @@ -#=============================================================================== -# imageView.py -# -# -# -#=============================================================================== -import os, sys -from PyQt4 import QtCore, QtGui +""" + + imageView.py + +""" +from core.mePyQt import QtCore, QtGui + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + # # ImageView # -class ImageView ( QtGui.QGraphicsView ) : - # - # __init__ - # - def __init__ ( self, parent ) : - # - QtGui.QGraphicsView.__init__ ( self, parent ) - - self.state = 'idle' - self.panStartPos = None - - self.pixmap = None - - # set scene - scene = QtGui.QGraphicsScene ( self ) - - scene.setSceneRect ( 0, 0, 256, 256 ) - #scene.setItemIndexMethod ( QtGui.QGraphicsScene.NoIndex ) - self.setScene ( scene ) - - # qt graphics stuff - #self.setCacheMode ( QtGui.QGraphicsView.CacheBackground ) - self.setRenderHint ( QtGui.QPainter.Antialiasing ) - - self.setTransformationAnchor ( QtGui.QGraphicsView.AnchorUnderMouse ) - self.setResizeAnchor ( QtGui.QGraphicsView.AnchorViewCenter ) - self.setDragMode ( QtGui.QGraphicsView.RubberBandDrag ) - - self.setMouseTracking ( False ) - - self.BgBrush = QtGui.QBrush ( QtGui.QColor ( 128, 128, 128 ) ) - # - # keyPressEvent - # - def keyPressEvent ( self, event ) : - # - print ">> ImageView.keyPressEvent" - QtGui.QGraphicsView.keyPressEvent ( self, event) - # - # wheelEvent - # - def wheelEvent ( self, event ) : - # - #print ">> ImageView.wheelEvent" - # QtGui.QGraphicsView.wheelEvent( self, event) - scale = -1.0 - if 'linux' in sys.platform: scale = 1.0 - import math - scaleFactor = math.pow( 2.0, scale * event.delta() / 600.0 ) - factor = self.matrix ().scale ( scaleFactor, scaleFactor ).mapRect ( QtCore.QRectF ( -1, -1, 2, 2 ) ).width () - if factor < 0.07 or factor > 100: return - self.scale ( scaleFactor, scaleFactor ) - # - # mousePressEvent - # - def mousePressEvent ( self, event ) : - # - #print ">> ImageView.mousePressEvent" - if ( event.button () == QtCore.Qt.MidButton or - ( event.button () == QtCore.Qt.LeftButton and event.modifiers () == QtCore.Qt.ShiftModifier ) ) : - if self.state == 'idle': - self.panStartPos = self.mapToScene ( event.pos () ) - self.state = 'pan' - return - QtGui.QGraphicsView.mousePressEvent ( self, event ) - # - # mouseDoubleClickEvent - # - def mouseDoubleClickEvent ( self, event ) : - # - #print ">> ImageView.mouseDoubleClickEvent" - self.emit ( QtCore.SIGNAL ( 'mouseDoubleClickEvent' ) ) - QtGui.QGraphicsView.mouseDoubleClickEvent ( self, event ) - # - # mouseMoveEvent - # - def mouseMoveEvent ( self, event ) : - # - #print ">> ImageView.mouseMoveEvent" - if self.state == 'pan' : - panCurrentPos = self.mapToScene ( event.pos () ) - panDeltaPos = panCurrentPos - self.panStartPos - # update view matrix - self.setInteractive ( False ) - self.translate ( panDeltaPos.x (), panDeltaPos.y () ) - self.setInteractive ( True ) - else : - QtGui.QGraphicsView.mouseMoveEvent ( self, event ) - # - # mouseReleaseEvent - # - def mouseReleaseEvent ( self, event ): - # - #print ">> ImageView.mouseReleaseEvent" - if self.state == 'pan' : - self.state = 'idle' - self.panStartPos = None - QtGui.QGraphicsView.mouseReleaseEvent ( self, event ) - # - # viewportEvent - # - def viewportEvent ( self, event ) : - #case QEvent::TouchBegin: - # case QEvent::TouchUpdate: - # case QEvent::TouchEnd: - if event.type () == QtCore.QEvent.TouchBegin : - print ">> ImageView: QEvent.TouchBegin" - return QtGui.QGraphicsView.viewportEvent ( self, event ) - # - # setImage - # - def setImage ( self, imageName ) : - # - self.pixmap = QtGui.QPixmap () - wi = 256 - hi = 256 +class ImageView ( QtModule.QGraphicsView ) : + # + # __init__ + # + def __init__ ( self, parent ) : + # + QtModule.QGraphicsView.__init__ ( self, parent ) + + self.state = 'idle' + self.panStartPos = None + + self.pixmap = None + + # set scene + scene = QtModule.QGraphicsScene ( self ) + + scene.setSceneRect ( 0, 0, 256, 256 ) + #scene.setItemIndexMethod ( QtGui.QGraphicsScene.NoIndex ) + self.setScene ( scene ) + + # qt graphics stuff + #self.setCacheMode ( QtGui.QGraphicsView.CacheBackground ) + self.setRenderHint ( QtGui.QPainter.Antialiasing ) + + self.setTransformationAnchor ( QtModule.QGraphicsView.AnchorUnderMouse ) + self.setResizeAnchor ( QtModule.QGraphicsView.AnchorViewCenter ) + self.setDragMode ( QtModule.QGraphicsView.RubberBandDrag ) + + self.setMouseTracking ( False ) + + self.BgBrush = QtGui.QBrush ( QtGui.QColor ( 128, 128, 128 ) ) + # + # keyPressEvent + # + def keyPressEvent ( self, event ) : + # + print ">> ImageView.keyPressEvent" + QtGui.QGraphicsView.keyPressEvent ( self, event) + # + # wheelEvent + # + def wheelEvent ( self, event ) : + # + #print ">> ImageView.wheelEvent" + # QtGui.QGraphicsView.wheelEvent( self, event) + import sys + scale = -1.0 + if 'linux' in sys.platform: scale = 1.0 + import math + scaleFactor = math.pow( 2.0, scale * event.delta() / 600.0 ) + factor = self.matrix ().scale ( scaleFactor, scaleFactor ).mapRect ( QtCore.QRectF ( -1, -1, 2, 2 ) ).width () + if factor < 0.07 or factor > 100: return + self.scale ( scaleFactor, scaleFactor ) + # + # mousePressEvent + # + def mousePressEvent ( self, event ) : + # + #print ">> ImageView.mousePressEvent" + if ( event.button () == QtCore.Qt.MidButton or + ( event.button () == QtCore.Qt.LeftButton and event.modifiers () == QtCore.Qt.ShiftModifier ) ) : + if self.state == 'idle': + self.panStartPos = self.mapToScene ( event.pos () ) + self.state = 'pan' + return + QtModule.QGraphicsView.mousePressEvent ( self, event ) + # + # mouseDoubleClickEvent + # + def mouseDoubleClickEvent ( self, event ) : + # + #print ">> ImageView.mouseDoubleClickEvent" + self.emit ( QtCore.SIGNAL ( 'mouseDoubleClickEvent' ) ) + QtModule.QGraphicsView.mouseDoubleClickEvent ( self, event ) + # + # mouseMoveEvent + # + def mouseMoveEvent ( self, event ) : + # + #print ">> ImageView.mouseMoveEvent" + if self.state == 'pan' : + panCurrentPos = self.mapToScene ( event.pos () ) + panDeltaPos = panCurrentPos - self.panStartPos + # update view matrix + self.setInteractive ( False ) + self.translate ( panDeltaPos.x (), panDeltaPos.y () ) + self.setInteractive ( True ) + else : + QtModule.QGraphicsView.mouseMoveEvent ( self, event ) + # + # mouseReleaseEvent + # + def mouseReleaseEvent ( self, event ): + # + #print ">> ImageView.mouseReleaseEvent" + if self.state == 'pan' : + self.state = 'idle' + self.panStartPos = None + QtModule.QGraphicsView.mouseReleaseEvent ( self, event ) + # + # viewportEvent + # + def viewportEvent ( self, event ) : + #case QEvent::TouchBegin: + # case QEvent::TouchUpdate: + # case QEvent::TouchEnd: + if event.type () == QtCore.QEvent.TouchBegin : + print ">> ImageView: QEvent.TouchBegin" + return QtModule.QGraphicsView.viewportEvent ( self, event ) + # + # setImage + # + def setImage ( self, imageName ) : + # + self.pixmap = QtGui.QPixmap () + wi = 256 + hi = 256 - if imageName != '' : - print ">> ImageView.setImage name = %s" % imageName + if imageName != '' : + print ">> ImageView.setImage name = %s" % imageName - imageReader = QtGui.QImageReader ( imageName ) + imageReader = QtGui.QImageReader ( imageName ) - if imageReader.canRead () : - image = imageReader.read () - if not self.pixmap.convertFromImage ( image ) : - print "!! QPixmap can't convert %s" % imageName - else: - print "!! QImageReader can't read %s..." % imageName - # print imageReader.supportedImageFormats () - print "!! Lets try PIL module ..." - import Image - image = Image.open ( imageName ) - # image.verify() + if imageReader.canRead () : + image = imageReader.read () + if not self.pixmap.convertFromImage ( image ) : + print "!! QPixmap can't convert %s" % imageName + else: + print "!! QImageReader can't read %s..." % imageName + # print imageReader.supportedImageFormats () + print "!! Lets try PIL module ..." + import Image + image = Image.open ( imageName ) + # image.verify() - import os - from global_vars import app_global_vars + import os + from global_vars import app_global_vars - tmpname = app_global_vars [ 'TempPath' ] + '/' + os.path.basename ( imageName + '.png' ) - print "** Save %s ..." % tmpname - image.save ( tmpname ) + tmpname = app_global_vars [ 'TempPath' ] + '/' + os.path.basename ( imageName + '.png' ) + print "** Save %s ..." % tmpname + image.save ( tmpname ) - self.pixmap = QtGui.QPixmap ( tmpname ) + self.pixmap = QtGui.QPixmap ( tmpname ) - if not self.pixmap.isNull (): - wi = self.pixmap.width () - hi = self.pixmap.height () - else: - print "!! ImageView: isNull()" + if not self.pixmap.isNull (): + wi = self.pixmap.width () + hi = self.pixmap.height () + else: + print "!! ImageView: isNull()" - self.scene ().setSceneRect ( 0, 0, wi, hi ) - self.scene ().update () - # - # drawBackground - # - def drawBackground ( self, painter, rect ) : - # - painter.setRenderHint ( QtGui.QPainter.Antialiasing ) - painter.setRenderHint ( QtGui.QPainter.SmoothPixmapTransform ) - painter.fillRect ( rect, self.BgBrush ) - if self.pixmap is not None: - painter.drawPixmap ( 0, 0, self.pixmap ) - # - # resetZoom - # - def resetZoom ( self ) : - # - self.setInteractive ( False ) - self.resetTransform () - self.setInteractive ( True ) + self.scene ().setSceneRect ( 0, 0, wi, hi ) + self.scene ().update () + # + # drawBackground + # + def drawBackground ( self, painter, rect ) : + # + painter.setRenderHint ( QtGui.QPainter.Antialiasing ) + painter.setRenderHint ( QtGui.QPainter.SmoothPixmapTransform ) + painter.fillRect ( rect, self.BgBrush ) + if self.pixmap is not None: + painter.drawPixmap ( 0, 0, self.pixmap ) + # + # resetZoom + # + def resetZoom ( self ) : + # + self.setInteractive ( False ) + self.resetTransform () + self.setInteractive ( True ) diff --git a/global_vars.py b/global_vars.py index 43346c5..9b5b8a6 100644 --- a/global_vars.py +++ b/global_vars.py @@ -1,7 +1,7 @@ # # global_vars.py # -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui app_global_vars = { 'TempPath':'' ,'RootPath':'' diff --git a/gui/MainWindow.py b/gui/MainWindow.py index 125f872..7a3e656 100644 --- a/gui/MainWindow.py +++ b/gui/MainWindow.py @@ -1,11 +1,9 @@ """ - MainWindow.py + MainWindow.py """ -import os, sys - -from PyQt4 import QtCore, QtGui, QtXml +from core.mePyQt import QtCore, QtGui, QtXml #from PyQt4.QtGui import QWhatsThis from global_vars import app_global_vars, DEBUG_MODE, VALID_RIB_NODE_TYPES, VALID_RSL_NODE_TYPES, VALID_RSL_SHADER_TYPES from core.meCommon import * @@ -31,890 +29,909 @@ from meShaderEd import getDefaultValue from ui_MainWindow import Ui_MainWindow + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + # # Create a class for our main window # -class MainWindow ( QtGui.QMainWindow ) : - # - # __init__ - # - def __init__ ( self ) : - # - QtGui.QMainWindow.__init__ ( self ) - - self.ui = Ui_MainWindow () - self.ui.setupUi ( self ) - # - # setup WhatsThis help action - # - self.ui.actionHelpMode = QtGui.QWhatsThis.createAction ( ) - self.ui.actionHelpMode.setToolTip ( 'Enter "WhatsThis" help mode' ) - self.ui.menuHelp.addAction ( self.ui.actionHelpMode ) - self.ui.toolBar.addSeparator() - self.ui.toolBar.addAction ( self.ui.actionHelpMode ) - QtCore.QObject.connect ( self.ui.actionHelpMode, QtCore.SIGNAL ( 'toggled(bool)' ), self.onHelpMode ) - - self.clipboard = QtGui.QApplication.clipboard () - - self.recentProjects = app_settings.value ( 'RecentProjects' ).toStringList () - self.recentNetworks = app_settings.value ( 'RecentNetworks' ).toStringList () - - self.addRecentProject ( app_global_vars [ 'ProjectPath' ] ) - - self.setupMenuBar () - self.setupPanels () - - self.activeNodeList = None - self.workArea = None # current work area - self.onNew () # create new document - - grid_enabled = getDefaultValue ( app_settings, 'WorkArea', 'grid_enabled' ) - grid_snap = getDefaultValue ( app_settings, 'WorkArea', 'grid_snap' ) - grid_size = int ( getDefaultValue ( app_settings, 'WorkArea', 'grid_size' ) ) - reverse_flow = getDefaultValue ( app_settings, 'WorkArea', 'reverse_flow' ) - straight_links = getDefaultValue ( app_settings, 'WorkArea', 'straight_links' ) - - #self.ui.workArea.gridSize = grid_size - #self.ui.workArea.gridSnap = grid_snap - self.workArea.drawGrid = grid_enabled - #self.ui.workArea.reverseFlow = reverse_flow - #self.ui.workArea.straightLinks = straight_links - - self.ui.actionShowGrid.setChecked ( grid_enabled ) - self.ui.actionSnapGrid.setChecked ( grid_snap ) - self.ui.actionReverseFlow.setChecked ( reverse_flow ) - self.ui.actionStraightLinks.setChecked ( straight_links ) - - self.ui.nodeList_ctl.setLibrary ( app_global_vars [ 'NodesPath' ] ) - self.ui.project_ctl.setLibrary ( app_global_vars [ 'ProjectNetworks' ] ) - - #self.ui.dockNodes.setWindowTitle ( 'Library: %s' % app_global_vars [ 'NodesPath' ] ) - #self.ui.dockProject.setWindowTitle ( 'Project: %s' % app_global_vars [ 'ProjectNetworks' ] ) - - QtCore.QObject.connect ( self.ui.nodeList_ctl.ui.nodeList, QtCore.SIGNAL ( 'setActiveNodeList' ), self.setActiveNodeList ) - QtCore.QObject.connect ( self.ui.project_ctl.ui.nodeList, QtCore.SIGNAL ( 'setActiveNodeList' ), self.setActiveNodeList ) - - QtCore.QObject.connect ( self.ui.tabs, QtCore.SIGNAL ( 'currentChanged(int)' ), self.onTabSelected ) - QtCore.QObject.connect ( self.ui.tabs, QtCore.SIGNAL ( 'tabCloseRequested(int)' ), self.onTabCloseRequested ) - - QtCore.QObject.connect ( self.ui.nodeParam_ctl, QtCore.SIGNAL ( 'nodeLabelChanged' ), self.onNodeLabelChanged ) - QtCore.QObject.connect ( self.ui.nodeParam_ctl, QtCore.SIGNAL ( 'nodeParamChanged' ), self.onNodeParamChanged ) - - self.setupActions () - self.setupWindowTitle () - # - # connectWorkAreaSignals - # - def connectWorkAreaSignals ( self ) : - # - if self.workArea != None : - if self.activeNodeList != None : - QtCore.QObject.connect ( self.activeNodeList, QtCore.SIGNAL ( 'addNode' ), self.workArea.insertNodeNet ) - QtCore.QObject.connect ( self.workArea, QtCore.SIGNAL ( 'selectNodes' ), self.onSelectGfxNodes ) - QtCore.QObject.connect ( self.workArea, QtCore.SIGNAL ( 'nodeConnectionChanged' ), self.onGfxNodeParamChanged ) - QtCore.QObject.connect ( self.workArea, QtCore.SIGNAL ( 'gfxNodeAdded' ), self.onAddGfxNode ) - QtCore.QObject.connect ( self.workArea, QtCore.SIGNAL ( 'gfxNodeRemoved' ), self.onRemoveGfxNode ) - #QtCore.QObject.connect ( self.workArea, QtCore.SIGNAL ( 'editGfxNode' ), self.editGfxNode ) - QtCore.QObject.connect ( self.workArea.scene(), QtCore.SIGNAL ( 'nodeUpdated' ), self.updateNodeParamView ) - QtCore.QObject.connect ( self.workArea.scene(), QtCore.SIGNAL ( 'gfxNodeParamChanged' ), self.onGfxNodeParamChanged ) - # - # disconnectWorkAreaSignals - # - def disconnectWorkAreaSignals ( self ) : - # - if self.workArea != None : - if self.activeNodeList != None : - QtCore.QObject.disconnect ( self.activeNodeList, QtCore.SIGNAL ( 'addNode' ), self.workArea.insertNodeNet ) - QtCore.QObject.disconnect ( self.workArea, QtCore.SIGNAL ( 'selectNodes' ), self.onSelectGfxNodes ) - QtCore.QObject.disconnect ( self.workArea, QtCore.SIGNAL ( 'nodeConnectionChanged' ), self.onGfxNodeParamChanged ) - QtCore.QObject.disconnect ( self.workArea, QtCore.SIGNAL ( 'gfxNodeAdded' ), self.onAddGfxNode ) - QtCore.QObject.disconnect ( self.workArea, QtCore.SIGNAL ( 'gfxNodeRemoved' ), self.onRemoveGfxNode ) - #QtCore.QObject.disconnect ( self.workArea, QtCore.SIGNAL ( 'editGfxNode' ), self.editGfxNode ) - QtCore.QObject.disconnect ( self.workArea.scene(), QtCore.SIGNAL ( 'nodeUpdated' ), self.updateNodeParamView ) - QtCore.QObject.disconnect ( self.workArea.scene(), QtCore.SIGNAL ( 'gfxNodeParamChanged' ), self.onGfxNodeParamChanged ) - # - # setupWindowTitle - # - def setupWindowTitle ( self ) : - # - self.setWindowTitle ( 'meShaderEd %s (%s) %s' % ( app_global_vars [ 'version' ], app_global_vars [ 'RendererPreset' ].getCurrentPresetName (), app_global_vars [ 'ProjectPath' ] ) ) - self.ui.dockNodes.setToolTip ( app_global_vars [ 'NodesPath' ] ) - self.ui.dockNodes.setStatusTip ( app_global_vars [ 'NodesPath' ] ) - self.ui.dockProject.setToolTip ( app_global_vars [ 'ProjectNetworks' ] ) - self.ui.dockProject.setStatusTip ( app_global_vars [ 'ProjectNetworks' ] ) - # - # setupMenuBar - # - def setupMenuBar ( self ) : - # override font for menu from Designer's settings to system default - font = QtGui.QFont () - if ( sys.platform == 'win32' ): - # Runing on windows, override font sizes from Designer to default - font.setPointSize ( 8 ) - elif ( sys.platform == 'darwin' ): - font.setPointSize ( 10 ) - - self.ui.menubar.setFont ( font ) - self.ui.menuFile.setFont ( font ) - self.ui.menuEdit.setFont ( font ) - self.ui.menuCommand.setFont ( font ) - self.ui.menuWindow.setFont ( font ) - self.ui.menuHelp.setFont ( font ) - - self.buildRecentProjectsMenu () - self.buildRecentNetworksMenu () - # - # buildRecentProjectsMenu - # - def buildRecentProjectsMenu ( self ) : - #self.recentProjects = app_settings.value ( 'RecentProjects' ).toStringList () - #self.recentNetworks = app_settings.value ( 'RecentNetworks' ).toStringList () - self.ui.menuRecent_Projects.clear () - - if len ( self.recentProjects ) : - icon = QtGui.QIcon.fromTheme ( 'folder', QtGui.QIcon ( ':/file_icons/resources/open.png' ) ) - # QtGui.QIcon ( ':/file_icons/resources/recentFile.png' ) 'folder' - for i, fname in enumerate ( self.recentProjects ) : - # QtCore.QFileInfo ( fname ).fileName () - action = QtGui.QAction ( icon, '&%d %s' % ( i + 1, fname ), self ) - action.setData ( QtCore.QVariant ( fname ) ) - self.connect ( action, QtCore.SIGNAL ( 'triggered()' ), self.onOpenRecentProject ) - self.ui.menuRecent_Projects.addAction ( action ) - # - # buildRecentNetworksMenu - # - def buildRecentNetworksMenu ( self ) : - # - self.ui.menuRecent_Networks.clear () - - if len ( self.recentNetworks ) : - for i, fname in enumerate ( self.recentNetworks ) : - icon = QtGui.QIcon.fromTheme ( 'document-new', QtGui.QIcon ( ':/file_icons/resources/new.png' ) ) - # QtCore.QFileInfo ( fname ).fileName () - action = QtGui.QAction ( icon, '&%d %s' % ( i + 1, fname ), self ) - action.setData ( QtCore.QVariant ( fname ) ) - self.connect ( action, QtCore.SIGNAL ( 'triggered()' ), self.onOpenRecentNetwork ) - self.ui.menuRecent_Networks.addAction ( action ) - # - # setupPanels - # - def setupPanels ( self ) : - # - self.tabifyDockWidget ( self.ui.dockNodes, self.ui.dockProject ) - - #self.tabifyDockWidget ( self.ui.dockPreview, self.ui.dockGeom ) - self.tabifyDockWidget ( self.ui.dockParam, self.ui.dockSwatch ) - - # temporary hide unused panels - #self.removeDockWidget ( self.ui.dockGeom ) - #self.removeDockWidget ( self.ui.dockSwatch ) - #self.ui.dockGeom.hide () - self.ui.dockSwatch.hide () - - self.ui.dockNodes.raise_ () - self.ui.dockPreview.raise_ () - self.ui.dockParam.raise_ () - - #self.addDockWidget ( QtCore.Qt.DockWidgetArea ( 2 ), self.ui.dockParam ) - #self.ui.dockParam.show () - # - # addRecentProject - # - def addRecentProject ( self, project ) : - # - if project is not None : - recent_projects_max = getDefaultValue ( app_settings, '', 'recent_projects_max' ) - - if not self.recentProjects.contains ( project ) : - self.recentProjects.prepend ( QtCore.QString ( project ) ) - - while self.recentProjects.count () > recent_projects_max : - self.recentProjects.takeLast () - - recentProjects = QtCore.QVariant ( self.recentProjects ) if self.recentProjects else QtCore.QVariant () - app_settings.setValue ( 'RecentProjects', recentProjects ) - # - # addRecentNetwork - # - def addRecentNetwork ( self, network ) : - # - if network is not None : - recent_networks_max = getDefaultValue ( app_settings, '', 'recent_networks_max' ) - - if not self.recentNetworks.contains ( network ) : - self.recentNetworks.prepend ( QtCore.QString ( network ) ) - - while self.recentNetworks.count () > recent_networks_max : - self.recentNetworks.takeLast () - - recentNetworks = QtCore.QVariant ( self.recentNetworks ) if self.recentNetworks else QtCore.QVariant () - app_settings.setValue ( 'RecentNetworks', recentNetworks ) - # - # setupActions - # - def setupActions ( self ) : - # - #if DEBUG_MODE : print '>> MainWindow.setupActions' - numNodes = 0 - numSelectedNodes = 0 - numSelectedLinks = 0 - selectedNodeType = None - if self.workArea is not None : - numNodes = len ( self.workArea.getAllGfxNodes () ) - numSelectedNodes = len ( self.workArea.selectedNodes ) - numSelectedLinks = len ( self.workArea.selectedLinks ) - if numSelectedNodes == 1 : - selectedNodeType = self.getSelectedNode ().node.type - enableForPaste = False - - if self.clipboard.ownsClipboard () or (sys.platform == 'darwin'): - if DEBUG_MODE : print '** self.clipboard.ownsClipboard' - data = self.clipboard.mimeData () - if data is not None : - if data.hasText () : - enableForPaste = True - - self.ui.actionExportShader.setEnabled ( selectedNodeType in VALID_RSL_SHADER_TYPES ) - self.ui.actionViewComputedCode.setEnabled ( selectedNodeType in VALID_RSL_NODE_TYPES or selectedNodeType in VALID_RIB_NODE_TYPES ) - self.ui.actionSaveSelected.setEnabled ( numSelectedNodes > 0 ) - self.ui.actionSelectAll.setEnabled ( numNodes > 0 ) - self.ui.actionSelectAbove.setEnabled ( numSelectedNodes == 1 ) - self.ui.actionSelectBelow.setEnabled ( numSelectedNodes == 1 ) - self.ui.actionDuplicate.setEnabled ( numSelectedNodes > 0 ) - self.ui.actionDuplicateWithLinks.setEnabled ( numSelectedNodes > 0 ) - self.ui.actionDelete.setEnabled ( ( numSelectedNodes > 0 ) or ( numSelectedLinks > 0 ) ) - self.ui.actionCut.setEnabled ( numSelectedNodes > 0 ) - self.ui.actionCopy.setEnabled ( numSelectedNodes > 0 ) - self.ui.actionPaste.setEnabled ( enableForPaste ) - self.ui.actionFitAll.setEnabled ( numNodes > 0 ) - self.ui.actionFitSelected.setEnabled ( numSelectedNodes > 0 ) - # - # onProjectSetup - # - def onProjectSetup ( self ) : - # - if DEBUG_MODE : print ">> MainWindow.onProjectSetup" - projectSetupDlg = ProjectSetup ( app_settings ) - projectSetupDlg.exec_() - self.ui.project_ctl.setLibrary ( app_global_vars [ 'ProjectNetworks' ] ) - createDefaultProject ( app_settings ) - self.setupWindowTitle () - self.addRecentProject ( app_global_vars [ 'ProjectPath' ] ) - self.buildRecentProjectsMenu () - # - # onSettingsSetup - # - def onSettingsSetup ( self ) : - # - if DEBUG_MODE : print '>> MainWindow.onSettingsSetup' - settingsSetupDlg = SettingsSetup ( app_settings ) - settingsSetupDlg.exec_() - self.ui.nodeList_ctl.setLibrary ( app_global_vars [ 'NodesPath' ] ) - # - # onRenderSettings - # - def onRenderSettings ( self ) : - # - if DEBUG_MODE : print ( '>> MainWindow::onRenderSettings' ) - import copy - self.RendererPreset = copy.deepcopy ( app_global_vars [ 'RendererPreset' ] ) - if DEBUG_MODE : print ( ':: self.RendererPreset.getCurrentPresetName = %s' % self.RendererPreset.getCurrentPresetName () ) - renderSettingsDlg = meRendererSetup ( self.RendererPreset ) - QtCore.QObject.connect ( renderSettingsDlg, QtCore.SIGNAL ( 'presetChanged' ), self.onRenderPresetChanged ) - QtCore.QObject.connect ( renderSettingsDlg, QtCore.SIGNAL ( 'savePreset' ), self.onRenderPresetSave ) - renderSettingsDlg.exec_ () - # - # onRenderPresetChanged - # - def onRenderPresetChanged ( self ) : - # - if DEBUG_MODE : print ( '>> MainWindow::onRenderPresetChanged preset = %s' % self.RendererPreset.getCurrentPresetName () ) - app_settings.setValue ( 'defRenderer', self.RendererPreset.getCurrentPresetName () ) +class MainWindow ( QtModule.QMainWindow ) : + # + # __init__ + # + def __init__ ( self ) : + # + QtModule.QMainWindow.__init__ ( self ) + + self.ui = Ui_MainWindow () + self.ui.setupUi ( self ) + # + # setup WhatsThis help action + # + self.ui.actionHelpMode = QtModule.QWhatsThis.createAction ( ) + self.ui.actionHelpMode.setToolTip ( 'Enter "WhatsThis" help mode' ) + self.ui.menuHelp.addAction ( self.ui.actionHelpMode ) + self.ui.toolBar.addSeparator() + self.ui.toolBar.addAction ( self.ui.actionHelpMode ) + + self.clipboard = QtModule.QApplication.clipboard () + + self.recentProjects = getSettingsStrValue ( app_settings, 'RecentProjects' ) + self.recentNetworks = getSettingsStrValue ( app_settings, 'RecentNetworks' ) + + self.addRecentProject ( app_global_vars [ 'ProjectPath' ] ) + + self.setupMenuBar () + self.setupPanels () + + self.activeNodeList = None + self.workArea = None # current work area + self.onNew () # create new document + + grid_enabled = getDefaultValue ( app_settings, 'WorkArea', 'grid_enabled' ) + grid_snap = getDefaultValue ( app_settings, 'WorkArea', 'grid_snap' ) + grid_size = int ( getDefaultValue ( app_settings, 'WorkArea', 'grid_size' ) ) + reverse_flow = getDefaultValue ( app_settings, 'WorkArea', 'reverse_flow' ) + straight_links = getDefaultValue ( app_settings, 'WorkArea', 'straight_links' ) + + #self.ui.workArea.gridSize = grid_size + #self.ui.workArea.gridSnap = grid_snap + self.workArea.drawGrid = grid_enabled + #self.ui.workArea.reverseFlow = reverse_flow + #self.ui.workArea.straightLinks = straight_links + + self.ui.actionShowGrid.setChecked ( grid_enabled ) + self.ui.actionSnapGrid.setChecked ( grid_snap ) + self.ui.actionReverseFlow.setChecked ( reverse_flow ) + self.ui.actionStraightLinks.setChecked ( straight_links ) + + self.ui.nodeList_ctl.setLibrary ( app_global_vars [ 'NodesPath' ] ) + self.ui.project_ctl.setLibrary ( app_global_vars [ 'ProjectNetworks' ] ) + + #self.ui.dockNodes.setWindowTitle ( 'Library: %s' % app_global_vars [ 'NodesPath' ] ) + #self.ui.dockProject.setWindowTitle ( 'Project: %s' % app_global_vars [ 'ProjectNetworks' ] ) + + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.connect ( self.ui.actionHelpMode, QtCore.SIGNAL ( 'toggled(bool)' ), self.onHelpMode ) + QtCore.QObject.connect ( self.ui.nodeList_ctl.ui.nodeList, QtCore.SIGNAL ( 'setActiveNodeList' ), self.setActiveNodeList ) + QtCore.QObject.connect ( self.ui.project_ctl.ui.nodeList, QtCore.SIGNAL ( 'setActiveNodeList' ), self.setActiveNodeList ) + + QtCore.QObject.connect ( self.ui.tabs, QtCore.SIGNAL ( 'currentChanged(int)' ), self.onTabSelected ) + QtCore.QObject.connect ( self.ui.tabs, QtCore.SIGNAL ( 'tabCloseRequested(int)' ), self.onTabCloseRequested ) + + QtCore.QObject.connect ( self.ui.nodeParam_ctl, QtCore.SIGNAL ( 'nodeLabelChanged' ), self.onNodeLabelChanged ) + QtCore.QObject.connect ( self.ui.nodeParam_ctl, QtCore.SIGNAL ( 'nodeParamChanged' ), self.onNodeParamChanged ) + + self.setupActions () + self.setupWindowTitle () + # + # connectWorkAreaSignals + # + def connectWorkAreaSignals ( self ) : + # + if QtCore.QT_VERSION < 50000 : + if self.workArea != None : + if self.activeNodeList != None : + QtCore.QObject.connect ( self.activeNodeList, QtCore.SIGNAL ( 'addNode' ), self.workArea.insertNodeNet ) + QtCore.QObject.connect ( self.workArea, QtCore.SIGNAL ( 'selectNodes' ), self.onSelectGfxNodes ) + QtCore.QObject.connect ( self.workArea, QtCore.SIGNAL ( 'nodeConnectionChanged' ), self.onGfxNodeParamChanged ) + QtCore.QObject.connect ( self.workArea, QtCore.SIGNAL ( 'gfxNodeAdded' ), self.onAddGfxNode ) + QtCore.QObject.connect ( self.workArea, QtCore.SIGNAL ( 'gfxNodeRemoved' ), self.onRemoveGfxNode ) + #QtCore.QObject.connect ( self.workArea, QtCore.SIGNAL ( 'editGfxNode' ), self.editGfxNode ) + QtCore.QObject.connect ( self.workArea.scene(), QtCore.SIGNAL ( 'nodeUpdated' ), self.updateNodeParamView ) + QtCore.QObject.connect ( self.workArea.scene(), QtCore.SIGNAL ( 'gfxNodeParamChanged' ), self.onGfxNodeParamChanged ) + # + # disconnectWorkAreaSignals + # + def disconnectWorkAreaSignals ( self ) : + # + if QtCore.QT_VERSION < 50000 : + if self.workArea != None : + if self.activeNodeList != None : + QtCore.QObject.disconnect ( self.activeNodeList, QtCore.SIGNAL ( 'addNode' ), self.workArea.insertNodeNet ) + QtCore.QObject.disconnect ( self.workArea, QtCore.SIGNAL ( 'selectNodes' ), self.onSelectGfxNodes ) + QtCore.QObject.disconnect ( self.workArea, QtCore.SIGNAL ( 'nodeConnectionChanged' ), self.onGfxNodeParamChanged ) + QtCore.QObject.disconnect ( self.workArea, QtCore.SIGNAL ( 'gfxNodeAdded' ), self.onAddGfxNode ) + QtCore.QObject.disconnect ( self.workArea, QtCore.SIGNAL ( 'gfxNodeRemoved' ), self.onRemoveGfxNode ) + #QtCore.QObject.disconnect ( self.workArea, QtCore.SIGNAL ( 'editGfxNode' ), self.editGfxNode ) + QtCore.QObject.disconnect ( self.workArea.scene(), QtCore.SIGNAL ( 'nodeUpdated' ), self.updateNodeParamView ) + QtCore.QObject.disconnect ( self.workArea.scene(), QtCore.SIGNAL ( 'gfxNodeParamChanged' ), self.onGfxNodeParamChanged ) + # + # setupWindowTitle + # + def setupWindowTitle ( self ) : + # + self.setWindowTitle ( 'meShaderEd %s (%s) %s' % ( app_global_vars [ 'version' ], app_global_vars [ 'RendererPreset' ].getCurrentPresetName (), app_global_vars [ 'ProjectPath' ] ) ) + self.ui.dockNodes.setToolTip ( app_global_vars [ 'NodesPath' ] ) + self.ui.dockNodes.setStatusTip ( app_global_vars [ 'NodesPath' ] ) + self.ui.dockProject.setToolTip ( app_global_vars [ 'ProjectNetworks' ] ) + self.ui.dockProject.setStatusTip ( app_global_vars [ 'ProjectNetworks' ] ) + # + # setupMenuBar + # + def setupMenuBar ( self ) : + # override font for menu from Designer's settings to system default + import sys + font = QtGui.QFont () + if ( sys.platform == 'win32' ): + # Runing on windows, override font sizes from Designer to default + font.setPointSize ( 8 ) + elif ( sys.platform == 'darwin' ): + font.setPointSize ( 10 ) + + self.ui.menubar.setFont ( font ) + self.ui.menuFile.setFont ( font ) + self.ui.menuEdit.setFont ( font ) + self.ui.menuCommand.setFont ( font ) + self.ui.menuWindow.setFont ( font ) + self.ui.menuHelp.setFont ( font ) + + self.buildRecentProjectsMenu () + self.buildRecentNetworksMenu () + # + # buildRecentProjectsMenu + # + def buildRecentProjectsMenu ( self ) : + #self.recentProjects = app_settings.value ( 'RecentProjects' ).toStringList () + #self.recentNetworks = app_settings.value ( 'RecentNetworks' ).toStringList () + self.ui.menuRecent_Projects.clear () + + if QtCore.QT_VERSION < 50000 : + if len ( self.recentProjects ) : + icon = QtGui.QIcon.fromTheme ( 'folder', QtGui.QIcon ( ':/file_icons/resources/open.png' ) ) + # QtGui.QIcon ( ':/file_icons/resources/recentFile.png' ) 'folder' + for i, fname in enumerate ( self.recentProjects ) : + # QtCore.QFileInfo ( fname ).fileName () + action = QtModule.QAction ( icon, '&%d %s' % ( i + 1, fname ), self ) + action.setData ( QtCore.QVariant ( fname ) ) + self.connect ( action, QtCore.SIGNAL ( 'triggered()' ), self.onOpenRecentProject ) + self.ui.menuRecent_Projects.addAction ( action ) + # + # buildRecentNetworksMenu + # + def buildRecentNetworksMenu ( self ) : + # + self.ui.menuRecent_Networks.clear () + + if QtCore.QT_VERSION < 50000 : + if len ( self.recentNetworks ) : + for i, fname in enumerate ( self.recentNetworks ) : + icon = QtGui.QIcon.fromTheme ( 'document-new', QtGui.QIcon ( ':/file_icons/resources/new.png' ) ) + # QtCore.QFileInfo ( fname ).fileName () + action = QtModule.QAction ( icon, '&%d %s' % ( i + 1, fname ), self ) + action.setData ( QtCore.QVariant ( fname ) ) + self.connect ( action, QtCore.SIGNAL ( 'triggered()' ), self.onOpenRecentNetwork ) + self.ui.menuRecent_Networks.addAction ( action ) + # + # setupPanels + # + def setupPanels ( self ) : + # + self.tabifyDockWidget ( self.ui.dockNodes, self.ui.dockProject ) + + #self.tabifyDockWidget ( self.ui.dockPreview, self.ui.dockGeom ) + self.tabifyDockWidget ( self.ui.dockParam, self.ui.dockSwatch ) + + # temporary hide unused panels + #self.removeDockWidget ( self.ui.dockGeom ) + #self.removeDockWidget ( self.ui.dockSwatch ) + #self.ui.dockGeom.hide () + self.ui.dockSwatch.hide () + + self.ui.dockNodes.raise_ () + self.ui.dockPreview.raise_ () + self.ui.dockParam.raise_ () + + #self.addDockWidget ( QtCore.Qt.DockWidgetArea ( 2 ), self.ui.dockParam ) + #self.ui.dockParam.show () + # + # addRecentProject + # + def addRecentProject ( self, project ) : + # + if project is not None : + if QtCore.QT_VERSION < 50000 : + recent_projects_max = getDefaultValue ( app_settings, '', 'recent_projects_max' ) + + if project not in self.recentProjects : + self.recentProjects.prepend ( QtCore.QString ( project ) ) + + while self.recentProjects.count () > recent_projects_max : + self.recentProjects.takeLast () + + recentProjects = QtCore.QVariant ( self.recentProjects ) if self.recentProjects else QtCore.QVariant () + app_settings.setValue ( 'RecentProjects', recentProjects ) + # + # addRecentNetwork + # + def addRecentNetwork ( self, network ) : + # + if network is not None : + if QtCore.QT_VERSION < 50000 : + recent_networks_max = getDefaultValue ( app_settings, '', 'recent_networks_max' ) + + if network not in self.recentNetworks : + self.recentNetworks.prepend ( QtCore.QString ( network ) ) + + while self.recentNetworks.count () > recent_networks_max : + self.recentNetworks.takeLast () + + recentNetworks = QtCore.QVariant ( self.recentNetworks ) if self.recentNetworks else QtCore.QVariant () + app_settings.setValue ( 'RecentNetworks', recentNetworks ) + # + # setupActions + # + def setupActions ( self ) : + # + #if DEBUG_MODE : print '>> MainWindow.setupActions' + import sys + numNodes = 0 + numSelectedNodes = 0 + numSelectedLinks = 0 + selectedNodeType = None + if self.workArea is not None : + numNodes = len ( self.workArea.getAllGfxNodes () ) + numSelectedNodes = len ( self.workArea.selectedNodes ) + numSelectedLinks = len ( self.workArea.selectedLinks ) + if numSelectedNodes == 1 : + selectedNodeType = self.getSelectedNode ().node.type + enableForPaste = False + + if self.clipboard.ownsClipboard () or (sys.platform == 'darwin'): + if DEBUG_MODE : print '** self.clipboard.ownsClipboard' + data = self.clipboard.mimeData () + if data is not None : + if data.hasText () : + enableForPaste = True + + self.ui.actionExportShader.setEnabled ( selectedNodeType in VALID_RSL_SHADER_TYPES ) + self.ui.actionViewComputedCode.setEnabled ( selectedNodeType in VALID_RSL_NODE_TYPES or selectedNodeType in VALID_RIB_NODE_TYPES ) + self.ui.actionSaveSelected.setEnabled ( numSelectedNodes > 0 ) + self.ui.actionSelectAll.setEnabled ( numNodes > 0 ) + self.ui.actionSelectAbove.setEnabled ( numSelectedNodes == 1 ) + self.ui.actionSelectBelow.setEnabled ( numSelectedNodes == 1 ) + self.ui.actionDuplicate.setEnabled ( numSelectedNodes > 0 ) + self.ui.actionDuplicateWithLinks.setEnabled ( numSelectedNodes > 0 ) + self.ui.actionDelete.setEnabled ( ( numSelectedNodes > 0 ) or ( numSelectedLinks > 0 ) ) + self.ui.actionCut.setEnabled ( numSelectedNodes > 0 ) + self.ui.actionCopy.setEnabled ( numSelectedNodes > 0 ) + self.ui.actionPaste.setEnabled ( enableForPaste ) + self.ui.actionFitAll.setEnabled ( numNodes > 0 ) + self.ui.actionFitSelected.setEnabled ( numSelectedNodes > 0 ) + # + # onProjectSetup + # + def onProjectSetup ( self ) : + # + if DEBUG_MODE : print ">> MainWindow.onProjectSetup" + projectSetupDlg = ProjectSetup ( app_settings ) + projectSetupDlg.exec_() + self.ui.project_ctl.setLibrary ( app_global_vars [ 'ProjectNetworks' ] ) + createDefaultProject ( app_settings ) + self.setupWindowTitle () + self.addRecentProject ( app_global_vars [ 'ProjectPath' ] ) + self.buildRecentProjectsMenu () + # + # onSettingsSetup + # + def onSettingsSetup ( self ) : + # + if DEBUG_MODE : print '>> MainWindow.onSettingsSetup' + settingsSetupDlg = SettingsSetup ( app_settings ) + settingsSetupDlg.exec_() + self.ui.nodeList_ctl.setLibrary ( app_global_vars [ 'NodesPath' ] ) + # + # onRenderSettings + # + def onRenderSettings ( self ) : + # + if DEBUG_MODE : print ( '>> MainWindow::onRenderSettings' ) + import copy + self.RendererPreset = copy.deepcopy ( app_global_vars [ 'RendererPreset' ] ) + if DEBUG_MODE : print ( ':: self.RendererPreset.getCurrentPresetName = %s' % self.RendererPreset.getCurrentPresetName () ) + renderSettingsDlg = meRendererSetup ( self.RendererPreset ) + QtCore.QObject.connect ( renderSettingsDlg, QtCore.SIGNAL ( 'presetChanged' ), self.onRenderPresetChanged ) + QtCore.QObject.connect ( renderSettingsDlg, QtCore.SIGNAL ( 'savePreset' ), self.onRenderPresetSave ) + renderSettingsDlg.exec_ () + # + # onRenderPresetChanged + # + def onRenderPresetChanged ( self ) : + # + if DEBUG_MODE : print ( '>> MainWindow::onRenderPresetChanged preset = %s' % self.RendererPreset.getCurrentPresetName () ) + app_settings.setValue ( 'defRenderer', self.RendererPreset.getCurrentPresetName () ) - app_global_vars [ 'RendererName' ] = self.RendererPreset.currentPreset.RendererName - app_global_vars [ 'RendererFlags' ] = self.RendererPreset.currentPreset.RendererFlags - app_global_vars [ 'ShaderCompiler' ] = self.RendererPreset.currentPreset.ShaderCompiler - app_global_vars [ 'ShaderDefines' ] = self.RendererPreset.currentPreset.ShaderDefines - app_global_vars [ 'ShaderInfo' ] = self.RendererPreset.currentPreset.ShaderInfo - app_global_vars [ 'SLO' ] = self.RendererPreset.currentPreset.ShaderExt - app_global_vars [ 'TextureMake' ] = self.RendererPreset.currentPreset.TextureMake - app_global_vars [ 'TextureInfo' ] = self.RendererPreset.currentPreset.TextureInfo - app_global_vars [ 'TextureViewer' ] = self.RendererPreset.currentPreset.TextureViewer - app_global_vars [ 'TEX' ] = self.RendererPreset.currentPreset.TextureExt - app_global_vars [ 'RendererPreset' ] = self.RendererPreset - self.setupWindowTitle () - # - # onRenderPresetSave - # - def onRenderPresetSave ( self ) : - # - if DEBUG_MODE : print ( '>> MainWindow::onRenderPresetSave preset = %s' % self.RendererPreset.getCurrentPresetName () ) - self.RendererPreset.saveSettings () - app_global_vars [ 'RendererPreset' ] = self.RendererPreset - # - # onShowGrid - # - def onShowGrid ( self, check ) : - # - self.workArea.drawGrid = bool ( check ) - app_settings.beginGroup ( 'WorkArea' ) - app_settings.setValue ( 'grid_enabled', bool ( check ) ) - app_settings.endGroup () - - self.workArea.resetCachedContent () - #self.ui.workArea.update() - # - # onSnapGrid - # - def onSnapGrid ( self, check ) : - # - self.workArea.gridSnap = bool ( check ) - app_settings.beginGroup ( 'WorkArea' ) - app_settings.setValue ( 'grid_snap', bool ( check ) ) - app_settings.endGroup () - # - # onReverseFlow - # - def onReverseFlow ( self, check ) : - # - self.workArea.reverseFlow = bool ( check ) - app_settings.beginGroup ( 'WorkArea' ) - app_settings.setValue ( 'reverse_flow', bool ( check ) ) - app_settings.endGroup () - - #self.ui.workArea.resetCachedContent() - # - # onStraightLinks - # - def onStraightLinks ( self, check ) : - # - self.workArea.straightLinks = bool ( check ) - app_settings.beginGroup ( 'WorkArea' ) - app_settings.setValue ( 'straight_links', bool ( check ) ) - app_settings.endGroup () - self.workArea.resetCachedContent () - self.workArea.adjustLinks () - # - # setActiveNodeList - # - def setActiveNodeList ( self, nodeList ) : - # - if DEBUG_MODE : print '>> MainWindow.setActiveNodeList' - if self.activeNodeList != None : - QtCore.QObject.disconnect ( self.activeNodeList, QtCore.SIGNAL ( 'addNode' ), self.workArea.insertNodeNet ) - self.activeNodeList = nodeList - QtCore.QObject.connect ( self.activeNodeList, QtCore.SIGNAL ( 'addNode' ), self.workArea.insertNodeNet ) - # - # onGetNode - # - # Called by WorkArea after drag&drop event - # Here we choose selected nodeList panel (Library or Project) - # for processing node request - # - def onGetNode ( self, itemFilename, pos ) : - # - if self.activeNodeList != None : self.activeNodeList.onGetNode ( itemFilename, pos ) - # - # onAddGfxNode - # - def onAddGfxNode ( self, gfxNode ) : - # - #print ">> MainWindow: onAddGfxNode = %s" % gfxNode.node.label - if gfxNode.node.type == 'image' : self.ui.imageView_ctl.addViewer ( gfxNode ) - - #if self.ui.nodeParam_ctl.receivers( QtCore.SIGNAL( 'onNodeParamChanged(QObject,QObject)' ) ) == 0 : - # QtCore.QObject.connect( self.ui.nodeParam_ctl, QtCore.SIGNAL( 'onNodeParamChanged(QObject,QObject)' ), self.ui.imageView_ctl.onNodeParamChanged ) - #else : - # print ">> MainWindow: nodeParam_ctl onNodeParamChanged already connected to imageView_ctl" - # - # onRemoveGfxNode - # - def onRemoveGfxNode ( self, gfxNode ) : - # - if DEBUG_MODE : print '>> MainWindow.onRemoveGfxNode = %s' % gfxNode.node.label - if gfxNode.node.type == 'image' : - self.ui.imageView_ctl.removeViewer ( gfxNode ) - #QtCore.QObject.disconnect ( self.ui.nodeParam_ctl, QtCore.SIGNAL ( 'onNodeParamChanged(QObject,QObject)' ), self.ui.imageView_ctl.onNodeParamChanged ) - # - # getSelectedNode - # - def getSelectedNode ( self ) : return self.workArea.selectedNodes [0] - # - # onRenderPreview - # - def onRenderPreview ( self ) : print ">> MainWindow.onRenderPreview (not implemented yet...)" - # - # onShowSwatch - # - def onShowSwatch ( self ) : print ">> MainWindow.onShowSwatch (not implemented yet...)" - # - # onHideSwatch - # - def onHideSwatch ( self ) : print ">> MainWindow.onHideSwatch (not implemented yet...)" - # - # onCreateNode - # - def onCreateNode ( self ) : print ">> MainWindow.onCreateNode (not implemented yet...)" - # - # onExportShader - # - def onExportShader ( self ) : - # - if DEBUG_MODE : print ">> MainWindow.onExportShader" - gfxNode = self.getSelectedNode () - exportShaderDlg = ExportShaderDialog ( gfxNode.node ) - exportShaderDlg.exec_ () - if exportShaderDlg.ui.chk_save_changes.isChecked () : - if DEBUG_MODE : print '>> MainWindow.exportShaderDlg save changes' - gfxNode.updateGfxNode ( removeLinks = False ) - self.workArea.updateBelow ( gfxNode ) - self.updateNodeParamView () - self.workArea.scene().update () - # - # onViewComputedCode - # - def onViewComputedCode ( self ) : ViewComputedCodeDialog ( self.getSelectedNode ().node ).exec_ () - - # - # onEditNode - # - def onEditNode ( self ) : - # - if DEBUG_MODE : print ">> MainWindow.onEditNode" - - gfxNode = self.getSelectedNode () - editNode = gfxNode.node.copy () - - dupNodeNet = NodeNetwork ( 'duplicate' ) - dupNodeNet.addNode ( editNode ) - # - # copy input links to new node - # - if DEBUG_MODE : print '** duplicate input links ...' - for link in gfxNode.node.getInputLinks () : - newLink = link.copy () - newParam = editNode.getInputParamByName ( link.dstParam.name ) - newLink.setDst ( editNode, newParam ) - dupNodeNet.addLink ( newLink ) - - newLink.printInfo () - # - # copy output links to new node - # - if DEBUG_MODE : print '** duplicate output links ...' - for link in gfxNode.node.getOutputLinks () : - newLink = link.copy () - newParam = editNode.getOutputParamByName ( link.srcParam.name ) - newLink.setSrc ( editNode, newParam ) - dupNodeNet.addLink ( newLink ) - - newLink.printInfo () - - nodeEditDlg = NodeEditorDialog ( editNode ) - - if nodeEditDlg.exec_ () == QtGui.QDialog.Accepted : - # - if DEBUG_MODE : print '>> MainWindow.nodeEditDlg Accepted' - # - # remove original node with links - ( inputLinksToRemove, outputLinksToRemove ) = self.workArea.nodeNet.removeNode ( gfxNode.node ) - - for link in inputLinksToRemove : self.workArea.nodeNet.removeLink ( link ) - for link in outputLinksToRemove : self.workArea.nodeNet.removeLink ( link ) - - # add duplicate network to current node net - self.workArea.nodeNet.add ( dupNodeNet ) - - if gfxNode.node.label != editNode.label : - self.ui.imageView_ctl.onNodeLabelChanged ( gfxNode, editNode.label ) - - # set new node to gfxNode.node - gfxNode.node = editNode - gfxNode.updateGfxNode () - for link in editNode.getInputLinks () : self.workArea.addGfxLink ( link ) - for link in editNode.getOutputLinks () : self.workArea.addGfxLink ( link ) - self.updateNodeParamView () - self.workArea.scene().update () - - else : - # remove duplicate node network - dupNodeNet.clear () - # - # onDelete - # - def onDelete ( self ) : - # - selected = self.workArea.scene ().selectedItems () - if len ( selected ) : - self.workArea.removeSelected () - else : - self.ui.imageView_ctl.removeAllViewers () - self.workArea.clear() - # - # onSelectAll - # - def onSelectAll ( self ) : self.workArea.selectAllNodes () - # - # onSelectAbove - # - def onSelectAbove ( self ) : self.workArea.selectAbove ( self.getSelectedNode () ) - # - # onSelectBelow - # - def onSelectBelow ( self ) : self.workArea.selectBelow ( self.getSelectedNode () ) - # - # onCopy - # - def onCopy ( self ) : - if DEBUG_MODE : print '>> MainWindow.onCopy' - self.workArea.copyNodes ( self.clipboard, cutNodes = False ) - self.setupActions () - # - # onCut - # - def onCut ( self ) : - if DEBUG_MODE : print '>> MainWindow.onCut' - self.workArea.copyNodes ( self.clipboard, cutNodes = True ) - self.setupActions () - # - # onPaste - # - def onPaste ( self ) : - if DEBUG_MODE : print '>> MainWindow.onPaste' - self.workArea.pasteNodes ( self.clipboard ) - # - # onDuplicate - # - def onDuplicate ( self ) : self.workArea.duplicateNodes ( preserveLinks = False ) - # - # onDuplicateWithLinks - # - def onDuplicateWithLinks ( self ) : self.workArea.duplicateNodes ( preserveLinks = True ) - # - # onSelectGfxNodes - # - def onSelectGfxNodes ( self, gfxNodes = [], gfxLinks = [] ) : - # - self.setupActions () - self.workArea.inspectedNode = None - if len ( gfxNodes ) == 1 : self.workArea.inspectedNode = gfxNodes[ 0 ] - - self.ui.nodeParam_ctl.setNode ( self.workArea.inspectedNode ) - # - # onNodeLabelChanged - # - def onNodeLabelChanged ( self, gfxNode, newLabel ) : - # - self.workArea.nodeNet.renameNodeLabel ( gfxNode.node, newLabel ) - gfxNode.updateNodeLabel () - self.ui.imageView_ctl.onNodeLabelChanged ( gfxNode, newLabel ) - self.workArea.scene ().update () - # - # onNodeParamChanged - # - def onNodeParamChanged ( self, gfxNode, param ) : - # - if DEBUG_MODE : print ">> MainWindow.onNodeParamChanged" - #param.shaderParam = not gfxNode.node.isInputParamLinked ( param ) - - # from WorkArea we have GfxNode in signal nodeConnectionChanged - # hence need to update nodeParam_ctl - if isinstance ( gfxNode, GfxNote ) : - #if DEBUG_MODE : print "* update GfxNote" - gfxNode.updateGfxNode () - #node.update () - self.workArea.scene ().update () - elif isinstance ( gfxNode, GfxSwatchNode ) : - if DEBUG_MODE : print "* update GfxSwatchNode" - gfxNode.setupSwatchParams () - gfxNode.setupGeometry () - gfxNode.adjustLinks () - self.workArea.scene ().update () - elif isinstance ( gfxNode, GfxNode ) : - if DEBUG_MODE : print "* update GfxNode" - gfxNode.updateGfxNode ( removeLinks = False ) - self.updateNodeParamView () - - if self.ui.imageView_ctl.autoUpdate () : self.ui.imageView_ctl.updateViewer() - # - # onGxNodeParamChanged - # - def onGfxNodeParamChanged ( self, gfxNode, param = None ) : - # - if DEBUG_MODE : print ">> MainWindow.onGxNodeParamChanged" - - # from WorkArea we have GfxNode in signal nodeConnectionChanged - # hence need to update nodeParam_ctl - if isinstance ( gfxNode, GfxNode ) or isinstance ( gfxNode, GfxSwatchNode ) : - #if DEBUG_MODE : print "* update nodeView" - # gfxNode.updateInputParams () - self.updateNodeParamView () - self.workArea.scene ().update () - - if self.ui.imageView_ctl.autoUpdate () : self.ui.imageView_ctl.updateViewer() - # - # updateNodeParamView - # - def updateNodeParamView ( self, gfxNode = None ) : - # - if DEBUG_MODE : - print '>> MainWindow.updateNodeParamView' - if gfxNode is not None : - print '** gfxNode = "%s"' % gfxNode.node.label - self.ui.nodeParam_ctl.disconnectParamSignals () - self.ui.nodeParam_ctl.connectParamSignals () - self.ui.nodeParam_ctl.updateGui () - # - # onFitAll - # - def onFitAll ( self ) : self.workArea.fitGfxNodesInView ( self.workArea.getAllGfxNodes () ) - # - # onFitSelected - # - def onFitSelected ( self ) : self.workArea.fitGfxNodesInView ( self.workArea.selectedNodes ) - # - # onZoomReset - # - def onZoomReset ( self ) : self.workArea.resetZoom () - # - # onNewParamView - # - def onNewParamView ( self ) : print ">> MainWindow.onNewParamView (not implemented yet...)" - # - # onTabSelected - # - def onTabSelected ( self, idx ) : - # - if DEBUG_MODE : print '>> MainWindow.onTabSelected (%d)' % idx - self.disconnectWorkAreaSignals () - self.ui.imageView_ctl.removeAllViewers () - self.workArea = self.ui.tabs.currentWidget () - - imageNodes = self.workArea.getGfxNodesByType ( 'image' ) - # setup imageView menu for image nodes in new tab - for gfxNode in imageNodes : self.ui.imageView_ctl.addViewer ( gfxNode ) - - self.connectWorkAreaSignals () - self.ui.nodeParam_ctl.setNode ( self.workArea.inspectedNode ) - self.workArea.adjustLinks () - # - # onTabCloseRequested - # - def onTabCloseRequested ( self, idx ) : - # - if DEBUG_MODE : print '>> MainWindow: onTabCloseRequested (%d)' % idx - if self.ui.tabs.count () > 1 : - self.workArea.nodeNet.clear () - self.ui.tabs.removeTab ( idx ) - # - # onNew - # - def onNew ( self, tabName = 'untitled' ) : - # - def tabNameExists ( self, name ) : - ret = False - for i in range ( 0, self.ui.tabs.count () ) : - if name == str ( self.ui.tabs.tabText ( i ) ): - ret = True - break - return ret - - newName = tabName - if DEBUG_MODE : print '-> self.ui.tabs.count() = %d ' % self.ui.tabs.count () - - if self.workArea != None : - if DEBUG_MODE : print '-> create new WorkArea widget' - # set unique new name - name = newName - i = 0 - while True : - if tabNameExists ( self, name ) : - name = newName + str ( i ) - i += 1 - continue - else : - break - newName = name - workArea = WorkArea () # create new WorkArea instance - newTab = self.ui.tabs.addTab ( workArea, newName ) - else : - if DEBUG_MODE : print '-> use initial WorkArea widget' - workArea = self.ui.workArea # use initial WorkArea widget - self.workArea = workArea - self.connectWorkAreaSignals () - - nodeNet = NodeNetwork ( newName ) - workArea.setNodeNetwork ( nodeNet ) - - self.ui.tabs.setTabText ( self.ui.tabs.indexOf ( workArea ), newName ) - self.ui.tabs.setCurrentIndex ( self.ui.tabs.indexOf ( workArea ) ) - # - # onOpen - # - def onOpen ( self ) : - # - if DEBUG_MODE : print ">> MainWindow.onOpen" - # - curDir = app_global_vars [ 'ProjectNetworks' ] - typeFilter = 'Shader networks *.xml;;All files *.*;;' - - filename = str ( QtGui.QFileDialog.getOpenFileName ( self, "Open file", curDir, typeFilter ) ) - if filename != '' : - if self.openNetwork ( filename ) : - self.addRecentNetwork ( normPath ( filename ) ) - self.buildRecentNetworksMenu () - # - # openNetwork - # - def openNetwork ( self, filename ) : - # - ret = True - if DEBUG_MODE : print "-> open file %s" % filename - if QtCore.QFile.exists ( filename ) : - ( name, ext ) = os.path.splitext ( os.path.basename ( filename ) ) - - self.ui.imageView_ctl.removeAllViewers () - - self.workArea.clear () - self.workArea.nodeNet.name = name - self.workArea.nodeNet.fileName = '' - self.ui.tabs.setTabText ( self.ui.tabs.indexOf ( self.workArea ), name ) - - self.workArea.openNodeNet ( normPath ( filename ) ) - else : - print "ERROR! filename %s doesn't exist" % filename - ret = False - return ret - # - # onOpenRecentNetwork - # - def onOpenRecentNetwork ( self ) : - # - action = self.sender () - if isinstance ( action, QtGui.QAction ): - network = unicode ( action.data ().toString () ) - if network is not None : - if DEBUG_MODE : print '>> onOpenRecentNetwork : %s' % network - if not self.openNetwork ( network ) : - # TODO!!! remove network from rescentNetworks - pass - # - # onOpenRecentProject - # - def onOpenRecentProject ( self ) : - # - action = self.sender () - if isinstance ( action, QtGui.QAction ): - project = unicode ( action.data ().toString () ) - if project is not None : - print '>> onOpenRecentProject : %s' % project - if openDefaultProject ( app_settings, app_global_vars, project ) : - # very strange... app_settings doesn't update inside meCommon.openDefaultProject... - # though app_global_vars does - # have to duplicate this action here... - app_settings.setValue ( 'project', app_global_vars [ 'ProjectPath' ] ) - app_settings.setValue ( 'project_shaders', app_global_vars [ 'ProjectShaders' ] ) - app_settings.setValue ( 'project_textures', app_global_vars [ 'ProjectTextures' ] ) - app_settings.setValue ( 'shader_networks', app_global_vars [ 'ProjectNetworks' ] ) - app_settings.setValue ( 'shader_sources', app_global_vars [ 'ProjectSources' ] ) - - self.ui.project_ctl.setLibrary ( app_global_vars [ 'ProjectNetworks' ] ) - self.setupWindowTitle () - else : - print "ERROR! project %s doesn't exist" % project - # TODO!!! remove project from rescentProjects - # - # onImport - # - def onImport ( self ) : - # - if DEBUG_MODE : print ">> MainWindow.onImport" - # - curDir = app_global_vars [ 'ProjectNetworks' ] - typeFilter = 'Shader networks *.xml;;All files *.*;;' - - filename = str ( QtGui.QFileDialog.getOpenFileName ( self, "Import file", curDir, typeFilter ) ) - if filename != '' : - if DEBUG_MODE : print "-> import file %s" % filename - self.workArea.insertNodeNet ( normPath ( filename ) ) - # - # onSaveSelected - # - def onSaveSelected ( self ) : - # - if DEBUG_MODE : print ">> MainWindow.onSaveSelected" - singleNode = ( len ( self.workArea.selectedNodes ) == 1 ) - curDir = app_global_vars [ 'ProjectNetworks' ] - saveName = os.path.join ( curDir, self.workArea.nodeNet.name + '.xml' ) - typeFilter = 'Shader networks *.xml;;All files *.*;;' - - filename = str( QtGui.QFileDialog.getSaveFileName ( self, "Save file as", saveName, typeFilter ) ) - if filename != '' : - if DEBUG_MODE : print '-> save file As %s' % filename - ( name, ext ) = os.path.splitext ( os.path.basename ( filename ) ) - if singleNode : - # save single node - print '*** save as single Node' - gfxNode = self.getSelectedNode () - saveNode = gfxNode.node.copy () - saveNode.name = name - saveNode.master = normPath ( filename ) - saveNode.save () - else : - # save selected as network - print '*** save as nodenet' - saveNodeNet = self.workArea.nodeNetFromSelected ( name ) - saveNodeNet.fileName = normPath ( filename ) - saveNodeNet.save () - # - # onSave - # - def onSave ( self ) : - # - if DEBUG_MODE : print ">> MainWindow.onSave" - # if file is new -- use onSaveAs function - # - curDir = app_global_vars [ 'ProjectNetworks' ] - if self.workArea.nodeNet.fileName == '' : - self.onSaveAs () - else : - if DEBUG_MODE : print '-> save file %s' % self.workArea.nodeNet.fileName - self.workArea.nodeNet.save () - # - # onSaveAs - # - def onSaveAs ( self ) : - # - if DEBUG_MODE : print ">> MainWindow.onSaveAs" - # - curDir = app_global_vars [ 'ProjectNetworks' ] - saveName = os.path.join ( curDir, self.workArea.nodeNet.name + '.xml' ) - typeFilter = 'Shader networks *.xml;;All files *.*;;' - - filename = str( QtGui.QFileDialog.getSaveFileName ( self, "Save file as", saveName, typeFilter ) ) - if filename != '' : - if DEBUG_MODE : print '-> save file As %s' % filename - ( name, ext ) = os.path.splitext ( os.path.basename ( filename ) ) - self.workArea.nodeNet.fileName = normPath ( filename ) - self.workArea.nodeNet.name = name - self.ui.tabs.setTabText ( self.ui.tabs.indexOf ( self.workArea ), name ) - self.workArea.nodeNet.save () - self.addRecentNetwork ( normPath ( filename ) ) - self.buildRecentNetworksMenu () - self.ui.project_ctl.onReload () - # - # onHelpNode - # - def onHelpMode ( self, showWhatsThis ) : - # - #if showWhatsThis : - QtGui.QWhatsThis.enterWhatsThisMode () - #else : - # QtGui.QWhatsThis.leaveWhatsThisMode () - # - # onCompileShader - # - def onCompileShader ( self ) : - # - if DEBUG_MODE : print ">> MainWindow.onCompileShader" - pass + app_global_vars [ 'RendererName' ] = self.RendererPreset.currentPreset.RendererName + app_global_vars [ 'RendererFlags' ] = self.RendererPreset.currentPreset.RendererFlags + app_global_vars [ 'ShaderCompiler' ] = self.RendererPreset.currentPreset.ShaderCompiler + app_global_vars [ 'ShaderDefines' ] = self.RendererPreset.currentPreset.ShaderDefines + app_global_vars [ 'ShaderInfo' ] = self.RendererPreset.currentPreset.ShaderInfo + app_global_vars [ 'SLO' ] = self.RendererPreset.currentPreset.ShaderExt + app_global_vars [ 'TextureMake' ] = self.RendererPreset.currentPreset.TextureMake + app_global_vars [ 'TextureInfo' ] = self.RendererPreset.currentPreset.TextureInfo + app_global_vars [ 'TextureViewer' ] = self.RendererPreset.currentPreset.TextureViewer + app_global_vars [ 'TEX' ] = self.RendererPreset.currentPreset.TextureExt + app_global_vars [ 'RendererPreset' ] = self.RendererPreset + self.setupWindowTitle () + # + # onRenderPresetSave + # + def onRenderPresetSave ( self ) : + # + if DEBUG_MODE : print ( '>> MainWindow::onRenderPresetSave preset = %s' % self.RendererPreset.getCurrentPresetName () ) + self.RendererPreset.saveSettings () + app_global_vars [ 'RendererPreset' ] = self.RendererPreset + # + # onShowGrid + # + def onShowGrid ( self, check ) : + # + self.workArea.drawGrid = bool ( check ) + app_settings.beginGroup ( 'WorkArea' ) + app_settings.setValue ( 'grid_enabled', bool ( check ) ) + app_settings.endGroup () + + self.workArea.resetCachedContent () + #self.ui.workArea.update() + # + # onSnapGrid + # + def onSnapGrid ( self, check ) : + # + self.workArea.gridSnap = bool ( check ) + app_settings.beginGroup ( 'WorkArea' ) + app_settings.setValue ( 'grid_snap', bool ( check ) ) + app_settings.endGroup () + # + # onReverseFlow + # + def onReverseFlow ( self, check ) : + # + self.workArea.reverseFlow = bool ( check ) + app_settings.beginGroup ( 'WorkArea' ) + app_settings.setValue ( 'reverse_flow', bool ( check ) ) + app_settings.endGroup () + + #self.ui.workArea.resetCachedContent() + # + # onStraightLinks + # + def onStraightLinks ( self, check ) : + # + self.workArea.straightLinks = bool ( check ) + app_settings.beginGroup ( 'WorkArea' ) + app_settings.setValue ( 'straight_links', bool ( check ) ) + app_settings.endGroup () + self.workArea.resetCachedContent () + self.workArea.adjustLinks () + # + # setActiveNodeList + # + def setActiveNodeList ( self, nodeList ) : + # + if DEBUG_MODE : print '>> MainWindow.setActiveNodeList' + if self.activeNodeList != None : + QtCore.QObject.disconnect ( self.activeNodeList, QtCore.SIGNAL ( 'addNode' ), self.workArea.insertNodeNet ) + self.activeNodeList = nodeList + QtCore.QObject.connect ( self.activeNodeList, QtCore.SIGNAL ( 'addNode' ), self.workArea.insertNodeNet ) + # + # onGetNode + # + # Called by WorkArea after drag&drop event + # Here we choose selected nodeList panel (Library or Project) + # for processing node request + # + def onGetNode ( self, itemFilename, pos ) : + # + if self.activeNodeList != None : self.activeNodeList.onGetNode ( itemFilename, pos ) + # + # onAddGfxNode + # + def onAddGfxNode ( self, gfxNode ) : + # + #print ">> MainWindow: onAddGfxNode = %s" % gfxNode.node.label + if gfxNode.node.type == 'image' : self.ui.imageView_ctl.addViewer ( gfxNode ) + + #if self.ui.nodeParam_ctl.receivers( QtCore.SIGNAL( 'onNodeParamChanged(QObject,QObject)' ) ) == 0 : + # QtCore.QObject.connect( self.ui.nodeParam_ctl, QtCore.SIGNAL( 'onNodeParamChanged(QObject,QObject)' ), self.ui.imageView_ctl.onNodeParamChanged ) + #else : + # print ">> MainWindow: nodeParam_ctl onNodeParamChanged already connected to imageView_ctl" + # + # onRemoveGfxNode + # + def onRemoveGfxNode ( self, gfxNode ) : + # + if DEBUG_MODE : print '>> MainWindow.onRemoveGfxNode = %s' % gfxNode.node.label + if gfxNode.node.type == 'image' : + self.ui.imageView_ctl.removeViewer ( gfxNode ) + #QtCore.QObject.disconnect ( self.ui.nodeParam_ctl, QtCore.SIGNAL ( 'onNodeParamChanged(QObject,QObject)' ), self.ui.imageView_ctl.onNodeParamChanged ) + # + # getSelectedNode + # + def getSelectedNode ( self ) : return self.workArea.selectedNodes [0] + # + # onRenderPreview + # + def onRenderPreview ( self ) : print ">> MainWindow.onRenderPreview (not implemented yet...)" + # + # onShowSwatch + # + def onShowSwatch ( self ) : print ">> MainWindow.onShowSwatch (not implemented yet...)" + # + # onHideSwatch + # + def onHideSwatch ( self ) : print ">> MainWindow.onHideSwatch (not implemented yet...)" + # + # onCreateNode + # + def onCreateNode ( self ) : print ">> MainWindow.onCreateNode (not implemented yet...)" + # + # onExportShader + # + def onExportShader ( self ) : + # + if DEBUG_MODE : print ">> MainWindow.onExportShader" + gfxNode = self.getSelectedNode () + exportShaderDlg = ExportShaderDialog ( gfxNode.node ) + exportShaderDlg.exec_ () + if exportShaderDlg.ui.chk_save_changes.isChecked () : + if DEBUG_MODE : print '>> MainWindow.exportShaderDlg save changes' + gfxNode.updateGfxNode ( removeLinks = False ) + self.workArea.updateBelow ( gfxNode ) + self.updateNodeParamView () + self.workArea.scene().update () + # + # onViewComputedCode + # + def onViewComputedCode ( self ) : ViewComputedCodeDialog ( self.getSelectedNode ().node ).exec_ () + + # + # onEditNode + # + def onEditNode ( self ) : + # + if DEBUG_MODE : print ">> MainWindow.onEditNode" + + gfxNode = self.getSelectedNode () + editNode = gfxNode.node.copy () + + dupNodeNet = NodeNetwork ( 'duplicate' ) + dupNodeNet.addNode ( editNode ) + # + # copy input links to new node + # + if DEBUG_MODE : print '** duplicate input links ...' + for link in gfxNode.node.getInputLinks () : + newLink = link.copy () + newParam = editNode.getInputParamByName ( link.dstParam.name ) + newLink.setDst ( editNode, newParam ) + dupNodeNet.addLink ( newLink ) + + newLink.printInfo () + # + # copy output links to new node + # + if DEBUG_MODE : print '** duplicate output links ...' + for link in gfxNode.node.getOutputLinks () : + newLink = link.copy () + newParam = editNode.getOutputParamByName ( link.srcParam.name ) + newLink.setSrc ( editNode, newParam ) + dupNodeNet.addLink ( newLink ) + + newLink.printInfo () + + nodeEditDlg = NodeEditorDialog ( editNode ) + + if nodeEditDlg.exec_ () == QtGui.QDialog.Accepted : + # + if DEBUG_MODE : print '>> MainWindow.nodeEditDlg Accepted' + # + # remove original node with links + ( inputLinksToRemove, outputLinksToRemove ) = self.workArea.nodeNet.removeNode ( gfxNode.node ) + + for link in inputLinksToRemove : self.workArea.nodeNet.removeLink ( link ) + for link in outputLinksToRemove : self.workArea.nodeNet.removeLink ( link ) + + # add duplicate network to current node net + self.workArea.nodeNet.add ( dupNodeNet ) + + if gfxNode.node.label != editNode.label : + self.ui.imageView_ctl.onNodeLabelChanged ( gfxNode, editNode.label ) + + # set new node to gfxNode.node + gfxNode.node = editNode + gfxNode.updateGfxNode () + for link in editNode.getInputLinks () : self.workArea.addGfxLink ( link ) + for link in editNode.getOutputLinks () : self.workArea.addGfxLink ( link ) + self.updateNodeParamView () + self.workArea.scene().update () + + else : + # remove duplicate node network + dupNodeNet.clear () + # + # onDelete + # + def onDelete ( self ) : + # + selected = self.workArea.scene ().selectedItems () + if len ( selected ) : + self.workArea.removeSelected () + else : + self.ui.imageView_ctl.removeAllViewers () + self.workArea.clear() + # + # onSelectAll + # + def onSelectAll ( self ) : self.workArea.selectAllNodes () + # + # onSelectAbove + # + def onSelectAbove ( self ) : self.workArea.selectAbove ( self.getSelectedNode () ) + # + # onSelectBelow + # + def onSelectBelow ( self ) : self.workArea.selectBelow ( self.getSelectedNode () ) + # + # onCopy + # + def onCopy ( self ) : + if DEBUG_MODE : print '>> MainWindow.onCopy' + self.workArea.copyNodes ( self.clipboard, cutNodes = False ) + self.setupActions () + # + # onCut + # + def onCut ( self ) : + if DEBUG_MODE : print '>> MainWindow.onCut' + self.workArea.copyNodes ( self.clipboard, cutNodes = True ) + self.setupActions () + # + # onPaste + # + def onPaste ( self ) : + if DEBUG_MODE : print '>> MainWindow.onPaste' + self.workArea.pasteNodes ( self.clipboard ) + # + # onDuplicate + # + def onDuplicate ( self ) : self.workArea.duplicateNodes ( preserveLinks = False ) + # + # onDuplicateWithLinks + # + def onDuplicateWithLinks ( self ) : self.workArea.duplicateNodes ( preserveLinks = True ) + # + # onSelectGfxNodes + # + def onSelectGfxNodes ( self, gfxNodes = [], gfxLinks = [] ) : + # + self.setupActions () + self.workArea.inspectedNode = None + if len ( gfxNodes ) == 1 : self.workArea.inspectedNode = gfxNodes[ 0 ] + + self.ui.nodeParam_ctl.setNode ( self.workArea.inspectedNode ) + # + # onNodeLabelChanged + # + def onNodeLabelChanged ( self, gfxNode, newLabel ) : + # + self.workArea.nodeNet.renameNodeLabel ( gfxNode.node, newLabel ) + gfxNode.updateNodeLabel () + self.ui.imageView_ctl.onNodeLabelChanged ( gfxNode, newLabel ) + self.workArea.scene ().update () + # + # onNodeParamChanged + # + def onNodeParamChanged ( self, gfxNode, param ) : + # + if DEBUG_MODE : print ">> MainWindow.onNodeParamChanged" + #param.shaderParam = not gfxNode.node.isInputParamLinked ( param ) + + # from WorkArea we have GfxNode in signal nodeConnectionChanged + # hence need to update nodeParam_ctl + if isinstance ( gfxNode, GfxNote ) : + #if DEBUG_MODE : print "* update GfxNote" + gfxNode.updateGfxNode () + #node.update () + self.workArea.scene ().update () + elif isinstance ( gfxNode, GfxSwatchNode ) : + if DEBUG_MODE : print "* update GfxSwatchNode" + gfxNode.setupSwatchParams () + gfxNode.setupGeometry () + gfxNode.adjustLinks () + self.workArea.scene ().update () + elif isinstance ( gfxNode, GfxNode ) : + if DEBUG_MODE : print "* update GfxNode" + gfxNode.updateGfxNode ( removeLinks = False ) + self.updateNodeParamView () + + if self.ui.imageView_ctl.autoUpdate () : self.ui.imageView_ctl.updateViewer() + # + # onGxNodeParamChanged + # + def onGfxNodeParamChanged ( self, gfxNode, param = None ) : + # + if DEBUG_MODE : print ">> MainWindow.onGxNodeParamChanged" + + # from WorkArea we have GfxNode in signal nodeConnectionChanged + # hence need to update nodeParam_ctl + if isinstance ( gfxNode, GfxNode ) or isinstance ( gfxNode, GfxSwatchNode ) : + #if DEBUG_MODE : print "* update nodeView" + # gfxNode.updateInputParams () + self.updateNodeParamView () + self.workArea.scene ().update () + + if self.ui.imageView_ctl.autoUpdate () : self.ui.imageView_ctl.updateViewer() + # + # updateNodeParamView + # + def updateNodeParamView ( self, gfxNode = None ) : + # + if DEBUG_MODE : + print '>> MainWindow.updateNodeParamView' + if gfxNode is not None : + print '** gfxNode = "%s"' % gfxNode.node.label + self.ui.nodeParam_ctl.disconnectParamSignals () + self.ui.nodeParam_ctl.connectParamSignals () + self.ui.nodeParam_ctl.updateGui () + # + # onFitAll + # + def onFitAll ( self ) : self.workArea.fitGfxNodesInView ( self.workArea.getAllGfxNodes () ) + # + # onFitSelected + # + def onFitSelected ( self ) : self.workArea.fitGfxNodesInView ( self.workArea.selectedNodes ) + # + # onZoomReset + # + def onZoomReset ( self ) : self.workArea.resetZoom () + # + # onNewParamView + # + def onNewParamView ( self ) : print ">> MainWindow.onNewParamView (not implemented yet...)" + # + # onTabSelected + # + def onTabSelected ( self, idx ) : + # + if DEBUG_MODE : print '>> MainWindow.onTabSelected (%d)' % idx + self.disconnectWorkAreaSignals () + self.ui.imageView_ctl.removeAllViewers () + self.workArea = self.ui.tabs.currentWidget () + + imageNodes = self.workArea.getGfxNodesByType ( 'image' ) + # setup imageView menu for image nodes in new tab + for gfxNode in imageNodes : self.ui.imageView_ctl.addViewer ( gfxNode ) + + self.connectWorkAreaSignals () + self.ui.nodeParam_ctl.setNode ( self.workArea.inspectedNode ) + self.workArea.adjustLinks () + # + # onTabCloseRequested + # + def onTabCloseRequested ( self, idx ) : + # + if DEBUG_MODE : print '>> MainWindow: onTabCloseRequested (%d)' % idx + if self.ui.tabs.count () > 1 : + self.workArea.nodeNet.clear () + self.ui.tabs.removeTab ( idx ) + # + # onNew + # + def onNew ( self, tabName = 'untitled' ) : + # + def tabNameExists ( self, name ) : + ret = False + for i in range ( 0, self.ui.tabs.count () ) : + if name == str ( self.ui.tabs.tabText ( i ) ): + ret = True + break + return ret + + newName = tabName + if DEBUG_MODE : print '-> self.ui.tabs.count() = %d ' % self.ui.tabs.count () + + if self.workArea != None : + if DEBUG_MODE : print '-> create new WorkArea widget' + # set unique new name + name = newName + i = 0 + while True : + if tabNameExists ( self, name ) : + name = newName + str ( i ) + i += 1 + continue + else : + break + newName = name + workArea = WorkArea () # create new WorkArea instance + newTab = self.ui.tabs.addTab ( workArea, newName ) + else : + if DEBUG_MODE : print '-> use initial WorkArea widget' + workArea = self.ui.workArea # use initial WorkArea widget + self.workArea = workArea + self.connectWorkAreaSignals () + + nodeNet = NodeNetwork ( newName ) + workArea.setNodeNetwork ( nodeNet ) + + self.ui.tabs.setTabText ( self.ui.tabs.indexOf ( workArea ), newName ) + self.ui.tabs.setCurrentIndex ( self.ui.tabs.indexOf ( workArea ) ) + # + # onOpen + # + def onOpen ( self ) : + # + if DEBUG_MODE : print ">> MainWindow.onOpen" + # + curDir = app_global_vars [ 'ProjectNetworks' ] + typeFilter = 'Shader networks *.xml;;All files *.*;;' + + filename = str ( QtGui.QFileDialog.getOpenFileName ( self, "Open file", curDir, typeFilter ) ) + if filename != '' : + if self.openNetwork ( filename ) : + self.addRecentNetwork ( normPath ( filename ) ) + self.buildRecentNetworksMenu () + # + # openNetwork + # + def openNetwork ( self, filename ) : + # + import os + ret = True + if DEBUG_MODE : print "-> open file %s" % filename + if QtCore.QFile.exists ( filename ) : + ( name, ext ) = os.path.splitext ( os.path.basename ( filename ) ) + + self.ui.imageView_ctl.removeAllViewers () + + self.workArea.clear () + self.workArea.nodeNet.name = name + self.workArea.nodeNet.fileName = '' + self.ui.tabs.setTabText ( self.ui.tabs.indexOf ( self.workArea ), name ) + + self.workArea.openNodeNet ( normPath ( filename ) ) + else : + print "ERROR! filename %s doesn't exist" % filename + ret = False + return ret + # + # onOpenRecentNetwork + # + def onOpenRecentNetwork ( self ) : + # + action = self.sender () + if isinstance ( action, QtGui.QAction ): + network = unicode ( action.data ().toString () ) + if network is not None : + if DEBUG_MODE : print '>> onOpenRecentNetwork : %s' % network + if not self.openNetwork ( network ) : + # TODO!!! remove network from rescentNetworks + pass + # + # onOpenRecentProject + # + def onOpenRecentProject ( self ) : + # + action = self.sender () + if isinstance ( action, QtGui.QAction ): + project = unicode ( action.data ().toString () ) + if project is not None : + print '>> onOpenRecentProject : %s' % project + if openDefaultProject ( app_settings, app_global_vars, project ) : + # very strange... app_settings doesn't update inside meCommon.openDefaultProject... + # though app_global_vars does + # have to duplicate this action here... + app_settings.setValue ( 'project', app_global_vars [ 'ProjectPath' ] ) + app_settings.setValue ( 'project_shaders', app_global_vars [ 'ProjectShaders' ] ) + app_settings.setValue ( 'project_textures', app_global_vars [ 'ProjectTextures' ] ) + app_settings.setValue ( 'shader_networks', app_global_vars [ 'ProjectNetworks' ] ) + app_settings.setValue ( 'shader_sources', app_global_vars [ 'ProjectSources' ] ) + + self.ui.project_ctl.setLibrary ( app_global_vars [ 'ProjectNetworks' ] ) + self.setupWindowTitle () + else : + print "ERROR! project %s doesn't exist" % project + # TODO!!! remove project from rescentProjects + # + # onImport + # + def onImport ( self ) : + # + if DEBUG_MODE : print ">> MainWindow.onImport" + # + curDir = app_global_vars [ 'ProjectNetworks' ] + typeFilter = 'Shader networks *.xml;;All files *.*;;' + + filename = str ( QtGui.QFileDialog.getOpenFileName ( self, "Import file", curDir, typeFilter ) ) + if filename != '' : + if DEBUG_MODE : print "-> import file %s" % filename + self.workArea.insertNodeNet ( normPath ( filename ) ) + # + # onSaveSelected + # + def onSaveSelected ( self ) : + # + import os + if DEBUG_MODE : print ">> MainWindow.onSaveSelected" + singleNode = ( len ( self.workArea.selectedNodes ) == 1 ) + curDir = app_global_vars [ 'ProjectNetworks' ] + saveName = os.path.join ( curDir, self.workArea.nodeNet.name + '.xml' ) + typeFilter = 'Shader networks *.xml;;All files *.*;;' + + filename = str( QtGui.QFileDialog.getSaveFileName ( self, "Save file as", saveName, typeFilter ) ) + if filename != '' : + if DEBUG_MODE : print '-> save file As %s' % filename + ( name, ext ) = os.path.splitext ( os.path.basename ( filename ) ) + if singleNode : + # save single node + print '*** save as single Node' + gfxNode = self.getSelectedNode () + saveNode = gfxNode.node.copy () + saveNode.name = name + saveNode.master = normPath ( filename ) + saveNode.save () + else : + # save selected as network + print '*** save as nodenet' + saveNodeNet = self.workArea.nodeNetFromSelected ( name ) + saveNodeNet.fileName = normPath ( filename ) + saveNodeNet.save () + # + # onSave + # + def onSave ( self ) : + # + if DEBUG_MODE : print ">> MainWindow.onSave" + # if file is new -- use onSaveAs function + # + curDir = app_global_vars [ 'ProjectNetworks' ] + if self.workArea.nodeNet.fileName == '' : + self.onSaveAs () + else : + if DEBUG_MODE : print '-> save file %s' % self.workArea.nodeNet.fileName + self.workArea.nodeNet.save () + # + # onSaveAs + # + def onSaveAs ( self ) : + # + if DEBUG_MODE : print ">> MainWindow.onSaveAs" + # + import os + curDir = app_global_vars [ 'ProjectNetworks' ] + saveName = os.path.join ( curDir, self.workArea.nodeNet.name + '.xml' ) + typeFilter = 'Shader networks *.xml;;All files *.*;;' + + filename = str( QtGui.QFileDialog.getSaveFileName ( self, "Save file as", saveName, typeFilter ) ) + if filename != '' : + if DEBUG_MODE : print '-> save file As %s' % filename + ( name, ext ) = os.path.splitext ( os.path.basename ( filename ) ) + self.workArea.nodeNet.fileName = normPath ( filename ) + self.workArea.nodeNet.name = name + self.ui.tabs.setTabText ( self.ui.tabs.indexOf ( self.workArea ), name ) + self.workArea.nodeNet.save () + self.addRecentNetwork ( normPath ( filename ) ) + self.buildRecentNetworksMenu () + self.ui.project_ctl.onReload () + # + # onHelpNode + # + def onHelpMode ( self, showWhatsThis ) : + # + #if showWhatsThis : + QtGui.QWhatsThis.enterWhatsThisMode () + #else : + # QtGui.QWhatsThis.leaveWhatsThisMode () + # + # onCompileShader + # + def onCompileShader ( self ) : + # + if DEBUG_MODE : print ">> MainWindow.onCompileShader" + pass diff --git a/gui/ProjectSetup.py b/gui/ProjectSetup.py index 2c49b41..c9b16f6 100644 --- a/gui/ProjectSetup.py +++ b/gui/ProjectSetup.py @@ -1,137 +1,149 @@ -#=============================================================================== -# ProjectSetup.py -# -# ver. 1.0.0 -# Author: Yuri Meshalkin (aka mesh) (yuri.meshalkin@gmail.com) -# -# Dialog for managing project directories -# -#=============================================================================== +""" + + ProjectSetup.py -import os, sys -from PyQt4 import QtCore, QtGui + ver. 1.0.0 + Author: Yuri Meshalkin (aka mesh) (yuri.meshalkin@gmail.com) + + Dialog for managing project directories + +""" +from core.mePyQt import QtCore, QtGui from core.meCommon import * from global_vars import app_global_vars from ui_projectSetup import Ui_ProjectSetup + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + # +# ProjectSetup # -# -class ProjectSetup( QtGui.QDialog ): - # - # - def __init__ ( self, app_settings ): - QtGui.QDialog.__init__ ( self ) +class ProjectSetup( QtModule.QDialog ): + # + # + def __init__ ( self, app_settings ): + # + QtModule.QDialog.__init__ ( self ) - self.app_settings = app_settings - self.rootDir = str ( self.app_settings.value ( 'project' ).toString () ) - self.buildGui () - # - # buildGui - # - def buildGui ( self ): - # build the gui created with QtDesigner - self.ui = Ui_ProjectSetup () - self.ui.setupUi ( self ) - - ##font = QtGui.QFont() - ##if( sys.platform == 'win32' ) : - # Runing on windows, override font sizes from Designer to default - ## font.setPointSize(8) - ##else : - ## font.setPointSize(10) - - self.ui.lineEdit_project.setText ( self.rootDir ) + self.app_settings = app_settings + self.rootDir = str ( self.app_settings.value ( 'project' ).toString () ) + self.buildGui () + # + # buildGui + # + def buildGui ( self ): + # build the gui created with QtDesigner + self.ui = Ui_ProjectSetup () + self.ui.setupUi ( self ) + + ##font = QtGui.QFont() + ##if( sys.platform == 'win32' ) : + # Runing on windows, override font sizes from Designer to default + ## font.setPointSize(8) + ##else : + ## font.setPointSize(10) + + self.ui.lineEdit_project.setText ( self.rootDir ) - self.ui.lineEdit_network.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'shader_networks' ).toString () ) ) ) - self.ui.lineEdit_sources.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'shader_sources' ).toString () ) ) ) - self.ui.lineEdit_shaders.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'project_shaders' ).toString () ) ) ) - self.ui.lineEdit_textures.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'project_textures' ).toString () ) ) ) - # - # setupProject - # - def setupProject ( self ) : - # - project_shaders = normPath ( fromRelativePath ( self.rootDir, str ( self.ui.lineEdit_shaders.text () ) ) ) - project_textures = normPath ( fromRelativePath ( self.rootDir, str ( self.ui.lineEdit_textures.text () ) ) ) - - shader_networks_dir = normPath ( fromRelativePath ( self.rootDir, str ( self.ui.lineEdit_network.text () ) ) ) - shader_sources_dir = normPath ( fromRelativePath ( self.rootDir, str ( self.ui.lineEdit_sources.text () ) ) ) - - createMissingDirs ( [ self.rootDir, project_shaders, project_textures, shader_networks_dir, shader_sources_dir ] ) - - return ( project_shaders, project_textures, shader_networks_dir, shader_sources_dir ) - # - # onBrowseProjectDir - # - def onBrowseProjectDir ( self ) : - curDir = self.ui.lineEdit_project.text () - newDir = QtGui.QFileDialog.getExistingDirectory ( self, 'Select Project Directory', curDir ) - if newDir != '' : - self.rootDir = normPath ( newDir ) - self.ui.lineEdit_project.setText ( self.rootDir ) - self.setupProject () - # - # onBrowseNetworksDir - # - def onBrowseNetworksDir ( self ) : - curDir = fromRelativePath ( self.rootDir, str ( self.ui.lineEdit_network.text () ) ) - newDir = QtGui.QFileDialog.getExistingDirectory ( self, 'Select Shader Networks Directory', curDir ) - if newDir != '' : - self.ui.lineEdit_network.setText ( toRelativePath ( self.rootDir, normPath ( newDir ) ) ) - # - # onBrowseSourcesDir - # - def onBrowseSourcesDir ( self ) : - curDir = fromRelativePath ( self.rootDir, str ( self.ui.lineEdit_sources.text () ) ) - newDir = QtGui.QFileDialog.getExistingDirectory ( self, 'Select Shader Sources Directory', curDir ) - if newDir != '' : - self.ui.lineEdit_sources.setText ( toRelativePath ( self.rootDir, normPath ( newDir ) ) ) - # - # onBrowseShadersDir - # - def onBrowseShadersDir ( self ) : - curDir = fromRelativePath ( self.rootDir, str ( self.ui.lineEdit_shaders.text () ) ) - newDir = QtGui.QFileDialog.getExistingDirectory ( self, 'Select Compiled Shaders Directory', curDir ) - if newDir != '' : - self.ui.lineEdit_shaders.setText ( toRelativePath ( self.rootDir, normPath ( newDir ) ) ) - # - # onBrowseTexturesDir - # - def onBrowseTexturesDir ( self ) : - curDir = fromRelativePath ( self.rootDir, str ( self.ui.lineEdit_textures.text () ) ) - newDir = QtGui.QFileDialog.getExistingDirectory ( self, 'Select Textures Directory', curDir ) - if newDir != '' : - self.ui.lineEdit_textures.setText ( toRelativePath ( self.rootDir, normPath ( newDir ) ) ) - # - # reject - # - def reject ( self ) : self.done ( 0 ) - # - # accept - # - def accept ( self ) : - # - ( project_shaders, project_textures, shader_networks_dir, shader_sources_dir ) = self.setupProject () - - self.app_settings.setValue ( 'project', self.rootDir ) + self.ui.lineEdit_network.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'shader_networks' ).toString () ) ) ) + self.ui.lineEdit_sources.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'shader_sources' ).toString () ) ) ) + self.ui.lineEdit_shaders.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'project_shaders' ).toString () ) ) ) + self.ui.lineEdit_textures.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'project_textures' ).toString () ) ) ) + # + # setupProject + # + def setupProject ( self ) : + # + project_shaders = normPath ( fromRelativePath ( self.rootDir, str ( self.ui.lineEdit_shaders.text () ) ) ) + project_textures = normPath ( fromRelativePath ( self.rootDir, str ( self.ui.lineEdit_textures.text () ) ) ) + + shader_networks_dir = normPath ( fromRelativePath ( self.rootDir, str ( self.ui.lineEdit_network.text () ) ) ) + shader_sources_dir = normPath ( fromRelativePath ( self.rootDir, str ( self.ui.lineEdit_sources.text () ) ) ) + + createMissingDirs ( [ self.rootDir, project_shaders, project_textures, shader_networks_dir, shader_sources_dir ] ) + + return ( project_shaders, project_textures, shader_networks_dir, shader_sources_dir ) + # + # onBrowseProjectDir + # + def onBrowseProjectDir ( self ) : + # + curDir = self.ui.lineEdit_project.text () + newDir = QtModule.QFileDialog.getExistingDirectory ( self, 'Select Project Directory', curDir ) + if newDir != '' : + self.rootDir = normPath ( newDir ) + self.ui.lineEdit_project.setText ( self.rootDir ) + self.setupProject () + # + # onBrowseNetworksDir + # + def onBrowseNetworksDir ( self ) : + # + curDir = fromRelativePath ( self.rootDir, str ( self.ui.lineEdit_network.text () ) ) + newDir = QtModule.QFileDialog.getExistingDirectory ( self, 'Select Shader Networks Directory', curDir ) + if newDir != '' : + self.ui.lineEdit_network.setText ( toRelativePath ( self.rootDir, normPath ( newDir ) ) ) + # + # onBrowseSourcesDir + # + def onBrowseSourcesDir ( self ) : + # + curDir = fromRelativePath ( self.rootDir, str ( self.ui.lineEdit_sources.text () ) ) + newDir = QtModule.QFileDialog.getExistingDirectory ( self, 'Select Shader Sources Directory', curDir ) + if newDir != '' : + self.ui.lineEdit_sources.setText ( toRelativePath ( self.rootDir, normPath ( newDir ) ) ) + # + # onBrowseShadersDir + # + def onBrowseShadersDir ( self ) : + # + curDir = fromRelativePath ( self.rootDir, str ( self.ui.lineEdit_shaders.text () ) ) + newDir = QtModule.QFileDialog.getExistingDirectory ( self, 'Select Compiled Shaders Directory', curDir ) + if newDir != '' : + self.ui.lineEdit_shaders.setText ( toRelativePath ( self.rootDir, normPath ( newDir ) ) ) + # + # onBrowseTexturesDir + # + def onBrowseTexturesDir ( self ) : + # + curDir = fromRelativePath ( self.rootDir, str ( self.ui.lineEdit_textures.text () ) ) + newDir = QtModule.QFileDialog.getExistingDirectory ( self, 'Select Textures Directory', curDir ) + if newDir != '' : + self.ui.lineEdit_textures.setText ( toRelativePath ( self.rootDir, normPath ( newDir ) ) ) + # + # reject + # + def reject ( self ) : self.done ( 0 ) + # + # accept + # + def accept ( self ) : + # + ( project_shaders, project_textures, shader_networks_dir, shader_sources_dir ) = self.setupProject () + + self.app_settings.setValue ( 'project', self.rootDir ) - self.app_settings.setValue ( 'shader_networks', shader_networks_dir ) - self.app_settings.setValue ( 'shader_sources', shader_sources_dir ) - self.app_settings.setValue ( 'project_shaders', project_shaders ) - self.app_settings.setValue ( 'project_textures', project_textures ) - - app_global_vars [ 'ProjectPath' ] = self.rootDir - - app_global_vars [ 'ProjectShaders' ] = project_shaders - app_global_vars [ 'ProjectTextures' ] = project_textures - - app_global_vars [ 'ProjectNetworks' ] = shader_networks_dir - app_global_vars [ 'ProjectSources' ] = shader_sources_dir - - app_global_vars [ 'ProjectSearchPath' ] = sanitizeSearchPath ( self.rootDir ) - app_global_vars [ 'ProjectSearchShaders' ] = sanitizeSearchPath ( project_shaders ) - app_global_vars [ 'ProjectSearchTextures' ] = sanitizeSearchPath ( project_textures ) - - self.done ( 0 ) \ No newline at end of file + self.app_settings.setValue ( 'shader_networks', shader_networks_dir ) + self.app_settings.setValue ( 'shader_sources', shader_sources_dir ) + self.app_settings.setValue ( 'project_shaders', project_shaders ) + self.app_settings.setValue ( 'project_textures', project_textures ) + + app_global_vars [ 'ProjectPath' ] = self.rootDir + + app_global_vars [ 'ProjectShaders' ] = project_shaders + app_global_vars [ 'ProjectTextures' ] = project_textures + + app_global_vars [ 'ProjectNetworks' ] = shader_networks_dir + app_global_vars [ 'ProjectSources' ] = shader_sources_dir + + app_global_vars [ 'ProjectSearchPath' ] = sanitizeSearchPath ( self.rootDir ) + app_global_vars [ 'ProjectSearchShaders' ] = sanitizeSearchPath ( project_shaders ) + app_global_vars [ 'ProjectSearchTextures' ] = sanitizeSearchPath ( project_textures ) + + self.done ( 0 ) \ No newline at end of file diff --git a/gui/SettingsSetup.py b/gui/SettingsSetup.py index e4ceaf1..9111a07 100644 --- a/gui/SettingsSetup.py +++ b/gui/SettingsSetup.py @@ -8,136 +8,150 @@ # #=============================================================================== -import os, sys -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui from core.meCommon import * from global_vars import app_global_vars from ui_settingsSetup import Ui_SettingsSetup + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + # +# SettingsSetup # -# -class SettingsSetup ( QtGui.QDialog ): - # - # - def __init__ ( self, app_settings ): - QtGui.QDialog.__init__(self) +class SettingsSetup ( QtModule.QDialog ): + # + # + def __init__ ( self, app_settings ): + # + QtModule.QDialog.__init__(self) - self.app_settings = app_settings - - #self.debugPrint() - self.buildGui() - # - # - def buildGui ( self ): - # build the gui created with QtDesigner - self.ui = Ui_SettingsSetup ( ) - self.ui.setupUi ( self ) - - ##font = QtGui.QFont() - ##if( sys.platform == 'win32' ) : - # Runing on windows, override font sizes from Designer to default - ## font.setPointSize(8) - ##else : - ## font.setPointSize(10) - - self.ui.lineEdit_temp.setText( self.app_settings.value('temp').toString() ) - self.ui.lineEdit_inc.setText( self.app_settings.value('include').toString() ) - self.ui.lineEdit_lib.setText( self.app_settings.value('lib').toString() ) - self.ui.lineEdit_nodes.setText( self.app_settings.value('nodes').toString() ) - self.ui.lineEdit_shaders.setText( self.app_settings.value('shaders').toString() ) - self.ui.lineEdit_textures.setText( self.app_settings.value('texture').toString() ) - self.ui.lineEdit_archives.setText( self.app_settings.value('archive').toString() ) - # - # - def onBrowseTempDir ( self ): - curDir = self.ui.lineEdit_temp.text() - newDir = QtGui.QFileDialog.getExistingDirectory( self, "Select Temp Directory", curDir ) - if newDir != '' : - self.ui.lineEdit_temp.setText( normPath( newDir ) ) - # - # - def onBrowseLibraryDir ( self ): - curDir = self.ui.lineEdit_lib.text() - newDir = QtGui.QFileDialog.getExistingDirectory( self, "Select Library Directory", curDir ) - if newDir != '' : - self.ui.lineEdit_lib.setText( normPath( newDir ) ) - # - # - def onBrowseNodesDir ( self ): - curDir = self.ui.lineEdit_nodes.text() - newDir = QtGui.QFileDialog.getExistingDirectory( self, "Select Nodes Directory", curDir ) - if newDir != '' : - self.ui.lineEdit_nodes.setText( normPath( newDir ) ) - # - # - def onBrowseIncludesDir ( self ): - curDir = self.ui.lineEdit_inc.text() - newDir = QtGui.QFileDialog.getExistingDirectory( self, "Select Includes Directory", curDir ) - if newDir != '' : - self.ui.lineEdit_inc.setText( normPath( newDir ) ) - # - # - def onBrowseShadersDir ( self ): - curDir = self.ui.lineEdit_shaders.text() - newDir = QtGui.QFileDialog.getExistingDirectory( self, "Select Shaders Directory", curDir ) - if newDir != '' : - self.ui.lineEdit_shaders.setText( normPath( newDir ) ) - # - # - def onBrowseTexturesDir ( self ): - curDir = self.ui.lineEdit_textures.text() - newDir = QtGui.QFileDialog.getExistingDirectory( self, "Select Directory", curDir ) - if newDir != '' : - self.ui.lineEdit_textures.setText( normPath( newDir ) ) - # - # - def onBrowseArchivesDir ( self ): - curDir = self.ui.lineEdit_archives.text() - newDir = QtGui.QFileDialog.getExistingDirectory( self, "Select Directory", curDir ) - if newDir != '' : - self.ui.lineEdit_archives.setText( normPath( newDir ) ) - # - # - def reject ( self ): - self.done( 0 ) - # - # - def accept ( self ): - #print ">> SettingsSetup: accept" - - temp_dir = normPath ( self.ui.lineEdit_temp.text() ) - inc_dir = normPath ( self.ui.lineEdit_inc.text() ) - lib_dir = normPath ( self.ui.lineEdit_lib.text() ) - nodes_dir = normPath ( self.ui.lineEdit_nodes.text() ) - - shaders_dir = normPath ( self.ui.lineEdit_shaders.text() ) - textures_dir = normPath ( self.ui.lineEdit_textures.text() ) - archives_dir = normPath ( self.ui.lineEdit_archives.text() ) - - self.app_settings.setValue( 'temp', temp_dir ) - self.app_settings.setValue( 'include', inc_dir ) - self.app_settings.setValue( 'lib', lib_dir ) - self.app_settings.setValue( 'nodes', nodes_dir ) - self.app_settings.setValue( 'shaders', shaders_dir ) - self.app_settings.setValue( 'texture', textures_dir ) - self.app_settings.setValue( 'archive', archives_dir ) - - app_global_vars[ 'TempPath' ] = temp_dir - - app_global_vars[ 'LibPath' ] = lib_dir - app_global_vars[ 'NodesPath' ] = nodes_dir - - app_global_vars[ 'IncludePath' ] = inc_dir - app_global_vars[ 'ShaderPath' ] = shaders_dir - app_global_vars[ 'TexturePath' ] = textures_dir - - app_global_vars[ 'TextureSearchPath' ] = sanitizeSearchPath ( textures_dir ) - app_global_vars[ 'ShaderSearchPath' ] = sanitizeSearchPath ( shaders_dir ) - app_global_vars[ 'ArchiveSearchPath' ] = sanitizeSearchPath ( archives_dir ) - - createMissingDirs ( [temp_dir, lib_dir, nodes_dir, shaders_dir, textures_dir, archives_dir] ) # inc_dir, - - #self.emit( QtCore.SIGNAL( "accepted()" ) ) - self.done( 0 ) \ No newline at end of file + self.app_settings = app_settings + + #self.debugPrint() + self.buildGui() + # + # + def buildGui ( self ): + # build the gui created with QtDesigner + self.ui = Ui_SettingsSetup ( ) + self.ui.setupUi ( self ) + + ##font = QtGui.QFont() + ##if( sys.platform == 'win32' ) : + # Runing on windows, override font sizes from Designer to default + ## font.setPointSize(8) + ##else : + ## font.setPointSize(10) + + self.ui.lineEdit_temp.setText( self.app_settings.value('temp').toString() ) + self.ui.lineEdit_inc.setText( self.app_settings.value('include').toString() ) + self.ui.lineEdit_lib.setText( self.app_settings.value('lib').toString() ) + self.ui.lineEdit_nodes.setText( self.app_settings.value('nodes').toString() ) + self.ui.lineEdit_shaders.setText( self.app_settings.value('shaders').toString() ) + self.ui.lineEdit_textures.setText( self.app_settings.value('texture').toString() ) + self.ui.lineEdit_archives.setText( self.app_settings.value('archive').toString() ) + # + # + def onBrowseTempDir ( self ): + # + curDir = self.ui.lineEdit_temp.text() + newDir = QtModule.QFileDialog.getExistingDirectory( self, "Select Temp Directory", curDir ) + if newDir != '' : + self.ui.lineEdit_temp.setText( normPath( newDir ) ) + # + # + def onBrowseLibraryDir ( self ): + # + curDir = self.ui.lineEdit_lib.text() + newDir = QtModule.QFileDialog.getExistingDirectory( self, "Select Library Directory", curDir ) + if newDir != '' : + self.ui.lineEdit_lib.setText( normPath( newDir ) ) + # + # + def onBrowseNodesDir ( self ): + # + curDir = self.ui.lineEdit_nodes.text() + newDir = QtModule.QFileDialog.getExistingDirectory( self, "Select Nodes Directory", curDir ) + if newDir != '' : + self.ui.lineEdit_nodes.setText( normPath( newDir ) ) + # + # + def onBrowseIncludesDir ( self ): + # + curDir = self.ui.lineEdit_inc.text() + newDir = QtModule.QFileDialog.getExistingDirectory( self, "Select Includes Directory", curDir ) + if newDir != '' : + self.ui.lineEdit_inc.setText( normPath( newDir ) ) + # + # + def onBrowseShadersDir ( self ): + # + curDir = self.ui.lineEdit_shaders.text() + newDir = QtModule.QFileDialog.getExistingDirectory( self, "Select Shaders Directory", curDir ) + if newDir != '' : + self.ui.lineEdit_shaders.setText( normPath( newDir ) ) + # + # + def onBrowseTexturesDir ( self ): + # + curDir = self.ui.lineEdit_textures.text() + newDir = QtModule.QFileDialog.getExistingDirectory( self, "Select Directory", curDir ) + if newDir != '' : + self.ui.lineEdit_textures.setText( normPath( newDir ) ) + # + # + def onBrowseArchivesDir ( self ): + # + curDir = self.ui.lineEdit_archives.text() + newDir = QtModule.QFileDialog.getExistingDirectory( self, "Select Directory", curDir ) + if newDir != '' : + self.ui.lineEdit_archives.setText( normPath( newDir ) ) + # + # + def reject ( self ): + self.done( 0 ) + # + # + def accept ( self ): + #print ">> SettingsSetup: accept" + + temp_dir = normPath ( self.ui.lineEdit_temp.text() ) + inc_dir = normPath ( self.ui.lineEdit_inc.text() ) + lib_dir = normPath ( self.ui.lineEdit_lib.text() ) + nodes_dir = normPath ( self.ui.lineEdit_nodes.text() ) + + shaders_dir = normPath ( self.ui.lineEdit_shaders.text() ) + textures_dir = normPath ( self.ui.lineEdit_textures.text() ) + archives_dir = normPath ( self.ui.lineEdit_archives.text() ) + + self.app_settings.setValue( 'temp', temp_dir ) + self.app_settings.setValue( 'include', inc_dir ) + self.app_settings.setValue( 'lib', lib_dir ) + self.app_settings.setValue( 'nodes', nodes_dir ) + self.app_settings.setValue( 'shaders', shaders_dir ) + self.app_settings.setValue( 'texture', textures_dir ) + self.app_settings.setValue( 'archive', archives_dir ) + + app_global_vars[ 'TempPath' ] = temp_dir + + app_global_vars[ 'LibPath' ] = lib_dir + app_global_vars[ 'NodesPath' ] = nodes_dir + + app_global_vars[ 'IncludePath' ] = inc_dir + app_global_vars[ 'ShaderPath' ] = shaders_dir + app_global_vars[ 'TexturePath' ] = textures_dir + + app_global_vars[ 'TextureSearchPath' ] = sanitizeSearchPath ( textures_dir ) + app_global_vars[ 'ShaderSearchPath' ] = sanitizeSearchPath ( shaders_dir ) + app_global_vars[ 'ArchiveSearchPath' ] = sanitizeSearchPath ( archives_dir ) + + createMissingDirs ( [temp_dir, lib_dir, nodes_dir, shaders_dir, textures_dir, archives_dir] ) # inc_dir, + + #self.emit( QtCore.SIGNAL( "accepted()" ) ) + self.done( 0 ) \ No newline at end of file diff --git a/gui/ViewComputedCodeDialog.py b/gui/ViewComputedCodeDialog.py index 6600557..09e287f 100644 --- a/gui/ViewComputedCodeDialog.py +++ b/gui/ViewComputedCodeDialog.py @@ -8,43 +8,49 @@ Dialog for managing node code """ -import os, sys -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui from global_vars import app_global_vars, DEBUG_MODE, VALID_RIB_NODE_TYPES, VALID_RSL_NODE_TYPES, VALID_RSL_SHADER_TYPES from nodeEditor.nodeCodeEditor import NodeCodeEditor from ui_viewComputedCodeDialog import Ui_ViewComputedCodeDialog + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + # # ViewComputedCodeDialog # -class ViewComputedCodeDialog ( QtGui.QDialog ) : - # - # __init__ - # - def __init__ ( self, node = None ): - # - QtGui.QDialog.__init__ ( self ) +class ViewComputedCodeDialog ( QtModule.QDialog ) : + # + # __init__ + # + def __init__ ( self, node = None ): + # + QtModule.QDialog.__init__ ( self ) - self.node = node - self.code = self.getComputedCode ( node ) - self.buildGui () - - # - # buildGui - # - def buildGui ( self ) : - # build the gui created with QtDesigner - self.ui = Ui_ViewComputedCodeDialog () - self.ui.setupUi ( self ) - self.ui.codeEdit.setNodeCode ( self.code, 'SL', readOnly = True ) - # - # getComputedCode - # - def getComputedCode ( self, node ) : - # - computedCode = None - if node is not None : - computedCode = node.getComputedCode ( CodeOnly = True ) - - return computedCode \ No newline at end of file + self.node = node + self.code = self.getComputedCode ( node ) + self.buildGui () + + # + # buildGui + # + def buildGui ( self ) : + # build the gui created with QtDesigner + self.ui = Ui_ViewComputedCodeDialog () + self.ui.setupUi ( self ) + self.ui.codeEdit.setNodeCode ( self.code, 'SL', readOnly = True ) + # + # getComputedCode + # + def getComputedCode ( self, node ) : + # + computedCode = None + if node is not None : + computedCode = node.getComputedCode ( CodeOnly = True ) + + return computedCode diff --git a/gui/exportShader/ExportShaderDialog.py b/gui/exportShader/ExportShaderDialog.py index 330e93d..d6134f2 100644 --- a/gui/exportShader/ExportShaderDialog.py +++ b/gui/exportShader/ExportShaderDialog.py @@ -7,9 +7,8 @@ Dialog for export node as SL shader """ -import os, sys -from PyQt4 import QtCore, QtGui -from PyQt4.QtCore import QVariant +from core.mePyQt import QtCore, QtGui +#from PyQt4.QtCore import QVariant from core.meCommon import * from global_vars import app_global_vars, DEBUG_MODE @@ -20,284 +19,291 @@ from core.node import Node from ui_exportShaderDialog import Ui_ExportShaderDialog + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets # # ExportShaderDialog # -class ExportShaderDialog ( QtGui.QDialog ) : - # - # __init__ - # - def __init__ ( self, node ) : - # - QtGui.QDialog.__init__ ( self ) - - self.editNode = node - self.computed_code = None +class ExportShaderDialog ( QtModule.QDialog ) : + # + # __init__ + # + def __init__ ( self, node ) : + # + QtModule.QDialog.__init__ ( self ) + + self.editNode = node + self.computed_code = None - self.buildGui () - - # !!!!! - # temporary disable NodeParamEditor param name field - # because after param name changing, shader code also have to be changed - # !!!!! - self.ui.param.ui.name_lineEdit.setEnabled ( False ) - - self.connectSignals () - - self.ui.btn_view.setDefault ( False ) - self.ui.chk_save_changes.setEnabled ( False ) # !!! temporary all changes to nodes are saved - # - # connectSignals - # - def connectSignals ( self ) : - # QtCore.QObject - QtCore.QObject.connect ( self.ui.list_nodes, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onNodeChanged ) - QtCore.QObject.connect ( self.ui.list_inputs, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onInputParamChanged ) - QtCore.QObject.connect ( self.ui.list_outputs, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onOutputParamChanged ) - QtCore.QObject.connect ( self.ui.node, QtCore.SIGNAL ( 'changeNodeLabel' ), self.onRenameNodeLabel ) - - QtCore.QObject.connect ( self.ui.param, QtCore.SIGNAL ( 'changeParamLabel' ), self.onParamChange ) - QtCore.QObject.connect ( self.ui.param, QtCore.SIGNAL ( 'changeParamIsShader' ), self.onParamChange ) - QtCore.QObject.connect ( self.ui.param, QtCore.SIGNAL ( 'changeParamDetail' ), self.onParamChange ) - QtCore.QObject.connect ( self.ui.param, QtCore.SIGNAL ( 'changeParamProvider' ), self.onParamChange ) - QtCore.QObject.connect ( self.ui.param, QtCore.SIGNAL ( 'changeParamValue' ), self.onParamChange ) - # - # disconnectSignals - # - def disconnectSignals ( self ) : - # - QtCore.QObject.disconnect ( self.ui.list_nodes, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onNodeChanged ) - QtCore.QObject.disconnect ( self.ui.list_inputs, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onInputParamChanged ) - QtCore.QObject.disconnect ( self.ui.list_outputs, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onOutputParamChanged ) - QtCore.QObject.disconnect ( self.ui.node, QtCore.SIGNAL ( 'changeNodeLabel' ), self.onRenameNodeLabel ) - - QtCore.QObject.disconnect ( self.ui.param, QtCore.SIGNAL ( 'changeParamLabel' ), self.onParamChange ) - QtCore.QObject.disconnect ( self.ui.param, QtCore.SIGNAL ( 'changeParamIsShader' ), self.onParamChange ) - QtCore.QObject.disconnect ( self.ui.param, QtCore.SIGNAL ( 'changeParamDetail' ), self.onParamChange ) - QtCore.QObject.disconnect ( self.ui.param, QtCore.SIGNAL ( 'changeParamProvider' ), self.onParamChange ) - QtCore.QObject.disconnect ( self.ui.param, QtCore.SIGNAL ( 'changeParamValue' ), self.onParamChange ) - # - # buildGui - # - def buildGui ( self ) : - # build the gui created with QtDesigner - self.ui = Ui_ExportShaderDialog () - self.ui.setupUi ( self ) - if self.editNode is not None : - # - self.setWindowTitle ( 'ExportShader: %s (%s)' % ( self.editNode.label, self.editNode.name ) ) - - separator = QtGui.QListWidgetItem ( '---- exported shader ----' ) - separator.setFlags ( QtCore.Qt.NoItemFlags ) - self.ui.list_nodes.addItem ( separator ) - - item = QtGui.QListWidgetItem ( self.editNode.label ) - node_var = QVariant ( self.editNode ) - item.setData ( QtCore.Qt.UserRole + 1, node_var ) - self.ui.list_nodes.addItem ( item ) + self.buildGui () + + # !!!!! + # temporary disable NodeParamEditor param name field + # because after param name changing, shader code also have to be changed + # !!!!! + self.ui.param.ui.name_lineEdit.setEnabled ( False ) + + self.connectSignals () + + self.ui.btn_view.setDefault ( False ) + self.ui.chk_save_changes.setEnabled ( False ) # !!! temporary all changes to nodes are saved + # + # connectSignals + # + def connectSignals ( self ) : + # QtCore.QObject + QtCore.QObject.connect ( self.ui.list_nodes, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onNodeChanged ) + QtCore.QObject.connect ( self.ui.list_inputs, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onInputParamChanged ) + QtCore.QObject.connect ( self.ui.list_outputs, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onOutputParamChanged ) + QtCore.QObject.connect ( self.ui.node, QtCore.SIGNAL ( 'changeNodeLabel' ), self.onRenameNodeLabel ) + + QtCore.QObject.connect ( self.ui.param, QtCore.SIGNAL ( 'changeParamLabel' ), self.onParamChange ) + QtCore.QObject.connect ( self.ui.param, QtCore.SIGNAL ( 'changeParamIsShader' ), self.onParamChange ) + QtCore.QObject.connect ( self.ui.param, QtCore.SIGNAL ( 'changeParamDetail' ), self.onParamChange ) + QtCore.QObject.connect ( self.ui.param, QtCore.SIGNAL ( 'changeParamProvider' ), self.onParamChange ) + QtCore.QObject.connect ( self.ui.param, QtCore.SIGNAL ( 'changeParamValue' ), self.onParamChange ) + # + # disconnectSignals + # + def disconnectSignals ( self ) : + # + QtCore.QObject.disconnect ( self.ui.list_nodes, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onNodeChanged ) + QtCore.QObject.disconnect ( self.ui.list_inputs, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onInputParamChanged ) + QtCore.QObject.disconnect ( self.ui.list_outputs, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onOutputParamChanged ) + QtCore.QObject.disconnect ( self.ui.node, QtCore.SIGNAL ( 'changeNodeLabel' ), self.onRenameNodeLabel ) + + QtCore.QObject.disconnect ( self.ui.param, QtCore.SIGNAL ( 'changeParamLabel' ), self.onParamChange ) + QtCore.QObject.disconnect ( self.ui.param, QtCore.SIGNAL ( 'changeParamIsShader' ), self.onParamChange ) + QtCore.QObject.disconnect ( self.ui.param, QtCore.SIGNAL ( 'changeParamDetail' ), self.onParamChange ) + QtCore.QObject.disconnect ( self.ui.param, QtCore.SIGNAL ( 'changeParamProvider' ), self.onParamChange ) + QtCore.QObject.disconnect ( self.ui.param, QtCore.SIGNAL ( 'changeParamValue' ), self.onParamChange ) + # + # buildGui + # + def buildGui ( self ) : + # build the gui created with QtDesigner + self.ui = Ui_ExportShaderDialog () + self.ui.setupUi ( self ) + if self.editNode is not None : + # + self.setWindowTitle ( 'ExportShader: %s (%s)' % ( self.editNode.label, self.editNode.name ) ) + + separator = QtModule.QListWidgetItem ( '---- exported shader ----' ) + separator.setFlags ( QtCore.Qt.NoItemFlags ) + self.ui.list_nodes.addItem ( separator ) + + item = QtModule.QListWidgetItem ( self.editNode.label ) + node_var = QVariant ( self.editNode ) + item.setData ( QtCore.Qt.UserRole + 1, node_var ) + self.ui.list_nodes.addItem ( item ) - separator = QtGui.QListWidgetItem ( '---- connected nodes ----' ) - separator.setFlags ( QtCore.Qt.NoItemFlags ) - self.ui.list_nodes.addItem ( separator ) + separator = QtModule.QListWidgetItem ( '---- connected nodes ----' ) + separator.setFlags ( QtCore.Qt.NoItemFlags ) + self.ui.list_nodes.addItem ( separator ) - #childrenList = [] - #childrenList = self.editNode.getChildrenList ( childrenList ) - self.computed_code = self.editNode.getComputedCode ( CodeOnly = True ) - print '*** (%s) children list: ' % self.editNode.label - for node in self.editNode.visitedNodes : #childrenList : - print '* (%s)' % node.label - item = QtGui.QListWidgetItem ( node.label ) - item.setData ( QtCore.Qt.UserRole + 1, QVariant ( node ) ) - self.ui.list_nodes.addItem ( item ) - # - # updateComputedParams - # - def updateComputedParams ( self ) : - # - self.ui.list_inputs.clear () - self.ui.list_outputs.clear () - self.computed_code = self.editNode.getComputedCode ( CodeOnly = True ) - # setup input params list - for ( param, node ) in self.editNode.computedInputParamsList : - item = QtGui.QListWidgetItem ( ( node.getParamDeclaration ( param )).rstrip ( ';\n' ) ) - item.setData ( QtCore.Qt.UserRole + 1, QVariant ( param ) ) - item.setData ( QtCore.Qt.UserRole + 2, QVariant ( node ) ) - self.ui.list_inputs.addItem ( item ) - # setup output params list - for ( param, node ) in self.editNode.computedOutputParamsList : - item = QtGui.QListWidgetItem ( ( 'output ' + node.getParamDeclaration ( param ) ).rstrip ( ';\n' ) ) - item.setData ( QtCore.Qt.UserRole + 1, QVariant ( param ) ) - item.setData ( QtCore.Qt.UserRole + 2, QVariant ( node ) ) - self.ui.list_outputs.addItem ( item ) - # - # updateNodeParams - # - def updateNodeParams ( self, node ) : - # - self.ui.list_inputs.clear () - self.ui.list_outputs.clear () - - linkedFont = QtGui.QFont () - linkedFont.setItalic ( True ) - linkedBrush = QtGui.QBrush () - linkedBrush.setColor ( QtCore.Qt.blue ) - # setup input params list - for param in node.inputParams : - item = QtGui.QListWidgetItem ( param.label ) - item.setData ( QtCore.Qt.UserRole + 1, QVariant ( param ) ) - item.setData ( QtCore.Qt.UserRole + 2, QVariant ( node ) ) - if node.isInputParamLinked ( param ) : - item.setFont ( linkedFont ) - item.setForeground ( linkedBrush ) - self.ui.list_inputs.addItem ( item ) - # setup output params list - for param in node.outputParams : - item = QtGui.QListWidgetItem ( param.label ) - item.setData ( QtCore.Qt.UserRole + 1, QVariant ( param ) ) - item.setData ( QtCore.Qt.UserRole + 2, QVariant ( node ) ) - if node.isOutputParamLinked ( param ) : - item.setFont ( linkedFont ) - item.setForeground ( linkedBrush ) - self.ui.list_outputs.addItem ( item ) - # - # onNodeChanged - # - def onNodeChanged ( self ) : - # - if DEBUG_MODE : print '>> ExportShaderDialog.onNodeChanged' - self.disconnectSignals () - item = self.ui.list_nodes.currentItem () - node = item.data ( QtCore.Qt.UserRole + 1 ).toPyObject () - print '* (%s) selected' % node.label - self.ui.node.setNode ( node ) - self.ui.prop_tabWidget.setCurrentIndex ( 0 ) + #childrenList = [] + #childrenList = self.editNode.getChildrenList ( childrenList ) + self.computed_code = self.editNode.getComputedCode ( CodeOnly = True ) + print '*** (%s) children list: ' % self.editNode.label + for node in self.editNode.visitedNodes : #childrenList : + print '* (%s)' % node.label + item = QtGui.QListWidgetItem ( node.label ) + item.setData ( QtCore.Qt.UserRole + 1, QVariant ( node ) ) + self.ui.list_nodes.addItem ( item ) + # + # updateComputedParams + # + def updateComputedParams ( self ) : + # + self.ui.list_inputs.clear () + self.ui.list_outputs.clear () + self.computed_code = self.editNode.getComputedCode ( CodeOnly = True ) + # setup input params list + for ( param, node ) in self.editNode.computedInputParamsList : + item = QtGui.QListWidgetItem ( ( node.getParamDeclaration ( param )).rstrip ( ';\n' ) ) + item.setData ( QtCore.Qt.UserRole + 1, QVariant ( param ) ) + item.setData ( QtCore.Qt.UserRole + 2, QVariant ( node ) ) + self.ui.list_inputs.addItem ( item ) + # setup output params list + for ( param, node ) in self.editNode.computedOutputParamsList : + item = QtGui.QListWidgetItem ( ( 'output ' + node.getParamDeclaration ( param ) ).rstrip ( ';\n' ) ) + item.setData ( QtCore.Qt.UserRole + 1, QVariant ( param ) ) + item.setData ( QtCore.Qt.UserRole + 2, QVariant ( node ) ) + self.ui.list_outputs.addItem ( item ) + # + # updateNodeParams + # + def updateNodeParams ( self, node ) : + # + self.ui.list_inputs.clear () + self.ui.list_outputs.clear () + + linkedFont = QtGui.QFont () + linkedFont.setItalic ( True ) + linkedBrush = QtGui.QBrush () + linkedBrush.setColor ( QtCore.Qt.blue ) + # setup input params list + for param in node.inputParams : + item = QtGui.QListWidgetItem ( param.label ) + item.setData ( QtCore.Qt.UserRole + 1, QVariant ( param ) ) + item.setData ( QtCore.Qt.UserRole + 2, QVariant ( node ) ) + if node.isInputParamLinked ( param ) : + item.setFont ( linkedFont ) + item.setForeground ( linkedBrush ) + self.ui.list_inputs.addItem ( item ) + # setup output params list + for param in node.outputParams : + item = QtModule.QListWidgetItem ( param.label ) + item.setData ( QtCore.Qt.UserRole + 1, QVariant ( param ) ) + item.setData ( QtCore.Qt.UserRole + 2, QVariant ( node ) ) + if node.isOutputParamLinked ( param ) : + item.setFont ( linkedFont ) + item.setForeground ( linkedBrush ) + self.ui.list_outputs.addItem ( item ) + # + # onNodeChanged + # + def onNodeChanged ( self ) : + # + if DEBUG_MODE : print '>> ExportShaderDialog.onNodeChanged' + self.disconnectSignals () + item = self.ui.list_nodes.currentItem () + node = item.data ( QtCore.Qt.UserRole + 1 ).toPyObject () + print '* (%s) selected' % node.label + self.ui.node.setNode ( node ) + self.ui.prop_tabWidget.setCurrentIndex ( 0 ) - if self.ui.list_nodes.currentRow () != 1 : - self.updateNodeParams ( node ) - self.ui.list_inputs.clear () - self.ui.list_outputs.clear () - - linkedFont = QtGui.QFont () - linkedFont.setItalic ( True ) - linkedBrush = QtGui.QBrush () - linkedBrush.setColor ( QtCore.Qt.blue ) - # setup input params list - for param in node.inputParams : - item = QtGui.QListWidgetItem ( param.label ) - item.setData ( QtCore.Qt.UserRole + 1, QVariant ( param ) ) - item.setData ( QtCore.Qt.UserRole + 2, QVariant ( node ) ) - if node.isInputParamLinked ( param ) : - item.setFont ( linkedFont ) - item.setForeground ( linkedBrush ) - self.ui.list_inputs.addItem ( item ) - - # setup output params list - for param in node.outputParams : - item = QtGui.QListWidgetItem ( param.label ) - item.setData ( QtCore.Qt.UserRole + 1, QVariant ( param ) ) - item.setData ( QtCore.Qt.UserRole + 2, QVariant ( node ) ) - if node.isOutputParamLinked ( param ) : - item.setFont ( linkedFont ) - item.setForeground ( linkedBrush ) - self.ui.list_outputs.addItem ( item ) - else : - self.updateComputedParams () - - self.connectSignals () - # - # onInputParamChanged - # - def onInputParamChanged ( self ) : - # - if DEBUG_MODE : print '>> ExportShaderDialog.onInputParamChanged' - item = self.ui.list_inputs.currentItem () - param = item.data ( QtCore.Qt.UserRole + 1 ).toPyObject () - node = item.data ( QtCore.Qt.UserRole + 2 ).toPyObject () - #print '* (%s) selected' % param.label - self.ui.param.setParam ( param ) - self.ui.node.setNode ( node ) - self.ui.prop_tabWidget.setCurrentIndex ( 1 ) - # - # onOutputParamChanged - # - def onOutputParamChanged ( self ) : - # - if DEBUG_MODE : print '>> ExportShaderDialog.onOutputParamChanged' - item = self.ui.list_outputs.currentItem () - param = item.data ( QtCore.Qt.UserRole + 1 ).toPyObject () - node = item.data ( QtCore.Qt.UserRole + 2 ).toPyObject () - #print '* (%s) selected' % self.param.label - self.ui.param.setParam ( param ) - self.ui.node.setNode ( node ) - self.ui.prop_tabWidget.setCurrentIndex ( 1 ) - # - # updateGui - # - def updateGui ( self ) : - # - if self.editNode is not None : - if DEBUG_MODE : print '>> ExportShaderDialog.updateGui' - self.disconnectSignals () - self.connectSignals () - # - # onRenameNodeLabel - # - def onRenameNodeLabel ( self, oldName, newName ) : - # - editNode = self.ui.node.editNode - for i in range ( self.ui.list_nodes.count () ) : - item = self.ui.list_nodes.item ( i ) - node = item.data ( QtCore.Qt.UserRole + 1 ).toPyObject () - if node is not None and node == editNode : - item.setText ( editNode.label ) - - if self.ui.list_nodes.currentRow () == 1 : - self.updateComputedParams () - # - # onParamChange - # - def onParamChange ( self ) : - # - param = self.ui.param.param - node = self.ui.node.editNode - - if self.ui.list_nodes.currentRow () == 1 : - self.updateComputedParams () - else : - self.updateNodeParams ( node ) - # - # onViewCode - # - def onViewCode ( self ) : ViewComputedCodeDialog ( self.editNode ).exec_ () + if self.ui.list_nodes.currentRow () != 1 : + self.updateNodeParams ( node ) + self.ui.list_inputs.clear () + self.ui.list_outputs.clear () + + linkedFont = QtGui.QFont () + linkedFont.setItalic ( True ) + linkedBrush = QtGui.QBrush () + linkedBrush.setColor ( QtCore.Qt.blue ) + # setup input params list + for param in node.inputParams : + item = QtModule.QListWidgetItem ( param.label ) + item.setData ( QtCore.Qt.UserRole + 1, QVariant ( param ) ) + item.setData ( QtCore.Qt.UserRole + 2, QVariant ( node ) ) + if node.isInputParamLinked ( param ) : + item.setFont ( linkedFont ) + item.setForeground ( linkedBrush ) + self.ui.list_inputs.addItem ( item ) + + # setup output params list + for param in node.outputParams : + item = QtModule.QListWidgetItem ( param.label ) + item.setData ( QtCore.Qt.UserRole + 1, QVariant ( param ) ) + item.setData ( QtCore.Qt.UserRole + 2, QVariant ( node ) ) + if node.isOutputParamLinked ( param ) : + item.setFont ( linkedFont ) + item.setForeground ( linkedBrush ) + self.ui.list_outputs.addItem ( item ) + else : + self.updateComputedParams () + + self.connectSignals () + # + # onInputParamChanged + # + def onInputParamChanged ( self ) : + # + if DEBUG_MODE : print '>> ExportShaderDialog.onInputParamChanged' + item = self.ui.list_inputs.currentItem () + param = item.data ( QtCore.Qt.UserRole + 1 ).toPyObject () + node = item.data ( QtCore.Qt.UserRole + 2 ).toPyObject () + #print '* (%s) selected' % param.label + self.ui.param.setParam ( param ) + self.ui.node.setNode ( node ) + self.ui.prop_tabWidget.setCurrentIndex ( 1 ) + # + # onOutputParamChanged + # + def onOutputParamChanged ( self ) : + # + if DEBUG_MODE : print '>> ExportShaderDialog.onOutputParamChanged' + item = self.ui.list_outputs.currentItem () + param = item.data ( QtCore.Qt.UserRole + 1 ).toPyObject () + node = item.data ( QtCore.Qt.UserRole + 2 ).toPyObject () + #print '* (%s) selected' % self.param.label + self.ui.param.setParam ( param ) + self.ui.node.setNode ( node ) + self.ui.prop_tabWidget.setCurrentIndex ( 1 ) + # + # updateGui + # + def updateGui ( self ) : + # + if self.editNode is not None : + if DEBUG_MODE : print '>> ExportShaderDialog.updateGui' + self.disconnectSignals () + self.connectSignals () + # + # onRenameNodeLabel + # + def onRenameNodeLabel ( self, oldName, newName ) : + # + editNode = self.ui.node.editNode + for i in range ( self.ui.list_nodes.count () ) : + item = self.ui.list_nodes.item ( i ) + node = item.data ( QtCore.Qt.UserRole + 1 ).toPyObject () + if node is not None and node == editNode : + item.setText ( editNode.label ) + + if self.ui.list_nodes.currentRow () == 1 : + self.updateComputedParams () + # + # onParamChange + # + def onParamChange ( self ) : + # + param = self.ui.param.param + node = self.ui.node.editNode + + if self.ui.list_nodes.currentRow () == 1 : + self.updateComputedParams () + else : + self.updateNodeParams ( node ) + # + # onViewCode + # + def onViewCode ( self ) : ViewComputedCodeDialog ( self.editNode ).exec_ () - # - # onExport - # - def onExport ( self ) : - # - saveName = os.path.join ( app_global_vars [ 'ProjectSources' ], self.editNode.getInstanceName () + '.sl' ) - typeFilter = 'Shader source files *.sl;;All files *.*;;' + # + # onExport + # + def onExport ( self ) : + # + import os + saveName = os.path.join ( app_global_vars [ 'ProjectSources' ], self.editNode.getInstanceName () + '.sl' ) + typeFilter = 'Shader source files *.sl;;All files *.*;;' - filename = str( QtGui.QFileDialog.getSaveFileName ( self, "Export shader code as", saveName, typeFilter ) ) - if filename != '' : - if DEBUG_MODE : print '-> Export shader code as %s' % filename - shaderCode = self.editNode.getComputedCode () - self.editNode.writeShader ( shaderCode, filename ) + filename = str( QtGui.QFileDialog.getSaveFileName ( self, "Export shader code as", saveName, typeFilter ) ) + if filename != '' : + if DEBUG_MODE : print '-> Export shader code as %s' % filename + shaderCode = self.editNode.getComputedCode () + self.editNode.writeShader ( shaderCode, filename ) - # - # Ignore default Enter press event - # - def keyPressEvent ( self, event ) : - # - #if DEBUG_MODE : print '>> ExportShaderDialog.keyPressEvent' - if event.key () == QtCore.Qt.Key_Enter or event.key () == QtCore.Qt.Key_Return : - event.ignore () - else: - QtGui.QDialog.keyPressEvent ( self, event ) - # - # accept - # - def accept ( self ) : - # - if DEBUG_MODE : print '>> ExportShaderDialog.accept' - self.done ( QtGui.QDialog.Accepted ) \ No newline at end of file + # + # Ignore default Enter press event + # + def keyPressEvent ( self, event ) : + # + #if DEBUG_MODE : print '>> ExportShaderDialog.keyPressEvent' + if event.key () == QtCore.Qt.Key_Enter or event.key () == QtCore.Qt.Key_Return : + event.ignore () + else: + QtModule.QDialog.keyPressEvent ( self, event ) + # + # accept + # + def accept ( self ) : + # + if DEBUG_MODE : print '>> ExportShaderDialog.accept' + self.done ( QtModule.QDialog.Accepted ) \ No newline at end of file diff --git a/gui/exportShader/ui_exportShaderDialog.py b/gui/exportShader/ui_exportShaderDialog.py index 48e16df..3835a27 100644 --- a/gui/exportShader/ui_exportShaderDialog.py +++ b/gui/exportShader/ui_exportShaderDialog.py @@ -7,7 +7,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 diff --git a/gui/imageViewWidget.py b/gui/imageViewWidget.py index 6a4a745..94caa63 100644 --- a/gui/imageViewWidget.py +++ b/gui/imageViewWidget.py @@ -1,156 +1,161 @@ -#=============================================================================== -# imageViewWidget.py -# -# -# -#=============================================================================== +""" -import os, sys -from PyQt4 import QtCore, QtGui + imageViewWidget.py -from PyQt4.QtCore import QDir, QString, QModelIndex -from PyQt4.QtGui import QFileSystemModel -from PyQt4.QtGui import QFileIconProvider +""" +from core.mePyQt import QtCore, QtGui + +#from PyQt4.QtCore import QDir, QString, QModelIndex +#from PyQt4.QtGui import QFileSystemModel +#from PyQt4.QtGui import QFileIconProvider from ui_imageViewWidget import Ui_imageViewWidget import gui.ui_settings as UI from core.node import Node from core.nodeLibrary import NodeLibrary + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + # # ImageViewWidget # -class ImageViewWidget ( QtGui.QWidget ) : - # - # __init__ - # - def __init__ ( self ) : - # - QtGui.QWidget.__init__ ( self ) - - # This is always the same - self.ui = Ui_imageViewWidget () - self.ui.setupUi ( self ) - - self.ui.selector.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) - self.ui.selector.setMaximumSize ( QtCore.QSize( UI.MAX, UI.COMBO_HEIGHT ) ) - - self.imageNodes = [] - - #self.ui.treeView.setDragEnabled ( True ) - #self.ui.treeView.setRootIsDecorated( True ) - - QtCore.QObject.connect ( self.ui.imageArea, QtCore.SIGNAL ( 'mouseDoubleClickEvent' ), self.updateViewer ) - QtCore.QObject.connect ( self.ui.selector, QtCore.SIGNAL ( 'currentIndexChanged(int)' ), self.onViewerChanged ) - #QtCore.QObject.connect( self.ui, QtCore.SIGNAL( 'paramChanged()' ), self.onParamChanged ) - - #self.updateGui() - #self.emit( QtCore.SIGNAL( 'onGfxNodeParamChanged(QObject,QObject)' ), self, param.name ) - # - # currentImageNode - # - def currentImageNode ( self ) : - gfxNode = None - idx = self.ui.selector.currentIndex () - if len ( self.imageNodes ) > 0 : - gfxNode = self.imageNodes [ idx ] - return gfxNode - # - # addViewer - # - def addViewer ( self, gfxNode ) : - # - self.imageNodes.append ( gfxNode ) - self.ui.selector.addItem ( gfxNode.node.label ) - # - # removeAllViewers - # - def removeAllViewers ( self ) : - # - self.imageNodes = [] - self.ui.selector.clear() - # - # removeViewer - # - def removeViewer ( self, gfxNode ) : - # - for i in range ( 0, len ( self.imageNodes ) ) : - if gfxNode == self.imageNodes [ i ] : - self.imageNodes.pop ( i ) - self.ui.selector.removeItem ( i ) - #QtCore.QObject.disconnect ( gfxNode.node, QtCore.SIGNAL( 'onNodeParamChanged(QObject,QObject)' ), self.onNodeParamChanged ) - break - # - # onViewerChanged - # - def onViewerChanged ( self, idx ) : - # - if len ( self.imageNodes ) > 0 : - print ">> ImageViewWidget.onViewerChanged to %s" % self.imageNodes [ idx ].node.label - #QtCore.QObject.connect( self.imageNodes[ idx ].node, QtCore.SIGNAL( 'onNodeParamChanged(QObject,QObject)' ), self.onNodeParamChanged ) - self.updateViewer ( compute = False ) - # - # updateViewer - # - def updateViewer ( self, compute = True ) : - # - print ">> ImageViewWidget.updateViewer" - RenderViewMode = False - idx = self.ui.selector.currentIndex () - if len ( self.imageNodes ) > 0 : - gfxNode = self.imageNodes [ idx ] - print ">> ImageViewWidget.getImageName on %s" % gfxNode.node.label - - imageInputParam = gfxNode.node.getInputParamByName ( 'image' ) - if imageInputParam is not None : - if gfxNode.node.isInputParamLinked ( imageInputParam ): - link = gfxNode.node.inputLinks [ imageInputParam ] - displayParam = link.srcNode.getInputParamByName ( 'DisplayDriver' ) - if displayParam is not None : - print '>> Display driver = %s' % displayParam.value - if displayParam.value != 'tiff' : - RenderViewMode = True - - if compute : - imageName = gfxNode.node.computeNode () - else : - imageName = gfxNode.node.imageName - - print ">> ImageViewWidget: imageName = %s" % imageName - - if not RenderViewMode : - self.ui.imageArea.setImage ( imageName ) - - #imageParam = None - #for param in gfxNode.node.inputParams : - # if param.name == 'image' : - # imageParam = param - # break - #if imageParam is not None : - # print ">> ImageViewWidget: image = %s" % imageParam.value - # self.ui.imageArea.setImage ( imageParam.value ) - # - # autoUpdate - # - def autoUpdate ( self ) : return self.ui.chk_auto.isChecked () - # - # onNodeParamChanged - # - def onNodeParamChanged ( self, node, param ) : - # - print ">> ImageViewWidget.onNodeParamChanged %s %s" % ( node.label, param.name ) - if node == self.currentImageNode().node : - self.updateViewer () - # - # onNodeLabelChanged - # - def onNodeLabelChanged ( self, gfxNode, newLabel ) : - # - print ">> ImageViewWidget.onNodeLabelChanged %s %s" % ( gfxNode.node.label, newLabel ) - i = 0 - for i in range ( len ( self.imageNodes ) ) : - if gfxNode == self.imageNodes [ i ] : - self.ui.selector.setItemText ( i, newLabel ) - break - i += 1 +class ImageViewWidget ( QtModule.QWidget ) : + # + # __init__ + # + def __init__ ( self ) : + # + QtModule.QWidget.__init__ ( self ) + + # This is always the same + self.ui = Ui_imageViewWidget () + self.ui.setupUi ( self ) + + self.ui.selector.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) + self.ui.selector.setMaximumSize ( QtCore.QSize( UI.MAX, UI.COMBO_HEIGHT ) ) + + self.imageNodes = [] + + #self.ui.treeView.setDragEnabled ( True ) + #self.ui.treeView.setRootIsDecorated( True ) + + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.connect ( self.ui.imageArea, QtCore.SIGNAL ( 'mouseDoubleClickEvent' ), self.updateViewer ) + QtCore.QObject.connect ( self.ui.selector, QtCore.SIGNAL ( 'currentIndexChanged(int)' ), self.onViewerChanged ) + #QtCore.QObject.connect( self.ui, QtCore.SIGNAL( 'paramChanged()' ), self.onParamChanged ) + + #self.updateGui() + #self.emit( QtCore.SIGNAL( 'onGfxNodeParamChanged(QObject,QObject)' ), self, param.name ) + # + # currentImageNode + # + def currentImageNode ( self ) : + gfxNode = None + idx = self.ui.selector.currentIndex () + if len ( self.imageNodes ) > 0 : + gfxNode = self.imageNodes [ idx ] + return gfxNode + # + # addViewer + # + def addViewer ( self, gfxNode ) : + # + self.imageNodes.append ( gfxNode ) + self.ui.selector.addItem ( gfxNode.node.label ) + # + # removeAllViewers + # + def removeAllViewers ( self ) : + # + self.imageNodes = [] + self.ui.selector.clear() + # + # removeViewer + # + def removeViewer ( self, gfxNode ) : + # + for i in range ( 0, len ( self.imageNodes ) ) : + if gfxNode == self.imageNodes [ i ] : + self.imageNodes.pop ( i ) + self.ui.selector.removeItem ( i ) + #QtCore.QObject.disconnect ( gfxNode.node, QtCore.SIGNAL( 'onNodeParamChanged(QObject,QObject)' ), self.onNodeParamChanged ) + break + # + # onViewerChanged + # + def onViewerChanged ( self, idx ) : + # + if len ( self.imageNodes ) > 0 : + print ">> ImageViewWidget.onViewerChanged to %s" % self.imageNodes [ idx ].node.label + #QtCore.QObject.connect( self.imageNodes[ idx ].node, QtCore.SIGNAL( 'onNodeParamChanged(QObject,QObject)' ), self.onNodeParamChanged ) + self.updateViewer ( compute = False ) + # + # updateViewer + # + def updateViewer ( self, compute = True ) : + # + print ">> ImageViewWidget.updateViewer" + RenderViewMode = False + idx = self.ui.selector.currentIndex () + if len ( self.imageNodes ) > 0 : + gfxNode = self.imageNodes [ idx ] + print ">> ImageViewWidget.getImageName on %s" % gfxNode.node.label + + imageInputParam = gfxNode.node.getInputParamByName ( 'image' ) + if imageInputParam is not None : + if gfxNode.node.isInputParamLinked ( imageInputParam ): + link = gfxNode.node.inputLinks [ imageInputParam ] + displayParam = link.srcNode.getInputParamByName ( 'DisplayDriver' ) + if displayParam is not None : + print '>> Display driver = %s' % displayParam.value + if displayParam.value != 'tiff' : + RenderViewMode = True + + if compute : + imageName = gfxNode.node.computeNode () + else : + imageName = gfxNode.node.imageName + + print ">> ImageViewWidget: imageName = %s" % imageName + + if not RenderViewMode : + self.ui.imageArea.setImage ( imageName ) + + #imageParam = None + #for param in gfxNode.node.inputParams : + # if param.name == 'image' : + # imageParam = param + # break + #if imageParam is not None : + # print ">> ImageViewWidget: image = %s" % imageParam.value + # self.ui.imageArea.setImage ( imageParam.value ) + # + # autoUpdate + # + def autoUpdate ( self ) : return self.ui.chk_auto.isChecked () + # + # onNodeParamChanged + # + def onNodeParamChanged ( self, node, param ) : + # + print ">> ImageViewWidget.onNodeParamChanged %s %s" % ( node.label, param.name ) + if node == self.currentImageNode().node : + self.updateViewer () + # + # onNodeLabelChanged + # + def onNodeLabelChanged ( self, gfxNode, newLabel ) : + # + print ">> ImageViewWidget.onNodeLabelChanged %s %s" % ( gfxNode.node.label, newLabel ) + i = 0 + for i in range ( len ( self.imageNodes ) ) : + if gfxNode == self.imageNodes [ i ] : + self.ui.selector.setItemText ( i, newLabel ) + break + i += 1 diff --git a/gui/meRendererSetup.py b/gui/meRendererSetup.py index bdaa9ed..5d7f953 100644 --- a/gui/meRendererSetup.py +++ b/gui/meRendererSetup.py @@ -11,203 +11,210 @@ Presets are stored in xml file """ -import os, sys -from PyQt4 import QtCore, QtGui, QtXml +from core.mePyQt import QtCore, QtGui, QtXml from ui_meRendererSetup import Ui_meRendererSetup + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + # # meRendererSetup # -class meRendererSetup ( QtGui.QDialog ) : - # - # __init__ - # - def __init__ ( self, rendererPreset ) : - # - QtGui.QDialog.__init__ ( self ) +class meRendererSetup ( QtModule.QDialog ) : + # + # __init__ + # + def __init__ ( self, rendererPreset ) : + # + QtModule.QDialog.__init__ ( self ) - self.rendererPreset = rendererPreset - self.labelsReady = False - self.buildGui () - # - # buildGui - # - def buildGui ( self ) : - # build the gui created with QtDesigner - self.ui = Ui_meRendererSetup () - self.ui.setupUi ( self ) - - font = QtGui.QFont () - if ( sys.platform == 'win32' ) : - # Runing on windows, override font sizes from Designer to default - font.setPointSize ( 8 ) - else : - font.setPointSize ( 10 ) - self.ui.labelPreset.setFont ( font ) - self.ui.listPreset.setFont ( font ) - self.ui.newButton.setFont ( font ) - self.ui.deleteButton.setFont ( font ) - self.ui.cancelButton.setFont ( font ) - self.ui.okButton.setFont ( font ) - self.ui.saveButton.setFont ( font ) - self.ui.tabs.setFont ( font ) - self.ui.labelName.setFont ( font ) - self.ui.labelCmd.setFont ( font ) - self.ui.labelFlags.setFont ( font ) - self.ui.labelCompiler.setFont ( font ) - self.ui.labelShaderInfo.setFont ( font ) - self.ui.labelDefines.setFont ( font ) - self.ui.labelShaderExt.setFont ( font ) - self.ui.labelShaderExt.setFont ( font ) - self.ui.labelTexMake.setFont ( font ) - self.ui.labelTexInfo.setFont ( font ) - self.ui.labelTexViewer.setFont ( font ) - self.ui.labelTexExt.setFont ( font ) + self.rendererPreset = rendererPreset + self.labelsReady = False + self.buildGui () + # + # buildGui + # + def buildGui ( self ) : + # build the gui created with QtDesigner + import sys + self.ui = Ui_meRendererSetup () + self.ui.setupUi ( self ) + + font = QtGui.QFont () + if ( sys.platform == 'win32' ) : + # Runing on windows, override font sizes from Designer to default + font.setPointSize ( 8 ) + else : + font.setPointSize ( 10 ) + self.ui.labelPreset.setFont ( font ) + self.ui.listPreset.setFont ( font ) + self.ui.newButton.setFont ( font ) + self.ui.deleteButton.setFont ( font ) + self.ui.cancelButton.setFont ( font ) + self.ui.okButton.setFont ( font ) + self.ui.saveButton.setFont ( font ) + self.ui.tabs.setFont ( font ) + self.ui.labelName.setFont ( font ) + self.ui.labelCmd.setFont ( font ) + self.ui.labelFlags.setFont ( font ) + self.ui.labelCompiler.setFont ( font ) + self.ui.labelShaderInfo.setFont ( font ) + self.ui.labelDefines.setFont ( font ) + self.ui.labelShaderExt.setFont ( font ) + self.ui.labelShaderExt.setFont ( font ) + self.ui.labelTexMake.setFont ( font ) + self.ui.labelTexInfo.setFont ( font ) + self.ui.labelTexViewer.setFont ( font ) + self.ui.labelTexExt.setFont ( font ) - self.labelsReady = False + self.labelsReady = False - for label in self.rendererPreset.getPresetNames () : - self.ui.listPreset.addItem ( label ) - - self.labelsReady = True - - presetName = self.rendererPreset.getCurrentPresetName () - idx = self.ui.listPreset.findText ( presetName ) - print ">> buildGui:: set current renderer to: %s (%d)" % ( presetName, idx ) - #self.ui.listPreset.setCurrentIndex ( -1 ) - self.ui.listPreset.setCurrentIndex ( idx ) - # - # getDataFromGui - # - def getDataFromGui ( self ) : - # ckeck if current_renderer still exists after deleting preset - #print ">> getDataFromGui:: current renderer to: %s" % self.rendererPreset.getCurrentPresetName() - - self.rendererPreset.currentPreset.RendererName = str ( self.ui.lineCmd.text () ) - self.rendererPreset.currentPreset.RendererFlags = str ( self.ui.lineFlags.text () ) - self.rendererPreset.currentPreset.ShaderCompiler = str ( self.ui.lineCompiler.text () ) - self.rendererPreset.currentPreset.ShaderInfo = str ( self.ui.lineShaderInfo.text () ) - self.rendererPreset.currentPreset.ShaderDefines = str ( self.ui.lineDefines.text () ) - self.rendererPreset.currentPreset.ShaderExt = str ( self.ui.lineShaderExt.text () ) - self.rendererPreset.currentPreset.TextureMake = str ( self.ui.lineTexMake.text () ) - self.rendererPreset.currentPreset.TextureInfo = str ( self.ui.lineTexInfo.text () ) - self.rendererPreset.currentPreset.TextureViewer = str ( self.ui.lineTexViewer.text () ) - self.rendererPreset.currentPreset.TextureExt = str ( self.ui.lineTexExt.text () ) - # - # onIndexChanged - # - def onIndexChanged ( self, name ) : - #print ">> onIndexChanged:: self.labelsReady == %d" % self.labelsReady - if ( self.labelsReady and name != '' ) : - # change current renderer - self.rendererPreset.setCurrentPresetByName ( str ( name ) ) - self.updateGui () - # - # updateGui - # - def updateGui ( self ) : - # redraw gui elements - #print ">> updateGui:: current renderer: %s" % self.rendererPreset.getCurrentPresetName() - if len ( self.rendererPreset.presetsList ) > 0 : - if self.rendererPreset.currentPreset is not None : - self.ui.lineName.setText ( self.rendererPreset.getCurrentPresetName () ) - self.ui.lineCmd.setText ( self.rendererPreset.currentPreset.RendererName ) - self.ui.lineFlags.setText ( self.rendererPreset.currentPreset.RendererFlags ) - self.ui.lineCompiler.setText ( self.rendererPreset.currentPreset.ShaderCompiler ) - self.ui.lineShaderInfo.setText ( self.rendererPreset.currentPreset.ShaderInfo ) - self.ui.lineDefines.setText ( self.rendererPreset.currentPreset.ShaderDefines ) - self.ui.lineShaderExt.setText ( self.rendererPreset.currentPreset.ShaderExt ) - self.ui.lineTexMake.setText ( self.rendererPreset.currentPreset.TextureMake ) - self.ui.lineTexInfo.setText ( self.rendererPreset.currentPreset.TextureInfo ) - self.ui.lineTexViewer.setText ( self.rendererPreset.currentPreset.TextureViewer ) - self.ui.lineTexExt.setText ( self.rendererPreset.currentPreset.TextureExt ) - self.ui.deleteButton.setEnabled ( True ) - self.ui.tab1.setEnabled ( True ) - self.ui.tab2.setEnabled ( True) - self.ui.tab3.setEnabled ( True ) - else : - self.ui.deleteButton.setEnabled ( False ) - self.ui.tab1.setEnabled ( False ) - self.ui.tab2.setEnabled ( False ) - self.ui.tab3.setEnabled ( False ) - self.ui.lineName.clear () - self.ui.lineCmd.clear () - self.ui.lineFlags.clear () - self.ui.lineCompiler.clear () - self.ui.lineShaderInfo.clear () - self.ui.lineDefines.clear () - self.ui.lineShaderExt.clear () - self.ui.lineTexMake.clear () - self.ui.lineTexInfo.clear () - self.ui.lineTexViewer.clear () - self.ui.lineTexExt.clear () - # - # onNewPreset - # - def onNewPreset ( self ) : - # create new empty preset - title = 'Untitled' - newLabel = title - #self.labelsReady = False - i = 0 - while True : - if newLabel in self.rendererPreset.getPresetNames () : - newLabel = title + str ( i ) - i += 1 - continue - else : - break; - self.rendererPreset.addPreset ( newLabel ) - #self.labelsReady = True - self.ui.listPreset.addItem ( newLabel ) - idx = self.ui.listPreset.findText ( newLabel ) - self.ui.listPreset.setCurrentIndex ( -1 ) - self.ui.listPreset.setCurrentIndex ( idx ) - #self.updateGui () - # - # onDeletePreset - # - def onDeletePreset ( self ) : - # delete existing preset - if len ( self.rendererPreset.presetsList ) > 0 : - msgBox = QtGui.QMessageBox () - ret = msgBox.warning ( self, 'Warning', "Do you really want to delete this preset?", - QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No ) - - if ret == QtGui.QMessageBox.Yes : - self.rendererPreset.deleteCurrentPreset () - i = self.ui.listPreset.currentIndex () - self.ui.listPreset.removeItem ( i ) - self.rendererPreset.setCurrentPresetByName ( str ( self.ui.listPreset.currentText () ) ) - # - # onEditLabel - # - def onEditLabel ( self ) : - # edit label - newLabel = str ( self.ui.lineName.text () ) - if ( self.rendererPreset.getCurrentPresetName () != newLabel ) : - if newLabel not in self.rendererPreset.getPresetNames () : - self.rendererPreset.renameCurrentPreset ( newLabel ) - # rename current preset ComboBox item to new label - i = self.ui.listPreset.currentIndex () - self.ui.listPreset.setItemText ( i, newLabel ) - else : - # this label already exists, so restore to previose - self.ui.lineName.setText ( self.rendererPreset.getCurrentPresetName () ) - # - # onSave - # - def onSave ( self ) : - # get data from Gui for current renderer before saving - self.getDataFromGui () - self.emit ( QtCore.SIGNAL ( 'presetChanged' ) ) - self.emit ( QtCore.SIGNAL ( 'savePreset' ) ) - #self.done ( 0 ) - # - # onSelect - # - def onSelect ( self ) : - # get data from Gui for current renderer before saving - self.getDataFromGui () - self.emit( QtCore.SIGNAL ( 'presetChanged' ) ) - self.done ( 0 ) + for label in self.rendererPreset.getPresetNames () : + self.ui.listPreset.addItem ( label ) + + self.labelsReady = True + + presetName = self.rendererPreset.getCurrentPresetName () + idx = self.ui.listPreset.findText ( presetName ) + print ">> buildGui:: set current renderer to: %s (%d)" % ( presetName, idx ) + #self.ui.listPreset.setCurrentIndex ( -1 ) + self.ui.listPreset.setCurrentIndex ( idx ) + # + # getDataFromGui + # + def getDataFromGui ( self ) : + # ckeck if current_renderer still exists after deleting preset + #print ">> getDataFromGui:: current renderer to: %s" % self.rendererPreset.getCurrentPresetName() + + self.rendererPreset.currentPreset.RendererName = str ( self.ui.lineCmd.text () ) + self.rendererPreset.currentPreset.RendererFlags = str ( self.ui.lineFlags.text () ) + self.rendererPreset.currentPreset.ShaderCompiler = str ( self.ui.lineCompiler.text () ) + self.rendererPreset.currentPreset.ShaderInfo = str ( self.ui.lineShaderInfo.text () ) + self.rendererPreset.currentPreset.ShaderDefines = str ( self.ui.lineDefines.text () ) + self.rendererPreset.currentPreset.ShaderExt = str ( self.ui.lineShaderExt.text () ) + self.rendererPreset.currentPreset.TextureMake = str ( self.ui.lineTexMake.text () ) + self.rendererPreset.currentPreset.TextureInfo = str ( self.ui.lineTexInfo.text () ) + self.rendererPreset.currentPreset.TextureViewer = str ( self.ui.lineTexViewer.text () ) + self.rendererPreset.currentPreset.TextureExt = str ( self.ui.lineTexExt.text () ) + # + # onIndexChanged + # + def onIndexChanged ( self, name ) : + #print ">> onIndexChanged:: self.labelsReady == %d" % self.labelsReady + if ( self.labelsReady and name != '' ) : + # change current renderer + self.rendererPreset.setCurrentPresetByName ( str ( name ) ) + self.updateGui () + # + # updateGui + # + def updateGui ( self ) : + # redraw gui elements + #print ">> updateGui:: current renderer: %s" % self.rendererPreset.getCurrentPresetName() + if len ( self.rendererPreset.presetsList ) > 0 : + if self.rendererPreset.currentPreset is not None : + self.ui.lineName.setText ( self.rendererPreset.getCurrentPresetName () ) + self.ui.lineCmd.setText ( self.rendererPreset.currentPreset.RendererName ) + self.ui.lineFlags.setText ( self.rendererPreset.currentPreset.RendererFlags ) + self.ui.lineCompiler.setText ( self.rendererPreset.currentPreset.ShaderCompiler ) + self.ui.lineShaderInfo.setText ( self.rendererPreset.currentPreset.ShaderInfo ) + self.ui.lineDefines.setText ( self.rendererPreset.currentPreset.ShaderDefines ) + self.ui.lineShaderExt.setText ( self.rendererPreset.currentPreset.ShaderExt ) + self.ui.lineTexMake.setText ( self.rendererPreset.currentPreset.TextureMake ) + self.ui.lineTexInfo.setText ( self.rendererPreset.currentPreset.TextureInfo ) + self.ui.lineTexViewer.setText ( self.rendererPreset.currentPreset.TextureViewer ) + self.ui.lineTexExt.setText ( self.rendererPreset.currentPreset.TextureExt ) + self.ui.deleteButton.setEnabled ( True ) + self.ui.tab1.setEnabled ( True ) + self.ui.tab2.setEnabled ( True) + self.ui.tab3.setEnabled ( True ) + else : + self.ui.deleteButton.setEnabled ( False ) + self.ui.tab1.setEnabled ( False ) + self.ui.tab2.setEnabled ( False ) + self.ui.tab3.setEnabled ( False ) + self.ui.lineName.clear () + self.ui.lineCmd.clear () + self.ui.lineFlags.clear () + self.ui.lineCompiler.clear () + self.ui.lineShaderInfo.clear () + self.ui.lineDefines.clear () + self.ui.lineShaderExt.clear () + self.ui.lineTexMake.clear () + self.ui.lineTexInfo.clear () + self.ui.lineTexViewer.clear () + self.ui.lineTexExt.clear () + # + # onNewPreset + # + def onNewPreset ( self ) : + # create new empty preset + title = 'Untitled' + newLabel = title + #self.labelsReady = False + i = 0 + while True : + if newLabel in self.rendererPreset.getPresetNames () : + newLabel = title + str ( i ) + i += 1 + continue + else : + break; + self.rendererPreset.addPreset ( newLabel ) + #self.labelsReady = True + self.ui.listPreset.addItem ( newLabel ) + idx = self.ui.listPreset.findText ( newLabel ) + self.ui.listPreset.setCurrentIndex ( -1 ) + self.ui.listPreset.setCurrentIndex ( idx ) + #self.updateGui () + # + # onDeletePreset + # + def onDeletePreset ( self ) : + # delete existing preset + if len ( self.rendererPreset.presetsList ) > 0 : + msgBox = QtModule.QMessageBox () + ret = msgBox.warning ( self, 'Warning', "Do you really want to delete this preset?", + QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No ) + + if ret == QtModule.QMessageBox.Yes : + self.rendererPreset.deleteCurrentPreset () + i = self.ui.listPreset.currentIndex () + self.ui.listPreset.removeItem ( i ) + self.rendererPreset.setCurrentPresetByName ( str ( self.ui.listPreset.currentText () ) ) + # + # onEditLabel + # + def onEditLabel ( self ) : + # edit label + newLabel = str ( self.ui.lineName.text () ) + if ( self.rendererPreset.getCurrentPresetName () != newLabel ) : + if newLabel not in self.rendererPreset.getPresetNames () : + self.rendererPreset.renameCurrentPreset ( newLabel ) + # rename current preset ComboBox item to new label + i = self.ui.listPreset.currentIndex () + self.ui.listPreset.setItemText ( i, newLabel ) + else : + # this label already exists, so restore to previose + self.ui.lineName.setText ( self.rendererPreset.getCurrentPresetName () ) + # + # onSave + # + def onSave ( self ) : + # get data from Gui for current renderer before saving + self.getDataFromGui () + self.emit ( QtCore.SIGNAL ( 'presetChanged' ) ) + self.emit ( QtCore.SIGNAL ( 'savePreset' ) ) + #self.done ( 0 ) + # + # onSelect + # + def onSelect ( self ) : + # get data from Gui for current renderer before saving + self.getDataFromGui () + self.emit( QtCore.SIGNAL ( 'presetChanged' ) ) + self.done ( 0 ) diff --git a/gui/nodeEditor/NodeEditorDialog.py b/gui/nodeEditor/NodeEditorDialog.py index 10444e7..bbc77ad 100644 --- a/gui/nodeEditor/NodeEditorDialog.py +++ b/gui/nodeEditor/NodeEditorDialog.py @@ -7,8 +7,7 @@ Dialog for managing node code and parameters """ -import os, sys, copy -from PyQt4 import Qt, QtCore, QtGui, QtXml +from core.mePyQt import Qt, QtCore, QtGui, QtXml from core.meCommon import * from global_vars import app_global_vars, DEBUG_MODE, VALID_PARAM_TYPES, VALID_RIB_NODE_TYPES @@ -37,614 +36,619 @@ TAB_PARAM = 5 TAB_LINK_INFO = 6 +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets # # NodeEditorDialog # -class NodeEditorDialog ( QtGui.QDialog ) : - # - # __init__ - # - def __init__ ( self, node = None ): - # - QtGui.QDialog.__init__ ( self ) - - self.editNode = node - - # self.removedLinks = [] - - self.nodePropertiesEditor = None - self.nodeParamEditor = None - self.nodeLinkEditor = None - - self.nodeCodeEditor = None - self.controlCodeEditor = None - self.eventCodeEditor = None - self.paramCodeEditor = None - - #self.setEditNode ( node ) - self.buildGui () - self.connectSignals () - - self.ui.btn_save.setDefault ( False ) - self.ui.btn_close.setDefault ( True ) - self.updateGui () - # - # connectSignals - # - def connectSignals ( self ) : - # - QtCore.QObject.connect ( self.ui.input_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) # onInputParamSelectionChanged ) - QtCore.QObject.connect ( self.ui.output_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) # onOutputParamSelectionChanged ) - - QtCore.QObject.connect ( self.ui.input_list, QtCore.SIGNAL ( 'addItem' ), self.onAddParam ) - QtCore.QObject.connect ( self.ui.output_list, QtCore.SIGNAL ( 'addItem' ), self.onAddParam ) - QtCore.QObject.connect ( self.ui.input_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameParam ) - QtCore.QObject.connect ( self.ui.output_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameParam ) - QtCore.QObject.connect ( self.ui.input_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveParam ) - QtCore.QObject.connect ( self.ui.output_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveParam ) - - QtCore.QObject.connect ( self.ui.tabs_param_list, QtCore.SIGNAL ( 'currentChanged(int)' ), self.updateGui ) - - if self.nodeParamEditor is not None : - QtCore.QObject.connect ( self.nodeParamEditor, QtCore.SIGNAL ( 'changeParamName' ), self.onRenameParam ) - QtCore.QObject.connect ( self.nodeParamEditor, QtCore.SIGNAL ( 'changeParamLabel' ), self.onRenameParamLabel ) - - if self.nodeCodeEditor is not None : - QtCore.QObject.connect ( self.nodeCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditCode ) - - if self.controlCodeEditor is not None : - QtCore.QObject.connect ( self.controlCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditControlCode ) - - if self.paramCodeEditor is not None : - QtCore.QObject.connect ( self.paramCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditParamCode ) - - if self.eventCodeEditor is not None : - QtCore.QObject.connect ( self.eventCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditEventCode ) - - QtCore.QObject.connect ( self.ui.internals_list, QtCore.SIGNAL ( 'addItem' ), self.onAddInternal ) - QtCore.QObject.connect ( self.ui.includes_list, QtCore.SIGNAL ( 'addItem' ), self.onAddInclude ) - - QtCore.QObject.connect ( self.ui.internals_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameInternal ) - QtCore.QObject.connect ( self.ui.includes_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameInclude ) - - QtCore.QObject.connect ( self.ui.internals_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveInternal ) - QtCore.QObject.connect ( self.ui.includes_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveInclude ) - - QtCore.QObject.connect ( self.ui.handlers_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) - - # - # disconnectSignals - # - def disconnectSignals ( self ) : - # - QtCore.QObject.disconnect ( self.ui.input_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) # onInputParamSelectionChanged ) - QtCore.QObject.disconnect ( self.ui.output_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) # onOutputParamSelectionChanged ) - - QtCore.QObject.disconnect ( self.ui.input_list, QtCore.SIGNAL ( 'addItem' ), self.onAddParam ) - QtCore.QObject.disconnect ( self.ui.output_list, QtCore.SIGNAL ( 'addItem' ), self.onAddParam ) - QtCore.QObject.disconnect ( self.ui.input_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameParam ) - QtCore.QObject.disconnect ( self.ui.output_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameParam ) - QtCore.QObject.disconnect ( self.ui.input_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveParam ) - QtCore.QObject.disconnect ( self.ui.output_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveParam ) - - QtCore.QObject.disconnect ( self.ui.tabs_param_list, QtCore.SIGNAL ( "currentChanged(int)" ), self.updateGui ) - - if self.nodeParamEditor is not None : - QtCore.QObject.disconnect ( self.nodeParamEditor, QtCore.SIGNAL ( 'changeParamName' ), self.onRenameParam ) - QtCore.QObject.disconnect ( self.nodeParamEditor, QtCore.SIGNAL ( 'changeParamLabel' ), self.onRenameParamLabel ) - - if self.nodeCodeEditor is not None : - QtCore.QObject.disconnect ( self.nodeCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditCode ) - - if self.controlCodeEditor is not None : - QtCore.QObject.disconnect ( self.controlCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditControlCode) - - if self.paramCodeEditor is not None : - QtCore.QObject.disconnect ( self.paramCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditParamCode ) - - if self.eventCodeEditor is not None : - QtCore.QObject.disconnect ( self.eventCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditEventCode ) - - QtCore.QObject.disconnect ( self.ui.internals_list, QtCore.SIGNAL ( 'addItem' ), self.onAddInternal ) - QtCore.QObject.disconnect ( self.ui.includes_list, QtCore.SIGNAL ( 'addItem' ), self.onAddInclude ) - - QtCore.QObject.disconnect ( self.ui.internals_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameInternal ) - QtCore.QObject.disconnect ( self.ui.includes_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameInclude ) - - QtCore.QObject.disconnect ( self.ui.internals_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveInternal ) - QtCore.QObject.disconnect ( self.ui.includes_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveInclude ) - - QtCore.QObject.disconnect ( self.ui.handlers_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) - - # - # setEditNode - # - def setEditNode ( self, editNode ) : - # - if DEBUG_MODE : print '>> NodeEditorDialog: setEditNode' - self.editNode = editNode - # - # buildGui - # - def buildGui ( self ) : - # build the gui created with QtDesigner - self.ui = Ui_NodeEditorDialog () - self.ui.setupUi ( self ) - - if self.editNode is not None : - # - self.setWindowTitle ( 'NodeEditor: %s (%s)' % ( self.editNode.label, self.editNode.name ) ) - - linkedFont = QtGui.QFont () - linkedFont.setItalic ( True ) - linkedBrush = QtGui.QBrush () - linkedBrush.setColor ( QtCore.Qt.blue ) - - # setup loacal variables list - for name in self.editNode.internals : - item = QtGui.QListWidgetItem ( name ) - self.ui.internals_list.ui.listWidget.addItem ( item ) - - # setup includes list - for name in self.editNode.includes : - item = QtGui.QListWidgetItem ( name ) - self.ui.includes_list.ui.listWidget.addItem ( item ) - - # setup input params list - for param in self.editNode.inputParams : - item = QtGui.QListWidgetItem ( param.name ) - if self.editNode.isInputParamLinked ( param ) : - item.setFont ( linkedFont ) - item.setForeground ( linkedBrush ) - self.ui.input_list.ui.listWidget.addItem ( item ) - - # setup output params list - for param in self.editNode.outputParams : - item = QtGui.QListWidgetItem ( param.name ) - if self.editNode.isOutputParamLinked ( param ) : - item.setFont ( linkedFont ) - item.setForeground ( linkedBrush ) - self.ui.output_list.ui.listWidget.addItem ( item ) - - # setup input links list - for link in self.editNode.getInputLinks () : - item = QtGui.QListWidgetItem ( 'id=%d' % link.id ) - item.setData ( QtCore.Qt.UserRole, QVariant ( int ( link.id ) ) ) - self.ui.input_links_listWidget.addItem ( item ) - - # setup output links list - for link in self.editNode.getOutputLinks () : - item = QtGui.QListWidgetItem ( 'id=%d' % link.id ) - item.setData ( QtCore.Qt.UserRole, QVariant ( int ( link.id ) ) ) - self.ui.output_links_listWidget.addItem ( item ) - - # setup event handlers list - if self.editNode.event_code : - for handler in self.editNode.event_code.keys () : - item = QtGui.QListWidgetItem ( handler ) - self.ui.handlers_list.ui.listWidget.addItem ( item ) - - self.nodeCodeEditor = self.ui.node_code - self.nodeCodeEditor.setNodeCode ( self.editNode.code, 'SL' ) - - self.controlCodeEditor = self.ui.control_code - self.controlCodeEditor.setNodeCode ( self.editNode.control_code, 'python' ) - - self.eventCodeEditor = self.ui.event_code - #self.eventCodeEditor.setNodeCode ( self.editNode.event_code, 'python' ) - - self.paramCodeEditor = self.ui.param_code - #self.paramCodeEditor.setNodeCode ( self.editNode.param_code, 'python' ) - - - self.nodePropertiesEditor = self.ui.node - self.nodePropertiesEditor.setNode ( self.editNode ) - - self.nodeParamEditor = self.ui.param - - self.nodeLinkEditor = self.ui.link - - self.ui.tabWidget.setCurrentIndex ( TAB_NODE_CODE ) - self.ui.toolBox.setCurrentIndex ( IDX_INTERNALS ) - self.ui.tabs_param_list.setCurrentIndex ( 0 ) # input param tab - - # - # updateGui - # - def updateGui ( self ) : - # - if self.editNode is not None : - if DEBUG_MODE : print '>> NodeEditorDialog::updateGui' - - self.disconnectSignals () - - self.eventCodeEditor.setNodeCode ( None, 'python' ) - self.paramCodeEditor.setNodeCode ( None, 'python' ) - - idx = self.ui.toolBox.currentIndex () - - if idx == IDX_PARAM : - # Parameters - tab_idx = self.ui.tabs_param_list.currentIndex () - param = None - - if tab_idx == 0 : - # input parameters - list_item = self.ui.input_list.ui.listWidget.currentItem () - - if list_item is not None : - param = self.editNode.getInputParamByName ( str ( list_item.text () ) ) - - elif tab_idx == 1 : - # output parametrs - list_item = self.ui.output_list.ui.listWidget.currentItem () - - if list_item is not None : - param = self.editNode.getOutputParamByName ( str ( list_item.text () ) ) - - self.nodeParamEditor.setParam ( param ) - if param is not None and param.type == 'control' : - self.paramCodeEditor.setNodeCode ( param.code, 'python' ) - #print '*** set (%s).param.code :' % param.label - #print param.code - - elif idx == IDX_HANDLERS : - handler_item = self.ui.handlers_list.ui.listWidget.currentItem () - if handler_item is not None : - handler = str ( handler_item.text () ) - handler_code = self.editNode.event_code [ handler ] - self.eventCodeEditor.setNodeCode ( handler_code, 'python' ) - #else : - # print '** no selection in handlers_list' - - elif idx == IDX_LINKS : - inputLinkSelected = False - link_id = None - tab_idx = self.ui.tabs_links_list.currentIndex () - - if tab_idx == 0 : - # input links - inputLinkSelected = True - links_item = self.ui.input_links_listWidget.currentItem () - if links_item is not None : ( link_id, ok ) = links_item.data ( QtCore.Qt.UserRole ).toInt () - - else : - # output links - links_item = self.ui.output_links_listWidget.currentItem () - if links_item is not None : ( link_id, ok ) = links_item.data ( QtCore.Qt.UserRole ).toInt () - - if link_id is not None : - link = None - - if inputLinkSelected : link = self.editNode.getInputLinkByID ( link_id ) - else : link = self.editNode.getOutputLinkByID ( link_id ) - - if link is not None : - ( srcNode, srcParam ) = link.getSrc () - ( dstNode, dstParam ) = link.getDst () - self.nodeLinkEditor.ui.src_node_lineEdit.setText ( srcNode.label ) - self.nodeLinkEditor.ui.src_param_lineEdit.setText ( srcParam.label ) - self.nodeLinkEditor.ui.src_id_lineEdit.setText ( str ( srcNode.id ) ) - self.nodeLinkEditor.ui.dst_node_lineEdit.setText ( dstNode.label ) - self.nodeLinkEditor.ui.dst_param_lineEdit.setText ( dstParam.label ) - self.nodeLinkEditor.ui.dst_id_lineEdit.setText ( str ( dstNode.id ) ) - self.connectSignals () - # - # onToolBoxIndexChanged - # - def onToolBoxIndexChanged ( self, idx ) : - if DEBUG_MODE : print '>> NodeEditorDialog::onToolBoxIndexChanged (idx = %d)' % idx - # - #self.disconnectSignals () - - if idx == IDX_PARAM : - # Input, Output Parameters - self.ui.tabWidget.setCurrentIndex ( TAB_PARAM ) - - elif idx == IDX_LINKS : - # Input, Output Links - self.ui.tabWidget.setCurrentIndex ( TAB_LINK_INFO ) - - elif idx == IDX_INTERNALS : - # Includes, Local Names, Code - self.ui.tabWidget.setCurrentIndex ( TAB_NODE_CODE ) - - elif idx == IDX_HANDLERS : - # Event Handlers code - self.ui.tabWidget.setCurrentIndex ( TAB_EVENT_CODE ) - - #self.connectSignals () - self.updateGui () - # - # onInputParamSelectionChanged - # - def onInputParamSelectionChanged ( self, paramName ) : - # - if DEBUG_MODE : print '>> NodeEditorDialog::onInputParamSelectionChanged (%s)' % paramName - param = self.editNode.getInputParamByName ( str ( paramName ) ) - self.nodeParamEditor.setParam ( param ) - # - # onOutputParamSelectionChanged - # - def onOutputParamSelectionChanged ( self, paramName ) : - # - if DEBUG_MODE : print '>> NodeEditorDialog::onOutputParamSelectionChanged (%s)' % paramName - param = self.editNode.getOutputParamByName ( str ( paramName ) ) - self.nodeParamEditor.setParam ( param ) - # - # onCodeListIndexChanged - # - def onCodeListIndexChanged ( self, idx ) : - # if DEBUG_MODE : print '>> NodeEditorDialog: onCodeListIndexChanged idx = %d' % idx - self.updateGui () - # - # onRemoveInternal - # - def onRemoveInternal ( self, internal ) : - # - internalsListWidget = self.ui.internals_list.ui.listWidget - self.editNode.internals.remove ( internal ) - item = internalsListWidget.currentItem () - internalsListWidget.takeItem ( internalsListWidget.currentRow () ) - internalsListWidget.removeItemWidget ( item ) - internalsListWidget.clearSelection () - internalsListWidget.setCurrentItem ( None ) - # - # onRemoveInclude - # - def onRemoveInclude ( self, include ) : - # - includesListWidget = self.ui.includes_list.ui.listWidget - self.editNode.includes.remove ( include ) - item = includesListWidget.currentItem() - includesListWidget.takeItem ( includesListWidget.currentRow () ) - includesListWidget.removeItemWidget ( item ) - includesListWidget.clearSelection () - includesListWidget.setCurrentItem ( None ) - # - # onRemoveParam - # - def onRemoveParam ( self, paramName ) : - # - isInputParam = False - tab_idx = self.ui.tabs_param_list.currentIndex () - if tab_idx == 0 : isInputParam = True - param = None - paramList = None - linkList = None - - if isInputParam : - param = self.editNode.getInputParamByName ( paramName ) - paramList = self.ui.input_list - linkList = self.ui.input_links_listWidget - else : - param = self.editNode.getOutputParamByName ( paramName ) - paramList = self.ui.output_list - linkList = self.ui.output_links_listWidget - - removedLinks = self.editNode.removeParam ( param ) - - # remove item from links list and node network - for link in removedLinks : - item_name = 'id=%d' % link.id - item = linkList.findItems ( item_name, QtCore.Qt.MatchExactly )[0] - linkList.takeItem ( linkList.row ( item ) ) - link.nodenet.removeLink ( link ) - - # remove item from param list - item = paramList.ui.listWidget.currentItem () - paramList.ui.listWidget.takeItem ( paramList.ui.listWidget.currentRow () ) - paramList.ui.listWidget.removeItemWidget ( item ) - paramList.ui.listWidget.clearSelection () - paramList.ui.listWidget.setCurrentItem ( None ) - - # remove item from code (invalidate code) - pass - # - # onRenameInternal - # - def onRenameInternal ( self, oldName, newName ) : - # - internalsListWidget = self.ui.internals_list.ui.listWidget - from core.meCommon import getUniqueName - idx = self.editNode.internals.index ( oldName ) - newName = getUniqueName ( newName, self.editNode.internals ) - self.editNode.internals [ idx ] = newName - - item = internalsListWidget.findItems ( oldName, QtCore.Qt.MatchExactly )[0] - item.setText ( newName ) - self.ui.internals_list.setName ( newName ) - internalsListWidget.clearSelection () - internalsListWidget.setCurrentItem ( item ) - # - # onRenameInclude - # - def onRenameInclude ( self, oldName, newName ) : - # - includesListWidget = self.ui.includes_list.ui.listWidget - from core.meCommon import getUniqueName - idx = self.editNode.includes.index ( oldName ) - newName = getUniqueName ( newName, self.editNode.includes ) - self.editNode.includes [ idx ] = newName - - item = includesListWidget.findItems ( oldName, QtCore.Qt.MatchExactly )[0] - item.setText ( newName ) - self.ui.includes_list.setName ( newName ) - includesListWidget.clearSelection () - includesListWidget.setCurrentItem ( item ) - # - # onRenameParam - # - def onRenameParam ( self, oldName, newName ) : - # - isInputParam = False - tab_idx = self.ui.tabs_param_list.currentIndex () - if tab_idx == 0 : isInputParam = True - param = None - paramList = None - if isInputParam : - param = self.editNode.getInputParamByName ( oldName ) - paramList = self.ui.input_list - else : - param = self.editNode.getOutputParamByName ( oldName ) - paramList = self.ui.output_list - - self.editNode.renameParamName ( param, newName ) - - item = paramList.ui.listWidget.findItems ( oldName, QtCore.Qt.MatchExactly )[0] - item.setText ( param.name ) - paramList.setName ( param.name ) - paramList.ui.listWidget.clearSelection () - paramList.ui.listWidget.setCurrentItem ( item ) - # - # onRenameParamLabel - # - def onRenameParamLabel ( self, oldName, newName ) : - # - param = self.nodeParamEditor.param - self.editNode.renameParamLabel ( param, newName ) - self.nodeParamEditor.ui.label_lineEdit.setText ( param.label ) - # - # onAddInternal - # - def onAddInternal ( self, newName ) : - # - if DEBUG_MODE : print '>> NodeEditorDialog::onAddInternal (%s) ' % (newName) - # name can be changed to be unique - newName = self.editNode.addInternal ( newName ) - internalsListWidget = self.ui.internals_list.ui.listWidget - internalsListWidget.addItem ( newName ) - internalsListWidget.setCurrentItem ( internalsListWidget.findItems ( newName, QtCore.Qt.MatchExactly )[0] ) - # - # onAddInclude - # - def onAddInclude ( self, newName ) : - # - if DEBUG_MODE : print '>> NodeEditorDialog::onAddInclude (%s) ' % (newName) - # name can be changed to be unique - newName = self.editNode.addInclude ( newName ) - includesListWidget = self.ui.includes_list.ui.listWidget - includesListWidget.addItem ( newName ) - includesListWidget.setCurrentItem ( includesListWidget.findItems ( newName, QtCore.Qt.MatchExactly )[0] ) - # - # onAddParam - # - def onAddParam ( self, newName ) : - # - if DEBUG_MODE : print '>> NodeEditorDialog::onAddParam (%s) ' % (newName) - isInputParam = False - paramType = None - isRibParam = ( self.editNode.type in VALID_RIB_NODE_TYPES ) - tab_idx = self.ui.tabs_param_list.currentIndex () - if tab_idx == 0 : isInputParam = True - # ask user about param type - typeDialog = QtGui.QDialog () # Qt.MSWindowsFixedSizeDialogHint - typeDialog.setModal ( True ) - - typeDialog.setWindowTitle ( 'Parameter Type' ) - typeDialog.resize (180, 100 ) - sizePolicy = QtGui.QSizePolicy ( QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed ) - sizePolicy.setHorizontalStretch ( 0 ) - sizePolicy.setVerticalStretch ( 0 ) - sizePolicy.setHeightForWidth ( typeDialog.sizePolicy().hasHeightForWidth() ) - typeDialog.setSizePolicy ( sizePolicy ) - typeDialog.setSizeGripEnabled ( False ) - - typeDialog.verticalLayout = QtGui.QVBoxLayout ( typeDialog ) - typeDialog.verticalLayout.setSizeConstraint ( QtGui.QLayout.SetMinimumSize ) - typeDialog.type_comboBox = QtGui.QComboBox ( typeDialog ) - - for label in VALID_PARAM_TYPES : typeDialog.type_comboBox.addItem ( label ) - - typeDialog.verticalLayout.addWidget ( typeDialog.type_comboBox ) - - typeDialog.btnBox = QtGui.QDialogButtonBox ( QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel, parent = typeDialog ) - typeDialog.btnBox.setCenterButtons ( True ) - typeDialog.verticalLayout.addWidget ( typeDialog.btnBox ) - - QtCore.QObject.connect ( typeDialog.btnBox, QtCore.SIGNAL ( 'accepted()' ), typeDialog.accept ) - QtCore.QObject.connect ( typeDialog.btnBox, QtCore.SIGNAL ( 'rejected()' ), typeDialog.reject ) - - if typeDialog.exec_() == QtGui.QDialog.Accepted : - paramType = str ( typeDialog.type_comboBox.currentText () ) - - if DEBUG_MODE : print '>> NodeEditorDialog::onAddParam typeDialog Accepted (%s)' % paramType - # create empty xml node parameter - dom = QtXml.QDomDocument ( newName ) - xmlnode = dom.createElement( 'property' ) - - xmlnode.setAttribute ( 'name', newName ) - xmlnode.setAttribute ( 'label', newName ) - xmlnode.setAttribute ( 'type', paramType ) - param = createParamFromXml ( xmlnode, isRibParam, isInputParam ) - item = QtGui.QListWidgetItem ( param.name ) - - paramListWidget = self.ui.input_list.ui.listWidget - - if isInputParam : - self.editNode.addInputParam ( param ) - else : - self.editNode.addOutputParam ( param ) - paramListWidget = self.ui.output_list.ui.listWidget - - paramListWidget.addItem ( param.name ) - paramListWidget.setCurrentItem ( paramListWidget.findItems ( param.name, QtCore.Qt.MatchExactly )[0] ) - #self.nodeParamEditor.setParam ( param ) - # - # onEditCode - # - def onEditCode ( self ) : - # - if DEBUG_MODE : print '>> NodeEditorDialog::onEditCode' - if self.nodeCodeEditor is not None : - #self.nodeCodeEditor.ui.textEdit - self.editNode.code = str ( self.nodeCodeEditor.ui.textEdit.toPlainText () ) - # - # onEditControlCode - # - def onEditControlCode ( self ) : - # - if DEBUG_MODE : print '>> NodeEditorDialog::onEditControlCode' - if self.controlCodeEditor is not None : - self.editNode.control_code = str ( self.controlCodeEditor.ui.textEdit.toPlainText () ) - # - # onEditParamCode - # - def onEditParamCode ( self ) : - # - if DEBUG_MODE : print '>> NodeEditorDialog::onEditParamCode' - if self.paramCodeEditor is not None : - param = self.nodeParamEditor.param - if param is not None and param.type == 'control' : - param.code = str ( self.paramCodeEditor.ui.textEdit.toPlainText () ) - #print '*** set (%s).param.code :' % param.label - #print param.code - # - # onEditEventCode - # - def onEditEventCode ( self ) : - # - if DEBUG_MODE : print '>> NodeEditorDialog::onEditEventCode' - if self.eventCodeEditor is not None : - handler_item = self.ui.handlers_list.ui.listWidget.currentItem () - if handler_item is not None : - handler = str ( handler_item.text () ) - self.editNode.event_code [ handler ] = str ( self.eventCodeEditor.ui.textEdit.toPlainText () ) - - # - # Ignore default Enter press event - # - def keyPressEvent ( self, event ) : - # - #if DEBUG_MODE : print '>> NodeEditorDialog::keyPressEvent' - if event.key () == QtCore.Qt.Key_Enter or event.key () == QtCore.Qt.Key_Return : - event.ignore () - else: - QtGui.QDialog.keyPressEvent ( self, event ) - # - # accept - # - def accept ( self ) : - # - if DEBUG_MODE : print '>> NodeEditorDialog::accept' - self.done ( QtGui.QDialog.Accepted ) +class NodeEditorDialog ( QtModule.QDialog ) : + # + # __init__ + # + def __init__ ( self, node = None ): + # + QtModule.QDialog.__init__ ( self ) + + self.editNode = node + + # self.removedLinks = [] + + self.nodePropertiesEditor = None + self.nodeParamEditor = None + self.nodeLinkEditor = None + + self.nodeCodeEditor = None + self.controlCodeEditor = None + self.eventCodeEditor = None + self.paramCodeEditor = None + + #self.setEditNode ( node ) + self.buildGui () + self.connectSignals () + + self.ui.btn_save.setDefault ( False ) + self.ui.btn_close.setDefault ( True ) + self.updateGui () + # + # connectSignals + # + def connectSignals ( self ) : + # + QtCore.QObject.connect ( self.ui.input_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) # onInputParamSelectionChanged ) + QtCore.QObject.connect ( self.ui.output_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) # onOutputParamSelectionChanged ) + + QtCore.QObject.connect ( self.ui.input_list, QtCore.SIGNAL ( 'addItem' ), self.onAddParam ) + QtCore.QObject.connect ( self.ui.output_list, QtCore.SIGNAL ( 'addItem' ), self.onAddParam ) + QtCore.QObject.connect ( self.ui.input_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameParam ) + QtCore.QObject.connect ( self.ui.output_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameParam ) + QtCore.QObject.connect ( self.ui.input_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveParam ) + QtCore.QObject.connect ( self.ui.output_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveParam ) + + QtCore.QObject.connect ( self.ui.tabs_param_list, QtCore.SIGNAL ( 'currentChanged(int)' ), self.updateGui ) + + if self.nodeParamEditor is not None : + QtCore.QObject.connect ( self.nodeParamEditor, QtCore.SIGNAL ( 'changeParamName' ), self.onRenameParam ) + QtCore.QObject.connect ( self.nodeParamEditor, QtCore.SIGNAL ( 'changeParamLabel' ), self.onRenameParamLabel ) + + if self.nodeCodeEditor is not None : + QtCore.QObject.connect ( self.nodeCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditCode ) + + if self.controlCodeEditor is not None : + QtCore.QObject.connect ( self.controlCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditControlCode ) + + if self.paramCodeEditor is not None : + QtCore.QObject.connect ( self.paramCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditParamCode ) + + if self.eventCodeEditor is not None : + QtCore.QObject.connect ( self.eventCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditEventCode ) + + QtCore.QObject.connect ( self.ui.internals_list, QtCore.SIGNAL ( 'addItem' ), self.onAddInternal ) + QtCore.QObject.connect ( self.ui.includes_list, QtCore.SIGNAL ( 'addItem' ), self.onAddInclude ) + + QtCore.QObject.connect ( self.ui.internals_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameInternal ) + QtCore.QObject.connect ( self.ui.includes_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameInclude ) + + QtCore.QObject.connect ( self.ui.internals_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveInternal ) + QtCore.QObject.connect ( self.ui.includes_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveInclude ) + + QtCore.QObject.connect ( self.ui.handlers_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) + + # + # disconnectSignals + # + def disconnectSignals ( self ) : + # + QtCore.QObject.disconnect ( self.ui.input_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) # onInputParamSelectionChanged ) + QtCore.QObject.disconnect ( self.ui.output_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) # onOutputParamSelectionChanged ) + + QtCore.QObject.disconnect ( self.ui.input_list, QtCore.SIGNAL ( 'addItem' ), self.onAddParam ) + QtCore.QObject.disconnect ( self.ui.output_list, QtCore.SIGNAL ( 'addItem' ), self.onAddParam ) + QtCore.QObject.disconnect ( self.ui.input_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameParam ) + QtCore.QObject.disconnect ( self.ui.output_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameParam ) + QtCore.QObject.disconnect ( self.ui.input_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveParam ) + QtCore.QObject.disconnect ( self.ui.output_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveParam ) + + QtCore.QObject.disconnect ( self.ui.tabs_param_list, QtCore.SIGNAL ( "currentChanged(int)" ), self.updateGui ) + + if self.nodeParamEditor is not None : + QtCore.QObject.disconnect ( self.nodeParamEditor, QtCore.SIGNAL ( 'changeParamName' ), self.onRenameParam ) + QtCore.QObject.disconnect ( self.nodeParamEditor, QtCore.SIGNAL ( 'changeParamLabel' ), self.onRenameParamLabel ) + + if self.nodeCodeEditor is not None : + QtCore.QObject.disconnect ( self.nodeCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditCode ) + + if self.controlCodeEditor is not None : + QtCore.QObject.disconnect ( self.controlCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditControlCode) + + if self.paramCodeEditor is not None : + QtCore.QObject.disconnect ( self.paramCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditParamCode ) + + if self.eventCodeEditor is not None : + QtCore.QObject.disconnect ( self.eventCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditEventCode ) + + QtCore.QObject.disconnect ( self.ui.internals_list, QtCore.SIGNAL ( 'addItem' ), self.onAddInternal ) + QtCore.QObject.disconnect ( self.ui.includes_list, QtCore.SIGNAL ( 'addItem' ), self.onAddInclude ) + + QtCore.QObject.disconnect ( self.ui.internals_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameInternal ) + QtCore.QObject.disconnect ( self.ui.includes_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameInclude ) + + QtCore.QObject.disconnect ( self.ui.internals_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveInternal ) + QtCore.QObject.disconnect ( self.ui.includes_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveInclude ) + + QtCore.QObject.disconnect ( self.ui.handlers_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) + + # + # setEditNode + # + def setEditNode ( self, editNode ) : + # + if DEBUG_MODE : print '>> NodeEditorDialog: setEditNode' + self.editNode = editNode + # + # buildGui + # + def buildGui ( self ) : + # build the gui created with QtDesigner + self.ui = Ui_NodeEditorDialog () + self.ui.setupUi ( self ) + + if self.editNode is not None : + # + self.setWindowTitle ( 'NodeEditor: %s (%s)' % ( self.editNode.label, self.editNode.name ) ) + + linkedFont = QtGui.QFont () + linkedFont.setItalic ( True ) + linkedBrush = QtGui.QBrush () + linkedBrush.setColor ( QtCore.Qt.blue ) + + # setup loacal variables list + for name in self.editNode.internals : + item = QtGui.QListWidgetItem ( name ) + self.ui.internals_list.ui.listWidget.addItem ( item ) + + # setup includes list + for name in self.editNode.includes : + item = QtGui.QListWidgetItem ( name ) + self.ui.includes_list.ui.listWidget.addItem ( item ) + + # setup input params list + for param in self.editNode.inputParams : + item = QtGui.QListWidgetItem ( param.name ) + if self.editNode.isInputParamLinked ( param ) : + item.setFont ( linkedFont ) + item.setForeground ( linkedBrush ) + self.ui.input_list.ui.listWidget.addItem ( item ) + + # setup output params list + for param in self.editNode.outputParams : + item = QtGui.QListWidgetItem ( param.name ) + if self.editNode.isOutputParamLinked ( param ) : + item.setFont ( linkedFont ) + item.setForeground ( linkedBrush ) + self.ui.output_list.ui.listWidget.addItem ( item ) + + # setup input links list + for link in self.editNode.getInputLinks () : + item = QtGui.QListWidgetItem ( 'id=%d' % link.id ) + item.setData ( QtCore.Qt.UserRole, QVariant ( int ( link.id ) ) ) + self.ui.input_links_listWidget.addItem ( item ) + + # setup output links list + for link in self.editNode.getOutputLinks () : + item = QtGui.QListWidgetItem ( 'id=%d' % link.id ) + item.setData ( QtCore.Qt.UserRole, QVariant ( int ( link.id ) ) ) + self.ui.output_links_listWidget.addItem ( item ) + + # setup event handlers list + if self.editNode.event_code : + for handler in self.editNode.event_code.keys () : + item = QtGui.QListWidgetItem ( handler ) + self.ui.handlers_list.ui.listWidget.addItem ( item ) + + self.nodeCodeEditor = self.ui.node_code + self.nodeCodeEditor.setNodeCode ( self.editNode.code, 'SL' ) + + self.controlCodeEditor = self.ui.control_code + self.controlCodeEditor.setNodeCode ( self.editNode.control_code, 'python' ) + + self.eventCodeEditor = self.ui.event_code + #self.eventCodeEditor.setNodeCode ( self.editNode.event_code, 'python' ) + + self.paramCodeEditor = self.ui.param_code + #self.paramCodeEditor.setNodeCode ( self.editNode.param_code, 'python' ) + + + self.nodePropertiesEditor = self.ui.node + self.nodePropertiesEditor.setNode ( self.editNode ) + + self.nodeParamEditor = self.ui.param + + self.nodeLinkEditor = self.ui.link + + self.ui.tabWidget.setCurrentIndex ( TAB_NODE_CODE ) + self.ui.toolBox.setCurrentIndex ( IDX_INTERNALS ) + self.ui.tabs_param_list.setCurrentIndex ( 0 ) # input param tab + + # + # updateGui + # + def updateGui ( self ) : + # + if self.editNode is not None : + if DEBUG_MODE : print '>> NodeEditorDialog::updateGui' + + self.disconnectSignals () + + self.eventCodeEditor.setNodeCode ( None, 'python' ) + self.paramCodeEditor.setNodeCode ( None, 'python' ) + + idx = self.ui.toolBox.currentIndex () + + if idx == IDX_PARAM : + # Parameters + tab_idx = self.ui.tabs_param_list.currentIndex () + param = None + + if tab_idx == 0 : + # input parameters + list_item = self.ui.input_list.ui.listWidget.currentItem () + + if list_item is not None : + param = self.editNode.getInputParamByName ( str ( list_item.text () ) ) + + elif tab_idx == 1 : + # output parametrs + list_item = self.ui.output_list.ui.listWidget.currentItem () + + if list_item is not None : + param = self.editNode.getOutputParamByName ( str ( list_item.text () ) ) + + self.nodeParamEditor.setParam ( param ) + if param is not None and param.type == 'control' : + self.paramCodeEditor.setNodeCode ( param.code, 'python' ) + #print '*** set (%s).param.code :' % param.label + #print param.code + + elif idx == IDX_HANDLERS : + handler_item = self.ui.handlers_list.ui.listWidget.currentItem () + if handler_item is not None : + handler = str ( handler_item.text () ) + handler_code = self.editNode.event_code [ handler ] + self.eventCodeEditor.setNodeCode ( handler_code, 'python' ) + #else : + # print '** no selection in handlers_list' + + elif idx == IDX_LINKS : + inputLinkSelected = False + link_id = None + tab_idx = self.ui.tabs_links_list.currentIndex () + + if tab_idx == 0 : + # input links + inputLinkSelected = True + links_item = self.ui.input_links_listWidget.currentItem () + if links_item is not None : ( link_id, ok ) = links_item.data ( QtCore.Qt.UserRole ).toInt () + + else : + # output links + links_item = self.ui.output_links_listWidget.currentItem () + if links_item is not None : ( link_id, ok ) = links_item.data ( QtCore.Qt.UserRole ).toInt () + + if link_id is not None : + link = None + + if inputLinkSelected : link = self.editNode.getInputLinkByID ( link_id ) + else : link = self.editNode.getOutputLinkByID ( link_id ) + + if link is not None : + ( srcNode, srcParam ) = link.getSrc () + ( dstNode, dstParam ) = link.getDst () + self.nodeLinkEditor.ui.src_node_lineEdit.setText ( srcNode.label ) + self.nodeLinkEditor.ui.src_param_lineEdit.setText ( srcParam.label ) + self.nodeLinkEditor.ui.src_id_lineEdit.setText ( str ( srcNode.id ) ) + self.nodeLinkEditor.ui.dst_node_lineEdit.setText ( dstNode.label ) + self.nodeLinkEditor.ui.dst_param_lineEdit.setText ( dstParam.label ) + self.nodeLinkEditor.ui.dst_id_lineEdit.setText ( str ( dstNode.id ) ) + self.connectSignals () + # + # onToolBoxIndexChanged + # + def onToolBoxIndexChanged ( self, idx ) : + if DEBUG_MODE : print '>> NodeEditorDialog::onToolBoxIndexChanged (idx = %d)' % idx + # + #self.disconnectSignals () + + if idx == IDX_PARAM : + # Input, Output Parameters + self.ui.tabWidget.setCurrentIndex ( TAB_PARAM ) + + elif idx == IDX_LINKS : + # Input, Output Links + self.ui.tabWidget.setCurrentIndex ( TAB_LINK_INFO ) + + elif idx == IDX_INTERNALS : + # Includes, Local Names, Code + self.ui.tabWidget.setCurrentIndex ( TAB_NODE_CODE ) + + elif idx == IDX_HANDLERS : + # Event Handlers code + self.ui.tabWidget.setCurrentIndex ( TAB_EVENT_CODE ) + + #self.connectSignals () + self.updateGui () + # + # onInputParamSelectionChanged + # + def onInputParamSelectionChanged ( self, paramName ) : + # + if DEBUG_MODE : print '>> NodeEditorDialog::onInputParamSelectionChanged (%s)' % paramName + param = self.editNode.getInputParamByName ( str ( paramName ) ) + self.nodeParamEditor.setParam ( param ) + # + # onOutputParamSelectionChanged + # + def onOutputParamSelectionChanged ( self, paramName ) : + # + if DEBUG_MODE : print '>> NodeEditorDialog::onOutputParamSelectionChanged (%s)' % paramName + param = self.editNode.getOutputParamByName ( str ( paramName ) ) + self.nodeParamEditor.setParam ( param ) + # + # onCodeListIndexChanged + # + def onCodeListIndexChanged ( self, idx ) : + # if DEBUG_MODE : print '>> NodeEditorDialog: onCodeListIndexChanged idx = %d' % idx + self.updateGui () + # + # onRemoveInternal + # + def onRemoveInternal ( self, internal ) : + # + internalsListWidget = self.ui.internals_list.ui.listWidget + self.editNode.internals.remove ( internal ) + item = internalsListWidget.currentItem () + internalsListWidget.takeItem ( internalsListWidget.currentRow () ) + internalsListWidget.removeItemWidget ( item ) + internalsListWidget.clearSelection () + internalsListWidget.setCurrentItem ( None ) + # + # onRemoveInclude + # + def onRemoveInclude ( self, include ) : + # + includesListWidget = self.ui.includes_list.ui.listWidget + self.editNode.includes.remove ( include ) + item = includesListWidget.currentItem() + includesListWidget.takeItem ( includesListWidget.currentRow () ) + includesListWidget.removeItemWidget ( item ) + includesListWidget.clearSelection () + includesListWidget.setCurrentItem ( None ) + # + # onRemoveParam + # + def onRemoveParam ( self, paramName ) : + # + isInputParam = False + tab_idx = self.ui.tabs_param_list.currentIndex () + if tab_idx == 0 : isInputParam = True + param = None + paramList = None + linkList = None + + if isInputParam : + param = self.editNode.getInputParamByName ( paramName ) + paramList = self.ui.input_list + linkList = self.ui.input_links_listWidget + else : + param = self.editNode.getOutputParamByName ( paramName ) + paramList = self.ui.output_list + linkList = self.ui.output_links_listWidget + + removedLinks = self.editNode.removeParam ( param ) + + # remove item from links list and node network + for link in removedLinks : + item_name = 'id=%d' % link.id + item = linkList.findItems ( item_name, QtCore.Qt.MatchExactly )[0] + linkList.takeItem ( linkList.row ( item ) ) + link.nodenet.removeLink ( link ) + + # remove item from param list + item = paramList.ui.listWidget.currentItem () + paramList.ui.listWidget.takeItem ( paramList.ui.listWidget.currentRow () ) + paramList.ui.listWidget.removeItemWidget ( item ) + paramList.ui.listWidget.clearSelection () + paramList.ui.listWidget.setCurrentItem ( None ) + + # remove item from code (invalidate code) + pass + # + # onRenameInternal + # + def onRenameInternal ( self, oldName, newName ) : + # + internalsListWidget = self.ui.internals_list.ui.listWidget + from core.meCommon import getUniqueName + idx = self.editNode.internals.index ( oldName ) + newName = getUniqueName ( newName, self.editNode.internals ) + self.editNode.internals [ idx ] = newName + + item = internalsListWidget.findItems ( oldName, QtCore.Qt.MatchExactly )[0] + item.setText ( newName ) + self.ui.internals_list.setName ( newName ) + internalsListWidget.clearSelection () + internalsListWidget.setCurrentItem ( item ) + # + # onRenameInclude + # + def onRenameInclude ( self, oldName, newName ) : + # + includesListWidget = self.ui.includes_list.ui.listWidget + from core.meCommon import getUniqueName + idx = self.editNode.includes.index ( oldName ) + newName = getUniqueName ( newName, self.editNode.includes ) + self.editNode.includes [ idx ] = newName + + item = includesListWidget.findItems ( oldName, QtCore.Qt.MatchExactly )[0] + item.setText ( newName ) + self.ui.includes_list.setName ( newName ) + includesListWidget.clearSelection () + includesListWidget.setCurrentItem ( item ) + # + # onRenameParam + # + def onRenameParam ( self, oldName, newName ) : + # + isInputParam = False + tab_idx = self.ui.tabs_param_list.currentIndex () + if tab_idx == 0 : isInputParam = True + param = None + paramList = None + if isInputParam : + param = self.editNode.getInputParamByName ( oldName ) + paramList = self.ui.input_list + else : + param = self.editNode.getOutputParamByName ( oldName ) + paramList = self.ui.output_list + + self.editNode.renameParamName ( param, newName ) + + item = paramList.ui.listWidget.findItems ( oldName, QtCore.Qt.MatchExactly )[0] + item.setText ( param.name ) + paramList.setName ( param.name ) + paramList.ui.listWidget.clearSelection () + paramList.ui.listWidget.setCurrentItem ( item ) + # + # onRenameParamLabel + # + def onRenameParamLabel ( self, oldName, newName ) : + # + param = self.nodeParamEditor.param + self.editNode.renameParamLabel ( param, newName ) + self.nodeParamEditor.ui.label_lineEdit.setText ( param.label ) + # + # onAddInternal + # + def onAddInternal ( self, newName ) : + # + if DEBUG_MODE : print '>> NodeEditorDialog::onAddInternal (%s) ' % (newName) + # name can be changed to be unique + newName = self.editNode.addInternal ( newName ) + internalsListWidget = self.ui.internals_list.ui.listWidget + internalsListWidget.addItem ( newName ) + internalsListWidget.setCurrentItem ( internalsListWidget.findItems ( newName, QtCore.Qt.MatchExactly )[0] ) + # + # onAddInclude + # + def onAddInclude ( self, newName ) : + # + if DEBUG_MODE : print '>> NodeEditorDialog::onAddInclude (%s) ' % (newName) + # name can be changed to be unique + newName = self.editNode.addInclude ( newName ) + includesListWidget = self.ui.includes_list.ui.listWidget + includesListWidget.addItem ( newName ) + includesListWidget.setCurrentItem ( includesListWidget.findItems ( newName, QtCore.Qt.MatchExactly )[0] ) + # + # onAddParam + # + def onAddParam ( self, newName ) : + # + if DEBUG_MODE : print '>> NodeEditorDialog::onAddParam (%s) ' % (newName) + isInputParam = False + paramType = None + isRibParam = ( self.editNode.type in VALID_RIB_NODE_TYPES ) + tab_idx = self.ui.tabs_param_list.currentIndex () + if tab_idx == 0 : isInputParam = True + # ask user about param type + typeDialog = QtGui.QDialog () # Qt.MSWindowsFixedSizeDialogHint + typeDialog.setModal ( True ) + + typeDialog.setWindowTitle ( 'Parameter Type' ) + typeDialog.resize (180, 100 ) + sizePolicy = QtGui.QSizePolicy ( QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed ) + sizePolicy.setHorizontalStretch ( 0 ) + sizePolicy.setVerticalStretch ( 0 ) + sizePolicy.setHeightForWidth ( typeDialog.sizePolicy().hasHeightForWidth() ) + typeDialog.setSizePolicy ( sizePolicy ) + typeDialog.setSizeGripEnabled ( False ) + + typeDialog.verticalLayout = QtGui.QVBoxLayout ( typeDialog ) + typeDialog.verticalLayout.setSizeConstraint ( QtGui.QLayout.SetMinimumSize ) + typeDialog.type_comboBox = QtGui.QComboBox ( typeDialog ) + + for label in VALID_PARAM_TYPES : typeDialog.type_comboBox.addItem ( label ) + + typeDialog.verticalLayout.addWidget ( typeDialog.type_comboBox ) + + typeDialog.btnBox = QtGui.QDialogButtonBox ( QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel, parent = typeDialog ) + typeDialog.btnBox.setCenterButtons ( True ) + typeDialog.verticalLayout.addWidget ( typeDialog.btnBox ) + + QtCore.QObject.connect ( typeDialog.btnBox, QtCore.SIGNAL ( 'accepted()' ), typeDialog.accept ) + QtCore.QObject.connect ( typeDialog.btnBox, QtCore.SIGNAL ( 'rejected()' ), typeDialog.reject ) + + if typeDialog.exec_() == QtGui.QDialog.Accepted : + paramType = str ( typeDialog.type_comboBox.currentText () ) + + if DEBUG_MODE : print '>> NodeEditorDialog::onAddParam typeDialog Accepted (%s)' % paramType + # create empty xml node parameter + dom = QtXml.QDomDocument ( newName ) + xmlnode = dom.createElement( 'property' ) + + xmlnode.setAttribute ( 'name', newName ) + xmlnode.setAttribute ( 'label', newName ) + xmlnode.setAttribute ( 'type', paramType ) + param = createParamFromXml ( xmlnode, isRibParam, isInputParam ) + item = QtGui.QListWidgetItem ( param.name ) + + paramListWidget = self.ui.input_list.ui.listWidget + + if isInputParam : + self.editNode.addInputParam ( param ) + else : + self.editNode.addOutputParam ( param ) + paramListWidget = self.ui.output_list.ui.listWidget + + paramListWidget.addItem ( param.name ) + paramListWidget.setCurrentItem ( paramListWidget.findItems ( param.name, QtCore.Qt.MatchExactly )[0] ) + #self.nodeParamEditor.setParam ( param ) + # + # onEditCode + # + def onEditCode ( self ) : + # + if DEBUG_MODE : print '>> NodeEditorDialog::onEditCode' + if self.nodeCodeEditor is not None : + #self.nodeCodeEditor.ui.textEdit + self.editNode.code = str ( self.nodeCodeEditor.ui.textEdit.toPlainText () ) + # + # onEditControlCode + # + def onEditControlCode ( self ) : + # + if DEBUG_MODE : print '>> NodeEditorDialog::onEditControlCode' + if self.controlCodeEditor is not None : + self.editNode.control_code = str ( self.controlCodeEditor.ui.textEdit.toPlainText () ) + # + # onEditParamCode + # + def onEditParamCode ( self ) : + # + if DEBUG_MODE : print '>> NodeEditorDialog::onEditParamCode' + if self.paramCodeEditor is not None : + param = self.nodeParamEditor.param + if param is not None and param.type == 'control' : + param.code = str ( self.paramCodeEditor.ui.textEdit.toPlainText () ) + #print '*** set (%s).param.code :' % param.label + #print param.code + # + # onEditEventCode + # + def onEditEventCode ( self ) : + # + if DEBUG_MODE : print '>> NodeEditorDialog::onEditEventCode' + if self.eventCodeEditor is not None : + handler_item = self.ui.handlers_list.ui.listWidget.currentItem () + if handler_item is not None : + handler = str ( handler_item.text () ) + self.editNode.event_code [ handler ] = str ( self.eventCodeEditor.ui.textEdit.toPlainText () ) + + # + # Ignore default Enter press event + # + def keyPressEvent ( self, event ) : + # + #if DEBUG_MODE : print '>> NodeEditorDialog::keyPressEvent' + if event.key () == QtCore.Qt.Key_Enter or event.key () == QtCore.Qt.Key_Return : + event.ignore () + else: + QtGui.QDialog.keyPressEvent ( self, event ) + # + # accept + # + def accept ( self ) : + # + if DEBUG_MODE : print '>> NodeEditorDialog::accept' + self.done ( QtGui.QDialog.Accepted ) diff --git a/gui/nodeEditor/codeSyntaxHighlighter.py b/gui/nodeEditor/codeSyntaxHighlighter.py index 034d5de..a5b67a5 100644 --- a/gui/nodeEditor/codeSyntaxHighlighter.py +++ b/gui/nodeEditor/codeSyntaxHighlighter.py @@ -9,7 +9,7 @@ """ import os, sys -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui from core.meCommon import * from global_vars import app_global_vars diff --git a/gui/nodeEditor/nodeCodeEditor.py b/gui/nodeEditor/nodeCodeEditor.py index 3ca0200..46582d9 100644 --- a/gui/nodeEditor/nodeCodeEditor.py +++ b/gui/nodeEditor/nodeCodeEditor.py @@ -8,8 +8,7 @@ Dialog for managing node code """ -import os, sys -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui from core.meCommon import * from global_vars import app_global_vars @@ -18,56 +17,63 @@ from codeSyntaxHighlighter import CodeSyntaxHighlighter from ui_nodeCodeEditor import Ui_NodeCodeEditor + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + # # NodeCodeEditor # -class NodeCodeEditor ( QtGui.QWidget ): - # - # __init__ - # - def __init__ ( self, parent, editNodeCode = None ) : - # - QtGui.QWidget.__init__ ( self, parent ) - - self.editNodeCode = editNodeCode - - #self.debugPrint() - self.buildGui() - # - # buildGui - # - def buildGui ( self ) : - # build the gui created with QtDesigner - self.ui = Ui_NodeCodeEditor ( ) - self.ui.setupUi ( self ) - - # - # setNodeCode - # - def setNodeCode ( self, editNodeCode, mode = 'SL', readOnly = False ) : - # - self.editNodeCode = editNodeCode - - if self.editNodeCode is not None : - code = self.editNodeCode - - doc = QtGui.QTextDocument () - - font = QtGui.QFont( 'Monospace' ) - font.setFixedPitch ( True ) - font.setPointSize ( UI.FONT_HEIGHT ) - - codeSyntax = CodeSyntaxHighlighter ( doc, mode ) - - self.ui.textEdit.setDocument ( doc ) - self.ui.textEdit.setTabStopWidth ( UI.TAB_SIZE ) - self.ui.textEdit.setFont ( font ) - self.ui.textEdit.setLineWrapMode ( QtGui.QTextEdit.NoWrap ) - self.ui.textEdit.setReadOnly ( readOnly ) - else : - code = '' - self.ui.textEdit.setPlainText ( code ) - - - - +class NodeCodeEditor ( QtModule.QWidget ): + # + # __init__ + # + def __init__ ( self, parent, editNodeCode = None ) : + # + QtModule.QWidget.__init__ ( self, parent ) + + self.editNodeCode = editNodeCode + + #self.debugPrint() + self.buildGui() + # + # buildGui + # + def buildGui ( self ) : + # build the gui created with QtDesigner + self.ui = Ui_NodeCodeEditor ( ) + self.ui.setupUi ( self ) + + # + # setNodeCode + # + def setNodeCode ( self, editNodeCode, mode = 'SL', readOnly = False ) : + # + self.editNodeCode = editNodeCode + + if self.editNodeCode is not None : + code = self.editNodeCode + + doc = QtGui.QTextDocument () + + font = QtGui.QFont( 'Monospace' ) + font.setFixedPitch ( True ) + font.setPointSize ( UI.FONT_HEIGHT ) + + codeSyntax = CodeSyntaxHighlighter ( doc, mode ) + + self.ui.textEdit.setDocument ( doc ) + self.ui.textEdit.setTabStopWidth ( UI.TAB_SIZE ) + self.ui.textEdit.setFont ( font ) + self.ui.textEdit.setLineWrapMode ( QtGui.QTextEdit.NoWrap ) + self.ui.textEdit.setReadOnly ( readOnly ) + else : + code = '' + self.ui.textEdit.setPlainText ( code ) + + + + diff --git a/gui/nodeEditor/nodeLinkEditor.py b/gui/nodeEditor/nodeLinkEditor.py index 1aac233..d08c6d6 100644 --- a/gui/nodeEditor/nodeLinkEditor.py +++ b/gui/nodeEditor/nodeLinkEditor.py @@ -1,15 +1,14 @@ -#=============================================================================== -# nodeLinkEditor.py -# -# ver. 1.0.0 -# Author: Yuri Meshalkin (aka mesh) (yuri.meshalkin@gmail.com) -# -# Dialog for managing node -# -#=============================================================================== +""" + + nodeLinkEditor.py + + ver. 1.0.0 + Author: Yuri Meshalkin (aka mesh) (yuri.meshalkin@gmail.com) -import os, sys -from PyQt4 import QtCore, QtGui + Dialog for managing node links + +""" +from core.mePyQt import QtCore, QtGui from core.meCommon import * from global_vars import app_global_vars @@ -19,53 +18,59 @@ from core.node import Node from ui_nodeLinkEditor import Ui_NodeLinkEditor + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets # +# NodeLinkEditor # -# -class NodeLinkEditor ( QtGui.QWidget ) : - # - # __init__ - # - def __init__ ( self, parent ) : - # - QtGui.QWidget.__init__ ( self ) +class NodeLinkEditor ( QtModule.QWidget ) : + # + # __init__ + # + def __init__ ( self, parent ) : + # + QtModule.QWidget.__init__ ( self ) - self.buildGui () - # - # buildGui - # - def buildGui ( self ) : - # build the gui created with QtDesigner - self.ui = Ui_NodeLinkEditor () - self.ui.setupUi ( self ) - # - # connectSignals - # - def connectSignals ( self ) : - # QtCore.QObject. - pass - """ - self.connect ( self.ui.name_lineEdit, QtCore.SIGNAL( 'editingFinished()' ), self.onEditNodeStrAttrName ) - self.connect ( self.ui.label_lineEdit, QtCore.SIGNAL( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) - self.connect ( self.ui.master_lineEdit, QtCore.SIGNAL( 'editingFinished()' ), self.onEditNodeStrAttrMaster ) - self.connect ( self.ui.author_lineEdit, QtCore.SIGNAL( 'editingFinished()' ), self.onEditNodeStrAttrAuthor ) - self.connect ( self.ui.icon_lineEdit, QtCore.SIGNAL( 'editingFinished()' ), self.onEditNodeStrAttrIcon ) - self.connect ( self.ui.type_comboBox, QtCore.SIGNAL( 'activated(int)' ), self.onEditNodeType ) - self.connect ( self.ui.help_plainTextEdit, QtCore.SIGNAL( 'textChanged()' ), self.onEditNodeTxtAttr ) - """ - # - # disconnectSignals - # - def disconnectSignals ( self ) : - # - pass - """ - if self.editNode is not None : - self.disconnect ( self.ui.name_lineEdit, QtCore.SIGNAL( 'editingFinished()' ), self.onEditNodeStrAttrName ) - self.disconnect ( self.ui.label_lineEdit, QtCore.SIGNAL( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) - self.disconnect ( self.ui.master_lineEdit, QtCore.SIGNAL( 'editingFinished()' ), self.onEditNodeStrAttrMaster ) - self.disconnect ( self.ui.author_lineEdit, QtCore.SIGNAL( 'editingFinished()' ), self.onEditNodeStrAttrAuthor ) - self.disconnect ( self.ui.icon_lineEdit, QtCore.SIGNAL( 'editingFinished()' ), self.onEditNodeStrAttrIcon ) - self.disconnect ( self.ui.type_comboBox, QtCore.SIGNAL( 'activated(int)' ), self.onEditNodeType ) - self.disconnect ( self.ui.help_plainTextEdit, QtCore.SIGNAL( 'textChanged()' ), self.onEditNodeTxtAttr ) - """ \ No newline at end of file + self.buildGui () + # + # buildGui + # + def buildGui ( self ) : + # build the gui created with QtDesigner + self.ui = Ui_NodeLinkEditor () + self.ui.setupUi ( self ) + # + # connectSignals + # + def connectSignals ( self ) : + # QtCore.QObject. + pass + """ + self.connect ( self.ui.name_lineEdit, QtCore.SIGNAL( 'editingFinished()' ), self.onEditNodeStrAttrName ) + self.connect ( self.ui.label_lineEdit, QtCore.SIGNAL( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) + self.connect ( self.ui.master_lineEdit, QtCore.SIGNAL( 'editingFinished()' ), self.onEditNodeStrAttrMaster ) + self.connect ( self.ui.author_lineEdit, QtCore.SIGNAL( 'editingFinished()' ), self.onEditNodeStrAttrAuthor ) + self.connect ( self.ui.icon_lineEdit, QtCore.SIGNAL( 'editingFinished()' ), self.onEditNodeStrAttrIcon ) + self.connect ( self.ui.type_comboBox, QtCore.SIGNAL( 'activated(int)' ), self.onEditNodeType ) + self.connect ( self.ui.help_plainTextEdit, QtCore.SIGNAL( 'textChanged()' ), self.onEditNodeTxtAttr ) + """ + # + # disconnectSignals + # + def disconnectSignals ( self ) : + # + pass + """ + if self.editNode is not None : + self.disconnect ( self.ui.name_lineEdit, QtCore.SIGNAL( 'editingFinished()' ), self.onEditNodeStrAttrName ) + self.disconnect ( self.ui.label_lineEdit, QtCore.SIGNAL( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) + self.disconnect ( self.ui.master_lineEdit, QtCore.SIGNAL( 'editingFinished()' ), self.onEditNodeStrAttrMaster ) + self.disconnect ( self.ui.author_lineEdit, QtCore.SIGNAL( 'editingFinished()' ), self.onEditNodeStrAttrAuthor ) + self.disconnect ( self.ui.icon_lineEdit, QtCore.SIGNAL( 'editingFinished()' ), self.onEditNodeStrAttrIcon ) + self.disconnect ( self.ui.type_comboBox, QtCore.SIGNAL( 'activated(int)' ), self.onEditNodeType ) + self.disconnect ( self.ui.help_plainTextEdit, QtCore.SIGNAL( 'textChanged()' ), self.onEditNodeTxtAttr ) + """ \ No newline at end of file diff --git a/gui/nodeEditor/nodeNamesEditor.py b/gui/nodeEditor/nodeNamesEditor.py index 4793a0c..31053ba 100644 --- a/gui/nodeEditor/nodeNamesEditor.py +++ b/gui/nodeEditor/nodeNamesEditor.py @@ -8,98 +8,104 @@ Widget for manage names in list """ -import os, sys -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui #from core.meCommon import * from global_vars import app_global_vars, DEBUG_MODE from ui_nodeNamesEditor import Ui_NodeNamesEditor + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + # # NodeNamesEditor # -class NodeNamesEditor ( QtGui.QWidget ) : - # - # __init__ - # - def __init__ ( self, parent ) : - # - QtGui.QWidget.__init__ ( self, parent ) - self.saved_text = '' - self.approvedNewName = '' - self.buildGui () - # - # buildGui - # - def buildGui ( self ): - # build the gui created with QtDesigner - self.ui = Ui_NodeNamesEditor ( ) - self.ui.setupUi ( self ) - # - # setName - # - def setName ( self, newName ) : - # - if newName == '' : - if self.saved_text != '' : - newName = self.saved_text +class NodeNamesEditor ( QtModule.QWidget ) : + # + # __init__ + # + def __init__ ( self, parent ) : + # + QtModule.QWidget.__init__ ( self, parent ) + self.saved_text = '' + self.approvedNewName = '' + self.buildGui () + # + # buildGui + # + def buildGui ( self ): + # build the gui created with QtDesigner + self.ui = Ui_NodeNamesEditor ( ) + self.ui.setupUi ( self ) + # + # setName + # + def setName ( self, newName ) : + # + if newName == '' : + if self.saved_text != '' : + newName = self.saved_text - self.ui.name_lineEdit.setText ( newName ) - self.saved_text = newName - # - # onAddItem - # - def onAddItem ( self ) : - # - if DEBUG_MODE : print '>> NodeNamesEditor: onAddItem' - new_text = str ( self.ui.name_lineEdit.text () ).strip () - if new_text != '' : - self.emit ( QtCore.SIGNAL ( 'addItem' ), new_text ) - # - # onRemoveItem - # - def onRemoveItem ( self ) : - # - if DEBUG_MODE : print '>> NodeNamesEditor::onRemoveItem' - list_item = self.ui.listWidget.currentItem () - - if list_item is not None : - item_text = str ( list_item.text () ) - #self.ui.listWidget.takeItem ( self.ui.listWidget.currentRow () ) - #self.ui.listWidget.removeItemWidget ( list_item ) - self.emit ( QtCore.SIGNAL ( 'removeItem' ), item_text ) - # - # onRenameItem - # - def onRenameItem ( self ) : - # - if DEBUG_MODE : print '>> NodeNamesEditor.onRenameItem' - new_text = str ( self.ui.name_lineEdit.text () ).strip () - - if new_text == '' : - if self.saved_text != '' : - new_text = self.saved_text - self.ui.name_lineEdit.setText ( new_text ) - - list_item = self.ui.listWidget.currentItem () - - if list_item is not None : # e.g. listWidget is not empty - old_text = list_item.text () - if new_text != old_text : - self.emit ( QtCore.SIGNAL( 'renameItem' ), old_text, new_text ) - else : - self.ui.listWidget.clearSelection () - self.ui.listWidget.setCurrentItem ( None ) - # - # onSelectionChanged - # - def onSelectionChanged ( self ) : - # - if DEBUG_MODE : print '>> NodeNamesEditor.onSelectionChanged' - list_item = self.ui.listWidget.currentItem () - - if list_item is not None : - self.saved_text = str ( list_item.text() ) - self.ui.name_lineEdit.setText ( self.saved_text ) - self.emit ( QtCore.SIGNAL ( 'selectionChanged' ), self.saved_text ) - \ No newline at end of file + self.ui.name_lineEdit.setText ( newName ) + self.saved_text = newName + # + # onAddItem + # + def onAddItem ( self ) : + # + if DEBUG_MODE : print '>> NodeNamesEditor: onAddItem' + new_text = str ( self.ui.name_lineEdit.text () ).strip () + if new_text != '' : + self.emit ( QtCore.SIGNAL ( 'addItem' ), new_text ) + # + # onRemoveItem + # + def onRemoveItem ( self ) : + # + if DEBUG_MODE : print '>> NodeNamesEditor::onRemoveItem' + list_item = self.ui.listWidget.currentItem () + + if list_item is not None : + item_text = str ( list_item.text () ) + #self.ui.listWidget.takeItem ( self.ui.listWidget.currentRow () ) + #self.ui.listWidget.removeItemWidget ( list_item ) + self.emit ( QtCore.SIGNAL ( 'removeItem' ), item_text ) + # + # onRenameItem + # + def onRenameItem ( self ) : + # + if DEBUG_MODE : print '>> NodeNamesEditor.onRenameItem' + new_text = str ( self.ui.name_lineEdit.text () ).strip () + + if new_text == '' : + if self.saved_text != '' : + new_text = self.saved_text + self.ui.name_lineEdit.setText ( new_text ) + + list_item = self.ui.listWidget.currentItem () + + if list_item is not None : # e.g. listWidget is not empty + old_text = list_item.text () + if new_text != old_text : + self.emit ( QtCore.SIGNAL( 'renameItem' ), old_text, new_text ) + else : + self.ui.listWidget.clearSelection () + self.ui.listWidget.setCurrentItem ( None ) + # + # onSelectionChanged + # + def onSelectionChanged ( self ) : + # + if DEBUG_MODE : print '>> NodeNamesEditor.onSelectionChanged' + list_item = self.ui.listWidget.currentItem () + + if list_item is not None : + self.saved_text = str ( list_item.text() ) + self.ui.name_lineEdit.setText ( self.saved_text ) + self.emit ( QtCore.SIGNAL ( 'selectionChanged' ), self.saved_text ) + \ No newline at end of file diff --git a/gui/nodeEditor/nodeParamEditor.py b/gui/nodeEditor/nodeParamEditor.py index 5f46095..6b2455f 100644 --- a/gui/nodeEditor/nodeParamEditor.py +++ b/gui/nodeEditor/nodeParamEditor.py @@ -8,8 +8,7 @@ Dialog for managing node parameters """ -import os, sys -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui from core.meCommon import * from global_vars import app_global_vars, DEBUG_MODE, VALID_PARAM_TYPES @@ -28,314 +27,320 @@ from gui.params.ControlWidget import ControlWidget from ui_nodeParamEditor import Ui_NodeParamEditor + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets # # NodeParamEditor # -class NodeParamEditor ( QtGui.QWidget ) : - # - # __init__ - # - def __init__ ( self, parent ) : - # - QtGui.QWidget.__init__ ( self, parent ) - self.param = None - self.param_default = None - self.paramWidgets = { 'string' : StringWidget - ,'image' : StringWidget - ,'rib' : StringWidget - ,'surface' : StringWidget - ,'displacement' : StringWidget - ,'light' : StringWidget - ,'volume' : StringWidget - ,'float' : FloatWidget - ,'int' : IntWidget - ,'color' : ColorWidget - ,'normal' : NormalWidget - ,'transform' : PointWidget - ,'point' : PointWidget - ,'vector' : VectorWidget - ,'matrix' : MatrixWidget - ,'text' : TextWidget - ,'control' : ControlWidget - ,'shader' : StringWidget - ,'geom' : StringWidget - } +class NodeParamEditor ( QtModule.QWidget ) : + # + # __init__ + # + def __init__ ( self, parent ) : + # + QtModule.QWidget.__init__ ( self, parent ) + self.param = None + self.param_default = None + self.paramWidgets = { 'string' : StringWidget + ,'image' : StringWidget + ,'rib' : StringWidget + ,'surface' : StringWidget + ,'displacement' : StringWidget + ,'light' : StringWidget + ,'volume' : StringWidget + ,'float' : FloatWidget + ,'int' : IntWidget + ,'color' : ColorWidget + ,'normal' : NormalWidget + ,'transform' : PointWidget + ,'point' : PointWidget + ,'vector' : VectorWidget + ,'matrix' : MatrixWidget + ,'text' : TextWidget + ,'control' : ControlWidget + ,'shader' : StringWidget + ,'geom' : StringWidget + } - self.buildGui() - # - # - def __delete__ ( self, obj ) : - # - print '* NodeParamEditor closed... %s' % str( obj ) - # - # buildGui - # - def buildGui ( self ) : - # build the gui created with QtDesigner - self.ui = Ui_NodeParamEditor ( ) - self.ui.setupUi ( self ) + self.buildGui() + # + # + def __delete__ ( self, obj ) : + # + print '* NodeParamEditor closed... %s' % str( obj ) + # + # buildGui + # + def buildGui ( self ) : + # build the gui created with QtDesigner + self.ui = Ui_NodeParamEditor ( ) + self.ui.setupUi ( self ) - # correct UI sizes for some controls - self.ui.check_enabled.setMinimumSize ( QtCore.QSize ( UI.CHECK_WIDTH, UI.HEIGHT ) ) - self.ui.check_enabled.setMaximumSize ( QtCore.QSize ( UI.CHECK_WIDTH, UI.HEIGHT ) ) - - self.ui.check_display.setMinimumSize ( QtCore.QSize ( UI.CHECK_WIDTH, UI.HEIGHT ) ) - self.ui.check_display.setMaximumSize ( QtCore.QSize ( UI.CHECK_WIDTH, UI.HEIGHT ) ) + # correct UI sizes for some controls + self.ui.check_enabled.setMinimumSize ( QtCore.QSize ( UI.CHECK_WIDTH, UI.HEIGHT ) ) + self.ui.check_enabled.setMaximumSize ( QtCore.QSize ( UI.CHECK_WIDTH, UI.HEIGHT ) ) + + self.ui.check_display.setMinimumSize ( QtCore.QSize ( UI.CHECK_WIDTH, UI.HEIGHT ) ) + self.ui.check_display.setMaximumSize ( QtCore.QSize ( UI.CHECK_WIDTH, UI.HEIGHT ) ) - self.ui.check_shader.setMinimumSize ( QtCore.QSize ( UI.CHECK_WIDTH, UI.HEIGHT ) ) - self.ui.check_shader.setMaximumSize ( QtCore.QSize ( UI.CHECK_WIDTH, UI.HEIGHT ) ) + self.ui.check_shader.setMinimumSize ( QtCore.QSize ( UI.CHECK_WIDTH, UI.HEIGHT ) ) + self.ui.check_shader.setMaximumSize ( QtCore.QSize ( UI.CHECK_WIDTH, UI.HEIGHT ) ) - for label in VALID_PARAM_TYPES : self.ui.type_comboBox.addItem ( label ) - - self.ui.type_comboBox.setCurrentIndex ( -1 ) - self.ui.type_comboBox.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) - self.ui.type_comboBox.setMaximumSize ( QtCore.QSize( UI.MAX, UI.COMBO_HEIGHT ) ) + for label in VALID_PARAM_TYPES : self.ui.type_comboBox.addItem ( label ) + + self.ui.type_comboBox.setCurrentIndex ( -1 ) + self.ui.type_comboBox.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) + self.ui.type_comboBox.setMaximumSize ( QtCore.QSize( UI.MAX, UI.COMBO_HEIGHT ) ) - # temporary disabled, until "how to do it gracefully" will be clear ... - self.ui.type_comboBox.setEnabled ( False ) + # temporary disabled, until "how to do it gracefully" will be clear ... + self.ui.type_comboBox.setEnabled ( False ) - for label in [ 'None', 'uniform', 'varying', ] : - self.ui.detail_comboBox.addItem ( label ) - self.ui.detail_comboBox.setCurrentIndex ( -1 ) - self.ui.detail_comboBox.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) - self.ui.detail_comboBox.setMaximumSize ( QtCore.QSize( UI.MAX, UI.COMBO_HEIGHT ) ) + for label in [ 'None', 'uniform', 'varying', ] : + self.ui.detail_comboBox.addItem ( label ) + self.ui.detail_comboBox.setCurrentIndex ( -1 ) + self.ui.detail_comboBox.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) + self.ui.detail_comboBox.setMaximumSize ( QtCore.QSize( UI.MAX, UI.COMBO_HEIGHT ) ) - for label in [ 'None', 'internal', 'external', 'primitive', 'attribute' ] : - self.ui.provider_comboBox.addItem ( label ) - self.ui.provider_comboBox.setCurrentIndex ( -1 ) - self.ui.provider_comboBox.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) - self.ui.provider_comboBox.setMaximumSize ( QtCore.QSize( UI.MAX, UI.COMBO_HEIGHT ) ) + for label in [ 'None', 'internal', 'external', 'primitive', 'attribute' ] : + self.ui.provider_comboBox.addItem ( label ) + self.ui.provider_comboBox.setCurrentIndex ( -1 ) + self.ui.provider_comboBox.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) + self.ui.provider_comboBox.setMaximumSize ( QtCore.QSize( UI.MAX, UI.COMBO_HEIGHT ) ) - for label in [ 'None', 'slider', 'switch', 'selector', 'file', 'button' ] : - self.ui.subtype_comboBox.addItem ( label ) - self.ui.subtype_comboBox.setCurrentIndex ( -1 ) - self.ui.subtype_comboBox.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) - self.ui.subtype_comboBox.setMaximumSize ( QtCore.QSize( UI.MAX, UI.COMBO_HEIGHT ) ) - # - # As paramWidet is monitoring a change of param.value only, - # we need to cynchronize changing of param_default.value with param.default - # - def onParamDefValueChanged ( self, param ) : - # - if DEBUG_MODE : print '* onParamDefValueChanged' - self.param.default = self.param_default.value - self.emit ( QtCore.SIGNAL ( 'changeParamDefValue' ), self.param ) - # - # onParamValueChanged - # - def onParamValueChanged ( self, param ) : - # - if DEBUG_MODE : print '* onParamValueChanged' - self.param.value = param.value - self.emit ( QtCore.SIGNAL ( 'changeParamValue' ), self.param ) - # - # connectSignals - # - def connectSignals ( self ) : - # - self.connect ( self.param_default, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamDefValueChanged ) - self.connect ( self.param, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamValueChanged ) - self.connect ( self.ui.name_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditParamName ) - self.connect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditParamLabel ) - self.connect ( self.ui.check_enabled, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onEditParamEnabled ) - self.connect ( self.ui.check_display, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onEditParamDisplay ) - self.connect ( self.ui.check_shader, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onEditParamShader ) - self.connect ( self.ui.type_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamType ) - self.connect ( self.ui.detail_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamDetail ) - self.connect ( self.ui.provider_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamProvider ) - self.connect ( self.ui.subtype_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamSubtype ) - self.connect ( self.ui.range_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditParamRange ) - self.connect ( self.ui.descr_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditParamHelp ) - # - # disconnectSignals - # - def disconnectSignals ( self ) : - # - if self.param_default is not None : - self.disconnect ( self.param_default, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamDefValueChanged ) - if self.param is not None : - self.disconnect ( self.param, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamValueChanged ) - self.disconnect ( self.ui.name_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditParamName ) - self.disconnect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditParamLabel ) - self.disconnect ( self.ui.check_enabled, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onEditParamEnabled ) - self.disconnect ( self.ui.check_display, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onEditParamDisplay ) - self.disconnect ( self.ui.check_shader, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onEditParamShader ) - self.disconnect ( self.ui.type_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamType ) - self.disconnect ( self.ui.detail_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamDetail ) - self.disconnect ( self.ui.provider_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamProvider ) - self.disconnect ( self.ui.subtype_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamSubtype ) - self.disconnect ( self.ui.descr_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditParamHelp ) - # - # reset - # - def reset ( self ) : - # - self.ui.name_lineEdit.setText ( '' ) - self.ui.label_lineEdit.setText ( '' ) - - self.ui.check_enabled.setChecked ( True ) - self.ui.check_display.setChecked ( True ) - self.ui.check_shader.setChecked ( False ) + for label in [ 'None', 'slider', 'switch', 'selector', 'file', 'button' ] : + self.ui.subtype_comboBox.addItem ( label ) + self.ui.subtype_comboBox.setCurrentIndex ( -1 ) + self.ui.subtype_comboBox.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) + self.ui.subtype_comboBox.setMaximumSize ( QtCore.QSize( UI.MAX, UI.COMBO_HEIGHT ) ) + # + # As paramWidet is monitoring a change of param.value only, + # we need to cynchronize changing of param_default.value with param.default + # + def onParamDefValueChanged ( self, param ) : + # + if DEBUG_MODE : print '* onParamDefValueChanged' + self.param.default = self.param_default.value + self.emit ( QtCore.SIGNAL ( 'changeParamDefValue' ), self.param ) + # + # onParamValueChanged + # + def onParamValueChanged ( self, param ) : + # + if DEBUG_MODE : print '* onParamValueChanged' + self.param.value = param.value + self.emit ( QtCore.SIGNAL ( 'changeParamValue' ), self.param ) + # + # connectSignals + # + def connectSignals ( self ) : + # + self.connect ( self.param_default, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamDefValueChanged ) + self.connect ( self.param, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamValueChanged ) + self.connect ( self.ui.name_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditParamName ) + self.connect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditParamLabel ) + self.connect ( self.ui.check_enabled, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onEditParamEnabled ) + self.connect ( self.ui.check_display, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onEditParamDisplay ) + self.connect ( self.ui.check_shader, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onEditParamShader ) + self.connect ( self.ui.type_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamType ) + self.connect ( self.ui.detail_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamDetail ) + self.connect ( self.ui.provider_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamProvider ) + self.connect ( self.ui.subtype_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamSubtype ) + self.connect ( self.ui.range_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditParamRange ) + self.connect ( self.ui.descr_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditParamHelp ) + # + # disconnectSignals + # + def disconnectSignals ( self ) : + # + if self.param_default is not None : + self.disconnect ( self.param_default, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamDefValueChanged ) + if self.param is not None : + self.disconnect ( self.param, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamValueChanged ) + self.disconnect ( self.ui.name_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditParamName ) + self.disconnect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditParamLabel ) + self.disconnect ( self.ui.check_enabled, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onEditParamEnabled ) + self.disconnect ( self.ui.check_display, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onEditParamDisplay ) + self.disconnect ( self.ui.check_shader, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onEditParamShader ) + self.disconnect ( self.ui.type_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamType ) + self.disconnect ( self.ui.detail_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamDetail ) + self.disconnect ( self.ui.provider_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamProvider ) + self.disconnect ( self.ui.subtype_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamSubtype ) + self.disconnect ( self.ui.descr_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditParamHelp ) + # + # reset + # + def reset ( self ) : + # + self.ui.name_lineEdit.setText ( '' ) + self.ui.label_lineEdit.setText ( '' ) + + self.ui.check_enabled.setChecked ( True ) + self.ui.check_display.setChecked ( True ) + self.ui.check_shader.setChecked ( False ) - self.ui.type_comboBox.setCurrentIndex( -1 ) - self.ui.detail_comboBox.setCurrentIndex ( -1 ) - self.ui.provider_comboBox.setCurrentIndex ( -1 ) - self.ui.subtype_comboBox.setCurrentIndex ( -1 ) - self.ui.range_lineEdit.setText ( '' ) + self.ui.type_comboBox.setCurrentIndex( -1 ) + self.ui.detail_comboBox.setCurrentIndex ( -1 ) + self.ui.provider_comboBox.setCurrentIndex ( -1 ) + self.ui.subtype_comboBox.setCurrentIndex ( -1 ) + self.ui.range_lineEdit.setText ( '' ) - doc = QtGui.QTextDocument () - doc.setPlainText ( '' ) - layout = QtGui.QPlainTextDocumentLayout ( doc ) - doc.setDocumentLayout ( layout ) - self.ui.descr_plainTextEdit.setDocument ( doc ) - # - # Remove stackedWidget's layout every time, - # when current parameter (or it's type) is changing - # - def removeValueWidget ( self ) : - # - while True : - currentWidget = self.ui.value_stackedWidget.currentWidget () - if currentWidget is not None : - #print '> removeWidget: %s' % str( currentWidget ) - self.ui.value_stackedWidget.removeWidget ( currentWidget ) - else : - break - # - # setParam - # - def setParam ( self, param ) : - # - self.removeValueWidget() - self.disconnectSignals() - self.param = param - - if self.param is not None : - #import copy - self.param_default = self.param.copy() # duplicate param for default value editing - self.param_default.value = param.default + doc = QtGui.QTextDocument () + doc.setPlainText ( '' ) + layout = QtGui.QPlainTextDocumentLayout ( doc ) + doc.setDocumentLayout ( layout ) + self.ui.descr_plainTextEdit.setDocument ( doc ) + # + # Remove stackedWidget's layout every time, + # when current parameter (or it's type) is changing + # + def removeValueWidget ( self ) : + # + while True : + currentWidget = self.ui.value_stackedWidget.currentWidget () + if currentWidget is not None : + #print '> removeWidget: %s' % str( currentWidget ) + self.ui.value_stackedWidget.removeWidget ( currentWidget ) + else : + break + # + # setParam + # + def setParam ( self, param ) : + # + self.removeValueWidget() + self.disconnectSignals() + self.param = param + + if self.param is not None : + #import copy + self.param_default = self.param.copy() # duplicate param for default value editing + self.param_default.value = param.default - self.ui.name_lineEdit.setText ( self.param.name ) - self.ui.label_lineEdit.setText ( self.param.label ) - - self.ui.check_enabled.setChecked ( self.param.enabled ) - self.ui.check_display.setChecked ( self.param.display ) - self.ui.check_shader.setChecked ( self.param.shaderParam ) + self.ui.name_lineEdit.setText ( self.param.name ) + self.ui.label_lineEdit.setText ( self.param.label ) + + self.ui.check_enabled.setChecked ( self.param.enabled ) + self.ui.check_display.setChecked ( self.param.display ) + self.ui.check_shader.setChecked ( self.param.shaderParam ) - self.ui.type_comboBox.setCurrentIndex ( self.ui.type_comboBox.findText ( self.param.type ) ) - self.ui.detail_comboBox.setCurrentIndex ( self.ui.detail_comboBox.findText ( self.param.detail ) ) - self.ui.provider_comboBox.setCurrentIndex ( self.ui.provider_comboBox.findText ( self.param.provider ) ) - self.ui.subtype_comboBox.setCurrentIndex ( self.ui.subtype_comboBox.findText ( self.param.subtype ) ) - self.ui.range_lineEdit.setText ( self.param.range ) + self.ui.type_comboBox.setCurrentIndex ( self.ui.type_comboBox.findText ( self.param.type ) ) + self.ui.detail_comboBox.setCurrentIndex ( self.ui.detail_comboBox.findText ( self.param.detail ) ) + self.ui.provider_comboBox.setCurrentIndex ( self.ui.provider_comboBox.findText ( self.param.provider ) ) + self.ui.subtype_comboBox.setCurrentIndex ( self.ui.subtype_comboBox.findText ( self.param.subtype ) ) + self.ui.range_lineEdit.setText ( self.param.range ) - doc = QtGui.QTextDocument () - help_text = '' - if self.param.help != None : help_text = self.param.help + doc = QtGui.QTextDocument () + help_text = '' + if self.param.help != None : help_text = self.param.help - doc.setPlainText ( help_text ) - layout = QtGui.QPlainTextDocumentLayout ( doc ) - doc.setDocumentLayout( layout ) + doc.setPlainText ( help_text ) + layout = QtGui.QPlainTextDocumentLayout ( doc ) + doc.setDocumentLayout( layout ) - self.ui.descr_plainTextEdit.setDocument ( doc ) - # - # setup param values view - # - paramsLayout = QtGui.QGridLayout () - paramsLayout.setContentsMargins ( 2, 2, 2, 2 ) - paramsLayout.setSizeConstraint ( QtGui.QLayout.SetNoConstraint ) - paramsLayout.setVerticalSpacing ( 4 ) - paramsLayout.setColumnStretch ( 1, 1 ) - paramsLayout.setRowStretch ( 2, 1 ) - - frame = QtGui.QFrame () - frame.setLayout ( paramsLayout ) + self.ui.descr_plainTextEdit.setDocument ( doc ) + # + # setup param values view + # + paramsLayout = QtGui.QGridLayout () + paramsLayout.setContentsMargins ( 2, 2, 2, 2 ) + paramsLayout.setSizeConstraint ( QtGui.QLayout.SetNoConstraint ) + paramsLayout.setVerticalSpacing ( 4 ) + paramsLayout.setColumnStretch ( 1, 1 ) + paramsLayout.setRowStretch ( 2, 1 ) + + frame = QtGui.QFrame () + frame.setLayout ( paramsLayout ) - if self.param.type in self.paramWidgets.keys () : - print '>> Create %s param widget' % self.param.type + if self.param.type in self.paramWidgets.keys () : + print '>> Create %s param widget' % self.param.type - # create paramWidget without GfxNode and ignoreSubtype = True - self.ui.value_widget = apply ( self.paramWidgets [ self.param.type ], [ self.param, None, True ] ) - self.ui.value_widget.label.setText ( 'Current Value' ) - - paramsLayout.addLayout ( self.ui.value_widget.label_vl, 0, 0, 1, 1 ) - paramsLayout.addLayout ( self.ui.value_widget.param_vl, 0, 1, 1, 1 ) - - self.ui.def_value_widget = apply ( self.paramWidgets [ self.param_default.type ], [ self.param_default, None, True ] ) - self.ui.def_value_widget.label.setText ( 'Default Value' ) + # create paramWidget without GfxNode and ignoreSubtype = True + self.ui.value_widget = apply ( self.paramWidgets [ self.param.type ], [ self.param, None, True ] ) + self.ui.value_widget.label.setText ( 'Current Value' ) + + paramsLayout.addLayout ( self.ui.value_widget.label_vl, 0, 0, 1, 1 ) + paramsLayout.addLayout ( self.ui.value_widget.param_vl, 0, 1, 1, 1 ) + + self.ui.def_value_widget = apply ( self.paramWidgets [ self.param_default.type ], [ self.param_default, None, True ] ) + self.ui.def_value_widget.label.setText ( 'Default Value' ) - paramsLayout.addLayout ( self.ui.def_value_widget.label_vl, 1, 0, 1, 1 ) - paramsLayout.addLayout ( self.ui.def_value_widget.param_vl, 1, 1, 1, 1 ) - - spacer = QtGui.QSpacerItem ( 20, 20, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding ) - paramsLayout.addItem ( spacer, 2, 0, 1, 1 ) + paramsLayout.addLayout ( self.ui.def_value_widget.label_vl, 1, 0, 1, 1 ) + paramsLayout.addLayout ( self.ui.def_value_widget.param_vl, 1, 1, 1, 1 ) + + spacer = QtGui.QSpacerItem ( 20, 20, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding ) + paramsLayout.addItem ( spacer, 2, 0, 1, 1 ) - self.ui.value_stackedWidget.addWidget ( frame ) - self.connectSignals () - else : - self.reset () - # - # onEditParamName - # - def onEditParamName ( self ) : - # - # !!! ListWidget item for param also should be changed - # - oldName = self.param.name - newName = str ( self.ui.name_lineEdit.text () ).strip () - if newName == '' : - newName = oldName - self.ui.name_lineEdit.setText ( newName ) - if newName != oldName : - self.param.name = newName - self.emit( QtCore.SIGNAL ( 'changeParamName' ), oldName, newName ) - # - # onEditParamLabel - # - def onEditParamLabel ( self ) : - # - oldName = self.param.label - newName = str ( self.ui.label_lineEdit.text () ).strip () - if newName == '' : - newName = oldName - self.ui.label_lineEdit.setText ( newName ) - if newName != oldName : - self.param.label = newName - self.emit ( QtCore.SIGNAL ( 'changeParamLabel' ), oldName, newName ) - # - # - # - def onEditParamEnabled ( self, value ) : self.param.enabled = self.ui.check_enabled.isChecked () - def onEditParamDisplay ( self, value ) : self.param.display = self.ui.check_display.isChecked () - def onEditParamShader ( self, value ) : - # - self.param.shaderParam = self.ui.check_shader.isChecked () - self.emit ( QtCore.SIGNAL ( 'changeParamIsShader' ), self.param ) - - def onEditParamType ( self, idx ) : - # - # !!! UI for param.value and param.default also should be changed - # - self.param.type = str ( self.ui.type_comboBox.itemText ( idx ) ) - self.emit ( QtCore.SIGNAL ( 'changeParamType' ), self.param ) + self.ui.value_stackedWidget.addWidget ( frame ) + self.connectSignals () + else : + self.reset () + # + # onEditParamName + # + def onEditParamName ( self ) : + # + # !!! ListWidget item for param also should be changed + # + oldName = self.param.name + newName = str ( self.ui.name_lineEdit.text () ).strip () + if newName == '' : + newName = oldName + self.ui.name_lineEdit.setText ( newName ) + if newName != oldName : + self.param.name = newName + self.emit( QtCore.SIGNAL ( 'changeParamName' ), oldName, newName ) + # + # onEditParamLabel + # + def onEditParamLabel ( self ) : + # + oldName = self.param.label + newName = str ( self.ui.label_lineEdit.text () ).strip () + if newName == '' : + newName = oldName + self.ui.label_lineEdit.setText ( newName ) + if newName != oldName : + self.param.label = newName + self.emit ( QtCore.SIGNAL ( 'changeParamLabel' ), oldName, newName ) + # + # + # + def onEditParamEnabled ( self, value ) : self.param.enabled = self.ui.check_enabled.isChecked () + def onEditParamDisplay ( self, value ) : self.param.display = self.ui.check_display.isChecked () + def onEditParamShader ( self, value ) : + # + self.param.shaderParam = self.ui.check_shader.isChecked () + self.emit ( QtCore.SIGNAL ( 'changeParamIsShader' ), self.param ) + + def onEditParamType ( self, idx ) : + # + # !!! UI for param.value and param.default also should be changed + # + self.param.type = str ( self.ui.type_comboBox.itemText ( idx ) ) + self.emit ( QtCore.SIGNAL ( 'changeParamType' ), self.param ) - def onEditParamDetail ( self, idx ) : - # - self.param.detail = str ( self.ui.detail_comboBox.itemText ( idx ) ) - self.emit ( QtCore.SIGNAL ( 'changeParamDetail' ), self.param ) - - def onEditParamProvider ( self, idx ) : - # - self.param.provider = str ( self.ui.provider_comboBox.itemText ( idx ) ) - self.emit ( QtCore.SIGNAL ( 'changeParamProvider' ), self.param ) - - def onEditParamSubtype ( self, idx ) : - # - self.param.subtype = str ( self.ui.subtype_comboBox.itemText ( idx ) ) - self.emit ( QtCore.SIGNAL ( 'changeParamSubtype' ), self.param ) - - def onEditParamRange ( self ) : - # - self.param.range = str ( self.ui.range_lineEdit.text () ) - self.emit ( QtCore.SIGNAL ( 'changeParamRange' ), self.param ) - - def onEditParamHelp ( self ) : self.param.help = str ( self.ui.descr_plainTextEdit.toPlainText () ) + def onEditParamDetail ( self, idx ) : + # + self.param.detail = str ( self.ui.detail_comboBox.itemText ( idx ) ) + self.emit ( QtCore.SIGNAL ( 'changeParamDetail' ), self.param ) + + def onEditParamProvider ( self, idx ) : + # + self.param.provider = str ( self.ui.provider_comboBox.itemText ( idx ) ) + self.emit ( QtCore.SIGNAL ( 'changeParamProvider' ), self.param ) + + def onEditParamSubtype ( self, idx ) : + # + self.param.subtype = str ( self.ui.subtype_comboBox.itemText ( idx ) ) + self.emit ( QtCore.SIGNAL ( 'changeParamSubtype' ), self.param ) + + def onEditParamRange ( self ) : + # + self.param.range = str ( self.ui.range_lineEdit.text () ) + self.emit ( QtCore.SIGNAL ( 'changeParamRange' ), self.param ) + + def onEditParamHelp ( self ) : self.param.help = str ( self.ui.descr_plainTextEdit.toPlainText () ) diff --git a/gui/nodeEditor/nodePropertiesEditor.py b/gui/nodeEditor/nodePropertiesEditor.py index d40eb8d..4553f89 100644 --- a/gui/nodeEditor/nodePropertiesEditor.py +++ b/gui/nodeEditor/nodePropertiesEditor.py @@ -8,8 +8,7 @@ Dialog for managing node properties """ -import os, sys -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui from core.meCommon import * from global_vars import app_global_vars, DEBUG_MODE, VALID_NODE_TYPES @@ -19,160 +18,167 @@ from core.node import Node from ui_nodePropertiesEditor import Ui_NodePropertiesEditor + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + # # NodeEditor # -class NodePropertiesEditor ( QtGui.QWidget ) : - # - # __init__ - # - def __init__ ( self, parent, editNode = None ) : - # - QtGui.QWidget.__init__ ( self, parent ) - - self.editNode = editNode - - #self.debugPrint() - self.buildGui () - self.setNode ( editNode ) - # - # buildGui - # - def buildGui ( self ) : - # build the gui created with QtDesigner - self.ui = Ui_NodePropertiesEditor () - self.ui.setupUi ( self ) - # - # setNode - # - def setNode ( self, editNode ) : - # - self.disconnectSignals () - self.editNode = editNode - - if self.editNode is not None : - # - name = self.editNode.name - if self.editNode.name is None : name = '' - self.ui.name_lineEdit.setText ( name ) - - label = self.editNode.label - if self.editNode.label is None : label = '' - self.ui.label_lineEdit.setText ( label ) - - author = self.editNode.author - if self.editNode.author is None : author = '' - self.ui.author_lineEdit.setText ( author ) - - master = self.editNode.master - if self.editNode.master is None : master = '' - self.ui.master_lineEdit.setText ( master ) - - icon = self.editNode.icon - if self.editNode.icon is None : icon = '' - self.ui.icon_lineEdit.setText ( icon ) - # print '* self.editNode.help = %s' % self.editNode.help - - doc = QtGui.QTextDocument () - help_text = '' - if self.editNode.help != None : - help_text = self.editNode.help - - doc.setPlainText ( help_text ) - layout = QtGui.QPlainTextDocumentLayout( doc ) - doc.setDocumentLayout( layout ) - - self.ui.help_plainTextEdit.setDocument ( doc ) - - self.ui.id_lineEdit.setText ( str ( self.editNode.id ) ) - - self.ui.type_comboBox.setEditable ( False ) - self.ui.type_comboBox.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) - self.ui.type_comboBox.setMaximumSize ( QtCore.QSize( UI.MAX, UI.COMBO_HEIGHT ) ) - - currentIdx = -1 - i = 0 - for label in VALID_NODE_TYPES : - self.ui.type_comboBox.addItem ( label ) - if label == self.editNode.type : - currentIdx = i - i += 1 - - self.ui.type_comboBox.setCurrentIndex ( currentIdx ) - - # temporary disabled, until "how to do it gracefully" will be clear ... - self.ui.type_comboBox.setEnabled ( False ) - - self.connectSignals () - # - # connectSignals - # - def connectSignals ( self ) : - # QtCore.QObject. - self.connect ( self.ui.name_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrName ) - self.connect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) - self.connect ( self.ui.master_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrMaster ) - self.connect ( self.ui.author_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrAuthor ) - self.connect ( self.ui.icon_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrIcon ) - self.connect ( self.ui.type_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditNodeType ) - self.connect ( self.ui.help_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditNodeTxtAttr ) - # - # disconnectSignals - # - def disconnectSignals ( self ) : - # - if self.editNode is not None : - self.disconnect ( self.ui.name_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrName ) - self.disconnect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) - self.disconnect ( self.ui.master_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrMaster ) - self.disconnect ( self.ui.author_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrAuthor ) - self.disconnect ( self.ui.icon_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrIcon ) - self.disconnect ( self.ui.type_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditNodeType ) - self.disconnect ( self.ui.help_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditNodeTxtAttr ) - # - # doesn't work ... - # - def onEditNodeStrAttr ( self, attr = None ) : - # - if attr is not None and self.editNode is not None: - if attr == 'name' : - self.editNode.name = str ( self.ui.name_lineEdit.text () ) - elif attr == 'label' : - self.editNode.label = str ( self.ui.label_lineEdit.text () ) - elif attr == 'master' : - self.editNode.master = str ( self.ui.master_lineEdit.text () ) - elif attr == 'author' : - self.editNode.author = str ( self.ui.author_lineEdit.text () ) - elif attr == 'icon' : - self.editNode.icon = str ( self.ui.icon_lineEdit.text () ) - # - # - # - def onEditNodeStrAttrName ( self ) : self.editNode.name = str ( self.ui.name_lineEdit.text () ) - def onEditNodeStrAttrLabel ( self ) : - # - oldLabel = self.editNode.label - newLabel = str ( self.ui.label_lineEdit.text () ).strip () - if newLabel == '' : - self.disconnect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) - newLabel = oldLabel - self.ui.label_lineEdit.setText ( newLabel ) - self.connect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) - if newLabel != oldLabel : - self.editNode.label = newLabel - self.emit ( QtCore.SIGNAL ( 'changeNodeLabel' ), oldLabel, newLabel ) - - def onEditNodeStrAttrMaster ( self ) : self.editNode.master = str ( self.ui.master_lineEdit.text () ) - def onEditNodeStrAttrAuthor ( self ) : self.editNode.author = str ( self.ui.author_lineEdit.text () ) - def onEditNodeStrAttrIcon ( self ) : self.editNode.icon = str ( self.ui.icon_lineEdit.text () ) - # - # onEditNodeTxtAttr - # - def onEditNodeTxtAttr ( self ) : self.editNode.help = str ( self.ui.help_plainTextEdit.toPlainText () ) - # - # onEditNodeType - # - def onEditNodeType ( self, idx ) : self.editNode.type = str ( self.ui.type_comboBox.itemText ( idx ) ) +class NodePropertiesEditor ( QtModule.QWidget ) : + # + # __init__ + # + def __init__ ( self, parent, editNode = None ) : + # + QtModule.QWidget.__init__ ( self, parent ) + + self.editNode = editNode + + #self.debugPrint() + self.buildGui () + self.setNode ( editNode ) + # + # buildGui + # + def buildGui ( self ) : + # build the gui created with QtDesigner + self.ui = Ui_NodePropertiesEditor () + self.ui.setupUi ( self ) + # + # setNode + # + def setNode ( self, editNode ) : + # + self.disconnectSignals () + self.editNode = editNode + + if self.editNode is not None : + # + name = self.editNode.name + if self.editNode.name is None : name = '' + self.ui.name_lineEdit.setText ( name ) + + label = self.editNode.label + if self.editNode.label is None : label = '' + self.ui.label_lineEdit.setText ( label ) + + author = self.editNode.author + if self.editNode.author is None : author = '' + self.ui.author_lineEdit.setText ( author ) + + master = self.editNode.master + if self.editNode.master is None : master = '' + self.ui.master_lineEdit.setText ( master ) + + icon = self.editNode.icon + if self.editNode.icon is None : icon = '' + self.ui.icon_lineEdit.setText ( icon ) + # print '* self.editNode.help = %s' % self.editNode.help + + doc = QtGui.QTextDocument () + help_text = '' + if self.editNode.help != None : + help_text = self.editNode.help + + doc.setPlainText ( help_text ) + layout = QtGui.QPlainTextDocumentLayout( doc ) + doc.setDocumentLayout( layout ) + + self.ui.help_plainTextEdit.setDocument ( doc ) + + self.ui.id_lineEdit.setText ( str ( self.editNode.id ) ) + + self.ui.type_comboBox.setEditable ( False ) + self.ui.type_comboBox.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) + self.ui.type_comboBox.setMaximumSize ( QtCore.QSize( UI.MAX, UI.COMBO_HEIGHT ) ) + + currentIdx = -1 + i = 0 + for label in VALID_NODE_TYPES : + self.ui.type_comboBox.addItem ( label ) + if label == self.editNode.type : + currentIdx = i + i += 1 + + self.ui.type_comboBox.setCurrentIndex ( currentIdx ) + + # temporary disabled, until "how to do it gracefully" will be clear ... + self.ui.type_comboBox.setEnabled ( False ) + + self.connectSignals () + # + # connectSignals + # + def connectSignals ( self ) : + # QtCore.QObject. + self.connect ( self.ui.name_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrName ) + self.connect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) + self.connect ( self.ui.master_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrMaster ) + self.connect ( self.ui.author_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrAuthor ) + self.connect ( self.ui.icon_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrIcon ) + self.connect ( self.ui.type_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditNodeType ) + self.connect ( self.ui.help_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditNodeTxtAttr ) + # + # disconnectSignals + # + def disconnectSignals ( self ) : + # + if self.editNode is not None : + self.disconnect ( self.ui.name_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrName ) + self.disconnect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) + self.disconnect ( self.ui.master_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrMaster ) + self.disconnect ( self.ui.author_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrAuthor ) + self.disconnect ( self.ui.icon_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrIcon ) + self.disconnect ( self.ui.type_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditNodeType ) + self.disconnect ( self.ui.help_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditNodeTxtAttr ) + # + # doesn't work ... + # + def onEditNodeStrAttr ( self, attr = None ) : + # + if attr is not None and self.editNode is not None: + if attr == 'name' : + self.editNode.name = str ( self.ui.name_lineEdit.text () ) + elif attr == 'label' : + self.editNode.label = str ( self.ui.label_lineEdit.text () ) + elif attr == 'master' : + self.editNode.master = str ( self.ui.master_lineEdit.text () ) + elif attr == 'author' : + self.editNode.author = str ( self.ui.author_lineEdit.text () ) + elif attr == 'icon' : + self.editNode.icon = str ( self.ui.icon_lineEdit.text () ) + # + # + # + def onEditNodeStrAttrName ( self ) : self.editNode.name = str ( self.ui.name_lineEdit.text () ) + def onEditNodeStrAttrLabel ( self ) : + # + oldLabel = self.editNode.label + newLabel = str ( self.ui.label_lineEdit.text () ).strip () + if newLabel == '' : + self.disconnect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) + newLabel = oldLabel + self.ui.label_lineEdit.setText ( newLabel ) + self.connect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) + if newLabel != oldLabel : + self.editNode.label = newLabel + self.emit ( QtCore.SIGNAL ( 'changeNodeLabel' ), oldLabel, newLabel ) + + def onEditNodeStrAttrMaster ( self ) : self.editNode.master = str ( self.ui.master_lineEdit.text () ) + def onEditNodeStrAttrAuthor ( self ) : self.editNode.author = str ( self.ui.author_lineEdit.text () ) + def onEditNodeStrAttrIcon ( self ) : self.editNode.icon = str ( self.ui.icon_lineEdit.text () ) + # + # onEditNodeTxtAttr + # + def onEditNodeTxtAttr ( self ) : self.editNode.help = str ( self.ui.help_plainTextEdit.toPlainText () ) + # + # onEditNodeType + # + def onEditNodeType ( self, idx ) : self.editNode.type = str ( self.ui.type_comboBox.itemText ( idx ) ) diff --git a/gui/nodeEditor/ui_nodeCodeEditor.py b/gui/nodeEditor/ui_nodeCodeEditor.py index 36f8303..a775ea0 100644 --- a/gui/nodeEditor/ui_nodeCodeEditor.py +++ b/gui/nodeEditor/ui_nodeCodeEditor.py @@ -7,7 +7,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 diff --git a/gui/nodeEditor/ui_nodeEditorDialog.py b/gui/nodeEditor/ui_nodeEditorDialog.py index 8ff166e..cde89d6 100644 --- a/gui/nodeEditor/ui_nodeEditorDialog.py +++ b/gui/nodeEditor/ui_nodeEditorDialog.py @@ -7,7 +7,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 diff --git a/gui/nodeEditor/ui_nodeLinkEditor.py b/gui/nodeEditor/ui_nodeLinkEditor.py index 5edc6e1..eb1f054 100644 --- a/gui/nodeEditor/ui_nodeLinkEditor.py +++ b/gui/nodeEditor/ui_nodeLinkEditor.py @@ -7,7 +7,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 diff --git a/gui/nodeEditor/ui_nodeNamesEditor.py b/gui/nodeEditor/ui_nodeNamesEditor.py index 6b32c6e..2de8d24 100644 --- a/gui/nodeEditor/ui_nodeNamesEditor.py +++ b/gui/nodeEditor/ui_nodeNamesEditor.py @@ -7,7 +7,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 diff --git a/gui/nodeEditor/ui_nodeParamEditor.py b/gui/nodeEditor/ui_nodeParamEditor.py index 256ede8..ca9c965 100644 --- a/gui/nodeEditor/ui_nodeParamEditor.py +++ b/gui/nodeEditor/ui_nodeParamEditor.py @@ -7,7 +7,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 diff --git a/gui/nodeEditor/ui_nodePropertiesEditor.py b/gui/nodeEditor/ui_nodePropertiesEditor.py index 645655b..135ac38 100644 --- a/gui/nodeEditor/ui_nodePropertiesEditor.py +++ b/gui/nodeEditor/ui_nodePropertiesEditor.py @@ -7,7 +7,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 diff --git a/gui/nodeLibraryView.py b/gui/nodeLibraryView.py index d33ac25..6dfdf0c 100644 --- a/gui/nodeLibraryView.py +++ b/gui/nodeLibraryView.py @@ -1,15 +1,13 @@ -#=============================================================================== -# nodeLibraryView.py -# -# -# -#=============================================================================== -import os, sys -from PyQt4 import QtCore, QtGui +""" + + nodeLibraryView.py -from PyQt4.QtCore import QDir, QString, QModelIndex -from PyQt4.QtGui import QFileSystemModel -from PyQt4.QtGui import QFileIconProvider +""" +from core.mePyQt import QtCore, QtGui + +#from PyQt4.QtCore import QDir, QString, QModelIndex +#from PyQt4.QtGui import QFileSystemModel +#from PyQt4.QtGui import QFileIconProvider from core.meCommon import * @@ -19,44 +17,51 @@ from core.node import Node from core.nodeLibrary import NodeLibrary + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + # # NodeLibraryView # -class NodeLibraryView ( QtGui.QWidget ) : - # - # __init__ - # - def __init__ ( self ) : - # - QtGui.QWidget.__init__ ( self ) - - # This is always the same - self.ui=Ui_nodeLibraryView () - self.ui.setupUi ( self ) - self.updateGui () - # - # setLibrary - # - def setLibrary ( self, dirName ) : self.ui.nodeList.setLibrary ( dirName ) - # - # onReload - # - def onReload ( self ) : self.ui.nodeList.reloadLibrary () - # - # updateGui - # - def updateGui ( self ) : - # - pass - #if ( self.nodesLib != '' ) : - # self.ui.treeView.setupModel( self.nodesLib.model ) - - #self.ui.treeView.reset () - #self.ui.treeView.setModel ( self.nodesLib.model ) - - #self.ui.infoText.clear () - #self.ui.infoText.setText( "Node:
Author:
" ) - - +class NodeLibraryView ( QtModule.QWidget ) : + # + # __init__ + # + def __init__ ( self ) : + # + QtModule.QWidget.__init__ ( self ) + + # This is always the same + self.ui=Ui_nodeLibraryView () + self.ui.setupUi ( self ) + self.updateGui () + # + # setLibrary + # + def setLibrary ( self, dirName ) : self.ui.nodeList.setLibrary ( dirName ) + # + # onReload + # + def onReload ( self ) : self.ui.nodeList.reloadLibrary () + # + # updateGui + # + def updateGui ( self ) : + # + pass + #if ( self.nodesLib != '' ) : + # self.ui.treeView.setupModel( self.nodesLib.model ) + + #self.ui.treeView.reset () + #self.ui.treeView.setModel ( self.nodesLib.model ) + + #self.ui.infoText.clear () + #self.ui.infoText.setText( "Node:
Author:
" ) + + diff --git a/gui/nodeList.py b/gui/nodeList.py index 2ac028f..232d589 100644 --- a/gui/nodeList.py +++ b/gui/nodeList.py @@ -1,144 +1,153 @@ -#=============================================================================== -# nodeList.py -# -# -# -#=============================================================================== +""" -import os, sys -from PyQt4 import QtCore, QtGui + nodeList.py -from PyQt4.QtCore import QDir, QString, QModelIndex -from PyQt4.QtGui import QFileSystemModel -from PyQt4.QtGui import QFileIconProvider +""" +from core.mePyQt import QtCore, QtGui + +#from PyQt4.QtCore import QDir, QString, QModelIndex +#from PyQt4.QtGui import QFileSystemModel +#from PyQt4.QtGui import QFileIconProvider from ui_nodeList import Ui_nodeList #from MainWindow import MainWindow from core.node import Node from core.nodeLibrary import NodeLibrary + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + # # NodeList # -class NodeList ( QtGui.QWidget ) : - # - # __init__ - # - def __init__ ( self, parent ) : - # - QtGui.QWidget.__init__ ( self, parent ) - - self.nodesLib = '' - self.nodesDir = '' - # This is always the same - self.ui=Ui_nodeList () - self.ui.setupUi ( self ) - - self.ui.treeView.setDragEnabled ( True ) - #self.ui.treeView.setRootIsDecorated( True ) - - QtCore.QObject.connect ( self.ui.treeView, QtCore.SIGNAL ( "pressed(QModelIndex)" ), self.clicked ) - QtCore.QObject.connect ( self.ui.treeView, QtCore.SIGNAL ( "doubleClicked(QModelIndex)" ), self.doubleClicked ) - - self.updateGui () - # - # updateGui - # - def updateGui ( self ) : - # - if self.nodesLib != '' : - # self.ui.treeView.setupModel( self.nodesLib.model ) - - self.ui.treeView.reset () - self.ui.treeView.setModel ( self.nodesLib.model ) - - self.ui.infoText.clear () - #self.ui.infoText.setText( "Node:
Author:
" ) - # - # setLibrary - # - def setLibrary ( self, dirName ) : - # - self.nodesDir = dirName - self.nodesLib = NodeLibrary ( dirName ) - self.updateGui() - # - # reloadLibrary - # - def reloadLibrary ( self ) : - # - print '>> NodeList: reloadLibrary' - self.nodesLib = NodeLibrary ( self.nodesDir ) - self.updateGui () - # - # clicked - # - def clicked ( self, index ) : - # - item = self.nodesLib.model.itemFromIndex ( index ) - self.showDescription ( item ) - # - # send signal to MainWindow to help distinguish which nodeList - # is active for addNode getNode events - # - self.emit ( QtCore.SIGNAL ( "setActiveNodeList" ), self ) - # - # doubleClicked - # - def doubleClicked ( self, index ) : - # - item = self.nodesLib.model.itemFromIndex ( index ) - nodeKind = item.whatsThis () - - if nodeKind != 'folder' : - nodeFilename = item.data ( QtCore.Qt.UserRole + 4 ).toString () - self.emit ( QtCore.SIGNAL ( 'addNode' ), nodeFilename ) - # - # showDescription - # - def showDescription ( self, item ) : - # - nodeName = item.text () - nodeKind = item.whatsThis () - nodeAuthor = item.data ( QtCore.Qt.UserRole + 1 ).toString () - nodeType = item.data ( QtCore.Qt.UserRole + 2 ).toString () - nodeHelp = item.data ( QtCore.Qt.UserRole + 3 ).toString () - nodeFilename = item.data ( QtCore.Qt.UserRole + 4 ).toString () - nodeIcon = item.data ( QtCore.Qt.UserRole + 5 ).toString () - - self.ui.infoText.clear () - - description = '' - - if nodeKind != 'folder' : - if nodeIcon != '' : - iconFileName = os.path.join ( os.path.dirname ( str ( nodeFilename ) ), str ( nodeIcon ) ) - print str ( iconFileName ) - description += '' # width="128" height="128" +class NodeList ( QtModule.QWidget ) : + # + # __init__ + # + def __init__ ( self, parent ) : + # + QtModule.QWidget.__init__ ( self, parent ) + + self.nodesLib = '' + self.nodesDir = '' + # This is always the same + self.ui=Ui_nodeList () + self.ui.setupUi ( self ) + + self.ui.treeView.setDragEnabled ( True ) + #self.ui.treeView.setRootIsDecorated( True ) + + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.connect ( self.ui.treeView, QtCore.SIGNAL ( "pressed(QModelIndex)" ), self.clicked ) + QtCore.QObject.connect ( self.ui.treeView, QtCore.SIGNAL ( "doubleClicked(QModelIndex)" ), self.doubleClicked ) + else : + print ( '!!! NodeList connect!!!! solve it ' ) + + self.updateGui () + # + # updateGui + # + def updateGui ( self ) : + # + if self.nodesLib != '' : + # self.ui.treeView.setupModel( self.nodesLib.model ) + + self.ui.treeView.reset () + self.ui.treeView.setModel ( self.nodesLib.model ) + + self.ui.infoText.clear () + #self.ui.infoText.setText( "Node:
Author:
" ) + # + # setLibrary + # + def setLibrary ( self, dirName ) : + # + self.nodesDir = dirName + self.nodesLib = NodeLibrary ( dirName ) + self.updateGui() + # + # reloadLibrary + # + def reloadLibrary ( self ) : + # + print '>> NodeList: reloadLibrary' + self.nodesLib = NodeLibrary ( self.nodesDir ) + self.updateGui () + # + # clicked + # + def clicked ( self, index ) : + # + item = self.nodesLib.model.itemFromIndex ( index ) + self.showDescription ( item ) + # + # send signal to MainWindow to help distinguish which nodeList + # is active for addNode getNode events + # + self.emit ( QtCore.SIGNAL ( "setActiveNodeList" ), self ) + # + # doubleClicked + # + def doubleClicked ( self, index ) : + # + item = self.nodesLib.model.itemFromIndex ( index ) + nodeKind = item.whatsThis () + + if nodeKind != 'folder' : + nodeFilename = item.data ( QtCore.Qt.UserRole + 4 ).toString () + self.emit ( QtCore.SIGNAL ( 'addNode' ), nodeFilename ) + # + # showDescription + # + def showDescription ( self, item ) : + # + import os + + nodeName = item.text () + nodeKind = item.whatsThis () + nodeAuthor = item.data ( QtCore.Qt.UserRole + 1 ).toString () + nodeType = item.data ( QtCore.Qt.UserRole + 2 ).toString () + nodeHelp = item.data ( QtCore.Qt.UserRole + 3 ).toString () + nodeFilename = item.data ( QtCore.Qt.UserRole + 4 ).toString () + nodeIcon = item.data ( QtCore.Qt.UserRole + 5 ).toString () + + self.ui.infoText.clear () + + description = '' + + if nodeKind != 'folder' : + if nodeIcon != '' : + iconFileName = os.path.join ( os.path.dirname ( str ( nodeFilename ) ), str ( nodeIcon ) ) + print str ( iconFileName ) + description += '' # width="128" height="128" - description += "" - #description += "" - #description += "" - #description += "" - #description += "" - #description += "" - #description += "" - #description += "" - #description += "" - #description += "" - #description += "" - #description += "" - #description += "" - description += "" - description += "" - description += "" - description += "" - description += "
name:" + nodeName + "
type:" + nodeType +"
filename:" + nodeFilename +"
author:" + nodeAuthor +"

" - - description += "
" + nodeHelp +"
" - - self.ui.infoText.setText ( description ) - - #self.ui.infoText.clear() - #self.ui.infoText.setText( "Name:" + nodeName + "
Author:" + nodeAuthor +"
" ) - #self.ui.infoText.setText( QString("Clicked on %1: ").arg(nodeKind) + item.text() ) + description += "" + #description += "" + #description += "" + #description += "" + #description += "" + #description += "" + #description += "" + #description += "" + #description += "" + #description += "" + #description += "" + #description += "" + #description += "" + description += "" + description += "" + description += "" + description += "" + description += "
name:" + nodeName + "
type:" + nodeType +"
filename:" + nodeFilename +"
author:" + nodeAuthor +"

" + + description += "
" + nodeHelp +"
" + + self.ui.infoText.setText ( description ) + + #self.ui.infoText.clear() + #self.ui.infoText.setText( "Name:" + nodeName + "
Author:" + nodeAuthor +"
" ) + #self.ui.infoText.setText( QString("Clicked on %1: ").arg(nodeKind) + item.text() ) diff --git a/gui/nodeParamList.py b/gui/nodeParamList.py index 32a498c..18d9446 100644 --- a/gui/nodeParamList.py +++ b/gui/nodeParamList.py @@ -3,12 +3,11 @@ nodeParamList.py """ -import os, sys -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui -from PyQt4.QtCore import QDir, QString, QModelIndex -from PyQt4.QtGui import QFileSystemModel -from PyQt4.QtGui import QFileIconProvider +#from PyQt4.QtCore import QDir, QString, QModelIndex +#from PyQt4.QtGui import QFileSystemModel +#from PyQt4.QtGui import QFileIconProvider #from ui_nodeParam import Ui_nodeParam #from MainWindow import MainWindow @@ -29,257 +28,264 @@ from gui.params.MatrixWidget import MatrixWidget from gui.params.TextWidget import TextWidget from gui.params.ControlWidget import ControlWidget + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets # -# NodeParamListFrame +# NodeParamListTab # -class NodeParamListTab ( QtGui.QWidget ) : - # - # __init__ - # - def __init__ ( self, parent, gfxNode = None, isInput = True, showConnected = False ) : - # - QtGui.QWidget.__init__ ( self, parent ) - - self.nodeParamView = parent - self.gfxNode = gfxNode - self.isInput = isInput - - self.showConnected = showConnected - - self.labelWidth = UI.CHECK_WIDTH + UI.LABEL_WIDTH + 6 + 20 - self.stackedWidget = None - self.nodeParamList = None - - self.buildGui () - self.updateGui () - self.connectSignals () - # - # connectSignals - # - def connectSignals ( self ) : - # - self.connect ( self.paramHeader, QtCore.SIGNAL ( 'sectionResized(int,int,int)' ), self.onSectionResized ) - # - # onSectionResized - # - def onSectionResized ( self, idx, oldSize, newSize ) : - # - #if DEBUG_MODE : print ( '>> NodeParamViewTab.onSectionResized %d %d %d' ) % ( idx, oldSize, newSize ) - if idx == 0 : - self.labelWidth = newSize - if self.nodeParamList is not None : - self.nodeParamList.setLabelWidth ( newSize ) - #self.nodeParamList.updateGui () - # - # setNode - # - def setNode ( self, gfxNode ) : - # - #if DEBUG_MODE :print ">> NodeParamListTab.setNode" - self.gfxNode = gfxNode - #self.nodeParamList.setNode ( gfxNode ) - self.updateGui () - # - # onParamRemoved - # - def onParamRemoved ( self, param ) : - # - if DEBUG_MODE : print ">> NodeParamViewTab.onRemoved node = %s param = %s" % ( self.gfxNode.node.label, param.name ) - self.gfxNode.node.removeParam ( param ) - self.gfxNode.removeGfxNodeParam ( param ) - self.gfxNode.onUpdateNodeParams ( True ) - #self.emit ( QtCore.SIGNAL ( 'nodeParamChanged' ), self.gfxNode, param ) # .node - self.nodeParamView.disconnectParamSignals () - self.updateGui () - self.nodeParamView.connectParamSignals () - # - # buildGui - # - def buildGui ( self ) : - # - self.model = QtGui.QStandardItemModel () - self.model.setColumnCount ( 2 ) - self.model.setHeaderData ( 0, QtCore.Qt.Horizontal, QtCore.QVariant ( 'Parameter' ) ) - self.model.setHeaderData ( 1, QtCore.Qt.Horizontal, QtCore.QVariant ( 'Value' ) ) - - self.paramHeader = QtGui.QHeaderView ( QtCore.Qt.Horizontal, self ) - self.paramHeader.setModel ( self.model ) - self.paramHeader.resizeSection ( 0, self.labelWidth ) - self.paramHeader.setMinimumSectionSize ( self.labelWidth ) - self.paramHeader.setStretchLastSection ( True ) - self.paramHeader.setFixedHeight ( 24 ) - self.paramHeader.setFrameShape ( QtGui.QFrame.Box ) - self.paramHeader.setFrameShadow ( QtGui.QFrame.Raised ) - self.paramHeader.setLineWidth ( 1 ) - self.paramHeader.setMidLineWidth ( 2 ) - - self.stackedWidget = QtGui.QStackedWidget ( self ) - - self.paramsLayout = QtGui.QGridLayout ( self ) - self.paramsLayout.setContentsMargins ( 2, 2, 2, 2 ) - self.paramsLayout.setSizeConstraint ( QtGui.QLayout.SetNoConstraint ) - self.paramsLayout.setVerticalSpacing ( 0 ) - self.paramsLayout.setRowStretch ( 1, 1 ) - - self.paramsLayout.addWidget ( self.paramHeader, 0, 0, 1, 1 ) - self.paramsLayout.addWidget ( self.stackedWidget, 1, 0, 1, 1 ) - - frame = QtGui.QFrame () - self.stackedWidget.addWidget ( frame ) - # - # updateGui - # - def updateGui ( self ) : - # - #if DEBUG_MODE : print '>> NodeParamListTab.updateGui %s' % self.gfxNode - self.removeValueWidget () - if self.gfxNode is not None : - frame = QtGui.QFrame () - - self.nodeParamList = NodeParamList ( self, self.gfxNode, self.isInput, self.showConnected ) - self.nodeParamList.setLabelWidth ( self.labelWidth ) - frame.setLayout ( self.nodeParamList.paramListLayout ) - - self.nodeParamList.updateGui () - - # build a scroll area - scrollArea = QtGui.QScrollArea () - scrollArea.setWidgetResizable ( True ) - scrollArea.setWidget ( frame ) - - self.stackedWidget.addWidget ( scrollArea ) - # - # Remove stackedWidget's layout every time, - # when current parameter (or it's type) is changing - # - def removeValueWidget ( self ) : - # - if self.stackedWidget is not None : - #while True : - currentWidget = self.stackedWidget.currentWidget () - if currentWidget is not None : - #print '> removeWidget: %s' % currentWidget - self.stackedWidget.removeWidget ( currentWidget ) - #else : - # break +class NodeParamListTab ( QtModule.QWidget ) : + # + # __init__ + # + def __init__ ( self, parent, gfxNode = None, isInput = True, showConnected = False ) : + # + QtModule.QWidget.__init__ ( self, parent ) + + self.nodeParamView = parent + self.gfxNode = gfxNode + self.isInput = isInput + + self.showConnected = showConnected + + self.labelWidth = UI.CHECK_WIDTH + UI.LABEL_WIDTH + 6 + 20 + self.stackedWidget = None + self.nodeParamList = None + + self.buildGui () + self.updateGui () + self.connectSignals () + # + # connectSignals + # + def connectSignals ( self ) : + # + if QtCore.QT_VERSION < 50000 : + self.connect ( self.paramHeader, QtCore.SIGNAL ( 'sectionResized(int,int,int)' ), self.onSectionResized ) + # + # onSectionResized + # + def onSectionResized ( self, idx, oldSize, newSize ) : + # + #if DEBUG_MODE : print ( '>> NodeParamViewTab.onSectionResized %d %d %d' ) % ( idx, oldSize, newSize ) + if idx == 0 : + self.labelWidth = newSize + if self.nodeParamList is not None : + self.nodeParamList.setLabelWidth ( newSize ) + #self.nodeParamList.updateGui () + # + # setNode + # + def setNode ( self, gfxNode ) : + # + #if DEBUG_MODE :print ">> NodeParamListTab.setNode" + self.gfxNode = gfxNode + #self.nodeParamList.setNode ( gfxNode ) + self.updateGui () + # + # onParamRemoved + # + def onParamRemoved ( self, param ) : + # + if DEBUG_MODE : print ">> NodeParamViewTab.onRemoved node = %s param = %s" % ( self.gfxNode.node.label, param.name ) + self.gfxNode.node.removeParam ( param ) + self.gfxNode.removeGfxNodeParam ( param ) + self.gfxNode.onUpdateNodeParams ( True ) + #self.emit ( QtCore.SIGNAL ( 'nodeParamChanged' ), self.gfxNode, param ) # .node + self.nodeParamView.disconnectParamSignals () + self.updateGui () + self.nodeParamView.connectParamSignals () + # + # buildGui + # + def buildGui ( self ) : + # + self.model = QtGui.QStandardItemModel () + self.model.setColumnCount ( 2 ) + self.model.setHeaderData ( 0, QtCore.Qt.Horizontal, QtCore.QVariant ( 'Parameter' ) ) + self.model.setHeaderData ( 1, QtCore.Qt.Horizontal, QtCore.QVariant ( 'Value' ) ) + + self.paramHeader = QtModule.QHeaderView ( QtCore.Qt.Horizontal, self ) + self.paramHeader.setModel ( self.model ) + self.paramHeader.resizeSection ( 0, self.labelWidth ) + self.paramHeader.setMinimumSectionSize ( self.labelWidth ) + self.paramHeader.setStretchLastSection ( True ) + self.paramHeader.setFixedHeight ( 24 ) + self.paramHeader.setFrameShape ( QtModule.QFrame.Box ) + self.paramHeader.setFrameShadow ( QtModule.QFrame.Raised ) + self.paramHeader.setLineWidth ( 1 ) + self.paramHeader.setMidLineWidth ( 2 ) + + self.stackedWidget = QtModule.QStackedWidget ( self ) + + self.paramsLayout = QtModule.QGridLayout ( self ) + self.paramsLayout.setContentsMargins ( 2, 2, 2, 2 ) + self.paramsLayout.setSizeConstraint ( QtModule.QLayout.SetNoConstraint ) + self.paramsLayout.setVerticalSpacing ( 0 ) + self.paramsLayout.setRowStretch ( 1, 1 ) + + self.paramsLayout.addWidget ( self.paramHeader, 0, 0, 1, 1 ) + self.paramsLayout.addWidget ( self.stackedWidget, 1, 0, 1, 1 ) + + frame = QtModule.QFrame () + self.stackedWidget.addWidget ( frame ) + # + # updateGui + # + def updateGui ( self ) : + # + #if DEBUG_MODE : print '>> NodeParamListTab.updateGui %s' % self.gfxNode + self.removeValueWidget () + if self.gfxNode is not None : + frame = QtModule.QFrame () + + self.nodeParamList = NodeParamList ( self, self.gfxNode, self.isInput, self.showConnected ) + self.nodeParamList.setLabelWidth ( self.labelWidth ) + frame.setLayout ( self.nodeParamList.paramListLayout ) + + self.nodeParamList.updateGui () + + # build a scroll area + scrollArea = QtModule.QScrollArea () + scrollArea.setWidgetResizable ( True ) + scrollArea.setWidget ( frame ) + + self.stackedWidget.addWidget ( scrollArea ) + # + # Remove stackedWidget's layout every time, + # when current parameter (or it's type) is changing + # + def removeValueWidget ( self ) : + # + if self.stackedWidget is not None : + #while True : + currentWidget = self.stackedWidget.currentWidget () + if currentWidget is not None : + #print '> removeWidget: %s' % currentWidget + self.stackedWidget.removeWidget ( currentWidget ) + #else : + # break # # NodeParamList # -class NodeParamList ( QtGui.QWidget ) : - # - # __init__ - # - def __init__ ( self, parent, gfxNode = None, isInput = True, showConnected = False ) : - # - QtGui.QWidget.__init__ ( self, parent ) - - self.nodeParamViewTab = parent - self.gfxNode = gfxNode - self.isInput = isInput - - self.showConnected = showConnected - - self.paramWidgets = { 'string' : StringWidget - ,'image' : StringWidget - ,'rib' : StringWidget - ,'surface' : StringWidget - ,'displacement' : StringWidget - ,'light' : StringWidget - ,'volume' : StringWidget - ,'float' : FloatWidget - ,'int' : IntWidget - ,'color' : ColorWidget - ,'normal' : NormalWidget - ,'transform' : PointWidget - ,'point' : PointWidget - ,'vector' : VectorWidget - ,'matrix' : MatrixWidget - ,'text' : TextWidget - ,'control' : ControlWidget - ,'shader' : StringWidget - ,'geom' : StringWidget - } - self.paramListLayout = None - self.labelWidth = UI.CHECK_WIDTH + UI.LABEL_WIDTH - self.buildGui () - # - # setNode - # - def setNode ( self, gfxNode ) : - # - #if DEBUG_MODE :print ">> NodeParamList.setNode" - self.gfxNode = gfxNode - self.updateGui () - # - # setLabelWidth - # - def setLabelWidth ( self, labelWidth ) : - # - self.labelWidth = labelWidth - self.paramListLayout.setColumnMinimumWidth ( 0, self.labelWidth ) - # - # buildGui - # - def buildGui ( self ) : - # - #if DEBUG_MODE : print '>> NodeParamList.buildGui' - - self.paramListLayout = QtGui.QGridLayout () - self.paramListLayout.setSizeConstraint ( QtGui.QLayout.SetNoConstraint ) - self.paramListLayout.setSpacing ( UI.SPACING ) - self.paramListLayout.setMargin ( UI.SPACING ) - self.paramListLayout.setAlignment ( QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft ) - self.paramListLayout.setColumnMinimumWidth ( 0, self.labelWidth ) - self.paramListLayout.setColumnStretch ( 1, 1 ) - # - # updateGui - # - def updateGui ( self ) : - # - #if DEBUG_MODE : print '>> NodeParamList.updateGui %s' % self.gfxNode - self.paramListLayout.setColumnMinimumWidth ( 0, self.labelWidth ) - if self.gfxNode is not None : - params = [] - if self.isInput : - params = self.gfxNode.node.inputParams - else : - params = self.gfxNode.node.outputParams - paramWidget = None - paramRows = 0 - for param in params : - isParamLinked = False - linkedParamsList = [] - - if param.isInput : - ( srcNode, srcParam ) = self.gfxNode.node.getLinkedSrcNode ( param ) - isParamLinked = srcNode is not None - if isParamLinked : - linkedParamsList.append ( ( srcNode, srcParam ) ) - else : - linkedParamsList = self.gfxNode.node.getLinkedDstNodes ( param, linkedParamsList ) - isParamLinked = ( len ( linkedParamsList ) > 0 ) - - if param.display : - if param.type in self.paramWidgets.keys () : - if isParamLinked : - #print '***', param.name, 'linked to', linkedParamsList - if self.showConnected : - paramWidget = LinkWidget ( param, self.gfxNode, False, linkedParamsList ) - else : - continue - else : - paramWidget = apply ( self.paramWidgets [ param.type ], [ param, self.gfxNode ] ) - - if paramWidget is not None : - self.paramListLayout.addLayout ( paramWidget.label_vl, paramRows, 0, 1, 1 ) - self.paramListLayout.addLayout ( paramWidget.param_vl, paramRows, 1, 1, 1 ) - if not param.enabled : - paramWidget.setEnabled ( False ) - - if param.removable : - QtCore.QObject.connect ( paramWidget, QtCore.SIGNAL ( 'nodeParamRemoved' ), self.nodeParamViewTab.onParamRemoved ) - paramRows += 1 - - spacer = QtGui.QSpacerItem ( 20, 20, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding ) - self.paramListLayout.addItem ( spacer, paramRows, 0, 1, 1 ) - self.paramListLayout.setRowStretch ( paramRows, 1 ) +class NodeParamList ( QtModule.QWidget ) : + # + # __init__ + # + def __init__ ( self, parent, gfxNode = None, isInput = True, showConnected = False ) : + # + QtModule.QWidget.__init__ ( self, parent ) + + self.nodeParamViewTab = parent + self.gfxNode = gfxNode + self.isInput = isInput + + self.showConnected = showConnected + + self.paramWidgets = { 'string' : StringWidget + ,'image' : StringWidget + ,'rib' : StringWidget + ,'surface' : StringWidget + ,'displacement' : StringWidget + ,'light' : StringWidget + ,'volume' : StringWidget + ,'float' : FloatWidget + ,'int' : IntWidget + ,'color' : ColorWidget + ,'normal' : NormalWidget + ,'transform' : PointWidget + ,'point' : PointWidget + ,'vector' : VectorWidget + ,'matrix' : MatrixWidget + ,'text' : TextWidget + ,'control' : ControlWidget + ,'shader' : StringWidget + ,'geom' : StringWidget + } + self.paramListLayout = None + self.labelWidth = UI.CHECK_WIDTH + UI.LABEL_WIDTH + self.buildGui () + # + # setNode + # + def setNode ( self, gfxNode ) : + # + #if DEBUG_MODE :print ">> NodeParamList.setNode" + self.gfxNode = gfxNode + self.updateGui () + # + # setLabelWidth + # + def setLabelWidth ( self, labelWidth ) : + # + self.labelWidth = labelWidth + self.paramListLayout.setColumnMinimumWidth ( 0, self.labelWidth ) + # + # buildGui + # + def buildGui ( self ) : + # + #if DEBUG_MODE : print '>> NodeParamList.buildGui' + + self.paramListLayout = QtModule.QGridLayout () + self.paramListLayout.setSizeConstraint ( QtGui.QLayout.SetNoConstraint ) + self.paramListLayout.setSpacing ( UI.SPACING ) + self.paramListLayout.setMargin ( UI.SPACING ) + self.paramListLayout.setAlignment ( QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft ) + self.paramListLayout.setColumnMinimumWidth ( 0, self.labelWidth ) + self.paramListLayout.setColumnStretch ( 1, 1 ) + # + # updateGui + # + def updateGui ( self ) : + # + #if DEBUG_MODE : print '>> NodeParamList.updateGui %s' % self.gfxNode + self.paramListLayout.setColumnMinimumWidth ( 0, self.labelWidth ) + if self.gfxNode is not None : + params = [] + if self.isInput : + params = self.gfxNode.node.inputParams + else : + params = self.gfxNode.node.outputParams + paramWidget = None + paramRows = 0 + for param in params : + isParamLinked = False + linkedParamsList = [] + + if param.isInput : + ( srcNode, srcParam ) = self.gfxNode.node.getLinkedSrcNode ( param ) + isParamLinked = srcNode is not None + if isParamLinked : + linkedParamsList.append ( ( srcNode, srcParam ) ) + else : + linkedParamsList = self.gfxNode.node.getLinkedDstNodes ( param, linkedParamsList ) + isParamLinked = ( len ( linkedParamsList ) > 0 ) + + if param.display : + if param.type in self.paramWidgets.keys () : + if isParamLinked : + #print '***', param.name, 'linked to', linkedParamsList + if self.showConnected : + paramWidget = LinkWidget ( param, self.gfxNode, False, linkedParamsList ) + else : + continue + else : + paramWidget = apply ( self.paramWidgets [ param.type ], [ param, self.gfxNode ] ) + + if paramWidget is not None : + self.paramListLayout.addLayout ( paramWidget.label_vl, paramRows, 0, 1, 1 ) + self.paramListLayout.addLayout ( paramWidget.param_vl, paramRows, 1, 1, 1 ) + if not param.enabled : + paramWidget.setEnabled ( False ) + + if param.removable : + QtCore.QObject.connect ( paramWidget, QtCore.SIGNAL ( 'nodeParamRemoved' ), self.nodeParamViewTab.onParamRemoved ) + paramRows += 1 + + spacer = QtModule.QSpacerItem ( 20, 20, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding ) + self.paramListLayout.addItem ( spacer, paramRows, 0, 1, 1 ) + self.paramListLayout.setRowStretch ( paramRows, 1 ) diff --git a/gui/nodeParamView.py b/gui/nodeParamView.py index 1737231..d9fa1e6 100644 --- a/gui/nodeParamView.py +++ b/gui/nodeParamView.py @@ -3,12 +3,11 @@ nodeParamView.py """ -import os, sys -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui -from PyQt4.QtCore import QDir, QString, QModelIndex -from PyQt4.QtGui import QFileSystemModel -from PyQt4.QtGui import QFileIconProvider +#from PyQt4.QtCore import QDir, QString, QModelIndex +#from PyQt4.QtGui import QFileSystemModel +#from PyQt4.QtGui import QFileIconProvider #from ui_nodeParam import Ui_nodeParam #from MainWindow import MainWindow @@ -19,180 +18,189 @@ import gui.ui_settings as UI from global_vars import DEBUG_MODE + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + # # NodeParamView # -class NodeParamView ( QtGui.QWidget ) : - # - # __init__ - # - def __init__ ( self ) : - # - QtGui.QWidget.__init__ ( self ) +class NodeParamView ( QtModule.QWidget ) : + # + # __init__ + # + def __init__ ( self ) : + # + QtModule.QWidget.__init__ ( self ) - self.gfxNode = None - - self.inputParamListTab = None - self.outputParamListTab = None - - self.showConnected = False - self.buildGui () - self.updateGui () - self.connectSignals () - # - # setNode - # - def setNode ( self, gfxNode ) : - # - #if DEBUG_MODE : print ">> NodeParamView.setNode" - self.disconnectParamSignals () - self.gfxNode = gfxNode - self.inputParamListTab.setNode ( gfxNode ) - self.outputParamListTab.setNode ( gfxNode ) - self.nameEdit.setEnabled ( self.gfxNode is not None ) - self.updateGui () - self.connectParamSignals () - # - # connectSignals - # - def connectSignals ( self ) : - # - self.connect ( self.nameEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.nodeLabelChanged ) - self.connect ( self.showConnectButton, QtCore.SIGNAL ( 'toggled(bool)' ), self.showConnections ) - # - # disconnectSignals - # - def disconnectSignals ( self ) : - # - self.disconnect ( self.nameEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.nodeLabelChanged ) - self.disconnect ( self.showConnectButton, QtCore.SIGNAL ( 'toggled(bool)' ), self.showConnections ) - # - # connectParamSignals - # - def connectParamSignals ( self ) : - #print ">> NodeParamView.connectParamSignals" - if self.gfxNode is not None : - for inputParam in self.gfxNode.node.inputParams : - self.connect ( inputParam, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamChanged ) - for outputParam in self.gfxNode.node.outputParams : - self.connect ( outputParam, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamChanged ) - # - # disconnectParamSignals - # - def disconnectParamSignals ( self ) : - #print ">> NodeParamView.disconnectParamSignals" - if self.gfxNode is not None : - for inputParam in self.gfxNode.node.inputParams : - self.disconnect ( inputParam, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamChanged ) - for outputParam in self.gfxNode.node.outputParams : - self.disconnect ( outputParam, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamChanged ) - # - # showConnections - # - def showConnections ( self, show ) : - # - print ">> NodeParamView.showConnections %s" % show - self.showConnected = show - self.inputParamListTab.showConnected = show - self.outputParamListTab.showConnected = show - self.inputParamListTab.updateGui () - self.outputParamListTab.updateGui () - # - # onParamChanged - # - def onParamChanged ( self, param ) : - # - if DEBUG_MODE : print ">> NodeParamView.onParamChanged node = %s param = %s" % ( self.gfxNode.node.label, param.name ) - self.emit ( QtCore.SIGNAL ( 'nodeParamChanged' ), self.gfxNode, param ) # .node - - # - # nodeLabelChanged - # - def nodeLabelChanged ( self ) : - # - #if DEBUG_MODE : print ">> NodeParamView.nodeLabelChanged" - if self.gfxNode is not None : - from core.meCommon import getParsedLabel - newLabel = getParsedLabel ( self.nameEdit.text () ) - #if DEBUG_MODE : print "** newLabel = %s" % newLabel - if newLabel != '' : - # update label only if realy changed - if newLabel != self.gfxNode.node.label : - # rename node label if same name exists in NodeNet - self.emit ( QtCore.SIGNAL ( 'nodeLabelChanged' ), self.gfxNode, newLabel ) - self.nameEdit.clear () - self.nameEdit.setText ( self.gfxNode.node.label ) - # - # buildGui - # - def buildGui ( self ) : - # - label = QtGui.QLabel () - label.setMinimumSize ( QtCore.QSize ( UI.NODE_LABEL_WIDTH, UI.HEIGHT ) ) - label.setMaximumSize ( QtCore.QSize ( UI.NODE_LABEL_WIDTH, UI.HEIGHT ) ) + self.gfxNode = None + + self.inputParamListTab = None + self.outputParamListTab = None + + self.showConnected = False + self.buildGui () + self.updateGui () + self.connectSignals () + # + # setNode + # + def setNode ( self, gfxNode ) : + # + #if DEBUG_MODE : print ">> NodeParamView.setNode" + self.disconnectParamSignals () + self.gfxNode = gfxNode + self.inputParamListTab.setNode ( gfxNode ) + self.outputParamListTab.setNode ( gfxNode ) + self.nameEdit.setEnabled ( self.gfxNode is not None ) + self.updateGui () + self.connectParamSignals () + # + # connectSignals + # + def connectSignals ( self ) : + # + if QtCore.QT_VERSION < 50000 : + self.connect ( self.nameEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.nodeLabelChanged ) + self.connect ( self.showConnectButton, QtCore.SIGNAL ( 'toggled(bool)' ), self.showConnections ) + # + # disconnectSignals + # + def disconnectSignals ( self ) : + # + if QtCore.QT_VERSION < 50000 : + self.disconnect ( self.nameEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.nodeLabelChanged ) + self.disconnect ( self.showConnectButton, QtCore.SIGNAL ( 'toggled(bool)' ), self.showConnections ) + # + # connectParamSignals + # + def connectParamSignals ( self ) : + #print ">> NodeParamView.connectParamSignals" + if self.gfxNode is not None : + for inputParam in self.gfxNode.node.inputParams : + self.connect ( inputParam, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamChanged ) + for outputParam in self.gfxNode.node.outputParams : + self.connect ( outputParam, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamChanged ) + # + # disconnectParamSignals + # + def disconnectParamSignals ( self ) : + #print ">> NodeParamView.disconnectParamSignals" + if self.gfxNode is not None : + for inputParam in self.gfxNode.node.inputParams : + self.disconnect ( inputParam, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamChanged ) + for outputParam in self.gfxNode.node.outputParams : + self.disconnect ( outputParam, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamChanged ) + # + # showConnections + # + def showConnections ( self, show ) : + # + print ">> NodeParamView.showConnections %s" % show + self.showConnected = show + self.inputParamListTab.showConnected = show + self.outputParamListTab.showConnected = show + self.inputParamListTab.updateGui () + self.outputParamListTab.updateGui () + # + # onParamChanged + # + def onParamChanged ( self, param ) : + # + if DEBUG_MODE : print ">> NodeParamView.onParamChanged node = %s param = %s" % ( self.gfxNode.node.label, param.name ) + self.emit ( QtCore.SIGNAL ( 'nodeParamChanged' ), self.gfxNode, param ) # .node + + # + # nodeLabelChanged + # + def nodeLabelChanged ( self ) : + # + #if DEBUG_MODE : print ">> NodeParamView.nodeLabelChanged" + if self.gfxNode is not None : + from core.meCommon import getParsedLabel + newLabel = getParsedLabel ( self.nameEdit.text () ) + #if DEBUG_MODE : print "** newLabel = %s" % newLabel + if newLabel != '' : + # update label only if realy changed + if newLabel != self.gfxNode.node.label : + # rename node label if same name exists in NodeNet + self.emit ( QtCore.SIGNAL ( 'nodeLabelChanged' ), self.gfxNode, newLabel ) + self.nameEdit.clear () + self.nameEdit.setText ( self.gfxNode.node.label ) + # + # buildGui + # + def buildGui ( self ) : + # + label = QtModule.QLabel () + label.setMinimumSize ( QtCore.QSize ( UI.NODE_LABEL_WIDTH, UI.HEIGHT ) ) + label.setMaximumSize ( QtCore.QSize ( UI.NODE_LABEL_WIDTH, UI.HEIGHT ) ) - font = QtGui.QFont () - label.setFont ( font ) - #label.setAlignment(QtCore.Qt.AlignCenter) - label.setText ( 'Label' ) + font = QtGui.QFont () + label.setFont ( font ) + #label.setAlignment(QtCore.Qt.AlignCenter) + label.setText ( 'Label' ) - self.nameEdit = QtGui.QLineEdit () - self.nameEdit.setMaximumSize ( QtCore.QSize ( UI.MAX, UI.HEIGHT ) ) - self.nameEdit.setEnabled ( False ) - - self.showConnectButton = QtGui.QToolButton ( self ) - sizePolicy = QtGui.QSizePolicy ( QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed ) - sizePolicy.setHorizontalStretch ( 20 ) - sizePolicy.setVerticalStretch ( 20 ) - sizePolicy.setHeightForWidth ( self.showConnectButton.sizePolicy().hasHeightForWidth() ) - self.showConnectButton.setSizePolicy ( sizePolicy ) - self.showConnectButton.setMaximumSize ( QtCore.QSize ( 20, 20 ) ) - icon = QtGui.QIcon () - icon.addPixmap ( QtGui.QPixmap ( ':/show_icons/resources/show_connect.png' ), QtGui.QIcon.Normal, QtGui.QIcon.On ) - self.showConnectButton.setIcon ( icon ) - self.showConnectButton.setAutoRaise ( False ) - self.showConnectButton.setCheckable ( True ) - self.showConnectButton.setChecked ( self.showConnected ) - self.showConnectButton.setToolTip ( 'Show connected parameters' ) - #self.showConnectButton.setIconSize ( QtCore.QSize ( 16, 16 ) ) - self.showConnectButton.setObjectName ( 'showConnectButton' ) + self.nameEdit = QtModule.QLineEdit () + self.nameEdit.setMaximumSize ( QtCore.QSize ( UI.MAX, UI.HEIGHT ) ) + self.nameEdit.setEnabled ( False ) + + self.showConnectButton = QtModule.QToolButton ( self ) + sizePolicy = QtModule.QSizePolicy ( QtModule.QSizePolicy.Fixed, QtModule.QSizePolicy.Fixed ) + sizePolicy.setHorizontalStretch ( 20 ) + sizePolicy.setVerticalStretch ( 20 ) + sizePolicy.setHeightForWidth ( self.showConnectButton.sizePolicy().hasHeightForWidth() ) + self.showConnectButton.setSizePolicy ( sizePolicy ) + self.showConnectButton.setMaximumSize ( QtCore.QSize ( 20, 20 ) ) + icon = QtGui.QIcon () + icon.addPixmap ( QtGui.QPixmap ( ':/show_icons/resources/show_connect.png' ), QtGui.QIcon.Normal, QtGui.QIcon.On ) + self.showConnectButton.setIcon ( icon ) + self.showConnectButton.setAutoRaise ( False ) + self.showConnectButton.setCheckable ( True ) + self.showConnectButton.setChecked ( self.showConnected ) + self.showConnectButton.setToolTip ( 'Show connected parameters' ) + #self.showConnectButton.setIconSize ( QtCore.QSize ( 16, 16 ) ) + self.showConnectButton.setObjectName ( 'showConnectButton' ) - headerLayout = QtGui.QHBoxLayout () - headerLayout.setSpacing ( UI.SPACING ) - headerLayout.setMargin ( UI.SPACING ) - headerLayout.setStretch ( 1, 1 ) + headerLayout = QtModule.QHBoxLayout () + headerLayout.setSpacing ( UI.SPACING ) + #headerLayout.setMargin ( UI.SPACING ) + headerLayout.setStretch ( 1, 1 ) - headerLayout.addWidget ( label ) - headerLayout.addWidget ( self.nameEdit ) - headerLayout.addWidget ( self.showConnectButton ) + headerLayout.addWidget ( label ) + headerLayout.addWidget ( self.nameEdit ) + headerLayout.addWidget ( self.showConnectButton ) - mainLayout = QtGui.QVBoxLayout () - mainLayout.addLayout ( headerLayout ) - - self.params_tabs = QtGui.QTabWidget ( self ) - - self.inputParamListTab = NodeParamListTab ( self, self.gfxNode, isInput = True, showConnected = self.showConnected ) - self.params_tabs.addTab ( self.inputParamListTab, 'Input' ) - - self.outputParamListTab = NodeParamListTab ( self, self.gfxNode, isInput = False, showConnected = self.showConnected ) - self.params_tabs.addTab ( self.outputParamListTab, 'Output' ) - - self.params_tabs.setCurrentIndex ( 0 ) - - mainLayout.addWidget ( self.params_tabs ) - - self.setLayout ( mainLayout ) - # - # updateGui - # - def updateGui ( self ) : - # - #if DEBUG_MODE : print '>> NodeParamView.updateGui' - - self.nameEdit.clear () - if self.gfxNode is not None : - self.nameEdit.setText ( self.gfxNode.node.label ) - - self.inputParamListTab.updateGui () - self.outputParamListTab.updateGui () - \ No newline at end of file + mainLayout = QtModule.QVBoxLayout () + mainLayout.addLayout ( headerLayout ) + + self.params_tabs = QtModule.QTabWidget ( self ) + + self.inputParamListTab = NodeParamListTab ( self, self.gfxNode, isInput = True, showConnected = self.showConnected ) + self.params_tabs.addTab ( self.inputParamListTab, 'Input' ) + + self.outputParamListTab = NodeParamListTab ( self, self.gfxNode, isInput = False, showConnected = self.showConnected ) + self.params_tabs.addTab ( self.outputParamListTab, 'Output' ) + + self.params_tabs.setCurrentIndex ( 0 ) + + mainLayout.addWidget ( self.params_tabs ) + + self.setLayout ( mainLayout ) + # + # updateGui + # + def updateGui ( self ) : + # + #if DEBUG_MODE : print '>> NodeParamView.updateGui' + + self.nameEdit.clear () + if self.gfxNode is not None : + self.nameEdit.setText ( self.gfxNode.node.label ) + + self.inputParamListTab.updateGui () + self.outputParamListTab.updateGui () + \ No newline at end of file diff --git a/gui/nodeSwatchParam.py b/gui/nodeSwatchParam.py index c6c37d5..11b7f42 100644 --- a/gui/nodeSwatchParam.py +++ b/gui/nodeSwatchParam.py @@ -1,39 +1,46 @@ -#=============================================================================== -# nodeSwatchParam.py -#=============================================================================== +""" -import os, sys -from PyQt4 import QtCore, QtGui + nodeSwatchParam.py + +""" +from core.mePyQt import QtCore, QtGui from ui_nodeSwatchParam import Ui_NodeSwatchParam import ui_settings as UI + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + # +# NodeSwatchParam # -# -class NodeSwatchParam ( QtGui.QWidget ) : - # - # __init__ - # - def __init__ ( self ) : - # - QtGui.QWidget.__init__ ( self ) +class NodeSwatchParam ( QtModule.QWidget ) : + # + # __init__ + # + def __init__ ( self ) : + # + QtModule.QWidget.__init__ ( self ) - self.ui = Ui_NodeSwatchParam () - self.ui.setupUi ( self ) + self.ui = Ui_NodeSwatchParam () + self.ui.setupUi ( self ) - self.buildGui () - self.updateGui () - # - # buildGui - # - def buildGui ( self ) : - # - pass - # - # updateGui - # - def updateGui ( self ) : - # - pass - # \ No newline at end of file + self.buildGui () + self.updateGui () + # + # buildGui + # + def buildGui ( self ) : + # + pass + # + # updateGui + # + def updateGui ( self ) : + # + pass + # \ No newline at end of file diff --git a/gui/nodeTreeView.py b/gui/nodeTreeView.py index f2843b1..369228e 100644 --- a/gui/nodeTreeView.py +++ b/gui/nodeTreeView.py @@ -1,52 +1,63 @@ -#=============================================================================== -# nodeTreeView.py -# -# -# -#=============================================================================== +""" + + nodeTreeView.py -import os, sys -from PyQt4 import QtCore, QtGui +""" +from core.mePyQt import QtCore, QtGui, Qt -from PyQt4.QtCore import QDir, QString, QModelIndex -from PyQt4.QtGui import QFileSystemModel -from PyQt4.QtGui import QFileIconProvider +#from PyQt4.QtCore import QDir, QString, QModelIndex +#from PyQt4.QtGui import QFileSystemModel +#from PyQt4.QtGui import QFileIconProvider from core.node import Node from core.nodeLibrary import NodeLibrary + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + # +# NodeTreeView # -# -class NodeTreeView ( QtGui.QTreeView ): - # - # - def __init__( self, parent = None ): - #print ">> NodeTreeWidget init" - QtGui.QTreeView.__init__ ( self, parent ) - self.setMinimumHeight ( 200 ) - # - # - def startDrag ( self, dropActions ): - #print ">> NodeTreeView startDrag " - selectedIdx = self.selectedIndexes () - # for idx in selectedIdx : - idx = selectedIdx[ 0 ] - item = self.model().itemFromIndex( idx ) - #print "item = %s" % item.text() +class NodeTreeView ( QtModule.QTreeView ) : + # + # __init__ + # + def __init__( self, parent = None ): + #print ">> NodeTreeWidget init" + QtModule.QTreeView.__init__ ( self, parent ) + self.setMinimumHeight ( 200 ) + # + # startDrag + # + def startDrag ( self, dropActions ) : + #print ">> NodeTreeView startDrag " + selectedIdx = self.selectedIndexes () + # for idx in selectedIdx : + idx = selectedIdx[ 0 ] + item = self.model().itemFromIndex( idx ) + #print "item = %s" % item.text() - itemName = item.text() - itemFilename = item.data( QtCore.Qt.UserRole + 4 ).toString() - - # set custom data - data = QtCore.QByteArray () - stream = QtCore.QDataStream ( data, QtCore.QIODevice.WriteOnly ) - stream << itemFilename - mimeData = QtCore.QMimeData() - mimeData.setData ( 'application/x-text', data ) - - # set drag - drag = QtGui.QDrag ( self ) - drag.setMimeData ( mimeData ) - #drag.setPixmap ( QtGui.QPixmap(':/node.png') ) - drag.start ( QtCore.Qt.CopyAction ) + # set custom data + data = QtCore.QByteArray () + stream = QtCore.QDataStream ( data, QtCore.QIODevice.WriteOnly ) + + itemName = item.text () + if QtCore.QT_VERSION < 50000 : + itemFilename = item.data( QtCore.Qt.UserRole + 4 ).toString () + stream << itemFilename + else : + itemFilename = item.data( QtCore.Qt.UserRole + 4 ) + stream.writeBytes ( itemFilename ) + + mimeData = QtCore.QMimeData() + mimeData.setData ( 'application/x-text', data ) + + # set drag + drag = QtGui.QDrag ( self ) + drag.setMimeData ( mimeData ) + #drag.setPixmap ( QtGui.QPixmap(':/node.png') ) + drag.start ( QtCore.Qt.CopyAction ) diff --git a/gui/params/ColorWidget.py b/gui/params/ColorWidget.py index 22a1066..2fab213 100644 --- a/gui/params/ColorWidget.py +++ b/gui/params/ColorWidget.py @@ -3,7 +3,7 @@ ColorWidget.py """ -from PyQt4 import QtGui, QtCore +from core.mePyQt import QtGui, QtCore import gui.ui_settings as UI from paramWidget import ParamWidget diff --git a/gui/params/ControlWidget.py b/gui/params/ControlWidget.py index 145e2b4..b66df7b 100644 --- a/gui/params/ControlWidget.py +++ b/gui/params/ControlWidget.py @@ -3,7 +3,7 @@ ControlWidget.py """ -from PyQt4 import QtGui, QtCore +from core.mePyQt import QtGui, QtCore from global_vars import app_global_vars, DEBUG_MODE import gui.ui_settings as UI diff --git a/gui/params/FloatWidget.py b/gui/params/FloatWidget.py index b87b787..c0d9d75 100644 --- a/gui/params/FloatWidget.py +++ b/gui/params/FloatWidget.py @@ -6,7 +6,7 @@ import math from decimal import * -from PyQt4 import QtGui, QtCore +from core.mePyQt import QtGui, QtCore import gui.ui_settings as UI from paramWidget import ParamWidget diff --git a/gui/params/IntWidget.py b/gui/params/IntWidget.py index 2693298..b9f101a 100644 --- a/gui/params/IntWidget.py +++ b/gui/params/IntWidget.py @@ -3,7 +3,7 @@ IntWidget.py """ -from PyQt4 import QtGui, QtCore +from core.mePyQt import QtGui, QtCore import gui.ui_settings as UI from paramWidget import ParamWidget diff --git a/gui/params/MatrixWidget.py b/gui/params/MatrixWidget.py index d66d690..45d08c3 100644 --- a/gui/params/MatrixWidget.py +++ b/gui/params/MatrixWidget.py @@ -3,7 +3,7 @@ MatrixWidget.py """ -from PyQt4 import QtGui, QtCore +from core.mePyQt import QtGui, QtCore import gui.ui_settings as UI from paramWidget import ParamWidget diff --git a/gui/params/NormalWidget.py b/gui/params/NormalWidget.py index 62de068..d522a29 100644 --- a/gui/params/NormalWidget.py +++ b/gui/params/NormalWidget.py @@ -3,7 +3,7 @@ NormalWidget.py """ -from PyQt4 import QtGui, QtCore +from core.mePyQt import QtGui, QtCore import gui.ui_settings as UI from paramWidget import ParamWidget diff --git a/gui/params/PointWidget.py b/gui/params/PointWidget.py index b12574c..2264d8f 100644 --- a/gui/params/PointWidget.py +++ b/gui/params/PointWidget.py @@ -3,7 +3,7 @@ PointWidget.py """ -from PyQt4 import QtGui, QtCore +from core.mePyQt import QtGui, QtCore import gui.ui_settings as UI from paramWidget import ParamWidget diff --git a/gui/params/StringWidget.py b/gui/params/StringWidget.py index 4dd34dd..b643dd9 100644 --- a/gui/params/StringWidget.py +++ b/gui/params/StringWidget.py @@ -3,7 +3,7 @@ StringWidget.py """ -from PyQt4 import QtGui, QtCore +from core.mePyQt import QtGui, QtCore from global_vars import app_global_vars, DEBUG_MODE import gui.ui_settings as UI diff --git a/gui/params/TextWidget.py b/gui/params/TextWidget.py index 5832963..73626a1 100644 --- a/gui/params/TextWidget.py +++ b/gui/params/TextWidget.py @@ -3,7 +3,7 @@ TextWidget.py """ -from PyQt4 import QtGui, QtCore +from core.mePyQt import QtGui, QtCore import gui.ui_settings as UI from paramWidget import ParamWidget diff --git a/gui/params/VectorWidget.py b/gui/params/VectorWidget.py index a7696ec..c805a67 100644 --- a/gui/params/VectorWidget.py +++ b/gui/params/VectorWidget.py @@ -3,7 +3,7 @@ VectorWidget.py """ -from PyQt4 import QtGui, QtCore +from core.mePyQt import QtGui, QtCore import gui.ui_settings as UI from paramWidget import ParamWidget diff --git a/gui/params/linkWidget.py b/gui/params/linkWidget.py index 44c6157..d1e1a14 100644 --- a/gui/params/linkWidget.py +++ b/gui/params/linkWidget.py @@ -3,7 +3,7 @@ linkWidget.py """ -from PyQt4 import QtGui, QtCore +from core.mePyQt import QtGui, QtCore from global_vars import app_global_vars, DEBUG_MODE import gui.ui_settings as UI diff --git a/gui/params/paramLabel.py b/gui/params/paramLabel.py index 3f53c3f..eb6d841 100644 --- a/gui/params/paramLabel.py +++ b/gui/params/paramLabel.py @@ -3,149 +3,156 @@ paramLabel.py """ -from PyQt4 import QtGui, QtCore +from core.mePyQt import QtGui, QtCore from global_vars import app_global_vars, DEBUG_MODE import gui.ui_settings as UI + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + # # ParamLabel -- editable parameter label # -class ParamLabel ( QtGui.QLabel ) : - # - # __init__ - # - def __init__ ( self, parent, param = None ) : - # - super ( QtGui.QLabel, self ).__init__ ( parent ) - self.widget = parent - self.param = param - if param is not None : - if param.label != '' : - label_text = param.label - else : - label_text = param.name - self.setText ( label_text ) - if self.param.provider == 'primitive' : - primitiveColor = QtGui.QColor ( 240, 150, 0 ) - palette = QtGui.QPalette () - palette.setColor ( QtGui.QPalette.WindowText, primitiveColor ) - self.setPalette ( palette ) - if self.param.detail == 'varying' : - font = QtGui.QFont () - font.setItalic ( True ) - self.setFont ( font ) - #self.setScaledContents ( True ) - #self.setMouseTracking ( True ) - self.buildGui () - self.updateGui () - self.connectSignals () - # - # __del__ - # - def __del__ ( self ) : - # - self.disconnectSignals () - # - # buildGui - # - def buildGui ( self ) : - # - self.editLabel = QtGui.QLineEdit ( self ) - self.editLabel.setText ( self.text () ) - self.editLabel.setVisible ( False ) - # - # updateGui - # - def updateGui ( self ) : - # - pass - # - # connectSignals - # - def connectSignals ( self ) : - # - self.connect ( self.editLabel, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditingFinished ) - # - # disconnectSignals - # - def disconnectSignals ( self ) : - # - self.disconnect ( self.editLabel, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditingFinished ) - """ - # - # mouseMoveEvent - # - def mouseMoveEvent ( self, event ) : - # - if DEBUG_MODE : print ">> ParamLabel( %s ).mouseMoveEvent" % self.param.name - QtGui.QWidget.mouseMoveEvent ( self, event ) - """ - # - # onEditingFinished - # - def onEditingFinished ( self ) : - # - if DEBUG_MODE : print ">> ParamLabel( %s ).onEditingFinished" % self.param.name - oldLabel = self.param.label - newLabel = str ( self.editLabel.text () ).strip () - if newLabel != oldLabel : - newLabel = self.widget.gfxNode.node.renameParamLabel ( self.param, newLabel ) - self.setText ( newLabel ) - self.editLabel.setText ( newLabel ) - self.adjustSize () - self.editLabel.adjustSize () - self.param.paramChanged () - self.setVisible ( True ) - self.editLabel.setVisible ( False ) - # - # mouseDoubleClickEvent - # - def mouseDoubleClickEvent ( self, event ) : - # - button = event.button () - if button == QtCore.Qt.LeftButton : - #if DEBUG_MODE : print ">> ParamLabel( %s ).mouseDoubleClickEvent" % self.param.name - parentLayout = self.parent ().layout () - editWidth = parentLayout.columnMinimumWidth ( 0 ) - self.mapToParent ( QtCore.QPoint ( 0, 0 ) ).x () - self.setFixedWidth ( editWidth ) - self.editLabel.setFixedWidth ( editWidth ) - self.editLabel.setVisible ( True ) - - return - QtGui.QWidget.mouseDoubleClickEvent ( self, event ) - # - # mousePressEvent - # - def mousePressEvent ( self, event ) : - # - #if DEBUG_MODE : print ">> ParamLabel( %s ).mousePressEvent" % self.param.name - button = event.button () - modifiers =event.modifiers () - if button == QtCore.Qt.LeftButton : - if modifiers == QtCore.Qt.ControlModifier : - if DEBUG_MODE : print '* CTRL+LMB (change in shaderParam)' - self.param.shaderParam = not self.param.shaderParam - self.param.paramChanged () - return - elif modifiers == QtCore.Qt.AltModifier : - if DEBUG_MODE : print '* ALT+LMB ( change detail "uniform/varying")' - if self.param.detail == 'varying' : - self.param.detail = 'uniform' - else : - self.param.detail = 'varying' - self.param.paramChanged () - return - elif button == QtCore.Qt.RightButton : - if modifiers == QtCore.Qt.ControlModifier : - if DEBUG_MODE : print '* CTRL+RMB change provider "primitive"/"internal"' - if self.param.provider == 'primitive' : - self.param.provider = '' - else : - self.param.provider = 'primitive' - self.param.paramChanged () - return - elif modifiers == QtCore.Qt.AltModifier : - if DEBUG_MODE : print '* ALT+RMB "enable"/"disable" parameter' - self.param.enabled = not self.param.enabled - self.param.paramChanged () - QtGui.QWidget.mousePressEvent ( self, event ) +class ParamLabel ( QtModule.QLabel ) : + # + # __init__ + # + def __init__ ( self, parent, param = None ) : + # + super ( QtModule.QLabel, self ).__init__ ( parent ) + self.widget = parent + self.param = param + if param is not None : + if param.label != '' : + label_text = param.label + else : + label_text = param.name + self.setText ( label_text ) + if self.param.provider == 'primitive' : + primitiveColor = QtGui.QColor ( 240, 150, 0 ) + palette = QtGui.QPalette () + palette.setColor ( QtGui.QPalette.WindowText, primitiveColor ) + self.setPalette ( palette ) + if self.param.detail == 'varying' : + font = QtGui.QFont () + font.setItalic ( True ) + self.setFont ( font ) + #self.setScaledContents ( True ) + #self.setMouseTracking ( True ) + self.buildGui () + self.updateGui () + self.connectSignals () + # + # __del__ + # + def __del__ ( self ) : + # + self.disconnectSignals () + # + # buildGui + # + def buildGui ( self ) : + # + self.editLabel = QtModule.QLineEdit ( self ) + self.editLabel.setText ( self.text () ) + self.editLabel.setVisible ( False ) + # + # updateGui + # + def updateGui ( self ) : + # + pass + # + # connectSignals + # + def connectSignals ( self ) : + # + self.connect ( self.editLabel, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditingFinished ) + # + # disconnectSignals + # + def disconnectSignals ( self ) : + # + self.disconnect ( self.editLabel, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditingFinished ) + """ + # + # mouseMoveEvent + # + def mouseMoveEvent ( self, event ) : + # + if DEBUG_MODE : print ">> ParamLabel( %s ).mouseMoveEvent" % self.param.name + QtGui.QWidget.mouseMoveEvent ( self, event ) + """ + # + # onEditingFinished + # + def onEditingFinished ( self ) : + # + if DEBUG_MODE : print ">> ParamLabel( %s ).onEditingFinished" % self.param.name + oldLabel = self.param.label + newLabel = str ( self.editLabel.text () ).strip () + if newLabel != oldLabel : + newLabel = self.widget.gfxNode.node.renameParamLabel ( self.param, newLabel ) + self.setText ( newLabel ) + self.editLabel.setText ( newLabel ) + self.adjustSize () + self.editLabel.adjustSize () + self.param.paramChanged () + self.setVisible ( True ) + self.editLabel.setVisible ( False ) + # + # mouseDoubleClickEvent + # + def mouseDoubleClickEvent ( self, event ) : + # + button = event.button () + if button == QtCore.Qt.LeftButton : + #if DEBUG_MODE : print ">> ParamLabel( %s ).mouseDoubleClickEvent" % self.param.name + parentLayout = self.parent ().layout () + editWidth = parentLayout.columnMinimumWidth ( 0 ) - self.mapToParent ( QtCore.QPoint ( 0, 0 ) ).x () + self.setFixedWidth ( editWidth ) + self.editLabel.setFixedWidth ( editWidth ) + self.editLabel.setVisible ( True ) + + return + QtGui.QWidget.mouseDoubleClickEvent ( self, event ) + # + # mousePressEvent + # + def mousePressEvent ( self, event ) : + # + #if DEBUG_MODE : print ">> ParamLabel( %s ).mousePressEvent" % self.param.name + button = event.button () + modifiers =event.modifiers () + if button == QtCore.Qt.LeftButton : + if modifiers == QtCore.Qt.ControlModifier : + if DEBUG_MODE : print '* CTRL+LMB (change in shaderParam)' + self.param.shaderParam = not self.param.shaderParam + self.param.paramChanged () + return + elif modifiers == QtCore.Qt.AltModifier : + if DEBUG_MODE : print '* ALT+LMB ( change detail "uniform/varying")' + if self.param.detail == 'varying' : + self.param.detail = 'uniform' + else : + self.param.detail = 'varying' + self.param.paramChanged () + return + elif button == QtCore.Qt.RightButton : + if modifiers == QtCore.Qt.ControlModifier : + if DEBUG_MODE : print '* CTRL+RMB change provider "primitive"/"internal"' + if self.param.provider == 'primitive' : + self.param.provider = '' + else : + self.param.provider = 'primitive' + self.param.paramChanged () + return + elif modifiers == QtCore.Qt.AltModifier : + if DEBUG_MODE : print '* ALT+RMB "enable"/"disable" parameter' + self.param.enabled = not self.param.enabled + self.param.paramChanged () + QtGui.QWidget.mousePressEvent ( self, event ) diff --git a/gui/params/paramWidget.py b/gui/params/paramWidget.py index 6c19d9a..10b99d9 100644 --- a/gui/params/paramWidget.py +++ b/gui/params/paramWidget.py @@ -3,190 +3,197 @@ paramWidget.py """ -from PyQt4 import QtGui, QtCore +from core.mePyQt import QtGui, QtCore from global_vars import app_global_vars, DEBUG_MODE, VALID_PARAM_TYPES, VALID_RSL_NODE_TYPES, VALID_RSL_PARAM_TYPES import gui.ui_settings as UI -from paramLabel import ParamLabel +from paramLabel import ParamLabel + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + # # ParamWidget general class for parameter widgets # -class ParamWidget ( QtGui.QWidget ) : - # - # __init__ - # - def __init__ ( self, param, gfxNode, ignoreSubtype = False ) : - # - super ( QtGui.QWidget, self ).__init__ ( None ) - self.param = param - self.gfxNode = gfxNode - self.ignoreSubtype = ignoreSubtype # if widget is used in NodeEditor, then ignoreSubtype = True +class ParamWidget ( QtModule.QWidget ) : + # + # __init__ + # + def __init__ ( self, param, gfxNode, ignoreSubtype = False ) : + # + super ( QtModule.QWidget, self ).__init__ ( None ) + self.param = param + self.gfxNode = gfxNode + self.ignoreSubtype = ignoreSubtype # if widget is used in NodeEditor, then ignoreSubtype = True - self.buildGeneralGui () - self.buildGui () - self.ui.updateGui ( self.param.value ) - #self.connectSignals () - #self.connect( self.param, QtCore.SIGNAL( 'paramChanged(QObject)' ), self.onParamChanged ) - #if DEBUG_MODE : print ">> ParamWidget (%s.%s) __init__" % ( self.gfxNode.node.label, self.param.label ) - # - # __del__ - # - def __del__ ( self ) : - # - if DEBUG_MODE : print '>> ParamWidget( %s ).__del__ ' % self.param.name - # - # connectSignals - # - def connectSignals ( self ) : - # - pass - # - # setEnabled - # - def setEnabled ( self, enabled = True ) : - # - for hl in self.param_vl.children () : - for i in range ( hl.count () ) : - obj = hl.itemAt ( i ).widget () - if obj is not None : - obj.setEnabled ( enabled ) - # - # onParamChanged - # - def onParamChanged ( self, param ) : - # - if DEBUG_MODE : print ">> ParamWidget( %s ).onParamChanged" % param.name - self.ui.disconnectSignals ( self ) - self.ui.updateGui ( self.param.value ) - self.ui.connectSignals ( self ) - #self.emit ( QtCore.SIGNAL( 'onParamChanged(QObject)' ), param ) - # - # buildGeneralGui - # - def buildGeneralGui ( self ) : - #if DEBUG_MODE : print ">> ParamWidget buildGeneralGui" - - self.label_vl = QtGui.QVBoxLayout () - self.label_vl.setSpacing ( UI.SPACING ) - self.label_vl.setMargin ( 0 ) - self.label_vl.setAlignment ( QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft ) + self.buildGeneralGui () + self.buildGui () + self.ui.updateGui ( self.param.value ) + #self.connectSignals () + #self.connect( self.param, QtCore.SIGNAL( 'paramChanged(QObject)' ), self.onParamChanged ) + #if DEBUG_MODE : print ">> ParamWidget (%s.%s) __init__" % ( self.gfxNode.node.label, self.param.label ) + # + # __del__ + # + def __del__ ( self ) : + # + if DEBUG_MODE : print '>> ParamWidget( %s ).__del__ ' % self.param.name + # + # connectSignals + # + def connectSignals ( self ) : + # + pass + # + # setEnabled + # + def setEnabled ( self, enabled = True ) : + # + for hl in self.param_vl.children () : + for i in range ( hl.count () ) : + obj = hl.itemAt ( i ).widget () + if obj is not None : + obj.setEnabled ( enabled ) + # + # onParamChanged + # + def onParamChanged ( self, param ) : + # + if DEBUG_MODE : print ">> ParamWidget( %s ).onParamChanged" % param.name + self.ui.disconnectSignals ( self ) + self.ui.updateGui ( self.param.value ) + self.ui.connectSignals ( self ) + #self.emit ( QtCore.SIGNAL( 'onParamChanged(QObject)' ), param ) + # + # buildGeneralGui + # + def buildGeneralGui ( self ) : + #if DEBUG_MODE : print ">> ParamWidget buildGeneralGui" + + self.label_vl = QtModule.QVBoxLayout () + self.label_vl.setSpacing ( UI.SPACING ) + self.label_vl.setMargin ( 0 ) + self.label_vl.setAlignment ( QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft ) - #self.gui = QtGui.QWidget ( self ) + #self.gui = QtGui.QWidget ( self ) - self.hl = QtGui.QHBoxLayout () - self.hl.setSpacing ( UI.SPACING ) - self.hl.setMargin ( 0 ) - self.hl.setAlignment ( QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft ) - - # vertical layout for parametrs values (e.g. output links or matrix rows) - self.param_vl = QtGui.QVBoxLayout () - self.param_vl.setSpacing ( UI.SPACING ) - self.param_vl.setMargin ( 0 ) - self.param_vl.setAlignment ( QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft ) - # - # add 'isShaderParam' check box only for RSL nodes - # - if self.gfxNode is not None : - # - # add "Use as Shader parameter" checkbox - # - if ( self.gfxNode.node.type in VALID_RSL_NODE_TYPES ) and ( self.param.type in VALID_RSL_PARAM_TYPES ) and ( self.param.provider != 'attribute' ) : - self.check = QtGui.QCheckBox ( self ) - self.check.setMinimumSize ( QtCore.QSize ( UI.CHECK_WIDTH, UI.HEIGHT ) ) - self.check.setMaximumSize ( QtCore.QSize ( UI.CHECK_WIDTH, UI.HEIGHT ) ) - self.check.setToolTip ( 'Use as Shader parameter' ) - self.check.setChecked ( self.param.shaderParam ) - self.connect ( self.check, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onShaderParamChanged ) - self.hl.addWidget ( self.check ) - else : - spacer = QtGui.QSpacerItem ( UI.LT_SPACE, UI.HEIGHT, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum ) - self.hl.addItem ( spacer ) - # - # add 'remove' button for removable parameters - # - if self.param.removable : - self.removeButton = QtGui.QToolButton ( self ) - sizePolicy = QtGui.QSizePolicy ( QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed ) - sizePolicy.setHorizontalStretch ( 20 ) - sizePolicy.setVerticalStretch ( 20 ) - sizePolicy.setHeightForWidth ( self.removeButton.sizePolicy().hasHeightForWidth() ) - self.removeButton.setSizePolicy ( sizePolicy ) - self.removeButton.setMaximumSize ( QtCore.QSize ( 20, 20 ) ) - icon = QtGui.QIcon () - icon.addPixmap ( QtGui.QPixmap ( ':/edit_icons/resources/del_list.png' ), QtGui.QIcon.Normal, QtGui.QIcon.On ) - self.removeButton.setIcon ( icon ) - self.removeButton.setAutoRaise ( True ) - self.removeButton.setToolTip ( 'Remove parameter' ) - self.removeButton.setIconSize ( QtCore.QSize ( 16, 16 ) ) - self.removeButton.setObjectName ( 'removeButton' ) - self.hl.addWidget ( self.removeButton ) - QtCore.QObject.connect ( self.removeButton, QtCore.SIGNAL ( 'clicked()' ), self.onRemoveItem ) - - #self.label = QtGui.QLabel ( self ) - self.label = ParamLabel ( self, self.param ) - #font = QtGui.QFont () - #font.setBold ( False ) - #self.label.setFont ( font ) - # QtCore.QObject - #self.connect ( self.label, QtCore.SIGNAL ( 'mouseDoubleClickEvent(QEvent)' ), self.onMouseDoubleClickEvent ) - #self.connect ( self.label, QtCore.SIGNAL ( 'mousePressEvent(QEvent)' ), self.onMousePressEvent ) - - self.helpMark = QtGui.QLabel ( self ) - palette = QtGui.QPalette () - palette.setColor ( QtGui.QPalette.WindowText, QtGui.QColor ( 0, 140, 0 ) ) - font1 = QtGui.QFont () - font1.setBold ( True ) - self.helpMark.setPalette ( palette ) - self.helpMark.setFont ( font1 ) - self.helpMark.setText ( '' ) - - self.helpMark.setMinimumSize ( QtCore.QSize ( 6, UI.HEIGHT ) ) - self.helpMark.setMaximumSize ( QtCore.QSize ( 6, UI.HEIGHT ) ) - - self.helpMark.setEnabled ( False ) - - if self.param.help is not None and self.param.help != '' : - self.label.setWhatsThis ( self.param.help ) - self.helpMark.setWhatsThis ( self.param.help ) - self.helpMark.setText ( '?' ) - self.helpMark.setEnabled ( True ) - - self.label.setAlignment ( QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter ) - #self.label.setMinimumSize ( QtCore.QSize ( UI.LABEL_WIDTH, UI.HEIGHT ) ) - #self.label.setMaximumSize ( QtCore.QSize ( UI.LABEL_WIDTH, UI.HEIGHT ) ) - - #self.vl.addWidget ( self.gui ) - self.hl.addWidget ( self.label ) - self.hl.addWidget ( self.helpMark ) - #self.hl.addLayout ( self.param_vl ) - self.label_vl.addItem ( QtGui.QSpacerItem ( 20, 0, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum ) ) - self.label_vl.addLayout ( self.hl ) - # - # onShaderParamChanged - # - def onShaderParamChanged ( self, value ) : - # - self.param.shaderParam = self.check.isChecked () - self.gfxNode.updateGfxNodeParams ( True ) - #if self.param.isInput : - # self.gfxNode.updateInputParams () - #else : - # self.gfxNode.updateOutputParams () - # - # buildGui -- virtual method - # should be overriden in inherited classes - # - def buildGui ( self ) : - # - pass - spacer = QtGui.QSpacerItem ( 20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum ) - self.hl.addItem ( spacer ) - # - # onRemoveItem - # - def onRemoveItem ( self ) : - # - if DEBUG_MODE : print '>> ParamWidget( %s ).onRemoveItem ' % self.param.name - self.emit ( QtCore.SIGNAL ( 'nodeParamRemoved' ), self.param ) + self.hl = QtModule.QHBoxLayout () + self.hl.setSpacing ( UI.SPACING ) + self.hl.setMargin ( 0 ) + self.hl.setAlignment ( QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft ) + + # vertical layout for parametrs values (e.g. output links or matrix rows) + self.param_vl = QtModule.QVBoxLayout () + self.param_vl.setSpacing ( UI.SPACING ) + self.param_vl.setMargin ( 0 ) + self.param_vl.setAlignment ( QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft ) + # + # add 'isShaderParam' check box only for RSL nodes + # + if self.gfxNode is not None : + # + # add "Use as Shader parameter" checkbox + # + if ( self.gfxNode.node.type in VALID_RSL_NODE_TYPES ) and ( self.param.type in VALID_RSL_PARAM_TYPES ) and ( self.param.provider != 'attribute' ) : + self.check = QtModule.QCheckBox ( self ) + self.check.setMinimumSize ( QtCore.QSize ( UI.CHECK_WIDTH, UI.HEIGHT ) ) + self.check.setMaximumSize ( QtCore.QSize ( UI.CHECK_WIDTH, UI.HEIGHT ) ) + self.check.setToolTip ( 'Use as Shader parameter' ) + self.check.setChecked ( self.param.shaderParam ) + self.connect ( self.check, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onShaderParamChanged ) + self.hl.addWidget ( self.check ) + else : + spacer = QtModule.QSpacerItem ( UI.LT_SPACE, UI.HEIGHT, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum ) + self.hl.addItem ( spacer ) + # + # add 'remove' button for removable parameters + # + if self.param.removable : + self.removeButton = QtModule.QToolButton ( self ) + sizePolicy = QtModule.QSizePolicy ( QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed ) + sizePolicy.setHorizontalStretch ( 20 ) + sizePolicy.setVerticalStretch ( 20 ) + sizePolicy.setHeightForWidth ( self.removeButton.sizePolicy().hasHeightForWidth() ) + self.removeButton.setSizePolicy ( sizePolicy ) + self.removeButton.setMaximumSize ( QtCore.QSize ( 20, 20 ) ) + icon = QtModule.QIcon () + icon.addPixmap ( QtGui.QPixmap ( ':/edit_icons/resources/del_list.png' ), QtGui.QIcon.Normal, QtGui.QIcon.On ) + self.removeButton.setIcon ( icon ) + self.removeButton.setAutoRaise ( True ) + self.removeButton.setToolTip ( 'Remove parameter' ) + self.removeButton.setIconSize ( QtCore.QSize ( 16, 16 ) ) + self.removeButton.setObjectName ( 'removeButton' ) + self.hl.addWidget ( self.removeButton ) + QtCore.QObject.connect ( self.removeButton, QtCore.SIGNAL ( 'clicked()' ), self.onRemoveItem ) + + #self.label = QtGui.QLabel ( self ) + self.label = ParamLabel ( self, self.param ) + #font = QtGui.QFont () + #font.setBold ( False ) + #self.label.setFont ( font ) + # QtCore.QObject + #self.connect ( self.label, QtCore.SIGNAL ( 'mouseDoubleClickEvent(QEvent)' ), self.onMouseDoubleClickEvent ) + #self.connect ( self.label, QtCore.SIGNAL ( 'mousePressEvent(QEvent)' ), self.onMousePressEvent ) + + self.helpMark = QtModule.QLabel ( self ) + palette = QtGui.QPalette () + palette.setColor ( QtGui.QPalette.WindowText, QtGui.QColor ( 0, 140, 0 ) ) + font1 = QtGui.QFont () + font1.setBold ( True ) + self.helpMark.setPalette ( palette ) + self.helpMark.setFont ( font1 ) + self.helpMark.setText ( '' ) + + self.helpMark.setMinimumSize ( QtCore.QSize ( 6, UI.HEIGHT ) ) + self.helpMark.setMaximumSize ( QtCore.QSize ( 6, UI.HEIGHT ) ) + + self.helpMark.setEnabled ( False ) + + if self.param.help is not None and self.param.help != '' : + self.label.setWhatsThis ( self.param.help ) + self.helpMark.setWhatsThis ( self.param.help ) + self.helpMark.setText ( '?' ) + self.helpMark.setEnabled ( True ) + + self.label.setAlignment ( QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter ) + #self.label.setMinimumSize ( QtCore.QSize ( UI.LABEL_WIDTH, UI.HEIGHT ) ) + #self.label.setMaximumSize ( QtCore.QSize ( UI.LABEL_WIDTH, UI.HEIGHT ) ) + + #self.vl.addWidget ( self.gui ) + self.hl.addWidget ( self.label ) + self.hl.addWidget ( self.helpMark ) + #self.hl.addLayout ( self.param_vl ) + self.label_vl.addItem ( QtGui.QSpacerItem ( 20, 0, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum ) ) + self.label_vl.addLayout ( self.hl ) + # + # onShaderParamChanged + # + def onShaderParamChanged ( self, value ) : + # + self.param.shaderParam = self.check.isChecked () + self.gfxNode.updateGfxNodeParams ( True ) + #if self.param.isInput : + # self.gfxNode.updateInputParams () + #else : + # self.gfxNode.updateOutputParams () + # + # buildGui -- virtual method + # should be overriden in inherited classes + # + def buildGui ( self ) : + # + pass + spacer = QtModule.QSpacerItem ( 20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum ) + self.hl.addItem ( spacer ) + # + # onRemoveItem + # + def onRemoveItem ( self ) : + # + if DEBUG_MODE : print '>> ParamWidget( %s ).onRemoveItem ' % self.param.name + self.emit ( QtCore.SIGNAL ( 'nodeParamRemoved' ), self.param ) diff --git a/gui/resources_rc.py b/gui/resources_rc.py index b2472fe..0840f63 100644 --- a/gui/resources_rc.py +++ b/gui/resources_rc.py @@ -7,7 +7,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore +from core.mePyQt import QtCore qt_resource_data = "\ \x00\x00\x03\x54\ diff --git a/gui/ui_MainWindow.py b/gui/ui_MainWindow.py index 0f94563..9c9f718 100644 --- a/gui/ui_MainWindow.py +++ b/gui/ui_MainWindow.py @@ -7,7 +7,13 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets try: _fromUtf8 = QtCore.QString.fromUtf8 @@ -16,29 +22,29 @@ def _fromUtf8(s): return s try: - _encoding = QtGui.QApplication.UnicodeUTF8 + _encoding = QtModule.QApplication.UnicodeUTF8 def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig, _encoding) + return QtModule.QApplication.translate(context, text, disambig, _encoding) except AttributeError: def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig) + return QtModule.QApplication.translate(context, text, disambig) class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.resize(963, 894) - MainWindow.setDockOptions(QtGui.QMainWindow.AllowTabbedDocks|QtGui.QMainWindow.AnimatedDocks) + MainWindow.setDockOptions(QtModule.QMainWindow.AllowTabbedDocks|QtModule.QMainWindow.AnimatedDocks) MainWindow.setUnifiedTitleAndToolBarOnMac(False) - self.centralwidget = QtGui.QWidget(MainWindow) + self.centralwidget = QtModule.QWidget(MainWindow) self.centralwidget.setAcceptDrops(True) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) - self.gridLayout = QtGui.QGridLayout(self.centralwidget) - self.gridLayout.setMargin(0) + self.gridLayout = QtModule.QGridLayout(self.centralwidget) + #self.gridLayout.setMargin(0) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) - self.tabs = QtGui.QTabWidget(self.centralwidget) + self.tabs = QtModule.QTabWidget(self.centralwidget) self.tabs.setAcceptDrops(True) - self.tabs.setTabPosition(QtGui.QTabWidget.North) - self.tabs.setTabShape(QtGui.QTabWidget.Rounded) + self.tabs.setTabPosition(QtModule.QTabWidget.North) + self.tabs.setTabShape(QtModule.QTabWidget.Rounded) self.tabs.setElideMode(QtCore.Qt.ElideNone) self.tabs.setDocumentMode(True) self.tabs.setTabsClosable(True) @@ -50,59 +56,59 @@ def setupUi(self, MainWindow): self.tabs.addTab(self.workArea, _fromUtf8("")) self.gridLayout.addWidget(self.tabs, 0, 0, 1, 1) MainWindow.setCentralWidget(self.centralwidget) - self.menubar = QtGui.QMenuBar(MainWindow) + self.menubar = QtModule.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 963, 21)) font = QtGui.QFont() font.setFamily(_fromUtf8("Lucida Sans")) font.setPointSize(9) self.menubar.setFont(font) self.menubar.setObjectName(_fromUtf8("menubar")) - self.menuFile = QtGui.QMenu(self.menubar) + self.menuFile = QtModule.QMenu(self.menubar) font = QtGui.QFont() font.setFamily(_fromUtf8("MS Shell Dlg 2")) font.setPointSize(8) self.menuFile.setFont(font) self.menuFile.setObjectName(_fromUtf8("menuFile")) - self.menuRecent_Projects = QtGui.QMenu(self.menuFile) + self.menuRecent_Projects = QtModule.QMenu(self.menuFile) self.menuRecent_Projects.setObjectName(_fromUtf8("menuRecent_Projects")) - self.menuRecent_Networks = QtGui.QMenu(self.menuFile) + self.menuRecent_Networks = QtModule.QMenu(self.menuFile) self.menuRecent_Networks.setObjectName(_fromUtf8("menuRecent_Networks")) - self.menuEdit = QtGui.QMenu(self.menubar) + self.menuEdit = QtModule.QMenu(self.menubar) font = QtGui.QFont() font.setFamily(_fromUtf8("MS Shell Dlg 2")) font.setPointSize(8) self.menuEdit.setFont(font) self.menuEdit.setObjectName(_fromUtf8("menuEdit")) - self.menuCommand = QtGui.QMenu(self.menubar) + self.menuCommand = QtModule.QMenu(self.menubar) self.menuCommand.setEnabled(True) font = QtGui.QFont() font.setFamily(_fromUtf8("MS Shell Dlg 2")) font.setPointSize(8) self.menuCommand.setFont(font) self.menuCommand.setObjectName(_fromUtf8("menuCommand")) - self.menuCreateNode = QtGui.QMenu(self.menuCommand) + self.menuCreateNode = QtModule.QMenu(self.menuCommand) self.menuCreateNode.setEnabled(True) self.menuCreateNode.setObjectName(_fromUtf8("menuCreateNode")) - self.menuWindow = QtGui.QMenu(self.menubar) + self.menuWindow = QtModule.QMenu(self.menubar) font = QtGui.QFont() font.setFamily(_fromUtf8("MS Shell Dlg 2")) font.setPointSize(8) self.menuWindow.setFont(font) self.menuWindow.setObjectName(_fromUtf8("menuWindow")) - self.menuHelp = QtGui.QMenu(self.menubar) + self.menuHelp = QtModule.QMenu(self.menubar) font = QtGui.QFont() font.setFamily(_fromUtf8("MS Shell Dlg 2")) font.setPointSize(8) self.menuHelp.setFont(font) self.menuHelp.setLayoutDirection(QtCore.Qt.RightToLeft) self.menuHelp.setObjectName(_fromUtf8("menuHelp")) - self.menuView = QtGui.QMenu(self.menubar) + self.menuView = QtModule.QMenu(self.menubar) self.menuView.setObjectName(_fromUtf8("menuView")) MainWindow.setMenuBar(self.menubar) - self.statusbar = QtGui.QStatusBar(MainWindow) + self.statusbar = QtModule.QStatusBar(MainWindow) self.statusbar.setObjectName(_fromUtf8("statusbar")) MainWindow.setStatusBar(self.statusbar) - self.dockNodes = QtGui.QDockWidget(MainWindow) + self.dockNodes = QtModule.QDockWidget(MainWindow) self.dockNodes.setMinimumSize(QtCore.QSize(150, 42)) self.dockNodes.setFloating(False) self.dockNodes.setAllowedAreas(QtCore.Qt.LeftDockWidgetArea|QtCore.Qt.RightDockWidgetArea) @@ -111,147 +117,147 @@ def setupUi(self, MainWindow): self.nodeList_ctl.setObjectName(_fromUtf8("nodeList_ctl")) self.dockNodes.setWidget(self.nodeList_ctl) MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.dockNodes) - self.toolBar = QtGui.QToolBar(MainWindow) + self.toolBar = QtModule.QToolBar(MainWindow) self.toolBar.setMinimumSize(QtCore.QSize(0, 0)) self.toolBar.setBaseSize(QtCore.QSize(0, 0)) self.toolBar.setAllowedAreas(QtCore.Qt.LeftToolBarArea|QtCore.Qt.TopToolBarArea) self.toolBar.setIconSize(QtCore.QSize(24, 24)) self.toolBar.setObjectName(_fromUtf8("toolBar")) MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar) - self.dockPreview = QtGui.QDockWidget(MainWindow) + self.dockPreview = QtModule.QDockWidget(MainWindow) self.dockPreview.setBaseSize(QtCore.QSize(300, 0)) self.dockPreview.setFloating(False) - self.dockPreview.setFeatures(QtGui.QDockWidget.AllDockWidgetFeatures) + self.dockPreview.setFeatures(QtModule.QDockWidget.AllDockWidgetFeatures) self.dockPreview.setAllowedAreas(QtCore.Qt.LeftDockWidgetArea|QtCore.Qt.RightDockWidgetArea) self.dockPreview.setObjectName(_fromUtf8("dockPreview")) self.imageView_ctl = ImageViewWidget() self.imageView_ctl.setObjectName(_fromUtf8("imageView_ctl")) self.dockPreview.setWidget(self.imageView_ctl) MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.dockPreview) - self.dockParam = QtGui.QDockWidget(MainWindow) + self.dockParam = QtModule.QDockWidget(MainWindow) self.dockParam.setBaseSize(QtCore.QSize(300, 0)) - self.dockParam.setFeatures(QtGui.QDockWidget.AllDockWidgetFeatures) + self.dockParam.setFeatures(QtModule.QDockWidget.AllDockWidgetFeatures) self.dockParam.setAllowedAreas(QtCore.Qt.LeftDockWidgetArea|QtCore.Qt.RightDockWidgetArea) self.dockParam.setObjectName(_fromUtf8("dockParam")) self.nodeParam_ctl = NodeParamView() self.nodeParam_ctl.setObjectName(_fromUtf8("nodeParam_ctl")) self.dockParam.setWidget(self.nodeParam_ctl) MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.dockParam) - self.dockProject = QtGui.QDockWidget(MainWindow) + self.dockProject = QtModule.QDockWidget(MainWindow) self.dockProject.setObjectName(_fromUtf8("dockProject")) self.project_ctl = NodeLibraryView() self.project_ctl.setObjectName(_fromUtf8("project_ctl")) self.dockProject.setWidget(self.project_ctl) MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.dockProject) - self.dockSwatch = QtGui.QDockWidget(MainWindow) + self.dockSwatch = QtModule.QDockWidget(MainWindow) self.dockSwatch.setObjectName(_fromUtf8("dockSwatch")) self.swatchParam_ctl = NodeSwatchParam() self.swatchParam_ctl.setObjectName(_fromUtf8("swatchParam_ctl")) self.dockSwatch.setWidget(self.swatchParam_ctl) MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.dockSwatch) - self.actionRendererOptions = QtGui.QAction(MainWindow) + self.actionRendererOptions = QtModule.QAction(MainWindow) self.actionRendererOptions.setObjectName(_fromUtf8("actionRendererOptions")) - self.actionPreviewOptions = QtGui.QAction(MainWindow) + self.actionPreviewOptions = QtModule.QAction(MainWindow) self.actionPreviewOptions.setObjectName(_fromUtf8("actionPreviewOptions")) - self.actionNew = QtGui.QAction(MainWindow) + self.actionNew = QtModule.QAction(MainWindow) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/file_icons/resources/new.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.actionNew.setIcon(icon) self.actionNew.setToolTip(_fromUtf8("New Project")) self.actionNew.setStatusTip(_fromUtf8("Create a new project")) self.actionNew.setObjectName(_fromUtf8("actionNew")) - self.actionOpen = QtGui.QAction(MainWindow) + self.actionOpen = QtModule.QAction(MainWindow) icon1 = QtGui.QIcon() icon1.addPixmap(QtGui.QPixmap(_fromUtf8(":/file_icons/resources/open.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.actionOpen.setIcon(icon1) self.actionOpen.setObjectName(_fromUtf8("actionOpen")) - self.actionSave = QtGui.QAction(MainWindow) + self.actionSave = QtModule.QAction(MainWindow) icon2 = QtGui.QIcon() icon2.addPixmap(QtGui.QPixmap(_fromUtf8(":/file_icons/resources/save.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.actionSave.setIcon(icon2) self.actionSave.setObjectName(_fromUtf8("actionSave")) - self.actionExit = QtGui.QAction(MainWindow) + self.actionExit = QtModule.QAction(MainWindow) self.actionExit.setObjectName(_fromUtf8("actionExit")) - self.actionSaveAs = QtGui.QAction(MainWindow) + self.actionSaveAs = QtModule.QAction(MainWindow) self.actionSaveAs.setObjectName(_fromUtf8("actionSaveAs")) - self.actionImport = QtGui.QAction(MainWindow) + self.actionImport = QtModule.QAction(MainWindow) self.actionImport.setObjectName(_fromUtf8("actionImport")) - self.actionSaveSelected = QtGui.QAction(MainWindow) + self.actionSaveSelected = QtModule.QAction(MainWindow) self.actionSaveSelected.setEnabled(False) self.actionSaveSelected.setObjectName(_fromUtf8("actionSaveSelected")) - self.actionCopy = QtGui.QAction(MainWindow) + self.actionCopy = QtModule.QAction(MainWindow) self.actionCopy.setEnabled(False) icon3 = QtGui.QIcon() icon3.addPixmap(QtGui.QPixmap(_fromUtf8(":/edit_icons/resources/copy.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.actionCopy.setIcon(icon3) self.actionCopy.setObjectName(_fromUtf8("actionCopy")) - self.actionCut = QtGui.QAction(MainWindow) + self.actionCut = QtModule.QAction(MainWindow) self.actionCut.setEnabled(False) icon4 = QtGui.QIcon() icon4.addPixmap(QtGui.QPixmap(_fromUtf8(":/edit_icons/resources/editcut1.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.actionCut.setIcon(icon4) self.actionCut.setObjectName(_fromUtf8("actionCut")) - self.actionPaste = QtGui.QAction(MainWindow) + self.actionPaste = QtModule.QAction(MainWindow) self.actionPaste.setEnabled(False) icon5 = QtGui.QIcon() icon5.addPixmap(QtGui.QPixmap(_fromUtf8(":/edit_icons/resources/paste.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.actionPaste.setIcon(icon5) self.actionPaste.setObjectName(_fromUtf8("actionPaste")) - self.actionUndo = QtGui.QAction(MainWindow) + self.actionUndo = QtModule.QAction(MainWindow) self.actionUndo.setEnabled(False) icon6 = QtGui.QIcon() icon6.addPixmap(QtGui.QPixmap(_fromUtf8(":/edit_icons/resources/undo.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.actionUndo.setIcon(icon6) self.actionUndo.setObjectName(_fromUtf8("actionUndo")) - self.actionRedo = QtGui.QAction(MainWindow) + self.actionRedo = QtModule.QAction(MainWindow) self.actionRedo.setEnabled(False) icon7 = QtGui.QIcon() icon7.addPixmap(QtGui.QPixmap(_fromUtf8(":/edit_icons/resources/redo.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.actionRedo.setIcon(icon7) self.actionRedo.setObjectName(_fromUtf8("actionRedo")) - self.actionEditNode = QtGui.QAction(MainWindow) + self.actionEditNode = QtModule.QAction(MainWindow) self.actionEditNode.setEnabled(True) self.actionEditNode.setObjectName(_fromUtf8("actionEditNode")) - self.actionRenderPreview = QtGui.QAction(MainWindow) + self.actionRenderPreview = QtModule.QAction(MainWindow) self.actionRenderPreview.setEnabled(True) self.actionRenderPreview.setObjectName(_fromUtf8("actionRenderPreview")) - self.actionShowNodes = QtGui.QAction(MainWindow) + self.actionShowNodes = QtModule.QAction(MainWindow) self.actionShowNodes.setCheckable(True) self.actionShowNodes.setChecked(True) self.actionShowNodes.setObjectName(_fromUtf8("actionShowNodes")) - self.actionShowParameters = QtGui.QAction(MainWindow) + self.actionShowParameters = QtModule.QAction(MainWindow) self.actionShowParameters.setCheckable(True) self.actionShowParameters.setChecked(True) self.actionShowParameters.setObjectName(_fromUtf8("actionShowParameters")) - self.actionShowGrid = QtGui.QAction(MainWindow) + self.actionShowGrid = QtModule.QAction(MainWindow) self.actionShowGrid.setCheckable(True) icon8 = QtGui.QIcon() icon8.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/grid_off.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) icon8.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/grid_on.png")), QtGui.QIcon.Normal, QtGui.QIcon.On) self.actionShowGrid.setIcon(icon8) self.actionShowGrid.setObjectName(_fromUtf8("actionShowGrid")) - self.actionAbout = QtGui.QAction(MainWindow) + self.actionAbout = QtModule.QAction(MainWindow) self.actionAbout.setObjectName(_fromUtf8("actionAbout")) - self.actionHelp = QtGui.QAction(MainWindow) + self.actionHelp = QtModule.QAction(MainWindow) self.actionHelp.setObjectName(_fromUtf8("actionHelp")) - self.actionShowToolbar = QtGui.QAction(MainWindow) + self.actionShowToolbar = QtModule.QAction(MainWindow) self.actionShowToolbar.setCheckable(True) self.actionShowToolbar.setChecked(True) self.actionShowToolbar.setObjectName(_fromUtf8("actionShowToolbar")) - self.actionShowPreview = QtGui.QAction(MainWindow) + self.actionShowPreview = QtModule.QAction(MainWindow) self.actionShowPreview.setCheckable(True) self.actionShowPreview.setChecked(True) self.actionShowPreview.setObjectName(_fromUtf8("actionShowPreview")) - self.actionDelete = QtGui.QAction(MainWindow) + self.actionDelete = QtModule.QAction(MainWindow) icon9 = QtGui.QIcon() icon9.addPixmap(QtGui.QPixmap(_fromUtf8(":/edit_icons/resources/delete.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.actionDelete.setIcon(icon9) self.actionDelete.setObjectName(_fromUtf8("actionDelete")) - self.actionProjectSetup = QtGui.QAction(MainWindow) + self.actionProjectSetup = QtModule.QAction(MainWindow) self.actionProjectSetup.setObjectName(_fromUtf8("actionProjectSetup")) - self.actionSettings = QtGui.QAction(MainWindow) + self.actionSettings = QtModule.QAction(MainWindow) self.actionSettings.setObjectName(_fromUtf8("actionSettings")) - self.actionReverseFlow = QtGui.QAction(MainWindow) + self.actionReverseFlow = QtModule.QAction(MainWindow) self.actionReverseFlow.setCheckable(True) self.actionReverseFlow.setEnabled(False) icon10 = QtGui.QIcon() @@ -260,63 +266,63 @@ def setupUi(self, MainWindow): self.actionReverseFlow.setIcon(icon10) self.actionReverseFlow.setVisible(False) self.actionReverseFlow.setObjectName(_fromUtf8("actionReverseFlow")) - self.actionStraightLinks = QtGui.QAction(MainWindow) + self.actionStraightLinks = QtModule.QAction(MainWindow) self.actionStraightLinks.setCheckable(True) icon11 = QtGui.QIcon() icon11.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/straight_off.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) icon11.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/straight_on.png")), QtGui.QIcon.Normal, QtGui.QIcon.On) self.actionStraightLinks.setIcon(icon11) self.actionStraightLinks.setObjectName(_fromUtf8("actionStraightLinks")) - self.actionSnapGrid = QtGui.QAction(MainWindow) + self.actionSnapGrid = QtModule.QAction(MainWindow) self.actionSnapGrid.setCheckable(True) icon12 = QtGui.QIcon() icon12.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/snap_off.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) icon12.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/snap_on.png")), QtGui.QIcon.Normal, QtGui.QIcon.On) self.actionSnapGrid.setIcon(icon12) self.actionSnapGrid.setObjectName(_fromUtf8("actionSnapGrid")) - self.actionFitAll = QtGui.QAction(MainWindow) + self.actionFitAll = QtModule.QAction(MainWindow) icon13 = QtGui.QIcon() icon13.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/fit_all.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.actionFitAll.setIcon(icon13) self.actionFitAll.setVisible(True) self.actionFitAll.setObjectName(_fromUtf8("actionFitAll")) - self.actionFitSelected = QtGui.QAction(MainWindow) + self.actionFitSelected = QtModule.QAction(MainWindow) icon14 = QtGui.QIcon() icon14.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/fit_selected.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.actionFitSelected.setIcon(icon14) self.actionFitSelected.setVisible(True) self.actionFitSelected.setObjectName(_fromUtf8("actionFitSelected")) - self.actionZoomReset = QtGui.QAction(MainWindow) + self.actionZoomReset = QtModule.QAction(MainWindow) icon15 = QtGui.QIcon() icon15.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/zoom_reset.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.actionZoomReset.setIcon(icon15) self.actionZoomReset.setObjectName(_fromUtf8("actionZoomReset")) - self.actionNewParamView = QtGui.QAction(MainWindow) + self.actionNewParamView = QtModule.QAction(MainWindow) self.actionNewParamView.setObjectName(_fromUtf8("actionNewParamView")) - self.actionNewImageView = QtGui.QAction(MainWindow) + self.actionNewImageView = QtModule.QAction(MainWindow) self.actionNewImageView.setObjectName(_fromUtf8("actionNewImageView")) - self.actionDuplicate = QtGui.QAction(MainWindow) + self.actionDuplicate = QtModule.QAction(MainWindow) self.actionDuplicate.setObjectName(_fromUtf8("actionDuplicate")) - self.actionDuplicateWithLinks = QtGui.QAction(MainWindow) + self.actionDuplicateWithLinks = QtModule.QAction(MainWindow) self.actionDuplicateWithLinks.setObjectName(_fromUtf8("actionDuplicateWithLinks")) - self.actionSelectAll = QtGui.QAction(MainWindow) + self.actionSelectAll = QtModule.QAction(MainWindow) self.actionSelectAll.setObjectName(_fromUtf8("actionSelectAll")) - self.actionSelectBelow = QtGui.QAction(MainWindow) + self.actionSelectBelow = QtModule.QAction(MainWindow) self.actionSelectBelow.setObjectName(_fromUtf8("actionSelectBelow")) - self.actionSelectAbove = QtGui.QAction(MainWindow) + self.actionSelectAbove = QtModule.QAction(MainWindow) self.actionSelectAbove.setObjectName(_fromUtf8("actionSelectAbove")) - self.actionExportShader = QtGui.QAction(MainWindow) + self.actionExportShader = QtModule.QAction(MainWindow) self.actionExportShader.setObjectName(_fromUtf8("actionExportShader")) - self.actionShowSwatch = QtGui.QAction(MainWindow) + self.actionShowSwatch = QtModule.QAction(MainWindow) self.actionShowSwatch.setObjectName(_fromUtf8("actionShowSwatch")) - self.actionHideSwatch = QtGui.QAction(MainWindow) + self.actionHideSwatch = QtModule.QAction(MainWindow) self.actionHideSwatch.setObjectName(_fromUtf8("actionHideSwatch")) - self.actionHelpMode = QtGui.QAction(MainWindow) + self.actionHelpMode = QtModule.QAction(MainWindow) self.actionHelpMode.setCheckable(True) self.actionHelpMode.setObjectName(_fromUtf8("actionHelpMode")) - self.actionViewComputedCode = QtGui.QAction(MainWindow) + self.actionViewComputedCode = QtModule.QAction(MainWindow) self.actionViewComputedCode.setObjectName(_fromUtf8("actionViewComputedCode")) - self.actionCompileShader = QtGui.QAction(MainWindow) + self.actionCompileShader = QtModule.QAction(MainWindow) self.actionCompileShader.setObjectName(_fromUtf8("actionCompileShader")) self.menuRecent_Projects.addSeparator() self.menuRecent_Networks.addSeparator() @@ -403,41 +409,42 @@ def setupUi(self, MainWindow): self.retranslateUi(MainWindow) self.tabs.setCurrentIndex(0) - QtCore.QObject.connect(self.actionExit, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.close) - QtCore.QObject.connect(self.actionProjectSetup, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onProjectSetup) - QtCore.QObject.connect(self.actionShowGrid, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), MainWindow.onShowGrid) - QtCore.QObject.connect(self.actionRendererOptions, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onRenderSettings) - QtCore.QObject.connect(self.actionSnapGrid, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), MainWindow.onSnapGrid) - QtCore.QObject.connect(self.actionReverseFlow, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), MainWindow.onReverseFlow) - QtCore.QObject.connect(self.actionStraightLinks, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), MainWindow.onStraightLinks) - QtCore.QObject.connect(self.actionDelete, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onDelete) - QtCore.QObject.connect(self.actionFitAll, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onFitAll) - QtCore.QObject.connect(self.actionFitSelected, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onFitSelected) - QtCore.QObject.connect(self.actionZoomReset, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onZoomReset) - QtCore.QObject.connect(self.actionNewParamView, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onNewParamView) - QtCore.QObject.connect(self.actionNew, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onNew) - QtCore.QObject.connect(self.actionSave, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSave) - QtCore.QObject.connect(self.actionSaveAs, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSaveAs) - QtCore.QObject.connect(self.actionOpen, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onOpen) - QtCore.QObject.connect(self.actionSettings, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSettingsSetup) - QtCore.QObject.connect(self.actionImport, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onImport) - QtCore.QObject.connect(self.actionDuplicate, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onDuplicate) - QtCore.QObject.connect(self.actionDuplicateWithLinks, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onDuplicateWithLinks) - QtCore.QObject.connect(self.actionCopy, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onCopy) - QtCore.QObject.connect(self.actionCut, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onCut) - QtCore.QObject.connect(self.actionSelectAll, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSelectAll) - QtCore.QObject.connect(self.actionPaste, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onPaste) - QtCore.QObject.connect(self.actionSelectAbove, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSelectAbove) - QtCore.QObject.connect(self.actionSelectBelow, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSelectBelow) - QtCore.QObject.connect(self.actionEditNode, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onEditNode) - QtCore.QObject.connect(self.actionExportShader, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onExportShader) - QtCore.QObject.connect(self.actionRenderPreview, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onRenderPreview) - QtCore.QObject.connect(self.actionShowSwatch, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onShowSwatch) - QtCore.QObject.connect(self.actionHideSwatch, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onHideSwatch) - QtCore.QObject.connect(self.actionSaveSelected, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSaveSelected) - QtCore.QObject.connect(self.actionViewComputedCode, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onViewComputedCode) - QtCore.QObject.connect(self.actionCompileShader, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onCompileShader) - QtCore.QMetaObject.connectSlotsByName(MainWindow) + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.connect(self.actionExit, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.close) + QtCore.QObject.connect(self.actionProjectSetup, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onProjectSetup) + QtCore.QObject.connect(self.actionShowGrid, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), MainWindow.onShowGrid) + QtCore.QObject.connect(self.actionRendererOptions, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onRenderSettings) + QtCore.QObject.connect(self.actionSnapGrid, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), MainWindow.onSnapGrid) + QtCore.QObject.connect(self.actionReverseFlow, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), MainWindow.onReverseFlow) + QtCore.QObject.connect(self.actionStraightLinks, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), MainWindow.onStraightLinks) + QtCore.QObject.connect(self.actionDelete, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onDelete) + QtCore.QObject.connect(self.actionFitAll, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onFitAll) + QtCore.QObject.connect(self.actionFitSelected, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onFitSelected) + QtCore.QObject.connect(self.actionZoomReset, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onZoomReset) + QtCore.QObject.connect(self.actionNewParamView, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onNewParamView) + QtCore.QObject.connect(self.actionNew, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onNew) + QtCore.QObject.connect(self.actionSave, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSave) + QtCore.QObject.connect(self.actionSaveAs, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSaveAs) + QtCore.QObject.connect(self.actionOpen, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onOpen) + QtCore.QObject.connect(self.actionSettings, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSettingsSetup) + QtCore.QObject.connect(self.actionImport, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onImport) + QtCore.QObject.connect(self.actionDuplicate, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onDuplicate) + QtCore.QObject.connect(self.actionDuplicateWithLinks, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onDuplicateWithLinks) + QtCore.QObject.connect(self.actionCopy, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onCopy) + QtCore.QObject.connect(self.actionCut, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onCut) + QtCore.QObject.connect(self.actionSelectAll, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSelectAll) + QtCore.QObject.connect(self.actionPaste, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onPaste) + QtCore.QObject.connect(self.actionSelectAbove, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSelectAbove) + QtCore.QObject.connect(self.actionSelectBelow, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSelectBelow) + QtCore.QObject.connect(self.actionEditNode, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onEditNode) + QtCore.QObject.connect(self.actionExportShader, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onExportShader) + QtCore.QObject.connect(self.actionRenderPreview, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onRenderPreview) + QtCore.QObject.connect(self.actionShowSwatch, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onShowSwatch) + QtCore.QObject.connect(self.actionHideSwatch, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onHideSwatch) + QtCore.QObject.connect(self.actionSaveSelected, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSaveSelected) + QtCore.QObject.connect(self.actionViewComputedCode, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onViewComputedCode) + QtCore.QObject.connect(self.actionCompileShader, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onCompileShader) + QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): MainWindow.setWindowTitle(_translate("MainWindow", "meShaderEd", None)) diff --git a/gui/ui_imageViewWidget.py b/gui/ui_imageViewWidget.py index 44ce82d..6eba972 100644 --- a/gui/ui_imageViewWidget.py +++ b/gui/ui_imageViewWidget.py @@ -7,74 +7,81 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + try: - _fromUtf8 = QtCore.QString.fromUtf8 + _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: - def _fromUtf8(s): - return s + def _fromUtf8(s): + return s try: - _encoding = QtGui.QApplication.UnicodeUTF8 - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig, _encoding) + _encoding = QtGui.QApplication.UnicodeUTF8 + def _translate(context, text, disambig): + return QtModule.QApplication.translate(context, text, disambig, _encoding) except AttributeError: - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig) + def _translate(context, text, disambig): + return QtModule.QApplication.translate(context, text, disambig) class Ui_imageViewWidget(object): - def setupUi(self, imageViewWidget): - imageViewWidget.setObjectName(_fromUtf8("imageViewWidget")) - imageViewWidget.resize(479, 334) - self.gridLayout = QtGui.QGridLayout(imageViewWidget) - self.gridLayout.setMargin(4) - self.gridLayout.setHorizontalSpacing(4) - self.gridLayout.setVerticalSpacing(2) - self.gridLayout.setObjectName(_fromUtf8("gridLayout")) - self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setSpacing(8) - self.horizontalLayout.setContentsMargins(0, -1, 0, -1) - self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) - self.label = QtGui.QLabel(imageViewWidget) - self.label.setObjectName(_fromUtf8("label")) - self.horizontalLayout.addWidget(self.label) - self.selector = QtGui.QComboBox(imageViewWidget) - self.selector.setMinimumSize(QtCore.QSize(120, 20)) - self.selector.setMaximumSize(QtCore.QSize(16777215, 20)) - self.selector.setFrame(True) - self.selector.setObjectName(_fromUtf8("selector")) - self.horizontalLayout.addWidget(self.selector) - self.btn_reset = QtGui.QToolButton(imageViewWidget) - self.btn_reset.setObjectName(_fromUtf8("btn_reset")) - self.horizontalLayout.addWidget(self.btn_reset) - spacerItem = QtGui.QSpacerItem(68, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout.addItem(spacerItem) - self.chk_auto = QtGui.QCheckBox(imageViewWidget) - self.chk_auto.setObjectName(_fromUtf8("chk_auto")) - self.horizontalLayout.addWidget(self.chk_auto) - self.btn_render = QtGui.QPushButton(imageViewWidget) - self.btn_render.setMaximumSize(QtCore.QSize(16777215, 20)) - self.btn_render.setObjectName(_fromUtf8("btn_render")) - self.horizontalLayout.addWidget(self.btn_render) - self.horizontalLayout.setStretch(3, 1) - self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1) - self.imageArea = ImageView(imageViewWidget) - self.imageArea.setObjectName(_fromUtf8("imageArea")) - self.gridLayout.addWidget(self.imageArea, 1, 0, 1, 1) - self.gridLayout.setRowStretch(1, 1) + def setupUi(self, imageViewWidget): + imageViewWidget.setObjectName(_fromUtf8("imageViewWidget")) + imageViewWidget.resize(479, 334) + self.gridLayout = QtModule.QGridLayout(imageViewWidget) + #self.gridLayout.setMargin(4) + self.gridLayout.setHorizontalSpacing(4) + self.gridLayout.setVerticalSpacing(2) + self.gridLayout.setObjectName(_fromUtf8("gridLayout")) + self.horizontalLayout = QtModule.QHBoxLayout() + self.horizontalLayout.setSpacing(8) + self.horizontalLayout.setContentsMargins(0, -1, 0, -1) + self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) + self.label = QtModule.QLabel(imageViewWidget) + self.label.setObjectName(_fromUtf8("label")) + self.horizontalLayout.addWidget(self.label) + self.selector = QtModule.QComboBox(imageViewWidget) + self.selector.setMinimumSize(QtCore.QSize(120, 20)) + self.selector.setMaximumSize(QtCore.QSize(16777215, 20)) + self.selector.setFrame(True) + self.selector.setObjectName(_fromUtf8("selector")) + self.horizontalLayout.addWidget(self.selector) + self.btn_reset = QtModule.QToolButton(imageViewWidget) + self.btn_reset.setObjectName(_fromUtf8("btn_reset")) + self.horizontalLayout.addWidget(self.btn_reset) + spacerItem = QtModule.QSpacerItem(68, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) + self.horizontalLayout.addItem(spacerItem) + self.chk_auto = QtModule.QCheckBox(imageViewWidget) + self.chk_auto.setObjectName(_fromUtf8("chk_auto")) + self.horizontalLayout.addWidget(self.chk_auto) + self.btn_render = QtModule.QPushButton(imageViewWidget) + self.btn_render.setMaximumSize(QtCore.QSize(16777215, 20)) + self.btn_render.setObjectName(_fromUtf8("btn_render")) + self.horizontalLayout.addWidget(self.btn_render) + self.horizontalLayout.setStretch(3, 1) + self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1) + self.imageArea = ImageView(imageViewWidget) + self.imageArea.setObjectName(_fromUtf8("imageArea")) + self.gridLayout.addWidget(self.imageArea, 1, 0, 1, 1) + self.gridLayout.setRowStretch(1, 1) - self.retranslateUi(imageViewWidget) - QtCore.QObject.connect(self.btn_render, QtCore.SIGNAL(_fromUtf8("clicked()")), imageViewWidget.updateViewer) - QtCore.QObject.connect(self.btn_reset, QtCore.SIGNAL(_fromUtf8("clicked()")), self.imageArea.resetZoom) - QtCore.QMetaObject.connectSlotsByName(imageViewWidget) + self.retranslateUi(imageViewWidget) + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.connect(self.btn_render, QtCore.SIGNAL(_fromUtf8("clicked()")), imageViewWidget.updateViewer) + QtCore.QObject.connect(self.btn_reset, QtCore.SIGNAL(_fromUtf8("clicked()")), self.imageArea.resetZoom) + QtCore.QMetaObject.connectSlotsByName(imageViewWidget) - def retranslateUi(self, imageViewWidget): - imageViewWidget.setWindowTitle(_translate("imageViewWidget", "ImageView", None)) - self.label.setText(_translate("imageViewWidget", "Node", None)) - self.btn_reset.setToolTip(_translate("imageViewWidget", "Reset zoom", None)) - self.btn_reset.setText(_translate("imageViewWidget", "1:1", None)) - self.chk_auto.setText(_translate("imageViewWidget", "auto", None)) - self.btn_render.setText(_translate("imageViewWidget", "Update", None)) + def retranslateUi(self, imageViewWidget): + imageViewWidget.setWindowTitle(_translate("imageViewWidget", "ImageView", None)) + self.label.setText(_translate("imageViewWidget", "Node", None)) + self.btn_reset.setToolTip(_translate("imageViewWidget", "Reset zoom", None)) + self.btn_reset.setText(_translate("imageViewWidget", "1:1", None)) + self.chk_auto.setText(_translate("imageViewWidget", "auto", None)) + self.btn_render.setText(_translate("imageViewWidget", "Update", None)) from gfx.imageView import ImageView diff --git a/gui/ui_meRendererSetup.py b/gui/ui_meRendererSetup.py index a8b766e..b4a0cc6 100644 --- a/gui/ui_meRendererSetup.py +++ b/gui/ui_meRendererSetup.py @@ -7,7 +7,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui class Ui_meRendererSetup(object): def setupUi(self, meRendererSetup): diff --git a/gui/ui_nodeLibraryView.py b/gui/ui_nodeLibraryView.py index f214d34..6cda28f 100644 --- a/gui/ui_nodeLibraryView.py +++ b/gui/ui_nodeLibraryView.py @@ -7,45 +7,53 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets try: - _fromUtf8 = QtCore.QString.fromUtf8 + _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: - _fromUtf8 = lambda s: s + _fromUtf8 = lambda s: s class Ui_nodeLibraryView(object): - def setupUi(self, nodeLibraryView): - nodeLibraryView.setObjectName(_fromUtf8("nodeLibraryView")) - nodeLibraryView.resize(447, 443) - self.verticalLayout = QtGui.QVBoxLayout(nodeLibraryView) - self.verticalLayout.setSpacing(0) - self.verticalLayout.setContentsMargins(2, 2, 2, 0) - self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) - self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setSpacing(-1) - self.horizontalLayout.setContentsMargins(8, -1, 8, -1) - self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) - self.btn_reload = QtGui.QPushButton(nodeLibraryView) - self.btn_reload.setMinimumSize(QtCore.QSize(60, 20)) - self.btn_reload.setMaximumSize(QtCore.QSize(60, 20)) - self.btn_reload.setObjectName(_fromUtf8("btn_reload")) - self.horizontalLayout.addWidget(self.btn_reload) - spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout.addItem(spacerItem) - self.horizontalLayout.setStretch(1, 1) - self.verticalLayout.addLayout(self.horizontalLayout) - self.nodeList = NodeList(nodeLibraryView) - self.nodeList.setObjectName(_fromUtf8("nodeList")) - self.verticalLayout.addWidget(self.nodeList) - self.verticalLayout.setStretch(1, 1) - - self.retranslateUi(nodeLibraryView) - QtCore.QObject.connect(self.btn_reload, QtCore.SIGNAL(_fromUtf8("clicked()")), nodeLibraryView.onReload) - QtCore.QMetaObject.connectSlotsByName(nodeLibraryView) - - def retranslateUi(self, nodeLibraryView): - nodeLibraryView.setWindowTitle(QtGui.QApplication.translate("nodeLibraryView", "Form", None, QtGui.QApplication.UnicodeUTF8)) - self.btn_reload.setText(QtGui.QApplication.translate("nodeLibraryView", "Reload", None, QtGui.QApplication.UnicodeUTF8)) + def setupUi(self, nodeLibraryView): + nodeLibraryView.setObjectName(_fromUtf8("nodeLibraryView")) + nodeLibraryView.resize(447, 443) + self.verticalLayout = QtModule.QVBoxLayout(nodeLibraryView) + self.verticalLayout.setSpacing(0) + self.verticalLayout.setContentsMargins(2, 2, 2, 0) + self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + self.horizontalLayout = QtModule.QHBoxLayout() + self.horizontalLayout.setSpacing(-1) + self.horizontalLayout.setContentsMargins(8, -1, 8, -1) + self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) + self.btn_reload = QtModule.QPushButton(nodeLibraryView) + self.btn_reload.setMinimumSize(QtCore.QSize(60, 20)) + self.btn_reload.setMaximumSize(QtCore.QSize(60, 20)) + self.btn_reload.setObjectName(_fromUtf8("btn_reload")) + self.horizontalLayout.addWidget(self.btn_reload) + spacerItem = QtModule.QSpacerItem(40, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) + self.horizontalLayout.addItem(spacerItem) + self.horizontalLayout.setStretch(1, 1) + self.verticalLayout.addLayout(self.horizontalLayout) + self.nodeList = NodeList(nodeLibraryView) + self.nodeList.setObjectName(_fromUtf8("nodeList")) + self.verticalLayout.addWidget(self.nodeList) + self.verticalLayout.setStretch(1, 1) + + self.retranslateUi(nodeLibraryView) + + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.connect(self.btn_reload, QtCore.SIGNAL(_fromUtf8("clicked()")), nodeLibraryView.onReload) + QtCore.QMetaObject.connectSlotsByName(nodeLibraryView) + + def retranslateUi(self, nodeLibraryView): + nodeLibraryView.setWindowTitle(QtModule.QApplication.translate("nodeLibraryView", "Form", None)) + self.btn_reload.setText(QtModule.QApplication.translate("nodeLibraryView", "Reload", None)) from nodeList import NodeList diff --git a/gui/ui_nodeList.py b/gui/ui_nodeList.py index fbd5198..11cba6b 100644 --- a/gui/ui_nodeList.py +++ b/gui/ui_nodeList.py @@ -7,62 +7,68 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets try: - _fromUtf8 = QtCore.QString.fromUtf8 + _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: - _fromUtf8 = lambda s: s + _fromUtf8 = lambda s: s class Ui_nodeList(object): - def setupUi(self, nodeList): - nodeList.setObjectName(_fromUtf8("nodeList")) - nodeList.resize(374, 699) - self.verticalLayout_2 = QtGui.QVBoxLayout(nodeList) - self.verticalLayout_2.setSpacing(2) - self.verticalLayout_2.setMargin(2) - self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) - self.splitter = QtGui.QSplitter(nodeList) - self.splitter.setOrientation(QtCore.Qt.Vertical) - self.splitter.setOpaqueResize(True) - self.splitter.setChildrenCollapsible(True) - self.splitter.setObjectName(_fromUtf8("splitter")) - self.treeView = NodeTreeView(self.splitter) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) - sizePolicy.setHorizontalStretch(1) - sizePolicy.setVerticalStretch(1) - sizePolicy.setHeightForWidth(self.treeView.sizePolicy().hasHeightForWidth()) - self.treeView.setSizePolicy(sizePolicy) - self.treeView.setSortingEnabled(False) - self.treeView.setObjectName(_fromUtf8("treeView")) - self.treeView.header().setVisible(False) - self.groupBox = QtGui.QGroupBox(self.splitter) - self.groupBox.setAutoFillBackground(True) - self.groupBox.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) - self.groupBox.setFlat(False) - self.groupBox.setObjectName(_fromUtf8("groupBox")) - self.verticalLayout = QtGui.QVBoxLayout(self.groupBox) - self.verticalLayout.setSpacing(0) - self.verticalLayout.setMargin(2) - self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) - self.infoText = QtGui.QTextEdit(self.groupBox) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) - sizePolicy.setHorizontalStretch(1) - sizePolicy.setVerticalStretch(1) - sizePolicy.setHeightForWidth(self.infoText.sizePolicy().hasHeightForWidth()) - self.infoText.setSizePolicy(sizePolicy) - self.infoText.setFrameShape(QtGui.QFrame.HLine) - self.infoText.setFrameShadow(QtGui.QFrame.Raised) - self.infoText.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) - self.infoText.setObjectName(_fromUtf8("infoText")) - self.verticalLayout.addWidget(self.infoText) - self.verticalLayout_2.addWidget(self.splitter) + def setupUi(self, nodeList): + nodeList.setObjectName(_fromUtf8("nodeList")) + nodeList.resize(374, 699) + self.verticalLayout_2 = QtModule.QVBoxLayout(nodeList) + self.verticalLayout_2.setSpacing(2) + #self.verticalLayout_2.setMargin(2) + self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) + self.splitter = QtModule.QSplitter(nodeList) + self.splitter.setOrientation(QtCore.Qt.Vertical) + self.splitter.setOpaqueResize(True) + self.splitter.setChildrenCollapsible(True) + self.splitter.setObjectName(_fromUtf8("splitter")) + self.treeView = NodeTreeView(self.splitter) + sizePolicy = QtModule.QSizePolicy(QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Expanding) + sizePolicy.setHorizontalStretch(1) + sizePolicy.setVerticalStretch(1) + sizePolicy.setHeightForWidth(self.treeView.sizePolicy().hasHeightForWidth()) + self.treeView.setSizePolicy(sizePolicy) + self.treeView.setSortingEnabled(False) + self.treeView.setObjectName(_fromUtf8("treeView")) + self.treeView.header().setVisible(False) + self.groupBox = QtModule.QGroupBox(self.splitter) + self.groupBox.setAutoFillBackground(True) + self.groupBox.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) + self.groupBox.setFlat(False) + self.groupBox.setObjectName(_fromUtf8("groupBox")) + self.verticalLayout = QtModule.QVBoxLayout(self.groupBox) + self.verticalLayout.setSpacing(0) + #self.verticalLayout.setMargin(2) + self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + self.infoText = QtModule.QTextEdit(self.groupBox) + sizePolicy = QtModule.QSizePolicy(QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Expanding) + sizePolicy.setHorizontalStretch(1) + sizePolicy.setVerticalStretch(1) + sizePolicy.setHeightForWidth(self.infoText.sizePolicy().hasHeightForWidth()) + self.infoText.setSizePolicy(sizePolicy) + self.infoText.setFrameShape(QtModule.QFrame.HLine) + self.infoText.setFrameShadow(QtModule.QFrame.Raised) + self.infoText.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) + self.infoText.setObjectName(_fromUtf8("infoText")) + self.verticalLayout.addWidget(self.infoText) + self.verticalLayout_2.addWidget(self.splitter) - self.retranslateUi(nodeList) - QtCore.QMetaObject.connectSlotsByName(nodeList) + self.retranslateUi(nodeList) + QtCore.QMetaObject.connectSlotsByName(nodeList) - def retranslateUi(self, nodeList): - nodeList.setWindowTitle(QtGui.QApplication.translate("nodeList", "Form", None, QtGui.QApplication.UnicodeUTF8)) - self.groupBox.setTitle(QtGui.QApplication.translate("nodeList", "Description", None, QtGui.QApplication.UnicodeUTF8)) + def retranslateUi(self, nodeList): + nodeList.setWindowTitle(QtModule.QApplication.translate("nodeList", "Form", None)) + self.groupBox.setTitle(QtModule.QApplication.translate("nodeList", "Description", None)) from nodeTreeView import NodeTreeView diff --git a/gui/ui_nodeParam.py b/gui/ui_nodeParam.py index 37e0c14..7765c38 100644 --- a/gui/ui_nodeParam.py +++ b/gui/ui_nodeParam.py @@ -7,7 +7,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 diff --git a/gui/ui_nodeSwatchParam.py b/gui/ui_nodeSwatchParam.py index 81ab815..99407bd 100644 --- a/gui/ui_nodeSwatchParam.py +++ b/gui/ui_nodeSwatchParam.py @@ -7,94 +7,100 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets try: - _fromUtf8 = QtCore.QString.fromUtf8 + _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: - _fromUtf8 = lambda s: s + _fromUtf8 = lambda s: s class Ui_NodeSwatchParam(object): - def setupUi(self, NodeSwatchParam): - NodeSwatchParam.setObjectName(_fromUtf8("NodeSwatchParam")) - NodeSwatchParam.resize(408, 309) - self.verticalLayout = QtGui.QVBoxLayout(NodeSwatchParam) - self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) - self.hl_type = QtGui.QHBoxLayout() - self.hl_type.setObjectName(_fromUtf8("hl_type")) - self.label = QtGui.QLabel(NodeSwatchParam) - self.label.setMinimumSize(QtCore.QSize(80, 0)) - self.label.setObjectName(_fromUtf8("label")) - self.hl_type.addWidget(self.label) - self.type_selector = QtGui.QComboBox(NodeSwatchParam) - self.type_selector.setEnabled(False) - self.type_selector.setObjectName(_fromUtf8("type_selector")) - self.hl_type.addWidget(self.type_selector) - spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.hl_type.addItem(spacerItem) - self.hl_type.setStretch(2, 1) - self.verticalLayout.addLayout(self.hl_type) - self.hl_param = QtGui.QHBoxLayout() - self.hl_param.setObjectName(_fromUtf8("hl_param")) - self.label_2 = QtGui.QLabel(NodeSwatchParam) - self.label_2.setMinimumSize(QtCore.QSize(80, 0)) - self.label_2.setObjectName(_fromUtf8("label_2")) - self.hl_param.addWidget(self.label_2) - self.param_selector = QtGui.QComboBox(NodeSwatchParam) - self.param_selector.setObjectName(_fromUtf8("param_selector")) - self.hl_param.addWidget(self.param_selector) - spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.hl_param.addItem(spacerItem1) - self.verticalLayout.addLayout(self.hl_param) - self.hl_shape = QtGui.QHBoxLayout() - self.hl_shape.setObjectName(_fromUtf8("hl_shape")) - self.label_3 = QtGui.QLabel(NodeSwatchParam) - self.label_3.setMinimumSize(QtCore.QSize(80, 0)) - self.label_3.setObjectName(_fromUtf8("label_3")) - self.hl_shape.addWidget(self.label_3) - self.shape_selector = QtGui.QComboBox(NodeSwatchParam) - self.shape_selector.setObjectName(_fromUtf8("shape_selector")) - self.hl_shape.addWidget(self.shape_selector) - spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.hl_shape.addItem(spacerItem2) - self.verticalLayout.addLayout(self.hl_shape) - self.hl_size = QtGui.QHBoxLayout() - self.hl_size.setObjectName(_fromUtf8("hl_size")) - self.label_4 = QtGui.QLabel(NodeSwatchParam) - self.label_4.setMinimumSize(QtCore.QSize(80, 0)) - self.label_4.setObjectName(_fromUtf8("label_4")) - self.hl_size.addWidget(self.label_4) - self.size_selector = QtGui.QComboBox(NodeSwatchParam) - self.size_selector.setObjectName(_fromUtf8("size_selector")) - self.hl_size.addWidget(self.size_selector) - spacerItem3 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.hl_size.addItem(spacerItem3) - self.verticalLayout.addLayout(self.hl_size) - self.hl_rate = QtGui.QHBoxLayout() - self.hl_rate.setObjectName(_fromUtf8("hl_rate")) - self.label_5 = QtGui.QLabel(NodeSwatchParam) - self.label_5.setMinimumSize(QtCore.QSize(80, 0)) - self.label_5.setObjectName(_fromUtf8("label_5")) - self.hl_rate.addWidget(self.label_5) - self.lineEdit = QtGui.QLineEdit(NodeSwatchParam) - self.lineEdit.setMinimumSize(QtCore.QSize(50, 0)) - self.lineEdit.setMaximumSize(QtCore.QSize(50, 16777215)) - self.lineEdit.setObjectName(_fromUtf8("lineEdit")) - self.hl_rate.addWidget(self.lineEdit) - spacerItem4 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.hl_rate.addItem(spacerItem4) - self.verticalLayout.addLayout(self.hl_rate) - spacerItem5 = QtGui.QSpacerItem(20, 148, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.verticalLayout.addItem(spacerItem5) + def setupUi(self, NodeSwatchParam): + NodeSwatchParam.setObjectName(_fromUtf8("NodeSwatchParam")) + NodeSwatchParam.resize(408, 309) + self.verticalLayout = QtModule.QVBoxLayout(NodeSwatchParam) + self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + self.hl_type = QtModule.QHBoxLayout() + self.hl_type.setObjectName(_fromUtf8("hl_type")) + self.label = QtModule.QLabel(NodeSwatchParam) + self.label.setMinimumSize(QtCore.QSize(80, 0)) + self.label.setObjectName(_fromUtf8("label")) + self.hl_type.addWidget(self.label) + self.type_selector = QtModule.QComboBox(NodeSwatchParam) + self.type_selector.setEnabled(False) + self.type_selector.setObjectName(_fromUtf8("type_selector")) + self.hl_type.addWidget(self.type_selector) + spacerItem = QtModule.QSpacerItem(40, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) + self.hl_type.addItem(spacerItem) + self.hl_type.setStretch(2, 1) + self.verticalLayout.addLayout(self.hl_type) + self.hl_param = QtModule.QHBoxLayout() + self.hl_param.setObjectName(_fromUtf8("hl_param")) + self.label_2 = QtModule.QLabel(NodeSwatchParam) + self.label_2.setMinimumSize(QtCore.QSize(80, 0)) + self.label_2.setObjectName(_fromUtf8("label_2")) + self.hl_param.addWidget(self.label_2) + self.param_selector = QtModule.QComboBox(NodeSwatchParam) + self.param_selector.setObjectName(_fromUtf8("param_selector")) + self.hl_param.addWidget(self.param_selector) + spacerItem1 = QtModule.QSpacerItem(40, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) + self.hl_param.addItem(spacerItem1) + self.verticalLayout.addLayout(self.hl_param) + self.hl_shape = QtModule.QHBoxLayout() + self.hl_shape.setObjectName(_fromUtf8("hl_shape")) + self.label_3 = QtModule.QLabel(NodeSwatchParam) + self.label_3.setMinimumSize(QtCore.QSize(80, 0)) + self.label_3.setObjectName(_fromUtf8("label_3")) + self.hl_shape.addWidget(self.label_3) + self.shape_selector = QtModule.QComboBox(NodeSwatchParam) + self.shape_selector.setObjectName(_fromUtf8("shape_selector")) + self.hl_shape.addWidget(self.shape_selector) + spacerItem2 = QtModule.QSpacerItem(40, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) + self.hl_shape.addItem(spacerItem2) + self.verticalLayout.addLayout(self.hl_shape) + self.hl_size = QtModule.QHBoxLayout() + self.hl_size.setObjectName(_fromUtf8("hl_size")) + self.label_4 = QtModule.QLabel(NodeSwatchParam) + self.label_4.setMinimumSize(QtCore.QSize(80, 0)) + self.label_4.setObjectName(_fromUtf8("label_4")) + self.hl_size.addWidget(self.label_4) + self.size_selector = QtModule.QComboBox(NodeSwatchParam) + self.size_selector.setObjectName(_fromUtf8("size_selector")) + self.hl_size.addWidget(self.size_selector) + spacerItem3 = QtModule.QSpacerItem(40, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) + self.hl_size.addItem(spacerItem3) + self.verticalLayout.addLayout(self.hl_size) + self.hl_rate = QtModule.QHBoxLayout() + self.hl_rate.setObjectName(_fromUtf8("hl_rate")) + self.label_5 = QtModule.QLabel(NodeSwatchParam) + self.label_5.setMinimumSize(QtCore.QSize(80, 0)) + self.label_5.setObjectName(_fromUtf8("label_5")) + self.hl_rate.addWidget(self.label_5) + self.lineEdit = QtModule.QLineEdit(NodeSwatchParam) + self.lineEdit.setMinimumSize(QtCore.QSize(50, 0)) + self.lineEdit.setMaximumSize(QtCore.QSize(50, 16777215)) + self.lineEdit.setObjectName(_fromUtf8("lineEdit")) + self.hl_rate.addWidget(self.lineEdit) + spacerItem4 = QtModule.QSpacerItem(40, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) + self.hl_rate.addItem(spacerItem4) + self.verticalLayout.addLayout(self.hl_rate) + spacerItem5 = QtModule.QSpacerItem(20, 148, QtModule.QSizePolicy.Minimum, QtModule.QSizePolicy.Expanding) + self.verticalLayout.addItem(spacerItem5) - self.retranslateUi(NodeSwatchParam) - QtCore.QMetaObject.connectSlotsByName(NodeSwatchParam) + self.retranslateUi(NodeSwatchParam) + QtCore.QMetaObject.connectSlotsByName(NodeSwatchParam) - def retranslateUi(self, NodeSwatchParam): - NodeSwatchParam.setWindowTitle(QtGui.QApplication.translate("NodeSwatchParam", "Form", None, QtGui.QApplication.UnicodeUTF8)) - self.label.setText(QtGui.QApplication.translate("NodeSwatchParam", "Type", None, QtGui.QApplication.UnicodeUTF8)) - self.label_2.setText(QtGui.QApplication.translate("NodeSwatchParam", "Parameter", None, QtGui.QApplication.UnicodeUTF8)) - self.label_3.setText(QtGui.QApplication.translate("NodeSwatchParam", "Shape", None, QtGui.QApplication.UnicodeUTF8)) - self.label_4.setText(QtGui.QApplication.translate("NodeSwatchParam", "Size", None, QtGui.QApplication.UnicodeUTF8)) - self.label_5.setText(QtGui.QApplication.translate("NodeSwatchParam", "Shading Rate", None, QtGui.QApplication.UnicodeUTF8)) + def retranslateUi(self, NodeSwatchParam): + NodeSwatchParam.setWindowTitle(QtModule.QApplication.translate("NodeSwatchParam", "Form", None)) + self.label.setText(QtModule.QApplication.translate("NodeSwatchParam", "Type", None)) + self.label_2.setText(QtModule.QApplication.translate("NodeSwatchParam", "Parameter", None)) + self.label_3.setText(QtModule.QApplication.translate("NodeSwatchParam", "Shape", None)) + self.label_4.setText(QtModule.QApplication.translate("NodeSwatchParam", "Size", None)) + self.label_5.setText(QtModule.QApplication.translate("NodeSwatchParam", "Shading Rate", None)) diff --git a/gui/ui_projectSetup.py b/gui/ui_projectSetup.py index b9d92ef..c43f615 100644 --- a/gui/ui_projectSetup.py +++ b/gui/ui_projectSetup.py @@ -7,7 +7,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 diff --git a/gui/ui_settingsSetup.py b/gui/ui_settingsSetup.py index 2c1fce3..cf8eeb6 100644 --- a/gui/ui_settingsSetup.py +++ b/gui/ui_settingsSetup.py @@ -7,7 +7,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 diff --git a/gui/ui_viewComputedCodeDialog.py b/gui/ui_viewComputedCodeDialog.py index 9dc1174..b4b3af3 100644 --- a/gui/ui_viewComputedCodeDialog.py +++ b/gui/ui_viewComputedCodeDialog.py @@ -7,7 +7,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 diff --git a/gui/ui_workArea.py b/gui/ui_workArea.py index 1c365bc..6997171 100644 --- a/gui/ui_workArea.py +++ b/gui/ui_workArea.py @@ -7,7 +7,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore, QtGui +from core.mePyQt import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 diff --git a/meShaderEd.py b/meShaderEd.py index 19af21e..ab0d480 100644 --- a/meShaderEd.py +++ b/meShaderEd.py @@ -9,20 +9,20 @@ Initial code and data structure was based on ShaderLink of Libero Spagnolini (Libe) - http://libe.ocracy.org/shaderlink.html - http://code.google.com/p/shaderlink/ + http://libe.ocracy.org/shaderlink.html + http://code.google.com/p/shaderlink/ And idea of open source RSL tool belongs to Alexei Puzikov (Kidd) - http://code.google.com/p/shaderman/ + http://code.google.com/p/shaderman/ The RenderMan Shader Editor """ import sys import os -#import ntpath -from PyQt4 import QtCore, QtGui + +from core.mePyQt import QtCore, QtGui from core.meCommon import * from core.nodeLibrary import NodeLibrary @@ -31,178 +31,203 @@ from global_vars import app_global_vars, app_colors, DEBUG_MODE root = normPath ( sys.path [0] ) -version = '0.3.4b' +branchName = 'QT5' +version = '0.3.4b ' + branchName app_settings = QtCore.QSettings ( QtCore.QSettings.IniFormat, - QtCore.QSettings.UserScope, - 'mesh', 'meShaderEd' ) + QtCore.QSettings.UserScope, + 'mesh', 'meShaderEd_' + branchName ) # # setDefaultValue # def setDefaultValue ( key, def_value ) : - if not app_settings.contains ( key ): - app_settings.setValue ( key, def_value ) - - value = app_settings.value ( key ) - if value.toString () == 'true' : value = True - elif value.toString () == 'false' : value = False - else : - if isinstance ( def_value, QtGui.QColor ) : - value = QtGui.QColor ( value ) - else : - value = str ( value.toString () ) - return value + if not app_settings.contains ( key ): + app_settings.setValue ( key, def_value ) + value = app_settings.value ( key ) + if QtCore.QT_VERSION < 50000 : + if value.toString () == 'true' : value = True + elif value.toString () == 'false' : value = False + else : + if isinstance ( def_value, QtGui.QColor ) : + value = QtGui.QColor ( value ) + else : + value = str ( value.toString () ) + else : + if value == 'true' : value = True + elif value == 'false' : value = False + else : + if isinstance ( def_value, QtGui.QColor ) : + value = QtGui.QColor ( value ) + else : + value = str ( value ) + return value # # getDefaultValue # def getDefaultValue ( settings, group, key, def_value = None ) : - if group != '' : settings.beginGroup ( group ) - value = settings.value ( key ) - if group != '' : settings.endGroup ( ) - if value.toString () == 'true' : value = True - elif value.toString () == 'false' : value = False - else : - if def_value is not None and isinstance ( def_value, QtGui.QColor ) : - value = QtGui.QColor ( value ) - else : - value = str ( value.toString () ) - return value - + if group != '' : settings.beginGroup ( group ) + value = settings.value ( key ) + if group != '' : settings.endGroup ( ) + if QtCore.QT_VERSION < 50000 : + if value.toString () == 'true' : value = True + elif value.toString () == 'false' : value = False + else : + if def_value is not None and isinstance ( def_value, QtGui.QColor ) : + value = QtGui.QColor ( value ) + else : + value = str ( value.toString () ) + else : + if value == 'true' : value = True + elif value == 'false' : value = False + else : + if def_value is not None and isinstance ( def_value, QtGui.QColor ) : + value = QtGui.QColor ( value ) + else : + value = str ( value ) + return value + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets # # main routine # def main () : - #global root - app = QtGui.QApplication ( sys.argv ) - - app_settings.setValue ( 'version', version ) - app_settings.setValue ( 'root', normPath ( root ) ) - project_filename = setDefaultValue ( 'project_filename', 'meshadered.prj' ) - - temp_dir = setDefaultValue ( 'temp', normPath ( os.path.join ( root, 'tmp' ) ) ) - - project_dir = setDefaultValue ( 'project', normPath ( os.path.join ( root, 'samples' ) ) ) - project_shaders = setDefaultValue ( 'project_shaders', normPath ( os.path.join ( project_dir,'shaders' ) ) ) - project_textures = setDefaultValue ( 'project_textures',normPath ( os.path.join ( project_dir,'textures' ) ) ) - - shader_networks_dir = setDefaultValue ( 'shader_networks', normPath ( os.path.join ( project_shaders,'shn' ) ) ) - shader_sources_dir = setDefaultValue ( 'shader_sources', normPath ( os.path.join ( project_shaders,'src' ) ) ) - shader_output_dir = project_shaders - - lib_dir = setDefaultValue ( 'lib', normPath ( os.path.join ( root, 'lib' ) ) ) - node_dir = setDefaultValue ( 'nodes', normPath ( os.path.join ( lib_dir, 'nodes' ) ) ) - texture_dir = setDefaultValue ( 'texture', normPath ( os.path.join ( lib_dir, 'textures' ) ) ) - shaders_dir = setDefaultValue ( 'shaders', normPath ( os.path.join ( lib_dir, 'shaders' ) ) ) - archive_dir = setDefaultValue ( 'archive', normPath ( os.path.join ( lib_dir, 'archives' ) ) ) - - include_dir = setDefaultValue ( 'include', normPath ( os.path.join ( root, 'include' ) ) ) - - createMissingDirs ( [ temp_dir, lib_dir, project_dir, project_shaders, project_textures ] ) - createMissingDirs ( [ shader_networks_dir, shader_sources_dir ] ) - createMissingDirs ( [ node_dir, texture_dir, shaders_dir, archive_dir ] ) # include_dir supposed to be a list - # - # Recent projects/networks - # - setDefaultValue ( 'recent_projects_max', 10 ) - setDefaultValue ( 'recent_networks_max', 10 ) - # - # setup globals - # - app_global_vars [ 'version' ] = app_settings.value( 'version' ).toString() - app_global_vars [ 'RootPath' ] = root - app_global_vars [ 'TempPath' ] = temp_dir - app_global_vars [ 'ProjectPath' ] = project_dir - app_global_vars [ 'ProjectShaders' ] = project_shaders - app_global_vars [ 'ProjectTextures' ] = project_textures - - app_global_vars [ 'ProjectNetworks' ] = shader_networks_dir - app_global_vars [ 'ProjectSources' ] = shader_sources_dir - - app_global_vars [ 'LibPath' ] = lib_dir - app_global_vars [ 'NodesPath' ] = node_dir - app_global_vars [ 'TexturePath' ] = texture_dir - app_global_vars [ 'ShaderPath' ] = shaders_dir - app_global_vars [ 'IncludePath' ] = include_dir - - app_global_vars [ 'TextureSearchPath' ] = sanitizeSearchPath ( texture_dir ) - app_global_vars [ 'ShaderSearchPath' ] = sanitizeSearchPath ( shaders_dir ) - app_global_vars [ 'ArchiveSearchPath' ] = sanitizeSearchPath ( archive_dir ) - - app_global_vars [ 'ProjectSearchPath' ] = sanitizeSearchPath ( project_dir ) - app_global_vars [ 'ProjectSearchShaders' ] = sanitizeSearchPath ( project_shaders ) - app_global_vars [ 'ProjectSearchTextures' ] = sanitizeSearchPath ( project_textures ) - - # - # Setup current renderer preset - # - defRenderer = setDefaultValue ( 'defRenderer', '3Delight' ) - preset = meRendererPreset ( os.path.join ( root, 'renderers.xml' ), defRenderer ) - app_global_vars [ 'RendererPreset' ] = preset - app_global_vars [ 'RendererName' ] = preset.currentPreset.RendererName - app_global_vars [ 'RendererFlags' ] = preset.currentPreset.RendererFlags - app_global_vars [ 'ShaderCompiler' ] = preset.currentPreset.ShaderCompiler - app_global_vars [ 'ShaderDefines' ] = preset.currentPreset.ShaderDefines - app_global_vars [ 'ShaderInfo' ] = preset.currentPreset.ShaderInfo - app_global_vars [ 'SLO' ] = preset.currentPreset.ShaderExt - app_global_vars [ 'TextureMake' ] = preset.currentPreset.TextureMake - app_global_vars [ 'TextureInfo' ] = preset.currentPreset.TextureInfo - app_global_vars [ 'TextureViewer' ] = preset.currentPreset.TextureViewer - app_global_vars [ 'TEX' ] = preset.currentPreset.TextureExt - - createDefaultProject ( app_settings, True ) # check_if_exist = True - - if DEBUG_MODE : - print 'TextureSearchPath = %s' % app_global_vars [ 'TextureSearchPath' ] - print 'ShaderSearchPath = %s' % app_global_vars [ 'ShaderSearchPath' ] - print 'ArchiveSearchPath = %s' % app_global_vars [ 'ArchiveSearchPath' ] - print 'Renderer = %s' % app_global_vars [ 'RendererName' ] - - #app_global_vars[ 'RibPath' ] = '' - #app_global_vars[ 'DisplayPath' ] = '' - app_settings.beginGroup ( 'WorkArea' ) - #grid_enabled = bool( setDefaultValue( 'grid_enabled', True ).toString() ) - grid_enabled = setDefaultValue ( 'grid_enabled', True ) - grid_size = int ( setDefaultValue ( 'grid_size', 10 ) ) - grid_snap = setDefaultValue ( 'grid_snap', True ) - reverse_flow = setDefaultValue ( 'reverse_flow', False ) - straight_links = setDefaultValue ( 'straight_links', True ) - - app_settings.endGroup () - - app_settings.beginGroup ( 'Colors' ) - app_colors [ 'rsl_node_bg' ] = setDefaultValue ( 'rsl_node_bg', app_colors [ 'rsl_node_bg' ] ) - app_colors [ 'rib_node_bg' ] = setDefaultValue ( 'rib_node_bg', app_colors [ 'rib_node_bg' ] ) - app_colors [ 'image_node_bg' ] = setDefaultValue ( 'image_node_bg', app_colors [ 'image_node_bg' ] ) - app_colors [ 'group_node_bg' ] = setDefaultValue ( 'group_node_bg', app_colors [ 'group_node_bg' ] ) - app_settings.endGroup () - from gui.MainWindow import MainWindow - - window = MainWindow () #, rendererPreset ) - window.show () - - # It's exec_ because exec is a reserved word in Python - sys.exit ( app.exec_ () ) + # + app = QtModule.QApplication ( sys.argv ) + + + + app_settings.setValue ( 'version', version ) + app_settings.setValue ( 'root', normPath ( root ) ) + project_filename = setDefaultValue ( 'project_filename', 'meshadered.prj' ) + + temp_dir = setDefaultValue ( 'temp', normPath ( os.path.join ( root, 'tmp' ) ) ) + + project_dir = setDefaultValue ( 'project', normPath ( os.path.join ( root, 'samples' ) ) ) + project_shaders = setDefaultValue ( 'project_shaders', normPath ( os.path.join ( project_dir,'shaders' ) ) ) + project_textures = setDefaultValue ( 'project_textures',normPath ( os.path.join ( project_dir,'textures' ) ) ) + + shader_networks_dir = setDefaultValue ( 'shader_networks', normPath ( os.path.join ( project_shaders,'shn' ) ) ) + shader_sources_dir = setDefaultValue ( 'shader_sources', normPath ( os.path.join ( project_shaders,'src' ) ) ) + shader_output_dir = project_shaders + + lib_dir = setDefaultValue ( 'lib', normPath ( os.path.join ( root, 'lib' ) ) ) + node_dir = setDefaultValue ( 'nodes', normPath ( os.path.join ( lib_dir, 'nodes' ) ) ) + texture_dir = setDefaultValue ( 'texture', normPath ( os.path.join ( lib_dir, 'textures' ) ) ) + shaders_dir = setDefaultValue ( 'shaders', normPath ( os.path.join ( lib_dir, 'shaders' ) ) ) + archive_dir = setDefaultValue ( 'archive', normPath ( os.path.join ( lib_dir, 'archives' ) ) ) + + include_dir = setDefaultValue ( 'include', normPath ( os.path.join ( root, 'include' ) ) ) + + createMissingDirs ( [ temp_dir, lib_dir, project_dir, project_shaders, project_textures ] ) + createMissingDirs ( [ shader_networks_dir, shader_sources_dir ] ) + createMissingDirs ( [ node_dir, texture_dir, shaders_dir, archive_dir ] ) # include_dir supposed to be a list + # + # Recent projects/networks + # + setDefaultValue ( 'recent_projects_max', 10 ) + setDefaultValue ( 'recent_networks_max', 10 ) + # + # setup globals + # + app_global_vars [ 'version' ] = getSettingsStrValue ( app_settings, 'version' ) + app_global_vars [ 'RootPath' ] = root + app_global_vars [ 'TempPath' ] = temp_dir + app_global_vars [ 'ProjectPath' ] = project_dir + app_global_vars [ 'ProjectShaders' ] = project_shaders + app_global_vars [ 'ProjectTextures' ] = project_textures + + app_global_vars [ 'ProjectNetworks' ] = shader_networks_dir + app_global_vars [ 'ProjectSources' ] = shader_sources_dir + + app_global_vars [ 'LibPath' ] = lib_dir + app_global_vars [ 'NodesPath' ] = node_dir + app_global_vars [ 'TexturePath' ] = texture_dir + app_global_vars [ 'ShaderPath' ] = shaders_dir + app_global_vars [ 'IncludePath' ] = include_dir + + app_global_vars [ 'TextureSearchPath' ] = sanitizeSearchPath ( texture_dir ) + app_global_vars [ 'ShaderSearchPath' ] = sanitizeSearchPath ( shaders_dir ) + app_global_vars [ 'ArchiveSearchPath' ] = sanitizeSearchPath ( archive_dir ) + + app_global_vars [ 'ProjectSearchPath' ] = sanitizeSearchPath ( project_dir ) + app_global_vars [ 'ProjectSearchShaders' ] = sanitizeSearchPath ( project_shaders ) + app_global_vars [ 'ProjectSearchTextures' ] = sanitizeSearchPath ( project_textures ) + + # + # Setup current renderer preset + # + defRenderer = setDefaultValue ( 'defRenderer', '3Delight' ) + preset = meRendererPreset ( os.path.join ( root, 'renderers.xml' ), defRenderer ) + app_global_vars [ 'RendererPreset' ] = preset + app_global_vars [ 'RendererName' ] = preset.currentPreset.RendererName + app_global_vars [ 'RendererFlags' ] = preset.currentPreset.RendererFlags + app_global_vars [ 'ShaderCompiler' ] = preset.currentPreset.ShaderCompiler + app_global_vars [ 'ShaderDefines' ] = preset.currentPreset.ShaderDefines + app_global_vars [ 'ShaderInfo' ] = preset.currentPreset.ShaderInfo + app_global_vars [ 'SLO' ] = preset.currentPreset.ShaderExt + app_global_vars [ 'TextureMake' ] = preset.currentPreset.TextureMake + app_global_vars [ 'TextureInfo' ] = preset.currentPreset.TextureInfo + app_global_vars [ 'TextureViewer' ] = preset.currentPreset.TextureViewer + app_global_vars [ 'TEX' ] = preset.currentPreset.TextureExt + + createDefaultProject ( app_settings, True ) # check_if_exist = True + + if DEBUG_MODE : + print 'TextureSearchPath = %s' % app_global_vars [ 'TextureSearchPath' ] + print 'ShaderSearchPath = %s' % app_global_vars [ 'ShaderSearchPath' ] + print 'ArchiveSearchPath = %s' % app_global_vars [ 'ArchiveSearchPath' ] + print 'Renderer = %s' % app_global_vars [ 'RendererName' ] + + #app_global_vars[ 'RibPath' ] = '' + #app_global_vars[ 'DisplayPath' ] = '' + app_settings.beginGroup ( 'WorkArea' ) + #grid_enabled = bool( setDefaultValue( 'grid_enabled', True ).toString() ) + grid_enabled = setDefaultValue ( 'grid_enabled', True ) + grid_size = int ( setDefaultValue ( 'grid_size', 10 ) ) + grid_snap = setDefaultValue ( 'grid_snap', True ) + reverse_flow = setDefaultValue ( 'reverse_flow', False ) + straight_links = setDefaultValue ( 'straight_links', True ) + + app_settings.endGroup () + + app_settings.beginGroup ( 'Colors' ) + app_colors [ 'rsl_node_bg' ] = setDefaultValue ( 'rsl_node_bg', app_colors [ 'rsl_node_bg' ] ) + app_colors [ 'rib_node_bg' ] = setDefaultValue ( 'rib_node_bg', app_colors [ 'rib_node_bg' ] ) + app_colors [ 'image_node_bg' ] = setDefaultValue ( 'image_node_bg', app_colors [ 'image_node_bg' ] ) + app_colors [ 'group_node_bg' ] = setDefaultValue ( 'group_node_bg', app_colors [ 'group_node_bg' ] ) + app_settings.endGroup () + from gui.MainWindow import MainWindow + + window = MainWindow () #, rendererPreset ) + window.show () + + # It's exec_ because exec is a reserved word in Python + sys.exit ( app.exec_ () ) # # # if __name__ == "__main__": - # - print '* meShaderEd version %s' % version - - if len( sys.argv ) > 1 : - if sys.argv [ 1 ].lower () == '-debug' or sys.argv [ 1 ].lower () == '-d': - print '>> Running in DEBUG mode ...' - DEBUG_MODE = True - - if DEBUG_MODE : - #safeEffects = QtCore.QT_VERSION >= 0x40600 and QtCore.PYQT_VERSION > 0x40704 - print '* Python %s' % sys.version - print '* QT_VERSION = %0X' % QtCore.QT_VERSION - print '* PYQT_VERSION = %0X' % QtCore.PYQT_VERSION - - if sys.platform == 'win32' : - QtGui.QApplication.setStyle ( QtGui.QStyleFactory.create ( 'Cleanlooks' ) ) - if QtCore.QT_VERSION < 50000 : - QtGui.QApplication.setPalette ( QtGui.QApplication.style ().standardPalette () ) - - main () + # + print '* meShaderEd version %s' % version + + if len( sys.argv ) > 1 : + if sys.argv [ 1 ].lower () == '-debug' or sys.argv [ 1 ].lower () == '-d': + print '>> Running in DEBUG mode ...' + DEBUG_MODE = True + + if DEBUG_MODE : + #safeEffects = QtCore.QT_VERSION >= 0x40600 and QtCore.PYQT_VERSION > 0x40704 + print '* Python %s' % sys.version + print '* QT_VERSION = %0X' % QtCore.QT_VERSION + print '* PYQT_VERSION = %0X' % QtCore.PYQT_VERSION + + if sys.platform == 'win32' : + if QtCore.QT_VERSION < 50000 : + QtModule.QApplication.setStyle ( QtModule.QStyleFactory.create ( 'Cleanlooks' ) ) + QtModule.QApplication.setPalette ( QtModule.QApplication.style ().standardPalette () ) + + main () From f88190238f8bad42d42a79c2a2af053baabe964c Mon Sep 17 00:00:00 2001 From: ymesh Date: Thu, 24 Sep 2015 12:24:46 +0300 Subject: [PATCH 2/6] New script mkpyqt5.py works with PyQt5. All .ui files moved to "ui" folders in their locations. --- .../{ => ui}/ui_exportShaderDialog.ui | 0 gui/mkpyqt.py | 275 ----------------- gui/nodeEditor/{ => ui}/ui_nodeCodeEditor.ui | 0 .../{ => ui}/ui_nodeEditorDialog.ui | 0 gui/nodeEditor/{ => ui}/ui_nodeLinkEditor.ui | 0 gui/nodeEditor/{ => ui}/ui_nodeNamesEditor.ui | 0 gui/nodeEditor/{ => ui}/ui_nodeParamEditor.ui | 0 .../{ => ui}/ui_nodePropertiesEditor.ui | 0 gui/{ => ui}/ui_MainWindow.ui | 0 gui/{ => ui}/ui_imageViewWidget.ui | 0 gui/{ => ui}/ui_meRendererSetup.ui | 0 gui/{ => ui}/ui_nodeLibraryView.ui | 0 gui/{ => ui}/ui_nodeList.ui | 0 gui/{ => ui}/ui_nodeParam.ui | 0 gui/{ => ui}/ui_nodeSwatchParam.ui | 0 gui/{ => ui}/ui_projectSetup.ui | 0 gui/{ => ui}/ui_settingsSetup.ui | 0 gui/{ => ui}/ui_viewComputedCodeDialog.ui | 0 gui/{ => ui}/ui_workArea.ui | 0 meShaderEd.py | 8 +- mkpyqt5.py | 286 ++++++++++++++++++ 21 files changed, 289 insertions(+), 280 deletions(-) rename gui/exportShader/{ => ui}/ui_exportShaderDialog.ui (100%) delete mode 100644 gui/mkpyqt.py rename gui/nodeEditor/{ => ui}/ui_nodeCodeEditor.ui (100%) rename gui/nodeEditor/{ => ui}/ui_nodeEditorDialog.ui (100%) rename gui/nodeEditor/{ => ui}/ui_nodeLinkEditor.ui (100%) rename gui/nodeEditor/{ => ui}/ui_nodeNamesEditor.ui (100%) rename gui/nodeEditor/{ => ui}/ui_nodeParamEditor.ui (100%) rename gui/nodeEditor/{ => ui}/ui_nodePropertiesEditor.ui (100%) rename gui/{ => ui}/ui_MainWindow.ui (100%) rename gui/{ => ui}/ui_imageViewWidget.ui (100%) rename gui/{ => ui}/ui_meRendererSetup.ui (100%) rename gui/{ => ui}/ui_nodeLibraryView.ui (100%) rename gui/{ => ui}/ui_nodeList.ui (100%) rename gui/{ => ui}/ui_nodeParam.ui (100%) rename gui/{ => ui}/ui_nodeSwatchParam.ui (100%) rename gui/{ => ui}/ui_projectSetup.ui (100%) rename gui/{ => ui}/ui_settingsSetup.ui (100%) rename gui/{ => ui}/ui_viewComputedCodeDialog.ui (100%) rename gui/{ => ui}/ui_workArea.ui (100%) create mode 100644 mkpyqt5.py diff --git a/gui/exportShader/ui_exportShaderDialog.ui b/gui/exportShader/ui/ui_exportShaderDialog.ui similarity index 100% rename from gui/exportShader/ui_exportShaderDialog.ui rename to gui/exportShader/ui/ui_exportShaderDialog.ui diff --git a/gui/mkpyqt.py b/gui/mkpyqt.py deleted file mode 100644 index 3d6e21b..0000000 --- a/gui/mkpyqt.py +++ /dev/null @@ -1,275 +0,0 @@ -#!/usr/bin/env python -################################################################################## -# -# Shaderlink 0.4 - A RenderMan Shader Authoring Toolkit -# http://libe.ocracy.org/shaderlink.html -# 2009 Libero Spagnolini (libero.spagnolini@gmail.com) -# -################################################################################## - - -# Copyright (c) 2007-9 Qtrac Ltd. All rights reserved. -# This program or module is free software: you can redistribute it and/or -# modify it under the terms of the GNU General Public License as published -# by the Free Software Foundation, either version 2 of the License, or -# version 3 of the License, or (at your option) any later version. It is -# provided for educational purposes and is distributed in the hope that -# it will be useful, but WITHOUT ANY WARRANTY; without even the implied -# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -# the GNU General Public License for more details. - -import os -import platform -import stat -import sys -import PyQt4.QtCore - -__version__ = "1.0.3" - -if sys.platform.startswith("win"): - PATH = os.path.join(os.path.dirname(sys.executable), - "Lib/site-packages/PyQt4/bin") -else: - app = PyQt4.QtCore.QCoreApplication([]) - PATH = unicode(app.applicationDirPath()) - del app -if sys.platform.startswith("darwin"): - i = PATH.find("Resources") - if i > -1: - PATH = PATH[:i] + "bin" -PYUIC4 = os.path.join(PATH, "pyuic4") # e.g. PYUIC4 = "/usr/bin/pyuic4" - -#if sys.platform.startswith("darwin"): -# PYUIC4 = os.path.dirname(sys.executable) -# i = PYUIC4.find("Resources") -# if i > -1: -# PYUIC4 = PYUIC4[:i] + "Lib/python2.5/site-packages/PyQt4/uic/pyuic.py" -PYRCC4 = os.path.join(PATH, "pyrcc4") - -PYLUPDATE4 = os.path.join(PATH, "pylupdate4") -LRELEASE = "lrelease" -if platform.system() == "Windows": - PYUIC4 = PYUIC4.replace("/", "\\") + ".bat" - PYRCC4 = PYRCC4.replace("/", "\\") + ".exe" - PYLUPDATE4 = PYLUPDATE4.replace("/", "\\") + ".exe" - -msg = [] -if not os.access(PYUIC4, os.F_OK): - msg.append("failed to find pyuic4; tried %s" % PYUIC4) -if not os.access(PYRCC4, os.F_OK): - msg.append("failed to find pyrcc4; tried %s" % PYRCC4) -if not os.access(PYLUPDATE4, os.F_OK): - msg.append("failed to find pylupdate4; tried %s" % PYLUPDATE4) -if msg: - print "\n".join(msg) - print "try manually editing this program to put the correct " + \ - "paths in place" - sys.exit() -#if sys.platform.startswith("darwin"): -# PYUIC4 = "/usr/bin/pyuic4" -# PYRCC4 = "/usr/bin/pyrcc4" - -print "PYUIC4 = %s" % PYUIC4 -print "PYRCC4 = %s" % PYRCC4 - -Debug = False -Verbose = False - -def usage(): - print """usage: mkpyqt.py [options] [path] - -Options (which can be given in any of the forms shown): --b --build build [default] --c --clean clean --f --force force --t --translate translate --r --recurse recurse --v --verbose verbose --D --debug debug -path defaults to . - -If executed with no arguments (or with a build argument) it does a -build, i.e., it looks for all *.ui and *.qrc files and makes sure that -the corresponding ui_*.py and qrc_*.py files exist and are up-to-date. - -If executed with clean, deletes all ui_*.py and qrc_*.py files that have -corresponding *.ui and *.qrc files, and all *.pyc and *.pyo files. - -If executed with force, it does a clean followed by a build. - -If building and the translate option is given, after building, it runs -pylupdate4 on all .py and .pyw files it encounters, and then runs lrelease -on all .ts files it encounters. It does not use a .pro file so the .ts -files must be created in the first place, e.g., using pylupdate4 on one -of the source files and using its -ts option. - -WARNING: Do not give any hand-coded files names that match ui_*.py or -qrc_*.py since these will be deleted by mkpyqt.py clean! - -NOTE: If any tool fails to run, e.g., pyuic4, then edit this program and -hard-code the path; the variables with the tool paths are near the top -of the file. - -mkpyqt.py v %s. Copyright (c) 2007-9 Qtrac Ltd. All rights reserved. -""" % __version__ - sys.exit() - - -def report_failure(command, args, process): - msg = "" - ba = process.readAllStandardError() - if not ba.isEmpty(): - msg = ": " + str(QString(ba)) - print "failed", command, " ".join(args), msg - - -def build(path): - for name in os.listdir(path): - source = os.path.join(path, name) - target = None - if source.endswith(".ui"): - target = os.path.join(path, name.replace(".ui", ".py")) - command = PYUIC4 - elif source.endswith(".qrc"): - (fname, fext) = os.path.splitext(name) - target = os.path.join(path, fname + "_rc.py") - #target = os.path.join(path, "qrc_" + name.replace(".qrc", ".py")) - command = PYRCC4 - process = PyQt4.QtCore.QProcess() - if target is not None: - if not os.access(target, os.F_OK) or ( - os.stat(source)[stat.ST_MTIME] > \ - os.stat(target)[stat.ST_MTIME]): - args = ["-o", target, source] - if sys.platform.startswith("darwin") and command == PYUIC4: - #command = sys.executable - #args = [PYUIC4] + args - command = PYUIC4 - if Debug: - print "# %s %s" % (command, " ".join(args)) - else: - if Verbose: - print "# %s %s" % (command, " ".join(args)) - process.start(command, args) - if not process.waitForFinished(2 * 60 * 1000): - report_failure(command, args, process) - else: - print source, "->", target - elif Verbose: - print source, "is up-to-date" - - -def clean(path): - deletelist = [] - for name in os.listdir(path): - target = os.path.join(path, name) - source = None - if target.endswith(".py") or target.endswith(".pyc") or \ - target.endswith(".pyo"): - if name.startswith("ui_") and not name[-1] in "oc": - source = os.path.join(path, name[3:-3] + ".ui") - elif name.startswith("qrc_"): - if target[-1] in "oc": - source = os.path.join(path, name[4:-4] + ".qrc") - else: - source = os.path.join(path, name[4:-3] + ".qrc") - elif target[-1] in "oc": - source = target[:-1] - if source is not None: - if os.access(source, os.F_OK): - if Debug: - print "# delete ", target - else: - deletelist.append(target) - else: - print "will not remove '%s' since `%s' not found" % ( - target, source) - if not Debug: - for target in deletelist: - if Verbose: - print "deleted", target - os.remove(target) - - -def translate(path): - files = [] - tsfiles = [] - for name in os.listdir(path): - if name.endswith((".py", ".pyw")): - files.append(os.path.join(path, name)) - elif name.endswith(".ts"): - tsfiles.append(os.path.join(path, name)) - if not tsfiles: - return - verbose = "-verbose" if Verbose else "" - silent = "-silent" if not Verbose else "" - process = PyQt4.QtCore.QProcess() - for ts in tsfiles: - qm = ts[:-3] + ".qm" - command1 = PYLUPDATE4 - args1 = [verbose] + files + ["-ts", ts] - command2 = LRELEASE - args2 = [silent, ts, "-qm", qm] - if Debug: - print "updated", ts - print "generated", qm - else: - process.start(command1, args1) - if not process.waitForFinished(2 * 60 * 1000): - report_failure(command1, args1, process) - process.start(command2, args2) - if not process.waitForFinished(2 * 60 * 1000): - report_failure(command2, args2, process) - - -def apply(recurse, function, path): - if not recurse: - function(path) - else: - for root, dirs, files in os.walk(path): - for dir in dirs: - function(os.path.join(root, dir)) - - -def main(): - global Debug, Verbose - function = build - recurse = False - trans = False - force = False - path = "." - args = sys.argv[1:] - while args: - arg = args.pop(0) - if arg in ("-D", "--debug", "debug"): - Debug = True - elif arg in ("-b", "--build", "build"): - pass # This is the default - elif arg in ("-c", "--clean", "clean"): - function = clean - elif arg in ("-f", "--force", "force"): - force = True - elif arg in ("-t", "--translate", "translate"): - trans = True - elif arg in ("-r", "--recurse", "recurse"): - recurse = True - elif arg in ("-v", "--verbose", "verbose"): - Verbose = True - elif arg in ("-h", "--help", "help"): - usage() - else: - path = arg - if not force: - apply(recurse, function, path) - else: - apply(recurse, clean, path) - apply(recurse, build, path) - if trans and (function == build or force): - apply(recurse, translate, path) - -main() - -# 1.0.1 Fixed bug reported by Brian Downing where paths that contained -# spaces were not handled correctly. -# 1.0.2 Changed default path on Windows to match PyQt 4.4 -# 1.0.3 Tried to make the paths work on Mac OS X diff --git a/gui/nodeEditor/ui_nodeCodeEditor.ui b/gui/nodeEditor/ui/ui_nodeCodeEditor.ui similarity index 100% rename from gui/nodeEditor/ui_nodeCodeEditor.ui rename to gui/nodeEditor/ui/ui_nodeCodeEditor.ui diff --git a/gui/nodeEditor/ui_nodeEditorDialog.ui b/gui/nodeEditor/ui/ui_nodeEditorDialog.ui similarity index 100% rename from gui/nodeEditor/ui_nodeEditorDialog.ui rename to gui/nodeEditor/ui/ui_nodeEditorDialog.ui diff --git a/gui/nodeEditor/ui_nodeLinkEditor.ui b/gui/nodeEditor/ui/ui_nodeLinkEditor.ui similarity index 100% rename from gui/nodeEditor/ui_nodeLinkEditor.ui rename to gui/nodeEditor/ui/ui_nodeLinkEditor.ui diff --git a/gui/nodeEditor/ui_nodeNamesEditor.ui b/gui/nodeEditor/ui/ui_nodeNamesEditor.ui similarity index 100% rename from gui/nodeEditor/ui_nodeNamesEditor.ui rename to gui/nodeEditor/ui/ui_nodeNamesEditor.ui diff --git a/gui/nodeEditor/ui_nodeParamEditor.ui b/gui/nodeEditor/ui/ui_nodeParamEditor.ui similarity index 100% rename from gui/nodeEditor/ui_nodeParamEditor.ui rename to gui/nodeEditor/ui/ui_nodeParamEditor.ui diff --git a/gui/nodeEditor/ui_nodePropertiesEditor.ui b/gui/nodeEditor/ui/ui_nodePropertiesEditor.ui similarity index 100% rename from gui/nodeEditor/ui_nodePropertiesEditor.ui rename to gui/nodeEditor/ui/ui_nodePropertiesEditor.ui diff --git a/gui/ui_MainWindow.ui b/gui/ui/ui_MainWindow.ui similarity index 100% rename from gui/ui_MainWindow.ui rename to gui/ui/ui_MainWindow.ui diff --git a/gui/ui_imageViewWidget.ui b/gui/ui/ui_imageViewWidget.ui similarity index 100% rename from gui/ui_imageViewWidget.ui rename to gui/ui/ui_imageViewWidget.ui diff --git a/gui/ui_meRendererSetup.ui b/gui/ui/ui_meRendererSetup.ui similarity index 100% rename from gui/ui_meRendererSetup.ui rename to gui/ui/ui_meRendererSetup.ui diff --git a/gui/ui_nodeLibraryView.ui b/gui/ui/ui_nodeLibraryView.ui similarity index 100% rename from gui/ui_nodeLibraryView.ui rename to gui/ui/ui_nodeLibraryView.ui diff --git a/gui/ui_nodeList.ui b/gui/ui/ui_nodeList.ui similarity index 100% rename from gui/ui_nodeList.ui rename to gui/ui/ui_nodeList.ui diff --git a/gui/ui_nodeParam.ui b/gui/ui/ui_nodeParam.ui similarity index 100% rename from gui/ui_nodeParam.ui rename to gui/ui/ui_nodeParam.ui diff --git a/gui/ui_nodeSwatchParam.ui b/gui/ui/ui_nodeSwatchParam.ui similarity index 100% rename from gui/ui_nodeSwatchParam.ui rename to gui/ui/ui_nodeSwatchParam.ui diff --git a/gui/ui_projectSetup.ui b/gui/ui/ui_projectSetup.ui similarity index 100% rename from gui/ui_projectSetup.ui rename to gui/ui/ui_projectSetup.ui diff --git a/gui/ui_settingsSetup.ui b/gui/ui/ui_settingsSetup.ui similarity index 100% rename from gui/ui_settingsSetup.ui rename to gui/ui/ui_settingsSetup.ui diff --git a/gui/ui_viewComputedCodeDialog.ui b/gui/ui/ui_viewComputedCodeDialog.ui similarity index 100% rename from gui/ui_viewComputedCodeDialog.ui rename to gui/ui/ui_viewComputedCodeDialog.ui diff --git a/gui/ui_workArea.ui b/gui/ui/ui_workArea.ui similarity index 100% rename from gui/ui_workArea.ui rename to gui/ui/ui_workArea.ui diff --git a/meShaderEd.py b/meShaderEd.py index ab0d480..a3d536c 100644 --- a/meShaderEd.py +++ b/meShaderEd.py @@ -18,10 +18,7 @@ The RenderMan Shader Editor """ -import sys -import os - - +import os, sys from core.mePyQt import QtCore, QtGui from core.meCommon import * @@ -33,6 +30,7 @@ root = normPath ( sys.path [0] ) branchName = 'QT5' version = '0.3.4b ' + branchName +__version__ = version app_settings = QtCore.QSettings ( QtCore.QSettings.IniFormat, QtCore.QSettings.UserScope, @@ -225,7 +223,7 @@ def main () : print '* QT_VERSION = %0X' % QtCore.QT_VERSION print '* PYQT_VERSION = %0X' % QtCore.PYQT_VERSION - if sys.platform == 'win32' : + if sys.platform.startswith ( 'win') : if QtCore.QT_VERSION < 50000 : QtModule.QApplication.setStyle ( QtModule.QStyleFactory.create ( 'Cleanlooks' ) ) QtModule.QApplication.setPalette ( QtModule.QApplication.style ().standardPalette () ) diff --git a/mkpyqt5.py b/mkpyqt5.py new file mode 100644 index 0000000..60d6da6 --- /dev/null +++ b/mkpyqt5.py @@ -0,0 +1,286 @@ +#!/usr/bin/python +################################################################################## +# +# Shaderlink 0.4 - A RenderMan Shader Authoring Toolkit +# http://libe.ocracy.org/shaderlink.html +# 2009 Libero Spagnolini (libero.spagnolini@gmail.com) +# +################################################################################## + + +# Copyright (c) 2007-9 Qtrac Ltd. All rights reserved. +# This program or module is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as published +# by the Free Software Foundation, either version 2 of the License, or +# version 3 of the License, or (at your option) any later version. It is +# provided for educational purposes and is distributed in the hope that +# it will be useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +# the GNU General Public License for more details. + +import os +import platform +import stat +import sys +from core.mePyQt import QtCore, PythonQtType + +if QtCore.QT_VERSION < 50000 : pass + +__version__ = "1.0.4" + +print '* Python %s' % sys.version +print '* QT_VERSION = %0X' % QtCore.QT_VERSION +print '* PYQT_VERSION = %0X' % QtCore.PYQT_VERSION + +if PythonQtType != 'PyQt5' : + print ( '! This script supposed to work with PyQt5 only ...' ) + sys.exit() + +if sys.platform.startswith("win"): + #PATH = os.path.join(os.path.dirname(sys.executable), "Lib/site-packages/PyQt4") + PATH = os.path.dirname ( sys.executable ) +else: + app = QtCore.QCoreApplication ( [] ) + PATH = unicode ( app.applicationDirPath () ) + del app +if sys.platform.startswith ( "darwin" ): + i = PATH.find ("Resources" ) + if i > -1: + PATH = PATH[:i] + "bin" + PYUIC5 = "/System/Library/Frameworks/Python.framework/Versions/2.7/bin/pyuic4" +else : + PYUIC5 = os.path.join ( PATH, "pyuic5" ) # e.g. PYUIC5 = "/usr/bin/pyuic5" + +if sys.platform.startswith ( "darwin" ): +# PYUIC5 = os.path.dirname(sys.executable) +# i = PYUIC5.find("Resources") +# if i > -1: +# PYUIC5 = PYUIC5[:i] + "Lib/python2.5/site-packages/PyQt4/uic/pyuic.py" + PYRCC5 = "/System/Library/Frameworks/Python.framework/Versions/2.7/bin/pyrcc4" + PYLUPDATE5 = "/System/Library/Frameworks/Python.framework/Versions/2.7/bin/pylupdate4" +else : + PYRCC5 = os.path.join ( PATH, "pyrcc5" ) + PYLUPDATE5 = os.path.join ( PATH, "pylupdate5" ) + +LRELEASE = "lrelease" +if platform.system () == "Windows" : + PYUIC5 = PYUIC5.replace ( "/", "\\" ) + ".bat" + PYRCC5 = PYRCC5.replace ( "/", "\\" ) + ".exe" + PYLUPDATE5 = PYLUPDATE5.replace ( "/", "\\" ) + ".exe" + +msg = [] +if not os.access ( PYUIC5, os.F_OK ) : + msg.append ( "failed to find pyuic5; tried %s" % PYUIC5 ) +if not os.access(PYRCC5, os.F_OK): + msg.append ( "failed to find pyrcc5; tried %s" % PYRCC5 ) +if not os.access ( PYLUPDATE5, os.F_OK ): + msg.append ( "failed to find pylupdate5; tried %s" % PYLUPDATE5 ) +if msg : + print "\n".join ( msg ) + print "try manually editing this program to put the correct " + \ + "paths in place" + sys.exit() +#if sys.platform.startswith("darwin"): +# PYUIC5 = "/usr/bin/pyuic5" +# PYRCC5 = "/usr/bin/pyrcc5" + +print "PYUIC5 = %s" % PYUIC5 +print "PYRCC5 = %s" % PYRCC5 +print "PYLUPDATE5 = %s" % PYLUPDATE5 + +Debug = False +Verbose = False + +def usage () : + print """usage: mkpyqt5.py [options] [path] + +Options (which can be given in any of the forms shown): +-b --build build [default] +-c --clean clean +-f --force force +-t --translate translate +-r --recurse recurse +-v --verbose verbose +-D --debug debug +path defaults to . + +If executed with no arguments (or with a build argument) it does a +build, i.e., it looks for all *.ui and *.qrc files and makes sure that +the corresponding ui_*.py and qrc_*.py files exist and are up-to-date. + +If executed with clean, deletes all ui_*.py and qrc_*.py files that have +corresponding *.ui and *.qrc files, and all *.pyc and *.pyo files. + +If executed with force, it does a clean followed by a build. + +If building and the translate option is given, after building, it runs +pylupdate4 on all .py and .pyw files it encounters, and then runs lrelease +on all .ts files it encounters. It does not use a .pro file so the .ts +files must be created in the first place, e.g., using pylupdate4 on one +of the source files and using its -ts option. + +WARNING: Do not give any hand-coded files names that match ui_*.py or +qrc_*.py since these will be deleted by mkpyqt.py clean! + +NOTE: If any tool fails to run, e.g., pyuic5, then edit this program and +hard-code the path; the variables with the tool paths are near the top +of the file. + +mkpyqt.py v %s. Copyright (c) 2007-9 Qtrac Ltd. All rights reserved. +""" % __version__ + sys.exit() + + +def report_failure ( command, args, process ) : + msg = "" + ba = process.readAllStandardError () + if not ba.isEmpty () : + msg = ": " + str ( ba ) + print "failed", command, " ".join ( args ), msg + +def build ( path ) : + for name in os.listdir ( path ) : + source = os.path.join ( path, name ) + target = None + if source.endswith ( ".ui" ) : + target = os.path.join ( path, name.replace (".ui", ".py") ) + command = PYUIC5 + elif source.endswith ( ".qrc" ) : + ( fname, fext ) = os.path.splitext ( name ) + target = os.path.join ( path, fname + "_rc.py" ) + #target = os.path.join ( path, "qrc_" + name.replace(".qrc", ".py" ) ) + command = PYRCC5 + process = QtCore.QProcess () + if target is not None : + if not os.access ( target, os.F_OK) or ( + os.stat ( source ) [ stat.ST_MTIME ] > \ + os.stat ( target ) [ stat.ST_MTIME ] ): + args = [ "-o", target, source ] + if sys.platform.startswith ( "darwin") and command == PYUIC5 : + #command = sys.executable + #args = [PYUIC4] + args + command = PYUIC5 + if Debug: + print "# %s %s" % ( command, " ".join ( args ) ) + else: + if Verbose : + print "# %s %s" % ( command, " ".join ( args ) ) + process.start ( command, args ) + if not process.waitForFinished (2 * 60 * 1000) : + report_failure ( command, args, process ) + else : + print source, "->", target + elif Verbose : + print source, "is up-to-date" + +def clean ( path ) : + deletelist = [] + for name in os.listdir ( path ) : + target = os.path.join ( path, name ) + source = None + if target.endswith ( ".py" ) or target.endswith ( ".pyc" ) or \ + target.endswith ( ".pyo" ) : + if name.startswith ( "ui_" ) and not name [ -1 ] in "oc" : + source = os.path.join ( path, name [ 3:-3 ] + ".ui" ) + elif name.startswith ("qrc_" ) : + if target [ -1 ] in "oc" : + source = os.path.join ( path, name [ 4:-4 ] + ".qrc" ) + else: + source = os.path.join ( path, name [ 4:-3 ] + ".qrc" ) + elif target [ -1 ] in "oc": + source = target [ :-1 ] + if source is not None : + if os.access ( source, os.F_OK ) : + if Debug : + print "# delete ", target + else: + deletelist.append ( target ) + else: + print "will not remove '%s' since `%s' not found" % ( target, source ) + if not Debug : + for target in deletelist : + if Verbose: + print "deleted", target + os.remove(target) + +def translate ( path ) : + files = [] + tsfiles = [] + for name in os.listdir ( path ) : + if name.endswith ( (".py", ".pyw" ) ) : + files.append(os.path.join(path, name)) + elif name.endswith ( ".ts" ) : + tsfiles.append ( os.path.join ( path, name ) ) + if not tsfiles : + return + verbose = "-verbose" if Verbose else "" + silent = "-silent" if not Verbose else "" + process = QtCore.QProcess () + for ts in tsfiles : + qm = ts [ :-3 ] + ".qm" + command1 = PYLUPDATE5 + args1 = [ verbose ] + files + [ "-ts", ts ] + command2 = LRELEASE + args2 = [ silent, ts, "-qm", qm ] + if Debug : + print "updated", ts + print "generated", qm + else: + process.start ( command1, args1 ) + if not process.waitForFinished ( 2 * 60 * 1000 ) : + report_failure ( command1, args1, process ) + process.start ( command2, args2 ) + if not process.waitForFinished ( 2 * 60 * 1000 ) : + report_failure ( command2, args2, process ) + +def apply ( recurse, function, path ): + if not recurse : + function ( path ) + else: + for root, dirs, files in os.walk ( path ) : + for dir in dirs : + function ( os.path.join ( root, dir ) ) + +def main () : + global Debug, Verbose + function = build + recurse = False + trans = False + force = False + path = "." + args = sys.argv [1:] + while args: + arg = args.pop ( 0 ) + if arg in ( "-D", "--debug", "debug" ) : + Debug = True + elif arg in ( "-b", "--build", "build" ): + pass # This is the default + elif arg in ( "-c", "--clean", "clean" ) : + function = clean + elif arg in ( "-f", "--force", "force" ) : + force = True + elif arg in ( "-t", "--translate", "translate" ) : + trans = True + elif arg in ( "-r", "--recurse", "recurse" ) : + recurse = True + elif arg in ( "-v", "--verbose", "verbose" ) : + Verbose = True + elif arg in ( "-h", "--help", "help" ): + usage () + else: + path = arg + if not force: + apply (recurse, function, path ) + else: + apply ( recurse, clean, path ) + apply ( recurse, build, path ) + if trans and ( function == build or force ): + apply ( recurse, translate, path ) + +main() + +# 1.0.1 Fixed bug reported by Brian Downing where paths that contained +# spaces were not handled correctly. +# 1.0.2 Changed default path on Windows to match PyQt 4.4 +# 1.0.3 Tried to make the paths work on Mac OS X +# 1.0.4 modified for work with PyQt5 (by Yuri Meshalkin) From ecca398b5dbd72c725b2b18c278bbc0415ca5122 Mon Sep 17 00:00:00 2001 From: ymesh Date: Sun, 27 Sep 2015 22:30:43 +0300 Subject: [PATCH 3/6] Usage of PyQt4 signals replaced with pyqtSignal and Signal class --- core/node.py | 1773 +++++++++++---------- core/nodeNetwork.py | 16 +- core/nodeParam.py | 612 +++---- core/signal.py | 26 + gfx/WorkArea.py | 167 +- gfx/gfxLink.py | 27 +- gfx/gfxNode.py | 100 +- gfx/gfxNodeConnector.py | 96 +- gfx/gfxNodeLabel.py | 12 +- gfx/gfxNote.py | 20 +- gfx/imageView.py | 12 +- gui/MainWindow.py | 85 +- gui/ProjectSetup.py | 14 +- gui/SettingsSetup.py | 23 +- gui/ViewComputedCodeDialog.py | 1 - gui/exportShader/ExportShaderDialog.py | 75 +- gui/exportShader/ui_exportShaderDialog.py | 251 +-- gui/imageViewWidget.py | 8 +- gui/meRendererSetup.py | 19 +- gui/nodeEditor/NodeEditorDialog.py | 189 +-- gui/nodeEditor/codeSyntaxHighlighter.py | 197 +-- gui/nodeEditor/nodeNamesEditor.py | 30 +- gui/nodeEditor/nodeParamEditor.py | 63 +- gui/nodeEditor/nodePropertiesEditor.py | 53 +- gui/nodeEditor/ui_nodeCodeEditor.py | 56 +- gui/nodeEditor/ui_nodeEditorDialog.py | 518 +++--- gui/nodeEditor/ui_nodeLinkEditor.py | 222 +-- gui/nodeEditor/ui_nodeNamesEditor.py | 120 +- gui/nodeEditor/ui_nodeParamEditor.py | 350 ++-- gui/nodeEditor/ui_nodePropertiesEditor.py | 256 +-- gui/nodeList.py | 54 +- gui/nodeParamList.py | 22 +- gui/nodeParamView.py | 50 +- gui/nodeTreeView.py | 5 +- gui/params/ColorWidget.py | 292 ++-- gui/params/ControlWidget.py | 214 +-- gui/params/FloatWidget.py | 633 ++++---- gui/params/IntWidget.py | 529 +++--- gui/params/MatrixWidget.py | 608 +++---- gui/params/NormalWidget.py | 212 +-- gui/params/PointWidget.py | 212 +-- gui/params/StringWidget.py | 428 ++--- gui/params/TextWidget.py | 128 +- gui/params/VectorWidget.py | 211 +-- gui/params/linkWidget.py | 202 +-- gui/params/paramLabel.py | 15 +- gui/params/paramWidget.py | 32 +- gui/ui_MainWindow.py | 1083 +++++++------ gui/ui_imageViewWidget.py | 5 +- gui/ui_meRendererSetup.py | 798 +++++----- gui/ui_nodeLibraryView.py | 4 +- gui/ui_nodeParam.py | 56 +- gui/ui_projectSetup.py | 296 ++-- gui/ui_settingsSetup.py | 355 +++-- gui/ui_viewComputedCodeDialog.py | 68 +- gui/ui_workArea.py | 12 +- meShaderEd.py | 4 +- 57 files changed, 6472 insertions(+), 5447 deletions(-) create mode 100644 core/signal.py diff --git a/core/node.py b/core/node.py index 90bd634..1bba87b 100644 --- a/core/node.py +++ b/core/node.py @@ -1,7 +1,6 @@ """ node.py - """ import os, sys, copy @@ -15,516 +14,528 @@ # Node # class Node ( QtCore.QObject ) : - # - id = 0 - # - # __init__ - # - def __init__ ( self, xml_node = None, nodenet = None ) : - # - QtCore.QObject.__init__ ( self ) - - self.id = None - self.name = None - self.label = None - self.type = None - - self.author = None - self.help = None - self.icon = None - - self.master = None - - self.code = None # Node code (RSL, RIB, ... ) - self.control_code = None # python code executed before node computation - self.computed_code = None # code collected after compute on all connected nodes - - self.event_code = {} - #self.event_code [ 'ParamLabelRenamed' ] = None - #self.event_code [ 'ParamAdded' ] = None - #self.event_code [ 'ParamRemoved' ] = None - - self.display = True - - self.computedInputParams = None - self.computedOutputParams = None - self.computedLocalParams = None - self.computedIncludes = None - self.computedLocals = None - self.computedCode = None - - #self.previewCode = None - - self.inputParams = [] - self.outputParams = [] - self.internals = [] - self.includes = [] - - self.inputLinks = {} - self.outputLinks = {} - - self.childs = set() - - self.nodenet = nodenet - - # position from GfxNode - self.offset = ( 0, 0 ) - - if xml_node != None : - self.parseFromXML ( xml_node ) - # - # __del__ - # - def __del__ ( self ) : - # - if DEBUG_MODE : print '>> Node( %s ).__del__' % self.label - # - # build - # - @classmethod - def build ( cls ) : - # set unique id while building - node = cls () - Node.id += 1 - node.id = Node.id - return node - # - # copy - # - def copy ( self ) : assert 0, 'copy needs to be implemented!' - # - # updateNode - # - def updateNode ( self ) : - # - if DEBUG_MODE : print '>> Node( %s ).updateNode' % self.label - self.emit ( QtCore.SIGNAL ( 'nodeUpdated' ), self ) - # - # updateNodeParams - # - def updateNodeParams ( self ) : - # - if DEBUG_MODE : print '>> Node( %s ).updateNodeParams' % self.label - self.emit ( QtCore.SIGNAL ( 'nodeParamsUpdated' ), self ) - # - # addChild - # - def addChild ( self, node ) : self.childs.add ( node ) - # - # removeChild - # - def removeChild ( self, node ) : - # - if node in self.childs : - self.childs.remove ( node ) - if DEBUG_MODE : print '** Node(%s).removeChild %s' % ( self.label, node.label ) - else : - if DEBUG_MODE : print '!! Node(%s).removeChild child %s is not in the list' % ( self.label, node.label ) - # - # printInfo - # - def printInfo ( self ) : - # - print ':: Node (id = %d) label = %s' % ( self.id, self.label ) - print '** Node inputLinks:' - for param in self.inputLinks.keys () : - print '\t* param: %s (%s) linked to ' % ( param.name, param.label ) - self.inputLinks [ param ].printInfo () - print '** Node outputLinks:' - #print '*****', self.outputLinks - for param in self.outputLinks.keys () : - print '\t* param: %s (%s) linked to ' % ( param.name, param.label ) - linklist = self.outputLinks [ param ] - for link in linklist : - link.printInfo () - print '** Node children:' - for child in self.childs : - print '\t* %s' % child.label - # - # addInputParam - # - def addInputParam ( self, param ) : - # - param.isInput = True - # to be sure that name and label is unique - if param.name in self.getParamsNames () : self.renameParamName ( param, param.name ) - if param.label in self.getParamsLabels () : self.renameParamLabel ( param, param.label ) - self.inputParams.append ( param ) - if self.event_code : - if 'ParamAdded' in self.event_code.keys () : - exec ( self.event_code [ 'ParamAdded' ], { 'param' : param, 'self' : self } ) - # - # addOutputParam - # - def addOutputParam ( self, param ) : - # - param.isInput = False - # to be sure that name and label is unique - if param.name in self.getParamsNames () : self.renameParamName ( param, param.name ) - if param.label in self.getParamsLabels () : self.renameParamLabel ( param, param.label ) - self.outputParams.append ( param ) - if self.event_code : - if 'ParamAdded' in self.event_code.keys () : - exec ( self.event_code [ 'ParamAdded' ], { 'param' : param, 'self' : self } ) - # - # addInternal - # - def addInternal ( self, newName ) : - #print '--> add internal: %s' % internal - internal = newName - if internal != '' : - from meCommon import getUniqueName - internal = getUniqueName ( newName, self.internals ) - self.internals.append ( internal ) - return internal - # - # addInclude - # - def addInclude ( self, newName ) : - #print '--> add include: %s' % include - include = newName - if include != '' : - from meCommon import getUniqueName - include = getUniqueName ( newName, self.includes ) - self.includes.append ( include ) - return include - # - # attachInputParamToLink - # - def attachInputParamToLink ( self, param, link ) : - # - self.inputLinks [ param ] = link - # - # attachOutputParamToLink - # - def attachOutputParamToLink ( self, param, link ) : - # - #if DEBUG_MODE : print ">> Node::attachOutputParamToLink param = %s" % param.name - if not param in self.outputLinks.keys () : - self.outputLinks [ param ] = [] - if not link in self.outputLinks [ param ] : - self.outputLinks [ param ].append ( link ) - # - # detachInputParam - # - def detachInputParam ( self, param ) : - # - removedLink = None - if DEBUG_MODE : print ">> Node::detachInputParam param = %s" % param.name - if param in self.inputLinks.keys () : - removedLink = self.inputLinks.pop ( param ) - return removedLink - # - # detachOutputParam - # - def detachOutputParam ( self, param ) : - # - removedLinks = [] - if param in self.outputLinks.keys () : - outputLinks = self.outputLinks [ param ] - for link in outputLinks : - removedLinks.append ( link ) - self.outputLinks.pop ( param ) - return removedLinks - # - # detachOutputParamFromLink - # - def detachOutputParamFromLink ( self, param, link ) : - # - removedLink = None - if param in self.outputLinks.keys () : - outputLinks = self.outputLinks [ param ] - if link in outputLinks : - removedLink = link - outputLinks.remove ( link ) - return removedLink - # - # isInputParamLinked - # - def isInputParamLinked ( self, param ) : return param in self.inputLinks.keys () - # - # isOutputParamLinked - # - def isOutputParamLinked ( self, param ) : return param in self.outputLinks.keys () - # - # getLinkedSrcNode - # - def getLinkedSrcNode ( self, param ) : - # returns node linked to input parameter param, - # skipping all ConnectorNode - # - #if DEBUG_MODE : print '* getLinkedSrcNode node = %s param = %s' % ( self.label, param.label ) - srcNode = None - srcParam = None - if self.isInputParamLinked ( param ) : - #if DEBUG_MODE : print '* isInputParamLinked' - link = self.inputLinks [ param ] - if link.srcNode.type == 'connector' : - if len ( link.srcNode.inputParams ) : - firstParam = link.srcNode.inputParams [0] - ( srcNode, srcParam ) = link.srcNode.getLinkedSrcNode ( firstParam ) - else : - if DEBUG_MODE : print '* no inputParams at connector %s' % ( link.srcNode.label ) - else : - srcNode = link.srcNode - srcParam = link.srcParam - return ( srcNode, srcParam ) - # - # getLinkedDstNodes - # - def getLinkedDstNodes ( self, param, dstConnections = [] ) : - # returns nodes linked to output parameter param, - # skipping all ConnectorNode - # - #if DEBUG_MODE : print '*** getLinkedDstNodese node = %s param = %s' % ( self.label, param.label ) - dstNode = None - dstParam = None - # dstConnections = [] - if self.isOutputParamLinked ( param ) : - #if DEBUG_MODE : print '* isOutputParamLinked' - dstLinks = self.getOutputLinks ( param ) - for link in dstLinks : - if link.dstNode.type == 'connector' : - #if DEBUG_MODE : print '* link.dstNode.type == connector' - connectorOutputParams = link.dstNode.outputParams - if len ( connectorOutputParams ) > 0 : - for connectorOutputParam in connectorOutputParams : - connectorDstConnections = [] - retList = link.dstNode.getLinkedDstNodes ( connectorOutputParam, connectorDstConnections ) - for ( retNode, retParam ) in retList : - dstConnections.append ( ( retNode, retParam ) ) - else : - if DEBUG_MODE : print '* no outputParams at connector %s' % ( link.dstNode.label ) - else : - dstNode = link.dstNode - dstParam = link.dstParam - dstConnections.append ( ( dstNode, dstParam ) ) - return dstConnections - - # - # removeParam - # - def removeParam ( self, param ) : - # - removedLinks = [] - if param.isInput : - link = self.detachInputParam ( param ) - if link is not None : removedLinks.append ( link ) - self.inputParams.remove ( param ) - else : - removedLinks = self.detachOutputParam ( param ) - self.outputParams.remove ( param ) - if self.event_code : - if 'ParamRemoved' in self.event_code.keys () : - exec ( self.event_code [ 'ParamRemoved' ], { 'param' : param, 'self' : self } ) - return removedLinks - # - # getInputParamByName - # - def getInputParamByName ( self, name ) : - # - result = None - for param in self.inputParams : - if param.name == name : - result = param - break - return result - # - # getOutputParamByName - # - def getOutputParamByName ( self, name ) : - # - result = None - for param in self.outputParams : - if param.name == name : - result = param - break - return result - # - # getInputParamValueByName - # - def getInputParamValueByName ( self, name, CodeOnly = False ) : - # - result = None - srcNode = srcParam = None - param = self.getInputParamByName ( name ) - ( srcNode, srcParam ) = self.getLinkedSrcNode ( param ) - if srcNode is not None : - # computation may be skipped if we need only value - #if compute : - srcNode.computeNode ( CodeOnly ) - if self.computed_code is not None : - self.computed_code += srcNode.computed_code - result = srcNode.parseGlobalVars ( srcParam.getValueToStr () ) - else : - result = param.getValueToStr () - - return result - # - # return common list for input and output parameters - # - def getParamsList ( self ) : - # - params = self.inputParams + self.outputParams - return params - # - # getParamsNames - # - def getParamsNames ( self ) : - # - names = [] - for pm in self.getParamsList () : names.append ( pm.name ) - return names - # - # getParamsLabels - # - def getParamsLabels ( self ) : - # - labels = [] - for pm in self.getParamsList () : labels.append ( pm.label ) - return labels - # - # getInputLinks - # - def getInputLinks ( self ) : - # - inputLinks = [] - for link in self.inputLinks.values () : - inputLinks.append ( link ) - return inputLinks - # - # getOutputLinks - # - def getOutputLinks ( self, param = None ) : - # - outputLinks = [] - for link_list in self.outputLinks.values () : - for link in link_list : - if param is not None : - if link.srcParam != param : - continue - outputLinks.append ( link ) - return outputLinks - # - # getInputLinkByID - # - def getInputLinkByID ( self, id ) : - # - result = None - for link in self.getInputLinks () : - if link.id == id : - result = link - break - return result - # - # getOutputLinkByID - # - def getOutputLinkByID ( self, id ) : - # - result = None - for link in self.getOutputLinks () : - if link.id == id : - result = link - break - return result - # - # renameParamName - # - def renameParamName ( self, param, newName ) : - # assign new unique name to param - from meCommon import getUniqueName - param.name = getUniqueName ( newName, self.getParamsNames() ) - return param.name - # - # renameParamLabel - # - def renameParamLabel ( self, param, newLabel ) : - # - oldLabel = param.label - if DEBUG_MODE : print ">> Node( %s ).renameParamLabel oldLabel = %s newLabel = %s" % ( self.label, oldLabel, newLabel ) - if newLabel == '' : newLabel = self.param.name - # assign new unique label to param - from meCommon import getUniqueName - param.label = getUniqueName ( newLabel, self.getParamsLabels () ) - if self.event_code : - if 'ParamLabelRenamed' in self.event_code.keys () : - exec ( self.event_code [ 'ParamLabelRenamed' ], { 'param' : param, 'self' : self, 'oldLabel' : oldLabel } ) - - return param.label - # - # onParamChanged - # - def onParamChanged ( self, param ) : - # - if DEBUG_MODE : print ">> Node: onParamChanged node = %s param = %s" % ( self.label, param.name ) - pass - #self.emit( QtCore.SIGNAL( 'onNodeParamChanged(QObject,QObject)' ), self, param ) - # - # getLabel - # - def getLabel ( self ) : return self.label - # - # getName - # - def getName ( self ) : return self.label - # - # getNodenetName - # - def getNodenetName ( self ) : return self.nodenet.getName () - # - # getInstanceName - # - def getInstanceName ( self ) : return getParsedLabel ( self.label ) - # - # getParamName - # - def getParamName ( self, param ) : - # - if param.isRibParam or param.provider == 'attribute': - paramName = param.name - elif param.provider == 'primitive' : - paramName = getParsedLabel ( param.label ) - else : - paramName = self.getInstanceName () + '_' + getParsedLabel ( param.label ) - return paramName - # - # getParamDeclaration - # - def getParamDeclaration ( self, param ) : - # - result = '' - result += param.typeToStr () + ' ' - result += self.getParamName ( param ) + ' = ' - result += param.getValueToStr () + ';\n' - return result - # - # parseFromXML - # - def parseFromXML ( self, xml_node ) : - # - id_node = xml_node.attributes ().namedItem ( 'id' ) - if not id_node.isNull () : - self.id = int ( id_node.nodeValue () ) - else : - if DEBUG_MODE : print '>> Node::parseFromXML id is None' - - self.name = str ( xml_node.attributes ().namedItem ( 'name' ).nodeValue () ) - self.label = str ( xml_node.attributes ().namedItem ( 'label' ).nodeValue () ) - if self.label == '' : self.label = self.name - #print '-> parsing from XML node name= %s label= %s' % ( self.name, self.label ) - - self.author = str ( xml_node.attributes ().namedItem ( 'author' ).nodeValue () ) - self.type = str ( xml_node.attributes ().namedItem ( 'type' ).nodeValue () ) - # - # Assume that all nodes without specified type, have to be 'rsl_code' - # - if self.type == '' or self.type is None : self.type = 'rsl_code' - - help_tag = xml_node.namedItem ( 'help' ) - if not help_tag.isNull() : - self.help = help_tag.toElement ().text () - #print '-> help= %s' % self.help - self.icon = str ( xml_node.attributes ().namedItem ( 'icon' ).nodeValue () ) + # + # Define signals for PyQt5 + # + if QtCore.QT_VERSION >= 50000 : + # + nodeUpdated = QtCore.pyqtSignal ( [QtCore.QObject] ) + nodeParamsUpdated = QtCore.pyqtSignal ( [QtCore.QObject] ) + # + id = 0 + # + # __init__ + # + def __init__ ( self, xml_node = None, nodenet = None ) : + # + QtCore.QObject.__init__ ( self ) + + self.id = None + self.name = None + self.label = None + self.type = None + + self.author = None + self.help = None + self.icon = None + + self.master = None + + self.code = None # Node code (RSL, RIB, ... ) + self.control_code = None # python code executed before node computation + self.computed_code = None # code collected after compute on all connected nodes + + self.event_code = {} + #self.event_code [ 'ParamLabelRenamed' ] = None + #self.event_code [ 'ParamAdded' ] = None + #self.event_code [ 'ParamRemoved' ] = None + + self.display = True + + self.computedInputParams = None + self.computedOutputParams = None + self.computedLocalParams = None + self.computedIncludes = None + self.computedLocals = None + self.computedCode = None + + #self.previewCode = None + + self.inputParams = [] + self.outputParams = [] + self.internals = [] + self.includes = [] + + self.inputLinks = {} + self.outputLinks = {} + + self.childs = set() + + self.nodenet = nodenet + + # position from GfxNode + self.offset = ( 0, 0 ) + + if xml_node != None : + self.parseFromXML ( xml_node ) + # + # __del__ + # + def __del__ ( self ) : + # + if DEBUG_MODE : print '>> Node( %s ).__del__' % self.label + # + # build + # + @classmethod + def build ( cls ) : + # set unique id while building + node = cls () + Node.id += 1 + node.id = Node.id + return node + # + # copy + # + def copy ( self ) : assert 0, 'copy needs to be implemented!' + # + # updateNode + # + def updateNode ( self ) : + # + if DEBUG_MODE : print '>> Node( %s ).updateNode' % self.label + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( 'nodeUpdated' ), self ) + else : + self.nodeUpdated.emit ( self ) + # + # updateNodeParams + # + def updateNodeParams ( self ) : + # + if DEBUG_MODE : print '>> Node( %s ).updateNodeParams' % self.label + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( 'nodeParamsUpdated' ), self ) + else : + self.nodeParamsUpdated.emit ( self ) + # + # addChild + # + def addChild ( self, node ) : self.childs.add ( node ) + # + # removeChild + # + def removeChild ( self, node ) : + # + if node in self.childs : + self.childs.remove ( node ) + if DEBUG_MODE : print '** Node(%s).removeChild %s' % ( self.label, node.label ) + else : + if DEBUG_MODE : print '!! Node(%s).removeChild child %s is not in the list' % ( self.label, node.label ) + # + # printInfo + # + def printInfo ( self ) : + # + print ':: Node (id = %d) label = %s' % ( self.id, self.label ) + print '** Node inputLinks:' + for param in self.inputLinks.keys () : + print '\t* param: %s (%s) linked to ' % ( param.name, param.label ) + self.inputLinks [ param ].printInfo () + print '** Node outputLinks:' + #print '*****', self.outputLinks + for param in self.outputLinks.keys () : + print '\t* param: %s (%s) linked to ' % ( param.name, param.label ) + linklist = self.outputLinks [ param ] + for link in linklist : + link.printInfo () + print '** Node children:' + for child in self.childs : + print '\t* %s' % child.label + # + # addInputParam + # + def addInputParam ( self, param ) : + # + param.isInput = True + # to be sure that name and label is unique + if param.name in self.getParamsNames () : self.renameParamName ( param, param.name ) + if param.label in self.getParamsLabels () : self.renameParamLabel ( param, param.label ) + self.inputParams.append ( param ) + if self.event_code : + if 'ParamAdded' in self.event_code.keys () : + exec ( self.event_code [ 'ParamAdded' ], { 'param' : param, 'self' : self } ) + # + # addOutputParam + # + def addOutputParam ( self, param ) : + # + param.isInput = False + # to be sure that name and label is unique + if param.name in self.getParamsNames () : self.renameParamName ( param, param.name ) + if param.label in self.getParamsLabels () : self.renameParamLabel ( param, param.label ) + self.outputParams.append ( param ) + if self.event_code : + if 'ParamAdded' in self.event_code.keys () : + exec ( self.event_code [ 'ParamAdded' ], { 'param' : param, 'self' : self } ) + # + # addInternal + # + def addInternal ( self, newName ) : + #print '--> add internal: %s' % internal + internal = newName + if internal != '' : + from meCommon import getUniqueName + internal = getUniqueName ( newName, self.internals ) + self.internals.append ( internal ) + return internal + # + # addInclude + # + def addInclude ( self, newName ) : + #print '--> add include: %s' % include + include = newName + if include != '' : + from meCommon import getUniqueName + include = getUniqueName ( newName, self.includes ) + self.includes.append ( include ) + return include + # + # attachInputParamToLink + # + def attachInputParamToLink ( self, param, link ) : + # + self.inputLinks [ param ] = link + # + # attachOutputParamToLink + # + def attachOutputParamToLink ( self, param, link ) : + # + #if DEBUG_MODE : print ">> Node::attachOutputParamToLink param = %s" % param.name + if not param in self.outputLinks.keys () : + self.outputLinks [ param ] = [] + if not link in self.outputLinks [ param ] : + self.outputLinks [ param ].append ( link ) + # + # detachInputParam + # + def detachInputParam ( self, param ) : + # + removedLink = None + if DEBUG_MODE : print ">> Node::detachInputParam param = %s" % param.name + if param in self.inputLinks.keys () : + removedLink = self.inputLinks.pop ( param ) + return removedLink + # + # detachOutputParam + # + def detachOutputParam ( self, param ) : + # + removedLinks = [] + if param in self.outputLinks.keys () : + outputLinks = self.outputLinks [ param ] + for link in outputLinks : + removedLinks.append ( link ) + self.outputLinks.pop ( param ) + return removedLinks + # + # detachOutputParamFromLink + # + def detachOutputParamFromLink ( self, param, link ) : + # + removedLink = None + if param in self.outputLinks.keys () : + outputLinks = self.outputLinks [ param ] + if link in outputLinks : + removedLink = link + outputLinks.remove ( link ) + return removedLink + # + # isInputParamLinked + # + def isInputParamLinked ( self, param ) : return param in self.inputLinks.keys () + # + # isOutputParamLinked + # + def isOutputParamLinked ( self, param ) : return param in self.outputLinks.keys () + # + # getLinkedSrcNode + # + def getLinkedSrcNode ( self, param ) : + # returns node linked to input parameter param, + # skipping all ConnectorNode + # + #if DEBUG_MODE : print '* getLinkedSrcNode node = %s param = %s' % ( self.label, param.label ) + srcNode = None + srcParam = None + if self.isInputParamLinked ( param ) : + #if DEBUG_MODE : print '* isInputParamLinked' + link = self.inputLinks [ param ] + if link.srcNode.type == 'connector' : + if len ( link.srcNode.inputParams ) : + firstParam = link.srcNode.inputParams [0] + ( srcNode, srcParam ) = link.srcNode.getLinkedSrcNode ( firstParam ) + else : + if DEBUG_MODE : print '* no inputParams at connector %s' % ( link.srcNode.label ) + else : + srcNode = link.srcNode + srcParam = link.srcParam + return ( srcNode, srcParam ) + # + # getLinkedDstNodes + # + def getLinkedDstNodes ( self, param, dstConnections = [] ) : + # returns nodes linked to output parameter param, + # skipping all ConnectorNode + # + #if DEBUG_MODE : print '*** getLinkedDstNodese node = %s param = %s' % ( self.label, param.label ) + dstNode = None + dstParam = None + # dstConnections = [] + if self.isOutputParamLinked ( param ) : + #if DEBUG_MODE : print '* isOutputParamLinked' + dstLinks = self.getOutputLinks ( param ) + for link in dstLinks : + if link.dstNode.type == 'connector' : + #if DEBUG_MODE : print '* link.dstNode.type == connector' + connectorOutputParams = link.dstNode.outputParams + if len ( connectorOutputParams ) > 0 : + for connectorOutputParam in connectorOutputParams : + connectorDstConnections = [] + retList = link.dstNode.getLinkedDstNodes ( connectorOutputParam, connectorDstConnections ) + for ( retNode, retParam ) in retList : + dstConnections.append ( ( retNode, retParam ) ) + else : + if DEBUG_MODE : print '* no outputParams at connector %s' % ( link.dstNode.label ) + else : + dstNode = link.dstNode + dstParam = link.dstParam + dstConnections.append ( ( dstNode, dstParam ) ) + return dstConnections + # + # removeParam + # + def removeParam ( self, param ) : + # + removedLinks = [] + if param.isInput : + link = self.detachInputParam ( param ) + if link is not None : removedLinks.append ( link ) + self.inputParams.remove ( param ) + else : + removedLinks = self.detachOutputParam ( param ) + self.outputParams.remove ( param ) + if self.event_code : + if 'ParamRemoved' in self.event_code.keys () : + exec ( self.event_code [ 'ParamRemoved' ], { 'param' : param, 'self' : self } ) + return removedLinks + # + # getInputParamByName + # + def getInputParamByName ( self, name ) : + # + result = None + for param in self.inputParams : + if param.name == name : + result = param + break + return result + # + # getOutputParamByName + # + def getOutputParamByName ( self, name ) : + # + result = None + for param in self.outputParams : + if param.name == name : + result = param + break + return result + # + # getInputParamValueByName + # + def getInputParamValueByName ( self, name, CodeOnly = False ) : + # + result = None + srcNode = srcParam = None + param = self.getInputParamByName ( name ) + ( srcNode, srcParam ) = self.getLinkedSrcNode ( param ) + if srcNode is not None : + # computation may be skipped if we need only value + #if compute : + srcNode.computeNode ( CodeOnly ) + if self.computed_code is not None : + self.computed_code += srcNode.computed_code + result = srcNode.parseGlobalVars ( srcParam.getValueToStr () ) + else : + result = param.getValueToStr () + + return result + # + # return common list for input and output parameters + # + def getParamsList ( self ) : + # + params = self.inputParams + self.outputParams + return params + # + # getParamsNames + # + def getParamsNames ( self ) : + # + names = [] + for pm in self.getParamsList () : names.append ( pm.name ) + return names + # + # getParamsLabels + # + def getParamsLabels ( self ) : + # + labels = [] + for pm in self.getParamsList () : labels.append ( pm.label ) + return labels + # + # getInputLinks + # + def getInputLinks ( self ) : + # + inputLinks = [] + for link in self.inputLinks.values () : + inputLinks.append ( link ) + return inputLinks + # + # getOutputLinks + # + def getOutputLinks ( self, param = None ) : + # + outputLinks = [] + for link_list in self.outputLinks.values () : + for link in link_list : + if param is not None : + if link.srcParam != param : + continue + outputLinks.append ( link ) + return outputLinks + # + # getInputLinkByID + # + def getInputLinkByID ( self, id ) : + # + result = None + for link in self.getInputLinks () : + if link.id == id : + result = link + break + return result + # + # getOutputLinkByID + # + def getOutputLinkByID ( self, id ) : + # + result = None + for link in self.getOutputLinks () : + if link.id == id : + result = link + break + return result + # + # renameParamName + # + def renameParamName ( self, param, newName ) : + # assign new unique name to param + from meCommon import getUniqueName + param.name = getUniqueName ( newName, self.getParamsNames() ) + return param.name + # + # renameParamLabel + # + def renameParamLabel ( self, param, newLabel ) : + # + oldLabel = param.label + if DEBUG_MODE : print ">> Node( %s ).renameParamLabel oldLabel = %s newLabel = %s" % ( self.label, oldLabel, newLabel ) + if newLabel == '' : newLabel = self.param.name + # assign new unique label to param + from meCommon import getUniqueName + param.label = getUniqueName ( newLabel, self.getParamsLabels () ) + if self.event_code : + if 'ParamLabelRenamed' in self.event_code.keys () : + exec ( self.event_code [ 'ParamLabelRenamed' ], { 'param' : param, 'self' : self, 'oldLabel' : oldLabel } ) + + return param.label + # + # onParamChanged + # + def onParamChanged ( self, param ) : + # + if DEBUG_MODE : print ">> Node: onParamChanged node = %s param = %s" % ( self.label, param.name ) + pass + #self.emit( QtCore.SIGNAL( 'onNodeParamChanged(QObject,QObject)' ), self, param ) + # + # getLabel + # + def getLabel ( self ) : return self.label + # + # getName + # + def getName ( self ) : return self.label + # + # getNodenetName + # + def getNodenetName ( self ) : return self.nodenet.getName () + # + # getInstanceName + # + def getInstanceName ( self ) : return getParsedLabel ( self.label ) + # + # getParamName + # + def getParamName ( self, param ) : + # + if param.isRibParam or param.provider == 'attribute': + paramName = param.name + elif param.provider == 'primitive' : + paramName = getParsedLabel ( param.label ) + else : + paramName = self.getInstanceName () + '_' + getParsedLabel ( param.label ) + return paramName + # + # getParamDeclaration + # + def getParamDeclaration ( self, param ) : + # + result = '' + result += param.typeToStr () + ' ' + result += self.getParamName ( param ) + ' = ' + result += param.getValueToStr () + ';\n' + return result + # + # parseFromXML + # + def parseFromXML ( self, xml_node ) : + # + id_node = xml_node.attributes ().namedItem ( 'id' ) + if not id_node.isNull () : + self.id = int ( id_node.nodeValue () ) + else : + if DEBUG_MODE : print '>> Node::parseFromXML id is None' + + self.name = str ( xml_node.attributes ().namedItem ( 'name' ).nodeValue () ) + self.label = str ( xml_node.attributes ().namedItem ( 'label' ).nodeValue () ) + if self.label == '' : self.label = self.name + #print '-> parsing from XML node name= %s label= %s' % ( self.name, self.label ) + + self.author = str ( xml_node.attributes ().namedItem ( 'author' ).nodeValue () ) + self.type = str ( xml_node.attributes ().namedItem ( 'type' ).nodeValue () ) + # + # Assume that all nodes without specified type, have to be 'rsl_code' + # + if self.type == '' or self.type is None : self.type = 'rsl_code' + + help_tag = xml_node.namedItem ( 'help' ) + if not help_tag.isNull() : + self.help = help_tag.toElement ().text () + #print '-> help= %s' % self.help + self.icon = str ( xml_node.attributes ().namedItem ( 'icon' ).nodeValue () ) # from core.nodeParam import * # createParamTable = { 'float':FloatNodeParam @@ -545,380 +556,380 @@ def parseFromXML ( self, xml_node ) : # ,'image':ImageNodeParam # } - input_tag = xml_node.namedItem ( 'input' ) - if not input_tag.isNull () : - xml_paramList = input_tag.toElement ().elementsByTagName ( 'property' ) - for i in range ( 0, xml_paramList.length () ) : - xml_param = xml_paramList.item ( i ) - #param_type = str( xml_param.attributes().namedItem( 'type' ).nodeValue() ) - # - # some parameters (String, Color, Point, Vector, Normal, Matrix ...) - # have different string interpretation in RIB - # - isRibParam = ( self.type in VALID_RIB_NODE_TYPES ) - param = createParamFromXml ( xml_param, isRibParam, True ) # #param.isInput = True - #param = createParamTable[ param_type ]( xml_param, isRibParam ) - #param.isInput = True - self.addInputParam ( param ) - #print '--> param = %s value = %s (isRibParam = %d )' % ( param.label, param.getValueToStr(), isRibParam ) - - output_tag = xml_node.namedItem ( 'output' ) - if not output_tag.isNull () : - xml_paramList = output_tag.toElement ().elementsByTagName ( 'property' ) - for i in range ( 0, xml_paramList.length () ) : - xml_param = xml_paramList.item ( i ) - #param_type = str( xml_param.attributes().namedItem( 'type' ).nodeValue() ) - # - # some parameters (Color, Point, Vector, Normal, Matrix ...) - # have different string interpretation in RIB - # - isRibParam = ( self.type in VALID_RIB_NODE_TYPES ) - param = createParamFromXml ( xml_param, isRibParam, False ) # #param.isInput = False - #param = createParamTable[ param_type ]( xml_param, isRibParam ) - #param.isInput = False - self.addOutputParam ( param ) - #print '--> param = %s value = %s' % ( param.label, param.getValueToStr() ) - - internal_tag = xml_node.namedItem ( 'internal' ) - if not internal_tag.isNull () : - xml_internalList = internal_tag.toElement ().elementsByTagName ( 'variable' ) - for i in range ( 0, xml_internalList.length () ) : - var_tag = xml_internalList.item ( i ) - var = str ( var_tag.attributes ().namedItem ( 'name' ).nodeValue () ) - self.addInternal ( var ) - - include_tag = xml_node.namedItem ( 'include' ) - if not include_tag.isNull () : - xml_includeList = include_tag.toElement ().elementsByTagName ( 'file' ) - for i in range ( 0, xml_includeList.length () ) : - inc_tag = xml_includeList.item ( i ) - inc = str ( inc_tag.attributes ().namedItem ( 'name' ).nodeValue () ) - self.addInclude ( inc ) - - offset_tag = xml_node.namedItem ( 'offset' ) - if not offset_tag.isNull() : - x = float ( offset_tag.attributes ().namedItem ( 'x' ).nodeValue () ) - y = float ( offset_tag.attributes ().namedItem ( 'y' ).nodeValue () ) - self.offset = ( x, y ) - - control_code_tag = xml_node.namedItem ( 'control_code' ) - if not control_code_tag.isNull () : - code_str = str ( control_code_tag.toElement ().text () ) - if code_str.lstrip () == '' : code_str = None - self.control_code = code_str - else : - # for temp. backward compatibility - control_code_tag = xml_node.namedItem ( 'param_code' ) - if not control_code_tag.isNull() : - code_str = str ( control_code_tag.toElement ().text () ) - if code_str.lstrip () == '' : code_str = None - self.control_code = code_str - - code_tag = xml_node.namedItem ( 'code' ) - if not code_tag.isNull () : - code_str = str ( code_tag.toElement ().text () ) - if code_str.lstrip () == '' : code_str = None - self.code = code_str - - event_code_tag = xml_node.namedItem ( 'event_code' ) - if not event_code_tag.isNull () : - xml_handlerList = event_code_tag.toElement ().elementsByTagName ( 'handler' ) - for i in range ( 0, xml_handlerList.length () ) : - handler_tag = xml_handlerList.item ( i ) - handler_name = str ( handler_tag.attributes ().namedItem ( 'name' ).nodeValue () ) - code_str = str ( handler_tag.toElement ().text () ).lstrip () - if code_str == '' : code_str = None - self.event_code [ handler_name ] = code_str - #print '** handler = %s' % handler_name - #print '** handler code :' - #print self.event_code [ handler_name ] - # - # parseToXML - # - def parseToXML ( self, dom ) : - # - xml_node = dom.createElement ( 'node' ) - if DEBUG_MODE : print '>> Node::parseToXML (id = %d)' % ( self.id ) - if self.id is None : - if DEBUG_MODE : print '>> Node::parseToXML id is None' - xml_node.setAttribute ( 'id', str( self.id ) ) - xml_node.setAttribute ( 'name', self.name ) - if self.label != None : xml_node.setAttribute ( 'label', self.label ) - if self.type != None : xml_node.setAttribute ( 'type', self.type ) - if self.author != None : xml_node.setAttribute ( 'author', self.author ) - if self.icon != None : xml_node.setAttribute ( 'icon', self.icon ) - - if self.help != None : - # append node help (short description) - help_tag = dom.createElement ( 'help' ) - help_text = dom.createTextNode ( self.help ) - help_tag.appendChild ( help_text ) - xml_node.appendChild ( help_tag ) - - input_tag = dom.createElement ( 'input' ) - for param in self.inputParams : - #print '--> parsing param to XML: %s ...' % param.name - input_tag.appendChild ( param.parseToXML ( dom ) ) - xml_node.appendChild ( input_tag ) - - output_tag = dom.createElement ( 'output' ) - for param in self.outputParams : - #print '--> parsing param to XML: %s ...' % param.name - output_tag.appendChild ( param.parseToXML ( dom ) ) - xml_node.appendChild ( output_tag ) - - internal_tag = dom.createElement ( 'internal' ) - for var in self.internals : - var_tag = dom.createElement( 'variable' ) - var_tag.setAttribute ( 'name', var ) - internal_tag.appendChild ( var_tag ) - xml_node.appendChild ( internal_tag ) - - include_tag = dom.createElement ( 'include' ) - for inc in self.includes : - inc_tag = dom.createElement( 'file' ) - inc_tag.setAttribute ( 'name', inc ) - include_tag.appendChild ( inc_tag ) - xml_node.appendChild ( include_tag ) - - if self.control_code != None : - control_code_tag = dom.createElement ( 'control_code' ) - control_code_data = dom.createCDATASection ( self.control_code ) - control_code_tag.appendChild ( control_code_data ) - xml_node.appendChild ( control_code_tag ) - - if self.code != None : - code_tag = dom.createElement ( 'code' ) - code_data = dom.createCDATASection ( self.code ) - code_tag.appendChild ( code_data ) - xml_node.appendChild ( code_tag ) - - if self.event_code : - event_code_tag = dom.createElement ( 'event_code' ) - print '*** write event_code' - for key in self.event_code.keys () : - print '*** write handler "%s"' % key - handler_tag = dom.createElement( 'handler' ) - handler_tag.setAttribute ( 'name', key ) - event_code_tag.appendChild ( handler_tag ) - handler_data = dom.createCDATASection ( self.event_code [ key ] ) - handler_tag.appendChild ( handler_data ) - xml_node.appendChild ( event_code_tag ) - - if self.offset != None : - ( x, y ) = self.offset - offset_tag = dom.createElement ( 'offset' ) - offset_tag.setAttribute ( 'x', x ) - offset_tag.setAttribute ( 'y', y ) - xml_node.appendChild ( offset_tag ) - - return xml_node - # - # getHeader - # - def getHeader ( self ) : assert 0, 'getHeader needs to be implemented!' - - # - # getComputedCode - # - def getComputedCode ( self, CodeOnly = False ) : assert 0, 'getComputedCode needs to be implemented!' - - # - # computeNode - # - def computeNode ( self, CodeOnly = False ) : assert 0, 'computeNode needs to be implemented!' - - # - # execControlCode - # - def execControlCode ( self ) : - # - if self.control_code != None : - control_code = self.control_code.lstrip () - if control_code != '' : - exec control_code - # - # parseGlobalVars - # - def parseGlobalVars ( self, parsedStr ) : - # - resultStr = '' - parserStart = 0 - parserPos = 0 - - while parserPos != -1 : - parserPos = str ( parsedStr ).find ( '$', parserStart ) - if parserPos != -1 : - # - if parserPos != 0 : - resultStr += parsedStr [ parserStart : parserPos ] - - # check global vars first - if parsedStr [ ( parserPos + 1 ) : ( parserPos + 2 ) ] == '{' : - globStart = parserPos + 2 - parserPos = str( parsedStr ).find ( '}', globStart ) - global_var_name = parsedStr [ globStart : ( parserPos ) ] - - #print '-> found global var %s' % global_var_name - - if global_var_name in app_global_vars.keys () : - resultStr += app_global_vars [ global_var_name ] - elif global_var_name in node_global_vars.keys () : - if global_var_name == 'INSTANCENAME' : resultStr += self.getInstanceName () - elif global_var_name == 'NODELABEL' : resultStr += self.getLabel () - elif global_var_name == 'NODENAME' : resultStr += self.getName () - elif global_var_name == 'PARAMS' : resultStr += self.getComputedInputParams () + self.getComputedOutputParams () - elif global_var_name == 'NODENETNAME' : resultStr += self.getNodenetName () - elif global_var_name == 'OUTPUTNAME' : resultStr += normPath ( os.path.join ( app_global_vars [ 'TempPath' ], self.getNodenetName () + '_' + self.getLabel () ) ) - else : - # keep $ sign for otheer, non ${...} cases - resultStr += '$' - - #print 'parserPos = %d parserStart = %d' % ( parserPos, parserStart ) - if parserPos != -1 : - parserStart = parserPos + 1 - - resultStr += parsedStr [ parserStart: ] - - return resultStr - # - # copySetup - # - def copySetup ( self, newNode ) : - # - if DEBUG_MODE : print '>> Node( %s ).copySetup ' % self.label - - newNode.id = self.id - - name = self.name - if name is None : name = str ( self.type ) - - newNode.name = name - - label = self.label - if label is None : label = name - - newNode.label = label - newNode.type = self.type - newNode.author = self.author - newNode.help = self.help - newNode.icon = self.icon - newNode.master = self.master - newNode.display = self.display - - newNode.offset = self.offset - - import copy - newNode.code = copy.copy ( self.code ) - newNode.control_code = copy.copy ( self.control_code ) - newNode.event_code = copy.copy ( self.event_code ) - #self.computed_code = None - - newNode.internals = copy.copy ( self.internals ) - newNode.includes = copy.copy ( self.includes ) - - newNode.inputLinks = {} - newNode.outputLinks = {} - - #newNode.childs = set () - print '***newNode.childs: ', newNode.childs - #newNode.childs = copy.copy ( self.childs ) - - newNode.inputParams = [] - for param in self.inputParams : newNode.inputParams.append ( param.copy () ) - - newNode.outputParams = [] - for param in self.outputParams : newNode.outputParams.append ( param.copy () ) - - return newNode - # - # save Node to .xml document - # - def save ( self ) : - # - result = False - - dom = QtXml.QDomDocument ( self.name ) - xml_code = self.parseToXML ( dom ) - dom.appendChild ( xml_code ) - - file = QFile ( self.master ) - if file.open ( QtCore.QIODevice.WriteOnly ) : - if file.write ( dom.toByteArray () ) != -1 : - result = True - file.close() - return result - # - # getChildrenSet - # - def getChildrenSet ( self, children_set = set () ) : - # - for node in self.childs : - children_set = node.getChildrenSet ( children_set ) - children_set.add ( node ) - return children_set - # - # getChildrenList - # - def getChildrenList ( self, children_list = [] ) : - # - for node in self.childs : - children_list = node.getChildrenList ( children_list ) - if node not in children_list : - children_list.append ( node ) - - return children_list + input_tag = xml_node.namedItem ( 'input' ) + if not input_tag.isNull () : + xml_paramList = input_tag.toElement ().elementsByTagName ( 'property' ) + for i in range ( 0, xml_paramList.length () ) : + xml_param = xml_paramList.item ( i ) + #param_type = str( xml_param.attributes().namedItem( 'type' ).nodeValue() ) + # + # some parameters (String, Color, Point, Vector, Normal, Matrix ...) + # have different string interpretation in RIB + # + isRibParam = ( self.type in VALID_RIB_NODE_TYPES ) + param = createParamFromXml ( xml_param, isRibParam, True ) # #param.isInput = True + #param = createParamTable[ param_type ]( xml_param, isRibParam ) + #param.isInput = True + self.addInputParam ( param ) + #print '--> param = %s value = %s (isRibParam = %d )' % ( param.label, param.getValueToStr(), isRibParam ) + + output_tag = xml_node.namedItem ( 'output' ) + if not output_tag.isNull () : + xml_paramList = output_tag.toElement ().elementsByTagName ( 'property' ) + for i in range ( 0, xml_paramList.length () ) : + xml_param = xml_paramList.item ( i ) + #param_type = str( xml_param.attributes().namedItem( 'type' ).nodeValue() ) + # + # some parameters (Color, Point, Vector, Normal, Matrix ...) + # have different string interpretation in RIB + # + isRibParam = ( self.type in VALID_RIB_NODE_TYPES ) + param = createParamFromXml ( xml_param, isRibParam, False ) # #param.isInput = False + #param = createParamTable[ param_type ]( xml_param, isRibParam ) + #param.isInput = False + self.addOutputParam ( param ) + #print '--> param = %s value = %s' % ( param.label, param.getValueToStr() ) + + internal_tag = xml_node.namedItem ( 'internal' ) + if not internal_tag.isNull () : + xml_internalList = internal_tag.toElement ().elementsByTagName ( 'variable' ) + for i in range ( 0, xml_internalList.length () ) : + var_tag = xml_internalList.item ( i ) + var = str ( var_tag.attributes ().namedItem ( 'name' ).nodeValue () ) + self.addInternal ( var ) + + include_tag = xml_node.namedItem ( 'include' ) + if not include_tag.isNull () : + xml_includeList = include_tag.toElement ().elementsByTagName ( 'file' ) + for i in range ( 0, xml_includeList.length () ) : + inc_tag = xml_includeList.item ( i ) + inc = str ( inc_tag.attributes ().namedItem ( 'name' ).nodeValue () ) + self.addInclude ( inc ) + + offset_tag = xml_node.namedItem ( 'offset' ) + if not offset_tag.isNull() : + x = float ( offset_tag.attributes ().namedItem ( 'x' ).nodeValue () ) + y = float ( offset_tag.attributes ().namedItem ( 'y' ).nodeValue () ) + self.offset = ( x, y ) + + control_code_tag = xml_node.namedItem ( 'control_code' ) + if not control_code_tag.isNull () : + code_str = str ( control_code_tag.toElement ().text () ) + if code_str.lstrip () == '' : code_str = None + self.control_code = code_str + else : + # for temp. backward compatibility + control_code_tag = xml_node.namedItem ( 'param_code' ) + if not control_code_tag.isNull() : + code_str = str ( control_code_tag.toElement ().text () ) + if code_str.lstrip () == '' : code_str = None + self.control_code = code_str + + code_tag = xml_node.namedItem ( 'code' ) + if not code_tag.isNull () : + code_str = str ( code_tag.toElement ().text () ) + if code_str.lstrip () == '' : code_str = None + self.code = code_str + + event_code_tag = xml_node.namedItem ( 'event_code' ) + if not event_code_tag.isNull () : + xml_handlerList = event_code_tag.toElement ().elementsByTagName ( 'handler' ) + for i in range ( 0, xml_handlerList.length () ) : + handler_tag = xml_handlerList.item ( i ) + handler_name = str ( handler_tag.attributes ().namedItem ( 'name' ).nodeValue () ) + code_str = str ( handler_tag.toElement ().text () ).lstrip () + if code_str == '' : code_str = None + self.event_code [ handler_name ] = code_str + #print '** handler = %s' % handler_name + #print '** handler code :' + #print self.event_code [ handler_name ] + # + # parseToXML + # + def parseToXML ( self, dom ) : + # + xml_node = dom.createElement ( 'node' ) + if DEBUG_MODE : print '>> Node::parseToXML (id = %d)' % ( self.id ) + if self.id is None : + if DEBUG_MODE : print '>> Node::parseToXML id is None' + xml_node.setAttribute ( 'id', str( self.id ) ) + xml_node.setAttribute ( 'name', self.name ) + if self.label != None : xml_node.setAttribute ( 'label', self.label ) + if self.type != None : xml_node.setAttribute ( 'type', self.type ) + if self.author != None : xml_node.setAttribute ( 'author', self.author ) + if self.icon != None : xml_node.setAttribute ( 'icon', self.icon ) + + if self.help != None : + # append node help (short description) + help_tag = dom.createElement ( 'help' ) + help_text = dom.createTextNode ( self.help ) + help_tag.appendChild ( help_text ) + xml_node.appendChild ( help_tag ) + + input_tag = dom.createElement ( 'input' ) + for param in self.inputParams : + #print '--> parsing param to XML: %s ...' % param.name + input_tag.appendChild ( param.parseToXML ( dom ) ) + xml_node.appendChild ( input_tag ) + + output_tag = dom.createElement ( 'output' ) + for param in self.outputParams : + #print '--> parsing param to XML: %s ...' % param.name + output_tag.appendChild ( param.parseToXML ( dom ) ) + xml_node.appendChild ( output_tag ) + + internal_tag = dom.createElement ( 'internal' ) + for var in self.internals : + var_tag = dom.createElement( 'variable' ) + var_tag.setAttribute ( 'name', var ) + internal_tag.appendChild ( var_tag ) + xml_node.appendChild ( internal_tag ) + + include_tag = dom.createElement ( 'include' ) + for inc in self.includes : + inc_tag = dom.createElement( 'file' ) + inc_tag.setAttribute ( 'name', inc ) + include_tag.appendChild ( inc_tag ) + xml_node.appendChild ( include_tag ) + + if self.control_code != None : + control_code_tag = dom.createElement ( 'control_code' ) + control_code_data = dom.createCDATASection ( self.control_code ) + control_code_tag.appendChild ( control_code_data ) + xml_node.appendChild ( control_code_tag ) + + if self.code != None : + code_tag = dom.createElement ( 'code' ) + code_data = dom.createCDATASection ( self.code ) + code_tag.appendChild ( code_data ) + xml_node.appendChild ( code_tag ) + + if self.event_code : + event_code_tag = dom.createElement ( 'event_code' ) + print '*** write event_code' + for key in self.event_code.keys () : + print '*** write handler "%s"' % key + handler_tag = dom.createElement( 'handler' ) + handler_tag.setAttribute ( 'name', key ) + event_code_tag.appendChild ( handler_tag ) + handler_data = dom.createCDATASection ( self.event_code [ key ] ) + handler_tag.appendChild ( handler_data ) + xml_node.appendChild ( event_code_tag ) + + if self.offset != None : + ( x, y ) = self.offset + offset_tag = dom.createElement ( 'offset' ) + offset_tag.setAttribute ( 'x', x ) + offset_tag.setAttribute ( 'y', y ) + xml_node.appendChild ( offset_tag ) + + return xml_node + # + # getHeader + # + def getHeader ( self ) : assert 0, 'getHeader needs to be implemented!' + + # + # getComputedCode + # + def getComputedCode ( self, CodeOnly = False ) : assert 0, 'getComputedCode needs to be implemented!' + + # + # computeNode + # + def computeNode ( self, CodeOnly = False ) : assert 0, 'computeNode needs to be implemented!' + + # + # execControlCode + # + def execControlCode ( self ) : + # + if self.control_code != None : + control_code = self.control_code.lstrip () + if control_code != '' : + exec control_code + # + # parseGlobalVars + # + def parseGlobalVars ( self, parsedStr ) : + # + resultStr = '' + parserStart = 0 + parserPos = 0 + + while parserPos != -1 : + parserPos = str ( parsedStr ).find ( '$', parserStart ) + if parserPos != -1 : + # + if parserPos != 0 : + resultStr += parsedStr [ parserStart : parserPos ] + + # check global vars first + if parsedStr [ ( parserPos + 1 ) : ( parserPos + 2 ) ] == '{' : + globStart = parserPos + 2 + parserPos = str( parsedStr ).find ( '}', globStart ) + global_var_name = parsedStr [ globStart : ( parserPos ) ] + + #print '-> found global var %s' % global_var_name + + if global_var_name in app_global_vars.keys () : + resultStr += app_global_vars [ global_var_name ] + elif global_var_name in node_global_vars.keys () : + if global_var_name == 'INSTANCENAME' : resultStr += self.getInstanceName () + elif global_var_name == 'NODELABEL' : resultStr += self.getLabel () + elif global_var_name == 'NODENAME' : resultStr += self.getName () + elif global_var_name == 'PARAMS' : resultStr += self.getComputedInputParams () + self.getComputedOutputParams () + elif global_var_name == 'NODENETNAME' : resultStr += self.getNodenetName () + elif global_var_name == 'OUTPUTNAME' : resultStr += normPath ( os.path.join ( app_global_vars [ 'TempPath' ], self.getNodenetName () + '_' + self.getLabel () ) ) + else : + # keep $ sign for otheer, non ${...} cases + resultStr += '$' + + #print 'parserPos = %d parserStart = %d' % ( parserPos, parserStart ) + if parserPos != -1 : + parserStart = parserPos + 1 + + resultStr += parsedStr [ parserStart: ] + + return resultStr + # + # copySetup + # + def copySetup ( self, newNode ) : + # + if DEBUG_MODE : print '>> Node( %s ).copySetup ' % self.label + + newNode.id = self.id + + name = self.name + if name is None : name = str ( self.type ) + + newNode.name = name + + label = self.label + if label is None : label = name + + newNode.label = label + newNode.type = self.type + newNode.author = self.author + newNode.help = self.help + newNode.icon = self.icon + newNode.master = self.master + newNode.display = self.display + + newNode.offset = self.offset + + import copy + newNode.code = copy.copy ( self.code ) + newNode.control_code = copy.copy ( self.control_code ) + newNode.event_code = copy.copy ( self.event_code ) + #self.computed_code = None + + newNode.internals = copy.copy ( self.internals ) + newNode.includes = copy.copy ( self.includes ) + + newNode.inputLinks = {} + newNode.outputLinks = {} + + #newNode.childs = set () + print '***newNode.childs: ', newNode.childs + #newNode.childs = copy.copy ( self.childs ) + + newNode.inputParams = [] + for param in self.inputParams : newNode.inputParams.append ( param.copy () ) + + newNode.outputParams = [] + for param in self.outputParams : newNode.outputParams.append ( param.copy () ) + + return newNode + # + # save Node to .xml document + # + def save ( self ) : + # + result = False + + dom = QtXml.QDomDocument ( self.name ) + xml_code = self.parseToXML ( dom ) + dom.appendChild ( xml_code ) + + file = QFile ( self.master ) + if file.open ( QtCore.QIODevice.WriteOnly ) : + if file.write ( dom.toByteArray () ) != -1 : + result = True + file.close() + return result + # + # getChildrenSet + # + def getChildrenSet ( self, children_set = set () ) : + # + for node in self.childs : + children_set = node.getChildrenSet ( children_set ) + children_set.add ( node ) + return children_set + # + # getChildrenList + # + def getChildrenList ( self, children_list = [] ) : + # + for node in self.childs : + children_list = node.getChildrenList ( children_list ) + if node not in children_list : + children_list.append ( node ) + + return children_list # # createParamFromXml # # name and type must be specified in xml # def createParamFromXml ( xml_param, isRibParam, isInput = True ) : - # - from core.params.floatNodeParam import FloatNodeParam - from core.params.intNodeParam import IntNodeParam - from core.params.colorNodeParam import ColorNodeParam - from core.params.stringNodeParam import StringNodeParam - from core.params.normalNodeParam import NormalNodeParam - from core.params.pointNodeParam import PointNodeParam - from core.params.vectorNodeParam import VectorNodeParam - from core.params.matrixNodeParam import MatrixNodeParam - from core.params.surfaceNodeParam import SurfaceNodeParam - from core.params.displacementNodeParam import DisplacementNodeParam - from core.params.volumeNodeParam import VolumeNodeParam - from core.params.lightNodeParam import LightNodeParam - from core.params.ribNodeParam import RibNodeParam - from core.params.textNodeParam import TextNodeParam - from core.params.transformNodeParam import TransformNodeParam - from core.params.imageNodeParam import ImageNodeParam - from core.params.controlParam import ControlParam - from core.params.shaderNodeParam import ShaderNodeParam - - param = None - createParamTable = { 'float' : FloatNodeParam - ,'int' : IntNodeParam - ,'color' : ColorNodeParam - ,'string' : StringNodeParam - ,'normal' : NormalNodeParam - ,'point' : PointNodeParam - ,'vector' : VectorNodeParam - ,'matrix' : MatrixNodeParam - ,'surface' : SurfaceNodeParam - ,'displacement' : DisplacementNodeParam - ,'volume' : VolumeNodeParam - ,'light' : LightNodeParam - ,'rib' : RibNodeParam - ,'text' : TextNodeParam - ,'transform' : TransformNodeParam - ,'image' : ImageNodeParam - ,'control' : ControlParam - ,'shader' : ShaderNodeParam - } - param_type = str ( xml_param.attributes ().namedItem ( 'type' ).nodeValue () ) - if param_type in createParamTable.keys () : - param = createParamTable [ param_type ]( xml_param, isRibParam ) - param.isInput = isInput - else : - print '* Error: unknown param type !' - return param + # + from core.params.floatNodeParam import FloatNodeParam + from core.params.intNodeParam import IntNodeParam + from core.params.colorNodeParam import ColorNodeParam + from core.params.stringNodeParam import StringNodeParam + from core.params.normalNodeParam import NormalNodeParam + from core.params.pointNodeParam import PointNodeParam + from core.params.vectorNodeParam import VectorNodeParam + from core.params.matrixNodeParam import MatrixNodeParam + from core.params.surfaceNodeParam import SurfaceNodeParam + from core.params.displacementNodeParam import DisplacementNodeParam + from core.params.volumeNodeParam import VolumeNodeParam + from core.params.lightNodeParam import LightNodeParam + from core.params.ribNodeParam import RibNodeParam + from core.params.textNodeParam import TextNodeParam + from core.params.transformNodeParam import TransformNodeParam + from core.params.imageNodeParam import ImageNodeParam + from core.params.controlParam import ControlParam + from core.params.shaderNodeParam import ShaderNodeParam + + param = None + createParamTable = { 'float' : FloatNodeParam + ,'int' : IntNodeParam + ,'color' : ColorNodeParam + ,'string' : StringNodeParam + ,'normal' : NormalNodeParam + ,'point' : PointNodeParam + ,'vector' : VectorNodeParam + ,'matrix' : MatrixNodeParam + ,'surface' : SurfaceNodeParam + ,'displacement' : DisplacementNodeParam + ,'volume' : VolumeNodeParam + ,'light' : LightNodeParam + ,'rib' : RibNodeParam + ,'text' : TextNodeParam + ,'transform' : TransformNodeParam + ,'image' : ImageNodeParam + ,'control' : ControlParam + ,'shader' : ShaderNodeParam + } + param_type = str ( xml_param.attributes ().namedItem ( 'type' ).nodeValue () ) + if param_type in createParamTable.keys () : + param = createParamTable [ param_type ]( xml_param, isRibParam ) + param.isInput = isInput + else : + print '* Error: unknown param type !' + return param diff --git a/core/nodeNetwork.py b/core/nodeNetwork.py index 243162f..e54299a 100644 --- a/core/nodeNetwork.py +++ b/core/nodeNetwork.py @@ -71,20 +71,14 @@ def copy ( self ) : def copySetup ( self, newNode ) : # if DEBUG_MODE : print '>> NodeNetwork( %s ).copySetup ' % self.label - newNode.node_id = self.node_id newNode.link_id = self.link_id - newNode.name = self.name newNode.fileName = self.fileName - newNode.help = self.help - newNode.isDirty = self.isDirty - newNode.nodes = {} newNode.links = {} - # # renameNodeLabel # @@ -325,7 +319,7 @@ def save ( self ) : dom = QtXml.QDomDocument ( self.name ) self.parseToXML ( dom ) - file = QFile ( self.fileName ) + file = QtCore.QFile ( self.fileName ) if file.open ( QtCore.QIODevice.WriteOnly ) : if file.write ( dom.toByteArray () ) != -1 : result = True @@ -341,7 +335,7 @@ def open ( self, fileName ) : dom = QtXml.QDomDocument ( self.name ) - file = QFile ( fileName ) + file = QtCore.QFile ( fileName ) if file.open ( QtCore.QIODevice.ReadOnly ) : if dom.setContent ( file ) : self.fileName = fileName @@ -357,7 +351,7 @@ def open ( self, fileName ) : else : print '!! unknown XML document format' self.correct_id ( nodes, links ) - file.close() + file.close () #if DEBUG_MODE : print '>> NodeNetwork( %s ).open node_id = %d link_id = %d' % ( self.name, self.node_id, self.link_id ) #if DEBUG_MODE : self.printInfo () return ( nodes, links ) @@ -371,7 +365,7 @@ def insert ( self, fileName ) : dom = QtXml.QDomDocument ( self.name ) - file = QFile ( fileName ) + file = QtCore.QFile ( fileName ) if file.open ( QtCore.QIODevice.ReadOnly ) : if dom.setContent ( file ) : root = dom.documentElement () @@ -386,7 +380,7 @@ def insert ( self, fileName ) : ( nodes, links ) = self.add ( nodeNet ) else : print '!! unknown XML document format' - file.close() + file.close () #if DEBUG_MODE : print '>> NodeNetwork( %s ).insert node_id = %d link_id = %d' % ( self.name, self.node_id, self.link_id ) #if DEBUG_MODE : self.printInfo () return ( nodes, links ) diff --git a/core/nodeParam.py b/core/nodeParam.py index 01cc717..3d5e73e 100644 --- a/core/nodeParam.py +++ b/core/nodeParam.py @@ -7,6 +7,7 @@ import re import copy from core.mePyQt import QtCore +from core.signal import Signal from core.node import Node from global_vars import app_global_vars, DEBUG_MODE, VALID_RIB_NODE_TYPES @@ -15,303 +16,314 @@ # Abstract Node Parameter Class # class NodeParam ( QtCore.QObject ) : - # - isInput = True - isRibParam = False - id = 0 - # - # __init__ - # - def __init__ ( self, xml_param = None, isRibParam = False ) : - # - super ( NodeParam, self ).__init__ () - - self.id = None - self.name = None - self.label = None - self.type = None - self.help = None # short description - - self.default = None - self.value = None - self.shaderParam = False - - self.isRibParam = isRibParam - self.display = True - self.enabled = True - self.removable = False - - # extra parameter description - self.detail = '' # variable, uniform - self.provider = '' # primitive, connection, constant, variable, expression - - # ui decorative parameters - self.subtype = '' - self.range = '' - - self.space = None # actual for color, point, vector, normal, matrix - self.spaceDef = None # default value space - - self.arraySize = None # otherwise, it should be a list of values ( or empty list ) - - self.defaultArray = [] - self.valueArray = [] - #self.spaceArray = [] - #self.spaceDefArray = [] - - if xml_param != None : self.parseFromXML ( xml_param ) - # - # isArray - # - def isArray ( self ) : return ( self.array is not None ) - # - # setup - # - def setup ( self, name, label = '', detail = None, provider = None ) : - # - self.name = name - if label == '' or label is None : self.label = name - else: self.label = label - - self.detail = detail - self.provider = provider - # - # copy - # - def copy ( self ) : assert 0, 'copy needs to be implemented!' - # - # copySetup - # - def copySetup ( self, newParam ) : - # - #if DEBUG_MODE : print '>> NodeParam( %s ).copySetup' % self.label - newParam.id = self.id - newParam.name = self.name - newParam.label = self.label - newParam.type = self.type - newParam.help = self.help - newParam.isInput = self.isInput - newParam.shaderParam = self.shaderParam - newParam.isRibParam = self.isRibParam - newParam.display = self.display - newParam.enabled = self.enabled - newParam.removable = self.removable - newParam.detail = self.detail - newParam.provider = self.provider - newParam.subtype = self.subtype - newParam.range = self.range - newParam.space = self.space - newParam.spaceDef = self.spaceDef - - newParam.default = copy.deepcopy ( self.default ) - newParam.value = copy.deepcopy ( self.value ) - # - # typeToStr - # - def typeToStr ( self ) : - # - str = self.detail + ' ' + self.type - return str.lstrip () - # - # encodedTypeStr - # - def encodedTypeStr ( self ) : assert 0, 'encodedStr needs to be implemented!' - # - # setValueFromStr - # - def setValueFromStr ( self, strValue ) : self.value = self.valueFromStr ( strValue ) - # - # setDefaultFromStr - # - def setDefaultFromStr ( self, strValue ) : self.default = self.valueFromStr ( strValue ) - - # - # Virtual functions - # - - # - # valueFromStr - # - def valueFromStr ( self, strValue ) : return strValue - # - # getValueToStr - # - def getValueToStr ( self ) : - # - if self.value != None : - return self.valueToStr ( self.value ) - else : - return None - # - # getDefaultToStr - # - def getDefaultToStr ( self ) : - # - if self.default != None : - return self.valueToStr ( self.default ) - else : - return None - # - # virtual function - # - def valueToStr ( self, value ) : return str ( value ) - # - # paramChanged - # - def paramChanged ( self ) : - # - if DEBUG_MODE : print '>> NodeParam.paramChanged (name = %s)' % self.name - self.emit ( QtCore.SIGNAL ( 'paramChanged(QObject)' ), self ) - # - # setupUI - # - def setupUI ( self, subtype, range ) : - # - self.subtype = subtype - self.range = range - # - # setValue - # - def setValue ( self, value ) : - # - if self.value != value : - self.value = value - self.paramChanged () - # - # removeItemFromRange - # - def removeItemFromRange ( self, item_label ) : - # - newRangeList = [] - if self.range != '' : # and self.subtype == 'selector': - tmp_list = str ( self.range ).split ( ':' ) - for s in tmp_list : - pair = s.split ( '=' ) - if len ( pair ) > 1 : - label = pair [0] - value = pair [1] - else : - label = s - value = s - # - if label != item_label : - newRangeList.append ( s ) - self.range = ( ':' ).join ( newRangeList ) - # - # renameItemInRange - # - def renameItemInRange ( self, item_label, newLabel ) : - # - newRangeList = [] - if self.range != '' : # and self.subtype == 'selector': - tmp_list = str ( self.range ).split ( ':' ) - for s in tmp_list : - pair = s.split ( '=' ) - if len ( pair ) > 1 : - label = pair [0] - value = pair [1] - else : - label = s - value = s - # - if label == item_label : - s = s.replace ( label, newLabel, 1 ) # replace only label - newRangeList.append ( s ) - self.range = ( ':' ).join ( newRangeList ) - # - # parseFromXML - # - def parseFromXML ( self, xml_param ) : - # - self.name = str ( xml_param.attributes ().namedItem ( 'name' ).nodeValue () ) - self.label = str ( xml_param.attributes ().namedItem ( 'label' ).nodeValue () ) - if self.label == '' : self.label = self.name - self.type = str ( xml_param.attributes ().namedItem ( 'type' ).nodeValue () ) - self.shaderParam = xml_param.attributes ().namedItem ( 'shaderParam' ).nodeValue () == '1' - - self.detail = str ( xml_param.attributes ().namedItem ( 'detail' ).nodeValue () ) - self.provider = str ( xml_param.attributes ().namedItem ( 'provider' ).nodeValue () ) - self.subtype = str ( xml_param.attributes ().namedItem ( 'subtype' ).nodeValue () ) - self.range = str ( xml_param.attributes ().namedItem ( 'range' ).nodeValue () ) - - self.display = True - if not xml_param.attributes ().namedItem ( 'display' ).isNull () : - self.display = xml_param.attributes ().namedItem ( 'display' ).nodeValue () == '1' - - self.enabled = True - if not xml_param.attributes ().namedItem ( 'enabled' ).isNull () : - self.enabled = xml_param.attributes ().namedItem ( 'enabled' ).nodeValue () == '1' - - self.removable = False - if not xml_param.attributes ().namedItem ( 'removable' ).isNull () : - self.removable = xml_param.attributes ().namedItem ( 'removable' ).nodeValue () == '1' - - if not xml_param.attributes ().namedItem ( 'space' ).isNull () : - space = str ( xml_param.attributes ().namedItem ( 'space' ).nodeValue () ) - if space != '' : - self.space = space - self.spaceDef = space - - if not xml_param.attributes ().namedItem ( 'spaceDef' ).isNull () : - spaceDef = str ( xml_param.attributes ().namedItem ( 'spaceDef' ).nodeValue () ) - if spaceDef != '' : - self.spaceDef = space - - self.setDefaultFromStr ( xml_param.attributes ().namedItem ( 'default' ).nodeValue () ) - - if not xml_param.attributes ().namedItem ( 'value' ).isNull () : - self.setValueFromStr ( xml_param.attributes ().namedItem ( 'value' ).nodeValue () ) - else : - self.value = self.default - - #print ':: value = %s default = %s' % ( self.getValueToStr(), self.getDefaultToStr() ) - - help_tag = xml_param.namedItem ( 'help' ) - - if not help_tag.isNull () : - self.help = str ( help_tag.toElement ().text () ) - # - # parseToXML - # - def parseToXML ( self, dom ) : - # - xmlnode = dom.createElement( 'property' ) - - if self.name != None : xmlnode.setAttribute ( 'name', self.name ) - if self.label != None : xmlnode.setAttribute ( 'label', self.label ) - if self.type != None : xmlnode.setAttribute ( 'type', self.type ) - if self.shaderParam : xmlnode.setAttribute ( 'shaderParam', True ) - if not self.display : xmlnode.setAttribute ( 'display', False ) - if not self.enabled : xmlnode.setAttribute ( 'enabled', False ) - if self.removable : xmlnode.setAttribute ( 'removable', True ) - if self.detail != '' : xmlnode.setAttribute ( 'detail', self.detail ) - if self.provider != '' : xmlnode.setAttribute ( 'provider', self.provider ) - # ui decorative parameters - if self.subtype != '' : xmlnode.setAttribute ( 'subtype', self.subtype ) - if self.range != '' : xmlnode.setAttribute ( 'range', self.range ) - - if self.space != None : - if self.space != '' : xmlnode.setAttribute ( 'space', self.space ) - - # write default value space only if it differs from value space - if self.spaceDef != None : - if self.spaceDef != '' and self.spaceDef != self.space : xmlnode.setAttribute ( 'spaceDef', self.spaceDef ) - - if self.default != None : - value = self.getDefaultToStr () - if not self.type in VALID_RIB_NODE_TYPES : value = value.strip ( '\"' ) - xmlnode.setAttribute ( 'default', value ) - - if self.value != None : - value = self.getValueToStr () - if not self.type in VALID_RIB_NODE_TYPES : value = value.strip ( '\"' ) - xmlnode.setAttribute ( 'value', value ) - - if self.help != None : - # append node help (short description) - help_tag = dom.createElement ( 'help' ) - help_text = dom.createTextNode ( self.help ) - help_tag.appendChild ( help_text ) - xmlnode.appendChild ( help_tag ) - - return xmlnode + # + isInput = True + isRibParam = False + id = 0 + # + # __init__ + # + def __init__ ( self, xml_param = None, isRibParam = False ) : + # + super ( NodeParam, self ).__init__ () + # + # Define signals for PyQt5 + # + if QtCore.QT_VERSION >= 50000 : + # + self.paramChangedSignal = Signal () + + self.id = None + self.name = None + self.label = None + self.type = None + self.help = None # short description + + self.default = None + self.value = None + self.shaderParam = False + + self.isRibParam = isRibParam + self.display = True + self.enabled = True + self.removable = False + + # extra parameter description + self.detail = '' # variable, uniform + self.provider = '' # primitive, connection, constant, variable, expression + + # ui decorative parameters + self.subtype = '' + self.range = '' + + self.space = None # actual for color, point, vector, normal, matrix + self.spaceDef = None # default value space + + self.arraySize = None # otherwise, it should be a list of values ( or empty list ) + + self.defaultArray = [] + self.valueArray = [] + #self.spaceArray = [] + #self.spaceDefArray = [] + + if xml_param != None : self.parseFromXML ( xml_param ) + # + # isArray + # + def isArray ( self ) : return ( self.array is not None ) + # + # setup + # + def setup ( self, name, label = '', detail = None, provider = None ) : + # + self.name = name + if label == '' or label is None : self.label = name + else: self.label = label + + self.detail = detail + self.provider = provider + # + # copy + # + def copy ( self ) : assert 0, 'copy needs to be implemented!' + # + # copySetup + # + def copySetup ( self, newParam ) : + # + #if DEBUG_MODE : print '>> NodeParam( %s ).copySetup' % self.label + #if QtCore.QT_VERSION >= 50000 : + # newParam.paramChangedSignal = self.paramChangedSignal # Signal () + newParam.id = self.id + newParam.name = self.name + newParam.label = self.label + newParam.type = self.type + newParam.help = self.help + newParam.isInput = self.isInput + newParam.shaderParam = self.shaderParam + newParam.isRibParam = self.isRibParam + newParam.display = self.display + newParam.enabled = self.enabled + newParam.removable = self.removable + newParam.detail = self.detail + newParam.provider = self.provider + newParam.subtype = self.subtype + newParam.range = self.range + newParam.space = self.space + newParam.spaceDef = self.spaceDef + + newParam.default = copy.deepcopy ( self.default ) + newParam.value = copy.deepcopy ( self.value ) + # + # typeToStr + # + def typeToStr ( self ) : + # + str = self.detail + ' ' + self.type + return str.lstrip () + # + # encodedTypeStr + # + def encodedTypeStr ( self ) : assert 0, 'encodedStr needs to be implemented!' + # + # setValueFromStr + # + def setValueFromStr ( self, strValue ) : self.value = self.valueFromStr ( strValue ) + # + # setDefaultFromStr + # + def setDefaultFromStr ( self, strValue ) : self.default = self.valueFromStr ( strValue ) + + # + # Virtual functions + # + + # + # valueFromStr + # + def valueFromStr ( self, strValue ) : return strValue + # + # getValueToStr + # + def getValueToStr ( self ) : + # + if self.value != None : + return self.valueToStr ( self.value ) + else : + return None + # + # getDefaultToStr + # + def getDefaultToStr ( self ) : + # + if self.default != None : + return self.valueToStr ( self.default ) + else : + return None + # + # virtual function + # + def valueToStr ( self, value ) : return str ( value ) + # + # paramChanged + # + def paramChanged ( self ) : + # + if DEBUG_MODE : print '>> NodeParam.paramChanged (name = %s)' % self.name + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( 'paramChangedSignal(QObject)' ), self ) + else : + self.paramChangedSignal.emit ( self ) + # + # setupUI + # + def setupUI ( self, subtype, range ) : + # + self.subtype = subtype + self.range = range + # + # setValue + # + def setValue ( self, value ) : + # + if self.value != value : + self.value = value + self.paramChanged () + # + # removeItemFromRange + # + def removeItemFromRange ( self, item_label ) : + # + newRangeList = [] + if self.range != '' : # and self.subtype == 'selector': + tmp_list = str ( self.range ).split ( ':' ) + for s in tmp_list : + pair = s.split ( '=' ) + if len ( pair ) > 1 : + label = pair [0] + value = pair [1] + else : + label = s + value = s + # + if label != item_label : + newRangeList.append ( s ) + self.range = ( ':' ).join ( newRangeList ) + # + # renameItemInRange + # + def renameItemInRange ( self, item_label, newLabel ) : + # + newRangeList = [] + if self.range != '' : # and self.subtype == 'selector': + tmp_list = str ( self.range ).split ( ':' ) + for s in tmp_list : + pair = s.split ( '=' ) + if len ( pair ) > 1 : + label = pair [0] + value = pair [1] + else : + label = s + value = s + # + if label == item_label : + s = s.replace ( label, newLabel, 1 ) # replace only label + newRangeList.append ( s ) + self.range = ( ':' ).join ( newRangeList ) + # + # parseFromXML + # + def parseFromXML ( self, xml_param ) : + # + self.name = str ( xml_param.attributes ().namedItem ( 'name' ).nodeValue () ) + self.label = str ( xml_param.attributes ().namedItem ( 'label' ).nodeValue () ) + if self.label == '' : self.label = self.name + self.type = str ( xml_param.attributes ().namedItem ( 'type' ).nodeValue () ) + self.shaderParam = xml_param.attributes ().namedItem ( 'shaderParam' ).nodeValue () == '1' + + self.detail = str ( xml_param.attributes ().namedItem ( 'detail' ).nodeValue () ) + self.provider = str ( xml_param.attributes ().namedItem ( 'provider' ).nodeValue () ) + self.subtype = str ( xml_param.attributes ().namedItem ( 'subtype' ).nodeValue () ) + self.range = str ( xml_param.attributes ().namedItem ( 'range' ).nodeValue () ) + + self.display = True + if not xml_param.attributes ().namedItem ( 'display' ).isNull () : + self.display = xml_param.attributes ().namedItem ( 'display' ).nodeValue () == '1' + + self.enabled = True + if not xml_param.attributes ().namedItem ( 'enabled' ).isNull () : + self.enabled = xml_param.attributes ().namedItem ( 'enabled' ).nodeValue () == '1' + + self.removable = False + if not xml_param.attributes ().namedItem ( 'removable' ).isNull () : + self.removable = xml_param.attributes ().namedItem ( 'removable' ).nodeValue () == '1' + + if not xml_param.attributes ().namedItem ( 'space' ).isNull () : + space = str ( xml_param.attributes ().namedItem ( 'space' ).nodeValue () ) + if space != '' : + self.space = space + self.spaceDef = space + + if not xml_param.attributes ().namedItem ( 'spaceDef' ).isNull () : + spaceDef = str ( xml_param.attributes ().namedItem ( 'spaceDef' ).nodeValue () ) + if spaceDef != '' : + self.spaceDef = space + + self.setDefaultFromStr ( xml_param.attributes ().namedItem ( 'default' ).nodeValue () ) + + if not xml_param.attributes ().namedItem ( 'value' ).isNull () : + self.setValueFromStr ( xml_param.attributes ().namedItem ( 'value' ).nodeValue () ) + else : + self.value = self.default + + #print ':: value = %s default = %s' % ( self.getValueToStr(), self.getDefaultToStr() ) + + help_tag = xml_param.namedItem ( 'help' ) + + if not help_tag.isNull () : + self.help = str ( help_tag.toElement ().text () ) + # + # parseToXML + # + def parseToXML ( self, dom ) : + # + xmlnode = dom.createElement( 'property' ) + + if self.name != None : xmlnode.setAttribute ( 'name', self.name ) + if self.label != None : xmlnode.setAttribute ( 'label', self.label ) + if self.type != None : xmlnode.setAttribute ( 'type', self.type ) + if self.shaderParam : xmlnode.setAttribute ( 'shaderParam', True ) + if not self.display : xmlnode.setAttribute ( 'display', False ) + if not self.enabled : xmlnode.setAttribute ( 'enabled', False ) + if self.removable : xmlnode.setAttribute ( 'removable', True ) + if self.detail != '' : xmlnode.setAttribute ( 'detail', self.detail ) + if self.provider != '' : xmlnode.setAttribute ( 'provider', self.provider ) + # ui decorative parameters + if self.subtype != '' : xmlnode.setAttribute ( 'subtype', self.subtype ) + if self.range != '' : xmlnode.setAttribute ( 'range', self.range ) + + if self.space != None : + if self.space != '' : xmlnode.setAttribute ( 'space', self.space ) + + # write default value space only if it differs from value space + if self.spaceDef != None : + if self.spaceDef != '' and self.spaceDef != self.space : xmlnode.setAttribute ( 'spaceDef', self.spaceDef ) + + if self.default != None : + value = self.getDefaultToStr () + if not self.type in VALID_RIB_NODE_TYPES : value = value.strip ( '\"' ) + xmlnode.setAttribute ( 'default', value ) + + if self.value != None : + value = self.getValueToStr () + if not self.type in VALID_RIB_NODE_TYPES : value = value.strip ( '\"' ) + xmlnode.setAttribute ( 'value', value ) + + if self.help != None : + # append node help (short description) + help_tag = dom.createElement ( 'help' ) + help_text = dom.createTextNode ( self.help ) + help_tag.appendChild ( help_text ) + xmlnode.appendChild ( help_tag ) + + return xmlnode diff --git a/core/signal.py b/core/signal.py new file mode 100644 index 0000000..004e9e6 --- /dev/null +++ b/core/signal.py @@ -0,0 +1,26 @@ +""" + + signal.py + + This code borrowed from http://blog.abstractfactory.io/dynamic-signals-in-pyqt/ + hello@abstractfactory.io + +""" +class Signal : + # + def __init__( self ) : + self.__subscribers = [] + + def emit ( self, *args, **kwargs ) : + for subs in self.__subscribers : + subs ( *args, **kwargs ) + + def connect ( self, func ) : + self.__subscribers.append ( func ) + + def disconnect ( self, func ) : + try: + self.__subscribers.remove ( func ) + except ValueError: + print ( 'Warning: function %s not removed from signal %s' ( func,self )) + \ No newline at end of file diff --git a/gfx/WorkArea.py b/gfx/WorkArea.py index 760db12..a80866a 100644 --- a/gfx/WorkArea.py +++ b/gfx/WorkArea.py @@ -4,6 +4,7 @@ """ from core.mePyQt import QtCore, QtGui +from core.signal import Signal from core.meCommon import * @@ -25,18 +26,96 @@ else : from core.mePyQt import QtWidgets QtModule = QtWidgets + +# +# WorkAreaScene +# +# Translates user signals from graphics objects +# to work area +# +class WorkAreaScene ( QtModule.QGraphicsScene ) : + + # + # __init__ + # + def __init__ ( self, view ) : + # + QtModule.QGraphicsScene.__init__ ( self ) + # + # Define signals for PyQt5 + # + if QtCore.QT_VERSION >= 50000 : + # + self.startNodeConnector = Signal () #QtCore.pyqtSignal ( QtModule.QGraphicsObject, QtCore.QPointF ) + self.traceNodeConnector = Signal () #QtCore.pyqtSignal ( QtModule.QGraphicsObject, QtCore.QPointF ) + self.endNodeConnector = Signal () #QtCore.pyqtSignal ( QtModule.QGraphicsObject, QtCore.QPointF ) + + self.startNodeLink = Signal () #( QtModule.QGraphicsObject ) # QtModule.QGraphicsItem + self.traceNodeLink = Signal () #QtCore.pyqtSignal ( QtModule.QGraphicsObject, QtCore.QPointF ) + self.endNodeLink = Signal () #QtCore.pyqtSignal ( QtModule.QGraphicsObject, QtCore.QPointF ) + + self.onGfxNodeRemoved = Signal () #QtCore.pyqtSignal ( QtModule.QGraphicsObject ) + self.onGfxLinkRemoved = Signal () #QtCore.pyqtSignal ( QtModule.QGraphicsObject ) + + self.nodeUpdated = Signal () #QtCore.pyqtSignal ( QtModule.QGraphicsItem ) + self.gfxNodeParamChanged = Signal () #QtCore.pyqtSignal ( QtModule.QGraphicsItem, QtCore.QObject ) + + self.view = view + self.connectSignals () + # + # connectSignals + # + def connectSignals ( self ) : + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.connect ( self, QtCore.SIGNAL ( 'selectionChanged()' ), self.view.onSelectionChanged ) + + QtCore.QObject.connect ( self, QtCore.SIGNAL ( 'startNodeLink' ), self.view.onStartNodeLink ) + QtCore.QObject.connect ( self, QtCore.SIGNAL ( 'traceNodeLink' ), self.view.onTraceNodeLink ) + QtCore.QObject.connect ( self, QtCore.SIGNAL ( 'endNodeLink' ), self.view.onEndNodeLink ) + + QtCore.QObject.connect ( self, QtCore.SIGNAL ( 'startNodeConnector' ), self.view.onStartNodeConnector ) + QtCore.QObject.connect ( self, QtCore.SIGNAL ( 'traceNodeConnector' ), self.view.onTraceNodeConnector ) + QtCore.QObject.connect ( self, QtCore.SIGNAL ( 'endNodeConnector' ), self.view.onEndNodeConnector ) + QtCore.QObject.connect ( self, QtCore.SIGNAL ( 'onGfxNodeRemoved' ), self.view.onRemoveNode ) + QtCore.QObject.connect ( self, QtCore.SIGNAL ( 'onGfxLinkRemoved' ), self.view.onRemoveLink ) + + else : + self.selectionChanged.connect ( self.view.onSelectionChanged ) + + self.startNodeLink.connect ( self.view.onStartNodeLink ) + self.traceNodeLink.connect ( self.view.onTraceNodeLink ) + self.endNodeLink.connect ( self.view.onEndNodeLink ) + + self.startNodeConnector.connect ( self.view.onStartNodeConnector ) + self.traceNodeConnector.connect ( self.view.onTraceNodeConnector ) + self.endNodeConnector.connect ( self.view.onEndNodeConnector ) + + self.onGfxNodeRemoved.connect ( self.view.onRemoveNode ) + self.onGfxLinkRemoved.connect ( self.view.onRemoveLink ) # # WorkArea # class WorkArea ( QtModule.QGraphicsView ) : + # # __init__ # def __init__ ( self ) : # QtModule.QGraphicsView.__init__ ( self ) - + + # + # Define signals for PyQt5 + # + if QtCore.QT_VERSION >= 50000 : + # + self.selectNodes = Signal () #( list, list ) + self.nodeConnectionChanged = Signal () #QtCore.pyqtSignal ( QtModule.QGraphicsObject, QtCore.QObject ) + + self.gfxNodeAdded = Signal () #( QtModule.QGraphicsObject ) + self.gfxNodeRemoved = Signal () #( QtModule.QGraphicsObject ) + # self.drawGrid = True self.gridSnap = False self.straightLinks = False @@ -60,8 +139,7 @@ def __init__ ( self ) : self.selectedLinks = [] # set scene - scene = QtModule.QGraphicsScene ( self ) - + scene = WorkAreaScene ( self ) scene.setSceneRect ( -10000, -10000, 20000, 20000 ) #scene.setItemIndexMethod ( QtGui.QGraphicsScene.NoIndex ) self.setScene ( scene ) @@ -93,22 +171,16 @@ def __init__ ( self ) : self.viewBrush = QtGui.QBrush ( QtGui.QColor ( 148, 148, 148 ) ) self.setBackgroundBrush ( self.viewBrush ) - if QtCore.QT_VERSION < 50000 : - QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'selectionChanged()' ), self.onSelectionChanged ) - - QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'startNodeLink' ), self.onStartNodeLink ) - QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'traceNodeLink' ), self.onTraceNodeLink ) - QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'endNodeLink' ), self.onEndNodeLink ) - - QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'startNodeConnector' ), self.onStartNodeConnector ) - QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'traceNodeConnector' ), self.onTraceNodeConnector ) - QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'endNodeConnector' ), self.onEndNodeConnector ) - - QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'onGfxNodeRemoved' ), self.onRemoveNode ) - QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'onGfxLinkRemoved' ), self.onRemoveLink ) + # self.connectSignals () if DEBUG_MODE : print ">> WorkArea. __init__" # + # connectSignals + # + def connectSignals ( self ) : + # + pass + # # drawBackground # def drawBackground ( self, painter, rect ) : @@ -265,7 +337,10 @@ def addGfxNode ( self, node, pos = None ) : #for item in scene.selectedItems (): item.setSelected ( False ) scene.addItem ( gfxNode ) gfxNode.setSelected ( True ) - self.emit ( QtCore.SIGNAL ( 'gfxNodeAdded' ), gfxNode ) + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( 'gfxNodeAdded' ), gfxNode ) + else : + self.gfxNodeAdded.emit ( gfxNode ) # # adjustLinks # @@ -303,7 +378,10 @@ def onSelectionChanged ( self ) : elif isinstance ( item, GfxSwatchNode ) : self.selectedNodes.append ( item ) elif isinstance ( item, GfxLink ) : self.selectedLinks.append ( item ) - self.emit ( QtCore.SIGNAL ( 'selectNodes' ), self.selectedNodes, self.selectedLinks ) + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( 'selectNodes' ), self.selectedNodes, self.selectedLinks ) + else : + self.selectNodes.emit ( self.selectedNodes, self.selectedLinks ) # # lastConnectCandidateReset # @@ -339,8 +417,12 @@ def isLinkAcceptable ( self, connector, connectCandidate ) : # # onStartNodeLink # + #@QtCore.pyqtSlot( GfxNodeConnector ) def onStartNodeLink ( self, connector ): # + #if DEBUG_MODE : print '>> WorkArea::onStartNodeLink' + #if DEBUG_MODE : print connector + srcNode = connector.getNode () srcParam = connector.param if DEBUG_MODE : print '>> WorkArea::onStartNodeLink from %s (%s)' % ( srcNode.label, srcParam.label ) @@ -364,7 +446,10 @@ def onStartNodeLink ( self, connector ): def onTraceNodeLink ( self, connector, scenePos ) : # node = connector.parentItem().node # print ">> WorkArea: onDrawNodeLink from %s (%d %d)" % ( node.label, scenePos.x(), scenePos.y() ) - connectCandidate = self.scene ().itemAt ( scenePos ) + if QtCore.QT_VERSION < 50000 : + connectCandidate = self.scene ().itemAt ( scenePos ) + else : + connectCandidate = self.scene ().itemAt ( scenePos, self.transform () ) srcConnector = self.currentGfxLink.srcConnector swappedLink = False if srcConnector is None : # link has swapped connectors @@ -449,8 +534,10 @@ def onEndNodeLink ( self, connector, scenePos ) : self.currentGfxLink.link = link self.nodeNet.addLink ( link ) - #self.emit ( QtCore.SIGNAL ( 'nodeConnectionChanged' ), self.currentGfxLink.srcConnector.getGfxNode (), self.currentGfxLink.srcConnector.param ) - self.emit ( QtCore.SIGNAL ( 'nodeConnectionChanged' ), self.currentGfxLink.dstConnector.getGfxNode (), self.currentGfxLink.dstConnector.param ) + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( 'nodeConnectionChanged' ), self.currentGfxLink.dstConnector.getGfxNode (), self.currentGfxLink.dstConnector.param ) + else : + self.nodeConnectionChanged.emit ( self.currentGfxLink.dstConnector.getGfxNode (), self.currentGfxLink.dstConnector.param ) self.lastConnectCandidateReset () self.currentGfxLink = None @@ -576,7 +663,10 @@ def onEndNodeConnector ( self, connector, scenePos ) : def onRemoveNode ( self, gfxNode ) : # print ">> WorkArea.onRemoveNode %s (id = %d)" % ( gfxNode.node.label, gfxNode.node.id ) - self.emit ( QtCore.SIGNAL ( 'gfxNodeRemoved' ), gfxNode ) + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( 'gfxNodeRemoved' ), gfxNode ) + else : + self.gfxNodeRemoved.emit ( gfxNode ) self.scene ().removeItem ( gfxNode ) self.nodeNet.removeNode ( gfxNode.node ) @@ -599,8 +689,10 @@ def onRemoveLink ( self, gfxLink ) : #self.emit( QtCore.SIGNAL( 'nodeConnectionChanged' ), srcConnector.parentItem(), srcConnector.param ) if dstConnector is not None : if DEBUG_MODE : print '*** dstConnector.parentItem().node.label = %s ' % dstConnector.getNode ().label - self.emit ( QtCore.SIGNAL ( 'nodeConnectionChanged' ), dstConnector.getGfxNode (), dstConnector.param ) - + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( 'nodeConnectionChanged' ), dstConnector.getGfxNode (), dstConnector.param ) + else : + self.nodeConnectionChanged.emit ( dstConnector.getGfxNode (), dstConnector.param ) # # removeSelected # @@ -658,8 +750,13 @@ def dropEvent ( self, event ) : # decode drop stuff data = mimedata.data ( 'application/x-text' ) stream = QtCore.QDataStream ( data, QtCore.QIODevice.ReadOnly ) - filename = QtCore.QString () - stream >> filename + + if QtCore.QT_VERSION < 50000 : + filename = QtCore.QString () + stream >> filename + else : + filename = '' + filename = stream.readBytes () if DEBUG_MODE : print 'itemFilename = %s' % ( filename ) @@ -696,8 +793,16 @@ def wheelEvent ( self, event ) : scale = -1.0 if 'linux' in sys.platform: scale = 1.0 import math - scaleFactor = math.pow( 2.0, scale * event.delta() / 600.0 ) - factor = self.matrix().scale( scaleFactor, scaleFactor ).mapRect( QtCore.QRectF( -1, -1, 2, 2 ) ).width () + if QtCore.QT_VERSION < 50000 : + scaleFactor = math.pow( 2.0, scale * event.delta () / 600.0 ) + else : + delta = event.angleDelta () + #print ( '>> delta rx = %d ry = %d' % ( delta.x (), delta.y () ) ) + scaleFactor = math.pow( 2.0, scale * delta.y () / 600.0 ) + + # self.matrix () is depicated + factor = self.transform ().scale ( scaleFactor, scaleFactor ).mapRect ( QtCore.QRectF ( -1, -1, 2, 2 ) ).width () + if factor < 0.07 or factor > 100: return self.scale ( scaleFactor, scaleFactor ) # @@ -748,7 +853,7 @@ def mouseMoveEvent ( self, event ) : if 'linux' in sys.platform: scale = 1.0 import math scaleFactor = math.pow ( 2.0, scale * max ( deltaPos.x (), deltaPos.y () ) / 200.0 ) # - factor = self.matrix().scale( scaleFactor, scaleFactor ).mapRect( QtCore.QRectF( -1, -1, 2, 2 ) ).width() + factor = self.transform ().scale ( scaleFactor, scaleFactor ).mapRect ( QtCore.QRectF( -1, -1, 2, 2 ) ).width () if factor < 0.07 or factor > 100: return # update view matrix @@ -806,9 +911,11 @@ def openNodeNet ( self, filename, pos = None ) : # # insertNodeNet # + # Called by signal 'addNode' def insertNodeNet ( self, filename, pos = None ) : # - if DEBUG_MODE : print ">> WorkArea.insertNodeNet (before) nodes = %d links = %d" % ( len(self.nodeNet.nodes.values()), len(self.nodeNet.links.values()) ) + if DEBUG_MODE : print ( '>> WorkArea.insertNodeNet filename = ' + filename ) + if DEBUG_MODE : print ( ">> WorkArea.insertNodeNet (before) nodes = %d links = %d" % ( len(self.nodeNet.nodes.values()), len(self.nodeNet.links.values()) ) ) ( nodes, links ) = self.nodeNet.insert ( normPath ( filename ) ) diff --git a/gfx/gfxLink.py b/gfx/gfxLink.py index c753b44..598da71 100644 --- a/gfx/gfxLink.py +++ b/gfx/gfxLink.py @@ -25,22 +25,22 @@ class GfxLink ( QtModule.QGraphicsItem ) : # @staticmethod def createFromPoints ( srcP, dstP ) : + # gfxLink = GfxLink () gfxLink.srcPoint = gfxLink.mapToItem ( gfxLink, srcP ) gfxLink.dstPoint = gfxLink.mapToItem ( gfxLink, dstP ) gfxLink.adjust () - return gfxLink # # createFromLink # @staticmethod def createFromLink ( link ): + # gfxLink = GfxLink () gfxLink.link = link gfxLink.path = QtGui.QPainterPath () gfxLink.adjust () - return gfxLink # # __init__ @@ -55,7 +55,7 @@ def __init__ ( self, link = None, srcConnector = None, dstConnector = None ) : # qt graphics stuff self.brushSelected = QtGui.QBrush ( QtGui.QColor ( 250, 250, 250 ) ) self.brushNormal = QtGui.QBrush ( QtGui.QColor ( 20, 20, 20 ) ) - self.setFlag ( QtGui.QGraphicsItem.ItemIsSelectable ) + self.setFlag ( QtModule.QGraphicsItem.ItemIsSelectable ) self.setZValue( 0 ) self.link = link @@ -77,6 +77,7 @@ def __init__ ( self, link = None, srcConnector = None, dstConnector = None ) : # remove # def remove ( self ) : + # if DEBUG_MODE : print ">> GfxLink::remove" if self.srcConnector is not None : @@ -89,7 +90,10 @@ def remove ( self ) : scene = self.scene () if scene != None : if DEBUG_MODE : print ">> GfxLink::remove emit( onGfxLinkRemoved )" - scene.emit ( QtCore.SIGNAL ( 'onGfxLinkRemoved' ), self ) + if QtCore.QT_VERSION < 50000 : + scene.emit ( QtCore.SIGNAL ( 'onGfxLinkRemoved' ), self ) + else : + scene.onGfxLinkRemoved.emit ( self ) # # type # @@ -114,6 +118,7 @@ def swapConnectors ( self ): # isDstConnectedTo # def isDstConnectedTo ( self, connector ) : + # connected = False if connector == self.dstConnector : connected = True @@ -140,6 +145,7 @@ def setSrcConnector ( self, srcConnector ) : # setDstConnector # def setDstConnector ( self, dstConnector ) : + # if dstConnector is not None : self.dstPoint = dstConnector.getCenterPoint () self.dstConnector = dstConnector @@ -148,13 +154,15 @@ def setDstConnector ( self, dstConnector ) : # itemChange # def itemChange ( self, change, value ) : - if change == QtGui.QGraphicsItem.ItemSelectedChange : - self.isLinkSelected = value.toBool () - return QtGui.QGraphicsItem.itemChange ( self, change, value ) + # + if change == QtModule.QGraphicsItem.ItemSelectedChange : + self.isLinkSelected = ( value == 1 ) #value.toBool () + return QtModule.QGraphicsItem.itemChange ( self, change, value ) # # setPoints # def setPoints ( self, srcP, dstP ) : + # self.srcPoint = self.mapToItem ( self, srcP ) self.dstPoint = self.mapToItem ( self, dstP ) self.adjust () @@ -162,18 +170,21 @@ def setPoints ( self, srcP, dstP ) : # setSrcPoint # def setSrcPoint ( self, p ) : + # self.srcPoint = self.mapToItem ( self, p ) self.adjust () # # setDstPoint # def setDstPoint ( self, p ) : + # self.dstPoint = self.mapToItem ( self, p ) self.adjust () # # adjust # def adjust ( self ) : + # from meShaderEd import getDefaultValue self.isStraight = getDefaultValue ( app_settings, 'WorkArea', 'straight_links' ) @@ -203,7 +214,7 @@ def adjust ( self ) : p1 = self.srcPoint + QtCore.QPointF ( offsetVX, offsetVY ) self.points.append ( p1 ) # third point - p2 = QtCore.QPointF ( centerX, self.srcPoint.y() ) + p2 = QtCore.QPointF ( centerX, self.srcPoint.y() ) self.points.append ( p2 ) # fourth point p3 = QtCore.QPointF ( centerX, centerY ) diff --git a/gfx/gfxNode.py b/gfx/gfxNode.py index 87d595d..b7d2496 100644 --- a/gfx/gfxNode.py +++ b/gfx/gfxNode.py @@ -4,6 +4,7 @@ """ from core.mePyQt import QtCore, QtGui +from core.signal import Signal from gfx.gfxNodeLabel import GfxNodeLabel from gfx.gfxNodeConnector import GfxNodeConnector @@ -21,15 +22,25 @@ # # GfxNode # -class GfxNode ( QtModule.QGraphicsItem ) : +class GfxNode ( QtModule.QGraphicsItem ) : # QtModule.QGraphicsItem QtModule.QGraphicsItem # Type = GFX_NODE_TYPE + # # __init__ # def __init__ ( self, node ) : # QtModule.QGraphicsItem.__init__ ( self ) + # + # Define signals for PyQt5 + # + if QtCore.QT_VERSION >= 50000 : + # + pass + #self.nodeUpdated = Signal () #QtCore.pyqtSignal ( QtModule.QGraphicsItem ) + #self.gfxNodeParamChanged = Signal () #QtCore.pyqtSignal ( QtModule.QGraphicsItem, QtCore.QObject ) + #self.onGfxNodeRemoved = Signal () #QtCore.pyqtSignal ( QtModule.QGraphicsItem ) self.node = node self.header = {} @@ -79,31 +90,50 @@ def __init__ ( self, node ) : self.BrushShadow = QtGui.QBrush ( self.shadowColor ) self.PenShadow = QtGui.QPen ( self.shadowColor ) - - self.collapse = None # 'input' 'output' 'all' if self.node is not None : - QtCore.QObject.connect ( self.node, QtCore.SIGNAL ( 'nodeUpdated' ), self.onUpdateNode ) - QtCore.QObject.connect ( self.node, QtCore.SIGNAL ( 'nodeParamsUpdated' ), self.onUpdateNodeParams ) + self.connectSignals () self.updateGfxNode () ( x, y ) = self.node.offset self.setPos ( x, y ) # flag (new from QT 4.6...) - self.setFlag ( QtGui.QGraphicsItem.ItemSendsScenePositionChanges ) - self.setFlag ( QtGui.QGraphicsItem.ItemSendsGeometryChanges ) + self.setFlag ( QtModule.QGraphicsItem.ItemSendsScenePositionChanges ) + self.setFlag ( QtModule.QGraphicsItem.ItemSendsGeometryChanges ) # qt graphics stuff - self.setFlag ( QtGui.QGraphicsItem.ItemIsMovable ) - self.setFlag ( QtGui.QGraphicsItem.ItemIsSelectable ) + self.setFlag ( QtModule.QGraphicsItem.ItemIsMovable ) + self.setFlag ( QtModule.QGraphicsItem.ItemIsSelectable ) self.setZValue ( 1 ) # + # connectSignals + # + def connectSignals ( self ) : + # + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.connect ( self.node, QtCore.SIGNAL ( 'nodeUpdated' ), self.onUpdateNode ) + QtCore.QObject.connect ( self.node, QtCore.SIGNAL ( 'nodeParamsUpdated' ), self.onUpdateNodeParams ) + else : + self.node.nodeUpdated.connect ( self.onUpdateNode ) + self.node.nodeParamsUpdated.connect ( self.onUpdateNodeParams ) + # + # disconnectSignals + # + def disconnectSignals ( self ) : + # + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.disconnect ( self.node, QtCore.SIGNAL ( 'nodeUpdated' ), self.onUpdateNode ) + QtCore.QObject.disconnect ( self.node, QtCore.SIGNAL ( 'nodeParamsUpdated' ), self.onUpdateNodeParams ) + else : + self.node.nodeUpdated.disconnect ( self.onUpdateNode ) + self.node.nodeParamsUpdated.disconnect ( self.onUpdateNodeParams ) + # # type # def type ( self ) : return GfxNode.Type # - # + # get_bg_color # def get_bg_color ( self ) : # @@ -123,7 +153,10 @@ def onUpdateNode ( self ) : # if DEBUG_MODE : print '>> GfxNode( %s ).updateNode' % ( self.node.label ) self.updateGfxNodeParams ( True ) - self.scene().emit ( QtCore.SIGNAL ( 'nodeUpdated' ), self ) + if QtCore.QT_VERSION < 50000 : + self.scene().emit ( QtCore.SIGNAL ( 'nodeUpdated' ), self ) + else : + self.scene().nodeUpdated.emit ( self ) # # onUpdateNodeParams # @@ -131,8 +164,10 @@ def onUpdateNodeParams ( self, forceUpdate = False ) : # if DEBUG_MODE : print '>> GfxNode( %s ).onUpdateNodeParams' % ( self.node.label ) self.updateGfxNodeParams ( forceUpdate ) - self.scene().emit ( QtCore.SIGNAL ( 'gfxNodeParamChanged' ), self ) - + if QtCore.QT_VERSION < 50000 : + self.scene().emit ( QtCore.SIGNAL ( 'gfxNodeParamChanged' ), self ) + else : + self.scene().gfxNodeParamChanged.emit ( self ) # # updateGfxNodeParams # @@ -158,7 +193,8 @@ def updateGfxNode ( self, removeLinks = True ) : self.outputConnectors = [] self.inputConnectors = [] # remove all children - for item in self.childItems () : self.scene ().removeItem ( item ) + for item in self.childItems () : + self.scene ().removeItem ( item ) self.header = {} self.setupHeader () self.outputParamLabels = [] @@ -196,10 +232,13 @@ def getOutputConnectorByParam ( self, param ) : def remove ( self ) : # if DEBUG_MODE : print '>> GfxNode.remove' - QtCore.QObject.disconnect ( self.node, QtCore.SIGNAL ( 'nodeUpdated' ), self.onUpdateNode ) + self.disconnectSignals () for connect in self.inputConnectors : connect.removeAllLinks () for connect in self.outputConnectors : connect.removeAllLinks () - self.scene().emit ( QtCore.SIGNAL ( 'onGfxNodeRemoved' ), self ) + if QtCore.QT_VERSION < 50000 : + self.scene().emit ( QtCore.SIGNAL ( 'onGfxNodeRemoved' ), self ) + else : + self.scene().onGfxNodeRemoved.emit ( self ) # # updateNodeLabel # @@ -366,6 +405,7 @@ def setupOutputParamsGeometry ( self, xs, ys ) : connector.rect.moveTo ( x - connector.radius, y + hi / 2 - connector.radius ) y += hi connector.setParentItem ( self ) + # # setupInputParamsGeometry # @@ -414,12 +454,16 @@ def updateGfxNodeParamLabel ( self, param, label, forceUpdate = False ) : label.setProcessEvents ( True ) if forceUpdate : self.update () - self.scene().emit ( QtCore.SIGNAL ( 'gfxNodeParamChanged' ), self, param ) + if QtCore.QT_VERSION < 50000 : + self.scene().emit ( QtCore.SIGNAL ( 'gfxNodeParamChanged' ), self, param ) + else : + self.gfxNodeParamChanged.emit ( self, param ) # # addGfxNodeParam # def addGfxNodeParam ( self, param ) : # + if DEBUG_MODE : print ">> GfxNode.addGfxNodeParam (%s)" % param.label if param.isInput : labels = self.inputParamLabels connectors = self.inputConnectors @@ -439,7 +483,8 @@ def addGfxNodeParam ( self, param ) : labels.append ( label ) connector = GfxNodeConnector ( param, UI.CONNECTOR_RADIUS, node = None ) - if not param.isInput : connector.singleLinkOnly = False + if not param.isInput : + connector.singleLinkOnly = False connectors.append ( connector ) # # removeGfxNodeParam @@ -505,23 +550,27 @@ def adjustLinks ( self ) : # # itemChange # + def itemChange ( self, change, value ) : # - if change == QtGui.QGraphicsItem.ItemSelectedHasChanged : #ItemSelectedChange: + if change == QtModule.QGraphicsItem.ItemSelectedHasChanged : #ItemSelectedChange: QGraphicsItem if self.node.type != 'variable' : # variable node has not header - self.header [ 'label' ].setSelected ( value.toBool () ) + #if QtCore.QT_VERSION < 50000 : + # self.header [ 'label' ].setSelected ( value.toBool () ) + #else : + self.header [ 'label' ].setSelected ( value ) #self.header['swatch'].isNodeSelected = self.isNodeSelected - if value.toBool () : + if value == 1 : items = self.scene ().items () for i in range ( len ( items ) - 1, -1, -1 ) : if items [ i ].parentItem() is None : if items [ i ] != self : items [ i ].stackBefore ( self ) #scene.setFocusItem ( self ) - elif change == QtGui.QGraphicsItem.ItemPositionHasChanged : + elif change == QtModule.QGraphicsItem.ItemPositionHasChanged : from meShaderEd import getDefaultValue - grid_snap = getDefaultValue ( app_settings, 'WorkArea', 'grid_snap' ) + grid_snap = bool ( getDefaultValue ( app_settings, 'WorkArea', 'grid_snap' ) ) grid_size = int ( getDefaultValue ( app_settings, 'WorkArea', 'grid_size' ) ) x = self.x () y = self.y () @@ -533,7 +582,10 @@ def itemChange ( self, change, value ) : #if DEBUG_MODE : print '* GfxNode.itemChange = ItemPositionHasChanged (%f, %f)' % ( x, y ) self.node.offset = ( x, y ) self.adjustLinks () - return QtGui.QGraphicsItem.itemChange ( self, change, value ) + #return QtCore.QPointF ( x, y ) + #return super( GfxNode, self ).itemChange ( change, value ) + return QtModule.QGraphicsItem.itemChange ( self, change, value ) + # # paint # diff --git a/gfx/gfxNodeConnector.py b/gfx/gfxNodeConnector.py index a9e7b74..8842fc2 100644 --- a/gfx/gfxNodeConnector.py +++ b/gfx/gfxNodeConnector.py @@ -5,6 +5,7 @@ """ import copy from core.mePyQt import QtCore, QtGui +from core.signal import Signal from meShaderEd import app_settings from global_vars import DEBUG_MODE, GFX_NODE_CONNECTOR_TYPE @@ -18,7 +19,7 @@ # # GfxNodeConnector # -class GfxNodeConnector ( QtModule.QGraphicsItem ) : +class GfxNodeConnector ( QtModule.QGraphicsItem ) : #QtModule.QGraphicsItem # Type = GFX_NODE_CONNECTOR_TYPE isRound = True @@ -27,7 +28,9 @@ class GfxNodeConnector ( QtModule.QGraphicsItem ) : # def __init__ ( self, param = None, radius = UI.CONNECTOR_RADIUS, isRound = True, node = None ) : # + #QtModule.QGraphicsItem.__init__ ( self ) QtModule.QGraphicsItem.__init__ ( self ) + self.paramsBrushes = { 'c' : QtGui.QBrush ( QtGui.QColor ( QtCore.Qt.darkRed ) ) ,'f' : QtGui.QBrush ( QtGui.QColor ( QtCore.Qt.lightGray ) ) ,'m' : QtGui.QBrush ( QtGui.QColor ( QtCore.Qt.darkYellow ) ) @@ -55,12 +58,12 @@ def __init__ ( self, param = None, radius = UI.CONNECTOR_RADIUS, isRound = True, self.node = node # is not None if this "ConnectorNode" if node is not None : # flag (new from QT 4.6...) - self.setFlag ( QtGui.QGraphicsItem.ItemSendsScenePositionChanges ) - self.setFlag ( QtGui.QGraphicsItem.ItemSendsGeometryChanges ) + #self.setFlag ( QtModule.QGraphicsItem.ItemSendsScenePositionChanges ) + self.setFlag ( QtModule.QGraphicsItem.ItemSendsGeometryChanges ) # qt graphics stuff - self.setFlag ( QtGui.QGraphicsItem.ItemIsMovable ) - self.setFlag ( QtGui.QGraphicsItem.ItemIsSelectable ) + self.setFlag ( QtModule.QGraphicsItem.ItemIsMovable ) + self.setFlag ( QtModule.QGraphicsItem.ItemIsSelectable ) self.setZValue ( 1 ) ( x, y ) = self.node.offset self.setPos ( x, y ) @@ -72,6 +75,10 @@ def __init__ ( self, param = None, radius = UI.CONNECTOR_RADIUS, isRound = True, self.brush = self.paramsBrushes [ paramTypeStr ] #self.setFlag ( QtGui.QGraphicsItem.ItemIsSelectable ) + #if DEBUG_MODE : print '>> GfxNodeConnector::__init__' + #if DEBUG_MODE : print self + + # self.startNodeLink.connect ( self.onStartNodeLinkTest ) # # type # @@ -102,7 +109,7 @@ def paint ( self, painter, option, widget ) : painter.setPen ( pen ) painter.setBrush ( self.brush ) painter.drawEllipse ( self.rect ) - # print ( ">> GfxNodeConnector.paint" ) + #print ( ">> GfxNodeConnector.paint" ) # # getCenterPoint # @@ -329,19 +336,23 @@ def getScene ( self ) : # def itemChange ( self, change, value ) : # - if change == QtGui.QGraphicsItem.ItemSelectedHasChanged : - self.isNodeSelected = value.toBool () + #if DEBUG_MODE : print ">> itemChanged " + #if DEBUG_MODE : print change + #if DEBUG_MODE : print value + if change == QtModule.QGraphicsItem.ItemSelectedHasChanged : + #if DEBUG_MODE : print "* selection " + self.isNodeSelected = ( value == 1 ) #value.toBool () #if self.isNodeSelected : # node = self.parentItem ().node # if node is not None : # if DEBUG_MODE : print ">> selected conector for node %s (id = %d)" % ( node.label, node.id ) - elif change == QtGui.QGraphicsItem.ItemPositionHasChanged: + elif change == QtModule.QGraphicsItem.ItemPositionHasChanged : + #if DEBUG_MODE : print "* position " if self.isNode () : #if DEBUG_MODE : print ">> ItemPositionHasChanged conector for node %s ( %d, %d )" % ( self.node.label, self.x(), self.y() ) from meShaderEd import getDefaultValue grid_snap = getDefaultValue ( app_settings, 'WorkArea', 'grid_snap' ) grid_size = int ( getDefaultValue ( app_settings, 'WorkArea', 'grid_size' ) ) - x = self.x() y = self.y() if grid_snap : @@ -353,8 +364,17 @@ def itemChange ( self, change, value ) : #if DEBUG_MODE : print '* GfxNode.itemChange = ItemPositionHasChanged (%f, %f)' % ( x, y ) self.node.offset = ( x, y ) self.adjustLinks () - - return QtGui.QGraphicsItem.itemChange ( self, change, value ) + #return QtCore.QPointF ( x, y ) + + #elif change == QtModule.QGraphicsItem.ItemParentChange : + #if DEBUG_MODE : print "* parent " + # return value + #else : + # if DEBUG_MODE : print "* nothing " + # return value + + return QtModule.QGraphicsItem.itemChange ( self, change, value ) + # # hilite # @@ -363,53 +383,83 @@ def hilite ( self, state ) : self.isNodeSelected = state self.update() # + # onStartNodeLinkTest + # + @QtCore.pyqtSlot ( QtModule.QGraphicsItem ) # QtModule.QGraphicsItem QtModule.QGraphicsItem + def onStartNodeLinkTest ( self, connector ) : + # + if DEBUG_MODE : print '>> onStartNodeLinkTest' + #if DEBUG_MODE : print msg + if DEBUG_MODE : print connector + if DEBUG_MODE : print self + # # mousePressEvent # def mousePressEvent ( self, event ) : - #print ">> mousePressEvent" + #if DEBUG_MODE : print ">> mousePressEvent" + #if DEBUG_MODE : print self self.hilite( True ) if event.modifiers () == QtCore.Qt.ControlModifier : # start new ConnectorNode self.state = 'traceNodeConnector' - self.getScene ().emit ( QtCore.SIGNAL ( 'startNodeConnector' ), self, event.scenePos () ) + if QtCore.QT_VERSION < 50000 : + self.getScene ().emit ( QtCore.SIGNAL ( 'startNodeConnector' ), self, event.scenePos () ) + else : + self.getScene ().startNodeConnector.emit ( self, event.scenePos () ) else : if not self.isNode () : # start new link self.state = 'traceNodeLink' - self.getScene ().emit ( QtCore.SIGNAL ( 'startNodeLink' ), self ) - + if QtCore.QT_VERSION < 50000 : + self.getScene ().emit ( QtCore.SIGNAL ( 'startNodeLink' ), self ) + else : + #if DEBUG_MODE : print '* startNodeLink.emit ' + #if DEBUG_MODE : print self + self.getScene ().startNodeLink.emit ( self ) if self.state != 'idle' : self.grabMouse () event.accept () else : - QtGui.QGraphicsItem.mousePressEvent ( self, event ) + QtModule.QGraphicsItem.mousePressEvent ( self, event ) # # mouseMoveEvent # def mouseMoveEvent ( self, event ) : #print ">> mouseMoveEvent at %d %d" % ( event.scenePos().x(), event.scenePos().y() ) if self.state == 'traceNodeLink' : - self.getScene ().emit ( QtCore.SIGNAL ( 'traceNodeLink' ), self, event.scenePos () ) + if QtCore.QT_VERSION < 50000 : + self.getScene ().emit ( QtCore.SIGNAL ( 'traceNodeLink' ), self, event.scenePos () ) + else : + self.getScene ().traceNodeLink.emit ( self, event.scenePos () ) elif self.state == 'traceNodeConnector' : - self.getScene ().emit ( QtCore.SIGNAL ( 'traceNodeConnector' ), self, event.scenePos () ) + if QtCore.QT_VERSION < 50000 : + self.getScene ().emit ( QtCore.SIGNAL ( 'traceNodeConnector' ), self, event.scenePos () ) + else : + self.getScene ().traceNodeConnector.emit ( self, event.scenePos () ) if self.state != 'idle' : event.accept() else : - QtGui.QGraphicsItem.mouseMoveEvent ( self, event ) + QtModule.QGraphicsItem.mouseMoveEvent ( self, event ) # # mouseReleaseEvent # def mouseReleaseEvent ( self, event ) : #print ">> mouseReleaseEvent" if self.state == 'traceNodeLink' : - self.getScene ().emit ( QtCore.SIGNAL ( 'endNodeLink' ), self, event.scenePos () ) + if QtCore.QT_VERSION < 50000 : + self.getScene ().emit ( QtCore.SIGNAL ( 'endNodeLink' ), self, event.scenePos () ) + else : + self.getScene ().endNodeLink.emit ( self, event.scenePos () ) elif self.state == 'traceNodeConnector' : - self.getScene ().emit ( QtCore.SIGNAL ( 'endNodeConnector' ), self, event.scenePos () ) + if QtCore.QT_VERSION < 50000 : + self.getScene ().emit ( QtCore.SIGNAL ( 'endNodeConnector' ), self, event.scenePos () ) + else : + self.getScene ().endNodeConnector.emit ( self, event.scenePos () ) if self.state != 'idle' : self.hilite ( False ) self.state = 'idle' self.ungrabMouse () event.accept () else : - QtGui.QGraphicsItem.mouseReleaseEvent ( self, event ) + QtModule.QGraphicsItem.mouseReleaseEvent ( self, event ) diff --git a/gfx/gfxNodeLabel.py b/gfx/gfxNodeLabel.py index c298103..7e82b2c 100644 --- a/gfx/gfxNodeLabel.py +++ b/gfx/gfxNodeLabel.py @@ -54,8 +54,8 @@ def __init__ ( self, text, param = None, bgFill = True ) : self.editable = False self.processEvents = False - self.setFlag ( QtGui.QGraphicsItem.ItemIsMovable, False ) # QGraphicsItem QGraphicsWidget - self.setFlag ( QtGui.QGraphicsItem.ItemIsSelectable, False ) + self.setFlag ( QtModule.QGraphicsItem.ItemIsMovable, False ) + self.setFlag ( QtModule.QGraphicsItem.ItemIsSelectable, False ) self.rect = QtCore.QRectF () # @@ -165,8 +165,7 @@ def setProcessEvents ( self, process = True ) : # self.processEvents = process #self.setFlag ( QtGui.QGraphicsItem.ItemIsMovable, process ) - self.setFlag ( QtGui.QGraphicsItem.ItemIsSelectable, process ) - #self.setFlag ( QtGui.QGraphicsWidget.ItemIsSelectable, process ) + self.setFlag ( QtModule.QGraphicsItem.ItemIsSelectable, process ) # # mouseDoubleClickEvent # @@ -188,7 +187,7 @@ def mouseDoubleClickEvent ( self, event ) : def mousePressEvent ( self, event ) : if self.processEvents : #print ">> GfxNodeLabel.mousePressEvent" - inWhatsThisMode = QtGui.QWhatsThis.inWhatsThisMode () + inWhatsThisMode = QtModule.QWhatsThis.inWhatsThisMode () #if inWhatsThisMode : # print '** inWhatsThisMode active' from gfx.gfxNode import GfxNode @@ -221,8 +220,7 @@ def mousePressEvent ( self, event ) : parentNode.updateGfxNodeParamLabel ( self.param, self, True ) return QtCore.QEvent.ignore ( event ) - QtGui.QGraphicsItem.mousePressEvent ( self, event ) - #QtGui.QGraphicsWidget.mousePressEvent ( self, event ) + QtModule.QGraphicsItem.mousePressEvent ( self, event ) """ # # mouseMoveEvent diff --git a/gfx/gfxNote.py b/gfx/gfxNote.py index 70331d6..ed4849b 100644 --- a/gfx/gfxNote.py +++ b/gfx/gfxNote.py @@ -72,13 +72,13 @@ def __init__ ( self, node ) : self.BrushNodeNormal = QtGui.QBrush ( self.bgColor ) # flag (new from QT 4.6...) - self.setFlag ( QtGui.QGraphicsItem.ItemSendsScenePositionChanges ) - self.setFlag ( QtGui.QGraphicsItem.ItemSendsGeometryChanges ) - #self.setFlag ( QtGui.QGraphicsItem.ItemIsFocusable ) + self.setFlag ( QtModule.QGraphicsItem.ItemSendsScenePositionChanges ) + self.setFlag ( QtModule.QGraphicsItem.ItemSendsGeometryChanges ) + #self.setFlag ( QtModule.QGraphicsItem.ItemIsFocusable ) # qt graphics stuff - self.setFlag ( QtGui.QGraphicsItem.ItemIsMovable ) - self.setFlag ( QtGui.QGraphicsItem.ItemIsSelectable ) + self.setFlag ( QtModule.QGraphicsItem.ItemIsMovable ) + self.setFlag ( QtModule.QGraphicsItem.ItemIsSelectable ) self.setZValue ( 1 ) # # type @@ -202,16 +202,16 @@ def shape ( self ) : # def itemChange ( self, change, value ) : # - if change == QtGui.QGraphicsItem.ItemSelectedHasChanged : #ItemSelectedChange: - self.label_widget.setSelected ( value.toBool () ) - if value.toBool () : + if change == QtModule.QGraphicsItem.ItemSelectedHasChanged : #ItemSelectedChange: + self.label_widget.setSelected ( value == 1 ) + if value == 1 : items = self.scene ().items () for i in range ( len ( items ) - 1, -1, -1 ) : if items [ i ].parentItem() is None : if items [ i ] != self : items [ i ].stackBefore ( self ) #scene.setFocusItem ( self ) - elif change == QtGui.QGraphicsItem.ItemPositionHasChanged: + elif change == QtModule.QGraphicsItem.ItemPositionHasChanged: from meShaderEd import getDefaultValue grid_snap = getDefaultValue ( app_settings, 'WorkArea', 'grid_snap' ) grid_size = int ( getDefaultValue ( app_settings, 'WorkArea', 'grid_size' ) ) @@ -225,7 +225,7 @@ def itemChange ( self, change, value ) : #if DEBUG_MODE : print '* GfxNode.itemChange = ItemPositionHasChanged (%f, %f)' % ( x, y ) self.node.offset = ( x, y ) #self.adjustLinks () - return QtGui.QGraphicsItem.itemChange ( self, change, value ) + return QtModule.QGraphicsItem.itemChange ( self, change, value ) # # paint # diff --git a/gfx/imageView.py b/gfx/imageView.py index 185cf78..563150f 100644 --- a/gfx/imageView.py +++ b/gfx/imageView.py @@ -4,6 +4,7 @@ """ from core.mePyQt import QtCore, QtGui +from core.signal import Signal if QtCore.QT_VERSION < 50000 : QtModule = QtGui @@ -21,6 +22,12 @@ class ImageView ( QtModule.QGraphicsView ) : def __init__ ( self, parent ) : # QtModule.QGraphicsView.__init__ ( self, parent ) + # + # Define signals for PyQt5 + # + if QtCore.QT_VERSION >= 50000 : + # + self.mouseDoubleClickSignal = Signal () self.state = 'idle' self.panStartPos = None @@ -86,7 +93,10 @@ def mousePressEvent ( self, event ) : def mouseDoubleClickEvent ( self, event ) : # #print ">> ImageView.mouseDoubleClickEvent" - self.emit ( QtCore.SIGNAL ( 'mouseDoubleClickEvent' ) ) + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( 'mouseDoubleClickEvent' ) ) + else : + self.mouseDoubleClickSignal.emit () QtModule.QGraphicsView.mouseDoubleClickEvent ( self, event ) # # mouseMoveEvent diff --git a/gui/MainWindow.py b/gui/MainWindow.py index 7a3e656..02ea616 100644 --- a/gui/MainWindow.py +++ b/gui/MainWindow.py @@ -4,6 +4,7 @@ """ from core.mePyQt import QtCore, QtGui, QtXml +from core.signal import Signal #from PyQt4.QtGui import QWhatsThis from global_vars import app_global_vars, DEBUG_MODE, VALID_RIB_NODE_TYPES, VALID_RSL_NODE_TYPES, VALID_RSL_SHADER_TYPES from core.meCommon import * @@ -95,6 +96,15 @@ def __init__ ( self ) : #self.ui.dockNodes.setWindowTitle ( 'Library: %s' % app_global_vars [ 'NodesPath' ] ) #self.ui.dockProject.setWindowTitle ( 'Project: %s' % app_global_vars [ 'ProjectNetworks' ] ) + self.connectSignals () + + self.setupActions () + self.setupWindowTitle () + # + # connectSignals + # + def connectSignals ( self ) : + # if QtCore.QT_VERSION < 50000 : QtCore.QObject.connect ( self.ui.actionHelpMode, QtCore.SIGNAL ( 'toggled(bool)' ), self.onHelpMode ) QtCore.QObject.connect ( self.ui.nodeList_ctl.ui.nodeList, QtCore.SIGNAL ( 'setActiveNodeList' ), self.setActiveNodeList ) @@ -103,11 +113,20 @@ def __init__ ( self ) : QtCore.QObject.connect ( self.ui.tabs, QtCore.SIGNAL ( 'currentChanged(int)' ), self.onTabSelected ) QtCore.QObject.connect ( self.ui.tabs, QtCore.SIGNAL ( 'tabCloseRequested(int)' ), self.onTabCloseRequested ) - QtCore.QObject.connect ( self.ui.nodeParam_ctl, QtCore.SIGNAL ( 'nodeLabelChanged' ), self.onNodeLabelChanged ) - QtCore.QObject.connect ( self.ui.nodeParam_ctl, QtCore.SIGNAL ( 'nodeParamChanged' ), self.onNodeParamChanged ) - - self.setupActions () - self.setupWindowTitle () + QtCore.QObject.connect ( self.ui.nodeParam_ctl, QtCore.SIGNAL ( 'nodeLabelChangedSignal' ), self.onNodeLabelChanged ) + QtCore.QObject.connect ( self.ui.nodeParam_ctl, QtCore.SIGNAL ( 'nodeParamChangedSignal' ), self.onNodeParamChanged ) + else : + self.ui.actionHelpMode.toggled.connect ( self.onHelpMode ) + + self.ui.nodeList_ctl.ui.nodeList.setActiveNodeList.connect ( self.setActiveNodeList ) + self.ui.project_ctl.ui.nodeList.setActiveNodeList.connect ( self.setActiveNodeList ) + + self.ui.tabs.currentChanged.connect ( self.onTabSelected ) + self.ui.tabs.tabCloseRequested.connect ( self.onTabCloseRequested ) + + self.ui.nodeParam_ctl.nodeLabelChangedSignal.connect ( self.onNodeLabelChanged ) + self.ui.nodeParam_ctl.nodeParamChangedSignal.connect ( self.onNodeParamChanged ) + # # connectWorkAreaSignals # @@ -116,14 +135,26 @@ def connectWorkAreaSignals ( self ) : if QtCore.QT_VERSION < 50000 : if self.workArea != None : if self.activeNodeList != None : - QtCore.QObject.connect ( self.activeNodeList, QtCore.SIGNAL ( 'addNode' ), self.workArea.insertNodeNet ) - QtCore.QObject.connect ( self.workArea, QtCore.SIGNAL ( 'selectNodes' ), self.onSelectGfxNodes ) - QtCore.QObject.connect ( self.workArea, QtCore.SIGNAL ( 'nodeConnectionChanged' ), self.onGfxNodeParamChanged ) + QtCore.QObject.connect ( self.activeNodeList, QtCore.SIGNAL ( 'addNode' ), self.workArea.insertNodeNet ) + QtCore.QObject.connect ( self.workArea, QtCore.SIGNAL ( 'selectNodes' ), self.onSelectGfxNodes ) + QtCore.QObject.connect ( self.workArea, QtCore.SIGNAL ( 'nodeConnectionChanged' ), self.onGfxNodeParamChanged ) QtCore.QObject.connect ( self.workArea, QtCore.SIGNAL ( 'gfxNodeAdded' ), self.onAddGfxNode ) QtCore.QObject.connect ( self.workArea, QtCore.SIGNAL ( 'gfxNodeRemoved' ), self.onRemoveGfxNode ) #QtCore.QObject.connect ( self.workArea, QtCore.SIGNAL ( 'editGfxNode' ), self.editGfxNode ) QtCore.QObject.connect ( self.workArea.scene(), QtCore.SIGNAL ( 'nodeUpdated' ), self.updateNodeParamView ) - QtCore.QObject.connect ( self.workArea.scene(), QtCore.SIGNAL ( 'gfxNodeParamChanged' ), self.onGfxNodeParamChanged ) + QtCore.QObject.connect ( self.workArea.scene(), QtCore.SIGNAL ( 'gfxNodeParamChanged' ), self.onGfxNodeParamChanged ) + else : + if self.workArea != None : + if self.activeNodeList != None : + self.activeNodeList.addNode.connect( self.workArea.insertNodeNet ) + self.workArea.selectNodes.connect ( self.onSelectGfxNodes ) + self.workArea.nodeConnectionChanged.connect ( self.onGfxNodeParamChanged ) + self.workArea.gfxNodeAdded.connect ( self.onAddGfxNode ) + self.workArea.gfxNodeRemoved.connect ( self.onRemoveGfxNode ) + #self.workArea.editGfxNode.connect ( self.editGfxNode ) + self.workArea.scene().nodeUpdated.connect ( self.updateNodeParamView ) + self.workArea.scene().gfxNodeParamChanged.connect ( self.onGfxNodeParamChanged ) + # # disconnectWorkAreaSignals # @@ -374,7 +405,6 @@ def onShowGrid ( self, check ) : app_settings.beginGroup ( 'WorkArea' ) app_settings.setValue ( 'grid_enabled', bool ( check ) ) app_settings.endGroup () - self.workArea.resetCachedContent () #self.ui.workArea.update() # @@ -395,7 +425,6 @@ def onReverseFlow ( self, check ) : app_settings.beginGroup ( 'WorkArea' ) app_settings.setValue ( 'reverse_flow', bool ( check ) ) app_settings.endGroup () - #self.ui.workArea.resetCachedContent() # # onStraightLinks @@ -414,10 +443,16 @@ def onStraightLinks ( self, check ) : def setActiveNodeList ( self, nodeList ) : # if DEBUG_MODE : print '>> MainWindow.setActiveNodeList' - if self.activeNodeList != None : - QtCore.QObject.disconnect ( self.activeNodeList, QtCore.SIGNAL ( 'addNode' ), self.workArea.insertNodeNet ) - self.activeNodeList = nodeList - QtCore.QObject.connect ( self.activeNodeList, QtCore.SIGNAL ( 'addNode' ), self.workArea.insertNodeNet ) + if QtCore.QT_VERSION < 50000 : + if self.activeNodeList != None : + QtCore.QObject.disconnect ( self.activeNodeList, QtCore.SIGNAL ( 'addNode' ), self.workArea.insertNodeNet ) + self.activeNodeList = nodeList + QtCore.QObject.connect ( self.activeNodeList, QtCore.SIGNAL ( 'addNode' ), self.workArea.insertNodeNet ) + else : + if self.activeNodeList != None : + self.activeNodeList.addNode.disconnect ( self.workArea.insertNodeNet ) + self.activeNodeList = nodeList + self.activeNodeList.addNode.connect( self.workArea.insertNodeNet ) # # onGetNode # @@ -434,7 +469,8 @@ def onGetNode ( self, itemFilename, pos ) : def onAddGfxNode ( self, gfxNode ) : # #print ">> MainWindow: onAddGfxNode = %s" % gfxNode.node.label - if gfxNode.node.type == 'image' : self.ui.imageView_ctl.addViewer ( gfxNode ) + if gfxNode.node.type == 'image' : + self.ui.imageView_ctl.addViewer ( gfxNode ) #if self.ui.nodeParam_ctl.receivers( QtCore.SIGNAL( 'onNodeParamChanged(QObject,QObject)' ) ) == 0 : # QtCore.QObject.connect( self.ui.nodeParam_ctl, QtCore.SIGNAL( 'onNodeParamChanged(QObject,QObject)' ), self.ui.imageView_ctl.onNodeParamChanged ) @@ -722,7 +758,8 @@ def onTabCloseRequested ( self, idx ) : self.ui.tabs.removeTab ( idx ) # # onNew - # + # + @QtCore.pyqtSlot () def onNew ( self, tabName = 'untitled' ) : # def tabNameExists ( self, name ) : @@ -732,7 +769,7 @@ def tabNameExists ( self, name ) : ret = True break return ret - + # newName = tabName if DEBUG_MODE : print '-> self.ui.tabs.count() = %d ' % self.ui.tabs.count () @@ -743,11 +780,13 @@ def tabNameExists ( self, name ) : i = 0 while True : if tabNameExists ( self, name ) : - name = newName + str ( i ) + name = newName + str ( i ) + print name i += 1 continue else : break + newName = name workArea = WorkArea () # create new WorkArea instance newTab = self.ui.tabs.addTab ( workArea, newName ) @@ -848,7 +887,7 @@ def onImport ( self ) : curDir = app_global_vars [ 'ProjectNetworks' ] typeFilter = 'Shader networks *.xml;;All files *.*;;' - filename = str ( QtGui.QFileDialog.getOpenFileName ( self, "Import file", curDir, typeFilter ) ) + filename = str ( QtModule.QFileDialog.getOpenFileName ( self, "Import file", curDir, typeFilter ) ) if filename != '' : if DEBUG_MODE : print "-> import file %s" % filename self.workArea.insertNodeNet ( normPath ( filename ) ) @@ -864,7 +903,7 @@ def onSaveSelected ( self ) : saveName = os.path.join ( curDir, self.workArea.nodeNet.name + '.xml' ) typeFilter = 'Shader networks *.xml;;All files *.*;;' - filename = str( QtGui.QFileDialog.getSaveFileName ( self, "Save file as", saveName, typeFilter ) ) + filename = str( QtModule.QFileDialog.getSaveFileName ( self, "Save file as", saveName, typeFilter ) ) if filename != '' : if DEBUG_MODE : print '-> save file As %s' % filename ( name, ext ) = os.path.splitext ( os.path.basename ( filename ) ) @@ -908,7 +947,7 @@ def onSaveAs ( self ) : saveName = os.path.join ( curDir, self.workArea.nodeNet.name + '.xml' ) typeFilter = 'Shader networks *.xml;;All files *.*;;' - filename = str( QtGui.QFileDialog.getSaveFileName ( self, "Save file as", saveName, typeFilter ) ) + filename = str( QtModule.QFileDialog.getSaveFileName ( self, "Save file as", saveName, typeFilter ) ) if filename != '' : if DEBUG_MODE : print '-> save file As %s' % filename ( name, ext ) = os.path.splitext ( os.path.basename ( filename ) ) @@ -925,7 +964,7 @@ def onSaveAs ( self ) : def onHelpMode ( self, showWhatsThis ) : # #if showWhatsThis : - QtGui.QWhatsThis.enterWhatsThisMode () + QtModule.QWhatsThis.enterWhatsThisMode () #else : # QtGui.QWhatsThis.leaveWhatsThisMode () # diff --git a/gui/ProjectSetup.py b/gui/ProjectSetup.py index c9b16f6..fe506db 100644 --- a/gui/ProjectSetup.py +++ b/gui/ProjectSetup.py @@ -51,10 +51,16 @@ def buildGui ( self ): self.ui.lineEdit_project.setText ( self.rootDir ) - self.ui.lineEdit_network.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'shader_networks' ).toString () ) ) ) - self.ui.lineEdit_sources.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'shader_sources' ).toString () ) ) ) - self.ui.lineEdit_shaders.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'project_shaders' ).toString () ) ) ) - self.ui.lineEdit_textures.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'project_textures' ).toString () ) ) ) + if QtCore.QT_VERSION < 50000 : + self.ui.lineEdit_network.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'shader_networks' ).toString () ) ) ) + self.ui.lineEdit_sources.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'shader_sources' ).toString () ) ) ) + self.ui.lineEdit_shaders.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'project_shaders' ).toString () ) ) ) + self.ui.lineEdit_textures.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'project_textures' ).toString () ) ) ) + else : + self.ui.lineEdit_network.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'shader_networks' ) ) ) ) + self.ui.lineEdit_sources.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'shader_sources' ) ) ) ) + self.ui.lineEdit_shaders.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'project_shaders' ) ) ) ) + self.ui.lineEdit_textures.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'project_textures' ) ) ) ) # # setupProject # diff --git a/gui/SettingsSetup.py b/gui/SettingsSetup.py index 9111a07..8c4e6f4 100644 --- a/gui/SettingsSetup.py +++ b/gui/SettingsSetup.py @@ -49,13 +49,22 @@ def buildGui ( self ): ##else : ## font.setPointSize(10) - self.ui.lineEdit_temp.setText( self.app_settings.value('temp').toString() ) - self.ui.lineEdit_inc.setText( self.app_settings.value('include').toString() ) - self.ui.lineEdit_lib.setText( self.app_settings.value('lib').toString() ) - self.ui.lineEdit_nodes.setText( self.app_settings.value('nodes').toString() ) - self.ui.lineEdit_shaders.setText( self.app_settings.value('shaders').toString() ) - self.ui.lineEdit_textures.setText( self.app_settings.value('texture').toString() ) - self.ui.lineEdit_archives.setText( self.app_settings.value('archive').toString() ) + if QtCore.QT_VERSION < 50000 : + self.ui.lineEdit_temp.setText( self.app_settings.value('temp').toString() ) + self.ui.lineEdit_inc.setText( self.app_settings.value('include').toString() ) + self.ui.lineEdit_lib.setText( self.app_settings.value('lib').toString() ) + self.ui.lineEdit_nodes.setText( self.app_settings.value('nodes').toString() ) + self.ui.lineEdit_shaders.setText( self.app_settings.value('shaders').toString() ) + self.ui.lineEdit_textures.setText( self.app_settings.value('texture').toString() ) + self.ui.lineEdit_archives.setText( self.app_settings.value('archive').toString() ) + else : + self.ui.lineEdit_temp.setText( self.app_settings.value('temp') ) + self.ui.lineEdit_inc.setText( self.app_settings.value('include') ) + self.ui.lineEdit_lib.setText( self.app_settings.value('lib') ) + self.ui.lineEdit_nodes.setText( self.app_settings.value('nodes') ) + self.ui.lineEdit_shaders.setText( self.app_settings.value('shaders') ) + self.ui.lineEdit_textures.setText( self.app_settings.value('texture') ) + self.ui.lineEdit_archives.setText( self.app_settings.value('archive') ) # # def onBrowseTempDir ( self ): diff --git a/gui/ViewComputedCodeDialog.py b/gui/ViewComputedCodeDialog.py index 09e287f..1fcb2ce 100644 --- a/gui/ViewComputedCodeDialog.py +++ b/gui/ViewComputedCodeDialog.py @@ -35,7 +35,6 @@ def __init__ ( self, node = None ): self.node = node self.code = self.getComputedCode ( node ) self.buildGui () - # # buildGui # diff --git a/gui/exportShader/ExportShaderDialog.py b/gui/exportShader/ExportShaderDialog.py index d6134f2..0bdada1 100644 --- a/gui/exportShader/ExportShaderDialog.py +++ b/gui/exportShader/ExportShaderDialog.py @@ -8,6 +8,7 @@ """ from core.mePyQt import QtCore, QtGui +from core.signal import Signal #from PyQt4.QtCore import QVariant from core.meCommon import * @@ -56,31 +57,55 @@ def __init__ ( self, node ) : # def connectSignals ( self ) : # QtCore.QObject - QtCore.QObject.connect ( self.ui.list_nodes, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onNodeChanged ) - QtCore.QObject.connect ( self.ui.list_inputs, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onInputParamChanged ) - QtCore.QObject.connect ( self.ui.list_outputs, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onOutputParamChanged ) - QtCore.QObject.connect ( self.ui.node, QtCore.SIGNAL ( 'changeNodeLabel' ), self.onRenameNodeLabel ) - - QtCore.QObject.connect ( self.ui.param, QtCore.SIGNAL ( 'changeParamLabel' ), self.onParamChange ) - QtCore.QObject.connect ( self.ui.param, QtCore.SIGNAL ( 'changeParamIsShader' ), self.onParamChange ) - QtCore.QObject.connect ( self.ui.param, QtCore.SIGNAL ( 'changeParamDetail' ), self.onParamChange ) - QtCore.QObject.connect ( self.ui.param, QtCore.SIGNAL ( 'changeParamProvider' ), self.onParamChange ) - QtCore.QObject.connect ( self.ui.param, QtCore.SIGNAL ( 'changeParamValue' ), self.onParamChange ) + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.connect ( self.ui.list_nodes, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onNodeChanged ) + QtCore.QObject.connect ( self.ui.list_inputs, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onInputParamChanged ) + QtCore.QObject.connect ( self.ui.list_outputs, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onOutputParamChanged ) + QtCore.QObject.connect ( self.ui.node, QtCore.SIGNAL ( 'changeNodeLabel' ), self.onRenameNodeLabel ) + + QtCore.QObject.connect ( self.ui.param, QtCore.SIGNAL ( 'changeParamLabel' ), self.onParamChange ) + QtCore.QObject.connect ( self.ui.param, QtCore.SIGNAL ( 'changeParamIsShader' ), self.onParamChange ) + QtCore.QObject.connect ( self.ui.param, QtCore.SIGNAL ( 'changeParamDetail' ), self.onParamChange ) + QtCore.QObject.connect ( self.ui.param, QtCore.SIGNAL ( 'changeParamProvider' ), self.onParamChange ) + QtCore.QObject.connect ( self.ui.param, QtCore.SIGNAL ( 'changeParamValue' ), self.onParamChange ) + else : + self.ui.list_nodes.temSelectionChanged.connect ( self.onNodeChanged ) + self.ui.list_inputs,temSelectionChanged.connect ( self.onInputParamChanged ) + self.ui.list_outputs.temSelectionChanged.connect ( self.onOutputParamChanged ) + + self.ui.node.changeNodeLabel.connect ( self.onRenameNodeLabel ) + self.ui.param.changeParamLabel.connect ( self.onParamChange ) + self.ui.param.changeParamIsShader.connect ( self.onParamChange ) + self.ui.param.changeParamDetail.connect ( self.onParamChange ) + self.ui.param.changeParamProvider.connect ( self.onParamChange ) + self.ui.param.changeParamValue.connect ( self.onParamChange ) # # disconnectSignals # def disconnectSignals ( self ) : # - QtCore.QObject.disconnect ( self.ui.list_nodes, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onNodeChanged ) - QtCore.QObject.disconnect ( self.ui.list_inputs, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onInputParamChanged ) - QtCore.QObject.disconnect ( self.ui.list_outputs, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onOutputParamChanged ) - QtCore.QObject.disconnect ( self.ui.node, QtCore.SIGNAL ( 'changeNodeLabel' ), self.onRenameNodeLabel ) - - QtCore.QObject.disconnect ( self.ui.param, QtCore.SIGNAL ( 'changeParamLabel' ), self.onParamChange ) - QtCore.QObject.disconnect ( self.ui.param, QtCore.SIGNAL ( 'changeParamIsShader' ), self.onParamChange ) - QtCore.QObject.disconnect ( self.ui.param, QtCore.SIGNAL ( 'changeParamDetail' ), self.onParamChange ) - QtCore.QObject.disconnect ( self.ui.param, QtCore.SIGNAL ( 'changeParamProvider' ), self.onParamChange ) - QtCore.QObject.disconnect ( self.ui.param, QtCore.SIGNAL ( 'changeParamValue' ), self.onParamChange ) + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.disconnect ( self.ui.list_nodes, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onNodeChanged ) + QtCore.QObject.disconnect ( self.ui.list_inputs, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onInputParamChanged ) + QtCore.QObject.disconnect ( self.ui.list_outputs, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onOutputParamChanged ) + + QtCore.QObject.disconnect ( self.ui.node, QtCore.SIGNAL ( 'changeNodeLabel' ), self.onRenameNodeLabel ) + QtCore.QObject.disconnect ( self.ui.param, QtCore.SIGNAL ( 'changeParamLabel' ), self.onParamChange ) + QtCore.QObject.disconnect ( self.ui.param, QtCore.SIGNAL ( 'changeParamIsShader' ), self.onParamChange ) + QtCore.QObject.disconnect ( self.ui.param, QtCore.SIGNAL ( 'changeParamDetail' ), self.onParamChange ) + QtCore.QObject.disconnect ( self.ui.param, QtCore.SIGNAL ( 'changeParamProvider' ), self.onParamChange ) + QtCore.QObject.disconnect ( self.ui.param, QtCore.SIGNAL ( 'changeParamValue' ), self.onParamChange ) + else : + self.ui.list_nodes.temSelectionChanged.disconnect ( self.onNodeChanged ) + self.ui.list_inputs,temSelectionChanged.disconnect ( self.onInputParamChanged ) + self.ui.list_outputs.temSelectionChanged.disconnect ( self.onOutputParamChanged ) + + self.ui.node.changeNodeLabel.disconnect ( self.onRenameNodeLabel ) + self.ui.param.changeParamLabel.disconnect ( self.onParamChange ) + self.ui.param.changeParamIsShader.disconnect ( self.onParamChange ) + self.ui.param.changeParamDetail.disconnect ( self.onParamChange ) + self.ui.param.changeParamProvider.disconnect ( self.onParamChange ) + self.ui.param.changeParamValue.disconnect ( self.onParamChange ) # # buildGui # @@ -111,7 +136,7 @@ def buildGui ( self ) : print '*** (%s) children list: ' % self.editNode.label for node in self.editNode.visitedNodes : #childrenList : print '* (%s)' % node.label - item = QtGui.QListWidgetItem ( node.label ) + item = QtModule.QListWidgetItem ( node.label ) item.setData ( QtCore.Qt.UserRole + 1, QVariant ( node ) ) self.ui.list_nodes.addItem ( item ) # @@ -124,13 +149,13 @@ def updateComputedParams ( self ) : self.computed_code = self.editNode.getComputedCode ( CodeOnly = True ) # setup input params list for ( param, node ) in self.editNode.computedInputParamsList : - item = QtGui.QListWidgetItem ( ( node.getParamDeclaration ( param )).rstrip ( ';\n' ) ) + item = QtModule.QListWidgetItem ( ( node.getParamDeclaration ( param )).rstrip ( ';\n' ) ) item.setData ( QtCore.Qt.UserRole + 1, QVariant ( param ) ) item.setData ( QtCore.Qt.UserRole + 2, QVariant ( node ) ) self.ui.list_inputs.addItem ( item ) # setup output params list for ( param, node ) in self.editNode.computedOutputParamsList : - item = QtGui.QListWidgetItem ( ( 'output ' + node.getParamDeclaration ( param ) ).rstrip ( ';\n' ) ) + item = QtModule.QListWidgetItem ( ( 'output ' + node.getParamDeclaration ( param ) ).rstrip ( ';\n' ) ) item.setData ( QtCore.Qt.UserRole + 1, QVariant ( param ) ) item.setData ( QtCore.Qt.UserRole + 2, QVariant ( node ) ) self.ui.list_outputs.addItem ( item ) @@ -148,7 +173,7 @@ def updateNodeParams ( self, node ) : linkedBrush.setColor ( QtCore.Qt.blue ) # setup input params list for param in node.inputParams : - item = QtGui.QListWidgetItem ( param.label ) + item = QtModule.QListWidgetItem ( param.label ) item.setData ( QtCore.Qt.UserRole + 1, QVariant ( param ) ) item.setData ( QtCore.Qt.UserRole + 2, QVariant ( node ) ) if node.isInputParamLinked ( param ) : @@ -284,7 +309,7 @@ def onExport ( self ) : saveName = os.path.join ( app_global_vars [ 'ProjectSources' ], self.editNode.getInstanceName () + '.sl' ) typeFilter = 'Shader source files *.sl;;All files *.*;;' - filename = str( QtGui.QFileDialog.getSaveFileName ( self, "Export shader code as", saveName, typeFilter ) ) + filename = str( QtModule.QFileDialog.getSaveFileName ( self, "Export shader code as", saveName, typeFilter ) ) if filename != '' : if DEBUG_MODE : print '-> Export shader code as %s' % filename shaderCode = self.editNode.getComputedCode () diff --git a/gui/exportShader/ui_exportShaderDialog.py b/gui/exportShader/ui_exportShaderDialog.py index 3835a27..9967752 100644 --- a/gui/exportShader/ui_exportShaderDialog.py +++ b/gui/exportShader/ui_exportShaderDialog.py @@ -8,132 +8,151 @@ # WARNING! All changes made in this file will be lost! from core.mePyQt import QtCore, QtGui +from core.signal import Signal + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets try: - _fromUtf8 = QtCore.QString.fromUtf8 + _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: - def _fromUtf8(s): - return s + def _fromUtf8(s): + return s try: - _encoding = QtGui.QApplication.UnicodeUTF8 - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig, _encoding) + _encoding = QtModule.QApplication.UnicodeUTF8 + def _translate(context, text, disambig): + return QtModule.QApplication.translate(context, text, disambig, _encoding) except AttributeError: - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig) + def _translate(context, text, disambig): + return QtModule.QApplication.translate(context, text, disambig) class Ui_ExportShaderDialog(object): - def setupUi(self, ExportShaderDialog): - ExportShaderDialog.setObjectName(_fromUtf8("ExportShaderDialog")) - ExportShaderDialog.resize(955, 711) - self.gridLayout_7 = QtGui.QGridLayout(ExportShaderDialog) - self.gridLayout_7.setObjectName(_fromUtf8("gridLayout_7")) - self.gridLayout_6 = QtGui.QGridLayout() - self.gridLayout_6.setObjectName(_fromUtf8("gridLayout_6")) - self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) - self.chk_save_changes = QtGui.QCheckBox(ExportShaderDialog) - self.chk_save_changes.setChecked(True) - self.chk_save_changes.setObjectName(_fromUtf8("chk_save_changes")) - self.horizontalLayout.addWidget(self.chk_save_changes) - spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout.addItem(spacerItem) - self.btn_view = QtGui.QPushButton(ExportShaderDialog) - self.btn_view.setObjectName(_fromUtf8("btn_view")) - self.horizontalLayout.addWidget(self.btn_view) - self.btn_export = QtGui.QPushButton(ExportShaderDialog) - self.btn_export.setObjectName(_fromUtf8("btn_export")) - self.horizontalLayout.addWidget(self.btn_export) - self.btn_close = QtGui.QPushButton(ExportShaderDialog) - self.btn_close.setDefault(False) - self.btn_close.setObjectName(_fromUtf8("btn_close")) - self.horizontalLayout.addWidget(self.btn_close) - self.gridLayout_6.addLayout(self.horizontalLayout, 1, 0, 1, 1) - self.splitter = QtGui.QSplitter(ExportShaderDialog) - self.splitter.setOrientation(QtCore.Qt.Horizontal) - self.splitter.setObjectName(_fromUtf8("splitter")) - self.node_tabWidget = QtGui.QTabWidget(self.splitter) - self.node_tabWidget.setObjectName(_fromUtf8("node_tabWidget")) - self.tab = QtGui.QWidget() - self.tab.setObjectName(_fromUtf8("tab")) - self.gridLayout = QtGui.QGridLayout(self.tab) - self.gridLayout.setMargin(2) - self.gridLayout.setSpacing(2) - self.gridLayout.setObjectName(_fromUtf8("gridLayout")) - self.list_nodes = QtGui.QListWidget(self.tab) - self.list_nodes.setModelColumn(0) - self.list_nodes.setObjectName(_fromUtf8("list_nodes")) - self.gridLayout.addWidget(self.list_nodes, 0, 0, 1, 1) - self.node_tabWidget.addTab(self.tab, _fromUtf8("")) - self.params_tabWidget = QtGui.QTabWidget(self.splitter) - self.params_tabWidget.setObjectName(_fromUtf8("params_tabWidget")) - self.tab_inputs = QtGui.QWidget() - self.tab_inputs.setObjectName(_fromUtf8("tab_inputs")) - self.gridLayout_2 = QtGui.QGridLayout(self.tab_inputs) - self.gridLayout_2.setMargin(2) - self.gridLayout_2.setSpacing(2) - self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) - self.list_inputs = QtGui.QListWidget(self.tab_inputs) - self.list_inputs.setObjectName(_fromUtf8("list_inputs")) - self.gridLayout_2.addWidget(self.list_inputs, 0, 0, 1, 1) - self.params_tabWidget.addTab(self.tab_inputs, _fromUtf8("")) - self.tab_outputs = QtGui.QWidget() - self.tab_outputs.setObjectName(_fromUtf8("tab_outputs")) - self.gridLayout_3 = QtGui.QGridLayout(self.tab_outputs) - self.gridLayout_3.setMargin(2) - self.gridLayout_3.setSpacing(2) - self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3")) - self.list_outputs = QtGui.QListWidget(self.tab_outputs) - self.list_outputs.setObjectName(_fromUtf8("list_outputs")) - self.gridLayout_3.addWidget(self.list_outputs, 0, 0, 1, 1) - self.params_tabWidget.addTab(self.tab_outputs, _fromUtf8("")) - self.prop_tabWidget = QtGui.QTabWidget(self.splitter) - self.prop_tabWidget.setObjectName(_fromUtf8("prop_tabWidget")) - self.tab_prop_node = QtGui.QWidget() - self.tab_prop_node.setObjectName(_fromUtf8("tab_prop_node")) - self.gridLayout_4 = QtGui.QGridLayout(self.tab_prop_node) - self.gridLayout_4.setMargin(2) - self.gridLayout_4.setSpacing(2) - self.gridLayout_4.setObjectName(_fromUtf8("gridLayout_4")) - self.node = NodePropertiesEditor(self.tab_prop_node) - self.node.setObjectName(_fromUtf8("node")) - self.gridLayout_4.addWidget(self.node, 0, 0, 1, 1) - self.prop_tabWidget.addTab(self.tab_prop_node, _fromUtf8("")) - self.tab_prop_param = QtGui.QWidget() - self.tab_prop_param.setObjectName(_fromUtf8("tab_prop_param")) - self.gridLayout_5 = QtGui.QGridLayout(self.tab_prop_param) - self.gridLayout_5.setMargin(2) - self.gridLayout_5.setSpacing(2) - self.gridLayout_5.setObjectName(_fromUtf8("gridLayout_5")) - self.param = NodeParamEditor(self.tab_prop_param) - self.param.setObjectName(_fromUtf8("param")) - self.gridLayout_5.addWidget(self.param, 0, 0, 1, 1) - self.prop_tabWidget.addTab(self.tab_prop_param, _fromUtf8("")) - self.gridLayout_6.addWidget(self.splitter, 0, 0, 1, 1) - self.gridLayout_6.setRowStretch(0, 1) - self.gridLayout_7.addLayout(self.gridLayout_6, 0, 0, 1, 1) + def setupUi(self, ExportShaderDialog): + ExportShaderDialog.setObjectName(_fromUtf8("ExportShaderDialog")) + ExportShaderDialog.resize(955, 711) + self.gridLayout_7 = QtModule.QGridLayout(ExportShaderDialog) + self.gridLayout_7.setObjectName(_fromUtf8("gridLayout_7")) + self.gridLayout_6 = QtModule.QGridLayout() + self.gridLayout_6.setObjectName(_fromUtf8("gridLayout_6")) + self.horizontalLayout = QtModule.QHBoxLayout() + self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) + self.chk_save_changes = QtModule.QCheckBox(ExportShaderDialog) + self.chk_save_changes.setChecked(True) + self.chk_save_changes.setObjectName(_fromUtf8("chk_save_changes")) + self.horizontalLayout.addWidget(self.chk_save_changes) + spacerItem = QtModule.QSpacerItem(40, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) + self.horizontalLayout.addItem(spacerItem) + self.btn_view = QtModule.QPushButton(ExportShaderDialog) + self.btn_view.setObjectName(_fromUtf8("btn_view")) + self.horizontalLayout.addWidget(self.btn_view) + self.btn_export = QtModule.QPushButton(ExportShaderDialog) + self.btn_export.setObjectName(_fromUtf8("btn_export")) + self.horizontalLayout.addWidget(self.btn_export) + self.btn_close = QtModule.QPushButton(ExportShaderDialog) + self.btn_close.setDefault(False) + self.btn_close.setObjectName(_fromUtf8("btn_close")) + self.horizontalLayout.addWidget(self.btn_close) + self.gridLayout_6.addLayout(self.horizontalLayout, 1, 0, 1, 1) + self.splitter = QtModule.QSplitter(ExportShaderDialog) + self.splitter.setOrientation(QtCore.Qt.Horizontal) + self.splitter.setObjectName(_fromUtf8("splitter")) + self.node_tabWidget = QtModule.QTabWidget(self.splitter) + self.node_tabWidget.setObjectName(_fromUtf8("node_tabWidget")) + self.tab = QtModule.QWidget() + self.tab.setObjectName(_fromUtf8("tab")) + self.gridLayout = QtModule.QGridLayout(self.tab) + if QtCore.QT_VERSION < 50000 : + self.gridLayout.setMargin(2) + self.gridLayout.setSpacing(2) + self.gridLayout.setObjectName(_fromUtf8("gridLayout")) + self.list_nodes = QtModule.QListWidget(self.tab) + self.list_nodes.setModelColumn(0) + self.list_nodes.setObjectName(_fromUtf8("list_nodes")) + self.gridLayout.addWidget(self.list_nodes, 0, 0, 1, 1) + self.node_tabWidget.addTab(self.tab, _fromUtf8("")) + self.params_tabWidget = QtModule.QTabWidget(self.splitter) + self.params_tabWidget.setObjectName(_fromUtf8("params_tabWidget")) + self.tab_inputs = QtModule.QWidget() + self.tab_inputs.setObjectName(_fromUtf8("tab_inputs")) + self.gridLayout_2 = QtModule.QGridLayout(self.tab_inputs) + + if QtCore.QT_VERSION < 50000 : + self.gridLayout_2.setMargin(2) + self.gridLayout_2.setSpacing(2) + self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) + self.list_inputs = QtModule.QListWidget(self.tab_inputs) + self.list_inputs.setObjectName(_fromUtf8("list_inputs")) + self.gridLayout_2.addWidget(self.list_inputs, 0, 0, 1, 1) + self.params_tabWidget.addTab(self.tab_inputs, _fromUtf8("")) + self.tab_outputs = QtModule.QWidget() + self.tab_outputs.setObjectName(_fromUtf8("tab_outputs")) + self.gridLayout_3 = QtModule.QGridLayout(self.tab_outputs) + if QtCore.QT_VERSION < 50000 : + self.gridLayout_3.setMargin(2) + self.gridLayout_3.setSpacing(2) + self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3")) + self.list_outputs = QtModule.QListWidget(self.tab_outputs) + self.list_outputs.setObjectName(_fromUtf8("list_outputs")) + self.gridLayout_3.addWidget(self.list_outputs, 0, 0, 1, 1) + self.params_tabWidget.addTab(self.tab_outputs, _fromUtf8("")) + self.prop_tabWidget = QtModule.QTabWidget(self.splitter) + self.prop_tabWidget.setObjectName(_fromUtf8("prop_tabWidget")) + self.tab_prop_node = QtModule.QWidget() + self.tab_prop_node.setObjectName(_fromUtf8("tab_prop_node")) + self.gridLayout_4 = QtModule.QGridLayout(self.tab_prop_node) + if QtCore.QT_VERSION < 50000 : + self.gridLayout_4.setMargin(2) + self.gridLayout_4.setSpacing(2) + self.gridLayout_4.setObjectName(_fromUtf8("gridLayout_4")) + self.node = NodePropertiesEditor(self.tab_prop_node) + self.node.setObjectName(_fromUtf8("node")) + self.gridLayout_4.addWidget(self.node, 0, 0, 1, 1) + self.prop_tabWidget.addTab(self.tab_prop_node, _fromUtf8("")) + self.tab_prop_param = QtModule.QWidget() + self.tab_prop_param.setObjectName(_fromUtf8("tab_prop_param")) + self.gridLayout_5 = QtModule.QGridLayout(self.tab_prop_param) + if QtCore.QT_VERSION < 50000 : + self.gridLayout_5.setMargin(2) + self.gridLayout_5.setSpacing(2) + self.gridLayout_5.setObjectName(_fromUtf8("gridLayout_5")) + self.param = NodeParamEditor(self.tab_prop_param) + self.param.setObjectName(_fromUtf8("param")) + self.gridLayout_5.addWidget(self.param, 0, 0, 1, 1) + self.prop_tabWidget.addTab(self.tab_prop_param, _fromUtf8("")) + self.gridLayout_6.addWidget(self.splitter, 0, 0, 1, 1) + self.gridLayout_6.setRowStretch(0, 1) + self.gridLayout_7.addLayout(self.gridLayout_6, 0, 0, 1, 1) - self.retranslateUi(ExportShaderDialog) - self.node_tabWidget.setCurrentIndex(0) - self.params_tabWidget.setCurrentIndex(0) - self.prop_tabWidget.setCurrentIndex(0) - QtCore.QObject.connect(self.btn_export, QtCore.SIGNAL(_fromUtf8("clicked()")), ExportShaderDialog.onExport) - QtCore.QObject.connect(self.btn_close, QtCore.SIGNAL(_fromUtf8("clicked()")), ExportShaderDialog.reject) - QtCore.QObject.connect(self.btn_view, QtCore.SIGNAL(_fromUtf8("clicked()")), ExportShaderDialog.onViewCode) - QtCore.QMetaObject.connectSlotsByName(ExportShaderDialog) + self.retranslateUi(ExportShaderDialog) + self.node_tabWidget.setCurrentIndex(0) + self.params_tabWidget.setCurrentIndex(0) + self.prop_tabWidget.setCurrentIndex(0) + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.connect(self.btn_export, QtCore.SIGNAL(_fromUtf8("clicked()")), ExportShaderDialog.onExport) + QtCore.QObject.connect(self.btn_close, QtCore.SIGNAL(_fromUtf8("clicked()")), ExportShaderDialog.reject) + QtCore.QObject.connect(self.btn_view, QtCore.SIGNAL(_fromUtf8("clicked()")), ExportShaderDialog.onViewCode) + else : + self.btn_export.clicked.connect( ExportShaderDialog.onExport) + self.btn_close.clicked.connect( ExportShaderDialog.reject) + self.btn_view.clicked.connect( ExportShaderDialog.onViewCode) + + QtCore.QMetaObject.connectSlotsByName(ExportShaderDialog) - def retranslateUi(self, ExportShaderDialog): - ExportShaderDialog.setWindowTitle(_translate("ExportShaderDialog", "ExportShader", None)) - self.chk_save_changes.setText(_translate("ExportShaderDialog", "Save changes", None)) - self.btn_view.setText(_translate("ExportShaderDialog", "View Code ...", None)) - self.btn_export.setText(_translate("ExportShaderDialog", "Export ...", None)) - self.btn_close.setText(_translate("ExportShaderDialog", "Close", None)) - self.node_tabWidget.setTabText(self.node_tabWidget.indexOf(self.tab), _translate("ExportShaderDialog", "Nodes", None)) - self.params_tabWidget.setTabText(self.params_tabWidget.indexOf(self.tab_inputs), _translate("ExportShaderDialog", "Inputs", None)) - self.params_tabWidget.setTabText(self.params_tabWidget.indexOf(self.tab_outputs), _translate("ExportShaderDialog", "Outputs", None)) - self.prop_tabWidget.setTabText(self.prop_tabWidget.indexOf(self.tab_prop_node), _translate("ExportShaderDialog", "Node", None)) - self.prop_tabWidget.setTabText(self.prop_tabWidget.indexOf(self.tab_prop_param), _translate("ExportShaderDialog", "Parameter", None)) + def retranslateUi(self, ExportShaderDialog): + ExportShaderDialog.setWindowTitle(_translate("ExportShaderDialog", "ExportShader", None)) + self.chk_save_changes.setText(_translate("ExportShaderDialog", "Save changes", None)) + self.btn_view.setText(_translate("ExportShaderDialog", "View Code ...", None)) + self.btn_export.setText(_translate("ExportShaderDialog", "Export ...", None)) + self.btn_close.setText(_translate("ExportShaderDialog", "Close", None)) + self.node_tabWidget.setTabText(self.node_tabWidget.indexOf(self.tab), _translate("ExportShaderDialog", "Nodes", None)) + self.params_tabWidget.setTabText(self.params_tabWidget.indexOf(self.tab_inputs), _translate("ExportShaderDialog", "Inputs", None)) + self.params_tabWidget.setTabText(self.params_tabWidget.indexOf(self.tab_outputs), _translate("ExportShaderDialog", "Outputs", None)) + self.prop_tabWidget.setTabText(self.prop_tabWidget.indexOf(self.tab_prop_node), _translate("ExportShaderDialog", "Node", None)) + self.prop_tabWidget.setTabText(self.prop_tabWidget.indexOf(self.tab_prop_param), _translate("ExportShaderDialog", "Parameter", None)) from gui.nodeEditor.nodeParamEditor import NodeParamEditor from gui.nodeEditor.nodePropertiesEditor import NodePropertiesEditor diff --git a/gui/imageViewWidget.py b/gui/imageViewWidget.py index 94caa63..8cd04e0 100644 --- a/gui/imageViewWidget.py +++ b/gui/imageViewWidget.py @@ -4,6 +4,7 @@ """ from core.mePyQt import QtCore, QtGui +from core.signal import Signal #from PyQt4.QtCore import QDir, QString, QModelIndex #from PyQt4.QtGui import QFileSystemModel @@ -20,7 +21,6 @@ else : from core.mePyQt import QtWidgets QtModule = QtWidgets - # # ImageViewWidget # @@ -45,8 +45,11 @@ def __init__ ( self ) : #self.ui.treeView.setRootIsDecorated( True ) if QtCore.QT_VERSION < 50000 : - QtCore.QObject.connect ( self.ui.imageArea, QtCore.SIGNAL ( 'mouseDoubleClickEvent' ), self.updateViewer ) + QtCore.QObject.connect ( self.ui.imageArea, QtCore.SIGNAL ( 'mouseDoubleClickSignal' ), self.updateViewer ) QtCore.QObject.connect ( self.ui.selector, QtCore.SIGNAL ( 'currentIndexChanged(int)' ), self.onViewerChanged ) + else : + self.ui.imageArea.mouseDoubleClickSignal.connect ( self.updateViewer ) + self.ui.selector.currentIndexChanged.connect ( self.onViewerChanged ) #QtCore.QObject.connect( self.ui, QtCore.SIGNAL( 'paramChanged()' ), self.onParamChanged ) #self.updateGui() @@ -55,6 +58,7 @@ def __init__ ( self ) : # currentImageNode # def currentImageNode ( self ) : + # gfxNode = None idx = self.ui.selector.currentIndex () if len ( self.imageNodes ) > 0 : diff --git a/gui/meRendererSetup.py b/gui/meRendererSetup.py index 5d7f953..db68d53 100644 --- a/gui/meRendererSetup.py +++ b/gui/meRendererSetup.py @@ -26,6 +26,12 @@ # class meRendererSetup ( QtModule.QDialog ) : # + # Define signals for PyQt5 + # + if QtCore.QT_VERSION >= 50000 : + presetChanged = QtCore.pyqtSignal () + savePreset = QtCore.pyqtSignal () + # # __init__ # def __init__ ( self, rendererPreset ) : @@ -207,8 +213,12 @@ def onEditLabel ( self ) : def onSave ( self ) : # get data from Gui for current renderer before saving self.getDataFromGui () - self.emit ( QtCore.SIGNAL ( 'presetChanged' ) ) - self.emit ( QtCore.SIGNAL ( 'savePreset' ) ) + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( 'presetChanged' ) ) + self.emit ( QtCore.SIGNAL ( 'savePreset' ) ) + else : + self.presetChanged.emit () + self.savePreset.emit () #self.done ( 0 ) # # onSelect @@ -216,5 +226,8 @@ def onSave ( self ) : def onSelect ( self ) : # get data from Gui for current renderer before saving self.getDataFromGui () - self.emit( QtCore.SIGNAL ( 'presetChanged' ) ) + if QtCore.QT_VERSION < 50000 : + self.emit( QtCore.SIGNAL ( 'presetChanged' ) ) + else : + self.presetChanged.emit () self.done ( 0 ) diff --git a/gui/nodeEditor/NodeEditorDialog.py b/gui/nodeEditor/NodeEditorDialog.py index bbc77ad..411689b 100644 --- a/gui/nodeEditor/NodeEditorDialog.py +++ b/gui/nodeEditor/NodeEditorDialog.py @@ -8,6 +8,7 @@ """ from core.mePyQt import Qt, QtCore, QtGui, QtXml +from core.signal import Signal from core.meCommon import * from global_vars import app_global_vars, DEBUG_MODE, VALID_PARAM_TYPES, VALID_RIB_NODE_TYPES @@ -77,88 +78,90 @@ def __init__ ( self, node = None ): # def connectSignals ( self ) : # - QtCore.QObject.connect ( self.ui.input_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) # onInputParamSelectionChanged ) - QtCore.QObject.connect ( self.ui.output_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) # onOutputParamSelectionChanged ) - - QtCore.QObject.connect ( self.ui.input_list, QtCore.SIGNAL ( 'addItem' ), self.onAddParam ) - QtCore.QObject.connect ( self.ui.output_list, QtCore.SIGNAL ( 'addItem' ), self.onAddParam ) - QtCore.QObject.connect ( self.ui.input_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameParam ) - QtCore.QObject.connect ( self.ui.output_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameParam ) - QtCore.QObject.connect ( self.ui.input_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveParam ) - QtCore.QObject.connect ( self.ui.output_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveParam ) - - QtCore.QObject.connect ( self.ui.tabs_param_list, QtCore.SIGNAL ( 'currentChanged(int)' ), self.updateGui ) - - if self.nodeParamEditor is not None : - QtCore.QObject.connect ( self.nodeParamEditor, QtCore.SIGNAL ( 'changeParamName' ), self.onRenameParam ) - QtCore.QObject.connect ( self.nodeParamEditor, QtCore.SIGNAL ( 'changeParamLabel' ), self.onRenameParamLabel ) - - if self.nodeCodeEditor is not None : - QtCore.QObject.connect ( self.nodeCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditCode ) - - if self.controlCodeEditor is not None : - QtCore.QObject.connect ( self.controlCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditControlCode ) - - if self.paramCodeEditor is not None : - QtCore.QObject.connect ( self.paramCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditParamCode ) + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.connect ( self.ui.input_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) # onInputParamSelectionChanged ) + QtCore.QObject.connect ( self.ui.output_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) # onOutputParamSelectionChanged ) + + QtCore.QObject.connect ( self.ui.input_list, QtCore.SIGNAL ( 'addItem' ), self.onAddParam ) + QtCore.QObject.connect ( self.ui.output_list, QtCore.SIGNAL ( 'addItem' ), self.onAddParam ) + QtCore.QObject.connect ( self.ui.input_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameParam ) + QtCore.QObject.connect ( self.ui.output_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameParam ) + QtCore.QObject.connect ( self.ui.input_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveParam ) + QtCore.QObject.connect ( self.ui.output_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveParam ) + + QtCore.QObject.connect ( self.ui.tabs_param_list, QtCore.SIGNAL ( 'currentChanged(int)' ), self.updateGui ) + + if self.nodeParamEditor is not None : + QtCore.QObject.connect ( self.nodeParamEditor, QtCore.SIGNAL ( 'changeParamName' ), self.onRenameParam ) + QtCore.QObject.connect ( self.nodeParamEditor, QtCore.SIGNAL ( 'changeParamLabel' ), self.onRenameParamLabel ) + + if self.nodeCodeEditor is not None : + QtCore.QObject.connect ( self.nodeCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditCode ) + + if self.controlCodeEditor is not None : + QtCore.QObject.connect ( self.controlCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditControlCode ) + + if self.paramCodeEditor is not None : + QtCore.QObject.connect ( self.paramCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditParamCode ) + + if self.eventCodeEditor is not None : + QtCore.QObject.connect ( self.eventCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditEventCode ) + + QtCore.QObject.connect ( self.ui.internals_list, QtCore.SIGNAL ( 'addItem' ), self.onAddInternal ) + QtCore.QObject.connect ( self.ui.includes_list, QtCore.SIGNAL ( 'addItem' ), self.onAddInclude ) + + QtCore.QObject.connect ( self.ui.internals_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameInternal ) + QtCore.QObject.connect ( self.ui.includes_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameInclude ) + + QtCore.QObject.connect ( self.ui.internals_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveInternal ) + QtCore.QObject.connect ( self.ui.includes_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveInclude ) - if self.eventCodeEditor is not None : - QtCore.QObject.connect ( self.eventCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditEventCode ) - - QtCore.QObject.connect ( self.ui.internals_list, QtCore.SIGNAL ( 'addItem' ), self.onAddInternal ) - QtCore.QObject.connect ( self.ui.includes_list, QtCore.SIGNAL ( 'addItem' ), self.onAddInclude ) - - QtCore.QObject.connect ( self.ui.internals_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameInternal ) - QtCore.QObject.connect ( self.ui.includes_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameInclude ) - - QtCore.QObject.connect ( self.ui.internals_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveInternal ) - QtCore.QObject.connect ( self.ui.includes_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveInclude ) - - QtCore.QObject.connect ( self.ui.handlers_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) + QtCore.QObject.connect ( self.ui.handlers_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) # # disconnectSignals # def disconnectSignals ( self ) : # - QtCore.QObject.disconnect ( self.ui.input_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) # onInputParamSelectionChanged ) - QtCore.QObject.disconnect ( self.ui.output_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) # onOutputParamSelectionChanged ) - - QtCore.QObject.disconnect ( self.ui.input_list, QtCore.SIGNAL ( 'addItem' ), self.onAddParam ) - QtCore.QObject.disconnect ( self.ui.output_list, QtCore.SIGNAL ( 'addItem' ), self.onAddParam ) - QtCore.QObject.disconnect ( self.ui.input_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameParam ) - QtCore.QObject.disconnect ( self.ui.output_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameParam ) - QtCore.QObject.disconnect ( self.ui.input_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveParam ) - QtCore.QObject.disconnect ( self.ui.output_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveParam ) - - QtCore.QObject.disconnect ( self.ui.tabs_param_list, QtCore.SIGNAL ( "currentChanged(int)" ), self.updateGui ) - - if self.nodeParamEditor is not None : - QtCore.QObject.disconnect ( self.nodeParamEditor, QtCore.SIGNAL ( 'changeParamName' ), self.onRenameParam ) - QtCore.QObject.disconnect ( self.nodeParamEditor, QtCore.SIGNAL ( 'changeParamLabel' ), self.onRenameParamLabel ) - - if self.nodeCodeEditor is not None : - QtCore.QObject.disconnect ( self.nodeCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditCode ) - - if self.controlCodeEditor is not None : - QtCore.QObject.disconnect ( self.controlCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditControlCode) - - if self.paramCodeEditor is not None : - QtCore.QObject.disconnect ( self.paramCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditParamCode ) - - if self.eventCodeEditor is not None : - QtCore.QObject.disconnect ( self.eventCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditEventCode ) - - QtCore.QObject.disconnect ( self.ui.internals_list, QtCore.SIGNAL ( 'addItem' ), self.onAddInternal ) - QtCore.QObject.disconnect ( self.ui.includes_list, QtCore.SIGNAL ( 'addItem' ), self.onAddInclude ) - - QtCore.QObject.disconnect ( self.ui.internals_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameInternal ) - QtCore.QObject.disconnect ( self.ui.includes_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameInclude ) - - QtCore.QObject.disconnect ( self.ui.internals_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveInternal ) - QtCore.QObject.disconnect ( self.ui.includes_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveInclude ) - - QtCore.QObject.disconnect ( self.ui.handlers_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.disconnect ( self.ui.input_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) # onInputParamSelectionChanged ) + QtCore.QObject.disconnect ( self.ui.output_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) # onOutputParamSelectionChanged ) + + QtCore.QObject.disconnect ( self.ui.input_list, QtCore.SIGNAL ( 'addItem' ), self.onAddParam ) + QtCore.QObject.disconnect ( self.ui.output_list, QtCore.SIGNAL ( 'addItem' ), self.onAddParam ) + QtCore.QObject.disconnect ( self.ui.input_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameParam ) + QtCore.QObject.disconnect ( self.ui.output_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameParam ) + QtCore.QObject.disconnect ( self.ui.input_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveParam ) + QtCore.QObject.disconnect ( self.ui.output_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveParam ) + + QtCore.QObject.disconnect ( self.ui.tabs_param_list, QtCore.SIGNAL ( "currentChanged(int)" ), self.updateGui ) + + if self.nodeParamEditor is not None : + QtCore.QObject.disconnect ( self.nodeParamEditor, QtCore.SIGNAL ( 'changeParamName' ), self.onRenameParam ) + QtCore.QObject.disconnect ( self.nodeParamEditor, QtCore.SIGNAL ( 'changeParamLabel' ), self.onRenameParamLabel ) + + if self.nodeCodeEditor is not None : + QtCore.QObject.disconnect ( self.nodeCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditCode ) + + if self.controlCodeEditor is not None : + QtCore.QObject.disconnect ( self.controlCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditControlCode) + + if self.paramCodeEditor is not None : + QtCore.QObject.disconnect ( self.paramCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditParamCode ) + + if self.eventCodeEditor is not None : + QtCore.QObject.disconnect ( self.eventCodeEditor.ui.textEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditEventCode ) + + QtCore.QObject.disconnect ( self.ui.internals_list, QtCore.SIGNAL ( 'addItem' ), self.onAddInternal ) + QtCore.QObject.disconnect ( self.ui.includes_list, QtCore.SIGNAL ( 'addItem' ), self.onAddInclude ) + + QtCore.QObject.disconnect ( self.ui.internals_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameInternal ) + QtCore.QObject.disconnect ( self.ui.includes_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameInclude ) + + QtCore.QObject.disconnect ( self.ui.internals_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveInternal ) + QtCore.QObject.disconnect ( self.ui.includes_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveInclude ) + + QtCore.QObject.disconnect ( self.ui.handlers_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) # # setEditNode @@ -186,17 +189,17 @@ def buildGui ( self ) : # setup loacal variables list for name in self.editNode.internals : - item = QtGui.QListWidgetItem ( name ) + item = QtModule.QListWidgetItem ( name ) self.ui.internals_list.ui.listWidget.addItem ( item ) # setup includes list for name in self.editNode.includes : - item = QtGui.QListWidgetItem ( name ) + item = QtModule.QListWidgetItem ( name ) self.ui.includes_list.ui.listWidget.addItem ( item ) # setup input params list for param in self.editNode.inputParams : - item = QtGui.QListWidgetItem ( param.name ) + item = QtModule.QListWidgetItem ( param.name ) if self.editNode.isInputParamLinked ( param ) : item.setFont ( linkedFont ) item.setForeground ( linkedBrush ) @@ -204,7 +207,7 @@ def buildGui ( self ) : # setup output params list for param in self.editNode.outputParams : - item = QtGui.QListWidgetItem ( param.name ) + item = QtModule.QListWidgetItem ( param.name ) if self.editNode.isOutputParamLinked ( param ) : item.setFont ( linkedFont ) item.setForeground ( linkedBrush ) @@ -212,20 +215,20 @@ def buildGui ( self ) : # setup input links list for link in self.editNode.getInputLinks () : - item = QtGui.QListWidgetItem ( 'id=%d' % link.id ) + item = QtModule.QListWidgetItem ( 'id=%d' % link.id ) item.setData ( QtCore.Qt.UserRole, QVariant ( int ( link.id ) ) ) self.ui.input_links_listWidget.addItem ( item ) # setup output links list for link in self.editNode.getOutputLinks () : - item = QtGui.QListWidgetItem ( 'id=%d' % link.id ) + item = QtModule.QListWidgetItem ( 'id=%d' % link.id ) item.setData ( QtCore.Qt.UserRole, QVariant ( int ( link.id ) ) ) self.ui.output_links_listWidget.addItem ( item ) # setup event handlers list if self.editNode.event_code : for handler in self.editNode.event_code.keys () : - item = QtGui.QListWidgetItem ( handler ) + item = QtModule.QListWidgetItem ( handler ) self.ui.handlers_list.ui.listWidget.addItem ( item ) self.nodeCodeEditor = self.ui.node_code @@ -542,12 +545,12 @@ def onAddParam ( self, newName ) : tab_idx = self.ui.tabs_param_list.currentIndex () if tab_idx == 0 : isInputParam = True # ask user about param type - typeDialog = QtGui.QDialog () # Qt.MSWindowsFixedSizeDialogHint + typeDialog = QtModule.QDialog () # Qt.MSWindowsFixedSizeDialogHint typeDialog.setModal ( True ) typeDialog.setWindowTitle ( 'Parameter Type' ) typeDialog.resize (180, 100 ) - sizePolicy = QtGui.QSizePolicy ( QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed ) + sizePolicy = QtModule.QSizePolicy ( QtModule.QSizePolicy.Fixed, QtModule.QSizePolicy.Fixed ) sizePolicy.setHorizontalStretch ( 0 ) sizePolicy.setVerticalStretch ( 0 ) sizePolicy.setHeightForWidth ( typeDialog.sizePolicy().hasHeightForWidth() ) @@ -562,14 +565,18 @@ def onAddParam ( self, newName ) : typeDialog.verticalLayout.addWidget ( typeDialog.type_comboBox ) - typeDialog.btnBox = QtGui.QDialogButtonBox ( QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel, parent = typeDialog ) + typeDialog.btnBox = QtModule.QDialogButtonBox ( QtModule.QDialogButtonBox.Ok | QtModule.QDialogButtonBox.Cancel, parent = typeDialog ) typeDialog.btnBox.setCenterButtons ( True ) typeDialog.verticalLayout.addWidget ( typeDialog.btnBox ) - QtCore.QObject.connect ( typeDialog.btnBox, QtCore.SIGNAL ( 'accepted()' ), typeDialog.accept ) - QtCore.QObject.connect ( typeDialog.btnBox, QtCore.SIGNAL ( 'rejected()' ), typeDialog.reject ) + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.connect ( typeDialog.btnBox, QtCore.SIGNAL ( 'accepted()' ), typeDialog.accept ) + QtCore.QObject.connect ( typeDialog.btnBox, QtCore.SIGNAL ( 'rejected()' ), typeDialog.reject ) + else : + typeDialog.btnBox,accepted.connect ( typeDialog.accept ) + typeDialog.btnBox,rejected.connect ( typeDialog.reject ) - if typeDialog.exec_() == QtGui.QDialog.Accepted : + if typeDialog.exec_() == QtModule.QDialog.Accepted : paramType = str ( typeDialog.type_comboBox.currentText () ) if DEBUG_MODE : print '>> NodeEditorDialog::onAddParam typeDialog Accepted (%s)' % paramType @@ -581,7 +588,7 @@ def onAddParam ( self, newName ) : xmlnode.setAttribute ( 'label', newName ) xmlnode.setAttribute ( 'type', paramType ) param = createParamFromXml ( xmlnode, isRibParam, isInputParam ) - item = QtGui.QListWidgetItem ( param.name ) + item = QtModule.QListWidgetItem ( param.name ) paramListWidget = self.ui.input_list.ui.listWidget @@ -644,11 +651,11 @@ def keyPressEvent ( self, event ) : if event.key () == QtCore.Qt.Key_Enter or event.key () == QtCore.Qt.Key_Return : event.ignore () else: - QtGui.QDialog.keyPressEvent ( self, event ) + QtModule.QDialog.keyPressEvent ( self, event ) # # accept # def accept ( self ) : # if DEBUG_MODE : print '>> NodeEditorDialog::accept' - self.done ( QtGui.QDialog.Accepted ) + self.done ( QtModule.QDialog.Accepted ) diff --git a/gui/nodeEditor/codeSyntaxHighlighter.py b/gui/nodeEditor/codeSyntaxHighlighter.py index a5b67a5..65df812 100644 --- a/gui/nodeEditor/codeSyntaxHighlighter.py +++ b/gui/nodeEditor/codeSyntaxHighlighter.py @@ -15,105 +15,112 @@ from global_vars import app_global_vars import gui.ui_settings as UI + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + # # CodeSyntaxHighlighter # class CodeSyntaxHighlighter ( QtGui.QSyntaxHighlighter ): - # - def __init__ ( self, textDocument, mode = 'SL' ): - # - QtGui.QSyntaxHighlighter.__init__ ( self, textDocument ) - - self.mode = mode - self.highlightingRules = [] - - syntax_colors = {} - - syntax_colors [ 'types' ] = QtCore.Qt.blue - syntax_colors [ 'literal' ] = QtCore.Qt.darkGreen - syntax_colors [ 'comment' ] = QtCore.Qt.darkGray - syntax_colors [ 'function' ] = QtCore.Qt.darkMagenta - syntax_colors [ 'params' ] = QtCore.Qt.red - syntax_colors [ 'globals' ] = QtCore.Qt.darkCyan - - # types - self.typeFormat = QtGui.QTextCharFormat () - self.typeFormat.setForeground ( syntax_colors [ 'types' ] ) - - typePatterns = [ '\\bfloat\\b', '\\bcolor\\b', '\\bmatrix\\b', '\\bvector\\b', '\\bstring\\b', '\\bpoint\\b', '\\bnormal\\b' ] - - for typePattern in typePatterns: - typeRule = ( QtCore.QRegExp ( typePattern ), self.typeFormat ) - self.highlightingRules.append ( typeRule ) - - # single line comment - self.singleLineCommentFormat = QtGui.QTextCharFormat () - self.singleLineCommentFormat.setForeground ( syntax_colors [ 'comment' ] ) - singleLineCommentRule = ( QtCore.QRegExp ( '//[^\n]*' ), self.singleLineCommentFormat ) - self.highlightingRules.append ( singleLineCommentRule ) + # + def __init__ ( self, textDocument, mode = 'SL' ): + # + QtGui.QSyntaxHighlighter.__init__ ( self, textDocument ) + + self.mode = mode + self.highlightingRules = [] + + syntax_colors = {} + + syntax_colors [ 'types' ] = QtCore.Qt.blue + syntax_colors [ 'literal' ] = QtCore.Qt.darkGreen + syntax_colors [ 'comment' ] = QtCore.Qt.darkGray + syntax_colors [ 'function' ] = QtCore.Qt.darkMagenta + syntax_colors [ 'params' ] = QtCore.Qt.red + syntax_colors [ 'globals' ] = QtCore.Qt.darkCyan + + # types + self.typeFormat = QtGui.QTextCharFormat () + self.typeFormat.setForeground ( syntax_colors [ 'types' ] ) + + typePatterns = [ '\\bfloat\\b', '\\bcolor\\b', '\\bmatrix\\b', '\\bvector\\b', '\\bstring\\b', '\\bpoint\\b', '\\bnormal\\b' ] + + for typePattern in typePatterns: + typeRule = ( QtCore.QRegExp ( typePattern ), self.typeFormat ) + self.highlightingRules.append ( typeRule ) + + # single line comment + self.singleLineCommentFormat = QtGui.QTextCharFormat () + self.singleLineCommentFormat.setForeground ( syntax_colors [ 'comment' ] ) + singleLineCommentRule = ( QtCore.QRegExp ( '//[^\n]*' ), self.singleLineCommentFormat ) + self.highlightingRules.append ( singleLineCommentRule ) - # multiline comment - self.multiLineCommentFormat = QtGui.QTextCharFormat () - self.multiLineCommentFormat.setForeground ( syntax_colors [ 'comment' ] ) - self.commentStartExpression = QtCore.QRegExp ( "/\\*" ) - self.commentEndExpression = QtCore.QRegExp ( "\\*/" ) - - # literal - self.literalFormat = QtGui.QTextCharFormat () - self.literalFormat.setForeground ( syntax_colors [ 'literal' ] ) - literalRule_1 = ( QtCore.QRegExp ( '\"[A-Za-z0-9_]+\"' ), self.literalFormat ) - literalRule_2 = ( QtCore.QRegExp ( "\'[A-Za-z0-9_]+\'" ), self.literalFormat ) - self.highlightingRules.append ( literalRule_1 ) - self.highlightingRules.append ( literalRule_2 ) + # multiline comment + self.multiLineCommentFormat = QtGui.QTextCharFormat () + self.multiLineCommentFormat.setForeground ( syntax_colors [ 'comment' ] ) + self.commentStartExpression = QtCore.QRegExp ( "/\\*" ) + self.commentEndExpression = QtCore.QRegExp ( "\\*/" ) + + # literal + self.literalFormat = QtGui.QTextCharFormat () + self.literalFormat.setForeground ( syntax_colors [ 'literal' ] ) + literalRule_1 = ( QtCore.QRegExp ( '\"[A-Za-z0-9_]+\"' ), self.literalFormat ) + literalRule_2 = ( QtCore.QRegExp ( "\'[A-Za-z0-9_]+\'" ), self.literalFormat ) + self.highlightingRules.append ( literalRule_1 ) + self.highlightingRules.append ( literalRule_2 ) - # function - self.functionFormat = QtGui.QTextCharFormat () - self.functionFormat.setForeground ( syntax_colors [ 'function' ] ) - functionRule = ( QtCore.QRegExp ( '\\b[A-Za-z0-9_]+ ?(?=\\()' ), self.functionFormat ) - self.highlightingRules.append ( functionRule ) - - # params - self.paramsFormat = QtGui.QTextCharFormat () - self.paramsFormat.setForeground ( syntax_colors [ 'params' ] ) - paramsRule = ( QtCore.QRegExp ( '\$\([A-Za-z0-9_]+\)' ), self.paramsFormat ) - self.highlightingRules.append ( paramsRule ) - - # globals - self.globalsFormat = QtGui.QTextCharFormat () - self.globalsFormat.setForeground ( syntax_colors [ 'globals' ] ) - globalsRule = ( QtCore.QRegExp ( '\$\{[A-Za-z0-9_]+\}' ), self.globalsFormat ) - self.highlightingRules.append ( globalsRule ) - - # - # highlightBlock - # - def highlightBlock ( self, text ): - #print "DBG: highlightBlock %s" % ( text ) - # apply rules - for rule in self.highlightingRules: - expression = QtCore.QRegExp ( rule[0] ) - index = expression.indexIn ( text ) - while index >= 0: - length = expression.matchedLength () - self.setFormat ( index, length, rule[1] ) - index = expression.indexIn ( text, index + length ) - - self.setCurrentBlockState ( 0 ) - - # multiline comment handling - startIndex = 0; - if self.previousBlockState() != 1: - startIndex = self.commentStartExpression.indexIn ( text ) + # function + self.functionFormat = QtGui.QTextCharFormat () + self.functionFormat.setForeground ( syntax_colors [ 'function' ] ) + functionRule = ( QtCore.QRegExp ( '\\b[A-Za-z0-9_]+ ?(?=\\()' ), self.functionFormat ) + self.highlightingRules.append ( functionRule ) + + # params + self.paramsFormat = QtGui.QTextCharFormat () + self.paramsFormat.setForeground ( syntax_colors [ 'params' ] ) + paramsRule = ( QtCore.QRegExp ( '\$\([A-Za-z0-9_]+\)' ), self.paramsFormat ) + self.highlightingRules.append ( paramsRule ) + + # globals + self.globalsFormat = QtGui.QTextCharFormat () + self.globalsFormat.setForeground ( syntax_colors [ 'globals' ] ) + globalsRule = ( QtCore.QRegExp ( '\$\{[A-Za-z0-9_]+\}' ), self.globalsFormat ) + self.highlightingRules.append ( globalsRule ) + + # + # highlightBlock + # + def highlightBlock ( self, text ): + #print "DBG: highlightBlock %s" % ( text ) + # apply rules + for rule in self.highlightingRules: + expression = QtCore.QRegExp ( rule[0] ) + index = expression.indexIn ( text ) + while index >= 0: + length = expression.matchedLength () + self.setFormat ( index, length, rule[1] ) + index = expression.indexIn ( text, index + length ) + + self.setCurrentBlockState ( 0 ) + + # multiline comment handling + startIndex = 0; + if self.previousBlockState() != 1: + startIndex = self.commentStartExpression.indexIn ( text ) - while startIndex >= 0: - endIndex = self.commentEndExpression.indexIn ( text, startIndex ) - commentLength = 0 - if endIndex == -1: - self.setCurrentBlockState ( 1 ) - commentLength = text.length () - startIndex - else: - commentLength = endIndex - startIndex + self.commentEndExpression.matchedLength () - - self.setFormat ( startIndex, commentLength, self.multiLineCommentFormat ) - startIndex = self.commentStartExpression.indexIn ( text, startIndex + commentLength ) - \ No newline at end of file + while startIndex >= 0: + endIndex = self.commentEndExpression.indexIn ( text, startIndex ) + commentLength = 0 + if endIndex == -1: + self.setCurrentBlockState ( 1 ) + commentLength = text.length () - startIndex + else: + commentLength = endIndex - startIndex + self.commentEndExpression.matchedLength () + + self.setFormat ( startIndex, commentLength, self.multiLineCommentFormat ) + startIndex = self.commentStartExpression.indexIn ( text, startIndex + commentLength ) + \ No newline at end of file diff --git a/gui/nodeEditor/nodeNamesEditor.py b/gui/nodeEditor/nodeNamesEditor.py index 31053ba..b2827e9 100644 --- a/gui/nodeEditor/nodeNamesEditor.py +++ b/gui/nodeEditor/nodeNamesEditor.py @@ -9,6 +9,7 @@ """ from core.mePyQt import QtCore, QtGui +from core.signal import Signal #from core.meCommon import * from global_vars import app_global_vars, DEBUG_MODE @@ -26,6 +27,15 @@ # class NodeNamesEditor ( QtModule.QWidget ) : # + # Define signals for PyQt5 + # + if QtCore.QT_VERSION >= 50000 : + # + selectionChanged = Signal () + addItem = Signal () + removeItem = Signal () + renameItem = Signal () + # # __init__ # def __init__ ( self, parent ) : @@ -60,7 +70,10 @@ def onAddItem ( self ) : if DEBUG_MODE : print '>> NodeNamesEditor: onAddItem' new_text = str ( self.ui.name_lineEdit.text () ).strip () if new_text != '' : - self.emit ( QtCore.SIGNAL ( 'addItem' ), new_text ) + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( 'addItem' ), new_text ) + else : + self.addItem.emit ( new_text ) # # onRemoveItem # @@ -73,7 +86,10 @@ def onRemoveItem ( self ) : item_text = str ( list_item.text () ) #self.ui.listWidget.takeItem ( self.ui.listWidget.currentRow () ) #self.ui.listWidget.removeItemWidget ( list_item ) - self.emit ( QtCore.SIGNAL ( 'removeItem' ), item_text ) + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( 'removeItem' ), item_text ) + else : + self.removeItem.emit ( item_text ) # # onRenameItem # @@ -92,7 +108,10 @@ def onRenameItem ( self ) : if list_item is not None : # e.g. listWidget is not empty old_text = list_item.text () if new_text != old_text : - self.emit ( QtCore.SIGNAL( 'renameItem' ), old_text, new_text ) + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL( 'renameItem' ), old_text, new_text ) + else : + self.renameItem.emit ( old_text, new_text ) else : self.ui.listWidget.clearSelection () self.ui.listWidget.setCurrentItem ( None ) @@ -107,5 +126,8 @@ def onSelectionChanged ( self ) : if list_item is not None : self.saved_text = str ( list_item.text() ) self.ui.name_lineEdit.setText ( self.saved_text ) - self.emit ( QtCore.SIGNAL ( 'selectionChanged' ), self.saved_text ) + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( 'selectionChanged' ), self.saved_text ) + else : + self.selectionChanged.emit ( self.saved_text ) \ No newline at end of file diff --git a/gui/nodeEditor/nodeParamEditor.py b/gui/nodeEditor/nodeParamEditor.py index 6b2455f..90c3b2e 100644 --- a/gui/nodeEditor/nodeParamEditor.py +++ b/gui/nodeEditor/nodeParamEditor.py @@ -9,6 +9,7 @@ """ from core.mePyQt import QtCore, QtGui +from core.signal import Signal from core.meCommon import * from global_vars import app_global_vars, DEBUG_MODE, VALID_PARAM_TYPES @@ -138,38 +139,42 @@ def onParamValueChanged ( self, param ) : # def connectSignals ( self ) : # - self.connect ( self.param_default, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamDefValueChanged ) - self.connect ( self.param, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamValueChanged ) - self.connect ( self.ui.name_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditParamName ) - self.connect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditParamLabel ) - self.connect ( self.ui.check_enabled, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onEditParamEnabled ) - self.connect ( self.ui.check_display, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onEditParamDisplay ) - self.connect ( self.ui.check_shader, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onEditParamShader ) - self.connect ( self.ui.type_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamType ) - self.connect ( self.ui.detail_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamDetail ) - self.connect ( self.ui.provider_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamProvider ) - self.connect ( self.ui.subtype_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamSubtype ) - self.connect ( self.ui.range_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditParamRange ) - self.connect ( self.ui.descr_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditParamHelp ) + if QtCore.QT_VERSION < 50000 : + self.connect ( self.param_default, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamDefValueChanged ) + self.connect ( self.param, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamValueChanged ) + + self.connect ( self.ui.name_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditParamName ) + self.connect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditParamLabel ) + self.connect ( self.ui.check_enabled, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onEditParamEnabled ) + self.connect ( self.ui.check_display, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onEditParamDisplay ) + self.connect ( self.ui.check_shader, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onEditParamShader ) + self.connect ( self.ui.type_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamType ) + self.connect ( self.ui.detail_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamDetail ) + self.connect ( self.ui.provider_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamProvider ) + self.connect ( self.ui.subtype_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamSubtype ) + self.connect ( self.ui.range_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditParamRange ) + self.connect ( self.ui.descr_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditParamHelp ) # # disconnectSignals # def disconnectSignals ( self ) : # - if self.param_default is not None : - self.disconnect ( self.param_default, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamDefValueChanged ) - if self.param is not None : - self.disconnect ( self.param, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamValueChanged ) - self.disconnect ( self.ui.name_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditParamName ) - self.disconnect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditParamLabel ) - self.disconnect ( self.ui.check_enabled, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onEditParamEnabled ) - self.disconnect ( self.ui.check_display, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onEditParamDisplay ) - self.disconnect ( self.ui.check_shader, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onEditParamShader ) - self.disconnect ( self.ui.type_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamType ) - self.disconnect ( self.ui.detail_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamDetail ) - self.disconnect ( self.ui.provider_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamProvider ) - self.disconnect ( self.ui.subtype_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamSubtype ) - self.disconnect ( self.ui.descr_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditParamHelp ) + if QtCore.QT_VERSION < 50000 : + if self.param_default is not None : + self.disconnect ( self.param_default, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamDefValueChanged ) + if self.param is not None : + self.disconnect ( self.param, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamValueChanged ) + + self.disconnect ( self.ui.name_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditParamName ) + self.disconnect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditParamLabel ) + self.disconnect ( self.ui.check_enabled, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onEditParamEnabled ) + self.disconnect ( self.ui.check_display, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onEditParamDisplay ) + self.disconnect ( self.ui.check_shader, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onEditParamShader ) + self.disconnect ( self.ui.type_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamType ) + self.disconnect ( self.ui.detail_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamDetail ) + self.disconnect ( self.ui.provider_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamProvider ) + self.disconnect ( self.ui.subtype_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamSubtype ) + self.disconnect ( self.ui.descr_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditParamHelp ) # # reset # @@ -238,14 +243,14 @@ def setParam ( self, param ) : if self.param.help != None : help_text = self.param.help doc.setPlainText ( help_text ) - layout = QtGui.QPlainTextDocumentLayout ( doc ) + layout = QtModule.QPlainTextDocumentLayout ( doc ) doc.setDocumentLayout( layout ) self.ui.descr_plainTextEdit.setDocument ( doc ) # # setup param values view # - paramsLayout = QtGui.QGridLayout () + paramsLayout = QtModule.QGridLayout () paramsLayout.setContentsMargins ( 2, 2, 2, 2 ) paramsLayout.setSizeConstraint ( QtGui.QLayout.SetNoConstraint ) paramsLayout.setVerticalSpacing ( 4 ) diff --git a/gui/nodeEditor/nodePropertiesEditor.py b/gui/nodeEditor/nodePropertiesEditor.py index 4553f89..1f3e49e 100644 --- a/gui/nodeEditor/nodePropertiesEditor.py +++ b/gui/nodeEditor/nodePropertiesEditor.py @@ -9,6 +9,7 @@ """ from core.mePyQt import QtCore, QtGui +from core.signal import Signal from core.meCommon import * from global_vars import app_global_vars, DEBUG_MODE, VALID_NODE_TYPES @@ -85,7 +86,7 @@ def setNode ( self, editNode ) : help_text = self.editNode.help doc.setPlainText ( help_text ) - layout = QtGui.QPlainTextDocumentLayout( doc ) + layout = QtModule.QPlainTextDocumentLayout( doc ) doc.setDocumentLayout( layout ) self.ui.help_plainTextEdit.setDocument ( doc ) @@ -115,26 +116,46 @@ def setNode ( self, editNode ) : # def connectSignals ( self ) : # QtCore.QObject. - self.connect ( self.ui.name_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrName ) - self.connect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) - self.connect ( self.ui.master_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrMaster ) - self.connect ( self.ui.author_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrAuthor ) - self.connect ( self.ui.icon_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrIcon ) - self.connect ( self.ui.type_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditNodeType ) - self.connect ( self.ui.help_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditNodeTxtAttr ) + if QtCore.QT_VERSION < 50000 : + self.connect ( self.ui.name_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrName ) + self.connect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) + self.connect ( self.ui.master_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrMaster ) + self.connect ( self.ui.author_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrAuthor ) + self.connect ( self.ui.icon_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrIcon ) + self.connect ( self.ui.type_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditNodeType ) + self.connect ( self.ui.help_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditNodeTxtAttr ) + else : + self.ui.name_lineEdit.editingFinished.connect ( self.onEditNodeStrAttrName ) + self.ui.label_lineEdit.editingFinished.connect ( self.onEditNodeStrAttrLabel ) + self.ui.master_lineEdit.editingFinished.connect ( self.onEditNodeStrAttrMaster ) + self.ui.author_lineEdit.editingFinished.connect ( self.onEditNodeStrAttrAuthor ) + self.ui.icon_lineEdit.editingFinished.connect ( self.onEditNodeStrAttrIcon ) + self.ui.type_comboBox.activated.connect ( self.onEditNodeType ) + self.ui.help_plainTextEdit.textChanged.connect ( self.onEditNodeTxtAttr ) # # disconnectSignals # def disconnectSignals ( self ) : # - if self.editNode is not None : - self.disconnect ( self.ui.name_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrName ) - self.disconnect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) - self.disconnect ( self.ui.master_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrMaster ) - self.disconnect ( self.ui.author_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrAuthor ) - self.disconnect ( self.ui.icon_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrIcon ) - self.disconnect ( self.ui.type_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditNodeType ) - self.disconnect ( self.ui.help_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditNodeTxtAttr ) + if QtCore.QT_VERSION < 50000 : + if self.editNode is not None : + self.disconnect ( self.ui.name_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrName ) + self.disconnect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) + self.disconnect ( self.ui.master_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrMaster ) + self.disconnect ( self.ui.author_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrAuthor ) + self.disconnect ( self.ui.icon_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrIcon ) + self.disconnect ( self.ui.type_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditNodeType ) + self.disconnect ( self.ui.help_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditNodeTxtAttr ) + else : + if self.editNode is not None : + self.ui.name_lineEdit.editingFinished.disconnect ( self.onEditNodeStrAttrName ) + self.ui.label_lineEdit.editingFinished.disconnect ( self.onEditNodeStrAttrLabel ) + self.ui.master_lineEdit.editingFinished.disconnect ( self.onEditNodeStrAttrMaster ) + self.ui.author_lineEdit.editingFinished.disconnect ( self.onEditNodeStrAttrAuthor ) + self.ui.icon_lineEdit.editingFinished.disconnect ( self.onEditNodeStrAttrIcon ) + self.ui.type_comboBox.activated.disconnect ( self.onEditNodeType ) + self.ui.help_plainTextEdit.textChanged.disconnect ( self.onEditNodeTxtAttr ) + # # # doesn't work ... # diff --git a/gui/nodeEditor/ui_nodeCodeEditor.py b/gui/nodeEditor/ui_nodeCodeEditor.py index a775ea0..63bdc50 100644 --- a/gui/nodeEditor/ui_nodeCodeEditor.py +++ b/gui/nodeEditor/ui_nodeCodeEditor.py @@ -9,36 +9,42 @@ from core.mePyQt import QtCore, QtGui +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + try: - _fromUtf8 = QtCore.QString.fromUtf8 + _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: - def _fromUtf8(s): - return s + def _fromUtf8(s): + return s try: - _encoding = QtGui.QApplication.UnicodeUTF8 - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig, _encoding) + _encoding = QtGui.QApplication.UnicodeUTF8 + def _translate(context, text, disambig): + return QtModule.QApplication.translate(context, text, disambig, _encoding) except AttributeError: - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig) + def _translate(context, text, disambig): + return QtModule.QApplication.translate(context, text, disambig) class Ui_NodeCodeEditor(object): - def setupUi(self, NodeCodeEditor): - NodeCodeEditor.setObjectName(_fromUtf8("NodeCodeEditor")) - NodeCodeEditor.resize(683, 838) - self.gridLayout = QtGui.QGridLayout(NodeCodeEditor) - self.gridLayout.setMargin(0) - self.gridLayout.setSpacing(0) - self.gridLayout.setObjectName(_fromUtf8("gridLayout")) - self.textEdit = QtGui.QTextEdit(NodeCodeEditor) - self.textEdit.setLineWidth(2) - self.textEdit.setObjectName(_fromUtf8("textEdit")) - self.gridLayout.addWidget(self.textEdit, 0, 0, 1, 1) - - self.retranslateUi(NodeCodeEditor) - QtCore.QMetaObject.connectSlotsByName(NodeCodeEditor) - - def retranslateUi(self, NodeCodeEditor): - NodeCodeEditor.setWindowTitle(_translate("NodeCodeEditor", "Form", None)) + def setupUi(self, NodeCodeEditor): + NodeCodeEditor.setObjectName(_fromUtf8("NodeCodeEditor")) + NodeCodeEditor.resize(683, 838) + self.gridLayout = QtModule.QGridLayout(NodeCodeEditor) + self.gridLayout.setMargin(0) + self.gridLayout.setSpacing(0) + self.gridLayout.setObjectName(_fromUtf8("gridLayout")) + self.textEdit = QtModule.QTextEdit(NodeCodeEditor) + self.textEdit.setLineWidth(2) + self.textEdit.setObjectName(_fromUtf8("textEdit")) + self.gridLayout.addWidget(self.textEdit, 0, 0, 1, 1) + + self.retranslateUi(NodeCodeEditor) + QtCore.QMetaObject.connectSlotsByName(NodeCodeEditor) + + def retranslateUi(self, NodeCodeEditor): + NodeCodeEditor.setWindowTitle(_translate("NodeCodeEditor", "Form", None)) diff --git a/gui/nodeEditor/ui_nodeEditorDialog.py b/gui/nodeEditor/ui_nodeEditorDialog.py index cde89d6..1521f9e 100644 --- a/gui/nodeEditor/ui_nodeEditorDialog.py +++ b/gui/nodeEditor/ui_nodeEditorDialog.py @@ -9,261 +9,287 @@ from core.mePyQt import QtCore, QtGui +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + try: - _fromUtf8 = QtCore.QString.fromUtf8 + _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: - def _fromUtf8(s): - return s + def _fromUtf8(s): + return s try: - _encoding = QtGui.QApplication.UnicodeUTF8 - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig, _encoding) + _encoding = QtGui.QApplication.UnicodeUTF8 + def _translate(context, text, disambig): + return QtModule.QApplication.translate(context, text, disambig, _encoding) except AttributeError: - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig) + def _translate(context, text, disambig): + return QtModule.QApplication.translate(context, text, disambig) class Ui_NodeEditorDialog(object): - def setupUi(self, NodeEditorDialog): - NodeEditorDialog.setObjectName(_fromUtf8("NodeEditorDialog")) - NodeEditorDialog.resize(750, 658) - self.verticalLayout = QtGui.QVBoxLayout(NodeEditorDialog) - self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) - self.splitter = QtGui.QSplitter(NodeEditorDialog) - self.splitter.setLineWidth(2) - self.splitter.setOrientation(QtCore.Qt.Horizontal) - self.splitter.setHandleWidth(8) - self.splitter.setChildrenCollapsible(False) - self.splitter.setObjectName(_fromUtf8("splitter")) - self.toolBox = QtGui.QToolBox(self.splitter) - self.toolBox.setMinimumSize(QtCore.QSize(0, 0)) - self.toolBox.setMaximumSize(QtCore.QSize(16777215, 16777215)) - self.toolBox.setBaseSize(QtCore.QSize(200, 0)) - self.toolBox.setFrameShape(QtGui.QFrame.NoFrame) - self.toolBox.setFrameShadow(QtGui.QFrame.Plain) - self.toolBox.setLineWidth(1) - self.toolBox.setMidLineWidth(0) - self.toolBox.setObjectName(_fromUtf8("toolBox")) - self.internals = QtGui.QWidget() - self.internals.setGeometry(QtCore.QRect(0, 0, 204, 501)) - self.internals.setObjectName(_fromUtf8("internals")) - self.verticalLayout_3 = QtGui.QVBoxLayout(self.internals) - self.verticalLayout_3.setSpacing(0) - self.verticalLayout_3.setMargin(0) - self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3")) - self.tabs_code_list = QtGui.QTabWidget(self.internals) - self.tabs_code_list.setObjectName(_fromUtf8("tabs_code_list")) - self.internals_tab = QtGui.QWidget() - self.internals_tab.setObjectName(_fromUtf8("internals_tab")) - self.gridLayout_4 = QtGui.QGridLayout(self.internals_tab) - self.gridLayout_4.setMargin(2) - self.gridLayout_4.setSpacing(0) - self.gridLayout_4.setObjectName(_fromUtf8("gridLayout_4")) - self.internals_list = NodeNamesEditor(self.internals_tab) - self.internals_list.setObjectName(_fromUtf8("internals_list")) - self.gridLayout_4.addWidget(self.internals_list, 0, 0, 1, 1) - self.tabs_code_list.addTab(self.internals_tab, _fromUtf8("")) - self.includes_tab = QtGui.QWidget() - self.includes_tab.setObjectName(_fromUtf8("includes_tab")) - self.gridLayout_5 = QtGui.QGridLayout(self.includes_tab) - self.gridLayout_5.setMargin(2) - self.gridLayout_5.setSpacing(0) - self.gridLayout_5.setObjectName(_fromUtf8("gridLayout_5")) - self.includes_list = NodeNamesEditor(self.includes_tab) - self.includes_list.setObjectName(_fromUtf8("includes_list")) - self.gridLayout_5.addWidget(self.includes_list, 0, 0, 1, 1) - self.tabs_code_list.addTab(self.includes_tab, _fromUtf8("")) - self.verticalLayout_3.addWidget(self.tabs_code_list) - self.toolBox.addItem(self.internals, _fromUtf8("")) - self.parameters = QtGui.QWidget() - self.parameters.setGeometry(QtCore.QRect(0, 0, 204, 501)) - self.parameters.setObjectName(_fromUtf8("parameters")) - self.verticalLayout_8 = QtGui.QVBoxLayout(self.parameters) - self.verticalLayout_8.setSpacing(0) - self.verticalLayout_8.setMargin(0) - self.verticalLayout_8.setObjectName(_fromUtf8("verticalLayout_8")) - self.tabs_param_list = QtGui.QTabWidget(self.parameters) - self.tabs_param_list.setObjectName(_fromUtf8("tabs_param_list")) - self.inputs_tab = QtGui.QWidget() - self.inputs_tab.setObjectName(_fromUtf8("inputs_tab")) - self.gridLayout_2 = QtGui.QGridLayout(self.inputs_tab) - self.gridLayout_2.setMargin(2) - self.gridLayout_2.setSpacing(0) - self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) - self.input_list = NodeNamesEditor(self.inputs_tab) - self.input_list.setObjectName(_fromUtf8("input_list")) - self.gridLayout_2.addWidget(self.input_list, 0, 0, 1, 1) - self.tabs_param_list.addTab(self.inputs_tab, _fromUtf8("")) - self.outputs_tab = QtGui.QWidget() - self.outputs_tab.setObjectName(_fromUtf8("outputs_tab")) - self.gridLayout_3 = QtGui.QGridLayout(self.outputs_tab) - self.gridLayout_3.setMargin(2) - self.gridLayout_3.setSpacing(0) - self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3")) - self.output_list = NodeNamesEditor(self.outputs_tab) - self.output_list.setObjectName(_fromUtf8("output_list")) - self.gridLayout_3.addWidget(self.output_list, 0, 0, 1, 1) - self.tabs_param_list.addTab(self.outputs_tab, _fromUtf8("")) - self.verticalLayout_8.addWidget(self.tabs_param_list) - self.toolBox.addItem(self.parameters, _fromUtf8("")) - self.handlers = QtGui.QWidget() - self.handlers.setGeometry(QtCore.QRect(0, 0, 204, 501)) - self.handlers.setObjectName(_fromUtf8("handlers")) - self.verticalLayout_2 = QtGui.QVBoxLayout(self.handlers) - self.verticalLayout_2.setSpacing(0) - self.verticalLayout_2.setMargin(0) - self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) - self.handlers_list = NodeNamesEditor(self.handlers) - self.handlers_list.setObjectName(_fromUtf8("handlers_list")) - self.verticalLayout_2.addWidget(self.handlers_list) - self.toolBox.addItem(self.handlers, _fromUtf8("")) - self.links = QtGui.QWidget() - self.links.setGeometry(QtCore.QRect(0, 0, 204, 501)) - self.links.setObjectName(_fromUtf8("links")) - self.verticalLayout_81 = QtGui.QVBoxLayout(self.links) - self.verticalLayout_81.setSpacing(0) - self.verticalLayout_81.setMargin(0) - self.verticalLayout_81.setObjectName(_fromUtf8("verticalLayout_81")) - self.tabs_links_list = QtGui.QTabWidget(self.links) - self.tabs_links_list.setObjectName(_fromUtf8("tabs_links_list")) - self.input_links_tab = QtGui.QWidget() - self.input_links_tab.setObjectName(_fromUtf8("input_links_tab")) - self.gridLayout_6 = QtGui.QGridLayout(self.input_links_tab) - self.gridLayout_6.setMargin(2) - self.gridLayout_6.setSpacing(0) - self.gridLayout_6.setObjectName(_fromUtf8("gridLayout_6")) - self.input_links_listWidget = QtGui.QListWidget(self.input_links_tab) - self.input_links_listWidget.setObjectName(_fromUtf8("input_links_listWidget")) - self.gridLayout_6.addWidget(self.input_links_listWidget, 0, 0, 1, 1) - self.tabs_links_list.addTab(self.input_links_tab, _fromUtf8("")) - self.output_links_tab = QtGui.QWidget() - self.output_links_tab.setObjectName(_fromUtf8("output_links_tab")) - self.gridLayout_66 = QtGui.QGridLayout(self.output_links_tab) - self.gridLayout_66.setMargin(2) - self.gridLayout_66.setSpacing(0) - self.gridLayout_66.setObjectName(_fromUtf8("gridLayout_66")) - self.output_links_listWidget = QtGui.QListWidget(self.output_links_tab) - self.output_links_listWidget.setObjectName(_fromUtf8("output_links_listWidget")) - self.gridLayout_66.addWidget(self.output_links_listWidget, 0, 0, 1, 1) - self.tabs_links_list.addTab(self.output_links_tab, _fromUtf8("")) - self.verticalLayout_81.addWidget(self.tabs_links_list) - self.toolBox.addItem(self.links, _fromUtf8("")) - self.tabWidget = QtGui.QTabWidget(self.splitter) - self.tabWidget.setObjectName(_fromUtf8("tabWidget")) - self.node_tab = QtGui.QWidget() - self.node_tab.setObjectName(_fromUtf8("node_tab")) - self.gridLayout_10 = QtGui.QGridLayout(self.node_tab) - self.gridLayout_10.setObjectName(_fromUtf8("gridLayout_10")) - self.node = NodePropertiesEditor(self.node_tab) - self.node.setObjectName(_fromUtf8("node")) - self.gridLayout_10.addWidget(self.node, 0, 0, 1, 1) - self.tabWidget.addTab(self.node_tab, _fromUtf8("")) - self.node_code_tab = QtGui.QWidget() - self.node_code_tab.setObjectName(_fromUtf8("node_code_tab")) - self.gridLayout = QtGui.QGridLayout(self.node_code_tab) - self.gridLayout.setMargin(2) - self.gridLayout.setSpacing(2) - self.gridLayout.setObjectName(_fromUtf8("gridLayout")) - self.node_code = NodeCodeEditor(self.node_code_tab) - self.node_code.setObjectName(_fromUtf8("node_code")) - self.gridLayout.addWidget(self.node_code, 0, 0, 1, 1) - self.tabWidget.addTab(self.node_code_tab, _fromUtf8("")) - self.control_code_tab = QtGui.QWidget() - self.control_code_tab.setObjectName(_fromUtf8("control_code_tab")) - self.gridLayout_7 = QtGui.QGridLayout(self.control_code_tab) - self.gridLayout_7.setMargin(2) - self.gridLayout_7.setSpacing(2) - self.gridLayout_7.setObjectName(_fromUtf8("gridLayout_7")) - self.control_code = NodeCodeEditor(self.control_code_tab) - self.control_code.setObjectName(_fromUtf8("control_code")) - self.gridLayout_7.addWidget(self.control_code, 0, 0, 1, 1) - self.tabWidget.addTab(self.control_code_tab, _fromUtf8("")) - self.event_code_tab = QtGui.QWidget() - self.event_code_tab.setObjectName(_fromUtf8("event_code_tab")) - self.gridLayout_8 = QtGui.QGridLayout(self.event_code_tab) - self.gridLayout_8.setMargin(2) - self.gridLayout_8.setSpacing(2) - self.gridLayout_8.setObjectName(_fromUtf8("gridLayout_8")) - self.event_code = NodeCodeEditor(self.event_code_tab) - self.event_code.setObjectName(_fromUtf8("event_code")) - self.gridLayout_8.addWidget(self.event_code, 0, 0, 1, 1) - self.tabWidget.addTab(self.event_code_tab, _fromUtf8("")) - self.param_code_tab = QtGui.QWidget() - self.param_code_tab.setObjectName(_fromUtf8("param_code_tab")) - self.gridLayout_9 = QtGui.QGridLayout(self.param_code_tab) - self.gridLayout_9.setMargin(2) - self.gridLayout_9.setSpacing(2) - self.gridLayout_9.setObjectName(_fromUtf8("gridLayout_9")) - self.param_code = NodeCodeEditor(self.param_code_tab) - self.param_code.setObjectName(_fromUtf8("param_code")) - self.gridLayout_9.addWidget(self.param_code, 0, 0, 1, 1) - self.tabWidget.addTab(self.param_code_tab, _fromUtf8("")) - self.param_tab = QtGui.QWidget() - self.param_tab.setObjectName(_fromUtf8("param_tab")) - self.gridLayout_11 = QtGui.QGridLayout(self.param_tab) - self.gridLayout_11.setObjectName(_fromUtf8("gridLayout_11")) - self.param = NodeParamEditor(self.param_tab) - self.param.setObjectName(_fromUtf8("param")) - self.gridLayout_11.addWidget(self.param, 0, 0, 1, 1) - self.tabWidget.addTab(self.param_tab, _fromUtf8("")) - self.link_tab = QtGui.QWidget() - self.link_tab.setObjectName(_fromUtf8("link_tab")) - self.gridLayout_12 = QtGui.QGridLayout(self.link_tab) - self.gridLayout_12.setObjectName(_fromUtf8("gridLayout_12")) - self.link = NodeLinkEditor(self.link_tab) - self.link.setObjectName(_fromUtf8("link")) - self.gridLayout_12.addWidget(self.link, 0, 0, 1, 1) - self.tabWidget.addTab(self.link_tab, _fromUtf8("")) - self.verticalLayout.addWidget(self.splitter) - self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) - spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout.addItem(spacerItem) - self.btn_save = QtGui.QPushButton(NodeEditorDialog) - self.btn_save.setObjectName(_fromUtf8("btn_save")) - self.horizontalLayout.addWidget(self.btn_save) - self.btn_close = QtGui.QPushButton(NodeEditorDialog) - self.btn_close.setObjectName(_fromUtf8("btn_close")) - self.horizontalLayout.addWidget(self.btn_close) - self.verticalLayout.addLayout(self.horizontalLayout) - self.verticalLayout.setStretch(0, 1) + def setupUi(self, NodeEditorDialog): + NodeEditorDialog.setObjectName(_fromUtf8("NodeEditorDialog")) + NodeEditorDialog.resize(750, 658) + self.verticalLayout = QtModule.QVBoxLayout(NodeEditorDialog) + self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + self.splitter = QtModule.QSplitter(NodeEditorDialog) + self.splitter.setLineWidth(2) + self.splitter.setOrientation(QtCore.Qt.Horizontal) + self.splitter.setHandleWidth(8) + self.splitter.setChildrenCollapsible(False) + self.splitter.setObjectName(_fromUtf8("splitter")) + self.toolBox = QtModule.QToolBox(self.splitter) + self.toolBox.setMinimumSize(QtCore.QSize(0, 0)) + self.toolBox.setMaximumSize(QtCore.QSize(16777215, 16777215)) + self.toolBox.setBaseSize(QtCore.QSize(200, 0)) + self.toolBox.setFrameShape(QtGui.QFrame.NoFrame) + self.toolBox.setFrameShadow(QtGui.QFrame.Plain) + self.toolBox.setLineWidth(1) + self.toolBox.setMidLineWidth(0) + self.toolBox.setObjectName(_fromUtf8("toolBox")) + self.internals = QtModule.QWidget() + self.internals.setGeometry(QtCore.QRect(0, 0, 204, 501)) + self.internals.setObjectName(_fromUtf8("internals")) + self.verticalLayout_3 = QtModule.QVBoxLayout(self.internals) + self.verticalLayout_3.setSpacing(0) + if QtCore.QT_VERSION < 50000 : + self.verticalLayout_3.setMargin(0) + self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3")) + self.tabs_code_list = QtModule.QTabWidget(self.internals) + self.tabs_code_list.setObjectName(_fromUtf8("tabs_code_list")) + self.internals_tab = QtModule.QWidget() + self.internals_tab.setObjectName(_fromUtf8("internals_tab")) + self.gridLayout_4 = QtModule.QGridLayout(self.internals_tab) + if QtCore.QT_VERSION < 50000 : + self.gridLayout_4.setMargin(2) + self.gridLayout_4.setSpacing(0) + self.gridLayout_4.setObjectName(_fromUtf8("gridLayout_4")) + self.internals_list = NodeNamesEditor(self.internals_tab) + self.internals_list.setObjectName(_fromUtf8("internals_list")) + self.gridLayout_4.addWidget(self.internals_list, 0, 0, 1, 1) + self.tabs_code_list.addTab(self.internals_tab, _fromUtf8("")) + self.includes_tab = QtModule.QWidget() + self.includes_tab.setObjectName(_fromUtf8("includes_tab")) + self.gridLayout_5 = QtModule.QGridLayout(self.includes_tab) + if QtCore.QT_VERSION < 50000 : + self.gridLayout_5.setMargin(2) + self.gridLayout_5.setSpacing(0) + self.gridLayout_5.setObjectName(_fromUtf8("gridLayout_5")) + self.includes_list = NodeNamesEditor(self.includes_tab) + self.includes_list.setObjectName(_fromUtf8("includes_list")) + self.gridLayout_5.addWidget(self.includes_list, 0, 0, 1, 1) + self.tabs_code_list.addTab(self.includes_tab, _fromUtf8("")) + self.verticalLayout_3.addWidget(self.tabs_code_list) + self.toolBox.addItem(self.internals, _fromUtf8("")) + self.parameters = QtModule.QWidget() + self.parameters.setGeometry(QtCore.QRect(0, 0, 204, 501)) + self.parameters.setObjectName(_fromUtf8("parameters")) + self.verticalLayout_8 = QtModule.QVBoxLayout(self.parameters) + self.verticalLayout_8.setSpacing(0) + if QtCore.QT_VERSION < 50000 : + self.verticalLayout_8.setMargin(0) + self.verticalLayout_8.setObjectName(_fromUtf8("verticalLayout_8")) + self.tabs_param_list = QtModule.QTabWidget(self.parameters) + self.tabs_param_list.setObjectName(_fromUtf8("tabs_param_list")) + self.inputs_tab = QtModule.QWidget() + self.inputs_tab.setObjectName(_fromUtf8("inputs_tab")) + self.gridLayout_2 = QtModule.QGridLayout(self.inputs_tab) + self.gridLayout_2.setMargin(2) + self.gridLayout_2.setSpacing(0) + self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) + self.input_list = NodeNamesEditor(self.inputs_tab) + self.input_list.setObjectName(_fromUtf8("input_list")) + self.gridLayout_2.addWidget(self.input_list, 0, 0, 1, 1) + self.tabs_param_list.addTab(self.inputs_tab, _fromUtf8("")) + self.outputs_tab = QtModule.QWidget() + self.outputs_tab.setObjectName(_fromUtf8("outputs_tab")) + self.gridLayout_3 = QtModule.QGridLayout(self.outputs_tab) + self.gridLayout_3.setMargin(2) + self.gridLayout_3.setSpacing(0) + self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3")) + self.output_list = NodeNamesEditor(self.outputs_tab) + self.output_list.setObjectName(_fromUtf8("output_list")) + self.gridLayout_3.addWidget(self.output_list, 0, 0, 1, 1) + self.tabs_param_list.addTab(self.outputs_tab, _fromUtf8("")) + self.verticalLayout_8.addWidget(self.tabs_param_list) + self.toolBox.addItem(self.parameters, _fromUtf8("")) + self.handlers = QtModule.QWidget() + self.handlers.setGeometry(QtCore.QRect(0, 0, 204, 501)) + self.handlers.setObjectName(_fromUtf8("handlers")) + self.verticalLayout_2 = QtModule.QVBoxLayout(self.handlers) + self.verticalLayout_2.setSpacing(0) + if QtCore.QT_VERSION < 50000 : + self.verticalLayout_2.setMargin(0) + self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) + self.handlers_list = NodeNamesEditor(self.handlers) + self.handlers_list.setObjectName(_fromUtf8("handlers_list")) + self.verticalLayout_2.addWidget(self.handlers_list) + self.toolBox.addItem(self.handlers, _fromUtf8("")) + self.links = QtModule.QWidget() + self.links.setGeometry(QtCore.QRect(0, 0, 204, 501)) + self.links.setObjectName(_fromUtf8("links")) + self.verticalLayout_81 = QtModule.QVBoxLayout(self.links) + self.verticalLayout_81.setSpacing(0) + if QtCore.QT_VERSION < 50000 : + self.verticalLayout_81.setMargin(0) + self.verticalLayout_81.setObjectName(_fromUtf8("verticalLayout_81")) + self.tabs_links_list = QtModule.QTabWidget(self.links) + self.tabs_links_list.setObjectName(_fromUtf8("tabs_links_list")) + self.input_links_tab = QtModule.QWidget() + self.input_links_tab.setObjectName(_fromUtf8("input_links_tab")) + self.gridLayout_6 = QtModule.QGridLayout(self.input_links_tab) + if QtCore.QT_VERSION < 50000 : + self.gridLayout_6.setMargin(2) + self.gridLayout_6.setSpacing(0) + self.gridLayout_6.setObjectName(_fromUtf8("gridLayout_6")) + self.input_links_listWidget = QtModule.QListWidget(self.input_links_tab) + self.input_links_listWidget.setObjectName(_fromUtf8("input_links_listWidget")) + self.gridLayout_6.addWidget(self.input_links_listWidget, 0, 0, 1, 1) + self.tabs_links_list.addTab(self.input_links_tab, _fromUtf8("")) + self.output_links_tab = QtModule.QWidget() + self.output_links_tab.setObjectName(_fromUtf8("output_links_tab")) + self.gridLayout_66 = QtModule.QGridLayout(self.output_links_tab) + if QtCore.QT_VERSION < 50000 : + self.gridLayout_66.setMargin(2) + self.gridLayout_66.setSpacing(0) + self.gridLayout_66.setObjectName(_fromUtf8("gridLayout_66")) + self.output_links_listWidget = QtModule.QListWidget(self.output_links_tab) + self.output_links_listWidget.setObjectName(_fromUtf8("output_links_listWidget")) + self.gridLayout_66.addWidget(self.output_links_listWidget, 0, 0, 1, 1) + self.tabs_links_list.addTab(self.output_links_tab, _fromUtf8("")) + self.verticalLayout_81.addWidget(self.tabs_links_list) + self.toolBox.addItem(self.links, _fromUtf8("")) + self.tabWidget = QtModule.QTabWidget(self.splitter) + self.tabWidget.setObjectName(_fromUtf8("tabWidget")) + self.node_tab = QtModule.QWidget() + self.node_tab.setObjectName(_fromUtf8("node_tab")) + self.gridLayout_10 = QtModule.QGridLayout(self.node_tab) + self.gridLayout_10.setObjectName(_fromUtf8("gridLayout_10")) + self.node = NodePropertiesEditor(self.node_tab) + self.node.setObjectName(_fromUtf8("node")) + self.gridLayout_10.addWidget(self.node, 0, 0, 1, 1) + self.tabWidget.addTab(self.node_tab, _fromUtf8("")) + self.node_code_tab = QtModule.QWidget() + self.node_code_tab.setObjectName(_fromUtf8("node_code_tab")) + self.gridLayout = QtModule.QGridLayout(self.node_code_tab) + if QtCore.QT_VERSION < 50000 : + self.gridLayout.setMargin(2) + self.gridLayout.setSpacing(2) + self.gridLayout.setObjectName(_fromUtf8("gridLayout")) + self.node_code = NodeCodeEditor(self.node_code_tab) + self.node_code.setObjectName(_fromUtf8("node_code")) + self.gridLayout.addWidget(self.node_code, 0, 0, 1, 1) + self.tabWidget.addTab(self.node_code_tab, _fromUtf8("")) + self.control_code_tab = QtModule.QWidget() + self.control_code_tab.setObjectName(_fromUtf8("control_code_tab")) + self.gridLayout_7 = QtModule.QGridLayout(self.control_code_tab) + self.gridLayout_7.setMargin(2) + self.gridLayout_7.setSpacing(2) + self.gridLayout_7.setObjectName(_fromUtf8("gridLayout_7")) + self.control_code = NodeCodeEditor(self.control_code_tab) + self.control_code.setObjectName(_fromUtf8("control_code")) + self.gridLayout_7.addWidget(self.control_code, 0, 0, 1, 1) + self.tabWidget.addTab(self.control_code_tab, _fromUtf8("")) + self.event_code_tab = QtModule.QWidget() + self.event_code_tab.setObjectName(_fromUtf8("event_code_tab")) + self.gridLayout_8 = QtModule.QGridLayout(self.event_code_tab) + if QtCore.QT_VERSION < 50000 : + self.gridLayout_8.setMargin(2) + self.gridLayout_8.setSpacing(2) + self.gridLayout_8.setObjectName(_fromUtf8("gridLayout_8")) + self.event_code = NodeCodeEditor(self.event_code_tab) + self.event_code.setObjectName(_fromUtf8("event_code")) + self.gridLayout_8.addWidget(self.event_code, 0, 0, 1, 1) + self.tabWidget.addTab(self.event_code_tab, _fromUtf8("")) + self.param_code_tab = QtModule.QWidget() + self.param_code_tab.setObjectName(_fromUtf8("param_code_tab")) + self.gridLayout_9 = QtModule.QGridLayout(self.param_code_tab) + if QtCore.QT_VERSION < 50000 : + self.gridLayout_9.setMargin(2) + self.gridLayout_9.setSpacing(2) + self.gridLayout_9.setObjectName(_fromUtf8("gridLayout_9")) + self.param_code = NodeCodeEditor(self.param_code_tab) + self.param_code.setObjectName(_fromUtf8("param_code")) + self.gridLayout_9.addWidget(self.param_code, 0, 0, 1, 1) + self.tabWidget.addTab(self.param_code_tab, _fromUtf8("")) + self.param_tab = QtModule.QWidget() + self.param_tab.setObjectName(_fromUtf8("param_tab")) + self.gridLayout_11 = QtModule.QGridLayout(self.param_tab) + self.gridLayout_11.setObjectName(_fromUtf8("gridLayout_11")) + self.param = NodeParamEditor(self.param_tab) + self.param.setObjectName(_fromUtf8("param")) + self.gridLayout_11.addWidget(self.param, 0, 0, 1, 1) + self.tabWidget.addTab(self.param_tab, _fromUtf8("")) + self.link_tab = QtModule.QWidget() + self.link_tab.setObjectName(_fromUtf8("link_tab")) + self.gridLayout_12 = QtModule.QGridLayout(self.link_tab) + self.gridLayout_12.setObjectName(_fromUtf8("gridLayout_12")) + self.link = NodeLinkEditor(self.link_tab) + self.link.setObjectName(_fromUtf8("link")) + self.gridLayout_12.addWidget(self.link, 0, 0, 1, 1) + self.tabWidget.addTab(self.link_tab, _fromUtf8("")) + self.verticalLayout.addWidget(self.splitter) + self.horizontalLayout = QtGui.QHBoxLayout() + self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) + spacerItem = QtGui.QSpacerItem(40, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) + self.horizontalLayout.addItem(spacerItem) + self.btn_save = QtGui.QPushButton(NodeEditorDialog) + self.btn_save.setObjectName(_fromUtf8("btn_save")) + self.horizontalLayout.addWidget(self.btn_save) + self.btn_close = QtGui.QPushButton(NodeEditorDialog) + self.btn_close.setObjectName(_fromUtf8("btn_close")) + self.horizontalLayout.addWidget(self.btn_close) + self.verticalLayout.addLayout(self.horizontalLayout) + self.verticalLayout.setStretch(0, 1) - self.retranslateUi(NodeEditorDialog) - self.toolBox.setCurrentIndex(0) - self.toolBox.layout().setSpacing(6) - self.tabs_code_list.setCurrentIndex(0) - self.tabs_param_list.setCurrentIndex(0) - self.tabs_links_list.setCurrentIndex(0) - self.tabWidget.setCurrentIndex(0) - QtCore.QObject.connect(self.toolBox, QtCore.SIGNAL(_fromUtf8("currentChanged(int)")), NodeEditorDialog.onToolBoxIndexChanged) - QtCore.QObject.connect(self.btn_save, QtCore.SIGNAL(_fromUtf8("clicked()")), NodeEditorDialog.accept) - QtCore.QObject.connect(self.btn_close, QtCore.SIGNAL(_fromUtf8("clicked()")), NodeEditorDialog.reject) - QtCore.QObject.connect(self.input_links_listWidget, QtCore.SIGNAL(_fromUtf8("itemSelectionChanged()")), NodeEditorDialog.updateGui) - QtCore.QObject.connect(self.output_links_listWidget, QtCore.SIGNAL(_fromUtf8("itemSelectionChanged()")), NodeEditorDialog.updateGui) - QtCore.QObject.connect(self.tabs_links_list, QtCore.SIGNAL(_fromUtf8("currentChanged(int)")), NodeEditorDialog.updateGui) - QtCore.QMetaObject.connectSlotsByName(NodeEditorDialog) + self.retranslateUi(NodeEditorDialog) + self.toolBox.setCurrentIndex(0) + self.toolBox.layout().setSpacing(6) + self.tabs_code_list.setCurrentIndex(0) + self.tabs_param_list.setCurrentIndex(0) + self.tabs_links_list.setCurrentIndex(0) + self.tabWidget.setCurrentIndex(0) + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.connect(self.toolBox, QtCore.SIGNAL(_fromUtf8("currentChanged(int)")), NodeEditorDialog.onToolBoxIndexChanged) + QtCore.QObject.connect(self.btn_save, QtCore.SIGNAL(_fromUtf8("clicked()")), NodeEditorDialog.accept) + QtCore.QObject.connect(self.btn_close, QtCore.SIGNAL(_fromUtf8("clicked()")), NodeEditorDialog.reject) + QtCore.QObject.connect(self.input_links_listWidget, QtCore.SIGNAL(_fromUtf8("itemSelectionChanged()")), NodeEditorDialog.updateGui) + QtCore.QObject.connect(self.output_links_listWidget, QtCore.SIGNAL(_fromUtf8("itemSelectionChanged()")), NodeEditorDialog.updateGui) + QtCore.QObject.connect(self.tabs_links_list, QtCore.SIGNAL(_fromUtf8("currentChanged(int)")), NodeEditorDialog.updateGui) + else : + self.toolBox.currentChanged.connect( NodeEditorDialog.onToolBoxIndexChanged) + self.btn_save.clicked.connect( NodeEditorDialog.accept) + self.btn_close.clicked.connect( NodeEditorDialog.reject) + self.input_links_listWidget.itemSelectionChanged.connect( NodeEditorDialog.updateGui) + self.output_links_listWidget.itemSelectionChanged.connect( NodeEditorDialog.updateGui) + self.tabs_links_list,currentChanged.connect( NodeEditorDialog.updateGui) + + QtCore.QMetaObject.connectSlotsByName(NodeEditorDialog) - def retranslateUi(self, NodeEditorDialog): - NodeEditorDialog.setWindowTitle(_translate("NodeEditorDialog", "NodeEditor", None)) - self.tabs_code_list.setTabText(self.tabs_code_list.indexOf(self.internals_tab), _translate("NodeEditorDialog", "Local variables", None)) - self.tabs_code_list.setTabText(self.tabs_code_list.indexOf(self.includes_tab), _translate("NodeEditorDialog", "Includes", None)) - self.toolBox.setItemText(self.toolBox.indexOf(self.internals), _translate("NodeEditorDialog", "Internals", None)) - self.tabs_param_list.setTabText(self.tabs_param_list.indexOf(self.inputs_tab), _translate("NodeEditorDialog", "Input", None)) - self.tabs_param_list.setTabText(self.tabs_param_list.indexOf(self.outputs_tab), _translate("NodeEditorDialog", "Output", None)) - self.toolBox.setItemText(self.toolBox.indexOf(self.parameters), _translate("NodeEditorDialog", "Parameters", None)) - self.toolBox.setItemText(self.toolBox.indexOf(self.handlers), _translate("NodeEditorDialog", "Event Handlers", None)) - self.tabs_links_list.setTabText(self.tabs_links_list.indexOf(self.input_links_tab), _translate("NodeEditorDialog", "Input", None)) - self.tabs_links_list.setTabText(self.tabs_links_list.indexOf(self.output_links_tab), _translate("NodeEditorDialog", "Output", None)) - self.toolBox.setItemText(self.toolBox.indexOf(self.links), _translate("NodeEditorDialog", "Links", None)) - self.tabWidget.setTabText(self.tabWidget.indexOf(self.node_tab), _translate("NodeEditorDialog", "Node", None)) - self.tabWidget.setTabText(self.tabWidget.indexOf(self.node_code_tab), _translate("NodeEditorDialog", "Node Code", None)) - self.tabWidget.setTabText(self.tabWidget.indexOf(self.control_code_tab), _translate("NodeEditorDialog", "Control Code", None)) - self.tabWidget.setTabText(self.tabWidget.indexOf(self.event_code_tab), _translate("NodeEditorDialog", "Event Code", None)) - self.tabWidget.setTabText(self.tabWidget.indexOf(self.param_code_tab), _translate("NodeEditorDialog", "Param Code", None)) - self.tabWidget.setTabText(self.tabWidget.indexOf(self.param_tab), _translate("NodeEditorDialog", "Parameter", None)) - self.tabWidget.setTabText(self.tabWidget.indexOf(self.link_tab), _translate("NodeEditorDialog", "Link Info", None)) - self.btn_save.setText(_translate("NodeEditorDialog", "Save", None)) - self.btn_close.setText(_translate("NodeEditorDialog", "Close", None)) + def retranslateUi(self, NodeEditorDialog): + NodeEditorDialog.setWindowTitle(_translate("NodeEditorDialog", "NodeEditor", None)) + self.tabs_code_list.setTabText(self.tabs_code_list.indexOf(self.internals_tab), _translate("NodeEditorDialog", "Local variables", None)) + self.tabs_code_list.setTabText(self.tabs_code_list.indexOf(self.includes_tab), _translate("NodeEditorDialog", "Includes", None)) + self.toolBox.setItemText(self.toolBox.indexOf(self.internals), _translate("NodeEditorDialog", "Internals", None)) + self.tabs_param_list.setTabText(self.tabs_param_list.indexOf(self.inputs_tab), _translate("NodeEditorDialog", "Input", None)) + self.tabs_param_list.setTabText(self.tabs_param_list.indexOf(self.outputs_tab), _translate("NodeEditorDialog", "Output", None)) + self.toolBox.setItemText(self.toolBox.indexOf(self.parameters), _translate("NodeEditorDialog", "Parameters", None)) + self.toolBox.setItemText(self.toolBox.indexOf(self.handlers), _translate("NodeEditorDialog", "Event Handlers", None)) + self.tabs_links_list.setTabText(self.tabs_links_list.indexOf(self.input_links_tab), _translate("NodeEditorDialog", "Input", None)) + self.tabs_links_list.setTabText(self.tabs_links_list.indexOf(self.output_links_tab), _translate("NodeEditorDialog", "Output", None)) + self.toolBox.setItemText(self.toolBox.indexOf(self.links), _translate("NodeEditorDialog", "Links", None)) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.node_tab), _translate("NodeEditorDialog", "Node", None)) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.node_code_tab), _translate("NodeEditorDialog", "Node Code", None)) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.control_code_tab), _translate("NodeEditorDialog", "Control Code", None)) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.event_code_tab), _translate("NodeEditorDialog", "Event Code", None)) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.param_code_tab), _translate("NodeEditorDialog", "Param Code", None)) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.param_tab), _translate("NodeEditorDialog", "Parameter", None)) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.link_tab), _translate("NodeEditorDialog", "Link Info", None)) + self.btn_save.setText(_translate("NodeEditorDialog", "Save", None)) + self.btn_close.setText(_translate("NodeEditorDialog", "Close", None)) from nodeNamesEditor import NodeNamesEditor from nodePropertiesEditor import NodePropertiesEditor diff --git a/gui/nodeEditor/ui_nodeLinkEditor.py b/gui/nodeEditor/ui_nodeLinkEditor.py index eb1f054..97bad40 100644 --- a/gui/nodeEditor/ui_nodeLinkEditor.py +++ b/gui/nodeEditor/ui_nodeLinkEditor.py @@ -9,118 +9,124 @@ from core.mePyQt import QtCore, QtGui +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + try: - _fromUtf8 = QtCore.QString.fromUtf8 + _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: - _fromUtf8 = lambda s: s + _fromUtf8 = lambda s: s class Ui_NodeLinkEditor(object): - def setupUi(self, NodeLinkEditor): - NodeLinkEditor.setObjectName(_fromUtf8("NodeLinkEditor")) - NodeLinkEditor.resize(714, 611) - self.verticalLayout_3 = QtGui.QVBoxLayout(NodeLinkEditor) - self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3")) - self.srcGroup = QtGui.QGroupBox(NodeLinkEditor) - self.srcGroup.setObjectName(_fromUtf8("srcGroup")) - self.verticalLayout = QtGui.QVBoxLayout(self.srcGroup) - self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) - self.horizontalLayout_2 = QtGui.QHBoxLayout() - self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) - self.name_label = QtGui.QLabel(self.srcGroup) - self.name_label.setMinimumSize(QtCore.QSize(100, 0)) - self.name_label.setObjectName(_fromUtf8("name_label")) - self.horizontalLayout_2.addWidget(self.name_label) - self.src_node_lineEdit = QtGui.QLineEdit(self.srcGroup) - self.src_node_lineEdit.setEnabled(False) - self.src_node_lineEdit.setObjectName(_fromUtf8("src_node_lineEdit")) - self.horizontalLayout_2.addWidget(self.src_node_lineEdit) - self.horizontalLayout_2.setStretch(1, 1) - self.verticalLayout.addLayout(self.horizontalLayout_2) - self.horizontalLayout_3 = QtGui.QHBoxLayout() - self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3")) - self.label_label = QtGui.QLabel(self.srcGroup) - self.label_label.setMinimumSize(QtCore.QSize(100, 0)) - self.label_label.setObjectName(_fromUtf8("label_label")) - self.horizontalLayout_3.addWidget(self.label_label) - self.src_param_lineEdit = QtGui.QLineEdit(self.srcGroup) - self.src_param_lineEdit.setEnabled(False) - self.src_param_lineEdit.setObjectName(_fromUtf8("src_param_lineEdit")) - self.horizontalLayout_3.addWidget(self.src_param_lineEdit) - self.horizontalLayout_3.setStretch(1, 1) - self.verticalLayout.addLayout(self.horizontalLayout_3) - self.horizontalLayout_4 = QtGui.QHBoxLayout() - self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4")) - self.name_label_2 = QtGui.QLabel(self.srcGroup) - self.name_label_2.setMinimumSize(QtCore.QSize(100, 0)) - self.name_label_2.setObjectName(_fromUtf8("name_label_2")) - self.horizontalLayout_4.addWidget(self.name_label_2) - self.src_id_lineEdit = QtGui.QLineEdit(self.srcGroup) - self.src_id_lineEdit.setEnabled(False) - self.src_id_lineEdit.setMaximumSize(QtCore.QSize(50, 16777215)) - self.src_id_lineEdit.setObjectName(_fromUtf8("src_id_lineEdit")) - self.horizontalLayout_4.addWidget(self.src_id_lineEdit) - spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout_4.addItem(spacerItem) - self.verticalLayout.addLayout(self.horizontalLayout_4) - self.verticalLayout_3.addWidget(self.srcGroup) - self.dstGroup = QtGui.QGroupBox(NodeLinkEditor) - self.dstGroup.setObjectName(_fromUtf8("dstGroup")) - self.verticalLayout_2 = QtGui.QVBoxLayout(self.dstGroup) - self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) - self.horizontalLayout_6 = QtGui.QHBoxLayout() - self.horizontalLayout_6.setObjectName(_fromUtf8("horizontalLayout_6")) - self.name_label_3 = QtGui.QLabel(self.dstGroup) - self.name_label_3.setMinimumSize(QtCore.QSize(100, 0)) - self.name_label_3.setObjectName(_fromUtf8("name_label_3")) - self.horizontalLayout_6.addWidget(self.name_label_3) - self.dst_node_lineEdit = QtGui.QLineEdit(self.dstGroup) - self.dst_node_lineEdit.setEnabled(False) - self.dst_node_lineEdit.setObjectName(_fromUtf8("dst_node_lineEdit")) - self.horizontalLayout_6.addWidget(self.dst_node_lineEdit) - self.horizontalLayout_6.setStretch(1, 1) - self.verticalLayout_2.addLayout(self.horizontalLayout_6) - self.horizontalLayout_5 = QtGui.QHBoxLayout() - self.horizontalLayout_5.setObjectName(_fromUtf8("horizontalLayout_5")) - self.label_label_2 = QtGui.QLabel(self.dstGroup) - self.label_label_2.setMinimumSize(QtCore.QSize(100, 0)) - self.label_label_2.setObjectName(_fromUtf8("label_label_2")) - self.horizontalLayout_5.addWidget(self.label_label_2) - self.dst_param_lineEdit = QtGui.QLineEdit(self.dstGroup) - self.dst_param_lineEdit.setEnabled(False) - self.dst_param_lineEdit.setObjectName(_fromUtf8("dst_param_lineEdit")) - self.horizontalLayout_5.addWidget(self.dst_param_lineEdit) - self.horizontalLayout_5.setStretch(1, 1) - self.verticalLayout_2.addLayout(self.horizontalLayout_5) - self.horizontalLayout_7 = QtGui.QHBoxLayout() - self.horizontalLayout_7.setSpacing(6) - self.horizontalLayout_7.setObjectName(_fromUtf8("horizontalLayout_7")) - self.name_label_4 = QtGui.QLabel(self.dstGroup) - self.name_label_4.setMinimumSize(QtCore.QSize(100, 0)) - self.name_label_4.setObjectName(_fromUtf8("name_label_4")) - self.horizontalLayout_7.addWidget(self.name_label_4) - self.dst_id_lineEdit = QtGui.QLineEdit(self.dstGroup) - self.dst_id_lineEdit.setEnabled(False) - self.dst_id_lineEdit.setMaximumSize(QtCore.QSize(50, 16777215)) - self.dst_id_lineEdit.setObjectName(_fromUtf8("dst_id_lineEdit")) - self.horizontalLayout_7.addWidget(self.dst_id_lineEdit) - spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout_7.addItem(spacerItem1) - self.verticalLayout_2.addLayout(self.horizontalLayout_7) - self.verticalLayout_3.addWidget(self.dstGroup) - spacerItem2 = QtGui.QSpacerItem(20, 0, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.verticalLayout_3.addItem(spacerItem2) + def setupUi(self, NodeLinkEditor): + NodeLinkEditor.setObjectName(_fromUtf8("NodeLinkEditor")) + NodeLinkEditor.resize(714, 611) + self.verticalLayout_3 = QtModule.QVBoxLayout(NodeLinkEditor) + self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3")) + self.srcGroup = QtModule.QGroupBox(NodeLinkEditor) + self.srcGroup.setObjectName(_fromUtf8("srcGroup")) + self.verticalLayout = QtModule.QVBoxLayout(self.srcGroup) + self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + self.horizontalLayout_2 = QtModule.QHBoxLayout() + self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) + self.name_label = QtModule.QLabel(self.srcGroup) + self.name_label.setMinimumSize(QtCore.QSize(100, 0)) + self.name_label.setObjectName(_fromUtf8("name_label")) + self.horizontalLayout_2.addWidget(self.name_label) + self.src_node_lineEdit = QtModule.QLineEdit(self.srcGroup) + self.src_node_lineEdit.setEnabled(False) + self.src_node_lineEdit.setObjectName(_fromUtf8("src_node_lineEdit")) + self.horizontalLayout_2.addWidget(self.src_node_lineEdit) + self.horizontalLayout_2.setStretch(1, 1) + self.verticalLayout.addLayout(self.horizontalLayout_2) + self.horizontalLayout_3 = QtModule.QHBoxLayout() + self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3")) + self.label_label = QtModule.QLabel(self.srcGroup) + self.label_label.setMinimumSize(QtCore.QSize(100, 0)) + self.label_label.setObjectName(_fromUtf8("label_label")) + self.horizontalLayout_3.addWidget(self.label_label) + self.src_param_lineEdit = QtModule.QLineEdit(self.srcGroup) + self.src_param_lineEdit.setEnabled(False) + self.src_param_lineEdit.setObjectName(_fromUtf8("src_param_lineEdit")) + self.horizontalLayout_3.addWidget(self.src_param_lineEdit) + self.horizontalLayout_3.setStretch(1, 1) + self.verticalLayout.addLayout(self.horizontalLayout_3) + self.horizontalLayout_4 = QtModule.QHBoxLayout() + self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4")) + self.name_label_2 = QtModule.QLabel(self.srcGroup) + self.name_label_2.setMinimumSize(QtCore.QSize(100, 0)) + self.name_label_2.setObjectName(_fromUtf8("name_label_2")) + self.horizontalLayout_4.addWidget(self.name_label_2) + self.src_id_lineEdit = QtModule.QLineEdit(self.srcGroup) + self.src_id_lineEdit.setEnabled(False) + self.src_id_lineEdit.setMaximumSize(QtCore.QSize(50, 16777215)) + self.src_id_lineEdit.setObjectName(_fromUtf8("src_id_lineEdit")) + self.horizontalLayout_4.addWidget(self.src_id_lineEdit) + spacerItem = QtModule.QSpacerItem(40, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) + self.horizontalLayout_4.addItem(spacerItem) + self.verticalLayout.addLayout(self.horizontalLayout_4) + self.verticalLayout_3.addWidget(self.srcGroup) + self.dstGroup = QtModule.QGroupBox(NodeLinkEditor) + self.dstGroup.setObjectName(_fromUtf8("dstGroup")) + self.verticalLayout_2 = QtModule.QVBoxLayout(self.dstGroup) + self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) + self.horizontalLayout_6 = QtModule.QHBoxLayout() + self.horizontalLayout_6.setObjectName(_fromUtf8("horizontalLayout_6")) + self.name_label_3 = QtModule.QLabel(self.dstGroup) + self.name_label_3.setMinimumSize(QtCore.QSize(100, 0)) + self.name_label_3.setObjectName(_fromUtf8("name_label_3")) + self.horizontalLayout_6.addWidget(self.name_label_3) + self.dst_node_lineEdit = QtModule.QLineEdit(self.dstGroup) + self.dst_node_lineEdit.setEnabled(False) + self.dst_node_lineEdit.setObjectName(_fromUtf8("dst_node_lineEdit")) + self.horizontalLayout_6.addWidget(self.dst_node_lineEdit) + self.horizontalLayout_6.setStretch(1, 1) + self.verticalLayout_2.addLayout(self.horizontalLayout_6) + self.horizontalLayout_5 = QtModule.QHBoxLayout() + self.horizontalLayout_5.setObjectName(_fromUtf8("horizontalLayout_5")) + self.label_label_2 = QtModule.QLabel(self.dstGroup) + self.label_label_2.setMinimumSize(QtCore.QSize(100, 0)) + self.label_label_2.setObjectName(_fromUtf8("label_label_2")) + self.horizontalLayout_5.addWidget(self.label_label_2) + self.dst_param_lineEdit = QtModule.QLineEdit(self.dstGroup) + self.dst_param_lineEdit.setEnabled(False) + self.dst_param_lineEdit.setObjectName(_fromUtf8("dst_param_lineEdit")) + self.horizontalLayout_5.addWidget(self.dst_param_lineEdit) + self.horizontalLayout_5.setStretch(1, 1) + self.verticalLayout_2.addLayout(self.horizontalLayout_5) + self.horizontalLayout_7 = QtModule.QHBoxLayout() + self.horizontalLayout_7.setSpacing(6) + self.horizontalLayout_7.setObjectName(_fromUtf8("horizontalLayout_7")) + self.name_label_4 = QtModule.QLabel(self.dstGroup) + self.name_label_4.setMinimumSize(QtCore.QSize(100, 0)) + self.name_label_4.setObjectName(_fromUtf8("name_label_4")) + self.horizontalLayout_7.addWidget(self.name_label_4) + self.dst_id_lineEdit = QtModule.QLineEdit(self.dstGroup) + self.dst_id_lineEdit.setEnabled(False) + self.dst_id_lineEdit.setMaximumSize(QtCore.QSize(50, 16777215)) + self.dst_id_lineEdit.setObjectName(_fromUtf8("dst_id_lineEdit")) + self.horizontalLayout_7.addWidget(self.dst_id_lineEdit) + spacerItem1 = QtModule.QSpacerItem(40, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) + self.horizontalLayout_7.addItem(spacerItem1) + self.verticalLayout_2.addLayout(self.horizontalLayout_7) + self.verticalLayout_3.addWidget(self.dstGroup) + spacerItem2 = QtModule.QSpacerItem(20, 0, QtModule.QSizePolicy.Minimum, QtModule.QSizePolicy.Expanding) + self.verticalLayout_3.addItem(spacerItem2) - self.retranslateUi(NodeLinkEditor) - QtCore.QMetaObject.connectSlotsByName(NodeLinkEditor) + self.retranslateUi(NodeLinkEditor) + QtCore.QMetaObject.connectSlotsByName(NodeLinkEditor) - def retranslateUi(self, NodeLinkEditor): - NodeLinkEditor.setWindowTitle(QtGui.QApplication.translate("NodeLinkEditor", "NodeLinkEditor", None, QtGui.QApplication.UnicodeUTF8)) - self.srcGroup.setTitle(QtGui.QApplication.translate("NodeLinkEditor", "Source Node", None, QtGui.QApplication.UnicodeUTF8)) - self.name_label.setText(QtGui.QApplication.translate("NodeLinkEditor", "Name", None, QtGui.QApplication.UnicodeUTF8)) - self.label_label.setText(QtGui.QApplication.translate("NodeLinkEditor", "Parameter", None, QtGui.QApplication.UnicodeUTF8)) - self.name_label_2.setText(QtGui.QApplication.translate("NodeLinkEditor", "id", None, QtGui.QApplication.UnicodeUTF8)) - self.dstGroup.setTitle(QtGui.QApplication.translate("NodeLinkEditor", "Destination Node", None, QtGui.QApplication.UnicodeUTF8)) - self.name_label_3.setText(QtGui.QApplication.translate("NodeLinkEditor", "Name", None, QtGui.QApplication.UnicodeUTF8)) - self.label_label_2.setText(QtGui.QApplication.translate("NodeLinkEditor", "Parameter", None, QtGui.QApplication.UnicodeUTF8)) - self.name_label_4.setText(QtGui.QApplication.translate("NodeLinkEditor", "id", None, QtGui.QApplication.UnicodeUTF8)) + def retranslateUi(self, NodeLinkEditor): + NodeLinkEditor.setWindowTitle(QtGui.QApplication.translate("NodeLinkEditor", "NodeLinkEditor", None)) + self.srcGroup.setTitle(QtGui.QApplication.translate("NodeLinkEditor", "Source Node", None)) + self.name_label.setText(QtGui.QApplication.translate("NodeLinkEditor", "Name", None)) + self.label_label.setText(QtGui.QApplication.translate("NodeLinkEditor", "Parameter", None)) + self.name_label_2.setText(QtGui.QApplication.translate("NodeLinkEditor", "id", None)) + self.dstGroup.setTitle(QtGui.QApplication.translate("NodeLinkEditor", "Destination Node", None)) + self.name_label_3.setText(QtGui.QApplication.translate("NodeLinkEditor", "Name", None)) + self.label_label_2.setText(QtGui.QApplication.translate("NodeLinkEditor", "Parameter", None)) + self.name_label_4.setText(QtGui.QApplication.translate("NodeLinkEditor", "id", None)) diff --git a/gui/nodeEditor/ui_nodeNamesEditor.py b/gui/nodeEditor/ui_nodeNamesEditor.py index 2de8d24..cf82fb9 100644 --- a/gui/nodeEditor/ui_nodeNamesEditor.py +++ b/gui/nodeEditor/ui_nodeNamesEditor.py @@ -9,65 +9,77 @@ from core.mePyQt import QtCore, QtGui +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + try: - _fromUtf8 = QtCore.QString.fromUtf8 + _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: - _fromUtf8 = lambda s: s + _fromUtf8 = lambda s: s class Ui_NodeNamesEditor(object): - def setupUi(self, NodeNamesEditor): - NodeNamesEditor.setObjectName(_fromUtf8("NodeNamesEditor")) - NodeNamesEditor.resize(417, 393) - self.verticalLayout = QtGui.QVBoxLayout(NodeNamesEditor) - self.verticalLayout.setSpacing(0) - self.verticalLayout.setMargin(0) - self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) - self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setSpacing(2) - self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) - self.name_lineEdit = QtGui.QLineEdit(NodeNamesEditor) - self.name_lineEdit.setObjectName(_fromUtf8("name_lineEdit")) - self.horizontalLayout.addWidget(self.name_lineEdit) - self.addButton = QtGui.QToolButton(NodeNamesEditor) - self.addButton.setMinimumSize(QtCore.QSize(24, 24)) - self.addButton.setMaximumSize(QtCore.QSize(24, 24)) - icon = QtGui.QIcon() - icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/edit_icons/resources/plus.png")), QtGui.QIcon.Normal, QtGui.QIcon.On) - self.addButton.setIcon(icon) - self.addButton.setObjectName(_fromUtf8("addButton")) - self.horizontalLayout.addWidget(self.addButton) - self.removeButton = QtGui.QToolButton(NodeNamesEditor) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(24) - sizePolicy.setVerticalStretch(24) - sizePolicy.setHeightForWidth(self.removeButton.sizePolicy().hasHeightForWidth()) - self.removeButton.setSizePolicy(sizePolicy) - self.removeButton.setMaximumSize(QtCore.QSize(24, 24)) - icon1 = QtGui.QIcon() - icon1.addPixmap(QtGui.QPixmap(_fromUtf8(":/edit_icons/resources/minus.png")), QtGui.QIcon.Normal, QtGui.QIcon.On) - self.removeButton.setIcon(icon1) - self.removeButton.setObjectName(_fromUtf8("removeButton")) - self.horizontalLayout.addWidget(self.removeButton) - self.verticalLayout.addLayout(self.horizontalLayout) - self.listWidget = QtGui.QListWidget(NodeNamesEditor) - self.listWidget.setAcceptDrops(True) - self.listWidget.setDragEnabled(True) - self.listWidget.setDragDropMode(QtGui.QAbstractItemView.InternalMove) - self.listWidget.setObjectName(_fromUtf8("listWidget")) - self.verticalLayout.addWidget(self.listWidget) + def setupUi(self, NodeNamesEditor): + NodeNamesEditor.setObjectName(_fromUtf8("NodeNamesEditor")) + NodeNamesEditor.resize(417, 393) + self.verticalLayout = QtModule.QVBoxLayout(NodeNamesEditor) + self.verticalLayout.setSpacing(0) + self.verticalLayout.setMargin(0) + self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + self.horizontalLayout = QtModule.QHBoxLayout() + self.horizontalLayout.setSpacing(2) + self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) + self.name_lineEdit = QtModule.QLineEdit(NodeNamesEditor) + self.name_lineEdit.setObjectName(_fromUtf8("name_lineEdit")) + self.horizontalLayout.addWidget(self.name_lineEdit) + self.addButton = QtModule.QToolButton(NodeNamesEditor) + self.addButton.setMinimumSize(QtCore.QSize(24, 24)) + self.addButton.setMaximumSize(QtCore.QSize(24, 24)) + icon = QtGui.QIcon() + icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/edit_icons/resources/plus.png")), QtGui.QIcon.Normal, QtGui.QIcon.On) + self.addButton.setIcon(icon) + self.addButton.setObjectName(_fromUtf8("addButton")) + self.horizontalLayout.addWidget(self.addButton) + self.removeButton = QtModule.QToolButton(NodeNamesEditor) + sizePolicy = QtModule.QSizePolicy(QtModule.QSizePolicy.Fixed, QtModule.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(24) + sizePolicy.setVerticalStretch(24) + sizePolicy.setHeightForWidth(self.removeButton.sizePolicy().hasHeightForWidth()) + self.removeButton.setSizePolicy(sizePolicy) + self.removeButton.setMaximumSize(QtCore.QSize(24, 24)) + icon1 = QtGui.QIcon() + icon1.addPixmap(QtGui.QPixmap(_fromUtf8(":/edit_icons/resources/minus.png")), QtGui.QIcon.Normal, QtGui.QIcon.On) + self.removeButton.setIcon(icon1) + self.removeButton.setObjectName(_fromUtf8("removeButton")) + self.horizontalLayout.addWidget(self.removeButton) + self.verticalLayout.addLayout(self.horizontalLayout) + self.listWidget = QtModule.QListWidget(NodeNamesEditor) + self.listWidget.setAcceptDrops(True) + self.listWidget.setDragEnabled(True) + self.listWidget.setDragDropMode(QtGui.QAbstractItemView.InternalMove) + self.listWidget.setObjectName(_fromUtf8("listWidget")) + self.verticalLayout.addWidget(self.listWidget) - self.retranslateUi(NodeNamesEditor) - QtCore.QObject.connect(self.addButton, QtCore.SIGNAL(_fromUtf8("clicked()")), NodeNamesEditor.onAddItem) - QtCore.QObject.connect(self.removeButton, QtCore.SIGNAL(_fromUtf8("clicked()")), NodeNamesEditor.onRemoveItem) - QtCore.QObject.connect(self.listWidget, QtCore.SIGNAL(_fromUtf8("itemSelectionChanged()")), NodeNamesEditor.onSelectionChanged) - QtCore.QObject.connect(self.name_lineEdit, QtCore.SIGNAL(_fromUtf8("editingFinished()")), NodeNamesEditor.onRenameItem) - QtCore.QMetaObject.connectSlotsByName(NodeNamesEditor) + self.retranslateUi(NodeNamesEditor) + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.connect(self.addButton, QtCore.SIGNAL(_fromUtf8("clicked()")), NodeNamesEditor.onAddItem) + QtCore.QObject.connect(self.removeButton, QtCore.SIGNAL(_fromUtf8("clicked()")), NodeNamesEditor.onRemoveItem) + QtCore.QObject.connect(self.listWidget, QtCore.SIGNAL(_fromUtf8("itemSelectionChanged()")), NodeNamesEditor.onSelectionChanged) + QtCore.QObject.connect(self.name_lineEdit, QtCore.SIGNAL(_fromUtf8("editingFinished()")), NodeNamesEditor.onRenameItem) + else : + self.addButton.clicked.connect( NodeNamesEditor.onAddItem) + self.removeButton.clicked.connect( NodeNamesEditor.onRemoveItem) + self.listWidget.itemSelectionChanged.connect( NodeNamesEditor.onSelectionChanged) + self.name_lineEdit.editingFinished.connect( NodeNamesEditor.onRenameItem) + QtCore.QMetaObject.connectSlotsByName(NodeNamesEditor) - def retranslateUi(self, NodeNamesEditor): - NodeNamesEditor.setWindowTitle(QtGui.QApplication.translate("NodeNamesEditor", "Form", None, QtGui.QApplication.UnicodeUTF8)) - self.addButton.setToolTip(QtGui.QApplication.translate("NodeNamesEditor", "Add", None, QtGui.QApplication.UnicodeUTF8)) - self.addButton.setText(QtGui.QApplication.translate("NodeNamesEditor", "...", None, QtGui.QApplication.UnicodeUTF8)) - self.removeButton.setToolTip(QtGui.QApplication.translate("NodeNamesEditor", "Remove", None, QtGui.QApplication.UnicodeUTF8)) - self.removeButton.setText(QtGui.QApplication.translate("NodeNamesEditor", "...", None, QtGui.QApplication.UnicodeUTF8)) + def retranslateUi(self, NodeNamesEditor): + NodeNamesEditor.setWindowTitle(QtGui.QApplication.translate("NodeNamesEditor", "Form", None)) + self.addButton.setToolTip(QtGui.QApplication.translate("NodeNamesEditor", "Add", None)) + self.addButton.setText(QtGui.QApplication.translate("NodeNamesEditor", "...", None)) + self.removeButton.setToolTip(QtGui.QApplication.translate("NodeNamesEditor", "Remove", None)) + self.removeButton.setText(QtGui.QApplication.translate("NodeNamesEditor", "...", None)) import gui.resources_rc diff --git a/gui/nodeEditor/ui_nodeParamEditor.py b/gui/nodeEditor/ui_nodeParamEditor.py index ca9c965..d057640 100644 --- a/gui/nodeEditor/ui_nodeParamEditor.py +++ b/gui/nodeEditor/ui_nodeParamEditor.py @@ -9,185 +9,191 @@ from core.mePyQt import QtCore, QtGui +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + try: - _fromUtf8 = QtCore.QString.fromUtf8 + _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: - def _fromUtf8(s): - return s + def _fromUtf8(s): + return s try: - _encoding = QtGui.QApplication.UnicodeUTF8 - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig, _encoding) + _encoding = QtModule.QApplication.UnicodeUTF8 + def _translate(context, text, disambig): + return QtModule.QApplication.translate(context, text, disambig, _encoding) except AttributeError: - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig) + def _translate(context, text, disambig): + return QtModule.QApplication.translate(context, text, disambig) class Ui_NodeParamEditor(object): - def setupUi(self, NodeParamEditor): - NodeParamEditor.setObjectName(_fromUtf8("NodeParamEditor")) - NodeParamEditor.resize(646, 773) - self.verticalLayout = QtGui.QVBoxLayout(NodeParamEditor) - self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) - self.horizontalLayout_2 = QtGui.QHBoxLayout() - self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) - self.name_label = QtGui.QLabel(NodeParamEditor) - self.name_label.setMinimumSize(QtCore.QSize(100, 0)) - self.name_label.setObjectName(_fromUtf8("name_label")) - self.horizontalLayout_2.addWidget(self.name_label) - self.name_lineEdit = QtGui.QLineEdit(NodeParamEditor) - self.name_lineEdit.setObjectName(_fromUtf8("name_lineEdit")) - self.horizontalLayout_2.addWidget(self.name_lineEdit) - self.horizontalLayout_2.setStretch(1, 1) - self.verticalLayout.addLayout(self.horizontalLayout_2) - self.horizontalLayout_3 = QtGui.QHBoxLayout() - self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3")) - self.label_label = QtGui.QLabel(NodeParamEditor) - self.label_label.setMinimumSize(QtCore.QSize(100, 0)) - self.label_label.setObjectName(_fromUtf8("label_label")) - self.horizontalLayout_3.addWidget(self.label_label) - self.label_lineEdit = QtGui.QLineEdit(NodeParamEditor) - self.label_lineEdit.setObjectName(_fromUtf8("label_lineEdit")) - self.horizontalLayout_3.addWidget(self.label_lineEdit) - self.horizontalLayout_3.setStretch(1, 1) - self.verticalLayout.addLayout(self.horizontalLayout_3) - self.horizontalLayout_12 = QtGui.QHBoxLayout() - self.horizontalLayout_12.setObjectName(_fromUtf8("horizontalLayout_12")) - self.enabled_label = QtGui.QLabel(NodeParamEditor) - self.enabled_label.setMinimumSize(QtCore.QSize(100, 0)) - self.enabled_label.setObjectName(_fromUtf8("enabled_label")) - self.horizontalLayout_12.addWidget(self.enabled_label) - self.check_enabled = QtGui.QCheckBox(NodeParamEditor) - self.check_enabled.setText(_fromUtf8("")) - self.check_enabled.setObjectName(_fromUtf8("check_enabled")) - self.horizontalLayout_12.addWidget(self.check_enabled) - spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout_12.addItem(spacerItem) - self.verticalLayout.addLayout(self.horizontalLayout_12) - self.horizontalLayout_5 = QtGui.QHBoxLayout() - self.horizontalLayout_5.setObjectName(_fromUtf8("horizontalLayout_5")) - self.display_label = QtGui.QLabel(NodeParamEditor) - self.display_label.setMinimumSize(QtCore.QSize(100, 0)) - self.display_label.setObjectName(_fromUtf8("display_label")) - self.horizontalLayout_5.addWidget(self.display_label) - self.check_display = QtGui.QCheckBox(NodeParamEditor) - self.check_display.setText(_fromUtf8("")) - self.check_display.setObjectName(_fromUtf8("check_display")) - self.horizontalLayout_5.addWidget(self.check_display) - spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout_5.addItem(spacerItem1) - self.verticalLayout.addLayout(self.horizontalLayout_5) - self.horizontalLayout_6 = QtGui.QHBoxLayout() - self.horizontalLayout_6.setObjectName(_fromUtf8("horizontalLayout_6")) - self.shader_label = QtGui.QLabel(NodeParamEditor) - self.shader_label.setMinimumSize(QtCore.QSize(100, 0)) - self.shader_label.setObjectName(_fromUtf8("shader_label")) - self.horizontalLayout_6.addWidget(self.shader_label) - self.check_shader = QtGui.QCheckBox(NodeParamEditor) - self.check_shader.setText(_fromUtf8("")) - self.check_shader.setObjectName(_fromUtf8("check_shader")) - self.horizontalLayout_6.addWidget(self.check_shader) - spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout_6.addItem(spacerItem2) - self.verticalLayout.addLayout(self.horizontalLayout_6) - self.horizontalLayout_7 = QtGui.QHBoxLayout() - self.horizontalLayout_7.setObjectName(_fromUtf8("horizontalLayout_7")) - self.type_label = QtGui.QLabel(NodeParamEditor) - self.type_label.setMinimumSize(QtCore.QSize(100, 0)) - self.type_label.setObjectName(_fromUtf8("type_label")) - self.horizontalLayout_7.addWidget(self.type_label) - self.type_comboBox = QtGui.QComboBox(NodeParamEditor) - self.type_comboBox.setMinimumSize(QtCore.QSize(100, 0)) - self.type_comboBox.setObjectName(_fromUtf8("type_comboBox")) - self.horizontalLayout_7.addWidget(self.type_comboBox) - spacerItem3 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout_7.addItem(spacerItem3) - self.verticalLayout.addLayout(self.horizontalLayout_7) - self.horizontalLayout_8 = QtGui.QHBoxLayout() - self.horizontalLayout_8.setObjectName(_fromUtf8("horizontalLayout_8")) - self.detail_label = QtGui.QLabel(NodeParamEditor) - self.detail_label.setMinimumSize(QtCore.QSize(100, 0)) - self.detail_label.setObjectName(_fromUtf8("detail_label")) - self.horizontalLayout_8.addWidget(self.detail_label) - self.detail_comboBox = QtGui.QComboBox(NodeParamEditor) - self.detail_comboBox.setMinimumSize(QtCore.QSize(100, 0)) - self.detail_comboBox.setObjectName(_fromUtf8("detail_comboBox")) - self.horizontalLayout_8.addWidget(self.detail_comboBox) - spacerItem4 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout_8.addItem(spacerItem4) - self.verticalLayout.addLayout(self.horizontalLayout_8) - self.horizontalLayout_11 = QtGui.QHBoxLayout() - self.horizontalLayout_11.setObjectName(_fromUtf8("horizontalLayout_11")) - self.provider_label_2 = QtGui.QLabel(NodeParamEditor) - self.provider_label_2.setMinimumSize(QtCore.QSize(100, 0)) - self.provider_label_2.setObjectName(_fromUtf8("provider_label_2")) - self.horizontalLayout_11.addWidget(self.provider_label_2) - self.provider_comboBox = QtGui.QComboBox(NodeParamEditor) - self.provider_comboBox.setMinimumSize(QtCore.QSize(100, 0)) - self.provider_comboBox.setObjectName(_fromUtf8("provider_comboBox")) - self.horizontalLayout_11.addWidget(self.provider_comboBox) - spacerItem5 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout_11.addItem(spacerItem5) - self.verticalLayout.addLayout(self.horizontalLayout_11) - self.horizontalLayout_9 = QtGui.QHBoxLayout() - self.horizontalLayout_9.setObjectName(_fromUtf8("horizontalLayout_9")) - self.subtype_label = QtGui.QLabel(NodeParamEditor) - self.subtype_label.setMinimumSize(QtCore.QSize(100, 0)) - self.subtype_label.setObjectName(_fromUtf8("subtype_label")) - self.horizontalLayout_9.addWidget(self.subtype_label) - self.subtype_comboBox = QtGui.QComboBox(NodeParamEditor) - self.subtype_comboBox.setMinimumSize(QtCore.QSize(100, 0)) - self.subtype_comboBox.setObjectName(_fromUtf8("subtype_comboBox")) - self.horizontalLayout_9.addWidget(self.subtype_comboBox) - spacerItem6 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout_9.addItem(spacerItem6) - self.verticalLayout.addLayout(self.horizontalLayout_9) - self.horizontalLayout_10 = QtGui.QHBoxLayout() - self.horizontalLayout_10.setObjectName(_fromUtf8("horizontalLayout_10")) - self.range_label = QtGui.QLabel(NodeParamEditor) - self.range_label.setMinimumSize(QtCore.QSize(100, 0)) - self.range_label.setObjectName(_fromUtf8("range_label")) - self.horizontalLayout_10.addWidget(self.range_label) - self.range_lineEdit = QtGui.QLineEdit(NodeParamEditor) - self.range_lineEdit.setObjectName(_fromUtf8("range_lineEdit")) - self.horizontalLayout_10.addWidget(self.range_lineEdit) - self.horizontalLayout_10.setStretch(1, 1) - self.verticalLayout.addLayout(self.horizontalLayout_10) - self.value_stackedWidget = QtGui.QStackedWidget(NodeParamEditor) - self.value_stackedWidget.setObjectName(_fromUtf8("value_stackedWidget")) - self.value_stackedWidgetPage1 = QtGui.QWidget() - self.value_stackedWidgetPage1.setObjectName(_fromUtf8("value_stackedWidgetPage1")) - self.value_stackedWidget.addWidget(self.value_stackedWidgetPage1) - self.verticalLayout.addWidget(self.value_stackedWidget) - spacerItem7 = QtGui.QSpacerItem(20, 0, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.verticalLayout.addItem(spacerItem7) - self.horizontalLayout_4 = QtGui.QHBoxLayout() - self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4")) - self.descr_label = QtGui.QLabel(NodeParamEditor) - self.descr_label.setMinimumSize(QtCore.QSize(100, 0)) - self.descr_label.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) - self.descr_label.setObjectName(_fromUtf8("descr_label")) - self.horizontalLayout_4.addWidget(self.descr_label) - self.descr_plainTextEdit = QtGui.QPlainTextEdit(NodeParamEditor) - self.descr_plainTextEdit.setMinimumSize(QtCore.QSize(0, 60)) - self.descr_plainTextEdit.setObjectName(_fromUtf8("descr_plainTextEdit")) - self.horizontalLayout_4.addWidget(self.descr_plainTextEdit) - self.verticalLayout.addLayout(self.horizontalLayout_4) + def setupUi(self, NodeParamEditor): + NodeParamEditor.setObjectName(_fromUtf8("NodeParamEditor")) + NodeParamEditor.resize(646, 773) + self.verticalLayout = QtModule.QVBoxLayout(NodeParamEditor) + self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + self.horizontalLayout_2 = QtModule.QHBoxLayout() + self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) + self.name_label = QtModule.QLabel(NodeParamEditor) + self.name_label.setMinimumSize(QtCore.QSize(100, 0)) + self.name_label.setObjectName(_fromUtf8("name_label")) + self.horizontalLayout_2.addWidget(self.name_label) + self.name_lineEdit = QtModule.QLineEdit(NodeParamEditor) + self.name_lineEdit.setObjectName(_fromUtf8("name_lineEdit")) + self.horizontalLayout_2.addWidget(self.name_lineEdit) + self.horizontalLayout_2.setStretch(1, 1) + self.verticalLayout.addLayout(self.horizontalLayout_2) + self.horizontalLayout_3 = QtModule.QHBoxLayout() + self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3")) + self.label_label = QtModule.QLabel(NodeParamEditor) + self.label_label.setMinimumSize(QtCore.QSize(100, 0)) + self.label_label.setObjectName(_fromUtf8("label_label")) + self.horizontalLayout_3.addWidget(self.label_label) + self.label_lineEdit = QtModule.QLineEdit(NodeParamEditor) + self.label_lineEdit.setObjectName(_fromUtf8("label_lineEdit")) + self.horizontalLayout_3.addWidget(self.label_lineEdit) + self.horizontalLayout_3.setStretch(1, 1) + self.verticalLayout.addLayout(self.horizontalLayout_3) + self.horizontalLayout_12 = QtModule.QHBoxLayout() + self.horizontalLayout_12.setObjectName(_fromUtf8("horizontalLayout_12")) + self.enabled_label = QtModule.QLabel(NodeParamEditor) + self.enabled_label.setMinimumSize(QtCore.QSize(100, 0)) + self.enabled_label.setObjectName(_fromUtf8("enabled_label")) + self.horizontalLayout_12.addWidget(self.enabled_label) + self.check_enabled = QtModule.QCheckBox(NodeParamEditor) + self.check_enabled.setText(_fromUtf8("")) + self.check_enabled.setObjectName(_fromUtf8("check_enabled")) + self.horizontalLayout_12.addWidget(self.check_enabled) + spacerItem = QtModule.QSpacerItem(40, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) + self.horizontalLayout_12.addItem(spacerItem) + self.verticalLayout.addLayout(self.horizontalLayout_12) + self.horizontalLayout_5 = QtModule.QHBoxLayout() + self.horizontalLayout_5.setObjectName(_fromUtf8("horizontalLayout_5")) + self.display_label = QtModule.QLabel(NodeParamEditor) + self.display_label.setMinimumSize(QtCore.QSize(100, 0)) + self.display_label.setObjectName(_fromUtf8("display_label")) + self.horizontalLayout_5.addWidget(self.display_label) + self.check_display = QtModule.QCheckBox(NodeParamEditor) + self.check_display.setText(_fromUtf8("")) + self.check_display.setObjectName(_fromUtf8("check_display")) + self.horizontalLayout_5.addWidget(self.check_display) + spacerItem1 = QtModule.QSpacerItem(40, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) + self.horizontalLayout_5.addItem(spacerItem1) + self.verticalLayout.addLayout(self.horizontalLayout_5) + self.horizontalLayout_6 = QtModule.QHBoxLayout() + self.horizontalLayout_6.setObjectName(_fromUtf8("horizontalLayout_6")) + self.shader_label = QtModule.QLabel(NodeParamEditor) + self.shader_label.setMinimumSize(QtCore.QSize(100, 0)) + self.shader_label.setObjectName(_fromUtf8("shader_label")) + self.horizontalLayout_6.addWidget(self.shader_label) + self.check_shader = QtModule.QCheckBox(NodeParamEditor) + self.check_shader.setText(_fromUtf8("")) + self.check_shader.setObjectName(_fromUtf8("check_shader")) + self.horizontalLayout_6.addWidget(self.check_shader) + spacerItem2 = QtModule.QSpacerItem(40, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) + self.horizontalLayout_6.addItem(spacerItem2) + self.verticalLayout.addLayout(self.horizontalLayout_6) + self.horizontalLayout_7 = QtModule.QHBoxLayout() + self.horizontalLayout_7.setObjectName(_fromUtf8("horizontalLayout_7")) + self.type_label = QtModule.QLabel(NodeParamEditor) + self.type_label.setMinimumSize(QtCore.QSize(100, 0)) + self.type_label.setObjectName(_fromUtf8("type_label")) + self.horizontalLayout_7.addWidget(self.type_label) + self.type_comboBox = QtModule.QComboBox(NodeParamEditor) + self.type_comboBox.setMinimumSize(QtCore.QSize(100, 0)) + self.type_comboBox.setObjectName(_fromUtf8("type_comboBox")) + self.horizontalLayout_7.addWidget(self.type_comboBox) + spacerItem3 = QtModule.QSpacerItem(40, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) + self.horizontalLayout_7.addItem(spacerItem3) + self.verticalLayout.addLayout(self.horizontalLayout_7) + self.horizontalLayout_8 = QtModule.QHBoxLayout() + self.horizontalLayout_8.setObjectName(_fromUtf8("horizontalLayout_8")) + self.detail_label = QtModule.QLabel(NodeParamEditor) + self.detail_label.setMinimumSize(QtCore.QSize(100, 0)) + self.detail_label.setObjectName(_fromUtf8("detail_label")) + self.horizontalLayout_8.addWidget(self.detail_label) + self.detail_comboBox = QtModule.QComboBox(NodeParamEditor) + self.detail_comboBox.setMinimumSize(QtCore.QSize(100, 0)) + self.detail_comboBox.setObjectName(_fromUtf8("detail_comboBox")) + self.horizontalLayout_8.addWidget(self.detail_comboBox) + spacerItem4 = QtModule.QSpacerItem(40, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) + self.horizontalLayout_8.addItem(spacerItem4) + self.verticalLayout.addLayout(self.horizontalLayout_8) + self.horizontalLayout_11 = QtModule.QHBoxLayout() + self.horizontalLayout_11.setObjectName(_fromUtf8("horizontalLayout_11")) + self.provider_label_2 = QtModule.QLabel(NodeParamEditor) + self.provider_label_2.setMinimumSize(QtCore.QSize(100, 0)) + self.provider_label_2.setObjectName(_fromUtf8("provider_label_2")) + self.horizontalLayout_11.addWidget(self.provider_label_2) + self.provider_comboBox = QtModule.QComboBox(NodeParamEditor) + self.provider_comboBox.setMinimumSize(QtCore.QSize(100, 0)) + self.provider_comboBox.setObjectName(_fromUtf8("provider_comboBox")) + self.horizontalLayout_11.addWidget(self.provider_comboBox) + spacerItem5 = QtModule.QSpacerItem(40, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) + self.horizontalLayout_11.addItem(spacerItem5) + self.verticalLayout.addLayout(self.horizontalLayout_11) + self.horizontalLayout_9 = QtModule.QHBoxLayout() + self.horizontalLayout_9.setObjectName(_fromUtf8("horizontalLayout_9")) + self.subtype_label = QtModule.QLabel(NodeParamEditor) + self.subtype_label.setMinimumSize(QtCore.QSize(100, 0)) + self.subtype_label.setObjectName(_fromUtf8("subtype_label")) + self.horizontalLayout_9.addWidget(self.subtype_label) + self.subtype_comboBox = QtModule.QComboBox(NodeParamEditor) + self.subtype_comboBox.setMinimumSize(QtCore.QSize(100, 0)) + self.subtype_comboBox.setObjectName(_fromUtf8("subtype_comboBox")) + self.horizontalLayout_9.addWidget(self.subtype_comboBox) + spacerItem6 = QtModule.QSpacerItem(40, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) + self.horizontalLayout_9.addItem(spacerItem6) + self.verticalLayout.addLayout(self.horizontalLayout_9) + self.horizontalLayout_10 = QtModule.QHBoxLayout() + self.horizontalLayout_10.setObjectName(_fromUtf8("horizontalLayout_10")) + self.range_label = QtModule.QLabel(NodeParamEditor) + self.range_label.setMinimumSize(QtCore.QSize(100, 0)) + self.range_label.setObjectName(_fromUtf8("range_label")) + self.horizontalLayout_10.addWidget(self.range_label) + self.range_lineEdit = QtModule.QLineEdit(NodeParamEditor) + self.range_lineEdit.setObjectName(_fromUtf8("range_lineEdit")) + self.horizontalLayout_10.addWidget(self.range_lineEdit) + self.horizontalLayout_10.setStretch(1, 1) + self.verticalLayout.addLayout(self.horizontalLayout_10) + self.value_stackedWidget = QtModule.QStackedWidget(NodeParamEditor) + self.value_stackedWidget.setObjectName(_fromUtf8("value_stackedWidget")) + self.value_stackedWidgetPage1 = QtModule.QWidget() + self.value_stackedWidgetPage1.setObjectName(_fromUtf8("value_stackedWidgetPage1")) + self.value_stackedWidget.addWidget(self.value_stackedWidgetPage1) + self.verticalLayout.addWidget(self.value_stackedWidget) + spacerItem7 = QtModule.QSpacerItem(20, 0, QtModule.QSizePolicy.Minimum, QtModule.QSizePolicy.Expanding) + self.verticalLayout.addItem(spacerItem7) + self.horizontalLayout_4 = QtModule.QHBoxLayout() + self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4")) + self.descr_label = QtModule.QLabel(NodeParamEditor) + self.descr_label.setMinimumSize(QtCore.QSize(100, 0)) + self.descr_label.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) + self.descr_label.setObjectName(_fromUtf8("descr_label")) + self.horizontalLayout_4.addWidget(self.descr_label) + self.descr_plainTextEdit = QtModule.QPlainTextEdit(NodeParamEditor) + self.descr_plainTextEdit.setMinimumSize(QtCore.QSize(0, 60)) + self.descr_plainTextEdit.setObjectName(_fromUtf8("descr_plainTextEdit")) + self.horizontalLayout_4.addWidget(self.descr_plainTextEdit) + self.verticalLayout.addLayout(self.horizontalLayout_4) - self.retranslateUi(NodeParamEditor) - QtCore.QMetaObject.connectSlotsByName(NodeParamEditor) + self.retranslateUi(NodeParamEditor) + QtCore.QMetaObject.connectSlotsByName(NodeParamEditor) - def retranslateUi(self, NodeParamEditor): - NodeParamEditor.setWindowTitle(_translate("NodeParamEditor", "Form", None)) - self.name_label.setText(_translate("NodeParamEditor", "Name", None)) - self.label_label.setText(_translate("NodeParamEditor", "Label", None)) - self.enabled_label.setText(_translate("NodeParamEditor", "Enabled", None)) - self.display_label.setText(_translate("NodeParamEditor", "Display", None)) - self.shader_label.setText(_translate("NodeParamEditor", "Use in Shader", None)) - self.type_label.setText(_translate("NodeParamEditor", "Type", None)) - self.detail_label.setText(_translate("NodeParamEditor", "Detail", None)) - self.provider_label_2.setText(_translate("NodeParamEditor", "Provider", None)) - self.subtype_label.setText(_translate("NodeParamEditor", "GUI Subtype", None)) - self.range_label.setText(_translate("NodeParamEditor", "Range", None)) - self.descr_label.setText(_translate("NodeParamEditor", "Description", None)) + def retranslateUi(self, NodeParamEditor): + NodeParamEditor.setWindowTitle(_translate("NodeParamEditor", "Form", None)) + self.name_label.setText(_translate("NodeParamEditor", "Name", None)) + self.label_label.setText(_translate("NodeParamEditor", "Label", None)) + self.enabled_label.setText(_translate("NodeParamEditor", "Enabled", None)) + self.display_label.setText(_translate("NodeParamEditor", "Display", None)) + self.shader_label.setText(_translate("NodeParamEditor", "Use in Shader", None)) + self.type_label.setText(_translate("NodeParamEditor", "Type", None)) + self.detail_label.setText(_translate("NodeParamEditor", "Detail", None)) + self.provider_label_2.setText(_translate("NodeParamEditor", "Provider", None)) + self.subtype_label.setText(_translate("NodeParamEditor", "GUI Subtype", None)) + self.range_label.setText(_translate("NodeParamEditor", "Range", None)) + self.descr_label.setText(_translate("NodeParamEditor", "Description", None)) diff --git a/gui/nodeEditor/ui_nodePropertiesEditor.py b/gui/nodeEditor/ui_nodePropertiesEditor.py index 135ac38..1133208 100644 --- a/gui/nodeEditor/ui_nodePropertiesEditor.py +++ b/gui/nodeEditor/ui_nodePropertiesEditor.py @@ -9,138 +9,144 @@ from core.mePyQt import QtCore, QtGui +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + try: - _fromUtf8 = QtCore.QString.fromUtf8 + _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: - def _fromUtf8(s): - return s + def _fromUtf8(s): + return s try: - _encoding = QtGui.QApplication.UnicodeUTF8 - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig, _encoding) + _encoding = QtModule.QApplication.UnicodeUTF8 + def _translate(context, text, disambig): + return QtModule.QApplication.translate(context, text, disambig, _encoding) except AttributeError: - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig) + def _translate(context, text, disambig): + return QtModule.QApplication.translate(context, text, disambig) class Ui_NodePropertiesEditor(object): - def setupUi(self, NodePropertiesEditor): - NodePropertiesEditor.setObjectName(_fromUtf8("NodePropertiesEditor")) - NodePropertiesEditor.resize(448, 498) - self.verticalLayout = QtGui.QVBoxLayout(NodePropertiesEditor) - self.verticalLayout.setSpacing(2) - self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) - self.horizontalLayout_2 = QtGui.QHBoxLayout() - self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) - self.name_label = QtGui.QLabel(NodePropertiesEditor) - self.name_label.setMinimumSize(QtCore.QSize(100, 0)) - self.name_label.setObjectName(_fromUtf8("name_label")) - self.horizontalLayout_2.addWidget(self.name_label) - self.name_lineEdit = QtGui.QLineEdit(NodePropertiesEditor) - self.name_lineEdit.setObjectName(_fromUtf8("name_lineEdit")) - self.horizontalLayout_2.addWidget(self.name_lineEdit) - self.horizontalLayout_2.setStretch(1, 1) - self.verticalLayout.addLayout(self.horizontalLayout_2) - self.horizontalLayout_3 = QtGui.QHBoxLayout() - self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3")) - self.label_label = QtGui.QLabel(NodePropertiesEditor) - self.label_label.setMinimumSize(QtCore.QSize(100, 0)) - self.label_label.setObjectName(_fromUtf8("label_label")) - self.horizontalLayout_3.addWidget(self.label_label) - self.label_lineEdit = QtGui.QLineEdit(NodePropertiesEditor) - self.label_lineEdit.setObjectName(_fromUtf8("label_lineEdit")) - self.horizontalLayout_3.addWidget(self.label_lineEdit) - self.horizontalLayout_3.setStretch(1, 1) - self.verticalLayout.addLayout(self.horizontalLayout_3) - self.horizontalLayout_7 = QtGui.QHBoxLayout() - self.horizontalLayout_7.setObjectName(_fromUtf8("horizontalLayout_7")) - self.type_label = QtGui.QLabel(NodePropertiesEditor) - self.type_label.setMinimumSize(QtCore.QSize(100, 0)) - self.type_label.setObjectName(_fromUtf8("type_label")) - self.horizontalLayout_7.addWidget(self.type_label) - self.type_comboBox = QtGui.QComboBox(NodePropertiesEditor) - self.type_comboBox.setMinimumSize(QtCore.QSize(100, 0)) - self.type_comboBox.setObjectName(_fromUtf8("type_comboBox")) - self.horizontalLayout_7.addWidget(self.type_comboBox) - spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout_7.addItem(spacerItem) - self.verticalLayout.addLayout(self.horizontalLayout_7) - self.horizontalLayout_5 = QtGui.QHBoxLayout() - self.horizontalLayout_5.setObjectName(_fromUtf8("horizontalLayout_5")) - self.author_label = QtGui.QLabel(NodePropertiesEditor) - self.author_label.setMinimumSize(QtCore.QSize(100, 0)) - self.author_label.setObjectName(_fromUtf8("author_label")) - self.horizontalLayout_5.addWidget(self.author_label) - self.author_lineEdit = QtGui.QLineEdit(NodePropertiesEditor) - self.author_lineEdit.setObjectName(_fromUtf8("author_lineEdit")) - self.horizontalLayout_5.addWidget(self.author_lineEdit) - self.horizontalLayout_5.setStretch(1, 1) - self.verticalLayout.addLayout(self.horizontalLayout_5) - self.horizontalLayout_6 = QtGui.QHBoxLayout() - self.horizontalLayout_6.setObjectName(_fromUtf8("horizontalLayout_6")) - self.icon_label = QtGui.QLabel(NodePropertiesEditor) - self.icon_label.setMinimumSize(QtCore.QSize(100, 0)) - self.icon_label.setObjectName(_fromUtf8("icon_label")) - self.horizontalLayout_6.addWidget(self.icon_label) - self.icon_lineEdit = QtGui.QLineEdit(NodePropertiesEditor) - self.icon_lineEdit.setObjectName(_fromUtf8("icon_lineEdit")) - self.horizontalLayout_6.addWidget(self.icon_lineEdit) - self.horizontalLayout_6.setStretch(1, 1) - self.verticalLayout.addLayout(self.horizontalLayout_6) - self.horizontalLayout_8 = QtGui.QHBoxLayout() - self.horizontalLayout_8.setObjectName(_fromUtf8("horizontalLayout_8")) - self.master_label = QtGui.QLabel(NodePropertiesEditor) - self.master_label.setMinimumSize(QtCore.QSize(100, 0)) - self.master_label.setObjectName(_fromUtf8("master_label")) - self.horizontalLayout_8.addWidget(self.master_label) - self.master_lineEdit = QtGui.QLineEdit(NodePropertiesEditor) - self.master_lineEdit.setObjectName(_fromUtf8("master_lineEdit")) - self.horizontalLayout_8.addWidget(self.master_lineEdit) - self.horizontalLayout_8.setStretch(1, 1) - self.verticalLayout.addLayout(self.horizontalLayout_8) - self.horizontalLayout_9 = QtGui.QHBoxLayout() - self.horizontalLayout_9.setObjectName(_fromUtf8("horizontalLayout_9")) - self.id_label = QtGui.QLabel(NodePropertiesEditor) - self.id_label.setEnabled(False) - self.id_label.setMinimumSize(QtCore.QSize(100, 0)) - self.id_label.setObjectName(_fromUtf8("id_label")) - self.horizontalLayout_9.addWidget(self.id_label) - self.id_lineEdit = QtGui.QLineEdit(NodePropertiesEditor) - self.id_lineEdit.setEnabled(False) - self.id_lineEdit.setMinimumSize(QtCore.QSize(60, 0)) - self.id_lineEdit.setMaximumSize(QtCore.QSize(60, 16777215)) - self.id_lineEdit.setObjectName(_fromUtf8("id_lineEdit")) - self.horizontalLayout_9.addWidget(self.id_lineEdit) - spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout_9.addItem(spacerItem1) - self.horizontalLayout_9.setStretch(2, 1) - self.verticalLayout.addLayout(self.horizontalLayout_9) - spacerItem2 = QtGui.QSpacerItem(20, 109, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.verticalLayout.addItem(spacerItem2) - self.horizontalLayout_4 = QtGui.QHBoxLayout() - self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4")) - self.help_label = QtGui.QLabel(NodePropertiesEditor) - self.help_label.setMinimumSize(QtCore.QSize(100, 0)) - self.help_label.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) - self.help_label.setObjectName(_fromUtf8("help_label")) - self.horizontalLayout_4.addWidget(self.help_label) - self.help_plainTextEdit = QtGui.QPlainTextEdit(NodePropertiesEditor) - self.help_plainTextEdit.setMinimumSize(QtCore.QSize(0, 60)) - self.help_plainTextEdit.setObjectName(_fromUtf8("help_plainTextEdit")) - self.horizontalLayout_4.addWidget(self.help_plainTextEdit) - self.verticalLayout.addLayout(self.horizontalLayout_4) + def setupUi(self, NodePropertiesEditor): + NodePropertiesEditor.setObjectName(_fromUtf8("NodePropertiesEditor")) + NodePropertiesEditor.resize(448, 498) + self.verticalLayout = QtModule.QVBoxLayout(NodePropertiesEditor) + self.verticalLayout.setSpacing(2) + self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + self.horizontalLayout_2 = QtModule.QHBoxLayout() + self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) + self.name_label = QtModule.QLabel(NodePropertiesEditor) + self.name_label.setMinimumSize(QtCore.QSize(100, 0)) + self.name_label.setObjectName(_fromUtf8("name_label")) + self.horizontalLayout_2.addWidget(self.name_label) + self.name_lineEdit = QtModule.QLineEdit(NodePropertiesEditor) + self.name_lineEdit.setObjectName(_fromUtf8("name_lineEdit")) + self.horizontalLayout_2.addWidget(self.name_lineEdit) + self.horizontalLayout_2.setStretch(1, 1) + self.verticalLayout.addLayout(self.horizontalLayout_2) + self.horizontalLayout_3 = QtModule.QHBoxLayout() + self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3")) + self.label_label = QtModule.QLabel(NodePropertiesEditor) + self.label_label.setMinimumSize(QtCore.QSize(100, 0)) + self.label_label.setObjectName(_fromUtf8("label_label")) + self.horizontalLayout_3.addWidget(self.label_label) + self.label_lineEdit = QtModule.QLineEdit(NodePropertiesEditor) + self.label_lineEdit.setObjectName(_fromUtf8("label_lineEdit")) + self.horizontalLayout_3.addWidget(self.label_lineEdit) + self.horizontalLayout_3.setStretch(1, 1) + self.verticalLayout.addLayout(self.horizontalLayout_3) + self.horizontalLayout_7 = QtModule.QHBoxLayout() + self.horizontalLayout_7.setObjectName(_fromUtf8("horizontalLayout_7")) + self.type_label = QtModule.QLabel(NodePropertiesEditor) + self.type_label.setMinimumSize(QtCore.QSize(100, 0)) + self.type_label.setObjectName(_fromUtf8("type_label")) + self.horizontalLayout_7.addWidget(self.type_label) + self.type_comboBox = QtModule.QComboBox(NodePropertiesEditor) + self.type_comboBox.setMinimumSize(QtCore.QSize(100, 0)) + self.type_comboBox.setObjectName(_fromUtf8("type_comboBox")) + self.horizontalLayout_7.addWidget(self.type_comboBox) + spacerItem = QtModule.QSpacerItem(40, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) + self.horizontalLayout_7.addItem(spacerItem) + self.verticalLayout.addLayout(self.horizontalLayout_7) + self.horizontalLayout_5 = QtModule.QHBoxLayout() + self.horizontalLayout_5.setObjectName(_fromUtf8("horizontalLayout_5")) + self.author_label = QtModule.QLabel(NodePropertiesEditor) + self.author_label.setMinimumSize(QtCore.QSize(100, 0)) + self.author_label.setObjectName(_fromUtf8("author_label")) + self.horizontalLayout_5.addWidget(self.author_label) + self.author_lineEdit = QtModule.QLineEdit(NodePropertiesEditor) + self.author_lineEdit.setObjectName(_fromUtf8("author_lineEdit")) + self.horizontalLayout_5.addWidget(self.author_lineEdit) + self.horizontalLayout_5.setStretch(1, 1) + self.verticalLayout.addLayout(self.horizontalLayout_5) + self.horizontalLayout_6 = QtModule.QHBoxLayout() + self.horizontalLayout_6.setObjectName(_fromUtf8("horizontalLayout_6")) + self.icon_label = QtModule.QLabel(NodePropertiesEditor) + self.icon_label.setMinimumSize(QtCore.QSize(100, 0)) + self.icon_label.setObjectName(_fromUtf8("icon_label")) + self.horizontalLayout_6.addWidget(self.icon_label) + self.icon_lineEdit = QtModule.QLineEdit(NodePropertiesEditor) + self.icon_lineEdit.setObjectName(_fromUtf8("icon_lineEdit")) + self.horizontalLayout_6.addWidget(self.icon_lineEdit) + self.horizontalLayout_6.setStretch(1, 1) + self.verticalLayout.addLayout(self.horizontalLayout_6) + self.horizontalLayout_8 = QtModule.QHBoxLayout() + self.horizontalLayout_8.setObjectName(_fromUtf8("horizontalLayout_8")) + self.master_label = QtModule.QLabel(NodePropertiesEditor) + self.master_label.setMinimumSize(QtCore.QSize(100, 0)) + self.master_label.setObjectName(_fromUtf8("master_label")) + self.horizontalLayout_8.addWidget(self.master_label) + self.master_lineEdit = QtModule.QLineEdit(NodePropertiesEditor) + self.master_lineEdit.setObjectName(_fromUtf8("master_lineEdit")) + self.horizontalLayout_8.addWidget(self.master_lineEdit) + self.horizontalLayout_8.setStretch(1, 1) + self.verticalLayout.addLayout(self.horizontalLayout_8) + self.horizontalLayout_9 = QtModule.QHBoxLayout() + self.horizontalLayout_9.setObjectName(_fromUtf8("horizontalLayout_9")) + self.id_label = QtModule.QLabel(NodePropertiesEditor) + self.id_label.setEnabled(False) + self.id_label.setMinimumSize(QtCore.QSize(100, 0)) + self.id_label.setObjectName(_fromUtf8("id_label")) + self.horizontalLayout_9.addWidget(self.id_label) + self.id_lineEdit = QtModule.QLineEdit(NodePropertiesEditor) + self.id_lineEdit.setEnabled(False) + self.id_lineEdit.setMinimumSize(QtCore.QSize(60, 0)) + self.id_lineEdit.setMaximumSize(QtCore.QSize(60, 16777215)) + self.id_lineEdit.setObjectName(_fromUtf8("id_lineEdit")) + self.horizontalLayout_9.addWidget(self.id_lineEdit) + spacerItem1 = QtModule.QSpacerItem(40, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) + self.horizontalLayout_9.addItem(spacerItem1) + self.horizontalLayout_9.setStretch(2, 1) + self.verticalLayout.addLayout(self.horizontalLayout_9) + spacerItem2 = QtModule.QSpacerItem(20, 109, QtModule.QSizePolicy.Minimum, QtModule.QSizePolicy.Expanding) + self.verticalLayout.addItem(spacerItem2) + self.horizontalLayout_4 = QtModule.QHBoxLayout() + self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4")) + self.help_label = QtModule.QLabel(NodePropertiesEditor) + self.help_label.setMinimumSize(QtCore.QSize(100, 0)) + self.help_label.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) + self.help_label.setObjectName(_fromUtf8("help_label")) + self.horizontalLayout_4.addWidget(self.help_label) + self.help_plainTextEdit = QtModule.QPlainTextEdit(NodePropertiesEditor) + self.help_plainTextEdit.setMinimumSize(QtCore.QSize(0, 60)) + self.help_plainTextEdit.setObjectName(_fromUtf8("help_plainTextEdit")) + self.horizontalLayout_4.addWidget(self.help_plainTextEdit) + self.verticalLayout.addLayout(self.horizontalLayout_4) - self.retranslateUi(NodePropertiesEditor) - QtCore.QMetaObject.connectSlotsByName(NodePropertiesEditor) + self.retranslateUi(NodePropertiesEditor) + QtCore.QMetaObject.connectSlotsByName(NodePropertiesEditor) - def retranslateUi(self, NodePropertiesEditor): - NodePropertiesEditor.setWindowTitle(_translate("NodePropertiesEditor", "NodeEditor", None)) - self.name_label.setText(_translate("NodePropertiesEditor", "Name", None)) - self.label_label.setText(_translate("NodePropertiesEditor", "Label", None)) - self.type_label.setText(_translate("NodePropertiesEditor", "Type", None)) - self.author_label.setText(_translate("NodePropertiesEditor", "Author", None)) - self.icon_label.setText(_translate("NodePropertiesEditor", "Icon", None)) - self.master_label.setText(_translate("NodePropertiesEditor", "Master", None)) - self.id_label.setText(_translate("NodePropertiesEditor", "Node ID", None)) - self.help_label.setText(_translate("NodePropertiesEditor", "Description", None)) + def retranslateUi(self, NodePropertiesEditor): + NodePropertiesEditor.setWindowTitle(_translate("NodePropertiesEditor", "NodeEditor", None)) + self.name_label.setText(_translate("NodePropertiesEditor", "Name", None)) + self.label_label.setText(_translate("NodePropertiesEditor", "Label", None)) + self.type_label.setText(_translate("NodePropertiesEditor", "Type", None)) + self.author_label.setText(_translate("NodePropertiesEditor", "Author", None)) + self.icon_label.setText(_translate("NodePropertiesEditor", "Icon", None)) + self.master_label.setText(_translate("NodePropertiesEditor", "Master", None)) + self.id_label.setText(_translate("NodePropertiesEditor", "Node ID", None)) + self.help_label.setText(_translate("NodePropertiesEditor", "Description", None)) diff --git a/gui/nodeList.py b/gui/nodeList.py index 232d589..b7a5793 100644 --- a/gui/nodeList.py +++ b/gui/nodeList.py @@ -26,28 +26,38 @@ # class NodeList ( QtModule.QWidget ) : # + # Define signals for PyQt5 + # + if QtCore.QT_VERSION >= 50000 : + setActiveNodeList = QtCore.pyqtSignal ( [QtModule.QWidget] ) + addNode = QtCore.pyqtSignal ( [str] ) + # # __init__ # def __init__ ( self, parent ) : # QtModule.QWidget.__init__ ( self, parent ) - + self.nodesLib = '' self.nodesDir = '' # This is always the same - self.ui=Ui_nodeList () + self.ui = Ui_nodeList () self.ui.setupUi ( self ) - self.ui.treeView.setDragEnabled ( True ) #self.ui.treeView.setRootIsDecorated( True ) - + self.connectSignals () + self.updateGui () + # + # connectSignals + # + def connectSignals ( self ) : + # if QtCore.QT_VERSION < 50000 : QtCore.QObject.connect ( self.ui.treeView, QtCore.SIGNAL ( "pressed(QModelIndex)" ), self.clicked ) QtCore.QObject.connect ( self.ui.treeView, QtCore.SIGNAL ( "doubleClicked(QModelIndex)" ), self.doubleClicked ) else : - print ( '!!! NodeList connect!!!! solve it ' ) - - self.updateGui () + self.ui.treeView.pressed.connect ( self.clicked ) + self.ui.treeView.doubleClicked.connect ( self.doubleClicked ) # # updateGui # @@ -88,7 +98,10 @@ def clicked ( self, index ) : # send signal to MainWindow to help distinguish which nodeList # is active for addNode getNode events # - self.emit ( QtCore.SIGNAL ( "setActiveNodeList" ), self ) + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( "setActiveNodeList" ), self ) + else : + self.setActiveNodeList.emit ( self ) # # doubleClicked # @@ -98,8 +111,12 @@ def doubleClicked ( self, index ) : nodeKind = item.whatsThis () if nodeKind != 'folder' : - nodeFilename = item.data ( QtCore.Qt.UserRole + 4 ).toString () - self.emit ( QtCore.SIGNAL ( 'addNode' ), nodeFilename ) + if QtCore.QT_VERSION < 50000 : + nodeFilename = item.data ( QtCore.Qt.UserRole + 4 ).toString () + self.emit ( QtCore.SIGNAL ( 'addNode' ), nodeFilename ) + else : + nodeFilename = item.data ( QtCore.Qt.UserRole + 4 ) + self.addNode.emit ( nodeFilename ) # # showDescription # @@ -109,11 +126,18 @@ def showDescription ( self, item ) : nodeName = item.text () nodeKind = item.whatsThis () - nodeAuthor = item.data ( QtCore.Qt.UserRole + 1 ).toString () - nodeType = item.data ( QtCore.Qt.UserRole + 2 ).toString () - nodeHelp = item.data ( QtCore.Qt.UserRole + 3 ).toString () - nodeFilename = item.data ( QtCore.Qt.UserRole + 4 ).toString () - nodeIcon = item.data ( QtCore.Qt.UserRole + 5 ).toString () + if QtCore.QT_VERSION < 50000 : + nodeAuthor = item.data ( QtCore.Qt.UserRole + 1 ).toString () + nodeType = item.data ( QtCore.Qt.UserRole + 2 ).toString () + nodeHelp = item.data ( QtCore.Qt.UserRole + 3 ).toString () + nodeFilename = item.data ( QtCore.Qt.UserRole + 4 ).toString () + nodeIcon = item.data ( QtCore.Qt.UserRole + 5 ).toString () + else : + nodeAuthor = item.data ( QtCore.Qt.UserRole + 1 ) + nodeType = item.data ( QtCore.Qt.UserRole + 2 ) + nodeHelp = item.data ( QtCore.Qt.UserRole + 3 ) + nodeFilename = item.data ( QtCore.Qt.UserRole + 4 ) + nodeIcon = item.data ( QtCore.Qt.UserRole + 5 ) self.ui.infoText.clear () diff --git a/gui/nodeParamList.py b/gui/nodeParamList.py index 18d9446..ef9d317 100644 --- a/gui/nodeParamList.py +++ b/gui/nodeParamList.py @@ -4,7 +4,7 @@ """ from core.mePyQt import QtCore, QtGui - +from core.signal import Signal #from PyQt4.QtCore import QDir, QString, QModelIndex #from PyQt4.QtGui import QFileSystemModel #from PyQt4.QtGui import QFileIconProvider @@ -39,6 +39,12 @@ # class NodeParamListTab ( QtModule.QWidget ) : # + # Define signals for PyQt5 + # + if QtCore.QT_VERSION >= 50000 : + # + sectionResized = QtCore.pyqtSignal ( int,int,int ) + # # __init__ # def __init__ ( self, parent, gfxNode = None, isInput = True, showConnected = False ) : @@ -65,6 +71,8 @@ def connectSignals ( self ) : # if QtCore.QT_VERSION < 50000 : self.connect ( self.paramHeader, QtCore.SIGNAL ( 'sectionResized(int,int,int)' ), self.onSectionResized ) + else : + self.paramHeader.sectionResized.connect ( self.onSectionResized ) # # onSectionResized # @@ -231,9 +239,10 @@ def buildGui ( self ) : #if DEBUG_MODE : print '>> NodeParamList.buildGui' self.paramListLayout = QtModule.QGridLayout () - self.paramListLayout.setSizeConstraint ( QtGui.QLayout.SetNoConstraint ) + self.paramListLayout.setSizeConstraint ( QtModule.QLayout.SetNoConstraint ) self.paramListLayout.setSpacing ( UI.SPACING ) - self.paramListLayout.setMargin ( UI.SPACING ) + if QtCore.QT_VERSION < 50000 : + self.paramListLayout.setMargin ( UI.SPACING ) self.paramListLayout.setAlignment ( QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft ) self.paramListLayout.setColumnMinimumWidth ( 0, self.labelWidth ) self.paramListLayout.setColumnStretch ( 1, 1 ) @@ -283,9 +292,12 @@ def updateGui ( self ) : paramWidget.setEnabled ( False ) if param.removable : - QtCore.QObject.connect ( paramWidget, QtCore.SIGNAL ( 'nodeParamRemoved' ), self.nodeParamViewTab.onParamRemoved ) + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.connect ( paramWidget, QtCore.SIGNAL ( 'nodeParamRemoved' ), self.nodeParamViewTab.onParamRemoved ) + else : + paramWidget.nodeParamRemoved.connect ( self.nodeParamViewTab.onParamRemoved ) paramRows += 1 - spacer = QtModule.QSpacerItem ( 20, 20, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding ) + spacer = QtModule.QSpacerItem ( 20, 20, QtModule.QSizePolicy.Minimum, QtModule.QSizePolicy.Expanding ) self.paramListLayout.addItem ( spacer, paramRows, 0, 1, 1 ) self.paramListLayout.setRowStretch ( paramRows, 1 ) diff --git a/gui/nodeParamView.py b/gui/nodeParamView.py index d9fa1e6..7d9bf36 100644 --- a/gui/nodeParamView.py +++ b/gui/nodeParamView.py @@ -4,7 +4,7 @@ """ from core.mePyQt import QtCore, QtGui - +from core.signal import Signal #from PyQt4.QtCore import QDir, QString, QModelIndex #from PyQt4.QtGui import QFileSystemModel #from PyQt4.QtGui import QFileIconProvider @@ -24,7 +24,6 @@ else : from core.mePyQt import QtWidgets QtModule = QtWidgets - # # NodeParamView # @@ -35,6 +34,13 @@ class NodeParamView ( QtModule.QWidget ) : def __init__ ( self ) : # QtModule.QWidget.__init__ ( self ) + # + # Define signals for PyQt5 + # + if QtCore.QT_VERSION >= 50000 : + # + self.nodeParamChangedSignal = Signal () + self.nodeLabelChangedSignal = Signal () self.gfxNode = None @@ -66,6 +72,9 @@ def connectSignals ( self ) : if QtCore.QT_VERSION < 50000 : self.connect ( self.nameEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.nodeLabelChanged ) self.connect ( self.showConnectButton, QtCore.SIGNAL ( 'toggled(bool)' ), self.showConnections ) + else : + self.nameEdit.editingFinished.connect ( self.nodeLabelChanged ) + self.showConnectButton.toggled.connect ( self.showConnections ) # # disconnectSignals # @@ -74,6 +83,9 @@ def disconnectSignals ( self ) : if QtCore.QT_VERSION < 50000 : self.disconnect ( self.nameEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.nodeLabelChanged ) self.disconnect ( self.showConnectButton, QtCore.SIGNAL ( 'toggled(bool)' ), self.showConnections ) + else : + self.nameEdit.editingFinished.disconnect ( self.nodeLabelChanged ) + self.showConnectButton.toggled.disconnect ( self.showConnections ) # # connectParamSignals # @@ -81,9 +93,15 @@ def connectParamSignals ( self ) : #print ">> NodeParamView.connectParamSignals" if self.gfxNode is not None : for inputParam in self.gfxNode.node.inputParams : - self.connect ( inputParam, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamChanged ) + if QtCore.QT_VERSION < 50000 : + self.connect ( inputParam, QtCore.SIGNAL ( 'paramChangedSignal(QObject)' ), self.onParamChanged ) + else : + inputParam.paramChangedSignal.connect ( self.onParamChanged ) for outputParam in self.gfxNode.node.outputParams : - self.connect ( outputParam, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamChanged ) + if QtCore.QT_VERSION < 50000 : + self.connect ( outputParam, QtCore.SIGNAL ( 'paramChangedSignal(QObject)' ), self.onParamChanged ) + else : + outputParam.paramChangedSignal.connect ( self.onParamChanged ) # # disconnectParamSignals # @@ -91,9 +109,15 @@ def disconnectParamSignals ( self ) : #print ">> NodeParamView.disconnectParamSignals" if self.gfxNode is not None : for inputParam in self.gfxNode.node.inputParams : - self.disconnect ( inputParam, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamChanged ) + if QtCore.QT_VERSION < 50000 : + self.disconnect ( inputParam, QtCore.SIGNAL ( 'paramChangedSignal(QObject)' ), self.onParamChanged ) + else : + inputParam.paramChangedSignal.disconnect ( self.onParamChanged ) for outputParam in self.gfxNode.node.outputParams : - self.disconnect ( outputParam, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamChanged ) + if QtCore.QT_VERSION < 50000 : + self.disconnect ( outputParam, QtCore.SIGNAL ( 'paramChangedSignal(QObject)' ), self.onParamChanged ) + else : + outputParam.paramChangedSignal.disconnect ( self.onParamChanged ) # # showConnections # @@ -111,8 +135,10 @@ def showConnections ( self, show ) : def onParamChanged ( self, param ) : # if DEBUG_MODE : print ">> NodeParamView.onParamChanged node = %s param = %s" % ( self.gfxNode.node.label, param.name ) - self.emit ( QtCore.SIGNAL ( 'nodeParamChanged' ), self.gfxNode, param ) # .node - + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( 'nodeParamChangedSignal' ), self.gfxNode, param ) # .node + else : + self.nodeParamChangedSignal.emit ( self.gfxNode, param ) # .node # # nodeLabelChanged # @@ -127,7 +153,10 @@ def nodeLabelChanged ( self ) : # update label only if realy changed if newLabel != self.gfxNode.node.label : # rename node label if same name exists in NodeNet - self.emit ( QtCore.SIGNAL ( 'nodeLabelChanged' ), self.gfxNode, newLabel ) + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( 'nodeLabelChangedSignal' ), self.gfxNode, newLabel ) + else : + self.nodeLabelChangedSignal.emit ( self.gfxNode, newLabel ) self.nameEdit.clear () self.nameEdit.setText ( self.gfxNode.node.label ) # @@ -167,7 +196,8 @@ def buildGui ( self ) : headerLayout = QtModule.QHBoxLayout () headerLayout.setSpacing ( UI.SPACING ) - #headerLayout.setMargin ( UI.SPACING ) + if QtCore.QT_VERSION < 50000 : + headerLayout.setMargin ( UI.SPACING ) headerLayout.setStretch ( 1, 1 ) headerLayout.addWidget ( label ) diff --git a/gui/nodeTreeView.py b/gui/nodeTreeView.py index 369228e..bd12940 100644 --- a/gui/nodeTreeView.py +++ b/gui/nodeTreeView.py @@ -59,5 +59,8 @@ def startDrag ( self, dropActions ) : drag = QtGui.QDrag ( self ) drag.setMimeData ( mimeData ) #drag.setPixmap ( QtGui.QPixmap(':/node.png') ) - drag.start ( QtCore.Qt.CopyAction ) + if QtCore.QT_VERSION < 50000 : + drag.start ( QtCore.Qt.CopyAction ) + else : + drag.exec_ ( QtCore.Qt.CopyAction ) diff --git a/gui/params/ColorWidget.py b/gui/params/ColorWidget.py index 2fab213..8f3d430 100644 --- a/gui/params/ColorWidget.py +++ b/gui/params/ColorWidget.py @@ -4,146 +4,188 @@ """ from core.mePyQt import QtGui, QtCore +from core.signal import Signal import gui.ui_settings as UI from paramWidget import ParamWidget + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets # # FloatWidget # class ColorWidget ( ParamWidget ) : - # - # buildGui - # - def buildGui ( self ) : - # - self.ui = Ui_ColorWidget_field () - self.ui.setupUi ( self ) + """ + # + # __init__ + # + def __init__ ( self, param, gfxNode, ignoreSubtype = False ) : + # + ParamWidget.__init__ ( self, param, gfxNode, ignoreSubtype = False ) + # + # Define signals for PyQt5 + # + if QtCore.QT_VERSION >= 50000 : + # + self.clicked = Signal () + """ + # + # buildGui + # + def buildGui ( self ) : + # + # + # Define signals for PyQt5 + # + if QtCore.QT_VERSION >= 50000 : + # + self.clicked = Signal () + + self.ui = Ui_ColorWidget_field () + self.ui.setupUi ( self ) # # ColorEditEventFilter # class ColorEditEventFilter ( QtCore.QObject ) : - # - # __init__ - # - def __init__ ( self, ColorWidget ) : - # - QtCore.QObject.__init__ ( self, None ) - self.ColorWidget = ColorWidget - #print "eventFilter created..." - # - # eventFilter - # - def eventFilter ( self, obj, event ) : - # check for single click - if event.type () == QtCore.QEvent.MouseButtonPress: - #print "eventFilter = MouseButtonPress" - self.ColorWidget.emit ( QtCore.SIGNAL ( 'clicked()' ) ) - return True - else: - return obj.eventFilter ( obj, event ) + # + # __init__ + # + def __init__ ( self, ColorWidget ) : + # + QtCore.QObject.__init__ ( self, None ) + self.ColorWidget = ColorWidget + #print "eventFilter created..." + # + # eventFilter + # + def eventFilter ( self, obj, event ) : + # check for single click + if event.type () == QtCore.QEvent.MouseButtonPress: + #print "eventFilter = MouseButtonPress" + if QtCore.QT_VERSION < 50000 : + self.ColorWidget.emit ( QtCore.SIGNAL ( 'clicked()' ) ) + else : + self.ColorWidget.clicked.emit () + return True + else: + return obj.eventFilter ( obj, event ) # # Ui_ColorWidget_field # class Ui_ColorWidget_field ( object ) : - # - # setupUi - # - def setupUi ( self, ColorWidget ) : - # - hl = QtGui.QHBoxLayout () - self.widget = ColorWidget - self.colorEdit = QtGui.QLabel ( ColorWidget ) - - self.colorEdit.setMinimumSize ( QtCore.QSize( UI.COLOR_WIDTH, UI.HEIGHT ) ) - self.colorEdit.setMaximumSize ( QtCore.QSize( UI.COLOR_WIDTH, UI.HEIGHT ) ) + # + # setupUi + # + def setupUi ( self, ColorWidget ) : + # + hl = QtModule.QHBoxLayout () + self.widget = ColorWidget + self.colorEdit = QtModule.QLabel ( ColorWidget ) + + self.colorEdit.setMinimumSize ( QtCore.QSize ( UI.COLOR_WIDTH, UI.HEIGHT ) ) + self.colorEdit.setMaximumSize ( QtCore.QSize ( UI.COLOR_WIDTH, UI.HEIGHT ) ) - self.colorEdit.setObjectName ( 'colorEdit' ) - - self.selector = QtGui.QComboBox ( ColorWidget ) - self.selector.setEditable ( False ) - #self.selector.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) - self.selector.setMaximumSize ( QtCore.QSize( UI.MAX, UI.COMBO_HEIGHT ) ) - - for label in [ "rgb", "hsv", "hsl", "xyz", "XYZ", "YIQ" ] : - self.selector.addItem ( label ) - if self.widget.param.space != None : - self.selector.setCurrentIndex ( self.selector.findText ( self.widget.param.space ) ) - - spacer = QtGui.QSpacerItem ( 20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum ) - - hl.addWidget ( self.colorEdit ) - hl.addWidget ( self.selector ) - hl.addItem ( spacer ) - self.widget.param_vl.addLayout ( hl ) - - QtCore.QMetaObject.connectSlotsByName ( ColorWidget ) - self.connectSignals ( ColorWidget ) - - # install a custom filter in order to avoid subclassing - self.colorEventFilter = ColorEditEventFilter ( ColorWidget ) - self.colorEdit.installEventFilter ( self.colorEventFilter ) - - # - # connectSignals - # - def connectSignals ( self, ColorWidget ) : - # register signal propertyChanged for updating the gui - #self.connect( self.colorProperty, QtCore.SIGNAL('propertyChanged()'), self.onPropertyChanged ) - ColorWidget.connect ( ColorWidget, QtCore.SIGNAL ( 'clicked()' ), self.onClicked ) - ColorWidget.connect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) - # - # disconnectSignals - # - def disconnectSignals ( self, ColorWidget ) : - # register signal propertyChanged for updating the gui - #self.disconnect( self.colorProperty, QtCore.SIGNAL('propertyChanged()'), self.onPropertyChanged ) - ColorWidget.disconnect ( ColorWidget, QtCore.SIGNAL ( 'clicked()' ), self.onClicked ) - ColorWidget.disconnect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) - # - # onClicked - # - def onClicked ( self ) : - #print( "ColorWidget = onClicked" ) - redValue = int ( self.widget.param.value [0] * 255 ) - greenValue = int ( self.widget.param.value [1] * 255 ) - blueValue = int ( self.widget.param.value [2] * 255 ) - colorSelected = QtGui.QColorDialog.getColor ( QtGui.QColor ( redValue, greenValue, blueValue ), self.widget ) - if colorSelected.isValid() : - newValue = ( colorSelected.redF (), - colorSelected.greenF (), - colorSelected.blueF ()) - self.widget.param.setValue ( newValue ) - #self.widget.param.paramChanged () - self.updateGui ( self.widget.param.value ) - # - # onCurrentIndexChanged - # - def onCurrentIndexChanged ( self, idx ) : - space = str ( self.selector.currentText () ) - if space == 'rgb' : space = None - self.widget.param.space = space - # - # updateGui - # - def updateGui ( self, value ) : - r = value [0] - g = value [1] - b = value [2] - - pixmap = QtGui.QPixmap ( UI.COLOR_WIDTH, UI.HEIGHT ) - pixmap.fill ( QtCore.Qt.transparent ) - painter = QtGui.QPainter () - painter.begin ( pixmap ) - painter.setRenderHint ( QtGui.QPainter.Antialiasing, True ) - - color = QtGui.QColor ( r * 255, g * 255, b * 255 ) - - painter.setPen ( QtCore.Qt.NoPen ) - painter.setBrush ( color ) - rect = QtCore.QRectF ( 0.0, 0.0, UI.COLOR_WIDTH, UI.HEIGHT ) - painter.drawRects ( rect ) - painter.end () - - self.colorEdit.setPixmap ( pixmap ) + self.colorEdit.setObjectName ( 'colorEdit' ) + + self.selector = QtModule.QComboBox ( ColorWidget ) + self.selector.setEditable ( False ) + #self.selector.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) + self.selector.setMaximumSize ( QtCore.QSize ( UI.MAX, UI.COMBO_HEIGHT ) ) + + for label in [ "rgb", "hsv", "hsl", "xyz", "XYZ", "YIQ" ] : + self.selector.addItem ( label ) + if self.widget.param.space != None : + self.selector.setCurrentIndex ( self.selector.findText ( self.widget.param.space ) ) + + spacer = QtModule.QSpacerItem ( 20, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum ) + + hl.addWidget ( self.colorEdit ) + hl.addWidget ( self.selector ) + hl.addItem ( spacer ) + self.widget.param_vl.addLayout ( hl ) + + self.connectSignals ( ColorWidget ) + + QtCore.QMetaObject.connectSlotsByName ( ColorWidget ) + + # install a custom filter in order to avoid subclassing + self.colorEventFilter = ColorEditEventFilter ( ColorWidget ) + self.colorEdit.installEventFilter ( self.colorEventFilter ) + + # + # connectSignals + # + def connectSignals ( self, ColorWidget ) : + # register signal propertyChanged for updating the gui + #self.connect( self.colorProperty, QtCore.SIGNAL('propertyChanged()'), self.onPropertyChanged ) + if QtCore.QT_VERSION < 50000 : + ColorWidget.connect ( ColorWidget, QtCore.SIGNAL ( 'clicked()' ), self.onClicked ) + ColorWidget.connect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) + else : + ColorWidget.clicked.connect ( self.onClicked ) + self.selector.activated.connect ( self.onCurrentIndexChanged ) + # + # disconnectSignals + # + def disconnectSignals ( self, ColorWidget ) : + # register signal propertyChanged for updating the gui + #self.disconnect( self.colorProperty, QtCore.SIGNAL('propertyChanged()'), self.onPropertyChanged ) + if QtCore.QT_VERSION < 50000 : + ColorWidget.disconnect ( ColorWidget, QtCore.SIGNAL ( 'clicked()' ), self.onClicked ) + ColorWidget.disconnect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) + else : + ColorWidget.clicked.disconnect ( self.onClicked ) + self.selector.activated.disconnect ( self.onCurrentIndexChanged ) + # + # onClicked + # + def onClicked ( self ) : + #print( "ColorWidget = onClicked" ) + redValue = int ( self.widget.param.value [0] * 255 ) + greenValue = int ( self.widget.param.value [1] * 255 ) + blueValue = int ( self.widget.param.value [2] * 255 ) + colorSelected = QtModule.QColorDialog.getColor ( QtGui.QColor ( redValue, greenValue, blueValue ), self.widget ) + if colorSelected.isValid () : + newValue = ( colorSelected.redF (), + colorSelected.greenF (), + colorSelected.blueF ()) + self.widget.param.setValue ( newValue ) + #self.widget.param.paramChanged () + self.updateGui ( self.widget.param.value ) + # + # onCurrentIndexChanged + # + def onCurrentIndexChanged ( self, idx ) : + # + space = str ( self.selector.currentText () ) + if space == 'rgb' : space = None + self.widget.param.space = space + # + # updateGui + # + def updateGui ( self, value ) : + # + r = value [0] + g = value [1] + b = value [2] + + pixmap = QtGui.QPixmap ( UI.COLOR_WIDTH, UI.HEIGHT ) + pixmap.fill ( QtCore.Qt.transparent ) + painter = QtGui.QPainter () + painter.begin ( pixmap ) + painter.setRenderHint ( QtGui.QPainter.Antialiasing, True ) + + color = QtGui.QColor ( r * 255, g * 255, b * 255 ) + + painter.setPen ( QtCore.Qt.NoPen ) + painter.setBrush ( color ) + rect = QtCore.QRectF ( 0.0, 0.0, UI.COLOR_WIDTH, UI.HEIGHT ) + painter.drawRects ( rect ) + painter.end () + + self.colorEdit.setPixmap ( pixmap ) diff --git a/gui/params/ControlWidget.py b/gui/params/ControlWidget.py index b66df7b..77f9dbb 100644 --- a/gui/params/ControlWidget.py +++ b/gui/params/ControlWidget.py @@ -9,122 +9,140 @@ import gui.ui_settings as UI from paramWidget import ParamWidget +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + # # ControlWidget # class ControlWidget ( ParamWidget ) : - # - # buildGui - # - def buildGui ( self ) : - # - if not self.ignoreSubtype : - if self.param.subtype == 'button': - self.ui = Ui_ControlWidget_button () - else: - self.ui = Ui_ControlWidget_field () - else : - self.ui = Ui_ControlWidget_field () + # + # buildGui + # + def buildGui ( self ) : + # + if not self.ignoreSubtype : + if self.param.subtype == 'button': + self.ui = Ui_ControlWidget_button () + else: + self.ui = Ui_ControlWidget_field () + else : + self.ui = Ui_ControlWidget_field () - self.ui.setupUi ( self ) + self.ui.setupUi ( self ) # # Ui_ControlWidget_field # class Ui_ControlWidget_field ( object ) : - # - # setupUi - # - def setupUi ( self, ControlWidget ) : - # - hl = QtGui.QHBoxLayout () - hl.setStretch ( 1, 1 ) - - self.widget = ControlWidget + # + # setupUi + # + def setupUi ( self, ControlWidget ) : + # + hl = QtGui.QHBoxLayout () + hl.setStretch ( 1, 1 ) + + self.widget = ControlWidget - self.stringEdit = QtGui.QLineEdit ( ControlWidget ) + self.stringEdit = QtModule.QLineEdit ( ControlWidget ) - self.stringEdit.setMinimumSize ( QtCore.QSize ( UI.LABEL_WIDTH, UI.HEIGHT ) ) # UI.EDIT_WIDTH - self.stringEdit.setMaximumSize ( QtCore.QSize ( UI.MAX, UI.HEIGHT ) ) + self.stringEdit.setMinimumSize ( QtCore.QSize ( UI.LABEL_WIDTH, UI.HEIGHT ) ) # UI.EDIT_WIDTH + self.stringEdit.setMaximumSize ( QtCore.QSize ( UI.MAX, UI.HEIGHT ) ) - hl.addWidget ( self.stringEdit ) - self.widget.param_vl.addLayout ( hl ) + hl.addWidget ( self.stringEdit ) + self.widget.param_vl.addLayout ( hl ) - QtCore.QMetaObject.connectSlotsByName ( ControlWidget ) - self.connectSignals ( ControlWidget ) - # - # connectSignals - # - def connectSignals ( self, ControlWidget ) : - # - ControlWidget.connect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) - # - # disconnectSignals - # - def disconnectSignals ( self, ControlWidget ) : - # - ControlWidget.disconnect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) - # - # onStringEditEditingFinished - # - def onStringEditEditingFinished ( self ) : - # - stringValue = self.stringEdit.text () - self.widget.param.setValue ( str ( stringValue ) ) - # - # updateGui - # - def updateGui ( self, value ) : - # - self.stringEdit.setText ( value ) + QtCore.QMetaObject.connectSlotsByName ( ControlWidget ) + self.connectSignals ( ControlWidget ) + # + # connectSignals + # + def connectSignals ( self, ControlWidget ) : + # + if QtCore.QT_VERSION < 50000 : + ControlWidget.connect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) + else : + self.stringEdit.editingFinished.connect ( self.onStringEditEditingFinished ) + # + # disconnectSignals + # + def disconnectSignals ( self, ControlWidget ) : + # + if QtCore.QT_VERSION < 50000 : + ControlWidget.disconnect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) + else : + self.stringEdit.editingFinished.disconnect ( self.onStringEditEditingFinished ) + # + # onStringEditEditingFinished + # + def onStringEditEditingFinished ( self ) : + # + stringValue = self.stringEdit.text () + self.widget.param.setValue ( str ( stringValue ) ) + # + # updateGui + # + def updateGui ( self, value ) : + # + self.stringEdit.setText ( value ) # # Ui_ControlWidget_button # class Ui_ControlWidget_button ( object ) : - # - # setupUi - # - def setupUi ( self, ControlWidget ) : - # - hl = QtGui.QHBoxLayout () - hl.setStretch ( 1, 1 ) - - self.widget = ControlWidget + # + # setupUi + # + def setupUi ( self, ControlWidget ) : + # + hl = QtModule.QHBoxLayout () + hl.setStretch ( 1, 1 ) + + self.widget = ControlWidget - self.button = QtGui.QPushButton ( self.widget.param.btext, ControlWidget ) - #self.button.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) - #self.button.setMaximumSize ( QtCore.QSize ( UI.MAX, UI.COMBO_HEIGHT ) ) + self.button = QtModule.QPushButton ( self.widget.param.btext, ControlWidget ) + #self.button.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) + #self.button.setMaximumSize ( QtCore.QSize ( UI.MAX, UI.COMBO_HEIGHT ) ) - spacer = QtGui.QSpacerItem ( UI.HEIGHT, UI.HEIGHT, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum ) + spacer = QtModule.QSpacerItem ( UI.HEIGHT, UI.HEIGHT, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum ) - hl.addWidget ( self.button ) - hl.addItem ( spacer ) - self.widget.param_vl.addLayout ( hl ) + hl.addWidget ( self.button ) + hl.addItem ( spacer ) + self.widget.param_vl.addLayout ( hl ) - QtCore.QMetaObject.connectSlotsByName ( ControlWidget ) - self.connectSignals ( ControlWidget ) - # - # connectSignals - # - def connectSignals ( self, ControlWidget ) : - # - ControlWidget.connect ( self.button, QtCore.SIGNAL ( 'clicked()' ), self.onClicked ) - # - # disconnectSignals - # - def disconnectSignals ( self, ControlWidget ) : - # - ControlWidget.disconnect ( self.button, QtCore.SIGNAL ( 'clicked()' ), self.onClicked ) - # - # onClicked - # - def onClicked ( self ) : - # - if DEBUG_MODE : print '>> Ui_ControlWidget_button.clicked()' - self.widget.param.execControlCode ( self.widget.gfxNode.node ) - # - # updateGui - # - def updateGui ( self, value ) : - # - pass - #self.button.setText ( value ) + QtCore.QMetaObject.connectSlotsByName ( ControlWidget ) + self.connectSignals ( ControlWidget ) + # + # connectSignals + # + def connectSignals ( self, ControlWidget ) : + # + if QtCore.QT_VERSION < 50000 : + ControlWidget.connect ( self.button, QtCore.SIGNAL ( 'clicked()' ), self.onClicked ) + else : + self.button.clicked.connect ( self.onClicked ) + # + # disconnectSignals + # + def disconnectSignals ( self, ControlWidget ) : + # + if QtCore.QT_VERSION < 50000 : + ControlWidget.disconnect ( self.button, QtCore.SIGNAL ( 'clicked()' ), self.onClicked ) + else : + self.button.clicked.disconnect ( self.onClicked ) + # + # onClicked + # + def onClicked ( self ) : + # + if DEBUG_MODE : print '>> Ui_ControlWidget_button.clicked()' + self.widget.param.execControlCode ( self.widget.gfxNode.node ) + # + # updateGui + # + def updateGui ( self, value ) : + # + pass + #self.button.setText ( value ) diff --git a/gui/params/FloatWidget.py b/gui/params/FloatWidget.py index c0d9d75..22094d9 100644 --- a/gui/params/FloatWidget.py +++ b/gui/params/FloatWidget.py @@ -1,328 +1,371 @@ """ - FloatWidget.py + FloatWidget.py """ import math from decimal import * from core.mePyQt import QtGui, QtCore +from core.signal import Signal import gui.ui_settings as UI from paramWidget import ParamWidget + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets # # FloatWidget # class FloatWidget ( ParamWidget ) : - # - # buildGui - # - def buildGui ( self ) : - # - if not self.ignoreSubtype : - if self.param.subtype == 'selector': - self.ui = Ui_FloatWidget_selector() - elif self.param.subtype == 'switch': - self.ui = Ui_FloatWidget_switch() - elif self.param.subtype == 'slider' or self.param.subtype == 'vslider' : - self.ui = Ui_FloatWidget_slider() - else: - self.ui = Ui_FloatWidget_field() - else : - self.ui = Ui_FloatWidget_field() - - self.ui.setupUi ( self ) + # + # buildGui + # + def buildGui ( self ) : + # + if not self.ignoreSubtype : + if self.param.subtype == 'selector': + self.ui = Ui_FloatWidget_selector() + elif self.param.subtype == 'switch': + self.ui = Ui_FloatWidget_switch() + elif self.param.subtype == 'slider' or self.param.subtype == 'vslider' : + self.ui = Ui_FloatWidget_slider() + else: + self.ui = Ui_FloatWidget_field() + else : + self.ui = Ui_FloatWidget_field() + + self.ui.setupUi ( self ) # # Ui_FloatWidget_field # class Ui_FloatWidget_field ( object ) : - # - # setupUi - # - def setupUi ( self, FloatWidget ) : - # - hl = QtGui.QHBoxLayout () - self.widget = FloatWidget - - self.floatEdit = QtGui.QLineEdit ( FloatWidget ) - - self.floatEdit.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) # UI.EDIT_WIDTH - self.floatEdit.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - spacer = QtGui.QSpacerItem ( 20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum ) - - hl.addWidget ( self.floatEdit ) - hl.addItem ( spacer ) - self.widget.param_vl.addLayout ( hl ) - - QtCore.QMetaObject.connectSlotsByName ( FloatWidget ) - self.connectSignals ( FloatWidget ) - # - # connectSignals - # - def connectSignals ( self, FloatWidget ) : - # - FloatWidget.connect ( self.floatEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - # - # disconnectSignals - # - def disconnectSignals ( self, FloatWidget ) : - # - FloatWidget.disconnect ( self.floatEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - # - # onFloatEditEditingFinished - # - def onFloatEditEditingFinished ( self ) : - # - floatStr = self.floatEdit.text () - floatValue = floatStr.toFloat () [0] - self.widget.param.setValue ( floatValue ) - # self.widget.param.paramChanged () - # - # updateGui - # - def updateGui ( self, value ) : - # - self.floatEdit.setText ( QtCore.QString.number(value, 'f', 3) ) + # + # setupUi + # + def setupUi ( self, FloatWidget ) : + # + hl = QtModule.QHBoxLayout () + self.widget = FloatWidget + + self.floatEdit = QtModule.QLineEdit ( FloatWidget ) + + self.floatEdit.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) # UI.EDIT_WIDTH + self.floatEdit.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + spacer = QtModule.QSpacerItem ( 20, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum ) + + hl.addWidget ( self.floatEdit ) + hl.addItem ( spacer ) + self.widget.param_vl.addLayout ( hl ) + + QtCore.QMetaObject.connectSlotsByName ( FloatWidget ) + self.connectSignals ( FloatWidget ) + # + # connectSignals + # + def connectSignals ( self, FloatWidget ) : + # + if QtCore.QT_VERSION < 50000 : + FloatWidget.connect ( self.floatEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + else : + self.floatEdit.editingFinished.connect ( self.onFloatEditEditingFinished ) + # + # disconnectSignals + # + def disconnectSignals ( self, FloatWidget ) : + # + if QtCore.QT_VERSION < 50000 : + FloatWidget.disconnect ( self.floatEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + else : + self.floatEdit.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + # + # onFloatEditEditingFinished + # + def onFloatEditEditingFinished ( self ) : + # + floatStr = self.floatEdit.text () + if QtCore.QT_VERSION < 50000 : + floatValue = floatStr.toFloat () [0] + else : + floatValue = float ( floatStr ) + self.widget.param.setValue ( floatValue ) + # self.widget.param.paramChanged () + # + # updateGui + # + def updateGui ( self, value ) : + # + if QtCore.QT_VERSION < 50000 : + self.floatEdit.setText ( QtCore.QString.number(value, 'f', 3) ) + else : + self.floatEdit.setText ( str ( value ) ) # # Ui_FloatWidget_switch # class Ui_FloatWidget_switch ( object ) : - # - # setupUi - def setupUi ( self, FloatWidget ) : - # - hl = QtGui.QHBoxLayout () - self.widget = FloatWidget - - self.checkBox = QtGui.QCheckBox ( FloatWidget ) - - self.checkBox.setMinimumSize ( QtCore.QSize ( UI.CHECK_WIDTH, UI.HEIGHT ) ) # UI.EDIT_WIDTH - self.checkBox.setMaximumSize ( QtCore.QSize ( UI.MAX, UI.HEIGHT ) ) - spacer = QtGui.QSpacerItem ( 20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum ) - - hl.addWidget ( self.checkBox ) - hl.addItem ( spacer ) - self.widget.param_vl.addLayout ( hl ) - - QtCore.QMetaObject.connectSlotsByName ( FloatWidget ) - self.connectSignals ( FloatWidget ) - # - # connectSignals - # - def connectSignals ( self, FloatWidget ) : - # - FloatWidget.connect ( self.checkBox, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onStateChanged ) - # - # disconnectSignals - # - def disconnectSignals ( self, FloatWidget ) : - # - FloatWidget.disconnect ( self.checkBox, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onStateChanged ) - # - # onStateChanged - # - def onStateChanged ( self, value ) : - # - floatValue = self.checkBox.isChecked () - self.widget.param.setValue ( floatValue ) - # - # updateGui - # - def updateGui ( self, value ) : - # - self.checkBox.setChecked ( value != 0 ) + # + # setupUi + def setupUi ( self, FloatWidget ) : + # + hl = QtModule.QHBoxLayout () + self.widget = FloatWidget + + self.checkBox = QtModule.QCheckBox ( FloatWidget ) + + self.checkBox.setMinimumSize ( QtCore.QSize ( UI.CHECK_WIDTH, UI.HEIGHT ) ) # UI.EDIT_WIDTH + self.checkBox.setMaximumSize ( QtCore.QSize ( UI.MAX, UI.HEIGHT ) ) + spacer = QtGui.QSpacerItem ( 20, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum ) + + hl.addWidget ( self.checkBox ) + hl.addItem ( spacer ) + self.widget.param_vl.addLayout ( hl ) + + QtCore.QMetaObject.connectSlotsByName ( FloatWidget ) + self.connectSignals ( FloatWidget ) + # + # connectSignals + # + def connectSignals ( self, FloatWidget ) : + # + if QtCore.QT_VERSION < 50000 : + FloatWidget.connect ( self.checkBox, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onStateChanged ) + else : + self.checkBox.stateChanged.connect ( self.onStateChanged ) + # + # disconnectSignals + # + def disconnectSignals ( self, FloatWidget ) : + # + if QtCore.QT_VERSION < 50000 : + FloatWidget.disconnect ( self.checkBox, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onStateChanged ) + else : + self.checkBox.stateChanged.disconnect ( self.onStateChanged ) + # + # onStateChanged + # + def onStateChanged ( self, value ) : + # + floatValue = self.checkBox.isChecked () + self.widget.param.setValue ( floatValue ) + # + # updateGui + # + def updateGui ( self, value ) : + # + self.checkBox.setChecked ( value != 0 ) # # Ui_FloatWidget_selector # class Ui_FloatWidget_selector ( object ) : - # - # setupUi - # - def setupUi ( self, FloatWidget ) : - # - hl = QtGui.QHBoxLayout () - self.widget = FloatWidget - - self.selector = QtGui.QComboBox ( FloatWidget ) - self.selector.setEditable ( False ) - self.selector.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) - self.selector.setMaximumSize ( QtCore.QSize( UI.MAX, UI.COMBO_HEIGHT ) ) - - rangeList = self.widget.param.getRangeValues () - for ( label, value ) in rangeList : - self.selector.addItem ( label, float( value ) ) - - spacer = QtGui.QSpacerItem ( UI.HEIGHT, UI.HEIGHT, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum ) - - hl.addWidget ( self.selector ) - hl.addItem ( spacer ) - self.widget.param_vl.addLayout ( hl ) - - QtCore.QMetaObject.connectSlotsByName ( FloatWidget ) - self.connectSignals ( FloatWidget ) - # - # connectSignals - # - def connectSignals ( self, FloatWidget ) : - # - FloatWidget.connect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) - # - # disconnectSignals - # - def disconnectSignals ( self, FloatWidget ) : - FloatWidget.disconnect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) - # - # onCurrentIndexChanged - # - def onCurrentIndexChanged ( self, idx ) : - # - ( floatValue, ok ) = self.selector.itemData ( idx ).toFloat () - self.widget.param.setValue ( float ( floatValue ) ) - # - # updateGui - # - def updateGui ( self, setValue ) : - # - currentIdx = -1 - i = 0 - rangeList = self.widget.param.getRangeValues () - for ( label, value ) in rangeList : - if setValue == value : - currentIdx = i - break - i += 1 - self.selector.setCurrentIndex ( currentIdx ) + # + # setupUi + # + def setupUi ( self, FloatWidget ) : + # + hl = QtModule.QHBoxLayout () + self.widget = FloatWidget + + self.selector = QtModule.QComboBox ( FloatWidget ) + self.selector.setEditable ( False ) + self.selector.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) + self.selector.setMaximumSize ( QtCore.QSize( UI.MAX, UI.COMBO_HEIGHT ) ) + + rangeList = self.widget.param.getRangeValues () + for ( label, value ) in rangeList : + self.selector.addItem ( label, float( value ) ) + + spacer = QtModule.QSpacerItem ( UI.HEIGHT, UI.HEIGHT, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum ) + + hl.addWidget ( self.selector ) + hl.addItem ( spacer ) + self.widget.param_vl.addLayout ( hl ) + + QtCore.QMetaObject.connectSlotsByName ( FloatWidget ) + self.connectSignals ( FloatWidget ) + # + # connectSignals + # + def connectSignals ( self, FloatWidget ) : + # + if QtCore.QT_VERSION < 50000 : + FloatWidget.connect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) + else : + self.selector.activated.connect ( self.onCurrentIndexChanged ) + # + # disconnectSignals + # + def disconnectSignals ( self, FloatWidget ) : + # + if QtCore.QT_VERSION < 50000 : + FloatWidget.disconnect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) + else : + self.selector.activated.disconnect ( self.onCurrentIndexChanged ) + # + # onCurrentIndexChanged + # + def onCurrentIndexChanged ( self, idx ) : + # + ( floatValue, ok ) = self.selector.itemData ( idx ).toFloat () + self.widget.param.setValue ( float ( floatValue ) ) + # + # updateGui + # + def updateGui ( self, setValue ) : + # + currentIdx = -1 + i = 0 + rangeList = self.widget.param.getRangeValues () + for ( label, value ) in rangeList : + if setValue == value : + currentIdx = i + break + i += 1 + self.selector.setCurrentIndex ( currentIdx ) # # Ui_FloatWidget_slider # class Ui_FloatWidget_slider ( object ) : - # - # getRangeMultiplier - # - def getRangeMultiplier ( self, floatStep ) : - # - multiplier = 1.0 - value = float ( floatStep ) - while not value.is_integer () : - value *= 10.0 - multiplier *= 10.0 - - return multiplier - # - # setupUi - # - def setupUi ( self, FloatWidget ) : - # - hl = QtGui.QHBoxLayout () - hl.setStretch ( 1, 1 ) - - self.widget = FloatWidget - - self.floatEdit = QtGui.QLineEdit( FloatWidget ) - - self.floatEdit.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) # UI.EDIT_WIDTH - self.floatEdit.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - - self.slider = QtGui.QSlider ( QtCore.Qt.Horizontal, FloatWidget ) - - floatMinVal = 0 - floatMaxVal = 1 - floatStep = 0.1 - - rangeList = self.widget.param.getRangeValues () - if len ( rangeList ) : - floatMinVal = rangeList [ 0 ] - floatMaxVal = rangeList [ 1 ] - floatStep = rangeList [ 2 ] - - if floatStep == 0.0 : floatStep = 0.1 + # + # getRangeMultiplier + # + def getRangeMultiplier ( self, floatStep ) : + # + multiplier = 1.0 + value = float ( floatStep ) + while not value.is_integer () : + value *= 10.0 + multiplier *= 10.0 + + return multiplier + # + # setupUi + # + def setupUi ( self, FloatWidget ) : + # + hl = QtModule.QHBoxLayout () + hl.setStretch ( 1, 1 ) + + self.widget = FloatWidget + + self.floatEdit = QtModule.QLineEdit( FloatWidget ) + + self.floatEdit.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) # UI.EDIT_WIDTH + self.floatEdit.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + + self.slider = QtModule.QSlider ( QtCore.Qt.Horizontal, FloatWidget ) + + floatMinVal = 0 + floatMaxVal = 1 + floatStep = 0.1 + + rangeList = self.widget.param.getRangeValues () + if len ( rangeList ) : + floatMinVal = rangeList [ 0 ] + floatMaxVal = rangeList [ 1 ] + floatStep = rangeList [ 2 ] + + if floatStep == 0.0 : floatStep = 0.1 - multiplier = self.getRangeMultiplier ( floatStep ) - - intMinVal = int ( floatMinVal * multiplier ) - intMaxVal = int ( floatMaxVal * multiplier ) - intStep = int ( floatStep * multiplier ) - - self.slider.setRange ( intMinVal, intMaxVal ) - self.slider.setSingleStep ( intStep ) - - self.slider.setValue ( int ( self.widget.param.value * multiplier ) ) + multiplier = self.getRangeMultiplier ( floatStep ) + + intMinVal = int ( floatMinVal * multiplier ) + intMaxVal = int ( floatMaxVal * multiplier ) + intStep = int ( floatStep * multiplier ) + + self.slider.setRange ( intMinVal, intMaxVal ) + self.slider.setSingleStep ( intStep ) + + self.slider.setValue ( int ( self.widget.param.value * multiplier ) ) - hl.addWidget ( self.floatEdit ) - hl.addWidget ( self.slider ) - self.widget.param_vl.addLayout ( hl ) - - QtCore.QMetaObject.connectSlotsByName ( FloatWidget ) - self.connectSignals ( FloatWidget ) - # - # connectSignals - # - def connectSignals ( self, FloatWidget ) : - # - FloatWidget.connect ( self.floatEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - FloatWidget.connect ( self.slider, QtCore.SIGNAL ( 'valueChanged(int)' ), self.onSliderValueChanged ) - # - # disconnectSignals - # - def disconnectSignals ( self, FloatWidget ) : - # - FloatWidget.disconnect ( self.floatEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - FloatWidget.disconnect ( self.slider, QtCore.SIGNAL ( 'valueChanged(int)' ), self.onSliderValueChanged ) - # - # onFloatEditEditingFinished - # - def onFloatEditEditingFinished ( self ) : - # - floatStr = self.floatEdit.text () - floatValue = floatStr.toFloat () [ 0 ] - self.widget.param.setValue ( floatValue ) - - floatMinVal = 0 - floatMaxVal = 1 - floatStep = 0.1 - - rangeList = self.widget.param.getRangeValues () - if len ( rangeList ) : - floatMinVal = rangeList [ 0 ] - floatMaxVal = rangeList [ 1 ] - floatStep = rangeList [ 2 ] - - if floatStep == 0.0 : floatStep = 0.1 - - multiplier = self.getRangeMultiplier ( floatStep ) - - intMinVal = int ( floatMinVal * multiplier ) - intMaxVal = int ( floatMaxVal * multiplier ) - intStep = int ( floatStep * multiplier ) - - self.slider.setValue ( int ( floatValue * multiplier ) ) - # - # onSliderValueChanged - # - def onSliderValueChanged ( self, value ) : - # - intValue = value #self.slider.value () - - floatMinVal = 0 - floatMaxVal = 1 - floatStep = 0.1 - - rangeList = self.widget.param.getRangeValues () - if len ( rangeList ) : - floatMinVal = rangeList [ 0 ] - floatMaxVal = rangeList [ 1 ] - floatStep = rangeList [ 2 ] - - if floatStep == 0.0 : floatStep = 0.1 - - multiplier = self.getRangeMultiplier ( floatStep ) - - floatValue = float ( intValue ) / float ( multiplier ) - self.widget.param.setValue ( floatValue ) - self.updateGui ( floatValue ) - # - # updateGui - # - def updateGui ( self, value ) : - # - self.floatEdit.setText ( QtCore.QString.number ( value, 'f', 3 ) ) + hl.addWidget ( self.floatEdit ) + hl.addWidget ( self.slider ) + self.widget.param_vl.addLayout ( hl ) + + QtCore.QMetaObject.connectSlotsByName ( FloatWidget ) + self.connectSignals ( FloatWidget ) + # + # connectSignals + # + def connectSignals ( self, FloatWidget ) : + # + if QtCore.QT_VERSION < 50000 : + FloatWidget.connect ( self.floatEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + FloatWidget.connect ( self.slider, QtCore.SIGNAL ( 'valueChanged(int)' ), self.onSliderValueChanged ) + else : + self.floatEdit.editingFinished.connect ( self.onFloatEditEditingFinished ) + self.slider.valueChanged.connect ( self.onSliderValueChanged ) + # + # disconnectSignals + # + def disconnectSignals ( self, FloatWidget ) : + # + if QtCore.QT_VERSION < 50000 : + FloatWidget.disconnect ( self.floatEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + FloatWidget.disconnect ( self.slider, QtCore.SIGNAL ( 'valueChanged(int)' ), self.onSliderValueChanged ) + else : + self.floatEdit.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + self.slider.valueChanged.disconnect ( self.onSliderValueChanged ) + # + # onFloatEditEditingFinished + # + def onFloatEditEditingFinished ( self ) : + # + floatStr = self.floatEdit.text () + floatValue = floatStr.toFloat () [ 0 ] + self.widget.param.setValue ( floatValue ) + + floatMinVal = 0 + floatMaxVal = 1 + floatStep = 0.1 + + rangeList = self.widget.param.getRangeValues () + if len ( rangeList ) : + floatMinVal = rangeList [ 0 ] + floatMaxVal = rangeList [ 1 ] + floatStep = rangeList [ 2 ] + + if floatStep == 0.0 : floatStep = 0.1 + + multiplier = self.getRangeMultiplier ( floatStep ) + + intMinVal = int ( floatMinVal * multiplier ) + intMaxVal = int ( floatMaxVal * multiplier ) + intStep = int ( floatStep * multiplier ) + + self.slider.setValue ( int ( floatValue * multiplier ) ) + # + # onSliderValueChanged + # + def onSliderValueChanged ( self, value ) : + # + intValue = value #self.slider.value () + + floatMinVal = 0 + floatMaxVal = 1 + floatStep = 0.1 + + rangeList = self.widget.param.getRangeValues () + if len ( rangeList ) : + floatMinVal = rangeList [ 0 ] + floatMaxVal = rangeList [ 1 ] + floatStep = rangeList [ 2 ] + + if floatStep == 0.0 : floatStep = 0.1 + + multiplier = self.getRangeMultiplier ( floatStep ) + + floatValue = float ( intValue ) / float ( multiplier ) + self.widget.param.setValue ( floatValue ) + self.updateGui ( floatValue ) + # + # updateGui + # + def updateGui ( self, value ) : + # + if QtCore.QT_VERSION < 50000 : + self.floatEdit.setText ( QtCore.QString.number ( value, 'f', 3 ) ) + else : + self.floatEdit.setText ( str ( value ) ) diff --git a/gui/params/IntWidget.py b/gui/params/IntWidget.py index b9f101a..5e384eb 100644 --- a/gui/params/IntWidget.py +++ b/gui/params/IntWidget.py @@ -6,262 +6,315 @@ from core.mePyQt import QtGui, QtCore import gui.ui_settings as UI -from paramWidget import ParamWidget +from paramWidget import ParamWidget + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets # # IntWidget # class IntWidget ( ParamWidget ) : - # - # buildGui - # - def buildGui ( self ) : - # - if not self.ignoreSubtype : - if self.param.subtype == 'selector' : - self.ui = Ui_IntWidget_selector () - elif self.param.subtype == 'switch' : - self.ui = Ui_IntWidget_switch () - elif self.param.subtype == 'slider' or self.param.subtype == 'vslider' : - self.ui = Ui_IntWidget_slider () - else: - self.ui = Ui_IntWidget_field () - else : - self.ui = Ui_IntWidget_field () - - self.ui.setupUi ( self ) + # + # buildGui + # + def buildGui ( self ) : + # + if not self.ignoreSubtype : + if self.param.subtype == 'selector' : + self.ui = Ui_IntWidget_selector () + elif self.param.subtype == 'switch' : + self.ui = Ui_IntWidget_switch () + elif self.param.subtype == 'slider' or self.param.subtype == 'vslider' : + self.ui = Ui_IntWidget_slider () + else: + self.ui = Ui_IntWidget_field () + else : + self.ui = Ui_IntWidget_field () + + self.ui.setupUi ( self ) # # Ui_IntWidget_field # class Ui_IntWidget_field ( object ) : - # - # setupUi - # - def setupUi ( self, IntWidget ) : - # - hl = QtGui.QHBoxLayout () - self.widget = IntWidget - - self.intEdit = QtGui.QLineEdit ( IntWidget ) - - self.intEdit.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.intEdit.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - spacer = QtGui.QSpacerItem ( 20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum ) - - hl.addWidget ( self.intEdit ) - hl.addItem ( spacer ) - self.widget.param_vl.addLayout ( hl ) - - QtCore.QMetaObject.connectSlotsByName ( IntWidget ) - self.connectSignals ( IntWidget ) - # - # connectSignals - # - def connectSignals ( self, IntWidget ) : - # - IntWidget.connect ( self.intEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onIntEditEditingFinished ) - # - # disconnectSignals - # - def disconnectSignals ( self, IntWidget ) : - # - IntWidget.disconnect ( self.intEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onIntEditEditingFinished ) - # - # onIntEditEditingFinished - # - def onIntEditEditingFinished ( self ) : - # - intStr = self.intEdit.text () - intValue = intStr.toInt () [ 0 ] - self.widget.param.setValue ( intValue ) - # - # updateGui - def updateGui ( self, value ): self.intEdit.setText ( QtCore.QString.number ( value ) ) + # + # setupUi + # + def setupUi ( self, IntWidget ) : + # + hl = QtModule.QHBoxLayout () + self.widget = IntWidget + + self.intEdit = QtModule.QLineEdit ( IntWidget ) + + self.intEdit.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.intEdit.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + spacer = QtModule.QSpacerItem ( 20, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum ) + + hl.addWidget ( self.intEdit ) + hl.addItem ( spacer ) + self.widget.param_vl.addLayout ( hl ) + + QtCore.QMetaObject.connectSlotsByName ( IntWidget ) + self.connectSignals ( IntWidget ) + # + # connectSignals + # + def connectSignals ( self, IntWidget ) : + # + if QtCore.QT_VERSION < 50000 : + IntWidget.connect ( self.intEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onIntEditEditingFinished ) + else : + self.intEdit.editingFinished.connect ( self.onIntEditEditingFinished ) + # + # disconnectSignals + # + def disconnectSignals ( self, IntWidget ) : + # + if QtCore.QT_VERSION < 50000 : + IntWidget.disconnect ( self.intEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onIntEditEditingFinished ) + else : + self.intEdit.editingFinished.disconnect ( self.onIntEditEditingFinished ) + # + # onIntEditEditingFinished + # + def onIntEditEditingFinished ( self ) : + # + intStr = self.intEdit.text () + if QtCore.QT_VERSION < 50000 : + intValue = intStr.toInt () [ 0 ] + else : + intValue = int ( intStr ) + self.widget.param.setValue ( intValue ) + # + # updateGui + def updateGui ( self, value ): + # + if QtCore.QT_VERSION < 50000 : + self.intEdit.setText ( QtCore.QString.number ( value ) ) + else : + self.intEdit.setText ( str ( value ) ) # # Ui_IntWidget_switch # class Ui_IntWidget_switch ( object ) : - # - # setupUi - # - def setupUi ( self, IntWidget ) : - # - hl = QtGui.QHBoxLayout () - self.widget = IntWidget - - self.checkBox = QtGui.QCheckBox ( IntWidget ) - - self.checkBox.setMinimumSize ( QtCore.QSize ( UI.CHECK_WIDTH, UI.HEIGHT ) ) - self.checkBox.setMaximumSize ( QtCore.QSize ( UI.MAX, UI.HEIGHT ) ) - spacer = QtGui.QSpacerItem ( 20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum ) - - hl.addWidget ( self.checkBox ) - hl.addItem ( spacer ) - self.widget.param_vl.addLayout ( hl ) - - QtCore.QMetaObject.connectSlotsByName ( IntWidget ) - self.connectSignals ( IntWidget ) - # - # connectSignals - # - def connectSignals ( self, IntWidget ) : - # - IntWidget.connect ( self.checkBox, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onStateChanged ) - # - # disconnectSignals - # - def disconnectSignals ( self, IntWidget ) : - # - IntWidget.disconnect ( self.checkBox, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onStateChanged ) - # - # onStateChanged - # - def onStateChanged ( self, value ) : - # - intValue = self.checkBox.isChecked () - self.widget.param.setValue ( intValue ) - # - # updateGui - # - def updateGui ( self, value ) : self.checkBox.setChecked ( value != 0 ) + # + # setupUi + # + def setupUi ( self, IntWidget ) : + # + hl = QtModule.QHBoxLayout () + self.widget = IntWidget + + self.checkBox = QtModule.QCheckBox ( IntWidget ) + + self.checkBox.setMinimumSize ( QtCore.QSize ( UI.CHECK_WIDTH, UI.HEIGHT ) ) + self.checkBox.setMaximumSize ( QtCore.QSize ( UI.MAX, UI.HEIGHT ) ) + spacer = QtModule.QSpacerItem ( 20, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum ) + + hl.addWidget ( self.checkBox ) + hl.addItem ( spacer ) + self.widget.param_vl.addLayout ( hl ) + + QtCore.QMetaObject.connectSlotsByName ( IntWidget ) + self.connectSignals ( IntWidget ) + # + # connectSignals + # + def connectSignals ( self, IntWidget ) : + # + if QtCore.QT_VERSION < 50000 : + IntWidget.connect ( self.checkBox, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onStateChanged ) + else : + self.checkBox.stateChanged.connect ( self.onStateChanged ) + # + # disconnectSignals + # + def disconnectSignals ( self, IntWidget ) : + # + if QtCore.QT_VERSION < 50000 : + IntWidget.disconnect ( self.checkBox, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onStateChanged ) + else : + self.checkBox.stateChanged.disconnect ( self.onStateChanged ) + # + # onStateChanged + # + def onStateChanged ( self, value ) : + # + intValue = self.checkBox.isChecked () + self.widget.param.setValue ( intValue ) + # + # updateGui + # + def updateGui ( self, value ) : + # + self.checkBox.setChecked ( value != 0 ) # # Ui_IntWidget_selector # class Ui_IntWidget_selector ( object ) : - # - # setupUi - # - def setupUi ( self, IntWidget ) : - # - hl = QtGui.QHBoxLayout () - self.widget = IntWidget - - self.selector = QtGui.QComboBox ( IntWidget ) - self.selector.setEditable ( False ) - self.selector.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) - self.selector.setMaximumSize ( QtCore.QSize ( UI.MAX, UI.COMBO_HEIGHT ) ) - - rangeList = self.widget.param.getRangeValues () - - for ( label, value ) in rangeList : self.selector.addItem ( label, int( value ) ) - - spacer = QtGui.QSpacerItem ( UI.HEIGHT, UI.HEIGHT, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum ) - - hl.addWidget ( self.selector ) - hl.addItem ( spacer ) - self.widget.param_vl.addLayout ( hl ) - - QtCore.QMetaObject.connectSlotsByName ( IntWidget ) - self.connectSignals ( IntWidget ) - # - # connectSignals - # - def connectSignals ( self, IntWidget ) : - # - IntWidget.connect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) - # - # disconnectSignals - # - def disconnectSignals ( self, IntWidget ) : - # - IntWidget.disconnect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) - # - # onCurrentIndexChanged - # - def onCurrentIndexChanged ( self, idx ) : - # - ( intValue, ok ) = self.selector.itemData ( idx ).toInt () - self.widget.param.setValue ( int ( intValue ) ) - # - # updateGui - # - def updateGui ( self, setValue ) : - # - currentIdx = -1 - i = 0 - rangeList = self.widget.param.getRangeValues () - for ( label, value ) in rangeList : - if setValue == value : - currentIdx = i - break - i += 1 - self.selector.setCurrentIndex ( currentIdx ) + # + # setupUi + # + def setupUi ( self, IntWidget ) : + # + hl = QtModule.QHBoxLayout () + self.widget = IntWidget + + self.selector = QtModule.QComboBox ( IntWidget ) + self.selector.setEditable ( False ) + self.selector.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) + self.selector.setMaximumSize ( QtCore.QSize ( UI.MAX, UI.COMBO_HEIGHT ) ) + + rangeList = self.widget.param.getRangeValues () + + for ( label, value ) in rangeList : self.selector.addItem ( label, int( value ) ) + + spacer = QtModule.QSpacerItem ( UI.HEIGHT, UI.HEIGHT, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum ) + + hl.addWidget ( self.selector ) + hl.addItem ( spacer ) + self.widget.param_vl.addLayout ( hl ) + + QtCore.QMetaObject.connectSlotsByName ( IntWidget ) + self.connectSignals ( IntWidget ) + # + # connectSignals + # + def connectSignals ( self, IntWidget ) : + # + if QtCore.QT_VERSION < 50000 : + IntWidget.connect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) + else : + self.selector.activated.connect ( self.onCurrentIndexChanged ) + # + # disconnectSignals + # + def disconnectSignals ( self, IntWidget ) : + # + if QtCore.QT_VERSION < 50000 : + IntWidget.disconnect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) + else : + self.selector.activated.disconnect ( self.onCurrentIndexChanged ) + # + # onCurrentIndexChanged + # + def onCurrentIndexChanged ( self, idx ) : + # + if QtCore.QT_VERSION < 50000 : + ( intValue, ok ) = self.selector.itemData ( idx ).toInt () + else : + intValue = self.selector.itemData ( idx ) + self.widget.param.setValue ( int ( intValue ) ) + # + # updateGui + # + def updateGui ( self, setValue ) : + # + currentIdx = -1 + i = 0 + rangeList = self.widget.param.getRangeValues () + for ( label, value ) in rangeList : + if setValue == value : + currentIdx = i + break + i += 1 + self.selector.setCurrentIndex ( currentIdx ) # # Ui_IntWidget_slider # class Ui_IntWidget_slider ( object ) : - # - # setupUi - # - def setupUi ( self, IntWidget ) : - # - hl = QtGui.QHBoxLayout () - hl.setStretch ( 1, 1 ) - - self.widget = IntWidget - - self.intEdit = QtGui.QLineEdit ( IntWidget ) - - self.intEdit.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.intEdit.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - - self.slider = QtGui.QSlider ( QtCore.Qt.Horizontal, IntWidget ) - - intMinVal = 0 - intMaxVal = 10 - intStep = 1 - - rangeList = self.widget.param.getRangeValues () - - if len ( rangeList ) : - intMinVal = rangeList [ 0 ] - intMaxVal = rangeList [ 1 ] - intStep = rangeList [ 2 ] - - if intStep == 0 : intStep = 1 - - self.slider.setRange ( intMinVal, intMaxVal ) - self.slider.setSingleStep ( intStep ) - - self.slider.setValue ( int ( self.widget.param.value ) ) + # + # setupUi + # + def setupUi ( self, IntWidget ) : + # + hl = QtModule.QHBoxLayout () + hl.setStretch ( 1, 1 ) + + self.widget = IntWidget + + self.intEdit = QtGui.QLineEdit ( IntWidget ) + + self.intEdit.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.intEdit.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + + self.slider = QtModule.QSlider ( QtCore.Qt.Horizontal, IntWidget ) + + intMinVal = 0 + intMaxVal = 10 + intStep = 1 + + rangeList = self.widget.param.getRangeValues () + + if len ( rangeList ) : + intMinVal = rangeList [ 0 ] + intMaxVal = rangeList [ 1 ] + intStep = rangeList [ 2 ] + + if intStep == 0 : intStep = 1 + + self.slider.setRange ( intMinVal, intMaxVal ) + self.slider.setSingleStep ( intStep ) + + self.slider.setValue ( int ( self.widget.param.value ) ) - hl.addWidget ( self.intEdit ) - hl.addWidget ( self.slider ) - self.widget.param_vl.addLayout ( hl ) - - QtCore.QMetaObject.connectSlotsByName ( IntWidget ) - self.connectSignals ( IntWidget ) - # - # connectSignals - # - def connectSignals ( self, IntWidget ) : - # - IntWidget.connect ( self.intEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onIntEditEditingFinished ) - IntWidget.connect ( self.slider, QtCore.SIGNAL ( 'valueChanged(int)' ), self.onSliderValueChanged ) - # - # disconnectSignals - # - def disconnectSignals ( self, IntWidget ) : - # - IntWidget.disconnect ( self.intEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onIntEditEditingFinished ) - IntWidget.disconnect ( self.slider, QtCore.SIGNAL ( 'valueChanged(int)' ), self.onSliderValueChanged ) - # - # onIntEditEditingFinished - # - def onIntEditEditingFinished ( self ) : - # - intStr = self.intEdit.text () - intValue = intStr.toInt () [ 0 ] - self.widget.param.setValue ( intValue ) - self.slider.setValue ( intValue ) - # - # onSliderValueChanged - # - def onSliderValueChanged ( self, value ) : - # - self.widget.param.setValue ( value ) - self.updateGui ( value) - #self.widget.param.paramChanged () - # - # updateGui - # - def updateGui ( self, value ) : self.intEdit.setText ( QtCore.QString.number ( value ) ) + hl.addWidget ( self.intEdit ) + hl.addWidget ( self.slider ) + self.widget.param_vl.addLayout ( hl ) + + QtCore.QMetaObject.connectSlotsByName ( IntWidget ) + self.connectSignals ( IntWidget ) + # + # connectSignals + # + def connectSignals ( self, IntWidget ) : + # + if QtCore.QT_VERSION < 50000 : + IntWidget.connect ( self.intEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onIntEditEditingFinished ) + IntWidget.connect ( self.slider, QtCore.SIGNAL ( 'valueChanged(int)' ), self.onSliderValueChanged ) + else : + self.intEdit.editingFinished.connect ( self.onIntEditEditingFinished ) + self.slider.valueChanged.connect ( self.onSliderValueChanged ) + # + # disconnectSignals + # + def disconnectSignals ( self, IntWidget ) : + # + if QtCore.QT_VERSION < 50000 : + IntWidget.disconnect ( self.intEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onIntEditEditingFinished ) + IntWidget.disconnect ( self.slider, QtCore.SIGNAL ( 'valueChanged(int)' ), self.onSliderValueChanged ) + else : + self.intEdit.editingFinished.disconnect ( self.onIntEditEditingFinished ) + self.slider.valueChanged.disconnect ( self.onSliderValueChanged ) + # + # onIntEditEditingFinished + # + def onIntEditEditingFinished ( self ) : + # + intStr = self.intEdit.text () + if QtCore.QT_VERSION < 50000 : + intValue = intStr.toInt () [ 0 ] + else : + intValue = int ( intStr ) + self.widget.param.setValue ( intValue ) + self.slider.setValue ( intValue ) + # + # onSliderValueChanged + # + def onSliderValueChanged ( self, value ) : + # + self.widget.param.setValue ( value ) + self.updateGui ( value) + #self.widget.param.paramChanged () + # + # updateGui + # + def updateGui ( self, value ) : + # + if QtCore.QT_VERSION < 50000 : + self.intEdit.setText ( QtCore.QString.number ( value ) ) + else : + self.intEdit.setText ( str ( value ) ) diff --git a/gui/params/MatrixWidget.py b/gui/params/MatrixWidget.py index 45d08c3..9add305 100644 --- a/gui/params/MatrixWidget.py +++ b/gui/params/MatrixWidget.py @@ -7,289 +7,341 @@ import gui.ui_settings as UI from paramWidget import ParamWidget + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets # # MatrixWidget # class MatrixWidget ( ParamWidget ) : - # - # buildGui - # - def buildGui ( self ) : - # - self.ui = Ui_MatrixWidget_field () - self.ui.setupUi ( self ) + # + # buildGui + # + def buildGui ( self ) : + # + self.ui = Ui_MatrixWidget_field () + self.ui.setupUi ( self ) # # Ui_MatrixWidget_field # class Ui_MatrixWidget_field ( object ) : - # - # setupUi - # - def setupUi ( self, MatrixWidget ) : - # - hl = QtGui.QHBoxLayout () - self.widget = MatrixWidget - - self.floatEdit0 = QtGui.QLineEdit( MatrixWidget ) - self.floatEdit1 = QtGui.QLineEdit( MatrixWidget ) - self.floatEdit2 = QtGui.QLineEdit( MatrixWidget ) - self.floatEdit3 = QtGui.QLineEdit( MatrixWidget ) - - self.floatEdit4 = QtGui.QLineEdit( MatrixWidget ) - self.floatEdit5 = QtGui.QLineEdit( MatrixWidget ) - self.floatEdit6 = QtGui.QLineEdit( MatrixWidget ) - self.floatEdit7 = QtGui.QLineEdit( MatrixWidget ) - - self.floatEdit8 = QtGui.QLineEdit( MatrixWidget ) - self.floatEdit9 = QtGui.QLineEdit( MatrixWidget ) - self.floatEdit10 = QtGui.QLineEdit( MatrixWidget ) - self.floatEdit11 = QtGui.QLineEdit( MatrixWidget ) - - self.floatEdit12 = QtGui.QLineEdit( MatrixWidget ) - self.floatEdit13 = QtGui.QLineEdit( MatrixWidget ) - self.floatEdit14 = QtGui.QLineEdit( MatrixWidget ) - self.floatEdit15 = QtGui.QLineEdit( MatrixWidget ) - - - self.floatEdit0.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit1.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit2.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit3.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - - self.floatEdit4.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit5.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit6.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit7.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - - self.floatEdit8.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit9.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit10.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit11.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - - self.floatEdit12.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit13.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit14.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit15.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - - - self.floatEdit0.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit1.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit2.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit3.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - - self.floatEdit4.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit5.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit6.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit7.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - - self.floatEdit8.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit9.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit10.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit11.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - - self.floatEdit12.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit13.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit14.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit15.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - - self.selector = QtGui.QComboBox ( MatrixWidget ) - self.selector.setEditable ( False ) - #self.selector.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) - self.selector.setMaximumSize ( QtCore.QSize( UI.MAX, UI.COMBO_HEIGHT ) ) - - for label in [ "current", "shader", "object", "camera", "world", "raster", "NDC", "screen" ] : - self.selector.addItem ( label ) - if self.widget.param.space != None : - self.selector.setCurrentIndex( self.selector.findText ( self.widget.param.space ) ) - - spacer0 = QtGui.QSpacerItem ( 20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum ) - - hl.addWidget ( self.selector ) - hl.addItem ( spacer0 ) - self.widget.param_vl.addLayout ( hl ) - - hl1 = QtGui.QHBoxLayout () - hl1.setSpacing ( UI.SPACING ) - hl1.setMargin ( 0 ) - hl1.addWidget ( self.floatEdit0 ) - hl1.addWidget ( self.floatEdit1 ) - hl1.addWidget ( self.floatEdit2 ) - hl1.addWidget ( self.floatEdit3 ) - spacer1 = QtGui.QSpacerItem ( 20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum ) - hl1.addItem ( spacer1 ) - - self.widget.param_vl.addLayout ( hl1 ) - - hl2 = QtGui.QHBoxLayout () - hl2.setSpacing ( UI.SPACING ) - hl2.setMargin ( 0 ) - hl2.addWidget ( self.floatEdit4 ) - hl2.addWidget ( self.floatEdit5 ) - hl2.addWidget ( self.floatEdit6 ) - hl2.addWidget ( self.floatEdit7 ) - spacer2 = QtGui.QSpacerItem ( 20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum ) - hl2.addItem ( spacer2 ) - - self.widget.param_vl.addLayout ( hl2 ) - - hl3 = QtGui.QHBoxLayout () - hl3.setSpacing ( UI.SPACING ) - hl3.setMargin ( 0 ) - hl3.addWidget ( self.floatEdit8 ) - hl3.addWidget ( self.floatEdit9 ) - hl3.addWidget ( self.floatEdit10 ) - hl3.addWidget ( self.floatEdit11 ) - spacer3 = QtGui.QSpacerItem ( 20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum ) - hl3.addItem ( spacer3 ) - - self.widget.param_vl.addLayout ( hl3 ) - - hl4 = QtGui.QHBoxLayout () - hl4.setSpacing ( UI.SPACING ) - hl4.setMargin ( 0 ) - hl4.addWidget ( self.floatEdit12 ) - hl4.addWidget ( self.floatEdit13 ) - hl4.addWidget ( self.floatEdit14 ) - hl4.addWidget ( self.floatEdit15 ) - spacer4 = QtGui.QSpacerItem ( 20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum ) - hl4.addItem ( spacer4 ) - - self.widget.param_vl.addLayout ( hl4 ) - - QtCore.QMetaObject.connectSlotsByName ( MatrixWidget ) - self.connectSignals ( MatrixWidget ) - # - # connectSignals - # - def connectSignals ( self, MatrixWidget ) : - # - MatrixWidget.connect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - MatrixWidget.connect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - MatrixWidget.connect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - MatrixWidget.connect ( self.floatEdit3, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - - MatrixWidget.connect ( self.floatEdit4, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - MatrixWidget.connect ( self.floatEdit5, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - MatrixWidget.connect ( self.floatEdit6, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - MatrixWidget.connect ( self.floatEdit7, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - - MatrixWidget.connect ( self.floatEdit8, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - MatrixWidget.connect ( self.floatEdit9, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - MatrixWidget.connect ( self.floatEdit10, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - MatrixWidget.connect ( self.floatEdit11, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - - MatrixWidget.connect ( self.floatEdit12, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - MatrixWidget.connect ( self.floatEdit13, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - MatrixWidget.connect ( self.floatEdit14, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - MatrixWidget.connect ( self.floatEdit15, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - - MatrixWidget.connect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) - # - # disconnectSignals - # - def disconnectSignals ( self, MatrixWidget ) : - # - MatrixWidget.disconnect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - MatrixWidget.disconnect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - MatrixWidget.disconnect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - MatrixWidget.disconnect ( self.floatEdit3, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - - MatrixWidget.disconnect ( self.floatEdit4, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - MatrixWidget.disconnect ( self.floatEdit5, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - MatrixWidget.disconnect ( self.floatEdit6, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - MatrixWidget.disconnect ( self.floatEdit7, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - - MatrixWidget.disconnect ( self.floatEdit8, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - MatrixWidget.disconnect ( self.floatEdit9, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - MatrixWidget.disconnect ( self.floatEdit10, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - MatrixWidget.disconnect ( self.floatEdit11, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - - MatrixWidget.disconnect ( self.floatEdit12, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - MatrixWidget.disconnect ( self.floatEdit13, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - MatrixWidget.disconnect ( self.floatEdit14, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - MatrixWidget.disconnect ( self.floatEdit15, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - - MatrixWidget.disconnect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) - # - # onFloatEditEditingFinished - # - def onFloatEditEditingFinished ( self ) : - # - floatStr0 = self.floatEdit0.text () - floatStr1 = self.floatEdit1.text () - floatStr2 = self.floatEdit2.text () - floatStr3 = self.floatEdit3.text () - f0 = floatStr0.toFloat ()[0] - f1 = floatStr1.toFloat ()[0] - f2 = floatStr2.toFloat ()[0] - f3 = floatStr3.toFloat ()[0] - - #self.widget.param.value[ 0 ] = [ f0, f1, f2, f3 ] - - floatStr0 = self.floatEdit4.text () - floatStr1 = self.floatEdit5.text () - floatStr2 = self.floatEdit6.text () - floatStr3 = self.floatEdit7.text () - f4 = floatStr0.toFloat ()[0] - f5 = floatStr1.toFloat ()[0] - f6 = floatStr2.toFloat ()[0] - f7 = floatStr3.toFloat ()[0] - - #self.widget.param.value[ 1 ] = [ f4, f5, f6, f7 ] - - floatStr0 = self.floatEdit8.text () - floatStr1 = self.floatEdit9.text () - floatStr2 = self.floatEdit10.text () - floatStr3 = self.floatEdit11.text () - f8 = floatStr0.toFloat ()[0] - f9 = floatStr1.toFloat ()[0] - f10 = floatStr2.toFloat ()[0] - f11 = floatStr3.toFloat ()[0] - - #self.widget.param.value[ 2 ] = [ f8, f9, f10, f11 ] - - floatStr0 = self.floatEdit12.text () - floatStr1 = self.floatEdit13.text () - floatStr2 = self.floatEdit14.text () - floatStr3 = self.floatEdit15.text () - f12 = floatStr0.toFloat ()[0] - f13 = floatStr1.toFloat ()[0] - f14 = floatStr2.toFloat ()[0] - f15 = floatStr3.toFloat ()[0] - - #self.widget.param.value[ 3 ] = [ f12, f13, f14, f15 ] - - self.widget.param.setValue ( [ [ f0, f1, f2, f3 ], [ f4, f5, f6, f7 ], [ f8, f9, f10, f11 ],[ f12, f13, f14, f15 ] ] ) - # - # onCurrentIndexChanged - # - def onCurrentIndexChanged ( self, idx ) : - # - space = str ( self.selector.currentText () ) - if space == 'current' : space = None - self.widget.param.space = space - # - # updateGui - # value = [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]] - # - def updateGui ( self, value ) : - # - self.floatEdit0.setText ( QtCore.QString.number ( value [0][0], 'f', 3 ) ) - self.floatEdit1.setText ( QtCore.QString.number ( value [0][1], 'f', 3 ) ) - self.floatEdit2.setText ( QtCore.QString.number ( value [0][2], 'f', 3 ) ) - self.floatEdit3.setText ( QtCore.QString.number ( value [0][3], 'f', 3 ) ) - - self.floatEdit4.setText ( QtCore.QString.number ( value [1][0], 'f', 3 ) ) - self.floatEdit5.setText ( QtCore.QString.number ( value [1][1], 'f', 3 ) ) - self.floatEdit6.setText ( QtCore.QString.number ( value [1][2], 'f', 3 ) ) - self.floatEdit7.setText ( QtCore.QString.number ( value [1][3], 'f', 3 ) ) - - self.floatEdit8.setText ( QtCore.QString.number ( value [2][0], 'f', 3 ) ) - self.floatEdit9.setText ( QtCore.QString.number ( value [2][1], 'f', 3 ) ) - self.floatEdit10.setText ( QtCore.QString.number ( value [2][2], 'f', 3 ) ) - self.floatEdit11.setText ( QtCore.QString.number ( value [2][3], 'f', 3 ) ) - - self.floatEdit12.setText ( QtCore.QString.number ( value [3][0], 'f', 3 ) ) - self.floatEdit13.setText ( QtCore.QString.number ( value [3][1], 'f', 3 ) ) - self.floatEdit14.setText ( QtCore.QString.number ( value [3][2], 'f', 3 ) ) - self.floatEdit15.setText ( QtCore.QString.number ( value [3][3], 'f', 3 ) ) + # + # setupUi + # + def setupUi ( self, MatrixWidget ) : + # + hl = QtModule.QHBoxLayout () + self.widget = MatrixWidget + + self.floatEdit0 = QtModule.QLineEdit( MatrixWidget ) + self.floatEdit1 = QtModule.QLineEdit( MatrixWidget ) + self.floatEdit2 = QtModule.QLineEdit( MatrixWidget ) + self.floatEdit3 = QtModule.QLineEdit( MatrixWidget ) + + self.floatEdit4 = QtModule.QLineEdit( MatrixWidget ) + self.floatEdit5 = QtModule.QLineEdit( MatrixWidget ) + self.floatEdit6 = QtModule.QLineEdit( MatrixWidget ) + self.floatEdit7 = QtModule.QLineEdit( MatrixWidget ) + + self.floatEdit8 = QtModule.QLineEdit( MatrixWidget ) + self.floatEdit9 = QtModule.QLineEdit( MatrixWidget ) + self.floatEdit10 = QtModule.QLineEdit( MatrixWidget ) + self.floatEdit11 = QtModule.QLineEdit( MatrixWidget ) + + self.floatEdit12 = QtModule.QLineEdit( MatrixWidget ) + self.floatEdit13 = QtModule.QLineEdit( MatrixWidget ) + self.floatEdit14 = QtModule.QLineEdit( MatrixWidget ) + self.floatEdit15 = QtModule.QLineEdit( MatrixWidget ) + + + self.floatEdit0.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit1.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit2.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit3.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + + self.floatEdit4.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit5.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit6.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit7.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + + self.floatEdit8.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit9.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit10.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit11.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + + self.floatEdit12.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit13.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit14.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit15.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + + + self.floatEdit0.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit1.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit2.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit3.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + + self.floatEdit4.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit5.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit6.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit7.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + + self.floatEdit8.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit9.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit10.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit11.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + + self.floatEdit12.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit13.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit14.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit15.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + + self.selector = QtModule.QComboBox ( MatrixWidget ) + self.selector.setEditable ( False ) + #self.selector.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) + self.selector.setMaximumSize ( QtCore.QSize( UI.MAX, UI.COMBO_HEIGHT ) ) + + for label in [ "current", "shader", "object", "camera", "world", "raster", "NDC", "screen" ] : + self.selector.addItem ( label ) + if self.widget.param.space != None : + self.selector.setCurrentIndex( self.selector.findText ( self.widget.param.space ) ) + + spacer0 = QtModule.QSpacerItem ( 20, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum ) + + hl.addWidget ( self.selector ) + hl.addItem ( spacer0 ) + self.widget.param_vl.addLayout ( hl ) + + hl1 = QtModule.QHBoxLayout () + hl1.setSpacing ( UI.SPACING ) + hl1.setMargin ( 0 ) + hl1.addWidget ( self.floatEdit0 ) + hl1.addWidget ( self.floatEdit1 ) + hl1.addWidget ( self.floatEdit2 ) + hl1.addWidget ( self.floatEdit3 ) + spacer1 = QtModule.QSpacerItem ( 20, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum ) + hl1.addItem ( spacer1 ) + + self.widget.param_vl.addLayout ( hl1 ) + + hl2 = QtModule.QHBoxLayout () + hl2.setSpacing ( UI.SPACING ) + hl2.setMargin ( 0 ) + hl2.addWidget ( self.floatEdit4 ) + hl2.addWidget ( self.floatEdit5 ) + hl2.addWidget ( self.floatEdit6 ) + hl2.addWidget ( self.floatEdit7 ) + spacer2 = QtModule.QSpacerItem ( 20, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum ) + hl2.addItem ( spacer2 ) + + self.widget.param_vl.addLayout ( hl2 ) + + hl3 = QtModule.QHBoxLayout () + hl3.setSpacing ( UI.SPACING ) + hl3.setMargin ( 0 ) + hl3.addWidget ( self.floatEdit8 ) + hl3.addWidget ( self.floatEdit9 ) + hl3.addWidget ( self.floatEdit10 ) + hl3.addWidget ( self.floatEdit11 ) + spacer3 = QtModule.QSpacerItem ( 20, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum ) + hl3.addItem ( spacer3 ) + + self.widget.param_vl.addLayout ( hl3 ) + + hl4 = QtModule.QHBoxLayout () + hl4.setSpacing ( UI.SPACING ) + hl4.setMargin ( 0 ) + hl4.addWidget ( self.floatEdit12 ) + hl4.addWidget ( self.floatEdit13 ) + hl4.addWidget ( self.floatEdit14 ) + hl4.addWidget ( self.floatEdit15 ) + spacer4 = QtModule.QSpacerItem ( 20, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum ) + hl4.addItem ( spacer4 ) + + self.widget.param_vl.addLayout ( hl4 ) + + QtCore.QMetaObject.connectSlotsByName ( MatrixWidget ) + self.connectSignals ( MatrixWidget ) + # + # connectSignals + # + def connectSignals ( self, MatrixWidget ) : + # + if QtCore.QT_VERSION < 50000 : + MatrixWidget.connect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + MatrixWidget.connect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + MatrixWidget.connect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + MatrixWidget.connect ( self.floatEdit3, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + + MatrixWidget.connect ( self.floatEdit4, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + MatrixWidget.connect ( self.floatEdit5, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + MatrixWidget.connect ( self.floatEdit6, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + MatrixWidget.connect ( self.floatEdit7, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + + MatrixWidget.connect ( self.floatEdit8, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + MatrixWidget.connect ( self.floatEdit9, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + MatrixWidget.connect ( self.floatEdit10, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + MatrixWidget.connect ( self.floatEdit11, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + + MatrixWidget.connect ( self.floatEdit12, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + MatrixWidget.connect ( self.floatEdit13, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + MatrixWidget.connect ( self.floatEdit14, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + MatrixWidget.connect ( self.floatEdit15, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + + MatrixWidget.connect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) + else : + self.floatEdit0.editingFinished.connect ( self.onFloatEditEditingFinished ) + self.floatEdit1.editingFinished.connect ( self.onFloatEditEditingFinished ) + self.floatEdit2.editingFinished.connect ( self.onFloatEditEditingFinished ) + self.floatEdit3.editingFinished.connect ( self.onFloatEditEditingFinished ) + + self.floatEdit4.editingFinished.connect ( self.onFloatEditEditingFinished ) + self.floatEdit5.editingFinished.connect ( self.onFloatEditEditingFinished ) + self.floatEdit6.editingFinished.connect ( self.onFloatEditEditingFinished ) + self.floatEdit7.editingFinished.connect ( self.onFloatEditEditingFinished ) + + self.floatEdit8.editingFinished.connect ( self.onFloatEditEditingFinished ) + self.floatEdit9.editingFinished.connect ( self.onFloatEditEditingFinished ) + self.floatEdit10.editingFinished.connect ( self.onFloatEditEditingFinished ) + self.floatEdit11.editingFinished.connect ( self.onFloatEditEditingFinished ) + + self.floatEdit12.editingFinished.connect ( self.onFloatEditEditingFinished ) + self.floatEdit13.editingFinished.connect ( self.onFloatEditEditingFinished ) + self.floatEdit14.editingFinished.connect ( self.onFloatEditEditingFinished ) + self.floatEdit15.editingFinished.connect ( self.onFloatEditEditingFinished ) + + self.selector.activated.connect ( self.onCurrentIndexChanged ) + # + # disconnectSignals + # + def disconnectSignals ( self, MatrixWidget ) : + # + if QtCore.QT_VERSION < 50000 : + MatrixWidget.disconnect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + MatrixWidget.disconnect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + MatrixWidget.disconnect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + MatrixWidget.disconnect ( self.floatEdit3, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + + MatrixWidget.disconnect ( self.floatEdit4, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + MatrixWidget.disconnect ( self.floatEdit5, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + MatrixWidget.disconnect ( self.floatEdit6, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + MatrixWidget.disconnect ( self.floatEdit7, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + + MatrixWidget.disconnect ( self.floatEdit8, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + MatrixWidget.disconnect ( self.floatEdit9, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + MatrixWidget.disconnect ( self.floatEdit10, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + MatrixWidget.disconnect ( self.floatEdit11, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + + MatrixWidget.disconnect ( self.floatEdit12, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + MatrixWidget.disconnect ( self.floatEdit13, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + MatrixWidget.disconnect ( self.floatEdit14, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + MatrixWidget.disconnect ( self.floatEdit15, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + + MatrixWidget.disconnect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) + else : + self.floatEdit0.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + self.floatEdit1.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + self.floatEdit2.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + self.floatEdit3.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + + self.floatEdit4.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + self.floatEdit5.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + self.floatEdit6.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + self.floatEdit7.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + + self.floatEdit8.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + self.floatEdit9.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + self.floatEdit10.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + self.floatEdit11.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + + self.floatEdit12.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + self.floatEdit13.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + self.floatEdit14.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + self.floatEdit15.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + + self.selector.activated.connect ( self.onCurrentIndexChanged ) + # + # onFloatEditEditingFinished + # + def onFloatEditEditingFinished ( self ) : + # + floatStr0 = self.floatEdit0.text () + floatStr1 = self.floatEdit1.text () + floatStr2 = self.floatEdit2.text () + floatStr3 = self.floatEdit3.text () + f0 = floatStr0.toFloat ()[0] + f1 = floatStr1.toFloat ()[0] + f2 = floatStr2.toFloat ()[0] + f3 = floatStr3.toFloat ()[0] + + #self.widget.param.value[ 0 ] = [ f0, f1, f2, f3 ] + + floatStr0 = self.floatEdit4.text () + floatStr1 = self.floatEdit5.text () + floatStr2 = self.floatEdit6.text () + floatStr3 = self.floatEdit7.text () + f4 = floatStr0.toFloat ()[0] + f5 = floatStr1.toFloat ()[0] + f6 = floatStr2.toFloat ()[0] + f7 = floatStr3.toFloat ()[0] + + #self.widget.param.value[ 1 ] = [ f4, f5, f6, f7 ] + + floatStr0 = self.floatEdit8.text () + floatStr1 = self.floatEdit9.text () + floatStr2 = self.floatEdit10.text () + floatStr3 = self.floatEdit11.text () + f8 = floatStr0.toFloat ()[0] + f9 = floatStr1.toFloat ()[0] + f10 = floatStr2.toFloat ()[0] + f11 = floatStr3.toFloat ()[0] + + #self.widget.param.value[ 2 ] = [ f8, f9, f10, f11 ] + + floatStr0 = self.floatEdit12.text () + floatStr1 = self.floatEdit13.text () + floatStr2 = self.floatEdit14.text () + floatStr3 = self.floatEdit15.text () + f12 = floatStr0.toFloat ()[0] + f13 = floatStr1.toFloat ()[0] + f14 = floatStr2.toFloat ()[0] + f15 = floatStr3.toFloat ()[0] + + #self.widget.param.value[ 3 ] = [ f12, f13, f14, f15 ] + + self.widget.param.setValue ( [ [ f0, f1, f2, f3 ], [ f4, f5, f6, f7 ], [ f8, f9, f10, f11 ],[ f12, f13, f14, f15 ] ] ) + # + # onCurrentIndexChanged + # + def onCurrentIndexChanged ( self, idx ) : + # + space = str ( self.selector.currentText () ) + if space == 'current' : space = None + self.widget.param.space = space + # + # updateGui + # value = [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]] + # + def updateGui ( self, value ) : + # + self.floatEdit0.setText ( QtCore.QString.number ( value [0][0], 'f', 3 ) ) + self.floatEdit1.setText ( QtCore.QString.number ( value [0][1], 'f', 3 ) ) + self.floatEdit2.setText ( QtCore.QString.number ( value [0][2], 'f', 3 ) ) + self.floatEdit3.setText ( QtCore.QString.number ( value [0][3], 'f', 3 ) ) + + self.floatEdit4.setText ( QtCore.QString.number ( value [1][0], 'f', 3 ) ) + self.floatEdit5.setText ( QtCore.QString.number ( value [1][1], 'f', 3 ) ) + self.floatEdit6.setText ( QtCore.QString.number ( value [1][2], 'f', 3 ) ) + self.floatEdit7.setText ( QtCore.QString.number ( value [1][3], 'f', 3 ) ) + + self.floatEdit8.setText ( QtCore.QString.number ( value [2][0], 'f', 3 ) ) + self.floatEdit9.setText ( QtCore.QString.number ( value [2][1], 'f', 3 ) ) + self.floatEdit10.setText ( QtCore.QString.number ( value [2][2], 'f', 3 ) ) + self.floatEdit11.setText ( QtCore.QString.number ( value [2][3], 'f', 3 ) ) + + self.floatEdit12.setText ( QtCore.QString.number ( value [3][0], 'f', 3 ) ) + self.floatEdit13.setText ( QtCore.QString.number ( value [3][1], 'f', 3 ) ) + self.floatEdit14.setText ( QtCore.QString.number ( value [3][2], 'f', 3 ) ) + self.floatEdit15.setText ( QtCore.QString.number ( value [3][3], 'f', 3 ) ) diff --git a/gui/params/NormalWidget.py b/gui/params/NormalWidget.py index d522a29..ffab3e8 100644 --- a/gui/params/NormalWidget.py +++ b/gui/params/NormalWidget.py @@ -6,108 +6,126 @@ from core.mePyQt import QtGui, QtCore import gui.ui_settings as UI -from paramWidget import ParamWidget +from paramWidget import ParamWidget + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets # # NormalWidget # class NormalWidget ( ParamWidget ) : - # - # buildGui - # - def buildGui ( self ) : - # - self.ui = Ui_NormalWidget_field () - self.ui.setupUi ( self ) + # + # buildGui + # + def buildGui ( self ) : + # + self.ui = Ui_NormalWidget_field () + self.ui.setupUi ( self ) # # Ui_NormalWidget_field # class Ui_NormalWidget_field ( object ) : - # - # setupUi - # - def setupUi ( self, NormalWidget ) : - # - hl = QtGui.QHBoxLayout () - self.widget = NormalWidget - - self.floatEdit0 = QtGui.QLineEdit( NormalWidget ) - self.floatEdit1 = QtGui.QLineEdit( NormalWidget ) - self.floatEdit2 = QtGui.QLineEdit( NormalWidget ) - - self.floatEdit0.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) # UI.EDIT_WIDTH - self.floatEdit1.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit2.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - - self.floatEdit0.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit1.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit2.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - - self.selector = QtGui.QComboBox ( NormalWidget ) - self.selector.setEditable ( False ) - #self.selector.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) - self.selector.setMaximumSize ( QtCore.QSize( UI.MAX, UI.COMBO_HEIGHT ) ) - - for label in [ "current", "shader", "object", "camera", "world", "raster", "NDC", "screen" ] : - self.selector.addItem ( label ) - if self.widget.param.space != None : - self.selector.setCurrentIndex( self.selector.findText ( self.widget.param.space ) ) - - spacer = QtGui.QSpacerItem ( 20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum ) - - hl.addWidget ( self.floatEdit0 ) - hl.addWidget ( self.floatEdit1 ) - hl.addWidget ( self.floatEdit2 ) - hl.addWidget ( self.selector ) - hl.addItem ( spacer ) - - self.widget.param_vl.addLayout ( hl ) - - QtCore.QMetaObject.connectSlotsByName ( NormalWidget ) - self.connectSignals ( NormalWidget ) - # - # connectSignals - # - def connectSignals ( self, NormalWidget ) : - # - NormalWidget.connect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - NormalWidget.connect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - NormalWidget.connect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - NormalWidget.connect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) - # - # disconnectSignals - # - def disconnectSignals ( self, NormalWidget ) : - # - NormalWidget.disconnect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - NormalWidget.disconnect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - NormalWidget.disconnect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - NormalWidget.disconnect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) - # - # onFloatEditEditingFinished - # - def onFloatEditEditingFinished ( self ) : - # - floatStr0 = self.floatEdit0.text () - floatStr1 = self.floatEdit1.text () - floatStr2 = self.floatEdit2.text () - f0 = floatStr0.toFloat ()[0] - f1 = floatStr1.toFloat ()[0] - f2 = floatStr2.toFloat ()[0] - - self.widget.param.setValue ( [ f0, f1, f2 ] ) - # - # onCurrentIndexChanged - # - def onCurrentIndexChanged ( self, idx ) : - # - space = str ( self.selector.currentText () ) - if space == 'current' : space = None - self.widget.param.space = space - # - # updateGui - # - def updateGui ( self, value ) : - # - self.floatEdit0.setText ( QtCore.QString.number ( value [0], 'f', 3 ) ) - self.floatEdit1.setText ( QtCore.QString.number ( value [1], 'f', 3 ) ) - self.floatEdit2.setText ( QtCore.QString.number ( value [2], 'f', 3 ) ) + # + # setupUi + # + def setupUi ( self, NormalWidget ) : + # + hl = QtModule.QHBoxLayout () + self.widget = NormalWidget + + self.floatEdit0 = QtGui.QLineEdit( NormalWidget ) + self.floatEdit1 = QtGui.QLineEdit( NormalWidget ) + self.floatEdit2 = QtGui.QLineEdit( NormalWidget ) + + self.floatEdit0.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) # UI.EDIT_WIDTH + self.floatEdit1.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit2.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + + self.floatEdit0.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit1.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit2.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + + self.selector = QtModule.QComboBox ( NormalWidget ) + self.selector.setEditable ( False ) + #self.selector.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) + self.selector.setMaximumSize ( QtCore.QSize( UI.MAX, UI.COMBO_HEIGHT ) ) + + for label in [ "current", "shader", "object", "camera", "world", "raster", "NDC", "screen" ] : + self.selector.addItem ( label ) + if self.widget.param.space != None : + self.selector.setCurrentIndex( self.selector.findText ( self.widget.param.space ) ) + + spacer = QtModule.QSpacerItem ( 20, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum ) + + hl.addWidget ( self.floatEdit0 ) + hl.addWidget ( self.floatEdit1 ) + hl.addWidget ( self.floatEdit2 ) + hl.addWidget ( self.selector ) + hl.addItem ( spacer ) + + self.widget.param_vl.addLayout ( hl ) + + QtCore.QMetaObject.connectSlotsByName ( NormalWidget ) + self.connectSignals ( NormalWidget ) + # + # connectSignals + # + def connectSignals ( self, NormalWidget ) : + # + if QtCore.QT_VERSION < 50000 : + NormalWidget.connect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + NormalWidget.connect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + NormalWidget.connect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + NormalWidget.connect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) + else : + self.floatEdit0.editingFinished.connect ( self.onFloatEditEditingFinished ) + self.floatEdit1.editingFinished.connect ( self.onFloatEditEditingFinished ) + self.floatEdit2.editingFinished.connect ( self.onFloatEditEditingFinished ) + self.selector.activated.connect ( self.onCurrentIndexChanged ) + # + # disconnectSignals + # + def disconnectSignals ( self, NormalWidget ) : + # + if QtCore.QT_VERSION < 50000 : + NormalWidget.disconnect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + NormalWidget.disconnect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + NormalWidget.disconnect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + NormalWidget.disconnect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) + else : + self.floatEdit0.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + self.floatEdit1.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + self.floatEdit2.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + self.selector.activated.disconnect ( self.onCurrentIndexChanged ) + # + # onFloatEditEditingFinished + # + def onFloatEditEditingFinished ( self ) : + # + floatStr0 = self.floatEdit0.text () + floatStr1 = self.floatEdit1.text () + floatStr2 = self.floatEdit2.text () + f0 = floatStr0.toFloat ()[0] + f1 = floatStr1.toFloat ()[0] + f2 = floatStr2.toFloat ()[0] + + self.widget.param.setValue ( [ f0, f1, f2 ] ) + # + # onCurrentIndexChanged + # + def onCurrentIndexChanged ( self, idx ) : + # + space = str ( self.selector.currentText () ) + if space == 'current' : space = None + self.widget.param.space = space + # + # updateGui + # + def updateGui ( self, value ) : + # + self.floatEdit0.setText ( QtCore.QString.number ( value [0], 'f', 3 ) ) + self.floatEdit1.setText ( QtCore.QString.number ( value [1], 'f', 3 ) ) + self.floatEdit2.setText ( QtCore.QString.number ( value [2], 'f', 3 ) ) diff --git a/gui/params/PointWidget.py b/gui/params/PointWidget.py index 2264d8f..f6087bb 100644 --- a/gui/params/PointWidget.py +++ b/gui/params/PointWidget.py @@ -6,108 +6,126 @@ from core.mePyQt import QtGui, QtCore import gui.ui_settings as UI -from paramWidget import ParamWidget +from paramWidget import ParamWidget + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets # # PointWidget # class PointWidget ( ParamWidget ) : - # - # PointWidget - # - def buildGui ( self ) : - # - self.ui = Ui_PointWidget_field () - self.ui.setupUi ( self ) + # + # PointWidget + # + def buildGui ( self ) : + # + self.ui = Ui_PointWidget_field () + self.ui.setupUi ( self ) # # Ui_PointWidget_field # class Ui_PointWidget_field ( object ) : - # - # setupUi - # - def setupUi ( self, PointWidget ) : - # - hl = QtGui.QHBoxLayout () - self.widget = PointWidget - - self.floatEdit0 = QtGui.QLineEdit ( PointWidget ) - self.floatEdit1 = QtGui.QLineEdit ( PointWidget ) - self.floatEdit2 = QtGui.QLineEdit ( PointWidget ) - - self.floatEdit0.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) # UI.EDIT_WIDTH - self.floatEdit1.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit2.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - - self.floatEdit0.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit1.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit2.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - - self.selector = QtGui.QComboBox ( PointWidget ) - self.selector.setEditable ( False ) - #self.selector.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) - self.selector.setMaximumSize ( QtCore.QSize( UI.MAX, UI.COMBO_HEIGHT ) ) - - for label in [ "current", "shader", "object", "camera", "world", "raster", "NDC", "screen" ] : - self.selector.addItem ( label ) - if self.widget.param.space != None : - self.selector.setCurrentIndex( self.selector.findText ( self.widget.param.space ) ) - - spacer = QtGui.QSpacerItem ( 20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum ) - - hl.addWidget ( self.floatEdit0 ) - hl.addWidget ( self.floatEdit1 ) - hl.addWidget ( self.floatEdit2 ) - hl.addWidget ( self.selector ) - hl.addItem ( spacer ) - - self.widget.param_vl.addLayout ( hl ) - - QtCore.QMetaObject.connectSlotsByName ( PointWidget ) - self.connectSignals ( PointWidget ) - # - # connectSignals - # - def connectSignals ( self, PointWidget ) : - # - PointWidget.connect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - PointWidget.connect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - PointWidget.connect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - PointWidget.connect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) - # - # disconnectSignals - # - def disconnectSignals ( self, PointWidget ) : - # - PointWidget.disconnect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - PointWidget.disconnect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - PointWidget.disconnect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - PointWidget.disconnect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) - # - # onFloatEditEditingFinished - # - def onFloatEditEditingFinished ( self ) : - # - floatStr0 = self.floatEdit0.text () - floatStr1 = self.floatEdit1.text () - floatStr2 = self.floatEdit2.text () - f0 = floatStr0.toFloat ()[0] - f1 = floatStr1.toFloat ()[0] - f2 = floatStr2.toFloat ()[0] - - self.widget.param.setValue ( [ f0, f1, f2 ] ) - # - # onCurrentIndexChanged - # - def onCurrentIndexChanged ( self, idx ) : - # - space = str ( self.selector.currentText () ) - if space == 'current' : space = None - self.widget.param.space = space - # - # updateGui - # - def updateGui ( self, value ) : - # - self.floatEdit0.setText ( QtCore.QString.number( value [0], 'f', 3 ) ) - self.floatEdit1.setText ( QtCore.QString.number( value [1], 'f', 3 ) ) - self.floatEdit2.setText ( QtCore.QString.number( value [2], 'f', 3 ) ) + # + # setupUi + # + def setupUi ( self, PointWidget ) : + # + hl = QtModule.QHBoxLayout () + self.widget = PointWidget + + self.floatEdit0 = QtModule.QLineEdit ( PointWidget ) + self.floatEdit1 = QtModule.QLineEdit ( PointWidget ) + self.floatEdit2 = QtModule.QLineEdit ( PointWidget ) + + self.floatEdit0.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) # UI.EDIT_WIDTH + self.floatEdit1.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit2.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + + self.floatEdit0.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit1.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit2.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + + self.selector = QtModule.QComboBox ( PointWidget ) + self.selector.setEditable ( False ) + #self.selector.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) + self.selector.setMaximumSize ( QtCore.QSize( UI.MAX, UI.COMBO_HEIGHT ) ) + + for label in [ "current", "shader", "object", "camera", "world", "raster", "NDC", "screen" ] : + self.selector.addItem ( label ) + if self.widget.param.space != None : + self.selector.setCurrentIndex ( self.selector.findText ( self.widget.param.space ) ) + + spacer = QtModule.QSpacerItem ( 20, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum ) + + hl.addWidget ( self.floatEdit0 ) + hl.addWidget ( self.floatEdit1 ) + hl.addWidget ( self.floatEdit2 ) + hl.addWidget ( self.selector ) + hl.addItem ( spacer ) + + self.widget.param_vl.addLayout ( hl ) + + QtCore.QMetaObject.connectSlotsByName ( PointWidget ) + self.connectSignals ( PointWidget ) + # + # connectSignals + # + def connectSignals ( self, PointWidget ) : + # + if QtCore.QT_VERSION < 50000 : + PointWidget.connect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + PointWidget.connect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + PointWidget.connect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + PointWidget.connect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) + else : + self.floatEdit0.editingFinished.connect ( self.onFloatEditEditingFinished ) + self.floatEdit1,editingFinished.connect ( self.onFloatEditEditingFinished ) + self.floatEdit2.editingFinished.connect ( self.onFloatEditEditingFinished ) + self.selector.activated.connect ( self.onCurrentIndexChanged ) + # + # disconnectSignals + # + def disconnectSignals ( self, PointWidget ) : + # + if QtCore.QT_VERSION < 50000 : + PointWidget.disconnect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + PointWidget.disconnect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + PointWidget.disconnect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + PointWidget.disconnect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) + else : + self.floatEdit0.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + self.floatEdit1,editingFinished.disconnect ( self.onFloatEditEditingFinished ) + self.floatEdit2.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + self.selector.activated.disconnect ( self.onCurrentIndexChanged ) + # + # onFloatEditEditingFinished + # + def onFloatEditEditingFinished ( self ) : + # + floatStr0 = self.floatEdit0.text () + floatStr1 = self.floatEdit1.text () + floatStr2 = self.floatEdit2.text () + f0 = floatStr0.toFloat ()[0] + f1 = floatStr1.toFloat ()[0] + f2 = floatStr2.toFloat ()[0] + + self.widget.param.setValue ( [ f0, f1, f2 ] ) + # + # onCurrentIndexChanged + # + def onCurrentIndexChanged ( self, idx ) : + # + space = str ( self.selector.currentText () ) + if space == 'current' : space = None + self.widget.param.space = space + # + # updateGui + # + def updateGui ( self, value ) : + # + self.floatEdit0.setText ( QtCore.QString.number( value [0], 'f', 3 ) ) + self.floatEdit1.setText ( QtCore.QString.number( value [1], 'f', 3 ) ) + self.floatEdit2.setText ( QtCore.QString.number( value [2], 'f', 3 ) ) diff --git a/gui/params/StringWidget.py b/gui/params/StringWidget.py index b643dd9..2dbc947 100644 --- a/gui/params/StringWidget.py +++ b/gui/params/StringWidget.py @@ -8,218 +8,248 @@ from global_vars import app_global_vars, DEBUG_MODE import gui.ui_settings as UI from paramWidget import ParamWidget + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets # # StringWidget # class StringWidget ( ParamWidget ) : - # - # buildGui - # - def buildGui ( self ) : - # - if not self.ignoreSubtype : - if self.param.subtype == 'selector': - self.ui = Ui_StringWidget_selector () - elif self.param.subtype == 'file': - self.ui = Ui_StringWidget_file () - else: - self.ui = Ui_StringWidget_field () - else : - self.ui = Ui_StringWidget_field () - self.ui.setupUi ( self ) + # + # buildGui + # + def buildGui ( self ) : + # + if not self.ignoreSubtype : + if self.param.subtype == 'selector': + self.ui = Ui_StringWidget_selector () + elif self.param.subtype == 'file': + self.ui = Ui_StringWidget_file () + else: + self.ui = Ui_StringWidget_field () + else : + self.ui = Ui_StringWidget_field () + self.ui.setupUi ( self ) # # Ui_StringWidget_field # class Ui_StringWidget_field ( object ) : - # - # setupUi - # - def setupUi ( self, StringWidget ) : - # - hl = QtGui.QHBoxLayout () - hl.setStretch ( 1, 1 ) - - self.widget = StringWidget - - self.stringEdit = QtGui.QLineEdit ( StringWidget ) - - self.stringEdit.setMinimumSize ( QtCore.QSize ( UI.LABEL_WIDTH, UI.HEIGHT ) ) # UI.EDIT_WIDTH - self.stringEdit.setMaximumSize ( QtCore.QSize ( UI.MAX, UI.HEIGHT ) ) - - hl.addWidget ( self.stringEdit ) - self.widget.param_vl.addLayout ( hl ) - - QtCore.QMetaObject.connectSlotsByName ( StringWidget ) - self.connectSignals ( StringWidget ) - # - # connectSignals - # - def connectSignals ( self, StringWidget ) : - # - StringWidget.connect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) - # - # disconnectSignals - # - def disconnectSignals ( self, StringWidget ) : - # - StringWidget.disconnect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) - # - # onStringEditEditingFinished - # - def onStringEditEditingFinished ( self ) : - # - stringValue = self.stringEdit.text () - self.widget.param.setValue ( str ( stringValue ) ) - # - # updateGui - # - def updateGui ( self, value ) : - # - self.stringEdit.setText ( value ) + # + # setupUi + # + def setupUi ( self, StringWidget ) : + # + hl = QtModule.QHBoxLayout () + hl.setStretch ( 1, 1 ) + + self.widget = StringWidget + + self.stringEdit = QtModule.QLineEdit ( StringWidget ) + + self.stringEdit.setMinimumSize ( QtCore.QSize ( UI.LABEL_WIDTH, UI.HEIGHT ) ) # UI.EDIT_WIDTH + self.stringEdit.setMaximumSize ( QtCore.QSize ( UI.MAX, UI.HEIGHT ) ) + + hl.addWidget ( self.stringEdit ) + self.widget.param_vl.addLayout ( hl ) + + QtCore.QMetaObject.connectSlotsByName ( StringWidget ) + self.connectSignals ( StringWidget ) + # + # connectSignals + # + def connectSignals ( self, StringWidget ) : + # + if QtCore.QT_VERSION < 50000 : + StringWidget.connect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) + else : + self.stringEdit.editingFinished.connect ( self.onStringEditEditingFinished ) + # + # disconnectSignals + # + def disconnectSignals ( self, StringWidget ) : + # + if QtCore.QT_VERSION < 50000 : + StringWidget.disconnect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) + else : + self.stringEdit.editingFinished.disconnect ( self.onStringEditEditingFinished ) + # + # onStringEditEditingFinished + # + def onStringEditEditingFinished ( self ) : + # + stringValue = self.stringEdit.text () + self.widget.param.setValue ( str ( stringValue ) ) + # + # updateGui + # + def updateGui ( self, value ) : + # + self.stringEdit.setText ( value ) # # Ui_StringWidget_selector # class Ui_StringWidget_selector ( object ) : - # - # setupUi - # - def setupUi ( self, StringWidget ) : - # - hl = QtGui.QHBoxLayout () - self.widget = StringWidget - - self.selector = QtGui.QComboBox ( StringWidget ) - self.selector.setEditable ( False ) - self.selector.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) - self.selector.setMaximumSize ( QtCore.QSize( UI.MAX, UI.COMBO_HEIGHT ) ) - - rangeList = self.widget.param.getRangeValues () - - for ( label, value ) in rangeList : - #print "label = %s value = %s" % ( label, value ) - self.selector.addItem ( label, value ) - - spacer = QtGui.QSpacerItem ( UI.HEIGHT, UI.HEIGHT, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum ) - - hl.addWidget ( self.selector ) - hl.addItem ( spacer ) - self.widget.param_vl.addLayout ( hl ) - - QtCore.QMetaObject.connectSlotsByName ( StringWidget ) - self.connectSignals ( StringWidget ) - # - # connectSignals - # - def connectSignals ( self, StringWidget ) : - # - StringWidget.connect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) - # - # disconnectSignals - # - def disconnectSignals ( self, StringWidget ) : - # - StringWidget.disconnect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) - # - # onCurrentIndexChanged - # - def onCurrentIndexChanged ( self, idx ) : - pass - stringValue = self.selector.itemData ( idx ).toString () - #print ">> Ui_StringWidget_selector idx = %d setValue = %s" % ( idx, stringValue ) - self.widget.param.setValue ( str ( stringValue ) ) - # - # updateGui - # - def updateGui ( self, setValue ) : - # - currentIdx = -1 - i = 0 - rangeList = self.widget.param.getRangeValues () - for ( label, value ) in rangeList : - if setValue == value : - currentIdx = i - break - i += 1 - self.selector.setCurrentIndex ( currentIdx ) + # + # setupUi + # + def setupUi ( self, StringWidget ) : + # + hl = QtModule.QHBoxLayout () + self.widget = StringWidget + + self.selector = QtModule.QComboBox ( StringWidget ) + self.selector.setEditable ( False ) + self.selector.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) + self.selector.setMaximumSize ( QtCore.QSize( UI.MAX, UI.COMBO_HEIGHT ) ) + + rangeList = self.widget.param.getRangeValues () + + for ( label, value ) in rangeList : + #print "label = %s value = %s" % ( label, value ) + self.selector.addItem ( label, value ) + + spacer = QtModule.QSpacerItem ( UI.HEIGHT, UI.HEIGHT, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum ) + + hl.addWidget ( self.selector ) + hl.addItem ( spacer ) + self.widget.param_vl.addLayout ( hl ) + + QtCore.QMetaObject.connectSlotsByName ( StringWidget ) + self.connectSignals ( StringWidget ) + # + # connectSignals + # + def connectSignals ( self, StringWidget ) : + # + if QtCore.QT_VERSION < 50000 : + StringWidget.connect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) + else : + self.selector.activated.connect ( self.onCurrentIndexChanged ) + # + # disconnectSignals + # + def disconnectSignals ( self, StringWidget ) : + # + if QtCore.QT_VERSION < 50000 : + StringWidget.disconnect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) + else : + self.selector.activated.disconnect ( self.onCurrentIndexChanged ) + # + # onCurrentIndexChanged + # + def onCurrentIndexChanged ( self, idx ) : + # + #pass + if QtCore.QT_VERSION < 50000 : + stringValue = self.selector.itemData ( idx ).toString () + else : + stringValue = str ( self.selector.itemData ( idx ) ) + #print ">> Ui_StringWidget_selector idx = %d setValue = %s" % ( idx, stringValue ) + self.widget.param.setValue ( str ( stringValue ) ) + # + # updateGui + # + def updateGui ( self, setValue ) : + # + currentIdx = -1 + i = 0 + rangeList = self.widget.param.getRangeValues () + for ( label, value ) in rangeList : + if setValue == value : + currentIdx = i + break + i += 1 + self.selector.setCurrentIndex ( currentIdx ) # # Ui_StringWidget_file # class Ui_StringWidget_file ( object ) : - # - # setupUi - # - def setupUi ( self, StringWidget ) : - # - hl = QtGui.QHBoxLayout () - hl.setStretch ( 1, 1 ) - - self.widget = StringWidget - - self.stringEdit = QtGui.QLineEdit ( StringWidget ) - - self.stringEdit.setMinimumSize ( QtCore.QSize ( UI.LABEL_WIDTH, UI.HEIGHT ) ) # UI.EDIT_WIDTH - self.stringEdit.setMaximumSize ( QtCore.QSize ( UI.MAX, UI.HEIGHT ) ) - - self.btnBrowseDir = QtGui.QToolButton ( StringWidget ) - self.btnBrowseDir.setText ( '...' ) - self.btnBrowseDir.setMinimumSize ( QtCore.QSize ( UI.BROWSE_WIDTH, UI.HEIGHT ) ) - self.btnBrowseDir.setMaximumSize ( QtCore.QSize ( UI.BROWSE_WIDTH, UI.HEIGHT ) ) - - hl.addWidget ( self.stringEdit ) - hl.addWidget ( self.btnBrowseDir ) - self.widget.param_vl.addLayout ( hl ) - - - #QtCore.QMetaObject.connectSlotsByName ( StringWidget ) - - self.connectSignals ( StringWidget ) - # - # connectSignals - # - def connectSignals ( self, StringWidget ) : - # - StringWidget.connect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) - StringWidget.connect ( self.btnBrowseDir, QtCore.SIGNAL ( 'clicked()' ), self.onBrowseFile ) - # - # disconnectSignals - # - def disconnectSignals ( self, StringWidget ) : - # - StringWidget.disconnect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) - StringWidget.disconnect ( self.btnBrowseDir, QtCore.SIGNAL ( 'clicked()' ), self.onBrowseFile ) - # - # onStringEditEditingFinished - # - def onStringEditEditingFinished ( self ) : - # - stringValue = self.stringEdit.text () - self.widget.param.value = str ( stringValue ) - #self.widget.param.paramChanged () - # - # onBrowseFile - # - def onBrowseFile ( self ) : - # - if DEBUG_MODE : print '>> Ui_StringWidget_file onBrowseFile' - typeFilter = '' - rangeList = self.widget.param.getRangeValues () - - for ( label, value ) in rangeList : - if DEBUG_MODE : print "label = %s value = %s" % ( label, value ) - typeFilter += ( label + ' ' + value + ';;' ) - #self.selector.addItem ( label, value ) - #print '>> Ui_StringWidget_file typeFilter = %s' % typeFilter - - curDir = app_global_vars [ 'ProjectPath' ] - - filename = QtGui.QFileDialog.getOpenFileName ( self.widget, 'Select file', curDir, typeFilter ) - - if filename != '' : - self.widget.param.setValue ( str ( filename ) ) - self.updateGui ( self.widget.param.value ) - # - # updateGui - # - def updateGui ( self, value ) : - # - self.stringEdit.setText ( value ) + # + # setupUi + # + def setupUi ( self, StringWidget ) : + # + hl = QtModule.QHBoxLayout () + hl.setStretch ( 1, 1 ) + + self.widget = StringWidget + + self.stringEdit = QtModule.QLineEdit ( StringWidget ) + + self.stringEdit.setMinimumSize ( QtCore.QSize ( UI.LABEL_WIDTH, UI.HEIGHT ) ) # UI.EDIT_WIDTH + self.stringEdit.setMaximumSize ( QtCore.QSize ( UI.MAX, UI.HEIGHT ) ) + + self.btnBrowseDir = QtModule.QToolButton ( StringWidget ) + self.btnBrowseDir.setText ( '...' ) + self.btnBrowseDir.setMinimumSize ( QtCore.QSize ( UI.BROWSE_WIDTH, UI.HEIGHT ) ) + self.btnBrowseDir.setMaximumSize ( QtCore.QSize ( UI.BROWSE_WIDTH, UI.HEIGHT ) ) + + hl.addWidget ( self.stringEdit ) + hl.addWidget ( self.btnBrowseDir ) + self.widget.param_vl.addLayout ( hl ) + + + #QtCore.QMetaObject.connectSlotsByName ( StringWidget ) + + self.connectSignals ( StringWidget ) + # + # connectSignals + # + def connectSignals ( self, StringWidget ) : + # + if QtCore.QT_VERSION < 50000 : + StringWidget.connect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) + StringWidget.connect ( self.btnBrowseDir, QtCore.SIGNAL ( 'clicked()' ), self.onBrowseFile ) + else : + self.stringEdit.editingFinished.connect ( self.onStringEditEditingFinished ) + self.btnBrowseDir.clicked.connect ( self.onBrowseFile ) + # + # disconnectSignals + # + def disconnectSignals ( self, StringWidget ) : + # + if QtCore.QT_VERSION < 50000 : + StringWidget.disconnect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) + StringWidget.disconnect ( self.btnBrowseDir, QtCore.SIGNAL ( 'clicked()' ), self.onBrowseFile ) + else : + self.stringEdit.editingFinished.disconnect ( self.onStringEditEditingFinished ) + self.btnBrowseDir.clicked.disconnect ( self.onBrowseFile ) + # + # onStringEditEditingFinished + # + def onStringEditEditingFinished ( self ) : + # + stringValue = self.stringEdit.text () + self.widget.param.value = str ( stringValue ) + #self.widget.param.paramChanged () + # + # onBrowseFile + # + def onBrowseFile ( self ) : + # + if DEBUG_MODE : print '>> Ui_StringWidget_file onBrowseFile' + typeFilter = '' + rangeList = self.widget.param.getRangeValues () + + for ( label, value ) in rangeList : + if DEBUG_MODE : print "label = %s value = %s" % ( label, value ) + typeFilter += ( label + ' ' + value + ';;' ) + #self.selector.addItem ( label, value ) + #print '>> Ui_StringWidget_file typeFilter = %s' % typeFilter + + curDir = app_global_vars [ 'ProjectPath' ] + + filename = QtModule.QFileDialog.getOpenFileName ( self.widget, 'Select file', curDir, typeFilter ) + + if filename != '' : + self.widget.param.setValue ( str ( filename ) ) + self.updateGui ( self.widget.param.value ) + # + # updateGui + # + def updateGui ( self, value ) : + # + self.stringEdit.setText ( value ) diff --git a/gui/params/TextWidget.py b/gui/params/TextWidget.py index 73626a1..9e886b7 100644 --- a/gui/params/TextWidget.py +++ b/gui/params/TextWidget.py @@ -6,71 +6,83 @@ from core.mePyQt import QtGui, QtCore import gui.ui_settings as UI -from paramWidget import ParamWidget +from paramWidget import ParamWidget + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets # # TextWidget # class TextWidget ( ParamWidget ) : - # - # buildGui - # - def buildGui ( self ) : - # - self.ui = Ui_TextWidget_field () - self.ui.setupUi ( self ) + # + # buildGui + # + def buildGui ( self ) : + # + self.ui = Ui_TextWidget_field () + self.ui.setupUi ( self ) # # Ui_StringWidget_field # class Ui_TextWidget_field ( object ) : - # - # setupUi - # - def setupUi ( self, TextWidget ) : - # - hl = QtGui.QHBoxLayout () - hl.setStretch ( 1, 1 ) - - self.widget = TextWidget - self.text_plainTextEdit = QtGui.QPlainTextEdit ( TextWidget ) - self.text_plainTextEdit.setMinimumSize ( QtCore.QSize ( UI.LABEL_WIDTH, UI.HEIGHT ) ) - self.text_plainTextEdit.setMaximumSize ( QtCore.QSize ( UI.MAX, UI.HEIGHT * 4 ) ) - - self.doc = QtGui.QTextDocument () - self.doc.setPlainText ( '' ) - layout = QtGui.QPlainTextDocumentLayout ( self.doc ) - self.doc.setDocumentLayout ( layout ) - self.text_plainTextEdit.setDocument ( self.doc ) - - hl.addWidget ( self.text_plainTextEdit ) - self.widget.param_vl.addLayout ( hl ) - - QtCore.QMetaObject.connectSlotsByName ( TextWidget ) - self.connectSignals ( TextWidget ) - # - # connectSignals - # - def connectSignals ( self, TextWidget ) : - # - TextWidget.connect ( self.text_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onTextEditEditingFinished ) - # - # disconnectSignals - # - def disconnectSignals ( self, TextWidget ) : - # - TextWidget.disconnect ( self.text_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onTextEditEditingFinished ) - # - # onTextEditEditingFinished - # - def onTextEditEditingFinished ( self ) : - # - stringValue = self.text_plainTextEdit.toPlainText () - self.widget.param.setValue ( stringValue ) - # - # updateGui - # - def updateGui ( self, value ) : - # - self.doc.setPlainText ( value ) - self.text_plainTextEdit.setDocument ( self.doc ) + # + # setupUi + # + def setupUi ( self, TextWidget ) : + # + hl = QtModule.QHBoxLayout () + hl.setStretch ( 1, 1 ) + + self.widget = TextWidget + self.text_plainTextEdit = QtModule.QPlainTextEdit ( TextWidget ) + self.text_plainTextEdit.setMinimumSize ( QtCore.QSize ( UI.LABEL_WIDTH, UI.HEIGHT ) ) + self.text_plainTextEdit.setMaximumSize ( QtCore.QSize ( UI.MAX, UI.HEIGHT * 4 ) ) + + self.doc = QtGui.QTextDocument () + self.doc.setPlainText ( '' ) + layout = QtModule.QPlainTextDocumentLayout ( self.doc ) + self.doc.setDocumentLayout ( layout ) + self.text_plainTextEdit.setDocument ( self.doc ) + + hl.addWidget ( self.text_plainTextEdit ) + self.widget.param_vl.addLayout ( hl ) + + QtCore.QMetaObject.connectSlotsByName ( TextWidget ) + self.connectSignals ( TextWidget ) + # + # connectSignals + # + def connectSignals ( self, TextWidget ) : + # + if QtCore.QT_VERSION < 50000 : + TextWidget.connect ( self.text_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onTextEditEditingFinished ) + else : + self.text_plainTextEdit.textChanged.connect ( self.onTextEditEditingFinished ) + # + # disconnectSignals + # + def disconnectSignals ( self, TextWidget ) : + # + if QtCore.QT_VERSION < 50000 : + TextWidget.disconnect ( self.text_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onTextEditEditingFinished ) + else : + self.text_plainTextEdit.textChanged.connect ( self.onTextEditEditingFinished ) + # + # onTextEditEditingFinished + # + def onTextEditEditingFinished ( self ) : + # + stringValue = self.text_plainTextEdit.toPlainText () + self.widget.param.setValue ( stringValue ) + # + # updateGui + # + def updateGui ( self, value ) : + # + self.doc.setPlainText ( value ) + self.text_plainTextEdit.setDocument ( self.doc ) diff --git a/gui/params/VectorWidget.py b/gui/params/VectorWidget.py index c805a67..6b7c85b 100644 --- a/gui/params/VectorWidget.py +++ b/gui/params/VectorWidget.py @@ -6,107 +6,126 @@ from core.mePyQt import QtGui, QtCore import gui.ui_settings as UI -from paramWidget import ParamWidget +from paramWidget import ParamWidget + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets # # VectorWidget # class VectorWidget ( ParamWidget ): - # - # buildGui - # - def buildGui ( self ): - # - self.ui = Ui_VectorWidget_field() - self.ui.setupUi ( self ) + # + # buildGui + # + def buildGui ( self ): + # + self.ui = Ui_VectorWidget_field() + self.ui.setupUi ( self ) # # Ui_VectorWidget_field # class Ui_VectorWidget_field ( object ) : - # - # setupUi - # - def setupUi ( self, VectorWidget ) : - # - hl = QtGui.QHBoxLayout () - self.widget = VectorWidget - - self.floatEdit0 = QtGui.QLineEdit( VectorWidget ) - self.floatEdit1 = QtGui.QLineEdit( VectorWidget ) - self.floatEdit2 = QtGui.QLineEdit( VectorWidget ) - - self.floatEdit0.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) # UI.EDIT_WIDTH - self.floatEdit1.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit2.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - - self.floatEdit0.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit1.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - self.floatEdit2.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) - - self.selector = QtGui.QComboBox ( VectorWidget ) - self.selector.setEditable ( False ) - #self.selector.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) - self.selector.setMaximumSize ( QtCore.QSize( UI.MAX, UI.COMBO_HEIGHT ) ) - - for label in [ "current", "shader", "object", "camera", "world", "raster", "NDC", "screen" ] : - self.selector.addItem ( label ) - if self.widget.param.space != None : - self.selector.setCurrentIndex( self.selector.findText ( self.widget.param.space ) ) - - spacer = QtGui.QSpacerItem ( 20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum ) - - hl.addWidget ( self.floatEdit0 ) - hl.addWidget ( self.floatEdit1 ) - hl.addWidget ( self.floatEdit2 ) - hl.addWidget ( self.selector ) - hl.addItem ( spacer ) - self.widget.param_vl.addLayout ( hl ) - - QtCore.QMetaObject.connectSlotsByName ( VectorWidget ) - self.connectSignals ( VectorWidget ) - # - # connectSignals - # - def connectSignals ( self, VectorWidget ) : - # - VectorWidget.connect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - VectorWidget.connect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - VectorWidget.connect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - VectorWidget.connect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) - # - # disconnectSignals - # - def disconnectSignals ( self, VectorWidget ) : - # - VectorWidget.disconnect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - VectorWidget.disconnect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - VectorWidget.disconnect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) - VectorWidget.disconnect ( self.selector, QtCore.SIGNAL( 'activated(int)' ), self.onCurrentIndexChanged ) - # - # onFloatEditEditingFinished - # - def onFloatEditEditingFinished ( self ) : - # - floatStr0 = self.floatEdit0.text () - floatStr1 = self.floatEdit1.text () - floatStr2 = self.floatEdit2.text () - f0 = floatStr0.toFloat ()[0] - f1 = floatStr1.toFloat ()[0] - f2 = floatStr2.toFloat ()[0] - - self.widget.param.setValue ( [ f0, f1, f2 ] ) - # - # onCurrentIndexChanged - # - def onCurrentIndexChanged ( self, idx ) : - # - space = str ( self.selector.currentText () ) - if space == 'current' : space = None - self.widget.param.space = space - # - # updateGui - # - def updateGui ( self, value ) : - # - self.floatEdit0.setText ( QtCore.QString.number ( value [0], 'f', 3 ) ) - self.floatEdit1.setText ( QtCore.QString.number ( value [1], 'f', 3 ) ) - self.floatEdit2.setText ( QtCore.QString.number ( value [2], 'f', 3 ) ) + # + # setupUi + # + def setupUi ( self, VectorWidget ) : + # + hl = QtModule.QHBoxLayout () + self.widget = VectorWidget + + self.floatEdit0 = QtModule.QLineEdit( VectorWidget ) + self.floatEdit1 = QtModule.QLineEdit( VectorWidget ) + self.floatEdit2 = QtModule.QLineEdit( VectorWidget ) + + self.floatEdit0.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) # UI.EDIT_WIDTH + self.floatEdit1.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit2.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + + self.floatEdit0.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit1.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + self.floatEdit2.setMaximumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) + + self.selector = QtModule.QComboBox ( VectorWidget ) + self.selector.setEditable ( False ) + #self.selector.setMinimumSize ( QtCore.QSize ( UI.COMBO_WIDTH, UI.COMBO_HEIGHT ) ) + self.selector.setMaximumSize ( QtCore.QSize( UI.MAX, UI.COMBO_HEIGHT ) ) + + for label in [ "current", "shader", "object", "camera", "world", "raster", "NDC", "screen" ] : + self.selector.addItem ( label ) + if self.widget.param.space != None : + self.selector.setCurrentIndex ( self.selector.findText ( self.widget.param.space ) ) + + spacer = QtModule.QSpacerItem ( 20, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum ) + + hl.addWidget ( self.floatEdit0 ) + hl.addWidget ( self.floatEdit1 ) + hl.addWidget ( self.floatEdit2 ) + hl.addWidget ( self.selector ) + hl.addItem ( spacer ) + self.widget.param_vl.addLayout ( hl ) + + QtCore.QMetaObject.connectSlotsByName ( VectorWidget ) + self.connectSignals ( VectorWidget ) + # + # connectSignals + # + def connectSignals ( self, VectorWidget ) : + # + if QtCore.QT_VERSION < 50000 : + VectorWidget.connect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + VectorWidget.connect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + VectorWidget.connect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + VectorWidget.connect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) + else : + self.floatEdit0.editingFinished.connect ( self.onFloatEditEditingFinished ) + self.floatEdit1.editingFinished.connect ( self.onFloatEditEditingFinished ) + self.floatEdit2.editingFinished.connect ( self.onFloatEditEditingFinished ) + self.selector.activated.connect ( self.onCurrentIndexChanged ) + + # + # disconnectSignals + # + def disconnectSignals ( self, VectorWidget ) : + # + if QtCore.QT_VERSION < 50000 : + VectorWidget.disconnect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + VectorWidget.disconnect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + VectorWidget.disconnect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) + VectorWidget.disconnect ( self.selector, QtCore.SIGNAL( 'activated(int)' ), self.onCurrentIndexChanged ) + else : + self.floatEdit0.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + self.floatEdit1.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + self.floatEdit2.editingFinished.disconnect ( self.onFloatEditEditingFinished ) + self.selector.activated.disconnect ( self.onCurrentIndexChanged ) + # + # onFloatEditEditingFinished + # + def onFloatEditEditingFinished ( self ) : + # + floatStr0 = self.floatEdit0.text () + floatStr1 = self.floatEdit1.text () + floatStr2 = self.floatEdit2.text () + f0 = floatStr0.toFloat ()[0] + f1 = floatStr1.toFloat ()[0] + f2 = floatStr2.toFloat ()[0] + + self.widget.param.setValue ( [ f0, f1, f2 ] ) + # + # onCurrentIndexChanged + # + def onCurrentIndexChanged ( self, idx ) : + # + space = str ( self.selector.currentText () ) + if space == 'current' : space = None + self.widget.param.space = space + # + # updateGui + # + def updateGui ( self, value ) : + # + self.floatEdit0.setText ( QtCore.QString.number ( value [0], 'f', 3 ) ) + self.floatEdit1.setText ( QtCore.QString.number ( value [1], 'f', 3 ) ) + self.floatEdit2.setText ( QtCore.QString.number ( value [2], 'f', 3 ) ) diff --git a/gui/params/linkWidget.py b/gui/params/linkWidget.py index d1e1a14..ffbe4ed 100644 --- a/gui/params/linkWidget.py +++ b/gui/params/linkWidget.py @@ -8,109 +8,115 @@ from global_vars import app_global_vars, DEBUG_MODE import gui.ui_settings as UI from paramWidget import ParamWidget + +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets # # LinkWidget widgets for linked parameter # class LinkWidget ( ParamWidget ) : - # - # __init__ - # - def __init__ ( self, param, gfxNode, ignoreSubtype = False, linkedParamsList = [] ) : - # - self.linkedParamsList = linkedParamsList - ParamWidget.__init__ ( self, param, gfxNode, ignoreSubtype ) - - # - # buildGui - # - def buildGui ( self ) : - # - self.ui = Ui_LinkWidget () - self.ui.setupUi ( self ) - - #if DEBUG_MODE : print ">> LinkWidget.buildGui" + # + # __init__ + # + def __init__ ( self, param, gfxNode, ignoreSubtype = False, linkedParamsList = [] ) : + # + self.linkedParamsList = linkedParamsList + ParamWidget.__init__ ( self, param, gfxNode, ignoreSubtype ) + + # + # buildGui + # + def buildGui ( self ) : + # + self.ui = Ui_LinkWidget () + self.ui.setupUi ( self ) + + #if DEBUG_MODE : print ">> LinkWidget.buildGui" # # Ui_LinkWidget # class Ui_LinkWidget ( object ) : - # - # setupUi - # - def setupUi ( self, LinkWidget ) : - # - self.widget = LinkWidget - - for ( linkNode, linkParam ) in self.widget.linkedParamsList : - hl = QtGui.QHBoxLayout () - hl.setStretch ( 1, 0 ) - - stringEdit = QtGui.QLineEdit ( LinkWidget ) - stringEdit.setEnabled ( False ) - - stringEdit.setText ( linkNode.label + '.' + linkParam.label + ' (' + linkParam.name + ')' ) - - stringEdit.setMinimumSize ( QtCore.QSize ( UI.LABEL_WIDTH, UI.HEIGHT ) ) # UI.EDIT_WIDTH - stringEdit.setMaximumSize ( QtCore.QSize ( UI.MAX, UI.HEIGHT ) ) - - btnSize = QtCore.QSize ( 20, 20 ) - sizePolicy = QtGui.QSizePolicy ( QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed ) - sizePolicy.setHorizontalStretch ( 20 ) - sizePolicy.setVerticalStretch ( 20 ) - - selectButton = QtGui.QToolButton () - selectButton.setText ( '>' ) - sizePolicy.setHeightForWidth ( selectButton.sizePolicy().hasHeightForWidth() ) - selectButton.setSizePolicy ( sizePolicy ) - selectButton.setMaximumSize ( btnSize ) - selectButton.setAutoRaise ( False ) - selectButton.setToolTip ( 'Go to connection' ) - #selectButton.setIconSize ( QtCore.QSize ( 16, 16 ) ) - selectButton.setObjectName ( 'selectButton' ) - #QtCore.QObject.connect ( self.selectButton, QtCore.SIGNAL ( 'clicked()' ), self.onRemoveItem ) - selectButton.setEnabled ( False ) - - removeButton = QtGui.QToolButton () - sizePolicy.setHeightForWidth ( removeButton.sizePolicy().hasHeightForWidth() ) - removeButton.setSizePolicy ( sizePolicy ) - removeButton.setMaximumSize ( btnSize ) - del_icon = QtGui.QIcon () - del_icon.addPixmap ( QtGui.QPixmap ( ':/edit_icons/resources/del.png' ), QtGui.QIcon.Normal, QtGui.QIcon.On ) - removeButton.setIcon ( del_icon ) - removeButton.setAutoRaise ( False ) - removeButton.setToolTip ( 'Remove connection' ) - #removeButton.setIconSize ( QtCore.QSize ( 16, 16 ) ) - removeButton.setObjectName ( 'removeButton' ) - #QtCore.QObject.connect ( self.removeButton, QtCore.SIGNAL ( 'clicked()' ), self.onRemoveItem ) - removeButton.setEnabled ( False ) - - hl.addWidget ( stringEdit ) - hl.addWidget ( selectButton ) - hl.addWidget ( removeButton ) - - self.widget.param_vl.addLayout ( hl ) - - QtCore.QMetaObject.connectSlotsByName ( LinkWidget ) - self.connectSignals ( LinkWidget ) - # - # connectSignals - # - def connectSignals ( self, LinkWidget ) : - # - pass - #LinkWidget.connect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) - # - # disconnectSignals - # - def disconnectSignals ( self, LinkWidget ) : - # - pass - #LinkWidget.disconnect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) - # - # updateGui - # - def updateGui ( self, value ) : - # - pass - #print ">> LinkWidget.updateGui", value - #if self.linkNode is not None : - # self.stringEdit.setText ( self.linkNode.label + '.' + self.linkParam.label + ' (' + self.linkParam.name + ')' ) \ No newline at end of file + # + # setupUi + # + def setupUi ( self, LinkWidget ) : + # + self.widget = LinkWidget + + for ( linkNode, linkParam ) in self.widget.linkedParamsList : + hl = QtModule.QHBoxLayout () + hl.setStretch ( 1, 0 ) + + stringEdit = QtModule.QLineEdit ( LinkWidget ) + stringEdit.setEnabled ( False ) + + stringEdit.setText ( linkNode.label + '.' + linkParam.label + ' (' + linkParam.name + ')' ) + + stringEdit.setMinimumSize ( QtCore.QSize ( UI.LABEL_WIDTH, UI.HEIGHT ) ) # UI.EDIT_WIDTH + stringEdit.setMaximumSize ( QtCore.QSize ( UI.MAX, UI.HEIGHT ) ) + + btnSize = QtCore.QSize ( 20, 20 ) + sizePolicy = QtModule.QSizePolicy ( QtModule.QSizePolicy.Fixed, QtModule.QSizePolicy.Fixed ) + sizePolicy.setHorizontalStretch ( 20 ) + sizePolicy.setVerticalStretch ( 20 ) + + selectButton = QtModule.QToolButton () + selectButton.setText ( '>' ) + sizePolicy.setHeightForWidth ( selectButton.sizePolicy().hasHeightForWidth() ) + selectButton.setSizePolicy ( sizePolicy ) + selectButton.setMaximumSize ( btnSize ) + selectButton.setAutoRaise ( False ) + selectButton.setToolTip ( 'Go to connection' ) + #selectButton.setIconSize ( QtCore.QSize ( 16, 16 ) ) + selectButton.setObjectName ( 'selectButton' ) + #QtCore.QObject.connect ( self.selectButton, QtCore.SIGNAL ( 'clicked()' ), self.onRemoveItem ) + selectButton.setEnabled ( False ) + + removeButton = QtModule.QToolButton () + sizePolicy.setHeightForWidth ( removeButton.sizePolicy().hasHeightForWidth() ) + removeButton.setSizePolicy ( sizePolicy ) + removeButton.setMaximumSize ( btnSize ) + del_icon = QtGui.QIcon () + del_icon.addPixmap ( QtGui.QPixmap ( ':/edit_icons/resources/del.png' ), QtGui.QIcon.Normal, QtGui.QIcon.On ) + removeButton.setIcon ( del_icon ) + removeButton.setAutoRaise ( False ) + removeButton.setToolTip ( 'Remove connection' ) + #removeButton.setIconSize ( QtCore.QSize ( 16, 16 ) ) + removeButton.setObjectName ( 'removeButton' ) + #QtCore.QObject.connect ( self.removeButton, QtCore.SIGNAL ( 'clicked()' ), self.onRemoveItem ) + removeButton.setEnabled ( False ) + + hl.addWidget ( stringEdit ) + hl.addWidget ( selectButton ) + hl.addWidget ( removeButton ) + + self.widget.param_vl.addLayout ( hl ) + + QtCore.QMetaObject.connectSlotsByName ( LinkWidget ) + self.connectSignals ( LinkWidget ) + # + # connectSignals + # + def connectSignals ( self, LinkWidget ) : + # + pass + #LinkWidget.connect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) + # + # disconnectSignals + # + def disconnectSignals ( self, LinkWidget ) : + # + pass + #LinkWidget.disconnect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) + # + # updateGui + # + def updateGui ( self, value ) : + # + pass + #print ">> LinkWidget.updateGui", value + #if self.linkNode is not None : + # self.stringEdit.setText ( self.linkNode.label + '.' + self.linkParam.label + ' (' + self.linkParam.name + ')' ) \ No newline at end of file diff --git a/gui/params/paramLabel.py b/gui/params/paramLabel.py index eb6d841..2ddfba1 100644 --- a/gui/params/paramLabel.py +++ b/gui/params/paramLabel.py @@ -4,6 +4,7 @@ """ from core.mePyQt import QtGui, QtCore +from core.signal import Signal from global_vars import app_global_vars, DEBUG_MODE import gui.ui_settings as UI @@ -71,13 +72,19 @@ def updateGui ( self ) : # def connectSignals ( self ) : # - self.connect ( self.editLabel, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditingFinished ) + if QtCore.QT_VERSION < 50000 : + self.connect ( self.editLabel, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditingFinished ) + else : + self.editLabel.editingFinished.connect ( self.onEditingFinished ) # # disconnectSignals # def disconnectSignals ( self ) : # - self.disconnect ( self.editLabel, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditingFinished ) + if QtCore.QT_VERSION < 50000 : + self.disconnect ( self.editLabel, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditingFinished ) + else : + self.editLabel.editingFinished.disconnect ( self.onEditingFinished ) """ # # mouseMoveEvent @@ -119,7 +126,7 @@ def mouseDoubleClickEvent ( self, event ) : self.editLabel.setVisible ( True ) return - QtGui.QWidget.mouseDoubleClickEvent ( self, event ) + QtModule.QWidget.mouseDoubleClickEvent ( self, event ) # # mousePressEvent # @@ -155,4 +162,4 @@ def mousePressEvent ( self, event ) : if DEBUG_MODE : print '* ALT+RMB "enable"/"disable" parameter' self.param.enabled = not self.param.enabled self.param.paramChanged () - QtGui.QWidget.mousePressEvent ( self, event ) + QtModule.QWidget.mousePressEvent ( self, event ) diff --git a/gui/params/paramWidget.py b/gui/params/paramWidget.py index 10b99d9..eda4995 100644 --- a/gui/params/paramWidget.py +++ b/gui/params/paramWidget.py @@ -4,6 +4,7 @@ """ from core.mePyQt import QtGui, QtCore +from core.signal import Signal from global_vars import app_global_vars, DEBUG_MODE, VALID_PARAM_TYPES, VALID_RSL_NODE_TYPES, VALID_RSL_PARAM_TYPES import gui.ui_settings as UI @@ -15,7 +16,6 @@ else : from core.mePyQt import QtWidgets QtModule = QtWidgets - # # ParamWidget general class for parameter widgets # @@ -26,6 +26,13 @@ class ParamWidget ( QtModule.QWidget ) : def __init__ ( self, param, gfxNode, ignoreSubtype = False ) : # super ( QtModule.QWidget, self ).__init__ ( None ) + # + # Define signals for PyQt5 + # + if QtCore.QT_VERSION >= 50000 : + # + self.nodeParamRemoved = Signal () + # self.param = param self.gfxNode = gfxNode self.ignoreSubtype = ignoreSubtype # if widget is used in NodeEditor, then ignoreSubtype = True @@ -76,20 +83,23 @@ def buildGeneralGui ( self ) : self.label_vl = QtModule.QVBoxLayout () self.label_vl.setSpacing ( UI.SPACING ) - self.label_vl.setMargin ( 0 ) + if QtCore.QT_VERSION < 50000 : + self.label_vl.setMargin ( 0 ) self.label_vl.setAlignment ( QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft ) #self.gui = QtGui.QWidget ( self ) self.hl = QtModule.QHBoxLayout () self.hl.setSpacing ( UI.SPACING ) - self.hl.setMargin ( 0 ) + if QtCore.QT_VERSION < 50000 : + self.hl.setMargin ( 0 ) self.hl.setAlignment ( QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft ) # vertical layout for parametrs values (e.g. output links or matrix rows) self.param_vl = QtModule.QVBoxLayout () self.param_vl.setSpacing ( UI.SPACING ) - self.param_vl.setMargin ( 0 ) + if QtCore.QT_VERSION < 50000 : + self.param_vl.setMargin ( 0 ) self.param_vl.setAlignment ( QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft ) # # add 'isShaderParam' check box only for RSL nodes @@ -107,7 +117,7 @@ def buildGeneralGui ( self ) : self.connect ( self.check, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onShaderParamChanged ) self.hl.addWidget ( self.check ) else : - spacer = QtModule.QSpacerItem ( UI.LT_SPACE, UI.HEIGHT, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum ) + spacer = QtModule.QSpacerItem ( UI.LT_SPACE, UI.HEIGHT, QtModule.QSizePolicy.Minimum, QtModule.QSizePolicy.Minimum ) self.hl.addItem ( spacer ) # # add 'remove' button for removable parameters @@ -167,7 +177,8 @@ def buildGeneralGui ( self ) : self.hl.addWidget ( self.label ) self.hl.addWidget ( self.helpMark ) #self.hl.addLayout ( self.param_vl ) - self.label_vl.addItem ( QtGui.QSpacerItem ( 20, 0, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum ) ) + spacer = QtModule.QSpacerItem ( 20, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum ) + self.label_vl.addItem ( spacer ) self.label_vl.addLayout ( self.hl ) # # onShaderParamChanged @@ -187,13 +198,16 @@ def onShaderParamChanged ( self, value ) : def buildGui ( self ) : # pass - spacer = QtModule.QSpacerItem ( 20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum ) + spacer = QtModule.QSpacerItem ( 20, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum ) self.hl.addItem ( spacer ) # # onRemoveItem # def onRemoveItem ( self ) : # - if DEBUG_MODE : print '>> ParamWidget( %s ).onRemoveItem ' % self.param.name - self.emit ( QtCore.SIGNAL ( 'nodeParamRemoved' ), self.param ) + if DEBUG_MODE : print '>> ParamWidget( %s ).onRemoveItem ' % self.param.name + if QtCore.QT_VERSION >= 50000 : + self.emit ( QtCore.SIGNAL ( 'nodeParamRemoved' ), self.param ) + else : + self.nodeParamRemoved.emit ( self.param ) diff --git a/gui/ui_MainWindow.py b/gui/ui_MainWindow.py index 9c9f718..0ca97f5 100644 --- a/gui/ui_MainWindow.py +++ b/gui/ui_MainWindow.py @@ -16,537 +16,574 @@ QtModule = QtWidgets try: - _fromUtf8 = QtCore.QString.fromUtf8 + _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: - def _fromUtf8(s): - return s + def _fromUtf8(s): + return s try: - _encoding = QtModule.QApplication.UnicodeUTF8 - def _translate(context, text, disambig): - return QtModule.QApplication.translate(context, text, disambig, _encoding) + _encoding = QtModule.QApplication.UnicodeUTF8 + def _translate(context, text, disambig): + return QtModule.QApplication.translate(context, text, disambig, _encoding) except AttributeError: - def _translate(context, text, disambig): - return QtModule.QApplication.translate(context, text, disambig) + def _translate(context, text, disambig): + return QtModule.QApplication.translate(context, text, disambig) class Ui_MainWindow(object): - def setupUi(self, MainWindow): - MainWindow.setObjectName(_fromUtf8("MainWindow")) - MainWindow.resize(963, 894) - MainWindow.setDockOptions(QtModule.QMainWindow.AllowTabbedDocks|QtModule.QMainWindow.AnimatedDocks) - MainWindow.setUnifiedTitleAndToolBarOnMac(False) - self.centralwidget = QtModule.QWidget(MainWindow) - self.centralwidget.setAcceptDrops(True) - self.centralwidget.setObjectName(_fromUtf8("centralwidget")) - self.gridLayout = QtModule.QGridLayout(self.centralwidget) - #self.gridLayout.setMargin(0) - self.gridLayout.setObjectName(_fromUtf8("gridLayout")) - self.tabs = QtModule.QTabWidget(self.centralwidget) - self.tabs.setAcceptDrops(True) - self.tabs.setTabPosition(QtModule.QTabWidget.North) - self.tabs.setTabShape(QtModule.QTabWidget.Rounded) - self.tabs.setElideMode(QtCore.Qt.ElideNone) - self.tabs.setDocumentMode(True) - self.tabs.setTabsClosable(True) - self.tabs.setMovable(False) - self.tabs.setObjectName(_fromUtf8("tabs")) - self.workArea = WorkArea() - self.workArea.setAcceptDrops(True) - self.workArea.setObjectName(_fromUtf8("workArea")) - self.tabs.addTab(self.workArea, _fromUtf8("")) - self.gridLayout.addWidget(self.tabs, 0, 0, 1, 1) - MainWindow.setCentralWidget(self.centralwidget) - self.menubar = QtModule.QMenuBar(MainWindow) - self.menubar.setGeometry(QtCore.QRect(0, 0, 963, 21)) - font = QtGui.QFont() - font.setFamily(_fromUtf8("Lucida Sans")) - font.setPointSize(9) - self.menubar.setFont(font) - self.menubar.setObjectName(_fromUtf8("menubar")) - self.menuFile = QtModule.QMenu(self.menubar) - font = QtGui.QFont() - font.setFamily(_fromUtf8("MS Shell Dlg 2")) - font.setPointSize(8) - self.menuFile.setFont(font) - self.menuFile.setObjectName(_fromUtf8("menuFile")) - self.menuRecent_Projects = QtModule.QMenu(self.menuFile) - self.menuRecent_Projects.setObjectName(_fromUtf8("menuRecent_Projects")) - self.menuRecent_Networks = QtModule.QMenu(self.menuFile) - self.menuRecent_Networks.setObjectName(_fromUtf8("menuRecent_Networks")) - self.menuEdit = QtModule.QMenu(self.menubar) - font = QtGui.QFont() - font.setFamily(_fromUtf8("MS Shell Dlg 2")) - font.setPointSize(8) - self.menuEdit.setFont(font) - self.menuEdit.setObjectName(_fromUtf8("menuEdit")) - self.menuCommand = QtModule.QMenu(self.menubar) - self.menuCommand.setEnabled(True) - font = QtGui.QFont() - font.setFamily(_fromUtf8("MS Shell Dlg 2")) - font.setPointSize(8) - self.menuCommand.setFont(font) - self.menuCommand.setObjectName(_fromUtf8("menuCommand")) - self.menuCreateNode = QtModule.QMenu(self.menuCommand) - self.menuCreateNode.setEnabled(True) - self.menuCreateNode.setObjectName(_fromUtf8("menuCreateNode")) - self.menuWindow = QtModule.QMenu(self.menubar) - font = QtGui.QFont() - font.setFamily(_fromUtf8("MS Shell Dlg 2")) - font.setPointSize(8) - self.menuWindow.setFont(font) - self.menuWindow.setObjectName(_fromUtf8("menuWindow")) - self.menuHelp = QtModule.QMenu(self.menubar) - font = QtGui.QFont() - font.setFamily(_fromUtf8("MS Shell Dlg 2")) - font.setPointSize(8) - self.menuHelp.setFont(font) - self.menuHelp.setLayoutDirection(QtCore.Qt.RightToLeft) - self.menuHelp.setObjectName(_fromUtf8("menuHelp")) - self.menuView = QtModule.QMenu(self.menubar) - self.menuView.setObjectName(_fromUtf8("menuView")) - MainWindow.setMenuBar(self.menubar) - self.statusbar = QtModule.QStatusBar(MainWindow) - self.statusbar.setObjectName(_fromUtf8("statusbar")) - MainWindow.setStatusBar(self.statusbar) - self.dockNodes = QtModule.QDockWidget(MainWindow) - self.dockNodes.setMinimumSize(QtCore.QSize(150, 42)) - self.dockNodes.setFloating(False) - self.dockNodes.setAllowedAreas(QtCore.Qt.LeftDockWidgetArea|QtCore.Qt.RightDockWidgetArea) - self.dockNodes.setObjectName(_fromUtf8("dockNodes")) - self.nodeList_ctl = NodeLibraryView() - self.nodeList_ctl.setObjectName(_fromUtf8("nodeList_ctl")) - self.dockNodes.setWidget(self.nodeList_ctl) - MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.dockNodes) - self.toolBar = QtModule.QToolBar(MainWindow) - self.toolBar.setMinimumSize(QtCore.QSize(0, 0)) - self.toolBar.setBaseSize(QtCore.QSize(0, 0)) - self.toolBar.setAllowedAreas(QtCore.Qt.LeftToolBarArea|QtCore.Qt.TopToolBarArea) - self.toolBar.setIconSize(QtCore.QSize(24, 24)) - self.toolBar.setObjectName(_fromUtf8("toolBar")) - MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar) - self.dockPreview = QtModule.QDockWidget(MainWindow) - self.dockPreview.setBaseSize(QtCore.QSize(300, 0)) - self.dockPreview.setFloating(False) - self.dockPreview.setFeatures(QtModule.QDockWidget.AllDockWidgetFeatures) - self.dockPreview.setAllowedAreas(QtCore.Qt.LeftDockWidgetArea|QtCore.Qt.RightDockWidgetArea) - self.dockPreview.setObjectName(_fromUtf8("dockPreview")) - self.imageView_ctl = ImageViewWidget() - self.imageView_ctl.setObjectName(_fromUtf8("imageView_ctl")) - self.dockPreview.setWidget(self.imageView_ctl) - MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.dockPreview) - self.dockParam = QtModule.QDockWidget(MainWindow) - self.dockParam.setBaseSize(QtCore.QSize(300, 0)) - self.dockParam.setFeatures(QtModule.QDockWidget.AllDockWidgetFeatures) - self.dockParam.setAllowedAreas(QtCore.Qt.LeftDockWidgetArea|QtCore.Qt.RightDockWidgetArea) - self.dockParam.setObjectName(_fromUtf8("dockParam")) - self.nodeParam_ctl = NodeParamView() - self.nodeParam_ctl.setObjectName(_fromUtf8("nodeParam_ctl")) - self.dockParam.setWidget(self.nodeParam_ctl) - MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.dockParam) - self.dockProject = QtModule.QDockWidget(MainWindow) - self.dockProject.setObjectName(_fromUtf8("dockProject")) - self.project_ctl = NodeLibraryView() - self.project_ctl.setObjectName(_fromUtf8("project_ctl")) - self.dockProject.setWidget(self.project_ctl) - MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.dockProject) - self.dockSwatch = QtModule.QDockWidget(MainWindow) - self.dockSwatch.setObjectName(_fromUtf8("dockSwatch")) - self.swatchParam_ctl = NodeSwatchParam() - self.swatchParam_ctl.setObjectName(_fromUtf8("swatchParam_ctl")) - self.dockSwatch.setWidget(self.swatchParam_ctl) - MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.dockSwatch) - self.actionRendererOptions = QtModule.QAction(MainWindow) - self.actionRendererOptions.setObjectName(_fromUtf8("actionRendererOptions")) - self.actionPreviewOptions = QtModule.QAction(MainWindow) - self.actionPreviewOptions.setObjectName(_fromUtf8("actionPreviewOptions")) - self.actionNew = QtModule.QAction(MainWindow) - icon = QtGui.QIcon() - icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/file_icons/resources/new.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.actionNew.setIcon(icon) - self.actionNew.setToolTip(_fromUtf8("New Project")) - self.actionNew.setStatusTip(_fromUtf8("Create a new project")) - self.actionNew.setObjectName(_fromUtf8("actionNew")) - self.actionOpen = QtModule.QAction(MainWindow) - icon1 = QtGui.QIcon() - icon1.addPixmap(QtGui.QPixmap(_fromUtf8(":/file_icons/resources/open.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.actionOpen.setIcon(icon1) - self.actionOpen.setObjectName(_fromUtf8("actionOpen")) - self.actionSave = QtModule.QAction(MainWindow) - icon2 = QtGui.QIcon() - icon2.addPixmap(QtGui.QPixmap(_fromUtf8(":/file_icons/resources/save.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.actionSave.setIcon(icon2) - self.actionSave.setObjectName(_fromUtf8("actionSave")) - self.actionExit = QtModule.QAction(MainWindow) - self.actionExit.setObjectName(_fromUtf8("actionExit")) - self.actionSaveAs = QtModule.QAction(MainWindow) - self.actionSaveAs.setObjectName(_fromUtf8("actionSaveAs")) - self.actionImport = QtModule.QAction(MainWindow) - self.actionImport.setObjectName(_fromUtf8("actionImport")) - self.actionSaveSelected = QtModule.QAction(MainWindow) - self.actionSaveSelected.setEnabled(False) - self.actionSaveSelected.setObjectName(_fromUtf8("actionSaveSelected")) - self.actionCopy = QtModule.QAction(MainWindow) - self.actionCopy.setEnabled(False) - icon3 = QtGui.QIcon() - icon3.addPixmap(QtGui.QPixmap(_fromUtf8(":/edit_icons/resources/copy.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.actionCopy.setIcon(icon3) - self.actionCopy.setObjectName(_fromUtf8("actionCopy")) - self.actionCut = QtModule.QAction(MainWindow) - self.actionCut.setEnabled(False) - icon4 = QtGui.QIcon() - icon4.addPixmap(QtGui.QPixmap(_fromUtf8(":/edit_icons/resources/editcut1.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.actionCut.setIcon(icon4) - self.actionCut.setObjectName(_fromUtf8("actionCut")) - self.actionPaste = QtModule.QAction(MainWindow) - self.actionPaste.setEnabled(False) - icon5 = QtGui.QIcon() - icon5.addPixmap(QtGui.QPixmap(_fromUtf8(":/edit_icons/resources/paste.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.actionPaste.setIcon(icon5) - self.actionPaste.setObjectName(_fromUtf8("actionPaste")) - self.actionUndo = QtModule.QAction(MainWindow) - self.actionUndo.setEnabled(False) - icon6 = QtGui.QIcon() - icon6.addPixmap(QtGui.QPixmap(_fromUtf8(":/edit_icons/resources/undo.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.actionUndo.setIcon(icon6) - self.actionUndo.setObjectName(_fromUtf8("actionUndo")) - self.actionRedo = QtModule.QAction(MainWindow) - self.actionRedo.setEnabled(False) - icon7 = QtGui.QIcon() - icon7.addPixmap(QtGui.QPixmap(_fromUtf8(":/edit_icons/resources/redo.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.actionRedo.setIcon(icon7) - self.actionRedo.setObjectName(_fromUtf8("actionRedo")) - self.actionEditNode = QtModule.QAction(MainWindow) - self.actionEditNode.setEnabled(True) - self.actionEditNode.setObjectName(_fromUtf8("actionEditNode")) - self.actionRenderPreview = QtModule.QAction(MainWindow) - self.actionRenderPreview.setEnabled(True) - self.actionRenderPreview.setObjectName(_fromUtf8("actionRenderPreview")) - self.actionShowNodes = QtModule.QAction(MainWindow) - self.actionShowNodes.setCheckable(True) - self.actionShowNodes.setChecked(True) - self.actionShowNodes.setObjectName(_fromUtf8("actionShowNodes")) - self.actionShowParameters = QtModule.QAction(MainWindow) - self.actionShowParameters.setCheckable(True) - self.actionShowParameters.setChecked(True) - self.actionShowParameters.setObjectName(_fromUtf8("actionShowParameters")) - self.actionShowGrid = QtModule.QAction(MainWindow) - self.actionShowGrid.setCheckable(True) - icon8 = QtGui.QIcon() - icon8.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/grid_off.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - icon8.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/grid_on.png")), QtGui.QIcon.Normal, QtGui.QIcon.On) - self.actionShowGrid.setIcon(icon8) - self.actionShowGrid.setObjectName(_fromUtf8("actionShowGrid")) - self.actionAbout = QtModule.QAction(MainWindow) - self.actionAbout.setObjectName(_fromUtf8("actionAbout")) - self.actionHelp = QtModule.QAction(MainWindow) - self.actionHelp.setObjectName(_fromUtf8("actionHelp")) - self.actionShowToolbar = QtModule.QAction(MainWindow) - self.actionShowToolbar.setCheckable(True) - self.actionShowToolbar.setChecked(True) - self.actionShowToolbar.setObjectName(_fromUtf8("actionShowToolbar")) - self.actionShowPreview = QtModule.QAction(MainWindow) - self.actionShowPreview.setCheckable(True) - self.actionShowPreview.setChecked(True) - self.actionShowPreview.setObjectName(_fromUtf8("actionShowPreview")) - self.actionDelete = QtModule.QAction(MainWindow) - icon9 = QtGui.QIcon() - icon9.addPixmap(QtGui.QPixmap(_fromUtf8(":/edit_icons/resources/delete.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.actionDelete.setIcon(icon9) - self.actionDelete.setObjectName(_fromUtf8("actionDelete")) - self.actionProjectSetup = QtModule.QAction(MainWindow) - self.actionProjectSetup.setObjectName(_fromUtf8("actionProjectSetup")) - self.actionSettings = QtModule.QAction(MainWindow) - self.actionSettings.setObjectName(_fromUtf8("actionSettings")) - self.actionReverseFlow = QtModule.QAction(MainWindow) - self.actionReverseFlow.setCheckable(True) - self.actionReverseFlow.setEnabled(False) - icon10 = QtGui.QIcon() - icon10.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/ledoff.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - icon10.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/ledon.png")), QtGui.QIcon.Normal, QtGui.QIcon.On) - self.actionReverseFlow.setIcon(icon10) - self.actionReverseFlow.setVisible(False) - self.actionReverseFlow.setObjectName(_fromUtf8("actionReverseFlow")) - self.actionStraightLinks = QtModule.QAction(MainWindow) - self.actionStraightLinks.setCheckable(True) - icon11 = QtGui.QIcon() - icon11.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/straight_off.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - icon11.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/straight_on.png")), QtGui.QIcon.Normal, QtGui.QIcon.On) - self.actionStraightLinks.setIcon(icon11) - self.actionStraightLinks.setObjectName(_fromUtf8("actionStraightLinks")) - self.actionSnapGrid = QtModule.QAction(MainWindow) - self.actionSnapGrid.setCheckable(True) - icon12 = QtGui.QIcon() - icon12.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/snap_off.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - icon12.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/snap_on.png")), QtGui.QIcon.Normal, QtGui.QIcon.On) - self.actionSnapGrid.setIcon(icon12) - self.actionSnapGrid.setObjectName(_fromUtf8("actionSnapGrid")) - self.actionFitAll = QtModule.QAction(MainWindow) - icon13 = QtGui.QIcon() - icon13.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/fit_all.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.actionFitAll.setIcon(icon13) - self.actionFitAll.setVisible(True) - self.actionFitAll.setObjectName(_fromUtf8("actionFitAll")) - self.actionFitSelected = QtModule.QAction(MainWindow) - icon14 = QtGui.QIcon() - icon14.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/fit_selected.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.actionFitSelected.setIcon(icon14) - self.actionFitSelected.setVisible(True) - self.actionFitSelected.setObjectName(_fromUtf8("actionFitSelected")) - self.actionZoomReset = QtModule.QAction(MainWindow) - icon15 = QtGui.QIcon() - icon15.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/zoom_reset.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.actionZoomReset.setIcon(icon15) - self.actionZoomReset.setObjectName(_fromUtf8("actionZoomReset")) - self.actionNewParamView = QtModule.QAction(MainWindow) - self.actionNewParamView.setObjectName(_fromUtf8("actionNewParamView")) - self.actionNewImageView = QtModule.QAction(MainWindow) - self.actionNewImageView.setObjectName(_fromUtf8("actionNewImageView")) - self.actionDuplicate = QtModule.QAction(MainWindow) - self.actionDuplicate.setObjectName(_fromUtf8("actionDuplicate")) - self.actionDuplicateWithLinks = QtModule.QAction(MainWindow) - self.actionDuplicateWithLinks.setObjectName(_fromUtf8("actionDuplicateWithLinks")) - self.actionSelectAll = QtModule.QAction(MainWindow) - self.actionSelectAll.setObjectName(_fromUtf8("actionSelectAll")) - self.actionSelectBelow = QtModule.QAction(MainWindow) - self.actionSelectBelow.setObjectName(_fromUtf8("actionSelectBelow")) - self.actionSelectAbove = QtModule.QAction(MainWindow) - self.actionSelectAbove.setObjectName(_fromUtf8("actionSelectAbove")) - self.actionExportShader = QtModule.QAction(MainWindow) - self.actionExportShader.setObjectName(_fromUtf8("actionExportShader")) - self.actionShowSwatch = QtModule.QAction(MainWindow) - self.actionShowSwatch.setObjectName(_fromUtf8("actionShowSwatch")) - self.actionHideSwatch = QtModule.QAction(MainWindow) - self.actionHideSwatch.setObjectName(_fromUtf8("actionHideSwatch")) - self.actionHelpMode = QtModule.QAction(MainWindow) - self.actionHelpMode.setCheckable(True) - self.actionHelpMode.setObjectName(_fromUtf8("actionHelpMode")) - self.actionViewComputedCode = QtModule.QAction(MainWindow) - self.actionViewComputedCode.setObjectName(_fromUtf8("actionViewComputedCode")) - self.actionCompileShader = QtModule.QAction(MainWindow) - self.actionCompileShader.setObjectName(_fromUtf8("actionCompileShader")) - self.menuRecent_Projects.addSeparator() - self.menuRecent_Networks.addSeparator() - self.menuFile.addAction(self.actionNew) - self.menuFile.addAction(self.actionOpen) - self.menuFile.addAction(self.actionSave) - self.menuFile.addAction(self.actionSaveAs) - self.menuFile.addAction(self.actionSaveSelected) - self.menuFile.addSeparator() - self.menuFile.addAction(self.actionProjectSetup) - self.menuFile.addSeparator() - self.menuFile.addAction(self.actionImport) - self.menuFile.addSeparator() - self.menuFile.addAction(self.menuRecent_Projects.menuAction()) - self.menuFile.addAction(self.menuRecent_Networks.menuAction()) - self.menuFile.addSeparator() - self.menuFile.addAction(self.actionExit) - self.menuEdit.addAction(self.actionUndo) - self.menuEdit.addAction(self.actionRedo) - self.menuEdit.addSeparator() - self.menuEdit.addAction(self.actionSelectAll) - self.menuEdit.addAction(self.actionSelectBelow) - self.menuEdit.addAction(self.actionSelectAbove) - self.menuEdit.addSeparator() - self.menuEdit.addAction(self.actionCopy) - self.menuEdit.addAction(self.actionCut) - self.menuEdit.addAction(self.actionPaste) - self.menuEdit.addSeparator() - self.menuEdit.addAction(self.actionDuplicate) - self.menuEdit.addAction(self.actionDuplicateWithLinks) - self.menuEdit.addAction(self.actionDelete) - self.menuEdit.addSeparator() - self.menuEdit.addAction(self.actionRendererOptions) - self.menuEdit.addAction(self.actionSettings) - self.menuCreateNode.addSeparator() - self.menuCommand.addAction(self.menuCreateNode.menuAction()) - self.menuCommand.addAction(self.actionEditNode) - self.menuCommand.addAction(self.actionViewComputedCode) - self.menuCommand.addAction(self.actionExportShader) - self.menuCommand.addSeparator() - self.menuCommand.addAction(self.actionCompileShader) - self.menuCommand.addAction(self.actionRenderPreview) - self.menuCommand.addAction(self.actionShowSwatch) - self.menuCommand.addAction(self.actionHideSwatch) - self.menuWindow.addAction(self.actionShowToolbar) - self.menuWindow.addAction(self.actionShowNodes) - self.menuWindow.addAction(self.actionShowParameters) - self.menuWindow.addAction(self.actionShowPreview) - self.menuWindow.addSeparator() - self.menuWindow.addAction(self.actionNewParamView) - self.menuWindow.addAction(self.actionNewImageView) - self.menuHelp.addAction(self.actionAbout) - self.menuHelp.addAction(self.actionHelp) - self.menuView.addAction(self.actionShowGrid) - self.menuView.addAction(self.actionSnapGrid) - self.menuView.addAction(self.actionReverseFlow) - self.menuView.addAction(self.actionStraightLinks) - self.menuView.addSeparator() - self.menuView.addAction(self.actionFitAll) - self.menuView.addAction(self.actionFitSelected) - self.menuView.addAction(self.actionZoomReset) - self.menubar.addAction(self.menuFile.menuAction()) - self.menubar.addAction(self.menuEdit.menuAction()) - self.menubar.addAction(self.menuCommand.menuAction()) - self.menubar.addAction(self.menuView.menuAction()) - self.menubar.addAction(self.menuWindow.menuAction()) - self.menubar.addAction(self.menuHelp.menuAction()) - self.toolBar.addAction(self.actionNew) - self.toolBar.addAction(self.actionOpen) - self.toolBar.addAction(self.actionSave) - self.toolBar.addSeparator() - self.toolBar.addAction(self.actionCopy) - self.toolBar.addAction(self.actionCut) - self.toolBar.addAction(self.actionPaste) - self.toolBar.addAction(self.actionDelete) - self.toolBar.addSeparator() - self.toolBar.addAction(self.actionFitAll) - self.toolBar.addAction(self.actionFitSelected) - self.toolBar.addAction(self.actionZoomReset) - self.toolBar.addAction(self.actionShowGrid) - self.toolBar.addAction(self.actionSnapGrid) - self.toolBar.addAction(self.actionStraightLinks) - self.toolBar.addAction(self.actionReverseFlow) + def setupUi(self, MainWindow): + MainWindow.setObjectName(_fromUtf8("MainWindow")) + MainWindow.resize(963, 894) + MainWindow.setDockOptions(QtModule.QMainWindow.AllowTabbedDocks|QtModule.QMainWindow.AnimatedDocks) + MainWindow.setUnifiedTitleAndToolBarOnMac(False) + self.centralwidget = QtModule.QWidget(MainWindow) + self.centralwidget.setAcceptDrops(True) + self.centralwidget.setObjectName(_fromUtf8("centralwidget")) + self.gridLayout = QtModule.QGridLayout(self.centralwidget) + #self.gridLayout.setMargin(0) + self.gridLayout.setObjectName(_fromUtf8("gridLayout")) + self.tabs = QtModule.QTabWidget(self.centralwidget) + self.tabs.setAcceptDrops(True) + self.tabs.setTabPosition(QtModule.QTabWidget.North) + self.tabs.setTabShape(QtModule.QTabWidget.Rounded) + self.tabs.setElideMode(QtCore.Qt.ElideNone) + self.tabs.setDocumentMode(True) + self.tabs.setTabsClosable(True) + self.tabs.setMovable(False) + self.tabs.setObjectName(_fromUtf8("tabs")) + self.workArea = WorkArea() + self.workArea.setAcceptDrops(True) + self.workArea.setObjectName(_fromUtf8("workArea")) + self.tabs.addTab(self.workArea, _fromUtf8("")) + self.gridLayout.addWidget(self.tabs, 0, 0, 1, 1) + MainWindow.setCentralWidget(self.centralwidget) + self.menubar = QtModule.QMenuBar(MainWindow) + self.menubar.setGeometry(QtCore.QRect(0, 0, 963, 21)) + font = QtGui.QFont() + font.setFamily(_fromUtf8("Lucida Sans")) + font.setPointSize(9) + self.menubar.setFont(font) + self.menubar.setObjectName(_fromUtf8("menubar")) + self.menuFile = QtModule.QMenu(self.menubar) + font = QtGui.QFont() + font.setFamily(_fromUtf8("MS Shell Dlg 2")) + font.setPointSize(8) + self.menuFile.setFont(font) + self.menuFile.setObjectName(_fromUtf8("menuFile")) + self.menuRecent_Projects = QtModule.QMenu(self.menuFile) + self.menuRecent_Projects.setObjectName(_fromUtf8("menuRecent_Projects")) + self.menuRecent_Networks = QtModule.QMenu(self.menuFile) + self.menuRecent_Networks.setObjectName(_fromUtf8("menuRecent_Networks")) + self.menuEdit = QtModule.QMenu(self.menubar) + font = QtGui.QFont() + font.setFamily(_fromUtf8("MS Shell Dlg 2")) + font.setPointSize(8) + self.menuEdit.setFont(font) + self.menuEdit.setObjectName(_fromUtf8("menuEdit")) + self.menuCommand = QtModule.QMenu(self.menubar) + self.menuCommand.setEnabled(True) + font = QtGui.QFont() + font.setFamily(_fromUtf8("MS Shell Dlg 2")) + font.setPointSize(8) + self.menuCommand.setFont(font) + self.menuCommand.setObjectName(_fromUtf8("menuCommand")) + self.menuCreateNode = QtModule.QMenu(self.menuCommand) + self.menuCreateNode.setEnabled(True) + self.menuCreateNode.setObjectName(_fromUtf8("menuCreateNode")) + self.menuWindow = QtModule.QMenu(self.menubar) + font = QtGui.QFont() + font.setFamily(_fromUtf8("MS Shell Dlg 2")) + font.setPointSize(8) + self.menuWindow.setFont(font) + self.menuWindow.setObjectName(_fromUtf8("menuWindow")) + self.menuHelp = QtModule.QMenu(self.menubar) + font = QtGui.QFont() + font.setFamily(_fromUtf8("MS Shell Dlg 2")) + font.setPointSize(8) + self.menuHelp.setFont(font) + self.menuHelp.setLayoutDirection(QtCore.Qt.RightToLeft) + self.menuHelp.setObjectName(_fromUtf8("menuHelp")) + self.menuView = QtModule.QMenu(self.menubar) + self.menuView.setObjectName(_fromUtf8("menuView")) + MainWindow.setMenuBar(self.menubar) + self.statusbar = QtModule.QStatusBar(MainWindow) + self.statusbar.setObjectName(_fromUtf8("statusbar")) + MainWindow.setStatusBar(self.statusbar) + self.dockNodes = QtModule.QDockWidget(MainWindow) + self.dockNodes.setMinimumSize(QtCore.QSize(150, 42)) + self.dockNodes.setFloating(False) + self.dockNodes.setAllowedAreas(QtCore.Qt.LeftDockWidgetArea|QtCore.Qt.RightDockWidgetArea) + self.dockNodes.setObjectName(_fromUtf8("dockNodes")) + self.nodeList_ctl = NodeLibraryView() + self.nodeList_ctl.setObjectName(_fromUtf8("nodeList_ctl")) + self.dockNodes.setWidget(self.nodeList_ctl) + MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.dockNodes) + self.toolBar = QtModule.QToolBar(MainWindow) + self.toolBar.setMinimumSize(QtCore.QSize(0, 0)) + self.toolBar.setBaseSize(QtCore.QSize(0, 0)) + self.toolBar.setAllowedAreas(QtCore.Qt.LeftToolBarArea|QtCore.Qt.TopToolBarArea) + self.toolBar.setIconSize(QtCore.QSize(24, 24)) + self.toolBar.setObjectName(_fromUtf8("toolBar")) + MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar) + self.dockPreview = QtModule.QDockWidget(MainWindow) + self.dockPreview.setBaseSize(QtCore.QSize(300, 0)) + self.dockPreview.setFloating(False) + self.dockPreview.setFeatures(QtModule.QDockWidget.AllDockWidgetFeatures) + self.dockPreview.setAllowedAreas(QtCore.Qt.LeftDockWidgetArea|QtCore.Qt.RightDockWidgetArea) + self.dockPreview.setObjectName(_fromUtf8("dockPreview")) + self.imageView_ctl = ImageViewWidget() + self.imageView_ctl.setObjectName(_fromUtf8("imageView_ctl")) + self.dockPreview.setWidget(self.imageView_ctl) + MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.dockPreview) + self.dockParam = QtModule.QDockWidget(MainWindow) + self.dockParam.setBaseSize(QtCore.QSize(300, 0)) + self.dockParam.setFeatures(QtModule.QDockWidget.AllDockWidgetFeatures) + self.dockParam.setAllowedAreas(QtCore.Qt.LeftDockWidgetArea|QtCore.Qt.RightDockWidgetArea) + self.dockParam.setObjectName(_fromUtf8("dockParam")) + self.nodeParam_ctl = NodeParamView() + self.nodeParam_ctl.setObjectName(_fromUtf8("nodeParam_ctl")) + self.dockParam.setWidget(self.nodeParam_ctl) + MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.dockParam) + self.dockProject = QtModule.QDockWidget(MainWindow) + self.dockProject.setObjectName(_fromUtf8("dockProject")) + self.project_ctl = NodeLibraryView() + self.project_ctl.setObjectName(_fromUtf8("project_ctl")) + self.dockProject.setWidget(self.project_ctl) + MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.dockProject) + self.dockSwatch = QtModule.QDockWidget(MainWindow) + self.dockSwatch.setObjectName(_fromUtf8("dockSwatch")) + self.swatchParam_ctl = NodeSwatchParam() + self.swatchParam_ctl.setObjectName(_fromUtf8("swatchParam_ctl")) + self.dockSwatch.setWidget(self.swatchParam_ctl) + MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.dockSwatch) + self.actionRendererOptions = QtModule.QAction(MainWindow) + self.actionRendererOptions.setObjectName(_fromUtf8("actionRendererOptions")) + self.actionPreviewOptions = QtModule.QAction(MainWindow) + self.actionPreviewOptions.setObjectName(_fromUtf8("actionPreviewOptions")) + self.actionNew = QtModule.QAction(MainWindow) + icon = QtGui.QIcon() + icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/file_icons/resources/new.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.actionNew.setIcon(icon) + self.actionNew.setToolTip(_fromUtf8("New Project")) + self.actionNew.setStatusTip(_fromUtf8("Create a new project")) + self.actionNew.setObjectName(_fromUtf8("actionNew")) + self.actionOpen = QtModule.QAction(MainWindow) + icon1 = QtGui.QIcon() + icon1.addPixmap(QtGui.QPixmap(_fromUtf8(":/file_icons/resources/open.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.actionOpen.setIcon(icon1) + self.actionOpen.setObjectName(_fromUtf8("actionOpen")) + self.actionSave = QtModule.QAction(MainWindow) + icon2 = QtGui.QIcon() + icon2.addPixmap(QtGui.QPixmap(_fromUtf8(":/file_icons/resources/save.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.actionSave.setIcon(icon2) + self.actionSave.setObjectName(_fromUtf8("actionSave")) + self.actionExit = QtModule.QAction(MainWindow) + self.actionExit.setObjectName(_fromUtf8("actionExit")) + self.actionSaveAs = QtModule.QAction(MainWindow) + self.actionSaveAs.setObjectName(_fromUtf8("actionSaveAs")) + self.actionImport = QtModule.QAction(MainWindow) + self.actionImport.setObjectName(_fromUtf8("actionImport")) + self.actionSaveSelected = QtModule.QAction(MainWindow) + self.actionSaveSelected.setEnabled(False) + self.actionSaveSelected.setObjectName(_fromUtf8("actionSaveSelected")) + self.actionCopy = QtModule.QAction(MainWindow) + self.actionCopy.setEnabled(False) + icon3 = QtGui.QIcon() + icon3.addPixmap(QtGui.QPixmap(_fromUtf8(":/edit_icons/resources/copy.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.actionCopy.setIcon(icon3) + self.actionCopy.setObjectName(_fromUtf8("actionCopy")) + self.actionCut = QtModule.QAction(MainWindow) + self.actionCut.setEnabled(False) + icon4 = QtGui.QIcon() + icon4.addPixmap(QtGui.QPixmap(_fromUtf8(":/edit_icons/resources/editcut1.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.actionCut.setIcon(icon4) + self.actionCut.setObjectName(_fromUtf8("actionCut")) + self.actionPaste = QtModule.QAction(MainWindow) + self.actionPaste.setEnabled(False) + icon5 = QtGui.QIcon() + icon5.addPixmap(QtGui.QPixmap(_fromUtf8(":/edit_icons/resources/paste.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.actionPaste.setIcon(icon5) + self.actionPaste.setObjectName(_fromUtf8("actionPaste")) + self.actionUndo = QtModule.QAction(MainWindow) + self.actionUndo.setEnabled(False) + icon6 = QtGui.QIcon() + icon6.addPixmap(QtGui.QPixmap(_fromUtf8(":/edit_icons/resources/undo.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.actionUndo.setIcon(icon6) + self.actionUndo.setObjectName(_fromUtf8("actionUndo")) + self.actionRedo = QtModule.QAction(MainWindow) + self.actionRedo.setEnabled(False) + icon7 = QtGui.QIcon() + icon7.addPixmap(QtGui.QPixmap(_fromUtf8(":/edit_icons/resources/redo.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.actionRedo.setIcon(icon7) + self.actionRedo.setObjectName(_fromUtf8("actionRedo")) + self.actionEditNode = QtModule.QAction(MainWindow) + self.actionEditNode.setEnabled(True) + self.actionEditNode.setObjectName(_fromUtf8("actionEditNode")) + self.actionRenderPreview = QtModule.QAction(MainWindow) + self.actionRenderPreview.setEnabled(True) + self.actionRenderPreview.setObjectName(_fromUtf8("actionRenderPreview")) + self.actionShowNodes = QtModule.QAction(MainWindow) + self.actionShowNodes.setCheckable(True) + self.actionShowNodes.setChecked(True) + self.actionShowNodes.setObjectName(_fromUtf8("actionShowNodes")) + self.actionShowParameters = QtModule.QAction(MainWindow) + self.actionShowParameters.setCheckable(True) + self.actionShowParameters.setChecked(True) + self.actionShowParameters.setObjectName(_fromUtf8("actionShowParameters")) + self.actionShowGrid = QtModule.QAction(MainWindow) + self.actionShowGrid.setCheckable(True) + icon8 = QtGui.QIcon() + icon8.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/grid_off.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon8.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/grid_on.png")), QtGui.QIcon.Normal, QtGui.QIcon.On) + self.actionShowGrid.setIcon(icon8) + self.actionShowGrid.setObjectName(_fromUtf8("actionShowGrid")) + self.actionAbout = QtModule.QAction(MainWindow) + self.actionAbout.setObjectName(_fromUtf8("actionAbout")) + self.actionHelp = QtModule.QAction(MainWindow) + self.actionHelp.setObjectName(_fromUtf8("actionHelp")) + self.actionShowToolbar = QtModule.QAction(MainWindow) + self.actionShowToolbar.setCheckable(True) + self.actionShowToolbar.setChecked(True) + self.actionShowToolbar.setObjectName(_fromUtf8("actionShowToolbar")) + self.actionShowPreview = QtModule.QAction(MainWindow) + self.actionShowPreview.setCheckable(True) + self.actionShowPreview.setChecked(True) + self.actionShowPreview.setObjectName(_fromUtf8("actionShowPreview")) + self.actionDelete = QtModule.QAction(MainWindow) + icon9 = QtGui.QIcon() + icon9.addPixmap(QtGui.QPixmap(_fromUtf8(":/edit_icons/resources/delete.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.actionDelete.setIcon(icon9) + self.actionDelete.setObjectName(_fromUtf8("actionDelete")) + self.actionProjectSetup = QtModule.QAction(MainWindow) + self.actionProjectSetup.setObjectName(_fromUtf8("actionProjectSetup")) + self.actionSettings = QtModule.QAction(MainWindow) + self.actionSettings.setObjectName(_fromUtf8("actionSettings")) + self.actionReverseFlow = QtModule.QAction(MainWindow) + self.actionReverseFlow.setCheckable(True) + self.actionReverseFlow.setEnabled(False) + icon10 = QtGui.QIcon() + icon10.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/ledoff.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon10.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/ledon.png")), QtGui.QIcon.Normal, QtGui.QIcon.On) + self.actionReverseFlow.setIcon(icon10) + self.actionReverseFlow.setVisible(False) + self.actionReverseFlow.setObjectName(_fromUtf8("actionReverseFlow")) + self.actionStraightLinks = QtModule.QAction(MainWindow) + self.actionStraightLinks.setCheckable(True) + icon11 = QtGui.QIcon() + icon11.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/straight_off.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon11.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/straight_on.png")), QtGui.QIcon.Normal, QtGui.QIcon.On) + self.actionStraightLinks.setIcon(icon11) + self.actionStraightLinks.setObjectName(_fromUtf8("actionStraightLinks")) + self.actionSnapGrid = QtModule.QAction(MainWindow) + self.actionSnapGrid.setCheckable(True) + icon12 = QtGui.QIcon() + icon12.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/snap_off.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon12.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/snap_on.png")), QtGui.QIcon.Normal, QtGui.QIcon.On) + self.actionSnapGrid.setIcon(icon12) + self.actionSnapGrid.setObjectName(_fromUtf8("actionSnapGrid")) + self.actionFitAll = QtModule.QAction(MainWindow) + icon13 = QtGui.QIcon() + icon13.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/fit_all.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.actionFitAll.setIcon(icon13) + self.actionFitAll.setVisible(True) + self.actionFitAll.setObjectName(_fromUtf8("actionFitAll")) + self.actionFitSelected = QtModule.QAction(MainWindow) + icon14 = QtGui.QIcon() + icon14.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/fit_selected.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.actionFitSelected.setIcon(icon14) + self.actionFitSelected.setVisible(True) + self.actionFitSelected.setObjectName(_fromUtf8("actionFitSelected")) + self.actionZoomReset = QtModule.QAction(MainWindow) + icon15 = QtGui.QIcon() + icon15.addPixmap(QtGui.QPixmap(_fromUtf8(":/show_icons/resources/zoom_reset.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.actionZoomReset.setIcon(icon15) + self.actionZoomReset.setObjectName(_fromUtf8("actionZoomReset")) + self.actionNewParamView = QtModule.QAction(MainWindow) + self.actionNewParamView.setObjectName(_fromUtf8("actionNewParamView")) + self.actionNewImageView = QtModule.QAction(MainWindow) + self.actionNewImageView.setObjectName(_fromUtf8("actionNewImageView")) + self.actionDuplicate = QtModule.QAction(MainWindow) + self.actionDuplicate.setObjectName(_fromUtf8("actionDuplicate")) + self.actionDuplicateWithLinks = QtModule.QAction(MainWindow) + self.actionDuplicateWithLinks.setObjectName(_fromUtf8("actionDuplicateWithLinks")) + self.actionSelectAll = QtModule.QAction(MainWindow) + self.actionSelectAll.setObjectName(_fromUtf8("actionSelectAll")) + self.actionSelectBelow = QtModule.QAction(MainWindow) + self.actionSelectBelow.setObjectName(_fromUtf8("actionSelectBelow")) + self.actionSelectAbove = QtModule.QAction(MainWindow) + self.actionSelectAbove.setObjectName(_fromUtf8("actionSelectAbove")) + self.actionExportShader = QtModule.QAction(MainWindow) + self.actionExportShader.setObjectName(_fromUtf8("actionExportShader")) + self.actionShowSwatch = QtModule.QAction(MainWindow) + self.actionShowSwatch.setObjectName(_fromUtf8("actionShowSwatch")) + self.actionHideSwatch = QtModule.QAction(MainWindow) + self.actionHideSwatch.setObjectName(_fromUtf8("actionHideSwatch")) + self.actionHelpMode = QtModule.QAction(MainWindow) + self.actionHelpMode.setCheckable(True) + self.actionHelpMode.setObjectName(_fromUtf8("actionHelpMode")) + self.actionViewComputedCode = QtModule.QAction(MainWindow) + self.actionViewComputedCode.setObjectName(_fromUtf8("actionViewComputedCode")) + self.actionCompileShader = QtModule.QAction(MainWindow) + self.actionCompileShader.setObjectName(_fromUtf8("actionCompileShader")) + self.menuRecent_Projects.addSeparator() + self.menuRecent_Networks.addSeparator() + self.menuFile.addAction(self.actionNew) + self.menuFile.addAction(self.actionOpen) + self.menuFile.addAction(self.actionSave) + self.menuFile.addAction(self.actionSaveAs) + self.menuFile.addAction(self.actionSaveSelected) + self.menuFile.addSeparator() + self.menuFile.addAction(self.actionProjectSetup) + self.menuFile.addSeparator() + self.menuFile.addAction(self.actionImport) + self.menuFile.addSeparator() + self.menuFile.addAction(self.menuRecent_Projects.menuAction()) + self.menuFile.addAction(self.menuRecent_Networks.menuAction()) + self.menuFile.addSeparator() + self.menuFile.addAction(self.actionExit) + self.menuEdit.addAction(self.actionUndo) + self.menuEdit.addAction(self.actionRedo) + self.menuEdit.addSeparator() + self.menuEdit.addAction(self.actionSelectAll) + self.menuEdit.addAction(self.actionSelectBelow) + self.menuEdit.addAction(self.actionSelectAbove) + self.menuEdit.addSeparator() + self.menuEdit.addAction(self.actionCopy) + self.menuEdit.addAction(self.actionCut) + self.menuEdit.addAction(self.actionPaste) + self.menuEdit.addSeparator() + self.menuEdit.addAction(self.actionDuplicate) + self.menuEdit.addAction(self.actionDuplicateWithLinks) + self.menuEdit.addAction(self.actionDelete) + self.menuEdit.addSeparator() + self.menuEdit.addAction(self.actionRendererOptions) + self.menuEdit.addAction(self.actionSettings) + self.menuCreateNode.addSeparator() + self.menuCommand.addAction(self.menuCreateNode.menuAction()) + self.menuCommand.addAction(self.actionEditNode) + self.menuCommand.addAction(self.actionViewComputedCode) + self.menuCommand.addAction(self.actionExportShader) + self.menuCommand.addSeparator() + self.menuCommand.addAction(self.actionCompileShader) + self.menuCommand.addAction(self.actionRenderPreview) + self.menuCommand.addAction(self.actionShowSwatch) + self.menuCommand.addAction(self.actionHideSwatch) + self.menuWindow.addAction(self.actionShowToolbar) + self.menuWindow.addAction(self.actionShowNodes) + self.menuWindow.addAction(self.actionShowParameters) + self.menuWindow.addAction(self.actionShowPreview) + self.menuWindow.addSeparator() + self.menuWindow.addAction(self.actionNewParamView) + self.menuWindow.addAction(self.actionNewImageView) + self.menuHelp.addAction(self.actionAbout) + self.menuHelp.addAction(self.actionHelp) + self.menuView.addAction(self.actionShowGrid) + self.menuView.addAction(self.actionSnapGrid) + self.menuView.addAction(self.actionReverseFlow) + self.menuView.addAction(self.actionStraightLinks) + self.menuView.addSeparator() + self.menuView.addAction(self.actionFitAll) + self.menuView.addAction(self.actionFitSelected) + self.menuView.addAction(self.actionZoomReset) + self.menubar.addAction(self.menuFile.menuAction()) + self.menubar.addAction(self.menuEdit.menuAction()) + self.menubar.addAction(self.menuCommand.menuAction()) + self.menubar.addAction(self.menuView.menuAction()) + self.menubar.addAction(self.menuWindow.menuAction()) + self.menubar.addAction(self.menuHelp.menuAction()) + self.toolBar.addAction(self.actionNew) + self.toolBar.addAction(self.actionOpen) + self.toolBar.addAction(self.actionSave) + self.toolBar.addSeparator() + self.toolBar.addAction(self.actionCopy) + self.toolBar.addAction(self.actionCut) + self.toolBar.addAction(self.actionPaste) + self.toolBar.addAction(self.actionDelete) + self.toolBar.addSeparator() + self.toolBar.addAction(self.actionFitAll) + self.toolBar.addAction(self.actionFitSelected) + self.toolBar.addAction(self.actionZoomReset) + self.toolBar.addAction(self.actionShowGrid) + self.toolBar.addAction(self.actionSnapGrid) + self.toolBar.addAction(self.actionStraightLinks) + self.toolBar.addAction(self.actionReverseFlow) - self.retranslateUi(MainWindow) - self.tabs.setCurrentIndex(0) - if QtCore.QT_VERSION < 50000 : - QtCore.QObject.connect(self.actionExit, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.close) - QtCore.QObject.connect(self.actionProjectSetup, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onProjectSetup) - QtCore.QObject.connect(self.actionShowGrid, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), MainWindow.onShowGrid) - QtCore.QObject.connect(self.actionRendererOptions, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onRenderSettings) - QtCore.QObject.connect(self.actionSnapGrid, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), MainWindow.onSnapGrid) - QtCore.QObject.connect(self.actionReverseFlow, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), MainWindow.onReverseFlow) - QtCore.QObject.connect(self.actionStraightLinks, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), MainWindow.onStraightLinks) - QtCore.QObject.connect(self.actionDelete, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onDelete) - QtCore.QObject.connect(self.actionFitAll, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onFitAll) - QtCore.QObject.connect(self.actionFitSelected, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onFitSelected) - QtCore.QObject.connect(self.actionZoomReset, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onZoomReset) - QtCore.QObject.connect(self.actionNewParamView, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onNewParamView) - QtCore.QObject.connect(self.actionNew, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onNew) - QtCore.QObject.connect(self.actionSave, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSave) - QtCore.QObject.connect(self.actionSaveAs, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSaveAs) - QtCore.QObject.connect(self.actionOpen, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onOpen) - QtCore.QObject.connect(self.actionSettings, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSettingsSetup) - QtCore.QObject.connect(self.actionImport, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onImport) - QtCore.QObject.connect(self.actionDuplicate, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onDuplicate) - QtCore.QObject.connect(self.actionDuplicateWithLinks, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onDuplicateWithLinks) - QtCore.QObject.connect(self.actionCopy, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onCopy) - QtCore.QObject.connect(self.actionCut, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onCut) - QtCore.QObject.connect(self.actionSelectAll, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSelectAll) - QtCore.QObject.connect(self.actionPaste, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onPaste) - QtCore.QObject.connect(self.actionSelectAbove, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSelectAbove) - QtCore.QObject.connect(self.actionSelectBelow, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSelectBelow) - QtCore.QObject.connect(self.actionEditNode, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onEditNode) - QtCore.QObject.connect(self.actionExportShader, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onExportShader) - QtCore.QObject.connect(self.actionRenderPreview, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onRenderPreview) - QtCore.QObject.connect(self.actionShowSwatch, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onShowSwatch) - QtCore.QObject.connect(self.actionHideSwatch, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onHideSwatch) - QtCore.QObject.connect(self.actionSaveSelected, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSaveSelected) - QtCore.QObject.connect(self.actionViewComputedCode, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onViewComputedCode) - QtCore.QObject.connect(self.actionCompileShader, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onCompileShader) - QtCore.QMetaObject.connectSlotsByName(MainWindow) + self.retranslateUi(MainWindow) + self.tabs.setCurrentIndex(0) + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.connect(self.actionExit, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.close) + QtCore.QObject.connect(self.actionProjectSetup, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onProjectSetup) + QtCore.QObject.connect(self.actionShowGrid, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), MainWindow.onShowGrid) + QtCore.QObject.connect(self.actionRendererOptions, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onRenderSettings) + QtCore.QObject.connect(self.actionSnapGrid, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), MainWindow.onSnapGrid) + QtCore.QObject.connect(self.actionReverseFlow, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), MainWindow.onReverseFlow) + QtCore.QObject.connect(self.actionStraightLinks, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), MainWindow.onStraightLinks) + QtCore.QObject.connect(self.actionDelete, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onDelete) + QtCore.QObject.connect(self.actionFitAll, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onFitAll) + QtCore.QObject.connect(self.actionFitSelected, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onFitSelected) + QtCore.QObject.connect(self.actionZoomReset, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onZoomReset) + QtCore.QObject.connect(self.actionNewParamView, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onNewParamView) + QtCore.QObject.connect(self.actionNew, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onNew) + QtCore.QObject.connect(self.actionSave, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSave) + QtCore.QObject.connect(self.actionSaveAs, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSaveAs) + QtCore.QObject.connect(self.actionOpen, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onOpen) + QtCore.QObject.connect(self.actionSettings, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSettingsSetup) + QtCore.QObject.connect(self.actionImport, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onImport) + QtCore.QObject.connect(self.actionDuplicate, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onDuplicate) + QtCore.QObject.connect(self.actionDuplicateWithLinks, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onDuplicateWithLinks) + QtCore.QObject.connect(self.actionCopy, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onCopy) + QtCore.QObject.connect(self.actionCut, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onCut) + QtCore.QObject.connect(self.actionSelectAll, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSelectAll) + QtCore.QObject.connect(self.actionPaste, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onPaste) + QtCore.QObject.connect(self.actionSelectAbove, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSelectAbove) + QtCore.QObject.connect(self.actionSelectBelow, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSelectBelow) + QtCore.QObject.connect(self.actionEditNode, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onEditNode) + QtCore.QObject.connect(self.actionExportShader, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onExportShader) + QtCore.QObject.connect(self.actionRenderPreview, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onRenderPreview) + QtCore.QObject.connect(self.actionShowSwatch, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onShowSwatch) + QtCore.QObject.connect(self.actionHideSwatch, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onHideSwatch) + QtCore.QObject.connect(self.actionSaveSelected, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onSaveSelected) + QtCore.QObject.connect(self.actionViewComputedCode, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onViewComputedCode) + QtCore.QObject.connect(self.actionCompileShader, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onCompileShader) + else : + self.actionExit.triggered.connect(MainWindow.close) + self.actionProjectSetup.triggered.connect(MainWindow.onProjectSetup) + self.actionShowGrid.toggled.connect(MainWindow.onShowGrid) + self.actionRendererOptions.triggered.connect(MainWindow.onRenderSettings) + self.actionSnapGrid.toggled.connect(MainWindow.onSnapGrid) + self.actionReverseFlow.toggled.connect(MainWindow.onReverseFlow) + self.actionStraightLinks.toggled.connect(MainWindow.onStraightLinks) + self.actionDelete.triggered.connect(MainWindow.onDelete) + self.actionFitAll.triggered.connect(MainWindow.onFitAll) + self.actionFitSelected.triggered.connect(MainWindow.onFitSelected) + self.actionZoomReset.triggered.connect(MainWindow.onZoomReset) + self.actionNewParamView.triggered.connect(MainWindow.onNewParamView) + self.actionNew.triggered.connect(MainWindow.onNew) + self.actionSave.triggered.connect(MainWindow.onSave) + self.actionSaveAs.triggered.connect(MainWindow.onSaveAs) + self.actionOpen.triggered.connect(MainWindow.onOpen) + self.actionSettings.triggered.connect(MainWindow.onSettingsSetup) + self.actionImport.triggered.connect(MainWindow.onImport) + self.actionDuplicate.triggered.connect(MainWindow.onDuplicate) + self.actionDuplicateWithLinks.triggered.connect(MainWindow.onDuplicateWithLinks) + self.actionCopy.triggered.connect(MainWindow.onCopy) + self.actionCut.triggered.connect(MainWindow.onCut) + self.actionSelectAll.triggered.connect(MainWindow.onSelectAll) + self.actionPaste.triggered.connect(MainWindow.onPaste) + self.actionSelectAbove.triggered.connect(MainWindow.onSelectAbove) + self.actionSelectBelow.triggered.connect(MainWindow.onSelectBelow) + self.actionEditNode.triggered.connect(MainWindow.onEditNode) + self.actionExportShader.triggered.connect(MainWindow.onExportShader) + self.actionRenderPreview.triggered.connect(MainWindow.onRenderPreview) + self.actionShowSwatch.triggered.connect(MainWindow.onShowSwatch) + self.actionHideSwatch.triggered.connect(MainWindow.onHideSwatch) + self.actionSaveSelected.triggered.connect(MainWindow.onSaveSelected) + self.actionViewComputedCode.triggered.connect(MainWindow.onViewComputedCode) + self.actionCompileShader.triggered.connect(MainWindow.onCompileShader) + """ + """ + QtCore.QMetaObject.connectSlotsByName(MainWindow) - def retranslateUi(self, MainWindow): - MainWindow.setWindowTitle(_translate("MainWindow", "meShaderEd", None)) - self.tabs.setTabText(self.tabs.indexOf(self.workArea), _translate("MainWindow", "none", None)) - self.menuFile.setTitle(_translate("MainWindow", "File", None)) - self.menuRecent_Projects.setTitle(_translate("MainWindow", "Recent Projects", None)) - self.menuRecent_Networks.setTitle(_translate("MainWindow", "Recent Networks", None)) - self.menuEdit.setTitle(_translate("MainWindow", "Edit", None)) - self.menuCommand.setTitle(_translate("MainWindow", "Command", None)) - self.menuCreateNode.setTitle(_translate("MainWindow", "Create Node", None)) - self.menuWindow.setTitle(_translate("MainWindow", "Window", None)) - self.menuHelp.setTitle(_translate("MainWindow", "Help", None)) - self.menuView.setTitle(_translate("MainWindow", "View", None)) - self.dockNodes.setWindowTitle(_translate("MainWindow", "Library", None)) - self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar", None)) - self.toolBar.setToolTip(_translate("MainWindow", "Enter to Help Mode", None)) - self.dockPreview.setWindowTitle(_translate("MainWindow", "Image View", None)) - self.dockParam.setWindowTitle(_translate("MainWindow", "Node Parameters", None)) - self.dockProject.setWindowTitle(_translate("MainWindow", "Project", None)) - self.dockSwatch.setWindowTitle(_translate("MainWindow", "Node Preview", None)) - self.actionRendererOptions.setText(_translate("MainWindow", "Renderer ...", None)) - self.actionRendererOptions.setToolTip(_translate("MainWindow", "Renderer Options", None)) - self.actionPreviewOptions.setText(_translate("MainWindow", "Preview ...", None)) - self.actionPreviewOptions.setToolTip(_translate("MainWindow", "Preview Options", None)) - self.actionNew.setText(_translate("MainWindow", "&New", None)) - self.actionNew.setWhatsThis(_translate("MainWindow", "Click this option to create a new project", None)) - self.actionNew.setShortcut(_translate("MainWindow", "Ctrl+N", None)) - self.actionOpen.setText(_translate("MainWindow", "&Open", None)) - self.actionOpen.setStatusTip(_translate("MainWindow", "Open existing project", None)) - self.actionOpen.setShortcut(_translate("MainWindow", "Ctrl+O", None)) - self.actionSave.setText(_translate("MainWindow", "&Save", None)) - self.actionSave.setShortcut(_translate("MainWindow", "Ctrl+S", None)) - self.actionExit.setText(_translate("MainWindow", "Quit", None)) - self.actionExit.setShortcut(_translate("MainWindow", "Ctrl+Q", None)) - self.actionSaveAs.setText(_translate("MainWindow", "Save As ...", None)) - self.actionImport.setText(_translate("MainWindow", "Import", None)) - self.actionSaveSelected.setText(_translate("MainWindow", "Save Selected As ...", None)) - self.actionSaveSelected.setToolTip(_translate("MainWindow", "Save selected nodes", None)) - self.actionCopy.setText(_translate("MainWindow", "Copy", None)) - self.actionCopy.setShortcut(_translate("MainWindow", "Ctrl+C", None)) - self.actionCut.setText(_translate("MainWindow", "Cut", None)) - self.actionCut.setShortcut(_translate("MainWindow", "Ctrl+X", None)) - self.actionPaste.setText(_translate("MainWindow", "Paste", None)) - self.actionPaste.setShortcut(_translate("MainWindow", "Ctrl+V", None)) - self.actionUndo.setText(_translate("MainWindow", "Undo", None)) - self.actionRedo.setText(_translate("MainWindow", "Redo", None)) - self.actionEditNode.setText(_translate("MainWindow", "Edit Node ...", None)) - self.actionEditNode.setShortcut(_translate("MainWindow", "Ctrl+E", None)) - self.actionRenderPreview.setText(_translate("MainWindow", "Render Preview", None)) - self.actionRenderPreview.setShortcut(_translate("MainWindow", "Ctrl+R", None)) - self.actionShowNodes.setText(_translate("MainWindow", "Nodes Library", None)) - self.actionShowNodes.setToolTip(_translate("MainWindow", "Show Nodes", None)) - self.actionShowParameters.setText(_translate("MainWindow", "Node Parameters", None)) - self.actionShowParameters.setToolTip(_translate("MainWindow", "Show Parameters", None)) - self.actionShowGrid.setText(_translate("MainWindow", "Show grid", None)) - self.actionShowGrid.setToolTip(_translate("MainWindow", "Show grid", None)) - self.actionAbout.setText(_translate("MainWindow", "About", None)) - self.actionHelp.setText(_translate("MainWindow", "Help", None)) - self.actionShowToolbar.setText(_translate("MainWindow", "Toolbar", None)) - self.actionShowPreview.setText(_translate("MainWindow", "Image View", None)) - self.actionShowPreview.setToolTip(_translate("MainWindow", "Show Preview", None)) - self.actionDelete.setText(_translate("MainWindow", "Delete", None)) - self.actionDelete.setShortcut(_translate("MainWindow", "Del", None)) - self.actionProjectSetup.setText(_translate("MainWindow", "Project Setup ...", None)) - self.actionSettings.setText(_translate("MainWindow", "Settings ...", None)) - self.actionReverseFlow.setText(_translate("MainWindow", "Reverse Flow", None)) - self.actionStraightLinks.setText(_translate("MainWindow", "Staright Links", None)) - self.actionStraightLinks.setToolTip(_translate("MainWindow", "Draw Straight Links", None)) - self.actionSnapGrid.setText(_translate("MainWindow", "Snap To Grid", None)) - self.actionSnapGrid.setToolTip(_translate("MainWindow", "Snap to grid", None)) - self.actionFitAll.setText(_translate("MainWindow", "Fit All", None)) - self.actionFitAll.setShortcut(_translate("MainWindow", "F", None)) - self.actionFitSelected.setText(_translate("MainWindow", "Fit Selected", None)) - self.actionFitSelected.setShortcut(_translate("MainWindow", "Shift+F", None)) - self.actionZoomReset.setText(_translate("MainWindow", "Reset Zoom", None)) - self.actionZoomReset.setToolTip(_translate("MainWindow", "Reset Zoom", None)) - self.actionNewParamView.setText(_translate("MainWindow", "New Parameter View", None)) - self.actionNewImageView.setText(_translate("MainWindow", "New Image View", None)) - self.actionDuplicate.setText(_translate("MainWindow", "Duplicate", None)) - self.actionDuplicate.setShortcut(_translate("MainWindow", "Ctrl+D", None)) - self.actionDuplicateWithLinks.setText(_translate("MainWindow", "Duplicate with links", None)) - self.actionDuplicateWithLinks.setShortcut(_translate("MainWindow", "Ctrl+Shift+D", None)) - self.actionSelectAll.setText(_translate("MainWindow", "Select All", None)) - self.actionSelectAll.setShortcut(_translate("MainWindow", "Ctrl+A", None)) - self.actionSelectBelow.setText(_translate("MainWindow", "Select below", None)) - self.actionSelectBelow.setToolTip(_translate("MainWindow", "Select hierarchy below", None)) - self.actionSelectBelow.setShortcut(_translate("MainWindow", "Ctrl+Down", None)) - self.actionSelectAbove.setText(_translate("MainWindow", "Select above", None)) - self.actionSelectAbove.setToolTip(_translate("MainWindow", "Select hierarchy above", None)) - self.actionSelectAbove.setShortcut(_translate("MainWindow", "Ctrl+Up", None)) - self.actionExportShader.setText(_translate("MainWindow", "Export As Shader ...", None)) - self.actionExportShader.setShortcut(_translate("MainWindow", "Ctrl+T", None)) - self.actionShowSwatch.setText(_translate("MainWindow", "Show Swatch", None)) - self.actionShowSwatch.setShortcut(_translate("MainWindow", "Ctrl+Shift+S", None)) - self.actionHideSwatch.setText(_translate("MainWindow", "Hide Swatch", None)) - self.actionHideSwatch.setShortcut(_translate("MainWindow", "Ctrl+Shift+H", None)) - self.actionHelpMode.setText(_translate("MainWindow", "Help", None)) - self.actionHelpMode.setShortcut(_translate("MainWindow", "Shift+F1", None)) - self.actionViewComputedCode.setText(_translate("MainWindow", "View Computed Code ...", None)) - self.actionViewComputedCode.setShortcut(_translate("MainWindow", "Ctrl+Alt+V", None)) - self.actionCompileShader.setText(_translate("MainWindow", "Compile Shader", None)) - self.actionCompileShader.setShortcut(_translate("MainWindow", "Ctrl+L", None)) + def retranslateUi(self, MainWindow): + MainWindow.setWindowTitle(_translate("MainWindow", "meShaderEd", None)) + self.tabs.setTabText(self.tabs.indexOf(self.workArea), _translate("MainWindow", "none", None)) + self.menuFile.setTitle(_translate("MainWindow", "File", None)) + self.menuRecent_Projects.setTitle(_translate("MainWindow", "Recent Projects", None)) + self.menuRecent_Networks.setTitle(_translate("MainWindow", "Recent Networks", None)) + self.menuEdit.setTitle(_translate("MainWindow", "Edit", None)) + self.menuCommand.setTitle(_translate("MainWindow", "Command", None)) + self.menuCreateNode.setTitle(_translate("MainWindow", "Create Node", None)) + self.menuWindow.setTitle(_translate("MainWindow", "Window", None)) + self.menuHelp.setTitle(_translate("MainWindow", "Help", None)) + self.menuView.setTitle(_translate("MainWindow", "View", None)) + self.dockNodes.setWindowTitle(_translate("MainWindow", "Library", None)) + self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar", None)) + self.toolBar.setToolTip(_translate("MainWindow", "Enter to Help Mode", None)) + self.dockPreview.setWindowTitle(_translate("MainWindow", "Image View", None)) + self.dockParam.setWindowTitle(_translate("MainWindow", "Node Parameters", None)) + self.dockProject.setWindowTitle(_translate("MainWindow", "Project", None)) + self.dockSwatch.setWindowTitle(_translate("MainWindow", "Node Preview", None)) + self.actionRendererOptions.setText(_translate("MainWindow", "Renderer ...", None)) + self.actionRendererOptions.setToolTip(_translate("MainWindow", "Renderer Options", None)) + self.actionPreviewOptions.setText(_translate("MainWindow", "Preview ...", None)) + self.actionPreviewOptions.setToolTip(_translate("MainWindow", "Preview Options", None)) + self.actionNew.setText(_translate("MainWindow", "&New", None)) + self.actionNew.setWhatsThis(_translate("MainWindow", "Click this option to create a new project", None)) + self.actionNew.setShortcut(_translate("MainWindow", "Ctrl+N", None)) + self.actionOpen.setText(_translate("MainWindow", "&Open", None)) + self.actionOpen.setStatusTip(_translate("MainWindow", "Open existing project", None)) + self.actionOpen.setShortcut(_translate("MainWindow", "Ctrl+O", None)) + self.actionSave.setText(_translate("MainWindow", "&Save", None)) + self.actionSave.setShortcut(_translate("MainWindow", "Ctrl+S", None)) + self.actionExit.setText(_translate("MainWindow", "Quit", None)) + self.actionExit.setShortcut(_translate("MainWindow", "Ctrl+Q", None)) + self.actionSaveAs.setText(_translate("MainWindow", "Save As ...", None)) + self.actionImport.setText(_translate("MainWindow", "Import", None)) + self.actionSaveSelected.setText(_translate("MainWindow", "Save Selected As ...", None)) + self.actionSaveSelected.setToolTip(_translate("MainWindow", "Save selected nodes", None)) + self.actionCopy.setText(_translate("MainWindow", "Copy", None)) + self.actionCopy.setShortcut(_translate("MainWindow", "Ctrl+C", None)) + self.actionCut.setText(_translate("MainWindow", "Cut", None)) + self.actionCut.setShortcut(_translate("MainWindow", "Ctrl+X", None)) + self.actionPaste.setText(_translate("MainWindow", "Paste", None)) + self.actionPaste.setShortcut(_translate("MainWindow", "Ctrl+V", None)) + self.actionUndo.setText(_translate("MainWindow", "Undo", None)) + self.actionRedo.setText(_translate("MainWindow", "Redo", None)) + self.actionEditNode.setText(_translate("MainWindow", "Edit Node ...", None)) + self.actionEditNode.setShortcut(_translate("MainWindow", "Ctrl+E", None)) + self.actionRenderPreview.setText(_translate("MainWindow", "Render Preview", None)) + self.actionRenderPreview.setShortcut(_translate("MainWindow", "Ctrl+R", None)) + self.actionShowNodes.setText(_translate("MainWindow", "Nodes Library", None)) + self.actionShowNodes.setToolTip(_translate("MainWindow", "Show Nodes", None)) + self.actionShowParameters.setText(_translate("MainWindow", "Node Parameters", None)) + self.actionShowParameters.setToolTip(_translate("MainWindow", "Show Parameters", None)) + self.actionShowGrid.setText(_translate("MainWindow", "Show grid", None)) + self.actionShowGrid.setToolTip(_translate("MainWindow", "Show grid", None)) + self.actionAbout.setText(_translate("MainWindow", "About", None)) + self.actionHelp.setText(_translate("MainWindow", "Help", None)) + self.actionShowToolbar.setText(_translate("MainWindow", "Toolbar", None)) + self.actionShowPreview.setText(_translate("MainWindow", "Image View", None)) + self.actionShowPreview.setToolTip(_translate("MainWindow", "Show Preview", None)) + self.actionDelete.setText(_translate("MainWindow", "Delete", None)) + self.actionDelete.setShortcut(_translate("MainWindow", "Del", None)) + self.actionProjectSetup.setText(_translate("MainWindow", "Project Setup ...", None)) + self.actionSettings.setText(_translate("MainWindow", "Settings ...", None)) + self.actionReverseFlow.setText(_translate("MainWindow", "Reverse Flow", None)) + self.actionStraightLinks.setText(_translate("MainWindow", "Staright Links", None)) + self.actionStraightLinks.setToolTip(_translate("MainWindow", "Draw Straight Links", None)) + self.actionSnapGrid.setText(_translate("MainWindow", "Snap To Grid", None)) + self.actionSnapGrid.setToolTip(_translate("MainWindow", "Snap to grid", None)) + self.actionFitAll.setText(_translate("MainWindow", "Fit All", None)) + self.actionFitAll.setShortcut(_translate("MainWindow", "F", None)) + self.actionFitSelected.setText(_translate("MainWindow", "Fit Selected", None)) + self.actionFitSelected.setShortcut(_translate("MainWindow", "Shift+F", None)) + self.actionZoomReset.setText(_translate("MainWindow", "Reset Zoom", None)) + self.actionZoomReset.setToolTip(_translate("MainWindow", "Reset Zoom", None)) + self.actionNewParamView.setText(_translate("MainWindow", "New Parameter View", None)) + self.actionNewImageView.setText(_translate("MainWindow", "New Image View", None)) + self.actionDuplicate.setText(_translate("MainWindow", "Duplicate", None)) + self.actionDuplicate.setShortcut(_translate("MainWindow", "Ctrl+D", None)) + self.actionDuplicateWithLinks.setText(_translate("MainWindow", "Duplicate with links", None)) + self.actionDuplicateWithLinks.setShortcut(_translate("MainWindow", "Ctrl+Shift+D", None)) + self.actionSelectAll.setText(_translate("MainWindow", "Select All", None)) + self.actionSelectAll.setShortcut(_translate("MainWindow", "Ctrl+A", None)) + self.actionSelectBelow.setText(_translate("MainWindow", "Select below", None)) + self.actionSelectBelow.setToolTip(_translate("MainWindow", "Select hierarchy below", None)) + self.actionSelectBelow.setShortcut(_translate("MainWindow", "Ctrl+Down", None)) + self.actionSelectAbove.setText(_translate("MainWindow", "Select above", None)) + self.actionSelectAbove.setToolTip(_translate("MainWindow", "Select hierarchy above", None)) + self.actionSelectAbove.setShortcut(_translate("MainWindow", "Ctrl+Up", None)) + self.actionExportShader.setText(_translate("MainWindow", "Export As Shader ...", None)) + self.actionExportShader.setShortcut(_translate("MainWindow", "Ctrl+T", None)) + self.actionShowSwatch.setText(_translate("MainWindow", "Show Swatch", None)) + self.actionShowSwatch.setShortcut(_translate("MainWindow", "Ctrl+Shift+S", None)) + self.actionHideSwatch.setText(_translate("MainWindow", "Hide Swatch", None)) + self.actionHideSwatch.setShortcut(_translate("MainWindow", "Ctrl+Shift+H", None)) + self.actionHelpMode.setText(_translate("MainWindow", "Help", None)) + self.actionHelpMode.setShortcut(_translate("MainWindow", "Shift+F1", None)) + self.actionViewComputedCode.setText(_translate("MainWindow", "View Computed Code ...", None)) + self.actionViewComputedCode.setShortcut(_translate("MainWindow", "Ctrl+Alt+V", None)) + self.actionCompileShader.setText(_translate("MainWindow", "Compile Shader", None)) + self.actionCompileShader.setShortcut(_translate("MainWindow", "Ctrl+L", None)) from nodeLibraryView import NodeLibraryView from imageViewWidget import ImageViewWidget diff --git a/gui/ui_imageViewWidget.py b/gui/ui_imageViewWidget.py index 6eba972..0a74afe 100644 --- a/gui/ui_imageViewWidget.py +++ b/gui/ui_imageViewWidget.py @@ -74,7 +74,10 @@ def setupUi(self, imageViewWidget): if QtCore.QT_VERSION < 50000 : QtCore.QObject.connect(self.btn_render, QtCore.SIGNAL(_fromUtf8("clicked()")), imageViewWidget.updateViewer) QtCore.QObject.connect(self.btn_reset, QtCore.SIGNAL(_fromUtf8("clicked()")), self.imageArea.resetZoom) - QtCore.QMetaObject.connectSlotsByName(imageViewWidget) + else : + self.btn_render.clicked.connect( imageViewWidget.updateViewer) + self.btn_reset.clicked.connect( self.imageArea.resetZoom) + QtCore.QMetaObject.connectSlotsByName(imageViewWidget) def retranslateUi(self, imageViewWidget): imageViewWidget.setWindowTitle(_translate("imageViewWidget", "ImageView", None)) diff --git a/gui/ui_meRendererSetup.py b/gui/ui_meRendererSetup.py index b4a0cc6..7f3970f 100644 --- a/gui/ui_meRendererSetup.py +++ b/gui/ui_meRendererSetup.py @@ -9,397 +9,415 @@ from core.mePyQt import QtCore, QtGui +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + class Ui_meRendererSetup(object): - def setupUi(self, meRendererSetup): - meRendererSetup.setObjectName("meRendererSetup") - meRendererSetup.resize(447, 258) - self.gridLayout = QtGui.QGridLayout(meRendererSetup) - self.gridLayout.setObjectName("gridLayout") - self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName("horizontalLayout") - self.labelPreset = QtGui.QLabel(meRendererSetup) - self.labelPreset.setMinimumSize(QtCore.QSize(80, 0)) - self.labelPreset.setMaximumSize(QtCore.QSize(16777215, 16777215)) - font = QtGui.QFont() - font.setFamily("MS Shell Dlg 2") - font.setPointSize(10) - self.labelPreset.setFont(font) - self.labelPreset.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.labelPreset.setObjectName("labelPreset") - self.horizontalLayout.addWidget(self.labelPreset) - self.listPreset = QtGui.QComboBox(meRendererSetup) - self.listPreset.setMinimumSize(QtCore.QSize(150, 0)) - font = QtGui.QFont() - font.setPointSize(10) - self.listPreset.setFont(font) - self.listPreset.setEditable(False) - self.listPreset.setInsertPolicy(QtGui.QComboBox.InsertAtBottom) - self.listPreset.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContentsOnFirstShow) - self.listPreset.setFrame(True) - self.listPreset.setObjectName("listPreset") - self.horizontalLayout.addWidget(self.listPreset) - spacerItem = QtGui.QSpacerItem(138, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout.addItem(spacerItem) - self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1) - self.btnlt = QtGui.QHBoxLayout() - self.btnlt.setSpacing(6) - self.btnlt.setObjectName("btnlt") - self.newButton = QtGui.QPushButton(meRendererSetup) - self.newButton.setMinimumSize(QtCore.QSize(60, 0)) - font = QtGui.QFont() - font.setPointSize(8) - self.newButton.setFont(font) - self.newButton.setAutoDefault(False) - self.newButton.setObjectName("newButton") - self.btnlt.addWidget(self.newButton) - self.deleteButton = QtGui.QPushButton(meRendererSetup) - self.deleteButton.setMinimumSize(QtCore.QSize(60, 0)) - font = QtGui.QFont() - font.setPointSize(8) - self.deleteButton.setFont(font) - self.deleteButton.setAutoDefault(False) - self.deleteButton.setObjectName("deleteButton") - self.btnlt.addWidget(self.deleteButton) - self.saveButton = QtGui.QPushButton(meRendererSetup) - self.saveButton.setMinimumSize(QtCore.QSize(60, 0)) - font = QtGui.QFont() - font.setPointSize(8) - self.saveButton.setFont(font) - self.saveButton.setAutoDefault(False) - self.saveButton.setObjectName("saveButton") - self.btnlt.addWidget(self.saveButton) - spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.btnlt.addItem(spacerItem1) - self.cancelButton = QtGui.QPushButton(meRendererSetup) - self.cancelButton.setMinimumSize(QtCore.QSize(80, 0)) - font = QtGui.QFont() - font.setPointSize(8) - self.cancelButton.setFont(font) - self.cancelButton.setAutoDefault(False) - self.cancelButton.setObjectName("cancelButton") - self.btnlt.addWidget(self.cancelButton) - self.okButton = QtGui.QPushButton(meRendererSetup) - self.okButton.setMinimumSize(QtCore.QSize(80, 0)) - font = QtGui.QFont() - font.setPointSize(8) - self.okButton.setFont(font) - self.okButton.setAutoDefault(True) - self.okButton.setDefault(True) - self.okButton.setObjectName("okButton") - self.btnlt.addWidget(self.okButton) - self.btnlt.setStretch(3, 1) - self.gridLayout.addLayout(self.btnlt, 5, 0, 1, 1) - self.tabs = QtGui.QTabWidget(meRendererSetup) - self.tabs.setMinimumSize(QtCore.QSize(0, 140)) - self.tabs.setMaximumSize(QtCore.QSize(16777215, 140)) - font = QtGui.QFont() - font.setPointSize(10) - font.setWeight(50) - font.setItalic(False) - font.setBold(False) - self.tabs.setFont(font) - self.tabs.setLayoutDirection(QtCore.Qt.LeftToRight) - self.tabs.setAutoFillBackground(True) - self.tabs.setTabPosition(QtGui.QTabWidget.North) - self.tabs.setTabShape(QtGui.QTabWidget.Rounded) - self.tabs.setElideMode(QtCore.Qt.ElideLeft) - self.tabs.setUsesScrollButtons(False) - self.tabs.setDocumentMode(False) - self.tabs.setTabsClosable(False) - self.tabs.setObjectName("tabs") - self.tab1 = QtGui.QWidget() - self.tab1.setObjectName("tab1") - self.verticalLayout_2 = QtGui.QVBoxLayout(self.tab1) - self.verticalLayout_2.setSpacing(2) - self.verticalLayout_2.setContentsMargins(2, 4, 2, 2) - self.verticalLayout_2.setObjectName("verticalLayout_2") - self.horizontalLayout_2 = QtGui.QHBoxLayout() - self.horizontalLayout_2.setSpacing(4) - self.horizontalLayout_2.setObjectName("horizontalLayout_2") - self.labelName = QtGui.QLabel(self.tab1) - self.labelName.setMinimumSize(QtCore.QSize(80, 0)) - self.labelName.setBaseSize(QtCore.QSize(150, 0)) - font = QtGui.QFont() - font.setPointSize(10) - self.labelName.setFont(font) - self.labelName.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.labelName.setObjectName("labelName") - self.horizontalLayout_2.addWidget(self.labelName) - self.lineName = QtGui.QLineEdit(self.tab1) - self.lineName.setFrame(True) - self.lineName.setObjectName("lineName") - self.horizontalLayout_2.addWidget(self.lineName) - self.horizontalLayout_2.setStretch(1, 1) - self.verticalLayout_2.addLayout(self.horizontalLayout_2) - self.horizontalLayout_3 = QtGui.QHBoxLayout() - self.horizontalLayout_3.setSpacing(4) - self.horizontalLayout_3.setObjectName("horizontalLayout_3") - self.labelCmd = QtGui.QLabel(self.tab1) - self.labelCmd.setMinimumSize(QtCore.QSize(80, 0)) - self.labelCmd.setBaseSize(QtCore.QSize(150, 0)) - font = QtGui.QFont() - font.setPointSize(10) - self.labelCmd.setFont(font) - self.labelCmd.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.labelCmd.setObjectName("labelCmd") - self.horizontalLayout_3.addWidget(self.labelCmd) - self.lineCmd = QtGui.QLineEdit(self.tab1) - self.lineCmd.setObjectName("lineCmd") - self.horizontalLayout_3.addWidget(self.lineCmd) - self.horizontalLayout_3.setStretch(1, 1) - self.verticalLayout_2.addLayout(self.horizontalLayout_3) - self.horizontalLayout_4 = QtGui.QHBoxLayout() - self.horizontalLayout_4.setSpacing(4) - self.horizontalLayout_4.setObjectName("horizontalLayout_4") - self.labelFlags = QtGui.QLabel(self.tab1) - self.labelFlags.setMinimumSize(QtCore.QSize(80, 0)) - self.labelFlags.setBaseSize(QtCore.QSize(150, 0)) - font = QtGui.QFont() - font.setPointSize(10) - self.labelFlags.setFont(font) - self.labelFlags.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.labelFlags.setObjectName("labelFlags") - self.horizontalLayout_4.addWidget(self.labelFlags) - self.lineFlags = QtGui.QLineEdit(self.tab1) - self.lineFlags.setObjectName("lineFlags") - self.horizontalLayout_4.addWidget(self.lineFlags) - self.horizontalLayout_4.setStretch(1, 1) - self.verticalLayout_2.addLayout(self.horizontalLayout_4) - spacerItem2 = QtGui.QSpacerItem(20, 26, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.verticalLayout_2.addItem(spacerItem2) - self.tabs.addTab(self.tab1, "") - self.tab2 = QtGui.QWidget() - self.tab2.setObjectName("tab2") - self.verticalLayout = QtGui.QVBoxLayout(self.tab2) - self.verticalLayout.setSpacing(2) - self.verticalLayout.setContentsMargins(2, 4, 2, 2) - self.verticalLayout.setObjectName("verticalLayout") - self.horizontalLayout_5 = QtGui.QHBoxLayout() - self.horizontalLayout_5.setSpacing(4) - self.horizontalLayout_5.setObjectName("horizontalLayout_5") - self.labelCompiler = QtGui.QLabel(self.tab2) - self.labelCompiler.setMinimumSize(QtCore.QSize(80, 0)) - font = QtGui.QFont() - font.setPointSize(10) - self.labelCompiler.setFont(font) - self.labelCompiler.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.labelCompiler.setObjectName("labelCompiler") - self.horizontalLayout_5.addWidget(self.labelCompiler) - self.lineCompiler = QtGui.QLineEdit(self.tab2) - self.lineCompiler.setObjectName("lineCompiler") - self.horizontalLayout_5.addWidget(self.lineCompiler) - self.horizontalLayout_5.setStretch(1, 1) - self.verticalLayout.addLayout(self.horizontalLayout_5) - self.horizontalLayout_6 = QtGui.QHBoxLayout() - self.horizontalLayout_6.setSpacing(4) - self.horizontalLayout_6.setObjectName("horizontalLayout_6") - self.labelShaderInfo = QtGui.QLabel(self.tab2) - self.labelShaderInfo.setMinimumSize(QtCore.QSize(80, 0)) - font = QtGui.QFont() - font.setPointSize(10) - self.labelShaderInfo.setFont(font) - self.labelShaderInfo.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.labelShaderInfo.setObjectName("labelShaderInfo") - self.horizontalLayout_6.addWidget(self.labelShaderInfo) - self.lineShaderInfo = QtGui.QLineEdit(self.tab2) - self.lineShaderInfo.setObjectName("lineShaderInfo") - self.horizontalLayout_6.addWidget(self.lineShaderInfo) - self.horizontalLayout_6.setStretch(1, 1) - self.verticalLayout.addLayout(self.horizontalLayout_6) - self.horizontalLayout_7 = QtGui.QHBoxLayout() - self.horizontalLayout_7.setSpacing(4) - self.horizontalLayout_7.setObjectName("horizontalLayout_7") - self.labelDefines = QtGui.QLabel(self.tab2) - self.labelDefines.setMinimumSize(QtCore.QSize(80, 0)) - font = QtGui.QFont() - font.setPointSize(10) - self.labelDefines.setFont(font) - self.labelDefines.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.labelDefines.setObjectName("labelDefines") - self.horizontalLayout_7.addWidget(self.labelDefines) - self.lineDefines = QtGui.QLineEdit(self.tab2) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.lineDefines.sizePolicy().hasHeightForWidth()) - self.lineDefines.setSizePolicy(sizePolicy) - self.lineDefines.setMaximumSize(QtCore.QSize(16777215, 16777215)) - self.lineDefines.setObjectName("lineDefines") - self.horizontalLayout_7.addWidget(self.lineDefines) - self.horizontalLayout_7.setStretch(1, 1) - self.verticalLayout.addLayout(self.horizontalLayout_7) - self.horizontalLayout_8 = QtGui.QHBoxLayout() - self.horizontalLayout_8.setSpacing(4) - self.horizontalLayout_8.setSizeConstraint(QtGui.QLayout.SetNoConstraint) - self.horizontalLayout_8.setObjectName("horizontalLayout_8") - self.labelShaderExt = QtGui.QLabel(self.tab2) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.labelShaderExt.sizePolicy().hasHeightForWidth()) - self.labelShaderExt.setSizePolicy(sizePolicy) - self.labelShaderExt.setMinimumSize(QtCore.QSize(80, 0)) - self.labelShaderExt.setMaximumSize(QtCore.QSize(16777215, 16777215)) - font = QtGui.QFont() - font.setPointSize(10) - self.labelShaderExt.setFont(font) - self.labelShaderExt.setLayoutDirection(QtCore.Qt.LeftToRight) - self.labelShaderExt.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.labelShaderExt.setObjectName("labelShaderExt") - self.horizontalLayout_8.addWidget(self.labelShaderExt) - self.lineShaderExt = QtGui.QLineEdit(self.tab2) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.lineShaderExt.sizePolicy().hasHeightForWidth()) - self.lineShaderExt.setSizePolicy(sizePolicy) - self.lineShaderExt.setMinimumSize(QtCore.QSize(50, 0)) - self.lineShaderExt.setMaximumSize(QtCore.QSize(50, 16777215)) - self.lineShaderExt.setLayoutDirection(QtCore.Qt.LeftToRight) - self.lineShaderExt.setAutoFillBackground(False) - self.lineShaderExt.setObjectName("lineShaderExt") - self.horizontalLayout_8.addWidget(self.lineShaderExt) - spacerItem3 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout_8.addItem(spacerItem3) - self.horizontalLayout_8.setStretch(2, 1) - self.verticalLayout.addLayout(self.horizontalLayout_8) - spacerItem4 = QtGui.QSpacerItem(20, 0, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.verticalLayout.addItem(spacerItem4) - self.tabs.addTab(self.tab2, "") - self.tab3 = QtGui.QWidget() - self.tab3.setObjectName("tab3") - self.verticalLayout_3 = QtGui.QVBoxLayout(self.tab3) - self.verticalLayout_3.setSpacing(2) - self.verticalLayout_3.setContentsMargins(2, 4, 2, 2) - self.verticalLayout_3.setObjectName("verticalLayout_3") - self.horizontalLayout_9 = QtGui.QHBoxLayout() - self.horizontalLayout_9.setSpacing(4) - self.horizontalLayout_9.setObjectName("horizontalLayout_9") - self.labelTexMake = QtGui.QLabel(self.tab3) - self.labelTexMake.setMinimumSize(QtCore.QSize(80, 0)) - self.labelTexMake.setMaximumSize(QtCore.QSize(16777215, 16777215)) - font = QtGui.QFont() - font.setPointSize(10) - self.labelTexMake.setFont(font) - self.labelTexMake.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.labelTexMake.setObjectName("labelTexMake") - self.horizontalLayout_9.addWidget(self.labelTexMake) - self.lineTexMake = QtGui.QLineEdit(self.tab3) - self.lineTexMake.setObjectName("lineTexMake") - self.horizontalLayout_9.addWidget(self.lineTexMake) - self.verticalLayout_3.addLayout(self.horizontalLayout_9) - self.horizontalLayout_10 = QtGui.QHBoxLayout() - self.horizontalLayout_10.setSpacing(4) - self.horizontalLayout_10.setObjectName("horizontalLayout_10") - self.labelTexInfo = QtGui.QLabel(self.tab3) - self.labelTexInfo.setMinimumSize(QtCore.QSize(80, 0)) - font = QtGui.QFont() - font.setPointSize(10) - self.labelTexInfo.setFont(font) - self.labelTexInfo.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.labelTexInfo.setObjectName("labelTexInfo") - self.horizontalLayout_10.addWidget(self.labelTexInfo) - self.lineTexInfo = QtGui.QLineEdit(self.tab3) - self.lineTexInfo.setObjectName("lineTexInfo") - self.horizontalLayout_10.addWidget(self.lineTexInfo) - self.verticalLayout_3.addLayout(self.horizontalLayout_10) - self.horizontalLayout_11 = QtGui.QHBoxLayout() - self.horizontalLayout_11.setSpacing(4) - self.horizontalLayout_11.setObjectName("horizontalLayout_11") - self.labelTexViewer = QtGui.QLabel(self.tab3) - self.labelTexViewer.setMinimumSize(QtCore.QSize(80, 0)) - font = QtGui.QFont() - font.setPointSize(10) - self.labelTexViewer.setFont(font) - self.labelTexViewer.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.labelTexViewer.setObjectName("labelTexViewer") - self.horizontalLayout_11.addWidget(self.labelTexViewer) - self.lineTexViewer = QtGui.QLineEdit(self.tab3) - self.lineTexViewer.setObjectName("lineTexViewer") - self.horizontalLayout_11.addWidget(self.lineTexViewer) - self.verticalLayout_3.addLayout(self.horizontalLayout_11) - self.horizontalLayout_12 = QtGui.QHBoxLayout() - self.horizontalLayout_12.setSpacing(4) - self.horizontalLayout_12.setObjectName("horizontalLayout_12") - self.labelTexExt = QtGui.QLabel(self.tab3) - self.labelTexExt.setMinimumSize(QtCore.QSize(80, 0)) - self.labelTexExt.setMaximumSize(QtCore.QSize(16777215, 16777215)) - font = QtGui.QFont() - font.setPointSize(10) - self.labelTexExt.setFont(font) - self.labelTexExt.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.labelTexExt.setObjectName("labelTexExt") - self.horizontalLayout_12.addWidget(self.labelTexExt) - self.lineTexExt = QtGui.QLineEdit(self.tab3) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.lineTexExt.sizePolicy().hasHeightForWidth()) - self.lineTexExt.setSizePolicy(sizePolicy) - self.lineTexExt.setMaximumSize(QtCore.QSize(50, 16777215)) - self.lineTexExt.setObjectName("lineTexExt") - self.horizontalLayout_12.addWidget(self.lineTexExt) - spacerItem5 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout_12.addItem(spacerItem5) - self.horizontalLayout_12.setStretch(2, 1) - self.verticalLayout_3.addLayout(self.horizontalLayout_12) - spacerItem6 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.verticalLayout_3.addItem(spacerItem6) - self.tabs.addTab(self.tab3, "") - self.gridLayout.addWidget(self.tabs, 1, 0, 1, 1) - spacerItem7 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.gridLayout.addItem(spacerItem7, 4, 0, 1, 1) + def setupUi(self, meRendererSetup): + meRendererSetup.setObjectName("meRendererSetup") + meRendererSetup.resize(447, 258) + self.gridLayout = QtModule.QGridLayout(meRendererSetup) + self.gridLayout.setObjectName("gridLayout") + self.horizontalLayout = QtModule.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") + self.labelPreset = QtModule.QLabel(meRendererSetup) + self.labelPreset.setMinimumSize(QtCore.QSize(80, 0)) + self.labelPreset.setMaximumSize(QtCore.QSize(16777215, 16777215)) + font = QtGui.QFont() + font.setFamily("MS Shell Dlg 2") + font.setPointSize(10) + self.labelPreset.setFont(font) + self.labelPreset.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.labelPreset.setObjectName("labelPreset") + self.horizontalLayout.addWidget(self.labelPreset) + self.listPreset = QtModule.QComboBox(meRendererSetup) + self.listPreset.setMinimumSize(QtCore.QSize(150, 0)) + font = QtGui.QFont() + font.setPointSize(10) + self.listPreset.setFont(font) + self.listPreset.setEditable(False) + self.listPreset.setInsertPolicy(QtModule.QComboBox.InsertAtBottom) + self.listPreset.setSizeAdjustPolicy(QtModule.QComboBox.AdjustToContentsOnFirstShow) + self.listPreset.setFrame(True) + self.listPreset.setObjectName("listPreset") + self.horizontalLayout.addWidget(self.listPreset) + spacerItem = QtModule.QSpacerItem(138, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) + self.horizontalLayout.addItem(spacerItem) + self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1) + self.btnlt = QtModule.QHBoxLayout() + self.btnlt.setSpacing(6) + self.btnlt.setObjectName("btnlt") + self.newButton = QtModule.QPushButton(meRendererSetup) + self.newButton.setMinimumSize(QtCore.QSize(60, 0)) + font = QtGui.QFont() + font.setPointSize(8) + self.newButton.setFont(font) + self.newButton.setAutoDefault(False) + self.newButton.setObjectName("newButton") + self.btnlt.addWidget(self.newButton) + self.deleteButton = QtModule.QPushButton(meRendererSetup) + self.deleteButton.setMinimumSize(QtCore.QSize(60, 0)) + font = QtGui.QFont() + font.setPointSize(8) + self.deleteButton.setFont(font) + self.deleteButton.setAutoDefault(False) + self.deleteButton.setObjectName("deleteButton") + self.btnlt.addWidget(self.deleteButton) + self.saveButton = QtModule.QPushButton(meRendererSetup) + self.saveButton.setMinimumSize(QtCore.QSize(60, 0)) + font = QtGui.QFont() + font.setPointSize(8) + self.saveButton.setFont(font) + self.saveButton.setAutoDefault(False) + self.saveButton.setObjectName("saveButton") + self.btnlt.addWidget(self.saveButton) + spacerItem1 = QtModule.QSpacerItem(40, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) + self.btnlt.addItem(spacerItem1) + self.cancelButton = QtModule.QPushButton(meRendererSetup) + self.cancelButton.setMinimumSize(QtCore.QSize(80, 0)) + font = QtGui.QFont() + font.setPointSize(8) + self.cancelButton.setFont(font) + self.cancelButton.setAutoDefault(False) + self.cancelButton.setObjectName("cancelButton") + self.btnlt.addWidget(self.cancelButton) + self.okButton = QtModule.QPushButton(meRendererSetup) + self.okButton.setMinimumSize(QtCore.QSize(80, 0)) + font = QtGui.QFont() + font.setPointSize(8) + self.okButton.setFont(font) + self.okButton.setAutoDefault(True) + self.okButton.setDefault(True) + self.okButton.setObjectName("okButton") + self.btnlt.addWidget(self.okButton) + self.btnlt.setStretch(3, 1) + self.gridLayout.addLayout(self.btnlt, 5, 0, 1, 1) + self.tabs = QtModule.QTabWidget(meRendererSetup) + self.tabs.setMinimumSize(QtCore.QSize(0, 140)) + self.tabs.setMaximumSize(QtCore.QSize(16777215, 140)) + font = QtGui.QFont() + font.setPointSize(10) + font.setWeight(50) + font.setItalic(False) + font.setBold(False) + self.tabs.setFont(font) + self.tabs.setLayoutDirection(QtCore.Qt.LeftToRight) + self.tabs.setAutoFillBackground(True) + self.tabs.setTabPosition(QtModule.QTabWidget.North) + self.tabs.setTabShape(QtModule.QTabWidget.Rounded) + self.tabs.setElideMode(QtCore.Qt.ElideLeft) + self.tabs.setUsesScrollButtons(False) + self.tabs.setDocumentMode(False) + self.tabs.setTabsClosable(False) + self.tabs.setObjectName("tabs") + self.tab1 = QtModule.QWidget() + self.tab1.setObjectName("tab1") + self.verticalLayout_2 = QtModule.QVBoxLayout(self.tab1) + self.verticalLayout_2.setSpacing(2) + self.verticalLayout_2.setContentsMargins(2, 4, 2, 2) + self.verticalLayout_2.setObjectName("verticalLayout_2") + self.horizontalLayout_2 = QtModule.QHBoxLayout() + self.horizontalLayout_2.setSpacing(4) + self.horizontalLayout_2.setObjectName("horizontalLayout_2") + self.labelName = QtModule.QLabel(self.tab1) + self.labelName.setMinimumSize(QtCore.QSize(80, 0)) + self.labelName.setBaseSize(QtCore.QSize(150, 0)) + font = QtGui.QFont() + font.setPointSize(10) + self.labelName.setFont(font) + self.labelName.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.labelName.setObjectName("labelName") + self.horizontalLayout_2.addWidget(self.labelName) + self.lineName = QtModule.QLineEdit(self.tab1) + self.lineName.setFrame(True) + self.lineName.setObjectName("lineName") + self.horizontalLayout_2.addWidget(self.lineName) + self.horizontalLayout_2.setStretch(1, 1) + self.verticalLayout_2.addLayout(self.horizontalLayout_2) + self.horizontalLayout_3 = QtModule.QHBoxLayout() + self.horizontalLayout_3.setSpacing(4) + self.horizontalLayout_3.setObjectName("horizontalLayout_3") + self.labelCmd = QtModule.QLabel(self.tab1) + self.labelCmd.setMinimumSize(QtCore.QSize(80, 0)) + self.labelCmd.setBaseSize(QtCore.QSize(150, 0)) + font = QtGui.QFont() + font.setPointSize(10) + self.labelCmd.setFont(font) + self.labelCmd.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.labelCmd.setObjectName("labelCmd") + self.horizontalLayout_3.addWidget(self.labelCmd) + self.lineCmd = QtModule.QLineEdit(self.tab1) + self.lineCmd.setObjectName("lineCmd") + self.horizontalLayout_3.addWidget(self.lineCmd) + self.horizontalLayout_3.setStretch(1, 1) + self.verticalLayout_2.addLayout(self.horizontalLayout_3) + self.horizontalLayout_4 = QtModule.QHBoxLayout() + self.horizontalLayout_4.setSpacing(4) + self.horizontalLayout_4.setObjectName("horizontalLayout_4") + self.labelFlags = QtModule.QLabel(self.tab1) + self.labelFlags.setMinimumSize(QtCore.QSize(80, 0)) + self.labelFlags.setBaseSize(QtCore.QSize(150, 0)) + font = QtGui.QFont() + font.setPointSize(10) + self.labelFlags.setFont(font) + self.labelFlags.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.labelFlags.setObjectName("labelFlags") + self.horizontalLayout_4.addWidget(self.labelFlags) + self.lineFlags = QtModule.QLineEdit(self.tab1) + self.lineFlags.setObjectName("lineFlags") + self.horizontalLayout_4.addWidget(self.lineFlags) + self.horizontalLayout_4.setStretch(1, 1) + self.verticalLayout_2.addLayout(self.horizontalLayout_4) + spacerItem2 = QtModule.QSpacerItem(20, 26, QtModule.QSizePolicy.Minimum, QtModule.QSizePolicy.Expanding) + self.verticalLayout_2.addItem(spacerItem2) + self.tabs.addTab(self.tab1, "") + self.tab2 = QtModule.QWidget() + self.tab2.setObjectName("tab2") + self.verticalLayout = QtModule.QVBoxLayout(self.tab2) + self.verticalLayout.setSpacing(2) + self.verticalLayout.setContentsMargins(2, 4, 2, 2) + self.verticalLayout.setObjectName("verticalLayout") + self.horizontalLayout_5 = QtModule.QHBoxLayout() + self.horizontalLayout_5.setSpacing(4) + self.horizontalLayout_5.setObjectName("horizontalLayout_5") + self.labelCompiler = QtModule.QLabel(self.tab2) + self.labelCompiler.setMinimumSize(QtCore.QSize(80, 0)) + font = QtGui.QFont() + font.setPointSize(10) + self.labelCompiler.setFont(font) + self.labelCompiler.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.labelCompiler.setObjectName("labelCompiler") + self.horizontalLayout_5.addWidget(self.labelCompiler) + self.lineCompiler = QtModule.QLineEdit(self.tab2) + self.lineCompiler.setObjectName("lineCompiler") + self.horizontalLayout_5.addWidget(self.lineCompiler) + self.horizontalLayout_5.setStretch(1, 1) + self.verticalLayout.addLayout(self.horizontalLayout_5) + self.horizontalLayout_6 = QtModule.QHBoxLayout() + self.horizontalLayout_6.setSpacing(4) + self.horizontalLayout_6.setObjectName("horizontalLayout_6") + self.labelShaderInfo = QtModule.QLabel(self.tab2) + self.labelShaderInfo.setMinimumSize(QtCore.QSize(80, 0)) + font = QtGui.QFont() + font.setPointSize(10) + self.labelShaderInfo.setFont(font) + self.labelShaderInfo.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.labelShaderInfo.setObjectName("labelShaderInfo") + self.horizontalLayout_6.addWidget(self.labelShaderInfo) + self.lineShaderInfo = QtModule.QLineEdit(self.tab2) + self.lineShaderInfo.setObjectName("lineShaderInfo") + self.horizontalLayout_6.addWidget(self.lineShaderInfo) + self.horizontalLayout_6.setStretch(1, 1) + self.verticalLayout.addLayout(self.horizontalLayout_6) + self.horizontalLayout_7 = QtModule.QHBoxLayout() + self.horizontalLayout_7.setSpacing(4) + self.horizontalLayout_7.setObjectName("horizontalLayout_7") + self.labelDefines = QtModule.QLabel(self.tab2) + self.labelDefines.setMinimumSize(QtCore.QSize(80, 0)) + font = QtGui.QFont() + font.setPointSize(10) + self.labelDefines.setFont(font) + self.labelDefines.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.labelDefines.setObjectName("labelDefines") + self.horizontalLayout_7.addWidget(self.labelDefines) + self.lineDefines = QtModule.QLineEdit(self.tab2) + sizePolicy = QtModule.QSizePolicy(QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.lineDefines.sizePolicy().hasHeightForWidth()) + self.lineDefines.setSizePolicy(sizePolicy) + self.lineDefines.setMaximumSize(QtCore.QSize(16777215, 16777215)) + self.lineDefines.setObjectName("lineDefines") + self.horizontalLayout_7.addWidget(self.lineDefines) + self.horizontalLayout_7.setStretch(1, 1) + self.verticalLayout.addLayout(self.horizontalLayout_7) + self.horizontalLayout_8 = QtModule.QHBoxLayout() + self.horizontalLayout_8.setSpacing(4) + self.horizontalLayout_8.setSizeConstraint(QtGui.QLayout.SetNoConstraint) + self.horizontalLayout_8.setObjectName("horizontalLayout_8") + self.labelShaderExt = QtModule.QLabel(self.tab2) + sizePolicy = QtModule.QSizePolicy(QtModule.QSizePolicy.Fixed, QtModule.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.labelShaderExt.sizePolicy().hasHeightForWidth()) + self.labelShaderExt.setSizePolicy(sizePolicy) + self.labelShaderExt.setMinimumSize(QtCore.QSize(80, 0)) + self.labelShaderExt.setMaximumSize(QtCore.QSize(16777215, 16777215)) + font = QtGui.QFont() + font.setPointSize(10) + self.labelShaderExt.setFont(font) + self.labelShaderExt.setLayoutDirection(QtCore.Qt.LeftToRight) + self.labelShaderExt.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.labelShaderExt.setObjectName("labelShaderExt") + self.horizontalLayout_8.addWidget(self.labelShaderExt) + self.lineShaderExt = QtModule.QLineEdit(self.tab2) + sizePolicy = QtModule.QSizePolicy(QtModule.QSizePolicy.Fixed, QtModule.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.lineShaderExt.sizePolicy().hasHeightForWidth()) + self.lineShaderExt.setSizePolicy(sizePolicy) + self.lineShaderExt.setMinimumSize(QtCore.QSize(50, 0)) + self.lineShaderExt.setMaximumSize(QtCore.QSize(50, 16777215)) + self.lineShaderExt.setLayoutDirection(QtCore.Qt.LeftToRight) + self.lineShaderExt.setAutoFillBackground(False) + self.lineShaderExt.setObjectName("lineShaderExt") + self.horizontalLayout_8.addWidget(self.lineShaderExt) + spacerItem3 = QtModule.QSpacerItem(40, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) + self.horizontalLayout_8.addItem(spacerItem3) + self.horizontalLayout_8.setStretch(2, 1) + self.verticalLayout.addLayout(self.horizontalLayout_8) + spacerItem4 = QtModule.QSpacerItem(20, 0, QtModule.QSizePolicy.Minimum, QtModule.QSizePolicy.Expanding) + self.verticalLayout.addItem(spacerItem4) + self.tabs.addTab(self.tab2, "") + self.tab3 = QtModule.QWidget() + self.tab3.setObjectName("tab3") + self.verticalLayout_3 = QtModule.QVBoxLayout(self.tab3) + self.verticalLayout_3.setSpacing(2) + self.verticalLayout_3.setContentsMargins(2, 4, 2, 2) + self.verticalLayout_3.setObjectName("verticalLayout_3") + self.horizontalLayout_9 = QtModule.QHBoxLayout() + self.horizontalLayout_9.setSpacing(4) + self.horizontalLayout_9.setObjectName("horizontalLayout_9") + self.labelTexMake = QtModule.QLabel(self.tab3) + self.labelTexMake.setMinimumSize(QtCore.QSize(80, 0)) + self.labelTexMake.setMaximumSize(QtCore.QSize(16777215, 16777215)) + font = QtGui.QFont() + font.setPointSize(10) + self.labelTexMake.setFont(font) + self.labelTexMake.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.labelTexMake.setObjectName("labelTexMake") + self.horizontalLayout_9.addWidget(self.labelTexMake) + self.lineTexMake = QtModule.QLineEdit(self.tab3) + self.lineTexMake.setObjectName("lineTexMake") + self.horizontalLayout_9.addWidget(self.lineTexMake) + self.verticalLayout_3.addLayout(self.horizontalLayout_9) + self.horizontalLayout_10 = QtModule.QHBoxLayout() + self.horizontalLayout_10.setSpacing(4) + self.horizontalLayout_10.setObjectName("horizontalLayout_10") + self.labelTexInfo = QtModule.QLabel(self.tab3) + self.labelTexInfo.setMinimumSize(QtCore.QSize(80, 0)) + font = QtGui.QFont() + font.setPointSize(10) + self.labelTexInfo.setFont(font) + self.labelTexInfo.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.labelTexInfo.setObjectName("labelTexInfo") + self.horizontalLayout_10.addWidget(self.labelTexInfo) + self.lineTexInfo = QtModule.QLineEdit(self.tab3) + self.lineTexInfo.setObjectName("lineTexInfo") + self.horizontalLayout_10.addWidget(self.lineTexInfo) + self.verticalLayout_3.addLayout(self.horizontalLayout_10) + self.horizontalLayout_11 = QtModule.QHBoxLayout() + self.horizontalLayout_11.setSpacing(4) + self.horizontalLayout_11.setObjectName("horizontalLayout_11") + self.labelTexViewer = QtModule.QLabel(self.tab3) + self.labelTexViewer.setMinimumSize(QtCore.QSize(80, 0)) + font = QtGui.QFont() + font.setPointSize(10) + self.labelTexViewer.setFont(font) + self.labelTexViewer.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.labelTexViewer.setObjectName("labelTexViewer") + self.horizontalLayout_11.addWidget(self.labelTexViewer) + self.lineTexViewer = QtModule.QLineEdit(self.tab3) + self.lineTexViewer.setObjectName("lineTexViewer") + self.horizontalLayout_11.addWidget(self.lineTexViewer) + self.verticalLayout_3.addLayout(self.horizontalLayout_11) + self.horizontalLayout_12 = QtModule.QHBoxLayout() + self.horizontalLayout_12.setSpacing(4) + self.horizontalLayout_12.setObjectName("horizontalLayout_12") + self.labelTexExt = QtModule.QLabel(self.tab3) + self.labelTexExt.setMinimumSize(QtCore.QSize(80, 0)) + self.labelTexExt.setMaximumSize(QtCore.QSize(16777215, 16777215)) + font = QtGui.QFont() + font.setPointSize(10) + self.labelTexExt.setFont(font) + self.labelTexExt.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.labelTexExt.setObjectName("labelTexExt") + self.horizontalLayout_12.addWidget(self.labelTexExt) + self.lineTexExt = QtModule.QLineEdit(self.tab3) + sizePolicy = QtModule.QSizePolicy(QtModule.QSizePolicy.Fixed, QtModule.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.lineTexExt.sizePolicy().hasHeightForWidth()) + self.lineTexExt.setSizePolicy(sizePolicy) + self.lineTexExt.setMaximumSize(QtCore.QSize(50, 16777215)) + self.lineTexExt.setObjectName("lineTexExt") + self.horizontalLayout_12.addWidget(self.lineTexExt) + spacerItem5 = QtModule.QSpacerItem(40, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) + self.horizontalLayout_12.addItem(spacerItem5) + self.horizontalLayout_12.setStretch(2, 1) + self.verticalLayout_3.addLayout(self.horizontalLayout_12) + spacerItem6 = QtModule.QSpacerItem(20, 40, QtModule.QSizePolicy.Minimum, QtModule.QSizePolicy.Expanding) + self.verticalLayout_3.addItem(spacerItem6) + self.tabs.addTab(self.tab3, "") + self.gridLayout.addWidget(self.tabs, 1, 0, 1, 1) + spacerItem7 = QtModule.QSpacerItem(20, 40, QtModule.QSizePolicy.Minimum, QtModule.QSizePolicy.Expanding) + self.gridLayout.addItem(spacerItem7, 4, 0, 1, 1) - self.retranslateUi(meRendererSetup) - self.tabs.setCurrentIndex(0) - QtCore.QObject.connect(self.cancelButton, QtCore.SIGNAL("clicked()"), meRendererSetup.close) - QtCore.QObject.connect(self.okButton, QtCore.SIGNAL("clicked()"), meRendererSetup.onSelect) - QtCore.QObject.connect(self.listPreset, QtCore.SIGNAL("currentIndexChanged(QString)"), meRendererSetup.onIndexChanged) - QtCore.QObject.connect(self.newButton, QtCore.SIGNAL("clicked()"), meRendererSetup.onNewPreset) - QtCore.QObject.connect(self.deleteButton, QtCore.SIGNAL("clicked()"), meRendererSetup.onDeletePreset) - QtCore.QObject.connect(self.lineName, QtCore.SIGNAL("editingFinished()"), meRendererSetup.onEditLabel) - QtCore.QObject.connect(self.saveButton, QtCore.SIGNAL("clicked()"), meRendererSetup.onSave) - QtCore.QMetaObject.connectSlotsByName(meRendererSetup) - meRendererSetup.setTabOrder(self.tabs, self.listPreset) - meRendererSetup.setTabOrder(self.listPreset, self.newButton) - meRendererSetup.setTabOrder(self.newButton, self.deleteButton) - meRendererSetup.setTabOrder(self.deleteButton, self.cancelButton) - meRendererSetup.setTabOrder(self.cancelButton, self.lineName) - meRendererSetup.setTabOrder(self.lineName, self.lineCmd) - meRendererSetup.setTabOrder(self.lineCmd, self.lineFlags) - meRendererSetup.setTabOrder(self.lineFlags, self.lineCompiler) - meRendererSetup.setTabOrder(self.lineCompiler, self.lineShaderInfo) - meRendererSetup.setTabOrder(self.lineShaderInfo, self.lineDefines) - meRendererSetup.setTabOrder(self.lineDefines, self.lineShaderExt) - meRendererSetup.setTabOrder(self.lineShaderExt, self.lineTexMake) - meRendererSetup.setTabOrder(self.lineTexMake, self.lineTexInfo) - meRendererSetup.setTabOrder(self.lineTexInfo, self.lineTexViewer) - meRendererSetup.setTabOrder(self.lineTexViewer, self.lineTexExt) + self.retranslateUi(meRendererSetup) + self.tabs.setCurrentIndex(0) + + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.connect(self.cancelButton, QtCore.SIGNAL("clicked()"), meRendererSetup.close) + QtCore.QObject.connect(self.okButton, QtCore.SIGNAL("clicked()"), meRendererSetup.onSelect) + QtCore.QObject.connect(self.listPreset, QtCore.SIGNAL("currentIndexChanged(QString)"), meRendererSetup.onIndexChanged) + QtCore.QObject.connect(self.newButton, QtCore.SIGNAL("clicked()"), meRendererSetup.onNewPreset) + QtCore.QObject.connect(self.deleteButton, QtCore.SIGNAL("clicked()"), meRendererSetup.onDeletePreset) + QtCore.QObject.connect(self.lineName, QtCore.SIGNAL("editingFinished()"), meRendererSetup.onEditLabel) + QtCore.QObject.connect(self.saveButton, QtCore.SIGNAL("clicked()"), meRendererSetup.onSave) + else : + self.cancelButton.clicked.connect( meRendererSetup.close) + self.okButton.clicked.connect( meRendererSetup.onSelect) + self.listPreset.currentIndexChanged.connect( meRendererSetup.onIndexChanged) + self.newButton.clicked.connect( meRendererSetup.onNewPreset) + self.deleteButton.clicked.connect( meRendererSetup.onDeletePreset) + self.lineName.editingFinished.connect( meRendererSetup.onEditLabel) + self.saveButton.clicked.connect( meRendererSetup.onSave) + + QtCore.QMetaObject.connectSlotsByName(meRendererSetup) + + meRendererSetup.setTabOrder(self.tabs, self.listPreset) + meRendererSetup.setTabOrder(self.listPreset, self.newButton) + meRendererSetup.setTabOrder(self.newButton, self.deleteButton) + meRendererSetup.setTabOrder(self.deleteButton, self.cancelButton) + meRendererSetup.setTabOrder(self.cancelButton, self.lineName) + meRendererSetup.setTabOrder(self.lineName, self.lineCmd) + meRendererSetup.setTabOrder(self.lineCmd, self.lineFlags) + meRendererSetup.setTabOrder(self.lineFlags, self.lineCompiler) + meRendererSetup.setTabOrder(self.lineCompiler, self.lineShaderInfo) + meRendererSetup.setTabOrder(self.lineShaderInfo, self.lineDefines) + meRendererSetup.setTabOrder(self.lineDefines, self.lineShaderExt) + meRendererSetup.setTabOrder(self.lineShaderExt, self.lineTexMake) + meRendererSetup.setTabOrder(self.lineTexMake, self.lineTexInfo) + meRendererSetup.setTabOrder(self.lineTexInfo, self.lineTexViewer) + meRendererSetup.setTabOrder(self.lineTexViewer, self.lineTexExt) - def retranslateUi(self, meRendererSetup): - meRendererSetup.setWindowTitle(QtGui.QApplication.translate("meRendererSetup", "Renderer preset setup", None, QtGui.QApplication.UnicodeUTF8)) - self.labelPreset.setText(QtGui.QApplication.translate("meRendererSetup", "Preset", None, QtGui.QApplication.UnicodeUTF8)) - self.newButton.setToolTip(QtGui.QApplication.translate("meRendererSetup", "Create new renderer preset", None, QtGui.QApplication.UnicodeUTF8)) - self.newButton.setText(QtGui.QApplication.translate("meRendererSetup", "New", None, QtGui.QApplication.UnicodeUTF8)) - self.deleteButton.setToolTip(QtGui.QApplication.translate("meRendererSetup", "Delete current renderer preset", None, QtGui.QApplication.UnicodeUTF8)) - self.deleteButton.setText(QtGui.QApplication.translate("meRendererSetup", "Delete", None, QtGui.QApplication.UnicodeUTF8)) - self.saveButton.setToolTip(QtGui.QApplication.translate("meRendererSetup", "Save current renderer preset", None, QtGui.QApplication.UnicodeUTF8)) - self.saveButton.setText(QtGui.QApplication.translate("meRendererSetup", "Save", None, QtGui.QApplication.UnicodeUTF8)) - self.cancelButton.setText(QtGui.QApplication.translate("meRendererSetup", "Cancel", None, QtGui.QApplication.UnicodeUTF8)) - self.okButton.setToolTip(QtGui.QApplication.translate("meRendererSetup", "Select current renderer preset", None, QtGui.QApplication.UnicodeUTF8)) - self.okButton.setText(QtGui.QApplication.translate("meRendererSetup", "Select", None, QtGui.QApplication.UnicodeUTF8)) - self.labelName.setText(QtGui.QApplication.translate("meRendererSetup", "Label", None, QtGui.QApplication.UnicodeUTF8)) - self.labelCmd.setText(QtGui.QApplication.translate("meRendererSetup", "Command", None, QtGui.QApplication.UnicodeUTF8)) - self.labelFlags.setText(QtGui.QApplication.translate("meRendererSetup", "Flags", None, QtGui.QApplication.UnicodeUTF8)) - self.tabs.setTabText(self.tabs.indexOf(self.tab1), QtGui.QApplication.translate("meRendererSetup", "Renderer", None, QtGui.QApplication.UnicodeUTF8)) - self.labelCompiler.setText(QtGui.QApplication.translate("meRendererSetup", " Compiler", None, QtGui.QApplication.UnicodeUTF8)) - self.labelShaderInfo.setText(QtGui.QApplication.translate("meRendererSetup", "SloInfo", None, QtGui.QApplication.UnicodeUTF8)) - self.labelDefines.setText(QtGui.QApplication.translate("meRendererSetup", "Defines", None, QtGui.QApplication.UnicodeUTF8)) - self.labelShaderExt.setText(QtGui.QApplication.translate("meRendererSetup", " Extension", None, QtGui.QApplication.UnicodeUTF8)) - self.tabs.setTabText(self.tabs.indexOf(self.tab2), QtGui.QApplication.translate("meRendererSetup", "Shaders", None, QtGui.QApplication.UnicodeUTF8)) - self.labelTexMake.setText(QtGui.QApplication.translate("meRendererSetup", "TexMake", None, QtGui.QApplication.UnicodeUTF8)) - self.labelTexInfo.setText(QtGui.QApplication.translate("meRendererSetup", " TexInfo", None, QtGui.QApplication.UnicodeUTF8)) - self.labelTexViewer.setText(QtGui.QApplication.translate("meRendererSetup", "Viewer", None, QtGui.QApplication.UnicodeUTF8)) - self.labelTexExt.setText(QtGui.QApplication.translate("meRendererSetup", " Extension", None, QtGui.QApplication.UnicodeUTF8)) - self.tabs.setTabText(self.tabs.indexOf(self.tab3), QtGui.QApplication.translate("meRendererSetup", "Textures", None, QtGui.QApplication.UnicodeUTF8)) + def retranslateUi(self, meRendererSetup): + meRendererSetup.setWindowTitle(QtGui.QApplication.translate("meRendererSetup", "Renderer preset setup", None)) + self.labelPreset.setText(QtGui.QApplication.translate("meRendererSetup", "Preset", None)) + self.newButton.setToolTip(QtGui.QApplication.translate("meRendererSetup", "Create new renderer preset", None)) + self.newButton.setText(QtGui.QApplication.translate("meRendererSetup", "New", None)) + self.deleteButton.setToolTip(QtGui.QApplication.translate("meRendererSetup", "Delete current renderer preset", None)) + self.deleteButton.setText(QtGui.QApplication.translate("meRendererSetup", "Delete", None)) + self.saveButton.setToolTip(QtGui.QApplication.translate("meRendererSetup", "Save current renderer preset", None)) + self.saveButton.setText(QtGui.QApplication.translate("meRendererSetup", "Save", None)) + self.cancelButton.setText(QtGui.QApplication.translate("meRendererSetup", "Cancel", None)) + self.okButton.setToolTip(QtGui.QApplication.translate("meRendererSetup", "Select current renderer preset", None)) + self.okButton.setText(QtGui.QApplication.translate("meRendererSetup", "Select", None)) + self.labelName.setText(QtGui.QApplication.translate("meRendererSetup", "Label", None)) + self.labelCmd.setText(QtGui.QApplication.translate("meRendererSetup", "Command", None)) + self.labelFlags.setText(QtGui.QApplication.translate("meRendererSetup", "Flags", None)) + self.tabs.setTabText(self.tabs.indexOf(self.tab1), QtGui.QApplication.translate("meRendererSetup", "Renderer", None)) + self.labelCompiler.setText(QtGui.QApplication.translate("meRendererSetup", " Compiler", None)) + self.labelShaderInfo.setText(QtGui.QApplication.translate("meRendererSetup", "SloInfo", None)) + self.labelDefines.setText(QtGui.QApplication.translate("meRendererSetup", "Defines", None)) + self.labelShaderExt.setText(QtGui.QApplication.translate("meRendererSetup", " Extension", None)) + self.tabs.setTabText(self.tabs.indexOf(self.tab2), QtGui.QApplication.translate("meRendererSetup", "Shaders", None)) + self.labelTexMake.setText(QtGui.QApplication.translate("meRendererSetup", "TexMake", None)) + self.labelTexInfo.setText(QtGui.QApplication.translate("meRendererSetup", " TexInfo", None)) + self.labelTexViewer.setText(QtGui.QApplication.translate("meRendererSetup", "Viewer", None)) + self.labelTexExt.setText(QtGui.QApplication.translate("meRendererSetup", " Extension", None)) + self.tabs.setTabText(self.tabs.indexOf(self.tab3), QtGui.QApplication.translate("meRendererSetup", "Textures", None)) diff --git a/gui/ui_nodeLibraryView.py b/gui/ui_nodeLibraryView.py index 6cda28f..5d2bb49 100644 --- a/gui/ui_nodeLibraryView.py +++ b/gui/ui_nodeLibraryView.py @@ -50,7 +50,9 @@ def setupUi(self, nodeLibraryView): if QtCore.QT_VERSION < 50000 : QtCore.QObject.connect(self.btn_reload, QtCore.SIGNAL(_fromUtf8("clicked()")), nodeLibraryView.onReload) - QtCore.QMetaObject.connectSlotsByName(nodeLibraryView) + else : + self.btn_reload.clicked.connect( nodeLibraryView.onReload) + QtCore.QMetaObject.connectSlotsByName(nodeLibraryView) def retranslateUi(self, nodeLibraryView): nodeLibraryView.setWindowTitle(QtModule.QApplication.translate("nodeLibraryView", "Form", None)) diff --git a/gui/ui_nodeParam.py b/gui/ui_nodeParam.py index 7765c38..07c29d1 100644 --- a/gui/ui_nodeParam.py +++ b/gui/ui_nodeParam.py @@ -9,35 +9,41 @@ from core.mePyQt import QtCore, QtGui +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + try: - _fromUtf8 = QtCore.QString.fromUtf8 + _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: - _fromUtf8 = lambda s: s + _fromUtf8 = lambda s: s class Ui_Form(object): - def setupUi(self, Form): - Form.setObjectName(_fromUtf8("Form")) - Form.resize(370, 474) - self.verticalLayout = QtGui.QVBoxLayout(Form) - self.verticalLayout.setSpacing(2) - self.verticalLayout.setMargin(4) - self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) - self.labelLayout = QtGui.QHBoxLayout() - self.labelLayout.setObjectName(_fromUtf8("labelLayout")) - self.label = QtGui.QLabel(Form) - self.label.setObjectName(_fromUtf8("label")) - self.labelLayout.addWidget(self.label) - self.nodeLabelEdit = QtGui.QLineEdit(Form) - self.nodeLabelEdit.setObjectName(_fromUtf8("nodeLabelEdit")) - self.labelLayout.addWidget(self.nodeLabelEdit) - self.labelLayout.setStretch(1, 1) - self.verticalLayout.addLayout(self.labelLayout) - self.label.setBuddy(self.nodeLabelEdit) + def setupUi(self, Form): + Form.setObjectName(_fromUtf8("Form")) + Form.resize(370, 474) + self.verticalLayout = QtModule.QVBoxLayout(Form) + self.verticalLayout.setSpacing(2) + self.verticalLayout.setMargin(4) + self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + self.labelLayout = QtModule.QHBoxLayout() + self.labelLayout.setObjectName(_fromUtf8("labelLayout")) + self.label = QtModule.QLabel(Form) + self.label.setObjectName(_fromUtf8("label")) + self.labelLayout.addWidget(self.label) + self.nodeLabelEdit = QtModule.QLineEdit(Form) + self.nodeLabelEdit.setObjectName(_fromUtf8("nodeLabelEdit")) + self.labelLayout.addWidget(self.nodeLabelEdit) + self.labelLayout.setStretch(1, 1) + self.verticalLayout.addLayout(self.labelLayout) + self.label.setBuddy(self.nodeLabelEdit) - self.retranslateUi(Form) - QtCore.QMetaObject.connectSlotsByName(Form) + self.retranslateUi(Form) + QtCore.QMetaObject.connectSlotsByName(Form) - def retranslateUi(self, Form): - Form.setWindowTitle(QtGui.QApplication.translate("Form", "Form", None, QtGui.QApplication.UnicodeUTF8)) - self.label.setText(QtGui.QApplication.translate("Form", "Label", None, QtGui.QApplication.UnicodeUTF8)) + def retranslateUi(self, Form): + Form.setWindowTitle(QtGui.QApplication.translate("Form", "Form", None) + self.label.setText(QtGui.QApplication.translate("Form", "Label", None) diff --git a/gui/ui_projectSetup.py b/gui/ui_projectSetup.py index c43f615..5c99580 100644 --- a/gui/ui_projectSetup.py +++ b/gui/ui_projectSetup.py @@ -9,150 +9,166 @@ from core.mePyQt import QtCore, QtGui +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + try: - _fromUtf8 = QtCore.QString.fromUtf8 + _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: - _fromUtf8 = lambda s: s + _fromUtf8 = lambda s: s class Ui_ProjectSetup(object): - def setupUi(self, ProjectSetup): - ProjectSetup.setObjectName(_fromUtf8("ProjectSetup")) - ProjectSetup.resize(426, 342) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum) - sizePolicy.setHorizontalStretch(1) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(ProjectSetup.sizePolicy().hasHeightForWidth()) - ProjectSetup.setSizePolicy(sizePolicy) - ProjectSetup.setMinimumSize(QtCore.QSize(0, 0)) - ProjectSetup.setMaximumSize(QtCore.QSize(16777215, 16777215)) - ProjectSetup.setSizeGripEnabled(False) - self.verticalLayout_3 = QtGui.QVBoxLayout(ProjectSetup) - self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3")) - self.grp_project = QtGui.QGroupBox(ProjectSetup) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.grp_project.sizePolicy().hasHeightForWidth()) - self.grp_project.setSizePolicy(sizePolicy) - self.grp_project.setMinimumSize(QtCore.QSize(0, 0)) - self.grp_project.setMaximumSize(QtCore.QSize(16777215, 16777215)) - self.grp_project.setObjectName(_fromUtf8("grp_project")) - self.verticalLayout = QtGui.QVBoxLayout(self.grp_project) - self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) - self.hl_project = QtGui.QHBoxLayout() - self.hl_project.setObjectName(_fromUtf8("hl_project")) - self.label_project = QtGui.QLabel(self.grp_project) - self.label_project.setMinimumSize(QtCore.QSize(80, 0)) - self.label_project.setMaximumSize(QtCore.QSize(80, 16777215)) - self.label_project.setObjectName(_fromUtf8("label_project")) - self.hl_project.addWidget(self.label_project) - self.lineEdit_project = QtGui.QLineEdit(self.grp_project) - self.lineEdit_project.setObjectName(_fromUtf8("lineEdit_project")) - self.hl_project.addWidget(self.lineEdit_project) - self.btn_project_dir = QtGui.QToolButton(self.grp_project) - self.btn_project_dir.setObjectName(_fromUtf8("btn_project_dir")) - self.hl_project.addWidget(self.btn_project_dir) - self.hl_project.setStretch(1, 1) - self.verticalLayout.addLayout(self.hl_project) - self.verticalLayout_3.addWidget(self.grp_project) - self.grp_shaders = QtGui.QGroupBox(ProjectSetup) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.grp_shaders.sizePolicy().hasHeightForWidth()) - self.grp_shaders.setSizePolicy(sizePolicy) - self.grp_shaders.setMinimumSize(QtCore.QSize(0, 0)) - self.grp_shaders.setMaximumSize(QtCore.QSize(16777215, 16777215)) - self.grp_shaders.setObjectName(_fromUtf8("grp_shaders")) - self.verticalLayout_2 = QtGui.QVBoxLayout(self.grp_shaders) - self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) - self.hl_shaders = QtGui.QHBoxLayout() - self.hl_shaders.setObjectName(_fromUtf8("hl_shaders")) - self.label_shaders = QtGui.QLabel(self.grp_shaders) - self.label_shaders.setMinimumSize(QtCore.QSize(80, 0)) - self.label_shaders.setMaximumSize(QtCore.QSize(80, 16777215)) - self.label_shaders.setObjectName(_fromUtf8("label_shaders")) - self.hl_shaders.addWidget(self.label_shaders) - self.lineEdit_shaders = QtGui.QLineEdit(self.grp_shaders) - self.lineEdit_shaders.setObjectName(_fromUtf8("lineEdit_shaders")) - self.hl_shaders.addWidget(self.lineEdit_shaders) - self.btn_shaders_dir = QtGui.QToolButton(self.grp_shaders) - self.btn_shaders_dir.setObjectName(_fromUtf8("btn_shaders_dir")) - self.hl_shaders.addWidget(self.btn_shaders_dir) - self.verticalLayout_2.addLayout(self.hl_shaders) - self.hl_network = QtGui.QHBoxLayout() - self.hl_network.setObjectName(_fromUtf8("hl_network")) - self.label_network = QtGui.QLabel(self.grp_shaders) - self.label_network.setMinimumSize(QtCore.QSize(80, 0)) - self.label_network.setMaximumSize(QtCore.QSize(80, 16777215)) - self.label_network.setObjectName(_fromUtf8("label_network")) - self.hl_network.addWidget(self.label_network) - self.lineEdit_network = QtGui.QLineEdit(self.grp_shaders) - self.lineEdit_network.setObjectName(_fromUtf8("lineEdit_network")) - self.hl_network.addWidget(self.lineEdit_network) - self.btn_network_dir = QtGui.QToolButton(self.grp_shaders) - self.btn_network_dir.setObjectName(_fromUtf8("btn_network_dir")) - self.hl_network.addWidget(self.btn_network_dir) - self.verticalLayout_2.addLayout(self.hl_network) - self.hl_sources = QtGui.QHBoxLayout() - self.hl_sources.setObjectName(_fromUtf8("hl_sources")) - self.label_sources = QtGui.QLabel(self.grp_shaders) - self.label_sources.setMinimumSize(QtCore.QSize(80, 0)) - self.label_sources.setMaximumSize(QtCore.QSize(80, 16777215)) - self.label_sources.setObjectName(_fromUtf8("label_sources")) - self.hl_sources.addWidget(self.label_sources) - self.lineEdit_sources = QtGui.QLineEdit(self.grp_shaders) - self.lineEdit_sources.setObjectName(_fromUtf8("lineEdit_sources")) - self.hl_sources.addWidget(self.lineEdit_sources) - self.btn_sources_dir = QtGui.QToolButton(self.grp_shaders) - self.btn_sources_dir.setObjectName(_fromUtf8("btn_sources_dir")) - self.hl_sources.addWidget(self.btn_sources_dir) - self.verticalLayout_2.addLayout(self.hl_sources) - self.hl_textures = QtGui.QHBoxLayout() - self.hl_textures.setObjectName(_fromUtf8("hl_textures")) - self.label_textures = QtGui.QLabel(self.grp_shaders) - self.label_textures.setMinimumSize(QtCore.QSize(80, 0)) - self.label_textures.setMaximumSize(QtCore.QSize(80, 16777215)) - self.label_textures.setObjectName(_fromUtf8("label_textures")) - self.hl_textures.addWidget(self.label_textures) - self.lineEdit_textures = QtGui.QLineEdit(self.grp_shaders) - self.lineEdit_textures.setObjectName(_fromUtf8("lineEdit_textures")) - self.hl_textures.addWidget(self.lineEdit_textures) - self.btn_textures_dir = QtGui.QToolButton(self.grp_shaders) - self.btn_textures_dir.setObjectName(_fromUtf8("btn_textures_dir")) - self.hl_textures.addWidget(self.btn_textures_dir) - self.verticalLayout_2.addLayout(self.hl_textures) - self.verticalLayout_3.addWidget(self.grp_shaders) - spacerItem = QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.verticalLayout_3.addItem(spacerItem) - self.buttonBox = QtGui.QDialogButtonBox(ProjectSetup) - self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) - self.buttonBox.setObjectName(_fromUtf8("buttonBox")) - self.verticalLayout_3.addWidget(self.buttonBox) + def setupUi(self, ProjectSetup): + ProjectSetup.setObjectName(_fromUtf8("ProjectSetup")) + ProjectSetup.resize(426, 342) + sizePolicy = QtModule.QSizePolicy(QtModule.QSizePolicy.Preferred, QtModule.QSizePolicy.Minimum) + sizePolicy.setHorizontalStretch(1) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(ProjectSetup.sizePolicy().hasHeightForWidth()) + ProjectSetup.setSizePolicy(sizePolicy) + ProjectSetup.setMinimumSize(QtCore.QSize(0, 0)) + ProjectSetup.setMaximumSize(QtCore.QSize(16777215, 16777215)) + ProjectSetup.setSizeGripEnabled(False) + self.verticalLayout_3 = QtModule.QVBoxLayout(ProjectSetup) + self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3")) + self.grp_project = QtModule.QGroupBox(ProjectSetup) + sizePolicy = QtModule.QSizePolicy(QtModule.QSizePolicy.Preferred, QtModule.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.grp_project.sizePolicy().hasHeightForWidth()) + self.grp_project.setSizePolicy(sizePolicy) + self.grp_project.setMinimumSize(QtCore.QSize(0, 0)) + self.grp_project.setMaximumSize(QtCore.QSize(16777215, 16777215)) + self.grp_project.setObjectName(_fromUtf8("grp_project")) + self.verticalLayout = QtModule.QVBoxLayout(self.grp_project) + self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + self.hl_project = QtModule.QHBoxLayout() + self.hl_project.setObjectName(_fromUtf8("hl_project")) + self.label_project = QtModule.QLabel(self.grp_project) + self.label_project.setMinimumSize(QtCore.QSize(80, 0)) + self.label_project.setMaximumSize(QtCore.QSize(80, 16777215)) + self.label_project.setObjectName(_fromUtf8("label_project")) + self.hl_project.addWidget(self.label_project) + self.lineEdit_project = QtModule.QLineEdit(self.grp_project) + self.lineEdit_project.setObjectName(_fromUtf8("lineEdit_project")) + self.hl_project.addWidget(self.lineEdit_project) + self.btn_project_dir = QtModule.QToolButton(self.grp_project) + self.btn_project_dir.setObjectName(_fromUtf8("btn_project_dir")) + self.hl_project.addWidget(self.btn_project_dir) + self.hl_project.setStretch(1, 1) + self.verticalLayout.addLayout(self.hl_project) + self.verticalLayout_3.addWidget(self.grp_project) + self.grp_shaders = QtModule.QGroupBox(ProjectSetup) + sizePolicy = QtModule.QSizePolicy(QtModule.QSizePolicy.Preferred, QtModule.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.grp_shaders.sizePolicy().hasHeightForWidth()) + self.grp_shaders.setSizePolicy(sizePolicy) + self.grp_shaders.setMinimumSize(QtCore.QSize(0, 0)) + self.grp_shaders.setMaximumSize(QtCore.QSize(16777215, 16777215)) + self.grp_shaders.setObjectName(_fromUtf8("grp_shaders")) + self.verticalLayout_2 = QtModule.QVBoxLayout(self.grp_shaders) + self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) + self.hl_shaders = QtModule.QHBoxLayout() + self.hl_shaders.setObjectName(_fromUtf8("hl_shaders")) + self.label_shaders = QtModule.QLabel(self.grp_shaders) + self.label_shaders.setMinimumSize(QtCore.QSize(80, 0)) + self.label_shaders.setMaximumSize(QtCore.QSize(80, 16777215)) + self.label_shaders.setObjectName(_fromUtf8("label_shaders")) + self.hl_shaders.addWidget(self.label_shaders) + self.lineEdit_shaders = QtModule.QLineEdit(self.grp_shaders) + self.lineEdit_shaders.setObjectName(_fromUtf8("lineEdit_shaders")) + self.hl_shaders.addWidget(self.lineEdit_shaders) + self.btn_shaders_dir = QtModule.QToolButton(self.grp_shaders) + self.btn_shaders_dir.setObjectName(_fromUtf8("btn_shaders_dir")) + self.hl_shaders.addWidget(self.btn_shaders_dir) + self.verticalLayout_2.addLayout(self.hl_shaders) + self.hl_network = QtModule.QHBoxLayout() + self.hl_network.setObjectName(_fromUtf8("hl_network")) + self.label_network = QtModule.QLabel(self.grp_shaders) + self.label_network.setMinimumSize(QtCore.QSize(80, 0)) + self.label_network.setMaximumSize(QtCore.QSize(80, 16777215)) + self.label_network.setObjectName(_fromUtf8("label_network")) + self.hl_network.addWidget(self.label_network) + self.lineEdit_network = QtModule.QLineEdit(self.grp_shaders) + self.lineEdit_network.setObjectName(_fromUtf8("lineEdit_network")) + self.hl_network.addWidget(self.lineEdit_network) + self.btn_network_dir = QtModule.QToolButton(self.grp_shaders) + self.btn_network_dir.setObjectName(_fromUtf8("btn_network_dir")) + self.hl_network.addWidget(self.btn_network_dir) + self.verticalLayout_2.addLayout(self.hl_network) + self.hl_sources = QtModule.QHBoxLayout() + self.hl_sources.setObjectName(_fromUtf8("hl_sources")) + self.label_sources = QtModule.QLabel(self.grp_shaders) + self.label_sources.setMinimumSize(QtCore.QSize(80, 0)) + self.label_sources.setMaximumSize(QtCore.QSize(80, 16777215)) + self.label_sources.setObjectName(_fromUtf8("label_sources")) + self.hl_sources.addWidget(self.label_sources) + self.lineEdit_sources = QtModule.QLineEdit(self.grp_shaders) + self.lineEdit_sources.setObjectName(_fromUtf8("lineEdit_sources")) + self.hl_sources.addWidget(self.lineEdit_sources) + self.btn_sources_dir = QtModule.QToolButton(self.grp_shaders) + self.btn_sources_dir.setObjectName(_fromUtf8("btn_sources_dir")) + self.hl_sources.addWidget(self.btn_sources_dir) + self.verticalLayout_2.addLayout(self.hl_sources) + self.hl_textures = QtModule.QHBoxLayout() + self.hl_textures.setObjectName(_fromUtf8("hl_textures")) + self.label_textures = QtModule.QLabel(self.grp_shaders) + self.label_textures.setMinimumSize(QtCore.QSize(80, 0)) + self.label_textures.setMaximumSize(QtCore.QSize(80, 16777215)) + self.label_textures.setObjectName(_fromUtf8("label_textures")) + self.hl_textures.addWidget(self.label_textures) + self.lineEdit_textures = QtModule.QLineEdit(self.grp_shaders) + self.lineEdit_textures.setObjectName(_fromUtf8("lineEdit_textures")) + self.hl_textures.addWidget(self.lineEdit_textures) + self.btn_textures_dir = QtModule.QToolButton(self.grp_shaders) + self.btn_textures_dir.setObjectName(_fromUtf8("btn_textures_dir")) + self.hl_textures.addWidget(self.btn_textures_dir) + self.verticalLayout_2.addLayout(self.hl_textures) + self.verticalLayout_3.addWidget(self.grp_shaders) + spacerItem = QtModule.QSpacerItem(20, 20, QtModule.QSizePolicy.Minimum, QtModule.QSizePolicy.Expanding) + self.verticalLayout_3.addItem(spacerItem) + self.buttonBox = QtGui.QDialogButtonBox(ProjectSetup) + self.buttonBox.setOrientation(QtCore.Qt.Horizontal) + self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) + self.buttonBox.setObjectName(_fromUtf8("buttonBox")) + self.verticalLayout_3.addWidget(self.buttonBox) - self.retranslateUi(ProjectSetup) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), ProjectSetup.accept) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), ProjectSetup.reject) - QtCore.QObject.connect(self.btn_project_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), ProjectSetup.onBrowseProjectDir) - QtCore.QObject.connect(self.btn_network_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), ProjectSetup.onBrowseNetworksDir) - QtCore.QObject.connect(self.btn_shaders_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), ProjectSetup.onBrowseShadersDir) - QtCore.QObject.connect(self.btn_sources_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), ProjectSetup.onBrowseSourcesDir) - QtCore.QObject.connect(self.btn_textures_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), ProjectSetup.onBrowseTexturesDir) - QtCore.QMetaObject.connectSlotsByName(ProjectSetup) + self.retranslateUi(ProjectSetup) + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), ProjectSetup.accept) + QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), ProjectSetup.reject) + QtCore.QObject.connect(self.btn_project_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), ProjectSetup.onBrowseProjectDir) + QtCore.QObject.connect(self.btn_network_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), ProjectSetup.onBrowseNetworksDir) + QtCore.QObject.connect(self.btn_shaders_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), ProjectSetup.onBrowseShadersDir) + QtCore.QObject.connect(self.btn_sources_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), ProjectSetup.onBrowseSourcesDir) + QtCore.QObject.connect(self.btn_textures_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), ProjectSetup.onBrowseTexturesDir) + else : + self.buttonBox.accepted.connect( ProjectSetup.accept) + self.buttonBox.rejected.connect( ProjectSetup.reject) + self.btn_project_dir.clicked.connect( ProjectSetup.onBrowseProjectDir) + self.btn_network_dir.clicked.connect( ProjectSetup.onBrowseNetworksDir) + self.btn_shaders_dir.clicked.connect( ProjectSetup.onBrowseShadersDir) + self.btn_sources_dir.clicked.connect( ProjectSetup.onBrowseSourcesDir) + self.btn_textures_dir.clicked.connect( ProjectSetup.onBrowseTexturesDir) + + QtCore.QMetaObject.connectSlotsByName(ProjectSetup) - def retranslateUi(self, ProjectSetup): - ProjectSetup.setWindowTitle(QtGui.QApplication.translate("ProjectSetup", "Project Setup", None, QtGui.QApplication.UnicodeUTF8)) - self.grp_project.setTitle(QtGui.QApplication.translate("ProjectSetup", "Project", None, QtGui.QApplication.UnicodeUTF8)) - self.label_project.setText(QtGui.QApplication.translate("ProjectSetup", "Root", None, QtGui.QApplication.UnicodeUTF8)) - self.btn_project_dir.setText(QtGui.QApplication.translate("ProjectSetup", "...", None, QtGui.QApplication.UnicodeUTF8)) - self.grp_shaders.setTitle(QtGui.QApplication.translate("ProjectSetup", "Resources", None, QtGui.QApplication.UnicodeUTF8)) - self.label_shaders.setText(QtGui.QApplication.translate("ProjectSetup", "Shaders", None, QtGui.QApplication.UnicodeUTF8)) - self.btn_shaders_dir.setText(QtGui.QApplication.translate("ProjectSetup", "...", None, QtGui.QApplication.UnicodeUTF8)) - self.label_network.setText(QtGui.QApplication.translate("ProjectSetup", "Networks", None, QtGui.QApplication.UnicodeUTF8)) - self.btn_network_dir.setText(QtGui.QApplication.translate("ProjectSetup", "...", None, QtGui.QApplication.UnicodeUTF8)) - self.label_sources.setText(QtGui.QApplication.translate("ProjectSetup", "Sources", None, QtGui.QApplication.UnicodeUTF8)) - self.btn_sources_dir.setText(QtGui.QApplication.translate("ProjectSetup", "...", None, QtGui.QApplication.UnicodeUTF8)) - self.label_textures.setText(QtGui.QApplication.translate("ProjectSetup", "Textures", None, QtGui.QApplication.UnicodeUTF8)) - self.btn_textures_dir.setText(QtGui.QApplication.translate("ProjectSetup", "...", None, QtGui.QApplication.UnicodeUTF8)) + def retranslateUi(self, ProjectSetup): + ProjectSetup.setWindowTitle(QtGui.QApplication.translate("ProjectSetup", "Project Setup", None)) + self.grp_project.setTitle(QtGui.QApplication.translate("ProjectSetup", "Project", None)) + self.label_project.setText(QtGui.QApplication.translate("ProjectSetup", "Root", None)) + self.btn_project_dir.setText(QtGui.QApplication.translate("ProjectSetup", "...", None)) + self.grp_shaders.setTitle(QtGui.QApplication.translate("ProjectSetup", "Resources", None)) + self.label_shaders.setText(QtGui.QApplication.translate("ProjectSetup", "Shaders", None)) + self.btn_shaders_dir.setText(QtGui.QApplication.translate("ProjectSetup", "...", None)) + self.label_network.setText(QtGui.QApplication.translate("ProjectSetup", "Networks", None)) + self.btn_network_dir.setText(QtGui.QApplication.translate("ProjectSetup", "...", None)) + self.label_sources.setText(QtGui.QApplication.translate("ProjectSetup", "Sources", None)) + self.btn_sources_dir.setText(QtGui.QApplication.translate("ProjectSetup", "...", None)) + self.label_textures.setText(QtGui.QApplication.translate("ProjectSetup", "Textures", None)) + self.btn_textures_dir.setText(QtGui.QApplication.translate("ProjectSetup", "...", None)) diff --git a/gui/ui_settingsSetup.py b/gui/ui_settingsSetup.py index cf8eeb6..e7459f3 100644 --- a/gui/ui_settingsSetup.py +++ b/gui/ui_settingsSetup.py @@ -9,179 +9,196 @@ from core.mePyQt import QtCore, QtGui +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + try: - _fromUtf8 = QtCore.QString.fromUtf8 + _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: - _fromUtf8 = lambda s: s + _fromUtf8 = lambda s: s class Ui_SettingsSetup(object): - def setupUi(self, SettingsSetup): - SettingsSetup.setObjectName(_fromUtf8("SettingsSetup")) - SettingsSetup.resize(376, 346) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum) - sizePolicy.setHorizontalStretch(1) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(SettingsSetup.sizePolicy().hasHeightForWidth()) - SettingsSetup.setSizePolicy(sizePolicy) - SettingsSetup.setMinimumSize(QtCore.QSize(0, 0)) - SettingsSetup.setMaximumSize(QtCore.QSize(16777215, 16777215)) - SettingsSetup.setSizeGripEnabled(False) - self.verticalLayout_2 = QtGui.QVBoxLayout(SettingsSetup) - self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) - self.grp_dirs = QtGui.QGroupBox(SettingsSetup) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.grp_dirs.sizePolicy().hasHeightForWidth()) - self.grp_dirs.setSizePolicy(sizePolicy) - self.grp_dirs.setMinimumSize(QtCore.QSize(0, 0)) - self.grp_dirs.setMaximumSize(QtCore.QSize(16777215, 16777215)) - self.grp_dirs.setObjectName(_fromUtf8("grp_dirs")) - self.verticalLayout = QtGui.QVBoxLayout(self.grp_dirs) - self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) - self.hl_temp = QtGui.QHBoxLayout() - self.hl_temp.setSizeConstraint(QtGui.QLayout.SetMinimumSize) - self.hl_temp.setObjectName(_fromUtf8("hl_temp")) - self.label_temp = QtGui.QLabel(self.grp_dirs) - self.label_temp.setMinimumSize(QtCore.QSize(80, 0)) - self.label_temp.setMaximumSize(QtCore.QSize(80, 16777215)) - self.label_temp.setBaseSize(QtCore.QSize(60, 0)) - self.label_temp.setObjectName(_fromUtf8("label_temp")) - self.hl_temp.addWidget(self.label_temp) - self.lineEdit_temp = QtGui.QLineEdit(self.grp_dirs) - self.lineEdit_temp.setObjectName(_fromUtf8("lineEdit_temp")) - self.hl_temp.addWidget(self.lineEdit_temp) - self.btn_temp_dir = QtGui.QToolButton(self.grp_dirs) - self.btn_temp_dir.setObjectName(_fromUtf8("btn_temp_dir")) - self.hl_temp.addWidget(self.btn_temp_dir) - self.hl_temp.setStretch(1, 1) - self.verticalLayout.addLayout(self.hl_temp) - self.hl_inc = QtGui.QHBoxLayout() - self.hl_inc.setObjectName(_fromUtf8("hl_inc")) - self.label_inc = QtGui.QLabel(self.grp_dirs) - self.label_inc.setMinimumSize(QtCore.QSize(80, 0)) - self.label_inc.setMaximumSize(QtCore.QSize(80, 16777215)) - self.label_inc.setObjectName(_fromUtf8("label_inc")) - self.hl_inc.addWidget(self.label_inc) - self.lineEdit_inc = QtGui.QLineEdit(self.grp_dirs) - self.lineEdit_inc.setObjectName(_fromUtf8("lineEdit_inc")) - self.hl_inc.addWidget(self.lineEdit_inc) - self.btn_inc_dir = QtGui.QToolButton(self.grp_dirs) - self.btn_inc_dir.setObjectName(_fromUtf8("btn_inc_dir")) - self.hl_inc.addWidget(self.btn_inc_dir) - self.hl_inc.setStretch(1, 1) - self.verticalLayout.addLayout(self.hl_inc) - self.hl_lib = QtGui.QHBoxLayout() - self.hl_lib.setObjectName(_fromUtf8("hl_lib")) - self.label_lib = QtGui.QLabel(self.grp_dirs) - self.label_lib.setMinimumSize(QtCore.QSize(80, 0)) - self.label_lib.setMaximumSize(QtCore.QSize(80, 16777215)) - self.label_lib.setObjectName(_fromUtf8("label_lib")) - self.hl_lib.addWidget(self.label_lib) - self.lineEdit_lib = QtGui.QLineEdit(self.grp_dirs) - self.lineEdit_lib.setObjectName(_fromUtf8("lineEdit_lib")) - self.hl_lib.addWidget(self.lineEdit_lib) - self.btn_lib_dir = QtGui.QToolButton(self.grp_dirs) - self.btn_lib_dir.setObjectName(_fromUtf8("btn_lib_dir")) - self.hl_lib.addWidget(self.btn_lib_dir) - self.hl_lib.setStretch(1, 1) - self.verticalLayout.addLayout(self.hl_lib) - self.hl_nodes = QtGui.QHBoxLayout() - self.hl_nodes.setObjectName(_fromUtf8("hl_nodes")) - self.label_nodes = QtGui.QLabel(self.grp_dirs) - self.label_nodes.setMinimumSize(QtCore.QSize(80, 0)) - self.label_nodes.setMaximumSize(QtCore.QSize(80, 16777215)) - self.label_nodes.setObjectName(_fromUtf8("label_nodes")) - self.hl_nodes.addWidget(self.label_nodes) - self.lineEdit_nodes = QtGui.QLineEdit(self.grp_dirs) - self.lineEdit_nodes.setObjectName(_fromUtf8("lineEdit_nodes")) - self.hl_nodes.addWidget(self.lineEdit_nodes) - self.btn_nodes_dir = QtGui.QToolButton(self.grp_dirs) - self.btn_nodes_dir.setObjectName(_fromUtf8("btn_nodes_dir")) - self.hl_nodes.addWidget(self.btn_nodes_dir) - self.hl_nodes.setStretch(1, 1) - self.verticalLayout.addLayout(self.hl_nodes) - self.hl_shaders = QtGui.QHBoxLayout() - self.hl_shaders.setObjectName(_fromUtf8("hl_shaders")) - self.label_shaders = QtGui.QLabel(self.grp_dirs) - self.label_shaders.setMinimumSize(QtCore.QSize(80, 0)) - self.label_shaders.setMaximumSize(QtCore.QSize(80, 16777215)) - self.label_shaders.setObjectName(_fromUtf8("label_shaders")) - self.hl_shaders.addWidget(self.label_shaders) - self.lineEdit_shaders = QtGui.QLineEdit(self.grp_dirs) - self.lineEdit_shaders.setObjectName(_fromUtf8("lineEdit_shaders")) - self.hl_shaders.addWidget(self.lineEdit_shaders) - self.btn_shaders_dir = QtGui.QToolButton(self.grp_dirs) - self.btn_shaders_dir.setObjectName(_fromUtf8("btn_shaders_dir")) - self.hl_shaders.addWidget(self.btn_shaders_dir) - self.hl_shaders.setStretch(1, 1) - self.verticalLayout.addLayout(self.hl_shaders) - self.hl_textures = QtGui.QHBoxLayout() - self.hl_textures.setObjectName(_fromUtf8("hl_textures")) - self.label_textures = QtGui.QLabel(self.grp_dirs) - self.label_textures.setMinimumSize(QtCore.QSize(80, 0)) - self.label_textures.setMaximumSize(QtCore.QSize(80, 16777215)) - self.label_textures.setObjectName(_fromUtf8("label_textures")) - self.hl_textures.addWidget(self.label_textures) - self.lineEdit_textures = QtGui.QLineEdit(self.grp_dirs) - self.lineEdit_textures.setObjectName(_fromUtf8("lineEdit_textures")) - self.hl_textures.addWidget(self.lineEdit_textures) - self.btn_textures_dir = QtGui.QToolButton(self.grp_dirs) - self.btn_textures_dir.setObjectName(_fromUtf8("btn_textures_dir")) - self.hl_textures.addWidget(self.btn_textures_dir) - self.hl_textures.setStretch(1, 1) - self.verticalLayout.addLayout(self.hl_textures) - self.hl_archives = QtGui.QHBoxLayout() - self.hl_archives.setObjectName(_fromUtf8("hl_archives")) - self.label_archives = QtGui.QLabel(self.grp_dirs) - self.label_archives.setMinimumSize(QtCore.QSize(80, 0)) - self.label_archives.setMaximumSize(QtCore.QSize(80, 16777215)) - self.label_archives.setObjectName(_fromUtf8("label_archives")) - self.hl_archives.addWidget(self.label_archives) - self.lineEdit_archives = QtGui.QLineEdit(self.grp_dirs) - self.lineEdit_archives.setObjectName(_fromUtf8("lineEdit_archives")) - self.hl_archives.addWidget(self.lineEdit_archives) - self.btn_archives_dir = QtGui.QToolButton(self.grp_dirs) - self.btn_archives_dir.setObjectName(_fromUtf8("btn_archives_dir")) - self.hl_archives.addWidget(self.btn_archives_dir) - self.hl_archives.setStretch(1, 1) - self.verticalLayout.addLayout(self.hl_archives) - self.verticalLayout_2.addWidget(self.grp_dirs) - spacerItem = QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.verticalLayout_2.addItem(spacerItem) - self.buttonBox = QtGui.QDialogButtonBox(SettingsSetup) - self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) - self.buttonBox.setObjectName(_fromUtf8("buttonBox")) - self.verticalLayout_2.addWidget(self.buttonBox) + def setupUi(self, SettingsSetup): + SettingsSetup.setObjectName(_fromUtf8("SettingsSetup")) + SettingsSetup.resize(376, 346) + sizePolicy = QtModule.QSizePolicy(QtModule.QSizePolicy.Preferred, QtModule.QSizePolicy.Minimum) + sizePolicy.setHorizontalStretch(1) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(SettingsSetup.sizePolicy().hasHeightForWidth()) + SettingsSetup.setSizePolicy(sizePolicy) + SettingsSetup.setMinimumSize(QtCore.QSize(0, 0)) + SettingsSetup.setMaximumSize(QtCore.QSize(16777215, 16777215)) + SettingsSetup.setSizeGripEnabled(False) + self.verticalLayout_2 = QtModule.QVBoxLayout(SettingsSetup) + self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) + self.grp_dirs = QtModule.QGroupBox(SettingsSetup) + sizePolicy = QtModule.QSizePolicy(QtModule.QSizePolicy.Preferred, QtModule.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.grp_dirs.sizePolicy().hasHeightForWidth()) + self.grp_dirs.setSizePolicy(sizePolicy) + self.grp_dirs.setMinimumSize(QtCore.QSize(0, 0)) + self.grp_dirs.setMaximumSize(QtCore.QSize(16777215, 16777215)) + self.grp_dirs.setObjectName(_fromUtf8("grp_dirs")) + self.verticalLayout = QtModule.QVBoxLayout(self.grp_dirs) + self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + self.hl_temp = QtModule.QHBoxLayout() + self.hl_temp.setSizeConstraint(QtGui.QLayout.SetMinimumSize) + self.hl_temp.setObjectName(_fromUtf8("hl_temp")) + self.label_temp = QtModule.QLabel(self.grp_dirs) + self.label_temp.setMinimumSize(QtCore.QSize(80, 0)) + self.label_temp.setMaximumSize(QtCore.QSize(80, 16777215)) + self.label_temp.setBaseSize(QtCore.QSize(60, 0)) + self.label_temp.setObjectName(_fromUtf8("label_temp")) + self.hl_temp.addWidget(self.label_temp) + self.lineEdit_temp = QtModule.QLineEdit(self.grp_dirs) + self.lineEdit_temp.setObjectName(_fromUtf8("lineEdit_temp")) + self.hl_temp.addWidget(self.lineEdit_temp) + self.btn_temp_dir = QtModule.QToolButton(self.grp_dirs) + self.btn_temp_dir.setObjectName(_fromUtf8("btn_temp_dir")) + self.hl_temp.addWidget(self.btn_temp_dir) + self.hl_temp.setStretch(1, 1) + self.verticalLayout.addLayout(self.hl_temp) + self.hl_inc = QtModule.QHBoxLayout() + self.hl_inc.setObjectName(_fromUtf8("hl_inc")) + self.label_inc = QtModule.QLabel(self.grp_dirs) + self.label_inc.setMinimumSize(QtCore.QSize(80, 0)) + self.label_inc.setMaximumSize(QtCore.QSize(80, 16777215)) + self.label_inc.setObjectName(_fromUtf8("label_inc")) + self.hl_inc.addWidget(self.label_inc) + self.lineEdit_inc = QtModule.QLineEdit(self.grp_dirs) + self.lineEdit_inc.setObjectName(_fromUtf8("lineEdit_inc")) + self.hl_inc.addWidget(self.lineEdit_inc) + self.btn_inc_dir = QtModule.QToolButton(self.grp_dirs) + self.btn_inc_dir.setObjectName(_fromUtf8("btn_inc_dir")) + self.hl_inc.addWidget(self.btn_inc_dir) + self.hl_inc.setStretch(1, 1) + self.verticalLayout.addLayout(self.hl_inc) + self.hl_lib = QtModule.QHBoxLayout() + self.hl_lib.setObjectName(_fromUtf8("hl_lib")) + self.label_lib = QtModule.QLabel(self.grp_dirs) + self.label_lib.setMinimumSize(QtCore.QSize(80, 0)) + self.label_lib.setMaximumSize(QtCore.QSize(80, 16777215)) + self.label_lib.setObjectName(_fromUtf8("label_lib")) + self.hl_lib.addWidget(self.label_lib) + self.lineEdit_lib = QtModule.QLineEdit(self.grp_dirs) + self.lineEdit_lib.setObjectName(_fromUtf8("lineEdit_lib")) + self.hl_lib.addWidget(self.lineEdit_lib) + self.btn_lib_dir = QtModule.QToolButton(self.grp_dirs) + self.btn_lib_dir.setObjectName(_fromUtf8("btn_lib_dir")) + self.hl_lib.addWidget(self.btn_lib_dir) + self.hl_lib.setStretch(1, 1) + self.verticalLayout.addLayout(self.hl_lib) + self.hl_nodes = QtModule.QHBoxLayout() + self.hl_nodes.setObjectName(_fromUtf8("hl_nodes")) + self.label_nodes = QtModule.QLabel(self.grp_dirs) + self.label_nodes.setMinimumSize(QtCore.QSize(80, 0)) + self.label_nodes.setMaximumSize(QtCore.QSize(80, 16777215)) + self.label_nodes.setObjectName(_fromUtf8("label_nodes")) + self.hl_nodes.addWidget(self.label_nodes) + self.lineEdit_nodes = QtModule.QLineEdit(self.grp_dirs) + self.lineEdit_nodes.setObjectName(_fromUtf8("lineEdit_nodes")) + self.hl_nodes.addWidget(self.lineEdit_nodes) + self.btn_nodes_dir = QtModule.QToolButton(self.grp_dirs) + self.btn_nodes_dir.setObjectName(_fromUtf8("btn_nodes_dir")) + self.hl_nodes.addWidget(self.btn_nodes_dir) + self.hl_nodes.setStretch(1, 1) + self.verticalLayout.addLayout(self.hl_nodes) + self.hl_shaders = QtModule.QHBoxLayout() + self.hl_shaders.setObjectName(_fromUtf8("hl_shaders")) + self.label_shaders = QtModule.QLabel(self.grp_dirs) + self.label_shaders.setMinimumSize(QtCore.QSize(80, 0)) + self.label_shaders.setMaximumSize(QtCore.QSize(80, 16777215)) + self.label_shaders.setObjectName(_fromUtf8("label_shaders")) + self.hl_shaders.addWidget(self.label_shaders) + self.lineEdit_shaders = QtModule.QLineEdit(self.grp_dirs) + self.lineEdit_shaders.setObjectName(_fromUtf8("lineEdit_shaders")) + self.hl_shaders.addWidget(self.lineEdit_shaders) + self.btn_shaders_dir = QtModule.QToolButton(self.grp_dirs) + self.btn_shaders_dir.setObjectName(_fromUtf8("btn_shaders_dir")) + self.hl_shaders.addWidget(self.btn_shaders_dir) + self.hl_shaders.setStretch(1, 1) + self.verticalLayout.addLayout(self.hl_shaders) + self.hl_textures = QtModule.QHBoxLayout() + self.hl_textures.setObjectName(_fromUtf8("hl_textures")) + self.label_textures = QtModule.QLabel(self.grp_dirs) + self.label_textures.setMinimumSize(QtCore.QSize(80, 0)) + self.label_textures.setMaximumSize(QtCore.QSize(80, 16777215)) + self.label_textures.setObjectName(_fromUtf8("label_textures")) + self.hl_textures.addWidget(self.label_textures) + self.lineEdit_textures = QtModule.QLineEdit(self.grp_dirs) + self.lineEdit_textures.setObjectName(_fromUtf8("lineEdit_textures")) + self.hl_textures.addWidget(self.lineEdit_textures) + self.btn_textures_dir = QtModule.QToolButton(self.grp_dirs) + self.btn_textures_dir.setObjectName(_fromUtf8("btn_textures_dir")) + self.hl_textures.addWidget(self.btn_textures_dir) + self.hl_textures.setStretch(1, 1) + self.verticalLayout.addLayout(self.hl_textures) + self.hl_archives = QtModule.QHBoxLayout() + self.hl_archives.setObjectName(_fromUtf8("hl_archives")) + self.label_archives = QtModule.QLabel(self.grp_dirs) + self.label_archives.setMinimumSize(QtCore.QSize(80, 0)) + self.label_archives.setMaximumSize(QtCore.QSize(80, 16777215)) + self.label_archives.setObjectName(_fromUtf8("label_archives")) + self.hl_archives.addWidget(self.label_archives) + self.lineEdit_archives = QtModule.QLineEdit(self.grp_dirs) + self.lineEdit_archives.setObjectName(_fromUtf8("lineEdit_archives")) + self.hl_archives.addWidget(self.lineEdit_archives) + self.btn_archives_dir = QtModule.QToolButton(self.grp_dirs) + self.btn_archives_dir.setObjectName(_fromUtf8("btn_archives_dir")) + self.hl_archives.addWidget(self.btn_archives_dir) + self.hl_archives.setStretch(1, 1) + self.verticalLayout.addLayout(self.hl_archives) + self.verticalLayout_2.addWidget(self.grp_dirs) + spacerItem = QtModule.QSpacerItem(20, 20, QtModule.QSizePolicy.Minimum, QtModule.QSizePolicy.Expanding) + self.verticalLayout_2.addItem(spacerItem) + self.buttonBox = QtModule.QDialogButtonBox(SettingsSetup) + self.buttonBox.setOrientation(QtCore.Qt.Horizontal) + self.buttonBox.setStandardButtons(QtModule.QDialogButtonBox.Cancel|QtModule.QDialogButtonBox.Ok) + self.buttonBox.setObjectName(_fromUtf8("buttonBox")) + self.verticalLayout_2.addWidget(self.buttonBox) - self.retranslateUi(SettingsSetup) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), SettingsSetup.accept) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), SettingsSetup.reject) - QtCore.QObject.connect(self.btn_lib_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), SettingsSetup.onBrowseLibraryDir) - QtCore.QObject.connect(self.btn_temp_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), SettingsSetup.onBrowseTempDir) - QtCore.QObject.connect(self.btn_inc_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), SettingsSetup.onBrowseIncludesDir) - QtCore.QObject.connect(self.btn_nodes_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), SettingsSetup.onBrowseNodesDir) - QtCore.QObject.connect(self.btn_shaders_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), SettingsSetup.onBrowseShadersDir) - QtCore.QObject.connect(self.btn_textures_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), SettingsSetup.onBrowseTexturesDir) - QtCore.QObject.connect(self.btn_archives_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), SettingsSetup.onBrowseArchivesDir) - QtCore.QMetaObject.connectSlotsByName(SettingsSetup) + self.retranslateUi(SettingsSetup) + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), SettingsSetup.accept) + QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), SettingsSetup.reject) + QtCore.QObject.connect(self.btn_lib_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), SettingsSetup.onBrowseLibraryDir) + QtCore.QObject.connect(self.btn_temp_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), SettingsSetup.onBrowseTempDir) + QtCore.QObject.connect(self.btn_inc_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), SettingsSetup.onBrowseIncludesDir) + QtCore.QObject.connect(self.btn_nodes_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), SettingsSetup.onBrowseNodesDir) + QtCore.QObject.connect(self.btn_shaders_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), SettingsSetup.onBrowseShadersDir) + QtCore.QObject.connect(self.btn_textures_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), SettingsSetup.onBrowseTexturesDir) + QtCore.QObject.connect(self.btn_archives_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), SettingsSetup.onBrowseArchivesDir) + else : + self.buttonBox.accepted.connect( SettingsSetup.accept) + self.buttonBox.rejected.connect( SettingsSetup.reject) + self.btn_lib_dir.clicked.connect( SettingsSetup.onBrowseLibraryDir) + self.btn_temp_dir.clicked.connect( SettingsSetup.onBrowseTempDir) + self.btn_inc_dir.clicked.connect( SettingsSetup.onBrowseIncludesDir) + self.btn_nodes_dir.clicked.connect( SettingsSetup.onBrowseNodesDir) + self.btn_shaders_dir.clicked.connect( SettingsSetup.onBrowseShadersDir) + self.btn_textures_dir.clicked.connect( SettingsSetup.onBrowseTexturesDir) + self.btn_archives_dir.clicked.connect( SettingsSetup.onBrowseArchivesDir) + QtCore.QMetaObject.connectSlotsByName(SettingsSetup) - def retranslateUi(self, SettingsSetup): - SettingsSetup.setWindowTitle(QtGui.QApplication.translate("SettingsSetup", "Settings Setup", None, QtGui.QApplication.UnicodeUTF8)) - self.grp_dirs.setTitle(QtGui.QApplication.translate("SettingsSetup", "Directories", None, QtGui.QApplication.UnicodeUTF8)) - self.label_temp.setText(QtGui.QApplication.translate("SettingsSetup", "Temp", None, QtGui.QApplication.UnicodeUTF8)) - self.btn_temp_dir.setText(QtGui.QApplication.translate("SettingsSetup", "...", None, QtGui.QApplication.UnicodeUTF8)) - self.label_inc.setText(QtGui.QApplication.translate("SettingsSetup", "Includes", None, QtGui.QApplication.UnicodeUTF8)) - self.btn_inc_dir.setText(QtGui.QApplication.translate("SettingsSetup", "...", None, QtGui.QApplication.UnicodeUTF8)) - self.label_lib.setText(QtGui.QApplication.translate("SettingsSetup", "Library", None, QtGui.QApplication.UnicodeUTF8)) - self.btn_lib_dir.setText(QtGui.QApplication.translate("SettingsSetup", "...", None, QtGui.QApplication.UnicodeUTF8)) - self.label_nodes.setText(QtGui.QApplication.translate("SettingsSetup", "Nodes", None, QtGui.QApplication.UnicodeUTF8)) - self.btn_nodes_dir.setText(QtGui.QApplication.translate("SettingsSetup", "...", None, QtGui.QApplication.UnicodeUTF8)) - self.label_shaders.setText(QtGui.QApplication.translate("SettingsSetup", "Shaders", None, QtGui.QApplication.UnicodeUTF8)) - self.btn_shaders_dir.setText(QtGui.QApplication.translate("SettingsSetup", "...", None, QtGui.QApplication.UnicodeUTF8)) - self.label_textures.setText(QtGui.QApplication.translate("SettingsSetup", "Textures", None, QtGui.QApplication.UnicodeUTF8)) - self.btn_textures_dir.setText(QtGui.QApplication.translate("SettingsSetup", "...", None, QtGui.QApplication.UnicodeUTF8)) - self.label_archives.setText(QtGui.QApplication.translate("SettingsSetup", "Archives", None, QtGui.QApplication.UnicodeUTF8)) - self.btn_archives_dir.setText(QtGui.QApplication.translate("SettingsSetup", "...", None, QtGui.QApplication.UnicodeUTF8)) + def retranslateUi(self, SettingsSetup): + SettingsSetup.setWindowTitle(QtGui.QApplication.translate("SettingsSetup", "Settings Setup", None)) + self.grp_dirs.setTitle(QtGui.QApplication.translate("SettingsSetup", "Directories", None)) + self.label_temp.setText(QtGui.QApplication.translate("SettingsSetup", "Temp", None)) + self.btn_temp_dir.setText(QtGui.QApplication.translate("SettingsSetup", "...", None)) + self.label_inc.setText(QtGui.QApplication.translate("SettingsSetup", "Includes", None)) + self.btn_inc_dir.setText(QtGui.QApplication.translate("SettingsSetup", "...", None)) + self.label_lib.setText(QtGui.QApplication.translate("SettingsSetup", "Library", None)) + self.btn_lib_dir.setText(QtGui.QApplication.translate("SettingsSetup", "...", None)) + self.label_nodes.setText(QtGui.QApplication.translate("SettingsSetup", "Nodes", None)) + self.btn_nodes_dir.setText(QtGui.QApplication.translate("SettingsSetup", "...", None)) + self.label_shaders.setText(QtGui.QApplication.translate("SettingsSetup", "Shaders", None)) + self.btn_shaders_dir.setText(QtGui.QApplication.translate("SettingsSetup", "...", None)) + self.label_textures.setText(QtGui.QApplication.translate("SettingsSetup", "Textures", None)) + self.btn_textures_dir.setText(QtGui.QApplication.translate("SettingsSetup", "...", None)) + self.label_archives.setText(QtGui.QApplication.translate("SettingsSetup", "Archives", None)) + self.btn_archives_dir.setText(QtGui.QApplication.translate("SettingsSetup", "...", None)) diff --git a/gui/ui_viewComputedCodeDialog.py b/gui/ui_viewComputedCodeDialog.py index b4b3af3..cff0dce 100644 --- a/gui/ui_viewComputedCodeDialog.py +++ b/gui/ui_viewComputedCodeDialog.py @@ -9,41 +9,51 @@ from core.mePyQt import QtCore, QtGui +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + try: - _fromUtf8 = QtCore.QString.fromUtf8 + _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: - def _fromUtf8(s): - return s + def _fromUtf8(s): + return s try: - _encoding = QtGui.QApplication.UnicodeUTF8 - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig, _encoding) + _encoding = QtGui.QApplication.UnicodeUTF8 + def _translate(context, text, disambig): + return QtModule.QApplication.translate(context, text, disambig, _encoding) except AttributeError: - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig) + def _translate(context, text, disambig): + return QtModule.QApplication.translate(context, text, disambig) class Ui_ViewComputedCodeDialog(object): - def setupUi(self, ViewComputedCodeDialog): - ViewComputedCodeDialog.setObjectName(_fromUtf8("ViewComputedCodeDialog")) - ViewComputedCodeDialog.resize(681, 669) - self.gridLayout = QtGui.QGridLayout(ViewComputedCodeDialog) - self.gridLayout.setObjectName(_fromUtf8("gridLayout")) - self.codeEdit = NodeCodeEditor(ViewComputedCodeDialog) - self.codeEdit.setObjectName(_fromUtf8("codeEdit")) - self.gridLayout.addWidget(self.codeEdit, 0, 0, 1, 1) - self.buttonBox = QtGui.QDialogButtonBox(ViewComputedCodeDialog) - self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Close) - self.buttonBox.setObjectName(_fromUtf8("buttonBox")) - self.gridLayout.addWidget(self.buttonBox, 1, 0, 1, 1) - - self.retranslateUi(ViewComputedCodeDialog) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), ViewComputedCodeDialog.accept) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), ViewComputedCodeDialog.reject) - QtCore.QMetaObject.connectSlotsByName(ViewComputedCodeDialog) - - def retranslateUi(self, ViewComputedCodeDialog): - ViewComputedCodeDialog.setWindowTitle(_translate("ViewComputedCodeDialog", "Dialog", None)) + def setupUi(self, ViewComputedCodeDialog): + ViewComputedCodeDialog.setObjectName(_fromUtf8("ViewComputedCodeDialog")) + ViewComputedCodeDialog.resize(681, 669) + self.gridLayout = QtModule.QGridLayout(ViewComputedCodeDialog) + self.gridLayout.setObjectName(_fromUtf8("gridLayout")) + self.codeEdit = NodeCodeEditor(ViewComputedCodeDialog) + self.codeEdit.setObjectName(_fromUtf8("codeEdit")) + self.gridLayout.addWidget(self.codeEdit, 0, 0, 1, 1) + self.buttonBox = QtModule.QDialogButtonBox(ViewComputedCodeDialog) + self.buttonBox.setOrientation(QtCore.Qt.Horizontal) + self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Close) + self.buttonBox.setObjectName(_fromUtf8("buttonBox")) + self.gridLayout.addWidget(self.buttonBox, 1, 0, 1, 1) + + self.retranslateUi(ViewComputedCodeDialog) + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), ViewComputedCodeDialog.accept) + QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), ViewComputedCodeDialog.reject) + else : + self.buttonBox.accepted.connect( ViewComputedCodeDialog.accept ) + self.buttonBox.rejected.connect( ViewComputedCodeDialog.reject ) + QtCore.QMetaObject.connectSlotsByName(ViewComputedCodeDialog) + + def retranslateUi(self, ViewComputedCodeDialog): + ViewComputedCodeDialog.setWindowTitle(_translate("ViewComputedCodeDialog", "Dialog", None)) from gui.nodeEditor.nodeCodeEditor import NodeCodeEditor diff --git a/gui/ui_workArea.py b/gui/ui_workArea.py index 6997171..7e10420 100644 --- a/gui/ui_workArea.py +++ b/gui/ui_workArea.py @@ -9,6 +9,12 @@ from core.mePyQt import QtCore, QtGui +if QtCore.QT_VERSION < 50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: @@ -19,11 +25,11 @@ def setupUi(self, workArea): workArea.setObjectName(_fromUtf8("workArea")) workArea.resize(668, 594) workArea.setAcceptDrops(True) - self.gridLayout = QtGui.QGridLayout(workArea) + self.gridLayout = QtModule.QGridLayout(workArea) self.gridLayout.setMargin(0) self.gridLayout.setSpacing(0) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) - self.graphicsView = QtGui.QGraphicsView(workArea) + self.graphicsView = QtModule.QGraphicsView(workArea) self.graphicsView.setObjectName(_fromUtf8("graphicsView")) self.gridLayout.addWidget(self.graphicsView, 0, 0, 1, 1) @@ -31,5 +37,5 @@ def setupUi(self, workArea): QtCore.QMetaObject.connectSlotsByName(workArea) def retranslateUi(self, workArea): - workArea.setWindowTitle(QtGui.QApplication.translate("workArea", "network", None, QtGui.QApplication.UnicodeUTF8)) + workArea.setWindowTitle(QtModule.QApplication.translate("workArea", "network", None )) diff --git a/meShaderEd.py b/meShaderEd.py index a3d536c..641f261 100644 --- a/meShaderEd.py +++ b/meShaderEd.py @@ -75,8 +75,8 @@ def getDefaultValue ( settings, group, key, def_value = None ) : else : value = str ( value.toString () ) else : - if value == 'true' : value = True - elif value == 'false' : value = False + if value == 'true' or value is True : value = True + elif value == 'false' or value is False : value = False else : if def_value is not None and isinstance ( def_value, QtGui.QColor ) : value = QtGui.QColor ( value ) From e066f4e0286d48e01adf57999d1d941047f1227d Mon Sep 17 00:00:00 2001 From: ymesh Date: Tue, 29 Sep 2015 22:34:19 +0300 Subject: [PATCH 4/6] Fixed some controls and signals --- core/node.py | 17 +- core/signal.py | 3 +- gfx/gfxNote.py | 5 +- gfx/gfxSwatchNode.py | 31 +- gfx/imageView.py | 14 +- gui/MainWindow.py | 55 +- gui/exportShader/ExportShaderDialog.py | 80 ++- gui/imageViewWidget.py | 5 +- gui/meRendererSetup.py | 6 +- gui/nodeEditor/NodeEditorDialog.py | 120 +++- gui/nodeEditor/codeSyntaxHighlighter.py | 6 +- gui/nodeEditor/nodeCodeEditor.py | 7 +- gui/nodeEditor/nodeNamesEditor.py | 23 +- gui/nodeEditor/nodeParamEditor.py | 159 ++++- gui/nodeEditor/nodePropertiesEditor.py | 53 +- gui/nodeEditor/ui_nodeCodeEditor.py | 3 +- gui/nodeEditor/ui_nodeEditorDialog.py | 23 +- gui/nodeEditor/ui_nodeLinkEditor.py | 18 +- gui/nodeEditor/ui_nodeNamesEditor.py | 15 +- gui/params/FloatWidget.py | 11 +- gui/params/NormalWidget.py | 19 +- gui/params/PointWidget.py | 15 +- gui/params/VectorWidget.py | 13 +- gui/params/paramWidget.py | 11 +- gui/ui_meRendererSetup.py | 52 +- gui/ui_viewComputedCodeDialog.py | 2 +- lib/nodes/example_001.xml | 740 +++++++++++++++++++++++ lib/nodes/startup.xml | 225 +++++++ lib/nodes/{ => utilites}/imageViewer.xml | 0 29 files changed, 1509 insertions(+), 222 deletions(-) create mode 100644 lib/nodes/example_001.xml create mode 100644 lib/nodes/startup.xml rename lib/nodes/{ => utilites}/imageViewer.xml (100%) diff --git a/core/node.py b/core/node.py index 1bba87b..613b00b 100644 --- a/core/node.py +++ b/core/node.py @@ -5,6 +5,7 @@ """ import os, sys, copy from core.mePyQt import QtCore, QtXml +from core.signal import Signal #from PyQt4.QtCore import QDir, QFile, QVariant from global_vars import app_global_vars, DEBUG_MODE, VALID_RIB_NODE_TYPES @@ -15,13 +16,6 @@ # class Node ( QtCore.QObject ) : # - # Define signals for PyQt5 - # - if QtCore.QT_VERSION >= 50000 : - # - nodeUpdated = QtCore.pyqtSignal ( [QtCore.QObject] ) - nodeParamsUpdated = QtCore.pyqtSignal ( [QtCore.QObject] ) - # id = 0 # # __init__ @@ -29,7 +23,14 @@ class Node ( QtCore.QObject ) : def __init__ ( self, xml_node = None, nodenet = None ) : # QtCore.QObject.__init__ ( self ) - + # + # Define signals for PyQt5 + # + if QtCore.QT_VERSION >= 50000 : + # + self.nodeUpdated = Signal () # QtCore.pyqtSignal ( [QtCore.QObject] ) + self.nodeParamsUpdated = Signal () #QtCore.pyqtSignal ( [QtCore.QObject] ) + # self.id = None self.name = None self.label = None diff --git a/core/signal.py b/core/signal.py index 004e9e6..88953b2 100644 --- a/core/signal.py +++ b/core/signal.py @@ -22,5 +22,6 @@ def disconnect ( self, func ) : try: self.__subscribers.remove ( func ) except ValueError: - print ( 'Warning: function %s not removed from signal %s' ( func,self )) + #print ( 'Warning: function %s not removed from signal %s' ( func,self )) + print ( 'Warning: function not removed from signal' ) \ No newline at end of file diff --git a/gfx/gfxNote.py b/gfx/gfxNote.py index ed4849b..d606792 100644 --- a/gfx/gfxNote.py +++ b/gfx/gfxNote.py @@ -90,7 +90,10 @@ def type ( self ) : return GfxNote.Type def remove ( self ) : # if DEBUG_MODE : print '>> GfxNote remove gfxNode (temp)' - self.scene().emit ( QtCore.SIGNAL ( 'onGfxNodeRemoved' ), self ) + if QtCore.QT_VERSION < 50000 : + self.scene().emit ( QtCore.SIGNAL ( 'onGfxNodeRemoved' ), self ) + else : + self.scene().onGfxNodeRemoved.emit ( self ) # # updateNodeLabel # diff --git a/gfx/gfxSwatchNode.py b/gfx/gfxSwatchNode.py index 78e9eae..63fc6df 100644 --- a/gfx/gfxSwatchNode.py +++ b/gfx/gfxSwatchNode.py @@ -70,12 +70,12 @@ def __init__ ( self, node = None, swatchSize = UI.SWATCH_SIZE ) : self.setPos ( x, y ) # flag (new from QT 4.6...) - self.setFlag ( QtGui.QGraphicsItem.ItemSendsScenePositionChanges ) - self.setFlag ( QtGui.QGraphicsItem.ItemSendsGeometryChanges ) + self.setFlag ( QtModule.QGraphicsItem.ItemSendsScenePositionChanges ) + self.setFlag ( QtModule.QGraphicsItem.ItemSendsGeometryChanges ) # qt graphics stuff - self.setFlag ( QtGui.QGraphicsItem.ItemIsMovable ) - self.setFlag ( QtGui.QGraphicsItem.ItemIsSelectable ) + self.setFlag ( QtModule.QGraphicsItem.ItemIsMovable ) + self.setFlag ( QtModule.QGraphicsItem.ItemIsSelectable ) self.setZValue ( 1 ) #self.connectSignals () @@ -85,14 +85,20 @@ def __init__ ( self, node = None, swatchSize = UI.SWATCH_SIZE ) : def connectSignals ( self ) : # if self.scene () is not None : - QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'updateSwatch' ), self.updateSwatch ) + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'updateSwatch' ), self.updateSwatch ) + else : + self.scene ().updateSwatch.connect ( self.updateSwatch ) # # disconnectSignals # def disconnectSignals ( self ) : # if self.scene () is not None : - QtCore.QObject.disconnect ( self.scene (), QtCore.SIGNAL ( 'updateSwatch' ), self.updateSwatch ) + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.disconnect ( self.scene (), QtCore.SIGNAL ( 'updateSwatch' ), self.updateSwatch ) + else : + self.scene ().updateSwatch.disconnect ( self.updateSwatch ) # # type # @@ -104,7 +110,10 @@ def remove ( self ) : # if DEBUG_MODE : print '>> GfxSwatchNode.remove' for connect in self.inputConnectors : connect.removeAllLinks () - self.scene().emit ( QtCore.SIGNAL ( 'onGfxNodeRemoved' ), self ) + if QtCore.QT_VERSION < 50000 : + self.scene().emit ( QtCore.SIGNAL ( 'onGfxNodeRemoved' ), self ) + else : + self.scene().onGfxNodeRemoved.emit ( self ) # # getInputConnectorByParam # @@ -199,14 +208,14 @@ def adjustLinks ( self ) : # def itemChange ( self, change, value ) : # - if change == QtGui.QGraphicsItem.ItemSelectedHasChanged : #ItemSelectedChange: - if value.toBool () : + if change == QtModule.QGraphicsItem.ItemSelectedHasChanged : #ItemSelectedChange: + if value == 1 : items = self.scene ().items () for i in range ( len ( items ) - 1, -1, -1 ) : if items [ i ].parentItem() is None : if items [ i ] != self : items [ i ].stackBefore ( self ) - elif change == QtGui.QGraphicsItem.ItemPositionHasChanged : + elif change == QtModule.QGraphicsItem.ItemPositionHasChanged : from meShaderEd import getDefaultValue grid_snap = getDefaultValue ( app_settings, 'WorkArea', 'grid_snap' ) grid_size = int ( getDefaultValue ( app_settings, 'WorkArea', 'grid_size' ) ) @@ -218,7 +227,7 @@ def itemChange ( self, change, value ) : self.setPos ( x, y ) self.node.offset = ( x, y ) self.adjustLinks () - return QtGui.QGraphicsItem.itemChange ( self, change, value ) + return QtModule.QGraphicsItem.itemChange ( self, change, value ) # # paint # diff --git a/gfx/imageView.py b/gfx/imageView.py index 563150f..9d5f1cb 100644 --- a/gfx/imageView.py +++ b/gfx/imageView.py @@ -58,7 +58,7 @@ def __init__ ( self, parent ) : def keyPressEvent ( self, event ) : # print ">> ImageView.keyPressEvent" - QtGui.QGraphicsView.keyPressEvent ( self, event) + QtModule.QGraphicsView.keyPressEvent ( self, event) # # wheelEvent # @@ -70,8 +70,14 @@ def wheelEvent ( self, event ) : scale = -1.0 if 'linux' in sys.platform: scale = 1.0 import math - scaleFactor = math.pow( 2.0, scale * event.delta() / 600.0 ) - factor = self.matrix ().scale ( scaleFactor, scaleFactor ).mapRect ( QtCore.QRectF ( -1, -1, 2, 2 ) ).width () + if QtCore.QT_VERSION < 50000 : + scaleFactor = math.pow( 2.0, scale * event.delta() / 600.0 ) + else : + delta = event.angleDelta () + #print ( '>> delta rx = %d ry = %d' % ( delta.x (), delta.y () ) ) + scaleFactor = math.pow( 2.0, scale * delta.y () / 600.0 ) + # self.matrix () is depicated + factor = self.transform ().scale ( scaleFactor, scaleFactor ).mapRect ( QtCore.QRectF ( -1, -1, 2, 2 ) ).width () if factor < 0.07 or factor > 100: return self.scale ( scaleFactor, scaleFactor ) # @@ -94,7 +100,7 @@ def mouseDoubleClickEvent ( self, event ) : # #print ">> ImageView.mouseDoubleClickEvent" if QtCore.QT_VERSION < 50000 : - self.emit ( QtCore.SIGNAL ( 'mouseDoubleClickEvent' ) ) + self.emit ( QtCore.SIGNAL ( 'mouseDoubleClickSignal' ) ) else : self.mouseDoubleClickSignal.emit () QtModule.QGraphicsView.mouseDoubleClickEvent ( self, event ) diff --git a/gui/MainWindow.py b/gui/MainWindow.py index 02ea616..fd70f4f 100644 --- a/gui/MainWindow.py +++ b/gui/MainWindow.py @@ -154,8 +154,7 @@ def connectWorkAreaSignals ( self ) : #self.workArea.editGfxNode.connect ( self.editGfxNode ) self.workArea.scene().nodeUpdated.connect ( self.updateNodeParamView ) self.workArea.scene().gfxNodeParamChanged.connect ( self.onGfxNodeParamChanged ) - - # + # # disconnectWorkAreaSignals # def disconnectWorkAreaSignals ( self ) : @@ -171,6 +170,17 @@ def disconnectWorkAreaSignals ( self ) : #QtCore.QObject.disconnect ( self.workArea, QtCore.SIGNAL ( 'editGfxNode' ), self.editGfxNode ) QtCore.QObject.disconnect ( self.workArea.scene(), QtCore.SIGNAL ( 'nodeUpdated' ), self.updateNodeParamView ) QtCore.QObject.disconnect ( self.workArea.scene(), QtCore.SIGNAL ( 'gfxNodeParamChanged' ), self.onGfxNodeParamChanged ) + else : + if self.workArea != None : + if self.activeNodeList != None : + self.activeNodeList.addNode.disconnect( self.workArea.insertNodeNet ) + self.workArea.selectNodes.disconnect ( self.onSelectGfxNodes ) + self.workArea.nodeConnectionChanged.disconnect ( self.onGfxNodeParamChanged ) + self.workArea.gfxNodeAdded.disconnect ( self.onAddGfxNode ) + self.workArea.gfxNodeRemoved.disconnect ( self.onRemoveGfxNode ) + #self.workArea.editGfxNode.disconnect ( self.editGfxNode ) + self.workArea.scene().nodeUpdated.disconnect ( self.updateNodeParamView ) + self.workArea.scene().gfxNodeParamChanged.disconnect ( self.onGfxNodeParamChanged ) # # setupWindowTitle # @@ -365,8 +375,12 @@ def onRenderSettings ( self ) : self.RendererPreset = copy.deepcopy ( app_global_vars [ 'RendererPreset' ] ) if DEBUG_MODE : print ( ':: self.RendererPreset.getCurrentPresetName = %s' % self.RendererPreset.getCurrentPresetName () ) renderSettingsDlg = meRendererSetup ( self.RendererPreset ) - QtCore.QObject.connect ( renderSettingsDlg, QtCore.SIGNAL ( 'presetChanged' ), self.onRenderPresetChanged ) - QtCore.QObject.connect ( renderSettingsDlg, QtCore.SIGNAL ( 'savePreset' ), self.onRenderPresetSave ) + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.connect ( renderSettingsDlg, QtCore.SIGNAL ( 'presetChanged' ), self.onRenderPresetChanged ) + QtCore.QObject.connect ( renderSettingsDlg, QtCore.SIGNAL ( 'savePreset' ), self.onRenderPresetSave ) + else : + renderSettingsDlg.presetChanged.connect ( self.onRenderPresetChanged ) + renderSettingsDlg.savePreset.connect ( self.onRenderPresetSave ) renderSettingsDlg.exec_ () # # onRenderPresetChanged @@ -468,7 +482,7 @@ def onGetNode ( self, itemFilename, pos ) : # def onAddGfxNode ( self, gfxNode ) : # - #print ">> MainWindow: onAddGfxNode = %s" % gfxNode.node.label + print ">> MainWindow: onAddGfxNode = %s" % gfxNode.node.label if gfxNode.node.type == 'image' : self.ui.imageView_ctl.addViewer ( gfxNode ) @@ -562,7 +576,7 @@ def onEditNode ( self ) : nodeEditDlg = NodeEditorDialog ( editNode ) - if nodeEditDlg.exec_ () == QtGui.QDialog.Accepted : + if nodeEditDlg.exec_ () == QtModule.QDialog.Accepted : # if DEBUG_MODE : print '>> MainWindow.nodeEditDlg Accepted' # @@ -701,7 +715,8 @@ def onGfxNodeParamChanged ( self, gfxNode, param = None ) : self.updateNodeParamView () self.workArea.scene ().update () - if self.ui.imageView_ctl.autoUpdate () : self.ui.imageView_ctl.updateViewer() + if self.ui.imageView_ctl.autoUpdate () : + self.ui.imageView_ctl.updateViewer() # # updateNodeParamView # @@ -741,8 +756,10 @@ def onTabSelected ( self, idx ) : self.workArea = self.ui.tabs.currentWidget () imageNodes = self.workArea.getGfxNodesByType ( 'image' ) + # setup imageView menu for image nodes in new tab - for gfxNode in imageNodes : self.ui.imageView_ctl.addViewer ( gfxNode ) + for gfxNode in imageNodes : + self.ui.imageView_ctl.addViewer ( gfxNode ) self.connectWorkAreaSignals () self.ui.nodeParam_ctl.setNode ( self.workArea.inspectedNode ) @@ -810,8 +827,10 @@ def onOpen ( self ) : # curDir = app_global_vars [ 'ProjectNetworks' ] typeFilter = 'Shader networks *.xml;;All files *.*;;' - - filename = str ( QtGui.QFileDialog.getOpenFileName ( self, "Open file", curDir, typeFilter ) ) + if QtCore.QT_VERSION < 50000 : + filename = str ( QtGui.QFileDialog.getOpenFileName ( self, "Open file", curDir, typeFilter ) ) + else : + (filename, filter) = QtModule.QFileDialog.getOpenFileName ( self, "Open file", curDir, typeFilter ) if filename != '' : if self.openNetwork ( filename ) : self.addRecentNetwork ( normPath ( filename ) ) @@ -887,7 +906,10 @@ def onImport ( self ) : curDir = app_global_vars [ 'ProjectNetworks' ] typeFilter = 'Shader networks *.xml;;All files *.*;;' - filename = str ( QtModule.QFileDialog.getOpenFileName ( self, "Import file", curDir, typeFilter ) ) + if QtCore.QT_VERSION < 50000 : + filename = str ( QtModule.QFileDialog.getOpenFileName ( self, "Import file", curDir, typeFilter ) ) + else : + (filename, filter) = QtModule.QFileDialog.getOpenFileName ( self, "Import file", curDir, typeFilter ) if filename != '' : if DEBUG_MODE : print "-> import file %s" % filename self.workArea.insertNodeNet ( normPath ( filename ) ) @@ -903,7 +925,10 @@ def onSaveSelected ( self ) : saveName = os.path.join ( curDir, self.workArea.nodeNet.name + '.xml' ) typeFilter = 'Shader networks *.xml;;All files *.*;;' - filename = str( QtModule.QFileDialog.getSaveFileName ( self, "Save file as", saveName, typeFilter ) ) + if QtCore.QT_VERSION < 50000 : + filename = str( QtModule.QFileDialog.getSaveFileName ( self, "Save file as", saveName, typeFilter ) ) + else : + (filename, filter) = QtModule.QFileDialog.getSaveFileName ( self, "Save file as", saveName, typeFilter ) if filename != '' : if DEBUG_MODE : print '-> save file As %s' % filename ( name, ext ) = os.path.splitext ( os.path.basename ( filename ) ) @@ -946,8 +971,10 @@ def onSaveAs ( self ) : curDir = app_global_vars [ 'ProjectNetworks' ] saveName = os.path.join ( curDir, self.workArea.nodeNet.name + '.xml' ) typeFilter = 'Shader networks *.xml;;All files *.*;;' - - filename = str( QtModule.QFileDialog.getSaveFileName ( self, "Save file as", saveName, typeFilter ) ) + if QtCore.QT_VERSION < 50000 : + filename = str( QtModule.QFileDialog.getSaveFileName ( self, "Save file as", saveName, typeFilter ) ) + else : + (filename, filter) = QtModule.QFileDialog.getSaveFileName ( self, "Save file as", saveName, typeFilter ) if filename != '' : if DEBUG_MODE : print '-> save file As %s' % filename ( name, ext ) = os.path.splitext ( os.path.basename ( filename ) ) diff --git a/gui/exportShader/ExportShaderDialog.py b/gui/exportShader/ExportShaderDialog.py index 0bdada1..a58777e 100644 --- a/gui/exportShader/ExportShaderDialog.py +++ b/gui/exportShader/ExportShaderDialog.py @@ -69,9 +69,9 @@ def connectSignals ( self ) : QtCore.QObject.connect ( self.ui.param, QtCore.SIGNAL ( 'changeParamProvider' ), self.onParamChange ) QtCore.QObject.connect ( self.ui.param, QtCore.SIGNAL ( 'changeParamValue' ), self.onParamChange ) else : - self.ui.list_nodes.temSelectionChanged.connect ( self.onNodeChanged ) - self.ui.list_inputs,temSelectionChanged.connect ( self.onInputParamChanged ) - self.ui.list_outputs.temSelectionChanged.connect ( self.onOutputParamChanged ) + self.ui.list_nodes.itemSelectionChanged.connect ( self.onNodeChanged ) + self.ui.list_inputs.itemSelectionChanged.connect ( self.onInputParamChanged ) + self.ui.list_outputs.itemSelectionChanged.connect ( self.onOutputParamChanged ) self.ui.node.changeNodeLabel.connect ( self.onRenameNodeLabel ) self.ui.param.changeParamLabel.connect ( self.onParamChange ) @@ -96,9 +96,9 @@ def disconnectSignals ( self ) : QtCore.QObject.disconnect ( self.ui.param, QtCore.SIGNAL ( 'changeParamProvider' ), self.onParamChange ) QtCore.QObject.disconnect ( self.ui.param, QtCore.SIGNAL ( 'changeParamValue' ), self.onParamChange ) else : - self.ui.list_nodes.temSelectionChanged.disconnect ( self.onNodeChanged ) - self.ui.list_inputs,temSelectionChanged.disconnect ( self.onInputParamChanged ) - self.ui.list_outputs.temSelectionChanged.disconnect ( self.onOutputParamChanged ) + self.ui.list_nodes.itemSelectionChanged.disconnect ( self.onNodeChanged ) + self.ui.list_inputs.itemSelectionChanged.disconnect ( self.onInputParamChanged ) + self.ui.list_outputs.itemSelectionChanged.disconnect ( self.onOutputParamChanged ) self.ui.node.changeNodeLabel.disconnect ( self.onRenameNodeLabel ) self.ui.param.changeParamLabel.disconnect ( self.onParamChange ) @@ -122,7 +122,7 @@ def buildGui ( self ) : self.ui.list_nodes.addItem ( separator ) item = QtModule.QListWidgetItem ( self.editNode.label ) - node_var = QVariant ( self.editNode ) + node_var = QtCore.QVariant ( self.editNode ) item.setData ( QtCore.Qt.UserRole + 1, node_var ) self.ui.list_nodes.addItem ( item ) @@ -137,7 +137,7 @@ def buildGui ( self ) : for node in self.editNode.visitedNodes : #childrenList : print '* (%s)' % node.label item = QtModule.QListWidgetItem ( node.label ) - item.setData ( QtCore.Qt.UserRole + 1, QVariant ( node ) ) + item.setData ( QtCore.Qt.UserRole + 1, QtCore.QVariant ( node ) ) self.ui.list_nodes.addItem ( item ) # # updateComputedParams @@ -150,14 +150,14 @@ def updateComputedParams ( self ) : # setup input params list for ( param, node ) in self.editNode.computedInputParamsList : item = QtModule.QListWidgetItem ( ( node.getParamDeclaration ( param )).rstrip ( ';\n' ) ) - item.setData ( QtCore.Qt.UserRole + 1, QVariant ( param ) ) - item.setData ( QtCore.Qt.UserRole + 2, QVariant ( node ) ) + item.setData ( QtCore.Qt.UserRole + 1, QtCore.QVariant ( param ) ) + item.setData ( QtCore.Qt.UserRole + 2, QtCore.QVariant ( node ) ) self.ui.list_inputs.addItem ( item ) # setup output params list for ( param, node ) in self.editNode.computedOutputParamsList : item = QtModule.QListWidgetItem ( ( 'output ' + node.getParamDeclaration ( param ) ).rstrip ( ';\n' ) ) - item.setData ( QtCore.Qt.UserRole + 1, QVariant ( param ) ) - item.setData ( QtCore.Qt.UserRole + 2, QVariant ( node ) ) + item.setData ( QtCore.Qt.UserRole + 1, QtCore.QVariant ( param ) ) + item.setData ( QtCore.Qt.UserRole + 2, QtCore.QVariant ( node ) ) self.ui.list_outputs.addItem ( item ) # # updateNodeParams @@ -174,8 +174,8 @@ def updateNodeParams ( self, node ) : # setup input params list for param in node.inputParams : item = QtModule.QListWidgetItem ( param.label ) - item.setData ( QtCore.Qt.UserRole + 1, QVariant ( param ) ) - item.setData ( QtCore.Qt.UserRole + 2, QVariant ( node ) ) + item.setData ( QtCore.Qt.UserRole + 1, QtCore.QVariant ( param ) ) + item.setData ( QtCore.Qt.UserRole + 2, QtCore.QVariant ( node ) ) if node.isInputParamLinked ( param ) : item.setFont ( linkedFont ) item.setForeground ( linkedBrush ) @@ -183,8 +183,8 @@ def updateNodeParams ( self, node ) : # setup output params list for param in node.outputParams : item = QtModule.QListWidgetItem ( param.label ) - item.setData ( QtCore.Qt.UserRole + 1, QVariant ( param ) ) - item.setData ( QtCore.Qt.UserRole + 2, QVariant ( node ) ) + item.setData ( QtCore.Qt.UserRole + 1, QtCore.QVariant ( param ) ) + item.setData ( QtCore.Qt.UserRole + 2, QtCore.QVariant ( node ) ) if node.isOutputParamLinked ( param ) : item.setFont ( linkedFont ) item.setForeground ( linkedBrush ) @@ -196,8 +196,11 @@ def onNodeChanged ( self ) : # if DEBUG_MODE : print '>> ExportShaderDialog.onNodeChanged' self.disconnectSignals () - item = self.ui.list_nodes.currentItem () - node = item.data ( QtCore.Qt.UserRole + 1 ).toPyObject () + item = self.ui.list_nodes.currentItem () + if QtCore.QT_VERSION < 50000 : + node = item.data ( QtCore.Qt.UserRole + 1 ).toPyObject () + else : + node = item.data ( QtCore.Qt.UserRole + 1 ) print '* (%s) selected' % node.label self.ui.node.setNode ( node ) self.ui.prop_tabWidget.setCurrentIndex ( 0 ) @@ -214,8 +217,8 @@ def onNodeChanged ( self ) : # setup input params list for param in node.inputParams : item = QtModule.QListWidgetItem ( param.label ) - item.setData ( QtCore.Qt.UserRole + 1, QVariant ( param ) ) - item.setData ( QtCore.Qt.UserRole + 2, QVariant ( node ) ) + item.setData ( QtCore.Qt.UserRole + 1, QtCore.QVariant ( param ) ) + item.setData ( QtCore.Qt.UserRole + 2, QtCore.QVariant ( node ) ) if node.isInputParamLinked ( param ) : item.setFont ( linkedFont ) item.setForeground ( linkedBrush ) @@ -224,8 +227,8 @@ def onNodeChanged ( self ) : # setup output params list for param in node.outputParams : item = QtModule.QListWidgetItem ( param.label ) - item.setData ( QtCore.Qt.UserRole + 1, QVariant ( param ) ) - item.setData ( QtCore.Qt.UserRole + 2, QVariant ( node ) ) + item.setData ( QtCore.Qt.UserRole + 1, QtCore.QVariant ( param ) ) + item.setData ( QtCore.Qt.UserRole + 2, QtCore.QVariant ( node ) ) if node.isOutputParamLinked ( param ) : item.setFont ( linkedFont ) item.setForeground ( linkedBrush ) @@ -240,9 +243,13 @@ def onNodeChanged ( self ) : def onInputParamChanged ( self ) : # if DEBUG_MODE : print '>> ExportShaderDialog.onInputParamChanged' - item = self.ui.list_inputs.currentItem () - param = item.data ( QtCore.Qt.UserRole + 1 ).toPyObject () - node = item.data ( QtCore.Qt.UserRole + 2 ).toPyObject () + item = self.ui.list_inputs.currentItem () + if QtCore.QT_VERSION < 50000 : + param = item.data ( QtCore.Qt.UserRole + 1 ).toPyObject () + node = item.data ( QtCore.Qt.UserRole + 2 ).toPyObject () + else : + param = item.data ( QtCore.Qt.UserRole + 1 ) + node = item.data ( QtCore.Qt.UserRole + 2 ) #print '* (%s) selected' % param.label self.ui.param.setParam ( param ) self.ui.node.setNode ( node ) @@ -253,9 +260,13 @@ def onInputParamChanged ( self ) : def onOutputParamChanged ( self ) : # if DEBUG_MODE : print '>> ExportShaderDialog.onOutputParamChanged' - item = self.ui.list_outputs.currentItem () - param = item.data ( QtCore.Qt.UserRole + 1 ).toPyObject () - node = item.data ( QtCore.Qt.UserRole + 2 ).toPyObject () + item = self.ui.list_outputs.currentItem () + if QtCore.QT_VERSION < 50000 : + param = item.data ( QtCore.Qt.UserRole + 1 ).toPyObject () + node = item.data ( QtCore.Qt.UserRole + 2 ).toPyObject () + else : + param = item.data ( QtCore.Qt.UserRole + 1 ) + node = item.data ( QtCore.Qt.UserRole + 2 ) #print '* (%s) selected' % self.param.label self.ui.param.setParam ( param ) self.ui.node.setNode ( node ) @@ -277,7 +288,10 @@ def onRenameNodeLabel ( self, oldName, newName ) : editNode = self.ui.node.editNode for i in range ( self.ui.list_nodes.count () ) : item = self.ui.list_nodes.item ( i ) - node = item.data ( QtCore.Qt.UserRole + 1 ).toPyObject () + if QtCore.QT_VERSION < 50000 : + node = item.data ( QtCore.Qt.UserRole + 1 ).toPyObject () + else : + node = item.data ( QtCore.Qt.UserRole + 1 ) if node is not None and node == editNode : item.setText ( editNode.label ) @@ -299,7 +313,6 @@ def onParamChange ( self ) : # onViewCode # def onViewCode ( self ) : ViewComputedCodeDialog ( self.editNode ).exec_ () - # # onExport # @@ -308,13 +321,14 @@ def onExport ( self ) : import os saveName = os.path.join ( app_global_vars [ 'ProjectSources' ], self.editNode.getInstanceName () + '.sl' ) typeFilter = 'Shader source files *.sl;;All files *.*;;' - - filename = str( QtModule.QFileDialog.getSaveFileName ( self, "Export shader code as", saveName, typeFilter ) ) + if QtCore.QT_VERSION < 50000 : + filename = str( QtModule.QFileDialog.getSaveFileName ( self, "Export shader code as", saveName, typeFilter ) ) + else : + ( filename, filter ) = QtModule.QFileDialog.getSaveFileName ( self, "Export shader code as", saveName, typeFilter ) if filename != '' : if DEBUG_MODE : print '-> Export shader code as %s' % filename shaderCode = self.editNode.getComputedCode () self.editNode.writeShader ( shaderCode, filename ) - # # Ignore default Enter press event # diff --git a/gui/imageViewWidget.py b/gui/imageViewWidget.py index 8cd04e0..5e3db95 100644 --- a/gui/imageViewWidget.py +++ b/gui/imageViewWidget.py @@ -101,9 +101,10 @@ def onViewerChanged ( self, idx ) : # # updateViewer # + @QtCore.pyqtSlot () def updateViewer ( self, compute = True ) : # - print ">> ImageViewWidget.updateViewer" + print ">> ImageViewWidget.updateViewer compute = %d" % compute RenderViewMode = False idx = self.ui.selector.currentIndex () if len ( self.imageNodes ) > 0 : @@ -121,8 +122,10 @@ def updateViewer ( self, compute = True ) : RenderViewMode = True if compute : + print '* compute ' imageName = gfxNode.node.computeNode () else : + print '* use image ' imageName = gfxNode.node.imageName print ">> ImageViewWidget: imageName = %s" % imageName diff --git a/gui/meRendererSetup.py b/gui/meRendererSetup.py index db68d53..1487c51 100644 --- a/gui/meRendererSetup.py +++ b/gui/meRendererSetup.py @@ -13,6 +13,8 @@ """ from core.mePyQt import QtCore, QtGui, QtXml +from global_vars import app_global_vars, DEBUG_MODE + from ui_meRendererSetup import Ui_meRendererSetup if QtCore.QT_VERSION < 50000 : @@ -110,7 +112,9 @@ def getDataFromGui ( self ) : # onIndexChanged # def onIndexChanged ( self, name ) : - #print ">> onIndexChanged:: self.labelsReady == %d" % self.labelsReady + if DEBUG_MODE : print ">> onIndexChanged:: nam = %s self.labelsReady == %d" % ( name, self.labelsReady ) + #if DEBUG_MODE : print self.ui.listPreset.currentText () + name = self.ui.listPreset.currentText () if ( self.labelsReady and name != '' ) : # change current renderer self.rendererPreset.setCurrentPresetByName ( str ( name ) ) diff --git a/gui/nodeEditor/NodeEditorDialog.py b/gui/nodeEditor/NodeEditorDialog.py index 411689b..ffbd318 100644 --- a/gui/nodeEditor/NodeEditorDialog.py +++ b/gui/nodeEditor/NodeEditorDialog.py @@ -54,9 +54,7 @@ def __init__ ( self, node = None ): QtModule.QDialog.__init__ ( self ) self.editNode = node - # self.removedLinks = [] - self.nodePropertiesEditor = None self.nodeParamEditor = None self.nodeLinkEditor = None @@ -79,13 +77,15 @@ def __init__ ( self, node = None ): def connectSignals ( self ) : # if QtCore.QT_VERSION < 50000 : - QtCore.QObject.connect ( self.ui.input_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) # onInputParamSelectionChanged ) - QtCore.QObject.connect ( self.ui.output_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) # onOutputParamSelectionChanged ) + QtCore.QObject.connect ( self.ui.input_list, QtCore.SIGNAL ( 'selectionChangedSignal' ), self.updateGui ) # onInputParamSelectionChanged ) + QtCore.QObject.connect ( self.ui.output_list, QtCore.SIGNAL ( 'selectionChangedSignal' ), self.updateGui ) # onOutputParamSelectionChanged ) QtCore.QObject.connect ( self.ui.input_list, QtCore.SIGNAL ( 'addItem' ), self.onAddParam ) QtCore.QObject.connect ( self.ui.output_list, QtCore.SIGNAL ( 'addItem' ), self.onAddParam ) + QtCore.QObject.connect ( self.ui.input_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameParam ) QtCore.QObject.connect ( self.ui.output_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameParam ) + QtCore.QObject.connect ( self.ui.input_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveParam ) QtCore.QObject.connect ( self.ui.output_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveParam ) @@ -116,7 +116,48 @@ def connectSignals ( self ) : QtCore.QObject.connect ( self.ui.internals_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveInternal ) QtCore.QObject.connect ( self.ui.includes_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveInclude ) - QtCore.QObject.connect ( self.ui.handlers_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) + QtCore.QObject.connect ( self.ui.handlers_list, QtCore.SIGNAL ( 'selectionChangedSignal' ), self.updateGui ) + else : + self.ui.input_list.selectionChangedSignal.connect ( self.updateGui ) # onInputParamSelectionChanged ) + self.ui.output_list.selectionChangedSignal.connect ( self.updateGui ) # onOutputParamSelectionChanged ) + + self.ui.input_list.addItem.connect ( self.onAddParam ) + self.ui.output_list.addItem.connect ( self.onAddParam ) + + self.ui.input_list.renameItem.connect ( self.onRenameParam ) + self.ui.output_list.renameItem.connect ( self.onRenameParam ) + + self.ui.input_list.removeItem.connect ( self.onRemoveParam ) + self.ui.output_list.removeItem.connect ( self.onRemoveParam ) + + self.ui.tabs_param_list.currentChanged.connect ( self.updateGui ) + + if self.nodeParamEditor is not None : + self.nodeParamEditor.changeParamName.connect ( self.onRenameParam ) + self.nodeParamEditor.changeParamName.connect ( self.onRenameParamLabel ) + + if self.nodeCodeEditor is not None : + self.nodeCodeEditor.ui.textEdit.textChanged.connect ( self.onEditCode ) + + if self.controlCodeEditor is not None : + self.controlCodeEditor.ui.textEdit.textChanged.connect ( self.onEditControlCode ) + + if self.paramCodeEditor is not None : + self.paramCodeEditor.ui.textEdit.textChanged.connect ( self.onEditParamCode ) + + if self.eventCodeEditor is not None : + self.eventCodeEditor.ui.textEdit.textChanged.connect ( self.onEditEventCode ) + + self.ui.internals_list.addItem.connect ( self.onAddInternal ) + self.ui.includes_list.addItem.connect ( self.onAddInclude ) + + self.ui.internals_list.renameItem.connect ( self.onRenameInternal ) + self.ui.includes_list.renameItem.connect ( self.onRenameInclude ) + + self.ui.internals_list.removeItem.connect ( self.onRemoveInternal ) + self.ui.includes_list.removeItem.connect ( self.onRemoveInclude ) + + self.ui.handlers_list.selectionChangedSignal.connect ( self.updateGui ) # # disconnectSignals @@ -124,13 +165,15 @@ def connectSignals ( self ) : def disconnectSignals ( self ) : # if QtCore.QT_VERSION < 50000 : - QtCore.QObject.disconnect ( self.ui.input_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) # onInputParamSelectionChanged ) - QtCore.QObject.disconnect ( self.ui.output_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) # onOutputParamSelectionChanged ) + QtCore.QObject.disconnect ( self.ui.input_list, QtCore.SIGNAL ( 'selectionChangedSignal' ), self.updateGui ) # onInputParamSelectionChanged ) + QtCore.QObject.disconnect ( self.ui.output_list, QtCore.SIGNAL ( 'selectionChangedSignal' ), self.updateGui ) # onOutputParamSelectionChanged ) QtCore.QObject.disconnect ( self.ui.input_list, QtCore.SIGNAL ( 'addItem' ), self.onAddParam ) QtCore.QObject.disconnect ( self.ui.output_list, QtCore.SIGNAL ( 'addItem' ), self.onAddParam ) + QtCore.QObject.disconnect ( self.ui.input_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameParam ) QtCore.QObject.disconnect ( self.ui.output_list, QtCore.SIGNAL ( 'renameItem' ), self.onRenameParam ) + QtCore.QObject.disconnect ( self.ui.input_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveParam ) QtCore.QObject.disconnect ( self.ui.output_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveParam ) @@ -161,8 +204,48 @@ def disconnectSignals ( self ) : QtCore.QObject.disconnect ( self.ui.internals_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveInternal ) QtCore.QObject.disconnect ( self.ui.includes_list, QtCore.SIGNAL ( 'removeItem' ), self.onRemoveInclude ) - QtCore.QObject.disconnect ( self.ui.handlers_list, QtCore.SIGNAL ( 'selectionChanged' ), self.updateGui ) - + QtCore.QObject.disconnect ( self.ui.handlers_list, QtCore.SIGNAL ( 'selectionChangedSignal' ), self.updateGui ) + else : + self.ui.input_list.selectionChangedSignal.disconnect ( self.updateGui ) # onInputParamSelectionChanged ) + self.ui.output_list.selectionChangedSignal.disconnect ( self.updateGui ) # onOutputParamSelectionChanged ) + + self.ui.input_list.addItem.disconnect ( self.onAddParam ) + self.ui.output_list.addItem.disconnect ( self.onAddParam ) + + self.ui.input_list.renameItem.disconnect ( self.onRenameParam ) + self.ui.output_list.renameItem.disconnect ( self.onRenameParam ) + + self.ui.input_list.removeItem.disconnect ( self.onRemoveParam ) + self.ui.output_list.removeItem.disconnect ( self.onRemoveParam ) + + self.ui.tabs_param_list.currentChanged.disconnect ( self.updateGui ) + + if self.nodeParamEditor is not None : + self.nodeParamEditor.changeParamName.disconnect ( self.onRenameParam ) + self.nodeParamEditor.changeParamName.disconnect ( self.onRenameParamLabel ) + + if self.nodeCodeEditor is not None : + self.nodeCodeEditor.ui.textEdit.textChanged.disconnect ( self.onEditCode ) + + if self.controlCodeEditor is not None : + self.controlCodeEditor.ui.textEdit.textChanged.disconnect ( self.onEditControlCode ) + + if self.paramCodeEditor is not None : + self.paramCodeEditor.ui.textEdit.textChanged.disconnect ( self.onEditParamCode ) + + if self.eventCodeEditor is not None : + self.eventCodeEditor.ui.textEdit.textChanged.disconnect ( self.onEditEventCode ) + + self.ui.internals_list.addItem.disconnect ( self.onAddInternal ) + self.ui.includes_list.addItem.disconnect ( self.onAddInclude ) + + self.ui.internals_list.renameItem.disconnect ( self.onRenameInternal ) + self.ui.includes_list.renameItem.disconnect ( self.onRenameInclude ) + + self.ui.internals_list.removeItem.disconnect ( self.onRemoveInternal ) + self.ui.includes_list.removeItem.disconnect ( self.onRemoveInclude ) + + self.ui.handlers_list.selectionChangedSignal.disconnect ( self.updateGui ) # # setEditNode # @@ -216,13 +299,13 @@ def buildGui ( self ) : # setup input links list for link in self.editNode.getInputLinks () : item = QtModule.QListWidgetItem ( 'id=%d' % link.id ) - item.setData ( QtCore.Qt.UserRole, QVariant ( int ( link.id ) ) ) + item.setData ( QtCore.Qt.UserRole, QtCore.QVariant ( int ( link.id ) ) ) self.ui.input_links_listWidget.addItem ( item ) # setup output links list for link in self.editNode.getOutputLinks () : item = QtModule.QListWidgetItem ( 'id=%d' % link.id ) - item.setData ( QtCore.Qt.UserRole, QVariant ( int ( link.id ) ) ) + item.setData ( QtCore.Qt.UserRole, QtCore.QVariant ( int ( link.id ) ) ) self.ui.output_links_listWidget.addItem ( item ) # setup event handlers list @@ -254,11 +337,10 @@ def buildGui ( self ) : self.ui.tabWidget.setCurrentIndex ( TAB_NODE_CODE ) self.ui.toolBox.setCurrentIndex ( IDX_INTERNALS ) self.ui.tabs_param_list.setCurrentIndex ( 0 ) # input param tab - # # updateGui # - def updateGui ( self ) : + def updateGui ( self, foo_param = None ) : # if self.editNode is not None : if DEBUG_MODE : print '>> NodeEditorDialog::updateGui' @@ -313,12 +395,20 @@ def updateGui ( self ) : # input links inputLinkSelected = True links_item = self.ui.input_links_listWidget.currentItem () - if links_item is not None : ( link_id, ok ) = links_item.data ( QtCore.Qt.UserRole ).toInt () + if links_item is not None : + if QtCore.QT_VERSION < 50000 : + ( link_id, ok ) = links_item.data ( QtCore.Qt.UserRole ).toInt () + else : + link_id = links_item.data ( QtCore.Qt.UserRole ) else : # output links links_item = self.ui.output_links_listWidget.currentItem () - if links_item is not None : ( link_id, ok ) = links_item.data ( QtCore.Qt.UserRole ).toInt () + if links_item is not None : + if QtCore.QT_VERSION < 50000 : + ( link_id, ok ) = links_item.data ( QtCore.Qt.UserRole ).toInt () + else: + link_id = links_item.data ( QtCore.Qt.UserRole ) if link_id is not None : link = None diff --git a/gui/nodeEditor/codeSyntaxHighlighter.py b/gui/nodeEditor/codeSyntaxHighlighter.py index 65df812..97ea008 100644 --- a/gui/nodeEditor/codeSyntaxHighlighter.py +++ b/gui/nodeEditor/codeSyntaxHighlighter.py @@ -90,7 +90,6 @@ def __init__ ( self, textDocument, mode = 'SL' ): self.globalsFormat.setForeground ( syntax_colors [ 'globals' ] ) globalsRule = ( QtCore.QRegExp ( '\$\{[A-Za-z0-9_]+\}' ), self.globalsFormat ) self.highlightingRules.append ( globalsRule ) - # # highlightBlock # @@ -117,7 +116,10 @@ def highlightBlock ( self, text ): commentLength = 0 if endIndex == -1: self.setCurrentBlockState ( 1 ) - commentLength = text.length () - startIndex + if QtCore.QT_VERSION < 50000 : + commentLength = text.length () - startIndex + else : + commentLength = len ( text ) - startIndex else: commentLength = endIndex - startIndex + self.commentEndExpression.matchedLength () diff --git a/gui/nodeEditor/nodeCodeEditor.py b/gui/nodeEditor/nodeCodeEditor.py index 46582d9..f154372 100644 --- a/gui/nodeEditor/nodeCodeEditor.py +++ b/gui/nodeEditor/nodeCodeEditor.py @@ -68,12 +68,9 @@ def setNodeCode ( self, editNodeCode, mode = 'SL', readOnly = False ) : self.ui.textEdit.setDocument ( doc ) self.ui.textEdit.setTabStopWidth ( UI.TAB_SIZE ) self.ui.textEdit.setFont ( font ) - self.ui.textEdit.setLineWrapMode ( QtGui.QTextEdit.NoWrap ) + self.ui.textEdit.setLineWrapMode ( QtModule.QTextEdit.NoWrap ) self.ui.textEdit.setReadOnly ( readOnly ) else : code = '' self.ui.textEdit.setPlainText ( code ) - - - - + diff --git a/gui/nodeEditor/nodeNamesEditor.py b/gui/nodeEditor/nodeNamesEditor.py index b2827e9..e945208 100644 --- a/gui/nodeEditor/nodeNamesEditor.py +++ b/gui/nodeEditor/nodeNamesEditor.py @@ -27,20 +27,21 @@ # class NodeNamesEditor ( QtModule.QWidget ) : # - # Define signals for PyQt5 - # - if QtCore.QT_VERSION >= 50000 : - # - selectionChanged = Signal () - addItem = Signal () - removeItem = Signal () - renameItem = Signal () - # # __init__ # def __init__ ( self, parent ) : # QtModule.QWidget.__init__ ( self, parent ) + # + # Define signals for PyQt5 + # + if QtCore.QT_VERSION >= 50000 : + # + self.selectionChangedSignal = Signal () + self.addItem = Signal () + self.removeItem = Signal () + self.renameItem = Signal () + # self.saved_text = '' self.approvedNewName = '' self.buildGui () @@ -127,7 +128,7 @@ def onSelectionChanged ( self ) : self.saved_text = str ( list_item.text() ) self.ui.name_lineEdit.setText ( self.saved_text ) if QtCore.QT_VERSION < 50000 : - self.emit ( QtCore.SIGNAL ( 'selectionChanged' ), self.saved_text ) + self.emit ( QtCore.SIGNAL ( 'selectionChangedSignal' ), self.saved_text ) else : - self.selectionChanged.emit ( self.saved_text ) + self.selectionChangedSignal.emit ( self.saved_text ) \ No newline at end of file diff --git a/gui/nodeEditor/nodeParamEditor.py b/gui/nodeEditor/nodeParamEditor.py index 90c3b2e..269c46f 100644 --- a/gui/nodeEditor/nodeParamEditor.py +++ b/gui/nodeEditor/nodeParamEditor.py @@ -44,9 +44,26 @@ class NodeParamEditor ( QtModule.QWidget ) : def __init__ ( self, parent ) : # QtModule.QWidget.__init__ ( self, parent ) + # + # Define signals for PyQt5 + # + if QtCore.QT_VERSION >= 50000 : + # + self.changeParamName = Signal () + self.changeParamLabel = Signal () + self.changeParamIsShader = Signal () + self.changeParamType = Signal () + self.changeParamDetail = Signal () + self.changeParamProvider = Signal () + self.changeParamSubtype = Signal () + self.changeParamRange = Signal () + + self.changeParamValue = Signal () + self.changeParamDefValue = Signal () + # self.param = None self.param_default = None - self.paramWidgets = { 'string' : StringWidget + self.paramWidgets = { 'string' : StringWidget ,'image' : StringWidget ,'rib' : StringWidget ,'surface' : StringWidget @@ -125,7 +142,10 @@ def onParamDefValueChanged ( self, param ) : # if DEBUG_MODE : print '* onParamDefValueChanged' self.param.default = self.param_default.value - self.emit ( QtCore.SIGNAL ( 'changeParamDefValue' ), self.param ) + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( 'changeParamDefValue' ), self.param ) + else : + self.changeParamDefValue.emit ( self.param ) # # onParamValueChanged # @@ -133,15 +153,18 @@ def onParamValueChanged ( self, param ) : # if DEBUG_MODE : print '* onParamValueChanged' self.param.value = param.value - self.emit ( QtCore.SIGNAL ( 'changeParamValue' ), self.param ) + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( 'changeParamValue' ), self.param ) + else : + self.changeParamValue.emit ( self.param ) # # connectSignals # def connectSignals ( self ) : # if QtCore.QT_VERSION < 50000 : - self.connect ( self.param_default, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamDefValueChanged ) - self.connect ( self.param, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamValueChanged ) + self.connect ( self.param_default, QtCore.SIGNAL ( 'paramChangedSignal(QObject)' ), self.onParamDefValueChanged ) + self.connect ( self.param, QtCore.SIGNAL ( 'paramChangedSignal(QObject)' ), self.onParamValueChanged ) self.connect ( self.ui.name_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditParamName ) self.connect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditParamLabel ) @@ -154,6 +177,21 @@ def connectSignals ( self ) : self.connect ( self.ui.subtype_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamSubtype ) self.connect ( self.ui.range_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditParamRange ) self.connect ( self.ui.descr_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditParamHelp ) + else : + self.param_default.paramChangedSignal.connect ( self.onParamDefValueChanged ) + self.param.paramChangedSignal.connect ( self.onParamValueChanged ) + + self.ui.name_lineEdit.editingFinished.connect ( self.onEditParamName ) + self.ui.label_lineEdit.editingFinished.connect ( self.onEditParamLabel ) + self.ui.check_enabled.stateChanged.connect ( self.onEditParamEnabled ) + self.ui.check_display.stateChanged.connect ( self.onEditParamDisplay ) + self.ui.check_shader.stateChanged.connect ( self.onEditParamShader ) + self.ui.type_comboBox.activated.connect ( self.onEditParamType ) + self.ui.detail_comboBox.activated.connect ( self.onEditParamDetail ) + self.ui.provider_comboBox.activated.connect ( self.onEditParamProvider ) + self.ui.subtype_comboBox.activated.connect ( self.onEditParamSubtype ) + self.ui.range_lineEdit.editingFinished.connect ( self.onEditParamRange ) + self.ui.descr_plainTextEdit.textChanged.connect ( self.onEditParamHelp ) # # disconnectSignals # @@ -161,9 +199,9 @@ def disconnectSignals ( self ) : # if QtCore.QT_VERSION < 50000 : if self.param_default is not None : - self.disconnect ( self.param_default, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamDefValueChanged ) + self.disconnect ( self.param_default, QtCore.SIGNAL ( 'paramChangedSignal(QObject)' ), self.onParamDefValueChanged ) if self.param is not None : - self.disconnect ( self.param, QtCore.SIGNAL ( 'paramChanged(QObject)' ), self.onParamValueChanged ) + self.disconnect ( self.param, QtCore.SIGNAL ( 'paramChangedSignal(QObject)' ), self.onParamValueChanged ) self.disconnect ( self.ui.name_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditParamName ) self.disconnect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditParamLabel ) @@ -175,6 +213,23 @@ def disconnectSignals ( self ) : self.disconnect ( self.ui.provider_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamProvider ) self.disconnect ( self.ui.subtype_comboBox, QtCore.SIGNAL ( 'activated(int)' ), self.onEditParamSubtype ) self.disconnect ( self.ui.descr_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onEditParamHelp ) + else : + if self.param_default is not None : + self.param_default.paramChangedSignal.disconnect ( self.onParamDefValueChanged ) + if self.param is not None : + self.param.paramChangedSignal.disconnect ( self.onParamValueChanged ) + + self.ui.name_lineEdit.editingFinished.disconnect ( self.onEditParamName ) + self.ui.label_lineEdit.editingFinished.disconnect ( self.onEditParamLabel ) + self.ui.check_enabled.stateChanged.disconnect ( self.onEditParamEnabled ) + self.ui.check_display.stateChanged.disconnect ( self.onEditParamDisplay ) + self.ui.check_shader.stateChanged.disconnect ( self.onEditParamShader ) + self.ui.type_comboBox.activated.disconnect ( self.onEditParamType ) + self.ui.detail_comboBox.activated.disconnect ( self.onEditParamDetail ) + self.ui.provider_comboBox.activated.disconnect ( self.onEditParamProvider ) + self.ui.subtype_comboBox.activated.disconnect ( self.onEditParamSubtype ) + self.ui.range_lineEdit.editingFinished.disconnect ( self.onEditParamRange ) + self.ui.descr_plainTextEdit.textChanged.disconnect ( self.onEditParamHelp ) # # reset # @@ -195,7 +250,7 @@ def reset ( self ) : doc = QtGui.QTextDocument () doc.setPlainText ( '' ) - layout = QtGui.QPlainTextDocumentLayout ( doc ) + layout = QtModule.QPlainTextDocumentLayout ( doc ) doc.setDocumentLayout ( layout ) self.ui.descr_plainTextEdit.setDocument ( doc ) # @@ -252,12 +307,12 @@ def setParam ( self, param ) : # paramsLayout = QtModule.QGridLayout () paramsLayout.setContentsMargins ( 2, 2, 2, 2 ) - paramsLayout.setSizeConstraint ( QtGui.QLayout.SetNoConstraint ) + paramsLayout.setSizeConstraint ( QtModule.QLayout.SetNoConstraint ) paramsLayout.setVerticalSpacing ( 4 ) paramsLayout.setColumnStretch ( 1, 1 ) paramsLayout.setRowStretch ( 2, 1 ) - frame = QtGui.QFrame () + frame = QtModule.QFrame () frame.setLayout ( paramsLayout ) if self.param.type in self.paramWidgets.keys () : @@ -276,7 +331,7 @@ def setParam ( self, param ) : paramsLayout.addLayout ( self.ui.def_value_widget.label_vl, 1, 0, 1, 1 ) paramsLayout.addLayout ( self.ui.def_value_widget.param_vl, 1, 1, 1, 1 ) - spacer = QtGui.QSpacerItem ( 20, 20, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding ) + spacer = QtModule.QSpacerItem ( 20, 20, QtModule.QSizePolicy.Minimum, QtModule.QSizePolicy.Expanding ) paramsLayout.addItem ( spacer, 2, 0, 1, 1 ) self.ui.value_stackedWidget.addWidget ( frame ) @@ -297,7 +352,10 @@ def onEditParamName ( self ) : self.ui.name_lineEdit.setText ( newName ) if newName != oldName : self.param.name = newName - self.emit( QtCore.SIGNAL ( 'changeParamName' ), oldName, newName ) + if QtCore.QT_VERSION < 50000 : + self.emit( QtCore.SIGNAL ( 'changeParamName' ), oldName, newName ) + else : + self.changeParamName.emit ( oldName, newName ) # # onEditParamLabel # @@ -310,42 +368,87 @@ def onEditParamLabel ( self ) : self.ui.label_lineEdit.setText ( newName ) if newName != oldName : self.param.label = newName - self.emit ( QtCore.SIGNAL ( 'changeParamLabel' ), oldName, newName ) + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( 'changeParamLabel' ), oldName, newName ) + else : + self.changeParamLabel.emit ( oldName, newName ) + # + # onEditParamEnabled # + def onEditParamEnabled ( self, value ) : + # + self.param.enabled = self.ui.check_enabled.isChecked () + # + # onEditParamEnabled + # + def onEditParamDisplay ( self, value ) : + # + self.param.display = self.ui.check_display.isChecked () # + # onEditParamShader # - def onEditParamEnabled ( self, value ) : self.param.enabled = self.ui.check_enabled.isChecked () - def onEditParamDisplay ( self, value ) : self.param.display = self.ui.check_display.isChecked () def onEditParamShader ( self, value ) : # self.param.shaderParam = self.ui.check_shader.isChecked () - self.emit ( QtCore.SIGNAL ( 'changeParamIsShader' ), self.param ) - + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( 'changeParamIsShader' ), self.param ) + else : + self.changeParamIsShader.emit ( self.param ) + # + # onEditParamType + # def onEditParamType ( self, idx ) : # # !!! UI for param.value and param.default also should be changed # self.param.type = str ( self.ui.type_comboBox.itemText ( idx ) ) - self.emit ( QtCore.SIGNAL ( 'changeParamType' ), self.param ) - + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( 'changeParamType' ), self.param ) + else : + self.changeParamType.emit ( self.param ) + # + # onEditParamDetail + # def onEditParamDetail ( self, idx ) : # self.param.detail = str ( self.ui.detail_comboBox.itemText ( idx ) ) - self.emit ( QtCore.SIGNAL ( 'changeParamDetail' ), self.param ) - + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( 'changeParamDetail' ), self.param ) + else : + self.changeParamDetail.emit ( self.param ) + # + # onEditParamProvider + # def onEditParamProvider ( self, idx ) : # self.param.provider = str ( self.ui.provider_comboBox.itemText ( idx ) ) - self.emit ( QtCore.SIGNAL ( 'changeParamProvider' ), self.param ) - + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( 'changeParamProvider' ), self.param ) + else : + self.changeParamProvider.emit ( self.param ) + # + # onEditParamSubtype + # def onEditParamSubtype ( self, idx ) : # self.param.subtype = str ( self.ui.subtype_comboBox.itemText ( idx ) ) - self.emit ( QtCore.SIGNAL ( 'changeParamSubtype' ), self.param ) - + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( 'changeParamSubtype' ), self.param ) + else : + self.changeParamSubtype.emit ( self.param ) + # + # onEditParamRange + # def onEditParamRange ( self ) : # self.param.range = str ( self.ui.range_lineEdit.text () ) - self.emit ( QtCore.SIGNAL ( 'changeParamRange' ), self.param ) - - def onEditParamHelp ( self ) : self.param.help = str ( self.ui.descr_plainTextEdit.toPlainText () ) + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( 'changeParamRange' ), self.param ) + else : + self.changeParamRange.emit ( self.param ) + # + # onEditParamHelp + # + def onEditParamHelp ( self ) : + # + self.param.help = str ( self.ui.descr_plainTextEdit.toPlainText () ) diff --git a/gui/nodeEditor/nodePropertiesEditor.py b/gui/nodeEditor/nodePropertiesEditor.py index 1f3e49e..026dd1b 100644 --- a/gui/nodeEditor/nodePropertiesEditor.py +++ b/gui/nodeEditor/nodePropertiesEditor.py @@ -36,7 +36,13 @@ class NodePropertiesEditor ( QtModule.QWidget ) : def __init__ ( self, parent, editNode = None ) : # QtModule.QWidget.__init__ ( self, parent ) - + # + # Define signals for PyQt5 + # + if QtCore.QT_VERSION >= 50000 : + # + self.changeNodeLabel = Signal () + # self.editNode = editNode #self.debugPrint() @@ -181,25 +187,52 @@ def onEditNodeStrAttrLabel ( self ) : oldLabel = self.editNode.label newLabel = str ( self.ui.label_lineEdit.text () ).strip () if newLabel == '' : - self.disconnect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) + if QtCore.QT_VERSION < 50000 : + self.disconnect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) + else : + self.ui.label_lineEdit.editingFinished.disconnect ( self.onEditNodeStrAttrLabel ) newLabel = oldLabel self.ui.label_lineEdit.setText ( newLabel ) - self.connect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) + if QtCore.QT_VERSION < 50000 : + self.connect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) + else : + self.ui.label_lineEdit.editingFinished.connect ( self.onEditNodeStrAttrLabel ) if newLabel != oldLabel : self.editNode.label = newLabel - self.emit ( QtCore.SIGNAL ( 'changeNodeLabel' ), oldLabel, newLabel ) - - def onEditNodeStrAttrMaster ( self ) : self.editNode.master = str ( self.ui.master_lineEdit.text () ) - def onEditNodeStrAttrAuthor ( self ) : self.editNode.author = str ( self.ui.author_lineEdit.text () ) - def onEditNodeStrAttrIcon ( self ) : self.editNode.icon = str ( self.ui.icon_lineEdit.text () ) + if QtCore.QT_VERSION < 50000 : + self.emit ( QtCore.SIGNAL ( 'changeNodeLabel' ), oldLabel, newLabel ) + else : + self.changeNodeLabel.emit ( oldLabel, newLabel ) + # + # onEditNodeStrAttrMaster + # + def onEditNodeStrAttrMaster ( self ) : + # + self.editNode.master = str ( self.ui.master_lineEdit.text () ) + # + # onEditNodeStrAttrAuthor + # + def onEditNodeStrAttrAuthor ( self ) : + # + self.editNode.author = str ( self.ui.author_lineEdit.text () ) + # + # onEditNodeStrAttrIcon + # + def onEditNodeStrAttrIcon ( self ) : + # + self.editNode.icon = str ( self.ui.icon_lineEdit.text () ) # # onEditNodeTxtAttr # - def onEditNodeTxtAttr ( self ) : self.editNode.help = str ( self.ui.help_plainTextEdit.toPlainText () ) + def onEditNodeTxtAttr ( self ) : + # + self.editNode.help = str ( self.ui.help_plainTextEdit.toPlainText () ) # # onEditNodeType # - def onEditNodeType ( self, idx ) : self.editNode.type = str ( self.ui.type_comboBox.itemText ( idx ) ) + def onEditNodeType ( self, idx ) : + # + self.editNode.type = str ( self.ui.type_comboBox.itemText ( idx ) ) diff --git a/gui/nodeEditor/ui_nodeCodeEditor.py b/gui/nodeEditor/ui_nodeCodeEditor.py index 63bdc50..4705e13 100644 --- a/gui/nodeEditor/ui_nodeCodeEditor.py +++ b/gui/nodeEditor/ui_nodeCodeEditor.py @@ -34,7 +34,8 @@ def setupUi(self, NodeCodeEditor): NodeCodeEditor.setObjectName(_fromUtf8("NodeCodeEditor")) NodeCodeEditor.resize(683, 838) self.gridLayout = QtModule.QGridLayout(NodeCodeEditor) - self.gridLayout.setMargin(0) + if QtCore.QT_VERSION < 50000 : + self.gridLayout.setMargin(0) self.gridLayout.setSpacing(0) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) self.textEdit = QtModule.QTextEdit(NodeCodeEditor) diff --git a/gui/nodeEditor/ui_nodeEditorDialog.py b/gui/nodeEditor/ui_nodeEditorDialog.py index 1521f9e..5dc95d8 100644 --- a/gui/nodeEditor/ui_nodeEditorDialog.py +++ b/gui/nodeEditor/ui_nodeEditorDialog.py @@ -45,8 +45,8 @@ def setupUi(self, NodeEditorDialog): self.toolBox.setMinimumSize(QtCore.QSize(0, 0)) self.toolBox.setMaximumSize(QtCore.QSize(16777215, 16777215)) self.toolBox.setBaseSize(QtCore.QSize(200, 0)) - self.toolBox.setFrameShape(QtGui.QFrame.NoFrame) - self.toolBox.setFrameShadow(QtGui.QFrame.Plain) + self.toolBox.setFrameShape(QtModule.QFrame.NoFrame) + self.toolBox.setFrameShadow(QtModule.QFrame.Plain) self.toolBox.setLineWidth(1) self.toolBox.setMidLineWidth(0) self.toolBox.setObjectName(_fromUtf8("toolBox")) @@ -97,7 +97,8 @@ def setupUi(self, NodeEditorDialog): self.inputs_tab = QtModule.QWidget() self.inputs_tab.setObjectName(_fromUtf8("inputs_tab")) self.gridLayout_2 = QtModule.QGridLayout(self.inputs_tab) - self.gridLayout_2.setMargin(2) + if QtCore.QT_VERSION < 50000 : + self.gridLayout_2.setMargin(2) self.gridLayout_2.setSpacing(0) self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) self.input_list = NodeNamesEditor(self.inputs_tab) @@ -107,7 +108,8 @@ def setupUi(self, NodeEditorDialog): self.outputs_tab = QtModule.QWidget() self.outputs_tab.setObjectName(_fromUtf8("outputs_tab")) self.gridLayout_3 = QtModule.QGridLayout(self.outputs_tab) - self.gridLayout_3.setMargin(2) + if QtCore.QT_VERSION < 50000 : + self.gridLayout_3.setMargin(2) self.gridLayout_3.setSpacing(0) self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3")) self.output_list = NodeNamesEditor(self.outputs_tab) @@ -186,7 +188,8 @@ def setupUi(self, NodeEditorDialog): self.control_code_tab = QtModule.QWidget() self.control_code_tab.setObjectName(_fromUtf8("control_code_tab")) self.gridLayout_7 = QtModule.QGridLayout(self.control_code_tab) - self.gridLayout_7.setMargin(2) + if QtCore.QT_VERSION < 50000 : + self.gridLayout_7.setMargin(2) self.gridLayout_7.setSpacing(2) self.gridLayout_7.setObjectName(_fromUtf8("gridLayout_7")) self.control_code = NodeCodeEditor(self.control_code_tab) @@ -232,14 +235,14 @@ def setupUi(self, NodeEditorDialog): self.gridLayout_12.addWidget(self.link, 0, 0, 1, 1) self.tabWidget.addTab(self.link_tab, _fromUtf8("")) self.verticalLayout.addWidget(self.splitter) - self.horizontalLayout = QtGui.QHBoxLayout() + self.horizontalLayout = QtModule.QHBoxLayout() self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) - spacerItem = QtGui.QSpacerItem(40, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) + spacerItem = QtModule.QSpacerItem(40, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) - self.btn_save = QtGui.QPushButton(NodeEditorDialog) + self.btn_save = QtModule.QPushButton(NodeEditorDialog) self.btn_save.setObjectName(_fromUtf8("btn_save")) self.horizontalLayout.addWidget(self.btn_save) - self.btn_close = QtGui.QPushButton(NodeEditorDialog) + self.btn_close = QtModule.QPushButton(NodeEditorDialog) self.btn_close.setObjectName(_fromUtf8("btn_close")) self.horizontalLayout.addWidget(self.btn_close) self.verticalLayout.addLayout(self.horizontalLayout) @@ -265,7 +268,7 @@ def setupUi(self, NodeEditorDialog): self.btn_close.clicked.connect( NodeEditorDialog.reject) self.input_links_listWidget.itemSelectionChanged.connect( NodeEditorDialog.updateGui) self.output_links_listWidget.itemSelectionChanged.connect( NodeEditorDialog.updateGui) - self.tabs_links_list,currentChanged.connect( NodeEditorDialog.updateGui) + self.tabs_links_list.currentChanged.connect( NodeEditorDialog.updateGui) QtCore.QMetaObject.connectSlotsByName(NodeEditorDialog) diff --git a/gui/nodeEditor/ui_nodeLinkEditor.py b/gui/nodeEditor/ui_nodeLinkEditor.py index 97bad40..10619cd 100644 --- a/gui/nodeEditor/ui_nodeLinkEditor.py +++ b/gui/nodeEditor/ui_nodeLinkEditor.py @@ -120,13 +120,13 @@ def setupUi(self, NodeLinkEditor): QtCore.QMetaObject.connectSlotsByName(NodeLinkEditor) def retranslateUi(self, NodeLinkEditor): - NodeLinkEditor.setWindowTitle(QtGui.QApplication.translate("NodeLinkEditor", "NodeLinkEditor", None)) - self.srcGroup.setTitle(QtGui.QApplication.translate("NodeLinkEditor", "Source Node", None)) - self.name_label.setText(QtGui.QApplication.translate("NodeLinkEditor", "Name", None)) - self.label_label.setText(QtGui.QApplication.translate("NodeLinkEditor", "Parameter", None)) - self.name_label_2.setText(QtGui.QApplication.translate("NodeLinkEditor", "id", None)) - self.dstGroup.setTitle(QtGui.QApplication.translate("NodeLinkEditor", "Destination Node", None)) - self.name_label_3.setText(QtGui.QApplication.translate("NodeLinkEditor", "Name", None)) - self.label_label_2.setText(QtGui.QApplication.translate("NodeLinkEditor", "Parameter", None)) - self.name_label_4.setText(QtGui.QApplication.translate("NodeLinkEditor", "id", None)) + NodeLinkEditor.setWindowTitle(QtModule.QApplication.translate("NodeLinkEditor", "NodeLinkEditor", None)) + self.srcGroup.setTitle(QtModule.QApplication.translate("NodeLinkEditor", "Source Node", None)) + self.name_label.setText(QtModule.QApplication.translate("NodeLinkEditor", "Name", None)) + self.label_label.setText(QtModule.QApplication.translate("NodeLinkEditor", "Parameter", None)) + self.name_label_2.setText(QtModule.QApplication.translate("NodeLinkEditor", "id", None)) + self.dstGroup.setTitle(QtModule.QApplication.translate("NodeLinkEditor", "Destination Node", None)) + self.name_label_3.setText(QtModule.QApplication.translate("NodeLinkEditor", "Name", None)) + self.label_label_2.setText(QtModule.QApplication.translate("NodeLinkEditor", "Parameter", None)) + self.name_label_4.setText(QtModule.QApplication.translate("NodeLinkEditor", "id", None)) diff --git a/gui/nodeEditor/ui_nodeNamesEditor.py b/gui/nodeEditor/ui_nodeNamesEditor.py index cf82fb9..57dae9f 100644 --- a/gui/nodeEditor/ui_nodeNamesEditor.py +++ b/gui/nodeEditor/ui_nodeNamesEditor.py @@ -26,7 +26,8 @@ def setupUi(self, NodeNamesEditor): NodeNamesEditor.resize(417, 393) self.verticalLayout = QtModule.QVBoxLayout(NodeNamesEditor) self.verticalLayout.setSpacing(0) - self.verticalLayout.setMargin(0) + if QtCore.QT_VERSION < 50000 : + self.verticalLayout.setMargin(0) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.horizontalLayout = QtModule.QHBoxLayout() self.horizontalLayout.setSpacing(2) @@ -58,7 +59,7 @@ def setupUi(self, NodeNamesEditor): self.listWidget = QtModule.QListWidget(NodeNamesEditor) self.listWidget.setAcceptDrops(True) self.listWidget.setDragEnabled(True) - self.listWidget.setDragDropMode(QtGui.QAbstractItemView.InternalMove) + self.listWidget.setDragDropMode(QtModule.QAbstractItemView.InternalMove) self.listWidget.setObjectName(_fromUtf8("listWidget")) self.verticalLayout.addWidget(self.listWidget) @@ -76,10 +77,10 @@ def setupUi(self, NodeNamesEditor): QtCore.QMetaObject.connectSlotsByName(NodeNamesEditor) def retranslateUi(self, NodeNamesEditor): - NodeNamesEditor.setWindowTitle(QtGui.QApplication.translate("NodeNamesEditor", "Form", None)) - self.addButton.setToolTip(QtGui.QApplication.translate("NodeNamesEditor", "Add", None)) - self.addButton.setText(QtGui.QApplication.translate("NodeNamesEditor", "...", None)) - self.removeButton.setToolTip(QtGui.QApplication.translate("NodeNamesEditor", "Remove", None)) - self.removeButton.setText(QtGui.QApplication.translate("NodeNamesEditor", "...", None)) + NodeNamesEditor.setWindowTitle(QtModule.QApplication.translate("NodeNamesEditor", "Form", None)) + self.addButton.setToolTip(QtModule.QApplication.translate("NodeNamesEditor", "Add", None)) + self.addButton.setText(QtModule.QApplication.translate("NodeNamesEditor", "...", None)) + self.removeButton.setToolTip(QtModule.QApplication.translate("NodeNamesEditor", "Remove", None)) + self.removeButton.setText(QtModule.QApplication.translate("NodeNamesEditor", "...", None)) import gui.resources_rc diff --git a/gui/params/FloatWidget.py b/gui/params/FloatWidget.py index 22094d9..e8c3a9a 100644 --- a/gui/params/FloatWidget.py +++ b/gui/params/FloatWidget.py @@ -117,14 +117,14 @@ def setupUi ( self, FloatWidget ) : self.checkBox.setMinimumSize ( QtCore.QSize ( UI.CHECK_WIDTH, UI.HEIGHT ) ) # UI.EDIT_WIDTH self.checkBox.setMaximumSize ( QtCore.QSize ( UI.MAX, UI.HEIGHT ) ) - spacer = QtGui.QSpacerItem ( 20, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum ) + spacer = QtModule.QSpacerItem ( 20, 20, QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Minimum ) hl.addWidget ( self.checkBox ) hl.addItem ( spacer ) self.widget.param_vl.addLayout ( hl ) - - QtCore.QMetaObject.connectSlotsByName ( FloatWidget ) + self.connectSignals ( FloatWidget ) + QtCore.QMetaObject.connectSlotsByName ( FloatWidget ) # # connectSignals # @@ -314,7 +314,10 @@ def disconnectSignals ( self, FloatWidget ) : def onFloatEditEditingFinished ( self ) : # floatStr = self.floatEdit.text () - floatValue = floatStr.toFloat () [ 0 ] + if QtCore.QT_VERSION < 50000 : + floatValue = floatStr.toFloat () [ 0 ] + else : + floatValue = float ( floatStr ) self.widget.param.setValue ( floatValue ) floatMinVal = 0 diff --git a/gui/params/NormalWidget.py b/gui/params/NormalWidget.py index ffab3e8..f5607b3 100644 --- a/gui/params/NormalWidget.py +++ b/gui/params/NormalWidget.py @@ -36,9 +36,9 @@ def setupUi ( self, NormalWidget ) : hl = QtModule.QHBoxLayout () self.widget = NormalWidget - self.floatEdit0 = QtGui.QLineEdit( NormalWidget ) - self.floatEdit1 = QtGui.QLineEdit( NormalWidget ) - self.floatEdit2 = QtGui.QLineEdit( NormalWidget ) + self.floatEdit0 = QtModule.QLineEdit( NormalWidget ) + self.floatEdit1 = QtModule.QLineEdit( NormalWidget ) + self.floatEdit2 = QtModule.QLineEdit( NormalWidget ) self.floatEdit0.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) # UI.EDIT_WIDTH self.floatEdit1.setMinimumSize ( QtCore.QSize ( UI.FIELD_WIDTH, UI.HEIGHT ) ) @@ -68,8 +68,8 @@ def setupUi ( self, NormalWidget ) : self.widget.param_vl.addLayout ( hl ) - QtCore.QMetaObject.connectSlotsByName ( NormalWidget ) self.connectSignals ( NormalWidget ) + QtCore.QMetaObject.connectSlotsByName ( NormalWidget ) # # connectSignals # @@ -126,6 +126,11 @@ def onCurrentIndexChanged ( self, idx ) : # def updateGui ( self, value ) : # - self.floatEdit0.setText ( QtCore.QString.number ( value [0], 'f', 3 ) ) - self.floatEdit1.setText ( QtCore.QString.number ( value [1], 'f', 3 ) ) - self.floatEdit2.setText ( QtCore.QString.number ( value [2], 'f', 3 ) ) + if QtCore.QT_VERSION < 50000 : + self.floatEdit0.setText ( QtCore.QString.number( value [0], 'f', 3 ) ) + self.floatEdit1.setText ( QtCore.QString.number( value [1], 'f', 3 ) ) + self.floatEdit2.setText ( QtCore.QString.number( value [2], 'f', 3 ) ) + else : + self.floatEdit0.setText ( str ( value [0] ) ) + self.floatEdit1.setText ( str ( value [1] ) ) + self.floatEdit2.setText ( str ( value [2] ) ) diff --git a/gui/params/PointWidget.py b/gui/params/PointWidget.py index f6087bb..014bd6c 100644 --- a/gui/params/PointWidget.py +++ b/gui/params/PointWidget.py @@ -82,7 +82,7 @@ def connectSignals ( self, PointWidget ) : PointWidget.connect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) else : self.floatEdit0.editingFinished.connect ( self.onFloatEditEditingFinished ) - self.floatEdit1,editingFinished.connect ( self.onFloatEditEditingFinished ) + self.floatEdit1.editingFinished.connect ( self.onFloatEditEditingFinished ) self.floatEdit2.editingFinished.connect ( self.onFloatEditEditingFinished ) self.selector.activated.connect ( self.onCurrentIndexChanged ) # @@ -97,7 +97,7 @@ def disconnectSignals ( self, PointWidget ) : PointWidget.disconnect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) else : self.floatEdit0.editingFinished.disconnect ( self.onFloatEditEditingFinished ) - self.floatEdit1,editingFinished.disconnect ( self.onFloatEditEditingFinished ) + self.floatEdit1.editingFinished.disconnect ( self.onFloatEditEditingFinished ) self.floatEdit2.editingFinished.disconnect ( self.onFloatEditEditingFinished ) self.selector.activated.disconnect ( self.onCurrentIndexChanged ) # @@ -126,6 +126,11 @@ def onCurrentIndexChanged ( self, idx ) : # def updateGui ( self, value ) : # - self.floatEdit0.setText ( QtCore.QString.number( value [0], 'f', 3 ) ) - self.floatEdit1.setText ( QtCore.QString.number( value [1], 'f', 3 ) ) - self.floatEdit2.setText ( QtCore.QString.number( value [2], 'f', 3 ) ) + if QtCore.QT_VERSION < 50000 : + self.floatEdit0.setText ( QtCore.QString.number( value [0], 'f', 3 ) ) + self.floatEdit1.setText ( QtCore.QString.number( value [1], 'f', 3 ) ) + self.floatEdit2.setText ( QtCore.QString.number( value [2], 'f', 3 ) ) + else : + self.floatEdit0.setText ( str ( value [0] ) ) + self.floatEdit1.setText ( str ( value [1] ) ) + self.floatEdit2.setText ( str ( value [2] ) ) diff --git a/gui/params/VectorWidget.py b/gui/params/VectorWidget.py index 6b7c85b..4fc9815 100644 --- a/gui/params/VectorWidget.py +++ b/gui/params/VectorWidget.py @@ -67,8 +67,8 @@ def setupUi ( self, VectorWidget ) : hl.addItem ( spacer ) self.widget.param_vl.addLayout ( hl ) - QtCore.QMetaObject.connectSlotsByName ( VectorWidget ) self.connectSignals ( VectorWidget ) + QtCore.QMetaObject.connectSlotsByName ( VectorWidget ) # # connectSignals # @@ -126,6 +126,11 @@ def onCurrentIndexChanged ( self, idx ) : # def updateGui ( self, value ) : # - self.floatEdit0.setText ( QtCore.QString.number ( value [0], 'f', 3 ) ) - self.floatEdit1.setText ( QtCore.QString.number ( value [1], 'f', 3 ) ) - self.floatEdit2.setText ( QtCore.QString.number ( value [2], 'f', 3 ) ) + if QtCore.QT_VERSION < 50000 : + self.floatEdit0.setText ( QtCore.QString.number( value [0], 'f', 3 ) ) + self.floatEdit1.setText ( QtCore.QString.number( value [1], 'f', 3 ) ) + self.floatEdit2.setText ( QtCore.QString.number( value [2], 'f', 3 ) ) + else : + self.floatEdit0.setText ( str ( value [0] ) ) + self.floatEdit1.setText ( str ( value [1] ) ) + self.floatEdit2.setText ( str ( value [2] ) ) diff --git a/gui/params/paramWidget.py b/gui/params/paramWidget.py index eda4995..bcb0e7d 100644 --- a/gui/params/paramWidget.py +++ b/gui/params/paramWidget.py @@ -114,7 +114,10 @@ def buildGeneralGui ( self ) : self.check.setMaximumSize ( QtCore.QSize ( UI.CHECK_WIDTH, UI.HEIGHT ) ) self.check.setToolTip ( 'Use as Shader parameter' ) self.check.setChecked ( self.param.shaderParam ) - self.connect ( self.check, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onShaderParamChanged ) + if QtCore.QT_VERSION < 50000 : + self.connect ( self.check, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onShaderParamChanged ) + else : + self.check.stateChanged.connect ( self.onShaderParamChanged ) self.hl.addWidget ( self.check ) else : spacer = QtModule.QSpacerItem ( UI.LT_SPACE, UI.HEIGHT, QtModule.QSizePolicy.Minimum, QtModule.QSizePolicy.Minimum ) @@ -138,8 +141,10 @@ def buildGeneralGui ( self ) : self.removeButton.setIconSize ( QtCore.QSize ( 16, 16 ) ) self.removeButton.setObjectName ( 'removeButton' ) self.hl.addWidget ( self.removeButton ) - QtCore.QObject.connect ( self.removeButton, QtCore.SIGNAL ( 'clicked()' ), self.onRemoveItem ) - + if QtCore.QT_VERSION < 50000 : + QtCore.QObject.connect ( self.removeButton, QtCore.SIGNAL ( 'clicked()' ), self.onRemoveItem ) + else : + self.removeButton.clicked.connect ( self.onRemoveItem ) #self.label = QtGui.QLabel ( self ) self.label = ParamLabel ( self, self.param ) #font = QtGui.QFont () diff --git a/gui/ui_meRendererSetup.py b/gui/ui_meRendererSetup.py index 7f3970f..66a591e 100644 --- a/gui/ui_meRendererSetup.py +++ b/gui/ui_meRendererSetup.py @@ -236,7 +236,7 @@ def setupUi(self, meRendererSetup): self.verticalLayout.addLayout(self.horizontalLayout_7) self.horizontalLayout_8 = QtModule.QHBoxLayout() self.horizontalLayout_8.setSpacing(4) - self.horizontalLayout_8.setSizeConstraint(QtGui.QLayout.SetNoConstraint) + self.horizontalLayout_8.setSizeConstraint(QtModule.QLayout.SetNoConstraint) self.horizontalLayout_8.setObjectName("horizontalLayout_8") self.labelShaderExt = QtModule.QLabel(self.tab2) sizePolicy = QtModule.QSizePolicy(QtModule.QSizePolicy.Fixed, QtModule.QSizePolicy.Preferred) @@ -395,29 +395,29 @@ def setupUi(self, meRendererSetup): meRendererSetup.setTabOrder(self.lineTexViewer, self.lineTexExt) def retranslateUi(self, meRendererSetup): - meRendererSetup.setWindowTitle(QtGui.QApplication.translate("meRendererSetup", "Renderer preset setup", None)) - self.labelPreset.setText(QtGui.QApplication.translate("meRendererSetup", "Preset", None)) - self.newButton.setToolTip(QtGui.QApplication.translate("meRendererSetup", "Create new renderer preset", None)) - self.newButton.setText(QtGui.QApplication.translate("meRendererSetup", "New", None)) - self.deleteButton.setToolTip(QtGui.QApplication.translate("meRendererSetup", "Delete current renderer preset", None)) - self.deleteButton.setText(QtGui.QApplication.translate("meRendererSetup", "Delete", None)) - self.saveButton.setToolTip(QtGui.QApplication.translate("meRendererSetup", "Save current renderer preset", None)) - self.saveButton.setText(QtGui.QApplication.translate("meRendererSetup", "Save", None)) - self.cancelButton.setText(QtGui.QApplication.translate("meRendererSetup", "Cancel", None)) - self.okButton.setToolTip(QtGui.QApplication.translate("meRendererSetup", "Select current renderer preset", None)) - self.okButton.setText(QtGui.QApplication.translate("meRendererSetup", "Select", None)) - self.labelName.setText(QtGui.QApplication.translate("meRendererSetup", "Label", None)) - self.labelCmd.setText(QtGui.QApplication.translate("meRendererSetup", "Command", None)) - self.labelFlags.setText(QtGui.QApplication.translate("meRendererSetup", "Flags", None)) - self.tabs.setTabText(self.tabs.indexOf(self.tab1), QtGui.QApplication.translate("meRendererSetup", "Renderer", None)) - self.labelCompiler.setText(QtGui.QApplication.translate("meRendererSetup", " Compiler", None)) - self.labelShaderInfo.setText(QtGui.QApplication.translate("meRendererSetup", "SloInfo", None)) - self.labelDefines.setText(QtGui.QApplication.translate("meRendererSetup", "Defines", None)) - self.labelShaderExt.setText(QtGui.QApplication.translate("meRendererSetup", " Extension", None)) - self.tabs.setTabText(self.tabs.indexOf(self.tab2), QtGui.QApplication.translate("meRendererSetup", "Shaders", None)) - self.labelTexMake.setText(QtGui.QApplication.translate("meRendererSetup", "TexMake", None)) - self.labelTexInfo.setText(QtGui.QApplication.translate("meRendererSetup", " TexInfo", None)) - self.labelTexViewer.setText(QtGui.QApplication.translate("meRendererSetup", "Viewer", None)) - self.labelTexExt.setText(QtGui.QApplication.translate("meRendererSetup", " Extension", None)) - self.tabs.setTabText(self.tabs.indexOf(self.tab3), QtGui.QApplication.translate("meRendererSetup", "Textures", None)) + meRendererSetup.setWindowTitle(QtModule.QApplication.translate("meRendererSetup", "Renderer preset setup", None)) + self.labelPreset.setText(QtModule.QApplication.translate("meRendererSetup", "Preset", None)) + self.newButton.setToolTip(QtModule.QApplication.translate("meRendererSetup", "Create new renderer preset", None)) + self.newButton.setText(QtModule.QApplication.translate("meRendererSetup", "New", None)) + self.deleteButton.setToolTip(QtModule.QApplication.translate("meRendererSetup", "Delete current renderer preset", None)) + self.deleteButton.setText(QtModule.QApplication.translate("meRendererSetup", "Delete", None)) + self.saveButton.setToolTip(QtModule.QApplication.translate("meRendererSetup", "Save current renderer preset", None)) + self.saveButton.setText(QtModule.QApplication.translate("meRendererSetup", "Save", None)) + self.cancelButton.setText(QtModule.QApplication.translate("meRendererSetup", "Cancel", None)) + self.okButton.setToolTip(QtModule.QApplication.translate("meRendererSetup", "Select current renderer preset", None)) + self.okButton.setText(QtModule.QApplication.translate("meRendererSetup", "Select", None)) + self.labelName.setText(QtModule.QApplication.translate("meRendererSetup", "Label", None)) + self.labelCmd.setText(QtModule.QApplication.translate("meRendererSetup", "Command", None)) + self.labelFlags.setText(QtModule.QApplication.translate("meRendererSetup", "Flags", None)) + self.tabs.setTabText(self.tabs.indexOf(self.tab1), QtModule.QApplication.translate("meRendererSetup", "Renderer", None)) + self.labelCompiler.setText(QtModule.QApplication.translate("meRendererSetup", " Compiler", None)) + self.labelShaderInfo.setText(QtModule.QApplication.translate("meRendererSetup", "SloInfo", None)) + self.labelDefines.setText(QtModule.QApplication.translate("meRendererSetup", "Defines", None)) + self.labelShaderExt.setText(QtModule.QApplication.translate("meRendererSetup", " Extension", None)) + self.tabs.setTabText(self.tabs.indexOf(self.tab2), QtModule.QApplication.translate("meRendererSetup", "Shaders", None)) + self.labelTexMake.setText(QtModule.QApplication.translate("meRendererSetup", "TexMake", None)) + self.labelTexInfo.setText(QtModule.QApplication.translate("meRendererSetup", " TexInfo", None)) + self.labelTexViewer.setText(QtModule.QApplication.translate("meRendererSetup", "Viewer", None)) + self.labelTexExt.setText(QtModule.QApplication.translate("meRendererSetup", " Extension", None)) + self.tabs.setTabText(self.tabs.indexOf(self.tab3), QtModule.QApplication.translate("meRendererSetup", "Textures", None)) diff --git a/gui/ui_viewComputedCodeDialog.py b/gui/ui_viewComputedCodeDialog.py index cff0dce..a64f92a 100644 --- a/gui/ui_viewComputedCodeDialog.py +++ b/gui/ui_viewComputedCodeDialog.py @@ -40,7 +40,7 @@ def setupUi(self, ViewComputedCodeDialog): self.gridLayout.addWidget(self.codeEdit, 0, 0, 1, 1) self.buttonBox = QtModule.QDialogButtonBox(ViewComputedCodeDialog) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Close) + self.buttonBox.setStandardButtons(QtModule.QDialogButtonBox.Close) self.buttonBox.setObjectName(_fromUtf8("buttonBox")) self.gridLayout.addWidget(self.buttonBox, 1, 0, 1, 1) diff --git a/lib/nodes/example_001.xml b/lib/nodes/example_001.xml new file mode 100644 index 0000000..a2f29e3 --- /dev/null +++ b/lib/nodes/example_001.xml @@ -0,0 +1,740 @@ + + + Short NodeNetwork description + + + Image viewer with dynamicaly added inputs + + + +#print ":: Hello from (%s) XML control param code !!!" % self.label +from core.params.imageNodeParam import ImageNodeParam +lastNonremovableParam = node.getInputParamByName ( 'selector' ) +lastNonremovableParamIdx = node.inputParams.index ( lastNonremovableParam ) +lastParamIdx = len ( node.inputParams ) +suffixIdx = lastParamIdx - lastNonremovableParamIdx + +newParam = ImageNodeParam () +newParam.setup ( 'image' + str ( suffixIdx ), '', '', '' ) +newParam.value = '' +newParam.default = '' +newParam.subtype="file" +newParam.range="All files=*.*:TIFF=*.tif:PNG=*.png:JPEG=*.jpg" +newParam.removable = True +node.addInputParam ( newParam ) +node.updateNodeParams () + + + + + + + + + + + + + + + + + + + + Basic preview RIB with geometry primitive, 2 distant and 1 environment light + + + + + + + + + + + + + + + + + + + + + + + + + + + Basic surface shader. + + + + + + + + + + + + + + Returns the 3D point on the surface of your object. + + + The name of a coordinate system for the manifold. + In addition to your custom coordinate systems + you can use "current", "world", "object", "shader" + and "NDC" (screen coordinates). + + + Controls the scale of the manifold. Note + that increasing the frequency of the manifold will result + in decreasing the scale of a feature. + + + If you have attached __Pref geometry and, + for debugging purposes, want to ignore it, click + here. Note that it's much more efficient to simply + remove the reference geometry if it's not needed. + + + + + + + + + + + + + + + + + Color filtered noise. + + + + + + + + + + + + + + + + + + + + + + Blinn illumination model. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Text note + + + + + + + + + + + + + + + Swatch displacement shader. + + + + + + + + + + + + + + Swatch surface shader. + + + + + + + + + + + + + + Basic primitive preview RIB for swatch node + + + + + + + + + + + + + + + + + + + + + + + + + + + + Swatch node viewer + + + + + + + + + + + + Global point P. + + + + + + + + + + + Root displacement shader. + + + + + + + + + + + + + + Global normal N. + + + + + + + + + + + Float filtered noise. + + + + + + + + + + + + + + + + + + + + + + Simple displacement shader. + + + + + + + The space that displacement is performed in. + You may want to set it to "world" to ignore object scale. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/nodes/startup.xml b/lib/nodes/startup.xml new file mode 100644 index 0000000..2b27848 --- /dev/null +++ b/lib/nodes/startup.xml @@ -0,0 +1,225 @@ + + + Short NodeNetwork description + + + Image viewer with dynamicaly added inputs + + + +#print ":: Hello from (%s) XML control param code !!!" % self.label +from core.params.imageNodeParam import ImageNodeParam +lastNonremovableParam = node.getInputParamByName ( 'selector' ) +lastNonremovableParamIdx = node.inputParams.index ( lastNonremovableParam ) +lastParamIdx = len ( node.inputParams ) +suffixIdx = lastParamIdx - lastNonremovableParamIdx + +newParam = ImageNodeParam () +newParam.setup ( 'image' + str ( suffixIdx ), '', '', '' ) +newParam.value = '' +newParam.default = '' +newParam.subtype="file" +newParam.range="All files=*.*:TIFF=*.tif:PNG=*.png:JPEG=*.jpg" +newParam.removable = True +node.addInputParam ( newParam ) +node.updateNodeParams () + + + + + + + + + + + + + + + + + + + + Basic preview RIB with geometry primitive, 2 distant and 1 environment light + + + + + + + + + + + + + + + + + + + + + + + + + + + Basic surface shader. + + + + + + + + + + + + + + Text note + + + + + + + + + + + + + + + + + + + diff --git a/lib/nodes/imageViewer.xml b/lib/nodes/utilites/imageViewer.xml similarity index 100% rename from lib/nodes/imageViewer.xml rename to lib/nodes/utilites/imageViewer.xml From aaafb3a0ed3aad9c2b84eeba50a7445e9e827f43 Mon Sep 17 00:00:00 2001 From: ymesh Date: Thu, 1 Oct 2015 02:37:35 +0300 Subject: [PATCH 5/6] Corrected constant value in condition QtCore.QT_VERSION < 0x50000 --- core/meCommon.py | 3 +- core/mePyQt.py | 8 ++- core/node.py | 6 +-- core/nodeParam.py | 6 +-- gfx/WorkArea.py | 26 +++++---- gfx/gfxLink.py | 4 +- gfx/gfxNode.py | 18 +++---- gfx/gfxNodeConnector.py | 14 ++--- gfx/gfxNodeLabel.py | 2 +- gfx/gfxNote.py | 4 +- gfx/gfxSwatchNode.py | 8 +-- gfx/imageView.py | 8 +-- global_vars.py | 28 +++++----- gui/MainWindow.py | 65 ++++++++++++++--------- gui/ProjectSetup.py | 4 +- gui/SettingsSetup.py | 4 +- gui/ViewComputedCodeDialog.py | 2 +- gui/exportShader/ExportShaderDialog.py | 16 +++--- gui/exportShader/ui_exportShaderDialog.py | 14 ++--- gui/imageViewWidget.py | 4 +- gui/meRendererSetup.py | 8 +-- gui/nodeEditor/NodeEditorDialog.py | 12 ++--- gui/nodeEditor/codeSyntaxHighlighter.py | 4 +- gui/nodeEditor/nodeCodeEditor.py | 2 +- gui/nodeEditor/nodeLinkEditor.py | 2 +- gui/nodeEditor/nodeNamesEditor.py | 12 ++--- gui/nodeEditor/nodeParamEditor.py | 28 +++++----- gui/nodeEditor/nodePropertiesEditor.py | 14 ++--- gui/nodeEditor/ui_nodeCodeEditor.py | 4 +- gui/nodeEditor/ui_nodeEditorDialog.py | 32 +++++------ gui/nodeEditor/ui_nodeLinkEditor.py | 2 +- gui/nodeEditor/ui_nodeNamesEditor.py | 6 +-- gui/nodeEditor/ui_nodeParamEditor.py | 2 +- gui/nodeEditor/ui_nodePropertiesEditor.py | 2 +- gui/nodeLibraryView.py | 2 +- gui/nodeList.py | 12 ++--- gui/nodeParamList.py | 10 ++-- gui/nodeParamView.py | 22 ++++---- gui/nodeSwatchParam.py | 2 +- gui/nodeTreeView.py | 6 +-- gui/params/ColorWidget.py | 12 ++--- gui/params/ControlWidget.py | 10 ++-- gui/params/FloatWidget.py | 26 ++++----- gui/params/IntWidget.py | 28 +++++----- gui/params/MatrixWidget.py | 6 +-- gui/params/NormalWidget.py | 8 +-- gui/params/PointWidget.py | 8 +-- gui/params/StringWidget.py | 16 +++--- gui/params/TextWidget.py | 6 +-- gui/params/VectorWidget.py | 8 +-- gui/params/linkWidget.py | 2 +- gui/params/paramLabel.py | 6 +-- gui/params/paramWidget.py | 16 +++--- gui/ui_MainWindow.py | 4 +- gui/ui_imageViewWidget.py | 4 +- gui/ui_meRendererSetup.py | 4 +- gui/ui_nodeLibraryView.py | 4 +- gui/ui_nodeList.py | 2 +- gui/ui_nodeParam.py | 2 +- gui/ui_nodeSwatchParam.py | 2 +- gui/ui_projectSetup.py | 4 +- gui/ui_settingsSetup.py | 4 +- gui/ui_viewComputedCodeDialog.py | 4 +- gui/ui_workArea.py | 2 +- meShaderEd.py | 18 +++---- mkpyqt5.py | 2 +- 66 files changed, 326 insertions(+), 310 deletions(-) diff --git a/core/meCommon.py b/core/meCommon.py index 6e3fc70..273d539 100644 --- a/core/meCommon.py +++ b/core/meCommon.py @@ -162,7 +162,8 @@ def getParsedLabel ( text ) : # getSettingsStrValue # def getSettingsStrValue ( settings, key ) : - if QtCore.QT_VERSION < 50000 : + # + if QtCore.QT_VERSION < 0x50000 : return str ( settings.value ( key ).toString () ) else : return str ( settings.value ( key ) ) diff --git a/core/mePyQt.py b/core/mePyQt.py index bb9bba4..f6800ec 100644 --- a/core/mePyQt.py +++ b/core/mePyQt.py @@ -29,14 +29,18 @@ PythonQt = __import__( 'PyQt4', globals(), locals(), List ) PythonQtType = 'PyQt4' +print ( '* ' + PythonQtType + ' module imported' ) +print ( '* ' + 'QT_VERSION = %x' % PythonQt.QtCore.QT_VERSION ) + Qt = PythonQt.Qt QtCore = PythonQt.QtCore QtGui = PythonQt.QtGui QtXml = PythonQt.QtXml -QtWidgets = PythonQt.QtWidgets +if QtCore.QT_VERSION >= 0x50000 : + QtWidgets = PythonQt.QtWidgets #QtNetwork = PythonQt.QtNetwork -print ( '* ' + PythonQtType + ' module imported' ) + if PythonQtType == 'PyQt4' or PythonQtType == 'PyQt5': #print('You can install PySide if interested in LGPL license.') diff --git a/core/node.py b/core/node.py index 613b00b..0f24597 100644 --- a/core/node.py +++ b/core/node.py @@ -26,7 +26,7 @@ def __init__ ( self, xml_node = None, nodenet = None ) : # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 50000 : + if QtCore.QT_VERSION >= 0x50000 : # self.nodeUpdated = Signal () # QtCore.pyqtSignal ( [QtCore.QObject] ) self.nodeParamsUpdated = Signal () #QtCore.pyqtSignal ( [QtCore.QObject] ) @@ -105,7 +105,7 @@ def copy ( self ) : assert 0, 'copy needs to be implemented!' def updateNode ( self ) : # if DEBUG_MODE : print '>> Node( %s ).updateNode' % self.label - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( 'nodeUpdated' ), self ) else : self.nodeUpdated.emit ( self ) @@ -115,7 +115,7 @@ def updateNode ( self ) : def updateNodeParams ( self ) : # if DEBUG_MODE : print '>> Node( %s ).updateNodeParams' % self.label - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( 'nodeParamsUpdated' ), self ) else : self.nodeParamsUpdated.emit ( self ) diff --git a/core/nodeParam.py b/core/nodeParam.py index 3d5e73e..c889fc7 100644 --- a/core/nodeParam.py +++ b/core/nodeParam.py @@ -29,7 +29,7 @@ def __init__ ( self, xml_param = None, isRibParam = False ) : # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 50000 : + if QtCore.QT_VERSION >= 0x50000 : # self.paramChangedSignal = Signal () @@ -92,7 +92,7 @@ def copy ( self ) : assert 0, 'copy needs to be implemented!' def copySetup ( self, newParam ) : # #if DEBUG_MODE : print '>> NodeParam( %s ).copySetup' % self.label - #if QtCore.QT_VERSION >= 50000 : + #if QtCore.QT_VERSION >= 0x50000 : # newParam.paramChangedSignal = self.paramChangedSignal # Signal () newParam.id = self.id newParam.name = self.name @@ -170,7 +170,7 @@ def valueToStr ( self, value ) : return str ( value ) def paramChanged ( self ) : # if DEBUG_MODE : print '>> NodeParam.paramChanged (name = %s)' % self.name - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( 'paramChangedSignal(QObject)' ), self ) else : self.paramChangedSignal.emit ( self ) diff --git a/gfx/WorkArea.py b/gfx/WorkArea.py index a80866a..2867737 100644 --- a/gfx/WorkArea.py +++ b/gfx/WorkArea.py @@ -21,7 +21,7 @@ from meShaderEd import app_settings from global_vars import DEBUG_MODE -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -34,7 +34,6 @@ # to work area # class WorkAreaScene ( QtModule.QGraphicsScene ) : - # # __init__ # @@ -44,7 +43,7 @@ def __init__ ( self, view ) : # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 50000 : + if QtCore.QT_VERSION >= 0x50000 : # self.startNodeConnector = Signal () #QtCore.pyqtSignal ( QtModule.QGraphicsObject, QtCore.QPointF ) self.traceNodeConnector = Signal () #QtCore.pyqtSignal ( QtModule.QGraphicsObject, QtCore.QPointF ) @@ -66,7 +65,7 @@ def __init__ ( self, view ) : # connectSignals # def connectSignals ( self ) : - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.connect ( self, QtCore.SIGNAL ( 'selectionChanged()' ), self.view.onSelectionChanged ) QtCore.QObject.connect ( self, QtCore.SIGNAL ( 'startNodeLink' ), self.view.onStartNodeLink ) @@ -97,7 +96,6 @@ def connectSignals ( self ) : # WorkArea # class WorkArea ( QtModule.QGraphicsView ) : - # # __init__ # @@ -108,7 +106,7 @@ def __init__ ( self ) : # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 50000 : + if QtCore.QT_VERSION >= 0x50000 : # self.selectNodes = Signal () #( list, list ) self.nodeConnectionChanged = Signal () #QtCore.pyqtSignal ( QtModule.QGraphicsObject, QtCore.QObject ) @@ -337,7 +335,7 @@ def addGfxNode ( self, node, pos = None ) : #for item in scene.selectedItems (): item.setSelected ( False ) scene.addItem ( gfxNode ) gfxNode.setSelected ( True ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( 'gfxNodeAdded' ), gfxNode ) else : self.gfxNodeAdded.emit ( gfxNode ) @@ -378,7 +376,7 @@ def onSelectionChanged ( self ) : elif isinstance ( item, GfxSwatchNode ) : self.selectedNodes.append ( item ) elif isinstance ( item, GfxLink ) : self.selectedLinks.append ( item ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( 'selectNodes' ), self.selectedNodes, self.selectedLinks ) else : self.selectNodes.emit ( self.selectedNodes, self.selectedLinks ) @@ -446,7 +444,7 @@ def onStartNodeLink ( self, connector ): def onTraceNodeLink ( self, connector, scenePos ) : # node = connector.parentItem().node # print ">> WorkArea: onDrawNodeLink from %s (%d %d)" % ( node.label, scenePos.x(), scenePos.y() ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : connectCandidate = self.scene ().itemAt ( scenePos ) else : connectCandidate = self.scene ().itemAt ( scenePos, self.transform () ) @@ -534,7 +532,7 @@ def onEndNodeLink ( self, connector, scenePos ) : self.currentGfxLink.link = link self.nodeNet.addLink ( link ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( 'nodeConnectionChanged' ), self.currentGfxLink.dstConnector.getGfxNode (), self.currentGfxLink.dstConnector.param ) else : self.nodeConnectionChanged.emit ( self.currentGfxLink.dstConnector.getGfxNode (), self.currentGfxLink.dstConnector.param ) @@ -663,7 +661,7 @@ def onEndNodeConnector ( self, connector, scenePos ) : def onRemoveNode ( self, gfxNode ) : # print ">> WorkArea.onRemoveNode %s (id = %d)" % ( gfxNode.node.label, gfxNode.node.id ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( 'gfxNodeRemoved' ), gfxNode ) else : self.gfxNodeRemoved.emit ( gfxNode ) @@ -689,7 +687,7 @@ def onRemoveLink ( self, gfxLink ) : #self.emit( QtCore.SIGNAL( 'nodeConnectionChanged' ), srcConnector.parentItem(), srcConnector.param ) if dstConnector is not None : if DEBUG_MODE : print '*** dstConnector.parentItem().node.label = %s ' % dstConnector.getNode ().label - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( 'nodeConnectionChanged' ), dstConnector.getGfxNode (), dstConnector.param ) else : self.nodeConnectionChanged.emit ( dstConnector.getGfxNode (), dstConnector.param ) @@ -751,7 +749,7 @@ def dropEvent ( self, event ) : data = mimedata.data ( 'application/x-text' ) stream = QtCore.QDataStream ( data, QtCore.QIODevice.ReadOnly ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : filename = QtCore.QString () stream >> filename else : @@ -793,7 +791,7 @@ def wheelEvent ( self, event ) : scale = -1.0 if 'linux' in sys.platform: scale = 1.0 import math - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : scaleFactor = math.pow( 2.0, scale * event.delta () / 600.0 ) else : delta = event.angleDelta () diff --git a/gfx/gfxLink.py b/gfx/gfxLink.py index 598da71..fb5ba80 100644 --- a/gfx/gfxLink.py +++ b/gfx/gfxLink.py @@ -8,7 +8,7 @@ from global_vars import DEBUG_MODE, GFX_LINK_TYPE from meShaderEd import app_settings -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -90,7 +90,7 @@ def remove ( self ) : scene = self.scene () if scene != None : if DEBUG_MODE : print ">> GfxLink::remove emit( onGfxLinkRemoved )" - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : scene.emit ( QtCore.SIGNAL ( 'onGfxLinkRemoved' ), self ) else : scene.onGfxLinkRemoved.emit ( self ) diff --git a/gfx/gfxNode.py b/gfx/gfxNode.py index b7d2496..5888eac 100644 --- a/gfx/gfxNode.py +++ b/gfx/gfxNode.py @@ -14,7 +14,7 @@ from meShaderEd import app_settings import gui.ui_settings as UI -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -35,7 +35,7 @@ def __init__ ( self, node ) : # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 50000 : + if QtCore.QT_VERSION >= 0x50000 : # pass #self.nodeUpdated = Signal () #QtCore.pyqtSignal ( QtModule.QGraphicsItem ) @@ -111,7 +111,7 @@ def __init__ ( self, node ) : # def connectSignals ( self ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.connect ( self.node, QtCore.SIGNAL ( 'nodeUpdated' ), self.onUpdateNode ) QtCore.QObject.connect ( self.node, QtCore.SIGNAL ( 'nodeParamsUpdated' ), self.onUpdateNodeParams ) else : @@ -122,7 +122,7 @@ def connectSignals ( self ) : # def disconnectSignals ( self ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.disconnect ( self.node, QtCore.SIGNAL ( 'nodeUpdated' ), self.onUpdateNode ) QtCore.QObject.disconnect ( self.node, QtCore.SIGNAL ( 'nodeParamsUpdated' ), self.onUpdateNodeParams ) else : @@ -153,7 +153,7 @@ def onUpdateNode ( self ) : # if DEBUG_MODE : print '>> GfxNode( %s ).updateNode' % ( self.node.label ) self.updateGfxNodeParams ( True ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.scene().emit ( QtCore.SIGNAL ( 'nodeUpdated' ), self ) else : self.scene().nodeUpdated.emit ( self ) @@ -164,7 +164,7 @@ def onUpdateNodeParams ( self, forceUpdate = False ) : # if DEBUG_MODE : print '>> GfxNode( %s ).onUpdateNodeParams' % ( self.node.label ) self.updateGfxNodeParams ( forceUpdate ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.scene().emit ( QtCore.SIGNAL ( 'gfxNodeParamChanged' ), self ) else : self.scene().gfxNodeParamChanged.emit ( self ) @@ -235,7 +235,7 @@ def remove ( self ) : self.disconnectSignals () for connect in self.inputConnectors : connect.removeAllLinks () for connect in self.outputConnectors : connect.removeAllLinks () - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.scene().emit ( QtCore.SIGNAL ( 'onGfxNodeRemoved' ), self ) else : self.scene().onGfxNodeRemoved.emit ( self ) @@ -454,7 +454,7 @@ def updateGfxNodeParamLabel ( self, param, label, forceUpdate = False ) : label.setProcessEvents ( True ) if forceUpdate : self.update () - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.scene().emit ( QtCore.SIGNAL ( 'gfxNodeParamChanged' ), self, param ) else : self.gfxNodeParamChanged.emit ( self, param ) @@ -556,7 +556,7 @@ def itemChange ( self, change, value ) : if change == QtModule.QGraphicsItem.ItemSelectedHasChanged : #ItemSelectedChange: QGraphicsItem if self.node.type != 'variable' : # variable node has not header - #if QtCore.QT_VERSION < 50000 : + #if QtCore.QT_VERSION < 0x50000 : # self.header [ 'label' ].setSelected ( value.toBool () ) #else : self.header [ 'label' ].setSelected ( value ) diff --git a/gfx/gfxNodeConnector.py b/gfx/gfxNodeConnector.py index 8842fc2..f637455 100644 --- a/gfx/gfxNodeConnector.py +++ b/gfx/gfxNodeConnector.py @@ -11,7 +11,7 @@ from global_vars import DEBUG_MODE, GFX_NODE_CONNECTOR_TYPE import gui.ui_settings as UI -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -402,7 +402,7 @@ def mousePressEvent ( self, event ) : if event.modifiers () == QtCore.Qt.ControlModifier : # start new ConnectorNode self.state = 'traceNodeConnector' - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.getScene ().emit ( QtCore.SIGNAL ( 'startNodeConnector' ), self, event.scenePos () ) else : self.getScene ().startNodeConnector.emit ( self, event.scenePos () ) @@ -410,7 +410,7 @@ def mousePressEvent ( self, event ) : if not self.isNode () : # start new link self.state = 'traceNodeLink' - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.getScene ().emit ( QtCore.SIGNAL ( 'startNodeLink' ), self ) else : #if DEBUG_MODE : print '* startNodeLink.emit ' @@ -427,12 +427,12 @@ def mousePressEvent ( self, event ) : def mouseMoveEvent ( self, event ) : #print ">> mouseMoveEvent at %d %d" % ( event.scenePos().x(), event.scenePos().y() ) if self.state == 'traceNodeLink' : - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.getScene ().emit ( QtCore.SIGNAL ( 'traceNodeLink' ), self, event.scenePos () ) else : self.getScene ().traceNodeLink.emit ( self, event.scenePos () ) elif self.state == 'traceNodeConnector' : - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.getScene ().emit ( QtCore.SIGNAL ( 'traceNodeConnector' ), self, event.scenePos () ) else : self.getScene ().traceNodeConnector.emit ( self, event.scenePos () ) @@ -446,12 +446,12 @@ def mouseMoveEvent ( self, event ) : def mouseReleaseEvent ( self, event ) : #print ">> mouseReleaseEvent" if self.state == 'traceNodeLink' : - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.getScene ().emit ( QtCore.SIGNAL ( 'endNodeLink' ), self, event.scenePos () ) else : self.getScene ().endNodeLink.emit ( self, event.scenePos () ) elif self.state == 'traceNodeConnector' : - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.getScene ().emit ( QtCore.SIGNAL ( 'endNodeConnector' ), self, event.scenePos () ) else : self.getScene ().endNodeConnector.emit ( self, event.scenePos () ) diff --git a/gfx/gfxNodeLabel.py b/gfx/gfxNodeLabel.py index 7e82b2c..2bf2c61 100644 --- a/gfx/gfxNodeLabel.py +++ b/gfx/gfxNodeLabel.py @@ -8,7 +8,7 @@ from global_vars import app_colors, DEBUG_MODE, GFX_NODE_LABEL_TYPE from meShaderEd import app_settings -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/gfx/gfxNote.py b/gfx/gfxNote.py index d606792..e1d4c17 100644 --- a/gfx/gfxNote.py +++ b/gfx/gfxNote.py @@ -10,7 +10,7 @@ from global_vars import DEBUG_MODE, GFX_NOTE_TYPE from meShaderEd import app_settings -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -90,7 +90,7 @@ def type ( self ) : return GfxNote.Type def remove ( self ) : # if DEBUG_MODE : print '>> GfxNote remove gfxNode (temp)' - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.scene().emit ( QtCore.SIGNAL ( 'onGfxNodeRemoved' ), self ) else : self.scene().onGfxNodeRemoved.emit ( self ) diff --git a/gfx/gfxSwatchNode.py b/gfx/gfxSwatchNode.py index 63fc6df..8a595b1 100644 --- a/gfx/gfxSwatchNode.py +++ b/gfx/gfxSwatchNode.py @@ -13,7 +13,7 @@ from meShaderEd import app_settings import gui.ui_settings as UI -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -85,7 +85,7 @@ def __init__ ( self, node = None, swatchSize = UI.SWATCH_SIZE ) : def connectSignals ( self ) : # if self.scene () is not None : - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'updateSwatch' ), self.updateSwatch ) else : self.scene ().updateSwatch.connect ( self.updateSwatch ) @@ -95,7 +95,7 @@ def connectSignals ( self ) : def disconnectSignals ( self ) : # if self.scene () is not None : - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.disconnect ( self.scene (), QtCore.SIGNAL ( 'updateSwatch' ), self.updateSwatch ) else : self.scene ().updateSwatch.disconnect ( self.updateSwatch ) @@ -110,7 +110,7 @@ def remove ( self ) : # if DEBUG_MODE : print '>> GfxSwatchNode.remove' for connect in self.inputConnectors : connect.removeAllLinks () - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.scene().emit ( QtCore.SIGNAL ( 'onGfxNodeRemoved' ), self ) else : self.scene().onGfxNodeRemoved.emit ( self ) diff --git a/gfx/imageView.py b/gfx/imageView.py index 9d5f1cb..5677e7f 100644 --- a/gfx/imageView.py +++ b/gfx/imageView.py @@ -6,7 +6,7 @@ from core.mePyQt import QtCore, QtGui from core.signal import Signal -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -25,7 +25,7 @@ def __init__ ( self, parent ) : # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 50000 : + if QtCore.QT_VERSION >= 0x50000 : # self.mouseDoubleClickSignal = Signal () @@ -70,7 +70,7 @@ def wheelEvent ( self, event ) : scale = -1.0 if 'linux' in sys.platform: scale = 1.0 import math - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : scaleFactor = math.pow( 2.0, scale * event.delta() / 600.0 ) else : delta = event.angleDelta () @@ -99,7 +99,7 @@ def mousePressEvent ( self, event ) : def mouseDoubleClickEvent ( self, event ) : # #print ">> ImageView.mouseDoubleClickEvent" - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( 'mouseDoubleClickSignal' ) ) else : self.mouseDoubleClickSignal.emit () diff --git a/global_vars.py b/global_vars.py index 9b5b8a6..ac11336 100644 --- a/global_vars.py +++ b/global_vars.py @@ -2,6 +2,13 @@ # global_vars.py # from core.mePyQt import QtCore, QtGui + +if QtCore.QT_VERSION < 0x50000 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + app_global_vars = { 'TempPath':'' ,'RootPath':'' @@ -45,21 +52,12 @@ DEBUG_MODE = True -if QtCore.QT_VERSION < 50000 : - GFX_NODE_TYPE = QtGui.QGraphicsItem.UserType + 1 - GFX_LINK_TYPE = QtGui.QGraphicsItem.UserType + 2 - GFX_NODE_LABEL_TYPE = QtGui.QGraphicsItem.UserType + 3 - GFX_NODE_CONNECTOR_TYPE = QtGui.QGraphicsItem.UserType + 4 - GFX_SWATCH_NODE_TYPE = QtGui.QGraphicsItem.UserType + 5 - GFX_NOTE_TYPE = QtGui.QGraphicsItem.UserType + 6 -else : - UserType = 65536 - GFX_NODE_TYPE = UserType + 1 - GFX_LINK_TYPE = UserType + 2 - GFX_NODE_LABEL_TYPE = UserType + 3 - GFX_NODE_CONNECTOR_TYPE = UserType + 4 - GFX_SWATCH_NODE_TYPE = UserType + 5 - GFX_NOTE_TYPE = UserType + 6 +GFX_NODE_TYPE = QtModule.QGraphicsItem.UserType + 1 +GFX_LINK_TYPE = QtModule.QGraphicsItem.UserType + 2 +GFX_NODE_LABEL_TYPE = QtModule.QGraphicsItem.UserType + 3 +GFX_NODE_CONNECTOR_TYPE = QtModule.QGraphicsItem.UserType + 4 +GFX_SWATCH_NODE_TYPE = QtModule.QGraphicsItem.UserType + 5 +GFX_NOTE_TYPE = QtModule.QGraphicsItem.UserType + 6 VALID_NODE_TYPES = [ 'rib', 'rib_code', diff --git a/gui/MainWindow.py b/gui/MainWindow.py index fd70f4f..df6d45f 100644 --- a/gui/MainWindow.py +++ b/gui/MainWindow.py @@ -31,12 +31,11 @@ from ui_MainWindow import Ui_MainWindow -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets QtModule = QtWidgets - # # Create a class for our main window # @@ -61,10 +60,13 @@ def __init__ ( self ) : self.clipboard = QtModule.QApplication.clipboard () - self.recentProjects = getSettingsStrValue ( app_settings, 'RecentProjects' ) - self.recentNetworks = getSettingsStrValue ( app_settings, 'RecentNetworks' ) - - self.addRecentProject ( app_global_vars [ 'ProjectPath' ] ) + if QtCore.QT_VERSION < 0x50000 : + self.recentProjects = app_settings.value ( 'RecentProjects' ).toStringList () + self.recentNetworks = app_settings.value ( 'RecentNetworks' ).toStringList () + self.addRecentProject ( app_global_vars [ 'ProjectPath' ] ) + else : + # should be fixed !!! + pass self.setupMenuBar () self.setupPanels () @@ -105,7 +107,7 @@ def __init__ ( self ) : # def connectSignals ( self ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.connect ( self.ui.actionHelpMode, QtCore.SIGNAL ( 'toggled(bool)' ), self.onHelpMode ) QtCore.QObject.connect ( self.ui.nodeList_ctl.ui.nodeList, QtCore.SIGNAL ( 'setActiveNodeList' ), self.setActiveNodeList ) QtCore.QObject.connect ( self.ui.project_ctl.ui.nodeList, QtCore.SIGNAL ( 'setActiveNodeList' ), self.setActiveNodeList ) @@ -132,7 +134,7 @@ def connectSignals ( self ) : # def connectWorkAreaSignals ( self ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : if self.workArea != None : if self.activeNodeList != None : QtCore.QObject.connect ( self.activeNodeList, QtCore.SIGNAL ( 'addNode' ), self.workArea.insertNodeNet ) @@ -159,7 +161,7 @@ def connectWorkAreaSignals ( self ) : # def disconnectWorkAreaSignals ( self ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : if self.workArea != None : if self.activeNodeList != None : QtCore.QObject.disconnect ( self.activeNodeList, QtCore.SIGNAL ( 'addNode' ), self.workArea.insertNodeNet ) @@ -217,11 +219,12 @@ def setupMenuBar ( self ) : # buildRecentProjectsMenu # def buildRecentProjectsMenu ( self ) : - #self.recentProjects = app_settings.value ( 'RecentProjects' ).toStringList () - #self.recentNetworks = app_settings.value ( 'RecentNetworks' ).toStringList () - self.ui.menuRecent_Projects.clear () - - if QtCore.QT_VERSION < 50000 : + # + if QtCore.QT_VERSION < 0x50000 : + self.recentProjects = app_settings.value ( 'RecentProjects' ).toStringList () + print '>> self.recentProjects:' + print self.recentProjects + self.ui.menuRecent_Projects.clear () if len ( self.recentProjects ) : icon = QtGui.QIcon.fromTheme ( 'folder', QtGui.QIcon ( ':/file_icons/resources/open.png' ) ) # QtGui.QIcon ( ':/file_icons/resources/recentFile.png' ) 'folder' @@ -231,14 +234,17 @@ def buildRecentProjectsMenu ( self ) : action.setData ( QtCore.QVariant ( fname ) ) self.connect ( action, QtCore.SIGNAL ( 'triggered()' ), self.onOpenRecentProject ) self.ui.menuRecent_Projects.addAction ( action ) + else : + # should be fixed !!! + pass # # buildRecentNetworksMenu # def buildRecentNetworksMenu ( self ) : # - self.ui.menuRecent_Networks.clear () - - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : + self.recentNetworks = app_settings.value ( 'RecentNetworks' ).toStringList () + self.ui.menuRecent_Networks.clear () if len ( self.recentNetworks ) : for i, fname in enumerate ( self.recentNetworks ) : icon = QtGui.QIcon.fromTheme ( 'document-new', QtGui.QIcon ( ':/file_icons/resources/new.png' ) ) @@ -247,6 +253,9 @@ def buildRecentNetworksMenu ( self ) : action.setData ( QtCore.QVariant ( fname ) ) self.connect ( action, QtCore.SIGNAL ( 'triggered()' ), self.onOpenRecentNetwork ) self.ui.menuRecent_Networks.addAction ( action ) + else : + # should be fixed !!! + pass # # setupPanels # @@ -275,7 +284,7 @@ def setupPanels ( self ) : def addRecentProject ( self, project ) : # if project is not None : - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : recent_projects_max = getDefaultValue ( app_settings, '', 'recent_projects_max' ) if project not in self.recentProjects : @@ -286,13 +295,16 @@ def addRecentProject ( self, project ) : recentProjects = QtCore.QVariant ( self.recentProjects ) if self.recentProjects else QtCore.QVariant () app_settings.setValue ( 'RecentProjects', recentProjects ) + else : + # should be fixed !!! + pass # # addRecentNetwork # def addRecentNetwork ( self, network ) : # if network is not None : - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : recent_networks_max = getDefaultValue ( app_settings, '', 'recent_networks_max' ) if network not in self.recentNetworks : @@ -303,6 +315,9 @@ def addRecentNetwork ( self, network ) : recentNetworks = QtCore.QVariant ( self.recentNetworks ) if self.recentNetworks else QtCore.QVariant () app_settings.setValue ( 'RecentNetworks', recentNetworks ) + else : + # should be fixed !!! + pass # # setupActions # @@ -375,7 +390,7 @@ def onRenderSettings ( self ) : self.RendererPreset = copy.deepcopy ( app_global_vars [ 'RendererPreset' ] ) if DEBUG_MODE : print ( ':: self.RendererPreset.getCurrentPresetName = %s' % self.RendererPreset.getCurrentPresetName () ) renderSettingsDlg = meRendererSetup ( self.RendererPreset ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.connect ( renderSettingsDlg, QtCore.SIGNAL ( 'presetChanged' ), self.onRenderPresetChanged ) QtCore.QObject.connect ( renderSettingsDlg, QtCore.SIGNAL ( 'savePreset' ), self.onRenderPresetSave ) else : @@ -457,7 +472,7 @@ def onStraightLinks ( self, check ) : def setActiveNodeList ( self, nodeList ) : # if DEBUG_MODE : print '>> MainWindow.setActiveNodeList' - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : if self.activeNodeList != None : QtCore.QObject.disconnect ( self.activeNodeList, QtCore.SIGNAL ( 'addNode' ), self.workArea.insertNodeNet ) self.activeNodeList = nodeList @@ -827,7 +842,7 @@ def onOpen ( self ) : # curDir = app_global_vars [ 'ProjectNetworks' ] typeFilter = 'Shader networks *.xml;;All files *.*;;' - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : filename = str ( QtGui.QFileDialog.getOpenFileName ( self, "Open file", curDir, typeFilter ) ) else : (filename, filter) = QtModule.QFileDialog.getOpenFileName ( self, "Open file", curDir, typeFilter ) @@ -906,7 +921,7 @@ def onImport ( self ) : curDir = app_global_vars [ 'ProjectNetworks' ] typeFilter = 'Shader networks *.xml;;All files *.*;;' - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : filename = str ( QtModule.QFileDialog.getOpenFileName ( self, "Import file", curDir, typeFilter ) ) else : (filename, filter) = QtModule.QFileDialog.getOpenFileName ( self, "Import file", curDir, typeFilter ) @@ -925,7 +940,7 @@ def onSaveSelected ( self ) : saveName = os.path.join ( curDir, self.workArea.nodeNet.name + '.xml' ) typeFilter = 'Shader networks *.xml;;All files *.*;;' - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : filename = str( QtModule.QFileDialog.getSaveFileName ( self, "Save file as", saveName, typeFilter ) ) else : (filename, filter) = QtModule.QFileDialog.getSaveFileName ( self, "Save file as", saveName, typeFilter ) @@ -971,7 +986,7 @@ def onSaveAs ( self ) : curDir = app_global_vars [ 'ProjectNetworks' ] saveName = os.path.join ( curDir, self.workArea.nodeNet.name + '.xml' ) typeFilter = 'Shader networks *.xml;;All files *.*;;' - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : filename = str( QtModule.QFileDialog.getSaveFileName ( self, "Save file as", saveName, typeFilter ) ) else : (filename, filter) = QtModule.QFileDialog.getSaveFileName ( self, "Save file as", saveName, typeFilter ) diff --git a/gui/ProjectSetup.py b/gui/ProjectSetup.py index fe506db..3ca023d 100644 --- a/gui/ProjectSetup.py +++ b/gui/ProjectSetup.py @@ -15,7 +15,7 @@ from ui_projectSetup import Ui_ProjectSetup -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -51,7 +51,7 @@ def buildGui ( self ): self.ui.lineEdit_project.setText ( self.rootDir ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.ui.lineEdit_network.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'shader_networks' ).toString () ) ) ) self.ui.lineEdit_sources.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'shader_sources' ).toString () ) ) ) self.ui.lineEdit_shaders.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'project_shaders' ).toString () ) ) ) diff --git a/gui/SettingsSetup.py b/gui/SettingsSetup.py index 8c4e6f4..1f9007c 100644 --- a/gui/SettingsSetup.py +++ b/gui/SettingsSetup.py @@ -15,7 +15,7 @@ from ui_settingsSetup import Ui_SettingsSetup -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -49,7 +49,7 @@ def buildGui ( self ): ##else : ## font.setPointSize(10) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.ui.lineEdit_temp.setText( self.app_settings.value('temp').toString() ) self.ui.lineEdit_inc.setText( self.app_settings.value('include').toString() ) self.ui.lineEdit_lib.setText( self.app_settings.value('lib').toString() ) diff --git a/gui/ViewComputedCodeDialog.py b/gui/ViewComputedCodeDialog.py index 1fcb2ce..bf2bc93 100644 --- a/gui/ViewComputedCodeDialog.py +++ b/gui/ViewComputedCodeDialog.py @@ -15,7 +15,7 @@ from nodeEditor.nodeCodeEditor import NodeCodeEditor from ui_viewComputedCodeDialog import Ui_ViewComputedCodeDialog -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/gui/exportShader/ExportShaderDialog.py b/gui/exportShader/ExportShaderDialog.py index a58777e..9d66bb6 100644 --- a/gui/exportShader/ExportShaderDialog.py +++ b/gui/exportShader/ExportShaderDialog.py @@ -21,7 +21,7 @@ from ui_exportShaderDialog import Ui_ExportShaderDialog -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -57,7 +57,7 @@ def __init__ ( self, node ) : # def connectSignals ( self ) : # QtCore.QObject - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.connect ( self.ui.list_nodes, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onNodeChanged ) QtCore.QObject.connect ( self.ui.list_inputs, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onInputParamChanged ) QtCore.QObject.connect ( self.ui.list_outputs, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onOutputParamChanged ) @@ -84,7 +84,7 @@ def connectSignals ( self ) : # def disconnectSignals ( self ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.disconnect ( self.ui.list_nodes, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onNodeChanged ) QtCore.QObject.disconnect ( self.ui.list_inputs, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onInputParamChanged ) QtCore.QObject.disconnect ( self.ui.list_outputs, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onOutputParamChanged ) @@ -197,7 +197,7 @@ def onNodeChanged ( self ) : if DEBUG_MODE : print '>> ExportShaderDialog.onNodeChanged' self.disconnectSignals () item = self.ui.list_nodes.currentItem () - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : node = item.data ( QtCore.Qt.UserRole + 1 ).toPyObject () else : node = item.data ( QtCore.Qt.UserRole + 1 ) @@ -244,7 +244,7 @@ def onInputParamChanged ( self ) : # if DEBUG_MODE : print '>> ExportShaderDialog.onInputParamChanged' item = self.ui.list_inputs.currentItem () - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : param = item.data ( QtCore.Qt.UserRole + 1 ).toPyObject () node = item.data ( QtCore.Qt.UserRole + 2 ).toPyObject () else : @@ -261,7 +261,7 @@ def onOutputParamChanged ( self ) : # if DEBUG_MODE : print '>> ExportShaderDialog.onOutputParamChanged' item = self.ui.list_outputs.currentItem () - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : param = item.data ( QtCore.Qt.UserRole + 1 ).toPyObject () node = item.data ( QtCore.Qt.UserRole + 2 ).toPyObject () else : @@ -288,7 +288,7 @@ def onRenameNodeLabel ( self, oldName, newName ) : editNode = self.ui.node.editNode for i in range ( self.ui.list_nodes.count () ) : item = self.ui.list_nodes.item ( i ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : node = item.data ( QtCore.Qt.UserRole + 1 ).toPyObject () else : node = item.data ( QtCore.Qt.UserRole + 1 ) @@ -321,7 +321,7 @@ def onExport ( self ) : import os saveName = os.path.join ( app_global_vars [ 'ProjectSources' ], self.editNode.getInstanceName () + '.sl' ) typeFilter = 'Shader source files *.sl;;All files *.*;;' - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : filename = str( QtModule.QFileDialog.getSaveFileName ( self, "Export shader code as", saveName, typeFilter ) ) else : ( filename, filter ) = QtModule.QFileDialog.getSaveFileName ( self, "Export shader code as", saveName, typeFilter ) diff --git a/gui/exportShader/ui_exportShaderDialog.py b/gui/exportShader/ui_exportShaderDialog.py index 9967752..c7d6d64 100644 --- a/gui/exportShader/ui_exportShaderDialog.py +++ b/gui/exportShader/ui_exportShaderDialog.py @@ -10,7 +10,7 @@ from core.mePyQt import QtCore, QtGui from core.signal import Signal -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -65,7 +65,7 @@ def setupUi(self, ExportShaderDialog): self.tab = QtModule.QWidget() self.tab.setObjectName(_fromUtf8("tab")) self.gridLayout = QtModule.QGridLayout(self.tab) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.gridLayout.setMargin(2) self.gridLayout.setSpacing(2) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) @@ -80,7 +80,7 @@ def setupUi(self, ExportShaderDialog): self.tab_inputs.setObjectName(_fromUtf8("tab_inputs")) self.gridLayout_2 = QtModule.QGridLayout(self.tab_inputs) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.gridLayout_2.setMargin(2) self.gridLayout_2.setSpacing(2) self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) @@ -91,7 +91,7 @@ def setupUi(self, ExportShaderDialog): self.tab_outputs = QtModule.QWidget() self.tab_outputs.setObjectName(_fromUtf8("tab_outputs")) self.gridLayout_3 = QtModule.QGridLayout(self.tab_outputs) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.gridLayout_3.setMargin(2) self.gridLayout_3.setSpacing(2) self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3")) @@ -104,7 +104,7 @@ def setupUi(self, ExportShaderDialog): self.tab_prop_node = QtModule.QWidget() self.tab_prop_node.setObjectName(_fromUtf8("tab_prop_node")) self.gridLayout_4 = QtModule.QGridLayout(self.tab_prop_node) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.gridLayout_4.setMargin(2) self.gridLayout_4.setSpacing(2) self.gridLayout_4.setObjectName(_fromUtf8("gridLayout_4")) @@ -115,7 +115,7 @@ def setupUi(self, ExportShaderDialog): self.tab_prop_param = QtModule.QWidget() self.tab_prop_param.setObjectName(_fromUtf8("tab_prop_param")) self.gridLayout_5 = QtModule.QGridLayout(self.tab_prop_param) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.gridLayout_5.setMargin(2) self.gridLayout_5.setSpacing(2) self.gridLayout_5.setObjectName(_fromUtf8("gridLayout_5")) @@ -131,7 +131,7 @@ def setupUi(self, ExportShaderDialog): self.node_tabWidget.setCurrentIndex(0) self.params_tabWidget.setCurrentIndex(0) self.prop_tabWidget.setCurrentIndex(0) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.connect(self.btn_export, QtCore.SIGNAL(_fromUtf8("clicked()")), ExportShaderDialog.onExport) QtCore.QObject.connect(self.btn_close, QtCore.SIGNAL(_fromUtf8("clicked()")), ExportShaderDialog.reject) QtCore.QObject.connect(self.btn_view, QtCore.SIGNAL(_fromUtf8("clicked()")), ExportShaderDialog.onViewCode) diff --git a/gui/imageViewWidget.py b/gui/imageViewWidget.py index 5e3db95..1faa592 100644 --- a/gui/imageViewWidget.py +++ b/gui/imageViewWidget.py @@ -16,7 +16,7 @@ from core.node import Node from core.nodeLibrary import NodeLibrary -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -44,7 +44,7 @@ def __init__ ( self ) : #self.ui.treeView.setDragEnabled ( True ) #self.ui.treeView.setRootIsDecorated( True ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.connect ( self.ui.imageArea, QtCore.SIGNAL ( 'mouseDoubleClickSignal' ), self.updateViewer ) QtCore.QObject.connect ( self.ui.selector, QtCore.SIGNAL ( 'currentIndexChanged(int)' ), self.onViewerChanged ) else : diff --git a/gui/meRendererSetup.py b/gui/meRendererSetup.py index 1487c51..bf0723d 100644 --- a/gui/meRendererSetup.py +++ b/gui/meRendererSetup.py @@ -17,7 +17,7 @@ from ui_meRendererSetup import Ui_meRendererSetup -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -30,7 +30,7 @@ class meRendererSetup ( QtModule.QDialog ) : # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 50000 : + if QtCore.QT_VERSION >= 0x50000 : presetChanged = QtCore.pyqtSignal () savePreset = QtCore.pyqtSignal () # @@ -217,7 +217,7 @@ def onEditLabel ( self ) : def onSave ( self ) : # get data from Gui for current renderer before saving self.getDataFromGui () - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( 'presetChanged' ) ) self.emit ( QtCore.SIGNAL ( 'savePreset' ) ) else : @@ -230,7 +230,7 @@ def onSave ( self ) : def onSelect ( self ) : # get data from Gui for current renderer before saving self.getDataFromGui () - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit( QtCore.SIGNAL ( 'presetChanged' ) ) else : self.presetChanged.emit () diff --git a/gui/nodeEditor/NodeEditorDialog.py b/gui/nodeEditor/NodeEditorDialog.py index ffbd318..5491a6c 100644 --- a/gui/nodeEditor/NodeEditorDialog.py +++ b/gui/nodeEditor/NodeEditorDialog.py @@ -37,7 +37,7 @@ TAB_PARAM = 5 TAB_LINK_INFO = 6 -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -76,7 +76,7 @@ def __init__ ( self, node = None ): # def connectSignals ( self ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.connect ( self.ui.input_list, QtCore.SIGNAL ( 'selectionChangedSignal' ), self.updateGui ) # onInputParamSelectionChanged ) QtCore.QObject.connect ( self.ui.output_list, QtCore.SIGNAL ( 'selectionChangedSignal' ), self.updateGui ) # onOutputParamSelectionChanged ) @@ -164,7 +164,7 @@ def connectSignals ( self ) : # def disconnectSignals ( self ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.disconnect ( self.ui.input_list, QtCore.SIGNAL ( 'selectionChangedSignal' ), self.updateGui ) # onInputParamSelectionChanged ) QtCore.QObject.disconnect ( self.ui.output_list, QtCore.SIGNAL ( 'selectionChangedSignal' ), self.updateGui ) # onOutputParamSelectionChanged ) @@ -396,7 +396,7 @@ def updateGui ( self, foo_param = None ) : inputLinkSelected = True links_item = self.ui.input_links_listWidget.currentItem () if links_item is not None : - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : ( link_id, ok ) = links_item.data ( QtCore.Qt.UserRole ).toInt () else : link_id = links_item.data ( QtCore.Qt.UserRole ) @@ -405,7 +405,7 @@ def updateGui ( self, foo_param = None ) : # output links links_item = self.ui.output_links_listWidget.currentItem () if links_item is not None : - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : ( link_id, ok ) = links_item.data ( QtCore.Qt.UserRole ).toInt () else: link_id = links_item.data ( QtCore.Qt.UserRole ) @@ -659,7 +659,7 @@ def onAddParam ( self, newName ) : typeDialog.btnBox.setCenterButtons ( True ) typeDialog.verticalLayout.addWidget ( typeDialog.btnBox ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.connect ( typeDialog.btnBox, QtCore.SIGNAL ( 'accepted()' ), typeDialog.accept ) QtCore.QObject.connect ( typeDialog.btnBox, QtCore.SIGNAL ( 'rejected()' ), typeDialog.reject ) else : diff --git a/gui/nodeEditor/codeSyntaxHighlighter.py b/gui/nodeEditor/codeSyntaxHighlighter.py index 97ea008..3270530 100644 --- a/gui/nodeEditor/codeSyntaxHighlighter.py +++ b/gui/nodeEditor/codeSyntaxHighlighter.py @@ -16,7 +16,7 @@ import gui.ui_settings as UI -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -116,7 +116,7 @@ def highlightBlock ( self, text ): commentLength = 0 if endIndex == -1: self.setCurrentBlockState ( 1 ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : commentLength = text.length () - startIndex else : commentLength = len ( text ) - startIndex diff --git a/gui/nodeEditor/nodeCodeEditor.py b/gui/nodeEditor/nodeCodeEditor.py index f154372..b33ae2e 100644 --- a/gui/nodeEditor/nodeCodeEditor.py +++ b/gui/nodeEditor/nodeCodeEditor.py @@ -18,7 +18,7 @@ from ui_nodeCodeEditor import Ui_NodeCodeEditor -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/gui/nodeEditor/nodeLinkEditor.py b/gui/nodeEditor/nodeLinkEditor.py index d08c6d6..1910be6 100644 --- a/gui/nodeEditor/nodeLinkEditor.py +++ b/gui/nodeEditor/nodeLinkEditor.py @@ -19,7 +19,7 @@ from ui_nodeLinkEditor import Ui_NodeLinkEditor -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/gui/nodeEditor/nodeNamesEditor.py b/gui/nodeEditor/nodeNamesEditor.py index e945208..d6c83c1 100644 --- a/gui/nodeEditor/nodeNamesEditor.py +++ b/gui/nodeEditor/nodeNamesEditor.py @@ -16,7 +16,7 @@ from ui_nodeNamesEditor import Ui_NodeNamesEditor -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -35,7 +35,7 @@ def __init__ ( self, parent ) : # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 50000 : + if QtCore.QT_VERSION >= 0x50000 : # self.selectionChangedSignal = Signal () self.addItem = Signal () @@ -71,7 +71,7 @@ def onAddItem ( self ) : if DEBUG_MODE : print '>> NodeNamesEditor: onAddItem' new_text = str ( self.ui.name_lineEdit.text () ).strip () if new_text != '' : - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( 'addItem' ), new_text ) else : self.addItem.emit ( new_text ) @@ -87,7 +87,7 @@ def onRemoveItem ( self ) : item_text = str ( list_item.text () ) #self.ui.listWidget.takeItem ( self.ui.listWidget.currentRow () ) #self.ui.listWidget.removeItemWidget ( list_item ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( 'removeItem' ), item_text ) else : self.removeItem.emit ( item_text ) @@ -109,7 +109,7 @@ def onRenameItem ( self ) : if list_item is not None : # e.g. listWidget is not empty old_text = list_item.text () if new_text != old_text : - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL( 'renameItem' ), old_text, new_text ) else : self.renameItem.emit ( old_text, new_text ) @@ -127,7 +127,7 @@ def onSelectionChanged ( self ) : if list_item is not None : self.saved_text = str ( list_item.text() ) self.ui.name_lineEdit.setText ( self.saved_text ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( 'selectionChangedSignal' ), self.saved_text ) else : self.selectionChangedSignal.emit ( self.saved_text ) diff --git a/gui/nodeEditor/nodeParamEditor.py b/gui/nodeEditor/nodeParamEditor.py index 269c46f..86a7059 100644 --- a/gui/nodeEditor/nodeParamEditor.py +++ b/gui/nodeEditor/nodeParamEditor.py @@ -29,7 +29,7 @@ from ui_nodeParamEditor import Ui_NodeParamEditor -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -47,7 +47,7 @@ def __init__ ( self, parent ) : # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 50000 : + if QtCore.QT_VERSION >= 0x50000 : # self.changeParamName = Signal () self.changeParamLabel = Signal () @@ -142,7 +142,7 @@ def onParamDefValueChanged ( self, param ) : # if DEBUG_MODE : print '* onParamDefValueChanged' self.param.default = self.param_default.value - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( 'changeParamDefValue' ), self.param ) else : self.changeParamDefValue.emit ( self.param ) @@ -153,7 +153,7 @@ def onParamValueChanged ( self, param ) : # if DEBUG_MODE : print '* onParamValueChanged' self.param.value = param.value - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( 'changeParamValue' ), self.param ) else : self.changeParamValue.emit ( self.param ) @@ -162,7 +162,7 @@ def onParamValueChanged ( self, param ) : # def connectSignals ( self ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.connect ( self.param_default, QtCore.SIGNAL ( 'paramChangedSignal(QObject)' ), self.onParamDefValueChanged ) self.connect ( self.param, QtCore.SIGNAL ( 'paramChangedSignal(QObject)' ), self.onParamValueChanged ) @@ -197,7 +197,7 @@ def connectSignals ( self ) : # def disconnectSignals ( self ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : if self.param_default is not None : self.disconnect ( self.param_default, QtCore.SIGNAL ( 'paramChangedSignal(QObject)' ), self.onParamDefValueChanged ) if self.param is not None : @@ -352,7 +352,7 @@ def onEditParamName ( self ) : self.ui.name_lineEdit.setText ( newName ) if newName != oldName : self.param.name = newName - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit( QtCore.SIGNAL ( 'changeParamName' ), oldName, newName ) else : self.changeParamName.emit ( oldName, newName ) @@ -368,7 +368,7 @@ def onEditParamLabel ( self ) : self.ui.label_lineEdit.setText ( newName ) if newName != oldName : self.param.label = newName - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( 'changeParamLabel' ), oldName, newName ) else : self.changeParamLabel.emit ( oldName, newName ) @@ -390,7 +390,7 @@ def onEditParamDisplay ( self, value ) : def onEditParamShader ( self, value ) : # self.param.shaderParam = self.ui.check_shader.isChecked () - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( 'changeParamIsShader' ), self.param ) else : self.changeParamIsShader.emit ( self.param ) @@ -402,7 +402,7 @@ def onEditParamType ( self, idx ) : # !!! UI for param.value and param.default also should be changed # self.param.type = str ( self.ui.type_comboBox.itemText ( idx ) ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( 'changeParamType' ), self.param ) else : self.changeParamType.emit ( self.param ) @@ -412,7 +412,7 @@ def onEditParamType ( self, idx ) : def onEditParamDetail ( self, idx ) : # self.param.detail = str ( self.ui.detail_comboBox.itemText ( idx ) ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( 'changeParamDetail' ), self.param ) else : self.changeParamDetail.emit ( self.param ) @@ -422,7 +422,7 @@ def onEditParamDetail ( self, idx ) : def onEditParamProvider ( self, idx ) : # self.param.provider = str ( self.ui.provider_comboBox.itemText ( idx ) ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( 'changeParamProvider' ), self.param ) else : self.changeParamProvider.emit ( self.param ) @@ -432,7 +432,7 @@ def onEditParamProvider ( self, idx ) : def onEditParamSubtype ( self, idx ) : # self.param.subtype = str ( self.ui.subtype_comboBox.itemText ( idx ) ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( 'changeParamSubtype' ), self.param ) else : self.changeParamSubtype.emit ( self.param ) @@ -442,7 +442,7 @@ def onEditParamSubtype ( self, idx ) : def onEditParamRange ( self ) : # self.param.range = str ( self.ui.range_lineEdit.text () ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( 'changeParamRange' ), self.param ) else : self.changeParamRange.emit ( self.param ) diff --git a/gui/nodeEditor/nodePropertiesEditor.py b/gui/nodeEditor/nodePropertiesEditor.py index 026dd1b..ad70b7b 100644 --- a/gui/nodeEditor/nodePropertiesEditor.py +++ b/gui/nodeEditor/nodePropertiesEditor.py @@ -20,7 +20,7 @@ from ui_nodePropertiesEditor import Ui_NodePropertiesEditor -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -39,7 +39,7 @@ def __init__ ( self, parent, editNode = None ) : # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 50000 : + if QtCore.QT_VERSION >= 0x50000 : # self.changeNodeLabel = Signal () # @@ -122,7 +122,7 @@ def setNode ( self, editNode ) : # def connectSignals ( self ) : # QtCore.QObject. - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.connect ( self.ui.name_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrName ) self.connect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) self.connect ( self.ui.master_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrMaster ) @@ -143,7 +143,7 @@ def connectSignals ( self ) : # def disconnectSignals ( self ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : if self.editNode is not None : self.disconnect ( self.ui.name_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrName ) self.disconnect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) @@ -187,19 +187,19 @@ def onEditNodeStrAttrLabel ( self ) : oldLabel = self.editNode.label newLabel = str ( self.ui.label_lineEdit.text () ).strip () if newLabel == '' : - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.disconnect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) else : self.ui.label_lineEdit.editingFinished.disconnect ( self.onEditNodeStrAttrLabel ) newLabel = oldLabel self.ui.label_lineEdit.setText ( newLabel ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.connect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) else : self.ui.label_lineEdit.editingFinished.connect ( self.onEditNodeStrAttrLabel ) if newLabel != oldLabel : self.editNode.label = newLabel - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( 'changeNodeLabel' ), oldLabel, newLabel ) else : self.changeNodeLabel.emit ( oldLabel, newLabel ) diff --git a/gui/nodeEditor/ui_nodeCodeEditor.py b/gui/nodeEditor/ui_nodeCodeEditor.py index 4705e13..b1c5e95 100644 --- a/gui/nodeEditor/ui_nodeCodeEditor.py +++ b/gui/nodeEditor/ui_nodeCodeEditor.py @@ -9,7 +9,7 @@ from core.mePyQt import QtCore, QtGui -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -34,7 +34,7 @@ def setupUi(self, NodeCodeEditor): NodeCodeEditor.setObjectName(_fromUtf8("NodeCodeEditor")) NodeCodeEditor.resize(683, 838) self.gridLayout = QtModule.QGridLayout(NodeCodeEditor) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.gridLayout.setMargin(0) self.gridLayout.setSpacing(0) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) diff --git a/gui/nodeEditor/ui_nodeEditorDialog.py b/gui/nodeEditor/ui_nodeEditorDialog.py index 5dc95d8..7225d59 100644 --- a/gui/nodeEditor/ui_nodeEditorDialog.py +++ b/gui/nodeEditor/ui_nodeEditorDialog.py @@ -9,7 +9,7 @@ from core.mePyQt import QtCore, QtGui -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -55,7 +55,7 @@ def setupUi(self, NodeEditorDialog): self.internals.setObjectName(_fromUtf8("internals")) self.verticalLayout_3 = QtModule.QVBoxLayout(self.internals) self.verticalLayout_3.setSpacing(0) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.verticalLayout_3.setMargin(0) self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3")) self.tabs_code_list = QtModule.QTabWidget(self.internals) @@ -63,7 +63,7 @@ def setupUi(self, NodeEditorDialog): self.internals_tab = QtModule.QWidget() self.internals_tab.setObjectName(_fromUtf8("internals_tab")) self.gridLayout_4 = QtModule.QGridLayout(self.internals_tab) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.gridLayout_4.setMargin(2) self.gridLayout_4.setSpacing(0) self.gridLayout_4.setObjectName(_fromUtf8("gridLayout_4")) @@ -74,7 +74,7 @@ def setupUi(self, NodeEditorDialog): self.includes_tab = QtModule.QWidget() self.includes_tab.setObjectName(_fromUtf8("includes_tab")) self.gridLayout_5 = QtModule.QGridLayout(self.includes_tab) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.gridLayout_5.setMargin(2) self.gridLayout_5.setSpacing(0) self.gridLayout_5.setObjectName(_fromUtf8("gridLayout_5")) @@ -89,7 +89,7 @@ def setupUi(self, NodeEditorDialog): self.parameters.setObjectName(_fromUtf8("parameters")) self.verticalLayout_8 = QtModule.QVBoxLayout(self.parameters) self.verticalLayout_8.setSpacing(0) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.verticalLayout_8.setMargin(0) self.verticalLayout_8.setObjectName(_fromUtf8("verticalLayout_8")) self.tabs_param_list = QtModule.QTabWidget(self.parameters) @@ -97,7 +97,7 @@ def setupUi(self, NodeEditorDialog): self.inputs_tab = QtModule.QWidget() self.inputs_tab.setObjectName(_fromUtf8("inputs_tab")) self.gridLayout_2 = QtModule.QGridLayout(self.inputs_tab) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.gridLayout_2.setMargin(2) self.gridLayout_2.setSpacing(0) self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) @@ -108,7 +108,7 @@ def setupUi(self, NodeEditorDialog): self.outputs_tab = QtModule.QWidget() self.outputs_tab.setObjectName(_fromUtf8("outputs_tab")) self.gridLayout_3 = QtModule.QGridLayout(self.outputs_tab) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.gridLayout_3.setMargin(2) self.gridLayout_3.setSpacing(0) self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3")) @@ -123,7 +123,7 @@ def setupUi(self, NodeEditorDialog): self.handlers.setObjectName(_fromUtf8("handlers")) self.verticalLayout_2 = QtModule.QVBoxLayout(self.handlers) self.verticalLayout_2.setSpacing(0) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.verticalLayout_2.setMargin(0) self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) self.handlers_list = NodeNamesEditor(self.handlers) @@ -135,7 +135,7 @@ def setupUi(self, NodeEditorDialog): self.links.setObjectName(_fromUtf8("links")) self.verticalLayout_81 = QtModule.QVBoxLayout(self.links) self.verticalLayout_81.setSpacing(0) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.verticalLayout_81.setMargin(0) self.verticalLayout_81.setObjectName(_fromUtf8("verticalLayout_81")) self.tabs_links_list = QtModule.QTabWidget(self.links) @@ -143,7 +143,7 @@ def setupUi(self, NodeEditorDialog): self.input_links_tab = QtModule.QWidget() self.input_links_tab.setObjectName(_fromUtf8("input_links_tab")) self.gridLayout_6 = QtModule.QGridLayout(self.input_links_tab) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.gridLayout_6.setMargin(2) self.gridLayout_6.setSpacing(0) self.gridLayout_6.setObjectName(_fromUtf8("gridLayout_6")) @@ -154,7 +154,7 @@ def setupUi(self, NodeEditorDialog): self.output_links_tab = QtModule.QWidget() self.output_links_tab.setObjectName(_fromUtf8("output_links_tab")) self.gridLayout_66 = QtModule.QGridLayout(self.output_links_tab) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.gridLayout_66.setMargin(2) self.gridLayout_66.setSpacing(0) self.gridLayout_66.setObjectName(_fromUtf8("gridLayout_66")) @@ -177,7 +177,7 @@ def setupUi(self, NodeEditorDialog): self.node_code_tab = QtModule.QWidget() self.node_code_tab.setObjectName(_fromUtf8("node_code_tab")) self.gridLayout = QtModule.QGridLayout(self.node_code_tab) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.gridLayout.setMargin(2) self.gridLayout.setSpacing(2) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) @@ -188,7 +188,7 @@ def setupUi(self, NodeEditorDialog): self.control_code_tab = QtModule.QWidget() self.control_code_tab.setObjectName(_fromUtf8("control_code_tab")) self.gridLayout_7 = QtModule.QGridLayout(self.control_code_tab) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.gridLayout_7.setMargin(2) self.gridLayout_7.setSpacing(2) self.gridLayout_7.setObjectName(_fromUtf8("gridLayout_7")) @@ -199,7 +199,7 @@ def setupUi(self, NodeEditorDialog): self.event_code_tab = QtModule.QWidget() self.event_code_tab.setObjectName(_fromUtf8("event_code_tab")) self.gridLayout_8 = QtModule.QGridLayout(self.event_code_tab) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.gridLayout_8.setMargin(2) self.gridLayout_8.setSpacing(2) self.gridLayout_8.setObjectName(_fromUtf8("gridLayout_8")) @@ -210,7 +210,7 @@ def setupUi(self, NodeEditorDialog): self.param_code_tab = QtModule.QWidget() self.param_code_tab.setObjectName(_fromUtf8("param_code_tab")) self.gridLayout_9 = QtModule.QGridLayout(self.param_code_tab) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.gridLayout_9.setMargin(2) self.gridLayout_9.setSpacing(2) self.gridLayout_9.setObjectName(_fromUtf8("gridLayout_9")) @@ -255,7 +255,7 @@ def setupUi(self, NodeEditorDialog): self.tabs_param_list.setCurrentIndex(0) self.tabs_links_list.setCurrentIndex(0) self.tabWidget.setCurrentIndex(0) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.connect(self.toolBox, QtCore.SIGNAL(_fromUtf8("currentChanged(int)")), NodeEditorDialog.onToolBoxIndexChanged) QtCore.QObject.connect(self.btn_save, QtCore.SIGNAL(_fromUtf8("clicked()")), NodeEditorDialog.accept) QtCore.QObject.connect(self.btn_close, QtCore.SIGNAL(_fromUtf8("clicked()")), NodeEditorDialog.reject) diff --git a/gui/nodeEditor/ui_nodeLinkEditor.py b/gui/nodeEditor/ui_nodeLinkEditor.py index 10619cd..9a0a7fa 100644 --- a/gui/nodeEditor/ui_nodeLinkEditor.py +++ b/gui/nodeEditor/ui_nodeLinkEditor.py @@ -9,7 +9,7 @@ from core.mePyQt import QtCore, QtGui -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/gui/nodeEditor/ui_nodeNamesEditor.py b/gui/nodeEditor/ui_nodeNamesEditor.py index 57dae9f..2b20285 100644 --- a/gui/nodeEditor/ui_nodeNamesEditor.py +++ b/gui/nodeEditor/ui_nodeNamesEditor.py @@ -9,7 +9,7 @@ from core.mePyQt import QtCore, QtGui -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -26,7 +26,7 @@ def setupUi(self, NodeNamesEditor): NodeNamesEditor.resize(417, 393) self.verticalLayout = QtModule.QVBoxLayout(NodeNamesEditor) self.verticalLayout.setSpacing(0) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.verticalLayout.setMargin(0) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.horizontalLayout = QtModule.QHBoxLayout() @@ -64,7 +64,7 @@ def setupUi(self, NodeNamesEditor): self.verticalLayout.addWidget(self.listWidget) self.retranslateUi(NodeNamesEditor) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.connect(self.addButton, QtCore.SIGNAL(_fromUtf8("clicked()")), NodeNamesEditor.onAddItem) QtCore.QObject.connect(self.removeButton, QtCore.SIGNAL(_fromUtf8("clicked()")), NodeNamesEditor.onRemoveItem) QtCore.QObject.connect(self.listWidget, QtCore.SIGNAL(_fromUtf8("itemSelectionChanged()")), NodeNamesEditor.onSelectionChanged) diff --git a/gui/nodeEditor/ui_nodeParamEditor.py b/gui/nodeEditor/ui_nodeParamEditor.py index d057640..4c5d0f1 100644 --- a/gui/nodeEditor/ui_nodeParamEditor.py +++ b/gui/nodeEditor/ui_nodeParamEditor.py @@ -9,7 +9,7 @@ from core.mePyQt import QtCore, QtGui -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/gui/nodeEditor/ui_nodePropertiesEditor.py b/gui/nodeEditor/ui_nodePropertiesEditor.py index 1133208..ee051ac 100644 --- a/gui/nodeEditor/ui_nodePropertiesEditor.py +++ b/gui/nodeEditor/ui_nodePropertiesEditor.py @@ -9,7 +9,7 @@ from core.mePyQt import QtCore, QtGui -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/gui/nodeLibraryView.py b/gui/nodeLibraryView.py index 6dfdf0c..685a741 100644 --- a/gui/nodeLibraryView.py +++ b/gui/nodeLibraryView.py @@ -18,7 +18,7 @@ from core.node import Node from core.nodeLibrary import NodeLibrary -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/gui/nodeList.py b/gui/nodeList.py index b7a5793..dcb264a 100644 --- a/gui/nodeList.py +++ b/gui/nodeList.py @@ -15,7 +15,7 @@ from core.node import Node from core.nodeLibrary import NodeLibrary -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -28,7 +28,7 @@ class NodeList ( QtModule.QWidget ) : # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 50000 : + if QtCore.QT_VERSION >= 0x50000 : setActiveNodeList = QtCore.pyqtSignal ( [QtModule.QWidget] ) addNode = QtCore.pyqtSignal ( [str] ) # @@ -52,7 +52,7 @@ def __init__ ( self, parent ) : # def connectSignals ( self ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.connect ( self.ui.treeView, QtCore.SIGNAL ( "pressed(QModelIndex)" ), self.clicked ) QtCore.QObject.connect ( self.ui.treeView, QtCore.SIGNAL ( "doubleClicked(QModelIndex)" ), self.doubleClicked ) else : @@ -98,7 +98,7 @@ def clicked ( self, index ) : # send signal to MainWindow to help distinguish which nodeList # is active for addNode getNode events # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( "setActiveNodeList" ), self ) else : self.setActiveNodeList.emit ( self ) @@ -111,7 +111,7 @@ def doubleClicked ( self, index ) : nodeKind = item.whatsThis () if nodeKind != 'folder' : - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : nodeFilename = item.data ( QtCore.Qt.UserRole + 4 ).toString () self.emit ( QtCore.SIGNAL ( 'addNode' ), nodeFilename ) else : @@ -126,7 +126,7 @@ def showDescription ( self, item ) : nodeName = item.text () nodeKind = item.whatsThis () - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : nodeAuthor = item.data ( QtCore.Qt.UserRole + 1 ).toString () nodeType = item.data ( QtCore.Qt.UserRole + 2 ).toString () nodeHelp = item.data ( QtCore.Qt.UserRole + 3 ).toString () diff --git a/gui/nodeParamList.py b/gui/nodeParamList.py index ef9d317..e161f39 100644 --- a/gui/nodeParamList.py +++ b/gui/nodeParamList.py @@ -29,7 +29,7 @@ from gui.params.TextWidget import TextWidget from gui.params.ControlWidget import ControlWidget -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -41,7 +41,7 @@ class NodeParamListTab ( QtModule.QWidget ) : # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 50000 : + if QtCore.QT_VERSION >= 0x50000 : # sectionResized = QtCore.pyqtSignal ( int,int,int ) # @@ -69,7 +69,7 @@ def __init__ ( self, parent, gfxNode = None, isInput = True, showConnected = Fal # def connectSignals ( self ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.connect ( self.paramHeader, QtCore.SIGNAL ( 'sectionResized(int,int,int)' ), self.onSectionResized ) else : self.paramHeader.sectionResized.connect ( self.onSectionResized ) @@ -241,7 +241,7 @@ def buildGui ( self ) : self.paramListLayout = QtModule.QGridLayout () self.paramListLayout.setSizeConstraint ( QtModule.QLayout.SetNoConstraint ) self.paramListLayout.setSpacing ( UI.SPACING ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.paramListLayout.setMargin ( UI.SPACING ) self.paramListLayout.setAlignment ( QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft ) self.paramListLayout.setColumnMinimumWidth ( 0, self.labelWidth ) @@ -292,7 +292,7 @@ def updateGui ( self ) : paramWidget.setEnabled ( False ) if param.removable : - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.connect ( paramWidget, QtCore.SIGNAL ( 'nodeParamRemoved' ), self.nodeParamViewTab.onParamRemoved ) else : paramWidget.nodeParamRemoved.connect ( self.nodeParamViewTab.onParamRemoved ) diff --git a/gui/nodeParamView.py b/gui/nodeParamView.py index 7d9bf36..74de0e8 100644 --- a/gui/nodeParamView.py +++ b/gui/nodeParamView.py @@ -19,7 +19,7 @@ import gui.ui_settings as UI from global_vars import DEBUG_MODE -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -37,7 +37,7 @@ def __init__ ( self ) : # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 50000 : + if QtCore.QT_VERSION >= 0x50000 : # self.nodeParamChangedSignal = Signal () self.nodeLabelChangedSignal = Signal () @@ -69,7 +69,7 @@ def setNode ( self, gfxNode ) : # def connectSignals ( self ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.connect ( self.nameEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.nodeLabelChanged ) self.connect ( self.showConnectButton, QtCore.SIGNAL ( 'toggled(bool)' ), self.showConnections ) else : @@ -80,7 +80,7 @@ def connectSignals ( self ) : # def disconnectSignals ( self ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.disconnect ( self.nameEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.nodeLabelChanged ) self.disconnect ( self.showConnectButton, QtCore.SIGNAL ( 'toggled(bool)' ), self.showConnections ) else : @@ -93,12 +93,12 @@ def connectParamSignals ( self ) : #print ">> NodeParamView.connectParamSignals" if self.gfxNode is not None : for inputParam in self.gfxNode.node.inputParams : - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.connect ( inputParam, QtCore.SIGNAL ( 'paramChangedSignal(QObject)' ), self.onParamChanged ) else : inputParam.paramChangedSignal.connect ( self.onParamChanged ) for outputParam in self.gfxNode.node.outputParams : - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.connect ( outputParam, QtCore.SIGNAL ( 'paramChangedSignal(QObject)' ), self.onParamChanged ) else : outputParam.paramChangedSignal.connect ( self.onParamChanged ) @@ -109,12 +109,12 @@ def disconnectParamSignals ( self ) : #print ">> NodeParamView.disconnectParamSignals" if self.gfxNode is not None : for inputParam in self.gfxNode.node.inputParams : - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.disconnect ( inputParam, QtCore.SIGNAL ( 'paramChangedSignal(QObject)' ), self.onParamChanged ) else : inputParam.paramChangedSignal.disconnect ( self.onParamChanged ) for outputParam in self.gfxNode.node.outputParams : - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.disconnect ( outputParam, QtCore.SIGNAL ( 'paramChangedSignal(QObject)' ), self.onParamChanged ) else : outputParam.paramChangedSignal.disconnect ( self.onParamChanged ) @@ -135,7 +135,7 @@ def showConnections ( self, show ) : def onParamChanged ( self, param ) : # if DEBUG_MODE : print ">> NodeParamView.onParamChanged node = %s param = %s" % ( self.gfxNode.node.label, param.name ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( 'nodeParamChangedSignal' ), self.gfxNode, param ) # .node else : self.nodeParamChangedSignal.emit ( self.gfxNode, param ) # .node @@ -153,7 +153,7 @@ def nodeLabelChanged ( self ) : # update label only if realy changed if newLabel != self.gfxNode.node.label : # rename node label if same name exists in NodeNet - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.emit ( QtCore.SIGNAL ( 'nodeLabelChangedSignal' ), self.gfxNode, newLabel ) else : self.nodeLabelChangedSignal.emit ( self.gfxNode, newLabel ) @@ -196,7 +196,7 @@ def buildGui ( self ) : headerLayout = QtModule.QHBoxLayout () headerLayout.setSpacing ( UI.SPACING ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : headerLayout.setMargin ( UI.SPACING ) headerLayout.setStretch ( 1, 1 ) diff --git a/gui/nodeSwatchParam.py b/gui/nodeSwatchParam.py index 11b7f42..0769bcf 100644 --- a/gui/nodeSwatchParam.py +++ b/gui/nodeSwatchParam.py @@ -9,7 +9,7 @@ import ui_settings as UI -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/gui/nodeTreeView.py b/gui/nodeTreeView.py index bd12940..80bc967 100644 --- a/gui/nodeTreeView.py +++ b/gui/nodeTreeView.py @@ -12,7 +12,7 @@ from core.node import Node from core.nodeLibrary import NodeLibrary -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -45,7 +45,7 @@ def startDrag ( self, dropActions ) : stream = QtCore.QDataStream ( data, QtCore.QIODevice.WriteOnly ) itemName = item.text () - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : itemFilename = item.data( QtCore.Qt.UserRole + 4 ).toString () stream << itemFilename else : @@ -59,7 +59,7 @@ def startDrag ( self, dropActions ) : drag = QtGui.QDrag ( self ) drag.setMimeData ( mimeData ) #drag.setPixmap ( QtGui.QPixmap(':/node.png') ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : drag.start ( QtCore.Qt.CopyAction ) else : drag.exec_ ( QtCore.Qt.CopyAction ) diff --git a/gui/params/ColorWidget.py b/gui/params/ColorWidget.py index 8f3d430..d13f794 100644 --- a/gui/params/ColorWidget.py +++ b/gui/params/ColorWidget.py @@ -9,7 +9,7 @@ import gui.ui_settings as UI from paramWidget import ParamWidget -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -28,7 +28,7 @@ def __init__ ( self, param, gfxNode, ignoreSubtype = False ) : # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 50000 : + if QtCore.QT_VERSION >= 0x50000 : # self.clicked = Signal () """ @@ -40,7 +40,7 @@ def buildGui ( self ) : # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 50000 : + if QtCore.QT_VERSION >= 0x50000 : # self.clicked = Signal () @@ -65,7 +65,7 @@ def eventFilter ( self, obj, event ) : # check for single click if event.type () == QtCore.QEvent.MouseButtonPress: #print "eventFilter = MouseButtonPress" - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.ColorWidget.emit ( QtCore.SIGNAL ( 'clicked()' ) ) else : self.ColorWidget.clicked.emit () @@ -121,7 +121,7 @@ def setupUi ( self, ColorWidget ) : def connectSignals ( self, ColorWidget ) : # register signal propertyChanged for updating the gui #self.connect( self.colorProperty, QtCore.SIGNAL('propertyChanged()'), self.onPropertyChanged ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : ColorWidget.connect ( ColorWidget, QtCore.SIGNAL ( 'clicked()' ), self.onClicked ) ColorWidget.connect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) else : @@ -133,7 +133,7 @@ def connectSignals ( self, ColorWidget ) : def disconnectSignals ( self, ColorWidget ) : # register signal propertyChanged for updating the gui #self.disconnect( self.colorProperty, QtCore.SIGNAL('propertyChanged()'), self.onPropertyChanged ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : ColorWidget.disconnect ( ColorWidget, QtCore.SIGNAL ( 'clicked()' ), self.onClicked ) ColorWidget.disconnect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) else : diff --git a/gui/params/ControlWidget.py b/gui/params/ControlWidget.py index 77f9dbb..957ecfc 100644 --- a/gui/params/ControlWidget.py +++ b/gui/params/ControlWidget.py @@ -9,7 +9,7 @@ import gui.ui_settings as UI from paramWidget import ParamWidget -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -62,7 +62,7 @@ def setupUi ( self, ControlWidget ) : # def connectSignals ( self, ControlWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : ControlWidget.connect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) else : self.stringEdit.editingFinished.connect ( self.onStringEditEditingFinished ) @@ -71,7 +71,7 @@ def connectSignals ( self, ControlWidget ) : # def disconnectSignals ( self, ControlWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : ControlWidget.disconnect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) else : self.stringEdit.editingFinished.disconnect ( self.onStringEditEditingFinished ) @@ -119,7 +119,7 @@ def setupUi ( self, ControlWidget ) : # def connectSignals ( self, ControlWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : ControlWidget.connect ( self.button, QtCore.SIGNAL ( 'clicked()' ), self.onClicked ) else : self.button.clicked.connect ( self.onClicked ) @@ -128,7 +128,7 @@ def connectSignals ( self, ControlWidget ) : # def disconnectSignals ( self, ControlWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : ControlWidget.disconnect ( self.button, QtCore.SIGNAL ( 'clicked()' ), self.onClicked ) else : self.button.clicked.disconnect ( self.onClicked ) diff --git a/gui/params/FloatWidget.py b/gui/params/FloatWidget.py index e8c3a9a..2128da9 100644 --- a/gui/params/FloatWidget.py +++ b/gui/params/FloatWidget.py @@ -12,7 +12,7 @@ import gui.ui_settings as UI from paramWidget import ParamWidget -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -68,7 +68,7 @@ def setupUi ( self, FloatWidget ) : # def connectSignals ( self, FloatWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : FloatWidget.connect ( self.floatEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) else : self.floatEdit.editingFinished.connect ( self.onFloatEditEditingFinished ) @@ -77,7 +77,7 @@ def connectSignals ( self, FloatWidget ) : # def disconnectSignals ( self, FloatWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : FloatWidget.disconnect ( self.floatEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) else : self.floatEdit.editingFinished.disconnect ( self.onFloatEditEditingFinished ) @@ -87,7 +87,7 @@ def disconnectSignals ( self, FloatWidget ) : def onFloatEditEditingFinished ( self ) : # floatStr = self.floatEdit.text () - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : floatValue = floatStr.toFloat () [0] else : floatValue = float ( floatStr ) @@ -98,7 +98,7 @@ def onFloatEditEditingFinished ( self ) : # def updateGui ( self, value ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.floatEdit.setText ( QtCore.QString.number(value, 'f', 3) ) else : self.floatEdit.setText ( str ( value ) ) @@ -130,7 +130,7 @@ def setupUi ( self, FloatWidget ) : # def connectSignals ( self, FloatWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : FloatWidget.connect ( self.checkBox, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onStateChanged ) else : self.checkBox.stateChanged.connect ( self.onStateChanged ) @@ -139,7 +139,7 @@ def connectSignals ( self, FloatWidget ) : # def disconnectSignals ( self, FloatWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : FloatWidget.disconnect ( self.checkBox, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onStateChanged ) else : self.checkBox.stateChanged.disconnect ( self.onStateChanged ) @@ -190,7 +190,7 @@ def setupUi ( self, FloatWidget ) : # def connectSignals ( self, FloatWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : FloatWidget.connect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) else : self.selector.activated.connect ( self.onCurrentIndexChanged ) @@ -199,7 +199,7 @@ def connectSignals ( self, FloatWidget ) : # def disconnectSignals ( self, FloatWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : FloatWidget.disconnect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) else : self.selector.activated.disconnect ( self.onCurrentIndexChanged ) @@ -291,7 +291,7 @@ def setupUi ( self, FloatWidget ) : # def connectSignals ( self, FloatWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : FloatWidget.connect ( self.floatEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) FloatWidget.connect ( self.slider, QtCore.SIGNAL ( 'valueChanged(int)' ), self.onSliderValueChanged ) else : @@ -302,7 +302,7 @@ def connectSignals ( self, FloatWidget ) : # def disconnectSignals ( self, FloatWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : FloatWidget.disconnect ( self.floatEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) FloatWidget.disconnect ( self.slider, QtCore.SIGNAL ( 'valueChanged(int)' ), self.onSliderValueChanged ) else : @@ -314,7 +314,7 @@ def disconnectSignals ( self, FloatWidget ) : def onFloatEditEditingFinished ( self ) : # floatStr = self.floatEdit.text () - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : floatValue = floatStr.toFloat () [ 0 ] else : floatValue = float ( floatStr ) @@ -368,7 +368,7 @@ def onSliderValueChanged ( self, value ) : # def updateGui ( self, value ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.floatEdit.setText ( QtCore.QString.number ( value, 'f', 3 ) ) else : self.floatEdit.setText ( str ( value ) ) diff --git a/gui/params/IntWidget.py b/gui/params/IntWidget.py index 5e384eb..1f4afdf 100644 --- a/gui/params/IntWidget.py +++ b/gui/params/IntWidget.py @@ -8,7 +8,7 @@ import gui.ui_settings as UI from paramWidget import ParamWidget -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -64,7 +64,7 @@ def setupUi ( self, IntWidget ) : # def connectSignals ( self, IntWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : IntWidget.connect ( self.intEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onIntEditEditingFinished ) else : self.intEdit.editingFinished.connect ( self.onIntEditEditingFinished ) @@ -73,7 +73,7 @@ def connectSignals ( self, IntWidget ) : # def disconnectSignals ( self, IntWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : IntWidget.disconnect ( self.intEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onIntEditEditingFinished ) else : self.intEdit.editingFinished.disconnect ( self.onIntEditEditingFinished ) @@ -83,7 +83,7 @@ def disconnectSignals ( self, IntWidget ) : def onIntEditEditingFinished ( self ) : # intStr = self.intEdit.text () - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : intValue = intStr.toInt () [ 0 ] else : intValue = int ( intStr ) @@ -92,7 +92,7 @@ def onIntEditEditingFinished ( self ) : # updateGui def updateGui ( self, value ): # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.intEdit.setText ( QtCore.QString.number ( value ) ) else : self.intEdit.setText ( str ( value ) ) @@ -125,7 +125,7 @@ def setupUi ( self, IntWidget ) : # def connectSignals ( self, IntWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : IntWidget.connect ( self.checkBox, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onStateChanged ) else : self.checkBox.stateChanged.connect ( self.onStateChanged ) @@ -134,7 +134,7 @@ def connectSignals ( self, IntWidget ) : # def disconnectSignals ( self, IntWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : IntWidget.disconnect ( self.checkBox, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onStateChanged ) else : self.checkBox.stateChanged.disconnect ( self.onStateChanged ) @@ -185,7 +185,7 @@ def setupUi ( self, IntWidget ) : # def connectSignals ( self, IntWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : IntWidget.connect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) else : self.selector.activated.connect ( self.onCurrentIndexChanged ) @@ -194,7 +194,7 @@ def connectSignals ( self, IntWidget ) : # def disconnectSignals ( self, IntWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : IntWidget.disconnect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) else : self.selector.activated.disconnect ( self.onCurrentIndexChanged ) @@ -203,7 +203,7 @@ def disconnectSignals ( self, IntWidget ) : # def onCurrentIndexChanged ( self, idx ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : ( intValue, ok ) = self.selector.itemData ( idx ).toInt () else : intValue = self.selector.itemData ( idx ) @@ -272,7 +272,7 @@ def setupUi ( self, IntWidget ) : # def connectSignals ( self, IntWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : IntWidget.connect ( self.intEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onIntEditEditingFinished ) IntWidget.connect ( self.slider, QtCore.SIGNAL ( 'valueChanged(int)' ), self.onSliderValueChanged ) else : @@ -283,7 +283,7 @@ def connectSignals ( self, IntWidget ) : # def disconnectSignals ( self, IntWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : IntWidget.disconnect ( self.intEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onIntEditEditingFinished ) IntWidget.disconnect ( self.slider, QtCore.SIGNAL ( 'valueChanged(int)' ), self.onSliderValueChanged ) else : @@ -295,7 +295,7 @@ def disconnectSignals ( self, IntWidget ) : def onIntEditEditingFinished ( self ) : # intStr = self.intEdit.text () - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : intValue = intStr.toInt () [ 0 ] else : intValue = int ( intStr ) @@ -314,7 +314,7 @@ def onSliderValueChanged ( self, value ) : # def updateGui ( self, value ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.intEdit.setText ( QtCore.QString.number ( value ) ) else : self.intEdit.setText ( str ( value ) ) diff --git a/gui/params/MatrixWidget.py b/gui/params/MatrixWidget.py index 9add305..c538b95 100644 --- a/gui/params/MatrixWidget.py +++ b/gui/params/MatrixWidget.py @@ -8,7 +8,7 @@ import gui.ui_settings as UI from paramWidget import ParamWidget -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -169,7 +169,7 @@ def setupUi ( self, MatrixWidget ) : # def connectSignals ( self, MatrixWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : MatrixWidget.connect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) MatrixWidget.connect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) MatrixWidget.connect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) @@ -218,7 +218,7 @@ def connectSignals ( self, MatrixWidget ) : # def disconnectSignals ( self, MatrixWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : MatrixWidget.disconnect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) MatrixWidget.disconnect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) MatrixWidget.disconnect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) diff --git a/gui/params/NormalWidget.py b/gui/params/NormalWidget.py index f5607b3..44b6406 100644 --- a/gui/params/NormalWidget.py +++ b/gui/params/NormalWidget.py @@ -8,7 +8,7 @@ import gui.ui_settings as UI from paramWidget import ParamWidget -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -75,7 +75,7 @@ def setupUi ( self, NormalWidget ) : # def connectSignals ( self, NormalWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : NormalWidget.connect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) NormalWidget.connect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) NormalWidget.connect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) @@ -90,7 +90,7 @@ def connectSignals ( self, NormalWidget ) : # def disconnectSignals ( self, NormalWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : NormalWidget.disconnect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) NormalWidget.disconnect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) NormalWidget.disconnect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) @@ -126,7 +126,7 @@ def onCurrentIndexChanged ( self, idx ) : # def updateGui ( self, value ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.floatEdit0.setText ( QtCore.QString.number( value [0], 'f', 3 ) ) self.floatEdit1.setText ( QtCore.QString.number( value [1], 'f', 3 ) ) self.floatEdit2.setText ( QtCore.QString.number( value [2], 'f', 3 ) ) diff --git a/gui/params/PointWidget.py b/gui/params/PointWidget.py index 014bd6c..b769058 100644 --- a/gui/params/PointWidget.py +++ b/gui/params/PointWidget.py @@ -8,7 +8,7 @@ import gui.ui_settings as UI from paramWidget import ParamWidget -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -75,7 +75,7 @@ def setupUi ( self, PointWidget ) : # def connectSignals ( self, PointWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : PointWidget.connect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) PointWidget.connect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) PointWidget.connect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) @@ -90,7 +90,7 @@ def connectSignals ( self, PointWidget ) : # def disconnectSignals ( self, PointWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : PointWidget.disconnect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) PointWidget.disconnect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) PointWidget.disconnect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) @@ -126,7 +126,7 @@ def onCurrentIndexChanged ( self, idx ) : # def updateGui ( self, value ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.floatEdit0.setText ( QtCore.QString.number( value [0], 'f', 3 ) ) self.floatEdit1.setText ( QtCore.QString.number( value [1], 'f', 3 ) ) self.floatEdit2.setText ( QtCore.QString.number( value [2], 'f', 3 ) ) diff --git a/gui/params/StringWidget.py b/gui/params/StringWidget.py index 2dbc947..953c68c 100644 --- a/gui/params/StringWidget.py +++ b/gui/params/StringWidget.py @@ -9,7 +9,7 @@ import gui.ui_settings as UI from paramWidget import ParamWidget -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -62,7 +62,7 @@ def setupUi ( self, StringWidget ) : # def connectSignals ( self, StringWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : StringWidget.connect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) else : self.stringEdit.editingFinished.connect ( self.onStringEditEditingFinished ) @@ -71,7 +71,7 @@ def connectSignals ( self, StringWidget ) : # def disconnectSignals ( self, StringWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : StringWidget.disconnect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) else : self.stringEdit.editingFinished.disconnect ( self.onStringEditEditingFinished ) @@ -124,7 +124,7 @@ def setupUi ( self, StringWidget ) : # def connectSignals ( self, StringWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : StringWidget.connect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) else : self.selector.activated.connect ( self.onCurrentIndexChanged ) @@ -133,7 +133,7 @@ def connectSignals ( self, StringWidget ) : # def disconnectSignals ( self, StringWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : StringWidget.disconnect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) else : self.selector.activated.disconnect ( self.onCurrentIndexChanged ) @@ -143,7 +143,7 @@ def disconnectSignals ( self, StringWidget ) : def onCurrentIndexChanged ( self, idx ) : # #pass - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : stringValue = self.selector.itemData ( idx ).toString () else : stringValue = str ( self.selector.itemData ( idx ) ) @@ -200,7 +200,7 @@ def setupUi ( self, StringWidget ) : # def connectSignals ( self, StringWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : StringWidget.connect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) StringWidget.connect ( self.btnBrowseDir, QtCore.SIGNAL ( 'clicked()' ), self.onBrowseFile ) else : @@ -211,7 +211,7 @@ def connectSignals ( self, StringWidget ) : # def disconnectSignals ( self, StringWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : StringWidget.disconnect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) StringWidget.disconnect ( self.btnBrowseDir, QtCore.SIGNAL ( 'clicked()' ), self.onBrowseFile ) else : diff --git a/gui/params/TextWidget.py b/gui/params/TextWidget.py index 9e886b7..2700903 100644 --- a/gui/params/TextWidget.py +++ b/gui/params/TextWidget.py @@ -8,7 +8,7 @@ import gui.ui_settings as UI from paramWidget import ParamWidget -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -57,7 +57,7 @@ def setupUi ( self, TextWidget ) : # def connectSignals ( self, TextWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : TextWidget.connect ( self.text_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onTextEditEditingFinished ) else : self.text_plainTextEdit.textChanged.connect ( self.onTextEditEditingFinished ) @@ -66,7 +66,7 @@ def connectSignals ( self, TextWidget ) : # def disconnectSignals ( self, TextWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : TextWidget.disconnect ( self.text_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onTextEditEditingFinished ) else : self.text_plainTextEdit.textChanged.connect ( self.onTextEditEditingFinished ) diff --git a/gui/params/VectorWidget.py b/gui/params/VectorWidget.py index 4fc9815..f33f502 100644 --- a/gui/params/VectorWidget.py +++ b/gui/params/VectorWidget.py @@ -8,7 +8,7 @@ import gui.ui_settings as UI from paramWidget import ParamWidget -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -74,7 +74,7 @@ def setupUi ( self, VectorWidget ) : # def connectSignals ( self, VectorWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : VectorWidget.connect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) VectorWidget.connect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) VectorWidget.connect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) @@ -90,7 +90,7 @@ def connectSignals ( self, VectorWidget ) : # def disconnectSignals ( self, VectorWidget ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : VectorWidget.disconnect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) VectorWidget.disconnect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) VectorWidget.disconnect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) @@ -126,7 +126,7 @@ def onCurrentIndexChanged ( self, idx ) : # def updateGui ( self, value ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.floatEdit0.setText ( QtCore.QString.number( value [0], 'f', 3 ) ) self.floatEdit1.setText ( QtCore.QString.number( value [1], 'f', 3 ) ) self.floatEdit2.setText ( QtCore.QString.number( value [2], 'f', 3 ) ) diff --git a/gui/params/linkWidget.py b/gui/params/linkWidget.py index ffbe4ed..6bd8998 100644 --- a/gui/params/linkWidget.py +++ b/gui/params/linkWidget.py @@ -9,7 +9,7 @@ import gui.ui_settings as UI from paramWidget import ParamWidget -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/gui/params/paramLabel.py b/gui/params/paramLabel.py index 2ddfba1..e02e682 100644 --- a/gui/params/paramLabel.py +++ b/gui/params/paramLabel.py @@ -9,7 +9,7 @@ from global_vars import app_global_vars, DEBUG_MODE import gui.ui_settings as UI -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -72,7 +72,7 @@ def updateGui ( self ) : # def connectSignals ( self ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.connect ( self.editLabel, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditingFinished ) else : self.editLabel.editingFinished.connect ( self.onEditingFinished ) @@ -81,7 +81,7 @@ def connectSignals ( self ) : # def disconnectSignals ( self ) : # - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.disconnect ( self.editLabel, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditingFinished ) else : self.editLabel.editingFinished.disconnect ( self.onEditingFinished ) diff --git a/gui/params/paramWidget.py b/gui/params/paramWidget.py index bcb0e7d..0ba5639 100644 --- a/gui/params/paramWidget.py +++ b/gui/params/paramWidget.py @@ -11,7 +11,7 @@ from paramLabel import ParamLabel -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -29,7 +29,7 @@ def __init__ ( self, param, gfxNode, ignoreSubtype = False ) : # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 50000 : + if QtCore.QT_VERSION >= 0x50000 : # self.nodeParamRemoved = Signal () # @@ -83,7 +83,7 @@ def buildGeneralGui ( self ) : self.label_vl = QtModule.QVBoxLayout () self.label_vl.setSpacing ( UI.SPACING ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.label_vl.setMargin ( 0 ) self.label_vl.setAlignment ( QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft ) @@ -91,14 +91,14 @@ def buildGeneralGui ( self ) : self.hl = QtModule.QHBoxLayout () self.hl.setSpacing ( UI.SPACING ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.hl.setMargin ( 0 ) self.hl.setAlignment ( QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft ) # vertical layout for parametrs values (e.g. output links or matrix rows) self.param_vl = QtModule.QVBoxLayout () self.param_vl.setSpacing ( UI.SPACING ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.param_vl.setMargin ( 0 ) self.param_vl.setAlignment ( QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft ) # @@ -114,7 +114,7 @@ def buildGeneralGui ( self ) : self.check.setMaximumSize ( QtCore.QSize ( UI.CHECK_WIDTH, UI.HEIGHT ) ) self.check.setToolTip ( 'Use as Shader parameter' ) self.check.setChecked ( self.param.shaderParam ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : self.connect ( self.check, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onShaderParamChanged ) else : self.check.stateChanged.connect ( self.onShaderParamChanged ) @@ -141,7 +141,7 @@ def buildGeneralGui ( self ) : self.removeButton.setIconSize ( QtCore.QSize ( 16, 16 ) ) self.removeButton.setObjectName ( 'removeButton' ) self.hl.addWidget ( self.removeButton ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.connect ( self.removeButton, QtCore.SIGNAL ( 'clicked()' ), self.onRemoveItem ) else : self.removeButton.clicked.connect ( self.onRemoveItem ) @@ -211,7 +211,7 @@ def buildGui ( self ) : def onRemoveItem ( self ) : # if DEBUG_MODE : print '>> ParamWidget( %s ).onRemoveItem ' % self.param.name - if QtCore.QT_VERSION >= 50000 : + if QtCore.QT_VERSION >= 0x50000 : self.emit ( QtCore.SIGNAL ( 'nodeParamRemoved' ), self.param ) else : self.nodeParamRemoved.emit ( self.param ) diff --git a/gui/ui_MainWindow.py b/gui/ui_MainWindow.py index 0ca97f5..88a0b7d 100644 --- a/gui/ui_MainWindow.py +++ b/gui/ui_MainWindow.py @@ -9,7 +9,7 @@ from core.mePyQt import QtCore, QtGui -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -409,7 +409,7 @@ def setupUi(self, MainWindow): self.retranslateUi(MainWindow) self.tabs.setCurrentIndex(0) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.connect(self.actionExit, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.close) QtCore.QObject.connect(self.actionProjectSetup, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onProjectSetup) QtCore.QObject.connect(self.actionShowGrid, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), MainWindow.onShowGrid) diff --git a/gui/ui_imageViewWidget.py b/gui/ui_imageViewWidget.py index 0a74afe..d18ba95 100644 --- a/gui/ui_imageViewWidget.py +++ b/gui/ui_imageViewWidget.py @@ -9,7 +9,7 @@ from core.mePyQt import QtCore, QtGui -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -71,7 +71,7 @@ def setupUi(self, imageViewWidget): self.gridLayout.setRowStretch(1, 1) self.retranslateUi(imageViewWidget) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.connect(self.btn_render, QtCore.SIGNAL(_fromUtf8("clicked()")), imageViewWidget.updateViewer) QtCore.QObject.connect(self.btn_reset, QtCore.SIGNAL(_fromUtf8("clicked()")), self.imageArea.resetZoom) else : diff --git a/gui/ui_meRendererSetup.py b/gui/ui_meRendererSetup.py index 66a591e..4739a75 100644 --- a/gui/ui_meRendererSetup.py +++ b/gui/ui_meRendererSetup.py @@ -9,7 +9,7 @@ from core.mePyQt import QtCore, QtGui -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -359,7 +359,7 @@ def setupUi(self, meRendererSetup): self.retranslateUi(meRendererSetup) self.tabs.setCurrentIndex(0) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.connect(self.cancelButton, QtCore.SIGNAL("clicked()"), meRendererSetup.close) QtCore.QObject.connect(self.okButton, QtCore.SIGNAL("clicked()"), meRendererSetup.onSelect) QtCore.QObject.connect(self.listPreset, QtCore.SIGNAL("currentIndexChanged(QString)"), meRendererSetup.onIndexChanged) diff --git a/gui/ui_nodeLibraryView.py b/gui/ui_nodeLibraryView.py index 5d2bb49..5af9ac7 100644 --- a/gui/ui_nodeLibraryView.py +++ b/gui/ui_nodeLibraryView.py @@ -9,7 +9,7 @@ from core.mePyQt import QtCore, QtGui -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -48,7 +48,7 @@ def setupUi(self, nodeLibraryView): self.retranslateUi(nodeLibraryView) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.connect(self.btn_reload, QtCore.SIGNAL(_fromUtf8("clicked()")), nodeLibraryView.onReload) else : self.btn_reload.clicked.connect( nodeLibraryView.onReload) diff --git a/gui/ui_nodeList.py b/gui/ui_nodeList.py index 11cba6b..06c0eda 100644 --- a/gui/ui_nodeList.py +++ b/gui/ui_nodeList.py @@ -9,7 +9,7 @@ from core.mePyQt import QtCore, QtGui -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/gui/ui_nodeParam.py b/gui/ui_nodeParam.py index 07c29d1..bd3a4ed 100644 --- a/gui/ui_nodeParam.py +++ b/gui/ui_nodeParam.py @@ -9,7 +9,7 @@ from core.mePyQt import QtCore, QtGui -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/gui/ui_nodeSwatchParam.py b/gui/ui_nodeSwatchParam.py index 99407bd..b4e02c1 100644 --- a/gui/ui_nodeSwatchParam.py +++ b/gui/ui_nodeSwatchParam.py @@ -9,7 +9,7 @@ from core.mePyQt import QtCore, QtGui -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/gui/ui_projectSetup.py b/gui/ui_projectSetup.py index 5c99580..9ac984a 100644 --- a/gui/ui_projectSetup.py +++ b/gui/ui_projectSetup.py @@ -9,7 +9,7 @@ from core.mePyQt import QtCore, QtGui -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -138,7 +138,7 @@ def setupUi(self, ProjectSetup): self.verticalLayout_3.addWidget(self.buttonBox) self.retranslateUi(ProjectSetup) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), ProjectSetup.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), ProjectSetup.reject) QtCore.QObject.connect(self.btn_project_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), ProjectSetup.onBrowseProjectDir) diff --git a/gui/ui_settingsSetup.py b/gui/ui_settingsSetup.py index e7459f3..f45b109 100644 --- a/gui/ui_settingsSetup.py +++ b/gui/ui_settingsSetup.py @@ -9,7 +9,7 @@ from core.mePyQt import QtCore, QtGui -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -162,7 +162,7 @@ def setupUi(self, SettingsSetup): self.verticalLayout_2.addWidget(self.buttonBox) self.retranslateUi(SettingsSetup) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), SettingsSetup.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), SettingsSetup.reject) QtCore.QObject.connect(self.btn_lib_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), SettingsSetup.onBrowseLibraryDir) diff --git a/gui/ui_viewComputedCodeDialog.py b/gui/ui_viewComputedCodeDialog.py index a64f92a..4bb8163 100644 --- a/gui/ui_viewComputedCodeDialog.py +++ b/gui/ui_viewComputedCodeDialog.py @@ -9,7 +9,7 @@ from core.mePyQt import QtCore, QtGui -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -45,7 +45,7 @@ def setupUi(self, ViewComputedCodeDialog): self.gridLayout.addWidget(self.buttonBox, 1, 0, 1, 1) self.retranslateUi(ViewComputedCodeDialog) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), ViewComputedCodeDialog.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), ViewComputedCodeDialog.reject) else : diff --git a/gui/ui_workArea.py b/gui/ui_workArea.py index 7e10420..b3ea2cc 100644 --- a/gui/ui_workArea.py +++ b/gui/ui_workArea.py @@ -9,7 +9,7 @@ from core.mePyQt import QtCore, QtGui -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/meShaderEd.py b/meShaderEd.py index 641f261..62dbb57 100644 --- a/meShaderEd.py +++ b/meShaderEd.py @@ -42,7 +42,7 @@ def setDefaultValue ( key, def_value ) : if not app_settings.contains ( key ): app_settings.setValue ( key, def_value ) value = app_settings.value ( key ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : if value.toString () == 'true' : value = True elif value.toString () == 'false' : value = False else : @@ -66,7 +66,7 @@ def getDefaultValue ( settings, group, key, def_value = None ) : if group != '' : settings.beginGroup ( group ) value = settings.value ( key ) if group != '' : settings.endGroup ( ) - if QtCore.QT_VERSION < 50000 : + if QtCore.QT_VERSION < 0x50000 : if value.toString () == 'true' : value = True elif value.toString () == 'false' : value = False else : @@ -84,7 +84,7 @@ def getDefaultValue ( settings, group, key, def_value = None ) : value = str ( value ) return value -if QtCore.QT_VERSION < 50000 : +if QtCore.QT_VERSION < 0x50000 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -95,9 +95,7 @@ def getDefaultValue ( settings, group, key, def_value = None ) : def main () : # app = QtModule.QApplication ( sys.argv ) - - app_settings.setValue ( 'version', version ) app_settings.setValue ( 'root', normPath ( root ) ) project_filename = setDefaultValue ( 'project_filename', 'meshadered.prj' ) @@ -198,9 +196,10 @@ def main () : app_colors [ 'image_node_bg' ] = setDefaultValue ( 'image_node_bg', app_colors [ 'image_node_bg' ] ) app_colors [ 'group_node_bg' ] = setDefaultValue ( 'group_node_bg', app_colors [ 'group_node_bg' ] ) app_settings.endGroup () + from gui.MainWindow import MainWindow - window = MainWindow () #, rendererPreset ) + window = MainWindow () window.show () # It's exec_ because exec is a reserved word in Python @@ -224,8 +223,9 @@ def main () : print '* PYQT_VERSION = %0X' % QtCore.PYQT_VERSION if sys.platform.startswith ( 'win') : - if QtCore.QT_VERSION < 50000 : - QtModule.QApplication.setStyle ( QtModule.QStyleFactory.create ( 'Cleanlooks' ) ) - QtModule.QApplication.setPalette ( QtModule.QApplication.style ().standardPalette () ) + if QtCore.QT_VERSION < 0x50000 : + pass + #QtModule.QApplication.setStyle ( QtModule.QStyleFactory.create ( 'Cleanlooks' ) ) + #QtModule.QApplication.setPalette ( QtModule.QApplication.style ().standardPalette () ) main () diff --git a/mkpyqt5.py b/mkpyqt5.py index 60d6da6..79a2ecc 100644 --- a/mkpyqt5.py +++ b/mkpyqt5.py @@ -24,7 +24,7 @@ import sys from core.mePyQt import QtCore, PythonQtType -if QtCore.QT_VERSION < 50000 : pass +if QtCore.QT_VERSION < 0x50000 : pass __version__ = "1.0.4" From c2cf2521eeff8f18c5f77e5dceabfdad23ec0370 Mon Sep 17 00:00:00 2001 From: ymesh Date: Sat, 3 Oct 2015 02:41:20 +0300 Subject: [PATCH 6/6] Added PySide compatibility --- core/meCommon.py | 89 +------- core/mePyQt.py | 53 ++--- core/meRendererPreset.py | 2 +- core/node.py | 13 +- core/nodeLibrary.py | 19 +- core/nodeLink.py | 2 +- core/nodeNetwork.py | 2 +- core/nodeParam.py | 6 +- core/nodes/connectorNode.py | 2 +- core/nodes/imageNode.py | 2 +- core/nodes/noteNode.py | 2 +- core/nodes/ribCodeNode.py | 2 +- core/nodes/ribNode.py | 2 +- core/nodes/rslNode.py | 2 +- core/nodes/swatchNode.py | 2 +- core/swatchInfo.py | 2 +- gfx/WorkArea.py | 45 ++-- gfx/gfxLink.py | 6 +- gfx/gfxNode.py | 33 +-- gfx/gfxNodeConnector.py | 33 +-- gfx/gfxNodeLabel.py | 4 +- gfx/gfxNote.py | 15 +- gfx/gfxSwatchNode.py | 10 +- gfx/imageView.py | 19 +- global_vars.py | 4 +- gui/MainWindow.py | 160 ++++++++----- gui/ProjectSetup.py | 11 +- gui/SettingsSetup.py | 6 +- gui/ViewComputedCodeDialog.py | 4 +- gui/exportShader/ExportShaderDialog.py | 18 +- gui/exportShader/ui_exportShaderDialog.py | 21 +- gui/imageViewWidget.py | 8 +- gui/meRendererSetup.py | 25 ++- gui/nodeEditor/NodeEditorDialog.py | 27 ++- gui/nodeEditor/codeSyntaxHighlighter.py | 6 +- gui/nodeEditor/nodeCodeEditor.py | 4 +- gui/nodeEditor/nodeLinkEditor.py | 4 +- gui/nodeEditor/nodeNamesEditor.py | 14 +- gui/nodeEditor/nodeParamEditor.py | 30 +-- gui/nodeEditor/nodePropertiesEditor.py | 18 +- gui/nodeEditor/ui_nodeCodeEditor.py | 7 +- gui/nodeEditor/ui_nodeEditorDialog.py | 59 +++-- gui/nodeEditor/ui_nodeLinkEditor.py | 4 +- gui/nodeEditor/ui_nodeNamesEditor.py | 10 +- gui/nodeEditor/ui_nodeParamEditor.py | 4 +- gui/nodeEditor/ui_nodePropertiesEditor.py | 4 +- gui/nodeLibraryView.py | 4 +- gui/nodeList.py | 40 ++-- gui/nodeParamList.py | 34 +-- gui/nodeParamView.py | 27 ++- gui/nodeSwatchParam.py | 4 +- gui/nodeTreeView.py | 28 ++- gui/params/ColorWidget.py | 18 +- gui/params/ControlWidget.py | 12 +- gui/params/FloatWidget.py | 33 +-- gui/params/IntWidget.py | 30 +-- gui/params/MatrixWidget.py | 79 ++++--- gui/params/NormalWidget.py | 10 +- gui/params/PointWidget.py | 10 +- gui/params/StringWidget.py | 30 +-- gui/params/TextWidget.py | 8 +- gui/params/VectorWidget.py | 10 +- gui/params/linkWidget.py | 4 +- gui/params/paramLabel.py | 11 +- gui/params/paramWidget.py | 31 +-- gui/resources_rc.py | 2 +- gui/ui_MainWindow.py | 8 +- gui/ui_imageViewWidget.py | 8 +- gui/ui_meRendererSetup.py | 6 +- gui/ui_nodeLibraryView.py | 6 +- gui/ui_nodeList.py | 8 +- gui/ui_nodeParam.py | 49 ---- gui/ui_nodeSwatchParam.py | 4 +- gui/ui_projectSetup.py | 36 +-- gui/ui_settingsSetup.py | 40 ++-- gui/ui_viewComputedCodeDialog.py | 6 +- gui/ui_workArea.py | 41 ---- meShaderEd.py | 113 +++++++++- mkpyqt5.py | 4 +- .../shaders/shn}/example_001.xml | 0 samples/shaders/shn/startup.xml | 210 ++++++++++++++++++ 81 files changed, 987 insertions(+), 792 deletions(-) delete mode 100644 gui/ui_nodeParam.py delete mode 100644 gui/ui_workArea.py rename {lib/nodes => samples/shaders/shn}/example_001.xml (100%) create mode 100644 samples/shaders/shn/startup.xml diff --git a/core/meCommon.py b/core/meCommon.py index 273d539..61f097b 100644 --- a/core/meCommon.py +++ b/core/meCommon.py @@ -4,7 +4,7 @@ """ import os, sys -from core.mePyQt import QtCore +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore # # findExecutable # @@ -159,93 +159,6 @@ def getParsedLabel ( text ) : newLabel = newLabel.replace ( ' ', "_" ) return newLabel # -# getSettingsStrValue -# -def getSettingsStrValue ( settings, key ) : - # - if QtCore.QT_VERSION < 0x50000 : - return str ( settings.value ( key ).toString () ) - else : - return str ( settings.value ( key ) ) -# -# createDefaultProject -# -def createDefaultProject ( settings, check_if_exist = False ) : - # - project_filename = getSettingsStrValue ( settings, 'project_filename' ) - project = getSettingsStrValue ( settings, 'project' ) - project_shaders = getSettingsStrValue ( settings, 'project_shaders' ) - project_textures = getSettingsStrValue ( settings, 'project_textures' ) - shader_networks = getSettingsStrValue ( settings, 'shader_networks' ) - shader_sources = getSettingsStrValue ( settings, 'shader_sources' ) - - filename = normPath ( os.path.join ( project, project_filename ) ) - if check_if_exist : - if os.path.exists ( filename ) : - print '>> DefaultProject %s already exists...' % filename - return - - print '>> createDefaultProject %s' % filename - - with open ( filename , 'w') as f : - f.write ( 'project_shaders=%s\n' % toRelativePath ( project, project_shaders ) ) - f.write ( 'project_textures=%s\n' % toRelativePath ( project, project_textures ) ) - f.write ( 'shader_networks=%s\n' % toRelativePath ( project, shader_networks ) ) - f.write ( 'shader_sources=%s\n' % toRelativePath ( project, shader_sources ) ) - f.closed -# -# openDefaultProject -# -def openDefaultProject ( settings, global_vars, project ) : - # - ret = False - if os.path.exists ( project ) : - project_filename = str ( settings.value ( 'project_filename' ).toString () ) - filename = normPath ( os.path.join ( project, project_filename ) ) - project_dir = normPath ( project ) - # setup default setting - project_shaders = normPath ( os.path.join ( project_dir,'shaders' ) ) - project_textures = normPath ( os.path.join ( project_dir,'textures' ) ) - shader_networks_dir = normPath ( os.path.join ( project_shaders,'shn' ) ) - shader_sources_dir = normPath ( os.path.join ( project_shaders,'src' ) ) - if os.path.exists ( filename ) : - # read settings from existing project file - f = open ( filename, 'r' ) - for line in f : - ( key, value ) = line.split ( '=' ) - name = key.strip() - if name in [ 'project_shaders', 'project_textures', 'shader_networks', 'shader_sources' ] : - print 'name = %s value = %s' % ( name, fromRelativePath ( project_dir, value.strip() ) ) - settings.setValue ( name, fromRelativePath ( project_dir, value.strip() ) ) - f.close () - else : - # setup default settings and create default file - settings.setValue ( 'project', project_dir ) - settings.setValue ( 'project_shaders', project_shaders ) - settings.setValue ( 'project_textures', project_textures ) - settings.setValue ( 'shader_networks', shader_networks_dir ) - settings.setValue ( 'shader_sources', shader_sources_dir ) - - createDefaultProject ( settings ) - - global_vars [ 'ProjectPath' ] = project_dir - - global_vars [ 'ProjectShaders' ] = project_shaders - global_vars [ 'ProjectTextures' ] = project_textures - - global_vars [ 'ProjectNetworks' ] = shader_networks_dir - global_vars [ 'ProjectSources' ] = shader_sources_dir - - global_vars [ 'ProjectSearchPath' ] = sanitizeSearchPath ( project_dir ) - global_vars [ 'ProjectSearchShaders' ] = sanitizeSearchPath ( project_shaders ) - global_vars [ 'ProjectSearchTextures' ] = sanitizeSearchPath ( project_textures ) - - createMissingDirs ( [ project_shaders, project_textures, shader_networks_dir, shader_sources_dir ] ) - - ret = True - - return ret -# # parseGlobalVars # def parseGlobalVars ( inputStr ) : diff --git a/core/mePyQt.py b/core/mePyQt.py index f6800ec..9179ac6 100644 --- a/core/mePyQt.py +++ b/core/mePyQt.py @@ -14,56 +14,43 @@ 'QtWidgets', 'Qt' ] - PythonQtType = None -PySide = True +usePySide = False +usePyQt4 = False +usePyQt5 = False try: PythonQt = __import__( 'PySide', globals(), locals(), List ) PythonQtType = 'PySide' + usePySide = True except ImportError: try: PythonQt = __import__( 'PyQt5', globals(), locals(), List ) PythonQtType = 'PyQt5' + usePyQt5 = True except ImportError: - PythonQt = __import__( 'PyQt4', globals(), locals(), List ) - PythonQtType = 'PyQt4' + try: + PythonQt = __import__( 'PyQt4', globals(), locals(), List ) + PythonQtType = 'PyQt4' + usePyQt4 = True + except ImportError: + pass print ( '* ' + PythonQtType + ' module imported' ) -print ( '* ' + 'QT_VERSION = %x' % PythonQt.QtCore.QT_VERSION ) -Qt = PythonQt.Qt +if usePySide : + print ( '* ' + 'PySide.qVersion = %s' % PythonQt.QtCore.qVersion() ) +else : + print ( '* ' + 'QT_VERSION = %x' % PythonQt.QtCore.QT_VERSION ) + +#if not PySide : +# Qt = PythonQt.Qt QtCore = PythonQt.QtCore QtGui = PythonQt.QtGui QtXml = PythonQt.QtXml -if QtCore.QT_VERSION >= 0x50000 : - QtWidgets = PythonQt.QtWidgets #QtNetwork = PythonQt.QtNetwork +if usePyQt5 : + QtWidgets = PythonQt.QtWidgets -if PythonQtType == 'PyQt4' or PythonQtType == 'PyQt5': - #print('You can install PySide if interested in LGPL license.') - PySide = False -# -# GetOpenFileName -# -def GetOpenFileName ( i_qwidget, i_title, i_path = None ) : - if i_path is None : - i_path = '.' - if PySide : - afile, filter = \ - QtGui.QFileDialog.getOpenFileName ( i_qwidget, i_title, i_path ) - return afile - return str ( QtGui.QFileDialog.getOpenFileName ( i_qwidget, i_title, i_path ) ) -# -# GetSaveFileName -# -def GetSaveFileName ( i_qwdget, i_title, i_path = None ) : - if i_path is None : - i_path = '.' - if PySide : - afile, filter = \ - QtGui.QFileDialog.getSaveFileName ( i_qwdget, i_title, i_path ) - return afile - return str ( QtGui.QFileDialog.getSaveFileName ( i_qwdget, i_title, i_path ) ) diff --git a/core/meRendererPreset.py b/core/meRendererPreset.py index 4469f9e..373b5ea 100644 --- a/core/meRendererPreset.py +++ b/core/meRendererPreset.py @@ -4,7 +4,7 @@ """ import os, sys -from core.mePyQt import QtCore, QtXml +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtXml #from core.mePyQt.QtCore import QDir, QFile, QVariant # # meRendererInfo diff --git a/core/node.py b/core/node.py index 0f24597..e54ce1d 100644 --- a/core/node.py +++ b/core/node.py @@ -4,7 +4,7 @@ """ import os, sys, copy -from core.mePyQt import QtCore, QtXml +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtXml from core.signal import Signal #from PyQt4.QtCore import QDir, QFile, QVariant @@ -26,7 +26,7 @@ def __init__ ( self, xml_node = None, nodenet = None ) : # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 0x50000 : + if usePySide or usePyQt5 : # self.nodeUpdated = Signal () # QtCore.pyqtSignal ( [QtCore.QObject] ) self.nodeParamsUpdated = Signal () #QtCore.pyqtSignal ( [QtCore.QObject] ) @@ -105,7 +105,7 @@ def copy ( self ) : assert 0, 'copy needs to be implemented!' def updateNode ( self ) : # if DEBUG_MODE : print '>> Node( %s ).updateNode' % self.label - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'nodeUpdated' ), self ) else : self.nodeUpdated.emit ( self ) @@ -115,7 +115,7 @@ def updateNode ( self ) : def updateNodeParams ( self ) : # if DEBUG_MODE : print '>> Node( %s ).updateNodeParams' % self.label - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'nodeParamsUpdated' ), self ) else : self.nodeParamsUpdated.emit ( self ) @@ -719,9 +719,10 @@ def parseToXML ( self, dom ) : if self.offset != None : ( x, y ) = self.offset + if DEBUG_MODE : print '>> Node::parseToXML offset (%d,%d)' % ( x, y ) offset_tag = dom.createElement ( 'offset' ) - offset_tag.setAttribute ( 'x', x ) - offset_tag.setAttribute ( 'y', y ) + offset_tag.setAttribute ( 'x', str (x) ) # have to use 'str' because PySide throws + offset_tag.setAttribute ( 'y', str (y) ) # Overflow error for negative values here xml_node.appendChild ( offset_tag ) return xml_node diff --git a/core/nodeLibrary.py b/core/nodeLibrary.py index e491780..bf652b1 100644 --- a/core/nodeLibrary.py +++ b/core/nodeLibrary.py @@ -3,7 +3,7 @@ nodeLibrary.py """ -from core.mePyQt import QtCore, QtGui, QtXml +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui, QtXml #from QtCore import QDir, QFile, QVariant #from QtGui import QStandardItemModel, QStandardItem @@ -96,11 +96,18 @@ def scanXmlNodes ( self, filename ) : item = QtGui.QStandardItem ( nodeName ) item.setEditable ( False ) - item.setData ( QtCore.QVariant ( nodeAuthor ), QtCore.Qt.UserRole + 1 ) - item.setData ( QtCore.QVariant ( nodeType ), QtCore.Qt.UserRole + 2 ) - item.setData ( QtCore.QVariant ( nodeHelp ), QtCore.Qt.UserRole + 3 ) - item.setData ( QtCore.QVariant ( nodeFilename ), QtCore.Qt.UserRole + 4 ) - item.setData ( QtCore.QVariant ( nodeIcon ), QtCore.Qt.UserRole + 5 ) + if not usePySide : + item.setData ( QtCore.QVariant ( nodeAuthor ), QtCore.Qt.UserRole + 1 ) + item.setData ( QtCore.QVariant ( nodeType ), QtCore.Qt.UserRole + 2 ) + item.setData ( QtCore.QVariant ( nodeHelp ), QtCore.Qt.UserRole + 3 ) + item.setData ( QtCore.QVariant ( nodeFilename ), QtCore.Qt.UserRole + 4 ) + item.setData ( QtCore.QVariant ( nodeIcon ), QtCore.Qt.UserRole + 5 ) + else : + item.setData ( nodeAuthor, QtCore.Qt.UserRole + 1 ) + item.setData ( nodeType, QtCore.Qt.UserRole + 2 ) + item.setData ( nodeHelp, QtCore.Qt.UserRole + 3 ) + item.setData ( nodeFilename, QtCore.Qt.UserRole + 4 ) + item.setData ( nodeIcon, QtCore.Qt.UserRole + 5 ) if node.nodeName () == 'nodenet' : # set Blue color for nodenet items diff --git a/core/nodeLink.py b/core/nodeLink.py index 1a558be..d1d218e 100644 --- a/core/nodeLink.py +++ b/core/nodeLink.py @@ -5,7 +5,7 @@ # #=============================================================================== import os, sys -from core.mePyQt import QtCore +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore from global_vars import app_global_vars, DEBUG_MODE from node import Node diff --git a/core/nodeNetwork.py b/core/nodeNetwork.py index e54299a..72ae741 100644 --- a/core/nodeNetwork.py +++ b/core/nodeNetwork.py @@ -5,7 +5,7 @@ """ import os, sys -from core.mePyQt import QtCore, QtXml +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtXml #from PyQt4.QtCore import QDir, QFile, QVariant from node import * diff --git a/core/nodeParam.py b/core/nodeParam.py index c889fc7..ee66717 100644 --- a/core/nodeParam.py +++ b/core/nodeParam.py @@ -6,7 +6,7 @@ import os, sys import re import copy -from core.mePyQt import QtCore +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore from core.signal import Signal from core.node import Node @@ -29,7 +29,7 @@ def __init__ ( self, xml_param = None, isRibParam = False ) : # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 0x50000 : + if usePySide or usePyQt5 : # self.paramChangedSignal = Signal () @@ -170,7 +170,7 @@ def valueToStr ( self, value ) : return str ( value ) def paramChanged ( self ) : # if DEBUG_MODE : print '>> NodeParam.paramChanged (name = %s)' % self.name - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'paramChangedSignal(QObject)' ), self ) else : self.paramChangedSignal.emit ( self ) diff --git a/core/nodes/connectorNode.py b/core/nodes/connectorNode.py index b4c4736..b59fb13 100644 --- a/core/nodes/connectorNode.py +++ b/core/nodes/connectorNode.py @@ -3,7 +3,7 @@ connectorNode.py """ -from core.mePyQt import QtCore +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore from core.node import Node from core.nodeParam import NodeParam diff --git a/core/nodes/imageNode.py b/core/nodes/imageNode.py index 739d5e7..5412ded 100644 --- a/core/nodes/imageNode.py +++ b/core/nodes/imageNode.py @@ -3,7 +3,7 @@ imageNode.py """ -from core.mePyQt import QtCore +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore from core.node import Node diff --git a/core/nodes/noteNode.py b/core/nodes/noteNode.py index af38058..99d3314 100644 --- a/core/nodes/noteNode.py +++ b/core/nodes/noteNode.py @@ -3,7 +3,7 @@ noteNode.py """ -from core.mePyQt import QtCore +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore from core.node import Node from core.nodeParam import NodeParam diff --git a/core/nodes/ribCodeNode.py b/core/nodes/ribCodeNode.py index d66013e..b13aee7 100644 --- a/core/nodes/ribCodeNode.py +++ b/core/nodes/ribCodeNode.py @@ -3,7 +3,7 @@ ribCodeNode.py """ -from core.mePyQt import QtCore +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore from core.node import Node from core.nodeParam import NodeParam diff --git a/core/nodes/ribNode.py b/core/nodes/ribNode.py index b79b17d..1c4502f 100644 --- a/core/nodes/ribNode.py +++ b/core/nodes/ribNode.py @@ -7,7 +7,7 @@ """ import os, sys -from core.mePyQt import QtCore +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore from core.node import Node from core.nodeParam import NodeParam diff --git a/core/nodes/rslNode.py b/core/nodes/rslNode.py index 084aea0..a0395bb 100644 --- a/core/nodes/rslNode.py +++ b/core/nodes/rslNode.py @@ -7,7 +7,7 @@ """ import os, sys -from core.mePyQt import QtCore +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore from core.node import Node from core.nodeParam import NodeParam diff --git a/core/nodes/swatchNode.py b/core/nodes/swatchNode.py index b01a167..5a163de 100644 --- a/core/nodes/swatchNode.py +++ b/core/nodes/swatchNode.py @@ -3,7 +3,7 @@ swatchNode.py """ -from core.mePyQt import QtCore +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore from core.node import Node from core.nodeParam import NodeParam diff --git a/core/swatchInfo.py b/core/swatchInfo.py index 1041322..8126a41 100644 --- a/core/swatchInfo.py +++ b/core/swatchInfo.py @@ -5,7 +5,7 @@ # #=============================================================================== import os, sys -from core.mePyQt import QtCore +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore from global_vars import app_global_vars, DEBUG_MODE from core.node_global_vars import node_global_vars diff --git a/gfx/WorkArea.py b/gfx/WorkArea.py index 2867737..3d44e2b 100644 --- a/gfx/WorkArea.py +++ b/gfx/WorkArea.py @@ -3,7 +3,7 @@ WorkArea.py """ -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from core.signal import Signal from core.meCommon import * @@ -21,7 +21,7 @@ from meShaderEd import app_settings from global_vars import DEBUG_MODE -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -43,7 +43,7 @@ def __init__ ( self, view ) : # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 0x50000 : + if usePySide or usePyQt5 : # self.startNodeConnector = Signal () #QtCore.pyqtSignal ( QtModule.QGraphicsObject, QtCore.QPointF ) self.traceNodeConnector = Signal () #QtCore.pyqtSignal ( QtModule.QGraphicsObject, QtCore.QPointF ) @@ -58,14 +58,14 @@ def __init__ ( self, view ) : self.nodeUpdated = Signal () #QtCore.pyqtSignal ( QtModule.QGraphicsItem ) self.gfxNodeParamChanged = Signal () #QtCore.pyqtSignal ( QtModule.QGraphicsItem, QtCore.QObject ) - + # self.view = view self.connectSignals () # # connectSignals # def connectSignals ( self ) : - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.connect ( self, QtCore.SIGNAL ( 'selectionChanged()' ), self.view.onSelectionChanged ) QtCore.QObject.connect ( self, QtCore.SIGNAL ( 'startNodeLink' ), self.view.onStartNodeLink ) @@ -102,18 +102,17 @@ class WorkArea ( QtModule.QGraphicsView ) : def __init__ ( self ) : # QtModule.QGraphicsView.__init__ ( self ) - # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 0x50000 : + if usePySide or usePyQt5 : # self.selectNodes = Signal () #( list, list ) self.nodeConnectionChanged = Signal () #QtCore.pyqtSignal ( QtModule.QGraphicsObject, QtCore.QObject ) self.gfxNodeAdded = Signal () #( QtModule.QGraphicsObject ) self.gfxNodeRemoved = Signal () #( QtModule.QGraphicsObject ) - # + # self.drawGrid = True self.gridSnap = False self.straightLinks = False @@ -335,7 +334,7 @@ def addGfxNode ( self, node, pos = None ) : #for item in scene.selectedItems (): item.setSelected ( False ) scene.addItem ( gfxNode ) gfxNode.setSelected ( True ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'gfxNodeAdded' ), gfxNode ) else : self.gfxNodeAdded.emit ( gfxNode ) @@ -376,7 +375,7 @@ def onSelectionChanged ( self ) : elif isinstance ( item, GfxSwatchNode ) : self.selectedNodes.append ( item ) elif isinstance ( item, GfxLink ) : self.selectedLinks.append ( item ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'selectNodes' ), self.selectedNodes, self.selectedLinks ) else : self.selectNodes.emit ( self.selectedNodes, self.selectedLinks ) @@ -444,7 +443,7 @@ def onStartNodeLink ( self, connector ): def onTraceNodeLink ( self, connector, scenePos ) : # node = connector.parentItem().node # print ">> WorkArea: onDrawNodeLink from %s (%d %d)" % ( node.label, scenePos.x(), scenePos.y() ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : connectCandidate = self.scene ().itemAt ( scenePos ) else : connectCandidate = self.scene ().itemAt ( scenePos, self.transform () ) @@ -532,7 +531,7 @@ def onEndNodeLink ( self, connector, scenePos ) : self.currentGfxLink.link = link self.nodeNet.addLink ( link ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'nodeConnectionChanged' ), self.currentGfxLink.dstConnector.getGfxNode (), self.currentGfxLink.dstConnector.param ) else : self.nodeConnectionChanged.emit ( self.currentGfxLink.dstConnector.getGfxNode (), self.currentGfxLink.dstConnector.param ) @@ -661,7 +660,7 @@ def onEndNodeConnector ( self, connector, scenePos ) : def onRemoveNode ( self, gfxNode ) : # print ">> WorkArea.onRemoveNode %s (id = %d)" % ( gfxNode.node.label, gfxNode.node.id ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'gfxNodeRemoved' ), gfxNode ) else : self.gfxNodeRemoved.emit ( gfxNode ) @@ -687,7 +686,7 @@ def onRemoveLink ( self, gfxLink ) : #self.emit( QtCore.SIGNAL( 'nodeConnectionChanged' ), srcConnector.parentItem(), srcConnector.param ) if dstConnector is not None : if DEBUG_MODE : print '*** dstConnector.parentItem().node.label = %s ' % dstConnector.getNode ().label - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'nodeConnectionChanged' ), dstConnector.getGfxNode (), dstConnector.param ) else : self.nodeConnectionChanged.emit ( dstConnector.getGfxNode (), dstConnector.param ) @@ -727,7 +726,7 @@ def dragEnterEvent ( self, event ) : # dragMoveEvent # def dragMoveEvent ( self, event ) : - #print ">> WorkArea: onDragMoveEvent" + #print ">> WorkArea.dragMoveEvent" mimedata = event.mimeData () if mimedata.hasFormat ( 'application/x-text' ) or mimedata.hasFormat ( 'text/uri-list' ): event.setDropAction ( QtCore.Qt.CopyAction ) @@ -740,7 +739,7 @@ def dragMoveEvent ( self, event ) : def dropEvent ( self, event ) : # import os - if DEBUG_MODE : print ">> WorkArea.onDropEvent" + if DEBUG_MODE : print ">> WorkArea.dropEvent" file_list = [] mimedata = event.mimeData () @@ -749,14 +748,20 @@ def dropEvent ( self, event ) : data = mimedata.data ( 'application/x-text' ) stream = QtCore.QDataStream ( data, QtCore.QIODevice.ReadOnly ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : filename = QtCore.QString () - stream >> filename else : filename = '' + + if not usePyQt5 : + if usePySide : + filename = stream.readString () + else : + stream >> filename + else : filename = stream.readBytes () - if DEBUG_MODE : print 'itemFilename = %s' % ( filename ) + if DEBUG_MODE : print '* read itemFilename = %s' % ( filename ) file_list.append ( filename ) event.setDropAction ( QtCore.Qt.CopyAction ) @@ -791,7 +796,7 @@ def wheelEvent ( self, event ) : scale = -1.0 if 'linux' in sys.platform: scale = 1.0 import math - if QtCore.QT_VERSION < 0x50000 : + if not usePyQt5 : scaleFactor = math.pow( 2.0, scale * event.delta () / 600.0 ) else : delta = event.angleDelta () diff --git a/gfx/gfxLink.py b/gfx/gfxLink.py index fb5ba80..29ad8d4 100644 --- a/gfx/gfxLink.py +++ b/gfx/gfxLink.py @@ -3,12 +3,12 @@ gfxLink.py """ -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from global_vars import DEBUG_MODE, GFX_LINK_TYPE from meShaderEd import app_settings -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -90,7 +90,7 @@ def remove ( self ) : scene = self.scene () if scene != None : if DEBUG_MODE : print ">> GfxLink::remove emit( onGfxLinkRemoved )" - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : scene.emit ( QtCore.SIGNAL ( 'onGfxLinkRemoved' ), self ) else : scene.onGfxLinkRemoved.emit ( self ) diff --git a/gfx/gfxNode.py b/gfx/gfxNode.py index 5888eac..f406095 100644 --- a/gfx/gfxNode.py +++ b/gfx/gfxNode.py @@ -3,7 +3,7 @@ gfxNode.py """ -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from core.signal import Signal from gfx.gfxNodeLabel import GfxNodeLabel @@ -14,7 +14,7 @@ from meShaderEd import app_settings import gui.ui_settings as UI -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -25,22 +25,12 @@ class GfxNode ( QtModule.QGraphicsItem ) : # QtModule.QGraphicsItem QtModule.QGraphicsItem # Type = GFX_NODE_TYPE - # # __init__ # def __init__ ( self, node ) : # QtModule.QGraphicsItem.__init__ ( self ) - # - # Define signals for PyQt5 - # - if QtCore.QT_VERSION >= 0x50000 : - # - pass - #self.nodeUpdated = Signal () #QtCore.pyqtSignal ( QtModule.QGraphicsItem ) - #self.gfxNodeParamChanged = Signal () #QtCore.pyqtSignal ( QtModule.QGraphicsItem, QtCore.QObject ) - #self.onGfxNodeRemoved = Signal () #QtCore.pyqtSignal ( QtModule.QGraphicsItem ) self.node = node self.header = {} @@ -111,7 +101,7 @@ def __init__ ( self, node ) : # def connectSignals ( self ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.connect ( self.node, QtCore.SIGNAL ( 'nodeUpdated' ), self.onUpdateNode ) QtCore.QObject.connect ( self.node, QtCore.SIGNAL ( 'nodeParamsUpdated' ), self.onUpdateNodeParams ) else : @@ -122,7 +112,7 @@ def connectSignals ( self ) : # def disconnectSignals ( self ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.disconnect ( self.node, QtCore.SIGNAL ( 'nodeUpdated' ), self.onUpdateNode ) QtCore.QObject.disconnect ( self.node, QtCore.SIGNAL ( 'nodeParamsUpdated' ), self.onUpdateNodeParams ) else : @@ -149,11 +139,11 @@ def get_bg_color ( self ) : # # onUpdateNode # - def onUpdateNode ( self ) : + def onUpdateNode ( self, foo_param = None ) : # - if DEBUG_MODE : print '>> GfxNode( %s ).updateNode' % ( self.node.label ) + if DEBUG_MODE : print '>> GfxNode( %s ).onUpdateNode' % ( self.node.label ) self.updateGfxNodeParams ( True ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.scene().emit ( QtCore.SIGNAL ( 'nodeUpdated' ), self ) else : self.scene().nodeUpdated.emit ( self ) @@ -164,7 +154,7 @@ def onUpdateNodeParams ( self, forceUpdate = False ) : # if DEBUG_MODE : print '>> GfxNode( %s ).onUpdateNodeParams' % ( self.node.label ) self.updateGfxNodeParams ( forceUpdate ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.scene().emit ( QtCore.SIGNAL ( 'gfxNodeParamChanged' ), self ) else : self.scene().gfxNodeParamChanged.emit ( self ) @@ -235,7 +225,7 @@ def remove ( self ) : self.disconnectSignals () for connect in self.inputConnectors : connect.removeAllLinks () for connect in self.outputConnectors : connect.removeAllLinks () - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.scene().emit ( QtCore.SIGNAL ( 'onGfxNodeRemoved' ), self ) else : self.scene().onGfxNodeRemoved.emit ( self ) @@ -454,7 +444,7 @@ def updateGfxNodeParamLabel ( self, param, label, forceUpdate = False ) : label.setProcessEvents ( True ) if forceUpdate : self.update () - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.scene().emit ( QtCore.SIGNAL ( 'gfxNodeParamChanged' ), self, param ) else : self.gfxNodeParamChanged.emit ( self, param ) @@ -550,13 +540,12 @@ def adjustLinks ( self ) : # # itemChange # - def itemChange ( self, change, value ) : # if change == QtModule.QGraphicsItem.ItemSelectedHasChanged : #ItemSelectedChange: QGraphicsItem if self.node.type != 'variable' : # variable node has not header - #if QtCore.QT_VERSION < 0x50000 : + #if not usePyQt5 : # self.header [ 'label' ].setSelected ( value.toBool () ) #else : self.header [ 'label' ].setSelected ( value ) diff --git a/gfx/gfxNodeConnector.py b/gfx/gfxNodeConnector.py index f637455..6e1560c 100644 --- a/gfx/gfxNodeConnector.py +++ b/gfx/gfxNodeConnector.py @@ -4,14 +4,14 @@ """ import copy -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from core.signal import Signal from meShaderEd import app_settings from global_vars import DEBUG_MODE, GFX_NODE_CONNECTOR_TYPE import gui.ui_settings as UI -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -28,7 +28,6 @@ class GfxNodeConnector ( QtModule.QGraphicsItem ) : #QtModule.QGraphicsItem # def __init__ ( self, param = None, radius = UI.CONNECTOR_RADIUS, isRound = True, node = None ) : # - #QtModule.QGraphicsItem.__init__ ( self ) QtModule.QGraphicsItem.__init__ ( self ) self.paramsBrushes = { 'c' : QtGui.QBrush ( QtGui.QColor ( QtCore.Qt.darkRed ) ) @@ -73,10 +72,6 @@ def __init__ ( self, param = None, radius = UI.CONNECTOR_RADIUS, isRound = True, paramTypeStr = self.getInputParam ().encodedTypeStr () if paramTypeStr in self.paramsBrushes.keys () : self.brush = self.paramsBrushes [ paramTypeStr ] - - #self.setFlag ( QtGui.QGraphicsItem.ItemIsSelectable ) - #if DEBUG_MODE : print '>> GfxNodeConnector::__init__' - #if DEBUG_MODE : print self # self.startNodeLink.connect ( self.onStartNodeLinkTest ) # @@ -337,8 +332,6 @@ def getScene ( self ) : def itemChange ( self, change, value ) : # #if DEBUG_MODE : print ">> itemChanged " - #if DEBUG_MODE : print change - #if DEBUG_MODE : print value if change == QtModule.QGraphicsItem.ItemSelectedHasChanged : #if DEBUG_MODE : print "* selection " self.isNodeSelected = ( value == 1 ) #value.toBool () @@ -360,21 +353,12 @@ def itemChange ( self, change, value ) : x -= ( x % grid_size ) y -= ( y % grid_size ) self.setPos ( x, y ) - #if DEBUG_MODE : print '* GfxNode.itemChange = ItemPositionHasChanged (%f, %f)' % ( x, y ) self.node.offset = ( x, y ) self.adjustLinks () #return QtCore.QPointF ( x, y ) - - #elif change == QtModule.QGraphicsItem.ItemParentChange : - #if DEBUG_MODE : print "* parent " - # return value - #else : - # if DEBUG_MODE : print "* nothing " - # return value return QtModule.QGraphicsItem.itemChange ( self, change, value ) - # # hilite # @@ -385,7 +369,6 @@ def hilite ( self, state ) : # # onStartNodeLinkTest # - @QtCore.pyqtSlot ( QtModule.QGraphicsItem ) # QtModule.QGraphicsItem QtModule.QGraphicsItem def onStartNodeLinkTest ( self, connector ) : # if DEBUG_MODE : print '>> onStartNodeLinkTest' @@ -402,7 +385,7 @@ def mousePressEvent ( self, event ) : if event.modifiers () == QtCore.Qt.ControlModifier : # start new ConnectorNode self.state = 'traceNodeConnector' - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.getScene ().emit ( QtCore.SIGNAL ( 'startNodeConnector' ), self, event.scenePos () ) else : self.getScene ().startNodeConnector.emit ( self, event.scenePos () ) @@ -410,7 +393,7 @@ def mousePressEvent ( self, event ) : if not self.isNode () : # start new link self.state = 'traceNodeLink' - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.getScene ().emit ( QtCore.SIGNAL ( 'startNodeLink' ), self ) else : #if DEBUG_MODE : print '* startNodeLink.emit ' @@ -427,12 +410,12 @@ def mousePressEvent ( self, event ) : def mouseMoveEvent ( self, event ) : #print ">> mouseMoveEvent at %d %d" % ( event.scenePos().x(), event.scenePos().y() ) if self.state == 'traceNodeLink' : - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.getScene ().emit ( QtCore.SIGNAL ( 'traceNodeLink' ), self, event.scenePos () ) else : self.getScene ().traceNodeLink.emit ( self, event.scenePos () ) elif self.state == 'traceNodeConnector' : - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.getScene ().emit ( QtCore.SIGNAL ( 'traceNodeConnector' ), self, event.scenePos () ) else : self.getScene ().traceNodeConnector.emit ( self, event.scenePos () ) @@ -446,12 +429,12 @@ def mouseMoveEvent ( self, event ) : def mouseReleaseEvent ( self, event ) : #print ">> mouseReleaseEvent" if self.state == 'traceNodeLink' : - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.getScene ().emit ( QtCore.SIGNAL ( 'endNodeLink' ), self, event.scenePos () ) else : self.getScene ().endNodeLink.emit ( self, event.scenePos () ) elif self.state == 'traceNodeConnector' : - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.getScene ().emit ( QtCore.SIGNAL ( 'endNodeConnector' ), self, event.scenePos () ) else : self.getScene ().endNodeConnector.emit ( self, event.scenePos () ) diff --git a/gfx/gfxNodeLabel.py b/gfx/gfxNodeLabel.py index 2bf2c61..13dd5a5 100644 --- a/gfx/gfxNodeLabel.py +++ b/gfx/gfxNodeLabel.py @@ -3,12 +3,12 @@ gfxNodeLabel.py """ -from core.mePyQt import Qt, QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from global_vars import app_colors, DEBUG_MODE, GFX_NODE_LABEL_TYPE from meShaderEd import app_settings -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/gfx/gfxNote.py b/gfx/gfxNote.py index e1d4c17..2b8dd18 100644 --- a/gfx/gfxNote.py +++ b/gfx/gfxNote.py @@ -3,14 +3,14 @@ gfxNote.py """ -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from gfx.gfxNodeLabel import GfxNodeLabel from global_vars import DEBUG_MODE, GFX_NOTE_TYPE from meShaderEd import app_settings -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -89,8 +89,8 @@ def type ( self ) : return GfxNote.Type # def remove ( self ) : # - if DEBUG_MODE : print '>> GfxNote remove gfxNode (temp)' - if QtCore.QT_VERSION < 0x50000 : + if DEBUG_MODE : print '>> GfxNote.remove' + if usePyQt4 : self.scene().emit ( QtCore.SIGNAL ( 'onGfxNodeRemoved' ), self ) else : self.scene().onGfxNodeRemoved.emit ( self ) @@ -106,10 +106,13 @@ def updateNodeLabel ( self ) : # updateGfxNode # def updateGfxNode ( self ) : + if DEBUG_MODE : print '>> GfxNote( %s ).updateGfxNode' % ( self.node.label ) # remove all children - for item in self.childItems () : self.scene ().removeItem ( item ) + for item in self.childItems () : + self.scene ().removeItem ( item ) self.setupParameters () self.setupGeometry () + self.update () # # setupParameters # @@ -233,7 +236,7 @@ def itemChange ( self, change, value ) : # paint # def paint ( self, painter, option, widget ) : - # print ( ">> GfxNode.paint" ) + #print ( ">> GfxNode.paint" ) painter.setRenderHint ( QtGui.QPainter.Antialiasing ) painter.setRenderHint ( QtGui.QPainter.SmoothPixmapTransform ) diff --git a/gfx/gfxSwatchNode.py b/gfx/gfxSwatchNode.py index 8a595b1..c5ad68a 100644 --- a/gfx/gfxSwatchNode.py +++ b/gfx/gfxSwatchNode.py @@ -3,7 +3,7 @@ gfxSwatchNode.py """ -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from gfx.gfxNodeLabel import GfxNodeLabel from gfx.gfxNodeConnector import GfxNodeConnector @@ -13,7 +13,7 @@ from meShaderEd import app_settings import gui.ui_settings as UI -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -85,7 +85,7 @@ def __init__ ( self, node = None, swatchSize = UI.SWATCH_SIZE ) : def connectSignals ( self ) : # if self.scene () is not None : - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.connect ( self.scene (), QtCore.SIGNAL ( 'updateSwatch' ), self.updateSwatch ) else : self.scene ().updateSwatch.connect ( self.updateSwatch ) @@ -95,7 +95,7 @@ def connectSignals ( self ) : def disconnectSignals ( self ) : # if self.scene () is not None : - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.disconnect ( self.scene (), QtCore.SIGNAL ( 'updateSwatch' ), self.updateSwatch ) else : self.scene ().updateSwatch.disconnect ( self.updateSwatch ) @@ -110,7 +110,7 @@ def remove ( self ) : # if DEBUG_MODE : print '>> GfxSwatchNode.remove' for connect in self.inputConnectors : connect.removeAllLinks () - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.scene().emit ( QtCore.SIGNAL ( 'onGfxNodeRemoved' ), self ) else : self.scene().onGfxNodeRemoved.emit ( self ) diff --git a/gfx/imageView.py b/gfx/imageView.py index 5677e7f..0d73097 100644 --- a/gfx/imageView.py +++ b/gfx/imageView.py @@ -3,10 +3,10 @@ imageView.py """ -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from core.signal import Signal -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -25,32 +25,25 @@ def __init__ ( self, parent ) : # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 0x50000 : + if usePySide or usePyQt5 : # self.mouseDoubleClickSignal = Signal () - + # self.state = 'idle' self.panStartPos = None - self.pixmap = None - # set scene scene = QtModule.QGraphicsScene ( self ) - scene.setSceneRect ( 0, 0, 256, 256 ) #scene.setItemIndexMethod ( QtGui.QGraphicsScene.NoIndex ) self.setScene ( scene ) - # qt graphics stuff #self.setCacheMode ( QtGui.QGraphicsView.CacheBackground ) self.setRenderHint ( QtGui.QPainter.Antialiasing ) - self.setTransformationAnchor ( QtModule.QGraphicsView.AnchorUnderMouse ) self.setResizeAnchor ( QtModule.QGraphicsView.AnchorViewCenter ) self.setDragMode ( QtModule.QGraphicsView.RubberBandDrag ) - self.setMouseTracking ( False ) - self.BgBrush = QtGui.QBrush ( QtGui.QColor ( 128, 128, 128 ) ) # # keyPressEvent @@ -70,7 +63,7 @@ def wheelEvent ( self, event ) : scale = -1.0 if 'linux' in sys.platform: scale = 1.0 import math - if QtCore.QT_VERSION < 0x50000 : + if not usePyQt5 : scaleFactor = math.pow( 2.0, scale * event.delta() / 600.0 ) else : delta = event.angleDelta () @@ -99,7 +92,7 @@ def mousePressEvent ( self, event ) : def mouseDoubleClickEvent ( self, event ) : # #print ">> ImageView.mouseDoubleClickEvent" - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'mouseDoubleClickSignal' ) ) else : self.mouseDoubleClickSignal.emit () diff --git a/global_vars.py b/global_vars.py index ac11336..ee5456a 100644 --- a/global_vars.py +++ b/global_vars.py @@ -1,9 +1,9 @@ # # global_vars.py # -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/gui/MainWindow.py b/gui/MainWindow.py index df6d45f..30fe675 100644 --- a/gui/MainWindow.py +++ b/gui/MainWindow.py @@ -3,7 +3,7 @@ MainWindow.py """ -from core.mePyQt import QtCore, QtGui, QtXml +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui, QtXml from core.signal import Signal #from PyQt4.QtGui import QWhatsThis from global_vars import app_global_vars, DEBUG_MODE, VALID_RIB_NODE_TYPES, VALID_RSL_NODE_TYPES, VALID_RSL_SHADER_TYPES @@ -27,11 +27,11 @@ from meShaderEd import app_settings #from meShaderEd import app_renderer -from meShaderEd import getDefaultValue +from meShaderEd import getDefaultValue, setDefaultValue, createDefaultProject, openDefaultProject from ui_MainWindow import Ui_MainWindow -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -60,13 +60,35 @@ def __init__ ( self ) : self.clipboard = QtModule.QApplication.clipboard () - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.recentProjects = app_settings.value ( 'RecentProjects' ).toStringList () self.recentNetworks = app_settings.value ( 'RecentNetworks' ).toStringList () - self.addRecentProject ( app_global_vars [ 'ProjectPath' ] ) else : - # should be fixed !!! - pass + self.recentProjects = [] + self.recentNetworks = [] + + recentProjects = app_settings.value ( 'RecentProjects' ) + if recentProjects is not None : + if isinstance ( recentProjects, list ) : + for proj in recentProjects : + self.recentProjects.append ( proj ) + else : + self.recentProjects.append ( recentProjects ) + + recentNetworks = app_settings.value ( 'RecentNetworks' ) + if recentNetworks is not None : + if isinstance ( recentNetworks, list ) : + for network in recentNetworks : + self.recentNetworks.append ( network ) + else : + self.recentNetworks.append ( recentNetworks ) + + print '* recentProjects =', self.recentProjects + print '* recentNetworks =', self.recentNetworks + + print '* ProjectPath =', app_global_vars [ 'ProjectPath' ] + + self.addRecentProject ( app_global_vars [ 'ProjectPath' ] ) self.setupMenuBar () self.setupPanels () @@ -107,7 +129,7 @@ def __init__ ( self ) : # def connectSignals ( self ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.connect ( self.ui.actionHelpMode, QtCore.SIGNAL ( 'toggled(bool)' ), self.onHelpMode ) QtCore.QObject.connect ( self.ui.nodeList_ctl.ui.nodeList, QtCore.SIGNAL ( 'setActiveNodeList' ), self.setActiveNodeList ) QtCore.QObject.connect ( self.ui.project_ctl.ui.nodeList, QtCore.SIGNAL ( 'setActiveNodeList' ), self.setActiveNodeList ) @@ -134,7 +156,7 @@ def connectSignals ( self ) : # def connectWorkAreaSignals ( self ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : if self.workArea != None : if self.activeNodeList != None : QtCore.QObject.connect ( self.activeNodeList, QtCore.SIGNAL ( 'addNode' ), self.workArea.insertNodeNet ) @@ -161,7 +183,7 @@ def connectWorkAreaSignals ( self ) : # def disconnectWorkAreaSignals ( self ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : if self.workArea != None : if self.activeNodeList != None : QtCore.QObject.disconnect ( self.activeNodeList, QtCore.SIGNAL ( 'addNode' ), self.workArea.insertNodeNet ) @@ -220,10 +242,10 @@ def setupMenuBar ( self ) : # def buildRecentProjectsMenu ( self ) : # - if QtCore.QT_VERSION < 0x50000 : - self.recentProjects = app_settings.value ( 'RecentProjects' ).toStringList () - print '>> self.recentProjects:' - print self.recentProjects + print '>> buildRecentProjectsMenu ...' + if usePyQt4 : + #self.recentProjects = app_settings.value ( 'RecentProjects' ).toStringList () + print '>> self.recentProjects:', self.recentProjects self.ui.menuRecent_Projects.clear () if len ( self.recentProjects ) : icon = QtGui.QIcon.fromTheme ( 'folder', QtGui.QIcon ( ':/file_icons/resources/open.png' ) ) @@ -235,15 +257,25 @@ def buildRecentProjectsMenu ( self ) : self.connect ( action, QtCore.SIGNAL ( 'triggered()' ), self.onOpenRecentProject ) self.ui.menuRecent_Projects.addAction ( action ) else : - # should be fixed !!! - pass + #self.recentProjects = app_settings.value ( 'RecentProjects' ) + print '>> self.recentProjects:', self.recentProjects + self.ui.menuRecent_Projects.clear () + if len ( self.recentProjects ) : + icon = QtGui.QIcon.fromTheme ( 'folder', QtGui.QIcon ( ':/file_icons/resources/open.png' ) ) + # QtGui.QIcon ( ':/file_icons/resources/recentFile.png' ) 'folder' + for i, fname in enumerate ( self.recentProjects ) : + # QtCore.QFileInfo ( fname ).fileName () + action = QtModule.QAction ( icon, '&%d %s' % ( i + 1, fname ), self ) + action.setData ( fname ) + action.triggered.connect ( self.onOpenRecentProject ) + self.ui.menuRecent_Projects.addAction ( action ) # # buildRecentNetworksMenu # def buildRecentNetworksMenu ( self ) : # - if QtCore.QT_VERSION < 0x50000 : - self.recentNetworks = app_settings.value ( 'RecentNetworks' ).toStringList () + if usePyQt4 : + #self.recentNetworks = app_settings.value ( 'RecentNetworks' ).toStringList () self.ui.menuRecent_Networks.clear () if len ( self.recentNetworks ) : for i, fname in enumerate ( self.recentNetworks ) : @@ -254,8 +286,16 @@ def buildRecentNetworksMenu ( self ) : self.connect ( action, QtCore.SIGNAL ( 'triggered()' ), self.onOpenRecentNetwork ) self.ui.menuRecent_Networks.addAction ( action ) else : - # should be fixed !!! - pass + #self.recentNetworks = app_settings.value ( 'RecentNetworks' ) + self.ui.menuRecent_Networks.clear () + if len ( self.recentNetworks ) : + for i, fname in enumerate ( self.recentNetworks ) : + icon = QtGui.QIcon.fromTheme ( 'document-new', QtGui.QIcon ( ':/file_icons/resources/new.png' ) ) + # QtCore.QFileInfo ( fname ).fileName () + action = QtModule.QAction ( icon, '&%d %s' % ( i + 1, fname ), self ) + action.setData ( fname ) + action.triggered.connect ( self.onOpenRecentNetwork ) + self.ui.menuRecent_Networks.addAction ( action ) # # setupPanels # @@ -283,41 +323,46 @@ def setupPanels ( self ) : # def addRecentProject ( self, project ) : # + print '>> addRecentProject ', project if project is not None : - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : recent_projects_max = getDefaultValue ( app_settings, '', 'recent_projects_max' ) - if project not in self.recentProjects : self.recentProjects.prepend ( QtCore.QString ( project ) ) - while self.recentProjects.count () > recent_projects_max : self.recentProjects.takeLast () - recentProjects = QtCore.QVariant ( self.recentProjects ) if self.recentProjects else QtCore.QVariant () app_settings.setValue ( 'RecentProjects', recentProjects ) else : - # should be fixed !!! - pass + recent_projects_max = getDefaultValue ( app_settings, '', 'recent_projects_max' ) + if project not in self.recentProjects : + self.recentProjects.insert ( 0, project ) + while len ( self.recentProjects ) > recent_projects_max : + self.recentProjects.pop () + app_settings.setValue ( 'RecentProjects', self.recentProjects ) + print '* project added recentProjects =', self.recentProjects + print '* recentProjects =', self.recentProjects # # addRecentNetwork # def addRecentNetwork ( self, network ) : # if network is not None : - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : recent_networks_max = getDefaultValue ( app_settings, '', 'recent_networks_max' ) - if network not in self.recentNetworks : self.recentNetworks.prepend ( QtCore.QString ( network ) ) - while self.recentNetworks.count () > recent_networks_max : self.recentNetworks.takeLast () - recentNetworks = QtCore.QVariant ( self.recentNetworks ) if self.recentNetworks else QtCore.QVariant () app_settings.setValue ( 'RecentNetworks', recentNetworks ) else : - # should be fixed !!! - pass + recent_networks_max = getDefaultValue ( app_settings, '', 'recent_networks_max' ) + if network not in self.recentNetworks : + self.recentNetworks.insert ( 0, network ) + while len ( self.recentNetworks ) > recent_networks_max : + self.recentNetworks.pop () + app_settings.setValue ( 'RecentNetworks', self.recentNetworks ) # # setupActions # @@ -390,7 +435,7 @@ def onRenderSettings ( self ) : self.RendererPreset = copy.deepcopy ( app_global_vars [ 'RendererPreset' ] ) if DEBUG_MODE : print ( ':: self.RendererPreset.getCurrentPresetName = %s' % self.RendererPreset.getCurrentPresetName () ) renderSettingsDlg = meRendererSetup ( self.RendererPreset ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.connect ( renderSettingsDlg, QtCore.SIGNAL ( 'presetChanged' ), self.onRenderPresetChanged ) QtCore.QObject.connect ( renderSettingsDlg, QtCore.SIGNAL ( 'savePreset' ), self.onRenderPresetSave ) else : @@ -472,7 +517,7 @@ def onStraightLinks ( self, check ) : def setActiveNodeList ( self, nodeList ) : # if DEBUG_MODE : print '>> MainWindow.setActiveNodeList' - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : if self.activeNodeList != None : QtCore.QObject.disconnect ( self.activeNodeList, QtCore.SIGNAL ( 'addNode' ), self.workArea.insertNodeNet ) self.activeNodeList = nodeList @@ -676,8 +721,8 @@ def onSelectGfxNodes ( self, gfxNodes = [], gfxLinks = [] ) : # self.setupActions () self.workArea.inspectedNode = None - if len ( gfxNodes ) == 1 : self.workArea.inspectedNode = gfxNodes[ 0 ] - + if len ( gfxNodes ) == 1 : + self.workArea.inspectedNode = gfxNodes[ 0 ] self.ui.nodeParam_ctl.setNode ( self.workArea.inspectedNode ) # # onNodeLabelChanged @@ -699,7 +744,7 @@ def onNodeParamChanged ( self, gfxNode, param ) : # from WorkArea we have GfxNode in signal nodeConnectionChanged # hence need to update nodeParam_ctl if isinstance ( gfxNode, GfxNote ) : - #if DEBUG_MODE : print "* update GfxNote" + if DEBUG_MODE : print "* update GfxNote" gfxNode.updateGfxNode () #node.update () self.workArea.scene ().update () @@ -713,7 +758,6 @@ def onNodeParamChanged ( self, gfxNode, param ) : if DEBUG_MODE : print "* update GfxNode" gfxNode.updateGfxNode ( removeLinks = False ) self.updateNodeParamView () - if self.ui.imageView_ctl.autoUpdate () : self.ui.imageView_ctl.updateViewer() # # onGxNodeParamChanged @@ -791,8 +835,8 @@ def onTabCloseRequested ( self, idx ) : # # onNew # - @QtCore.pyqtSlot () - def onNew ( self, tabName = 'untitled' ) : + # @QtCore.pyqtSlot () + def onNew ( self, foo_param=None, tabName = 'untitled' ) : # def tabNameExists ( self, name ) : ret = False @@ -842,7 +886,7 @@ def onOpen ( self ) : # curDir = app_global_vars [ 'ProjectNetworks' ] typeFilter = 'Shader networks *.xml;;All files *.*;;' - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : filename = str ( QtGui.QFileDialog.getOpenFileName ( self, "Open file", curDir, typeFilter ) ) else : (filename, filter) = QtModule.QFileDialog.getOpenFileName ( self, "Open file", curDir, typeFilter ) @@ -879,24 +923,33 @@ def openNetwork ( self, filename ) : def onOpenRecentNetwork ( self ) : # action = self.sender () - if isinstance ( action, QtGui.QAction ): - network = unicode ( action.data ().toString () ) + if isinstance ( action, QtModule.QAction ): + if usePyQt4 : + network = unicode ( action.data ().toString () ) + else : + network = action.data () if network is not None : if DEBUG_MODE : print '>> onOpenRecentNetwork : %s' % network if not self.openNetwork ( network ) : - # TODO!!! remove network from rescentNetworks - pass + if usePyQt4 : + self.recentNetworks.removeAll ( network ) + else : + self.recentNetworks.remove ( network ) # # onOpenRecentProject # def onOpenRecentProject ( self ) : # action = self.sender () - if isinstance ( action, QtGui.QAction ): - project = unicode ( action.data ().toString () ) + if isinstance ( action, QtModule.QAction ): + if usePyQt4 : + project = unicode ( action.data ().toString () ) + else : + project = action.data () if project is not None : print '>> onOpenRecentProject : %s' % project - if openDefaultProject ( app_settings, app_global_vars, project ) : + project_filename = getDefaultValue ( app_settings, '', 'project_filename' ) + if openDefaultProject ( app_settings, app_global_vars, project, project_filename ) : # very strange... app_settings doesn't update inside meCommon.openDefaultProject... # though app_global_vars does # have to duplicate this action here... @@ -910,7 +963,10 @@ def onOpenRecentProject ( self ) : self.setupWindowTitle () else : print "ERROR! project %s doesn't exist" % project - # TODO!!! remove project from rescentProjects + if usePyQt4 : + self.recentProjects.removeAll ( network ) + else : + self.recentProjects.remove ( network ) # # onImport # @@ -921,7 +977,7 @@ def onImport ( self ) : curDir = app_global_vars [ 'ProjectNetworks' ] typeFilter = 'Shader networks *.xml;;All files *.*;;' - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : filename = str ( QtModule.QFileDialog.getOpenFileName ( self, "Import file", curDir, typeFilter ) ) else : (filename, filter) = QtModule.QFileDialog.getOpenFileName ( self, "Import file", curDir, typeFilter ) @@ -940,7 +996,7 @@ def onSaveSelected ( self ) : saveName = os.path.join ( curDir, self.workArea.nodeNet.name + '.xml' ) typeFilter = 'Shader networks *.xml;;All files *.*;;' - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : filename = str( QtModule.QFileDialog.getSaveFileName ( self, "Save file as", saveName, typeFilter ) ) else : (filename, filter) = QtModule.QFileDialog.getSaveFileName ( self, "Save file as", saveName, typeFilter ) @@ -986,7 +1042,7 @@ def onSaveAs ( self ) : curDir = app_global_vars [ 'ProjectNetworks' ] saveName = os.path.join ( curDir, self.workArea.nodeNet.name + '.xml' ) typeFilter = 'Shader networks *.xml;;All files *.*;;' - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : filename = str( QtModule.QFileDialog.getSaveFileName ( self, "Save file as", saveName, typeFilter ) ) else : (filename, filter) = QtModule.QFileDialog.getSaveFileName ( self, "Save file as", saveName, typeFilter ) diff --git a/gui/ProjectSetup.py b/gui/ProjectSetup.py index 3ca023d..e0b68ce 100644 --- a/gui/ProjectSetup.py +++ b/gui/ProjectSetup.py @@ -8,14 +8,14 @@ Dialog for managing project directories """ -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from core.meCommon import * from global_vars import app_global_vars from ui_projectSetup import Ui_ProjectSetup -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -32,7 +32,10 @@ def __init__ ( self, app_settings ): QtModule.QDialog.__init__ ( self ) self.app_settings = app_settings - self.rootDir = str ( self.app_settings.value ( 'project' ).toString () ) + if usePyQt4 : + self.rootDir = str ( self.app_settings.value ( 'project' ).toString () ) + else : + self.rootDir = self.app_settings.value ( 'project' ) self.buildGui () # # buildGui @@ -51,7 +54,7 @@ def buildGui ( self ): self.ui.lineEdit_project.setText ( self.rootDir ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.ui.lineEdit_network.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'shader_networks' ).toString () ) ) ) self.ui.lineEdit_sources.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'shader_sources' ).toString () ) ) ) self.ui.lineEdit_shaders.setText ( toRelativePath ( self.rootDir, str ( self.app_settings.value ( 'project_shaders' ).toString () ) ) ) diff --git a/gui/SettingsSetup.py b/gui/SettingsSetup.py index 1f9007c..40fdc2c 100644 --- a/gui/SettingsSetup.py +++ b/gui/SettingsSetup.py @@ -8,14 +8,14 @@ # #=============================================================================== -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from core.meCommon import * from global_vars import app_global_vars from ui_settingsSetup import Ui_SettingsSetup -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -49,7 +49,7 @@ def buildGui ( self ): ##else : ## font.setPointSize(10) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.ui.lineEdit_temp.setText( self.app_settings.value('temp').toString() ) self.ui.lineEdit_inc.setText( self.app_settings.value('include').toString() ) self.ui.lineEdit_lib.setText( self.app_settings.value('lib').toString() ) diff --git a/gui/ViewComputedCodeDialog.py b/gui/ViewComputedCodeDialog.py index bf2bc93..f493a24 100644 --- a/gui/ViewComputedCodeDialog.py +++ b/gui/ViewComputedCodeDialog.py @@ -8,14 +8,14 @@ Dialog for managing node code """ -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from global_vars import app_global_vars, DEBUG_MODE, VALID_RIB_NODE_TYPES, VALID_RSL_NODE_TYPES, VALID_RSL_SHADER_TYPES from nodeEditor.nodeCodeEditor import NodeCodeEditor from ui_viewComputedCodeDialog import Ui_ViewComputedCodeDialog -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/gui/exportShader/ExportShaderDialog.py b/gui/exportShader/ExportShaderDialog.py index 9d66bb6..99916af 100644 --- a/gui/exportShader/ExportShaderDialog.py +++ b/gui/exportShader/ExportShaderDialog.py @@ -7,7 +7,7 @@ Dialog for export node as SL shader """ -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from core.signal import Signal #from PyQt4.QtCore import QVariant @@ -21,7 +21,7 @@ from ui_exportShaderDialog import Ui_ExportShaderDialog -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -57,7 +57,7 @@ def __init__ ( self, node ) : # def connectSignals ( self ) : # QtCore.QObject - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.connect ( self.ui.list_nodes, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onNodeChanged ) QtCore.QObject.connect ( self.ui.list_inputs, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onInputParamChanged ) QtCore.QObject.connect ( self.ui.list_outputs, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onOutputParamChanged ) @@ -84,7 +84,7 @@ def connectSignals ( self ) : # def disconnectSignals ( self ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.disconnect ( self.ui.list_nodes, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onNodeChanged ) QtCore.QObject.disconnect ( self.ui.list_inputs, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onInputParamChanged ) QtCore.QObject.disconnect ( self.ui.list_outputs, QtCore.SIGNAL ( 'itemSelectionChanged()' ), self.onOutputParamChanged ) @@ -197,7 +197,7 @@ def onNodeChanged ( self ) : if DEBUG_MODE : print '>> ExportShaderDialog.onNodeChanged' self.disconnectSignals () item = self.ui.list_nodes.currentItem () - if QtCore.QT_VERSION < 0x50000 : + if not usePyQt5 : node = item.data ( QtCore.Qt.UserRole + 1 ).toPyObject () else : node = item.data ( QtCore.Qt.UserRole + 1 ) @@ -244,7 +244,7 @@ def onInputParamChanged ( self ) : # if DEBUG_MODE : print '>> ExportShaderDialog.onInputParamChanged' item = self.ui.list_inputs.currentItem () - if QtCore.QT_VERSION < 0x50000 : + if not usePyQt5 : param = item.data ( QtCore.Qt.UserRole + 1 ).toPyObject () node = item.data ( QtCore.Qt.UserRole + 2 ).toPyObject () else : @@ -261,7 +261,7 @@ def onOutputParamChanged ( self ) : # if DEBUG_MODE : print '>> ExportShaderDialog.onOutputParamChanged' item = self.ui.list_outputs.currentItem () - if QtCore.QT_VERSION < 0x50000 : + if not usePyQt5 : param = item.data ( QtCore.Qt.UserRole + 1 ).toPyObject () node = item.data ( QtCore.Qt.UserRole + 2 ).toPyObject () else : @@ -288,7 +288,7 @@ def onRenameNodeLabel ( self, oldName, newName ) : editNode = self.ui.node.editNode for i in range ( self.ui.list_nodes.count () ) : item = self.ui.list_nodes.item ( i ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : node = item.data ( QtCore.Qt.UserRole + 1 ).toPyObject () else : node = item.data ( QtCore.Qt.UserRole + 1 ) @@ -321,7 +321,7 @@ def onExport ( self ) : import os saveName = os.path.join ( app_global_vars [ 'ProjectSources' ], self.editNode.getInstanceName () + '.sl' ) typeFilter = 'Shader source files *.sl;;All files *.*;;' - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : filename = str( QtModule.QFileDialog.getSaveFileName ( self, "Export shader code as", saveName, typeFilter ) ) else : ( filename, filter ) = QtModule.QFileDialog.getSaveFileName ( self, "Export shader code as", saveName, typeFilter ) diff --git a/gui/exportShader/ui_exportShaderDialog.py b/gui/exportShader/ui_exportShaderDialog.py index c7d6d64..a73f7c4 100644 --- a/gui/exportShader/ui_exportShaderDialog.py +++ b/gui/exportShader/ui_exportShaderDialog.py @@ -7,10 +7,10 @@ # # WARNING! All changes made in this file will be lost! -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from core.signal import Signal -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -65,8 +65,7 @@ def setupUi(self, ExportShaderDialog): self.tab = QtModule.QWidget() self.tab.setObjectName(_fromUtf8("tab")) self.gridLayout = QtModule.QGridLayout(self.tab) - if QtCore.QT_VERSION < 0x50000 : - self.gridLayout.setMargin(2) + self.gridLayout.setContentsMargins ( 2, 2, 2, 2 ) self.gridLayout.setSpacing(2) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) self.list_nodes = QtModule.QListWidget(self.tab) @@ -80,8 +79,7 @@ def setupUi(self, ExportShaderDialog): self.tab_inputs.setObjectName(_fromUtf8("tab_inputs")) self.gridLayout_2 = QtModule.QGridLayout(self.tab_inputs) - if QtCore.QT_VERSION < 0x50000 : - self.gridLayout_2.setMargin(2) + self.gridLayout_2.setContentsMargins ( 2, 2, 2, 2 ) self.gridLayout_2.setSpacing(2) self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) self.list_inputs = QtModule.QListWidget(self.tab_inputs) @@ -91,8 +89,7 @@ def setupUi(self, ExportShaderDialog): self.tab_outputs = QtModule.QWidget() self.tab_outputs.setObjectName(_fromUtf8("tab_outputs")) self.gridLayout_3 = QtModule.QGridLayout(self.tab_outputs) - if QtCore.QT_VERSION < 0x50000 : - self.gridLayout_3.setMargin(2) + self.gridLayout_3.setContentsMargins ( 2, 2, 2, 2 ) self.gridLayout_3.setSpacing(2) self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3")) self.list_outputs = QtModule.QListWidget(self.tab_outputs) @@ -104,8 +101,7 @@ def setupUi(self, ExportShaderDialog): self.tab_prop_node = QtModule.QWidget() self.tab_prop_node.setObjectName(_fromUtf8("tab_prop_node")) self.gridLayout_4 = QtModule.QGridLayout(self.tab_prop_node) - if QtCore.QT_VERSION < 0x50000 : - self.gridLayout_4.setMargin(2) + self.gridLayout_4.setContentsMargins ( 2, 2, 2, 2 ) self.gridLayout_4.setSpacing(2) self.gridLayout_4.setObjectName(_fromUtf8("gridLayout_4")) self.node = NodePropertiesEditor(self.tab_prop_node) @@ -115,8 +111,7 @@ def setupUi(self, ExportShaderDialog): self.tab_prop_param = QtModule.QWidget() self.tab_prop_param.setObjectName(_fromUtf8("tab_prop_param")) self.gridLayout_5 = QtModule.QGridLayout(self.tab_prop_param) - if QtCore.QT_VERSION < 0x50000 : - self.gridLayout_5.setMargin(2) + self.gridLayout_5.setContentsMargins ( 2, 2, 2, 2 ) self.gridLayout_5.setSpacing(2) self.gridLayout_5.setObjectName(_fromUtf8("gridLayout_5")) self.param = NodeParamEditor(self.tab_prop_param) @@ -131,7 +126,7 @@ def setupUi(self, ExportShaderDialog): self.node_tabWidget.setCurrentIndex(0) self.params_tabWidget.setCurrentIndex(0) self.prop_tabWidget.setCurrentIndex(0) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.connect(self.btn_export, QtCore.SIGNAL(_fromUtf8("clicked()")), ExportShaderDialog.onExport) QtCore.QObject.connect(self.btn_close, QtCore.SIGNAL(_fromUtf8("clicked()")), ExportShaderDialog.reject) QtCore.QObject.connect(self.btn_view, QtCore.SIGNAL(_fromUtf8("clicked()")), ExportShaderDialog.onViewCode) diff --git a/gui/imageViewWidget.py b/gui/imageViewWidget.py index 1faa592..81b5507 100644 --- a/gui/imageViewWidget.py +++ b/gui/imageViewWidget.py @@ -3,7 +3,7 @@ imageViewWidget.py """ -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from core.signal import Signal #from PyQt4.QtCore import QDir, QString, QModelIndex @@ -16,7 +16,7 @@ from core.node import Node from core.nodeLibrary import NodeLibrary -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -44,7 +44,7 @@ def __init__ ( self ) : #self.ui.treeView.setDragEnabled ( True ) #self.ui.treeView.setRootIsDecorated( True ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.connect ( self.ui.imageArea, QtCore.SIGNAL ( 'mouseDoubleClickSignal' ), self.updateViewer ) QtCore.QObject.connect ( self.ui.selector, QtCore.SIGNAL ( 'currentIndexChanged(int)' ), self.onViewerChanged ) else : @@ -101,7 +101,7 @@ def onViewerChanged ( self, idx ) : # # updateViewer # - @QtCore.pyqtSlot () + #@QtCore.pyqtSlot () def updateViewer ( self, compute = True ) : # print ">> ImageViewWidget.updateViewer compute = %d" % compute diff --git a/gui/meRendererSetup.py b/gui/meRendererSetup.py index bf0723d..e64e7de 100644 --- a/gui/meRendererSetup.py +++ b/gui/meRendererSetup.py @@ -11,35 +11,36 @@ Presets are stored in xml file """ -from core.mePyQt import QtCore, QtGui, QtXml +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui, QtXml +from core.signal import Signal from global_vars import app_global_vars, DEBUG_MODE from ui_meRendererSetup import Ui_meRendererSetup -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets QtModule = QtWidgets - # # meRendererSetup # class meRendererSetup ( QtModule.QDialog ) : # - # Define signals for PyQt5 - # - if QtCore.QT_VERSION >= 0x50000 : - presetChanged = QtCore.pyqtSignal () - savePreset = QtCore.pyqtSignal () - # # __init__ # def __init__ ( self, rendererPreset ) : # QtModule.QDialog.__init__ ( self ) - + # + # Define signals for PyQt5 + # + if usePySide or usePyQt5 : + # + self.presetChanged = Signal () + self.savePreset = Signal () + # self.rendererPreset = rendererPreset self.labelsReady = False self.buildGui () @@ -217,7 +218,7 @@ def onEditLabel ( self ) : def onSave ( self ) : # get data from Gui for current renderer before saving self.getDataFromGui () - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'presetChanged' ) ) self.emit ( QtCore.SIGNAL ( 'savePreset' ) ) else : @@ -230,7 +231,7 @@ def onSave ( self ) : def onSelect ( self ) : # get data from Gui for current renderer before saving self.getDataFromGui () - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit( QtCore.SIGNAL ( 'presetChanged' ) ) else : self.presetChanged.emit () diff --git a/gui/nodeEditor/NodeEditorDialog.py b/gui/nodeEditor/NodeEditorDialog.py index 5491a6c..bca79c9 100644 --- a/gui/nodeEditor/NodeEditorDialog.py +++ b/gui/nodeEditor/NodeEditorDialog.py @@ -7,7 +7,7 @@ Dialog for managing node code and parameters """ -from core.mePyQt import Qt, QtCore, QtGui, QtXml +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui, QtXml from core.signal import Signal from core.meCommon import * @@ -37,7 +37,7 @@ TAB_PARAM = 5 TAB_LINK_INFO = 6 -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -76,7 +76,7 @@ def __init__ ( self, node = None ): # def connectSignals ( self ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.connect ( self.ui.input_list, QtCore.SIGNAL ( 'selectionChangedSignal' ), self.updateGui ) # onInputParamSelectionChanged ) QtCore.QObject.connect ( self.ui.output_list, QtCore.SIGNAL ( 'selectionChangedSignal' ), self.updateGui ) # onOutputParamSelectionChanged ) @@ -164,7 +164,7 @@ def connectSignals ( self ) : # def disconnectSignals ( self ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.disconnect ( self.ui.input_list, QtCore.SIGNAL ( 'selectionChangedSignal' ), self.updateGui ) # onInputParamSelectionChanged ) QtCore.QObject.disconnect ( self.ui.output_list, QtCore.SIGNAL ( 'selectionChangedSignal' ), self.updateGui ) # onOutputParamSelectionChanged ) @@ -299,13 +299,19 @@ def buildGui ( self ) : # setup input links list for link in self.editNode.getInputLinks () : item = QtModule.QListWidgetItem ( 'id=%d' % link.id ) - item.setData ( QtCore.Qt.UserRole, QtCore.QVariant ( int ( link.id ) ) ) + if not usePySide : + item.setData ( QtCore.Qt.UserRole, QtCore.QVariant ( int ( link.id ) ) ) + else : + item.setData ( QtCore.Qt.UserRole, int ( link.id ) ) self.ui.input_links_listWidget.addItem ( item ) # setup output links list for link in self.editNode.getOutputLinks () : item = QtModule.QListWidgetItem ( 'id=%d' % link.id ) - item.setData ( QtCore.Qt.UserRole, QtCore.QVariant ( int ( link.id ) ) ) + if not usePySide : + item.setData ( QtCore.Qt.UserRole, QtCore.QVariant ( int ( link.id ) ) ) + else : + item.setData ( QtCore.Qt.UserRole, int ( link.id ) ) self.ui.output_links_listWidget.addItem ( item ) # setup event handlers list @@ -396,7 +402,7 @@ def updateGui ( self, foo_param = None ) : inputLinkSelected = True links_item = self.ui.input_links_listWidget.currentItem () if links_item is not None : - if QtCore.QT_VERSION < 0x50000 : + if not usePyQt5 : ( link_id, ok ) = links_item.data ( QtCore.Qt.UserRole ).toInt () else : link_id = links_item.data ( QtCore.Qt.UserRole ) @@ -405,7 +411,7 @@ def updateGui ( self, foo_param = None ) : # output links links_item = self.ui.output_links_listWidget.currentItem () if links_item is not None : - if QtCore.QT_VERSION < 0x50000 : + if not usePyQt5 : ( link_id, ok ) = links_item.data ( QtCore.Qt.UserRole ).toInt () else: link_id = links_item.data ( QtCore.Qt.UserRole ) @@ -536,7 +542,6 @@ def onRemoveParam ( self, paramName ) : paramList.ui.listWidget.setCurrentItem ( None ) # remove item from code (invalidate code) - pass # # onRenameInternal # @@ -659,7 +664,7 @@ def onAddParam ( self, newName ) : typeDialog.btnBox.setCenterButtons ( True ) typeDialog.verticalLayout.addWidget ( typeDialog.btnBox ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.connect ( typeDialog.btnBox, QtCore.SIGNAL ( 'accepted()' ), typeDialog.accept ) QtCore.QObject.connect ( typeDialog.btnBox, QtCore.SIGNAL ( 'rejected()' ), typeDialog.reject ) else : @@ -738,7 +743,7 @@ def onEditEventCode ( self ) : def keyPressEvent ( self, event ) : # #if DEBUG_MODE : print '>> NodeEditorDialog::keyPressEvent' - if event.key () == QtCore.Qt.Key_Enter or event.key () == QtCore.Qt.Key_Return : + if event.key () == QtCore.Qt.Key_Enter or event.key () == QtCore.Qt.Key_Return : event.ignore () else: QtModule.QDialog.keyPressEvent ( self, event ) diff --git a/gui/nodeEditor/codeSyntaxHighlighter.py b/gui/nodeEditor/codeSyntaxHighlighter.py index 3270530..c580aad 100644 --- a/gui/nodeEditor/codeSyntaxHighlighter.py +++ b/gui/nodeEditor/codeSyntaxHighlighter.py @@ -9,14 +9,14 @@ """ import os, sys -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from core.meCommon import * from global_vars import app_global_vars import gui.ui_settings as UI -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -116,7 +116,7 @@ def highlightBlock ( self, text ): commentLength = 0 if endIndex == -1: self.setCurrentBlockState ( 1 ) - if QtCore.QT_VERSION < 0x50000 : + if not usePyQt5 : commentLength = text.length () - startIndex else : commentLength = len ( text ) - startIndex diff --git a/gui/nodeEditor/nodeCodeEditor.py b/gui/nodeEditor/nodeCodeEditor.py index b33ae2e..23142c7 100644 --- a/gui/nodeEditor/nodeCodeEditor.py +++ b/gui/nodeEditor/nodeCodeEditor.py @@ -8,7 +8,7 @@ Dialog for managing node code """ -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from core.meCommon import * from global_vars import app_global_vars @@ -18,7 +18,7 @@ from ui_nodeCodeEditor import Ui_NodeCodeEditor -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/gui/nodeEditor/nodeLinkEditor.py b/gui/nodeEditor/nodeLinkEditor.py index 1910be6..f343e0d 100644 --- a/gui/nodeEditor/nodeLinkEditor.py +++ b/gui/nodeEditor/nodeLinkEditor.py @@ -8,7 +8,7 @@ Dialog for managing node links """ -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from core.meCommon import * from global_vars import app_global_vars @@ -19,7 +19,7 @@ from ui_nodeLinkEditor import Ui_NodeLinkEditor -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/gui/nodeEditor/nodeNamesEditor.py b/gui/nodeEditor/nodeNamesEditor.py index d6c83c1..8cc4d7f 100644 --- a/gui/nodeEditor/nodeNamesEditor.py +++ b/gui/nodeEditor/nodeNamesEditor.py @@ -8,7 +8,7 @@ Widget for manage names in list """ -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from core.signal import Signal #from core.meCommon import * @@ -16,7 +16,7 @@ from ui_nodeNamesEditor import Ui_NodeNamesEditor -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -35,7 +35,7 @@ def __init__ ( self, parent ) : # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 0x50000 : + if usePySide or usePyQt5 : # self.selectionChangedSignal = Signal () self.addItem = Signal () @@ -71,7 +71,7 @@ def onAddItem ( self ) : if DEBUG_MODE : print '>> NodeNamesEditor: onAddItem' new_text = str ( self.ui.name_lineEdit.text () ).strip () if new_text != '' : - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'addItem' ), new_text ) else : self.addItem.emit ( new_text ) @@ -87,7 +87,7 @@ def onRemoveItem ( self ) : item_text = str ( list_item.text () ) #self.ui.listWidget.takeItem ( self.ui.listWidget.currentRow () ) #self.ui.listWidget.removeItemWidget ( list_item ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'removeItem' ), item_text ) else : self.removeItem.emit ( item_text ) @@ -109,7 +109,7 @@ def onRenameItem ( self ) : if list_item is not None : # e.g. listWidget is not empty old_text = list_item.text () if new_text != old_text : - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL( 'renameItem' ), old_text, new_text ) else : self.renameItem.emit ( old_text, new_text ) @@ -127,7 +127,7 @@ def onSelectionChanged ( self ) : if list_item is not None : self.saved_text = str ( list_item.text() ) self.ui.name_lineEdit.setText ( self.saved_text ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'selectionChangedSignal' ), self.saved_text ) else : self.selectionChangedSignal.emit ( self.saved_text ) diff --git a/gui/nodeEditor/nodeParamEditor.py b/gui/nodeEditor/nodeParamEditor.py index 86a7059..bdad09f 100644 --- a/gui/nodeEditor/nodeParamEditor.py +++ b/gui/nodeEditor/nodeParamEditor.py @@ -8,7 +8,7 @@ Dialog for managing node parameters """ -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from core.signal import Signal from core.meCommon import * @@ -29,7 +29,7 @@ from ui_nodeParamEditor import Ui_NodeParamEditor -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -47,7 +47,7 @@ def __init__ ( self, parent ) : # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 0x50000 : + if usePySide or usePyQt5 : # self.changeParamName = Signal () self.changeParamLabel = Signal () @@ -142,7 +142,7 @@ def onParamDefValueChanged ( self, param ) : # if DEBUG_MODE : print '* onParamDefValueChanged' self.param.default = self.param_default.value - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'changeParamDefValue' ), self.param ) else : self.changeParamDefValue.emit ( self.param ) @@ -153,7 +153,7 @@ def onParamValueChanged ( self, param ) : # if DEBUG_MODE : print '* onParamValueChanged' self.param.value = param.value - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'changeParamValue' ), self.param ) else : self.changeParamValue.emit ( self.param ) @@ -162,7 +162,7 @@ def onParamValueChanged ( self, param ) : # def connectSignals ( self ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.connect ( self.param_default, QtCore.SIGNAL ( 'paramChangedSignal(QObject)' ), self.onParamDefValueChanged ) self.connect ( self.param, QtCore.SIGNAL ( 'paramChangedSignal(QObject)' ), self.onParamValueChanged ) @@ -197,7 +197,7 @@ def connectSignals ( self ) : # def disconnectSignals ( self ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : if self.param_default is not None : self.disconnect ( self.param_default, QtCore.SIGNAL ( 'paramChangedSignal(QObject)' ), self.onParamDefValueChanged ) if self.param is not None : @@ -352,7 +352,7 @@ def onEditParamName ( self ) : self.ui.name_lineEdit.setText ( newName ) if newName != oldName : self.param.name = newName - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit( QtCore.SIGNAL ( 'changeParamName' ), oldName, newName ) else : self.changeParamName.emit ( oldName, newName ) @@ -368,7 +368,7 @@ def onEditParamLabel ( self ) : self.ui.label_lineEdit.setText ( newName ) if newName != oldName : self.param.label = newName - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'changeParamLabel' ), oldName, newName ) else : self.changeParamLabel.emit ( oldName, newName ) @@ -390,7 +390,7 @@ def onEditParamDisplay ( self, value ) : def onEditParamShader ( self, value ) : # self.param.shaderParam = self.ui.check_shader.isChecked () - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'changeParamIsShader' ), self.param ) else : self.changeParamIsShader.emit ( self.param ) @@ -402,7 +402,7 @@ def onEditParamType ( self, idx ) : # !!! UI for param.value and param.default also should be changed # self.param.type = str ( self.ui.type_comboBox.itemText ( idx ) ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'changeParamType' ), self.param ) else : self.changeParamType.emit ( self.param ) @@ -412,7 +412,7 @@ def onEditParamType ( self, idx ) : def onEditParamDetail ( self, idx ) : # self.param.detail = str ( self.ui.detail_comboBox.itemText ( idx ) ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'changeParamDetail' ), self.param ) else : self.changeParamDetail.emit ( self.param ) @@ -422,7 +422,7 @@ def onEditParamDetail ( self, idx ) : def onEditParamProvider ( self, idx ) : # self.param.provider = str ( self.ui.provider_comboBox.itemText ( idx ) ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'changeParamProvider' ), self.param ) else : self.changeParamProvider.emit ( self.param ) @@ -432,7 +432,7 @@ def onEditParamProvider ( self, idx ) : def onEditParamSubtype ( self, idx ) : # self.param.subtype = str ( self.ui.subtype_comboBox.itemText ( idx ) ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'changeParamSubtype' ), self.param ) else : self.changeParamSubtype.emit ( self.param ) @@ -442,7 +442,7 @@ def onEditParamSubtype ( self, idx ) : def onEditParamRange ( self ) : # self.param.range = str ( self.ui.range_lineEdit.text () ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'changeParamRange' ), self.param ) else : self.changeParamRange.emit ( self.param ) diff --git a/gui/nodeEditor/nodePropertiesEditor.py b/gui/nodeEditor/nodePropertiesEditor.py index ad70b7b..9ef1f5e 100644 --- a/gui/nodeEditor/nodePropertiesEditor.py +++ b/gui/nodeEditor/nodePropertiesEditor.py @@ -8,7 +8,7 @@ Dialog for managing node properties """ -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from core.signal import Signal from core.meCommon import * @@ -20,7 +20,7 @@ from ui_nodePropertiesEditor import Ui_NodePropertiesEditor -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -39,10 +39,10 @@ def __init__ ( self, parent, editNode = None ) : # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 0x50000 : + if usePySide or usePyQt5 : # self.changeNodeLabel = Signal () - # + # self.editNode = editNode #self.debugPrint() @@ -122,7 +122,7 @@ def setNode ( self, editNode ) : # def connectSignals ( self ) : # QtCore.QObject. - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.connect ( self.ui.name_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrName ) self.connect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) self.connect ( self.ui.master_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrMaster ) @@ -143,7 +143,7 @@ def connectSignals ( self ) : # def disconnectSignals ( self ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : if self.editNode is not None : self.disconnect ( self.ui.name_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrName ) self.disconnect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) @@ -187,19 +187,19 @@ def onEditNodeStrAttrLabel ( self ) : oldLabel = self.editNode.label newLabel = str ( self.ui.label_lineEdit.text () ).strip () if newLabel == '' : - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.disconnect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) else : self.ui.label_lineEdit.editingFinished.disconnect ( self.onEditNodeStrAttrLabel ) newLabel = oldLabel self.ui.label_lineEdit.setText ( newLabel ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.connect ( self.ui.label_lineEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditNodeStrAttrLabel ) else : self.ui.label_lineEdit.editingFinished.connect ( self.onEditNodeStrAttrLabel ) if newLabel != oldLabel : self.editNode.label = newLabel - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'changeNodeLabel' ), oldLabel, newLabel ) else : self.changeNodeLabel.emit ( oldLabel, newLabel ) diff --git a/gui/nodeEditor/ui_nodeCodeEditor.py b/gui/nodeEditor/ui_nodeCodeEditor.py index b1c5e95..903f81c 100644 --- a/gui/nodeEditor/ui_nodeCodeEditor.py +++ b/gui/nodeEditor/ui_nodeCodeEditor.py @@ -7,9 +7,9 @@ # # WARNING! All changes made in this file will be lost! -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -34,8 +34,7 @@ def setupUi(self, NodeCodeEditor): NodeCodeEditor.setObjectName(_fromUtf8("NodeCodeEditor")) NodeCodeEditor.resize(683, 838) self.gridLayout = QtModule.QGridLayout(NodeCodeEditor) - if QtCore.QT_VERSION < 0x50000 : - self.gridLayout.setMargin(0) + self.gridLayout.setContentsMargins ( 0, 0, 0, 0 ) self.gridLayout.setSpacing(0) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) self.textEdit = QtModule.QTextEdit(NodeCodeEditor) diff --git a/gui/nodeEditor/ui_nodeEditorDialog.py b/gui/nodeEditor/ui_nodeEditorDialog.py index 7225d59..28abd8a 100644 --- a/gui/nodeEditor/ui_nodeEditorDialog.py +++ b/gui/nodeEditor/ui_nodeEditorDialog.py @@ -7,9 +7,9 @@ # # WARNING! All changes made in this file will be lost! -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -55,16 +55,14 @@ def setupUi(self, NodeEditorDialog): self.internals.setObjectName(_fromUtf8("internals")) self.verticalLayout_3 = QtModule.QVBoxLayout(self.internals) self.verticalLayout_3.setSpacing(0) - if QtCore.QT_VERSION < 0x50000 : - self.verticalLayout_3.setMargin(0) + self.verticalLayout_3.setContentsMargins ( 0, 0, 0, 0 ) self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3")) self.tabs_code_list = QtModule.QTabWidget(self.internals) self.tabs_code_list.setObjectName(_fromUtf8("tabs_code_list")) self.internals_tab = QtModule.QWidget() self.internals_tab.setObjectName(_fromUtf8("internals_tab")) self.gridLayout_4 = QtModule.QGridLayout(self.internals_tab) - if QtCore.QT_VERSION < 0x50000 : - self.gridLayout_4.setMargin(2) + self.gridLayout_4.setContentsMargins ( 2, 2, 2, 2 ) self.gridLayout_4.setSpacing(0) self.gridLayout_4.setObjectName(_fromUtf8("gridLayout_4")) self.internals_list = NodeNamesEditor(self.internals_tab) @@ -74,8 +72,7 @@ def setupUi(self, NodeEditorDialog): self.includes_tab = QtModule.QWidget() self.includes_tab.setObjectName(_fromUtf8("includes_tab")) self.gridLayout_5 = QtModule.QGridLayout(self.includes_tab) - if QtCore.QT_VERSION < 0x50000 : - self.gridLayout_5.setMargin(2) + self.gridLayout_5.setContentsMargins ( 2, 2, 2, 2 ) self.gridLayout_5.setSpacing(0) self.gridLayout_5.setObjectName(_fromUtf8("gridLayout_5")) self.includes_list = NodeNamesEditor(self.includes_tab) @@ -89,16 +86,16 @@ def setupUi(self, NodeEditorDialog): self.parameters.setObjectName(_fromUtf8("parameters")) self.verticalLayout_8 = QtModule.QVBoxLayout(self.parameters) self.verticalLayout_8.setSpacing(0) - if QtCore.QT_VERSION < 0x50000 : - self.verticalLayout_8.setMargin(0) + #if usePyQt4 : + self.verticalLayout_8.setContentsMargins ( 0, 0, 0, 0 ) self.verticalLayout_8.setObjectName(_fromUtf8("verticalLayout_8")) self.tabs_param_list = QtModule.QTabWidget(self.parameters) self.tabs_param_list.setObjectName(_fromUtf8("tabs_param_list")) self.inputs_tab = QtModule.QWidget() self.inputs_tab.setObjectName(_fromUtf8("inputs_tab")) self.gridLayout_2 = QtModule.QGridLayout(self.inputs_tab) - if QtCore.QT_VERSION < 0x50000 : - self.gridLayout_2.setMargin(2) + #if usePyQt4 : + self.gridLayout_2.setContentsMargins ( 2, 2, 2, 2 ) self.gridLayout_2.setSpacing(0) self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) self.input_list = NodeNamesEditor(self.inputs_tab) @@ -108,8 +105,8 @@ def setupUi(self, NodeEditorDialog): self.outputs_tab = QtModule.QWidget() self.outputs_tab.setObjectName(_fromUtf8("outputs_tab")) self.gridLayout_3 = QtModule.QGridLayout(self.outputs_tab) - if QtCore.QT_VERSION < 0x50000 : - self.gridLayout_3.setMargin(2) + #if usePyQt4 : + self.gridLayout_3.setContentsMargins ( 2, 2, 2, 2 ) self.gridLayout_3.setSpacing(0) self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3")) self.output_list = NodeNamesEditor(self.outputs_tab) @@ -123,8 +120,8 @@ def setupUi(self, NodeEditorDialog): self.handlers.setObjectName(_fromUtf8("handlers")) self.verticalLayout_2 = QtModule.QVBoxLayout(self.handlers) self.verticalLayout_2.setSpacing(0) - if QtCore.QT_VERSION < 0x50000 : - self.verticalLayout_2.setMargin(0) + #if usePyQt4 : + self.verticalLayout_2.setContentsMargins ( 0, 0, 0, 0 ) self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) self.handlers_list = NodeNamesEditor(self.handlers) self.handlers_list.setObjectName(_fromUtf8("handlers_list")) @@ -135,16 +132,16 @@ def setupUi(self, NodeEditorDialog): self.links.setObjectName(_fromUtf8("links")) self.verticalLayout_81 = QtModule.QVBoxLayout(self.links) self.verticalLayout_81.setSpacing(0) - if QtCore.QT_VERSION < 0x50000 : - self.verticalLayout_81.setMargin(0) + #if usePyQt4 : + self.verticalLayout_81.setContentsMargins ( 0, 0, 0, 0 ) self.verticalLayout_81.setObjectName(_fromUtf8("verticalLayout_81")) self.tabs_links_list = QtModule.QTabWidget(self.links) self.tabs_links_list.setObjectName(_fromUtf8("tabs_links_list")) self.input_links_tab = QtModule.QWidget() self.input_links_tab.setObjectName(_fromUtf8("input_links_tab")) self.gridLayout_6 = QtModule.QGridLayout(self.input_links_tab) - if QtCore.QT_VERSION < 0x50000 : - self.gridLayout_6.setMargin(2) + #if usePyQt4 : + self.gridLayout_6.setContentsMargins ( 0, 0, 0, 0 ) self.gridLayout_6.setSpacing(0) self.gridLayout_6.setObjectName(_fromUtf8("gridLayout_6")) self.input_links_listWidget = QtModule.QListWidget(self.input_links_tab) @@ -154,8 +151,8 @@ def setupUi(self, NodeEditorDialog): self.output_links_tab = QtModule.QWidget() self.output_links_tab.setObjectName(_fromUtf8("output_links_tab")) self.gridLayout_66 = QtModule.QGridLayout(self.output_links_tab) - if QtCore.QT_VERSION < 0x50000 : - self.gridLayout_66.setMargin(2) + #if usePyQt4 : + self.gridLayout_66.setContentsMargins ( 2, 2, 2, 2 ) self.gridLayout_66.setSpacing(0) self.gridLayout_66.setObjectName(_fromUtf8("gridLayout_66")) self.output_links_listWidget = QtModule.QListWidget(self.output_links_tab) @@ -177,8 +174,8 @@ def setupUi(self, NodeEditorDialog): self.node_code_tab = QtModule.QWidget() self.node_code_tab.setObjectName(_fromUtf8("node_code_tab")) self.gridLayout = QtModule.QGridLayout(self.node_code_tab) - if QtCore.QT_VERSION < 0x50000 : - self.gridLayout.setMargin(2) + #if usePyQt4 : + self.gridLayout.setContentsMargins ( 2, 2, 2, 2 ) self.gridLayout.setSpacing(2) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) self.node_code = NodeCodeEditor(self.node_code_tab) @@ -188,8 +185,8 @@ def setupUi(self, NodeEditorDialog): self.control_code_tab = QtModule.QWidget() self.control_code_tab.setObjectName(_fromUtf8("control_code_tab")) self.gridLayout_7 = QtModule.QGridLayout(self.control_code_tab) - if QtCore.QT_VERSION < 0x50000 : - self.gridLayout_7.setMargin(2) + #if usePyQt4 : + self.gridLayout_7.setContentsMargins ( 2, 2, 2, 2 ) self.gridLayout_7.setSpacing(2) self.gridLayout_7.setObjectName(_fromUtf8("gridLayout_7")) self.control_code = NodeCodeEditor(self.control_code_tab) @@ -199,8 +196,8 @@ def setupUi(self, NodeEditorDialog): self.event_code_tab = QtModule.QWidget() self.event_code_tab.setObjectName(_fromUtf8("event_code_tab")) self.gridLayout_8 = QtModule.QGridLayout(self.event_code_tab) - if QtCore.QT_VERSION < 0x50000 : - self.gridLayout_8.setMargin(2) + #if usePyQt4 : + self.gridLayout_8.setContentsMargins ( 2, 2, 2, 2 ) self.gridLayout_8.setSpacing(2) self.gridLayout_8.setObjectName(_fromUtf8("gridLayout_8")) self.event_code = NodeCodeEditor(self.event_code_tab) @@ -210,8 +207,8 @@ def setupUi(self, NodeEditorDialog): self.param_code_tab = QtModule.QWidget() self.param_code_tab.setObjectName(_fromUtf8("param_code_tab")) self.gridLayout_9 = QtModule.QGridLayout(self.param_code_tab) - if QtCore.QT_VERSION < 0x50000 : - self.gridLayout_9.setMargin(2) + #if usePyQt4 : + self.gridLayout_9.setContentsMargins ( 2, 2, 2, 2 ) self.gridLayout_9.setSpacing(2) self.gridLayout_9.setObjectName(_fromUtf8("gridLayout_9")) self.param_code = NodeCodeEditor(self.param_code_tab) @@ -255,7 +252,7 @@ def setupUi(self, NodeEditorDialog): self.tabs_param_list.setCurrentIndex(0) self.tabs_links_list.setCurrentIndex(0) self.tabWidget.setCurrentIndex(0) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.connect(self.toolBox, QtCore.SIGNAL(_fromUtf8("currentChanged(int)")), NodeEditorDialog.onToolBoxIndexChanged) QtCore.QObject.connect(self.btn_save, QtCore.SIGNAL(_fromUtf8("clicked()")), NodeEditorDialog.accept) QtCore.QObject.connect(self.btn_close, QtCore.SIGNAL(_fromUtf8("clicked()")), NodeEditorDialog.reject) diff --git a/gui/nodeEditor/ui_nodeLinkEditor.py b/gui/nodeEditor/ui_nodeLinkEditor.py index 9a0a7fa..b8fb044 100644 --- a/gui/nodeEditor/ui_nodeLinkEditor.py +++ b/gui/nodeEditor/ui_nodeLinkEditor.py @@ -7,9 +7,9 @@ # # WARNING! All changes made in this file will be lost! -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/gui/nodeEditor/ui_nodeNamesEditor.py b/gui/nodeEditor/ui_nodeNamesEditor.py index 2b20285..98a273b 100644 --- a/gui/nodeEditor/ui_nodeNamesEditor.py +++ b/gui/nodeEditor/ui_nodeNamesEditor.py @@ -7,9 +7,9 @@ # # WARNING! All changes made in this file will be lost! -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -26,8 +26,8 @@ def setupUi(self, NodeNamesEditor): NodeNamesEditor.resize(417, 393) self.verticalLayout = QtModule.QVBoxLayout(NodeNamesEditor) self.verticalLayout.setSpacing(0) - if QtCore.QT_VERSION < 0x50000 : - self.verticalLayout.setMargin(0) + #if usePyQt4 : + self.verticalLayout.setContentsMargins ( 0, 0, 0, 0 ) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.horizontalLayout = QtModule.QHBoxLayout() self.horizontalLayout.setSpacing(2) @@ -64,7 +64,7 @@ def setupUi(self, NodeNamesEditor): self.verticalLayout.addWidget(self.listWidget) self.retranslateUi(NodeNamesEditor) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.connect(self.addButton, QtCore.SIGNAL(_fromUtf8("clicked()")), NodeNamesEditor.onAddItem) QtCore.QObject.connect(self.removeButton, QtCore.SIGNAL(_fromUtf8("clicked()")), NodeNamesEditor.onRemoveItem) QtCore.QObject.connect(self.listWidget, QtCore.SIGNAL(_fromUtf8("itemSelectionChanged()")), NodeNamesEditor.onSelectionChanged) diff --git a/gui/nodeEditor/ui_nodeParamEditor.py b/gui/nodeEditor/ui_nodeParamEditor.py index 4c5d0f1..cc13056 100644 --- a/gui/nodeEditor/ui_nodeParamEditor.py +++ b/gui/nodeEditor/ui_nodeParamEditor.py @@ -7,9 +7,9 @@ # # WARNING! All changes made in this file will be lost! -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/gui/nodeEditor/ui_nodePropertiesEditor.py b/gui/nodeEditor/ui_nodePropertiesEditor.py index ee051ac..d0975db 100644 --- a/gui/nodeEditor/ui_nodePropertiesEditor.py +++ b/gui/nodeEditor/ui_nodePropertiesEditor.py @@ -7,9 +7,9 @@ # # WARNING! All changes made in this file will be lost! -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/gui/nodeLibraryView.py b/gui/nodeLibraryView.py index 685a741..2feeca2 100644 --- a/gui/nodeLibraryView.py +++ b/gui/nodeLibraryView.py @@ -3,7 +3,7 @@ nodeLibraryView.py """ -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui #from PyQt4.QtCore import QDir, QString, QModelIndex #from PyQt4.QtGui import QFileSystemModel @@ -18,7 +18,7 @@ from core.node import Node from core.nodeLibrary import NodeLibrary -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/gui/nodeList.py b/gui/nodeList.py index dcb264a..1a66c29 100644 --- a/gui/nodeList.py +++ b/gui/nodeList.py @@ -3,19 +3,18 @@ nodeList.py """ -from core.mePyQt import QtCore, QtGui - +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui +from core.signal import Signal #from PyQt4.QtCore import QDir, QString, QModelIndex #from PyQt4.QtGui import QFileSystemModel #from PyQt4.QtGui import QFileIconProvider from ui_nodeList import Ui_nodeList -#from MainWindow import MainWindow from core.node import Node from core.nodeLibrary import NodeLibrary -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -26,18 +25,19 @@ # class NodeList ( QtModule.QWidget ) : # - # Define signals for PyQt5 - # - if QtCore.QT_VERSION >= 0x50000 : - setActiveNodeList = QtCore.pyqtSignal ( [QtModule.QWidget] ) - addNode = QtCore.pyqtSignal ( [str] ) - # # __init__ # def __init__ ( self, parent ) : # QtModule.QWidget.__init__ ( self, parent ) - + # + # Define signals for PyQt5 + # + if usePySide or usePyQt5 : + # + self.setActiveNodeList = Signal () + self.addNode = Signal () + # self.nodesLib = '' self.nodesDir = '' # This is always the same @@ -52,7 +52,7 @@ def __init__ ( self, parent ) : # def connectSignals ( self ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.connect ( self.ui.treeView, QtCore.SIGNAL ( "pressed(QModelIndex)" ), self.clicked ) QtCore.QObject.connect ( self.ui.treeView, QtCore.SIGNAL ( "doubleClicked(QModelIndex)" ), self.doubleClicked ) else : @@ -92,13 +92,15 @@ def reloadLibrary ( self ) : # def clicked ( self, index ) : # + print ">> NodeList::clicked " item = self.nodesLib.model.itemFromIndex ( index ) self.showDescription ( item ) # # send signal to MainWindow to help distinguish which nodeList # is active for addNode getNode events # - if QtCore.QT_VERSION < 0x50000 : + print ">> NodeList::emit setActiveNodeList" + if usePyQt4 : self.emit ( QtCore.SIGNAL ( "setActiveNodeList" ), self ) else : self.setActiveNodeList.emit ( self ) @@ -107,26 +109,32 @@ def clicked ( self, index ) : # def doubleClicked ( self, index ) : # + print ">> NodeList::doubleClicked " item = self.nodesLib.model.itemFromIndex ( index ) nodeKind = item.whatsThis () if nodeKind != 'folder' : - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : nodeFilename = item.data ( QtCore.Qt.UserRole + 4 ).toString () - self.emit ( QtCore.SIGNAL ( 'addNode' ), nodeFilename ) else : nodeFilename = item.data ( QtCore.Qt.UserRole + 4 ) + + print ">> NodeList::emit addNode" + if usePyQt4 : + self.emit ( QtCore.SIGNAL ( 'addNode' ), nodeFilename ) + else : self.addNode.emit ( nodeFilename ) # # showDescription # def showDescription ( self, item ) : # + print ">> NodeList::showDescription " import os nodeName = item.text () nodeKind = item.whatsThis () - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : nodeAuthor = item.data ( QtCore.Qt.UserRole + 1 ).toString () nodeType = item.data ( QtCore.Qt.UserRole + 2 ).toString () nodeHelp = item.data ( QtCore.Qt.UserRole + 3 ).toString () diff --git a/gui/nodeParamList.py b/gui/nodeParamList.py index e161f39..8681d62 100644 --- a/gui/nodeParamList.py +++ b/gui/nodeParamList.py @@ -3,7 +3,7 @@ nodeParamList.py """ -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from core.signal import Signal #from PyQt4.QtCore import QDir, QString, QModelIndex #from PyQt4.QtGui import QFileSystemModel @@ -29,7 +29,7 @@ from gui.params.TextWidget import TextWidget from gui.params.ControlWidget import ControlWidget -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -39,18 +39,18 @@ # class NodeParamListTab ( QtModule.QWidget ) : # - # Define signals for PyQt5 - # - if QtCore.QT_VERSION >= 0x50000 : - # - sectionResized = QtCore.pyqtSignal ( int,int,int ) - # # __init__ # def __init__ ( self, parent, gfxNode = None, isInput = True, showConnected = False ) : # QtModule.QWidget.__init__ ( self, parent ) - + # + # Define signals for PyQt5 + # + if usePySide or usePyQt5 : + # + self.sectionResized = Signal () + # self.nodeParamView = parent self.gfxNode = gfxNode self.isInput = isInput @@ -69,7 +69,7 @@ def __init__ ( self, parent, gfxNode = None, isInput = True, showConnected = Fal # def connectSignals ( self ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.connect ( self.paramHeader, QtCore.SIGNAL ( 'sectionResized(int,int,int)' ), self.onSectionResized ) else : self.paramHeader.sectionResized.connect ( self.onSectionResized ) @@ -113,8 +113,12 @@ def buildGui ( self ) : # self.model = QtGui.QStandardItemModel () self.model.setColumnCount ( 2 ) - self.model.setHeaderData ( 0, QtCore.Qt.Horizontal, QtCore.QVariant ( 'Parameter' ) ) - self.model.setHeaderData ( 1, QtCore.Qt.Horizontal, QtCore.QVariant ( 'Value' ) ) + if not usePySide : + self.model.setHeaderData ( 0, QtCore.Qt.Horizontal, QtCore.QVariant ( 'Parameter' ) ) + self.model.setHeaderData ( 1, QtCore.Qt.Horizontal, QtCore.QVariant ( 'Value' ) ) + else : + self.model.setHeaderData ( 0, QtCore.Qt.Horizontal, 'Parameter' ) + self.model.setHeaderData ( 1, QtCore.Qt.Horizontal, 'Value' ) self.paramHeader = QtModule.QHeaderView ( QtCore.Qt.Horizontal, self ) self.paramHeader.setModel ( self.model ) @@ -241,8 +245,8 @@ def buildGui ( self ) : self.paramListLayout = QtModule.QGridLayout () self.paramListLayout.setSizeConstraint ( QtModule.QLayout.SetNoConstraint ) self.paramListLayout.setSpacing ( UI.SPACING ) - if QtCore.QT_VERSION < 0x50000 : - self.paramListLayout.setMargin ( UI.SPACING ) + self.paramListLayout.setContentsMargins ( UI.SPACING, UI.SPACING, UI.SPACING, UI.SPACING ) + self.paramListLayout.setAlignment ( QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft ) self.paramListLayout.setColumnMinimumWidth ( 0, self.labelWidth ) self.paramListLayout.setColumnStretch ( 1, 1 ) @@ -292,7 +296,7 @@ def updateGui ( self ) : paramWidget.setEnabled ( False ) if param.removable : - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.connect ( paramWidget, QtCore.SIGNAL ( 'nodeParamRemoved' ), self.nodeParamViewTab.onParamRemoved ) else : paramWidget.nodeParamRemoved.connect ( self.nodeParamViewTab.onParamRemoved ) diff --git a/gui/nodeParamView.py b/gui/nodeParamView.py index 74de0e8..98861f5 100644 --- a/gui/nodeParamView.py +++ b/gui/nodeParamView.py @@ -3,7 +3,7 @@ nodeParamView.py """ -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from core.signal import Signal #from PyQt4.QtCore import QDir, QString, QModelIndex #from PyQt4.QtGui import QFileSystemModel @@ -19,7 +19,7 @@ import gui.ui_settings as UI from global_vars import DEBUG_MODE -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -37,11 +37,11 @@ def __init__ ( self ) : # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 0x50000 : + if usePySide or usePyQt5 : # self.nodeParamChangedSignal = Signal () self.nodeLabelChangedSignal = Signal () - + # self.gfxNode = None self.inputParamListTab = None @@ -69,7 +69,7 @@ def setNode ( self, gfxNode ) : # def connectSignals ( self ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.connect ( self.nameEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.nodeLabelChanged ) self.connect ( self.showConnectButton, QtCore.SIGNAL ( 'toggled(bool)' ), self.showConnections ) else : @@ -80,7 +80,7 @@ def connectSignals ( self ) : # def disconnectSignals ( self ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.disconnect ( self.nameEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.nodeLabelChanged ) self.disconnect ( self.showConnectButton, QtCore.SIGNAL ( 'toggled(bool)' ), self.showConnections ) else : @@ -93,12 +93,12 @@ def connectParamSignals ( self ) : #print ">> NodeParamView.connectParamSignals" if self.gfxNode is not None : for inputParam in self.gfxNode.node.inputParams : - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.connect ( inputParam, QtCore.SIGNAL ( 'paramChangedSignal(QObject)' ), self.onParamChanged ) else : inputParam.paramChangedSignal.connect ( self.onParamChanged ) for outputParam in self.gfxNode.node.outputParams : - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.connect ( outputParam, QtCore.SIGNAL ( 'paramChangedSignal(QObject)' ), self.onParamChanged ) else : outputParam.paramChangedSignal.connect ( self.onParamChanged ) @@ -109,12 +109,12 @@ def disconnectParamSignals ( self ) : #print ">> NodeParamView.disconnectParamSignals" if self.gfxNode is not None : for inputParam in self.gfxNode.node.inputParams : - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.disconnect ( inputParam, QtCore.SIGNAL ( 'paramChangedSignal(QObject)' ), self.onParamChanged ) else : inputParam.paramChangedSignal.disconnect ( self.onParamChanged ) for outputParam in self.gfxNode.node.outputParams : - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.disconnect ( outputParam, QtCore.SIGNAL ( 'paramChangedSignal(QObject)' ), self.onParamChanged ) else : outputParam.paramChangedSignal.disconnect ( self.onParamChanged ) @@ -135,7 +135,7 @@ def showConnections ( self, show ) : def onParamChanged ( self, param ) : # if DEBUG_MODE : print ">> NodeParamView.onParamChanged node = %s param = %s" % ( self.gfxNode.node.label, param.name ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'nodeParamChangedSignal' ), self.gfxNode, param ) # .node else : self.nodeParamChangedSignal.emit ( self.gfxNode, param ) # .node @@ -153,7 +153,7 @@ def nodeLabelChanged ( self ) : # update label only if realy changed if newLabel != self.gfxNode.node.label : # rename node label if same name exists in NodeNet - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'nodeLabelChangedSignal' ), self.gfxNode, newLabel ) else : self.nodeLabelChangedSignal.emit ( self.gfxNode, newLabel ) @@ -196,8 +196,7 @@ def buildGui ( self ) : headerLayout = QtModule.QHBoxLayout () headerLayout.setSpacing ( UI.SPACING ) - if QtCore.QT_VERSION < 0x50000 : - headerLayout.setMargin ( UI.SPACING ) + headerLayout.setContentsMargins ( UI.SPACING, UI.SPACING, UI.SPACING, UI.SPACING ) headerLayout.setStretch ( 1, 1 ) headerLayout.addWidget ( label ) diff --git a/gui/nodeSwatchParam.py b/gui/nodeSwatchParam.py index 0769bcf..4a3255b 100644 --- a/gui/nodeSwatchParam.py +++ b/gui/nodeSwatchParam.py @@ -3,13 +3,13 @@ nodeSwatchParam.py """ -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from ui_nodeSwatchParam import Ui_NodeSwatchParam import ui_settings as UI -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/gui/nodeTreeView.py b/gui/nodeTreeView.py index 80bc967..1303b01 100644 --- a/gui/nodeTreeView.py +++ b/gui/nodeTreeView.py @@ -3,7 +3,7 @@ nodeTreeView.py """ -from core.mePyQt import QtCore, QtGui, Qt +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui #from PyQt4.QtCore import QDir, QString, QModelIndex #from PyQt4.QtGui import QFileSystemModel @@ -12,7 +12,9 @@ from core.node import Node from core.nodeLibrary import NodeLibrary -if QtCore.QT_VERSION < 0x50000 : +from global_vars import DEBUG_MODE + +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -26,14 +28,14 @@ class NodeTreeView ( QtModule.QTreeView ) : # __init__ # def __init__( self, parent = None ): - #print ">> NodeTreeWidget init" + # QtModule.QTreeView.__init__ ( self, parent ) self.setMinimumHeight ( 200 ) # # startDrag - # + # def startDrag ( self, dropActions ) : - #print ">> NodeTreeView startDrag " + print ">> NodeTreeView::startDrag " selectedIdx = self.selectedIndexes () # for idx in selectedIdx : idx = selectedIdx[ 0 ] @@ -45,12 +47,20 @@ def startDrag ( self, dropActions ) : stream = QtCore.QDataStream ( data, QtCore.QIODevice.WriteOnly ) itemName = item.text () - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : itemFilename = item.data( QtCore.Qt.UserRole + 4 ).toString () - stream << itemFilename else : itemFilename = item.data( QtCore.Qt.UserRole + 4 ) - stream.writeBytes ( itemFilename ) + + if not usePyQt5 : + if usePySide : + stream.writeString ( itemFilename ) + else : + stream << itemFilename + else : + stream.writeBytes ( itemFilename ) + + if DEBUG_MODE : print '* write itemFilename = %s' % ( itemFilename ) mimeData = QtCore.QMimeData() mimeData.setData ( 'application/x-text', data ) @@ -59,7 +69,7 @@ def startDrag ( self, dropActions ) : drag = QtGui.QDrag ( self ) drag.setMimeData ( mimeData ) #drag.setPixmap ( QtGui.QPixmap(':/node.png') ) - if QtCore.QT_VERSION < 0x50000 : + if not usePyQt5 : drag.start ( QtCore.Qt.CopyAction ) else : drag.exec_ ( QtCore.Qt.CopyAction ) diff --git a/gui/params/ColorWidget.py b/gui/params/ColorWidget.py index d13f794..63cd22f 100644 --- a/gui/params/ColorWidget.py +++ b/gui/params/ColorWidget.py @@ -3,13 +3,13 @@ ColorWidget.py """ -from core.mePyQt import QtGui, QtCore +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from core.signal import Signal import gui.ui_settings as UI from paramWidget import ParamWidget -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -36,11 +36,10 @@ def __init__ ( self, param, gfxNode, ignoreSubtype = False ) : # buildGui # def buildGui ( self ) : - # # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 0x50000 : + if usePySide or usePyQt5 : # self.clicked = Signal () @@ -65,7 +64,7 @@ def eventFilter ( self, obj, event ) : # check for single click if event.type () == QtCore.QEvent.MouseButtonPress: #print "eventFilter = MouseButtonPress" - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.ColorWidget.emit ( QtCore.SIGNAL ( 'clicked()' ) ) else : self.ColorWidget.clicked.emit () @@ -121,7 +120,7 @@ def setupUi ( self, ColorWidget ) : def connectSignals ( self, ColorWidget ) : # register signal propertyChanged for updating the gui #self.connect( self.colorProperty, QtCore.SIGNAL('propertyChanged()'), self.onPropertyChanged ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : ColorWidget.connect ( ColorWidget, QtCore.SIGNAL ( 'clicked()' ), self.onClicked ) ColorWidget.connect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) else : @@ -133,7 +132,7 @@ def connectSignals ( self, ColorWidget ) : def disconnectSignals ( self, ColorWidget ) : # register signal propertyChanged for updating the gui #self.disconnect( self.colorProperty, QtCore.SIGNAL('propertyChanged()'), self.onPropertyChanged ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : ColorWidget.disconnect ( ColorWidget, QtCore.SIGNAL ( 'clicked()' ), self.onClicked ) ColorWidget.disconnect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) else : @@ -143,7 +142,7 @@ def disconnectSignals ( self, ColorWidget ) : # onClicked # def onClicked ( self ) : - #print( "ColorWidget = onClicked" ) + print( ">> ColorWidget::onClicked" ) redValue = int ( self.widget.param.value [0] * 255 ) greenValue = int ( self.widget.param.value [1] * 255 ) blueValue = int ( self.widget.param.value [2] * 255 ) @@ -182,8 +181,7 @@ def updateGui ( self, value ) : painter.setPen ( QtCore.Qt.NoPen ) painter.setBrush ( color ) - rect = QtCore.QRectF ( 0.0, 0.0, UI.COLOR_WIDTH, UI.HEIGHT ) - painter.drawRects ( rect ) + painter.drawRect ( 0.0, 0.0, UI.COLOR_WIDTH, UI.HEIGHT ) painter.end () self.colorEdit.setPixmap ( pixmap ) diff --git a/gui/params/ControlWidget.py b/gui/params/ControlWidget.py index 957ecfc..3a18d66 100644 --- a/gui/params/ControlWidget.py +++ b/gui/params/ControlWidget.py @@ -3,13 +3,13 @@ ControlWidget.py """ -from core.mePyQt import QtGui, QtCore +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from global_vars import app_global_vars, DEBUG_MODE import gui.ui_settings as UI from paramWidget import ParamWidget -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -62,7 +62,7 @@ def setupUi ( self, ControlWidget ) : # def connectSignals ( self, ControlWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : ControlWidget.connect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) else : self.stringEdit.editingFinished.connect ( self.onStringEditEditingFinished ) @@ -71,7 +71,7 @@ def connectSignals ( self, ControlWidget ) : # def disconnectSignals ( self, ControlWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : ControlWidget.disconnect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) else : self.stringEdit.editingFinished.disconnect ( self.onStringEditEditingFinished ) @@ -119,7 +119,7 @@ def setupUi ( self, ControlWidget ) : # def connectSignals ( self, ControlWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : ControlWidget.connect ( self.button, QtCore.SIGNAL ( 'clicked()' ), self.onClicked ) else : self.button.clicked.connect ( self.onClicked ) @@ -128,7 +128,7 @@ def connectSignals ( self, ControlWidget ) : # def disconnectSignals ( self, ControlWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : ControlWidget.disconnect ( self.button, QtCore.SIGNAL ( 'clicked()' ), self.onClicked ) else : self.button.clicked.disconnect ( self.onClicked ) diff --git a/gui/params/FloatWidget.py b/gui/params/FloatWidget.py index 2128da9..48f0ee2 100644 --- a/gui/params/FloatWidget.py +++ b/gui/params/FloatWidget.py @@ -6,13 +6,13 @@ import math from decimal import * -from core.mePyQt import QtGui, QtCore +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from core.signal import Signal import gui.ui_settings as UI from paramWidget import ParamWidget -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -68,7 +68,7 @@ def setupUi ( self, FloatWidget ) : # def connectSignals ( self, FloatWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : FloatWidget.connect ( self.floatEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) else : self.floatEdit.editingFinished.connect ( self.onFloatEditEditingFinished ) @@ -77,7 +77,7 @@ def connectSignals ( self, FloatWidget ) : # def disconnectSignals ( self, FloatWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : FloatWidget.disconnect ( self.floatEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) else : self.floatEdit.editingFinished.disconnect ( self.onFloatEditEditingFinished ) @@ -87,7 +87,7 @@ def disconnectSignals ( self, FloatWidget ) : def onFloatEditEditingFinished ( self ) : # floatStr = self.floatEdit.text () - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : floatValue = floatStr.toFloat () [0] else : floatValue = float ( floatStr ) @@ -98,7 +98,7 @@ def onFloatEditEditingFinished ( self ) : # def updateGui ( self, value ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.floatEdit.setText ( QtCore.QString.number(value, 'f', 3) ) else : self.floatEdit.setText ( str ( value ) ) @@ -130,7 +130,7 @@ def setupUi ( self, FloatWidget ) : # def connectSignals ( self, FloatWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : FloatWidget.connect ( self.checkBox, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onStateChanged ) else : self.checkBox.stateChanged.connect ( self.onStateChanged ) @@ -139,7 +139,7 @@ def connectSignals ( self, FloatWidget ) : # def disconnectSignals ( self, FloatWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : FloatWidget.disconnect ( self.checkBox, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onStateChanged ) else : self.checkBox.stateChanged.disconnect ( self.onStateChanged ) @@ -190,7 +190,7 @@ def setupUi ( self, FloatWidget ) : # def connectSignals ( self, FloatWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : FloatWidget.connect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) else : self.selector.activated.connect ( self.onCurrentIndexChanged ) @@ -199,7 +199,7 @@ def connectSignals ( self, FloatWidget ) : # def disconnectSignals ( self, FloatWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : FloatWidget.disconnect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) else : self.selector.activated.disconnect ( self.onCurrentIndexChanged ) @@ -208,7 +208,10 @@ def disconnectSignals ( self, FloatWidget ) : # def onCurrentIndexChanged ( self, idx ) : # - ( floatValue, ok ) = self.selector.itemData ( idx ).toFloat () + if usePyQt4 : + ( floatValue, ok ) = self.selector.itemData ( idx ).toFloat () + else : + floatValue = self.selector.itemData ( idx ) self.widget.param.setValue ( float ( floatValue ) ) # # updateGui @@ -291,7 +294,7 @@ def setupUi ( self, FloatWidget ) : # def connectSignals ( self, FloatWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : FloatWidget.connect ( self.floatEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) FloatWidget.connect ( self.slider, QtCore.SIGNAL ( 'valueChanged(int)' ), self.onSliderValueChanged ) else : @@ -302,7 +305,7 @@ def connectSignals ( self, FloatWidget ) : # def disconnectSignals ( self, FloatWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : FloatWidget.disconnect ( self.floatEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) FloatWidget.disconnect ( self.slider, QtCore.SIGNAL ( 'valueChanged(int)' ), self.onSliderValueChanged ) else : @@ -314,7 +317,7 @@ def disconnectSignals ( self, FloatWidget ) : def onFloatEditEditingFinished ( self ) : # floatStr = self.floatEdit.text () - if QtCore.QT_VERSION < 0x50000 : + if not usePyQt5 : floatValue = floatStr.toFloat () [ 0 ] else : floatValue = float ( floatStr ) @@ -368,7 +371,7 @@ def onSliderValueChanged ( self, value ) : # def updateGui ( self, value ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.floatEdit.setText ( QtCore.QString.number ( value, 'f', 3 ) ) else : self.floatEdit.setText ( str ( value ) ) diff --git a/gui/params/IntWidget.py b/gui/params/IntWidget.py index 1f4afdf..a98256b 100644 --- a/gui/params/IntWidget.py +++ b/gui/params/IntWidget.py @@ -3,12 +3,12 @@ IntWidget.py """ -from core.mePyQt import QtGui, QtCore +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui import gui.ui_settings as UI from paramWidget import ParamWidget -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -64,7 +64,7 @@ def setupUi ( self, IntWidget ) : # def connectSignals ( self, IntWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : IntWidget.connect ( self.intEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onIntEditEditingFinished ) else : self.intEdit.editingFinished.connect ( self.onIntEditEditingFinished ) @@ -73,7 +73,7 @@ def connectSignals ( self, IntWidget ) : # def disconnectSignals ( self, IntWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : IntWidget.disconnect ( self.intEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onIntEditEditingFinished ) else : self.intEdit.editingFinished.disconnect ( self.onIntEditEditingFinished ) @@ -83,7 +83,7 @@ def disconnectSignals ( self, IntWidget ) : def onIntEditEditingFinished ( self ) : # intStr = self.intEdit.text () - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : intValue = intStr.toInt () [ 0 ] else : intValue = int ( intStr ) @@ -92,7 +92,7 @@ def onIntEditEditingFinished ( self ) : # updateGui def updateGui ( self, value ): # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.intEdit.setText ( QtCore.QString.number ( value ) ) else : self.intEdit.setText ( str ( value ) ) @@ -125,7 +125,7 @@ def setupUi ( self, IntWidget ) : # def connectSignals ( self, IntWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : IntWidget.connect ( self.checkBox, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onStateChanged ) else : self.checkBox.stateChanged.connect ( self.onStateChanged ) @@ -134,7 +134,7 @@ def connectSignals ( self, IntWidget ) : # def disconnectSignals ( self, IntWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : IntWidget.disconnect ( self.checkBox, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onStateChanged ) else : self.checkBox.stateChanged.disconnect ( self.onStateChanged ) @@ -185,7 +185,7 @@ def setupUi ( self, IntWidget ) : # def connectSignals ( self, IntWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : IntWidget.connect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) else : self.selector.activated.connect ( self.onCurrentIndexChanged ) @@ -194,7 +194,7 @@ def connectSignals ( self, IntWidget ) : # def disconnectSignals ( self, IntWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : IntWidget.disconnect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) else : self.selector.activated.disconnect ( self.onCurrentIndexChanged ) @@ -203,7 +203,7 @@ def disconnectSignals ( self, IntWidget ) : # def onCurrentIndexChanged ( self, idx ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : ( intValue, ok ) = self.selector.itemData ( idx ).toInt () else : intValue = self.selector.itemData ( idx ) @@ -272,7 +272,7 @@ def setupUi ( self, IntWidget ) : # def connectSignals ( self, IntWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : IntWidget.connect ( self.intEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onIntEditEditingFinished ) IntWidget.connect ( self.slider, QtCore.SIGNAL ( 'valueChanged(int)' ), self.onSliderValueChanged ) else : @@ -283,7 +283,7 @@ def connectSignals ( self, IntWidget ) : # def disconnectSignals ( self, IntWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : IntWidget.disconnect ( self.intEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onIntEditEditingFinished ) IntWidget.disconnect ( self.slider, QtCore.SIGNAL ( 'valueChanged(int)' ), self.onSliderValueChanged ) else : @@ -295,7 +295,7 @@ def disconnectSignals ( self, IntWidget ) : def onIntEditEditingFinished ( self ) : # intStr = self.intEdit.text () - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : intValue = intStr.toInt () [ 0 ] else : intValue = int ( intStr ) @@ -314,7 +314,7 @@ def onSliderValueChanged ( self, value ) : # def updateGui ( self, value ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.intEdit.setText ( QtCore.QString.number ( value ) ) else : self.intEdit.setText ( str ( value ) ) diff --git a/gui/params/MatrixWidget.py b/gui/params/MatrixWidget.py index c538b95..74f2ddf 100644 --- a/gui/params/MatrixWidget.py +++ b/gui/params/MatrixWidget.py @@ -3,12 +3,12 @@ MatrixWidget.py """ -from core.mePyQt import QtGui, QtCore +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui import gui.ui_settings as UI from paramWidget import ParamWidget -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -116,7 +116,8 @@ def setupUi ( self, MatrixWidget ) : hl1 = QtModule.QHBoxLayout () hl1.setSpacing ( UI.SPACING ) - hl1.setMargin ( 0 ) + #if usePyQt4 : + hl1.setContentsMargins ( 0, 0, 0, 0 ) hl1.addWidget ( self.floatEdit0 ) hl1.addWidget ( self.floatEdit1 ) hl1.addWidget ( self.floatEdit2 ) @@ -128,7 +129,8 @@ def setupUi ( self, MatrixWidget ) : hl2 = QtModule.QHBoxLayout () hl2.setSpacing ( UI.SPACING ) - hl2.setMargin ( 0 ) + #if usePyQt4 : + hl2.setContentsMargins ( 0, 0, 0, 0 ) hl2.addWidget ( self.floatEdit4 ) hl2.addWidget ( self.floatEdit5 ) hl2.addWidget ( self.floatEdit6 ) @@ -140,7 +142,8 @@ def setupUi ( self, MatrixWidget ) : hl3 = QtModule.QHBoxLayout () hl3.setSpacing ( UI.SPACING ) - hl3.setMargin ( 0 ) + #if usePyQt4 : + hl3.setContentsMargins ( 0, 0, 0, 0 ) hl3.addWidget ( self.floatEdit8 ) hl3.addWidget ( self.floatEdit9 ) hl3.addWidget ( self.floatEdit10 ) @@ -152,7 +155,8 @@ def setupUi ( self, MatrixWidget ) : hl4 = QtModule.QHBoxLayout () hl4.setSpacing ( UI.SPACING ) - hl4.setMargin ( 0 ) + #if usePyQt4 : + hl4.setContentsMargins ( 0, 0, 0, 0 ) hl4.addWidget ( self.floatEdit12 ) hl4.addWidget ( self.floatEdit13 ) hl4.addWidget ( self.floatEdit14 ) @@ -169,7 +173,7 @@ def setupUi ( self, MatrixWidget ) : # def connectSignals ( self, MatrixWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : MatrixWidget.connect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) MatrixWidget.connect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) MatrixWidget.connect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) @@ -218,7 +222,7 @@ def connectSignals ( self, MatrixWidget ) : # def disconnectSignals ( self, MatrixWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : MatrixWidget.disconnect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) MatrixWidget.disconnect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) MatrixWidget.disconnect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) @@ -326,22 +330,43 @@ def onCurrentIndexChanged ( self, idx ) : # def updateGui ( self, value ) : # - self.floatEdit0.setText ( QtCore.QString.number ( value [0][0], 'f', 3 ) ) - self.floatEdit1.setText ( QtCore.QString.number ( value [0][1], 'f', 3 ) ) - self.floatEdit2.setText ( QtCore.QString.number ( value [0][2], 'f', 3 ) ) - self.floatEdit3.setText ( QtCore.QString.number ( value [0][3], 'f', 3 ) ) - - self.floatEdit4.setText ( QtCore.QString.number ( value [1][0], 'f', 3 ) ) - self.floatEdit5.setText ( QtCore.QString.number ( value [1][1], 'f', 3 ) ) - self.floatEdit6.setText ( QtCore.QString.number ( value [1][2], 'f', 3 ) ) - self.floatEdit7.setText ( QtCore.QString.number ( value [1][3], 'f', 3 ) ) - - self.floatEdit8.setText ( QtCore.QString.number ( value [2][0], 'f', 3 ) ) - self.floatEdit9.setText ( QtCore.QString.number ( value [2][1], 'f', 3 ) ) - self.floatEdit10.setText ( QtCore.QString.number ( value [2][2], 'f', 3 ) ) - self.floatEdit11.setText ( QtCore.QString.number ( value [2][3], 'f', 3 ) ) - - self.floatEdit12.setText ( QtCore.QString.number ( value [3][0], 'f', 3 ) ) - self.floatEdit13.setText ( QtCore.QString.number ( value [3][1], 'f', 3 ) ) - self.floatEdit14.setText ( QtCore.QString.number ( value [3][2], 'f', 3 ) ) - self.floatEdit15.setText ( QtCore.QString.number ( value [3][3], 'f', 3 ) ) + if usePyQt4 : + self.floatEdit0.setText ( QtCore.QString.number ( value [0][0], 'f', 3 ) ) + self.floatEdit1.setText ( QtCore.QString.number ( value [0][1], 'f', 3 ) ) + self.floatEdit2.setText ( QtCore.QString.number ( value [0][2], 'f', 3 ) ) + self.floatEdit3.setText ( QtCore.QString.number ( value [0][3], 'f', 3 ) ) + + self.floatEdit4.setText ( QtCore.QString.number ( value [1][0], 'f', 3 ) ) + self.floatEdit5.setText ( QtCore.QString.number ( value [1][1], 'f', 3 ) ) + self.floatEdit6.setText ( QtCore.QString.number ( value [1][2], 'f', 3 ) ) + self.floatEdit7.setText ( QtCore.QString.number ( value [1][3], 'f', 3 ) ) + + self.floatEdit8.setText ( QtCore.QString.number ( value [2][0], 'f', 3 ) ) + self.floatEdit9.setText ( QtCore.QString.number ( value [2][1], 'f', 3 ) ) + self.floatEdit10.setText ( QtCore.QString.number ( value [2][2], 'f', 3 ) ) + self.floatEdit11.setText ( QtCore.QString.number ( value [2][3], 'f', 3 ) ) + + self.floatEdit12.setText ( QtCore.QString.number ( value [3][0], 'f', 3 ) ) + self.floatEdit13.setText ( QtCore.QString.number ( value [3][1], 'f', 3 ) ) + self.floatEdit14.setText ( QtCore.QString.number ( value [3][2], 'f', 3 ) ) + self.floatEdit15.setText ( QtCore.QString.number ( value [3][3], 'f', 3 ) ) + else : + self.floatEdit0.setText ( str ( value [0][0] ) ) + self.floatEdit1.setText ( str ( value [0][1] ) ) + self.floatEdit2.setText ( str ( value [0][2] ) ) + self.floatEdit3.setText ( str ( value [0][3] ) ) + + self.floatEdit4.setText ( str ( value [1][0] ) ) + self.floatEdit5.setText ( str ( value [1][1] ) ) + self.floatEdit6.setText ( str ( value [1][2] ) ) + self.floatEdit7.setText ( str ( value [1][3] ) ) + + self.floatEdit8.setText ( str ( value [2][0] ) ) + self.floatEdit9.setText ( str ( value [2][1] ) ) + self.floatEdit10.setText ( str ( value [2][2] ) ) + self.floatEdit11.setText ( str ( value [2][3] ) ) + + self.floatEdit12.setText ( str ( value [3][0] ) ) + self.floatEdit13.setText ( str ( value [3][1] ) ) + self.floatEdit14.setText ( str ( value [3][2] ) ) + self.floatEdit15.setText ( str ( value [3][3] ) ) diff --git a/gui/params/NormalWidget.py b/gui/params/NormalWidget.py index 44b6406..a447603 100644 --- a/gui/params/NormalWidget.py +++ b/gui/params/NormalWidget.py @@ -3,12 +3,12 @@ NormalWidget.py """ -from core.mePyQt import QtGui, QtCore +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui import gui.ui_settings as UI from paramWidget import ParamWidget -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -75,7 +75,7 @@ def setupUi ( self, NormalWidget ) : # def connectSignals ( self, NormalWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : NormalWidget.connect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) NormalWidget.connect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) NormalWidget.connect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) @@ -90,7 +90,7 @@ def connectSignals ( self, NormalWidget ) : # def disconnectSignals ( self, NormalWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : NormalWidget.disconnect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) NormalWidget.disconnect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) NormalWidget.disconnect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) @@ -126,7 +126,7 @@ def onCurrentIndexChanged ( self, idx ) : # def updateGui ( self, value ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.floatEdit0.setText ( QtCore.QString.number( value [0], 'f', 3 ) ) self.floatEdit1.setText ( QtCore.QString.number( value [1], 'f', 3 ) ) self.floatEdit2.setText ( QtCore.QString.number( value [2], 'f', 3 ) ) diff --git a/gui/params/PointWidget.py b/gui/params/PointWidget.py index b769058..5de77b1 100644 --- a/gui/params/PointWidget.py +++ b/gui/params/PointWidget.py @@ -3,12 +3,12 @@ PointWidget.py """ -from core.mePyQt import QtGui, QtCore +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui import gui.ui_settings as UI from paramWidget import ParamWidget -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -75,7 +75,7 @@ def setupUi ( self, PointWidget ) : # def connectSignals ( self, PointWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : PointWidget.connect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) PointWidget.connect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) PointWidget.connect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) @@ -90,7 +90,7 @@ def connectSignals ( self, PointWidget ) : # def disconnectSignals ( self, PointWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : PointWidget.disconnect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) PointWidget.disconnect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) PointWidget.disconnect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) @@ -126,7 +126,7 @@ def onCurrentIndexChanged ( self, idx ) : # def updateGui ( self, value ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.floatEdit0.setText ( QtCore.QString.number( value [0], 'f', 3 ) ) self.floatEdit1.setText ( QtCore.QString.number( value [1], 'f', 3 ) ) self.floatEdit2.setText ( QtCore.QString.number( value [2], 'f', 3 ) ) diff --git a/gui/params/StringWidget.py b/gui/params/StringWidget.py index 953c68c..c3c7006 100644 --- a/gui/params/StringWidget.py +++ b/gui/params/StringWidget.py @@ -3,13 +3,13 @@ StringWidget.py """ -from core.mePyQt import QtGui, QtCore +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from global_vars import app_global_vars, DEBUG_MODE import gui.ui_settings as UI from paramWidget import ParamWidget -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -20,7 +20,7 @@ class StringWidget ( ParamWidget ) : # # buildGui - # + # def buildGui ( self ) : # if not self.ignoreSubtype : @@ -62,7 +62,7 @@ def setupUi ( self, StringWidget ) : # def connectSignals ( self, StringWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : StringWidget.connect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) else : self.stringEdit.editingFinished.connect ( self.onStringEditEditingFinished ) @@ -71,7 +71,7 @@ def connectSignals ( self, StringWidget ) : # def disconnectSignals ( self, StringWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : StringWidget.disconnect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) else : self.stringEdit.editingFinished.disconnect ( self.onStringEditEditingFinished ) @@ -124,7 +124,7 @@ def setupUi ( self, StringWidget ) : # def connectSignals ( self, StringWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : StringWidget.connect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) else : self.selector.activated.connect ( self.onCurrentIndexChanged ) @@ -133,7 +133,7 @@ def connectSignals ( self, StringWidget ) : # def disconnectSignals ( self, StringWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : StringWidget.disconnect ( self.selector, QtCore.SIGNAL ( 'activated(int)' ), self.onCurrentIndexChanged ) else : self.selector.activated.disconnect ( self.onCurrentIndexChanged ) @@ -143,7 +143,7 @@ def disconnectSignals ( self, StringWidget ) : def onCurrentIndexChanged ( self, idx ) : # #pass - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : stringValue = self.selector.itemData ( idx ).toString () else : stringValue = str ( self.selector.itemData ( idx ) ) @@ -190,17 +190,14 @@ def setupUi ( self, StringWidget ) : hl.addWidget ( self.stringEdit ) hl.addWidget ( self.btnBrowseDir ) self.widget.param_vl.addLayout ( hl ) - - - #QtCore.QMetaObject.connectSlotsByName ( StringWidget ) - + QtCore.QMetaObject.connectSlotsByName ( StringWidget ) self.connectSignals ( StringWidget ) # # connectSignals # def connectSignals ( self, StringWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : StringWidget.connect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) StringWidget.connect ( self.btnBrowseDir, QtCore.SIGNAL ( 'clicked()' ), self.onBrowseFile ) else : @@ -211,7 +208,7 @@ def connectSignals ( self, StringWidget ) : # def disconnectSignals ( self, StringWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : StringWidget.disconnect ( self.stringEdit, QtCore.SIGNAL ( 'editingFinished()' ), self.onStringEditEditingFinished ) StringWidget.disconnect ( self.btnBrowseDir, QtCore.SIGNAL ( 'clicked()' ), self.onBrowseFile ) else : @@ -242,7 +239,10 @@ def onBrowseFile ( self ) : curDir = app_global_vars [ 'ProjectPath' ] - filename = QtModule.QFileDialog.getOpenFileName ( self.widget, 'Select file', curDir, typeFilter ) + if usePyQt4 : + filename = QtModule.QFileDialog.getOpenFileName ( self.widget, 'Select file', curDir, typeFilter ) + else : + ( filename, filter ) = QtModule.QFileDialog.getOpenFileName ( self.widget, 'Select file', curDir, typeFilter ) if filename != '' : self.widget.param.setValue ( str ( filename ) ) diff --git a/gui/params/TextWidget.py b/gui/params/TextWidget.py index 2700903..c77c3cd 100644 --- a/gui/params/TextWidget.py +++ b/gui/params/TextWidget.py @@ -3,12 +3,12 @@ TextWidget.py """ -from core.mePyQt import QtGui, QtCore +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui import gui.ui_settings as UI from paramWidget import ParamWidget -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -57,7 +57,7 @@ def setupUi ( self, TextWidget ) : # def connectSignals ( self, TextWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : TextWidget.connect ( self.text_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onTextEditEditingFinished ) else : self.text_plainTextEdit.textChanged.connect ( self.onTextEditEditingFinished ) @@ -66,7 +66,7 @@ def connectSignals ( self, TextWidget ) : # def disconnectSignals ( self, TextWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : TextWidget.disconnect ( self.text_plainTextEdit, QtCore.SIGNAL ( 'textChanged()' ), self.onTextEditEditingFinished ) else : self.text_plainTextEdit.textChanged.connect ( self.onTextEditEditingFinished ) diff --git a/gui/params/VectorWidget.py b/gui/params/VectorWidget.py index f33f502..7a2f5f3 100644 --- a/gui/params/VectorWidget.py +++ b/gui/params/VectorWidget.py @@ -3,12 +3,12 @@ VectorWidget.py """ -from core.mePyQt import QtGui, QtCore +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui import gui.ui_settings as UI from paramWidget import ParamWidget -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -74,7 +74,7 @@ def setupUi ( self, VectorWidget ) : # def connectSignals ( self, VectorWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : VectorWidget.connect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) VectorWidget.connect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) VectorWidget.connect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) @@ -90,7 +90,7 @@ def connectSignals ( self, VectorWidget ) : # def disconnectSignals ( self, VectorWidget ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : VectorWidget.disconnect ( self.floatEdit0, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) VectorWidget.disconnect ( self.floatEdit1, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) VectorWidget.disconnect ( self.floatEdit2, QtCore.SIGNAL ( 'editingFinished()' ), self.onFloatEditEditingFinished ) @@ -126,7 +126,7 @@ def onCurrentIndexChanged ( self, idx ) : # def updateGui ( self, value ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.floatEdit0.setText ( QtCore.QString.number( value [0], 'f', 3 ) ) self.floatEdit1.setText ( QtCore.QString.number( value [1], 'f', 3 ) ) self.floatEdit2.setText ( QtCore.QString.number( value [2], 'f', 3 ) ) diff --git a/gui/params/linkWidget.py b/gui/params/linkWidget.py index 6bd8998..1716565 100644 --- a/gui/params/linkWidget.py +++ b/gui/params/linkWidget.py @@ -3,13 +3,13 @@ linkWidget.py """ -from core.mePyQt import QtGui, QtCore +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from global_vars import app_global_vars, DEBUG_MODE import gui.ui_settings as UI from paramWidget import ParamWidget -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/gui/params/paramLabel.py b/gui/params/paramLabel.py index e02e682..572762f 100644 --- a/gui/params/paramLabel.py +++ b/gui/params/paramLabel.py @@ -3,13 +3,13 @@ paramLabel.py """ -from core.mePyQt import QtGui, QtCore +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from core.signal import Signal from global_vars import app_global_vars, DEBUG_MODE import gui.ui_settings as UI -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -24,7 +24,8 @@ class ParamLabel ( QtModule.QLabel ) : # def __init__ ( self, parent, param = None ) : # - super ( QtModule.QLabel, self ).__init__ ( parent ) + #super ( QtModule.QLabel, self ).__init__ ( parent ) + QtModule.QLabel.__init__ ( self, parent ) self.widget = parent self.param = param if param is not None : @@ -72,7 +73,7 @@ def updateGui ( self ) : # def connectSignals ( self ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.connect ( self.editLabel, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditingFinished ) else : self.editLabel.editingFinished.connect ( self.onEditingFinished ) @@ -81,7 +82,7 @@ def connectSignals ( self ) : # def disconnectSignals ( self ) : # - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.disconnect ( self.editLabel, QtCore.SIGNAL ( 'editingFinished()' ), self.onEditingFinished ) else : self.editLabel.editingFinished.disconnect ( self.onEditingFinished ) diff --git a/gui/params/paramWidget.py b/gui/params/paramWidget.py index 0ba5639..0627b01 100644 --- a/gui/params/paramWidget.py +++ b/gui/params/paramWidget.py @@ -3,7 +3,7 @@ paramWidget.py """ -from core.mePyQt import QtGui, QtCore +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from core.signal import Signal from global_vars import app_global_vars, DEBUG_MODE, VALID_PARAM_TYPES, VALID_RSL_NODE_TYPES, VALID_RSL_PARAM_TYPES @@ -11,7 +11,7 @@ from paramLabel import ParamLabel -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -25,11 +25,12 @@ class ParamWidget ( QtModule.QWidget ) : # def __init__ ( self, param, gfxNode, ignoreSubtype = False ) : # - super ( QtModule.QWidget, self ).__init__ ( None ) + #super ( QtModule.QWidget, self ).__init__ ( None ) + QtModule.QWidget.__init__ ( self ) # # Define signals for PyQt5 # - if QtCore.QT_VERSION >= 0x50000 : + if usePySide or usePyQt5 : # self.nodeParamRemoved = Signal () # @@ -83,23 +84,23 @@ def buildGeneralGui ( self ) : self.label_vl = QtModule.QVBoxLayout () self.label_vl.setSpacing ( UI.SPACING ) - if QtCore.QT_VERSION < 0x50000 : - self.label_vl.setMargin ( 0 ) + #if usePyQt4 : + self.label_vl.setContentsMargins ( 0, 0, 0, 0 ) self.label_vl.setAlignment ( QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft ) #self.gui = QtGui.QWidget ( self ) self.hl = QtModule.QHBoxLayout () self.hl.setSpacing ( UI.SPACING ) - if QtCore.QT_VERSION < 0x50000 : - self.hl.setMargin ( 0 ) + #if usePyQt4 : + self.hl.setContentsMargins ( 0, 0, 0, 0 ) self.hl.setAlignment ( QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft ) # vertical layout for parametrs values (e.g. output links or matrix rows) self.param_vl = QtModule.QVBoxLayout () self.param_vl.setSpacing ( UI.SPACING ) - if QtCore.QT_VERSION < 0x50000 : - self.param_vl.setMargin ( 0 ) + #if usePyQt4 : + self.param_vl.setContentsMargins ( 0, 0, 0, 0 ) self.param_vl.setAlignment ( QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft ) # # add 'isShaderParam' check box only for RSL nodes @@ -114,7 +115,7 @@ def buildGeneralGui ( self ) : self.check.setMaximumSize ( QtCore.QSize ( UI.CHECK_WIDTH, UI.HEIGHT ) ) self.check.setToolTip ( 'Use as Shader parameter' ) self.check.setChecked ( self.param.shaderParam ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : self.connect ( self.check, QtCore.SIGNAL ( 'stateChanged(int)' ), self.onShaderParamChanged ) else : self.check.stateChanged.connect ( self.onShaderParamChanged ) @@ -127,13 +128,13 @@ def buildGeneralGui ( self ) : # if self.param.removable : self.removeButton = QtModule.QToolButton ( self ) - sizePolicy = QtModule.QSizePolicy ( QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed ) + sizePolicy = QtModule.QSizePolicy ( QtModule.QSizePolicy.Fixed, QtModule.QSizePolicy.Fixed ) sizePolicy.setHorizontalStretch ( 20 ) sizePolicy.setVerticalStretch ( 20 ) sizePolicy.setHeightForWidth ( self.removeButton.sizePolicy().hasHeightForWidth() ) self.removeButton.setSizePolicy ( sizePolicy ) self.removeButton.setMaximumSize ( QtCore.QSize ( 20, 20 ) ) - icon = QtModule.QIcon () + icon = QtGui.QIcon () icon.addPixmap ( QtGui.QPixmap ( ':/edit_icons/resources/del_list.png' ), QtGui.QIcon.Normal, QtGui.QIcon.On ) self.removeButton.setIcon ( icon ) self.removeButton.setAutoRaise ( True ) @@ -141,7 +142,7 @@ def buildGeneralGui ( self ) : self.removeButton.setIconSize ( QtCore.QSize ( 16, 16 ) ) self.removeButton.setObjectName ( 'removeButton' ) self.hl.addWidget ( self.removeButton ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.connect ( self.removeButton, QtCore.SIGNAL ( 'clicked()' ), self.onRemoveItem ) else : self.removeButton.clicked.connect ( self.onRemoveItem ) @@ -211,7 +212,7 @@ def buildGui ( self ) : def onRemoveItem ( self ) : # if DEBUG_MODE : print '>> ParamWidget( %s ).onRemoveItem ' % self.param.name - if QtCore.QT_VERSION >= 0x50000 : + if usePyQt4 : self.emit ( QtCore.SIGNAL ( 'nodeParamRemoved' ), self.param ) else : self.nodeParamRemoved.emit ( self.param ) diff --git a/gui/resources_rc.py b/gui/resources_rc.py index 0840f63..98f38e6 100644 --- a/gui/resources_rc.py +++ b/gui/resources_rc.py @@ -7,7 +7,7 @@ # # WARNING! All changes made in this file will be lost! -from core.mePyQt import QtCore +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore qt_resource_data = "\ \x00\x00\x03\x54\ diff --git a/gui/ui_MainWindow.py b/gui/ui_MainWindow.py index 88a0b7d..5cdca23 100644 --- a/gui/ui_MainWindow.py +++ b/gui/ui_MainWindow.py @@ -7,9 +7,9 @@ # # WARNING! All changes made in this file will be lost! -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -39,7 +39,7 @@ def setupUi(self, MainWindow): self.centralwidget.setAcceptDrops(True) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.gridLayout = QtModule.QGridLayout(self.centralwidget) - #self.gridLayout.setMargin(0) + self.gridLayout.setContentsMargins ( 0, 0, 0, 0 ) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) self.tabs = QtModule.QTabWidget(self.centralwidget) self.tabs.setAcceptDrops(True) @@ -409,7 +409,7 @@ def setupUi(self, MainWindow): self.retranslateUi(MainWindow) self.tabs.setCurrentIndex(0) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.connect(self.actionExit, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.close) QtCore.QObject.connect(self.actionProjectSetup, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.onProjectSetup) QtCore.QObject.connect(self.actionShowGrid, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), MainWindow.onShowGrid) diff --git a/gui/ui_imageViewWidget.py b/gui/ui_imageViewWidget.py index d18ba95..46b3eab 100644 --- a/gui/ui_imageViewWidget.py +++ b/gui/ui_imageViewWidget.py @@ -7,9 +7,9 @@ # # WARNING! All changes made in this file will be lost! -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -34,7 +34,7 @@ def setupUi(self, imageViewWidget): imageViewWidget.setObjectName(_fromUtf8("imageViewWidget")) imageViewWidget.resize(479, 334) self.gridLayout = QtModule.QGridLayout(imageViewWidget) - #self.gridLayout.setMargin(4) + self.gridLayout.setContentsMargins ( 4, 4, 4, 4 ) self.gridLayout.setHorizontalSpacing(4) self.gridLayout.setVerticalSpacing(2) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) @@ -71,7 +71,7 @@ def setupUi(self, imageViewWidget): self.gridLayout.setRowStretch(1, 1) self.retranslateUi(imageViewWidget) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.connect(self.btn_render, QtCore.SIGNAL(_fromUtf8("clicked()")), imageViewWidget.updateViewer) QtCore.QObject.connect(self.btn_reset, QtCore.SIGNAL(_fromUtf8("clicked()")), self.imageArea.resetZoom) else : diff --git a/gui/ui_meRendererSetup.py b/gui/ui_meRendererSetup.py index 4739a75..9c71cd9 100644 --- a/gui/ui_meRendererSetup.py +++ b/gui/ui_meRendererSetup.py @@ -7,9 +7,9 @@ # # WARNING! All changes made in this file will be lost! -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -359,7 +359,7 @@ def setupUi(self, meRendererSetup): self.retranslateUi(meRendererSetup) self.tabs.setCurrentIndex(0) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.connect(self.cancelButton, QtCore.SIGNAL("clicked()"), meRendererSetup.close) QtCore.QObject.connect(self.okButton, QtCore.SIGNAL("clicked()"), meRendererSetup.onSelect) QtCore.QObject.connect(self.listPreset, QtCore.SIGNAL("currentIndexChanged(QString)"), meRendererSetup.onIndexChanged) diff --git a/gui/ui_nodeLibraryView.py b/gui/ui_nodeLibraryView.py index 5af9ac7..edb2c4d 100644 --- a/gui/ui_nodeLibraryView.py +++ b/gui/ui_nodeLibraryView.py @@ -7,9 +7,9 @@ # # WARNING! All changes made in this file will be lost! -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -48,7 +48,7 @@ def setupUi(self, nodeLibraryView): self.retranslateUi(nodeLibraryView) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.connect(self.btn_reload, QtCore.SIGNAL(_fromUtf8("clicked()")), nodeLibraryView.onReload) else : self.btn_reload.clicked.connect( nodeLibraryView.onReload) diff --git a/gui/ui_nodeList.py b/gui/ui_nodeList.py index 06c0eda..24126bc 100644 --- a/gui/ui_nodeList.py +++ b/gui/ui_nodeList.py @@ -7,9 +7,9 @@ # # WARNING! All changes made in this file will be lost! -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -26,7 +26,7 @@ def setupUi(self, nodeList): nodeList.resize(374, 699) self.verticalLayout_2 = QtModule.QVBoxLayout(nodeList) self.verticalLayout_2.setSpacing(2) - #self.verticalLayout_2.setMargin(2) + self.verticalLayout_2.setContentsMargins ( 2, 2, 2, 2 ) self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) self.splitter = QtModule.QSplitter(nodeList) self.splitter.setOrientation(QtCore.Qt.Vertical) @@ -49,7 +49,7 @@ def setupUi(self, nodeList): self.groupBox.setObjectName(_fromUtf8("groupBox")) self.verticalLayout = QtModule.QVBoxLayout(self.groupBox) self.verticalLayout.setSpacing(0) - #self.verticalLayout.setMargin(2) + self.verticalLayout.setContentsMargins ( 2, 2, 2, 2 ) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.infoText = QtModule.QTextEdit(self.groupBox) sizePolicy = QtModule.QSizePolicy(QtModule.QSizePolicy.Expanding, QtModule.QSizePolicy.Expanding) diff --git a/gui/ui_nodeParam.py b/gui/ui_nodeParam.py deleted file mode 100644 index bd3a4ed..0000000 --- a/gui/ui_nodeParam.py +++ /dev/null @@ -1,49 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'gui\ui_nodeParam.ui' -# -# Created: Thu Apr 11 21:06:16 2013 -# by: PyQt4 UI code generator 4.9.4 -# -# WARNING! All changes made in this file will be lost! - -from core.mePyQt import QtCore, QtGui - -if QtCore.QT_VERSION < 0x50000 : - QtModule = QtGui -else : - from core.mePyQt import QtWidgets - QtModule = QtWidgets - -try: - _fromUtf8 = QtCore.QString.fromUtf8 -except AttributeError: - _fromUtf8 = lambda s: s - -class Ui_Form(object): - def setupUi(self, Form): - Form.setObjectName(_fromUtf8("Form")) - Form.resize(370, 474) - self.verticalLayout = QtModule.QVBoxLayout(Form) - self.verticalLayout.setSpacing(2) - self.verticalLayout.setMargin(4) - self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) - self.labelLayout = QtModule.QHBoxLayout() - self.labelLayout.setObjectName(_fromUtf8("labelLayout")) - self.label = QtModule.QLabel(Form) - self.label.setObjectName(_fromUtf8("label")) - self.labelLayout.addWidget(self.label) - self.nodeLabelEdit = QtModule.QLineEdit(Form) - self.nodeLabelEdit.setObjectName(_fromUtf8("nodeLabelEdit")) - self.labelLayout.addWidget(self.nodeLabelEdit) - self.labelLayout.setStretch(1, 1) - self.verticalLayout.addLayout(self.labelLayout) - self.label.setBuddy(self.nodeLabelEdit) - - self.retranslateUi(Form) - QtCore.QMetaObject.connectSlotsByName(Form) - - def retranslateUi(self, Form): - Form.setWindowTitle(QtGui.QApplication.translate("Form", "Form", None) - self.label.setText(QtGui.QApplication.translate("Form", "Label", None) - diff --git a/gui/ui_nodeSwatchParam.py b/gui/ui_nodeSwatchParam.py index b4e02c1..d2856df 100644 --- a/gui/ui_nodeSwatchParam.py +++ b/gui/ui_nodeSwatchParam.py @@ -7,9 +7,9 @@ # # WARNING! All changes made in this file will be lost! -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets diff --git a/gui/ui_projectSetup.py b/gui/ui_projectSetup.py index 9ac984a..a6506b6 100644 --- a/gui/ui_projectSetup.py +++ b/gui/ui_projectSetup.py @@ -7,9 +7,9 @@ # # WARNING! All changes made in this file will be lost! -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -131,14 +131,14 @@ def setupUi(self, ProjectSetup): self.verticalLayout_3.addWidget(self.grp_shaders) spacerItem = QtModule.QSpacerItem(20, 20, QtModule.QSizePolicy.Minimum, QtModule.QSizePolicy.Expanding) self.verticalLayout_3.addItem(spacerItem) - self.buttonBox = QtGui.QDialogButtonBox(ProjectSetup) + self.buttonBox = QtModule.QDialogButtonBox(ProjectSetup) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) + self.buttonBox.setStandardButtons(QtModule.QDialogButtonBox.Cancel|QtModule.QDialogButtonBox.Ok) self.buttonBox.setObjectName(_fromUtf8("buttonBox")) self.verticalLayout_3.addWidget(self.buttonBox) self.retranslateUi(ProjectSetup) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), ProjectSetup.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), ProjectSetup.reject) QtCore.QObject.connect(self.btn_project_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), ProjectSetup.onBrowseProjectDir) @@ -158,17 +158,17 @@ def setupUi(self, ProjectSetup): QtCore.QMetaObject.connectSlotsByName(ProjectSetup) def retranslateUi(self, ProjectSetup): - ProjectSetup.setWindowTitle(QtGui.QApplication.translate("ProjectSetup", "Project Setup", None)) - self.grp_project.setTitle(QtGui.QApplication.translate("ProjectSetup", "Project", None)) - self.label_project.setText(QtGui.QApplication.translate("ProjectSetup", "Root", None)) - self.btn_project_dir.setText(QtGui.QApplication.translate("ProjectSetup", "...", None)) - self.grp_shaders.setTitle(QtGui.QApplication.translate("ProjectSetup", "Resources", None)) - self.label_shaders.setText(QtGui.QApplication.translate("ProjectSetup", "Shaders", None)) - self.btn_shaders_dir.setText(QtGui.QApplication.translate("ProjectSetup", "...", None)) - self.label_network.setText(QtGui.QApplication.translate("ProjectSetup", "Networks", None)) - self.btn_network_dir.setText(QtGui.QApplication.translate("ProjectSetup", "...", None)) - self.label_sources.setText(QtGui.QApplication.translate("ProjectSetup", "Sources", None)) - self.btn_sources_dir.setText(QtGui.QApplication.translate("ProjectSetup", "...", None)) - self.label_textures.setText(QtGui.QApplication.translate("ProjectSetup", "Textures", None)) - self.btn_textures_dir.setText(QtGui.QApplication.translate("ProjectSetup", "...", None)) + ProjectSetup.setWindowTitle(QtModule.QApplication.translate("ProjectSetup", "Project Setup", None)) + self.grp_project.setTitle(QtModule.QApplication.translate("ProjectSetup", "Project", None)) + self.label_project.setText(QtModule.QApplication.translate("ProjectSetup", "Root", None)) + self.btn_project_dir.setText(QtModule.QApplication.translate("ProjectSetup", "...", None)) + self.grp_shaders.setTitle(QtModule.QApplication.translate("ProjectSetup", "Resources", None)) + self.label_shaders.setText(QtModule.QApplication.translate("ProjectSetup", "Shaders", None)) + self.btn_shaders_dir.setText(QtModule.QApplication.translate("ProjectSetup", "...", None)) + self.label_network.setText(QtModule.QApplication.translate("ProjectSetup", "Networks", None)) + self.btn_network_dir.setText(QtModule.QApplication.translate("ProjectSetup", "...", None)) + self.label_sources.setText(QtModule.QApplication.translate("ProjectSetup", "Sources", None)) + self.btn_sources_dir.setText(QtModule.QApplication.translate("ProjectSetup", "...", None)) + self.label_textures.setText(QtModule.QApplication.translate("ProjectSetup", "Textures", None)) + self.btn_textures_dir.setText(QtModule.QApplication.translate("ProjectSetup", "...", None)) diff --git a/gui/ui_settingsSetup.py b/gui/ui_settingsSetup.py index f45b109..595a40d 100644 --- a/gui/ui_settingsSetup.py +++ b/gui/ui_settingsSetup.py @@ -7,9 +7,9 @@ # # WARNING! All changes made in this file will be lost! -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -46,7 +46,7 @@ def setupUi(self, SettingsSetup): self.verticalLayout = QtModule.QVBoxLayout(self.grp_dirs) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.hl_temp = QtModule.QHBoxLayout() - self.hl_temp.setSizeConstraint(QtGui.QLayout.SetMinimumSize) + self.hl_temp.setSizeConstraint(QtModule.QLayout.SetMinimumSize) self.hl_temp.setObjectName(_fromUtf8("hl_temp")) self.label_temp = QtModule.QLabel(self.grp_dirs) self.label_temp.setMinimumSize(QtCore.QSize(80, 0)) @@ -162,7 +162,7 @@ def setupUi(self, SettingsSetup): self.verticalLayout_2.addWidget(self.buttonBox) self.retranslateUi(SettingsSetup) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), SettingsSetup.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), SettingsSetup.reject) QtCore.QObject.connect(self.btn_lib_dir, QtCore.SIGNAL(_fromUtf8("clicked()")), SettingsSetup.onBrowseLibraryDir) @@ -185,20 +185,20 @@ def setupUi(self, SettingsSetup): QtCore.QMetaObject.connectSlotsByName(SettingsSetup) def retranslateUi(self, SettingsSetup): - SettingsSetup.setWindowTitle(QtGui.QApplication.translate("SettingsSetup", "Settings Setup", None)) - self.grp_dirs.setTitle(QtGui.QApplication.translate("SettingsSetup", "Directories", None)) - self.label_temp.setText(QtGui.QApplication.translate("SettingsSetup", "Temp", None)) - self.btn_temp_dir.setText(QtGui.QApplication.translate("SettingsSetup", "...", None)) - self.label_inc.setText(QtGui.QApplication.translate("SettingsSetup", "Includes", None)) - self.btn_inc_dir.setText(QtGui.QApplication.translate("SettingsSetup", "...", None)) - self.label_lib.setText(QtGui.QApplication.translate("SettingsSetup", "Library", None)) - self.btn_lib_dir.setText(QtGui.QApplication.translate("SettingsSetup", "...", None)) - self.label_nodes.setText(QtGui.QApplication.translate("SettingsSetup", "Nodes", None)) - self.btn_nodes_dir.setText(QtGui.QApplication.translate("SettingsSetup", "...", None)) - self.label_shaders.setText(QtGui.QApplication.translate("SettingsSetup", "Shaders", None)) - self.btn_shaders_dir.setText(QtGui.QApplication.translate("SettingsSetup", "...", None)) - self.label_textures.setText(QtGui.QApplication.translate("SettingsSetup", "Textures", None)) - self.btn_textures_dir.setText(QtGui.QApplication.translate("SettingsSetup", "...", None)) - self.label_archives.setText(QtGui.QApplication.translate("SettingsSetup", "Archives", None)) - self.btn_archives_dir.setText(QtGui.QApplication.translate("SettingsSetup", "...", None)) + SettingsSetup.setWindowTitle(QtModule.QApplication.translate("SettingsSetup", "Settings Setup", None)) + self.grp_dirs.setTitle(QtModule.QApplication.translate("SettingsSetup", "Directories", None)) + self.label_temp.setText(QtModule.QApplication.translate("SettingsSetup", "Temp", None)) + self.btn_temp_dir.setText(QtModule.QApplication.translate("SettingsSetup", "...", None)) + self.label_inc.setText(QtModule.QApplication.translate("SettingsSetup", "Includes", None)) + self.btn_inc_dir.setText(QtModule.QApplication.translate("SettingsSetup", "...", None)) + self.label_lib.setText(QtModule.QApplication.translate("SettingsSetup", "Library", None)) + self.btn_lib_dir.setText(QtModule.QApplication.translate("SettingsSetup", "...", None)) + self.label_nodes.setText(QtModule.QApplication.translate("SettingsSetup", "Nodes", None)) + self.btn_nodes_dir.setText(QtModule.QApplication.translate("SettingsSetup", "...", None)) + self.label_shaders.setText(QtModule.QApplication.translate("SettingsSetup", "Shaders", None)) + self.btn_shaders_dir.setText(QtModule.QApplication.translate("SettingsSetup", "...", None)) + self.label_textures.setText(QtModule.QApplication.translate("SettingsSetup", "Textures", None)) + self.btn_textures_dir.setText(QtModule.QApplication.translate("SettingsSetup", "...", None)) + self.label_archives.setText(QtModule.QApplication.translate("SettingsSetup", "Archives", None)) + self.btn_archives_dir.setText(QtModule.QApplication.translate("SettingsSetup", "...", None)) diff --git a/gui/ui_viewComputedCodeDialog.py b/gui/ui_viewComputedCodeDialog.py index 4bb8163..b23fac8 100644 --- a/gui/ui_viewComputedCodeDialog.py +++ b/gui/ui_viewComputedCodeDialog.py @@ -7,9 +7,9 @@ # # WARNING! All changes made in this file will be lost! -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui -if QtCore.QT_VERSION < 0x50000 : +if not usePyQt5 : QtModule = QtGui else : from core.mePyQt import QtWidgets @@ -45,7 +45,7 @@ def setupUi(self, ViewComputedCodeDialog): self.gridLayout.addWidget(self.buttonBox, 1, 0, 1, 1) self.retranslateUi(ViewComputedCodeDialog) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), ViewComputedCodeDialog.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), ViewComputedCodeDialog.reject) else : diff --git a/gui/ui_workArea.py b/gui/ui_workArea.py deleted file mode 100644 index b3ea2cc..0000000 --- a/gui/ui_workArea.py +++ /dev/null @@ -1,41 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file '.\ui_workArea.ui' -# -# Created: Mon Mar 14 07:25:17 2011 -# by: PyQt4 UI code generator 4.8.2 -# -# WARNING! All changes made in this file will be lost! - -from core.mePyQt import QtCore, QtGui - -if QtCore.QT_VERSION < 0x50000 : - QtModule = QtGui -else : - from core.mePyQt import QtWidgets - QtModule = QtWidgets - -try: - _fromUtf8 = QtCore.QString.fromUtf8 -except AttributeError: - _fromUtf8 = lambda s: s - -class Ui_workArea(object): - def setupUi(self, workArea): - workArea.setObjectName(_fromUtf8("workArea")) - workArea.resize(668, 594) - workArea.setAcceptDrops(True) - self.gridLayout = QtModule.QGridLayout(workArea) - self.gridLayout.setMargin(0) - self.gridLayout.setSpacing(0) - self.gridLayout.setObjectName(_fromUtf8("gridLayout")) - self.graphicsView = QtModule.QGraphicsView(workArea) - self.graphicsView.setObjectName(_fromUtf8("graphicsView")) - self.gridLayout.addWidget(self.graphicsView, 0, 0, 1, 1) - - self.retranslateUi(workArea) - QtCore.QMetaObject.connectSlotsByName(workArea) - - def retranslateUi(self, workArea): - workArea.setWindowTitle(QtModule.QApplication.translate("workArea", "network", None )) - diff --git a/meShaderEd.py b/meShaderEd.py index 62dbb57..2da4056 100644 --- a/meShaderEd.py +++ b/meShaderEd.py @@ -19,7 +19,7 @@ """ import os, sys -from core.mePyQt import QtCore, QtGui +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, QtGui from core.meCommon import * from core.nodeLibrary import NodeLibrary @@ -27,6 +27,12 @@ from global_vars import app_global_vars, app_colors, DEBUG_MODE +if not usePyQt5 : + QtModule = QtGui +else : + from core.mePyQt import QtWidgets + QtModule = QtWidgets + root = normPath ( sys.path [0] ) branchName = 'QT5' version = '0.3.4b ' + branchName @@ -42,7 +48,7 @@ def setDefaultValue ( key, def_value ) : if not app_settings.contains ( key ): app_settings.setValue ( key, def_value ) value = app_settings.value ( key ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : if value.toString () == 'true' : value = True elif value.toString () == 'false' : value = False else : @@ -66,7 +72,7 @@ def getDefaultValue ( settings, group, key, def_value = None ) : if group != '' : settings.beginGroup ( group ) value = settings.value ( key ) if group != '' : settings.endGroup ( ) - if QtCore.QT_VERSION < 0x50000 : + if usePyQt4 : if value.toString () == 'true' : value = True elif value.toString () == 'false' : value = False else : @@ -84,11 +90,91 @@ def getDefaultValue ( settings, group, key, def_value = None ) : value = str ( value ) return value -if QtCore.QT_VERSION < 0x50000 : - QtModule = QtGui -else : - from core.mePyQt import QtWidgets - QtModule = QtWidgets +# +# getSettingsStrValue +# +#def getSettingsStrValue ( settings, key ) : +# # +# if usePyQt4 : +# return str ( settings.value ( key ).toString () ) +# else : +# return str ( settings.value ( key ) ) +# +# createDefaultProject +# +def createDefaultProject ( settings, check_if_exist = False ) : + # + project_filename = getDefaultValue ( settings, '', 'project_filename' ) + project = getDefaultValue ( settings, '', 'project' ) + project_shaders = getDefaultValue ( settings, '', 'project_shaders' ) + project_textures = getDefaultValue ( settings, '', 'project_textures' ) + shader_networks = getDefaultValue ( settings, '', 'shader_networks' ) + shader_sources = getDefaultValue ( settings, '', 'shader_sources' ) + + filename = normPath ( os.path.join ( project, project_filename ) ) + if check_if_exist : + if os.path.exists ( filename ) : + print '>> DefaultProject %s already exists...' % filename + return + print '>> createDefaultProject %s' % filename + with open ( filename , 'w') as f : + f.write ( 'project_shaders=%s\n' % toRelativePath ( project, project_shaders ) ) + f.write ( 'project_textures=%s\n' % toRelativePath ( project, project_textures ) ) + f.write ( 'shader_networks=%s\n' % toRelativePath ( project, shader_networks ) ) + f.write ( 'shader_sources=%s\n' % toRelativePath ( project, shader_sources ) ) + f.closed +# +# openDefaultProject +# +def openDefaultProject ( settings, global_vars, project, project_filename ) : + # + ret = False + if os.path.exists ( project ) : + # + filename = normPath ( os.path.join ( project, project_filename ) ) + project_dir = normPath ( project ) + # setup default setting + project_shaders = normPath ( os.path.join ( project_dir,'shaders' ) ) + project_textures = normPath ( os.path.join ( project_dir,'textures' ) ) + shader_networks_dir = normPath ( os.path.join ( project_shaders,'shn' ) ) + shader_sources_dir = normPath ( os.path.join ( project_shaders,'src' ) ) + if os.path.exists ( filename ) : + # read settings from existing project file + f = open ( filename, 'r' ) + for line in f : + ( key, value ) = line.split ( '=' ) + name = key.strip() + if name in [ 'project_shaders', 'project_textures', 'shader_networks', 'shader_sources' ] : + print 'name = %s value = %s' % ( name, fromRelativePath ( project_dir, value.strip() ) ) + settings.setValue ( name, fromRelativePath ( project_dir, value.strip() ) ) + f.close () + else : + # setup default settings and create default file + settings.setValue ( 'project', project_dir ) + settings.setValue ( 'project_shaders', project_shaders ) + settings.setValue ( 'project_textures', project_textures ) + settings.setValue ( 'shader_networks', shader_networks_dir ) + settings.setValue ( 'shader_sources', shader_sources_dir ) + + createDefaultProject ( settings ) + + global_vars [ 'ProjectPath' ] = project_dir + + global_vars [ 'ProjectShaders' ] = project_shaders + global_vars [ 'ProjectTextures' ] = project_textures + + global_vars [ 'ProjectNetworks' ] = shader_networks_dir + global_vars [ 'ProjectSources' ] = shader_sources_dir + + global_vars [ 'ProjectSearchPath' ] = sanitizeSearchPath ( project_dir ) + global_vars [ 'ProjectSearchShaders' ] = sanitizeSearchPath ( project_shaders ) + global_vars [ 'ProjectSearchTextures' ] = sanitizeSearchPath ( project_textures ) + + createMissingDirs ( [ project_shaders, project_textures, shader_networks_dir, shader_sources_dir ] ) + + ret = True + + return ret # # main routine # @@ -129,7 +215,7 @@ def main () : # # setup globals # - app_global_vars [ 'version' ] = getSettingsStrValue ( app_settings, 'version' ) + app_global_vars [ 'version' ] = getDefaultValue ( app_settings, '', 'version' ) app_global_vars [ 'RootPath' ] = root app_global_vars [ 'TempPath' ] = temp_dir app_global_vars [ 'ProjectPath' ] = project_dir @@ -219,11 +305,14 @@ def main () : if DEBUG_MODE : #safeEffects = QtCore.QT_VERSION >= 0x40600 and QtCore.PYQT_VERSION > 0x40704 print '* Python %s' % sys.version - print '* QT_VERSION = %0X' % QtCore.QT_VERSION - print '* PYQT_VERSION = %0X' % QtCore.PYQT_VERSION + if not usePySide : + print '* QT_VERSION = %0X' % QtCore.QT_VERSION + print '* PYQT_VERSION = %0X' % QtCore.PYQT_VERSION + else : + print '* PySide Version = %s' % QtCore.__version__ if sys.platform.startswith ( 'win') : - if QtCore.QT_VERSION < 0x50000 : + if not usePyQt5 : pass #QtModule.QApplication.setStyle ( QtModule.QStyleFactory.create ( 'Cleanlooks' ) ) #QtModule.QApplication.setPalette ( QtModule.QApplication.style ().standardPalette () ) diff --git a/mkpyqt5.py b/mkpyqt5.py index 79a2ecc..ead3a66 100644 --- a/mkpyqt5.py +++ b/mkpyqt5.py @@ -22,9 +22,9 @@ import platform import stat import sys -from core.mePyQt import QtCore, PythonQtType +from core.mePyQt import usePySide, usePyQt4, usePyQt5, QtCore, PythonQtType -if QtCore.QT_VERSION < 0x50000 : pass +if not usePyQt5 : pass __version__ = "1.0.4" diff --git a/lib/nodes/example_001.xml b/samples/shaders/shn/example_001.xml similarity index 100% rename from lib/nodes/example_001.xml rename to samples/shaders/shn/example_001.xml diff --git a/samples/shaders/shn/startup.xml b/samples/shaders/shn/startup.xml new file mode 100644 index 0000000..bcfddd7 --- /dev/null +++ b/samples/shaders/shn/startup.xml @@ -0,0 +1,210 @@ + + + Short NodeNetwork description + + + Image viewer with dynamicaly added inputs + + + +#print ":: Hello from (%s) XML control param code !!!" % self.label +from core.params.imageNodeParam import ImageNodeParam +lastNonremovableParam = node.getInputParamByName ( 'selector' ) +lastNonremovableParamIdx = node.inputParams.index ( lastNonremovableParam ) +lastParamIdx = len ( node.inputParams ) +suffixIdx = lastParamIdx - lastNonremovableParamIdx + +newParam = ImageNodeParam () +newParam.setup ( 'image' + str ( suffixIdx ), '', '', '' ) +newParam.value = '' +newParam.default = '' +newParam.subtype="file" +newParam.range="All files=*.*:TIFF=*.tif:PNG=*.png:JPEG=*.jpg" +newParam.removable = True +node.addInputParam ( newParam ) +node.updateNodeParams () + + + + + + + + + + + + + + + + + + + + Basic preview RIB with geometry primitive, 2 distant and 1 environment light + + + + + + + + + + + + + + + + + + + + + + + + + + + Basic surface shader. + + + + + + + + + + + + + + + + + +