Esempio n. 1
0
    def __init__(self, parent, **params):
        self.params = Params(**params)

        self.__splitter_idx__ = 0
        self.data_vectors_accessor_group = \
            self.params.data_vectors_accessor_group  # alias
        if not self.data_vectors_accessor_group == None:
            self.main_data_accessor = \
                self.data_vectors_accessor_group.group_data_vector_accessor
        else:
            self.main_data_accessor = self.params.data_accessor  # alias

        super(PoincarePlotSettingsDockWidget,
              self).__init__(parent,
                             title=params.get('title',
                                              'Poincare plot settings'),
                             **params)
        self.__splitter__ = SplitterWidget(self.dockComposite,
                                           orientation=Qt.Vertical)
        self.__splitter__.setHandleWidth(5)

        self.__createStatisticsWidget__(QVBoxLayout())
        self.__createFiltersWidget__(QHBoxLayout())
        self.__createOutputSpecificationWidget__(QVBoxLayout())
        self.__createMiscellaneousWidget__(QVBoxLayout())

        parent.addDockWidget(Qt.LeftDockWidgetArea, self)
    def __init__(self, **params):
        super(TachogramPlotTabItemWidget, self).__init__(**params)
        self.params = Params(**params)
        layout = QHBoxLayout()
        self.setLayout(layout)
        self.__splitter__ = SplitterWidget(self,
                                           objectName='poincarePlot',
                                           save_state=True)
        self.__createDatasourceListWidget__()
        self.__createTachogramPlotManager__()

        #this method's call is very important, it sets up widgets sizes which
        #make up a splitter; it has to be the last operation in
        #the TachogramPlotTabWidget's creation process
        self.__splitter__.updateSizes()
        self.setObjectName(TACHOGRAM_PLOT_TAB_ITEM_WIDGET_OBJECT_NAME)
Esempio n. 3
0
    def __init__(self, parent, **params):
        self.params = Params(**params)
        self.data_accessor = self.params.data_accessor  # alias
        super(TachogramPlotSettingsDockWidget,
              self).__init__(parent,
                             title=params.get('title',
                                              'Tachogram plot settings'),
                             **params)

        self.__splitter__ = SplitterWidget(self.dockComposite,
                                           orientation=Qt.Vertical)
        self.__splitter__.setHandleWidth(5)

        self.__createUnitsWidget__(QHBoxLayout())
        self.__createFiltersWidget__(QVBoxLayout())

        parent.addDockWidget(Qt.BottomDockWidgetArea, self)
    def __init__(self, **params):
        super(TachogramPlotTabItemWidget, self).__init__(**params)
        self.params = Params(**params)
        layout = QHBoxLayout()
        self.setLayout(layout)
        self.__splitter__ = SplitterWidget(self, objectName='poincarePlot',
                                           save_state=True)
        self.__createDatasourceListWidget__()
        self.__createTachogramPlotManager__()

        #this method's call is very important, it sets up widgets sizes which
        #make up a splitter; it has to be the last operation in
        #the TachogramPlotTabWidget's creation process
        self.__splitter__.updateSizes()
        self.setObjectName(TACHOGRAM_PLOT_TAB_ITEM_WIDGET_OBJECT_NAME)
    def __init__(self, parent, **params):
        self.params = Params(**params)
        self.data_accessor = self.params.data_accessor  # alias
        super(TachogramPlotSettingsDockWidget, self).__init__(parent,
            title=params.get('title', 'Tachogram plot settings'),
            **params)

        self.__splitter__ = SplitterWidget(self.dockComposite,
                                           orientation=Qt.Vertical)
        self.__splitter__.setHandleWidth(5)

        self.__createUnitsWidget__(QHBoxLayout())
        self.__createFiltersWidget__(QVBoxLayout())

        parent.addDockWidget(Qt.BottomDockWidgetArea, self)
