]> Creatis software - crea.git/commitdiff
Merge remote-tracking branch 'refs/remotes/origin/creaDevManagerCMake'
authorunknown <gonzalez@EI-ED-345.creatis.insa-lyon.fr>
Tue, 23 Apr 2013 12:31:47 +0000 (14:31 +0200)
committerunknown <gonzalez@EI-ED-345.creatis.insa-lyon.fr>
Tue, 23 Apr 2013 12:31:47 +0000 (14:31 +0200)
47 files changed:
appli/creaDevManager/creaDevManager.cpp
lib/creaDevManagerLib/CDMUtilities.cpp
lib/creaDevManagerLib/CDMUtilities.h
lib/creaDevManagerLib/CMakeLists.txt
lib/creaDevManagerLib/creaDevManagerIds.h
lib/creaDevManagerLib/modelCDMAppli.cpp
lib/creaDevManagerLib/modelCDMAppli.h
lib/creaDevManagerLib/modelCDMApplication.cpp
lib/creaDevManagerLib/modelCDMApplication.h
lib/creaDevManagerLib/modelCDMLib.cpp
lib/creaDevManagerLib/modelCDMLib.h
lib/creaDevManagerLib/modelCDMLibrary.cpp
lib/creaDevManagerLib/modelCDMLibrary.h
lib/creaDevManagerLib/modelCDMPackage.cpp
lib/creaDevManagerLib/modelCDMPackage.h
lib/creaDevManagerLib/modelCDMProject.cpp
lib/creaDevManagerLib/modelCDMProject.h
lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp
lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.h
lib/creaDevManagerLib/wxCDMApplicationDescriptionPanel.cpp
lib/creaDevManagerLib/wxCDMApplicationDescriptionPanel.h
lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.cpp
lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.h
lib/creaDevManagerLib/wxCDMCMakeListsDescriptionPanel.cpp
lib/creaDevManagerLib/wxCDMCMakeListsDescriptionPanel.h
lib/creaDevManagerLib/wxCDMFileDescriptionPanel.cpp
lib/creaDevManagerLib/wxCDMFileDescriptionPanel.h
lib/creaDevManagerLib/wxCDMFolderDescriptionPanel.cpp
lib/creaDevManagerLib/wxCDMFolderDescriptionPanel.h
lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp
lib/creaDevManagerLib/wxCDMLibDescriptionPanel.h
lib/creaDevManagerLib/wxCDMLibraryDescriptionPanel.cpp
lib/creaDevManagerLib/wxCDMLibraryDescriptionPanel.h
lib/creaDevManagerLib/wxCDMMainDescriptionPanel.cpp
lib/creaDevManagerLib/wxCDMMainDescriptionPanel.h
lib/creaDevManagerLib/wxCDMMainFrame.cpp
lib/creaDevManagerLib/wxCDMMainFrame.h
lib/creaDevManagerLib/wxCDMPackageConfigurationDialog.cpp [new file with mode: 0644]
lib/creaDevManagerLib/wxCDMPackageConfigurationDialog.h [new file with mode: 0644]
lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp
lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.h
lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp
lib/creaDevManagerLib/wxCDMPackageManagerPanel.h
lib/creaDevManagerLib/wxCDMProjectActionsPanel.cpp
lib/creaDevManagerLib/wxCDMProjectActionsPanel.h
lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp
lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.h

index fd922da7e8e70de8ff6bb946ffda26e6334c0216..a57d7b23ba822e5a053b8663574ab7d16b4280f9 100644 (file)
@@ -49,7 +49,7 @@ bool wxCreaDevManagerApp::OnInit()
 
   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;
index b4696b1104177d6949398c58a0d5638d631cef95..cc64ee3e96acfa6376010b08e7adc64afc5b29bd 100644 (file)
@@ -356,4 +356,196 @@ namespace CDMUtilities
        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;
+  }
+
 }
