コード例 #1
0
    def createLowRightButton(self, label, type, movieIn, movieOut, movieShake):
        item = TextButton(label, TextButton.RIGHT, type, self.window.scene,
                          None, TextButton.PANEL)
        item.setRecursiveVisible(False)
        item.setZValue(10)

        sw = self.window.scene.sceneRect().width()
        xOffset = 70

        # Create in-animation.
        anim = DemoItemAnimation(item, DemoItemAnimation.ANIM_IN)
        anim.setDuration(1800 * Colors.animSpeedButtons)
        anim.setStartPos(
            QtCore.QPointF(sw,
                           Colors.contentStartY + Colors.contentHeight - 35))
        anim.setPosAt(
            0.5,
            QtCore.QPointF(sw,
                           Colors.contentStartY + Colors.contentHeight - 35))
        anim.setPosAt(
            0.7,
            QtCore.QPointF(xOffset + 535,
                           Colors.contentStartY + Colors.contentHeight - 35))
        anim.setPosAt(
            1.0,
            QtCore.QPointF(xOffset + 535,
                           Colors.contentStartY + Colors.contentHeight - 26))
        movieIn.append(anim)

        # Create out-animation.
        anim = DemoItemAnimation(item, DemoItemAnimation.ANIM_OUT)
        anim.hideOnFinished = True
        anim.setDuration(400 * Colors.animSpeedButtons)
        anim.setStartPos(
            QtCore.QPointF(xOffset + 535,
                           Colors.contentStartY + Colors.contentHeight - 26))
        anim.setPosAt(
            1.0,
            QtCore.QPointF(sw,
                           Colors.contentStartY + Colors.contentHeight - 26))
        movieOut.append(anim)
コード例 #2
0
ファイル: view.py プロジェクト: lovejunjie1/shaderlink_pyside
    def computeGfxNodePropsSizes(self):
        # input properties
        self.inputPropsDim = {}
        startInputPropBoxP = QtCore.QPointF(
            self.rect.x() + self.edgeSeparator,
            self.rect.y() + self.propBoxSize + self.headerHeight)

        for i in range(len(self.node.inputProps)):
            startPoint = QtCore.QPointF(
                startInputPropBoxP.x(),
                startInputPropBoxP.y() + 2 * i * self.propBoxSize)
            box = QtCore.QRectF(startPoint.x(), startPoint.y(),
                                self.propBoxSize, self.propBoxSize)
            textPoint = box.bottomRight() + QtCore.QPointF(
                0.5 * self.propBoxSize, 0.0)
            self.inputPropsDim[self.node.inputProps[i]] = {
                'box': box,
                'point': textPoint
            }

        # output properties
        self.outputPropsDim = {}
        startOutputPropP = QtCore.QPointF(
            self.rect.topRight().x() - self.propBoxSize - self.edgeSeparator,
            self.rect.y() + self.propBoxSize + self.headerHeight)

        for i in range(len(self.node.outputProps)):
            startPoint = QtCore.QPointF(
                startOutputPropP.x(),
                startOutputPropP.y() + 2 * i * self.propBoxSize)
            box = QtCore.QRectF(startPoint.x(), startPoint.y(),
                                self.propBoxSize, self.propBoxSize)
            textPoint = box.bottomLeft() + QtCore.QPointF(
                -0.5 * self.propBoxSize - self.maxOutputWidth, 0.0)
            self.outputPropsDim[self.node.outputProps[i]] = {
                'box': box,
                'point': textPoint
            }
コード例 #3
0
    def __init__(self, diagramType, contextMenu, parent=None, scene=None):
        super(DiagramItem, self).__init__(parent, scene)

        self.arrows = []

        self.diagramType = diagramType
        self.myContextMenu = contextMenu

        path = QtGui.QPainterPath()
        if self.diagramType == self.StartEnd:
            path.moveTo(200, 50)
            path.arcTo(150, 0, 50, 50, 0, 90)
            path.arcTo(50, 0, 50, 50, 90, 90)
            path.arcTo(50, 50, 50, 50, 180, 90)
            path.arcTo(150, 50, 50, 50, 270, 90)
            path.lineTo(200, 25)
            self.myPolygon = path.toFillPolygon()
        elif self.diagramType == self.Conditional:
            self.myPolygon = QtGui.QPolygonF([
                    QtCore.QPointF(-100, 0), QtCore.QPointF(0, 100),
                    QtCore.QPointF(100, 0), QtCore.QPointF(0, -100),
                    QtCore.QPointF(-100, 0)])
        elif self.diagramType == self.Step:
            self.myPolygon = QtGui.QPolygonF([
                    QtCore.QPointF(-100, -100), QtCore.QPointF(100, -100),
                    QtCore.QPointF(100, 100), QtCore.QPointF(-100, 100),
                    QtCore.QPointF(-100, -100)])
        else:
            self.myPolygon = QtGui.QPolygonF([
                    QtCore.QPointF(-120, -80), QtCore.QPointF(-70, 80),
                    QtCore.QPointF(120, 80), QtCore.QPointF(70, -80),
                    QtCore.QPointF(-120, -80)])

        self.setPolygon(self.myPolygon)
        self.setFlag(QtGui.QGraphicsItem.ItemIsMovable, True)
        self.setFlag(QtGui.QGraphicsItem.ItemIsSelectable, True)
コード例 #4
0
ファイル: lose_finder.py プロジェクト: tws0002/Shadow
 def size_pos(self):
     out = self.scenePos() + QtCore.QPointF(self.port_x + self.port_x,
                                            self.port_y + self.port_x)
     return out
コード例 #5
0
ファイル: kbackdrop.py プロジェクト: sonictk/Kraken
 def getGraphPos(self):
     transform = self.transform()
     size = self.size()
     return QtCore.QPointF(transform.dx() + (size.width() * 0.5),
                           transform.dy() + (size.height() * 0.5))
コード例 #6
0
ファイル: node.py プロジェクト: danbradham/nodify
 def b_pnts(self):
     '''QPoints for down side'''
     pnt_a = QtCore.QPointF(-self.width * 0.5, 0)
     pnt_b = QtCore.QPointF(self.width * 0.5, 0)
     pnt_c = QtCore.QPointF(0, -self.height * 0.5)
     return pnt_a, pnt_b, pnt_c
コード例 #7
0
 def on_select(self):
     item = self.list_widget.selectedItems()[0]
     index = self.list_widget.indexOfTopLevelItem(item)
     x = self.footprint_list[index]['x']/1000000.0
     y = self.footprint_list[index]['y']/1000000.0
     self.owner.set_marker(QtCore.QPointF(x,y),self.footprint_list[index]['bot'])
コード例 #8
0
	def drawCerca(self, cerca):
		poly = QtGui.QPolygonF()
		for p in cerca:
			poly.append(QtCore.QPointF(float(p["x"]),float(p["y"])))
		self.scene().addPolygon(poly,QtGui.QPen(QtCore.Qt.magenta,4))
		self.show()
