Exemplo n.º 1
0
class ExampleDialog(ImageDialog):
    def __init__(
        self,
        wintitle=_("Example dialog box"),
        icon="guidata.svg",
        options=dict(show_contrast=True),
        edit=False,
    ):
        self.filter_gbox = None
        self.data = None
        self.item = None
        super(ExampleDialog, self).__init__(
            wintitle=wintitle, icon=icon, toolbar=True, edit=edit, options=options
        )
        self.resize(600, 600)

    def register_tools(self):
        opentool = self.add_tool(OpenImageTool)
        opentool.SIG_OPEN_FILE.connect(self.open_image)
        self.register_all_image_tools()
        self.activate_default_tool()

    def create_plot(self, options):
        self.filter_gbox = DataSetEditGroupBox(_("Filter parameters"), FilterParam)
        self.filter_gbox.setEnabled(False)
        self.filter_gbox.SIG_APPLY_BUTTON_CLICKED.connect(self.apply_filter)
        self.plot_layout.addWidget(self.filter_gbox, 0, 0)
        self.param_gbox = DataSetShowGroupBox(_("Image parameters"), ImageParam)
        self.plot_layout.addWidget(self.param_gbox, 0, 1)

        options = dict(title=_("Image title"), zlabel=_("z-axis scale label"))
        ImageDialog.create_plot(self, options, 1, 0, 1, 0)

    def open_image(self, filename):
        """Opening image *filename*"""
        self.data = io.imread(filename, to_grayscale=True)
        self.show_data(self.data)
        param = ImageParam()
        param.title = filename
        param.height, param.width = self.data.shape
        update_dataset(self.param_gbox.dataset, param)
        self.param_gbox.get()
        self.filter_gbox.setEnabled(True)

    def show_data(self, data):
        plot = self.get_plot()
        if self.item is not None:
            self.item.set_data(data)
        else:
            self.item = make.image(data, colormap="gray")
            plot.add_item(self.item, z=0)
        plot.set_active_item(self.item)
        plot.replot()

    def apply_filter(self):
        param = self.filter_gbox.dataset
        filterfunc = getattr(scipy.ndimage, param.name)
        data = filterfunc(self.data, param.size)
        self.show_data(data)
Exemplo n.º 2
0
class ExampleDialog(ImageDialog):
    def __init__(self, wintitle=_("Example dialog box"),
                 icon="guidata.svg", options=dict(show_contrast=True),
                 edit=False):
        self.filter_gbox = None
        self.data = None
        self.item = None
        super(ExampleDialog, self).__init__(wintitle=wintitle, icon=icon,
                                            toolbar=True, edit=edit,
                                            options=options)        
        self.resize(600, 600)
        
    def register_tools(self):
        opentool = self.add_tool(OpenImageTool)
        self.connect(opentool, SIGNAL("openfile(QString*)"), self.open_image)
        self.register_all_image_tools()
        self.activate_default_tool()

    def create_plot(self, options):
        self.filter_gbox = DataSetEditGroupBox(_("Filter parameters"),
                                               FilterParam)
        self.filter_gbox.setEnabled(False)
        self.connect(self.filter_gbox, SIGNAL("apply_button_clicked()"),
                     self.apply_filter)
        self.plot_layout.addWidget(self.filter_gbox, 0, 0)
        self.param_gbox = DataSetShowGroupBox(_("Image parameters"), ImageParam)
        self.plot_layout.addWidget(self.param_gbox, 0, 1)
        
        options = dict(title=_("Image title"), zlabel=_("z-axis scale label"))
        ImageDialog.create_plot(self, options, 1, 0, 1, 0)
        
    def open_image(self, filename):
        """Opening image *filename*"""
        self.data = io.imread(filename, to_grayscale=True)
        self.show_data(self.data)
        param = ImageParam()
        param.title = filename
        param.height, param.width = self.data.shape
        update_dataset(self.param_gbox.dataset, param)
        self.param_gbox.get()
        self.filter_gbox.setEnabled(True)
        
    def show_data(self, data):
        plot = self.get_plot()
        if self.item is not None:
            self.item.set_data(data)
        else:
            self.item = make.image(data, colormap="gray")
            plot.add_item(self.item, z=0)
        plot.set_active_item(self.item)
        plot.replot()
        
    def apply_filter(self):
        param = self.filter_gbox.dataset
        filterfunc = getattr(scipy.ndimage, param.name)
        data = filterfunc(self.data, param.size)
        self.show_data(data)
