Пример #1
0
QtYARPScope::QtYARPScope(QQuickItem *parent):
    QQuickPaintedItem(parent),
    i(0),
    yarp(yarp::os::YARP_CLOCK_SYSTEM),
    loader(nullptr),
    plotManager(PlotManager::instance()),
    topLevel(nullptr),
    bPressed(false),
    currentSelectedPlotter(nullptr)
{
    setFlag(ItemHasContents, true);

    setAcceptedMouseButtons(Qt::AllButtons);
    setRenderTarget(QQuickPaintedItem::FramebufferObject);

    connect(this, SIGNAL(widthChanged()), this, SLOT(updateCustomPlotSize()) );
    connect(this, SIGNAL(heightChanged()), this, SLOT(updateCustomPlotSize()));

}
Пример #2
0
void CustomPlotRegression::initCustomPlotRegression()
{
    m_CustomPlot = new QCustomPlot();
    //m_CustomPlot->setMinimumHeight(200);
    updateCustomPlotSize();

    //    setupQuadraticDemo( m_CustomPlot );

    connect( m_CustomPlot, &QCustomPlot::afterReplot, this, &CustomPlotRegression::onCustomReplot );
    m_CustomPlot->replot();
}
Пример #3
0
void CustomPlotLineChart::initCustomPlot()
{
    m_CustomPlot = new QCustomPlot();

    m_CustomPlot->addGraph();

    calculateData();

    m_CustomPlot->graph(0)->setData(m_xAxis, m_yAxis);
    m_CustomPlot->yAxis->setRange(0, 230);
    m_CustomPlot->xAxis->setRange(0, m_xAxis.size() + 1);
    m_CustomPlot->yAxis->setLabel(tr("Heart Rate"));

    updateCustomPlotSize();

    qDebug() << "initCustomPlot()";
}
Пример #4
0
/*! \brief parse the parameters received from the main container in QstringList form
    \param params the parameter list
*/
bool QtYARPScope::parseParameters(QStringList params)
{
    //YARP network initialization
    if (!yarp.checkNetwork()) {
        qCritical("Cannot connect to yarp network");
        return false;
    }
    else
    {
        connect(plotManager,SIGNAL(requestRepaint()),this,SLOT(onRepaint()),Qt::QueuedConnection);
    }
    // Setup resource finder
    yarp::os::ResourceFinder rf;
    rf.setVerbose();
    // TODO Read default values from yarpscope.ini
    rf.setDefaultConfigFile("yarpscope.ini");
    rf.setDefaultContext("yarpscope"); 

    // Transform Qt Params array in standard argc & argv
    int c = params.count();
    char **v;
    v = (char**)malloc(sizeof(char*) * c);
    for(int i=0;i<params.count();i++){
        v[i] = strdup(params.at(i).toLatin1().data());
    }

    if(!rf.configure(c, v)){
        usage();
        for(int i=0;i<params.count();i++) {
            free(v[i]);
        }
        free(v);
        return false;
    }

    qDebug("%s",rf.toString().data());

    if (rf.check("help")) {
        usage();
        for(int i=0;i<params.count();i++) {
            free(v[i]);
        }
        free(v);
        return false;
    }

    for(int i=0;i<params.count();i++) {
        free(v[i]);
    }
    free(v);

//********************** Deprecated options
    // local
    if (rf.check("local")) {
        qWarning() << "--local option is deprecated. YARPScope now uses \"${YARP_PORT_PREFIX}/YARPScope/${REMOTE_PORT_NAME}\"";
    }

    // rows
    if (rf.check("rows")) {
        qWarning() << "--rows option is deprecated. Use XML mode if you need more than one plot in a single window\"";
    }

    // cols
    if (rf.check("cols")) {
        qWarning() << "--cols option is deprecated. Use XML mode if you need more than one plot in a single window\"";
    }
//********************************************
//************************* Generic options
    int interval;
    // title
    if (rf.find("title").isString()) {
        emit setWindowTitle(QString("%1").arg(rf.find("title").asString().data()));
    }
    // position
    if (rf.find("x").isInt32() && rf.find("y").isInt32()) {
        emit setWindowPosition(rf.find("x").asInt32(), rf.find("y").asInt32());
    }
    // size
    if (rf.find("dx").isInt32() && rf.find("dy").isInt32()) {
        emit setWindowSize(rf.find("dx").asInt32(), rf.find("dy").asInt32());
    }
    // interval
    if (rf.find("interval").isInt32()) {
        interval = rf.find("interval").asInt32();
    }else{
        interval = 50;
    }
//*******************************************

    bool ok;
    if (rf.check("xml")) {
// XML Mode Options
        const std::string &filename = rf.findFile("xml");
        QString f = QString("%1").arg(filename.data());
        loader = new XmlLoader(f,plotManager,this);
        qDebug("Loading file %s",filename.c_str());
    } else {
// Command Line Mode Options
        qDebug("Loading from command line");
        loader = new SimpleLoader(&rf,plotManager, &ok,this);
        if (!ok) {
            usage();
            exit(1);
        }
    }
    plotManager->setInterval(interval);
    emit intervalLoaded(interval);


    updateCustomPlotSize();

    return true;
}