Results 1 to 5 of 5

Thread: Using QGLWidget for plotting

  1. #1
    Join Date
    Nov 2009
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Using QGLWidget for plotting

    Hi, I'm using the QGLWidget to display some data that I'm trying to plot. Each graph has its own Y axis and they all share an X axis (also QGLWidgets) When I try to update my scales to match the data, my program locks up and starts running at 99% of the CPU. I have a signal/slot connection to pass the new min and max for the scale. It's watching a realtime data stream, and sampling at 20ms intervals, and redrawing the screen at 200ms intervals. When I redraw the screen, I want the scales to adjust to the new right bound of the graph. I have the following code:

    Qt Code:
    1. // shifts the shared X axis
    2. // This is a slot
    3. void GLScaleWidget::shiftX(const double &amt){
    4. this->min = amt;
    5. this->max = amt+30; //(assume 30s of data for now)
    6. this->makeCurrent();
    7. glMatrixMode(GL_PROJECTION);
    8. glLoadIdentity();
    9. glTranslated(amt, 0, 0);
    10. this->updateGL();
    11. }
    To copy to clipboard, switch view to plain text mode 

    and the problem that I'm getting is that as soon as it starts to do any shifting on the scale, everything else dies too. (It works fine if i dont shift the scale) gl Calls stop functioning correctly, and everything goes black in the window.

    Any help with this would be greatly appreciated.
    Thanks!!!

  2. #2
    Join Date
    Jun 2010
    Location
    India
    Posts
    50
    Thanks
    1
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Using QGLWidget for plotting

    Why are you resetting the projection matrix before transformation ?

  3. #3
    Join Date
    Nov 2009
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Using QGLWidget for plotting

    Thanks for the response =)

    I'm resetting teh projection matrix because "amt" is the offset from x=0. I could save it and just subtract out the old amount from the new amount, and then transform it, but then there would be one more variable to deal with, and one more operation, and just as much matrix math lol. and doing it that way has reliably worked for me before haha

  4. #4
    Join Date
    Jun 2010
    Location
    India
    Posts
    50
    Thanks
    1
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Using QGLWidget for plotting

    If you comment these lines....
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    1. will gl Calls work ? and your graphics is OK(not black ) ?

    Why dont you debug and find exactly where the problem is ?

  5. #5
    Join Date
    Nov 2009
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Using QGLWidget for plotting

    it does the same thing - works up until I try to shift everything, and then fails in the same fashion... I've already started a class that does a similar job, but contains all of the code to draw the scales and the plots. and then just move around the scene using translatef(). I looked into it yesterday, and it seems like its due to the correct QGLContext not being active. I've also tried calling "makeCurrent()" before making gl calls in a class other than the one with the active QGLContext, but that didn't help either....

Similar Threads

  1. Plotting polylines
    By Indalo in forum Qwt
    Replies: 0
    Last Post: 22nd December 2009, 08:51
  2. Odd plotting behaviour
    By ajb in forum Qwt
    Replies: 2
    Last Post: 30th October 2009, 08:30
  3. Plotting a graph with QWT
    By steg90 in forum Qwt
    Replies: 1
    Last Post: 6th June 2007, 17:04
  4. Plotting plug-in available?
    By brcain in forum Qt Programming
    Replies: 2
    Last Post: 12th September 2006, 22:58
  5. How do i get a 2-D plotting widget?
    By superutsav in forum Qt Programming
    Replies: 6
    Last Post: 12th January 2006, 09:54

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.