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