#include #include #include #include using namespace crea; namespace creaImageIO { //==================================================================== // Ctor TreeHandlerImageAdder::TreeHandlerImageAdder(TreeHandler* tree) : mTreeHandler(tree) { } // Dtor TreeHandlerImageAdder::~TreeHandlerImageAdder() { } //==================================================================== //==================================================================== void TreeHandlerImageAdder::ConnectProgressObserver(ProgressCallbackType callback) { mProgressSignal.connect(callback); } //==================================================================== //===================================================================== bool TreeHandlerImageAdder::IsHandledFile( const std::string& filename) { return (mReader.CanRead(filename,"")); } //===================================================================== //===================================================================== void TreeHandlerImageAdder::AddFiles( const std::vector& filenames) { mProgress.Reset(); unsigned int nbf = filenames.size(); std::vector::const_iterator i; for (i=filenames.begin();i!=filenames.end();++i) { mProgress.IncNumberScannedFiles(); if (IsHandledFile(*i)) { mProgress.IncNumberHandledFiles(); AddFile(*i); /* if (progress) { std::string mess("Adding "); mess += *i; if (!progress->Update( (int)(summary.added_images*999./nbf), std2wx(mess))) { // Some file was added hence we must return true ! summary.cancelled_by_user = true; break; } } */ } mProgressSignal(mProgress); } } //===================================================================== //===================================================================== void TreeHandlerImageAdder::AddDirectory( const std::string& directory, bool recurse) { mProgress.Reset(); AddDirectoryRecursor( directory, recurse ); } //===================================================================== //===================================================================== void TreeHandlerImageAdder::AddFile( const std::string& filename ) { std::map< std::string, std::string> attr; mTreeHandler->GetTree().GetDescriptor().BuildAttributeMap(attr); mReader.ReadAttributes(filename,attr); int lev = mTreeHandler->AddBranch(attr); // update the progress according to lev if (levGetTree().GetNumberOfLevels()) mProgress.IncNumberAddedFiles(); } //===================================================================== //===================================================================== void TreeHandlerImageAdder::AddDirectoryRecursor(const std::string &dirpath, bool recursive) { // std::cout << "dir : "<Pulse(std2wx(mess)); } */ std::string fileName; std::string dirName = dirpath; wxDir dir( std2wx(dirpath) ); if ( !dir.IsOpened() ) { // deal with the error here - wxDir would already log an error message // explaining the exact reason of the failure return; } wxString filename; bool cont = dir.GetFirst(&filename, wxEmptyString, wxDIR_FILES | wxDIR_HIDDEN ); while ( cont ) { mProgress.IncNumberScannedFiles(); wxFileName wxffn(dir.GetName(),filename); std::string ffn = wx2std(wxffn.GetFullPath()); // std::cout << "file : "<