コード例 #9
0
    def __init__(self, letters):
        super(EffectScan, self).__init__(letters)

        for letter in self.letters:
            letter.setGuidedPos(QtCore.QPointF(100, -300))
コード例 #10
0
ファイル: Node.py プロジェクト: sugeerth/BrainModulyzer
    def paint(self, painter, option, widget):
        painter.setPen(QtCore.Qt.NoPen)
        self.font = painter.font()
        self.font.setBold(False)
        fm = QtGui.QFontMetrics(painter.font())
        wi = fm.maxWidth()
        ht = fm.height()

        if not (self.ForCommunities):
            mess = self.Translate.set(str(self.Brain_Regions[self.counter -
                                                             1]))
            self.font.setPointSize(9)
            rect = fm.boundingRect(mess + str(22))
            painter.setFont(self.font)
            dx = -rect.width() / 2 + rect.width() / 5
            dy = rect.height() / 2 - 0.5
            rect.translate(dx, dy)
        else:
            mess = self.Translate.set(str(self.counter))
            self.font.setPointSize(16)
            rect = fm.boundingRect(mess + str(22))
            painter.setFont(self.font)
            dx = -rect.width() / 2 + rect.width() / 5 + 2.5
            dy = rect.height() / 2 - 2.5
            self.nodesize = 14
            rect.translate(dx, dy)

        if self.NodeCommunityColor:
            if option.state & QtGui.QStyle.State_Selected:
                painter.save()
                self.Selected = True
                self.WhitePaint = True
                self.CommunityColor.setAlpha(255)
                painter.setBrush(self.CommunityColor)
            else:
                painter.save()
                self.Selected = False
                self.WhitePaint = False
                painter.setBrush(self.CommunityColor)

        else:
            if (option.state & QtGui.QStyle.State_Selected):
                painter.save()
                self.Selected = True
                self.WhitePaint = True
                #FIXME Green
                painter.setBrush(QtCore.Qt.darkGreen)
                # painter.setBrush(self.NodeColor)
            else:
                painter.save()
                self.Selected = False
                self.WhitePaint = False
                painter.setBrush(self.nodeColor)

        painter.setPen(QtGui.QPen(QtCore.Qt.black, 0))
        painter.drawEllipse(QtCore.QPointF(0, 0), self.nodesize,
                            self.nodesize - 2)

        if self.WhitePaint:
            circle_path = QtGui.QPainterPath()
            painter.setPen(QtGui.QPen(QtCore.Qt.blue, 2))
            circle_path.addEllipse(QtCore.QPointF(0, 0), self.nodesize + 1,
                                   self.nodesize + 1)
            painter.drawPath(circle_path)
            painter.setPen(QtGui.QPen(QtCore.Qt.black, 0))
            painter.drawText(rect, QtCore.Qt.TextSingleLine, mess)
        else:
            painter.drawText(rect, QtCore.Qt.TextSingleLine, mess)
        painter.restore()
コード例 #11
0
ファイル: hodo.py プロジェクト: rsobash/SHARPpy
 def drawSMV(self, qp):
     '''
     Draws the storm motion vector.
     
     Parameters
     ----------
     qp: QtGui.QPainter object
     
     '''
     ## set a pen with white color, width 1, solid line.
     penwidth = 1
     pen = QtGui.QPen(QtGui.QColor(WHITE), penwidth)
     pen.setStyle(QtCore.Qt.SolidLine)
     qp.setPen(pen)
     ## check and make sure there is no missing data
     try:
         mask = np.maximum( self.u, self.v )
         hght = self.hght[~mask]
         u = self.u[~mask]; v = self.v[~mask]
         ## calculate the left and right storm motion vectors
         rstu,rstv,lstu,lstv = self.srwind
         rstu = rstu[~mask]; rstv = rstv[~mask]
         lstu = lstu[~mask]; lstv = lstv[~mask]
     ## otherwise the data is fine
     except:
         hght = self.hght
         u = self.u; v = self.v
         rstu,rstv,lstu,lstv = self.srwind
     ## convert the left and right mover vector components to pixel values
     ruu, rvv = self.uv_to_pix(rstu,rstv)
     luu, lvv = self.uv_to_pix(lstu, lstv)
     ## calculate the center points of the storm motion vectors
     center_rm = QtCore.QPointF(ruu,rvv)
     center_lm = QtCore.QPointF(luu,lvv)
     ## draw circles around the sorm motion vectors
     qp.drawEllipse(center_rm, 5, 5)
     qp.drawEllipse(center_lm, 5, 5)
     ## get the effective inflow layer
     ptop, pbottom = self.ptop, self.pbottom
     ## make sure the effective inflow layer exists
     if ptop is np.ma.masked and pbottom is np.ma.masked:
         pass
     else:
         ## get the interpolated wind at the bottom and top
         ## of the effective inflow layer
         utop,vtop = tab.interp.components(self.prof, ptop)
         ubot,vbot = tab.interp.components(self.prof, pbottom)
         ## convert these values to pixels
         uutop, vvtop = self.uv_to_pix(utop, vtop)
         uubot, vvbot = self.uv_to_pix(ubot, vbot)
         ## set a pen
         pen = QtGui.QPen(QtGui.QColor("#00FFFF"), penwidth)
         pen.setStyle(QtCore.Qt.SolidLine)
         qp.setPen(pen)
         ## draw lines showing the effective inflow layer
         qp.drawLine(center_rm.x(), center_rm.y(), uubot, vvbot)
         qp.drawLine(center_rm.x(), center_rm.y(), uutop, vvtop)
     color = QtGui.QColor('#000000')
     color.setAlpha(0)
     pen = QtGui.QPen(color, 0, QtCore.Qt.SolidLine)
     qp.setPen(pen)
     h_offset = 2; v_offset=5; width = 55; hght = 12;
     rm_rect = QtCore.QRectF(ruu+h_offset, rvv+v_offset, width, hght)
     lm_rect = QtCore.QRectF(luu+h_offset, lvv+v_offset, width, hght)
     qp.drawRect(rm_rect)
     qp.drawRect(lm_rect) 
     ## now make the pen white and draw text using
     ## the invisible rectangles
     pen = QtGui.QPen(QtGui.QColor("#FFFFFF"))
     qp.setPen(pen)
     qp.setFont(self.label_font)
     rm_stuff = tab.utils.INT2STR(self.bunkers_right_vec[0]) + '/' + tab.utils.INT2STR(self.bunkers_right_vec[1])
     lm_stuff = tab.utils.INT2STR(self.bunkers_left_vec[0]) + '/' + tab.utils.INT2STR(self.bunkers_left_vec[1])
     qp.drawText(rm_rect, QtCore.Qt.AlignCenter, rm_stuff + " RM")
     qp.drawText(lm_rect, QtCore.Qt.AlignCenter, lm_stuff + " LM")
