X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FInterface_ManagerContour_NDimensions%2FwxContourMainFrame.cxx;h=30cafdf91220e9193cbf66038d781874208c3a4a;hb=022ea4ddf8cd8a991cc9060f3c13e51af6bc226e;hp=d16860f764259305c585d266e8a129a6612b45d7;hpb=8c1e8d790d969626c886564e539b9ddec9ac2f8a;p=creaContours.git diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx index d16860f..30cafdf 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx +++ b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx @@ -58,6 +58,9 @@ char wxContourMainFrame::COPY = 'C'; _refLineControl = NULL; _refLineModel = NULL; _refLineView = NULL; + _imageReslicer = NULL; + _thresholdTable = NULL; + _thresholdMapper = NULL; _thresholdActor = NULL; _actorPresent = false; @@ -79,6 +82,9 @@ char wxContourMainFrame::COPY = 'C'; _refLineControl = NULL; _refLineModel = NULL; _refLineView = NULL; + _imageReslicer = NULL; + _thresholdTable = NULL; + _thresholdMapper = NULL; _thresholdActor = NULL; _actorPresent = false; @@ -161,8 +167,7 @@ void wxContourMainFrame::setVectImages( std::vector images ){ void wxContourMainFrame :: resetInstance() { - delete instance; - instance = NULL; + instance->Destroy(); } wxContourMainFrame :: ~wxContourMainFrame() @@ -170,6 +175,8 @@ void wxContourMainFrame::setVectImages( std::vector images ){ _pannew->Close(); interfMainPanel::resetInstance(); + delete kernelManager; + instance = NULL; //_pannew->Destroy(); //delete _pannew; @@ -593,7 +600,7 @@ void wxContourMainFrame::changeInstant() kernelManager->setInstant(instantVect); //_modelManager->setInstant( _actualInstant ); - updateActor(); + onThresholdChange(); updateInstantOutlines(); updateInstantImageData(); updateInstantAxes(); @@ -637,83 +644,6 @@ void wxContourMainFrame::updateInstantAxes() { } -void wxContourMainFrame :: updateActor() -{ - if (_actorPresent) - { - int minMax[2]; - _pannew->onThresholdInstantChange(minMax); - - 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; - int minVal = minMax[0]; - int maxVal = minMax[1]; - - 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() ); - printf("EED wxContourMainFrame::updateActor %d \n" , z); - _thresholdActor->SetPosition( 0,0, 900-1 ); - } -} void wxContourMainFrame::onChangeDeep(int val){ _instantPanel->setConceptValue( "Axe Depth", (int)val ); @@ -879,7 +809,8 @@ void wxContourMainFrame::onSave(){ saveFileWithContours( fileNameContourROI ); } } -void wxContourMainFrame::saveFileWithContours( std::string filename ){ +void wxContourMainFrame::saveFileWithContours( std::string filename ) +{ FILE *pFile=fopen(filename.c_str(),"w+"); std::vector< std::string > lstNameThings; @@ -1211,7 +1142,7 @@ const double propagationScaling = atof( crea::wx2std(prop).c_str() ); vtkPolyData* polyDataResult = cntVTK->GetOutput(); - std::cout<<"Points "<GetNumberOfPoints()<GetNumberOfPoints()<Update( ); polyDataResult->UpdateInformation(); @@ -1293,9 +1224,9 @@ myfile.open ("C:/Creatis/example2.txt"); { vecX.push_back( p[0] ); myfile <GetZ(); + double range[2]; + + vtkImageData * img = getImageData(); + img->GetScalarRange(range); + + int minTot = floor (range[0]); + int maxTot = ceil (range[1]); + + double minMax[2]; + _pannew->onThresholdInstantChange(minMax); + int minVal = floor (minMax[0]); + int maxVal = floor (minMax[1]); + if (!_actorPresent) { - int z = _theViewPanel->GetZ(); - - vtkImageData * img = getImageData(); - vtkImageReslice *imageReslice = vtkImageReslice::New(); + if (_imageReslicer==NULL) + { + _imageReslicer = vtkImageReslice::New(); + _imageReslicer->SetInput( img ); + _imageReslicer->SetInformationInput(img); + _imageReslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1); + _imageReslicer->SetOutputDimensionality(2); + _imageReslicer->SetInterpolationModeToLinear(); + } - 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(); + _imageReslicer->SetResliceAxesOrigin(0,0,z); - img = imageReslice->GetOutput(); + img = _imageReslicer->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( ); + if (_thresholdTable==NULL) + { + //Lookup Table + _thresholdTable = vtkLookupTable::New(); + _thresholdTable->SetNumberOfTableValues(maxTot+1); + _thresholdTable->SetTableRange(range); + _thresholdTable->SetAlphaRange(0, 1); + _thresholdTable->SetValueRange(0, 1); + _thresholdTable->SetSaturationRange(0, 0); + _thresholdTable->SetRampToLinear( ); + } //Assign a fake color for the upper image, and set the white as transparent int i; - for(i = min; i <= max; i++) + for(i = minTot; i <= maxTot; i++) { if( i >= minVal && i <= maxVal ) { - lookup->SetTableValue(i, 1.0, 0.0, 0.0, 1); + _thresholdTable->SetTableValue(i, 1.0, 0.0, 0.0, 1); } - else if( i >= min && i < minVal ) + else if( i >= minTot && i < minVal ) { - lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent + _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent } - else if( i > maxVal && i < max ) + else if( i > maxVal && i < maxTot ) { - lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent + _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent } else { - lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent + _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent } } - - lookup->Build( ); - - vtkImageMapToColors *mapperImage = vtkImageMapToColors::New( ); - mapperImage->SetLookupTable( lookup ); - mapperImage->SetInput( img ); - //mapperImage->SetOutputFormatToRGBA( ); + _thresholdTable->Build( ); + + if (_thresholdMapper==NULL) + { + _thresholdMapper = vtkImageMapToColors::New( ); + } + + _thresholdMapper->SetLookupTable( _thresholdTable ); + _thresholdMapper->SetInput( img ); if (_thresholdActor==NULL) { _thresholdActor = vtkImageActor::New( ); _thresholdActor->SetOpacity( 0.6 ); - _thresholdActor->InterpolateOn( ); + _thresholdActor->InterpolateOn( ); + _thresholdActor->SetPosition( 0,0, 900-1 ); } -printf("EED wxContourMainFrame::onThreshold \n"); - _thresholdActor->SetPosition( 0,0, z+1 ); - _thresholdActor->SetInput( mapperImage->GetOutput() ); + + _thresholdActor->SetInput( _thresholdMapper->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) + else { - 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(); + _imageReslicer->SetResliceAxesOrigin(0,0,z); + img = _imageReslicer->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++) + for(i = minTot; i <= maxTot; i++) { if( i >= minVal && i <= maxVal ) { - lookup->SetTableValue(i, 1.0, 0.0, 0.0, 1); + _thresholdTable->SetTableValue(i, 1.0, 0.0, 0.0, 1); } - else if( i >= min && i < minVal ) + else if( i >= minTot && i < minVal ) { - lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent + _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent } - else if( i > maxVal && i < max ) + else if( i > maxVal && i < maxTot ) { - lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent + _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent } else { - lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent + _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent } } - - lookup->Build( ); - vtkImageMapToColors *mapperImage = vtkImageMapToColors::New( ); - mapperImage->SetLookupTable( lookup ); - mapperImage->SetInput( img ); - //mapperImage->SetOutputFormatToRGBA( ); + _thresholdTable->Build( ); + _thresholdMapper->SetLookupTable( _thresholdTable ); + _thresholdMapper->SetInput( img ); + _thresholdActor->SetInput( _thresholdMapper->GetOutput() ); + } + /* + 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(); + */ + _theViewPanel->RefreshInterface(); +} - _thresholdActor->SetInput( mapperImage->GetOutput() ); -printf("EED wxContourMainFrame::onThresholdChange \n"); - _thresholdActor->SetPosition( 0,0, z+1 ); +void wxContourMainFrame::onThresholdChange() +{ + if (_actorPresent) + { + onThreshold(); } - - RefreshInterface(); } void wxContourMainFrame::onThresholdInterpolation(bool interpolate) @@ -1974,7 +1885,7 @@ void wxContourMainFrame::onThresholdInterpolation(bool interpolate) _thresholdActor->InterpolateOff( ); } - RefreshInterface(); + _theViewPanel->RefreshInterface(); } } @@ -1985,7 +1896,7 @@ void wxContourMainFrame::onThresholdChangeOpacity (int opacity) _thresholdActor->SetOpacity(opacity*0.1); } - RefreshInterface(); + _theViewPanel->RefreshInterface(); } void wxContourMainFrame::onThresholdRemove() @@ -1997,7 +1908,7 @@ void wxContourMainFrame::onThresholdRemove() _actorPresent = false; } - RefreshInterface(); + _theViewPanel->RefreshInterface(); } void wxContourMainFrame::showAxis(bool show) @@ -2683,4 +2594,7 @@ void wxContourMainFrame::saveFileWithContoursAutomatique(){ onSave(); } } +void wxContourMainFrame::ShowToolsPanel(bool show){ + _pannew->Show(show); +}