Ejemplo n.º 1
0
def initialize_plugin():
    # Create Pyside interface with iClone main window
    ic_dlg = wrapInstance(int(RLPy.RUi.GetMainWindow()), QtWidgets.QMainWindow)

    plugin_menu = ic_dlg.menuBar().findChild(
        QtWidgets.QMenu, "pysample_menu")  # Check if the menu item exists
    if plugin_menu is None:

        # Create Pyside layout for QMenu named "Python Samples" and attach it to the Plugins menu
        plugin_menu = wrapInstance(
            int(RLPy.RUi.AddMenu("Python Samples", RLPy.EMenu_Plugins)),
            QtWidgets.QMenu)
        plugin_menu.setObjectName(
            "pysample_menu"
        )  # Setting an object name for the menu is equivalent to giving it an ID

    # Check if the menu action already exists
    menu_actions = plugin_menu.actions()
    for i in range(len(menu_actions)):
        if menu_actions[i].text() == "Pose Manager":
            plugin_menu.removeAction(
                menu_actions[i])  # Remove duplicate actions

    # Set up the menu action
    menu_action = plugin_menu.addAction("Pose Manager")
    menu_action.triggered.connect(show_window)
Ejemplo n.º 2
0
def initialize_plugin():
    global api_version
    api_version = RLPy.RApplication.GetApiVersion()
    # Create Pyside interface with iClone main window
    ic_dlg = wrapInstance(int(RLPy.RUi.GetMainWindow()), QtWidgets.QMainWindow)

    # Check if the menu item exists
    plugin_menu = ic_dlg.menuBar().findChild(QtWidgets.QMenu, "pysample_menu")
    if plugin_menu is None:

        # Create Pyside layout for QMenu named "Python Samples" and attach it to the Plugins menu
        plugin_menu = wrapInstance(int(RLPy.RUi.AddMenu("Python Samples", RLPy.EMenu_Plugins)), QtWidgets.QMenu)
        plugin_menu.setObjectName("pysample_menu")  # Setting an object name for the menu is equivalent to giving it an ID

    # Add the "Spring Joints" menu item to Plugins > Python Samples
    menu_action = plugin_menu.addAction("Spring Joints")

    # Show the dialog window when the menu item is triggered
    menu_action.triggered.connect(show_window)

    create_ui()

    global spring_ui
    global spring_callbacks
    spring_callbacks["dialog_events"] = DialogEventCallback()
    spring_callbacks["dialog_events"].register_show_event_callback(on_show_main_dlg)
    spring_callbacks["dialog_events"].register_hide_event_callback(on_close_main_dlg)
    spring_ui["dialog_window"].RegisterEventCallback(spring_callbacks["dialog_events"])

    register_event()
Ejemplo n.º 3
0
    def __init__(self, _main_dlg):
        global main_dlg
        global main_pyside_dlg
        global main_dlg_view
        global main_dlg_root
        global esc_action
        global ui_kit

        main_dlg = _main_dlg

        # Create an URL to the QML file
        main_dlg_url = QUrl("qrc:/objKit/qml/Main.qml")
        main_dlg_view = PySide2.QtQuickWidgets.QQuickWidget()
        main_dlg_view.setSource(main_dlg_url)
        main_dlg_view.setResizeMode(
            PySide2.QtQuickWidgets.QQuickWidget.SizeRootObjectToView)

        # Python get Main.qml object
        main_dlg_root = main_dlg_view.rootObject()

        # Set dialog Layout with titlebar
        main_pyside_dlg = wrapInstance(int(main_dlg.GetWindow()),
                                       PySide2.QtWidgets.QDialog)
        main_pyside_dlg.setObjectName("Visible Object Kit")

        # HotKey
        esc_action = wrapInstance(int(ui_kit.AddHotKey("Escape")),
                                  PySide2.QtWidgets.QAction)
        esc_action.triggered.connect(self.hide)
        esc_action.setEnabled(False)

        # Generate custom dialog
        self.main_layout = main_pyside_dlg.layout()
        self.main_layout.addWidget(main_dlg_view)
        main_pyside_dlg.adjustSize()
Ejemplo n.º 4
0
def initialize_plugin():
    print("start_initialize_plugin")
    global app
    global main_dlg_view
    global main_dlg_context
    global objKitModule
    global ui_kit
    global obj_kit

    app = PySide2.QtWidgets.QApplication.instance()
    if not app:
        app = PySide2.QtWidgets.QApplication([])
    app.aboutToQuit.connect(close_application)

    # Init mainwindow
    main_widget = wrapInstance(int(ui_kit.GetMainWindow()), PySide2.QtWidgets.QWidget)

    # Init Visible object kit dialog
    main_dlg = ui_kit.CreateRDialog()
    main_dlg.SetWindowTitle("Visible Object Kit")
    obj_kit = ObjectKit(main_dlg)

    # Menu
    plugin_menu = wrapInstance(int(ui_kit.AddMenu("Visible Object Kit", RLPy.EMenu_Plugins)), PySide2.QtWidgets.QMenu)
    plugin_action = plugin_menu.addAction("Visible Object Kit")
    plugin_action.setIcon((QIcon(":/objKit/icon/objKit.svg")))
    plugin_action.triggered.connect(show_main_dlg)

    # Inject Python data into QML
    main_dlg_view = obj_kit.get_main_dlg()
    main_dlg_context = main_dlg_view.rootContext()
    objKitModule = ObjectKitQmlModule()
    main_dlg_context.setContextProperty("objKitModule", objKitModule)
    print("end_initialize_plugin")
