示例#1
0
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();
}
示例#2
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
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);
    }
}
示例#3
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
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);
}
示例#4
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
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() != SYMBOL_NONE)
    {
        QwtSymbol::Style style = QwtSymbol::NoSymbol;

        switch (m_pointSymbol())
        {
            case SYMBOL_ELLIPSE:
            style = QwtSymbol::Ellipse;
            break;
            case SYMBOL_RECT:
            style = QwtSymbol::Rect;
            break;
            case SYMBOL_DIAMOND:
            style = QwtSymbol::Diamond;
            break;
            case SYMBOL_TRIANGLE:
            style = QwtSymbol::Triangle;
            break;
            case SYMBOL_CROSS:
            style = QwtSymbol::Cross;
            break;
            case SYMBOL_XCROSS:
            style = QwtSymbol::XCross;
            break;

            default:
            break;
        }

        // QwtPlotCurve will take ownership of the symbol
        symbol = new QwtSymbol(style);

        symbol->setSize(6, 6);
        symbol->setColor(curveColor);
    }

    QwtPlotCurve::CurveStyle curveStyle = QwtPlotCurve::NoCurve;
    Qt::PenStyle penStyle = Qt::SolidLine;

    if (m_lineStyle() != STYLE_NONE)
    {
        switch (m_curveInterpolation())
        {
        case INTERPOLATION_STEP_LEFT:
            curveStyle = QwtPlotCurve::Steps;
            m_qwtPlotCurve->setCurveAttribute(QwtPlotCurve::Inverted, false);
            break;
        case INTERPOLATION_POINT_TO_POINT: // Fall through
        default:
            curveStyle = QwtPlotCurve::Lines;
            break;
        }

        switch (m_lineStyle())
        {
            case STYLE_SOLID:
            penStyle = Qt::SolidLine;
            break;
            case STYLE_DASH:
            penStyle = Qt::DashLine;
            break;
            case STYLE_DOT:
            penStyle = Qt::DotLine;
            break;
            case STYLE_DASH_DOT:
            penStyle = Qt::DashDotLine;
            break;

            default:
            break;
        }
    }
    QPen curvePen(curveColor);
    curvePen.setWidth(m_curveThickness);
    curvePen.setStyle(penStyle);

    m_qwtPlotCurve->setPen(curvePen);
    m_qwtPlotCurve->setStyle(curveStyle);
    m_qwtPlotCurve->setSymbol(symbol);
    m_qwtPlotCurve->setSymbolSkipPixelDistance(m_symbolSkipPixelDistance());
}
示例#5
0
void sigmaDetect(SAUIInterface* ui)
{
    QList<QwtPlotItem*> curs;
    SAChart2D* chart = filter_xy_series(ui,curs);
    if(nullptr == chart || curs.size() <= 0)
    {
        saUI->showMessageInfo(TR("unsupport chart items"),SA::WarningMessage);
        return;
    }
    double sigma;
    bool isMark,isChangedPlot;
    if(!getSigmaDetectPorperty(sigma,&isMark,&isChangedPlot,ui))
    {
        return;
    }
    if(!isMark && !isChangedPlot)
    {
        return;
    }
    QStringList infos;
    QScopedPointer<SAFigureOptCommand> topCmd(new SAFigureOptCommand(chart,QString("sigma %1").arg(sigma)));
    for (int i = 0;i<curs.size();++i)
    {
        QwtPlotItem* item = curs[i];
        switch(item->rtti())
        {
        case QwtPlotItem::Rtti_PlotCurve:
        {
            QVector<double> xs,ys;
            {
                QVector<QPointF> wave;
                SAChart::getPlotCurveSample(item,wave);
                xs.reserve(wave.size());
                ys.reserve(wave.size());
                std::for_each(wave.begin(),wave.end(),[&xs](const QPointF& p){xs.push_back(p.x());});
                std::for_each(wave.begin(),wave.end(),[&ys](const QPointF& p){ys.push_back(p.y());});
            }
            QString info;
            QString title = item->title().text();
            QVector<int> indexs;
            saFun::sigmaDenoising(xs,ys,sigma,indexs);
            info = QString("sigma(\"%1\") out range datas count:%2").arg(title).arg(indexs.size());
            infos.append(info);
            if(0 == indexs.size())
            {
                continue;
            }
            if(isMark)
            {
                QVector<double> oxs,oys;
                czy::copy_inner_indexs(xs.begin(),indexs.begin(),indexs.end(),std::back_inserter(oxs));
                czy::copy_inner_indexs(ys.begin(),indexs.begin(),indexs.end(),std::back_inserter(oys));
                QwtPlotCurve* curs = new QwtPlotCurve(QString("%1_outSigmaMarker").arg(title));
                curs->setSamples(oxs,oys);
                SAChart::setCurvePenStyle(curs,Qt::NoPen);
                QwtSymbol* sym = new QwtSymbol(QwtSymbol::XCross);
                sym->setColor(SARandColorMaker::getCurveColor());
                sym->setSize(QSize(6,6));
                curs->setSymbol(sym);
                new SAFigureChartItemAddCommand(chart
                                                ,curs
                                                ,QString("%1 - sigma out rang").arg(title)
                                                ,topCmd.data());
            }
            if(isChangedPlot)
            {
                QVector<int> allIndex;
                QVector<int> innerIndex;
                const int count = xs.size();
                innerIndex.resize(count);
                allIndex.reserve(count);
                for(int i=0;i<count;++i)
                {
                    allIndex.append(i);
                }
                czy::copy_out_of_indexs(allIndex.begin(),allIndex.end(),indexs.begin(),indexs.end(),std::back_inserter(innerIndex));
                QVector<double> oxs,oys;
                czy::copy_inner_indexs(xs.begin(),innerIndex.begin(),innerIndex.end(),std::back_inserter(oxs));
                czy::copy_inner_indexs(ys.begin(),innerIndex.begin(),innerIndex.end(),std::back_inserter(oys));
                QVector<QPointF> oxys;
                saFun::makeVectorPointF(oxs,oys,oxys);;

                new SAFigureReplaceAllDatasCommand<QPointF,QwtPlotCurve,decltype(&SAChart::setPlotCurveSample)>
                        (chart
                       ,item
                       ,oxys
                       ,TR("%1 sigma %2").arg(title).arg(sigma)
                       ,&SAChart::setPlotCurveSample
                       ,&SAChart::getPlotCurveSample
                       ,topCmd.data()
                       );

            }
            break;
        }
        }

        /*
        QwtSeriesStore<QPointF>* series = dynamic_cast<QwtSeriesStore<QPointF>*>(item);
        if(nullptr == series)
        {
            continue;
        }
        QVector<double> xs,ys;
        if(!chart->getXYData(&xs,&ys,item))
        {
            continue;
        }

        QString info;
        QString title = item->title().text();
        QVector<int> indexs;
        saFun::sigmaDenoising(xs,ys,sigma,indexs);
        info = QString("sigma(\"%1\") out range datas count:%2").arg(title).arg(indexs.size());
        infos.append(info);
        if(0 == indexs.size())
        {
            continue;
        }
        if(isMark)
        {
            QVector<double> oxs,oys;
            czy::copy_inner_indexs(xs.begin(),indexs.begin(),indexs.end(),std::back_inserter(oxs));
            czy::copy_inner_indexs(ys.begin(),indexs.begin(),indexs.end(),std::back_inserter(oys));
            QwtPlotCurve* curs = new QwtPlotCurve(QString("%1_outSigmaMarker").arg(title));
            curs->setSamples(oxs,oys);
            SAChart::setCurvePenStyle(curs,Qt::NoPen);
            QwtSymbol* sym = new QwtSymbol(QwtSymbol::XCross);
            sym->setColor(SARandColorMaker::getCurveColor());
            sym->setSize(QSize(6,6));
            curs->setSymbol(sym);
            new SAFigureChartItemAddCommand(chart
                                            ,curs
                                            ,QString("%1 - sigma out rang").arg(title)
                                            ,topCmd.data());
        }
        if(isChangedPlot)
        {
            QVector<int> allIndex;
            QVector<int> innerIndex;
            const int count = xs.size();
            innerIndex.resize(count);
            allIndex.reserve(count);
            for(int i=0;i<count;++i)
            {
                allIndex.append(i);
            }
            czy::copy_out_of_indexs(allIndex.begin(),allIndex.end(),indexs.begin(),indexs.end(),std::back_inserter(innerIndex));
            QVector<double> oxs,oys;
            czy::copy_inner_indexs(xs.begin(),innerIndex.begin(),innerIndex.end(),std::back_inserter(oxs));
            czy::copy_inner_indexs(ys.begin(),innerIndex.begin(),innerIndex.end(),std::back_inserter(oys));
            QVector<QPointF> oxys;
            saFun::makeVectorPointF(oxs,oys,oxys);
            new SAFigureChangeXYSeriesDataCommand(chart
                                                 ,series
                                                 ,TR("%1 sigma %2").arg(title).arg(sigma)
                                                 ,oxys
                                                 ,topCmd.data());

            new SAFigureReplaceAllDatasCommand<>(chart
                                              ,series
                                              ,);
        }
        */
    }
    if(topCmd->childCount() > 0)
    {
        chart->appendCommand(topCmd.take());
        saUI->showNormalMessageInfo(infos.join('\n'));
    }
}