def importJsonSetting(self, path=None):
        """
        importJsonSetting 导入Json
        
        Keyword Arguments:
            path {str} -- 导入路径 为空则弹出选择窗口获取 (default: {None})
        """
        if not path:
            path, _ = QFileDialog.getOpenFileName(self,
                                                  caption=u"获取设置",
                                                  filter=u"json (*.json)")
            if not path: return

        # NOTE 如果文件不存在则返回空
        if not os.path.exists(path): return

        with open(path, 'r') as f:
            self.setting_data = json.load(f, encoding="utf-8")

        if self.setting_data["Horizontal_RB"]:
            self.Horizontal_RB.setChecked(1)
        else:
            self.Vertical_RB.setChecked(1)

        if self.setting_data["Maya_RB"]:
            self.Maya_RB.setChecked(1)
        else:
            self.Qt_RB.setChecked(1)

        self.Crop_CB.setChecked(self.setting_data["Crop_CB"])
        self.Limit_CB.setChecked(self.setting_data["Limit_CB"])
        self.Width_SP.setValue(self.setting_data["Width_SP"])
        self.Height_SP.setValue(self.setting_data["Height_SP"])
        self.Fit_SP.setValue(self.setting_data["Fit_SP"])
    def export_csv(self, path=None):
        if not path:
            path, _ = QFileDialog.getSaveFileName(
                self, caption=u"输出设置", filter=u"csv (*.csv)"
            )
            if not path:
                return

        csv = ""
        row_count = self.model.rowCount()
        column_count = self.model.columnCount()
        for i in range(row_count):
            col_list = [
                self.model.itemData(self.model.index(i, j))[0]
                for j in range(column_count)
            ]
            csv += ",".join(col_list) + "\n"

        with open(path, "w", encoding="gbk") as f:
            f.write(csv)

        # NOTE 打开输出的路径
        subprocess.Popen(
            ["start", "", os.path.dirname(path)], creationflags=0x08000000, shell=True
        )
    def exportJsonSetting(self, path=None):
        """
        exportJsonSetting 导出Json
        
        Keyword Arguments:
            path {str} -- 导出路径 为空则弹出选择窗口获取 (default: {None})
        """
        if not path:
            path, _ = QFileDialog.getSaveFileName(self,
                                                  caption=u"输出设置",
                                                  filter=u"json (*.json)")
            if not path: return

        self.setting_data["Horizontal_RB"] = self.Horizontal_RB.isChecked()
        self.setting_data["Maya_RB"] = self.Maya_RB.isChecked()
        self.setting_data["Crop_CB"] = self.Crop_CB.isChecked()
        self.setting_data["Limit_CB"] = self.Limit_CB.isChecked()
        self.setting_data["Width_SP"] = self.Width_SP.value()
        self.setting_data["Height_SP"] = self.Height_SP.value()
        self.setting_data["Fit_SP"] = self.Fit_SP.value()

        try:
            with open(path, 'w') as f:
                json.dump(self.setting_data, f, indent=4)
        except:
            QtWidgets.QMessageBox.warning(self, "Warning", "保存失败")
Esempio n. 4
0
    def getFile(self):
        path_list, _ = QFileDialog().getOpenFileNames(
            self,
            caption=u"获取Maya文件",
            filter="Maya Scene (*.ma *.mb);;所有文件 (*)")

        for path in path_list:
            self.addItem(path)
Esempio n. 5
0
 def export_setting(self):
     path, _ = QFileDialog.getSaveFileName(self,
                                           caption=u"输出设置",
                                           filter=u"ini (*.ini)")
     if not path:
         return
     copyfile(self.settings.fileName(), path)
     toast(u"导出成功", "info")
    def import_csv(self, path=None):
        if not path:
            path, _ = QFileDialog.getOpenFileName(
                self, caption=u"获取设置", filter=u"csv (*.csv)"
            )
        # NOTE 如果文件不存在则返回空
        if not path or not os.path.exists(path):
            return

        self.handle_csv(path)
        self.settings.setValue("csv_file", path)
Esempio n. 7
0
    def handleSetDirectory(self, directory=None):
        directory = directory if directory else QFileDialog.getExistingDirectory(
            self)
        if directory:
            self.timer.stop()
            directories = self.watcher.directories()
            if directories:
                self.watcher.removePaths(directories)

            self._changed = False
            self.watcher.addPath(directory)
            self.updateList()
            self.timer.start()
    def exportJsonSetting(self):
        """
        exportJsonSetting 导出 Json 设置
        """
        path, _ = QFileDialog.getSaveFileName(self,
                                              caption=u"输出摄像机设置",
                                              filter=u"json (*.json)")
        if not path: return

        try:
            with open(path, 'w') as f:
                json.dump(self.camera_setting, f, indent=4)
        except:
            QtWidgets.QMessageBox.warning(self, "Warning", "保存失败")
