From: Ricardo Corredor Date: Tue, 13 Oct 2009 02:37:21 +0000 (+0000) Subject: Changes with manualBaseModel. It improves the functionality with the new X-Git-Tag: CREATOOLS.2-0-3~44 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=dfdd7c80dbd20fea642090201b64eb7119a144bf;p=creaContours.git Changes with manualBaseModel. It improves the functionality with the new points contour and some saving and loading aspects of the contours --- diff --git a/data/Icons/Letter.PNG b/data/Icons/Letter.PNG new file mode 100644 index 0000000..791d0b7 Binary files /dev/null and b/data/Icons/Letter.PNG differ diff --git a/data/Icons/Points.png b/data/Icons/Points.png new file mode 100644 index 0000000..4f7e241 Binary files /dev/null and b/data/Icons/Points.png differ diff --git a/lib/Interface_Icons_NDimensions/interfEditMenu.cxx b/lib/Interface_Icons_NDimensions/interfEditMenu.cxx index 8780412..2aea262 100644 --- a/lib/Interface_Icons_NDimensions/interfEditMenu.cxx +++ b/lib/Interface_Icons_NDimensions/interfEditMenu.cxx @@ -30,6 +30,12 @@ void interfEditMenu::initButtons(wxEvtHandler* evtHandler) { nom.push_back("Redo ctrl + y"); funct.push_back((wxObjectEventFunction) &interfEditMenu:: onRedo); +//CMRU 17-08-09 ------------------------------------------------------------------ + path.push_back(datadir + "/Letter.PNG"); + nom.push_back("Insert a Label"); + funct.push_back((wxObjectEventFunction)&interfEditMenu::onPrintLabel); +//------------------------------------------------------------------------------- + this->addButtons(path, nom); this->setVectorFunction(funct); @@ -54,6 +60,9 @@ void interfEditMenu::onUndo(wxCommandEvent& event){ void interfEditMenu::onRedo(wxCommandEvent& event){ interfMainPanel::getInstance()->onRedo(); } +void interfEditMenu::onPrintLabel(wxCommandEvent& event){ + interfMainPanel::getInstance()->onPrintLabel(); +} interfEditMenu::~interfEditMenu() { diff --git a/lib/Interface_Icons_NDimensions/interfEditMenu.h b/lib/Interface_Icons_NDimensions/interfEditMenu.h index 17582f0..58100b5 100644 --- a/lib/Interface_Icons_NDimensions/interfEditMenu.h +++ b/lib/Interface_Icons_NDimensions/interfEditMenu.h @@ -19,6 +19,7 @@ public: void onPaste(wxCommandEvent& event); void onUndo(wxCommandEvent& event); void onRedo(wxCommandEvent& event); + void onPrintLabel(wxCommandEvent& event); }; diff --git a/lib/Interface_Icons_NDimensions/interfMainPanel.cxx b/lib/Interface_Icons_NDimensions/interfMainPanel.cxx index 40456bf..b5da629 100644 --- a/lib/Interface_Icons_NDimensions/interfMainPanel.cxx +++ b/lib/Interface_Icons_NDimensions/interfMainPanel.cxx @@ -35,7 +35,11 @@ interfMainPanel::interfMainPanel(wxWindow * parent, int sizex, int sizey, wxEvtH 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 ); @@ -106,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); @@ -349,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); @@ -455,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(""))); @@ -578,11 +589,18 @@ 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(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T(""))); + infoPanelMask = new wxPanel(panelAux, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T(""))); wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1); infoPanelMask->SetSizer(flexsizer, true); infoPanelMask->SetAutoLayout( true ); @@ -597,7 +615,36 @@ void interfMainPanel::onInformationPressed(){ infoPanelMask->Layout(); } - showPanel(infoPanelMask); + +//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(); } @@ -758,3 +805,92 @@ void interfMainPanel::SetContourGroup(int contourGroup) { wxContourMainFrame::getInstance()->SetContourGroup( contourGroup); } + +//CMRU 17-08-09 --------------------------------------------- +void interfMainPanel::onPrintLabel () +{ + 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; + } + + wxTextEntryDialog* dialog = new wxTextEntryDialog(this,"Enter a tag name: ") ; + + if (dialog->ShowModal() == wxID_OK) + { + label = dialog->GetValue(); + + 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; + + type = wxContourMainFrame::getInstance()->getType(); + contourSize = wxContourMainFrame::getInstance()->getContourSizeInPixels(); + + std::cout<<"Cata->TamaƱo del contorno en pixeles:"<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 diff --git a/lib/Interface_Icons_NDimensions/interfMainPanel.h b/lib/Interface_Icons_NDimensions/interfMainPanel.h index 9c3868d..460fbf2 100644 --- a/lib/Interface_Icons_NDimensions/interfMainPanel.h +++ b/lib/Interface_Icons_NDimensions/interfMainPanel.h @@ -95,6 +95,11 @@ public: void onCreateContourRectangle( ); void onCreateContourCircle( ); void onCreateContourLine( ); + + // RaC 09-09 --------------------- + void onCreateContourPoints( ); + // RaC 09-09 --------------------- + void onCreateContoursBullEye(wxPanel* panBull); ///////////////////////////////// void onDeleteContour(); @@ -157,6 +162,34 @@ public: void ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ); void SetContourGroup(int contourGroup); +//CMRU 29-08-09----------------------------------------------------------------------------------------------- + + /** + * Associates the current selected contour with a label + */ + void onPrintLabel(); + + + /** + * Calculates the pixel value in milimeters according to the current contour if the selected contour is a Line Contour + * @param size Size in milimeters of the selected contour + * @param unit Measurement unit + */ + void onCalibration(wxString size, int unit); + + /** + * Calculate the pixel value in milimeters + * @param realSize Size of the contour in milimeters + * @param sizePixel Size of the contour in pixels + */ + double onePixelSize (double realSize,double sizePixel); + + /** + * Returns the value of a pixel in milimeters + */ + double GetPixelValue(); +//------------------------------------------------------------------------------------------------------------ + private: @@ -177,6 +210,24 @@ private: wxPanel* infoPanel; wxPanel* infoPanelMask; +//CMRU 17-08-09 ------------------------------------------------------------------ + + /** + * Panel with the calibration options + */ + wxPanel* infoPanelCalibration; + + /** + * Panel who contains the calibration panel and the information panel mask + */ + wxPanel* panelAux; + + /** + * Value of a pixel in milimeters + */ + double _pixelValue; +//-------------------------------------------------------------------------------- + wxStaticText* statictext; wxStaticText* statictext1; wxStaticText* statictext2; diff --git a/lib/Interface_Icons_NDimensions/interfNewContourMenu.cxx b/lib/Interface_Icons_NDimensions/interfNewContourMenu.cxx index 42d97ba..35cb02b 100644 --- a/lib/Interface_Icons_NDimensions/interfNewContourMenu.cxx +++ b/lib/Interface_Icons_NDimensions/interfNewContourMenu.cxx @@ -43,12 +43,14 @@ void interfNewContourMenu::initButtons(wxEvtHandler* evtHandler) { nom.push_back("Create a Line"); funct.push_back((wxObjectEventFunction) &interfNewContourMenu::onCreateContourLine); hand.push_back(this); -/* - path.push_back(datadir + "/Line.png"); + + // RaC 09-09 --------------------- + path.push_back(datadir + "/Points.png"); nom.push_back("Create Points"); funct.push_back((wxObjectEventFunction) &interfNewContourMenu::onCreateContourPoints); hand.push_back(this); -*/ + // RaC 09-09 --------------------- + this->addButtons(path, nom); this->setVectorFunction(funct); @@ -90,9 +92,10 @@ void interfNewContourMenu::onCreateContourCircle( wxCommandEvent& event ){ void interfNewContourMenu::onCreateContourLine( wxCommandEvent& event ){ interfMainPanel::getInstance()->onCreateContourLine(); } -/* + +// RaC 09-09 --------------------- void interfNewContourMenu::onCreateContourPoints( wxCommandEvent& event ){ - interfMainPanel::getInstance()->onCreateContourLine(); + interfMainPanel::getInstance()->onCreateContourPoints(); } -*/ +// RaC 09-09 --------------------- diff --git a/lib/Interface_Icons_NDimensions/interfNewContourMenu.h b/lib/Interface_Icons_NDimensions/interfNewContourMenu.h index 21c1b5a..3584d95 100644 --- a/lib/Interface_Icons_NDimensions/interfNewContourMenu.h +++ b/lib/Interface_Icons_NDimensions/interfNewContourMenu.h @@ -46,7 +46,10 @@ private: **/ void onCreateContourLine( wxCommandEvent& event ); - //void onCreateContourPoints( wxCommandEvent& event ); + /** + ** This method is in charge of capturing the event when the button is clicked + **/ + void onCreateContourPoints( wxCommandEvent& event ); }; diff --git a/lib/Interface_Icons_NDimensions/interfToolsPanels.cxx b/lib/Interface_Icons_NDimensions/interfToolsPanels.cxx index a93ae0a..c4a05d0 100644 --- a/lib/Interface_Icons_NDimensions/interfToolsPanels.cxx +++ b/lib/Interface_Icons_NDimensions/interfToolsPanels.cxx @@ -455,3 +455,44 @@ void interfInformationPanel::onContourGroup(wxCommandEvent& event) interfMainPanel::getInstance()->SetContourGroup( _radiolstboxContourGroup->GetSelection() ); } +//CMRU 29-08-09----------------------------------------------------------------------------------------------- +interfCalibrationPanel:: interfCalibrationPanel(wxWindow * parent) +: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN) +{ + double range[2]; + interfMainPanel::getInstance()->getImageRange(range); + + //Radio buttons + wxString options[3]; + options[0]=_T("mm"); + options[1]=_T("cm"); + options[2]=_T("inch"); + + _unitsRadiobox = new wxRadioBox(this, -1, _T("Unit of measurement"), wxPoint(2, 25), wxSize(145,45), 3 , options, 3, wxRA_SPECIFY_COLS); + _unitsRadiobox->SetSelection(0); + + //The label + new wxStaticText(this, wxID_ANY, wxT("Real Size: "), wxPoint(2, 5)); + + //Text Control + _size = new wxTextCtrl(this, wxID_ANY, wxT(""), wxPoint(78,3), wxSize(70, 20), 0, wxDefaultValidator, wxTextCtrlNameStr); + + //The button + new wxButton(this, 1, wxT("Calibrate"), wxPoint(78, 70), wxSize(70, 25), 0, wxDefaultValidator, wxT("button")); + + //Conexion del boton con su respectivo manejador + Connect(1, wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction) &interfCalibrationPanel::onCalibrate); + +} + +interfCalibrationPanel:: ~interfCalibrationPanel() +{ +} + +void interfCalibrationPanel::onCalibrate(wxCommandEvent& event) +{ + wxString size =_size->GetValue(); + int unit = _unitsRadiobox->GetSelection(); + interfMainPanel::getInstance()->onCalibration(size, unit); +} +//------------------------------------------------------------------------------------------------------------ \ No newline at end of file diff --git a/lib/Interface_Icons_NDimensions/interfToolsPanels.h b/lib/Interface_Icons_NDimensions/interfToolsPanels.h index 093349e..e0784f2 100644 --- a/lib/Interface_Icons_NDimensions/interfToolsPanels.h +++ b/lib/Interface_Icons_NDimensions/interfToolsPanels.h @@ -92,7 +92,41 @@ private: }; +//CMRU 29-08-09----------------------------------------------------------------------------------------------- +/** +* This class represents the calibration panel in the interface icons +*/ +class interfCalibrationPanel + : public wxPanel +{ +public: + + /** + * Initialized the panel + * @param parent Window who contains the panel + */ + interfCalibrationPanel(wxWindow * parent); + + ~interfCalibrationPanel(); + /** + * Manages the event associated with the button of calibration + */ + void onCalibrate(wxCommandEvent& event); + +private: + + /** + * Text field of the calibration measure + */ + wxTextCtrl * _size; + + /** + * Radio Box with the measurement units + */ + wxRadioBox * _unitsRadiobox; +}; +//------------------------------------------------------------------------------------------------------------ #endif diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx index 5596ea4..41a3804 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx +++ b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx @@ -15,7 +15,8 @@ #include "ConceptDataWrap.h" #include - +#include +using namespace std; //---------------------------------------------------------------------------------------------------------------- // Class implementation @@ -336,12 +337,21 @@ void wxContourMainFrame::onCreateContourLine( ){ createContour( 6 ); } +// RaC 09-09 -------------------------------------- +void wxContourMainFrame::onCreateContourPoints( ){ + //JCP 20-10-08 Undo redo implementation + saveState(); + //JCP 20-10-08 Undo redo implementation + createContour( 7 ); +} +// RaC 09-09 -------------------------------------- + //------------------------------------------------------------------------------------------------------------ void wxContourMainFrame :: onCreateContourBullEye(wxPanel* panel ) { - //Creating the manualContourModel and including in the model - manualContourModel * manModelContour = factoryManualContourModel(panel ); + //Creating the manualBaseModel and including in the model + manualBaseModel * manModelContour = factoryManualContourModel(panel ); std::vector instantVector; _instantPanel->getInstant( instantVector ); @@ -366,8 +376,7 @@ void wxContourMainFrame :: onCreateContourBullEye(wxPanel* panel ) void wxContourMainFrame :: createContour( int typeContour ) { //Creating the manualContourModel and including in the model - manualContourModel * manModelContour = kernelManager->factoryManualContourModel(typeContour); - + manualBaseModel * manModelContour = kernelManager->factoryManualContourModel(typeContour); std::vector instantVector; _instantPanel->getInstant( instantVector ); @@ -389,10 +398,10 @@ void wxContourMainFrame :: createContour( int typeContour ) } } -manualContourModel * wxContourMainFrame::factoryManualContourModel(wxPanel* panel){ +manualBaseModel * wxContourMainFrame::factoryManualContourModel(wxPanel* panel){ manualContourModelBullEye *manModelContourBullEye = new manualContourModelBullEye(); - manualContourModel *manModelContour=NULL; + manualBaseModel *manModelContour=NULL; manModelContour = manModelContourBullEye; if (panel!=NULL){ int iCrown,sizeCrowns,iSector,sizeSectors; @@ -753,7 +762,7 @@ void wxContourMainFrame::onRedo(){ void wxContourMainFrame :: createCopyContourOf ( std::string anExistingKName, std::vector &instantNoTouchData, bool append ) { std::string cloneName = kernelManager->createCopyContourOf( anExistingKName, instantNoTouchData ); - manualContourModel * manualModel = kernelManager->getOutlineByKeyName(cloneName);//_modelManager->getOutlineByKeyName( cloneName )->getModel(); + manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(cloneName);//_modelManager->getOutlineByKeyName( cloneName )->getModel(); _theViewPanel->getSceneManager()->createCopyContourOf( anExistingKName, cloneName, manualModel , append ); } @@ -761,7 +770,7 @@ void wxContourMainFrame :: createCopyContourOf ( std::string anExistingKName, st void wxContourMainFrame :: createMirrorContourOf ( std::string anExistingKName, std::vector &instantNoTouchData, bool append ) { std::string cloneName = kernelManager->createCopyContourOf( anExistingKName, instantNoTouchData ); - manualContourModel * manualModel = kernelManager->getOutlineByKeyName(cloneName); + manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(cloneName); manualPoint * refPoint1 = _refLineModel->GetManualPoint(0); manualPoint * refPoint2 = _refLineModel->GetManualPoint(1); @@ -840,7 +849,7 @@ void wxContourMainFrame ::loadContours( FILE *pFile, bool staticContour ) std::vector instantVector; int typeContourModel; - manualContourModel *manModelContour; + manualBaseModel *manModelContour; int typeView; int i; @@ -896,11 +905,41 @@ void wxContourMainFrame ::loadContours( FILE *pFile, bool staticContour ) void wxContourMainFrame::onLoad() { char tmp[255]; - wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxOPEN ); - if (dialog.ShowModal() == wxID_OK) + char tmpD[255]; + std::string fileNameContourROI = GetFileLocation(); + +//CMRU 03-09-09----------------------------------------------------------------------------------------------- + if(GetFileLocation().empty()) + { +//------------------------------------------------------------------------------------------------------------ + wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxOPEN ); + if (dialog.ShowModal() == wxID_OK) + { + fileNameContourROI = (const char *)(dialog.GetPath().mb_str()); + } + } + + FILE *pFile =fopen(fileNameContourROI.c_str(),"r+"); + + +//CMRU 03-09-09- ---------------------------------------------------------------------------------------------- + if(pFile != NULL) { - std::string fileNameContourROI = (const char *)(dialog.GetPath().mb_str()); - FILE *pFile=fopen(fileNameContourROI.c_str(),"r+"); +//------------------------------------------------------------------------------------------------------------ + fileNameContourROI.append("data"); + FILE *pFileData=fopen(fileNameContourROI.c_str(),"r+"); + if(pFileData != NULL) + { + fscanf(pFileData,"%s",tmpD); // --CreaContour-- + fscanf(pFileData,"%s",tmpD); // Version + fscanf(pFileData,"%s",tmpD); // 1.0.2 || 1.0.1 || 1.0.0 + + fscanf(pFileData,"%s",tmpD); // onePixelSize + fscanf(pFileData,"%s",tmpD); // # + _onePixelSize = atof(tmpD); + fscanf(pFileData,"%s",tmpD); // NumberOfContours + fscanf(pFileData,"%s",tmpD); // # + } fscanf(pFile,"%s",tmp); // --CreaContour-- @@ -911,24 +950,29 @@ void wxContourMainFrame::onLoad() //AD:02-06-09 if (version=="1.0.2") { - openContours(pFile,2,false); - openContours(pFile,2,true); //Load StaticContours + openContours(pFile,pFileData,2,false); + openContours(pFile,pFileData,2,true); //Load StaticContours } //AD:02-06-09 else if (version=="1.0.1") { - openContours(pFile,1,false); //Skips ImageDimensions and ImageSpacing - openContours(pFile,1,true); //Load StaticContours, skips ImageDimensions and ImageSpacing + openContours(pFile,pFileData,1,false); //Skips ImageDimensions and ImageSpacing + openContours(pFile,pFileData,1,true); //Load StaticContours, skips ImageDimensions and ImageSpacing } //AD:02-06-09 else if (version=="1.0.0") { - openContours(pFile,1,false); //Skips ImageDimensions and ImageSpacing + openContours(pFile,pFileData,1,false); //Skips ImageDimensions and ImageSpacing } fclose(pFile); + + if(pFileData != NULL) + { + fclose(pFileData); + } } _theViewPanel->getSceneManager()->removeSceneContours(); changeInstant(); @@ -936,13 +980,28 @@ void wxContourMainFrame::onLoad() //AD: 29-05-09 void wxContourMainFrame::onSave(){ - wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxSAVE ); - if (dialog.ShowModal() == wxID_OK) +//CMRU 03-09-09----------------------------------------------------------------------------------------------- + if(GetFileLocation().empty()) { - std::string fileNameContourROI = (const char *)(dialog.GetPath().mb_str()); +//------------------------------------------------------------------------------------------------------------ + wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxSAVE ); + if (dialog.ShowModal() == wxID_OK) + { + std::string fileNameContourROI = (const char *)(dialog.GetPath().mb_str()); + kernelManager->setCurrentFileName(fileNameContourROI); + saveFileWithContours( fileNameContourROI ); + } + } +//CMRU 03-09-09----------------------------------------------------------------------------------------------- + else + { + std::cout<<"Nombre del archivo: "<setCurrentFileName(fileNameContourROI); - saveFileWithContours( fileNameContourROI ); + saveFileWithContours( fileNameContourROI); } +//------------------------------------------------------------------------------------------------------------ } //AD: 29-05-09 @@ -950,11 +1009,26 @@ void wxContourMainFrame::saveFileWithContours( std::string filename ) { FILE *pFile=fopen(filename.c_str(),"w+"); + +//CMRU 03-09-09----------------------------------------------------------------------------------------------- + filename.append("data"); + std::cout<<"Nombre del archivo: "< lstNameThings; int i,sizeLstNameThings; fprintf(pFile,"--CreaContour--\n"); fprintf(pFile,"Version %s\n", "1.0.2" ); + +//CMRU 03-09-09----------------------------------------------------------------------------------------------- + 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<SaveThingName( pFile, lstNameThings[i] ); +//CMRU 03-09-09----------------------------------------------------------------------------------------------- + manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(lstNameThings[i]); + double sizeInPixel = manualModel ->GetPathSize(); + double realContourSize = sizeInPixel*_onePixelSize; + manualModel ->SetRealSize(realContourSize); +//------------------------------------------------------------------------------------------------------------ + + //int size= kernelManager->GetLstNameThings().size(); + + kernelManager->SaveThingName( pFile, pFileData, lstNameThings[i] ); _theViewPanel->getSceneManager()->SaveThingName( pFile, lstNameThings[i] ); }// for i @@ -989,16 +1076,22 @@ void wxContourMainFrame::saveFileWithContours( std::string filename ) lstNameThings = kernelManager->GetLstNameThingsStatic(); sizeLstNameThings = lstNameThings.size(); fprintf(pFile,"NumberOfContoursStatic %d\n", sizeLstNameThings ); + +//CMRU 03-09-09----------------------------------------------------------------------------------------------- + fprintf(pFileData,"NumberOfContoursStatic %d\n", sizeLstNameThings ); +//------------------------------------------------------------------------------------------------------------ + for (i=0 ; iSaveThingName( pFile, lstNameThings[i] ); + kernelManager->SaveThingName( pFile, pFileData, lstNameThings[i] ); _theViewPanel->getSceneManager()->SaveThingName( pFile, lstNameThings[i] ); }// for i fclose(pFile); + fclose(pFileData); } //AD:04-06-09 -void wxContourMainFrame::openContours( FILE *pFile, int version, bool staticContour ) +void wxContourMainFrame::openContours( FILE *pFile, FILE *pFileData, int version, bool staticContour ) { char tmp[255]; @@ -1045,7 +1138,7 @@ void wxContourMainFrame::openContours( FILE *pFile, int version, bool staticCont std::vector instantVector; int typeContourModel; - manualContourModel *manModelContour; + manualBaseModel *manModelContour; int typeView; if (compatible==true) @@ -1076,6 +1169,10 @@ void wxContourMainFrame::openContours( FILE *pFile, int version, bool staticCont manModelContour = kernelManager->factoryManualContourModel(typeContourModel); manModelContour->Open(pFile); + if(pFileData != NULL) + { + manModelContour->OpenData(pFileData); + } fscanf(pFile,"%s",tmp); // TypeView fscanf(pFile,"%s",tmp); // ## @@ -1158,7 +1255,10 @@ void wxContourMainFrame::openContours( FILE *pFile, int version, bool staticCont manModelContour = kernelManager->factoryManualContourModel(typeContourModel); manModelContour->Open(pFile); - + if(pFileData != NULL) + { + manModelContour->OpenData(pFileData); + } if (transform==true) { if (typeOfTransformation==0) @@ -1579,7 +1679,7 @@ void wxContourMainFrame::SegmentationOneSliceITK(int x, int y, int z, wxString d int j,sizeCtrPt = vecCtrlPointX.size(); - manualContourModel *manModelContour = kernelManager->factoryManualContourModel( typeofcontour ); + manualBaseModel *manModelContour = kernelManager->factoryManualContourModel( typeofcontour ); manModelContour->SetNumberOfPointsSpline( ((sizeCtrPt/100)+1)*100 ); if (sizeCtrPt>=3){ for (j=0 ; jfactoryManualContourModel( typeofcontour ); + manualBaseModel *manModelContour = kernelManager->factoryManualContourModel( typeofcontour ); manModelContour->SetNumberOfPointsSpline( ((sizeCtrPt/100)+1)*100 ); if (sizeCtrPt>=3){ for (j=0 ; jGetPoints(z, type, &vecCtrlPointX,&vecCtrlPointY,&vecCtrlPointZ, theName,typeofcontour, tempVector); + manualBaseModel* manModelContour = kernelManager->GetPoints(z, type, &vecCtrlPointX,&vecCtrlPointY,&vecCtrlPointZ, theName,typeofcontour, tempVector); if( manModelContour!=NULL ){ double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default @@ -2206,9 +2306,9 @@ void wxContourMainFrame::onInformationContourLabels(int typeContourGroup,int sel _contourextractdata ->SetTypeOperation( typeContourGroup % 3 ); - std::vector lstManConMod; - std::vector lstManConModTmp; - std::vector lstManConModExp; + std::vector lstManConMod; + std::vector lstManConModTmp; + std::vector lstManConModExp; std::vector pLstValue; std::vector pLstValuePosX; std::vector pLstValuePosY; @@ -2276,8 +2376,8 @@ void wxContourMainFrame::onInformationContourLabels(int typeContourGroup,int sel ContourThing **contourthing = lstContourThings[ii]; lstManConMod.push_back( (*contourthing)->getModel() ); } - lstManConModExp = kernelManager->ExploseEachModel( lstManConMod ); + lstManConModExp = kernelManager->ExploseEachModel( lstManConMod ); tempString.Printf(_T("%d - %d"),z, sizeLstContourThings); interfMainPanel::getInstance()->setRowLabelInfoPanel(z, tempString); @@ -2298,10 +2398,11 @@ void wxContourMainFrame::onInformationContourLabels(int typeContourGroup,int sel int tmpIntA; - - for( iContourGroup=0 ; iContourGroupStatistics( &pLstValue, grayRangeMin, @@ -2508,9 +2610,9 @@ void wxContourMainFrame::SaveValuesXYZ(std::string directory,std::string namefil //int typeContourGroup = this->_radiolstboxContourGroup->GetSelection(); _contourextractdata ->SetTypeOperation( typeContourGroup % 3 ); - std::vector lstManConMod; - std::vector lstManConModTmp; - std::vector lstManConModExp; + std::vector lstManConMod; + std::vector lstManConModTmp; + std::vector lstManConModExp; std::vector pLstValue; std::vector pLstValuePosX; std::vector pLstValuePosY; @@ -2638,9 +2740,9 @@ void wxContourMainFrame::getMaskValue(vtkImageData ** mask,vtkImageData ** value } _contourextractdata ->SetTypeOperation( typeContourGroup % 3 ); - std::vector lstManConMod; - std::vector lstManConModTmp; - std::vector lstManConModExp; + std::vector lstManConMod; + std::vector lstManConModTmp; + std::vector lstManConModExp; std::vector tempVector; _instantPanel->getInstant( tempVector ); @@ -2882,8 +2984,82 @@ wxPanel *wxContourMainFrame::getThresholdImageViewPanel(wxWindow *parent) return _viewThresholdImagePanel; } +//CMRU 17-08-09----------------------------------------------------------------------------------------------- +int wxContourMainFrame::getType () +{ + int tipo = 0; + std::vector currentSelection = _theViewPanel->getSelectedObjects(); + + if(!currentSelection.empty()) + { + std::string cloneName = currentSelection [0]; + manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(cloneName); + tipo = manualModel-> GetTypeModel(); + return tipo; + } +} +double wxContourMainFrame::getContourSizeInPixels() +{ + double contourSize = 0; + + std::vector currentSelection = _theViewPanel->getSelectedObjects(); if(!currentSelection.empty()) + if(!currentSelection.empty()) + { + std::string cloneName = currentSelection [0]; + + manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(cloneName);//_modelManager->getOutlineByKeyName( cloneName )->getModel(); + contourSize = manualModel-> GetPathSize(); + } + return contourSize; +} +manualBaseModel * wxContourMainFrame::getContour () +{ + std::vector currentSelection = _theViewPanel->getSelectedObjects(); + + if(!currentSelection.empty()) + { + std::string cloneName = currentSelection [0]; + manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(cloneName);//_modelManager->getOutlineByKeyName( cloneName )->getModel(); + return manualModel; + } + return NULL; +} +void wxContourMainFrame::onPrintLabel (wxString label, manualBaseModel* manualModel) +{ + std::string labelAscii(label.ToAscii()); + int pos = labelAscii.find(" "); + int j; + + for (j=0 ; pos != string::npos;j++) + { + labelAscii.replace( pos, 1, "_" ); + pos= labelAscii.find(" "); + } + manualModel -> SetLabel(labelAscii); +} +void wxContourMainFrame::onInsertCalculation(manualBaseModel* manualModel) +{ + double sizeInPixel = manualModel ->GetPathSize(); + double onePixelRealSize = interfMainPanel::getInstance()->GetPixelValue();; + double realContourSize = sizeInPixel*onePixelRealSize; + manualModel ->SetRealSize(realContourSize); +} +double wxContourMainFrame::onePixelSize( double value) +{ + return _onePixelSize = value; +} +std::string wxContourMainFrame::GetFileLocation() +{ + return _fileLocation; +} +void wxContourMainFrame::SetFileLocation(std::string newFileLocation) +{ + _fileLocation = newFileLocation; + std::cout<<"GETFILELOCATION:"<<_fileLocation< images, long style = wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER, std::string datadir="C:/Creatis/creaContoursBin/RelWithDebInfo/"); static wxContourMainFrame* getInstance(); static void resetInstance(); + //------------------------------------------------------------------------------------------------------------ // Other functional methods //------------------------------------------------------------------------------------------------------------ @@ -206,6 +207,7 @@ class wxContourMainFrame : public wxPanel { void onCreateContourRectangle( ); void onCreateContourCircle( ); void onCreateContourLine( ); + void onCreateContourPoints( ); void onCreateContourBullEye(wxPanel* pan); ///////////////////////////////// void onDeleteContour(); @@ -241,7 +243,7 @@ class wxContourMainFrame : public wxPanel { void onLoad(); void onSave(); - void openContours( FILE *pFile, int version, bool staticContour ); + void openContours( FILE *pFile, FILE *pFileData, int version, bool staticContour ); void RefreshInterface(); @@ -293,6 +295,10 @@ class wxContourMainFrame : public wxPanel { std::vector getOutlinesName(int slide); + // + // + // @param typeContourGroup - int The operation id (AND,OR,XOR,ALL=3) + // void onInformationContourLabels(int typeContourGroup,int selection,int minimumZ,int maximumZ,int grayRangeMin, int grayRangeMax); void onSaveResults(std::string directory,std::string namefile, std::string filename, @@ -314,6 +320,56 @@ class wxContourMainFrame : public wxPanel { void SetContourGroup(int contourGroup); wxPanel *getThresholdImageViewPanel(wxWindow *parent); + +//CMRU 17-08-09----------------------------------------------------------------------------------------------- + + /** + * Associates the String parameter with the contour + * @param label Label entered by the user + * @param manualBaseModel Currently selected contour + */ + void onPrintLabel (wxString label, manualBaseModel* manualModel); + + /** + * Calculates the size of the contour received as a parameter. Uses the measure of a pixel in millimeters. + * @param manualBaseModel Currently selected contour + */ + void onInsertCalculation(manualBaseModel* manualModel); + + /** + * Assigns and returns the value of a pixel in millimeters + @ param value Measure of the pixel in millimeters + */ + double onePixelSize(double value); + + /** + * Returns the type of the currently selected contour + */ + int getType(); + + /** + * Returns the size in pixels of the currently selected contour + */ + double getContourSizeInPixels(); + + /** + * Returns the currently selected contour. If no contour is selected returns NULL + */ + manualBaseModel* getContour(); + + /** + * Returns the Path of the data persistence file + */ + std::string GetFileLocation(); + + /** + * Assign a new path to the data persistence file + @ param newFileLocation New path of the file + */ + void SetFileLocation(std::string newFileLocation); +//------------------------------------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------------------------------------ private: //------------------------------------------------------------------------------------------------------------ @@ -382,7 +438,7 @@ private: //manualContourModel * factoryManualContourModel(int typeContour); - manualContourModel * factoryManualContourModel(wxPanel* panel); + manualBaseModel * factoryManualContourModel(wxPanel* panel); ContourExtractData *_contourextractdata; @@ -400,6 +456,15 @@ private: static char COPY; +//CMRU 17-08-09----------------------------------------------------------------------------------------------- + wxWindow *infoWin2; + wxPanel *calibrationPanel; + wxPanel *calibrationPanelError; + double _onePixelSize; + std::string _imageLocation; + std::string _fileLocation; +//------------------------------------------------------------------------------------------------------------ + }; #endif diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx b/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx index 4bfd0fd..a3611aa 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx +++ b/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx @@ -753,7 +753,7 @@ DEFINE_EVENT_TYPE( wxINSTANT_CHANGE ) return _sceneManager->GetImageData(); } - void wxContourViewPanel::configureViewControlTo(std::string theName,manualContourModel* manModelContour,double* spc,int typeofcontour){ + void wxContourViewPanel::configureViewControlTo(std::string theName,manualBaseModel* manModelContour,double* spc,int typeofcontour){ _sceneManager->configureViewControlTo(theName, manModelContour, spc, typeofcontour); } @@ -786,8 +786,8 @@ DEFINE_EVENT_TYPE( wxINSTANT_CHANGE ) void wxContourViewPanel::onBrigthnessColorWindowLevel(int colorwindow,int windowlevel){ wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)getWxVtkBaseView(); vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2(); - imageviewer->SetColorWindow(colorwindow); - imageviewer->SetColorLevel(windowlevel); + //AMP//imageviewer->SetColorWindow(colorwindow); + //AMP//imageviewer->SetColorLevel(windowlevel); } void wxContourViewPanel::onInterpolation(bool interpolate){ diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.h b/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.h index 660df4f..4b68847 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.h +++ b/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.h @@ -307,7 +307,7 @@ class wxContourViewPanel : public wxPanel {// public wxScrolledWindow { vtkImageData* getImageData(); - void configureViewControlTo(std::string theName,manualContourModel* manModelContour,double* spc,int typeofcontour); + void configureViewControlTo(std::string theName,manualBaseModel* manModelContour,double* spc,int typeofcontour); int GetImageDataSizeZ(); diff --git a/lib/Interface_ManagerContour_NDimensions/wxInstantChooserPanel.cxx b/lib/Interface_ManagerContour_NDimensions/wxInstantChooserPanel.cxx index 4e14484..ea1cfea 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxInstantChooserPanel.cxx +++ b/lib/Interface_ManagerContour_NDimensions/wxInstantChooserPanel.cxx @@ -134,8 +134,7 @@ DEFINE_EVENT_TYPE( wxINSTANT_CHOOSER_CHANGE ) int value = _lastConceptUpdated->getActualValue(); int min = _lastConceptUpdated->getMinValue(); int max = _lastConceptUpdated->getMaxValue(); - int delta = (int) (pow((double) 2,(double) _resolutionSlider->GetValue() )); - + int delta = (int) (pow( 2, _resolutionSlider->GetValue() )); int minTmp = value - delta/2; int maxTmp = value + delta/2; if (minTmpgetActualValue(); int min = theConceptToUpdate->getMinValue(); int max = theConceptToUpdate->getMaxValue(); - int delta = (int) (pow( (double)2, (double)_resolutionSlider->GetValue() )); + int delta = (int) (pow( 2, _resolutionSlider->GetValue() )); int minTmp = value - delta/2; int maxTmp = value + delta/2; if (minTmpfind( anExistingKName ); - manualContourModel *cModule = manualModel; + manualBaseModel *cModule = manualModel; manualViewBaseContour *cViewer = iter->second->getViewer()->Clone(); manualContourBaseControler *cControl = iter->second->getControler()->Clone( ); @@ -1109,7 +1115,7 @@ DEFINE_EVENT_TYPE( wxEVT_CHANGED_DEEP ) if (currentSelection.size()>=1){ manualContourBaseControler *cControler = this->getControlerOf( currentSelection[0] ); - manualContourModel *cModel = cControler->GetManualContourModel(); + manualBaseModel *cModel = cControler->GetManualContourModel(); int i,size = cModel->GetNumberOfPointsSpline(); double x,y,z; for (i=0; i @@ -92,7 +93,25 @@ class wxVtkBaseView_SceneManager : public InteractorStyleMaracas { void setWxVtkViewBase( wxVtkBaseView * theBaseView ); void setWxEventHandler( wxEvtHandler * theEventHandler ); wxVtkBaseView * getWxVtkViewBase(); - void configureViewControlTo( std::string theKeyName, manualContourModel * manContourControl, double * spc ,int typeContour); + + // + // Method which creates and associates view and controller to the contour model type pointed in parameter. + // The possible contour types are: + // 0-spline + // 1-spline + // 2-rectangle + // 3-circle + // 4-BullEye + // 5-BullEyeSector + // 6-Line + // 7-Points + // NOTE: The model is created in the KernelManagerContour class, factoryManualContourModel method + // @param typeContour - int + // @param theKeyName - string + // @param manContourControl - manualBaseModel + // @param spc - double* 3-pos Array + void configureViewControlTo( std::string theKeyName, manualBaseModel * manContourControl, double * spc ,int typeContour); + void configureSelectionROI( double * spc ); ContourWrap_ViewControl * insertWrap( std::string theKeyName, manualContourBaseControler * manContourControl, manualViewBaseContour * manViewerContour ); void desconfigureViewControlOf( std::string theKeyName ); @@ -116,7 +135,7 @@ class wxVtkBaseView_SceneManager : public InteractorStyleMaracas { // Other functional methods //------------------------------------------------------------------------------------------------------------ - void createCopyContourOf( std::string anExistingKName, std::string cloneName, manualContourModel * manualModel, bool append = false ); + void createCopyContourOf( std::string anExistingKName, std::string cloneName, manualBaseModel * manualModel, bool append = false ); void removeFromScene( ContourWrap_ViewControl * contourWRP, bool visualization = true, bool control = true ); void removeFromScene( std::string theKeyName, bool visualization = true, bool control = true ); void removeSceneContours( ); @@ -211,7 +230,7 @@ private: bool _drawingSelectionROI; manualRoiControler *_controlerSelectionROI; manualViewRoi *_viewerSelectionROI; - manualContourModel *_modelSelectionROI; + manualBaseModel *_modelSelectionROI; double _widthOfContour; bool _ctrlKey; diff --git a/lib/kernel_ManagerContour_NDimensions/ContourThing.cxx b/lib/kernel_ManagerContour_NDimensions/ContourThing.cxx index aa87478..648ee88 100644 --- a/lib/kernel_ManagerContour_NDimensions/ContourThing.cxx +++ b/lib/kernel_ManagerContour_NDimensions/ContourThing.cxx @@ -16,7 +16,7 @@ /* * Creates a ContourThing */ - ContourThing :: ContourThing(manualContourModel * model) + ContourThing :: ContourThing(manualBaseModel * model) { setModel( model ); } @@ -49,12 +49,12 @@ outlineName = aName; } - manualContourModel * ContourThing ::getModel() + manualBaseModel * ContourThing ::getModel() { return theModel; } - void ContourThing :: setModel(manualContourModel * model) + void ContourThing :: setModel(manualBaseModel * model) { theModel = model; } diff --git a/lib/kernel_ManagerContour_NDimensions/ContourThing.h b/lib/kernel_ManagerContour_NDimensions/ContourThing.h index 80e3e8a..45b2f08 100644 --- a/lib/kernel_ManagerContour_NDimensions/ContourThing.h +++ b/lib/kernel_ManagerContour_NDimensions/ContourThing.h @@ -22,7 +22,7 @@ public: /* * Creates a ContourThing */ - ContourThing(manualContourModel * model); + ContourThing(manualBaseModel * model); /* * Destroys a ContourThing @@ -43,9 +43,9 @@ public: void setName(std::string aName); - manualContourModel * getModel(); + manualBaseModel * getModel(); - void setModel(manualContourModel * model); + void setModel(manualBaseModel * model); /* * Executes the given command if posible and returns is posible or not @@ -73,6 +73,6 @@ private: std::string outlineName; - manualContourModel * theModel; + manualBaseModel * theModel; }; #endif diff --git a/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx b/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx index 9d3f861..236e4a5 100644 --- a/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx +++ b/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx @@ -130,7 +130,7 @@ OutlineModelManager* KernelManagerContour::getOutlineModelManager(){ return modelManager; } -std::string KernelManagerContour::createOutline(manualContourModel * manModelContour,std::vector instantVector){ +std::string KernelManagerContour::createOutline(manualBaseModel * manModelContour,std::vector instantVector){ return modelManager->createOutline( manModelContour, instantVector ); } @@ -153,8 +153,8 @@ std::vector KernelManagerContour::GetLstNameThingsStatic(){ return modelManager->GetLstNameThingsStatic(); } -void KernelManagerContour::SaveThingName(FILE* pFile, std::string name ){ - modelManager->SaveThingName(pFile, name); +void KernelManagerContour::SaveThingName(FILE* pFile, FILE *pFileData, std::string name ){ + modelManager->SaveThingName(pFile, pFileData, name); } std::vector KernelManagerContour::GetLstNameThings(){ return modelManager->GetLstNameThings(); @@ -168,7 +168,7 @@ bool KernelManagerContour::IsPartOfStaticList(std::string theKeyName){ } void KernelManagerContour::deleteCModel(std::string theKeyName){ - manualContourModel* cModel = modelManager->getOutlineByKeyName(theKeyName)->getModel(); + manualBaseModel* cModel = modelManager->getOutlineByKeyName(theKeyName)->getModel(); modelManager->removeOutline( theKeyName ); delete cModel; @@ -207,7 +207,7 @@ std::string KernelManagerContour::createCopyContourOf ( std::string anExistingKN { return modelManager->createCopyContourOf(anExistingKName, instantNoTouchData); } -manualContourModel* KernelManagerContour::getOutlineByKeyName(std::string cloneName){ +manualBaseModel* KernelManagerContour::getOutlineByKeyName(std::string cloneName){ return modelManager->getOutlineByKeyName (cloneName )->getModel(); } @@ -314,11 +314,11 @@ void KernelManagerContour::CalculeSplinePropagation(){ _contourPropagation->CalculeSplinePropagation(); } -manualContourModel* KernelManagerContour::GetPoints(int z,int type, std::vector* vecCtrlPointX,std::vector* vecCtrlPointY,std::vector* vecCtrlPointZ, std::string& theName,int typeofcontour, std::vector tempVector){ +manualBaseModel* KernelManagerContour::GetPoints(int z,int type, std::vector* vecCtrlPointX,std::vector* vecCtrlPointY,std::vector* vecCtrlPointZ, std::string& theName,int typeofcontour, std::vector tempVector){ bool addedModel = false; - manualContourModel* manModelContour=NULL; + manualBaseModel* manModelContour=NULL; if (_contourPropagation->ifSliceKeyContourExist(z)==false){ @@ -358,9 +358,12 @@ manualContourModel* KernelManagerContour::GetPoints(int z,int type, std::vector< return manModelContour; } -manualContourModel * KernelManagerContour::factoryManualContourModel(int typeContour) +manualBaseModel * KernelManagerContour::factoryManualContourModel(int typeContour) { - manualContourModel *manModelContour=NULL; + manualBaseModel *manModelContour=NULL; + + // Creating the model + // NOTE: The view and the controler are created in the wxVtkBaseView_SceneManager class, configureViewControlTo method // spline if (typeContour==0) @@ -391,6 +394,12 @@ manualContourModel * KernelManagerContour::factoryManualContourModel(int typeCon { manModelContour = new manualContourModelLine(); } + + // points + if (typeContour==7) + { + manModelContour = new manualBaseModel(); + } return manModelContour; } @@ -410,9 +419,9 @@ std::vector KernelManagerContour::getOutlinesAtInstant(Instant* return modelManager->getOutlinesAtInstant(instant); } -std::vector KernelManagerContour::ExploseEachModel( std::vector lstManConMod ){ - std::vector lstTmp; - std::vector lstResult; +std::vector KernelManagerContour::ExploseEachModel( std::vector lstManConMod ){ + std::vector lstTmp; + std::vector lstResult; int j,jSize; int i,iSize=lstManConMod.size(); for (i=0;i instantVector); + std::string createOutline(manualBaseModel * manModelContour,std::vector instantVector); ///////////////////////////////// std::string intToString(int num); std::vector GetLstNameThingsStatic(); - void SaveThingName(FILE* pFile, std::string name ); + void SaveThingName(FILE* pFile, FILE *pFileData, std::string name ); std::vector GetLstNameThings(); @@ -89,7 +89,7 @@ public: Instant * getCurrentInstant(); - manualContourModel* getOutlineByKeyName(std::string cloneName); + manualBaseModel* getOutlineByKeyName(std::string cloneName); bool onRedo(std::string& filename); @@ -107,9 +107,22 @@ public: void getMaxMinZ(double *minZ,double *maxZ); - manualContourModel* GetPoints(int z,int type, std::vector* vecCtrlPointX,std::vector* vecCtrlPointY,std::vector* vecCtrlPointZ, std::string& theName,int typeofcontour, std::vector tempVector); - - manualContourModel* factoryManualContourModel(int typeContour); + manualBaseModel* GetPoints(int z,int type, std::vector* vecCtrlPointX,std::vector* vecCtrlPointY,std::vector* vecCtrlPointZ, std::string& theName,int typeofcontour, std::vector tempVector); + + // + // Method which creates the model associated with the type in parameter. The possible contour types are: + // 0-spline + // 1-spline + // 2-rectangle + // 3-circle + // 4-BullEye + // 5-BullEyeSector + // 6-Line + // 7-Points + // NOTE: The view and the controler are created in the wxVtkBaseView_SceneManager class, configureViewControlTo method + // @param typeContour - int + // @return manualBaseModel - Model created based on the type + manualBaseModel* factoryManualContourModel(int typeContour); void CalculeSplinePropagation(); @@ -117,7 +130,7 @@ public: std::vector getOutlinesAtInstant(Instant* instant ); - std::vector ExploseEachModel( std::vector lstManConMod ); + std::vector ExploseEachModel( std::vector lstManConMod ); void getConceptsInformation(std::vector& conceptNameVect, std::vector& conceptSizeVect); diff --git a/lib/kernel_ManagerContour_NDimensions/OutlineModelManager.cxx b/lib/kernel_ManagerContour_NDimensions/OutlineModelManager.cxx index 89d0b6d..c2301ce 100644 --- a/lib/kernel_ManagerContour_NDimensions/OutlineModelManager.cxx +++ b/lib/kernel_ManagerContour_NDimensions/OutlineModelManager.cxx @@ -338,7 +338,7 @@ * @return Returns the key name of the created outline, or ""if it wasn't created */ // bool OutlineModelManager :: createOutline(std::string aName, ContourThing * &theOutline) - std::string OutlineModelManager :: createOutline(manualContourModel * model, std::vector theInstantData, std::string aName) + std::string OutlineModelManager :: createOutline(manualBaseModel * model, std::vector theInstantData, std::string aName) { ContourThing * theOutline = new ContourThing ( model ); theOutline->setName(aName); @@ -764,11 +764,11 @@ std::string OutlineModelManager :: createCopyContourOf( std::string anExistingKName, std::vector &instantNoTouchData ) { - manualContourModel * manModelContour = getOutlineByKeyName( anExistingKName )->getModel()->Clone(); + manualBaseModel * manModelContour = getOutlineByKeyName( anExistingKName )->getModel()->Clone(); return createOutline( manModelContour, instantNoTouchData ); } - void OutlineModelManager::SaveThingName( FILE *pFile, std::string nameThing ) + void OutlineModelManager::SaveThingName( FILE *pFile, FILE *pFileData, std::string nameThing ) { std::vector< Instant * > *lstInstants; lstInstants = outlinesEnvironment->getInstantsOfThing( nameThing ); @@ -783,5 +783,6 @@ fprintf(pFile,"\n"); ContourThing *contourthing = *outlinesEnvironment->getThingByName(nameThing); contourthing->getModel()->Save(pFile); + contourthing->getModel()->SaveData(pFileData); } diff --git a/lib/kernel_ManagerContour_NDimensions/OutlineModelManager.h b/lib/kernel_ManagerContour_NDimensions/OutlineModelManager.h index 63feb9e..8520b6a 100644 --- a/lib/kernel_ManagerContour_NDimensions/OutlineModelManager.h +++ b/lib/kernel_ManagerContour_NDimensions/OutlineModelManager.h @@ -170,7 +170,7 @@ public: * @return Returns the key name of the created outline, or ""if it wasn't created */ //bool createOutline(std::string aName, ContourThing * &theOutline); - std::string createOutline(manualContourModel * model, std::vector theInstantData, std::string aName = "" ); + std::string createOutline(manualBaseModel * model, std::vector theInstantData, std::string aName = "" ); /* * Creates an axeThing with a given name @@ -358,7 +358,7 @@ public: void removeAllOutlines(); std::string createCopyContourOf( std::string anExistingKName, std::vector &instantNoTouchData ); - void SaveThingName( FILE *pFile, std::string nameThing ); + void SaveThingName( FILE *pFile, FILE *pFileData, std::string nameThing ); void ChangeContourOfList(std::string keyName, Instant *instant); int IsPartOfStaticList(std::string ss);