void DialogRepositionSurface::GetCoordinate( double* pos )
{
  if (ui->tabWidget->currentIndex() == 0)
  {
    /*
    QStringList list = ui->lineEditTarget->text().split(",", QString::SkipEmptyParts);
    if (list.size() < 3)
      list = ui->lineEditTarget->text().split(" ", QString::SkipEmptyParts);

    for ( int i = 0; i < 3; i++ )
      pos[i] = list[i].toDouble();
    */
    pos[0] = ui->lineEditTargetX->text().toDouble();
    pos[1] = ui->lineEditTargetY->text().toDouble();
    pos[2] = ui->lineEditTargetZ->text().toDouble();
  }
  else
  {
    pos[0] = ui->lineEditCoordX->text().toDouble();
    pos[1] = ui->lineEditCoordY->text().toDouble();
    pos[2] = ui->lineEditCoordZ->text().toDouble();
    if (ui->radioButtonCoordRAS->isChecked())
    {
      LayerSurface* surf = (LayerSurface*)MainWindow::GetMainWindow()->GetActiveLayer( "Surface" );
      if ( surf )
      {
        surf->GetSurfaceRASAtVertex(GetVertex(), pos);
      }
    }
  }
}
Esempio n. 2
0
SurfaceROI* RenderView3D::InitializeSurfaceROI( int posX, int posY )
{
  double pos[3];
  vtkProp* prop = this->PickProp( posX, posY, pos );
  if ( !prop )
  {
    return NULL;
  }

  LayerCollection* lc_surf = MainWindow::GetMainWindow()->GetLayerCollection( "Surface" );
  LayerSurface* surf = NULL;
  for ( int i = 0; i < lc_surf->GetNumberOfLayers(); i++ )
  {
    LayerSurface* temp = (LayerSurface*)lc_surf->GetLayer(i);
    if ( temp->HasProp( prop ) )
    {
      surf = temp;
      break;
    }
  }

  if ( !surf )
  {
    return false;
  }

  lc_surf->SetActiveLayer( surf );
  SurfaceROI* roi = surf->GetSurfaceROI();
  if ( roi )
  {
    roi->InitializeOutline(pos);
  }
  return roi;
}
void DialogRepositionSurface::UpdateUI()
{
  MainWindow* mainwnd = MainWindow::GetMainWindowPointer();
  LayerSurface* surf = (LayerSurface*)mainwnd->GetActiveLayer( "Surface" );
  m_btnSave->Enable( surf && surf->IsModified() && !mainwnd->IsProcessing() );
  m_btnSaveAs->Enable( surf && !mainwnd->IsProcessing() );
  m_btnUndo->Enable( surf && surf->HasUndo() );
}
Esempio n. 4
0
void PanelSurface::OnSpinVectorPointSize( wxSpinEvent& event )
{
  LayerSurface* surf = ( LayerSurface* )MainWindow::GetMainWindowPointer()->GetLayerCollection( "Surface" )->GetActiveLayer();
  if ( surf )
  {
    surf->GetProperties()->SetVectorPointSize( event.GetInt() );
  }
}
Esempio n. 5
0
void PanelSurface::OnChoiceMeshColorMap( wxCommandEvent& event )
{
  LayerSurface* surf = ( LayerSurface* )MainWindow::GetMainWindowPointer()->GetLayerCollection( "Surface" )->GetActiveLayer();
  if ( surf )
  {
    surf->GetProperties()->SetMeshColorMap( event.GetSelection() );
  }  
}
void DialogRepositionSurface::UpdateUI()
{
  MainWindow* mainwnd = MainWindow::GetMainWindow();
  LayerSurface* surf = (LayerSurface*)mainwnd->GetActiveLayer( "Surface" );
  ui->pushButtonSave->setEnabled( surf && surf->IsModified() && !mainwnd->IsBusy() );
  ui->pushButtonSaveAs->setEnabled( surf && !mainwnd->IsBusy() );
  ui->pushButtonUndo->setEnabled( surf && surf->HasUndo() );
}
Esempio n. 7
0
void PanelSurface::OnCheckHideInfo( wxCommandEvent& event )
{
  LayerSurface* surf = ( LayerSurface* )MainWindow::GetMainWindowPointer()->GetLayerCollection( "Surface" )->GetActiveLayer();
  if ( surf )
  {
    surf->GetProperties()->SetShowInfo( !event.IsChecked() );
  }  
}
void DialogRepositionSurface::OnUndo( )
{
  LayerSurface* surf = (LayerSurface*)MainWindow::GetMainWindow()->GetActiveLayer( "Surface" );
  if ( surf )
  {
    surf->Undo();
    UpdateUI();
  }
}
void DialogRepositionSurface::OnUndo( wxCommandEvent& event )
{
  LayerSurface* surf = (LayerSurface*)MainWindow::GetMainWindowPointer()->GetActiveLayer( "Surface" );
  if ( surf )
  {
    surf->Undo();
    UpdateUI();
  }
}
Esempio n. 10
0
void PanelSurface::OnSurfaceLockUpdateUI( wxUpdateUIEvent& event )
{
  event.Enable( m_listBoxLayers->GetSelection() != wxNOT_FOUND );
  if ( m_listBoxLayers->GetSelection() != wxNOT_FOUND )
  {
    LayerSurface* layer = ( LayerSurface* )( void* )m_listBoxLayers->GetClientData( m_listBoxLayers->GetSelection() );
    event.Check( layer && layer->IsLocked() );
  }
}
Esempio n. 11
0
void PanelSurface::OnSliderOpacity( wxScrollEvent& event )
{
  if ( m_listBoxLayers->GetSelection() != wxNOT_FOUND )
  {
    LayerSurface* layer = ( LayerSurface* )( void* )m_listBoxLayers->GetClientData( m_listBoxLayers->GetSelection() );
    if ( layer )
      layer->GetProperties()->SetOpacity( event.GetPosition() / 100.0 );
  }
}
Esempio n. 12
0
void PanelSurface::OnLabelColorChanged( wxColourPickerEvent& event )
{
  LayerSurface* surf = ( LayerSurface* )MainWindow::GetMainWindowPointer()->GetLayerCollection( "Surface" )->GetActiveLayer();
  if ( surf )
  {
    wxColour c = event.GetColour();
    surf->GetActiveLabel()->SetColor( c.Red()/255.0, c.Green()/255.0, c.Blue()/255.0 );
  }
}
Esempio n. 13
0
void PanelSurface::OnSliderMidPoint( wxScrollEvent& event )
{
  LayerSurface* surf = ( LayerSurface* )MainWindow::GetMainWindowPointer()->GetLayerCollection( "Surface" )->GetActiveLayer();
  if ( surf )
  {
    double range[2];
    surf->GetCurvatureRange( range );
    surf->GetProperties()->SetThresholdMidPoint( (double)m_sliderMidPoint->GetValue() / 100.0 * ( range[1] - range[0] ) + range[0] );
  }
}
Esempio n. 14
0
void PanelSurface::OnSliderSlope( wxScrollEvent& event )
{
  LayerSurface* surf = ( LayerSurface* )MainWindow::GetMainWindowPointer()->GetLayerCollection( "Surface" )->GetActiveLayer();
  if ( surf )
  {
    double fMin = 0;
    double fMax = 100;
    surf->GetProperties()->SetThresholdSlope( (double)m_sliderSlope->GetValue() / 100.0 * ( fMax - fMin ) + fMin );
  }
}
Esempio n. 15
0
void PanelSurface::OnSliderMidPointChanging( wxScrollEvent& event )
{
  LayerSurface* surf = ( LayerSurface* )MainWindow::GetMainWindowPointer()->GetLayerCollection( "Surface" )->GetActiveLayer();
  if ( surf )
  {  
    double range[2];
    surf->GetCurvatureRange( range );
    UpdateTextValue( m_textMidPoint, (double)m_sliderMidPoint->GetValue() / 100.0 * ( range[1] - range[0] ) + range[0] );
  }
}
void DialogRepositionSurface::OnApply()
{
  LayerSurface* surf = (LayerSurface*)MainWindow::GetMainWindow()->GetActiveLayer("Surface");
  LayerMRI* mri = (LayerMRI*)MainWindow::GetMainWindow()->GetActiveLayer("MRI");
  QString msg;
  if ( !surf )
    msg = "No active surface found.";
  else if ( !mri && ui->tabWidget->currentIndex() == 0)
    msg = "No active volume found.";

  if (!msg.isEmpty())
  {
    QMessageBox::warning(this, "Error", msg);
    return;
  }

  if (ValidateAll())
  {
    ui->pushButtonApply->setDisabled(true);
    if (ui->tabWidget->currentIndex() == 0)
    {
      if (ui->comboBoxTarget->currentIndex() == 0)
      {
        surf->RepositionSurface(mri, GetVertex(),
                                GetIntensity(),
                                GetNeighborSize(),
                                GetSigma(),
                                GetFlags());
      }
      else
      {
        double pos[3];
        GetCoordinate(pos);
        surf->RepositionSurface( mri, GetVertex(),
                                       pos,
                                       GetNeighborSize(),
                                       GetSigma(),
                                       GetFlags());
      }
    }
    else if (ui->tabWidget->currentIndex() == 1)
    {
      double pos[3];
      GetCoordinate(pos);
      surf->RepositionVertex(GetVertex(), pos);
    }
    else
    {
      surf->RepositionSmoothSurface(GetVertex(), GetNeighborSize(), GetSmoothingSteps());
    }
    UpdateUI();
    ui->pushButtonApply->setDisabled(false);
    QTimer::singleShot(0, MainWindow::GetMainWindow(), SIGNAL(SlicePositionChanged()));
  }
}
Esempio n. 17
0
void PanelSurface::OnSurfaceLock( wxCommandEvent& event )
{
  if ( m_listBoxLayers->GetSelection() != wxNOT_FOUND )
  {
    LayerSurface* layer = ( LayerSurface* )( void* )m_listBoxLayers->GetClientData( m_listBoxLayers->GetSelection() );
    if ( layer )
    {
      layer->Lock( event.IsChecked() );
    }
  }
}
Esempio n. 18
0
void RenderView3D::UpdateScalarBar()
{
  LayerSurface* surf = (LayerSurface*) MainWindow::GetMainWindow()->GetActiveLayer( "Surface" );
  if ( surf && surf->GetActiveOverlay() )
  {
    m_actorScalarBar->SetLookupTable( surf->GetActiveOverlay()->GetProperty()->GetLookupTable() );
  }
  else
  {
    RenderView::UpdateScalarBar();
  }
}
Esempio n. 19
0
void PanelSurface::OnTextOpacity( wxCommandEvent& event )
{
  double dvalue;
  if ( m_textOpacity->GetValue().ToDouble( &dvalue ) )
  {
    LayerSurface* layer = ( LayerSurface* )( void* )m_listBoxLayers->GetClientData( m_listBoxLayers->GetSelection() );
    if ( layer && layer->GetProperties()->GetOpacity() != dvalue )
    {
      layer->GetProperties()->SetOpacity( dvalue );
    }
  }
}
void DialogRepositionSurface::UpdateVertex()
{
  LayerSurface* surf = (LayerSurface*)MainWindow::GetMainWindow()->GetActiveLayer( "Surface" );
  if (surf)
  {
    int nVertex = surf->GetVertexIndexAtTarget( surf->GetSlicePosition(), NULL );
    if ( nVertex >= 0 )
    {
      ui->lineEditVertex->setText( QString::number(nVertex) );
      ui->lineEditVertex2->setText(QString::number(nVertex) );
      ui->lineEditVertex3->setText(QString::number(nVertex) );
      OnCoordinateTypeChanged();
    }
  }
}
Esempio n. 21
0
void PanelSurface::OnChoiceCurvatureMap( wxCommandEvent& event )
{
  LayerSurface* surf = ( LayerSurface* )MainWindow::GetMainWindowPointer()->GetLayerCollection( "Surface" )->GetActiveLayer();
  if ( surf )
  {
    if ( event.GetSelection() < 3 )
      surf->GetProperties()->SetCurvatureMap( event.GetSelection() );
    else
    {
      // load new curvature maps
      MainWindow::GetMainWindowPointer()->LoadSurfaceCurvature();
    }
    UpdateUI();
  }
}
Esempio n. 22
0
void RenderView3D::AddSurfaceROIPoint( int posX, int posY )
{
  LayerSurface* surf = (LayerSurface*)MainWindow::GetMainWindow()->GetActiveLayer( "Surface" );
  if ( surf )
  {
    double pos[3];
    vtkProp* prop = this->PickProp( posX, posY, pos );
    if ( !prop || !surf->HasProp( prop ) )
    {
      return;
    }

    surf->GetSurfaceROI()->AddPoint( pos );
    RequestRedraw();
  }
}
Esempio n. 23
0
void PanelSurface::OnChoiceVector( wxCommandEvent& event )
{
  LayerSurface* surf = ( LayerSurface* )MainWindow::GetMainWindowPointer()->GetLayerCollection( "Surface" )->GetActiveLayer();
  if ( surf )
  {
    int nVector = event.GetSelection() - 1;
    if ( nVector < surf->GetNumberOfVectorSets() )
      surf->SetActiveVector( nVector );
    else
    {
      // load new
      MainWindow::GetMainWindowPointer()->LoadSurfaceVector();
      UpdateUI();
    }
  }
}
void DialogRepositionSurface::DoListenToMessage ( std::string const iMsg, void* iData, void* sender )
{
  if ( iMsg == "LayerModified" )
  {
    UpdateUI();
  }
  else if ( iMsg == "SurfaceVertexClicked" )
  {   
    LayerSurface* surf = (LayerSurface*)MainWindow::GetMainWindowPointer()->GetActiveLayer( "Surface" );
    if ( surf )
    {
      int nVertex = surf->GetVertexIndexAtTarget( surf->GetSlicePosition(), NULL );
      if ( nVertex >= 0 )
        m_textVertex->SetValue( ( wxString() << nVertex ) );
    }
  }
}
Esempio n. 25
0
void PanelSurface::OnChoiceLabel( wxCommandEvent& event )
{
  LayerSurface* surf = ( LayerSurface* )MainWindow::GetMainWindowPointer()->GetLayerCollection( "Surface" )->GetActiveLayer();
  if ( surf )
  {
    int nSel = event.GetSelection();
    if ( nSel >= surf->GetNumberOfLabels() )
    {
      MainWindow::GetMainWindowPointer()->LoadSurfaceLabel();
    }
    else
    {
      surf->SetActiveLabel( nSel );
    }
    UpdateUI();
  }  
}
Esempio n. 26
0
void PanelSurface::OnChoiceAnnotation( wxCommandEvent& event )
{
  LayerSurface* surf = ( LayerSurface* )MainWindow::GetMainWindowPointer()->GetLayerCollection( "Surface" )->GetActiveLayer();
  if ( surf )
  {
    int nSel = event.GetSelection() - 1;
    if ( nSel < surf->GetNumberOfAnnotations() )
    {
      surf->SetActiveAnnotation( nSel );
    }
    else
    {
      // load new overlay map
      MainWindow::GetMainWindowPointer()->LoadSurfaceAnnotation();
    }
    UpdateUI();
  }  
}
Esempio n. 27
0
void RenderView3D::PickCurrentSurfaceVertex(int posX, int posY)
{
  LayerCollection* lc_surface = MainWindow::GetMainWindow()->GetLayerCollection( "Surface" );

  this->setToolTip("");
  if ( lc_surface->IsEmpty() )
  {
    return;
  }

  vtkCellPicker* picker = vtkCellPicker::SafeDownCast( this->GetRenderWindow()->GetInteractor()->GetPicker() );
  if ( picker )
  {
    picker->InitializePickList();

    vtkPropCollection* props = GetRenderer()->GetViewProps();
    if ( props )
    {
      props->InitTraversal();
      vtkProp* prop = props->GetNextProp();
      while ( prop )
      {
        if ( vtkActor::SafeDownCast( prop ) )
        {
          picker->AddPickList( prop );
        }
        prop = props->GetNextProp();
      }
    }

    double pos[3];
    picker->Pick( posX, rect().height() - posY, 0, GetRenderer() );
    picker->GetPickPosition( pos );

    vtkProp* prop = picker->GetViewProp();
    Layer* layer = lc_surface->HasProp( prop );
    if (layer)
    {
      LayerSurface* surf = (LayerSurface*)layer;
      surf->SetCurrentVertex(surf->GetVertexIndexAtTarget(pos, NULL));
      emit SurfaceVertexClicked();
    }
  }
}
void DialogRepositionSurface::OnCoordinateTypeChanged()
{
  LayerSurface* surf = (LayerSurface*)MainWindow::GetMainWindow()->GetActiveLayer( "Surface" );
  if ( surf )
  {
    int nVertex = ui->lineEditVertex2->text().toInt();
    if (nVertex >= 0)
    {
      double pt[3];
      if (ui->radioButtonCoordRAS->isChecked())
        surf->GetRASAtVertex(nVertex, pt);
      else
        surf->GetSurfaceRASAtVertex(nVertex, pt);
      ui->lineEditCoordX->setText(QString::number(pt[0], 'f', 2));
      ui->lineEditCoordY->setText(QString::number(pt[1], 'f', 2));
      ui->lineEditCoordZ->setText(QString::number(pt[2], 'f', 2));
    }
  }
}
Esempio n. 29
0
void PanelSurface::OnTextPosition( wxCommandEvent& event )
{
  wxArrayString sa = MyUtils::SplitString( m_textPosition->GetValue(), _(",") );
  if ( sa.Count() < 3 )
    sa = MyUtils::SplitString( m_textPosition->GetValue(), _(" ") );
  
  double pos[3];
  if ( sa.Count() < 3 || !sa[0].ToDouble( pos ) || !sa[1].ToDouble( pos+1 ) || !sa[2].ToDouble( pos+2 ) )
  {
    cerr << "Please enter 3 numbers." << endl;
    return;
  }
      
  LayerSurface* surf = ( LayerSurface* )MainWindow::GetMainWindowPointer()->GetLayerCollection( "Surface" )->GetActiveLayer();
  if ( surf )
  {
    surf->GetProperties()->SetPosition( pos );
    UpdateUI();
  }  
}
void DialogRepositionSurface::UpdateIntensity()
{
  LayerMRI* mri = (LayerMRI*)MainWindow::GetMainWindow()->GetTopVisibleLayer("MRI");
  LayerSurface* surf = (LayerSurface*)MainWindow::GetMainWindow()->GetActiveLayer( "Surface" );
  if (mri && surf)
  {
    double ras[3], surf_ras[3];
    mri->GetSlicePosition(ras);
    surf->GetSurfaceRASAtTarget(ras, surf_ras);
    mri->RemapPositionToRealRAS(ras, ras);
    double val = mri->GetSampledVoxelValueByRAS(ras);
    if (val >= 0)
    {
      ui->lineEditTarget->setText(QString::number(val, 'f', 2));
      OnCoordinateTypeChanged();
    }
    ui->lineEditTargetX->setText(QString::number(surf_ras[0], 'f', 2));
    ui->lineEditTargetY->setText(QString::number(surf_ras[1], 'f', 2));
    ui->lineEditTargetZ->setText(QString::number(surf_ras[2], 'f', 2));
  }
}