Ejemplo n.º 5
0
def initialize_plugin():
    # Add menu
    ic_dlg = wrapInstance(int(RLPy.RUi.GetMainWindow()), PySide2.QtWidgets.QMainWindow)
    plugin_menu = ic_dlg.menuBar().findChild(PySide2.QtWidgets.QMenu, "pysample_menu")
    if (plugin_menu == None):
        plugin_menu = wrapInstance(int(RLPy.RUi.AddMenu("Python Samples", RLPy.EMenu_Plugins)), PySide2.QtWidgets.QMenu)
        plugin_menu.setObjectName("pysample_menu")

    batch_render_action = plugin_menu.addAction("Batch Render Folder")
    batch_render_action.setObjectName("batch_render_action")
    batch_render_action.triggered.connect(show_dialog)
Ejemplo n.º 6
0
def initialize_plugin():
    # Create Pyside interface with iClone main window
    ic_dlg = wrapInstance(int(RLPy.RUi.GetMainWindow()), QtWidgets.QMainWindow)
    # Check if the menu item exists
    plugin_menu = ic_dlg.menuBar().findChild(QtWidgets.QMenu, "pysample_menu")
    if plugin_menu is None:
        # Create Pyside layout for QMenu named "Python Samples" and attach it to the Plugins menu
        plugin_menu = wrapInstance(int(RLPy.RUi.AddMenu("Python Samples", RLPy.EMenu_Plugins)), QtWidgets.QMenu)
        plugin_menu.setObjectName("pysample_menu")  # Setting an object name for the menu is equivalent to giving it an ID
    # Add the "Smooth Camera Follow" menu item to Plugins > Python Samples
    menu_action = plugin_menu.addAction("Smooth Camera Follow")
    # Show the dialog window when the menu item is triggered
    menu_action.triggered.connect(show_window)
Ejemplo n.º 7
0
def add_menu(menu_title, action_name, trigger_func):
    ic_dlg = wrapInstance(int(RLPy.RUi.GetMainWindow()),
                          PySide2.QtWidgets.QMainWindow)
    plugin_menu = ic_dlg.menuBar().findChild(PySide2.QtWidgets.QMenu,
                                             "pysample_menu")
    if plugin_menu is None:
        plugin_menu = wrapInstance(
            int(RLPy.RUi.AddMenu("Python Samples", RLPy.EMenu_Plugins)),
            PySide2.QtWidgets.QMenu)
        plugin_menu.setObjectName("pysample_menu")

    menu_action = plugin_menu.addAction(action_name)
    menu_action.triggered.connect(trigger_func)
Ejemplo n.º 8
0
def initialize_plugin():
    global event_list, event_callback

    ic_dlg = wrapInstance(int(RLPy.RUi.GetMainWindow()), QtWidgets.QMainWindow)
    plugin_menu = ic_dlg.menuBar().findChild(QtWidgets.QMenu, "pysample_menu")
    if plugin_menu is None:
        plugin_menu = wrapInstance(int(RLPy.RUi.AddMenu(
            "Python Samples", RLPy.EMenu_Plugins)), QtWidgets.QMenu)
        plugin_menu.setObjectName('pysample_menu')

    # dialog
    menu_action = plugin_menu.addAction("PropPlanter")
    init_dialog()
    menu_action.triggered.connect(show_dialog)
Ejemplo n.º 9
0
def show_window():
    global caf_ui, caf_callbacks

    if "window" in caf_ui:  # If the window already exist...
        print("Camera Auto-Focus window session already exists!")
        return  # Exit before creating a duplicate window

    caf_ui["window"] = RLPy.RUi.CreateRDockWidget()

    # Register dialog events
    caf_callbacks["dock"] = DialogEventCallback()
    caf_ui["window"].RegisterEventCallback(caf_callbacks["dock"])
    caf_ui["window"].SetAllowedAreas(RLPy.EDockWidgetAreas_RightDockWidgetArea)

    # Create Pyside layout for RDialog
    caf_ui["dock"] = wrapInstance(int(caf_ui["window"].GetWindow()), QtWidgets.QDockWidget)

    # Read and set the QT ui file from the script location
    ui_file = QtCore.QFile(os.path.dirname(__file__) + "/Camera_Auto_Focus.ui")
    ui_file.open(QtCore.QFile.ReadOnly)
    caf_ui["widget"] = QtUiTools.QUiLoader().load(ui_file)
    ui_file.close()
    caf_ui["dock"].setWidget(caf_ui["widget"])

    caf_ui["window"].Show()

    register_events()  # Register all global callback events
