]> Creatis software - crea.git/blob - lib/creaDevManagerLib/wxCDMProjectActionsPanel.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / wxCDMProjectActionsPanel.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 #
8 #  This software is governed by the CeCILL-B license under French law and 
9 #  abiding by the rules of distribution of free software. You can  use, 
10 #  modify and/ or redistribute the software under the terms of the CeCILL-B 
11 #  license as circulated by CEA, CNRS and INRIA at the following URL 
12 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
13 #  or in the file LICENSE.txt.
14 #
15 #  As a counterpart to the access to the source code and  rights to copy,
16 #  modify and redistribute granted by the license, users are provided only
17 #  with a limited warranty  and the software's author,  the holder of the
18 #  economic rights,  and the successive licensors  have only  limited
19 #  liability. 
20 #
21 #  The fact that you are presently reading this means that you have had
22 #  knowledge of the CeCILL-B license and that you accept its terms.
23 # ------------------------------------------------------------------------ 
24  */
25
26
27 /*
28  * wxCDMProjectActionsPanel.cpp
29  *
30  *  Created on: 25/10/2012
31  *      Author: Daniel Felipe Gonzalez Obando
32  */
33
34 #include "wxCDMProjectActionsPanel.h"
35
36 #include <wx/progdlg.h>
37
38 #include "creaDevManagerIds.h"
39
40 BEGIN_EVENT_TABLE(wxCDMProjectActionsPanel, wxPanel)
41 EVT_BUTTON(ID_BUTTON_BUILD_PROJECT, wxCDMProjectActionsPanel::OnBtnBuildProject)
42 EVT_BUTTON(ID_BUTTON_CONFIGURE_BUILD, wxCDMProjectActionsPanel::OnBtnConfigureBuild)
43 EVT_BUTTON(ID_BUTTON_CONNECT_PROJECT, wxCDMProjectActionsPanel::OnBtnConnectProject)
44 END_EVENT_TABLE()
45
46 wxCDMProjectActionsPanel::wxCDMProjectActionsPanel(
47     wxWindow* parent,
48     modelCDMProject* project,
49     wxWindowID id,
50     const wxString& caption,
51     const wxPoint& pos,
52     const wxSize& size,
53     long style
54 )
55 {
56   wxCDMProjectActionsPanel::Create(parent,id,caption,pos,size,style);
57   this->project = project;
58 }
59
60 wxCDMProjectActionsPanel::~wxCDMProjectActionsPanel()
61 {
62 }
63
64 bool wxCDMProjectActionsPanel::Create(
65     wxWindow* parent,
66     wxWindowID id,
67     const wxString& caption,
68     const wxPoint& pos,
69     const wxSize& size,
70     long style
71 )
72 {
73   wxPanel::Create(parent,id,pos,size,style);
74   wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
75   this->SetSizer(sizer);
76
77   CreateControls();
78
79   return TRUE;
80 }
81
82 void wxCDMProjectActionsPanel::CreateControls()
83 {
84   wxButton* configurebt = new wxButton(this, ID_BUTTON_CONFIGURE_BUILD, _T("1. Configure Project (CMake)"));
85   configurebt->SetToolTip(wxT("This is the first step in order to execute the project. Make sure you have selected the desired Build location."));
86   wxButton* compilebt = new wxButton(this, ID_BUTTON_BUILD_PROJECT, _T("2. Compile Project"));
87   compilebt->SetToolTip(wxT("This step should be done after configuring the project. This will create the executables."));
88   wxButton* plugbt = new wxButton(this, ID_BUTTON_CONNECT_PROJECT, _T("3. Plug Packages (BBTK)"));
89   plugbt->SetToolTip(wxT("This step should be done after compiling the project. This will allow to use the boxes in this project to be available in the bbEditor."));
90   this->GetSizer()->Add(configurebt, 0, wxALL, 5);
91   this->GetSizer()->Add(compilebt, 0, wxALL, 5);
92   this->GetSizer()->Add(plugbt, 0, wxALL, 5);
93 }
94
95 //configure project
96 void wxCDMProjectActionsPanel::OnBtnConfigureBuild(wxCommandEvent& event)
97 {
98   std::string* result;
99   if(!this->project->ConfigureBuild(result))
100     {
101       wxMessageBox(crea::std2wx(result->c_str()), wxT("Project Configuration - Error!"));
102       return;
103     }
104   wxMessageBox(crea::std2wx("The configuration was executed successfully."), wxT("Project Configuration"));
105 }
106
107 //compile project
108 void wxCDMProjectActionsPanel::OnBtnBuildProject(wxCommandEvent& event)
109 {
110   std::string* result;
111   //wxProgressDialog* loadBar = new wxProgressDialog(wxT("Compiling"), wxT("Please wait while the compilation is executing..."), 100, this);
112   //loadBar->Pulse();
113   if(!this->project->Build(result))
114     {
115       //loadBar->Destroy();
116       wxMessageBox(crea::std2wx(result->c_str()), wxT("Project Compilation - Error!"));
117       return;
118     }
119   //loadBar->Destroy();
120   wxMessageBox(crea::std2wx("The compilation was executed successfully. Please check the \"building.log\" file located in the build folder to check the compilation result."), wxT("Project Compilation"));
121 }
122
123 //plug packages
124 void wxCDMProjectActionsPanel::OnBtnConnectProject(wxCommandEvent& event)
125 {
126   std::string* result;
127   if(!this->project->Connect(result))
128       {
129         wxMessageBox(crea::std2wx(result->c_str()), wxT("Plug Packages - Error!"));
130         return;
131       }
132     wxMessageBox(crea::std2wx("The connection was executed successfully. Please check the \"plugging.log\" file located in the build folder to check the compilation result."), wxT("Plug Package"));
133 }