void paint(QPainter &painter){ // const T w=painter.device()->width(); // const T h=painter.device()->height(); // const T s=0.5; //QPointF origo(w2,h2); QPointF origin(bx,by); QPointF neutral(nx,ny); QPointF foot(cx-body.cx,cy-body.cy); QPointF target(tx-body.cx,ty-body.cy); QPointF old(sx-body.cx,sy-body.cy); QPen base(QBrush(Qt::NoBrush),0.02); QPen white(base); white.setWidthF(0.04); white.setColor(QColor(enabled?(lift?"white":"gray"):"darkred")); QPen green(base); green.setWidthF(0.04); green.setColor(QColor("green")); QPen purple(base); purple.setWidthF(0.01); purple.setColor(QColor("purple").darker()); QPen red(base); red.setWidthF(0.02); red.setColor(QColor(balance?"yellow":"red")); QPen teal(base); teal.setWidthF(0.01); teal.setColor(QColor("teal")); QPen blue(base); blue.setWidthF(0.01); blue.setColor(QColor("blue")); const T r=0.02; painter.setPen(teal); painter.drawEllipse(old,r,r); painter.setPen(blue); painter.drawEllipse(target,r,r); painter.setPen(purple); painter.drawEllipse(neutral,r*0.3,r*0.3); painter.setPen(red); painter.drawEllipse(foot,r,r); painter.setPen(white); painter.drawLine(origin,foot); painter.setPen(enabled?green:red); painter.drawEllipse(origin,r,r); }
void graphics::ThaiCucQuyen(QPainter& painter) { int w=width(); int h=height(); QPoint a(w/2,h/2); painter.drawEllipse(a,200,200); // 2 Hinh Tron Nho painter.drawEllipse(w/2-120,h/2,30,30); painter.drawEllipse(w/2+100,h/2,30,30); // 2 Can Moc painter.drawArc(w/2-200,h/2-100,200,200,0,16*-180); painter.drawArc(w/2,h/2-100,200,200,0,16*180); }
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)); } } }
void LightMap::drawMarkIco(QPainter& painter, QPointF& posOnMap,QSharedPointer<DataMark> mark,QSharedPointer<Channel> channel) { QPointF posForPicture = QPointF(posOnMap.x()-12.0, posOnMap.y()-12.0); QPointF posForText = QPointF(posOnMap.x()-24.0, posOnMap.y()+24.0); QString channel_name = channel->getName(); if(channel_name == "Fuel prices") { painter.drawImage(posForPicture, QImage(":/img/fuel.png")); } else if(channel_name == "Public announcements") { painter.drawImage(posForPicture, QImage(":/img/public.png")); } else if(channel_name == "ObsTestChannel") { painter.drawImage(posForPicture, QImage(":/img/test.png")); painter.drawText(posForText, "Test text"); } else if(channel_name.startsWith("bus_")) { painter.drawImage(posForPicture, QImage(":/img/bus.png")); painter.drawText(posForText, channel_name.split('_').at(1)); } else if(channel_name.startsWith("tram_")) { painter.drawImage(posForPicture, QImage(":/img/tram.png")); painter.drawText(posForText, channel_name.split('_').at(1)); } else if(channel_name.startsWith("troll_")) { painter.drawImage(posForPicture, QImage(":/img/trolleybus.png")); painter.drawText(posForText, channel_name.split('_').at(1)); } else if(channel_name.startsWith("user_")) { painter.drawImage(posForPicture, QImage(":/img/user.png")); } else { qDebug() << "drawing blue mark"; painter.setBrush(Qt::blue); painter.drawEllipse(posOnMap,10,10); painter.setBrush(Qt::black); painter.drawEllipse(posOnMap,3,3); if (mark->getLabel()!="tracker's tag") { int mins_ago=(mark->getTime().toUTC().secsTo(QDateTime::currentDateTime()))/60; painter.drawText(posForText,mark->getLabel()+", "+ QString::number(mins_ago)+" min. ago"); } } }
void RoundHint::paintEvent(QPaintEvent *) { QPainter paint; paint.begin(this); paint.setPen(QPen(borderColor)); if(false == isMarked) { paint.setBrush(QBrush (fillingColor)); paint.drawEllipse (QRect(2, 2, this->geometry().width()-4, this->geometry().height()-4)); } else { paint.setBrush(QBrush (markedFillingColor)); paint.drawEllipse (QRect(2, 2, this->geometry().width()-4, this->geometry().height()-4)); } paint.end(); }
void Bubble::draw_bubble(QPainter &painter) { QPen pen; pen.setWidth(stroke); pen.setBrush(colour); painter.setRenderHint(QPainter::HighQualityAntialiasing); painter.setPen(Qt::NoPen); painter.setBrush(colour); painter.setOpacity(opacity); painter.drawEllipse(QPointF(position()[0],position()[1]), r, r); painter.setPen(pen); painter.setBrush(Qt::NoBrush); painter.setOpacity(1.0); painter.drawEllipse(QPointF(position()[0],position()[1]), r, r); }
void ImageViewer::displayKeypoints(QPainter& painter)const { //CvSize s; QPoint pt1, pt2; //CvScalar color; /*char keyFile[256]; sprintf(keyFile, "key/%s.key" if(!fopen(""));*/ if (siftObj1.keypoints==NULL){ printf("ERROR : Keypoints NULL\n"); exit(-1); } painter.setPen(Qt::blue); painter.setBrush(Qt::white); /*Display keypoints*/ if (!siftObj1.IsEmpty() /*&& siftObj1.keypoints!=NULL*/){ for (Keypoint k=siftObj1.keypoints;k!=NULL;k=k->next) { //printf("kp1 %p %f,%f\n", k, k->col, k->row); pt1.setX(ROUND(k->col)); pt1.setY(ROUND(k->row)); painter.drawEllipse(pt1, 3, 3); // Display keypoints vectors pt2.setX(ROUND(k->col + k->scale * 1 * cos(k->ori))); pt2.setY(ROUND(k->row + k->scale * 1 * sin(k->ori))); painter.drawLine (pt1, pt2); } } //cout<<dispMatch<<" ADFADSF "<<siftObj2.IsEmpty()<<endl; if (dispMatch && !siftObj2.IsEmpty() /*&& siftObj2.keypoints!=NULL*/){ /*Display keypoints 2*/ for (Keypoint k=siftObj2.keypoints;k!=NULL;k=k->next) { //printf("kp2 %p %f,%f %p\n", k, k->col, k->row, k->next); pt1.setX(ROUND(k->col)); pt1.setY(ROUND(k->row) + image1.height()); painter.drawEllipse(pt1, 3, 3); // Display keypoints vectors pt2.setX(ROUND(k->col + k->scale * 1 * cos(k->ori))); pt2.setY(ROUND(k->row + k->scale * 1 * sin(k->ori) + image1.height())); painter.drawLine (pt1, pt2); } } }
void QvkWidgetcircle::paintEvent( QPaintEvent *event ) { (void)event; QRegion RegionWidget( 0, 0, width(), height() ); QRegion RegionPaint( 0, 0, width(), height(), QRegion::Ellipse ); #ifdef QT4 QRegion RegionSpace = RegionWidget.subtract( RegionPaint ); QRegion RegionPaintWidget = RegionWidget.subtract( RegionSpace ); #endif #ifdef QT5 QRegion RegionSpace = RegionWidget.subtracted( RegionPaint ); QRegion RegionPaintWidget = RegionWidget.subtracted( RegionSpace ); #endif setMask(RegionPaintWidget); QPainter painter;; painter.begin( this ); painter.setRenderHints( QPainter::Antialiasing, true ); QBrush brush( widgetColor, Qt::SolidPattern ); painter.setBrush( brush ); painter.setPen( widgetColor ); painter.drawEllipse ( QPoint( width()/2, height()/2), width()/2-1, height()/2-1 ); if ( set == false ) { QBrush brush_1( Qt::white, Qt::SolidPattern ); painter.setBrush( brush_1 ); painter.setPen( Qt::white ); painter.drawEllipse ( QPoint( width()/2, height()/2), width()/5, height()/5 ); } if ( set == true ) { QBrush brush_2( Qt::white, Qt::SolidPattern ); painter.setBrush( brush_2 ); painter.setPen( Qt::white ); painter.drawEllipse ( QPoint( width()/2, height()/2), width()/5, height()/5 ); QBrush brush_3( Qt::black, Qt::SolidPattern ); painter.setBrush( brush_3 ); painter.setPen( Qt::black ); painter.drawEllipse ( QPoint( width()/2, height()/2), width()/5-2, height()/5-2 ); } painter.end(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { this->showMaximized(); setFocusPolicy(Qt::StrongFocus); ui->setupUi(this); createActions(); createToolBars(); QPixmap *pixmap = new QPixmap(100, 100); pixmap->fill(Qt::black); QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem(); QGraphicsScene *scene = new QGraphicsScene(0,0,100,100); // ui->viewport->setScene(scene); QPainter painter; painter.begin(pixmap); painter.setPen(QColor(0,255,0)); painter.drawLine(20,20,30,30); painter.setPen(QColor(255,0,0)); painter.drawEllipse(30,30,30,30); painter.end(); pixmapItem->setPixmap(*pixmap); scene->addItem(pixmapItem); ui->viewport->setScene(scene); ui->viewport->update(); }
void Circle::paint(QPainter &painter) { // Fill ellipse switch(this->code) { case Shape::Circle: { painter.setBrush( QBrush( QColor(0, 0, 0) ) ); break; } case Shape::StartCircle: { painter.setBrush( QBrush( QColor(0, 255, 0) ) ); break; } case Shape::GoalCircle: { painter.setBrush( QBrush( QColor(255, 0, 0) ) ); break; } } painter.setPen( Qt::NoPen ); // Draw ellipse // painter.setBrush( Qt::NoBrush ); // painter.setPen( Qt::black ); QPointF center = QPointF(start.x(), start.y()); int radius = sqrt((double)((start.x()-end.x())*(start.x()-end.x()) + (start.y()-end.y())*(start.y()-end.y()))); // qDebug() << "radius: " << radius; painter.setRenderHint(QPainter::Antialiasing, true); painter.drawEllipse(center, (qreal)radius, (qreal)radius); }
void SdLostFoundMsgSupportCanvas::draw(QPainter & p) { if (! visible()) return; QRect r = rect(); if (selected()) p.fillRect(r, ::Qt::black); else { QBrush brsh = p.brush(); p.setBrush(::Qt::black); p.drawEllipse(r.left(), r.top(), LOSTFOUND_SIZE, LOSTFOUND_SIZE); p.setBrush(brsh); } FILE * fp = svg(); if (fp != 0) { const float rr = LOSTFOUND_SIZE / (float) 2.0; fprintf(fp, "<ellipse fill=\"black\" stroke=\"none\" cx=\"%g\" cy=\"%g\" rx=\"%g\" ry=\"%g\" />\n", (float)(r.left() + rr), (float)(r.top() + rr), rr, rr); } // don't use show_mark is selected : too small }
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 ); }
void WTextSourceViewerLine::drawFoldingLineHidden(QPainter &p,const QPointF &pt) { float demi_char_space=char_space/2.0f; QPointF pos(0,pt.y()-demi_char_space); QRectF text_pos(pos,QSizeF(char_space,char_space)); QPointF p3(pt.x(),pt.y()); QPointF p1c(char_space,pt.y()); QBrush b=p.brush(); p.setBrush(Qt::black); QRectF endPoint3(p3.x()-2,p3.y()-2,4,4); p.drawEllipse(endPoint3); p.setBrush(b); p.drawLine(p1c,p3); float pos_size=char_space; QRectF rectangle(pos.x(),pos.y(),pos_size,pos_size); p.drawRoundRect(rectangle); float _x1=pos.x()+3.0f; float _y=pos.y()+pos_size/2.0f; float _x2=pos.x()+pos_size-3.0f; float _x=pos.x()+pos_size/2; float _y1=pos.y()+3; float _y2=pos.y()+pos_size-3; p.drawLine(QPointF(_x1,_y),QPointF(_x2,_y)); p.drawLine(QPointF(_x,_y1),QPointF(_x,_y2)); }
void NavMesh::render(QPainter& painter) { // Itera entre os vertices do grafo for( NodeVector::Iterator v = _vertices.begin(); v != _vertices.end(); ++v ) { int m_pointSize = 10; const QPoint point = (*v)->getPos(); painter.setPen(Qt::gray); painter.setBrush( (*v)->getColor() ); painter.drawEllipse(QRectF(point.x() - m_pointSize, point.y() - m_pointSize, m_pointSize*2, m_pointSize*2)); // If there is no arc, continue to the next node if (!(*v)->adjacents.isEmpty()) { // Draw all arcs from this node AdjacencyList::Iterator arcIt; for (arcIt = (*v)->adjacents.begin(); arcIt != (*v)->adjacents.end(); ++arcIt) { QPoint from = (*arcIt)->from->getPos(); QPoint to = (*arcIt)->to->getPos(); painter.drawLine(from, to); //QRect rect(from,to); //painter.drawRect(rect); } } } }
void PlotWidget::resizeEvent(QResizeEvent *event) { double maxX=XCoord[0], maxY=YCoord[0], minX=XCoord[0], minY=YCoord[0]; uint i; int longX=width()-80; int longY=height()-140; for(i=0; i< XCoord.size(); i++){ if(minX>XCoord[i]) minX=XCoord[i]; if(maxX<XCoord[i]) maxX=XCoord[i]; if(minY>YCoord[i]) minY=YCoord[i]; if(maxY<YCoord[i]) maxY=YCoord[i]; } double x,y; imagen=QImage(longX+30,longY+30,QImage::Format_RGB32); QPainter painter; painter.begin(&imagen); painter.eraseRect(0,0,longX+30,longY+30); painter.setPen(Qt::blue); painter.setBrush(Qt::blue); for(i=0;i<=XCoord.size();i++){ x=(XCoord[i]-minX)*longX/(maxX-minX)+30; y=(YCoord[i]-minY)*longY/(maxY-minY); painter.drawEllipse(x,longY-y,5,5); } painter.setPen(Qt::black); if(LinearFitEnabled){ painter.drawLine(30,longY- ((minX*Plot_m+Plot_b)-minY)*longY/(maxY-minY),longX+30,longY-((maxX*Plot_m+Plot_b)-minY)*longY/(maxY-minY)); } painter.end(); ImageLabel->setPixmap(QPixmap::fromImage(imagen)); // ImageLabel->adjustSize(); QWidget::resizeEvent(event); }
void ClusterView::drawClusters(QPainter& painter,const QValueList<int>& clustersList,bool drawCircles){ //Loop on the clusters to be drawn QValueList<int>::const_iterator clusterIterator; ItemColors& clusterColors = doc.clusterColors(); Data& clusteringData = doc.data(); for(clusterIterator = clustersList.begin(); clusterIterator != clustersList.end(); ++clusterIterator){ //Get the color associated with the cluster and set the color to use to this color painter.setPen(clusterColors.color(*clusterIterator)); //Get the iterator on the spikes of the current cluster Data::Iterator spikeIterator = clusteringData.iterator(static_cast<dataType>(*clusterIterator)); //Iterate over the spikes of the cluster and draw them if(drawCircles) for(;spikeIterator.hasNext();spikeIterator.next()){ QPoint point = spikeIterator(dimensionX,dimensionY); painter.setBrush(clusterColors.color(*clusterIterator)); painter.drawEllipse(point.x() - 1,point.y() - 1,2,2); } else for(;spikeIterator.hasNext();spikeIterator.next()){ painter.drawPoint(spikeIterator(dimensionX,dimensionY)); } } painter.setBrush(NoBrush); }
void Radar::PrintPlanes(QPainter &painter) { int row = 1; int col = 0; for (AConstIterator iter = Acs.begin(), end = Acs.end(); iter != end; iter ++) { qDebug("print"); row = 1; col = (int)(iter.value().Heading / 11.25); if (iter.key() == selectedIcao) { QPen pen; pen.setColor(QColor(180, 200, 0)); pen.setWidthF(2); painter.setBrush(QColor(0, 0, 0, 50)); painter.setPen(pen); painter.setRenderHint(QPainter::Antialiasing, true); painter.drawEllipse(QPointF(iter.value().r_x, iter.value().r_y), 19, 19); painter.setRenderHint(QPainter::Antialiasing, false); row = 0; } painter.drawPixmap(iter.value().r_x - 17, iter.value().r_y - 17, icon_width, icon_height, sprite, col * icon_width, row * icon_height, icon_width, icon_height); } }
void Canvas::DrawFood(QPainter &painter, const QPoint &p) { QColor red(qRgb(255, 0, 0)); painter.setBrush(red); painter.drawEllipse(p.x() * _unit, p.y() * _unit, _unit, _unit); }
void QgsEffectStackPropertiesWidget::updatePreview() { QPainter painter; QImage previewImage( 150, 150, QImage::Format_ARGB32 ); previewImage.fill( Qt::transparent ); painter.begin( &previewImage ); painter.setRenderHint( QPainter::Antialiasing ); QgsRenderContext context = QgsSymbolLayerV2Utils::createRenderContext( &painter ); if ( !mPreviewPicture ) { QPicture previewPic; QPainter previewPicPainter; previewPicPainter.begin( &previewPic ); previewPicPainter.setPen( Qt::red ); previewPicPainter.setBrush( QColor( 255, 100, 100, 255 ) ); previewPicPainter.drawEllipse( QPoint( 75, 75 ), 30, 30 ); previewPicPainter.end(); mStack->render( previewPic, context ); } else { context.painter()->translate( 35, 35 ); mStack->render( *mPreviewPicture, context ); } painter.end(); lblPreview->setPixmap( QPixmap::fromImage( previewImage ) ); }
void ZonesGraph::_drawPhasePlate (QPainter &painter, double squareWidth, double maxRad, QBrush &, QBrush &) { int width = size().width(); int height = size().height(); //painter.setPen (QPen (QColor (255, 255, 255), 5 * dpiScaling.y())); float wholeRad = squareWidth * (_fresnel->getHoleRadius() / maxRad); //painter.drawEllipse (QPoint (width / 2, height / 2), wholeRad, wholeRad); double minIntensity = 1e+8, maxIntensity = 0; for (double n = 0; n < wholeRad; n += 1) { double holeRad = (n / squareWidth) * maxRad; double colorIntensity = _fresnel->getPhasePlateWidthOnRing (holeRad); if (colorIntensity < minIntensity) minIntensity = colorIntensity; if (colorIntensity > maxIntensity) maxIntensity = colorIntensity; } painter.setBrush (QBrush (QColor (0, 0, 0, 0))); for (double n = 0; n < wholeRad; n += 0.2) { double holeRad = (n / squareWidth) * maxRad; double colorIntensity = _fresnel->getPhasePlateWidthOnRing (holeRad); colorIntensity = (1 - colorIntensity / maxIntensity) * 0.75 + 0.25; QColor clr = QColor (0, 150, 255); painter.setPen (QColor (clr.red() * colorIntensity, clr.green() * colorIntensity, clr.blue() * colorIntensity)); painter.drawEllipse (QPoint (width / 2, height / 2), (int)n, (int)n); } }
void PathDeformRenderer::generateLensPixmap() { qreal rad = m_radius + LENS_EXTENT; QRect bounds = circle_bounds(QPointF(), rad, 0); QPainter painter; if (preferImage()) { m_lens_image = QImage(bounds.size(), QImage::Format_ARGB32_Premultiplied); m_lens_image.fill(0); painter.begin(&m_lens_image); } else { m_lens_pixmap = QPixmap(bounds.size()); m_lens_pixmap.fill(Qt::transparent); painter.begin(&m_lens_pixmap); } QRadialGradient gr(rad, rad, rad, 3 * rad / 5, 3 * rad / 5); gr.setColorAt(0.0, QColor(255, 255, 255, 191)); gr.setColorAt(0.2, QColor(255, 255, 127, 191)); gr.setColorAt(0.9, QColor(150, 150, 200, 63)); gr.setColorAt(0.95, QColor(0, 0, 0, 127)); gr.setColorAt(1, QColor(0, 0, 0, 0)); painter.setRenderHint(QPainter::Antialiasing); painter.setBrush(gr); painter.setPen(Qt::NoPen); painter.drawEllipse(0, 0, bounds.width(), bounds.height()); }
void CFlightVisualiser::drawPathes(QPainter& painter, const QRect &fieldLimit) { QPainterPath targetPath, chaserPath; if(_target.size() == 0 || _chaser.size() == 0) { std::runtime_error("No path for target and chaser"); } targetPath.moveTo(QPointF(getScreenPoint(_target[0], fieldLimit))); chaserPath.moveTo(QPointF(getScreenPoint(_chaser[0], fieldLimit))); for(auto iter = _target.begin() + 1; iter != _target.end(); ++iter) { QPointF res = getScreenPoint(*iter, fieldLimit); targetPath.lineTo(res); } for(auto iter = _chaser.begin() + 1; iter != _chaser.end(); ++iter) { QPointF res = getScreenPoint(*iter, fieldLimit); chaserPath.lineTo(res); } painter.drawPath(targetPath); painter.drawPath(chaserPath); painter.drawEllipse(getScreenPoint(*(_target.end() - 1), fieldLimit), 5, 5); painter.drawEllipse(getScreenPoint(*(_chaser.end() - 1), fieldLimit), 5, 5); }
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); }
void MarkerMapObject::paint(QPainter &painter, QRect view, int scale) { // Save the painter state for this paint session // so that it can be restored after without influencing other objects painter.save(); { // Translate, scale, and rotate... QTransform t; t.scale(1.0/scale, 1.0/scale); t.translate(x - view.x()*scale, view.height()*scale - y + view.y()*scale); painter.setTransform(t); for(int index = 0; index < transformationCount; index++) { long arrowLength = 1000*scale; long ballSize = 20*scale; Vector2D a = transformation[index].trans(); Vector2D b = (transformation[index] * Trafo2D::trans(0, arrowLength)).trans(); painter.setPen(transformationColors[index]); QPen pen = painter.pen(); pen.setWidth(2*scale); painter.setPen(pen); painter.drawLine(a.x(), -a.y(), b.x(), -b.y()); painter.setBrush(QBrush(transformationColors[index])); painter.drawEllipse(a.x()-ballSize/2, -(a.y()+ballSize/2), ballSize, ballSize); } } painter.restore(); }
int main(int argc, char *argv[]) { QApplication app(argc, argv); QTextCodec::setCodecForTr(QTextCodec::codecForLocale()); QSvgGenerator svgGen; svgGen.setFileName("test.svg"); QRectF rectangle(10.0, 20.0, 80.0, 60.0); QPainter painter; painter.begin(&svgGen); QPen pen(Qt::red); painter.setPen(pen); painter.drawEllipse(rectangle); rectangle.moveRight(100); painter.drawRect(rectangle); rectangle.moveRight(100); QRectF source(0.0, 0.0, 70.0, 40.0); QImage image("Greenstone.bmp"); painter.drawImage(rectangle, image, source); painter.end(); return 0; }
void RenderArea::dibujarNodo(hora n,QPainter &P) { P.setPen(Qt::black); P.setBrush(Qt::yellow); P.drawEllipse(QPointF(n.x,n.y),12,12); P.drawText(n.x-9,n.y+5,n.lugar); }
void operator<<(QPainter &painter, const Weighted_point &wp) { if (wp.weight() >= 0) { double r = std::max(2.0, sqrt(wp.weight())); painter.drawEllipse(QRectF(wp.x()-r, wp.y()-r, 2*r, 2*r)); } }
void StreetMapMapWidget::paintEvent(QPaintEvent *evnt) { Lock l(m_positionMutex); m_mapTileProvider->invalidate(); if ( (fabs(m_position.getLatitude()) > 1e-1) && (fabs(m_position.getLongitude()) > 1e-1) ) { m_mapTileProvider->latitude = m_position.getLatitude(); m_mapTileProvider->longitude = m_position.getLongitude(); } QPainter painter; painter.begin(this); painter.setRenderHint(QPainter::Antialiasing); m_mapTileProvider->render(&painter, evnt->rect()); painter.setPen(Qt::black); painter.drawText(rect(), Qt::AlignBottom | Qt::TextWordWrap, "Map data (c) OpenStreetMap contributors (CC-BY-SA)."); painter.end(); { // TODO: Draw something on top of the map like the EgoState of the vehicle. QPainter egoStatePainter; egoStatePainter.begin(this); egoStatePainter.setBrush(QBrush(Qt::red)); egoStatePainter.drawEllipse(width()/2, height()/2, 10, 10); egoStatePainter.end(); } }
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 setMultiModelObjectTrajectory2D::displayShowRMMMobileTrajectory2D(QPainter &painter, SpRMMMobileObject mobileObject) { int i, size; if( (size = mobileObject->trajectory2D.size()) == 0 ) return; int x1, y1, x2, y2; std::deque<SpTrajectoryPoint>::iterator points = mobileObject->trajectory2D.begin(); //Show first point x1 = (int) (*points)->x; y1 = (int) (*points)->y; //Oldest red painter.setPen(QColor(255,0,0,255)); //red painter.drawEllipse(x1 - 1, y1 - 1, 3, 3); //Draw next points and lines connecting them painter.setPen(QColor(0,0,255,255)); //blue for(i=1, points++; i<size ; i++, points++) { x2 = x1; y2 = y1; x1 = (int) (*points)->x; y1 = (int) (*points)->y; painter.drawLine(x1, y1, x2, y2); if(i<size-1) painter.drawEllipse(x1 - 1, y1 - 1, 3, 3); } if(size > 1) { painter.setPen(QColor(255,255,255,255)); //white painter.drawEllipse(x1 - 1, y1 - 1, 3, 3); //Draw final estimated point and line for next frame /* painter.setPen(QColor(0,255,0,255)); //green x2 = x1; y2 = y1; mobileObject->get2DPositionProjection(x1, y1); painter.drawLine(x1, y1, x2, y2); painter.drawEllipse(x1 - 1, y1 - 1, 3, 3);*/ } }