From: Daniel Gonzalez Date: Thu, 17 Jan 2013 19:05:53 +0000 (+0100) Subject: Feature #1711 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=2fb5dd9262993efaf56bfc731f4297fdb96bf63e;p=crea.git Feature #1711 CreaDevManager application implementation -Project structure report implemented! available in project actions panel -fixed bug when refreshing project with no open project. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 4393e64..ca43033 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # --------------------------------------------------------------------- # # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image -# pour la Santé) +# 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 diff --git a/appli/creaDevManager/CMakeLists.txt b/appli/creaDevManager/CMakeLists.txt index bec75cd..0a5320a 100644 --- a/appli/creaDevManager/CMakeLists.txt +++ b/appli/creaDevManager/CMakeLists.txt @@ -1,7 +1,7 @@ # --------------------------------------------------------------------- # # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image -# pour la Santé) +# 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 @@ -71,3 +71,9 @@ SET ( ${EXE_NAME}_LINK_LIBRARIES #-Creates and installs the exe----------------------------------------------- CREA_ADD_EXECUTABLE( ${EXE_NAME} ) #============================================================================ + +CONFIGURE_FILE( + ${CMAKE_CURRENT_SOURCE_DIR}/about.html + ${EXECUTABLE_OUTPUT_PATH}/about.html + @ONLY IMMEDIATE + ) diff --git a/appli/creaDevManager/about.html b/appli/creaDevManager/about.html new file mode 100644 index 0000000..19d43e6 --- /dev/null +++ b/appli/creaDevManager/about.html @@ -0,0 +1,31 @@ + + + + + + + + + +
+
+ CREA Development Manager + +
+
+

Creatis 2012 - Lyon, France

+ + + + + +
+

Created by Daniel González - daniel.gonzalez@creatis.insa-lyon.fr

+
+ +

This software is governed by the CeCILL-B license under French law and abiding by the rules of distribution of free software.

