Esempio n. 1
0
    def onAddModel_RectPrism(self):
        item = self.treeWidget.currentItem()
        if not item:
            return
        proj = item.belongToProj
        if not proj:
            return
        model = Model(self.modelType_RectPrism)
        # print(model.m_geometry_center_x)#OK
        newItem = QTreeWidgetItem(item, self.ItemType_Model_RectPrism)  #type
        newItem.setText(0, '长方体')
        newItem.setIcon(0, QIcon(":/ForwardCenter/cube"))

        newItem.belongToProj = proj
        newItem.belongToModel = model

        # print(proj.m_models.__len__())#OK

        self.treeWidget.setCurrentItem(newItem)
        add = self.onRectPrismModelSetting()  #弹出长方体模型设置dialog
        if not add:
            currentItem = self.treeWidget.currentItem()
            parentItem = currentItem.parent()
            parentItem.removeChild(currentItem)
        else:
            proj.addModel(model)
Esempio n. 2
0
    def onAddModel_Sphere(self):
        item = self.treeWidget.currentItem()
        if not item:
            return
        proj = item.belongToProj
        if not proj:
            return

        model = Model(self.modelType_Sphere)
        #print(model.m_geometry_center_x)#OK

        #设置item
        newItem = QTreeWidgetItem(item, self.ItemType_Model_Sphere)  #type
        newItem.setText(0, '球体')
        newItem.setIcon(0, QIcon(":/ForwardCenter/sphere"))

        #设置item所属项目和模型
        newItem.belongToProj = proj
        newItem.belongToModel = model

        # print(proj.m_models.__len__())#ok

        self.treeWidget.setCurrentItem(newItem)
        add = self.onSphereModelSetting()  #弹出球体模型设置dialog
        if not add:
            currentItem = self.treeWidget.currentItem()
            parentItem = currentItem.parent()
            parentItem.removeChild(currentItem)
        else:
            proj.addModel(model)  #底层模型数据添加
Esempio n. 3
0
    def onImportModel(self):
        item = self.treeWidget.currentItem()
        if not item:
            return
        parentItem = item.parent()
        if not parentItem:
            return
        proj = parentItem.belongToProj
        if not proj:
            return
        filename = QFileDialog.getOpenFileName(
            self, '导入模型', '', "Model Files(*.txt);;All Files(*.*)",
            'Model Files(*.txt)')
        if filename[0] != '':
            with open(filename[0], 'r') as f:
                if int(f.readline()) == proj.m_projectType:
                    modelCount = int(f.readline())
                    for i in np.arange(modelCount):
                        modelType = int(f.readline())
                        if modelType == self.modelType_Sphere:  #球体
                            model = Model(self.modelType_Sphere)

                            # 设置item
                            newItem = QTreeWidgetItem(
                                item, self.ItemType_Model_Sphere)  # type
                            newItem.setText(0, '球体')
                            newItem.setIcon(0, QIcon(":/ForwardCenter/sphere"))

                            # 设置item所属项目和模型
                            newItem.belongToProj = proj
                            newItem.belongToModel = model

                            model.m_geometry_center_x = int(f.readline())
                            model.m_geometry_center_y = int(f.readline())
                            model.m_geometry_center_z = int(f.readline())
                            model.m_geometry_radius = int(f.readline())
                            if proj.m_projectType == 1:  # 重力模型
                                model.density = float(f.readline())
                            elif proj.m_projectType == 0:  #磁法模型
                                model.K = float(f.readline())

                            proj.addModel(model)  # 底层模型数据添加
                        elif modelType == self.modelType_RectPrism:  #长方体
                            model = Model(self.modelType_RectPrism)

                            newItem = QTreeWidgetItem(
                                item, self.ItemType_Model_RectPrism)  # type
                            newItem.setText(0, '长方体')
                            newItem.setIcon(0, QIcon(":/ForwardCenter/cube"))

                            newItem.belongToProj = proj
                            newItem.belongToModel = model

                            model.m_geometry_center_x = int(f.readline())
                            model.m_geometry_center_y = int(f.readline())
                            model.m_geometry_center_z = int(f.readline())
                            model.m_geometry_xLen = int(f.readline())
                            model.m_geometry_yLen = int(f.readline())
                            model.m_geometry_zLen = int(f.readline())
                            if proj.m_projectType == 1:  # 重力模型
                                model.density = float(f.readline())
                            elif proj.m_projectType == 0:  # 磁法模型
                                model.K = float(f.readline())
                            proj.addModel(model)
                else:
                    QMessageBox.information(self, '提示', '该文件不符合对应的正演项目!')
                    return