Ejemplo n.º 10
0
def run_script():
    global layer_manager_dlg
    layer_manager_tree_widget = LayerManagerTreeWidget()

    layer_manager_dlg = RLPy.RUi.CreateRDockWidget()
    layer_manager_dlg.SetWindowTitle("Group Manager")

    main_pyside_dlg = wrapInstance(int(layer_manager_dlg.GetWindow()),
                                   QtWidgets.QDockWidget)

    main_widget = QtWidgets.QWidget()

    main_pyside_dlg.setWidget(main_widget)

    main_widget_layout = QtWidgets.QVBoxLayout()

    main_widget.setLayout(main_widget_layout)

    label = QtWidgets.QLabel()
    label.setText(
        "Right click on an empty area to create a new Group.\nYou can drag the nodes to assign Groups.\nDouble-click on the Group label to rename the Group."
    )

    main_widget_layout.addWidget(label)
    main_widget_layout.addWidget(layer_manager_tree_widget)

    layer_manager_dlg.Show()
Ejemplo n.º 11
0
def run_script(): 
    global layer_manager_dlg
    layer_manager_tree_widget = LayerManagerTreeWidget()
    
    layer_manager_dlg = RLPy.RUi.CreateRDockWidget()
    layer_manager_dlg.SetWindowTitle("Layer Manager")
    
    main_pyside_dlg = wrapInstance(int(layer_manager_dlg.GetWindow()), QtWidgets.QDockWidget)
    
    main_widget = QtWidgets.QWidget()
    
    main_pyside_dlg.setWidget(main_widget)
    
    main_widget_layout = QtWidgets.QVBoxLayout()
    
    main_widget.setLayout(main_widget_layout)
    
    
    label = QtWidgets.QLabel()
    label.setText("Right Click on the empty area to create a new layer.\nDrag the node to the new layer.\nDouble Click to rename the layer.")
    
    main_widget_layout.addWidget(label)
    main_widget_layout.addWidget(layer_manager_tree_widget)
    
    layer_manager_dlg.Show()
Ejemplo n.º 12
0
def init_dialog():
    global layer_manager_dlg
    global layer_manager_tree_widget
    layer_manager_tree_widget = LayerManagerTreeWidget()

    layer_manager_dlg = RLPy.RUi.CreateRDockWidget()
    layer_manager_dlg.SetWindowTitle("Group Manager")

    main_pyside_dlg = wrapInstance(int(layer_manager_dlg.GetWindow()),
                                   QtWidgets.QDockWidget)

    main_widget = QtWidgets.QWidget()

    main_pyside_dlg.setWidget(main_widget)

    main_widget_layout = QtWidgets.QVBoxLayout()

    main_widget.setLayout(main_widget_layout)

    label = QtWidgets.QLabel()
    label.setText(
        "Right click on an empty area to create a new Group.\nYou can drag the nodes to assign Groups.\nDouble-click on the Group label to rename the Group."
    )

    button = QtWidgets.QPushButton()
    button.setText("Update")
    button.setMinimumSize(25, 25)
    button.clicked.connect(update_tree_view)

    main_widget_layout.addWidget(label)
    main_widget_layout.addWidget(layer_manager_tree_widget)
    main_widget_layout.addWidget(button)
Ejemplo n.º 13
0
def viewport_screenshot(width, height):
    '''
    Grabs a screen shot of the viewport render region and returns a Qt Pixmap.
    This is a rather flimsy implementation -changes to the render screen ratio can expose additional brittleness
    '''
    main_window_address = RLPy.RUi.GetMainWindow()
    main_window = wrapInstance(int(main_window_address), QtWidgets.QWidget)

    # iClone viewport is situated in the "centralwidget" Qt object
    viewport = main_window.findChild(QtWidgets.QWidget, "centralwidget")
    viewport_parts = viewport.findChildren(QtWidgets.QWidget, "")
    render_view = viewport_parts[0]

    # iClone doesn't have an object name for the render view so we have to hack a solution to find it
    for part in viewport_parts:
        if part.geometry().height(
        ) > viewport.geometry().height() * 0.20 or part.geometry().width(
        ) > viewport.geometry().width() * 0.20:
            if part.geometry().width() < render_view.geometry().width(
            ) or part.geometry().height() < render_view.geometry().height():
                render_view = part

    # Screenshot to Qt pixmap
    size = min(render_view.geometry().height(),
               render_view.geometry().width()) * 0.5
    left = render_view.width() * 0.5 - size * 0.5
    top = render_view.height() * 0.5 - size * 0.5
    crop = 0  # Pixels from the edges
    pixmap = QtGui.QPixmap.grabWindow(render_view.winId(), left + crop * 0.5,
                                      top + crop * 0.5, size - crop,
                                      size - crop)

    return pixmap.scaled(width, height, Qt.IgnoreAspectRatio,
                         Qt.TransformationMode.FastTransformation)
