예제 #1
0
 def __init__(self, parent):
     QSplitter.__init__(self, parent)
     self.imagelist = QListWidget(self)
     self.addWidget(self.imagelist)
     self.properties = DataSetEditGroupBox(_("Properties"), ImageParam)
     self.properties.setEnabled(False)
     self.addWidget(self.properties)
예제 #2
0
    def __init__(self, parent):
        QSplitter.__init__(self, parent)
        # List Widget
        self.csvlist = QListWidget(self)
        self.csvlist.setContextMenuPolicy(Qt.ActionsContextMenu)

        plotCSV = QAction(self)
        plotCSV.setText("Plot")
        plotCSV.triggered.connect(self.plotCSV)
        delete = QAction(self)
        delete.setText("Remove")
        delete.triggered.connect(self.removeItem)
        extractCSV = QAction(self)
        extractCSV.setText("Extract to Arrays")
        extractCSV.triggered.connect(self.extractArray)
        self.csvlist.addAction(plotCSV)
        self.csvlist.addAction(extractCSV)
        self.csvlist.addAction(delete)

        self.addWidget(self.csvlist)

        # Properties widget
        self.properties = DataSetEditGroupBox(_("參數(Properties)"), CsvParam)
        self.properties.setEnabled(False)
        self.addWidget(self.properties)
예제 #3
0
 def _connect_project_properties(self):
     self.projectproperties = DataSetEditGroupBox(
         "Project Data",
         ProjectPropertiesDataset,
         comment="Parameters common to all assets")
     self.projectproperties.SIG_APPLY_BUTTON_CLICKED.connect(
         self._apply_dataset_values)
예제 #4
0
    def __init__(self, dataset, title = '', settings = None, settingskey = None, parent = None):
        super(ParamWidget, self).__init__(parent = parent)
        
        self.settings = settings
        self.settingskey = settingskey
        
        self.mainLayout = QVBoxLayout()
        self.setLayout(self.mainLayout)
        
        
        if self.settings is not None and self.settingskey is not None:
            stored_list = self.settings.getValueOrDefault('storedParameters/'+self.settingskey, [ ])

            h = QHBoxLayout()
            self.mainLayout.addLayout(h)
            h.addStretch(1)
            self.comboParam = QComboBox()
            h.addWidget(self.comboParam, 3)
            
            self.refreshCombo()
            self.comboParam.currentIndexChanged.connect(self.comboParamChanged)

            buttonSave = QPushButton(QIcon(':/list-add.png') ,'')
            buttonSave.setMaximumSize(25,25)
            h.addWidget(buttonSave)
            buttonSave.clicked.connect(self.saveNewParam)
            buttonDel = QPushButton(QIcon(':/list-remove.png') ,'')
            buttonDel.setMaximumSize(25,25)
            h.addWidget(buttonDel)
            buttonDel.clicked.connect(self.delSavedParam)
        
        self.params = DataSetEditGroupBox(title,dataset, show_button = False)
        self.mainLayout.addWidget( self.params )
        
        self.default_dict = self.to_dict()
예제 #5
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)
예제 #6
0
class ImageListWithProperties(QSplitter):
    def __init__(self, parent):
        QSplitter.__init__(self, parent)
        self.imagelist = QListWidget(self)
        self.addWidget(self.imagelist)
        self.properties = DataSetEditGroupBox(_("Properties"), ImageParam)
        self.properties.setEnabled(False)
        self.addWidget(self.properties)
예제 #7
0
class DAQParamsProperties(QSplitter):
    def __init__(self, parent):
        QSplitter.__init__(self, parent)
        # self.lineList = QListWidget(self)
        # self.addWidget(self.lineList)
        self.properties = DataSetEditGroupBox(_("Properties"), DAQParam)
        self.properties.setEnabled(True)
        self.addWidget(self.properties)
예제 #8
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)
예제 #9
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)
예제 #10
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))
예제 #11
0
class LoggerDialog(QDialog):
    def __init__(self):
        QDialog.__init__(self)
        self.setWindowTitle("Data Logger")
        self.groupbox1 = DataSetEditGroupBox("Parametres de lock",Loggerdataset,show_button = False)   
        self.groupbox1.dataset.parent = self
        self.values = self.groupbox1.dataset
        self.groupbox1.dataset.parent = self
        lay = QVBoxLayout()
        lay.addWidget(self.groupbox1)
        self.setLayout(lay)
        self.resize(800,300)
        
        self.timer = QTimer()
        self.timer.timeout.connect(self.log)
        #self.timer.timeout.connect(self.update_values)
        self.timer.setInterval(100) #ms
        self.show()
    
    def transform_number(self):
        self.values.next = self.values.next*self.values.mult + self.values.add
        self.groupbox1.get()
    
    def log(self):
        self.groupbox1.set()
        if not vsa.on_screen.meas_done():
            return
        if vsa.on_screen.current_average()<self.values.next:
            vsa.on_screen.resume()
            return
        if self.values.save:
            self.manual()
        else:
            vsa.on_screen.resume()
        self.transform_number()
        #vsa.on_screen.set_average(self.values.next)
        

    def manual(self):
        vsa.on_screen.pause()
        try:
            df = load(self.values.filename)
        except IOError:
            df = matched_df()
        append_one_av(df)
        df.save(self.values.filename)
        vsa.on_screen.resume()
        
    
    def start(self):
        print "starting"
        vsa.on_screen.set_average(self.values.next)
        vsa.on_screen.restart()
        self.timer.start()
예제 #12
0
 def __init__(self, parent):
     QSplitter.__init__(self, parent)
     self.lineList = QListWidget(self)
     self.addWidget(self.lineList)
     self.properties = DataSetEditGroupBox(_("Properties"), SignalParam)
     self.properties.setEnabled(False)
     self.addWidget(self.properties)
예제 #13
0
    def _generateGroupBox(self):
        '''
        Generate if necessary the group box for this
        :return:
        '''
        if self._groupbox is None:
            # from  widgets create the view containing the datasets
            _dataSetView = self._generateGuidataDataset()
            if len(_dataSetView._items) > 0:
                if self._viewtype == 'Tabs':
                    self._groupbox = DataSetEditGroupBox(self.viewname, _dataSetView, comment='')
                else:
                    self._groupbox = DataSetEditGroupBox(self.viewname, _dataSetView, comment='')
                self._groupbox.SIG_APPLY_BUTTON_CLICKED.connect(self._updatedView)

        return self._groupbox
예제 #14
0
    def __init__(self, dataset, title = '', settings = None, settingskey = None, parent = None):
        super(ParamWidget, self).__init__(parent = parent)
        
        self.settings = settings
        self.settingskey = settingskey
        
        self.mainLayout = QVBoxLayout()
        self.setLayout(self.mainLayout)
        
        
        if self.settings is not None and self.settingskey is not None:
            stored_list = self.settings.getValueOrDefault('storedParameters/'+self.settingskey, [ ])

            h = QHBoxLayout()
            self.mainLayout.addLayout(h)
            h.addStretch(1)
            self.comboParam = QComboBox()
            h.addWidget(self.comboParam, 3)
            
            self.refreshCombo()
            self.comboParam.currentIndexChanged.connect(self.comboParamChanged)

            buttonSave = QPushButton(QIcon(':/list-add.png') ,'')
            buttonSave.setMaximumSize(25,25)
            h.addWidget(buttonSave)
            buttonSave.clicked.connect(self.saveNewParam)
            buttonDel = QPushButton(QIcon(':/list-remove.png') ,'')
            buttonDel.setMaximumSize(25,25)
            h.addWidget(buttonDel)
            buttonDel.clicked.connect(self.delSavedParam)
        
        self.params = DataSetEditGroupBox(title,dataset, show_button = False)
        self.mainLayout.addWidget( self.params )
        
        self.default_dict = self.to_dict()
예제 #15
0
파일: gui.py 프로젝트: KGerring/lintful
	def __init__(self):
		QMainWindow.__init__(self)
		self.setWindowTitle("Application example")
		self.groupbox = DataSetEditGroupBox("Standard dataset", OtherDataSet, comment='')
		#self.dialog = guidata.dataset.qtwidgets.DataSetEditDialog(self.groupbox)
		splitter = QSplitter(self)
		splitter.addWidget(self.groupbox)
