示例#1
0
    def __init__(self, parent):
        super(PlotCustomizer, self).__init__()

        self._plot_config_key = None
        self._previous_key = None
        self._plot_configs = {None: PlotConfigHistory("No_Key_Selected", PlotConfig(None))}

        self._plotConfigCreator = self._defaultPlotConfigCreator

        self._customization_dialog = CustomizePlotDialog("Customize", parent)

        self._customization_dialog.addTab("general", "General", DefaultCustomizationView())
        self._customization_dialog.addTab("style", "Style", StyleCustomizationView())
        self._customization_dialog.addTab("statistics", "Statistics", StatisticsCustomizationView())

        self._customize_limits = LimitsCustomizationView()
        self._customization_dialog.addTab("limits", "Limits", self._customize_limits)

        self._customization_dialog.applySettings.connect(self.applyCustomization)
        self._customization_dialog.undoSettings.connect(self.undoCustomization)
        self._customization_dialog.redoSettings.connect(self.redoCustomization)
        self._customization_dialog.resetSettings.connect(self.resetCustomization)
        self._customization_dialog.copySettings.connect(self.copyCustomization)

        self._revertCustomization(self.getPlotConfig())
示例#2
0
 def switchPlotConfigHistory(self, key):
     if key != self._plot_config_key:
         if not key in self._plot_configs:
             self._plot_configs[key] = PlotConfigHistory(key, self._selectiveCopyOfCurrentPlotConfig(key))
             self._customization_dialog.addCopyableKey(key)
         self._previous_key = self._plot_config_key
         self._plot_config_key = key
         self._revertCustomization(self.getPlotConfig(), emit=False)
示例#3
0
 def switchPlotConfigHistory(self, key_def):
     key = key_def["key"]
     if key != self._plot_config_key:
         if not key in self._plot_configs:
             self._plot_configs[key] = PlotConfigHistory(
                 key, PlotConfigFactory.createPlotConfigForKey(key_def))
             self._customization_dialog.addCopyableKey(key)
         self._customization_dialog.currentPlotKeyChanged(key)
         self._previous_key = self._plot_config_key
         self._plot_config_key = key
         self._revertCustomization(self.getPlotConfig(), emit=False)
示例#4
0
    def copyCustomizationTo(self, keys):
        """ copies the plotconfig of the current key, to a set of other keys"""
        history = self._getPlotConfigHistory()

        for key in keys:
            if key not in self._plot_configs:
                self._plot_configs[key] = PlotConfigHistory("No_Key_Selected",
                                                            PlotConfig(self.default_plot_settings, title=None))
            source_config = history.getPlotConfig()
            source_config.setTitle(key)

            self._plot_configs[key].applyChanges(source_config)

            self._customization_dialog.addCopyableKey(key)

        self._emitChangedSignal(emit=True)
示例#5
0
    def test_plot_config_history(self):
        ps = PlotSettings()
        test_pc = PlotConfig(ps, title="test_1")
        history = PlotConfigHistory("test", test_pc)

        self.assertEqual(history.getPlotConfig().title(), test_pc.title())
        self.assertNotEqual(history.getPlotConfig(), test_pc)

        self.assertFalse(history.isUndoPossible())
        self.assertFalse(history.isRedoPossible())

        history.applyChanges(PlotConfig(ps, title="test_2"))
        self.assertTrue(history.isUndoPossible())
        self.assertFalse(history.isRedoPossible())
        self.assertEqual(history.getPlotConfig().title(), "test_2")

        history.undoChanges()
        self.assertFalse(history.isUndoPossible())
        self.assertTrue(history.isRedoPossible())
        self.assertEqual(history.getPlotConfig().title(), "test_1")

        history.redoChanges()
        self.assertTrue(history.isUndoPossible())
        self.assertFalse(history.isRedoPossible())
        self.assertEqual(history.getPlotConfig().title(), "test_2")

        history.resetChanges()
        self.assertTrue(history.isUndoPossible())
        self.assertFalse(history.isRedoPossible())
        self.assertEqual(history.getPlotConfig().title(), "test_1")

        history.undoChanges()
        self.assertTrue(history.isUndoPossible())
        self.assertTrue(history.isRedoPossible())
        self.assertEqual(history.getPlotConfig().title(), "test_2")
示例#6
0
    def test_plot_config_history(self):
        ps = PlotSettings( )
        test_pc = PlotConfig(ps , title = "test_1")
        history = PlotConfigHistory("test", test_pc)

        self.assertEqual(history.getPlotConfig().title(), test_pc.title())
        self.assertNotEqual(history.getPlotConfig(), test_pc)

        self.assertFalse(history.isUndoPossible())
        self.assertFalse(history.isRedoPossible())

        history.applyChanges(PlotConfig(ps, title = "test_2"))
        self.assertTrue(history.isUndoPossible())
        self.assertFalse(history.isRedoPossible())
        self.assertEqual(history.getPlotConfig().title(), "test_2")

        history.undoChanges()
        self.assertFalse(history.isUndoPossible())
        self.assertTrue(history.isRedoPossible())
        self.assertEqual(history.getPlotConfig().title(), "test_1")

        history.redoChanges()
        self.assertTrue(history.isUndoPossible())
        self.assertFalse(history.isRedoPossible())
        self.assertEqual(history.getPlotConfig().title(), "test_2")

        history.resetChanges()
        self.assertTrue(history.isUndoPossible())
        self.assertFalse(history.isRedoPossible())
        self.assertEqual(history.getPlotConfig().title(), "test_1")

        history.undoChanges()
        self.assertTrue(history.isUndoPossible())
        self.assertTrue(history.isRedoPossible())
        self.assertEqual(history.getPlotConfig().title(), "test_2")