예제 #1
0
    def mouseMoved(self, pos):

        self.q = self._item.mapFromScene(pos)
        self._lastPos = self.q
        if (pg.Qt.QtVersion.startswith('4')):
            message = QtCore.QString()
        else:
            message = str()
        if type(message) != str:
            message.append("X: ")
            message.append("{0:.1f}".format(self.q.x()))
        else:
            message += "X: "
            message += "{0:.1f}".format(self.q.x())
        if type(message) != str:
            message.append(", Y: ")
            message.append("{0:.1f}".format(self.q.y()))
        else:
            message += ", Y: "
            message += "{0:.1f}".format(self.q.y())

        # print message
        # if self.q.x() > 0 and self.q.x() < self._geometry.wRange(self._plane):
        #   if self.q.y() > 0 and self.q.y() < self._geometry.tRange():
        self._statusBar.showMessage(message)
예제 #2
0
    def mouseMoved(self, pos):
        self.q = self._item.mapFromScene(pos)
        self._lastPos = self.q

        offset = 0
        for i in range(self._geometry.nTPCs() * self._geometry.nCryos(), 0,
                       -1):
            if self.q.y() > i * (self._geometry.tRange() +
                                 self._geometry.cathodeGap()):
                offset = -i * (self._geometry.tRange() +
                               self._geometry.cathodeGap())
                break

        if (pg.Qt.QT_LIB == 'PyQt4'):
            message = QtCore.QString()
        else:
            message = str()
        if self._cmSpace:
            if type(message) != str:
                message.append("X: ")
                message.append("{0:.1f}".format(self.q.x() *
                                                self._geometry.wire2cm()))
            else:
                message += "X: "
                message += "{0:.1f}".format(self.q.x() *
                                            self._geometry.wire2cm())
        else:
            if type(message) != str:
                message.append("W: ")
                message.append(str(int(self.q.x())))
            else:
                message += "W: "
                message += str(int(self.q.x()))
        if self._cmSpace:
            if type(message) != str:
                message.append(", Y: ")
                message.append(
                    "{0:.1f}".format((self.q.y() + offset) *
                                     self._geometry.time2cm() -
                                     self._geometry.offset(self._plane)))
            else:
                message += ", Y: "
                message += "{0:.1f}".format((self.q.y() + offset) *
                                            self._geometry.time2cm() -
                                            self._geometry.offset(self._plane))
        else:
            if type(message) != str:
                message.append(", T: ")
                message.append(str(int(self.q.y() + offset)))
            else:
                message += ", T: "
                message += str(int(self.q.y() + offset))

        max_trange = self._geometry.tRange() * self._geometry.nTPCs()

        if self.q.x() > 0 and self.q.x() < self._geometry.wRange(self._plane):
            if self.q.y() > 0 and self.q.y() < max_trange:
                self._statusBar.showMessage(message)
예제 #3
0
    def get_control_file(self):
        """ Method that opens a QFileDialog to load the control file """
        dialog = QtGui.QFileDialog(directory=QtCore.QString('./'))
        dialog.setFileMode(QtGui.QFileDialog.AnyFile)
        dialog.setFilter('Python Files (*.py)')

        if dialog.exec_():
            filenames = dialog.selectedFiles()
            self.form.lineEdit_control.setText(filenames[0])
            if not self.launch_file == filenames[0]:
                self.control_file = filenames[0]
                self.check_control_file()
예제 #4
0
    def get_launch_file(self):
        """ Method that opens a QFileDialog to load the launch file """
        dialog = QtGui.QFileDialog(directory=QtCore.QString('./examples'))
        dialog.setFileMode(QtGui.QFileDialog.AnyFile)
        dialog.setFilter('Launch Files (*.launch)')

        if dialog.exec_():
            filenames = dialog.selectedFiles()
            self.form.lineEdit_launch.setText(filenames[0])
            if not self.launch_file == filenames[0]:
                self.remove_drone_tabs()
                self.launch_file = filenames[0]
                self.check_launch_file()
                self.set_drone_tabs()
                self.set_signals_tabs()
