示例#1
0
void CSVRender::WorldspaceWidget::mouseReleaseEvent (QMouseEvent *event)
{
    std::string button = mapButton (event);
    mDragMode.clear();

    if (button=="p-edit" || button=="s-edit" ||
        button=="p-select" || button=="s-select")
    {
        if (mDragging)
        {
            EditMode& editMode = dynamic_cast<CSVRender::EditMode&> (*mEditMode->getCurrent());

            editMode.dragCompleted();
            mDragging = false;
        }
        else
        {
            osg::ref_ptr<TagBase> tag = mousePick (event->pos());

            handleMouseClick (tag, button, event->modifiers() & Qt::ShiftModifier);
        }
    }
    else
        SceneWidget::mouseReleaseEvent(event);
}
示例#2
0
void CSVRender::WorldspaceWidget::mouseMoveEvent (QMouseEvent *event)
{
    if (mDragging)
    {
        int diffX = event->x() - mDragX;
        int diffY = (height() - event->y()) - mDragY;

        mDragX = event->x();
        mDragY = height() - event->y();

        double factor = mDragFactor;

        if (event->modifiers() & Qt::ShiftModifier)
            factor *= mDragShiftFactor;

        EditMode& editMode = dynamic_cast<CSVRender::EditMode&> (*mEditMode->getCurrent());

        editMode.drag (diffX, diffY, factor);
    }
    else if (mDragMode=="p-edit" || mDragMode=="s-edit" || mDragMode=="p-select" || mDragMode=="s-select")
    {
        osg::ref_ptr<TagBase> tag = mousePick (event->pos());

        EditMode& editMode = dynamic_cast<CSVRender::EditMode&> (*mEditMode->getCurrent());

        if (mDragMode=="p-edit")
            mDragging = editMode.primaryEditStartDrag (tag);
        else if (mDragMode=="s-edit")
            mDragging = editMode.secondaryEditStartDrag (tag);
        else if (mDragMode=="p-select")
            mDragging = editMode.primarySelectStartDrag (tag);
        else if (mDragMode=="s-select")
            mDragging = editMode.secondarySelectStartDrag (tag);

        if (mDragging)
        {
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
            mDragX = event->localPos().x();
            mDragY = height() - event->localPos().y();
#else
            mDragX = event->posF().x();
            mDragY = height() - event->posF().y();
#endif
        }
    }
    else
    {
        if (event->globalPos()!=mToolTipPos)
        {
            mToolTipPos = event->globalPos();

            if (mShowToolTips)
                mToolTipDelayTimer.start (mToolTipDelay);
        }

        SceneWidget::mouseMoveEvent(event);
    }
}
示例#3
0
void CSVRender::WorldspaceWidget::showToolTip()
{
    if (mShowToolTips)
    {
        QPoint pos = QCursor::pos();

        if (osg::ref_ptr<TagBase> tag = mousePick (mapFromGlobal (pos)))
        {
            bool hideBasics = CSMPrefs::get()["Tooltips"]["scene-hide-basic"].isTrue();
            QToolTip::showText (pos, tag->getToolTip (hideBasics), this);
        }
    }
}
void CSVRender::WorldspaceWidget::showToolTip()
{
    if (mShowToolTips)
    {
        QPoint pos = QCursor::pos();

        WorldspaceHitResult hit = mousePick (mapFromGlobal (pos), getInteractionMask());
        if (hit.tag)
        {
            bool hideBasics = CSMPrefs::get()["Tooltips"]["scene-hide-basic"].isTrue();
            QToolTip::showText (pos, hit.tag->getToolTip (hideBasics), this);
        }
    }
}
void CSVRender::WorldspaceWidget::handleInteraction(InteractionType type, bool activate)
{
    if (activate)
    {
        if (!mDragging)
            mDragMode = type;
    }
    else
    {
        mDragMode = InteractionType_None;

        if (mDragging)
        {
            EditMode* editMode = getEditMode();
            editMode->dragCompleted(mapFromGlobal(QCursor::pos()));
            mDragging = false;
        }
        else
        {
            WorldspaceHitResult hit = mousePick(mapFromGlobal(QCursor::pos()), getInteractionMask());
            handleInteractionPress(hit, type);
        }
    }
}