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( )
41 // ----------------------------------------------------------------------------------
42 ButtonContainerSettings::~ButtonContainerSettings( )
46 // ----------------------------------------------------------------------------------
47 ButtonContainerSettings::ButtonGroupMap
48 ButtonContainerSettings::GetButtonGroupContainer( )
50 return m_ButtonGroupContainer;
52 // ----------------------------------------------------------------------------------
53 ButtonContainerSettings::KeyMapList
54 ButtonContainerSettings::GetGroupNameList( )
56 return m_GroupNameList;
58 // ----------------------------------------------------------------------------------
59 //GetButtonPanel returns the panel associated to the buttonAction
60 ButtonContainerSettings::PanelButton
61 ButtonContainerSettings::GetPanelButton( const StringType &buttonName )
65 std::cout<<"MLER ButtonContainerSettings // GetPanelButton "<<std::endl;
67 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
68 != this->m_GroupNameList.end( ); ++it )
71 std::cout<< std::endl<<"MLER ButtonContainerSettings // GetPanelButton :: it "<< *it<<std::endl;
73 ButtonList list = this->m_ButtonGroupContainer[ ( *it ) ];
74 for( ButtonList::iterator it1 = list.begin( ); it1 != list.end( ); ++it1 )
76 if ( ( *it1 )->first->first.compare( buttonName ) == 0 )
78 return ( ( *it1 )->second->second );
83 catch ( std::exception& e )
86 << "ButtonContainerSettings::GetPanelButton( const StringType &buttonName ) "
87 << "exception: " << e.what( ) << std::endl;
91 // ----------------------------------------------------------------------------------
92 ButtonContainerSettings::ButtonGroupSettings*
93 ButtonContainerSettings::GetButtonGroupSettings( TFunctor* functor )
95 ButtonGroupSettings* settings = NULL;
98 std::cout<< std::endl<<"MLER CLASS : ButtonContainerSettings" << std::endl;
99 std::cout<< std::endl<<"MLER ButtonContainerSettings // GetButtonGroupSettings "<<std::endl;
101 settings = new ButtonGroupSettings( );
102 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
103 != this->m_GroupNameList.end( ); ++it )
105 ButtonList list = this->m_ButtonGroupContainer[ ( *it ) ];
107 std::cout<<"MLER ButtonContainerSettings // GetButtonGroupSettings :: it "<< *it<<std::endl;
109 for( ButtonList::iterator it1 = list.begin( ); it1 != list.end( ); ++it1 )
111 settings->AddButton( ( *it ), ( *it1 )->first->first, ( *it1 )->first->second, ( *it1 )->second->first, functor );
115 catch ( std::exception& e )
118 << "ButtonContainerSettings::GetPanelButton( const StringType &buttonName ) "
119 << "exception: " << e.what( ) << std::endl;
123 // ----------------------------------------------------------------------------------
125 ButtonContainerSettings::SetButtonGroupContainer(
126 ButtonGroupMap m_ButtonGroupContainer )
128 this->m_ButtonGroupContainer = m_ButtonGroupContainer;
130 // ----------------------------------------------------------------------------------
132 ButtonContainerSettings::SetGroupNameList( KeyMapList m_GroupNameList )
134 this->m_GroupNameList = m_GroupNameList;
137 // ----------------------------------------------------------------------------------
139 ButtonContainerSettings::AddButton( const StringType & groupName,
140 const StringType &buttonName, const wxBitmap &icon,
141 const StringType &buttonDescription, PanelButton panel )
145 std::cout<< std::endl<<"MLER ButtonContainerSettings // AddButton"<<std::endl;
147 //builds the button information
148 //I don't know the try catch doesn't work!!
151 std::cerr << "ButtonContainerSettings::AddButton"
152 << "exception: NULL Pointer in panel " << std::endl;
155 panel->Show( false );
156 ButtonPair* pair = new ButtonPair(
157 new ButtonInfo( buttonName, icon ),
158 new ActionButton( buttonDescription, panel ) );
159 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
160 != this->m_GroupNameList.end( ); ++it )
162 if ( ( *it ).compare( groupName ) == 0 )
164 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
168 this->m_GroupNameList.push_back( groupName );
169 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
171 catch ( const std::exception& e )
174 << "ButtonContainerSettings::AddButton( const StringType & groupName,"
175 << "const StringType &buttonName, const StringType &iconpath,"
176 << "const StringType &buttonDescription, PanelButton panel ) "
177 << "exception: " << e.what( ) << std::endl;
181 // ----------------------------------------------------------------------------------
183 ButtonContainerSettings::AddButton( BCPSettingsStruct* info )
187 //builds the button information
188 //I don't know the try catch doesn't work!!
189 if ( info->panel == NULL )
191 std::cerr << "ButtonContainerSettings::AddButton"
192 << "exception: NULL Pointer in panel " << std::endl;
195 info->panel->Show( false );
196 ButtonPair* pair = new ButtonPair(
197 new ButtonInfo( info->buttonName, info->icon ),
198 new ActionButton( info->buttonDescription, info->panel ) );
199 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
200 != this->m_GroupNameList.end( ); ++it )
202 if ( ( *it ).compare( info->groupName ) == 0 )
204 this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
208 this->m_GroupNameList.push_back( info->groupName );
209 this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
211 catch ( const std::exception& e )
214 << "ButtonContainerSettings::AddButton( BCPSettingsStruct* info )"
215 << "exception: " << e.what( ) << std::endl;
220 // ----------------------------------------------------------------------------------
222 ButtonContainerSettings::AddButtons( BCStructVectorType infoList )
226 for( BCStructVectorType::iterator it = infoList.begin( ); it
227 != infoList.end( ); ++it )
229 this->AddButton( *it );
232 catch ( std::exception& e )
235 << "ButtonContainerSettings::AddButtons( BCStructVectorType infoList )"
236 << "exception: " << e.what( ) << std::endl;
244 ButtonContainerSettings::AddItem(BCPSettingsStruct* info)
246 if(info->panel == NULL)
249 << "ButtonContainerSettings::AddItem"
250 << "exception: NULL Pointer in panel" << std::endl;
255 wxString myString((info->buttonName).c_str(),wxConvUTF8);
256 item.SetText(myString);
260 for(KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
261 != this->m_GroupNameList.end( ); ++it )
263 if((*it).compare(info->groupName) == 0)
265 this->m_ListGroupContainer[info->groupName].push_back(item);
269 this->m_GroupNameList.push_back(info->groupName);
270 this->m_ListGroupContainer[info->groupName].push_back(item);
273 catch ( const std::exception& e )
276 << "ContainerSettings::AddButtons( BCStructVectorType infoList ) "
277 << "exception: " << e.what( ) << std::endl;
282 ButtonContainerSettings::AddItems(BCStructVectorType infoList)
286 for( BCStructVectorType::iterator it = infoList.begin( ); it
287 != infoList.end( ); ++it )
292 catch ( const std::exception& e )
295 << "ContainerSettings::AddButtons( BCStructVectorType infoList ) "
296 << "exception: " << e.what( ) << std::endl;
301 // ----------------------------------------------------------------------------------