本文整理汇总了C++中QwtPlotCurve::symbol方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtPlotCurve::symbol方法的具体用法?C++ QwtPlotCurve::symbol怎么用?C++ QwtPlotCurve::symbol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtPlotCurve
的用法示例。
在下文中一共展示了QwtPlotCurve::symbol方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSymbolSize
int CurvesModel::getSymbolSize(int row) const {
SolvWidget* solv = solvers->at(row);
QwtPlotCurve* curve = solv->curve;
if(curve->symbol() != NULL && curve->symbol()->style() != QwtSymbol::NoSymbol) {
return curve->symbol()->size().width();
}
return 7;
}
示例2: getSymbolColor
QColor CurvesModel::getSymbolColor(int row) const {
SolvWidget* solv = solvers->at(row);
QwtPlotCurve* curve = solv->curve;
if(curve->symbol() != NULL && curve->symbol()->style() != QwtSymbol::NoSymbol) {
return curve->symbol()->pen().color();
}
return curve->pen().color();
}
示例3: flags
Qt::ItemFlags CurvesModel::flags(const QModelIndex& index) const
{
SolvWidget* solv = solvers->at(index.row());
QwtPlotCurve* curve = solv->curve;
if(index.column() < 5) return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
if(index.column() == 5 || index.column() == 6) {
if(curve->symbol() != NULL && curve->symbol()->style() != QwtSymbol::NoSymbol) {
return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
} else {
return Qt::NoItemFlags;
}
}
return QAbstractItemModel::flags(index);
}
示例4: symbolSizeValue
void PlotPropertiesGUI::symbolSizeValue(int value)
{
QwtPlotCurve *plotCurve = internalCurves.value(currentCurve)->plotCurve;
// Changes only the symbol width
QwtSymbol symbol = plotCurve->symbol();
symbol.setStyle((QwtSymbol::Style) (ui->curveSymbolCombo->currentIndex() - 1)); // starts in -1
if (symbol.brush().style() != Qt::NoBrush)
symbol.setBrush(QBrush(plotCurve->pen().color()));
symbol.setSize(value);
plotCurve->setSymbol(symbol);
plotter->replot();
}
示例5: selectedSymbol
void PlotPropertiesGUI::selectedSymbol(int value)
{
QwtPlotCurve *plotCurve = internalCurves.value(currentCurve)->plotCurve;
QwtSymbol symbol, oldSym = plotCurve->symbol();
symbol.setStyle((QwtSymbol::Style) (value - 1)); // starts in -1);
symbol.setSize(ui->symbolSizeSpinBox->value());
symbol.setPen(oldSym.pen());
if (symbol.brush().style() != Qt::NoBrush)
// symbol.setBrush(QBrush(oldSym.pen().color()));
symbol.setBrush(QBrush(plotCurve->pen().color()));
plotCurve->setSymbol(symbol);
plotter->replot();
}
示例6: consistCurveTab
void PlotPropertiesGUI::consistCurveTab(const QString &name)
{
QwtPlotCurve *plotCurve = internalCurves.value(name)->plotCurve;
QwtSymbol symbol = plotCurve->symbol();
ui->symbolSizeSpinBox->setValue( symbol.size().width() );
ui->curveSymbolCombo->setCurrentIndex( (int)symbol.style() + 1); // Starts in -1
// Fixes bug built when used 'plotCurve->symbol()'
plotCurve->setSymbol(symbol);
ui->curveWidthSpinBox->setValue( plotCurve->pen().width() );
ui->curveStyleCombo->setCurrentIndex( (int)plotCurve->style() );
ui->lineStylecombo->setCurrentIndex( (int)plotCurve->pen().style() );
ui->curveColorButton->setStyleSheet(QString(" border-radius: 4px; "
"border: 1px solid rgb(0, 0, 0); background-color: %1")
.arg(plotCurve->pen().color().name()));
}
示例7: onLegendChecked
void QcepPlot::onLegendChecked(const QVariant &itemInfo, bool on, int index)
{
// if (g_Application) {
// g_Application->printMessage(tr("QxrdPlot::onLegendChecked(%1,%2,%3)").arg(itemInfo.toString()).arg(on).arg(index));
// }
QwtPlotItem *item = infoToItem(itemInfo);
if (item) {
QwtPlotCurve *pc = dynamic_cast<QwtPlotCurve*>(item);
if (pc) {
QPen pen = pc->pen();
const QwtSymbol *oldsym = pc->symbol();
QwtSymbol *sym = NULL;
if (oldsym) {
sym = new QwtSymbol(oldsym->style(), oldsym->brush(), oldsym->pen(), oldsym->size());
}
if (on) {
pen.setWidth(3);
if (sym) {
sym->setSize(9,9);
}
} else {
pen.setWidth(1);
if (sym) {
sym->setSize(5,5);
}
}
pc->setPen(pen);
if (sym) {
pc->setSymbol(sym);
}
}
replot();
}
}
示例8: enableLegend
/*!
\brief Enable or disable the legend
\param tf \c TRUE (enabled) or \c FALSE (disabled)
\param curveKey Key of a existing curve.
If curveKey < 0 the legends for all
curves will be updated.
\sa QwtPlot::setAutoLegend()
\sa QwtPlot::setLegendPos()
*/
void QwtPlot::enableLegend(
#ifndef QWT_NO_LEGEND
bool enable, long curveKey
#else
bool, long
#endif
)
{
#ifndef QWT_NO_LEGEND
QwtPlotCurve *curCurve;
bool isUpdateEnabled = d_legend->isUpdatesEnabled();
d_legend->setUpdatesEnabled(FALSE);
if ( curveKey < 0 ) // legends for all curves
{
if ( enable )
{
if ( d_legend->itemCnt() < d_curves->count() )
{
// not all curves have a legend
d_legend->clear();
QIntDictIterator<QwtPlotCurve> itc(*d_curves);
itc.toFirst();
while ((curCurve = itc.current()))
{
d_legend->appendItem(curCurve->title(),
curCurve->symbol(), curCurve->pen(), itc.currentKey());
++itc;
}
}
}
else
{
if ( d_legend->itemCnt() > 0 )
d_legend->clear();
}
}
else
{
uint index = d_legend->findFirstKey(curveKey);
if ( enable )
{
curCurve = d_curves->find(curveKey);
if ( curCurve && ( index >= d_legend->itemCnt() ) )
{
// curve exists and has no legend
d_legend->appendItem(curCurve->title(),
curCurve->symbol(), curCurve->pen(), curveKey);
}
}
else
{
if ( index < d_legend->itemCnt() )
d_legend->removeItem(index);
}
}
d_legend->setUpdatesEnabled(isUpdateEnabled);
updateLayout();
#endif
}
示例9: reset
/*!
Reset color and fonts of a plot
\sa QwtPlotPrintFilter::apply
*/
void QwtPlotPrintFilter::reset(QwtPlot *plot) const
{
if ( d_cache == 0 )
return;
QFont *font;
QColor *color;
if ( plot->d_lblTitle )
{
QPalette palette = plot->d_lblTitle->palette();
palette.setColor(
QPalette::Active, QColorGroup::Foreground, d_cache->titleColor);
plot->d_lblTitle->setPalette(palette);
plot->d_lblTitle->setFont(d_cache->titleFont);
}
if ( plot->d_legend )
{
QIntDictIterator<QWidget> it = plot->d_legend->itemIterator();
for ( QWidget *w = it.toFirst(); w != 0; w = ++it)
{
const int key = it.currentKey();
font = d_cache->legendFonts.find(key);
if ( font )
w->setFont(*font);
if ( w->inherits("QwtLegendButton") )
{
QwtLegendButton *btn = (QwtLegendButton *)w;
QwtSymbol symbol = btn->symbol();
color = d_cache->curveSymbolPenColors.find(key);
if ( color )
{
QPen pen = symbol.pen();
pen.setColor(*color);
symbol.setPen(pen);
}
color = d_cache->curveSymbolBrushColors.find(key);
if ( color )
{
QBrush brush = symbol.brush();
brush.setColor(*color);
symbol.setBrush(brush);
}
btn->setSymbol(symbol);
color = d_cache->curveColors.find(key);
if ( color )
{
QPen pen = btn->curvePen();
pen.setColor(*color);
btn->setCurvePen(pen);
}
}
}
}
for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
{
QwtScale *scale = plot->d_scale[axis];
if ( scale )
{
QPalette palette = scale->palette();
palette.setColor(QPalette::Active, QColorGroup::Foreground,
d_cache->scaleColor[axis]);
scale->setPalette(palette);
scale->setFont(d_cache->scaleFont[axis]);
scale->setTitleColor(d_cache->scaleTitleColor[axis]);
scale->setTitleFont(d_cache->scaleTitleFont[axis]);
int startDist, endDist;
scale->minBorderDist(startDist, endDist);
scale->setBorderDist(startDist, endDist);
}
}
plot->setBackgroundColor(d_cache->widgetBackground);
plot->setCanvasBackground(d_cache->canvasBackground);
QPen pen = plot->d_grid->majPen();
pen.setColor(d_cache->gridColors[0]);
plot->d_grid->setMajPen(pen);
pen = plot->d_grid->minPen();
pen.setColor(d_cache->gridColors[1]);
plot->d_grid->setMinPen(pen);
QIntDictIterator<QwtPlotCurve> itc(*plot->d_curves);
for (QwtPlotCurve *c = itc.toFirst(); c != 0; c = ++itc )
{
const int key = itc.currentKey();
//.........这里部分代码省略.........
示例10: apply
/*!
Change color and fonts of a plot
\sa QwtPlotPrintFilter::apply
*/
void QwtPlotPrintFilter::apply(QwtPlot *plot) const
{
QwtPlotPrintFilter *that = (QwtPlotPrintFilter *)this;
delete that->d_cache;
that->d_cache = new QwtPlotPrintFilterCache;
QwtPlotPrintFilterCache &cache = *that->d_cache;
if ( plot->d_lblTitle )
{
QPalette palette = plot->d_lblTitle->palette();
cache.titleColor = palette.color(
QPalette::Active, QColorGroup::Foreground);
palette.setColor(QPalette::Active, QColorGroup::Foreground,
color(cache.titleColor, Title));
plot->d_lblTitle->setPalette(palette);
cache.titleFont = plot->d_lblTitle->font();
plot->d_lblTitle->setFont(font(cache.titleFont, Title));
}
if ( plot->d_legend )
{
QIntDictIterator<QWidget> it = plot->d_legend->itemIterator();
for ( QWidget *w = it.toFirst(); w != 0; w = ++it)
{
const int key = it.currentKey();
cache.legendFonts.insert(it.currentKey(), new QFont(w->font()));
w->setFont(font(w->font(), Legend, key));
if ( w->inherits("QwtLegendButton") )
{
QwtLegendButton *btn = (QwtLegendButton *)w;
QwtSymbol symbol = btn->symbol();
QPen pen = symbol.pen();
QBrush brush = symbol.brush();
pen.setColor(color(pen.color(), CurveSymbol, key));
brush.setColor(color(brush.color(), CurveSymbol, key));
symbol.setPen(pen);
symbol.setBrush(brush);
btn->setSymbol(symbol);
pen = btn->curvePen();
pen.setColor(color(pen.color(), Curve, key));
btn->setCurvePen(pen);
}
}
}
for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
{
QwtScale *scale = plot->d_scale[axis];
if ( scale )
{
cache.scaleColor[axis] = scale->palette().color(
QPalette::Active, QColorGroup::Foreground);
QPalette palette = scale->palette();
palette.setColor(QPalette::Active, QColorGroup::Foreground,
color(cache.scaleColor[axis], AxisScale, axis));
scale->setPalette(palette);
cache.scaleFont[axis] = scale->font();
scale->setFont(font(cache.scaleFont[axis], AxisScale, axis));
cache.scaleTitleColor[axis] = scale->titleColor();
scale->setTitleColor(
color(cache.scaleTitleColor[axis], AxisTitle, axis));
cache.scaleTitleFont[axis] = scale->titleFont();
scale->setTitleFont(
font(cache.scaleTitleFont[axis], AxisTitle, axis));
int startDist, endDist;
scale->minBorderDist(startDist, endDist);
scale->setBorderDist(startDist, endDist);
}
}
cache.widgetBackground = plot->backgroundColor();
plot->setBackgroundColor(color(cache.widgetBackground, WidgetBackground));
cache.canvasBackground = plot->canvasBackground();
plot->setCanvasBackground(color(cache.canvasBackground, CanvasBackground));
QPen pen = plot->d_grid->majPen();
cache.gridColors[0] = pen.color();
pen.setColor(color(pen.color(), MajorGrid));
plot->d_grid->setMajPen(pen);
pen = plot->d_grid->minPen();
cache.gridColors[1] = pen.color();
pen.setColor(color(pen.color(), MinorGrid));
plot->d_grid->setMinPen(pen);
//.........这里部分代码省略.........
示例11: reset
void QwtPlotPrintFilter::reset(QwtPlotItem *item) const
{
if ( d_data->cache == 0 )
return;
const PrivateData::Cache &cache = *d_data->cache;
switch(item->rtti())
{
case QwtPlotItem::Rtti_PlotGrid:
{
QwtPlotGrid *grid = (QwtPlotGrid *)item;
QPen pen = grid->majPen();
pen.setColor(cache.gridColors[0]);
grid->setMajPen(pen);
pen = grid->minPen();
pen.setColor(cache.gridColors[1]);
grid->setMinPen(pen);
break;
}
case QwtPlotItem::Rtti_PlotCurve:
{
QwtPlotCurve *c = (QwtPlotCurve *)item;
QwtSymbol symbol = c->symbol();
if ( cache.curveSymbolPenColors.contains(c) )
{
symbol.setPen(cache.curveSymbolPenColors[c]);
}
if ( cache.curveSymbolBrushColors.contains(c) )
{
QBrush brush = symbol.brush();
brush.setColor(cache.curveSymbolBrushColors[c]);
symbol.setBrush(brush);
}
c->setSymbol(symbol);
if ( cache.curveColors.contains(c) )
{
QPen pen = c->pen();
pen.setColor(cache.curveColors[c]);
c->setPen(pen);
}
break;
}
case QwtPlotItem::Rtti_PlotMarker:
{
QwtPlotMarker *m = (QwtPlotMarker *)item;
if ( cache.markerFonts.contains(m) )
{
QwtText label = m->label();
label.setFont(cache.markerFonts[m]);
m->setLabel(label);
}
if ( cache.markerLabelColors.contains(m) )
{
QwtText label = m->label();
label.setColor(cache.markerLabelColors[m]);
m->setLabel(label);
}
if ( cache.markerLineColors.contains(m) )
{
QPen pen = m->linePen();
pen.setColor(cache.markerLineColors[m]);
m->setLinePen(pen);
}
QwtSymbol symbol = m->symbol();
if ( cache.markerSymbolPenColors.contains(m) )
{
QPen pen = symbol.pen();
pen.setColor(cache.markerSymbolPenColors[m]);
symbol.setPen(pen);
}
if ( cache.markerSymbolBrushColors.contains(m) )
{
QBrush brush = symbol.brush();
brush.setColor(cache.markerSymbolBrushColors[m]);
symbol.setBrush(brush);
}
m->setSymbol(symbol);
break;
}
default:
break;
}
}
示例12: apply
void QwtPlotPrintFilter::apply(QwtPlotItem *item) const
{
PrivateData::Cache &cache = *d_data->cache;
switch(item->rtti())
{
case QwtPlotItem::Rtti_PlotGrid:
{
QwtPlotGrid *grid = (QwtPlotGrid *)item;
QPen pen = grid->majPen();
cache.gridColors[0] = pen.color();
pen.setColor(color(pen.color(), MajorGrid));
grid->setMajPen(pen);
pen = grid->minPen();
cache.gridColors[1] = pen.color();
pen.setColor(color(pen.color(), MinorGrid));
grid->setMinPen(pen);
break;
}
case QwtPlotItem::Rtti_PlotCurve:
{
QwtPlotCurve *c = (QwtPlotCurve *)item;
QwtSymbol symbol = c->symbol();
QPen pen = symbol.pen();
cache.curveSymbolPenColors.insert(c, pen.color());
pen.setColor(color(pen.color(), CurveSymbol));
symbol.setPen(pen);
QBrush brush = symbol.brush();
cache.curveSymbolBrushColors.insert(c, brush.color());
brush.setColor(color(brush.color(), CurveSymbol));
symbol.setBrush(brush);
c->setSymbol(symbol);
pen = c->pen();
cache.curveColors.insert(c, pen.color());
pen.setColor(color(pen.color(), Curve));
c->setPen(pen);
break;
}
case QwtPlotItem::Rtti_PlotMarker:
{
QwtPlotMarker *m = (QwtPlotMarker *)item;
QwtText label = m->label();
cache.markerFonts.insert(m, label.font());
label.setFont(font(label.font(), Marker));
cache.markerLabelColors.insert(m, label.color());
label.setColor(color(label.color(), Marker));
m->setLabel(label);
QPen pen = m->linePen();
cache.markerLineColors.insert(m, pen.color());
pen.setColor(color(pen.color(), Marker));
m->setLinePen(pen);
QwtSymbol symbol = m->symbol();
pen = symbol.pen();
cache.markerSymbolPenColors.insert(m, pen.color());
pen.setColor(color(pen.color(), MarkerSymbol));
symbol.setPen(pen);
QBrush brush = symbol.brush();
cache.markerSymbolBrushColors.insert(m, brush.color());
brush.setColor(color(brush.color(), MarkerSymbol));
symbol.setBrush(brush);
m->setSymbol(symbol);
break;
}
default:
break;
}
}
示例13: data
QVariant CurvesModel::data(const QModelIndex& index, int role) const
{
SolvWidget* solv = solvers->at(index.row());
QwtPlotCurve * curve = solv->curve;
QColor col = curve->pen().color();
int bright = col.red() + 2*col.green() + col.blue();
QwtSymbol::Style symSty;
switch(index.column()) {
case 0:// title
switch(role) {
case Qt::DisplayRole :
case Qt::EditRole:
return solv->getTitle();
}
break;
case 1:// line color
switch(role) {
case Qt::BackgroundRole:
return QBrush(col);
case Qt::ForegroundRole:
if(bright > 600 ) return QBrush(Qt::darkGray);
return QBrush(Qt::white);
case Qt::DisplayRole:
return QVariant(colorName(col));
case Qt::EditRole:
case Qt::UserRole:
return QVariant(col);
}
break;
case 2:// line style
switch(role) {
case Qt::DecorationRole:
return penIcon(solv->curve->pen());
case Qt::DisplayRole :
return penStyles[solv->curve->pen().style()];
case Qt::EditRole :
return solv->curve->pen().style();
}
break;
case 3:// line width
switch(role) {
case Qt::DecorationRole:
return penIcon(solv->curve->pen());
case Qt::DisplayRole :
return QString("%1").arg(solv->curve->pen().widthF(),4,'f',2);
case Qt::EditRole :
return solv->curve->pen().widthF();
}
break;
case 4:// symbol style
if(curve->symbol() == NULL) {
symSty = QwtSymbol::NoSymbol;
} else {
symSty = curve->symbol()->style();
}
switch(role) {
case Qt::EditRole :
return QVariant(symSty);
case Qt::DisplayRole :
return SymbolStyleDelegate::symName(symSty);
}
break;
case 5:// symbol color
if(curve->symbol() != NULL && curve->symbol()->style() != QwtSymbol::NoSymbol) {
col= curve->symbol()->pen().color();
} // default to curve pen color
switch(role) {
case Qt::BackgroundRole:
return QBrush(col);
case Qt::ForegroundRole:
if(bright > 600 ) return QBrush(Qt::darkGray);
return QBrush(Qt::white);
case Qt::DisplayRole :
if(curve->symbol() == NULL || curve->symbol()->style() == QwtSymbol::NoSymbol) {
return ("No Symbol");
}
return QVariant(colorName(col)) ;
case Qt::EditRole:
case Qt::UserRole:
return QVariant(col);
}
break;
case 6: // symbol size
switch(role) {
//case Qt::DecorationRole:
//return penIcon(solv->curve->pen());
case Qt::DisplayRole :
if(curve->symbol() != NULL && curve->symbol()->style() != QwtSymbol::NoSymbol ) {
return QString("%1").arg(curve->symbol()->size().width());
}
break;
case Qt::EditRole :
case Qt::UserRole:
if(curve->symbol() != NULL && curve->symbol()->style() != QwtSymbol::NoSymbol ) {
return curve->symbol()->size().width();
}
return 7;
}
}
return QVariant();
//.........这里部分代码省略.........
示例14: setData
bool CurvesModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
SolvWidget* solv = solvers->at(index.row());
QwtPlotCurve* curve = solv->curve;
QPen pen = curve->pen(); /// This makes a copy of Pen
QColor col;
Qt::PenStyle ps;
QwtSymbol *symbol;
QwtSymbol::Style symbolStyle;
QBrush brush;
QSize symSize;
bool ok;
double lw;
int ss;
if( role != Qt::EditRole ) return false;
switch(index.column()) {
case 0:// title
if(value.toString().size() > 1) {
QString newTitle = value.toString();
if( newTitle != solv->getTitle() ) {
solv->setTitle(value.toString());
emit newdata();
return true;
}
}
return false;
case 1:// line color
col = value.value<QColor>();
if(pen.color() != col ) {
pen.setColor(col);
curve->setPen(pen);
solv->setColor(col);
emit newdata();
return true;
}
return false;
case 2:// line style
ps = Qt::PenStyle(value.toInt());
if( ps != pen.style()) {
pen.setStyle(ps);
curve->setPen(pen);
emit newdata();
return true;
}
return false;
case 3:// line width
lw = value.toDouble(&ok);
if(ok && (lw != curve->pen().widthF())) {
pen.setWidthF(lw);
curve->setPen(pen);
emit newdata();
return true;
}
return false;
case 4:// symbol style
symbolStyle = QwtSymbol::Style(value.toInt());
if(curve->symbol() == NULL) {
if(symbolStyle == QwtSymbol::NoSymbol ) return false;
pen.setStyle(Qt::SolidLine);
symbol = new QwtSymbol(symbolStyle,QBrush(),pen,QSize(7,7));//Qt::transparent
} else {
if(curve->symbol()->style() == symbolStyle) return false;
if(symbolStyle == QwtSymbol::NoSymbol) {
symbol = NULL;
} else {
symbol = new QwtSymbol(symbolStyle,curve->symbol()->brush(),curve->symbol()->pen(),curve->symbol()->size());
}
}
curve->setSymbol(symbol);
emit newdata();
return true;
case 5:// symbol color
col = value.value<QColor>();
if(curve->symbol() == NULL || curve->symbol()->style() == QwtSymbol::NoSymbol ) return false;
if(curve->symbol()->pen().color() == col ) return false;
pen = curve->symbol()->pen();
pen.setColor(col);
symbol = new QwtSymbol(curve->symbol()->style(),curve->symbol()->brush(),pen,curve->symbol()->size());
curve->setSymbol(symbol);
emit newdata();
return true;
case 6: // symbol size
ss = value.toInt();
if(ss < 1) return false;
if(curve->symbol() == NULL || curve->symbol()->style() == QwtSymbol::NoSymbol ) return false;
if(curve->symbol()->size().width() == ss ) return false;
symbol = new QwtSymbol(curve->symbol()->style(),curve->symbol()->brush(),curve->symbol()->pen(),QSize(ss,ss));
curve->setSymbol(symbol);
emit newdata();
return false;
}
return QAbstractItemModel::setData(index, value, role);
}