Example #1
0
 def overrideCurrentFrameChanged(self, value):
     col = lib_state.get_active_collection()
     if col is None:
         LOG.warning('No active collection, cannot override Solver Step.')
         return
     # 'value' from Qt is expected to be an int, we expect a bool.
     value = bool(value)
     lib_col.set_override_current_frame_on_collection(col, value)
     self.updateSolverModel()
     self.updateSolveValidState()
     self.setStatusLine(const.STATUS_READY)
     return
Example #2
0
    def setOverrideCurrentFrame(self, col, value):
        """
        Set the override status for the collection given.

        Updates the relevant UI components with the new data.

        :param col: The Collection to set.
        :type col: Collection

        :param value: Should we override the current frame? Yes or No.
        :type value: bool
        """
        assert isinstance(value, bool)
        lib_col.set_override_current_frame_on_collection(col, value)
        self.updateSolverModel()
        self.updateSolveValidState()
        return
Example #3
0
def __set_override_current_frame_value(col, layout_ui, tab, value):
    if layout_ui is None:
        if tab in [const.SOLVER_TAB_BASIC_VALUE,
                   const.SOLVER_TAB_STANDARD_VALUE]:
            if value is True:
                value = const.RANGE_TYPE_CURRENT_FRAME_VALUE
            lib_col_state.set_solver_range_type_on_collection(col, value)
        elif tab == const.SOLVER_TAB_LEGACY_VALUE:
            lib_col.set_override_current_frame_on_collection(col, value)
        else:
            raise ValueError('tab is not supported; tab=%r' % tab)
    else:
        if tab == const.SOLVER_TAB_BASIC_VALUE:
            pass
        elif tab == const.SOLVER_TAB_STANDARD_VALUE:
            pass
        elif tab == const.SOLVER_TAB_LEGACY_VALUE:
            layout_ui.solver_settings.legacy_widget.setOverrideCurrentFrame(col, value)
        else:
            raise ValueError('tab is not supported; tab=%r' % tab)
    return
Example #4
0
def run_solve(override_current_frame=None):
    """
    Run the solver for the active collection.

    If the Solver UI is found, the window will update and show
    progress messages.

    This function is strongly dependant on the Solver UI.
    The following state information is set via the Solver UI.

    - Active Collection
    - Log Level
    - Refresh Viewport

    :param override_current_frame: Before running the solver, change
                                   the "override current frame" state to
                                   this value.
    :type override_current_frame: bool
    """
    assert (override_current_frame is None
            or isinstance(override_current_frame, bool))

    col = lib_state.get_active_collection()
    if col is None:
        msg = 'No active Collection found. Skipping solve.'
        LOG.warning(msg)
        return
    refresh_state = lib_state.get_refresh_viewport_state()
    log_level = lib_state.get_log_level()

    layout = None
    win = solver_window.SolverWindow.get_instance()
    if win is None:
        msg = 'Could not get window.'
        LOG.warning(msg)
    else:
        layout = win.getSubForm()

    # Set value.
    prev_value = None
    if override_current_frame is not None:
        prev_value = lib_col.get_override_current_frame_from_collection(col)
        if layout is None:
            lib_col.set_override_current_frame_on_collection(
                col,
                override_current_frame
            )
        else:
            # The function should operate on the currently active
            # collection, so we don't need to pass a collection.
            layout.setOverrideCurrentFrame(col, override_current_frame)

    # Run Solver
    lib_col.run_solve_ui(
        col,
        refresh_state,
        log_level,
        win,
    )

    # Restore previous value.
    if override_current_frame is not None:
        if layout is None:
            lib_col.set_override_current_frame_on_collection(
                col,
                prev_value
            )
        else:
            layout.setOverrideCurrentFrame(col, prev_value)
    return