Results 1 to 20 of 21

Thread: Reading scenePos by small step

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Reading scenePos by small step

    Can we see the exact code reproducing the problem?

  2. #2
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    40
    Thanked 8 Times in 4 Posts

    Default Re: Reading scenePos by small step

    I belive that the code is not a problem, rather the understanding of coordinates system.
    I am passing from signal to slot the:
    Qt Code:
    1. mouseEvent->scenePos();
    To copy to clipboard, switch view to plain text mode 
    scenePos().x() in the qDebug() show the int, so I belive that I am reading only int values, but need to also read the decimal fraction.

    How to do it is the problem.


    But...when I zoom, let's say 3 times, I get high precision coordinates.(because the distance between 2 point is bigger, and this maybe be the reason).
    Last edited by maverick_pol; 17th August 2007 at 13:30.
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Reading scenePos by small step

    You are getting an integer, because the fraction part is zero. Pixels on the screen are so big (the scale can be 1:1 or smaller) compared to the scene coordinates, that you can't "click" on points that have noninteger coordinates.

  4. #4
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    40
    Thanked 8 Times in 4 Posts

    Default Re: Reading scenePos by small step

    Ok, that's a good point, but I have an application written in MFC that uses CDC to paint my map and show the .xxx values.
    And I am suppose to do the same.

    Ok, I have just discoverd one thing. When I start the application I get only the INT part of the coordinate, but when I zoom In I get the high precision float(good). Not all.
    When I zoom out(the map the same as when I start the app) I get the same high precision float(good), not the INT,even though the map scale is the same as at the begining. ?!!!!!

    I have attached screen(when apps start(INT VAL) and after zooming iN/out). Map has the same scale but coords are shown with a different precision)

    Maverick
    Attached Images Attached Images
    Last edited by maverick_pol; 17th August 2007 at 14:39.
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Reading scenePos by small step

    Could you please ask your application to report the scene size and coordinates on every mouse click or so? My opinion is that your scene size varies and that causes the "malfunction".

  6. #6
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    40
    Thanked 8 Times in 4 Posts

    Default Re: Reading scenePos by small step

    Hi,

    While using fitInView(QRect) the scene is being scaled and rotated(if needed) to ensure that the rect is visible(but not always); there are some flags that help to set the best needed transformation.
    I am sure that the scene has different size while zooming, etc.
    The main question is, why after zooming In and then zooming out I can see the high precision coordinates when the size of the scene is the same as during the app start?
    Why I can't see the fraction just after the app starts?
    Maybe there is somekind of flag/attribute that changes during the zoomIn/Out connected with coordinates precision?

    Maverick
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Reading scenePos by small step

    You can really not respond to my question in your posts, but I'll keep asking the same question over and over - could you report the scene size right after creating it and after each zooming operation? The most probable cause is that the scale of the view changes because of some event that happens during execution of the application (like because the scene size changes) and it causes "fractions" to become available. Could you please use qDebug to report the scene size like I asked you here and in the other thread? Because right now we're getting nowhere.

  8. #8
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    40
    Thanked 8 Times in 4 Posts

    Default Re: Reading scenePos by small step

    Hi,

    Excuse me for not being very precise in my posts. I will try to give more details.
    Scene/View/_rectangle size :
    http://www.qtcentre.org/forum/f-qt-p...html#post46345

    Maverick
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  9. #9
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    40
    Thanked 8 Times in 4 Posts

    Default Re: Reading scenePos by small step

    any other ideas?

    Beforehand thanks!

    Maverick
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Reading scenePos by small step

    Solve the problem from the other thread first.

  11. #11
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    40
    Thanked 8 Times in 4 Posts

    Default Re: Reading scenePos by small step

    I will try to solve the other thread, but that thread seems to be "dead". You were the only person helping me there for a long time. After including the problematic code, noone responded to it.

    Maverick
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Reading scenePos by small step

    The thread seems very much alive...

  13. The following user says thank you to wysota for this useful post:

    maverick_pol (28th August 2007)

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
  •  
Qt is a trademark of The Qt Company.