2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------
30 * wxCreaDevManagerTreeCtrl.cpp
32 * Created on: 19/10/2012
33 * Author: Daniel Felipe Gonzalez Obando
36 #include "wxCDMProjectsTreeCtrl.h"
41 #include <wx/imaglist.h>
43 #include "creaDevManagerIds.h"
44 #include "images/AIcon20.xpm"
45 #include "images/ApIcon20.xpm"
46 #include "images/BBIcon20.xpm"
47 #include "images/BBSIcon20.xpm"
48 #include "images/BBGIcon20.xpm"
49 #include "images/CIcon20.xpm"
50 #include "images/CFIcon20.xpm"
51 #include "images/CMIcon20.xpm"
52 #include "images/FdIcon20.xpm"
53 #include "images/FlIcon20.xpm"
54 #include "images/LbIcon20.xpm"
55 #include "images/LIcon20.xpm"
56 #include "images/PrIcon20.xpm"
57 #include "images/PkIcon20.xpm"
59 wxCDMProjectsTreeCtrl::wxCDMProjectsTreeCtrl(
65 const wxValidator &validator,
69 wxCDMProjectsTreeCtrl::Create(parent, id, pos, size, style, validator, name);
72 wxCDMProjectsTreeCtrl::~wxCDMProjectsTreeCtrl()
76 bool wxCDMProjectsTreeCtrl::Create(
82 const wxValidator &validator,
86 wxTreeCtrl::Create (parent, id, pos, size, style, validator, name);
88 this->DeleteAllItems();
90 wxImageList* images = new wxImageList(20, 20, true);
91 this->ID_AIcon = images->Add(wxIcon(AIcon20));
92 this->ID_ApIcon = images->Add(wxIcon(ApIcon20));
93 this->ID_BBIcon = images->Add(wxIcon(BBIcon20));
94 this->ID_BBGIcon = images->Add(wxIcon(BBGIcon20));
95 this->ID_BBSIcon = images->Add(wxIcon(BBSIcon20));
96 this->ID_Cicon = images->Add(wxIcon(CIcon20));
97 this->ID_CMIcon = images->Add(wxIcon(CMIcon20));
98 this->ID_FdIcon = images->Add(wxIcon(FdIcon20));
99 this->ID_FlIcon = images->Add(wxIcon(FlIcon20));
100 this->ID_CFIcon = images->Add(wxIcon(CFIcon20));
101 this->ID_LbIcon = images->Add(wxIcon(LbIcon20));
102 this->ID_LIcon = images->Add(wxIcon(LIcon20));
103 this->ID_PrIcon = images->Add(wxIcon(PrIcon20));
104 this->ID_PkIcon = images->Add(wxIcon(PkIcon20));
105 this->AssignImageList(images);
107 wxTreeItemId rootIndex = this->AddRoot(wxT("No Open Project"), this->ID_Cicon, this->ID_Cicon);
113 void wxCDMProjectsTreeCtrl::BuildTree(std::map< wxCDMTreeItemId, modelCDMIProjectTreeNode* >& modelElements, modelCDMProject* projectTree)
116 std::cout << "building tree" << std::endl;
117 this->DeleteAllItems();
118 modelElements.clear();
119 if(projectTree != NULL)
121 projectTree->SetId(this->AddRoot(crea::std2wx(projectTree->GetName()), this->ID_PrIcon));
123 modelElements[projectTree->GetId()] = projectTree;
125 std::cout << "Building TreeCtrl for " << projectTree->GetName() << std::endl;
126 this->BuildTree(projectTree->GetChildren(), modelElements, projectTree->GetId());
128 this->Expand(projectTree->GetId().GetWxId());
134 wxTreeItemId rootIndex = this-> AddRoot(_("No Open Project"), this->ID_Cicon);
138 void wxCDMProjectsTreeCtrl::BuildTree(const std::vector<modelCDMIProjectTreeNode*>& treeNodes, std::map< wxCDMTreeItemId, modelCDMIProjectTreeNode* >& modelElements, const wxCDMTreeItemId& parent)
140 for (int i = 0; i < (int)(treeNodes.size()); i++)
142 //cout << projectsTree[i].GetName() << endl;
143 if(treeNodes[i] != NULL)
145 int idIcon = GetIconId(treeNodes[i]);
146 wxString nodeName((treeNodes[i]->GetName()).c_str(), wxConvUTF8);
147 treeNodes[i]->SetId(wxCDMTreeItemId(this->AppendItem(parent.GetWxId(), nodeName, idIcon)));
149 modelElements[treeNodes[i]->GetId()] = treeNodes[i];
151 std::vector<modelCDMIProjectTreeNode*> innerChildren = treeNodes[i]->GetChildren();
152 if(innerChildren.size() > 0)
154 this->BuildTree(innerChildren, modelElements, treeNodes[i]->GetId());
161 int wxCDMProjectsTreeCtrl::GetIconId(modelCDMIProjectTreeNode* node)
163 modelCDMIProjectTreeNode* element = dynamic_cast<modelCDMProject*>(node);
166 return this->ID_PrIcon;
170 element = dynamic_cast<modelCDMAppli*>(node);
173 return this->ID_ApIcon;
177 element = dynamic_cast<modelCDMApplication*>(node);
180 return this->ID_AIcon;
184 element = dynamic_cast<modelCDMLib*>(node);
187 return this->ID_LbIcon;
191 element = dynamic_cast<modelCDMLibrary*>(node);
194 return this->ID_LIcon;
198 element = dynamic_cast<modelCDMPackage*>(node);
201 return this->ID_PkIcon;
205 element = dynamic_cast<modelCDMBlackBox*>(node);
208 return this->ID_BBIcon;
212 element = dynamic_cast<modelCDMCMakeListsFile*>(node);
215 return this->ID_CMIcon;
219 element = dynamic_cast<modelCDMCodeFile*>(node);
222 return this->ID_CFIcon;
226 element = dynamic_cast<modelCDMBBSFile*>(node);
229 return this->ID_BBSIcon;
233 element = dynamic_cast<modelCDMBBGFile*>(node);
236 return this->ID_BBGIcon;
240 element = dynamic_cast<modelCDMFolder*>(node);
243 return this->ID_FdIcon;
247 element = dynamic_cast<modelCDMFile*>(node);
250 return this->ID_FlIcon;
254 return this->ID_Cicon;