Exemplo n.º 1
0
void GraphModeler::rightClick(Q3ListViewItem *item, const QPoint &point, int index)
{
    if (!item) return;
    bool isNode=true;
    helper::vector<Q3ListViewItem*> selection; getSelectedItems(selection);
    bool isSingleSelection= (selection.size() == 1);
    for (unsigned int i=0; i<selection.size(); ++i)
    {
        if (getObject(item)!=NULL)
        {
            isNode = false;
            break;
        }
    }

    bool isLoader = false;
    if (dynamic_cast<sofa::core::loader::BaseLoader*>(getComponent(item)) != NULL)
        isLoader = true;

    Q3PopupMenu *contextMenu = new Q3PopupMenu ( this, "ContextMenu" );
    if (isNode)
    {
        contextMenu->insertItem("Collapse", this, SLOT( collapseNode()));
        contextMenu->insertItem("Expand"  , this, SLOT( expandNode()));
        if (isSingleSelection)
        {
            contextMenu->insertSeparator ();
            contextMenu->insertItem("Load"  , this, SLOT( loadNode()));
            contextMenu->insertItem(QIconSet(), tr( "Preset"), preset);
        }
    }
    contextMenu->insertItem("Save"  , this, SLOT( saveComponents()));

    /*int index_menu = */contextMenu->insertItem("Delete"  , this, SLOT( deleteComponent()));

    //If the node/component is not erasable, clicking on Delete won't do anything.
//        if (isNode)
//        {
//          if ( !isNodeErasable ( getNode(item) ) )
//            contextMenu->setItemEnabled ( index_menu,false );
//        }
//        else
//        {
//          if ( !isObjectErasable ( getObject(item) ))
//            contextMenu->setItemEnabled ( index_menu,false );
//        }

    contextMenu->insertItem("Modify"  , this, SLOT( openModifyObject()));
    contextMenu->insertItem("GlobalModification"  , this, SLOT( globalModification()));

    if (!isNode && !isLoader)
        contextMenu->insertItem("Link"  , this, SLOT( linkComponent()));

    contextMenu->popup ( point, index );

}
Exemplo n.º 2
0
void FloatyPlugin::showPopup()
{
    ProcessMenuParam mp;
    mp.id    = MenuContact;
    mp.param = (void*)(popupId);
    mp.key	 = 0;
    Event eMenu(EventProcessMenu, &mp);
    Q3PopupMenu *menu = (Q3PopupMenu*)eMenu.process();
    menu->popup(popupPos);
}
Exemplo n.º 3
0
bool ShortcutsPlugin::eventFilter(QObject *o, QEvent *e)
{
    unsigned button = 0;
    QMouseEvent *me = NULL;
    if (e->type() == QEvent::MouseButtonPress){
        me = static_cast<QMouseEvent*>(e);
        switch (me->button()){
        case Qt::LeftButton:
            button = 1;
            break;
        case Qt::RightButton:
            button = 2;
            break;
        case Qt::MidButton:
            button = 3;
            break;
        default:
            break;
        }
    }
    if (e->type() == QEvent::MouseButtonDblClick){
        me = static_cast<QMouseEvent*>(e);
        switch (me->button()){
        case Qt::LeftButton:
            button = 4;
            break;
        case Qt::RightButton:
            button = 5;
            break;
        case Qt::MidButton:
            button = 6;
            break;
        default:
            break;
        }
    }
    if (me){
        button |= me->state() & (Qt::AltModifier | Qt::ControlModifier | Qt::ShiftModifier);
        MAP_CMDS::iterator it = mouseCmds.find(button);
        if (it != mouseCmds.end()){
            const CommandDef &cmd = (*it).second;
            Event e(EventGetMenu, (void*)&cmd);
            Q3PopupMenu *popup = (Q3PopupMenu*)(e.process());
            if (popup){
                popup->popup(me->globalPos());
                return true;
            }
        }
    }
    return QObject::eventFilter(o, e);
}
Exemplo n.º 4
0
void QSofaListView::RunSofaRightClicked( Q3ListViewItem *item,
        const QPoint& point,
        int index )
{

    if( item == NULL) return;
    //updateMatchingObjectmodel();
    bool object_hasData = false;
    if(object_.type == typeObject)
    {
        object_hasData = object_.ptr.Object->getDataFields().size() > 0 ? true : false;
    }
    Q3PopupMenu *contextMenu = new Q3PopupMenu ( this, "ContextMenu" );
    if( object_.isNode() )
    {
        int index_menu = contextMenu->insertItem("Focus", this,SLOT(focusNode()) );
        bool enable = object_.ptr.Node->f_bbox.getValue().isValid() && !object_.ptr.Node->f_bbox.getValue().isFlat();
        contextMenu->setItemEnabled(index_menu,enable);
    }
    if( object_.isObject() )
    {
        int index_menu = contextMenu->insertItem("Focus", this,SLOT( focusObject() ) );
        bool enable = object_.ptr.Object->f_bbox.getValue().isValid() && !object_.ptr.Object->f_bbox.getValue().isFlat() ;
        contextMenu->setItemEnabled(index_menu,enable);
    }
    contextMenu->insertSeparator();

    //Creation of the context Menu
    if ( object_.type == typeNode)
    {
        contextMenu->insertItem ( "Collapse", this, SLOT ( collapseNode() ) );
        contextMenu->insertItem ( "Expand", this, SLOT ( expandNode() ) );
        contextMenu->insertSeparator ();
        /*****************************************************************************************************************/
        if (object_.ptr.Node->isActive())
            contextMenu->insertItem ( "Deactivate", this, SLOT ( DeactivateNode() ) );
        else
            contextMenu->insertItem ( "Activate", this, SLOT ( ActivateNode() ) );
        contextMenu->insertSeparator ();
        /*****************************************************************************************************************/

        contextMenu->insertItem ( "Save Node", this, SLOT ( SaveNode() ) );
        contextMenu->insertItem ( "Export OBJ", this, SLOT ( exportOBJ() ) );

        if ( attribute_ == SIMULATION)
        {
            contextMenu->insertItem ( "Add Node", this, SLOT ( RaiseAddObject() ) );

            int index_menu = contextMenu->insertItem ( "Remove Node", this, SLOT ( RemoveNode() ) );
            //If one of the elements or child of the current node is beeing modified, you cannot allow the user to erase the node
            if ( !isNodeErasable ( object_.ptr.Node ) )
                contextMenu->setItemEnabled ( index_menu,false );
        }
    }
    contextMenu->insertItem ( "Modify", this, SLOT ( Modify() ) );
    if(object_hasData)
    {
        if(item->childCount() > 0)
        {
            contextMenu->insertItem("Hide Datas",this, SLOT ( HideDatas() ) );
        }
        else
        {
            contextMenu->insertItem("Show Datas", this, SLOT ( ShowDatas() ) );
        }
    }
    contextMenu->popup ( point, index );
}