예제 #1
0
    def _on_slider_value_changed(self):
        if self._entity is None or not self.isEnabled():
            return

        slider_value = state.get('current_slider_value')
        real_frame = get_real_frame(slider_value)

        body_mode = state.get('body_mode')
        if body_mode is BodyMode.PLAYBACK:
            closeup_camera = state.get('closeup_camera')
            state.cast(
                'camera', 'request_shot_image', self._entity.get_id(),
                real_frame, closeup_camera=closeup_camera, delay=True
            )
        elif body_mode is BodyMode.MODEL:
            job = state.get('current_job')
            if job is None:
                return

            state.cast(
                'resolve', 'request_geometry',
                self._entity, real_frame
            )

        self._playback_bar.on_slider_value_changed(slider_value)
예제 #2
0
 def _on_save(self):
     directory = str(
         QFileDialog.getExistingDirectory(self, "Select Directory"))
     if directory is not None and directory != '':
         state.cast(
             'camera', 'request_save_image',
             state.get('current_slider_value') + state.get('offset_frame'),
             directory)
예제 #3
0
 def _update_clip_visible(self):
     body_mode = state.get('body_mode')
     if body_mode is BodyMode.PLAYBACK:
         crop = state.get('Crop')
         self.setVisible(crop)
     elif body_mode is BodyMode.MODEL:
         loop = state.get('Loop')
         self.setVisible(loop)
예제 #4
0
    def _get_rig_geo(self):
        job = state.get('current_job')
        body_mode = state.get('body_mode')
        if job is None or body_mode is not BodyMode.MODEL:
            return

        state.cast(
            'resolve', 'request_geometry', job, None
        )
예제 #5
0
 def _prepare(self):
     body_mode = state.get('body_mode')
     if body_mode is BodyMode.PLAYBACK:
         for camera_id in setting.get_working_camera_ids():
             state.on_changed(f'pixmap_{camera_id}', self.increase)
         if state.get('closeup_camera'):
             state.on_changed('pixmap_closeup', self.increase)
     elif body_mode is BodyMode.MODEL:
         state.on_changed('opengl_data', self.increase)
예제 #6
0
 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)
예제 #7
0
 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)
예제 #8
0
    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])
예제 #9
0
 def _prepare(self):
     body_mode = state.get('body_mode')
     if body_mode is BodyMode.PLAYBACK:
         self._threashold = len(setting.get_working_camera_ids())
         for camera_id in setting.get_working_camera_ids():
             state.on_changed(f'pixmap_{camera_id}', self._loaded)
         if state.get('closeup_camera'):
             state.on_changed('pixmap_closeup', self._loaded)
             self._threashold += 1
     elif body_mode is BodyMode.MODEL:
         state.on_changed('tick_update_geo', self._notify)
예제 #10
0
 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)
예제 #11
0
 def _on_show(self):
     offset_frame = state.get('offset_frame')
     frames = state.get('frames')
     state.cast(
         'resolve',
         'export_model',
         state.get('current_project'),
         state.get('current_shot'),
         state.get('current_job'),
         [f + offset_frame for f in frames],
         self._export_path
     )
예제 #12
0
    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)
예제 #13
0
 def _update_shot_list(self):
     current_shot = state.get('current_shot')
     body_mode = state.get('body_mode')
     if (body_mode is BodyMode.MODEL and current_shot == self._shot
             and len(self._shot.jobs) > 0):
         if self._job_list is None:
             self._job_list = JobList(self._shot._jobs)
             self.addWidget(self._job_list)
     else:
         if self._job_list is not None:
             self._job_list.deleteLater()
             self._job_list = None
             state.cast('project', 'select_job', None)
예제 #14
0
    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)
예제 #15
0
    def _update(self):
        if state.get('caching'):
            return

        status = state.get('status')
        for key, value in status.items():
            if key not in self._widgets:
                continue

            if isinstance(value, float):
                text = f'{value:.2f}'
            else:
                text = str(value)
            self._widgets[key].set_text(text)
예제 #16
0
    def _update(self):
        value = state.get(self._name)
        if self._type == 'int':
            text = str(int(value))
        elif value == 0:
            text = '0'
        else:
            text = f'{value:.02f}'.rstrip('0.')

        self._label.setText(text)

        if state.get('parm_outside'):
            v = (value - self._vmin) / (self._vmax - self._vmin) * self._length
            self._slider.setValue(int(v))
예제 #17
0
    def _get_total_progress(self):
        shot = state.get('current_shot')
        body_mode = state.get('body_mode')
        if body_mode is BodyMode.PLAYBACK:
            count = len(setting.get_working_camera_ids())

            if state.get('closeup_camera'):
                count += 1

            return (
                shot.frame_range[1] - shot.frame_range[0] + 1
            ) * count
        elif body_mode is BodyMode.MODEL:
            return len(state.get('frames'))