예제 #16
0
    def __init__(self):
        # init main panel
        QMainWindow.__init__(self, None)
#        QMainWindow.__init__(self, None, QtCore.Qt.WindowStaysOnTopHint)
        Thread.__init__(self)
        widget = QWidget()
        self.setCentralWidget(widget)
        self.setWindowTitle('3D tracking')
        self.move(600, 150)
        # define main objects
        self.tracking = tracking_3d.Tracking3D.getInstance()
        
        # init dataset from gui_construction
        self.gb_sequence = DataSetEditGroupBox("Sequence", 
                    gui_construction.RemoteParameters, comment='')
        self.gb_sample = DataSetEditGroupBox("Sample", 
                    gui_construction.SampleParameters, comment='')
        self.gb_tracking = DataSetEditGroupBox("Tracking", 
                    gui_construction.TrackingParameters, comment='')
            
        self.btn_process = QPushButton("Start tracking", self)
        self.btn_process.clicked.connect(self.start_tracking)

        # associate events to dataset apply buttons
        self.connect(self.gb_sequence, SIGNAL("apply_button_clicked()"), 
                     self.update_remote_params)
        self.connect(self.gb_tracking, SIGNAL("apply_button_clicked()"), 
                     self.update_tracking_params)     
        self.connect(self.gb_sample, SIGNAL("apply_button_clicked()"), 
                     self.update_sample_parameters)
                     
        # organize the app panels
        splitter1 = QSplitter(QtCore.Qt.Vertical)
        splitter1.addWidget(self.gb_sequence)
        splitter1.addWidget(self.gb_sample)
        splitter1.addWidget(self.gb_tracking)
        splitter1.addWidget(self.btn_process)
        
        splitter = QSplitter(self)
        splitter.addWidget(splitter1)
        self.setCentralWidget(splitter)
        self.setContentsMargins(10, 5, 10, 5)   
        
        # get all params from datasets
        self.gb_sequence.get()
        self.gb_sample.get()
        self.gb_tracking.get()
예제 #17
0
    def __init__(self, parent):
        QSplitter.__init__(self, parent)
        # List Widget
        self.arraylist = QListWidget(self)
        self.arraylist.setContextMenuPolicy(Qt.ActionsContextMenu)

        newArray = QAction(self)
        newArray.setText("Paste Array (no header name)")
        newArray.triggered.connect(self.pasteArray)
        newArrayWithName = QAction(self)
        newArrayWithName.setText("Paste Array (with header name)")
        newArrayWithName.triggered.connect(self.pasteArrayWithName)
        plotArray = QAction(self)
        plotArray.setText("Plot Array")
        plotArray.triggered.connect(self.plotArray)
        modifyArray = QAction(self)
        modifyArray.setText("Modify Array(Calibration)")
        modifyArray.triggered.connect(self.modifyArray)
        plotScatter = QAction(self)
        plotScatter.setText("Plot Scatter")
        plotScatter.triggered.connect(self.plotScatter)
        plotHist = QAction(self)
        plotHist.setText("Plot Histogram")
        plotHist.triggered.connect(self.plotHist)
        delete = QAction(self)
        delete.setText("Remove")
        delete.triggered.connect(self.removeItem)
        curveDialog = QAction(self)
        curveDialog.setText("Open Curve Dialog")
        curveDialog.triggered.connect(self.openCurveDialog)
        self.arraylist.addAction(newArray)
        self.arraylist.addAction(newArrayWithName)
        self.arraylist.addAction(plotArray)
        self.arraylist.addAction(plotScatter)
        self.arraylist.addAction(plotHist)
        self.arraylist.addAction(modifyArray)
        self.arraylist.addAction(curveDialog)
        self.arraylist.addAction(delete)

        self.addWidget(self.arraylist)

        # Properties widget
        self.properties = DataSetEditGroupBox(_("參數(Properties)"), CsvParam)
        self.properties.setEnabled(False)
        self.addWidget(self.properties)
예제 #18
0
파일: _gui_tmp.py 프로젝트: BD75/mpsrad
 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])
예제 #19
0
    def __init__(self, parent):
        plots=\
         [[
          {'name':'Source 1','curves':['in1']},
          {'name':'Source 2','curves':['in2']}],
         [
          {'name':'Result','curves':['out']},
         ]]

        self.tabs = parent.sp

        df = [n.axisLimits[1] - n.axisLimits[0] for n in self.tabs]
        df2 = max(df) / 2

        axisLimits = [
            -df2, df2,
            min([n.axisLimits[2] for n in self.tabs]),
            max([n.axisLimits[3] for n in self.tabs])
        ]

        PlotPanel.__init__(self,
                           parent=parent,
                           plots=plots,
                           axisLimits=axisLimits)

        self._cBox = DataSetEditGroupBox("Control",
                                         self.cSet,
                                         show_button=False)
        self.addWidget(self._cBox)

        tabchoices = [(m, n.name, None) for m, n in enumerate(self.tabs)]
        curvechoices = [(n, n, None) for n in self.tabs[0].curves.keys()]

        self.cSet._items[1].set_prop('data', choices=tabchoices)
        self._cBox.dataset.tab1 = 0
        self.cSet._items[2].set_prop('data', choices=curvechoices)
        self._cBox.dataset.data1 = curvechoices[0][0]
        self.cSet._items[5].set_prop('data', choices=tabchoices)
        self._cBox.dataset.tab2 = 0
        self.cSet._items[6].set_prop('data', choices=curvechoices)
        self._cBox.dataset.data2 = curvechoices[0][0]
        self._cBox.get()
예제 #20
0
파일: gui.py 프로젝트: KGerring/lintful
	def __init__(self):
		QMainWindow.__init__(self)
		self.setWindowTitle("Application example")
		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 = self.menuBar().addMenu("Edit")
		
		self.groupbox = DataSetEditGroupBox("Standard dataset", OtherDataSet, comment='')
		self.groupbox.SIG_APPLY_BUTTON_CLICKED.connect(self.update_window)
		self.display = DataSetEditGroupBox("Read-only dataset", OtherDataSet, comment='')
		
		splitter = QSplitter(self)
		splitter.addWidget(self.groupbox)
		self.setCentralWidget(splitter)
		self.setContentsMargins(10, 5, 10, 5)
예제 #21
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)
예제 #22
0
    def __init__(self, parent=None):
        QSplitter.__init__(self, parent)
        self.setOrientation(Qt.Vertical)
        self.optimization_input = DataSetEditGroupBox("Optimization",
                                                      OptimizationInput)
        self.addWidget(self.optimization_input)
        self.connect(self.optimization_input, SIGNAL("apply_button_clicked()"),
                     self.start_opt)

        plot.ioff()
        figure = plot.figure()
        self.addWidget(figure.canvas.manager.window)
예제 #23
0
    def __init__(self, parent=None):
        QSplitter.__init__(self, parent)
        self.setOrientation(Qt.Vertical)
        self.curve = None
        plot.ioff() # Must call plot.draw to update
        self.figure = plot.figure()
        self.plot = self.figure.gca()

        # Set "num_of_steps" as a trigger to update the plot
        NumericalInput.num_of_steps.set_prop("display", callback=self.plot_callback)
        self.numerical_input = DataSetEditGroupBox("Numerical", NumericalInput, show_button=False)
        self.addWidget(self.numerical_input)
        self.addWidget(self.figure.canvas.manager.window)
    def __init__(self):
        QMainWindow.__init__(self)
        self.setWindowIcon(get_icon('python.png'))
        self.setWindowTitle("P3 Ctrl")
        # Instantiate dataset-related widgets:
        self.group1 = DataSetEditGroupBox("Activable dataset",
                                          Processing,
                                          comment='')
        self.group1.SIG_APPLY_BUTTON_CLICKED.connect(self.group1._items[0].hi)
        splitter = QSplitter(self)
        splitter.addWidget(self.group1)

        self.setCentralWidget(splitter)
        self.setContentsMargins(10, 5, 10, 5)
