本文整理汇总了C++中QPainter::window方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainter::window方法的具体用法?C++ QPainter::window怎么用?C++ QPainter::window使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPainter
的用法示例。
在下文中一共展示了QPainter::window方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
void TouchUI::draw( QPainter & painter )
{
_screen_width = painter.window().width();
_screen_height = painter.window().height();
limitScroll();
// draw background
QRect rect(0,0,painter.window().width(),_height);
painter.drawTiledPixmap( rect, _background );
// draw icons
for ( int i = 0; i < _items.count(); i++ )
{
UIItem * t = _items[i];
int posx = t->x1;
int posy = t->y1;
if ( posx < 0 ) posx = _screen_width+posx;
QSvgRenderer * image = t->image;
if ( t->highlighted )
painter.setCompositionMode( QPainter::CompositionMode_HardLight );
else
painter.setCompositionMode( QPainter::CompositionMode_SourceOver );
if ( image == NULL ) continue;
int h = image->defaultSize().height();
int w = image->defaultSize().width();
int img_width = g_config.ui_size;
int img_height = g_config.ui_size;
ImageLoadThread::fitImage( w,h, img_width, img_height, false );
QRectF r( posx+_xoffset, posy+_yoffset, w, h );
image->render( &painter, r );
}
}
示例2: drawContent
void WColorBar::drawContent(QPainter &p, bool) {
int hue, selectHue, s, v;
color.getHsv(hue,s,v);
colorGroup().highlight().getHsv(selectHue,s,v);
int left=p.window().left();
int width=p.window().width();
int top=p.window().top();
int selecTop=-1, selecBottom=-1;
if (rangeSelecting) {
selecBottom=max(selecStartPos,selecEndPos);
selecTop=min(selecStartPos,selecEndPos);
}
float step=float(p.window().height())/256;
QColor paintColor;
for (int i=0; i<256; i++) {
float y=i*step;
if (rint(y)>selecBottom || rint(y)<selecTop)
paintColor.setHsv(hue,255,255-i);
else
paintColor.setHsv(selectHue,128,int(255-i*0.5));
p.fillRect(left,top+int(rint(y)),width,int(rint(y+step)-rint(y)),
QBrush(paintColor));
}
}
示例3: Segment
void operator<<(QPainter &painter, const Line &l)
{
const Bare_point &s = l.point();
Vector d = l.direction().to_vector();
double len = d.squared_length();
double window_dim = std::max(painter.window().width(), painter.window().height());
d = d * window_dim/std::min(len, 1.0);
painter << Segment(s-d, s+d);
}
示例4: drawContent
void WLinePlot::drawContent(QPainter &p, bool completeRedraw) {
completeRedraw=true;
QArray<float>::Iterator xIt, yIt;
p.eraseRect(p.window());
if (!traces.isEmpty() && xData.count()>0) {
if (wrapAround) {
p.setPen(SolidLine);
// cycle traces and draw them
for (WGraphTrace *trace=traces.first();
trace !=0; trace=traces.next())
if (trace->isVisible()) {
p.setPen(trace->getPen());
xIt=xData.begin();
yIt=trace->getData().begin();
p.moveTo(mapToViewCoords(*xIt,*yIt));
for (++xIt, ++yIt; xIt<xData.end(); ++xIt, ++yIt)
p.lineTo(mapToViewCoords(*xIt,*yIt));
}
// drawing new cursor at newPos+1
if (cursorPos<traceLength()-1) {
int x1 = mapToViewCoords(xData[cursorPos],0).x();
int x2 = mapToViewCoords(xData[cursorPos+1],0).x()+1;
p.fillRect(x1,p.window().top(),x2-x1,p.window().height(),red);
}
} else {
float *x=xData.data(), *y;
for (WGraphTrace *trace=traces.first();
trace !=0; trace=traces.next())
if (trace->isVisible()) {
y=trace->getData().data();
p.setPen(trace->getPen());
p.moveTo(mapToViewCoords(x[0],y[(cursorPos+1) %
traceLength()]));
for (int i=1; i<traceLength(); i++)
p.lineTo(mapToViewCoords(x[i],y[(i+cursorPos+1) %
traceLength()]));
}
}
}
}
示例5: drawSingle
void drawSingle(const QPixmap &img, int panX, int panY, QPainter &painter, qreal zoom){
if(zoom <= 0.0)
zoom = qMin(qreal(painter.window().width()) / qreal(img.width()), qreal(painter.window().height()) / qreal(img.height()));
painter.translate(painter.window().width() / 2,
painter.window().height() / 2);
painter.translate(panX, panY);
painter.scale(zoom, zoom);
painter.drawPixmap(-img.width() / 2, -img.height() / 2, img);
}
示例6: draw_tooltip
void ChartBase::draw_tooltip(QPainter& painter, const QPoint& mouse_position) const
{
size_t point_index;
if (!on_chart(mouse_position, point_index))
return;
const int ShiftX = 2;
const int ShiftY = 2;
const int MarginX = 8;
const int MarginY = 5;
const int FrameMargin = 3;
const qreal CornerRadius = 2.0;
const int Opacity = 180;
const QColor TextColor(210, 210, 210, Opacity);
const QColor BorderColor(40, 40, 40, Opacity);
const QColor BackgroundColor(80, 80, 80, Opacity);
if (m_tooltip_formatter.get() == 0)
return;
const Vector2d& point = m_original_points[point_index];
const QString text = m_tooltip_formatter->format(point);
const QRect text_rect = painter.fontMetrics().boundingRect(QRect(), Qt::AlignCenter, text);
QRect tooltip_rect(
mouse_position.x() + ShiftX,
mouse_position.y() - text_rect.height() - 2 * MarginY - ShiftY,
text_rect.width() + 2 * MarginX,
text_rect.height() + 2 * MarginY);
if (tooltip_rect.left() < FrameMargin)
tooltip_rect.moveLeft(FrameMargin);
if (tooltip_rect.top() < FrameMargin)
tooltip_rect.moveTop(FrameMargin);
const int MaxRight = painter.window().right() - FrameMargin;
if (tooltip_rect.right() > MaxRight)
tooltip_rect.moveRight(MaxRight);
const int MaxBottom = painter.window().bottom() - FrameMargin;
if (tooltip_rect.bottom() > MaxBottom)
tooltip_rect.moveBottom(MaxBottom);
painter.setPen(BorderColor);
painter.setBrush(QBrush(BackgroundColor));
painter.drawRoundedRect(tooltip_rect, CornerRadius, CornerRadius);
painter.setPen(TextColor);
painter.drawText(tooltip_rect, Qt::AlignCenter, text);
}
示例7: DrawEigenvals
void ProjectorPCA::DrawEigenvals(QPainter &painter)
{
int w=painter.window().width();
int h=painter.window().height();
int pad = 5;
Mat& eigVal = pca.eigenvalues;
int dim = eigVal.rows;
float maxEigVal = 0;
#ifdef OPENCV21 // legacy
FOR(i, dim) if(eigVal.at<float>(i,1) == eigVal.at<float>(i,1)) maxEigVal += eigVal.at<float>(i,1);
#else // OPENCV22+
FOR(i, dim) if(eigVal.at<float>(i) == eigVal.at<float>(i)) maxEigVal += eigVal.at<float>(i);
#endif
maxEigVal = max(1.f,maxEigVal);
float maxAccumulator = 0;
#ifdef OPENCV21 // legacy
FOR(i, dim) if(eigVal.at<float>(i,1) == eigVal.at<float>(i,1)) maxAccumulator += eigVal.at<float>(i,1) / maxEigVal;
#else // OPENCV22+
FOR(i, dim) if(eigVal.at<float>(i) == eigVal.at<float>(i)) maxAccumulator += eigVal.at<float>(i) / maxEigVal;
#endif
float accumulator = 0;
painter.setPen(Qt::black);
painter.drawLine(QPointF(pad, h-2*pad), QPointF(w-pad, h-2*pad));
painter.drawLine(QPointF(pad, pad), QPointF(pad, h-2*pad));
painter.setRenderHint(QPainter::Antialiasing);
QPointF point(pad,pad);
painter.setPen(Qt::red);
FOR(i, dim)
{
#ifdef OPENCV21 // legacy
float eigval = eigVal.at<float>(i,1);
#else // OPENCV22+
float eigval = eigVal.at<float>(i);
#endif
if(eigval == eigval)
{
accumulator += eigval / maxEigVal;
//qDebug() << "accumulator: " << accumulator << accumulator/maxAccumulator;
QPointF point2 = QPointF(dim==1 ? w/2 : i * (w-2*pad) / (dim-1) + pad+(!i?1:0), (int)(accumulator/maxAccumulator * (h-2*pad)));
painter.drawLine(point, point2);
point = point2;
}
else
{
point.setX(dim==1 ? w/2 : i * (w-2*pad) / (dim-1) + pad+(!i?1:0));
}
}
示例8: CollectWidgets
void ribi::braw::QtPrintRatingDialog::Print(const std::string& filename)
{
QPrinter printer;
printer.setOrientation(QPrinter::Portrait);
printer.setPaperSize(QPrinter::A4);
printer.setFullPage(false);
printer.setOutputFileName(filename.c_str());
//Draw the image to painter to printer (?must be done before printing)
QPainter painter;
painter.begin(&printer);
{
//Collect widgets to print
const std::vector<QWidget *> widgets = CollectWidgets();
int y = 0;
for (QWidget * const widget: widgets)
{
const int h = widget->height();
if (y+h > painter.window().height())
{
printer.newPage();
y = 0;
}
widget->render(&painter,QPoint(0,y));
y+=h;
}
}
painter.end();
}
示例9: eventFilter
bool MainWindow::eventFilter(QObject *object, QEvent *event)
{
if ( object == ui->position && event->type() == QEvent::MouseButtonPress )
{
m_bDraggingPosition = true;
return false;
}
else if ( object == ui->position && event->type() == QEvent::MouseButtonRelease )
{
m_bDraggingPosition = false;
return false;
}
else if ( object == ui->sampleWindow && event->type() == QEvent::MouseButtonPress )
{
CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();
pMainFrame->GetVisualizerWindow()->SendMessage(WM_LBUTTONDOWN);
}
else if ( object == ui->sampleWindow && event->type() == QEvent::Paint )
{
CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();
QPainter p;
QRect rect = pMainFrame->GetVisualizerWindow()->toQWidget()->rect().adjusted(3,2,-3,-3);
QPixmap pixmap(rect.size());
p.begin(&pixmap);
pMainFrame->GetVisualizerWindow()->toQWidget()->render(&p,QPoint(),QRegion(3,3,rect.width(),rect.height()));
p.end();
p.begin(ui->sampleWindow);
p.drawPixmap(0,0,pixmap.scaled(p.window().size(),Qt::IgnoreAspectRatio,Qt::FastTransformation));
p.end();
return true;
}
return false;
}
示例10: drawBackGround
/*!
*/
void
FieldPainter::draw( QPainter & painter )
{
if ( Options::instance().minimumMode() )
{
painter.fillRect( painter.window(),
Qt::black );
return;
}
if ( Options::instance().antiAliasing() )
{
painter.setRenderHint( QPainter::Antialiasing, false );
}
drawBackGround( painter );
drawLines( painter );
drawPenaltyAreaLines( painter );
drawGoalAreaLines( painter );
drawGoals( painter );
if ( Options::instance().showFlag() )
{
drawFlags( painter );
}
if ( Options::instance().gridStep() > 0.0 )
{
drawGrid( painter );
}
if ( Options::instance().antiAliasing() )
{
painter.setRenderHint( QPainter::Antialiasing );
}
}
示例11:
/*!
*/
void
FieldPainter::drawBackGround( QPainter & painter ) const
{
// fill the whole region
painter.fillRect( painter.window(),
M_field_brush );
}
示例12: printInfoText
void SlideProperties::printInfoText(QPainter& p, int& offset, const QString& str, const QColor& pcol)
{
if (!str.isEmpty())
{
offset += QFontMetrics(p.font()).lineSpacing();
p.setPen(Qt::black);
for (int x = -1; x <= 1; ++x)
{
for (int y = offset + 1; y >= offset - 1; --y)
{
p.drawText(x, p.window().height() - y, str);
}
}
p.setPen(pcol);
p.drawText(0, p.window().height() - offset, str);
}
}
示例13: paintItself
void counterWidget::paintItself(QPainter& inp)
{
inp.save();
int w_width = inp.window().width();
int w_height = inp.window().height();
// first let's draw ownership
inp.setBrush(QBrush(Qt::NoBrush));
if(ownerPresent_m) inp.setBrush(QBrush(playerColor2QColor(frameColor_m), Qt::Dense5Pattern));
if(mortgage_m) inp.setBrush(QBrush(Qt::gray, Qt::Dense5Pattern));
inp.drawRect(0, 0, w_width, w_height); // outer rectangle
// now we need to draw counter pattern
inp.setBrush(QBrush(Qt::blue, Qt::VerPattern));
QRect patternRectangle(frameWidth_m, frameWidth_m, w_width- 2*frameWidth_m,
w_height - 2*frameWidth_m);
inp.drawRect(patternRectangle);
// now we need to draw name
inp.drawText(patternRectangle, name_m, QTextOption(Qt::AlignTop| Qt::AlignHCenter));
inp.restore();
}
示例14: drawGrid
void WGraphFrame::drawGrid(QPainter &p) {
QArray<int>::Iterator it;
QPen oldPen=p.pen();
p.setPen(gridPen);
if (xGridVisible && parent->xAxis()->isVisible())
for (it=parent->xAxis()->getTickArray().begin();
it!=parent->xAxis()->getTickArray().end(); ++it)
p.drawLine(*it, p.window().top(), *it, p.window().bottom());
if (yGridVisible && parent->yAxis()->isVisible())
for (it=parent->yAxis()->getTickArray().begin();
it!=parent->yAxis()->getTickArray().end(); ++it)
p.drawLine(p.window().left(), *it, p.window().right(), *it);
p.setPen(oldPen);
}
示例15: draw
void draw( QPainter &painter, const Slice &slice, const uiCoord2D &pithCoord, const int &intensityThreshold, const TKD::ProjectionType &view )
{
painter.save();
painter.setPen(QColor(255,255,255,127));
const uint width = painter.window().width();
const uint height = painter.window().height();
const qreal angularIncrement = TWO_PI/(qreal)(width);
uint i, j, x, y;
if ( view == TKD::Z_PROJECTION )
{
for ( j=0 ; j<height ; ++j )
{
for ( i=0 ; i<width ; ++i )
{
if ( slice.at(j,i) > intensityThreshold ) painter.drawPoint(i,j);
}
}
}
else if ( view == TKD::CARTESIAN_PROJECTION )
{
for ( j=0 ; j<height ; ++j )
{
for ( i=0 ; i<width ; ++i )
{
x = pithCoord.x + j * qCos(i*angularIncrement);
y = pithCoord.y + j * qSin(i*angularIncrement);
if ( slice.at(y,x) > intensityThreshold ) painter.drawPoint(i,j);
}
}
}
painter.restore();
}