Last active
May 12, 2021 09:46
-
-
Save Swordslayer/1582be3dc34e586993a29682318f0e41 to your computer and use it in GitHub Desktop.
Using Qt UI with scripted plugins.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plugin simpleManipulator MXSQtSample | |
name:"MXSQtSample" category:"Manipulators" | |
classID:#(0x76d22fb1, 0x190d5d2d) | |
( | |
parameters main rollout:params | |
( | |
radius type:#worldUnits default:10 | |
on radius set val do if not loading and this.params.isDisplayed do | |
( | |
this.params.dial.blockSignals on --> prevent recursive calls | |
this.params.dial.setValue val | |
this.params.dial.blockSignals off | |
) | |
) | |
fn setRadius val = with undo on this.radius = val | |
rollout params "Radius" autoLayoutOnResize:on | |
( | |
local QtWidgets = if QtWidgets == undefined then python.import "PySide2.QtWidgets" else QtWidgets | |
local dial = QtWidgets.QDial() | |
local layout | |
on params open do | |
( | |
dial.setWrapping on | |
dial.setMaximum 100 | |
dial.setValue this.radius | |
dial.valueChanged.connect this.setRadius | |
dial.sliderPressed.connect (fn startHold = theHold.superBegin()) | |
dial.sliderReleased.connect (fn acceptHold = theHold.superAccept "Radius changed") | |
local rolloutWidget = QtWidgets.QWidget.find (UIAccessor.GetParentWindow params.hwnd) | |
layout = rolloutWidget.layout() | |
) | |
on params rolledUp open do | |
if open then layout.addWidget dial else layout.removeWidget dial | |
) | |
tool create numPoints:1 (on mousePoint click do nodeTM.translation = gridPoint) | |
on updateGizmos do | |
( | |
this.clearGizmos() | |
this.addGizmoShape (manip.makeCircle [0, 0, 0] radius 16) 0 (blue/255.) (orange/255.) | |
) | |
) | |
MXSQtSample isSelected:on | |
SetCommandPanelTaskMode #modify |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment