]> Creatis software - creaContours.git/blobdiff - lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx
*** empty log message ***
[creaContours.git] / lib / Interface_ManagerContour_NDimensions / wxContourMainFrame.cxx
index 1957a9e4d37aed7e1a61f5576abc4e8e7f95cb0d..26678b33bb2c7d805ce11f5734babcf524fae6ec 100644 (file)
@@ -68,7 +68,8 @@ char wxContourMainFrame::COPY = 'C';
                _viewMaskImagePanel                     = NULL;
                _viewThresholdImage                     = NULL;
                _viewThresholdImagePanel        = NULL;
-
+               _viewColorLayerImage            = NULL;
+               _viewColorLayerImagePanel       = NULL;
        }
 
        wxContourMainFrame :: wxContourMainFrame(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector<vtkImageData*> images, long style,std::string datadir)         
@@ -88,6 +89,8 @@ char wxContourMainFrame::COPY = 'C';
                _viewMaskImagePanel                     = NULL;
                _viewThresholdImage                     = NULL;
                _viewThresholdImagePanel        = NULL;
+               _viewColorLayerImage            = NULL;
+               _viewColorLayerImagePanel       = NULL;
 
                // set up default notebook style
                m_notebook_style =wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_EXTERNAL_MOVE | wxNO_BORDER;
@@ -153,7 +156,8 @@ void wxContourMainFrame::setVectImages(std::vector<vtkImageData*> imgs)
 }
 
 
-       wxContourMainFrame* wxContourMainFrame :: getInstance(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector<vtkImageData*> images, long style,std::string datadir ){
+       wxContourMainFrame* wxContourMainFrame :: getInstance(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector<vtkImageData*> images, long style,std::string datadir )
+       {
                if(instance == NULL){
                        instance = new wxContourMainFrame(parent, id, title, pos, size, images, style,datadir);
                }
@@ -669,7 +673,15 @@ void wxContourMainFrame::changeInstant()
                                _viewThresholdImage->onThreshold();
                        }
                }
-       
+
+       // Refresh Threshold image
+               if(_viewColorLayerImage!=NULL){
+                       _viewColorLayerImage->SetZ(actualSlice);                        
+                       if (_viewColorLayerImagePanel->IsVisible()==true){
+                               _viewColorLayerImage->onThreshold();
+                       }
+               }
+
                updateInstantOutlines();
                updateInstantImageData();
                updateInstantAxes();
@@ -912,11 +924,8 @@ void wxContourMainFrame ::loadContours( FILE *pFile, bool staticContour )
 }
 
 void wxContourMainFrame::onLoad()
-{
-       char tmp[255];
-       char tmpD[255];
+{      
        std::string fileNameContourROI = GetFileLocation();
-
 //CMRU 03-09-09-----------------------------------------------------------------------------------------------
        if(GetFileLocation().empty())
        {
@@ -928,6 +937,13 @@ void wxContourMainFrame::onLoad()
                }
        }
 
+       onLoadContours(fileNameContourROI);
+}
+
+void wxContourMainFrame::onLoadContours(std::string fileNameContourROI){
+       char tmp[255];
+       char tmpD[255];
+
        FILE *pFile =fopen(fileNameContourROI.c_str(),"r+");
 
 
@@ -985,7 +1001,35 @@ void wxContourMainFrame::onLoad()
        }
        _theViewPanel->getSceneManager()->removeSceneContours();
        changeInstant();
+
+}
+
+void wxContourMainFrame::onImport(){
+       std::string filename, filenamecontours;
+       wxFileDialog dialog(NULL, _T("Choose a XML Osirix File"), _T(""), _T(""), _T("*.xml"), wxOPEN );
+
+       if (dialog.ShowModal() == wxID_OK)
+       {
+               filename = dialog.GetPath().mb_str();           
+               filenamecontours = kernelManager->parseOsirixFile(filename);
+
+               if(filenamecontours.compare("") != 0){
+                       onLoadContours(filenamecontours);
+               }
+
+       }
 }
