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


C++ QPainter::setPen方法代码示例

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


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

示例1: drawBeatCircles

void IntervalProgressDisplay::drawBeatCircles(QPainter& p, int hRadius, int vRadius, int beatCircles, int offset) {
    paintEllipticalPath(p, hRadius, vRadius);

    double angle = -PI / 2.0;

    const float FIRST_COLOR_POSITION = 0.0f;
    const float SECOND_COLOR_POSITION = 0.99f;

    //float hRadius = width()/2;
    //float vRadius = height()/2;

    for (int i = 0; i < beatCircles; i++) {

        int x = centerX + (hRadius  * std::cos(angle));// - ovalSize /2;
        int y = (centerY + (vRadius * std::sin(angle))) + ovalSize/2;

        QRadialGradient brush(x + ovalSize/2, y, ovalSize*2);
        QPen pen(Qt::NoPen);

        //p->drawLine(0, centerY, width(), centerY);

        //beat not played yet
        brush.setColorAt(FIRST_COLOR_POSITION, Qt::gray);
        brush.setColorAt(SECOND_COLOR_POSITION, Qt::black);

        bool isIntervalFirstBeat = i + offset == 0;
        bool isMeasureFirstBeat = (i + offset) % beatsPerAccent == 0;
        if (i + offset == currentBeat && (isIntervalFirstBeat || isMeasureFirstBeat)) {//first beats
            if( isIntervalFirstBeat || isShowingAccents() ){
                brush.setColorAt(FIRST_COLOR_POSITION, QColor(255, 100, 100));//accent beat colors
                brush.setColorAt(SECOND_COLOR_POSITION, Qt::red);
            }
            else{
                brush.setColorAt(FIRST_COLOR_POSITION, Qt::green); //playing beat highlight colors
                brush.setColorAt(SECOND_COLOR_POSITION, Qt::darkGreen);
            }
            pen.setColor(Qt::darkGray);
            pen.setStyle(Qt::SolidLine);
        }
        else{
            if((i + offset) % beatsPerAccent == 0 && (i+offset) > currentBeat){
                if(isShowingAccents()){
                    brush.setColorAt(FIRST_COLOR_POSITION, Qt::white); //accent marks
                    brush.setColorAt(SECOND_COLOR_POSITION, Qt::gray);

                    pen.setColor(Qt::gray);
                    pen.setStyle(Qt::SolidLine);
                }
            }
            else if ( (i + offset) <= currentBeat) {
                if(i + offset < currentBeat){
                    brush.setColorAt(FIRST_COLOR_POSITION, PLAYED_BEATS_FIRST_COLOR); //played beats
                    brush.setColorAt(SECOND_COLOR_POSITION, PLAYED_BEATS_SECOND_COLOR);
                }
                else{//the current beat is highlighted
                    brush.setColorAt(FIRST_COLOR_POSITION, Qt::green); //playing beat highlight colors
                    brush.setColorAt(SECOND_COLOR_POSITION, Qt::darkGreen);

                    pen.setColor(Qt::darkGreen);
                    pen.setStyle(Qt::SolidLine);
                }
            }
        }

        p.setBrush(brush);
        p.setPen( pen );
        int size = (i + offset) == currentBeat ? ovalSize + 1 : ovalSize;
        p.drawEllipse( QPoint(x, y), size, size);

        if(offset > 0 && currentBeat < offset){//is drawing the first circles?
            p.setBrush(QColor(255,255, 255, 200)); //the internal circles are drawed transparent
            p.drawEllipse( QPoint(x, y), size, size);
        }

        angle -= 2 * -PI / beatCircles;

    }
}
开发者ID:Ezeer,项目名称:JomTobo,代码行数:78,代码来源:IntervalProgressDisplay.cpp

示例2: drawOnionSkinSelection

