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 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
66 != this->m_GroupNameList.end( ); ++it )
68 ButtonList list = this->m_ButtonGroupContainer[ ( *it ) ];
69 for( ButtonList::iterator it1 = list.begin( ); it1 != list.end( ); ++it1 )
71 if ( ( *it1 )->first->first.compare( buttonName ) == 0 )
73 return ( ( *it1 )->second->second );
78 catch ( std::exception& e )
81 << "ButtonContainerSettings::GetPanelButton( const StringType &buttonName ) "
82 << "exception: " << e.what( ) << std::endl;
86 // ----------------------------------------------------------------------------------
87 ButtonContainerSettings::ButtonGroupSettings*
88 ButtonContainerSettings::GetButtonGroupSettings( TFunctor* functor )
90 ButtonGroupSettings* settings = NULL;
93 settings = new ButtonGroupSettings( );
94 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
95 != this->m_GroupNameList.end( ); ++it )
97 ButtonList list = this->m_ButtonGroupContainer[ ( *it ) ];
98 for( ButtonList::iterator it1 = list.begin( ); it1 != list.end( ); ++it1 )
100 settings->AddButton( ( *it ), ( *it1 )->first->first, ( *it1 )->first->second, ( *it1 )->second->first, functor );
104 catch ( std::exception& e )
107 << "ButtonContainerSettings::GetPanelButton( const StringType &buttonName ) "
108 << "exception: " << e.what( ) << std::endl;
112 // ----------------------------------------------------------------------------------
114 ButtonContainerSettings::SetButtonGroupContainer(
115 ButtonGroupMap m_ButtonGroupContainer )
117 this->m_ButtonGroupContainer = m_ButtonGroupContainer;
119 // ----------------------------------------------------------------------------------
121 ButtonContainerSettings::SetGroupNameList( KeyMapList m_GroupNameList )
123 this->m_GroupNameList = m_GroupNameList;
126 // ----------------------------------------------------------------------------------
128 ButtonContainerSettings::AddButton( const StringType & groupName,
129 const StringType &buttonName, const wxBitmap &icon,
130 const StringType &buttonDescription, PanelButton panel )
134 //builds the button information
135 //I don't know the try catch doesn't work!!
138 std::cerr << "ButtonContainerSettings::AddButton"
139 << "exception: NULL Pointer in panel " << std::endl;
142 panel->Show( false );
143 ButtonPair* pair = new ButtonPair(
144 new ButtonInfo( buttonName, icon ),
145 new ActionButton( buttonDescription, panel ) );
146 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
147 != this->m_GroupNameList.end( ); ++it )
149 if ( ( *it ).compare( groupName ) == 0 )
151 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
155 this->m_GroupNameList.push_back( groupName );
156 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
158 catch ( const std::exception& e )
161 << "ButtonContainerSettings::AddButton( const StringType & groupName,"
162 << "const StringType &buttonName, const StringType &iconpath,"
163 << "const StringType &buttonDescription, PanelButton panel ) "
164 << "exception: " << e.what( ) << std::endl;
168 // ----------------------------------------------------------------------------------
170 ButtonContainerSettings::AddButton( BCPSettingsStruct* info )
174 //builds the button information
175 //I don't know the try catch doesn't work!!
176 if ( info->panel == NULL )
178 std::cerr << "ButtonContainerSettings::AddButton"
179 << "exception: NULL Pointer in panel " << std::endl;
182 info->panel->Show( false );
183 ButtonPair* pair = new ButtonPair(
184 new ButtonInfo( info->buttonName, info->icon ),
185 new ActionButton( info->buttonDescription, info->panel ) );
186 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
187 != this->m_GroupNameList.end( ); ++it )
189 if ( ( *it ).compare( info->groupName ) == 0 )
191 this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
195 this->m_GroupNameList.push_back( info->groupName );
196 this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
198 catch ( const std::exception& e )
201 << "ButtonContainerSettings::AddButton( BCPSettingsStruct* info )"
202 << "exception: " << e.what( ) << std::endl;
207 // ----------------------------------------------------------------------------------
209 ButtonContainerSettings::AddButtons( BCStructVectorType infoList )
213 for( BCStructVectorType::iterator it = infoList.begin( ); it
214 != infoList.end( ); ++it )
216 this->AddButton( *it );
219 catch ( std::exception& e )
222 << "ButtonContainerSettings::AddButtons( BCStructVectorType infoList )"
223 << "exception: " << e.what( ) << std::endl;
226 // ----------------------------------------------------------------------------------