views:

145

answers:

0

Hello. I'm using qwt chart package and have encountered a problem. I've tried to combine few examples from the web-page into one, and log10scaleEngine behaves strange together with curves that are filled with color.

The problem is with switching to log10scale: the curves are filled upwards (instead of downwards): 1) linear scale, 2) logarithmic.

So, here is how i plot the curves:

void
Chart::updateColors(int ind_)
{
       if (ind_ >= mCurves.size()) return;
       QwtPlotCurve *curve = mCurves[ind_];
       QColor c;
   QBrush b; QPen p;
               if (ind_ < mColorPickers.size())
               {
                       c=mColorPickers[ind_]->color();
               }

       if (this->steps())
               curve->setStyle(QwtPlotCurve::Steps);

       switch (ind_)
               {
               case 0 :
                       b.setStyle(Qt::BDiagPattern); break;
               case 1 :
                       b.setStyle(Qt::FDiagPattern); break;
               default:
                       b.setStyle(Qt::SolidPattern);
               }

       curve->setRenderHint(QwtPlotItem::RenderAntialiased);
       p.setColor(c);

       QBrush symB;
       symB.setColor(c);
       symB.setStyle(Qt::SolidPattern);

       QColor bg = c;
       bg.setRed(bg.red() - 30);
       bg.setGreen(bg.green() - 30);
       bg.setBlue(bg.blue() - 30);
       bg.setAlpha(30);
       b.setColor(bg);

       QwtSymbol sym;
       sym.setSize(10);
       sym.setBrush(symB);
       sym.setPen(p);

       if (ind_ == 0)
               sym.setStyle(QwtSymbol::Ellipse);
       if (ind_ ==1)
               sym.setStyle(QwtSymbol::Diamond);
       if (ind_ ==2)
               sym.setStyle(QwtSymbol::Triangle);
       if (ind_ ==3)
               sym.setStyle(QwtSymbol::Cross);
       sym.setPen(p);
   sym.setSize(7);
       if (!mSteps)
               curve->setSymbol(sym);
       curve->setBrush(b);
       curve->setPen(p);
       curve->attach(this);
}

And here is how i switch between logarithmic and linear scales:

void
Chart::toLogScale()
{
       log10scale = !log10scale;
       if (log10scale)
               setAxisScaleEngine(QwtPlot::yLeft, new QwtLog10ScaleEngine);
       else
               setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);

       updateColors();
}

Any idea how I can fix this? Thank you very much in advance, appreciate your time!