void FilmstripFrameHeadGadget::drawOnionSkinSelection(QPainter &p, const QColor &lightColor, const QColor &darkColor)
{
	int currentRow = getCurrentFrame();

	TPixel frontPixel, backPixel;
	bool inksOnly;
	Preferences::instance()->getOnionData(frontPixel, backPixel, inksOnly);
	QColor frontColor((int)frontPixel.r, (int)frontPixel.g, (int)frontPixel.b, 128);
	QColor backColor((int)backPixel.r, (int)backPixel.g, (int)backPixel.b, 128);

	OnionSkinMask osMask = TApp::instance()->getCurrentOnionSkin()->getOnionSkinMask();
	int mosCount = osMask.getMosCount();

	int i;
	//OnionSkinの円の左上座標のy値
	int onionDotYPos = m_dy / 2 - 5;

	p.setPen(Qt::red);
	//--- OnionSkinが有効なら実線、無効なら点線
	if (!osMask.isEnabled()) {
		QPen currentPen = p.pen();
		currentPen.setStyle(Qt::DashLine);
		currentPen.setColor(QColor(128, 128, 128, 255));
		p.setPen(currentPen);
	}
	//カレントフレームにOnionSkinを伸ばすハンドルを描画
	{
		int angle180 = 16 * 180;
		QRectF handleRect(0, 0, 30, 30);

		//上向きのハンドル:1フレーム目のときは描画しない
		if (currentRow > 0) {
			int y0 = index2y(currentRow) - 15;
			p.setBrush(QBrush(backColor));
			p.drawChord(handleRect.translated(0, y0), 0, angle180);
		}

		//下向きのハンドル:最終フレームの時は描画しない
		std::vector<TFrameId> fids;
		m_filmstrip->getLevel()->getFids(fids);
		int frameCount = (int)fids.size();
		if (currentRow < frameCount - 1) {
			int y1 = index2y(currentRow + 1) - 15;
			p.setBrush(QBrush(frontColor));
			p.drawChord(handleRect.translated(0, y1), angle180, angle180);
		}

		//--- 動く Onion Skinの描画 その1
		//先に線を描く
		//まず OnionSkinの最大/最小値を取得
		int minMos = 0;
		int maxMos = 0;
		for (i = 0; i < mosCount; i++) {
			int mos = osMask.getMos(i);
			if (minMos > mos)
				minMos = mos;
			if (maxMos < mos)
				maxMos = mos;
		}
		p.setBrush(Qt::NoBrush);
		//min/maxが更新されていたら、線を描く
		if (minMos < 0) //上方向に伸ばす線
		{
			int y0 = index2y(currentRow + minMos) + onionDotYPos + 10; //10は●の直径
			int y1 = index2y(currentRow) - 15;
			p.drawLine(15, y0, 15, y1);
		}
		if (maxMos > 0) //下方向に伸ばす線
		{
			int y0 = index2y(currentRow + 1) + 15;
			int y1 = index2y(currentRow + maxMos) + onionDotYPos;
			p.drawLine(15, y0, 15, y1);
		}
	}

	//--- Fix Onion Skinの描画
	for (i = 0; i < osMask.getFosCount(); i++) {
		int fos = osMask.getFos(i);
		//if(fos == currentRow) continue;
		int y = index2y(fos) + onionDotYPos;
		p.setPen(Qt::red);
		//OnionSkinがDisableなら中空にする
		p.setBrush(osMask.isEnabled() ? QBrush(QColor(0, 255, 255, 128)) : Qt::NoBrush);
		p.drawEllipse(0, y, 10, 10);
	}
	//---

	//--- 動く Onion Skinの描画 その2

	//続いて、各OnionSkinの●を描く
	p.setPen(Qt::red);
	for (i = 0; i < mosCount; i++) {
		//mosはOnionSkinの描かれるフレームのオフセット値
		int mos = osMask.getMos(i);
		//100312 iwasawa ハイライトする場合は後で描くのでスキップする
		if (currentRow + mos == m_highlightedMosFrame)
			continue;

		int y = index2y(currentRow + mos) + onionDotYPos;

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

示例3: drawDiagonals

void QtGrid::drawDiagonals( QPainter &painter )
{
    painter.setPen( QPen( diagonal_color, 1 ) );
    //painter.drawLine( ( int )x(), ( int )y(), ( int )x() + _width, ( int )y() + _height );
    //painter.drawLine( ( int )x(), ( int )y() + _height, ( int )x() + _width, ( int )y() );
}
开发者ID:BackupTheBerlios,项目名称:ktoon-svn,代码行数:6,代码来源:qtgrid.cpp

示例4: Draw

void GraphScale::Draw(QPainter &painter)
{
    double scale;
    int x,y,w,w_max,font_h = QFontMetrics(font).height();

    painter.setPen(pen);
    painter.setFont(font);

    switch (pos)
    {
      case pos_bottom:
        scale = graph->w / (vmax-vmin);
        painter.drawLine(graph->xo,graph->yo,graph->xo+graph->w,graph->yo);
        for (double v=vmin;v<=vmax;v+=vinc)
        {
            QString s = (labdps<0 ? QString("%1").arg(v/labdiv) : QString("%1").arg(v/labdiv, 0, 'f', labdps)) + labsuffix;

            x=graph->xo + (v-vmin)*scale;
        //printf("x=%d\n",x);
            painter.drawLine(x,graph->yo,x,graph->yo + 10);
            x=x - QFontMetrics(font).boundingRect(s).width()/2;
            painter.drawText(x,graph->yo + 10 + font_h,s);
        }
        break;

    case pos_left:
        scale = graph->h / (vmax-vmin);
        painter.drawLine(graph->xo,graph->yo,graph->xo,graph->yo-graph->h);
        w_max=0;
        for (double v=vmin;v<=vmax;v+=vinc)
        {
            QString s = (labdps<0 ? QString("%1").arg(v/labdiv) : QString("%1").arg(v/labdiv, 0, 'f', labdps)) + labsuffix;
            y=graph->yo - (v-vmin)*scale;
            painter.drawLine(graph->xo,y,graph->xo-10,y);
            w = QFontMetrics(font).boundingRect(s).width();
            x=graph->xo - 12 - w;
            painter.drawText(x,y + font_h/2.5,s);
            if (w>w_max) w_max=w;
        }
        if (!title.isEmpty())
        {
            x=graph->xo;
            y=graph->yo - graph->h/2.0;
            w=QFontMetrics(font).boundingRect(title).width();
            painter.save();
            painter.translate(x,y);
            painter.rotate(-90.0);
            painter.drawText(-w/2.0,-w_max-font_h-4,title);
            painter.restore();
        }
        break;

    case pos_right:
        scale = graph->h / (vmax-vmin);
        painter.drawLine(graph->xo+graph->w,graph->yo,graph->xo+graph->w,graph->yo-graph->h);
        w_max=0;
        for (double v=vmin;v<=vmax;v+=vinc)
        {
//printf("scalev=%lf\n",v);
            QString s = (labdps<0 ? QString("%1").arg(v/labdiv) : QString("%1").arg(v/labdiv, 0, 'f', labdps)) + labsuffix;
            x=graph->xo + graph->w;
            y=graph->yo - (v-vmin)*scale;
            w = QFontMetrics(font).boundingRect(s).width();
            painter.drawLine(x,y,x+10,y);
            painter.drawText(x+12,y + font_h/2.5,s);
            if (w>w_max) w_max=w;
        }
        if (!title.isEmpty())
        {
            x=graph->xo + graph->w;
            y=graph->yo - graph->h/2.0;
            w=QFontMetrics(font).boundingRect(title).width();
            painter.save();
            painter.translate(x,y);
            painter.rotate(90.0);
            painter.drawText(-w/2.0,-w_max-font_h-4,title);
            painter.restore();
        }
        break;

      default: break;
    }
}
开发者ID:Analias,项目名称:sark-100-antenna-analyzer,代码行数:83,代码来源:graph.cpp

示例5: draw

void ContinuousPanel::draw(QPainter& painter, const QList<Element*>& el) {
      painter.save();
      painter.setRenderHint(QPainter::Antialiasing, preferences.antialiasedDrawing);
      painter.setRenderHint(QPainter::TextAntialiasing, true);

      // Draw colored rectangle
      painter.setClipping(false);
      QPointF pos(_offsetPanel, 0);
      painter.translate(pos);
      QPen pen;
      pen.setWidthF(0.0);
      pen.setStyle(Qt::NoPen);
      painter.setPen(pen);
      painter.setBrush(preferences.fgColor);
      QRectF bg(_rect);
      bg.setWidth(_widthClef + _widthKeySig + _widthTimeSig + _leftMarginTotal + _panelRightPadding);
      QPixmap* fgPixmap = _sv->fgPixmap();
      if (fgPixmap == 0 || fgPixmap->isNull())
            painter.fillRect(bg, preferences.fgColor);
      else {
            painter.setMatrixEnabled(false);
            painter.drawTiledPixmap(bg, *fgPixmap, bg.topLeft()
               - QPoint(lrint(_sv->matrix().dx()), lrint(_sv->matrix().dy())));
            painter.setMatrixEnabled(true);
            }

      painter.setClipRect(_rect);
      painter.setClipping(true);

      QColor color(MScore::layoutBreakColor);

      // Draw measure text number
      QString text = _mmRestCount ? QString("#%1-%2").arg(_currentMeasureNo+1).arg(_currentMeasureNo+_mmRestCount) : QString("#%1").arg(_currentMeasureNo+1);
      Text* newElement = new Text(_score);
      newElement->setTextStyleType(TextStyleType::DEFAULT);
      newElement->setFlag(ElementFlag::MOVABLE, false);
      newElement->setXmlText(text);
      newElement->textStyle().setFamily("FreeSans");
      newElement->textStyle().setSizeIsSpatiumDependent(true);
      newElement->setColor(color);
      newElement->sameLayout();
      pos = QPointF(_score->styleP(StyleIdx::clefLeftMargin) + _widthClef, _y + newElement->height());
      painter.translate(pos);
      newElement->draw(&painter);
      pos += QPointF(_offsetPanel, 0);
      painter.translate(-pos);
      delete newElement;

      // This second pass draws the elements spaced evently using the width of the largest element
      for (const Element* e : el) {
            e->itemDiscovered = 0;
            if (!e->visible()) {
                  if (_score->printing() || !_score->showInvisible())
                        continue;
                  }

           if (e->type() == Element::Type::STAFF_LINES) {
                  Staff* currentStaff = _score->staff(e->staffIdx());
                  Segment* parent = _score->tick2segmentMM(_currentMeasureTick);

                  pos = QPointF (_offsetPanel, e->pagePos().y());
                  painter.translate(pos);

                  // Draw staff lines
                  StaffLines* newStaffLines = static_cast<StaffLines*>(e->clone());
                  newStaffLines->setWidth(bg.width());
                  newStaffLines->setParent(parent);
                  newStaffLines->setTrack(e->track());
                  newStaffLines->layout();
                  newStaffLines->setColor(color);
                  newStaffLines->draw(&painter);
                  delete newStaffLines;

                  // Draw barline
                  BarLine* newBarLine = new BarLine(_score);
                  newBarLine->setBarLineType(BarLineType::NORMAL);
                  newBarLine->setParent(parent);
                  newBarLine->setTrack(e->track());
                  newBarLine->setSpan(currentStaff->barLineSpan());
                  newBarLine->setSpanFrom(currentStaff->barLineFrom());
                  newBarLine->setSpanTo(currentStaff->barLineTo());
                  newBarLine->layout();
                  newBarLine->setColor(color);
                  newBarLine->draw(&painter);
                  delete newBarLine;

                  // Draw the current staff name
                  QList<StaffName>& staffNamesLong = currentStaff->part()->instrument()->longNames();
                  QString staffName = staffNamesLong.isEmpty() ? " " : staffNamesLong[0].name();
                  if (staffName == "") {
                        QList<StaffName>& staffNamesShort = currentStaff->part()->instrument()->shortNames();
                        staffName = staffNamesShort.isEmpty() ? "" : staffNamesShort[0].name();
                        }

                  Text* newName = new Text(_score);
                  newName->setXmlText(staffName);
                  newName->setParent(parent);
                  newName->setTrack(e->track());
                  newName->setColor(color);
                  newName->textStyle().setFamily("FreeSans");
//.........这里部分代码省略.........
开发者ID:konri9,项目名称:MuseScore,代码行数:101,代码来源:continuouspanel.cpp

示例6: PaintPoleFigureOverlay

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
QImage PoleFigureImageUtilities::PaintPoleFigureOverlay(int imageWidth, int imageHeight, QString label, QImage image)
{
  int pxHigh = 0;
  int pxWide = 0;

  // Scale the Font Point size to something reasonable to the size of the image. Here our standard was 14Pt Font when the
  // Pole figure was 512 Pixels square.
  int fontPtSize = imageHeight / 32;

  QFont font("Ariel", fontPtSize, QFont::Bold);
  QFontMetrics metrics(font);
  pxHigh = metrics.height();
  pxWide = metrics.width(QString("Y"));

  int pxOffset = 2 * pxWide;
  int pyOffset = 2 * pxHigh;

  int pImageWidth = imageWidth + pxOffset * 2;
  int pImageHeight = imageHeight + pyOffset * 2;

  QImage pImage(pImageWidth, pImageHeight, QImage::Format_ARGB32_Premultiplied);
  pImage.fill(0xFFFFFFFF); // All white background

  // Create a Painter backed by a QImage to draw into
  QPainter painter;
  painter.begin(&pImage);
  painter.setRenderHint(QPainter::Antialiasing, true);
  qint32 penWidth = 1;

#if 0
  // DRAW A BORDER AROUND THE IMAGE FOR DEBUGGING
  QColor c(RgbColor::dRgb(255, 0, 0, 255));
  painter.setPen(QPen(c, penWidth, Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin));

  painter.drawLine(0, 0, pImageWidth, 0); // Top
  painter.drawLine(0, 0, 0, pImageHeight); // Left
  painter.drawLine(pImageWidth, 0, pImageWidth, pImageHeight); // Right
  painter.drawLine(0, pImageHeight, pImageWidth, pImageHeight); // Bottom
  //-----------------
#endif

  painter.setFont(font);
//  metrics = painter.fontMetrics();
//  pxHigh = metrics.height();
//  pxWide = metrics.width(QString("Y"));

  // Draw the Pole Figure into the center of the canvas
  QPoint point(pxOffset, pyOffset);
  painter.drawImage(point, image);

  // Scale pen width based on the size of the image
  penWidth = imageHeight / 256;
  painter.setPen(QPen(QColor(0, 0, 0, 255), penWidth, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));

  // Draw the Outer circular border around the pole figure
  QPainterPath circle;
  QPointF center(pImageWidth / 2, pImageHeight / 2);
  circle.addEllipse(center, imageWidth / 2, imageHeight / 2);
  painter.drawPath(circle);

  // Label the X Axis
  painter.drawText(pImageWidth - (pxWide * 1.5), pImageHeight / 2 + pxHigh / 3, "X");
  // Label the Y Axis
  pxWide = metrics.width(QString("Y"));
  painter.drawText(pImageWidth / 2 - pxWide / 2, pyOffset - penWidth - 1, "Y");

  // Draw the name of the Pole Figure
  int labelWidth = 0;
  int maxWidth = pImageWidth / 5; // No more than a Quarter of the width of the image
  while(labelWidth < maxWidth)
  {
    fontPtSize++;
    font = QFont("Ariel", fontPtSize, QFont::Bold);
    metrics = QFontMetrics(font);
    labelWidth = metrics.width(label); // Figure out which string is longer (pixel wise)
  }
  painter.setFont(font);
  pxHigh = metrics.height() + 2;
// pxWide = metrics.width(label);
  painter.drawText(pxOffset, pxHigh, label);

  // Draw slightly transparent lines
  //penWidth = 1;
  painter.setPen(QPen(QColor(0, 0, 0, 180), penWidth, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
  // Draw the X Axis
  painter.drawLine(pxOffset, pImageHeight / 2, pImageWidth - pxOffset, pImageHeight / 2);
  // Draw the Y Axis
  painter.drawLine(pImageWidth / 2, pyOffset, pImageWidth / 2, pImageHeight - pyOffset);

  painter.end();
  return pImage;
}
开发者ID:kglowins,项目名称:DREAM3D,代码行数:95,代码来源:PoleFigureImageUtilities.cpp

示例7: pdraw

void SigScale::pdraw(QPainter& p, const QRect& r)
{
    int x = r.x();
    int w = r.width();
    int h = height();

    if (x < 0)
        x = 0;
    QColor colTimeLine = QColor(172,181,176);
    p.setPen(colTimeLine);
    p.setFont(QFont("fixed-width", 9, QFont::Bold));
    for (ciSigEvent si = sigmap.begin(); si != sigmap.end(); ++si)
    {
        SigEvent* e = si->second;
        int xp = mapx(e->tick);
        if (xp > x + w)
            break;
        if (xp + 40 < x)
            continue;
        p.drawLine(xp, 0, xp, h / 2);
        p.drawLine(xp, h / 2, xp + 5, h / 2);
        QString s;
        s.sprintf("%d/%d", e->sig.z, e->sig.n);
        p.drawText(xp + 8, h - 6, s);
    }

    //---------------------------------------------------
    //    draw location marker
    //---------------------------------------------------

    //Christopher here is your color
    QList<QColor> colors;
    colors << QColor(0, 186, 255) << QColor(139, 225, 69) << QColor(139, 225, 69) << QColor(156,75,219);
    if (pos[3] != MAXINT)
    {
        p.setPen(colors.at(3));
        int xp = mapx(pos[3]);
        if (xp >= x && xp < x + w)
        {
            p.drawLine(xp, 0, xp, height()-10);
            QPixmap* pm = markIcon[3];
            p.drawPixmap(xp - pm->width() / 2, 1, *pm);
        }
    }

    //colors << QColor(139, 225, 69) << QColor(139, 225, 69) << QColor(0, 186, 255);
    for (int i = 0; i < 3; ++i)
    {
        int xp = mapx(pos[i]);
        if (xp >= x && xp < x + w)
        {
            p.setPen(colors.at(i));
            p.drawLine(xp, 0, xp, 8);
            QPixmap* pm = markIcon[i];
            p.drawPixmap(xp - pm->width() / 2, 1, *pm);
        }
    }
    /*//p.setPen(Qt::red);
    p.setPen(QColor(0, 186, 255));
    int xp = mapx(pos[0]);
    if (xp >= x && xp < x + w)
        p.drawLine(xp, 0, xp, h);
    //p.setPen(Qt::blue);
    p.setPen(QColor(139, 225, 69));
    xp = mapx(pos[1]);
    if (xp >= x && xp < x + w)
        p.drawLine(xp, 0, xp, h);
    xp = mapx(pos[2]);
    if (xp >= x && xp < x + w)
        p.drawLine(xp, 0, xp, h);*/
}
开发者ID:ViktorNova,项目名称:los,代码行数:71,代码来源:sigscale.cpp

示例8: paint

void NavigationMapObject::paint(QPainter &painter, QRect view, int scale)
{
	// Save the painter state for this paint session
	// so that it can be restored after without influencing other objects
	painter.save(); {

		// Translate, scale, and rotate...
		QTransform t;
		t.scale(1.0/scale, 1.0/scale);
		t.translate(x - view.x()*scale, view.height()*scale - y + view.y()*scale);
		painter.setTransform(t, true);

		if(navigation != NULL) {

			// Init
			QColor pink(255,68,224);
			width = 0;
			height = 0;
			painter.setPen(Qt::transparent);
			painter.setOpacity(0.5);
			painter.setBrush(QBrush(pink));
			QList<Vector2D> navPoints = navigation->getNavPoints();

			// Draw all nav points
			for(int i = 0; i < navPoints.count(); i++) {

				// Calc size and coord
				int size = 100;
				if(navigation->getCurrentNavPoint()+1 == i) size = 200;
				int x = (int)navPoints.at(i).x();
				int y = (int)navPoints.at(i).y();

				// Set object dimensions based on most distant points...
				if(x > width) width = x;
				if(y > height) height = y;

				painter.setPen(Qt::transparent);
				painter.setOpacity(0.5);
				painter.setBrush(QBrush(pink));
				painter.drawEllipse(QRect(x - (size / 2), (-y) - (size / 2), size, size));

				painter.setFont(QFont("Arial Black", 120, QFont::Bold));
				painter.setPen(pink);
				painter.setOpacity(0.5);
				painter.drawText(x + 150, (-y) - 150, QString("%1").arg(i));

				if(i > 0) {

					QPen pen = painter.pen();
					pen.setWidth(20);
					painter.setPen(pen);
					painter.drawLine((int)navPoints.at(i-1).x(), -((int)navPoints.at(i-1).y()), x, -y);
				}
			}

			// Draw splines
			if(navigation->name == "SplineNavigation") {
//				drawSpline(painter, ((SplineNavigation*)navigation)->getNavSplineX(), ((SplineNavigation*)navigation)->getNavSplineY(), scale, Qt::yellow, 20);
//				drawSpline(painter, ((SplineNavigation*)navigation)->getWheelLeftSplineX(), ((SplineNavigation*)navigation)->getWheelLeftSplineY(), scale, Qt::red, 1);
//				drawSpline(painter, ((SplineNavigation*)navigation)->getWheelRightSplineX(), ((SplineNavigation*)navigation)->getWheelRightSplineY(), scale, Qt::green, 1);
			}

		}

	} painter.restore();
}
开发者ID:seeyousystems,项目名称:core,代码行数:66,代码来源:NavigationMapObject.cpp

示例9: displayIcon

void QgsGrassEdit::displayIcon( double x, double y, const QPen & pen,
                                int type, int size, QPainter *painter )
{
  QgsPoint point;
  QPolygon pointArray( 2 );

  point.setX( x );
  point.setY( y );

  point = transformLayerToCanvas( point );

  int px = qRound( point.x() );
  int py = qRound( point.y() );
  int m = ( size - 1 ) / 2;

  QPainter *myPainter;
  if ( !painter )
  {
    myPainter = new QPainter();
    myPainter->begin( mPixmap );
  }
  else
  {
    myPainter = painter;
  }

  myPainter->setPen( pen );

  switch ( type )
  {
    case QgsVertexMarker::ICON_CROSS :
      pointArray.setPoint( 0, px - m, py );
      pointArray.setPoint( 1, px + m, py );
      myPainter->drawPolyline( pointArray );

      pointArray.setPoint( 0, px, py + m );
      pointArray.setPoint( 1, px, py - m );
      myPainter->drawPolyline( pointArray );
      break;
    case QgsVertexMarker::ICON_X :
      pointArray.setPoint( 0, px - m, py + m );
      pointArray.setPoint( 1, px + m, py - m );
      myPainter->drawPolyline( pointArray );

      pointArray.setPoint( 0, px - m, py - m );
      pointArray.setPoint( 1, px + m, py + m );
      myPainter->drawPolyline( pointArray );
      break;
    case QgsVertexMarker::ICON_BOX :
      pointArray.resize( 5 );
      pointArray.setPoint( 0, px - m, py - m );
      pointArray.setPoint( 1, px + m, py - m );
      pointArray.setPoint( 2, px + m, py + m );
      pointArray.setPoint( 3, px - m, py + m );
      pointArray.setPoint( 4, px - m, py - m );
      myPainter->drawPolyline( pointArray );
      break;
  }

  if ( !painter )
  {
    myPainter->end();
    //mCanvas->update();
    mCanvasEdit->update();
    delete myPainter;
  }
}
开发者ID:CSRedRat,项目名称:QGIS,代码行数:67,代码来源:qgsgrassedit.cpp

示例10: Draw

bool FunctionalTest::Draw(QPainter& painter, QRect &free_rect , const QString &) const
{
    test::hydro_cylinder::Parameters *params = static_cast< test::hydro_cylinder::Parameters * >( CURRENT_PARAMS );
    if ( !params )
        return true;

    QFont header_font = painter.font();
    header_font.setFamily("Arial");
    header_font.setPointSize( 14 );
    QFont result_font = header_font;
    result_font.setUnderline(true);
    QFont text_font = header_font;
    text_font.setPointSize( 12 );


    auto DrawRowCenter = [ &painter, &free_rect ](QRect const& place, QFont const& font, QColor const& color, QString const& text )
    {
        painter.save();
        QFontMetrics metrix( font );
        QPoint start_point( place.center().x() - metrix.width( text ) / 2, place.center().y() +metrix.height()/2);
        painter.setFont( font );
        painter.setPen( color );
        painter.drawText( start_point, text );
        painter.restore();
    };
    auto DrawRowLeft = [ &painter, &free_rect ](    QRect const& place,
                                                    QFont const& font,
                                                    QColor const& color1,
                                                    QString const& label,
                                                    QColor const& color2 = Qt::black,
                                                    QString const& value = "",
                                                    QColor const& color3 = Qt::black,
                                                    QString const& value2 = "")
    {
        painter.save();
        QFontMetrics metrix( font );
        QPoint start_point( place.left() , place.center().y()+metrix.height()/2 );
        QPoint start_point2( start_point.x() + metrix.width(label), place.center().y() +metrix.height()/2);
        QPoint start_point3( start_point2.x() + metrix.width(value), place.center().y() +metrix.height()/2);
        painter.setFont( font );
        painter.setPen( color1 );
        painter.drawText( start_point, label );
        painter.setPen( color2 );
        painter.drawText( start_point2, value );
        painter.setPen( color3 );
        painter.drawText( start_point3, value2 );
        painter.restore();
    };

    QFontMetrics m(text_font);
    int width = m.width("123456789012345678901234567890123456789012345");
    char symbol = '.';
    auto FillToSize = [ width, &m, symbol ]( QString text )
    {
        while( m.width( text + symbol ) < width )
            text += symbol;
        return text + " ";
    };


    uint32_t num = 0;
    bool res = DrawLine( num, free_rect, result_font,
    [ this, &painter, &DrawRowCenter, &result_font ]( QRect const& rect )
    {
        DrawRowCenter( rect, result_font, Qt::black, "Результаты испытаний" );
    }, 2 );

    res = DrawLine( num, free_rect, text_font,
    [ this, &painter, &DrawRowLeft, &FillToSize, &text_font ]( QRect const& rect )
    {
        DrawRowLeft( rect, text_font, Qt::black, FillToSize("Температура масла во время испытаний, ˚С"), Qt::red, test::ToString(OilTemp) );
    }, 2 );


    QString header = "<html>"
            "<head>"
              "<meta charset='utf-8'>"
              "<style type='text/css'>"
                   "td { text-align: center;}"
                   "th { font-weight: normal; padding: 2px;}"
                   "table {border-collapse: collapse; border-style: solid; vertical-align:middle;}"
             "</style>"
            "</head>"
            "<body>"
            "<table width='100%' border='1.5' cellspacing='-0.5' cellpadding='-0.5'>"
               "<tr>"
                   "<th> Номер </th>"
                   "<th></th>"
                   "<th> Работоспособность </th>"
               "</tr>";

    QString footer = "</table>"
            "</body>"
            "</html>";

    typedef std::pair<QString, bool> Item;
    std::vector< Item > tests;
    tests.push_back( Item( "Наружная герметичность ", HermResult ) );
    tests.push_back( Item( "Максимальное давление", MaxPressureResult ) );
    tests.push_back( Item( "Рабочее давление", WorkPressureResult ) );
//.........这里部分代码省略.........
开发者ID:firef0xff,项目名称:SSHGS01,代码行数:101,代码来源:cylinder_test.cpp

示例11: syncStickyNoteWithFileContents

void StickyNoteActor::syncStickyNoteWithFileContents()
{
	reauthorize(false);

	// clear the old texture
#ifdef DXRENDER
	SAFE_RELEASE(_stickyNoteTextureId);
#else
	if (_stickyNoteTextureId)
	{
		glDeleteTextures(1, &_stickyNoteTextureId);
		_stickyNoteTextureId = 0;
	}
#endif

	// get the font
	int fontSize = NxMath::max(20, themeManager->getValueAsInt("ui.stickyNote.font.size",0));
	FontDescription desc(themeManager->getValueAsFontFamilyName("ui.stickyNote.font.family",""), fontSize);
	QFont stickyNoteFont = fontManager->getFont(desc);

	// get the sticky note text
	QString stickyNoteStr;
	getStickyNote(getFullPath(), &stickyNoteStr);

	// layout the sticky note text
	QTextOption option;
		option.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
	_stickyNoteText.setDefaultTextOption(option);
	_stickyNoteText.setDefaultFont(stickyNoteFont);
	_stickyNoteText.setDocumentMargin(12.5f);
	_stickyNoteText.setTextWidth(256);
	_stickyNoteText.setPlainText(stickyNoteStr);

	QSizeF textSize = _stickyNoteText.size();
	const int minStickyNoteFontSize = 10;
	while (textSize.height() > 256 && 
		   stickyNoteFont.pointSize() > minStickyNoteFontSize)
	{
		stickyNoteFont.setPointSize(stickyNoteFont.pointSize() - 1);
		_stickyNoteText.setDefaultFont(stickyNoteFont);
		textSize = _stickyNoteText.size();
	}

	// render the sticky note to a qimage
	const unsigned int bufferSize = 256;
	QImage image(bufferSize, bufferSize, QImage::Format_ARGB32);
	image.fill(Qt::red);
	QPainter p;
	p.begin(&image);
	p.setRenderHint(QPainter::Antialiasing, true);
	p.setRenderHint(QPainter::TextAntialiasing, true);
		p.drawImage(0, 0, _stickyNoteBackground);
		p.setPen(QColor(50, 50, 75));
		_stickyNoteText.drawContents(&p, QRect(0, 0, bufferSize, int(bufferSize - _stickyNoteText.documentMargin())));
	p.end();
#ifdef DXRENDER
	_stickyNoteTextureId = dxr->createTextureFromData(image.width(), image.height(), image.bits(), image.bytesPerLine());
#else
	// load the qimage into open gl
	glGenTextures(1, &_stickyNoteTextureId);
	glBindTexture(GL_TEXTURE_2D, _stickyNoteTextureId);

	float maximumAnisotropy = 0.0f;
	glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maximumAnisotropy);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, maximumAnisotropy);
	if (GLEW_ARB_texture_border_clamp)
	{
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER_ARB);
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER_ARB);
	}
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);

	// copy the full image (glTexSubImage2D does not work well with GL_GENERATE_MIPMAP)
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.width(), image.height(),
		0, GL_BGRA, GL_UNSIGNED_BYTE, image.bits());
#endif
}
开发者ID:DX94,项目名称:BumpTop,代码行数:79,代码来源:BT_StickyNoteActor.cpp

示例12: drawData

void SpeechAudiometryWidget::drawData()
{
    int xx = -1;
    int yy = -1;

    QPainter paint;
    paint.begin(&m_data);

    // Draw RE data
    paint.setPen(Qt::red);
    xx = -1;
    yy = -1;
    for (int i = 0; i < 23; ++i)
    {
        int x = BORDER_LEFT + i*gridWidth()/22;
        if (m_reData[i] >= 0)
        {
            int y = BORDER_TOP + static_cast<int> (((100 - m_reData[i])/100.0)*gridHeight() + 0.5);
            switch (m_kind)
            {
                case WITHOUT:
                    paint.drawEllipse(x-4, y-4, 8, 8);
                    break;
                case WITH:
                    paint.setBrush(QBrush(paint.pen().color(), Qt::SolidPattern));
                    paint.drawEllipse(x-4, y-4, 8, 8);
                    paint.setBrush(Qt::NoBrush);
                    break;
                default:
                   Q_ASSERT(false);
            }
            if (xx > 0 && yy > 0) paint.drawLine(xx, yy, x, y);
            xx = x;
            yy = y;
        }
    }

    // Draw LE data
    paint.setPen(Qt::blue);
    xx = -1;
    yy = -1;
    for (int i = 0; i < 23; ++i)
    {
        int x = BORDER_LEFT + i*gridWidth()/22;
        if (m_leData[i] >= 0)
        {
            int y = BORDER_TOP + static_cast<int> (((100 - m_leData[i])/100.0)*gridHeight() + 0.5);
            switch (m_kind)
            {
                case WITHOUT:
                    paint.drawLine(x-4, y-4, x+4, y+4);
                    paint.drawLine(x-4, y+4, x+4, y-4);
                    break;
                case WITH:
                    paint.fillRect(x-4, y-4, 8, 8, paint.pen().color());
                    break;
                default:
                   Q_ASSERT(false);
            }
            if (xx > 0 && yy > 0) paint.drawLine(xx, yy, x, y);
            xx = x;
            yy = y;
        }
    }

    // Draw RELE data
    paint.setPen(Qt::darkGreen);
    xx = -1;
    yy = -1;
    for (int i = 0; i < 23; ++i)
    {
        int x = BORDER_LEFT + i*gridWidth()/22;
        if (m_releData[i] >= 0)
        {
            int y = BORDER_TOP + static_cast<int> (((100 - m_releData[i])/100.0)*gridHeight() + 0.5);
            switch (m_kind)
            {
                case WITHOUT:
                    paint.drawLine(x-4, y+4, x+4, y+4);
                    paint.drawLine(x-4, y+4, x, y-4);
                    paint.drawLine(x, y-4, x+4, y+4);
                    break;
                case WITH:
                    {
                        paint.setBrush(QBrush(paint.pen().color(), Qt::SolidPattern));
                        QPoint points[] = { QPoint(x-4, y+4), QPoint(x+4, y+4), QPoint(x, y-4) };
                        paint.drawConvexPolygon(points, 3);
                        paint.setBrush(Qt::NoBrush);
                    }
                    break;
                default:
                   Q_ASSERT(false);
            }
            if (xx > 0 && yy > 0) paint.drawLine(xx, yy, x, y);
            xx = x;
            yy = y;
        }
    }
}
开发者ID:Roelio81,项目名称:audioadmin,代码行数:99,代码来源:speechaudiometrywidget.cpp

示例13: drawGrid

void SpeechAudiometryWidget::drawGrid()
{
    QPainter paint;
    paint.begin(&m_rooster);

    QFont boldFont;
    boldFont.setBold(true);

    // Paint the vertical axes
    for (int i = 0; i < 23; ++i)
    {
        int x = BORDER_LEFT + i*gridWidth()/22;
        paint.setPen(Qt::black);
        if ((i % 2 == 0) && (i != 0) && (i < 20))
            paint.drawText(x-6, gridHeight()+25, QString::number(i*5));
        else if (i == 20)
            paint.drawText(x-9, gridHeight()+25, QString::number(i*5));

        paint.setPen(QPen((i == 0 || i == 8 || i == 11 || i == 14) ? Qt::black : Qt::lightGray, (i == 0) ? 2 : 1));
        paint.drawLine(x, BORDER_TOP, x, gridHeight()+BORDER_TOP);
    }
    paint.setPen(Qt::black);
    paint.setFont(boldFont);
    paint.drawText(BORDER_LEFT+gridWidth(), 25+gridHeight(), "dB");
    paint.setFont(QFont());

    // Paint the horizontal axes
    for (int i = 0; i < 21; ++i)
    {
        int y = BORDER_TOP + i*gridHeight()/20;
        if (i % 2 == 0)
        {
            paint.setPen(Qt::black);
            paint.drawText(15 + 6*((i/20) + (i == 0 ? 0 : 1)), y+6, QString::number((20-i)*5));
        }

        paint.setPen(QPen((i == 10 || i == 20) ? Qt::black : Qt::lightGray, (i == 20) ? 2 : 1));
        paint.drawLine(BORDER_LEFT+1, y, BORDER_LEFT+gridWidth(), y);
    }
    paint.setPen(Qt::black);
    paint.setFont(boldFont);
    paint.drawText(34, 8, "%");
    paint.setFont(QFont());

    // Tekenen van de curve
    int minY = BORDER_TOP;
    int maxY = BORDER_TOP + gridHeight();
    paint.setPen(Qt::black);
    for (int x = BORDER_LEFT; x < BORDER_LEFT + 2*(gridWidth()/22); ++x)
    {
        double xx1 = (x - BORDER_LEFT*1.0) / (4.0*(gridWidth()/22.0) / 20.0);
        double yy1 = (3.0/5.0)*xx1*xx1 - xx1;
        double xx2 = (x - BORDER_LEFT*1.0 + 1.0) / (4.0*(gridWidth()/22.0) / 20.0);
        double yy2 = (3.0/5.0)*xx2*xx2 - xx2;
        int y1 = std::min(static_cast<int> (BORDER_TOP + ((100.0 - yy1) * gridHeight())/100.0), maxY);
        int y2 = std::min(static_cast<int> (BORDER_TOP + ((100.0 - yy2) * gridHeight())/100.0), maxY);
        paint.drawLine(x, y1, x+1, y2);
    }
    for (int x = BORDER_LEFT + 2*(gridWidth()/22); x < BORDER_LEFT + 4*(gridWidth()/22); ++x)
    {
        double xx1 = (x - BORDER_LEFT*1.0) / (4.0*(gridWidth()/22.0) / 20.0);
        double yy1 = (-3.0/5.0)*xx1*xx1 + 23.0*xx1 - 120.0;
        double xx2 = (x - BORDER_LEFT*1.0 + 1.0) / (4.0*(gridWidth()/22.0) / 20.0);
        double yy2 = (-3.0/5.0)*xx2*xx2 + 23.0*xx2 - 120.0;
        int y1 = std::max(static_cast<int> (BORDER_TOP + ((100.0 - yy1) * gridHeight())/100.0), minY);
        int y2 = std::max(static_cast<int> (BORDER_TOP + ((100.0 - yy2) * gridHeight())/100.0), minY);
        paint.drawLine(x, y1, x+1, y2);
    }
}
开发者ID:Roelio81,项目名称:audioadmin,代码行数:69,代码来源:speechaudiometrywidget.cpp

示例14: off

void QgsEllipseSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context )
{
  bool ok;
  if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH ) )
  {
    context.setOriginalValueVariable( mOutlineWidth );
    double width = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH, context, mOutlineWidth ).toDouble();
    width = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), width, mOutlineWidthUnit, mOutlineWidthMapUnitScale );
    mPen.setWidthF( width );
  }
  if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_STYLE ) )
  {
    context.setOriginalValueVariable( QgsSymbolLayerV2Utils::encodePenStyle( mPen.style() ) );
    QString styleString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_STYLE, context, QVariant(), &ok ).toString();
    if ( ok )
    {
      Qt::PenStyle style = QgsSymbolLayerV2Utils::decodePenStyle( styleString );
      mPen.setStyle( style );
    }
  }
  if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_FILL_COLOR ) )
  {
    context.setOriginalValueVariable( QgsSymbolLayerV2Utils::encodeColor( mBrush.color() ) );
    QString colorString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_FILL_COLOR, context, QVariant(), &ok ).toString();
    if ( ok )
      mBrush.setColor( QgsSymbolLayerV2Utils::decodeColor( colorString ) );
  }
  if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_COLOR ) )
  {
    context.setOriginalValueVariable( QgsSymbolLayerV2Utils::encodeColor( mPen.color() ) );
    QString colorString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_COLOR, context, QVariant(), &ok ).toString();
    if ( ok )
      mPen.setColor( QgsSymbolLayerV2Utils::decodeColor( colorString ) );
  }
  double scaledWidth = mSymbolWidth;
  double scaledHeight = mSymbolHeight;
  if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_WIDTH ) || hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_HEIGHT ) || hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_SYMBOL_NAME ) )
  {
    QString symbolName =  mSymbolName;
    if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_SYMBOL_NAME ) )
    {
      context.setOriginalValueVariable( mSymbolName );
      symbolName = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_SYMBOL_NAME, context, mSymbolName ).toString();
    }
    preparePath( symbolName, context, &scaledWidth, &scaledHeight, context.feature() );
  }

  //offset
  double offsetX = 0;
  double offsetY = 0;
  markerOffset( context, scaledWidth, scaledHeight, mSymbolWidthUnit, mSymbolHeightUnit, offsetX, offsetY, mSymbolWidthMapUnitScale, mSymbolHeightMapUnitScale );
  QPointF off( offsetX, offsetY );

  QPainter* p = context.renderContext().painter();
  if ( !p )
  {
    return;
  }

  //priority for rotation: 1. data defined symbol level, 2. symbol layer rotation (mAngle)
  double rotation = 0.0;
  if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_ROTATION ) )
  {
    context.setOriginalValueVariable( mAngle );
    rotation = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_ROTATION, context, mAngle ).toDouble() + mLineAngle;
  }
  else if ( !qgsDoubleNear( mAngle + mLineAngle, 0.0 ) )
  {
    rotation = mAngle + mLineAngle;
  }
  if ( rotation )
    off = _rotatedOffset( off, rotation );

  QMatrix transform;
  transform.translate( point.x() + off.x(), point.y() + off.y() );
  if ( !qgsDoubleNear( rotation, 0.0 ) )
  {
    transform.rotate( rotation );
  }

  p->setPen( mPen );
  p->setBrush( mBrush );
  p->drawPath( transform.map( mPainterPath ) );
}
开发者ID:dionhouston,项目名称:QGIS,代码行数:84,代码来源:qgsellipsesymbollayerv2.cpp

