Example #1
0
void GLWidget::delegateMouseMove(QMouseEvent *event)
{
    emit mouseMoved(this);

    // get window coordinates of event
    mouse_Event_X_ = event->x();
    mouse_Event_Y_ = event->y();

    // convert to scene coordinates
    if(isOnly2D_)
    {
        Eigen::Vector3d p = camera2D_.viewMatrixInverse() * Eigen::Vector3d(mouse_Event_X_, mouse_Event_Y_, 0);
        mouse_Event_XScene_ = p[0];
        mouse_Event_YScene_ = p[1];
    }

    // if there  is no mouse  button down, it  is a void  move event
    if(!(mouse_LeftButton_ || mouse_MidButton_ || mouse_RightButton_))
    {
        qint64 idleTime = mouse_timerIdleTime_.elapsed();
        if(idleTime>1)
        {
            MoveEvent(mouse_Event_XScene_, mouse_Event_YScene_);
        }
        mouse_timerIdleTime_.start();
        return;
    }
    
      // if there is no possible PMR actions, ignore this
      if(mouse_PMRAction_ == GLAction::None)
        return;

      // determines if the action should become a PMR action
      if(mouse_ClicAction_)
      {
        if(abs(mouse_PressEvent_X_ - mouse_Event_X_) > MIN_SIZE_DRAWING ||
           abs(mouse_PressEvent_Y_ - mouse_Event_Y_) > MIN_SIZE_DRAWING)
        {
            PMRPressEvent(mouse_PMRAction_,
                      mouse_PressEvent_XScene_, mouse_PressEvent_YScene_);
            mouse_ClicAction_ = GLAction::None;
        }
    }

    // calls the move event
    if(!mouse_ClicAction_)
    {
        qint64 idleTime = mouse_timerIdleTime_.elapsed();
        if(idleTime>1)
        {
            PMRMoveEvent(mouse_PMRAction_, mouse_Event_XScene_, mouse_Event_YScene_);
        }
        mouse_timerIdleTime_.start();
    }
}
VOID CComTouchDriver::ProcessInputEvent(const TOUCHINPUT* inData)
{
    DWORD dwCursorID = inData->dwID;
    DWORD dwEvent = inData->dwFlags;
    BOOL bFoundObj = FALSE;	

    
    // Check if contacts should be incremented
    if((dwEvent & TOUCHEVENTF_DOWN) && (dwCursorID != MOUSE_CURSOR_ID))
    {
        m_uNumContacts++;
    }

    // Screen the types of inputs and the number of contacts
    if((m_uNumContacts == 0) && (dwCursorID != MOUSE_CURSOR_ID))
    {
        return;
    }
    else if((m_uNumContacts > 0) && (dwCursorID == MOUSE_CURSOR_ID))
    {
        return;
    }

    // Check if contacts should be decremented
    if((dwEvent & TOUCHEVENTF_UP) && (dwCursorID != MOUSE_CURSOR_ID))
    {
        m_uNumContacts--;
    }    
    
    // Find the object and associate the cursor id with the object
    if(dwEvent & TOUCHEVENTF_DOWN)
    {
        std::list<CCoreObject*>::iterator it;
        for(it = m_lCoreObjects.begin(); it != m_lCoreObjects.end(); it++)
        {
            DownEvent(*it, inData, &bFoundObj);
            if(bFoundObj) break;
        }
    }
    else if(dwEvent & TOUCHEVENTF_MOVE)
    {
        if(m_mCursorObject.count(inData->dwID) > 0)
        {
            MoveEvent(inData);
        }
    }
    else if(dwEvent & TOUCHEVENTF_UP)
    {
        if(m_mCursorObject.count(inData->dwID) > 0)
        {
            UpEvent(inData);
        }
    }
}
Example #3
0
void CHLRView3D::OnMouseMove(UINT nFlags, CPoint point) 
{
    //   ============================  LEFT BUTTON =======================
  if ( nFlags & MK_LBUTTON)
    {
     if ( nFlags & CASCADESHORTCUTKEY ) 
	  {
	    // move with MB1 and Control : on the dynamic zooming  
	    // Do the zoom in function of mouse's coordinates  
	    myView->Zoom(myXmax,myYmax,point.x,point.y); 
	    // save the current mouse coordinate in min 
		myXmax = point.x; 
        myYmax = point.y;	
	  }
	  else // if ( Ctrl )
	  {
        switch (myCurrentMode)
        {
         case CurAction3d_Nothing :
            DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False);
		   myXmax = point.x; 
           myYmax = point.y;
           if (nFlags & MULTISELECTIONKEY)		
       	     MultiDragEvent(myXmax,myYmax,0);
           else
             DragEvent(myXmax,myYmax,0);
            DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_True);
          break;
         case CurAction3d_DynamicZooming :
	       myView->Zoom(myXmax,myYmax,point.x,point.y); 
	       // save the current mouse coordinate in min \n";
	       myXmax=point.x;  myYmax=point.y;
         break;
         case CurAction3d_WindowZooming :
		   myXmax = point.x; myYmax = point.y;	
            DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False,LongDash);
            DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_True,LongDash);
         break;
         case CurAction3d_DynamicPanning :
		   myView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
		   myXmax = point.x; myYmax = point.y;	
         break;
         case CurAction3d_GlobalPanning : // nothing           
        break;
        case  CurAction3d_DynamicRotation :
          myView->Rotation(point.x,point.y);
	      myView->Redraw();
        break;
        default :
           Standard_Failure::Raise(" incompatible Current Mode ");
        break;
        }//  switch (myCurrentMode)
      }// if ( nFlags & CASCADESHORTCUTKEY )  else 
    } else //   if ( nFlags & MK_LBUTTON) 
    //   ============================  MIDDLE BUTTON =======================
    if ( nFlags & MK_MBUTTON)
    {
     if ( nFlags & CASCADESHORTCUTKEY ) 
	  {
		myView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
		myXmax = point.x; myYmax = point.y;	

	  }
    } else //  if ( nFlags & MK_MBUTTON)
    //   ============================  RIGHT BUTTON =======================
    if ( nFlags & MK_RBUTTON)
    {
     if ( nFlags & CASCADESHORTCUTKEY ) 
	  {
      	 myView->Rotation(point.x,point.y);
	  }
    }else //if ( nFlags & MK_RBUTTON)
    //   ============================  NO BUTTON =======================
    {  // No buttons 
	  myXmax = point.x; myYmax = point.y;	
	  if (nFlags & MULTISELECTIONKEY)
		MultiMoveEvent(point.x,point.y);
	  else
		MoveEvent(point.x,point.y);
   }
}