+
+
+
+ + diff --git a/install/CMakeLists.txt b/install/CMakeLists.txt index d4620cd..f003414 100644 --- a/install/CMakeLists.txt +++ b/install/CMakeLists.txt @@ -1,7 +1,7 @@ # --------------------------------------------------------------------- # # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image -# pour la Santé) +# 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 @@ -92,6 +92,7 @@ SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE.txt") SET(CPACK_PACKAGE_VERSION_MAJOR ${crea_MAJOR_VERSION}) SET(CPACK_PACKAGE_VERSION_MINOR ${crea_MINOR_VERSION}) SET(CPACK_PACKAGE_VERSION_PATCH ${crea_BUILD_VERSION}) + IF(WIN32) SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CreaTools\\\\crea-${crea_MAJOR_VERSION}.${crea_MINOR_VERSION}.${crea_BUILD_VERSION}") ELSE(WIN32) diff --git a/lib/creaDevManagerLib/creaDevManagerIds.h b/lib/creaDevManagerLib/creaDevManagerIds.h index f595934..4376d3e 100644 --- a/lib/creaDevManagerLib/creaDevManagerIds.h +++ b/lib/creaDevManagerLib/creaDevManagerIds.h @@ -115,4 +115,6 @@ #define ID_CHECKBOX_DISABLE_HELP 10335 #define ID_CHECKBOX_TOGGLE_HELP 10335 +#define ID_BUTTON_CHECK_PROJECT 10336 + #endif /* CREADEVMANAGERIDS_H_ */ diff --git a/lib/creaDevManagerLib/modelCDMAppli.cpp b/lib/creaDevManagerLib/modelCDMAppli.cpp index 7669853..586c550 100644 --- a/lib/creaDevManagerLib/modelCDMAppli.cpp +++ b/lib/creaDevManagerLib/modelCDMAppli.cpp @@ -36,6 +36,7 @@ #include #include +#include #include #include "CDMUtilities.h" @@ -303,3 +304,76 @@ const bool modelCDMAppli::Refresh(std::string*& result) std::sort(this->applications.begin(), this->applications.end(), CompareNodeItem); return true; } + +void modelCDMAppli::CheckStructure(std::map& properties) +{ + //check cmake exist + if(this->CMakeLists != NULL) + { + //set properties parameters based on model + for (int i = 0; i < this->applications.size(); i++) + properties["appli add " + this->applications[i]->GetName()] = false; + + //open cmakelists + std::ifstream confFile; + confFile.open((this->CMakeLists->GetPath()).c_str()); + + //take everything that is not commented + std::string fileContent; + + std::string word; + std::vector words; + while(confFile.is_open() && !confFile.eof()) + { + std::getline(confFile,word, '\n'); + if(word[0] != '#') + { + CDMUtilities::splitter::split(words, word, "#", CDMUtilities::splitter::empties_ok); + if (words.size() > 0) + { + word = words[0]; + CDMUtilities::splitter::split(words, word, " ", CDMUtilities::splitter::empties_ok); + for (int i = 0; i < words.size(); i++) + { + if(words[i].substr(0,2) == "//") + break; + fileContent += words[i] + " "; + } + } + } + } + + //check every instruction + std::stringstream ss(fileContent); + while(!ss.eof()) + { + std::getline(ss,word, '('); + + //check instruction name + CDMUtilities::splitter::split(words, word, " ", CDMUtilities::splitter::no_empties); + + //add instructions + if (words.size() > 0 && words[words.size()-1] == "ADD_SUBDIRECTORY") + { + std::getline(ss,word, ')'); + //std::cout << word << std::endl; + CDMUtilities::splitter::split(words, word, " ", CDMUtilities::splitter::no_empties); + + if (words.size() > 0) + { + { + properties["appli add " + words[0]] = true; + } + } + } + } + + } + + //check libraries' structure + for (int i = 0; i < this->applications.size(); i++) + { + properties["application " + this->applications[i]->GetName()] = true; + this->applications[i]->CheckStructure(properties); + } +} diff --git a/lib/creaDevManagerLib/modelCDMAppli.h b/lib/creaDevManagerLib/modelCDMAppli.h index d5df81e..60d66d0 100644 --- a/lib/creaDevManagerLib/modelCDMAppli.h +++ b/lib/creaDevManagerLib/modelCDMAppli.h @@ -37,6 +37,7 @@ #include #include +#include #include"modelCDMFolder.h" #include"modelCDMApplication.h" @@ -56,6 +57,8 @@ public: ); virtual const bool Refresh(std::string*& result); + void CheckStructure(std::map& properties); + private: std::vector applications; }; diff --git a/lib/creaDevManagerLib/modelCDMApplication.cpp b/lib/creaDevManagerLib/modelCDMApplication.cpp index 19cc293..56c9e08 100644 --- a/lib/creaDevManagerLib/modelCDMApplication.cpp +++ b/lib/creaDevManagerLib/modelCDMApplication.cpp @@ -35,6 +35,7 @@ #include "modelCDMApplication.h" #include +#include #include #include "CDMUtilities.h" @@ -421,3 +422,90 @@ const bool modelCDMApplication::Refresh(std::string*& result) this->SortChildren(); return true; } + +void modelCDMApplication::CheckStructure(std::map& properties) +{ + //check cmake exist + if(this->CMakeLists != NULL) + { + //set default properties + properties["application " + this->name + " lib ${crea_LIBRARIES}"] = false; + properties["application " + this->name + " lib ${WXWIDGETS_LIBRARIES}"] = false; + properties["application " + this->name + " lib ${KWWidgets_LIBRARIES}"] = false; + properties["application " + this->name + " lib ${VTK_LIBRARIES}"] = false; + properties["application " + this->name + " lib ${ITK_LIBRARIES}"] = false; + properties["application " + this->name + " lib ${GDCM_LIBRARIES}"] = false; + properties["application " + this->name + " lib ${BOOST_LIBRARIES}"] = false; + + //open cmakelists + std::ifstream confFile; + confFile.open((this->CMakeLists->GetPath()).c_str()); + + //take everything that is not commented + std::string fileContent; + + std::string word; + std::vector words; + while(confFile.is_open() && !confFile.eof()) + { + std::getline(confFile,word, '\n'); + if(word[0] != '#') + { + CDMUtilities::splitter::split(words, word, "#", CDMUtilities::splitter::empties_ok); + if (words.size() > 0) + { + word = words[0]; + CDMUtilities::splitter::split(words, word, " ", CDMUtilities::splitter::empties_ok); + for (int i = 0; i < words.size(); i++) + { + if(words[i].substr(0,2) == "//") + break; + fileContent += words[i] + " "; + } + } + } + } + + //check every instruction + std::stringstream ss(fileContent); + while(!ss.eof()) + { + std::getline(ss,word, '('); + + //check instruction name + CDMUtilities::splitter::split(words, word, " ", CDMUtilities::splitter::no_empties); + + //set instructions + if (words.size() > 0 && words[words.size()-1] == "SET") + { + std::getline(ss,word, ')'); + + CDMUtilities::splitter::split(words, word, " \t", CDMUtilities::splitter::no_empties); + if (words.size() > 1) + { + if (words[0] == "${EXE_NAME}_LINK_LIBRARIES") + { + for (int i = 1; i < words.size(); i++) + { + properties["application " + this->name + " lib " + words[i]] = true; + } + } + } + } + else if (words.size() > 0 && words[words.size()-1] == "INCLUDE_DIRECTORIES") + { + std::getline(ss,word, ')'); + + CDMUtilities::splitter::split(words, word, " \t", CDMUtilities::splitter::no_empties); + + for (int i = 0; i < words.size(); i++) + { + properties["application " + this->name + " dir " + words[i]] = true; + } + + + } + } + + } +} diff --git a/lib/creaDevManagerLib/modelCDMApplication.h b/lib/creaDevManagerLib/modelCDMApplication.h index 4935676..cf97476 100644 --- a/lib/creaDevManagerLib/modelCDMApplication.h +++ b/lib/creaDevManagerLib/modelCDMApplication.h @@ -37,6 +37,7 @@ #include #include +#include #include "modelCDMFolder.h" #include "modelCDMFile.h" @@ -57,6 +58,8 @@ public: virtual const bool Refresh(std::string*& result); + void CheckStructure(std::map& properties); + private: std::string executableName; modelCDMFile* mainFile; diff --git a/lib/creaDevManagerLib/modelCDMLib.cpp b/lib/creaDevManagerLib/modelCDMLib.cpp index a040ae8..e09cf2d 100644 --- a/lib/creaDevManagerLib/modelCDMLib.cpp +++ b/lib/creaDevManagerLib/modelCDMLib.cpp @@ -35,6 +35,7 @@ #include "modelCDMLib.h" #include +#include #include #include "CDMUtilities.h" @@ -304,3 +305,76 @@ const bool modelCDMLib::Refresh(std::string*& result) std::sort(this->libraries.begin(), this->libraries.end(), CompareNodeItem); return true; } + +void modelCDMLib::CheckStructure(std::map& properties) +{ + //check cmake exist + if(this->CMakeLists != NULL) + { + //set properties parameters based on model + for (int i = 0; i < this->libraries.size(); i++) + properties["lib add " + libraries[i]->GetName()] = false; + + //open cmakelists + std::ifstream confFile; + confFile.open((this->CMakeLists->GetPath()).c_str()); + + //take everything that is not commented + std::string fileContent; + + std::string word; + std::vector words; + while(confFile.is_open() && !confFile.eof()) + { + std::getline(confFile,word, '\n'); + if(word[0] != '#') + { + CDMUtilities::splitter::split(words, word, "#", CDMUtilities::splitter::empties_ok); + if (words.size() > 0) + { + word = words[0]; + CDMUtilities::splitter::split(words, word, " ", CDMUtilities::splitter::empties_ok); + for (int i = 0; i < words.size(); i++) + { + if(words[i].substr(0,2) == "//") + break; + fileContent += words[i] + " "; + } + } + } + } + + //check every instruction + std::stringstream ss(fileContent); + while(!ss.eof()) + { + std::getline(ss,word, '('); + + //check instruction name + CDMUtilities::splitter::split(words, word, " ", CDMUtilities::splitter::no_empties); + + //add instructions + if (words.size() > 0 && words[words.size()-1] == "ADD_SUBDIRECTORY") + { + std::getline(ss,word, ')'); + //std::cout << word << std::endl; + CDMUtilities::splitter::split(words, word, " ", CDMUtilities::splitter::no_empties); + + if (words.size() > 0) + { + { + properties["lib add " + words[0]] = true; + } + } + } + } + + } + + //check libraries' structure + for (int i = 0; i < this->libraries.size(); i++) + { + properties["library " + this->libraries[i]->GetName()] = true; + this->libraries[i]->CheckStructure(properties); + } +} diff --git a/lib/creaDevManagerLib/modelCDMLib.h b/lib/creaDevManagerLib/modelCDMLib.h index 49722b1..6b96a76 100644 --- a/lib/creaDevManagerLib/modelCDMLib.h +++ b/lib/creaDevManagerLib/modelCDMLib.h @@ -37,6 +37,7 @@ #include #include +#include #include "modelCDMFolder.h" #include "modelCDMLibrary.h" @@ -57,6 +58,8 @@ public: virtual const bool Refresh(std::string*& result); + void CheckStructure(std::map& properties); + private: std::vector libraries; }; diff --git a/lib/creaDevManagerLib/modelCDMLibrary.cpp b/lib/creaDevManagerLib/modelCDMLibrary.cpp index 3e47717..f67999c 100644 --- a/lib/creaDevManagerLib/modelCDMLibrary.cpp +++ b/lib/creaDevManagerLib/modelCDMLibrary.cpp @@ -35,6 +35,7 @@ #include "modelCDMLibrary.h" #include +#include #include #include "CDMUtilities.h" @@ -194,17 +195,17 @@ bool modelCDMLibrary::SetNameLibrary(const std::string& fileName, std::string*& modelCDMFolder* modelCDMLibrary::CreateFolder(const std::string& name, std::string*& result) { //TODO:: mkdir depending on OS - std::string command = "mkdir \"" + path + CDMUtilities::SLASH + name + "\""; - if(system(command.c_str())) - { - result = new std::string("Error executing: " + command + "."); - return NULL; - } - modelCDMFolder* folder = new modelCDMFolder(this, path + CDMUtilities::SLASH + name, name, level + 1); - this->folders.push_back(folder); - this->children.push_back(folder); - - return folder; + std::string command = "mkdir \"" + path + CDMUtilities::SLASH + name + "\""; + if(system(command.c_str())) + { + result = new std::string("Error executing: " + command + "."); + return NULL; + } + modelCDMFolder* folder = new modelCDMFolder(this, path + CDMUtilities::SLASH + name, name, level + 1); + this->folders.push_back(folder); + this->children.push_back(folder); + + return folder; } const bool modelCDMLibrary::Refresh(std::string*& result) @@ -353,3 +354,78 @@ const bool modelCDMLibrary::Refresh(std::string*& result) std::sort(this->folders.begin(), this->folders.end(), CompareNodeItem); return true; } + +void modelCDMLibrary::CheckStructure(std::map& properties) +{ + //check cmake exist + if(this->CMakeLists != NULL) + { + //set default values + properties["library " + this->name + " lib ${crea_LIBRARIES}"] = false; + properties["library " + this->name + " lib ${WXWIDGETS_LIBRARIES}"] = false; + properties["library " + this->name + " lib ${KWWidgets_LIBRARIES}"] = false; + properties["library " + this->name + " lib ${VTK_LIBRARIES}"] = false; + properties["library " + this->name + " lib ${ITK_LIBRARIES}"] = false; + properties["library " + this->name + " lib ${GDCM_LIBRARIES}"] = false; + properties["library " + this->name + " lib ${BOOST_LIBRARIES}"] = false; + + + //open cmakelists + std::ifstream confFile; + confFile.open((this->CMakeLists->GetPath()).c_str()); + + //take everything that is not commented + std::string fileContent; + + std::string word; + std::vector words; + while(confFile.is_open() && !confFile.eof()) + { + std::getline(confFile,word, '\n'); + if(word[0] != '#') + { + CDMUtilities::splitter::split(words, word, "#", CDMUtilities::splitter::empties_ok); + if (words.size() > 0) + { + word = words[0]; + CDMUtilities::splitter::split(words, word, " ", CDMUtilities::splitter::empties_ok); + for (int i = 0; i < words.size(); i++) + { + if(words[i].substr(0,2) == "//") + break; + fileContent += words[i] + " "; + } + } + } + } + + //check every instruction + std::stringstream ss(fileContent); + while(!ss.eof()) + { + std::getline(ss,word, '('); + + //check instruction name + CDMUtilities::splitter::split(words, word, " ", CDMUtilities::splitter::no_empties); + + //set instructions + if (words.size() > 0 && words[words.size()-1] == "SET") + { + std::getline(ss,word, ')'); + + CDMUtilities::splitter::split(words, word, " \t", CDMUtilities::splitter::no_empties); + if (words.size() > 1) + { + if (words[0] == "${LIBRARY_NAME}_LINK_LIBRARIES") + { + for (int i = 1; i < words.size(); i++) + { + properties["library " + this->name + " lib " + words[i]] = true; + } + } + } + } + } + + } +} diff --git a/lib/creaDevManagerLib/modelCDMLibrary.h b/lib/creaDevManagerLib/modelCDMLibrary.h index fb3b7d9..2a64ff1 100644 --- a/lib/creaDevManagerLib/modelCDMLibrary.h +++ b/lib/creaDevManagerLib/modelCDMLibrary.h @@ -37,6 +37,7 @@ #include #include +#include #include "modelCDMFolder.h" @@ -54,6 +55,8 @@ public: virtual const bool Refresh(std::string*& result); + void CheckStructure(std::map& properties); + private: std::string nameLibrary; std::vector folders; diff --git a/lib/creaDevManagerLib/modelCDMPackage.cpp b/lib/creaDevManagerLib/modelCDMPackage.cpp index 093d610..0f001bb 100644 --- a/lib/creaDevManagerLib/modelCDMPackage.cpp +++ b/lib/creaDevManagerLib/modelCDMPackage.cpp @@ -35,6 +35,7 @@ #include "modelCDMPackage.h" #include +#include #include #include "creaWx.h" @@ -568,3 +569,108 @@ const bool modelCDMPackage::Refresh(std::string*& result) this->SortChildren(); return true; } + +void modelCDMPackage::CheckStructure(std::map& properties) +{ + //check cmake exist + if(this->CMakeLists != NULL) + { + //open cmakelists + std::ifstream confFile; + confFile.open((this->CMakeLists->GetPath()).c_str()); + + //take everything that is not commented + std::string fileContent; + + std::string word; + std::vector words; + while(confFile.is_open() && !confFile.eof()) + { + std::getline(confFile,word, '\n'); + if(word[0] != '#') + { + CDMUtilities::splitter::split(words, word, "#", CDMUtilities::splitter::empties_ok); + if (words.size() > 0) + { + word = words[0]; + CDMUtilities::splitter::split(words, word, " ", CDMUtilities::splitter::empties_ok); + for (int i = 0; i < words.size(); i++) + { + if(words[i].substr(0,2) == "//") + break; + fileContent += words[i] + " "; + } + } + } + } + + //check every instruction + std::stringstream ss(fileContent); + while(!ss.eof()) + { + std::getline(ss,word, '('); + + //check instruction name + CDMUtilities::splitter::split(words, word, " ", CDMUtilities::splitter::no_empties); + + //set instructions + if (words.size() > 0 && words[words.size()-1] == "SET") + { + std::getline(ss,word, ')'); + + CDMUtilities::splitter::split(words, word, " \t", CDMUtilities::splitter::no_empties); + if (words.size() > 1) + { + if (words[0] == "${BBTK_PACKAGE_NAME}_USE_VTK" && words[1] == "ON") + { + properties["package " + this->name + " set USE_VTK"] = true; + } + else if (words[0] == "${BBTK_PACKAGE_NAME}_USE_ITK" && words[1] == "ON") + { + properties["package " + this->name + " set USE_ITK"] = true; + } + else if (words[0] == "${BBTK_PACKAGE_NAME}_USE_GDCM" && words[1] == "ON") + { + properties["package " + this->name + " set USE_GDCM"] = true; + } + else if (words[0] == "${BBTK_PACKAGE_NAME}_USE_GDCM_VTK" && words[1] == "ON") + { + properties["package " + this->name + " set USE_GDCM_VTK"] = true; + } + else if (words[0] == "${BBTK_PACKAGE_NAME}_USE_GSMIS" && words[1] == "ON") + { + properties["package " + this->name + " set USE_GSMIS"] = true; + } + else if (words[0] == "${BBTK_PACKAGE_NAME}_USE_WXWIDGETS" && words[1] == "ON") + { + properties["package " + this->name + " set USE_WXWIDGETS"] = true; + } + else if (words[0] == "${BBTK_PACKAGE_NAME}_USE_KWWIDGETS" && words[1] == "ON") + { + properties["package " + this->name + " set USE_KWWIDGETS"] = true; + } + else if (words[0] == "USE_BOOST" && words[1] == "ON") + { + properties["package " + this->name + " set USE_BOOST"] = true; + } + else if (words[0] == "${BBTK_PACKAGE_NAME}_INCLUDE_DIRS") + { + for (int i = 1; i < words.size(); i++) + { + if(words[i].substr(0,2) == "${" || words[i].substr(0,2) == "..") + properties["package " + this->name + " dir " + words[i]] = true; + } + } + else if (words[0] == "${BBTK_PACKAGE_NAME}_LIBS") + { + for (int i = 1; i < words.size(); i++) + { + properties["package " + this->name + " lib " + words[i]] = true; + } + } + } + } + } + + } +} diff --git a/lib/creaDevManagerLib/modelCDMPackage.h b/lib/creaDevManagerLib/modelCDMPackage.h index de1b0a9..471dbb3 100644 --- a/lib/creaDevManagerLib/modelCDMPackage.h +++ b/lib/creaDevManagerLib/modelCDMPackage.h @@ -37,6 +37,7 @@ #include #include +#include #include"modelCDMFolder.h" #include"modelCDMPackageSrc.h" @@ -73,6 +74,8 @@ public: ); virtual const bool Refresh(std::string*& result); + void CheckStructure(std::map& properties); + private: std::string namePackage; std::string authors; diff --git a/lib/creaDevManagerLib/modelCDMProject.cpp b/lib/creaDevManagerLib/modelCDMProject.cpp index 501d059..51f642a 100644 --- a/lib/creaDevManagerLib/modelCDMProject.cpp +++ b/lib/creaDevManagerLib/modelCDMProject.cpp @@ -765,31 +765,166 @@ bool modelCDMProject::Build(std::string*& result, const std::string& line) bool modelCDMProject::Connect(std::string*& result) { //TODO: adjust for windows and mac - #ifdef _WIN32 - // ------ Windows - #elif __APPLE__ - // ------ Apple - #else - // ------ Linux - //open binary folder - wxDir dir(crea::std2wx((this->buildPath).c_str())); - - //if binary folder can't be opened then return false - if (!dir.IsOpened()) - { - result = new std::string("The build path could not be opened. Make sure to configure the project before compiling it"); - return false; - } - //create plug command - std::string plugComm = "bbPlugPackage \"" + this->buildPath + "\" > \"" + this->buildPath + CDMUtilities::SLASH + "plugging.log\" 2>&1"; - std::cout << "executing '" << plugComm << "'" << std::endl; - //execute plug command - if(system(plugComm.c_str())) - { - //if there was an error then report it - result = new std::string("There was an error plugging the packages of the project, please check the console to read more about the problem."); - return false; - } - #endif - return true; +#ifdef _WIN32 + // ------ Windows +#elif __APPLE__ + // ------ Apple +#else + // ------ Linux + //open binary folder + wxDir dir(crea::std2wx((this->buildPath).c_str())); + + //if binary folder can't be opened then return false + if (!dir.IsOpened()) + { + result = new std::string("The build path could not be opened. Make sure to configure the project before compiling it"); + return false; + } + //create plug command + std::string plugComm = "bbPlugPackage \"" + this->buildPath + "\" > \"" + this->buildPath + CDMUtilities::SLASH + "plugging.log\" 2>&1"; + std::cout << "executing '" << plugComm << "'" << std::endl; + //execute plug command + if(system(plugComm.c_str())) + { + //if there was an error then report it + result = new std::string("There was an error plugging the packages of the project, please check the console to read more about the problem."); + return false; + } +#endif + return true; +} + +void modelCDMProject::CheckStructure(std::map& properties) +{ + //check cmake exist + if(this->CMakeLists != NULL) + { + //set properties parameters based on model + properties["project add appli"] = this->appli != NULL; + properties["project add lib"] = this->lib != NULL; + for (int i = 0; i < this->packages.size(); i++) + properties["project add " + packages[i]->GetName()] = false; + + //open cmakelists + std::ifstream confFile; + confFile.open((this->CMakeLists->GetPath()).c_str()); + + //take everything that is not commented + std::string fileContent; + + std::string word; + std::vector words; + while(confFile.is_open() && !confFile.eof()) + { + std::getline(confFile,word, '\n'); + if(word[0] != '#') + { + CDMUtilities::splitter::split(words, word, "#", CDMUtilities::splitter::empties_ok); + if (words.size() > 0) + { + word = words[0]; + CDMUtilities::splitter::split(words, word, " ", CDMUtilities::splitter::empties_ok); + for (int i = 0; i < words.size(); i++) + { + if(words[i].substr(0,2) == "//") + break; + fileContent += words[i] + " "; + } + } + + } + } + + //check every instruction + std::stringstream ss(fileContent); + while(!ss.eof()) + { + std::getline(ss,word, '('); + + //check instruction name + CDMUtilities::splitter::split(words, word, " ", CDMUtilities::splitter::no_empties); + + //set instructions + if (words.size() > 0 && words[words.size()-1] == "SET") + { + std::getline(ss,word, ')'); + + CDMUtilities::splitter::split(words, word, " ", CDMUtilities::splitter::no_empties); + if (words.size() > 1) + { + if (words[0] == "USE_CREA" && words[1] == "ON") + { + properties["project set USE_CREA"] = true; + } + else if (words[0] == "USE_GDCM" && words[1] == "ON") + { + properties["project set USE_GDCM"] = true; + } + else if (words[0] == "USE_GDCM_VTK" && words[1] == "ON") + { + properties["project set USE_GDCM_VTK"] = true; + } + else if (words[0] == "USE_GDCM2" && words[1] == "ON") + { + properties["project set USE_GDCM2"] = true; + } + else if (words[0] == "USE_WXWIDGETS" && words[1] == "ON") + { + properties["project set USE_WXWIDGETS"] = true; + } + else if (words[0] == "USE_KWWIDGETS" && words[1] == "ON") + { + properties["project set USE_KWWIDGETS"] = true; + } + else if (words[0] == "USE_VTK" && words[1] == "ON") + { + properties["project set USE_VTK"] = true; + } + else if (words[0] == "USE_ITK" && words[1] == "ON") + { + properties["project set USE_ITK"] = true; + } + else if (words[0] == "USE_BOOST" && words[1] == "ON") + { + properties["project set USE_BOOST"] = true; + } + } + } + //add instructions + else if (words.size() > 0 && words[words.size()-1] == "ADD_SUBDIRECTORY") + { + std::getline(ss,word, ')'); + //std::cout << word << std::endl; + CDMUtilities::splitter::split(words, word, " ", CDMUtilities::splitter::no_empties); + + if (words.size() > 0) + { + if(words[0] == "appli") + { + properties["project add "+words[0]] = this->appli != NULL; + } + else if(words[0] == "lib") + { + properties["project add "+words[0]] = this->lib != NULL; + } + else + { + properties["project add "+words[0]] = true; + } + } + } + } + + } + + //check appli's structure + this->appli->CheckStructure(properties); + //check lib's structure + this->lib->CheckStructure(properties); + //check packages' structure + for (int i = 0; i < this->packages.size(); i++) + { + properties["package " + this->packages[i]->GetName()] = true; + this->packages[i]->CheckStructure(properties); + } } diff --git a/lib/creaDevManagerLib/modelCDMProject.h b/lib/creaDevManagerLib/modelCDMProject.h index 87d1d37..7e69c79 100644 --- a/lib/creaDevManagerLib/modelCDMProject.h +++ b/lib/creaDevManagerLib/modelCDMProject.h @@ -37,6 +37,7 @@ #include #include +#include #include "modelCDMFolder.h" #include "modelCDMLib.h" @@ -68,11 +69,6 @@ public: */ ~modelCDMProject(); - /** - * Unimplemented. - */ - void PopulateProject(); - //Getters /** @@ -244,6 +240,12 @@ public: */ bool Connect(std::string*& result); + /** + * Checks the CMakeLists files to see what's going to be compiled and what's not. + * @param properties Map containing the project compilation properties. + */ + void CheckStructure(std::map& properties); + private: diff --git a/lib/creaDevManagerLib/wxCDMMainFrame.cpp b/lib/creaDevManagerLib/wxCDMMainFrame.cpp index 143d239..7f51fa0 100755 --- a/lib/creaDevManagerLib/wxCDMMainFrame.cpp +++ b/lib/creaDevManagerLib/wxCDMMainFrame.cpp @@ -31,9 +31,12 @@ #include #include +#include "creaSystem.h" #include "wx/treectrl.h" #include "wx/treebase.h" #include "wx/tooltip.h" +#include "wx/wxhtml.h" +#include "wx/statline.h" #include "CDMUtilities.h" #include "creaDevManagerIds.h" @@ -58,19 +61,10 @@ BEGIN_EVENT_TABLE(wxCDMMainFrame, wxFrame) EVT_MENU(ID_MENU_NEW_PROJECT, wxCDMMainFrame::OnMenuNewProject) EVT_MENU(ID_MENU_OPEN_PROJECT, wxCDMMainFrame::OnMenuOpenProject) -EVT_MENU(ID_MENU_OPEN_RECENT, wxCDMMainFrame::OnMenuOpenRecent) EVT_MENU(ID_MENU_CLOSE_PROJECT, wxCDMMainFrame::OnMenuCloseProject) -EVT_MENU(ID_MENU_CLOSE_ALL_PROJECTS, wxCDMMainFrame::OnMenuCloseAllProjects) EVT_MENU(ID_MENU_EXPORT_HIERARCHY, wxCDMMainFrame::OnMenuExportHierarchy) EVT_MENU(ID_MENU_EXIT, wxCDMMainFrame::OnMenuExit) EVT_MENU(ID_MENU_REFRESH_PROJECT, wxCDMMainFrame::OnMenuRefreshProject) -EVT_MENU(ID_MENU_CUT, wxCDMMainFrame::OnMenuMenuCut) -EVT_MENU(ID_MENU_COPY, wxCDMMainFrame::OnMenuMenuCopy) -EVT_MENU(ID_MENU_PASTE, wxCDMMainFrame::OnMenuMenuPaste) -EVT_MENU(ID_MENU_DELETE, wxCDMMainFrame::OnMenuMenuDelete) -EVT_MENU(ID_MENU_SELECT_ALL, wxCDMMainFrame::OnMenuSelectAll) -EVT_MENU(ID_MENU_SELECT_NONE, wxCDMMainFrame::OnMenuSelectNone) -EVT_MENU(ID_MENU_EVENT_LOG, wxCDMMainFrame::OnMenuEventLog) EVT_MENU(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxCDMMainFrame::OnMenuBBTKGraphicalEditor) EVT_MENU(ID_MENU_MINITOOLS, wxCDMMainFrame::OnMenuMiniTools) EVT_MENU(ID_MENU_CODE_EDITOR, wxCDMMainFrame::OnMenuCodeEditor) @@ -160,10 +154,8 @@ void wxCDMMainFrame::CreateMenus() menu_File = new wxMenu(); menu_File->Append(ID_MENU_NEW_PROJECT, wxT("&New Project...")); menu_File->Append(ID_MENU_OPEN_PROJECT, wxT("&Open Project...")); - menu_File->Append(ID_MENU_OPEN_RECENT, wxT("Open &Recent")); menu_File->AppendSeparator(); menu_File->Append(ID_MENU_CLOSE_PROJECT, wxT("&Close Project")); - menu_File->Append(ID_MENU_CLOSE_ALL_PROJECTS, wxT("C&lose All Projects")); menu_File->AppendSeparator(); menu_File->Append(ID_MENU_EXPORT_HIERARCHY, wxT("&Export Project Hierarchy...")); menu_File->AppendSeparator(); @@ -174,20 +166,11 @@ void wxCDMMainFrame::CreateMenus() //EditMenu menu_Edit = new wxMenu(); menu_Edit->Append(ID_MENU_REFRESH_PROJECT, wxT("&Refresh Project")); - menu_Edit->AppendSeparator(); - menu_Edit->Append(ID_MENU_CUT, wxT("Cu&t")); - menu_Edit->Append(ID_MENU_COPY, wxT("&Copy")); - menu_Edit->Append(ID_MENU_PASTE, wxT("&Paste")); - menu_Edit->AppendSeparator(); - menu_Edit->Append(ID_MENU_DELETE, wxT("&Delete")); - menu_Edit->Append(ID_MENU_SELECT_ALL, wxT("Select &All")); - menu_Edit->Append(ID_MENU_SELECT_NONE, wxT("Ca&ncel Selection")); menuBar->Append(menu_Edit, wxT("&Edit")); //ToolsMenu menu_Tools = new wxMenu(); - menu_Tools->Append(ID_MENU_EVENT_LOG, wxT("Event &Log")); menu_Tools->Append(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxT("BBTK &Graphical Editor")); menu_Tools->Append(ID_MENU_MINITOOLS, wxT("&MiniTools")); menu_Tools->Append(ID_MENU_CODE_EDITOR, wxT("&Code Editor")); @@ -368,13 +351,13 @@ void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event) std::cout << "building ui" << std::endl; - //populate tree control tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject()); tree_Projects->SelectItem(this->model->GetProject()->GetId(), false); tree_Projects->SelectItem(this->model->GetProject()->GetId(), true); + //change project's actions panel if(this->panel_ProjectActions!= NULL) { @@ -398,16 +381,11 @@ void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event) auiManager.Update(); - } event.Skip(); } -void wxCDMMainFrame::OnMenuOpenRecent(wxCommandEvent& event) -{ - std::cerr << "Event OnMenuOpenRecent not implemented" << std::endl; - event.Skip(); -} + void wxCDMMainFrame::OnMenuCloseProject(wxCommandEvent& event) { std::cout << "closing project" << std::endl; @@ -447,44 +425,7 @@ void wxCDMMainFrame::OnMenuCloseProject(wxCommandEvent& event) auiManager.Update(); event.Skip(); } -void wxCDMMainFrame::OnMenuCloseAllProjects(wxCommandEvent& event) -{ - std::cerr << "Event OnMenuCloseAllProjects closing only one project" << std::endl; - std::string* result; - if(!this->model->CloseProject(result)) - { - std::cout << "error closing project: " << *result << std::endl; - wxMessageBox( crea::std2wx(result->c_str()), wxT("Close Project - Error"), wxICON_ERROR); - } - tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject()); - - if(this->panel_Properties != NULL) - { - auiManager.DetachPane(this->panel_Properties); - this->panel_Properties->Destroy(); - this->panel_Properties = NULL; - } - if(this->panel_ProjectActions != NULL) - { - auiManager.DetachPane(this->panel_ProjectActions); - this->panel_ProjectActions->Destroy(); - this->panel_ProjectActions = NULL; - } - - this->panel_Properties = new wxCDMMainDescriptionPanel( - this, - ID_WINDOW_PROPERTIES, - wxT("Description Panel"), - wxDefaultPosition, - wxSize(600, 400), - 0 - ); - - auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400)); - auiManager.Update(); - event.Skip(); -} void wxCDMMainFrame::OnMenuExportHierarchy(wxCommandEvent& event) { std::cerr << "Event OnMenuExportHierarchy not implemented" << std::endl; @@ -527,53 +468,17 @@ void wxCDMMainFrame::OnMenuRefreshProject(wxCommandEvent& event) { wxMessageBox( crea::std2wx(result->c_str()), wxT("Refresh Project - Error"), wxICON_ERROR); } - this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject()); - - this->auiManager.Update(); - - this->tree_Projects->SelectItem(this->model->GetProject()->GetId(), false); - this->tree_Projects->SelectItem(this->model->GetProject()->GetId(), true); + if(this->model->GetProject() != NULL) + { + this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject()); + this->auiManager.Update(); - //TODO: Show possible problems in CMakeLists files - event.Skip(); -} -void wxCDMMainFrame::OnMenuMenuCut(wxCommandEvent& event) -{ - std::cerr << "Event OnMenuMenuCut not implemented" << std::endl; - event.Skip(); -} -void wxCDMMainFrame::OnMenuMenuCopy(wxCommandEvent& event) -{ - std::cerr << "Event OnMenuMenuCopy not implemented" << std::endl; - event.Skip(); -} -void wxCDMMainFrame::OnMenuMenuPaste(wxCommandEvent& event) -{ - std::cerr << "Event OnMenuMenuPaste not implemented" << std::endl; - event.Skip(); -} -void wxCDMMainFrame::OnMenuMenuDelete(wxCommandEvent& event) -{ - std::cerr << "Event OnMenuMenuDelete not implemented" << std::endl; - event.Skip(); -} -void wxCDMMainFrame::OnMenuSelectAll(wxCommandEvent& event) -{ - std::cerr << "Event OnMenuSelectAll not implemented" << std::endl; - event.Skip(); -} -void wxCDMMainFrame::OnMenuSelectNone(wxCommandEvent& event) -{ - std::cerr << "Event OnMenuSelectNone not implemented" << std::endl; + this->tree_Projects->SelectItem(this->model->GetProject()->GetId(), false); + this->tree_Projects->SelectItem(this->model->GetProject()->GetId(), true); + } event.Skip(); } -//Tools Menu -void wxCDMMainFrame::OnMenuEventLog(wxCommandEvent& event) -{ - std::cerr << "Event OnMenuEventLog not implemented" << std::endl; - event.Skip(); -} void wxCDMMainFrame::OnMenuBBTKGraphicalEditor(wxCommandEvent& event) { std::cerr << "Event OnMenuBBTKGraphicalEditor not implemented" << std::endl; @@ -608,23 +513,45 @@ void wxCDMMainFrame::OnMenuCommandLine(wxCommandEvent& event) //Help Menu void wxCDMMainFrame::OnMenuHelp(wxCommandEvent& event) { - std::cerr << "Event OnMenuHelp not implemented" << std::endl; - event.Skip(); + wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/site/en/CreatoolsDocumentation"), 0); } void wxCDMMainFrame::OnMenuReportBug(wxCommandEvent& event) { - std::cerr << "Event OnMenuReportBug not implemented" << std::endl; - event.Skip(); + wxLaunchDefaultBrowser(_T("http://vip.creatis.insa-lyon.fr:9002/projects/crea"), 0); } void wxCDMMainFrame::OnMenuAboutCreaDevManager(wxCommandEvent& event) { - std::cerr << "Event OnMenuAboutCreaDevManager not implemented" << std::endl; - event.Skip(); + wxBoxSizer *topsizer; + wxHtmlWindow *html; + wxDialog dlg(this, wxID_ANY, wxString(_("About"))); + + topsizer = new wxBoxSizer(wxVERTICAL); + + html = new wxHtmlWindow(&dlg, wxID_ANY, wxDefaultPosition, wxSize(380, 160), wxHW_SCROLLBAR_NEVER); + html -> SetBorders(0); + html -> LoadPage(wxT("about.html")); + html -> SetSize(html -> GetInternalRepresentation() -> GetWidth(), + html -> GetInternalRepresentation() -> GetHeight()); + + topsizer -> Add(html, 1, wxALL, 10); + +#if wxUSE_STATLINE + topsizer -> Add(new wxStaticLine(&dlg, wxID_ANY), 0, wxEXPAND | wxLEFT | wxRIGHT, 10); +#endif // wxUSE_STATLINE + + wxButton *bu1 = new wxButton(&dlg, wxID_OK, _("OK")); + bu1 -> SetDefault(); + + topsizer -> Add(bu1, 0, wxALL | wxALIGN_RIGHT, 15); + + dlg.SetSizer(topsizer); + topsizer -> Fit(&dlg); + + dlg.ShowModal(); } void wxCDMMainFrame::OnMenuAboutCreatis(wxCommandEvent& event) { - std::cerr << "Event OnMenuAboutCreatis not implemented" << std::endl; - event.Skip(); + wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/site/en"), 0); } void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event) diff --git a/lib/creaDevManagerLib/wxCDMMainFrame.h b/lib/creaDevManagerLib/wxCDMMainFrame.h index 64a316f..11aa604 100755 --- a/lib/creaDevManagerLib/wxCDMMainFrame.h +++ b/lib/creaDevManagerLib/wxCDMMainFrame.h @@ -95,23 +95,14 @@ protected: //File void OnMenuNewProject(wxCommandEvent& event); void OnMenuOpenProject(wxCommandEvent& event); - void OnMenuOpenRecent(wxCommandEvent& event); void OnMenuCloseProject(wxCommandEvent& event); - void OnMenuCloseAllProjects(wxCommandEvent& event); void OnMenuExportHierarchy(wxCommandEvent& event); void OnMenuExit(wxCommandEvent& event); //Edit void OnMenuRefreshProject(wxCommandEvent& event); - void OnMenuMenuCut(wxCommandEvent& event); - void OnMenuMenuCopy(wxCommandEvent& event); - void OnMenuMenuPaste(wxCommandEvent& event); - void OnMenuMenuDelete(wxCommandEvent& event); - void OnMenuSelectAll(wxCommandEvent& event); - void OnMenuSelectNone(wxCommandEvent& event); //Tools - void OnMenuEventLog(wxCommandEvent& event); void OnMenuBBTKGraphicalEditor(wxCommandEvent& event); void OnMenuMiniTools(wxCommandEvent& event); void OnMenuCodeEditor(wxCommandEvent& event); diff --git a/lib/creaDevManagerLib/wxCDMProjectActionsPanel.cpp b/lib/creaDevManagerLib/wxCDMProjectActionsPanel.cpp index 2d89a2d..3032659 100755 --- a/lib/creaDevManagerLib/wxCDMProjectActionsPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMProjectActionsPanel.cpp @@ -37,7 +37,11 @@ #include "creaDevManagerIds.h" +#include +#include "wxCDMProjectStructureReportDialog.h" + BEGIN_EVENT_TABLE(wxCDMProjectActionsPanel, wxPanel) +EVT_BUTTON(ID_BUTTON_CHECK_PROJECT, wxCDMProjectActionsPanel::OnBtnCheckProjectStructure) EVT_BUTTON(ID_BUTTON_BUILD_PROJECT, wxCDMProjectActionsPanel::OnBtnBuildProject) EVT_BUTTON(ID_BUTTON_CONFIGURE_BUILD, wxCDMProjectActionsPanel::OnBtnConfigureBuild) EVT_BUTTON(ID_BUTTON_CONNECT_PROJECT, wxCDMProjectActionsPanel::OnBtnConnectProject) @@ -81,17 +85,30 @@ bool wxCDMProjectActionsPanel::Create( void wxCDMProjectActionsPanel::CreateControls() { - wxButton* configurebt = new wxButton(this, ID_BUTTON_CONFIGURE_BUILD, _T("1. Configure Project (CMake)")); - configurebt->SetToolTip(wxT("This is the first step in order to execute the project. Make sure you have selected the desired Build location.")); - wxButton* compilebt = new wxButton(this, ID_BUTTON_BUILD_PROJECT, _T("2. Compile Project")); + wxButton* checkStructbt = new wxButton(this, ID_BUTTON_CHECK_PROJECT, _T("1. Check Project Structure")); + checkStructbt->SetToolTip(wxT("This step checks the project structure and tells what is going to be compiled.")); + wxButton* configurebt = new wxButton(this, ID_BUTTON_CONFIGURE_BUILD, _T("2. Configure Project (CMake)")); + configurebt->SetToolTip(wxT("This is the second step in order to execute the project. Make sure you have selected the desired Build location.")); + wxButton* compilebt = new wxButton(this, ID_BUTTON_BUILD_PROJECT, _T("3. Compile Project")); compilebt->SetToolTip(wxT("This step should be done after configuring the project. This will create the executables.")); - wxButton* plugbt = new wxButton(this, ID_BUTTON_CONNECT_PROJECT, _T("3. Plug Packages (BBTK)")); + wxButton* plugbt = new wxButton(this, ID_BUTTON_CONNECT_PROJECT, _T("4. Plug Packages (BBTK)")); plugbt->SetToolTip(wxT("This step should be done after compiling the project. This will allow to use the boxes in this project to be available in the bbEditor.")); + this->GetSizer()->Add(checkStructbt, 0, wxALL, 5); this->GetSizer()->Add(configurebt, 0, wxALL, 5); this->GetSizer()->Add(compilebt, 0, wxALL, 5); this->GetSizer()->Add(plugbt, 0, wxALL, 5); } +//check project structure +void wxCDMProjectActionsPanel::OnBtnCheckProjectStructure(wxCommandEvent& event) +{ + std::map prjStruct; + this->project->CheckStructure(prjStruct); + std::cout << prjStruct.size() << std::endl; + wxCDMProjectStructureReportDialog* structure = new wxCDMProjectStructureReportDialog(this->GetParent(), prjStruct, wxID_ANY); + structure->Show(true); +} + //configure project void wxCDMProjectActionsPanel::OnBtnConfigureBuild(wxCommandEvent& event) { diff --git a/lib/creaDevManagerLib/wxCDMProjectActionsPanel.h b/lib/creaDevManagerLib/wxCDMProjectActionsPanel.h index d01e9e5..dc98709 100755 --- a/lib/creaDevManagerLib/wxCDMProjectActionsPanel.h +++ b/lib/creaDevManagerLib/wxCDMProjectActionsPanel.h @@ -67,6 +67,7 @@ public: protected: void CreateControls(); + void OnBtnCheckProjectStructure(wxCommandEvent& event); void OnBtnConfigureBuild(wxCommandEvent& event); void OnBtnBuildProject(wxCommandEvent& event); void OnBtnConnectProject(wxCommandEvent& event); diff --git a/lib/creaDevManagerLib/wxCDMProjectStructureReportDialog.cpp b/lib/creaDevManagerLib/wxCDMProjectStructureReportDialog.cpp new file mode 100644 index 0000000..8c5ff80 --- /dev/null +++ b/lib/creaDevManagerLib/wxCDMProjectStructureReportDialog.cpp @@ -0,0 +1,558 @@ +/* +# --------------------------------------------------------------------- +# +# 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. +# ------------------------------------------------------------------------ + */ + + +/* + * wxCDMProjectStructureReportDialog.cpp + * + * Created on: 17/1/2013 + * Author: Daniel Felipe Gonzalez Obando + */ + +#include "wxCDMProjectStructureReportDialog.h" + +#include "creaDevManagerIds.h" + +#include +#include +#include "CDMUtilities.h" + +BEGIN_EVENT_TABLE(wxCDMProjectStructureReportDialog, wxDialog) +EVT_BUTTON(ID_BUTTON_CANCEL, wxCDMProjectStructureReportDialog::OnFinish) +END_EVENT_TABLE() + +wxCDMProjectStructureReportDialog::wxCDMProjectStructureReportDialog( + wxWindow* parent, + const std::map& properties, + wxWindowID id, + const wxString& caption, + const wxPoint& position, + const wxSize& size, + long style +) +{ + this->properties = properties; + wxCDMProjectStructureReportDialog::Create(parent, id, caption, position, size, style); +} + +wxCDMProjectStructureReportDialog::~wxCDMProjectStructureReportDialog() +{ +} + +bool wxCDMProjectStructureReportDialog::Create( + wxWindow* parent, + wxWindowID id, + const wxString& caption, + const wxPoint& position, + const wxSize& size, + long int style +) +{ + wxDialog::Create(parent, id, caption, position, size, style); + + this->CreateControls(); + + return TRUE; +} + +void wxCDMProjectStructureReportDialog::CreateControls() +{ + + wxBoxSizer* v_sizer1 = new wxBoxSizer(wxVERTICAL); + + wxHtmlWindow* htmlWindow = new wxHtmlWindow(this, wxID_ANY); + htmlWindow->SetPage(this->GetContent()); + v_sizer1->Add(htmlWindow, 1, wxEXPAND); + v_sizer1->Add(new wxButton(this, ID_BUTTON_CANCEL, wxT("Close")),0,wxEXPAND); + + SetSizer(v_sizer1); +} + +void wxCDMProjectStructureReportDialog::OnFinish(wxCommandEvent& event) +{ + this->EndDialog(wxID_CANCEL); +} + +wxString wxCDMProjectStructureReportDialog::GetContent() +{ + std::map::iterator it, it2; + std::map pkgs; + std::map libs; + std::map applis; + for (it = this->properties.begin(); it != this->properties.end(); it++) + { + std::cout << it->first << " " << it->second << std::endl; + if(it->first.substr(0,7) == "package") + { + std::vector words; + CDMUtilities::splitter::split(words, it->first, " ", CDMUtilities::splitter::no_empties); + pkgs[words[1]] = true; + } + else if(it->first.substr(0,7) == "library") + { + std::vector words; + CDMUtilities::splitter::split(words, it->first, " ", CDMUtilities::splitter::no_empties); + libs[words[1]] = true; + } + else if(it->first.substr(0,11) == "application") + { + std::vector words; + CDMUtilities::splitter::split(words, it->first, " ", CDMUtilities::splitter::no_empties); + applis[words[1]] = true; + } + } + std::string report = ""; + report += + "" + "" + " Project Structure Check Report" + "" + "" + "

