Results 1 to 6 of 6

Thread: Infinite filling area curve

  1. #1

    Question Infinite filling area curve

    Hi all. I'm using qwt 5.2.2. I'm trying to make kind of filling area between two lines. Lines can be infinite in horizontal. I'm using DBL_MIN and DBL_MAX.
    Lines are inherit from QwtPlotMarker. If my lines are infinite, I create them using setYValue(double), if not - setValue(double, double).
    Code for my filling area:
    Qt Code:
    1. QwtPlotCurve* fillingAreaCurve = new QwtPlotCurve;
    2.  
    3. fillingAreaCurve->setItemAttribute(QwtPlotItem::Legend, false);
    4. fillingAreaCurve->setStyle(QwtPlotCurve::Lines);
    5. fillingAreaCurve->setPen(QPen(Qt::gray, 1, Qt::SolidLine));
    6. fillingAreaCurve->setBrush(QBrush(QColor(150, 150, 150, 127),Qt::SolidPattern));
    7. fillingAreaCurve->setBaseline(baseline);
    8. fillingAreaCurve->setData(xData, yData, 2);
    To copy to clipboard, switch view to plain text mode 

    Where xData is array, xData[0] = DBL_MIN, xData[1] = DBL_MAX. After that, i do attach(plot) and replot().
    The problem is that my program freeze. I tried to separate them to two areas - from DBL_MIN to 0 and from 0 to DBL_MAX - nothing changed.
    Any ideas?

    P.S.: Sorry for my horrible English.

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

    Default Re: Infinite filling area curve

    Quote Originally Posted by SandyEmerald View Post
    Hi all. I'm using qwt 5.2.2. I'm trying to make kind of filling area between two lines.
    Upgrade to Qwt 6.x and use QwtPlotIntervalCurve.

    Uwe

  3. #3

    Default Re: Infinite filling area curve

    I can't do it. It does not depend on me.

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

    Default Re: Infinite filling area curve

    Then tell the guys where it depends on, that I have said, that implementing this feature with Qwt 5.x will be a pain.

    Uwe

  5. #5

    Default Re: Infinite filling area curve

    So, could you please help to do the same thing with QwtPlotMarker? My idea is in using pen with semitransparent color. How i can draw ending line with QwtPlotMarker?
    I coded:
    Qt Code:
    1. QwtPlotMarker *marker = new QwtPlotMarker();
    2. QPen pen;
    3. pen.setColor(QColor(150, 150, 150, 127));
    4. marker->setLineStyle(QwtPlotMarker::HLine);
    To copy to clipboard, switch view to plain text mode 

    So, now, if i'd want to draw infinite filling area, i could calculate pen width and use
    Qt Code:
    1. pen.setWidthF(width);
    2. marker->setLinePen(pen);
    3. setYValue(y);
    To copy to clipboard, switch view to plain text mode 

    and what about ending line? help please

  6. #6

    Default Re: Infinite filling area curve

    Problem of the code posted in first message is that qwt tries to calculate scales steps and other staff and can't do it correctly when min showed value is DBL_MIN and max = DBL_MAX. Anyway you most likely dont want your plot autoscaled to [DBL_MIN, DBL_MAX].
    I can suggest next solution - make your own data for curve:

    InfiniteData(const QwtPlot* plot, double left, double right, double y):
    m_plot(plot), m_boundingCurve(boundingCurve), m_left(left), m_right(right), m_y(y)
    {
    }

    virtual QwtData* copy () const
    {
    return new InfiniteData(m_plot, m_left, m_right, m_y);
    }

    virtual size_t size() const
    {
    return 2;
    }

    virtual double x(size_t i) const
    {
    const double x = (i == 0) ? m_left : m_right;
    const QwtScaleDiv* xScale = m_plot->axisScaleDiv(QwtPlot::xBottom);

    if(std::fabs(x - DBL_MIN) < std::numeric_limits<double>::epsilon())
    return xScale->lowerBound() - xScale->range();

    if(std::fabs(DBL_MAX - x) < std::numeric_limits<double>::epsilon())
    return xScale->upperBound() + xScale->range();

    return x;
    }

    virtual double y(size_t i) const
    {
    return m_y;
    }

    virtual QwtDoubleRect boundingRect() const
    {
    return QwtDoubleRect(); //But your plot will always replot in such way to contain [0, 0] point. You can change it as you need
    }

    private:
    const QwtPlot* m_plot;
    const double m_left;
    const double m_right;
    const double m_y;
    };

    And then use it like:
    QwtPlotCurve* fillingAreaCurve = new QwtPlotCurve;
    fillingAreaCurve->setItemAttribute(QwtPlotItem::Legend, false);
    fillingAreaCurve->setStyle(QwtPlotCurve::Lines);
    fillingAreaCurve->setPen(QPen(Qt::gray, 1, Qt::SolidLine));
    fillingAreaCurve->setBrush(QBrush(QColor(150, 150, 150, 127),Qt::SolidPattern));
    fillingAreaCurve->setBaseline(firstYValue);
    fillingAreaCurve->setData(InfiniteData(plot, DBL_MIN, DBL_MAX, secondYValue));

    And happiness will come!

Similar Threads

  1. Replies: 5
    Last Post: 17th December 2014, 12:07
  2. Replies: 3
    Last Post: 16th December 2014, 05:43
  3. Replies: 10
    Last Post: 7th March 2012, 18:22
  4. Replies: 2
    Last Post: 4th September 2011, 21:50
  5. Compute the area under a curve
    By giusepped in forum Qwt
    Replies: 0
    Last Post: 26th December 2008, 06:56

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.