예제 #1
0
 def __createFilePreview__(self, parent, filename):
     composite = CompositeWidget(parent)
     layout = QVBoxLayout()
     composite.setLayout(layout)
     informationLabel = LabelWidget(composite)
     layout.addWidget(informationLabel)
     preview = PlainTextEditWidget(composite, readonly=True)
     layout.addWidget(preview)
     file_ = QFile(filename)
     if file_.open(QFile.ReadOnly):
         preview.insertPlainText(QString(file_.readAll()))
         preview.moveCursor(QTextCursor.Start)
         informationLabel.setText('Lines # ' +
                                  str(preview.document().lineCount()))
         file_.close()
     return composite
예제 #2
0
 def __createFilePreview__(self, parent, filename):
     composite = CompositeWidget(parent)
     layout = QVBoxLayout()
     composite.setLayout(layout)
     informationLabel = LabelWidget(composite)
     layout.addWidget(informationLabel)
     preview = PlainTextEditWidget(composite, readonly=True)
     layout.addWidget(preview)
     file_ = QFile(filename)
     if file_.open(QFile.ReadOnly):
         preview.insertPlainText(QString(file_.readAll()))
         preview.moveCursor(QTextCursor.Start)
         informationLabel.setText('Lines # '
                                  + str(preview.document().lineCount()))
         file_.close()
     return composite
