Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for optional text label and icon for connection curves #29

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Nodz/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import nodz_main
from . import nodz_utils
1 change: 1 addition & 0 deletions default_config.json → Nodz/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// General > Edit values BUT do not delete.
"scene_width": 2000,
"scene_height": 2000,
"scene_bg_color": [75,75,75,255],
"grid_size": 36,
"antialiasing": true,
"antialiasing_boost": true,
Expand Down
44 changes: 26 additions & 18 deletions nodz_demo.py → Nodz/nodz_demo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os

from Qt import QtCore, QtWidgets
import nodz_main
from . import nodz_main

try:
app = QtWidgets.QApplication([])
Expand All @@ -20,71 +22,71 @@
# Nodes
@QtCore.Slot(str)
def on_nodeCreated(nodeName):
print 'node created : ', nodeName
print('node created : ', nodeName)

@QtCore.Slot(str)
def on_nodeDeleted(nodeName):
print 'node deleted : ', nodeName
print('node deleted : ', nodeName)

@QtCore.Slot(str, str)
def on_nodeEdited(nodeName, newName):
print 'node edited : {0}, new name : {1}'.format(nodeName, newName)
print('node edited : {0}, new name : {1}'.format(nodeName, newName))

@QtCore.Slot(str)
def on_nodeSelected(nodesName):
print 'node selected : ', nodesName
print('node selected : ', nodesName)

@QtCore.Slot(str, object)
def on_nodeMoved(nodeName, nodePos):
print 'node {0} moved to {1}'.format(nodeName, nodePos)
print('node {0} moved to {1}'.format(nodeName, nodePos))

@QtCore.Slot(str)
def on_nodeDoubleClick(nodeName):
print 'double click on node : {0}'.format(nodeName)
print('double click on node : {0}'.format(nodeName))

# Attrs
@QtCore.Slot(str, int)
def on_attrCreated(nodeName, attrId):
print 'attr created : {0} at index : {1}'.format(nodeName, attrId)
print('attr created : {0} at index : {1}'.format(nodeName, attrId))

@QtCore.Slot(str, int)
def on_attrDeleted(nodeName, attrId):
print 'attr Deleted : {0} at old index : {1}'.format(nodeName, attrId)
print('attr Deleted : {0} at old index : {1}'.format(nodeName, attrId))

@QtCore.Slot(str, int, int)
def on_attrEdited(nodeName, oldId, newId):
print 'attr Edited : {0} at old index : {1}, new index : {2}'.format(nodeName, oldId, newId)
print('attr Edited : {0} at old index : {1}, new index : {2}'.format(nodeName, oldId, newId))

# Connections
@QtCore.Slot(str, str, str, str)
def on_connected(srcNodeName, srcPlugName, destNodeName, dstSocketName):
print 'connected src: "{0}" at "{1}" to dst: "{2}" at "{3}"'.format(srcNodeName, srcPlugName, destNodeName, dstSocketName)
print('connected src: "{0}" at "{1}" to dst: "{2}" at "{3}"'.format(srcNodeName, srcPlugName, destNodeName, dstSocketName))

@QtCore.Slot(str, str, str, str)
def on_disconnected(srcNodeName, srcPlugName, destNodeName, dstSocketName):
print 'disconnected src: "{0}" at "{1}" from dst: "{2}" at "{3}"'.format(srcNodeName, srcPlugName, destNodeName, dstSocketName)
print('disconnected src: "{0}" at "{1}" from dst: "{2}" at "{3}"'.format(srcNodeName, srcPlugName, destNodeName, dstSocketName))

# Graph
@QtCore.Slot()
def on_graphSaved():
print 'graph saved !'
print('graph saved !')

@QtCore.Slot()
def on_graphLoaded():
print 'graph loaded !'
print('graph loaded !')

@QtCore.Slot()
def on_graphCleared():
print 'graph cleared !'
print('graph cleared !')

@QtCore.Slot()
def on_graphEvaluated():
print 'graph evaluated !'
print('graph evaluated !')

# Other
@QtCore.Slot(object)
def on_keyPressed(key):
print 'key pressed : ', key
print('key pressed : ', key)

nodz.signal_NodeCreated.connect(on_nodeCreated)
nodz.signal_NodeDeleted.connect(on_nodeDeleted)
Expand Down Expand Up @@ -152,6 +154,10 @@ def on_keyPressed(key):
nodz.createAttribute(node=nodeB, name='Battr4', index=-1, preset='attr_preset_3',
plug=True, socket=False, dataType=int, plugMaxConnections=1, socketMaxConnections=-1)

nodz.createAttribute(node=nodeB, name='Battr5', index=-1, preset='attr_preset_3',
plug=True, socket=False, dataType=int, plugMaxConnections=-1, socketMaxConnections=-1,
connectionLabel="Sample", connectionIcon=os.path.join(os.path.dirname(__file__),'pixmap.png'))



# Node C
Expand Down Expand Up @@ -191,6 +197,8 @@ def on_keyPressed(key):
nodz.createConnection('nodeB', 'Battr2', 'nodeA', 'Aattr3')
nodz.createConnection('nodeB', 'Battr1', 'nodeA', 'Aattr4')

nodz.createConnection('nodeB', 'Battr5', 'nodeA', 'Aattr4')

# Attributes Edition
nodz.editAttribute(node=nodeC, index=0, newName=None, newIndex=-1)
nodz.editAttribute(node=nodeC, index=-1, newName='NewAttrName', newIndex=None)
Expand All @@ -207,7 +215,7 @@ def on_keyPressed(key):


# Graph
print nodz.evaluateGraph()
print(nodz.evaluateGraph())

nodz.saveGraph(filePath='Enter your path')

Expand Down
Loading