void LayerSurface::SetActiveAnnotation( int n ) { if ( n < (int)m_annotations.size() ) { m_nActiveAnnotation = n; UpdateAnnotation(); emit ActiveAnnotationChanged( n ); emit ActorUpdated(); } }
void DisplayWidget::paintEvent(QPaintEvent *event) { QPainter painter; painter.begin(this); painter.setRenderHint(QPainter::Antialiasing); m_Handler->Paint(&painter, event, m_iElapsed, geometry()); painter.end(); if(m_bShowAnnotation) { UpdateAnnotation(); ShowAnnotation(); } }
void LayerSurface::UpdateOverlay( bool bAskRedraw ) { vtkPolyDataMapper* mapper = vtkPolyDataMapper::SafeDownCast( m_mainActor->GetMapper() ); vtkPolyData* polydata = mapper->GetInput(); vtkPolyData* polydataWireframe = vtkPolyDataMapper::SafeDownCast( m_wireframeActor->GetMapper() )->GetInput(); if ( m_nActiveOverlay >= 0 ) { if ( mapper ) { int nCount = polydata->GetPoints()->GetNumberOfPoints(); vtkSmartPointer<vtkUnsignedCharArray> array = vtkUnsignedCharArray::SafeDownCast( polydata->GetPointData()->GetArray( "Overlay" ) ); if ( array.GetPointer() == NULL ) { array = vtkSmartPointer<vtkUnsignedCharArray>::New(); array->SetNumberOfComponents( 4 ); array->SetNumberOfTuples( nCount ); array->SetName( "Overlay" ); polydata->GetPointData()->AddArray( array ); polydataWireframe->GetPointData()->AddArray( array ); } unsigned char* data = new unsigned char[ nCount*4 ]; GetProperty()->GetCurvatureLUT()->MapScalarsThroughTable( polydata->GetPointData()->GetScalars("Curvature"), data, VTK_RGBA ); GetActiveOverlay()->MapOverlay( data ); MapLabels( data, nCount ); for ( int i = 0; i < nCount; i++ ) { array->SetTupleValue( i, data + i*4 ); } delete[] data; polydata->GetPointData()->SetActiveScalars( "Overlay" ); if ( GetProperty()->GetMeshColorMap() == LayerPropertySurface::MC_Surface ) { polydataWireframe->GetPointData()->SetActiveScalars( "Overlay" ); } } } else if ( m_nActiveAnnotation >= 0 ) { UpdateAnnotation( false ); } else { if ( m_labels.size() == 0 || m_nActiveLabel < 0) // no labels { polydata->GetPointData()->SetActiveScalars( "Curvature" ); if ( GetProperty()->GetMeshColorMap() == LayerPropertySurface::MC_Surface ) { polydataWireframe->GetPointData()->SetActiveScalars( "Curvature" ); } } else { if ( mapper ) { int nCount = polydata->GetPoints()->GetNumberOfPoints(); vtkSmartPointer<vtkUnsignedCharArray> array = vtkUnsignedCharArray::SafeDownCast( polydata->GetPointData()->GetArray( "Overlay" ) ); if ( array.GetPointer() == NULL ) { array = vtkSmartPointer<vtkUnsignedCharArray>::New(); array->SetNumberOfComponents( 4 ); array->SetNumberOfTuples( nCount ); array->SetName( "Overlay" ); polydata->GetPointData()->AddArray( array ); polydataWireframe->GetPointData()->AddArray( array ); } unsigned char* data = new unsigned char[ nCount*4 ]; GetProperty()->GetCurvatureLUT()->MapScalarsThroughTable( polydata->GetPointData()->GetScalars("Curvature"), data, VTK_RGBA ); MapLabels( data, nCount ); for ( int i = 0; i < nCount; i++ ) { array->SetTupleValue( i, data + i*4 ); } delete[] data; polydata->GetPointData()->SetActiveScalars( "Overlay" ); if ( GetProperty()->GetMeshColorMap() == LayerPropertySurface::MC_Surface ) { polydataWireframe->GetPointData()->SetActiveScalars( "Overlay" ); } } } } if ( bAskRedraw ) { emit ActorUpdated(); } }