Esempio n. 1
0
void TurnAndBank::createCard(void){
    QImage _cardImage = QImage(QSize(500,150), QImage::Format_ARGB32);
    _cardImage.fill(0x00ff0000);
    
    uint midx, midy, width, height;
    width = _cardImage.width();
    midx = width/2;
    height = _cardImage.height();
    midy = height/2;
    
    
    QPainter p;
    p.setRenderHint(QPainter::Antialiasing, true);
    p.begin(&_cardImage);
    
    p.setPen(QPen(Qt::white, 7, Qt::SolidLine,
                  Qt::FlatCap, Qt::MiterJoin));
    p.setBrush(Qt::SolidPattern);
    p.setBrush(Qt::white);
    
    
    p.drawChord(midx-30, midy-30, 60, 60, 0, 360*16);
    
    p.drawLine(midx-60, midy-30,  midx+60, midy-30);
    p.drawLine(midx, midy-30,  midx, midy-80);
    p.drawLine(midx-240, midy,  midx+240, midy);
    
    
    p.setPen(QPen(Qt::white, 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
    static const QPointF rightWing[] = {
        QPointF(midx, midy-2),
        QPointF(midx+245, midy-3),
        QPointF(midx+244, midy+3),
        QPointF(midx, midy+15)
    };
    p.drawConvexPolygon(rightWing, 4);

    static const QPointF leftWing[] = {
        QPointF(midx, midy-2),
        QPointF(midx-245, midy-3),
        QPointF(midx-244, midy+3),
        QPointF(midx, midy+15)
    };
    p.drawConvexPolygon(leftWing, 4);
    
    
    
    p.end();
    _card = QPixmap::fromImage(_cardImage, Qt::AutoColor);
    
}
Esempio n. 2
0
void DecodeTrace::draw_range(const pv::data::decode::Annotation &a, QPainter &p,
	int h, double start, double end, int y, const ViewItemPaintParams &pp,
	int row_title_width) const
{
	const double top = y + .5 - h / 2;
	const double bottom = y + .5 + h / 2;
	const vector<QString> annotations = a.annotations();

	// If the two ends are within 1 pixel, draw a vertical line
	if (start + 1.0 > end) {
		p.drawLine(QPointF(start, top), QPointF(start, bottom));
		return;
	}

	const double cap_width = min((end - start) / 4, EndCapWidth);

	QPointF pts[] = {
		QPointF(start, y + .5f),
		QPointF(start + cap_width, top),
		QPointF(end - cap_width, top),
		QPointF(end, y + .5f),
		QPointF(end - cap_width, bottom),
		QPointF(start + cap_width, bottom)
	};

	p.drawConvexPolygon(pts, countof(pts));

	if (annotations.empty())
		return;

	const int ann_start = start + cap_width;
	const int ann_end = end - cap_width;

	const int real_start = std::max(ann_start, pp.left() + row_title_width);
	const int real_end = std::min(ann_end, pp.right());
	const int real_width = real_end - real_start;

	QRectF rect(real_start, y - h / 2, real_width, h);
	if (rect.width() <= 4)
		return;

	p.setPen(Qt::black);

	// Try to find an annotation that will fit
	QString best_annotation;
	int best_width = 0;

	for (const QString &a : annotations) {
		const int w = p.boundingRect(QRectF(), 0, a).width();
		if (w <= rect.width() && w > best_width)
			best_annotation = a, best_width = w;
	}

	if (best_annotation.isEmpty())
		best_annotation = annotations.back();

	// If not ellide the last in the list
	p.drawText(rect, Qt::AlignCenter, p.fontMetrics().elidedText(
		best_annotation, Qt::ElideRight, rect.width()));
}
Esempio n. 3
0
  void DrawMana( QPainter& painter, int x, int y, int width, int height, int mana ) const {
    // Draw mana
    QPen origPen = painter.pen();
    QPen pen( QColor( 0, 52, 113 ) );
    pen.setCosmetic( true );
    pen.setWidth( 1 );
    painter.setPen( pen );

    QBrush brush( QColor( 40, 119, 238 ) );
    painter.setBrush( brush );

    QTransform transform;
    painter.translate( x + width * 0.5, y + height * 0.5 );
    painter.scale( width * 0.8, height * 0.8 );

    static const QPointF points[5] = {
      QPointF( 0.0, -1.0 ),
      QPointF( 1.0, -0.2 ),
      QPointF( 0.6, 1.0 ),
      QPointF( -0.6, 1.0 ),
      QPointF( -1.0, -0.2 ),
    };
    painter.drawConvexPolygon( points, 5 );
    painter.resetTransform();
    painter.setPen( origPen );

    painter.drawText( x, y, width, height, Qt::AlignCenter | Qt::AlignVCenter, QString::number( mana ) );
  }
void HistoryGraph::paintGraph(QPainter & a_Painter)
{
	// Draw the graph:
	const auto & snapshots = m_Project->getSnapshots();
	if (snapshots.empty() || (m_Model == nullptr))
	{
		return;
	}
	int prevX = projectionX(snapshots.front()->getTimestamp());
	std::vector<int> prevY;
	std::vector<int> y;
	int prevYH = projectionY(snapshots.front()->getHeapSize());
	int prevYT = projectionY(snapshots.front()->getTotalSize());
	const auto & graphedItems = m_Model->getGraphedAllocationPaths();
	auto numGraphedItems = graphedItems.size();
	prevY.resize(numGraphedItems);
	y.resize(numGraphedItems);
	projectCodeLocationsY(snapshots.front().get(), prevY);
	std::vector<bool> isSelected;
	isSelected.resize(numGraphedItems);
	for (const auto & s: m_Selection->selectedIndexes())
	{
		isSelected[s.row()] = true;
	}
	for (const auto & s: snapshots)
	{
		int x = projectionX(s->getTimestamp());
		projectCodeLocationsY(s.get(), y);
		assert(y.size() == numGraphedItems);
		int yH = projectionY(s->getHeapSize());
		int yT = projectionY(s->getTotalSize());
		a_Painter.drawLine(prevX, prevYH, x, yH);
		a_Painter.drawLine(prevX, prevYT, x, yT);
		int top = m_Height - 1;
		int prevTop = m_Height - 1;
		QPoint points[4] =
		{
			QPoint(prevX, 0),
			QPoint(prevX, 0),
			QPoint(x, 0),
			QPoint(x, 0),
		};
		for (size_t i = 0; i < numGraphedItems; i++)
		{
			points[0].setY(prevTop);
			points[1].setY(prevY[i]);
			points[2].setY(y[i]);
			points[3].setY(top);
			a_Painter.setBrush(QBrush(graphedItems[i]->m_Color, isSelected[i] ? Qt::DiagCrossPattern : Qt::SolidPattern));
			a_Painter.drawConvexPolygon(points, 4);
			top = y[i];
			prevTop = prevY[i];
		}
		prevX = x;
		prevYH = yH;
		prevYT = yT;
		std::swap(prevY, y);
	}
}
Esempio n. 5
0
    static void draw(unsigned icam, unsigned ncam,
		     QPainter& painter, bool draw_fast) 
    { static const QPointF hex[6] = { QPointF(0.0,1.0), 
				      QPointF(M_SQRT3/2.0, 0.5),
				      QPointF(M_SQRT3/2.0, -0.5),
				      QPointF(0.0,-1.0), 
				      QPointF(-M_SQRT3/2.0, -0.5),
				      QPointF(-M_SQRT3/2.0, 0.5) };
      painter.drawConvexPolygon(hex,sizeof(hex)/sizeof(*hex)); }
void
TransitionWidget::drawTriPoint(QPainter& painter, double x, double y)
{
	QPointF points[3] = {
		QPointF(x, y - 1.35 * 1.15 * MARKER_SIZE),
		QPointF(x + 1.35 * MARKER_SIZE, y + 1.35 * 0.577 * MARKER_SIZE),
		QPointF(x - 1.35 * MARKER_SIZE, y + 1.35 * 0.577 * MARKER_SIZE)
	};
	painter.drawConvexPolygon(points, 3);
}
void QgsPanningWidget::paintEvent( QPaintEvent* pe )
{
  Q_UNUSED( pe );

  QPainter p;
  p.begin( this );
  p.setPen( Qt::red );
  QPolygonF t = mPoly.translated( -mPoly.boundingRect().left(), -mPoly.boundingRect().top() );
  p.drawConvexPolygon( t );
  p.end();
}
void AnalogClock::drawClockHand(QPainter &painter,
                                float rotateDegree,
                                const QPoint * points,
                                unsigned short pointCount,
                                QColor &color)
{
    painter.setPen(Qt::NoPen);
    painter.setBrush(color);
    painter.save();
    painter.rotate(rotateDegree);
    painter.drawConvexPolygon(points, pointCount);
    painter.restore();
}
Esempio n. 9
0
    static void draw(unsigned icam, unsigned ncam,
		     QPainter& painter, bool draw_fast) 
    { 
      static const QPointF shamrock[] = 
	{ QPointF(  0.0,      2.0/M_SQRT3),   // OUTER
	  QPointF(  1.0/4.0,  M_SQRT3/4.0 ),  // INNER
	  QPointF(  1.0,      1.0/M_SQRT3),   // OUTER
	  QPointF(  1.0/2.0,  0.0 ),          // INNER
	  QPointF(  1.0,     -1.0/M_SQRT3),   // OUTER
	  QPointF(  1.0/4.0, -M_SQRT3/4.0 ),  // INNER
	  QPointF(  0.0,     -2.0/M_SQRT3),   // OUTER
	  QPointF( -1.0/4.0, -M_SQRT3/4.0 ),  // INNER
	  QPointF( -1.0,     -1.0/M_SQRT3 ),  // OUTER
	  QPointF( -1.0/2.0,  0.0 ),          // INNER
	  QPointF( -1.0,      1.0/M_SQRT3 ),  // OUTER
	  QPointF( -1.0/4.0,  M_SQRT3/4.0 )   // INNER
	};              
      painter.drawConvexPolygon(star,sizeof(shamrock)/sizeof(*shamrock)); 
    }
void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool shouldAntialias)
{
    if (paintingDisabled())
        return;

    if (npoints <= 1)
        return;

    QPolygonF polygon(npoints);

    for (size_t i = 0; i < npoints; i++)
        polygon[i] = points[i];

    QPainter *p = m_data->p();
    p->save();
    p->setRenderHint(QPainter::Antialiasing, shouldAntialias);
    p->drawConvexPolygon(polygon);
    p->restore();
}
Esempio n. 11
0
void
Panner::paintEvent(QPaintEvent *e)
{
    Profiler profiler("Panner::paintEvent");

    QPaintEvent *e2 = new QPaintEvent(e->region().boundingRect());
    QGraphicsView::paintEvent(e2);

    QPainter paint;
    paint.begin(viewport());
    paint.setClipRegion(e->region());

    QPainterPath path;
    path.addRect(rect());
    path.addPolygon(mapFromScene(m_pannedRect));

    QColor c(GUIPalette::getColour(GUIPalette::PannerOverlay));
    c.setAlpha(80);
    paint.setPen(Qt::NoPen);
    paint.setBrush(c);
    paint.drawPath(path);

    paint.setBrush(Qt::NoBrush);
    paint.setPen(QPen(GUIPalette::getColour(GUIPalette::PannerOverlay), 0));
    paint.drawConvexPolygon(mapFromScene(m_pannedRect));

    if (m_pointerVisible && scene()) {
        QPoint top = mapFromScene(m_pointerTop);
        float height = m_pointerHeight;
        if (height == 0.f) height = scene()->height();
        QPoint bottom = mapFromScene
            (QPointF(m_pointerTop.x(), m_pointerTop.y() + height));
        paint.setPen(QPen(GUIPalette::getColour(GUIPalette::Pointer), 2));
        paint.drawLine(top, bottom);
    }

    RG_DEBUG << "draw polygon: " << mapFromScene(m_pannedRect);
    paint.end();

    emit pannerChanged(m_pannedRect);
}
Esempio n. 12
0
void Cut_widget::draw_cut()
{

    if(cut!=NULL){
        delete cut;
    }
    if(image!=NULL){
        delete image;
    }
    int i;
if(this->object->height==0){
    this->object->height=1;
}
if(this->object->width==0){
    this->object->width=1;
}

    if(ui->x_rButton->isChecked()){
        image = new QPixmap(object->map->sizeY,500);
        ui->pos_Box->setMaximum(object->width);
        cut = new QPolygon(this->object->map->sizeY);
        cut->append(QPoint(0,500));
      /*  int x = ( this->object->map->sizeX /  this->object->width  ) * ui->pos_Box->value();
        for(i=1; i < this->object->map->sizeY; i++){
           QPoint p;
            p.setY(image->height()-Map::get_point(this->object->map,x,i-1));
            p.setX(i);
            cut->append(p);
      }*/
    }else{
        image = new QPixmap(object->map->sizeX,500);
        ui->pos_Box->setMaximum(object->height);
        cut = new QPolygon(this->object->map->sizeX);
       cut->append(QPoint(0,500));
        int x = ( this->object->map->sizeY / this->object->height) * ui->pos_Box->value();
            for(i=1; i < this->object->map->sizeX; i++){
                QPoint p;
                p.setY(image->height()-Map::get_point(this->object->map,x,i-1));
                p.setX(i);
                cut->append(p);

            }

        }
 //           cut->append(QPoint(image->width(),image->height()));

cut->append(QPoint(25,450));
cut->append(QPoint(50,400));
cut->append(QPoint(100,300));
cut->append(QPoint(200,250));
cut->append(QPoint(300,0));
        QPainter painter;
        QPen pen;
    pen.setColor(Qt::black);
    pen.setStyle(Qt::SolidLine);
    pen.setWidth(1);
    painter.begin(image);
    painter.setPen(pen);
    painter.fillRect(0,0,image->width(),image->height(),QBrush(Qt::white));
    painter.setBrush(QBrush(Qt::gray));
    painter.drawConvexPolygon(*cut);
    painter.end();
    ui->display_Label->setPixmap(image->scaled(ui->display_Label->size(),Qt::KeepAspectRatio));
 //   if(ui->x_rButton->isChecked()){
 //       emit draw_cut_GL(1,ui->pos_Box->value());
 //   }else{
 //       emit draw_cut_GL(0,ui->pos_Box->value());
 //   }


}
void GraphicsWidget::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event)

	//set up painting with antialiasing etc
	QPainter painter;

	painter.begin(&elements);
	painter.setRenderHint(QPainter::Antialiasing);
	painter.setRenderHint(QPainter::HighQualityAntialiasing);
	painter.setRenderHint(QPainter::SmoothPixmapTransform);

	//transform coordinates to fit everything neatly on the screen
	painter.save();
	painter.setWorldTransform(getCurrentTransform());

	if (grid != nullptr)
	{
		//loop through and draw each entry
		for (const auto& cell: grid->getCells())
		{
			GridEntry &entry = grid->getEntry(cell);
			if (entry.modified) {
				entry.modified = false;
				painter.save();

				painter.translate(cell.x(), cell.y());

				QPen pen(Qt::black);
				pen.setWidthF(0);

				painter.setPen(pen);
				if (entry.type == GridEntry::Wall)
					painter.setBrush(Qt::darkBlue);

				else if (entry.type == GridEntry::Start)
					painter.setBrush(Qt::yellow);

				else if (entry.type == GridEntry::End)
					painter.setBrush(Qt::red);

				else if (entry.path)
					painter.setBrush(Qt::white);

				else if (entry.searched)
					painter.setBrush(Qt::cyan);
				
				else
					painter.setBrush(Qt::darkGreen);

                painter.drawConvexPolygon(DISPLAY_HEXAGON);

				painter.restore();
			}
		}
	}

	painter.restore();
	painter.setPen(Qt::white);

	QPainter screenPainter(this);
	screenPainter.fillRect(rect(), QBrush(Qt::black));
	screenPainter.drawImage(0, 0, elements);
}
Esempio n. 14
0
void ManoMeter::paintBackground(QPainter & painter)
{
	static const int scaleTriangle[6] = { -6,141,6,141,0,129 };
	initCoordinateSystem(painter);

        // Painting Malowanie obwiedni tarczy. Bia³a tarcza z czarn± skal±
        QPen Pen(QColor(0,0,0)); Pen.setWidth(4);
        painter.setPen(Pen);

        QRadialGradient back1(QPointF(0.0,0.0),180.0,QPointF(-35.0,145.0));
	back1.setColorAt(0.0,QColor(250,250,250));
	back1.setColorAt(1.0,QColor(20,20,20));

	QRadialGradient back2(QPointF(0.0,0.0),225.0,QPointF(76.5,135.0));
	back2.setColorAt(0.0,QColor(10,10,10));
	back2.setColorAt(1.0,QColor(250,250,250));

	painter.setBrush(QBrush(back1));
	painter.drawEllipse(-162,-162,324,324);
	painter.setPen(Qt::NoPen);
        painter.setBrush(QBrush(back2));
        painter.drawEllipse(-152,-152,304,304);

        QRadialGradient shield(QPointF(0,0),182,QPointF(-12.0,-15.0));
	shield.setColorAt(0.0,Qt::white);
	shield.setColorAt(0.5,QColor(240,240,240));
	shield.setColorAt(1.0,QColor(215,215,215));


	// internal scale circle 
	painter.setBrush(QBrush(shield));
	painter.setPen(Pen);
	painter.drawEllipse(-142,-142,284,284);

	  painter.setPen(Qt::NoPen);
          // nominal
	  painter.setBrush(QColor(0,200,0));
	  assert(m_max-m_min != 0);
	  int angle = static_cast<int>( (3840 * ( m_nominal - m_min ))/(m_max-m_min) );
	  if (m_min <= m_nominal && m_nominal < m_max )
           painter.drawPie(QRect(-141,-141,282,282),-480,3840 - angle % 5760 );
	  // Critical

	  painter.setBrush(QBrush(Qt::red));
	  angle = static_cast<int>( (3840 * ( m_critical - m_min ))/(m_max-m_min) );
	  if ( m_min <= m_critical && m_critical < m_max  )
	  painter.drawPie(QRect(-141,-141,282,282),-480, 3840 - angle % 5760  ); //-480, 3840*( m_max-m_min - critical()-abs(m_min) )/static_cast<double>(m_max-m_min));
	  // bia³a obwiednia
	  painter.setBrush(QBrush(shield));
	  painter.drawEllipse(-129,-129,258,258);

        // Ustawienie siê na pocz±tku skali

        painter.rotate(60.0);

 	// Rysowanie skali kreski
	painter.save();
        painter.setBrush(QBrush(Qt::black));
  	int line_length=10;
	for (int i=0;i<33;i++)
	{
	  painter.setPen(Pen);

          if (i % 4) painter.drawLine(0,140,0,140-line_length);
          else {
	    painter.setPen(Qt::NoPen);
	    painter.drawConvexPolygon(QPolygon(3, scaleTriangle));
	  }

	  painter.rotate(7.5);

	Pen.setWidth(3);

 	  if (i % 2)  line_length=10;
	  else        line_length=5;
	}
	painter.restore();

        // Rysowanie skali liczby .

	if (true || digitOffset())
        {
          painter.setPen(Qt::black);
          painter.rotate(-60.0);
	  painter.setFont(digitFont());
	  for (int i=0;i<9;i++)
	  {
	    double v = m_min + i*(m_max - m_min)/8.0;
	    if (fabs(v) < 0.000001 ) v = 0.0;
	    QString val = QString("%1").arg(v);
            QSize Size = painter.fontMetrics().size(Qt::TextSingleLine, val);
            painter.save();
	    painter.translate( digitOffset() * cos((5+i)*PI/6.0), digitOffset() * sin((5+i)*PI/6.0));
	    painter.drawText( QPointF( Size.width()/ -2.0,  Size.height() / 4.0), val);
            painter.restore();
	  }
	}



}// paintBackground
Esempio n. 15
0
void RenderGlyph::paint(PaintInfo &paintInfo, int _tx, int _ty)
{
    if(paintInfo.phase != PaintActionForeground)
        return;

    if(style()->visibility() != VISIBLE)
        return;

    _tx += m_x;
    _ty += m_y;

    if((_ty > paintInfo.r.bottom()) || (_ty + m_height <= paintInfo.r.top()))
        return;

    QPainter *p = paintInfo.p;

    const QColor color(style()->color());
    p->setPen(color);

    int xHeight = m_height;
    int bulletWidth = (xHeight + 1) / 2;
    int yoff = (xHeight - 1) / 4;
    QRect marker(_tx, _ty + yoff, bulletWidth, bulletWidth);

    switch(m_type)
    {
        case LDISC:
            p->setBrush(color);
            p->drawEllipse(marker);
            return;
        case LCIRCLE:
            p->setBrush(Qt::NoBrush);
            p->drawEllipse(marker);
            return;
        case LSQUARE:
            p->setBrush(color);
            p->drawRect(marker);
            return;
        case LBOX:
            p->setBrush(Qt::NoBrush);
            p->drawRect(marker);
            return;
        case LDIAMOND:
        {
            static QPointArray diamond(4);
            int x = marker.x();
            int y = marker.y();
            int s = bulletWidth / 2;
            diamond[0] = QPoint(x + s, y);
            diamond[1] = QPoint(x + 2 * s, y + s);
            diamond[2] = QPoint(x + s, y + 2 * s);
            diamond[3] = QPoint(x, y + s);
            p->setBrush(color);
            p->drawConvexPolygon(diamond, 0, 4);
            return;
        }
        case LNONE:
            return;
        default:
            // not a glyph
            assert(false);
    }
}
Esempio n. 16
0
void QHA::drawForeground(QPainter& painter )
{
        painter.save();
        qfiBackground(painter, m_radius[QHE], 100) ;
        painter.restore();
    QColor	black1(230,230,230) ;
    QColor	black2(160,160,160) ;
    QColor	yellow(250,250,0) ; //couleur triangle
    QColor  white (250,250,250);
    QFont	fo1("Arial", 100 ) ;
    QFont	fo2("Arial", 50 ) ;
    QColor  bleuexterieur (83,123,216);
    QColor  marronexterieur (76,36,11);
    QColor  bleuinterieur (83,123,216);
    QColor  marroninterieur (76,36,11);

   // fond




        QConicalGradient cg(QPointF(0.0, 0.0), 360 ) ;
        cg.setColorAt(0.0, Qt::white ) ;
        cg.setColorAt(1.0, QColor (139,69,19) ) ;

        //pies bague
        painter.save();
        painter.rotate(0+value(QHE));
        painter.setBrush(bleuexterieur);
                                        //largeur                hauteur              élargie largeur        elargie hauteur
        painter.drawPie             (-0.831*QFI_RADIUS,     -0.83*QFI_RADIUS,       2.075*0.8*QFI_RADIUS,    2.07*0.8*QFI_RADIUS,    16*0,16*180);
        painter.restore();


        painter.save();
        painter.rotate(0+value(QHE));
        painter.setBrush(marronexterieur);
        painter.drawPie               (-0.831*QFI_RADIUS,-0.83*QFI_RADIUS, 2.075*0.8* QFI_RADIUS,   2.08*0.8 * QFI_RADIUS,   16*180,16*180);
        painter.restore();

        //pies rond central




        painter.save();
        painter.rotate(0+value(QHE));
        painter.setBrush(bleuinterieur);
                                  //largeur             hauteur                élargie largeur                 elargie hauteur
        painter.drawPie     (-0.635*QFI_RADIUS,     -0.64*QFI_RADIUS,       1.59*0.8*QFI_RADIUS,           1.61*0.8*QFI_RADIUS,     16*0,16*180);
        painter.restore();


        painter.save();
        painter.rotate(0+value(QHE));
        //painter.translate(60, 60);
        painter.setBrush(marroninterieur);
        painter.drawPie               (-0.635*QFI_RADIUS,-0.63*QFI_RADIUS, 1.59*0.8* QFI_RADIUS,   1.58*0.8 * QFI_RADIUS,      16*180,16*180);
        painter.restore();


painter.save();
painter.rotate(0+value(QHE));
        //triangles
        float w = 0;
        float h = 30;
        float r = 0.64*QFI_RADIUS;
        float hbis = h + 5 ;
        QPolygon    triangle, triangle2, triangle3;


    triangle  << QPoint ( r, 0) << QPoint (r + 1.5 * hbis, - 0.75 * hbis) << QPoint(r + 1.5 * hbis, 0.75* hbis) ;
    triangle2 << QPoint ( r, 0) << QPoint (0.82*QFI_RADIUS, - hbis) << QPoint(0.82*QFI_RADIUS, hbis) ;
    triangle3 << QPoint ( r, 0) << QPoint (0.45*QFI_RADIUS, - hbis) << QPoint(0.45*QFI_RADIUS, hbis );



   painter.save();



// traingle graduation
  painter.rotate(-90);

        for ( int i = 0 ; i < 360 ; ++i) {
            painter.save();
            painter.setBrush(white);
  if (i == 0) painter.drawConvexPolygon(triangle2);
  painter.restore();

  painter.save();
  painter.setBrush(yellow);

  if (i == 0) painter.drawConvexPolygon(triangle3);
  painter.restore();

  painter.save();
  painter.setBrush(white);
   if (i == 45)painter.drawConvexPolygon(triangle);
   if (i == 315)painter.drawConvexPolygon(triangle);// BY AXEL
  painter.restore();

    if (i % 5 == 0)   painter.drawRect(r, 10000, hbis, hbis );
    else if (i % 5 == 0 )   painter.drawEllipse(r, 10000, hbis, hbis);
    else                      qfiMarker(painter, white, r + h, QSize(w, h) ) ;
    painter.rotate(1.0) ;
        }
        painter.restore();



      //2 lignes rond central + ligne d'horiz

        painter.setPen(QPen(Qt::white,3));
        painter.save();
        painter.drawLine(-314, 0, 317, 0);
        painter.rotate(0+value(QHE2));
         painter.restore();

        painter.drawLine(-45, -150, 45, -150); //1 ligne (P)
        painter.drawLine(-45, -100, 45, -100); //2 ligne (P)



    // graduations
        painter.save() ;
        painter.rotate(180.0) ;
        QPen pen( Qt::white ) ;
        pen.setWidth(5) ;
        painter.setPen( pen ) ;
        for ( int i = 0 ; i < 31 ; ++i ) {
            int len = ( (i % 5) == 0 ? 90: 0 ) ;
            if (i != 15){
                if (( i== 12) || (i == 13) | (i == 17) || (i == 18 ))
                    len = 45 ;

            if (len != 0)

                painter.drawLine(0.82 * QFI_RADIUS - 90, 0,0.82 * QFI_RADIUS - 90 + len, 0 );
            }
            painter.rotate(6.0) ;
        }
        painter.restore() ;

    }
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;
        }
    }
}
Esempio n. 18
0
void TurnAndBank::createGlass(void){
    QImage _glassImage = QImage(QSize(500,500), QImage::Format_ARGB32);
    _glassImage.fill(0x00ffffff);
    
    QPainter p;
    p.setRenderHint(QPainter::Antialiasing, true);
    p.begin(&_glassImage);
    //p.scale(1./2.5, 1./2.5);
    
    
    
    // Cosmetics on glass: yellow arrows:
    p.setPen(QPen(QColor(79, 106, 25), 0, Qt::SolidLine,
                  Qt::FlatCap, Qt::MiterJoin));
    p.setBrush(Qt::SolidPattern);
    p.setBrush(Qt::yellow);
    
    static const QPointF bigArrow[] = {
        QPointF(250, 250),
        QPointF(362.5, 287.5),
        QPointF(137.5, 287.5)
    };
    int bigArrowNPts = sizeof(bigArrow)/sizeof(bigArrow[0]);
    
    p.drawConvexPolygon(bigArrow, bigArrowNPts);
    
    static const QPointF leftArrow[] = {
        QPointF(125, 375-10),
        QPointF(237.5, 320-10),
        QPointF(240, 322.5-10),
        QPointF(137.5, 387.5-10),
        QPointF(125,387.5-10)
    };
    int leftArrowNPts = sizeof(leftArrow)/sizeof(leftArrow[0]);
    p.drawConvexPolygon(leftArrow, leftArrowNPts);
    
    static const QPointF rightArrow[] = {
        QPointF(375, 375-10),
        QPointF(262.5, 320-10),
        QPointF(260, 322.5-10),
        QPointF(362.5,387.5-10),
        QPointF(375,387.5-10)
    };
    p.drawConvexPolygon(rightArrow, leftArrowNPts);
    
    // Upwards facing orange arrow at vertical up:
    
    static const QPointF orangeArrow[] = {
        QPointF(250, 50),
        QPointF(233, 88),
        QPointF(267, 88)
    };
    p.setBrush(QColor(255,116,0));
    p.drawConvexPolygon(orangeArrow, 3);
    
    // Little black pyramid and chord at bottom:
    p.setBrush(QColor(25,25,25));
    static const QPointF pyramid[] = {
        QPointF(250-19-60, 417+20),
        QPointF(250+19+60, 417+20),
        QPointF(250+25, 250+63+20),
        QPointF(250-25, 250+63+20)
    };
    
    p.drawConvexPolygon(pyramid, 4);
    p.setPen(QPen(Qt::black, 0, Qt::SolidLine,
                  Qt::FlatCap, Qt::MiterJoin));
    
    p.setBrush(QColor(76,76,76));
    p.drawChord(_glassImage.rect(), -40*16, -100*16);
    
    p.setBrush(QColor(25,25,25));
    p.drawChord(_glassImage.rect(), -42*16, -96*16);
    
    
    // Little vacuum text line
    p.setPen(QColor(200,200,200));
    p.setFont(QFont(QString("Helvetica"), 24, QFont::Bold, false));
    int width = p.fontMetrics().width(QString("VACUUM"));
    int height =p.fontMetrics().height();
    p.drawText(250-width/2,385,width, height, Qt::AlignCenter,  "VACUUM");
    
    
    
    p.end();
    
    _glass = QPixmap::fromImage(_glassImage, Qt::AutoColor);
    
}    
Esempio n. 19
0
void AttitudeIndicator::createGlass(float w, float h){

    // Init dimensions
    double origW = 500.0;
    double targetW = qMin(w,h);
    double targetH = targetW;

    // Create image
    QImage _glassImage = QImage(QSize(targetW,targetH), QImage::Format_ARGB32);
    _glassImage.fill(0x00ff0000);

    // Init painter and scale to the original drawing size at 500x500
    QPainter p;
    p.begin(&_glassImage);
    setupPainter(&p);
    double scale = targetW/origW;
    p.scale(scale,scale);

    // Cosmetics on glass: yellow arrows:
    p.setPen(QPen(QColor(0, 0, 0,50), 3, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
    p.setBrush(QColor(255,116,0));
    static const QPointF bigArrow[] = {
        QPointF(250, 250),
        QPointF(362.5, 287.5),
        QPointF(137.5, 287.5)
    };
    int bigArrowNPts = sizeof(bigArrow)/sizeof(bigArrow[0]);
    p.drawConvexPolygon(bigArrow, bigArrowNPts);
    p.setBrush(Qt::yellow);
    static const QPointF leftArrow[] = {
        QPointF(125, 375-10),
        QPointF(237.5, 320-10),
        QPointF(240, 322.5-10),
        QPointF(137.5, 387.5-10),
        QPointF(125,387.5-10)
    };
    int leftArrowNPts = sizeof(leftArrow)/sizeof(leftArrow[0]);
    p.drawConvexPolygon(leftArrow, leftArrowNPts);
    static const QPointF rightArrow[] = {
        QPointF(375, 375-10),
        QPointF(262.5, 320-10),
        QPointF(260, 322.5-10),
        QPointF(362.5,387.5-10),
        QPointF(375,387.5-10)
    };
    p.drawConvexPolygon(rightArrow, leftArrowNPts);
    
    // Upwards facing orange arrow at vertical up:
    static const QPointF orangeArrow[] = {
        QPointF(250, 50),
        QPointF(233, 88),
        QPointF(267, 88)
    };
    p.setBrush(QColor(255,116,0));
    p.drawConvexPolygon(orangeArrow, 3);
    
    // Little black pyramid and chord at bottom:
    p.setBrush(QColor(25,25,25));
    static const QPointF pyramid[] = {
        QPointF(250-19-60, 417+20),
        QPointF(250+19+60, 417+20),
        QPointF(250+25, 250+63+20),
        QPointF(250-25, 250+63+20)
    };
    p.drawConvexPolygon(pyramid, 4);
    p.setPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
    p.setBrush(QColor(76,76,76));
    p.drawChord(QRect(0,0,origW,origW), -40*16, -100*16);
    p.setBrush(QColor(25,25,25));
    p.drawChord(QRect(0,0,origW,origW), -42*16, -96*16);

    // Little vacuum text line
    p.setPen(QColor(200,200,200));
    QFont font(defaultFont);
    font.setPixelSize(20);
    font.setBold(true);
    p.setFont(font);
    int width = p.fontMetrics().width("VACUUM");
    int height = p.fontMetrics().height();
    p.drawText(250-width/2, 385, width, height, Qt::AlignCenter, "VACUUM");

    // Save as pixmap
    p.end();
    _glass = QPixmap::fromImage(_glassImage, Qt::AutoColor);
}    
Esempio n. 20
0
void FieldView::drawTeamSpace(QPainter& p) {
    // Get the latest LogFrame
    const LogFrame* frame = _history->at(0).get();

    if (showTeamNames) {
        // Draw Team Names
        QFont savedFont = p.font();
        QFont fontstyle = p.font();
        fontstyle.setPointSize(20);
        p.setFont(fontstyle);
        p.setPen(bluePen);
        drawText(p, QPointF(0, 4.75), QString(frame->team_name_blue().c_str()),
                 true);  // Blue
        p.setPen(yellowPen);
        drawText(p, QPointF(0, 1.75),
                 QString(frame->team_name_yellow().c_str()),
                 true);  // Yellow
        p.setFont(savedFont);
    }

    // Block off half the field
    if (!frame->use_our_half()) {
        const float FX = Field_Dimensions::Current_Dimensions.FloorWidth() / 2;
        const float FY1 = -Field_Dimensions::Current_Dimensions.Border();
        const float FY2 = Field_Dimensions::Current_Dimensions.Length() / 2;
        p.fillRect(QRectF(QPointF(-FX, FY1), QPointF(FX, FY2)),
                   QColor(0, 0, 0, 128));
    }
    if (!frame->use_opponent_half()) {
        const float FX = Field_Dimensions::Current_Dimensions.FloorWidth() / 2;
        const float FY1 = Field_Dimensions::Current_Dimensions.Length() / 2;
        const float FY2 = Field_Dimensions::Current_Dimensions.Length() +
                          Field_Dimensions::Current_Dimensions.Border();
        p.fillRect(QRectF(QPointF(-FX, FY1), QPointF(FX, FY2)),
                   QColor(0, 0, 0, 128));
    }

    if (showCoords) {
        drawCoords(p);
    }

    // History
    p.setBrush(Qt::NoBrush);
    QPainterPath ballTrail;
    for (unsigned int i = 0; i < 200 && i < _history->size(); ++i) {
        const LogFrame* oldFrame = _history->at(i).get();
        if (oldFrame && oldFrame->has_ball()) {
            QPointF pos = qpointf(oldFrame->ball().pos());

            if (i == 0)
                ballTrail.moveTo(pos);
            else
                ballTrail.lineTo(pos);
        }
    }
    QPen ballTrailPen(ballColor, 0.03);
    ballTrailPen.setCapStyle(Qt::RoundCap);
    p.setPen(ballTrailPen);
    p.drawPath(ballTrail);

    // Debug lines
    for (const DebugPath& path : frame->debug_paths()) {
        if (path.layer() < 0 || layerVisible(path.layer())) {
            tempPen.setColor(qcolor(path.color()));
            p.setPen(tempPen);
            std::vector<QPointF> pts;
            for (int i = 0; i < path.points_size(); ++i) {
                pts.push_back(qpointf(path.points(i)));
            }
            p.drawPolyline(pts.data(), pts.size());
        }
    }

    for (const DebugRobotPath& path : frame->debug_robot_paths()) {
        if (path.layer() < 0 || layerVisible(path.layer())) {
            for (int i = 0; i < path.points_size() - 1; ++i) {
                const DebugRobotPath::DebugRobotPathPoint& from =
                    path.points(i);
                const DebugRobotPath::DebugRobotPathPoint& to =
                    path.points(i + 1);

                Geometry2d::Point avgVel =
                    (Geometry2d::Point(path.points(i).vel()) +
                     Geometry2d::Point(path.points(i + 1).vel())) /
                    2;
                float pcntMaxSpd =
                    avgVel.mag() / MotionConstraints::defaultMaxSpeed();
                QColor mixedColor(std::min((int)(255 * pcntMaxSpd), 255), 0,
                                  std::min((int)(255 * (1 - pcntMaxSpd)), 255));
                QPen pen(mixedColor);
                pen.setCapStyle(Qt::RoundCap);
                pen.setWidthF(0.03);
                p.setPen(pen);

                const Geometry2d::Point fromPos = Geometry2d::Point(from.pos());
                const Geometry2d::Point toPos = Geometry2d::Point(to.pos());
                p.drawLine(fromPos.toQPointF(), toPos.toQPointF());
            }
        }
    }

    // Debug circles
    for (const DebugCircle& c : frame->debug_circles()) {
        if (c.layer() < 0 || layerVisible(c.layer())) {
            tempPen.setColor(c.color());
            p.setPen(tempPen);
            p.drawEllipse(qpointf(c.center()), c.radius(), c.radius());
        }
    }

    // Debug arcs
    for (const DebugArc& a : frame->debug_arcs()) {
        if (a.layer() < 0 || layerVisible(a.layer())) {
            tempPen.setColor(a.color());
            p.setPen(tempPen);

            auto c = a.center();
            auto t1 = a.start();
            auto t2 = a.end();
            auto R = a.radius();

            QRectF rect;
            rect.setX(-R + c.x());
            rect.setY(-R + c.y());
            rect.setWidth(R * 2);
            rect.setHeight(R * 2);

            t1 *= -(180 / M_PI) * 16;
            t2 *= -(180 / M_PI) * 16;

            p.drawArc(rect, t1, t2 - t1);
        }
    }

    // Debug text
    for (const DebugText& text : frame->debug_texts()) {
        if (text.layer() < 0 || layerVisible(text.layer())) {
            tempPen.setColor(text.color());
            p.setPen(tempPen);
            drawText(p, qpointf(text.pos()),
                     QString::fromStdString(text.text()), text.center());
        }
    }

    // Debug polygons
    p.setPen(Qt::NoPen);
    for (const DebugPath& path : frame->debug_polygons()) {
        if (path.layer() < 0 || layerVisible(path.layer())) {
            if (path.points_size() < 3) {
                fprintf(stderr, "Ignoring DebugPolygon with %d points\n",
                        path.points_size());
                continue;
            }

            QColor color = qcolor(path.color());
            color.setAlpha(64);
            p.setBrush(color);
            std::vector<QPointF> pts;
            for (int i = 0; i < path.points_size(); ++i) {
                pts.push_back(qpointf(path.points(i)));
            }
            p.drawConvexPolygon(pts.data(), pts.size());
        }
    }
    p.setBrush(Qt::NoBrush);

    // maps robots to their comet trails, so we can draw a path of where each
    // robot has been over the past X frames the pair used as a key is of the
    // form (team, robot_id).  Blue team = 1, yellow = 2. we only draw trails
    // for robots that exist in the current frame
    map<pair<int, int>, QPainterPath> cometTrails;

    /// populate @cometTrails with the past locations of each robot
    int pastLocationCount = 40;  // number of past locations to show
    for (int i = 0; i < pastLocationCount + 1 && i < _history->size(); i++) {
        const LogFrame* oldFrame = _history->at(i).get();
        if (oldFrame) {
            for (const LogFrame::Robot& r : oldFrame->self()) {
                pair<int, int> key(1, r.shell());
                if (cometTrails.find(key) != cometTrails.end() || i == 0) {
                    QPointF pt = qpointf(r.pos());
                    if (i == 0)
                        cometTrails[key].moveTo(pt);
                    else
                        cometTrails[key].lineTo(pt);
                }
            }

            for (const LogFrame::Robot& r : oldFrame->self()) {
                pair<int, int> key(2, r.shell());
                if (cometTrails.find(key) != cometTrails.end() || i == 0) {
                    QPointF pt = qpointf(r.pos());
                    if (i == 0)
                        cometTrails[key].moveTo(pt);
                    else
                        cometTrails[key].lineTo(pt);
                }
            }
        }
    }

    // draw robot comet trails
    const float cometTrailPenSize = 0.07;
    for (auto& kv : cometTrails) {
        QColor color = kv.first.first == 1 ? Qt::blue : Qt::yellow;
        QPen pen(color, cometTrailPenSize);
        pen.setCapStyle(Qt::RoundCap);
        p.setPen(pen);
        p.drawPath(kv.second);
    }

    // Text positioning vectors
    QPointF rtX = qpointf(Geometry2d::Point(0, 1).rotated(-_rotate * 90));
    QPointF rtY = qpointf(Geometry2d::Point(-1, 0).rotated(-_rotate * 90));

    // Opponent robots
    for (const LogFrame::Robot& r : frame->opp()) {
        drawRobot(p, !frame->blue_team(), r.shell(), qpointf(r.pos()),
                  r.angle(), r.ball_sense_status() == HasBall);
    }

    // Our robots
    int manualID = frame->manual_id();
    for (const LogFrame::Robot& r : frame->self()) {
        QPointF center = qpointf(r.pos());

        bool faulty = false;
        if (r.has_ball_sense_status() && (r.ball_sense_status() == Dazzled ||
                                          r.ball_sense_status() == Failed)) {
            faulty = true;
        }
        if (r.has_kicker_works() && !r.kicker_works()) {
            // 			faulty = true;
        }
        for (int i = 0; i < r.motor_status().size(); ++i) {
            if (r.motor_status(i) != Good) {
                faulty = true;
            }
        }
        if (r.has_battery_voltage() && r.battery_voltage() <= 14.3f) {
            faulty = true;
        }

        drawRobot(p, frame->blue_team(), r.shell(), center, r.angle(),
                  r.ball_sense_status() == HasBall, faulty);

        // Highlight the manually controlled robot
        if (manualID == r.shell()) {
            p.setPen(greenPen);
            const float r = Robot_Radius + .05;
            p.drawEllipse(center, r, r);
        }

        // Robot text
        QPointF textPos = center - rtX * 0.2 - rtY * (Robot_Radius + 0.1);
        for (const DebugText& text : r.text()) {
            if (text.layer() < 0 || layerVisible(text.layer())) {
                tempPen.setColor(text.color());
                p.setPen(tempPen);
                drawText(p, textPos, QString::fromStdString(text.text()),
                         false);
                textPos -= rtY * 0.1;
            }
        }
    }

    // Current ball position and velocity
    if (frame->has_ball()) {
        QPointF pos = qpointf(frame->ball().pos());
        QPointF vel = qpointf(frame->ball().vel());

        p.setPen(ballPen);
        p.setBrush(ballColor);
        p.drawEllipse(QRectF(-Ball_Radius + pos.x(), -Ball_Radius + pos.y(),
                             Ball_Diameter, Ball_Diameter));

        if (!vel.isNull()) {
            p.drawLine(pos, QPointF(pos.x() + vel.x(), pos.y() + vel.y()));
        }
    }
}