Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to set logarithmic scale on a QGraphicsView ?
QtWS25 Last Chance

How to set logarithmic scale on a QGraphicsView ?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    T3STY
    wrote on 19 Mar 2014, 23:53 last edited by
    #1

    I'm using the QGraphicsView framework to plot a bezier curve and I need to plot it using a logarithmic scale. But I've been unable to find anything that would set a logarithmic scale in the view.

    Is there anything available by default (maybe QGraphicsView::transform() ?) to ease my work ?
    If not, then any suggestions on how to achieve this are greatly appreciated.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Asperamanca
      wrote on 20 Mar 2014, 08:55 last edited by
      #2

      There's no built-in way I know of. But you might wish to take a look at "QWT":http://qwt.sourceforge.net/

      1 Reply Last reply
      0
      • T Offline
        T Offline
        T3STY
        wrote on 20 Mar 2014, 14:34 last edited by
        #3

        I have searched more about plotting Log scales and it seems there's nothing easier than extending the linear range to that of a logarithmic range, and then draw with logarithmic coordinates.
        Assuming the linear axis sizes are X=[0:width] and Y=[0:height] and a point has linear coordinates P=[x, y], then you have to translate those into log coordinates:
        xAxis = [log10(0) : log10(width)]
        yAxis = [log10(0) : log10(height)]
        P = [log10(x), log10(y)]

        I'm not sure if I have correctly understood this so if anyone can point out why my reasoning is wrong please tell me. Personally I think I'm mistakenly assuming that a point P shall be drawn at the log coordinates since this will be like having a linear axis with linear coordinates... I still have to try this.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Asperamanca
          wrote on 20 Mar 2014, 14:41 last edited by
          #4

          By "no built-in way" I meant there's no ready-to-use logarithmic transformation class, or such.
          There's nothing wrong with doing the required calculations yourself. All you need to do is mapping a logarithmic coordinate space to a linear coordinate space - basically what you do with 'P' above.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            T3STY
            wrote on 20 Mar 2014, 15:05 last edited by
            #5

            Thank you for help Asperamanca. yes, I understood what you meant by "no built-in way" above and it's not a problem for me to implement the necessary calculations. The real issue was to find out how to make it happen since I wasn't sure of which conversions Lin->Log I should apply (either point coordinate conversion or space size extension, or both). I'm now going to try a few combinations and check which one is right :)

            1 Reply Last reply
            0

            5/5

            20 Mar 2014, 15:05

            • Login

            • Login or register to search.
            5 out of 5
            • First post
              5/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved