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


C++ QPainterPath::currentPosition方法代码示例

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


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

示例1: drawFace

QGIFace* QGIViewPart::drawFace(TechDrawGeometry::Face* f, int idx)
{
    std::vector<TechDrawGeometry::Wire *> fWires = f->wires;
    QPainterPath facePath;
    for(std::vector<TechDrawGeometry::Wire *>::iterator wire = fWires.begin(); wire != fWires.end(); ++wire) {
        QPainterPath wirePath;
        for(std::vector<TechDrawGeometry::BaseGeom *>::iterator edge = (*wire)->geoms.begin(); edge != (*wire)->geoms.end(); ++edge) {
            //Save the start Position
            QPainterPath edgePath = drawPainterPath(*edge);
            // If the current end point matches the shape end point the new edge path needs reversing
            QPointF shapePos = (wirePath.currentPosition()- edgePath.currentPosition());
            if(sqrt(shapePos.x() * shapePos.x() + shapePos.y()*shapePos.y()) < 0.05) {    //magic tolerance
                edgePath = edgePath.toReversed();
            }
            wirePath.connectPath(edgePath);
        }
        //dumpPath("wirePath:",wirePath);
        facePath.addPath(wirePath);
    }
    facePath.setFillRule(Qt::OddEvenFill);

    QGIFace* gFace = new QGIFace(idx);
    addToGroup(gFace);
    gFace->setPos(0.0,0.0);
    gFace->setPath(facePath);
    //debug a path
    //std::stringstream faceId;
    //faceId << "facePath " << idx;
    //dumpPath(faceId.str().c_str(),facePath);

    return gFace;
}
开发者ID:wwmayer,项目名称:FreeCAD,代码行数:32,代码来源:QGIViewPart.cpp

示例2: paintEvent

void SearchButton::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);
    QPainterPath myPath;

    int radius = (height() / 5) * 2;
    QRect circle(height() / 3 - 1, height() / 4, radius, radius);
    myPath.addEllipse(circle);

    myPath.arcMoveTo(circle, 300);
    QPointF c = myPath.currentPosition();
    int diff = height() / 7;
    myPath.lineTo(qMin(width() - 2, (int)c.x() + diff), c.y() + diff);

    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing, true);
    painter.setPen(QPen(Qt::darkGray, 2));
    painter.drawPath(myPath);

    if (m_menu) {
        QPainterPath dropPath;
        dropPath.arcMoveTo(circle, 320);
        QPointF c = dropPath.currentPosition();
        c = QPointF(c.x() + 3.5, c.y() + 0.5);
        dropPath.moveTo(c);
        dropPath.lineTo(c.x() + 4, c.y());
        dropPath.lineTo(c.x() + 2, c.y() + 2);
        dropPath.closeSubpath();
        painter.setPen(Qt::darkGray);
        painter.setBrush(Qt::darkGray);
        painter.setRenderHint(QPainter::Antialiasing, false);
        painter.drawPath(dropPath);
    }
    painter.end();
}
开发者ID:ariya,项目名称:arora,代码行数:35,代码来源:searchlineedit.cpp

示例3: ri

//------------------------------------------------------------------------------
void
Canvas::DrawAnnulus(int x, int y,
                    unsigned inner_r, unsigned outer_r,
                    Angle start, Angle end)
  {
  QPainterPath p;
  QRectF ri(x - inner_r, y - inner_r, 2 * inner_r, 2 * inner_r);
  QRectF ro(x - outer_r, y - outer_r, 2 * outer_r, 2 * outer_r);
  // Draw the inner radius of the annulus.
  p.arcMoveTo(ri, start.Degrees());
  p.arcTo(ri, start.Degrees(), end.Degrees() - start.Degrees());
  if (start != end)
    { // Only draw the end caps when needed.
    // The currentPosition() will be at the end of the inner circle. Draw
    // one side of the annulus.
    // \todo This doesn't work because Angle(360) != Angle(0)!
    double xx = (outer_r - inner_r) * cos(end.Radians()) +
                p.currentPosition().rx();
    double yy = (outer_r - inner_r) * -sin(end.Radians()) +
                p.currentPosition().ry();
    p.lineTo(xx, yy);
    }
  else
    p.arcMoveTo(ro, end.Degrees());  // Set up for the outer circle.
  // The currentPosition() will be at the 'end' of the outer circle. Draw the
  // outer to the start.
  p.arcTo(ro, end.Degrees(), start.Degrees() - end.Degrees());
  if (start != end)
    {// And close it off to finish up.
    p.closeSubpath();
    }
  this->pushObject(p, this->pen(), this->brush());
  }
