Results 1 to 8 of 8

Thread: Phasor Plotting with QwtPolar (drawing rays on a polar coordinate grid)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2012
    Posts
    18
    Qt products
    Qt4
    Platforms
    Windows

    Default Phasor Plotting with QwtPolar (drawing rays on a polar coordinate grid)

    I'm trying to draw rays on a phasor coordinate plane and I have no idea what function to use or any example code that I could follow, in the Qwt Polar Documentation I found a drawRays method but the arguments are way too confusing. I'm using a QwtPhasorGrid. Could someone who has done this before help me, preferably with code examples? Thanks!

    Here's my code:
    phasor-plot.cpp

  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: Phasor Plotting with QwtPolar (drawing rays on a polar coordinate grid)

    There is no QwtPhasorGrid and the code you have posted shows nothing - so what do you want to display how ?

    Uwe

  3. #3
    Join Date
    Jan 2012
    Posts
    18
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Phasor Plotting with QwtPolar (drawing rays on a polar coordinate grid)

    Well, I'm trying to draw rays on a polar coordinate plane, the code in my first post will display a polar coordinate grid but I don't know how to plot a ray from the origin given the degrees and magnitude of the line. I was kind of forced to use something that someone didn't finish and he is now gone.

  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: Phasor Plotting with QwtPolar (drawing rays on a polar coordinate grid)

    Quote Originally Posted by bwnicewo View Post
    Well, I'm trying to draw rays on a polar coordinate plane, the code in my first post will display a polar coordinate grid but I don't know how to plot a ray from the origin given the degrees and magnitude of the line.
    The grid lines are rendered according to the ticks of the scales. If you want to to modify the grid ( having lines at different angles ) you have to modify the scale for the azimuth ( QwtPolar::AxisAzimuth ) - or configure the autoscaler that is responsible for calculating this scale. Check the QwtPolarPlot::setAxisXY methods.

    You can change the pen, that is used for drawing the grid lines by QwtPolarGrid::setMajorGridPen/setMinorGridPen - if this is what you mean by magnitude.

    In general drawing something to a plot widget is done by configuring and attaching Qwt plot item - or implementing your own type of plot items.

    Uwe

  5. #5
    Join Date
    Jan 2012
    Posts
    18
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Phasor Plotting with QwtPolar (drawing rays on a polar coordinate grid)

    Yeah, I wanted to attach an item to the plot, but I'm worried that I'll have to impliment my own plot item for just drawing a simple line from the origin, I would think there should just be a function to draw a line like drawLine or something that takes the length of the line and angle of the line.

  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: Phasor Plotting with QwtPolar (drawing rays on a polar coordinate grid)

    You can't simply draw to a widget - this is not how Qt works. On most platforms you can't event paint outside paint events at all. You also need to take care of the plot -> widget transformation, that is changing on different type of layout events or when zooming in/out. But having a class around a couple of lines of render code ( this is what your is plot item about) is nothing to be afraid of.

    QwtPlotMarker has a mode for drawing such a line - but I simply forgot to add a similar feature to QwtPolarMarker.

    Uwe

  7. #7
    Join Date
    Jan 2012
    Posts
    18
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Phasor Plotting with QwtPolar (drawing rays on a polar coordinate grid)

    What I have now to post the data is this:

    d_grid = new QwtPolarGrid();
    d_grid->setPen(QPen(Qt::white));
    for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ )
    {
    d_grid->showGrid(scaleId);
    d_grid->showMinorGrid(scaleId);

    QPen minorPen(Qt::gray);
    #if 0
    minorPen.setStyle(Qt::DotLine);
    #endif
    d_grid->setMinorGridPen(scaleId, minorPen);
    }
    d_grid->setAxisPen(QwtPolar::AxisAzimuth, QPen(Qt::black));

    d_grid->showAxis(QwtPolar::AxisAzimuth, true);
    d_grid->showAxis(QwtPolar::AxisLeft, false);
    d_grid->showAxis(QwtPolar::AxisRight, false);
    d_grid->showAxis(QwtPolar::AxisTop, false);
    d_grid->showAxis(QwtPolar::AxisBottom, false);
    d_grid->showGrid(QwtPolar::Azimuth, true);
    d_grid->showGrid(QwtPolar::Radius, true);
    d_grid->attach(this);

    // curves
    m_curve = new QwtPolarCurve();
    m_curve->setPen(QPen(Qt::red));
    m_curve->setData(SinData(0,10));
    m_curve->setPen(QPen(Qt::red));
    m_curve->attach(this);
    replot();

    SinData is a class to return a QwtData pointer to setData, the arguments are an angle offset and amplitude of the line respectively. I'm attaching it to a QwtPolarPlot, the problem is I'm not seeing anything on the grid.

    This wasn't my code, someone else wrote it.

  8. #8
    Join Date
    Mar 2013
    Location
    Poland
    Posts
    15
    Thanks
    2
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: Phasor Plotting with QwtPolar (drawing rays on a polar coordinate grid)

    bwnicewo, You solved it?

Similar Threads

  1. Replies: 0
    Last Post: 19th January 2012, 18:21
  2. Drawing a grid
    By LevelFour in forum Newbie
    Replies: 1
    Last Post: 14th February 2010, 17:38
  3. How to rotate qwt polar coordinate?
    By qmonkey in forum Qwt
    Replies: 5
    Last Post: 27th January 2010, 10:49
  4. Qwt Polar 0.1.0 - Qwt 5.2.0 - Qt 4.6.0
    By ronanf235 in forum Qt-based Software
    Replies: 1
    Last Post: 7th January 2010, 17:24
  5. drawing a grid
    By dreamer in forum Qt Programming
    Replies: 2
    Last Post: 27th April 2008, 10:17

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.