コード例 #1
0
    def trackMouse(self):
        """
		Mouse position presentation in GUI
		TODO: after implementing workspace calibration
		display the world coordinates the mouse points to
		in the RGB video image.
		"""
        x = QWidget.mapFromGlobal(self, QCursor.pos()).x()
        y = QWidget.mapFromGlobal(self, QCursor.pos()).y()
        if ((x < MIN_X) or (x >= MAX_X) or (y < MIN_Y) or (y >= MAX_Y)):
            self.ui.rdoutMousePixels.setText("(-,-,-)")
            self.ui.rdoutMouseWorld.setText("(-,-,-)")
        else:
            x = x - MIN_X
            y = y - MIN_Y
            if (self.kinect.currentDepthFrame.any() != 0):
                z = self.kinect.currentDepthFrame[y][x]
                self.ui.rdoutMousePixels.setText("(%.0f,%.0f,%.0f)" %
                                                 (x, y, z))
                if (self.kinect.kinectCalibrated):
                    z_w = .1236 * np.tan(z / 2842.5 + 1.1863) - 0.94
                    xy_world = self.sm.worldCoordinates(x, y)
                    self.ui.rdoutMouseWorld.setText(
                        "(%.3f,%.3f,%.3f)" %
                        (xy_world[0], xy_world[1], xy_world[2]))
コード例 #2
0
    def eventFilter( self, obj, event ):
        if obj == self.sequencesTable.horizontalHeader():
            if event.type() == QEvent.HoverMove:
                newColumn = self.sequencesTable.horizontalHeader().logicalIndexAt( event.pos() )
                if newColumn != self.deleteColumn:
                    if not self.removeInputButton.isVisible() and newColumn >= 0:
                        self.removeInputButton.show()
                    elif self.removeInputButton.isVisible() and newColumn == -1:
                        self.removeInputButton.hide()
                    self.deleteColumn = newColumn
                    if newColumn >= 0:
                        x = sum( map( self.sequencesTable.columnWidth, range( self.deleteColumn + 1 ) ) ) - 20
                        if self.sequencesTable.rowCount() > 0:
                            x += 15
                        self.removeInputButton.move( x, 2 )
            elif event.type() == QEvent.HoverLeave:
                child = self.childAt( self.mapFromGlobal( QCursor.pos() ) )
                if not isinstance( child, QToolButton ):
                    self.removeInputButton.hide()
                    self.deleteColumn = -1
        elif obj == self.removeInputButton:
            if event.type() == QEvent.HoverLeave:
                child = self.childAt( self.mapFromGlobal( QCursor.pos() ) )
                if isinstance( child, QToolButton ):
                    self.removeInputButton.hide()
                    self.deleteColumn = -1

        return DesignerWidget.eventFilter( self, obj, event )
コード例 #3
0
 def paintEvent(self, event):
     if not self.tenant:
         return
     paint = QPainter(self)
     for e in self.tenant.edges:
             if e == self.selectedEdge:
                 paint.setPen(self.colors["selected"])
             else:
                 paint.setPen(self.colors["line"])
             self.drawArrow(paint, self.vertices[e.e1].x() + self.size / 2, self.vertices[e.e1].y() + self.size / 2,
                          self.vertices[e.e2].x() + self.size / 2, self.vertices[e.e2].y() + self.size / 2)
     for v in self.vertices.keys():
         pen = paint.pen()
         paint.setPen(Qt.red)
         if self.selectedVertex == self.vertices[v]:
             paint.drawRect(self.vertices[v])
         if isinstance(v, VM):
             paint.drawImage(self.vertices[v], self.computericon)
         elif isinstance(v, Storage):
             paint.drawImage(self.vertices[v], self.storageicon)
         elif isinstance(v, NetElement):
             if v.router:
                 paint.drawImage(self.vertices[v], self.routericon)
             else:
                 paint.drawImage(self.vertices[v], self.switchicon)
         elif isinstance(v, Vnf):
             paint.drawImage(self.vertices[v], self.serviceicon)
         elif isinstance(v, Domain):
             paint.drawImage(self.vertices[v], self.domainicon)
     paint.setPen(self.colors["line"])
     if self.edgeDraw:
         self.drawArrow(paint, self.curEdge[0].x() + self.size / 2, self.curEdge[0].y() + self.size / 2,
                        QCursor.pos().x() - self.mapToGlobal(self.geometry().topLeft()).x(),
                        QCursor.pos().y() - self.mapToGlobal(self.geometry().topLeft()).y())
     paint.end()
コード例 #4
0
 def paintEvent(self, event):
     if not self.demand:
         return
     paint = QPainter(self)
     for e in self.demand.edges:
             if e == self.selectedEdge:
                 paint.setPen(self.colors["selected"])
             else:
                 paint.setPen(self.colors["line"])
             self.drawArrow(paint, self.vertices[e.e1].x() + self.size / 2, self.vertices[e.e1].y() + self.size / 2,
                          self.vertices[e.e2].x() + self.size / 2, self.vertices[e.e2].y() + self.size / 2)
     for v in self.vertices.keys():
         if isinstance(v,VM):
             if self.selectedVertex != self.vertices[v]:
                 paint.drawImage(self.vertices[v], self.computericon)
             else:
                 paint.drawImage(self.vertices[v], self.computerselectedicon)
         elif isinstance(v,DemandStorage):
             if self.selectedVertex != self.vertices[v]:
                 paint.drawImage(self.vertices[v], self.storageicon)
             else:
                 paint.drawImage(self.vertices[v], self.storageselectedicon)
     paint.setPen(self.colors["line"])
     if self.edgeDraw:
         self.drawArrow(paint, self.curEdge[0].x() + self.size / 2, self.curEdge[0].y() + self.size / 2,
                        QCursor.pos().x() - self.mapToGlobal(self.geometry().topLeft()).x(),
                        QCursor.pos().y() - self.mapToGlobal(self.geometry().topLeft()).y())
     paint.end()
コード例 #5
0
ファイル: todo_list.py プロジェクト: OSUser/quickpanel
 def onTodoListContextMenuReqeusted(self, pos):
     index = self.tvTodoList.indexAt(pos)
     if index.isValid():
         self.tvTodoList.setCurrentIndex(index)
     menu = QMenu()
     if index.isValid():
         task = self.todoListModel.taskAt(index)
         if task["finishment"] == 0:
             menu.addAction(self.actionMarkProcessing)
             menu.addAction(self.actionMarkFinished)
         elif task["finishment"] < 100:
             menu.addAction(self.actionMarkUnfinished)
             menu.addAction(self.actionMarkFinished)
         else:
             menu.addAction(self.actionMarkUnfinished)
             menu.addAction(self.actionMarkProcessing)
     menu.addSeparator()
     menu.addAction(self.actionCreateTodo)
     if index.isValid():
         menu.addAction(self.actionRemoveTodo)
         menu.addAction(self.actionModifyTodoSubject)
         menu.addAction(self.actionEditTodo)
     try:
         getattr(menu, "exec")(QCursor.pos())
     except AttributeError:
         getattr(menu, "exec_")(QCursor.pos())
