Results 1 to 5 of 5

Thread: QwtPlot sample to pixel association

  1. #1
    Join Date
    Oct 2010
    Posts
    11
    Thanks
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default QwtPlot sample to pixel association

    Hi,

    I'd appreciate some help with the following. If you set some raw data on a QwtPlotCurve, how can you make the plot draw consecutive samples in consecutive pixels?

    For example, in a QwtPlot subclass constructor:

    Qt Code:
    1. QwtPlotCurve *curve = new QwtPlotCurve("curve");
    2. curve->setPen(QPen(Qt::green, 1));
    3. curve->attach(this);
    4. setCanvasBackground( QColor(Qt::black) );
    5. curve->setData(qwtData);
    6. enableAxis(QwtPlot::xBottom, false);
    7. enableAxis(QwtPlot::yLeft, false);
    8. setMargin(0);
    9. setFixedSize(800, 600);
    To copy to clipboard, switch view to plain text mode 

    If qwtData has 400 values, they don't occupy half of the plot, instead they are stretched to fit the whole 800 pixels.

    I'd be very thankful for any clues.

    catto

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,241
    Thanked 860 Times in 809 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlot sample to pixel association

    The points are mapped according to the scales. When 400.0 on your x-axis is mapped to pixel position 800, then your point will be painted there.

    Guess you want to have a look at QwtPlotRescaler - in SVN trunk you find the navigation example, that demonstrates how to use it.

    Uwe

  3. #3
    Join Date
    Oct 2010
    Posts
    11
    Thanks
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QwtPlot sample to pixel association

    Hello Uwe,

    Thanks for your quick reply. We are studying the example you mentioned.

    Regards,

    Catto.

  4. #4
    Join Date
    Oct 2010
    Posts
    11
    Thanks
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QwtPlot sample to pixel association

    Hello Uwe,

    Regarding my first post, if the plot size is fixed (800x600) would it be enough to add

    Qt Code:
    1. setAxisScale(QwtPlot::xBottom, 1, 800, 1); // 800 ticks wide
    2. setAxisScale(QwtPlot::yLeft, -299, 300, 1); // 600 ticks height
    3. setCanvasLineWidth(0);
    To copy to clipboard, switch view to plain text mode 

    in order for every sample of data to be drawn in separate consecutive pixels?

    Besides the QwtPlotCurve pen width and the canvas line width, are there any other parameters that would need to be adjusted in order to get the desired behavior?


    Thanks for your help

    catto

  5. #5
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,241
    Thanked 860 Times in 809 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlot sample to pixel association

    Quote Originally Posted by catto View Post
    Regarding my first post, if the plot size is fixed (800x600) would it be enough to add ...
    When your plot consists of nothing beside the canvas ( no axes, title, legend ) and you additionally set all margins to 0.

    Uwe

  6. The following user says thank you to Uwe for this useful post:

    catto (5th November 2010)

Similar Threads

  1. System File Association
    By johnmauer in forum Qt Programming
    Replies: 5
    Last Post: 10th November 2010, 22:35
  2. Replies: 3
    Last Post: 29th October 2009, 17:52
  3. Replies: 6
    Last Post: 14th May 2009, 12:02
  4. QPixmap pixel by pixel ?
    By tommy in forum Qt Programming
    Replies: 19
    Last Post: 3rd December 2007, 22:52
  5. association between 2 classes
    By castorvert in forum General Programming
    Replies: 4
    Last Post: 5th April 2006, 07:52

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.