Exemplo n.º 1
1
void SerpinskiShape::drawShape(QPainter &painter, float cx, float cy, float radius) {
    if (radius < 3) return;

    float step = 2 * M_PI / _corners;
    float beginAngle = (-_rotateAngle - 90) * M_PI / 180;
    float endAngle = M_PI * ((float)(-_rotateAngle - 90) / 180 + 2);
    if (_corners == 4) {
        beginAngle += M_PI / 4;
        endAngle += M_PI / 4;
    }

    QVector<QPointF> vertices;
    for (float angle = beginAngle; angle < endAngle; angle += step) {
        vertices.push_back(QPointF(cos(angle) * radius, sin(angle) * radius));
    }
    vertices.push_back(vertices[0]);

    painter.save();
    painter.translate(cx, cy);
    painter.drawPolyline(QPolygonF(vertices));
    painter.restore();

    float nextRadius = 0;
    switch (_corners) {
    case 3:
        nextRadius = radius * 0.5;
        break;
    case 4:
    case 6:
        nextRadius = radius * 0.333;
        break;
    case 5:
        nextRadius = radius / 2.63;
        break;
    }

    float centerRaduis = radius - nextRadius;
    for (float angle = beginAngle; angle < endAngle; angle += step) {
        drawShape(painter,
                  cos(angle) * centerRaduis + cx,
                  sin(angle) * centerRaduis + cy,
                  nextRadius);
    }

    if (_corners != 4) return;

    float addRotate = M_PI / 4;
    beginAngle += addRotate;
    endAngle += addRotate;
    centerRaduis = radius * cos(addRotate) * 0.667;
    for (float angle = beginAngle; angle < endAngle; angle += step) {
        drawShape(painter,
                  cos(angle) * centerRaduis + cx,
                  sin(angle) * centerRaduis + cy,
                  nextRadius);
    }
}
Exemplo n.º 2
0
void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context )
{
  QPainter* p = context.renderContext().painter();
  if ( !p )
  {
    return;
  }

  double offset = 0.0;
  applyDataDefinedSymbology( context, mPen, mSelPen, offset );

  p->setPen( context.selected() ? mSelPen : mPen );

  // Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #2 points).
#if 0 // TODO[MD]: after merge
  if ( points.size() <= 2 && context.layer() && context.layer()->simplifyDrawingCanbeApplied( context.renderContext(), QgsVectorSimplifyMethod::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.layer()->simplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
  {
    p->setRenderHint( QPainter::Antialiasing, false );
    p->drawPolyline( points );
    p->setRenderHint( QPainter::Antialiasing, true );
    return;
  }
#endif

  if ( offset == 0 )
  {
    p->drawPolyline( points );
  }
  else
  {
    double scaledOffset = offset * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOffsetUnit );
    p->drawPolyline( ::offsetLine( points, scaledOffset ) );
  }
}
Exemplo n.º 3
0
void TraceGroup::paint_label(QPainter &p, const QRect &rect, bool hover)
{
	const QRectF r = label_rect(rect).adjusted(
		LineThickness / 2, LineThickness / 2,
		-LineThickness / 2, -LineThickness / 2);

	// Paint the label
	const QPointF points[] = {
		r.topRight(),
		r.topLeft(),
		r.bottomLeft(),
		r.bottomRight()
	};

	if (selected()) {
		const QPen pen(highlight_pen());
		p.setPen(QPen(pen.brush(), pen.width() + LineThickness,
			Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin));
		p.setBrush(Qt::transparent);
		p.drawPolyline(points, countof(points));
	}

	p.setPen(QPen(QBrush(LineColour.darker()), LineThickness,
		Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin));
	p.drawPolyline(points, countof(points));
	p.setPen(QPen(QBrush(hover ? LineColour.lighter() : LineColour),
		LineThickness - 2, Qt::SolidLine, Qt::SquareCap,
		Qt::RoundJoin));
	p.drawPolyline(points, countof(points));
}
void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context )
{
  QPainter* p = context.renderContext().painter();
  if ( !p )
  {
    return;
  }

  if ( context.renderHints() & QgsSymbolV2::DataDefinedSizeScale )
  {
    double scaledWidth = context.outputLineWidth( mWidth );
    mPen.setWidthF( scaledWidth );
    mSelPen.setWidthF( scaledWidth );
  }

  p->setPen( context.selected() ? mSelPen : mPen );
  if ( mOffset == 0 )
  {
    p->drawPolyline( points );
  }
  else
  {
    double scaledOffset = context.outputLineWidth( mOffset );
    p->drawPolyline( ::offsetLine( points, scaledOffset ) );
  }
}
Exemplo n.º 5
0
void ClusterView::eraseTheLastMovingLine(QColor polygonColor){
  //The user moved since the last left click, a line has been drawn in the mouseMoveEvent
  if(nbSelectionPoints != selectionPolygon.size()){
    //set existLastMovingLine to true to correctely erase the closed polygon
    existLastMovingLine = true;
    
    //Paint in the buffer to allow the selection to be redrawn after a refresh
    QPainter painter;
    painter.begin(&doublebuffer);
    //set the window (part of the word I want to show)
    QRect r((QRect)window);
    painter.setWindow(r.left(),r.top(),r.width()-1,r.height()-1);//hack because Qt QRect is used differently in this function
    painter.setRasterOp(XorROP);
    painter.setPen(polygonColor);
  
    //Treat the case when we reach the first point of the selection
    if(nbSelectionPoints == 1){
      //Erase the last line drawn (in mouseMoveEvent).
      painter.drawPolyline(selectionPolygon,selectionPolygon.size()-2);
    }
    else{
      //CAUTION, Do not remove this line otherwise strang dots will appear
      painter.drawPoint(selectionPolygon.point(selectionPolygon.size()-2));
      //Erase the last line drawn (in mouseMoveEvent)
      painter.drawPolyline(selectionPolygon,selectionPolygon.size()-2);
    }
    //Resize selectionPolygon to remove the last point
    //(the one set in mouseMoveEvent) from selectionPolygon
    selectionPolygon.resize(selectionPolygon.size()-1);

    nbSelectionPoints = selectionPolygon.size();  

    painter.end();
  }
}
Exemplo n.º 6
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void Graph::draw(QPainter &p) {
	QPolygonF poly;
	unproject(poly);

	p.setRenderHint(QPainter::Antialiasing, antiAliasing());

	if ( dropShadow() ) {
		p.translate(2,2);
		p.setPen(QPen(QColor(128,128,128,128), lineWidth()));
		p.drawPolyline(poly);
		p.translate(-2,-2);
	}

	p.setPen(pen());
	p.drawPolyline(poly);
}
Exemplo n.º 7
0
void AccumulateEnergy::DrawAccumulateEnergy(QPainter &painter)
{
    float y = draw_area_range.bottom() - dheight_ - 15;
    float x = draw_area_range.left();

    QPolygonF points;

    float accumulateenergydata = 0;
    float maxaccumulateenergy = maxaccumulateenergy_;
    if (maxaccumulateenergy == 0)
    {
       maxaccumulateenergy = 1;
    }

    for(int i = 0;i<datas_.size();i++)
    {
        EnergyData ei = datas_.value(i);
        accumulateenergydata += ei.energy;
        float xt =  x + i* draw_area_range.width() / days_;
        float yt =  y - accumulateenergydata*(uheight_ - 15) / maxaccumulateenergy;
        points.push_back(QPointF(xt,yt));

    }
    painter.save();
    QPen pen;
    pen.setColor(Qt::blue);
    painter.setPen(pen);
    painter.drawPolyline(points);
    painter.restore();
}
Exemplo n.º 8
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);

}
Exemplo n.º 9
0
void QtZigzag::draw(QPainter &painter) const {
    Point2D tl = Zigzag::center - Zigzag::size * 0.5;
    Point2D br = Zigzag::center + Zigzag::size * 0.5;
    Color p = getStyle().lineColor;
    Color f = getStyle().fillColor;
    if (isSelected()) f.alpha = 0.5;
    painter.setPen(QColor(p.red * 255, p.green * 255, p.blue * 255, p.alpha * 255));
    painter.setBrush(QBrush(QColor(f.red * 255, f.green * 255, f.blue * 255, f.alpha * 255)));

    float partLine = (br.x - tl.x) / (float)pointsAmount;

    QPointF *points = new QPointF[pointsAmount];

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

        points[i].setX(tl.x + i*partLine);

        if (i % 2) {
            points[i].setY(tl.y);
        } else {
            points[i].setY(br.y);
        }
    }

    painter.drawPolyline(points, pointsAmount);

    if(selected) {
        painter.setBrush(QBrush(QColor(255, 180, 120)));
        painter.drawEllipse(QPoint(tl.x, tl.y), 2, 2);
        painter.drawEllipse(QPoint(br.x, br.y), 2, 2);

    }
}
Exemplo n.º 10
0
void Plotter::drawCurves(QPainter& painter)
{
    noOfCurves = curveDataMap.count();
    QRect rect = this->printRect();
    double x=0,y=0;
    double width = rect.width() - 1;
    double height = rect.height() - 1;
    double yCount = maxY - minY;
    if(antiAliasing)
        painter.setRenderHints(QPainter::Antialiasing);
    painter.translate(Margin + 1,rect.bottom()-1);
    for(int i=0; i < noOfCurves ; i++)
    {
        QPolygonF polyline;
        QVector<double>* dataPtr = curveDataMap[i] ;
        for(int j = 0 ; j <= noOfPoints ; j++)
        {
            x = (width * j)/noOfPoints;
            y = (height * dataPtr->value(j))/yCount;
            polyline << QPoint(x,-y);
            //qDebug() << y;
        }
        qDebug() << x <<rect.right();
        painter.setPen(colorMap.value(i));
        painter.drawPolyline(polyline);

    }
}
Exemplo n.º 11
0
void AnalogSignal::paint_trace(QPainter &p,
	const boost::shared_ptr<pv::data::AnalogSnapshot> &snapshot,
	int y, int left, const int64_t start, const int64_t end,
	const double pixels_offset, const double samples_per_pixel)
{
	const int64_t sample_count = end - start;
    const int64_t channel_num = snapshot->get_channel_num();

    if (sample_count > 0) {
        const uint16_t *const samples = snapshot->get_samples(start, end);
        assert(samples);

        p.setPen(_colour);
        //p.setPen(QPen(_colour, 2, Qt::SolidLine));

        QPointF *points = new QPointF[sample_count];
        QPointF *point = points;

        for (int64_t sample = start; sample != end; sample++) {
            const float x = (sample / samples_per_pixel -
                pixels_offset) + left;
            *point++ = QPointF(x,
                               y - samples[(sample - start) * channel_num + get_index()] * _scale);
        }

        p.drawPolyline(points, point - points);

        //delete[] samples;
        delete[] points;
    }
}
Exemplo n.º 12
0
void GroupSignal::paint_trace(QPainter &p,
    const boost::shared_ptr<pv::data::GroupSnapshot> &snapshot,
	int y, int left, const int64_t start, const int64_t end,
	const double pixels_offset, const double samples_per_pixel)
{
	const int64_t sample_count = end - start;

    const uint16_t *samples = snapshot->get_samples(start, end);
	assert(samples);

	p.setPen(_colour);

	QPointF *points = new QPointF[sample_count];
	QPointF *point = points;

	for (int64_t sample = start; sample != end; sample++) {
		const float x = (sample / samples_per_pixel -
			pixels_offset) + left;
		*point++ = QPointF(x,
			y - samples[sample - start] * _scale);
	}

	p.drawPolyline(points, point - points);

	delete[] samples;
	delete[] points;
}
Exemplo n.º 13
0
void HoverPoints::paintPoints()
{
    QPainter qPainter;
    qPainter.begin( _colorMapWidget );

    // Set anti-aliasing.
    qPainter.setRenderHint( QPainter::Antialiasing );

    QPolygonF polygon;
    const auto& controlPoints = _colorMap.getControlPoints( _channel );

    const float w = _colorMapWidget->width();
    const float h = _colorMapWidget->height();

    for( size_t i = 0; i < controlPoints.size(); ++i )
    {
        polygon << QPointF( controlPoints[ i ].getX() / 256.0f * w,
                            ( 1.0f - controlPoints[ i ].getY()) * h );

    }

    qPainter.setPen( connectionPen );
    qPainter.drawPolyline( polygon );

    // Set the style.
    qPainter.setPen( pointPen );
    qPainter.setBrush( pointBrush );

    // After drawing the lines between the points, draw the points' shapes.
    for( const auto& pnt: polygon )
        qPainter.drawEllipse( pnt, controlPointSize, controlPointSize );
}
Exemplo n.º 14
0
void AnalogSignal::paint_trace(QPainter &p,
	const shared_ptr<pv::data::AnalogSegment> &segment,
	int y, int left, const int64_t start, const int64_t end,
	const double pixels_offset, const double samples_per_pixel)
{
	const int64_t sample_count = end - start;

	const float *const samples = segment->get_samples(start, end);
	assert(samples);

	p.setPen(colour_);

	QPointF *points = new QPointF[sample_count];
	QPointF *point = points;

	for (int64_t sample = start; sample != end; sample++) {
		const float x = (sample / samples_per_pixel -
			pixels_offset) + left;
		*point++ = QPointF(x,
			y - samples[sample - start] * scale_);
	}

	p.drawPolyline(points, point - points);

	delete[] samples;
	delete[] points;
}
Exemplo n.º 15
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);

}
Exemplo n.º 16
0
void FreeHand::draw( QPainter &painter ) const
{
    painter.save();
    painter.setPen(QPen(m_lineColor,m_lineWidth,Qt::SolidLine,Qt::RoundCap,Qt::RoundJoin));
    painter.drawPolyline(m_polygon);
    painter.restore();
}
Exemplo n.º 17
0
void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context )
{
  QPainter* p = context.renderContext().painter();
  if ( !p )
  {
    return;
  }

  double offset = 0.0;
  applyDataDefinedSymbology( context, mPen, mSelPen, offset );

  p->setPen( context.selected() ? mSelPen : mPen );

  // Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #2 points).
  if ( points.size() <= 2 && context.layer() && context.layer()->simplifyDrawingCanbeApplied( context.renderContext(), QgsVectorLayer::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.layer()->simplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
  {
    p->setRenderHint( QPainter::Antialiasing, false );
    p->drawPolyline( points );
    p->setRenderHint( QPainter::Antialiasing, true );
    return;
  }

  if ( mDrawInsidePolygon )
  {
    //only drawing the line on the interior of the polygon, so set clip path for painter
    p->save();
    QPainterPath clipPath;
    clipPath.addPolygon( points );
    p->setClipPath( clipPath, Qt::IntersectClip );
  }

  if ( offset == 0 )
  {
    p->drawPolyline( points );
  }
  else
  {
    double scaledOffset = offset * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOffsetUnit );
    p->drawPolyline( ::offsetLine( points, scaledOffset ) );
  }

  if ( mDrawInsidePolygon )
  {
    //restore painter to reset clip path
    p->restore();
  }
}
Exemplo n.º 18
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);
}
Exemplo n.º 19
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void SpectrumWidget::draw(QPainter &p, const Graph *g) {
	if ( g->isEmpty() || !g->isVisible() ) return;

	QPolygonF poly;
	g->unproject(poly);

	p.setRenderHint(QPainter::Antialiasing, g->antiAliasing());

	if ( g->dropShadow() ) {
		p.translate(2,2);
		p.setPen(QPen(QColor(128,128,128,128), g->lineWidth()));
		p.drawPolyline(poly);
		p.translate(-2,-2);
	}

	p.setPen(g->pen());
	p.drawPolyline(poly);
}
Exemplo n.º 20
0
void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context )
{
  QPainter* p = context.renderContext().painter();
  if ( !p )
  {
    return;
  }

  //size scaling by field
  if ( context.renderHints() & QgsSymbolV2::DataDefinedSizeScale )
  {
    applySizeScale( context, mPen, mSelPen );
  }

  double offset = mOffset;
  applyDataDefinedSymbology( context, mPen, mSelPen, offset );

  p->setPen( context.selected() ? mSelPen : mPen );

  // Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #2 points).
  if ( points.size() <= 2 &&
       ( context.renderContext().vectorSimplifyMethod().simplifyHints() & QgsVectorSimplifyMethod::AntialiasingSimplification ) &&
       QgsAbstractGeometrySimplifier::isGeneralizableByDeviceBoundingBox( points, context.renderContext().vectorSimplifyMethod().threshold() ) &&
       ( p->renderHints() & QPainter::Antialiasing ) )
  {
    p->setRenderHint( QPainter::Antialiasing, false );
    p->drawPolyline( points );
    p->setRenderHint( QPainter::Antialiasing, true );
    return;
  }

  if ( qgsDoubleNear( offset, 0 ) )
  {
    p->drawPolyline( points );
  }
  else
  {
    double scaledOffset = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), offset, mOffsetUnit, mOffsetMapUnitScale );
    QList<QPolygonF> mline = ::offsetLine( points, scaledOffset, context.feature() ? context.feature()->constGeometry()->type() : QGis::Line );
    for ( int part = 0; part < mline.count(); ++part )
      p->drawPolyline( mline[ part ] );
  }
}
Exemplo n.º 21
0
void QgsGrassEdit::displayElement( int line, const QPen & pen, int size, QPainter *painter )
{
  QgsDebugMsg( QString( "line = %1" ).arg( line ) );

  // is it a valid line?
  if ( line == 0 )
    return;

  if ( !mSymbDisplay[mLineSymb[line]] )
    return;

  int type = mProvider->readLine( mPoints, NULL, line );
  if ( type < 0 )
    return;

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

  if ( type & GV_POINTS )
  {
    displayIcon( mPoints->x[0], mPoints->y[0], pen, QgsVertexMarker::ICON_CROSS, size, myPainter );
  }
  else   // line
  {
    QgsPoint point;
    QPolygon pointArray( mPoints->n_points );

    for ( int i = 0; i < mPoints->n_points; i++ )
    {
      point.setX( mPoints->x[i] );
      point.setY( mPoints->y[i] );
      point = transformLayerToCanvas( point );
      pointArray.setPoint( i, qRound( point.x() ), qRound( point.y() ) );
    }

    myPainter->setPen( pen );
    myPainter->drawPolyline( pointArray );
  }

  if ( !painter )
  {
    myPainter->end();
    // porting mCanvas->update();
    mCanvasEdit->update();
    delete myPainter;
  }
}
Exemplo n.º 22
0
int drv_painter(int drvid, void *a0, void* a1, void* a2, void* a3, void* a4, void* a5, void* a6, void* a7, void* a8, void* a9)
{
    handle_head* head = (handle_head*)a0;
    QPainter *self = (QPainter*)head->native;
    switch (drvid) {
    case PAINTER_INIT: {
        drvNewHead(a0,new QPainter);
        break;
    }
    case PAINTER_DESTROY: {
        drvDelObj(a0,self);
        break;
    }
    case PAINTER_BEGIN: {
        self->begin(drvGetWidget(a1));
        break;
    }
    case PAINTER_END: {
        self->end();
        break;
    }
    case PAINTER_SETFONT: {
        self->setFont(drvGetFont(a1));
        break;
    }
    case PAINTER_FONT: {
        drvSetFont(a1,self->font());
        break;
    }
    case PAINTER_DRAWPOINT: {
        self->drawPoint(drvGetPoint(a1));
        break;
    }
    case PAINTER_DRAWLINE: {
        self->drawLine(drvGetPoint(a1),drvGetPoint(a2));
        break;
    }
    case PAINTER_DRAWLINES: {
        self->drawLines(drvGetPoints(a1));
        break;
    }
    case PAINTER_DRAWPOLYLINE: {
        self->drawPolyline(drvGetPoints(a1));
        break;
    }
    case PAINTER_DRAWTEXT: {
        self->drawText(drvGetPoint(a1),drvGetString(a2));
        break;
    }
    default:
        return 0;
    }
    return 1;
}
Exemplo n.º 23
0
void GeometryPainter::drawWay(QPainter& pt, const OsmMap* map, const Way* way, const QMatrix& m)
{
  int size = way->getNodeCount();
  QPolygonF a(size);

  for (int j = 0; j < size; j++)
  {
    ConstNodePtr n = map->getNode(way->getNodeId(j));
    a[j] = QPointF(m.map(QPointF(n->getX(), n->getY())) - QPointF(0.5, 0.5));
  }

  pt.drawPolyline(a);
}
Exemplo n.º 24
0
void Buffer::drawShape( QPainter &p )
{
	initPainter(p);
	int _x = (int)x()-8;
	int _y = (int)y()-8;
	Q3PointArray pa(3);
	pa[0] = QPoint( _x, _y );
	pa[1] = QPoint( _x+width(), _y+(height()/2) );
	pa[2] = QPoint( _x, _y+height() );
	p.drawPolygon(pa);
	p.drawPolyline(pa);
	deinitPainter(p);
}
Exemplo n.º 25
0
void CNItem::drawShape( QPainter &p )
{
	if (!isVisible())
		return;
	
// 	initPainter(p);
	if ( isSelected() )
		p.setPen(m_selectedCol);
	
	p.drawPolygon(areaPoints());
	p.drawPolyline(areaPoints());
// 	deinitPainter(p);
}
Exemplo n.º 26
0
void KexiArrowTip::drawFrame(QPainter& p)
{
	QPen pen(palette().active().foreground(), 1, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin);
	p.setPen( pen );
	/*
	   /\
	 +-  -----+
	 |  text  |
	 +--------+
	*/
	//1st line
	const int arrowOffset = 5; //5 pixels to right
	QPointArray pa(8);
	pa.setPoint(0, 0, m_arrowHeight-1);
	pa.setPoint(1, 0, height()-1);
	pa.setPoint(2, width()-1, height()-1);
	pa.setPoint(3, width()-1, m_arrowHeight-1);
	pa.setPoint(4, arrowOffset+m_arrowHeight+m_arrowHeight-2, m_arrowHeight-1);
	pa.setPoint(5, arrowOffset+m_arrowHeight-1, 0);
	pa.setPoint(6, arrowOffset, m_arrowHeight-1);
	pa.setPoint(7, 0, m_arrowHeight-1);
	p.drawPolyline(pa);
	//-2nd, internal line
	pa.resize(12);
	pa.setPoint(0, 1, m_arrowHeight);
	pa.setPoint(1, 1, height()-2);
	pa.setPoint(2, width()-2, height()-2);
	pa.setPoint(3, width()-2, m_arrowHeight);
	pa.setPoint(4, arrowOffset+m_arrowHeight+m_arrowHeight-2, m_arrowHeight);
	pa.setPoint(5, arrowOffset+m_arrowHeight-1, 1);
	pa.setPoint(6, arrowOffset, m_arrowHeight);
	pa.setPoint(7, 0, m_arrowHeight);
	pa.setPoint(8, arrowOffset+1, m_arrowHeight);
	pa.setPoint(9, arrowOffset+m_arrowHeight-1, 2);
	pa.setPoint(10, arrowOffset+m_arrowHeight+m_arrowHeight-3, m_arrowHeight);
	pa.setPoint(11, width()-2, m_arrowHeight);
	p.drawPolyline(pa);
}
Exemplo n.º 27
0
void HoverPoints::paintPoints()
{
    QPainter qPainter;
    qPainter.begin( _tfWidget );

    // Set anti-aliasing.
    qPainter.setRenderHint( QPainter::Antialiasing );

    // Make sure that styles and connection type are defined.
    if( _connectionPen.style() != Qt::NoPen && _connectionType != NO_CONNECTION )
    {
        qPainter.setPen( _connectionPen );

        // Connect the points using smoothed curves.
        if( _connectionType == CURVE_CONNECTION )
        {
            QPainterPath path;
            path.moveTo( _tfPoints.at( 0 ));
            for( int32_t i = 1; i < _tfPoints.size(); ++i )
            {
                const QPointF& p1 = _tfPoints.at( i - 1 );
                const QPointF& p2 = _tfPoints.at( i );
                const qreal distance = p2.x() - p1.x();

                path.cubicTo( p1.x() + distance / 2, p1.y(),
                              p1.x() + distance / 2, p2.y(),
                              p2.x(), p2.y());
            }

            qPainter.drawPath( path );
        }
        // Connect the points using piece-wise lines.
        else
            qPainter.drawPolyline( _tfPoints );
    }

    // Set the style.
    qPainter.setPen( _pointPen );
    qPainter.setBrush( _pointBrush );

    // After drawinf the lines between the points, draw the points' shapes.
    for( int32_t i = 0; i < _tfPoints.size(); ++i )
    {
        const QRectF& bounds = _pointBoundingRectangle( i );
        if( _pointShape == CIRCLE_POINT )
            qPainter.drawEllipse( bounds );
        else
            qPainter.drawRect( bounds );
    }
}
Exemplo n.º 28
0
void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context )
{
  QPainter* p = context.renderContext().painter();
  if ( !p )
  {
    return;
  }

  double offset = 0.0;
  applyDataDefinedSymbology( context, mPen, mSelPen, offset );

  p->setPen( context.selected() ? mSelPen : mPen );

  if ( offset == 0 )
  {
    p->drawPolyline( points );
  }
  else
  {
    double scaledOffset = offset * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOffsetUnit );
    p->drawPolyline( ::offsetLine( points, scaledOffset ) );
  }
}
Exemplo n.º 29
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 );
}
Exemplo n.º 30
0
void GeometryPainter::drawLineString(QPainter& pt, const OGRLineString* lineString,
  const QMatrix& m)
{
  QPolygonF a(lineString->getNumPoints());

  OGRPoint point;
  for (int j = 0; j < lineString->getNumPoints(); j++)
  {
    lineString->getPoint(j, &point);
    a[j] = QPointF(m.map(QPointF(point.getX(), point.getY())) - QPointF(0.5, 0.5));
  }

  pt.drawPolyline(a);
}