Example #1
0
void TMGraphView::mouseReleaseEvent(QMouseEvent * event)
{
    if(event->button() == Qt::LeftButton)
    {
        // User is trying to select an event
        if(abs(drag_start.x() - event->pos().x()) < 10 || abs(drag_start.y() - event->pos().y()) < 10)
        {
            Event ev = findEventAt(event->pos());
            emit eventDescriptionQueried(ev); // Mongoclient "should" reply with the description
        }
    }
    else if(event->button() == Qt::RightButton)
    {
        if(abs(zoom_start.x() - event->pos().x()) < 10 || abs(zoom_start.y() - event->pos().y()) < 10)
            return; // probably a missclick
        if(zoom_state == ZOOM_FORWARD)
        {
            addressMove((long long)(min(zoom_start.x(), event->pos().x())/address_zoom_factor));
            timeMove((long long)(min(zoom_start.y(), event->pos().y())/time_zoom_factor));
            address_zoom_factor *= width()/(double)abs(zoom_start.x() - event->pos().x());
            time_zoom_factor *= height()/(double)abs(zoom_start.y() - event->pos().y());
        }
        else if(zoom_state == ZOOM_BACKWARD)
        {
            address_zoom_factor *= abs(zoom_start.x() - event->pos().x())/(double)width();
            time_zoom_factor *= abs(zoom_start.y() - event->pos().y())/(double)height();
            addressMove(-(long long)(min(zoom_start.x(), event->pos().x())/address_zoom_factor));
            timeMove(-(long long)(min(zoom_start.y(), event->pos().y())/time_zoom_factor));
        }
        zoom_state = NO_ZOOM;
        update();
    }
}
void TMGraphView::keyPressEvent(QKeyEvent * event)
{
    static const double speed = 0.05;
    if(event->key() == Qt::Key_Up)
    {
        timeMove((long)(-height()*speed/time_zoom_factor));
        update();
    }
    else if(event->key() == Qt::Key_Down)
    {
        timeMove((long)(height()*speed/time_zoom_factor));
        update();
    }
    else if(event->key() == Qt::Key_Left)
    {
        addressMove((long)(-width()*speed/address_zoom_factor));
        update();
    }
    else if(event->key() == Qt::Key_Right)
    {
        addressMove((long)(width()*speed/address_zoom_factor));
        update();
    }
    else if(event->key() == Qt::Key_Plus)
    {
        size_px+=1;
        update();
    }
    else if(event->key() == Qt::Key_Minus)
    {
        size_px=max(size_px-1,1);
        update();
    }
}
Example #3
0
void TMGraphView::mouseMoveEvent(QMouseEvent * event)
{
    if(event->buttons() & Qt::LeftButton)
    {
        addressMove((long)((drag_last_pos.x()-event->pos().x())/address_zoom_factor));
        drag_last_pos.setX(event->pos().x());
        timeMove((long)((drag_last_pos.y()-event->pos().y())/time_zoom_factor));
        drag_last_pos.setY(event->pos().y());
        update();
    }
    emit cursorPositionChange(displayAddressToRealAddress(view_address + (long long)(event->pos().x()/address_zoom_factor)),
                              view_time + (long long)(event->pos().y()/time_zoom_factor));
}
Example #4
0
void TMGraphView::wheelEvent(QWheelEvent *event)
{
    event->accept();
    double f = (event->angleDelta().y()+event->angleDelta().x())/2000.0;
    Qt::KeyboardModifiers mod = QGuiApplication::keyboardModifiers();
    if(mod == Qt::NoModifier || mod == Qt::ControlModifier)
    {
        addressMove((long long)(event->pos().x()/address_zoom_factor*(2*f)/(1+f)));
        address_zoom_factor *= (1+f)/(1-f);
    }
    if(mod == Qt::NoModifier || mod == Qt::ShiftModifier)
    {
        timeMove((long long)(event->pos().y()/time_zoom_factor*(2*f)/(1+f)));
        time_zoom_factor *= (1+f)/(1-f);
    }
    else if(mod ==Qt::AltModifier)
    {
        size_factor *= (1+f)/(1-f);
        if(size_factor < 1)
            size_factor = 1;
    }
    update();
}