Ejemplo n.º 1
0
void graphics::NgoiLang(QPainter& painter,int x,int y,int c,int r)
{
    QPoint A(x-r/2,y+c);
    QPoint B(x+r/2,y+c);
    QPoint C(x+r/2,y+c/3);
    QPoint D(x,y);
    QPoint E(x-r/2,y+c/3);
    QPolygon poly1;
    poly1 << D << E << A << B << C;
    painter.drawPolygon(poly1);
// ve cai cua
    QPoint A1(x,y+c);
    QPoint B1(x,y+2*c/3);
    QPoint C1(x-r/4,y+2*c/3);
    QPoint D1(x-r/4,y+c);
    QPolygon poly2;
    poly2 << A1 << B1 << C1 << D1;
    painter.drawPolyline(poly2);
 // ve cua so
   QPoint A11(x-r/4,y+c/6);
    QPoint B11(x-r/4,y);
   QPoint C11(x-r/8,y);
    QPoint D11(x-r/8,y+c/12);
   QPolygon poly21;
    poly21 << A11 << B11 << C11 << D11;
    painter.drawPolygon(poly21);
    painter.drawRect(x+r/4,y+c/2.5,c/10,r/10);

}
Ejemplo n.º 2
0
//-----------------------------------------------------------------------
void GshhsReader::GsshDrawPolygons(QPainter &pnt, std::vector <GshhsPolygon*> &lst,
                                Projection *proj
        )
{
    std::vector <GshhsPolygon*>::iterator iter;
    GshhsPolygon *pol;
    QPoint *pts = NULL;
    int i;
    int nbp;
    
    int nbmax = 10000;
    pts = new QPoint[nbmax];
    assert(pts);
    
    for  (i=0, iter=lst.begin(); iter!=lst.end(); iter++,i++) {
        pol = *iter;
        
        if (nbmax < pol->n+2) {
            nbmax = pol->n+2;
            pts = new QPoint[nbmax];
            assert(pts);
        }
        
        nbp = GSHHS_scaledPoints(pol, pts, 0, proj);
        if (nbp > 3)
            pnt.drawPolygon(pts, nbp);
            
        nbp = GSHHS_scaledPoints(pol, pts, -360, proj);
        if (nbp > 3)
            pnt.drawPolygon(pts, nbp);
    }

    delete [] pts;
}
Ejemplo n.º 3
0
void graphics::NgoiNhaTiHon(QPainter& painter)
{
    QPoint A(150,450);
    QPoint B(350,450);
    QPoint C(350,200);
    QPoint D(250,100);
    QPoint E(150,200);

    QPolygon poly1;
    poly1 << A << B << C << D << E;
    painter.drawPolygon(poly1);
 // cai cua
    QPoint A1(250,450);
    QPoint B1(250,300);
    QPoint C1(200,300);
    QPoint D1(200,450);


    QPolygon poly11;
    poly11 << A1 << B1 << C1 << D1;
    painter.drawPolygon(poly11);
    painter.drawRect(300,250,30,30);
// ong khoi
    QPoint A12(200,150);
    QPoint B12(200,90);
    QPoint C12(175,90);
    QPoint D12(175,175);


    QPolygon poly12;
    poly12 << A12 << B12 << C12 << D12;
    painter.drawPolyline(poly12);

}
Ejemplo n.º 4
0
void
PictureZoneEditor::paintOverPictureMask(QPainter& painter)
{
	painter.setRenderHint(QPainter::Antialiasing);
	painter.setTransform(imageToVirtual() * virtualToWidget(), true);
	painter.setPen(Qt::NoPen);
	painter.setBrush(QColor(mask_color));

#ifndef Q_WS_X11
	// That's how it's supposed to be.
	painter.setCompositionMode(QPainter::CompositionMode_Clear);
#else
	// QPainter::CompositionMode_Clear doesn't work for arbitrarily shaped
	// objects on X11, as well as CompositionMode_Source with a transparent
	// brush.  Fortunately, CompositionMode_DestinationOut with a non-transparent
	// brush does actually work.
	painter.setCompositionMode(QPainter::CompositionMode_DestinationOut);
#endif

	typedef PictureLayerProperty PLP;

	// First pass: ERASER1
	BOOST_FOREACH(EditableZoneSet::Zone const& zone, m_zones) {
		if (zone.properties()->locateOrDefault<PLP>()->layer() == PLP::ERASER1) {
			painter.drawPolygon(zone.spline()->toPolygon(), Qt::WindingFill);
		}
	}

	painter.setCompositionMode(QPainter::CompositionMode_SourceOver);

	// Second pass: PAINTER2
	BOOST_FOREACH (EditableZoneSet::Zone const& zone, m_zones) {
		if (zone.properties()->locateOrDefault<PLP>()->layer() == PLP::PAINTER2) {
			painter.drawPolygon(zone.spline()->toPolygon(), Qt::WindingFill);
		}
	}

#ifndef Q_WS_X11
	// That's how it's supposed to be.
	painter.setCompositionMode(QPainter::CompositionMode_Clear);
#else
	// QPainter::CompositionMode_Clear doesn't work for arbitrarily shaped
	// objects on X11, as well as CompositionMode_Source with a transparent
	// brush.  Fortunately, CompositionMode_DestinationOut with a non-transparent
	// brush does actually work.
	painter.setCompositionMode(QPainter::CompositionMode_DestinationOut);
#endif

	// Third pass: ERASER1
	BOOST_FOREACH (EditableZoneSet::Zone const& zone, m_zones) {
		if (zone.properties()->locateOrDefault<PLP>()->layer() == PLP::ERASER3) {
			painter.drawPolygon(zone.spline()->toPolygon(), Qt::WindingFill);
		}
	}
}
Ejemplo n.º 5
0
void HorizontalPaintingStrategy::drawTabs(const KoRulerPrivate *d, QPainter &painter)
{
    if (! d->showTabs)
        return;
    QPolygonF polygon;

    painter.setBrush(d->ruler->palette().color(QPalette::Text));
    painter.setRenderHint( QPainter::Antialiasing );

    foreach (const KoRuler::Tab & t, d->tabs) {
        qreal x;
        if (d->rightToLeft)
            x = d->viewConverter->documentToViewX(d->activeRangeEnd - t.position)
                    + d->offset;
        else
            x = d->viewConverter->documentToViewX(d->activeRangeStart + t.position)
                    + d->offset;

        polygon.clear();
        switch (t.type) {
        case QTextOption::LeftTab:
            polygon << QPointF(x+0.5, d->ruler->height() - 8.5)
                << QPointF(x-5.5, d->ruler->height() - 2.5)
                << QPointF(x+0.5, d->ruler->height() - 2.5);
            painter.drawPolygon(polygon);
            break;
        case QTextOption::RightTab:
            polygon << QPointF(x+0.5, d->ruler->height() - 8.5)
                << QPointF(x+6.5, d->ruler->height() - 2.5)
                << QPointF(x+0.5, d->ruler->height() - 2.5);
            painter.drawPolygon(polygon);
            break;
        case QTextOption::CenterTab:
            polygon << QPointF(x+0.5, d->ruler->height() - 8.5)
                << QPointF(x-5.5, d->ruler->height() - 2.5)
                << QPointF(x+6.5, d->ruler->height() - 2.5);
            painter.drawPolygon(polygon);
            break;
        case QTextOption::DelimiterTab:
            polygon << QPointF(x-5.5, d->ruler->height() - 2.5)
                << QPointF(x+0.5, d->ruler->height() - 8.5)
                << QPointF(x+6.5, d->ruler->height() - 2.5);
            painter.drawPolyline(polygon);
            break;
        default:
            break;
        }
    }
    //painter.setRenderHint( QPainter::Antialiasing, false );
}
Ejemplo n.º 6
0
void TimeMarker::paint_label(QPainter &p, const QRect &rect, bool hover)
{
	if (!enabled())
		return;

	const qreal x = get_x();
	const QRectF r(label_rect(rect));

	const QPointF points[] = {
		r.topLeft(),
		r.bottomLeft(),
		QPointF(max(r.left(), x - ArrowSize), r.bottom()),
		QPointF(x, rect.bottom()),
		QPointF(min(r.right(), x + ArrowSize), r.bottom()),
		r.bottomRight(),
		r.topRight()
	};

	const QPointF highlight_points[] = {
		QPointF(r.left() + 1, r.top() + 1),
		QPointF(r.left() + 1, r.bottom() - 1),
		QPointF(max(r.left() + 1, x - ArrowSize), r.bottom() - 1),
		QPointF(min(max(r.left() + 1, x), r.right() - 1),
			rect.bottom() - 1),
		QPointF(min(r.right() - 1, x + ArrowSize), r.bottom() - 1),
		QPointF(r.right() - 1, r.bottom() - 1),
		QPointF(r.right() - 1, r.top() + 1),
	};

	if (selected()) {
		p.setPen(highlight_pen());
		p.setBrush(Qt::transparent);
		p.drawPolygon(points, countof(points));
	}

	p.setPen(Qt::transparent);
	p.setBrush(hover ? color_.lighter() : color_);
	p.drawPolygon(points, countof(points));

	p.setPen(color_.lighter());
	p.setBrush(Qt::transparent);
	p.drawPolygon(highlight_points, countof(highlight_points));

	p.setPen(color_.darker());
	p.setBrush(Qt::transparent);
	p.drawPolygon(points, countof(points));

	p.setPen(select_text_color(color_));
	p.drawText(r, Qt::AlignCenter | Qt::AlignVCenter, get_text());
}
Ejemplo n.º 7
0
void
ImageView::onPaint(QPainter& painter, InteractionState const& interaction)
{
	painter.setRenderHint(QPainter::Antialiasing, false);
	painter.setRenderHint(QPainter::SmoothPixmapTransform, true);

	painter.setPen(Qt::NoPen);
	QRectF const virt_rect(virtualDisplayRect());

	switch (m_virtLayout.type()) {
		case PageLayout::SINGLE_PAGE_UNCUT:
			painter.setBrush(QColor(0, 0, 255, 50));
			painter.drawRect(virt_rect);
			return; // No Split Line will be drawn.
		case PageLayout::SINGLE_PAGE_CUT:
			painter.setBrush(QColor(0, 0, 255, 50));
			painter.drawPolygon(m_virtLayout.singlePageOutline());
			break;
		case PageLayout::TWO_PAGES:
			painter.setBrush(m_leftPageRemoved ? QColor(0, 0, 0, 80) : QColor(0, 0, 255, 50));
			painter.drawPolygon(m_virtLayout.leftPageOutline());
			painter.setBrush(m_rightPageRemoved ? QColor(0, 0, 0, 80) : QColor(255, 0, 0, 50));
			painter.drawPolygon(m_virtLayout.rightPageOutline());
			break;
	}

	painter.setRenderHint(QPainter::Antialiasing, true);
	painter.setWorldTransform(QTransform());

	QPen pen(QColor(0, 0, 255));
	pen.setCosmetic(true);
	pen.setWidth(2);
	painter.setPen(pen);
	painter.setBrush(Qt::NoBrush);

	int const num_cutters = m_virtLayout.numCutters();
	for (int i = 0; i < num_cutters; ++i) {
		QLineF const cutter(widgetCutterLine(i));
		painter.drawLine(cutter);
		
		QRectF rect(m_handlePixmap.rect());

		rect.moveCenter(cutter.p1());
		painter.drawPixmap(rect.topLeft(), m_handlePixmap);

		rect.moveCenter(cutter.p2());
		painter.drawPixmap(rect.topLeft(), m_handlePixmap);
	}
}
Ejemplo n.º 8
0
void ECBJT::drawShape( QPainter &p )
{
	const int _x = int(x());
	const int _y = int(y());
	
	initPainter(p);
	
	p.drawLine( _x-8, _y-8, _x-8, _y+8 );
	p.drawLine( _x+8, _y-8, _x-8, _y );
	p.drawLine( _x+8, _y+8, _x-8, _y );
	
	QPolygon pa(3);
	if ( m_bIsNPN )
	{
		pa[0] = QPoint( _x+6, _y+7 );
		pa[1] = QPoint( _x+2, _y+8 );
		pa[2] = QPoint( _x+5, _y+3 );
	}
	else
	{
		pa[0] = QPoint( _x-7, _y+1 );
		pa[1] = QPoint( _x-4, _y+5 );
		pa[2] = QPoint( _x-2, _y );
	}
	p.setBrush( p.pen().color() );
	p.drawPolygon(pa);
	
	deinitPainter(p);
}
Ejemplo n.º 9
0
void ECPotentiometer::drawShape( QPainter &p )
{
	initPainter(p);
	int _x = int(x());
	int _y = int(y());
	
	p.drawRect( _x-14, _y-16, 12, 32 );
	
	Q3PointArray pa(3);
	pa[0] = QPoint( 0, 0 );
	pa[1] = QPoint( 4, -3 );
	pa[2] = QPoint( 4, 3 );
	
	int space = m_pSlider->style().pixelMetric( QStyle::PM_SliderSpaceAvailable, m_pSlider );
	int base_y = _y + int( space * m_sliderProp );
	
	pa.translate( _x + 16, base_y );
	
//	QColor c = m_p1->isSelected() ? m_selectedCol : black;
// FIXME ^ > 	
//	p.setPen(c);
//	p.setBrush(c);
	p.drawPolygon(pa);
	
	p.drawLine( _x + 20, base_y, _x + 24, base_y );
	p.drawLine( _x + 24, base_y, _x + 24, _y );
	
	deinitPainter(p);
}
Ejemplo n.º 10
0
void JunctionFlowNode::drawShape ( QPainter &p )
{
	const int _x = ( int ) x();
	const int _y = ( int ) y();

	if ( !m_inFlowConnList.isEmpty() )
	{
		const FlowConnectorList::iterator end = m_inFlowConnList.end();
		for ( FlowConnectorList::iterator it = m_inFlowConnList.begin(); it != end; ++ it )
		{
			Connector * connector = *it;
			if ( !connector )
				continue;

			// Work out the direction of the connector
			const QPointList points = connector->connectorPoints ( false );

			const int count = points.size();
			if ( count < 2 )
				continue;

			QPoint end_0 = points[count-1];
			QPoint end_1 = points[count-2];

			Q3PointArray pa;
			if ( end_0.x() < end_1.x() )
			{
				pa = arrowPoints ( 180 );
				pa.translate ( 4, 0 );
			}
			else if ( end_0.x() > end_1.x() )
			{
				pa = arrowPoints ( 0 );
				pa.translate ( -4, 0 );
			}
			else if ( end_0.y() < end_1.y() )
			{
				pa = arrowPoints ( 270 );
				pa.translate ( 0, 4 );
			}
			else if ( end_0.y() > end_1.y() )
			{
				pa = arrowPoints ( 90 );
				pa.translate ( 0, -4 );
			}
			else	continue;

			pa.translate ( _x, _y );
			p.setPen ( connector->isSelected() ? m_selectedColor : Qt::black );
			p.drawPolygon ( pa );
		}
		return;
	}

	if	( m_dir == 0 )		p.drawLine ( _x, _y, _x-8, _y );
	else if ( m_dir == 90 )		p.drawLine ( _x, _y, _x, _y-8 );
	else if ( m_dir == 180 )	p.drawLine ( _x, _y, _x+8, _y );
	else if ( m_dir == 270 )	p.drawLine ( _x, _y, _x, _y+8 );

}
Ejemplo n.º 11
0
void RRTWidget::drawTerminalState(QPainter &painter, const Vector2f &pos, const Vector2f &vel, const QColor &color) {
    //  draw point
    painter.setPen(QPen(color, 6));
    QPointF rootLoc(pos.x(), pos.y());
    painter.drawEllipse(rootLoc, 2, 2);


    Vector2f tipOffset = vel * VelocityDrawingMultiplier;
    Vector2f tipLocVec = pos + tipOffset;
    QPointF tipLoc(tipLocVec.x(), tipLocVec.y());

    //  draw arrow shaft
    painter.setPen(QPen(color, 3));
    painter.drawLine(rootLoc, tipLoc);

    //  draw arrow head
    Vector2f headBase = tipLocVec - tipOffset.normalized()*4;
    Vector2f perp = Vector2f(-tipOffset.y(), tipOffset.x()).normalized();
    Vector2f tipLeftVec = headBase + perp*4;
    Vector2f tipRightVec = headBase - perp*4;
    QPointF trianglePts[] = {
        tipLoc,
        QPointF(tipLeftVec.x(), tipLeftVec.y()),
        QPointF(tipRightVec.x(), tipRightVec.y())
    };
    painter.drawPolygon(trianglePts, 3);
}
Ejemplo n.º 12
0
void ArrowLine::drawShape(QPainter &p)
{
    p.setPen(darkGray);
    QCanvasLine::drawShape(p);

    double angle = computeAngle(startPoint().x(),
                                startPoint().y(),
                                endPoint().x(),
                                endPoint().y());
    QPointArray pts(3);

    QWMatrix m;
    int x, y;
    m.rotate(angle);
    m.map(-5, -2, &x, &y);
    pts.setPoint(0, x, y);
    m.map(-5, 2, &x, &y);
    pts.setPoint(1, x, y);
    m.map(0, 0, &x, &y);
    pts.setPoint(2, x, y);

    pts.translate(endPoint().x(), endPoint().y());

    p.setBrush(QColor(darkGray));
    p.drawPolygon(pts);
}
Ejemplo n.º 13
0
void Graph::paintEvent(QPaintEvent *)
{
    QPainter painter;
    painter.begin(this);
    painter.setBackground(background);
    painter.eraseRect(rect());
    QPoint *points = new QPoint[MAX_DATA_LENGTH +2];
    points[0] = QPoint(0,150);
    points[MAX_DATA_LENGTH +1] = QPoint(MAX_DATA_LENGTH,150);
    for (int s = 0; s < MAX_DATA_LENGTH; s++){
        points[s +1] = QPoint(s,100 - data.at(data.length() - s -1));
    }
    painter.setPen(gridPen);
    painter.setBrush(filler);
    for (int s = 0; s < MAX_DATA_LENGTH / 30; s++){
        painter.drawLine(MAX_DATA_LENGTH - 30 * (s+1), 0,MAX_DATA_LENGTH - 30 * (s+1), 100);
    }
    for (int s = 0; s < 10; s++){
        painter.drawLine(0, 10*s,MAX_DATA_LENGTH, 10*s);
    }
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setPen(circlePen);
    painter.drawPolygon(points,MAX_DATA_LENGTH +2);
    painter.end();
    delete points;
}
Ejemplo n.º 14
0
void FreeRegionGrabber::grabRect()
{
    QPolygon pol = selection;
    if ( !pol.isEmpty() )
    {
	grabbing = true;

        int xOffset = pixmap.rect().x() - pol.boundingRect().x();
        int yOffset = pixmap.rect().y() - pol.boundingRect().y();
        QPolygon translatedPol = pol.translated(xOffset, yOffset);

        QPixmap pixmap2(pol.boundingRect().size());
        pixmap2.fill(Qt::transparent);

        QPainter pt;
        pt.begin(&pixmap2);
        if (pt.paintEngine()->hasFeature(QPaintEngine::PorterDuff)) {
            pt.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing | QPainter::SmoothPixmapTransform, true);
            pt.setBrush(Qt::black);
            pt.setPen(QPen(QBrush(Qt::black), 0.5));
            pt.drawPolygon(translatedPol);
            pt.setCompositionMode(QPainter::CompositionMode_SourceIn);
        } else {
            pt.setClipRegion(QRegion(translatedPol));
            pt.setCompositionMode(QPainter::CompositionMode_Source);
        }

        pt.drawPixmap(pixmap2.rect(), pixmap, pol.boundingRect());
        pt.end();

        emit freeRegionUpdated(pol);
        emit freeRegionGrabbed(pixmap2);
    }
}
Ejemplo n.º 15
0
void ClsQStateArrayViewHex::drawHexagon(QPainter &paint, int iXCenter, int iYCenter, int iVertexlength, int /* iOrientation */){

    const double f = 1.7320508;

    iXCenter = iXCenter + (int)((double)iVertexlength/4. * f);
    iYCenter = iYCenter + (int)((double)iVertexlength/2.) ;


    QPointArray pa(6);

/*
    pa[0] = QPoint(iVertexlength / 2,0);
    pa[1] = QPoint(iVertexlength / 4 ,-iVertexlength / 4 * f);
    pa[2] = QPoint(-iVertexlength / 4,-iVertexlength / 4 * f);
    pa[3] = QPoint(-iVertexlength / 2,0);
    pa[4] = QPoint(-iVertexlength / 4,iVertexlength / 4 * f);
    pa[5] = QPoint(iVertexlength / 4 ,iVertexlength / 4 * f);
*/

    pa[0] = QPoint(0,                             (int)(-iVertexlength/2));
    pa[1] = QPoint((int)(iVertexlength / 4 * f),  (int)(-iVertexlength / 4));
    pa[2] = QPoint((int)(iVertexlength / 4 * f),  (int)(iVertexlength / 4));
    pa[3] = QPoint(0,                             (int)(iVertexlength/2));
    pa[4] = QPoint((int)(-iVertexlength / 4 * f), (int)(iVertexlength / 4));
    pa[5] = QPoint((int)(-iVertexlength / 4 * f), (int)(-iVertexlength / 4));

    pa.translate(iXCenter, iYCenter);

    paint.drawPolygon ( pa, false );
}
Ejemplo n.º 16
0
void LayerSound::paintImages(QPainter& painter, TimeLineCells* cells, int x, int y, int width, int height, bool selected, int frameSize)
{

    for(int i=0; i < sound.size(); i++)
    {
        qreal h = x + (framesPosition.at(i)-1)*frameSize+2;
        if (framesSelected.at(i))
        {
            painter.setBrush(QColor(60,60,60));
            h = h + frameOffset*frameSize;
            //	painter.drawRect((framesPosition.at(i)+frameOffset-1)*frameSize+2, verticalPosition+1, frameSize-2, layerHeight-4);
        }
        else
        {
            //	if (framesModified.at(i))
            //		painter.setBrush(QColor(255,125,125));
            //	else
            //painter.setPen(QPen(QBrush(QColor(40,40,40)), 1, Qt::SolidLine, Qt::RoundCap,Qt::RoundJoin));
            painter.setBrush(QColor(125,125,125));
        }
        QPointF points[3] = { QPointF(h, y+4), QPointF(h, y+height-4), QPointF(h+15, y+0.5*height) };
        painter.drawPolygon( points, 3 );
        //painter.drawRect((startingFrame.at(i)-1)*frameSize+2, verticalPosition+1, frameSize-2, layerHeight-4);
        painter.drawText(QPoint( h + 20, y+(2*height)/3), framesFilename.at(i) );
        //}
    }
}
Ejemplo n.º 17
0
void Cursor::paint_fix_label(QPainter &p, const QRect &rect,
    unsigned int prefix, QChar label, QColor color)
{
    using pv::view::Ruler;
    bool visible;

    compute_text_size(p, prefix);
    const QRect r(get_label_rect(rect, visible));
    if (!visible)
        return;

    p.setPen(Qt::transparent);
    p.setBrush(color);
    p.drawRect(r);

    const QPoint points[] = {
        QPoint(r.left() + r.width() / 2 - ArrowSize, r.bottom()),
        QPoint(r.left() + r.width() / 2 + ArrowSize, r.bottom()),
        QPoint(r.left() + r.width() / 2, rect.bottom()),
    };
    p.drawPolygon(points, countof(points));

    p.setPen(Qt::white);
    p.drawText(r, Qt::AlignCenter | Qt::AlignVCenter,
        Ruler::format_real_time(_index, _view.session().cur_samplerate()));

    const QRect arrowRect = QRect(r.bottomLeft().x(), r.bottomLeft().y(), r.width(), ArrowSize);
    p.drawText(arrowRect, Qt::AlignCenter | Qt::AlignVCenter, label);
}
Ejemplo n.º 18
0
void DebugDraw::DrawPolygon(const b2Vec2 *vertices, int32 vertexCount,
                            const b2Color &color)
{
    mP->setPen(toQColor(color));
    mP->setBrush(Qt::NoBrush);
    mP->drawPolygon(toQPolygonF(vertices, vertexCount));
}
Ejemplo n.º 19
0
void VariableCapacitor::drawShape(QPainter &p) {
	initPainter(p);

	// Get centre point of component.
	int _y = (int)y();
	int _x = (int)x();

	p.drawRect(_x - 8, _y - 8, 5, 16);
	p.drawRect(_x + 3, _y - 8, 5, 16);

// 	p.drawLine( _x-8, _y, _x-16, _y );
// 	p.drawLine( _x+8, _y, _x+16, _y );

	// Diagonally pointing arrow
	QPointArray pa(3);
	pa[0] = QPoint(-4, 0);
	pa[1] = QPoint(-2, 4);
	pa[2] = QPoint(0, 0);

	pa.translate(_x + 16, _y - 8);
	p.setBrush(p.pen().color());
	p.drawPolygon(pa);

	p.drawLine(_x - 16, _y + 8, _x + 16, _y - 8);

	deinitPainter(p);
}
Ejemplo n.º 20
0
void altitudewidget::paintEvent(QPaintEvent*){
    QPainter *painter = new QPainter(this);
    painter->setWindow(-50, -100, 100, 200);
    
    QPen backgroundpen(Qt::black, 1, Qt::SolidLine);
    painter->setPen(backgroundpen);
    QBrush backgroundbrush(Qt::black);
    painter->setBrush(backgroundbrush);
    painter->drawRect(-50, -100, 100, 200);

    QPen pointerpen(Qt::white, 1, Qt::SolidLine);
    painter->setPen(pointerpen);
    QBrush pointerbrush(Qt::white);
    painter->setBrush(pointerbrush);
    QPoint arrow[3] = {QPoint(-35, 0), QPoint(-45, 5), QPoint(-45, -5)};
    painter->drawPolygon(arrow, 3);
    
    painter->translate(0, -20*altitude);
    
    QString value;
    for(int i = 0; i<=100; i++) {
        painter->drawLine(-20, 0, -10, 0);
        painter->drawText(0, -10, 25, 20, Qt::AlignRight, value.setNum(i));
        //painter->drawText(0, 0, value.setNum(i));
        painter->translate(0, 20);
    }
}
Ejemplo n.º 21
0
void HorizontalDistancesPaintingStrategy::drawDistanceLine(const KoRulerPrivate *d, QPainter &painter, const qreal start, const qreal end)
{

    // Don't draw too short lines
    if (qMax(start, end) - qMin(start, end) < 1)
        return;

    painter.save();
    painter.translate(d->offset, d->ruler->height() / 2);
    painter.setPen(d->ruler->palette().color(QPalette::Text));
    painter.setBrush(d->ruler->palette().color(QPalette::Text));

    QLineF line(QPointF(d->viewConverter->documentToViewX(start), 0),
            QPointF(d->viewConverter->documentToViewX(end), 0));
    QPointF midPoint = line.pointAt(0.5);

    // Draw the label text
    QFont font = KGlobalSettings::smallestReadableFont();
    font.setPointSize(6);
    QFontMetrics fontMetrics(font);
    QString label = d->unit.toUserStringValue(
            d->viewConverter->viewToDocumentX(line.length())) + ' ' + KUnit::unitName(d->unit);
    QPointF labelPosition = QPointF(midPoint.x() - fontMetrics.width(label)/2,
            midPoint.y() + fontMetrics.ascent()/2);
    painter.setFont(font);
    painter.drawText(labelPosition, label);

    // Draw the arrow lines
    qreal arrowLength = (line.length() - fontMetrics.width(label)) / 2 - 2;
    arrowLength = qMax(qreal(0.0), arrowLength);
    QLineF startArrow(line.p1(), line.pointAt(arrowLength / line.length()));
    QLineF endArrow(line.p2(), line.pointAt(1.0 - arrowLength / line.length()));
    painter.drawLine(startArrow);
    painter.drawLine(endArrow);

    // Draw the arrow heads
    QPolygonF arrowHead;
    arrowHead << line.p1() << QPointF(line.x1()+3, line.y1()-3)
        << QPointF(line.x1()+3, line.y1()+3);
    painter.drawPolygon(arrowHead);
    arrowHead.clear();
    arrowHead << line.p2() << QPointF(line.x2()-3, line.y2()-3)
        << QPointF(line.x2()-3, line.y2()+3);
    painter.drawPolygon(arrowHead);

    painter.restore();
}
Ejemplo n.º 22
0
void HorizontalPaintingStrategy::drawIndents(const KoRulerPrivate *d, QPainter &painter)
{
    QPolygonF polygon;

    painter.setBrush(d->ruler->palette().brush(QPalette::Base));
    painter.setRenderHint( QPainter::Antialiasing );

    qreal x;
    // Draw first line start indent
    if (d->rightToLeft)
        x = d->effectiveActiveRangeEnd() - d->firstLineIndent - d->paragraphIndent;
    else
        x = d->effectiveActiveRangeStart() + d->firstLineIndent + d->paragraphIndent;
    // convert and use the +0.5 to go to nearest integer so that the 0.5 added below ensures sharp lines
    x = int(d->viewConverter->documentToViewX(x) + d->offset + 0.5);
    polygon << QPointF(x+6.5, 0.5)
        << QPointF(x+0.5, 8.5)
        << QPointF(x-5.5, 0.5)
        << QPointF(x+5.5, 0.5);
    painter.drawPolygon(polygon);

    // draw the hanging indent.
    if (d->rightToLeft)
        x = d->effectiveActiveRangeStart() + d->endIndent;
    else
        x = d->effectiveActiveRangeStart() + d->paragraphIndent;
    // convert and use the +0.5 to go to nearest integer so that the 0.5 added below ensures sharp lines
    x = int(d->viewConverter->documentToViewX(x) + d->offset + 0.5);
    const int bottom = d->ruler->height();
    polygon.clear();
    polygon << QPointF(x+6.5, bottom - 0.5)
        << QPointF(x+0.5, bottom - 8.5)
        << QPointF(x-5.5, bottom - 0.5)
        << QPointF(x+5.5, bottom - 0.5);
    painter.drawPolygon(polygon);

    // Draw end-indent or paragraph indent if mode is rightToLeft
    qreal diff;
    if (d->rightToLeft)
        diff = d->viewConverter->documentToViewX(d->effectiveActiveRangeEnd()
                     - d->paragraphIndent) + d->offset - x;
    else
        diff = d->viewConverter->documentToViewX(d->effectiveActiveRangeEnd() - d->endIndent)
                + d->offset - x;
    polygon.translate(diff, 0);
    painter.drawPolygon(polygon);
}
Ejemplo n.º 23
0
void BiDirLED::drawShape(QPainter &p) {
	initPainter(p);

	for (unsigned i = 0; i < 2; i++) {
		uint _b;

		if (lastUpdatePeriod == 0.)
			_b = last_brightness[i];
		else {
			_b = uint(avg_brightness[i] / lastUpdatePeriod);
			last_brightness[i] = _b;
		}

		avg_brightness[i] = 0.;

		p.setBrush(QColor(uint(255 - (255 - _b)*(1 - r[i])), uint(255 - (255 - _b)*(1 - g[i])), uint(255 - (255 - _b)*(1 - b[i]))));


		QPointArray pa(3);

		if (i == 0) {
			pa[0] = QPoint(8, -8);
			pa[1] = QPoint(-8, -16);
			pa[2] = QPoint(-8, 0);
		} else {
			pa[0] = QPoint(-8, 8);
			pa[1] = QPoint(8, 0);
			pa[2] = QPoint(8, 16);
		}

		pa.translate(int(x()), int(y()));

		p.drawPolygon(pa);
		p.drawPolyline(pa);
	}

	lastUpdatePeriod = 0.;

	// Draw the arrows indicating it's a LED
	int _x = (int)x() - 2;
	int _y = (int)y() - 21;

	p.drawLine(_x + 9, _y + 3, _x + 12, _y); // Tail of left arrow
	p.drawLine(_x + 12, _y, _x + 10, _y); // Left edge of left arrow tip
	p.drawLine(_x + 12, _y, _x + 12, _y + 2); // Right edge of left arrow tip

	p.drawLine(_x + 12, _y + 6, _x + 15, _y + 3); // Tail of right arrow
	p.drawLine(_x + 15, _y + 3, _x + 13, _y + 3); // Left edge of right arrow tip
	p.drawLine(_x + 15, _y + 3, _x + 15, _y + 5); // Right edge of right arrow tip

	p.drawLine(_x + 10, _y, _x + 15, _y + 5); // Diagonal line that forms base of both arrow tips

	_x = int(x());
	_y = int(y());
	p.drawLine(_x + 8, _y - 16, _x + 8, _y);
	p.drawLine(_x - 8, _y, _x - 8, _y + 16);

	deinitPainter(p);
}
Ejemplo n.º 24
0
void Configuration::displayMask(QPainter& painter)
{
	painter.setPen(QPen(QBrush(MDMA::mask_color), 1, Qt::SolidLine, Qt::RoundCap));
	painter.setBrush(QBrush(MDMA::mask_color));
	QPolygon poly;
	for(QPoint& p : user_mask) poly << p;
	painter.drawPolygon(poly);
}
Ejemplo n.º 25
0
void RectangleOverlapTester::debug(QPainter& painter) const
{
  for(auto const &rect : _rects)
    {
      QPolygonF poly = rect.makePolygon();
      painter.drawPolygon(poly);
    }
}
Ejemplo n.º 26
0
QPixmap ClsBaseQStateArrayView::getGradientPixmap(int iImgWidth, int iImgHeight, int _iColorMode ) {
#ifdef DEBUG_CLSBASEQSTATEARRAYVIEW
    cout << "ClsBaseQStateArrayView::getGradientPixmap(int iImgWidth, int iImgHeight)" << endl;
#endif

//    int iColorMode = ClsBaseQStateArrayView::GRAY;
//    int iColorMode = ClsBaseQStateArrayView::BLUE2RED;
//    int iColorMode = ClsBaseQStateArrayView::HSV;

    QPixmap pmGradient;
    QPainter* paintGradient = new QPainter();
    QWMatrix mxRot;
    int iDiag = (int)(sqrt(double(iImgWidth * iImgWidth + iImgHeight * iImgHeight))/2.);

    pmGradient.resize(2 * iDiag, 2 * iDiag);
    paintGradient->begin(&pmGradient);

    paintGradient->setWindow( 0, 0, 2 * iDiag, 2 * iDiag );

    int iNrSices = 50;
    for ( int i=0; i<iNrSices; i++ ) {
	paintGradient->setWorldMatrix( mxRot );
	QColor c;
	if(_iColorMode == ClsBaseQStateArrayView::GRAY){
	    c.setRgb( i* 255 / iNrSices,  i* 255 / iNrSices,  i* 255 / iNrSices );
	}
	else if(_iColorMode == ClsBaseQStateArrayView::BLUE2RED){
	    if(i<iNrSices/2){
		/* BLUE */
		c.setRgb(0, 0,  255 - i * 510/iNrSices);
	    }
	    else {
		/* RED */
		c.setRgb( (i - iNrSices/2) * 255/(iNrSices/2),  0,0);
	    }
	}
	else {
	    c.setHsv( i* 360 / iNrSices, 255, 255 );
	}
	paintGradient->setBrush( c );
	paintGradient->setPen( c );
//zzz	QPointArray a;
	QPolygon a;

	a.setPoints( 4,
		     0, 0,
		     iDiag * 2 / iNrSices, 0,
		     iDiag * 2 / iNrSices, iDiag * 2,
		     0, iDiag * 2 );
	paintGradient->drawPolygon( a );
	mxRot.translate( (double)iDiag * 2.0 / (double)iNrSices, 0.0  );
    }

    paintGradient->end();
    return pmGradient;

}
void QuickGuideWidget::PaintBubble(QPainter &pPainter, const QPoint &pStartPos, const QPoint &pEndPos, int pWidth, const QString &pContents)
{
#define BUBBLE_BOUND_WIDTH 10
#define BUBBLE_BOUND_HEIGHT 6

    //用透明色绘制文字,获取文字的实际尺寸高度。
    QFont font;
    font.setPointSize(this->height() / 50);
    pPainter.setFont(font);
    pPainter.setPen(Qt::transparent);
    QRect drawrect, textrect;
    if (pEndPos.y() > pStartPos.y()) {
        drawrect = QRect(pEndPos.x() - pWidth / 2, pEndPos.y(), pWidth, 1000);
        pPainter.drawText(drawrect, Qt::AlignHCenter | Qt::TextWordWrap, pContents, &textrect);
        textrect.adjust(0, BUBBLE_BOUND_HEIGHT, 0, BUBBLE_BOUND_HEIGHT);
    }
    else {
        drawrect = QRect(pEndPos.x() - pWidth / 2, pEndPos.y(), pWidth, 1000);
        pPainter.drawText(drawrect, Qt::AlignHCenter | Qt::TextWordWrap, pContents, &textrect);
        textrect.adjust(0, -textrect.height() - BUBBLE_BOUND_HEIGHT, 0, -textrect.height() - BUBBLE_BOUND_HEIGHT);
    }

    QRect bubblerect = textrect;
    bubblerect.adjust(-BUBBLE_BOUND_WIDTH, -BUBBLE_BOUND_HEIGHT, BUBBLE_BOUND_WIDTH, BUBBLE_BOUND_HEIGHT);

    //设置颜色。
    QLinearGradient shapebrush(0, bubblerect.top(), 0, bubblerect.bottom());
    shapebrush.setColorAt(0, QColor(227, 237, 255, 200));
    shapebrush.setColorAt(1, QColor(165, 197, 255, 200));
    pPainter.setBrush(shapebrush);
    QPen shapepen(QColor(74, 126, 187, 200), 2);
    pPainter.setPen(shapepen);

    //气泡。
    QPoint polygon[7];
    polygon[0] = QPoint(pEndPos.x() + BUBBLE_BOUND_HEIGHT, pEndPos.y());
    polygon[1] = pStartPos;
    polygon[2] = QPoint(pEndPos.x() - BUBBLE_BOUND_HEIGHT, pEndPos.y());
    if (pEndPos.y() > pStartPos.y()) {
        polygon[3] = bubblerect.topLeft();
        polygon[4] = bubblerect.bottomLeft();
        polygon[5] = bubblerect.bottomRight();
        polygon[6] = bubblerect.topRight();
    }
    else {
        polygon[3] = bubblerect.bottomLeft();
        polygon[4] = bubblerect.topLeft();
        polygon[5] = bubblerect.topRight();
        polygon[6] = bubblerect.bottomRight();
    }
    pPainter.drawPolygon(polygon, 7);

    //文字内容。
    QPen textpen(QColor(36, 54, 72));
    pPainter.setPen(textpen);
    pPainter.drawText(textrect, Qt::TextWordWrap, pContents);
}
Ejemplo n.º 28
0
void MapIcon::paintLeftTriangle(QPainter&p, const QPoint& point, 
				int size, int sizeWH)
{
  QPointArray atri(3);
  atri.setPoint(0, point.x() - size, point.y());
  atri.setPoint(1, point.x() + size, point.y() + size);
  atri.setPoint(2, point.x() + size, point.y() - size);
  p.drawPolygon(atri);
}
Ejemplo n.º 29
0
void Trace::paint_label(QPainter &p, int right, const QPoint pt)
{
    compute_text_size(p);
    const int y = get_y();

    const QRectF color_rect = get_rect("color", y, right);
    const QRectF name_rect  = get_rect("name",  y, right);
    const QRectF label_rect = get_rect("label", get_zeroPos(), right);

    p.setRenderHint(QPainter::Antialiasing);
    // Paint the ColorButton
    p.setPen(Qt::transparent);
    p.setBrush(enabled() ? _colour : dsDisable);
    p.drawRect(color_rect);

    // Paint the signal name
    p.setPen(enabled() ? Qt::black : dsDisable);
    p.drawText(name_rect, Qt::AlignLeft | Qt::AlignVCenter, _name);

    // Paint the trigButton
    paint_type_options(p, right, pt);

    // Paint the label
    if (enabled()) {
        const QPointF points[] = {
            label_rect.topLeft(),
            label_rect.topRight(),
            QPointF(right, get_zeroPos()),
            label_rect.bottomRight(),
            label_rect.bottomLeft()
        };

        p.setPen(Qt::transparent);
        if (_type == SR_CHANNEL_DSO)
            p.setBrush((label_rect.contains(pt) || selected()) ? _colour.darker() : _colour);
        else
            p.setBrush((label_rect.contains(pt) || selected()) ? dsYellow : dsBlue);
        p.drawPolygon(points, countof(points));

        p.setPen(QPen(Qt::blue, 1, Qt::DotLine));
        p.setBrush(Qt::transparent);
        p.drawLine(label_rect.right(), label_rect.top() + 3,
                    label_rect.right(), label_rect.bottom() - 3);

        // Paint the text
        p.setPen(Qt::white);
        if (_type == SR_CHANNEL_GROUP)
            p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, "G");
        else if (_type == SR_CHANNEL_ANALOG)
            p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, "A");
        else if (_type == SR_CHANNEL_DECODER)
            p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, "D");
        else
            p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, QString::number(_index_list.front()));
    }
}
Ejemplo n.º 30
0
void WorldPainter::paint(QPainter &p, QPolygon &polygon, double x, double y, double angle, double size) {
	auto transformations = QMatrix();
	transformations.rotate(angle);
	transformations.scale(size, size);

	auto trans_poly = transformations.map(polygon);
	trans_poly.translate(x, y);

	p.drawPolygon(trans_poly);
}