]> Creatis software - creaContours.git/blobdiff - lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx
#3334 creaContours Feature New Normal - Control Refresh events from bbtk
[creaContours.git] / lib / Interface_ManagerContour_NDimensions / wxContourMainFrame.cxx
index 33db75f8652b799e2e366ebc8186d9058709bb5e..793e05d9ebf18b600e7363c163ef7dbeaa1edb89 100644 (file)
@@ -52,7 +52,7 @@ using namespace std;
        // Constructors & Destructors
        //------------------------------------------------------------------------------------------------------------
 
-wxContourMainFrame* wxContourMainFrame:: instance = NULL;
+wxContourMainFrame* wxContourMainFrame::instance=NULL;
 char wxContourMainFrame::COPY = 'C';
 
        wxContourMainFrame :: wxContourMainFrame(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,long style)
@@ -94,7 +94,6 @@ char wxContourMainFrame::COPY = 'C';
                _viewThresholdImage                     = NULL;
                _viewThresholdImagePanel        = NULL;
                _viewColorLayerImagePanel       = NULL;
-
                _frameShowResultImages          = NULL;
        }
 
@@ -162,28 +161,29 @@ 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 )
        {
-               if(instance == NULL){
-                       instance = new wxContourMainFrame(parent, id, title, pos, size, images, style,datadir);
+               if(instance == NULL)
+               {
+                       instance=new wxContourMainFrame(parent, id, title, pos, size, images, style,datadir);
                }
                return instance;
        }
 
-       std::vector<vtkImageData*> wxContourMainFrame ::getVectImages()
+       std::vector<vtkImageData*> wxContourMainFrame::getVectImages()
        {
                return kernelManager->getVectImages();
        }
 
-       wxContourMainFrame* wxContourMainFrame :: getInstance()
+       wxContourMainFrame* wxContourMainFrame::getInstance()
        {
                return instance;
        }
 
-       void wxContourMainFrame :: resetInstance()
+       void wxContourMainFrame::resetInstance()
        {
                instance->Destroy();
        }
 
-       wxContourMainFrame :: ~wxContourMainFrame()
+       wxContourMainFrame::~wxContourMainFrame()
        {
                delete _contourextractdata;
                deleteAllContours();
@@ -212,7 +212,7 @@ void wxContourMainFrame::setVectImages(std::vector<vtkImageData*> imgs)
        // Creational and initialization methods using WxAui
        //------------------------------------------------------------------------------------------------------------
        //
-       wxAuiNotebook * wxContourMainFrame :: createNotebook()
+       wxAuiNotebook * wxContourMainFrame::createNotebook()
        {
                wxSize client_size = GetClientSize();
                wxAuiNotebook* noteBook = new wxAuiNotebook(this, -1, wxPoint(client_size.x, client_size.y), wxSize(430,200), m_notebook_style);
@@ -224,7 +224,7 @@ void wxContourMainFrame::setVectImages(std::vector<vtkImageData*> imgs)
        //------------------------------------------------------------------------------------------------------------
        // Creational and initialization methods
        //------------------------------------------------------------------------------------------------------------
-       bool wxContourMainFrame :: configurePanels( )
+       bool wxContourMainFrame::configurePanels( )
        {
                bool configured = _theViewPanel!=NULL;
 
@@ -852,7 +852,7 @@ void wxContourMainFrame :: createMirrorContourOf ( std::string anExistingKName,
                mp->SetPointX( vecOut[0] );
                mp->SetPointY( vecOut[1] );
                mp->SetPointZ( vecOut[2] );
-       }
+       } // for i
 
        _theViewPanel->getSceneManager()->createCopyContourOf( anExistingKName, cloneName, manualModel , append );
 }
@@ -863,7 +863,6 @@ void wxContourMainFrame ::loadState(std::string filename)
        onLoadContours(filename,false);
 }
 
-
 void wxContourMainFrame::onLoad()
 {
        std::string fileNameContourROI = GetFileLocation();
@@ -880,20 +879,17 @@ void wxContourMainFrame::onLoad()
                if (dialog.ShowModal() == wxID_OK)
                {
                        fileNameContourROI = (const char *)(dialog.GetPath().mb_str());
-               }
-       }
-
+               } // if dialog
+       } // if FileLocation
        onLoadContours(fileNameContourROI,true);
 }
 