Ejemplo n.º 14
0
def run_script():
    global music_controller_dlg
    global music_controller_widget
    global dialog_event_callback
    global event_callback

    music_controller_widget = MusicController()

    #create RDialog
    music_controller_dlg = RLPy.RUi.CreateRDialog()
    music_controller_dlg.SetWindowTitle("Music Controller")

    # register dialog event
    dialog_event_callback = DialogEventCallback()
    dialog_register_id = music_controller_dlg.RegisterEventCallback(
        dialog_event_callback)

    #wrap RDialog to Pyside Dialog
    main_pyside_dlg = wrapInstance(int(music_controller_dlg.GetWindow()),
                                   QtWidgets.QDialog)
    main_pyside_layout = main_pyside_dlg.layout()

    main_pyside_layout.addWidget(music_controller_widget)
    main_pyside_dlg.setFixedWidth(300)

    event_callback = REventCallbackSampleCode()
    id = RLPy.REventHandler.RegisterCallback(event_callback)
    global event_list
    event_list.append(id)
    #RLPy.REventHandler.UnregisterCallback(id)
    #show dialog
    music_controller_dlg.Show()
Ejemplo n.º 15
0
def initialize_plugin():
    # Add menu
    plugin_menu = wrapInstance(
        int(RLPy.RUi.AddMenu("Python Samples", RLPy.EMenu_Plugins)),
        PySide2.QtWidgets.QMenu)
    plugin_action = plugin_menu.addAction("Batch Render")
    plugin_action.triggered.connect(show_dialog)
Ejemplo n.º 16
0
    def initUI(self):
        # -- Create Pyside layout for RDialog --#
        self.transfer_vroid_character_dialog = RLPy.RUi.CreateRDialog()
        self.transfer_vroid_character_dialog.SetWindowTitle(
            "Transfer Vroid Character")
        self.pyside_dialog = wrapInstance(
            int(self.transfer_vroid_character_dialog.GetWindow()),
            QtWidgets.QDialog)
        self.pyside_dialog.setFixedWidth(300)
        self.mocap_layout = self.pyside_dialog.layout()

        # -- Add UI Elements --#
        self.info = QtWidgets.QTextEdit()
        self.mocap_layout.addWidget(self.info)
        self.info.setPlainText("Default path to 3DXchange  " + Xchange_path)

        self.path_3DXchange_button = QtWidgets.QPushButton(
            "Set path to 3DXchange")
        self.path_3DXchange_button.clicked.connect(self.path_3dxchange)
        self.mocap_layout.addWidget(self.path_3DXchange_button)

        self.import_3DXchange_button = QtWidgets.QPushButton(
            "Import fbx to 3DXchange")
        self.import_3DXchange_button.clicked.connect(self.import_3dxchange)
        self.mocap_layout.addWidget(self.import_3DXchange_button)

        self.update_character_iClone_button = QtWidgets.QPushButton(
            "Select texture folder and update")
        self.update_character_iClone_button.clicked.connect(
            self.update_character_iClone)
        self.mocap_layout.addWidget(self.update_character_iClone_button)

        return
Ejemplo n.º 17
0
def wrapInstance(widget):
    if isinstance(widget, basestring):
        widget = hou.ui.findPaneTab(widget)
    if USE_PYQT_MODULE:
        return sip.wrapinstance(long(widget), QObject)
    else:
        return shiboken.wrapInstance(long(widget), QWidget)
Ejemplo n.º 18
0
def create_qml_embedded_dialog(title, obj_name, qml_file, qml_context_name,
                               qml_context_value):
    main_dlg = RLPy.RUi.CreateRDialog()
    main_dlg.SetWindowTitle(title)  #title

    # wrapInstance
    main_pyside_dlg = wrapInstance(int(main_dlg.GetWindow()),
                                   PySide2.QtWidgets.QDialog)
    main_pyside_dlg.setObjectName(obj_name)  #obj_name

    # embed QML
    resource_path = os.path.dirname(__file__)
    main_dlg_view = PySide2.QtQuickWidgets.QQuickWidget()
    main_dlg_view.setSource(QUrl.fromLocalFile(resource_path +
                                               qml_file))  #qml_file
    main_dlg_view.setResizeMode(
        PySide2.QtQuickWidgets.QQuickWidget.SizeRootObjectToView)
    main_qml = main_dlg_view.rootObject()

    # add widget to layout
    main_layout = main_pyside_dlg.layout()
    main_layout.addWidget(main_dlg_view)
    main_pyside_dlg.adjustSize()

    # inject Python data into QML
    root_context = main_dlg_view.rootContext()
    root_context.setContextProperty(qml_context_name,
                                    qml_context_value)  #qml_context_name

    return [main_dlg, main_pyside_dlg, main_qml]