Exemplo n.º 3
0
    def create_plot(self, options):
        self.filter_gbox = DataSetEditGroupBox(_("Filter parameters"), FilterParam)
        self.filter_gbox.setEnabled(False)
        self.filter_gbox.SIG_APPLY_BUTTON_CLICKED.connect(self.apply_filter)
        self.plot_layout.addWidget(self.filter_gbox, 0, 0)
        self.param_gbox = DataSetShowGroupBox(_("Image parameters"), ImageParam)
        self.plot_layout.addWidget(self.param_gbox, 0, 1)

        options = dict(title=_("Image title"), zlabel=_("z-axis scale label"))
        ImageDialog.create_plot(self, options, 1, 0, 1, 0)
Exemplo n.º 4
0
    def __init__(self):
        QMainWindow.__init__(self)
        self.setWindowIcon(get_icon("python.png"))
        self.setWindowTitle("Application example")

        # Instantiate dataset-related widgets:
        self.groupbox1 = DataSetShowGroupBox("Activable dataset",
                                             ExampleDataSet,
                                             comment="")
        self.groupbox2 = DataSetShowGroupBox("Standard dataset",
                                             AnotherDataSet,
                                             comment="")
        self.groupbox3 = DataSetEditGroupBox("Standard dataset",
                                             OtherDataSet,
                                             comment="")
        self.groupbox4 = DataSetEditGroupBox("Standard dataset",
                                             ExampleMultiGroupDataSet,
                                             comment="")
        self.groupbox3.SIG_APPLY_BUTTON_CLICKED.connect(self.update_window)
        self.update_groupboxes()

        splitter = QSplitter(self)
        splitter.addWidget(self.groupbox1)
        splitter.addWidget(self.groupbox2)
        splitter.addWidget(self.groupbox3)
        splitter.addWidget(self.groupbox4)
        self.setCentralWidget(splitter)
        self.setContentsMargins(10, 5, 10, 5)

        # File menu
        file_menu = self.menuBar().addMenu("File")
        quit_action = create_action(
            self,
            "Quit",
            shortcut="Ctrl+Q",
            icon=get_std_icon("DialogCloseButton"),
            tip="Quit application",
            triggered=self.close,
        )
        add_actions(file_menu, (quit_action, ))

        # Edit menu
        edit_menu = self.menuBar().addMenu("Edit")
        editparam1_action = create_action(self,
                                          "Edit dataset 1",
                                          triggered=self.edit_dataset1)
        editparam2_action = create_action(self,
                                          "Edit dataset 2",
                                          triggered=self.edit_dataset2)
        editparam4_action = create_action(self,
                                          "Edit dataset 4",
                                          triggered=self.edit_dataset4)
        add_actions(edit_menu,
                    (editparam1_action, editparam2_action, editparam4_action))
Exemplo n.º 5
0
	def __init__(self,controlValues=None,*args,**kwargs):
		DataSetShowGroupBox.__init__(self,_("Housekeeping"),self.HKset)

		self.controlValues=controlValues
		self.measurements=None

		self.dbr=dbr()
		self.sensors=sensors()
		self.chopper=chopper()
		self.dbr.init()
		self.sensors.init()
		self.chopper.init()