コード例 #12
0
ファイル: hodo.py プロジェクト: rsobash/SHARPpy
    def mousePressEvent(self, e):
        '''
        Handles when the mouse is pressed.
        Used to set the storm motion vector.
        
        Parameters
        ----------
        e: an Event object
        
        '''
        if self.bndy == False:
            if self.hasMouseTracking():
                self.setMouseTracking(False)
            else:
                self.setMouseTracking(True)
        else:
            if self.hasMouseTracking():
                qp = QtGui.QPainter()
                self.bndy_u, self.bndy_v = self.pix_to_uv(e.x(), e.y())
                self.bndy_dir, self.bndy_spd = tab.utils.comp2vec(self.bndy_u, self.bndy_v)
                y1 = 400*np.sin(np.radians(self.bndy_dir)) + e.y()
                x1 = 400*np.cos(np.radians(self.bndy_dir)) + e.x()
                y2 = e.y() - 400*np.sin(np.radians(self.bndy_dir))
                x2 = e.x() - 400*np.cos(np.radians(self.bndy_dir))
                penwidth = 2
                width = 300
                hght = 14
                # Plot the actual boundary 
                boundary_color = QtGui.QColor("#CC9900")
                pen = QtGui.QPen(boundary_color, penwidth)
                qp.begin(self.plotBitMap)
                qp.setRenderHint(qp.Antialiasing)
                qp.setRenderHint(qp.TextAntialiasing)
                qp.setPen(pen)
                qp.drawLine(x1, y1, x2, y2)
                center_rm = QtCore.QPointF(e.x(),e.y())
                qp.setPen(pen)
                pen = QtGui.QPen(boundary_color, 50)
                pen.setStyle(QtCore.Qt.SolidLine)
                qp.drawEllipse(center_rm, 3, 3)

                # Plot the shear vector
                width = 150
                qp = self.setBlackPen(qp)
                rect = QtCore.QRectF(3, self.bry-35, width, hght)
                qp.drawRect(rect) 
                shear_color = QtGui.QColor("#0099CC")
                pen = QtGui.QPen(shear_color, penwidth)
                qp.setFont(self.critical_font)
                qp.setPen(pen)
                x2, y2 = self.uv_to_pix(self.prof.sfc_6km_shear[0], self.prof.sfc_6km_shear[1])
                qp.drawLine(e.x(), e.y(), x2, y2)
                dir, spd = tab.utils.comp2vec(self.prof.sfc_6km_shear[0], self.prof.sfc_6km_shear[1])
                qp.drawText(rect, QtCore.Qt.TextDontClip | QtCore.Qt.AlignLeft, "0 - 6 km Shear: " + tab.utils.INT2STR(dir) + '/' + tab.utils.INT2STR(spd) + ' kts')

                # Plot the 9-11 km Storm Relative Winds
                width = 200
                qp = self.setBlackPen(qp)
                rect = QtCore.QRectF(3, self.bry-20, width, hght)
                qp.drawRect(rect) 
                srw_color = QtGui.QColor("#FF00FF")
                pen = QtGui.QPen(srw_color, penwidth)
                qp.setPen(pen)
                x2, y2 = self.uv_to_pix(self.prof.srw_9_11km[0], self.prof.srw_9_11km[1])
                qp.drawLine(e.x(), e.y(), x2, y2)
                dir, spd = tab.utils.comp2vec(self.prof.srw_9_11km[0], self.prof.srw_9_11km[1])
                if spd >= 70:
                    supercell_type = "LP"
                elif spd < 70 and spd > 40:
                    supercell_type = "Classic"
                else:
                    supercell_type = "HP"
                qp.drawText(rect, QtCore.Qt.TextDontClip | QtCore.Qt.AlignLeft, "9 - 11 km SR-Wind: " + tab.utils.INT2STR(dir) + '/' + tab.utils.INT2STR(spd) + ' kts - (' + supercell_type + ')')
                
                # Draw the descrete vs mixed/linear mode output only if there is an LCL-EL layer.
                norm_Shear, mode_Shear, norm_Wind, norm_Mode = self.calculateStormMode()
 
                if tab.utils.QC(norm_Wind) and self.prof.mupcl.bplus != 0:
                    width = 80
                    qp = self.setBlackPen(qp)
                    rect = QtCore.QRectF(3, self.bry-80, width, hght)
                    qp.drawRect(rect)
                    color = QtGui.QColor(YELLOW)
                    pen = QtGui.QPen(color, penwidth)
                    qp.setPen(pen)
                    qp.drawText(rect, QtCore.Qt.TextDontClip | QtCore.Qt.AlignLeft, "...Storm Mode...")
                    
                    width = 270
                    qp = self.setBlackPen(qp)
                    rect = QtCore.QRectF(3, self.bry-50, width, hght)
                    qp.drawRect(rect)
                    if norm_Wind < 6:
                        color = QtGui.QColor(RED)
                    else:
                        color = QtGui.QColor(MAGENTA)
                    pen = QtGui.QPen(color, penwidth)
                    qp.setPen(pen)
                    qp.drawText(rect, QtCore.Qt.TextDontClip | QtCore.Qt.AlignLeft, "From Cloud Layer Wind - Bndy Diff (" + tab.utils.INT2STR(norm_Wind) + " m/s): " + norm_Mode)
                    width = 200
                    
                    qp = self.setBlackPen(qp)
                    rect = QtCore.QRectF(3, self.bry-65, width, hght)
                    qp.drawRect(rect)
                    if norm_Shear < 15:
                        color = QtGui.QColor(RED)
                    else:
                        color = QtGui.QColor(MAGENTA)
                    pen = QtGui.QPen(color, penwidth)
                    qp.setPen(pen)
                    qp.drawText(rect, QtCore.Qt.TextDontClip | QtCore.Qt.AlignLeft, "From Bndy 0-6 km Shr Diff (" + tab.utils.INT2STR(norm_Shear) + " m/s): " + mode_Shear)

                qp.end()

                self.update()
                self.setMouseTracking(False)
            else:
                self.plotBndy(self.bndy_dir)
                self.clearData()
                self.plotData()
                self.update()               
                self.setMouseTracking(True)
コード例 #13
0
    # States.
    rootState = QtCore.QState()
    ellipseState = QtCore.QState(rootState)
    figure8State = QtCore.QState(rootState)
    randomState = QtCore.QState(rootState)
    tiledState = QtCore.QState(rootState)
    centeredState = QtCore.QState(rootState)

    # Values.
    for i, item in enumerate(items):
        # Ellipse.
        ellipseState.assignProperty(
            item, 'pos',
            QtCore.QPointF(
                math.cos((i / 63.0) * 6.28) * 250,
                math.sin((i / 63.0) * 6.28) * 250))

        # Figure 8.
        figure8State.assignProperty(
            item, 'pos',
            QtCore.QPointF(
                math.sin((i / 63.0) * 6.28) * 250,
                math.sin(((i * 2) / 63.0) * 6.28) * 250))

        # Random.
        randomState.assignProperty(
            item, 'pos',
            QtCore.QPointF(-250 + QtCore.qrand() % 500,
                           -250 + QtCore.qrand() % 500))
