Ejemplo n.º 1
0
void QamTachymeter::drawForeground(QPainter& painter )
{
	float len ;						// longueur de l'aiguille orientée 0X+
	QVector<QPointF> pts ;			// points de construction dans demi-plan 0Y+
	QColor white(230,230,230) ;		// couleur de la pointe

	// aiguille "Rotor"

	len = 0.95 * m_radius[ROTOR] ;
	pts.clear() ;
	pts << QPointF( 0, 15 ) << QPointF( len - 60, 15 ) << QPointF( len, 0 ) ;
	
	painter.save() ;
	painter.rotate(m_start[ROTOR] + m_step[ROTOR] * ( value(ROTOR) / 10 ) ) ;
	qfiNeedle(painter, white, pts, 30, 0, 0.4 * len ) ;
	painter.restore() ;
	
	// aiguille "Turbine" (transparente)

	len = 0.8 * m_radius[TURBINE] ;
	pts.clear() ;
	pts << QPointF( -0.4 * m_radius[TURBINE], 20 ) << QPointF( len - 80, 20 ) << QPointF( len, 0 ) ;
	
	painter.save() ;
	painter.rotate(m_start[TURBINE] + m_step[TURBINE] * ( value(TURBINE) / 1000 ) ) ;
	qfiNeedle(painter, QColor(200, 200, 200, 120 ), pts, 40, 80 ) ;
	painter.restore() ;
	
	// axe central

	qfiAxis(painter, 30 ) ;
}
Ejemplo n.º 2
0
static void drawRotatedText (QPainter &p, int x, int y, float angle, const QString text) {
  p.translate(x, y);
  p.rotate(angle);
  p.drawText(0, 0, text);
  p.rotate(-1*angle);
  p.translate(-1*x, -1*y);
}
Ejemplo n.º 3
0
static void drawRotatedText (QPainter &p, int x, int y, int width, int height, float angle, const QString text) {
  p.translate(x, y);
  p.rotate(angle);
  p.drawText(QRectF(0,0,width,height),text,QTextOption(Qt::AlignHCenter));
  p.rotate(-1*angle);
  p.translate(-1*x, -1*y);
}
Ejemplo n.º 4
0
void PicItem::drawShape( QPainter & p )
{
	int _x = int(x());
	int _y = int(y());
	
	p.setBrush( QColor( 0xef, 0xff, 0xef ) );
	p.setFont( font() );
	
	p.drawRoundRect( _x, _y, width(), height(), 2000/width(), 2000/height() );
	
	p.drawText( _x+TopPadding-2, _y, width()-TopPadding+2, TopPadding, Qt::AlignVCenter, i18n("PIC Settings") );
	
	if ( !m_bExpanded )
		return;
	
	// Draw rectangle to cut off pins
	p.setBrush( QColor( 239, 255, 255 ) );
	QRect r( _x+SidePadding, _y+TopPadding, InnerWidth, m_innerHeight );
	p.drawRect(r);
	
	// Draw dimple thingy at end of pic
	p.drawArc( r.x()+(r.width()-ArcWidth)/2, r.y()+1-ArcWidth/2, ArcWidth, ArcWidth, 180*16, 180*16 );
	
	// Draw vertical text centered in PIC
	p.translate( r.width()/2 + r.x(), r.height()/2 + r.y() );
	p.rotate(90);
	QRect textRect( r.width()/-2, r.height()/-2, r.width(), r.height() );
	p.drawText( textRect, Qt::AlignCenter, microSettings->microInfo()->id() );
	
	p.rotate(-90);
	p.translate( r.width()/-2 - r.x(), r.height()/-2 - r.y() );
}
void MaxFlowVisualizer::drawEdge(const Edge &edge, QPainter &painter) const {
    QPen pen;
    pen.setWidth(3);
    // Ребро, которое считается "допустимым" по алгоритму, выделяем черным.
    if (relabelToFrontAlgo.getVertexHeight(edge.getFirstVertexIndex())
        == relabelToFrontAlgo.getVertexHeight(edge.getSecondVertexIndex()) + 1) {
        pen.setColor(Qt::black);
    }
    else {
        pen.setColor(Qt::gray);
    }
    if (edge.getFlow() != 0) {
        pen.setColor(Qt::darkBlue);
    }
    // Если в последнем действии алгоритма произошло проталкивание по этому ребру,
    // то выделим его красным.
    if (lastAlgoAction.getType() == AlgoAction::ACTION_PUSH && lastAlgoAction.getEdgeInfo() == edge) {
        pen.setColor(Qt::red);
    }
    painter.setPen(pen);
    QPoint pointFrom(verteciesList[edge.getFirstVertexIndex()].getCenterCoordX(),
                     verteciesList[edge.getFirstVertexIndex()].getCenterCoordY());
    QPoint pointTo(verteciesList[edge.getSecondVertexIndex()].getCenterCoordX(),
                   verteciesList[edge.getSecondVertexIndex()].getCenterCoordY());
    double length = sqrt(pow(pointFrom.x() - pointTo.x(), 2)
                         + pow(pointFrom.y() - pointTo.y(), 2));
    long vertexRaduis = verteciesList[edge.getSecondVertexIndex()].getRadius();
    QPoint offsetVector((pointFrom.x() - pointTo.x()) * vertexRaduis / length,
                        (pointFrom.y() - pointTo.y()) * vertexRaduis / length);
    QPoint arrow((pointFrom.x() - pointTo.x()) * 20 / length,
                 (pointFrom.y() - pointTo.y()) * 20 / length);
    // Рисование стрелки (самих маленьких боковых линий).
    // Перенесем систему координат в точку конца ребра (ориенированного).
    // Возьмем маленький отрезок ребра, и нарисуем его, повернув при этом систуму координат
    // на +30 и -30 градусов соответственно относительно исходного ребра.
    // Получилась стрелка ->
    // После этого восстановим систему координат.
    painter.setPen(pen);
    painter.drawLine(pointFrom, pointTo);
    painter.translate(pointTo.x(), pointTo.y());
    // Еще нужно отступить от конца ребра на радиус вершины
    // (т.к. ребро идет от центра к центру).
    painter.translate(offsetVector.x(), offsetVector.y());
    painter.rotate(30);
    painter.drawLine(QPoint(0, 0), arrow);
    painter.rotate(-60);
    painter.drawLine(QPoint(0, 0), arrow);
    painter.resetTransform();
    // Выводим информацию о ребре (flow | capacity) по середине ребра.
    if (state == ALGORITHM_RUN || (state == ALGORITHM_TERM && edge.flow != 0)) {
        QPen penForEdgeInfo;
        penForEdgeInfo.setColor(Qt::darkGreen);
        painter.setPen(penForEdgeInfo);
        std::string edgeInfo = "(" + std::to_string(edge.getFlow()) + " | " + std::to_string(edge.getCapacity()) + ")";
        painter.drawText(pointFrom.x() + (pointTo.x() - pointFrom.x()) / 2,
                         pointFrom.y() + (pointTo.y() - pointFrom.y()) / 2,
                         edgeInfo.c_str());
    }
}
Ejemplo n.º 6
0
void dslDial::paint(QPainter &p, QRectF dialRect, QColor dialColor, bool hover, bool inc)
{
    p.setRenderHint(QPainter::Antialiasing, true);
    p.setPen(dialColor);
    p.setBrush(dialColor);

    int dialStartAngle = 225 * 16;
    int dialSpanAngle = -270 * 16;

    // draw dial arc
    p.drawArc(dialRect, dialStartAngle, dialSpanAngle);
    // draw ticks
    p.save();
    p.translate(dialRect.center());
    p.rotate(45);
    for (uint64_t i = 0; i < _div; i++) {
        // draw major ticks
        p.drawLine(0, dialRect.width()/2+3, 0, dialRect.width()/2+8);
        // draw minor ticks
        for (uint64_t j = 0; (j < 5) && (i < _div - 1); j++) {
            p.drawLine(0, dialRect.width()/2+3, 0, dialRect.width()/2+5);
            p.rotate(54.0/(_div-1));
        }
    }
    // draw pointer
    p.rotate(90+270.0/(_div-1)*_sel);
    p.drawEllipse(-3, -3, 6, 6);
    p.drawLine(3, 0, 0, dialRect.width()/2-3);
    p.drawLine(-3, 0, 0, dialRect.width()/2-3);
    p.restore();
    // draw value
    uint64_t displayValue = _value[_sel]*_factor;
    uint64_t displayIndex = 0;
    while(displayValue / _step >= 1) {
        displayValue = displayValue / _step;
        displayIndex++;
    }
    QString pText = QString::number(displayValue) + _unit[displayIndex] + "/div";
    QFontMetrics fm(p.font());
    const QRectF valueRect = QRectF(dialRect.left(), dialRect.bottom()-dialRect.width()*0.3+fm.height()*0.5, dialRect.width(), fm.height());
    p.drawText(valueRect, Qt::AlignCenter, pText);

    // draw +/-
    if (hover) {
        const int arcInc = 15;
        const QRectF hoverRect = QRectF(dialRect.left()-arcInc, dialRect.top()-arcInc, dialRect.width()+arcInc*2, dialRect.height()+arcInc*2);
        const double arcSpan = hoverRect.width()/(2*sqrt(2));
        p.drawArc(hoverRect, 135 * 16, -90 * 16);
        if (inc)
            p.drawLine(hoverRect.center().x()+arcSpan, hoverRect.center().y()-arcSpan,
                       hoverRect.center().x()+arcSpan-4, hoverRect.center().y()-arcSpan-10);
        else
            p.drawLine(hoverRect.center().x()-arcSpan, hoverRect.center().y()-arcSpan,
                       hoverRect.center().x()-arcSpan+4, hoverRect.center().y()-arcSpan-10);
    }
}
Ejemplo n.º 7
0
void KisColorSelector::drawOutline(QPainter& painter, const QRect& rect)
{
    painter.setRenderHint(QPainter::Antialiasing, true);
    painter.resetTransform();
    painter.translate(rect.x() + rect.width()/2, rect.y() + rect.height()/2);
    painter.scale(rect.width()/2, rect.height()/2);
    painter.setPen(QPen(QBrush(Qt::gray), 0.005));
    
    if (getNumPieces() > 1) {
        for(int i=0; i<getNumRings(); ++i) {
            painter.resetTransform();
            painter.translate(rect.x() + rect.width()/2, rect.y() + rect.height()/2);
            painter.scale(rect.width()/2, rect.height()/2);
            painter.rotate(-m_colorRings[i].getShift().degrees());
            
            for(int j=0; j<m_colorRings[i].pieced.size(); ++j)
                painter.drawPath(m_colorRings[i].pieced[j]);
        }
        
        if (m_selectedRing >= 0 && m_selectedPiece >= 0) {
            painter.resetTransform();
            painter.translate(rect.x() + rect.width()/2, rect.y() + rect.height()/2);
            painter.rotate(-m_colorRings[m_selectedRing].getShift().degrees());
            painter.scale(rect.width()/2, rect.height()/2);
            
            painter.setPen(QPen(QBrush(Qt::red), 0.01));
            painter.drawPath(m_colorRings[m_selectedRing].pieced[m_selectedPiece]);
        }
    }
    else {
        for(int i=0; i<getNumRings(); ++i) {
            qreal rad = m_colorRings[i].outerRadius;
            painter.drawEllipse(QRectF(-rad, -rad, rad*2.0, rad*2.0));
        }
    }
    
    if (m_selectedRing >= 0) {
        qreal iRad = m_colorRings[m_selectedRing].innerRadius;
        qreal oRad = m_colorRings[m_selectedRing].outerRadius;
        
        painter.setPen(QPen(QBrush(Qt::red), 0.005));
        painter.drawEllipse(QRectF(-iRad, -iRad, iRad*2.0, iRad*2.0));
        painter.drawEllipse(QRectF(-oRad, -oRad, oRad*2.0, oRad*2.0));
        
        if (getNumPieces() <= 1) {
            float c = std::cos(-m_selectedColor.getH() * PI2);
            float s = std::sin(-m_selectedColor.getH() * PI2);
            painter.drawLine(QPointF(c*iRad, s*iRad), QPointF(c*oRad, s*oRad));
        }
    }
}
Ejemplo n.º 8
0
void QgsFontMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context )
{
  QPainter *p = context.renderContext().painter();
  if ( !p )
    return;

  QColor penColor = context.selected() ? context.renderContext().selectionColor() : mColor;
  penColor.setAlphaF( mColor.alphaF() * context.alpha() );
  p->setPen( penColor );
  p->setFont( mFont );

  p->save();
  //offset
  double offsetX = 0;
  double offsetY = 0;
  markerOffset( context, offsetX, offsetY );
  QPointF outputOffset( offsetX, offsetY );
  if ( mAngle )
    outputOffset = _rotatedOffset( outputOffset, mAngle );
  p->translate( point + outputOffset );

  if ( context.renderHints() & QgsSymbolV2::DataDefinedSizeScale )
  {
    double s = mSize / mOrigSize;
    p->scale( s, s );
  }

  if ( mAngle != 0 )
    p->rotate( mAngle );

  p->drawText( -mChrOffset, mChr );
  p->restore();
}
Ejemplo n.º 9
0
void RenderArea::transformPainter(QPainter &painter)
{
    for (int i = 0; i < operations.size(); ++i)
    {
        switch (operations[i])
        {
        case mover:
            painter.translate(20.0, 20.0);
            break;
        case Crecer:
            painter.scale(1.5, 1.5);
            break;
        case Decrecer:
            painter.scale(0.5, 0.5);
            break;
        case Rotar:
            painter.rotate(125);
            break;
            /*Al decrecerlo, se gira en el eje x-z en un sistema tridimensional imaginario, 
              pero también se podría hacer desde una matriz.*/
        case MirrorXAxis:
            painter.scale(1,-1);
            break;
        case MirrorYAxis:
            painter.scale(-1,1);
            break;
        case MirrorDouble:
            painter.scale(-1,-1);
            break;
        case Default:
        default:
            ;
        }
    }
}
Ejemplo n.º 10
0
//-----------------------------------------------------------------------------
//! 
//-----------------------------------------------------------------------------
void tBoatWidget::DrawThrusterIcon( QPainter& painter, int yPos )
{
    painter.save();

    QColor thrusterColor = tSystemSettings::Instance()->NightMode() ? Qt::darkGray : Qt::black;

    int w_2 = width()/2;
    painter.translate( QPointF(w_2, yPos) );

    painter.setRenderHint(QPainter::Antialiasing, false);
    painter.setPen( QPen(thrusterColor, 1) );
    painter.drawLine(-5,0,5,0);
    painter.drawLine(0,-5,0,5);
    painter.setRenderHint(QPainter::Antialiasing, true);

    
    for(int i=0;i<4;i++)
    {
        painter.save();
        painter.translate(QPointF(0.5, 0.5));
        painter.rotate(i*90);
        QPainterPath p1;
        p1.lineTo( QPointF( -4.5, -13 ) );
        p1.lineTo( QPointF( 4.5, -13 ) );
        painter.fillPath( p1, thrusterColor );
        painter.restore();
    }
        
    painter.setPen( QPen(thrusterColor, 3.5) );
    painter.drawEllipse(QPointF(0.5,0.5),13.0, 13.0);
    painter.restore();
}
Ejemplo n.º 11
0
void KPaintShape::setShapePainter(QPainter &painter, QPointF &centralPoint, float angle, bool bScale)
{
	if (angle >= g_cfNearZero || angle <= -g_cfNearZero)
	{
		if (bScale)
		{
			//painter.translate(m_pointOldShapeCenterPoint);
		}
		else
		{
			painter.translate(centralPoint);
		}
		
		painter.rotate(angle);

		if (bScale)
		{
			//painter.translate(-m_pointOldShapeCenterPoint);
		}
		else
		{
			painter.translate(-centralPoint);
		}
	}
}
Ejemplo n.º 12
0
void CMeter2DGraphView::UpdateValueAxisTitle()
{
   TRACE_FUN( Frequently, "CMeter2DGraphView::UpdateValueAxisTitle" );
   
   QString valueAxisTitle( QString::fromUtf8( model()->valueAxisTitle().c_str() ) );
   QRect valueAxisTitleRect( QFontMetrics( _boldFont ).boundingRect( 0, 0, _meshArea.height(), 0, Qt::AlignCenter | Qt::TextWordWrap,
                                                                     valueAxisTitle ) );

   _meshArea.setLeft( 0 );
   _meshArea.adjust( valueAxisTitleRect.height(), 0, 0, 0 );
   
   SRaster& raster( _rasterContainer[ CMeter2DGraphView::rtValueAxisTitle ] );
   
   raster._x = _meshArea.x() - valueAxisTitleRect.height();
   raster._y = _meshArea.y() + _meshArea.height() / 2 + valueAxisTitleRect.width() / 2;
   raster._image = QImage( valueAxisTitleRect.height(), valueAxisTitleRect.width(), QImage::Format_ARGB32 );
   
   QPainter painter;
   
   InitializeRasterRenderer( painter, raster._image );
   
   painter.setFont( _boldFont );
   
   painter.rotate( -90 );

   painter.drawText( -valueAxisTitleRect.width(), 0,
                     valueAxisTitleRect.width(), valueAxisTitleRect.height(),
                     Qt::AlignCenter | Qt::TextWordWrap, valueAxisTitle );
}
Ejemplo n.º 13
0
void Needle::Draw(
	QPainter& P, 		//! The painter object
	qreal fAngleDeg 	//! Needle angle given in degrees.
)
{
	P.save();
	
	P.rotate(-fAngleDeg);
	if(m_eType != tPlain && m_eType != tPlainLabel) {
		bool bActive = P.testRenderHint(QPainter::SmoothPixmapTransform);
		if(!bActive)
			P.setRenderHint(QPainter::SmoothPixmapTransform, true);
		P.drawPixmap(QPointF(0.0,-m_size.height()/2.0), m_px);
		if(!bActive)
			P.setRenderHint(QPainter::SmoothPixmapTransform, false);
	}
	else {
		P.setPen(QPen(Qt::white, m_size.height()));
		P.drawLine(m_iOffset, 0, m_size.width(), 0);
	}
	if(m_eType == tPlainLabel) {
		qreal fH = 9;
		P.setPen(QPen(Qt::white, 2));
		P.drawEllipse(0.5*m_size.width()-fH/2, -fH/2, fH,fH);
	}

	P.restore();
}
void RenderArea::transformPainter(QPainter &painter)
{
    for (int i = 0; i < operations.size(); ++i)
    {
        switch (operations[i])
        {
        case Translate:
            painter.translate(20.0, 20.0);
            break;
        case ZoomIn:
            painter.scale(1.5, 1.5);
            break;
        case ZoomOut:
            painter.scale(0.5, 0.5);
            break;
        case Rotate:
            painter.rotate(125);
            break;
        case ReflectionX:
            painter.scale(1,-1);
            break;
        case ReflectionY:
            painter.scale(-1,1);
            break;
        case Reflection:
            painter.scale(-1,-1);
            break;
        case NoTransformation:
        default:
            ;
        }
    }
}
Ejemplo n.º 15
0
//***************************************************************************
void Kwave::ScaleWidget::paintEvent(QPaintEvent *)
{
    bool inverse = false;
    int h = height();
    int w = width();
    QPainter p;

    p.begin(this);
    p.save();
    p.setPen(palette().light().color());

    p.drawLine(0, 0, w, 0);
    if (h > w) {
	p.setWindow(-w, 0, w, h);
	p.rotate(-90);
	h = width();
	w = height();

	inverse = true;
    }

    (m_logmode) ? drawLog(p, w, h, inverse) : drawLinear(p, w, h, inverse);

    p.restore();
    p.end();
}
Ejemplo n.º 16
0
void Interface::setRotate( int r)
{
     if (r < 360) {              /* -360   - 360  */
      rotazione = r;
                /////QPixmap base(origImageFilename);
                 QImage base(origImageFilename);
                int massimo = QMAX(base.width(),base.height());    /* find  max cube from image */
                int fotox = (massimo / 2) - (base.width() / 2);
                int fotoy = (massimo / 2) - (base.height() / 2);
                QPixmap nuovo(massimo,massimo);
                QPainter painter;
                painter.begin(&nuovo); 
                painter.setRenderHint(QPainter::Antialiasing);
                painter.translate((massimo / 2),(massimo / 2));
                painter.rotate(r); 
                painter.translate(-(massimo / 2),-(massimo / 2)); 
                /////painter.drawPixmap(fotox,fotoy,base);
                painter.drawImage(fotox,fotoy,base,Qt::MonoOnly);
                painter.end();  
                int newlarge = (massimo/cento)*ratio;
                display = nuovo.scaledToWidth(newlarge,Qt::FastTransformation);
                original = nuovo;
                
                wrapper->paint(display);
                ////////SetZoom( ratio );
                airotato = true;
     }
}
Ejemplo n.º 17
0
void t_libraryEditor::drawText(QPainter &painter, const someTextClass &text)
{
    painter.save();

    painter.setFont(text.font);

    QFontMetrics fm(text.font);
    int16_t fmW, fmH;
    fmW = fm.width(QString::fromStdString(text.theText));
    fmH = fm.height();

    painter.translate(text.posX, text.posY);
    if(text.direction)
        painter.rotate(text.direction);

    QPen dotPen;
    dotPen.setWidth(4);
    dotPen.setStyle(Qt::SolidLine);
    dotPen.setColor(g_color);
    painter.setPen(dotPen);

    painter.setBackground(QBrush(QColor(0,0,0,0)));

    painter.drawText(0, 0, QString::fromStdString(text.theText));
    painter.restore();
}
Ejemplo n.º 18
0
void TextRenderable::render(QPainter &painter, const RenderConfig &config) const
{
	painter.save();
	
	bool disable_antialiasing = config.options.testFlag(RenderConfig::Screen) && !(Settings::getInstance().getSettingCached(Settings::MapDisplay_TextAntialiasing).toBool());
	if (disable_antialiasing)
	{
		painter.setRenderHint(QPainter::Antialiasing, false);
		painter.setRenderHint(QPainter::TextAntialiasing, false);
	}
	
	if (framing_line)
	{
		QPen pen(painter.pen());
		pen.setJoinStyle(Qt::MiterJoin);
		pen.setMiterLimit(0.5);
		painter.setPen(pen);
	}
	
	painter.translate(anchor_x, anchor_y);
	if (rotation != 0)
		painter.rotate(-rotation * 180 / M_PI);
	painter.scale(scale_factor, scale_factor);
	painter.drawPath(path);
	
	painter.restore();
}
Ejemplo n.º 19
0
void GEAirport::draw(QPainter& painter)
{
    painter.save();

    QPointF center_xy;
    MYASSERT(m_projection->convertLatLonToXY(m_airport->getLatLon(), center_xy));
    painter.translate(center_xy.x(), center_xy.y());

    QPen pen(m_active_color);
    pen.setWidthF(APT_CIRCLE_WIDTH);
    painter.setPen(pen);

    // circle
    QRectF rect(-APT_CIRCLE_RADIUS, -APT_CIRCLE_RADIUS, 2*APT_CIRCLE_RADIUS, 2*APT_CIRCLE_RADIUS);
    painter.drawArc(rect, 0, FULL_ARC);

    // crown

    pen.setWidthF(APT_CIRCLE_CROWN_WIDTH);
    painter.setPen(pen);
    
    QLineF line(0, APT_CIRCLE_RADIUS, 0, APT_CIRCLE_RADIUS + APT_CIRCLE_CROWN_HEIGHT);
    int max_rotation = 6;
    for(int rotation=1; rotation<=max_rotation; ++rotation)
    {
        painter.rotate(360/(double)max_rotation);
        painter.drawLine(line);
    }

    painter.restore();
}
Ejemplo n.º 20
0
void DynamicGoo::paintDebug(QPainter &p){

    //set the pen green if is jointed or white if is free and not sleeping
    p.setPen( Qt::white);
    //if has joint draw the number of joint of it inside him.
    if (hasJoint()){
        target=NULL;
        prevTarget=NULL;
        p.drawText(QPoint(getPPosition().x()-5,getPPosition().y()+5),QString::number(this->nJoints()));
    }
    //if not and is free and is mooving to reach a target draw the direction
    else if (target!=NULL){
        if (prevTarget==NULL){
            p.setBrush(Qt::darkYellow);
            p.drawEllipse(getPPosition(),radius,radius);
        }
        else {
            p.setBrush(Qt::darkGreen);
            p.drawEllipse(getPPosition(),radius,radius);
        }

    }
    if (body->GetLinearVelocity().Length()){
        //save the position
        p.save();
        //translate the painter at the center of the goo
        p.translate(getPPosition());
        //rotate the painter of the angle between the goo and his target
        p.rotate(atan2(body->GetLinearVelocity().y,body->GetLinearVelocity().x)*180.0/3.141628);
        //draw a line in this direction of 40 px
        p.drawLine(0,0,body->GetLinearVelocity().Length(),0);

        //translate the painter at the end of the line
        p.translate(body->GetLinearVelocity().Length(),0);
        //rotatate of 45° degree
        p.rotate(45);
        //draw a line of 5 (this is one side of the arrow)
        p.drawLine(0,0,-5,0);
        //rotate to -45° degree
        p.rotate(270);
        //draw the other side of the arrow
        p.drawLine(0,0,-5,0);
        //restore the previous position

        p.restore();
    }
}
Ejemplo n.º 21
0
/**
 * Paint page to widget
 */
