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( )
45 // ----------------------------------------------------------------------------------
46 ButtonContainerSettings::ButtonGroupMap
47 ButtonContainerSettings::GetButtonGroupContainer( )
49 return m_ButtonGroupContainer;
51 // ----------------------------------------------------------------------------------
52 ButtonContainerSettings::KeyMapList
53 ButtonContainerSettings::GetGroupNameList( )
55 return m_GroupNameList;
57 // ----------------------------------------------------------------------------------
58 //GetButtonPanel returns the panel associated to the buttonAction
59 ButtonContainerSettings::PanelButton
60 ButtonContainerSettings::GetPanelButton( const StringType &buttonName )
64 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
65 != this->m_GroupNameList.end( ); ++it )
67 ButtonList list = this->m_ButtonGroupContainer[ ( *it ) ];
68 for( ButtonList::iterator it1 = list.begin( ); it1 != list.end( ); ++it1 )
70 if ( ( *it1 )->first->first.compare( buttonName ) == 0 )
72 return ( ( *it1 )->second->second );
77 catch ( std::exception& e )
80 << "ButtonContainerSettings::GetPanelButton( const StringType &buttonName ) "
81 << "exception: " << e.what( ) << std::endl;
85 // ----------------------------------------------------------------------------------
86 ButtonContainerSettings::ButtonGroupSettings*
87 ButtonContainerSettings::GetButtonGroupSettings( TFunctor* functor )
89 ButtonGroupSettings* settings = NULL;
92 settings = new ButtonGroupSettings( );
93 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
94 != this->m_GroupNameList.end( ); ++it )
96 ButtonList list = this->m_ButtonGroupContainer[ ( *it ) ];
97 for( ButtonList::iterator it1 = list.begin( ); it1 != list.end( ); ++it1 )
99 settings->AddButton( ( *it ), ( *it1 )->first->first,
100 ( *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;
125 // ----------------------------------------------------------------------------------
127 ButtonContainerSettings::AddButton( const StringType & groupName,
128 const StringType &buttonName, const StringType &iconpath,
129 const StringType &buttonDescription, PanelButton panel )
133 //builds the button information
134 //I don't know the try catch doesn't work!!
137 std::cerr << "ButtonContainerSettings::AddButton"
138 << "exception: NULL Pointer in panel " << std::endl;
141 panel->Show( false );
142 ButtonPair* pair = new ButtonPair(
143 new ButtonInfo( buttonName, iconpath ),
144 new ActionButton( buttonDescription, panel ) );
145 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
146 != this->m_GroupNameList.end( ); ++it )
148 if ( ( *it ).compare( groupName ) == 0 )
150 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
154 this->m_GroupNameList.push_back( groupName );
155 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
157 catch ( const std::exception& e )
160 << "ButtonContainerSettings::AddButton( const StringType & groupName,"
161 << "const StringType &buttonName, const StringType &iconpath,"
162 << "const StringType &buttonDescription, PanelButton panel ) "
163 << "exception: " << e.what( ) << std::endl;
166 // ----------------------------------------------------------------------------------
168 ButtonContainerSettings::AddButton( BCPSettingsStruct* info )
172 //builds the button information
173 //I don't know the try catch doesn't work!!
174 if ( info->panel == NULL )
176 std::cerr << "ButtonContainerSettings::AddButton"
177 << "exception: NULL Pointer in panel " << std::endl;
180 info->panel->Show( false );
181 ButtonPair* pair = new ButtonPair(
182 new ButtonInfo( info->buttonName, info->iconpath ),
183 new ActionButton( info->buttonDescription, info->panel ) );
184 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
185 != this->m_GroupNameList.end( ); ++it )
187 if ( ( *it ).compare( info->groupName ) == 0 )
189 this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
193 this->m_GroupNameList.push_back( info->groupName );
194 this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
196 catch ( const std::exception& e )
199 << "ButtonContainerSettings::AddButton( BCPSettingsStruct* info )"
200 << "exception: " << e.what( ) << std::endl;
204 // ----------------------------------------------------------------------------------
206 ButtonContainerSettings::AddButtons( BCStructVectorType infoList )
210 for( BCStructVectorType::iterator it = infoList.begin( ); it
211 != infoList.end( ); ++it )
213 this->AddButton( *it );
216 catch ( std::exception& e )
219 << "ButtonContainerSettings::AddButtons( BCStructVectorType infoList )"
220 << "exception: " << e.what( ) << std::endl;
223 // ----------------------------------------------------------------------------------