def updateModel(self): """ Refresh the name_comboBox with the current Maya scene state. """ col = lib_state.get_active_collection() if col is None: return roots_enabled = True roots_string = self.getRootFramesValue(col) if roots_string is None: frame = lib_maya_utils.get_current_frame() start, end = utils_time.get_maya_timeline_range_inner() int_list = list(set([start, frame, end])) roots_string = convert_types.intListToString(int_list) self.setRootFramesValue(col, roots_string) else: int_list = convert_types.stringToIntList(roots_string) roots_string = convert_types.intListToString(int_list) assert roots_string is not None block = self.blockSignals(True) self.rootFrames_lineEdit.setEnabled(roots_enabled) self.rootFrames_lineEdit.setText(roots_string) self.blockSignals(block) return
def rootFramesTextEntered(self): """ Run when the rootFrames_lineEdit text is has been entered (for example the user presses the <Enter> key to confirm the field value). """ text = self.rootFrames_lineEdit.text() col = lib_state.get_active_collection() if col is None: return # Round-trip conversion will make sure there are no syntax # errors given by the user. int_list = convert_types.stringToIntList(text) frames_string = convert_types.intListToString(int_list) if len(int_list) < 2: msg = 'Must have at least 2 root frames to solve.' LOG.warn(msg) msg = 'WARNING: ' + msg self.sendWarning.emit(msg) else: msg = const.STATUS_READY self.sendWarning.emit(msg) # Save the integer list, but present the user with a string. self.rootFrames_lineEdit.setText(frames_string) self.setRootFramesValue(col, frames_string) self.rootFramesChanged.emit() return
def setFrames(self, value): int_list = converttypes.stringToIntList(value) n = self.stepNode() if n is None: return n.set_frame_list(int_list) self.setStepNode(n) return
def get_root_frames_list(col): """ Get the Root Frames string, from the currently active Collection. :rtype: [int, ..] or None """ if col is None: return None root_frames_str = lib_col_state.get_solver_root_frames_from_collection(col) if root_frames_str is None or len(root_frames_str) == 0: return None root_frames = convert_types.stringToIntList(root_frames_str) return root_frames
def nextClicked(self): col = lib_state.get_active_collection() if col is None: return frames_string = self.getRootFramesValue(col) if frames_string is None: LOG.warn('Root Frames are not valid') return cur_frame = lib_maya_utils.get_current_frame() int_list = convert_types.stringToIntList(frames_string) next_frame = navigaterootframes_lib.get_next_frame(cur_frame, int_list) if next_frame is None: next_frame = cur_frame lib_maya_utils.set_current_frame(next_frame) return
def _get_prev_frame(): """ Get the previous frame number from Root Frames. :rtype: int or None """ root_frames_str = _get_root_frames_string() if root_frames_str is None: return None int_list = convert_types.stringToIntList(root_frames_str) if len(int_list) == 0: return None cur_frame = maya.cmds.currentTime(query=True) frame = lib.get_prev_frame(cur_frame, int_list) return frame
def removeClicked(self): col = lib_state.get_active_collection() if col is None: return frame = lib_maya_utils.get_current_frame() frames_string = self.getRootFramesValue(col) if frames_string is None: int_list = [frame] frames_string = convert_types.intListToString(int_list) self.setRootFramesValue(col, frames_string) self.rootFrames_lineEdit.setText(frames_string) else: int_list = convert_types.stringToIntList(frames_string) if frame in int_list: int_list.remove(frame) frames_string = convert_types.intListToString(int_list) self.setRootFramesValue(col, frames_string) self.rootFrames_lineEdit.setText(frames_string) return
def framesTextEntered(self): """ Run when the frames_lineEdit text is has been entered (for example the user presses the <Enter> key to confirm the field value). """ text = self.frames_lineEdit.text() col = lib_state.get_active_collection() if col is None: return # Round-trip conversion will make sure there are no syntax # errors given by the user. int_list = converttypes.stringToIntList(text) frames_string = converttypes.intListToString(int_list) self.frames_lineEdit.setText(frames_string) self.setFramesValue(col, frames_string) self.framesChanged.emit() return