git clone https://git.lucas.co/hou-control.git
hcnetwork editor: update
python3.11libs/hclib/core/hcnetworkeditor.py | 138 ++++++++++++---------------
python3.11libs/nodegraphhooks.py | 6 +-
2 files changed, 66 insertions(+), 78 deletions(-)
diff --git a/python3.11libs/hclib/core/hcnetworkeditor.py b/python3.11libs/hclib/core/hcnetworkeditor.py
index b3352a1..b2d53af 100644
--- a/python3.11libs/hclib/core/hcnetworkeditor.py
+++ b/python3.11libs/hclib/core/hcnetworkeditor.py
@@ -8,80 +8,64 @@ class HCNetworkEditor(HCPathTab):
self.editor = tab
self.deltat = 2
- def showPathMessage(self):
- self.editor.flashMessage(image=None, message=self.path(), duration=1)
+ def addDot(self):
+ if len(self.selectedNodes()) == 1:
+ dot = self.context().createNetworkDot()
+ dot.setInput(node)
+ dot.setPosition(self.cursorPos())
- """
- Nodes
- """
+ def addNetworkBox(self):
+ networkbox = self.context().createNetworkBox()
+ networkbox.setPosition(self.currentNode().position())
+
+ def addStickyNote(self):
+ stickynote = self.context().createStickyNote()
+ p = self.cursorPos()
+ stickynote.setPosition(p)
+ stickynote.setColor(hou.Color(0.71, 0.78, 1.0))
def arrangeNodes(self):
# self.context().layoutChildren(horizontal_spacing=5, vertical_spacing=
return
+ def bounds(self):
+ return self.editor.visibleBounds()
+
+ def cursorPos(self):
+ return self.editor.cursorPosition()
+
+ def deselectAll(self):
+ self.selectedNodes().setSelected(False)
+
+ def frameAll(self):
+ self.editor.requestZoomReset()
+
def quantizeNodes(self):
return
- def translateNodes(self, direction):
- idxmap = {
- 'up': 1,
- 'down': 1,
- 'left': 0,
- 'right': 0
- }
- rectifiermap = {
- 'up': hou.Vector2(0, 0.85),
- 'down': hou.Vector2(0, -0.85),
- 'left': hou.Vector2(0.-0.85, 0),
- 'right': hou.Vector2(0.85, 0)
- }
- for node in self.selectedNodes():
- idx = idxmap[direction]
- p = node.position() + rectifiermap[direction]
- val = p[idx]
- if val%1 <= 0.5:
- val = math.floor(val)
- else:
- val = math.ceil(val)
- p[idx] = val
- node.setPosition(p)
-
def renameNode(self):
node = self.currentNode()
name = hou.ui.readInput("Rename_node", buttons=("Yes", "No"))
if name[0] == 0:
node.setName(name[1])
- """
- Objects
- """
-
- def addNetworkBox(self):
- networkbox = self.context().createNetworkBox()
- networkbox.setPosition(self.currentNode().position())
-
- def addStickyNote(self):
- stickynote = self.context().createStickyNote()
- p = self.cursorPos()
- stickynote.setPosition(p)
- stickynote.setColor(hou.Color(0.71, 0.78, 1.0))
+ def screenSize(self):
+ return self.editor.screenBounds().size()
- def placeDot(self):
- if len(self.selectedNodes()) == 1:
- dot = self.context().createNetworkDot()
- dot.setInput(node)
- dot.setPosition(self.cursorPos())
+ def setBounds(self, bounds):
+ self.editor.setVisibleBounds(bounds)
- """
- Selection
- """
+ def showPathMessage(self):
+ self.editor.flashMessage(image=None, message=self.path(), duration=1)
- def deselectAll(self):
- self.selectedNodes().setSelected(False)
+ def showRadialMenu(self):
+ from ..utils.hcradialutils import editorRadialMain
+ menu = editorRadialMain()
+ print(menu)
+ self.editor.displayRadialMenu("hc_editor_radial_menu")
- """
- Settings
- """
+ def size(self):
+ return self.bounds().size()
def toggleDimUnusedNodes(self):
map = {
@@ -116,27 +100,29 @@ class HCNetworkEditor(HCPathTab):
mode = str(hou.updateModeSetting())
hou.setUpdateMode(map[mode])
- """
- Viewport
- """
-
- def cursorPos(self):
- return self.editor.cursorPosition()
-
- def bounds(self):
- return self.editor.visibleBounds()
-
- def frameAll(self):
- self.editor.requestZoomReset()
-
- def screenSize(self):
- return self.editor.screenBounds().size()
-
- def setBounds(self, bounds):
- self.editor.setVisibleBounds(bounds)
-
- def size(self):
- return self.bounds().size()
+ def translateNodes(self, direction):
+ idxmap = {
+ 'up': 1,
+ 'down': 1,
+ 'left': 0,
+ 'right': 0
+ }
+ rectifiermap = {
+ 'up': hou.Vector2(0, 0.85),
+ 'down': hou.Vector2(0, -0.85),
+ 'left': hou.Vector2(0.-0.85, 0),
+ 'right': hou.Vector2(0.85, 0)
+ }
+ for node in self.selectedNodes():
+ idx = idxmap[direction]
+ p = node.position() + rectifiermap[direction]
+ val = p[idx]
+ if val%1 <= 0.5:
+ val = math.floor(val)
+ else:
+ val = math.ceil(val)
+ p[idx] = val
+ node.setPosition(p)
def translateView(self, direction):
xformmap = {
diff --git a/python3.11libs/nodegraphhooks.py b/python3.11libs/nodegraphhooks.py
index 03e62dd..79580a4 100755
--- a/python3.11libs/nodegraphhooks.py
+++ b/python3.11libs/nodegraphhooks.py
@@ -35,11 +35,13 @@ def createEventHandler(uievent, pending_actions):
'Ctrl+L': lambda: hceditor.translateNodes('right'),
## Organize
'Ctrl+Shift+A': hceditor.arrangeNodes,
- 'Shift+D': hceditor.placeDot,
+ 'Shift+D': hceditor.addDot,
## Grid
'Shift+G': hceditor.toggleGridMode,
## Update mode
- 'M': hceditor.toggleUpdateMode
+ 'M': hceditor.toggleUpdateMode,
+ ## Radial menu
+ 'C': hceditor.showRadialMenu
}
key = uievent.key