Ejemplo n.º 19
0
def create_dialog():
    # initialize dialog
    main_widget = wrapInstance(int(RLPy.RUi.GetMainWindow()), PySide2.QtWidgets.QWidget)    
    dlg = PySide2.QtWidgets.QDialog(main_widget)    # set parent to main window
    
    ui_file = QFile(os.path.dirname(__file__) + "/BatchRender.ui")
    ui_file.open(QFile.ReadOnly)
    ui_widget = PySide2.QtUiTools.QUiLoader().load(ui_file) # load .ui file
    ui_file.close()
    ui_layout = PySide2.QtWidgets.QVBoxLayout()
    ui_layout.setContentsMargins( 0, 0, 0, 0 )
    ui_layout.addWidget(ui_widget)
    dlg.setLayout(ui_layout)
    dlg.setWindowTitle("Batch Render Folder")
    dlg.resize(ui_widget.size().width(), ui_widget.size().height())
    dlg.setMinimumSize(ui_widget.size())
    dlg.setMaximumSize(ui_widget.size())

    # connect button signals
    ui_sel_folder_btn = ui_widget.findChild(PySide2.QtWidgets.QPushButton, "qtFolderBtn")
    ui_sel_folder_btn.setIcon(QPixmap(os.path.dirname(os.path.abspath(__file__))+"\\icon\\Load.svg"))

    if ui_sel_folder_btn:
        ui_sel_folder_btn.clicked.connect(do_select_folder)
    ui_render_btn = ui_widget.findChild(PySide2.QtWidgets.QPushButton, "qtRenderButton")
    if ui_render_btn:
        ui_render_btn.clicked.connect(do_batch_render)
    return dlg;
Ejemplo n.º 20
0
def run_script():
    global rl_py_timer
    global timer_callback
    #init timer event
    rl_py_timer = RLPy.RPyTimer()
    rl_py_timer.SetInterval(100)
    timer_callback = RLPyTimerCallback()
    rl_py_timer.RegisterPyTimerCallback(timer_callback)
    timer_callback.register_time_out(update_skeleton)

    global jcm_manager_dlg
    jcm_manager_widget = JcmWidget()

    label = QtWidgets.QLabel()
    label.setText("The morph is defined by \nThe Script and Morph Creator.")

    #create RDialog
    jcm_manager_dlg = RLPy.RUi.CreateRDialog()
    jcm_manager_dlg.SetWindowTitle("Joint Driven Morph")
    #wrap RDialog to Pyside Dialog
    main_pyside_dlg = wrapInstance(int(jcm_manager_dlg.GetWindow()),
                                   QtWidgets.QDialog)
    main_pyside_layout = main_pyside_dlg.layout()

    main_pyside_layout.addWidget(label)
    main_pyside_layout.addWidget(jcm_manager_widget)
    main_pyside_dlg.setFixedWidth(200)
    #show dialog
    jcm_manager_dlg.Show()
Ejemplo n.º 21
0
def menu_example():
    global plugin_menu
    #CreateMenu
    plugin_menu = RLPy.RUi.AddMenu("EZLook", RLPy.EMenu_Plugins)
    EZLook_menu = wrapInstance(int(plugin_menu), PySide2.QtWidgets.QMenu)
    #CreateButton
    EZLook_action = EZLook_menu.addAction("EZLook")
    EZLook_action.triggered.connect(EZLook_button_click)
Ejemplo n.º 22
0
def initialize_plugin():
    global main_dlg
    global main_qml
    global main_pyside_dlg
    global res_path
    global tcp_server
    # Prepare main dialog
    main_dlg = RLPy.RUi.CreateRDialog()
    main_dlg.SetWindowTitle("Light Remote Control")

    # Create a Pyside2 Quickwidget and get root object from qml
    main_dlg_view = PySide2.QtQuickWidgets.QQuickWidget()
    main_dlg_view.setSource(QUrl.fromLocalFile(res_path + "Main.qml"))
    main_dlg_view.setResizeMode(
        PySide2.QtQuickWidgets.QQuickWidget.SizeRootObjectToView)
    main_qml = main_dlg_view.rootObject()

    # wrapInstance
    main_pyside_dlg = wrapInstance(int(main_dlg.GetWindow()),
                                   PySide2.QtWidgets.QDialog)
    main_pyside_dlg.setObjectName("Remote Light Plugin")

    # add widget to layout
    main_layout = main_pyside_dlg.layout()
    main_layout.addWidget(main_dlg_view)
    main_pyside_dlg.adjustSize()

    # prepare menu and connect action
    ic_dlg = wrapInstance(int(RLPy.RUi.GetMainWindow()),
                          PySide2.QtWidgets.QMainWindow)
    plugin_menu = ic_dlg.menuBar().findChild(PySide2.QtWidgets.QMenu,
                                             "pysample_menu")
    if (plugin_menu == None):
        plugin_menu = wrapInstance(
            int(RLPy.RUi.AddMenu("Python Samples", RLPy.EMenu_Plugins)),
            PySide2.QtWidgets.QMenu)
        plugin_menu.setObjectName("pysample_menu")

    plugin_action = plugin_menu.addAction("Light Remote Control")
    plugin_action.triggered.connect(show_main_dlg)

    main_qml.setIpAddress(socket.gethostbyname(socket.gethostname()))

    tcp_server = QTcpServer()
    tcp_server.listen(PySide2.QtNetwork.QHostAddress.Any, 7701)
    tcp_server.newConnection.connect(add_new_device)
