Esempio n. 1
0
 def apply(self):
     """
     This button launches a solve, but can also be used to cancel a solve.
     """
     running_state = lib_state.get_solver_is_running_state()
     if running_state is True:
         # Cancel out of a running solve if the user presses
         # the button again.
         lib_state.set_solver_user_interrupt_state(True)
         return
     undo_id = 'mmSolver: '
     undo_id += str(datetime.datetime.isoformat(datetime.datetime.now()))
     undo_id += ' '
     undo_id += str(uuid.uuid4())
     with undo_utils.undo_chunk_context(undo_id):
         block = self.blockSignals(True)
         try:
             mmapi.set_solver_running(True)
             options = lib_collection.gather_execute_options()
             log_level = lib_state.get_log_level()
             col = lib_state.get_active_collection()
             lib_collection.run_solve_ui(col, options, log_level, self)
         finally:
             mmapi.set_solver_running(False)
             self.blockSignals(block)
     return
Esempio n. 2
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))
    if override_current_frame is None:
        override_current_frame = False

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

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

    # Set 'override current frame' value.
    tab = lib_col_state.get_solver_tab_from_collection(col)
    prev_value = None
    if override_current_frame is True:
        prev_value = __get_override_current_frame_value(col, tab)
        __set_override_current_frame_value(col, layout, tab, override_current_frame)

    # Run Solver
    options = lib_col.gather_execute_options()
    lib_col.run_solve_ui(
        col,
        options,
        log_level,
        win,
    )

    # Restore previous value.
    if override_current_frame is True:
        __set_override_current_frame_value(col, layout, tab, prev_value)
    return
Esempio n. 3
0
 def apply(self):
     """
     This button launches a solve, but can also be used to cancel a solve.
     """
     running_state = lib_state.get_solver_is_running_state()
     if running_state is True:
         # Cancel out of a running solve if the user presses
         # the button again.
         lib_state.set_solver_user_interrupt_state(True)
         return
     undo_id = 'mmSolver: '
     undo_id += str(datetime.datetime.isoformat(datetime.datetime.now()))
     undo_id += ' '
     undo_id += str(uuid.uuid4())
     with tools_utils.tool_context(use_undo_chunk=True,
                                   undo_chunk_name=undo_id,
                                   restore_current_frame=False,
                                   pre_update_frame=False,
                                   post_update_frame=False,
                                   use_dg_evaluation_mode=True,
                                   disable_viewport=False):
         block = self.blockSignals(True)
         try:
             mmapi.set_solver_running(True)
             options = lib_collection.gather_execute_options()
             log_level = lib_state.get_log_level()
             col = lib_state.get_active_collection()
             lib_collection.run_solve_ui(col, options, log_level, self)
         finally:
             mmapi.set_solver_running(False)
             self.blockSignals(block)
     return
Esempio n. 4
0
 def apply(self):
     """
     Tbis button launches a solve, but can also be used to cancel a solve.
     """
     undo_id = 'mmSolver: ' + str(uuid.uuid4())
     with undo_utils.undo_chunk(undo_id):
         running_state = lib_state.get_solver_is_running_state()
         if running_state is True:
             lib_state.set_solver_user_interrupt_state(True)
             return
         refresh_state = lib_state.get_refresh_viewport_state()
         force_update_state = lib_state.get_force_dg_update_state()
         do_isolate_state = lib_state.get_isolate_object_while_solving_state(
         )
         image_plane_state = lib_state.get_display_image_plane_while_solving_state(
         )
         log_level = lib_state.get_log_level()
         col = lib_state.get_active_collection()
         lib_collection.run_solve_ui(col, refresh_state, force_update_state,
                                     do_isolate_state, image_plane_state,
                                     log_level, self)
     return
Esempio n. 5
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
Esempio n. 6
0
 def apply(self):
     refresh_state = lib_state.get_refresh_viewport_state()
     log_level = lib_state.get_log_level()
     col = lib_state.get_active_collection()
     lib_collection.run_solve_ui(col, refresh_state, log_level, self)
     return