コード例 #6
0
    def trackMouse(self):
        """ 
        Mouse position presentation in GUI
        TODO: after implementing workspace calibration 
        display the world coordinates the mouse points to 
        in the RGB video image.
        """

        x = QWidget.mapFromGlobal(self, QCursor.pos()).x()
        y = QWidget.mapFromGlobal(self, QCursor.pos()).y()
        if ((x < MIN_X) or (x >= MAX_X) or (y < MIN_Y) or (y >= MAX_Y)):
            self.ui.rdoutMousePixels.setText("(-,-,-)")
            self.ui.rdoutMouseWorld.setText("(-,-,-)")
        else:
            x = x - MIN_X
            y = y - MIN_Y
            if (self.kinect.currentDepthFrame.any() != 0):
                z = self.kinect.currentDepthFrame[y][x]
                self.ui.rdoutMousePixels.setText("(%.0f,%.0f,%.0f)" %
                                                 (x, y, z))
                #convert camera data to depth in mm
                depth = 1000 * 0.1236 * np.tan(z / 2842.5 + 1.1863)

                # if self.kinect.kinectCalibrated == True :
                world_frame = depth * np.dot(self.kinect.projection, [x, y, 1])
                #To convert depth to IK convention
                world_frame[2] = -world_frame[2] + 939
                self.ui.rdoutMouseWorld.setText(
                    "(%.0f,%.0f,%.0f)" %
                    (world_frame[0], world_frame[1], world_frame[2]))
                self.kinect.world_frame = world_frame  # use this variable in click and grab
コード例 #7
0
    def trackMouse(self):
        """
        Mouse position presentation in GUI
        TODO: Display the rgb/hsv value
        """

        x = QWidget.mapFromGlobal(self, QCursor.pos()).x()
        y = QWidget.mapFromGlobal(self, QCursor.pos()).y()
        if ((x < MIN_X) or (x >= MAX_X) or (y < MIN_Y) or (y >= MAX_Y)):
            self.ui.rdoutMousePixels.setText("(-,-,-)")
            self.ui.rdoutRGB.setText("(-,-,-)")
        else:
            x = x - MIN_X
            y = y - MIN_Y
            self.ui.rdoutMousePixels.setText("(%.0f,%.0f,-)" % (x, y))

            try:
                rgb = self.rgb_image[y, x]  # [r, g, b] of this pixel
            except TypeError:
                # get None for rgb_image
                print("trackMouse(): Didn't get RGB value")
                return

            hsv_image = cv2.cvtColor(self.rgb_image, cv2.COLOR_RGB2HSV)
            hsv = hsv_image[y, x]
            # print(hsv_image)
            # self.ui.rdoutRGB.setText("({},{},{})".format(rgb[0], rgb[1], rgb[2]))

            self.ui.rdoutRGB.setText("({},{},{})".format(
                hsv[0], hsv[1], hsv[2]))
コード例 #8
0
ファイル: control_station.py プロジェクト: tyz1030/robotArm
    def trackMouse(self):
        """ 
        Mouse position presentation in GUI
        TODO: after implementing workspace calibration 
        display the world coordinates the mouse points to 
        in the RGB video image.
        """

        x = QWidget.mapFromGlobal(self, QCursor.pos()).x()
        y = QWidget.mapFromGlobal(self, QCursor.pos()).y()
        if ((x < MIN_X) or (x >= MAX_X) or (y < MIN_Y) or (y >= MAX_Y)):
            self.ui.rdoutMousePixels.setText("(-,-,-)")
            self.ui.rdoutMouseWorld.setText("(-,-,-)")
        else:
            x = x - MIN_X
            y = y - MIN_Y
            """color calibration"""
            #color = self.kinect.colorDetector(x,y)
            #self.kinect.colorCalibration(x,y)
            #self.kinect.block_detection_verification(x,y)
            # map real world
            real_x = self.kinect.real_coord[x][y][0]
            real_y = self.kinect.real_coord[x][y][1]

            if (self.kinect.currentDepthFrame.any() != 0):
                z = self.kinect.currentDepthFrame[y][x]
                real_z = self.kinect.convertDepthtomm(z)
                self.ui.rdoutMousePixels.setText("(%.0f,%.0f,%.0f)" %
                                                 (x, y, z))
                if self.kinect.kinectCalibrated == True:
                    self.ui.rdoutMouseWorld.setText("(%.0f,%.0f,%.0f)" %
                                                    (real_x, real_y, real_z))
                else:
                    self.ui.rdoutMouseWorld.setText("(-,-,-)")
コード例 #9
0
ファイル: todo_list.py プロジェクト: OSUser/quickpanel
 def onTodoListContextMenuReqeusted(self, pos):
     index = self.tvTodoList.indexAt(pos)
     if index.isValid():
         self.tvTodoList.setCurrentIndex(index)
     menu = QMenu()
     if index.isValid():
         task = self.todoListModel.taskAt(index)
         if task["finishment"] == 0:
             menu.addAction(self.actionMarkProcessing)
             menu.addAction(self.actionMarkFinished)
         elif task["finishment"] < 100:
             menu.addAction(self.actionMarkUnfinished)
             menu.addAction(self.actionMarkFinished)
         else:
             menu.addAction(self.actionMarkUnfinished)
             menu.addAction(self.actionMarkProcessing)
     menu.addSeparator()
     menu.addAction(self.actionCreateTodo)
     if index.isValid():
         menu.addAction(self.actionRemoveTodo)
         menu.addAction(self.actionModifyTodoSubject)
         menu.addAction(self.actionEditTodo)
     try:
         getattr(menu, "exec")(QCursor.pos())
     except AttributeError:
         getattr(menu, "exec_")(QCursor.pos())
コード例 #10
0
    def trackMouse(self):
        """ 
        Mouse position presentation in GUI
        TODO: after implementing workspace calibration 
        display the world coordinates the mouse points to 
        in the RGB video image.
        """

        x = QWidget.mapFromGlobal(self, QCursor.pos()).x()
        y = QWidget.mapFromGlobal(self, QCursor.pos()).y()
        if ((x < MIN_X) or (x >= MAX_X) or (y < MIN_Y) or (y >= MAX_Y)):
            self.ui.rdoutMousePixels.setText("(-,-,-)")
            self.ui.rdoutMouseWorld.setText("(-,-,-)")
        else:
            x = x - MIN_X
            y = y - MIN_Y
            if (self.kinect.currentDepthFrame.any() != 0):
                z = self.kinect.currentDepthFrame[y][x]
                self.ui.rdoutMousePixels.setText("(%.0f,%.0f,%.0f)" %
                                                 (x, y, z))

                if not self.kinect.kinectCalibrated:
                    self.ui.rdoutMouseWorld.setText("(-,-,-)")
                else:
                    w_x, w_y, w_z = self.kinect.toWorldCoord(x, y, z)
                    self.ui.rdoutMouseWorld.setText("(%.1f,%.1f,%.1f)" %
                                                    (w_x, w_y, w_z))
コード例 #11
0
    def eventFilter(self, obj, event):
        if obj == self.sequencesTable.horizontalHeader():
            if event.type() == QEvent.HoverMove:
                newColumn = self.sequencesTable.horizontalHeader(
                ).logicalIndexAt(event.pos())
                if newColumn != self.deleteColumn:
                    if not self.removeInputButton.isVisible(
                    ) and newColumn >= 0:
                        self.removeInputButton.show()
                    elif self.removeInputButton.isVisible(
                    ) and newColumn == -1:
                        self.removeInputButton.hide()
                    self.deleteColumn = newColumn
                    if newColumn >= 0:
                        x = sum(
                            map(self.sequencesTable.columnWidth,
                                range(self.deleteColumn + 1))) - 20
                        if self.sequencesTable.rowCount() > 0:
                            x += 15
                        self.removeInputButton.move(x, 2)
            elif event.type() == QEvent.HoverLeave:
                child = self.childAt(self.mapFromGlobal(QCursor.pos()))
                if not isinstance(child, QToolButton):
                    self.removeInputButton.hide()
                    self.deleteColumn = -1
        elif obj == self.removeInputButton:
            if event.type() == QEvent.HoverLeave:
                child = self.childAt(self.mapFromGlobal(QCursor.pos()))
                if isinstance(child, QToolButton):
                    self.removeInputButton.hide()
                    self.deleteColumn = -1

        return DesignerWidget.eventFilter(self, obj, event)
