Package NetworkEditor :: Module net :: Class Network
[hide private]
[frames] | no frames]

Class Network

source code

mglutil.gui.Misc.Tk.KeybdModMonitor.KeyboardModifierMonitor --+
                                                              |
                                                 object --+   |
                                                          |   |
                                  itemBase.NetworkItemsBase --+
                                                              |
                                                             Network
Known Subclasses:
macros.MacroNetwork

class to hold all the information about a bunch of nodes and connections

Instance Methods [hide private]
  __init__(self, name='Noname')
  getNodeByName(self, name)
nodeList <- getNodeByName(self, name) Return all the nodes who's name match the name regular expression
  nodeIdToNumber(self, id)
return the current index of this node in network.nodes if the node's _id is given.
  getNodesByIds(self, ids)
returns a list of nodes based on a list of ids
  freeze(self, updateGUI=0)
  unfreeze(self, updateGUI=0)
  isFrozen(self)
  createCallbackManager(self, event, doc=None)
  addCallbackManager(self, event, func)
  describeCallbackManager(self, event)
  postCanvasMenu(self, event)
  delete(self, saveValues=0)
  destroyIcons(self, saveValues=0)
  destroyCanvas(self)
  buildIcons(self)
  rename(self, name)
  enter(self, event=None)
  configure(self, event=None)
  bindCallbacks(self)
  createCanvas(self)
create the Canvas and Title widgets
  setSplineConnections(self, yesno)
  getNetworkCreationSourceCode(self, networkName='masterNet', selectedOnly=0, indent="", withRun=True, ignoreOriginal=False, copyright=False)
returns code to re-create a network containing nodes and connections selectedOnly: True/False.
  buildLibraryImportCache(self, cache, network, selectedOnly=False)
Loop recursively (if macro nodes are present) over all nodes and build a dictionary containing the libraries needed to save a network
  getLibraryImportCode(self, cache, indent, editor='masterNet.getEditor()', importOnly=False)
Returns code to import libraries.
  getNodesCreationSourceCode(self, networkName, selectedOnly=0, indent="", ignoreOriginal=False)
build a string representation of this network
  getNodes(self, nodesIds)
return a list of nodes corresponding to canvasIds
  getNodesConnsPorts(self, nodesIds)
find out what objects correspond to a list of canvasIds this method is called by self.pickedItems()
  getConnections(self, nodes)
[2Connection], [1Connections], [1nodes] <- getConnections(nodes)...
  getNodesAndInputPort(self, nodesIds)
  getNodesAndOutputPort(self, nodesIds)
  getNodesAndConnections(self, nodesIds)
  pickedItems(self, event)
find out what has been picked
  mouse1Up(self, event=None)
  mouse2Up(self, event=None)
  mouse1Down(self, event=None, nbClick=1)
  mouse2Down(self, event=None)
  startDrawingSelectionBox(self, event)
  selectionBoxMotion(self, event)
  drawSelectionBox(self, event)
  selectionBoxEnd(self, event)
  moveCanvasStart(self, event=None)
  moveCanvas(self, event=None)
  moveCanvasEnd(self, event=None)
  moveSelectedNodesStart(self, event)
  moveSelectedNodes(self, event=None)
  moveSelectedNodesEnd(self, event=None)
  scale(self, xscale, yscale=None, xo=0, yo=0)
Scale the network
  scaleNetworkStart(self, event=None)
  scaleNetworkMotion(self, event)
  scaleNetworkEnd(self, event)
  resetScaleSelectedNodes(self)
  scaleHyper(self, xc, yc, rad)
  resetScale(self, event=None)
  getObjectsFromNames(self, names, objects)
[nodes] <- getObjectsFromNames(names) names can be a ';' separated list of names objects has to be a ssequence of objects each havinf a name attribute for each name in names, the first node matching the name is returned regular expressions are allowed
  objectsAsString(self, objects)
  expand(self, objects, objectList)
  expandNodes(self, objects)
  expandConnections(self, objects)
  resetNodeCache(self)
  addNode(self, node, posx, posy, tagModified=False, undo=1)
None <- addNode(node, posx, posy) Add a node to the network.
  connectNodes(self, node1, node2, portNode1=0, portNode2=0, mode='angles', name=None, blocking=True, undo=1, doNotScheduleOrCb=False, **kw)
