Results 1 to 5 of 5

Thread: Ensure margin for QwtPlotMarkers? And enlarge legend font?

  1. #1
    Join Date
    Nov 2009
    Location
    Sweden
    Posts
    34
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Ensure margin for QwtPlotMarkers? And enlarge legend font?

    Hi again,

    I have some marker text items (QwtPlotMarker) in my plot, located at desired (x,y) locations. All looks good, except in some cases when the plot is rescaled and parts of some
    markers end up outside the visible part of the canvas. The plot itself has a connected QwtPlotRescaler since It's important for me to keep the aspect ratio of the plotted curves. See examples in the attached pictures.
    IDD1.png IDD2.png IDD3.png
    Now I wonder if there is a way to take care of this so that the markers are always visible, regardless of how I rescale the plot? Can I somehow find out to what Y axis limits I need to set so that the (top and bottom) marker texts can fit, also if I should change font size of the markers? Or is there some other way to handle it? I would prefer not to set too large Y axis interval just to "be sure", rather as small as possible but still så that all text fits. (Hm, could this question be understood..?)
    The next question is about font size of the QwtPlotLegend. I've tried to increase the font size this way:
    Qt Code:
    1. QwtLegend* legend = new QwtLegend(plot);
    2. QFont lFont = legend->font();
    3. lFont.setPointSize(18);
    4. legend->setFont(lFont);
    5. plot->insertLegend(legend, QwtPlot::TopLegend, 1.0);
    6. plot->updateLegend();
    To copy to clipboard, switch view to plain text mode 
    However, this seems to have no effect, regardless of the size I set in setPointSize(...).
    An example here, showing how my plot looks now (and I would really like a bit larger font for the legend):
    EP2.png
    Ideas?
    Many thanks in advance!

  2. #2
    Join Date
    Nov 2009
    Location
    Sweden
    Posts
    34
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Ensure margin for QwtPlotMarkers? And enlarge legend font?

    One more comment, or rather a question, which, if I find some answer to it probably could help me solve the "margin" issue I'm facing.

    I thought that if I could find out the size of the QwtPlotMarker in terms of the coordinates of the plot, I could use this to simply adjust the Y axis limits when needed. I know of course the position of the marker, since I "placed" it in the plot with myPlotMarker->setValue( ), but still I would need to find out the extent of the resulting plot marker text "rect" in the plot, in terms of the plot coordinate X and Y limits. I assume this could be pretty simple, but I still cannot figure it out... Any bright ideas out there?

  3. #3
    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: Ensure margin for QwtPlotMarkers? And enlarge legend font?

    Not 100% sure if I got all the details ...

    But maybe it is simply "marker->label()->textSize( ).height() + marker->label()->spacing()" what you are looking for. Note that this is a value in widget ( != plot ) coordinates.
    As you already found a way, that the position of the marker is always inside you could try using QwtPlotLayout::setCanvasMargin() - also a value in widget coordinates.

    Otherwise you would need to use the scaleMaps to translate the pixels into plot coordinates. But then you have the same chicken/egg problem as the rescaler: the scale maps depend on the plot intervals - those you want to find out by using the scale maps.

    Of course you could also consider to overload QwtPlotMarker::drawLabel() and modify the layout code. so that the labels always stay inside of the boundaries of the canvas.

    Uwe

  4. #4
    Join Date
    Nov 2009
    Location
    Sweden
    Posts
    34
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Ensure margin for QwtPlotMarkers? And enlarge legend font?

    Thanks for your reply! Feels like I'm able to fix my margin issue, thanks to your advice. For now I will use the QwtPlotLayout::setCanvasMargin() approach, together with "marker->label()->textSize( ).height() + marker->label()->spacing()". It seems to be pretty simple and promising at a first glance.

    Regarding the font size of the legend in my plot: I still have not been able to "force" a larger font, so any hints here would also be most welcome.

    Best regards!

  5. #5
    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: Ensure margin for QwtPlotMarkers? And enlarge legend font?

    Quote Originally Posted by dobedidoo View Post
    Regarding the font size of the legend in my plot:
    The code you have posted is correct, you can try it f.e in the bode example.

    Uwe

Similar Threads

  1. Replies: 1
    Last Post: 26th October 2012, 08:49
  2. qwtPlot legend font size
    By Narciso in forum Qt Programming
    Replies: 2
    Last Post: 27th April 2012, 09:51
  3. How to enlarge the grap mouse selection
    By matteo.boscolo in forum Qt Programming
    Replies: 4
    Last Post: 13th August 2010, 14:10
  4. Replies: 5
    Last Post: 20th April 2010, 17:16
  5. Enlarge Pushbutton?
    By triperzonak in forum Qt Programming
    Replies: 7
    Last Post: 20th June 2008, 14:58

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.