コード例 #12
0
 def paintEvent(self, event):
     if not self.resources:
         return
     paint = QPainter(self)
     for e in self.resources.edges:
             if e == self.selectedEdge:
                 paint.setPen(self.colors["selected"])
             else:
                 paint.setPen(self.colors["line"])
             self.drawArrow(paint, self.vertices[e.e1].x() + self.size / 2, self.vertices[e.e1].y() + self.size / 2,
                          self.vertices[e.e2].x() + self.size / 2, self.vertices[e.e2].y() + self.size / 2)
     for v in self.vertices.keys():
         if isinstance(v, Computer):
             if self.selectedVertex != self.vertices[v]:
                 paint.drawImage(self.vertices[v], self.computericon)
             else:
                 paint.drawImage(self.vertices[v], self.computerselectedicon)
         elif isinstance(v, Storage):
             if self.selectedVertex != self.vertices[v]:
                 paint.drawImage(self.vertices[v], self.storageicon)
             else:
                 paint.drawImage(self.vertices[v], self.storageselectedicon)
         elif isinstance(v, Router):
             if self.selectedVertex != self.vertices[v]:
                 paint.drawImage(self.vertices[v], self.routericon)
             else:
                 paint.drawImage(self.vertices[v], self.routerselectedicon)
     paint.setPen(self.colors["line"])
     if self.edgeDraw:
         self.drawArrow(paint, self.curEdge[0].x() + self.size / 2, self.curEdge[0].y() + self.size / 2,
                        QCursor.pos().x() - self.mapToGlobal(self.geometry().topLeft()).x(),
                        QCursor.pos().y() - self.mapToGlobal(self.geometry().topLeft()).y())
     paint.end()
コード例 #13
0
ファイル: control_station.py プロジェクト: zli91/armlab-F18
    def trackMouse(self):
        """ 
        Mouse position presentation in GUI
        After implementing workspace calibration 
        display the world coordinates the mouse points to 
        in the RGB video image.
        """

        x = QWidget.mapFromGlobal(self,QCursor.pos()).x()
        y = QWidget.mapFromGlobal(self,QCursor.pos()).y()
        if ((x < MIN_X) or (x >= MAX_X) or (y < MIN_Y) or (y >= MAX_Y)):
            self.ui.rdoutMousePixels.setText("(-,-,-)")
            self.ui.rdoutMouseWorld.setText("(-,-,-)")
        else:
            x = x - MIN_X
            y = y - MIN_Y
            if(self.kinect.currentDepthFrame.any() != 0):
                z = self.kinect.currentDepthFrame[y][x]
                mouse_coord = [x,y,1]
                # affine = [[1,1,1],[1,1,1],[0,0,1]]
                
                self.ui.rdoutMousePixels.setText("(%.0f,%.0f,%.0f)" % (x,y,z))
                if (self.kinect.kinectCalibrated):
                    # Z = self.kinect.worldHeight - 0.1236 * 1000 * np.tan(z/2842.5 + 1.1863)
                    # world_coord = np.matmul(self.kinect.convert_to_world, mouse_coord)
                    world_coord = self.kinect.world_coord(x,y)
                    self.ui.rdoutMouseWorld.setText("(%.0f,%.0f,%.0f)" % (world_coord[0],world_coord[1],world_coord[2]))
                else:
                    self.ui.rdoutMouseWorld.setText("(-,-,-)")
コード例 #14
0
ファイル: popup.py プロジェクト: elanifegnirf/Snippets
	def show(self):
		"""
		This method reimplements the :meth:`QWidget.show` method.
		"""
		
		self.move(QCursor.pos().x() - self.width() / 2, QCursor.pos().y() - self.height() / 2)
		self.Interfaces_lineEdit.setText(RuntimeGlobals.popupPattern or QString())
		self.Interfaces_lineEdit.setFocus()
		super(Popup, self).show()
コード例 #15
0
 def broadTheMousePos(self):
     currentPosX = QCursor.pos().x()
     currentPosY = QCursor.pos().y()
     msg = "mousepos#" + str(currentPosX) + "#" + str(currentPosY)
     if self.currentPosMsg != msg:
         self.currentPosMsg = msg
         self.udpSocketTwo.writeDatagram(msg, self.mcast_addr_two, self.porttwo)
     else:
         pass
コード例 #16
0
ファイル: GraphCanvas.py プロジェクト: DanielZorin/movepoint
    def paintEvent(self, event):
        if not self.program:
            return
        # TODO: get rid of this call
        #self.ResizeCanvas()
        paint = QPainter(self)
        paint.setPen(self.colors["line"])
        paint.setFont(QtGui.QFont('Decorative', 10))
        for e in self.program.edges:
            if e != self.selectedEdge:
                self.drawArrow(
                    paint, self.vertices[e.source].x() + self.size / 2,
                    self.vertices[e.source].y() + self.size / 2,
                    self.vertices[e.destination].x() + self.size / 2,
                    self.vertices[e.destination].y() + self.size / 2)
            else:
                paint.setPen(self.colors["selected"])
                paint.setBrush(self.colors["selected"])
                self.drawArrow(
                    paint, self.vertices[e.source].x() + self.size / 2,
                    self.vertices[e.source].y() + self.size / 2,
                    self.vertices[e.destination].x() + self.size / 2,
                    self.vertices[e.destination].y() + self.size / 2)
                paint.setPen(self.colors["line"])
                paint.setBrush(self.colors["line"])

        paint.setPen(self.colors["vertex"])
        paint.setBrush(self.colors["vertex"])
        for task in self.vertices.values():
            if task == self.selectedVertex:
                paint.setPen(self.colors["selected"])
                paint.setBrush(self.colors["selected"])
                paint.drawEllipse(task)
                paint.setPen(self.colors["vertex"])
                paint.setBrush(self.colors["vertex"])
            else:
                paint.drawEllipse(task)

        paint.setPen(self.colors["text"])
        for v in self.vertices.keys():
            task = self.vertices[v]
            paint.drawText(task.center().x() - 2,
                           task.center().y() + 5, str(v.number))
            paint.drawText(task.topRight().x(),
                           task.topRight().y() + 5, str(v.name))

        paint.setPen(self.colors["line"])
        if self.edgeDraw:
            self.drawArrow(
                paint, self.curEdge[0].x() + self.size / 2,
                self.curEdge[0].y() + self.size / 2,
                QCursor.pos().x() -
                self.mapToGlobal(self.geometry().topLeft()).x(),
                QCursor.pos().y() -
                self.mapToGlobal(self.geometry().topLeft()).y())
        paint.end()
コード例 #17
0
ファイル: popup.py プロジェクト: ogre/Snippets
    def show(self):
        """
		Reimplements the :meth:`QWidget.show` method.
		"""

        self.move(QCursor.pos().x() - self.width() / 2,
                  QCursor.pos().y() - self.height() / 2)
        self.Interfaces_lineEdit.setText(RuntimeGlobals.popupPattern
                                         or QString())
        self.Interfaces_lineEdit.setFocus()
        super(Popup, self).show()
コード例 #18
0
ファイル: user_input.py プロジェクト: Chazzz/Dota2AI2016
def click(event, x, y, tries=0):
    'use QCursor to lazily move mouse'
    pos = QCursor.pos()
    device.emit(uinput.REL_X, x-pos.x(), syn = False)
    device.emit(uinput.REL_Y, y-pos.y())
    newpos = QCursor.pos()
    if newpos.x() != x or newpos.y() != y:
        raise Exception("Failed to move to (%s, %s) on first try" % (x, y))
    time.sleep(0.01) #minimap misclick time
    device.emit_click(event)
    return 0
