From 8c0188cb0a3b4c491a4c5498ee04c754ec0fac2b Mon Sep 17 00:00:00 2001 From: guigues Date: Mon, 4 Feb 2008 13:02:57 +0000 Subject: [PATCH] *** empty log message *** --- kernel/src/bbtkBlackBoxDescriptor.cxx | 8 +- kernel/src/bbtkFactory.cxx | 163 +++++++++++++++++++++++++- kernel/src/bbtkFactory.h | 13 +- kernel/src/bbtkInterpreter.cxx | 89 +++++++------- kernel/src/bbtkInterpreter.h | 7 +- kernel/src/bbtkPackage.h | 10 +- kernel/src/bbtkUtilities.h | 27 ++++- packages/wx/bbs/appli/testSlider.bbs | 2 +- packages/wx/bbs/appli/testSplit.bbs | 1 + packages/wx/src/bbwxSlider.h | 5 +- packages/wx/src/bbwxSplit.h | 5 +- 11 files changed, 268 insertions(+), 62 deletions(-) diff --git a/kernel/src/bbtkBlackBoxDescriptor.cxx b/kernel/src/bbtkBlackBoxDescriptor.cxx index 5aa953d..004deb4 100644 --- a/kernel/src/bbtkBlackBoxDescriptor.cxx +++ b/kernel/src/bbtkBlackBoxDescriptor.cxx @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkBlackBoxDescriptor.cxx,v $ Language: C++ - Date: $Date: 2008/01/30 12:14:42 $ - Version: $Revision: 1.3 $ + Date: $Date: 2008/02/04 13:02:57 $ + Version: $Revision: 1.4 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -91,10 +91,10 @@ namespace bbtk < // for getcwd #endif +#include // std::toupper // was in gdcm ... /* @@ -887,6 +888,164 @@ namespace bbtk <"); } } + + + + + void Factory::CreateHtmlIndex(IndexEntryType type, + const std::string& filename) + { + bbtkDebugMessageInc("Core",9,"Factory::CreateHtmlIndex(\"" + < > IndexType; + IndexType index; + // Builds the index map + PackageMapType::const_iterator i; + for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i ) + { + Package* pack = i->second.mPackage; + Package::BlackBoxMapType::const_iterator j; + for (j = pack->GetBlackBoxMap().begin(); + j!= pack->GetBlackBoxMap().end(); + ++j) + { + + std::vector keys; + if (type==Packages) + { + keys.push_back(pack->GetName()); + title = "Index by packages"; + } + else if (type==Initials) + { + std::string init(" "); + init[0] = std::toupper(j->second->GetTypeName()[0]); + keys.push_back(init); + title = "Alphabetical index"; + } + else if (type==Keywords) + { + // Split the keyword string + //std::vector keywords; + std::string delimiters = ";,"; + Utilities::SplitString(j->second->GetKeyword(), + delimiters,keys); + //std::vector::iterator si; + //for (si=keywords.begin();si!=keywords.end;++si) + // { + // keys.push_back(*si); + // } + title = "Index by keywords"; + } + + std::vector::const_iterator k; + for (k=keys.begin(); k!=keys.end(); ++k ) + { + IndexType::iterator p; + p = index.find(*k); + if (p != index.end()) + { + p->second.push_back(j->second); + } + else + { + std::vector v; + v.push_back(j->second); + index[*k] = v; + } + } + + } + } + // Creates the file + //--------------------- + // Open output file + std::ofstream s; + s.open(filename.c_str()); + if (!s.good()) + { + bbtkError("Factory::CreateHtmlIndex : could not open file '" + <\n"; + s << "\n"; + s << ""<<title<<"\n"; + s << "\n"; + s << "\n"; + s << "\n"; + s << "\n"; + // + s << "\n"; + s << "\n"; + //---------------------- + + //---------------------- + // Html body + s << "\n"; + s << "

