Results 1 to 2 of 2

Thread: Check a point inside or outside a road?

  1. #1

    Lightbulb Check a point inside or outside a road?

    Please see my Road picture, I draw it by QCanvas and use canvasview to show it. I have used : DrawLine , drawrect of QCanvas, and drawcubicbezier of QPainter to draw it.
    And now! i have a point. This point can be in anywhere on canvasview. How do i check it inside or outside a road?
    --> I thinked about using color to fill the road. And i will check color at position of point. If color at point same color of road => i will say this point inside the road!!!--> is that OK?if it ok! how can i get color at position of point? how can i fill color for road. It not a polygon.

    --> OR using point matrix, any point inside the road will have value = 1. and outside have value = 0. But ! it hard to create this matrix with the value.

    --> OR using this algorithm : "check a point inside or outside the polygon". This method can use for one part of road. But at confluence or more...It not a polygon.

    >>what else?
    Attached Images Attached Images

  2. #2
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Check a point inside or outside a road?

    Using QGraphicsView framework (Qt4), there are several ways to determine this. Looking at your image, it seems that your items can have have nicely defined QPainterPath shapes. So you can use QGraphicsItem::contains(). There are other ways as well, such as QGraphicsScene::itemAt().

    QGraphicsView is soooo much better than QCanvas, you may want to upgrade to Qt4 if you can.

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.