예제 #5
0
def test_types():
    paramSpec = [
        dict(name='float', type='float'),
        dict(name='int', type='int'),
        dict(name='str', type='str'),
        dict(name='list', type='list', values=['x','y','z']),
        dict(name='dict', type='list', values={'x':1, 'y':3, 'z':7}),
        dict(name='bool', type='bool'),
        dict(name='color', type='color'),
    ]
    
    param = pt.Parameter.create(name='params', type='group', children=paramSpec)
    tree = pt.ParameterTree()
    tree.setParameters(param)

    all_objs = {
        'int0': 0, 'int':7, 'float': -0.35, 'bigfloat': 1e129, 'npfloat': np.float(5), 
        'npint': np.int(5),'npinf': np.inf, 'npnan': np.nan, 'bool': True, 
        'complex': 5+3j, 'str': 'xxx', 'unicode': asUnicode('µ'), 
        'list': [1,2,3], 'dict': {'1': 2}, 'color': pg.mkColor('k'), 
        'brush': pg.mkBrush('k'), 'pen': pg.mkPen('k'), 'none': None
    }
    if hasattr(QtCore, 'QString'):
        all_objs['qstring'] = QtCore.QString('xxxµ')

    # float
    types = ['int0', 'int', 'float', 'bigfloat', 'npfloat', 'npint', 'npinf', 'npnan', 'bool']
    check_param_types(param.child('float'), float, float, 0.0, all_objs, types)

    # int
    types = ['int0', 'int', 'float', 'bigfloat', 'npfloat', 'npint', 'bool']
    inttyps = int if sys.version[0] >= '3' else (int, long) 
    check_param_types(param.child('int'), inttyps, int, 0, all_objs, types)
    
    # str  (should be able to make a string out of any type)
    types = all_objs.keys()
    strtyp = str if sys.version[0] >= '3' else unicode
    check_param_types(param.child('str'), strtyp, asUnicode, '', all_objs, types)
    
    # bool  (should be able to make a boolean out of any type?)
    types = all_objs.keys()
    check_param_types(param.child('bool'), bool, bool, False, all_objs, types)

    # color
    types = ['color', 'int0', 'int', 'float', 'npfloat', 'npint', 'list']
    init = QtGui.QColor(128, 128, 128, 255)
    check_param_types(param.child('color'), QtGui.QColor, pg.mkColor, init, all_objs, types)
예제 #6
0
    def mouseMoved(self, pos):
        self.q = self._item.mapFromScene(pos)
        self._lastPos = self.q
        if (pg.Qt.QT_LIB == 'PyQt4'):
            message = QtCore.QString()
        else:
            message = str()
        if self._cmSpace:
            if type(message) != str:
                message.append("X: ")
                message.append("{0:.1f}".format(self.q.x() *
                                                self._geometry.wire2cm()))
            else:
                message += "X: "
                message += "{0:.1f}".format(self.q.x() *
                                            self._geometry.wire2cm())
        else:
            if type(message) != str:
                message.append("W: ")
                message.append(str(int(self.q.x())))
            else:
                message += "W: "
                message += str(int(self.q.x()))
        if self._cmSpace:
            if type(message) != str:
                message.append(", Y: ")
                message.append(
                    "{0:.1f}".format(self.q.y() * self._geometry.time2cm() -
                                     self._geometry.offset(self._plane)))
            else:
                message += ", Y: "
                message += "{0:.1f}".format(self.q.y() *
                                            self._geometry.time2cm() -
                                            self._geometry.offset(self._plane))
        else:
            if type(message) != str:
                message.append(", T: ")
                message.append(str(int(self.q.y())))
            else:
                message += ", T: "
                message += str(int(self.q.y()))

        # print message
        if self.q.x() > 0 and self.q.x() < self._geometry.wRange(self._plane):
            if self.q.y() > 0 and self.q.y() < self._geometry.tRange():
                self._statusBar.showMessage(message)
    def onMove(self, pos):
        act_pos = self.mapFromScene(pos)
        p1 = self.pointsAt(act_pos)
        # print ('onMove, act_pos', act_pos, 'p1', p1)
        if len(p1) != 0:

            opdet_id = p1[0].data()['id']
            opdet_name = self._opdets_name[opdet_id]

            if (pg.Qt.QT_LIB == 'PyQt4'):
                message = QtCore.QString()
            else:
                message = str()

            if type(message) != str:
                message.append("OpDetName: ")
                message.append(opdet_name)
                message.append(";   X: ")
                message.append("{0:.1f}".format(self._opdets_x[opdet_id]))
                message.append(";   Y: ")
                message.append("{0:.1f}".format(self._opdets_y[opdet_id]))
                message.append(";   Z: ")
                message.append("{0:.1f}".format(self._opdets_z[opdet_id]))
                message.append(";   OpCh: ")
                message.append("{0:.0f}".format(opdet_id))
            else:
                message += "OpDetName: "
                message += opdet_name
                message += ";   X: "
                message += "{0:.1f}".format(self._opdets_x[opdet_id])
                message += ";   Y: "
                message += "{0:.1f}".format(self._opdets_y[opdet_id])
                message += ";   Z: "
                message += "{0:.1f}".format(self._opdets_z[opdet_id])
                message += ";   OpCh: "
                message += "{0:.0f}".format(opdet_id)

            self._statusBar.showMessage(message)
