SET(USE_VTK ON)
SET(USE_ITK OFF)
SET(USE_BOOST ON)
-SET(USE_WXWIDGETS ON)
-
-OPTION(USE_GDCM "use gdcm" ON)
-OPTION(USE_GDCM2 "use gdcm2" OFF)
+OPTION(USE_WXWIDGETS "Use WxWidgets GUI" ON)
+OPTION(USE_QT4 "USE WxWidgets GUI" OFF)
+OPTION(USE_XERCES "USE Xerces if you want to use an beta version of outputModel" OFF)
+
+IF(USE_QT4)
+ IF(USE_WXWIDGETS)
+ MESSAGE(STATUS "CANNOT USE QT WXWIDGETS IN SAME TIME")
+ ENDIF(USE_WXWIDGETS)
+ENDIF(USE_QT4)
+
+
+OPTION(USE_GDCM ON)
+OPTION(USE_GDCM2 OFF)
MESSAGE(STATUS "GDCM LIB ....= ${GDCM_LIBRARIES}")
IF(USE_GDCM2)
OPTION(USE_GDCM_ANOM "use gdcm2 anonymizer tool" OFF)
#include <creaVtkBasicSlicer.h>
-//
+
//#pragma comment(lib, "creaImageIO.lib")
//#pragma comment(lib, "DelayImp.lib")
//
int output_dim = _3D;
int threads = 1;
-
creaImageIO::WxGimmickReaderDialog w(
0,
std::vector<vtkImageData*> images;
w.GetSelectedImages(images,3);
+
+
+
+
+ std::vector<creaImageIO::OutStrGimmick> out;
+ std::vector<std::string> attr;
+ //attr.push_back("ALL");
+ attr.push_back("D0008_1070");
+ w.getSelected(out, attr,true,"");
+
+
+
// images[1]->UpdateInformation();
/* vtkMetaImageReader *r= vtkMetaImageReader::New();
r->SetFileName("c:\\toto.mhd");
std::cout << "$$$$$$$$$$$$$$$$$$$$ main ended "<<std::endl;
return false;
}
-
-
)
endif()
+
+IF(USE_XERCES)
+FILE(GLOB SOURCES_CREAIMAGEIO_OUTPUT
+ creaImageIOOutputModel.cpp
+ creaImageIOOutputModelParser.cpp
+ )
+SOURCE_GROUP("Source Files\\Output" FILES ${SOURCES_CREAIMAGEIO_OUTPUT})
+ENDIF(USE_XERCES)
+
+
+
+
# Header Files
FILE(GLOB HEADER_CREAIMAGEIO creaImageIOImagePointerHolder.h)
FILE(GLOB SOURCES_CREAIMAGEIO_PACS PACS/*.cpp)
${HEADER_CREAIMAGEIO_PACS}
)
else (BUILD_CREA_PACS)
+IF(USE_XERCES)
SET (SRCS
${PRIMITIVE_SRCS}
+ ${SOURCES_CREAIMAGEIO_OUTPUT}
)
+ELSE(USE_XERCES)
+ SET (SRCS
+ ${PRIMITIVE_SRCS}
+ )
+ENDIF(USE_XERCES)
endif (BUILD_CREA_PACS)
OPTION(${LIBRARY_NAME}_BUILD_SHARED
ADD_LIBRARY(${LIBRARY_NAME} ${CREAIMAGEIO_BUILD_SHARED} ${SRCS})
+IF(USE_QT4)
+TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
+ ${QT_LIBRARIES})
+ENDIF(USE_QT4)
+IF(USE_WXWIDGETS)
+TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
+ ${WXWIDGETS_LIBRARIES})
+ENDIF(USE_WXWIDGETS)
+
+
+IF (NOT USE_XERCES)
TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
${crea_LIBRARIES}
${creaBruker_LIBRARIES}
${GDCM_LIBRARIES}
${BOOST_LIBRARIES}
sqlite3)
-
+ELSE(NOT USE_XERCES)
+TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
+ ${crea_LIBRARIES}
+ ${creaBruker_LIBRARIES}
+ ${WXWIDGETS_LIBRARIES}
+ ${VTK_LIBRARIES}
+ ${GDCM_LIBRARIES}
+ ${BOOST_LIBRARIES}
+ ${XERCES_LIBRARIES}
+ sqlite3)
+ENDIF(NOT USE_XERCES)
+
+
#----------------------------------------------------------------------------
# INSTALLS LIBRARY
FILE(GLOB HEADERS "*.h" "*.txx")
virtual void ReadAttributes(const std::string& filename,
tree::AttributeMapType& attr) {}
+ /// Another function to read attributes for a file
+ virtual void getAttributes(const std::string filename, std::map <std::string , std::string> &infos, std::vector<std::string> i_attr){}
protected:
/// Set the reader's name
v.push_back("dcm");
v.push_back("");
}
- //=====================================================================
-
+
//========================================================================
std::string irclean(const std::string& str)
{
return str;
}
//========================================================================
-
+ //=====================================================================
+
+
+ void DicomImageReader::getAttributes(const std::string filename,
+ std::map <std::string , std::string> &infos,std::vector<std::string> i_attr)
+ {
+ gdcm::Reader reader;
+ reader.SetFileName( filename.c_str() );
+ if (reader.Read())
+ {
+ std::vector<std::string>::iterator it = i_attr.begin();
+ for(;it != i_attr.end(); it++)
+ {
+ unsigned short el;
+ unsigned short gr;
+ sscanf((*it).c_str(),"D%04hx_%04hx",&gr,&el);
+ if ( ( gr!=0 ) && ( el!=0 ) )
+ {
+ infos[(*it)] = ( GetStringValueFromTag(reader.GetFile().GetDataSet().GetDataElement(gdcm::Tag(gr,el))) );
+ }
+ }
+ }
+
+ }
//=====================================================================
void DicomImageReader::ReadAttributes(const std::string& filename,
std::map<std::string,std::string>& attr)
void ReadAttributes2(const std::string& filename,
tree::AttributeMapType& attr);
+ /// Another function to read attributes for a file
+ void getAttributes(const std::string filename, std::map <std::string , std::string> &infos, std::vector<std::string> i_attr);
private:
const std::string GetStringValueFromTag( const gdcm::DataElement& ds);
vtkGDCMImageReader *mReader;
#include <creaImageIOGimmick.h>
-
#include <creaImageIOSystem.h>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
+
//#include "io.h"
#ifndef PATH_MAX // If not defined yet : do it
# define PATH_MAX 2048
}
//========================================================================
+ //========================================================================
+ // get attributes values from database for a given file from database
+ //========================================================================
+ void Gimmick::GetAttributes(const std::string filename, std::map<std::string, std::string> &i_res, OutputAttr i_attr)
+ {
+ if (i_attr.inside.size() > 0)
+ {
+ std::map<std::string, std::string> map_attr;
+ TreeHandler * handler=GetTreeHandler(i_attr.db);
+ handler->getAllAttributes(filename, map_attr);
+ if(i_attr.inside.front() == "ALL") // we take all values
+ {
+ std::map<std::string, std::string>::iterator it = map_attr.begin();
+ for(; it != map_attr.end(); it++)
+ i_res[it->first] = it->second;
+ }
+ else
+ {
+ std::vector<std::string>::iterator it = i_attr.inside.begin();
+ for(; it != i_attr.inside.end(); it++)
+ i_res[(*it)] = map_attr[(*it)];
+ }
+ }
+
+
+ }
+
+
//========================================================================
void Gimmick::UpdateSetting(const std::string& name, const std::string& value)
addDB(name, it_path->c_str());
}
}
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Fill attributes structure with attributes present in database (inside vector
+// and not present (outside)
+///////////////////////////////////////////////////////////////////////////////
+void Gimmick::fillVectInfos(std::vector<std::string> i_attr, OutputAttr &infos)
+{
+ //test if a tag is present in Database descriptor
+ TreeHandler * handler=GetTreeHandler(infos.db);
+ mImageAdder.SetTreeHandler(handler);
+ std::vector<std::string>::const_iterator it = i_attr.begin();
+ for (;it != i_attr.end(); it++)
+ {
+ if( mImageAdder.isAttributeExist((*it)) != "" ) // in DB
+ {
+ infos.inside.push_back((*it));
+ }
+ else
+ {
+ infos.outside.push_back((*it)); // Need to scan again the files
+ }
+ }
}
+
+}
\ No newline at end of file
+
#ifdef _DEBUG
#include <crtdbg.h>
#define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
//=======================================================================
/// Central controler of the gimmick application
+
+
+
+ /// the selected attributes by end-user
+ typedef struct
+ {
+ // name of database to get attributes
+ std::string db;
+ // attributes available in this databse
+ std::vector<std::string> inside;
+ // attributes not available in this databse
+ std::vector<std::string> outside;
+ //
+ bool mult;
+ }OutputAttr;
+
class CREAIMAGEIO_EXPORT Gimmick
{
public:
const std::vector<std::string>& params,
std::vector<std::string>& results);
- ///
+ /// get Values for given attributes
+ void GetAttributes(const std::string filename, std::map<std::string, std::string> &i_res, OutputAttr i_attr);
+
const std::string& GetHomeDirectory();
const std::string& GetUserSettingsDirectory();
void CreateUserSettingsDirectory();
const std::string& GetLocalDatabasePath();
-
-
+ /// Decide if attributes are available through database
+ void fillVectInfos(std::vector<std::string> i_attr, OutputAttr &infos);
//=============================================
private:
SQLiteTreeHandler* mLocalDatabase;
#if defined(USE_GDCM2)
#include <vtkGDCMImageReader.h>
+#include "gdcmSystem.h"
+#include "gdcmCryptographicMessageSyntax.h"
+#include "gdcmUIDGenerator.h"
+#include "gdcmAnonymizer.h"
+#include "gdcmGlobal.h"
#endif
}
else
{
- boost::shared_ptr<ImageExtent> ie=boost::shared_ptr<ImageExtent>(new ImageExtent((*sel).GetAttribute("D0028_0010"),
- (*sel).GetAttribute("D0028_0011"),
- (*sel).GetAttribute("D0028_0012"),
- ""));
+ std::string extentx = (*sel).GetAttribute("D0028_0010");
+ std::string extenty = (*sel).GetAttribute("D0028_0011");
+ std::string extentz = (*sel).GetAttribute("D0028_0012");
+ std::string extentt = (*sel).GetAttribute("D0028_0010");
+ if( extentx == "" && extenty == "" && extentz == "")
+ {
+ // we try to create a vtkImageData just to get dim informations
+ // Long method need to improve it!
+ std::string name = (*sel).GetAttribute("FullFileName");
+ if (name != "")
+ {
+ int dim[3];
+ char c[5];
+ mReader.GetImage(name)->GetDimensions(dim);
+ sprintf(c,"%d", dim[0]);
+ extentx = c;
+ sprintf(c,"%d", dim[1]);
+ extenty = c;
+ sprintf(c,"%d", dim[2]);
+ extentz = c;
+ }
+ }
+
+ boost::shared_ptr<ImageExtent> ie=boost::shared_ptr<ImageExtent>(new ImageExtent(extentx, extenty, extentz,extentt));
if(mImageExtent==0)
{
mImageExtent=ie;
//======================================================================
void GimmickView::modifyValidationSignal(bool ivalid)
{
+
mValidationSignal(ivalid);
}
double spc[3];
first->GetSpacing(spc);
- spc[2]=OrderTheFileNameVector(im);
+
+ // OrderTheFileNameVector is not here anymore.
+ // Try orderFilesWithZSpacing from OutputModel FCY
+ // spc[2]=OrderTheFileNameVector(im);
+ spc[2] =1;
out->SetSpacing(spc);
}
//======================================================================
-#if defined(USE_GDCM)
- double GimmickView::OrderTheFileNameVector(std::vector<std::string> &im)
-{
- double spacing=1;
- typedef std::vector<GDCM_NAME_SPACE::File* > FileList;
- FileList fileVector;
- //GDCM_NAME_SPACE::File *f = GDCM_NAME_SPACE::File::New();
- GDCM_NAME_SPACE::SerieHelper *sh = GDCM_NAME_SPACE::SerieHelper::New();
- std::vector<std::string> lstAux;
- std::vector<std::string>::iterator it;
- for (it=im.begin(); it!=im.end(); ++it)
+
+
+ //////////////////////////////////////////////////////////
+ // Test if the image is a multiple or single frame.
+ // For the moment only with the creation of vtkImageDta.
+ // TO DO with image size and dim!!!
+ //////////////////////////////////////////////////////////
+ bool GimmickView::isSingle(const std::string i_file)
{
- ///\TODO liberer les GDCM_NAME_SPACE::File a la fin! // JPR
- GDCM_NAME_SPACE::File *f = GDCM_NAME_SPACE::File::New();
- f->SetFileName(*it);
- f->Load();
- if (f->IsReadable())
+ bool bres = true;
+ vtkImageData* first = mReader.GetImage( i_file);
+ int dim[3];
+ first->GetDimensions(dim);
+ if (dim[3] > 1)
{
- fileVector.push_back(f);
- } else {
- lstAux.push_back(*it);
+ bres = false;
}
- } // for
-
+ else
+ {
+ }
+ return bres;
+ }
+
+ //////////////////////////////////////////////////////////
+ // get Attributes values for a file
+ //////////////////////////////////////////////////////////
- if ((fileVector.size()>1) && (sh->IsCoherent( &fileVector )))
+ void GimmickView::getAttributes(const std::string i_file, std::map<std::string, std::string> &o_infos, OutputAttr i_attr)
{
- sh->OrderFileList(&fileVector);
- spacing= sh->GetZSpacing();
- im.clear();
- int i;
- for (i=0; i<fileVector.size(); i++)
- {
- im.push_back( (fileVector[i])->GetFileName() );
- }
- for (i=0; i<lstAux.size(); i++)
+ if(i_attr.inside.size() >0)
+ {
+ mGimmick->GetAttributes(i_file,o_infos,i_attr);
+ }
+ if(i_attr.outside.size()>0)
+ {
+ mReader.getAttributes(i_file,o_infos, i_attr.outside);
+ }
+ }
+
+ //////////////////////////////////////////////////////////
+ // create an output structure with n entries = n output
+ //////////////////////////////////////////////////////////
+ void GimmickView::readImages1(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
+ OutputAttr i_attr)
+ {
+ std::vector<std::string>::iterator it;
+ for (it=im.begin(); it!=im.end(); ++it)
+ {
+ OutStrGimmick out;
+ out.img = vtkImageData::New();
+ out.img->ShallowCopy(mReader.GetImage(*it));
+ if(i_attr.mult)
+ getAttributes((*it),out.infos,i_attr);
+ o_output.push_back(out);
+ }
+ // If we want only one output information structure, we set it outside the loop
+ if(!i_attr.mult)
+ {
+ getAttributes(im.front(), o_output.front().infos,i_attr);
+ }
+
+ }
+
+ //////////////////////////////////////////////////////////
+ // create an output structure with n entries = 1 output
+ //////////////////////////////////////////////////////////
+ void GimmickView::readImages3(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
+ OutputAttr i_attr, double i_zspc)
+ {
+ OutStrGimmick out;
+ vtkImageData* first = mReader.GetImage( im.front());
+ out.img = vtkImageData::New();
+ out.img->SetScalarType(first->GetScalarType());
+ out.img->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
+ int ext[6];
+ first->GetWholeExtent(ext); // send also 0,0 in Z
+ if(ext[5] == 0)
+ {
+ ext[5] = im.size()-1;
+ }
+ else
+ {
+ ext[5] = ext[5] * im.size()-1; // to deal with multiframes
+ }
+ out.img->SetExtent(ext);
+ int dim[3];
+ first->GetDimensions(dim);
+ out.img->SetDimensions(dim[0], dim[1], im.size() );
+ out.img->AllocateScalars();
+ out.img->Update();
+ unsigned long imsize = dim[0] * dim[1];
+ imsize = imsize * dim[2] ; // deal with multiframes here
+ // differents formats char , short, etc...
+ // differents components 1..3 ex. jpg ->RGB 3
+ imsize = imsize * first->GetScalarSize() * first->GetNumberOfScalarComponents();
+ // Order the file name vector already did with the OutputModel!!!
+ //!!!!out.img->SetSpacing(i_zspc);
+ int slice = 0;
+ std::vector<std::string>::iterator it;
+ for (it=im.begin(); it!=im.end(); ++it)
+ {
+ vtkImageData* cur = mReader.GetImage( (*it) );
+ memcpy(out.img->GetScalarPointer(0,0,slice), cur->GetScalarPointer(0,0,0), imsize);
+ slice++;
+ }
+ getAttributes(im.front(),out.infos, i_attr);
+ o_output.push_back(out);
+ }
+
+
+ // TO DO NO VERY SURE : NEED TO BE TESTED
+ //////////////////////////////////////////////////////////
+ // create an output structure with n entries (T size) = T output (n size)
+ //////////////////////////////////////////////////////////
+ void GimmickView::readImages2(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
+ OutputAttr i_attr, double i_zspc)
+ {
+ vtkImageData* first = mReader.GetImage( im.front());
+ int dim[3];
+ first->GetDimensions(dim);
+ // differents formats char , short, etc...
+ // differents components 1..3 ex. jpg ->RGB 3
+ unsigned long imsize = dim[0] * dim[1];
+ imsize = imsize * first->GetScalarSize() * first->GetNumberOfScalarComponents();
+
+ // Order the file name vector already did with the OutputModel!!!
+ std::vector<std::string>::iterator it;
+ std::vector<OutStrGimmick>::iterator it_out = o_output.begin();
+
+ for (it=im.begin(); it!=im.end(); ++it, it_out += dim[2])
+ {
+ vtkImageData* cur = mReader.GetImage( (*it) );
+ for (int slice= 0 ; slice <dim[2]; slice++)
{
- im.push_back( lstAux[i] );
+ OutStrGimmick out;
+ out.img = vtkImageData::New();
+ out.img->SetScalarType(first->GetScalarType());
+
+ out.img->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
+ int ext[6];
+ first->GetWholeExtent(ext); // send also 0,0 in Z
+ ext[5] = 0;
+ out.img->SetExtent(ext);
+
+ out.img->SetDimensions(dim[0], dim[1], 1 );
+ out.img->AllocateScalars();
+ out.img->Update();
+ memcpy(out.img->GetScalarPointer(0,0,0), cur->GetScalarPointer(0,0,slice), imsize);
+ o_output.push_back(out);
}
- }else {
- std::sort( im.begin(), im.end() );
+ if(i_attr.mult)
+ getAttributes((*it),(*it_out).infos,i_attr);
+ }
+ if(!i_attr.mult)
+ {
+ getAttributes(im.front(), o_output.front().infos,i_attr);
+ }
+
}
+
+ //////////////////////////////////////////////////////////
+ // create an output structure with n entries (T size) = T + n output
+ //////////////////////////////////////////////////////////
+ void GimmickView::readImages4(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
+ OutputAttr i_attr)
+ {
+ std::vector<std::string>::iterator it;
+ std::vector<OutStrGimmick>::iterator it_out = o_output.begin();
+ vtkImageData* first = mReader.GetImage( im.front());
+ int dim[3];
+ first->GetDimensions(dim);
- return spacing;
-}
+ for (int slice= 0 ; slice <dim[2]; slice++)
+ {
+ OutStrGimmick out;
+ out.img = vtkImageData::New();
+ out.img->SetScalarType(first->GetScalarType());
+ out.img->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
+
+ int ext[6];
+ first->GetWholeExtent(ext); // send also 0,0 in Z
+ ext[5] = 0;
+ out.img->SetExtent(ext);
+
+ out.img->SetDimensions(dim[0], dim[1], im.size() );
+ out.img->AllocateScalars();
+ out.img->Update();
+ unsigned long imsize = dim[0] * dim[1];
+ imsize = imsize * first->GetScalarSize() * first->GetNumberOfScalarComponents();
+ int index = 0;
+
+ for (it=im.begin(); it!=im.end(); ++it, index ++)
+ {
+ vtkImageData* cur = mReader.GetImage( (*it) );
+ memcpy(out.img->GetScalarPointer(0,0,index), cur->GetScalarPointer(0,0,slice), imsize);
+ o_output.push_back(out);
+ }
+ }
+ if(!i_attr.mult) // No sense to take informations in all images
+ {
+ getAttributes(im.front(), o_output.front().infos,i_attr);
+ }
+ }
-#endif
-#if defined(USE_GDCM2)
- // TO DO
- double GimmickView::OrderTheFileNameVector(std::vector<std::string> &im)
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Global function to read Images and create wished output (informations, multiple, type and size of output...)
+// In function of type (file, vector) and size, the correct readImages function is selected
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ void GimmickView::readImages(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
+ OutputAttr i_attr, int i_dim, double i_zspc)
{
- return 1;
+ int size = im.size();
+ if ( size == 0)
+ {
+ return;
+ }
+ else if (size == 1)
+ {
+ // Simplest case
+ // Only one image : give it
+ // But take in count multiframe possibility
+ if ( isSingle(im.front()) || i_dim != 1)
+ {
+ readImages1(o_output,im, i_attr);
+ }
+ else
+ {
+ readImages2(o_output,im, i_attr,i_zspc);
+ }
+
+ }
+ else
+ {
+ // multiple or single frame
+ if ( isSingle(im.front()) )
+ {
+ //we deal with 2D images
+ if(i_dim == 1)
+ {
+ // 2D to 3D
+ readImages3(o_output,im, i_attr,i_zspc);
+ }
+ else
+ {
+ readImages1(o_output,im, i_attr);
+ }
+ }
+ else
+ {
+ // we deal with multiple frames n x (2D x T)
+ // Differents outputs are avaialable
+ if(i_dim == 1)
+ {
+ // put all in one output
+ readImages3(o_output,im, i_attr,i_zspc);
+
+ }
+ else if( i_dim == 2)
+ {
+ // put in a vector of n x T (2D)
+ readImages2(o_output,im, i_attr,i_zspc);
+ }
+ else if( i_dim == 3)
+ {
+ // put in a vector of n (2D x T)
+ // No transformations.
+ readImages1(o_output,im, i_attr);
+ }
+ else
+ {
+ // put in a vector of T (2D x n)
+ readImages4(o_output,im, i_attr);
+ }
+ }
+ }
}
-#endif
-//======================================================================
+
+
void GimmickView::ReadImagesNotThreadedInVector(std::vector<vtkImageData*>& s, std::vector<std::string> im, int dimension)
mValidationSignal.connect(callback);
}
-} // EO namespace creaImageIO
-//////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
//void GimmickView::Anonymize(std::vector<std::string> i_filenames, int type)
+//{
+//
+// gdcm::FileMetaInformation::SetSourceApplicationEntityTitle( "gdcmanon" );
+// gdcm::Global& g = gdcm::Global::GetInstance();
+// //if( !resourcespath )
+// // {
+// // const char *xmlpathenv = getenv("GDCM_RESOURCES_PATH");
+// // if( xmlpathenv )
+// // {
+// // // Make sure to look for XML dict in user explicitly specified dir first:
+// // xmlpath = xmlpathenv;
+// // resourcespath = 1;
+// // }
+// // }
+// // if( resourcespath )
+// // {
+// // // xmlpath is set either by the cmd line option or the env var
+// // if( !g.Prepend( xmlpath.c_str() ) )
+// // {
+// // std::cerr << "Specified Resources Path is not valid: " << xmlpath << std::endl;
+// // return 1;
+// // }
+// // }
+// // All set, then load the XML files:
+// if( !g.LoadResourcesFiles() )
+// {
+// return ;
+// }
+// const gdcm::Defs &defs = g.GetDefs(); (void)defs;
+// if( !rootuid )
+// {
+// // only read the env var if no explicit cmd line option
+// // maybe there is an env var defined... let's check
+// const char *rootuid_env = getenv("GDCM_ROOT_UID");
+// if( rootuid_env )
+// {
+// rootuid = 1;
+// root = rootuid_env;
+// }
+// }
+// if( rootuid )
+// {
+// // root is set either by the cmd line option or the env var
+// if( !gdcm::UIDGenerator::IsValid( root.c_str() ) )
+// {
+// std::cerr << "specified Root UID is not valid: " << root << std::endl;
+// return 1;
+// }
+// gdcm::UIDGenerator::SetRoot( root.c_str() );
+// }
+//
+// if(type == 0)
// {
- //if(type == 0)
- //{
- // // Get private key/certificate
- // gdcm::CryptographicMessageSyntax cms;
- //if( !dumb_mode )
- // {
- // if( !GetRSAKeys(cms, rsa_path.c_str(), cert_path.c_str() ) )
- // {
- // return 1;
- // }
- // cms.SetCipherType( ciphertype );
- // }
-
- //// Setup gdcm::Anonymizer
- //gdcm::Anonymizer anon;
- //if( !dumb_mode )
- // anon.SetCryptographicMessageSyntax( &cms );
-
- //if( dumb_mode )
- // {
- // for(unsigned int i = 0; i < nfiles; ++i)
- // {
- // const char *in = filenames[i].c_str();
- // const char *out = outfilenames[i].c_str();
- // if( !AnonymizeOneFileDumb(anon, in, out, empty_tags, remove_tags, replace_tags_value) )
- // {
- // //std::cerr << "Could not anonymize: " << in << std::endl;
- // return 1;
- // }
- // }
- // }
- //else
- // {
- // for(unsigned int i = 0; i < nfiles; ++i)
- // {
- // const char *in = filenames[i].c_str();
- // const char *out = outfilenames[i].c_str();
- // if( !AnonymizeOneFile(anon, in, out) )
- // {
- // //std::cerr << "Could not anonymize: " << in << std::endl;
- // return 1;
- // }
- // }
- // }
-// }
\ No newline at end of file
+// // Get private key/certificate
+// gdcm::CryptographicMessageSyntax cms;
+// if( !dumb_mode )
+// {
+// if( !GetRSAKeys(cms, rsa_path.c_str(), cert_path.c_str() ) )
+// {
+// return 1;
+// }
+// cms.SetCipherType( ciphertype );
+// }
+//
+// // Setup gdcm::Anonymizer
+// gdcm::Anonymizer anon;
+// if( !dumb_mode )
+// anon.SetCryptographicMessageSyntax( &cms );
+//
+// if( dumb_mode )
+// {
+// for(unsigned int i = 0; i < nfiles; ++i)
+// {
+// const char *in = filenames[i].c_str();
+// const char *out = outfilenames[i].c_str();
+// if( !AnonymizeOneFileDumb(anon, in, out, empty_tags, remove_tags, replace_tags_value) )
+// {
+// //std::cerr << "Could not anonymize: " << in << std::endl;
+// return 1;
+// }
+// }
+// }
+// //else
+// // {
+// // for(unsigned int i = 0; i < nfiles; ++i)
+// // {
+// // const char *in = filenames[i].c_str();
+// // const char *out = outfilenames[i].c_str();
+// // if( !AnonymizeOneFile(anon, in, out) )
+// // {
+// // //std::cerr << "Could not anonymize: " << in << std::endl;
+// // return 1;
+// // }
+// // }
+// // }
+// }
+//}
+//
+} // EO namespace creaImageIO
\ No newline at end of file
namespace creaImageIO
{
+
+ typedef struct
+ {
+ vtkImageData *img;
+ std::map<std::string, std::string> infos;
+ }OutStrGimmick;
+
+
/**
* \ingroup View
*/
{ GimmickError("INTERNAL ERROR : EditFields not implemented"); }
/// Anonymize or de-anonymize data
- void Anonymize(std::vector<std::string> i_filenames, int type);
-
+ virtual void Anonymize(std::vector<std::string> i_filenames, int type)
+ { GimmickError("INTERNAL ERROR : Anonymize not implemented"); }
/// Display all Dicom Tags
virtual void DumpTags(const std::string filename)
void modifyValidationSignal(bool ivalid);
+
+ void readImages(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
+ OutputAttr i_attr, int i_dim, double i_zspc);
+ bool isSingle(const std::string i_file);
private:
- double OrderTheFileNameVector(std::vector<std::string> &im);
+
+ typedef void (*readXD)(std::vector<OutStrGimmick>&, std::vector<std::string>, OutputAttr, double);
+
+ void getAttributes(const std::string i_file, std::map<std::string, std::string> &o_infos, OutputAttr i_attr);
+
+ virtual void readImages2(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
+ OutputAttr i_attr, double i_zspc);
+
+ virtual void readImages3(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
+ OutputAttr i_attr, double i_zspc);
+
+ virtual void readImages4(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
+ OutputAttr i_attr);
+
+ virtual void readImages1(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
+ OutputAttr i_attr);
+
/// Controller which manages the interaction with the model
boost::shared_ptr< Gimmick> mGimmick;
return i;
}
//=====================================================================
-
-
+ // Another function to read attributes for a file
+ void ImageReader::getAttributes(const std::string filename,
+ std::map <std::string , std::string> &infos, std::vector<std::string> i_attr)
+ {
+ if (mLastFilename!=filename)
+ {
+ if (!CanRead(filename))
+ {
+ return;
+ }
+ }
+ mLastReader->getAttributes(filename, infos, i_attr);
+ }
//=====================================================================
void ImageReader::ReadAttributes(const std::string& filename,
std::map<std::string,std::string>& attr)
/// Exclude specific readers
/// TO DO...
+ /// Another function to read attributes for a file
+ void getAttributes(const std::string filename,
+ std::map <std::string , std::string> &infos, std::vector<std::string> i_attr);
+
protected:
/// Register a reader
}
}
//=====================================================================
+ // function to read attributes for a file
+ void MultiThreadImageReader::getAttributes(const std::string filename,
+ std::map <std::string , std::string> &infos,std::vector<std::string> i_attr)
+ {
+ mReader->getAttributes(filename, infos, i_attr);
+ }
//=====================================================================
void MultiThreadImageReader::Request( MultiThreadImageReaderUser* user,
void OnMultiThreadImageReaderEvent( const std::string& filename,
EventType type,
vtkImageData* image);
-
+
+ /// Function to read attributes for a file
+ void getAttributes(const std::string filename, std::map <std::string , std::string> &infos, std::vector<std::string> i_attr);
+
protected:
bool mDone;
int GetMaximalPriorityWithoutLocking();
int& UnloadIndex() { return mUnloadIndex; }
vtkImageData* GetImage() const { return mImage; }
void SetImage( vtkImageData* i ) { mImage=i; }
+
+ std::map<std::string, std::string> getAttributes(const std::vector<std::string> i_attr);
private:
MultiThreadImageReaderUser* mUser;
std::string mFilename;
#include <creaImageIOSQLiteTreeHandler.h>
#include <creaImageIOSystem.h>
#include <creaImageIOGimmick.h>
-#include <creaImageIOTree.h>
#include "CppSQLite3.h"
command += "\n)";
UPDATEDB(command);
+ GetTree().CopyAttributeDescriptorList(l);
// Add Attribute 'ID' to Description
GetTree().GetDescriptor().Add
return false;
}
+ GetTree().CopyAttributeDescriptorList(level);
}
{
std::string query = "DELETE FROM ";
-
-
- query += GetTree().GetLevelDescriptor(node->GetLevel()).GetName();
-
+ query += GetTree().GetLevelDescriptor(node->GetLevel()).GetName();
query += " WHERE ID='"+ node->GetAttribute("ID") + "';";
-
- UPDATEDB(query);
- GimmickDebugMessage(2,
- " Deleting '"
- <<node->GetLabel()<<"' with ID '"
- <<node->GetAttribute("ID")
- <<"' in level "<< GetTree().GetLevelDescriptor(node->GetLevel()).GetName()
- <<std::endl);
-
-
+ UPDATEDB(query);
+
if(node->GetNumberOfChildren()!=0)
{
Node::ChildrenListType::iterator i;
return nb;
}
- //=====================================================================
- void SQLiteTreeHandler::GetTopLevelNodeId(const std::string& searchParam, const std::string& searchValue, std::string& parent_id)
+//=====================================================================
+// get all attributes from database for a given file
+ void SQLiteTreeHandler::getAllAttributes(std::string i_filename, std::map<std::string, std::string> &i_results)
{
int level=GetTree().GetNumberOfLevels()-1;
- std::string sp=searchParam.c_str();
- std::string sv=searchValue.c_str();
+
+ std::string search = i_filename;
+ std::string param = "FullFileName";
+ std::string name;
+ std::string id;
+ std::set<std::string> pid;
+ std::vector<AttributeDescriptor> attr;
+ std::vector<AttributeDescriptor>::iterator it_attr;
+ std::vector<std::string> values;
+ std::vector<std::string>::iterator it_val;
+
+
+
+
while(level>1)
{
- std::stringstream out;
- std::stringstream results;
- out<<"SELECT PARENT_ID FROM "<<GetTree().GetLevelDescriptor(level).GetName();
- out<<" WHERE "<<sp<<"='"<<sv<<"'";
- CppSQLite3Query q;
- QUERYDB(out.str(),q);
-
-
- while (!q.eof())
- {
+ attr = GetTree().GetAttributeDescriptorList(level,1);
+
+ name = GetTree().GetLevelDescriptor(level).GetName();
+ std::vector<std::string> values;
+ GetUpLevelNodeId(level, param,search,id);
+ GetAttributes(name, param,search,attr, values);
+ for(it_attr = attr.begin(), it_val = values.begin(); it_attr != attr.end(); it_attr++, it_val++)
+ {
+ i_results[(*it_attr).GetKey()] = (*it_val).c_str();
+ }
+ search = id;
+ param = "ID";
+ level --;
+ }
+ }
+
+
+//=====================================================================
+// get selected attributes from database for a given file
+ void SQLiteTreeHandler::GetAttributes(std::string name, std::string i_id, std::string i_value, tree::LevelDescriptor::AttributeDescriptorListType i_attr, std::vector<std::string> &i_results)
+ {
+ //SELECT t1.ArtistName,CDs.Title FROM Artists t1, CDs WHERE t1.ArtistID=CDs.ArtistID
+ std::stringstream out;
+ std::stringstream results;
+ out<<"SELECT ";
+ tree::LevelDescriptor::AttributeDescriptorListType::iterator it = i_attr.begin();
+ std::string query ="";
+ for(; it != i_attr.end(); it++)
+ {
+ query += (*it).GetKey();
+ query +=" ,";
+ }
+ query = query.substr(0, query.size()-1);
+ out << query;
+ out << "FROM "<<name;
+ out<<" WHERE "<<i_id <<"='"<<i_value<<"'";
+ CppSQLite3Query q;
+ QUERYDB(out.str(),q);
+ while (!q.eof())
+ {
for (int fld = 0; fld < q.numFields(); fld++)
{
- results<<q.getStringField(fld);
+ i_results.push_back(q.getStringField(fld));
}
q.nextRow();
+ }
+ }
+
+ void SQLiteTreeHandler::GetUpLevelNodeId(int level, const std::string& searchParam, const std::string& searchValue, std::string& parent_id)
+ {
+ std::string sp=searchParam.c_str();
+ std::string sv=searchValue.c_str();
+ std::stringstream out;
+ std::stringstream results;
+ out<<"SELECT PARENT_ID FROM "<<GetTree().GetLevelDescriptor(level).GetName();
+ out<<" WHERE "<<sp<<"='"<<sv<<"'";
+ CppSQLite3Query q;
+ QUERYDB(out.str(),q);
+ while (!q.eof())
+ {
+ for (int fld = 0; fld < q.numFields(); fld++)
+ {
+ results<<q.getStringField(fld);
}
- level=level-1;
- sp="ID";
- sv=results.str();
+ q.nextRow();
+ }
+ parent_id = results.str();
+
+ }
+
+
+ //=====================================================================
+ void SQLiteTreeHandler::GetTopLevelNodeId(const std::string& searchParam, const std::string& searchValue, std::string& parent_id)
+ {
+ int level=GetTree().GetNumberOfLevels()-1;
+ std::string sp=searchParam.c_str();
+ std::string sv=searchValue.c_str();
+
+ while(level>1)
+ {
+ GetUpLevelNodeId(level, sp, sv, parent_id);
+ level--;
+ sp = "ID";
+ sv = parent_id;
}
- parent_id=sv;
+///*
+// std::stringstream out;
+// std::stringstream results;
+// out<<"SELECT PARENT_ID FROM "<<GetTree().GetLevelDescriptor(level).GetName();
+// out<<" WHERE "<<sp<<"='"<<sv<<"'";
+// CppSQLite3Query q;
+// QUERYDB(out.str(),q);
+//
+//
+// while (!q.eof())
+// {
+// for (int fld = 0; fld < q.numFields(); fld++)
+// {
+// results<<q.getStringField(fld);
+// }
+// q.nextRow();
+// }*/
+// level=level-1;
+// sp="ID";
+// sv=results.str();
+// }
+// parent_id=sv;
}
#define __creaImageIOSQLiteTreeHandler_h_INCLUDED__
#include <creaImageIOTreeHandler.h>
+#include <creaImageIOTree.h>
class CppSQLite3DB;
const std::string i_val);
//====================================================================
-
+ /// get all attributes from database for a given file
+ void getAllAttributes(std::string i_filename, std::map<std::string, std::string> &i_results);
+
+ /// get selected attributes from database for a given file
+ void GetAttributes(std::string name, std::string i_id, std::string i_value, tree::LevelDescriptor::AttributeDescriptorListType i_attr, std::vector<std::string> &i_results);
+
+ /// get Id for the up level node
+ void GetUpLevelNodeId(int level, const std::string& searchParam, const std::string& searchValue, std::string& parent_id);
-
protected:
//======================================================================
/// Open the database
Keys.push_back(SETTINGS_SYNC_FREQ);
Keys.push_back(SETTINGS_COPY_PATH);
Keys.push_back(SETTINGS_REMOVE_PATIENT_DISPLAY);
+ Keys.push_back(SETTINGS_OUTPUT_ASK);
+ Keys.push_back(SETTINGS_OUTPUT_DIM);
readSettings(Keys, sets);
}
m_SettingsMap[SETTINGS_DICOM_LIBRARY] = "gdcm";
m_SettingsMap[SETTINGS_COPY_PATH] = m_SettingsFileName.substr(0,m_SettingsFileName.find_last_of('\\')+1)+"Copied files";
m_SettingsMap[SETTINGS_REMOVE_PATIENT_DISPLAY] = "0";
+ m_SettingsMap[SETTINGS_OUTPUT_ASK] ="true";
+ m_SettingsMap[SETTINGS_OUTPUT_DIM] = "1";
writeSettingsFile();
}
#define SETTINGS_DBPATH "<dbpath>"
#define SETTINGS_COPY_PATH "<copy_path>"
#define SETTINGS_REMOVE_PATIENT_DISPLAY "<remove_patient>"
+#define SETTINGS_OUTPUT_ASK "<output_ask>"
+#define SETTINGS_OUTPUT_DIM "<output_dim>"
namespace creaImageIO
{ return GetDescriptor().GetLevelDescriptor(level); }
/// Returns the AttributeDescriptorList of a given level (const ref)
+ /// type = 0 all attributes
+ /// type = 1 without ID and PATIENT_ID
const LevelDescriptor::AttributeDescriptorListType&
- GetAttributeDescriptorList(int level) const
- { return GetDescriptor().GetAttributeDescriptorList(level); }
+ GetAttributeDescriptorList(int level, int type = 0) const
+ { return GetDescriptor().GetAttributeDescriptorList(level, type); }
virtual void Print() const;
+
+ /// Copy descriptor list without ID tag
+ void CopyAttributeDescriptorList(int level)
+ {
+ GetDescriptor().CopyAttributeDescriptorList(level);
+ }
+
+ /// Test if this attribute is available in this tree description
+ const std::string isAttributeExist(const std::string i_attr)
+ {
+ return mDescriptor.isExist(i_attr);
+ }
+
private:
Descriptor mDescriptor;
}
}
}
+
+
+ //==================================================================
+ // test if an attribute is present in DescriptionList
+ // return level's name
+ const std::string Descriptor::isExist(const std::string i_attr)
+ {
+ std::string name = "";
+ LevelDescriptorListType::const_iterator l = GetLevelDescriptorList().begin();
+ for (; l!= GetLevelDescriptorList().end(); ++l)
+ {
+ LevelDescriptor::AttributeDescriptorListType::const_iterator a = l->GetAttributeDescriptorList().begin();
+ for(;a!= l->GetAttributeDescriptorList().end(); ++a)
+ {
+ if (a->GetKey() == i_attr)
+ {
+ name = l->GetName();
+ break;
+ }
+ }
+ }
+ return name.c_str();
+ }
}
}
{ return mLevelDescriptorList[level]; }
/// Returns the AttributeDescriptorList of a given level (const ref)
+ /// type = 0 all attributes
+ /// type = 1 without ID and PATIENT_ID
const LevelDescriptor::AttributeDescriptorListType&
- GetAttributeDescriptorList(int level) const
- { return mLevelDescriptorList[level].GetAttributeDescriptorList(); }
+ GetAttributeDescriptorList(int level, int type = 0) const
+ { return mLevelDescriptorList[level].GetAttributeDescriptorList(type); }
+
+ /// Copy the AttributeDescriptorList without ID tag
+ void CopyAttributeDescriptorList(int level)
+ {
+ mLevelDescriptorList[level].CopyAttributeDescriptorList();
+ }
/// Adds a LevelDescriptor at the end of the list
void Add(const LevelDescriptor&);
//Create Attribute Descriptors from a file
void createDescriptorfromFile(const std::string &i_file);
+
+ /// test if an attribute is present in DescriptionList
+ /// return level's name
+ const std::string Descriptor::isExist(const std::string i_attr);
+
private:
LevelDescriptorListType mLevelDescriptorList;
/// Creates the mandatory level 0 descriptor called "Root"
const std::string i_val){}
//====================================================================
-
+ /// get all attributes for a file
+ virtual void getAllAttributes(std::string i_filename, std::map<std::string, std::string> &i_results) =0;
private:
/// The handled tree
INVALID_FILE_SEPARATOR ,
VALID_FILE_SEPARATOR);
i_sc.ReadAttributes(itr->string(),attr);
- mTreeHandler->GetTopLevelNodeId("FullFileName",itr->string(),parent_id);
+ // mTreeHandler->GetTopLevelNodeId("FullFileName",itr->string(),parent_id);
mTreeHandler->AddBranch(attr);
mProgress.IncNumberHandledFiles();
std::stringstream removedOn;
{
mProgress.IncNumberHandledFiles();
AddFile( itr->string() );
- mTreeHandler->GetTopLevelNodeId("FullFileName",itr->string(),parent_id);
+ //mTreeHandler->GetTopLevelNodeId("FullFileName",itr->string(),parent_id);
std::stringstream removedOn;
removedOn<<time(0);
mSynchronizer->InsertIgnoreFile(addKey, itr->string(),"0",removedOn.str(),mCurrentDB);
}
}
-
+ //=======================================================================
+ const std::string TreeHandlerImageAdder::isAttributeExist(const std::string i_attr)
+ {
+ return mTreeHandler->GetTree().isAttributeExist(i_attr);
+ }
+
}
void GetAttributes(const std::vector<std::string>& params,
const std::string& filename,
std::vector<std::string>& results);
-
+
+ /// Test if an attribute is referenced for a given treeHandler
+ const std::string isAttributeExist(const std::string i_attr);
}
}
-
+ // Copy the descriptor List without ID and PATIENT_ID attributes
+ void LevelDescriptor::CopyAttributeDescriptorList()
+ {
+ mAttributeDescriptorListWID = mAttributeDescriptorList;
+ for(AttributeDescriptorListType::iterator it = mAttributeDescriptorListWID.begin();
+ it != mAttributeDescriptorListWID.end(); it++)
+ {
+ if((*it).GetKey() == "ID")
+ {
+ mAttributeDescriptorListWID.erase(it);
+ break;
+ }
+ }
+
+ for(AttributeDescriptorListType::iterator it = mAttributeDescriptorListWID.begin();
+ it != mAttributeDescriptorListWID.end(); it++)
+ {
+ if((*it).GetKey() == "PARENT_ID")
+ {
+ mAttributeDescriptorListWID.erase(it);
+ break;
+ }
+ }
+ }
}
}
typedef std::vector<AttributeDescriptor> AttributeDescriptorListType;
/// Returns the list of AttributeDescriptor (const)
- const AttributeDescriptorListType& GetAttributeDescriptorList() const
- { return mAttributeDescriptorList; }
+ /// type = 0 all attributes
+ /// type = 1 without ID and PATIENT_ID
+ const AttributeDescriptorListType& GetAttributeDescriptorList(int type = 0) const
+ { if (type == 0)
+ return mAttributeDescriptorList;
+ else
+ return mAttributeDescriptorListWID;
+ }
+
+ /// Copy the original list of attributes
+ void CopyAttributeDescriptorList();
/// \return The list of attributes with flag IDENTIFIER set
const std::vector<std::string>& GetIdentifierList() const
private:
std::string mName;
+ // Attributes List for this level
AttributeDescriptorListType mAttributeDescriptorList;
+ // Attributes List for this level without ID and PARENT_ID attributes
+ AttributeDescriptorListType mAttributeDescriptorListWID;
/// The list of attributes with flag IDENTIFIER set
std::vector<std::string> mIdentifierList;
/// The list of attributes with flag LABEL set
fread(header, sizeof(int), HEADER_SIZE, Ultrasonix_file);
if (ferror(Ultrasonix_file))
return false;
- h.type = header[0];
- h.frame = header[1];
- h.height = header[2];
- h.width = header[3];
+ h.type = header[1];
+ h.frame = header[2];
+ h.height = header[3];
+ h.width = header[4];
h.frequency = header[14];
h.samplingRate = header[15];
//free(header);
fseek(Ultrasonix_file,0,SEEK_END); // go to end of file
if (h.type == TYPE_RF)
size = (ftell(Ultrasonix_file) - (HEADER_SIZE+h.frame) * sizeof(int)) / sizeof(short);
- else if (h.type == TYPE_B8)
- size = (ftell(Ultrasonix_file) - HEADER_SIZE * sizeof(int)) / sizeof(char);
+ else if (h.type == 1)//TYPE_B8)
+ size = (ftell(Ultrasonix_file) - (HEADER_SIZE+h.frame+4) * sizeof(int)) / sizeof(char);
else if (h.type == TYPE_B32)
size = (ftell(Ultrasonix_file) - HEADER_SIZE * sizeof(int)) / sizeof(int);
// check if the data size corresponds to the dimensions of the images
if (size == h.width * h.height * h.frame)
ok = true;
-
+
fclose(Ultrasonix_file);
}
return ok;
}
//=====================================================================
+ void UltrasonixImageReader::getAttributes(const std::string filename,
+ std::map <std::string , std::string> &infos, std::vector<std::string> i_attr)
+ {
+ //TO DO
+ }
//=====================================================================
vtkImageData* UltrasonixImageReader::ReadImage(const std::string& filename)
virtual void ReadAttributes(const std::string& filename,
tree::AttributeMapType& attr);
+ virtual void getAttributes(const std::string filename,
+ std::map <std::string , std::string> &infos, std::vector<std::string> i_attr);
+
};
//=====================================================================
}*/
}
//=====================================================================
-
+ void VtkImageReader::getAttributes(const std::string filename,
+ std::map <std::string , std::string> &infos, std::vector<std::string> i_attr)
+ {
+ }
//=====================================================================
vtkImageData* VtkImageReader::ReadImage(const std::string& filename)
{
virtual void ReadAttributes(const std::string& filename,
tree::AttributeMapType& attr);
+ virtual void getAttributes(const std::string filename,
+ std::map <std::string , std::string> &infos, std::vector<std::string> i_attr);
private:
vtkImageReader2* mReader;
std::string mExtensions;
/// Storage name
std::string m_name;
+
};
}
#endif // USE_WIDGETS
mView->GetSelectedImagesInVector(s, dim);
}
+
+
void OnSelectedImage(bool t);
void AddImagesToDB(std::string dir);
void GetSelectedImagesInVector(std::vector<vtkImageData*>& s, int dim)
{ mView->GetSelectedImagesInVector(s, dim); }
+ // get selected files in an Output structure
+ void getSelected(std::vector<OutStrGimmick> &outG,std::vector< std::string> i_attr, bool mult, const std::string outmodel)
+ {
+ mView->getSelectedFiles(outG, i_attr, mult, outmodel);
+ }
+
void GetSelectedFiles(std::vector<std::string>& s)
{ mView->GetSelectedFiles(s); }
#include <creaImageIOWxDescriptorPanel.h>
#include <creaImageIOWxDumpPanel.h>
#include <creaImageIOWxExportDlg.h>
+#include <creaImageIOWxOutputDlg.h>
+#include <creaImageIOOutputModel.h>
using namespace crea;
// Icons
{
std::vector<std::string> files;
GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->GetSelectedAsString(files);
- ReadImagesNotThreaded(s, files, dim);
+ //ReadImagesNotThreaded(s, files, dim);
+
+
+ std::string db_name = crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()));
+ // ReadImagesNotThreadedInfosInVector(db_name,output, files,dim,1);
}
+
+
//======================================================================
void WxGimmickView::GetSelectedImagesInVector(std::vector<vtkImageData*>& s, int dim)
{
std::vector<std::string> files;
+ std::string db_name = crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()));
GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->GetSelectedAsString(files);
+
ReadImagesNotThreadedInVector(s, files, dim);
}
+
+
+ /// By default if out_infos is empty, we dont' provide informations, we return only vtkImageData
+ /// if out_infos has only one entry "all" we provide all database informations
+ void WxGimmickView::getSelectedFiles(std::vector<OutStrGimmick> &outG, std::vector< std::string> i_attr,
+ bool mult, const std::string out_model)
+ {
+ // First we select the files
+ std::vector<std::string> files;
+ std::string db_name = crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()));
+ GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->GetSelectedAsString(files);
+
+ std::string asking;
+ std::string dim;
+ bool bsingle = isSingle(files.front());
+ int i_dim_out;
+ mGimmick->GetSetting(SETTINGS_OUTPUT_ASK, asking);
+ mGimmick->GetSetting(SETTINGS_OUTPUT_DIM, dim);
+
+ if (asking == "true")
+ {
+ // display the output dialog box
+ // get dim
+ int idim;
+ sscanf(dim.c_str(),"%d",&idim);
+ WxOutputDlg *dlg = new WxOutputDlg(this,files, idim -1, bsingle);
+ if (dlg->ShowModal() == wxID_OK)
+ {
+ dim = dlg->getDim();
+ mGimmick->UpdateSetting(SETTINGS_OUTPUT_ASK, dlg->getAsking());
+ mGimmick->UpdateSetting(SETTINGS_OUTPUT_DIM, dim);
+ }
+ else
+ {
+ return;
+ }
+ }
+ else
+ {
+ }
+ sscanf(dim.c_str(),"%d",&i_dim_out);
+
+
+ // Next we create the structure for dicom output infos
+ OutputAttr Oattr;
+ Oattr.db = crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()));
+ if(i_attr.empty())
+ {
+ // We don't send informations!
+ }
+ else if( i_attr.size() == 1 && i_attr.front() == "ALL")
+ {
+ // we send all database
+ Oattr.inside.push_back("ALL");
+ }
+ else if( (i_attr.size() == 1 && i_attr.front() != "ALL")
+ || (i_attr.size() >1) )
+ {
+ mGimmick->fillVectInfos(i_attr, Oattr);
+ }
+ else
+ {
+ // nothing
+ }
+
+ // Next we create model and sort files
+ std::vector<std::string> sort_files(files);
+ double zspacing = 1;
+ if( !out_model.empty() )
+ {
+ /* OutputModel mod(out_model);
+ mGimmick->isAttributeExist(db_name, mod);
+ mod.sort(files, sort_files);
+ */}
+
+ if ( sort_files.size() > 1 && ( (bsingle && i_dim_out == 1) || (!bsingle && i_dim_out ==3) ) )
+ {
+ OutputModel *mod = new OutputModel();
+ zspacing = mod->orderFilesWithZspacing(sort_files);
+ delete mod;
+ }
+ // Now we read and create the waiting output (vtkImageData * or OutGimmickData *)
+ readImages(outG, sort_files, Oattr, i_dim_out, zspacing);
+ }
+
+
+
+
//======================================================================
+ //======================================================================
+
+
//======================================================================
void WxGimmickView::GetSelectedFiles(std::vector<std::string>& s)
{
public:
typedef int EventType;
+ OutStrGimmick m_out;
/// Ctor
WxGimmickView(boost::shared_ptr<Gimmick>,
///(overloaded from GimmickView)
void GetSelectedFiles(std::vector<std::string>& s);
+ /// Returns the selected files in output structure
+ void getSelectedFiles(std::vector<OutStrGimmick> &outG, std::vector< std::string> out_infos, bool mult = false, const std::string out_model = "");
+
/// Returns the selected Images so that they comply with the
/// given parameter(4D) (overloaded from GimmickView)
void GetSelectedImages(std::vector<vtkImageData*>& s, int dim);
void GetSelectedImagesInVector(std::vector<vtkImageData*>& s, int dim);
+
/// Returns the images indicated by the filenames in the vector
/// so that they comply with the given parameter(dim)
//(overloaded from GimmickView)
}
}
+
+
//================================================================
void WxTreeView::GetFilenamesAsString(const std::vector<tree::Node*>& nodes, std::vector<std::string>&s)
{