NetworkConnection <- connectNodes(node1, node2, portNode1=1, portNode2=0, mode='angles', name='NoName', blocking=True, undo=1, **kw) create a networkConnection object that connects these 2 nodes if doNotScheduleOrCb is True, ScheduleNode() is not called, neither the callbacks afterConnect and beforeConnect
  specialConnectNodes(self, node1, node2, portNode1=0, portNode2=0, mode='angles', name='NoName', undo=1, **kw)
NetworkConnection <- specialConnectNodes(node1, node2, portNode1=1, portNode2=0, mode='angles', name='NoName', undo=1, **kw) create a networkConnection object that connects these 2 nodes
  deleteNodes(self, nodes, undo=1)
  deleteConnections(self, connections, undo=1, schedule=True)
Call this method to delete connections.
  deleteConnectionsNoCB(self, c, undo=1)
This method deletes connections without calling the beforeDisconnect() and afterDisconnect() methods.
  deleteConnection(self, node1, port1, node2, port2)
Delete a connection between port1 (output) and port2 (input).
  toggleSelection(self, nodes, undo=1)
  clearSelection(self, undo=1)
  clearSelectedNodes(self, undo=1)
  selectNodes(self, nodes, undo=1)
  deselectNodes(self, nodes, undo=1)
  clearSelectedConnections(self, undo=1)
  selectConnections(self, connections, undo=1)
  deselectConnections(self, connections, undo=1)
  arrowKeys_cb(self, dx, dy, event=None)
move subgraph of selected nodes when arrow keys are pressed
  moveSubGraph(self, nodes, dx, dy, absolute=False, tagModified=True, undo=1)
None <- moveSubGraph(nodes, dx, dy, absolute=False, undo=1) update the nodes' coordinates and move node's icon, also update connections If absolute is set to False (default), the graph moves by dx,dy, else it move TO dx, dy All nodes have an attribute hasMoved which will be set to True.
  waitForCompletion(self)
  stop(self)
set execStatus to 'stop'.
  start(self)
set execStatus to 'pending'.
  pause(self)
set execStatus to 'pause'.
  togglePause(self, event=None)
toggles execStatus between 'pause' and resume
  resume(self)
set execStatus to 'running'.
  getExecStatus(self)
  checkExecStatus(self)
  tagSubtree(self, node, val)
  widthFirstChildren(self, nodeIndex, allNodes)
build a list of nodes corresponding to a width first traversal of the network starting from the nodes specified in allNodes.
  getAllNodes(self, roots)
build a list of all the nodes under roots in the order they will be executed
  endOfRun(self, net)
function called after an execution ends
  run(self, roots=None)
schedule the subtree of nodes under roots for execution in a separate thread.
  subRun(self, roots=None)
  runNodes(self, allNodes, resetList=True)
run the list of nodes in the same thread as the caller
  resetWidgetValues(self)
Reset all widgets in the current network to the initialValue as defined in node.widgetDescr.
  createUserPanel(self, name, **kw)
  deleteUserPanel(self, name)
  getSubRunNodes(self, roots=None)

Inherited from mglutil.gui.Misc.Tk.KeybdModMonitor.KeyboardModifierMonitor: getModifier, isAlt, isControl, isShift, modifierDown, modifierUp

Inherited from itemBase.NetworkItemsBase: delEditor, getEditor, setEditor

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__


Properties [hide private]

Inherited from itemBase.NetworkItemsBase: editor

Inherited from object: __class__


Method Details [hide private]

__init__(self, name='Noname')
(Constructor)

source code 
None
Overrides: mglutil.gui.Misc.Tk.KeybdModMonitor.KeyboardModifierMonitor.__init__

getNodeByName(self, name)

source code 
nodeList <- getNodeByName(self, name) Return all the nodes who's name match the name regular expression

nodeIdToNumber(self, id)

source code 
return the current index of this node in network.nodes if the node's _id is given.

getNodesByIds(self, ids)

source code 
returns a list of nodes based on a list of ids

freeze(self, updateGUI=0)

source code 
None

unfreeze(self, updateGUI=0)

source code 
None

isFrozen(self)

source code 
None

createCallbackManager(self, event, doc=None)

source code 
None

addCallbackManager(self, event, func)

source code 
None

describeCallbackManager(self, event)

source code 
None

postCanvasMenu(self, event)