コード例 #14
0
  def layoutRadialScene(self):
    """ A convenience method for drawing the sensitivity scene in radial fashion
    """
    self.scene.clear()
    width = self.scene.width()
    height = self.scene.height()
    minDim = min([width,height])-24. # 12 point font * 2 for top and bottom,
                                     ## width is a bit harder...

    centerX = width/2.
    centerY = height/2.
    radius = minDim/2.

    axisPen = qtg.QPen(qtc.Qt.black)

    self.scene.addEllipse(centerX - radius, centerY - radius, minDim, \
                          minDim, axisPen)
    names = self.amsc.GetNames()[:-1]

    for i,name in enumerate(names):
      if len(names) <= 2:
        theta = 3*math.pi*float(i)/2.
      else:
        theta = 2*math.pi*float(i)/float(len(names))
      endX = radius*math.cos(theta)+centerX
      endY = radius*math.sin(theta)+centerY
      self.scene.addLine(centerX,centerY,endX,endY,axisPen)
      if self.showLabelsAction.isChecked():
        txtItem = self.scene.addSimpleText(name,self.font)
        txtItem.setPos(endX,endY)
        txtItem.setFlag(qtg.QGraphicsItem.ItemIsMovable)
        txtItem.setFlag(qtg.QGraphicsItem.ItemIsSelectable)
        txtItem.setFlag(qtg.QGraphicsItem.ItemIgnoresTransformations)

    selection = self.amsc.GetSelectedSegments()
    colorMap = self.amsc.GetColors()
    if self.valueGroup.checkedAction().text() == 'Linear coefficients':
      fits = self.amsc.SegmentFitCoefficients()
    elif self.valueGroup.checkedAction().text() == 'Pearson correlation':
      fits = self.amsc.SegmentPearsonCoefficients()
    elif self.valueGroup.checkedAction().text() == 'Spearman rank correlation':
      fits = self.amsc.SegmentSpearmanCoefficients()

    ## Check if they selected any extrema
    if selection is None or len(selection) == 0:
      selection = []
      selectedExts = self.amsc.GetSelectedExtrema()
      allSegments = self.amsc.GetCurrentLabels()
      for minMaxPair in allSegments:
        for extIdx in selectedExts:
          if extIdx in minMaxPair:
            selection.append(minMaxPair)
      ## Okay, well then we will just plot everything we have for the current
      ## level
      if len(selection) == 0:
        selection = allSegments

    if self.valueGroup.checkedAction().text() == 'Linear coefficients':
      maxValue = 0
      for extPair in selection:
        if maxValue < max(map(abs,fits[extPair])):
          maxValue = max(map(abs,fits[extPair]))
    else:
      maxValue = 1

    for extPair in selection:
      myColor = colorMap[extPair]
      myPen = qtg.QPen(qtg.QColor('#000000'))
      brushColor = qtg.QColor(myColor)
      brushColor.setAlpha(127)
      myBrush = qtg.QBrush(brushColor)
      myPoly = qtg.QPolygonF()
      for i,val in enumerate(map(abs,fits[extPair])):
        if len(names) <= 2:
          theta = 3*math.pi*float(i)/2.
        else:
          theta = 2*math.pi*float(i)/float(len(names))
        dimX = (val/maxValue)*radius*math.cos(theta)+centerX
        dimY = (val/maxValue)*radius*math.sin(theta)+centerY
        myPoly.append(qtc.QPointF(dimX,dimY))
      if len(names) <= 2:
        myPoly.append(qtc.QPointF(centerX,centerY))
      self.scene.addPolygon(myPoly,myPen,myBrush)
コード例 #15
0
ファイル: guideline.py プロジェクト: tryanaditya/mainmain
 def endPos(self):
     return QtCore.QPointF(self.line.p2().x() * self.scaleX,
                           self.line.p2().y() * self.scaleY)
