]> Creatis software - bbtk.git/commitdiff
*** empty log message ***
authorguigues <guigues>
Mon, 4 Feb 2008 13:02:57 +0000 (13:02 +0000)
committerguigues <guigues>
Mon, 4 Feb 2008 13:02:57 +0000 (13:02 +0000)
kernel/src/bbtkBlackBoxDescriptor.cxx
kernel/src/bbtkFactory.cxx
kernel/src/bbtkFactory.h
kernel/src/bbtkInterpreter.cxx
kernel/src/bbtkInterpreter.h
kernel/src/bbtkPackage.h
kernel/src/bbtkUtilities.h
packages/wx/bbs/appli/testSlider.bbs
packages/wx/bbs/appli/testSplit.bbs
packages/wx/src/bbwxSlider.h
packages/wx/src/bbwxSplit.h

index 5aa953d949ef6ca867b59ce7b0b22050a9ed8239..004deb4ca96d961d5cddba629dc72a4f2e161577 100644 (file)
@@ -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
                     <<GetTypeName()<<"]"<<std::endl);  
     if (clear) mKeyword = s;
     else mKeyword += s;
-    std::cout<<"keyword [" << mKeyword << "]" << std::endl;
+    mKeyword += ";";
   }  
   //=========================================================================
-
+  
   //=========================================================================
   const BlackBoxDescriptor::InputDescriptor* 
   BlackBoxDescriptor::GetInputDescriptor(const std::string & name) const
index d2d893c289472a00759da2b5dff0d0a90e1c34e2..1847452410ac472ab7addd8f4d7da9b6b9c96a3b 100644 (file)
@@ -4,8 +4,8 @@ Program:   bbtk
 Module:    $RCSfile: bbtkFactory.cxx,v $
 Language:  C++
 
-Date:      $Date: 2008/01/30 12:14:43 $
-Version:   $Revision: 1.8 $
+Date:      $Date: 2008/02/04 13:02:58 $
+Version:   $Revision: 1.9 $
                                                                                 
 
 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
@@ -35,6 +35,7 @@ PURPOSE.  See the above copyright notices for more information.
 #include <direct.h> // for getcwd
 #endif
 