コード例 #19
0
    def trackMouse(self):
        """ 
        Mouse position presentation in GUI
        TODO: after implementing workspace calibration 
        display the world coordinates the mouse points to 
        in the RGB video image.
        """

        x = QWidget.mapFromGlobal(self, QCursor.pos()).x()
        y = QWidget.mapFromGlobal(self, QCursor.pos()).y()
        if ((x < MIN_X) or (x >= MAX_X) or (y < MIN_Y) or (y >= MAX_Y)):
            self.ui.rdoutMousePixels.setText("(-,-,-)")
            self.ui.rdoutMouseWorld.setText("(-,-,-)")
        else:
            x = x - MIN_X
            y = y - MIN_Y
            if (self.kinect.currentDepthFrame.any() != 0):
                d = self.kinect.currentDepthFrame[y][x]  # depth value
                d = np.clip(d, 0, 2**10 - 1)
                Zc = 0.1236 * math.tan(d / 2842.5 + 1.1863)
                # print Zc
                # print('----control station intrinsic_matrix')
                # print self.kinect.intrinsic_matrix
                XYZ_camera = Zc * np.matmul(
                    np.linalg.inv(self.kinect.intrinsic_matrix),
                    np.array([x, y, 1]))
                # print('----control station co_eff_camera_2_world')
                # print self.kinect.co_eff_camera_2_world
                W = np.matmul(self.kinect.co_eff_camera_2_world,
                              np.append(XYZ_camera, 1))
                self.ui.rdoutMousePixels.setText("(%.0f,%.0f,%.0f)" %
                                                 (x, y, d))

                # W = np.matmul(self.sm.coeff_rgb_2_world, np.array([x, y, 1]))
                #linear fitting
                # d = 2047-z
                # 2047 - 718 --> 0
                # 2047 - 705 --> 38
                # 2047 - 688 --> 38*2
                # 2047 - 668 --> 38*3
                # 2047 - 646 --> 38*4
                # 2047 - 624 --> 38*5
                # 2047 - 598 --> 38*6
                # 2047 - 570 --> 38*7
                # 2047 - 538 --> 38*8
                # 2047 - 501 --> 38*9
                # 2047 - 462 --> 38*10
                # need better calibration function

                # W[2] =  (8.00506778e-06)*d**3-(3.79099906e-02)*d**2 + (6.08296089e+01)*d - (3.26712433e+04)
                #W[2] = (1.46565657e+00)*d - (1.91508256e+03)
                #W[2] = (-4.15178471e-08)*d**4 + (2.49769770e-04)*d**3 - (5.65159066e-01)*d**2 + (5.71205622e+02)*d - (2.17696573e+05)
                self.ui.rdoutMouseWorld.setText("(%.0f,%.0f,%.0f)" %
                                                (W[0], W[1], W[2]))
コード例 #20
0
def mouse_move(target):
    """moves the mouse cursor to the coordinates of 'target' by a continous
    movement.  Coordinates are relative to the main window"""
    pos = win.mapFromGlobal(QCursor.pos())
    start = [pos.x(), pos.y()]
    n = max(int(time * 25), 5)
    for i in range(0, n + 1):
        pos = [start[j] + (target[j] - start[j]) / n * i for j in range(2)]
        widget = app._qapp.widgetAt(QCursor.pos()) or win
        QTest.mouseMove(widget,
                        win.mapToGlobal(widget.mapFromGlobal(QPoint(*pos))),
                        time)
コード例 #21
0
ファイル: reporteditor.py プロジェクト: vertrex/DFF
 def mousePressEvent(self, e):
     QTreeWidget.mousePressEvent(self, e)
     index = self.indexAt(e.pos())
     if index.isValid():
         item = self.itemAt(e.pos())
         if e.button() == Qt.LeftButton:
             self.emit(SIGNAL("itemClicked"), item)
         elif e.button() == Qt.RightButton:
             self.treeItemMenu.popup(QCursor.pos())
     else:
         if e.button() == Qt.RightButton:
             self.treeNewItemMenu.popup(QCursor.pos())
コード例 #22
0
ファイル: imageviewer.py プロジェクト: vertrex/DFF
 def mouseReleaseEvent(self, event):
     if not self.rubberBand.size().isEmpty():
         rect = QRect(self.rubberBand.pos(), self.rubberBand.size())
         rect.moveLeft(rect.left() -
                       (self.width() - self.pixmap().width()) / 2.0)
         rect.moveTop(rect.top() -
                      (self.height() - self.pixmap().height()) / 2.0)
         self.currentSelection = rect
         self.copySelectionMenu.popup(QCursor.pos())
     else:
         self.copyMenu.popup(QCursor.pos())
     self.rubberBand.hide()
コード例 #23
0
 def showContextMenu(self):
     """Called when the user right-clicks or presses the context menu key."""
     pos = self.view.mapToGlobal(QPoint(0, 0))
     link, cursor = None, None
     # mouse inside view?
     if self.view.mapFromGlobal(QCursor.pos()) in self.view.viewport().rect():
         pos = QCursor.pos()
         pos_in_surface = self.view.surface().mapFromGlobal(pos)
         page, link = self.view.surface().pageLayout().linkAt(pos_in_surface)
         if link:
             cursor = self._links.cursor(link, True)
     from . import contextmenu
     contextmenu.show(pos, self.parent(), link, cursor)
コード例 #24
0
    def trackMouse(self):
        """
        Mouse position presentation in GUI
        TODO: Display the rgb/hsv value
        """

        x = QWidget.mapFromGlobal(self, QCursor.pos()).x()
        y = QWidget.mapFromGlobal(self, QCursor.pos()).y()
        if ((x < MIN_X) or (x >= MAX_X) or (y < MIN_Y) or (y >= MAX_Y)):
            self.ui.rdoutMousePixels.setText("(-,-,-)")
            self.ui.rdoutRGB.setText("(-,-,-)")
        else:
            x = x - MIN_X
            y = y - MIN_Y
            self.ui.rdoutMousePixels.setText("(%.0f,%.0f,-)" % (x, y))
コード例 #25
0
 def showContextMenu(self):
     """Called when the user right-clicks or presses the context menu key."""
     pos = self.view.mapToGlobal(QPoint(0, 0))
     link, cursor = None, None
     # mouse inside view?
     if self.view.mapFromGlobal(
             QCursor.pos()) in self.view.viewport().rect():
         pos = QCursor.pos()
         pos_in_surface = self.view.surface().mapFromGlobal(pos)
         page, link = self.view.surface().pageLayout().linkAt(
             pos_in_surface)
         if link:
             cursor = self._links.cursor(link, True)
     from . import contextmenu
     contextmenu.show(pos, self.parent(), link, cursor)
コード例 #26
0
    def process_custom_menu(self, point):
        ''' See XmlController for documentation '''
        item = self.select_item_at(point)
        if not item:
            return
        menu = QMenu()
        node = item.node

        if node.get('executable') == 'True':
            menu.addAction(self.actRunScenario)
        elif node.get('type') in ['selectable', 'model_choice']:
            menu.addAction(self.actMoveNodeUp)
            menu.addAction(self.actMoveNodeDown)
        elif node.tag == 'models_to_run': # special case of a selectable list
            models_menu = QMenu(menu)
            models_menu.setTitle('Add model to run')
            models_menu.setIcon(IconLibrary.icon('add'))
            available_model_names = get_model_names(self.project)
            for model_name in available_model_names:
                cb = lambda x = model_name, y = self.selected_index(): self.addModel(y, x)
                action = self.create_action('model', model_name, cb)
                models_menu.addAction(action)
            menu.addMenu(models_menu)

        self.add_default_menu_items_for_node(node, menu)

        if not menu.isEmpty():
            menu.exec_(QCursor.pos())