コード例 #16
0
ファイル: main.py プロジェクト: embicoin/kartludox
    def __init__(self, parent):
        super(MdiTable, self).__init__(parent)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setWindowTitle(self.tr('Table titilonius'))
        #self.setWindowFlags(QtCore.Qt.WindowMinimizeButtonHint)
        self.setMinimumHeight(200)

        self.pic = QtGui.QPixmap('./data/gfx/table/default/table.png')
        scene = QtGui.QGraphicsScene(self)
        scene.setBackgroundBrush(parent.mdiArea.background())
        #seat = scene.addPixmap(self.pic)
        seat = Interactable(self.pic, self)
        seat.setTransformationMode(QtCore.Qt.SmoothTransformation)
        scene.addItem(seat)
        self.disppic = scene.items()[0]
        #self.view = QtGui.QGraphicsView()
        self.view = NonScrollGraphicsView()
        self.view.setScene(scene)
        self.view.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.view.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.view.setAlignment(QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
        self.setWidget(self.view)   

        #scroll = ScrollEater(self.view)
        #self.view.installEventFilter(scroll)
        #self.view.clearFocus()
        #self.view.setFocusPolicy(QtCore.Qt.NoFocus)

        #self.seat = QtGui.QPixmap('./data/gfx/table/default/seat_empty.png')
        self.seat_boy = QtGui.QPixmap('./data/gfx/table/default/boy.png')
        self.seat_girl = QtGui.QPixmap('./data/gfx/table/default/girl.png')
        self.seat_custom = QtGui.QPixmap('./data/gfx/table/default/custom-avatar.png')
        #avatarPositions = [(610, 100), (620, 200), (510, 290), (330, 290), (140, 290), (30, 200), (60, 100), (240, 60), (430, 60), (80, 80)]
        avatarPositions = [
            (600, 38),
            (660, 170),
            (485, 360),
            (270, 360),
            (100, 327),
            (42, 168),
            (81, 77),
            (290, 20),
            (400, 20),
            (628, 319)]
        #avatarPositions = [(40, 170), (470, 280), (200, 280), (630, 170), (200, 40), (470, 40)]
        self.allSeats = []
        for p in avatarPositions:
        #for p in []:
            choice = random.randint(0,2)
            if choice == 0:
                seat = scene.addPixmap(self.seat_boy)
            elif choice == 1:
                seat = scene.addPixmap(self.seat_girl)
            else:
                seat = scene.addPixmap(self.seat_custom)
            seat.setTransformationMode(QtCore.Qt.SmoothTransformation)
            seat.setFlags(seat.ItemIsMovable)
            seat.setPos(*p)
            self.allSeats.append(seat)
            #seat = scene.addPixmap(self.seat)
        """seat.setPos(80,220)
        seat.setTransformationMode(QtCore.Qt.SmoothTransformation)
        seat = scene.addPixmap(self.seat)
        seat.setPos(60,30)
        seat.setTransformationMode(QtCore.Qt.SmoothTransformation)
        seat = scene.addPixmap(self.seat)
        seat.setPos(20,120)
        seat.setTransformationMode(QtCore.Qt.SmoothTransformation)
        seat = scene.addPixmap(self.seat)
        seat.setPos(460,120)
        seat.setTransformationMode(QtCore.Qt.SmoothTransformation)"""
        self.other = QtGui.QPixmap('./data/gfx/table/default/other_cards.png')
        #positions = [(610, 120), (620, 200), (510, 290), (330, 290), (140, 290), (100, 210), (120, 120), (280, 110), (480, 110)]
        positions = [(625, 210), (250, 80), (250, 320), (100, 210), (470, 80)]
        self.allCards = []
        #for p in positions:
        for p in []:
            #other = Interactable(self.other, self)
            other = scene.addPixmap(self.other)
            other.setTransformationMode(QtCore.Qt.SmoothTransformation)
            other.setFlags(other.ItemIsMovable)
            other.setPos(*p)
            self.allCards.append(other)
            #scene.addItem(other)
        """other = scene.addPixmap(self.other)
        other.setPos(80, 130)
        other.setTransformationMode(QtCore.Qt.SmoothTransformation)
        other = scene.addPixmap(self.other)
        other.setPos(120, 200)
        other.setTransformationMode(QtCore.Qt.SmoothTransformation)
        other = scene.addPixmap(self.other)
        other.setPos(440, 120)
        other.setTransformationMode(QtCore.Qt.SmoothTransformation)
        #other = scene.addPixmap(self.other)
        other = Interactable(self.other)
        other.setPos(380, 50)
        other.setTransformationMode(QtCore.Qt.SmoothTransformation)
        scene.addItem(other)"""

        font = QtGui.QFont('Lucida Sans')
        font.setPointSize(10)
        font1 = QtGui.QFont('Lucida Sans')
        font1.setPointSize(10)
        font1.setWeight(QtGui.QFont.Black)
        brush = QtGui.QLinearGradient()
        brush.setColorAt(0, QtCore.Qt.white)
        #brush = QtGui.QBrush()
        #brush.setColor(QtCore.Qt.white)
        pen = QtGui.QPen()
        pen.setWidth(0)
        pen.setStyle(QtCore.Qt.NoPen)
        names = [
            "Tracy",
            "Genjix",
            "derp-derp",
            "KibKibKib",
            "Tracy",
            "Genjix",
            "derp-derp",
            "KibKibKib",
            "drawingfishe",
            "scribl"]
        stacks = [
            '1200 btc',
            '8000 btc',
            '100 btc',
            '9112 btc',
            '1200 btc',
            '8000 btc',
            '100 btc',
            '9112 btc',
            '7654 btc',
            '400 btc']
        playbox = QtGui.QPixmap('./data/gfx/table/default/playerbox.png')
        self.allPlayboxes = []
        playboxPositions = [
            (377, 380),
            (652, 257),
            (638, 123),
            (260, 443),
            (580, 407),
            (85, 412),
            (31, 261),
            (180, 13),
            (493, 46),
            (21, 30)]
        for p in playboxPositions:
            path = QtGui.QPainterPath()
            play = scene.addPixmap(playbox)
            play.setFlags(play.ItemIsMovable)
            self.allPlayboxes.append(play)
            p = [p[0], p[1]]
            play.setPos(p[0], p[1])
            p[0] += 10
            p[1] += 4
            p = p[0], p[1] + 12
            path.addText(QtCore.QPointF(p[0], p[1]), font, names.pop())
            p = p[0], p[1] + 15
            path.addText(QtCore.QPointF(p[0], p[1]), font1, stacks.pop())
            scene.addPath(path, pen, brush)

        ranks = "23456789tjqka"
        suits = "hdcs"
        deck = [rank + suit for rank in ranks for suit in suits]
        deckGraphics = [QtSvg.QGraphicsSvgItem('./data/gfx/cards/replixanax/%s.svg'%card) for card in deck]
        random.shuffle(deckGraphics)

        for i in range(5):
            card = deckGraphics.pop()
            scene.addItem(card)
            card.setScale(0.8)
            card.setPos(280 + 50*i, 175)

        for p in avatarPositions:
            card = deckGraphics.pop()
            scene.addItem(card)
            card.setScale(0.8)
            p = p[0] - 10, p[1] - 5
            card.setPos(p[0], p[1])

            card = deckGraphics.pop()
            scene.addItem(card)
            card.setScale(0.8)
            p = p[0] + 22, p[1] + 10
            card.setPos(p[0], p[1])

        chips = [
            QtGui.QPixmap('./data/gfx/chips/default/chip0001.png'),
            QtGui.QPixmap('./data/gfx/chips/default/chip000025.png'),
            QtGui.QPixmap('./data/gfx/chips/default/chip000005.png')]
        def addchip(chip, scene, pos):
            other = scene.addPixmap(chip)
            other.setTransformationMode(QtCore.Qt.SmoothTransformation)
            other.setFlags(other.ItemIsMovable)
            other.setPos(*pos)
        start = 260
        off = 6
        addchip(chips[0], scene, (300, start))
        addchip(chips[0], scene, (300, start - off))
        addchip(chips[0], scene, (300, start - 2*off))
        addchip(chips[0], scene, (300, start - 3*off))
        addchip(chips[0], scene, (300, start - 4*off))
        addchip(chips[1], scene, (330, start))
        addchip(chips[1], scene, (330, start - off))
        addchip(chips[1], scene, (330, start - 2*off))
        addchip(chips[2], scene, (360, start))

        self.wgt = QtGui.QWidget()
        hbox = QtGui.QHBoxLayout()
        hbox.addStretch()
        fold = QtGui.QPushButton('Fold')
        fold.setObjectName('FoldBtn')
        #fold.setStyleSheet('background-color: #1169a4; width: 80px; font-size: 10pt; font-weight: bold; color: white;')
        fold.setCheckable(True)
        fold.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum)
        hbox.addWidget(fold)
        call = QtGui.QPushButton('Call\n$1')
        call.setObjectName('CallBtn')
        #call.setStyleSheet('background-color: #1169a4; width: 80px; font-size: 10pt; font-weight: bold; color: white;')
        call.setCheckable(True)
        call.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum)
        hbox.addWidget(call)
        hbox.addSpacing(20)
        rai = QtGui.QPushButton('Raise\n$2')
        rai.setObjectName('RaiseBtn')
        #rai.setStyleSheet('background-color: #1169a4; color: #ddf; width: 80px; height: 50px; font-size: 10pt; font-weight: bold;')
        rai.setCheckable(True)
        rai.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum)
        hbox.addWidget(rai)
        self.edit = QtGui.QLineEdit()
        self.edit.setValidator(QtGui.QDoubleValidator(0.0, -1.0, 2, self.edit))
        self.edit.setMaximumSize(60,28)
        self.edit.setText('1')
        #hbox.addWidget(self.edit, 0.2)
        self.slider = QtGui.QSlider(QtCore.Qt.Vertical)
        self.slider.setTickPosition(self.slider.TicksBelow)
        #self.slider.setStyleSheet('background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #B1B1B1, stop:1 #c4c4c4);')
        self.slider.valueChanged.connect(self.sliderMoved)
        self.edit.textChanged.connect(self.textChanged)
        #hbox.addWidget(self.slider)
        self.wgt.resize(500,100)
        #self.btn = QtGui.QPushButton('play')
        #self.btn.setAttribute(QtCore.Qt.WA_NoSystemBackground)
        self.wgt.setAttribute(QtCore.Qt.WA_NoSystemBackground)
        vboxnum = QtGui.QVBoxLayout()
        vboxnum.addStretch()
        vboxnum.addWidget(self.edit)
        hboxslider = QtGui.QHBoxLayout()
        hboxslider.addStretch()
        hboxslider.addLayout(vboxnum)
        hboxslider.addWidget(self.slider)
        vbox = QtGui.QVBoxLayout(self.wgt)
        #vbox.addStretch()
        vbox.addLayout(hboxslider)
        vbox.addLayout(hbox)
        size = self.pic.size()
        self.wgt.resize(size.width(), size.height())
        if QtCore.QDir.setCurrent('./data/gfx/table/default/'):
            self.wgt.setStyleSheet(str(common.loadStyleSheet('style.css')))
        QtCore.QDir.setCurrent('../../../../')
        scene.addWidget(self.wgt)
        self.view.setRenderHints(QtGui.QPainter.Antialiasing|QtGui.QPainter.SmoothPixmapTransform)