Esempio n. 6
0
class TachogramPlotSettingsDockWidget(DockWidgetWidget):
    """
    a dock widget for tachogram plot settings
    """
    def __init__(self, parent, **params):
        self.params = Params(**params)
        self.data_accessor = self.params.data_accessor  # alias
        super(TachogramPlotSettingsDockWidget,
              self).__init__(parent,
                             title=params.get('title',
                                              'Tachogram plot settings'),
                             **params)

        self.__splitter__ = SplitterWidget(self.dockComposite,
                                           orientation=Qt.Vertical)
        self.__splitter__.setHandleWidth(5)

        self.__createUnitsWidget__(QHBoxLayout())
        self.__createFiltersWidget__(QVBoxLayout())

        parent.addDockWidget(Qt.BottomDockWidgetArea, self)

    def __changeUnit__(self, unit):
        if not self.data_accessor == None:
            self.data_accessor.changeXSignalUnit(self, unit)

    def __createUnitsWidget__(self, layout):
        self.__unitsWidget__ = TimeUnitsWidget(
            self.__splitter__,
            i18n_def='X axis units',
            default_unit=self.data_accessor.signal_x_unit,
            change_unit_handler=self.__changeUnit__,
            layout=layout)
        self.__unitsWidget__.addUnit(OrderUnit)
        self.__splitter__.changeSplitterHandleColor(0, Qt.red)

    def __createFiltersWidget__(self, layout):
        self.__filtersWidget__ = FiltersWidget(
            self.__splitter__,
            layout=layout,
            data_accessor=self.data_accessor,
            annotation_widget_class=MasterAnnotationFilterWidget,
            use_apply_button=True,
            restore_button=True)
        self.__splitter__.changeSplitterHandleColor(1, Qt.blue)
    def __init__(self, parent, **params):
        self.params = Params(**params)

        self.__splitter_idx__ = 0
        self.data_vectors_accessor_group = \
            self.params.data_vectors_accessor_group  # alias
        if not self.data_vectors_accessor_group == None:
            self.main_data_accessor = \
                self.data_vectors_accessor_group.group_data_vector_accessor
        else:
            self.main_data_accessor = self.params.data_accessor  # alias

        super(PoincarePlotSettingsDockWidget, self).__init__(parent,
                title=params.get('title', 'Poincare plot settings'), **params)
        self.__splitter__ = SplitterWidget(self.dockComposite,
                                           orientation=Qt.Vertical)
        self.__splitter__.setHandleWidth(5)

        self.__createStatisticsWidget__(QVBoxLayout())
        self.__createFiltersWidget__(QHBoxLayout())
        self.__createOutputSpecificationWidget__(QVBoxLayout())
        self.__createMiscellaneousWidget__(QVBoxLayout())

        parent.addDockWidget(Qt.LeftDockWidgetArea, self)
class TachogramPlotSettingsDockWidget(DockWidgetWidget):
    """
    a dock widget for tachogram plot settings
    """
    def __init__(self, parent, **params):
        self.params = Params(**params)
        self.data_accessor = self.params.data_accessor  # alias
        super(TachogramPlotSettingsDockWidget, self).__init__(parent,
            title=params.get('title', 'Tachogram plot settings'),
            **params)

        self.__splitter__ = SplitterWidget(self.dockComposite,
                                           orientation=Qt.Vertical)
        self.__splitter__.setHandleWidth(5)

        self.__createUnitsWidget__(QHBoxLayout())
        self.__createFiltersWidget__(QVBoxLayout())

        parent.addDockWidget(Qt.BottomDockWidgetArea, self)

    def __changeUnit__(self, unit):
        if not self.data_accessor == None:
            self.data_accessor.changeXSignalUnit(self, unit)

    def __createUnitsWidget__(self, layout):
        self.__unitsWidget__ = TimeUnitsWidget(self.__splitter__,
                                i18n_def='X axis units',
                                default_unit=self.data_accessor.signal_x_unit,
                                change_unit_handler=self.__changeUnit__,
                                layout=layout)
        self.__unitsWidget__.addUnit(OrderUnit)
        self.__splitter__.changeSplitterHandleColor(0, Qt.red)

    def __createFiltersWidget__(self, layout):
        self.__filtersWidget__ = FiltersWidget(self.__splitter__,
                        layout=layout, data_accessor=self.data_accessor,
                        annotation_widget_class=MasterAnnotationFilterWidget,
                        use_apply_button=True,
                        restore_button=True)
        self.__splitter__.changeSplitterHandleColor(1, Qt.blue)
