if(images.size() > 0)
{
- this->setVectImages(images);
+ _images = images;
+ this->setVectImages();
}
}
-void wxContourMainFrame::setVectImages( std::vector<vtkImageData*> images ){
+void wxContourMainFrame::setVectImages( )
+{
#if defined(__GNUC__)
std::string str_home(getenv("HOME"));
notebook = this->createNotebook();
- kernelManager = new KernelManagerContour( images , _datadir+"/data/" , strCreaContourDataTmp );
+ kernelManager = new KernelManagerContour( _images , _datadir+"/data/" , strCreaContourDataTmp );
_instantPanel = new wxInstantChooserPanel( notebook, "Instant Chooser", true, false, "c" );
wxContourMainFrame :: ~wxContourMainFrame()
{
-
+ deleteAllContours();
_pannew->Close();
interfMainPanel::resetInstance();
delete kernelManager;
fscanf(pFile,"%s",tmp); // --CreaContour--
fscanf(pFile,"%s",tmp); // Version
- fscanf(pFile,"%s",tmp); // 1.0.1
+ fscanf(pFile,"%s",tmp); // 1.0.1 || 1.0.0
std::string version(tmp);
- openContours(pFile,false);
- if (version!="1.0.0"){
+ if (version=="1.0.1")
+ {
+ openContours(pFile,false);
+ }
+
+ else if (version=="1.0.0")
+ {
openContours(pFile,true);
}
// _theViewPanel->getSceneManager()->openFileWithContours(ff);
_theViewPanel->getSceneManager()->removeSceneContours();
changeInstant();
}
+
+//AD: 29-05-09
void wxContourMainFrame::onSave(){
wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxSAVE );
if (dialog.ShowModal() == wxID_OK)
saveFileWithContours( fileNameContourROI );
}
}
+
+//AD: 29-05-09
void wxContourMainFrame::saveFileWithContours( std::string filename )
{
lstNameThings = kernelManager->GetLstNameThings();
sizeLstNameThings = lstNameThings.size();
fprintf(pFile,"NumberOfContours %d\n", sizeLstNameThings );
+
+ vtkImageData *image = _images[0];
+
+ int dimRange[3];
+ image->GetDimensions(dimRange);
+
+ fprintf(pFile,"ImageDimensions %d %d %d\n", dimRange[0], dimRange[1], dimRange[2] );
+
+ double spaRange[3];
+ image->GetSpacing(spaRange);
+
+ fprintf(pFile,"ImageSpacing %f %f %f\n", spaRange[0], spaRange[1], spaRange[2] );
+
for (i=0 ; i<sizeLstNameThings ; i++)
{
kernelManager->SaveThingName( pFile, lstNameThings[i] );
fclose(pFile);
}
+//AD:02-06-09: TODO: Adjust spacing and dimensions to Rois comming from images with different specifications
void wxContourMainFrame::openContours( FILE *pFile, bool staticContour ){
char tmp[255];
fscanf(pFile,"%s",tmp); // NumberOfContours
manualContourModel *manModelContour;
int typeView;
- int i;
- for (i=0;i<numberOfContours;i++)
+ vtkImageData *image = _images[0];
+ int imageDim[3];
+ image->GetDimensions(imageDim);
+ double imageSpac[3];
+ image->GetSpacing(imageSpac);
+
+ int tempDim[3];
+ double tempSpac[3];
+
+ fscanf(pFile,"%s",tmp); // ImageDimensions
+ fscanf(pFile,"%s",tmp); // X
+ tempDim[0] = atoi(tmp);
+ fscanf(pFile,"%s",tmp); // Y
+ tempDim[1] = atoi(tmp);
+ fscanf(pFile,"%s",tmp); // Z
+ tempDim[2] = atoi(tmp);
+
+ fscanf(pFile,"%s",tmp); // ImageSpacing
+ fscanf(pFile,"%s",tmp); // X
+ tempSpac[0] = atof(tmp);
+ fscanf(pFile,"%s",tmp); // Y
+ tempSpac[1] = atof(tmp);
+ fscanf(pFile,"%s",tmp); // Z
+ tempSpac[2] = atof(tmp);
+
+ bool compatible = true;
+
+ //Compare Spacing and Dims in X and Y (Necessary in Z?)
+ if (imageDim[0]!=tempDim[0] || imageDim[1]!=tempDim[1] ||
+ imageSpac[0]!=tempSpac[0] || imageSpac[1]!=tempSpac[1])
{
- instantVector.clear();
- fscanf(pFile,"%s",tmp); // Instant
+ compatible = false;
+ }
- fscanf(pFile,"%s",tmp); // 1
- instantVector.push_back( atoi(tmp) );
- fscanf(pFile,"%s",tmp); // 2
- instantVector.push_back( atoi(tmp) );
- fscanf(pFile,"%s",tmp); // 3
- instantVector.push_back( atoi(tmp) );
- fscanf(pFile,"%s",tmp); // 4
- instantVector.push_back( atoi(tmp) );
- fscanf(pFile,"%s",tmp); // 5
- instantVector.push_back( atoi(tmp) );
- fscanf(pFile,"%s",tmp); // 6
- instantVector.push_back( atoi(tmp) );
+ if (compatible==true)
+ {
+ int i;
+ for (i=0;i<numberOfContours;i++)
+ {
+ instantVector.clear();
+ fscanf(pFile,"%s",tmp); // Instant
+ fscanf(pFile,"%s",tmp); // 1
+ instantVector.push_back( atoi(tmp) );
+ fscanf(pFile,"%s",tmp); // 2
+ instantVector.push_back( atoi(tmp) );
+ fscanf(pFile,"%s",tmp); // 3
+ instantVector.push_back( atoi(tmp) );
+ fscanf(pFile,"%s",tmp); // 4
+ instantVector.push_back( atoi(tmp) );
+ fscanf(pFile,"%s",tmp); // 5
+ instantVector.push_back( atoi(tmp) );
+ fscanf(pFile,"%s",tmp); // 6
+ instantVector.push_back( atoi(tmp) );
- fscanf(pFile,"%s",tmp); // TypeContourModel
- fscanf(pFile,"%s",tmp); // ##
- typeContourModel = atoi(tmp);
- manModelContour = kernelManager->factoryManualContourModel(typeContourModel);
- manModelContour->Open(pFile);
+ fscanf(pFile,"%s",tmp); // TypeContourModel
+ fscanf(pFile,"%s",tmp); // ##
+ typeContourModel = atoi(tmp);
- fscanf(pFile,"%s",tmp); // TypeView
- fscanf(pFile,"%s",tmp); // ##
- typeView = atoi(tmp);
+ manModelContour = kernelManager->factoryManualContourModel(typeContourModel);
+ manModelContour->Open(pFile);
+ fscanf(pFile,"%s",tmp); // TypeView
+ fscanf(pFile,"%s",tmp); // ##
+ typeView = atoi(tmp);
-// if (typeView==1)
-// {
-// }
+ // if (typeView==1)
+ // {
+ // }
- std::string theName;
- theName = kernelManager->createOutline( manModelContour, instantVector );
- bool addedModel = theName.compare("") != 0;
- if( addedModel )
- {
- double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
- _theViewPanel->getSpacing(spc);
- //Adding the manualContourControler to interface objects structure
- //Adding the manualViewContour to interface objects structure
- //_theViewPanel->getSceneManager()->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
- _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , typeView) ;
- }
- if (staticContour==true)
- {
- Instant instant(&instantVector);
- kernelManager->changeContourOfManager( theName , &instant );
- }
+ std::string theName;
+ theName = kernelManager->createOutline( manModelContour, instantVector );
+ bool addedModel = theName.compare("") != 0;
+ if( addedModel )
+ {
+ double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
+ _theViewPanel->getSpacing(spc);
+ //Adding the manualContourControler to interface objects structure
+ //Adding the manualViewContour to interface objects structure
+ //_theViewPanel->getSceneManager()->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
+ _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , typeView) ;
+ }
+
+ if (staticContour==true)
+ {
+ Instant instant(&instantVector);
+ kernelManager->changeContourOfManager( theName , &instant );
+ }
- }// for numberOfContours
+ }// for numberOfContours
+ }
+ else if (compatible==false)
+ {
+ wxMessageBox(_T("The actual image is not compatible with the selected Roi file"), _T("Error"), wxICON_ERROR | wxOK);
+ }
}
void wxContourMainFrame::RefreshInterface(){
RefreshInterface();
}
-int wxContourMainFrame::getColorWindow(){
+
+int wxContourMainFrame::getColorWindow()
+{
+ /*
+ double range[2];
+ vtkImageData * img = getImageData();
+ img->GetScalarRange(range);
+
+ std::cout<<"Val 1: "<<range[0]<<" Val 2: "<<range[1]<<std::endl;
+
+ return (int)range[1];
+ */
return _theViewPanel->getColorWindow();
}
-int wxContourMainFrame::getWindowLevel(){
+
+int wxContourMainFrame::getWindowLevel()
+{
+ /*
+ double range[2];
+ vtkImageData * img = getImageData();
+ img->GetScalarRange(range);
+
+ std::cout<<"Val 1: "<<range[0]<<" Val 2: "<<range[1]<<std::endl;
+
+ return (int)range[1];
+ */
return _theViewPanel->getWindowLevel();
}
delete contourextractdata;
}
+//AD: 29-05-09
void wxContourMainFrame::onSaveResults(std::string directory,std::string namefile, std::string filename,
int typeContourGroup, bool XYZValues, bool contourImage, bool statistics)
{
if (statistics)
{
- FILE *pFile=fopen(filename.c_str(),"w+");
+ std::ostringstream name;
+ name << filename << ".xls";
+
+
+ FILE *pFile=fopen(name.str().c_str(),"w+");
int sizeZ = _theViewPanel->GetImageDataSizeZ();
}
}
+//AD: 29-05-09
void wxContourMainFrame::SaveValuesXYZ(std::string directory,std::string namefile,int typeContourGroup)
{
wxBusyCursor wait;