index 5430aea2a9c97d770162aeb1ca398783eccf660c..92fe3d0cbd409b2cb531711fefd252da8a77b1da 100644 (file)
@@ -36,6 +36,7 @@
 #define CDMUTILITIES_H_
 
 #include<iostream>
+#include<vector>
 #include<cstddef>
 
 namespace CDMUtilities
@@ -175,6 +176,62 @@ 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_ */
index 37aa14e1ced15d716ffb7def417428f10412c697..bb1dbea12bb24554962021003dfe1ae332032d56 100644 (file)
@@ -1,7 +1,7 @@
 # ---------------------------------------------------------------------
 #
 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
-#                        pour la Santé)
+#                        pour la Sant�)
 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
@@ -83,7 +83,7 @@ IF ( BUILD_${LIBRARY_NAME} )
   #    ${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
index a73f569ac6ddf63120ad0792b03a7e711c054f44..2ac39608f999fa89354957495b88a6e2884dde23 100644 (file)
 #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_ */
index bcb0876ae6fcef9063820a0f535a8206ecb3875a..c66cbb871beb6deabfe5d74d36f31cbf7ee1d203 100644 (file)
@@ -183,6 +183,14 @@ modelCDMApplication* modelCDMAppli::CreateApplication(
           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);
@@ -237,6 +245,14 @@ modelCDMApplication* modelCDMAppli::CreateApplication(
           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);
@@ -467,3 +483,95 @@ void modelCDMAppli::CheckStructure(std::map<std::string, bool>& properties)
       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;
+}
index 579f12a2105e859710a5898c6e6cda0b783466ce..c3bce223b4798b2dc0a6c4c9efc22ca656783ca5 100644 (file)
@@ -72,7 +72,7 @@ public:
   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.
@@ -96,6 +96,21 @@ public:
    */
   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.
index 7083c4738cb9e778fc26d04cf9bb14d9f4b676d7..5d0f597df42de34211590bb008739ffa6412e660 100644 (file)
 
 #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"
@@ -117,7 +122,6 @@ modelCDMApplication::modelCDMApplication(modelCDMIProjectTreeNode* parent, const
       while (cont)
         {
           std::string stdfileName = crea::wx2std(fileName);
-
           //if CMakeLists, create CMakeLists
           if(stdfileName == "CMakeLists.txt")
             {
@@ -129,23 +133,46 @@ modelCDMApplication::modelCDMApplication(modelCDMIProjectTreeNode* parent, const
             {
               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);
             }
@@ -514,3 +541,456 @@ void modelCDMApplication::CheckStructure(std::map<std::string, bool>& properties
 
     }
 }
+
+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;
+}
index e471ec9289fd8a93c36f2b42efdf5d47c05773f7..18cb7c52bde7edd9ea52b7c2199caf03c2487315 100644 (file)
@@ -105,6 +105,30 @@ public:
    */
   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.
index e3c29023fffc04797962496f86d7f948d1fb2a00..3dcf9b8786766ce64d0681718d4dc22f16a65f6b 100644 (file)
@@ -177,6 +177,15 @@ modelCDMLibrary* modelCDMLib::CreateLibrary(
       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);
@@ -398,3 +407,95 @@ void modelCDMLib::CheckStructure(std::map<std::string, bool>& properties)
       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;
+}
index e372e5f887f9455e7ed3d36e7f09e46f332eca66..d8b8c27fbf0110292d652249de370b0a29d82905 100644 (file)
@@ -72,7 +72,7 @@ public:
   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.
@@ -95,6 +95,21 @@ public:
    */
   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.
index 7b99318b58333425375949bdd6d8b689dd4d5fe8..72310c78c3a7553e598b2867a43f9ee7e1bfad3c 100644 (file)
 
 #include "modelCDMLibrary.h"
 
+#include "modelCDMLib.h"
+
 #include <fstream>
 #include <sstream>
 #include <algorithm>
+#include <boost/regex.hpp>
 
 #include "CDMUtilities.h"
 #include "creaWx.h"