예제 #25
0
    def __init__(self, io, params_read, params_write, parent):
        super(ParamDialog, self).__init__(parent)

        self.setWindowTitle('Options for %s' % (io.name or io.__name__))
        self.io = io

        self.setModal(True)
        self.mainLayout = QVBoxLayout()
        self.setLayout(self.mainLayout)

        buttons = QDialogButtonBox(QDialogButtonBox.Ok
                                   | QDialogButtonBox.Cancel)
        self.connect(buttons, SIGNAL("accepted()"), SLOT("accept()"))
        self.connect(buttons, SIGNAL("rejected()"), SLOT("reject()"))

        self.read_params_edit = None
        self.read_params = params_read
        if valid_params(io.read_params):
            params = self.neo_to_guidata(io.read_params.values()[0],
                                         self.read_params)
            self.read_params_edit = DataSetEditGroupBox("Read",
                                                        params,
                                                        show_button=False)
            self.mainLayout.addWidget(self.read_params_edit)

        self.write_params_edit = None
        self.write_params = params_write
        if valid_params(io.write_params):
            params = self.neo_to_guidata(io.write_params.values()[0],
                                         self.write_params)
            self.write_params_edit = DataSetEditGroupBox("Write",
                                                         params,
                                                         show_button=False)
            self.mainLayout.addWidget(self.write_params_edit)

        self.mainLayout.addWidget(buttons)
예제 #26
0
class ImageListWithProperties(QSplitter):
    # Define View的部分
    def __init__(self, parent):
        QSplitter.__init__(self, parent)
        # List Widget
        self.csvlist = QListWidget(self)
        self.csvlist.setContextMenuPolicy(Qt.ActionsContextMenu)

        plotCSV = QAction(self)
        plotCSV.setText("Plot")
        plotCSV.triggered.connect(self.plotCSV)
        delete = QAction(self)
        delete.setText("Remove")
        delete.triggered.connect(self.removeItem)
        extractCSV = QAction(self)
        extractCSV.setText("Extract to Arrays")
        extractCSV.triggered.connect(self.extractArray)
        self.csvlist.addAction(plotCSV)
        self.csvlist.addAction(extractCSV)
        self.csvlist.addAction(delete)

        self.addWidget(self.csvlist)

        # Properties widget
        self.properties = DataSetEditGroupBox(_("參數(Properties)"), CsvParam)
        self.properties.setEnabled(False)
        self.addWidget(self.properties)

    def plotCSV(self):
        self.emit(SIGNAL("PLOT"))

    def removeItem(self):
        self.emit(SIGNAL("REMOVE"))

    def extractArray(self):
        self.emit(SIGNAL("EXTRACT_ARRAY"))
예제 #27
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))
예제 #28
0
 def __init__(self):
     QDialog.__init__(self)
     self.setWindowTitle("Data Logger")
     self.groupbox1 = DataSetEditGroupBox("Parametres de lock",Loggerdataset,show_button = False)   
     self.groupbox1.dataset.parent = self
     self.values = self.groupbox1.dataset
     self.groupbox1.dataset.parent = self
     lay = QVBoxLayout()
     lay.addWidget(self.groupbox1)
     self.setLayout(lay)
     self.resize(800,300)
     
     self.timer = QTimer()
     self.timer.timeout.connect(self.log)
     #self.timer.timeout.connect(self.update_values)
     self.timer.setInterval(100) #ms
     self.show()
예제 #29
0
    def __init__(self):
        # init main panel
        QMainWindow.__init__(self, None)
        #        QMainWindow.__init__(self, None, QtCore.Qt.WindowStaysOnTopHint)
        Thread.__init__(self)
        widget = QWidget()
        self.setCentralWidget(widget)
        self.setWindowTitle('3D tracking')
        self.move(600, 150)
        # define main objects
        self.tracking = tracking_3d.Tracking3D.getInstance()

        # init dataset from gui_construction
        self.gb_sequence = DataSetEditGroupBox(
            "Sequence", gui_construction.RemoteParameters, comment='')
        self.gb_sample = DataSetEditGroupBox("Sample",
                                             gui_construction.SampleParameters,
                                             comment='')
        self.gb_tracking = DataSetEditGroupBox(
            "Tracking", gui_construction.TrackingParameters, comment='')

        self.btn_process = QPushButton("Start tracking", self)
        self.btn_process.clicked.connect(self.start_tracking)

        # associate events to dataset apply buttons
        self.connect(self.gb_sequence, SIGNAL("apply_button_clicked()"),
                     self.update_remote_params)
        self.connect(self.gb_tracking, SIGNAL("apply_button_clicked()"),
                     self.update_tracking_params)
        self.connect(self.gb_sample, SIGNAL("apply_button_clicked()"),
                     self.update_sample_parameters)

        # organize the app panels
        splitter1 = QSplitter(QtCore.Qt.Vertical)
        splitter1.addWidget(self.gb_sequence)
        splitter1.addWidget(self.gb_sample)
        splitter1.addWidget(self.gb_tracking)
        splitter1.addWidget(self.btn_process)

        splitter = QSplitter(self)
        splitter.addWidget(splitter1)
        self.setCentralWidget(splitter)
        self.setContentsMargins(10, 5, 10, 5)

        # get all params from datasets
        self.gb_sequence.get()
        self.gb_sample.get()
        self.gb_tracking.get()
예제 #30
0
class MainWindow(Thread, QMainWindow):
    def __init__(self):
        # init main panel
        QMainWindow.__init__(self, None)
#        QMainWindow.__init__(self, None, QtCore.Qt.WindowStaysOnTopHint)
        Thread.__init__(self)
        widget = QWidget()
        self.setCentralWidget(widget)
        self.setWindowTitle('3D tracking')
        self.move(600, 150)
        # define main objects
        self.tracking = tracking_3d.Tracking3D.getInstance()
        
        # init dataset from gui_construction
        self.gb_sequence = DataSetEditGroupBox("Sequence", 
                    gui_construction.RemoteParameters, comment='')
        self.gb_sample = DataSetEditGroupBox("Sample", 
                    gui_construction.SampleParameters, comment='')
        self.gb_tracking = DataSetEditGroupBox("Tracking", 
                    gui_construction.TrackingParameters, comment='')
            
        self.btn_process = QPushButton("Start tracking", self)
        self.btn_process.clicked.connect(self.start_tracking)

        # associate events to dataset apply buttons
        self.connect(self.gb_sequence, SIGNAL("apply_button_clicked()"), 
                     self.update_remote_params)
        self.connect(self.gb_tracking, SIGNAL("apply_button_clicked()"), 
                     self.update_tracking_params)     
        self.connect(self.gb_sample, SIGNAL("apply_button_clicked()"), 
                     self.update_sample_parameters)
                     
        # organize the app panels
        splitter1 = QSplitter(QtCore.Qt.Vertical)
        splitter1.addWidget(self.gb_sequence)
        splitter1.addWidget(self.gb_sample)
        splitter1.addWidget(self.gb_tracking)
        splitter1.addWidget(self.btn_process)
        
        splitter = QSplitter(self)
        splitter.addWidget(splitter1)
        self.setCentralWidget(splitter)
        self.setContentsMargins(10, 5, 10, 5)   
        
        # get all params from datasets
        self.gb_sequence.get()
        self.gb_sample.get()
        self.gb_tracking.get()
        
    # when the main program is closed
    def closeEvent(self, event):
        remoteKoala = self.tracking.remoteKoala
        if remoteKoala is not None and remoteKoala.connected:
            self.tracking.remoteKoala.remoteCommands.ResetCorrSegments()
            self.tracking.remoteKoala.CloseConnection()

    # update the remote parameters
    def update_remote_params(self):
        utils.Log("Sequence parameters initialized")
        self.tracking.initRemoteKoala(self.gb_sequence.dataset)
        self.gb_sequence.dataset.last_holo_seq = \
                    (int)(self.tracking.remoteKoala.framesNumber) - 1
        self.gb_sequence.get()
#        self.gb_sequence.setEnabled(False)
        self.tracking.setupKoala()
    
    def update_sample_parameters(self):
        utils.Log("Sample paramters initialized")
        self.tracking.initSampleParams(self.gb_sample.dataset)
      
    # update tracking parameters 
    def update_tracking_params(self):
        utils.Log("Tracking paramters initialized")
        self.tracking.initTrackingParams(self.gb_tracking.dataset)
        self.gb_tracking.dataset.samplePlaneStepUM = self.tracking.stepUM
        self.gb_tracking.dataset.stackHeightUM = self.tracking.stackHeightUM
        self.gb_tracking.get()
        
    # initiate tracking process
    def start_tracking(self):
        utils.Log("Start tracking process")
        self.tracking.performTracking()
