Esempio n. 1
0
void LayerSurface::SetActiveLabelColor(const QColor &c)
{
  if ( m_nActiveLabel >= 0)
  {
    m_labels[m_nActiveLabel]->SetColor(c.redF(), c.greenF(), c.blueF());
    UpdateColorMap();
    emit ActorUpdated();
  }
}
Esempio n. 2
0
void LayerSurface::SetActiveLabel( int n )
{
  if ( n < (int)m_labels.size() && n != m_nActiveLabel )
  {
    m_nActiveLabel = n;
    UpdateColorMap();
    emit ActiveLabelChanged( n );
    emit ActorUpdated();
  }
}
Esempio n. 3
0
void LayerSurface::UpdateAnnotation( bool bAskRedraw )
{
  vtkPolyDataMapper* mapper = vtkPolyDataMapper::SafeDownCast( m_mainActor->GetMapper() );
  vtkPolyData* polydata = mapper->GetInput();
  vtkPolyDataMapper* mapperWireframe = vtkPolyDataMapper::SafeDownCast( m_wireframeActor->GetMapper() );
  vtkPolyData* polydataWireframe = mapperWireframe->GetInput();
  if ( m_nActiveAnnotation >= 0 )
  {
    if ( mapper )
    {
      int nCount = polydata->GetPoints()->GetNumberOfPoints();
      vtkSmartPointer<vtkIntArray> array = vtkIntArray::SafeDownCast( polydata->GetPointData()->GetArray( "Annotation" ) );
      if ( array.GetPointer() == NULL )
      {
        array = vtkSmartPointer<vtkIntArray>::New();
        //   array->SetNumberOfTuples( nCount );
        array->SetName( "Annotation" );
        polydata->GetPointData()->AddArray( array );
        polydataWireframe->GetPointData()->AddArray( array );
      }

      array->SetArray( GetActiveAnnotation()->GetIndices(), nCount, 1 );
      polydata->GetPointData()->SetActiveScalars( "Annotation" );

      vtkSmartPointer<vtkFreesurferLookupTable> lut = vtkSmartPointer<vtkFreesurferLookupTable>::New();
      lut->BuildFromCTAB( GetActiveAnnotation()->GetColorTable(), false );  // do not clear zero
      mapper->SetLookupTable( lut );
      mapper->UseLookupTableScalarRangeOn();
      if ( GetProperty()->GetMeshColorMap() == LayerPropertySurface::MC_Surface )
      {
        polydataWireframe->GetPointData()->SetActiveScalars( "Annotation" );
        mapperWireframe->SetLookupTable( lut );
        mapperWireframe->UseLookupTableScalarRangeOn();
      }
    }
  }
  else
  {
    UpdateColorMap();
  }
  if ( bAskRedraw )
  {
    emit ActorUpdated();
  }
}
Esempio n. 4
0
LayerFCD::LayerFCD(LayerMRI* layerMRI, 
                   QObject *parent) : LayerVolumeBase(parent),
  m_fcd(NULL),
  m_mri_difference(NULL)
{
  m_strTypeNames.push_back( "FCD" );
  m_sPrimaryType = "FCD";
  mProperty = new LayerPropertyFCD(this);
  for ( int i = 0; i < 3; i++ )
  {
    m_dSlicePosition[i] = 0;
    m_sliceActor2D[i] = vtkSmartPointer<vtkImageActor>::New();
    m_sliceActor3D[i] = vtkSmartPointer<vtkImageActor>::New();
    m_sliceActor2D[i]->InterpolateOff();
    m_sliceActor3D[i]->InterpolateOff();
  }

  mProperty = new LayerPropertyFCD( this );

  m_layerSource = layerMRI;
  if (m_layerSource)
  {
    InitializeData();
  }

  LayerPropertyFCD* p = GetProperty();
  connect( p, SIGNAL(ColorMapChanged()), this, SLOT(UpdateColorMap()) );
  connect( p, SIGNAL(OpacityChanged(double)), this, SLOT(UpdateOpacity()) );
  connect( p, SIGNAL(ThicknessThresholdChanged(double)), 
           this, SLOT(Recompute()));
  connect( p, SIGNAL(SigmaChanged(double)), this, SLOT(Recompute()));
  connect( p, SIGNAL(MinAreaChanged(int)), this, SLOT(Recompute()));

  // pre allocate MRIs & surfaces
  m_mri_norm = new LayerMRI(NULL);
  m_mri_flair = new LayerMRI(NULL);
  m_mri_t2 = new LayerMRI(NULL);
  m_mri_aseg = new LayerMRI(NULL);
  m_mri_difference = new LayerMRI(NULL);
  connect(m_mri_norm, SIGNAL(destroyed()), 
          this, SLOT(OnLayerDestroyed()), Qt::UniqueConnection);
  connect(m_mri_flair, SIGNAL(destroyed()), 
          this, SLOT(OnLayerDestroyed()), Qt::UniqueConnection);
  connect(m_mri_t2, SIGNAL(destroyed()), 
          this, SLOT(OnLayerDestroyed()), Qt::UniqueConnection);
  connect(m_mri_aseg, SIGNAL(destroyed()), 
          this, SLOT(OnLayerDestroyed()), Qt::UniqueConnection);
  connect(m_mri_difference, SIGNAL(destroyed()),
          this, SLOT(OnLayerDestroyed()), Qt::UniqueConnection);

  m_surf_lh = new LayerSurface(NULL);
  m_surf_rh = new LayerSurface(NULL);
  connect(m_surf_lh, SIGNAL(destroyed()),
          this, SLOT(OnLayerDestroyed()), Qt::UniqueConnection);
  connect(m_surf_rh, SIGNAL(destroyed()),
          this, SLOT(OnLayerDestroyed()), Qt::UniqueConnection);
  m_surf_lh_pial = new LayerSurface(NULL);
  m_surf_rh_pial = new LayerSurface(NULL);
  connect(m_surf_lh_pial, SIGNAL(destroyed()),
          this, SLOT(OnLayerDestroyed()), Qt::UniqueConnection);
  connect(m_surf_rh_pial, SIGNAL(destroyed()),
          this, SLOT(OnLayerDestroyed()), Qt::UniqueConnection);

  m_surf_lh_sphere_d1 = new LayerSurface(NULL);
  m_surf_rh_sphere_d1 = new LayerSurface(NULL);
  connect(m_surf_lh_sphere_d1, SIGNAL(destroyed()),
          this, SLOT(OnLayerDestroyed()), Qt::UniqueConnection);
  connect(m_surf_rh_sphere_d1, SIGNAL(destroyed()),
          this, SLOT(OnLayerDestroyed()), Qt::UniqueConnection);

  m_worker = new LayerFCDWorkerThread(this);
  connect(m_worker, SIGNAL(started()), this, SIGNAL(StatusChanged()));
  connect(m_worker, SIGNAL(finished()), this, SIGNAL(StatusChanged()));
  connect(m_worker, SIGNAL(terminated()), this, SIGNAL(StatusChanged()));
}
Esempio n. 5
0
LayerSurface::LayerSurface( LayerMRI* ref, QObject* parent ) : LayerEditable( parent ),
  m_surfaceSource( NULL ),
  m_bResampleToRAS( true ),
  m_volumeRef( ref ),
  m_nActiveOverlay( -1 ),
  m_nActiveAnnotation( -1 ),
  m_nActiveLabel( -1 ),
  m_bUndoable( false ),
  m_bVector2DPendingUpdate( true ),
  m_bLoadAll(false)
{
  m_strTypeNames.push_back( "Surface" );

  // create property before actors!
  mProperty = new LayerPropertySurface( this );

  for ( int i = 0; i < 3; i++ )
  {
    // m_nSliceNumber[i] = 0;
    m_sliceActor2D[i] = vtkActor::New();
    m_sliceActor3D[i] = vtkActor::New();
    m_vectorActor2D[i] = vtkActor::New();
  }

// m_mainActor = vtkLODActor::New();
  m_mainActor = vtkSmartPointer<vtkActor>::New();
  m_mainActor->GetProperty()->SetEdgeColor( 0.75, 0.75, 0.75 );
  mLowResFilter = vtkSmartPointer<vtkDecimatePro>::New();
  mLowResFilter->SetTargetReduction( 0.9 );
// mMediumResFilter = vtkSmartPointer<vtkDecimatePro>::New();
// mMediumResFilter->SetTargetReduction( 0.9 );

  m_vectorActor = vtkSmartPointer<vtkActor>::New();
  m_vectorActor->GetProperty()->SetColor( GetProperty()->GetVectorColor() );
  m_vectorActor->GetProperty()->SetPointSize( GetProperty()->GetVectorPointSize() );
  m_vectorActor->PickableOff();

  for ( int i = 0; i < 3; i++ )
  {
    m_vectorActor2D[i]->GetProperty()->SetColor( GetProperty()->GetVectorColor() );
    m_vectorActor2D[i]->GetProperty()->SetPointSize( GetProperty()->GetVectorPointSize() );
    m_vectorActor2D[i]->PickableOff();
  }

  m_vertexActor = vtkSmartPointer<vtkActor>::New();
  m_vertexActor->GetProperty()->SetRepresentationToPoints();
  m_vertexActor->VisibilityOff();

  m_wireframeActor = vtkSmartPointer<vtkActor>::New();
  m_wireframeActor->VisibilityOff();

  LayerPropertySurface* p = GetProperty();
  connect( p, SIGNAL(ColorMapChanged()), this, SLOT(UpdateColorMap()) ),
           connect( p, SIGNAL(OpacityChanged(double)), this, SLOT(UpdateOpacity()) );
  connect( p, SIGNAL(EdgeThicknessChanged(int)), this, SLOT(UpdateEdgeThickness()) );
  connect( p, SIGNAL(VectorPointSizeChanged(int)), this, SLOT(UpdateVectorPointSize()) );
  connect( p, SIGNAL(RenderModeChanged(int)), this, SLOT(UpdateRenderMode()) );
  connect( p, SIGNAL(VertexRenderChanged()), this, SLOT(UpdateVertexRender()) );
  connect( p, SIGNAL(MeshRenderChanged()), this, SLOT(UpdateMeshRender()) );
  connect( p, SIGNAL(PositionChanged()), this, SLOT(UpdateActorPositions()) );
}