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( )
 
  42         // ----------------------------------------------------------------------------------
 
  43         ButtonContainerSettings::~ButtonContainerSettings( )
 
  47         // ----------------------------------------------------------------------------------
 
  48         ButtonContainerSettings::ButtonGroupMap
 
  49         ButtonContainerSettings::GetButtonGroupContainer( )
 
  51                 std::cout<< "MLER | ButtonContainerSettings:: GetButtonGroupContainer( ) " << std::endl;
 
  52                 return m_ButtonGroupContainer;
 
  54         // ----------------------------------------------------------------------------------
 
  55         ButtonContainerSettings::KeyMapList
 
  56         ButtonContainerSettings::GetGroupNameList( )
 
  58                 std::cout<< "MLER | ButtonContainerSettings:: GetGroupNameList( ) " << std::endl;
 
  59                 return m_GroupNameList;
 
  61         // ----------------------------------------------------------------------------------
 
  62         //GetButtonPanel returns the panel associated to the buttonAction
 
  63         ButtonContainerSettings::PanelButton
 
  64         ButtonContainerSettings::GetPanelButton( const StringType &buttonName )
 
  68                         std::cout<< "MLER | ButtonContainerSettings:: GetPanelButton " << std::endl;
 
  70                         for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
 
  71                             != this->m_GroupNameList.end( ); ++it )
 
  74                                 //std::cout<< std::endl<<"MLER ButtonContainerSettings // GetPanelButton :: it "<< *it<<std::endl;
 
  76                                 ButtonList list = this->m_ButtonGroupContainer[ ( *it ) ];
 
  77                                 for( ButtonList::iterator it1 = list.begin( ); it1 != list.end( ); ++it1 )
 
  79                                         if ( ( *it1 )->first->first.compare( buttonName ) == 0 )
 
  81                                                 return ( ( *it1 )->second->second );
 
  86                 catch ( std::exception& e )
 
  89                             << "ButtonContainerSettings::GetPanelButton( const StringType &buttonName ) "
 
  90                             << "exception: " << e.what( ) << std::endl;
 
  94         // ----------------------------------------------------------------------------------
 
  95         ButtonContainerSettings::PanelButton
 
  96         ButtonContainerSettings::GetPanelList( const StringType &buttonName )
 
  98                 std::cout<< "MLER | ButtonContainerSettings:: GetPanelList " << std::endl;
 
 102                         if(m_itemsMap.empty())
 
 103                                 std::cout<< "no tengo nada "<< std::endl;
 
 105                         for( ItemsMap::iterator it= this->m_itemsMap.begin(); it!=this->m_itemsMap.end(); ++it )
 
 107                                 if( (*it).first.compare(buttonName) == 0 )
 
 108                                         return ( (*it).second );
 
 112                 }catch ( std::exception& e )
 
 115                             << "ButtonContainerSettings::GetPanelButton( const StringType &buttonName ) "
 
 116                             << "exception: " << e.what( ) << std::endl;
 
 123         // ----------------------------------------------------------------------------------
 
 124         ButtonContainerSettings::ButtonGroupSettings*
 
 125         ButtonContainerSettings::GetButtonGroupSettings( TFunctor* functor )
 
 127                 ButtonGroupSettings* settings = NULL;
 
 130                         std::cout<< "MLER | ButtonContainerSettings:: GetButtonGroupSettings() " << std::endl;
 
 132                         settings = new ButtonGroupSettings( );
 
 134                         for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
 
 135                             != this->m_GroupNameList.end( ); ++it )
 
 137                                 ButtonList list = this->m_ButtonGroupContainer[ ( *it ) ];
 
 139                                 for( ButtonList::iterator it1 = list.begin( ); it1 != list.end( ); ++it1 )
 
 141                                         std::cout<<"MLER ButtonContainerSettings // GetButtonGroupSettings :: groupName "<< *it<<std::endl;
 
 142                                         std::cout<<"MLER ButtonContainerSettings // GetButtonGroupSettings :: buttonName "<< ( *it1 )->first->first <<std::endl;
 
 144                                         settings->AddButton( ( *it ), ( *it1 )->first->first, ( *it1 )->first->second, ( *it1 )->second->first, functor );
 
 148                 catch ( std::exception& e )
 
 151                             << "ButtonContainerSettings::GetPanelButton( const StringType &buttonName ) "
 
 152                             << "exception: " << e.what( ) << std::endl;
 
 156         // ----------------------------------------------------------------------------------
 
 158         ButtonContainerSettings::SetButtonGroupContainer(
 
 159             ButtonGroupMap m_ButtonGroupContainer )
 
 161                 std::cout<< "MLER | ButtonContainerSettings:: SetButtonGroupContainer() " << std::endl;
 
 162                 this->m_ButtonGroupContainer = m_ButtonGroupContainer;
 
 164         // ----------------------------------------------------------------------------------
 
 166         ButtonContainerSettings::SetGroupNameList( KeyMapList m_GroupNameList )
 
 168                 std::cout<< "MLER | ButtonContainerSettings:: SetGroupNameList() " << std::endl;
 
 169                 this->m_GroupNameList = m_GroupNameList;
 
 172         // ----------------------------------------------------------------------------------
 
 174         ButtonContainerSettings::AddButton( const StringType & groupName,
 
 175             const StringType &buttonName, const wxBitmap &icon,
 
 176             const StringType &buttonDescription, PanelButton panel )
 
 180                         std::cout<< "MLER | ButtonContainerSettings:: AddButton( const StringType & groupName ..) " << std::endl;
 
 182                         //builds the button information
 
 183                         //I don't know the try catch doesn't work!!
 
 186                                 std::cerr << "ButtonContainerSettings::AddButton"
 
 187                                     << "exception: NULL Pointer in panel " << std::endl;
 
 191                         panel->Show( false );
 
 193                         ButtonPair* pair = new ButtonPair(
 
 194                             new ButtonInfo( buttonName, icon ),
 
 195                             new ActionButton( buttonDescription, panel ) );
 
 197                         for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
 
 198                             != this->m_GroupNameList.end( ); ++it )
 
 200                                 if ( ( *it ).compare( groupName ) == 0 )
 
 202                                         this->m_ButtonGroupContainer[ groupName ].push_back( pair );
 
 206                         this->m_GroupNameList.push_back( groupName );
 
 207                         this->m_ButtonGroupContainer[ groupName ].push_back( pair );
 
 209                 catch ( const std::exception& e )
 
 212                             << "ButtonContainerSettings::AddButton( const StringType & groupName,"
 
 213                             << "const StringType &buttonName, const StringType &iconpath,"
 
 214                             << "const StringType &buttonDescription, PanelButton panel ) "
 
 215                             << "exception: " << e.what( ) << std::endl;
 
 219         // ----------------------------------------------------------------------------------
 
 221         ButtonContainerSettings::AddButton( BCPSettingsStruct* info )
 
 225                         std::cout<< "MLER | ButtonContainerSettings:: AddButton( BCPSettingsStruct* info )" << std::endl;
 
 227                         //builds the button information
 
 228                         //I don't know the try catch doesn't work!!
 
 229                         if ( info->panel == NULL )
 
 231                                 std::cerr << "ButtonContainerSettings::AddButton"
 
 232                                     << "exception: NULL Pointer in panel " << std::endl;
 
 235                         info->panel->Show( false );
 
 236                         ButtonPair* pair = new ButtonPair(
 
 237                             new ButtonInfo( info->buttonName, info->icon ),
 
 238                             new ActionButton( info->buttonDescription, info->panel ) );
 
 239                         for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
 
 240                             != this->m_GroupNameList.end( ); ++it )
 
 242                                 if ( ( *it ).compare( info->groupName ) == 0 )
 
 244                                         this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
 
 248                         this->m_GroupNameList.push_back( info->groupName );
 
 249                         this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
 
 251                 catch ( const std::exception& e )
 
 254                             << "ButtonContainerSettings::AddButton( BCPSettingsStruct* info )"
 
 255                             << "exception: " << e.what( ) << std::endl;
 
 260         // ----------------------------------------------------------------------------------
 
 262         ButtonContainerSettings::AddButtons( BCStructVectorType infoList, int type )
 
 264                 std::cout<< "MLER | ButtonContainerSettings:: AddButtons( BCStructVectorType infoList, int type )" << std::endl;
 
 267                         for( BCStructVectorType::iterator it = infoList.begin( ); it
 
 268                             != infoList.end( ); ++it )
 
 271                                         this->AddButton( *it );
 
 276                 catch ( std::exception& e )
 
 279                             << "ButtonContainerSettings::AddButtons( BCStructVectorType infoList )"
 
 280                             << "exception: " << e.what( ) << std::endl;
 
 285         ButtonContainerSettings::AddItems(BCPSettingsStruct* info)
 
 289                         std::cout<< "MLER | ButtonContainerSettings:: AddItems(BCPSettingsStruct* info)" << std::endl;
 
 290                         //builds the button information
 
 291                         //I don't know the try catch doesn't work!!
 
 292                         if ( info->panel == NULL )
 
 294                                 std::cerr << "ButtonContainerSettings::AddButton"
 
 295                                     << "exception: NULL Pointer in panel " << std::endl;
 
 299                         info->panel->Show( false );
 
 301                         std::string mapKey = info->groupName + ":" + info->buttonName;
 
 302                         m_itemsMap[mapKey] = info->panel;
 
 305                 catch ( const std::exception& e )
 
 308                         << "ButtonContainerSettings::AddButton( BCPSettingsStruct* info )"
 
 309                         << "exception: " << e.what( ) << std::endl;
 
 314         ButtonContainerSettings::ItemsMap
 
 315         ButtonContainerSettings::GetItemsMap()
 
 317                 std::cout<< "MLER | ButtonContainerSettings:: GetItemsMap()" << std::endl;
 
 322 // ----------------------------------------------------------------------------------