source code 
None

delete(self, saveValues=0)

source code 
None

destroyIcons(self, saveValues=0)

source code 
None

destroyCanvas(self)

source code 
None

buildIcons(self)

source code 
None

rename(self, name)

source code 
None

enter(self, event=None)

source code 
None

configure(self, event=None)

source code 
None

bindCallbacks(self)

source code 
None

createCanvas(self)

source code 
create the Canvas and Title widgets

setSplineConnections(self, yesno)

source code 
None

getNetworkCreationSourceCode(self, networkName='masterNet', selectedOnly=0, indent="", withRun=True, ignoreOriginal=False, copyright=False)

source code 
returns code to re-create a network containing nodes and connections
selectedOnly: True/False. If set to true, we handle selected nodes only
indent: a string with whitespaces for code indentation
ignoreOriginal: True/False. Default:False. If set to True, we ignore the
                _original attribute of nodes (for example, nodes in a macro
                network that came from a node library where nodes are marked
                original)

buildLibraryImportCache(self, cache, network, selectedOnly=False)

source code 
Loop recursively (if macro nodes are present) over all nodes and build a dictionary containing the libraries needed to save a network

getLibraryImportCode(self, cache, indent, editor='masterNet.getEditor()', importOnly=False)

source code 
Returns code to import libraries. if importOnly=True, only the import statement is generated. If importOnly=False (Default), both import statement and adding to libary code is generated

getNodesCreationSourceCode(self, networkName, selectedOnly=0, indent="", ignoreOriginal=False)

source code 
build a string representation of this network

getNodes(self, nodesIds)

source code 
return a list of nodes corresponding to canvasIds

getNodesConnsPorts(self, nodesIds)

source code 
find out what objects correspond to a list of canvasIds this method is called by self.pickedItems()

getConnections(self, nodes)

source code 
[2Connection], [1Connections], [1nodes] <- getConnections(nodes)
returns 3 lists:
   a list of connections having both nodes in the set
   a list of connections having only 1 node in the set
   the list of nodes connected to a node outside the set

getNodesAndInputPort(self, nodesIds)

source code 
None

getNodesAndOutputPort(self, nodesIds)

source code 
None

getNodesAndConnections(self, nodesIds)

source code 
None

pickedItems(self, event)

source code 
find out what has been picked

mouse1Up(self, event=None)

source code 
None

mouse2Up(self, event=None)

source code 
None

mouse1Down(self, event=None, nbClick=1)

source code 
None

mouse2Down(self, event=None)

source code 
None

startDrawingSelectionBox(self, event)

source code 
None

selectionBoxMotion(self, event)

source code 
None

drawSelectionBox(self, event)

source code 
None

selectionBoxEnd(self, event)

source code 
None

moveCanvasStart(self, event=None)

source code 
None

moveCanvas(self, event=None)

source code 
None

moveCanvasEnd(self, event=None)

source code 
None

moveSelectedNodesStart(self, event)

source code 
None

moveSelectedNodes(self, event=None)

source code 
None

moveSelectedNodesEnd(self, event=None)

source code 
None

scale(self, xscale, yscale=None, xo=0, yo=0)

source code 
Scale the network

scaleNetworkStart(self, event=None)

source code 
None

scaleNetworkMotion(self, event)

source code 
None

scaleNetworkEnd(self, event)

source code 
None

resetScaleSelectedNodes(self)

source code 
None

scaleHyper(self, xc, yc, rad)

source code 
None

resetScale(self, event=None)

source code 
None

getObjectsFromNames(self, names, objects)

source code 
[nodes] <- getObjectsFromNames(names) names can be a ';' separated list of names objects has to be a ssequence of objects each havinf a name attribute for each name in names, the first node matching the name is returned regular expressions are allowed

objectsAsString(self, objects)

source code 
None

expand(self, objects, objectList)

source code 
None

expandNodes(self, objects)

source code 
None

expandConnections(self, objects)

source code 
None

resetNodeCache(self)

source code 
None

addNode(self, node, posx, posy, tagModified=False, undo=1)

source code 
None <- addNode(node, posx, posy)
Add a node to the network. Here, the attribute _original is set to False, and
all _modified (node, ports, widgets) are reset to False.
node: has to be an instance of a NetworkNode
posx and posy: coordiantes of the center of the node expressed
    in the canva's coordinate system
