Results 1 to 8 of 8

Thread: QwtDial: how to move drawing of the scale to the edges ?

  1. #1
    Join Date
    Jun 2012
    Posts
    63
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default QwtDial: how to move drawing of the scale to the edges ?

    Is it possible to change the place where round scale is drawn. I'd like to move it further to the edge of dial. Also the needle has to be extended to the edges.

    Here's an example.

    ecutalk_v1.3.5_beta3_diesel_new.png
    Last edited by phenoboy; 20th October 2013 at 16:11.

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

    Default Re: QwtDial: how to move drawing of the scale to the edges ?

    Quote Originally Posted by phenoboy View Post
    Is it possible to change the place where round scale is drawn. I'd like to move it further to the edge of dial.
    You could overload QwtDial::scaleInnerRect().

    Also the needle has to be extended to the edges.
    QwtDial::drawNeedle() is virtual too - modify the radius and call the base class.

    Uwe

  3. #3
    Join Date
    Jun 2012
    Posts
    63
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QwtDial: how to move drawing of the scale to the edges ?

    Thanks!

    I did this:

    QRect QwtGauge::scaleInnerRect() const {
    return boundingRect();
    }

    and got this:



    This is almost what I want. I still would like to draw scale and labels inside the circle. So almost like mirroring current drawing. Any help on this ? I found out that I probably need to override QwtRoundScaleDraw::drawTick and drawLabel. Am I on the right path ?

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

    Default Re: QwtDial: how to move drawing of the scale to the edges ?

    No QwtRoundScaleDraw always draws on the outer side - having the same on the inner side is on my TODO list for many years, but there was never enough interest to work on this feature.

    I don't recommend your implementation of scaleInnerRect as it simply returns something wrong to have some side effect. F.e your ticks are cut off at the top edge now.
    Instead I would implement a layout that organizes your dials, so that they overlap.

    Uwe

  5. #5
    Join Date
    Jun 2012
    Posts
    63
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QwtDial: how to move drawing of the scale to the edges ?

    Thanks for the comments. At least I'm interested - I think drawing ticks inside is more natural way but that's just me.

    I looked at QwtRouncScaleDraw:: drawTick and drawLabel. I think I understand how they're drawn. Just to make sure is there anything else I need to modify to get ticks and labels drawn inside ?

    Bt. the design of whole QwtDial and separate scaledraw class is fantastic. I wouldn't want to creat my own dial class just because of these ticks..

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

    Default Re: QwtDial: how to move drawing of the scale to the edges ?

    I think drawing ticks inside is more natural way but that's just me.
    Of course it is, but the code for the scales is a couple of years older ( written for QwtKnob ) than QwtDial and I took what was available at that time.

    Just to make sure is there anything else I need to modify to get ticks and labels drawn inside ?
    The difficult part is the layout code to avoid, that tick labels overlap ( sizeHint ... ) - usually a dial has more than only 1-2 labels like in your example. Note that QwtRoundScaleDraw is also used in the qwtpolar package.

    If you have something useful please upload a patch to: http://sourceforge.net/p/qwt/patches/?source=navbar

    Uwe

  7. #7
    Join Date
    Jun 2012
    Posts
    63
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QwtDial: how to move drawing of the scale to the edges ?

    Quote Originally Posted by Uwe View Post
    Of course it is, but the code for the scales is a couple of years older ( written for QwtKnob ) than QwtDial and I took what was available at that time.



    The difficult part is the layout code to avoid, that tick labels overlap ( sizeHint ... ) - usually a dial has more than only 1-2 labels like in your example. Note that QwtRoundScaleDraw is also used in the qwtpolar package.

    If you have something useful please upload a patch to: http://sourceforge.net/p/qwt/patches/?source=navbar

    Uwe
    I had a few minutes to look at this. It is not perfect. But starting to look quite allright for my purposes. For ticks code I just changed radius to radius - len( tick length from argument). Labels are harder. In drawLabel I'm just estimating radius (radius = radius - ticklen(MajorTick)*3. Sorry, Uwe I'm abusing your beautiful code It's not that easy to calculate correct radius. Font size should be taken into account too..

    Where is this white arc drawn that follows ticks? It might look better if I could remove it ?


  8. #8
    Join Date
    Jun 2012
    Posts
    63
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QwtDial: how to move drawing of the scale to the edges ?

    Quote Originally Posted by phenoboy View Post
    Where is this white arc drawn that follows ticks? It might look better if I could remove it ?
    Found it. It's the drawBackbone function.

Similar Threads

  1. Graph (nodes, edges) Drawing in Qt
    By Sabbir in forum Qt Programming
    Replies: 2
    Last Post: 20th February 2018, 08:50
  2. QwtDial label
    By lvsteenson in forum Qwt
    Replies: 1
    Last Post: 21st December 2012, 09:17
  3. Graphics View: Drawing Items that don't scale
    By Disperato in forum Qt Programming
    Replies: 5
    Last Post: 6th July 2009, 18:16
  4. Refresh axis scale drawing
    By jmsbc in forum Qwt
    Replies: 1
    Last Post: 14th June 2009, 15:45
  5. QWTDial problem
    By zaferaltug in forum Qwt
    Replies: 2
    Last Post: 20th November 2008, 16:40

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.