Пример #1
0
 def _on_browser_open(self):
     if self._imagecontainer is None:
         QMessageBox.warning(self, 'Data structure not loaded',
                             'The input directory structure file was not loaded.\n'
                             'Click "Scan input directory" in section "General" to proceed.')
     elif self._browser is None:
         try:
             browser = Browser(self._settings, self._imagecontainer, None)
             browser.show()
             browser.raise_()
             browser.setFocus()
             app = AppPreferences()
             browser.setStyleSheet(loadStyle(app.stylesheet))
             self._browser = browser
         except Exception as e:
             traceback.print_exc()
             QMessageBox.critical(self, "Error", str(e))
     else:
         self._browser.show()
         self._browser.raise_()
Пример #2
0
 def _on_browser_open(self):
     if self._imagecontainer is None:
         QMessageBox.warning(
             self, 'Data structure not loaded',
             'The input directory structure file was not loaded.\n'
             'Click "Scan input directory" in section "General" to proceed.'
         )
     elif self._browser is None:
         try:
             browser = Browser(self._settings, self._imagecontainer, None)
             browser.show()
             browser.raise_()
             browser.setFocus()
             app = AppPreferences()
             browser.setStyleSheet(loadStyle(app.stylesheet))
             self._browser = browser
         except Exception as e:
             traceback.print_exc()
             QMessageBox.critical(self, "Error", str(e))
     else:
         self._browser.show()
         self._browser.raise_()
Пример #3
0
    def __init__(self, appname, version, redirect, settings=None,
                 debug=False, *args, **kw):
        super(CecogAnalyzer, self).__init__(*args, **kw)
        self.setWindowTitle("%s-%s" %(appname, version) + '[*]')
        self.setAcceptDrops(True)
        self.setCentralWidget(QtWidgets.QFrame(self))
        self.setObjectName(appname)

        self.version = version
        self.appname = appname
        self.debug = debug

        self.environ = CecogEnvironment(version=version, redirect=redirect,
                                        debug=debug)

        if debug:
            self.environ.pprint()

        self._is_initialized = False
        self._imagecontainer = None
        self._meta_data = None
        self._browser = None

        action_quit = self.create_action('&Quit', slot=self.close)
        action_pref = self.create_action('&Preferences',
                                         slot=self.open_preferences)

        action_load = self.create_action('&Load Settings...',
                                         shortcut=QtGui.QKeySequence.Open,
                                         slot=self._on_file_open)
        action_save = self.create_action('&Save Settings',
                                         shortcut=QtGui.QKeySequence.Save,
                                         slot=self._on_file_save)
        self.action_save = action_save
        action_save_as = self.create_action('&Save Settings As...',
                                            shortcut=QtGui.QKeySequence.SaveAs,
                                            slot=self._on_file_save_as)

        menu_file = self.menuBar().addMenu('&File')
        self.add_actions(menu_file, (action_pref,
                                     None, action_load,
                                     None, action_save, action_save_as,
                                     None, action_quit))

        action_log = self.create_action('&Log window',
                                        shortcut=QtGui.QKeySequence(Qt.CTRL+Qt.Key_L),
                                        slot=self._on_show_log_window)

        action_open = self.create_action('&Browser',
                                         shortcut=QtGui.QKeySequence('CTRL+B'),
                                         slot=self._on_browser_open)

        menu_view = self.menuBar().addMenu('&View')
        self.add_actions(menu_view, (action_log,))
        self.add_actions(menu_view, (action_open,))

        action_assistant = self.create_action('&Help',
                                              shortcut=QtGui.QKeySequence.HelpContents,
                                              slot=self.show_assistant)
        action_about = self.create_action('&About', slot=self.on_about)
        action_aboutQt = self.create_action('&About Qt', slot=self.about_qt)


        menu_help = self.menuBar().addMenu('&Help')
        self.add_actions(menu_help, (action_assistant, action_about,
                                     action_aboutQt))

        self.setStatusBar(QtWidgets.QStatusBar(self))

        self._selection = QtWidgets.QListWidget(self.centralWidget())
        self._selection.setViewMode(QtWidgets.QListView.IconMode)
        self._selection.setIconSize(QtCore.QSize(35, 35))
        self._selection.setGridSize(QtCore.QSize(140, 60))
        self._selection.setMovement(QtWidgets.QListView.Static)
        self._selection.setMaximumWidth(self._selection.gridSize().width() + 5)
        self._selection.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self._selection.setSizePolicy(
            QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                  QtWidgets.QSizePolicy.Expanding))

        self._pages = FrameStack(self)

        self._settings_filename = None
        self._settings = GuiConfigSettings(self)

        self._tab_lookup = OrderedDict()
        self._tabs = [GeneralFrame(self._settings, self._pages, SECTION_NAME_GENERAL),
                      ObjectDetectionFrame(self._settings, self._pages, SECTION_NAME_OBJECTDETECTION),
                      FeatureExtractionFrame(self._settings, self._pages, SECTION_NAME_FEATURE_EXTRACTION),
                      ClassificationFrame(self._settings, self._pages, SECTION_NAME_CLASSIFICATION),
                      TrackingFrame(self._settings, self._pages, SECTION_NAME_TRACKING),
                      EventSelectionFrame(self._settings, self._pages, SECTION_NAME_EVENT_SELECTION),
                      ErrorCorrectionFrame(self._settings, self._pages, SECTION_NAME_ERRORCORRECTION),
                      OutputFrame(self._settings, self._pages, SECTION_NAME_OUTPUT),
                      ProcessingFrame(self._settings, self._pages, SECTION_NAME_PROCESSING)]

        # connections for the section frames
        self._tabs[3].connect_browser_btn(self._on_browser_open)
        for frame in self._tabs:
            frame.status_message.connect(self.statusBar().showMessage)

        app = AppPreferences()
        if app.cluster_support:
            clusterframe = ClusterFrame(self._settings, self._pages, SECTION_NAME_CLUSTER)
            clusterframe.set_imagecontainer(self._imagecontainer)
            self._tabs.append(clusterframe)

        try:
            self.updateStyleSheet(loadStyle(app.stylesheet))
        except Exception as e:
            # proceed with no stylesheet
            traceback.print_exc()


        widths = []
        for tab in self._tabs:
            size = self._add_page(tab)
            widths.append(size.width())
        self.set_modules_active(state=False)
        self._pages.setMinimumWidth(max(widths) + 45)

        self._selection.currentItemChanged.connect(self._on_change_page)
        self._selection.setCurrentRow(0)

        w_logo = QtWidgets.QLabel(self.centralWidget())
        w_logo.setPixmap(QtGui.QPixmap(':cecog_logo_w145'))

        layout = QtWidgets.QGridLayout(self.centralWidget())
        layout.addWidget(self._selection, 0, 0)
        layout.addWidget(w_logo, 1, 0, Qt.AlignBottom | Qt.AlignHCenter)
        layout.addWidget(self._pages, 0, 1, 2, 1)
        layout.setContentsMargins(1, 1, 1, 1)

        self.setGeometry(0, 0, 1250, 800)
        self.setMinimumSize(QtCore.QSize(700, 600))
        self._is_initialized = True

        self._restore_geometry()
        self.show()

        # finally load (demo) - settings
        if settings is None:
            self.load_settings(self.environ.demo_settings)
        elif os.path.isfile(settings):
            self.load_settings(settings)
        else:
            QMessageBox.warning(
                self, "Warning", "File (%s) does not exist" %settings)
