Vikram Nyamthi | 16 Apr 06:05
Picon

Problem in QwtPlotCurve

Hi All,

    I am newbie to qwt and qt. I am trying to alter the example data_plot so that a mark will appear on the graphs at some particular point.

        For this i used the following code

iValX = cRight->x(x);
        iValY = cLeft->y(x);
        printf("\n X & Y Val  = %d  %d\n",iValX,iValY);
   
        //if((x%10) == 0)
        if(iValX == 15)
        {
                 mY->setXValue(x);
            QPen p;
             const QColor oldcc = p.color();
        cRight->setSymbol(QwtSymbol(QwtSymbol::VLine,
            QBrush(c), QPen(c), QSize(1, 10)) );
        }   
        if(iValY == 15)
        {
        cLeft->setSymbol(QwtSymbol(QwtSymbol::VLine,
            QBrush(c), QPen(c), QSize(1, 10)) );
              }

           I am also attaching the graph i am able to plot .

            Can any one help me out to solve this problem.

         I am expecting a vertical lines on the curve when the value == 15 but, i am getting multiple vertical lines.



--
the biggest strength in the world is youth and the only strength that can conquer it is knowledge which we dont have cheers !!!!!!!!!!!!!!!!

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
qwt-interest mailing list
qwt-interest <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qwt-interest
Uwe Rathmann | 16 Apr 07:52
Picon

Re: Problem in QwtPlotCurve

Hi Vikram,

>     I am newbie to qwt and qt. I am trying to alter the example data_plot
> so that a mark will appear on the graphs at some particular point.

If these marks are not too many you can use QwtPlotMarker.

If you need to display symbols at particular curve points only you have to 
derive your own curve class and implement YourCurve::drawSymbols.

void YourCurve::drawSymbols(QPainter *painter, const QwtSymbol &symbol,
    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    int from, int to) const
{
    painter->setBrush(symbol.brush());
    painter->setPen(symbol.pen());

    QRect rect;
    rect.setSize(QwtPainter::metricsMap().screenToLayout(symbol.size()));

    for (int i = from; i <= to; i++)
    {
         if ( ... )
         {
             const int xi = xMap.transform(x(i));
             const int yi = yMap.transform(y(i));

             rect.moveCenter(QPoint(xi, yi));
             symbol.draw(painter, rect);
         }
     }
}

Uwe

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

Gmane