Results 1 to 3 of 3

Thread: qwtspectrogram axis adjustment for area not pixels

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2014
    Posts
    10
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: qwtspectrogram axis adjustment for area not pixels

    here is a class that converts double value of scale into string and display instead

    Qt Code:
    1. class MyScaleDraw: public QwtScaleDraw
    2. {
    3. public:
    4. MyScaleDraw()
    5. {
    6. setTickLength( QwtScaleDiv::MajorTick, 10 );
    7. setTickLength( QwtScaleDiv::MinorTick, 2 );
    8. setTickLength( QwtScaleDiv::MediumTick, 0 );
    9.  
    10. setLabelRotation( 0 );
    11. setLabelAlignment( Qt::AlignLeft | Qt::AlignVCenter );
    12.  
    13. setSpacing( 10 );
    14. }
    15.  
    16. virtual QwtText label( double value ) const
    17. {
    18. QwtText h=QwtText(QString::number(value*0.75); //use any scaling factor you want
    19. return h;
    20. }
    21. };
    To copy to clipboard, switch view to plain text mode 

    include the following below code after creating a plot


    Qt Code:
    1. d_plot->setAxisScaleDraw( QwtPlot::xBottom, new MyScaleDraw() );
    2. d_plot->setAxisScaleDraw( QwtPlot::yLeft, new MyScaleDraw() );
    To copy to clipboard, switch view to plain text mode 

    this solved my problem

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

    Default Re: qwtspectrogram axis adjustment for area not pixels

    I'm not 100% sure if I understand your initial mail exactly, but it looks like all you want to is to display a 500x500 matrix of values inside an area of a different size ( f.e 100x200 ) in plot coordinates :

    Qt Code:
    1. rasterdata->setInterval( Qt::XAxis, QwtInterval( 0.0, 100 ) );
    2. rasterdata->setInterval( Qt::YAxis, QwtInterval( 0.0, 200 ) );
    To copy to clipboard, switch view to plain text mode 
    If you are using QwtMatrixRaterData this would be all, otherwise it might be a good idea to implement YourRasterData::pixelHint() returning the size of one data pixel.

    With using your label transformation you are faking a different coordinate system to the user, than the one that is used by the plot. You will have effects, that the ticks are not aligned to your faked coordinate system, labels at other places ( picker/zoom ) might be wrong etc.

    Uwe

Similar Threads

  1. Replies: 1
    Last Post: 11th February 2014, 21:31
  2. QTreeView automatic Widget Height adjustment
    By mqt in forum Qt Programming
    Replies: 2
    Last Post: 5th October 2013, 11:42
  3. Replies: 5
    Last Post: 28th November 2011, 07:20
  4. Replies: 1
    Last Post: 8th October 2011, 19:15
  5. How to adddata for qwtspectrogram
    By centroid in forum Qwt
    Replies: 2
    Last Post: 2nd August 2010, 13:36

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
  •  
Qt is a trademark of The Qt Company.