Results 1 to 3 of 3

Thread: QwtPolarPlot radius scale

  1. #1
    Join Date
    Feb 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default QwtPolarPlot radius scale

    Hello,
    I'm looking for how to create my own major and minor ticks on the scaleId
    QwtPolar::Radius.
    I tried :
    Qt Code:
    1. if (!d_prefDlg->get_pasZ_Auto()) {
    2. /* Récupération du pas choisi
    3.   ****************************/
    4. double pasz = d_prefDlg->get_pasZ();
    5.  
    6. /* Ajustement des extrema
    7.   ************************/
    8. nivmax = pasz*ceil(nivmax/pasz);
    9. nivmin = pasz*floor(nivmin/pasz);
    10.  
    11. /* Nombre de pas
    12.   ***************/
    13. double nbPas = ((int)(((nivmax-nivmin)/pasz)));
    14.  
    15. /* Recherche du meilleur pas principal
    16.   *************************************/
    17. double major;
    18. for(int ii=8; ii>1; ii--) {
    19. major = floor(nbPas/ii);
    20. if (major > 5)
    21. break;
    22. }
    23. double pasMajor = major*pasz;
    24. int nbPasminor = floor(pasMajor/pasz);
    25. d_polarplot->setScale(QwtPolar::Radius,nivmin, nivmax, pasMajor);
    26. d_polarplot->setScaleMaxMajor(QwtPolar::Radius, major);
    27. d_polarplot->setScaleMaxMinor(QwtPolar::Radius, nbPasminor);
    28.  
    29.  
    30. /* Création des pas principaux et secondaires
    31.   ********************************************/
    32. QList<double> ticksR[QwtScaleDiv::NTickTypes];
    33. QList<double> &majorTicksR = ticksR[QwtScaleDiv::MajorTick];
    34. QList<double> &minorTicksR = ticksR[QwtScaleDiv::MinorTick];
    35. for (double niveau=nivmin; niveau <= nivmax; niveau=niveau+pasz) {
    36. if (fmod((niveau-nivmin),major*pasz) == 0) {
    37. majorTicksR.append(niveau);
    38. } else {
    39. minorTicksR.append(niveau);
    40. }
    41. }
    42.  
    43. QwtScaleDiv myScaleDivR = QwtScaleDiv(majorTicksR.first(),
    44. majorTicksR.last(), ticksR);
    45. d_polarplot->setScaleDiv(QwtPolar::Radius, myScaleDivR);
    46. if (d_polarplot->scaleDiv(QwtPolar::Radius)->isValid() == false)
    47. Message("Invalide", false);
    48.  
    49. } else
    50. d_polarplot->setScale(QwtPolar::Radius,nivmin, nivmax);
    To copy to clipboard, switch view to plain text mode 
    With nivmin = -93, nivmax=-39 and pasz=3, I should get the following major
    ticks :-93,-75,-57 and -39, with 6 minor ticks between 2 major ticks.

    But that did'nt work (see attach file).

    Thanks for your help
    Attached Images Attached Images

  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: QwtPolarPlot radius scale

    The boundaries and all major and minor ticks of a scale are defined in a QwtScaleDiv object. You can calculate a QwtScaleDiv object in your application code and pass it to the plot using QwtPolarPlot::setScaleDiv().

    A plot widget has a scale engine for each scale, that is able to calculate a QwtScaleDiv object from min/max/stepsize ( + max major steps + max minor steps ). QwtPolarPlot::setScale() calculates internally a QwtScaleDiv using the internal scale engine.

    Qwt offers two different types of scale engines: a linear and logarithmic one, both based on decades.

    The right solution for your problem depends on whether your plot offers a navigation ( zooming, panning, ... ). If not you can manually calculate your ticks and use QwtPolarPlot::setScaleDiv() - not using the internal scale engine.

    But if your plot offers navigation you need to implement an algorithm, that calculates ticks for any random boundaries for your -93 +i * 18 based scale system ( what ticks do you expect from a range -90 -> -89 ? ) in a class derived from QwtScaleEngine.

    Uwe

  3. #3
    Join Date
    Feb 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QwtPolarPlot radius scale (resolved)

    Hello,

    I resolved my problem. The QwtPolar documentation indicates that using setScaleDiv the autoscalling is disabled, but in fact you should disable the autoscaling in the QwtPolarGrid:
    Qt Code:
    1. this->d_grid = new QwtPolarGrid();
    2. if (!d_prefDlg->get_pasZ_Auto())
    3. d_grid->setGridAttribute(QwtPolarGrid::AutoScaling,false);
    4. else
    5. d_grid->setGridAttribute(QwtPolarGrid::AutoScaling,true);
    6.  
    7. ....
    8. d_grid->attach(d_polarplot);
    To copy to clipboard, switch view to plain text mode 

    Thank a lot

Similar Threads

  1. Border radius unix/windows
    By dacrawler in forum Newbie
    Replies: 2
    Last Post: 23rd January 2011, 14:27
  2. RADIUS SERVER and Qt 4.7
    By rmagro in forum Qt Programming
    Replies: 0
    Last Post: 18th November 2010, 15:51
  3. QFrame with border-radius inside QGraphicsScene
    By DeRatizator in forum Qt Programming
    Replies: 2
    Last Post: 23rd August 2010, 09:39
  4. qwt 5 log scale..
    By halberdier83 in forum Qwt
    Replies: 7
    Last Post: 12th November 2007, 08:21
  5. My own scale widget in Qwt
    By igrms in forum Qwt
    Replies: 7
    Last Post: 15th June 2006, 22: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.