Ejemplo n.º 23
0
def initialize_plugin():
    global open_ui_kit
    global camera_pyside_dlg
    global camera_transform
    
    # Add Menu to iClone
    plugin_menu = wrapInstance(int(RLPy.RUi.AddMenu("Camera Control", RLPy.EMenu_Plugins)), PySide2.QtWidgets.QMenu)
    plugin_action = plugin_menu.addAction("Open Camera Control")
    plugin_action.triggered.connect(show_dlg)
Ejemplo n.º 24
0
def show_window():
    global ui, events

    if "window" in ui:  # If the window already exists...
        if ui["window"].IsVisible():
            RLPy.RUi.ShowMessageBox(
                "Smooth Camera Follow - Operation Error",
                "The current Smooth Camera Follow session is still running.  You must first close the window to start another session.",
                RLPy.EMsgButton_Ok)
        else:
            ui["window"].Show()
        return

    # Create an iClone Dock Widget
    ui["window"] = RLPy.RUi.CreateRDockWidget()
    ui["window"].SetWindowTitle("Smooth Camera Follow")
    ui["window"].SetAllowedAreas(RLPy.EDockWidgetAreas_RightDockWidgetArea
                                 | RLPy.EDockWidgetAreas_LeftDockWidgetArea)

    # Load UI file
    ui_file = QtCore.QFile(
        os.path.dirname(__file__) + "/Smooth_Camera_Follow.ui")
    ui_file.open(QtCore.QFile.ReadOnly)
    ui["widget"] = QtUiTools.QUiLoader().load(ui_file)
    ui_file.close()

    # Assign the UI file to the Pyside dock widget and show it
    ui["dialog"] = wrapInstance(int(ui["window"].GetWindow()),
                                QtWidgets.QDockWidget)
    ui["dialog"].setWidget(ui["widget"])
    ui["widget"].progress.setHidden(True)

    # Add UI functionality
    ui["widget"].camera.currentIndexChanged.connect(update_ui)
    ui["widget"].prop.currentIndexChanged.connect(update_ui)
    ui["widget"].tautness.valueChanged.connect(
        lambda x: ui["widget"].tautness_slider.setValue(x * 1000))
    ui["widget"].tautness_slider.valueChanged.connect(
        lambda x: ui["widget"].tautness.setValue(x * 0.001))
    ui["widget"].delay.valueChanged.connect(calculate_total_keys)
    ui["widget"].start_frame.valueChanged.connect(calculate_total_keys)
    ui["widget"].end_frame.valueChanged.connect(calculate_total_keys)
    ui["widget"].reduction.valueChanged.connect(calculate_total_keys)
    ui["widget"].use_current_offset.clicked.connect(use_current_offset)
    ui["widget"].reset.clicked.connect(reset_ui)
    ui["widget"].follow.clicked.connect(setup)

    # Register events
    events["callback"] = EventCallback()
    events["callback_id"] = RLPy.REventHandler.RegisterCallback(
        events["callback"])
    events["dialog_callback"] = DialogCallback()
    ui["window"].RegisterEventCallback(events["dialog_callback"])

    # Show the UI
    ui["window"].Show()
    reset_ui()
Ejemplo n.º 25
0
def initialize_plugin():
    global execute_parent_path
    execute_parent_path = os.path.abspath(os.path.join(sys.executable, os.pardir))
    # Create Pyside interface with iClone main window
    ic_dlg = wrapInstance(int(RLPy.RUi.GetMainWindow()), QtWidgets.QMainWindow)

    # Check if the menu item exists
    plugin_menu = ic_dlg.menuBar().findChild(QtWidgets.QMenu, "pysample_menu")
    if plugin_menu is None:

        # Create Pyside layout for QMenu named "Python Samples" and attach it to the Plugins menu
        plugin_menu = wrapInstance(int(RLPy.RUi.AddMenu("Python Samples", RLPy.EMenu_Plugins)), QtWidgets.QMenu)
        plugin_menu.setObjectName("pysample_menu")  # Setting an object name for the menu is equivalent to giving it an ID

    # Add the "Popcorn Script Manager" menu item to Plugins > Python Samples
    menu_action = plugin_menu.addAction("PopcornFX Sequencer (Demo)")

    # Show the dialog window when the menu item is triggered
    menu_action.triggered.connect(show_window)
