1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
27 * @file buttonContainerSettings.cxx
28 * @brief Implements the ButtonContainerSettings class.
29 * @author Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr)
33 #include "buttonContainerSettings.h"
35 namespace creaPanelButtonContainer
37 // ----------------------------------------------------------------------------------
38 ButtonContainerSettings::ButtonContainerSettings( )
42 // ----------------------------------------------------------------------------------
43 ButtonContainerSettings::~ButtonContainerSettings( )
47 // ----------------------------------------------------------------------------------
48 ButtonContainerSettings::ButtonGroupMap
49 ButtonContainerSettings::GetButtonGroupContainer( )
51 std::cout<< "MLER | ButtonContainerSettings:: GetButtonGroupContainer( ) " << std::endl;
52 return m_ButtonGroupContainer;
54 // ----------------------------------------------------------------------------------
55 ButtonContainerSettings::KeyMapList
56 ButtonContainerSettings::GetGroupNameList( )
58 std::cout<< "MLER | ButtonContainerSettings:: GetGroupNameList( ) " << std::endl;
59 return m_GroupNameList;
61 // ----------------------------------------------------------------------------------
62 //GetButtonPanel returns the panel associated to the buttonAction
63 ButtonContainerSettings::PanelButton
64 ButtonContainerSettings::GetPanelButton( const StringType &buttonName )
68 std::cout<< "MLER | ButtonContainerSettings:: GetPanelButton " << std::endl;
70 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
71 != this->m_GroupNameList.end( ); ++it )
74 //std::cout<< std::endl<<"MLER ButtonContainerSettings // GetPanelButton :: it "<< *it<<std::endl;
76 ButtonList list = this->m_ButtonGroupContainer[ ( *it ) ];
77 for( ButtonList::iterator it1 = list.begin( ); it1 != list.end( ); ++it1 )
79 if ( ( *it1 )->first->first.compare( buttonName ) == 0 )
81 return ( ( *it1 )->second->second );
86 catch ( std::exception& e )
89 << "ButtonContainerSettings::GetPanelButton( const StringType &buttonName ) "
90 << "exception: " << e.what( ) << std::endl;
94 // ----------------------------------------------------------------------------------
95 ButtonContainerSettings::PanelButton
96 ButtonContainerSettings::GetPanelList( const StringType &buttonName )
98 std::cout<< "MLER | ButtonContainerSettings:: GetPanelList " << std::endl;
103 for( ItemsMap::iterator it= this->m_itemsMap.begin(); it!=this->m_itemsMap.end(); ++it )
105 if( (*it).first.compare(buttonName) == 0 )
107 std::cout<<"debe retornar" << std::endl;
108 return ( (*it).second );
113 }catch ( std::exception& e )
116 << "ButtonContainerSettings::GetPanelButton( const StringType &buttonName ) "
117 << "exception: " << e.what( ) << std::endl;
124 // ----------------------------------------------------------------------------------
125 ButtonContainerSettings::ButtonGroupSettings*
126 ButtonContainerSettings::GetButtonGroupSettings( TFunctor* functor )
128 ButtonGroupSettings* settings = NULL;
131 std::cout<< "MLER | ButtonContainerSettings:: GetButtonGroupSettings() " << std::endl;
133 settings = new ButtonGroupSettings( );
135 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
136 != this->m_GroupNameList.end( ); ++it )
138 ButtonList list = this->m_ButtonGroupContainer[ ( *it ) ];
140 for( ButtonList::iterator it1 = list.begin( ); it1 != list.end( ); ++it1 )
142 std::cout<<"MLER ButtonContainerSettings // GetButtonGroupSettings :: groupName "<< *it<<std::endl;
143 std::cout<<"MLER ButtonContainerSettings // GetButtonGroupSettings :: buttonName "<< ( *it1 )->first->first <<std::endl;
145 settings->AddButton( ( *it ), ( *it1 )->first->first, ( *it1 )->first->second, ( *it1 )->second->first, functor );
149 catch ( std::exception& e )
152 << "ButtonContainerSettings::GetPanelButton( const StringType &buttonName ) "
153 << "exception: " << e.what( ) << std::endl;
157 // ----------------------------------------------------------------------------------
159 ButtonContainerSettings::SetButtonGroupContainer(
160 ButtonGroupMap m_ButtonGroupContainer )
162 std::cout<< "MLER | ButtonContainerSettings:: SetButtonGroupContainer() " << std::endl;
163 this->m_ButtonGroupContainer = m_ButtonGroupContainer;
165 // ----------------------------------------------------------------------------------
167 ButtonContainerSettings::SetGroupNameList( KeyMapList m_GroupNameList )
169 std::cout<< "MLER | ButtonContainerSettings:: SetGroupNameList() " << std::endl;
170 this->m_GroupNameList = m_GroupNameList;
173 // ----------------------------------------------------------------------------------
175 ButtonContainerSettings::AddButton( const StringType & groupName,
176 const StringType &buttonName, const wxBitmap &icon,
177 const StringType &buttonDescription, PanelButton panel )
181 std::cout<< "MLER | ButtonContainerSettings:: AddButton( const StringType & groupName ..) " << std::endl;
183 //builds the button information
184 //I don't know the try catch doesn't work!!
187 std::cerr << "ButtonContainerSettings::AddButton"
188 << "exception: NULL Pointer in panel " << std::endl;
192 panel->Show( false );
194 ButtonPair* pair = new ButtonPair(
195 new ButtonInfo( buttonName, icon ),
196 new ActionButton( buttonDescription, panel ) );
198 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
199 != this->m_GroupNameList.end( ); ++it )
201 if ( ( *it ).compare( groupName ) == 0 )
203 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
207 this->m_GroupNameList.push_back( groupName );
208 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
210 catch ( const std::exception& e )
213 << "ButtonContainerSettings::AddButton( const StringType & groupName,"
214 << "const StringType &buttonName, const StringType &iconpath,"
215 << "const StringType &buttonDescription, PanelButton panel ) "
216 << "exception: " << e.what( ) << std::endl;
220 // ----------------------------------------------------------------------------------
222 ButtonContainerSettings::AddButton( BCPSettingsStruct* info )
226 std::cout<< "MLER | ButtonContainerSettings:: AddButton( BCPSettingsStruct* info )" << std::endl;
228 //builds the button information
229 //I don't know the try catch doesn't work!!
230 if ( info->panel == NULL )
232 std::cerr << "ButtonContainerSettings::AddButton"
233 << "exception: NULL Pointer in panel " << std::endl;
236 info->panel->Show( false );
237 ButtonPair* pair = new ButtonPair(
238 new ButtonInfo( info->buttonName, info->icon ),
239 new ActionButton( info->buttonDescription, info->panel ) );
240 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
241 != this->m_GroupNameList.end( ); ++it )
243 if ( ( *it ).compare( info->groupName ) == 0 )
245 this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
249 this->m_GroupNameList.push_back( info->groupName );
250 this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
252 catch ( const std::exception& e )
255 << "ButtonContainerSettings::AddButton( BCPSettingsStruct* info )"
256 << "exception: " << e.what( ) << std::endl;
261 // ----------------------------------------------------------------------------------
263 ButtonContainerSettings::AddButtons( BCStructVectorType infoList, int type )
265 std::cout<< "MLER | ButtonContainerSettings:: AddButtons( BCStructVectorType infoList, int type )" << std::endl;
268 for( BCStructVectorType::iterator it = infoList.begin( ); it
269 != infoList.end( ); ++it )
272 this->AddButton( *it );
273 else if( type == 1 || type == 2)
278 catch ( std::exception& e )
281 << "ButtonContainerSettings::AddButtons( BCStructVectorType infoList )"
282 << "exception: " << e.what( ) << std::endl;
287 ButtonContainerSettings::AddItems(BCPSettingsStruct* info)
291 std::cout<< "MLER | ButtonContainerSettings:: AddItems(BCPSettingsStruct* info)" << std::endl;
292 //builds the button information
293 //I don't know the try catch doesn't work!!
294 if ( info->panel == NULL )
296 std::cerr << "ButtonContainerSettings::AddItems"
297 << "exception: NULL Pointer in panel " << std::endl;
301 info->panel->Show( false );
303 std::string mapKey = info->groupName + ":" + info->buttonName;
304 m_itemsMap[mapKey] = info->panel;
307 catch ( const std::exception& e )
310 << "ButtonContainerSettings::AddButton( BCPSettingsStruct* info )"
311 << "exception: " << e.what( ) << std::endl;
316 ButtonContainerSettings::ItemsMap
317 ButtonContainerSettings::GetItemsMap()
319 std::cout<< "MLER | ButtonContainerSettings:: GetItemsMap()" << std::endl;
325 // ----------------------------------------------------------------------------------