コード例 #17
0
    def draw(self):
        off = self.offset
        VSPACING = self.WIDTH / 400
        HSPACING = VSPACING * self.ASPECT

        # draw HICANN outline
        self.scene.addRect(off.x, off.y, self.WIDTH, self.HEIGHT,
                           QtGui.QPen(QtGui.QColor(0, 0, 0)),
                           QtGui.QBrush(QtGui.QColor(200, 200, 200)))

        t = self.scene.addText("{}\n\nEnum({})".format(self.id,
                                                       self.id.id().value()))
        t.setPos(off.x + self.WIDTH / 2 - 100., off.y + 100.)

        # draw horizontal lines
        for ii in range(HLineOnHICANN.end):
            Y = off.y + self.HEIGHT / 2 + (ii -
                                           HLineOnHICANN.end / 2) * HSPACING
            self.horizontalLines.append(
                self.scene.addLine(off.x, Y, off.x + self.WIDTH, Y,
                                   QtGui.QPen('gray')))

        # draw vertical lines
        for ii in range(VLineOnHICANN.end):
            X = off.x+ii*VSPACING if ii<VLineOnHICANN.end/2 \
                    else off.x+self.WIDTH+(ii-VLineOnHICANN.end)*VSPACING
            self.verticalLines.append(
                self.scene.addLine(X, off.y, X, off.y + self.HEIGHT,
                                   QtGui.QPen('gray')))

        # draw synapse drivers and switch rows
        for side in [LEFT, RIGHT]:
            LENGTH = self.HEIGHT / 2 - (HLineOnHICANN.end + 6) / 2 * HSPACING
            END = SynapseSwitchRowOnHICANN.y_type.end
            X0 = off.x if side == LEFT else off.x + self.WIDTH
            DX = VLineOnHICANN.end / 2 * VSPACING
            DIR = 1 if side == LEFT else -1

            for vside in [TOP, BOTTOM]:
                start = off.y + self.HEIGHT if int(vside) else off.y + LENGTH
                DY = LENGTH / (END / 2)
                for idx, yy in enumerate(
                        np.linspace(start - LENGTH, start, END / 2)):
                    row = SynapseSwitchRowOnHICANN(
                        side, pyhalbe.Coordinate.Y(int(vside) * END / 2 + idx))

                    try:
                        # there is a synapse driver:
                        drv = row.toSynapseDriverOnHICANN()
                        B = X0 + DIR * (DX + 20)
                        line = self.scene.addLine(X0, yy, X0 + DIR * (DX + 20),
                                                  yy)
                        line.hide()

                        # draw driver polygon
                        poly = QtGui.QPolygonF()
                        poly.append(QtCore.QPointF(B, yy + 4))  # upper
                        poly.append(QtCore.QPointF(B + DIR * 5, yy))  # mid
                        poly.append(QtCore.QPointF(B, yy - 4))  # lower
                        p = self.scene.addPolygon(poly)

                        self.synapseswitchLines[row] = line
                        self.synapsedriver[drv] = (line, p)

                    except ValueError as e:
                        # row has NO local synapse driver:
                        self.synapseswitchLines[row] = \
                                self.scene.addLine(X0, yy, X0+DIR*DX, yy)
                        self.synapseswitchLines[row].hide()

        if self.show_switches:
            self.drawSwitches()
コード例 #18
0
    def __init__(self, letters):
        super(EffectRaindrops, self).__init__(letters)

        for letter in self.letters:
            letter.setGuidedPos(QtCore.QPointF(random.randint(-100, 100),
                    random.randint(-200, 1100)))
コード例 #19
0
ファイル: client.py プロジェクト: wkoot/imperialism-remake
    def __init__(self, client):
        super().__init__()

        self.setAttribute(QtCore.Qt.WA_StyledBackground)
        self.setProperty('background', 'texture')

        layout = g.RelativeLayout(self)

        start_image = QtGui.QPixmap(c.extend(c.Graphics_UI_Folder, 'start.background.jpg'))
        start_image_item = QtGui.QGraphicsPixmapItem(start_image)
        start_image_item.setZValue(1)

        scene = QtGui.QGraphicsScene(self)
        scene.addItem(start_image_item)

        view = QtGui.QGraphicsView(scene)
        view.resize(start_image.size())
        view.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        view.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        view.setSceneRect(0, 0, start_image.width(), start_image.height())
        view.layout_constraint = g.RelativeLayoutConstraint().center_horizontal().center_vertical()
        layout.addWidget(view)

        subtitle = QtGui.QLabel('')
        subtitle.layout_constraint = g.RelativeLayoutConstraint((0.5, -0.5, 0),
                                                                (0.5, -0.5, start_image.height() / 2 + 20))
        layout.addWidget(subtitle)

        actions = {
            'exit': client.quit,
            'help': client.show_help_browser,
            'lobby': client.show_game_lobby_dialog,
            'editor': client.switch_to_editor_screen,
            'options': client.show_options_dialog
        }

        image_map_file = c.extend(c.Graphics_UI_Folder, 'start.overlay.info')
        image_map = u.read_as_yaml(image_map_file)

        # security check, they have to be the same
        if actions.keys() != image_map.keys():
            raise RuntimeError('Start screen hot map info file ({}) corrupt.'.format(image_map_file))

        for k, v in image_map.items():
            # add action from our predefined action dictionary
            pixmap = QtGui.QPixmap(c.extend(c.Graphics_UI_Folder, v['overlay']))
            mapitem = MapItem(view, pixmap, label=subtitle, description=v['label'])
            mapitem.item.setZValue(3)
            offset = v['offset']
            mapitem.item.setOffset(QtCore.QPointF(offset[0], offset[1]))
            mapitem.item.clicked.connect(actions[k])

            frame_path = QtGui.QPainterPath()
            frame_path.addRect(mapitem.item.boundingRect())
            frame_item = scene.addPath(frame_path, StartScreen.frame_pen)
            frame_item.setZValue(4)
            scene.addItem(mapitem.item)

        version_label = QtGui.QLabel('<font color=#ffffff>{}</font>'.format(t.get_option(c.O.VERSION)))
        version_label.layout_constraint = g.RelativeLayoutConstraint().east(20).south(20)
        layout.addWidget(version_label)