Exemplo n.º 6
0
 def __init__(self):
     QMainWindow.__init__(self)
     self.setWindowIcon(get_icon('python.png'))
     self.setWindowTitle("Application example")
     
     # Instantiate dataset-related widgets:
     self.groupbox1 = DataSetShowGroupBox("Activable dataset",
                                          ExampleDataSet, comment='')
     self.groupbox2 = DataSetShowGroupBox("Standard dataset",
                                          AnotherDataSet, comment='')
     self.groupbox3 = DataSetEditGroupBox("Standard dataset",
                                          OtherDataSet, comment='')
     self.groupbox4 = DataSetEditGroupBox("Standard dataset",
                                          ExampleMultiGroupDataSet, comment='')
     self.connect(self.groupbox3, SIGNAL("apply_button_clicked()"),
                  self.update_window)
     self.update_groupboxes()
     
     splitter = QSplitter(self)
     splitter.addWidget(self.groupbox1)
     splitter.addWidget(self.groupbox2)
     splitter.addWidget(self.groupbox3)
     splitter.addWidget(self.groupbox4)
     self.setCentralWidget(splitter)
     self.setContentsMargins(10, 5, 10, 5)
     
     # File menu
     file_menu = self.menuBar().addMenu("File")
     quit_action = create_action(self, "Quit",
                                 shortcut="Ctrl+Q",
                                 icon=get_std_icon("DialogCloseButton"),
                                 tip="Quit application",
                                 triggered=self.close)
     add_actions(file_menu, (quit_action, ))
     
     # Edit menu
     edit_menu = self.menuBar().addMenu("Edit")
     editparam1_action = create_action(self, "Edit dataset 1",
                                       triggered=self.edit_dataset1)
     editparam2_action = create_action(self, "Edit dataset 2",
                                       triggered=self.edit_dataset2)
     editparam4_action = create_action(self, "Edit dataset 4",
                                       triggered=self.edit_dataset4)
     add_actions(edit_menu, (editparam1_action,
                             editparam2_action,
                             editparam4_action))
Exemplo n.º 7
0
 def __init__(self, parent):
     QSplitter.__init__(self, parent)
     self.parent = parent
     self.Controlvalues = DataSetEditGroupBox(_("Control panel"),
                                              Controlwidget,
                                              show_button=False)
     self.addWidget(self.Controlvalues)
     self.HKvalues = DataSetShowGroupBox(_("Housekeeping"), HKwidget)
     self.addWidget(self.HKvalues)
     self.setSizes([2000, 1])
Exemplo n.º 8
0
 def create_plot(self, options):
     self.filter_gbox = DataSetEditGroupBox(_("Filter parameters"),
                                            FilterParam)
     self.filter_gbox.setEnabled(False)
     self.filter_gbox.SIG_APPLY_BUTTON_CLICKED.connect(self.apply_filter)
     self.plot_layout.addWidget(self.filter_gbox, 0, 0)
     self.param_gbox = DataSetShowGroupBox(_("Image parameters"), ImageParam)
     self.plot_layout.addWidget(self.param_gbox, 0, 1)
     
     options = dict(title=_("Image title"), zlabel=_("z-axis scale label"))
     ImageDialog.create_plot(self, options, 1, 0, 1, 0)
