本文整理汇总了C++中QPointArray::putPoints方法的典型用法代码示例。如果您正苦于以下问题:C++ QPointArray::putPoints方法的具体用法?C++ QPointArray::putPoints怎么用?C++ QPointArray::putPoints使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPointArray
的用法示例。
在下文中一共展示了QPointArray::putPoints方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: customEvent
void ClusterView::customEvent(QCustomEvent* event){
if(event->type() == QEvent::User + 700){
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
ComputeEvent* computeEvent = (ComputeEvent*) event;
//Get the polygon
QPointArray polygon = computeEvent->polygon();
QRegion selectionArea;
QPointArray reviewPolygon;
long Xdimension = 0;
long Ydimension = 0;
//The QRegion uses rectangles to define its area and the number of rectangles
//increases with the height of the region (y axis). The more rectangles the longer
//the search of one point in the region will take. With a dimension like the time
//the height has an order of the millon (at least 5 going to 80 or more) given a huge amount
//of rectangles. A way of speeding the search of points is to reduce the number of rectangles.
//To do so, if the y dimension is the time, x and y axis are inverted.
//Caution: in Qt graphical coordinate system, the Y axis is inverted (increasing downwards),
//thus a point (x,y) is drawn as (x,-y), before creating the region the points are reset to there raw value (x,y).
if(view.ordinateDimension() != timeDimension){
for(uint i = 0; i< polygon.size();++i){
reviewPolygon.putPoints(i, 1,polygon.point(i).x(),-polygon.point(i).y());
Xdimension = dimensionX;
Ydimension = dimensionY;
}
}
else{
for(uint i = 0; i< polygon.size();++i){
reviewPolygon.putPoints(i, 1,-polygon.point(i).y(),polygon.point(i).x());
Xdimension = dimensionY;
Ydimension = dimensionX;
}
}
//Create a QRegion with the new selection area in order to use the research facilities offer by a QRegion.
selectionArea = QRegion(reviewPolygon);
if(!selectionArea.isNull()){
//Call any appropriate method
switch(mode){
case DELETE_NOISE:
doc.deleteNoise(selectionArea,view.clusters(),Xdimension,Ydimension);
break;
case DELETE_ARTEFACT:
doc.deleteArtifact(selectionArea,view.clusters(),Xdimension,Ydimension);
break;
case NEW_CLUSTER:
doc.createNewCluster(selectionArea,view.clusters(),Xdimension,Ydimension);
break;
case NEW_CLUSTERS:
doc.createNewClusters(selectionArea,view.clusters(),Xdimension,Ydimension);
break;
case ZOOM:
break; //nothing to do
}
}
QApplication::restoreOverrideCursor();
}
}
示例2: drawArrow
void BlastAlignPainter::drawArrow(int xs, int xe, int y, int w, QPainter* p, QColor c){
int aw = (int)((float)w*1.25);
int al = (int)((float)w*3);
int tx;
QPointArray head;
if(xe > xs){
head.putPoints(0, 4, 0, 0, -al/3, -aw, al, 0, -al/3, aw); // forward arrow
}else{
head.putPoints(0, 4, 0, 0, al/3, -aw, -al, 0, al/3, aw);
}
p->setPen(QPen(c, w));
if(xe > xs){ // again if forward arrow
p->drawLine(xs, y, xe-al, y);
p->translate((double)xe-al, (double)y);
tx = xe-al;
}else{
p->drawLine(xs, y, xe+al, y);
p->translate((double)xe+al, (double)y);
tx = xe+al;
}
// draw Head.
p->setPen(QPen(c, 0));
p->setBrush(c);
p->drawPolygon(head);
p->translate(-tx, 0); // put back to where we came from, and return..
}
示例3: availableSpaces
QPointArray Reversi::availableSpaces(const int player) const
{
QPointArray spaces;
for (int r = 0; r < size().height(); r++)
for (int c = 0; c < size().width(); c++)
if (available(QPoint(c, r), player))
spaces.putPoints(spaces.size(), 1, c, r);
return spaces;
}
示例4: qDrawMotifArrow
// motif arrows look the same whether they are used or not
// is this correct?
static void qDrawMotifArrow( QPainter *p, Qt::ArrowType type, bool down,
int x, int y, int w, int h,
const QColorGroup &g, bool )
{
QPointArray bFill; // fill polygon
QPointArray bTop; // top shadow.
QPointArray bBot; // bottom shadow.
QPointArray bLeft; // left shadow.
#ifndef QT_NO_TRANSFORMATIONS
QWMatrix matrix; // xform matrix
#endif
bool vertical = type == Qt::UpArrow || type == Qt::DownArrow;
bool horizontal = !vertical;
int dim = w < h ? w : h;
int colspec = 0x0000; // color specification array
if ( dim < 2 ) // too small arrow
return;
if ( dim > 3 ) {
if ( dim > 6 )
bFill.resize( dim & 1 ? 3 : 4 );
bTop.resize( (dim/2)*2 );
bBot.resize( dim & 1 ? dim + 1 : dim );
bLeft.resize( dim > 4 ? 4 : 2 );
bLeft.putPoints( 0, 2, 0,0, 0,dim-1 );
if ( dim > 4 )
bLeft.putPoints( 2, 2, 1,2, 1,dim-3 );
bTop.putPoints( 0, 4, 1,0, 1,1, 2,1, 3,1 );
bBot.putPoints( 0, 4, 1,dim-1, 1,dim-2, 2,dim-2, 3,dim-2 );
for( int i=0; i<dim/2-2 ; i++ ) {
bTop.putPoints( i*2+4, 2, 2+i*2,2+i, 5+i*2, 2+i );
bBot.putPoints( i*2+4, 2, 2+i*2,dim-3-i, 5+i*2,dim-3-i );
}
if ( dim & 1 ) // odd number size: extra line
bBot.putPoints( dim-1, 2, dim-3,dim/2, dim-1,dim/2 );
if ( dim > 6 ) { // dim>6: must fill interior
bFill.putPoints( 0, 2, 1,dim-3, 1,2 );
if ( dim & 1 ) // if size is an odd number
bFill.setPoint( 2, dim - 3, dim / 2 );
else
bFill.putPoints( 2, 2, dim-4,dim/2-1, dim-4,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 == Qt::UpArrow || type == Qt::LeftArrow ) {
#ifndef QT_NO_TRANSFORMATIONS // #### fix me!
matrix.translate( x, y );
if ( vertical ) {
matrix.translate( 0, h - 1 );
matrix.rotate( -90 );
} else {
matrix.translate( w - 1, h - 1 );
matrix.rotate( 180 );
}
#endif
if ( down )
colspec = horizontal ? 0x2334 : 0x2343;
else
colspec = horizontal ? 0x1443 : 0x1434;
}
else if ( type == Qt::DownArrow || type == Qt::RightArrow ) {
#ifndef QT_NO_TRANSFORMATIONS // #### fix me!
matrix.translate( x, y );
if ( vertical ) {
matrix.translate( w-1, 0 );
matrix.rotate( 90 );
}
#endif
if ( down )
colspec = horizontal ? 0x2443 : 0x2434;
else
colspec = horizontal ? 0x1334 : 0x1343;
}
QColor *cols[5];
cols[0] = 0;
cols[1] = (QColor *)&g.button();
cols[2] = (QColor *)&g.mid();
cols[3] = (QColor *)&g.light();
cols[4] = (QColor *)&g.dark();
#define CMID *cols[ (colspec>>12) & 0xf ]
#define CLEFT *cols[ (colspec>>8) & 0xf ]
#define CTOP *cols[ (colspec>>4) & 0xf ]
#define CBOT *cols[ colspec & 0xf ]
//.........这里部分代码省略.........
示例5: draw
void HorizontalLine::draw (QPixmap &buffer, Scaler &scaler, int, int, int)
{
QPainter painter;
painter.begin(&buffer);
painter.setFont(font);
int y = scaler.convertToY(getValue());
// if value is off chart then don't draw it
if (getValue() < scaler.getLow())
return;
painter.setPen(getColor());
QFontMetrics fm(font);
QString s;
getText(s);
int pixelsWide = fm.width(s);
painter.drawLine (0, y, buffer.width(), y);
painter.drawText(0, y - 1, s, -1);
painter.drawText(0 + pixelsWide + 1, y - 1, QString::number(getValue()), -1);
clearSelectionArea();
QPointArray array;
array.putPoints(0, 4, 0, y - 4, 0, y + 4, buffer.width(), y + 4, buffer.width(), y - 4);
setSelectionArea(new QRegion(array));
if (getStatus() == COBase::Selected)
{
clearGrabHandles();
int t = (int) buffer.width() / 4;
setGrabHandle(new QRegion(0,
y - (HANDLE_WIDTH / 2),
HANDLE_WIDTH,
HANDLE_WIDTH,
QRegion::Rectangle));
painter.fillRect(0, y - (HANDLE_WIDTH / 2), HANDLE_WIDTH, HANDLE_WIDTH, getColor());
setGrabHandle(new QRegion(t,
y - (HANDLE_WIDTH / 2),
HANDLE_WIDTH,
HANDLE_WIDTH,
QRegion::Rectangle));
painter.fillRect(t, y - (HANDLE_WIDTH / 2), HANDLE_WIDTH, HANDLE_WIDTH, getColor());
setGrabHandle(new QRegion(t * 2,
y - (HANDLE_WIDTH / 2),
HANDLE_WIDTH,
HANDLE_WIDTH,
QRegion::Rectangle));
painter.fillRect(t * 2, y - (HANDLE_WIDTH / 2), HANDLE_WIDTH, HANDLE_WIDTH, getColor());
setGrabHandle(new QRegion(t * 3,
y - (HANDLE_WIDTH / 2),
HANDLE_WIDTH,
HANDLE_WIDTH,
QRegion::Rectangle));
painter.fillRect(t * 3, y - (HANDLE_WIDTH / 2), HANDLE_WIDTH, HANDLE_WIDTH, getColor());
setGrabHandle(new QRegion(t * 4,
y - (HANDLE_WIDTH / 2),
HANDLE_WIDTH,
HANDLE_WIDTH,
QRegion::Rectangle));
painter.fillRect(t * 4, y - (HANDLE_WIDTH / 2), HANDLE_WIDTH, HANDLE_WIDTH, getColor());
}
painter.end();
}
示例6: 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 ]
//.........这里部分代码省略.........
示例7: paintAlignments
void BlastAlignPainter::paintAlignments(vector<blastAlignment>* balls, QPainter* p, int xo, int yo, int w, int h, int affy_length, int match_length){
/// draw the matchlength as a line at the top, and the affymetrix probe parts underneath, int the gives space..
/// assume that the background is black!! then we can have lovely purple on black.
int numSpace = 40; // space either side for numbers
int thickLineWidth = 8; // very thick..
int thickArrowHeadWidth = 10;
int thickArrowHeadLength = 25;
int yMargin = 30;
int yStep = 30; // the distance between size..
w = w - 2*xo;
int ew = w - (2*numSpace); // effective width. good for calculating things..
QPointArray aHead;
aHead.putPoints(0, 4, 0, 0, -thickArrowHeadLength/3, -thickArrowHeadWidth, thickArrowHeadLength, 0, -thickArrowHeadLength/3, +thickArrowHeadWidth);
// draw the arrow for the match,,
// first translate to the appropriate position..
QColor purple(180, 0, 180);
p->translate((double)xo, (double)yo+yMargin); // why double?????
drawArrow(numSpace, w-numSpace, 0, 8, p, purple);
p->setFont(QFont("Arial", 8));
p->setPen(QColor(255, 255, 255));
QString text;
text.setNum(0);
p->drawText(0, 4, text);
text.setNum(match_length);
p->drawText(w-numSpace+10, 4, text);
vector<blastAlignment>::iterator it;
/// and now lets draw the alignments.. ho yeahh...
for(it = balls->begin(); it != balls->end(); it++){
//for(int i=0; i < balls->size(); i++){
p->translate(0, (double)yStep);
// use the mStart and mEnd to work out where to put it.. simple calculation..
//float x1 = (float)(*it).mStart/(float)match_length;
//float x2 = (float)(*it).mEnd/(float)match_length;
int xs = (int)((float)ew * ((float)(*it).mStart)/((float)match_length));
int xe = (int)((float)ew * ((float)(*it).mEnd)/((float)match_length));
xs += numSpace;
xe += numSpace;
float logExp = 0; //log10((*it).expectation);
int r;
int g;
if((*it).expectation > 0){
logExp = log10((*it).expectation);
r = -((int)logExp);
r += 100; // add on a bit eh..
if(r > 255) { r = 255; }
g = 255 + (int)logExp; // it should always be negative..
if(g < 0) { g = 0; }
}else{
r = 255;
g = 0;
}
QColor matchColor(r, g, 0);
cout << "match length " << match_length << endl;
cout << "start : " << (*it).mStart << "\txs: " << xs << endl;
cout << "end : " << (*it).mEnd << "\txe: " << xe << endl;
cout << "and the exponent of " << (*it).expectation << "\tis: " << logExp << endl;
cout << "r: " << r << "\tg: " << g << endl;
//cout << "float 1: " << x1 << "\tfloat 2: " << x2 << endl;
////// this isn't perfect, -because we are ignoring any effect that gaps will have on the overall length of the alignment.
////// however, this isn't likely to be very large, and it is tricky for use to insert those gaps in the line representing th
///// whole sequence, so I think that it may be fair to leave it like this..
text.setNum((*it).affyStart);
p->setPen(QColor(255, 255, 255));
ostringstream matchString;
matchString << (*it).matches << "/" << (*it).alignmentLength << " (" << (*it).affyN << " N's)";
if(xs < xe){
p->drawText(xs-numSpace, 4, text);
text.setNum((*it).affyEnd);
p->drawText(xe+10, 4, text);
text = matchString.str().c_str();
p->drawText(numSpace, 4, text);
}else{
p->drawText(xs+10, 4, text);
text.setNum((*it).affyEnd);
p->drawText(xe - numSpace, 4, text);
text = matchString.str().c_str();
p->drawText(numSpace, 4, text);
}
drawArrow(xs, xe, 0, 4, p, matchColor);
}
p->translate((double)-xo, 0);
}