-
 void  wxContourMainFrame::SetZForAllContours(int pz)
 {
        //-- Normal Contours
        std::vector< std::string > lstNameThings;       
        int i,sizeLstNameThings;
-       int ii,sizeLstPoints;
-       
+       int ii,sizeLstPoints;   
        lstNameThings           = kernelManager->GetLstNameThings();
        sizeLstNameThings       = lstNameThings.size(); 
        for (i=0 ; i<sizeLstNameThings ; i++)
@@ -965,27 +961,18 @@ void wxContourMainFrame::onLoadContours(std::string fileNameContourROI, bool int
                        readDimSpc(pFile,false);                // DimSpc interactive OFF
                        openContours(pFile,pFileData,true);     // Load StaticContours
                        SetZForAllContours(-900);
-               }
-               //AD:02-06-09
-               else if (version=="1.0.1")
-               {
+               } else if (version=="1.0.1") { //AD:02-06-09
                        openContours(pFile,pFileData,false); //Skips ImageDimensions and ImageSpacing
                        openContours(pFile,pFileData,true); //Load StaticContours, skips ImageDimensions and ImageSpacing
-               }
-
-               //AD:02-06-09
-               else if (version=="1.0.0")
-               {
+               } else if (version=="1.0.0") { //AD:02-06-09
                        openContours(pFile,pFileData,false); //Skips ImageDimensions and ImageSpacing
                }
-
                fclose(pFile);
-
                if(pFileData != NULL)
                {
                        fclose(pFileData);
                } // if
-       }
+       } // pFile
        _theViewPanel->getSceneManager()->removeSceneContours();
        changeInstant();
 }
@@ -1005,7 +992,8 @@ void wxContourMainFrame::onImport()
                filename = dialog.GetPath().mb_str();
                filenamecontours = kernelManager->parseOsirixFile(filename);
 
-               if(filenamecontours.compare("") != 0){
+               if(filenamecontours.compare("") != 0)
+               {
                        onLoadContours(filenamecontours,true);
                } // if
        } // if
@@ -1020,7 +1008,6 @@ void wxContourMainFrame::onTest()
 #else
        wxFileDialog dialog(NULL, _T("Choose a File"), _T(""), _T(""), _T("*.*"), wxFD_OPEN );
 #endif
-
        if (dialog.ShowModal() == wxID_OK)
        {
                filename = dialog.GetPath().mb_str();
@@ -1028,9 +1015,9 @@ void wxContourMainFrame::onTest()
        } // if
 }
 
-
 //AD: 29-05-09