@@ -433,3 +436,445 @@ void modelCDMLibrary::CheckStructure(std::map<std::string, bool>& properties)
 
     }
 }
+
+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;
+}
index ae37ec9d2a7ca83d01e80f5377860d17bd16b4e8..bec12783c504f0c602063b53a0eabe2f5f6e71a9 100644 (file)
@@ -98,6 +98,30 @@ public:
    */
   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.
index 66c5e22fdac803ba73e4cc655fe2a3e87cae16ec..e565dec98f6728bdc933c7a75d01cf9f6ee6a736 100644 (file)
 
 #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"
@@ -689,3 +695,447 @@ void modelCDMPackage::CheckStructure(std::map<std::string, bool>& properties)
 
     }
 }
+
+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;
+}
index 05e24739014b69c8752d840ec9e57bb4a9b8b63d..198e68bafb44e148097783444fba3af93452ae25 100644 (file)
@@ -161,6 +161,30 @@ public:
    */
   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.
index aa6fdebcfe45432d06dce302ce0a4e05a4064dfe..c39463376e247080cecea63f49a45723ac5e4de9 100644 (file)
@@ -387,6 +387,14 @@ modelCDMIProjectTreeNode* modelCDMProject::CreatePackage(
       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);
@@ -739,15 +747,13 @@ bool modelCDMProject::Build(std::string*& result, const std::string& line)
   //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__
@@ -1001,3 +1007,96 @@ void modelCDMProject::CheckStructure(std::map<std::string, bool>& properties)
       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;
+}
index 5df1550a28c11c0fafe6b146472bdba5342a8336..f354db9e51c6e3e56aa73f82a79a8b1204b93524 100644 (file)
@@ -142,7 +142,7 @@ public:
 
   //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 '_'.
@@ -252,6 +252,21 @@ public:
    */
   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:
 
index 49904c2524caac65fe4655a846657c75d52f8111..9f818515305b4d9c6f4b5f24d9ef68fbe4e01887 100644 (file)
@@ -49,6 +49,7 @@ EVT_HYPERLINK(ID_LINK_SELECT_APPLICATION, wxCDMAppliDescriptionPanel::OnLnkAppli
 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(
@@ -81,6 +82,9 @@ bool wxCDMAppliDescriptionPanel::Create(
   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;
 }
 
@@ -120,23 +124,53 @@ void wxCDMAppliDescriptionPanel::CreateControls()
   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);
 
@@ -151,12 +185,12 @@ void wxCDMAppliDescriptionPanel::CreateControls()
   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);
 
@@ -254,6 +288,14 @@ void wxCDMAppliDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
     }
 }
 
+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;
index 88c2cf94b3333c1afa091b57dcc95b7f5dfc911e..a12c31f459521906559fb430e1657c70caf4d5fe 100644 (file)
@@ -36,7 +36,6 @@
 #define WXCDMAPPLIDESCRIPTIONPANEL_H_
 
 #include <creaWx.h>
-#include <wx/panel.h>
 #include <wx/hyperlink.h>
 
 #include "modelCDMAppli.h"
@@ -44,7 +43,7 @@
 /**
  * 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:
@@ -112,6 +111,11 @@ protected:
    * 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.
index 26c6ce0f124d3c8b00b05c469047d97e0d914766..5b63f239e3c2f1ae3a5beb28e67fe739fb299cfc 100644 (file)
@@ -50,6 +50,8 @@ EVT_BUTTON(ID_BUTTON_CREATE_FOLDER, wxCDMApplicationDescriptionPanel::OnBtnCreat
 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(
@@ -82,6 +84,9 @@ bool wxCDMApplicationDescriptionPanel::Create(
   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;
 }
 
@@ -143,6 +148,138 @@ void wxCDMApplicationDescriptionPanel::CreateControls()
   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"));
@@ -154,19 +291,19 @@ void wxCDMApplicationDescriptionPanel::CreateControls()
   //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."));
 
 
@@ -239,6 +376,22 @@ void wxCDMApplicationDescriptionPanel::OnBtnSetExeName(wxCommandEvent& event)
   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
index 741eb44e9c4d4aaffd7966291b580dc820a0aab6..d3117f8d0d34ac4bf96cc57a5473f28b0bcdf287 100644 (file)
@@ -36,7 +36,6 @@
 #define WXCDMAPPLICATIONDESCRIPTIONPANEL_H_
 
 #include <creaWx.h>
-#include <wx/panel.h>
 #include <wx/hyperlink.h>
 
 #include "modelCDMApplication.h"
@@ -44,7 +43,7 @@
 /**
  * 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:
@@ -118,8 +117,19 @@ protected:
 
   /**
    * 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.
    */