Exemplo n.º 9
0
    def _load_settings(self):
        self.appsettings = DataSetShowGroupBox("Settings",
                                             AppSettings, comment='',
                                             title=_("Application settings"))

        self.settings_storage = QSettings('settings.ini', QSettings.IniFormat)

        self.restoreGeometry( self.settings_storage.value('docksGeometry').toByteArray() )
        self.restoreState( self.settings_storage.value('docksState').toByteArray() )

        # load settings:
        self.settings_storage.beginGroup('BioHarnessPackets')
        rrdata = self.settings_storage.value('rrdata', True).toBool()
        breathing = self.settings_storage.value('breathing', True).toBool()
        ecg = self.settings_storage.value('ecg', False).toBool()
        summary = self.settings_storage.value('summary', False).toBool()
        accelerometer = self.settings_storage.value('accelerometer', False).toBool()
        self.settings_storage.endGroup()
        self.appsettings.dataset.bh_packets = []
        if rrdata: self.appsettings.dataset.bh_packets.append(0)
        if breathing: self.appsettings.dataset.bh_packets.append(1)
        if ecg: self.appsettings.dataset.bh_packets.append(2)
        if summary: self.appsettings.dataset.bh_packets.append(3)
        if accelerometer: self.appsettings.dataset.bh_packets.append(4)

        self.settings_storage.beginGroup('Misc')
        self.appsettings.dataset.timedsession = self.settings_storage.value('TimedDuration', 5).toInt()[0]
        # handle windows and linux serial port name
        portname = self.settings_storage.value('Serial_Port').toString()
        if str(portname).isdigit() is True:
            self.appsettings.dataset.serialport = int(portname)
        else:
             self.appsettings.dataset.serialport = str(portname)
        self.appsettings.dataset.use_virtual_serial = self.settings_storage.value('Use_Virtual_Serial_Port', False).toBool()
        self.settings_storage.endGroup()

        self.settings_storage.beginGroup('Storage')
        self.appsettings.dataset.enable_database = self.settings_storage.value('db_enable', False).toBool()
        self.appsettings.dataset.db_url = self.settings_storage.value('db_url').toString()
        self.appsettings.dataset.db_port = self.settings_storage.value('db_port').toString()
        self.appsettings.dataset.db_user = self.settings_storage.value('db_user').toString()
        self.appsettings.dataset.db_pwd = self.settings_storage.value('db_pwd').toString()
        self.appsettings.dataset.db_dbname = self.settings_storage.value('db_dbname').toString()
        self.appsettings.dataset.enable_files = self.settings_storage.value('files_enable', False).toBool()
        self.appsettings.dataset.directory_storage = self.settings_storage.value('directory').toString()
        self.settings_storage.endGroup()
Exemplo n.º 10
0
 def __init__(self, *args, **kwargs):
     DataSetShowGroupBox.__init__(self, _("Housekeeping"), self.HKset)
Exemplo n.º 11
0
class MainWindow(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)
        self.setWindowIcon(get_icon('python.png'))
        self.setWindowTitle("Application example")
        
        # Instantiate dataset-related widgets:
        self.groupbox1 = DataSetShowGroupBox("Activable dataset",
                                             ExampleDataSet, comment='')
        self.groupbox2 = DataSetShowGroupBox("Standard dataset",
                                             AnotherDataSet, comment='')
        self.groupbox3 = DataSetEditGroupBox("Standard dataset",
                                             OtherDataSet, comment='')
        self.groupbox4 = DataSetEditGroupBox("Standard dataset",
                                             ExampleMultiGroupDataSet, comment='')
        self.groupbox3.SIG_APPLY_BUTTON_CLICKED.connect(self.update_window)
        self.update_groupboxes()
        
        splitter = QSplitter(self)
        splitter.addWidget(self.groupbox1)
        splitter.addWidget(self.groupbox2)
        splitter.addWidget(self.groupbox3)
        splitter.addWidget(self.groupbox4)
        self.setCentralWidget(splitter)
        self.setContentsMargins(10, 5, 10, 5)
        
        # File menu
        file_menu = self.menuBar().addMenu("File")
        quit_action = create_action(self, "Quit",
                                    shortcut="Ctrl+Q",
                                    icon=get_std_icon("DialogCloseButton"),
                                    tip="Quit application",
                                    triggered=self.close)
        add_actions(file_menu, (quit_action, ))
        
        # Edit menu
        edit_menu = self.menuBar().addMenu("Edit")
        editparam1_action = create_action(self, "Edit dataset 1",
                                          triggered=self.edit_dataset1)
        editparam2_action = create_action(self, "Edit dataset 2",
                                          triggered=self.edit_dataset2)
        editparam4_action = create_action(self, "Edit dataset 4",
                                          triggered=self.edit_dataset4)
        add_actions(edit_menu, (editparam1_action,
                                editparam2_action,
                                editparam4_action))
        
    def update_window(self):
        dataset = self.groupbox3.dataset
        self.setWindowTitle(dataset.title)
        self.setWindowIcon(get_icon(dataset.icon))
        self.setWindowOpacity(dataset.opacity)
        
    def update_groupboxes(self):
        self.groupbox1.dataset.set_readonly() # This is an activable dataset
        self.groupbox1.get()
        self.groupbox2.get()
        self.groupbox4.get()
        
    def edit_dataset1(self):
        self.groupbox1.dataset.set_writeable() # This is an activable dataset
        if self.groupbox1.dataset.edit():
            self.update_groupboxes()
    
    def edit_dataset2(self):
        if self.groupbox2.dataset.edit():
            self.update_groupboxes()

    def edit_dataset4(self):
        if self.groupbox4.dataset.edit():
            self.update_groupboxes()
