def _new_project(self): if state.get('project_new_dialog'): result = popup(self, 'Create New Project', "Please input new project's name", 'Project Name') if result: state.cast('project', 'create_project', result) state.set('project_new_dialog', False)
def _on_take_screenshot(self): if state.get('playing'): state.set('playing', False) directory = str( QFileDialog.getExistingDirectory(self, "Select Directory")) if directory is not None and directory != '': popup(dialog=ScreenshotProgressDialog, dialog_args=(directory, ))
def __init__(self, parent): super().__init__(parent) self.setWindowTitle('Open Project') state.set('project_list_select', None) state.on_changed('project_list_dialog', self._update) state.on_changed('project_new_dialog', self._new_project) self._setup_ui()
def mousePressEvent(self, event): if event.button() == Qt.LeftButton: current_select = state.get('project_list_select') if current_select != self._project: state.set('project_list_select', self._project) elif event.button() == Qt.RightButton: pos = self.mapToGlobal(event.pos()) self._menu.exec_(pos)
def _on_show(self): body_mode = state.get('body_mode') if body_mode is BodyMode.PLAYBACK: state.cast( 'camera', 'cache_whole_shot', state.get('closeup_camera') ) elif body_mode is BodyMode.MODEL: state.cast('resolve', 'cache_whole_job') state.set('caching', True)
def _prepare(self): project = state.get('current_project') shot = state.get('current_shot') job = state.get('current_job') folder_name = f'{project.name}_{shot.name}_{job.name}' folder_name = re.sub(r'[^\w\d-]', '_', folder_name) path = Path(self._export_path) path = path.joinpath(folder_name) path.mkdir(exist_ok=True, parents=True) state.set('screenshot_export_path', str(path)) state.on_changed('tick_update_geo', self._play_next)
def _stop_function(self): if state.get('playing'): state.set('playing', False) if state.get('Crop'): state.set('Crop', False) state.set('crop_range', [None, None]) if state.get('Loop'): state.set('Loop', False) state.set('loop_range', [None, None])
def _on_key_pressed(self): if not self.isVisible(): return key = state.get('key') if key == Qt.Key_Up: self._change_closeup(-1) elif key == Qt.Key_Down: self._change_closeup(1) elif key == Qt.Key_Escape: closeup_camera = state.get('closeup_camera') if closeup_camera is not None: state.set('closeup_camera', None)
def _new_shot(self): if state.get('shot_new_dialog'): is_cali = state.get('is_cali') shot_type = 'cali' if is_cali else 'shot' result = popup(None, f'Create New {shot_type.title()}', f"Please input new {shot_type}'s name (optional)", f'{shot_type.title()} Name') if result is not False: project = state.get('current_project') project.create_shot(is_cali, result) state.set('shot_new_dialog', False)
def _update_geo(self): if state.get('caching'): return turntable = self._turntable_speed if state.get('playing') else 0 self._core.set_geo(state.get('opengl_data'), turntable) self._fps_counter.tick() # screenshot screenshot_path = state.get('screenshot_export_path') if screenshot_path is not None: self._take_screenshot(screenshot_path) state.set('tick_update_geo', None)
def __init__(self, name, vmin, vmax, _type, tick): super().__init__() self._name = name self._vmin = vmin self._vmax = vmax self._type = _type self._tick = tick self._length = self._get_interval_length() self._label = None self._slider = None state.set('parm_outside', True) self._setup_ui() state.on_changed(self._name, self._update) state.set('parm_outside', False)
def _change_closeup(self, step): closeup_camera = state.get('closeup_camera') if closeup_camera is None: return camera_ids = setting.get_working_camera_ids() idx = camera_ids.index(closeup_camera) idx += step if idx >= len(camera_ids): idx = 0 elif idx < 0: idx = len(camera_ids) - 1 state.set('closeup_camera', camera_ids[idx])
def resizeEvent(self, event): if self.width() * setting.camera_resolution[1] >\ self.height() * setting.camera_resolution[0]: width = self.height() / self._aspect_ratio width_margin = (self.width() - width) / 2 self._paint_rect = QRect(width_margin, 0, width, self.height()) else: height = self.width() * self._aspect_ratio height_margin = (self.height() - height) / 2 self._paint_rect = QRect(0, height_margin, self.width(), height) if (self._resize_leader and self.isVisible()): value = self._paint_rect.width() if value > 0: state.set('live_view_size', value)
def _on_click(self, source): if source == 'previous': step_pace(forward=False) elif source == 'play': if state.get('playing'): state.set('playing', False) self._player = None else: self._player = ShotPlayer( lambda: step_pace(stop=False) ) state.set('playing', True) elif source == 'next': step_pace(forward=True) elif source == 'clipleft': self._on_clip_range(0) elif source == 'clipright': self._on_clip_range(1)
def _on_clip_range(self, assign_idx): body_mode = state.get('body_mode') range_state = None if body_mode is BodyMode.PLAYBACK: range_state = 'crop_range' elif body_mode is BodyMode.MODEL: range_state = 'loop_range' clip_range = state.get(range_state) current_slider_value = state.get('current_slider_value') other_idx = abs(assign_idx - 1) other_frame = clip_range[other_idx] if other_idx == 1 and other_frame and current_slider_value > other_frame: return if other_idx == 0 and other_frame and current_slider_value < other_frame: return clip_range[assign_idx] = current_slider_value state.set(range_state, clip_range)
def _setup_ui(self): self.setStyleSheet('font-size: 18px;') new_button = ProjectListButton('add', 'New') new_button.clicked.connect( lambda: state.set('project_new_dialog', True)) self.addWidget(new_button) self.layout().addStretch() load_button = ProjectListButton('load', 'Load') load_button.clicked.connect(_load_project) load_button.setDisabled(True) self.addWidget(load_button)
def on_entity_changed(self, entity): if entity is None: return current_slider_value = state.get('current_slider_value') current_real_frame = get_real_frame(current_slider_value) if entity.has_prop('frame_range'): if entity.state < 1: return sf, ef = entity.frame_range frames = [f for f in range(sf, ef + 1)] state.set('offset_frame', sf) elif entity.has_prop('frames'): frames = entity.frames frames.sort() if current_real_frame in frames: current_slider_value = frames.index(current_real_frame) else: current_slider_value = 0 offset_frame = state.get('offset_frame') frames = [f - offset_frame for f in frames] state.set('frames', frames) max_slider_value = len(frames) - 1 self._slider.setMaximum(max_slider_value) state.set('current_slider_value', current_slider_value) self._labels[0].setText(str(frames[0])) self._labels[1].setText(str(frames[-1])) self.on_slider_value_changed(current_slider_value) self._slider.on_entity_changed(entity)
def _on_click(self): if self.isCheckable(): state.set(self._text, self.isChecked())
def _on_close(self): state.set('caching', False)
def _toggle_screen(self): state.set('second_screen', self.isChecked())
def _play_next(self): self.increase() state.set('current_slider_value', self._progress_bar.value())
def _on_close(self): state.set('screenshot_export_path', None)
def _on_show(self): state.set('current_slider_value', 0)
def _load_project(): state.cast('project', 'select_project', state.get('project_list_select')) state.set('project_list_dialog', False)
def _update_shot(self): state.set('pixmap_closeup', None)
def _new_dialog(self, is_cali=False): state.set('is_cali', is_cali) state.set('shot_new_dialog', True)
def _on_slider_changed(self, value): if state.get('current_slider_value') != value: state.set('current_slider_value', value)
def mousePressEvent(self, event): if event.button() == Qt.RightButton: if state.get('closeup_camera') is not None: state.set('closeup_camera', None)
def mousePressEvent(self, event): if (event.button() == Qt.LeftButton): self.leaveEvent(None) state.set('project_list_dialog', True)
def on_clicked(self): if self._mode is state.get('body_mode'): self.setChecked(True) else: state.set('body_mode', self._mode)