Results 1 to 6 of 6

Thread: Rendering a scale widget

  1. #1
    Join Date
    Feb 2013
    Posts
    38
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Rendering a scale widget

    Hi,

    I have several spectrograms. They share one color bar which I created.

    I am trying to render those spectrograms with their color bar.

    I efficiently render the spectrograms with the QwtPlotRenderer but when it comes to the color bar (which is a QwtScaleWidget) I am not sure how to do it. I had a look at the QwtPlotRenderer::renderScale method, but it takes as parameter a QwtPlot (which I don't have because my spectrograms don't have color bar : their spectrogram curve just has a color map).

    I try to extract the relevant code from the method, but I end up with issues with the font (the tick texts are very small) and the size (the color bar is not thick but I think I can manage this one).

    Here come the question : how to properly render a QwtScaleWidget which is not attached to a QwtPlot ?

    Thanks,

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

    Default Re: Rendering a scale widget

    Quote Originally Posted by moijhd View Post
    ... but I end up with issues with the font (the tick texts are very small) and the size (the color bar is not thick but I think I can manage this one).
    QwtPlotRenderer::render() sets up a scaling for the painter, so that the drawing code can ignore the different paint device resolution. Looks like your scale is not rendered with this painter ?

    Uwe

  3. #3
    Join Date
    Feb 2013
    Posts
    38
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Rendering a scale widget

    I actually use the same painter but not the same QwtPlotRenderer which I destroy when I don't have anymore plots to render. Should I keep it alive until I render the scale ?

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

    Default Re: Rendering a scale widget

    This is the painter transformation you have to use for rendering your scale:

    Qt Code:
    1. QTransform transform;
    2. transform.scale(
    3. double( painter->device()->logicalDpiX() ) / yourScale->logicalDpiX(),
    4. double( painter->device()->logicalDpiY() ) / yourScale->logicalDpiY() );
    To copy to clipboard, switch view to plain text mode 
    Uwe

  5. #5
    Join Date
    Feb 2013
    Posts
    38
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Rendering a scale widget

    Hi,

    Could you be more specific about where to transform and how should I render ?

    I have the scale widget. I create the QTransform. I apply it to the painter.

    And then ? QwtPlotRenderer extracted code ? QWidget::render ? I tried those two but it did not render properly (or rendered nothing).
    Since I added a title to the axis, the size of the text is also to fix.

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

    Default Re: Rendering a scale widget

    The axis has to be painted using scaleWidget->scaleDraw()->draw() scaleWidget->drawTitle() and scaleWidget->drawColorBar - like it is done inside of QwtPlotRenderer::renderScale().
    But as all geometries are internally stored in screen metrics you have to set up the painter transformation ( see above ), that translates and scales them to paint device coordinates.

    If your layout ( including the geometry where you want to render the extra scale ) is in paint device coordinates you have to use the inverted transformation to map the geometry of the scale into screen coordinates. Then you have to assign the transformation to the painter and call a method, that does something similar for your extra scale - like what is done in QwtPlotRenderer::renderScale(). Of course this method could have been won from stripping down the implementation of QwtPlotRenderer::renderScale().

    Uwe

Similar Threads

  1. Qt widget for graph rendering, like GrapViz
    By dennis714 in forum Qt Programming
    Replies: 3
    Last Post: 9th July 2013, 21:35
  2. Implementing cached rendering of a widget.
    By emmanuel in forum Qt Programming
    Replies: 4
    Last Post: 16th February 2010, 20:37
  3. Trouble with rendering to the widget
    By dosto.walla in forum Qt Programming
    Replies: 4
    Last Post: 29th September 2008, 15:44
  4. Problem rendering QImage from Phonon Widget
    By JimDaniel in forum Qt Programming
    Replies: 2
    Last Post: 12th July 2008, 15:31
  5. My own scale widget in Qwt
    By igrms in forum Qwt
    Replies: 7
    Last Post: 15th June 2006, 21:18

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.