QwtSymbol *SAQwtPlotCurveItemSetWidget::makeSymbol(QwtSymbol::Style style) { if(nullptr == m_curveItem) { return nullptr; } const QwtSymbol* oldSymbol = m_curveItem->symbol(); QwtSymbol* newSymbol = nullptr; if(QwtSymbol::NoSymbol != style) { newSymbol = new QwtSymbol(style); if(nullptr == oldSymbol) { //初始没有符号,第一次设置 QColor penColor = m_curveItem->pen().color(); newSymbol->setPen(penColor); penColor.setAlpha(80); newSymbol->setBrush(QBrush(penColor)); newSymbol->setSize(6,6); } else { newSymbol->setPen(oldSymbol->pen()); newSymbol->setBrush(oldSymbol->brush()); newSymbol->setSize(oldSymbol->size()); } } return newSymbol; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), config(), configUI(&config), experiment(&config, this), qwtPlotCurveHallU("Hall U"), qwtPlotCurveResistivity("Resistivity"), ui(new Ui::MainWindow) { experiment.setObjectName("experiment"); ui->setupUi(this); QObject::connect(&configUI, SIGNAL(accepted()), this, SLOT(show())); QObject::connect(&experiment, SIGNAL(coilBMeasured(double)), ui->coilBDoubleSpinBox, SLOT(setValue(double))); QObject::connect(&experiment, SIGNAL(coilIMeasured(double)), ui->coilCurrMeasDoubleSpinBox, SLOT(setValue(double))); QObject::connect(&experiment, SIGNAL(coilUMeasured(double)), ui->coilVoltMeasDoubleSpinBox, SLOT(setValue(double))); ui->qwtPlot->enableAxis(QwtPlot::yRight, true); QString titleTpl("<html><body><span style=\"font-family:'Sans Serif'; font-size:14pt; font-weight:600; font-style:bold;\"><span style=\"%1\">%2</span> %3</span></body></html>"); QwtText titleHall(titleTpl.arg("color: red;").arg("×").arg("hall U [V]")); QwtText titleR(titleTpl.arg("color: lime;").arg("*").arg("Resistivity [Ω]")); ui->qwtPlot->setAxisTitle(QwtPlot::yLeft, titleHall); ui->qwtPlot->setAxisTitle(QwtPlot::yRight, titleR); ui->qwtPlot->setAxisTitle(QwtPlot::xBottom, "B [T]"); qwtPlotCurveHallU.attach(ui->qwtPlot); qwtPlotCurveResistivity.attach(ui->qwtPlot); qwtPlotCurveHallU.setStyle(QwtPlotCurve::NoCurve); qwtPlotCurveResistivity.setStyle(QwtPlotCurve::NoCurve); QwtSymbol *qwtPlotHallUSymbol = new QwtSymbol(QwtSymbol::XCross); QwtSymbol *qwtPlotResistivitySymbol = new QwtSymbol(QwtSymbol::Star1); qwtPlotHallUSymbol->setColor(QColor(255, 0, 0)); qwtPlotResistivitySymbol->setColor(QColor(0, 255, 0)); qwtPlotHallUSymbol->setSize(QSize(12, 12)); qwtPlotResistivitySymbol->setSize(QSize(12, 12)); QPen hallSymbolPen(qwtPlotHallUSymbol->pen()); QPen resistivitySymbolPen(qwtPlotResistivitySymbol->pen()); hallSymbolPen.setWidth(2); resistivitySymbolPen.setWidth(2); qwtPlotHallUSymbol->setPen(hallSymbolPen); qwtPlotResistivitySymbol->setPen(resistivitySymbolPen); qwtPlotCurveResistivity.setYAxis(QwtPlot::yRight); qwtPlotCurveHallU.setSymbol(qwtPlotHallUSymbol); qwtPlotCurveResistivity.setSymbol(qwtPlotResistivitySymbol); ui->dataTableWidget->resizeColumnsToContents(); }
void VectorPlot::addDotPlot(const MarkupQwtAdapter&adapter, QColor color, const QString &name, bool addToLegend) { QwtPlotCurve *curve = new QwtPlotCurve(name); QwtSymbol sym; sym.setPen(QColor(color)); sym.setBrush(QColor(color)); sym.setStyle(QwtSymbol::Rect); sym.setSize( QSize(1, 20) ); curve->setSymbol(sym); curve->setStyle(QwtPlotCurve::NoCurve); if(adapter.size() > 0) { setupPlot(adapter.boundingRect()); curve->setData(adapter); curve->attach(plot); } if(!legend) { return; } // Добавляем кривую в легенду QwtLegendItem *item = new QwtLegendItem(0); item->setText(curve->title()); item->setSymbol(sym); item->setIdentifierMode(QwtLegendItem::ShowLine | QwtLegendItem::ShowSymbol | QwtLegendItem::ShowText); legend->insert(curve, item); }
void PfPvPlot::configChanged() { setCanvasBackground(GColor(CPLOTBACKGROUND)); // frame with inverse of background QwtSymbol *sym = new QwtSymbol; sym->setStyle(QwtSymbol::Ellipse); sym->setSize(4); sym->setPen(QPen(Qt::red)); sym->setBrush(QBrush(Qt::red)); curve->setSymbol(sym); curve->setStyle(QwtPlotCurve::Dots); curve->setRenderHint(QwtPlotItem::RenderAntialiased); QPalette palette; palette.setBrush(QPalette::Window, QBrush(GColor(CPLOTBACKGROUND))); palette.setColor(QPalette::WindowText, GColor(CPLOTMARKER)); palette.setColor(QPalette::Text, GColor(CPLOTMARKER)); setPalette(palette); axisWidget(QwtPlot::xBottom)->setPalette(palette); axisWidget(QwtPlot::yLeft)->setPalette(palette); // use grid line color for mX, mY and CPcurve QPen marker = GColor(CPLOTMARKER); QPen cp = GColor(CCP); mX->setLinePen(marker); mY->setLinePen(marker); cpCurve->setPen(cp); setCL(appsettings->value(this, GC_CRANKLENGTH).toDouble() / 1000.0); replot(); }
void PlotIterPath::setGrayPen() { QwtSymbol sym; sym.setStyle(QwtSymbol::Ellipse); sym.setBrush(QBrush(Qt::gray)); sym.setPen(QPen(Qt::black, 1)); sym.setSize(10); iterPathPlot_.setSymbol(sym); iterPathPlot_.setPen(QPen(Qt::black, 3)); sym.setBrush(QBrush(Qt::red)); sym.setPen(QPen(Qt::red, 1)); sym.setSize(10); selectedIteratePlot_.setSymbol(sym); selectedLinePlot_.setPen(QPen(Qt::red, 3)); }
void PlotIterPath::setColorPen(const QColor &color) { QwtSymbol sym; sym.setStyle(QwtSymbol::Ellipse); sym.setBrush(QBrush(color)); sym.setPen(QPen(color, 1)); sym.setSize(10); iterPathPlot_.setSymbol(sym); iterPathPlot_.setPen(QPen(color, 3)); sym.setBrush(QBrush(Qt::red)); sym.setPen(QPen(Qt::red, 1)); sym.setSize(10); selectedIteratePlot_.setSymbol(sym); selectedLinePlot_.setPen(QPen(Qt::red, 3)); }
SegmentInfo::SegmentInfo(const BinaryImageTreeItem *s): gammaStartIndex(0), gammaEndIndex(0), segment(s), arterySegment(NULL), sampleCurve(s->getName()), gammaCurve(s->getName()+ QObject::tr(" Gamma Fit")), patlakCurve(s->getName()), patlakRegression(s->getName() + QObject::tr(" linear Regression")), patlakCreated(false) { //get color of the segment QColor color = s->getColor(); //set color to the curve sampleCurve.setPen(QPen(color)); sampleCurve.setRenderHint(QwtPlotItem::RenderAntialiased, true); QwtSymbol symbol; //class for drawing symbols symbol.setStyle( QwtSymbol::Ellipse ); symbol.setSize(8); symbol.setPen(QPen(color)); symbol.setBrush(QBrush(color.darker(130))); //set the symbol to the curve sampleCurve.setSymbol( symbol ); //initialize curve data sampleCurve.setData( TimeDensityData() ); //create pen for gamma curve with dotted line QPen pen(color); pen.setStyle(Qt::DotLine); //set pen to gamma curve gammaCurve.setPen(pen); gammaCurve.setRenderHint(QwtPlotItem::RenderAntialiased, true); //initialize gamma curve data and hide it gammaCurve.setData( GammaFitData() ); gammaCurve.setVisible(false); //set style of the patlak curve patlakCurve.setRenderHint(QwtPlotItem::RenderAntialiased, true); patlakCurve.setStyle(QwtPlotCurve::NoCurve); symbol.setStyle( QwtSymbol::XCross ); symbol.setSize(8); symbol.setPen(QPen(color)); symbol.setBrush(QBrush(color.darker(130))); patlakCurve.setSymbol( symbol ); patlakRegression.setRenderHint(QwtPlotItem::RenderAntialiased, true); }
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(); } }
void specCanvasItem::setSymbolSize(const QSize& s) { if(oldSymbol) { oldSymbol->setSize(s) ; } else { QwtSymbol* newSymbol = symbol() ? cloneSymbol(symbol()) : (new QwtSymbol) ; newSymbol->setSize(s) ; setSymbol(newSymbol) ; } }
Graph::Graph(QWidget *parent) : QWidget(parent){ ui.setupUi(this); // Задаём положение окна по центру /*QDesktopWidget desktop; QRect rect = desktop.availableGeometry(desktop.primaryScreen()); QPoint center = rect.center(); center.setX(center.x() - (this->width()/2)); center.setY(center.y() - (this->height()/2)); move(center);*/ // Создаём окно this->setWindowTitle(QString::fromUtf8("График")); // Файл с настройками settings_read = new QSettings("settings.conf",QSettings::IniFormat); settings_write = new QSettings("settings.conf",QSettings::IniFormat); // Настройка отрисовки графика grid = new QwtPlotGrid; grid->enableXMin(true); grid->setMajPen(QPen(Qt::black,0,Qt::DotLine)); grid->setMinPen(QPen(Qt::gray,0,Qt::DotLine)); grid->attach(ui.qwtGraph); curveTimeForce = new QwtPlotCurve(); curveTimeForce->attach(ui.qwtGraph); QPen curvePen; curvePen.setStyle(Qt::DashLine); curvePen.setBrush(Qt::blue); curveTimeForce->setPen(curvePen); QwtSymbol symbolPoint; symbolPoint.setStyle(QwtSymbol::Rect); symbolPoint.setPen(QColor(Qt::blue)); symbolPoint.setSize(5); curveTimeForce->setSymbol(symbolPoint); // Установка единиц измерения силы connect( this->ui.rbAdc, SIGNAL( clicked() ), this, SLOT( rbAdcSet() ) ); connect( this->ui.rbNewton, SIGNAL( clicked() ), this, SLOT( rbNewtonSet() ) ); connect( this->ui.rbKgf, SIGNAL( clicked() ), this, SLOT( rbKgfSet() ) ); nPoints = 0; ui.rbAdc->setChecked(1); ui.qwtGraph->setAxisTitle(QwtPlot::yLeft,QString::fromUtf8("F, ед. ацп")); ui.qwtGraph->setAxisTitle(QwtPlot::xBottom,QString::fromUtf8("t, секунды")); // Загрузка настроек loadSettings(); }
void VectorPlot::addLinePlot(const VectorQwtAdapter &adapter) { setupPlot(adapter.boundingRect()); QwtPlotCurve *curve = new QwtPlotCurve(); QwtSymbol sym; sym.setStyle(QwtSymbol::Cross); sym.setPen(QColor(Qt::black)); sym.setSize(2); curve->setSymbol(sym); curve->setPen(QColor(Qt::darkGreen)); curve->setData(adapter); curve->attach(plot); }
PlotIterPath::PlotIterPath(QwtPlot *parent) : parent_(parent) { QwtSymbol sym; sym.setStyle(QwtSymbol::Ellipse); sym.setBrush(QBrush(Qt::gray)); sym.setPen(QPen(Qt::black, 1)); sym.setSize(10); iterPathPlot_.setSymbol(sym); iterPathPlot_.setPen(QPen(Qt::black, 3)); sym.setStyle(QwtSymbol::Ellipse); sym.setBrush(QBrush(Qt::red)); sym.setPen(QPen(Qt::red, 1)); sym.setSize(10); selectedIteratePlot_.setSymbol(sym); selectedLinePlot_.setPen(QPen(Qt::red, 3)); iterPathPlot_.attach(parent_); selectedIteratePlot_.attach(parent_); selectedLinePlot_.attach(parent_); }
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(); }
void Plot::insertCurve( const QString& title, const QVector<QPointF>& samples, const QColor &color ) { d_curve = new QwtPlotCurve( title ); d_curve->setRenderHint( QwtPlotItem::RenderAntialiased ); d_curve->setStyle( QwtPlotCurve::NoCurve ); d_curve->setLegendAttribute( QwtPlotCurve::LegendShowSymbol ); QwtSymbol *symbol = new QwtSymbol( QwtSymbol::XCross ); symbol->setSize( 4 ); symbol->setPen( QPen( color ) ); d_curve->setSymbol( symbol ); d_curve->setSamples( samples ); d_curve->attach( this ); }
void LegendWidget::drawSymbol(PlotCurve *c, int point, QPainter *p, int x, int y, int l) { if (!c || c->rtti() == QwtPlotItem::Rtti_PlotSpectrogram) return; if (c->type() == Graph::VectXYXY || c->type() == Graph::VectXYAM){ drawVector(c, p, x, y, l); return; } if (c->type() == Graph::Pie){ QwtPieCurve *pie = (QwtPieCurve *)c; const QBrush br = QBrush(pie->color(point), pie->pattern()); QPen pen = pie->pen(); p->save(); p->setPen (QPen(pen.color(), pen.widthF(), Qt::SolidLine)); QRect lr = QRect(x, y - 4, l, 10); p->setBrush(br); QwtPainter::drawRect(p, lr); p->restore(); return; } QwtSymbol symb = c->symbol(); const QBrush br = c->brush(); QPen pen = c->pen(); p->save(); if (c->style()!=0){ p->setPen (pen); if (br.style() != Qt::NoBrush || c->type() == Graph::Box){ QRect lr = QRect(x, y-4, l, 10); p->setBrush(br); QwtPainter::drawRect(p, lr); } else QwtPainter::drawLine(p, x, y, x + l, y); } int symb_size = symb.size().width(); if (symb_size > 15) symb_size = 15; else if (symb_size < 3) symb_size = 3; symb.setSize(symb_size); symb.draw(p, x + l/2, y); p->restore(); }
PfPvPlot::PfPvPlot() : rideItem (NULL), cp_ (0), cad_ (85), cl_ (0.175), shade_zones(true) { setCanvasBackground(Qt::white); setAxisTitle(yLeft, "Average Effective Pedal Force (N)"); setAxisScale(yLeft, 0, 600); setAxisTitle(xBottom, "Circumferential Pedal Velocity (m/s)"); setAxisScale(xBottom, 0, 3); mX = new QwtPlotMarker(); mX->setLineStyle(QwtPlotMarker::VLine); mX->attach(this); mY = new QwtPlotMarker(); mY->setLineStyle(QwtPlotMarker::HLine); mY->attach(this); cpCurve = new QwtPlotCurve(); cpCurve->setRenderHint(QwtPlotItem::RenderAntialiased); cpCurve->attach(this); curve = new QwtPlotCurve(); QwtSymbol sym; sym.setStyle(QwtSymbol::Ellipse); sym.setSize(6); sym.setPen(QPen(Qt::red)); sym.setBrush(QBrush(Qt::NoBrush)); curve->setSymbol(sym); curve->setStyle(QwtPlotCurve::Dots); curve->setRenderHint(QwtPlotItem::RenderAntialiased); curve->attach(this); boost::shared_ptr<QSettings> settings = GetApplicationSettings(); cl_ = settings->value(GC_CRANKLENGTH).toDouble() / 1000.0; recalc(); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimPlotCurve::updateCurveAppearance() { CVF_ASSERT(m_qwtPlotCurve); QColor curveColor(m_curveColor.value().rByte(), m_curveColor.value().gByte(), m_curveColor.value().bByte()); QwtSymbol* symbol = nullptr; if (m_pointSymbol() != RiuQwtSymbol::SYMBOL_NONE) { // QwtPlotCurve will take ownership of the symbol symbol = new RiuQwtSymbol(m_pointSymbol(), m_symbolLabel, m_symbolLabelPosition); symbol->setSize(m_symbolSize, m_symbolSize); symbol->setColor(curveColor); QColor symbolEdgeColor(m_symbolEdgeColor.value().rByte(), m_symbolEdgeColor.value().gByte(), m_symbolEdgeColor.value().bByte()); symbol->setPen(symbolEdgeColor); } m_qwtPlotCurve->setAppearance(m_lineStyle(), m_curveInterpolation(), m_curveThickness(), curveColor); m_qwtPlotCurve->setSymbol(symbol); m_qwtPlotCurve->setSymbolSkipPixelDistance(m_symbolSkipPixelDistance()); m_qwtPlotCurve->setErrorBarsColor(curveColor); // Make sure the legend lines are long enough to distinguish between line types. // Standard width in Qwt is 8 which is too short. // Use 10 and scale this by curve thickness + add space for displaying symbol. if (m_lineStyle() != RiuQwtPlotCurve::STYLE_NONE) { QSize legendIconSize = m_qwtPlotCurve->legendIconSize(); int symbolWidth = 0; if (symbol) { symbolWidth = symbol->boundingRect().size().width() + 2; } int width = std::max(10 * m_curveThickness, (symbolWidth * 3) / 2); legendIconSize.setWidth(width); m_qwtPlotCurve->setLegendIconSize(legendIconSize); } }
void IncrementalPlot::appendData(double *x, double *y, int size) { if (d_data == NULL) d_data = new CurveData; if (d_curve == NULL) { d_curve = new QwtPlotCurve("Data"); d_curve->setStyle(QwtPlotCurve::NoCurve); d_curve->setPaintAttribute(QwtPlotCurve::FilterPoints, true); const QColor &c = Qt::white; QwtSymbol *symbol = new QwtSymbol(QwtSymbol::Ellipse); symbol->setBrush(QBrush(c)); symbol->setPen(QPen(c)); symbol->setSize(QSize(6, 6)); d_curve->setSymbol(symbol); d_curve->attach(this); } d_data->append(x, y, size); d_curve->setRawSamples(d_data->x(), d_data->y(), d_data->count()); #ifdef __GNUC__ #warning better use QwtData #endif const bool cacheMode = qobject_cast<QwtPlotCanvas *>(canvas())->testPaintAttribute(QwtPlotCanvas::BackingStore); #if QT_VERSION >= 0x040000 && defined(Q_WS_X11) // Even if not recommended by TrollTech, Qt::WA_PaintOutsidePaintEvent // works on X11. This has an tremendous effect on the performance.. canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true); #endif QwtPlotCanvas *plotCanvas = qobject_cast<QwtPlotCanvas *>(canvas()); plotCanvas->setPaintAttribute(QwtPlotCanvas::BackingStore, false); QPainter painter; QwtScaleMap xMap = plotCanvas->plot()->canvasMap(d_curve->xAxis()); QwtScaleMap yMap = plotCanvas->plot()->canvasMap(d_curve->yAxis()); d_curve->drawSeries(&painter, xMap, yMap, (d_curve->paintRect(xMap, yMap)), d_curve->dataSize() - size, d_curve->dataSize() -1); plotCanvas->setPaintAttribute(QwtPlotCanvas::BackingStore, cacheMode); #if QT_VERSION >= 0x040000 && defined(Q_WS_X11) canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, false); #endif }
void FFTWidget::init() { setTitle("FFT"); hrBpm = 0; hrMarker = new QwtPlotMarker(); hrMarker->setLineStyle(QwtPlotMarker::VLine); hrMarker->setLinePen(QPen(QColor(255,255,255,100), 2, Qt::SolidLine)); QPen pen; pen.setWidth(2); pen.setColor(Qt::blue); QwtSymbol *symb = new QwtSymbol(QwtSymbol::Diamond); symb->setPen(pen); symb->setSize(10); hrMarker->setSymbol(symb); hrMarker->attach(this); hrMarker->setVisible(false); setAxisAutoScale(QwtPlot::yLeft, true); counter = 0; dX = QVector<double>(size, 0); dY = QVector<double>(size, 0); dYBuf = QVector<double>(size, 0); hamming = QVector<double>(size, 0); dataIn = QVector<double>(size, 0); sampleInterval = 1000/fS; p = fftw_plan_r2r_1d( size, dataIn.data(), dYBuf.data(), FFTW_DHT, FFTW_ESTIMATE ); for(int i=0;i<size;i++) { dX.replace(i, i*(fS/size)); double tmp = 0.54 - 0.46*(2*3.1415*i/size); hamming.replace(i, tmp); } pen.setColor(Qt::red); curve = new QwtPlotCurve(); curve->setPen(pen); curve->setRawSamples(dX.data(), dY.data(), size/2); curve->setRenderHint(QwtPlotItem::RenderAntialiased); curve->attach(this); }
Curve1() { setPen( QColor( 150, 150, 200 ), 2 ); setStyle( QwtPlotCurve::Lines ); QwtSplineCurveFitter *curveFitter = new QwtSplineCurveFitter(); curveFitter->setSplineSize( 150 ); setCurveFitter( curveFitter ); setCurveAttribute( QwtPlotCurve::Fitted, true ); QwtSymbol *symbol = new QwtSymbol( QwtSymbol::XCross ); symbol->setPen( Qt::yellow ); symbol->setSize( 7 ); setSymbol( symbol ); // somewhere to the left QTransform transform; transform.scale( 1.5, 1.0 ); transform.translate( 1.5, 3.0 ); setTransformation( transform ); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RiuFlowCharacteristicsPlot::addCurveWithLargeSymbol(QwtPlot* plot, const QString& curveName, const QColor& color, const QDateTime& dateTime, double timeHistoryValue) { auto curve = createEmptyCurve(plot, curveName, color); QwtSymbol::Style style = QwtSymbol::Diamond; QwtSymbol* symbol = new QwtSymbol(style); symbol->setSize(15, 15); symbol->setColor(color); curve->setSymbol(symbol); // Add date and value twice to avoid a cross as symbol generated by RiuLineSegmentQwtPlotCurve std::vector<QDateTime> dateTimes; dateTimes.push_back(dateTime); dateTimes.push_back(dateTime); std::vector<double> timeHistoryValues; timeHistoryValues.push_back(timeHistoryValue); timeHistoryValues.push_back(timeHistoryValue); curve->setSamplesFromDatesAndYValues(dateTimes, timeHistoryValues, false); }
void PfPvPlot::configChanged() { setCanvasBackground(GColor(CPLOTBACKGROUND)); // frame with inverse of background QwtSymbol sym; sym.setStyle(QwtSymbol::Ellipse); sym.setSize(6); sym.setPen(GCColor::invert(GColor(CPLOTBACKGROUND))); sym.setBrush(QBrush(Qt::NoBrush)); curve->setSymbol(new QwtSymbol(sym)); curve->setStyle(QwtPlotCurve::Dots); curve->setRenderHint(QwtPlotItem::RenderAntialiased); // use grid line color for mX, mY and CPcurve QPen marker = GColor(CPLOTMARKER); QPen cp = GColor(CCP); mX->setLinePen(marker); mY->setLinePen(marker); cpCurve->setPen(cp); setCL(appsettings->value(this, GC_CRANKLENGTH).toDouble() / 1000.0); }
Variog_multiplot:: Variog_multiplot( const std::vector<Discrete_function>& df_vec, const QStringList& titles, QWidget *parent, const char *name ) : QwtPlot(parent) { if (name) setObjectName(name); //this->setWindowFlags( Qt::SubWindow|Qt::MSWindowsFixedSizeDialogHint); //------------ // configure the plotting area //use a light gray for the grid QwtPlotGrid * grid = new QwtPlotGrid(); grid->enableX(true); grid->setPen( QPen( QColor(150,150,150), 0, Qt::DotLine ) ); grid->attach(this); // configure the plot axis this->axisScaleEngine(QwtPlot::xBottom)->setReference(0); this->axisScaleEngine(QwtPlot::yLeft)->setReference(0); this->axisScaleEngine(QwtPlot::xBottom)->setMargins(0,0.5); this->axisScaleEngine(QwtPlot::yLeft)->setMargins(0,0.5); this->axisScaleEngine(QwtPlot::xBottom)->setAttributes(QwtScaleEngine::Floating | QwtScaleEngine::IncludeReference); this->axisScaleEngine(QwtPlot::yLeft)->setAttributes(QwtScaleEngine::Floating | QwtScaleEngine::IncludeReference); QFont axis_font = this->axisFont( QwtPlot::xBottom ); axis_font.setPointSize( 7 ); QwtText title("distance"); title.setFont(axis_font); this->setAxisTitle( QwtPlot::xBottom,title); //------------- this->setWindowTitle( "All Plots" ); typedef enum QwtSymbol::Style QwtStyleEnum; typedef enum Qt::PenStyle QtPenStyleEnum; unsigned int dot_styles[8] = { QwtSymbol::Ellipse, QwtSymbol::Rect, QwtSymbol::Diamond, QwtSymbol::DTriangle, QwtSymbol::UTriangle, QwtSymbol::RTriangle, QwtSymbol::Cross, QwtSymbol::XCross }; unsigned int line_styles[5] = {Qt::SolidLine, Qt::DashLine, Qt::DotLine, Qt::DashDotLine, Qt::DashDotDotLine }; /* if( !title.isEmpty() ) { QFont title_font; title_font.setPointSize( 8 ); this->setTitle( title ); this->setTitleFont( title_font ); this->setCaption( title ); } */ const float ymargin = 1.05; const float xmargin = 1.06; float ymax = -9e99; float ymin = 9e99; float xmax = -9e99; for( unsigned int plot_id = 0; plot_id < df_vec.size() ; plot_id++ ) { std::vector<double> x_vals = df_vec[plot_id].x_values(); std::vector<double> y_vals = df_vec[plot_id].y_values(); double* x = new double[x_vals.size()]; double* y = new double[x_vals.size()]; int actual_size = 0; for( int i=0 ; i < x_vals.size() ; i++ ) { if( GsTL::equals( x_vals[i], df_vec[plot_id].no_data_value(), 0.001 ) || GsTL::equals( y_vals[i], df_vec[plot_id].no_data_value(), 0.001 ) ) continue; x[actual_size] = x_vals[i]; y[actual_size] = y_vals[i]; actual_size++; } if( actual_size > 0 ) { float current_ymax = *(std::max_element( y, y+actual_size )); float current_ymin = *(std::min_element( y, y+actual_size )); float current_xmax = *(std::max_element( x, x+actual_size )); ymax = std::max(ymax, current_ymax ); ymin = std::min(ymin, current_ymin ); xmax = std::max(xmax, current_xmax ); } QwtPlotCurve * curve_id = new QwtPlotCurve(titles[plot_id]); curve_id->attach(this); curve_id->setData( x, y, actual_size ); QwtSymbol symbol; // The following line uses an awful cast from int to enum !! // Awful, but it will stay until I find a more elegant way of looping // through all the qwt styles. symbol.setStyle( static_cast<QwtStyleEnum>(dot_styles[plot_id%8]) ); symbol.setPen( QPen(Qt::black, 1 ) ); symbol.setSize(6); curve_id->setSymbol(symbol); curve_id->setStyle(QwtPlotCurve::Lines); curve_id->setPen( QPen(Qt::darkGray, 0, static_cast<QtPenStyleEnum>(line_styles[plot_id%5]) ) ); delete [] x; delete [] y; } if( ymax == 0 && ymin == 0 ) this->setAxisAutoScale( QwtPlot::yLeft ); else this->setAxisScale( QwtPlot::yLeft, ymin*(2-ymargin), ymax*ymargin ); if( xmax > 0 ) { this->setAxisScale( QwtPlot::xBottom, 0, xmax*xmargin ); } QwtLegend * legend = new QwtLegend(); this->insertLegend(legend); this->replot(); }
// We are going to support multiple models; normal, normal-skew, linear // So for now lets make it a parameter for the model curve creation // The model may end up being comprised of 'sub models' for each fibre type void MUPlot::setModel(int model) { this->model = model; // first lets clear any curves we shouldn't be displaying // no model curve if not power ! if (modelCurve) { modelCurve->detach(); delete modelCurve; modelCurve = NULL; } if (slowCurve) { slowCurve->detach(); delete slowCurve; slowCurve = NULL; } if (slowHandle) { slowHandle->detach(); delete slowHandle; slowHandle = NULL; } if (slowLine) { slowLine->detach(); delete slowLine; slowLine = NULL; } if (fastCurve) { fastCurve->detach(); delete fastCurve; fastCurve = NULL; } if (fastHandle) { fastHandle->detach(); delete fastHandle; fastHandle = NULL; } if (fastLine) { fastLine->detach(); delete fastLine; fastLine = NULL; } if (mmpCurve) { mmpCurve->detach(); delete mmpCurve; mmpCurve = NULL; } switch (model) { case 0 : // no model - do nothing { } break; case 2 : // 2 Normal distribution -- drops through to case 1 below { fastCurve = new QwtPlotCurve( "MU Distribution" ); fastCurve->setData(fastNormal = new MUNormal(MU_FASTMEAN, 0.05f)); fastCurve->attach(this); QColor handleColor = QColor(Qt::magenta).darker(30); // customise (?) handleColor.setAlpha(64); // now a mean line fastLine = new QwtPlotMarker(); fastLine->setLineStyle(QwtPlotMarker::VLine); fastLine->setLinePen(QPen(QColor(handleColor), 0, Qt::SolidLine)); fastLine->setValue(MU_FASTMEAN, 0); // mean fastLine->setZ(50); fastLine->attach(this); // now add a handle QColor color = GColor(CPLOTBACKGROUND); double x = MU_FASTMEAN; // mean is ok double y = 0.05f * 40.0f; // variance scaled to w(x) QwtSymbol *sym = new QwtSymbol; sym->setStyle(QwtSymbol::Rect); sym->setSize(8 *dpiXFactor); sym->setPen(QPen(handleColor)); // customise ? sym->setBrush(QBrush(color)); fastHandle = new QwtPlotMarker(); fastHandle->setValue(x, y); fastHandle->setYAxis(yLeft); fastHandle->setZ(100); fastHandle->setSymbol(sym); fastHandle->attach(this); } // intentional fallthrough case 1 : // Normal distribution { slowCurve = new QwtPlotCurve( "MU Distribution" ); slowCurve->setData(slowNormal = new MUNormal(MU_SLOWMEAN, 0.05f)); slowCurve->attach(this); QColor handleColor = GColor(CCP).darker(30); handleColor.setAlpha(64); // now a mean line slowLine = new QwtPlotMarker(); slowLine->setLineStyle(QwtPlotMarker::VLine); slowLine->setLinePen(QPen(QColor(handleColor), 0, Qt::SolidLine)); slowLine->setValue(MU_SLOWMEAN, 0); // mean slowLine->setZ(50); slowLine->attach(this); // now add a handle QColor color = GColor(CPLOTBACKGROUND); double x = MU_SLOWMEAN; // mean is ok double y = 0.05f * 40.0f; // variance scaled to w(x) QwtSymbol *sym = new QwtSymbol; sym->setStyle(QwtSymbol::Rect); sym->setSize(8 *dpiXFactor); sym->setPen(QPen(handleColor)); // customise ? sym->setBrush(QBrush(color)); slowHandle = new QwtPlotMarker(); slowHandle->setValue(x, y); slowHandle->setYAxis(yLeft); slowHandle->setZ(100); slowHandle->setSymbol(sym); slowHandle->attach(this); // mmp curve mmpCurve = new QwtPlotCurve( "MU Distribution" ); mmpCurve->attach(parent->cpPlot); } break; } // set the colors etc for our curve(s) if (fastCurve) { // antialias bool antialias = appsettings->value(this, GC_ANTIALIAS, false).toBool(); if (antialias) fastCurve->setRenderHint(QwtPlotItem::RenderAntialiased); // color and brush QColor color = QColor(Qt::magenta); //XXX customise QPen pen(color); pen.setWidth(1.0); color.setAlpha(80); QBrush brush(color); fastCurve->setPen(pen); fastCurve->setBrush(brush); } if (slowCurve) { // antialias bool antialias = appsettings->value(this, GC_ANTIALIAS, false).toBool(); if (antialias) slowCurve->setRenderHint(QwtPlotItem::RenderAntialiased); // color and brush QColor color = GColor(CCP); // customise ? QPen pen(color); pen.setWidth(1.0); color.setAlpha(80); QBrush brush(color); slowCurve->setPen(pen); slowCurve->setBrush(brush); QwtSymbol *sym = new QwtSymbol; sym->setStyle(QwtSymbol::Ellipse); sym->setSize(4 *dpiXFactor); sym->setPen(QPen(Qt::yellow)); // customise ? sym->setBrush(QBrush(Qt::yellow)); mmpCurve->setPen(QPen(Qt::yellow)); mmpCurve->setSymbol(sym); mmpCurve->setBrush(Qt::NoBrush); // and refresh the MMP setMUSet(); } if (model) { modelCurve = new QwtPlotCurve( "Total Distribution" ); modelCurve->setData(this); // we provide the data too! QColor color = QColor(Qt::yellow); //XXX customise QPen pen(color); pen.setWidth(1.0); color.setAlpha(80); modelCurve->setPen(pen); modelCurve->setBrush(Qt::NoBrush); modelCurve->attach(this); } replot(); }
void ScatterPlot::setData (ScatterSettings *settings) { // get application settings cranklength = appsettings->value(this, GC_CRANKLENGTH, 0.0).toDouble() / 1000.0; // if there are no settings or incomplete settings // create a null data plot if (settings == NULL || settings->ride == NULL || settings->ride->ride() == NULL || settings->x == 0 || settings->y == 0 ) { return; } // if its not setup or no settings exist default to 175mm cranks if (cranklength == 0.0) cranklength = 0.175; // // Create Main Plot dataset - used to frame intervals // int points=0; x.clear(); y.clear(); x.resize(settings->ride->ride()->dataPoints().count()); y.resize(settings->ride->ride()->dataPoints().count()); double maxY = maxX = -65535; double minY = minX = 65535; foreach(const RideFilePoint *point, settings->ride->ride()->dataPoints()) { double xv = x[points] = pointType(point, settings->x, context->athlete->useMetricUnits, cranklength); double yv = y[points] = pointType(point, settings->y, context->athlete->useMetricUnits, cranklength); // skip zeroes? if (!(settings->ignore && (x[points] == 0 || y[points] == 0))) { points++; if (yv > maxY) maxY = yv; if (yv < minY) minY = yv; if (xv > maxX) maxX = xv; if (xv < minX) minX = xv; } } QwtSymbol sym; sym.setStyle(QwtSymbol::Ellipse); sym.setSize(6); sym.setPen(GCColor::invert(GColor(CPLOTBACKGROUND))); sym.setBrush(QBrush(Qt::NoBrush)); QPen p; p.setColor(GColor(CPLOTSYMBOL)); sym.setPen(p); // wipe away existing if (all) { all->detach(); delete all; } // setup the framing curve if (settings->frame) { all = new QwtPlotCurve(); all->setSymbol(new QwtSymbol(sym)); all->setStyle(QwtPlotCurve::Dots); all->setRenderHint(QwtPlotItem::RenderAntialiased); all->setData(x.constData(), y.constData(), points); all->attach(this); } else { all = NULL; } QPen gridPen(GColor(CPLOTGRID)); gridPen.setStyle(Qt::DotLine); if (grid) { grid->detach(); delete grid; } if (settings->gridlines) { grid = new QwtPlotGrid(); grid->setPen(gridPen); grid->enableX(true); grid->enableY(true); grid->attach(this); } else { grid = NULL; } setAxisTitle(yLeft, describeType(settings->y, true, useMetricUnits)); setAxisTitle(xBottom, describeType(settings->x, true, useMetricUnits)); // truncate PfPv values to make easier to read if (settings->y == MODEL_AEPF) setAxisScale(yLeft, 0, 600); else setAxisScale(yLeft, minY, maxY); if (settings->x == MODEL_CPV) setAxisScale(xBottom, 0, 3); else setAxisScale(xBottom, minX, maxX); // // Create Interval Plot dataset - used to frame intervals // // clear out any interval curves which are presently defined if (intervalCurves.size()) { QListIterator<QwtPlotCurve *> i(intervalCurves); while (i.hasNext()) { QwtPlotCurve *curve = i.next(); curve->detach(); delete curve; } } intervalCurves.clear(); // which ones are highlighted then? QVector<int> intervals; QMap<int,int> displaySequence; for (int child=0; child<context->athlete->allIntervalItems()->childCount(); child++) { IntervalItem *current = dynamic_cast<IntervalItem *>(context->athlete->allIntervalItems()->child(child)); if ((current != NULL) && current->isSelected()) { intervals.append(child); displaySequence.insert(current->displaySequence, intervals.count()-1); } } if (intervals.count() > 0) { // interval data in here QVector<QVector<double> > xvals(intervals.count()); // array of curve x arrays QVector<QVector<double> > yvals(intervals.count()); // array of curve x arrays QVector<int> points(intervals.count()); // points in eac curve // extract interval data foreach(const RideFilePoint *point, settings->ride->ride()->dataPoints()) { double x = pointType(point, settings->x, useMetricUnits, cranklength); double y = pointType(point, settings->y, useMetricUnits, cranklength); if (!(settings->ignore && (x == 0 && y ==0))) { // which interval is it in? for (int idx=0; idx<intervals.count(); idx++) { IntervalItem *current = dynamic_cast<IntervalItem *>(context->athlete->allIntervalItems()->child(intervals[idx])); if (point->secs+settings->ride->ride()->recIntSecs() > current->start && point->secs< current->stop) { xvals[idx].append(x); yvals[idx].append(y); points[idx]++; } } } } // now we have the interval data lets create the curves QMapIterator<int, int> order(displaySequence); while (order.hasNext()) { order.next(); int idx = order.value(); QPen pen; QColor intervalColor; intervalColor.setHsv((255/context->athlete->allIntervalItems()->childCount()) * (intervals[idx]), 255,255); pen.setColor(intervalColor); sym.setPen(pen); QwtPlotCurve *curve = new QwtPlotCurve(); curve->setSymbol(new QwtSymbol(sym)); curve->setStyle(QwtPlotCurve::Dots); curve->setRenderHint(QwtPlotItem::RenderAntialiased); curve->setData(xvals[idx].constData(), yvals[idx].constData(), points[idx]); curve->attach(this); intervalCurves.append(curve); } }
MainWin::MainWin() { int i; xMap.setScaleInterval(-0.5, 10.5); yMap.setScaleInterval(-1.1, 1.1); // // Frame style // setFrameStyle(QFrame::Box|QFrame::Raised); setLineWidth(2); setMidLineWidth(3); // // Calculate values // for(i=0; i<Size;i++) { xval[i] = double(i) * 10.0 / double(Size - 1); yval[i] = sin(xval[i]) * cos(2.0 * xval[i]); } // // define curve styles // QwtSymbol sym; i = 0; sym.setStyle(QwtSymbol::Cross); sym.setPen(QColor(Qt::black)); sym.setSize(5); crv[i].setSymbol(sym); crv[i].setPen(QColor(Qt::darkGreen)); crv[i].setStyle(QwtPlotCurve::Lines); crv[i].setCurveAttribute(QwtPlotCurve::Fitted); i++; sym.setStyle(QwtSymbol::Ellipse); sym.setPen(QColor(Qt::blue)); sym.setBrush(QColor(Qt::yellow)); sym.setSize(5); crv[i].setSymbol(sym); crv[i].setPen(QColor(Qt::red)); crv[i].setStyle(QwtPlotCurve::Sticks); i++; crv[i].setPen(QColor(Qt::darkBlue)); crv[i].setStyle(QwtPlotCurve::Lines); i++; #if QT_VERSION >= 0x040000 crv[i].setPen(QColor(Qt::darkBlue)); crv[i].setStyle(QwtPlotCurve::Lines); crv[i].setRenderHint(QwtPlotItem::RenderAntialiased); i++; #endif crv[i].setPen(QColor(Qt::darkCyan)); crv[i].setStyle(QwtPlotCurve::Steps); i++; sym.setStyle(QwtSymbol::XCross); sym.setPen(QColor(Qt::darkMagenta)); crv[i].setSymbol(sym); crv[i].setStyle(QwtPlotCurve::NoCurve); i++; // // attach data // for(i=0;i<CurvCnt;i++) crv[i].setRawData(xval,yval,Size); }
void ObserverGraphic::setAttributes(const QStringList &attribs, const QStringList &curveTitles, /*const*/ QStringList &legKeys, /*const*/ QStringList &legAttribs) { attribList = attribs; InternalCurve *interCurve = 0; QColor color; int attrSize = attribList.size(); // Ignores the attribute of the x axis if (observerType == TObsGraphic) attrSize--; for (int i = 0; i < attrSize; i++) { interCurve = new InternalCurve(attribList.at(i), plotter); if (interCurve) { if (i < curveTitles.size()) interCurve->plotCurve->setTitle(curveTitles.at(i)); else interCurve->plotCurve->setTitle(QString("$curve %1").arg(i + 1)); internalCurves->insert(attribList.at(i), interCurve); // Sets a random color for the created curve color = QColor::fromHsvF(hueValues[(int)(qrand() % HUE_COUNT)], 1, 1); interCurve->plotCurve->setPen(color); interCurve->plotCurve->setLegendAttribute(QwtPlotCurve::LegendShowLine); int width = 0, style = 0, symbol = 0, colorBar = 0, num = 0, size = 0, penstyle = 0; width = legKeys.indexOf(WIDTH); style = legKeys.indexOf(STYLE); symbol = legKeys.indexOf(SYMBOL); size = legKeys.indexOf(SIZE_); penstyle = legKeys.indexOf(PENSTYLE); colorBar = legKeys.indexOf(COLOR_BAR); if ((!legAttribs.isEmpty()) && (colorBar > -1)) { QString aux; QStringList colorStrList; QPen pen; aux = legAttribs.at(colorBar).mid(0, legAttribs.at(colorBar).indexOf(COLOR_BAR_SEP)); colorStrList = aux.split(COLORS_SEP, QString::SkipEmptyParts) .first().split(ITEM_SEP).first().split(COMP_COLOR_SEP); // Retrieves the last colorBar value // colorStrList = aux.split(COLORS_SEP, QString::SkipEmptyParts) // .last().split(ITEM_SEP).first().split(COMP_COLOR_SEP); // color color.setRed(colorStrList.at(0).toInt()); color.setGreen(colorStrList.at(1).toInt()); color.setBlue(colorStrList.at(2).toInt()); // width num = legAttribs.at(width).toInt(); pen = QPen(color); pen.setWidth((num > 0) ? num : 1); interCurve->plotCurve->setPen(pen); // pen num = legAttribs.at(penstyle).toInt(); pen.setStyle((Qt::PenStyle) num); interCurve->plotCurve->setPen(pen); // style num = legAttribs.at(style).toInt(); interCurve->plotCurve->setStyle((QwtPlotCurve::CurveStyle) num); // symbol num = legAttribs.at(symbol).toInt(); QwtSymbol* qwtSymbol = new QwtSymbol; qwtSymbol->setStyle((QwtSymbol::Style) num); qwtSymbol->setPen(pen); if ((QwtSymbol::Style) num !=(QwtSymbol::Style) -1) { interCurve->plotCurve->setLegendAttribute(QwtPlotCurve::LegendShowSymbol); } //size num = legAttribs.at(size).toInt(); qwtSymbol->setSize(num); if (qwtSymbol->brush().style() != Qt::NoBrush) qwtSymbol->setBrush(pen.color()); interCurve->plotCurve->setSymbol(qwtSymbol); for (int j = 0; j < LEGEND_ITENS; j++) { legKeys.removeFirst(); legAttribs.removeFirst(); } } } else { if (execModes != Quiet) qWarning("%s", qPrintable(TerraMEObserver::MEMORY_ALLOC_FAILED)); } } plotter->setInternalCurves(internalCurves->values()); }
Variog_plot:: Variog_plot( const Discrete_function& df, const Variogram_function_adaptor<Covariance<GsTLPoint> > *model, GsTLVector<double> angle, const std::vector<int>& pairs, const QString& title, bool y_starts_at_zero, QWidget *parent, const char *name) : QwtPlot(parent), pairs_shown_(false), model1_(0), model2_(0) { //this->setWindowFlags( ); setWindowFlags(Qt::SubWindow | Qt::MSWindowsFixedSizeDialogHint); if (name) setObjectName(name); setWindowIcon(QIcon()); //------------ // configure the plotting area //use a light gray for the grid QwtPlotGrid * grid = new QwtPlotGrid(); grid->enableX(true); grid->setPen( QPen( QColor(150,150,150), 0, Qt::DotLine ) ); grid->attach(this); this->axisScaleEngine(QwtPlot::xBottom)->setReference(0); this->axisScaleEngine(QwtPlot::yLeft)->setReference(0); this->axisScaleEngine(QwtPlot::xBottom)->setMargins(0,0.5); this->axisScaleEngine(QwtPlot::yLeft)->setMargins(0,0.5); this->axisScaleEngine(QwtPlot::xBottom)->setAttributes(QwtScaleEngine::Floating | QwtScaleEngine::IncludeReference); this->axisScaleEngine(QwtPlot::yLeft)->setAttributes(QwtScaleEngine::Floating | QwtScaleEngine::IncludeReference); QFont axis_font = this->axisFont( QwtPlot::xBottom ); axis_font.setPointSize( 7 ); QwtText t("distance"); t.setFont(axis_font); this->setAxisTitle( QwtPlot::xBottom,t); //------------- if( !title.isEmpty() ) { QFont title_font; QwtText T(title); title_font.setPointSize( 8 ); T.setFont(title_font); this->setTitle( T ); this->setWindowTitle( title ); } std::vector<double> x_vals = df.x_values(); std::vector<double> y_vals = df.y_values(); angle_ = angle; double* x = new double[x_vals.size()]; double* y = new double[x_vals.size()]; int actual_size = 0; for( int i=0 ; i < x_vals.size() ; i++ ) { if( GsTL::equals( x_vals[i], df.no_data_value(), 0.001 ) || GsTL::equals( y_vals[i], df.no_data_value(), 0.001 ) ) continue; x[actual_size] = x_vals[i]; y[actual_size] = y_vals[i]; pairs_.push_back( pairs[i] ); pairs_coord_x_.push_back( x_vals[i] ); pairs_coord_y_.push_back( y_vals[i] ); actual_size++; } model1_=model; const float ymargin = 1.05; const float xmargin = 1.06; if( actual_size > 0 ) { float ymax = *(std::max_element( y, y+actual_size )); float ymin = *(std::min_element( y, y+actual_size )); if( ymax == 0 && ymin == 0 ) this->setAxisAutoScale( QwtPlot::yLeft ); else if(ymax>0) this->setAxisScale( QwtPlot::yLeft, 0.0, ymax*ymargin ); else this->setAxisScale( QwtPlot::yLeft, ymin*(2-ymargin), ymax*ymargin ); if( y_starts_at_zero ) this->setAxisScale( QwtPlot::yLeft, 0.0, ymax*ymargin ); float xmax = *(std::max_element( x, x+actual_size )); this->setAxisScale( QwtPlot::xBottom, 0, xmax*xmargin ); } curve1_= new QwtPlotCurve("Discrete Function"); curve1_->setData( x, y, actual_size ); curve2_=new QwtPlotCurve("Model"); curve1_->attach(this); curve2_->attach(this); QwtSymbol symbol; symbol.setStyle(QwtSymbol::XCross); symbol.setPen( QPen(Qt::red, 3 ) ); symbol.setSize(7); curve1_->setSymbol(symbol); curve1_->setStyle(QwtPlotCurve::NoCurve); symbol.setStyle( QwtSymbol::NoSymbol ); symbol.setPen( QPen( Qt::blue, 1 ) ); curve2_->setSymbol(symbol); curve2_->setStyle(QwtPlotCurve::Lines); this->replot(); max_x_ = this->axisScaleDiv( QwtPlot::xBottom )->hBound(); /* QObject::connect( this, SIGNAL(plotMouseReleased(const QMouseEvent& )), this, SLOT(show_pairs_count(const QMouseEvent&)) ); */ delete [] x; delete [] y; }
void PlotCurve::restoreCurveLayout(const QStringList &lst) { QStringList::const_iterator line = lst.begin(); for (++line; line != lst.end(); ++line) { QString s = *line; if (s == "<Pen>") { QPen pen; while (s != "</Pen>") { s = (*(++line)).trimmed(); if (s.contains("<Color>")) pen.setColor(QColor(s.remove("<Color>").remove("</Color>"))); else if (s.contains("<Style>")) pen.setStyle(Graph::getPenStyle( s.remove("<Style>").remove("</Style>").toInt())); else if (s.contains("<Width>")) pen.setWidthF(s.remove("<Width>").remove("</Width>").toDouble()); } setPen(pen); } else if (s == "<Brush>") { QBrush brush; while (s != "</Brush>") { s = (*(++line)).trimmed(); if (s.contains("<Color>")) brush.setColor(QColor(s.remove("<Color>").remove("</Color>"))); else if (s.contains("<Style>")) brush.setStyle(PatternBox::brushStyle( s.remove("<Style>").remove("</Style>").toInt())); } setBrush(brush); } else if (s == "<Symbol>") { QwtSymbol symbol; while (s != "</Symbol>") { s = (*(++line)).trimmed(); if (s.contains("<Style>")) symbol.setStyle( SymbolBox::style(s.remove("<Style>").remove("</Style>").toInt())); else if (s.contains("<Size>")) symbol.setSize( (QwtSymbol::Style)s.remove("<Size>").remove("</Size>").toInt()); else if (s == "<SymbolPen>") { QPen pen; while (s != "</SymbolPen>") { s = (*(++line)).trimmed(); if (s.contains("<Color>")) pen.setColor(QColor(s.remove("<Color>").remove("</Color>"))); else if (s.contains("<Style>")) pen.setStyle(Graph::getPenStyle( s.remove("<Style>").remove("</Style>").toInt())); else if (s.contains("<Width>")) pen.setWidthF(s.remove("<Width>").remove("</Width>").toDouble()); } symbol.setPen(pen); } else if (s == "<SymbolBrush>") { QBrush brush; while (s != "</SymbolBrush>") { s = (*(++line)).trimmed(); if (s.contains("<Color>")) brush.setColor(QColor(s.remove("<Color>").remove("</Color>"))); else if (s.contains("<Style>")) brush.setStyle(PatternBox::brushStyle( s.remove("<Style>").remove("</Style>").toInt())); } symbol.setBrush(brush); } setSymbol(symbol); } } else if (s.contains("<xAxis>")) setXAxis(s.remove("<xAxis>").remove("</xAxis>").toInt()); else if (s.contains("<yAxis>")) setYAxis(s.remove("<yAxis>").remove("</yAxis>").toInt()); else if (s.contains("<Visible>")) setVisible(s.remove("<Visible>").remove("</Visible>").toInt()); } }
void QcepPlot::setPlotCurveStyle(int index, QwtPlotCurve *curve) { const int nColors = 10; const int nSymbols = 4; const int nStyles = 3; int colorIndex = index % nColors; int symbolIndex = (index / nColors) % nSymbols; int styleIndex = (index / (nColors * nSymbols)) % nStyles; QPen pen; QwtSymbol *symb = new QwtSymbol(); QBrush brush; switch (colorIndex) { case 0: pen = QPen(QColor(255,0,0)); // red break; case 1: pen = QPen(QColor(255,170,0)); // Orange break; case 2: pen = QPen(QColor(255,232,137)); // Yellow break; case 3: pen = QPen(QColor(0,255,0)); // Green break; case 4: pen = QPen(QColor(0,170,0)); // Dk green break; case 5: pen = QPen(QColor(0,255,255)); // Cyan break; case 6: pen = QPen(QColor(0,170,255)); // Sea blue break; case 7: pen = QPen(QColor(0,0,255)); // Blue break; case 8: pen = QPen(QColor(145,0,255)); // Violet break; case 9: pen = QPen(QColor(255,0,255)); // Magenta break; } switch (styleIndex) { case 0: pen.setStyle(Qt::SolidLine); break; case 1: pen.setStyle(Qt::DashLine); break; case 2: pen.setStyle(Qt::DotLine); break; case 3: pen.setStyle(Qt::DashDotLine); break; } symb->setPen(pen); symb->setBrush(QBrush(pen.color())); symb->setSize(5,5); switch (symbolIndex) { case 0: symb->setStyle(QwtSymbol::Ellipse); break; case 1: symb->setStyle(QwtSymbol::Rect); break; case 2: symb->setStyle(QwtSymbol::Triangle); break; case 3: symb->setStyle(QwtSymbol::DTriangle); break; } curve -> setPen(pen); curve -> setSymbol(symb); }