Skip to content

Commit

Permalink
NodeParam new attribute: removable (for removing dynamcally added par…
Browse files Browse the repository at this point in the history
…ameters)
  • Loading branch information
ymesh committed Jun 10, 2013
1 parent 62e1262 commit 05aed46
Show file tree
Hide file tree
Showing 9 changed files with 264 additions and 208 deletions.
6 changes: 4 additions & 2 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@

meShaderEd changes log

version 0.3.1 (?? May 2013)
version 0.3.1 (10 Jun 2013)
- ControlParam with special <control_code> section in XML, that allows to execute
python code for dynamic parameters manipulation
- ShaderInfo class for parsing compiled shaders parameters
- Lib/RIB/shaders/ReadShader.xml node that uses ShaderInfo call inside <control_code> section
for reloading shader parameters
- NodeParam new attributes : enabled, spaceDef, arraySize, defaultArray, valueArray
(though arrays parameters support is not fully implemented yet...)
btext (button text for button ControlParam)
removable (for removing dynamcally added parameters)
- Fixed some shading nodes, code, shaders and textures for Air, Aqsis, Pixie and RenderDotC compatibility
- Tested on PyQt 4.10.2 that was linked with Qt 5.0.2 libraries.
- New service nodes in Library


version 0.3.0 (16 Apr 2013)
SwatchNode for image preview in shading network
Expand Down
6 changes: 6 additions & 0 deletions core/nodeParam.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__ ( self, xml_param = None, isRibParam = False ) :
self.isRibParam = isRibParam
self.display = True
self.enabled = True
self.removable = False

# extra parameter description
self.detail = '' # variable, uniform
Expand Down Expand Up @@ -195,6 +196,10 @@ def parseFromXML ( self, xml_param ) :
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 () )
Expand Down Expand Up @@ -234,6 +239,7 @@ def parseToXML ( self, dom ) :
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
Expand Down
3 changes: 2 additions & 1 deletion core/params/controlParam.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ def parseToXML ( self, dom ) :
code_text = dom.createTextNode ( self.control_code )
code_tag.appendChild ( code_text )
xmlnode.appendChild ( code_tag )
if self.btext != '' : xmlnode.setAttribute ( 'btext', self.range )

if self.btext != '' : xmlnode.setAttribute ( 'btext', self.btext )

return xmlnode
#
Expand Down
4 changes: 2 additions & 2 deletions gui/nodeList.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from core.node import Node
from core.nodeLibrary import NodeLibrary
#
#
# NodeList
#
class NodeList ( QtGui.QWidget ) :
#
Expand Down Expand Up @@ -111,7 +111,7 @@ def showDescription ( self, item ) :
description = ''

if nodeKind != 'folder' :
if nodeIcon !='' :
if nodeIcon != '' :
iconFileName = os.path.join ( os.path.dirname ( str ( nodeFilename ) ), str ( nodeIcon ) )
print str ( iconFileName )
description += '<img src="' + iconFileName + '" />' # width="128" height="128"
Expand Down
14 changes: 14 additions & 0 deletions gui/nodeParamView.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@ def onParamChanged ( self, param ) :
print ">> NodeParamView.onParamChanged node = %s param = %s" % ( self.gfxNode.node.label, param.name )
self.emit ( QtCore.SIGNAL ( 'nodeParamChanged' ), self.gfxNode, param ) # .node
#
# onParamRemoved
#
def onParamRemoved ( self, param ) :
#
print ">> NodeParamView.onRemoved node = %s param = %s" % ( self.gfxNode.node.label, param.name )
self.gfxNode.node.removeParam ( param )
#self.emit ( QtCore.SIGNAL ( 'nodeParamChanged' ), self.gfxNode, param ) # .node
self.disconnectParamSignals ()
self.updateGui ()
self.connectParamSignals ()
#
# nodeLabelChanged
#
def nodeLabelChanged ( self ) :
Expand Down Expand Up @@ -189,6 +200,9 @@ def updateGui ( self ) :
frameLayout.addWidget ( paramWidget )
if not inputParam.enabled :
paramWidget.setEnabled ( False )

if inputParam.removable :
QtCore.QObject.connect ( paramWidget, QtCore.SIGNAL ( 'nodeParamRemoved' ), self.onParamRemoved )

spacer = QtGui.QSpacerItem ( 20, 20, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding )
frameLayout.addItem ( spacer )
Expand Down
55 changes: 40 additions & 15 deletions gui/params/paramWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def buildGeneralGui ( self ) :
if self.gfxNode is not None :
if not self.gfxNode.node.type in INVALID_RSL_PARAM_TYPES :
if 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 ) )
Expand All @@ -76,20 +75,39 @@ def buildGeneralGui ( self ) :
else :
spacer = QtGui.QSpacerItem ( UI.LT_SPACE, UI.HEIGHT, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum )
self.hl.addItem ( spacer )

