mainWindow = new wxCDMMainFrame(NULL);
SetTopWindow(mainWindow);
- mainWindow->SetSize(750, 700);
+ mainWindow->SetSize(850, 700);
wxToolTip::SetDelay(700);
mainWindow->Show(true);
std::cout << "Crea DevManager opened." << std::endl;
return res;
}
+ std::string readFile(const std::string& file_path)
+ {
+ std::string res;
+ std::ifstream file(file_path.c_str());
+ if (file.is_open())
+ {
+ char ch = file.get();
+ while (!file.eof())
+ {
+ res.push_back(ch);
+ ch = file.get();
+ }
+ file.close();
+ }
+ return res;
+ }
+
+ bool writeFile(const std::string& file_path, const std::string& st)
+ {
+ std::ofstream file(file_path.c_str());
+ if (file.is_open())
+ {
+ file << st;
+ file.close();
+ return true;
+ }
+ return false;
+
+ }
+
+ CMLFile readCMLFile(const std::string& file_path)
+ {
+ CMLFile res;
+
+ std::ifstream file(file_path.c_str());
+ if (file.is_open())
+ {
+ char ch = file.get();
+ while (!file.eof())
+ {
+ syntaxElement element;
+ if (isspace(ch))
+ {
+ //std::cout << "space" << std::endl;
+ element.first = "space";
+ element.second.push_back(std::string(1,ch));
+ }
+ else if (ch == '#')
+ {
+ //std::cout << "comment" << std::endl;
+ element.first = "comment";
+ std::string commentValue;
+ while (ch != '\n')
+ {
+ commentValue.push_back(ch);
+
+ ch = file.get();
+ if (file.eof())
+ break;
+ };
+ if (!file.eof())
+ commentValue.push_back('\n');
+ element.second.push_back(commentValue);
+ }
+ else
+ {
+ //std::cout << "command" << std::endl;
+ element.first = "command";
+ std::string commandValue;
+ while (true)
+ {
+ //std::cout << ch;
+ //std::cout.flush();
+ while(!isspace(ch) && ch != '(' && ch != ')' && ch != '#')
+ {
+ if(ch == '"')
+ {
+ if (commandValue.size()) {
+ element.second.push_back(commandValue);
+ commandValue.clear();
+ }
+ commandValue.push_back(ch);
+ ch = file.get();
+ while(!file.eof() && ch != '"')
+ {
+ if(ch == '\\')
+ {
+ commandValue.push_back(ch);
+ ch = file.get();
+ if(!file.eof())
+ commandValue.push_back(ch);
+ }
+ else
+ {
+ commandValue.push_back(ch);
+ }
+ ch = file.get();
+ }
+ if(!file.eof())
+ commandValue.push_back(ch);
+ element.second.push_back(commandValue);
+ commandValue.clear();
+ }
+ else
+ commandValue.push_back(ch);
+
+ ch = file.get();
+ }
+
+ if (!file.eof() && (isspace(ch) || ch == '(' || ch == ')' || ch == '#'))
+ {
+ if (commandValue.size()) {
+ element.second.push_back(commandValue);
+ commandValue.clear();
+ }
+ commandValue.push_back(ch);
+ if (ch == '#') {
+ while (ch != '\n') {
+ ch = file.get();
+ if (file.eof())
+ break;
+ commandValue.push_back(ch);
+ };
+ }
+ element.second.push_back(commandValue);
+ if (commandValue == ")")
+ {
+ commandValue.clear();
+ break;
+ }
+ commandValue.clear();
+ }
+
+ ch = file.get();
+ if (file.eof())
+ break;
+ }
+ }
+ res.push_back(element);
+
+ ch = file.get();
+ if (file.eof())
+ break;
+ }
+
+ file.close();
+ }
+
+/*
+ std::cout << "CMakeLists: " << file_path << std::endl;
+ for (int i = 0; i < res.size(); ++i) {
+ if (res[i].first == "command")
+ std::cout << "@";
+ for (int j = 0; j < res[i].second.size(); ++j) {
+ std::cout << "~" << res[i].second[j];
+ }
+ if (res[i].first == "command")
+ std::cout << "@";
+ }
+ std::cout << "End of file" << std::endl;
+*/
+ return res;
+ }
+
+ bool writeCMLFile(const std::string& file_path, const CMLFile& data)
+ {
+ std::ofstream file(file_path.c_str());
+ if(file.is_open())
+ {
+ for (int i = 0; i < data.size(); ++i) {
+ for (int j = 0; j < data[i].second.size(); ++j) {
+ file << data[i].second[j];
+ }
+ }
+ file.close();
+ return true;
+ }
+ return false;
+ }
+
+
+
+ void
+ normalizeStr(std::string& st)
+ {
+ while(st.size() && isspace(st[0]))
+ st.erase(0,1);
+ while(st.size() && isspace(st[st.size()-1]))
+ st.erase(st.size()-1,1);
+ return;
+ }
+
}
#define CDMUTILITIES_H_
#include<iostream>
+#include<vector>
#include<cstddef>
namespace CDMUtilities
* @return line stringified.
*/
std::string stringify(const std::string& line);
+
+ //CMakeLists file handling
+ /**
+ * Type definition for the value of a syntax element for CMakeLists files
+ */
+ typedef std::vector<std::string> cmdValue;
+
+ /**
+ * Type definition for the type of a syntax element for CMakeLists files
+ */
+ typedef std::string cmdType;
+
+ /**
+ * Type definition for syntax elements of a CMakeLists file
+ */
+ typedef std::pair<cmdType,cmdValue> syntaxElement;
+
+ /**
+ * Type definition for describing a CMakeLists file content
+ */
+ typedef std::vector<syntaxElement> CMLFile;
+
+ /**
+ * Reads a file as string and returns the read data.
+ * @param file_path Full path of the CMakeLists file.
+ * @return A string with the contents of the given file.
+ */
+ std::string readFile(const std::string& file_path);
+ /**
+ * Writes the given string into a file and returns whether the operation is successful.
+ * @param file_path Full path of the CMakeLists file.
+ * @param st string to write.
+ * @return True if the operation was successful.
+ */
+ bool writeFile(const std::string& file_path, const std::string& st);
+
+ /**
+ * Reads a CMakeLists file and returns the read data.
+ * @param file_path Full path of the CMakeLists file.
+ * @return A CMLFile with the contents of the given file.
+ */
+ CMLFile readCMLFile(const std::string& file_path);
+
+ /**
+ * Writes the given data into specified CMakeLists file.
+ * @param file_path Full path of the CMakeLists file.
+ * @param data CMakeLists data.
+ * @return True if the operation was successful.
+ */
+ bool writeCMLFile(const std::string& file_path, const CMLFile& data);
+
+ /**
+ * @param st Strips all space character at the beginning and at the end of the string.
+ */
+ void normalizeStr(std::string& st);
+
};
#endif /* CDMUTILITIES_H_ */
# ---------------------------------------------------------------------
#
# 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
# ${VTK_LIBRARIES}
# ${ITK_LIBRARIES}
# ${GDCM_LIBRARIES}
- # ${BOOST_LIBRARIES}
+ ${BOOST_LIBRARIES}
# If this library must link against other libraries
# USER! : Add here any extra Library you need
#define ID_BUTTON_OPEN_COMMAND 10317
#define ID_BUTTON_SET_VERSION 10318
#define ID_BUTTON_SET_BUILD_PATH 10319
-#define ID_BUTTON_SET_AUTHOR 10320
-#define ID_BUTTON_SET_DESCRIPTION 10321
-#define ID_BUTTON_SET_NAME 10322
-#define ID_BUTTON_SET_CATEGORY 10323
-
-
-#define ID_BUTTON_BUILD_PROJECT 10324
-#define ID_BUTTON_CONFIGURE_BUILD 10325
-#define ID_BUTTON_CONNECT_PROJECT 10326
-
-#define ID_BUTTON_GOTO_PACKAGE_MANAGER 10327
-#define ID_BUTTON_GOTO_APPLI_MANAGER 10328
-#define ID_BUTTON_GOTO_LIB_MANAGER 10329
-
-#define ID_LINK_SELECT_PACKAGE 10330
-#define ID_LINK_SELECT_LIBRARY 10331
-#define ID_LINK_SELECT_APPLICATION 10332
-#define ID_LINK_SELECT_BLACKBOX 10333
-
-#define ID_CHECKBOX_ENABLE_HELP 10334
-#define ID_CHECKBOX_DISABLE_HELP 10335
-#define ID_CHECKBOX_TOGGLE_HELP 10335
-
-#define ID_BUTTON_CHECK_PROJECT 10336
+#define ID_BUTTON_OPEN_BUILD_PATH 10320
+#define ID_BUTTON_SET_AUTHOR 10321
+#define ID_BUTTON_SET_DESCRIPTION 10322
+#define ID_BUTTON_SET_NAME 10323
+#define ID_BUTTON_SET_CATEGORY 10324
+
+
+#define ID_BUTTON_BUILD_PROJECT 10325
+#define ID_BUTTON_CONFIGURE_BUILD 10326
+#define ID_BUTTON_CONNECT_PROJECT 10327
+
+#define ID_BUTTON_GOTO_PACKAGE_MANAGER 10328
+#define ID_BUTTON_GOTO_APPLI_MANAGER 10329
+#define ID_BUTTON_GOTO_LIB_MANAGER 10330
+
+#define ID_LINK_SELECT_PACKAGE 10331
+#define ID_LINK_SELECT_LIBRARY 10332
+#define ID_LINK_SELECT_APPLICATION 10333
+#define ID_LINK_SELECT_BLACKBOX 10334
+
+#define ID_CHECK_INCLUDE_LIBRARY 10335
+#define ID_CHECK_INCLUDE_3RDLIBRARY 10336
+#define ID_CHECK_INCLUDE_PACKAGE 10337
+#define ID_CHECK_INCLUDE_APPLICATION 10338
+
+#define ID_CHECKBOX_ENABLE_HELP 10339
+#define ID_CHECKBOX_DISABLE_HELP 10340
+#define ID_CHECKBOX_TOGGLE_HELP 10341
+
+#define ID_BUTTON_CHECK_PROJECT 10342
+
+#define ID_MENU_OPEN_RECENT1 10343
+#define ID_MENU_OPEN_RECENT2 10344
+#define ID_MENU_OPEN_RECENT3 10345
+#define ID_MENU_OPEN_RECENT4 10346
+#define ID_MENU_OPEN_RECENT5 10347
#endif /* CREADEVMANAGERIDS_H_ */
return NULL;
}
+ //add application to appli CMakeLists
+ std::fstream out1((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str(), std::fstream::in | std::fstream::out | std::fstream::app);
+ if (out1.is_open())
+ {
+ out1 << "ADD_SUBDIRECTORY(" << name << ")" << std::endl;
+ out1.close();
+ }
+
//add application to model
modelCDMApplication* application = new modelCDMApplication(this, this->path + CDMUtilities::SLASH + name, name, this->level + 1);
this->applications.push_back(application);
return NULL;
}
+ //add application to appli CMakeLists
+ std::fstream out1((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str(), std::fstream::in | std::fstream::out | std::fstream::app);
+ if (out1.is_open())
+ {
+ out1 << "ADD_SUBDIRECTORY(" << name << ")" << std::endl;
+ out1.close();
+ }
+
//add application to model
modelCDMApplication* application = new modelCDMApplication(this, this->path + CDMUtilities::SLASH + name, name, this->level + 1);
this->applications.push_back(application);
this->applications[i]->CheckStructure(properties);
}
}
+
+bool modelCDMAppli::IsApplicationIncluded(const std::string& application_name)
+{
+ if (this->HasCMakeLists())
+ {
+ CDMUtilities::CMLFile cmlFile = CDMUtilities::readCMLFile(this->CMakeLists->GetPath().c_str());
+ for (int i = 0; i < cmlFile.size(); ++i)
+ {
+ if (cmlFile[i].first=="command" && cmlFile[i].second[0] == "ADD_SUBDIRECTORY")
+ {
+ int pos = 1;
+ while (pos < cmlFile[i].second.size())
+ {
+ if (!isspace(cmlFile[i].second[pos][0]) && cmlFile[i].second[pos][0] != '(' && cmlFile[i].second[pos][0] != '#')
+ {
+ if (application_name == cmlFile[i].second[pos])
+ return true;
+ break;
+ }
+ pos++;
+ }
+ }
+ }
+ }
+ return false;
+}
+
+bool modelCDMAppli::SetApplicationInclude(const std::string& application_name, const bool& toInclude)
+{
+ if (this->HasCMakeLists())
+ {
+ CDMUtilities::CMLFile cmlFile = CDMUtilities::readCMLFile(this->CMakeLists->GetPath().c_str());
+
+ bool found = false;
+
+ for (int i = 0; i < cmlFile.size(); ++i)
+ {
+ if(toInclude && cmlFile[i].first == "comment")
+ {
+ std::vector<std::string> segments;
+ std::string line = cmlFile[i].second[0];
+ while(line[0] == '#')
+ line.erase(0,1);
+
+ CDMUtilities::splitter::split(segments, line, " ()", CDMUtilities::splitter::no_empties);
+ if (segments.size() > 1 && segments[0] == "ADD_SUBDIRECTORY" && segments[1] == application_name)
+ {
+ found = true;
+ while(cmlFile[i].second[0][0] == '#')
+ cmlFile[i].second[0].erase(0,1);
+ }
+ }
+ else if(cmlFile[i].first == "command" && cmlFile[i].second[0] == "ADD_SUBDIRECTORY")
+ {
+ int pos = 1;
+ while (pos < cmlFile[i].second.size())
+ {
+ if (!isspace(cmlFile[i].second[pos][0]) && cmlFile[i].second[pos][0] != '(' && cmlFile[i].second[pos][0] != '#')
+ {
+ if (application_name == cmlFile[i].second[pos])
+ {
+ found = true;
+ if (!toInclude)
+ {
+ cmlFile[i].first = "comment";
+ cmlFile[i].second[0] = "#" + cmlFile[i].second[0];
+ while (cmlFile[i].second.size() > 1)
+ {
+ cmlFile[i].second[0] += cmlFile[i].second[1];
+ cmlFile[i].second.erase(cmlFile[i].second.begin()+1);
+ }
+
+ }
+ }
+ break;
+ }
+ pos++;
+ }
+ }
+ }
+ if (!found && toInclude)
+ {
+ CDMUtilities::syntaxElement element;
+ element.first = "command";
+ element.second.push_back("ADD_SUBDIRECTORY(" + application_name + ")");
+ cmlFile.push_back(element);
+ }
+
+ return CDMUtilities::writeCMLFile(this->CMakeLists->GetPath().c_str(),cmlFile);
+ }
+ return false;
+}
const std::vector<modelCDMApplication*>& GetApplications() const;
/**
- * Creates a new application in the system and creates an application node. This node is stored in the applications attribute and returned.
+ * Creates a new application in the system and creates an application node. This node is stored in the applications attribute and returned. The created application is included in the appli's CMakeLists file.
* @param name Name of the new application.
* @param type 0=console application, 1=GUI Application (wxWidgets).
* @param result Result message of the operation.
*/
void CheckStructure(std::map<std::string, bool>& properties);
+ /**
+ * Checks if the given application is included in the CMakeLists file.
+ * @param application_name Name of the library to check.
+ * @return True if the library is included, otherwise returns False.
+ */
+ bool IsApplicationIncluded(const std::string& application_name);
+
+ /**
+ * Sets the inclusion of the application in the lib's CMakeLists file. If the application inclusion already exist in file, then the line is uncommented/commented depending on the requested action. If the application inclusion doesn't exist yet, then it is included if the request is an inclusion.
+ * @param application_name Name of the application to include/exclude.
+ * @param toInclude True if the request is an inclusion, False otherwise.
+ * @return True if the request was processed successfully.
+ */
+ bool SetApplicationInclude(const std::string& application_name, const bool& toInclude);
+
private:
/**
* application in the appli folder node.
#include "modelCDMApplication.h"
+#include "modelCDMProject.h"
+#include "modelCDMLib.h"
+#include "modelCDMLibrary.h"
+
#include <fstream>
#include <sstream>
#include <algorithm>
+#include <boost/regex.hpp>
#include "CDMUtilities.h"
#include "creaWx.h"
while (cont)
{
std::string stdfileName = crea::wx2std(fileName);
-
//if CMakeLists, create CMakeLists
if(stdfileName == "CMakeLists.txt")
{
{
modelCDMFile* file = new modelCDMFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
std::string extension = stdfileName.substr(stdfileName.size()-4);
+ //if is cxx or cpp check if is the main file.
if (mainFile == NULL && (extension == ".cxx" || extension == ".cpp"))
{
- std::ifstream fileStream;
- std::string word;
- fileStream.open((this->path + CDMUtilities::SLASH + stdfileName).c_str());
- while (fileStream.is_open() && !fileStream.eof())
+ std::ifstream fileStream((this->path + CDMUtilities::SLASH + stdfileName).c_str());
+
+ if (fileStream.is_open())
{
- //get sets
- std::getline(fileStream,word,'(');
- std::vector<std::string> wordBits;
- CDMUtilities::splitter::split(wordBits,word," \n",CDMUtilities::splitter::no_empties);
- if (wordBits[wordBits.size() - 1] == "main" || wordBits[wordBits.size() - 1] == "IMPLEMENT_APP")
+ std::string fileContent = "";
+ char ch = fileStream.get();
+ while(!fileStream.eof())
+ {
+ fileContent.push_back(ch);
+ ch = fileStream.get();
+ }
+ fileStream.close();
+
+ boost::regex expression("^\\h*IMPLEMENT_APP[#\\s\\(]");
+ std::string::const_iterator start, end;
+ start = fileContent.begin();
+ end = fileContent.end();
+ boost::match_results<std::string::const_iterator> what;
+ boost::match_flag_type flags = boost::match_default;
+ if(boost::regex_search(start, end, what, expression, flags))
{
+ std::cout << "found main wxwidgets file: " << stdfileName << std::endl;
this->mainFile = file;
}
+ else
+ {
+ expression = boost::regex("^\\h*int\\h+main[#\\s\\(]");
+ start = fileContent.begin();
+ end = fileContent.end();
+ if(boost::regex_search(start, end, what, expression, flags))
+ {
+ std::cout << "found main console file: " << stdfileName << std::endl;
+ this->mainFile = file;
+ }
+ }
}
- fileStream.close();
+
}
this->children.push_back(file);
}
}
}
+
+std::map<std::string, bool> modelCDMApplication::Get3rdPartyLibraries()
+{
+ std::map<std::string, std::string> correspondence;
+ correspondence["${crea_LIBRARIES}"] = "Crea";
+ correspondence["${WXWIDGETS_LIBRARIES}"] = "WxWidgets";
+ correspondence["${KWWidgets_LIBRARIES}"] = "KWWidgets";
+ correspondence["${VTK_LIBRARIES}"] = "VTK";
+ correspondence["${ITK_LIBRARIES}"] = "ITK";
+ correspondence["${GDCM_LIBRARIES}"] = "GDCM";
+ correspondence["${BOOST_LIBRARIES}"] = "Boost";
+ std::map<std::string, bool> res;
+ res["Crea"] = false;
+ res["WxWidgets"] = false;
+ res["KWWidgets"] = false;
+ res["VTK"] = false;
+ res["ITK"] = false;
+ res["GDCM"] = false;
+ res["Boost"] = false;
+
+ if (this->HasCMakeLists())
+ {
+
+ std::string CMfile = CDMUtilities::readFile(this->CMakeLists->GetPath().c_str());
+
+ boost::regex expression("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{EXE_NAME\\}_LINK_LIBRARIES(([\\s]|#[^\\n]*\\n)+([\\$\\{\\}\\w\\d]+|\"(?:[^\"\\\\]|\\\\.)*\"))*([\\s]|#[^\\n]*\\n)*\\)");
+ std::string::const_iterator start, end;
+ start = CMfile.begin();
+ end = CMfile.end();
+ boost::match_results<std::string::const_iterator> what;
+ boost::match_flag_type flags = boost::match_default;
+ if(boost::regex_search(start, end, what, expression, flags))
+ {
+
+ expression = boost::regex("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{EXE_NAME\\}_LINK_LIBRARIES");
+ std::string::const_iterator start1, end1;
+ start1 = what[0].first;
+ end1 = what[0].second;
+ boost::match_results<std::string::const_iterator> what1;
+ if(boost::regex_search(start1, end1, what1, expression, flags))
+ {
+ expression = boost::regex("(#[^\\n]*\\n|\\s*\\$\\{\\w+\\})");
+ std::string::const_iterator start2, end2;
+ start2 = what1[0].second;
+ end2 = what[0].second;
+ boost::match_results<std::string::const_iterator> what2;
+ while(boost::regex_search(start2, end2, what2, expression, flags))
+ {
+ if(what2.str()[0] != '#')
+ {
+ std::string dete = what2.str();
+ CDMUtilities::normalizeStr(dete);
+ if(correspondence.find(dete) != correspondence.end())
+ res[correspondence[dete]] = true;
+ }
+ start2 = what2[0].second;
+ }
+ }
+ }
+ }
+ return res;
+}
+
+bool modelCDMApplication::Set3rdPartyLibrary(const std::string& library_name, const bool& toInclude)
+{
+ std::map<std::string, std::string> correspondence;
+
+ correspondence["Crea"] = "${crea_LIBRARIES}";
+ correspondence["WxWidgets"] = "${WXWIDGETS_LIBRARIES}";
+ correspondence["KWWidgets"] = "${KWWidgets_LIBRARIES}";
+ correspondence["VTK"] = "${VTK_LIBRARIES}";
+ correspondence["ITK"] = "${ITK_LIBRARIES}";
+ correspondence["GDCM"] = "${GDCM_LIBRARIES}";
+ correspondence["Boost"] = "${BOOST_LIBRARIES}";
+
+ std::map<std::string, std::string> regexCorrespondence;
+
+ regexCorrespondence["Crea"] = "\\$\\{crea_LIBRARIES\\}";
+ regexCorrespondence["WxWidgets"] = "\\$\\{WXWIDGETS_LIBRARIES\\}";
+ regexCorrespondence["KWWidgets"] = "\\$\\{KWWidgets_LIBRARIES\\}";
+ regexCorrespondence["VTK"] = "\\$\\{VTK_LIBRARIES\\}";
+ regexCorrespondence["ITK"] = "\\$\\{ITK_LIBRARIES\\}";
+ regexCorrespondence["GDCM"] = "\\$\\{GDCM_LIBRARIES\\}";
+ regexCorrespondence["Boost"] = "\\$\\{BOOST_LIBRARIES\\}";
+
+ if (correspondence.find(library_name) != correspondence.end())
+ {
+ std::string library_command = correspondence[library_name];
+ std::string regex_command = regexCorrespondence[library_name];
+ if (this->HasCMakeLists())
+ {
+ std::string CMfile = CDMUtilities::readFile(this->CMakeLists->GetPath().c_str());
+ std::string resCMfile = "";
+
+ boost::regex expression("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{EXE_NAME\\}_LINK_LIBRARIES(([\\s]|#[^\\n]*\\n)+([\\$\\{\\}\\w\\d]+|\"(?:[^\"\\\\]|\\\\.)*\"))*([\\s]|#[^\\n]*\\n)*\\)");
+ std::string::const_iterator start, end;
+ start = CMfile.begin();
+ end = CMfile.end();
+ boost::match_results<std::string::const_iterator> what;
+ boost::match_flag_type flags = boost::match_default;
+ if(boost::regex_search(start, end, what, expression, flags))
+ {
+ resCMfile += what.prefix().str();
+ bool found = false;
+ if (toInclude) {
+ expression = "^\\h*#+\\h*" + regex_command;
+ std::string::const_iterator start1, end1;
+ start1 = what[0].first;
+ end1 = what[0].second;
+ boost::match_results<std::string::const_iterator> what1, what2;
+ while(boost::regex_search(start1, end1, what1, expression, flags))
+ {
+ found = true;
+ resCMfile += what1.prefix().str();
+ std::string dete = what1[0].str();
+ for (int i = 0; i < dete.size(); ++i) {
+ if (dete[i] != '#')
+ resCMfile.push_back(dete[i]);
+ }
+ what2 = what1;
+ start1 = what1[0].second;
+ }
+ if (found)
+ resCMfile += what2.suffix().str();
+ else
+ {
+ expression = "^\\h*" + regex_command;
+ if(boost::regex_search(start1, end1, what1, expression, flags))
+ found = true;
+
+ expression = "^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{EXE_NAME\\}_LINK_LIBRARIES";
+ boost::regex_search(start1, end1, what1, expression, flags);
+
+ resCMfile += what1.prefix().str() + what1.str();
+ if(!found)
+ resCMfile += "\n" + library_command + "\n";
+ resCMfile += what1.suffix().str();
+ }
+
+ }else{
+ expression = "^\\h*" + regex_command;
+ std::string::const_iterator start1, end1;
+ start1 = what[0].first;
+ end1 = what[0].second;
+ boost::match_results<std::string::const_iterator> what1, what2;
+ while(boost::regex_search(start1, end1, what1, expression, flags))
+ {
+ found = true;
+ resCMfile += what1.prefix().str();
+ resCMfile += "#" + what1.str();
+ what2 = what1;
+ start1 = what1[0].second;
+ }
+ if (found)
+ resCMfile += what2.suffix().str();
+ else
+ {
+ expression = "^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{EXE_NAME\\}_LINK_LIBRARIES";
+ boost::regex_search(start1, end1, what1, expression, flags);
+
+ resCMfile += what1.prefix().str() + what1.str() + what1.suffix().str();
+ }
+ }
+ resCMfile += what.suffix().str();
+
+ return CDMUtilities::writeFile(this->CMakeLists->GetPath().c_str(), resCMfile);
+ }
+ }
+ }
+ return false;
+
+}
+
+std::map<std::string, bool> modelCDMApplication::GetCustomLibraries()
+{
+ std::map<std::string, bool> res;
+ std::map<std::string, bool> res1;
+
+ std::map<std::string, std::string> correspondence;
+ std::vector<modelCDMLibrary*> libraries;
+ if(this->GetParent() != NULL && this->GetParent()->GetParent() != NULL)
+ if(dynamic_cast<modelCDMProject*>(this->GetParent()->GetParent()) != NULL && dynamic_cast<modelCDMProject*>(this->GetParent()->GetParent())->GetLib() != NULL)
+ libraries = (dynamic_cast<modelCDMProject*>(this->GetParent()->GetParent()))->GetLib()->GetLibraries();
+ for (int i = 0; i < libraries.size(); ++i)
+ {
+ correspondence[libraries[i]->GetName()] = libraries[i]->GetNameLibrary();
+ res[libraries[i]->GetNameLibrary()] = false;
+ res1[libraries[i]->GetNameLibrary()] = false;
+ }
+
+ if (this->HasCMakeLists())
+ {
+ std::string CMfile = CDMUtilities::readFile(this->CMakeLists->GetPath().c_str());
+
+ //find included libraries
+ boost::regex expression("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{EXE_NAME\\}_LINK_LIBRARIES(([\\s]|#[^\\n]*\\n)+([\\$\\{\\}\\w\\d]+|\"(?:[^\"\\\\]|\\\\.)*\"))*([\\s]|#[^\\n]*\\n)*\\)");
+ std::string::const_iterator start, end;
+ start = CMfile.begin();
+ end = CMfile.end();
+ boost::match_results<std::string::const_iterator> what;
+ boost::match_flag_type flags = boost::match_default;
+ if(boost::regex_search(start, end, what, expression, flags))
+ {
+
+ expression = boost::regex("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{EXE_NAME\\}_LINK_LIBRARIES");
+ std::string::const_iterator start1, end1;
+ start1 = what[0].first;
+ end1 = what[0].second;
+ boost::match_results<std::string::const_iterator> what1;
+ if(boost::regex_search(start1, end1, what1, expression, flags))
+ {
+ expression = boost::regex("^\\h*[\\w\\d]+");
+ std::string::const_iterator start2, end2;
+ start2 = what1[0].second;
+ end2 = what[0].second;
+ boost::match_results<std::string::const_iterator> what2;
+ while(boost::regex_search(start2, end2, what2, expression, flags))
+ {
+ std::string dete = what2.str();
+ CDMUtilities::normalizeStr(dete);
+ //std::cout << "detectado lib: " << dete << std::endl;
+ if(res1.find(dete) != res1.end())
+ res1[dete] = true;
+
+ start2 = what2[0].second;
+ }
+ }
+ }
+
+ //find included folders
+ //std::cout << "searching..." << std::endl;
+ expression = boost::regex("^\\h*INCLUDE_DIRECTORIES([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*([\\./\\$\\{\\}\\w\\d]+|\"(?:[^\"\\\\]|\\\\.)*\")(([\\s]|#[^\\n]*\\n)+([\\$\\{\\}\\w\\d]+|\"(?:[^\"\\\\]|\\\\.)*\"))*([\\s]|#[^\\n]*\\n)*\\)");
+ start = CMfile.begin();
+ end = CMfile.end();
+ if(boost::regex_search(start, end, what, expression, flags))
+ {
+ //std::cout << what.str() << std::endl;
+ expression = boost::regex("^\\h*INCLUDE_DIRECTORIES([\\s]|#[^\\n]*\\n)*\\(");
+ std::string::const_iterator start1, end1;
+ start1 = what[0].first;
+ end1 = what[0].second;
+ boost::match_results<std::string::const_iterator> what1;
+ if(boost::regex_search(start1, end1, what1, expression, flags))
+ {
+ //std::cout << what1.str() << std::endl;
+ expression = boost::regex("^\\h*\\.\\.\\/\\.\\.\\/lib\\/([\\w\\d])+");
+ std::string::const_iterator start2, end2;
+ start2 = what1[0].second;
+ end2 = what[0].second;
+ boost::match_results<std::string::const_iterator> what2;
+ while(boost::regex_search(start2, end2, what2, expression, flags))
+ {
+ std::string dete = what2.str();
+ CDMUtilities::normalizeStr(dete);
+ //std::cout << "detectado dir: " << dete.substr(10) << std::endl;
+ if(correspondence.find(dete.substr(10)) != correspondence.end())
+ res[correspondence[dete.substr(10)]] = res1[correspondence[dete.substr(10)]];
+
+ start2 = what2[0].second;
+ }
+ }
+ }
+ }
+
+ return res;
+}
+
+bool modelCDMApplication::SetCustomLibrary(const std::string& library_name, const bool& toInclude)
+{
+ std::map<std::string, std::string> correspondence;
+
+ std::vector<modelCDMLibrary*> libraries;
+ modelCDMIProjectTreeNode* p = this;
+ while(p != NULL && dynamic_cast<modelCDMProject*>(p) == NULL)
+ p = p->GetParent();
+
+ if(p != NULL && dynamic_cast<modelCDMProject*>(p)->GetLib() != NULL)
+ libraries = dynamic_cast<modelCDMProject*>(p)->GetLib()->GetLibraries();
+
+ for (int i = 0; i < libraries.size(); ++i)
+ {
+ correspondence[libraries[i]->GetNameLibrary()] = libraries[i]->GetName();
+ }
+
+ if (correspondence.find(library_name) != correspondence.end())
+ {
+ if (this->HasCMakeLists())
+ {
+ std::string resCMfile = "";
+ std::string CMfile = CDMUtilities::readFile(this->CMakeLists->GetPath().c_str());
+ bool found = false;
+
+ //find included libraries
+ //std::cout << "searching..." << CMfile << std::endl;
+ boost::regex expression("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{EXE_NAME\\}_LINK_LIBRARIES(([\\s]|#[^\\n]*\\n)+([\\$\\{\\}\\w\\d]+|\"(?:[^\"\\\\]|\\\\.)*\"))*([\\s]|#[^\\n]*\\n)*\\)");
+ std::string::const_iterator start, end;
+ start = CMfile.begin();
+ end = CMfile.end();
+ boost::match_results<std::string::const_iterator> what;
+ boost::match_flag_type flags = boost::match_default;
+ if(boost::regex_search(start, end, what, expression, flags))
+ {
+ //std::cout << what.str() << std::endl;
+ resCMfile += what.prefix().str();
+ expression = boost::regex("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{EXE_NAME\\}_LINK_LIBRARIES");
+ std::string::const_iterator start1, end1;
+ start1 = what[0].first;
+ end1 = what[0].second;
+ boost::match_results<std::string::const_iterator> what1;
+ if(boost::regex_search(start1, end1, what1, expression, flags))
+ {
+ resCMfile += what1.prefix().str() + what1.str();
+ //check if already exists
+ expression = boost::regex("^\\h*"+library_name);
+ std::string::const_iterator start2, end2;
+ start2 = what1[0].second;
+ end2 = what[0].second;
+ boost::match_results<std::string::const_iterator> what2, temp2;
+ while(boost::regex_search(start2, end2, what2, expression, flags))
+ {
+ resCMfile += what2.prefix().str();
+ found = true;
+ if (!toInclude)
+ {
+ resCMfile += "#";
+ }
+ resCMfile += what2.str();
+ temp2 = what2;
+ start2 = what2[0].second;
+ }
+ if(found)
+ resCMfile += temp2.suffix().str();
+ //check if is commented
+ else
+ {
+ expression = boost::regex("^\\h*#+\\h*"+library_name);
+ start2 = what1[0].second;
+ end2 = what[0].second;
+ while(boost::regex_search(start2, end2, what2, expression, flags))
+ {
+ found = true;
+ resCMfile += what2.prefix().str();
+ if(toInclude)
+ {
+ std::string dete = what2[0].str();
+ for (int i = 0; i < dete.size(); ++i) {
+ if (dete[i] != '#')
+ resCMfile.push_back(dete[i]);
+ }
+ }
+ temp2 = what2;
+ start2 = what2[0].second;
+ }
+ if(found)
+ resCMfile += temp2.suffix().str();
+ //add at the beggining of instruction
+ else
+ {
+ if(toInclude)
+ resCMfile += "\n" + library_name;
+ resCMfile += what1.suffix().str();
+ }
+ }
+ }
+ resCMfile += what.suffix().str();
+ }
+ else
+ return false;
+
+ //find included folders
+ CMfile = resCMfile;
+ resCMfile = "";
+
+
+ found = false;
+ //std::cout << "searching..." << CMfile << std::endl;
+ expression = boost::regex("^\\h*INCLUDE_DIRECTORIES([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*([\\.\\/\\$\\{\\}\\w\\d]+|\"(?:[^\"\\\\]|\\\\.)*\"){0,1}?(([\\s]|#[^\\n]*\\n)+([\\.\\/\\$\\{\\}\\w\\d]+|\"(?:[^\"\\\\]|\\\\.)*\"))*([\\s]|#[^\\n]*\\n)*\\)");
+ start = CMfile.begin();
+ end = CMfile.end();
+ if(boost::regex_search(start, end, what, expression, flags))
+ {
+ resCMfile += what.prefix().str();
+ //std::cout << what.str() << std::endl;
+ expression = boost::regex("^\\h*INCLUDE_DIRECTORIES([\\s]|#[^\\n]*\\n)*\\(");
+ std::string::const_iterator start1, end1;
+ start1 = what[0].first;
+ end1 = what[0].second;
+ boost::match_results<std::string::const_iterator> what1;
+ if(boost::regex_search(start1, end1, what1, expression, flags))
+ {
+ resCMfile += what1.prefix().str() + what1.str();
+ //std::cout << what1.str() << std::endl;
+ //search if dir is already included
+ expression = boost::regex("^\\h*\\.\\.\\/\\.\\.\\/lib\\/"+correspondence[library_name]);
+ std::string::const_iterator start2, end2;
+ start2 = what1[0].second;
+ end2 = what[0].second;
+ boost::match_results<std::string::const_iterator> what2, temp2;
+ while(boost::regex_search(start2, end2, what2, expression, flags))
+ {
+ found = true;
+ resCMfile += what2.prefix().str();
+ if(!toInclude)
+ resCMfile += "#";
+ resCMfile += what2.str();
+ temp2 = what2;
+ start2 = what2[0].second;
+ }
+ if(found)
+ resCMfile += temp2.suffix().str();
+ //search if dir is commented
+ else
+ {
+ expression = boost::regex("^\\h*#+\\h*\\.\\.\\/\\.\\.\\/lib\\/"+correspondence[library_name]);
+ start2 = what1[0].second;
+ end2 = what[0].second;
+ while(boost::regex_search(start2, end2, what2, expression, flags))
+ {
+ found = true;
+ resCMfile += what2.prefix().str();
+ if(toInclude)
+ {
+ std::string dete = what2[0].str();
+ for (int i = 0; i < dete.size(); ++i) {
+ if (dete[i] != '#')
+ resCMfile.push_back(dete[i]);
+ }
+ }
+ temp2 = what2;
+ start2 = what2[0].second;
+ }
+ if(found)
+ resCMfile += temp2.suffix().str();
+ //add at the beggining of instruction
+ else
+ {
+ if(toInclude)
+ resCMfile += "\n../../lib/" + correspondence[library_name];
+ resCMfile += what1.suffix().str();
+ }
+ }
+ }
+ resCMfile += what.suffix().str();
+ }
+ else
+ return false;
+
+ return CDMUtilities::writeFile(this->CMakeLists->GetPath().c_str(), resCMfile);
+ }
+ }
+
+ return false;
+}
*/
void CheckStructure(std::map<std::string, bool>& properties);
+ /**
+ * Checks the application's CMakeLists file to check which third party libraries are enabled.
+ * @return A map with the name of the library and if it's included in the CMakeLists file.
+ */
+ std::map<std::string, bool> Get3rdPartyLibraries();
+
+ /**
+ * Sets the 3rd party library inclusion in the application's CMakeLists file.
+ * @return if the operation was successful.
+ */
+ bool Set3rdPartyLibrary(const std::string& library_name, const bool& toInclude);
+
+ /**
+ * Checks the application's CMakeLists file to check which custom libraries are enabled.
+ * @return A map with the name of the library and if it's included in the CMakeLists file.
+ */
+ std::map<std::string, bool> GetCustomLibraries();
+
+ /**
+ * Sets the custom library inclusion in the application's CMakeLists file.
+ * @return if the operation was successful.
+ */
+ bool SetCustomLibrary(const std::string& library_name, const bool& toInclude);
+
private:
/**
* Name of the application executable file.
return NULL;
}
+ //add library to lib CMakeLists
+ std::fstream out1((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str(), std::fstream::in | std::fstream::out | std::fstream::app);
+ if (out1.is_open())
+ {
+ out1 << "ADD_SUBDIRECTORY(" << name << ")" << std::endl;
+ out1.close();
+ }
+
+
//add library to model
modelCDMLibrary* library = new modelCDMLibrary(this, this->path + CDMUtilities::SLASH + name, name, this->level + 1);
this->libraries.push_back(library);
this->libraries[i]->CheckStructure(properties);
}
}
+
+bool modelCDMLib::IsLibraryIncluded(const std::string& library_name)
+{
+ if (this->HasCMakeLists())
+ {
+ CDMUtilities::CMLFile cmlFile = CDMUtilities::readCMLFile(this->CMakeLists->GetPath().c_str());
+ for (int i = 0; i < cmlFile.size(); ++i)
+ {
+ if (cmlFile[i].first=="command" && cmlFile[i].second[0] == "ADD_SUBDIRECTORY")
+ {
+ int pos = 1;
+ while (pos < cmlFile[i].second.size())
+ {
+ if (!isspace(cmlFile[i].second[pos][0]) && cmlFile[i].second[pos][0] != '(' && cmlFile[i].second[pos][0] != '#')
+ {
+ if (library_name == cmlFile[i].second[pos])
+ return true;
+ break;
+ }
+ pos++;
+ }
+ }
+ }
+ }
+ return false;
+}
+
+bool modelCDMLib::SetLibraryInclude(const std::string& library_name, const bool& toInclude)
+{
+ if (this->HasCMakeLists())
+ {
+ CDMUtilities::CMLFile cmlFile = CDMUtilities::readCMLFile(this->CMakeLists->GetPath().c_str());
+
+ bool found = false;
+
+ for (int i = 0; i < cmlFile.size(); ++i)
+ {
+ if(toInclude && cmlFile[i].first == "comment")
+ {
+ std::vector<std::string> segments;
+ std::string line = cmlFile[i].second[0];
+ while(line[0] == '#')
+ line.erase(0,1);
+
+ CDMUtilities::splitter::split(segments, line, " ()", CDMUtilities::splitter::no_empties);
+ if (segments.size() > 1 && segments[0] == "ADD_SUBDIRECTORY" && segments[1] == library_name)
+ {
+ found = true;
+ while(cmlFile[i].second[0][0] == '#')
+ cmlFile[i].second[0].erase(0,1);
+ }
+ }
+ else if(cmlFile[i].first == "command" && cmlFile[i].second[0] == "ADD_SUBDIRECTORY")
+ {
+ int pos = 1;
+ while (pos < cmlFile[i].second.size())
+ {
+ if (!isspace(cmlFile[i].second[pos][0]) && cmlFile[i].second[pos][0] != '(' && cmlFile[i].second[pos][0] != '#')
+ {
+ if (library_name == cmlFile[i].second[pos])
+ {
+ found = true;
+ if (!toInclude)
+ {
+ cmlFile[i].first = "comment";
+ cmlFile[i].second[0] = "#" + cmlFile[i].second[0];
+ while (cmlFile[i].second.size() > 1)
+ {
+ cmlFile[i].second[0] += cmlFile[i].second[1];
+ cmlFile[i].second.erase(cmlFile[i].second.begin()+1);
+ }
+
+ }
+ }
+ break;
+ }
+ pos++;
+ }
+ }
+ }
+ if (!found && toInclude)
+ {
+ CDMUtilities::syntaxElement element;
+ element.first = "command";
+ element.second.push_back("ADD_SUBDIRECTORY(" + library_name + ")");
+ cmlFile.push_back(element);
+ }
+
+ return CDMUtilities::writeCMLFile(this->CMakeLists->GetPath().c_str(),cmlFile);
+ }
+ return false;
+}
const std::vector<modelCDMLibrary*>& GetLibraries() const;
/**
- * Creates a new library node for the actual project and registers it. It modifies the project model as well as the system.
+ * Creates a new library node for the actual project and registers it. It modifies the project model as well as the system. The created library is included in the lib's CMakeLists file.
* @param name Name of the new library.
* @param result Result message.
* @return New library reference.
*/
void CheckStructure(std::map<std::string, bool>& properties);
+ /**
+ * Checks if the given library is included in the CMakeLists file.
+ * @param library_name Name of the library to check.
+ * @return True if the library is included, otherwise returns False.
+ */
+ bool IsLibraryIncluded(const std::string& library_name);
+
+ /**
+ * Sets the inclusion of the library in the lib's CMakeLists file. If the library inclusion already exist in file, then the line is uncommented/commented depending on the requested action. If the library inclusion doesn't exist yet, then it is included if the request is an inclusion.
+ * @param library_name Name of the library to include/exclude.
+ * @param toInclude True if the request is an inclusion, False otherwise.
+ * @return True if the request was processed successfully.
+ */
+ bool SetLibraryInclude(const std::string& library_name, const bool& toInclude);
+
private:
/**
* Libraries references.
#include "modelCDMLibrary.h"
+#include "modelCDMLib.h"
+
#include <fstream>
#include <sstream>
#include <algorithm>
+#include <boost/regex.hpp>
#include "CDMUtilities.h"
#include "creaWx.h"
}
}
+
+std::map<std::string, bool> modelCDMLibrary::Get3rdPartyLibraries()
+{
+ std::map<std::string, std::string> correspondence;
+ correspondence["${crea_LIBRARIES}"] = "Crea";
+ correspondence["${WXWIDGETS_LIBRARIES}"] = "WxWidgets";
+ correspondence["${KWWidgets_LIBRARIES}"] = "KWWidgets";
+ correspondence["${VTK_LIBRARIES}"] = "VTK";
+ correspondence["${ITK_LIBRARIES}"] = "ITK";
+ correspondence["${GDCM_LIBRARIES}"] = "GDCM";
+ correspondence["${BOOST_LIBRARIES}"] = "Boost";
+ std::map<std::string, bool> res;
+ res["Crea"] = false;
+ res["WxWidgets"] = false;
+ res["KWWidgets"] = false;
+ res["VTK"] = false;
+ res["ITK"] = false;
+ res["GDCM"] = false;
+ res["Boost"] = false;
+
+ if (this->HasCMakeLists())
+ {
+ std::string CMfile = CDMUtilities::readFile(this->CMakeLists->GetPath().c_str());
+
+ boost::regex expression("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{LIBRARY_NAME\\}_LINK_LIBRARIES(([\\s]|#[^\\n]*\\n)+([\\$\\{\\}\\w\\d]+|\"(?:[^\"\\\\]|\\\\.)*\"))*([\\s]|#[^\\n]*\\n)*\\)");
+ std::string::const_iterator start, end;
+ start = CMfile.begin();
+ end = CMfile.end();
+ boost::match_results<std::string::const_iterator> what;
+ boost::match_flag_type flags = boost::match_default;
+ if(boost::regex_search(start, end, what, expression, flags))
+ {
+
+ expression = boost::regex("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{LIBRARY_NAME\\}_LINK_LIBRARIES");
+ std::string::const_iterator start1, end1;
+ start1 = what[0].first;
+ end1 = what[0].second;
+ boost::match_results<std::string::const_iterator> what1;
+ if(boost::regex_search(start1, end1, what1, expression, flags))
+ {
+ expression = boost::regex("(#[^\\n]*\\n|\\s*\\$\\{\\w+\\})");
+ std::string::const_iterator start2, end2;
+ start2 = what1[0].second;
+ end2 = what[0].second;
+ boost::match_results<std::string::const_iterator> what2;
+ while(boost::regex_search(start2, end2, what2, expression, flags))
+ {
+ if(what2.str()[0] != '#')
+ {
+ std::string dete = what2.str();
+ CDMUtilities::normalizeStr(dete);
+ if(correspondence.find(dete) != correspondence.end())
+ res[correspondence[dete]] = true;
+ }
+ start2 = what2[0].second;
+ }
+ }
+ }
+ }
+ return res;
+}
+
+bool modelCDMLibrary::Set3rdPartyLibrary(const std::string& library_name, const bool& toInclude)
+{
+ std::map<std::string, std::string> correspondence;
+
+ correspondence["Crea"] = "${crea_LIBRARIES}";
+ correspondence["WxWidgets"] = "${WXWIDGETS_LIBRARIES}";
+ correspondence["KWWidgets"] = "${KWWidgets_LIBRARIES}";
+ correspondence["VTK"] = "${VTK_LIBRARIES}";
+ correspondence["ITK"] = "${ITK_LIBRARIES}";
+ correspondence["GDCM"] = "${GDCM_LIBRARIES}";
+ correspondence["Boost"] = "${BOOST_LIBRARIES}";
+
+ std::map<std::string, std::string> regexCorrespondence;
+
+ regexCorrespondence["Crea"] = "\\$\\{crea_LIBRARIES\\}";
+ regexCorrespondence["WxWidgets"] = "\\$\\{WXWIDGETS_LIBRARIES\\}";
+ regexCorrespondence["KWWidgets"] = "\\$\\{KWWidgets_LIBRARIES\\}";
+ regexCorrespondence["VTK"] = "\\$\\{VTK_LIBRARIES\\}";
+ regexCorrespondence["ITK"] = "\\$\\{ITK_LIBRARIES\\}";
+ regexCorrespondence["GDCM"] = "\\$\\{GDCM_LIBRARIES\\}";
+ regexCorrespondence["Boost"] = "\\$\\{BOOST_LIBRARIES\\}";
+
+ if (correspondence.find(library_name) != correspondence.end())
+ {
+ std::string library_command = correspondence[library_name];
+ std::string regex_command = regexCorrespondence[library_name];
+ if (this->HasCMakeLists())
+ {
+ std::string CMfile = CDMUtilities::readFile(this->CMakeLists->GetPath().c_str());
+ std::string resCMfile = "";
+
+ boost::regex expression("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{LIBRARY_NAME\\}_LINK_LIBRARIES(([\\s]|#[^\\n]*\\n)+([\\$\\{\\}\\w\\d]+|\"(?:[^\"\\\\]|\\\\.)*\"))*([\\s]|#[^\\n]*\\n)*\\)");
+ std::string::const_iterator start, end;
+ start = CMfile.begin();
+ end = CMfile.end();
+ boost::match_results<std::string::const_iterator> what;
+ boost::match_flag_type flags = boost::match_default;
+ if(boost::regex_search(start, end, what, expression, flags))
+ {
+ resCMfile += what.prefix().str();
+ bool found = false;
+ if (toInclude) {
+ expression = "^\\h*#+\\h*" + regex_command;
+ std::string::const_iterator start1, end1;
+ start1 = what[0].first;
+ end1 = what[0].second;
+ boost::match_results<std::string::const_iterator> what1, what2;
+ while(boost::regex_search(start1, end1, what1, expression, flags))
+ {
+ found = true;
+ resCMfile += what1.prefix().str();
+ std::string dete = what1[0].str();
+ for (int i = 0; i < dete.size(); ++i) {
+ if (dete[i] != '#')
+ resCMfile.push_back(dete[i]);
+ }
+ what2 = what1;
+ start1 = what1[0].second;
+ }
+ if (found)
+ resCMfile += what2.suffix().str();
+ else
+ {
+ expression = "^\\h*" + regex_command;
+ if(boost::regex_search(start1, end1, what1, expression, flags))
+ found = true;
+
+ expression = "^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{LIBRARY_NAME\\}_LINK_LIBRARIES";
+ boost::regex_search(start1, end1, what1, expression, flags);
+
+ resCMfile += what1.prefix().str() + what1.str();
+ if(!found)
+ resCMfile += "\n" + library_command + "\n";
+ resCMfile += what1.suffix().str();
+ }
+
+ }else{
+ expression = "^\\h*" + regex_command;
+ std::string::const_iterator start1, end1;
+ start1 = what[0].first;
+ end1 = what[0].second;
+ boost::match_results<std::string::const_iterator> what1, what2;
+ while(boost::regex_search(start1, end1, what1, expression, flags))
+ {
+ found = true;
+ resCMfile += what1.prefix().str();
+ resCMfile += "#" + what1.str();
+ what2 = what1;
+ start1 = what1[0].second;
+ }
+ if (found)
+ resCMfile += what2.suffix().str();
+ else
+ {
+ expression = "^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{LIBRARY_NAME\\}_LINK_LIBRARIES";
+ boost::regex_search(start1, end1, what1, expression, flags);
+
+ resCMfile += what1.prefix().str() + what1.str() + what1.suffix().str();
+ }
+ }
+ resCMfile += what.suffix().str();
+
+ return CDMUtilities::writeFile(this->CMakeLists->GetPath().c_str(), resCMfile);
+ }
+ }
+ }
+ return false;
+}
+
+std::map<std::string, bool> modelCDMLibrary::GetCustomLibraries()
+{
+ std::map<std::string, bool> res;
+ std::map<std::string, bool> res1;
+
+ std::map<std::string, std::string> correspondence;
+ std::vector<modelCDMLibrary*> libraries = ((modelCDMLib*)this->parent)->GetLibraries();
+ for (int i = 0; i < libraries.size(); ++i)
+ {
+ if(libraries[i]->GetNameLibrary() == this->nameLibrary)
+ continue;
+ correspondence[libraries[i]->GetName()] = libraries[i]->GetNameLibrary();
+ res[libraries[i]->GetNameLibrary()] = false;
+ res1[libraries[i]->GetNameLibrary()] = false;
+ }
+
+ if (this->HasCMakeLists())
+ {
+ std::string CMfile = CDMUtilities::readFile(this->CMakeLists->GetPath().c_str());
+
+ //find included libraries
+ boost::regex expression("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{LIBRARY_NAME\\}_LINK_LIBRARIES(([\\s]|#[^\\n]*\\n)+([\\$\\{\\}\\w\\d]+|\"(?:[^\"\\\\]|\\\\.)*\"))*([\\s]|#[^\\n]*\\n)*\\)");
+ std::string::const_iterator start, end;
+ start = CMfile.begin();
+ end = CMfile.end();
+ boost::match_results<std::string::const_iterator> what;
+ boost::match_flag_type flags = boost::match_default;
+ if(boost::regex_search(start, end, what, expression, flags))
+ {
+
+ expression = boost::regex("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{LIBRARY_NAME\\}_LINK_LIBRARIES");
+ std::string::const_iterator start1, end1;
+ start1 = what[0].first;
+ end1 = what[0].second;
+ boost::match_results<std::string::const_iterator> what1;
+ if(boost::regex_search(start1, end1, what1, expression, flags))
+ {
+ expression = boost::regex("^\\h*[\\w\\d]+");
+ std::string::const_iterator start2, end2;
+ start2 = what1[0].second;
+ end2 = what[0].second;
+ boost::match_results<std::string::const_iterator> what2;
+ while(boost::regex_search(start2, end2, what2, expression, flags))
+ {
+ std::string dete = what2.str();
+ CDMUtilities::normalizeStr(dete);
+ //std::cout << "detectado lib: " << dete << std::endl;
+ if(res1.find(dete) != res1.end())
+ res1[dete] = true;
+
+ start2 = what2[0].second;
+ }
+ }
+ }
+
+ //find included folders
+ //std::cout << "searching..." << std::endl;
+ expression = boost::regex("^\\h*INCLUDE_DIRECTORIES([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*([\\./\\$\\{\\}\\w\\d]+|\"(?:[^\"\\\\]|\\\\.)*\"){0,1}?(([\\s]|#[^\\n]*\\n)+([\\./\\$\\{\\}\\w\\d]+|\"(?:[^\"\\\\]|\\\\.)*\"))*([\\s]|#[^\\n]*\\n)*\\)");
+ start = CMfile.begin();
+ end = CMfile.end();
+ if(boost::regex_search(start, end, what, expression, flags))
+ {
+ //std::cout << what.str() << std::endl;
+ expression = boost::regex("^\\h*INCLUDE_DIRECTORIES([\\s]|#[^\\n]*\\n)*\\(");
+ std::string::const_iterator start1, end1;
+ start1 = what[0].first;
+ end1 = what[0].second;
+ boost::match_results<std::string::const_iterator> what1;
+ if(boost::regex_search(start1, end1, what1, expression, flags))
+ {
+ //std::cout << what1.str() << std::endl;
+ expression = boost::regex("^\\h*\\.\\.\\/([\\w\\d])+");
+ std::string::const_iterator start2, end2;
+ start2 = what1[0].second;
+ end2 = what[0].second;
+ boost::match_results<std::string::const_iterator> what2;
+ while(boost::regex_search(start2, end2, what2, expression, flags))
+ {
+ std::string dete = what2.str();
+ CDMUtilities::normalizeStr(dete);
+ //std::cout << "detectado dir: " << dete.substr(3) << std::endl;
+ if(correspondence.find(dete.substr(3)) != correspondence.end())
+ res[correspondence[dete.substr(3)]] = res1[correspondence[dete.substr(3)]];
+
+ start2 = what2[0].second;
+ }
+ }
+ }
+ }
+
+ return res;
+}
+
+bool modelCDMLibrary::SetCustomLibrary(const std::string& library_name, const bool& toInclude)
+{
+ std::map<std::string, std::string> correspondence;
+ std::vector<modelCDMLibrary*> libraries = ((modelCDMLib*)this->parent)->GetLibraries();
+ for (int i = 0; i < libraries.size(); ++i)
+ {
+ if(libraries[i]->GetNameLibrary() == this->nameLibrary)
+ continue;
+ correspondence[libraries[i]->GetNameLibrary()] = libraries[i]->GetName();
+ }
+
+ if (correspondence.find(library_name) != correspondence.end())
+ {
+ if (this->HasCMakeLists())
+ {
+ std::string resCMfile = "";
+ std::string CMfile = CDMUtilities::readFile(this->CMakeLists->GetPath().c_str());
+ bool found = false;
+
+ //find included libraries
+ boost::regex expression("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{LIBRARY_NAME\\}_LINK_LIBRARIES(([\\s]|#[^\\n]*\\n)+([\\$\\{\\}\\w\\d]+|\"(?:[^\"\\\\]|\\\\.)*\"))*([\\s]|#[^\\n]*\\n)*\\)");
+ std::string::const_iterator start, end;
+ start = CMfile.begin();
+ end = CMfile.end();
+ boost::match_results<std::string::const_iterator> what;
+ boost::match_flag_type flags = boost::match_default;
+ if(boost::regex_search(start, end, what, expression, flags))
+ {
+ resCMfile += what.prefix().str();
+ expression = boost::regex("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{LIBRARY_NAME\\}_LINK_LIBRARIES");
+ std::string::const_iterator start1, end1;
+ start1 = what[0].first;
+ end1 = what[0].second;
+ boost::match_results<std::string::const_iterator> what1;
+ if(boost::regex_search(start1, end1, what1, expression, flags))
+ {
+ resCMfile += what1.prefix().str() + what1.str();
+ //check if already exists
+ expression = boost::regex("^\\h*"+library_name);
+ std::string::const_iterator start2, end2;
+ start2 = what1[0].second;
+ end2 = what[0].second;
+ boost::match_results<std::string::const_iterator> what2, temp2;
+ while(boost::regex_search(start2, end2, what2, expression, flags))
+ {
+ resCMfile += what2.prefix().str();
+ found = true;
+ if (!toInclude)
+ {
+ resCMfile += "#";
+ }
+ resCMfile += what2.str();
+ temp2 = what2;
+ start2 = what2[0].second;
+ }
+ if(found)
+ resCMfile += temp2.suffix().str();
+ //check if is commented
+ else
+ {
+ expression = boost::regex("^\\h*#+\\h*"+library_name);
+ start2 = what1[0].second;
+ end2 = what[0].second;
+ while(boost::regex_search(start2, end2, what2, expression, flags))
+ {
+ found = true;
+ resCMfile += what2.prefix().str();
+ if(toInclude)
+ {
+ std::string dete = what2[0].str();
+ for (int i = 0; i < dete.size(); ++i) {
+ if (dete[i] != '#')
+ resCMfile.push_back(dete[i]);
+ }
+ }
+ temp2 = what2;
+ start2 = what2[0].second;
+ }
+ if(found)
+ resCMfile += temp2.suffix().str();
+ //add at the beggining of instruction
+ else
+ {
+ if(toInclude)
+ resCMfile += "\n" + library_name;
+ resCMfile += what1.suffix().str();
+ }
+ }
+ }
+ resCMfile += what.suffix().str();
+ }
+ else
+ return false;
+
+ //find included folders
+ CMfile = resCMfile;
+ resCMfile = "";
+
+
+ found = false;
+ std::cout << "searching..." << CMfile << std::endl;
+ expression = boost::regex("^\\h*INCLUDE_DIRECTORIES([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*([\\.\\/\\$\\{\\}\\w\\d]+|\"(?:[^\"\\\\]|\\\\.)*\"){0,1}?(([\\s]|#[^\\n]*\\n)+([\\.\\/\\$\\{\\}\\w\\d]+|\"(?:[^\"\\\\]|\\\\.)*\"))*([\\s]|#[^\\n]*\\n)*\\)");
+ start = CMfile.begin();
+ end = CMfile.end();
+ if(boost::regex_search(start, end, what, expression, flags))
+ {
+ resCMfile += what.prefix().str();
+ std::cout << what.str() << std::endl;
+ expression = boost::regex("^\\h*INCLUDE_DIRECTORIES([\\s]|#[^\\n]*\\n)*\\(");
+ std::string::const_iterator start1, end1;
+ start1 = what[0].first;
+ end1 = what[0].second;
+ boost::match_results<std::string::const_iterator> what1;
+ if(boost::regex_search(start1, end1, what1, expression, flags))
+ {
+ resCMfile += what1.prefix().str() + what1.str();
+ std::cout << what1.str() << std::endl;
+ //search if dir is already included
+ expression = boost::regex("^\\h*\\.\\.\\/"+correspondence[library_name]);
+ std::string::const_iterator start2, end2;
+ start2 = what1[0].second;
+ end2 = what[0].second;
+ boost::match_results<std::string::const_iterator> what2, temp2;
+ while(boost::regex_search(start2, end2, what2, expression, flags))
+ {
+ found = true;
+ resCMfile += what2.prefix().str();
+ if(!toInclude)
+ resCMfile += "#";
+ resCMfile += what2.str();
+ temp2 = what2;
+ start2 = what2[0].second;
+ }
+ if(found)
+ resCMfile += temp2.suffix().str();
+ //search if dir is commented
+ else
+ {
+ expression = boost::regex("^\\h*#+\\h*\\.\\.\\/"+correspondence[library_name]);
+ start2 = what1[0].second;
+ end2 = what[0].second;
+ while(boost::regex_search(start2, end2, what2, expression, flags))
+ {
+ found = true;
+ resCMfile += what2.prefix().str();
+ if(toInclude)
+ {
+ std::string dete = what2[0].str();
+ for (int i = 0; i < dete.size(); ++i) {
+ if (dete[i] != '#')
+ resCMfile.push_back(dete[i]);
+ }
+ }
+ temp2 = what2;
+ start2 = what2[0].second;
+ }
+ if(found)
+ resCMfile += temp2.suffix().str();
+ //add at the beggining of instruction
+ else
+ {
+ if(toInclude)
+ resCMfile += "\n../" + correspondence[library_name];
+ resCMfile += what1.suffix().str();
+ }
+ }
+ }
+ resCMfile += what.suffix().str();
+ }
+ else
+ return false;
+
+ return CDMUtilities::writeFile(this->CMakeLists->GetPath().c_str(), resCMfile);
+ }
+ }
+
+ return false;
+}
*/
void CheckStructure(std::map<std::string, bool>& properties);
+ /**
+ * Checks the library CMakeLists file to check which third party libraries are enabled.
+ * @return A map with the name of the library and if it's included in the CMakeLists file.
+ */
+ std::map<std::string, bool> Get3rdPartyLibraries();
+
+ /**
+ * Sets the 3rd party library inclusion in the CMakeLists file.
+ * @return if the operation was successful.
+ */
+ bool Set3rdPartyLibrary(const std::string& library_name, const bool& toInclude);
+
+ /**
+ * Checks the library CMakeLists file to check which custom libraries are enabled.
+ * @return A map with the name of the library and if it's included in the CMakeLists file.
+ */
+ std::map<std::string, bool> GetCustomLibraries();
+
+ /**
+ * Sets the custom library inclusion in the CMakeLists file.
+ * @return if the operation was successful.
+ */
+ bool SetCustomLibrary(const std::string& library_name, const bool& toInclude);
+
private:
/**
* Name of the library node. The name of a library can be different than the library folder name.
#include "modelCDMPackage.h"
+#include "modelCDMProject.h"
+#include "modelCDMLib.h"
+#include "modelCDMLibrary.h"
+
+
#include <fstream>
#include <sstream>
#include <algorithm>
+#include <boost/regex.hpp>
#include "creaWx.h"
#include "wx/dir.h"
}
}
+
+std::map<std::string, bool> modelCDMPackage::Get3rdPartyLibraries()
+{
+ std::map<std::string, std::string> correspondence;
+ correspondence["${BBTK_PACKAGE_NAME}_USE_VTK"] = "VTK";
+ correspondence["${BBTK_PACKAGE_NAME}_USE_ITK"] = "ITK";
+ correspondence["${BBTK_PACKAGE_NAME}_USE_GDCM"] = "GDCM";
+ correspondence["${BBTK_PACKAGE_NAME}_USE_GDCM_VTK"] = "GDCM_VTK";
+ correspondence["${BBTK_PACKAGE_NAME}_USE_GSMIS"] = "GSMIS";
+ correspondence["${BBTK_PACKAGE_NAME}_USE_WXWIDGETS"] = "WxWidgets";
+ correspondence["${BBTK_PACKAGE_NAME}_USE_KWWIDGETS"] = "KWWidgets";
+ std::map<std::string, bool> res;
+ res["VTK"] = false;
+ res["ITK"] = false;
+ res["GDCM"] = false;
+ res["GDCM_VTK"] = false;
+ res["GSMIS"] = false;
+ res["WxWidgets"] = false;
+ res["KWWidgets"] = false;
+
+ if (this->HasCMakeLists())
+ {
+ std::string CMfile = CDMUtilities::readFile(this->CMakeLists->GetPath().c_str());
+
+ boost::regex expression("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{BBTK_PACKAGE_NAME\\}_USE_\\w+\\s+ON");
+ std::string::const_iterator start, end;
+ start = CMfile.begin();
+ end = CMfile.end();
+ boost::match_results<std::string::const_iterator> what;
+ boost::match_flag_type flags = boost::match_default;
+ while(boost::regex_search(start, end, what, expression, flags))
+ {
+ //std::cout << what[0].str() << std::endl;
+ boost::regex expression1 = boost::regex("\\$\\{BBTK_PACKAGE_NAME\\}_USE_\\w+");
+ std::string::const_iterator start1, end1;
+ start1 = what[0].first;
+ end1 = what[0].second;
+ boost::match_results<std::string::const_iterator> what1;
+ if(boost::regex_search(start1, end1, what1, expression1, flags))
+ {
+ std::string dete = what1.str();
+ CDMUtilities::normalizeStr(dete);
+ //std::cout << dete << std::endl;
+ if(correspondence.find(dete) != correspondence.end())
+ res[correspondence[dete]] = true;
+ }
+ start = what[0].second;
+ }
+ }
+ return res;
+}
+
+bool modelCDMPackage::Set3rdPartyLibrary(const std::string& library_name,
+ const bool& toInclude)
+{
+ std::map<std::string, std::string> correspondence;
+
+ correspondence["VTK"] = "_USE_VTK";
+ correspondence["ITK"] = "_USE_ITK";
+ correspondence["GDCM"] = "_USE_GDCM";
+ correspondence["GDCM_VTK"] = "_USE_GDCM_VTK";
+ correspondence["GSMIS"] = "_USE_GSMIS";
+ correspondence["WxWidgets"] = "_USE_WXWIDGETS";
+ correspondence["KWWidgets"] = "_USE_KWWIDGETS";
+
+ if (correspondence.find(library_name) != correspondence.end())
+ {
+ std::string library_command = correspondence[library_name];
+// std::cout << "found correspondence " << library_command << std::endl;
+// std::cout.flush();
+ if (this->HasCMakeLists())
+ {
+ std::string CMfile = CDMUtilities::readFile(this->CMakeLists->GetPath().c_str());
+ std::string resCMfile = "";
+ bool found = false;
+
+// std::cout << "found cmakefile: " << CMfile << std::endl;
+// std::cout.flush();
+
+ try {
+// std::cout << "first regex" << std::endl;
+// std::cout.flush();
+ boost::regex expression("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{BBTK_PACKAGE_NAME\\}"+library_command+"([\\s]|#[^\\n]*\\n)+ON([\\s]|#[^\\n]*\\n)*\\)");
+
+ std::string::const_iterator start, end;
+ start = CMfile.begin();
+ end = CMfile.end();
+ boost::match_results<std::string::const_iterator> what;
+ boost::match_flag_type flags = boost::match_default;
+ if(boost::regex_search(start, end, what, expression, flags))
+ {
+// std::cout << "found " << what.str() << std::endl;
+// std::cout.flush();
+ found = true;
+ resCMfile += what.prefix().str();
+ if (toInclude)
+ resCMfile += what.str();
+ else
+ resCMfile += "#" + what.str();
+ resCMfile += what.suffix().str();
+
+ return CDMUtilities::writeFile(this->CMakeLists->GetPath().c_str(), resCMfile);
+ }
+ else
+ {
+// std::cout << "second regex" << std::endl;
+// std::cout.flush();
+ boost::regex expression("^\\h*#\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{BBTK_PACKAGE_NAME\\}"+library_command+"([\\s]|#[^\\n]*\\n)+ON([\\s]|#[^\\n]*\\n)*\\)");
+ if(boost::regex_search(start, end, what, expression, flags))
+ {
+ found = true;
+ resCMfile += what.prefix().str();
+ if(toInclude)
+ {
+ std::string dete = what[0].str();
+ for (int i = 0; i < dete.size(); ++i) {
+ if (dete[i] != '#')
+ resCMfile.push_back(dete[i]);
+ if (dete[i] == 'S')
+ {
+ resCMfile += dete.substr(i+1);
+ break;
+ }
+ }
+ }
+ else
+ resCMfile += what.str();
+
+ resCMfile += what.suffix().str();
+ return CDMUtilities::writeFile(this->CMakeLists->GetPath().c_str(), resCMfile);
+ }
+ else
+ {
+// std::cout << "third regex" << std::endl;
+// std::cout.flush();
+ boost::regex expression("^\\h*#\\h*UNCOMMENT EACH LIBRARY NEEDED \\(WILL BE FOUND AND USED AUTOMATICALLY\\)[^\\n]*\\n");
+ if(boost::regex_search(start, end, what, expression, flags))
+ {
+ found = true;
+ resCMfile += what.prefix().str();
+ resCMfile += what.str();
+ if(toInclude)
+ {
+ resCMfile += "SET(${BBTK_PACKAGE_NAME}"+ library_command +" ON)\n";
+ }
+ resCMfile += what.suffix().str();
+ return CDMUtilities::writeFile(this->CMakeLists->GetPath().c_str(), resCMfile);
+ }
+ }
+ }
+ } catch (boost::bad_expression& e) {
+ std::cout << "bad regex: " << e.what() << std::endl;
+ std::cout.flush();
+ }
+ }
+ }
+ return false;
+}
+
+std::map<std::string, bool> modelCDMPackage::GetCustomLibraries()
+{
+ std::map<std::string, bool> res;
+ std::map<std::string, bool> res1;
+
+ std::map<std::string, std::string> correspondence;
+ std::vector<modelCDMLibrary*> libraries;
+ modelCDMIProjectTreeNode* p = this;
+ while(p != NULL && dynamic_cast<modelCDMProject*>(p) == NULL)
+ p = p->GetParent();
+
+ if(p != NULL && dynamic_cast<modelCDMProject*>(p)->GetLib() != NULL)
+ libraries = dynamic_cast<modelCDMProject*>(p)->GetLib()->GetLibraries();
+
+ for (int i = 0; i < libraries.size(); ++i)
+ {
+ correspondence[libraries[i]->GetName()] = libraries[i]->GetNameLibrary();
+ res[libraries[i]->GetNameLibrary()] = false;
+ res1[libraries[i]->GetNameLibrary()] = false;
+ }
+
+ if (this->HasCMakeLists())
+ {
+ std::string CMfile = CDMUtilities::readFile(this->CMakeLists->GetPath().c_str());
+
+ //find included libraries
+ boost::regex expression("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{BBTK_PACKAGE_NAME\\}_LIBS(([\\s]|#[^\\n]*\\n)+([\\$\\{\\}\\w\\d]+|\"(?:[^\"\\\\]|\\\\.)*\"))*([\\s]|#[^\\n]*\\n)*\\)");
+ std::string::const_iterator start, end;
+ start = CMfile.begin();
+ end = CMfile.end();
+ boost::match_results<std::string::const_iterator> what;
+ boost::match_flag_type flags = boost::match_default;
+ if(boost::regex_search(start, end, what, expression, flags))
+ {
+
+ expression = boost::regex("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{BBTK_PACKAGE_NAME\\}_LIBS");
+ std::string::const_iterator start1, end1;
+ start1 = what[0].first;
+ end1 = what[0].second;
+ boost::match_results<std::string::const_iterator> what1;
+ if(boost::regex_search(start1, end1, what1, expression, flags))
+ {
+ expression = boost::regex("^\\h*[\\w\\d]+");
+ std::string::const_iterator start2, end2;
+ start2 = what1[0].second;
+ end2 = what[0].second;
+ boost::match_results<std::string::const_iterator> what2;
+ while(boost::regex_search(start2, end2, what2, expression, flags))
+ {
+ std::string dete = what2.str();
+ CDMUtilities::normalizeStr(dete);
+ //std::cout << "detectado lib: " << dete << std::endl;
+ if(res1.find(dete) != res1.end())
+ res1[dete] = true;
+
+ start2 = what2[0].second;
+ }
+ }
+ }
+
+ //find included folders
+ //std::cout << "searching..." << std::endl;
+ expression = boost::regex("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{BBTK_PACKAGE_NAME\\}_INCLUDE_DIRS(([\\s]|#[^\\n]*\\n|////[^\\n]*\\n)+([\\.\\/\\$\\{\\}\\w\\d]+|\"(?:[^\"\\\\]|\\\\.)*\"))*([\\s]|#[^\\n]*\\n)*\\)");
+ start = CMfile.begin();
+ end = CMfile.end();
+ if(boost::regex_search(start, end, what, expression, flags))
+ {
+ //std::cout << what.str() << std::endl;
+ expression = boost::regex("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{BBTK_PACKAGE_NAME\\}_INCLUDE_DIRS");
+ std::string::const_iterator start1, end1;
+ start1 = what[0].first;
+ end1 = what[0].second;
+ boost::match_results<std::string::const_iterator> what1;
+ if(boost::regex_search(start1, end1, what1, expression, flags))
+ {
+ //std::cout << what1.str() << std::endl;
+ expression = boost::regex("^\\h*\\.\\.\\/lib\\/([\\w\\d])+");
+ std::string::const_iterator start2, end2;
+ start2 = what1[0].second;
+ end2 = what[0].second;
+ boost::match_results<std::string::const_iterator> what2;
+ while(boost::regex_search(start2, end2, what2, expression, flags))
+ {
+ std::string dete = what2.str();
+ CDMUtilities::normalizeStr(dete);
+ //std::cout << "detectado dir: " << dete.substr(7) << std::endl;
+ if(correspondence.find(dete.substr(7)) != correspondence.end())
+ res[correspondence[dete.substr(7)]] = res1[correspondence[dete.substr(7)]];
+
+ start2 = what2[0].second;
+ }
+ }
+ }
+ }
+
+ return res;
+}
+
+bool modelCDMPackage::SetCustomLibrary(const std::string& library_name,
+ const bool& toInclude)
+{
+ std::map<std::string, std::string> correspondence;
+
+ std::vector<modelCDMLibrary*> libraries;
+ modelCDMIProjectTreeNode* p = this;
+ while(p != NULL && dynamic_cast<modelCDMProject*>(p) == NULL)
+ p = p->GetParent();
+
+ if(p != NULL && dynamic_cast<modelCDMProject*>(p)->GetLib() != NULL)
+ libraries = dynamic_cast<modelCDMProject*>(p)->GetLib()->GetLibraries();
+
+ for (int i = 0; i < libraries.size(); ++i)
+ {
+ correspondence[libraries[i]->GetNameLibrary()] = libraries[i]->GetName();
+ }
+
+ if (correspondence.find(library_name) != correspondence.end())
+ {
+ if (this->HasCMakeLists())
+ {
+ std::string resCMfile = "";
+ std::string CMfile = CDMUtilities::readFile(this->CMakeLists->GetPath().c_str());
+ bool found = false;
+
+ //find included libraries
+ //std::cout << "searching..." << CMfile << std::endl;
+ boost::regex expression("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{BBTK_PACKAGE_NAME\\}_LIBS(([\\s]|#[^\\n]*\\n)+([\\$\\{\\}\\w\\d]+|\"(?:[^\"\\\\]|\\\\.)*\"))*([\\s]|#[^\\n]*\\n)*\\)");
+ std::string::const_iterator start, end;
+ start = CMfile.begin();
+ end = CMfile.end();
+ boost::match_results<std::string::const_iterator> what;
+ boost::match_flag_type flags = boost::match_default;
+ if(boost::regex_search(start, end, what, expression, flags))
+ {
+ //std::cout << what.str() << std::endl;
+ resCMfile += what.prefix().str();
+ expression = boost::regex("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{BBTK_PACKAGE_NAME\\}_LIBS");
+ std::string::const_iterator start1, end1;
+ start1 = what[0].first;
+ end1 = what[0].second;
+ boost::match_results<std::string::const_iterator> what1;
+ if(boost::regex_search(start1, end1, what1, expression, flags))
+ {
+ resCMfile += what1.prefix().str() + what1.str();
+ //check if already exists
+ expression = boost::regex("^\\h*"+library_name);
+ std::string::const_iterator start2, end2;
+ start2 = what1[0].second;
+ end2 = what[0].second;
+ boost::match_results<std::string::const_iterator> what2, temp2;
+ while(boost::regex_search(start2, end2, what2, expression, flags))
+ {
+ resCMfile += what2.prefix().str();
+ found = true;
+ if (!toInclude)
+ {
+ resCMfile += "#";
+ }
+ resCMfile += what2.str();
+ temp2 = what2;
+ start2 = what2[0].second;
+ }
+ if(found)
+ resCMfile += temp2.suffix().str();
+ //check if is commented
+ else
+ {
+ expression = boost::regex("^\\h*#+\\h*"+library_name);
+ start2 = what1[0].second;
+ end2 = what[0].second;
+ while(boost::regex_search(start2, end2, what2, expression, flags))
+ {
+ found = true;
+ resCMfile += what2.prefix().str();
+ if(toInclude)
+ {
+ std::string dete = what2[0].str();
+ for (int i = 0; i < dete.size(); ++i) {
+ if (dete[i] != '#')
+ resCMfile.push_back(dete[i]);
+ }
+ }
+ temp2 = what2;
+ start2 = what2[0].second;
+ }
+ if(found)
+ resCMfile += temp2.suffix().str();
+ //add at the beggining of instruction
+ else
+ {
+ if(toInclude)
+ resCMfile += "\n" + library_name;
+ resCMfile += what1.suffix().str();
+ }
+ }
+ }
+ resCMfile += what.suffix().str();
+ }
+ else
+ return false;
+
+ //find included folders
+ CMfile = resCMfile;
+ resCMfile = "";
+
+
+ found = false;
+ //std::cout << "searching..." << CMfile << std::endl;
+ expression = boost::regex("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{BBTK_PACKAGE_NAME\\}_INCLUDE_DIRS(([\\s]|#[^\\n]*\\n)+([\\.\\/\\$\\{\\}\\w\\d]+|\"(?:[^\"\\\\]|\\\\.)*\"))*([\\s]|#[^\\n]*\\n)*\\)");
+ start = CMfile.begin();
+ end = CMfile.end();
+ if(boost::regex_search(start, end, what, expression, flags))
+ {
+ resCMfile += what.prefix().str();
+ //std::cout << what.str() << std::endl;
+ expression = boost::regex("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{BBTK_PACKAGE_NAME\\}_INCLUDE_DIRS");
+ std::string::const_iterator start1, end1;
+ start1 = what[0].first;
+ end1 = what[0].second;
+ boost::match_results<std::string::const_iterator> what1;
+ if(boost::regex_search(start1, end1, what1, expression, flags))
+ {
+ resCMfile += what1.prefix().str() + what1.str();
+ //std::cout << what1.str() << std::endl;
+ //search if dir is already included
+ expression = boost::regex("^\\h*\\.\\.\\/lib\\/"+correspondence[library_name]);
+ std::string::const_iterator start2, end2;
+ start2 = what1[0].second;
+ end2 = what[0].second;
+ boost::match_results<std::string::const_iterator> what2, temp2;
+ while(boost::regex_search(start2, end2, what2, expression, flags))
+ {
+ found = true;
+ resCMfile += what2.prefix().str();
+ if(!toInclude)
+ resCMfile += "#";
+ resCMfile += what2.str();
+ temp2 = what2;
+ start2 = what2[0].second;
+ }
+ if(found)
+ resCMfile += temp2.suffix().str();
+ //search if dir is commented
+ else
+ {
+ expression = boost::regex("^\\h*#+\\h*\\.\\.\\/lib\\/"+correspondence[library_name]);
+ start2 = what1[0].second;
+ end2 = what[0].second;
+ while(boost::regex_search(start2, end2, what2, expression, flags))
+ {
+ found = true;
+ resCMfile += what2.prefix().str();
+ if(toInclude)
+ {
+ std::string dete = what2[0].str();
+ for (int i = 0; i < dete.size(); ++i) {
+ if (dete[i] != '#')
+ resCMfile.push_back(dete[i]);
+ }
+ }
+ temp2 = what2;
+ start2 = what2[0].second;
+ }
+ if(found)
+ resCMfile += temp2.suffix().str();
+ //add at the beggining of instruction
+ else
+ {
+ if(toInclude)
+ resCMfile += "\n../lib/" + correspondence[library_name];
+ resCMfile += what1.suffix().str();
+ }
+ }
+ }
+ resCMfile += what.suffix().str();
+ }
+ else
+ return false;
+
+ return CDMUtilities::writeFile(this->CMakeLists->GetPath().c_str(), resCMfile);
+ }
+ }
+
+ return false;
+}
*/
void CheckStructure(std::map<std::string, bool>& properties);
+ /**
+ * Checks the package's CMakeLists file to check which third party libraries are enabled.
+ * @return A map with the name of the library and if it's included in the CMakeLists file.
+ */
+ std::map<std::string, bool> Get3rdPartyLibraries();
+
+ /**
+ * Sets the 3rd party library inclusion in the CMakeLists file.
+ * @return if the operation was successful.
+ */
+ bool Set3rdPartyLibrary(const std::string& library_name, const bool& toInclude);
+
+ /**
+ * Checks the package CMakeLists file to check which custom libraries are enabled.
+ * @return A map with the name of the library and if it's included in the CMakeLists file.
+ */
+ std::map<std::string, bool> GetCustomLibraries();
+
+ /**
+ * Sets the custom library inclusion in the CMakeLists file.
+ * @return if the operation was successful.
+ */
+ bool SetCustomLibrary(const std::string& library_name, const bool& toInclude);
+
private:
/**
* Package name.
return NULL;
}
+ //add library to project CMakeLists
+ std::fstream out1((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str(), std::fstream::in | std::fstream::out | std::fstream::app);
+ if (out1.is_open())
+ {
+ out1 << "ADD_SUBDIRECTORY(bbtk_" << nameFixed << "_PKG)" << std::endl;
+ out1.close();
+ }
+
//add library to model
modelCDMPackage* package = new modelCDMPackage(this, this->path + CDMUtilities::SLASH + "bbtk_" + nameFixed + "_PKG", "bbtk_" + nameFixed + "_PKG", this->level + 1);
this->packages.push_back(package);
//TODO: adjust for windows and mac
#ifdef _WIN32
// ------ Windows
- //\\..\\IDE\\VCExpress.exe \"" + this->buildPath + CDMUtilities::SLASH + this->nameProject + ".sln\"
-// std::string command = "\"" + std::string(getenv("VS90COMNTOOLS")) + "..\\IDE\\VCExpress.exe\" \"" + this->buildPath + CDMUtilities::SLASH + this->nameProject + ".sln\" &";
- std::string command = "\"\"%VS90COMNTOOLS%..\\IDE\\VCExpress.exe\" \"" + this->buildPath + CDMUtilities::SLASH + this->nameProject + ".sln\" &\"";
- command = "start cmd.exe /k " + command + " &";
- if(0 == system(command.c_str()))
+ std::string command = "start \"\" \"" + this->buildPath + CDMUtilities::SLASH + this->nameProject + ".sln\"";
+ //wxMessageBox(crea::std2wx(command), wxT("Project Compilation - Check!"));
+ if(0 == system(command.c_str()))
return true;
else
{
- result = new std::string("An error has happened running: \"" + command + "\". Please make sure to have visual c++ express installed and to have the VS90COMNTOOLS environment variable set.");
+ result = new std::string("An error has happened running: \"" + command + "\". Please make sure to have visual c++ installed.");
return false;
}
#elif __APPLE__
this->packages[i]->CheckStructure(properties);
}
}
+
+bool modelCDMProject::IsPackageIncluded(const std::string& package_name)
+{
+ if (this->HasCMakeLists())
+ {
+ CDMUtilities::CMLFile cmlFile = CDMUtilities::readCMLFile(this->CMakeLists->GetPath().c_str());
+ for (int i = 0; i < cmlFile.size(); ++i)
+ {
+ if (cmlFile[i].first=="command" && cmlFile[i].second[0] == "ADD_SUBDIRECTORY")
+ {
+ int pos = 1;
+ while (pos < cmlFile[i].second.size())
+ {
+ if (!isspace(cmlFile[i].second[pos][0]) && cmlFile[i].second[pos][0] != '(' && cmlFile[i].second[pos][0] != '#')
+ {
+ if (package_name == cmlFile[i].second[pos])
+ return true;
+ break;
+ }
+ pos++;
+ }
+ }
+ }
+ }
+ return false;
+
+}
+
+bool modelCDMProject::SetPackageInclude(const std::string& package_name, const bool& toInclude)
+{
+ if (this->HasCMakeLists())
+ {
+ CDMUtilities::CMLFile cmlFile = CDMUtilities::readCMLFile(this->CMakeLists->GetPath().c_str());
+
+ bool found = false;
+
+ for (int i = 0; i < cmlFile.size(); ++i)
+ {
+ if(toInclude && cmlFile[i].first == "comment")
+ {
+ std::vector<std::string> segments;
+ std::string line = cmlFile[i].second[0];
+ while(line[0] == '#')
+ line.erase(0,1);
+
+ CDMUtilities::splitter::split(segments, line, " ()", CDMUtilities::splitter::no_empties);
+ if (segments.size() > 1 && segments[0] == "ADD_SUBDIRECTORY" && segments[1] == package_name)
+ {
+ found = true;
+ while(cmlFile[i].second[0][0] == '#')
+ cmlFile[i].second[0].erase(0,1);
+ }
+ }
+ else if(cmlFile[i].first == "command" && cmlFile[i].second[0] == "ADD_SUBDIRECTORY")
+ {
+ int pos = 1;
+ while (pos < cmlFile[i].second.size())
+ {
+ if (!isspace(cmlFile[i].second[pos][0]) && cmlFile[i].second[pos][0] != '(' && cmlFile[i].second[pos][0] != '#')
+ {
+ if (package_name == cmlFile[i].second[pos])
+ {
+ found = true;
+ if (!toInclude)
+ {
+ cmlFile[i].first = "comment";
+ cmlFile[i].second[0] = "#" + cmlFile[i].second[0];
+ while (cmlFile[i].second.size() > 1)
+ {
+ cmlFile[i].second[0] += cmlFile[i].second[1];
+ cmlFile[i].second.erase(cmlFile[i].second.begin()+1);
+ }
+
+ }
+ }
+ break;
+ }
+ pos++;
+ }
+ }
+ }
+ if (!found && toInclude)
+ {
+ CDMUtilities::syntaxElement element;
+ element.first = "command";
+ element.second.push_back("ADD_SUBDIRECTORY(" + package_name + ")");
+ cmlFile.push_back(element);
+ }
+
+ return CDMUtilities::writeCMLFile(this->CMakeLists->GetPath().c_str(),cmlFile);
+ }
+ return false;
+}
//Creations
/**
- * Creates a package and sets it as a children of the project. This method creates the package in the hard drive and also in the model.
+ * Creates a package and sets it as a children of the project. This method creates the package in the hard drive and also in the model. The created package is included in the project's CMakeLists file.
* @param name Name of the package.
* @param result Result of the operation.
* @param authors Authors of the operation. If any space is found, it will be replaced by '_'.
*/
void CheckStructure(std::map<std::string, bool>& properties);
+ /**
+ * Checks if the given package is included in the CMakeLists file.
+ * @param package_name Name of the package to check.
+ * @return True if the package is included, otherwise returns False.
+ */
+ bool IsPackageIncluded(const std::string& package_name);
+
+ /**
+ * Sets the inclusion of the package in the project's CMakeLists file. If the package inclusion already exist in file, then the line is uncommented/commented depending on the requested action. If the package inclusion doesn't exist yet, then it is included if the request is an inclusion.
+ * @param package_name Name of the package to include/exclude.
+ * @param toInclude True if the request is an inclusion, False otherwise.
+ * @return True if the request was processed successfully.
+ */
+ bool SetPackageInclude(const std::string& package_name, const bool& toInclude);
+
private:
EVT_BUTTON(ID_BUTTON_CREATE_APPLICATION, wxCDMAppliDescriptionPanel::OnBtnCreateApplication)
EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMAppliDescriptionPanel::OnBtnEditCMakeLists)
EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMAppliDescriptionPanel::OnBtnOpenFolder)
+EVT_CHECKBOX(ID_CHECK_INCLUDE_APPLICATION, wxCDMAppliDescriptionPanel::OnChBApplicationChange)
END_EVENT_TABLE()
wxCDMAppliDescriptionPanel::wxCDMAppliDescriptionPanel(
wxPanel::Create(parent, id, pos, size, style);
this->appli = appli;
CreateControls();
+ // this part makes the scrollbars show up
+ this->FitInside(); // ask the sizer about the needed size
+ this->SetScrollRate(5, 5);
return TRUE;
}
wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("A&vailable Applications"));
propertiesBox->GetStaticBox()->SetToolTip(wxT("Select any of the available applications to see its details or the modify them."));
wxPanel* propertiesPanel = new wxPanel(this);
- wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
std::vector<modelCDMApplication*> applications = this->appli->GetApplications();
+ wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(applications.size()+1, 3, 9, 5);
+
+ wxStaticText* ChBTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Include in\nCMake"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+ wxStaticText* LkTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Application Name"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+ wxStaticText* HlpTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Help"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+
+ propertiesGridSizer -> Add(ChBTitle, 0, wxEXPAND | wxALL, 5);
+ propertiesGridSizer -> Add(LkTitle, 0, wxEXPAND | wxALL, 5);
+ propertiesGridSizer -> Add(HlpTitle, 0, wxEXPAND | wxALL, 5);
+
for (int i = 0; i < (int)(applications.size()); i++)
{
- wxHyperlinkCtrl* pApplicationlk = new wxHyperlinkCtrl(propertiesPanel,ID_LINK_SELECT_APPLICATION, crea::std2wx(applications[i]->GetName().c_str()), crea::std2wx(applications[i]->GetName().c_str()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
+ //checkbox for cmake inclusion
+ wxCheckBox* pApplicationChB = new wxCheckBox(propertiesPanel, ID_CHECK_INCLUDE_APPLICATION, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+ pApplicationChB->SetName(crea::std2wx(applications[i]->GetName()));
+ std::string tt = "if this box is checked the the " + applications[i]->GetName() + " application is included in the project compilation.";
+ pApplicationChB->SetToolTip(crea::std2wx(tt));
+ pApplicationChB->SetValue(this->appli->IsApplicationIncluded(applications[i]->GetName()));
+ propertiesGridSizer -> Add(pApplicationChB, 0, wxEXPAND | wxALIGN_CENTER);
+
+ //link to library with description
+ wxHyperlinkCtrl* pApplicationlk = new wxHyperlinkCtrl(propertiesPanel, ID_LINK_SELECT_APPLICATION, crea::std2wx(applications[i]->GetName().c_str()), crea::std2wx(applications[i]->GetName().c_str()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
pApplicationlk->SetWindowStyle(wxALIGN_LEFT | wxNO_BORDER);
- std::string tt = "Name: " + applications[i]->GetName() + "\n";
+ tt = "Name: " + applications[i]->GetName() + "\n";
tt += "Location: " + applications[i]->GetPath();
- pApplicationlk->SetToolTip(crea::std2wx(tt.c_str()));
+ pApplicationlk->SetToolTip(crea::std2wx(tt));
pApplicationlk->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMAppliDescriptionPanel::OnMouseEnter,NULL,this);
pApplicationlk->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMAppliDescriptionPanel::OnMouseExit,NULL,this);
- propertiesPanelSizer -> Add(pApplicationlk, 1, wxEXPAND | wxALL, 5);
+ propertiesGridSizer -> Add(pApplicationlk, 0, wxEXPAND);
+
+ //help icon
+ wxButton* pApplicationHlp = new wxButton(propertiesPanel, wxID_ANY, wxT("?"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
+ pApplicationHlp->Enable(false);
+ tt = "When this application is included in the CMakeLists file, the\nfollowing line is included in the CMakeList.txt file in the\nappli folder:\n"
+ "ADD_SUBDIRECTORY(" + applications[i]->GetName() + ")";
+ pApplicationHlp->SetToolTip(crea::std2wx(tt));
+
+ propertiesGridSizer -> Add(pApplicationHlp, 0, wxEXPAND | wxALIGN_CENTER);
}
- propertiesPanel->SetSizer(propertiesPanelSizer);
- propertiesPanelSizer->Fit(propertiesPanel);
+ propertiesGridSizer->AddGrowableCol(1,1);
+
+ propertiesPanel->SetSizer(propertiesGridSizer);
+ propertiesGridSizer->Fit(propertiesPanel);
+
propertiesBox->Add(propertiesPanel, 1, wxEXPAND | wxALL, 5);
sizer -> Add(propertiesBox, 0, wxEXPAND | wxALL, 10);
wxButton* createApplicationbt = new wxButton(actionsPanel, ID_BUTTON_CREATE_APPLICATION, _T("A. Create Application"));
createApplicationbt->SetToolTip(wxT("Create a new application for this project."));
actionsGridSizer->Add(createApplicationbt, 1, wxALL | wxEXPAND, 5);
- wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("B. Edit CMakeLists File"));
+ wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File"));
editCMakebt->SetToolTip(wxT("Open the system default text editor to edit the CMakeLists.txt file."));
editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMAppliDescriptionPanel::OnCMakeMouseEnter,NULL,this);
editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMAppliDescriptionPanel::OnCMakeMouseExit,NULL,this);
actionsGridSizer->Add(editCMakebt, 1, wxALL | wxEXPAND, 5);
- wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("C. Open Applications Folder"));
+ wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Applications Folder"));
openFolderbt->SetToolTip(wxT("Open the appli folder in the file explorer."));
actionsGridSizer->Add(openFolderbt, 1, wxALL | wxEXPAND, 5);
}
}
+void wxCDMAppliDescriptionPanel::OnChBApplicationChange(wxCommandEvent& event)
+{
+ this->appli->SetApplicationInclude(
+ crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()),
+ ((wxCheckBox*)event.GetEventObject())->GetValue()
+ );
+}
+
void wxCDMAppliDescriptionPanel::OnLnkApplicationSelect(wxHyperlinkEvent& event)
{
modelCDMApplication* applicationFound = NULL;
#define WXCDMAPPLIDESCRIPTIONPANEL_H_
#include <creaWx.h>
-#include <wx/panel.h>
#include <wx/hyperlink.h>
#include "modelCDMAppli.h"
/**
* Application manager description panel. Shows the available applications in the project and the actions corresponding to application management.
*/
-class wxCDMAppliDescriptionPanel : public wxPanel
+class wxCDMAppliDescriptionPanel : public wxScrolledWindow
{
DECLARE_EVENT_TABLE()
public:
* Handles when the open package cmakelists file button is pressed.
*/
void OnBtnEditCMakeLists(wxCommandEvent& event);
+ /**
+ * Handles when a application checkbox is (un)checked.
+ * @param event Has the link reference to know which application was selected.
+ */
+ void OnChBApplicationChange(wxCommandEvent& event);
/**
* Handles when an application link is pressed.
* @param event Has the link reference to know which application was selected.
EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMApplicationDescriptionPanel::OnBtnEditCMakeLists)
EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMApplicationDescriptionPanel::OnBtnOpenFolder)
EVT_BUTTON(ID_BUTTON_OPEN_CXX, wxCDMApplicationDescriptionPanel::OnBtnOpenMain)
+EVT_CHECKBOX(ID_CHECK_INCLUDE_3RDLIBRARY, wxCDMApplicationDescriptionPanel::On3rdLibraryChBChange)
+EVT_CHECKBOX(ID_CHECK_INCLUDE_LIBRARY, wxCDMApplicationDescriptionPanel::OnLibraryChBChange)
END_EVENT_TABLE()
wxCDMApplicationDescriptionPanel::wxCDMApplicationDescriptionPanel(
wxPanel::Create(parent, id, pos, size, style);
this->application = application;
CreateControls();
+ // this part makes the scrollbars show up
+ this->FitInside(); // ask the sizer about the needed size
+ this->SetScrollRate(5, 5);
return TRUE;
}
propertiesBox->Add(propertiesPanel, 0, wxEXPAND);
sizer->Add(propertiesBox, 0, wxEXPAND | wxALL, 10);
*/
+
+ //Includes
+ wxStaticBoxSizer* includesBox = new wxStaticBoxSizer(wxHORIZONTAL, this, wxT("&Used Libraries"));
+ includesBox->SetMinSize(200,250);
+ wxScrolledWindow* includesPanel = new wxScrolledWindow(this);
+ wxBoxSizer* includesPanelSizer = new wxBoxSizer(wxVERTICAL);
+
+ //Third Party Libraries
+ wxStaticText* Title1 = new wxStaticText(includesPanel, wxID_ANY, wxT("Third Party Libraries:"));
+ wxFont font = Title1->GetFont();
+ font.SetWeight(wxFONTWEIGHT_BOLD);
+ Title1->SetFont(font);
+ includesPanelSizer->Add(Title1, 0, wxEXPAND);
+
+ //inclusion data
+ std::map<std::string, bool> inclusions = this->application->Get3rdPartyLibraries();
+ //includesGrid Sizer
+ wxFlexGridSizer* includesGridSizer = new wxFlexGridSizer(inclusions.size()+1, 2, 0, 5);
+
+ wxStaticText* ChBTitle = new wxStaticText(
+ includesPanel,
+ wxID_ANY,
+ wxT("Included"),
+ wxDefaultPosition,
+ wxDefaultSize,
+ wxALIGN_CENTER
+ );
+ wxStaticText* LNmTitle = new wxStaticText(
+ includesPanel,
+ wxID_ANY,
+ wxT("Library Name"),
+ wxDefaultPosition,
+ wxDefaultSize,
+ wxALIGN_LEFT
+ );
+
+ includesGridSizer->Add(ChBTitle, 1, wxEXPAND);
+ includesGridSizer->Add(LNmTitle, 1, wxEXPAND);
+
+ for (std::map<std::string, bool>::iterator it = inclusions.begin(); it != inclusions.end(); ++it) {
+ wxCheckBox* ChBIncl = new wxCheckBox(
+ includesPanel, ID_CHECK_INCLUDE_3RDLIBRARY, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT
+ );
+ ChBIncl->SetToolTip(crea::std2wx(
+ "When this box is checked the " + it->first + " library\n"
+ "is included in the project configuration for\n"
+ "this application including the following instruction\n"
+ "in the application's folder CMakeLists.txt file:\n"
+ "SET ( ${LIBRARY_NAME}_LINK_LIBRARIES\n"
+ " ${" + it->first+ "_LIBRARIES}\n"
+ ")"));
+ ChBIncl->SetName(crea::std2wx(it->first));
+ ChBIncl->SetValue(it->second);
+ includesGridSizer->Add(ChBIncl, 1, wxEXPAND);
+
+ wxStaticText* LNmIncl = new wxStaticText(includesPanel, wxID_ANY, crea::std2wx(it->first));
+ includesGridSizer->Add(LNmIncl, 1, wxEXPAND);
+ }
+
+ includesGridSizer->AddGrowableCol(1,1);
+
+ includesPanelSizer->Add(includesGridSizer, 0, wxEXPAND | wxLEFT, 5);
+
+ //Custom Libraries
+ wxStaticText* Title2 = new wxStaticText(includesPanel, wxID_ANY, wxT("Custom Libraries:"));
+ font = Title2->GetFont();
+ font.SetWeight(wxFONTWEIGHT_BOLD);
+ Title2->SetFont(font);
+ includesPanelSizer->Add(Title2, 0, wxEXPAND);
+
+ //inclusion data
+ std::map<std::string, bool> inclusionsLibs = this->application->GetCustomLibraries();
+ //includesGrid Sizer
+ wxFlexGridSizer* includesLibGridSizer = new wxFlexGridSizer(inclusionsLibs.size()+1, 2, 0, 5);
+
+ wxStaticText* ChBTitle1 = new wxStaticText(
+ includesPanel,
+ wxID_ANY,
+ wxT("Included"),
+ wxDefaultPosition,
+ wxDefaultSize,
+ wxALIGN_CENTER
+ );
+ wxStaticText* LNmTitle1 = new wxStaticText(
+ includesPanel,
+ wxID_ANY,
+ wxT("Library Name"),
+ wxDefaultPosition,
+ wxDefaultSize,
+ wxALIGN_LEFT
+ );
+
+ includesLibGridSizer->Add(ChBTitle1, 1, wxEXPAND);
+ includesLibGridSizer->Add(LNmTitle1, 1, wxEXPAND);
+
+ for (std::map<std::string, bool>::iterator it = inclusionsLibs.begin(); it != inclusionsLibs.end(); ++it) {
+ wxCheckBox* ChBIncl = new wxCheckBox(
+ includesPanel, ID_CHECK_INCLUDE_LIBRARY, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT
+ );
+ ChBIncl->SetToolTip(crea::std2wx(
+ "When this box is checked the " + it->first + " custom\n"
+ "library is included in the project configuration for\n"
+ "this application including the following code in the\n"
+ "application's folder CMakeLists.txt file:\n"
+ "INCLUDE_DIRECTORIES (\n"
+ " ../../lib/"+ it->first + "\n"
+ ")\n"
+ "SET ( ${EXE_NAME}_LINK_LIBRARIES\n"
+ " " + it->first+ "\n"
+ ")"));
+ ChBIncl->SetName(crea::std2wx(it->first));
+ ChBIncl->SetValue(it->second);
+ includesLibGridSizer->Add(ChBIncl, 1, wxEXPAND);
+
+ wxStaticText* LNmIncl = new wxStaticText(includesPanel, wxID_ANY, crea::std2wx(it->first));
+ includesLibGridSizer->Add(LNmIncl, 1, wxEXPAND);
+ }
+
+ includesLibGridSizer->AddGrowableCol(1,1);
+
+ includesPanelSizer->Add(includesLibGridSizer, 0, wxEXPAND | wxLEFT, 5);
+
+ includesPanel->SetSizer(includesPanelSizer);
+ includesPanelSizer->Fit(includesPanel);
+
+ includesPanel->FitInside();
+ includesPanel->SetScrollRate(5,5);
+
+ includesBox->Add(includesPanel, 1, wxEXPAND);
+ sizer -> Add(includesBox, 0, wxALL | wxEXPAND, 10);
+
+
//Actions
//actions StaticBoxSizer
wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("&Actions"));
//actionsGrid Sizer
wxFlexGridSizer* actionsGridSizer = new wxFlexGridSizer(3, 2, 9, 15);
- wxButton* createClassbt = new wxButton(actionsPanel, ID_BUTTON_CREATE_CLASS, _T("Create Class (Optional)"));
+ wxButton* createClassbt = new wxButton(actionsPanel, ID_BUTTON_CREATE_CLASS, _T("Create Class"));
createClassbt->SetToolTip(wxT("Create a new Class (.h and .cxx files)."));
- wxButton* createFolderbt = new wxButton(actionsPanel, ID_BUTTON_CREATE_FOLDER, _T("Create Folder (Optional)"));
+ wxButton* createFolderbt = new wxButton(actionsPanel, ID_BUTTON_CREATE_FOLDER, _T("Create Folder"));
createFolderbt->SetToolTip(wxT("Create a new Folder inside the application folder."));
wxButton* openMainbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_CXX, _T("A. Open Main File"));
openMainbt->SetToolTip(wxT("Open the main file in the application folder with the default code editor."));
openMainbt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationDescriptionPanel::OnMainMouseEnter,NULL,this);
openMainbt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationDescriptionPanel::OnMainMouseExit,NULL,this);
- wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("C. Edit CMakeLists File"));
+ wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File"));
editCMakebt->SetToolTip(wxT("Edit the CMakeLists.txt file inside this application."));
editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationDescriptionPanel::OnCMakeMouseEnter,NULL,this);
editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationDescriptionPanel::OnCMakeMouseExit,NULL,this);
- wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("B. Open Application Folder"));
+ wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Application Folder"));
openFolderbt->SetToolTip(wxT("Open the application folder in the file explorer."));
this->executableNametc->SetLabel(crea::std2wx(this->application->GetExecutableName()));
}
+void wxCDMApplicationDescriptionPanel::On3rdLibraryChBChange(wxCommandEvent& event)
+{
+ if(this->application->Set3rdPartyLibrary(crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()), ((wxCheckBox*)event.GetEventObject())->GetValue()))
+ ((wxCheckBox*)event.GetEventObject())->SetValue(((wxCheckBox*)event.GetEventObject())->GetValue());
+ else
+ ((wxCheckBox*)event.GetEventObject())->SetValue(!((wxCheckBox*)event.GetEventObject())->GetValue());
+}
+
+void wxCDMApplicationDescriptionPanel::OnLibraryChBChange(wxCommandEvent& event)
+{
+ if(this->application->SetCustomLibrary(crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()), ((wxCheckBox*)event.GetEventObject())->GetValue()))
+ ((wxCheckBox*)event.GetEventObject())->SetValue(((wxCheckBox*)event.GetEventObject())->GetValue());
+ else
+ ((wxCheckBox*)event.GetEventObject())->SetValue(!((wxCheckBox*)event.GetEventObject())->GetValue());
+}
+
void wxCDMApplicationDescriptionPanel::OnBtnCreateClass(wxCommandEvent& event)
{
//get class name from user
#define WXCDMAPPLICATIONDESCRIPTIONPANEL_H_
#include <creaWx.h>
-#include <wx/panel.h>
#include <wx/hyperlink.h>
#include "modelCDMApplication.h"
/**
* Application description panel. Shows the properties and actions available for the described application.
*/
-class wxCDMApplicationDescriptionPanel : public wxPanel
+class wxCDMApplicationDescriptionPanel : public wxScrolledWindow
{
DECLARE_EVENT_TABLE()
public:
/**
* Handles when the set executable name button is pressed.
+ * @param event Unused
*/
void OnBtnSetExeName(wxCommandEvent& event);
+ /**
+ * Handles when a 3rd Party Library checkbox state is changed. It calls to include/exclude the selected application.
+ * @param event CheckBox event.
+ */
+ void On3rdLibraryChBChange(wxCommandEvent& event);
+ /**
+ * Handles when a Custom Library checkbox state is changed. It calls to include/exclude the selected application.
+ * @param event CheckBox event.
+ */
+ void OnLibraryChBChange(wxCommandEvent& event);
/**
* Handles when the create class button is pressed.
*/
long style
)
{
- wxPanel::Create(parent, id, pos, size, style);
this->blackBox = blackBox;
+ wxPanel::Create(parent, id, pos, size, style);
CreateControls();
+ // this part makes the scrollbars show up
+ this->FitInside(); // ask the sizer about the needed size
+ this->SetScrollRate(5, 5);
return TRUE;
}
openCxxbt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMBlackBoxDescriptionPanel::OnCxxMouseExit,NULL,this);
openCxxbt->SetToolTip(wxT("Open the .cxx file in the default text editor."));
actionsGridSizer->Add(openCxxbt, 1, wxALL | wxEXPAND, 5);
- wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("C. Open Source Folder"));
+ wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Source Folder"));
openFolderbt->SetToolTip(wxT("Open the source folder in the file explorer."));
actionsGridSizer->Add(openFolderbt, 1, wxALL | wxEXPAND, 5);
#define WXCDMBLACKBOXDESCRIPTIONPANEL_H_
#include <creaWx.h>
-#include <wx/panel.h>
#include <wx/hyperlink.h>
#include "modelCDMBlackBox.h"
/**
* Black box description panel. Shows the properties and available actions for the described black box.
*/
-class wxCDMBlackBoxDescriptionPanel : public wxPanel
+class wxCDMBlackBoxDescriptionPanel : public wxScrolledWindow
{
DECLARE_EVENT_TABLE()
public:
wxPanel::Create(parent, id, pos, size, style);
this->cMakeLists = makefile;
CreateControls();
+ // this part makes the scrollbars show up
+ this->FitInside(); // ask the sizer about the needed size
+ this->SetScrollRate(5, 5);
return TRUE;
}
#define WXCDMCMAKELISTSDESCRIPTIONPANEL_H_
#include <creaWx.h>
-#include <wx/panel.h>
#include <wx/hyperlink.h>
#include "modelCDMCMakeListsFile.h"
/**
* CMakeLists File description panel. Shows the file properties and the available actions for it.
*/
-class wxCDMCMakeListsDescriptionPanel : public wxPanel
+class wxCDMCMakeListsDescriptionPanel : public wxScrolledWindow
{
DECLARE_EVENT_TABLE()
public:
wxPanel::Create(parent, id, pos, size, style);
this->file = file;
CreateControls();
+ // this part makes the scrollbars show up
+ this->FitInside(); // ask the sizer about the needed size
+ this->SetScrollRate(5, 5);
return TRUE;
}
wxStaticText *pLength = new wxStaticText(propertiesPanel, -1, wxT("File Size"));
wxStaticText* pLocationtc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->file->GetPath()));
- pLocationtc->SetMaxSize(wxSize(350,-1));
+ pLocationtc->SetMaxSize(wxSize(300,-1));
int lgth = this->file->GetLength();
std::stringstream ss;
ss << lgth / 1024;
std::string lgths = ss.str() + " KB";
wxStaticText* pLengthtc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(lgths));
- propertiesGridSizer->Add(pLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+ propertiesGridSizer->Add(pLocation, 0, wxALIGN_RIGHT | wxALIGN_TOP);
propertiesGridSizer->Add(pLocationtc, 1, wxEXPAND);
- propertiesGridSizer->Add(pLength, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+ propertiesGridSizer->Add(pLength, 0, wxALIGN_RIGHT | wxALIGN_TOP);
propertiesGridSizer->Add(pLengthtc, 1, wxEXPAND);
propertiesGridSizer->AddGrowableCol(1,1);
#define WXCDMFILEDESCRIPTIONPANEL_H_
#include <creaWx.h>
-#include <wx/panel.h>
#include <wx/hyperlink.h>
#include "modelCDMFile.h"
/**
* File description panel. Shows the File properties and the available options for it.
*/
-class wxCDMFileDescriptionPanel : public wxPanel
+class wxCDMFileDescriptionPanel : public wxScrolledWindow
{
DECLARE_EVENT_TABLE()
public:
wxPanel::Create(parent, id, pos, size, style);
this->folder = folder;
CreateControls();
+ // this part makes the scrollbars show up
+ this->FitInside(); // ask the sizer about the needed size
+ this->SetScrollRate(5, 5);
return TRUE;
}
#define WXCDMFOLDERDESCRIPTIONPANEL_H_
#include <creaWx.h>
-#include <wx/panel.h>
#include <wx/hyperlink.h>
#include "modelCDMFolder.h"
/**
* Folder description panel. Shows the properties of the referenced folder and the available actions.
*/
-class wxCDMFolderDescriptionPanel : public wxPanel
+class wxCDMFolderDescriptionPanel : public wxScrolledWindow
{
DECLARE_EVENT_TABLE()
public:
EVT_BUTTON(ID_BUTTON_CREATE_LIBRARY, wxCDMLibDescriptionPanel::OnBtnCreateLibrary)
EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMLibDescriptionPanel::OnBtnEditCMakeLists)
EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMLibDescriptionPanel::OnBtnOpenFolder)
+EVT_CHECKBOX(ID_CHECK_INCLUDE_LIBRARY, wxCDMLibDescriptionPanel::OnChBLibraryChange)
END_EVENT_TABLE()
wxCDMLibDescriptionPanel::wxCDMLibDescriptionPanel(
wxPanel::Create(parent, id, pos, size, style);
this->lib = lib;
CreateControls();
+ // this part makes the scrollbars show up
+ this->FitInside(); // ask the sizer about the needed size
+ this->SetScrollRate(5, 5);
return TRUE;
}
wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("A&vailable Libraries"));
propertiesBox->GetStaticBox()->SetToolTip(wxT("Select any of the available libraries to see its details or modify them."));
wxPanel* propertiesPanel = new wxPanel(this);
- wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
std::vector<modelCDMLibrary*> libraries = this->lib->GetLibraries();
+ wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(libraries.size()+1, 3, 9, 5);
+
+ wxStaticText* ChBTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Include in\nCMake"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+ wxStaticText* LkTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Library Name"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+ wxStaticText* HlpTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Help"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+
+ propertiesGridSizer -> Add(ChBTitle, 0, wxEXPAND | wxALL, 5);
+ propertiesGridSizer -> Add(LkTitle, 0, wxEXPAND | wxALL, 5);
+ propertiesGridSizer -> Add(HlpTitle, 0, wxEXPAND | wxALL, 5);
+
for (int i = 0; i < (int)(libraries.size()); i++)
{
- wxHyperlinkCtrl* pLibrarylk = new wxHyperlinkCtrl(propertiesPanel, ID_LINK_SELECT_LIBRARY, crea::std2wx(libraries[i]->GetName().c_str()), crea::std2wx(libraries[i]->GetName().c_str()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
+ //checkbox for cmake inclusion
+ wxCheckBox* pLibraryChB = new wxCheckBox(propertiesPanel, ID_CHECK_INCLUDE_LIBRARY, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+ pLibraryChB->SetName(crea::std2wx(libraries[i]->GetName()));
+ std::string tt = "if this box is checked the the " + libraries[i]->GetName() + " library is included in the project compilation.";
+ pLibraryChB->SetToolTip(crea::std2wx(tt));
+ pLibraryChB->SetValue(this->lib->IsLibraryIncluded(libraries[i]->GetName()));
+ propertiesGridSizer -> Add(pLibraryChB, 0, wxEXPAND | wxALIGN_CENTER);
+
+ //link to library with description
+ wxHyperlinkCtrl* pLibrarylk = new wxHyperlinkCtrl(propertiesPanel, ID_LINK_SELECT_LIBRARY, crea::std2wx(libraries[i]->GetName().c_str()), crea::std2wx(libraries[i]->GetName().c_str()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
pLibrarylk->SetWindowStyle(wxALIGN_LEFT | wxNO_BORDER);
- std::string tt = "Name: " + libraries[i]->GetName() + "\n";
+ tt = "Name: " + libraries[i]->GetName() + "\n";
tt += "Location: " + libraries[i]->GetPath();
- pLibrarylk->SetToolTip(crea::std2wx(tt.c_str()));
+ pLibrarylk->SetToolTip(crea::std2wx(tt));
pLibrarylk->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibDescriptionPanel::OnMouseEnter,NULL,this);
pLibrarylk->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibDescriptionPanel::OnMouseExit,NULL,this);
- propertiesPanelSizer -> Add(pLibrarylk, 0, wxEXPAND | wxALL, 5);
+ propertiesGridSizer -> Add(pLibrarylk, 0, wxEXPAND);
+
+ //help icon
+ wxButton* pLibraryHlp = new wxButton(propertiesPanel, wxID_ANY, wxT("?"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
+ pLibraryHlp->Enable(false);
+ tt = "When this library is included in the CMakeLists file, the\nfollowing line is included in the CMakeList.txt file in the lib\nfolder:\n"
+ "ADD_SUBDIRECTORY(" + libraries[i]->GetName() + ")";
+ pLibraryHlp->SetToolTip(crea::std2wx(tt));
+
+ propertiesGridSizer -> Add(pLibraryHlp, 0, wxEXPAND | wxALIGN_CENTER);
}
- propertiesPanel->SetSizer(propertiesPanelSizer);
- propertiesPanelSizer->Fit(propertiesPanel);
+ propertiesGridSizer->AddGrowableCol(1,1);
+
+ propertiesPanel->SetSizer(propertiesGridSizer);
+ propertiesGridSizer->Fit(propertiesPanel);
propertiesBox->Add(propertiesPanel, 1, wxALL | wxEXPAND, 5);
sizer -> Add(propertiesBox, 0, wxEXPAND | wxALL, 10);
wxButton* createLibrarybt = new wxButton(actionsPanel, ID_BUTTON_CREATE_LIBRARY, _T("A. Create Library"));
createLibrarybt->SetToolTip(wxT("Create a new library for this project."));
actionsGridSizer->Add(createLibrarybt, 1, wxALL | wxEXPAND, 5);
- wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("B. Edit CMakeLists File"));
+ wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File"));
editCMakebt->SetToolTip(wxT("Open the system default text editor to edit the Lib's CMakeLists.txt file."));
editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibDescriptionPanel::OnCMakeMouseEnter,NULL,this);
editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibDescriptionPanel::OnCMakeMouseExit,NULL,this);
actionsGridSizer->Add(editCMakebt, 1, wxALL | wxEXPAND, 5);
- wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("C. Open Libraries Folder"));
+ wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Libraries Folder"));
openFolderbt->SetToolTip(wxT("Open the lib folder in the file explorer."));
actionsGridSizer->Add(openFolderbt, 1, wxALL | wxEXPAND, 5);
}
}
+void wxCDMLibDescriptionPanel::OnChBLibraryChange(wxCommandEvent& event)
+{
+ this->lib->SetLibraryInclude(
+ crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()),
+ ((wxCheckBox*)event.GetEventObject())->GetValue()
+ );
+}
+
void wxCDMLibDescriptionPanel::OnLnkLibrarySelect(wxHyperlinkEvent& event)
{
modelCDMLibrary* theLibrary = NULL;
#define WXCDMLIBDESCRIPTIONPANEL_H_
#include <creaWx.h>
-#include <wx/panel.h>
#include <wx/hyperlink.h>
#include "modelCDMLib.h"
/**
* Library manager description panel. Shows the available libraries in the project and the actions corresponding to library management.
*/
-class wxCDMLibDescriptionPanel : public wxPanel
+class wxCDMLibDescriptionPanel : public wxScrolledWindow
{
DECLARE_EVENT_TABLE()
public:
* Handles when the open package cmakelists file button is pressed.
*/
void OnBtnEditCMakeLists(wxCommandEvent& event);
+ /**
+ * Handles when a library checkbox is (un)checked.
+ * @param event Has the link reference to know which library was selected.
+ */
+ void OnChBLibraryChange(wxCommandEvent& event);
/**
* Handles when a library link is pressed.
* @param event Has the link reference to know which library was selected.
EVT_BUTTON(ID_BUTTON_CREATE_FOLDER, wxCDMLibraryDescriptionPanel::OnBtnCreateFolder)
EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMLibraryDescriptionPanel::OnBtnEditCMakeLists)
EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMLibraryDescriptionPanel::OnBtnOpenFolder)
+EVT_CHECKBOX(ID_CHECK_INCLUDE_3RDLIBRARY, wxCDMLibraryDescriptionPanel::On3rdLibraryChBChange)
+EVT_CHECKBOX(ID_CHECK_INCLUDE_LIBRARY, wxCDMLibraryDescriptionPanel::OnLibraryChBChange)
END_EVENT_TABLE()
wxCDMLibraryDescriptionPanel::wxCDMLibraryDescriptionPanel(
wxPanel::Create(parent, id, pos, size, style);
this->library = library;
CreateControls();
+ // this part makes the scrollbars show up
+ this->FitInside(); // ask the sizer about the needed size
+ this->SetScrollRate(5, 5);
return TRUE;
}
propertiesBox->Add(propertiesPanel, 0, wxEXPAND);
sizer->Add(propertiesBox, 0, wxEXPAND | wxALL, 10);
*/
+
+ //Includes
+ wxStaticBoxSizer* includesBox = new wxStaticBoxSizer(wxHORIZONTAL, this, wxT("&Used Libraries"));
+ includesBox->SetMinSize(200,250);
+ wxScrolledWindow* includesPanel = new wxScrolledWindow(this);
+ wxBoxSizer* includesPanelSizer = new wxBoxSizer(wxVERTICAL);
+
+ //Third Party Libraries
+ wxStaticText* Title1 = new wxStaticText(includesPanel, wxID_ANY, wxT("Third Party Libraries:"));
+ wxFont font = Title1->GetFont();
+ font.SetWeight(wxFONTWEIGHT_BOLD);
+ Title1->SetFont(font);
+ includesPanelSizer->Add(Title1, 0, wxEXPAND);
+
+ //inclusion data
+ std::map<std::string, bool> inclusions = this->library->Get3rdPartyLibraries();
+ //includesGrid Sizer
+ wxFlexGridSizer* includesGridSizer = new wxFlexGridSizer(inclusions.size()+1, 2, 0, 5);
+
+ wxStaticText* ChBTitle = new wxStaticText(
+ includesPanel,
+ wxID_ANY,
+ wxT("Included"),
+ wxDefaultPosition,
+ wxDefaultSize,
+ wxALIGN_CENTER
+ );
+ wxStaticText* LNmTitle = new wxStaticText(
+ includesPanel,
+ wxID_ANY,
+ wxT("Library Name"),
+ wxDefaultPosition,
+ wxDefaultSize,
+ wxALIGN_LEFT
+ );
+
+ includesGridSizer->Add(ChBTitle, 1, wxEXPAND);
+ includesGridSizer->Add(LNmTitle, 1, wxEXPAND);
+
+ for (std::map<std::string, bool>::iterator it = inclusions.begin(); it != inclusions.end(); ++it) {
+ wxCheckBox* ChBIncl = new wxCheckBox(
+ includesPanel, ID_CHECK_INCLUDE_3RDLIBRARY, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT
+ );
+ ChBIncl->SetToolTip(crea::std2wx(
+ "When this box is checked the " + it->first + " library\n"
+ "is included in the project configuration for\n"
+ "this library including the following instruction\n"
+ "in the library's folder CMakeLists.txt file:\n"
+ "SET ( ${LIBRARY_NAME}_LINK_LIBRARIES\n"
+ " ${" + it->first+ "_LIBRARIES}\n"
+ ")"));
+ ChBIncl->SetName(crea::std2wx(it->first));
+ ChBIncl->SetValue(it->second);
+ includesGridSizer->Add(ChBIncl, 1, wxEXPAND);
+
+ wxStaticText* LNmIncl = new wxStaticText(includesPanel, wxID_ANY, crea::std2wx(it->first));
+ includesGridSizer->Add(LNmIncl, 1, wxEXPAND);
+ }
+
+ includesGridSizer->AddGrowableCol(1,1);
+
+ includesPanelSizer->Add(includesGridSizer, 0, wxEXPAND | wxLEFT, 5);
+
+ //Custom Libraries
+ wxStaticText* Title2 = new wxStaticText(includesPanel, wxID_ANY, wxT("Custom Libraries:"));
+ font = Title2->GetFont();
+ font.SetWeight(wxFONTWEIGHT_BOLD);
+ Title2->SetFont(font);
+ includesPanelSizer->Add(Title2, 0, wxEXPAND);
+
+ //inclusion data
+ std::map<std::string, bool> inclusionsLibs = this->library->GetCustomLibraries();
+ //includesGrid Sizer
+ wxFlexGridSizer* includesLibGridSizer = new wxFlexGridSizer(inclusionsLibs.size()+1, 2, 0, 5);
+
+ wxStaticText* ChBTitle1 = new wxStaticText(
+ includesPanel,
+ wxID_ANY,
+ wxT("Included"),
+ wxDefaultPosition,
+ wxDefaultSize,
+ wxALIGN_CENTER
+ );
+ wxStaticText* LNmTitle1 = new wxStaticText(
+ includesPanel,
+ wxID_ANY,
+ wxT("Library Name"),
+ wxDefaultPosition,
+ wxDefaultSize,
+ wxALIGN_LEFT
+ );
+
+ includesLibGridSizer->Add(ChBTitle1, 1, wxEXPAND);
+ includesLibGridSizer->Add(LNmTitle1, 1, wxEXPAND);
+
+ for (std::map<std::string, bool>::iterator it = inclusionsLibs.begin(); it != inclusionsLibs.end(); ++it) {
+ wxCheckBox* ChBIncl = new wxCheckBox(
+ includesPanel, ID_CHECK_INCLUDE_LIBRARY, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT
+ );
+ ChBIncl->SetToolTip(crea::std2wx(
+ "When this box is checked the " + it->first + " custom\n"
+ "library is included in the project configuration for\n"
+ "this library including the following code in the\n"
+ "library's CMakeLists.txt file:\n"
+ "INCLUDE_DIRECTORIES (\n"
+ " ../"+ it->first + "\n"
+ ")\n"
+ "SET ( ${LIBRARY_NAME}_LINK_LIBRARIES\n"
+ " " + it->first+ "\n"
+ ")"));
+ ChBIncl->SetName(crea::std2wx(it->first));
+ ChBIncl->SetValue(it->second);
+ includesLibGridSizer->Add(ChBIncl, 1, wxEXPAND);
+
+ wxStaticText* LNmIncl = new wxStaticText(includesPanel, wxID_ANY, crea::std2wx(it->first));
+ includesLibGridSizer->Add(LNmIncl, 1, wxEXPAND);
+ }
+
+ includesLibGridSizer->AddGrowableCol(1,1);
+
+ includesPanelSizer->Add(includesLibGridSizer, 0, wxEXPAND | wxLEFT, 5);
+
+ includesPanel->SetSizer(includesPanelSizer);
+ includesPanelSizer->Fit(includesPanel);
+
+ includesPanel->FitInside();
+ includesPanel->SetScrollRate(5,5);
+
+ includesBox->Add(includesPanel, 1, wxEXPAND);
+ sizer -> Add(includesBox, 0, wxALL | wxEXPAND, 10);
+
+
+
//Actions
wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxHORIZONTAL, this, wxT("&Actions"));
wxPanel* actionsPanel = new wxPanel(this);
wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("B. Open Library Folder"));
openFolderbt->SetToolTip(wxT("Open the library folder in the file explorer."));
actionsGridSizer->Add(openFolderbt, 1, wxALL | wxEXPAND, 5);
- wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("C. Edit CMakeLists File"));
+ wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File"));
editCMakebt->SetToolTip(wxT("Edit the CMakeLists.txt of this library in the default text editor."));
editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibraryDescriptionPanel::OnCMakeMouseEnter,NULL,this);
editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibraryDescriptionPanel::OnCMakeMouseExit,NULL,this);
actionsGridSizer->Add(editCMakebt, 1, wxALL | wxEXPAND, 5);
- wxButton* createFolderbt = new wxButton(actionsPanel, ID_BUTTON_CREATE_FOLDER, _T("Create Folder (Optional)"));
+ wxButton* createFolderbt = new wxButton(actionsPanel, ID_BUTTON_CREATE_FOLDER, _T("Create Folder"));
createFolderbt->SetToolTip(wxT("Create a new folder for this library."));
actionsGridSizer->Add(createFolderbt, 1, wxALL | wxEXPAND, 5);
this->libraryNametc->SetLabel(crea::std2wx(this->library->GetNameLibrary()));
}
+void wxCDMLibraryDescriptionPanel::On3rdLibraryChBChange(wxCommandEvent& event)
+{
+ if(this->library->Set3rdPartyLibrary(crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()), ((wxCheckBox*)event.GetEventObject())->GetValue()))
+ ((wxCheckBox*)event.GetEventObject())->SetValue(((wxCheckBox*)event.GetEventObject())->GetValue());
+ else
+ ((wxCheckBox*)event.GetEventObject())->SetValue(!((wxCheckBox*)event.GetEventObject())->GetValue());
+}
+
+void wxCDMLibraryDescriptionPanel::OnLibraryChBChange(wxCommandEvent& event)
+{
+ if(this->library->SetCustomLibrary(crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()), ((wxCheckBox*)event.GetEventObject())->GetValue()))
+ ((wxCheckBox*)event.GetEventObject())->SetValue(((wxCheckBox*)event.GetEventObject())->GetValue());
+ else
+ ((wxCheckBox*)event.GetEventObject())->SetValue(!((wxCheckBox*)event.GetEventObject())->GetValue());
+}
+
void wxCDMLibraryDescriptionPanel::OnBtnCreateClass(wxCommandEvent& event)
{
//get class name from user
#define WXCDMLIBRARYDESCRIPTIONPANEL_H_
#include <creaWx.h>
-#include <wx/panel.h>
#include <wx/hyperlink.h>
#include "modelCDMLibrary.h"
/**
* Library description panel. Shows the available actions on the described library.
*/
-class wxCDMLibraryDescriptionPanel : public wxPanel
+class wxCDMLibraryDescriptionPanel : public wxScrolledWindow
{
DECLARE_EVENT_TABLE()
public:
* @param event Unused.
*/
void OnBtnSetExeName(wxCommandEvent& event);
+ /**
+ * Handles when a 3rd Party Library checkbox state is changed. It calls to include/exclude the selected library.
+ * @param event CheckBox event.
+ */
+ void On3rdLibraryChBChange(wxCommandEvent& event);
+ /**
+ * Handles when a Custom Library checkbox state is changed. It calls to include/exclude the selected library.
+ * @param event CheckBox event.
+ */
+ void OnLibraryChBChange(wxCommandEvent& event);
/**
* Handles when the create class button is pressed.
* @param event Unused.
{
wxPanel::Create(parent, id, pos, size, style);
CreateControls();
+ //to scroll
+ this->FitInside(); // ask the sizer about the needed size
+ this->SetScrollRate(5, 5);
+
+
return TRUE;
}
sizer->Add(headerSizer, 0, wxALIGN_CENTER | wxUP, 10);
//Actions
- wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("&Actions"));
+ wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxHORIZONTAL, this, wxT("&Actions"));
actionsBox->GetStaticBox()->SetToolTip(wxT("Create a new crea project or open an existing one selection any of the available actions."));
- wxPanel* actionsPanel = new wxPanel(this);
- wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
+ //wxPanel* actionsPanel = new wxPanel(this);
+ //wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
- wxButton* newProjectbt = new wxButton(actionsPanel, ID_BUTTON_NEWPROJECT, _T("New Project"));
+ wxButton* newProjectbt = new wxButton(this, ID_BUTTON_NEWPROJECT, _T("New Project"));
newProjectbt->SetToolTip(wxT("Create a new crea project."));
- actionsPanelSizer->Add(newProjectbt, 0, wxRIGHT | wxLEFT, 20);
- wxButton* openProjectbt = new wxButton(actionsPanel, ID_BUTTON_OPENPROJECT, _T("Open Project (source/binaries)"));
+ actionsBox->Add(newProjectbt, 0, wxALL, 20);
+ wxButton* openProjectbt = new wxButton(this, ID_BUTTON_OPENPROJECT, _T("Open Project (source/binaries)"));
openProjectbt->SetToolTip(wxT("Open an existing crea project from its binaries or its sources."));
- actionsPanelSizer->Add(openProjectbt, 0, wxRIGHT | wxLEFT, 20);
+ actionsBox->Add(openProjectbt, 0, wxALL, 20);
+
+ //actionsPanel->SetSizer(actionsPanelSizer);
+ //actionsPanelSizer->Fit(actionsPanel);
- actionsPanel->SetSizer(actionsPanelSizer);
- actionsPanelSizer->Fit(actionsPanel);
- actionsBox->Add(actionsPanel, 0, wxALIGN_CENTER | wxALL, 10);
- sizer -> Add(actionsBox, 0, wxEXPAND | wxALL, 20);
+ //actionsBox->Add(actionsPanel, 0,wxEXPAND | wxALIGN_CENTER | wxALL, 10);
+ sizer -> Add(actionsBox, 0, wxALIGN_CENTER | wxALL, 20);
//Asign sizer
sizer->SetSizeHints(this);
SetSizer(sizer);
-
+ sizer->Fit(this);
if(((wxCDMMainFrame*)this->GetParent())->isHelp())
{
wxDialog* helpDialog = new wxCDMMainHelpDialog(this->GetParent(), this, wxID_ANY);
#define WXCDMMAINDESCRIPTIONPANEL_H_
#include <creaWx.h>
-#include <wx/panel.h>
/**
* Main View description panel. Shows the welcome message and allows to open or create Crea projects.
*/
-class wxCDMMainDescriptionPanel : public wxPanel
+class wxCDMMainDescriptionPanel : public wxScrolledWindow
{
DECLARE_EVENT_TABLE()
BEGIN_EVENT_TABLE(wxCDMMainFrame, wxFrame)
+EVT_MENU_OPEN(wxCDMMainFrame::OnMenuBarOpen)
EVT_MENU(ID_MENU_NEW_PROJECT, wxCDMMainFrame::OnMenuNewProject)
EVT_MENU(ID_MENU_OPEN_PROJECT, wxCDMMainFrame::OnMenuOpenProject)
+EVT_MENU(ID_MENU_OPEN_RECENT1, wxCDMMainFrame::OnMenuOpenRecent)
+EVT_MENU(ID_MENU_OPEN_RECENT2, wxCDMMainFrame::OnMenuOpenRecent)
+EVT_MENU(ID_MENU_OPEN_RECENT3, wxCDMMainFrame::OnMenuOpenRecent)
+EVT_MENU(ID_MENU_OPEN_RECENT4, wxCDMMainFrame::OnMenuOpenRecent)
+EVT_MENU(ID_MENU_OPEN_RECENT5, wxCDMMainFrame::OnMenuOpenRecent)
EVT_MENU(ID_MENU_CLOSE_PROJECT, wxCDMMainFrame::OnMenuCloseProject)
EVT_MENU(ID_MENU_EXPORT_HIERARCHY, wxCDMMainFrame::OnMenuExportHierarchy)
EVT_MENU(ID_MENU_EXIT, wxCDMMainFrame::OnMenuExit)
{
wxMenuBar* menuBar = new wxMenuBar;
+ //Recently opened projects
+ menu_Recent = new wxMenu();
+ wxConfigBase* pConfig = wxConfigBase::Get();
+ std::string rp = crea::wx2std(pConfig->Read(wxT("RECENT1"), wxT("")));
+ if(rp != "")
+ {
+ menu_Recent->Append(ID_MENU_OPEN_RECENT1, crea::std2wx(rp));
+ rp = crea::wx2std(pConfig->Read(wxT("RECENT2"), wxT("")));
+ if(rp != "")
+ {
+ menu_Recent->Append(ID_MENU_OPEN_RECENT2, crea::std2wx(rp));
+ rp = crea::wx2std(pConfig->Read(wxT("RECENT3"), wxT("")));
+ if(rp != "")
+ {
+ menu_Recent->Append(ID_MENU_OPEN_RECENT3, crea::std2wx(rp));
+ rp = crea::wx2std(pConfig->Read(wxT("RECENT4"), wxT("")));
+ if(rp != "")
+ {
+ menu_Recent->Append(ID_MENU_OPEN_RECENT4, crea::std2wx(rp));
+ rp = crea::wx2std(pConfig->Read(wxT("RECENT5"), wxT("")));
+ if(rp != "")
+ {
+ menu_Recent->Append(ID_MENU_OPEN_RECENT5, crea::std2wx(rp));
+ }
+ }
+ }
+ }
+ }
+
//FileMenu
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->AppendSubMenu(menu_Recent,wxT("Open &Recent"),wxT("Open a recently opened project."));
menu_File->AppendSeparator();
menu_File->Append(ID_MENU_CLOSE_PROJECT, wxT("&Close Project"));
menu_File->AppendSeparator();
);
auiManager.AddPane(panel_Properties, wxAuiPaneInfo().BestSize(600,400).CenterPane().Name(wxT("panel_Properties")).Caption(wxT("")).CloseButton(false));
- auiManager.AddPane(tree_Projects, wxAuiPaneInfo().Right().MinSize(300,300).BestSize(300,400).CloseButton(false).Name(wxT("tree_Projects")).Caption(wxT("Project Tree")).CloseButton(false));
+ auiManager.AddPane(tree_Projects, wxAuiPaneInfo().Left().MinSize(250,300).BestSize(250,400).CloseButton(false).Name(wxT("tree_Projects")).Caption(wxT("Project Tree")).CloseButton(false));
auiManager.Update();
//auiManager.LoadPerspective(pers,true);
wxToolTip::Enable(true);
}
//Event Handlers
+
+void wxCDMMainFrame::OnMenuBarOpen(wxMenuEvent& event)
+{
+ //clean recent menu
+ int tam = menu_Recent->GetMenuItemCount();
+ for (int i = 0; i < tam; ++i) {
+ menu_Recent->Delete(menu_Recent->FindItemByPosition(0));
+ }
+ //populate recent menu
+ wxConfigBase* pConfig = wxConfigBase::Get();
+ std::string rp = crea::wx2std(pConfig->Read(wxT("RECENT1"), wxT("")));
+ if(rp != "")
+ {
+ menu_Recent->Append(ID_MENU_OPEN_RECENT1, crea::std2wx(rp));
+ rp = crea::wx2std(pConfig->Read(wxT("RECENT2"), wxT("")));
+ if(rp != "")
+ {
+ menu_Recent->Append(ID_MENU_OPEN_RECENT2, crea::std2wx(rp));
+ rp = crea::wx2std(pConfig->Read(wxT("RECENT3"), wxT("")));
+ if(rp != "")
+ {
+ menu_Recent->Append(ID_MENU_OPEN_RECENT3, crea::std2wx(rp));
+ rp = crea::wx2std(pConfig->Read(wxT("RECENT4"), wxT("")));
+ if(rp != "")
+ {
+ menu_Recent->Append(ID_MENU_OPEN_RECENT4, crea::std2wx(rp));
+ rp = crea::wx2std(pConfig->Read(wxT("RECENT5"), wxT("")));
+ if(rp != "")
+ {
+ menu_Recent->Append(ID_MENU_OPEN_RECENT5, crea::std2wx(rp));
+ }
+ }
+ }
+ }
+ }
+}
+
//File menu
void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
{
if(userResponse == wxID_FORWARD)
{
- //create project
+ //close open project
if(this->model->GetProject() != NULL)
{
if(!this->model->CloseProject(result))
event.Skip();
return;
}
+
if(this->panel_Properties != NULL)
{
auiManager.DetachPane(this->panel_Properties);
}
-
+ //create project
if(!this->model->CreateProject(
crea::wx2std(dialog->GetProjectName()),
crea::wx2std(dialog->GetProjectLocation()),
return;
}
+ //update recently open projects
+ wxConfigBase* pConfig = wxConfigBase::Get();
+ if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath()))
+ {
+ pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT("")));
+ pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT("")));
+ pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT("")));
+ pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT("")));
+ pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath()));
+ }
+
+
//show project actions panel
if(this->panel_ProjectActions != NULL)
{
//wxMessageBox(wxT("ProjectSelected") ,_T("New Project - Success!"),wxOK | wxICON_ERROR);
}
}
+void wxCDMMainFrame::OnMenuOpenRecent(wxCommandEvent& event)
+{
+ std::string* result;
+
+ //((wxMenuItem*)(event.GetEventObject()))->GetItemLabel();
+
+ std::string path = "";
+ wxConfigBase* pConfig = wxConfigBase::Get();
+ if(event.GetId() == ID_MENU_OPEN_RECENT1)
+ path = crea::wx2std (pConfig->Read(wxT("RECENT1"),wxT("")));
+ else if(event.GetId() == ID_MENU_OPEN_RECENT2)
+ path = crea::wx2std (pConfig->Read(wxT("RECENT2"),wxT("")));
+ else if(event.GetId() == ID_MENU_OPEN_RECENT3)
+ path = crea::wx2std (pConfig->Read(wxT("RECENT3"),wxT("")));
+ else if(event.GetId() == ID_MENU_OPEN_RECENT4)
+ path = crea::wx2std (pConfig->Read(wxT("RECENT4"),wxT("")));
+ else if(event.GetId() == ID_MENU_OPEN_RECENT5)
+ path = crea::wx2std (pConfig->Read(wxT("RECENT5"),wxT("")));
+
+ std::cout << "Selection to open: " << path << std::endl;
+ std::cout.flush();
+
+
+ //populate model
+ if(this->model->GetProject() != NULL)
+ {
+ std::cout << "Project not null, closing it" << std::endl;
+ if(!this->model->CloseProject(result))
+ {
+ std::cout << "error closing project: " << *result << std::endl;
+ wxMessageBox(crea::std2wx(result->c_str()),_T("New Project - Error!"),wxOK | wxICON_ERROR);
+ event.Skip();
+ return;
+ }
+
+ if(this->panel_Properties != NULL)
+ {
+ auiManager.DetachPane(this->panel_Properties);
+ this->panel_Properties->Hide();
+ }
+ if(this->panel_ProjectActions != NULL)
+ {
+ auiManager.DetachPane(this->panel_ProjectActions);
+ this->panel_ProjectActions->Hide();
+ }
+ }
+
+ if (!this->model->OpenProject(path, result))
+ {
+ std::cout << "error opening project: " << *result << std::endl;
+ wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR);
+ event.Skip();
+ return;
+ };
+
+ //update recently open projects
+ if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath()))
+ {
+ pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT("")));
+ pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT("")));
+ pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT("")));
+ pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT("")));
+ pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath()));
+ }
+
+ std::cout << "building ui" << std::endl;
+
+ //populate tree control
+ tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
+ tree_Projects->Unselect();
+ this->actualTreeItem.Unset();
+ tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
+
+
+ //change project's actions panel
+ if(this->panel_ProjectActions!= NULL)
+ {
+ auiManager.DetachPane(this->panel_ProjectActions);
+ this->panel_ProjectActions->Destroy();
+ this->panel_ProjectActions = NULL;
+ }
+ panel_ProjectActions = new wxCDMProjectActionsPanel(
+ this,
+ this->model->GetProject(),
+ ID_WINDOW_PROJ_ACTIONS,
+ wxT("Project Actions Panel"),
+ wxDefaultPosition,
+ wxSize(800,200),
+ 0
+ );
+ panel_ProjectActions->SetMinSize(wxSize(500, 100));
+
+
+ auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
+
+ auiManager.Update();
+
+}
void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event)
{
std::string* result;
event.Skip();
return;
}
+
if(this->panel_Properties != NULL)
{
auiManager.DetachPane(this->panel_Properties);
return;
};
+ //update recently open projects
+ wxConfigBase* pConfig = wxConfigBase::Get();
+ if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath()))
+ {
+ pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT("")));
+ pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT("")));
+ pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT("")));
+ pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT("")));
+ pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath()));
+ }
+
std::cout << "building ui" << std::endl;
//populate tree control
private:
//Menus
+ /**
+ * Recently opened projects menu
+ */
+ wxMenu* menu_Recent;
/**
* File menu
*/
//events
protected:
+
+ /**
+ * Starts when the menu bar is opened.
+ * @param event The event object that triggers the handler.
+ */
+ void OnMenuBarOpen(wxMenuEvent& event);
+
//File
/**
* New project handler. Launches a new project dialog and creates a project model if the project is correctly created.
* @param event The event object that triggers the handler.
*/
void OnMenuOpenProject(wxCommandEvent& event);
+ /**
+ * Open recent project handler. Creates a project model if the project is correctly opened given its path.
+ * @param event The event object that triggers the handler.
+ */
+ void OnMenuOpenRecent(wxCommandEvent& event);
/**
* Close project handler. Remove the project from the model and restarts the user interface.
* @param event The event object that triggers the handler.
--- /dev/null
+/*
+# ---------------------------------------------------------------------
+#
+# 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.
+# ------------------------------------------------------------------------
+ */
+
+
+/*
+ * wxCDMPackageConfigurationDialog.cpp
+ *
+ * Created on: 6/4/2013
+ * Author: Daniel Felipe Gonzalez Obando
+ */
+
+#include "wxCDMPackageConfigurationDialog.h"
+
+#include "creaDevManagerIds.h"
+
+BEGIN_EVENT_TABLE(wxCDMPackageConfigurationDialog, wxDialog)
+EVT_BUTTON(wxID_OK, wxCDMPackageConfigurationDialog::OnFinish)
+EVT_CHECKBOX(ID_CHECK_INCLUDE_3RDLIBRARY, wxCDMPackageConfigurationDialog::On3rdLibraryIncludeChange)
+EVT_CHECKBOX(ID_CHECK_INCLUDE_LIBRARY, wxCDMPackageConfigurationDialog::OnCustomLibraryIncludeChange)
+END_EVENT_TABLE()
+
+wxCDMPackageConfigurationDialog::wxCDMPackageConfigurationDialog(
+ wxWindow* parent,
+ modelCDMPackage* package,
+ wxWindowID id,
+ const wxString& caption,
+ const wxPoint& position,
+ const wxSize& size,
+ long style
+)
+{
+ this->package = package;
+ wxCDMPackageConfigurationDialog::Create(parent, id, caption, position, size, style);
+}
+
+wxCDMPackageConfigurationDialog::~wxCDMPackageConfigurationDialog()
+{
+}
+
+bool wxCDMPackageConfigurationDialog::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 wxCDMPackageConfigurationDialog::CreateControls()
+{
+
+ wxBoxSizer* v_sizer1 = new wxBoxSizer(wxVERTICAL);
+
+
+ wxStaticText* title = new wxStaticText(this, wxID_ANY, wxT("Please select the libraries that are used in this package."), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);//new wxRichTextCtrl(this,wxID_ANY, wxString("Create a new project"), wxDefaultPosition, wxDefaultSize, wxRE_READONLY);
+ v_sizer1->Add(title, 0, wxEXPAND | wxALIGN_LEFT | wxALL, 5);
+
+ wxScrolledWindow* includesPanel = new wxScrolledWindow(this);
+ includesPanel->FitInside();
+ includesPanel->SetScrollRate(5,5);
+
+ wxBoxSizer* includesPanelSizer = new wxBoxSizer(wxVERTICAL);
+
+ //Third Party Libraries
+ wxStaticText* Title1 = new wxStaticText(includesPanel, wxID_ANY, wxT("Third Party Libraries:"));
+ wxFont font = Title1->GetFont();
+ font.SetWeight(wxFONTWEIGHT_BOLD);
+ Title1->SetFont(font);
+ includesPanelSizer->Add(Title1, 0, wxEXPAND);
+
+ //inclusion data
+ std::map<std::string, bool> inclusions = this->package->Get3rdPartyLibraries();
+ //includesGrid Sizer
+ wxFlexGridSizer* includesGridSizer = new wxFlexGridSizer(inclusions.size()+1, 2, 0, 5);
+
+ wxStaticText* ChBTitle = new wxStaticText(
+ includesPanel,
+ wxID_ANY,
+ wxT("Included"),
+ wxDefaultPosition,
+ wxDefaultSize,
+ wxALIGN_CENTER
+ );
+ wxStaticText* LNmTitle = new wxStaticText(
+ includesPanel,
+ wxID_ANY,
+ wxT("Library Name"),
+ wxDefaultPosition,
+ wxDefaultSize,
+ wxALIGN_LEFT
+ );
+
+ includesGridSizer->Add(ChBTitle, 1, wxEXPAND);
+ includesGridSizer->Add(LNmTitle, 1, wxEXPAND);
+
+ for (std::map<std::string, bool>::iterator it = inclusions.begin(); it != inclusions.end(); ++it) {
+ wxCheckBox* ChBIncl = new wxCheckBox(
+ includesPanel, ID_CHECK_INCLUDE_3RDLIBRARY, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT
+ );
+ ChBIncl->SetToolTip(crea::std2wx(
+ "When this box is checked the " + it->first + " library\n"
+ "is included in the project configuration for\n"
+ "this package including the following instruction\n"
+ "in the package's folder CMakeLists.txt file:\n"
+ "SET(${BBTK_PACKAGE_NAME}_USE_" + it->first+ " ON)\n"
+ ));
+ ChBIncl->SetName(crea::std2wx(it->first));
+ ChBIncl->SetValue(it->second);
+ includesGridSizer->Add(ChBIncl, 0, wxEXPAND);
+
+ wxStaticText* LNmIncl = new wxStaticText(includesPanel, wxID_ANY, crea::std2wx(it->first));
+ includesGridSizer->Add(LNmIncl, 1, wxEXPAND);
+ }
+
+ includesGridSizer->AddGrowableCol(1,1);
+
+ includesPanelSizer->Add(includesGridSizer, 1, wxEXPAND | wxLEFT, 5);
+
+ //Custom Libraries
+ wxStaticText* Title2 = new wxStaticText(includesPanel, wxID_ANY, wxT("Custom Libraries:"));
+ font = Title2->GetFont();
+ font.SetWeight(wxFONTWEIGHT_BOLD);
+ Title2->SetFont(font);
+ includesPanelSizer->Add(Title2, 0, wxEXPAND);
+
+ //inclusion data
+ std::map<std::string, bool> inclusionsLibs = this->package->GetCustomLibraries();
+ //includesGrid Sizer
+ wxFlexGridSizer* includesLibGridSizer = new wxFlexGridSizer(inclusionsLibs.size()+1, 2, 0, 5);
+
+ wxStaticText* ChBTitle1 = new wxStaticText(
+ includesPanel,
+ wxID_ANY,
+ wxT("Included"),
+ wxDefaultPosition,
+ wxDefaultSize,
+ wxALIGN_CENTER
+ );
+ wxStaticText* LNmTitle1 = new wxStaticText(
+ includesPanel,
+ wxID_ANY,
+ wxT("Library Name"),
+ wxDefaultPosition,
+ wxDefaultSize,
+ wxALIGN_LEFT
+ );
+
+ includesLibGridSizer->Add(ChBTitle1, 1, wxEXPAND);
+ includesLibGridSizer->Add(LNmTitle1, 1, wxEXPAND);
+
+ for (std::map<std::string, bool>::iterator it = inclusionsLibs.begin(); it != inclusionsLibs.end(); ++it) {
+ wxCheckBox* ChBIncl = new wxCheckBox(
+ includesPanel, ID_CHECK_INCLUDE_LIBRARY, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT
+ );
+ ChBIncl->SetToolTip(crea::std2wx(
+ "When this box is checked the " + it->first + " custom\n"
+ "library is included in the project configuration for\n"
+ "this packages including the following code in the\n"
+ "package's folder CMakeLists.txt file:\n"
+ "SET(${BBTK_PACKAGE_NAME}_INCLUDE_DIRS\n"
+ " ../lib/"+ it->first + "\n"
+ ")\n"
+ "SET(${BBTK_PACKAGE_NAME}_LIBS\n"
+ " " + it->first+ "\n"
+ ")"));
+ ChBIncl->SetName(crea::std2wx(it->first));
+ ChBIncl->SetValue(it->second);
+ includesLibGridSizer->Add(ChBIncl, 0, wxEXPAND);
+
+ wxStaticText* LNmIncl = new wxStaticText(includesPanel, wxID_ANY, crea::std2wx(it->first));
+ includesLibGridSizer->Add(LNmIncl, 1, wxEXPAND);
+ }
+
+ includesLibGridSizer->AddGrowableCol(1,1);
+
+ includesPanelSizer->Add(includesLibGridSizer, 0, wxEXPAND | wxLEFT, 5);
+
+ includesPanel->SetSizer(includesPanelSizer);
+
+ v_sizer1->Add(includesPanel, 1, wxEXPAND | wxALL, 10);
+
+ v_sizer1->Add(new wxButton(this, wxID_OK, wxT("Close")), 0, wxALIGN_CENTER | wxRIGHT | wxBOTTOM, 30);
+
+ SetSizer(v_sizer1);
+}
+
+void wxCDMPackageConfigurationDialog::OnFinish(wxCommandEvent& event)
+{
+ this->EndModal(wxID_OK);
+}
+
+void wxCDMPackageConfigurationDialog::On3rdLibraryIncludeChange(
+ wxCommandEvent& event)
+{
+ if(this->package->Set3rdPartyLibrary(crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()), ((wxCheckBox*)event.GetEventObject())->GetValue()))
+ ((wxCheckBox*)event.GetEventObject())->SetValue(((wxCheckBox*)event.GetEventObject())->GetValue());
+ else
+ ((wxCheckBox*)event.GetEventObject())->SetValue(!((wxCheckBox*)event.GetEventObject())->GetValue());
+}
+
+void wxCDMPackageConfigurationDialog::OnCustomLibraryIncludeChange(
+ wxCommandEvent& event)
+{
+ if(this->package->SetCustomLibrary(crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()), ((wxCheckBox*)event.GetEventObject())->GetValue()))
+ ((wxCheckBox*)event.GetEventObject())->SetValue(((wxCheckBox*)event.GetEventObject())->GetValue());
+ else
+ ((wxCheckBox*)event.GetEventObject())->SetValue(!((wxCheckBox*)event.GetEventObject())->GetValue());
+}
--- /dev/null
+/*
+# ---------------------------------------------------------------------
+#
+# 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.
+# ------------------------------------------------------------------------
+*/
+
+
+/*
+ * wxCDMPackageConfigurationDialog.h
+ *
+ * Created on: 6/4/2013
+ * Author: Daniel Felipe Gonzalez Obando
+ */
+
+#ifndef WXCDMPACKAGECONFIGURATIONDIALOG_H_
+#define WXCDMPACKAGECONFIGURATIONDIALOG_H_
+
+#include <creaWx.h>
+#include <wx/dialog.h>
+
+#include "modelCDMPackage.h"
+
+/**
+ * Package Configuration Dialog
+ */
+class wxCDMPackageConfigurationDialog : public wxDialog
+{
+ DECLARE_EVENT_TABLE()
+public:
+ /**
+ * Package Configuration Dialog Constructor.
+ * @param parent Parent window.
+ * @param package Package Description reference.
+ * @param id Dialog ID. By default wxID_ANY.
+ * @param caption Dialog label. By default "Package Library Configuration".
+ * @param position Dialog position. By default wxDefaultPosition.
+ * @param size Dialog size. By default 350, 370.
+ * @param style Dialog style. By default wxDEFAULT_DIALOG_STYLE.
+ */
+ wxCDMPackageConfigurationDialog(
+ wxWindow* parent,
+ modelCDMPackage * package,
+ wxWindowID id = wxID_ANY,
+ const wxString& caption = wxT("Package Library Configuration"),
+ const wxPoint& position = wxDefaultPosition,
+ const wxSize& size = wxSize(350,370),
+ long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER
+ );
+ /**
+ * Destructor.
+ */
+ ~wxCDMPackageConfigurationDialog();
+ /**
+ * Package Configuration Dialog Creator.
+ * @param parent Parent window.
+ * @param id Dialog ID. By default wxID_ANY.
+ * @param caption Dialog label. By default "Package Library Configuration".
+ * @param position Dialog position. By default wxDefaultPosition.
+ * @param size Dialog size. By default 350, 370.
+ * @param style Dialog style. By default wxDEFAULT_DIALOG_STYLE.
+ * @return if the creation was successful.
+ */
+ bool Create(
+ wxWindow* parent,
+ wxWindowID id = wxID_ANY,
+ const wxString& caption = wxT("Package Library Configuration"),
+ const wxPoint& position = wxDefaultPosition,
+ const wxSize& size = wxSize(350,370),
+ long style = wxDEFAULT_DIALOG_STYLE
+ );
+
+protected:
+ /**
+ * Creates the help controls (text and buttons).
+ */
+ void CreateControls();
+
+//attributes
+private:
+ /**
+ * Main panel reference.
+ */
+ modelCDMPackage* package;
+
+//handlers
+protected:
+ /**
+ * Handler to close configuration dialog.
+ * @param event Unused.
+ */
+ void OnFinish(wxCommandEvent& event);
+
+ /**
+ * Handler when a third party library include is pressed.
+ * @param event checkbox event.
+ */
+ void On3rdLibraryIncludeChange(wxCommandEvent& event);
+
+ /**
+ * Handler when a custom library include is pressed.
+ * @param event checkbox event.
+ */
+ void OnCustomLibraryIncludeChange(wxCommandEvent& event);
+};
+
+#endif /* WXCDMPACKAGECONFIGURATIONDIALOG_H_ */
#include "images/PkIcon64.xpm"
#include "wxCDMNewBlackBoxDialog.h"
+#include "wxCDMPackageConfigurationDialog.h"
#include <wx/textdlg.h>
#include "CDMUtilities.h"
EVT_BUTTON(ID_BUTTON_CREATE_BLACKBOX, wxCDMPackageDescriptionPanel::OnBtnCreateBlackBox)
EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMPackageDescriptionPanel::OnBtnEditCMakeLists)
EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMPackageDescriptionPanel::OnBtnOpenFolder)
+EVT_BUTTON(ID_BUTTON_CHOOSE, wxCDMPackageDescriptionPanel::OnBtnConfigurePackage)
END_EVENT_TABLE()
wxCDMPackageDescriptionPanel::wxCDMPackageDescriptionPanel(
long style
)
{
- wxPanel::Create(parent, id, pos, size, style);
this->package = package;
+ wxPanel::Create(parent, id, pos, size, style);
CreateControls();
+ // this part makes the scrollbars show up
+ this->FitInside(); // ask the sizer about the needed size
+ this->SetScrollRate(5, 5);
return TRUE;
}
wxButton* createBBbt = new wxButton(actionsPanel, ID_BUTTON_CREATE_BLACKBOX, _T("A. Create Black Box"));
createBBbt->SetToolTip(wxT("Create a new black box for the active project inside this package."));
actionsGridSizer->Add(createBBbt, 1, wxALL | wxEXPAND, 5);
- wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("B. Edit CMakeLists File"));
+ wxButton* editConfbt = new wxButton(actionsPanel, ID_BUTTON_CHOOSE, _T("B. Configure Package"));
+ editConfbt->SetToolTip(wxT("Select the libraries your package is going to use. This procedure changes the package's CMakeLists file."));
+ actionsGridSizer->Add(editConfbt, 1, wxALL | wxEXPAND, 5);
+ wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File"));
editCMakebt->SetToolTip(wxT("Open the system default text editor to edit the package's CMakeLists.txt file."));
editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageDescriptionPanel::OnCMakeMouseEnter,NULL,this);
editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageDescriptionPanel::OnCMakeMouseExit,NULL,this);
actionsGridSizer->Add(editCMakebt, 1, wxALL | wxEXPAND, 5);
- wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("C. Open Package Folder"));
+ wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Package Folder"));
openFolderbt->SetToolTip(wxT("Open the package folder in the file explorer."));
actionsGridSizer->Add(openFolderbt, 1, wxALL | wxEXPAND, 5);
}
}
+void
+wxCDMPackageDescriptionPanel::OnBtnConfigurePackage(wxCommandEvent& event)
+{
+ wxCDMPackageConfigurationDialog* dialog = new wxCDMPackageConfigurationDialog(this,this->package);
+ long userResponse;
+ userResponse = dialog->ShowModal();
+}
+
void wxCDMPackageDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
{
std::string* result;
#define WXCDMPACKAGEDESCRIPTIONPANEL_H_
#include <creaWx.h>
-#include <wx/panel.h>
#include <wx/hyperlink.h>
#include "modelCDMPackage.h"
/**
* Package description panel. Shows the package's properties and the available actions for a package.
*/
-class wxCDMPackageDescriptionPanel : public wxPanel
+class wxCDMPackageDescriptionPanel : public wxScrolledWindow
{
DECLARE_EVENT_TABLE()
public:
* Handles when the create black box button is pressed.
*/
void OnBtnCreateBlackBox(wxCommandEvent& event);
+ /**
+ * Handles when the configure package button is pressed.
+ */
+ void OnBtnConfigurePackage(wxCommandEvent& event);
/**
* Handles when the edit cmakelists file button is pressed.
*/
EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_TOOL_CLICKED, wxCDMPackageManagerPanel::OnBtnCreatePackage)
EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMPackageManagerPanel::OnBtnEditCMakeLists)
EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_TOOL_ENTER, wxCDMPackageManagerPanel::OnBtnEditCMakeLists)
+EVT_CHECKBOX(ID_CHECK_INCLUDE_PACKAGE, wxCDMPackageManagerPanel::OnChBPackageChange)
END_EVENT_TABLE()
wxCDMPackageManagerPanel::wxCDMPackageManagerPanel(
wxPanel::Create(parent, id, pos, size, style);
this->project = project;
CreateControls();
+ // this part makes the scrollbars show up
+ this->FitInside(); // ask the sizer about the needed size
+ this->SetScrollRate(5, 5);
return TRUE;
}
wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("A&vailable Packages"));
propertiesBox->GetStaticBox()->SetToolTip(wxT("Select any of the available packages to see its details or modify them. Remember that black boxes are created inside packages, any of these packages is available."));
wxPanel* propertiesPanel = new wxPanel(this);
- wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
std::vector<modelCDMPackage*> packages = this->project->GetPackages();
+ wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(packages.size()+1, 3, 9, 5);
+
+ wxStaticText* ChBTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Include in\nCMake"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+ wxStaticText* LkTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Package Name"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+ wxStaticText* HlpTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Help"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+
+ propertiesGridSizer -> Add(ChBTitle, 0, wxEXPAND | wxALL, 5);
+ propertiesGridSizer -> Add(LkTitle, 0, wxEXPAND | wxALL, 5);
+ propertiesGridSizer -> Add(HlpTitle, 0, wxEXPAND | wxALL, 5);
+
for (int i = 0; i < (int)(packages.size()); i++)
{
- wxHyperlinkCtrl* pPackagelk = new wxHyperlinkCtrl(propertiesPanel,ID_LINK_SELECT_PACKAGE, crea::std2wx(packages[i]->GetName().c_str()), crea::std2wx(packages[i]->GetName().c_str()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
- pPackagelk->SetWindowStyle(wxALIGN_LEFT | wxNO_BORDER);
- std::string tt = "Author: " + packages[i]->GetAuthors() + "\nDescription: " + packages[i]->GetDescription();
+ //checkbox for cmake inclusion
+ wxCheckBox* pPackageChB = new wxCheckBox(propertiesPanel, ID_CHECK_INCLUDE_PACKAGE, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+ pPackageChB->SetName(crea::std2wx(packages[i]->GetName()));
+ std::string tt = "if this box is checked the the " + packages[i]->GetName() + " package is included in the project compilation.";
+ pPackageChB->SetToolTip(crea::std2wx(tt));
+ pPackageChB->SetValue(this->project->IsPackageIncluded(packages[i]->GetName()));
+ propertiesGridSizer -> Add(pPackageChB, 0, wxEXPAND | wxALIGN_CENTER);
+
+ //link to package with description
+ wxHyperlinkCtrl* pPackagelk = new wxHyperlinkCtrl(propertiesPanel, ID_LINK_SELECT_PACKAGE, crea::std2wx(packages[i]->GetName().c_str()), crea::std2wx(packages[i]->GetName().c_str()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
+ pPackagelk->SetWindowStyle(wxALIGN_LEFT | wxNO_BORDER);
+ tt = "Name: " + packages[i]->GetName() + "\n";
+ tt += "Location: " + packages[i]->GetPath();
pPackagelk->SetToolTip(crea::std2wx(tt));
- propertiesPanelSizer -> Add(pPackagelk, 0, wxEXPAND | wxALL, 5);
pPackagelk->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageManagerPanel::OnMouseEnter,NULL,this);
pPackagelk->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageManagerPanel::OnMouseExit,NULL,this);
+ propertiesGridSizer -> Add(pPackagelk, 0, wxEXPAND);
+
+ //help icon
+ wxButton* pPackageHlp = new wxButton(propertiesPanel, wxID_ANY, wxT("?"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
+ pPackageHlp->Enable(false);
+ tt = "When this package is included in the CMakeLists file, the\nfollowing line is included in the CMakeList.txt file in the\nproject folder:\n"
+ "ADD_SUBDIRECTORY(" + packages[i]->GetName() + ")";
+ pPackageHlp->SetToolTip(crea::std2wx(tt));
+
+ propertiesGridSizer -> Add(pPackageHlp, 0, wxEXPAND | wxALIGN_CENTER);
}
- propertiesPanel->SetSizer(propertiesPanelSizer);
- propertiesPanelSizer->Fit(propertiesPanel);
+ propertiesGridSizer->AddGrowableCol(1,1);
+
+ propertiesPanel->SetSizer(propertiesGridSizer);
+ propertiesGridSizer->Fit(propertiesPanel);
+
+
propertiesBox->Add(propertiesPanel, 1, wxALL | wxEXPAND, 5);
sizer -> Add(propertiesBox, 0, wxEXPAND | wxALL, 10);
wxButton* createPkgbt = new wxButton(actionsPanel, ID_BUTTON_CREATE_PACKAGE, _T("A. Create Package"));
createPkgbt->SetToolTip(wxT("Create a new package for this project."));
actionsGridSizer->Add(createPkgbt, 1, wxALL | wxEXPAND, 5);
- wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("B. Edit CMakeLists File"));
+ wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File"));
editCMakebt->SetToolTip(wxT("Edit the CMakeLists.txt file of this project."));
editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageManagerPanel::OnCMakeMouseEnter,NULL,this);
editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageManagerPanel::OnCMakeMouseExit,NULL,this);
wxPostEvent(this->GetParent(), *newEvent);
}
+void wxCDMPackageManagerPanel::OnChBPackageChange(wxCommandEvent& event)
+{
+ this->project->SetPackageInclude(
+ crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()),
+ ((wxCheckBox*)event.GetEventObject())->GetValue()
+ );
+}
+
void wxCDMPackageManagerPanel::OnLnkPackageSelect(wxHyperlinkEvent& event)
{
modelCDMPackage* thePackage = NULL;
#define WXCDMPACKAGEMANAGERPANEL_H_
#include <creaWx.h>
-#include <wx/panel.h>
#include <wx/hyperlink.h>
#include <wx/event.h>
/**
* Package manager description panel. Shows the available packages in the project and the actions corresponding to package management.
*/
-class wxCDMPackageManagerPanel : public wxPanel
+class wxCDMPackageManagerPanel : public wxScrolledWindow
{
DECLARE_EVENT_TABLE()
public:
* @param event Has the link reference to know where to return
*/
void OnBtnReturn(wxHyperlinkEvent& event);
+ /**
+ * Handles when a package checkbox is (un)checked.
+ * @param event Has the link reference to know which package was selected.
+ */
+ void OnChBPackageChange(wxCommandEvent& event);
/**
* Handles when a packages link is pressed.
* @param event Has the link reference to know which package was selected.
wxPanel::Create(parent,id,pos,size,style);
wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
this->SetSizer(sizer);
-
CreateControls();
+ // this part makes the scrollbars show up
+ this->FitInside(); // ask the sizer about the needed size
+ this->SetScrollRate(5, 5);
return TRUE;
}
#define WXCDMPROJECTACTIONSPANEL_H_
#include <creaWx.h>
-#include <wx/panel.h>
#include "modelCDMProject.h"
/**
* Panel with common actions for an open Crea project.
*/
-class wxCDMProjectActionsPanel : public wxPanel
+class wxCDMProjectActionsPanel : public wxScrolledWindow
{
DECLARE_EVENT_TABLE()
public:
EVT_BUTTON(ID_BUTTON_GOTO_APPLI_MANAGER, wxCDMProjectDescriptionPanel::OnBtnManageApplications)
EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists)
EVT_BUTTON(ID_BUTTON_SET_BUILD_PATH, wxCDMProjectDescriptionPanel::OnBtnSetBuildPath)
+EVT_BUTTON(ID_BUTTON_OPEN_BUILD_PATH, wxCDMProjectDescriptionPanel::OnBtnOpenBuild)
EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMProjectDescriptionPanel::OnBtnOpenFolder)
EVT_BUTTON(ID_BUTTON_SET_VERSION, wxCDMProjectDescriptionPanel::OnBtnSetVersion)
END_EVENT_TABLE()
wxPanel::Create(parent, id, pos, size, style);
this->project = project;
CreateControls();
+ // this part makes the scrollbars show up
+ this->FitInside(); // ask the sizer about the needed size
+ this->SetScrollRate(5, 5);
return TRUE;
}
// sourceLocation
wxBoxSizer* pSourceLocationsz = new wxBoxSizer(wxHORIZONTAL);
wxStaticText* pSourceLocationtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetPath()));
- //pSourceLocationtc->SetMaxSize(wxSize(350,-1));
+ pSourceLocationtc->SetMaxSize(wxSize(200,-1));
wxButton* pSourceLocationbt = new wxButton(propertiesPanel, ID_BUTTON_OPEN_FOLDER, wxT("Open"));
pSourceLocationbt->SetToolTip(wxT("Open the source folder in the file explorer."));
pSourceLocationsz->Add(pSourceLocationtc, 1, wxALIGN_CENTER, 1);
// buildLocation
wxBoxSizer* pBuildLocationsz = new wxBoxSizer(wxHORIZONTAL);
this->buildPathtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetBuildPath()));
- //this->buildPathtc->SetMaxSize(wxSize(350,-1));
- wxButton* pBuildLocationbt = new wxButton(propertiesPanel, ID_BUTTON_SET_BUILD_PATH, wxT("Choose"));
+ this->buildPathtc->SetMaxSize(wxSize(200,-1));
+
+ wxButton* pBuildLocationbt = new wxButton(propertiesPanel, ID_BUTTON_SET_BUILD_PATH, wxT("Choose..."));
pBuildLocationbt->SetToolTip(wxT("Select a new location for compiling the project."));
+
+ wxButton* pBuildOpenbt = new wxButton(propertiesPanel, ID_BUTTON_OPEN_BUILD_PATH, wxT("Open"));
+ pBuildOpenbt->SetToolTip(wxT("Open the binaries folder in the file explorer."));
+
pBuildLocationsz->Add(this->buildPathtc, 1, wxALIGN_CENTER, 1);
pBuildLocationsz->Add(pBuildLocationbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
+ pBuildLocationsz->Add(pBuildOpenbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
propertiesGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
propertiesGridSizer->Add(pVersionsz, 1, wxEXPAND);
actionsGridSizer->Add(appliMgrbt, 1, wxALL | wxEXPAND, 5);
}
// edit CMakeLists file
- wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("D. Edit CMakeLists File"));
+ wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File"));
editCMakebt->SetToolTip(wxT("Edit the CMakeLists.txt file of this project."));
editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnCMakeMouseEnter,NULL,this);
editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnCMakeMouseExit,NULL,this);
}
}
-void
-wxCDMProjectDescriptionPanel::OnBtnSetBuildPath(wxCommandEvent& event)
+void wxCDMProjectDescriptionPanel::OnBtnSetBuildPath(wxCommandEvent& event)
{
wxDirDialog* dialog = new wxDirDialog(this, wxT("Choose the new build location for the project"));
if(dialog->ShowModal())
this->buildPathtc->SetLabel(crea::std2wx(this->project->GetBuildPath()));
}
-void
-wxCDMProjectDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
+void wxCDMProjectDescriptionPanel::OnBtnOpenBuild(wxCommandEvent& event)
+{
+ if(CDMUtilities::openFileExplorer(this->project->GetBuildPath()))
+ wxMessageBox(crea::std2wx("The folder doesn't exist or hasn't yet been created."),_T("Open Folder - Error!"),wxOK | wxICON_ERROR);
+}
+
+void wxCDMProjectDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
{
std::string* result;
if(!this->project->OpenInFileExplorer(result))
#define WXCDMPROJECTDESCRIPTIONPANEL_H_
#include <creaWx.h>
-#include <wx/panel.h>
#include "modelCDMProject.h"
/**
* Project Description Panel. Shows the project properties and the principal actions for the project.
*/
-class wxCDMProjectDescriptionPanel : public wxPanel
+class wxCDMProjectDescriptionPanel : public wxScrolledWindow
{
DECLARE_EVENT_TABLE()
public:
* Handles when the choose build path button is pressed.
*/
void OnBtnSetBuildPath(wxCommandEvent& event);
+ /**
+ * Handles when the open build folder button is pressed.
+ */
+ void OnBtnOpenBuild(wxCommandEvent& event);
/**
* Handles when the open containing folder button is pressed.
*/