X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=kernel%2Fsrc%2FbbtkExecuter.cxx;h=bf51fe564d3a1b644ee850f9bbc044d9b3abfa08;hb=87efce51877a540d943b1aa26307994b38bba55b;hp=84273c0815cc85404d6c1fe180218b37f3a15241;hpb=8822f9075c66dcf742b9edae47271bb46af6a9b7;p=bbtk.git diff --git a/kernel/src/bbtkExecuter.cxx b/kernel/src/bbtkExecuter.cxx index 84273c0..bf51fe5 100644 --- a/kernel/src/bbtkExecuter.cxx +++ b/kernel/src/bbtkExecuter.cxx @@ -1,32 +1,39 @@ -/*========================================================================= +/* + # --------------------------------------------------------------------- + # + # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image + # pour la SantÈ) + # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton + # Previous Authors : Laurent Guigues, Jean-Pierre Roux + # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil + # + # This software is governed by the CeCILL-B license under French law and + # abiding by the rules of distribution of free software. You can use, + # modify and/ or redistribute the software under the terms of the CeCILL-B + # license as circulated by CEA, CNRS and INRIA at the following URL + # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html + # or in the file LICENSE.txt. + # + # As a counterpart to the access to the source code and rights to copy, + # modify and redistribute granted by the license, users are provided only + # with a limited warranty and the software's author, the holder of the + # economic rights, and the successive licensors have only limited + # liability. + # + # The fact that you are presently reading this means that you have had + # knowledge of the CeCILL-B license and that you accept its terms. + # ------------------------------------------------------------------------ */ + + +/*========================================================================= Program: bbtk Module: $RCSfile: bbtkExecuter.cxx,v $ Language: C++ - Date: $Date: 2009/01/27 14:22:56 $ - Version: $Revision: 1.27 $ + Date: $Date: 2012/11/16 08:49:01 $ + Version: $Revision: 1.34 $ =========================================================================*/ -/* --------------------------------------------------------------------- - -* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) -* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux -* -* This software is governed by the CeCILL-B license under French law and -* abiding by the rules of distribution of free software. You can use, -* modify and/ or redistribute the software under the terms of the CeCILL-B -* license as circulated by CEA, CNRS and INRIA at the following URL -* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -* or in the file LICENSE.txt. -* -* As a counterpart to the access to the source code and rights to copy, -* modify and redistribute granted by the license, users are provided only -* with a limited warranty and the software's author, the holder of the -* economic rights, and the successive licensors have only limited -* liability. -* -* The fact that you are presently reading this means that you have had -* knowledge of the CeCILL-B license and that you accept its terms. -* ------------------------------------------------------------------------ */ + /** * \file @@ -37,6 +44,7 @@ #include "bbtkMessageManager.h" #include "bbtkFactory.h" #include "bbtkUtilities.h" +//#include "bbtkWx.h" #include #ifdef USE_WXWIDGETS @@ -52,7 +60,7 @@ namespace bbtk //======================================================================= Executer::Pointer Executer::New() { - bbtkDebugMessage("Kernel",9,"Executer::New()"< Executer()" < create it to pass it to the factory @@ -76,19 +84,19 @@ namespace bbtk // -> this would auto-destroy !! mFactory->SetExecuter(MakePointer(this,true)); Reset(); - bbtkDebugDecTab("Kernel",9); + bbtkDebugMessage("object",2,"<== Executer()" < Executer::~Executer()" < ~Executer()" <Reset(); mFactory.reset(); - bbtkDebugDecTab("Kernel",9); + bbtkDebugMessage("object",2,"<== ~Executer()" < Executer::Reset()" <CheckPackages(); + // GetFactory()->Check(); mOpenDefinition.clear(); mOpenPackage.clear(); + + // Wx::DestroyTopWindow(); + GetFactory()->Reset(); +#if(USE_WXWIDGETS) + Wx::ProcessPendingEvents(); +#endif + // Create user package Package::Pointer p = Package::New("user","internal","User defined black boxes",""); @@ -137,13 +152,12 @@ namespace bbtk r->AddToDescription("User's workspace"); mOpenDefinition.push_back(CBBDefinition(r,"user")); // Register it into the user package - p->RegisterBlackBox(r); + p->Register(r); mRootCBB = r; // Object::PrintObjectListInfo(); // GetFactory()->CheckPackages(); - - bbtkDebugDecTab("Kernel",9); + bbtkDebugMessage("kernel",9,"<== Executer::Reset()" <ChangeBlackBoxName( GetWorkspace()->GetTypeName(), n ); + GetUserPackage()->ChangeDescriptorName( GetWorkspace()->GetTypeName(), n ); } //======================================================================= //======================================================================= void Executer::BeginPackage (const std::string &name) { - bbtkDebugMessageInc("Kernel",9,"Executer::BeginPackage(\""< Executer::BeginPackage(\""<InsertPackage(p); } mOpenPackage.push_back(p); + + bbtkDebugMessage("kernel",9,"<== Executer::BeginPackage(\""< Executer::Define(\""<SetScriptFileName(scriptfilename); mOpenDefinition.push_back( CBBDefinition( b, pack ) ); - bbtkDebugDecTab("Kernel",9); + bbtkDebugMessage("kernel",9,"<== Executer::Define(\""<SetTypeOfScript_Application(); + } + + + //======================================================================= void Executer::Clear() { - bbtkDebugMessageInc("Kernel",9,"Executer::Clear()" < Executer::Clear()" <GetPrototype()->Clear(); - + bbtkDebugMessage("kernel",9,"<== Executer::Clear()" <GetTypeName()<<"\")" - < Executer::EndDefine(\"" + <GetTypeName()<<"\")" + <RegisterBlackBox(GetCurrentDescriptor()); + // Register the descriptor in the current package + p->Register(GetCurrentDescriptor()); + bbtkDebugMessage("kernel",9,"<== Executer::EndDefine(\"" + <GetTypeName()<<"\")" + <GetPrototype()->bbGetBlackBox(box); // Looks for the adaptor - if ( b->bbGetInputType(input) != typeid(std::string) ) + if ( ( b->bbGetInputType(input) != typeid(bbtk::any) )&& + ( b->bbGetInputType(input) != typeid(std::string) ) ) { BlackBox::Pointer a = GetFactory()->NewAdaptor(typeid(std::string), @@ -488,14 +519,15 @@ namespace bbtk } //======================================================================= + + //======================================================================= /// prints the list of the boxes of the current descriptor - void Executer::PrintBoxes() + void Executer::PrintHelpListBoxes() { - bbtkMessageInc("Help",1,"The black box descriptor \"" - <GetTypeName()<<"\" contains : "<GetTypeName()<<"\" contains : "<PrintBlackBoxes(); - bbtkDecTab("Help",1); } //======================================================================= @@ -510,33 +542,7 @@ namespace bbtk { int detail = atoi(detailStr.c_str()); int level = atoi(levelStr.c_str()); - - std::string filename_rootHtml (output_html) ; - std::string simplefilename_rootHtml ( Utilities::get_file_name(output_html)); - - bool relative_link = true; - - // No output provided : automatic generation - if (output_html.length() == 0) - { - // Don't pollute the file store with "temp_dir" directories ... - std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_temp_dir(); - - char c = default_doc_dir.c_str()[strlen(default_doc_dir.c_str())-1]; - - std::string directory = default_doc_dir; - if (c != '/' && c !='\\') directory = directory + "/"; - directory = directory + "temp_dir"; - - filename_rootHtml = directory + "/" + "User.html"; - simplefilename_rootHtml = "User.html" ; - - // Creating directory - std::string command0("mkdir \"" +directory + "\""); - system( command0.c_str() ); - - relative_link = false; - } + bool relative_link = true; Package::Pointer p; try @@ -547,13 +553,30 @@ namespace bbtk { p = GetUserPackage(); } + + std::string doc_path = bbtk::ConfigurationFile::GetInstance().Get_doc_path(); + doc_path += bbtk::ConfigurationFile::GetInstance().Get_file_separator(); + doc_path += "bbdoc"; + doc_path += bbtk::ConfigurationFile::GetInstance().Get_file_separator(); + + std::string pack_name(p->GetName()); + std::string pack_path = doc_path + pack_name; + // Creating directory + if ( ! bbtk::Utilities::FileExists(pack_path) ) + { + std::string command("mkdir \"" +pack_path+ "\""); + system( command.c_str() ); + } + std::string pack_index(pack_path); + pack_index += bbtk::ConfigurationFile::GetInstance().Get_file_separator(); + pack_index += "index.html"; + + // Generating documentation-help of workspace - p->SetDocURL(filename_rootHtml); - p->SetDocRelativeURL(simplefilename_rootHtml); - - p->CreateHtmlPage(filename_rootHtml,"bbtk","user package",custom_header,custom_title,detail,level,relative_link); - - std::string page = filename_rootHtml; + p->SetDocURL(pack_index); + p->SetDocRelativeURL("index.html"); + p->CreateHtmlPage(pack_index,"bbtk","user package",custom_header,custom_title,detail,level,relative_link); + /* try { @@ -565,7 +588,7 @@ namespace bbtk page = ShowGraphInstances(nameblackbox,detail,level,system_display); } */ - return page; + return pack_index; } //======================================================================= @@ -623,7 +646,6 @@ namespace bbtk } else { s << "
" << blackbox->bbGetName()<< "
"; } - blackbox->bbInsertHTMLGraph( s, detail, level, true, directory, false ); s << "\n"; } @@ -634,15 +656,15 @@ namespace bbtk } else { - bbtkMessageInc("Help",1,"No black box: \"" - <bbShowRelations(blackbox,detail,level); //,mFactory); + blackbox->bbPrintHelp(blackbox,detail,level); //,mFactory); } if (!found) { - bbtkError("Blackbox Name not found.. <" <"); + bbtkError("box with name '" <