X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FInterface_ManagerContour_NDimensions%2FwxContourMainFrame.cxx;h=92600cd969d8240fb56ffb7a969e0bae5f1fcf97;hb=469e6994cecb1763109864df0be7067fe5c344f3;hp=1ce584994fc26d25f27de8c341be8249d293c964;hpb=0ac5c532df0c8e1506a58b22ccb4369426f56c4f;p=creaContours.git diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx index 1ce5849..92600cd 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx +++ b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx @@ -126,12 +126,22 @@ char wxContourMainFrame::COPY = 'C'; _performingOperation = new PerformingOperation(); if(images.size() > 0) { - this->setVectImages(images); + this->configure(images); } _contourextractdata = NULL; } -void wxContourMainFrame::setVectImages(std::vector imgs) + +void wxContourMainFrame::changeImage(int id, vtkImageData *img) +{ + if ( id<_images.size() ) _images[id]=img; + kernelManager->changeImage(id,img); + _theViewPanel->changeImage(img); +// updateInstantImageData(); + +} + +void wxContourMainFrame::configure(std::vector imgs) { _images = imgs; #if defined(_WIN32) @@ -159,7 +169,7 @@ void wxContourMainFrame::setVectImages(std::vector imgs) } - wxContourMainFrame* wxContourMainFrame :: getInstance(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector images, long style,std::string datadir ) + wxContourMainFrame* wxContourMainFrame::getInstance(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector images, long style,std::string datadir ) { if(instance == NULL) { @@ -214,9 +224,9 @@ void wxContourMainFrame::setVectImages(std::vector imgs) // wxAuiNotebook * wxContourMainFrame::createNotebook() { - wxSize client_size = GetClientSize(); + wxSize client_size = GetClientSize(); wxAuiNotebook* noteBook = new wxAuiNotebook(this, -1, wxPoint(client_size.x, client_size.y), wxSize(430,200), m_notebook_style); - wxBitmap page_bmp = wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16,16)); + wxBitmap page_bmp = wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16,16)); return noteBook; } @@ -734,7 +744,6 @@ void wxContourMainFrame::updateInstantImageData() { std::vector inst; _instantPanel->getInstant(inst); - vtkImageData* img = kernelManager->getImageAtInstant(inst); if(img!=NULL) { @@ -863,7 +872,7 @@ void wxContourMainFrame ::loadState(std::string filename) onLoadContours(filename,false); } -void wxContourMainFrame::onLoad() +void wxContourMainFrame::onLoad(bool interactiveInterface) // interactiveInterface default true { std::string fileNameContourROI = GetFileLocation(); //CMRU 03-09-09----------------------------------------------------------------------------------------------- @@ -881,7 +890,7 @@ void wxContourMainFrame::onLoad() fileNameContourROI = (const char *)(dialog.GetPath().mb_str()); } // if dialog } // if FileLocation - onLoadContours(fileNameContourROI,true); + onLoadContours(fileNameContourROI, interactiveInterface ); } void wxContourMainFrame::SetZForAllContours(int pz) @@ -894,7 +903,6 @@ void wxContourMainFrame::SetZForAllContours(int pz) sizeLstNameThings = lstNameThings.size(); for (i=0 ; igetOutlineByKeyName(lstNameThings[i]); sizeLstPoints = manualModel->GetSizeLstPoints(); for (ii=0 ; iiGetDimensions(dimRange); - fprintf(pFile,"ImageDimensions %d %d %d\n", dimRange[0], dimRange[1], dimRange[2] ); - double spaRange[3]; image->GetSpacing(spaRange); - fprintf(pFile,"ImageSpacing %f %f %f\n", spaRange[0], spaRange[1], spaRange[2] ); - // Normal Contours - lstNameThings = kernelManager->GetLstNameThings(); sizeLstNameThings = lstNameThings.size(); fprintf(pFile,"NumberOfContours %d\n", sizeLstNameThings ); - //CMRU 03-09-09----------------------------------------------------------------------------------------------- fprintf(pFileData,"NumberOfContours %d\n", sizeLstNameThings ); //------------------------------------------------------------------------------------------------------------ - - // EED 2017-05-30 double spc[3]; spc[0]=1; spc[1]=1; - spc[2]=1; - + spc[2]=1; for (i=0 ; igetOutlineByKeyName(lstNameThings[i]); - // EED 2017-05-30 // double sizeInPixel = manualModel ->GetPathSize( ); double sizeInPixel = manualModel ->GetPathSize( spc ); - double realContourSize = sizeInPixel*_onePixelSize; manualModel ->SetRealSize(realContourSize); //------------------------------------------------------------------------------------------------------------ - //int size= kernelManager->GetLstNameThings().size(); - kernelManager->SaveThingName( pFile, pFileData, lstNameThings[i] ); _theViewPanel->getSceneManager()->SaveThingName( pFile, lstNameThings[i] ); }// for i - //-- Static Contours - // fprintf(pFile,"ImageDimensions %d %d %d\n", dimRange[0], dimRange[1], dimRange[2] ); // fprintf(pFile,"ImageSpacing %f %f %f\n", spaRange[0], spaRange[1], spaRange[2] ); - lstNameThings = kernelManager->GetLstNameThingsStatic(); sizeLstNameThings = lstNameThings.size(); fprintf(pFile,"NumberOfContoursStatic %d\n", sizeLstNameThings ); - //CMRU 03-09-09----------------------------------------------------------------------------------------------- fprintf(pFileData,"NumberOfContoursStatic %d\n", sizeLstNameThings ); //------------------------------------------------------------------------------------------------------------ - for (i=0 ; iSaveThingName( pFile, pFileData, lstNameThings[i] ); @@ -1177,10 +1164,11 @@ void wxContourMainFrame::readDimSpc(FILE *pFile, bool interactiveOption) // wxBoxSizer *dialSizer = new wxBoxSizer(wxVERTICAL); wxFlexGridSizer *dialSizer = new wxFlexGridSizer(1); - wxString lstOptOperation[2]; - lstOptOperation[0]=_T("By Dimension"); - lstOptOperation[1]=_T("By Spacing"); - wxRadioBox * radioOpts = new wxRadioBox(dial, -1, _T("Type of Transformation"), wxDefaultPosition, wxSize(270,90), 2 , lstOptOperation, 2, wxRA_SPECIFY_COLS); + wxString lstOptOperation[3]; + lstOptOperation[0]=_T("By Dimension (XY)"); + lstOptOperation[1]=_T("By Spacing (XY)"); + lstOptOperation[2]=_T("By Spacing (XYZ)"); + wxRadioBox * radioOpts = new wxRadioBox(dial, -1, _T("Type of Transformation"), wxDefaultPosition, wxSize(370,200), 3 , lstOptOperation, 3, wxRA_SPECIFY_ROWS); dialSizer->Add( new wxStaticText(dial,-1,_T("The image resolution is not compatible with the ")) , 0, wxGROW ); dialSizer->Add( new wxStaticText(dial,-1,_T("selected Roi file. Do you want to tranform it?")) , 0, wxGROW ); @@ -1192,7 +1180,7 @@ void wxContourMainFrame::readDimSpc(FILE *pFile, bool interactiveOption) dial->Layout(); dial->ShowModal(); - int _tmpReadFileTypeOfTransformation = -1; + _tmpReadFileTypeOfTransformation = -1; //EED bool transform = false; if (dial->GetReturnCode() == wxID_OK) @@ -1210,7 +1198,6 @@ void wxContourMainFrame::readDimSpc(FILE *pFile, bool interactiveOption) //AD:04-06-09 void wxContourMainFrame::openContours( FILE *pFile, FILE *pFileData, bool staticContour ) { - char tmp[255]; vtkImageData *image = _images[0]; @@ -1328,14 +1315,22 @@ void wxContourMainFrame::openContours( FILE *pFile, FILE *pFileData, bool static //nothing to do.. } else if (_tmpReadFileTypeOfTransformation==0){ double transX, transY; - transX = (double) imageDim[0]/_tmpReadFileImageDim[0]; - transY = (double) imageDim[1]/_tmpReadFileImageDim[1]; - manModelContour->Transform_Ax_Plus_B(transX,0,transY,0); + transX = (double) imageDim[0]/_tmpReadFileImageDim[0]; // X + transY = (double) imageDim[1]/_tmpReadFileImageDim[1]; // Y + manModelContour->Transform_Ax_Plus_B(transX,0,transY,0); } else if (_tmpReadFileTypeOfTransformation==1) { double transX, transY; - transX = (double) _tmpReadFileImageSpac[0]/imageDim[0]; - transY = (double) _tmpReadFileImageSpac[1]/imageDim[1]; + transX = (double) _tmpReadFileImageSpac[0]/imageSpac[0]; // X + transY = (double) _tmpReadFileImageSpac[1]/imageSpac[1]; // Y + manModelContour->Transform_Ax_Plus_B(transX,0,transY,0); + } else if (_tmpReadFileTypeOfTransformation==2) { // with Z include + double transX, transY; + transX = (double) _tmpReadFileImageSpac[0]/imageSpac[0]; // X + transY = (double) _tmpReadFileImageSpac[1]/imageSpac[1]; // Y + instantVector[1]=instantVector[1]*_tmpReadFileImageSpac[2]/imageSpac[2]; // Z manModelContour->Transform_Ax_Plus_B(transX,0,transY,0); + }else { + printf ("EED Warnning! wxContourMainFrame::openContours _tmpReadFileTypeOfTransformation not set. \n"); } fscanf(pFile,"%s",tmp); // TypeView @@ -1715,7 +1710,7 @@ void wxContourMainFrame::SegmentationOneSliceITK(int x, int y, int z, wxString d } -void wxContourMainFrame::onSegmentationOneSlice(int isovalue,int sampling,int method){ +void wxContourMainFrame::onSegmentationOneSlice(double isovalue,int sampling,int method){ //JCP 20-10-08 Undo redo implementation saveState(); @@ -1725,20 +1720,17 @@ void wxContourMainFrame::onSegmentationOneSlice(int isovalue,int sampling,int me int x = _theViewPanel->GetX(); int y = _theViewPanel->GetY(); int z = _theViewPanel->GetZ(); - SegmentationOneSlice( x,y,z,isovalue, sampling, method ); + SegmentationOneSlice( x,y,z,isovalue, sampling, method , getImageData() ); RefreshInterface(); } -void wxContourMainFrame::SegmentationOneSlice( int x, int y, int z, int isovalue, int sampling, int method ) +void wxContourMainFrame::SegmentationOneSlice( int x, int y, int z, double isovalue, int sampling, int method , vtkImageData *imagedata) { - -printf("EED wxContourMainFrame::SegmentationOneSlice Start=%d %d\n",sampling,method ); -printf("EED wxContourMainFrame::SegmentationOneSlice %d %d %d \n",x,y,z ); - int typeofcontour = 1; //--Extracting Contour - vtkImageData *imagedata = getImageData(); +// 2024-01-09 +// vtkImageData *imagedata = getImageData(); vtkImageReslice *imageReslice = vtkImageReslice::New(); //EED @@ -1883,39 +1875,32 @@ myfile.close(); std::vector vecCtrlPointY; std::vector vecCtrlPointZ; -printf("EED wxContourMainFrame::SegmentationOneSlice GetNumberOfLines=%d \n",polyDataResult->GetNumberOfLines() ); - -int numberOfPointsInCell; -int numberOfcells=polyDataResult->GetNumberOfCells(); -for (int jj=0; jjGetCell( jj ); - numberOfPointsInCell=vtkcell->GetNumberOfPoints(); - printf("EED wxContourMainFrame::SegmentationOneSlice cell=%d points=%d \n",jj,numberOfPointsInCell ); -}// for jj - -printf("EED wxContourMainFrame::SegmentationOneSlice PrintSelf \n"); - -polyDataResult->PrintSelf( std::cout, vtkIndent(0) ); +//printf("EED wxContourMainFrame::SegmentationOneSlice GetNumberOfLines=%d \n",polyDataResult->GetNumberOfLines() ); +//int numberOfPointsInCell; +//int numberOfcells=polyDataResult->GetNumberOfCells(); +//for (int jj=0; jjGetCell( jj ); +// numberOfPointsInCell=vtkcell->GetNumberOfPoints(); +// printf("EED wxContourMainFrame::SegmentationOneSlice cell=%d points=%d \n",jj,numberOfPointsInCell ); +//}// for jj +// printf("EED wxContourMainFrame::SegmentationOneSlice PrintSelf \n"); +// polyDataResult->PrintSelf( std::cout, vtkIndent(0) ); if (polyDataResult->GetNumberOfCells()>0) { double *p; - printf("EED wxContourMainFrame::SegmentationOneSlice A \n"); vtkCell* vtkcell = polyDataResult->GetCell( 0 ); - printf("EED wxContourMainFrame::SegmentationOneSlice B \n"); // int ii,size=polyDataResult->GetNumberOfPoints(); int ii,size=vtkcell->GetNumberOfPoints(); - printf("EED wxContourMainFrame::SegmentationOneSlice C \n"); int id; for (ii=0;iiGetLines()->GetData()->GetValue(ii); // p = polyDataResult->GetPoint(id); p = vtkcell->GetPoints()->GetPoint(ii); - - printf("EED wxContourMainFrame::SegmentationOneSlice (%d) id=%d px=%f py=%f\n",ii,id, p[0],p[1]); +// printf("EED wxContourMainFrame::SegmentationOneSlice (%d) id=%d px=%f py=%f\n",ii,id, p[0],p[1]); // double x=p[0]; // double y=p[1]; vecX.push_back( p[0] ); @@ -1924,10 +1909,8 @@ polyDataResult->PrintSelf( std::cout, vtkIndent(0) ); vecZ.push_back( -900 ); // vecZ.push_back( p[2] ); } - ExtractControlPoints2D *extractcontrolpoints2d = new ExtractControlPoints2D(); extractcontrolpoints2d->SetContour( &vecX , &vecY , &vecZ ); - //PROOFS /*if (methodRadiobox->GetSelection()==0){ extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ ); @@ -1981,8 +1964,7 @@ polyDataResult->PrintSelf( std::cout, vtkIndent(0) ); } // if addedModel } // if sizeCtrPt } // if NumberOfCells > 0 - -printf("EED wxContourMainFrame::SegmentationOneSlice End\n"); +//printf("EED wxContourMainFrame::SegmentationOneSlice End\n"); } int wxContourMainFrame::GetImageDataSizeZ() @@ -1995,7 +1977,36 @@ void wxContourMainFrame::GetImageDataRange(double *range) _theViewPanel->GetImageDataRange(range); } -void wxContourMainFrame::onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method) +void wxContourMainFrame::onSegmentationAllSlices2(int step ,double isovalue,int sampling,int method,int minZ, int maxZ,vtkImageData* imagedata) +{ + //JCP 20-10-08 Undo redo implementation + saveState(); + //JCP 20-10-08 Undo redo implementation + wxBusyCursor wait; +// int x = _theViewPanel->GetX(); +// int y = _theViewPanel->GetY(); + int z; +// double porcent; +// wxString tmpString; +// double totalZ = maxZ-minZ+1; + int ext[6]; + imagedata->GetExtent(ext); + int sizeZ = ext[5]-ext[4]+1; + if (minZ<0) { minZ=0; } + if (maxZ>=sizeZ) { maxZ=sizeZ-1; } + for( z=minZ ; z<=maxZ ; z=z+step ) + { +// porcent = 100.0* (z-minZ)/totalZ; +// tmpString.Printf(_T(" %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ,z ); +// interfMainPanel::getInstance()->setLabelSegmentationPanelVTK(tmpString); + //_staticTextSegmentation->SetLabel(tmpString); + SegmentationOneSlice( 100,100,z,isovalue, sampling,method , imagedata ); + } +// interfMainPanel::getInstance()->setLabelSegmentationPanelVTK(_T(" ")); + RefreshInterface(); +} + +void wxContourMainFrame::onSegmentationAllSlices(int minZ,int maxZ,double isovalue,int sampling,int method) { //JCP 20-10-08 Undo redo implementation saveState(); @@ -2014,7 +2025,7 @@ void wxContourMainFrame::onSegmentationAllSlice(int minZ,int maxZ,int isovalue,i tmpString.Printf(_T(" %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ,z ); interfMainPanel::getInstance()->setLabelSegmentationPanelVTK(tmpString); //_staticTextSegmentation->SetLabel(tmpString); - SegmentationOneSlice( x,y,z,isovalue, sampling,method ); + SegmentationOneSlice( x,y,z,isovalue, sampling,method , getImageData() ); } interfMainPanel::getInstance()->setLabelSegmentationPanelVTK(_T(" ")); RefreshInterface(); @@ -2236,7 +2247,6 @@ int wxContourMainFrame::getWindowLevel() void wxContourMainFrame::onBrigthnessColorWindowLevel(int colorwindow,int windowlevel) { _theViewPanel->onBrigthnessColorWindowLevel(colorwindow, windowlevel); - RefreshInterface(); } @@ -3089,7 +3099,6 @@ void wxContourMainFrame::onSnakePressed(){ void wxContourMainFrame::saveFileWithContoursAutomatique() { -printf("EED wxContourMainFrame::saveFileWithContoursAutomatique \n"); std::string filename = kernelManager->getCurrentFileName(); if(filename.compare("")!=0){ saveFileWithContours(filename); @@ -3097,22 +3106,19 @@ printf("EED wxContourMainFrame::saveFileWithContoursAutomatique \n"); onSave(); } } + void wxContourMainFrame::ShowToolsPanel(bool show) { _pannew->Show(show); } - - void wxContourMainFrame::SetContourGroup(int contourGroup) { _contourGroup = contourGroup; } - wxPanel *wxContourMainFrame::getMaskImageViewPanel(wxWindow *parent) { - if (_viewMaskImagePanel==NULL) { _contourextractdata = new ContourExtractData(true); @@ -3178,6 +3184,18 @@ wxPanel *wxContourMainFrame::getColorLayerImageViewPanel(wxWindow *parent) return _viewColorLayerImagePanel; } +void wxContourMainFrame::SetColorLayerImage(vtkImageData* img) +{ + if (_viewColorLayerImagePanel!=NULL) + { + if (img!=NULL) + { + _viewColorLayerImagePanel->SetActive(true); + _viewColorLayerImagePanel->SetImage( img ); +// RefreshInterface(); + } // img + } // _viewColorLayerImagePanel +} wxPanel *wxContourMainFrame::getThresholdImageViewPanel(wxWindow *parent) { @@ -3185,13 +3203,14 @@ wxPanel *wxContourMainFrame::getThresholdImageViewPanel(wxWindow *parent) { double range[2]; _theViewPanel->getImageData()->GetScalarRange(range); - int min = (int)floor (range[0]); - int max = (int)ceil (range[1]); - int start= (max+min)/2 - (max-min)*0.25; - int end= (max+min)/2 + (max-min)*0.25; - _viewThresholdImagePanel = new ThresholdImageViewPanel( parent, min, max, start, end , 1); - _viewThresholdImage = new ThresholdImageView(); + int min = (int)floor (range[0]); + int max = (int)ceil (range[1]); + int start = (max+min)/2 - (max-min)*0.25; + int end = (max+min)/2 + (max-min)*0.25; + _viewThresholdImagePanel = new ThresholdImageViewPanel( parent, min, max, start, end , 1); + _viewThresholdImage = new ThresholdImageView(); _viewThresholdImage->SetminMaxValue(start,end); +// _viewThresholdImage->SetminMaxValue(range[0],range[1]); _viewThresholdImage->SetImage( _theViewPanel->getImageData() ); std::vector colorbarposition; colorbarposition.push_back( 10 ); @@ -3406,6 +3425,15 @@ void wxContourMainFrame::SetXY(int x, int y) _theViewPanel->SetXY(x,y); } +wxVtkBaseView* wxContourMainFrame::GetWxVtkBaseView() +{ + if (_theViewPanel!=NULL) + { + return _theViewPanel->getWxVtkBaseView();; + } else { + return NULL; + } +}