コード例 #27
0
    def _menu_context_tree(self, point, isRoot=False, root_path=None):
        index = self.indexAt(point)
        if not index.isValid() and not isRoot:
            return

        handler = None
        menu = QMenu(self)
        if isRoot or self.model().isDir(index):
            self._add_context_menu_for_folders(menu, isRoot, root_path)
        else:
            filename = self.model().fileName(index)
            lang = file_manager.get_file_extension(filename)
            self._add_context_menu_for_files(menu, lang)
        if isRoot:
            #get the extra context menu for this projectType
            handler = settings.get_project_type_handler(
                self.project.project_type)
            self._add_context_menu_for_root(menu)

        menu.addMenu(self._folding_menu)

        #menu for the Project Type(if present)
        if handler:
            for m in handler.get_context_menus():
                if isinstance(m, QMenu):
                    menu.addSeparator()
                    menu.addMenu(m)
        #show the menu!
        menu.exec_(QCursor.pos())
コード例 #28
0
ファイル: container.py プロジェクト: urkh/Turpial
 def __link_clicked(self, url):
     if url == 'cmd:add_columns':
         self.base.show_column_menu(QCursor.pos())
     elif url == 'cmd:add_accounts':
         self.base.show_accounts_dialog()
     elif url == 'cmd:restart':
         self.base.restart()
コード例 #29
0
def showContextMenu(self):
    opts = [
        [_("Mark Note"), "*", self.onMark],
        [_("Bury Note"), "-", self.onBuryNote],
        [_("Suspend Card"), "@", self.onSuspendCard],
        [_("Suspend Note"), "!", self.onSuspend],
        [_("Delete Note"), "Delete", self.onDelete],
        [_("Options"), "O", self.onOptions],
        None,
        [_("Replay Audio"), "R", self.replayAudio],
        [_("Record Own Voice"), "Shift+V", self.onRecordVoice],
        [_("Replay Own Voice"), "V", self.onReplayRecorded],
    ]
    m = QMenu(self.mw)
    for row in opts:
        if not row:
            m.addSeparator()
            continue
        label, scut, func = row
        a = m.addAction(label)
        a.setShortcut(QKeySequence(scut))
        a.connect(a, SIGNAL("triggered()"), func)
        #Only change is the following statement
    runHook("Reviewer.contextMenuEvent", self, m)
    m.exec_(QCursor.pos())
コード例 #30
0
ファイル: Mobile.py プロジェクト: eagle842/extensivetesting
 def onContextMenuEvent(self, event):
     """
     On context menu event
     """
     menu = QMenu(self)
     menu.addAction(self.copyAction)
     menu.popup(QCursor.pos())
コード例 #31
0
    def _menu_context_tree(self, point):
        index = self.indexAt(point)
        if not index.isValid():
            return

        item = self.itemAt(point)
        handler = None
        menu = QMenu(self)
        if item.isFolder or item.parent() is None:
            self._add_context_menu_for_folders(menu, item)
        elif not item.isFolder:
            self._add_context_menu_for_files(menu, item)
        if item.parent() is None:
            #get the extra context menu for this projectType
            handler = settings.get_project_type_handler(item.projectType)
            self._add_context_menu_for_root(menu, item)

        menu.addMenu(self._folding_menu)

        #menu for all items (legacy API)!
        extra_menus = self.extra_menus.get('all', ())
        #menu for all items!
        for m in extra_menus:
            if isinstance(m, QMenu):
                menu.addSeparator()
                menu.addMenu(m)
        #menu for the Project Type(if present)
        if handler:
            for m in handler.get_context_menus():
                if isinstance(m, QMenu):
                    menu.addSeparator()
                    menu.addMenu(m)
        #show the menu!
        menu.exec_(QCursor.pos())
コード例 #32
0
    def selectOutput(self):
        if isinstance(self.output, OutputDirectory):
            self.selectDirectory()
        else:
            popupMenu = QMenu()

            actionSaveToTempFile = QAction(
                self.tr('Save to a temporary file'), self.btnSelect)
            actionSaveToTempFile.triggered.connect(self.saveToTemporaryFile)
            popupMenu.addAction(actionSaveToTempFile)

            actionSaveToFile = QAction(
                self.tr('Save to file...'), self.btnSelect)
            actionSaveToFile.triggered.connect(self.selectFile)
            popupMenu.addAction(actionSaveToFile)

            if isinstance(self.output, OutputVector) \
                    and self.alg.provider.supportsNonFileBasedOutput():
                actionSaveToMemory = QAction(
                    self.tr('Save to memory layer'), self.btnSelect)
                actionSaveToMemory.triggered.connect(self.saveToMemory)
                popupMenu.addAction(actionSaveToMemory)
                actionSaveToPostGIS = QAction(
                    self.tr('Save to PostGIS table...'), self.btnSelect)
                actionSaveToPostGIS.triggered.connect(self.saveToPostGIS)
                settings = QSettings()
                settings.beginGroup('/PostgreSQL/connections/')
                names = settings.childGroups()
                settings.endGroup()
                actionSaveToPostGIS.setEnabled(bool(names))
                popupMenu.addAction(actionSaveToPostGIS)

            popupMenu.exec_(QCursor.pos())
コード例 #33
0
ファイル: toolkit.py プロジェクト: davidmorrill/facets
    def mouse_position ( self ):
        """ Returns the current mouse position (in screen coordinates) as a
            tuple of the form: (x,y).
        """
        position = QCursor.pos()

        return ( position.x(), position.y() )
コード例 #34
0
ファイル: eventRecorder.py プロジェクト: bheuer/ilastik
 def _shouldSaveEvent(self, event):
     if isinstance(event, QMouseEvent):
         # Ignore most mouse movement events if the user isn't pressing anything.
         if event.type() == QEvent.MouseMove \
             and int(event.button()) == 0 \
             and int(event.buttons()) == 0 \
             and int(event.modifiers()) == 0:
             # Somewhat hackish (and slow), but we have to record mouse movements during combo box usage.
             # Same for QMenu usage (on Mac, it doesn't seem to matter, but on Fedora it does matter.)
             widgetUnderCursor = QApplication.instance().widgetAt( QCursor.pos() )
             if widgetUnderCursor is not None and widgetUnderCursor.objectName() == "qt_scrollarea_viewport":
                 return has_ancestor(widgetUnderCursor, QComboBox)
             if isinstance(widgetUnderCursor, QMenu):
                 return True 
             return False
         else:
             return True
     
     # Ignore non-spontaneous events
     if not event.spontaneous():
         return False
     if event.type() in self.IgnoredEventTypes:
         return False
     if isinstance(event, self.IgnoredEventClasses):
         return False
     return True
コード例 #35
0
    def right_click(self, type, champ):
        u"Retourne une fonction qui sera executée lors d'un clic droit sur le champ 'champ'."
        champ.setFocus()
        plusieurs = isinstance(type, list)
        if plusieurs:
            type = type[0]
        liste_objets = self.onglet_actuel.feuille_actuelle.objets.lister(False, type = type)
        liste_objets.sort(key = attrgetter('nom')) # ordre alphabétique
        if not liste_objets:
            return
        menu = QMenu()

        for obj in liste_objets:
            action = menu.addAction(obj.nom_complet)
            action.nom = obj.nom

        action = menu.exec_(QCursor.pos())
        if action:
            if plusieurs:
                # le champ doit contenir non pas un objet, mais une liste d'objets
                val = champ.text().strip()
                if val:
                    if not val.endswith(","):
                        val += ","
                    val += " "
                champ.setText(val + action.nom)
            else:
                # le champ contient un seul objet
                champ.setText(action.nom)