+void wxContourMainFrame::onTest(){
+       std::string filename, filenamecontours;
+       wxFileDialog dialog(NULL, _T("Choose a File"), _T(""), _T(""), _T("*.*"), wxOPEN );
+
+       if (dialog.ShowModal() == wxID_OK)
+       {
+               filename = dialog.GetPath().mb_str();           
+               std::cout << "This is the filename: " << filename << std::endl;
+       }
+}
+
 
 //AD: 29-05-09
 void wxContourMainFrame::onSave(){
@@ -2304,6 +2348,11 @@ std::vector<std::string> wxContourMainFrame::getOutlinesName(int slide){
 }
 
 
+void wxContourMainFrame::SetScalarRange(int grayRangeMin, int grayRangeMax)
+{
+       _contourextractdata->SetScalarRange(grayRangeMin,grayRangeMax);
+}
+
 
 void wxContourMainFrame::onInformationContourLabels(int typeContourGroup,int selection,int minimumZ,int maximumZ,int grayRangeMin, int grayRangeMax)
 {
@@ -2419,16 +2468,22 @@ void wxContourMainFrame::onInformationContourLabels(int typeContourGroup,int sel
                        }
 
                        _contourextractdata->SetLstManualContourModel( lstManConModTmp );
+                       _contourextractdata->SetScalarRange(grayRangeMin,grayRangeMax);
 
                        pLstValue.clear();
                        pLstValuePosX.clear();
                        pLstValuePosY.clear();
                        pLstValuePosZ.clear();
-                       _contourextractdata->GetValuesInsideCrown(      &pLstValue,
+
+                       
+                       int numberOfPixels;
+                       _contourextractdata->GetValuesInsideCrown(  &numberOfPixels,
+                                                                                                               &pLstValue,
                                                                                                                &pLstValuePosX,
                                                                                                                &pLstValuePosY,
                                                                                                                &pLstValuePosZ);
 
+                       resultSize=numberOfPixels;
                        // Statistics of each slice.
                        _contourextractdata->Statistics( &pLstValue,
                                                                                        grayRangeMin,
@@ -2439,7 +2494,7 @@ void wxContourMainFrame::onInformationContourLabels(int typeContourGroup,int sel
                                                                                        &resultMax,
                                                                                        &resultAverage,
                                                                                        &resultStandardeviation);
-                       
+
                        if (interfMainPanel::getInstance()->getNumberColsInformationPanel()<_numberOfVariablesStatistics*(iContourGroup+1)  )
                        {
                                interfMainPanel::getInstance()->appendColsInformationPanel(_numberOfVariablesStatistics);
@@ -2447,7 +2502,8 @@ void wxContourMainFrame::onInformationContourLabels(int typeContourGroup,int sel
 
                        tmpIntA=_numberOfVariablesStatistics*iContourGroup ;
 
-                       tempString.Printf(_T("%d"),resultSize);
+                       tempString.Printf(_T("%d"),numberOfPixels);
+
                        interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA, tempString);  
 
                        tempString.Printf(_T("%d"),resultGrayRangeCount);
@@ -2699,7 +2755,9 @@ void wxContourMainFrame::SaveValuesXYZ(std::string directory,std::string namefil
                        pLstValuePosX.clear();
                        pLstValuePosY.clear();
                        pLstValuePosZ.clear();
-                       _contourextractdata->GetValuesInsideCrown(      &pLstValue,
+                       int numberOfPixels;
+                       _contourextractdata->GetValuesInsideCrown(      &numberOfPixels,
+                                                                                                               &pLstValue,
                                                                                                                &pLstValuePosX,
                                                                                                                &pLstValuePosY,
                                                                                                                &pLstValuePosZ);
@@ -2861,8 +2919,10 @@ void wxContourMainFrame::SaveImageResult(std::string directory,std::string namef
 // Image Value
        vtkMetaImageWriter *writerValueImage = vtkMetaImageWriter::New( );
        writerValueImage->SetInput( value );
+       writerValueImage->SetInput( value );
        writerValueImage->SetFileName( (const char *)filename.mb_str() );
        writerValueImage->SetFileDimensionality( 3 );
+       writerValueImage->SetCompression(false);
        writerValueImage->Write( );
 
 // Image Mask
@@ -2882,6 +2942,7 @@ void wxContourMainFrame::SaveImageResult(std::string directory,std::string namef
        writerMaskImage->SetInput( mask );
        writerMaskImage->SetFileName( (const char *)filename.mb_str() );
        writerMaskImage->SetFileDimensionality( 3 );
+       writerValueImage->SetCompression(false);
        writerMaskImage->Write( );
 
        interfMainPanel::getInstance()->setStringInfoPanel( _T("") );
@@ -2952,15 +3013,13 @@ wxPanel *wxContourMainFrame::getMaskImageViewPanel(wxWindow *parent)
        if      (_viewMaskImagePanel==NULL)
        {
                _contourextractdata = new ContourExtractData(true);
-               _contourextractdata->SetImage( _theViewPanel->getImageData() );
-               
+               _contourextractdata->SetImage( _theViewPanel->getImageData() );         
 //             double range[2];
 //             _theViewPanel->getImageData()->GetScalarRange(range);
                //int min = (int)floor (range[0]);
                //int max = (int)ceil (range[1]);
                int min = 254;
                int max = 256;
-               
                _viewMaskImagePanel = new ThresholdImageViewPanel( parent, -1, -1 , 0);
                _viewMaskImage = new ThresholdImageView();
                _viewMaskImage->SetImage(_contourextractdata->GetVtkImageMaskResult() );
@@ -2968,11 +3027,30 @@ wxPanel *wxContourMainFrame::getMaskImageViewPanel(wxWindow *parent)
                _viewMaskImage->SetBaseColor( 0,0,1 );
                _viewMaskImagePanel->SetThresholdImageView( _viewMaskImage );
                _viewMaskImage->SetwxVtkBaseView( _theViewPanel->getWxVtkBaseView() );
-               
        }
        return _viewMaskImagePanel;
 }
 
+
+wxPanel *wxContourMainFrame::getColorLayerImageViewPanel(wxWindow *parent)
+{
+       if      (_viewColorLayerImagePanel==NULL)
+       {
+               double range[2];
+               _theViewPanel->getImageData()->GetScalarRange(range);
+               int min = (int)floor (range[0]);
+               int max = (int)ceil (range[1]);         
+               _viewColorLayerImagePanel = new ColorLayerImageViewPanel( parent, min, max , 1);
+               _viewColorLayerImage = new ColorLayerImageView();
+//             _viewColorLayerImage->SetImage( _theViewPanel->getImageData() );
+               _viewColorLayerImage->SetImage( NULL );
+               _viewColorLayerImagePanel->SetColorLayerImageView( _viewColorLayerImage );
+               _viewColorLayerImage->SetwxVtkBaseView( _theViewPanel->getWxVtkBaseView() );
+       }
+       return _viewColorLayerImagePanel;
+}
+
+
 wxPanel *wxContourMainFrame::getThresholdImageViewPanel(wxWindow *parent)
 {
        if      (_viewThresholdImagePanel==NULL)
@@ -3071,4 +3149,4 @@ void wxContourMainFrame::SetFileLocation(std::string newFileLocation)
        _fileLocation = newFileLocation;
        std::cout<<"GETFILELOCATION:"<<_fileLocation<<std::endl;
 }
-//------------------------------------------------------------------------------------------------------------
\ No newline at end of file
+//------------------------------------------------------------------------------------------------------------