本文整理汇总了C++中QPainter::drawEllipse方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainter::drawEllipse方法的具体用法?C++ QPainter::drawEllipse怎么用?C++ QPainter::drawEllipse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPainter
的用法示例。
在下文中一共展示了QPainter::drawEllipse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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);*/
}
}
示例2: paint
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);
}
示例3: ThaiCucQuyen
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);
}
示例4: drawOutline
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));
}
}
}
示例5: drawMarkIco
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");
}
}
}
示例6: paintEvent
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();
}
示例7: draw_bubble
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);
}
示例8: displayKeypoints
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);
}
}
}
示例9: paintEvent
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();
}
示例10: drawTerminalState
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);
}
示例11: updatePreview
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 ) );
}
示例12: paint
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);
}
示例13: drawClusters
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);
}
示例14: generateLensPixmap
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());
}
示例15: PrintPlanes
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);
}
}