开发者ID:Exadios,项目名称:YCSoar,代码行数:34,代码来源:Canvas.cpp

示例4: drawScale

void AttitudeIndicator::drawScale(QPainter *painter, const QPointF &center,
    double radius, double origin, double minArc, double maxArc) const
{
    // counter clockwise, radian

    const double dir = (360.0 - origin) * M_PI / 180.0;
    const double offset = 4.0;

    const QPointF p0 = qwtPolar2Pos( center, offset, dir + M_PI );

    const double w = innerRect().width();

    QPainterPath path;
    path.moveTo( qwtPolar2Pos( p0, w, dir - M_PI_2 ) );
    path.lineTo( qwtPolar2Pos( path.currentPosition(), 2 * w, dir + M_PI_2 ) );
    path.lineTo( qwtPolar2Pos( path.currentPosition(), w, dir ) );
    path.lineTo( qwtPolar2Pos( path.currentPosition(), w, dir - M_PI_2 ) );

    painter->save();
    painter->setClipPath( path ); // swallow 180 - 360 degrees

    QwtDial::drawScale(painter,
        center, radius, origin, minArc, maxArc);

    painter->restore();
}
开发者ID:BryanF1947,项目名称:GoldenCheetah,代码行数:26,代码来源:attitude_indicator.cpp

示例5: renderToPath

QRectF GlyphElement::renderToPath( const QString& raw, QPainterPath& path ) const
{
    Q_UNUSED( raw )
    Q_UNUSED( path )
    // try to lookup the char in the font database
    AttributeManager am;
    QString fontFamily = am.stringOf( "fontfamily", this );
    QFontDatabase db;
    QFont tmpFont;

    // determine if the specified font and glyph can be found
    if( db.families().contains( fontFamily ) )
    {
        tmpFont.setFamily( fontFamily );
        path.addText( path.currentPosition(), tmpFont,
                      QChar( am.stringOf( "index", this ).toInt() ) ); 
        QFontMetricsF fm(tmpFont);
        return fm.boundingRect(QChar( am.stringOf( "index", this ).toInt() ) );
    }
    else { // if not found use alt text
        path.addText( path.currentPosition(), font(), am.stringOf( "alt", this ) );
        QFontMetricsF fm(font());
        return fm.boundingRect(am.stringOf( "alt", this ));
    }
}
开发者ID:KDE,项目名称:koffice-formulashape,代码行数:25,代码来源:GlyphElement.cpp

示例6: createPlotPath

void RealTimeMultiSampleArrayDelegate::createPlotPath(const QModelIndex &index, QPainterPath& path, QList< QVector<float> >& data) const
{
    //get maximum range of respective channel type (range value in FiffChInfo does not seem to contain a reasonable value)
    qint32 kind = (static_cast<const RealTimeMultiSampleArrayModel*>(index.model()))->m_qListChInfo[index.row()].getKind();
    float fMaxValue = 1e-9;

//    switch(kind) {
//        case FIFFV_MEG_CH: {
//            qint32 unit = (static_cast<const RealTimeMultiSampleArrayModel*>(index.model()))->m_pfiffIO->m_qlistRaw[0]->info.chs[index.row()].unit;
//            if(unit == FIFF_UNIT_T_M) {
//                dMaxValue = m_qSettings.value("RawDelegate/max_meg_grad").toDouble();
//            }
//            else if(unit == FIFF_UNIT_T)
//                dMaxValue = m_qSettings.value("RawDelegate/max_meg_mag").toDouble();
//            break;
//        }
//        case FIFFV_EEG_CH: {
//            dMaxValue = m_qSettings.value("RawDelegate/max_eeg").toDouble();
//            break;
//        }
//        case FIFFV_EOG_CH: {
//            dMaxValue = m_qSettings.value("RawDelegate/max_eog").toDouble();
//            break;
//        }
//        case FIFFV_STIM_CH: {
//            dMaxValue = m_qSettings.value("RawDelegate/max_stim").toDouble();
//            break;
//        }
//    }

    float fValue;
    float fScaleY = m_fPlotHeight/(2*fMaxValue);

    float y_base = path.currentPosition().y();
    QPointF qSamplePosition;

    //plot all rows from list of pairs
    for(qint8 i=0; i < data.size(); ++i) {
        //create lines from one to the next sample
        for(qint32 j=0; j < data[i].size(); ++j)
        {
            float val = data[i][j];
            fValue = val*fScaleY;

            float newY = y_base+fValue;

            qSamplePosition.setY(newY);
            qSamplePosition.setX(path.currentPosition().x()+m_fDx);

            path.lineTo(qSamplePosition);
        }
    }

//    qDebug("Plot-PainterPath created!");
}
开发者ID:TiKunze,项目名称:mne-cpp,代码行数:55,代码来源:realtimemultisamplearraydelegate.cpp