Ejemplo n.º 26
0
def show_window():
    global cdz_ui

    if "dialog_window" in cdz_ui:  # If the window already exists...
        if cdz_ui["dialog_window"].IsVisible():
            RLPy.RUi.ShowMessageBox(
                "Camera Dolly Zoom - Operation Error",
                "The current Camera Dolly Zoom session is still running.  You must first close the window to start another session.",
                RLPy.EMsgButton_Ok)
        else:
            cdz_ui["dialog_window"].Show()
        return

    cdz_ui["dialog_window"] = RLPy.RUi.CreateRDialog()
    cdz_ui["dialog_window"].SetWindowTitle("Camera Dolly Zoom")

    # Create Pyside layout for RDialog
    dialog = wrapInstance(int(cdz_ui["dialog_window"].GetWindow()),
                          QtWidgets.QDialog)
    dialog.setFixedWidth(350)

    # Read and set the QT ui file from the script location
    qt_ui_file = QtCore.QFile(
        os.path.dirname(__file__) + "/Camera_Dolly_Zoom.ui")
    qt_ui_file.open(QtCore.QFile.ReadOnly)
    cdz_ui["widget"] = QtUiTools.QUiLoader().load(qt_ui_file)
    qt_ui_file.close()
    dialog.layout().addWidget(cdz_ui["widget"])

    # Connect button commands
    cdz_ui["widget"].help.clicked.connect(show_help_dialog)
    cdz_ui["widget"].keyDollyZoom.clicked.connect(key_camera_distance)
    cdz_ui["widget"].clearDollyZoom.clicked.connect(undo_last_operation)
    cdz_ui["widget"].focalLength.valueChanged.connect(
        update_focal_length_slider)
    cdz_ui["widget"].focalLengthSlider.valueChanged.connect(
        update_focal_length)

    cdz_ui["dialog_window"].Show()

    # Register callbacks
    cdz_callbacks["dialog_events"] = DialogEventCallback()
    cdz_ui["dialog_window"].RegisterEventCallback(
        cdz_callbacks["dialog_events"])
    cdz_callbacks["timer"] = RLPy.RPyTimer()
    cdz_callbacks["timer"].SetInterval(
        17
    )  # Every frame of iClone is 16.66667 ms, which is an interval of 16 - 17
    cdz_callbacks["timer_callback"] = TimerCallback()
    cdz_callbacks["timer"].RegisterPyTimerCallback(
        cdz_callbacks["timer_callback"])
    cdz_callbacks["timer"].Start()

    update_ui()
Ejemplo n.º 27
0
def show_dialog():
    global ui, dialog_event_callback

    # Create the Dialog window
    ui["dialog"] = RLPy.RUi.CreateRDialog()
    ui["dialog"].SetWindowTitle("Audio Driven")

    # Register dialog events
    dialog_event_callback = DialogEventCallback()
    dialog_event_id = ui["dialog"].RegisterEventCallback(dialog_event_callback)

    # Create Pyside layout for RDialog
    dialog = wrapInstance(int(ui["dialog"].GetWindow()), QtWidgets.QDialog)
    dialog.setFixedWidth(300)

    ui["wave_file"] = Ext.FileControl("WAV File :", "WAVE (*.wav)",
                                      dialog.layout())
    ui["selection"] = Ext.SelectionControl("Current Selections :",
                                           parent=dialog.layout())
    ui["sync"] = Ext.Switch(
        "Syncronize Animations :",
        parent=dialog.layout())  # Sync the animations across clone groups
    ui["clones"] = Ext.SliderControl("Clones", (1, 20, 10),
                                     parent=dialog.layout())
    ui["spacing"] = Ext.SliderControl("Spacing", (-1000, 1000, 120),
                                      parent=dialog.layout())
    ui["alignment"] = Ext.DropdownControl("Alignment :", ["X", "Y", "Z"],
                                          parent=dialog.layout())
    ui["color"] = Ext.PalletControl("Transition Color :", (255, 0, 0),
                                    False,
                                    parent=dialog.layout())
    ui["ramp"] = Ext.SliderControl(
        "Ramp & Fade (secs)", (0.1, 3, 0.5), 2, True, parent=dialog.layout(
        ))  # Ramp up and down time for the animation in seconds
    ui["move"] = Ext.Vector3Control("Move", (1, 9999, 500),
                                    1, [False, False, False],
                                    parent=dialog.layout())
    ui["size"] = Ext.Vector3Control("Scale", (0, 999, 10),
                                    0.5, [False, False, True],
                                    parent=dialog.layout())
    ui["apply"] = Ext.Button("Apply", False, dialog.layout())
    ui["progress"] = Ext.ProgressBar("Progress", False, dialog.layout())

    ui["wave_file"].valueChanged.connect(audio_to_spectrogram)
    ui["selection"].valueChanged.connect(check_criteria)
    ui["apply"].clicked.connect(drive_by_audio)
    ui["sync"].setVisible(len(ui["selection"].value) > 1)

    ui["dialog"].Show()

    register_callbacks()
Ejemplo n.º 28
0
def set_dock(title="Prop Planter", width=300, height=400, layout=QtWidgets.QVBoxLayout):
    dock = RLPy.RUi.CreateRDockWidget()
    dock.SetWindowTitle(title)

    qt_dock = wrapInstance(int(dock.GetWindow()), QtWidgets.QDockWidget)
    main_widget = QtWidgets.QWidget()
    qt_dock.setWidget(main_widget)
    qt_dock.setFixedWidth(width)
    qt_dock.setMinimumHeight(height)

    main_layout = layout()
    main_widget.setLayout(main_layout)

    return dock, main_layout