class TachogramPlotTabItemWidget(TabWidgetItemCommon):

    def __init__(self, **params):
        super(TachogramPlotTabItemWidget, self).__init__(**params)
        self.params = Params(**params)
        layout = QHBoxLayout()
        self.setLayout(layout)
        self.__splitter__ = SplitterWidget(self, objectName='poincarePlot',
                                           save_state=True)
        self.__createDatasourceListWidget__()
        self.__createTachogramPlotManager__()

        #this method's call is very important, it sets up widgets sizes which
        #make up a splitter; it has to be the last operation in
        #the TachogramPlotTabWidget's creation process
        self.__splitter__.updateSizes()
        self.setObjectName(TACHOGRAM_PLOT_TAB_ITEM_WIDGET_OBJECT_NAME)

    def beforeCloseTab(self):
        """
        this method includes actions to be invoked when a TachogramPlotTabWidget is closing @IgnorePep8
        """
        self.__splitter__.saveSettings()

    def __createDatasourceListWidget__(self):
        self.__datasourceListWidget__ = \
            TachogramPlotDatasourceListWidget(self.__splitter__,
                                              self.params.model,
                add_tachogram_plot_handler=self.__addTachogramPlot__,
                close_tachogram_plot_handler=self.closeTab,
                close_tachograms_handler=self.__closeTachogramsHandler__)
        if self.__splitter__.sizesLoaded() == False:
            idx = self.__splitter__.indexOf(self.__datasourceListWidget__)
            self.__splitter__.setStretchFactor(idx, 1)

    def __createTachogramPlotManager__(self):
        self.__tachogramsManager__ = TachogramPlotManager(self.__splitter__,
                                                     add_widget_to_parent=True)
        self.__initial_tachogram_plot__ = \
                        self.__tachogramsManager__.createInitialPlot()
        self.__initial_tachogram_plot__.setSelectedFilesSpecificationsHandler(
                            self.__selected_files_specifications_handler__)

        if self.__splitter__.sizesLoaded() == False:
            idx = self.__splitter__.indexOf(self.__tachogramsManager__)
            self.__splitter__.setStretchFactor(idx, 20)
        SignalDispatcher.addSignalSubscriber(self, CLOSE_TACHOGRAM_PLOT_SIGNAL,
                                            self.__closeTachogramPlot__)
        SignalDispatcher.addSignalSubscriber(self, TAB_WIDGET_ADDED_SIGNAL,
                                            self.__tachogramPlotAdded__)
        SignalDispatcher.addSignalSubscriber(self,
                                             MAXIMIZE_TACHOGRAM_PLOT_SIGNAL,
                                             self.__maximizeTachogramPlot__)
        SignalDispatcher.addSignalSubscriber(self,
                                             RESTORE_TACHOGRAM_PLOT_SIGNAL,
                                             self.__restoreTachogramPlot__)

    def __addTachogramPlot__(self, file_specification, allow_duplication,
                             first_focus):
        added = self.__tachogramsManager__.addTachogramPlot(
                                        file_specification,
                                        allow_duplication=allow_duplication,
                                        first_focus=first_focus)
        if added:
            self.__initial_tachogram_plot__.addFileSpecification(
                                                        file_specification)
        return added

    def __closeTachogramsHandler__(self):
        if AreYouSureWindow(self, title='Closing all tachograms plots'):
            self.__tachogramsManager__.closeAllTabs()
            return True
        return False

    def __tachogramPlotAdded__(self):
        self.__datasourceListWidget__.enabledCloseAllTachogramsButton(True)

    def __closeTachogramPlot__(self, _tachogram_plot_tab):
        """
        method invoked when tachogram plot is closed and then it checks
        there are any opened tachogram plots if this is not the case
        the button 'close all tachograms' is disabled
        """
        if self.__tachogramsManager__.countNotCloseTabs() == 0:
            self.__datasourceListWidget__.enabledCloseAllTachogramsButton(False) #  @IgnorePep8
            self.__datasourceListWidget__.emit(ENABLEMEND_SIGNAL, False)

    def __maximizeTachogramPlot__(self):
        maximize_widget(self.__tachogramsManager__)

    def __restoreTachogramPlot__(self):
        restore_widget(self.__tachogramsManager__)

    def __selected_files_specifications_handler__(self):
        return self.__datasourceListWidget__.getSelectedFilesSpecifications()