예제 #18
0
    def _update_progress(self):
        if state.get('caching') or not self.isVisible():
            return

        progress = self._entity.get_cache_progress()

        if isinstance(progress, tuple):
            offset_tasks = {}
            offset_frame = state.get('offset_frame')
            for k, v in progress[1].items():
                offset_tasks[k - offset_frame] = v
            self._tasks = offset_tasks

        self._paint_progress()
        self._update()
예제 #19
0
    def _on_key_pressed(self):
        if self.parentWidget() is None:
            return

        key = state.get('key')
        if key == Qt.Key_Space:
            self._on_click('play')
예제 #20
0
    def _update(self):
        projects = state.get('projects')
        new_project_ids = []

        added_item = None
        for order, project in enumerate(projects):
            project_id = project.get_id()
            if project_id not in self._project_widgets:
                item = QListWidgetItem()
                widget = ProjectItem(item, project)
                self.insertItem(order, item)
                self.setItemWidget(item, widget)
                self._project_widgets[project_id] = widget

                if added_item is None:
                    added_item = item

            new_project_ids.append(project_id)

        deleted_widgets = [
            widget for widget in self._project_widgets.values()
            if widget.get_project_id() not in new_project_ids
        ]

        for widget in deleted_widgets:
            project_id = widget.get_project_id()
            index = self.indexFromItem(widget.get_item())
            self.takeItem(index.row())
            del self._project_widgets[project_id]

        if added_item:
            self.scrollToItem(added_item)
예제 #21
0
 def _set_pixmap(self):
     if self.isVisible():
         pixmap = state.get('pixmap_closeup')
         if pixmap is None:
             return
         self.setPixmap(
             pixmap.scaled(self.width(), self.height(), Qt.KeepAspectRatio))
예제 #22
0
    def get_result(self):
        frames = []
        offset_frame = state.get('offset_frame')

        for s1 in self._text_frames.text().strip().split():
            for s2 in s1.split(','):
                if s2 == '' or s2 is None:
                    continue
                if '-' in s2:
                    sf, ef = s2.split('-')
                    frames += [i for i in range(int(sf), int(ef) + 1)]
                else:
                    frames.append(int(s2))

        frames.sort()
        frames = set(frames)
        frames = [f + offset_frame for f in frames]

        parms = {'cali': self._comboBox.currentData()}
        for parm_widget in self._parms:
            name, value = parm_widget.get_result()
            parms[name] = value

        return {
            'name': self._text_name.text(),
            'frames': frames,
            'parms': parms
        }
예제 #23
0
    def _update(self):
        check_result = state.get('deadline_status')
        self.setText(self._submit_text if check_result else self._connect_text)
        self._is_server_on = check_result

        if check_result:
            self._submit()
예제 #24
0
 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)
예제 #25
0
 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, ))
예제 #26
0
 def mousePressEvent(self, event):
     if event.button() == Qt.LeftButton:
         current_select = state.get('current_shot')
         if current_select != self._shot:
             state.cast('project', 'select_shot', self._shot)
     elif event.button() == Qt.RightButton:
         pos = self.mapToGlobal(event.pos())
         self._menu.exec_(pos)
예제 #27
0
    def _update(self):
        body_mode = state.get('body_mode')

        if body_mode is BodyMode.LIVEVIEW:
            self._layout.setCurrentIndex(0)
        elif body_mode is BodyMode.PLAYBACK:
            self._layout.setCurrentIndex(1)
        elif body_mode is BodyMode.MODEL:
            self._layout.setCurrentIndex(2)
예제 #28
0
    def _update(self):
        current_select = state.get('project_list_select')
        if current_select == self._project:
            self._wrapper.setStyleSheet(self._wrapper_default +
                                        self._wrapper_selected)
        else:
            self._wrapper.setStyleSheet(self._wrapper_default)

        self._title_label.setText(self._project.name)
예제 #29
0
    def _update(self):
        cali_list = state.get('cali_list')
        self.clear()

        for label, job_id in cali_list:
            self.addItem(label, job_id)

        if len(cali_list) == 0:
            self.addItem('None', None)
예제 #30
0
    def _on_entity_changed(self):
        self._stop_function()

        body_mode = state.get('body_mode')
        if body_mode is BodyMode.LIVEVIEW:
            self._entity = None
            return
        else:
            job = state.get('current_job')
            if job is not None:
                self._entity = job
            else:
                shot = state.get('current_shot')
                self._entity = shot

        self._playback_bar.on_entity_changed(self._entity)
        if self._entity is not None and self._entity.state != 0:
            self._on_slider_value_changed()