class TachogramPlotSummaryCompositeWidget(MainWindowWidget):
    """
    initial tachogram plot window used to take operations
    on the whole group of tachogram plots
    """

    def __init__(self, parent, **params):
        super(TachogramPlotSummaryCompositeWidget, self).__init__(parent, **params)
        set_temporary_settings_id(self)
        self.params = Params(**params)

        self.addToolBar(OperationalToolBarWidget(self, excluded_buttons=[CloseToolButton]))
        self.addToolBar(PoincareToolBarWidget(self, reload_button=True))

        self.__central_widget__ = CompositeWidget(self, not_add_widget_to_parent_layout=True)
        layout = QVBoxLayout()
        self.__central_widget__.setLayout(layout)
        self.setCentralWidget(self.__central_widget__)
        self.__file_specifications__ = []
        self.__selected_files_specifications_handler__ = None
        SignalDispatcher.addSignalSubscriber(self, CLOSE_TACHOGRAM_PLOT_SIGNAL, self.__removeFileSpecification__)

    def toolbar_maximum_handler(self):
        SignalDispatcher.broadcastSignal(MAXIMIZE_TACHOGRAM_PLOT_SIGNAL)

    def toolbar_restore_handler(self):
        SignalDispatcher.broadcastSignal(RESTORE_TACHOGRAM_PLOT_SIGNAL)

    def toolbar_close_handler(self):
        SignalDispatcher.broadcastSignal(CLOSE_TACHOGRAM_PLOT_SIGNAL, self)

    def addFileSpecification(self, _file_specification):
        if self.__file_specifications__.count(_file_specification) == 0:
            self.__file_specifications__.append(_file_specification)

    def reload_poincare_settings_handler(self):
        """
        handler call by PoincareToolBarWidget toolbar
        reloads poincare plot settings widget
        """
        if hasattr(self, "__poincare_settings__"):
            self.removeDockWidget(self.__poincare_settings__)
            self.layout().removeWidget(self.__poincare_settings__)
            self.__poincare_settings__.deleteLater()
            delattr(self, "__poincare_settings__")

        if hasattr(self, "__poincare_datasources_table__"):
            self.layout().removeWidget(self.__poincare_datasources_table__)
            self.__poincare_datasources_table__.deleteLater()
            delattr(self, "__poincare_datasources_table__")

        self.show_poincare_settings_handler()

    def show_poincare_settings_handler(self):
        """
        handler call by PoincareToolBarWidget toolbar
        """

        if self.__selected_files_specifications_handler__:
            selected_files_specifications = self.__selected_files_specifications_handler__()
            if len(selected_files_specifications) > 0:
                for file_specification in selected_files_specifications:
                    self.addFileSpecification(file_specification)

        if len(self.__file_specifications__) == 0:
            InformationWindow(message="No data sources selected !")
            return
        if not hasattr(self, "__poincare_settings__"):

            # to convert data accessor objects based on file specification
            # objects to inform a user about progression special kind of
            # progress bar is used
            data_accessors_group_converter = FilesSpecificationsToDataAccessorsGroupConverter(
                self, self.__file_specifications__
            )

            data_vectors_accessor_group = data_accessors_group_converter.data_vectors_accessors_group

            self.__poincare_settings__ = PoincarePlotSettingsDockWidget(
                self,
                data_vectors_accessor_group=data_vectors_accessor_group,
                output_file_listener=self.__output_file_listener__,
                # save outcomes button in PoincarePlotSettingsDockWidget
                # have to be in fixed check state
                save_outcomes_fixed_state=True,
            )
        self.__poincare_settings__.show()

        if not hasattr(self, "__poincare_datasources_table__"):
            self.__poincare_datasources_table__ = PoincarePlotDatasourcesTableWidget(
                self.__central_widget__, data_accessors=data_vectors_accessor_group.data_vectors_accessors
            )  # @IgnorePep8
        self.__poincare_datasources_table__.show()

    def __output_file_listener__(self, _filename):
        if not hasattr(self, "__outcome_files_tracker__"):
            self.__outcome_files_tracker__ = OutcomeFilesTrackerDockWidget(self)
        self.__outcome_files_tracker__.show()
        self.__outcome_files_tracker__.appendFile(_filename)

        if hasattr(self, "__poincare_datasources_table__"):
            self.__poincare_datasources_table__.checkMarkFile(_filename)

    def setSelectedFilesSpecificationsHandler(self, _selected_files_specifications_handler):
        self.__selected_files_specifications_handler__ = _selected_files_specifications_handler

    def __removeFileSpecification__(self, _tachogram_plot_tab):
        """
        method is invoked when tachogram plot is closed to remove
        corresponding position from self.__file_specifications__
        """
        if widgets_have_the_same_parent(self, _tachogram_plot_tab, TACHOGRAM_PLOT_TAB_ITEM_WIDGET_OBJECT_NAME):
            if self.__file_specifications__.count(_tachogram_plot_tab.file_specification) > 0:
                del self.__file_specifications__[
                    self.__file_specifications__.index(_tachogram_plot_tab.file_specification)
                ]
