def populateOverrideCurrentFrame(self): cur_frame = False col = lib_state.get_active_collection() if col is not None: cur_frame = lib_col.get_override_current_frame_from_collection(col) self.overrideCurrentFrame_checkBox.setChecked(cur_frame) return
def strategy(self): """ The strategy of how to compute the frames A strategy order to solve the frames in. This strategy is only needed for static attribute computation. """ n = self.stepNode() if n is None: return const.STRATEGY_PER_FRAME_LABEL col = self.collectionNode() cur_frame = lib_collection.get_override_current_frame_from_collection( col) if cur_frame is True: return const.STRATEGY_PER_FRAME_LABEL v = n.get_strategy() assert v in const.STRATEGY_LIST idx = const.STRATEGY_LIST.index(v) # If we are not solving any static attributes, we show the # solver strategy as 'Per-Frame' use_static = n.get_use_static_attrs() value = const.STRATEGY_PER_FRAME_LABEL if use_static is True: value = const.STRATEGY_LABEL_LIST[idx] return value
def __get_override_current_frame_value(col, tab): value = None if tab in [const.SOLVER_TAB_BASIC_VALUE, const.SOLVER_TAB_STANDARD_VALUE]: value = lib_col_state.get_solver_range_type_from_collection(col) elif tab == const.SOLVER_TAB_LEGACY_VALUE: value = lib_col.get_override_current_frame_from_collection(col) else: raise ValueError('tab is not supported; tab=%r' % tab) return value
def frames(self): # if the option 'override current frame' is on, we ignore the actual # value. col = self.collectionNode() cur_frame = lib_collection.get_override_current_frame_from_collection( col) if cur_frame is True: return 'CURRENT' n = self.stepNode() int_list = n.get_frame_list() string = converttypes.intListToString(int_list) return string
def indexEnabled(self, index): """ Control if the given index is enabled or not. """ row_index = index.row() column_index = index.column() node = self._node_list[row_index] if node.enabled() is False: return False column_names = self.columnNames() column_name = self.getColumnNameFromIndex(index) enabled = False if column_name == const.SOLVER_COLUMN_NAME_ENABLED: return True else: stepEnabled = node.stepEnabled() stepEnabled = converttypes.stringToBoolean(stepEnabled) if stepEnabled is False: return False # The step is enabled! if column_name in [ const.SOLVER_COLUMN_NAME_FRAMES, const.SOLVER_COLUMN_NAME_ATTRIBUTES ]: enabled = True elif column_name == const.SOLVER_COLUMN_NAME_STRATEGY: # The 'strategy' column should be disabled if # 'attrs' is set to use either 'No Attributes' or # 'Animated Only'. attrs = node.attrs() if attrs in [ const.ATTR_FILTER_STATIC_ONLY_LABEL, const.ATTR_FILTER_STATIC_AND_ANIM_LABEL ]: enabled = True # When 'Override Current Frame' is on, frames and strategy # should be editable. if column_name in [ const.SOLVER_COLUMN_NAME_FRAMES, const.SOLVER_COLUMN_NAME_STRATEGY ]: col = node.collectionNode() cur_frame = lib_collection.get_override_current_frame_from_collection( col) if cur_frame is True: return False return enabled
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