void LayerSurface::Undo() { m_surfaceSource->UndoReposition(); SetModified(); m_bUndoable = false; emit ActorUpdated(); }
void LayerSurface::UpdateVertexRender() { m_vertexActor->SetVisibility( GetProperty()->GetShowVertices()? 1: 0 ); m_vertexActor->GetProperty()->SetPointSize( GetProperty()->GetVertexPointSize() ); m_vertexActor->GetProperty()->SetColor( GetProperty()->GetVertexColor() ); emit ActorUpdated(); }
void LayerSurface::RepositionSurface( LayerMRI* mri, int nVertex, double* pos, int size, double sigma ) { m_surfaceSource->Reposition( mri->GetSourceVolume(), nVertex, pos, size, sigma ); SetModified(); m_bUndoable = true; emit ActorUpdated(); }
void LayerSurface::UpdateMeshRender() { vtkPolyDataMapper* mapper = vtkPolyDataMapper::SafeDownCast( m_mainActor->GetMapper() ); vtkPolyData* polydata = mapper->GetInput(); vtkPolyDataMapper* mapperWireframe = vtkPolyDataMapper::SafeDownCast( m_wireframeActor->GetMapper() ); vtkPolyData* polydataWireframe = mapperWireframe->GetInput(); mapperWireframe->SetScalarVisibility( GetProperty()->GetMeshColorMap() != LayerPropertySurface::MC_Solid ? 1:0 ); switch ( GetProperty()->GetMeshColorMap() ) { case LayerPropertySurface::MC_Surface: polydataWireframe->GetPointData()->SetActiveScalars( polydata->GetPointData()->GetScalars()->GetName() ); mapperWireframe->SetLookupTable( mapper->GetLookupTable() ); break; case LayerPropertySurface::MC_Curvature: { // always display as threshold for curvature vtkSmartPointer<vtkRGBAColorTransferFunction> lut = vtkSmartPointer<vtkRGBAColorTransferFunction>::New(); GetProperty()->BuildCurvatureLUT( lut, LayerPropertySurface::CM_Threshold ); m_wireframeActor->GetMapper()->SetLookupTable( lut ); polydataWireframe->GetPointData()->SetActiveScalars( "Curvature" ); } break; case LayerPropertySurface::MC_Overlay: polydataWireframe->GetPointData()->SetActiveScalars( "Overlay" ); break; case LayerPropertySurface::MC_Solid: m_wireframeActor->GetProperty()->SetColor( GetProperty()->GetMeshColor() ); break; default: break; } emit ActorUpdated(); }
void LayerSurface::UpdateEdgeThickness() { for ( int i = 0; i < 3; i++ ) { m_sliceActor2D[i]->GetProperty()->SetLineWidth( GetProperty()->GetEdgeThickness() ); m_sliceActor3D[i]->GetProperty()->SetLineWidth( GetProperty()->GetEdgeThickness() ); } if ( GetProperty()->GetEdgeThickness() == 0 ) { if ( IsVisible() ) { for ( int i = 0; i < 3; i++ ) { m_sliceActor2D[i]->SetVisibility( 0 ); m_sliceActor3D[i]->SetVisibility( 0 ); } } } else if ( IsVisible() && !m_sliceActor2D[0]->GetVisibility() ) { for ( int i = 0; i < 3; i++ ) { m_sliceActor2D[i]->SetVisibility( 1 ); m_sliceActor3D[i]->SetVisibility( 1 ); } } emit ActorUpdated(); }
bool LayerVolumeBase::FloodFillByRAS( double* ras, int nPlane, bool bAdd, bool b3D, char* mask_out ) { int n[3]; double* origin = m_imageData->GetOrigin(); double* voxel_size = m_imageData->GetSpacing(); int* dim = m_imageData->GetDimensions(); for ( int i = 0; i < 3; i++ ) { n[i] = ( int )( ( ras[i] - origin[i] ) / voxel_size[i] + 0.5 ); } if (!b3D) { if ( FloodFillByIndex( n, nPlane, bAdd, true, mask_out ) ) { if ( !mask_out ) { SetModified(); } emit ActorUpdated(); return true; } else { return false; } } else { int n0[3] = { n[0], n[1], n[2]}; for (int i = n0[nPlane]; i < dim[nPlane]; i++) { n[nPlane] = i; if (!FloodFillByIndex( n, nPlane, bAdd, false)) break; } for (int i = n0[nPlane]-1; i >= 0; i--) { n[nPlane] = i; if (!FloodFillByIndex( n, nPlane, bAdd, false)) break; } SetModified(); emit ActorUpdated(); return true; } }
void LayerSurface::SetActiveLabelColor(const QColor &c) { if ( m_nActiveLabel >= 0) { m_labels[m_nActiveLabel]->SetColor(c.redF(), c.greenF(), c.blueF()); UpdateColorMap(); emit ActorUpdated(); } }
void LayerSurface::UpdateVectorPointSize() { for ( int i = 0; i < 3; i++ ) { m_vectorActor2D[i]->GetProperty()->SetPointSize( GetProperty()->GetVectorPointSize() ); } m_vectorActor->GetProperty()->SetPointSize( GetProperty()->GetVectorPointSize() ); emit ActorUpdated(); }
void LayerSurface::UpdateOpacity() { for ( int i = 0; i < 3; i++ ) { // m_sliceActor2D[i]->GetProperty()->SetOpacity( mProperty->GetOpacity() ); // m_sliceActor3D[i]->SetOpacity( mProperty->GetOpacity() ); } m_mainActor->GetProperty()->SetOpacity( GetProperty()->GetOpacity() ); emit ActorUpdated(); }
void LayerSurface::SetActiveLabel( int n ) { if ( n < (int)m_labels.size() && n != m_nActiveLabel ) { m_nActiveLabel = n; UpdateColorMap(); emit ActiveLabelChanged( n ); emit ActorUpdated(); } }
void LayerFCD::UpdateOpacity() { for ( int i = 0; i < 3; i++ ) { m_sliceActor2D[i]->SetOpacity( GetProperty()->GetOpacity() ); m_sliceActor3D[i]->SetOpacity( GetProperty()->GetOpacity() ); } emit ActorUpdated(); }
void LayerFCD::UpdateColorMap () { for ( int i = 0; i < 3; i++ ) { mColorMap[i]->SetLookupTable( GetProperty()->GetLookupTable() ); } // m_sliceActor2D[i]->GetProperty()->SetColor(1, 0, 0); emit ActorUpdated(); }
void LayerSurface::SetActiveAnnotation( int n ) { if ( n < (int)m_annotations.size() ) { m_nActiveAnnotation = n; UpdateAnnotation(); emit ActiveAnnotationChanged( n ); emit ActorUpdated(); } }
void LayerSurface::SetActiveSurface( int nSurface ) { if ( m_surfaceSource && m_surfaceSource->SetActiveSurface( nSurface ) ) { if ( GetActiveVector() >= 0 ) { UpdateVectorActor2D(); } emit ActorUpdated(); } }
void LayerFCD::DoCompute(bool resetProgress) { if (m_fcd) { if (resetProgress) { ::SetProgressCallback(ProgressCallback, 0, 50); } try { ::FCDcomputeThicknessLabels(m_fcd, GetProperty()->GetThicknessThreshold(), GetProperty()->GetSigma(), GetProperty()->GetMinArea()); } catch (int ret) { return; } m_labelVisibility.clear(); for (int i = 0; i < m_fcd->nlabels; i++) { m_labelVisibility << true; } UpdateRASImage(m_imageData); for (int i = 0; i < 3; i++) { mReslice[i]->Modified(); } if (resetProgress) { ::SetProgressCallback(ProgressCallback, 50, 60); } if (m_mri_difference) { m_mri_difference->UpdateMRIToImage(); } if (resetProgress) { ::SetProgressCallback(ProgressCallback, 60, 100); } // if (m_mri_decrease) // { // m_mri_decrease->UpdateMRIToImage(); // } emit LabelsChanged(); emit ActorUpdated(); } }
void LayerVolumeBase::Paste( int nPlane ) { SaveForUndo( nPlane ); double* origin = m_imageData->GetOrigin(); double* voxel_size = m_imageData->GetSpacing(); int nSlice = ( int )( ( m_dSlicePosition[nPlane] - origin[nPlane] ) / voxel_size[nPlane] + 0.5 ); m_bufferClipboard.slice = nSlice; LoadBufferItem( m_bufferClipboard, true ); // ignore zeros SetModified(); emit ActorUpdated(); }
void LayerVolumeTrack::RestoreColors() { MRI* mri = m_volumeSource->GetMRI(); COLOR_TABLE* ct = m_ctabStripped; if (!ct) return; for (int i = 0; i < mri->nframes; i++) { int nr, ng, nb; CTABrgbAtIndexi( ct, mri->frames[i].label, &nr, &ng, &nb ); m_actors[i]->GetProperty()->SetColor(nr/255.0, ng/255.0, nb/255.0); } emit ActorUpdated(); }
bool LayerSurface::LoadVectorFromFile( ) { if ( m_sVectorFilename.size() == 0 || !m_surfaceSource->MRISReadVectors( m_sVectorFilename ) ) { return false; } UpdateVectorActor2D(); emit Modified(); emit SurfaceVectorLoaded(); emit ActorUpdated(); return true; }
void LayerVolumeTrack::Highlight(int nLabel) { MRI* mri = m_volumeSource->GetMRI(); for (int i = 0; i < mri->nframes; i++) { if (nLabel == mri->frames[i].label) { this->SetActiveFrame(i); m_actors[i]->GetProperty()->SetColor(1.5, 1.5, 1.5); // let it over-flow emit ActorUpdated(); QTimer::singleShot(300, this, SLOT(RestoreColors())); } } }
void LayerSurface::SetActiveOverlay( int nOverlay ) { if ( nOverlay < (int)m_overlays.size() ) { if ( m_nActiveOverlay < 0 && nOverlay >= 0 ) { this->GetProperty()->SetCurvatureMap( LayerPropertySurface::CM_Binary ); } m_nActiveOverlay = nOverlay; UpdateOverlay(false); emit ActiveOverlayChanged( nOverlay ); emit ActorUpdated(); } }
void LayerVolumeTrack::SetThreshold(int nLabel, double th) { MRI* mri = m_volumeSource->GetMRI(); for (int i = 0; i < mri->nframes; i++) { if (nLabel == mri->frames[i].label) { mri->frames[i].thresh = th; UpdateFrameActor(i); GetProperty()->SetHeatScaleMinThreshold(th); emit ActorUpdated(); return; } } }
void LayerSurface::UpdateColorMap() { if ( m_surfaceSource == NULL ) { return; } for ( int i = 0; i < 3; i++ ) { m_sliceActor2D[i]->GetProperty()->SetColor( GetProperty()->GetEdgeColor() ); m_sliceActor3D[i]->GetProperty()->SetColor( GetProperty()->GetEdgeColor() ); m_sliceActor2D[i]->GetMapper()->ScalarVisibilityOff(); m_sliceActor3D[i]->GetMapper()->ScalarVisibilityOff(); m_vectorActor2D[i]->GetProperty()->SetColor( GetProperty()->GetVectorColor() ); } m_mainActor->GetProperty()->SetColor( GetProperty()->GetBinaryColor() ); m_wireframeActor->GetProperty()->SetColor( GetProperty()->GetBinaryColor() ); m_vectorActor->GetProperty()->SetColor( GetProperty()->GetVectorColor() ); if ( m_surfaceSource->IsCurvatureLoaded() ) { if ( GetProperty()->GetCurvatureLUT() != m_mainActor->GetMapper()->GetLookupTable() ) { m_mainActor->GetMapper()->SetLookupTable( GetProperty()->GetCurvatureLUT() ); } if ( GetProperty()->GetMeshColorMap() == LayerPropertySurface::MC_Surface ) { m_wireframeActor->GetMapper()->SetLookupTable( GetProperty()->GetCurvatureLUT() ); } else if ( GetProperty()->GetMeshColorMap() == LayerPropertySurface::MC_Curvature ) { UpdateMeshRender(); } /* vtkSmartPointer<vtkMapperCollection> mc = m_mainActor->GetLODMappers(); mc->InitTraversal(); vtkMapper* mapper = NULL; while ( ( mapper = mc->GetNextItem() ) != NULL ) { mapper->SetLookupTable( GetProperty()->GetCurvatureLUT() ); } */ } UpdateOverlay(false); emit ActorUpdated(); }
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(); } }
void LayerVolumeBase::Redo() { if ( m_bufferRedo.size() > 0 ) { UndoRedoBufferItem item = m_bufferRedo[m_bufferRedo.size()-1]; m_bufferRedo.pop_back(); UndoRedoBufferItem item2; SaveBufferItem( item2, item.plane, item.slice ); m_bufferUndo.push_back( item2 ); LoadBufferItem( item ); item.Clear(); SetModified(); emit ActorUpdated(); emit Modified(); } }
bool LayerCollection::AddLayer( Layer* layer, bool initializeCoordinate ) { if ( !layer->IsTypeOf( m_strType ) ) { std::cerr << "Can not add layer type of " << qPrintable(layer->GetEndType()) << " to layer collection type of " << qPrintable(m_strType) << "\n"; return false; } Layer* old_top = (m_layers.isEmpty() ? NULL : m_layers[0]); for ( int i = 0; i < m_layers.size(); i++ ) { if ( m_layers[i] == layer ) { return false; } } if ( initializeCoordinate) { layer->GetSlicePosition( m_dSlicePosition ); layer->GetWorldOrigin( m_dWorldOrigin ); layer->GetWorldSize( m_dWorldSize ); layer->GetWorldVoxelSize( m_dWorldVoxelSize ); } else { layer->SetSlicePosition( m_dSlicePosition ); } m_layers.insert( m_layers.begin(), layer ); connect( layer, SIGNAL(ActorUpdated()), this, SIGNAL(LayerActorUpdated()) ); connect( layer, SIGNAL(Transformed()), this, SIGNAL(LayerActorUpdated()) ); connect( layer, SIGNAL(ActorChanged()), this, SIGNAL(LayerActorChanged()) ); connect( layer, SIGNAL(NameChanged(QString)), this, SIGNAL(LayerNameChanged())); connect(layer, SIGNAL(Transformed()), this, SIGNAL(LayerTransformed())); if (layer->IsTypeOf("Editable")) connect( layer, SIGNAL(Modified()), this, SIGNAL(LayerModified())); if (layer->GetProperty()) { connect( layer->GetProperty(), SIGNAL(PropertyChanged()), this, SIGNAL(LayerPropertyChanged())); connect( layer->GetProperty(), SIGNAL(ShowInfoChanged(bool)), this, SIGNAL(LayerShowInfoChanged())); }
bool LayerSurface::LoadCurvatureFromFile( const QString& filename ) { QString fn = filename; if (!QFile::exists(fn)) { fn = QFileInfo(QFileInfo(m_sFilename).dir(), filename).absoluteFilePath(); } if ( !m_surfaceSource->LoadCurvature( fn ) ) { return false; } emit Modified(); emit SurfaceCurvatureLoaded(); emit ActorUpdated(); return true; }
void LayerVolumeBase::SetVoxelByRAS( double* ras, int nPlane, bool bAdd ) { int n[3]; double* origin = m_imageData->GetOrigin(); double* voxel_size = m_imageData->GetSpacing(); for ( int i = 0; i < 3; i++ ) { n[i] = ( int )( ( ras[i] - origin[i] ) / voxel_size[i] + 0.5 ); } if ( SetVoxelByIndex( n, nPlane, bAdd ) ) { SetModified(); emit ActorUpdated(); } else { // PopUndo(); // pop the previously saved undo step } }
void LayerVolumeBase::SetVoxelByRAS( double* ras1, double* ras2, int nPlane, bool bAdd ) { int n1[3], n2[3]; double* origin = m_imageData->GetOrigin(); double* voxel_size = m_imageData->GetSpacing(); for ( int i = 0; i < 3; i++ ) { n1[i] = ( int )( ( ras1[i] - origin[i] ) / voxel_size[i] + 0.5 ); n2[i] = ( int )( ( ras2[i] - origin[i] ) / voxel_size[i] + 0.5 ); } if ( SetVoxelByIndex( n1, n2, nPlane, bAdd ) ) { SetModified(); emit ActorUpdated(); } else { // PopUndo(); } }
void LayerSurface::UpdateActorPositions() { double* pos = GetProperty()->GetPosition(); for ( int i = 0; i < 3; i++ ) { m_sliceActor3D[i]->SetPosition( pos ); } m_sliceActor2D[0]->SetPosition( 0.1, pos[1], pos[2] ); m_sliceActor2D[1]->SetPosition( pos[0], 0.1, pos[2] ); m_sliceActor2D[2]->SetPosition( pos[0], pos[1], -0.1 ); m_vectorActor2D[0]->SetPosition( 1.0, pos[1], pos[2] ); m_vectorActor2D[1]->SetPosition( pos[0], 1.0, pos[2] ); m_vectorActor2D[2]->SetPosition( pos[0], pos[1], -1.0 ); m_mainActor->SetPosition( pos ); m_vectorActor->SetPosition( pos ); m_vertexActor->SetPosition( pos ); m_wireframeActor->SetPosition( pos ); emit ActorUpdated(); }
void LayerVolumeBase::SetLiveWireByRAS( double* pt1, double* pt2, int nPlane ) { int n1[3], n2[3]; double* orig = m_imageData->GetOrigin(); double* vxlsize = m_imageData->GetSpacing(); for ( int i = 0; i < 3; i++ ) { n1[i] = ( int )( ( pt1[i] - orig[i] ) / vxlsize[i] ); n2[i] = ( int )( ( pt2[i] - orig[i] ) / vxlsize[i] ); } vtkSmartPointer<vtkPoints> pts = vtkSmartPointer<vtkPoints>::New(); vtkImageData* image = m_imageData; LayerVolumeBase* ref_layer = m_propertyBrush->GetReferenceLayer(); if ( ref_layer != NULL ) { image = ref_layer->GetImageData(); } // else if ( m_imageDataRef.GetPointer() != NULL ) else if ( m_imageDataRef != NULL ) { image = m_imageDataRef; } m_livewire->GetLivewirePoints( image, nPlane, n1[nPlane], pt1, pt2, pts ); int n[3]; for ( int i = 0; i < pts->GetNumberOfPoints(); i++ ) { double* p = pts->GetPoint( i ); n[0] = (int)( ( p[0] - orig[0] ) / vxlsize[0] + 0.5 ); n[1] = (int)( ( p[1] - orig[1] ) / vxlsize[1] + 0.5); n[2] = (int)( ( p[2] - orig[2] ) / vxlsize[2] + 0.5 ); SetVoxelByIndex( n, nPlane, true ); } SetModified(); emit ActorUpdated(); }