Exemplo n.º 1
0
bool Interactor2D::ProcessMouseUpEvent( wxMouseEvent& event, RenderView* renderview )
{
  RenderView2D* view = ( RenderView2D* )renderview;

  if ( m_bSelecting )
  {
    view->StopSelection();
    view->NeedRedraw();
  }
  
  m_nMousePosX = event.GetX();
  m_nMousePosY = event.GetY();
  m_bWindowLevel = false;
  m_bChangeSlice = false;
  m_bMovingCursor = false;
  m_bSelecting = false;

  view->UpdateAnnotation();
  view->Update2DOverlay();

  if ( event.LeftUp() )
  {
    return false;
  }
  else
  {
    return Interactor::ProcessMouseUpEvent( event, renderview );
  }
}
Exemplo n.º 2
0
bool Interactor2D::ProcessMouseUpEvent( QMouseEvent* event, RenderView* renderview )
{
  RenderView2D* view = ( RenderView2D* )renderview;

  if ( m_bSelecting )
  {
    view->StopSelection();
    view->RequestRedraw();
  }

  m_nMousePosX = event->x();
  m_nMousePosY = event->y();
  m_bWindowLevel = false;
  m_bChangeSlice = false;
  m_bMovingCursor = false;
  m_bSelecting = false;

  view->UpdateAnnotation();
  view->Update2DOverlay();

  if ( event->button() == Qt::LeftButton )
  {
    return false;
  }
  else
  {
    return Interactor::ProcessMouseUpEvent( event, renderview );
  }
}
Exemplo n.º 3
0
void Interactor2D::ProcessPostMouseWheelEvent( wxMouseEvent& event, RenderView* renderview )
{
  RenderView2D* view = ( RenderView2D* )renderview;
  view->UpdateAnnotation();
  view->Update2DOverlay();
  view->NeedRedraw();
  view->SendBroadcast( "Zooming", view );

  Interactor::ProcessPostMouseWheelEvent( event, renderview );
}
Exemplo n.º 4
0
void Interactor2D::ProcessPostMouseWheelEvent( QWheelEvent* event, RenderView* renderview )
{
  RenderView2D* view = ( RenderView2D* )renderview;
  view->UpdateAnnotation();
  view->Update2DOverlay();
  view->RequestRedraw();
  view->EmitZooming();

  Interactor::ProcessPostMouseWheelEvent( event, renderview );
}
Exemplo n.º 5
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
}
Exemplo n.º 6
0
bool Interactor2D::ProcessMouseMoveEvent( wxMouseEvent& event, RenderView* renderview )
{
  RenderView2D* view = ( RenderView2D* )renderview;

  LayerCollectionManager* lcm = MainWindow::GetMainWindowPointer()->GetLayerCollectionManager();
  if ( !lcm->HasAnyLayer() )
  {
    return Interactor::ProcessMouseMoveEvent( event, renderview );
  }

  int posX = event.GetX();
  int posY = event.GetY();

  if ( m_bChangeSlice )
  {
    double* voxelSize = lcm->GetLayerCollection( "MRI" )->GetWorldVoxelSize();
    int nPlane = view->GetViewPlane();
    double dPixelPer = -0.20;
    double dPosDiff =  ( ( (int)( dPixelPer * ( posY - m_nDownPosY ) ) ) / dPixelPer -
                         ( (int)( dPixelPer * ( m_nMousePosY - m_nDownPosY ) ) ) / dPixelPer )
                       * dPixelPer * voxelSize[nPlane];
    if ( lcm->OffsetSlicePosition( nPlane, dPosDiff ) )
    {
      m_nMousePosX = posX;
      m_nMousePosY = posY;
    }
  }
  else if ( m_bMovingCursor )
  {
    view->UpdateCursorRASPosition( posX, posY );
    view->NeedRedraw();
  }
  else if ( m_bWindowLevel )
  {
    std::vector<Layer*> layers = lcm->GetLayerCollection( "MRI" )->GetLayers();
    LayerMRI* layer = NULL;
    for ( size_t i = 0; i < layers.size(); i++ )
    {
      layer = ( LayerMRI*)layers[i];
      if ( layer->IsVisible() && layer->GetProperties()->GetColorMap() == LayerPropertiesMRI::Grayscale )
        break;
    }
    if ( layer )
    {
      double scaleX = 0.002;
      double scaleY = 0.002;
      double w = ( posX - m_nMousePosX ) * scaleX;
      double l = ( posY - m_nMousePosY ) * scaleY;
      double scaleOverall = layer->GetProperties()->GetMaxValue() -
                            layer->GetProperties()->GetMinValue();
      w *= scaleOverall;
      l *= scaleOverall;
      w += layer->GetProperties()->GetWindow();
      l += layer->GetProperties()->GetLevel();
      if ( w < 0 )
        w = 0;
      layer->GetProperties()->SetWindowLevel( w, l );
    }
    m_nMousePosX = posX;
    m_nMousePosY = posY;
  }
  else if ( m_bSelecting )
  {
    view->UpdateSelection( posX, posY );   
    view->NeedRedraw();
  }
  else
  {
    if ( event.MiddleIsDown() || event.RightIsDown() )
    {
      view->UpdateAnnotation();
      view->Update2DOverlay();
      if ( event.RightIsDown() )
        view->SendBroadcast( "Zooming", view );
    }
    else
      view->UpdateMouseRASPosition( posX, posY );

    return Interactor::ProcessMouseMoveEvent( event, renderview );
  }

  return false;
}
Exemplo n.º 7
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
}
Exemplo n.º 8
0
bool Interactor2D::ProcessMouseMoveEvent( QMouseEvent* event, RenderView* renderview )
{
  RenderView2D* view = ( RenderView2D* )renderview;

  MainWindow* mainwnd = MainWindow::GetMainWindow();
  if ( mainwnd->IsEmpty() )
  {
    return Interactor::ProcessMouseMoveEvent( event, renderview );
  }

  int posX = event->x();
  int posY = event->y();

  if ( m_bChangeSlice )
  {
    double* voxelSize = mainwnd->GetLayerCollection( "MRI" )->GetWorldVoxelSize();
    int nPlane = view->GetViewPlane();
    double dPixelPer = -0.25;

    double dPosDiff =  ( ( (int)( dPixelPer * ( posY - m_nDownPosY ) ) ) / dPixelPer -
                         ( (int)( dPixelPer * ( m_nMousePosY - m_nDownPosY ) ) ) / dPixelPer )
                       * dPixelPer * voxelSize[nPlane];
    if ( mainwnd->OffsetSlicePosition( nPlane, dPosDiff ) )
    {
      m_nMousePosX = posX;
      m_nMousePosY = posY;
    }
  }
  else if ( m_bMovingCursor )
  {
    view->UpdateCursorRASPosition( posX, posY );
    view->RequestRedraw();
  }
  else if ( m_bWindowLevel )
  {
    QList<Layer*> layers = mainwnd->GetLayerCollection( "MRI" )->GetLayers();
    LayerMRI* layer = (LayerMRI*)mainwnd->GetActiveLayer("MRI");
    if (layer && (!layer->IsVisible() || layer->GetProperty()->GetColorMap() == LayerPropertyMRI::LUT))
    {
      layer = NULL;
    }
    if (layer == NULL)
    {
      for ( int i = 0; i < layers.size(); i++ )
      {
        layer = ( LayerMRI*)layers[i];
        if ( layer->IsVisible() && layer->GetProperty()->GetColorMap() != LayerPropertyMRI::LUT )
        {
          break;
        }
        else
        {
          layer = NULL;
        }
      }
    }
    if ( layer )
    {
      double scaleX = 0.002;
      double scaleY = 0.002;
      double w = ( posX - m_nMousePosX ) * scaleX;
      double l = ( posY - m_nMousePosY ) * scaleY;
      double scaleOverall = layer->GetProperty()->GetMaxValue() -
                            layer->GetProperty()->GetMinValue();
      w *= scaleOverall;
      l *= scaleOverall;
      switch ( layer->GetProperty()->GetColorMap() )
      {
      case LayerPropertyMRI::Grayscale:
        w += layer->GetProperty()->GetWindow();
        l += layer->GetProperty()->GetLevel();
        if ( w < 0 )
        {
          w = 0;
        }
        layer->GetProperty()->SetWindowLevel(w, l);
        break;
      case LayerPropertyMRI::Heat:
        w += layer->GetProperty()->GetHeatScaleMaxThreshold() - layer->GetProperty()->GetHeatScaleMinThreshold();
        l += (layer->GetProperty()->GetHeatScaleMaxThreshold() + layer->GetProperty()->GetHeatScaleMinThreshold())/2;
        if ( w < 0 )
        {
          w = 0;
        }
        layer->GetProperty()->SetHeatScale( l-w/2, l, l+w/2 );
        break;
      default:
        w += layer->GetProperty()->GetMaxGenericThreshold() - layer->GetProperty()->GetMinGenericThreshold();
        l += (layer->GetProperty()->GetMaxGenericThreshold() + layer->GetProperty()->GetMinGenericThreshold())/2;
        if ( w < 0 )
        {
          w = 0;
        }
        layer->GetProperty()->SetMinMaxGenericThreshold( l-w/2, l+w/2 );
        break;
      }
    }
    m_nMousePosX = posX;
    m_nMousePosY = posY;
  }
  else if ( m_bSelecting )
  {
    view->UpdateSelection( posX, posY );
    view->RequestRedraw();
  }
  else
  {
    if ( event->buttons() & Qt::MidButton || event->buttons() & Qt::RightButton )
    {
      view->UpdateAnnotation();
      view->Update2DOverlay();
      if ( event->buttons() & Qt::RightButton )
      {
        view->EmitZooming();
      }
    }
    else
    {
      view->UpdateMouseRASPosition( posX, posY );
    }

    return Interactor::ProcessMouseMoveEvent( event, renderview );
  }

  return false;
}