Example #1
0
    def updateModel(self):
        is_running = mmapi.is_solver_running()
        if is_running is True:
            return
        col = lib_state.get_active_collection()
        if col is not None:
            tab_name = self.getSolverTabValue(col)
            tab_name = tab_name.lower()
            idx = self._tab_name_to_index_map.get(tab_name, None)
            if idx is None:
                msg = 'Solver tab name is not valid: %r' % tab_name
                raise ValueError(msg)
            self.tabWidget.setCurrentIndex(idx)

        idx = self.tabWidget.currentIndex()
        tab_widget = self._getTabWidget(idx)
        tab_widget.updateModel()

        widgets = [
            tab_widget,
            self.info_label,
        ]
        _populateWidgetsEnabled(widgets)
        self.updateInfo()
        return
    def updateInfo(self):
        is_running = mmapi.is_solver_running()
        if is_running is True:
            return
        cam_list = set()
        mkr_list = set()
        bnd_list = set()

        text = 'Camera {cam} | Markers {mkr} | Bundles {bnd}'

        col = lib_state.get_active_collection()
        if col is not None:
            marker_list = col.get_marker_list()
            for mkr in marker_list:
                mkr_node = mkr.get_node()
                mkr_list.add(mkr_node)

                cam = mkr.get_camera()
                cam_shp_node = cam.get_shape_node()
                cam_list.add(cam_shp_node)

                bnd = mkr.get_bundle()
                if bnd is not None:
                    bnd_node = bnd.get_node()
                    bnd_list.add(bnd_node)

        text = text.format(
            cam=len(cam_list),
            mkr=len(mkr_list),
            bnd=len(bnd_list),
        )
        self.ui.info_label.setText(text)
        return
    def updateInfo(self):
        s = time.time()
        is_running = mmapi.is_solver_running()
        if is_running is True:
            return

        anm_count = 0
        stc_count = 0
        lck_count = 0
        col = lib_state.get_active_collection()
        if col is not None:
            attr_list = col.get_attribute_list()
            attr_state_list = [attr.get_state() for attr in attr_list]
            anm_count = attr_state_list.count(mmapi.ATTR_STATE_ANIMATED)
            stc_count = attr_state_list.count(mmapi.ATTR_STATE_STATIC)
            lck_count = attr_state_list.count(mmapi.ATTR_STATE_LOCKED)

        text = (
            'Animated {anm} | Static {stc} | Locked {lck}'
        ).format(anm=anm_count, stc=stc_count, lck=lck_count)
        self.ui.info_label.setText(text)

        e = time.time()
        LOG.debug('updateInfo: %r', e - s)
        return
Example #4
0
 def updateColumnVisibility(self):
     is_running = mmapi.is_solver_running()
     if is_running is True:
         return
     show_state = lib_state.get_display_attribute_state_state()
     show_min_max = lib_state.get_display_attribute_min_max_state()
     self.displayStateColumnChanged(show_state)
     self.displayMinMaxColumnChanged(show_min_max)
     return
Example #5
0
    def updateInfo(self):
        is_running = mmapi.is_solver_running()
        if is_running is True:
            return

        value = lib_state.get_auto_update_solver_validation_state()
        self.validate_pushButton.setEnabled(not value)
        if value is not True:
            return

        self.runUpdateInfo()
        return
 def updateColumnVisibility(self):
     is_running = mmapi.is_solver_running()
     if is_running is True:
         return
     show_weight = lib_state.get_display_object_weight_state()
     show_frm_dev = lib_state.get_display_object_frame_deviation_state()
     show_avg_dev = lib_state.get_display_object_average_deviation_state()
     show_max_dev = lib_state.get_display_object_maximum_deviation_state()
     self.displayWeightColumnChanged(show_weight)
     self.displayFrameDeviationColumnChanged(show_frm_dev)
     self.displayAverageDeviationColumnChanged(show_avg_dev)
     self.displayMaximumDeviationColumnChanged(show_max_dev)
     return
 def updateToggleButtons(self):
     is_running = mmapi.is_solver_running()
     if is_running is True:
         return
     col = lib_state.get_active_collection()
     if col is None:
         return
     show_anm = lib_col.get_attribute_toggle_animated_from_collection(col)
     show_stc = lib_col.get_attribute_toggle_static_from_collection(col)
     show_lck = lib_col.get_attribute_toggle_locked_from_collection(col)
     self.toggleAnimated_toolButton.setChecked(show_anm)
     self.toggleStatic_toolButton.setChecked(show_stc)
     self.toggleLocked_toolButton.setChecked(show_lck)
     return
 def updateToggleButtons(self):
     is_running = mmapi.is_solver_running()
     if is_running is True:
         return
     col = lib_state.get_active_collection()
     if col is None:
         return
     show_cam = lib_col.get_object_toggle_camera_from_collection(col)
     show_mkr = lib_col.get_object_toggle_marker_from_collection(col)
     show_bnd = lib_col.get_object_toggle_bundle_from_collection(col)
     self.toggleCamera_toolButton.setChecked(show_cam)
     self.toggleMarker_toolButton.setChecked(show_mkr)
     self.toggleBundle_toolButton.setChecked(show_bnd)
     return
    def updateModel(self):
        is_running = mmapi.is_solver_running()
        if is_running is True:
            return
        self.populateModel(self.model)
        valid = uiutils.isValidQtObject(self.treeView)
        if valid is False:
            return
        self.treeView.expandAll()

        widgets = [self]
        _populateWidgetsEnabled(widgets)

        block = self.blockSignals(True)
        self.dataChanged.emit()
        self.blockSignals(block)
        return
