From a6507d91019d9f428af751e5b0b3a7d19d6f0bf6 Mon Sep 17 00:00:00 2001 From: Eduardo Davila Date: Mon, 22 Jun 2009 07:47:40 +0000 Subject: [PATCH] no message --- .../interfMainPanel.cxx | 6 ++ .../interfMainPanel.h | 2 + .../interfToolsPanels.cxx | 25 ++++- .../interfToolsPanels.h | 1 + .../wxContourMainFrame.cxx | 102 +++++++++++++----- .../wxContourMainFrame.h | 9 +- .../wxVtkBaseView_SceneManager.cxx | 3 +- 7 files changed, 114 insertions(+), 34 deletions(-) diff --git a/lib/Interface_Icons_NDimensions/interfMainPanel.cxx b/lib/Interface_Icons_NDimensions/interfMainPanel.cxx index 0cf8b41..1d4bdfc 100644 --- a/lib/Interface_Icons_NDimensions/interfMainPanel.cxx +++ b/lib/Interface_Icons_NDimensions/interfMainPanel.cxx @@ -756,3 +756,9 @@ void interfMainPanel::onThresholdPressed() showPanel(thresholdPanel); } +void interfMainPanel::ShowResultImages(int typeContourGroup) +{ + wxContourMainFrame::getInstance()->ShowResultImages(typeContourGroup); +} + + diff --git a/lib/Interface_Icons_NDimensions/interfMainPanel.h b/lib/Interface_Icons_NDimensions/interfMainPanel.h index 90bd783..6e9f6f3 100644 --- a/lib/Interface_Icons_NDimensions/interfMainPanel.h +++ b/lib/Interface_Icons_NDimensions/interfMainPanel.h @@ -209,6 +209,8 @@ public: virtual bool Show(bool show); + void ShowResultImages(int typeContourGroup); + private: diff --git a/lib/Interface_Icons_NDimensions/interfToolsPanels.cxx b/lib/Interface_Icons_NDimensions/interfToolsPanels.cxx index 40c630d..92d9b0a 100644 --- a/lib/Interface_Icons_NDimensions/interfToolsPanels.cxx +++ b/lib/Interface_Icons_NDimensions/interfToolsPanels.cxx @@ -215,11 +215,16 @@ interfInformationPanel::interfInformationPanel(wxWindow * parent) statisticsContourBtn->SetEventHandler( this ); Connect( statisticsContourBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfInformationPanel::onExtractInformation ); + wxButton *showResultImagesBtn = new wxButton(this,-1,_T("Show result images"),wxDefaultPosition, wxSize(140,35) ); + showResultImagesBtn->SetEventHandler( this ); + Connect( showResultImagesBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfInformationPanel::onShowResultImages ); + + wxButton *saveResultsBtn = new wxButton(this,-1,_T("Save Results"),wxDefaultPosition, wxSize(140,35) ); saveResultsBtn->SetEventHandler( this ); Connect( saveResultsBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfInformationPanel::onSaveResults ); - - + + int sizeZ = interfMainPanel::getInstance()->GetImageDataSizeZ(); //_theViewPanel->getSceneManager()->GetImageDataSizeZ(); _mbarrangeSliceInformation = new mBarRange(this,65,65); @@ -290,6 +295,7 @@ interfInformationPanel::interfInformationPanel(wxWindow * parent) wxFlexGridSizer * sizerB = new wxFlexGridSizer(10); sizerB->Add( informationContourLabelsBtn, 1, wxALL ,2 ); sizerB->Add( statisticsContourBtn, 1, wxALL ,2 ); + sizerB->Add( showResultImagesBtn, 1, wxALL ,2 ); sizerB->Add( saveResultsBtn, 1, wxALL ,2 ); wxFlexGridSizer * sizer = new wxFlexGridSizer(1,8); @@ -316,6 +322,16 @@ void interfInformationPanel::onInformationContourLabels(wxCommandEvent& event){ wxBusyCursor wait; FillGridWithContoursInformation(); } + + +void interfInformationPanel::onShowResultImages(wxCommandEvent& event) +{ + onExtractInformation( event ); + int typeContourGroup = _radiolstboxContourGroup->GetSelection(); + interfMainPanel::getInstance()->ShowResultImages( typeContourGroup ); +} + + void interfInformationPanel::onExtractInformation(wxCommandEvent& event){ wxBusyCursor wait; _grid->ClearGrid(); @@ -325,10 +341,9 @@ void interfInformationPanel::onExtractInformation(wxCommandEvent& event){ int minZ = _mbarrangeSliceInformation->GetStart(); int maxZ = _mbarrangeSliceInformation->GetEnd(); - interfMainPanel::getInstance()->onInformationContourLabels(typeContourGroup, selection, minZ, maxZ); - - + interfMainPanel::getInstance()->onInformationContourLabels(typeContourGroup, selection, minZ, maxZ); } + void interfInformationPanel::onSaveResults(wxCommandEvent& event) { wxFileDialog dialog(this, _T("Choose a filename"), _T(""), _T(""), wxFileSelectorDefaultWildcardStr, wxSAVE ); diff --git a/lib/Interface_Icons_NDimensions/interfToolsPanels.h b/lib/Interface_Icons_NDimensions/interfToolsPanels.h index 396579b..fb21b95 100644 --- a/lib/Interface_Icons_NDimensions/interfToolsPanels.h +++ b/lib/Interface_Icons_NDimensions/interfToolsPanels.h @@ -81,6 +81,7 @@ private: void onInformationContourLabels(wxCommandEvent& event); void onExtractInformation(wxCommandEvent& event); + void onShowResultImages(wxCommandEvent& event); void onSaveResults(wxCommandEvent& event); void FillGridWithContoursInformation(); diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx index 89f6c39..b6d2133 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx +++ b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx @@ -62,7 +62,8 @@ char wxContourMainFrame::COPY = 'C'; // m_notebook_style =wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_EXTERNAL_MOVE | wxNO_BORDER; // m_notebook_theme = 0; //wxContour_ActionCommandsID a; - + + _contourextractdata = NULL; } wxContourMainFrame :: wxContourMainFrame(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector images, long style,std::string datadir) @@ -101,7 +102,8 @@ char wxContourMainFrame::COPY = 'C'; { this->setVectImages(images); } - + + _contourextractdata = NULL; } void wxContourMainFrame::setVectImages(std::vector imgs) @@ -169,6 +171,7 @@ void wxContourMainFrame::setVectImages(std::vector imgs) wxContourMainFrame :: ~wxContourMainFrame() { + delete _contourextractdata; deleteAllContours(); _pannew->Close(); interfMainPanel::resetInstance(); @@ -578,13 +581,50 @@ void wxContourMainFrame::setConceptValue( std::string name, int value ){ _instantPanel->setConceptValue(name, value); } + ConceptDataWrap* wxContourMainFrame::getLastConceptData(){ return _instantPanel->getLastConceptData(); } + + bool wxContourMainFrame::getIfConceptCheckedAt( std::string name, int pos ){ return _instantPanel->getIfConceptCheckedAt( name, pos ); } + + +void wxContourMainFrame::ShowResultImages(int typeContourGroup) +{ + vtkImageData * mask; + vtkImageData * value; + this->getMaskValue(&mask, &value, typeContourGroup); + + std::vector nTypeView; + nTypeView.push_back(5); + nTypeView.push_back(1); + 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); + + 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)); + + 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(); +} + + + + void wxContourMainFrame::changeInstant() { std::vector instantVect; @@ -604,6 +644,7 @@ void wxContourMainFrame::changeInstant() } + void wxContourMainFrame :: updateInstantOutlines() { _theViewPanel->removeSceneContours(); @@ -2329,13 +2370,21 @@ std::vector wxContourMainFrame::getOutlinesName(int slide){ return kernelManager->getOutlinesNameAtInstant(tempVector); } + +void wxContourMainFrame::GenerateContourExtractData() +{ + if (_contourextractdata==NULL) { _contourextractdata = new ContourExtractData(true); } +} + + void wxContourMainFrame::onInformationContourLabels(int typeContourGroup,int selection,int minimumZ,int maximumZ) { + GenerateContourExtractData(); + int maxContourGroup = 0; - ContourExtractData *contourextractdata = new ContourExtractData(); - contourextractdata ->SetTypeOperation( typeContourGroup % 3 ); + _contourextractdata ->SetTypeOperation( typeContourGroup % 3 ); std::vector lstManConMod; std::vector lstManConModTmp; @@ -2389,7 +2438,7 @@ void wxContourMainFrame::onInformationContourLabels(int typeContourGroup,int sel totalZ = maxZ-minZ+1; - contourextractdata->SetImage( imagedata); + _contourextractdata->SetImage( imagedata); // For each slice.. for ( z=minZ ; z<=maxZ ; z++ ) @@ -2402,7 +2451,7 @@ void wxContourMainFrame::onInformationContourLabels(int typeContourGroup,int sel //_staticTextInformation->SetLabel(tmpString); //Extraction data from contours of each slice - contourextractdata->SetZtoBeAnalys(z); + _contourextractdata->SetZtoBeAnalys(z); tempVector[1]=z; Instant instant(&tempVector); @@ -2449,18 +2498,18 @@ void wxContourMainFrame::onInformationContourLabels(int typeContourGroup,int sel lstManConModTmp = lstManConModExp; } - contourextractdata->SetLstManualContourModel( lstManConModTmp ); + _contourextractdata->SetLstManualContourModel( lstManConModTmp ); pLstValue.clear(); pLstValuePosX.clear(); pLstValuePosY.clear(); pLstValuePosZ.clear(); - contourextractdata->GetValuesInsideCrown( &pLstValue, + _contourextractdata->GetValuesInsideCrown( &pLstValue, &pLstValuePosX, &pLstValuePosY, &pLstValuePosZ); // Statistics of each slice. - contourextractdata->Statistics( &pLstValue, + _contourextractdata->Statistics( &pLstValue, minimumZ, maximumZ, &resultGrayRangeCount, @@ -2518,7 +2567,6 @@ void wxContourMainFrame::onInformationContourLabels(int typeContourGroup,int sel } interfMainPanel::getInstance()->setStringInfoPanel( _T("") ); - delete contourextractdata; } //AD: 29-05-09 @@ -2580,9 +2628,10 @@ void wxContourMainFrame::onSaveResults(std::string directory,std::string namefil void wxContourMainFrame::SaveValuesXYZ(std::string directory,std::string namefile,int typeContourGroup) { wxBusyCursor wait; - ContourExtractData *contourextractdata = new ContourExtractData(); + GenerateContourExtractData(); + //int typeContourGroup = this->_radiolstboxContourGroup->GetSelection(); - contourextractdata ->SetTypeOperation( typeContourGroup % 3 ); + _contourextractdata ->SetTypeOperation( typeContourGroup % 3 ); std::vector lstManConMod; std::vector lstManConModTmp; @@ -2609,7 +2658,7 @@ void wxContourMainFrame::SaveValuesXYZ(std::string directory,std::string namefil maxZ = sizeZ;//_mbarrange->GetEnd(); totalZ = maxZ-minZ+1; - contourextractdata->SetImage( imagedata); + _contourextractdata->SetImage( imagedata); // For each slice.. for ( z=0 ; zSetZtoBeAnalys( z); + _contourextractdata->SetZtoBeAnalys( z); tempVector[1]=z; Instant instant(&tempVector); @@ -2659,13 +2708,13 @@ void wxContourMainFrame::SaveValuesXYZ(std::string directory,std::string namefil lstManConModTmp = lstManConModExp; } - contourextractdata->SetLstManualContourModel( lstManConModTmp ); + _contourextractdata->SetLstManualContourModel( lstManConModTmp ); pLstValue.clear(); pLstValuePosX.clear(); pLstValuePosY.clear(); pLstValuePosZ.clear(); - contourextractdata->GetValuesInsideCrown( &pLstValue, + _contourextractdata->GetValuesInsideCrown( &pLstValue, &pLstValuePosX, &pLstValuePosY, &pLstValuePosZ); @@ -2700,18 +2749,19 @@ void wxContourMainFrame::SaveValuesXYZ(std::string directory,std::string namefil } // for z interfMainPanel::getInstance()->setStringInfoPanel(_T("")); //_staticTextInformation->SetLabel( _T("") ); - delete contourextractdata; + } void wxContourMainFrame::getMaskValue(vtkImageData ** mask,vtkImageData ** value,int typeContourGroup){ wxBusyCursor wait; - ContourExtractData *contourextractdata = new ContourExtractData( true ); + GenerateContourExtractData(); + //int typeContourGroup = this->_radiolstboxContourGroup->GetSelection(); if (typeContourGroup==3) { typeContourGroup=1; } - contourextractdata ->SetTypeOperation( typeContourGroup % 3 ); + _contourextractdata ->SetTypeOperation( typeContourGroup % 3 ); std::vector lstManConMod; std::vector lstManConModTmp; @@ -2736,7 +2786,7 @@ void wxContourMainFrame::getMaskValue(vtkImageData ** mask,vtkImageData ** value maxZ = sizeZ;//_mbarrange->GetEnd(); totalZ = maxZ-minZ+1; - contourextractdata->SetImage( imagedata); + _contourextractdata->SetImage( imagedata); // For each slice.. for ( z=0 ; zsetStringInfoPanel(tmpString); //Extraction data from contours of each slice - contourextractdata->SetZtoBeAnalys( z); + _contourextractdata->SetZtoBeAnalys( z); tempVector[1]=z; Instant instant(&tempVector); @@ -2781,15 +2831,15 @@ void wxContourMainFrame::getMaskValue(vtkImageData ** mask,vtkImageData ** value lstManConModTmp = lstManConModExp; } - contourextractdata->SetLstManualContourModel( lstManConModTmp ); - contourextractdata->CalculateImageResult(); // with actual Z + _contourextractdata->SetLstManualContourModel( lstManConModTmp ); + _contourextractdata->CalculateImageResult(); // with actual Z } // for iContourGroup } // for z - (*value) = contourextractdata->GetVtkImageValueResult(); - (*mask) = contourextractdata->GetVtkImageMaskResult(); - delete contourextractdata; + (*value) = _contourextractdata->GetVtkImageValueResult(); + (*mask) = _contourextractdata->GetVtkImageMaskResult(); + } void wxContourMainFrame::SaveImageResult(std::string directory,std::string namefile, vtkImageData* mask,vtkImageData* value) diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h index a217f4a..f686c62 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h +++ b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h @@ -308,6 +308,10 @@ class wxContourMainFrame : public wxPanel { void onSnakePressed(); void saveFileWithContoursAutomatique(); + + void ShowResultImages(int typeContourGroup); + + private: //------------------------------------------------------------------------------------------------------------ // Private methods @@ -391,9 +395,10 @@ private: //manualContourModel * factoryManualContourModel(int typeContour); manualContourModel * factoryManualContourModel(wxPanel* panel); + + ContourExtractData *_contourextractdata; - - + void GenerateContourExtractData(); void saveState(); void loadState(std::string filename); void loadContours( FILE *pFile, bool staticContour ); diff --git a/lib/Interface_ManagerContour_NDimensions/wxVtkBaseView_SceneManager.cxx b/lib/Interface_ManagerContour_NDimensions/wxVtkBaseView_SceneManager.cxx index 9e6a605..fccc036 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxVtkBaseView_SceneManager.cxx +++ b/lib/Interface_ManagerContour_NDimensions/wxVtkBaseView_SceneManager.cxx @@ -146,6 +146,7 @@ DEFINE_EVENT_TYPE( wxEVT_CHANGED_DEEP ) { manContourControl = new manualContourControler(); manViewerContour = new manualViewContour(); + manModelContour->SetCloseContour(false); } if (typeContour==2) @@ -186,7 +187,7 @@ DEFINE_EVENT_TYPE( wxEVT_CHANGED_DEEP ) //Configuring the relations between the contour members representation manViewerContour->SetModel( manModelContour ); manViewerContour->SetWxVtkBaseView( _wxVtk_BaseView ); - manViewerContour->SetRange( 2 ); + manViewerContour->SetRange( 0.5 ); manViewerContour->SetZ( 1000 ); manViewerContour->SetSpacing(spc); -- 2.47.1