]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkTranscriptor.cxx
- Finished the Transcriptor
[bbtk.git] / kernel / src / bbtkTranscriptor.cxx
index ff0785b392013d6ce23a9ee1ebc91e20167cba8a..e5e83b59a02837338c1b58e1798a6eb3a63cdd79 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkTranscriptor.cxx,v $ $
   Language:  C++
-  Date:      $Date: 2008/03/26 08:27:19 $
-  Version:   $Revision: 1.8 $
+  Date:      $Date: 2008/03/26 14:47:36 $
+  Version:   $Revision: 1.9 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -40,23 +40,53 @@ namespace bbtk
  *
  */
   Transcriptor::Transcriptor(std::string filename)
-    : mPackage(0),
-      mRoot(0),
+    :
       mNoExecMode(false),
       mDialogMode(NoDialog)
   {
     //VirtualExec();    
     bbtkDebugMessageInc("Kernel",9,"Transcriptor::Transcriptor()" <<std::endl);
-    Reset();
-    bbtkDebugDecTab("Kernel",9);
-
-    //std::ofstream *m_Fp = new std::ofstream();
+     //std::ofstream *m_Fp = new std::ofstream();
     m_Fp.open (filename.c_str(), std::ios::out );
 
-    m_Fp << "#include \"bbtkExecuter.h\""                   << std::endl;
+    std::string file,path;
+    file = bbtk::Utilities::ExtractScriptName(filename,path);
+    
+    m_Fp << "#include \"bbtkExecuter.h\"" << std::endl; 
+    m_Fp << "void " << file << "(bbtk::Executer* e)"<<std::endl;
+    m_Fp << "{"<<std::endl;
+
+    /*
+#ifdef _USE_WXWIDGETS_
+    m_Fp << "#ifdef _USE_WXWIDGETS_"<<std::endl;
+    m_Fp << "#include \"bbtkWx.h\""<< std::endl<<std::endl;
+    m_Fp << "class myApp : public wxApp"<<std::endl;
+    m_Fp << "{"<<std::endl;
+    m_Fp << "public:"<<std::endl;
+    m_Fp << "  bool OnInit( );"<<std::endl;
+    m_Fp << "  int  OnExit() { delete e; return true; }"<<std::endl;
+    m_Fp << "  bbtk::Executer* e;"<<std::endl;
+    m_Fp << "};"<<std::endl<<std::endl;
+    m_Fp << "IMPLEMENT_APP(myApp);"<<std::endl<<std::endl;
+    m_Fp << "bool myApp::OnInit( )"<<std::endl;
+    m_Fp << "{"<<std::endl;
+    m_Fp << "  wxApp::OnInit();"<<std::endl;
+    m_Fp << "#ifdef __WXGTK__"<<std::endl;
+    m_Fp << "  //See http://www.wxwindows.org/faqgtk.htm#locale"<<std::endl;
+    m_Fp << "  setlocale(LC_NUMERIC, \"C\");"<<std::endl;
+    m_Fp << "#endif"<<std::endl;
+    m_Fp << "  wxInitAllImageHandlers();"<<std::endl;
+    m_Fp << "  bbtk::Wx::CreateInvisibleTopWindow();"<<std::endl;
+    m_Fp << "  try {"<<std::endl;
+    m_Fp << "  e = new bbtk::Executer();"<<std::endl;
+#else
     m_Fp << "main(int argc, char *argv[]) {"                << std::endl;
     m_Fp << "  bbtk::Executer *e = new bbtk::Executer();"   << std::endl;
-  }
+#endif 
+    */
+    bbtkDebugDecTab("Kernel",9);
+ }
 
 /**
  *
@@ -64,29 +94,28 @@ namespace bbtk
   Transcriptor::~Transcriptor()
   {
   
-std::cout << "====================================================== delete Transcriptor\n";
-     bbtkDebugMessageInc("Kernel",9,"Transcriptor::~Transcriptor()" <<std::endl);
-     if (mRoot) 
-     {
-        mPackage->UnRegisterBlackBox("workspace");
-        delete mRoot;
-     }
-     if (mPackage)
-     {
-        //GetGlobalFactory()->UnLoadPackage("user");
-     }
-
-     if(m_Fp)
-     {
-        bbtkDebugDecTab("Kernel",9);
-        m_Fp << " }"   << std::endl;
-        m_Fp.close();
-       // delete m_Fp;
-     }
-  }
+    bbtkDebugMessageInc("Kernel",9,"Transcriptor::~Transcriptor()" <<std::endl);
+    /*
+#ifdef _USE_WXWIDGETS_
+    m_Fp << "  }"<<std::endl;
+    m_Fp << "  catch (bbtk::Exception err)"<<std::endl;
+    m_Fp << "  {"<<std::endl;
+    m_Fp << "    err.Print();"<<std::endl;
+    m_Fp << "  } "<<std::endl;
+    m_Fp << "  return true;"<<std::endl;
+    m_Fp << "}"   << std::endl;
+    m_Fp << "#endif"<<std::endl;
+#else 
+    m_Fp << "}"   << std::endl;
+#endif
+    */
+    m_Fp << "}"   << std::endl;
+    m_Fp.close();
 
