当前位置: 首页>>代码示例>>C++>>正文


C++ QPoint::y方法代码示例

本文整理汇总了C++中QPoint::y方法的典型用法代码示例。如果您正苦于以下问题:C++ QPoint::y方法的具体用法?C++ QPoint::y怎么用?C++ QPoint::y使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QPoint的用法示例。


在下文中一共展示了QPoint::y方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Inside

bool Connection::Inside(const QPoint &p)
{
    int x=(n1->x+n2->x)/2;
    int y=(n1->y+n2->y)/2;
    return pow(p.x()-x,2)+pow(p.y()-y,2)<pow(15,2);
}
开发者ID:b0xer,项目名称:Artificial-Intellect-course,代码行数:6,代码来源:connection.cpp

示例2: screenToTileCoords

/**
 * Converts screen to tile coordinates. Sub-tile return values are not
 * supported by this renderer.
 */
QPointF HexagonalRenderer::screenToTileCoords(qreal x, qreal y) const
{
    const RenderParams p(map());

    if (p.staggerX)
        x -= p.staggerEven ? p.tileWidth : p.sideOffsetX;
    else
        y -= p.staggerEven ? p.tileHeight : p.sideOffsetY;

    // Start with the coordinates of a grid-aligned tile
    QPoint referencePoint = QPoint(qFloor(x / (p.columnWidth * 2)),
                                   qFloor(y / (p.rowHeight * 2)));

    // Relative x and y position on the base square of the grid-aligned tile
    const QVector2D rel(x - referencePoint.x() * (p.columnWidth * 2),
                        y - referencePoint.y() * (p.rowHeight * 2));

    // Adjust the reference point to the correct tile coordinates
    int &staggerAxisIndex = p.staggerX ? referencePoint.rx() : referencePoint.ry();
    staggerAxisIndex *= 2;
    if (p.staggerEven)
        ++staggerAxisIndex;

    // Determine the nearest hexagon tile by the distance to the center
    QVector2D centers[4];

    if (p.staggerX) {
        const int left = p.sideLengthX / 2;
        const int centerX = left + p.columnWidth;
        const int centerY = p.tileHeight / 2;

        centers[0] = QVector2D(left,                    centerY);
        centers[1] = QVector2D(centerX,                 centerY - p.rowHeight);
        centers[2] = QVector2D(centerX,                 centerY + p.rowHeight);
        centers[3] = QVector2D(centerX + p.columnWidth, centerY);
    } else {
        const int top = p.sideLengthY / 2;
        const int centerX = p.tileWidth / 2;
        const int centerY = top + p.rowHeight;

        centers[0] = QVector2D(centerX,                 top);
        centers[1] = QVector2D(centerX - p.columnWidth, centerY);
        centers[2] = QVector2D(centerX + p.columnWidth, centerY);
        centers[3] = QVector2D(centerX,                 centerY + p.rowHeight);
    }

    int nearest = 0;
    qreal minDist = std::numeric_limits<qreal>::max();

    for (int i = 0; i < 4; ++i) {
        const QVector2D &center = centers[i];
        const qreal dc = (center - rel).lengthSquared();
        if (dc < minDist) {
            minDist = dc;
            nearest = i;
        }
    }

    static const QPoint offsetsStaggerX[4] = {
        QPoint( 0,  0),
        QPoint(+1, -1),
        QPoint(+1,  0),
        QPoint(+2,  0),
    };
    static const QPoint offsetsStaggerY[4] = {
        QPoint( 0,  0),
        QPoint(-1, +1),
        QPoint( 0, +1),
        QPoint( 0, +2),
    };

    const QPoint *offsets = p.staggerX ? offsetsStaggerX : offsetsStaggerY;
    return referencePoint + offsets[nearest];
}
开发者ID:Bertram25,项目名称:tiled,代码行数:78,代码来源:hexagonalrenderer.cpp

示例3: drawSelection

void IconWidget::drawSelection(QPainter& painter, QPoint selection)
{
    QRect selectionRect = QRect(ICON_SIZE * selection.x(), ICON_SIZE * selection.y(), ICON_SIZE, ICON_SIZE);

    painter.drawRect(selectionRect);
}
开发者ID:igorko,项目名称:FlareFramework,代码行数:6,代码来源:iconwidget.cpp

示例4: drawGrid

