예제 #1
0
    def check_parameters_files(self):
        source_file_color = open('./VTK_parameters/history', "r")
        files_para = source_file_color.readlines()

        if len(files_para) != 3:
            msgBox = qt.QMessageBox(self)
            msgBox.setText('Missing parameters files in the history')
            msgBox.exec_()
        else:
            matching = [s for s in files_para if ".col" in s]
            if len(str(matching)) != 2:
                self.color_file = str(matching[0]).rstrip('\n')
            else:
                self.color_file = 'empty'
                msgBox = qt.QMessageBox(self)
                msgBox.setText('Missing color file')
                msgBox.exec_()

            matching = [s for s in files_para if ".alp" in s]
            if len(str(matching)) != 2:
                self.alpha_file = str(matching[0]).rstrip('\n')
            else:
                self.alpha_file = 'empty'
                msgBox = qt.QMessageBox(self)
                msgBox.setText('Missing alpha file')
                msgBox.exec_()

            matching = [s for s in files_para if ".pr" in s]
            if len(str(matching)) != 2:
                self.para_file = str(matching[0]).rstrip('\n')
            else:
                self.para_file = 'empty'
                msgBox = qt.QMessageBox(self)
                msgBox.setText('Missing parameters file')
                msgBox.exec_()
예제 #2
0
    def _buttonParaSavePushed(self):
        source_file_color = open('./VTK_parameters/history', "r")
        files_para = source_file_color.readlines()
        matching = [s for s in files_para if ".pr" in s]

        if len(str(matching)) != 2:
            para_file = str(matching[0]).rstrip('\n')
            if para_file == 'para_rendering_default.pr':
                msgBox = qt.QMessageBox(self)
                msgBox.setText(
                    'Overwrite the default file is not allowed. Create a new file to save your table'
                )
                msgBox.exec_()
            else:

                paraFileToWrite = open('./VTK_parameters/' + para_file, "w")
                paraFileToWrite.writelines(
                    str(self.checkBox.checkState()) + ' ')
                paraFileToWrite.writelines(str(self.sliderAmb.value()) + ' ')
                paraFileToWrite.writelines(str(self.sliderDif.value()) + ' ')
                paraFileToWrite.writelines(str(self.sliderSpe.value()) + ' ')
                paraFileToWrite.writelines(str(self.sliderSpe.value()) + ' ')
                paraFileToWrite.writelines(str(self.sliderSpeP.value()) + ' ')
                paraFileToWrite.writelines(str(self.sliderOpa.value()))

        self.check_parameters_files()
예제 #3
0
    def _buttonAlphaSavePushed(self):
        source_file_color = open('./VTK_parameters/history', "r")
        files_para = source_file_color.readlines()
        matching = [s for s in files_para if ".alp" in s]

        if len(str(matching)) != 2:
            alpha_file = str(matching[0]).rstrip('\n')
            if alpha_file == 'alpha_rendering_default.alp':
                msgBox = qt.QMessageBox(self)
                msgBox.setText(
                    'Overwrite the default file is not allowed. Create a new file to save your table'
                )
                msgBox.exec_()
            else:

                alphaFileToWrite = open('./VTK_parameters/' + alpha_file, "w")

                for i in range(10):
                    for j in range(4):
                        try:
                            alphaFileToWrite.writelines(
                                self.AlphaCoef.item(i, j).text() + ' ')
                        except:
                            if j == 4:
                                alphaFileToWrite.writelines('0.5 ')
                            else:
                                alphaFileToWrite.writelines('0 ')
                    alphaFileToWrite.writelines('\n')

        self.check_parameters_files()
예제 #4
0
    def fill_para(self):

        if self.para_file != 'empty':
            try:
                source_file_para = open('./VTK_parameters/' + self.para_file,
                                        "r")

            except IOError:
                msgBox = qt.QMessageBox(self)
                msgBox.setText('The parameters fil : ' + self.para_file +
                               ' does not exist')
                msgBox.exec_()

            line = source_file_para.readlines()[0]
            parameters = line.split(' ')

            if int(parameters[0]) == 2:
                self.checkBox.setChecked(2)
            else:
                self.checkBox.setChecked(0)

            self.sliderAmb._defaultValue(float(parameters[1]))
            self.sliderDif._defaultValue(float(parameters[2]))
            self.sliderSpe._defaultValue(float(parameters[3]))
            self.sliderSpeP._defaultValue(float(parameters[4]))
            self.sliderOpa._defaultValue(float(parameters[5]))
        else:
            self.sliderAmb._defaultValue(1)
            self.sliderDif._defaultValue(1)
            self.sliderSpe._defaultValue(1)
            self.sliderSpeP._defaultValue(1)
            self.sliderOpa._defaultValue(1)
예제 #5
0
    def fill_alphaTable(self):
        if self.alpha_file != 'empty':
            try:
                source_file_alpha = open('./VTK_parameters/' + self.alpha_file,
                                         "r")
            except IOError:
                msgBox = qt.QMessageBox(self)
                msgBox.setText('The alpha file ' + self.alpha_file +
                               ' does not exist')
                msgBox.exec_()

            all_lines = source_file_alpha.readlines()
            j = 0
            for line in all_lines:

                line = line.rstrip('\n')
                line = line.split(' ')
                try:
                    line.remove('')
                except:
                    pass
                if len(line) == 2:
                    for i in range(2):
                        Item = qt.QTableWidgetItem()
                        Item.setText(str(line[i]))
                        self.AlphaCoef.setItem(j, i, Item)
                elif len(line) == 4:
                    for i in range(4):
                        Item = qt.QTableWidgetItem()

                        Item.setText(str(line[i]))
                        self.AlphaCoef.setItem(j, i, Item)
                j += 1
예제 #6
0
    def closeDir(self, safeClose=True):
        """
        :param bool safeClose: Prompts user to confirm closing of working directory. Default: True

        Removes the working directory currently selected in the drop down menu.
        """
        #
        # Prompt warning
        #
        if safeClose:
            msg = qt.QMessageBox()
            msg.setIcon(qt.QMessageBox.Warning)
            msg.setWindowTitle('Close directory')
            msg.setText(
                'Are you shure you want to close the current working directory?'
            )
            msg.setStandardButtons(qt.QMessageBox.Ok | qt.QMessageBox.Cancel)
            if msg.exec_() == qt.QMessageBox.Cancel:
                if DEBUG >= 1:
                    print('FileSystemBrowser.closeDir -- Abort')
                return

        #
        # Inteact with QDirListModel
        #
        currentIdx = self.workingDirCB.currentIndex()
        model = self.workingDirCB.model()

        if model.rowCount() > 0:
            model.removeDirs(row=currentIdx, count=1)
        if model.rowCount() <= 0:
            self.closeDirButton.setEnabled(False)
            self.workingDirCB.setCurrentIndex(-1)
        else:
            self.workingDirCB.setCurrentIndex(0)

        #
        # Reset the DirTree to the users home directory
        #
        homeDir = qt.QDir.home()
        self.fsView.setRootDirectory(homeDir)