tagModified: True or False. Sets the _modified flag of the node.

connectNodes(self, node1, node2, portNode1=0, portNode2=0, mode='angles', name=None, blocking=True, undo=1, doNotScheduleOrCb=False, **kw)

source code 
NetworkConnection <- connectNodes(node1, node2, portNode1=1, portNode2=0, mode='angles', name='NoName', blocking=True, undo=1, **kw) create a networkConnection object that connects these 2 nodes if doNotScheduleOrCb is True, ScheduleNode() is not called, neither the callbacks afterConnect and beforeConnect

specialConnectNodes(self, node1, node2, portNode1=0, portNode2=0, mode='angles', name='NoName', undo=1, **kw)

source code 
NetworkConnection <- specialConnectNodes(node1, node2, portNode1=1, portNode2=0, mode='angles', name='NoName', undo=1, **kw) create a networkConnection object that connects these 2 nodes

deleteNodes(self, nodes, undo=1)

source code 
None

deleteConnections(self, connections, undo=1, schedule=True)

source code 
Call this method to delete connections. This method will also call
beforeDisconnect() and afterDisconnect() that can be overwritten.
schedule: 
    if we are deleteing the node in port2, we don't want to schedule
    or trigger the callback

deleteConnectionsNoCB(self, c, undo=1)

source code 
This method deletes connections without calling the beforeDisconnect() and afterDisconnect() methods. This method is basically doing all the work.

deleteConnection(self, node1, port1, node2, port2)

source code 
Delete a connection between port1 (output) and port2 (input). Port1 and port2 can be either a port instance or the port name.

toggleSelection(self, nodes, undo=1)

source code 
None

clearSelection(self, undo=1)

source code 
None

clearSelectedNodes(self, undo=1)

source code 
None

selectNodes(self, nodes, undo=1)

source code 
None

deselectNodes(self, nodes, undo=1)

source code 
None

clearSelectedConnections(self, undo=1)

source code 
None

selectConnections(self, connections, undo=1)

source code 
None

deselectConnections(self, connections, undo=1)

source code 
None

arrowKeys_cb(self, dx, dy, event=None)

source code 
move subgraph of selected nodes when arrow keys are pressed

moveSubGraph(self, nodes, dx, dy, absolute=False, tagModified=True, undo=1)

source code 
None <- moveSubGraph(nodes, dx, dy, absolute=False, undo=1) update the nodes' coordinates and move node's icon, also update connections If absolute is set to False (default), the graph moves by dx,dy, else it move TO dx, dy All nodes have an attribute hasMoved which will be set to True.

waitForCompletion(self)

source code 
None

stop(self)

source code 
set execStatus to 'stop'. The execution will stop after completion of the current node

start(self)

source code 
set execStatus to 'pending'. The network can be run

pause(self)

source code 
set execStatus to 'pause'. The network execution will pause after the completion of the current node

togglePause(self, event=None)

source code 
toggles execStatus between 'pause' and resume

resume(self)

source code 
set execStatus to 'running'. Waiting execution threads are notified.

getExecStatus(self)

source code 
None

checkExecStatus(self)

source code 
None

tagSubtree(self, node, val)

source code 
None

widthFirstChildren(self, nodeIndex, allNodes)

source code 
build a list of nodes corresponding to a width first traversal of the network starting from the nodes specified in allNodes. Children for which the attribute isSchedulingNode was set to 1 are not added. A node will not be added to the list before all of its parents have been added

getAllNodes(self, roots)

source code 
build a list of all the nodes under roots in the order they will be executed

endOfRun(self, net)

source code 
function called after an execution ends

run(self, roots=None)

source code 
schedule the subtree of nodes under roots for execution in a separate thread. If roots is None list self.rootNodes is used

subRun(self, roots=None)

 
None

runNodes(self, allNodes, resetList=True)

source code 
run the list of nodes in the same thread as the caller

resetWidgetValues(self)

source code 
Reset all widgets in the current network to the initialValue as defined in node.widgetDescr. If no nodes are selected, we loop over all nodes, else we loop over the selected nodes. If a macro node is present, we recursively call this method in the macro network.

createUserPanel(self, name, **kw)

source code 
None

deleteUserPanel(self, name)

source code 
None

getSubRunNodes(self, roots=None)

source code 
None