本文整理汇总了C++中QPolygonF::end方法的典型用法代码示例。如果您正苦于以下问题:C++ QPolygonF::end方法的具体用法?C++ QPolygonF::end怎么用?C++ QPolygonF::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPolygonF
的用法示例。
在下文中一共展示了QPolygonF::end方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addValue
void VLCStatsView::addValue( float value )
{
value /= 1000;
QPolygonF shape = totalbitrateShape->polygon();
if ( shape.count() > ( STATS_LENGTH + 2 ) ) /* keep only STATS_LENGTH samples */
{
shape.remove( 1 );
for(int i=1; i<( STATS_LENGTH + 2 ); i++)
( (QPointF &) shape.at(i) ).setX( i - 1 ); /*move back values*/
}
int count = shape.count();
if ( count == 0 )
{
shape << QPointF( 0, 0 ); /* begin and close shape */
shape << QPointF( count, 0 );
}
shape.insert( shape.end() - 1, QPointF( count, value ) );
( (QPointF &) shape.last() ).setX( count );
totalbitrateShape->setPolygon( shape );
addHistoryValue( value );
QRectF maxsizes = scene()->itemsBoundingRect();
maxsizes.setRight( STATS_LENGTH );
fitInView( maxsizes ); /* fix viewport */
drawRulers( maxsizes );
}
示例2: pointsUpdated
void GradientEditor::pointsUpdated()
{
qreal w = m_alpha_shade->width();
QGradientStops stops;
QPolygonF points;
points += m_red_shade->points();
points += m_green_shade->points();
points += m_blue_shade->points();
points += m_alpha_shade->points();
qSort(points.begin(), points.end(), x_less_than);
for (int i=0; i<points.size(); ++i) {
qreal x = int(points.at(i).x());
if (i < points.size() - 1 && x == points.at(i+1).x())
continue;
QColor color((0x00ff0000 & m_red_shade->colorAt(int(x))) >> 16,
(0x0000ff00 & m_green_shade->colorAt(int(x))) >> 8,
(0x000000ff & m_blue_shade->colorAt(int(x))),
(0xff000000 & m_alpha_shade->colorAt(int(x))) >> 24);
if (x / w > 1)
return;
stops << QGradientStop(x / w, color);
}
m_alpha_shade->setGradientStops(stops);
emit gradientStopsChanged(stops);
}
示例3: prepareForDisplay
void Checker::prepareForDisplay (const QPolygonF &polygon,
int pointRadius,
const DocumentModelAxesChecker &modelAxesChecker,
const DocumentModelCoords &modelCoords)
{
LOG4CPP_INFO_S ((*mainCat)) << "Checker::prepareForDisplay";
ENGAUGE_ASSERT (polygon.count () == NUM_AXES_POINTS);
// Convert pixel coordinates in QPointF to screen and graph coordinates in Point using
// identity transformation, so this routine can reuse computations provided by Transformation
QList<Point> points;
QPolygonF::const_iterator itr;
for (itr = polygon.begin (); itr != polygon.end (); itr++) {
const QPointF &pF = *itr;
Point p (DUMMY_CURVENAME,
pF,
pF);
points.push_back (p);
}
// Screen and graph coordinates are treated as the same, so identity transform is used
Transformation transformIdentity;
transformIdentity.identity();
prepareForDisplay (points,
pointRadius,
modelAxesChecker,
modelCoords,
transformIdentity);
}
示例4: addHistoryValue
void VLCStatsView::addHistoryValue( float value )
{
/* We keep a full history by creating virtual blocks for inserts, growing
by power of 2 when no more space is available. At this time, we also
free space by agregating the oldest values 2 by 2.
Each shown value finally being a mean of blocksize samples.
*/
bool doinsert = false;
int next_blocksize = blocksize;
QPolygonF shape = historyShape->polygon();
int count = shape.count();
if ( count == 0 )
{
shape << QPointF( 0, 0 ); /* begin and close shape */
shape << QPointF( count, 0 );
}
valuesaccumulator += ( value / blocksize );
valuesaccumulatorcount++;
if ( valuesaccumulatorcount == blocksize )
{
valuesaccumulator = 0;
valuesaccumulatorcount = 0;
doinsert = true;
}
if ( doinsert )
{
if ( count > ( STATS_LENGTH + 2 ) )
{
float y = 0;
y += ((QPointF &) shape.at( historymergepointer + 1 )).y();
y += ((QPointF &) shape.at( historymergepointer + 2 )).y();
y /= 2;
/* merge */
shape.remove( historymergepointer + 2 );
( (QPointF &) shape.at( historymergepointer + 1 ) ).setY( y );
for(int i=historymergepointer +1; i<( STATS_LENGTH + 2 ); i++)
( (QPointF &) shape.at(i) ).setX( i - 1 ); /*move back values*/
historymergepointer++;
if ( historymergepointer > ( STATS_LENGTH - 1 ) )
{
historymergepointer = 0;
next_blocksize = ( blocksize << 1 );
}
}
shape.insert( shape.end() - 1, QPointF( count, value ) );
( (QPointF &) shape.last() ).setX( count );
}
else
( (QPointF &) shape.last() ).setX( count - 1 );
historyShape->setPolygon( shape );
blocksize = next_blocksize;
}
示例5: main
int main(int argc, char *argv[])
{
// This usage QApplication and QLabel is adapted from
// http://en.wikipedia.org/wiki/Qt_(toolkit)#Qt_hello_world
QApplication app(argc, argv);
// Declare a polygon. This is just Qt. The Qt Polygon can be used
// in GGL as well, just by its oneline registration above.
QPolygonF polygon;
// Qt methods can be used, in this case to add points
polygon
<< QPointF(10, 20) << QPointF(20, 30)
<< QPointF(30, 20) << QPointF(20, 10)
<< QPointF(10, 20);
// GGL methods can be used, e.g. to calculate area
std::ostringstream out;
out << "GGL area: " << boost::geometry::area(polygon) << std::endl;
// Some functionality is defined in both Qt and GGL
QPointF p(20,20);
out << "Qt contains: "
<< (polygon.containsPoint(p, Qt::WindingFill) ? "yes" : "no")
<< std::endl
<< "GGL within: "
<< (boost::geometry::within(p, polygon) ? "yes" : "no")
<< std::endl;
// Detail: if point is ON boundary, Qt says yes, GGL says no.
// Qt defines an iterator
// (which is actually required for GGL, it's part of the ring-concept)
// such that GGL can use the points of this polygon
QPolygonF::const_iterator it;
for (it = polygon.begin(); it != polygon.end(); ++it)
{
// Stream Delimiter-Separated, just to show something GGL can do
out << boost::geometry::dsv(*it) << std::endl;
}
// Stream the polygon as well
out << boost::geometry::dsv(polygon) << std::endl;
// Just show what we did in a label
QLabel label(out.str().c_str());
label.show();
return app.exec();
// What else could be useful, functionality that GGL has and Qt not (yet)?
// - simplify a polygon (to get less points and preserve shape)
// - clip a polygon with a box
// - calculate the centroid
// - calculate the perimeter
// - calculate the convex hull
// - transform it using matrix transformations
}
示例6: CHECK_AND_MAKE
Circle::Circle(const QPointF& p1, const QPointF& p2, const QPointF& p3) {
QPolygonF poly;
poly << p1 << p2 << p3;
qSort(poly.begin(), poly.end(), pointLessThan);
if CHECK_AND_MAKE(0, 1, 2)
else if CHECK_AND_MAKE(0, 2, 1)
else if CHECK_AND_MAKE(1, 0, 2)
else if CHECK_AND_MAKE(1, 2, 0)
else if CHECK_AND_MAKE(2, 0, 1)
else if CHECK_AND_MAKE(2, 1, 0)
else mRadius = -1;
}
示例7: onInsertPoint
void DialogFunction::onInsertPoint()
{
QAction* pActionInsertPoint = static_cast<QAction*>(sender());
const QPoint& point = pActionInsertPoint->data().toPoint();
QwtArraySeriesData<QPointF>* pSeries = static_cast<QwtArraySeriesData<QPointF>*>(_pCurve->data());
if (pSeries)
{
QPolygonF samples = pSeries->samples();
QPointF newPoint;
newPoint.setX(widgetPlot->invTransform(_pCurve->xAxis(), point.x()));
newPoint.setY(widgetPlot->invTransform(_pCurve->yAxis(), point.y()));
QPolygonF::iterator it = qLowerBound(samples.begin(), samples.end(), newPoint, boost::bind(&QPointF::x, _1) < boost::bind(&QPointF::x, _2));
samples.insert(it, newPoint);
_pCurve->setSamples(samples);
widgetPlot->replot();
}
}
示例8: polygonClip
void polygonClip(const QPolygonF& inpoly,
const QRectF& cliprect,
QPolygonF& out)
{
// construct initial state
State state(cliprect, out);
// do the clipping
for(QPolygonF::const_iterator pt = inpoly.begin(); pt != inpoly.end(); ++pt)
{
state.leftClipPoint(*pt);
}
// complete
state.leftClipPoint(state.left1st);
state.rightClipPoint(state.right1st);
state.topClipPoint(state.top1st);
state.bottomClipPoint(state.bottom1st);
}
示例9: resizePolygon
void BaseObjectView::resizePolygon(QPolygonF &pol, float width, float height)
{
QVector<QPointF>::iterator itr,itr_end;
float coef_a, coef_b;
itr=pol.begin();
itr_end=pol.end();
//Calculates the resize factor
coef_a=width / pol.boundingRect().width();
coef_b=height / pol.boundingRect().height();
//Applies the resize factor to all the polygon points
while(itr!=itr_end)
{
itr->setX(itr->x() * coef_a);
itr->setY(itr->y() * coef_b);
itr++;
}
}
示例10: l
void
ViewerGL::Implementation::drawCheckerboardTexture(const QPolygonF& polygon)
{
///We divide by 2 the tiles count because one texture is 4 tiles actually
QPointF topLeft, btmRight;
double screenW, screenH;
{
QMutexLocker l(&zoomCtxMutex);
topLeft = zoomCtx.toZoomCoordinates(0, 0);
screenW = zoomCtx.screenWidth();
screenH = zoomCtx.screenHeight();
btmRight = zoomCtx.toZoomCoordinates(screenW - 1, screenH - 1);
}
double xTilesCountF = screenW / (checkerboardTileSize * 4); //< 4 because the texture contains 4 tiles
double yTilesCountF = screenH / (checkerboardTileSize * 4);
GLuint savedTexture;
GL_GPU::glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&savedTexture);
{
GLProtectAttrib<GL_GPU> a(GL_ENABLE_BIT);
GL_GPU::glEnable(GL_TEXTURE_2D);
GL_GPU::glBindTexture(GL_TEXTURE_2D, checkerboardTextureID);
GL_GPU::glBegin(GL_POLYGON);
for (QPolygonF::const_iterator it = polygon.begin();
it != polygon.end();
++it) {
GL_GPU::glTexCoord2d( xTilesCountF * ( it->x() - topLeft.x() ) / ( btmRight.x() - topLeft.x() ),
yTilesCountF * ( it->y() - btmRight.y() ) / ( topLeft.y() - btmRight.y() ) );
GL_GPU::glVertex2d( it->x(), it->y() );
}
GL_GPU::glEnd();
//glDisable(GL_SCISSOR_TEST);
} // GLProtectAttrib a(GL_SCISSOR_BIT | GL_ENABLE_BIT);
GL_GPU::glBindTexture(GL_TEXTURE_2D, savedTexture);
glCheckError(GL_GPU);
}
示例11: transform
QTransform Carton::transform(Faces face, const QPointF &translation, qreal scaling) const
{
QTransform result;
const QSizeF originalSize(faceSize(face));
QPolygonF original(4);
original[0] = QPointF(0, 0); // TopLeft
original[1] = QPointF(originalSize.width(), 0); // TopRight
original[2] = QPointF(originalSize.width(), originalSize.height()), // BottomRight
original[3] = QPointF(0, originalSize.height()); // BottomLeft
QPolygonF targetFace = face2d(face);
QPolygonF::iterator i;
for (i = targetFace.begin(); i != targetFace.end(); ++i) {
(*i).setX((*i).x() * scaling + translation.x());
(*i).setY((*i).y() * scaling + translation.y());
}
const bool possible = QTransform::quadToQuad(original, targetFace, result);
Q_ASSERT(possible);
return result;
}
示例12: clipPolyline
void _PolyClipper::clipPolyline(const QPolygonF& poly)
{
// exit if fewer than 2 points in polygon
if ( poly.size() < 2 )
return;
// output goes here
QPolygonF pout;
QPolygonF::const_iterator polyiter = poly.begin();
QPointF lastpt = *polyiter;
polyiter++;
for( ; polyiter != poly.end(); ++polyiter )
{
QPointF p1 = lastpt;
QPointF p2 = *polyiter;
bool plotline = _clipper.clipLine(p1, p2);
if( plotline )
{
if( pout.isEmpty() )
{
// add first line
pout << p1;
if( ! smallDelta(p1, p2) )
pout << p2;
}
else
{
if( p1 == pout.last() )
{
if( ! smallDelta(p1, p2) )
// extend polyline
pout << p2;
}
else
{
// paint existing line
if( pout.size() >= 2 )
emitPolyline(pout);
// start new line
pout.clear();
pout << p1;
if( ! smallDelta(p1, p2) )
pout << p2;
}
}
}
else
{
// line isn't in region, so ignore results from clip function
// paint existing line
if( pout.size() >= 2 )
emitPolyline(pout);
// cleanup
pout.clear();
}
lastpt = *polyiter;
}
if( pout.size() >= 2 )
emitPolyline(pout);
}