def selection_changed_func(clientData):
    """The Maya selection has changed, we must synchronize the Maya
    selection with the Solver UI.

    :param clientData: The Qt window object class.
    :type clientData: SolverWindow

    :return: Nothing.
    :rtype: None
    """
    if mmapi.is_solver_running() is True:
        return
    sel_uuids = maya.cmds.ls(selection=True, uuid=True) or []
    valid = uiutils.isValidQtObject(clientData)
    if clientData is not None and valid is True:
        clientData.setNodeSelection(sel_uuids)
    return
    def updateInfo(self):
        is_running = mmapi.is_solver_running()
        if is_running is True:
            return
        anm_list = []
        stc_list = []
        lck_list = []

        text = 'Animated {anm} | Static {stc} | Locked {lck}'

        col = lib_state.get_active_collection()
        if col is not None:
            attr_list = col.get_attribute_list()
            anm_list = [True for attr in attr_list if attr.is_animated()]
            stc_list = [True for attr in attr_list if attr.is_static()]
            lck_list = [True for attr in attr_list if attr.is_locked()]

        text = text.format(anm=len(anm_list),
                           stc=len(stc_list),
                           lck=len(lck_list))
        self.ui.info_label.setText(text)
        return
    def updateModel(self):
        s = time.time()
        is_running = mmapi.is_solver_running()
        if is_running is True:
            return

        col = lib_state.get_active_collection()
        if col is None:
            return

        widgets = [self]
        nodebrowser_utils._populateWidgetsEnabled(col, widgets)
        self.populateModel(self.model, col)
        nodebrowser_utils._expand_node(self.treeView,
                                       self.treeView.model(),
                                       self.treeView.rootIndex(),
                                       expand=True,
                                       recurse=False)

        e = time.time()
        LOG.debug('updateModel: %r', e - s)
        return
def attribute_changed_func(callback_msg, plugA, plugB, clientData):
    """
    Callback triggered when an event happens to an attribute on a node.

    One callback handles many attributes and event types for one node.
    The callback is linked to the node, not the attribute.

    :param callback_msg: The type of callback message.
    :type callback_msg: OpenMaya.MNodeMessage.AttributeMessage

    :param plugA: First plug related to callback.
    :type plugA: OpenMaya.MPlug

    :param plugB: Second plug related to callback, may not be used if
                  not relevant to callback type.
    :type plugB: OpenMaya.MPlug

    :param clientData: Custom data given to the function. Expected to
                       be a tuple of length 2: (node_uuid, update_func)
    :type clientData: (str, function)

    :return: Nothing.
    :rtype: None
    """
    if mmapi.is_solver_running() is True:
        return
    node_uuid = clientData[0]
    update_func = clientData[1]
    if (callback_msg & OpenMaya.MNodeMessage.kConnectionMade
            or callback_msg & OpenMaya.MNodeMessage.kConnectionBroken
            or callback_msg & OpenMaya.MNodeMessage.kAttributeLocked
            or callback_msg & OpenMaya.MNodeMessage.kAttributeUnlocked
            or callback_msg & OpenMaya.MNodeMessage.kAttributeKeyable
            or callback_msg & OpenMaya.MNodeMessage.kAttributeUnkeyable
            or callback_msg & OpenMaya.MNodeMessage.kAttributeRemoved
            or callback_msg & OpenMaya.MNodeMessage.kAttributeRenamed):
        update_func()
    return
Example #14
0
def attribute_changed_func(callback_msg, plugA, plugB, clientData):
    """
    Callback triggered when an event happens to an attribute on a node.

    One callback handles many attributes and event types for one node.
    The callback is linked to the node, not the attribute.

    :param callback_msg: The type of callback message.
    :type callback_msg: OpenMaya.MNodeMessage.AttributeMessage

    :param plugA: First plug related to callback.
    :type plugA: OpenMaya.MPlug

    :param plugB: Second plug related to callback, may not be used if
                  not relevant to callback type.
    :type plugB: OpenMaya.MPlug

    :param clientData: node_uuid given to the function.
    :type clientData: str

    :return: Nothing.
    :rtype: None
    """
    if (callback_msg & OpenMaya.MNodeMessage.kConnectionMade
            or callback_msg & OpenMaya.MNodeMessage.kConnectionBroken
            or callback_msg & OpenMaya.MNodeMessage.kAttributeLocked
            or callback_msg & OpenMaya.MNodeMessage.kAttributeUnlocked
            or callback_msg & OpenMaya.MNodeMessage.kAttributeKeyable
            or callback_msg & OpenMaya.MNodeMessage.kAttributeUnkeyable
            or callback_msg & OpenMaya.MNodeMessage.kAttributeRemoved
            or callback_msg & OpenMaya.MNodeMessage.kAttributeRenamed):
        if mmapi.is_solver_running() is True:
            return
        node_uuid = clientData
        event_utils.trigger_event(mmapi.EVENT_NAME_ATTRIBUTE_STATE_CHANGED,
                                  node=node_uuid,
                                  plug=plugA)
    return
    def updateModel(self):
        is_running = mmapi.is_solver_running()
        if is_running is True:
            return

        col = lib_state.get_active_collection()
        if col is None:
            return

        self.populateModel(self.model, col)
        nodebrowser_utils._expand_node(
            self.treeView,
            self.treeView.model(),
            self.treeView.rootIndex(),
            expand=True,
            recurse=True)

        widgets = [self]
        nodebrowser_utils._populateWidgetsEnabled(col, widgets)

        block = self.blockSignals(True)
        self.viewUpdated.emit()
        self.blockSignals(block)
        return
Example #16
0
def get_solver_is_running_state():
    value = mmapi.is_solver_running()
    return value