X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FInterface_ManagerContour_NDimensions%2FwxContourMainFrame.cxx;h=a3f199a412109c5c46f425a5fe230be2e1804256;hb=87eb16df886e4afe2d53ddf115de54cf8fe25665;hp=760f5431b8e2618120e0b19db779df4059a8f100;hpb=28671ae02163f2b674da599a98a128f58dfead88;p=creaContours.git diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx index 760f543..a3f199a 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx +++ b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx @@ -94,6 +94,8 @@ char wxContourMainFrame::COPY = 'C'; _viewThresholdImage = NULL; _viewThresholdImagePanel = NULL; _viewColorLayerImagePanel = NULL; + + _frameShowResultImages = NULL; } wxContourMainFrame::wxContourMainFrame(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector images, long style,std::string datadir) @@ -103,7 +105,6 @@ char wxContourMainFrame::COPY = 'C'; _contourGroup = 1; _creatingContoursActive = false; _theViewPanel = NULL; - _instantPanel = NULL; _refLineControl = NULL; _refLineModel = NULL; @@ -123,7 +124,7 @@ char wxContourMainFrame::COPY = 'C'; inredo = 0; inundo = 0; _pannew = interfMainPanel::getInstance(this,datadir+"/data/Icons");//, eventHandler); - _performingOperation = new PerformingOperation(); + _performingOperation = new PerformingOperation(); if(images.size() > 0) { this->setVectImages(images); @@ -134,10 +135,10 @@ char wxContourMainFrame::COPY = 'C'; void wxContourMainFrame::setVectImages(std::vector imgs) { _images = imgs; - #if defined(__GNUC__) - std::string str_home(getenv("HOME")); - #elif defined(_WIN32) + #if defined(_WIN32) std::string str_home(getenv("USERPROFILE")); + #elif defined(__GNUC__) + std::string str_home(getenv("HOME")); #endif std::string strCreaContourDataTmp = str_home + "/.creaContourDataTemp/"; std::vector conceptNameVect; @@ -320,20 +321,25 @@ void wxContourMainFrame::onCreateContourSpline( ){ createContour( 1 ); } -void wxContourMainFrame::onCreateContourRectangle( ){ + +void wxContourMainFrame::onCreateContourRectangle( ) +{ //JCP 20-10-08 Undo redo implementation saveState(); //JCP 20-10-08 Undo redo implementation createContour( 2 ); } -void wxContourMainFrame::onCreateContourCircle( ){ + +void wxContourMainFrame::onCreateContourCircle( ) +{ //JCP 20-10-08 Undo redo implementation saveState(); //JCP 20-10-08 Undo redo implementation createContour( 3 ); } -void wxContourMainFrame::onCreateContourLine( ){ +void wxContourMainFrame::onCreateContourLine( ) +{ //JCP 20-10-08 Undo redo implementation saveState(); //JCP 20-10-08 Undo redo implementation @@ -341,7 +347,8 @@ void wxContourMainFrame::onCreateContourLine( ){ } // RaC 09-09 -------------------------------------- -void wxContourMainFrame::onCreateContourPoints( ){ +void wxContourMainFrame::onCreateContourPoints( ) +{ //JCP 20-10-08 Undo redo implementation saveState(); //JCP 20-10-08 Undo redo implementation @@ -350,7 +357,8 @@ void wxContourMainFrame::onCreateContourPoints( ){ // RaC 09-09 -------------------------------------- // RaC 10-09 -------------------------------------- -void wxContourMainFrame::onCreateContourPolygon( ){ +void wxContourMainFrame::onCreateContourPolygon( ) +{ //JCP 20-10-08 Undo redo implementation saveState(); //JCP 20-10-08 Undo redo implementation @@ -385,15 +393,14 @@ void wxContourMainFrame :: onCreateContourBullEye(wxPanel* panel ) _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , 4) ; } } + void wxContourMainFrame :: createContour( int typeContour ) { //Creating the manualContourModel and including in the model manualBaseModel * manModelContour = kernelManager->factoryManualContourModel(typeContour); - std::vector instantVector; _instantPanel->getInstant( instantVector ); std::string theName = kernelManager->createOutline(manModelContour, instantVector); - /*std::vector instantVector; _instantPanel->getInstant( instantVector ); std::string theName; @@ -407,9 +414,9 @@ void wxContourMainFrame :: createContour( int typeContour ) //Adding the manualViewContour to interface objects structure //_sceneManager->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active. _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , typeContour) ; - } - + } // if addedModel } + manualBaseModel * wxContourMainFrame::factoryManualContourModel(wxPanel* panel){ manualContourModelBullEye *manModelContourBullEye = new manualContourModelBullEye(); @@ -632,21 +639,27 @@ void wxContourMainFrame::ShowResultImages(int typeContourGroup, int selection, i nTypeView.push_back(2); nTypeView.push_back(0); - wxFrame *frame = new wxFrame(this, -1,_T("Result image extracted.."),wxDefaultPosition,wxSize(600,600), wxDEFAULT_FRAME_STYLE|wxSTAY_ON_TOP); - wxAuiManager *m_mgr_noteBookViewerResult = new wxAuiManager(); - m_mgr_noteBookViewerResult->SetManagedWindow(frame); + if (_frameShowResultImages==NULL) + { +// wxFrame *_frameShowResultImages = new wxFrame(this, -1,_T("Result image extracted.."),wxDefaultPosition,wxSize(600,600), wxDEFAULT_FRAME_STYLE|wxSTAY_ON_TOP); + _frameShowResultImages = new wxFrame(this, -1,_T("Result image extracted.."),wxDefaultPosition,wxSize(600,600), + wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER ); + + wxAuiManager *m_mgr_noteBookViewerResult = new wxAuiManager(); + m_mgr_noteBookViewerResult->SetManagedWindow(_frameShowResultImages); - wxAuiNotebook* noteBookViewerResult = new wxAuiNotebook(frame, -1, wxPoint(600, 600), wxSize(430,200), m_notebook_style); - m_mgr_noteBookViewerResult->AddPane(noteBookViewerResult, wxAuiPaneInfo().Name(wxT("notebook_content")).CenterPane().PaneBorder(false)); + wxAuiNotebook* noteBookViewerResult = new wxAuiNotebook(_frameShowResultImages, -1, wxPoint(600, 600), wxSize(430,200), m_notebook_style); + m_mgr_noteBookViewerResult->AddPane(noteBookViewerResult, wxAuiPaneInfo().Name(wxT("notebook_content")).CenterPane().PaneBorder(false)); - wxPanel *panelViewer1 = new wxMaracas_N_ViewersWidget(noteBookViewerResult, value,&nTypeView); - wxPanel *panelViewer2 = new wxMaracas_N_ViewersWidget(noteBookViewerResult, mask,&nTypeView); + wxPanel *panelViewer1 = new wxMaracas_N_ViewersWidget(noteBookViewerResult, value,&nTypeView); + wxPanel *panelViewer2 = new wxMaracas_N_ViewersWidget(noteBookViewerResult, mask,&nTypeView); - noteBookViewerResult->AddPage( panelViewer1, wxT("Image result") ); - noteBookViewerResult->AddPage( panelViewer2, wxT("Mask result") ); - m_mgr_noteBookViewerResult->Update(); - frame->Show(); + noteBookViewerResult->AddPage( panelViewer1, wxT("Image result") ); + noteBookViewerResult->AddPage( panelViewer2, wxT("Mask result") ); + m_mgr_noteBookViewerResult->Update(); + _frameShowResultImages->Show(); + } // if _frameShowResultImages } @@ -1703,19 +1716,18 @@ printf("EED wxContourMainFrame::SegmentationOneSliceITK Skypping this code. No { vecXo.push_back(p[0]); vecYo.push_back(p[1]); - } - else - { - vecX.push_back( p[0] ); - myfile <getSceneManager()->GetImageData(); @@ -1970,6 +1984,7 @@ void wxContourMainFrame::SegmentationOneSlice( int x, int y, int z, int isovalue cpd2->UpdateInformation(); vtkStripper* vtkstripper = vtkStripper::New( ); + vtkstripper->SetMaximumLength(20000); //EED 2017-01-01 Migration VTK7 #if VTK_MAJOR_VERSION <= 5 vtkstripper->SetInput( cpd2->GetOutput() ); @@ -2017,6 +2032,23 @@ myfile.close(); 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) ); + + + double *p; int ii,size=polyDataResult->GetNumberOfPoints(); int id; @@ -2024,11 +2056,13 @@ myfile.close(); { id = polyDataResult->GetLines()->GetData()->GetValue(ii); p = polyDataResult->GetPoint(id); +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] ); vecY.push_back( p[1] ); - vecZ.push_back( 900 ); +//EED 2017-12-16 + vecZ.push_back( -900 ); // vecZ.push_back( p[2] ); } @@ -2048,27 +2082,30 @@ myfile.close(); extractcontrolpoints2d->GetSamplingControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ ); }*/ - if (method==0){ + if (method==0) + { extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ ); - } - else if (method==1){ + } else if (method==1){ extractcontrolpoints2d->GetControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ ); - } - else if (method==2){ + } else if (method==2){ extractcontrolpoints2d->SetSamplingControlPoints( sampling ); extractcontrolpoints2d->GetSamplingControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ ); } //--Adding contour to the system - std::vector actualInstantVector; _instantPanel->getInstant( actualInstantVector ); actualInstantVector[1]=z; int j,sizeCtrPt = vecCtrlPointX.size(); manualBaseModel *manModelContour = kernelManager->factoryManualContourModel( typeofcontour ); - manModelContour->SetNumberOfPointsSpline( ((sizeCtrPt/100)+1)*100 ); - if (sizeCtrPt>=3){ +printf("EED wxContourMainFrame::SegmentationOneSlice sizeCtrPt=%d %d %d\n" , sizeCtrPt + , ((sizeCtrPt/100)+1)*100 *2 + , manModelContour->GetNumberOfPointsSpline() + ); + manModelContour->SetNumberOfPointsSpline( ((sizeCtrPt/100)+1)*100 *2 ); + if (sizeCtrPt>=3) + { for (j=0 ; jAddPoint( vecCtrlPointX[j] , vecCtrlPointY[j] , vecCtrlPointZ[j] ); @@ -2088,16 +2125,21 @@ myfile.close(); //_theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc, typeofcontour ) ; } // if addedModel } // if sizeCtrPt +printf("EED wxContourMainFrame::SegmentationOneSlice End\n"); } -int wxContourMainFrame::GetImageDataSizeZ(){ + +int wxContourMainFrame::GetImageDataSizeZ() +{ return _theViewPanel->GetImageDataSizeZ(); } -void wxContourMainFrame::GetImageDataRange(double *range){ +void wxContourMainFrame::GetImageDataRange(double *range) +{ _theViewPanel->GetImageDataRange(range); } -void wxContourMainFrame::onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method){ +void wxContourMainFrame::onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method) +{ //JCP 20-10-08 Undo redo implementation saveState(); //JCP 20-10-08 Undo redo implementation @@ -2945,7 +2987,6 @@ void wxContourMainFrame::getMaskValue(vtkImageData ** mask,vtkImageData ** value int z; int ii,sizeLstContourThings; - double totalZ; double porcent; @@ -3026,13 +3067,41 @@ void wxContourMainFrame::getMaskValue(vtkImageData ** mask,vtkImageData ** value } -void wxContourMainFrame::SaveImageResult(std::string directory,std::string namefile, vtkImageData* mask,vtkImageData* value) +std::string wxContourMainFrame::GetStringTypeImage( vtkImageData* image) { + std::string result=""; + if ( image->GetScalarType()==VTK_CHAR ) + { + result="CHAR"; + } else if ( image->GetScalarType()==VTK_UNSIGNED_CHAR ){ + result="UCHAR"; + } else if ( image->GetScalarType()==VTK_FLOAT ){ + result="FLOAT"; + } else if ( image->GetScalarType()==VTK_DOUBLE ){ + result="DOUBLE"; + } else if ( image->GetScalarType()==VTK_INT ){ + result="INT"; + } else if ( image->GetScalarType()==VTK_UNSIGNED_INT ){ + result="UINT"; + } else if ( image->GetScalarType()==VTK_SHORT ){ + result="SHORT"; + } else if ( image->GetScalarType()==VTK_UNSIGNED_SHORT ){ + result="USHORT"; + } else if ( image->GetScalarType()==VTK_LONG ){ + result="LONG"; + } else if ( image->GetScalarType()==VTK_UNSIGNED_LONG ){ + result="ULONG"; + } + return result; +} +void wxContourMainFrame::SaveImageResult(std::string directory,std::string namefile, vtkImageData* mask,vtkImageData* value) +{ + std::string stringType; double spc[3]; kernelManager->GetSpacing(spc,0); // returns the spacing of the first image - - std::string temp = directory + "/" + namefile + "-image-Value.mhd"; + stringType = GetStringTypeImage(value); + std::string temp = directory + "/" + namefile + "-image-Value-"+stringType+".mhd"; wxString filename = crea::std2wx(temp); @@ -3060,7 +3129,8 @@ void wxContourMainFrame::SaveImageResult(std::string directory,std::string namef writerValueImage->Write( ); // Image Mask - temp = directory + "/" + namefile + "-image-Mask.mhd"; + stringType = GetStringTypeImage(mask); + temp = directory + "/" + namefile + "-image-Mask-"+stringType+".mhd"; // LG 14/01/09 : using crea filename = crea::std2wx(temp); @@ -3153,7 +3223,7 @@ void wxContourMainFrame::SetContourGroup(int contourGroup) wxPanel *wxContourMainFrame::getMaskImageViewPanel(wxWindow *parent) { - + if (_viewMaskImagePanel==NULL) { _contourextractdata = new ContourExtractData(true); @@ -3162,15 +3232,29 @@ wxPanel *wxContourMainFrame::getMaskImageViewPanel(wxWindow *parent) // _theViewPanel->getImageData()->GetScalarRange(range); //int min = (int)floor (range[0]); //int max = (int)ceil (range[1]); + +//EED 2017-12-17 int min = 254; int max = 256; - _viewMaskImagePanel = new ThresholdImageViewPanel( parent, -1, -1 , 0); + + _viewMaskImagePanel = new ThresholdImageViewPanel( parent, -1, -1 , -1,-1, 0); _viewMaskImage = new ThresholdImageView(); - _viewMaskImage->SetImage(_contourextractdata->GetVtkImageMaskResult() ); + _viewMaskImage->SetImage( _contourextractdata->GetVtkImageMaskResult() ); _viewMaskImage->SetminMaxValue( min, max); _viewMaskImage->SetBaseColor( 0,0,1 ); + + + std::vector colorbarposition; + colorbarposition.push_back( -999 ); + colorbarposition.push_back( -999 ); + _viewMaskImage->SetColorBarPosition( colorbarposition ); + double spc[3]; + _viewMaskImage->SetSpcBase( _theViewPanel->getImageData()->GetSpacing() ); + _viewMaskImage->SetNewSpacingLayer( _theViewPanel->getImageData()->GetSpacing() ); + _viewMaskImagePanel->SetThresholdImageView( _viewMaskImage ); _viewMaskImage->SetwxVtkBaseView( _theViewPanel->getWxVtkBaseView() ); + _viewMaskImage->onThresholdChangeOpacity( 25 ); } return _viewMaskImagePanel; } @@ -3186,6 +3270,21 @@ wxPanel *wxContourMainFrame::getColorLayerImageViewPanel(wxWindow *parent) int max = (int)ceil (range[1]); _viewColorLayerImagePanel = new ColorLayerImageViewPanel( parent, min, max, 100, 1); _viewColorLayerImagePanel->GetColorLayerImageViewManager()->SetwxVtkBaseView( 0 , _theViewPanel->getWxVtkBaseView() ); + // std::vector range = bbGetInputlstRangeForColorBar(); + // clivp->GetColorLayerImageViewManager()->SetRangeForColorBar( range ); + std::vector colorbarposition; + colorbarposition.push_back( 50 ); + colorbarposition.push_back( 105 ); + _viewColorLayerImagePanel->GetColorLayerImageViewManager()->SetColorBarPosition( colorbarposition ); + // std::vector base_color; + // _viewColorLayerImagePanel->GetColorLayerImageViewManager()->SetBaseColors( base_color ); + // std::vector grey_level_boundaries; + // clivp->GetColorLayerImageViewManager()->SetGreyLevelBoundaries( grey_level_boundaries ); + std::vector transparence_level_boundaries; + transparence_level_boundaries.push_back(0); + _viewColorLayerImagePanel->GetColorLayerImageViewManager()->SetBaseTransparence( transparence_level_boundaries ); + _viewColorLayerImagePanel->GetColorLayerImageViewManager()->SetPlainOrGradientColor( false ); +// _viewColorLayerImagePanel->SetFittingMode( 3 ); } return _viewColorLayerImagePanel; } @@ -3199,13 +3298,25 @@ wxPanel *wxContourMainFrame::getThresholdImageViewPanel(wxWindow *parent) _theViewPanel->getImageData()->GetScalarRange(range); int min = (int)floor (range[0]); int max = (int)ceil (range[1]); - _viewThresholdImagePanel = new ThresholdImageViewPanel( parent, min, max , 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->SetImage( _theViewPanel->getImageData() ); - _viewThresholdImage->SetminMaxValue( min, max); + std::vector colorbarposition; + colorbarposition.push_back( 10 ); + colorbarposition.push_back( 105 ); + _viewThresholdImage->SetColorBarPosition( colorbarposition ); + double spc[3]; + _viewThresholdImage->SetSpcBase( _theViewPanel->getImageData()->GetSpacing() ); + _viewThresholdImage->SetNewSpacingLayer( _theViewPanel->getImageData()->GetSpacing() ); + _viewThresholdImage->SetBaseColor( 1,0,0 ); _viewThresholdImagePanel->SetThresholdImageView( _viewThresholdImage ); _viewThresholdImage->SetwxVtkBaseView( _theViewPanel->getWxVtkBaseView() ); + _viewThresholdImage->onThresholdChangeOpacity( 25 ); + RefreshInterface(); } return _viewThresholdImagePanel; } @@ -3315,7 +3426,6 @@ void wxContourMainFrame::SetFileLocation(std::string newFileLocation) void wxContourMainFrame::FlipSelectedContours(int flipDirection) { - printf("EED wxContourMainFrame::FlipSelectedContours flipDirection=%d \n", flipDirection ); FlipLstOfContours( (std::vector)_theViewPanel->getSceneManager()->getSelectedObjects() , flipDirection @@ -3325,7 +3435,6 @@ void wxContourMainFrame::FlipSelectedContours(int flipDirection) void wxContourMainFrame::FlipActualSliceContours(int flipDirection) { - printf("EED wxContourMainFrame::FlipActualSliceContours flipDirection=%d \n", flipDirection ); FlipLstOfContours( (std::vector)_theViewPanel->getSceneManager()->GetlstContoursNameActualSlice() , flipDirection @@ -3334,7 +3443,6 @@ void wxContourMainFrame::FlipActualSliceContours(int flipDirection) void wxContourMainFrame::FlipAllContours(int flipDirection) { - printf("EED wxContourMainFrame::FlipAllContours flipDirection=%d \n", flipDirection ); FlipLstOfContours( kernelManager->GetLstNameThings() , flipDirection