Results 1 to 2 of 2

Thread: strange display behaviior concerning drawPoint

  1. #1
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    124
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default strange display behaviior concerning drawPoint

    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.
    Qt Code:
    1. int linestring_count = this->m_linestrings.count();
    2. QPen save_pen = QPen(qPainter.pen());// make a copy of current pen
    3.  
    4. qreal real_ptWidth = 5;
    5.  
    6. for(int i=0; i< linestring_count; i++){// for each line string
    7. QVector<QPointF> pointVector = m_linestrings[i]->points();
    8. int pointcount_1 = pointVector.count() -1;
    9. for(int j = 0; j < pointcount_1; j++){
    10.  
    11. qPainter.setPen(save_pen);
    12. qPainter.drawLine(pointVector[j],pointVector[j+1]);
    13. LayerPainter::black_pen->setWidth(real_ptWidth);// using a static pen that has been allocated elsewhere
    14. qPainter.setPen(*LayerPainter::black_pen);
    15. qPainter.drawPoint(pointVector[j]);//draw the nodes as fat points
    16. qPainter.drawPoint(pointVector[j+1]);/draw other node as fat point
    17. qPainter.setPen(save_pen);// back to width=0
    18. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by feraudyh; 23rd July 2010 at 20:17. Reason: spelling

  2. #2
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    124
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: strange display behaviior concerning drawPoint

    By the way I have been able to work around the problem by drawing little polygons: no problem there!

Similar Threads

  1. strange conversion!
    By navid in forum Newbie
    Replies: 7
    Last Post: 14th June 2010, 11:34
  2. QPainter::drawPoint ( int x, int y )
    By berliner in forum Qt Programming
    Replies: 0
    Last Post: 10th May 2010, 00:07
  3. Replies: 8
    Last Post: 6th May 2010, 11:17
  4. Very strange with Qt+OpenCV
    By diego in forum Newbie
    Replies: 0
    Last Post: 29th June 2009, 05:33
  5. Strange error
    By joseph in forum General Programming
    Replies: 3
    Last Post: 8th February 2008, 13:32

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.