void EyeDrawWidget::paintEvent ( QPaintEvent* event )
{
	QPainter painter ( this );

	//painter.translate ( QPointF ( rect().width(), rect().height() ) / 2.0 ); //test
	painter.translate ( QPoint ( rect().width(), rect().height() ) / 2 );
	painter.rotate ( rotation );
	matrix = painter.worldMatrix().inverted();

	QRect  tmpRect = matrix.mapRect ( rect() );

	if ( img )
	{
		if ( srcRect.isNull() )
		{
			srcRect = tmpRect;
			srcRect.moveTo ( QPoint ( 0, 0 ) );
		}

		QPoint tmpPoint = srcRect.center();
		srcRect = tmpRect;
		srcRect.moveCenter ( tmpPoint );

		dstRect = tmpRect;
		dstRect.moveCenter ( QPoint ( 0, 0 ) );

		if ( zoom != oldZoom )
		{
			float zoomRatio = zoom / ( float ) oldZoom;
			oldZoom = zoom;
			tmpPoint *= zoomRatio;
			srcRect.moveCenter ( tmpPoint );
			delta = QPoint ( 0, 0 );
		}

		srcRect.moveCenter ( srcRect.center() + delta );

		if ( srcRect.left() < 0 ) srcRect.moveLeft ( 0 );
		if ( srcRect.top () < 0 ) srcRect.moveTop ( 0 );
		QSize pageSize = img->rect().size();
		if ( srcRect.right () + 1 > pageSize.width () ) srcRect.moveRight ( pageSize.width () - 1 );
		if ( srcRect.bottom() + 1 > pageSize.height() ) srcRect.moveBottom ( pageSize.height() - 1 );

		QRect rct = img->rect();
		srcRect = srcRect.intersected ( rct );
		rct.moveCenter ( QPoint ( 0, 0 ) );
		dstRect = dstRect.intersected ( rct );

		painter.drawImage ( dstRect, *img, srcRect );
		emit paintOSD ( painter, tmpRect.size() );
		painter.end();
		return;
	}

	if ( !message.isEmpty() )
		painter.drawText ( tmpRect, Qt::AlignCenter, message );

	emit paintOSD ( painter, tmpRect.size() );
}
void QgsDecorationNorthArrowDialog::rotatePixmap( int theRotationInt )
{
  QPixmap myQPixmap;
  QString myFileNameQString = ":/images/north_arrows/default.png";
// QgsDebugMsg(QString("Trying to load %1").arg(myFileNameQString));
  if ( myQPixmap.load( myFileNameQString ) )
  {
    QPixmap  myPainterPixmap( myQPixmap.height(), myQPixmap.width() );
    myPainterPixmap.fill();
    QPainter myQPainter;
    myQPainter.begin( &myPainterPixmap );

    myQPainter.setRenderHint( QPainter::SmoothPixmapTransform );

    double centerXDouble = myQPixmap.width() / 2.0;
    double centerYDouble = myQPixmap.height() / 2.0;
    //save the current canvas rotation
    myQPainter.save();
    //myQPainter.translate( (int)centerXDouble, (int)centerYDouble );

    //rotate the canvas
    myQPainter.rotate( theRotationInt );
    //work out how to shift the image so that it appears in the center of the canvas
    //(x cos a + y sin a - x, -x sin a + y cos a - y)
    const double PI = 3.14159265358979323846;
    double myRadiansDouble = ( PI / 180 ) * theRotationInt;
    int xShift = static_cast<int>((
                                    ( centerXDouble * cos( myRadiansDouble ) ) +
                                    ( centerYDouble * sin( myRadiansDouble ) )
                                  ) - centerXDouble );
    int yShift = static_cast<int>((
                                    ( -centerXDouble * sin( myRadiansDouble ) ) +
                                    ( centerYDouble * cos( myRadiansDouble ) )
                                  ) - centerYDouble );

    //draw the pixmap in the proper position
    myQPainter.drawPixmap( xShift, yShift, myQPixmap );

    //unrotate the canvas again
    myQPainter.restore();
    myQPainter.end();

    pixmapLabel->setPixmap( myPainterPixmap );
  }
  else
  {
    QPixmap  myPainterPixmap( 200, 200 );
    myPainterPixmap.fill();
    QPainter myQPainter;
    myQPainter.begin( &myPainterPixmap );
    QFont myQFont( "time", 12, QFont::Bold );
    myQPainter.setFont( myQFont );
    myQPainter.setPen( Qt::red );
    myQPainter.drawText( 10, 20, tr( "Pixmap not found" ) );
    myQPainter.end();
    pixmapLabel->setPixmap( myPainterPixmap );
  }
}
Ejemplo n.º 23
0
void GuiPart::deinitPainter( QPainter &p )
{
	if ( (m_angleDegrees%180) == 0 )
		return;
	
	p.translate( int(x()+(width()/2)), int(y()+(height()/2)) );
	p.rotate(-m_angleDegrees);
	p.translate( -int(x()+(width()/2)), -int(y()+(height()/2)) );
}
Ejemplo n.º 24
0
void GEVor::draw(QPainter& painter)
{
    painter.save();

    painter.setPen(QPen(m_active_color));
    
    QPointF center_xy;
    MYASSERT(m_projection->convertLatLonToXY(m_vor->getLatLon(), center_xy));
    painter.translate(center_xy.x(), center_xy.y());

    // outer circle
    QRectF rect(-VOR_OUTER_RADIUS, -VOR_OUTER_RADIUS, 2*VOR_OUTER_RADIUS, 2*VOR_OUTER_RADIUS);
    painter.drawArc(rect, 0, FULL_ARC);

    // middle circle
    rect = QRectF(-VOR_MIDDLE_RADIUS, -VOR_MIDDLE_RADIUS, 2*VOR_MIDDLE_RADIUS, 2*VOR_MIDDLE_RADIUS);
    painter.drawArc(rect, 0, FULL_ARC);

    // inner circle
    rect = QRectF(-VOR_INNER_RADIUS, -VOR_INNER_RADIUS, 2*VOR_INNER_RADIUS, 2*VOR_INNER_RADIUS);
    painter.drawArc(rect, 0, FULL_ARC);

    // crown lines
    painter.save();
    QLineF line(0, VOR_MIDDLE_RADIUS, 0, VOR_OUTER_RADIUS);
    int max_rotation = 12;
    for(int rotation = 0; rotation<max_rotation; ++rotation)
    {
        painter.rotate(360/(double)max_rotation);
        painter.drawLine(line);
    }
    painter.restore();

    // text


//     double text_dist = 30;
//     double text_angle = -135.0;

//     painter.rotate(text_angle);
//     painter.translate(0, -text_dist);
//     line = QLineF(0,0, 0, text_dist-VOR_OUTER_RADIUS);
//     painter.drawLine(line);
//     painter.rotate(-text_angle);

//     QRect text_bounding_rect = 
//         painter.boundingRect(QRect(0, 0, 500, 500), Qt::AlignLeft | Qt::AlignTop, text);

//     QRectF text_rect = QRectF(-text_bounding_rect.width(), 0,
//                               text_bounding_rect.width(), text_bounding_rect.height());

//     painter.drawRect(text_rect);
//     painter.drawText(text_rect, text);

    painter.restore();
}
Ejemplo n.º 25
0
void Cell::paintEvent(QPaintEvent *)
{
    if(changed)
    {
	changed = false;

	if(ddirs == None || ddirs == Free || locked)
	    pixmap = QPixmap(":/pics/locked.png");
        else
	    pixmap = QPixmap(":/pics/background.png");

	QPainter paint;
	paint.begin(&pixmap);

	if(blinkProgress)
	{
	    paint.setPen(QPen(Qt::white, BlinkWidth));
	    paint.drawLine(0, width() - blinkProgress,
			   width(), 2 * width() - blinkProgress);
	}

	if(focusedCell == this)
	    paint.drawPixmap(0, 0, QPixmap(":/pics/focus.png"));

	if((ddirs != Free) && (ddirs != None))
	{
	    double offset = 0;
	    if(rotationProgress)
	    {
                offset = width() / 2;
		paint.translate(offset, offset);
		paint.rotate(rotationProgress);
	    }

	    if(connected)
		paint.drawPixmap(int(-offset), int(-offset), * connectedpixmap[ddirs]);
	    else 
		paint.drawPixmap(int(-offset), int(-offset), * disconnectedpixmap[ddirs]);
            paint.resetMatrix();

	    if(root)
		paint.drawPixmap(0, 0, QPixmap(":/pics/server.png"));
	    else if(ddirs == U || ddirs == L || ddirs == D || ddirs == R)
	    {
		if(connected)
		    paint.drawPixmap(0, 0, QPixmap(":/pics/computer2.png"));
		else
		    paint.drawPixmap(0, 0, QPixmap(":/pics/computer1.png"));
	    }
	}
	paint.drawPixmap(0, 0, * shadowpixmap[shadow]);
	paint.end();
    }
    QPainter p(this);
    p.drawPixmap(0, 0, pixmap);
}
Ejemplo n.º 26
0
myscroll::myscroll(QWidget *parent) :
    QWidget(parent)
{
    this->resize(450,600);
    p1 = new QPixmap(300,400);
    p1->fill(Qt::transparent);
    p1 = new QPixmap(this->width(),this->height());
    p1->fill(Qt::transparent);

    QTime tim;
    tim=QTime::currentTime();
    qsrand(tim.msec()+tim.second()*1000);
    QPainter painter;
    painter.begin(p1);
    painter.setPen(Qt::red);
    save.setX(0);
    save.setY(300);
    for(int i=1; i<400; i++)
    {
        now.setX(i);
        now.setY(qrand()%20+300);
        painter.drawLine(save,now);
        save =now;
    }
    painter.drawLine(0,400,400,400);
    painter.drawLine(0,200,0,400);
    for(int i=0; i<200; i++)
    {
        if(!(i%10))
        {
            painter.drawLine(0,400-i,3,400);
        }
    }


    for(i=0; i<400; i++)
    {
        if(!(i%50))
        {
            painter.save();
            painter.translate(i,400);
            painter.rotate(-15);
            painter.setRenderHint(QPainter::Antialiasing,true);
            painter.setPen(QPen(Qt::red, 2, Qt::DashDotLine, Qt::RoundCap, Qt::RoundJoin));
            painter.drawLine(0,0,0,5);
            str.setNum(i);
            painter.drawText(QRectF(-10,0,30,50),Qt::AlignCenter,str);

            painter.restore();
        }
    }
//  draw_p1();

}
Ejemplo n.º 27
0
void MapEditorWidget::paintAxis(){
  QPainter p;
  p.begin(this);
  
  p.setRenderHint(QPainter::Antialiasing);

  p.setPen(QColor("#000000"));
  p.setBrush(QBrush());
  p.drawRect(plotArea);

  p.setPen(QColor("#000000"));
  
  QString maxY = QString::number(scaledPlotArea().bottomRight().y(),'g',4);
  QString minY = QString::number(scaledPlotArea().topLeft().y(),'g',4);
  QPointF pos = QPointF(plotArea.topLeft());
  QFontMetrics fm(p.font());
  pos.rx() -= fm.boundingRect(maxY).width()+5;
  pos.ry() += fm.boundingRect(maxY).height()/2;
  p.drawText(pos,maxY);

  pos = QPointF(plotArea.topLeft().x(),plotArea.bottomRight().y());
  pos.rx() -= fm.boundingRect(minY).width()+5;
  pos.ry() += fm.boundingRect(minY).height()/2-5;
  p.drawText(pos,minY);

  QString maxX = QString::number(scaledPlotArea().bottomRight().x(),'g',4);
  QString minX = QString::number(scaledPlotArea().topLeft().x(),'g',4);

  pos = QPointF(plotArea.topLeft().x(),plotArea.bottomRight().y());
  pos.rx() -= fm.boundingRect(minX).width()/2;
  pos.ry() += fm.boundingRect(minX).height();
  p.drawText(pos,minX);

  pos = QPointF(plotArea.bottomRight());
  pos.rx() -= fm.boundingRect(maxX).width();
  pos.ry() += fm.boundingRect(maxX).height();
  p.drawText(pos,maxX);

  if(!xLabel.isEmpty()){
    pos = QPointF(plotArea.bottomRight());
    pos.rx() -= fm.boundingRect(xLabel).width()/2+plotArea.width()/2;
    pos.ry() += fm.boundingRect(xLabel).height();
    p.drawText(pos,xLabel);
  }

  if(!yLabel.isEmpty()){
    pos = QPointF(-plotArea.topLeft().y(),plotArea.topLeft().x());
    p.rotate(-90);
    pos.ry() -= fm.boundingRect(yLabel).height()/2;
    pos.rx() -= fm.boundingRect(yLabel).width()/2+plotArea.height()/2;
    p.drawText(pos,yLabel);
  }

}
Ejemplo n.º 28
0
void CannonField::paintCannon(QPainter &painter)
{
	painter.setPen(Qt::NoPen);
	painter.setBrush(Qt::blue);

	painter.save();	
	painter.translate(0, height());
	painter.drawPie(QRect(-35, -35, 70, 70), 0, 90*16);
	painter.rotate(-currentAngle);
	painter.drawRect(QRect(30, -5, 20, 10));
	painter.restore();
}
Ejemplo n.º 29
0
void Kanagram::drawHelpText(QPainter &p, QString text)
{
	p.save();
	QFont font = m_font;
	font.setPointSize(12);
	p.setFont(font);
	p.rotate(-3.29);
	p.setPen(black);
	p.drawText(450, 340, text.section(' ', 0, 0));
	p.drawText(450, 360, text.section(' ', 1));
	p.restore();
}
Ejemplo n.º 30
0
void KisColorSelector::drawRing(QPainter& painter, KisColorSelector::ColorRing& ring, const QRect& rect)
{
    painter.setRenderHint(QPainter::Antialiasing, false);
    painter.resetTransform();
    painter.translate(rect.width()/2, rect.height()/2);
    
    if (ring.pieced.size() > 1) {
        painter.rotate(-ring.getShift().degrees());
        painter.scale(rect.width()/2, rect.height()/2);
        painter.setPen(Qt::NoPen);
        
        QBrush brush(Qt::SolidPattern);
        
        for(int i=0; i<ring.pieced.size(); ++i) {
            float hue = float(i) / float(ring.pieced.size()) + ring.getShift().scaled(0.0f, 1.0f);
            hue = (hue >= 1.0f) ? (hue - 1.0f) : hue;
            hue = (hue <  0.0f) ? (hue + 1.0f) : hue;
            
            KisColor color(hue, 1.0f, m_colorSpace);
            color.setS(ring.saturation);
            color.setX(getLight(m_light, hue, m_relativeLight));
            
            brush.setColor(color.getQColor());
            painter.fillPath(ring.pieced[i], brush);
        }
    }
    else {
        KisColor colors[7] = {
            KisColor(Qt::red    , m_colorSpace),
            KisColor(Qt::yellow , m_colorSpace),
            KisColor(Qt::green  , m_colorSpace),
            KisColor(Qt::cyan   , m_colorSpace),
            KisColor(Qt::blue   , m_colorSpace),
            KisColor(Qt::magenta, m_colorSpace),
            KisColor(Qt::red    , m_colorSpace)
        };
        
        QConicalGradient gradient(0, 0, 0);
        
        for(int i=0; i<=6; ++i) {
            qreal hue = float(i) / 6.0f;
            colors[i].setS(ring.saturation);
            colors[i].setX(getLight(m_light, hue, m_relativeLight));
            gradient.setColorAt(hue, colors[i].getQColor());
        }
        
        painter.scale(rect.width()/2, rect.height()/2);
        painter.fillPath(ring.pieced[0], QBrush(gradient));
    }
    
    painter.resetTransform();
}