예제 #31
0
    def __init__(self):
        # init main panel
        QMainWindow.__init__(self)
        Thread.__init__(self)
        widget = QWidget()
        self.setCentralWidget(widget)

        # define main objects
        self.remoteKoala = None
        self.aberrationCorrection = None
        self.stackDistance = None
        self.tracking = None
        self.db = None
        self.focusPoint = None
        self.trackingMode = 0  # 0 - Automatic, 1 - Single
        self.unwrapK = None
        self.setWindowTitle('3D tracking')

        # init dataset from gui_construction
        self.gb_dhm = DataSetEditGroupBox("DHM",
                                          gui_construction.DHMParameters,
                                          comment='')
        self.gb_sample = DataSetEditGroupBox("Sample",
                                             gui_construction.SampleParameters,
                                             comment='')
        self.gb_remote = DataSetEditGroupBox("Sequence",
                                             gui_construction.RemoteParameters,
                                             comment='')
        self.gb_holder = DataSetEditGroupBox("Focus",
                                             gui_construction.HolderParameters,
                                             comment='')
        self.gb_rec = DataSetEditGroupBox(
            "Preprocessing Parameters",
            gui_construction.ReconstructionParameters,
            comment='')
        #        self.gb_proc = DataSetEditGroupBox("Process",
        #                    gui_construction.ProcessParameters, comment='')
        #        self.gb_partchoice = DataSetEditGroupBox("Particle Choice",
        #                    gui_construction.ParticuleChoice, comment='')

        # associate events to dataset apply buttons
        self.connect(self.gb_dhm, SIGNAL("apply_button_clicked()"),
                     self.update_dhm_params)
        self.connect(self.gb_sample, SIGNAL("apply_button_clicked()"),
                     self.update_sample_params)
        self.connect(self.gb_remote, SIGNAL("apply_button_clicked()"),
                     self.update_remote_params)
        self.connect(self.gb_holder, SIGNAL("apply_button_clicked()"),
                     self.update_holder_params)

        # organize the subpanels
        splitter1 = QSplitter(QtCore.Qt.Vertical)
        splitter1.addWidget(self.gb_dhm)
        splitter1.addWidget(self.gb_sample)
        splitter1.addWidget(self.gb_remote)
        splitter1.addWidget(self.gb_holder)

        splitter2 = QSplitter(QtCore.Qt.Vertical)

        splitter = QSplitter(self)
        splitter.addWidget(splitter1)
        splitter.addWidget(splitter2)
        self.setCentralWidget(splitter)
        self.setContentsMargins(10, 5, 10, 5)

        # get all params from datasets
        self.gb_dhm.get()
예제 #32
0
 def __init__(self, parent):
     QSplitter.__init__(self, parent)
     DSParam.__init__
     self.datas = DataSetEditGroupBox(_("Dataset"), DSParam)
     self.addWidget(self.datas)
예제 #33
0
 def __init__(self, parent):
     QSplitter.__init__(self, parent)
     self.datas = DataSetEditGroupBox(_("Fit"), FitParam)
     self.addWidget(self.datas)
예제 #34
0
    def __init__(self):
        # init main panel
        QMainWindow.__init__(self)
        Thread.__init__(self)
        widget = QWidget()
        self.setCentralWidget(widget)

        # define main objects
        self.remoteKoala = None
        self.aberrationCorrection = None
        self.stackDistance = None
        self.tracking = None
        self.db = None
        self.focusPoint = None
        self.trackingMode = 0 # 0 - Automatic, 1 - Single
        self.unwrapK = None
        self.setWindowTitle('3D tracking')
        
        # init dataset from gui_construction
        self.gb_dhm = DataSetEditGroupBox("DHM", 
                    gui_construction.DHMParameters, comment='')
        self.gb_sample = DataSetEditGroupBox("Sample", 
                    gui_construction.SampleParameters, comment='')
        self.gb_remote = DataSetEditGroupBox("Sequence", 
                    gui_construction.RemoteParameters, comment='')       
        self.gb_holder = DataSetEditGroupBox("Focus", 
                    gui_construction.HolderParameters, comment='')
        self.gb_rec = DataSetEditGroupBox("Preprocessing Parameters", 
                    gui_construction.ReconstructionParameters, comment='')
#        self.gb_proc = DataSetEditGroupBox("Process", 
#                    gui_construction.ProcessParameters, comment='')
#        self.gb_partchoice = DataSetEditGroupBox("Particle Choice", 
#                    gui_construction.ParticuleChoice, comment='')
                    
        # associate events to dataset apply buttons
        self.connect(self.gb_dhm, SIGNAL("apply_button_clicked()"), 
                     self.update_dhm_params)
        self.connect(self.gb_sample, SIGNAL("apply_button_clicked()"), 
                     self.update_sample_params)
        self.connect(self.gb_remote, SIGNAL("apply_button_clicked()"), 
                     self.update_remote_params)
        self.connect(self.gb_holder, SIGNAL("apply_button_clicked()"), 
                     self.update_holder_params)
        
        # organize the subpanels
        splitter1 = QSplitter(QtCore.Qt.Vertical)
        splitter1.addWidget(self.gb_dhm)
        splitter1.addWidget(self.gb_sample)
        splitter1.addWidget(self.gb_remote)
        splitter1.addWidget(self.gb_holder)
        
        splitter2 = QSplitter(QtCore.Qt.Vertical)
        
        splitter = QSplitter(self)
        splitter.addWidget(splitter1)
        splitter.addWidget(splitter2)
        self.setCentralWidget(splitter)
        self.setContentsMargins(10, 5, 10, 5)   
        
        # get all params from datasets
        self.gb_dhm.get()
