本文整理汇总了C++中QPointArray::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ QPointArray::resize方法的具体用法?C++ QPointArray::resize怎么用?C++ QPointArray::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPointArray
的用法示例。
在下文中一共展示了QPointArray::resize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawArrow
void QCDEStyle::drawArrow( QPainter *p, ArrowType type, bool down,
int x, int y, int w, int h,
const QColorGroup &g, bool enabled, const QBrush * /* fill */ )
{
QPointArray bFill; // fill polygon
QPointArray bTop; // top shadow.
QPointArray bBot; // bottom shadow.
QPointArray bLeft; // left shadow.
QWMatrix matrix; // xform matrix
bool vertical = type == UpArrow || type == DownArrow;
bool horizontal = !vertical;
int dim = w < h ? w : h;
int colspec = 0x0000; // color specification array
if ( dim < 2 ) // too small arrow
return;
// adjust size and center (to fix rotation below)
if ( w > dim ) {
x += (w-dim)/2;
w = dim;
}
if ( h > dim ) {
y += (h-dim)/2;
h = dim;
}
if ( dim > 3 ) {
bFill.resize( dim & 1 ? 3 : 4 );
bTop.resize( 2 );
bBot.resize( 2 );
bLeft.resize( 2 );
bLeft.putPoints( 0, 2, 0,0, 0,dim-1 );
bTop.putPoints( 0, 2, 1,0, dim-1, dim/2);
bBot.putPoints( 0, 2, 1,dim-1, dim-1, dim/2);
if ( dim > 6 ) { // dim>6: must fill interior
bFill.putPoints( 0, 2, 1,dim-1, 1,1 );
if ( dim & 1 ) // if size is an odd number
bFill.setPoint( 2, dim - 2, dim / 2 );
else
bFill.putPoints( 2, 2, dim-2,dim/2-1, dim-2,dim/2 );
}
}
else {
if ( dim == 3 ) { // 3x3 arrow pattern
bLeft.setPoints( 4, 0,0, 0,2, 1,1, 1,1 );
bTop .setPoints( 2, 1,0, 1,0 );
bBot .setPoints( 2, 1,2, 2,1 );
}
else { // 2x2 arrow pattern
bLeft.setPoints( 2, 0,0, 0,1 );
bTop .setPoints( 2, 1,0, 1,0 );
bBot .setPoints( 2, 1,1, 1,1 );
}
}
if ( type == UpArrow || type == LeftArrow ) {
matrix.translate( x, y );
if ( vertical ) {
matrix.translate( 0, h - 1 );
matrix.rotate( -90 );
} else {
matrix.translate( w - 1, h - 1 );
matrix.rotate( 180 );
}
if ( down )
colspec = horizontal ? 0x2334 : 0x2343;
else
colspec = horizontal ? 0x1443 : 0x1434;
}
else if ( type == DownArrow || type == RightArrow ) {
matrix.translate( x, y );
if ( vertical ) {
matrix.translate( w-1, 0 );
matrix.rotate( 90 );
}
if ( down )
colspec = horizontal ? 0x2443 : 0x2434;
else
colspec = horizontal ? 0x1334 : 0x1343;
}
QColor *cols[5];
if ( enabled ) {
cols[0] = 0;
cols[1] = (QColor *)&g.button();
cols[2] = (QColor *)&g.mid();
cols[3] = (QColor *)&g.light();
cols[4] = (QColor *)&g.dark();
} else {
cols[0] = 0;
cols[1] = (QColor *)&g.button();
cols[2] = (QColor *)&g.button();
cols[3] = (QColor *)&g.button();
cols[4] = (QColor *)&g.button();
}
#define CMID *cols[ (colspec>>12) & 0xf ]
#define CLEFT *cols[ (colspec>>8) & 0xf ]
#define CTOP *cols[ (colspec>>4) & 0xf ]
//.........这里部分代码省略.........
示例2: drawOnePie
//.........这里部分代码省略.........
dataset,
pie,
chart );
datReg->points[ KDChartEnums::PosCenter ]
= drawPosition.center();
datReg->points[ KDChartEnums::PosCenterRight ]
= pointOnCircle( drawPosition, 0 );
datReg->points[ KDChartEnums::PosTopRight ]
= pointOnCircle( drawPosition, 720 );
datReg->points[ KDChartEnums::PosTopCenter ]
= pointOnCircle( drawPosition, 1440 );
datReg->points[ KDChartEnums::PosTopLeft ]
= pointOnCircle( drawPosition, 2160 );
datReg->points[ KDChartEnums::PosCenterLeft ]
= pointOnCircle( drawPosition, 2880 );
datReg->points[ KDChartEnums::PosBottomLeft ]
= pointOnCircle( drawPosition, 3600 );
datReg->points[ KDChartEnums::PosBottomCenter ]
= pointOnCircle( drawPosition, 4320 );
datReg->points[ KDChartEnums::PosBottomRight ]
= pointOnCircle( drawPosition, 5040 );
datReg->startAngle = 2880;
datReg->angleLen = 5760;
regions->append( datReg );
}
} else {
// draw the top of this piece
// Start with getting the points for the arc.
const int arcPoints = angleLen;
QPointArray collect(arcPoints+2);
int i=0;
for ( ; i<=angleLen; ++i){
collect.setPoint(i, pointOnCircle( drawPosition, startAngle+i ));
}
// Adding the center point of the piece.
collect.setPoint(i, drawPosition.center() );
painter->drawPolygon( collect );
//if( bHelp ){
// painter->drawPolyline( collect );
//bHelp=false;
//}
if ( regions ) {
QPointArray hitregion;
hitregion.makeArc( drawPosition.x(), drawPosition.y(),
drawPosition.width(),
drawPosition.height(),
( int ) startAngle, ( int ) angleLen );
hitregion.resize( hitregion.size() + 1 );
hitregion.setPoint( hitregion.size() - 1,
drawPosition.center() );
datReg = new KDChartDataRegion( region->unite( QRegion( hitregion ) ),
dataset,
pie,
chart );
datReg->points[ KDChartEnums::PosTopLeft ]
= pointOnCircle( drawPosition, startAngle + angleLen );
datReg->points[ KDChartEnums::PosTopCenter ]
= pointOnCircle( drawPosition, startAngle + angleLen / 2 );
datReg->points[ KDChartEnums::PosTopRight ]
= pointOnCircle( drawPosition, startAngle );
datReg->points[ KDChartEnums::PosBottomLeft ] = drawPosition.center();
datReg->points[ KDChartEnums::PosBottomCenter ]
= datReg->points[ KDChartEnums::PosBottomLeft ];
datReg->points[ KDChartEnums::PosBottomRight ]
= datReg->points[ KDChartEnums::PosBottomLeft ];
datReg->points[ KDChartEnums::PosCenterLeft ]
= QPoint( ( datReg->points[ KDChartEnums::PosTopLeft ].x()
+ datReg->points[ KDChartEnums::PosBottomLeft ].x() ) / 2,
( datReg->points[ KDChartEnums::PosTopLeft ].y()
+ datReg->points[ KDChartEnums::PosBottomLeft ].y() ) / 2 );
datReg->points[ KDChartEnums::PosCenter ]
= QPoint( ( datReg->points[ KDChartEnums::PosTopCenter ].x()
+ datReg->points[ KDChartEnums::PosBottomCenter ].x() ) / 2,
( datReg->points[ KDChartEnums::PosTopCenter ].y()
+ datReg->points[ KDChartEnums::PosBottomCenter ].y() ) / 2 );
datReg->points[ KDChartEnums::PosCenterRight ]
= QPoint( ( datReg->points[ KDChartEnums::PosTopRight ].x()
+ datReg->points[ KDChartEnums::PosBottomRight ].x() ) / 2,
( datReg->points[ KDChartEnums::PosTopRight ].y()
+ datReg->points[ KDChartEnums::PosBottomRight ].y() ) / 2 );
datReg->startAngle = startAngle;
datReg->angleLen = angleLen;
regions->append( datReg );
}
}
if( mustDeleteRegion )
delete region;
}
}
示例3: paintChart
void toBarChart::paintChart ( QPainter *p, QRect &rect )
{
QFontMetrics fm = p->fontMetrics();
if ( !Zooming ) {
if ( MinAuto ) {
bool first = true;
std::list<std::list<double> >::reverse_iterator i = Values.rbegin();
if ( i != Values.rend() ) {
for ( std::list<double>::iterator j = ( *i ).begin();j != ( *i ).end();j++ ) {
if ( first ) {
first = false;
zMinValue = *j;
} else if ( zMinValue > *j )
zMinValue = *j;
}
}
}
if ( MaxAuto ) {
bool first = true;
std::list<double> total;
{
for ( std::list<std::list<double> >::iterator i = Values.begin();i != Values.end();i++ ) {
std::list<double>::iterator k = total.begin();
for ( std::list<double>::iterator j = ( *i ).begin();j != ( *i ).end();j++ ) {
if ( k == total.end() ) {
total.insert ( total.end(), *j );
k = total.end();
} else {
*k += *j;
k++;
}
}
}
}
for ( std::list<double>::iterator i = total.begin();i != total.end();i++ ) {
if ( first ) {
first = false;
zMaxValue = *i;
} else if ( zMaxValue < *i )
zMaxValue = *i;
}
}
if ( !MinAuto )
zMinValue = MinValue;
else
zMinValue = round ( zMinValue, false );
if ( !MaxAuto )
zMaxValue = MaxValue;
else
zMaxValue = round ( zMaxValue, true );
}
paintTitle ( p, rect );
paintLegend ( p, rect );
paintAxis ( p, rect );
std::list<QPointArray> Points;
int cp = 0;
int samples = countSamples();
int zeroy = int ( rect.height() - 2 - ( -zMinValue / ( zMaxValue - zMinValue ) * ( rect.height() - 4 ) ) );
if ( samples > 1 ) {
const QWMatrix & mtx = p->worldMatrix();
p->setClipRect ( int ( mtx.dx() + 2 ), int ( mtx.dy() + 2 ), rect.width() - 3, rect.height() - 3 );
if ( Zooming )
p->drawText ( 2, 2, rect.width() - 4, rect.height() - 4,
AlignLeft | AlignTop, "Zoom" );
for ( std::list<std::list<double> >::reverse_iterator i = Values.rbegin();i != Values.rend();i++ ) {
std::list<double> &val = *i;
int count = 0;
int skip = SkipSamples;
QPointArray a ( samples + 10 );
int x = rect.width() - 2;
for ( std::list<double>::reverse_iterator j = val.rbegin();j != val.rend() && x >= 2;j++ ) {
if ( skip > 0 )
skip--;
else {
int val = int ( rect.height() - 2 - ( ( *j - zMinValue ) / ( zMaxValue - zMinValue ) * ( rect.height() - 4 ) ) );
x = rect.width() - 2 - count * ( rect.width() - 4 ) / ( samples - 1 );
a.setPoint ( count, x, val );
count++;
if ( count >= samples )
break;
}
}
a.resize ( count * 2 );
Points.insert ( Points.end(), a );
cp++;
}
}
std::map<int, int> Bottom;
for ( std::list<QPointArray>::iterator i = Points.begin();i != Points.end();i++ ) {
QPointArray a = *i;
int lx = 0;
int lb = 0;
for ( unsigned int j = 0;j < a.size() / 2;j++ ) {
int x, y;
a.point ( j, &x, &y );
if ( Bottom.find ( x ) == Bottom.end() )
//.........这里部分代码省略.........
示例4: addPoint
static void addPoint( QPointArray &a, const QPoint &p )
{
uint n = a.size();
a.resize( n + 1 );
a.setPoint( n, p );
}