index 959d27a4adab7a256faa41b838771dd35ecfdeff..b694aee05b7c3b033917157b1424f2619e117b02 100644 (file)
@@ -78,9 +78,12 @@ bool wxCDMBlackBoxDescriptionPanel::Create(
     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;
 }
 
@@ -186,7 +189,7 @@ void wxCDMBlackBoxDescriptionPanel::CreateControls()
   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);
 
index 94d3071a422d9f7271d69e4a151618c57be6b1c5..fb0291ba24a1ab535c6b5920d9e5755775004cd0 100644 (file)
@@ -36,7 +36,6 @@
 #define WXCDMBLACKBOXDESCRIPTIONPANEL_H_
 
 #include <creaWx.h>
-#include <wx/panel.h>
 #include <wx/hyperlink.h>
 
 #include "modelCDMBlackBox.h"
@@ -44,7 +43,7 @@
 /**
  * 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:
index 07316246549510d940cad80819d97879080a7398..ea0d465b08fd266d7d2ce4e614e4f6c8b973fb47 100644 (file)
@@ -75,6 +75,9 @@ bool wxCDMCMakeListsDescriptionPanel::Create(
   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;
 }
 
index ac6f73ffd7c8217423610de3f221b895a934e0a4..e2ca8426dbd19de847ca558c0febc34542bc348a 100644 (file)
@@ -36,7 +36,6 @@
 #define WXCDMCMAKELISTSDESCRIPTIONPANEL_H_
 
 #include <creaWx.h>
-#include <wx/panel.h>
 #include <wx/hyperlink.h>
 
 #include "modelCDMCMakeListsFile.h"
@@ -44,7 +43,7 @@
 /**
  * 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:
index fac03fa10c5474b077157443b2266f9b7a85dd33..e99603acf523f1ff414da26d0118e3ea62bb3549 100644 (file)
@@ -77,6 +77,9 @@ bool wxCDMFileDescriptionPanel::Create(
   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;
 }
 
@@ -124,16 +127,16 @@ void wxCDMFileDescriptionPanel::CreateControls()
   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);
index 09cc1048f211391a72d0c9ac58c6549ffbed689c..8eee2eeeb8419877620a430b6bca8194e69a3cd7 100644 (file)
@@ -36,7 +36,6 @@
 #define WXCDMFILEDESCRIPTIONPANEL_H_
 
 #include <creaWx.h>
-#include <wx/panel.h>
 #include <wx/hyperlink.h>
 
 #include "modelCDMFile.h"
@@ -44,7 +43,7 @@
 /**
  * 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:
index 7acc023142a9a9f95da5fc01ebf7f7e53b08fb4b..2f1c18175ae3b78444c0b813e58d41b3096a3ecc 100644 (file)
@@ -78,6 +78,9 @@ bool wxCDMFolderDescriptionPanel::Create(
   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;
 }
 
index fafe66ed5cfd2985b3d25900cfa8a1369d7511b9..f06f0ce692052f62c118e5f38f078339e69ef02e 100644 (file)
@@ -36,7 +36,6 @@
 #define WXCDMFOLDERDESCRIPTIONPANEL_H_
 
 #include <creaWx.h>
-#include <wx/panel.h>
 #include <wx/hyperlink.h>
 
 #include "modelCDMFolder.h"
@@ -44,7 +43,7 @@
 /**
  * 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:
index d31dd06395c3b77557cd0b29570fa4ccb6137ee0..4dec780e7faf18e1cf673e4e15c6e088e3008d18 100644 (file)
@@ -47,6 +47,7 @@ EVT_HYPERLINK(ID_LINK_SELECT_LIBRARY, wxCDMLibDescriptionPanel::OnLnkLibrarySele
 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(
@@ -79,6 +80,9 @@ bool wxCDMLibDescriptionPanel::Create(
   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;
 }
 
@@ -118,23 +122,52 @@ void wxCDMLibDescriptionPanel::CreateControls()
   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);
 
@@ -150,12 +183,12 @@ void wxCDMLibDescriptionPanel::CreateControls()
   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);
 
@@ -229,6 +262,14 @@ void wxCDMLibDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
     }
 }
 
+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;
index 2483c9aaec3d299bc97ee23c7c6111fa683f4ad3..15c9ec49e9a1dbb9c97450f22f5aac7ec2b2b2ac 100644 (file)
@@ -36,7 +36,6 @@
 #define WXCDMLIBDESCRIPTIONPANEL_H_
 
 #include <creaWx.h>
-#include <wx/panel.h>
 #include <wx/hyperlink.h>
 
 #include "modelCDMLib.h"
@@ -44,7 +43,7 @@
 /**
  * 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:
@@ -115,6 +114,11 @@ protected:
    * 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.
index 4892b64a8c6cc3f71ca9d8a269eee6cf71125268..71f6d69374decb41000d5dcebb73c79a34e47de9 100644 (file)
@@ -49,6 +49,8 @@ EVT_BUTTON(ID_BUTTON_CREATE_CLASS, wxCDMLibraryDescriptionPanel::OnBtnCreateClas
 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(
@@ -81,6 +83,9 @@ bool wxCDMLibraryDescriptionPanel::Create(
   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;
 }
 
@@ -144,6 +149,139 @@ void wxCDMLibraryDescriptionPanel::CreateControls()
   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);
@@ -158,12 +296,12 @@ void wxCDMLibraryDescriptionPanel::CreateControls()
   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);
 
@@ -228,6 +366,22 @@ void wxCDMLibraryDescriptionPanel::OnBtnSetExeName(wxCommandEvent& event)
   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
index 724e4850135a83a9f4ee494cc7547b1d53592857..0fcc262c49f79c4d75a7e9af4e4e8d2bdac32497 100644 (file)
@@ -36,7 +36,6 @@
 #define WXCDMLIBRARYDESCRIPTIONPANEL_H_
 
 #include <creaWx.h>
-#include <wx/panel.h>
 #include <wx/hyperlink.h>
 
 #include "modelCDMLibrary.h"
@@ -44,7 +43,7 @@
 /**
  * Library description panel. Shows the available actions on the described library.
  */