コード例 #36
0
    def process_custom_menu(self, position):
        self.currentColumn = self.treeview.indexAt(position).column()
        self.currentIndex = self.treeview.indexAt(position)

        self.menu = QMenu(self.treeview)

        if self.currentIndex.isValid():
            if self.model.fileInfo(self.currentIndex).suffix() == "txt":
                self.menu.addAction(self.actOpenTextFile)
            else:
                # Do stuff for directories
                export_choices, import_choices = self.fillInAvailableTools()

                if self.classification == "dataset" or self.classification == "database" or self.classification == "database_collection":
                    self.export_menu = QMenu(
                        QString('Export Opus %s to' % self.classification),
                        self.treeview)
                    self.export_menu.setIcon(IconLibrary.icon('export'))
                    self.import_menu = QMenu(
                        QString('Import Opus %s from' % self.classification),
                        self.treeview)
                    self.import_menu.setIcon(IconLibrary.icon('import'))

                    if len(export_choices) > 0:
                        self.export_dynactions = {}
                        for export_type, tool_node in export_choices.iteritems(
                        ):
                            dynaction = QAction(
                                IconLibrary.icon('spreadsheet'), export_type,
                                self.treeview)
                            self.export_menu.addAction(dynaction)
                            self.export_dynactions[export_type] = tool_node
                        QObject.connect(self.export_menu,
                                        SIGNAL("triggered(QAction*)"),
                                        self.dataActionMenuFunctionExport)
                        self.menu.addMenu(self.export_menu)

                    if len(import_choices) > 0:
                        self.import_dynactions = {}
                        for import_type, tool_node in import_choices.iteritems(
                        ):
                            dynaction = QAction(
                                IconLibrary.icon('spreadsheet'), import_type,
                                self.treeview)
                            self.import_menu.addAction(dynaction)
                            self.import_dynactions[import_type] = tool_node
                        QObject.connect(self.import_menu,
                                        SIGNAL("triggered(QAction*)"),
                                        self.dataActionMenuFunctionImport)
                        self.menu.addMenu(self.import_menu)

                    self.menu.addSeparator()

                    # We need to provide the option to open the dataset
                    self.menu.addAction(self.actViewDataset)

        # Now tack on a refresh for all right clicks
        #print "Setting model refresh"
        self.menu.addAction(self.actRefresh)
        self.menu.exec_(QCursor.pos())
コード例 #37
0
    def showHeaderMenu(self, point):
        # determine the column that was clicked on
        index = self.uiPlaylistTREE.header().logicalIndexAt(point)
        self._currentHeaderColumn = index

        # create the menu
        menu = QMenu(self)

        act = menu.addAction('Sort Ascending')
        act.setIcon(resources.icon('img/playlist/sort_ascending.png'))
        act.triggered.connect(self.sortAscending)

        act = menu.addAction('Sort Descending')
        act.setIcon(resources.icon('img/playlist/sort_descending.png'))
        act.triggered.connect(self.sortDescending)

        menu.addSeparator()

        # create a columns menu
        columns = menu.addMenu('Columns...')
        columns.setIcon(resources.icon('img/playlist/columns.png'))

        for c, col in enumerate(self.COLUMNS):
            act = columns.addAction(col)
            act.setCheckable(True)
            act.setChecked(not self.uiPlaylistTREE.isColumnHidden(c))

        columns.triggered.connect(self.toggleColumnTriggered)

        # popup the menu
        menu.exec_(QCursor.pos())
コード例 #38
0
ファイル: bpointviewer.py プロジェクト: eaglexmw/codimension
    def __showContextMenu( self, coord ):
        " Shows the context menu "
        index = self.currentIndex()
        if not index.isValid():
            return
        sindex = self.toSourceIndex( index )
        if not sindex.isValid():
            return
        bp = self.__model.getBreakPointByIndex( sindex )
        if not bp:
            return

        enableCount, disableCount = self.__model.getCounts()

        self.__editAct.setEnabled( True )
        self.__enableAct.setEnabled( not bp.isEnabled() )
        self.__disableAct.setEnabled( bp.isEnabled() )
        self.__jumpToCodeAct.setEnabled( True )
        self.__delAct.setEnabled( True )
        self.__enableAllAct.setEnabled( disableCount > 0 )
        self.__disableAllAct.setEnabled( enableCount > 0 )
        self.__delAllAct.setEnabled( enableCount + disableCount > 0 )

        self.menu.popup( QCursor.pos() )
        return
コード例 #39
0
ファイル: systray.py プロジェクト: Bindupriya/nuxeo-drive
 def replace(self):
     log.trace("Icon is %r", self._icon)
     self._icon_geometry = rect = self._icon.geometry()
     log.trace("IconRect is : %s,%s | %s,%s",rect.x(), rect.y(), rect.width(), rect.height())
     from PyQt4.QtGui import QApplication, QCursor
     from PyQt4.QtCore import QRect
     desktop = QApplication.desktop()
     log.trace("Screen id is %d", desktop.screenNumber(rect.topLeft()))
     screen = desktop.availableGeometry(desktop.screenNumber(rect.topLeft()))
     pos = screen
     log.trace("AvailableRect is : %s,%s | %s,%s",pos.x(), pos.y(), pos.width(), pos.height())
     pos = desktop.screenGeometry(desktop.screenNumber(rect.topLeft()))
     log.trace("ScreenRect is : %s,%s | %s,%s",pos.x(), pos.y(), pos.width(), pos.height())
     pos = QCursor.pos()
     log.trace("Cursor is : %s,%s",pos.x(), pos.y())
     if not rect.contains(pos) or (rect.x() == 0 and rect.y() == 0):
         # Avoid any modulo 0
         if rect.width() == 0 or rect.height() == 0:
             rect = QRect(pos.x(), pos.y(), rect.width(), rect.height())
         else:
             rect = QRect(pos.x()-pos.x()%rect.width(), pos.y()-pos.y()%rect.height(), rect.width(), rect.height())
         log.trace("Adjusting X/Y to %d/%d", rect.x(), rect.y())
         pos = rect
         log.trace("New rect is : %s,%s | %s,%s",pos.x(), pos.y(), pos.width(), pos.height())
     x = rect.x() + rect.width() - self.width()
     y = rect.y() - self.height()
     # Prevent the systray to be hidden
     if y < 0:
         y = rect.y() + rect.height()
     if x < 0:
         x = rect.x()
     log.trace("Move systray menu to %d/%d", x, y)
     self.move(x, y)
コード例 #40
0
ファイル: run.py プロジェクト: dmzkrsk/wol-tray
 def activated(self, reason):
     if reason == QSystemTrayIcon.DoubleClick:
         self.setup()
     elif reason == QSystemTrayIcon.Trigger:
         menu = QMenu()
         self.populateMenuFromSettings(menu)
         menu.exec_(QCursor.pos())
