PDA

View Full Version : strange display behaviior concerning drawPoint



feraudyh
23rd July 2010, 20:16
Hello,
I'm trying to write a simple kind of a map viewer. It draws various kinds of objects, but one of the most important is
the MultiLineString. Let me explain that: a LineString represents a set of line segments which follow each other, like
a zigzag if you like. The endpoint of a segment is called a node. A MultiLine string is just a collection of line strings.
These are used to represent roads. I hope that I have passed on the idea.

I want to be able to scale and translate the view on this using viewports.
Now all was going well, until I wanted to make the nodes stand out quite visibly.
The segments have width set to zero so they always look like the same with, independently of the scale.
The idea was to draw the nodes as points with a certain pen size that I readjust dynamicalyl so that they looked fatter than the segments.
To do this I try to use one pen for the lines and one pen for the nodes. But the very strange thing is that the nodes appear suddenly at certain magnifications (I mean scale) and disappear suddenly when zooming out.
And this happens even if I set the pen width for nodes to a fixed value 5.0 . The node drawn with drawPoint disappears when it is a lot more than 5.
May I include a fragment of my drawing routine for multilinestrings. I'm just asking you if the logic looks ok.


int linestring_count = this->m_linestrings.count();
QPen save_pen = QPen(qPainter.pen());// make a copy of current pen

qreal real_ptWidth = 5;

for(int i=0; i< linestring_count; i++){// for each line string
QVector<QPointF> pointVector = m_linestrings[i]->points();
int pointcount_1 = pointVector.count() -1;
for(int j = 0; j < pointcount_1; j++){

qPainter.setPen(save_pen);
qPainter.drawLine(pointVector[j],pointVector[j+1]);
LayerPainter::black_pen->setWidth(real_ptWidth);// using a static pen that has been allocated elsewhere
qPainter.setPen(*LayerPainter::black_pen);
qPainter.drawPoint(pointVector[j]);//draw the nodes as fat points
qPainter.drawPoint(pointVector[j+1]);/draw other node as fat point
qPainter.setPen(save_pen);// back to width=0
}

feraudyh
24th July 2010, 07:27
By the way I have been able to work around the problem by drawing little polygons: no problem there!