Ejemplo n.º 1
0
    def loadDirectoryWrapper(self):
        """Loads whole directory based on Parse class as simple as BHP"""
        if self._LOADED_FLAG_:
            self.deleteLoadedFiles()

        self._LOADED_FLAG_ = False
        directory = self.promptDirectory()
        if directory is None or directory == "" or directory == "  ":
            msg = "Invalid directory: {}. Do you wish to abort?".format(
                directory)
            PopUpWrapper("Invalid directory",
                         msg,
                         None,
                         QtWidgets.QMessageBox.Yes,
                         QtWidgets.QMessageBox.No,
                         self.refreshScreen,
                         self.loadDirectoryWrapper,
                         parent=self)
            return 0
        else:
            try:
                self.p = ThreadingWrapper(
                    completeAction=None,
                    exceptionAction=self.raise_thread_exception,
                    parent=self)
                self.p.collapse_threads(self.loadDirectory, directory)
                self.disablePanes()

            except ValueError as e:
                msg = "Invalid directory: {}. \
                    Error Message {}\nDo you wish to reselect?".format(
                    directory, str(e))
                x = PopUpWrapper("Invalid directory",
                                 msg,
                                 None,
                                 QtWidgets.QMessageBox.Yes,
                                 QtWidgets.QMessageBox.No,
                                 self.loadDirectoryWrapper,
                                 quit,
                                 parent=self)
                to_return = None
            except Exception as e:
                print(e)
                to_return = None
            else:
                self._BLOCK_ITERABLES_ = False
                self._LOADED_FLAG_ = True
                self._BLOCK_STRUCTURES_ = False
                to_return = 1
            return to_return
Ejemplo n.º 2
0
 def setScreenshotFolder(self):
     selected_dir = self.promptDirectory()
     if selected_dir is not None:
         self.screenshot_dir = selected_dir
         x = PopUpWrapper(
             title='Screenshot directory changed',
             msg='Current screenshot directory: {}'.format(self.screenshot_dir),
             more='Changed',
             yesMes=None)
     else:
         x = PopUpWrapper(
             title='Screenshot directory has not changed',
             msg='Current screenshot directory: {}'.format(self.screenshot_dir),
             more='Not changed',
             yesMes=None)
Ejemplo n.º 3
0
    def deleteWidget(self, number, null_delete=False, verbose=True):
        if self.playerWindow:
            if verbose:
                PopUpWrapper("Alert",
                    "You may loose calculation!", \
                    "If you proceed animation will be restarted and widget \
                    will be deleted!"                                     , \
                    QtWidgets.QMessageBox.Yes, \
                    QtWidgets.QMessageBox.No, \
                    None, \
                    self.refreshScreen(), parent=self)

            self.playerWindow.forceWorkerReset()
            self.playerWindow.closeMe()
            self.playerWindow.worker.clearWidgetIterators()
        """
        null delete explanation:
        for some unknown reason if clearBox() is called on the pane
        that has no widget that causes a major bug
        Therefore if cancel was pressed and no widget was created - hence
        null_delete, then do not call
        """
        if not null_delete:
            self.panes[number].clearBox()
            self.panes[number].removeWidget(self.panes[number].widget)
        self.panes[number].setUpDefaultBox()
        self.panes[number].button.clicked.connect(\
            lambda: self.showChooseWidgetSettings(number))
        self.refreshScreen()
Ejemplo n.º 4
0
    def showChooseWidgetSettings(self, number):
        if self.playerWindow != None:
            # animation is running and this is may be not first window
            if self.playerWindow.worker.running:
                PopUpWrapper("Alert",
                             "You may loose calculation!" +
                             " If you proceed animation will be restarted!", \
                             None,
                             QtWidgets.QMessageBox.Yes, \
                             QtWidgets.QMessageBox.No, \
                             None, \
                             self.refreshScreen())

                self.playerWindow.forceWorkerReset()
                self.playerWindow.closeMe()
        """Spawns Window for choosing widget for this pane"""
        if not self._LOADED_FLAG_:
            # spawn directory picker again
            self.loadDirectoryWrapper()
        else:
            self.new = ChooseWidget(number, \
                                    blockStructures = self._BLOCK_STRUCTURES_, \
                                    blockIterables = self._BLOCK_ITERABLES_,
                                    blockPlotIterables = self._BLOCK_PLOT_ITERABLES_,
                                    parent = self)
            self.new.setHandler(self.choosingWidgetReceiver)
