]> Creatis software - creaContours.git/blobdiff - lib/Interface_Icons_NDimensions/interfMainPanel.cxx
Changes with manualBaseModel. It improves the functionality with the new
[creaContours.git] / lib / Interface_Icons_NDimensions / interfMainPanel.cxx
index 0cf8b41dee745ef1a0398ccb0e952d81913a66fc..b5da6290946a2b1fbfb180fe7a3fcf12ca8f0468 100644 (file)
@@ -18,22 +18,28 @@ interfMainPanel::interfMainPanel(wxWindow * parent, int sizex, int sizey, wxEvtH
 : wxPanel(parent, -1, wxDefaultPosition, wxSize(sizex, sizey), wxBORDER_SUNKEN)
 {
 
-       PANEL = "New Contour";
-       PANEL1 = "I/O";
-       PANEL2 = "Edit";
-       PANEL3 = "Delete";
-       PANEL4 = "Tools";  
-       PANEL5 = "Segmentation";
-       segmentPanel = NULL;
-       segmentPanelITK = NULL;
-       configPanel = NULL;
-       spreadPanel = NULL;
-       infoWin = NULL;
-       informationPanel = NULL;
-       mirrorPanel = NULL;
-       thresholdPanel = NULL;
-       currentWindow = NULL;
-       
+       PANEL                           = "New Contour";
+       PANEL1                          = "I/O";
+       PANEL2                          = "Edit";
+       PANEL3                          = "Delete";
+       PANEL4                          = "Tools";  
+       PANEL5                          = "Segmentation";
+       segmentPanel            = NULL;
+       segmentPanelITK         = NULL;
+       configPanel                     = NULL;
+       spreadPanel                     = NULL;
+       infoWin                         = NULL;
+       infoPanel                       = NULL;
+       infoPanelMask           = NULL;
+       informationPanel        = NULL;
+       mirrorPanel                     = NULL;
+       thresholdPanel          = NULL;
+       currentWindow           = NULL;
+
+//CMRU 17-08-09 ------------------------------------------------------------------
+       infoPanelCalibration = NULL;
+       panelAux = NULL;
+//--------------------------------------------------------------------------------
        splitterwindow = new wxSplitterWindow(this,-1, wxDefaultPosition, wxSize(sizex, sizey), wxSP_3DSASH, wxString(_T("")));
 
        splitterwindow->SetMinimumPaneSize( 10 );
@@ -104,11 +110,11 @@ interfMainPanel::interfMainPanel(wxWindow * parent, int sizex, int sizey, wxEvtH
        wxFlexGridSizer* infosizer = new wxFlexGridSizer(1,1,2,2);      
        infoPanel->SetSizer(infosizer, true);
        infoPanel->SetAutoLayout( true );       
-               
+
        splitterwindow->Initialize(toolpanel);
        splitterwindow->SetSashGravity(1);
        splitterwindow->SplitHorizontally(toolpanel, infoPanel);        
-               
+
        Connect(b->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
        Connect(b1->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
        Connect(b2->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
@@ -125,11 +131,11 @@ interfMainPanel::~interfMainPanel(void)
 
 interfMainPanel* interfMainPanel::getInstance(wxWindow* parent, std::string datadir, wxEvtHandler * evtHandler){       
 
-       _newframe = new wxFrame(parent, -1, wxT(" Contour Tools "), wxPoint(25,50), wxSize(350,850),wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION |  wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT);
+       _newframe = new wxFrame(parent, -1, wxT(" Contour Tools "), wxPoint(25,50), wxSize(350,900),wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION |  wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT);
        
                                                                                                                                                                                
        if(interfmainpanel == NULL){
-               interfmainpanel = new interfMainPanel(_newframe, 350, 850, evtHandler, datadir);
+               interfmainpanel = new interfMainPanel(_newframe, 350, 900, evtHandler, datadir);
        }
 
        _newframe->Show(TRUE);
@@ -138,10 +144,10 @@ interfMainPanel* interfMainPanel::getInstance(wxWindow* parent, std::string data
 
 interfMainPanel* interfMainPanel::getInstance(wxWindow* parent, wxEvtHandler * evtHandler){    
 
-       _newframe = new wxFrame(parent, -1, wxT(" Contour Tools "), wxPoint(25,50), wxSize(350,850),wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION |  wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT );
+       _newframe = new wxFrame(parent, -1, wxT(" Contour Tools "), wxPoint(25,50), wxSize(350,900),wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION |  wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT );
 
        if(interfmainpanel == NULL){
-               interfmainpanel = new interfMainPanel(_newframe, 350, 850, evtHandler);
+               interfmainpanel = new interfMainPanel(_newframe, 350, 900, evtHandler);
        }
 
        _newframe->Show(TRUE);
@@ -347,6 +353,14 @@ void interfMainPanel::onCreateContourLine( ){
        wxContourMainFrame::getInstance()->showAxis(false);
     wxContourMainFrame::getInstance()->onCreateContourLine();
 }
+
+// RaC 09-09 ---------------------
+void interfMainPanel::onCreateContourPoints( ){
+       wxContourMainFrame::getInstance()->showAxis(false);
+    wxContourMainFrame::getInstance()->onCreateContourPoints();
+}
+// RaC 09-09 ---------------------
+
 void interfMainPanel::onCreateContoursBullEye(wxPanel* panBull){
        wxContourMainFrame::getInstance()->showAxis(false);
        wxContourMainFrame::getInstance()->onCreateContourBullEye(panBull);
@@ -453,7 +467,6 @@ void interfMainPanel::onSegmentationPressedITK(){
                //wxPanel* panel = contourevent->getSegmentationPanelITK(segmentPanelITK);
                wxPanel* panel = new interfSegmentationPanelITK(segmentPanelITK);
        
-
                wxStaticText* stattext = new wxStaticText(segmentPanelITK, -1, wxString(_T("   Automatic ITK Segmentation   ")), wxDefaultPosition,
                        wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
 
@@ -489,25 +502,20 @@ void interfMainPanel::onInterpolation(bool interpolate)
        wxContourMainFrame::getInstance()->onInterpolation(interpolate);
 }
 
-void interfMainPanel::onConfigurationPressed(){
 
+void interfMainPanel::onConfigurationPressed(){
        if(configPanel == NULL){
                configPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
                wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);    
                configPanel->SetSizer(flexsizer, true);
                configPanel->SetAutoLayout( true );     
                //configPanel->SetEventHandler(this->contourevent);
-               
                wxPanel* panel = new interfConfigurationPanel(configPanel);
-
                wxStaticText* stattext = new wxStaticText(configPanel, -1, wxString(_T("   Interface Configuration   ")), wxDefaultPosition,
                        wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
-
                flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
-
                flexsizer->Add(panel, wxEXPAND);
                configPanel->Layout();
-
        }
        showPanel(configPanel);
 }
@@ -556,6 +564,8 @@ void interfMainPanel::setStringSpread(std::string stringtemp){
 }
 
 void interfMainPanel::onInformationPressed(){
+       
+       // Statistics frame
        if(infoWin ==NULL){
                infoWin                                         = new wxFrame (this, -1,_T("  Statistics  "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION |  wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER  );
                infoWin->SetSize( wxSize(825,650) );
@@ -569,9 +579,7 @@ void interfMainPanel::onInformationPressed(){
                infoWin->SetSizer( sizerPanel );
                infoWin->SetAutoLayout( true );
                infoWin->Layout();
-
                infoWin->Show();
-
        }else {
 
                if (infoWin->IsShown()==true)
@@ -581,7 +589,63 @@ void interfMainPanel::onInformationPressed(){
                        //contourevent->FillGridWithContoursInformation();
                        infoWin->Show(true);
                }
+       }
+               
+//CMRU 29-08-09----------------------------------------------------------------------------------------------- 
+       if(panelAux == NULL)
+       {
+               panelAux = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
        }       
+//------------------------------------------------------------------------------------------------------------
+
+       // mask view control panel
+       if(infoPanelMask == NULL){
+               infoPanelMask = new wxPanel(panelAux, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
+               wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);    
+               infoPanelMask->SetSizer(flexsizer, true);
+               infoPanelMask->SetAutoLayout( true );   
+               //configPanel->SetEventHandler(this->contourevent);
+               wxPanel *panel = wxContourMainFrame::getInstance()->getMaskImageViewPanel( infoPanelMask );                             
+               wxStaticText* stattext = new wxStaticText(infoPanelMask, -1, wxString(_T("   Mask segmentation    ")), wxDefaultPosition,
+                                                                                                 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
+               
+               flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
+               
+               flexsizer->Add(panel, wxEXPAND);
+               infoPanelMask->Layout();
+               
+       }
+       
+//CMRU 29-08-09-----------------------------------------------------------------------------------------------
+       //Calibration panel
+       if(infoPanelCalibration == NULL)
+       {
+               infoPanelCalibration = new wxPanel(panelAux, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER , wxString(_T("")));
+               wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);    
+               infoPanelCalibration->SetSizer(flexsizer, true);
+               infoPanelCalibration->SetAutoLayout( true );    
+
+               wxPanel *panel = new interfCalibrationPanel(infoPanelCalibration);
+               wxStaticText* stattext = new wxStaticText(infoPanelCalibration, -1, wxString(_T("              Calibration               ")), wxDefaultPosition,
+                                                                                                 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
+               
+               flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
+               
+               flexsizer->Add(panel, wxEXPAND);
+               infoPanelCalibration->Layout();
+       }
+
+       wxFlexGridSizer* sizer = new wxFlexGridSizer(1);
+       panelAux->SetSizer(sizer, true);
+       panelAux->SetAutoLayout( true );        
+       sizer->Add(infoPanelMask);
+       sizer->Add(infoPanelCalibration);
+       
+       showPanel(panelAux);
+
+//------------------------------------------------------------------
+
+       wxContourMainFrame::getInstance()->changeInstant();
 }
 
 void interfMainPanel::getInstantVector(std::vector<int>& tempVector){
@@ -592,8 +656,8 @@ std::vector<std::string> interfMainPanel::getOutlinesName(int slide){
        return wxContourMainFrame::getInstance()->getOutlinesName(slide);
 }
 
-void interfMainPanel::onInformationContourLabels(int typeContourGroup,int selection,int minZ,int maxZ){
-       wxContourMainFrame::getInstance()->onInformationContourLabels(typeContourGroup, selection, minZ, maxZ);
+void interfMainPanel::onInformationContourLabels(int typeContourGroup,int selection,int minZ,int maxZ,int grayRangeMin,int grayRangeMax){
+       wxContourMainFrame::getInstance()->onInformationContourLabels(typeContourGroup, selection, minZ, maxZ,grayRangeMin,grayRangeMax);
 }
 
 void interfMainPanel::setStringInfoPanel(wxString tmpString){
@@ -624,10 +688,10 @@ void interfMainPanel::setColLableInfoPanel(int tmpIntB,wxString tmpTitleString){
 }
 
 void interfMainPanel::onSaveResults(std::string directory,std::string namefile, std::string filename, 
-                                                                       int typeContourGroup, bool XYZValues, bool contourImage, bool statistics)
+                                                                       int typeContourGroup, int selection, int minZ, int maxZ ,bool XYZValues, bool contourImage, bool statistics)
 {
        wxContourMainFrame::getInstance()->onSaveResults(directory, namefile, filename, 
-               typeContourGroup, XYZValues, contourImage, statistics);
+               typeContourGroup, selection, minZ,maxZ, XYZValues, contourImage, statistics);
 }
 
 wxString interfMainPanel::getCellValue(int j,int i){
@@ -704,55 +768,129 @@ void interfMainPanel::onMirrorChangeWidth(int width)
 }
 
 
-void interfMainPanel::onThreshold()
-{
-       wxContourMainFrame::getInstance()->onThreshold();
-}
 
-void interfMainPanel::onThresholdChange()
+//EED01
+void interfMainPanel::onThresholdPressed()
 {
-       wxContourMainFrame::getInstance()->onThresholdChange();
+       
+       // Threshold view control panel
+       if(thresholdPanel == NULL){
+               thresholdPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
+               wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);    
+               thresholdPanel->SetSizer(flexsizer, true);
+               thresholdPanel->SetAutoLayout( true );  
+               //configPanel->SetEventHandler(this->contourevent);
+               wxPanel *panel = wxContourMainFrame::getInstance()->getThresholdImageViewPanel( thresholdPanel );                               
+               wxStaticText* stattext = new wxStaticText(thresholdPanel, -1, wxString(_T("   Threshold segmentation    ")), wxDefaultPosition,
+                                                                                                 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
+               
+               flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
+               
+               flexsizer->Add(panel, wxEXPAND);
+               thresholdPanel->Layout();
+               
+       }
+       showPanel(thresholdPanel);
+       wxContourMainFrame::getInstance()->changeInstant();
 }
 
-void interfMainPanel::onThresholdInstantChange(double range[])
-{
-       panelThreshold->onThresholdInstantChange(range);
-}
 
-void interfMainPanel::onThresholdInterpolation(bool interpolate)
+void interfMainPanel::ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ)
 {
-       wxContourMainFrame::getInstance()->onThresholdInterpolation(interpolate);
+       wxContourMainFrame::getInstance()->ShowResultImages(typeContourGroup, selection, minZ, maxZ);
 }
 
-void interfMainPanel::onThresholdChangeOpacity (int opacity)
-{
-       wxContourMainFrame::getInstance()->onThresholdChangeOpacity(opacity);
-}
 
-void interfMainPanel::onThresholdRemove()
+void interfMainPanel::SetContourGroup(int contourGroup)
 {
-       wxContourMainFrame::getInstance()->onThresholdRemove();
+       wxContourMainFrame::getInstance()->SetContourGroup( contourGroup);
 }
 
-void interfMainPanel::onThresholdPressed()
+//CMRU 17-08-09 ---------------------------------------------
+void interfMainPanel::onPrintLabel () 
 {
-    if(thresholdPanel==NULL)
+       wxString label;
+       manualBaseModel* manualModel = wxContourMainFrame::getInstance()->getContour();
+
+       if(manualModel==NULL)
        {
+        wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please select a Contour"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
+               dial->ShowModal();
+               return;
+       }
 
-               thresholdPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
-               wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);    
-               thresholdPanel->SetSizer(flexsizer, true);
-               thresholdPanel->SetAutoLayout( true );  
-               panelThreshold = new interfThresholdPanel(thresholdPanel);
+       wxTextEntryDialog* dialog = new wxTextEntryDialog(this,"Enter a tag name: ") ;
        
-               wxStaticText* stattext = new wxStaticText(thresholdPanel, -1, wxString(_T("   Threshold Tool   ")), wxDefaultPosition,
-                       wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
+       if (dialog->ShowModal() == wxID_OK)
+       {
+               label = dialog->GetValue(); 
 
-               flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
-               flexsizer->Add(panelThreshold, wxEXPAND);
-               thresholdPanel->Layout();
+               if(label.Len()!=0)
+               {
+                       wxContourMainFrame::getInstance()->onPrintLabel(label,manualModel);
+                       wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("The tag name was updated"), wxT("Information"), wxOK | wxICON_INFORMATION);
+                       dial->ShowModal();
+               }
+               else
+               {
+                       wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please enter a valid tag"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
+                       dial->ShowModal();
+               }
+       }
+}
+void interfMainPanel::onCalibration(wxString size, int unit)
+{
+       int type = 0;
+       double contourSize = 0.0; 
+       double realSizeDouble = 0.0;
 
-       }       
-       showPanel(thresholdPanel);
+       type = wxContourMainFrame::getInstance()->getType(); 
+       contourSize = wxContourMainFrame::getInstance()->getContourSizeInPixels();
+
+       std::cout<<"Cata->TamaƱo del contorno en pixeles:"<<contourSize<<endl;
+       
+       if ( type == 6 ) 
+       {
+               if (size.ToDouble(&realSizeDouble))
+               {
+                       if(unit==1)
+                       {
+                               realSizeDouble = realSizeDouble * 10;
+                       }
+                       if(unit==2)
+                       {
+                               realSizeDouble = realSizeDouble * 25.4;
+                       }
+                       std::cout<< "Valor del usuario" << realSizeDouble<< endl ; 
+                       onePixelSize (realSizeDouble,contourSize);
+                }
+                else
+                {
+                       wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please enter a numeric value"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
+                       dial->ShowModal();
+                }              
+       }
+       else 
+       {
+       
+               wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please select a line contour"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
+               dial->ShowModal();
+       }
+       
+       wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("The calibration was made"), wxT("Information"), wxOK | wxICON_INFORMATION);
+       dial->ShowModal();
+       std::cout<< "Cata-> Se ha realizado la calibracion" << endl ;
 }
 
+double interfMainPanel::onePixelSize (double realSize,double sizePixel) 
+{
+       _pixelValue = realSize/sizePixel;
+       std::cout<< "Valor del un pixel = " << _pixelValue<< endl ;
+       wxContourMainFrame::getInstance()->onePixelSize (_pixelValue);
+       return _pixelValue ;
+}
+double interfMainPanel::GetPixelValue()
+{
+       return _pixelValue;
+}
+//------------------------------------------------------------------------------------------------------------
\ No newline at end of file