コード例 #1
0
void ToolWindowEdit::DoUpdateTools()
{
  int nViewId = MainWindow::GetMainWindowPointer()->GetActiveViewId();
  if ( nViewId < 0 || nViewId > 2 )
    nViewId = 0;
  RenderView2D* view = ( RenderView2D* )MainWindow::GetMainWindowPointer()->GetRenderView( nViewId );
  
  bool bVoxelEditVisible = m_toolbarVoxelEdit->IsShown();
  bool bROIEditVisible = m_toolbarROIEdit->IsShown();
  if ( bVoxelEditVisible != (view->GetInteractionMode() == RenderView2D::IM_VoxelEdit) ||
       bROIEditVisible != (view->GetInteractionMode() == RenderView2D::IM_ROIEdit) )
  {
    m_toolbarVoxelEdit ->Show( view->GetInteractionMode() == RenderView2D::IM_VoxelEdit );
    m_toolbarROIEdit ->Show( view->GetInteractionMode() == RenderView2D::IM_ROIEdit );

    XRCCTRL( *this, "ID_PANEL_HOLDER", wxPanel )->Layout();
  }

// XRCCTRL( *m_toolbarBrush, "ID_STATIC_BRUSH_SIZE", wxStaticText )->Enable( m_viewAxial->GetAction() != Interactor2DROIEdit::EM_Fill );
  m_spinBrushSize->Enable( view->GetAction() != Interactor2DROIEdit::EM_Fill );
  m_spinBrushTolerance->Enable( view->GetAction() == Interactor2DROIEdit::EM_Fill );
// choiceTemplate->Enable( checkTemplate->IsChecked() && m_viewAxial->GetAction() == Interactor2DROIEdit::EM_Fill );
// XRCCTRL( *m_toolbarBrush, "ID_STATIC_BRUSH_TOLERANCE", wxStaticText )->Enable( checkTemplate->IsChecked() ); //&& m_viewAxial->GetAction() == Interactor2DROIEdit::EM_Fill );
// XRCCTRL( *m_toolbarBrush, "ID_SPIN_BRUSH_TOLERANCE", wxSpinCtrl )->Enable( checkTemplate->IsChecked() );//&& m_viewAxial->GetAction() == Interactor2DROIEdit::EM_Fill );

  BrushProperty* bp = MainWindow::GetMainWindowPointer()->GetBrushProperty();
  LayerVolumeBase* layer = bp->GetReferenceLayer();
// if ( m_choiceTemplate->GetSelection() != wxNOT_FOUND )
//  layer = ( LayerEditable* )(void*)m_choiceTemplate->GetClientData( m_choiceTemplate->GetSelection() );

  m_choiceTemplate->Clear();
  m_choiceTemplate->Append( _("None"), (void*)NULL );
  LayerCollection* lc = MainWindow::GetMainWindowPointer()->GetLayerCollection( "MRI" );
  int nSel = 0;
  for ( int i = 0; i < lc->GetNumberOfLayers(); i++ )
  {
    LayerMRI* mri = (LayerMRI*)lc->GetLayer( i );
    if ( layer == mri )
    {
      nSel = i+1;
    }

    m_choiceTemplate->Append( wxString::FromAscii( mri->GetName() ), (void*)mri );
  }
// if ( !lc->IsEmpty() )
  m_choiceTemplate->SetSelection( nSel );

  m_spinBrushSize->SetValue( bp->GetBrushSize() );
  m_spinBrushTolerance->SetValue( bp->GetBrushTolerance( ) );

  m_checkDrawConnectedOnly->SetValue( bp->GetDrawConnectedOnly() );
  m_checkDrawRange  ->SetValue( bp->GetDrawRangeEnabled() );
  m_checkExcludeRange  ->SetValue( bp->GetExcludeRangeEnabled() );

  m_editDrawRangeLow  ->Enable( bp->GetDrawRangeEnabled() );
  m_editDrawRangeHigh  ->Enable( bp->GetDrawRangeEnabled() );
  m_editExcludeRangeLow ->Enable( bp->GetExcludeRangeEnabled() );
  m_editExcludeRangeHigh ->Enable( bp->GetExcludeRangeEnabled() );

  double* range = bp->GetDrawRange();
  UpdateTextValue( m_editDrawRangeLow, range[0] );
  UpdateTextValue( m_editDrawRangeHigh, range[1] );
  range = bp->GetExcludeRange();
  UpdateTextValue( m_editExcludeRangeLow, range[0] );
  UpdateTextValue( m_editExcludeRangeHigh, range[1] );

  Contour2D* c2d = view->GetContour2D();
  m_checkSmooth->SetValue( c2d->GetSmooth() );
  UpdateTextValue( m_editSmoothSD, c2d->GetSmoothSD() );
  m_editSmoothSD->Enable( c2d->GetSmooth() );
  UpdateTextValue( m_editContourValue, c2d->GetContourValue() );
  
  double* rgb = c2d->GetContourColor();
  m_colorPickerContour->SetColour( wxColour( (int)(rgb[0]*255), (int)(rgb[1]*255), (int)(rgb[2]*255) ) );
  
  int nAction = view->GetAction(); 
  ShowWidgets( m_widgetsBrushSize, nAction != Interactor2DVoxelEdit::EM_Contour &&
                                   nAction != Interactor2DVoxelEdit::EM_ColorPicker && 
                                   nAction != Interactor2DVoxelEdit::EM_Fill );
  ShowWidgets( m_widgetsReference, nAction == Interactor2DVoxelEdit::EM_Fill || 
                                   nAction == Interactor2DVoxelEdit::EM_Contour );  
  ShowWidgets( m_widgetsTolerance, nAction == Interactor2DVoxelEdit::EM_Fill );
  ShowWidgets( m_widgetsConstrain, nAction != Interactor2DVoxelEdit::EM_ColorPicker && 
      nAction != Interactor2DVoxelEdit::EM_Contour ); 
  ShowWidgets( m_widgetsSmooth, nAction == Interactor2DVoxelEdit::EM_Contour );
  ShowWidgets( m_widgetsContour, nAction == Interactor2DVoxelEdit::EM_Contour );
  
  m_bToUpdateTools = false;
  wxPanel* panel = XRCCTRL( *this, "ID_PANEL_HOLDER", wxPanel );
  panel->Layout();
  panel->Fit();
  Fit();
  Layout();
  MainWindow::GetMainWindowPointer()->NeedRedraw( 1 );
}
コード例 #2
0
void InfoTreeWidget::UpdateAll()
{
  this->clear();
  m_editor->hide();
  LayerCollection* lc_mri = MainWindow::GetMainWindow()->GetLayerCollection( "MRI" );
  LayerCollection* lc_surf = MainWindow::GetMainWindow()->GetLayerCollection( "Surface" );

  if ( lc_mri->IsEmpty() && lc_surf->IsEmpty())
  {
    return;
  }

  QTreeWidgetItem* item = new QTreeWidgetItem(this);
  item->setText(0, "RAS");

  double ras[3] = {m_dRAS[0], m_dRAS[1], m_dRAS[2]};
  if (!lc_mri->IsEmpty())
  {
    qobject_cast<LayerMRI*>(lc_mri->GetLayer(0))->RemapPositionToRealRAS(m_dRAS, ras);
  }
  QVariantMap map;
  item->setText(1, QString("%1, %2, %3")
                .arg(ras[0], 0, 'f', 2)
                .arg(ras[1], 0, 'f', 2)
                .arg(ras[2], 0, 'f', 2));
  map["Type"] = "RAS";
  map["EditableText"] = item->text(1);
  item->setData(1, Qt::UserRole, map);

  for (int i = 0; i < lc_mri->GetNumberOfLayers(); i++)
  {
    LayerMRI* layer = (LayerMRI*)lc_mri->GetLayer(i);
    int nIndex[3];
    if ( layer->GetProperty()->GetShowInfo() )
    {
      QTreeWidgetItem* item = new QTreeWidgetItem(this);
      item->setText(0, layer->GetName());
      layer->RASToOriginalIndex( ras, nIndex );
      double dvalue = layer->GetVoxelValue( m_dRAS );
      QString editable = QString("%1, %2, %3").arg(nIndex[0]).arg(nIndex[1]).arg(nIndex[2]);
      QString strg = QString("%1 \t[%2]").arg(dvalue).arg(editable);
      QString labelStrg;
      if (layer->IsTypeOf("PLabel"))
      {
        labelStrg = ((LayerPLabel*)layer)->GetLabelName(m_dRAS);
      }
      else
      {
        labelStrg = layer->GetLabelName( dvalue );
      }
      if (!labelStrg.isEmpty())
      {
        strg += "  " + labelStrg;
      }
      item->setText(1, strg);
      map.clear();
      map["Type"] = "MRI";
      map["EditableText"] = editable;
      map["Object"] = QVariant::fromValue((QObject*)layer);
      item->setData(1, Qt::UserRole, map);
    }
  }

  for (int i = 0; i < lc_surf->GetNumberOfLayers(); i++)
  {
    LayerSurface* surf = (LayerSurface*)lc_surf->GetLayer(i);
    if ( surf->GetProperty()->GetShowInfo() )
    {
      QTreeWidgetItem* item = new QTreeWidgetItem(this);
      item->setText(0, surf->GetName());
      double sf_pos[3];
      surf->GetSurfaceRASAtTarget( m_dRAS, sf_pos );
      QString editable = QString("%1, %2, %3")
                         .arg(sf_pos[0], 0, 'f', 2)
                         .arg(sf_pos[1], 0, 'f', 2)
                         .arg(sf_pos[2], 0, 'f', 2);
      item->setText(1, QString("SurfaceRAS\t[%1]").arg(editable));
      map.clear();
      map["Type"] = "SurfaceRAS";
      map["EditableText"] = editable;
      map["Object"] = QVariant::fromValue((QObject*)surf);
      item->setData(1, Qt::UserRole, map);

      int nVertex = surf->GetVertexIndexAtTarget( m_dRAS, NULL );
      if ( nVertex >= 0 )
      {
        surf->GetSurfaceRASAtVertex( nVertex, sf_pos );
        QTreeWidgetItem* item = new QTreeWidgetItem(this);
        item->setText(1, QString("Vertex \t%1  [%2, %3, %4]")
                      .arg(nVertex)
                      .arg(sf_pos[0], 0, 'f', 2)
                      .arg(sf_pos[1], 0, 'f', 2)
                      .arg(sf_pos[2], 0, 'f', 2));
        map.clear();
        map["Type"] = "SurfaceVertex";
        map["EditableText"] = QString::number(nVertex);
        map["Object"] = QVariant::fromValue((QObject*)surf);
        item->setData(1, Qt::UserRole, map);

        double vec[3];
        surf->GetNormalAtVertex( nVertex, vec );
        item = new QTreeWidgetItem(this);
        item->setText(1, QString("Normal \t[%1, %2, %3]")
                      .arg(vec[0], 0, 'f', 2)
                      .arg(vec[1], 0, 'f', 2)
                      .arg(vec[2], 0, 'f', 2));

        if ( surf->GetActiveVector() >= 0 )
        {
          surf->GetVectorAtVertex( nVertex, vec );
          item = new QTreeWidgetItem(this);
          item->setText(1, QString("Vector \t[%1, %2, %3]")
                        .arg(vec[0], 0, 'f', 2)
                        .arg(vec[1], 0, 'f', 2)
                        .arg(vec[2], 0, 'f', 2));
        }

        if ( surf->HasCurvature() )
        {
          item = new QTreeWidgetItem(this);
          item->setText(1, QString("Curvature \t%1").arg(surf->GetCurvatureValue(nVertex)));
        }


        int nOverlays = surf->GetNumberOfOverlays();
        for ( int i = 0; i < nOverlays; i++ )
        {
          SurfaceOverlay* overlay = surf->GetOverlay( i );
          item = new QTreeWidgetItem(this);
          item->setText(1, QString("%1 \t%2").arg(overlay->GetName()).arg(overlay->GetDataAtVertex( nVertex )));
        }

        int nAnnotations = surf->GetNumberOfAnnotations();
        for ( int i = 0; i < nAnnotations; i++ )
        {
          SurfaceAnnotation* annot = surf->GetAnnotation( i );
          item = new QTreeWidgetItem(this);
          item->setText(1, QString("%1 \t%2").arg(annot->GetName()).arg(annot->GetAnnotationNameAtVertex( nVertex )));
        }
      }
    }
  }
}