Esempio n. 9
0
    def import_setting(self):
        path, _ = QFileDialog.getOpenFileName(self,
                                              caption=u"获取设置",
                                              filter=u"ini (*.ini)")
        # NOTE 如果文件不存在则返回空
        if not path or not os.path.exists(path):
            return

        self.settings = QtCore.QSettings(path, QtCore.QSettings.IniFormat)
        self.settings.sync()
        self.load_settings()
        name = "%s.ini" % self.__class__.__name__
        self.settings = QtCore.QSettings(name, QtCore.QSettings.IniFormat)
        self.save_settings()
        toast(u"加载成功", "info")
Esempio n. 10
0
    def exportJsonSetting(self, path=None):
        """
        exportJsonSetting 导出Json
        
        Keyword Arguments:
            path {str} -- 导出路径 为空则弹出选择窗口获取 (default: {None})
        """
        if not path:
            path, _ = QFileDialog.getSaveFileName(self,
                                                  caption=u"输出设置",
                                                  filter=u"json (*.json)")
            if not path: return

        with open(path, 'w') as f:
            json.dump(self.setting, f, indent=4)
    def importJsonSetting(self):
        """
        importJsonSetting 导入 Json 设置
        """
        path, _ = QFileDialog.getOpenFileName(self,
                                              caption=u"获取摄像机设置",
                                              filter=u"json (*.json)")
        if not path: return

        # NOTE 如果文件不存在则返回空
        if not os.path.exists(path): return

        with open(path, 'r') as f:
            self.camera_setting = json.load(f,
                                            encoding="utf-8",
                                            object_pairs_hook=OrderedDict)

        # NOTE 更新面板内容
        self.showProcess()
Esempio n. 12
0
    def importJsonSetting(self, path=None):
        """
        importJsonSetting 导入Json
        
        Keyword Arguments:
            path {str} -- 导入路径 为空则弹出选择窗口获取 (default: {None})
        """
        if not path:
            path, _ = QFileDialog.getOpenFileName(self,
                                                  caption=u"获取设置",
                                                  filter=u"json (*.json)")
            if not path: return
        # NOTE 如果文件不存在则返回空
        if not os.path.exists(path): return

        with open(path, 'r') as f:
            self.setting = json.load(f,
                                     encoding="utf-8",
                                     object_pairs_hook=OrderedDict)

        # NOTE 更新面板内容
        self.refresh()
Esempio n. 13
0
    def capture(self):
        """
        capture 截取图片输出
        """
        file_path, _ = QFileDialog.getSaveFileName(
            self, caption=u"获取输出图片路径", filter=u"png (*.png);;jpg (*.jpg)")

        # NOTE 判断是否是空路径
        if not file_path:
            return

        # NOTE 获取当前激活的面板 (modelPanel4)
        for panel in pm.getPanel(type="modelPanel"):
            if pm.modelEditor(panel, q=1, av=1):
                active_cam = pm.modelEditor(panel, q=1, camera=1)
                active_panel = panel
                break

        # NOTE 获取当前 HUD 相关的显示状态
        display_1 = pm.modelEditor(active_panel, q=1, hud=1)
        display_2 = pm.modelEditor(active_panel, q=1, grid=1)
        display_3 = pm.modelEditor(active_panel, q=1, m=1)
        display_4 = pm.modelEditor(active_panel, q=1, hos=1)
        display_5 = pm.modelEditor(active_panel, q=1, sel=1)

        # NOTE 隐藏界面显示
        pm.modelEditor(active_panel, e=1, hud=0)
        pm.modelEditor(active_panel, e=1, grid=0)
        pm.modelEditor(active_panel, e=1, m=0)
        pm.modelEditor(active_panel, e=1, hos=0)
        pm.modelEditor(active_panel, e=1, sel=0)

        # NOTE 触发截屏处理
        self.cam_setting = self.manager.cam_setting
        self.setting = self.manager.setting
        # NOTE 根据设置窗口的选项 获取图片处理的API
        API = self.setting.Maya_RB.isChecked()
        if API:
            self.util = MayaImageUtil()
        else:
            self.util = QtImageUtil()

        # NOTE 创建临时摄像机组
        self.cam_setting.showProcess()

        # NOTE 获取摄像机截取的画面
        img_list = []
        for cam in self.cam_setting.camera_setting:
            pm.lookThru(cam)
            img = self.captureImage()
            if img: img_list.append(img)

        # Note 合并图片
        img = self.util.mergeImage(
            img_list, horizontal=self.setting.Horizontal_RB.isChecked())

        ext = os.path.splitext(file_path)[-1][1:]
        # Note 不同API的输出指令不一样进行区分
        if API:
            img.writeToFile(file_path, ext)
        else:
            img.save(file_path, format=ext)

        # NOTE 恢复HUD显示
        pm.modelEditor(active_panel, e=1, hud=display_1)
        pm.modelEditor(active_panel, e=1, grid=display_2)
        pm.modelEditor(active_panel, e=1, m=display_3)
        pm.modelEditor(active_panel, e=1, hos=display_4)
        pm.modelEditor(active_panel, e=1, sel=display_5)

        # NOTE 恢复之前的摄像机视角并删除临时的摄像机组
        pm.lookThru(active_cam)
        pm.delete(self.cam_setting.grp)

        # NOTE 输出成功信息
        QtWidgets.QMessageBox.information(self, u"输出完成",
                                          u"图片输出成功\n输出路径:%s" % file_path)