示例7: createPlotPath

void RawDelegate::createPlotPath(const QModelIndex &index, QPainterPath& path, QList<RowVectorPair>& listPairs) const
{
    //get maximum range of respective channel type (range value in FiffChInfo does not seem to contain a reasonable value)
    qint32 kind = (static_cast<const RawModel*>(index.model()))->m_chInfolist[index.row()].kind;
    double dMaxValue = 1e-9;

    switch(kind) {
    case FIFFV_MEG_CH: {
        qint32 unit = (static_cast<const RawModel*>(index.model()))->m_pfiffIO->m_qlistRaw[0]->info.chs[index.row()].unit;
        if(unit == FIFF_UNIT_T_M) {
            dMaxValue = m_qSettings.value("RawDelegate/max_meg_grad").toDouble();
        }
        else if(unit == FIFF_UNIT_T)
            dMaxValue = m_qSettings.value("RawDelegate/max_meg_mag").toDouble();
        break;
    }
    case FIFFV_EEG_CH: {
        dMaxValue = m_qSettings.value("RawDelegate/max_eeg").toDouble();
        break;
    }
    case FIFFV_EOG_CH: {
        dMaxValue = m_qSettings.value("RawDelegate/max_eog").toDouble();
        break;
    }
    case FIFFV_STIM_CH: {
        dMaxValue = m_qSettings.value("RawDelegate/max_stim").toDouble();
        break;
    }
    }

    double dValue;
    double dScaleY = m_dPlotHeight/(2*dMaxValue);

    double y_base = path.currentPosition().y();
    QPointF qSamplePosition;

    //plot all rows from list of pairs
    for(qint8 i=0; i < listPairs.size(); ++i) {
        //create lines from one to the next sample
        for(qint32 j=0; j < listPairs[i].second; ++j)
        {
            double val = *(listPairs[i].first+j);
            dValue = val*dScaleY;

            double newY = y_base+dValue;

            qSamplePosition.setY(newY);
            qSamplePosition.setX(path.currentPosition().x()+m_dDx);

            path.lineTo(qSamplePosition);
        }
    }

//    qDebug("Plot-PainterPath created!");
}
开发者ID:TiKunze,项目名称:mne-cpp,代码行数:55,代码来源:rawdelegate.cpp

示例8: currentPosition

void tst_QPainterPath::currentPosition()
{
    QPainterPath p;

    QCOMPARE(p.currentPosition(), QPointF());

    p.moveTo(100, 100);
    QCOMPARE(p.currentPosition(), QPointF(100, 100));

    p.lineTo(200, 200);
    QCOMPARE(p.currentPosition(), QPointF(200, 200));

    p.cubicTo(300, 200, 200, 300, 500, 500);
    QCOMPARE(p.currentPosition(), QPointF(500, 500));
}
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:15,代码来源:tst_qpainterpath.cpp

示例9: createGridPath