コード例 #41
0
def showContextMenu(self):
    opts = [
        [_("Mark Note"), "*", self.onMark],
        [_("Bury Note"), "-", self.onBuryNote],
        [_("Suspend Card"), "@", self.onSuspendCard],
        [_("Suspend Note"), "!", self.onSuspend],
        [_("Delete Note"), "Delete", self.onDelete],
        [_("Options"), "O", self.onOptions],
        None,
        [_("Replay Audio"), "R", self.replayAudio],
        [_("Record Own Voice"), "Shift+V", self.onRecordVoice],
        [_("Replay Own Voice"), "V", self.onReplayRecorded],
    ]
    m = QMenu(self.mw)
    for row in opts:
        if not row:
            m.addSeparator()
            continue
        label, scut, func = row
        a = m.addAction(label)
        a.setShortcut(QKeySequence(scut))
        a.connect(a, SIGNAL("triggered()"), func)
        #Only change is the following statement
    runHook("Reviewer.contextMenuEvent", self, m)
    m.exec_(QCursor.pos())
コード例 #42
0
 def __showContextMenu(self, coord):
     " Shows the frames list context menu "
     contextItem = self.exceptionsList.itemAt(coord)
     if contextItem is not None:
         self.__currentItem = contextItem
         self.__excptMenu.popup(QCursor.pos())
     return
コード例 #43
0
 def showMenu( self ):
     """
     Creates a menu to display for the editing of template information.
     """
     item = self.uiMenuTREE.currentItem()
     
     menu = QMenu(self)
     act = menu.addAction('Add Menu...')
     act.setIcon(QIcon(projexui.resources.find('img/folder.png')))
     act.triggered.connect(self.createMenu)
     
     if ( item and item.data(0, Qt.UserRole) == 'menu' ):
         act = menu.addAction('Rename Menu...')
         ico = QIcon(projexui.resources.find('img/edit.png'))
         act.setIcon(ico)
         act.triggered.connect(self.renameMenu)
     
     act = menu.addAction('Add Separator')
     act.setIcon(QIcon(projexui.resources.find('img/ui/splitter.png')))
     act.triggered.connect(self.createSeparator)
     
     menu.addSeparator()
     
     act = menu.addAction('Remove Item')
     act.setIcon(QIcon(projexui.resources.find('img/remove.png')))
     act.triggered.connect(self.removeItem)
     act.setEnabled(item is not None)
     
     menu.exec_(QCursor.pos())
コード例 #44
0
ファイル: varianttreewidget.py プロジェクト: arxsys/dff-api
    def mousePressEvent(self, event):
        index = self.indexAt(event.pos())
        if index.isValid():
	  item = self.itemAt(event.pos())
	  if event.button() == Qt.RightButton:
	    self.copyMenu.popup(QCursor.pos())
	QTreeWidget.mousePressEvent(self, event)
コード例 #45
0
    def __autoScrollAdvance(self):
        """Advance the auto scroll
        """
        pos = QCursor.pos()
        pos = self.mapFromGlobal(pos)
        margin = self.__autoScrollMargin

        vvalue = self.verticalScrollBar().value()
        hvalue = self.horizontalScrollBar().value()

        vrect = QRect(0, 0, self.width(), self.height())

        # What should be the speed
        advance = 10

        # We only do auto scroll if the mouse is inside the view.
        if vrect.contains(pos):
            if pos.x() < vrect.left() + margin:
                self.horizontalScrollBar().setValue(hvalue - advance)
            if pos.y() < vrect.top() + margin:
                self.verticalScrollBar().setValue(vvalue - advance)
            if pos.x() > vrect.right() - margin:
                self.horizontalScrollBar().setValue(hvalue + advance)
            if pos.y() > vrect.bottom() - margin:
                self.verticalScrollBar().setValue(vvalue + advance)

            if self.verticalScrollBar().value() == vvalue and \
                    self.horizontalScrollBar().value() == hvalue:
                self.__stopAutoScroll()
        else:
            self.__stopAutoScroll()

        log.debug("Auto scroll advance")
コード例 #46
0
ファイル: ScriptEditorDialog.py プロジェクト: Geoneer/QGIS
 def showSnippets(self, evt):
     popupmenu = QMenu()
     for name, snippet in self.snippets.iteritems():
         action = QAction(self.tr(name), self.btnSnippets)
         action.triggered[()].connect(lambda snippet=snippet: self.editor.insert(snippet))
         popupmenu.addAction(action)
     popupmenu.exec_(QCursor.pos())
コード例 #47
0
    def _menu_context_tree(self, point):
        index = self.indexAt(point)
        if not index.isValid():
            return

        menu = QMenu(self)
        f_all = menu.addAction(self.tr("Fold all"))
        u_all = menu.addAction(self.tr("Unfold all"))
        menu.addSeparator()
        u_class = menu.addAction(self.tr("Unfold classes"))
        u_class_method = menu.addAction(self.tr("Unfold classes and methods"))
        u_class_attr = menu.addAction(self.tr("Unfold classes and attributes"))
        menu.addSeparator()
        #save_state = menu.addAction(self.tr("Save State"))

        self.connect(f_all, SIGNAL("triggered()"),
            lambda: self.collapseAll())
        self.connect(u_all, SIGNAL("triggered()"),
            lambda: self.expandAll())
        self.connect(u_class, SIGNAL("triggered()"), self._unfold_class)
        self.connect(u_class_method, SIGNAL("triggered()"),
            self._unfold_class_method)
        self.connect(u_class_attr, SIGNAL("triggered()"),
            self._unfold_class_attribute)
        #self.connect(save_state, SIGNAL("triggered()"),
            #self._save_symbols_state)

        menu.exec_(QCursor.pos())
コード例 #48
0
 def __getTooltipPos(self):
     " Calculates the tooltip position - above the row "
     pos = QCursor.pos()
     if pos.x() + self.sizeHint().width() >= screenWidth:
         pos.setX(screenWidth - self.sizeHint().width() - 2)
     pos.setY(pos.y() - cellHeight - 1 - self.sizeHint().height())
     return pos
コード例 #49
0
    def process_custom_menu(self, point):
        item = self.select_item_at(point)
        if not item:
            return

        node = item.node
        menu = QMenu(self.view)

        # Populate menu
        if node.tag == 'run':
            menu.addAction(self.actGetInfoSimulationRuns)
            menu.addAction(self.actDeleteRun)
        elif node.tag == 'indicator_batches':
            menu.addAction(self.actAddNewIndicatorBatch)
        elif node.tag == 'simulation_runs':
            menu.addAction(self.actImportRun)
        elif node.tag == 'indicator_batch':
            menu.addAction(self.actAddVisualizationToBatch)
            run_batch_on_menu = QMenu('Run indicator batch on...')
            self._createBatchRunMenu(run_batch_on_menu)
            menu.addMenu(run_batch_on_menu)

        elif node.tag == 'batch_visualization': # get('type') == 'batch_visualization':
            menu.addAction(self.actConfigureExistingBatchIndicatorVis)

        self.add_default_menu_items_for_node(node, menu)

        if not menu.isEmpty():
            menu.exec_(QCursor.pos())
コード例 #50
0
ファイル: container.py プロジェクト: carriercomm/Turpial
 def __link_clicked(self, url):
     if url == "cmd:add_columns":
         self.base.show_column_menu(QCursor.pos())
     elif url == "cmd:add_accounts":
         self.base.show_accounts_dialog()
     elif url == "cmd:restart":
         self.base.restart()
コード例 #51
0
def show(widget, pos=None, timeout=10000):
    """Show the widget at position."""
    if pos is None:
        pos = QCursor.pos()
    global _widget
    if _widget:
        if _widget is not widget:
            _widget.hide()
    else:
        global _handler
        if _handler is None:
            _handler = EventHandler()
        QApplication.instance().installEventFilter(_handler)
    
    # where to display the tooltip
    screen = QApplication.desktop().availableGeometry(pos)
    x = pos.x() + 2
    y = pos.y() + 20
    if x + widget.width() > screen.x() + screen.width():
        x -= 4 + widget.width()
    if y + widget.height() > screen.y() + screen.height():
        y -= 24 + widget.height()
    if y < screen.y():
        y = screen.y()
    if x < screen.x():
        x = screen.x()
    widget.move(x, y)
    if widget.windowFlags() & Qt.ToolTip != Qt.ToolTip:
        widget.setWindowFlags(Qt.ToolTip)
        widget.ensurePolished()
    
    widget.show()
    _widget = widget
    _timer.start(timeout)