예제 #35
0
class ProjectGUI(QObject):
    logger = logging.getLogger()
    _new_project_signal = pyqtSignal()

    def __init__(self, parent):
        super(ProjectGUI, self).__init__()
        self.parent = parent
        self._connect_project_properties()

    def _reset_data(self):
        self.projectproperties.dataset._reset_values()
        self.rewrite_values_in_gui_with_variables()

    def _connect_project_properties(self):
        self.projectproperties = DataSetEditGroupBox(
            "Project Data",
            ProjectPropertiesDataset,
            comment="Parameters common to all assets")
        self.projectproperties.SIG_APPLY_BUTTON_CLICKED.connect(
            self._apply_dataset_values)

    def _apply_dataset_values(self):
        """This is connected to a signal. When mocking, use parent.apply_dataset_values method."""
        self.logger.info("Me pressed.")
        self.parent.apply_dataset_values()

    def check_epanetfile(self, enfile):
        if (os.path.isfile(enfile)):
            self.logger.info("EPANET valid file check. To be implemented")
            return enfile
        else:
            self.logger.info("Not a valid epanetfile: %s" % enfile)
            msgBox = QMessageBox(parent=self.parent)
            msgBox.setText("This is not a valid epanet file")
            msgBox.exec_()
            return None

    def log(self):
        try:
            k = self.projectproperties.dataset
            self.logger.info("discount rate =%s" % (k.discountrate))
        except Exception:
            pass

    def rewrite_values_in_gui_with_variables(self):
        self.logger.info("Writing: var>GUI ")
        self.log()
        self.projectproperties.get()

    def rewrite_values_in_variables_with_gui(self):
        self.logger.info("Writing: GUI>var ")
        self.log()
        # disable events from firing
        __status = self.projectproperties.blockSignals(True)
        self.projectproperties.set()
        # now enable them again
        self.projectproperties.blockSignals(__status)

    def new_project(self):
        self.logger.info("New Project")
        # first step, get the name of the epanet file from the user.
        if (self._new_project()):
            # now we inform the project_manager to do the calculation
            self._new_project_signal.emit()
            return True
        else:
            return False

    def _new_project(self):
        epanetfile, filter = self._getSaveFileName2(
            self.parent,
            "Select a valid EPANET 2.0 network file",
            self.parent.EPANETLOC or c.HOMEDIR,
            filter='*.inp')

        epanetfile = self.check_epanetfile(epanetfile)
        if (not epanetfile):
            return False
        msg = "New Project"
        self.projectproperties.dataset.projectname = self._create_empty_project(
            msg, epanetfile)
        self.parent.LASTPROJECT = self.projectproperties.dataset.projectname
        self.parent.EPANETLOC = os.path.dirname(epanetfile)
        self.rewrite_values_in_gui_with_variables()
        return True

    def _getSaveFileName(self, *args, **kwargs):
        # why this function and _getSaveFileName2? for tests to mock this method easily.
        self.logger.info("proxy calling QFileDialog.getSaveFileName ")
        return QFileDialog.getSaveFileName(*args, **kwargs)

    def _getSaveFileName2(self, *args, **kwargs):
        # why this function and _getSaveFileName? for tests to mock this method easily.
        self.logger.info("proxy calling QFileDialog.getOpenFileName ")
        return QFileDialog.getOpenFileName(*args, **kwargs)

    def _getOpenFileName(self, *args, **kwargs):
        self.logger.info("proxy calling QFileDialog.getOpenFileName ")
        return QFileDialog.getOpenFileName(*args, **kwargs)

    def _create_empty_project(self, msg, epanetfile):
        projectfile = self.get_save_filename(msg)
        self.logger.info(
            "creating empty project with filename %s and epanetfile %s " %
            (projectfile, epanetfile))
        if (not projectfile):
            return None
        else:
            return self._save_project_to_dest(projectfile,
                                              epanetfile=epanetfile)

    def get_save_filename(self, msg):
        projectfile, filter = self._getSaveFileName(
            self.parent,
            msg,
            self.parent.LASTPROJECT or c.HOMEDIR,
            filter='*' + c.PROJECTEXTENSION)
        self.logger.info("Selected file for save/new project : %s " %
                         projectfile)
        return projectfile

    def _update_results_with_gui_values(self):
        """Update the self.projectproperties.dataset.results object with
        group information. Call this before pickling data"""
        r = self.projectproperties.dataset.results
        if (not r):
            self.logger.info(
                "No results available yet with projectproperties. So, not updating"
            )
        else:
            self.logger.info(
                "Updating projectproperties.dataset.results with my_group")
            for item in r.links:
                item.asset_group = self.parent.datawindow.get_asset_group(
                    item.id)
                item.age = self.parent.datawindow.get_age(item.id)

    def _save_project_to_dest(self, projectfile, epanetfile=None):

        self.logger.info("Getting values from datawindow..")
        # First get latest values from dataWindow
        inf = self.parent.datawindow.get_information(all=True)
        self.projectproperties.dataset.group_list_to_save_or_load = inf
        self._update_results_with_gui_values()
        self.logger.info("Now writing data")
        prjname, subdir, ext = c._get_dir_and_extention(projectfile)
        self.projectproperties.dataset.write_data(prjname)

        if (not os.path.isdir(subdir)):
            os.mkdir(subdir)
            self.logger.info("Created  directory %s" % subdir)

        if (epanetfile):
            base = os.path.basename(epanetfile)
            dst = os.path.join(os.path.dirname(prjname), base)
            shutil.copy(epanetfile, dst)
            self.projectproperties.dataset.fname = base
            self.logger.info("copied epanet file to %s" % dst)
        return prjname

    def try_loading_project_properties(self, prj):
        try:
            self.logger.info("Trying to read properties from %s " % prj)
            if (self.projectproperties.dataset.read_data(prj)):
                self.logger.info(" %s project read successfully." % prj)
                return True
        except Exception as e:
            self.logger.exception("Could not load the project properties: %s" %
                                  e)
        return False

    def save_project(self):
        self.logger.info("Saving the project")
        # Implement the actions needed to save the project here.
        # first update any user changes in parameters
        self.rewrite_values_in_variables_with_gui()
        try:
            return self._save_project_to_dest(
                self.projectproperties.dataset.projectname)
        except Exception as e:
            self.logger.exception("Exception %s " % e)
            return False

    def save_project_as(self):
        msg = "Save project as"
        self.projectproperties.dataset.projectname = self.get_save_filename(
            msg)
        if (self.projectproperties.dataset.projectname):
            return self.save_project()
        else:
            return None

    def open_project(self):
        while (True):
            projectfile, filter = self._getOpenFileName(
                self.parent,
                "Open project",
                self.parent.LASTPROJECT or c.HOMEDIR,
                filter='*' + c.PROJECTEXTENSION)
            if (not projectfile):
                return None
            projectfile, dir, ext = c._get_dir_and_extention(projectfile)
            self.logger.info("Selected file to open : %s " % projectfile)
            # check if it is a valid project
            if (self._valid_project(projectfile)):
                self.projectproperties.dataset.projectname = projectfile
                self.parent.LASTPROJECT = self.projectproperties.dataset.projectname
                self.parent._display_project()
                # now update the dataWindow with project groups in opened project
                self.parent.datawindow.set_information(
                    self.projectproperties.dataset.group_list_to_save_or_load)
                self.logger.info("Updated dataWindow with project groups")
                # since we have done both (a) displaying network and
                # (b) updating the asset groups, now we can assign correct asset group
                # to each asset item
                if (self.projectproperties.dataset.results):
                    r = self.projectproperties.dataset.results.links
                    self.parent.datawindow.assign_values_to_asset_items(r)
                break
            else:
                self.logger.info("Project loading failed: Not a valid project")
                return None

        self.logger.info("Open Project valid")
        self.rewrite_values_in_gui_with_variables()
        self.parent.apply_dataset_values()
        return (projectfile)

    def _valid_project(self, prj):
        """Check if prj represents a valid project. """
        if (not os.path.isfile(prj)):
            return False
        if (not os.path.isdir(c._get_dir_and_extention(prj)[1])):
            return False
        # Try opening
        self.logger.info("Now calling try_loading_project_properties ")
        return self.try_loading_project_properties(prj)
예제 #36
0
class ArrayListWithProperties(QSplitter):
    # Define View的部分
    def __init__(self, parent):
        QSplitter.__init__(self, parent)
        # List Widget
        self.arraylist = QListWidget(self)
        self.arraylist.setContextMenuPolicy(Qt.ActionsContextMenu)

        newArray = QAction(self)
        newArray.setText("Paste Array (no header name)")
        newArray.triggered.connect(self.pasteArray)
        newArrayWithName = QAction(self)
        newArrayWithName.setText("Paste Array (with header name)")
        newArrayWithName.triggered.connect(self.pasteArrayWithName)
        plotArray = QAction(self)
        plotArray.setText("Plot Array")
        plotArray.triggered.connect(self.plotArray)
        modifyArray = QAction(self)
        modifyArray.setText("Modify Array(Calibration)")
        modifyArray.triggered.connect(self.modifyArray)
        plotScatter = QAction(self)
        plotScatter.setText("Plot Scatter")
        plotScatter.triggered.connect(self.plotScatter)
        plotHist = QAction(self)
        plotHist.setText("Plot Histogram")
        plotHist.triggered.connect(self.plotHist)
        delete = QAction(self)
        delete.setText("Remove")
        delete.triggered.connect(self.removeItem)
        curveDialog = QAction(self)
        curveDialog.setText("Open Curve Dialog")
        curveDialog.triggered.connect(self.openCurveDialog)
        self.arraylist.addAction(newArray)
        self.arraylist.addAction(newArrayWithName)
        self.arraylist.addAction(plotArray)
        self.arraylist.addAction(plotScatter)
        self.arraylist.addAction(plotHist)
        self.arraylist.addAction(modifyArray)
        self.arraylist.addAction(curveDialog)
        self.arraylist.addAction(delete)

        self.addWidget(self.arraylist)

        # Properties widget
        self.properties = DataSetEditGroupBox(_("參數(Properties)"), CsvParam)
        self.properties.setEnabled(False)
        self.addWidget(self.properties)

    def pasteArray(self):
        self.emit(SIGNAL("PASTE_NO_NAME"))

    def pasteArrayWithName(self):
        self.emit(SIGNAL("PASTE_WITH_NAME"))

    def plotHist(self):
        self.emit(SIGNAL("PLOT_HISTOGRAM"))

    def plotArray(self):
        self.emit(SIGNAL("PLOT"))

    def modifyArray(self):
        self.emit(SIGNAL("MODIFY_ARRAY"))

    def plotScatter(self):
        self.emit(SIGNAL("PLOT_SCATTER"))

    def removeItem(self):
        self.emit(SIGNAL("REMOVE"))

    def openCurveDialog(self):
        self.emit(SIGNAL("OPEN_CURVEDIALOG"))
