Exemplo n.º 1
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;
}
Exemplo n.º 2
0
void PhysVector::init() {
    setFlag(ItemIsMovable);
    setFlag(ItemIsSelectable);
    setFlag(ItemSendsGeometryChanges);
    setFlag(ItemSendsScenePositionChanges);
    setFlag(ItemIsFocusable);
    setCacheMode(DeviceCoordinateCache);
    setZValue(-1);
    setPen(QPen(m_Color, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
    setLine(0 + Magnitude(), 0 + Magnitude(), 0, 0);
}

void PhysVector::createConnections() {
    connect(this, SIGNAL(reorderObjNav(QGraphicsItem *)), m_pParent, SLOT(onReorderObjNav(QGraphicsItem *)));
    connect(this, SIGNAL(changeItemName(const QString &, const QString &)), m_pParent, SLOT(onChangeItemName(const QString &, const QString &)));
    connect(this, SIGNAL(repaint()), m_pParent, SLOT(onRepaint()));
}

void PhysVector::clearParticle(PhysParticle *pObj) {
    //qDebug("PhysVector::clearParticle()");
    if (m_pStartParticle == pObj)
        m_pStartParticle = NULL;
    if (m_pEndParticle == pObj)
        m_pEndParticle = NULL;
}

PhysVector *PhysVector::copy() {
    PhysVector *pObj = NULL;
    pObj = new PhysVector(static_cast<CartesianGraph *>(parentItem()), Name());
    pObj -> theta(theta());
    pObj -> Magnitude(Magnitude());
Exemplo n.º 3
0
LRESULT CALLBACK WindowsWindow::dispatch(
    const HWND hWnd
,   const UINT message
,   const WPARAM wParam
,   const LPARAM lParam)
{
    assert(!m_hWnd || hWnd == m_hWnd);

    if (!m_hWnd)
        return DefWindowProc(hWnd, message, wParam, lParam);

    // Windows Messages: http://msdn.microsoft.com/en-us/library/windows/desktop/ms644927(v=vs.85).aspx#windows_messages
    switch (message)
    {
    case WM_QUIT:
    case WM_CLOSE:
        onClose();
        break;

    case WM_DESTROY:
        onDestroy();
        break;

    case WM_SIZE:
        onResize(LOWORD(lParam), HIWORD(lParam));
        break;

    case WM_PAINT:
        onRepaint();
        break;

    case WM_USER_IDLE:
        onIdle();
        break;

    case WM_KEYDOWN:
    case WM_SYSKEYDOWN:
        if(!onKeyPress(LOWORD(wParam)))
            DefWindowProc(hWnd, message, wParam, lParam);
        break;

    case WM_KEYUP:
    case WM_SYSKEYUP:
        if(!onKeyRelease(LOWORD(wParam)))
            DefWindowProc(hWnd, message, wParam, lParam);
        break;

    //case WM_ACTIVATE:
    //    // Check for minimization.
    //    if (!HIWORD(wParam))
    //        m_eventHandler->activateEvent();
    //    else
    //        m_eventHandler->minimizeEvent();
    //    break;

    case WM_SYSCOMMAND: 
        // Absorb some system commands.
        switch (wParam)
        {
        case SC_SCREENSAVE:
        case SC_MONITORPOWER:
            return 0;
        }

    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}