Ejemplo n.º 29
0
def show_main_dlg():
    global hgp_dialog, hgp_actions
    global hand_rigger_callback, hand_rigger_callback_list

    if not hasattr(RLPy.RISkeletonComponent, "BreakClip"):
        RLPy.RUi.ShowMessageBox(
            "Hand Gestures Puppeteering",
            "In order for this script to work as intended, please upgrade to iClone 7.83.",
            RLPy.EMsgButton_Ok)

    if hgp_dialog is None:
        # create dialog
        hgp_dialog = {}
        hgp_dialog["qml module"] = HandRigQmlModule()
        dialog_globals = create_qml_embedded_dialog(
            'Hand Gestures Puppeteering', 'Hand Gestures Puppeteering',
            '/resource/qml/handrigger.qml', 'handRigger',
            hgp_dialog["qml module"])
        hgp_dialog["main dialog"] = dialog_globals[0]
        hgp_dialog["main pyside dialog"] = dialog_globals[1]
        hgp_dialog["main qml"] = dialog_globals[2]

        register_dialog_callback()
        register_hand_rigger_callback()

        hgp_actions["QT space"] = RLPy.RUi.AddHotKey("Space")
        hgp_actions["space"] = wrapInstance(int(hgp_actions["QT space"]),
                                            PySide2.QtWidgets.QAction)
        hgp_actions["space"].triggered.connect(space_function)

        hgp_actions["QT escape"] = RLPy.RUi.AddHotKey("Escape")
        hgp_actions["escape"] = wrapInstance(int(hgp_actions["QT escape"]),
                                             PySide2.QtWidgets.QAction)
        hgp_actions["escape"].triggered.connect(stop_mode)

    hgp_dialog["main dialog"].Show()
Ejemplo n.º 30
0
def create_window():
    global ui, all_avatars, avatar_events, student_avatar, data_refresh_needed, callback_registered

    ui["window"] = RLPy.RUi.CreateRDockWidget()
    ui["window"].SetWindowTitle("Replace N Render")
    ui["dock"] = wrapInstance(int(ui["window"].GetWindow()),
                              QtWidgets.QDockWidget)
    ui["main-widget"] = QtWidgets.QWidget()
    ui["dock"].setWidget(ui["main-widget"])

    ui["main-widget-layout"] = QtWidgets.QVBoxLayout()
    ui["main-widget"].setLayout(ui["main-widget-layout"])

    ui["avatar-label"] = QtWidgets.QLabel("Currently Selected Avatar:")
    ui["avatar-combo"] = QtWidgets.QComboBox()
    ui["main-widget-layout"].addWidget(ui["avatar-label"])
    ui["main-widget-layout"].addWidget(ui["avatar-combo"])
    ui["avatar-combo"].currentIndexChanged.connect(lambda: set_avatar_select())

    ui["scarf-label"] = QtWidgets.QLabel("Scarf Colour")
    ui["scarf-combo"] = QtWidgets.QComboBox()
    ui["main-widget-layout"].addWidget(ui["scarf-label"])
    ui["main-widget-layout"].addWidget(ui["scarf-combo"])
    ui["scarf-combo"].setDisabled(True)

    ui["spacer"] = QtWidgets.QSpacerItem(20, 20,
                                         QtWidgets.QSizePolicy.Expanding,
                                         QtWidgets.QSizePolicy.Minimum)
    ui["main-widget-layout"].addSpacerItem(ui["spacer"])

    ui["render-button"] = QtWidgets.QPushButton("Render")
    ui["main-widget-layout"].addWidget(ui["render-button"])
    ui["render-button"].clicked.connect(lambda: do_render())

    # Register dialog event callback
    avatar_events["dialog_callbacks"] = DialogEventCallback()
    ui["window"].RegisterEventCallback(avatar_events["dialog_callbacks"])

    # Grab all avatars in the scene
    if (data_refresh_needed):
        update_avatar_data()
        update_scarf_data()
        data_refresh_needed = False

    if (not callback_registered):
        register_callbacks()

    ui["window"].Show()
Ejemplo n.º 31
0
 def WidgetCreate(self, pWidgetParent):
            
     #
     # IN parameter pWidgetparent is the memory address of the parent Qt widget. 
     #   here we should PySide.shiboken.wrapInstance() function to convert it to PySide.QtWidget object.
     #   and use it the as the parent for native Qt widgets created via Python. 
     #   Similiar approach is available in the sip python module for PyQt 
     #
     # Only a single widget is allowed to be the *direct* child of the IN parent widget. 
     #
     self.mNativeQtWidget = ReferencingSample.MainForm(shiboken2.wrapInstance(pWidgetParent, QtWidgets.QWidget))
    
     #
     # return the memory address of the *single direct* child QWidget. 
     #
     return shiboken2.getCppPointer(self.mNativeQtWidget)[0]
Ejemplo n.º 32
0
def _qtObject( address, type ) :

	import Qt
	if "PyQt" in Qt.__binding__ :
		import sip
		return sip.wrapinstance( address, type )
	else :
		if Qt.__binding__ == "PySide2" :
			try :
				import PySide2.shiboken2 as shiboken
			except ImportError :
				import shiboken2 as shiboken
		else :
			try :
				import PySide.shiboken
			except ImportError :
				import shiboken

		return shiboken.wrapInstance( address, type )