void HexagonalRenderer::drawGrid(QPainter *painter, const QRectF &exposed,
                                 QColor gridColor) const
{
    QRect rect = exposed.toAlignedRect();
    if (rect.isNull())
        return;

    const RenderParams p(map());

    // Determine the tile and pixel coordinates to start at
    QPoint startTile = screenToTileCoords(rect.topLeft()).toPoint();
    QPoint startPos = tileToScreenCoords(startTile).toPoint();

    /* Determine in which half of the tile the top-left corner of the area we
     * need to draw is. If we're in the upper half, we need to start one row
     * up due to those tiles being visible as well. How we go up one row
     * depends on whether we're in the left or right half of the tile.
     */
    const bool inUpperHalf = rect.y() - startPos.y() < p.sideOffsetY;
    const bool inLeftHalf = rect.x() - startPos.x() < p.sideOffsetX;

    if (inUpperHalf)
        startTile.ry()--;
    if (inLeftHalf)
        startTile.rx()--;

    startTile.setX(qMax(0, startTile.x()));
    startTile.setY(qMax(0, startTile.y()));

    startPos = tileToScreenCoords(startTile).toPoint();

    const QPoint oct[8] = {
        QPoint(0,                           p.tileHeight - p.sideOffsetY),
        QPoint(0,                           p.sideOffsetY),
        QPoint(p.sideOffsetX,               0),
        QPoint(p.tileWidth - p.sideOffsetX, 0),
        QPoint(p.tileWidth,                 p.sideOffsetY),
        QPoint(p.tileWidth,                 p.tileHeight - p.sideOffsetY),
        QPoint(p.tileWidth - p.sideOffsetX, p.tileHeight),
        QPoint(p.sideOffsetX,               p.tileHeight)
    };

    QVector<QLine> lines;
    lines.reserve(8);

    gridColor.setAlpha(128);

    QPen gridPen(gridColor);
    gridPen.setCosmetic(true);
    gridPen.setDashPattern(QVector<qreal>() << 2 << 2);
    painter->setPen(gridPen);

    if (p.staggerX) {
        // Odd row shifting is applied in the rendering loop, so un-apply it here
        if (p.doStaggerX(startTile.x()))
            startPos.ry() -= p.rowHeight;

        for (; startPos.x() <= rect.right() && startTile.x() < map()->width(); startTile.rx()++) {
            QPoint rowTile = startTile;
            QPoint rowPos = startPos;

            if (p.doStaggerX(startTile.x()))
                rowPos.ry() += p.rowHeight;

            for (; rowPos.y() <= rect.bottom() && rowTile.y() < map()->height(); rowTile.ry()++) {
                lines.append(QLine(rowPos + oct[1], rowPos + oct[2]));
                lines.append(QLine(rowPos + oct[2], rowPos + oct[3]));
                lines.append(QLine(rowPos + oct[3], rowPos + oct[4]));

                const bool isStaggered = p.doStaggerX(startTile.x());
                const bool lastRow = rowTile.y() == map()->height() - 1;
                const bool lastColumn = rowTile.x() == map()->width() - 1;
                const bool bottomLeft = rowTile.x() == 0 || (lastRow && isStaggered);
                const bool bottomRight = lastColumn || (lastRow && isStaggered);

                if (bottomRight)
                    lines.append(QLine(rowPos + oct[5], rowPos + oct[6]));
                if (lastRow)
                    lines.append(QLine(rowPos + oct[6], rowPos + oct[7]));
                if (bottomLeft)
                    lines.append(QLine(rowPos + oct[7], rowPos + oct[0]));

                painter->drawLines(lines);
                lines.resize(0);

                rowPos.ry() += p.tileHeight + p.sideLengthY;
            }

            startPos.rx() += p.columnWidth;
        }
    } else {
        // Odd row shifting is applied in the rendering loop, so un-apply it here
        if (p.doStaggerY(startTile.y()))
            startPos.rx() -= p.columnWidth;

        for (; startPos.y() <= rect.bottom() && startTile.y() < map()->height(); startTile.ry()++) {
            QPoint rowTile = startTile;
            QPoint rowPos = startPos;

            if (p.doStaggerY(startTile.y()))
//.........这里部分代码省略.........
开发者ID:Bertram25,项目名称:tiled,代码行数:101,代码来源:hexagonalrenderer.cpp

示例5: updateMousePos

void Window::updateMousePos(QPoint pos)
{
    QString temp;
    temp.sprintf("Current/Last Mouse Pos: (%d, %d)", pos.x(), pos.y());
    statusBar->showMessage(temp);
}
开发者ID:NurKaynar,项目名称:hacklab,代码行数:6,代码来源:window.cpp

示例6: drawCoordinates

void SingleCellViewGraphPanelPlotOverlayWidget::drawCoordinates(QPainter *pPainter,
                                                                const QPoint &pPoint,
                                                                const QColor &pBackgroundColor,
                                                                const QColor &pForegroundColor,
                                                                const Location &pLocation,
                                                                const bool &pCanMoveLocation)
{
    // Retrieve the size of coordinates as they will appear on the screen,
    // which means using the same font as the one used for the axes
    // Note: normally, pPoint would be a QPointF, but we want the coordinates to
    //       be drawn relative to something (see paintEvent()) and the only way
    //       to guarantee that everything will be painted as expected is to use
    //       QPoint. Indeed, if we were to use QPointF, then QPainter would have
    //       to do some rouding and though everything should be fine (since we
    //       always add/subtract a rounded number), it happens that it's not
    //       always the case. Indeed, we should always have a gap of one pixel
    //       between the coordinates and pPoint, but it could happen that we
    //       have either no gap or one of two pixels...

    pPainter->setFont(mOwner->axisFont(QwtPlot::xBottom));

    QPointF point = mOwner->canvasPoint(pPoint, false);
    QString coordinates = QString("X: %1\nY: %2").arg(QLocale().toString(point.x(), 'g', 15),
                                                      QLocale().toString(point.y(), 'g', 15));
    QRect coordinatesRect = pPainter->boundingRect(qApp->desktop()->availableGeometry(), 0, coordinates);

    // Determine where the coordinates and its background should be drawn

    switch (pLocation) {
    case TopLeft:
        coordinatesRect.moveTo(pPoint.x()-coordinatesRect.width()-1,
                               pPoint.y()-coordinatesRect.height()-1);

        break;
    case TopRight:
        coordinatesRect.moveTo(pPoint.x()+2,
                               pPoint.y()-coordinatesRect.height()-1);

        break;
    case BottomLeft:
        coordinatesRect.moveTo(pPoint.x()-coordinatesRect.width()-1,
                               pPoint.y()+2);

        break;
    case BottomRight:
        coordinatesRect.moveTo(pPoint.x()+2,
                               pPoint.y()+2);

        break;
    }

    if (pCanMoveLocation) {
        QwtScaleMap canvasMapX = mOwner->canvasMap(QwtPlot::xBottom);
        QwtScaleMap canvasMapY = mOwner->canvasMap(QwtPlot::yLeft);

        QPoint topLeftPoint = QPoint(canvasMapX.transform(mOwner->minX()),
                                     canvasMapY.transform(mOwner->maxY()));
        QPoint bottomRightPoint = QPoint(canvasMapX.transform(mOwner->maxX()),
                                         canvasMapY.transform(mOwner->minY()));

        if (coordinatesRect.top() < topLeftPoint.y())
            coordinatesRect.moveTop(pPoint.y()+2);
        else if (coordinatesRect.top()+coordinatesRect.height()-1 > bottomRightPoint.y())
            coordinatesRect.moveTop(pPoint.y()-coordinatesRect.height()-1);

        if (coordinatesRect.left() < topLeftPoint.x())
            coordinatesRect.moveLeft(pPoint.x()+2);
        else if (coordinatesRect.left()+coordinatesRect.width()-1 > bottomRightPoint.x())
            coordinatesRect.moveLeft(pPoint.x()-coordinatesRect.width()-1);

        // Note: the -1 for the else-if tests is because fillRect() below works
        //       on (0, 0; width-1, height-1)...
    }

    // Draw a filled rectangle to act as the background for the coordinates
    // we are to show

    pPainter->fillRect(coordinatesRect, pBackgroundColor);

    // Draw the text for the coordinates, using a white pen

    QPen pen = pPainter->pen();

    pen.setColor(pForegroundColor);

    pPainter->setPen(pen);

    pPainter->drawText(coordinatesRect, coordinates);
}
开发者ID:Fairly,项目名称:opencor,代码行数:89,代码来源:singlecellviewgraphpanelplotwidget.cpp

示例7: collect

void hrAdventureScreen::collect()
{
    clearItems();

    const QVector<hrTile> &tiles = isUnderground ? tilesUnderground : tilesGround;
    QList<hrSceneObject> &objects = isUnderground ? objectsUnderground : objectsGround;

    if (tiles.isEmpty())
        return;

    for (int i = viewport.width() - 1; i >= 0; i--)
        for (int j = viewport.height() - 1; j >= 0; j--)
        {
            QPoint pos = coord::toPix(QPoint(i, j));
            QPoint index = viewport.topLeft() + QPoint(i, j);

            const hrTile &tile = tiles.at(index.y() * size.width() + index.x());

            hrGraphicsItem item = itemsTerrain[tile.terrainId];
            item.setCurFrame(tile.terrainFrame);
            item.setMirror(tile.isTerrainHorizontal(), tile.isTerrainVertical());
            item.setPoint(pos);
            addItem(item);

            if (tile.hasRiver())
            {
                hrGraphicsItem item = itemsRiver[tile.riverId];
                item.setCurFrame(tile.riverFrame);
                item.setMirror(tile.isRiverHorizontal(), tile.isRiverVertical());
                item.setPoint(pos);
                addItem(item);
            }
            if (tile.hasRoad())
            {
                drawRoad(tile, pos);
            }
        }

    if (viewport.y() > 0)
    {
        for (int i = 0; i < viewport.width(); i++)
        {
            QPoint pos = coord::toPix(QPoint(i, -1));
            QPoint index = viewport.topLeft() + QPoint(i, -1);

            const hrTile &tile = tiles.at(index.y() * size.width() + index.x());

            if (tile.hasRoad())
            {
                drawRoad(tile, pos);
            }
        }
    }

    QMutableListIterator<hrSceneObject> it(objects);

    while (it.hasNext())
    {
        hrSceneObject &obj = it.next();

        if (viewport.intersects(obj.getRect()))
        {
            QPoint pos = coord::toPix(obj.getPoint() - viewport.topLeft());
            hrGraphicsItem item = itemsObject[obj.getId()];
            item.setCurFrame(isAnimate ? obj.getNextFrame() : obj.getCurFrame());
            item.setPoint(pos);
            addItem(item);
        }
    }

    isAnimate = false;
}
开发者ID:Kaffeine,项目名称:openhomm,代码行数:72,代码来源:hrAdventureScreen.cpp

示例8: relayoutItems

// QListView does item layout in a very inflexible way, so let's do our custom layout again.
// FIXME: this is very inefficient, but due to the design flaw of QListView, this is currently the only workaround.
void DesktopWindow::relayoutItems() {
  loadItemPositions(); // something may have changed
  // qDebug("relayoutItems()");
  if(relayoutTimer_) {
    // this slot might be called from the timer, so we cannot delete it directly here.
    relayoutTimer_->deleteLater();
    relayoutTimer_ = NULL;
  }

  QDesktopWidget* desktop = qApp->desktop();
  int screen = 0;
  int row = 0;
  int rowCount = proxyModel_->rowCount();
  for(;;) {
    if(desktop->isVirtualDesktop()) {
      if(screen >= desktop->numScreens())
        break;
    }else {
      screen = screenNum_;
    }
    QRect workArea = desktop->availableGeometry(screen);
    workArea.adjust(12, 12, -12, -12); // add a 12 pixel margin to the work area
    // qDebug() << "workArea" << screen <<  workArea;
    // FIXME: we use an internal class declared in a private header here, which is pretty bad.
    QSize grid = listView_->gridSize();
    QPoint pos = workArea.topLeft();
    for(; row < rowCount; ++row) {
      QModelIndex index = proxyModel_->index(row, 0);
      int itemWidth = delegate_->sizeHint(listView_->getViewOptions(), index).width();
      FmFileInfo* file = proxyModel_->fileInfoFromIndex(index);
      QByteArray name = fm_file_info_get_name(file);
      QHash<QByteArray, QPoint>::iterator it = customItemPos_.find(name);
      if(it != customItemPos_.end()) { // the item has a custom position
        QPoint customPos = *it;
        // center the contents vertically
        listView_->setPositionForIndex(customPos + QPoint((grid.width() - itemWidth) / 2, 0), index);
        // qDebug() << "set custom pos:" << name << row << index << customPos;
        continue;
      }
      // check if the current pos is alredy occupied by a custom item
      bool used = false;
      for(it = customItemPos_.begin(); it != customItemPos_.end(); ++it) {
        QPoint customPos = *it;
        if(QRect(customPos, grid).contains(pos)) {
          used = true;
          break;
        }
      }
      if(used) { // go to next pos
        --row;
      }
      else {
        // center the contents vertically
        listView_->setPositionForIndex(pos + QPoint((grid.width() - itemWidth) / 2, 0), index);
        // qDebug() << "set pos" << name << row << index << pos;
      }
      // move to next cell in the column
      pos.setY(pos.y() + grid.height() + listView_->spacing());
      if(pos.y() + grid.height() > workArea.bottom() + 1) {
        // if the next position may exceed the bottom of work area, go to the top of next column
        pos.setX(pos.x() + grid.width() + listView_->spacing());
        pos.setY(workArea.top());

        // check if the new column exceeds the right margin of work area
        if(pos.x() + grid.width() > workArea.right() + 1) {
          if(desktop->isVirtualDesktop()) {
            // in virtual desktop mode, go to next screen
            ++screen;
            break;
          }
        }
      }
    }
    if(row >= rowCount)
      break;
  }
}
开发者ID:TECOMP111,项目名称:pcmanfm-qt,代码行数:79,代码来源:desktopwindow.cpp

示例9: paint_all

void DiagramCanvas::paint_all( QRect& r )
{
    int i;
    QPainter p( &buffer );
    QPen pen;
    QBrush brush;
    QPointArray a;
    QColor color;
    QRegion mask, crossing_disk;
    set<double>::iterator dbl_it;

    for ( i=0; i<crossingList.size(); ++i )
    {
        Crossing *c = crossingList[i];

        c->under->underpasses.insert( c->under->underpasses.end(), c->position_on_understrand );
    }

    for ( i=0; i<edgeList.size(); ++i )
    {
        Edge *e = edgeList[i];

        pen.setWidth( e->thickness );
        pen.setColor( CANVAS );
        p.setPen( pen );

        QPoint v, v1, v2, p1, p2 ;

        p1 = e->vertex[begin]->position;
        p2 = e->vertex[end]->position;
        p.drawLine( p1, p2 );
/*
      if (e->edge_type==singular)
        {

                v = p1 - p2;
                v1.setX( v.x() - v.y() );
                v1.setY( v.x() + v.y() );
                v2.setX( v.x() + v.y() );
                v2.setY( -v.x() + v.y() );

                v1 = 5 * v1 / sqrt( double (v1.x() * v1.x() + v1.y() * v1.y()) );
                v2 = 5 * v2 / sqrt( double (v2.x() * v2.x() + v2.y() * v2.y()) );
                v  = v / 2;
                pen.setWidth( ARROW );
                p.setPen( pen );
                p.drawLine( p2+v, p2+v1+v );
                p.drawLine( p2+v, p2+v2+v );
        }
*/
    }

    for ( i=0; i<edgeList.size(); ++i )
    {
        Edge *e = edgeList[i];

        color = (e->edge_type == drilled) ? DRILLED : colorList[e->arc_id % 18 ];

        pen.setWidth( e->thickness );
        pen.setColor( color );
        p.setPen( pen );

        brush.setColor( color );
        brush.setStyle( SolidPattern );
        p.setBrush( brush );

        if ( e->underpasses.size() > 0 )
        {
            p.setClipping( TRUE );
            mask = QRegion( 0, 0, width(), height(), QRegion::Rectangle );

            for ( dbl_it=e->underpasses.begin(); dbl_it!=e->underpasses.end(); ++dbl_it )
            {
                QPoint center = time_to_point( e, *dbl_it );
                crossing_disk = QRegion( center.x()-7, center.y()-7, 14, 14 , QRegion::Ellipse );
                mask -= crossing_disk;
            }

            p.setClipRegion( mask );
            QPoint v, v1, v2, p1, p2 ;

            p1 = e->vertex[begin]->position;
            p2 = e->vertex[end]->position;
            p.drawLine( p1, p2 );
/*
            if (e->edge_type==singular)
            {
                v = p1 - p2;
                v1.setX( v.x() - v.y() );
                v1.setY( v.x() + v.y() );
                v2.setX( v.x() + v.y() );
                v2.setY( -v.x() + v.y() );

                v1 = 5 * v1 / sqrt( double (v1.x() * v1.x() + v1.y() * v1.y()) );
                v2 = 5 * v2 / sqrt( double (v2.x() * v2.x() + v2.y() * v2.y()) );
                v  = v / 2;
                pen.setWidth( ARROW );
                p.setPen( pen );
                p.drawLine( p2+v, p2+v1+v );
                p.drawLine( p2+v, p2+v2+v );
//.........这里部分代码省略.........
开发者ID:DamianHeard,项目名称:orb,代码行数:101,代码来源:diagram_canvas.cpp

示例10: mouseMoveEvent

void SurfaceRenderWidget::mouseMoveEvent( QMouseEvent *event )
{
	if( !this->process_input_events )
		return;

	if( event->buttons() & Qt::LeftButton )
	{
		int x = event->x();
		int y = event->y();

		// rotate clipping object
		GLdouble angle = sqrt( ( double ) ( last_point.y() - y ) * ( last_point.y() - y ) + ( last_point.x() - x ) * ( last_point.x() - x ) );
		GLdouble axis_x = -( last_point.y() - y ) / angle;
		GLdouble axis_y = -( last_point.x() - x ) / angle;

		if( ( axis_x != 0 || axis_y != 0 ) && angle != 0 )
			bbox_transform = GLMatrix<GLfloat>::identity().applyRotate( angle, axis_x, axis_y, 0.0 ) * bbox_transform;
	}
	else
	{
		QPoint diff = last_point - event->pos();
		surface_transform = bbox_transform.inverse() * GLMatrix<GLfloat>().loadTranslate( -diff.x() / GLfloat( this->width() ), diff.y() / GLfloat( this->height() ), 0.0f ) * bbox_transform * surface_transform;
	}
	last_point = event->pos();
	update();
}
开发者ID:porst17,项目名称:realsurf,代码行数:26,代码来源:SurfaceRenderWidget.cpp

示例11: relationTo

/*! \reimp */
QAccessible::Relation QAccessibleWidget::relationTo(int child,
            const QAccessibleInterface *other, int otherChild) const
{
    Relation relation = Unrelated;
    if (d->asking == this) // recursive call
        return relation;

    QObject *o = other ? other->object() : 0;
    if (!o)
        return relation;

    QWidget *focus = widget()->focusWidget();
    if (object() == focus && isAncestor(o, focus))
        relation |= FocusChild;

    QACConnectionObject *connectionObject = (QACConnectionObject*)object();
    for (int sig = 0; sig < d->primarySignals.count(); ++sig) {
        if (connectionObject->isSender(o, d->primarySignals.at(sig).toAscii())) {
            relation |= Controller;
            break;
        }
    }
    // test for passive relationships.
    // d->asking protects from endless recursion.
    d->asking = this;
    int inverse = other->relationTo(otherChild, this, child);
    d->asking = 0;

    if (inverse & Controller)
        relation |= Controlled;
    if (inverse & Label)
        relation |= Labelled;

    if(o == object()) {
        if (child && !otherChild)
            return relation | Child;
        if (!child && otherChild)
            return relation | Ancestor;
        if (!child && !otherChild)
            return relation | Self;
    }

    QObject *parent = object()->parent();
    if (o == parent)
        return relation | Child;

    if (o->parent() == parent) {
        relation |= Sibling;
        QAccessibleInterface *sibIface = QAccessible::queryAccessibleInterface(o);
        Q_ASSERT(sibIface);
        QRect wg = rect(0);
        QRect sg = sibIface->rect(0);
        if (wg.intersects(sg)) {
            QAccessibleInterface *pIface = 0;
            sibIface->navigate(Ancestor, 1, &pIface);
            if (pIface && !((sibIface->state(0) | state(0)) & Invisible)) {
                int wi = pIface->indexOfChild(this);
                int si = pIface->indexOfChild(sibIface);

                if (wi > si)
                    relation |= QAccessible::Covers;
                else
                    relation |= QAccessible::Covered;
            }
            delete pIface;
        } else {
            QPoint wc = wg.center();
            QPoint sc = sg.center();
            if (wc.x() < sc.x())
                relation |= QAccessible::Left;
            else if(wc.x() > sc.x())
                relation |= QAccessible::Right;
            if (wc.y() < sc.y())
                relation |= QAccessible::Up;
            else if (wc.y() > sc.y())
                relation |= QAccessible::Down;
        }
        delete sibIface;

        return relation;
    }

    if (isAncestor(o, object()))
        return relation | Descendent;
    if (isAncestor(object(), o))
        return relation | Ancestor;

    return relation;
}
开发者ID:fluxer,项目名称:katie,代码行数:90,代码来源:qaccessiblewidget.cpp

示例12: mouseMoveEvent

void BleImageProcess::mouseMoveEvent(QMouseEvent *event)
{
    if (!m_activePair) return;

    QRect topLeftRect(m_activePair->rect.x(), m_activePair->rect.y(), 8, 8);
    QRect bottomRightRect(m_activePair->rect.bottomRight().x() - 8, m_activePair->rect.bottomRight().y() - 8, 8, 8);

    if (topLeftRect.contains(event->pos())) {
        setCursor(Qt::SizeFDiagCursor);
    } else if (bottomRightRect.contains(event->pos())) {
        setCursor(Qt::SizeFDiagCursor);
    } else if (m_activePair->rect.contains(event->pos())) {
        setCursor(Qt::SizeAllCursor);
    } else {
        setCursor(Qt::ArrowCursor);
    }

    if (m_startResize) {
        if (m_resizeFromTopLeft) {
            m_activePair->rect.setTopLeft(event->pos());
        }

        if (m_resizeFromBottomRight){
            m_activePair->rect.setBottomRight(event->pos());
        }
    }

    if (m_startMove) {
        QPoint diff = QPoint(event->pos().x() - m_lastMovePoint.x(), event->pos().y() - m_lastMovePoint.y());

        int w = m_activePair->rect.width();
        int h = m_activePair->rect.height();
        m_activePair->rect.setTopLeft(QPoint(m_activePair->rect.x() + diff.x(), m_activePair->rect.y() + diff.y()));
        m_activePair->rect.setWidth(w);
        m_activePair->rect.setHeight(h);
    }

    if (m_startResize || m_startMove) {
        updateSources();
    }

    update();
    m_lastMovePoint = event->pos();
}
开发者ID:JaydenChou,项目名称:Bull-Live-Encoder,代码行数:44,代码来源:BleImageProcess.cpp

示例13: navigate

/*! \reimp */
int QAccessibleWidget::navigate(RelationFlag relation, int entry,
                                QAccessibleInterface **target) const
{
    if (!target)
        return -1;

    *target = 0;
    QObject *targetObject = 0;

    QWidgetList childList = childWidgets(widget());
    bool complexWidget = childList.size() < childCount();

    switch (relation) {
    // Hierarchical
    case Self:
        targetObject = object();
        break;
    case Child:
        if (complexWidget) {
            if (entry > 0 && entry <= childCount())
                return entry;
            return -1;
        }else {
            if (entry > 0 && childList.size() >= entry)
                targetObject = childList.at(entry - 1);
        }
        break;
    case Ancestor:
        {
            if (entry <= 0)
                return -1;
            targetObject = widget()->parentWidget();
            int i;
            for (i = entry; i > 1 && targetObject; --i)
                targetObject = targetObject->parent();
            if (!targetObject && i == 1)
                targetObject = qApp;
        }
        break;
    case Sibling:
        {
            QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(parentObject());
            if (!iface)
                return -1;

            iface->navigate(Child, entry, target);
            delete iface;
            if (*target)
                return 0;
        }
        break;

    // Geometrical
    case QAccessible::Left:
        if (complexWidget && entry) {
            if (entry < 2 || widget()->height() > widget()->width() + 20) // looks vertical
                return -1;
            return entry - 1;
        }
        // fall through
    case QAccessible::Right:
        if (complexWidget && entry) {
            if (entry >= childCount() || widget()->height() > widget()->width() + 20) // looks vertical
                return -1;
            return entry + 1;
        }
        // fall through
    case QAccessible::Up:
        if (complexWidget && entry) {
            if (entry < 2 || widget()->width() > widget()->height() + 20) // looks horizontal
                return - 1;
            return entry - 1;
        }
        // fall through
    case QAccessible::Down:
        if (complexWidget && entry) {
            if (entry >= childCount() || widget()->width() > widget()->height()  + 20) // looks horizontal
                return - 1;
            return entry + 1;
        } else {
            QAccessibleInterface *pIface = QAccessible::queryAccessibleInterface(parentObject());
            if (!pIface)
                return -1;

            QRect startg = rect(0);
            QPoint startc = startg.center();
            QAccessibleInterface *candidate = 0;
            int mindist = 100000;
            int sibCount = pIface->childCount();
            for (int i = 0; i < sibCount; ++i) {
                QAccessibleInterface *sibling = 0;
                pIface->navigate(Child, i+1, &sibling);
                Q_ASSERT(sibling);
                if ((relationTo(0, sibling, 0) & Self) || (sibling->state(0) & QAccessible::Invisible)) {
                    //ignore ourself and invisible siblings
                    delete sibling;
                    continue;
                }

//.........这里部分代码省略.........
开发者ID:fluxer,项目名称:katie,代码行数:101,代码来源:qaccessiblewidget.cpp

示例14: MouseFuncPress

void RtKeyboard::MouseFuncPress(int iPressY,int iIndex)
{
    iPressY = 0;

    QPoint keyOffset = QPoint(-10,-60);
    QRect rectPressBtn = m_pFuncButton[iIndex]->geometry();
    QString strKey;
    QRect rectBtnText = QRect(18,16,15,15);

    //Delete the Select Key, if it is exist.
    if(m_pSelectKey) {
        delete m_pSelectKey;
        m_pSelectKey = NULL;
    }

    QWidget *parent = (QWidget*)this->parent();
    if(parent == NULL)
        parent = this;

	strKey = m_pFuncButton[iIndex]->text();

    QRect rectKeyboard = this->geometry();
    int iSrcWidth = rectKeyboard.x()+rectPressBtn.x()+keyOffset.x();
    int iSrcHeight = rectKeyboard.y()+rectPressBtn.y()+keyOffset.y();

    m_pSelectKey = new RtKeyButton(parent);

    if(iIndex == __FUN_KEY_0__)
    {
        m_pSelectKey->SetImages(&m_Key4[1],&m_Key4[1]);
        m_pSelectKey->setGeometry(iSrcWidth,iSrcHeight,m_Key4[1].width(),m_Key4[1].height());
    }
    else if(iIndex == __FUN_KEY_1__)//Function Key #1
    {
        m_pSelectKey->SetImages(&m_Key_Switch[1],&m_Key_Switch[1]);
        m_pSelectKey->setGeometry(iSrcWidth,iSrcHeight,m_Key_Switch[1].width(),m_Key_Switch[1].height());
     }
    else if(iIndex == __FUN_KEY_2__)//Function Key #2
    {
        QRect rectFun2Text = QRect(18,16,30,15);
        m_pSelectKey->setButtonText(strKey,rectFun2Text);
        m_pSelectKey->SetImages(&m_Key_Del[1],&m_Key_Del[1]);
        m_pSelectKey->setGeometry(iSrcWidth,iSrcHeight,m_Key_Del[1].width(),m_Key_Del[1].height());
    }
    else if(iIndex == __FUN_KEY_3__)//Function Key #3
    {
        QRect rectFun3Text = QRect(14,16,35,15);
        m_pSelectKey->SetImages(&m_Key7[1],&m_Key7[1]);
        m_pSelectKey->setGeometry(iSrcWidth,iSrcHeight,m_Key7[1].width(),m_Key7[1].height());
        m_pSelectKey->setButtonText(strKey,rectFun3Text);
    }
    else if(iIndex == __FUN_KEY_4__)//Function Key #4
    {
        QRect rectFun4Text = QRect(18,16,30,15);
        m_pSelectKey->SetImages(&m_Key_Enter[1],&m_Key_Enter[1]);
        m_pSelectKey->setGeometry(iSrcWidth,iSrcHeight,m_Key_Enter[1].width(),m_Key_Enter[1].height());
        m_pSelectKey->setButtonText(strKey,rectFun4Text);
    }
    else if(iIndex == __FUN_KEY_5__)//Function Key #5
    {
        m_pSelectKey->SetImages(&m_Key3[1],&m_Key3[1]);
        m_pSelectKey->setGeometry(iSrcWidth,iSrcHeight,m_Key3[1].width(),m_Key3[1].height());
        m_pSelectKey->setButtonText(strKey,rectBtnText);
    }
    else if(iIndex == __FUN_KEY_6__)//Function Key #6
    {
        m_pSelectKey->SetImages(&m_Key3[1],&m_Key3[1]);
        m_pSelectKey->setGeometry(iSrcWidth,iSrcHeight,m_Key3[1].width(),m_Key3[1].height());
        m_pSelectKey->setButtonText(strKey,rectBtnText);
    }

    m_pSelectKey->setAlignStyle(RtKeyButton::AlignCenter);
    m_pSelectKey->setEnabled(false);
    m_pSelectKey->show();
}
开发者ID:bravesheng,项目名称:offroad-navi,代码行数:75,代码来源:RtKeyboard.cpp

示例15: CreateScreenshot

void MediaSourceDesktop::CreateScreenshot()
{
    AVFrame             *tRGBFrame;
    int 				tCaptureResX = mSourceResX;
    int					tCaptureResY = mSourceResY;

    mMutexGrabberActive.lock();

//    LOG(LOG_VERBOSE, "Source: %d * %d", mSourceResX, mSourceResY);
//    LOG(LOG_VERBOSE, "Target: %d * %d", mTargetResX, mTargetResY);

    if (!mMediaSourceOpened)
    {
    	mMutexGrabberActive.unlock();
    	return;
    }

    if (mWidget == NULL)
    {
    	LOG(LOG_ERROR, "Capture widget is invalid");
    	mMutexGrabberActive.unlock();
    	return;
    }

    QTime tCurrentTime = QTime::currentTime();
    int tTimeDiff = mLastTimeGrabbed.msecsTo(tCurrentTime);

    //### skip capturing when we are too slow
    if (tTimeDiff < 1000 / (mInputFrameRate + 0.5 /* some tolerance! */))
    {
        #ifdef MSD_DEBUG_PACKETS
            LOG(LOG_VERBOSE, "Screen capturing skipped because system is too fast");
        #endif
		mMutexGrabberActive.unlock();
    	return;
    }

    if (mLastTimeGrabbed == QTime(0, 0, 0, 0))
    {
        mLastTimeGrabbed = tCurrentTime;
        mMutexGrabberActive.unlock();
        return;
    }else
        mLastTimeGrabbed = tCurrentTime;

    //### skip capturing when we are too slow
    if (tTimeDiff > 1000 / MIN_GRABBING_FPS)
    {
    	LOG(LOG_WARN, "Screen capturing skipped because system is too busy");
    	mMutexGrabberActive.unlock();
    	return;
    }

    //####################################################################
    //### AUTO DESKTOP
    //####################################################################
    QDesktopWidget *tDesktop = QApplication::desktop();
    if (mAutoDesktop)
    {
        tCaptureResX = tDesktop->availableGeometry(tDesktop->primaryScreen()).width();
        tCaptureResY = tDesktop->availableGeometry(tDesktop->primaryScreen()).height();
    }
    if (mAutoScreen)
    {
		#ifdef APPLE
			tCaptureResX = CGDisplayPixelsWide(CGMainDisplayID());
			tCaptureResY = CGDisplayPixelsHigh(CGMainDisplayID());
		#else
			tCaptureResX = tDesktop->screenGeometry(tDesktop->primaryScreen()).width();
			tCaptureResY = tDesktop->screenGeometry(tDesktop->primaryScreen()).height();
		#endif
	}

    //####################################################################
    //### GRABBING
    //####################################################################
    QPixmap tSourcePixmap;
    // screen capturing
	#if !defined(APPLE) || defined(HOMER_QT5)
    	tSourcePixmap = QPixmap::grabWindow(mWidget->winId(), mGrabOffsetX, mGrabOffsetY, tCaptureResX, tCaptureResY);
	#else
		CGImageRef tOSXWindowImage = CGWindowListCreateImage(CGRectInfinite, kCGWindowListOptionOnScreenOnly, mWidget->winId(), kCGWindowImageDefault);
		tSourcePixmap = QPixmap::fromMacCGImageRef(tOSXWindowImage).copy(mGrabOffsetX, mGrabOffsetY, tCaptureResX, tCaptureResY);
		CGImageRelease(tOSXWindowImage);
	#endif

	//####################################################################
	//### SCALING to source resolution
	//####################################################################
	if ((tSourcePixmap.width() != mSourceResX) || (tSourcePixmap.height() != mSourceResY))
	{// we have to adapt the assumed source resolution
		//LOG(LOG_VERBOSE, "Have to rescale from %d*%d to %d*%d", tSourcePixmap.width(), tSourcePixmap.height(), mSourceResX, mSourceResY);
		tSourcePixmap = tSourcePixmap.scaled(mSourceResX, mSourceResY);
	}

	//####################################################################
	//### MOUSE VISUALIZATION
	//####################################################################
	if (mMouseVisualization)
	{
//.........这里部分代码省略.........
开发者ID:Homer-Conferencing,项目名称:Homer-Conferencing,代码行数:101,代码来源:MediaSourceDesktop.cpp


注:本文中的QPoint::y方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。