コード例 #20
0
    def __init__(self, letters):
        super(EffectLine, self).__init__(letters)

        for i, letter in enumerate(self.letters):
            letter.setGuidedPos(QtCore.QPointF(100, 500 + i * 20))
コード例 #21
0
ファイル: node.py プロジェクト: danbradham/nodify
 def r_pnts(self):
     '''QPoints for right side'''
     pnt_a = QtCore.QPointF(0, -self.height * 0.5)
     pnt_b = QtCore.QPointF(0, self.height * 0.5)
     pnt_c = QtCore.QPointF(-self.width * 0.5, 0)
     return pnt_a, pnt_b, pnt_c
コード例 #22
0
    def setupGuides(self):
        x = 0
        y = 20

        self.qtGuide1 = GuideCircle(QtCore.QRectF(x, y, 260, 260), -36, 342)
        GuideLine(QtCore.QPointF(x + 240, y + 268), self.qtGuide1)
        GuideLine(QtCore.QPointF(x + 265, y + 246), self.qtGuide1)
        GuideLine(QtCore.QPointF(x + 158, y + 134), self.qtGuide1)
        GuideLine(QtCore.QPointF(x + 184, y + 109), self.qtGuide1)
        GuideLine(QtCore.QPointF(x + 160, y +  82), self.qtGuide1)
        GuideLine(QtCore.QPointF(x +  77, y + 163), self.qtGuide1)
        GuideLine(QtCore.QPointF(x + 100, y + 190), self.qtGuide1)
        GuideLine(QtCore.QPointF(x + 132, y + 159), self.qtGuide1)
        GuideLine(QtCore.QPointF(x + 188, y + 211), self.qtGuide1)
        GuideCircle(QtCore.QRectF(x + 30, y + 30, 200, 200), -30, 336, GuideCircle.CW, self.qtGuide1)
        GuideLine(QtCore.QPointF(x + 238, y + 201), self.qtGuide1)

        y = 30
        self.qtGuide2 = GuideCircle(QtCore.QRectF(x + 30, y + 30, 200, 200), 135, 270, GuideCircle.CCW)
        GuideLine(QtCore.QPointF(x + 222, y + 38), self.qtGuide2)
        GuideCircle(QtCore.QRectF(x, y, 260, 260), 135, 270, GuideCircle.CW, self.qtGuide2)
        GuideLine(QtCore.QPointF(x + 59, y + 59), self.qtGuide2)

        x = 115
        y = 10
        self.qtGuide3 = GuideLine(QtCore.QLineF(x, y, x + 30, y))
        GuideLine(QtCore.QPointF(x + 30, y + 170), self.qtGuide3)
        GuideLine(QtCore.QPointF(x, y + 170), self.qtGuide3)
        GuideLine(QtCore.QPointF(x, y), self.qtGuide3)

        self.qtGuide1.setFence(QtCore.QRectF(0, 0, 800, 600))
        self.qtGuide2.setFence(QtCore.QRectF(0, 0, 800, 600))
        self.qtGuide3.setFence(QtCore.QRectF(0, 0, 800, 600))
コード例 #23
0
 def setCenterPos(self, pos):
     pos = QtCore.QPointF(pos)
     pos.setX(pos.x() - (self.size / 2.0))
     pos.setY(pos.y() - (self.size / 2.0))
     self.setPos(pos)
コード例 #24
0
ファイル: tab_quadtree.py プロジェクト: hvasbath/kite
 def __init__(self, leaf):
     self.id = leaf.id
     QtCore.QRectF.__init__(self,
                            QtCore.QPointF(leaf.llE, leaf.llN + leaf.sizeN),
                            QtCore.QPointF(leaf.llE + leaf.sizeE, leaf.llN))
コード例 #25
0
ファイル: kbackdrop.py プロジェクト: sonictk/Kraken
    def mouseMoveEvent(self, event):
        if self.__dragging:
            newPos = self.mapToScene(event.pos())

            graph = self.getGraph()
            if graph.getSnapToGrid() is True:
                gridSize = graph.getGridSize()

                newNodePos = newPos - self._mouseDelta

                snapPosX = math.floor(newNodePos.x() / gridSize) * gridSize
                snapPosY = math.floor(newNodePos.y() / gridSize) * gridSize
                snapPos = QtCore.QPointF(snapPosX, snapPosY)

                newPosOffset = snapPos - newNodePos

                newPos = newPos + newPosOffset

            delta = newPos - self._lastDragPoint
            self.__graph.moveSelectedNodes(delta)
            self._lastDragPoint = newPos
            self._nodesMoved = True

        elif self.__resizing:

            newPos = self.mapToScene(event.pos())
            delta = newPos - self._mouseDownPoint
            self._resizedBackdrop = True

            newPosX = 0
            newPosY = 0
            newWidth = self._initBoundingRect.width()
            newHeight = self._initBoundingRect.height()

            if self.__resizeCorner == 0:

                newWidth = self._initBoundingRect.width() + (delta.x() * -1.0)
                newHeight = self._initBoundingRect.height() + (delta.y() *
                                                               -1.0)

                if newWidth <= self.minimumWidth():
                    newWidth = self.minimumWidth()
                else:
                    newPosX = self._initPos.x() + delta.x()

                if newHeight <= self.minimumHeight():
                    newHeight = self.minimumHeight()
                else:
                    newPosY = self._initPos.y() + delta.y()

            elif self.__resizeCorner == 1:

                newWidth = self._initBoundingRect.width() + delta.x()
                newHeight = self._initBoundingRect.height() + (delta.y() *
                                                               -1.0)

                if newWidth <= self.minimumWidth():
                    newWidth = self.minimumWidth()
                else:
                    newPosX = self._initPos.x()

                if newHeight <= self.minimumHeight():
                    newHeight = self.minimumHeight()
                else:
                    newPosY = self._initPos.y() + delta.y()

            elif self.__resizeCorner == 2:

                newWidth = self._initBoundingRect.width() + (delta.x() * -1.0)
                newHeight = self._initBoundingRect.height() + delta.y()

                if newWidth <= self.minimumWidth():
                    newWidth = self.minimumWidth()
                else:
                    newPosX = self._initPos.x() + delta.x()

                if newHeight <= self.minimumHeight():
                    newHeight = self.minimumHeight()
                else:
                    newPosY = self._initPos.y()

            elif self.__resizeCorner == 3:
                newPosX = self._initPos.x()
                newPosY = self._initPos.y()
                newWidth = self._initBoundingRect.width() + delta.x()
                newHeight = self._initBoundingRect.height() + delta.y()

                if newWidth <= self.minimumWidth():
                    newWidth = self.minimumWidth()

                if newHeight <= self.minimumHeight():
                    newHeight = self.minimumHeight()

            elif self.__resizeEdge == 0:
                pass

            elif self.__resizeEdge == 1:
                newWidth = self._initBoundingRect.width() + delta.x()
                newHeight = self._initBoundingRect.height()

                newPosY = self._initPos.y()

                if newWidth <= self.minimumWidth():
                    newWidth = self.minimumWidth()
                else:
                    newPosX = self._initPos.x()

            elif self.__resizeEdge == 2:
                newWidth = self._initBoundingRect.width()
                newHeight = self._initBoundingRect.height() + delta.y()

                newPosX = self._initPos.x()

                if newHeight <= self.minimumHeight():
                    newHeight = self.minimumHeight()
                else:
                    newPosY = self._initPos.y()

            elif self.__resizeEdge == 3:
                newWidth = self._initBoundingRect.width() + (delta.x() * -1.0)
                newHeight = self._initBoundingRect.height()

                newPosY = self._initPos.y()

                if newWidth <= self.minimumWidth():
                    newWidth = self.minimumWidth()
                else:
                    newPosX = self._initPos.x() + delta.x()

            self.setPos(newPosX, newPosY)
            self.resize(newWidth, newHeight)

            self.sizeChanged.emit(newWidth)

            self.prepareGeometryChange()

        else:
            super(KBackdrop, self).mouseMoveEvent(event)