예제 #37
0
class MainWindow(Thread, QMainWindow):
    def __init__(self):
        # init main panel
        QMainWindow.__init__(self, None)
        #        QMainWindow.__init__(self, None, QtCore.Qt.WindowStaysOnTopHint)
        Thread.__init__(self)
        widget = QWidget()
        self.setCentralWidget(widget)
        self.setWindowTitle('3D tracking')
        self.move(600, 150)
        # define main objects
        self.tracking = tracking_3d.Tracking3D.getInstance()

        # init dataset from gui_construction
        self.gb_sequence = DataSetEditGroupBox(
            "Sequence", gui_construction.RemoteParameters, comment='')
        self.gb_sample = DataSetEditGroupBox("Sample",
                                             gui_construction.SampleParameters,
                                             comment='')
        self.gb_tracking = DataSetEditGroupBox(
            "Tracking", gui_construction.TrackingParameters, comment='')

        self.btn_process = QPushButton("Start tracking", self)
        self.btn_process.clicked.connect(self.start_tracking)

        # associate events to dataset apply buttons
        self.connect(self.gb_sequence, SIGNAL("apply_button_clicked()"),
                     self.update_remote_params)
        self.connect(self.gb_tracking, SIGNAL("apply_button_clicked()"),
                     self.update_tracking_params)
        self.connect(self.gb_sample, SIGNAL("apply_button_clicked()"),
                     self.update_sample_parameters)

        # organize the app panels
        splitter1 = QSplitter(QtCore.Qt.Vertical)
        splitter1.addWidget(self.gb_sequence)
        splitter1.addWidget(self.gb_sample)
        splitter1.addWidget(self.gb_tracking)
        splitter1.addWidget(self.btn_process)

        splitter = QSplitter(self)
        splitter.addWidget(splitter1)
        self.setCentralWidget(splitter)
        self.setContentsMargins(10, 5, 10, 5)

        # get all params from datasets
        self.gb_sequence.get()
        self.gb_sample.get()
        self.gb_tracking.get()

    # when the main program is closed
    def closeEvent(self, event):
        remoteKoala = self.tracking.remoteKoala
        if remoteKoala is not None and remoteKoala.connected:
            self.tracking.remoteKoala.remoteCommands.ResetCorrSegments()
            self.tracking.remoteKoala.CloseConnection()

    # update the remote parameters
    def update_remote_params(self):
        utils.Log("Sequence parameters initialized")
        self.tracking.initRemoteKoala(self.gb_sequence.dataset)
        self.gb_sequence.dataset.last_holo_seq = \
                    (int)(self.tracking.remoteKoala.framesNumber) - 1
        self.gb_sequence.get()
        #        self.gb_sequence.setEnabled(False)
        self.tracking.setupKoala()

    def update_sample_parameters(self):
        utils.Log("Sample paramters initialized")
        self.tracking.initSampleParams(self.gb_sample.dataset)

    # update tracking parameters
    def update_tracking_params(self):
        utils.Log("Tracking paramters initialized")
        self.tracking.initTrackingParams(self.gb_tracking.dataset)
        self.gb_tracking.dataset.samplePlaneStepUM = self.tracking.stepUM
        self.gb_tracking.dataset.stackHeightUM = self.tracking.stackHeightUM
        self.gb_tracking.get()

    # initiate tracking process
    def start_tracking(self):
        utils.Log("Start tracking process")
        self.tracking.performTracking()
예제 #38
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()
예제 #39
0
class ParamWidget(QWidget):
    def __init__(self, dataset, title = '', settings = None, settingskey = None, parent = None):
        super(ParamWidget, self).__init__(parent = parent)
        
        self.settings = settings
        self.settingskey = settingskey
        
        self.mainLayout = QVBoxLayout()
        self.setLayout(self.mainLayout)
        
        
        if self.settings is not None and self.settingskey is not None:
            stored_list = self.settings.getValueOrDefault('storedParameters/'+self.settingskey, [ ])

            h = QHBoxLayout()
            self.mainLayout.addLayout(h)
            h.addStretch(1)
            self.comboParam = QComboBox()
            h.addWidget(self.comboParam, 3)
            
            self.refreshCombo()
            self.comboParam.currentIndexChanged.connect(self.comboParamChanged)

            buttonSave = QPushButton(QIcon(':/list-add.png') ,'')
            buttonSave.setMaximumSize(25,25)
            h.addWidget(buttonSave)
            buttonSave.clicked.connect(self.saveNewParam)
            buttonDel = QPushButton(QIcon(':/list-remove.png') ,'')
            buttonDel.setMaximumSize(25,25)
            h.addWidget(buttonDel)
            buttonDel.clicked.connect(self.delSavedParam)
        
        self.params = DataSetEditGroupBox(title,dataset, show_button = False)
        self.mainLayout.addWidget( self.params )
        
        self.default_dict = self.to_dict()
        

    def to_dict(self):
        self.params.set()
        ds = self.params.dataset
        d = OrderedDict()
        for item in ds._items:
            if type(item) is ChoiceItem:
                val = None
                ind = getattr(ds,  item._name)
                choices = item.get_prop_value("data", item, "choices")
                for choice in choices:
                    if choice[0] == ind:
                        val = choice[1]
            else:
                val = getattr(ds,  item._name)
            d[item._name] = val
        return d
        
    def update(self, d):
        ds = self.params.dataset
        for item in ds._items:
            if item._name in d:
                if type(item) is ChoiceItem:
                    choices = item.get_prop_value("data", item, "choices")
                    choices = [ c[1] for c in choices ]
                    ind = choices.index(d[item._name])
                    setattr(ds,  item._name, ind)
                else:
                    setattr(ds,  item._name, d[item._name])
        self.params.get()
    
    def reset(self):
        self.update(self.default_dict)
    
    def refreshCombo(self):
        stored_list = self.settings['storedParameters/'+self.settingskey]
        self.comboParam.clear()
        list_name = [ l[0] for l in stored_list ]
        self.comboParam.addItems(['Default' , ]+list_name  )
        
    
    def comboParamChanged(self, pos) :
        if pos <= 0 :
            self.reset()
        else :
            stored_list = self.settings['storedParameters/'+self.settingskey]
            self.update(stored_list[pos-1][1])
    
    def saveNewParam( self ) :
        class Parameters(DataSet):
            name = StringItem('name', default = '')
        dia = ParamDialog(Parameters, title = 'key')
        ok = dia.exec_()
        if  ok !=  QDialog.Accepted: return
        
        name = dia.to_dict()['name']
        stored_list = self.settings['storedParameters/'+self.settingskey]
        stored_list += [ [ name , self.to_dict() ] ]
        self.settings['storedParameters/'+self.settingskey] = stored_list

        self.refreshCombo()
        self.comboParam.setCurrentIndex(len(stored_list))

    def delSavedParam( self) :
        pos = self.comboParam.currentIndex()
        if pos == 0: return

        stored_list = self.settings['storedParameters/'+self.settingskey]
        del stored_list[pos-1]
        self.settings['storedParameters/'+self.settingskey] = stored_list
            
        self.refreshCombo()
        self.comboParam.setCurrentIndex(0)
