From: donadio Date: Wed, 29 Apr 2009 09:23:03 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: EED.02Oct2009~32 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=022ea4ddf8cd8a991cc9060f3c13e51af6bc226e;p=creaContours.git *** empty log message *** --- diff --git a/lib/Interface_Icons_NDimensions/interfMainPanel.cxx b/lib/Interface_Icons_NDimensions/interfMainPanel.cxx index 14f0f5a..4f75c89 100644 --- a/lib/Interface_Icons_NDimensions/interfMainPanel.cxx +++ b/lib/Interface_Icons_NDimensions/interfMainPanel.cxx @@ -705,17 +705,17 @@ void interfMainPanel::onMirrorChangeWidth(int width) } -void interfMainPanel::onThreshold(int minVal, int maxVal) +void interfMainPanel::onThreshold() { - wxContourMainFrame::getInstance()->onThreshold(minVal, maxVal); + wxContourMainFrame::getInstance()->onThreshold(); } -void interfMainPanel::onThresholdChange(int minVal, int maxVal) +void interfMainPanel::onThresholdChange() { - wxContourMainFrame::getInstance()->onThresholdChange(minVal, maxVal); + wxContourMainFrame::getInstance()->onThresholdChange(); } -void interfMainPanel::onThresholdInstantChange(int range[]) +void interfMainPanel::onThresholdInstantChange(double range[]) { panelThreshold->onThresholdInstantChange(range); } diff --git a/lib/Interface_Icons_NDimensions/interfMainPanel.h b/lib/Interface_Icons_NDimensions/interfMainPanel.h index c28928b..e9663c2 100644 --- a/lib/Interface_Icons_NDimensions/interfMainPanel.h +++ b/lib/Interface_Icons_NDimensions/interfMainPanel.h @@ -136,11 +136,11 @@ public: void onMirrorChangeWidth(int width); - void onThreshold(int minVal, int maxVal); + void onThreshold(); - void onThresholdChange(int minVal, int maxVal); + void onThresholdChange(); - void onThresholdInstantChange(int range[]); + void onThresholdInstantChange(double range[]); void onThresholdRemove(); diff --git a/lib/Interface_Icons_NDimensions/interfSegmentationPanels.cxx b/lib/Interface_Icons_NDimensions/interfSegmentationPanels.cxx index b4e1696..615f852 100644 --- a/lib/Interface_Icons_NDimensions/interfSegmentationPanels.cxx +++ b/lib/Interface_Icons_NDimensions/interfSegmentationPanels.cxx @@ -319,10 +319,7 @@ void interfThresholdPanel::onThresholdChange(wxCommandEvent& event) { if (_thresholdGo) { - int minVal = _mBarThreshold->GetStart(); - int maxVal = _mBarThreshold->GetEnd(); - - interfMainPanel::getInstance()->onThresholdChange(minVal, maxVal); + interfMainPanel::getInstance()->onThresholdChange(); //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal << std::endl; } @@ -332,27 +329,30 @@ void interfThresholdPanel::onThresholdGo(wxCommandEvent& event) { if (!_thresholdGo) { - int minVal = _mBarThreshold->GetStart(); - int maxVal = _mBarThreshold->GetEnd(); - - interfMainPanel::getInstance()->onThreshold(minVal, maxVal); + interfMainPanel::getInstance()->onThreshold(); _thresholdGo=true; } } void interfThresholdPanel::onThresholdRemove(wxCommandEvent& event) { - interfMainPanel::getInstance()->onThresholdRemove( ); - _thresholdGo=false; + if (_thresholdGo) + { + interfMainPanel::getInstance()->onThresholdRemove( ); + _thresholdGo=false; + } } void interfThresholdPanel::onThresholdStop() { - interfMainPanel::getInstance()->onThresholdRemove( ); - _thresholdGo=false; + if (_thresholdGo) + { + interfMainPanel::getInstance()->onThresholdRemove( ); + _thresholdGo=false; + } } -void interfThresholdPanel::onThresholdInstantChange(int range[]) +void interfThresholdPanel::onThresholdInstantChange(double range[]) { range[0] = _mBarThreshold->GetStart(); range[1] = _mBarThreshold->GetEnd(); diff --git a/lib/Interface_Icons_NDimensions/interfSegmentationPanels.h b/lib/Interface_Icons_NDimensions/interfSegmentationPanels.h index 72399b1..f52a776 100644 --- a/lib/Interface_Icons_NDimensions/interfSegmentationPanels.h +++ b/lib/Interface_Icons_NDimensions/interfSegmentationPanels.h @@ -109,7 +109,7 @@ public: ~interfThresholdPanel(); void onThresholdStop(); - void onThresholdInstantChange(int range[]); + void onThresholdInstantChange(double range[]); private: diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx index e391f7c..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; @@ -594,7 +600,7 @@ void wxContourMainFrame::changeInstant() kernelManager->setInstant(instantVect); //_modelManager->setInstant( _actualInstant ); - updateActor(); + onThresholdChange(); updateInstantOutlines(); updateInstantImageData(); updateInstantAxes(); @@ -638,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 ); @@ -880,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; @@ -1212,7 +1142,7 @@ const double propagationScaling = atof( crea::wx2std(prop).c_str() ); vtkPolyData* polyDataResult = cntVTK->GetOutput(); - std::cout<<"Points "<GetNumberOfPoints()<GetNumberOfPoints()<Update( ); polyDataResult->UpdateInformation(); @@ -1294,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) @@ -1975,7 +1885,7 @@ void wxContourMainFrame::onThresholdInterpolation(bool interpolate) _thresholdActor->InterpolateOff( ); } - RefreshInterface(); + _theViewPanel->RefreshInterface(); } } @@ -1986,7 +1896,7 @@ void wxContourMainFrame::onThresholdChangeOpacity (int opacity) _thresholdActor->SetOpacity(opacity*0.1); } - RefreshInterface(); + _theViewPanel->RefreshInterface(); } void wxContourMainFrame::onThresholdRemove() @@ -1998,7 +1908,7 @@ void wxContourMainFrame::onThresholdRemove() _actorPresent = false; } - RefreshInterface(); + _theViewPanel->RefreshInterface(); } void wxContourMainFrame::showAxis(bool show) diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h index 5733100..b86de8d 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h +++ b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h @@ -222,7 +222,6 @@ class wxContourMainFrame : public wxPanel { void updateInstantOutlines(); void updateInstantImageData(); void updateInstantAxes(); - void updateActor(); void onChangeDeep(int val); @@ -260,8 +259,8 @@ class wxContourMainFrame : public wxPanel { //AD void onMirror(); - void onThreshold(int minVal, int maxVal); - void onThresholdChange(int minVal, int maxVal); + void onThreshold(); + void onThresholdChange(); void onThresholdInterpolation(bool interpolate); void onThresholdChangeOpacity (int opacity); void onThresholdRemove(); @@ -344,8 +343,12 @@ private: long m_notebook_theme; int _numberOfVariablesStatistics; + vtkImageReslice * _imageReslicer; + vtkLookupTable * _thresholdTable; + vtkImageMapToColors * _thresholdMapper; vtkImageActor * _thresholdActor; + bool _actorPresent; //OutlineModelManager * _modelManager;