示例15: paintEvent

    void MapControl::paintEvent(QPaintEvent* evnt)
    {
        Q_UNUSED(evnt);

        static QPixmap *doubleBuffer( new QPixmap(width(), height()) );

        //check for resize change
        if ( doubleBuffer->width() != width() || doubleBuffer->height() != height() )
        {
            delete doubleBuffer;
            doubleBuffer = new QPixmap(width(), height());
        }

        QPainter dbPainter;
        dbPainter.begin(doubleBuffer);

        layermanager->drawImage(&dbPainter);
        layermanager->drawGeoms(&dbPainter);

        // draw scale
        if (scaleVisible)
        {
            static QList<double> distanceList;
            if (distanceList.isEmpty())
            {
                distanceList<<5000000<<2000000<<1000000<<1000000<<1000000<<100000<<100000<<50000<<50000<<10000<<10000<<10000<<1000<<1000<<500<<200<<100<<50<<25;
            }

            if (currentZoom() >= layermanager->minZoom() && distanceList.size() > currentZoom())
            {
                double line;
                line = distanceList.at( currentZoom() ) / pow(2.0, 18-currentZoom() ) / 0.597164;

                // draw the scale
                dbPainter.setPen(Qt::black);
                QPoint p1(10,size.height()-20);
                QPoint p2((int)line,size.height()-20);
                dbPainter.drawLine(p1,p2);

                dbPainter.drawLine(10,size.height()-15, 10,size.height()-25);
                dbPainter.drawLine((int)line,size.height()-15, (int)line,size.height()-25);

                QString distance;
                if (distanceList.at(currentZoom()) >= 1000)
                {
                    distance = QVariant( distanceList.at(currentZoom())/1000 )  .toString()+ " km";
                }
                else
                {
                    distance = QVariant( distanceList.at(currentZoom()) ).toString() + " m";
                }

                dbPainter.drawText(QPoint((int)line+10,size.height()-15), distance);
            }
        }

        if (crosshairsVisible)
        {
            dbPainter.drawLine(screen_middle.x(), screen_middle.y()-10,
                             screen_middle.x(), screen_middle.y()+10); // |
            dbPainter.drawLine(screen_middle.x()-10, screen_middle.y(),
                             screen_middle.x()+10, screen_middle.y()); // -
        }

        dbPainter.drawRect(0,0, size.width(), size.height());

        if (mousepressed && mymousemode == Dragging)
        {
            QRect rect = QRect(pre_click_px, current_mouse_pos);
            dbPainter.drawRect(rect);
        }
        dbPainter.end();
        QPainter painter;
        painter.begin( this );
        painter.drawPixmap( rect(), *doubleBuffer, doubleBuffer->rect() );
        painter.end();
    }
开发者ID:ggggamer,项目名称:silkopter,代码行数:77,代码来源:mapcontrol.cpp


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