void RealTimeMultiSampleArrayDelegate::createGridPath(QPainterPath& path, QList< QVector<float> >& data) const
{
    //horizontal lines
    float distance = m_fPlotHeight/m_nhlines;

    QPointF startpos = path.currentPosition();
    QPointF endpoint(path.currentPosition().x()+data[0].size()*data.size()*m_fDx,path.currentPosition().y());

    for(qint8 i=0; i < m_nhlines-1; ++i) {
        endpoint.setY(endpoint.y()+distance);
        path.moveTo(startpos.x(),endpoint.y());
        path.lineTo(endpoint);
    }

//    qDebug("Grid-PainterPath created!");
}
开发者ID:TiKunze,项目名称:mne-cpp,代码行数:16,代码来源:realtimemultisamplearraydelegate.cpp

示例10: createGridPath

void RawDelegate::createGridPath(QPainterPath& path, QList<RowVectorPair>& listPairs) const
{
    //horizontal lines
    double distance = m_dPlotHeight/m_nhlines;

    QPointF startpos = path.currentPosition();
    QPointF endpoint(path.currentPosition().x()+listPairs[0].second*listPairs.size()*m_dDx,path.currentPosition().y());

    for(qint8 i=0; i < m_nhlines-1; ++i) {
        endpoint.setY(endpoint.y()+distance);
        path.moveTo(startpos.x(),endpoint.y());
        path.lineTo(endpoint);
    }

//    qDebug("Grid-PainterPath created!");
}
开发者ID:TiKunze,项目名称:mne-cpp,代码行数:16,代码来源:rawdelegate.cpp

示例11: addToPainterPath

void QgsCircularString::addToPainterPath( QPainterPath &path ) const
{
  int nPoints = numPoints();
  if ( nPoints < 1 )
  {
    return;
  }

  if ( path.isEmpty() || path.currentPosition() != QPointF( mX[0], mY[0] ) )
  {
    path.moveTo( QPointF( mX[0], mY[0] ) );
  }

  for ( int i = 0; i < ( nPoints - 2 ) ; i += 2 )
  {
    QgsPointSequence pt;
    segmentize( QgsPointV2( mX[i], mY[i] ), QgsPointV2( mX[i + 1], mY[i + 1] ), QgsPointV2( mX[i + 2], mY[i + 2] ), pt );
    for ( int j = 1; j < pt.size(); ++j )
    {
      path.lineTo( pt.at( j ).x(), pt.at( j ).y() );
    }
    //arcTo( path, QPointF( mX[i], mY[i] ), QPointF( mX[i + 1], mY[i + 1] ), QPointF( mX[i + 2], mY[i + 2] ) );
  }

  //if number of points is even, connect to last point with straight line (even though the circular string is not valid)
  if ( nPoints % 2 == 0 )
  {
    path.lineTo( mX[ nPoints - 1 ], mY[ nPoints - 1 ] );
  }
}
开发者ID:cayetanobv,项目名称:QGIS,代码行数:30,代码来源:qgscircularstring.cpp

示例12: initialItemPosition

//=============================================================================
int sstQt01PathStoreViewCls::createDefaultItems(int iKey)
{
  //-----------------------------------------------------------------------------
  if ( iKey != 0) return -1;

  QPainterPath circlePath;
  QPainterPath squarePath;
  QPainterPath trianglePath;

  circlePath.addEllipse(QRect(0, 0, 100, 100));
  squarePath.addRect(QRect(0, 0, 100, 100));

  qreal x = trianglePath.currentPosition().x();
  qreal y = trianglePath.currentPosition().y();
  trianglePath.moveTo(x + 120 / 2, y);
  trianglePath.lineTo(0, 100);
  trianglePath.lineTo(120, 100);
  trianglePath.lineTo(x + 120 / 2, y);

  sstQt01ShapeItem oItem;

  oItem.createShapeItem(circlePath, "Circle", initialItemPosition(circlePath),
                  initialItemColor(),eSstQt01PathCircle);
  this->appendShapeItem(oItem);

  oItem.createShapeItem(squarePath, "Square", initialItemPosition(squarePath),
                  initialItemColor(),eSstQt01PathArea);
  this->appendShapeItem(oItem);

  oItem.createShapeItem(trianglePath, "Triangle",
                  initialItemPosition(trianglePath), initialItemColor(),eSstQt01PathArea);
  this->appendShapeItem(oItem);

  return 0;
}
开发者ID:UliRehr15,项目名称:sstQt01Lib,代码行数:36,代码来源:sstQt01PathStoreView.cpp

