void KstBaseCurve::updateParsedLegendTag() { delete _parsedLegendTag; if (_legendText.isEmpty()) { _parsedLegendTag = Label::parse(tagName(), false, false); } else { _parsedLegendTag = Label::parse(legendText(), true, false); } }
void Relation::updateParsedLegendTag() { delete _parsedLegendTag; if (_legendText.isEmpty()) { _parsedLegendTag = Label::parse(tag().tagString(), false, false); // FIXME: should this be displayString? } else { _parsedLegendTag = Label::parse(legendText(), true, false); } }
void caStripPlot::setLegendAttribute(QColor c, QFont f, LegendAtttribute SW) { int i; #if QWT_VERSION < 0x060100 for(i=0; i < NumberOfCurves; i++) { switch (SW) { case TEXT: if(thisLegendshow) { QwtText text; text.setText(legendText(i)); qobject_cast<QwtLegendItem*>(this->legend()->find(curve[i]))->setText(text); } break; case FONT: if(getLegendEnabled()) { if(legend() != (QwtLegend*) 0) { QList<QWidget *> list = legend()->legendItems(); for (QList<QWidget*>::iterator it = list.begin(); it != list.end(); ++it ) { QWidget *w = *it; w->setFont(f); } } } break; case COLOR: if(legend() != (QwtLegend*) 0) { QList<QWidget *> list = legend()->legendItems(); for (QList<QWidget*>::iterator it = list.begin(); it != list.end(); ++it ) { QWidget *w = *it; QPalette palette = w->palette(); palette.setColor( QPalette::WindowText, c); // for ticks palette.setColor( QPalette::Text, c); // for ticks' labels w->setPalette (palette); w->setFont(f); } } break; } } #else i=0; foreach (QwtPlotItem *plt_item, itemList()) { if ( plt_item->rtti() == QwtPlotItem::Rtti_PlotCurve ) { QwtLegend *lgd = qobject_cast<QwtLegend *>(legend()); QList<QWidget *> legendWidgets = lgd->legendWidgets(itemToInfo(plt_item)); if ( legendWidgets.size() == 1 ) { QwtLegendLabel *b = qobject_cast<QwtLegendLabel *>(legendWidgets[0]); switch (SW) { case TEXT: if(thisLegendshow) { QwtText text; text.setText(legendText(i++)); //printf("%s %s\n", b->plainText().toAscii().constData(), legendText(i-1).toAscii().constData()); b->setText(text); b->update(); } break; case FONT: //printf("%s %s\n", b->plainText().toAscii().constData(), legendText(i-1).toAscii().constData()); b->setFont(f); b->update(); break; case COLOR: //printf("%s %s\n", b->plainText().toAscii().constData(), legendText(i-1).toAscii().constData()); QPalette palette = b->palette(); palette.setColor( QPalette::WindowText, c); // for ticks palette.setColor( QPalette::Text, c); // for ticks' labels b->setPalette(palette); b->update(); break; } } } } #endif }
void caStripPlot::defineCurves(QStringList titres, units unit, double period, int width, int nbCurves) { int min, max; NumberOfCurves = nbCurves; Unit = unit; Period = period; scaleWidget->getBorderDistHint(min, max); savedTitres = titres; defineAxis(unit, period); // define curves for(int i=0; i < MAXCURVES; i++) { curvStyle s = Lines; QColor c; if(curve[i] != (QwtPlotCurve*) 0) { s = getStyle(i); c = getColor(i); delete curve[i]; } if(errorcurve[i] != (QwtPlotIntervalCurve*) 0) { delete errorcurve[i]; } if(fillcurve[i] != (QwtPlotIntervalCurve*) 0) { delete fillcurve[i]; } if(i < NumberOfCurves) { // set title and limits to legend QString titre = legendText(i); curve[i] = new QwtPlotCurve(titre); errorcurve[i] = new QwtPlotIntervalCurve(titre); fillcurve[i] = new QwtPlotIntervalCurve(titre); setStyle(s, i); curve[i]->setZ(i); curve[i]->attach(this); fillcurve[i]->setZ(i); fillcurve[i]->attach(this); fillcurve[i]->setItemAttribute(QwtPlotItem::Legend, false); errorcurve[i]->setZ(i); errorcurve[i]->attach(this); errorcurve[i]->setItemAttribute(QwtPlotItem::Legend, false); showCurve(i, false); realMax[i] = maxVal[i] = -1000000; realMin[i] = minVal[i] = 1000000; actVal[i] = realVal[i] = 0; } } showCurve(0, true); // draw legend if(thisLegendshow) { QwtLegend *lgd = new QwtLegend; insertLegend(lgd, QwtPlot::BottomLegend); // set color on legend texts setLegendAttribute(thisScaleColor, QFont("arial",9), COLOR); } RescaleCurves(width, unit, period); }