Project Structure Check Report

" + "
" + "

Project CMakeLists.txt

" + "

" + " Includes the following built-in libraries:" + "

    "; + if(this->properties["project set USE_CREA"]) + report += + "
  • Crea
  • "; + if(this->properties["project set USE_GDCM"]) + report += + "
  • GDCM
  • "; + if(this->properties["project set USE_GDCM_VTK"]) + report += + "
  • GDCM_VTK
  • "; + if(this->properties["project set USE_GDCM2"]) + report += + "
  • GDCM2
  • "; + if(this->properties["project set USE_WXWIDGETS"]) + report += + "
  • wxWidgets
  • "; + if(this->properties["project set USE_KWWIDGETS"]) + report += + "
  • kwWidgets
  • "; + if(this->properties["project set USE_VTK"]) + report += + "
  • VTK
  • "; + if(this->properties["project set USE_ITK"]) + report += + "
  • ITK
  • "; + if(this->properties["project set USE_BOOST"]) + report += + "
  • Boost
  • "; + report+= + "
" + "

" + "

" + " Doesn't include the following built-in libraries:" + "

    "; + if(!this->properties["project set USE_CREA"]) + report += + "
  • Crea
  • "; + if(!this->properties["project set USE_GDCM"]) + report += + "
  • GDCM
  • "; + if(!this->properties["project set USE_GDCM_VTK"]) + report += + "
  • GDCM_VTK
  • "; + if(!this->properties["project set USE_GDCM2"]) + report += + "
  • GDCM2
  • "; + if(!this->properties["project set USE_WXWIDGETS"]) + report += + "
  • wxWidgets
  • "; + if(!this->properties["project set USE_KWWIDGETS"]) + report += + "
  • kwWidgets
  • "; + if(!this->properties["project set USE_VTK"]) + report += + "
  • VTK
  • "; + if(!this->properties["project set USE_ITK"]) + report += + "
  • ITK
  • "; + if(!this->properties["project set USE_BOOST"]) + report += + "
  • Boost
  • "; + report+= + "