-class wxCDMLibraryDescriptionPanel : public wxPanel
+class wxCDMLibraryDescriptionPanel : public wxScrolledWindow
 {
   DECLARE_EVENT_TABLE()
 public:
@@ -122,6 +121,16 @@ protected:
    * @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.
index d7f10aed26ef61fd6f3bebf402ecca8a7744247c..dbe66c116321f947e495993af7eb2e5942909713 100644 (file)
@@ -75,6 +75,11 @@ bool wxCDMMainDescriptionPanel::Create(
 {
   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;
 }
 
@@ -97,27 +102,28 @@ void wxCDMMainDescriptionPanel::CreateControls()
   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);
index fb0defaa7b1fac0d60af5fc83bfa4187e02a8616..08490f77a45c4141a4ead2cec04ad1159445ad1d 100644 (file)
 #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()
 
index 8aca7ba1dfdb015fbe91597379c3511582f90077..3b64a1e182cf118705ab70ef5c3ce968a04ccf56 100755 (executable)
@@ -40,7 +40,6 @@
 #include "wx/statline.h"
 #include "wx/config.h"
 #include "CDMUtilities.h"
-#include "images/CIcon64.xpm"
 
 #include "creaDevManagerIds.h"
 #include "wxCDMMainDescriptionPanel.h"
 
 
 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)
