class SaveSettingsTest(unittest.TestCase):
    def setUp(self):
        self.app = QtGui.QApplication(sys.argv)

    def tearDown(self):
        del self.app

    def create_controller_and_data(self):
        self.controller = MainController()
        self.img_data = self.controller.img_model
        self.mask_data = self.controller.mask_model
        self.calibration_data = self.controller.calibration_model
        self.spectrum_data = self.controller.spectrum_model
        self.phase_data = self.controller.phase_model


    def test_calibration_data(self):
        self.create_controller_and_data()
        self.calibration_data.load(os.path.join(data_path, "LaB6_40keV_MarCCD.poni"))

        center_x = self.calibration_data.spectrum_geometry.poni1

        self.controller.save_settings()
        self.create_controller_and_data()

        self.assertEqual(self.calibration_data.spectrum_geometry.poni1, center_x)
Example #2
0
 def create_controller_and_data(self):
     self.controller = MainController()
     self.img_model = self.controller.img_model
     self.mask_model = self.controller.mask_model
     self.calibration_model = self.controller.calibration_model
     self.calibration_model.integrate_1d = MagicMock(
         return_value=(self.calibration_model.tth,
                       self.calibration_model.int))
     self.spectrum_model = self.controller.spectrum_model
     self.phase_model = self.controller.phase_model
 def create_controller_and_data(self):
     self.controller = MainController()
     self.img_data = self.controller.img_model
     self.mask_data = self.controller.mask_model
     self.calibration_data = self.controller.calibration_model
     self.spectrum_data = self.controller.spectrum_model
     self.phase_data = self.controller.phase_model
Example #4
0
 def create_controller_and_data(self):
     self.controller = MainController()
     self.img_model = self.controller.img_model
     self.mask_model = self.controller.mask_model
     self.calibration_model = self.controller.calibration_model
     self.calibration_model.integrate_1d = MagicMock(return_value=(self.calibration_model.tth,
                                                                   self.calibration_model.int))
     self.spectrum_model = self.controller.spectrum_model
     self.phase_model = self.controller.phase_model
