X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FInterface_ManagerContour_NDimensions%2FwxContourEventHandler.cxx;h=0bf6536690eb233c03ce3018a47fc44741e38e1b;hb=7e39ed1fa75cd57dfea770353f5286bdcee23c24;hp=36ff6c8d937276ac184139905641c80302a58f6f;hpb=23633c5496dd702cc9b332468f5daba67d608aca;p=creaContours.git diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourEventHandler.cxx b/lib/Interface_ManagerContour_NDimensions/wxContourEventHandler.cxx index 36ff6c8..0bf6536 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourEventHandler.cxx +++ b/lib/Interface_ManagerContour_NDimensions/wxContourEventHandler.cxx @@ -103,7 +103,6 @@ digraph example_0 { #include - //------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------ @@ -119,9 +118,9 @@ PanelBullEyeOptions::PanelBullEyeOptions (wxWindow * parent, wxSize size) : wxString lstOptions[2]; - lstOptions[0]="General options"; - lstOptions[1]="Detail options"; - _radioboxBullEyeGenOpt = new wxRadioBox(panel, -1, "General/Detail options", wxDefaultPosition, wxSize(200,45), 2 , lstOptions, 2, wxRA_SPECIFY_COLS); + lstOptions[0]= wxString("General options",wxConvUTF8); + lstOptions[1]= wxString("Detail options",wxConvUTF8); + _radioboxBullEyeGenOpt = new wxRadioBox(panel, -1, wxString("General/Detail options",wxConvUTF8), wxDefaultPosition, wxSize(200,45), 2 , lstOptions, 2, wxRA_SPECIFY_COLS); _radioboxBullEyeGenOpt->SetSelection(0); _spinctrlBullEyeNumOfCrowns = new wxSpinCtrl( panel , -1,_T("B"),wxDefaultPosition, wxSize(40,20) ); @@ -369,7 +368,11 @@ double PanelBullEyeOptions::GetAngDeltaOfCrownSection(int nCrown) inundo = 0; inredo = 0; stundoredo = "data/temp"; +#if(WIN32) mkdir(stundoredo.c_str()); +#else + mkdir(stundoredo.c_str(),755); +#endif stundoredo += "/cont"; } //------------------------------------------------------------------------------------------------------------ @@ -433,12 +436,12 @@ double PanelBullEyeOptions::GetAngDeltaOfCrownSection(int nCrown) else { dataConcept = _instantPanel->getLastConceptData(); - if( dataConcept->getName().compare( _theViewPanel->getVerticalConceptName() ) ) + if( dataConcept->getName().compare( _theViewPanel->getVerticalConceptName() ) == 0) { _theViewPanel->setActualVertical( dataConcept->getActualValue()); //_theViewPanel->setVerticalConcept( dataConcept->getName(), dataConcept->getMinShowedValue()/*dataConcept->getMinValue()*/, /*dataConcept->getMaxValue()*/ dataConcept->getMaxShowedValue(), dataConcept->getMinShowedValue(), dataConcept->getMaxShowedValue(), dataConcept->getActualValue()); } - else if( dataConcept->getName().compare( _theViewPanel->getHorizontalConceptName() ) || _instantPanel->getIfConceptCheckedAt( dataConcept->getName(), 0 ) ) + else if( dataConcept->getName().compare( _theViewPanel->getHorizontalConceptName() ) == 0|| _instantPanel->getIfConceptCheckedAt( dataConcept->getName(), 0 ) ) { _theViewPanel->setHorizontalConcept( dataConcept->getName(), dataConcept->getMinShowedValue()/*dataConcept->getMinValue()*/, /*dataConcept->getMaxValue()*/ dataConcept->getMaxShowedValue(), dataConcept->getMinShowedValue(), dataConcept->getMaxShowedValue(), dataConcept->getActualValue()); } @@ -518,7 +521,7 @@ double PanelBullEyeOptions::GetAngDeltaOfCrownSection(int nCrown) void wxContourEventHandler::onSpreadReset( wxCommandEvent& event ) { - _wxtextctrlSpread->SetValue(""); + _wxtextctrlSpread->SetValue(wxString("",wxConvUTF8)); _contourPropagation->resetAppend(); } @@ -542,11 +545,16 @@ double PanelBullEyeOptions::GetAngDeltaOfCrownSection(int nCrown) _contourPropagation->appendContour(&vecX , &vecY , &vecZ); wxString newstring; - newstring.Printf("%s %d -",_wxtextctrlSpread->GetValue(), actualSlice ); + //newstring.Printf("%s %d -",_wxtextctrlSpread->GetValue(), actualSlice ); + newstring.append(wxString(_wxtextctrlSpread->GetValue(),wxConvUTF8)); + newstring.append(wxString(" ",wxConvUTF8)); + newstring.append(wxString(intToString(actualSlice).c_str(),wxConvUTF8)); _wxtextctrlSpread->SetValue(newstring); } // if } + + //------------------------------------------------------------------------------------------------------------ void wxContourEventHandler::onSpreadGo( wxCommandEvent& event ) { @@ -584,7 +592,11 @@ double PanelBullEyeOptions::GetAngDeltaOfCrownSection(int nCrown) for ( z=(int)minZ ; z<=(int)maxZ ; z++ ) { porcent = 100.0* (z-minZ)/totalZ; - tmpString.Printf(" %d %c %d/%d %d", (int)porcent , 37 , (int)(z-minZ+1), (int)totalZ,z ); + int numero = (int)(z-minZ+1)/(int)totalZ; + std::string stringtemp = " "+intToString(porcent)+"% "+intToString(numero)+" "+intToString(z); + tmpString.Append(wxString(stringtemp.c_str(),wxConvUTF8)); + + //tmpString.Printf(" %d %c %d/%d %d", (int)porcent , 37 , (int)(z-minZ+1), (int)totalZ,z ); _staticTextSpread->SetLabel(tmpString); if (_contourPropagation->ifSliceKeyContourExist(z)==false) @@ -627,7 +639,7 @@ double PanelBullEyeOptions::GetAngDeltaOfCrownSection(int nCrown) } // if addedModel }// ifSliceKeyContourExist } // for z - _staticTextSpread->SetLabel(" "); + _staticTextSpread->SetLabel(wxString(" ",wxConvUTF8)); //RefreshInterface(); @@ -698,22 +710,22 @@ double PanelBullEyeOptions::GetAngDeltaOfCrownSection(int nCrown) _contourPropagation = new ContourPropagation(); - wxPanel *panel = new wxPanel(parent,-1,wxDefaultPosition, wxDefaultSize,wxNO_BORDER, wxString("")); + wxPanel *panel = new wxPanel(parent,-1,wxDefaultPosition, wxDefaultSize,wxNO_BORDER, wxString("",wxConvUTF8)); wxButton *spreadResetBtn = new wxButton(panel,-1,_T("Reset"),wxDefaultPosition, wxDefaultSize ); wxButton *spreadAddBtn = new wxButton(panel,-1,_T("Add"),wxDefaultPosition, wxDefaultSize); wxString lstOptions[3]; - lstOptions[0]="A"; - lstOptions[1]="B"; - lstOptions[2]="C"; - _spreadMethodRadiobox = new wxRadioBox(panel, -1, "Method (find ctrl. Points)", wxDefaultPosition, wxDefaultSize, 3 , lstOptions, 3, wxRA_SPECIFY_COLS); + lstOptions[0]=_T("A"); + lstOptions[1]=_T("B"); + lstOptions[2]=_T("C"); + _spreadMethodRadiobox = new wxRadioBox(panel, -1, _T("Method (find ctrl. Points)"), wxDefaultPosition, wxDefaultSize, 3 , lstOptions, 3, wxRA_SPECIFY_COLS); _spreadMethodRadiobox->SetSelection(2); wxButton *spreadGoBtn = new wxButton(panel,-1,_T("Go"),wxDefaultPosition, wxDefaultSize); _staticTextSpread = new wxStaticText(panel,-1,_T(" ")); - _wxtextctrlSpread = new wxTextCtrl(panel,-1, "",wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); + _wxtextctrlSpread = new wxTextCtrl(panel,-1, _T(""),wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); Connect( spreadResetBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSpreadReset ); @@ -755,11 +767,11 @@ double PanelBullEyeOptions::GetAngDeltaOfCrownSection(int nCrown) for( z=minZ ; z<=maxZ ; z++ ) { porcent = 100.0* (z-minZ)/totalZ; - tmpString.Printf(" %d %c %d/%d %d", (int)porcent , 37 , z-minZ+1, (int)totalZ,z ); + tmpString.Printf(_T(" %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ,z ); _staticTextSegmentation->SetLabel(tmpString); SegmentationOneSlice( x,y,z ); } - _staticTextSegmentation->SetLabel(" "); + _staticTextSegmentation->SetLabel(_T(" ")); RefreshInterface(); @@ -1043,10 +1055,10 @@ myfile.close(); _isovalue = new wxSlider(panel, -1, 40 , (int)(range[0]), (int)(range[1]), wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator); _sampling = new wxSlider(panel, -1, 20 , 4, 50, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator); wxString lstOptions[3]; - lstOptions[0]="A"; - lstOptions[1]="B"; - lstOptions[2]="C"; - methodRadiobox = new wxRadioBox(panel, -1, "Method (find ctrl. Points)", wxDefaultPosition, wxSize(200,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS); + lstOptions[0]=_T("A"); + lstOptions[1]=_T("B"); + lstOptions[2]=_T("C"); + methodRadiobox = new wxRadioBox(panel, -1, _T("Method (find ctrl. Points)"), wxDefaultPosition, wxSize(200,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS); methodRadiobox->SetSelection(2); _staticTextSegmentation = new wxStaticText(panel,-1,_T(" ")); @@ -1104,7 +1116,7 @@ myfile.close(); wxButton *spreadResetBtn = new wxButton(panel,-1,_T("Reset"),wxDefaultPosition, wxSize(80,35) ); wxButton *spreadAddBtn = new wxButton(panel,-1,_T("Add"),wxDefaultPosition, wxSize(80,35)); wxButton *spreadGoBtn = new wxButton(panel,-1,_T("GoA"),wxDefaultPosition, wxSize(80,35)); - _wxtextctrlTest = new wxTextCtrl(panel,-1, "",wxDefaultPosition, wxSize(200,150), wxTE_MULTILINE ); + _wxtextctrlTest = new wxTextCtrl(panel,-1, _T(""),wxDefaultPosition, wxSize(200,150), wxTE_MULTILINE ); _TestFrame->SetEventHandler( this ); Connect( spreadResetBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onTestReset ); @@ -1134,7 +1146,7 @@ myfile.close(); void wxContourEventHandler::onTestReset( wxCommandEvent& event ) { - _wxtextctrlTest->SetValue(""); + _wxtextctrlTest->SetValue(_T("")); _contourPropagation->resetAppend(); } @@ -1158,7 +1170,11 @@ myfile.close(); _contourPropagation->appendContour(&vecX , &vecY , &vecZ); wxString newstring; - newstring.Printf("%s %d -",_wxtextctrlTest->GetValue(), actualSlice ); + newstring.append(_wxtextctrlTest->GetValue()); + newstring.append(_T(" ")); + newstring.append(wxString(intToString(actualSlice).c_str(),wxConvUTF8)); + //newstring.Printf(_T("%s %d -"),, ); + newstring.append(_T(" -")); _wxtextctrlTest->SetValue(newstring); } // if } @@ -1265,13 +1281,13 @@ myfile.close(); std::vector lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant ); sizeLstContourThings = lstContourThings.size(); - tempString.Printf("%d - %d",z, sizeLstContourThings); + tempString.Printf(_T("%d - %d"),z, sizeLstContourThings); _grid->SetRowLabelValue(z, tempString ); for (ii=0 ; iigetName().c_str() ; + tempString = wxString((*contourthing)->getName().c_str(),wxConvUTF8) ; _grid->SetCellValue( z, ii, tempString ); } } @@ -1366,7 +1382,7 @@ myfile.close(); for ( z=minZ ; z<=maxZ ; z++ ) { porcent = 100.0* (z-minZ)/totalZ; - tmpString.Printf(" %d %c %d/%d %d", (int)porcent , 37 , z-minZ+1, (int)totalZ ,z); + tmpString.Printf(_T(" %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z); _staticTextInformation->SetLabel(tmpString); //Extraction data from contours of each slice @@ -1387,7 +1403,7 @@ myfile.close(); wxString tempString; - tempString.Printf("%d - %d",z, sizeLstContourThings); + tempString.Printf(_T("%d - %d"),z, sizeLstContourThings); _grid->SetRowLabelValue(z, tempString ); //EED004 int iContourGroup,sizeContourGroup; @@ -1443,17 +1459,17 @@ myfile.close(); tmpIntA=_numberOfVariablesStatistics*iContourGroup ; - tempString.Printf("%d",resultSize); + tempString.Printf(_T("%d"),resultSize); _grid->SetCellValue( z, tmpIntA + 0, tempString ); - tempString.Printf("%d",resultGrayRangeCount); + tempString.Printf(_T("%d"),resultGrayRangeCount); _grid->SetCellValue( z, tmpIntA + 1, tempString ); - tempString.Printf("%f",resultMin); + tempString.Printf(_T("%f"),resultMin); _grid->SetCellValue( z, tmpIntA + 2, tempString ); - tempString.Printf("%f",resultMax); + tempString.Printf(_T("%f"),resultMax); _grid->SetCellValue( z, tmpIntA + 3, tempString ); - tempString.Printf("%f",resultAverage); + tempString.Printf(_T("%f"),resultAverage); _grid->SetCellValue( z, tmpIntA + 4, tempString ); - tempString.Printf("%f",resultStandardeviation); + tempString.Printf(_T("%f"),resultStandardeviation); _grid->SetCellValue( z, tmpIntA + 5, tempString ); } // for iContourGroup @@ -1520,7 +1536,9 @@ myfile.close(); { porcent = 100.0* (z-minZ)/totalZ; - tmpString.Printf("Saving Values %d %c %d/%d %d", (int)porcent , 37 , z-minZ+1, (int)totalZ ,z); + + tmpString.Printf(_T("Saving Values")); + tmpString.Printf(_T(" %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z); _staticTextInformation->SetLabel(tmpString); @@ -1572,7 +1590,14 @@ myfile.close(); &pLstValuePosZ); wxString filename; - filename.Printf("%s\\%s-slice%d-cont%d.txt",directory.c_str(),namefile.c_str(),z,iContourGroup); + filename.Printf(_T("%s"),directory.c_str()); + filename.Printf(_T("\\")); + filename.Printf(_T("%s"),namefile.c_str()); + filename.Printf(_T("-slice")); + filename.Printf(_T("%d"),z); + filename.Printf(_T("-cont")); + filename.Printf(_T("%d"),iContourGroup); + filename.Printf(_T(".txt")); FILE *pFile=fopen((const char *)filename.mb_str(),"w+"); fprintf(pFile,"value \t x \t y \t z\n" ); int iLstValue,sizeLstValue=pLstValue.size(); @@ -1630,7 +1655,8 @@ myfile.close(); { porcent = 100.0* (z-minZ)/totalZ; - tmpString.Printf("Saving Values %d %c %d/%d %d", (int)porcent , 37 , z-minZ+1, (int)totalZ ,z); + tmpString.Printf(_T("Saving Values")); + tmpString.Printf(_T("%d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z); _staticTextInformation->SetLabel(tmpString); //Extraction data from contours of each slice @@ -1684,7 +1710,11 @@ myfile.close(); wxString filename; - filename.Printf("%s\\%s-Value.mhd",directory.c_str(),namefile.c_str(),z); + //filename.Printf(_T("%s\\%s-Value.mhd",directory.c_str(),namefile.c_str(),z); + filename.Printf(_T("%s"),directory.c_str()); + filename.Printf(_T("\\")); + filename.Printf(_T("%s"),namefile.c_str()); + filename.Printf(_T("-Value.mhd")); // Image Value vtkMetaImageWriter *writerValueImage = vtkMetaImageWriter::New( ); @@ -1694,7 +1724,11 @@ myfile.close(); writerValueImage->Write( ); // Image Mask - filename.Printf("%s\\%s-Mask.mhd",directory.c_str(),namefile.c_str(),z); + // filename.Printf("%s\\%s-Mask.mhd",directory.c_str(),namefile.c_str(),z); + filename.Printf(_T("%s"),directory.c_str()); + filename.Printf(_T("\\")); + filename.Printf(_T("%s"),namefile.c_str()); + filename.Printf(_T("-Mask.mhd")); vtkMetaImageWriter *writerMaskImage = vtkMetaImageWriter::New( ); writerMaskImage->SetInput( contourextractdata->GetVtkImageMaskResult() ); writerMaskImage->SetFileName( (const char *)filename.mb_str() ); @@ -1739,7 +1773,7 @@ myfile.close(); int iTitle,sizeTitle = (maxX / _numberOfVariablesStatistics); for ( iTitle=0; iTitle & keyNamesVector ) + void wxContourEventHandler :: deleteContours( std::vector keyNamesVector ) { int i,size=keyNamesVector.size(); for (i=0;isetWxEventHandler( this ); - Connect( _instantPanel->GetId(), wxINSTANT_CHOOSER_CHANGE, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourEventHandler::onChangeInstant ); + //Connect( _instantPanel->GetId(), wxINSTANT_CHOOSER_CHANGE, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourEventHandler::onChangeInstant ); std::vector vect; _instantPanel->getInstant( vect ); @@ -2724,7 +2758,7 @@ myfile.close(); //JCP 20-10-08 Undo redo implementation saveState(); //JCP 20-10-08 Undo redo implementation - deleteContours( _sceneManager->GetlstContoursNameActualSlice() ); + deleteContours( (std::vector)_sceneManager->GetlstContoursNameActualSlice() ); } @@ -3014,7 +3048,7 @@ void wxContourEventHandler::OnInterpolation(wxCommandEvent& event) return panel;*/ - wxPanel *panel = new wxPanel(parent,-1,wxDefaultPosition, wxDefaultSize,wxNO_BORDER, wxString("")); + wxPanel *panel = new wxPanel(parent,-1,wxDefaultPosition, wxDefaultSize,wxNO_BORDER, wxString(_T(""))); _withOfContourLine = new wxSlider(panel, -1, 1 , 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator); double range[2]; @@ -3269,10 +3303,12 @@ void wxContourEventHandler::OnInterpolation(wxCommandEvent& event) inredo = 0; - char str[9000]; - itoa(inundo, str, 10); + //char str[9000]; + //itoa(inundo, str, 10); + std::string str = intToString(inundo); - std::string temp = stundoredo + *str + ".roi"; + + std::string temp = stundoredo + str + ".roi"; saveFileWithContours(temp); inundo++; @@ -3308,11 +3344,12 @@ void wxContourEventHandler :: onREDO() inredo--; inundo++; - char str[9000]; - itoa(inundo, str, 10); + //char str[9000]; + //itoa(inundo, str, 10); + std::string str = intToString(inundo); - std::string temp = stundoredo + *str + ".roi"; + std::string temp = stundoredo + str + ".roi"; loadState(temp); @@ -3326,21 +3363,23 @@ void wxContourEventHandler :: onREDO() if(inundo>0){ if(inredo==0){ - char str[9000]; - itoa(inundo, str, 10); + //char str[9000]; + //itoa(inundo, str, 10); + std::string str = intToString(inundo); - std::string temp = stundoredo + *str + ".roi"; + std::string temp = stundoredo + str + ".roi"; saveFileWithContours(temp); } inredo++; inundo--; - char str[9000]; - itoa(inundo, str, 10); + //char str[9000]; + //itoa(inundo, str, 10); + std::string str = intToString(inundo); - std::string temp = stundoredo + *str + ".roi"; + std::string temp = stundoredo + str + ".roi"; loadState(temp); } @@ -3509,7 +3548,8 @@ void wxContourEventHandler :: onREDO() { porcent = 100.0* (z-minZ)/totalZ; - tmpString.Printf("Saving Values %d %c %d/%d %d", (int)porcent , 37 , z-minZ+1, (int)totalZ ,z); + tmpString.Printf(_T("Saving Values")); + tmpString.Printf(_T(" %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z); _staticTextInformation->SetLabel(tmpString); //Extraction data from contours of each slice @@ -3578,10 +3618,10 @@ void wxContourEventHandler :: onREDO() _isovalue = new wxSlider(panel, -1, 40 , (int)(range[0]), (int)(range[1]), wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator); _sampling = new wxSlider(panel, -1, 20 , 4, 50, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator); wxString lstOptions[3]; - lstOptions[0]="A"; - lstOptions[1]="B"; - lstOptions[2]="C"; - methodRadiobox = new wxRadioBox(panel, -1, "Method (find ctrl. Points)", wxDefaultPosition, wxSize(200,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS); + lstOptions[0]=_T("A"); + lstOptions[1]=_T("B"); + lstOptions[2]=_T("C"); + methodRadiobox = new wxRadioBox(panel, -1, _T("Method (find ctrl. Points)"), wxDefaultPosition, wxSize(200,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS); methodRadiobox->SetSelection(2); _staticTextSegmentation = new wxStaticText(panel,-1,_T(" ")); @@ -3664,9 +3704,9 @@ void wxContourEventHandler :: onREDO() vecZ[i] = actualSlice; } // for - wxDialog* dialog = new wxDialog(parent, -1, wxString("Snake")); + wxDialog* dialog = new wxDialog(parent, -1, wxString(_T("Snake"))); wxPanel* panel = new wxPanel(dialog,-1); - wxStaticText* sttext = new wxStaticText(panel, -1, wxString("Panel para snake")); + wxStaticText* sttext = new wxStaticText(panel, -1, wxString(_T("Panel para snake"))); dialog->ShowModal(); } // if @@ -3678,4 +3718,19 @@ void wxContourEventHandler :: onREDO() _InformationContourFrame->Show(false); } } + + std::string wxContourEventHandler::intToString(int num){ + std::string result; + if(num == 0){ + result = "0"; + }else{ + int k=num; + while (k > 0){ + char temp = k % 10 + 48; + k = k / 10; + result = temp + result; + } + } + return result; + } //JCP 21 - 10 - 09