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( );
103 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
104 != this->m_GroupNameList.end( ); ++it )
106 ButtonList list = this->m_ButtonGroupContainer[ ( *it ) ]; //MLER : Hacer cambio de contenedor
108 std::cout<<"MLER ButtonContainerSettings // GetButtonGroupSettings :: it "<< *it<<std::endl;
110 for( ButtonList::iterator it1 = list.begin( ); it1 != list.end( ); ++it1 )
112 std::cout<<"MLER ButtonContainerSettings // GetButtonGroupSettings :: groupName "<< *it<<std::endl;
113 std::cout<<"MLER ButtonContainerSettings // GetButtonGroupSettings :: buttonName "<< ( *it1 )->first->first <<std::endl;
115 settings->AddButton( ( *it ), ( *it1 )->first->first, ( *it1 )->first->second, ( *it1 )->second->first, functor );
119 catch ( std::exception& e )
122 << "ButtonContainerSettings::GetPanelButton( const StringType &buttonName ) "
123 << "exception: " << e.what( ) << std::endl;
127 // ----------------------------------------------------------------------------------
129 ButtonContainerSettings::SetButtonGroupContainer(
130 ButtonGroupMap m_ButtonGroupContainer )
132 this->m_ButtonGroupContainer = m_ButtonGroupContainer;
134 // ----------------------------------------------------------------------------------
136 ButtonContainerSettings::SetGroupNameList( KeyMapList m_GroupNameList )
138 this->m_GroupNameList = m_GroupNameList;
141 // ----------------------------------------------------------------------------------
143 ButtonContainerSettings::AddButton( const StringType & groupName,
144 const StringType &buttonName, const wxBitmap &icon,
145 const StringType &buttonDescription, PanelButton panel )
149 std::cout<< std::endl<<"MLER ButtonContainerSettings / AddButton(groupname...)"<<std::endl;
151 //builds the button information
152 //I don't know the try catch doesn't work!!
155 std::cerr << "ButtonContainerSettings::AddButton"
156 << "exception: NULL Pointer in panel " << std::endl;
160 panel->Show( false );
162 ButtonPair* pair = new ButtonPair(
163 new ButtonInfo( buttonName, icon ),
164 new ActionButton( buttonDescription, panel ) );
166 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
167 != this->m_GroupNameList.end( ); ++it )
169 if ( ( *it ).compare( groupName ) == 0 )
171 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
175 this->m_GroupNameList.push_back( groupName );
176 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
178 catch ( const std::exception& e )
181 << "ButtonContainerSettings::AddButton( const StringType & groupName,"
182 << "const StringType &buttonName, const StringType &iconpath,"
183 << "const StringType &buttonDescription, PanelButton panel ) "
184 << "exception: " << e.what( ) << std::endl;
188 // ----------------------------------------------------------------------------------
190 ButtonContainerSettings::AddButton( BCPSettingsStruct* info )
194 //builds the button information
195 //I don't know the try catch doesn't work!!
196 if ( info->panel == NULL )
198 std::cerr << "ButtonContainerSettings::AddButton"
199 << "exception: NULL Pointer in panel " << std::endl;
202 info->panel->Show( false );
203 ButtonPair* pair = new ButtonPair(
204 new ButtonInfo( info->buttonName, info->icon ),
205 new ActionButton( info->buttonDescription, info->panel ) );
206 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
207 != this->m_GroupNameList.end( ); ++it )
209 if ( ( *it ).compare( info->groupName ) == 0 )
211 this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
215 this->m_GroupNameList.push_back( info->groupName );
216 this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
218 catch ( const std::exception& e )
221 << "ButtonContainerSettings::AddButton( BCPSettingsStruct* info )"
222 << "exception: " << e.what( ) << std::endl;
227 // ----------------------------------------------------------------------------------
229 ButtonContainerSettings::AddButtons( BCStructVectorType infoList )
233 for( BCStructVectorType::iterator it = infoList.begin( ); it
234 != infoList.end( ); ++it )
236 this->AddButton( *it );
239 catch ( std::exception& e )
242 << "ButtonContainerSettings::AddButtons( BCStructVectorType infoList )"
243 << "exception: " << e.what( ) << std::endl;
248 // ----------------------------------------------------------------------------------