Пример #4
0
    def __init__(self,
                 appname,
                 version,
                 redirect,
                 settings=None,
                 debug=False,
                 *args,
                 **kw):
        super(CecogAnalyzer, self).__init__(*args, **kw)
        self.setWindowTitle("%s-%s" % (appname, version) + '[*]')
        self.setAcceptDrops(True)
        self.setCentralWidget(QtWidgets.QFrame(self))
        self.setObjectName(appname)

        self.version = version
        self.appname = appname
        self.debug = debug

        self.environ = CecogEnvironment(version=version,
                                        redirect=redirect,
                                        debug=debug)

        if debug:
            self.environ.pprint()

        self._is_initialized = False
        self._imagecontainer = None
        self._meta_data = None
        self._browser = None

        action_quit = self.create_action('&Quit', slot=self.close)
        action_pref = self.create_action('&Preferences',
                                         slot=self.open_preferences)

        action_load = self.create_action('&Load Settings...',
                                         shortcut=QtGui.QKeySequence.Open,
                                         slot=self._on_file_open)
        action_save = self.create_action('&Save Settings',
                                         shortcut=QtGui.QKeySequence.Save,
                                         slot=self._on_file_save)
        self.action_save = action_save
        action_save_as = self.create_action('&Save Settings As...',
                                            shortcut=QtGui.QKeySequence.SaveAs,
                                            slot=self._on_file_save_as)

        menu_file = self.menuBar().addMenu('&File')
        self.add_actions(menu_file,
                         (action_pref, None, action_load, None, action_save,
                          action_save_as, None, action_quit))

        action_log = self.create_action('&Log window',
                                        shortcut=QtGui.QKeySequence(Qt.CTRL +
                                                                    Qt.Key_L),
                                        slot=self._on_show_log_window)

        action_open = self.create_action('&Browser',
                                         shortcut=QtGui.QKeySequence('CTRL+B'),
                                         slot=self._on_browser_open)

        menu_view = self.menuBar().addMenu('&View')
        self.add_actions(menu_view, (action_log, ))
        self.add_actions(menu_view, (action_open, ))

        action_assistant = self.create_action(
            '&Help',
            shortcut=QtGui.QKeySequence.HelpContents,
            slot=self.show_assistant)
        action_about = self.create_action('&About', slot=self.on_about)
        action_aboutQt = self.create_action('&About Qt', slot=self.about_qt)

        menu_help = self.menuBar().addMenu('&Help')
        self.add_actions(menu_help,
                         (action_assistant, action_about, action_aboutQt))

        self.setStatusBar(QtWidgets.QStatusBar(self))

        self._selection = QtWidgets.QListWidget(self.centralWidget())
        self._selection.setViewMode(QtWidgets.QListView.IconMode)
        self._selection.setIconSize(QtCore.QSize(35, 35))
        self._selection.setGridSize(QtCore.QSize(140, 60))
        self._selection.setMovement(QtWidgets.QListView.Static)
        self._selection.setMaximumWidth(self._selection.gridSize().width() + 5)
        self._selection.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self._selection.setSizePolicy(
            QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                  QtWidgets.QSizePolicy.Expanding))

        self._pages = FrameStack(self)

        self._settings_filename = None
        self._settings = GuiConfigSettings(self)

        self._tab_lookup = OrderedDict()
        self._tabs = [
            GeneralFrame(self._settings, self._pages, SECTION_NAME_GENERAL),
            ObjectDetectionFrame(self._settings, self._pages,
                                 SECTION_NAME_OBJECTDETECTION),
            FeatureExtractionFrame(self._settings, self._pages,
                                   SECTION_NAME_FEATURE_EXTRACTION),
            ClassificationFrame(self._settings, self._pages,
                                SECTION_NAME_CLASSIFICATION),
            TrackingFrame(self._settings, self._pages, SECTION_NAME_TRACKING),
            EventSelectionFrame(self._settings, self._pages,
                                SECTION_NAME_EVENT_SELECTION),
            ErrorCorrectionFrame(self._settings, self._pages,
                                 SECTION_NAME_ERRORCORRECTION),
            OutputFrame(self._settings, self._pages, SECTION_NAME_OUTPUT),
            ProcessingFrame(self._settings, self._pages,
                            SECTION_NAME_PROCESSING)
        ]

        # connections for the section frames
        self._tabs[3].connect_browser_btn(self._on_browser_open)
        for frame in self._tabs:
            frame.status_message.connect(self.statusBar().showMessage)

        app = AppPreferences()
        if app.cluster_support:
            clusterframe = ClusterFrame(self._settings, self._pages,
                                        SECTION_NAME_CLUSTER)
            clusterframe.set_imagecontainer(self._imagecontainer)
            self._tabs.append(clusterframe)

        try:
            self.updateStyleSheet(loadStyle(app.stylesheet))
        except Exception as e:
            # proceed with no stylesheet
            traceback.print_exc()

        widths = []
        for tab in self._tabs:
            size = self._add_page(tab)
            widths.append(size.width())
        self.set_modules_active(state=False)
        self._pages.setMinimumWidth(max(widths) + 45)

        self._selection.currentItemChanged.connect(self._on_change_page)
        self._selection.setCurrentRow(0)

        w_logo = QtWidgets.QLabel(self.centralWidget())
        w_logo.setPixmap(QtGui.QPixmap(':cecog_logo_w145'))

        layout = QtWidgets.QGridLayout(self.centralWidget())
        layout.addWidget(self._selection, 0, 0)
        layout.addWidget(w_logo, 1, 0, Qt.AlignBottom | Qt.AlignHCenter)
        layout.addWidget(self._pages, 0, 1, 2, 1)
        layout.setContentsMargins(1, 1, 1, 1)

        self.setGeometry(0, 0, 1250, 800)
        self.setMinimumSize(QtCore.QSize(700, 600))
        self._is_initialized = True

        self._restore_geometry()
        self.show()

        # finally load (demo) - settings
        if settings is None:
            self.load_settings(self.environ.demo_settings)
        elif os.path.isfile(settings):
            self.load_settings(settings)
        else:
            QMessageBox.warning(self, "Warning",
                                "File (%s) does not exist" % settings)
Пример #5
0
 def setGlobalStylesheet(self, stylesheet):
     stylesheet = css.loadStyle(stylesheet)
     self.parent().updateStyleSheet(stylesheet)
Пример #6
0
 def setGlobalStylesheet(self, stylesheet):
     stylesheet = css.loadStyle(stylesheet)
     self.parent().updateStyleSheet(stylesheet)