Ejemplo n.º 5
0
    def loadFile(self):
        if self._LOADED_FLAG_:
            self.deleteLoadedFiles()
        self._LOADED_FLAG_ = False

        fileLoaded = self.promptFile()

        if fileLoaded is None or fileLoaded == "" or fileLoaded == "  ":
            msg = "Invalid directory: {}. Do you wish to abort?".format(
                fileLoaded)
            PopUpWrapper("Invalid directory", msg, None,
                         QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No,
                         self.refreshScreen, self.loadFile)
            return 0

        if ".odt" in fileLoaded:
            self.doh.passListObject(('plot_data', 'iterations'),
                                    *MultiprocessingParse.readFile(fileLoaded))
            self._BLOCK_ITERABLES_ = False
            self._BLOCK_PLOT_ITERABLES_ = False

        elif ".omf" in fileLoaded or ".ovf" in fileLoaded:
            self.doh.passListObject(('color_vectors', 'file_header'),
                                    *MultiprocessingParse.readFile(fileLoaded))
            self._BLOCK_STRUCTURES_ = False
        else:
            raise ValueError("main.py/loadFile: File format is not supported!")

        self._LOADED_FLAG_ = True
        return 1
 def accept(self):
     self.hide()
     try:
         self.options = self.optionsVerifier()
         self.eventHandler(self.options)
         self.close()
     except ValueError as ve:
         PopUpWrapper("Invalid vector format", str(ve), None,
                      QMessageBox.Yes, QMessageBox.No, None, quit)
Ejemplo n.º 7
0
 def thread_exception(self, exceptionE):
     if self.exceptionAction:
         self.exceptionAction()
     x = PopUpWrapper("Error",
                      msg="Error {}\n{}".format(exceptionE[0],
                                                exceptionE[1]),
                      more="Error window")
     self.movie.stop()
     self.movie_screen.close()
Ejemplo n.º 8
0
 def composeMovie(self):
     x = PopUpWrapper(
         title='Pick directory',
         msg='Pick directory where screenshots are located.' +
             'Current screenshot directory: {}'.format(self.screenshot_dir),
         more='Changed',
         yesMes=None)
     self.setScreenshotFolder()
     mv = Movie(self.screenshot_dir)
     mv.create_video()
 def accept(self):
     self.hide()
     try:
         self.options = self.optionsVerifier()
         if self.options is not None:
             self.eventHandler(self.options)
         self.close()
     except ValueError as ve:
         x = PopUpWrapper(
             title='Invalid format',
             msg='Vectors must be in format [x,y,z] {}'.format(ve),
             more='',
             yesMes=None, parent=self)
         self.show()
Ejemplo n.º 10
0
 def composeMovie(self):
     self.setScreenshotFolder()
     if self.screenshot_dir not in [None, "", " "]:
         mv = Movie(self.screenshot_dir)
         try:
             mv.create_video()
         except EnvironmentError:
             x = PopUpWrapper(
                 title='Movie Composer',
                 msg='Pick directory where screenshots are located.' +
                 'Proper files not found in current screenshot directory: {}'
                 .format(self.screenshot_dir),
                 more='',
                 yesMes=None,
                 parent=self)
Ejemplo n.º 11
0
    def loadDirectory(self):
        """Loads whole directory based on Parse class as simple as BHP"""
        directory = self.promptDirectory()

        if directory is None or directory == "" or directory=="  ":
            msg = "Invalid directory: {}. Do you wish to abort?".format(directory)
            self._LOADED_FLAG_ = False
            PopUpWrapper("Invalid directory", msg, None, QtWidgets.QMessageBox.Yes,
                            QtWidgets.QMessageBox.No, self.refreshScreen,
                            self.loadDirectory)
            return 0
        else:
            try:
                sub = "Data is currently being loaded using all cpu power," + \
                        "app may stop responding for a while."
                x = PopUpWrapper("Loading", sub, "Please Wait...")
                rawVectorData, header, plot_data, stages, trigger_list = \
                                    MultiprocessingParse.readFolder(directory)
                self.doh.passListObject(('color_vectors', 'file_header',
                                        'iterations'),
                                        rawVectorData, header, stages)
                if plot_data is not None:
                    self.doh.setDataObject(plot_data, 'plot_data')
                    # successfully loaded plot_data into DOH
                    self._BLOCK_PLOT_ITERABLES_ = False
                else:
                    self._BLOCK_PLOT_ITERABLES_ = True
                if trigger_list is not None:
                    self.doh.setDataObject(trigger_list, 'trigger')

                x.close()
            except ValueError as e:
                print(e.print_stack())
                msg = "Invalid directory: {}. \
                    Error Message {}\nDo you wish to reselect?".format(directory,
                                                                        str(e))
                x = PopUpWrapper("Invalid directory", msg, None,
                                QtWidgets.QMessageBox.Yes,
                                QtWidgets.QMessageBox.No,
                                self.loadDirectory, quit)
            finally:
                self._BLOCK_ITERABLES_ = False
                self._LOADED_FLAG_ = True
                self._BLOCK_STRUCTURES_ = False
            return 1
Ejemplo n.º 12
0
    def deleteWidget(self, number):

        if self.playerWindow:
            PopUpWrapper("Alert",
                "You may loose calculation!", \
                "If you proceed animation will be restarted and widget \
                will be deleted!", \
                QtWidgets.QMessageBox.Yes, \
                QtWidgets.QMessageBox.No, \
                None, \
                self.refreshScreen())

            self.playerWindow.forceWorkerReset()
            self.playerWindow.closeMe()
            self.playerWindow.worker.clearWidgetIterators()

        self.panes[number].clearBox()
        self.panes[number].setUpDefaultBox()
        self.panes[number].button.clicked.connect(\
            lambda: self.showChooseWidgetSettings(number))