+    bbtkDebugDecTab("Kernel",9);
+  }
+  
 
-  // ================= Begin of Battlefield =============================
   void Transcriptor::Reset()
   {
      m_Fp << "  e->Reset( );" << std::endl;
@@ -130,7 +159,7 @@ std::cout << "====================================================== delete Tran
   void Transcriptor::Create ( const std::string& nodeType, 
                               const std::string& nodeName)
   {
-    m_Fp << "  e->Add(\"" << nodeType << "\", \"" 
+    m_Fp << "  e->Create(\"" << nodeType << "\", \"" 
         <<  nodeName << "\");" << std::endl;
   }
 
@@ -162,8 +191,8 @@ std::cout << "====================================================== delete Tran
                                    const std::string& help)
   {
   
-    m_Fp << "  e->DefineInput(\""<< name << "\", " <<  box << ", "
-         << input << ", \"" << help << "\");" << std::endl;
+    m_Fp << "  e->DefineInput(\""<< name << "\", \"" <<  box << "\", \""
+         << input << "\", \"" << help << "\");" << std::endl;
   }
 
   
@@ -199,27 +228,25 @@ std::cout << "====================================================== delete Tran
   void Transcriptor::Author(const std::string &authorName)
   {
     
-    m_Fp << "  e->AddToAuthor(\"" << authorName << "\")" << std::endl;
+    m_Fp << "  e->Author(\"" << authorName << "\");" << std::endl;
   }
 
   void Transcriptor::Category(const std::string &category)
   {
-    m_Fp << "  e->AddToCategory(\"" << category << "\")" << std::endl;
+    m_Fp << "  e->Category(\"" << category << "\");" << std::endl;
   }
 
   void Transcriptor::Description(const std::string &d)
   {
-    m_Fp << "  e->AddToDescription(\"" << d << "\")" << std::endl;
+    m_Fp << "  e->Description(\"" << d << "\");" << std::endl;
   }
 
   /// prints the list of the boxes of the current descriptor
   void Transcriptor::PrintBoxes()
   {
-     m_Fp << "  e->PrintBoxes( )" << std::endl;
+     m_Fp << "  e->PrintBoxes( );" << std::endl;
  }
 
-// =========================End of Battlefield ========================================================================
-
   std::string Transcriptor::ShowGraph(const std::string &nameblackbox,
                                  const std::string &detailStr,
                                  const std::string &levelStr,
@@ -254,7 +281,7 @@ void Transcriptor::ShowRelations(const std::string &nameblackbox, const std::str
 
   void Transcriptor::Print(const std::string & message)
   {
-    m_Fp << "  e->Print(\"" <<message<<"\")"<<std::endl;
+    m_Fp << "  e->Print(\"" <<message<<"\");"<<std::endl;
   }
 
 
@@ -262,24 +289,24 @@ void Transcriptor::ShowRelations(const std::string &nameblackbox, const std::str
   void Transcriptor::SetMessageLevel(const std::string &kind,
                       int level)
   {
-    m_Fp << "  e->SetMessageLevel(\"" <<kind<<"\","<<level<<")"<<std::endl;
+    m_Fp << "  e->SetMessageLevel(\"" <<kind<<"\","<<level<<");"<<std::endl;
   }
   
 
   void Transcriptor::HelpMessages()
   {
-    m_Fp << "  e->HelpMessages()"<<std::endl;
+    m_Fp << "  e->HelpMessages();"<<std::endl;
   }
   
   void Transcriptor::LoadPackage(const std::string &name )
   {
-    m_Fp << "  e->LoadPackage(\"" <<name<<"\")"<<std::endl;
+    m_Fp << "  e->LoadPackage(\"" <<name<<"\");"<<std::endl;
   }
   
   
   void Transcriptor::UnLoadPackage(const std::string &name )
   {
-    m_Fp << "  e->UnLoadPackage(\"" <<name<<"\")"<<std::endl;
+    m_Fp << "  e->UnLoadPackage(\"" <<name<<"\");"<<std::endl;
   }