"<\n"; + + IndexType::iterator ii; + for (ii=index.begin();ii!=index.end();++ii) + { + s << "

"<first<<"\n"; + s << "

    \n"; + + s << "

    \n"; + + std::vector::iterator di; + for (di=ii->second.begin();di!=ii->second.end();++di) + { + std::string pack = (*di)->GetPackage()->GetName(); + std::string name = (*di)->GetTypeName(); + std::string descr = (*di)->GetDescription(); + s << ""; + s << " "; + s << " "; + s << "\n"; + } + s << "
    "; + s << "
  • " + <"; + s << "
  • " << descr << "
    \n"; + s << "

\n"; + s << "\n"; + } + //---------------------- + // Footer + time_t rawtime; + tm * ptm; + time ( &rawtime ); + ptm = gmtime ( &rawtime ); + + s << "


\n"; + s << "Automatically generated by bbi on " + << ptm->tm_mday << "/" << ptm->tm_mon << "/" << ptm->tm_year+1900 + << " - " << ptm->tm_hour << ":" << ptm->tm_min << " GMT\n"; + s << "\n"; + s.close(); + //---------------------- + + // End + bbtkDebugDecTab("Core",9); + } + } diff --git a/kernel/src/bbtkFactory.h b/kernel/src/bbtkFactory.h index 7a72a46..7eaefeb 100644 --- a/kernel/src/bbtkFactory.h +++ b/kernel/src/bbtkFactory.h @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkFactory.h,v $ Language: C++ - Date: $Date: 2008/01/22 16:55:04 $ - Version: $Revision: 1.2 $ + Date: $Date: 2008/02/04 13:02:58 $ + Version: $Revision: 1.3 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See doc/license.txt or @@ -72,6 +72,15 @@ namespace bbtk void WriteDotFilePackagesList(FILE *ff); void Reset(); + + typedef enum + { + Packages, + Keywords, + Initials + } + IndexEntryType; + void CreateHtmlIndex(IndexEntryType type, const std::string& filename); private: diff --git a/kernel/src/bbtkInterpreter.cxx b/kernel/src/bbtkInterpreter.cxx index d39aa91..5f6b3e6 100644 --- a/kernel/src/bbtkInterpreter.cxx +++ b/kernel/src/bbtkInterpreter.cxx @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkInterpreter.cxx,v $ $ Language: C++ - Date: $Date: 2008/02/01 13:06:29 $ - Version: $Revision: 1.17 $ + Date: $Date: 2008/02/04 13:02:58 $ + Version: $Revision: 1.18 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -163,6 +163,14 @@ Interpreter* Interpreter::mGlobalInterpreter = NULL; info.help = "Prints the value of all configuration parameters"; mCommandDict[info.keyword] = info; + info.keyword = "index"; // LG + info.argmin = 0; + info.argmax = 2; + info.code = cIndex; + info.syntax = "index [ ['Initials'(default)|'Packages'|'Keywords']]"; + info.help = "Creates an html index of known boxes. If filename is provided then save it to the file 'filename'. The default index entries are the initial letters of the names of the boxes. If 'Packages' or 'Keywords' is provided then the entries are either the package names or the keywords"; + mCommandDict[info.keyword] = info; + info.keyword = "reset"; //EED info.argmin = 0; info.argmax = 0; @@ -503,12 +511,20 @@ void Interpreter::InterpretLine( const std::string& line, bool &insideComment ) mExecuter->Author(words[1]); break; - case cKeyword : - mExecuter->Keyword(words[1]); - break; - - case cDescription : - mExecuter->Description(words[1]); + case cKeyword : + mExecuter->Keyword(words[1]); + break; + + case cIndex : + if (words.size()==1) + Index("tmp_index.html"); + else if (words.size()==2) + Index(words[1]); + else if (words.size()==3) + Index(words[1],words[2]); + break; + case cDescription : + mExecuter->Description(words[1]); break; case cHelp : @@ -588,28 +604,6 @@ void Interpreter::InterpretLine( const std::string& line, bool &insideComment ) - //======================================================================= - void SplitString ( const std::string& str, const std::string& delimiters, - std::vector& tokens) - { - // Skip delimiters at beginning. - std::string::size_type lastPos = str.find_first_not_of(delimiters, 0); - // Find first delimiter. - std::string::size_type pos = str.find_first_of(delimiters, lastPos); - - while (std::string::npos != pos || std::string::npos != lastPos) - { - // Found a token, add it to the vector. - tokens.push_back(str.substr(lastPos, pos - lastPos)); - // Skip delimiters. Note the "not_of" - lastPos = str.find_first_not_of(delimiters, pos); - // Find next delimiter - pos = str.find_first_of(delimiters, lastPos); - } - - } - //======================================================================= - //======================================================================= @@ -622,13 +616,13 @@ void Interpreter::SplitLine ( const std::string& str, std::vector& std::string delimiters = "\""; std::vector quote; - SplitString(str,delimiters,quote); + Utilities::SplitString(str,delimiters,quote); delimiters = " \t"; std::vector::iterator i; for (i=quote.begin(); i!=quote.end(); ) { - SplitString(*i,delimiters,tokens); + Utilities::SplitString(*i,delimiters,tokens); ++i; if (i!=quote.end()) { @@ -1507,10 +1501,10 @@ void Interpreter::Help(const std::vector& words) bbtkDebugDecTab("Interpreter",9); } - //======================================================================= - void Interpreter::Graph(const std::vector& words) - { - std::string page; +//======================================================================= +void Interpreter::Graph(const std::vector& words) +{ + std::string page; bool system_display = true; #ifdef _USE_WXWIDGETS_ @@ -1542,18 +1536,31 @@ void Interpreter::Help(const std::vector& words) page = mExecuter->ShowGraph(words[1],words[2],words[3],words[4],words[5],"",system_display); } else if (words.size()==7) - { - page = mExecuter->ShowGraph(words[1],words[2],words[3],words[4],words[5],words[6],system_display); - } - + { + page = mExecuter->ShowGraph(words[1],words[2],words[3],words[4],words[5],words[6],system_display); + } + #ifdef _USE_WXWIDGETS_ if ( WxConsole::GetInstance() != 0 ) WxConsole::GetInstance()->ShowHtmlPage(page); #endif } - //======================================================================= +//======================================================================= +//======================================================================= +void Interpreter::Index(const std::string& filename, + const std::string& type) +{ + Factory::IndexEntryType t; + if (type=="Initials") t = Factory::Initials; + else if (type=="Keywords") t = Factory::Keywords; + else if (type=="Packages") t = Factory::Packages; + + GetGlobalFactory()->CreateHtmlIndex(t,filename); +} +//======================================================================= + }//namespace diff --git a/kernel/src/bbtkInterpreter.h b/kernel/src/bbtkInterpreter.h index 24dbd89..dac437c 100644 --- a/kernel/src/bbtkInterpreter.h +++ b/kernel/src/bbtkInterpreter.h @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkInterpreter.h,v $ $ Language: C++ - Date: $Date: 2008/01/30 09:28:15 $ - Version: $Revision: 1.6 $ + Date: $Date: 2008/02/04 13:02:58 $ + Version: $Revision: 1.7 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -68,6 +68,7 @@ namespace bbtk cUnload, cGraph, cPrint, + cIndex, cWorkspace // LG } CommandCodeType; @@ -154,6 +155,8 @@ namespace bbtk /// void Print(const std::string&); + void Index(const std::string& filename, + const std::string& type = "Initials"); /// void FindCommandsWithPrefix( char* buf, int n, diff --git a/kernel/src/bbtkPackage.h b/kernel/src/bbtkPackage.h index 3b4d8dc..24edc8f 100644 --- a/kernel/src/bbtkPackage.h +++ b/kernel/src/bbtkPackage.h @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkPackage.h,v $ Language: C++ - Date: $Date: 2008/01/30 09:28:15 $ - Version: $Revision: 1.2 $ + Date: $Date: 2008/02/04 13:02:58 $ + Version: $Revision: 1.3 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See doc/license.txt or @@ -100,6 +100,10 @@ namespace bbtk /// Changes the name of a black box type void ChangeBlackBoxName( const std::string& oldname, const std::string& newname ); + /// The type of map of descriptors + typedef std::map< std::string, BlackBoxDescriptor*> BlackBoxMapType; + const BlackBoxMapType& GetBlackBoxMap() const { return mBlackBoxMap; } + BlackBoxMapType& GetBlackBoxMap() { return mBlackBoxMap; } private: /// The name of the package @@ -121,8 +125,6 @@ namespace bbtk std::string mDocRelativeURL; - /// The type of map of descriptors - typedef std::map< std::string, BlackBoxDescriptor*> BlackBoxMapType; /// The map of black boxes descriptors BlackBoxMapType mBlackBoxMap; diff --git a/kernel/src/bbtkUtilities.h b/kernel/src/bbtkUtilities.h index b399867..47779de 100644 --- a/kernel/src/bbtkUtilities.h +++ b/kernel/src/bbtkUtilities.h @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkUtilities.h,v $ Language: C++ - Date: $Date: 2008/01/30 15:29:07 $ - Version: $Revision: 1.9 $ + Date: $Date: 2008/02/04 13:02:58 $ + Version: $Revision: 1.10 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See doc/license.txt or @@ -363,6 +363,29 @@ static bool IsDirectory(std::string const &dirName) right = ""; } } + //======================================================================= + static inline void SplitString ( const std::string& str, + const std::string& delimiters, + std::vector& tokens) + { + // Skip delimiters at beginning. + std::string::size_type lastPos = str.find_first_not_of(delimiters, 0); + // Find first delimiter. + std::string::size_type pos = str.find_first_of(delimiters, lastPos); + + while (std::string::npos != pos || std::string::npos != lastPos) + { + // Found a token, add it to the vector. + tokens.push_back(str.substr(lastPos, pos - lastPos)); + // Skip delimiters. Note the "not_of" + lastPos = str.find_first_not_of(delimiters, pos); + // Find next delimiter + pos = str.find_first_of(delimiters, lastPos); + } + + } + //======================================================================= + // =================================================================================== diff --git a/packages/wx/bbs/appli/testSlider.bbs b/packages/wx/bbs/appli/testSlider.bbs index 713e049..0c07327 100644 --- a/packages/wx/bbs/appli/testSlider.bbs +++ b/packages/wx/bbs/appli/testSlider.bbs @@ -1,6 +1,6 @@ description "Simple test of wx::Slider widget" author "laurent.guigues@creatis.insa-lyon.fr" -#category "test" +keyword "test;wx" load wx new Slider slider diff --git a/packages/wx/bbs/appli/testSplit.bbs b/packages/wx/bbs/appli/testSplit.bbs index f585904..6bc8c90 100644 --- a/packages/wx/bbs/appli/testSplit.bbs +++ b/packages/wx/bbs/appli/testSplit.bbs @@ -1,5 +1,6 @@ description "Simple test of wx::Split widget" author "laurent.guigues@creatis.insa-lyon.fr" +keyword "test;wx" load wx diff --git a/packages/wx/src/bbwxSlider.h b/packages/wx/src/bbwxSlider.h index 9c93a7f..2b550ed 100644 --- a/packages/wx/src/bbwxSlider.h +++ b/packages/wx/src/bbwxSlider.h @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbwxSlider.h,v $ Language: C++ - Date: $Date: 2008/01/28 08:56:02 $ - Version: $Revision: 1.3 $ + Date: $Date: 2008/02/04 13:02:58 $ + Version: $Revision: 1.4 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -147,6 +147,7 @@ namespace bbwx BBTK_BEGIN_DESCRIBE_BLACK_BOX(Slider,bbtk::WxBlackBox); BBTK_NAME("Slider"); BBTK_AUTHOR("eduardo.davila@creatis.insa-lyon.fr"); + BBTK_KEYWORD("wx;widget"); BBTK_DESCRIPTION("Slider widget (wxSlider)"); BBTK_INPUT(Slider,In,"Initial position of the slider (default 0)",int); BBTK_INPUT(Slider,Min,"Minimum value of the slider (default 0)",int); diff --git a/packages/wx/src/bbwxSplit.h b/packages/wx/src/bbwxSplit.h index cb19445..569dfa5 100644 --- a/packages/wx/src/bbwxSplit.h +++ b/packages/wx/src/bbwxSplit.h @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbwxSplit.h,v $ Language: C++ - Date: $Date: 2008/01/28 08:56:02 $ - Version: $Revision: 1.3 $ + Date: $Date: 2008/02/04 13:02:58 $ + Version: $Revision: 1.4 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -99,6 +99,7 @@ namespace bbwx BBTK_NAME("Split"); BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr"); BBTK_DESCRIPTION("Widget which splits a window in two fixed size parts (wxSplitterWindow)"); + BBTK_KEYWORD("wx;widget"); BBTK_INPUT(Split,Widget1,"Upper or left widget",wxWindow*); BBTK_INPUT(Split,Widget2,"Lower or right widget",wxWindow*); BBTK_INPUT(Split,Orientation,"Orientation (default 0), 0=Horizontal , 1=Vertical",int); -- 2.45.1