self.label = QtGui.QLabel ( self )
font = QtGui.QFont ()
font.setBold ( False )
self.label.setFont ( font )

#if self.param.type != 'control' :
self.label.setText ( self.param.label )

self.label.setMinimumSize ( QtCore.QSize ( UI.LABEL_WIDTH, UI.HEIGHT ) )
self.label.setMaximumSize ( QtCore.QSize ( UI.LABEL_WIDTH, UI.HEIGHT ) )
self.label.setAlignment ( QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter )

self.hl.addWidget ( self.label )
#
# 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 ( 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 ( ':/edit_icons/resources/minus.png' ), QtGui.QIcon.Normal, QtGui.QIcon.On )
self.removeButton.setIcon ( icon1 )
self.removeButton.setObjectName ( 'removeButton' )

QtCore.QObject.connect ( self.removeButton, QtCore.SIGNAL ( 'clicked()' ), self.onRemoveItem )

self.hl.addWidget ( self.removeButton )

self.label = QtGui.QLabel ( self )
font = QtGui.QFont ()
font.setBold ( False )
self.label.setFont ( font )

#if self.param.type != 'control' :
self.label.setText ( self.param.label )

self.label.setMinimumSize ( QtCore.QSize ( UI.LABEL_WIDTH, UI.HEIGHT ) )
self.label.setMaximumSize ( QtCore.QSize ( UI.LABEL_WIDTH, UI.HEIGHT ) )
self.label.setAlignment ( QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter )

self.hl.addWidget ( self.label )
self.vl.addWidget ( self.gui )
#
# onShaderParamChanged
Expand All @@ -105,4 +123,11 @@ def buildGui ( self ) :
#
spacer = QtGui.QSpacerItem ( 20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum )
self.hl.addItem ( spacer )

#
# onRemoveItem
#
def onRemoveItem ( self ) :
print '>> ParamWidget( %s ).onRemoveItem ' % self.param.name
self.emit ( QtCore.SIGNAL ( 'nodeParamRemoved' ), self.param )

3 changes: 3 additions & 0 deletions lib/nodes/RIB/shaders/ReadShader.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if node is not None :
lastOutputParamIdx = node.outputParams.index ( lastOutputParam )
print '*** removing input params ***'
while lastInputParamIdx < ( len ( node.inputParams ) - 1 ) :
param = node.inputParams.pop ()
print param.name, param.type
Expand All @@ -38,12 +39,14 @@ if node is not None :
print '*** added input params ***'
for param in shaderInfo.inputParams :
if param.arraySize is None :
param.removable = True
node.addInputParam ( param )
print param.name, param.type
print '*** added output params ***'
for param in shaderInfo.outputParams :
if param.arraySize is None :
param.removable = True
node.addOutputParam ( param )
print param.name, param.type
Expand Down
17 changes: 6 additions & 11 deletions meShaderEd.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""
meShaderEd.py
version 0.3.1b (26 Apr 2013)
version 0.3.1 (10 Jun 2013)
written by Yuri.Meshalkin (mesh@kpp.kiev.ua)
Expand Down Expand Up @@ -31,7 +31,7 @@


root = normPath ( sys.path[0] )
version = '0.3.1b'
version = '0.3.1'

app_settings = QtCore.QSettings ( QtCore.QSettings.IniFormat,
QtCore.QSettings.UserScope,
Expand Down Expand Up @@ -65,13 +65,11 @@ def getDefaultValue ( settings, group, key ) :
defRenderer = setDefaultValue ( 'defRenderer','3Delight' )
app_renderer = meRendererPreset ( os.path.join ( root, 'renderers.xml' ), defRenderer )
#app_renderer.setPresetFile ( os.path.join( root, 'renderers.xml' ), defRenderer )

#
#
# main routine
#
def main ():
def main () :
#global root

app = QtGui.QApplication ( sys.argv )

app_settings.setValue ( 'version', version )
Expand Down Expand Up @@ -104,7 +102,6 @@ def main ():
#
setDefaultValue ( 'recent_projects_max', 10 )
setDefaultValue ( 'recent_networks_max', 10 )

#
# setup globals
#
Expand Down Expand Up @@ -150,9 +147,7 @@ def main ():

#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 ) )
Expand All @@ -170,7 +165,7 @@ def main ():
# It's exec_ because exec is a reserved word in Python
sys.exit ( app.exec_ () )
#
#
#
#
if __name__ == "__main__":
#
Expand All @@ -193,4 +188,4 @@ def main ():
if QtCore.QT_VERSION < 50000 :
QtGui.QApplication.setPalette ( QtGui.QApplication.style ().standardPalette () )

main()
main ()
Loading

0 comments on commit 05aed46

Please sign in to comment.