コード例 #26
0
    scene.addItem(p3)
    scene.addItem(p4)
    scene.addItem(p5)
    scene.addItem(p6)

    machine = QtCore.QStateMachine()
    state1 = QtCore.QState(machine)
    state2 = QtCore.QState(machine)
    state3 = QtCore.QState(machine)
    machine.setInitialState(state1)

    # State 1.
    state1.assignProperty(button, 'text', "Switch to state 2")
    state1.assignProperty(widget, 'geometry', QtCore.QRectF(0, 0, 400, 150))
    state1.assignProperty(box, 'geometry', QtCore.QRect(-200, 150, 200, 150))
    state1.assignProperty(p1, 'pos', QtCore.QPointF(68, 185))
    state1.assignProperty(p2, 'pos', QtCore.QPointF(168, 185))
    state1.assignProperty(p3, 'pos', QtCore.QPointF(268, 185))
    state1.assignProperty(p4, 'pos', QtCore.QPointF(68 - 150, 48 - 150))
    state1.assignProperty(p5, 'pos', QtCore.QPointF(168, 48 - 150))
    state1.assignProperty(p6, 'pos', QtCore.QPointF(268 + 150, 48 - 150))
    state1.assignProperty(p1, 'rotation', 0.0)
    state1.assignProperty(p2, 'rotation', 0.0)
    state1.assignProperty(p3, 'rotation', 0.0)
    state1.assignProperty(p4, 'rotation', -270.0)
    state1.assignProperty(p5, 'rotation', -90.0)
    state1.assignProperty(p6, 'rotation', 270.0)
    state1.assignProperty(boxProxy, 'opacity', 0.0)
    state1.assignProperty(p1, 'opacity', 1.0)
    state1.assignProperty(p2, 'opacity', 1.0)
    state1.assignProperty(p3, 'opacity', 1.0)
コード例 #27
0
ファイル: selector.py プロジェクト: CDAT/cdatgui
 def getCornerPoint( self, index ):
     return QtCore.QPointF( self.latlon_bounds[ 2*index ], self.latlon_bounds[ 2*index + 1 ] )
コード例 #28
0
 def paint(self, painter, option, widget):
     painter.drawPixmap(QtCore.QPointF(), self.p)
コード例 #29
0
 def convertArc(self, data):
     """Convert parameterization from endpoint to center.
     https://www.w3.org/TR/SVG/implnote.html#ArcConversionEndpointToCenter
     https://mortoray.com/2017/02/16/rendering-an-svg-elliptical-arc-as-bezier-curves/
     """
     from math import radians, sin, cos, sqrt
     import numpy as np
     x_1 = self.start_point.x()
     y_1 = self.start_point.y()
     r_x = data[0]
     r_y = data[1]
     phi = radians(data[2])  #rotation
     f_a = data[3]  #large arc
     f_s = data[4]  #sweep
     x_2 = data[5]
     y_2 = data[6]
     # NOTE: It seems that FreeCAD never apply rotation to the arcs.
     #       FreeCAD recalculate new values to the arc instead.
     xy_prime = np.mat([[cos(phi), sin(phi)], [-sin(phi), cos(phi)]]) * \
                np.array([[(x_1-x_2)/2], [(y_1-y_2)/2]])
     x_prime = xy_prime.item((0, 0))
     y_prime = xy_prime.item((1, 0))
     factor = -1 if f_a == f_s else 1
     cr = (x_prime / r_x)**2 + (y_prime / r_y)**2  #c ratio
     if cr > 1.0:
         r_x *= sqrt(cr)
         r_y *= sqrt(cr)
     dq = (r_x * y_prime)**2 + (r_y * x_prime)**2
     pq = ((r_x * r_y)**2 - dq) / dq
     c_prime = factor * sqrt(max([0, pq]))  #max ensure pq >= 0
     c_prime *= np.array([[r_x * y_prime / r_y], [-r_y * x_prime / r_x]])
     c = np.mat([[cos(phi), -sin(phi)], [sin(phi), cos(phi)]])*c_prime + \
         np.array([[(x_1+x_2)/2], [(y_1+y_2)/2]])
     c_x_prime = c_prime.item((0, 0))
     c_y_prime = c_prime.item((1, 0))
     start_angle = angleBetween(
         np.array([[1], [0]]),
         np.array([[(x_prime - c_x_prime) / r_x],
                   [(y_prime - c_y_prime) / r_y]]))
     arc_angle = angleBetween(
         np.array([[(x_prime - c_x_prime) / r_x],
                   [(y_prime - c_y_prime) / r_y]]),
         np.array([[(-x_prime - c_x_prime) / r_x],
                   [(-y_prime - c_y_prime) / r_y]])) % 360
     if f_s == 0 and arc_angle > 0:
         arc_angle -= 360
     elif f_s == 1 and arc_angle < 0:
         arc_angle += 360
     # TODO: consider phi here to calculate rect
     # Real rect (dimensions in millimiters)
     rect = QtCore.QRectF()
     width = 2 * r_x
     height = 2 * r_y
     rect.setWidth(width)
     rect.setHeight(height)
     center = QtCore.QPointF(c.item((0, 0)), c.item((1, 0)))
     rect.moveCenter(center)
     self.path_data = (rect, -start_angle, -arc_angle)
     # Rect to be drawn (dimensions in pixels)
     rect = QtCore.QRectF()
     rect.setWidth(mmtopx(width))
     rect.setHeight(mmtopx(height))
     center = QtCore.QPointF(mmtopx(c.item((0, 0))), mmtopx(c.item((1, 0))))
     rect.moveCenter(center)
     return (rect, -start_angle, -arc_angle)
コード例 #30
0
 def boundingRect(self):
     return QtCore.QRectF(QtCore.QPointF(0, 0), QtCore.QSizeF(self.p.size()))