Results 1 to 20 of 25

Thread: Problems with QwtPlotRenderer from Qwt 6

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,318
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problems with QwtPlotRenderer from Qwt 6

    Quote Originally Posted by mariposa View Post
    In my application I visualize found peaks by labels which are painted on the top part of the plot canvas. Therefore I created a class that inherits QwtPlotItem and I implemented the draw() function accordingly
    Guess the implementation of your QwtPlotItem doesn't work together with painter transformations, that are enabled when painting to a paint device with a different resolution than the screen resolution.

    But without knowing your code it is impossible to say more,

    Uwe

  2. #2
    Join Date
    Sep 2010
    Posts
    35
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Problems with QwtPlotRenderer from Qwt 6

    I can't paste the whole code for the peak labels since it is quite long. If anyone is interested nonetheless:
    https://cutenmr.svn.sourceforge.net/.../peaklabel.cpp

    I will instead paste snippets of a minimal example I created. I already expected that it is caused by my (wrong) implementation.

    My minimal example is a straight red line that is painted from the top of the canvas to the 0 position of my y-axis. The x-position is "3" in the unit of the x-axis. This is a screenshot of the (expected) result:

    screen2.jpg

    I mainly used the code from the cpupiemarker example for implementing my QwtPlotItem:

    First, I get the QwtScaleMap from my PlotWidget (which is part of a parameters object that I can easily pass to other objects):

    Qt Code:
    1. QwtScaleMap xMap = par->spectrum_plot->canvasMap(QwtPlot::xBottom);
    2. QwtScaleMap yMap = par->spectrum_plot->canvasMap(QwtPlot::yLeft);
    To copy to clipboard, switch view to plain text mode 

    Then the code for drawing the line:

    Qt Code:
    1. p->save();
    2. p->setPen(QColor(Qt::red));
    3. p->drawLine(QPointF(xMap.transform(3), 0), QPointF(xMap.transform(3), yMap.transform(0)));
    4. p->restore();
    To copy to clipboard, switch view to plain text mode 

    And that's all you can find in my draw() function. Everything else is identical to the cpupiemarker example.

    I attach the QwtPlotItem using this code:

    Qt Code:
    1. peakLabel* pL = new peakLabel(par);
    2. pL->attach(par->spectrum_plot);
    To copy to clipboard, switch view to plain text mode 

    And the (unexpected) result of the exported image is:

    export2.jpg

    If you need other parts of the code to evaluate what my mistake is, just ask.

    Many thanks

  3. #3
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,318
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problems with QwtPlotRenderer from Qwt 6

    Quote Originally Posted by mariposa View Post
    First, I get the QwtScaleMap from my PlotWidget (which is part of a parameters object that I can easily pass to other objects):
    Wrong maps - as long as you don't want to paint to the plot canvas widget. Instead you have to use the maps, that are passed as parameters f.e. to QwtPlotItem::draw().

    Uwe

  4. #4
    Join Date
    Sep 2010
    Posts
    35
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Problems with QwtPlotRenderer from Qwt 6

    Quote Originally Posted by Uwe View Post
    Wrong maps - as long as you don't want to paint to the plot canvas widget. Instead you have to use the maps, that are passed as parameters f.e. to QwtPlotItem::draw().
    Yes, that caused the problem of the displacement
    I can't believe I missed something that obvious. Thank you very much

    But the problem with the small axes and labels when using high resolutions persists.

Similar Threads

  1. Replies: 2
    Last Post: 23rd July 2010, 14:53
  2. problems
    By IRON_MAN in forum Newbie
    Replies: 11
    Last Post: 9th July 2009, 16:24
  3. problems going from 4.3.x to 4.4.0
    By Ovis in forum Installation and Deployment
    Replies: 4
    Last Post: 26th June 2008, 19:22
  4. Problems using a DLL
    By prosass in forum Newbie
    Replies: 7
    Last Post: 6th March 2007, 17:45
  5. QT4 Plugins - problems, problems
    By NormanDunbar in forum Qt Programming
    Replies: 6
    Last Post: 9th May 2006, 15:39

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.