-void wxContourMainFrame::onThreshold(int minVal, int maxVal)
-{
- if (!_actorPresent)
- {
- int z = _theViewPanel->GetZ();
-
- vtkImageData * img = getImageData();
- vtkImageReslice *imageReslice = vtkImageReslice::New();
-
- imageReslice->SetInput( img );
- imageReslice->SetInformationInput(img);
- imageReslice->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
- imageReslice->SetResliceAxesOrigin(0,0,z);
- imageReslice->SetOutputDimensionality(2);
- imageReslice->SetInterpolationModeToLinear();
-
- img = imageReslice->GetOutput();
- img->Update();
- img->UpdateInformation();
-
- wxVtkBaseView * baseView = _theViewPanel->getWxVtkBaseView();
-
- double range[2];
- img->GetScalarRange(range);
-
- int min = floor (range[0]);
- int max = ceil (range[1]);
-
- //Lookup Table
- vtkLookupTable *lookup = vtkLookupTable::New();
- lookup->SetNumberOfTableValues(max+1);
- lookup->SetTableRange(range);
- lookup->SetAlphaRange(0, 1);
- lookup->SetValueRange(0, 1);
- lookup->SetSaturationRange(0, 0);
- lookup->SetRampToLinear( );
-
- //Assign a fake color for the upper image, and set the white as transparent
- int i;
- for(i = min; i <= max; i++)
- {
- if( i >= minVal && i <= maxVal )
- {
- lookup->SetTableValue(i, 1.0, 0.0, 0.0, 1);
- }
- else if( i >= min && i < minVal )
- {
- lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
- }
- else if( i > maxVal && i < max )
- {
- lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
- }
- else
- {
- lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
- }
- }
-
- lookup->Build( );
-
- vtkImageMapToColors *mapperImage = vtkImageMapToColors::New( );
- mapperImage->SetLookupTable( lookup );
- mapperImage->SetInput( img );
- //mapperImage->SetOutputFormatToRGBA( );
-
- if (_thresholdActor==NULL)
- {
- _thresholdActor = vtkImageActor::New( );
- _thresholdActor->SetInput( mapperImage->GetOutput() );
- _thresholdActor->SetOpacity( 0.6 );
- _thresholdActor->SetPosition( 0,0, z+1 );
- _thresholdActor->InterpolateOn( );
- }
- else
- {
- _thresholdActor->SetInput( mapperImage->GetOutput() );
- }
-
- baseView->GetRenderer()->AddActor( _thresholdActor );
- _actorPresent = true;
- }
-
- RefreshInterface();
-/*
- vtkImageViewer2* viewer = vtkImageViewer2::New();
- viewer->SetInput( upperImageActor->GetInput() );
- viewer->SetColorLevel((range[1]-range[0])/2);
- viewer->SetColorWindow(range[1]);
- viewer->GetRenderer()->AddActor( upperImageActor );
- viewer->Render();
-*/
-
-}
-
-void wxContourMainFrame::onThresholdChange(int minVal, int maxVal)
-{
- if (_actorPresent)
- {
- int z = _theViewPanel->GetZ();
-
- vtkImageData * img = getImageData();
- vtkImageReslice *imageReslice = vtkImageReslice::New();
-
- imageReslice->SetInput( img );
- imageReslice->SetInformationInput(img);
- imageReslice->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
- imageReslice->SetResliceAxesOrigin(0,0,z);
- imageReslice->SetOutputDimensionality(2);
- imageReslice->SetInterpolationModeToLinear();
-
- img = imageReslice->GetOutput();
- img->Update();
- img->UpdateInformation();
-
-//EED?? wxVtkBaseView * baseView = _theViewPanel->getWxVtkBaseView();
-
- double range[2];
- img->GetScalarRange(range);
-
- int min = floor (range[0]);
- int max = ceil (range[1]);
-
- //Lookup Table
- vtkLookupTable *lookup = vtkLookupTable::New();
- lookup->SetNumberOfTableValues(max+1);
- lookup->SetTableRange(range);
- lookup->SetAlphaRange(0, 1);
- lookup->SetValueRange(0, 1);
- lookup->SetSaturationRange(0, 0);
- lookup->SetRampToLinear( );
-
- //Assign a fake color for the upper image, and set the white as transparent
- int i;
- for(i = min; i <= max; i++)
- {
- if( i >= minVal && i <= maxVal )
- {
- lookup->SetTableValue(i, 1.0, 0.0, 0.0, 1);
- }
- else if( i >= min && i < minVal )
- {
- lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
- }
- else if( i > maxVal && i < max )
- {
- lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
- }
- else
- {
- lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
- }
- }
-
- lookup->Build( );
-
- vtkImageMapToColors *mapperImage = vtkImageMapToColors::New( );
- mapperImage->SetLookupTable( lookup );
- mapperImage->SetInput( img );
- //mapperImage->SetOutputFormatToRGBA( );
-
- _thresholdActor->SetInput( mapperImage->GetOutput() );
- }
-
- RefreshInterface();
-}
-
-void wxContourMainFrame::onThresholdInterpolation(bool interpolate)
-{
- if (_thresholdActor!=NULL)
- {
- if (interpolate)
- {
- _thresholdActor->InterpolateOn( );
- }
-
- else
- {
- _thresholdActor->InterpolateOff( );
- }
-
- RefreshInterface();
- }
-}
-
-void wxContourMainFrame::onThresholdChangeOpacity (int opacity)
-{
- if (_actorPresent)
- {
- _thresholdActor->SetOpacity(opacity*0.1);
- }
-
- RefreshInterface();
-}
-
-void wxContourMainFrame::onThresholdRemove()
-{
- if (_actorPresent)
- {
- wxVtkBaseView * baseView = _theViewPanel->getWxVtkBaseView();
- baseView->GetRenderer()->RemoveActor( _thresholdActor );
- _actorPresent = false;
- }
-
- RefreshInterface();
-}