예제 #8
0
                def load_assignment(assignment):
                    print "Loading assignment " + assignment.name

                    # Update current assignment and exercise
                    global current_assignment
                    current_assignment = assignment
                    global current_exercise
                    current_exercise = assignment.exercises[0]

                    # Load relevant instructions and background. Exercise 1 is loaded by default
                    instructions.load(
                        QtCore.QUrl.fromLocalFile(
                            os.getcwd() + os.sep +
                            current_exercise.instructions_url))
                    background.load(
                        QtCore.QUrl.fromLocalFile(os.getcwd() + os.sep +
                                                  assignment.background_url))

                    # Update info label
                    label.setText(current_exercise.name + ': ' +
                                  current_exercise.description)

                    # Generate exercise drop down menu
                    menubar = win.menuBar()
                    exerciseMenu = menubar.addMenu('&Exercises')

                    # Add exercises to menu
                    for e in assignment.exercises:
                        load_exercise_action = QtGui.QAction(
                            QtCore.QString(e.name), exerciseMenu)
                        load_exercise_action.setStatusTip('Load exercise ' +
                                                          e.name)

                        # What happens when we load an exercise from the drop down menu
                        def loadExercise(ex):
                            #Set info label
                            label.setText(ex.name + ': ' + ex.description)
                            # Set instructions
                            instructions.load(
                                QtCore.QUrl.fromLocalFile(os.getcwd() +
                                                          os.sep +
                                                          ex.instructions_url))
                            # Set window title
                            win.setWindowTitle('Sci edu ' + VERSION_ID + ": " +
                                               ex.name)

                        load_exercise_action.triggered.connect(
                            partial(loadExercise, e))

                        exerciseMenu.addAction(load_exercise_action)
                    # fileMenu.addAction(exitAction)
                    viewMenu = menubar.addMenu('&View')
                    # fileMenu.addAction(exitAction)
                    helpMenu = menubar.addMenu('&Help')

                    # Hide load window and show main window
                    win.setWindowTitle('Sci edu ' + VERSION_ID + ": " +
                                       current_exercise.name)
                    #win.show()
                    win.showMaximized()
                    load_window.hide()
예제 #9
0
 def open_project(self):
     self.pmanager = ProjectManager();
     self.ui.plotWidget.clear()
     self.ui.plotWidget.reset_annotation() #MGM(V0.2): For erasing annotations which have been loaded for previous files.
     filter_pname=QtCore.QString() #MGM(V0.2): The name of filter changed to filter_pname for removing the warning
     pname= str(QtGui.QFileDialog.getOpenFileName(self, 'Open Project', 'Projects','*.prj',filter_pname))
     
     # pass to project manager
     if pname:
         self.ui.markFinishButton.setDisabled(True)
         self.project_directory = os.path.dirname(pname)
         os.chdir(self.project_directory)
         # read the project
         self.pmanager.read(pname)    
         
         # ask for username and  "login"  the user (or add it  the list of users or close the project)
         while 1==1:
             text, ok = QtGui.QInputDialog.getText(self, 'Input Dialog','Enter your user-name:')
             if ok:
                 
                 username=str(text);
                 if username in self.pmanager.usernames or self.pmanager.project_info["add_new_user"] == True:
                     self.status = "project_open"
                 else:
                     self.status = "project_close"
                         
                 break;
             else:
                 choice = QtGui.QMessageBox.question(self, 'Message',"Do you want to continue?", QtGui.QMessageBox.Yes |QtGui.QMessageBox.No, QtGui.QMessageBox.No)
                 if choice == QtGui.QMessageBox.No:
                     self.status="project_close"
                     break;
         # return if the project is not open        
         if self.status == "project_close":        
             return 
         
         if username in self.pmanager.usernames:
                 choice = QtGui.QMessageBox.question(self, 'Message',"Are you "+self.pmanager.users[username]+"?", QtGui.QMessageBox.Yes |QtGui.QMessageBox.No, QtGui.QMessageBox.No)
                 if choice == QtGui.QMessageBox.Yes:
                     self.status="project_open"
                 else:
                     self.status="project_close"
                         
         elif self.pmanager.project_info["add_new_user"]:
                 while 1==1:
                     text, ok = QtGui.QInputDialog.getText(self, 'Input Dialog','Please, enter your first and last names:')
                     if ok:
                         self.pmanager.add_user(username,str(text))
                         break;
                     else:
                         choice = QtGui.QMessageBox.question(self, 'Message',"Do you want to continue?", QtGui.QMessageBox.Yes |QtGui.QMessageBox.No, QtGui.QMessageBox.No)
                         if choice == QtGui.QMessageBox.No:
                             self.status="project_close"
                             break;       
                 if self.status == "project_close":
                     return;    
         self.current_user = username;        
         # Now that user logged in successfully continue:
         # Create (if not existed) necessary directory structure (project_dir/username/root) and copy needed files
         self.pmanager.create_dir_structure(self.current_user)
         self.edfListUpdate();