示例13: createGridPath

void PlotSignalWidget::createGridPath(QPainterPath& path)
{
    //horizontal lines
    qint8 m_nhlines = 6;
    double distance = m_dPlotHeight/m_nhlines;

    path.moveTo(0,-m_dPlotHeight/2+distance);

    for(qint8 i=0; i < m_nhlines-1; ++i) {
        QPointF endpoint(this->width(),path.currentPosition().y());
        path.lineTo(endpoint);
        path.moveTo(0,path.currentPosition().y()+distance);
    }

    qDebug("Grid-PainterPath created!");
}
开发者ID:BulatSuleymanoff,项目名称:mne-cpp,代码行数:16,代码来源:plotsignalwidget.cpp

示例14: updateTitleBar

//-------------------------------------------------------------------------
void QGuidoItemContainer::updateTitleBar()
{
	int barHeight = QFontMetrics( mHeadBar->textItem()->font() ).height();

	QPainterPath path;
	path.moveTo( 0 , barHeight );
	path.arcTo( QRect(0,0,ROUNDED_RECT_RADIUS * 2 , ROUNDED_RECT_RADIUS * 2) , 180 , -90 );
	path.lineTo( rect().width() - ROUNDED_RECT_RADIUS * 2 , 0 );
	path.arcTo( QRect( path.currentPosition().x() , path.currentPosition().y() ,ROUNDED_RECT_RADIUS * 2 , ROUNDED_RECT_RADIUS * 2) , 90 , -90 );
	path.lineTo( rect().width() , barHeight );
	path.closeSubpath();

	mHeadBar->setPath( path );

	updateTitleText();
	updateTitleBarVisibility();
}
开发者ID:EQ4,项目名称:guido-engine,代码行数:18,代码来源:QGuidoItemContainer.cpp

示例15: paintMediaToggleClosedCaptionsButton

bool RenderThemeQt::paintMediaToggleClosedCaptionsButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
{
    HTMLMediaElement* mediaElement = toParentMediaElement(o);
    if (!mediaElement)
        return false;

    QSharedPointer<StylePainter> p = getStylePainter(paintInfo);
    if (p.isNull() || !p->isValid())
        return true;

    p->painter->setRenderHint(QPainter::Antialiasing, true);

    paintMediaBackground(p->painter, r);

    WorldMatrixTransformer transformer(p->painter, o, r);
    p->painter->setBrush(getMediaControlForegroundColor(o));

    QPainterPath captionBubble;
    captionBubble.moveTo(98.766, 43.244);
    captionBubble.cubicTo(captionBubble.currentPosition() + QPointF(0, -23.163), captionBubble.currentPosition() + QPointF(-21.775, -41.94), captionBubble.currentPosition() + QPointF(-48.637, -41.94));
    captionBubble.cubicTo(captionBubble.currentPosition() + QPointF(-26.859, 0), captionBubble.currentPosition() + QPointF(-48.635, 18.777), captionBubble.currentPosition() + QPointF(-48.635, 41.94));
    captionBubble.cubicTo(captionBubble.currentPosition() + QPointF(0, 18.266), captionBubble.currentPosition() + QPointF(13.546, 33.796), captionBubble.currentPosition() + QPointF(32.444, 39.549));
    captionBubble.cubicTo(captionBubble.currentPosition() + QPointF(1.131, 8.356), captionBubble.currentPosition() + QPointF(26.037, 24.255), captionBubble.currentPosition() + QPointF(22.864, 19.921));
    captionBubble.cubicTo(captionBubble.currentPosition() + QPointF(-4.462, -6.096), captionBubble.currentPosition() + QPointF(-5.159, -13.183), captionBubble.currentPosition() + QPointF(-5.07, -17.566));
    captionBubble.cubicTo(QPointF(77.85, 84.397), QPointF(98.766, 65.923), QPointF(98.766, 43.224));
    captionBubble.closeSubpath();

    p->painter->drawPath(captionBubble);
    return false;
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:30,代码来源:RenderThemeQt.cpp


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