Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, September 2002
drawing point bigger then a single pixel


Message 1 in thread

I've just found out that QPainter::drawPoint(int,int) always draw one single pixel regardless of the current pen width setting. After thinking a while I come to the conclusion that is OK - point means point. But my problem is how to draw point that is a little bigger then a single pixel? Shall I draw ellipse or short line or maybe add my own implementation of drawPoint which draws more pixels according to the current pen settings? Does any one has ever faced similiar problem and found what is the best solution?

Jacek


Message 2 in thread

On czwartek 05 wrzesień 2002 03:48 am, Jacek Dylak wrote:
> I've just found out that QPainter::drawPoint(int,int) always draw one
> single pixel regardless of the current pen width setting. After thinking a
> while I come to the conclusion that is OK - point means point. But my
> problem is how to draw point that is a little bigger then a single pixel?
> Shall I draw ellipse or short line or maybe add my own implementation of
> drawPoint which draws more pixels according to the current pen settings?
> Does any one has ever faced similiar problem and found what is the best
> solution?

When the number of points is reasonable, it's OK to just draw ellipses. For a 
big number of points, it may speed things up to do bitblt if the ellipse is 
large enough (say width>3), and just draw one, two or three lines for special 
cases:

void myDrawPoint(QPoint p, int d, QPainter & p) {
	static const bool fatpoint = false;
	switch (d) {
	case 0:
	case 1:
		p.drawPoint(p);
		break;
	case 2:
		p.drawLine(p.x(), p.y(), p.x() + 2, p.y());
		p.drawLine(p.x(), p.y() + 1, p.x() + 2, p.y() + 1);
		break;
	case 3:
		if (fatpoint) {
			p.drawLine(p.x() - 1, p.y() - 1, p.x() + 2, p.y() - 1);
			p.drawLine(p.x() - 1, p.y() + 1, p.x() + 2, p.y() + 1);
		} else {
			p.drawPoint(p.x(), p.y() - 1);
			p.drawPoint(p.x(), p.y() + 1);
		}
		p.drawLine(p.x() - 1, p.y(), p.x() + 2, p.y());
	default:
		p.drawEllipse(QPoint(p.x() - (d >> 1), p.y() - (d >> 1)), QSize(d, d));
		// or do a bitblt if we know offhand that d is fixed
	}
}

Cheers, Kuba Ober


Message 3 in thread

> I've just found out that QPainter::drawPoint(int,int) always 
> draw one single pixel regardless of the current pen width 
> setting. After thinking a while I come to the conclusion that 
> is OK - point means point. But my problem is how to draw 
> point that is a little bigger then a single pixel? Shall I 
> draw ellipse or short line or maybe add my own implementation 
> of drawPoint which draws more pixels according to the current 
> pen settings? Does any one has ever faced similiar problem 
> and found what is the best solution?
> 
> Jacek

I encountered exactly the same thing a couple of days ago. I 'solved'
this by drawing an ellipse with the correct radius (of course after
translating it in order to get the center right...) and then filling
it with the proper color...

pieter


Message 4 in thread

OpenGL allows you to set a point size. glPointSize(float) does the trick.
Not sure about Windows so there might be compatibility issues. If all the
supported platforms allows it, this should be considered a bug. 

William R Volz,  Senior Research Geophysicist

ChevronTexaco 
Exploration & Production Technology Company
Subsurface Characterization Business Line
Interpretation Product Development & Support
4800 Fournace Place, Bellaire, TX, 77401
Tel 713 432 6666  CTN 666 6666 Fax 713 432 2536

><mailto:wrvo@chevrontexaco.com>
>This message may contain confidential information that is proprietary to
ChevronTexaco and is intended only for the use of the parties to whom it is
addressed. If you are not an intended recipient, you are hereby notified
that any disclosure, copying, distribution or use of any information in this
message is strictly prohibited. If you have received this message in error,
please notify me immediately at the telephone number noted above.


-----Original Message-----
From: Pieter Rijken [mailto:Pieter.Rijken@cmg.com] 
Sent: Thursday, September 05, 2002 3:09 AM
To: qt-interest@trolltech.com
Subject: RE: drawing point bigger then a single pixel


> I've just found out that QPainter::drawPoint(int,int) always
> draw one single pixel regardless of the current pen width 
> setting. After thinking a while I come to the conclusion that 
> is OK - point means point. But my problem is how to draw 
> point that is a little bigger then a single pixel? Shall I 
> draw ellipse or short line or maybe add my own implementation 
> of drawPoint which draws more pixels according to the current 
> pen settings? Does any one has ever faced similiar problem 
> and found what is the best solution?
> 
> Jacek

I encountered exactly the same thing a couple of days ago. I 'solved' this
by drawing an ellipse with the correct radius (of course after translating
it in order to get the center right...) and then filling it with the proper
color...

pieter

--
 [ signature omitted ]