Esempio n. 10
0
class PoincarePlotSettingsDockWidget(DockWidgetWidget):
    """
    a dock widget for poincare plot settings
    """
    def __init__(self, parent, **params):
        self.params = Params(**params)

        self.__splitter_idx__ = 0
        self.data_vectors_accessor_group = \
            self.params.data_vectors_accessor_group  # alias
        if not self.data_vectors_accessor_group == None:
            self.main_data_accessor = \
                self.data_vectors_accessor_group.group_data_vector_accessor
        else:
            self.main_data_accessor = self.params.data_accessor  # alias

        super(PoincarePlotSettingsDockWidget,
              self).__init__(parent,
                             title=params.get('title',
                                              'Poincare plot settings'),
                             **params)
        self.__splitter__ = SplitterWidget(self.dockComposite,
                                           orientation=Qt.Vertical)
        self.__splitter__.setHandleWidth(5)

        self.__createStatisticsWidget__(QVBoxLayout())
        self.__createFiltersWidget__(QHBoxLayout())
        self.__createOutputSpecificationWidget__(QVBoxLayout())
        self.__createMiscellaneousWidget__(QVBoxLayout())

        parent.addDockWidget(Qt.LeftDockWidgetArea, self)

    def __changeUnit__(self, unit):
        if not self.main_data_accessor == None:
            self.main_data_accessor.changeXSignalUnit(self, unit)

    def __createFiltersWidget__(self, layout):
        FiltersWidget(self.__splitter__,
                      layout=layout,
                      data_accessor=self.main_data_accessor,
                      title='Active filters for tachogram plot',
                      use_apply_button=False,
                      annotation_widget_class=SlaveAnnotationFilterWidget)
        self.__splitter__.changeSplitterHandleColor(self.__splitter_idx__,
                                                    Qt.red)
        self.__splitter_idx__ += 1

    def __createOutputSpecificationWidget__(self, layout):
        OutputSpecificationWidget(self.__splitter__,
                                  no_custom_separator=True,
                                  layout=layout,
                                  data_accessor=self.main_data_accessor)
        self.__splitter__.changeSplitterHandleColor(self.__splitter_idx__,
                                                    Qt.blue)
        self.__splitter_idx__ += 1

    def __createMiscellaneousWidget__(self, layout):
        MiscellaneousWidget(self.__splitter__,
                            layout=layout,
                            data_accessor=self.main_data_accessor)
        self.__splitter__.changeSplitterHandleColor(self.__splitter_idx__,
                                                    Qt.green)
        self.__splitter_idx__ += 1

    def __createStatisticsWidget__(self, layout):
        self.__statistics_widget__ = StatisticsWidget(
            self.__splitter__,
            layout=layout,
            data_accessor=self.main_data_accessor,
            data_vectors_accessor_group=self.data_vectors_accessor_group,
            output_file_listener=self.params.output_file_listener,
            save_outcomes_fixed_state=self.params.save_outcomes_fixed_state)
        self.__splitter__.changeSplitterHandleColor(self.__splitter_idx__,
                                                    Qt.black)
        self.__splitter_idx__ += 1
class TachogramPlotTabItemWidget(TabWidgetItemCommon):
    def __init__(self, **params):
        super(TachogramPlotTabItemWidget, self).__init__(**params)
        self.params = Params(**params)
        layout = QHBoxLayout()
        self.setLayout(layout)
        self.__splitter__ = SplitterWidget(self,
                                           objectName='poincarePlot',
                                           save_state=True)
        self.__createDatasourceListWidget__()
        self.__createTachogramPlotManager__()

        #this method's call is very important, it sets up widgets sizes which
        #make up a splitter; it has to be the last operation in
        #the TachogramPlotTabWidget's creation process
        self.__splitter__.updateSizes()
        self.setObjectName(TACHOGRAM_PLOT_TAB_ITEM_WIDGET_OBJECT_NAME)

    def beforeCloseTab(self):
        """
        this method includes actions to be invoked when a TachogramPlotTabWidget is closing @IgnorePep8
        """
        self.__splitter__.saveSettings()

    def __createDatasourceListWidget__(self):
        self.__datasourceListWidget__ = \
            TachogramPlotDatasourceListWidget(self.__splitter__,
                                              self.params.model,
                add_tachogram_plot_handler=self.__addTachogramPlot__,
                close_tachogram_plot_handler=self.closeTab,
                close_tachograms_handler=self.__closeTachogramsHandler__)
        if self.__splitter__.sizesLoaded() == False:
            idx = self.__splitter__.indexOf(self.__datasourceListWidget__)
            self.__splitter__.setStretchFactor(idx, 1)

    def __createTachogramPlotManager__(self):
        self.__tachogramsManager__ = TachogramPlotManager(
            self.__splitter__, add_widget_to_parent=True)
        self.__initial_tachogram_plot__ = \
                        self.__tachogramsManager__.createInitialPlot()
        self.__initial_tachogram_plot__.setSelectedFilesSpecificationsHandler(
            self.__selected_files_specifications_handler__)

        if self.__splitter__.sizesLoaded() == False:
            idx = self.__splitter__.indexOf(self.__tachogramsManager__)
            self.__splitter__.setStretchFactor(idx, 20)
        SignalDispatcher.addSignalSubscriber(self, CLOSE_TACHOGRAM_PLOT_SIGNAL,
                                             self.__closeTachogramPlot__)
        SignalDispatcher.addSignalSubscriber(self, TAB_WIDGET_ADDED_SIGNAL,
                                             self.__tachogramPlotAdded__)
        SignalDispatcher.addSignalSubscriber(self,
                                             MAXIMIZE_TACHOGRAM_PLOT_SIGNAL,
                                             self.__maximizeTachogramPlot__)
        SignalDispatcher.addSignalSubscriber(self,
                                             RESTORE_TACHOGRAM_PLOT_SIGNAL,
                                             self.__restoreTachogramPlot__)

    def __addTachogramPlot__(self, file_specification, allow_duplication,
                             first_focus):
        added = self.__tachogramsManager__.addTachogramPlot(
            file_specification,
            allow_duplication=allow_duplication,
            first_focus=first_focus)
        if added:
            self.__initial_tachogram_plot__.addFileSpecification(
                file_specification)
        return added

    def __closeTachogramsHandler__(self):
        if AreYouSureWindow(self, title='Closing all tachograms plots'):
            self.__tachogramsManager__.closeAllTabs()
            return True
        return False

    def __tachogramPlotAdded__(self):
        self.__datasourceListWidget__.enabledCloseAllTachogramsButton(True)

    def __closeTachogramPlot__(self, _tachogram_plot_tab):
        """
        method invoked when tachogram plot is closed and then it checks
        there are any opened tachogram plots if this is not the case
        the button 'close all tachograms' is disabled
        """
        if self.__tachogramsManager__.countNotCloseTabs() == 0:
            self.__datasourceListWidget__.enabledCloseAllTachogramsButton(
                False)  #  @IgnorePep8
            self.__datasourceListWidget__.emit(ENABLEMEND_SIGNAL, False)

    def __maximizeTachogramPlot__(self):
        maximize_widget(self.__tachogramsManager__)

    def __restoreTachogramPlot__(self):
        restore_widget(self.__tachogramsManager__)

    def __selected_files_specifications_handler__(self):
        return self.__datasourceListWidget__.getSelectedFilesSpecifications()