" + "

" + "

" + " Includes:" + "

    "; + if(this->properties["project add lib"]) + report += + "
  • Lib
  • "; + if(this->properties["project add appli"]) + report += + "
  • Appli
  • "; + for (it = this->properties.begin(); it != this->properties.end(); it++) + { + if(it->second == true && it->first.substr(0,11) == "project add") + { + std::string namePkg = it->first.substr(12); + if (namePkg.substr(0,4) == "bbtk") + report += + "
  • Package " + namePkg + "
  • "; + } + } + report+= + "
" + "

" + "

Doesn't include:" + "

    "; + if(!this->properties["project add lib"]) + report += + "
  • " + " Lib: use" + "
    ADD_SUBDIRECTORY(lib)
    " + " in the project CMakeLists file." + "
  • "; + if(!this->properties["project add appli"]) + report += + "
  • " + " Appli: use" + "
    ADD_SUBDIRECTORY(appli)
    " + " in the project CMakeLists file." + "
  • "; + for (it = this->properties.begin(); it != this->properties.end(); it++) + { + if(it->second == false && it->first.substr(0,11) == "project add") + { + std::string namePkg = it->first.substr(12); + report += + "
  • " + " Package \"" + namePkg + "\": use" + "
    ADD_SUBDIRECTORY(" + namePkg + ")
    " + " in the project CMakeLists file." + "
  • "; + } + } + report+= + "
