// No hardcoding test!!!
void SidarTestPaint1::sidarPaint(const SidarLabel &pSidar)
{
    QPen penline(QColor(70, 255, 0));
    QPen pentext(QColor(0, 167, 255));

    QSize Sidar_size = pSidar.size();
    QPainter pnt((QPaintDevice*)&pSidar);
    pnt.setPen(penline);
    QString s("WRAPPED");
    QFont fnt(pSidar.font());
    QFontMetrics fm(fnt);
    int pixW = fm.width(s);
    int pixH = fm.height(); // unused for now
    pnt.save();

    int texBegin = (Sidar_size.width()/2) - pixW/2;
    int texEnd   = (Sidar_size.width()/2) + pixW/2;

    int drawHeight = Sidar_size.height()/2;

    pnt.drawLine(QLine(0, drawHeight, texBegin, drawHeight));
    pnt.setPen(pentext);
    pnt.drawText(texBegin, drawHeight+(pixH/3), s);
    pnt.setPen(penline);
    pnt.drawLine(QLine(texEnd, drawHeight, Sidar_size.width(), drawHeight));
    pnt.restore();
}
Esempio n. 2
0
void GameWidget::newTurn(Turn turn) {
    QPoint center(turn.pos.x_cor * cell_size, turn.pos.y_cor * cell_size);

    center.rx() = (center.x() / cell_size) * cell_size + cell_size / 2;
    center.ry() = (center.y() / cell_size) * cell_size + cell_size / 2;
    
    qDebug() << center.rx() << " " << center.ry();

    if (turn.side == TICK_SIDE) {
        ticks.push_back(QLine(center.x() - cell_size / 2 + TIC_TOE_SMALL_COEF, 
            center.y() - cell_size / 2 + TIC_TOE_SMALL_COEF,
            center.x() + cell_size / 2 - TIC_TOE_SMALL_COEF, 
            center.y() + cell_size / 2 - TIC_TOE_SMALL_COEF));
        ticks.push_back(QLine(center.x() + cell_size / 2 - TIC_TOE_SMALL_COEF, 
            center.y() - cell_size / 2 + TIC_TOE_SMALL_COEF,
            center.x() - cell_size / 2 + TIC_TOE_SMALL_COEF, 
            center.y() + cell_size / 2 - TIC_TOE_SMALL_COEF));
    } else {
        toes.push_back(QRect(QPoint(center.x() - cell_size / 2 + TIC_TOE_SMALL_COEF, 
                   center.y() - cell_size / 2 + TIC_TOE_SMALL_COEF),
            QPoint(center.x() + cell_size / 2 - TIC_TOE_SMALL_COEF, 
                    center.y() + cell_size / 2 - TIC_TOE_SMALL_COEF)));
    }

    repaint();
}
Esempio n. 3
0
void QZoomLabel::paintEvent( QPaintEvent * event)
{
  QLabel::paintEvent(event);

  QPainter painter(this);

  // frame
  painter.setPen(QPen(QColor(237,237,230),1));

  painter.drawLine(QLine(0,0,width(),0));
  painter.drawLine(QLine(0,height()-1,width(),height()-1));
  painter.drawLine(QLine(0,0,0,height()));
  painter.drawLine(QLine(width()-1,0,width()-1,height()));

  // enable anti-aliasing
  painter.setRenderHint(QPainter::Antialiasing);

  painter.setPen(QPen(QColor(0,0,0),1)); // black

  QLineF line_down_1(40.0f, 9.0f, 44.0f, 12.0f);
  QLineF line_up_1  (44.0f, 12.0f, 48.0f, 9.0f);

  QLineF line_down_2(40.0f, 6.0f, 44.0f, 3.0f);
  QLineF line_up_2  (44.0f, 3.0f, 48.0f, 6.0f);

  // draw down-arrow
  painter.drawLine(line_down_1);
  painter.drawLine(line_up_1);

  // draw up-arrow
  painter.drawLine(line_down_2);
  painter.drawLine(line_up_2);
}
Esempio n. 4
0
    void BurgerWidget::paintEvent(QPaintEvent *e)
    {
        QPainter p(this);
        QImage pix(QSize(burger_width * 2, burger_height * 2), QImage::Format_ARGB32);
        QPainter painter(&pix);
        p.setRenderHint(QPainter::Antialiasing);
        p.setRenderHint(QPainter::TextAntialiasing);
        painter.setRenderHint(QPainter::Antialiasing);
        QPen pen(QColor(ql1s("#454545")));
        pen.setWidth(4);
        pen.setCapStyle(Qt::RoundCap);
        painter.setPen(pen);
        pix.fill(Qt::transparent);

        const static std::array<QLine, 3> lines =
        {
            QLine(QPoint(2, 6), QPoint(44, 6)),
            QLine(QPoint(2, 20), QPoint(44, 20)),
            QLine(QPoint(2, 34), QPoint(44, 34))
        };
        painter.drawLines(lines.data(), lines.size());

        painter.end();
        Utils::check_pixel_ratio(pix);
        if (Utils::is_mac_retina())
            pix = pix.scaled(QSize(width() * 2, height() * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
        else
            pix = pix.scaled(size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);

        p.fillRect(rect(), CommonStyle::getFrameColor());
        p.drawImage(0, 0, pix);
    }
void CRFTagRobot::drawPath(){

    //Flecha superior
    QVector<QPoint> arrow0;
    arrow0.append(QPoint(190, 10)); //punto sobre la recta
    arrow0.append(QPoint(200, 5));  //punto arriba de la recta
    arrow0.append(QPoint(200, 15)); //punto debajo de la recta
    //Flecha inferior
    QVector<QPoint> arrow1;
    arrow1.append(QPoint(190, 400)); //punto sobre la recta
    arrow1.append(QPoint(200, 395)); //punto arriba de la recta
    arrow1.append(QPoint(200, 405)); //punto debajo de la recta
    //Flecha diagonal 1
    QVector<QPoint> arrow2;
    arrow2.append(QPoint(170, 175)); //punto sobre de la recta
    arrow2.append(QPoint(170, 165)); //punto arriba de la recta
    arrow2.append(QPoint(160, 175)); //punto debajo de la recta
    //Flecha diagonal 2
    QVector<QPoint> arrow3;
    arrow3.append(QPoint(230, 175));
    arrow3.append(QPoint(220, 175));
    arrow3.append(QPoint(230, 185));

    this->scene.addPolygon(QPolygon(arrow0), QPen(), QBrush(QColor("black")));
    this->scene.addPolygon(QPolygon(arrow1), QPen(), QBrush(QColor("black")));
    this->scene.addPolygon(QPolygon(arrow2), QPen(), QBrush(QColor("black")));
    this->scene.addPolygon(QPolygon(arrow3), QPen(), QBrush(QColor("black")));
    this->scene.addLine(QLine(QPoint(0, 10), QPoint(400, 400)),QPen(QColor("black")));
    this->scene.addLine(QLine(QPoint(0, 400), QPoint(400, 10)),QPen(QColor("black")));
    this->scene.addLine(QLine(QPoint(0, 10), QPoint(400, 10)),QPen(QColor("black")));
    this->scene.addLine(QLine(QPoint(0, 400), QPoint(400, 400)),QPen(QColor("black")));
}
int BC_GEN::insertbuf(const QChar & bc)
{
	for(int index=0;index<(CODE39_SIZE+1);++index){//include '*'
		if(bc.toUpper().toLatin1()==code39_table[index]){//found char
			global_Xposition+=INTER_GAP_LEN;//char gap
			for(int i=0;i<CODE39_CODE_LEN;++i){
				switch(code39_code_table[index][i]){
					case 'B':
						for(int j=0;j<WIDE_BAR_LEN_R3;++j){
							encode_buf->append(QLine(global_Xposition,global_Yposition,global_Xposition,global_Yposition+global_height));
							global_Xposition+=1;}
						break;
					case 'b':
						for(int j=0;j<NARROW_BAR_LEN;++j){
							encode_buf->append(QLine(global_Xposition,global_Yposition,global_Xposition,global_Yposition+global_height));
							global_Xposition+=1;}
						break;
					case 'W':
						global_Xposition+=WIDE_BAR_LEN_R3;
						break;
					case 'w':
						global_Xposition+=NARROW_BAR_LEN;
						break;
					default:
						return -2;//code error
				}
			}
			chksum+=index;
			return 1;//insert successful
		}
	}
	return -3;//not found char
}
Esempio n. 7
0
void TraceGraphView::drawGrid(QPainter *painter,
                              const QRectF &rect) {
  // draw lines
  QPointF start = rect.topLeft().toPoint();
  QPointF end = rect.bottomRight().toPoint();
  LOG_DEBUG("Draw grid!");
  LOG_DEBUG(rect.topLeft().x() << " , " << rect.topLeft().y());
  LOG_DEBUG(rect.bottomRight().x() << " , " << rect.bottomRight().y());
  LOG_DEBUG(start.x() << " , " << start.y());
  LOG_DEBUG(end.x() << " , " << end.y());

  // draw vertical grid
  for (int i = start.x();
       i < end.x();
       ++i) {
    if (i % m_gridSpacing == 0) {
      painter->drawLine(QLine(QPoint(i, rect.top()),
                              QPoint(i, rect.bottom())));
      i+= m_gridSpacing - 2;
    }
  }

  // draw horizontal grid
  for (int i = start.y();
       i < end.y();
       ++i) {
    if (i % m_gridSpacing == 0) {
      painter->drawLine(QLine(QPoint(rect.left(), i),
                              QPoint(rect.right(), i)));
      i+= m_gridSpacing - 2;
    }
  }
}
Esempio n. 8
0
QImage Rotater::HideRollOutCorners(const QImage image)
{
    QImage destImage = QImage( image);

    QLine hline, vlineR, vlineL;
    int x0, y0, x1, y1;
    if (m_sign < 0)
    {
        x0 = 0, y0 = 0, x1 = m_width, y1 = 0;
    }
    else
    {
        x0 = 0, y0 = m_height, x1 = m_width, y1 = m_height;
    }

    hline = QLine(x0, y0, x1, y1);
    vlineR = QLine(m_width, 0, m_width, m_height);
    vlineL = QLine(0, 0, 0, m_height);

    QLine rvline = m_transform.map(vlineR);
    QPoint pa = get_line_cross_point(hline, rvline);
    QPoint pb = get_line_cross_point(vlineR, rvline);

    QLine rhline = m_transform.map(hline);
    QPoint pc = get_line_cross_point(vlineL, rhline);
    QPoint pd = get_line_cross_point(hline, rhline);

//    destImage = markOnImage( image, pa.x(), pa.y(), MarkType::CrossLines);
//    destImage = markOnImage( destImage, pb.x(), pb.y(), MarkType::CrossLines);
//    destImage = markOnImage( destImage, pc.x(), pc.y(), MarkType::CrossLines);
//    destImage = markOnImage( destImage, pd.x(), pd.y(), MarkType::CrossLines);

    QPolygonF triagle1, triagle2;
    triagle1 << pa << pb << QPointF(x1, y1);
    triagle2 << pc << pd << QPointF(x0, y0);

    QPainterPath myPath;
    myPath.addPolygon(triagle1);
    myPath.addPolygon(triagle2);

    QTransform transform;
    transform.translate(0, m_height * 0.5);
    transform.rotate(180, Qt::XAxis);
    transform.translate(0, -m_height * 0.5);
    QPainterPath myPath1 = transform.map(myPath);

    transform.reset();
    transform.translate(m_width * 0.5, 0);
    transform.rotate(180, Qt::YAxis);
    transform.translate(-m_width * 0.5, 0);
    myPath = transform.map(myPath);
    myPath.addPath(myPath1);

    QPainter painter(&destImage);
    painter.setBrush(Qt::SolidPattern);
    painter.drawPath(myPath);

    return destImage;
}
Esempio n. 9
0
 void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
 {
     static const QLine lines[] = {
         QLine(-8,0, 8,0),
         QLine(0,-8, 0,8),
     };
     painter->setPen(QPen(Qt::DashLine));
     painter->drawLines(lines, sizeof(lines) / sizeof(lines[0]));
 }
Esempio n. 10
0
void Canvas::drawH(int x, int y, int size) {
    int x0 = x - size / 2;
    int x1 = x + size / 2;
    int y0 = y - size / 2;
    int y1 = y + size / 2;

    lines.push_back(QLine(x0, y0, x0, y1));
    lines.push_back(QLine(x1, y0, x1, y1));
    lines.push_back(QLine(x0, y, x1, y));
}
Esempio n. 11
0
void ControlsOverlay::paintEvent(QPaintEvent *event) {
    Q_UNUSED(event)

    QPainter painter(this);
    painter.fillRect(QRect(0,0,60,20),QBrush(QColor(0,0,0,60),Qt::SolidPattern));
    painter.setPen(pen);
    painter.drawLine(QLine(4,15,15,15)); //minimize
    painter.drawRect(QRect(24,10,10,5)); //square
    painter.drawLine(QLine(44,4,54,14)); //cross 1
    painter.drawLine(QLine(44,15,54,5)); //cross 2
}
Esempio n. 12
0
/*!
 * \param[in] aPos point to insert into the polygon
 * \param[in] aPoly polygon
 */
int
ImageHolder::posInPolygon(QPoint *aPos, QPolygon *aPoly) const
{
	if (!aPos || !aPoly || aPoly->count() < 2 || aPos->isNull()) {
		return -1;
		/* NOTREACHED */
	}

	int x = aPos->x();
	int y = aPos->y();

	int index = 0;
	int dist = 100000;
	int temp = 0;
	int count = aPoly->count();
	QRect rect;

	for (int i = 0; i < count - 1; i++) {
		temp = pointToLineDistance(
			QLine(aPoly->at(i), aPoly->at(i + 1)),
			*aPos
			);
		rect.setTopLeft(aPoly->at(i));
		rect.setBottomRight(aPoly->at(i + 1));
		rect = rect.normalized();
		if (temp < dist &&
			((x < rect.right() && rect.left() < x) ||
			(y < rect.bottom() && rect.top() < y)))
		{
			dist = temp;
			index = i + 1;
		}
	}

	/* first and last points */
	temp = pointToLineDistance(
		QLine(aPoly->at(0), aPoly->at(count - 1)),
		*aPos
		);

	rect.setTopLeft(aPoly->at(0));
	rect.setBottomRight(aPoly->at(count - 1));
	rect = rect.normalized();
	if (temp < dist &&
		((x < rect.right() && rect.left() < x) ||
		(y < rect.bottom() && rect.top() < y)))
	{
		index = 0;
	}

	return index;
}
Esempio n. 13
0
/*!
  \code
    QPalette p = QApplication::palette();
    QPalette p2 = p;
    p2.setColor(QPalette::Highlight,p2.color(QPalette::Highlight).lighter());
    headerButtonFold = drawFoldIcon(p, true);
    headerButtonFoldOver = drawFoldIcon(p2, true);
    headerButtonUnfold = drawFoldIcon(p, false);
    headerButtonUnfoldOver = drawFoldIcon(p2, false);
  \endcode
 */
QPixmap SystemPanelScheme::drawFoldIcon(const QPalette& p, bool fold) const
{
    QImage img(17,17,QImage::Format_ARGB32_Premultiplied);
    img.fill(0x00000000);
    QPainter painter;
    painter.begin(&img);
    painter.setBrush(p.window());
    painter.drawEllipse(2,2,13,13);
    painter.setPen(p.color(QPalette::Base));
    painter.drawEllipse(2,2,13,13);
    painter.setPen(p.color(QPalette::Highlight));
    painter.drawLine(QLine(5,7,8,4));
    painter.drawLine(QLine(6,7,8,5));
    painter.drawLine(QLine(8,4,11,7));
    painter.drawLine(QLine(8,5,10,7));
    painter.drawLine(QLine(5,11,8,8));
    painter.drawLine(QLine(6,11,8,9));
    painter.drawLine(QLine(8,8,11,11));
    painter.drawLine(QLine(9,8,10,11));
    painter.end();

    if (!fold) {
        QTransform mat;
        mat.rotate(180.0);
        img = img.transformed(mat);
    }
    return QPixmap::fromImage(img);
}
Esempio n. 14
0
void SShadeRect( IRect *irect , int darkcolor , int lightcolor )

{
	float xmin = XTRANS(irect->xmin);
	float ymax = YTRANS(irect->ymin);
	float xmax = XTRANS(irect->xmax);
	float ymin = YTRANS(irect->ymax);

	/* printf("SShadeRect (0) : %d %d %d %d\n",
		irect->xmin,irect->ymin,irect->xmax,irect->ymax); */
	/* printf("SShadeRect (1) : %f %f %f %f\n",xmin,ymin,xmax,ymax); */

	/* first pass */

	QNewPen(darkcolor);
	QLine( xmin , ymin , xmax , ymin );	/* top */
	QLine( xmax , ymin , xmax , ymax );	/* right */
	QNewPen(lightcolor);
	QLine( xmax , ymax , xmin , ymax );	/* bottom */
	QLine( xmin , ymax , xmin , ymin );	/* left */

	/* second pass -> thicken line */

	xmin += 1.; ymin += 1.;
	xmax -= 1.; ymax -= 1.;

	QNewPen(darkcolor);
	QLine( xmin , ymin , xmax , ymin );	/* top */
	QLine( xmax , ymin , xmax , ymax );	/* right */
	QNewPen(lightcolor);
	QLine( xmax , ymax , xmin , ymax );	/* bottom */
	QLine( xmin , ymax , xmin , ymin );	/* left */

	/* printf("SShadeRect (2) : %f %f %f %f\n",xmin,ymin,xmax,ymax); */
}
Esempio n. 15
0
void OriginIndicator::paint(QPainter *painter,
                            const QStyleOptionGraphicsItem *,
                            QWidget *)
{
    static const QLine lines[] = {
        QLine(-8,0, 8,0),
        QLine(0,-8, 0,8),
    };
    painter->setPen(QPen(mUnderMouse ? Qt::white : Qt::lightGray, 1, Qt::DashLine));
    painter->drawLines(lines, sizeof(lines) / sizeof(lines[0]));
    painter->translate(1, 1);
    painter->setPen(QPen(Qt::black, 1, Qt::DashLine));
    painter->drawLines(lines, sizeof(lines) / sizeof(lines[0]));
}
Esempio n. 16
0
lineItem::lineItem(int width, int height)
{
    m_width = width;
    m_height =  height;

    QLine horizonLine = QLine(4, height * 0.55, width - 4, height  * 0.55);
    m_linePos.push_back(horizonLine);
    QLine verticalLine = QLine(width * 0.19, 4, width * 0.19, height - 4);
    m_linePos.push_back(verticalLine);
    m_lineCroPos.rx() = (double)(width * 19/100);
    m_lineCroPos.ry() = (double)(height * 55 /100) ;
    qDebug("lineItem::lineItem %d, %d",  m_lineCroPos.rx(),  m_lineCroPos.ry());

}
Esempio n. 17
0
//! [paint function]
void DisplayWidget::paint(QPainter &painter)
{
//![paint picture]
    painter.setClipRect(QRect(0, 0, 200, 200));
    painter.setPen(Qt::NoPen);

    switch (background) {
    case Sky:
    default:
        painter.fillRect(QRect(0, 0, 200, 200), Qt::darkBlue);
        painter.translate(145, 10);
        painter.setBrush(Qt::white);
        painter.drawPath(moon);
        painter.translate(-145, -10);
        break;
    case Trees:
    {
        painter.fillRect(QRect(0, 0, 200, 200), Qt::darkGreen);
        painter.setBrush(Qt::green);
        painter.setPen(Qt::black);
        for (int y = -55, row = 0; y < 200; y += 50, ++row) {
            int xs;
            if (row == 2 || row == 3)
                xs = 150;
            else
                xs = 50;
            for (int x = 0; x < 200; x += xs) {
                painter.save();
                painter.translate(x, y);
                painter.drawPath(tree);
                painter.restore();
            }
        }
        break;
    }
    case Road:
        painter.fillRect(QRect(0, 0, 200, 200), Qt::gray);
        painter.setPen(QPen(Qt::white, 4, Qt::DashLine));
        painter.drawLine(QLine(0, 35, 200, 35));
        painter.drawLine(QLine(0, 165, 200, 165));
        break;
    }

    painter.setBrush(shapeColor);
    painter.setPen(Qt::black);
    painter.translate(100, 100);
    painter.drawPath(shapeMap[shape]);
//![paint picture]
}
Esempio n. 18
0
/*!
    \fn TitleBar::draw_close_btn()
 */
void TitleBar::draw_close_btn()
{
    //draw close button
	int ih1 = 13;
	int iw1 = 30;
        QPainter painter;
        QPen pen;
	QLinearGradient gradient1(0, ih1, 0, 0);
	gradient1.setColorAt(0, QColor::fromRgb(131, 3, 3));
	rightPm = QPixmap(iw1, ih1);
	painter.begin(&rightPm);
	
	if(bpress)
	{
		gradient1.setColorAt(1, QColor::fromRgb(237, 26, 86));
		painter.fillRect(0, 0, iw1, ih1, QBrush(gradient1));
		//draw frame close button
		painter.setPen(QColor(0,0,0));
		painter.drawLine(0,0,iw1,0);
		painter.drawLine(0,ih1,0,0);
                painter.drawLine(0, ih1-1, iw1,ih1-1);
                pen.setColor(QColor(83,31,31));

	}
	else
	{
		
	    gradient1.setColorAt(1, QColor::fromRgb(243, 115, 115));
	    painter.fillRect(0, 0, iw1, ih1, QBrush(gradient1));
		//draw frame close button
	    painter.setPen(QColor(66,67,70));
	    painter.drawLine(0,0,iw1,0);
		painter.setPen(QColor(71,71,74));
	    painter.drawLine(0,ih1,0,0);
		painter.setPen(QColor(88,88,90));
            painter.drawLine(0, ih1-1, iw1,ih1-1);
            pen.setColor(QColor(255,255,255));
	}
		
	//draw line close button
	painter.setPen(pen);
	QVector<QLine> lines;
	lines << QLine(iw1-16,ih1-10,iw1-11,ih1-5) << QLine(iw1-11,ih1-10,iw1-16,ih1-5);
	painter.drawLines(lines);
		
	update();
	painter.end();
}
Esempio n. 19
0
void GraphicsGridItem::updateGrid()
{
    prepareGeometryChange();

    // horizontal lines
    mHLines.clear();
    for(int i=0; i<=mRows; i++) {
        mHLines << QLine(QPoint(0, i*mHSpacing), QPoint(mRect.width(),i*mHSpacing));
    }

    // vertical lines
    mVLines.clear();
    for(int i=0; i<=mColumns; i++) {
        mVLines << QLine(QPoint(i*mVSpacing,0), QPoint(i*mVSpacing,mRect.height()));
    }
}
Esempio n. 20
0
void SidarTestPaint::sidarPaint(const SidarLabel &pSidar)
{
    QPen penline(QColor(255, 0, 0));
    QPen pentext(QColor(0, 0, 255));

    QPainter pnt((QPaintDevice*)&pSidar);
    pnt.setPen(penline);
    QString s1("Left");
    QString s2("Right");
    QFont fnt(pSidar.font());
    QFontMetrics fm(fnt);
    int pixW1 = fm.width(s1);
    int pixH1 = fm.height();
    int pixW2 = fm.width(s2);

    pnt.save();
    pnt.setPen(pentext);
    pnt.drawText(0, pixW1, s1);
    pnt.setPen(penline);
    /*pixW1+pSidar.size().width()-pixW2,*/
    pnt.drawLine(QLine(pixW1, pixW1,
                       pSidar.size().width()-pixW2, pixW1));
    pnt.setPen(pentext);
    pnt.drawText(pSidar.size().width()-pixW2, pixW1, s2);
    pnt.restore();
}
Esempio n. 21
0
void FwLinePrimitive::paint(FwPainter *painter, const QRect &clipRect)
{
    Q_UNUSED(clipRect);

    FwPen* pen = this->pen();
    if(m_lenght && pen)
    {
        pen->drawLine(painter, QLine(geometry()->pos(), m_p2 + geometry()->pos()));
    }
}
Esempio n. 22
0
static void qt_plastique_draw_mdibutton(QPainter *painter, const QStyleOptionTitleBar *option, const QRect &tmp, bool hover, bool sunken)
{
    if (tmp.isNull())
        return;
    bool active = (option->titleBarState & QStyle::State_Active);
	
    // ### use palette colors instead
    QColor mdiButtonGradientStartColor;
    QColor mdiButtonGradientStopColor;
	
    if (active) {
        mdiButtonGradientStartColor = QColor((hover || sunken) ? 0x7d8bb1 : 0x55689a);
        mdiButtonGradientStopColor = QColor((hover || sunken) ? 0x939ebe : 0x7381ab);
    } else {
        mdiButtonGradientStartColor = QColor((hover || sunken) ? 0x9e9e9e : 0x818181);
        mdiButtonGradientStopColor = QColor((hover || sunken) ? 0xababab : 0x929292);
    }
	
    qt_plastique_draw_gradient(painter, tmp.adjusted(1, 1, -1, -1),
                               mdiButtonGradientStartColor, mdiButtonGradientStopColor);
	
    QColor mdiButtonBorderColor;
    if (active) {
        mdiButtonBorderColor = (hover || sunken) ? QColor(0x627097) : QColor(0x324577);
    } else {
        mdiButtonBorderColor = (hover || sunken) ? QColor(0x838383) : QColor(0x5e5e5e);
    }
    painter->setPen(QPen(mdiButtonBorderColor, 1));
	
    const QLine lines[4] = {
        QLine(tmp.left() + 2, tmp.top(), tmp.right() - 2, tmp.top()),
        QLine(tmp.left() + 2, tmp.bottom(), tmp.right() - 2, tmp.bottom()),
        QLine(tmp.left(), tmp.top() + 2, tmp.left(), tmp.bottom() - 2),
        QLine(tmp.right(), tmp.top() + 2, tmp.right(), tmp.bottom() - 2) };
    painter->drawLines(lines, 4);
	
    const QPoint points[4] = {
        QPoint(tmp.left() + 1, tmp.top() + 1),
        QPoint(tmp.right() - 1, tmp.top() + 1),
        QPoint(tmp.left() + 1, tmp.bottom() - 1),
        QPoint(tmp.right() - 1, tmp.bottom() - 1) };
    painter->drawPoints(points, 4);
}
Esempio n. 23
0
void QCPULabel::paintEvent(QPaintEvent * event)
{
  event->accept();

  // draw QLabel stuff
  QLabel::paintEvent(event);

  QPainter painter(this);

  // frame
  painter.setPen(QPen(QColor(237,237,230),1));

  painter.drawLine(QLine(0,0,width(),0));
  painter.drawLine(QLine(0,height()-1,width(),height()-1));
  painter.drawLine(QLine(0,0,0,height()));
  painter.drawLine(QLine(width()-1,0,width()-1,height()-1));

  // choose colors
  if (load <= 60.0f){
    painter.setPen(QPen(QColor(58,239,58)));
    painter.setBrush(QBrush(QColor(58,239,58))); // green
  }
  else if (load > 80.0f){
    painter.setPen(QPen(QColor(255,0,0)));
    painter.setBrush(QBrush(QColor(255,0,0))); // red // TODO: rgb
  }
  else {
    painter.setPen(QPen(QColor(255,255,0)));
    painter.setBrush(QBrush(QColor(255,255,0))); // yellow // TODO: rgb
  }

  // draw load bar
  painter.drawRect(1, 1, (int)(width()*load/100.0f)-1, height()-3);

  // set text
  //setText(QString().setNum((int)(load + 0.5f)));

  // quick-hack
  painter.setPen(QPen(QColor(0, 0, 0)));
  painter.drawText(QRect(0, 1, width(), height()), Qt::AlignCenter, QString().setNum((int)(load + 0.5f)));

}
void KarbonGradientWidget::paintEvent(QPaintEvent*)
{
    int w = width() - 4;  // available width for gradient and points
    int h = height() - 7; // available height for gradient and points
    int ph = colorStopBorder_height + 2; // point marker height
    int gh = h - ph;       // gradient area height

    QPainter painter(this);

    QLinearGradient gradient;
    gradient.setStart(QPointF(2, 2));
    gradient.setFinalStop(QPointF(width() - 2, 2));
    gradient.setStops(m_stops);

    m_checkerPainter.paint(painter, QRectF(2, 2, w, gh));

    painter.setBrush(QBrush(gradient));
    painter.drawRect(QRectF(2, 2, w, gh));

    painter.setBrush(QBrush());
    painter.setPen(palette().light().color());

    // light frame around widget
    QRect frame(1, 1, width() - 2, height() - 2);
    painter.drawRect(frame);

    // light line between gradient and point area
    painter.drawLine(QLine(QPoint(1, 3 + gh), QPoint(width() - 1, 3 + gh)));

    painter.setPen(palette().dark().color());
    // left-top frame around widget
    painter.drawLine(QPoint(), QPoint(0, height() - 1));
    painter.drawLine(QPoint(), QPoint(width() - 1, 0));

    // right-bottom from around gradient
    painter.drawLine(QPoint(width() - 2, 2), QPoint(width() - 2, 2 + gh));
    painter.drawLine(QPoint(width() - 2, 2 + gh), QPoint(2, 2 + gh));

    // upper line around point area
    painter.drawLine(QPoint(1, height() - 3 - ph), QPoint(width() - 1, height() - 3 - ph));

    // right-bottom line around point area
    painter.drawLine(QPoint(width() - 2, height() - ph - 1), QPoint(width() - 2, height() - 2));
    painter.drawLine(QPoint(width() - 2, height() - 2), QPoint(2, height() - 2));

    m_pntArea.setRect(2, height() - ph - 2, w, ph);
    painter.fillRect(m_pntArea.x(), m_pntArea.y(), m_pntArea.width(), m_pntArea.height(), palette().window().color());

    painter.setClipRect(m_pntArea.x(), m_pntArea.y(), m_pntArea.width(), m_pntArea.height());
    painter.translate(m_pntArea.x(), m_pntArea.y());

    foreach(const QGradientStop & stop, m_stops)
    paintColorStop(painter, (int)(stop.first * m_pntArea.width()), stop.second);
}
Esempio n. 25
0
        static void createPixmap(Item &item) {
            static qreal dpr = 2.0;
            static QSize iconSize(44, 44);
            QPixmap pixmap(iconSize.width() * Last * dpr, iconSize.height() * dpr);
            pixmap.setDevicePixelRatio(dpr);
            pixmap.fill(QColor(Qt::white));

            {
                const int margin(2);

                QPainter painter(&pixmap);
                QPen pen(item.pen);

                pen.setWidth(pen.width() * 2);

                painter.setPen(pen);
                painter.setBrush(item.brush);

                for (int i = Rect; i < Last; i++) {
                    const QRect rect(QPoint(iconSize.width() * i, 0), iconSize);

                    switch (i) {
                    case Rect: {
                        painter.drawRect(rect.adjusted(margin, margin, -margin, -margin));
                        break;
                    }
                    case Line:{
                        painter.drawLine(QLine(QPoint(rect.left() + margin, rect.center().y() - 2),
                                               QPoint(rect.right() - margin, rect.center().y() - 2)));
                        pen.setStyle(Qt::DotLine);
                        painter.setPen(pen);
                        painter.drawLine(QLine(QPoint(rect.left() + margin, rect.center().y() + 2),
                                               QPoint(rect.right() - margin, rect.center().y() + 2)));
                        break;
                    }
                    }
                }
            }

            item.pixmap = pixmap;
        }
Esempio n. 26
0
CScreenRectItem *CScreenShotView::createRectItem()
{
    QPointF topLeftPos = getPointFromSelectedItem(m_selectRect.topLeft());
    QPointF bottomRightPos = getPointFromSelectedItem(m_selectRect.bottomRight());
    //    QRectF rect = getPositiveRect(topLeftPos,bottomRightPos);
    QRectF rect = CScreenshotUtil::convertLineFToRectF(QLineF(topLeftPos,bottomRightPos));
    CScreenRectItem *item = new CScreenRectItem(rect,QLine(0,0,0,0));
    //    CScreenRectItem *item = new CScreenRectItem(QLineF(topLeftPos,bottomRightPos),QRectF(0,0,0,0));
    item->setLineColor(m_toolbarItem->getColor());
    item->setLineWidth(m_toolbarItem->getLineWidth());
    return item;
}
Esempio n. 27
0
// Draw connection lines between linking
// operators (to visualize dependencies).
void eGuiOpPage::_drawLinkLines(QPainter *painter)
{
    eASSERT(painter != eNULL);

    static const QPoint arrowPts[3] =
    {
        QPoint(0,            0),
        QPoint(-ARROW_SIZE,  ARROW_SIZE),
        QPoint(-ARROW_SIZE, -ARROW_SIZE)
    };

    painter->save();
    painter->setRenderHint(QPainter::HighQualityAntialiasing, true);
    painter->setPen(QColor(80, 90, 100));
    painter->setBrush(QBrush(QColor(120, 130, 140), Qt::SolidPattern));

    for (eU32 i=0; i<m_opPage->getOperatorCount(); i++)
    {
        const eIOperator *op = m_opPage->getOperatorByIndex(i);
        eASSERT(op != eNULL);

        for (eU32 j=0; j<op->getLinkingCount(); j++)
        {
            const eID linkingId = op->getLinkingOperator(j);
            const eIOperator *linkingOp = eDemoData::findOperator(linkingId);

            // Lies linking operator on same page?
            if (linkingOp && linkingOp->getOwnerPage() == m_opPage)
            {
                // Yes, so draw line between them.
                const QRect opRect = _getOperatorRect(op);
                const QRect linkingRect = _getOperatorRect(linkingOp);

                // Calculate nearest intersection point and
                // angle to rotate arrow.
                const QPoint nip = _getNearestIntersectionPoint(opRect, QLine(linkingRect.center(), opRect.center()));
                const QLine line(nip, linkingRect.center());
                const QPoint p = line.p1()-line.p2();
                const eF32 angle = eRadToDeg(eATan2(p.y(), p.x()));

                painter->drawLine(line);
                painter->save();
                painter->translate(line.p1().x(), line.p1().y());
                painter->rotate(angle);
                painter->drawConvexPolygon(arrowPts, 3);
                painter->restore();
            }
        }
    }

    painter->restore();
}
Esempio n. 28
0
void tst_QLine::testCenter()
{
    QFETCH(int, x1);
    QFETCH(int, y1);
    QFETCH(int, x2);
    QFETCH(int, y2);
    QFETCH(int, centerX);
    QFETCH(int, centerY);

    const QPoint c = QLine(x1, y1, x2, y2).center();
    QCOMPARE(centerX, c.x());
    QCOMPARE(centerY, c.y());
}
Esempio n. 29
0
void SidarTestPaint2::sidarPaint(const SidarLabel &pSidar)
{
    QPen penline(QColor(255, 0, 0));
    QPen pentext(QColor(255, 0, 255));

    QPainter pnt((QPaintDevice*)&pSidar);
    pnt.setPen(penline);
    QString s("Custom draw");
    QFont fnt(pSidar.font());
    QFontMetrics fm(fnt);
    int pixW = fm.width(s);
    int pixH = fm.height();
    pnt.save();
    QBrush br(QColor(255, 255, 0));
    pnt.fillRect(0,0, pSidar.size().width(), pSidar.size().height(), br);
    pnt.drawLine(QLine(0, 160, 160, 160));
    pnt.setPen(pentext);
    pnt.drawText(160, 165, s);
    pnt.setPen(penline);
    pnt.drawLine(QLine(160+pixW, 160, 320, 160));
    pnt.restore();
}
Esempio n. 30
-1
void UBGraphicsRuler::paintGraduations(QPainter *painter)
{
    painter->save();
    painter->setFont(font());
    QFontMetricsF fontMetrics(painter->font());
    for (int millimeters = 0; millimeters < (rect().width() - sLeftEdgeMargin - sRoundingRadius) / sPixelsPerMillimeter; millimeters++)
    {
        int graduationX = rotationCenter().x() + sPixelsPerMillimeter * millimeters;
        int graduationHeight = (0 == millimeters % UBGeometryUtils::millimetersPerCentimeter) ?
            UBGeometryUtils::centimeterGraduationHeight :
            ((0 == millimeters % UBGeometryUtils::millimetersPerHalfCentimeter) ?
                UBGeometryUtils::halfCentimeterGraduationHeight : UBGeometryUtils::millimeterGraduationHeight);
        painter->drawLine(QLine(graduationX, rotationCenter().y(), graduationX, rotationCenter().y() + graduationHeight));
        painter->drawLine(QLine(graduationX, rotationCenter().y() + rect().height(), graduationX, rotationCenter().y() + rect().height() - graduationHeight));
        if (0 == millimeters % UBGeometryUtils::millimetersPerCentimeter)
        {
            QString text = QString("%1").arg((int)(millimeters / UBGeometryUtils::millimetersPerCentimeter));
            if (graduationX + fontMetrics.width(text) / 2 < rect().right())
            {
                qreal textWidth = fontMetrics.width(text);
                qreal textHeight = fontMetrics.tightBoundingRect(text).height() + 5;
                painter->drawText(
                    QRectF(graduationX - textWidth / 2, rect().top() + 5 + UBGeometryUtils::centimeterGraduationHeight, textWidth, textHeight),
                    Qt::AlignVCenter, text);
                painter->drawText(
                    QRectF(graduationX - textWidth / 2, rect().bottom() - 5 - UBGeometryUtils::centimeterGraduationHeight - textHeight, textWidth, textHeight),
                    Qt::AlignVCenter, text);
            }
        }
    }
    painter->restore();
}