]> Creatis software - crea.git/blob - lib/creaDevManagerLib/wxCDMProjectStructureReportDialog.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / wxCDMProjectStructureReportDialog.cpp
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
5 #                        pour la Sant�)
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 #
10 #  This software is governed by the CeCILL-B license under French law and 
11 #  abiding by the rules of distribution of free software. You can  use, 
12 #  modify and/ or redistribute the software under the terms of the CeCILL-B 
13 #  license as circulated by CEA, CNRS and INRIA at the following URL 
14 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
15 #  or in the file LICENSE.txt.
16 #
17 #  As a counterpart to the access to the source code and  rights to copy,
18 #  modify and redistribute granted by the license, users are provided only
19 #  with a limited warranty  and the software's author,  the holder of the
20 #  economic rights,  and the successive licensors  have only  limited
21 #  liability. 
22 #
23 #  The fact that you are presently reading this means that you have had
24 #  knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ 
26  */
27
28
29 /*
30  * wxCDMProjectStructureReportDialog.cpp
31  *
32  *  Created on: 17/1/2013
33  *      Author: Daniel Felipe Gonzalez Obando
34  */
35
36 #include "wxCDMProjectStructureReportDialog.h"
37
38 #include "creaDevManagerIds.h"
39
40 #include <wx/html/htmlwin.h>
41 #include <vector>
42 #include "CDMUtilities.h"
43
44 BEGIN_EVENT_TABLE(wxCDMProjectStructureReportDialog, wxDialog)
45 EVT_BUTTON(ID_BUTTON_CANCEL, wxCDMProjectStructureReportDialog::OnFinish)
46 END_EVENT_TABLE()
47
48 wxCDMProjectStructureReportDialog::wxCDMProjectStructureReportDialog(
49     wxWindow* parent,
50     const std::map<std::string, bool>& properties,
51     wxWindowID id,
52     const wxString& caption,
53     const wxPoint& position,
54     const wxSize& size,
55     long style
56 )
57 {
58   this->properties = properties;
59   wxCDMProjectStructureReportDialog::Create(parent, id, caption, position, size, style);
60 }
61
62 wxCDMProjectStructureReportDialog::~wxCDMProjectStructureReportDialog()
63 {
64 }
65
66 bool wxCDMProjectStructureReportDialog::Create(
67     wxWindow* parent,
68     wxWindowID id,
69     const wxString& caption,
70     const wxPoint& position,
71     const wxSize& size,
72     long int style
73 )
74 {
75   wxDialog::Create(parent, id, caption, position, size, style);
76
77   this->CreateControls();
78
79   return TRUE;
80 }
81
82 void wxCDMProjectStructureReportDialog::CreateControls()
83 {
84
85   wxBoxSizer* v_sizer1 = new wxBoxSizer(wxVERTICAL);
86
87   wxHtmlWindow* htmlWindow = new wxHtmlWindow(this, wxID_ANY);
88   htmlWindow->SetPage(this->GetContent());
89   v_sizer1->Add(htmlWindow, 1, wxEXPAND);
90   v_sizer1->Add(new wxButton(this, ID_BUTTON_CANCEL, wxT("Close")),0,wxEXPAND);
91
92   SetSizer(v_sizer1);
93 }
94
95 void wxCDMProjectStructureReportDialog::OnFinish(wxCommandEvent& event)
96 {
97   this->EndDialog(wxID_CANCEL);
98 }
99
100 wxString wxCDMProjectStructureReportDialog::GetContent()
101 {
102   std::map<std::string, bool>::iterator it, it2;
103   std::map<std::string, bool> pkgs;
104   std::map<std::string, bool> libs;
105   std::map<std::string, bool> applis;
106   for (it = this->properties.begin(); it != this->properties.end(); it++)
107     {
108       std::cout << it->first << " " << it->second << std::endl;
109       if(it->first.substr(0,7) == "package")
110         {
111           std::vector<std::string> words;
112           CDMUtilities::splitter::split(words, it->first, " ", CDMUtilities::splitter::no_empties);
113           pkgs[words[1]] = true;
114         }
115       else if(it->first.substr(0,7) == "library")
116         {
117           std::vector<std::string> words;
118           CDMUtilities::splitter::split(words, it->first, " ", CDMUtilities::splitter::no_empties);
119           libs[words[1]] = true;
120         }
121       else if(it->first.substr(0,11) == "application")
122         {
123           std::vector<std::string> words;
124           CDMUtilities::splitter::split(words, it->first, " ", CDMUtilities::splitter::no_empties);
125           applis[words[1]] = true;
126         }
127     }
128   std::string report = "";
129   report +=
130       "<html>"
131       "<head>"
132       "  <title>Project Structure Check Report</title>"
133       "</head>"
134       "<body>"
135       "  <h1>Project Structure Check Report</h1>"
136       "  <div id=\"projectChk\">"
137       "    <h3>Project CMakeLists.txt</h3>"
138       "    <p>"
139       "      Includes the following built-in libraries:"
140       "      <font color=\"#00CC00\"><ul>";
141   if(this->properties["project set USE_CREA"])
142     report +=
143         "        <li>Crea</li>";
144   if(this->properties["project set USE_GDCM"])
145     report +=
146         "        <li>GDCM</li>";
147   if(this->properties["project set USE_GDCM_VTK"])
148     report +=
149         "        <li>GDCM_VTK</li>";
150   if(this->properties["project set USE_GDCM2"])
151     report +=
152         "        <li>GDCM2</li>";
153   if(this->properties["project set USE_WXWIDGETS"])
154     report +=
155         "        <li>wxWidgets</li>";
156   if(this->properties["project set USE_KWWIDGETS"])
157     report +=
158         "        <li>kwWidgets</li>";
159   if(this->properties["project set USE_VTK"])
160     report +=
161         "        <li>VTK</li>";
162   if(this->properties["project set USE_ITK"])
163     report +=
164         "        <li>ITK</li>";
165   if(this->properties["project set USE_BOOST"])
166     report +=
167         "        <li>Boost</li>";
168   report+=
169       "      </ul></font>"
170       "    </p>"
171       "    <p>"
172       "      Doesn't include the following built-in libraries:"
173       "      <font color=\"#AAAA00\"><ul>";
174   if(!this->properties["project set USE_CREA"])
175     report +=
176         "        <li>Crea</li>";
177   if(!this->properties["project set USE_GDCM"])
178     report +=
179         "        <li>GDCM</li>";
180   if(!this->properties["project set USE_GDCM_VTK"])
181     report +=
182         "        <li>GDCM_VTK</li>";
183   if(!this->properties["project set USE_GDCM2"])
184     report +=
185         "        <li>GDCM2</li>";
186   if(!this->properties["project set USE_WXWIDGETS"])
187     report +=
188         "        <li>wxWidgets</li>";
189   if(!this->properties["project set USE_KWWIDGETS"])
190     report +=
191         "        <li>kwWidgets</li>";
192   if(!this->properties["project set USE_VTK"])
193     report +=
194         "        <li>VTK</li>";
195   if(!this->properties["project set USE_ITK"])
196     report +=
197         "        <li>ITK</li>";
198   if(!this->properties["project set USE_BOOST"])
199     report +=
200         "        <li>Boost</li>";
201   report+=
202       "      </ul></font>"
203       "    </p>"
204       "    <p>"
205       "      Includes:"
206       "      <font color=\"#00CC00\"><ul>";
207   if(this->properties["project add lib"])
208     report +=
209         "        <li>Lib</li>";
210   if(this->properties["project add appli"])
211     report +=
212         "        <li>Appli</li>";
213   for (it = this->properties.begin(); it != this->properties.end(); it++)
214     {
215       if(it->second == true && it->first.substr(0,11) == "project add")
216         {
217           std::string namePkg = it->first.substr(12);
218           if (namePkg.substr(0,4) == "bbtk")
219             report +=
220                 "        <li>Package " + namePkg + "</li>";
221         }
222     }
223   report+=
224       "      </ul></font>"
225       "    </p>"
226       "    <p>Doesn't include:"
227       "      <font color=\"#FF0000\"><ul>";
228   if(!this->properties["project add lib"])
229     report +=
230         "        <li >"
231         "          Lib: use"
232         "          <blockquote>ADD_SUBDIRECTORY(lib)</blockquote>"
233         "          in the project CMakeLists file."
234         "        </li>";
235   if(!this->properties["project add appli"])
236     report +=
237         "        <li>"
238         "          Appli: use"
239         "          <blockquote>ADD_SUBDIRECTORY(appli)</blockquote>"
240         "          in the project CMakeLists file."
241         "        </li>";
242   for (it = this->properties.begin(); it != this->properties.end(); it++)
243     {
244       if(it->second == false && it->first.substr(0,11) == "project add")
245         {
246           std::string namePkg = it->first.substr(12);
247           report +=
248               "        <li>"
249               "          Package \"" + namePkg + "\": use"
250               "          <blockquote>ADD_SUBDIRECTORY(" + namePkg + ")</blockquote>"
251               "          in the project CMakeLists file."
252               "        </li>";
253         }
254     }
255   report+=
256       "      </ul></font>"
257       "    </p>"
258       "  </div>";
259
260   for (it = pkgs.begin(); it != pkgs.end(); it++)
261     {
262       report +=
263           "  <div id=\"package" + it->first + "Chk\">"
264           "    <h3>Package " + it->first + " CMakeLists.txt</h3>"
265           "    <p>"
266           "      Includes the following built-in libraries:"
267           "      <font color=\"#00CC00\"><ul>";
268       if(this->properties["package " + it->first + " set USE_VTK"])
269         report +=
270             "        <li>VTK</li>";
271       if(this->properties["package " + it->first + " set USE_ITK"])
272         report +=
273             "        <li>ITK</li>";
274       if(this->properties["package " + it->first + " set USE_GDCM"])
275         report +=
276             "        <li>GDCM</li>";
277       if(this->properties["package " + it->first + " set USE_GDC_VTK"])
278         report +=
279             "        <li>GDCM_VTK</li>";
280       if(this->properties["package " + it->first + " set USE_GSMIS"])
281         report +=
282             "        <li>GSMIS</li>";
283       if(this->properties["package " + it->first + " set USE_WXWIDGETS"])
284         report +=
285             "        <li>wxWidgets</li>";
286       if(this->properties["package " + it->first + " set USE_KWWIDGETS"])
287         report +=
288             "        <li>kwWidgets</li>";
289       report +=
290           "      </ul></font>"
291           "    </p>"
292           "    <p>"
293           "      Doesn't include the following built-in libraries:"
294           "      <font color=\"#AAAA00\"><ul>";
295       if(!this->properties["package " + it->first + " set USE_VTK"])
296         report +=
297             "        <li>VTK</li>";
298       if(!this->properties["package " + it->first + " set USE_ITK"])
299         report +=
300             "        <li>ITK</li>";
301       if(!this->properties["package " + it->first + " set USE_GDCM"])
302         report +=
303             "        <li>GDCM</li>";
304       if(!this->properties["package " + it->first + " set USE_GDC_VTK"])
305         report +=
306             "        <li>GDCM_VTK</li>";
307       if(!this->properties["package " + it->first + " set USE_GSMIS"])
308         report +=
309             "        <li>GSMIS</li>";
310       if(!this->properties["package " + it->first + " set USE_WXWIDGETS"])
311         report +=
312             "        <li>wxWidgets</li>";
313       if(!this->properties["package " + it->first + " set USE_KWWIDGETS"])
314         report +=
315             "        <li>kwWidgets</li>";
316       report +=
317           "      </ul></font>"
318           "    </p>"
319           "    <p>"
320           "      Includes the following additional directories:"
321           "      <font color=\"#00CC00\"><ul>";
322       for (it2 = this->properties.begin(); it2 != this->properties.end(); it2++)
323         {
324           std::string pkgname = "package " + it->first + " dir";
325           if(it2->first.substr(0,pkgname.size()) == pkgname)
326             {
327               std::string directoryName = it2->first.substr(pkgname.size()+1);
328               report +=
329                   "        <li>" + directoryName + "</li>";
330             }
331         }
332       report +=
333           "      </ul></font>"
334           "    </p>"
335           "    <p>"
336           "      Includes the following libraries:"
337           "      <font color=\"#00CC00\"><ul>";
338       for (it2 = this->properties.begin(); it2 != this->properties.end(); it2++)
339         {
340           std::string pkgname = "package " + it->first + " lib";
341           if(it2->first.substr(0,pkgname.size()) == pkgname)
342             {
343               std::string libraryName = it2->first.substr(pkgname.size()+1);
344               report +=
345                   "        <li>" + libraryName + "</li>";
346             }
347         }
348       report +=
349           "      </ul></font>"
350           "    </p>"
351           "    <p>"
352           "      <strong>Note:</strong><br>"
353           "      Please include the following lines in the package CMakeLists file in order to add a library:<br>"
354           "          - In section <strong>SET(${BBTK_PACKAGE_NAME}_INCLUDE_DIRS</strong> use:"
355           "          <blockquote>"
356           "            ../lib/[libraryFolderName]"
357           "          </blockquote>"
358           "          - In section <strong>SET(${BBTK_PACKAGE_NAME}_LIBS</strong> use:"
359           "          <blockquote>"
360           "            [libraryName]"
361           "          </blockquote>"
362           "    </p>"
363           "  </div>";
364     }
365   report +=
366       "  <div id=\"libChk\">"
367       "    <h3>Lib CMakeLists.txt</h3>"
368       "    <p>"
369       "      Includes libraries:"
370       "      <font color=\"#00CC00\"><ul>";
371   for (it = this->properties.begin(); it != this->properties.end(); it++)
372     {
373       if(it->second == true && it->first.substr(0, 7) == "lib add")
374         {
375           std::string nameLib = it->first.substr(8);
376           report +=
377               "        <li>" + nameLib + "</li>";
378         }
379     }
380   report +=
381       "      </ul></font>"
382       "    </p>"
383       "    <p>Doesn't include libraries:"
384       "      <font color=\"#FF0000\"><ul>";
385   for (it = this->properties.begin(); it != this->properties.end(); it++)
386     {
387       if(it->second == false && it->first.substr(0, 7) == "lib add")
388         {
389           std::string nameLib = it->first.substr(8);
390           report +=
391               "        <li>" + nameLib + "</li>";
392         }
393     }
394   report +=
395       "      </ul></font>"
396       "    </p>"
397       "    <p>"
398       "      <strong>Note:</strong><br>"
399       "      Please include the following lines in the lib CMakeLists file in order to add a library:"
400       "          <blockquote>ADD_SUBDIRECTORY([libraryName])</blockquote>"
401       "    </p>"
402       "  </div>";
403   for (it = libs.begin(); it != libs.end(); it++)
404     {
405       report +=
406           "  <div id=\"library" + it->first + "Chk\">"
407           "    <h3>Library " + it->first + " CMakeLists.txt</h3>"
408           "    <p>"
409           "      Includes the following libraries:"
410           "      <font color=\"#00CC00\"><ul>";
411       for (it2 = this->properties.begin(); it2 != this->properties.end(); it2++)
412         {
413           std::string libname = "library " + it->first + " lib";
414           if(it2->second == true && it2->first.substr(0,libname.size()) == libname)
415             {
416               std::string libraryName = it2->first.substr(libname.size()+1);
417               report +=
418                   "        <li>" + libraryName + "</li>";
419             }
420         }
421       report +=
422           "      </ul></font>"
423           "    </p>"
424           "    <p>"
425           "      Doesn't include the following libraries:"
426           "      <font color=\"#AAAA00\"><ul>";
427       for (it2 = this->properties.begin(); it2 != this->properties.end(); it2++)
428         {
429           std::string libname = "library " + it->first + " lib";
430           if(it2->second == false && it2->first.substr(0,libname.size()) == libname)
431             {
432               std::string libraryName = it2->first.substr(libname.size()+1);
433               report +=
434                   "        <li>" + libraryName + "</li>";
435             }
436         }
437       report +=
438           "      </ul></font>"
439           "    </p>"
440           "    <p>"
441           "      <strong>Note:</strong><br>"
442           "      Please include the following line in the library CMakeLists file in order to add a library:"
443           "          <blockquote>[libraryName]</blockquote>"
444           "      on <strong>SET ( ${LIBRARY_NAME}_LINK_LIBRARIES</strong> section if needed."
445           "    </p>"
446           "  </div>";
447     }
448   report +=
449       "  <div id=\"appliChk\">"
450       "    <h3>Appli CMakeLists.txt</h3>"
451       "    <p>"
452       "      Includes applications:"
453       "      <font color=\"#00CC00\"><ul>";
454   for (it = this->properties.begin(); it != this->properties.end(); it++)
455     {
456       if(it->second == true && it->first.substr(0, 9) == "appli add")
457         {
458           std::string nameAppli = it->first.substr(10);
459           report +=
460               "        <li>" + nameAppli + "</li>";
461         }
462     }
463   report +=
464       "      </ul></font>"
465       "    </p>"
466       "    <p>Doesn't include applications:"
467       "      <font color=\"#FF0000\"><ul>";
468   for (it = this->properties.begin(); it != this->properties.end(); it++)
469     {
470       if(it->second == false && it->first.substr(0, 9) == "appli add")
471         {
472           std::string nameAppli = it->first.substr(10);
473           report +=
474               "        <li>" + nameAppli + "</li>";
475         }
476     }
477   report +=
478       "      </ul></font>"
479       "    </p>"
480       "    <p>"
481       "      <strong>Note:</strong><br>"
482       "      Please include the following lines in the appli CMakeLists file in order to add an application:"
483       "          <blockquote>ADD_SUBDIRECTORY([applicationName])</blockquote>"
484       "    </p>"
485       "  </div>";
486   for (it = applis.begin(); it != applis.end(); it++)
487     {
488       report +=
489           "  <div id=\"application" + it->first + "Chk\">"
490           "    <h3>Application " + it->first + " CMakeLists.txt</h3>"
491           "    <p>"
492           "      Includes the following libraries:"
493           "      <font color=\"#00CC00\"><ul>";
494       for (it2 = this->properties.begin(); it2 != this->properties.end(); it2++)
495         {
496           std::string appliname = "application " + it->first + " dir";
497           if(it2->second && it2->first.substr(0,appliname.size()) == appliname)
498             {
499               std::string directoryName = it2->first.substr(appliname.size()+1);
500               report +=
501                   "        <li>" + directoryName + "</li>";
502             }
503         }
504       report +=
505           "      </ul></font>"
506           "    </p>"
507           "    <p>"
508           "      Includes the following libraries:"
509           "      <font color=\"#00CC00\"><ul>";
510       for (it2 = this->properties.begin(); it2 != this->properties.end(); it2++)
511         {
512           std::string appliname = "application " + it->first + " lib";
513           if(it2->second && it2->first.substr(0,appliname.size()) == appliname)
514             {
515               std::string libraryName = it2->first.substr(appliname.size()+1);
516               report +=
517                   "        <li>" + libraryName + "</li>";
518             }
519         }
520       report +=
521           "      </ul></font>"
522           "    </p>"
523           "    <p>"
524           "      Doesn't include the following libraries:"
525           "      <font color=\"#AAAA00\"><ul>";
526       for (it2 = this->properties.begin(); it2 != this->properties.end(); it2++)
527         {
528           std::string appliname = "application " + it->first + " lib";
529           if(it2->second == false && it2->first.substr(0,appliname.size()) == appliname)
530             {
531               std::string libraryName = it2->first.substr(appliname.size()+1);
532               report +=
533                   "        <li>" + libraryName + "</li>";
534             }
535         }
536       report +=
537           "      </ul></font>"
538           "    </p>"
539           "    <p>"
540           "      <strong>Note:</strong><br>"
541           "      Please include the following lines in the application CMakeLists file in order to add a library:<br>"
542           "          - In section <strong>INCLUDE_DIRECTORIES(</strong> use:"
543           "          <blockquote>"
544           "            ../lib/[libraryFolderName]"
545           "          </blockquote>"
546           "          - In section <strong>SET(${EXE_NAME}_LINK_LIBRARIES</strong> use:"
547           "          <blockquote>"
548           "            [libraryName]"
549           "          </blockquote>"
550           "    </p>"
551           "  </div>";
552     }
553   report +=
554       "</body>"
555       "</html>"
556       ;
557   return crea::std2wx(report);
558 }