+#include <cctype>    // std::toupper
 
 // was in gdcm ...
 /*
@@ -887,6 +888,164 @@ namespace bbtk
                 <<name<<">");
    }
  }
+    
+
+
+
+  void Factory::CreateHtmlIndex(IndexEntryType type, 
+                               const std::string& filename)
+  {
+    bbtkDebugMessageInc("Core",9,"Factory::CreateHtmlIndex(\""
+                       <<filename<<"\")"<<bbtkendl);
+    
+    std::string title;
+
+    typedef std::map<std::string, std::vector<BlackBoxDescriptor*> > 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<std::string> 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<std::string> keywords;
+               std::string delimiters = ";,";
+               Utilities::SplitString(j->second->GetKeyword(),
+                                      delimiters,keys);
+               //std::vector<std::string>::iterator si;
+               //for (si=keywords.begin();si!=keywords.end;++si)
+               //  {
+               //    keys.push_back(*si);
+               //  }
+               title = "Index by keywords";
+             }
+           
+           std::vector<std::string>::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<BlackBoxDescriptor*> 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 '"
+                <<filename<<"'");
+    }
+    
+    //----------------------
+    // Html head
+    s << "<html lang=\"en\">\n";
+    s << "<head>\n";
+    s << "<title>"<<title<<"</title>\n";
+    s << "<meta http-equiv=\"Content-Type\" content=\"text/html\">\n";
+    s << "<meta name=\"description\" content=\""<<title<<"\">\n";
+    s << "<meta name=\"generator\" content=\"\">\n";
+    s << "<link title=\"Top\" rel=\"top\" href=\"#Top\">\n";
+    //<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
+    s << "<meta http-equiv=\"Content-Style-Type\" content=\"text/css\"><style type=\"text/css\"><!--\n";
+    s << "pre.display { font-family:inherit }\n";
+    s << "pre.format  { font-family:inherit }\n";
+    s << "pre.smalldisplay { font-family:inherit; font-size:smaller }\n";
+    s << "pre.smallformat  { font-family:inherit; font-size:smaller }\n";
+    s << "pre.smallexample { font-size:smaller }\n";
+    s << "pre.smalllisp    { font-size:smaller }\n";
+    s << "span.sc    { font-variant:small-caps }\n";
+    s << "span.roman { font-family:serif; font-weight:normal; } \n";
+    s << "span.sansserif { font-family:sans-serif; font-weight:normal; }\n"; 
+    s << "--></style>\n";
+    s << "</head>\n";
+    //----------------------
+
+    //----------------------
+    // Html body
+    s << "<body>\n";
+    s << "<h1 class=\"settitle\">"<<title<<"</h1>\n";
+
+    IndexType::iterator ii;
+    for (ii=index.begin();ii!=index.end();++ii)
+      {
+       s << "<p><b>"<<ii->first<<"</b>\n";
+       s << "<ul>\n";
+
+       s << "<p><TABLE cellspacing=0  cellpadding=3>\n";
+
+       std::vector<BlackBoxDescriptor*>::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 << "<TR>";
+           s << "<TD style='vertical-align: top;'>";
+           s << "<li><a href=\""<<pack
+             <<"/index.html#"<<name<<"\">"
+             <<pack<<"::"<<name<<"</a>";
+           s << "</TD> ";
+           s << " <TD style='vertical-align: top;'>" << descr << " </TD>";
+           s << "</TR>\n";
+         }    
+       s << "</TABLE>\n";
+       s << "</li></ul>\n";
+       s << "</div>\n";
+      }
+    //----------------------
+    // Footer 
+    time_t rawtime;
+    tm * ptm;
+    time ( &rawtime );
+    ptm = gmtime ( &rawtime );
+
+    s << "<p><hr>\n";
+    s << "Automatically generated by <b>bbi</b> on "
+      << ptm->tm_mday << "/" << ptm->tm_mon << "/" << ptm->tm_year+1900 
+      << " - " << ptm->tm_hour << ":" << ptm->tm_min << " GMT\n";
+    s << "</body></html>\n"; 
+    s.close();
+    //----------------------
+
+    // End
+    bbtkDebugDecTab("Core",9);
+  }
+
 
 }
   
index 7a72a469b2934d7318f9d519dad3819fc619a33f..7eaefeb85eda4f767575c7c0a029607d16575a2a 100644 (file)
@@ -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:
 
index d39aa91deee86b6975c28586ff5a082b80389a4f..5f6b3e65b9853a38c5f2e6316faf8e3a003a227c 100644 (file)
@@ -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 [<filename> ['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<std::string>& 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>&
  
     std::string delimiters = "\"";
     std::vector<std::string> quote;
-    SplitString(str,delimiters,quote);
+    Utilities::SplitString(str,delimiters,quote);
 
     delimiters = " \t";
     std::vector<std::string>::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<std::string>& words)
     bbtkDebugDecTab("Interpreter",9);
   }
 
-  //=======================================================================
-  void Interpreter::Graph(const std::vector<std::string>& words)
-  {
-    std::string page;
+//=======================================================================
+void Interpreter::Graph(const std::vector<std::string>& words)
+{
+  std::string page;
     bool system_display = true;
 
 #ifdef _USE_WXWIDGETS_
@@ -1542,18 +1536,31 @@ void Interpreter::Help(const std::vector<std::string>& 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
 
 
index 24dbd89f29079743afdb46b14a5f0374f5b14f76..dac437c67eb920599e5563c45003ed3f9f32468a 100644 (file)
@@ -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,
index 3b4d8dcf3082ded00d4dc4cb4610964283f46db4..24edc8f8f945bf6e57f64215bb4a44d384824640 100644 (file)
@@ -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;
 
index b399867438ad95a1ffccd3f01f910f429dc307cf..47779dea87130710e957480a760dfcb75ffecafd 100644 (file)
@@ -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<std::string>& 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);
+      }
+    
+  }
+  //=======================================================================
+
 
 // ===================================================================================
 
index 713e049a37d583548721e6bc73ff931c77c17192..0c073272e83fd97fd068ee6f92054efda45979f0 100644 (file)
@@ -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
index f585904ff423d28b871858dece01290d782dd2c3..6bc8c907dd2a540080838e7c5d054f9fb366f3c4 100644 (file)
@@ -1,5 +1,6 @@
 description "Simple test of wx::Split widget"
 author "laurent.guigues@creatis.insa-lyon.fr"
+keyword "test;wx"
 
 load wx
 
index 9c93a7ff5eb997e442f8fbe73d16ae78bbbecb4c..2b550ed36d63ec905a7dcfd663d061896395b9c6 100644 (file)
@@ -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);
index cb194450333e2b1a3227e019550fb7bc63ebc896..569dfa562986f1f64ca2414dc56ea8f923998412 100644 (file)
@@ -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);