" + "

" + "
"; + + for (it = pkgs.begin(); it != pkgs.end(); it++) + { + report += + "
first + "Chk\">" + "

Package " + it->first + " CMakeLists.txt

" + "

" + " Includes the following built-in libraries:" + "

    "; + if(this->properties["package " + it->first + " set USE_VTK"]) + report += + "
  • VTK
  • "; + if(this->properties["package " + it->first + " set USE_ITK"]) + report += + "
  • ITK
  • "; + if(this->properties["package " + it->first + " set USE_GDCM"]) + report += + "
  • GDCM
  • "; + if(this->properties["package " + it->first + " set USE_GDC_VTK"]) + report += + "
  • GDCM_VTK
  • "; + if(this->properties["package " + it->first + " set USE_GSMIS"]) + report += + "
  • GSMIS
  • "; + if(this->properties["package " + it->first + " set USE_WXWIDGETS"]) + report += + "
  • wxWidgets
  • "; + if(this->properties["package " + it->first + " set USE_KWWIDGETS"]) + report += + "
  • kwWidgets
  • "; + report += + "
" + "

" + "

" + " Doesn't include the following built-in libraries:" + "

    "; + if(!this->properties["package " + it->first + " set USE_VTK"]) + report += + "
  • VTK
  • "; + if(!this->properties["package " + it->first + " set USE_ITK"]) + report += + "
  • ITK
  • "; + if(!this->properties["package " + it->first + " set USE_GDCM"]) + report += + "
  • GDCM
  • "; + if(!this->properties["package " + it->first + " set USE_GDC_VTK"]) + report += + "
  • GDCM_VTK
  • "; + if(!this->properties["package " + it->first + " set USE_GSMIS"]) + report += + "
  • GSMIS
  • "; + if(!this->properties["package " + it->first + " set USE_WXWIDGETS"]) + report += + "
  • wxWidgets
  • "; + if(!this->properties["package " + it->first + " set USE_KWWIDGETS"]) + report += + "
  • kwWidgets
  • "; + report += + "
