示例#1
0
bool Interactor2D::ProcessMouseDownEvent( wxMouseEvent& event, RenderView* renderview )
{
  RenderView2D* view = ( RenderView2D* )renderview;

  m_nMousePosX = event.GetX();
  m_nMousePosY = event.GetY();

  view->UpdateAnnotation();

  if ( event.CmdDown() && !event.ShiftDown() )
  {
    if ( event.LeftDown() )
    {
      view->ZoomAtCursor( m_nMousePosX, m_nMousePosY, true );
      return false;
    }
    else if ( event.RightDown() )
    {
      view->ZoomAtCursor( m_nMousePosX, m_nMousePosY, false );
      return false;
    }
  }

  if ( event.LeftDown() )
  {
    m_nDownPosX = m_nMousePosX;
    m_nDownPosY = m_nMousePosY;

    if ( event.ShiftDown() && !event.CmdDown() )
    {
      m_bWindowLevel = true;
    }
    else
    {
      m_bMovingCursor = true;
      view->UpdateCursorRASPosition( m_nMousePosX, m_nMousePosY );
      view->NeedRedraw();
    }
  }
  else if ( event.MiddleDown() && event.ShiftDown() )
  {
      m_bSelecting = true;
      view->StartSelection( m_nMousePosX, m_nMousePosY );
  }
  else if ( event.RightDown() && event.ShiftDown() && !event.CmdDown() )
  {
    m_bWindowLevel = true;
  }
  else
  {
    return Interactor::ProcessMouseDownEvent( event, renderview ); // pass down the event
  }

  return false; // do not pass down the event
}
示例#2
0
bool Interactor2D::ProcessMouseDownEvent( QMouseEvent* event, RenderView* renderview )
{
  RenderView2D* view = ( RenderView2D* )renderview;

  m_nMousePosX = event->x();
  m_nMousePosY = event->y();

  view->UpdateAnnotation();

  view->PickLineProfile(m_nMousePosX, m_nMousePosY);

  MainWindow* mainwnd = MainWindow::GetMainWindow();
  if ( ( event->modifiers() & CONTROL_MODIFIER ) &&  !( event->modifiers() & Qt::ShiftModifier ) )
  {
    if ( event->button() == Qt::LeftButton )
    {
#ifndef Q_WS_MAC
      view->ZoomAtCursor( m_nMousePosX, m_nMousePosY, 2.0 );    // zoom in
#endif
      return false;
    }
    else if ( event->button() == Qt::RightButton )
    {
#ifndef Q_WS_MAC
      view->ZoomAtCursor( m_nMousePosX, m_nMousePosY, 0.5 );    // zoom out
#endif
      return false;
    }
  }

  if ( event->button() == Qt::LeftButton )
  {
    m_nDownPosX = m_nMousePosX;
    m_nDownPosY = m_nMousePosY;

    if ( !( event->modifiers() & CONTROL_MODIFIER ) &&  ( event->modifiers() & Qt::ShiftModifier ) &&
         !mainwnd->IsRepositioningSurface())
    {
      m_bWindowLevel = true;
    }
    else
    {
      m_bMovingCursor = true;
      view->UpdateCursorRASPosition( m_nMousePosX, m_nMousePosY );
      view->RequestRedraw();
      if (mainwnd->IsRepositioningSurface())
      {
        if ( event->modifiers() & CONTROL_MODIFIER &&
          event->modifiers() & Qt::ShiftModifier)
          QTimer::singleShot(0, mainwnd, SIGNAL(SurfaceRepositionIntensityChanged()));
        else if (event->modifiers() & Qt::ShiftModifier)
          QTimer::singleShot(0, mainwnd, SIGNAL(SurfaceRepositionVertexChanged()));
      }
    }
  }
  else if ( event->button() == Qt::MidButton && ( event->modifiers() & Qt::ShiftModifier ) )
  {
    m_bSelecting = true;
    view->StartSelection( m_nMousePosX, m_nMousePosY );
  }
  else if ( event->button() == Qt::RightButton &&
            !( event->modifiers() & CONTROL_MODIFIER ) &&
            ( event->modifiers() & Qt::ShiftModifier ) )
  {
    m_bWindowLevel = true;
  }
#ifdef Q_WS_MAC
  else if ( event->button() == Qt::RightButton &&
            ( event->modifiers() & CONTROL_MODIFIER ) &&
            ( event->modifiers() & Qt::ShiftModifier ) )
  {
    m_bMovingCursor = true;
    view->UpdateCursorRASPosition( m_nMousePosX, m_nMousePosY );
    view->RequestRedraw();
  }
#endif
  else if (event->button() == Qt::MidButton && (event->modifiers() & CONTROL_MODIFIER ))
  {
    m_bChangeSlice = true;
  }
  else
  {
    return Interactor::ProcessMouseDownEvent( event, renderview ); // pass down the event
  }

  return false; // do not pass down the event
}