2 * @file buttonContainerSettings.cxx
3 * @brief Implements the ButtonContainerSettings class.
4 * @author Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr)
8 #include "buttonContainerSettings.h"
11 namespace creaPanelButtonContainer
13 // ----------------------------------------------------------------------------------
14 ButtonContainerSettings::ButtonContainerSettings( )
17 // ----------------------------------------------------------------------------------
18 ButtonContainerSettings::~ButtonContainerSettings( )
21 // ----------------------------------------------------------------------------------
22 ButtonContainerSettings::ButtonGroupMap
23 ButtonContainerSettings::GetButtonGroupContainer( )
25 return m_ButtonGroupContainer;
27 // ----------------------------------------------------------------------------------
28 ButtonContainerSettings::KeyMapList
29 ButtonContainerSettings::GetGroupNameList( )
31 return m_GroupNameList;
33 // ----------------------------------------------------------------------------------
34 //GetButtonPanel returns the panel associated to the buttonAction
35 ButtonContainerSettings::PanelButton
36 ButtonContainerSettings::GetPanelButton( const std::string &buttonName )
40 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
41 != this->m_GroupNameList.end( ); ++it )
43 ButtonList list = this->m_ButtonGroupContainer[ ( *it ) ];
44 for( ButtonList::iterator it1 = list.begin( ); it1 != list.end( ); ++it1 )
46 if ( ( *it1 )->first->first.compare( buttonName ) == 0 )
48 return ( ( *it1 )->second->second );
53 catch ( std::exception& e )
56 << "ButtonContainerSettings::GetPanelButton( const std::string &buttonName ) "
57 << "exception: " << e.what( ) << std::endl;
61 // ----------------------------------------------------------------------------------
62 ButtonContainerSettings::ButtonGroupSettings*
63 ButtonContainerSettings::GetButtonGroupSettings( TFunctor* functor )
65 ButtonGroupSettings* settings = new ButtonGroupSettings( );
68 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
69 != this->m_GroupNameList.end( ); ++it )
71 ButtonList list = this->m_ButtonGroupContainer[ ( *it ) ];
72 for( ButtonList::iterator it1 = list.begin( ); it1 != list.end( ); ++it1 )
74 settings->AddButton( ( *it ), ( *it1 )->first->first,
75 ( *it1 )->first->second, ( *it1 )->second->first, functor );
80 catch ( std::exception& e )
83 << "ButtonContainerSettings::GetPanelButton( const std::string &buttonName ) "
84 << "exception: " << e.what( ) << std::endl;
88 // ----------------------------------------------------------------------------------
90 ButtonContainerSettings::SetButtonGroupContainer(
91 ButtonGroupMap m_ButtonGroupContainer )
93 this->m_ButtonGroupContainer = m_ButtonGroupContainer;
95 // ----------------------------------------------------------------------------------
97 ButtonContainerSettings::SetGroupNameList( KeyMapList m_GroupNameList )
99 this->m_GroupNameList = m_GroupNameList;
101 // ----------------------------------------------------------------------------------
103 ButtonContainerSettings::AddButton( const std::string & groupName,
104 const std::string &buttonName, const std::string &iconpath,
105 const std::string &buttonDescription, PanelButton panel )
109 //builds the button information
110 panel->Show( false );
111 ButtonPair* pair = new ButtonPair(
112 new ButtonInfo( buttonName, iconpath ),
113 new ActionButton( buttonDescription, panel ) );
114 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
115 != this->m_GroupNameList.end( ); ++it )
117 if ( ( *it ).compare( groupName ) == 0 )
119 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
123 this->m_GroupNameList.push_back( groupName );
124 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
126 catch ( std::exception& e )
129 << "ButtonContainerSettings::AddButton( const std::string & groupName,"
130 << "const std::string &buttonName, const std::string &iconpath,"
131 << "const std::string &buttonDescription, PanelButton panel ) "
132 << "exception: " << e.what( ) << std::endl;
135 // ----------------------------------------------------------------------------------
137 ButtonContainerSettings::AddButton( BCPSettingsStruct* info )
141 //builds the button information
142 info->panel->Show( false );
143 ButtonPair* pair = new ButtonPair(
144 new ButtonInfo( info->buttonName, info->iconpath ),
145 new ActionButton( info->buttonDescription, info->panel ) );
146 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
147 != this->m_GroupNameList.end( ); ++it )
149 if ( ( *it ).compare( info->groupName ) == 0 )
151 this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
155 this->m_GroupNameList.push_back( info->groupName );
156 this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
158 catch ( std::exception& e )
161 << "ButtonContainerSettings::AddButton( BCPSettingsStruct* info )"
162 << "exception: " << e.what( ) << std::endl;
165 // ----------------------------------------------------------------------------------
167 ButtonContainerSettings::AddButtons( BCStructVectorType infoList )
171 for( BCStructVectorType::iterator it = infoList.begin( ); it
172 != infoList.end( ); ++it )
174 this->AddButton( *it );
177 catch ( std::exception& e )
180 << "ButtonContainerSettings::AddButtons( BCStructVectorType infoList )"
181 << "exception: " << e.what( ) << std::endl;
184 // ----------------------------------------------------------------------------------