예제 #4
0
class TachogramPlotSummaryCompositeWidget(MainWindowWidget):
    """
    initial tachogram plot window used to take operations
    on the whole group of tachogram plots
    """
    def __init__(self, parent, **params):
        super(TachogramPlotSummaryCompositeWidget,
              self).__init__(parent, **params)
        set_temporary_settings_id(self)
        self.params = Params(**params)

        self.addToolBar(
            OperationalToolBarWidget(self, excluded_buttons=[CloseToolButton]))
        self.addToolBar(PoincareToolBarWidget(self, reload_button=True))

        self.__central_widget__ = CompositeWidget(
            self, not_add_widget_to_parent_layout=True)
        layout = QVBoxLayout()
        self.__central_widget__.setLayout(layout)
        self.setCentralWidget(self.__central_widget__)
        self.__file_specifications__ = []
        self.__selected_files_specifications_handler__ = None
        SignalDispatcher.addSignalSubscriber(self, CLOSE_TACHOGRAM_PLOT_SIGNAL,
                                             self.__removeFileSpecification__)

    def toolbar_maximum_handler(self):
        SignalDispatcher.broadcastSignal(MAXIMIZE_TACHOGRAM_PLOT_SIGNAL)

    def toolbar_restore_handler(self):
        SignalDispatcher.broadcastSignal(RESTORE_TACHOGRAM_PLOT_SIGNAL)

    def toolbar_close_handler(self):
        SignalDispatcher.broadcastSignal(CLOSE_TACHOGRAM_PLOT_SIGNAL, self)

    def addFileSpecification(self, _file_specification):
        if self.__file_specifications__.count(_file_specification) == 0:
            self.__file_specifications__.append(_file_specification)

    def reload_poincare_settings_handler(self):
        """
        handler call by PoincareToolBarWidget toolbar
        reloads poincare plot settings widget
        """
        if hasattr(self, '__poincare_settings__'):
            self.removeDockWidget(self.__poincare_settings__)
            self.layout().removeWidget(self.__poincare_settings__)
            self.__poincare_settings__.deleteLater()
            delattr(self, '__poincare_settings__')

        if hasattr(self, '__poincare_datasources_table__'):
            self.layout().removeWidget(self.__poincare_datasources_table__)
            self.__poincare_datasources_table__.deleteLater()
            delattr(self, '__poincare_datasources_table__')

        self.show_poincare_settings_handler()

    def show_poincare_settings_handler(self):
        """
        handler call by PoincareToolBarWidget toolbar
        """

        if self.__selected_files_specifications_handler__:
            selected_files_specifications = \
                        self.__selected_files_specifications_handler__()
            if len(selected_files_specifications) > 0:
                for file_specification in selected_files_specifications:
                    self.addFileSpecification(file_specification)

        if len(self.__file_specifications__) == 0:
            InformationWindow(message='No data sources selected !')
            return
        if not hasattr(self, '__poincare_settings__'):

            #to convert data accessor objects based on file specification
            #objects to inform a user about progression special kind of
            #progress bar is used
            data_accessors_group_converter = \
                FilesSpecificationsToDataAccessorsGroupConverter(
                                            self, self.__file_specifications__)

            data_vectors_accessor_group = \
                data_accessors_group_converter.data_vectors_accessors_group

            self.__poincare_settings__ = PoincarePlotSettingsDockWidget(
                self,
                data_vectors_accessor_group=data_vectors_accessor_group,
                output_file_listener=self.__output_file_listener__,
                #save outcomes button in PoincarePlotSettingsDockWidget
                #have to be in fixed check state
                save_outcomes_fixed_state=True)
        self.__poincare_settings__.show()

        if not hasattr(self, '__poincare_datasources_table__'):
            self.__poincare_datasources_table__ = \
                    PoincarePlotDatasourcesTableWidget(self.__central_widget__,
                        data_accessors=data_vectors_accessor_group.data_vectors_accessors) # @IgnorePep8
        self.__poincare_datasources_table__.show()

    def __output_file_listener__(self, _filename):
        if not hasattr(self, '__outcome_files_tracker__'):
            self.__outcome_files_tracker__ = OutcomeFilesTrackerDockWidget(
                self)
        self.__outcome_files_tracker__.show()
        self.__outcome_files_tracker__.appendFile(_filename)

        if hasattr(self, '__poincare_datasources_table__'):
            self.__poincare_datasources_table__.checkMarkFile(_filename)

    def setSelectedFilesSpecificationsHandler(
            self, _selected_files_specifications_handler):
        self.__selected_files_specifications_handler__ = \
                                    _selected_files_specifications_handler

    def __removeFileSpecification__(self, _tachogram_plot_tab):
        """
        method is invoked when tachogram plot is closed to remove
        corresponding position from self.__file_specifications__
        """
        if widgets_have_the_same_parent(
                self, _tachogram_plot_tab,
                TACHOGRAM_PLOT_TAB_ITEM_WIDGET_OBJECT_NAME):
            if self.__file_specifications__.count(
                    _tachogram_plot_tab.file_specification) > 0:
                del self.__file_specifications__[
                    self.__file_specifications__.index(
                        _tachogram_plot_tab.file_specification)]