" + "

" + "

" + " Includes the following additional directories:" + "

    "; + for (it2 = this->properties.begin(); it2 != this->properties.end(); it2++) + { + std::string pkgname = "package " + it->first + " dir"; + if(it2->first.substr(0,pkgname.size()) == pkgname) + { + std::string directoryName = it2->first.substr(pkgname.size()+1); + report += + "
  • " + directoryName + "
  • "; + } + } + report += + "
" + "

" + "

" + " Includes the following libraries:" + "

    "; + for (it2 = this->properties.begin(); it2 != this->properties.end(); it2++) + { + std::string pkgname = "package " + it->first + " lib"; + if(it2->first.substr(0,pkgname.size()) == pkgname) + { + std::string libraryName = it2->first.substr(pkgname.size()+1); + report += + "
  • " + libraryName + "
  • "; + } + } + report += + "
" + "

" + "

" + " Note:
" + " Please include the following lines in the package CMakeLists file in order to add a library:
" + " - In section SET(${BBTK_PACKAGE_NAME}_INCLUDE_DIRS use:" + "

" + " ../lib/[libraryFolderName]" + "
" + " - In section SET(${BBTK_PACKAGE_NAME}_LIBS use:" + "
" + " [libraryName]" + "
" + "

" + "
"; + } + report += + "
" + "

Lib CMakeLists.txt

" + "

" + " Includes libraries:" + "

    "; + for (it = this->properties.begin(); it != this->properties.end(); it++) + { + if(it->second == true && it->first.substr(0, 7) == "lib add") + { + std::string nameLib = it->first.substr(8); + report += + "
  • " + nameLib + "
  • "; + } + } + report += + "
" + "

" + "

Doesn't include libraries:" + "

    "; + for (it = this->properties.begin(); it != this->properties.end(); it++) + { + if(it->second == false && it->first.substr(0, 7) == "lib add") + { + std::string nameLib = it->first.substr(8); + report += + "
  • " + nameLib + "
  • "; + } + } + report += + "
" + "

" + "

" + " Note:
" + " Please include the following lines in the lib CMakeLists file in order to add a library:" + "

ADD_SUBDIRECTORY([libraryName])
" + "

" + "
"; + for (it = libs.begin(); it != libs.end(); it++) + { + report += + "
first + "Chk\">" + "

Library " + it->first + " CMakeLists.txt

" + "

" + " Includes the following libraries:" + "

    "; + for (it2 = this->properties.begin(); it2 != this->properties.end(); it2++) + { + std::string libname = "library " + it->first + " lib"; + if(it2->second == true && it2->first.substr(0,libname.size()) == libname) + { + std::string libraryName = it2->first.substr(libname.size()+1); + report += + "
  • " + libraryName + "
  • "; + } + } + report += + "
" + "

" + "

" + " Doesn't include the following libraries:" + "

    "; + for (it2 = this->properties.begin(); it2 != this->properties.end(); it2++) + { + std::string libname = "library " + it->first + " lib"; + if(it2->second == false && it2->first.substr(0,libname.size()) == libname) + { + std::string libraryName = it2->first.substr(libname.size()+1); + report += + "
  • " + libraryName + "
  • "; + } + } + report += + "
" + "

" + "

" + " Note:
" + " Please include the following line in the library CMakeLists file in order to add a library:" + "

[libraryName]
" + " on SET ( ${LIBRARY_NAME}_LINK_LIBRARIES section if needed." + "

" + "
"; + } + report += + "
" + "

Appli CMakeLists.txt

" + "

" + " Includes applications:" + "

    "; + for (it = this->properties.begin(); it != this->properties.end(); it++) + { + if(it->second == true && it->first.substr(0, 9) == "appli add") + { + std::string nameAppli = it->first.substr(10); + report += + "
  • " + nameAppli + "
  • "; + } + } + report += + "
" + "

" + "

Doesn't include applications:" + "

    "; + for (it = this->properties.begin(); it != this->properties.end(); it++) + { + if(it->second == false && it->first.substr(0, 9) == "appli add") + { + std::string nameAppli = it->first.substr(10); + report += + "
  • " + nameAppli + "
  • "; + } + } + report += + "
" + "

" + "

" + " Note:
" + " Please include the following lines in the appli CMakeLists file in order to add an application:" + "

ADD_SUBDIRECTORY([applicationName])
" + "

" + "
"; + for (it = applis.begin(); it != applis.end(); it++) + { + report += + "
first + "Chk\">" + "

Application " + it->first + " CMakeLists.txt

" + "

" + " Includes the following libraries:" + "

    "; + for (it2 = this->properties.begin(); it2 != this->properties.end(); it2++) + { + std::string appliname = "application " + it->first + " dir"; + if(it2->second && it2->first.substr(0,appliname.size()) == appliname) + { + std::string directoryName = it2->first.substr(appliname.size()+1); + report += + "
  • " + directoryName + "
  • "; + } + } + report += + "
" + "

" + "

" + " Includes the following libraries:" + "

    "; + for (it2 = this->properties.begin(); it2 != this->properties.end(); it2++) + { + std::string appliname = "application " + it->first + " lib"; + if(it2->second && it2->first.substr(0,appliname.size()) == appliname) + { + std::string libraryName = it2->first.substr(appliname.size()+1); + report += + "
  • " + libraryName + "
  • "; + } + } + report += + "
" + "

" + "

" + " Doesn't include the following libraries:" + "

    "; + for (it2 = this->properties.begin(); it2 != this->properties.end(); it2++) + { + std::string appliname = "application " + it->first + " lib"; + if(it2->second == false && it2->first.substr(0,appliname.size()) == appliname) + { + std::string libraryName = it2->first.substr(appliname.size()+1); + report += + "
  • " + libraryName + "
  • "; + } + } + report += + "
" + "

" + "

" + " Note:
" + " Please include the following lines in the application CMakeLists file in order to add a library:
" + " - In section INCLUDE_DIRECTORIES( use:" + "

" + " ../lib/[libraryFolderName]" + "
" + " - In section SET(${EXE_NAME}_LINK_LIBRARIES use:" + "
" + " [libraryName]" + "
" + "

" + "
"; + } + report += + "" + "" + ; + return crea::std2wx(report); +} diff --git a/lib/creaDevManagerLib/wxCDMProjectStructureReportDialog.h b/lib/creaDevManagerLib/wxCDMProjectStructureReportDialog.h new file mode 100644 index 0000000..1536e09 --- /dev/null +++ b/lib/creaDevManagerLib/wxCDMProjectStructureReportDialog.h @@ -0,0 +1,80 @@ +/* +# --------------------------------------------------------------------- +# +# 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. +# ------------------------------------------------------------------------ +*/ + + +/* + * wxCDMProjectStructureReportDialog.h + * + * Created on: 3/1/2013 + * Author: Daniel Felipe Gonzalez Obando + */ + +#ifndef WXCDMPROJECTSTRUCTUREREPORTDIALOG_H_ +#define WXCDMPROJECTSTRUCTUREREPORTDIALOG_H_ + +#include +#include + +#include + +class wxCDMProjectStructureReportDialog : public wxDialog +{ + DECLARE_EVENT_TABLE() +public: + wxCDMProjectStructureReportDialog( + wxWindow* parent, + const std::map& properties, + wxWindowID id = wxID_ANY, + const wxString& caption = wxT("Project Structure Report"), + const wxPoint& position = wxDefaultPosition, + const wxSize& size = wxSize(700,500), + long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER + ); + ~wxCDMProjectStructureReportDialog(); + bool Create( + wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxString& caption = wxT("Project Structure Report"), + const wxPoint& position = wxDefaultPosition, + const wxSize& size = wxSize(700,500), + long style = wxDEFAULT_DIALOG_STYLE + ); + +protected: + void CreateControls(); + +//attributes +private: + std::map properties; + +//handlers +protected: + void OnFinish(wxCommandEvent& event); + wxString GetContent(); +}; + +#endif /* WXCDMPROJECTSTRUCTUREREPORTDIALOG_H_ */