class PoincarePlotSettingsDockWidget(DockWidgetWidget):
    """
    a dock widget for poincare plot settings
    """
    def __init__(self, parent, **params):
        self.params = Params(**params)

        self.__splitter_idx__ = 0
        self.data_vectors_accessor_group = \
            self.params.data_vectors_accessor_group  # alias
        if not self.data_vectors_accessor_group == None:
            self.main_data_accessor = \
                self.data_vectors_accessor_group.group_data_vector_accessor
        else:
            self.main_data_accessor = self.params.data_accessor  # alias

        super(PoincarePlotSettingsDockWidget, self).__init__(parent,
                title=params.get('title', 'Poincare plot settings'), **params)
        self.__splitter__ = SplitterWidget(self.dockComposite,
                                           orientation=Qt.Vertical)
        self.__splitter__.setHandleWidth(5)

        self.__createStatisticsWidget__(QVBoxLayout())
        self.__createFiltersWidget__(QHBoxLayout())
        self.__createOutputSpecificationWidget__(QVBoxLayout())
        self.__createMiscellaneousWidget__(QVBoxLayout())

        parent.addDockWidget(Qt.LeftDockWidgetArea, self)

    def __changeUnit__(self, unit):
        if not self.main_data_accessor == None:
            self.main_data_accessor.changeXSignalUnit(self, unit)

    def __createFiltersWidget__(self, layout):
        FiltersWidget(self.__splitter__,
                        layout=layout, data_accessor=self.main_data_accessor,
                        title='Active filters for tachogram plot',
                        use_apply_button=False,
                        annotation_widget_class=SlaveAnnotationFilterWidget)
        self.__splitter__.changeSplitterHandleColor(self.__splitter_idx__,
                                                    Qt.red)
        self.__splitter_idx__ += 1

    def __createOutputSpecificationWidget__(self, layout):
        OutputSpecificationWidget(self.__splitter__, no_custom_separator=True,
                        layout=layout, data_accessor=self.main_data_accessor)
        self.__splitter__.changeSplitterHandleColor(self.__splitter_idx__,
                                                    Qt.blue)
        self.__splitter_idx__ += 1

    def __createMiscellaneousWidget__(self, layout):
        MiscellaneousWidget(self.__splitter__, layout=layout,
                            data_accessor=self.main_data_accessor)
        self.__splitter__.changeSplitterHandleColor(self.__splitter_idx__,
                                                    Qt.green)
        self.__splitter_idx__ += 1

    def __createStatisticsWidget__(self, layout):
        self.__statistics_widget__ = StatisticsWidget(self.__splitter__,
            layout=layout, data_accessor=self.main_data_accessor,
            data_vectors_accessor_group=self.data_vectors_accessor_group,
            output_file_listener=self.params.output_file_listener,
            save_outcomes_fixed_state=self.params.save_outcomes_fixed_state)
        self.__splitter__.changeSplitterHandleColor(self.__splitter_idx__,
                                                    Qt.black)
        self.__splitter_idx__ += 1