Exemplo n.º 12
0
 def __init__(self, parent):
     QSplitter.__init__(self, parent)
     self.datas = DataSetShowGroupBox(_("Current"), InfoData)
     self.addWidget(self.datas)
Exemplo n.º 13
0
    def __init__(self):
        QMainWindow.__init__(self)
        self.setWindowIcon(get_icon('python.png'))
        self.setWindowTitle("Electric motor simulator")

        # Dataset for editing motor parameters
        self.groupbox1 = DataSetShowGroupBox("Motor parameters",
                                             ExampleDataSet,
                                             comment='')
        self.groupbox2 = DataSetShowGroupBox("Controller parameters",
                                             AnotherDataSet,
                                             comment='')
        self.groupbox3 = DataSetEditGroupBox("Standard dataset",
                                             OtherDataSet,
                                             comment='')
        self.groupbox4 = DataSetEditGroupBox("Standard dataset",
                                             ExampleMultiGroupDataSet,
                                             comment='')
        #self.groupbox3.SIG_APPLY_BUTTON_CLICKED.connect(self.update_window)
        self.update_groupboxes()

        splitter = QSplitter(self)
        splitter.addWidget(self.groupbox1)
        splitter.addWidget(self.groupbox2)
        #splitter.addWidget(self.groupbox3)
        #splitter.addWidget(self.groupbox4)
        self.setCentralWidget(splitter)
        self.setContentsMargins(10, 5, 10, 5)

        # File menu
        file_menu = self.menuBar().addMenu("File")
        quit_action = create_action(self,
                                    "Quit",
                                    shortcut="Ctrl+Q",
                                    icon=get_std_icon("DialogCloseButton"),
                                    tip="Quit application",
                                    triggered=self.close)
        add_actions(file_menu, (quit_action, ))

        # Edit menu
        edit_menu = self.menuBar().addMenu("Edit")
        editparam1_action = create_action(self,
                                          "Edit dataset 1",
                                          triggered=self.edit_dataset1)
        editparam2_action = create_action(self,
                                          "Edit dataset 2",
                                          triggered=self.edit_dataset2)
        editparam4_action = create_action(self,
                                          "Edit dataset 4",
                                          triggered=self.edit_dataset4)
        add_actions(edit_menu,
                    (editparam1_action, editparam2_action, editparam4_action))

        # Toolbar
        tb = self.addToolBar("Tools")
        reset = QAction("Reset", self)
        tb.addAction(reset)
        pause = QAction("Pause", self)
        tb.addAction(pause)
        step = QAction("Step", self)
        tb.addAction(step)
        go = QAction("Go", self)
        tb.addAction(go)
Exemplo n.º 14
0
	def show_groupbox(self):
		show = DataSetShowGroupBox("Standard dataset", self.groupbox.dataset)
		return show