Ejemplo n.º 1
0
    void GLWidget::mouseMoveEvent(QMouseEvent *event){

        mouseMotion(event->pos().x(), event->y());

        if( CurrIM == ExploreMode){
            if(LeftButtonDown == 1 ){				// rotate the volume
                MouseMoveToRotate(event->x()-buttonDownX, event->y()-buttonDownY) ;
                buttonDownX = event->x() ;
                buttonDownY = event->y() ;
            }
            else if( RightButtonDown == 1){			// move the camera, zoom in or out
                MouseMoveToZoom(event->x()-buttonDownX, event->y()-buttonDownY) ;
                buttonDownX = event->x() ;
                buttonDownY = event->y() ;
            }
        } //if( InteractionMode == ExploreMode)
        else if( CurrIM == SelectMode){
            if(LeftButtonDown == 1 ){				// temporary streamline selection or seedpoint move
                if( streamlines.bSeedpointSelected && iSeedpointMoveDir != -1 ){// seedpoint was already selected
                    MouseMoveToSeedpointMove(event->x()-buttonDownX, event->y()-buttonDownY) ;
                    buttonDownX = event->x() ;
                    buttonDownY = event->y() ;
                    updateGL();
                }
                else{
                    SelectObjectAtXY(event->x(), event->y());
                    switch(ObjectCatagory){
                        case STREAMLINE:
                            //printf("ObjectName %d\n",iObjectName) ;
                            streamlines.bSeedpointSelected = false ;
                            streamlines.TemporarySelectedStreamline(iObjectName) ;
                            updateGL();
                            break ;
                        case SEEDPOINT:
                            if(!streamlines.bSeedpointSelected){		// user just moved in to seed point
                                buttonDownX = event->x() ;
                                buttonDownY = event->y() ;
                                streamlines.bSeedpointSelected = true ;
                                updateGL();
                            }
                            break ;
                        case NO_OBJECT:
                            streamlines.TempSelectedStreamline = -1 ;
                            streamlines.bSeedpointSelected = false ;
                            updateGL();
                            break ;
                        default:
                            printf("Unidentified object.\n") ;
                            break ;
                    }  //switch(iObjectCatagory){
                } // else
            } //if(LeftButtonDown == 1 ){
        } //else if( CurrIM == SelectMode){
    }
Ejemplo n.º 2
0
    // the mouse callback
    void GLWidget::mousePressEvent(QMouseEvent *event){

        if( CurrIM == ExploreMode ){				// xplore mode mouse interaction
            if (event->buttons() ) {
                 if (Qt::LeftButton){
                      LeftButtonDown = 1 ;
                      buttonDownX = event->x() ;
                      buttonDownY = event->y() ;
                 }

                 else if(Qt::RightButton){
                      RightButtonDown = 1 ;
                      buttonDownX = event->x() ;
                      buttonDownY = event->y() ;
                }
            } //if (state == GLUT_DOWN )
            else if( event->buttons() ){
                LeftButtonDown = RightButtonDown = 0 ;
                volRenderer.SetProjectionResolution(false, false) ;
                updateGL() ;
            }
        } //if( CurrIM == ExploreMode )
        else if(CurrIM == SelectMode ){
            if (event->buttons() ) {
                if( Qt::RightButton){
                        LeftButtonDown = 1 ;
                        SelectObjectAtXY(event->x(), event->y());
                        switch(ObjectCatagory){
                            case STREAMLINE:
                                streamlines.TemporarySelectedStreamline(iObjectName);
                                updateGL() ;
                                break ;
                            case SEEDPOINT:
                            buttonDownX = event->x ();
                            buttonDownY = event->y() ;
                                streamlines.bSeedpointSelected = true ;
                                updateGL() ;
                                break ;
                            case NO_OBJECT:
                                break;
                            default:
                                printf("Unidentified object.\n") ;
                                break ;
                        }//switch(iObjectCatagory){
            }
            } //if (state == GLUT_DOWN )
            else if( event->buttons() ){
                LeftButtonDown = RightButtonDown = 0 ;
                //clear if any streamline was temporarily selected
                streamlines.TempSelectedStreamline = -1 ;
                switch(ObjectCatagory){
                    case STREAMLINE:
                        streamlines.UpdateStreamlineStatus(iObjectName) ;
                        updateGL() ;
                        break ;
                    case SEEDPOINT:
                        if( streamlines.bSeedpointMoved )
                            streamlines.UpdateSeedPoint() ;
                        streamlines.bSeedpointMoved = false ;
                        streamlines.bSeedpointSelected = false ;
                        ObjectCatagory = NO_OBJECT ;
                        iSeedpointMoveDir = -1 ;
                        updateGL() ;
                        break ;
                    case NO_OBJECT:
                        break ;
                }//switch(ObjectCatagory){
            }//else if( state == GLUT_UP )
            else{
                LeftButtonDown = RightButtonDown = 0 ;
            }
        } //else if(CurrIM == SelectMode )
    }