fscanf(pFile,"%s",tmp); // --CreaContour--
fscanf(pFile,"%s",tmp); // Version
- fscanf(pFile,"%s",tmp); // 1.0.1
+ fscanf(pFile,"%s",tmp); // 1.0.2 || 1.0.1 || 1.0.0
std::string version(tmp);
deleteAllContours();
- openContours(pFile,false);
- if (version!="1.0.0"){
- openContours(pFile,true);
+ //AD:02-06-09
+ if (version=="1.0.2")
+ {
+ loadContours(pFile);
+ }
+
+ //AD:02-06-09
+ else if (version=="1.0.1")
+ {
+ loadContours(pFile);
+ }
+
+ //AD:02-06-09
+ else if (version=="1.0.0")
+ {
+ loadContours(pFile);
}
fclose(pFile);
+}
+
+void wxContourMainFrame ::loadContours( FILE *pFile )
+{
+ char tmp[255];
+ fscanf(pFile,"%s",tmp); // NumberOfContours
+ fscanf(pFile,"%s",tmp); // ##
+ int numberOfContours = atoi(tmp);
+
+ std::vector<int> instantVector;
+ int typeContourModel;
+ manualContourModel *manModelContour;
+ int typeView;
- //_theViewPanel->getSceneManager()->removeSceneContours();
- //changeInstant();
+ fscanf(pFile,"%s",tmp); // ImageDimensions
+ fscanf(pFile,"%s",tmp); // X
+ fscanf(pFile,"%s",tmp); // Y
+ fscanf(pFile,"%s",tmp); // Z
+
+ fscanf(pFile,"%s",tmp); // ImageSpacing
+ fscanf(pFile,"%s",tmp); // X
+ fscanf(pFile,"%s",tmp); // Y
+ fscanf(pFile,"%s",tmp); // Z
+ 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); // TypeView
+ fscanf(pFile,"%s",tmp); // ##
+ typeView = atoi(tmp);
+
+ 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) ;
+ }
+ }// for numberOfContours
}
-void wxContourMainFrame::onLoad(){
+void wxContourMainFrame::onLoad()
+{
char tmp[255];
wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxOPEN );
if (dialog.ShowModal() == wxID_OK)
fscanf(pFile,"%s",tmp); // --CreaContour--
fscanf(pFile,"%s",tmp); // Version
- fscanf(pFile,"%s",tmp); // 1.0.1 || 1.0.0
+ fscanf(pFile,"%s",tmp); // 1.0.2 || 1.0.1 || 1.0.0
std::string version(tmp);
//AD:02-06-09
- if (version=="1.0.1")
+ if (version=="1.0.2")
+ {
+ openContours(pFile,2);
+ }
+
+ //AD:02-06-09
+ else if (version=="1.0.1")
{
- openContours(pFile,false);
+ openContours(pFile,1);
}
//AD:02-06-09
else if (version=="1.0.0")
{
- openContours(pFile,true);
+ openContours(pFile,0);
}
-// _theViewPanel->getSceneManager()->openFileWithContours(ff);
fclose(pFile);
}
int i,sizeLstNameThings;
fprintf(pFile,"--CreaContour--\n");
- fprintf(pFile,"Version %s\n", "1.0.1" );
+ fprintf(pFile,"Version %s\n", "1.0.2" );
// Normal Contours
lstNameThings = kernelManager->GetLstNameThings();
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 ){
+//AD:04-06-09
+void wxContourMainFrame::openContours( FILE *pFile, int version )
+{
char tmp[255];
fscanf(pFile,"%s",tmp); // NumberOfContours
fscanf(pFile,"%s",tmp); // ##
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])
+
+ //Version==2
+ if (version==2)
{
- compatible = false;
+ image->GetDimensions(imageDim);
+ image->GetSpacing(imageSpac);
+
+ 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);
+
+ //Compare Spacing and Dims in X and Y (Necessary in Z?) - Just for Version 3
+ if (imageDim[0]!=tempDim[0] || imageDim[1]!=tempDim[1] || imageSpac[0]!=tempSpac[0] || imageSpac[1]!=tempSpac[1])
+ {
+ compatible = false;
+ }
}
if (compatible==true)
fscanf(pFile,"%s",tmp); // ##
typeView = atoi(tmp);
-
- // if (typeView==1)
- // {
- // }
-
-
std::string theName;
theName = kernelManager->createOutline( manModelContour, instantVector );
bool addedModel = theName.compare("") != 0;
_theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , typeView) ;
}
- if (staticContour==true)
+ if (version==0) //StaticContours (will appear in all slices)
{
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);
+ wxDialog* dial = new wxDialog (this,-1,_T("Tools"),wxDefaultPosition, wxSize(250,160));
+ wxSizer* buttonsSizer = dial->CreateSeparatedButtonSizer(wxOK|wxCANCEL);
+ wxBoxSizer *dialSizer = new wxBoxSizer(wxVERTICAL);
+
+ wxString lstOptOperation[2];
+ lstOptOperation[0]=_T("By Dimension");
+ lstOptOperation[1]=_T("By Spacing");
+ wxRadioBox * radioOpts = new wxRadioBox(dial, -1, _T("Type of Transformation"), wxDefaultPosition, wxSize(270,45), 2 , lstOptOperation, 2, wxRA_SPECIFY_COLS);
+
+ dialSizer->Add( new wxStaticText(dial,-1,_T("The actual image is not compatible with the ")) , 0, wxGROW );
+ dialSizer->Add( new wxStaticText(dial,-1,_T("selected Roi file. Do you want to tranform it?")) , 0, wxGROW );
+ dialSizer->Add( new wxStaticText(dial,-1,_T(" ")) , 0, wxGROW );
+ dialSizer->Add(radioOpts,0,wxGROW);
+ dialSizer->Add( new wxStaticText(dial,-1,_T(" ")) , 0, wxGROW );
+ dialSizer->Add(buttonsSizer,0,wxGROW);
+ dial->SetSizer(dialSizer, true);
+ dial->Layout();
+ dial->ShowModal();
+
+ if (dial->GetReturnCode() == wxID_OK)
+ {
+ int typeOfTransformation = radioOpts->GetSelection();
+
+ 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);
+
+ if (typeOfTransformation==0)
+ {
+ manModelContour->OpenAndTransformDimension(pFile, imageDim, tempDim);
+ }
+ else if (typeOfTransformation==1)
+ {
+ manModelContour->OpenAndTransformSpacing(pFile, imageSpac, tempSpac);
+ }
+
+ fscanf(pFile,"%s",tmp); // TypeView
+ fscanf(pFile,"%s",tmp); // ##
+ typeView = atoi(tmp);
+
+ 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 (version==0) //StaticContours (will appear in all slices)
+ {
+ Instant instant(&instantVector);
+ kernelManager->changeContourOfManager( theName , &instant );
+ }
+ }// for numberOfContours
+ }
}
}