@@ -140,7 +145,6 @@ bool wxCDMMainFrame::Create(
 
   CreateMenus();
   CreateControls();
-  SetIcon(wxIcon(CIcon64));
   return TRUE;
 }
 
@@ -174,10 +178,40 @@ void wxCDMMainFrame::CreateMenus()
 {
   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();
@@ -248,7 +282,7 @@ void wxCDMMainFrame::CreateControls()
   );
 
   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);
@@ -256,6 +290,43 @@ void wxCDMMainFrame::CreateControls()
 }
 
 //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)
 {
@@ -267,7 +338,7 @@ void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
 
   if(userResponse == wxID_FORWARD)
     {
-      //create project
+      //close open project
       if(this->model->GetProject() != NULL)
         {
           if(!this->model->CloseProject(result))
@@ -277,6 +348,7 @@ void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
               event.Skip();
               return;
             }
+
           if(this->panel_Properties != NULL)
             {
               auiManager.DetachPane(this->panel_Properties);
@@ -290,7 +362,7 @@ void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
 
         }
 
-
+      //create project
       if(!this->model->CreateProject(
           crea::wx2std(dialog->GetProjectName()),
           crea::wx2std(dialog->GetProjectLocation()),
@@ -305,6 +377,18 @@ void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
           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)
         {
@@ -334,6 +418,104 @@ void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
          //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;
@@ -361,6 +543,7 @@ void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event)
               event.Skip();
               return;
             }
+
           if(this->panel_Properties != NULL)
             {
               auiManager.DetachPane(this->panel_Properties);
@@ -381,6 +564,17 @@ void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event)
           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
index b5180f16620b52065f9a59d531564f5430a8f344..3cacf8afbc168ec7f921d2acd81d0e17245e291e 100755 (executable)
@@ -125,6 +125,10 @@ protected:
 private:
 
   //Menus
+  /**
+   * Recently opened projects menu
+   */
+  wxMenu* menu_Recent;
   /**
    * File menu
    */
@@ -177,6 +181,13 @@ private:
 
   //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.
@@ -188,6 +199,11 @@ protected:
    * @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.
diff --git a/lib/creaDevManagerLib/wxCDMPackageConfigurationDialog.cpp b/lib/creaDevManagerLib/wxCDMPackageConfigurationDialog.cpp
new file mode 100644 (file)
index 0000000..2ab63a6
--- /dev/null
@@ -0,0 +1,239 @@
+/*
+# ---------------------------------------------------------------------
+#
+# 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());
+}
diff --git a/lib/creaDevManagerLib/wxCDMPackageConfigurationDialog.h b/lib/creaDevManagerLib/wxCDMPackageConfigurationDialog.h
new file mode 100644 (file)
index 0000000..a839430
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+# ---------------------------------------------------------------------
+#
+# 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_ */
index e2e452c0ae82a126cf657d17c2bc697067d89ebe..c736270ab93550b09ac1733dc8de971da2f5f621 100644 (file)
@@ -40,6 +40,7 @@
 #include "images/PkIcon64.xpm"
 
 #include "wxCDMNewBlackBoxDialog.h"
+#include "wxCDMPackageConfigurationDialog.h"
 #include <wx/textdlg.h>
 #include "CDMUtilities.h"
 
@@ -57,6 +58,7 @@ EVT_HYPERLINK(ID_LINK_SELECT_BLACKBOX, wxCDMPackageDescriptionPanel::OnLnkBlackB
 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(
@@ -86,9 +88,12 @@ bool wxCDMPackageDescriptionPanel::Create(
     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;
 }
 
@@ -215,12 +220,15 @@ void wxCDMPackageDescriptionPanel::CreateControls()
   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);
 
@@ -407,6 +415,14 @@ void wxCDMPackageDescriptionPanel::OnBtnCreateBlackBox(wxCommandEvent& event)
     }
 }
 
+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;
index 8e88f9a5b79a5690771639edaa5fd635f268e846..6e992bda4e56fa7c26293738073b03e6c0e9f6d2 100644 (file)
@@ -36,7 +36,6 @@
 #define WXCDMPACKAGEDESCRIPTIONPANEL_H_
 
 #include <creaWx.h>
-#include <wx/panel.h>
 #include <wx/hyperlink.h>
 
 #include "modelCDMPackage.h"
@@ -44,7 +43,7 @@
 /**
  * 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:
@@ -146,6 +145,10 @@ protected:
    * 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.
    */
index 543ac596fc53364f088baf6d3161d0649b21c828..d7a28be83fcd02f4e64d4289fc6c4b9ddf67fa99 100644 (file)
@@ -49,6 +49,7 @@ EVT_BUTTON(ID_BUTTON_CREATE_PACKAGE, wxCDMPackageManagerPanel::OnBtnCreatePackag
 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(
@@ -81,6 +82,9 @@ bool wxCDMPackageManagerPanel::Create(
   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;
 }
 
@@ -111,22 +115,54 @@ void wxCDMPackageManagerPanel::CreateControls()
   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);
@@ -142,7 +178,7 @@ void wxCDMPackageManagerPanel::CreateControls()
   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);
@@ -181,6 +217,14 @@ void wxCDMPackageManagerPanel::OnBtnReturn(wxHyperlinkEvent& event)
   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;
index 66a1d1c54228d390ed5420b5ec2a9fec1fd4f8fd..245ebf9640a774a2dd1a3e5c323d38935f505467 100644 (file)
@@ -36,7 +36,6 @@
 #define WXCDMPACKAGEMANAGERPANEL_H_
 
 #include <creaWx.h>
-#include <wx/panel.h>
 #include <wx/hyperlink.h>
 #include <wx/event.h>
 
@@ -45,7 +44,7 @@
 /**
  * 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:
@@ -119,6 +118,11 @@ protected:
    * @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.
index 0b33c8c311532189a2307eb194091ad78f5ad816..35a98be2edae555c1206e95872204c6e0dca11b9 100755 (executable)
@@ -77,8 +77,10 @@ bool wxCDMProjectActionsPanel::Create(
   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;
 }
index 93850e277860202f560ffab39f7b6a095c701087..cd60d7572395c466c02d32cb826de959a06b5fa8 100755 (executable)
 #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:
index 76aa9bbf99016d3f1ec30f77b2f780735cf14fdd..a6f121b7d02b26c624475e9c5260efd2b5b8a4e1 100644 (file)
@@ -49,6 +49,7 @@ EVT_BUTTON(ID_BUTTON_GOTO_LIB_MANAGER, wxCDMProjectDescriptionPanel::OnBtnManage
 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()
@@ -83,6 +84,9 @@ bool wxCDMProjectDescriptionPanel::Create(
   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;
 }
 
@@ -135,7 +139,7 @@ void wxCDMProjectDescriptionPanel::CreateControls()
   // 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);
@@ -143,11 +147,17 @@ void wxCDMProjectDescriptionPanel::CreateControls()
   // 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);
@@ -206,7 +216,7 @@ void wxCDMProjectDescriptionPanel::CreateControls()
       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);
@@ -303,8 +313,7 @@ void wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
     }
 }
 
-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())
@@ -316,8 +325,13 @@ wxCDMProjectDescriptionPanel::OnBtnSetBuildPath(wxCommandEvent& event)
   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))
index 86726c5dd1296b479776b341abffc827f2725f0a..d210e32ac2281dc941a888c27a1f01d9f5bc1bc0 100644 (file)
 #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:
@@ -145,6 +144,10 @@ protected:
    * 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.
    */