本文整理汇总了C++中QPainter::drawPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainter::drawPoint方法的具体用法?C++ QPainter::drawPoint怎么用?C++ QPainter::drawPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPainter
的用法示例。
在下文中一共展示了QPainter::drawPoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawShape
void FancyRectangle::drawShape(QPainter &p)
{
QPen oldPen = p.pen();
// draw rectangle
p.setPen(QPen(QColor(118, 118, 118), 1));
p.drawRect((int)x(), (int)y(),
width(), height());
// draw decorations
p.setPen(QPen(QColor(192, 192, 192), 1));
p.drawPoint((int)x(), (int)y());
p.drawPoint((int)x(), (int)y() + height() - 1);
p.drawPoint((int)x() + width() - 1, (int)y());
p.drawPoint((int)x() + width() - 1, (int)y() + height() - 1);
// p.setPen(QPen(QColor(196, 194, 205), 1));
p.setPen(QPen(p.brush().color().dark(120), 1));
p.drawLine((int)x() + 1, (int)y() + height() - 2,
(int)x() + width() - 2, (int)y() + height() - 2);
p.drawLine((int)x() + width() - 2, (int)y() + height() - 1,
(int)x() + width() - 2, (int)y() + 1);
p.setPen(oldPen);
}
示例2: paintEvent
void QVectorMap::paintEvent(QPaintEvent * ev) {
int w=size().width();
int h=size().height();
QPen dotPen;
QPixmap buffer(size());
QPainter p;
buffer.fill(Qt::black); // erasing buffer
p.begin(&buffer);
p.initFrom(this);
// drawing scale
if (scale_ != 1) {
int fix=80;
int greyLevel=fix+(255-fix)*scale_/100;
dotPen.setColor(QColor(greyLevel,greyLevel,greyLevel));
p.setPen(dotPen);
for(int i=-w/scale_;
i<w/scale_;
++i) {
for(int j=-h/scale_;
j<h/scale_;
++j) {
p.drawPoint(i*scale_+w/2,h-(j*scale_+h/2));
}
}
}
if (!vectorList_.empty()) {
VectorList::const_iterator it=vectorList_.begin();
Vector2D previous=*it;
int NbPoint=vectorList_.size();
int curPoint=1;
while(it != vectorList_.end()) {
dotPen.setColor(QColor(255-(255*curPoint/NbPoint),
255*curPoint/NbPoint,
0));
p.setPen(dotPen);
switch (mode_) {
case DrawPoint:
p.drawPoint((int)round((*it).x()*scale_+w/2),
(int)round(h-((*it).y()*scale_+h/2)));
break;
case DrawLine:
p.drawLine((int)round(previous.x()*scale_+w/2),
(int)round(h-(previous.y()*scale_+h/2)),
(int)round((*it).x()*scale_+w/2),
(int)round(h-((*it).y()*scale_+h/2)));
break;
}
previous=*it;
++curPoint;
++it;
}
}
p.end();
QPainter q(this);
q.drawPixmap(0,0,buffer);
}
示例3: qRound
/*!
*/
void
FieldPainter::drawPenaltyAreaLines( QPainter & painter ) const
{
const Options & opt = Options::instance();
// set gdi objects
painter.setPen( M_line_pen );
painter.setBrush( Qt::NoBrush );
// set screen coordinates of field
int left_x = opt.screenX( - Options::PITCH_HALF_LENGTH );
int right_x = opt.screenX( + Options::PITCH_HALF_LENGTH );
// set penalty area params
int pen_top_y = opt.screenY( - Options::PENALTY_AREA_WIDTH*0.5 );
int pen_bottom_y = opt.screenY( + Options::PENALTY_AREA_WIDTH*0.5 );
double pen_circle_y_degree_abs
= std::acos( ( Options::PENALTY_AREA_LENGTH - Options::PENALTY_SPOT_DIST )
/ Options::PENALTY_CIRCLE_R )
* ( 180.0 / M_PI );
int span_angle = qRound( pen_circle_y_degree_abs * 2.0 * 16 );
int pen_circle_r = opt.scale( Options::PENALTY_CIRCLE_R );
int pen_circle_size = opt.scale( Options::PENALTY_CIRCLE_R * 2.0 );
// left penalty area X
int pen_x = opt.screenX( -( Options::PITCH_HALF_LENGTH - Options::PENALTY_AREA_LENGTH ) );
// left arc
int pen_spot_x = opt.screenX( -( Options::PITCH_HALF_LENGTH - Options::PENALTY_SPOT_DIST ) );
painter.drawArc( pen_spot_x - pen_circle_r + 1,
opt.fieldCenter().y() - pen_circle_r,
pen_circle_size,
pen_circle_size,
qRound( -pen_circle_y_degree_abs * 16 ),
span_angle );
// left rectangle
painter.drawLine( left_x, pen_top_y, pen_x, pen_top_y );
painter.drawLine( pen_x, pen_top_y, pen_x, pen_bottom_y );
painter.drawLine( pen_x, pen_bottom_y, left_x, pen_bottom_y );
// left spot
painter.drawPoint( pen_spot_x, opt.fieldCenter().y() );
// right penalty area X
pen_x = opt.screenX( +( Options::PITCH_HALF_LENGTH - Options::PENALTY_AREA_LENGTH ) );
// right arc
pen_spot_x = opt.screenX( +( Options::PITCH_HALF_LENGTH - Options::PENALTY_SPOT_DIST ) );
painter.drawArc( pen_spot_x - pen_circle_r,
opt.fieldCenter().y() - pen_circle_r,
pen_circle_size, pen_circle_size,
qRound( ( 180.0 - pen_circle_y_degree_abs + 0.5 ) * 16 ),
span_angle );
// right rectangle
painter.drawLine( right_x, pen_top_y, pen_x, pen_top_y );
painter.drawLine( pen_x, pen_top_y, pen_x, pen_bottom_y );
painter.drawLine( pen_x, pen_bottom_y, right_x, pen_bottom_y );
// right spot
painter.drawPoint( pen_spot_x, opt.fieldCenter().y() );
}
示例4: drawDot
void MapView::drawDot(QPainter &painter, const QPoint &pos, const QColor &color)
{
painter.setPen(color);
painter.drawPoint(pos);
painter.drawPoint(pos + QPoint(1, 0));
painter.drawPoint(pos + QPoint(0, 1));
painter.drawPoint(pos + QPoint(1, 1));
}
示例5: updateActiveBuffer
void LaptopClient::updateActiveBuffer( )
{
QRect rTitle = titleRect();
if( !bufferDirty && (lastBufferWidth == rTitle.width()))
return;
if ( rTitle.width() <= 0 || rTitle.height() <= 0 )
return;
lastBufferWidth = rTitle.width();
bufferDirty = false;
activeBuffer = QPixmap(rTitle.width(), rTitle.height());
QPainter p;
QRect r(0, 0, activeBuffer.width(), activeBuffer.height());
p.begin(&activeBuffer);
if(aUpperGradient){
p.drawTiledPixmap(r, *aUpperGradient);
}
else{
p.fillRect(r, options()->color(KDecoration::ColorTitleBar, true));
}
if(titlePix)
p.drawTiledPixmap(r, *titlePix);
p.setFont(options()->font(true, isToolWindow() ));
QFontMetrics fm(options()->font(true));
QPalette g = options()->palette(KDecoration::ColorTitleBar, true);
g.setCurrentColorGroup( QPalette::Active );
if(aUpperGradient)
p.drawTiledPixmap(r.x()+((r.width()-fm.width(caption()))/2)-4,
r.y(), fm.width(caption())+8, r.height()-1,
*aUpperGradient);
else
p.fillRect(r.x()+((r.width()-fm.width(caption()))/2)-4, 0,
fm.width(caption())+8, r.height(),
g.brush(QPalette::Background));
p.setPen(g.mid().color());
p.drawLine(r.x(), r.y(), r.right(), r.y());
p.drawLine(r.x(), r.y(), r.x(), r.bottom());
p.setPen(g.color(QPalette::Button));
p.drawLine(r.right(), r.y(), r.right(), r.bottom());
p.drawLine(r.x(), r.bottom(), r.right(), r.bottom());
p.setPen(options()->color(KDecoration::ColorFont, true));
p.drawText(r.x(), r.y()+1, r.width(), r.height()-1,
Qt::AlignCenter, caption() );
g = options()->palette(KDecoration::ColorFrame, true);
g.setCurrentColorGroup( QPalette::Active );
p.setPen(g.background().color());
p.drawPoint(r.x(), r.y());
p.drawPoint(r.right(), r.y());
p.drawLine(r.right()+1, r.y(), r.right()+1, r.bottom());
p.end();
}
示例6: drawDotGrid
void VpGrid::drawDotGrid(GridGC &gridGC)
{
int x,y;
VpGC *vpgc = gridGC.m_gc;
QPainter *gc = vpgc->getGC();
// Assuming QPainter has already established begin().
gc->setRenderHint(QPainter::Antialiasing, true);
// Set the pen.
QPen pen;
pen.setColor(m_color);
pen.setStyle(Qt::SolidLine);
gc->setPen(pen);
for (int i = 0; i < gridGC.m_ynum + 1; i++) {
y = gridGC.m_yll + (i * gridGC.m_dy);
for (int j = 0; j < gridGC.m_xnum; j++) {
x = gridGC.m_xll + (j * gridGC.m_dx);
gc->drawPoint(x, y);
}
}
// Flush graphics to display.
//gc.flush();
//delete gc;
}
示例7: main
int main( int argc, char *argv[] ){
#ifdef APP
QApplication a(argc, argv);
MainWindow w(800, 600);
w.show();
return a.exec();
#else
QImage image(400, 400, QImage::Format_RGB888);
QPainter painter;
image.fill(Qt::white);
painter.begin(&image);
painter.setPen(QPen(Qt::black,1));
int s = 1;
int c = 0;
for (int i = 0; i < 400; i+=s) {
for (int j = 0; j < 400; j+=s) {
//painter.drawRect( i, 0 , i, 399 );
//painter.drawRect( 0, j , 399, j );
if( c % 2 ){
painter.drawPoint( i+1, j+1 );
}
c++;
}
c++;
}
painter.end();
image.save("шахматы2.png");
#endif
}
示例8: 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();
}
}
示例9: drawClusters
void ClusterView::drawClusters(QPainter& painter,const QValueList<int>& clustersList,bool drawCircles){
//Loop on the clusters to be drawn
QValueList<int>::const_iterator clusterIterator;
ItemColors& clusterColors = doc.clusterColors();
Data& clusteringData = doc.data();
for(clusterIterator = clustersList.begin(); clusterIterator != clustersList.end(); ++clusterIterator){
//Get the color associated with the cluster and set the color to use to this color
painter.setPen(clusterColors.color(*clusterIterator));
//Get the iterator on the spikes of the current cluster
Data::Iterator spikeIterator = clusteringData.iterator(static_cast<dataType>(*clusterIterator));
//Iterate over the spikes of the cluster and draw them
if(drawCircles) for(;spikeIterator.hasNext();spikeIterator.next()){
QPoint point = spikeIterator(dimensionX,dimensionY);
painter.setBrush(clusterColors.color(*clusterIterator));
painter.drawEllipse(point.x() - 1,point.y() - 1,2,2);
}
else for(;spikeIterator.hasNext();spikeIterator.next()){
painter.drawPoint(spikeIterator(dimensionX,dimensionY));
}
}
painter.setBrush(NoBrush);
}
示例10: paintGrid
void EditorArea::paintGrid(QPainter& painter)
{
painter.setPen(QPen(Qt::black, 0.5, Qt::SolidLine, Qt::RoundCap,
Qt::RoundJoin));
float gridSpacing = workspace->getGridSpacing();
float spacingOnScreen = size2screen(gridSpacing);
QPointF screenOrigin(0, 0);
QPointF screenEnd(width(), height());
QPointF originPhysCoord = screen2graph(screenOrigin);
float A = (originPhysCoord.x() - int(originPhysCoord.x() / gridSpacing) * gridSpacing) / gridSpacing;
float B = (originPhysCoord.y() - int(originPhysCoord.y() / gridSpacing) * gridSpacing) / gridSpacing;
int countX = 0;
int countY = 0;
while (- size2screen(A * gridSpacing) + countX * spacingOnScreen <= screenEnd.x() + 2 * spacingOnScreen) {
while (- size2screen(B * gridSpacing) + countY * spacingOnScreen <= screenEnd.y() + 2 * spacingOnScreen) {
painter.drawPoint(QPoint( - size2screen(A * gridSpacing) + countX * spacingOnScreen,
- size2screen(B * gridSpacing) + countY * spacingOnScreen ));
countY++;
}
countY = 0;
countX++;
}
}
示例11: paintFoliation
void paintFoliation(const balazs::Foliation& foliation, QPainter &painter, int folW, int folH)
{
painter.save();
painter.setPen(Qt::SolidLine);
painter.drawRect(0, 0, folW, folH);
for(std::size_t i = 0; i < foliation.numIntervals(); i++){
double singularityHeight = heightOfSingularity(foliation, i, folH);
QPointF topPoint(folW * foliation.topDivPoints()[i], 0);
QPointF middlePoint(folW * foliation.topDivPoints()[i], singularityHeight);
QPointF bottomPoint(folW * foliation.topDivPoints()[i], folH);
painter.setPen(Qt::SolidLine);
painter.drawLine(topPoint, middlePoint);
painter.setPen(Qt::DotLine);
painter.drawLine(bottomPoint, middlePoint);
painter.save();
painter.setPen(QPen(Qt::black, 4));
painter.drawPoint(middlePoint);
painter.restore();
}
painter.setPen(Qt::DashLine);
for(std::size_t i = 0; i < foliation.numIntervals(); i++){
QPointF topPoint(folW * foliation.bottomDivPoints()[i], folH);
QPointF bottomPoint(folW * foliation.bottomDivPoints()[i], 1.05 * folH);
painter.drawLine(topPoint, bottomPoint);
}
painter.restore();
}
示例12: drawCoordinates
void My_Painter::drawCoordinates(QPainter &painter)
{
painter.setPen(QPen(Qt::black, 4, Qt::SolidLine));
painter.setRenderHints(QPainter::Antialiasing, true);
painter.drawPoint(10, 200);
painter.setPen(Qt::black);
painter.drawText(2 - xBoundingRect.width() / 2,
203 + xBoundingRect.height() / 2, tr("0") );
//---------------| t |------------------------------------------
painter.drawLine(10, 10, 10, 200);
painter.drawLine(10, 10, 15, 15);
painter.drawLine(10, 10, 5, 15);
painter.drawText( 2 - xBoundingRect.width() / 2,
5 + xBoundingRect.height() / 2, tr("t") );
//--------------------------------------------------------------
//---------------| n |------------------------------------------
painter.drawLine(10, 200, 320, 200);
painter.drawLine(320, 200, 315, 195);
painter.drawLine(320, 200, 315, 205);
painter.drawText(326 - yBoundingRect.width() / 2,
201 + yBoundingRect.height() / 2, tr("n"));
//--------------------------------------------------------------
}
示例13: curve_pen
void
DewarpingView::paintXSpline(
QPainter& painter, InteractionState const& interaction,
InteractiveXSpline const& ispline)
{
XSpline const& spline = ispline.spline();
painter.save();
painter.setBrush(Qt::NoBrush);
#if 0 // No point in drawing the curve itself - we already draw the grid.
painter.setWorldTransform(imageToVirtual() * virtualToWidget());
QPen curve_pen(Qt::blue);
curve_pen.setWidthF(1.5);
curve_pen.setCosmetic(true);
painter.setPen(curve_pen);
std::vector<QPointF> const polyline(spline.toPolyline());
painter.drawPolyline(&polyline[0], polyline.size());
#endif
// Drawing cosmetic points in transformed coordinates seems unreliable,
// so let's draw them in widget coordinates.
painter.setWorldMatrixEnabled(false);
QPen existing_point_pen(Qt::red);
existing_point_pen.setWidthF(4.0);
existing_point_pen.setCosmetic(true);
painter.setPen(existing_point_pen);
int const num_control_points = spline.numControlPoints();
for (int i = 0; i < num_control_points; ++i) {
painter.drawPoint(sourceToWidget(spline.controlPointPosition(i)));
}
QPointF pt;
if (ispline.curveIsProximityLeader(interaction, &pt)) {
QPen new_point_pen(existing_point_pen);
new_point_pen.setColor(QColor(0x00ffff));
painter.setPen(new_point_pen);
painter.drawPoint(pt);
}
painter.restore();
}
示例14: operator
void operator()
( QPainter & painter
, const DrawPoint & d
) const
{
painter.setPen( d.pen );
painter.drawPoint( d.p );
}
示例15: doPaint
void doPaint(QPainter & p)
{
QRgb rgb = qRgb(161, 161, 161);
p.setBackground(QBrush(rgb));
p.eraseRect(0, 0, LCD_W, LCD_H);
if (1) {
#if !defined(PCBTARANIS)
rgb = qRgb(0, 0, 0);
p.setPen(rgb);
p.setBrush(QBrush(rgb));
#endif
#if defined(PCBTARANIS)
unsigned int previousDepth = 0xFF;
#endif
for (int y=0; y<LCD_H; y++) {
#if defined(PCBTARANIS)
unsigned int idx = (y/2) * LCD_W;
#else
unsigned int idx = (y/8) * LCD_W;
unsigned int mask = (1 << (y%8));
#endif
for (int x=0; x<LCD_W; x++, idx++) {
#if !defined(PCBTARANIS)
if (lcd_buf[idx] & mask) {
p.drawPoint(x, y);
}
#else
unsigned int z = (y & 1) ? (lcd_buf[idx] >> 4) : (lcd_buf[idx] & 0x0F);
if (z) {
if (z != previousDepth) {
previousDepth = z;
rgb = qRgb(161-(z*161)/15, 161-(z*161)/15, 161-(z*161)/15);
p.setPen(rgb);
p.setBrush(QBrush(rgb));
}
p.drawPoint(x, y);
}
#endif
}
}
}