예제 #40
0
class ParamWidget(QWidget):
    def __init__(self, dataset, title = '', settings = None, settingskey = None, parent = None):
        super(ParamWidget, self).__init__(parent = parent)
        
        self.settings = settings
        self.settingskey = settingskey
        
        self.mainLayout = QVBoxLayout()
        self.setLayout(self.mainLayout)
        
        
        if self.settings is not None and self.settingskey is not None:
            stored_list = self.settings.getValueOrDefault('storedParameters/'+self.settingskey, [ ])

            h = QHBoxLayout()
            self.mainLayout.addLayout(h)
            h.addStretch(1)
            self.comboParam = QComboBox()
            h.addWidget(self.comboParam, 3)
            
            self.refreshCombo()
            self.comboParam.currentIndexChanged.connect(self.comboParamChanged)

            buttonSave = QPushButton(QIcon(':/list-add.png') ,'')
            buttonSave.setMaximumSize(25,25)
            h.addWidget(buttonSave)
            buttonSave.clicked.connect(self.saveNewParam)
            buttonDel = QPushButton(QIcon(':/list-remove.png') ,'')
            buttonDel.setMaximumSize(25,25)
            h.addWidget(buttonDel)
            buttonDel.clicked.connect(self.delSavedParam)
        
        self.params = DataSetEditGroupBox(title,dataset, show_button = False)
        self.mainLayout.addWidget( self.params )
        
        self.default_dict = self.to_dict()
        

    def to_dict(self):
        self.params.set()
        ds = self.params.dataset
        d = OrderedDict()
        for item in ds._items:
            if type(item) is ChoiceItem:
                val = None
                ind = getattr(ds,  item._name)
                choices = item.get_prop_value("data", item, "choices")
                for choice in choices:
                    if choice[0] == ind:
                        val = choice[1]
            else:
                val = getattr(ds,  item._name)
            d[item._name] = val
        return d
        
    def update(self, d):
        ds = self.params.dataset
        for item in ds._items:
            if item._name in d:
                if type(item) is ChoiceItem:
                    choices = item.get_prop_value("data", item, "choices")
                    choices = [ c[1] for c in choices ]
                    ind = choices.index(d[item._name])
                    setattr(ds,  item._name, ind)
                else:
                    setattr(ds,  item._name, d[item._name])
        self.params.getInstance()
    
    def reset(self):
        self.update(self.default_dict)
    
    def refreshCombo(self):
        stored_list = self.settings['storedParameters/'+self.settingskey]
        self.comboParam.clear()
        list_name = [ l[0] for l in stored_list ]
        self.comboParam.addItems(['Default' , ]+list_name  )
        
    
    def comboParamChanged(self, pos) :
        if pos <= 0 :
            self.reset()
        else :
            stored_list = self.settings['storedParameters/'+self.settingskey]
            self.update(stored_list[pos-1][1])
    
    def saveNewParam( self ) :
        class Parameters(DataSet):
            name = StringItem('name', default = '')
        dia = ParamDialog(Parameters, title = 'key')
        ok = dia.exec_()
        if  ok !=  QDialog.Accepted: return
        
        name = dia.to_dict()['name']
        stored_list = self.settings['storedParameters/'+self.settingskey]
        stored_list += [ [ name , self.to_dict() ] ]
        self.settings['storedParameters/'+self.settingskey] = stored_list

        self.refreshCombo()
        self.comboParam.setCurrentIndex(len(stored_list))

    def delSavedParam( self) :
        pos = self.comboParam.currentIndex()
        if pos == 0: return

        stored_list = self.settings['storedParameters/'+self.settingskey]
        del stored_list[pos-1]
        self.settings['storedParameters/'+self.settingskey] = stored_list
            
        self.refreshCombo()
        self.comboParam.setCurrentIndex(0)
예제 #41
0
class GuidataView(view.GenericView):
    _CONST_Views = ['Splitter', 'Tabs', 'Standard']

    def __init__(self, viewname = '', viewtype ='Standard', qtapp=None):
        super().__init__(viewname)
        self._app = qtapp
        self._frame = None
        self._parentFrame = None
        self._viewtype = viewtype
        self._groupbox = None
        self._previousValues = OrderedDict()

    def getViewType(self):
        return self._viewtype

    viewtype = property(getViewType, doc='The view type, see _CONST_Views for available views. Readonly')

    def setParentView(self, parentview):
        '''
        Set the parent widget associated to this view (GenericView)
        :param parentview:
        :return:
        '''
        if self._parentFrame is not None:
            raise view.ViewInternalError(self, self._viewname, 'Parent was already set')
        # self._parentFrame = parentview.getViewContainer()
        self._parentFrame = parentview

    def show(self):
        # QT Stuff
        if self._app is None:
            self._app = QApplication([])
        if self._parentFrame is None:
            self._parentFrame = QMainWindow()

        # self._parentFrame.setWindowIcon(get_icon('python.png'))
        self._parentFrame.setWindowTitle(self.viewname)

         # Add the frame to this frame
        self._parentFrame.setCentralWidget(self.getFrame())
        self._parentFrame.setContentsMargins(10, 5, 10, 5)

        self._parentFrame.show()
        self._forceRefreshFromWidgets()
        self._previousValues = self._dumpValues()

    def close(self, closeapp=False):
        '''
        Implement the close view in the GerericView class, furthermore  close the QT application which this view belongs
        :param closeapp:
        :return:
        '''
        if self._parentFrame is not None:
            self._parentFrame.close()
            del self._parentFrame
        if self._app is not None and closeapp:
            del self._app

    def getFrame(self):
        '''
        Return the frame containing the presentation, check if the frame was created, otherwise it is created
        :return:
        '''
        if self._frame is None:
            self._generateFrame()
        return self._frame

    def _generateFrame(self):
        '''
        Return the frame containing the presentation, check if the frame was created, otherwise it is created
        :return:
        '''
        # generate the frame if necessary
        if self._frame is None:
            # Generate frame and define the layout based on the frame
            self._frame = QFrame(self._parentFrame)
            _layout = QVBoxLayout()
            self._frame.setLayout(_layout)

            # Add the "Main" group box for this view, if present. It is rendered in foreground
            if self._generateGroupBox() is not None:
                _layout.addWidget(self._groupbox)
            else:
                self._frame.setFrameStyle(QFrame.Panel|QFrame.Raised)
                self._frame.setLineWidth(1)

            # Add to layout eventually the other subview
            if self._viewtype == 'Tabs':
                _tabs = QTabWidget()
                _layout.addWidget(_tabs)
            elif self._viewtype == 'Splitter':
                _splitter =QSplitter()
                _layout.addWidget(_splitter)
            else:
                _sub_frame = QFrame()
                _sub_frame_layout = QHBoxLayout()
                _sub_frame.setLayout(_sub_frame_layout)
                _layout.addWidget(_sub_frame)

            # Add all the sub view as sub frames in the layout
            for sw in self._subViewDictionary.values():
                sw.setParentView(self._frame)
                if self._viewtype == 'Tabs':
                    _tabs.addTab(sw.getFrame(), sw.viewname)
                elif self._viewtype == 'Splitter':
                    _splitter.addWidget(sw.getFrame())
                else:
                    _sub_frame_layout.addWidget(sw.getFrame())

        return self._frame

    def _generateGroupBox(self):
        '''
        Generate if necessary the group box for this
        :return:
        '''
        if self._groupbox is None:
            # from  widgets create the view containing the datasets
            _dataSetView = self._generateGuidataDataset()
            if len(_dataSetView._items) > 0:
                if self._viewtype == 'Tabs':
                    self._groupbox = DataSetEditGroupBox(self.viewname, _dataSetView, comment='')
                else:
                    self._groupbox = DataSetEditGroupBox(self.viewname, _dataSetView, comment='')
                self._groupbox.SIG_APPLY_BUTTON_CLICKED.connect(self._updatedView)

        return self._groupbox

    def getViewContainer(self):
        '''
        This method must be reimplemented returning the proper window/frame etc.. It is based on the GUI implementation
        :return: a reference to the window container
        '''
        return self._parentFrame

    def getQTApp(self):
        '''
        Return the associated QT application, which is mandatory for guidata framework
        :return:
        '''
        return self._app

    def addWidget(self, widgetinstance):
        if not isinstance(widgetinstance, GuidataWidget):
            raise view.WrongWidgetClass(self, self._viewname, widgetinstance, GuidataWidget)
        super().addWidget(widgetinstance)

    def _dumpValues(self):
        widgetvalue = OrderedDict()

        for n, w in self._widgetDictionary.items():
            # I need to store the widget value and NOT the value returned (for example in a combo box I need to store
            # the index, not the value
            # widgetvalue[n] = w.getWidgetValue()
            widgetvalue[n] = GuidataWidget.convertValueToWidgetValue(w, w.getWidgetValue())

        return widgetvalue

    def _updatedViewHook(self):
        # En Widget ' + str(wtry point for a change...

        differences = {}
        differencesConverted = {}
        self._groupbox.get()
        dataset = self._groupbox.dataset

        for n, w in self._widgetDictionary.items():
            # if nameProp in  vars(dataset):
            # TODO: workaround,  the mechanism in the guidata framework is not very well documented.
            # TODO: then in order to get the proper value this is collected through the groupbox insteadm the value.
            # So i check in dataset every nameprop
            nameProp = w.name
            actualValue = getattr(dataset, nameProp) #, w.getWidgetValue())
            prevValue   = self._previousValues.get(n)
            logging.debug('--widgetname=' + w.name)

            if not (prevValue == actualValue):
                differences[n] = actualValue
                differencesConverted[n] = GuidataWidget.convertWidgetValueToValue(w, actualValue)
                #w._setWidgetValueHook(actualValue)
                logging.debug('  DIFFERENCE viewname={0}  prevvalue={1} - newvalue={2}'.format(n, prevValue, actualValue))
                logging.debug('  DIFFERENCE CONVERTED viewname={0}  prevvalue={1} - newvalue={2}'.format
                              (n, GuidataWidget.convertWidgetValueToValue(w, prevValue), differencesConverted[n]))
            else:
                logging.debug('  NO DIFFERENCE viewname={0}  prevvalue={1} - newvalue={2}'.format(n, prevValue, actualValue))

        if len(differences):
            self._forceRefreshToWidgets(differences)
            self._previousValues = self._dumpValues()
        return differencesConverted

    def _forceRefreshToWidgets(self, widget_to_set):
        '''
        A refresh to update the widget with the values stored in the groupbox associated
        This is a workaround relative to the guidata framework. (should be improved)
        :return:
        '''
        if self._groupbox == None:
            return

        #for key, w in self._widgetDictionary.items():
        for wname, valuetoconvert in widget_to_set.items():
            w = self.getWidget(wname)
            if w is None:
                raise RuntimeError('Widget cannot\'t be None')

            # TODO: this is horrible, but need a workaround for guidata to get the value from data set and force it in the GUI
            #valuetoconvert = getattr(self._groupbox.dataset, wname)
            converteddataset = GuidataWidget.convertWidgetValueToValue(w, valuetoconvert)
            logging.debug('For widget['+wname+'] Converted value from '+str(valuetoconvert)+' to ' + str(converteddataset))

            w.setWidgetValue(converteddataset) # Convertire from index to value
            logging.debug('\tValue set is '+str(w.getWidgetValue()))

    def _forceRefreshFromWidgets(self):
        '''
        A refresh to update the whole groupbox with the proper value associated in the widget
        A workaround in the bad documented guidata in order to  force the refresh from the data stored in the widget
        :return:
        '''
        if self._groupbox == None:
            return

        for key, w in self._widgetDictionary.items():
            value = w.getWidgetValue()
            valueconverted = w._getGuidataWidgetValue()
            logging.debug('For widget ['+key+'] Converted value from '+str(value)+' to ' + str(valueconverted))
            setattr(self._groupbox.dataset, key, valueconverted)
            logging.debug('\tRead back value  '+str(getattr(self._groupbox.dataset, key)))

        #PROBLEM IN GET!!! se faccio la get nelle combo box setto il valore del ITEM id e non del valore vero
        # in prarice il setattr dovrebbe settare l'ITEM ID per le combo box
        self._groupbox.get()

    def _userWidgetUpdatedHandler(self, sender):
        # WORKAROUND: the guidata need to be forced to update  the UI if the underlay widget is changed
        if not isinstance(sender, widget.GenericWidget):
            raise view.WrongWidgetClass(self,self.viewname, sender, widget.GenericWidget)
        self._forceRefreshFromWidgets()

        super()._userWidgetUpdatedHandler(sender)

    def _generateGuidataDataset(self):
        class DataSetView(DataSet):
            key = None
            value = None
            for key, value in self._widgetDictionary.items():
                locals()[key] = value.getDataSet()
            del key, value
        return DataSetView
