]> Creatis software - creaContours.git/blobdiff - lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx
*** empty log message ***
[creaContours.git] / lib / Interface_ManagerContour_NDimensions / wxContourMainFrame.cxx
index 41a380463ed91a7f30274c5cbc61635ffa5b6293..1e6ff4c9337394ae6d46937c305884932a33ccf8 100644 (file)
@@ -153,7 +153,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);
                }
@@ -346,6 +347,15 @@ void wxContourMainFrame::onCreateContourPoints( ){
 }
 // RaC 09-09 --------------------------------------
 
+// RaC 10-09 --------------------------------------
+void wxContourMainFrame::onCreateContourPolygon( ){
+    //JCP 20-10-08 Undo redo implementation
+       saveState();
+       //JCP 20-10-08 Undo redo implementation 
+       createContour( 10 );
+}
+// RaC 10-09 --------------------------------------
+
 //------------------------------------------------------------------------------------------------------------
 
 void wxContourMainFrame :: onCreateContourBullEye(wxPanel* panel )
@@ -903,11 +913,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())
        {
@@ -919,6 +926,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+");
 
 
@@ -976,8 +990,42 @@ 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 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);
+               }
+
+       }
+}
+
+
 //AD: 29-05-09
 void wxContourMainFrame::onSave(){
 //CMRU 03-09-09-----------------------------------------------------------------------------------------------
@@ -1026,7 +1074,6 @@ void wxContourMainFrame::saveFileWithContours( std::string filename )
        fprintf(pFileData,"--CreaContour--\n");
        fprintf(pFileData,"Version %s\n", "1.0.2" );
        fprintf(pFileData,"OnePixelSize %f\n", _onePixelSize);
-       std::cout<<"Valor de un pixel: "<<_onePixelSize<<std::endl;             
        
 //------------------------------------------------------------------------------------------------------------
        
@@ -2296,6 +2343,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)
 {
@@ -2411,16 +2463,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,
@@ -2431,7 +2489,7 @@ void wxContourMainFrame::onInformationContourLabels(int typeContourGroup,int sel
                                                                                        &resultMax,
                                                                                        &resultAverage,
                                                                                        &resultStandardeviation);
-                       
+
                        if (interfMainPanel::getInstance()->getNumberColsInformationPanel()<_numberOfVariablesStatistics*(iContourGroup+1)  )
                        {
                                interfMainPanel::getInstance()->appendColsInformationPanel(_numberOfVariablesStatistics);
@@ -2439,7 +2497,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);
@@ -2691,7 +2750,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);
@@ -2995,9 +3056,10 @@ int wxContourMainFrame::getType ()
                std::string cloneName = currentSelection [0];
                manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(cloneName);
                tipo = manualModel-> GetTypeModel();    
-               return tipo;
        }
+       return tipo;
 }
+
 double wxContourMainFrame::getContourSizeInPixels()
 {
        double contourSize = 0; 
@@ -3062,4 +3124,4 @@ void wxContourMainFrame::SetFileLocation(std::string newFileLocation)
        _fileLocation = newFileLocation;
        std::cout<<"GETFILELOCATION:"<<_fileLocation<<std::endl;
 }
-//------------------------------------------------------------------------------------------------------------
\ No newline at end of file
+//------------------------------------------------------------------------------------------------------------