Example #5
0
class SaveSettingsTest(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.app = QtGui.QApplication([])

    @classmethod
    def tearDownClass(cls):
        cls.app.quit()
        cls.app.deleteLater()

    def create_controller_and_data(self):
        self.controller = MainController()
        self.img_model = self.controller.img_model
        self.mask_model = self.controller.mask_model
        self.calibration_model = self.controller.calibration_model
        self.calibration_model.integrate_1d = MagicMock(
            return_value=(self.calibration_model.tth,
                          self.calibration_model.int))
        self.spectrum_model = self.controller.spectrum_model
        self.phase_model = self.controller.phase_model

    def tearDown(self):
        del self.calibration_model.cake_geometry
        del self.calibration_model.spectrum_geometry
        del self.calibration_model
        del self.img_model
        del self.mask_model
        del self.controller
        gc.collect()

    def test_calibration_data(self):
        self.create_controller_and_data()
        self.calibration_model.load(
            os.path.join(data_path, "LaB6_40keV_MarCCD.poni"))

        center_x = self.calibration_model.spectrum_geometry.poni1

        self.controller.save_settings()
        self.tearDown()
        self.create_controller_and_data()

        self.assertEqual(self.calibration_model.spectrum_geometry.poni1,
                         center_x)
Example #6
0
class SaveSettingsTest(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.app = QtGui.QApplication([])

    @classmethod
    def tearDownClass(cls):
        cls.app.quit()
        cls.app.deleteLater()

    def create_controller_and_data(self):
        self.controller = MainController()
        self.img_model = self.controller.img_model
        self.mask_model = self.controller.mask_model
        self.calibration_model = self.controller.calibration_model
        self.calibration_model.integrate_1d = MagicMock(return_value=(self.calibration_model.tth,
                                                                      self.calibration_model.int))
        self.spectrum_model = self.controller.spectrum_model
        self.phase_model = self.controller.phase_model

    def tearDown(self):
        del self.calibration_model.cake_geometry
        del self.calibration_model.spectrum_geometry
        del self.calibration_model
        del self.img_model
        del self.mask_model
        del self.controller
        gc.collect()

    def test_calibration_data(self):
        self.create_controller_and_data()
        self.calibration_model.load(os.path.join(data_path, "LaB6_40keV_MarCCD.poni"))

        center_x = self.calibration_model.spectrum_geometry.poni1

        self.controller.save_settings()
        self.tearDown()
        self.create_controller_and_data()

        self.assertEqual(self.calibration_model.spectrum_geometry.poni1, center_x)
Example #7
0
    def __init__(self):
        super(Example, self).__init__()

        self.mainController = MainController()

        self.pw = pg.PlotWidget(name='Plot1')
        self.modelTimeEdit = QtGui.QLineEdit()
        self.modelTimeEdit.setText(str(SolveModel.MODELING_TIME))
        self.stepIntegrationEdit = QtGui.QLineEdit()
        self.stepIntegrationEdit.setValidator(QtGui.QDoubleValidator(0.01, 1000.0, 3))
        self.stepIntegrationEdit.setText(str(SolveModel.STEP))
        self.valueManegeEdit = QtGui.QLineEdit()
        self.valueManegeEdit.setText(str(SolveModel.MANAGE_VALUE))
        self.manageTimeEdit = QtGui.QLineEdit()
        self.manageTimeEdit.setText(str(SolveModel.MANAGE_TIME))
        self.initUI()
Example #8
0
def run():
    app = QtGui.QApplication(sys.argv)
    main_controller = MainController()
    main_controller.show_view()
    app.exec_()
Example #9
0
# -*- coding: utf8 -*-
# SXRD_Collect - GUI program for collection single crystal X-ray diffraction data
# Copyright (C) 2015  Clemens Prescher ([email protected])
# GSECARS, University of Chicago
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
#     (at your option) any later version.
#
#     This program is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
#
#     You should have received a copy of the GNU General Public License
#     along with this program.  If not, see <http://www.gnu.org/licenses/>.
__author__ = 'Clemens Prescher'

import sys

from PyQt4 import QtGui

from controller.MainController import MainController

if __name__ == '__main__':
    app = QtGui.QApplication(sys.argv)
    controller = MainController()
    app.exec_()
#!/usr/bin/env python3
import sys

from controller.MainController import MainController
import re
if __name__ == '__main__':
    dict_regex = {
        'file_path': r"^file_path=(.*)$",
        'delay_refresh_general':
        r"^delay_refresh_general=([0-9]+(\.[0-9]+)?)$",
        'delay_refresh_statistics': r"^delay_refresh_statistics=([0-9]+)$",
        'delay_refresh_alert': r"^delay_refresh_alert=([0-9]+(\.[0-9]+)?)$",
        'threshold': r"^threshold=([0-9]+)$",
    }
    dict_param = {}
    for arg in sys.argv[1:]:
        print(arg)
        for key, reg in dict_regex.items():
            match = re.match(reg, arg)
            if match:
                dict_param[key] = match.group(1)
                del dict_regex[key]
                break
    application = MainController(dict_param)
Example #11
0
# -*- coding: utf8 -*-
__author__ = 'Clemens Prescher'

import sys
from datetime import datetime

from PyQt4 import QtGui

from controller.MainController import MainController

__version__ = 0.24

from sys import platform

app = QtGui.QApplication(sys.argv)
if platform != "darwin":
    app.setStyle('plastique')
controller = MainController(__version__)
controller.show_window()
app.exec_()
Example #12
0
 def setUp(self):
     self.app = QtGui.QApplication([])
     self.controller = MainController()
     self.main_widget = self.controller.main_widget
     self.model_widget = self.controller.main_widget.control_widget.model_widget
     self.create_spectrum()
Example #13
0
class PeakThisFunctionalTest(unittest.TestCase):
    def setUp(self):
        self.app = QtGui.QApplication([])
        self.controller = MainController()
        self.main_widget = self.controller.main_widget
        self.model_widget = self.controller.main_widget.control_widget.model_widget
        self.create_spectrum()

    def tearDown(self):
        del self.app


    def array_almost_equal(self, array1, array2):
        self.assertAlmostEqual(np.sum(array1 - array2), 0)

    def array_not_almost_equal(self, array1, array2):
        self.assertNotAlmostEqual(np.sum(array1 - array2), 0)

    def add_peak(self, type_number, click1_pos, click2_pos):
        QTest.mouseClick(self.main_widget.model_add_btn, QtCore.Qt.LeftButton)
        self.main_widget.model_selector_dialog.model_list.setCurrentRow(type_number)
        QTest.mouseClick(self.main_widget.model_selector_dialog.ok_btn, QtCore.Qt.LeftButton)
        QTest.mouseClick(self.main_widget.model_define_btn, QtCore.Qt.LeftButton)
        self.main_widget.spectrum_widget._spectrum_plot_emit_mouse_click_event(click1_pos[0], click1_pos[1])
        self.main_widget.spectrum_widget._spectrum_plot_emit_mouse_click_event(click2_pos[0], click2_pos[1])

    def copy_model(self, click1_pos, click2_pos):
        QTest.mouseClick(self.main_widget.model_copy_btn, QtCore.Qt.LeftButton)
        self.main_widget.spectrum_widget._spectrum_plot_emit_mouse_click_event(click1_pos[0], click1_pos[1])
        self.main_widget.spectrum_widget._spectrum_plot_emit_mouse_click_event(click2_pos[0], click2_pos[1])


    def create_spectrum(self):
        self.x = np.linspace(0, 10, 1000)
        self.y = np.zeros(self.x.shape)

        # creating the background:
        bkg_x = [0, 3, 7, 10]
        bkg_y = [1, 1.2, 1.1, 1]
        pchip_interpolator = PchipInterpolator(bkg_x, bkg_y, extrapolate=True)
        self.y += pchip_interpolator(self.x)

        # creating the models
        def create_peak(x, center, intensity, fwhm=0.2):
            gauss_curve = PickGaussianModel()
            gauss_curve.set_parameter_value('center', center)
            gauss_curve.set_parameter_value('intensity', intensity)
            gauss_curve.set_parameter_value('fwhm', fwhm)
            return gauss_curve.quick_eval(x)

        self.y += create_peak(self.x, 1, 10)
        self.y += create_peak(self.x, 3, 5)
        self.y += create_peak(self.x, 6, 2)
        self.y += create_peak(self.x, 7.5, 3)
        self.y += create_peak(self.x, 9, 8)

        #adding noise
        self.y += np.random.normal(0, 0.03 * np.max(self.y), self.y.shape)

        self.temp_file = tempfile.NamedTemporaryFile(suffix='.txt', delete=False)
        np.savetxt(self.temp_file, np.dstack((self.x, self.y))[0])
        self.temp_file.close()


    def test_use_case_for_raman_fitting(self):
        # Edith opens PeakThis sees the open file button and loads her spectrum into the program
        # she clicks the button and loads a spectrum
        self.controller.load_data(self.temp_file.name)

        # Edith notices that the spectrum is immediately shown in the graph window
        QtGui.QApplication.processEvents()
        x, y = self.main_widget.spectrum_widget.get_plot_data()

        self.array_almost_equal(x, self.x)
        self.array_almost_equal(y, self.y)

        # then she sees that she can define a background for her Data
        # she chooses that the standard pchip should be fine to model her data
        # and clicks define and sees that she can add points by clicking into the spectrum

        QTest.mouseClick(self.main_widget.background_define_btn, QtCore.Qt.LeftButton)

        bkg_click_points_x = [0, 3, 5]
        bkg_click_points_y = [1, 1.2, 6]

        for ind in range(len(bkg_click_points_x)):
            self.main_widget.spectrum_widget._spectrum_plot_emit_mouse_click_event(bkg_click_points_x[ind],
                                                                                  bkg_click_points_y[ind])

        bkg_points_x, bkg_points_y = self.main_widget.spectrum_widget.get_background_points_data()

        self.array_almost_equal(bkg_points_x, bkg_click_points_x)
        self.array_almost_equal(bkg_points_y, bkg_click_points_y)

        # every time she clicks in the spectrum after the first three clicks she sees that the background changes
        self.main_widget.spectrum_widget._spectrum_plot_emit_mouse_click_event(7, 1.1)

        x, bkg_y1 = self.main_widget.spectrum_widget.get_background_plot_data()
        self.array_almost_equal(self.x, x)

        self.main_widget.spectrum_widget._spectrum_plot_emit_mouse_click_event(10, 1)
        x, bkg_y2 = self.main_widget.spectrum_widget.get_background_plot_data()

        self.array_not_almost_equal(bkg_y1, bkg_y2)

        # after inspecting her data and background model she thinks that 'pchip' is maybe not the best way to
        # approximate the background so she tries the spline model, and she notices how the background is change

        self.main_widget.background_method_cb.setCurrentIndex(1)

        x, bkg_y3 = self.main_widget.spectrum_widget.get_background_plot_data()
        self.array_not_almost_equal(bkg_y2, bkg_y3)

        # then she sees that spline is actually worse and goes back to pchip
        self.main_widget.background_method_cb.setCurrentIndex(0)
        x, bkg_y4 = self.main_widget.spectrum_widget.get_background_plot_data()
        self.array_almost_equal(bkg_y4, bkg_y2)

        # Edith decides that she is finished with the background and clicks the button to finish it

        QTest.mouseClick(self.main_widget.background_define_btn, QtCore.Qt.LeftButton)

        # she notices that clicking into the spectrum now does not effect background any more...
        self.main_widget.spectrum_widget._spectrum_plot_emit_mouse_click_event(10, 10)
        x, bkg_y5 = self.main_widget.spectrum_widget.get_background_plot_data()
        self.array_almost_equal(bkg_y5, bkg_y4)

        # while playing and being happy that everything works she realizes that there is one point which might be
        # better deleted
        # She clicks the define button again and moves to the point and tries to delete by pressing x
        QTest.mouseClick(self.main_widget.background_define_btn, QtCore.Qt.LeftButton)


        class DummyKeyPressEvent():
            def __init__(self, text):
                self._text = text

            def text(self):
                return self._text


        self.main_widget.spectrum_widget._spectrum_plot_set_current_mouse_position(6.2, 4.5)
        self.main_widget.spectrum_widget._spectrum_plot_send_keypress_event(DummyKeyPressEvent('x'))

        bkg_scatter_x, bkg_scatter_y = self.main_widget.spectrum_widget.get_background_points_data()
        self.array_almost_equal(bkg_scatter_x, [0, 3, 7, 10])
        self.array_almost_equal(bkg_scatter_y, [1, 1.2, 1.1, 1])

        # Now she is satisfied with the result and finishes the background determination process
        QTest.mouseClick(self.main_widget.background_define_btn, QtCore.Qt.LeftButton)

        # she notices that pressing x does not delete points anymore
        self.main_widget.spectrum_widget._spectrum_plot_send_keypress_event(DummyKeyPressEvent('x'))
        bkg_scatter_x, bkg_scatter_y = self.main_widget.spectrum_widget.get_background_points_data()
        self.array_almost_equal(bkg_scatter_x, [0, 3, 7, 10])
        self.array_almost_equal(bkg_scatter_y, [1, 1.2, 1.1, 1])

        # As Edith is now happy with the background she decides to add a peak, because that's what she is here for,
        # right?
        # She sees that there is an add button an presses it
        QTest.mouseClick(self.main_widget.model_add_btn, QtCore.Qt.LeftButton)

        # a small dialog appears where she can choose the model she wants to add. She Sees that there are several
        # possible she thinks her peaks are
        # Gaussian shape like she chooses the Gaussian entry
        self.main_widget.model_selector_dialog.model_list.setCurrentRow(0)
        QTest.mouseClick(self.main_widget.model_selector_dialog.ok_btn, QtCore.Qt.LeftButton)

        # then she sees that a model appears in the list below the add button and that there is a table with
        # parameters available for the model

        self.assertGreater(self.main_widget.model_list.count(), 0)
        self.assertGreater(self.main_widget.model_parameter_table.rowCount(), 0)

        # she wonders if it is possible to change the parameters in the text boxes of the parameter table, and sees
        # that the spectrum is changing
        start_x, start_y = self.main_widget.spectrum_widget.get_model_plot_data(0)
        self.model_widget.parameter_table.item(0, 1).setText('20')
        self.model_widget.parameter_table.item(1, 1).setText('3')
        self.model_widget.parameter_table.item(2, 1).setText('19')
        after_x, after_y = self.main_widget.spectrum_widget.get_model_plot_data(0)
        self.array_almost_equal(start_x, after_x)
        self.array_not_almost_equal(start_y, after_y)

        # then she sees the "Define" and wonders, if this also makes it possible to visually define the model, like
        # she did before with the Background

        QTest.mouseClick(self.main_widget.model_define_btn, QtCore.Qt.LeftButton)
        self.main_widget.spectrum_widget._spectrum_plot_emit_mouse_click_event(1, 10)
        self.main_widget.spectrum_widget._spectrum_plot_emit_mouse_click_event(1.3, 4.5)

        after_define_x, after_define_y = self.main_widget.spectrum_widget.get_model_plot_data(0)
        self.array_not_almost_equal(after_define_y, after_y)


        # She decides to add some other peaks for fitting all the peaks she sees:
        self.add_peak(0, (3, 5), (3.3, 9.5))
        self.add_peak(0, (6, 2), (6.2, 14.6))
        self.add_peak(0, (7.5, 3), (7.8, 8))
        self.add_peak(0, (9, 8), (9.4, 11))

        self.assertEqual(self.main_widget.model_list.count(), 5)
        self.assertEqual(self.main_widget.spectrum_widget.get_number_of_model_plots(), 5)

        # she sees that there is a copy button and wonders if this will just take of the hassle to always use the
        # model selector
        QTest.mouseClick(self.main_widget.model_copy_btn, QtCore.Qt.LeftButton)

        self.assertEqual(self.main_widget.model_list.count(), 6)
        self.assertEqual(self.main_widget.spectrum_widget.get_number_of_model_plots(), 6)

        # then she sees that the last peak is doubled now and should be removed from the list

        QTest.mouseClick(self.main_widget.model_delete_btn, QtCore.Qt.LeftButton)
        self.assertEqual(self.main_widget.model_list.count(), 5)
        self.assertEqual(self.main_widget.spectrum_widget.get_number_of_model_plots(), 5)

        # now she is satisfied with the initial model and wants to fit the peaks:
        before_x, before_y = self.main_widget.spectrum_widget.get_model_plot_data(0)
        QTest.mouseClick(self.main_widget.fit_btn, QtCore.Qt.LeftButton)

        after_x, after_y = self.main_widget.spectrum_widget.get_model_plot_data(0)
        self.array_not_almost_equal(before_y, after_y)

        # and she sees that the lower graph now also shows the residual
        residual_x, residual_y = self.main_widget.spectrum_widget.get_residual_plot_data()
        self.array_almost_equal(after_x, residual_x)
        self.assertNotEqual(np.sum(residual_y), 0)

        # self.fail("Finish the Test!")
Example #14
0
]
FILE_NAME = 'log_test.log'


def create_log_test(threadName, delay):
    # with 1s by refresh
    # with a threshold set to 200 => alert between 10s to 20s
    list_nb_to_send = [20] * 20 + [0] * 60
    # creation of the file
    fichier = open(FILE_NAME, "w")
    fichier.close()
    for nb_to_send in list_nb_to_send:
        request_to_send = list_request[rd.randint(0, len(list_request) - 1)]

        with open(FILE_NAME, 'a') as f:
            for i in range(nb_to_send):
                time = datetime.utcnow().replace(
                    tzinfo=timezone.utc).strftime("%d/%b/%Y:%H:%M:%S %z")
                to_send = request_to_send.format(time)
                f.write(to_send + '\n')

        sleep(delay)


if __name__ == '__main__':
    _thread.start_new_thread(create_log_test, ("Thread-1", 1))
    application = MainController({
        'file_path': 'log_test.log',
        'threshold': 200
    })
Example #15
0
from multiprocessing import freeze_support

# launch script, do not try to import this
# (if you import it, it will do nothing - import the classes instead)
if __name__ == '__main__':
    freeze_support()
    from controller.MainController import MainController
    from tkinter import Tk

    window = Tk()

    mc = MainController(window)
    mc.start()
def controller(queue_wr,queue_rd):
    controller = MainController(queue_wr,queue_rd)
    controller.run()
Example #17
0
from controller.MainController import MainController

MainController()
Example #18
0
    sections = [separator, time_string, separator, errmsg, separator, tb_info]
    msg = '\n'.join(sections)
    try:
        f = open(log_file, "w")
        f.write(msg)
        f.write(version_info)
        f.close()
    except IOError:
        pass
    errorbox = ErrorMessageBox()
    errorbox.setText(str(notice) + str(msg) + str(version_info))
    errorbox.exec_()

sys.excepthook = excepthook


if __name__ == "__main__":

    from sys import platform as _platform
    from controller.MainController import MainController, get_version
    dioptas_version = get_version()
    print("Dioptas {}".format(dioptas_version))

    if _platform == "linux" or _platform == "linux2" or _platform == "win32" or _platform == 'cygwin':
        app.setStyle('plastique')

    controller = MainController()
    controller.show_window()
    app.exec_()
    del app
Example #19
0
class Example(QtGui.QWidget):
    def __init__(self):
        super(Example, self).__init__()

        self.mainController = MainController()

        self.pw = pg.PlotWidget(name='Plot1')
        self.modelTimeEdit = QtGui.QLineEdit()
        self.modelTimeEdit.setText(str(SolveModel.MODELING_TIME))
        self.stepIntegrationEdit = QtGui.QLineEdit()
        self.stepIntegrationEdit.setValidator(QtGui.QDoubleValidator(0.01, 1000.0, 3))
        self.stepIntegrationEdit.setText(str(SolveModel.STEP))
        self.valueManegeEdit = QtGui.QLineEdit()
        self.valueManegeEdit.setText(str(SolveModel.MANAGE_VALUE))
        self.manageTimeEdit = QtGui.QLineEdit()
        self.manageTimeEdit.setText(str(SolveModel.MANAGE_TIME))
        self.initUI()

    def initUI(self):
        self.resize(1000, 700)
        self.center()

        manageTime = QtGui.QLabel(u'Длительность управляющего воздействия, с')
        valueManege = QtGui.QLabel(u'Величина управляющего воздействия')
        stepIntegration = QtGui.QLabel(u'Шаг интегрирования')
        modelTime = QtGui.QLabel(u'Длительность моделирования')

        grid = QtGui.QGridLayout()
        grid.setSpacing(10)

        grid.addWidget(manageTime, 1, 0)
        grid.addWidget(self.manageTimeEdit, 2, 0)
        grid.addWidget(valueManege, 3, 0)
        grid.addWidget(self.valueManegeEdit, 4, 0)
        grid.addWidget(stepIntegration, 5, 0)
        grid.addWidget(self.stepIntegrationEdit, 6, 0)
        grid.addWidget(modelTime, 7, 0)
        grid.addWidget(self.modelTimeEdit, 8, 0)

        grid.addWidget(self.pw, 1, 1, 10, 1)

        datax = [1, 2, 3, 4, 5, 6]
        datay = [1, 4, 7, 2, 3, 3]

        confirmParametresBtn = QtGui.QPushButton(u'Применить параметры', self)
        solveBtn = QtGui.QPushButton(u'Решить')
        saveBtn = QtGui.QPushButton(u'Сохранить')
        clearBtn = QtGui.QPushButton(u'Очистить')

        confirmParametresBtn.clicked.connect(self.confirmParametrBtnClicked)
        solveBtn.clicked.connect(self.solveBtnClicked)
        saveBtn.clicked.connect(self.saveBtnClicked)
        clearBtn.clicked.connect(self.clearBtnClicked)

        grid.addWidget(confirmParametresBtn, 11, 0)
        grid.addWidget(solveBtn, 12, 0)
        grid.addWidget(saveBtn, 13, 0)
        grid.addWidget(clearBtn, 14, 0)

        self.setLayout(grid)

        self.setWindowTitle('LA Model')
        self.show()

    def confirmParametrBtnClicked(self):
        SolveModel.STEP = float(self.stepIntegrationEdit.text())
        if SolveModel.STEP == 0:
            SolveModel.STEP = 0.01
            self.stepIntegrationEdit.setText("0.01")
        SolveModel.MANAGE_TIME = float(self.manageTimeEdit.text())
        SolveModel.MANAGE_VALUE = float(self.valueManegeEdit.text())
        SolveModel.MODELING_TIME = float(self.modelTimeEdit.text())

    def solveBtnClicked(self):
        countTimes = int(SolveModel.MODELING_TIME / SolveModel.STEP)
        result = [None] * countTimes
        times = [None] * countTimes
        manage = [None] * countTimes
        solve = Solver(result, times, manage)
        datax, datay = solve.run()

        p1 = self.pw.plot(x=datax, y=datay, pen=(210, 2, 15))

    def saveBtnClicked(self):
        self.mainController.saveMetaData()

    def clearBtnClicked(self):
        self.pw.plotItem.clear()

    def center(self):

        qr = self.frameGeometry()
        cp = QtGui.QDesktopWidget().availableGeometry().center()
        qr.moveCenter(cp)
        self.move(qr.topLeft())

    def closeEvent(self, QCloseEvent):
        reply = QtGui.QMessageBox.question(self, 'Message', 'Are you sure to quit?',
                                           QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No)
        if reply == QtGui.QMessageBox.Yes:
            QCloseEvent.accept()
        else:
            QCloseEvent.ignore()