2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
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.
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
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 # ------------------------------------------------------------------------
28 * wxCDMProjectActionsPanel.cpp
30 * Created on: 25/10/2012
31 * Author: Daniel Felipe Gonzalez Obando
34 #include "wxCDMProjectActionsPanel.h"
36 #include <wx/progdlg.h>
38 #include "creaDevManagerIds.h"
41 #include "wxCDMProjectStructureReportDialog.h"
43 BEGIN_EVENT_TABLE(wxCDMProjectActionsPanel, wxPanel)
44 EVT_BUTTON(ID_BUTTON_CHECK_PROJECT, wxCDMProjectActionsPanel::OnBtnCheckProjectStructure)
45 EVT_BUTTON(ID_BUTTON_BUILD_PROJECT, wxCDMProjectActionsPanel::OnBtnBuildProject)
46 EVT_BUTTON(ID_BUTTON_CONFIGURE_BUILD, wxCDMProjectActionsPanel::OnBtnConfigureBuild)
47 EVT_BUTTON(ID_BUTTON_CONNECT_PROJECT, wxCDMProjectActionsPanel::OnBtnConnectProject)
50 wxCDMProjectActionsPanel::wxCDMProjectActionsPanel(
52 modelCDMProject* project,
54 const wxString& caption,
60 wxCDMProjectActionsPanel::Create(parent,id,caption,pos,size,style);
61 this->project = project;
64 wxCDMProjectActionsPanel::~wxCDMProjectActionsPanel()
68 bool wxCDMProjectActionsPanel::Create(
71 const wxString& caption,
77 wxPanel::Create(parent,id,pos,size,style);
78 // this part makes the scrollbars show up
79 this->FitInside(); // ask the sizer about the needed size
80 this->SetScrollRate(5, 5);
82 wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
83 this->SetSizer(sizer);
90 void wxCDMProjectActionsPanel::CreateControls()
92 wxButton* checkStructbt = new wxButton(this, ID_BUTTON_CHECK_PROJECT, _T("1. Check Project Structure"));
93 checkStructbt->SetToolTip(wxT("This step checks the project structure and tells what is going to be compiled."));
94 wxButton* configurebt = new wxButton(this, ID_BUTTON_CONFIGURE_BUILD, _T("2. Configure Project (CMake)"));
95 configurebt->SetToolTip(wxT("This is the second step in order to execute the project. Make sure you have selected the desired Build location."));
96 wxButton* compilebt = new wxButton(this, ID_BUTTON_BUILD_PROJECT, _T("3. Compile Project"));
97 compilebt->SetToolTip(wxT("This step should be done after configuring the project. This will create the executables."));
98 wxButton* plugbt = new wxButton(this, ID_BUTTON_CONNECT_PROJECT, _T("4. Plug Packages (BBTK)"));
99 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."));
100 this->GetSizer()->Add(checkStructbt, 0, wxALL, 5);
101 this->GetSizer()->Add(configurebt, 0, wxALL, 5);
102 this->GetSizer()->Add(compilebt, 0, wxALL, 5);
103 this->GetSizer()->Add(plugbt, 0, wxALL, 5);
106 //check project structure
107 void wxCDMProjectActionsPanel::OnBtnCheckProjectStructure(wxCommandEvent& event)
109 std::map<std::string, bool> prjStruct;
110 this->project->CheckStructure(prjStruct);
111 std::cout << prjStruct.size() << std::endl;
112 wxCDMProjectStructureReportDialog* structure = new wxCDMProjectStructureReportDialog(this->GetParent(), prjStruct, wxID_ANY);
113 structure->Show(true);
117 void wxCDMProjectActionsPanel::OnBtnConfigureBuild(wxCommandEvent& event)
120 if(!this->project->ConfigureBuild(result))
122 wxMessageBox(crea::std2wx(result->c_str()), wxT("Project Configuration - Error!"));
125 wxMessageBox(crea::std2wx("The configuration was executed successfully."), wxT("Project Configuration"));
129 void wxCDMProjectActionsPanel::OnBtnBuildProject(wxCommandEvent& event)
133 if(!this->project->Build(result, ""))
135 wxMessageBox(crea::std2wx(result->c_str()), wxT("Project Compilation - Error!"));
139 //get author from user
140 wxTextEntryDialog* buildDlg = new wxTextEntryDialog(
142 wxT("Enter the compilation instruction:"),
143 wxT("Project Compilation- creaDevManager"),
144 crea::std2wx(this->project->GetBuildInstruction()),
145 wxTE_MULTILINE | wxOK | wxCANCEL
148 if (buildDlg->ShowModal() == wxID_OK)
150 std::string buildDlgStr = crea::wx2std(buildDlg->GetValue());
152 if (buildDlgStr != "")
155 //wxProgressDialog* loadBar = new wxProgressDialog(wxT("Compiling"), wxT("Please wait while the compilation is executing..."), 100, this);
157 if(!this->project->Build(result, buildDlgStr))
159 //loadBar->Destroy();
160 wxMessageBox(crea::std2wx(result->c_str()), wxT("Project Compilation - Error!"));
163 //loadBar->Destroy();
164 //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"));
170 void wxCDMProjectActionsPanel::OnBtnConnectProject(wxCommandEvent& event)
173 int isDir = wxMessageBox(crea::std2wx("Is this the path of the project compilation to plug?:\n"+this->project->GetBuildPath()), wxT("Plug BBTK Packages"), wxYES_NO|wxCANCEL);
174 if(isDir != wxCANCEL)
176 wxString file = crea::std2wx(this->project->GetBuildPath());
179 file = wxDirSelector(
180 wxT("Please select the folder containing the bbtkPackage file you want to use. Usually it is where you built your project."),
181 crea::std2wx(this->project->GetBuildPath())
187 if(!this->project->Connect(result, crea::wx2std(file)))
189 wxMessageBox(crea::std2wx(result->c_str()), wxT("Plug BBTK Packages - Error!"), wxICON_ERROR);
194 wxMessageBox(crea::std2wx("The connection was executed successfully. Please check the console to see the compilation result.\n Also, don't forget to restart the BBTK Graphical Editor (if already opened) to see the plugged packages."), wxT("Plug Package"));