예제 #42
0
파일: gui.py 프로젝트: zanppa/motor-sim
    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)
예제 #43
0
 def __init__(self):
     DataSetEditGroupBox.__init__(self,
                                  None,
                                  self.params,
                                  show_button=False)
예제 #44
0
 def __init__(self):
     DataSetEditGroupBox.__init__(self,
                                  None,
                                  self.minmax,
                                  show_button=False)
     self.setAxis = None
예제 #45
0
 def __init__(self, *args, **kwargs):
     DataSetEditGroupBox.__init__(self,
                                  _("Control panel"),
                                  self.Controlset,
                                  show_button=False)
예제 #46
0
class MathPanel(PlotPanel):
    class cSet(DataSet):
        _bg1 = BeginGroup("Source 1").set_pos(0)
        tab1 = ChoiceItem("Tab", ['a'])
        data1 = ChoiceItem("Data", ['a'])
        _eg1 = EndGroup("")

        _bg2 = BeginGroup("Source 2").set_pos(1)
        tab2 = ChoiceItem("Tab", ['a'])
        data2 = ChoiceItem("Data", ['a'])
        _eg2 = EndGroup("")

        _bg3 = BeginGroup("Operation").set_pos(2)
        function = ChoiceItem("Function", [('y1-y2', 'y1-y2'),
                                           ('y1+y2', 'y1+y2'),
                                           ('y1/y2', 'y1/y2'),
                                           ('custom', 'f(x,y1,y2)')])
        custom = StringItem("f(x,y1,y2):")
        _eg3 = EndGroup("")

        text = TextItem("").set_pos(3)

    def __init__(self, parent):
        plots=\
         [[
          {'name':'Source 1','curves':['in1']},
          {'name':'Source 2','curves':['in2']}],
         [
          {'name':'Result','curves':['out']},
         ]]

        self.tabs = parent.sp

        df = [n.axisLimits[1] - n.axisLimits[0] for n in self.tabs]
        df2 = max(df) / 2

        axisLimits = [
            -df2, df2,
            min([n.axisLimits[2] for n in self.tabs]),
            max([n.axisLimits[3] for n in self.tabs])
        ]

        PlotPanel.__init__(self,
                           parent=parent,
                           plots=plots,
                           axisLimits=axisLimits)

        self._cBox = DataSetEditGroupBox("Control",
                                         self.cSet,
                                         show_button=False)
        self.addWidget(self._cBox)

        tabchoices = [(m, n.name, None) for m, n in enumerate(self.tabs)]
        curvechoices = [(n, n, None) for n in self.tabs[0].curves.keys()]

        self.cSet._items[1].set_prop('data', choices=tabchoices)
        self._cBox.dataset.tab1 = 0
        self.cSet._items[2].set_prop('data', choices=curvechoices)
        self._cBox.dataset.data1 = curvechoices[0][0]
        self.cSet._items[5].set_prop('data', choices=tabchoices)
        self._cBox.dataset.tab2 = 0
        self.cSet._items[6].set_prop('data', choices=curvechoices)
        self._cBox.dataset.data2 = curvechoices[0][0]
        self._cBox.get()

    def refreshTab(self):
        if self.curves is None: return
        self._cBox.set()
        d = self._cBox.dataset
        tab1, tab2 = self.tabs[d.tab1], self.tabs[d.tab2]

        x1, y1 = tab1.getx(), tab1.curves[d.data1].y
        x2, y2 = tab2.getx(), tab2.curves[d.data2].y

        if x1 is None or x2 is None: return

        x_min = min(min(x1), min(x2))
        x_max = max(max(x1), max(x2))
        dx1 = x1[1] - x1[0] if len(x1) > 1 else 1e9
        dx2 = x2[1] - x2[0] if len(x2) > 1 else 1e9
        dx = min(dx1, dx2)

        x = np.arange(x_min, x_max, dx)
        y1 = np.interp(x, x1, y1, left=0, right=0)
        y2 = np.interp(x, x2, y2, left=0, right=0)

        fun = self._cBox.dataset.function
        if fun == 'custom': fun = self._cBox.dataset.custom

        try:
            y = eval(fun)
        except:
            y = x * 0.

        self.curves['in1'].setplot(x, y1)
        self.curves['in2'].setplot(x, y2)
        self.curves['out'].setplot(x, y)