コード例 #52
0
    def _menu_context_tree(self, point):
        """Context menu"""
        index = self.tree.indexAt(point)
        if not index.isValid():
            return

        menu = QMenu(self)
        f_all = menu.addAction(translations.TR_FOLD_ALL)
        u_all = menu.addAction(translations.TR_UNFOLD_ALL)
        menu.addSeparator()
        u_class = menu.addAction(translations.TR_UNFOLD_CLASSES)
        u_class_method = menu.addAction(
                         translations.TR_UNFOLD_CLASSES_AND_METHODS)
        u_class_attr = menu.addAction(
                       translations.TR_UNFOLD_CLASSES_AND_ATTRIBUTES)
        menu.addSeparator()
        #save_state = menu.addAction(self.tr("Save State"))

        self.connect(f_all, SIGNAL("triggered()"),
            lambda: self.tree.collapseAll())
        self.connect(u_all, SIGNAL("triggered()"),
            lambda: self.tree.expandAll())
        self.connect(u_class, SIGNAL("triggered()"), self._unfold_class)
        self.connect(u_class_method, SIGNAL("triggered()"),
            self._unfold_class_method)
        self.connect(u_class_attr, SIGNAL("triggered()"),
            self._unfold_class_attribute)
        #self.connect(save_state, SIGNAL("triggered()"),
            #self._save_symbols_state)

        menu.exec_(QCursor.pos())
コード例 #53
0
ファイル: __init__.py プロジェクト: TeddyBoomer/geophar
 def verifier_feuille(self, eq1, eq2):
     print eq1, eq2
     for nom, eq in (('d1', eq1), ('d2', eq2)):
         if nom in self.feuille_actuelle.objets.noms:
             d = self.feuille_actuelle.objets[nom]
             d.label(mode=NOM)
             champ = self.feuille_actuelle.objets['champcache_' + nom]
             M, N = d
             M = (int(M.x), int(M.y))
             N = (int(N.x), int(N.y))
             if self.eq_reduite(M, N) == eq:
                 d.style(couleur='g')
                 champ.texte = 'ok'
                 msg = 'La droite %s est correcte.' % nom
                 if nom == 'd1':
                     msg += ' Construisez maintenant d2.'
             else:
                 print self.eq_reduite(*d), eq
                 d.style(couleur='r')
                 # On peut mettre n'importe quoi différent de ok dans
                 # champ, l'idée étant que si la droite est fausse mais
                 # n'a pas changé, on ne perde pas de point, et par
                 # contre on perde des points en cas de changement si
                 # c'est toujours faux.
                 champ.texte = str(d.equation)
                 msg = "Attention, la droite %s est fausse." % nom
             QToolTip.showText(QCursor.pos(), msg)
             self.canvas.message(msg, temporaire=False)
コード例 #54
0
    def timerEvent(self, event):
        """Handle events sent by the kinetic timer to decrease progressively
           the scrolling speed, eventually halting it.
        """
        count = 0
        if self._kineticData._state == KineticData.ManualScroll:
            count += 1
            cursorPos = QCursor.pos()
            self._kineticData._speed = cursorPos - self._kineticData._dragPos
            self._kineticData._dragPos = cursorPos
        elif self._kineticData._state == KineticData.AutoScroll:
            count += 1
            p = self.scrollOffset()

            if self._kineticData._speed == QPoint(
                    0,
                    0) or not self.setScrollOffset(p -
                                                   self._kineticData._speed):
                self._kineticData._state = KineticData.Steady
                # reset speed to 0, as wheel scrolling accumulates speed instead of setting it to a fixed value.
                self._kineticData._speed = QPoint(0, 0)
                # reset count to 0 to stop iterating.
                count = 0

            self._kineticData._speed = deaccelerate(
                self._kineticData._speed, 1, self._kineticData._maxSpeed)

        if count == 0:
            self._kineticData._ticker.stop()
            self.kineticScrollingActive.emit(False)

        super(KineticScrollArea, self).timerEvent(event)
コード例 #55
0
    def timerEvent(self, event):
        """Handle events sent by the kinetic timer to decrease progressively
           the scrolling speed, eventually halting it.
        """
        count = 0
        if self._kineticData._state == KineticData.ManualScroll:
            count += 1
            cursorPos = QCursor.pos()
            self._kineticData._speed = cursorPos - self._kineticData._dragPos
            self._kineticData._dragPos = cursorPos    
        elif self._kineticData._state == KineticData.AutoScroll:
            count += 1
            p = self.scrollOffset()

            if self._kineticData._speed == QPoint(0, 0) or not self.setScrollOffset(p - self._kineticData._speed):
                self._kineticData._state = KineticData.Steady
                # reset speed to 0, as wheel scrolling accumulates speed instead of setting it to a fixed value.
                self._kineticData._speed = QPoint(0,0)
                # reset count to 0 to stop iterating.
                count = 0
                
            self._kineticData._speed = deaccelerate(self._kineticData._speed, 1, self._kineticData._maxSpeed)
    
        if count == 0:
            self._kineticData._ticker.stop()
            self.kineticScrollingActive.emit(False)
    
        super(KineticScrollArea, self).timerEvent(event);
コード例 #56
0
    def _menu_context_tree(self, point):
        index = self.indexAt(point)
        if not index.isValid():
            return

        menu = QMenu(self)
        f_all = menu.addAction(self.tr("Fold all"))
        u_all = menu.addAction(self.tr("Unfold all"))
        menu.addSeparator()
        u_class = menu.addAction(self.tr("Unfold classes"))
        u_class_method = menu.addAction(self.tr("Unfold classes and methods"))
        u_class_attr = menu.addAction(self.tr("Unfold classes and attributes"))
        menu.addSeparator()
        #save_state = menu.addAction(self.tr("Save State"))

        self.connect(f_all, SIGNAL("triggered()"),
                     lambda: self.collapseAll())
        self.connect(u_all, SIGNAL("triggered()"),
                     lambda: self.expandAll())
        self.connect(u_class, SIGNAL("triggered()"), self._unfold_class)
        self.connect(u_class_method, SIGNAL("triggered()"),
                     self._unfold_class_method)
        self.connect(u_class_attr, SIGNAL("triggered()"),
                     self._unfold_class_attribute)
        #self.connect(save_state, SIGNAL("triggered()"),
            #self._save_symbols_state)

        menu.exec_(QCursor.pos())
コード例 #57
0
    def menuContextTree(self, point):
        index = self.indexAt(point)
        if not index.isValid():
            return

        item = self.itemAt(point)
        name = str(item.text(0))
        if item.isClickable:
            self.emit(SIGNAL("itemClicked(QTreeWidgetItem *, int)"), item,
                      item.lineno)

        menu = QMenu(self)
        if item.isAttribute:
            createPropertyAction = menu.addAction('Create Property')
            self.connect(
                createPropertyAction, SIGNAL("triggered()"),
                lambda: self._main._central.obtain_editor().create_property(
                    item.lineno, name))
        if item.isClickable:
            renameAction = menu.addAction('Rename')
            self.connect(
                renameAction, SIGNAL("triggered()"),
                lambda: self._main._central.obtain_editor().refactor_rename(
                    item.lineno, name))
        menu.exec_(QCursor.pos())