-void wxContourMainFrame::onSave(){
+void wxContourMainFrame::onSave()
+{
 //CMRU 03-09-09-----------------------------------------------------------------------------------------------
        if(GetFileLocation().empty())
        {
@@ -1047,10 +1034,7 @@ void wxContourMainFrame::onSave(){
                        kernelManager->setCurrentFileName(fileNameContourROI);
                        saveFileWithContours( fileNameContourROI );
                }
-       }
-//CMRU 03-09-09-----------------------------------------------------------------------------------------------
-       else
-       {
+       } else {//CMRU 03-09-09-----------------------------------------------------------------------------------------------
                std::cout<<"Nombre del archivo: "<<GetFileLocation()<<std::endl;
                std::string fileNameContourROI = GetFileLocation();
                std::cout<<"Nombre del archivo: "<<fileNameContourROI<<std::endl;
@@ -1190,12 +1174,13 @@ void wxContourMainFrame::readDimSpc(FILE *pFile, bool interactiveOption)
                {
                        wxDialog* dial = new wxDialog (this,-1,_T("Tools"),wxDefaultPosition, wxSize(460,360));
                        wxSizer* buttonsSizer = dial->CreateSeparatedButtonSizer(wxOK|wxCANCEL);
-                       wxBoxSizer *dialSizer = new wxBoxSizer(wxVERTICAL);
+//                     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,45), 2 , lstOptOperation,  2, wxRA_SPECIFY_COLS);
+                       wxRadioBox * radioOpts = new wxRadioBox(dial, -1, _T("Type of Transformation"), wxDefaultPosition, wxSize(270,90), 2 , lstOptOperation,  2, wxRA_SPECIFY_COLS);
 
                        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 );
@@ -1899,6 +1884,10 @@ void wxContourMainFrame::onSegmentationOneSlice(int isovalue,int sampling,int me
 
 void wxContourMainFrame::SegmentationOneSlice( int x, int y, int z, int isovalue, int sampling, int method )
 {
+
+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();
@@ -2072,7 +2061,7 @@ polyDataResult->PrintSelf( std::cout, vtkIndent(0) );
                int ii,size=vtkcell->GetNumberOfPoints();
        printf("EED wxContourMainFrame::SegmentationOneSlice C \n");
                int id;
-               for (ii=1;ii<=size;ii++)
+               for (ii=0;ii<size;ii++)
                {
        //              id      = polyDataResult->GetLines()->GetData()->GetValue(ii);
        //              p       = polyDataResult->GetPoint(id);
@@ -3250,7 +3239,9 @@ void wxContourMainFrame::onSnakePressed(){
 
 }
 
-void wxContourMainFrame::saveFileWithContoursAutomatique(){
+void wxContourMainFrame::saveFileWithContoursAutomatique()
+{
+printf("EED wxContourMainFrame::saveFileWithContoursAutomatique \n");
        std::string filename = kernelManager->getCurrentFileName();
        if(filename.compare("")!=0){
                saveFileWithContours(filename);
@@ -3258,7 +3249,8 @@ void wxContourMainFrame::saveFileWithContoursAutomatique(){
                onSave();
        }
 }
-void wxContourMainFrame::ShowToolsPanel(bool show){
+void wxContourMainFrame::ShowToolsPanel(bool show)
+{
        _pannew->Show(show);
 }
 
@@ -3463,6 +3455,9 @@ void wxContourMainFrame::SetFileLocation(std::string newFileLocation)
 {
        _fileLocation = newFileLocation;
        std::cout<<"GETFILELOCATION:"<<_fileLocation<<std::endl;
+
+//EED 2019-12-17
+       kernelManager->setCurrentFileName(_fileLocation);
 }
 //------------------------------------------------------------------------------------------------------------
 
@@ -3512,7 +3507,6 @@ void wxContourMainFrame::FlipLstOfContours(std::vector<std::string> lstNameThing
        sizeLstNameThings       = lstNameThings.size(); 
        for (i=0 ; i<sizeLstNameThings ; i++)
        {
-               printf("EED wxContourMainFrame::FlipAllContours contour=%d \n", i );
                manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(lstNameThings[i]);
                if (flipDirection==0)
                {
@@ -3540,8 +3534,6 @@ void wxContourMainFrame::FlipLstOfContours(std::vector<std::string> lstNameThing
 
 void wxContourMainFrame::FlipContours(int typeContourFlip, int flipDirection)
 {
-       printf("EED wxContourMainFrame::FlipContours( %d , %d ) \n",typeContourFlip,  flipDirection );
-
        saveState();
        
        if (typeContourFlip==0) // 
@@ -3561,7 +3553,6 @@ void wxContourMainFrame::FlipContours(int typeContourFlip, int flipDirection)
        RefreshInterface();
 }
 
-
 void wxContourMainFrame::SetXY(int x, int y)
 {
        _theViewPanel->SetXY(x,y);