]> Creatis software - creaMaracasVisu.git/commitdiff
#2516 creaMaracasVisu Feature New Normal - creaPanelButtonContainer ListPanel with...
authorespinosa <espinosa@creatis.insa-lyon.fr>
Fri, 30 Jan 2015 08:05:01 +0000 (09:05 +0100)
committerespinosa <espinosa@creatis.insa-lyon.fr>
Fri, 30 Jan 2015 08:05:01 +0000 (09:05 +0100)
lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/listConfig.cxx [new file with mode: 0644]
lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/listConfig.h [new file with mode: 0644]
lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/listConfigPanel.cxx [new file with mode: 0644]
lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/listConfigPanel.h [new file with mode: 0644]

diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/listConfig.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/listConfig.cxx
new file mode 100644 (file)
index 0000000..b96741c
--- /dev/null
@@ -0,0 +1,97 @@
+/*# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+#                        pour la Sant�)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+#  This software is governed by the CeCILL-B license under French law and
+#  abiding by the rules of distribution of free software. You can  use,
+#  modify and/ or redistribute the software under the terms of the CeCILL-B
+#  license as circulated by CEA, CNRS and INRIA at the following URL
+#  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+#  or in the file LICENSE.txt.
+#
+#  As a counterpart to the access to the source code and  rights to copy,
+#  modify and redistribute granted by the license, users are provided only
+#  with a limited warranty  and the software's author,  the holder of the
+#  economic rights,  and the successive licensors  have only  limited
+#  liability.
+#
+#  The fact that you are presently reading this means that you have had
+#  knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------ */
+
+#include "listConfig.h"
+
+namespace creaButtonContainer
+{
+       namespace model
+       {
+
+               ListConfig::ListConfig(ItemsMap items)
+               {
+                       m_itemsMap = items;
+
+               }
+
+               ListConfig::~ListConfig()
+               {
+
+               }
+
+               ListConfig::ItemsMap
+               ListConfig::AddFinalItems(std::string name)
+               {
+                       std::cout<< "MLER | ListConfig::AddFinalItems(std::string name)" << std::endl;
+
+                       ItemsMap::iterator it1 = m_finalItems.find(name);
+
+                       if(it1 == m_finalItems.end())
+                       {
+                               for(ItemsMap::iterator it=this->m_itemsMap.begin(); it!=this->m_itemsMap.end(); ++it)
+                               {
+                                       if((it->first).compare(name) != 0  )
+                                       {
+                                               std::cout << "Item en finalItems: "<< name << std::endl;
+                                               m_finalItems[name] = it->second;
+                                       }
+                               }
+                       }
+                       std::cout << "FinalItems Add" << m_finalItems.size() << std::endl;
+
+                       return (m_finalItems);
+               }
+
+               ListConfig::ItemsMap
+               ListConfig::DelFinalItems(std::string name)
+               {
+                       std::cout<< "MLER | ListConfig::DelFinalItems(std::string name)" << std::endl;
+                       ItemsMap::iterator it1;
+
+                       //if(m_finalItems.empty())
+                               std::cout<<"name item -----test A"<< name <<std::endl;
+
+                       if(!m_finalItems.empty())
+                       {
+                               for(ItemsMap::iterator it= this->m_finalItems.begin(); it!=this->m_finalItems.end();++it)
+                               {
+                                       if((it->first).compare(name) == 0  )
+                                       {
+                                               std::cout << "Item a borrar: "<< name << std::endl;
+
+                                               it1 = m_finalItems.find(name);
+                                               m_finalItems.erase(it1);
+
+                                       }
+                               }
+                       }
+
+                       std::cout<< "si borre tengo --- test 2 "<< m_finalItems.size() << std::endl;
+
+                       return (m_finalItems);
+               }
+
+       }//namespace model
+}//namespace creaButtonContainer
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/listConfig.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/listConfig.h
new file mode 100644 (file)
index 0000000..0c8edcc
--- /dev/null
@@ -0,0 +1,76 @@
+/*# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+#                        pour la Sant�)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+#  This software is governed by the CeCILL-B license under French law and
+#  abiding by the rules of distribution of free software. You can  use,
+#  modify and/ or redistribute the software under the terms of the CeCILL-B
+#  license as circulated by CEA, CNRS and INRIA at the following URL
+#  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+#  or in the file LICENSE.txt.
+#
+#  As a counterpart to the access to the source code and  rights to copy,
+#  modify and redistribute granted by the license, users are provided only
+#  with a limited warranty  and the software's author,  the holder of the
+#  economic rights,  and the successive licensors  have only  limited
+#  liability.
+#
+#  The fact that you are presently reading this means that you have had
+#  knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------ */
+
+#ifndef LISTCONFIG_H
+#define LISTCONFIG_H
+
+#include <wx/panel.h>
+
+#include<iostream>
+#include <map>
+#include <string>
+
+//#include "listWx.h"
+//#include "listConfigPanel.h"
+#include "functor.h"
+
+namespace creaButtonContainer
+{
+       namespace model
+       {
+               class ListConfig
+               {
+                       public:
+                               //typedef creaButtonContainer::model::TFunctor TFunctor;
+                               typedef std::map<std::string, wxPanel*> ItemsMap;
+
+
+
+                               //ListConfig(ItemsMap items, TFunctor* functor);
+                               ListConfig(ItemsMap items);
+                               ~ListConfig();
+
+                               //ItemsMap
+                               //GetItemsMap();
+
+                               ItemsMap
+                               AddFinalItems(std::string name);
+
+                               ItemsMap
+                               DelFinalItems(std::string name);
+
+                       private:
+
+                               ItemsMap m_itemsMap;
+                               TFunctor* functor;
+                               ItemsMap m_finalItems;
+
+
+               };
+
+       }
+}
+
+#endif // LISTCONFIG_H
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/listConfigPanel.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/listConfigPanel.cxx
new file mode 100644 (file)
index 0000000..ccaec94
--- /dev/null
@@ -0,0 +1,300 @@
+/*# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+#                        pour la Sant�)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+#  This software is governed by the CeCILL-B license under French law and
+#  abiding by the rules of distribution of free software. You can  use,
+#  modify and/ or redistribute the software under the terms of the CeCILL-B
+#  license as circulated by CEA, CNRS and INRIA at the following URL
+#  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+#  or in the file LICENSE.txt.
+#
+#  As a counterpart to the access to the source code and  rights to copy,
+#  modify and redistribute granted by the license, users are provided only
+#  with a limited warranty  and the software's author,  the holder of the
+#  economic rights,  and the successive licensors  have only  limited
+#  liability.
+#
+#  The fact that you are presently reading this means that you have had
+#  knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------ */
+
+#include "listConfigPanel.h"
+
+namespace creaPanelButtonContainer
+{
+
+               ListConfigPanel::ListConfigPanel(wxWindow* parent, wxWindowID id,const wxString& title, ListWx* modelList, ListWx* currentList) :
+                               wxDialog(parent,id,title)
+               {
+                       std::cout<< "MLER | ListConfigPanel::ListConfigPanel()" << std::endl;
+
+                       m_listWx = modelList;
+                       m_listWx->Reparent(this);
+                       m_listWx->Show(true);
+                       m_listWx->SetFunctorEnabled(false);
+                       m_listWx->FillList();
+
+                       m_finalListWx = currentList;
+                       m_finalListWx->Reparent(this);
+                       m_finalListWx->SetFunctorEnabled(false);
+                       m_finalListWx->Show(true);
+                       m_finalListWx->FillList();
+
+                       wxFlexGridSizer* sizer = new wxFlexGridSizer(2,1,0,0);
+                       //sizer->Add( new  wxStaticText(this,-1, _("Lista Configurable")));
+                       this->SetSizer(sizer);
+
+
+                       wxBoxSizer* sizerUp = new wxBoxSizer(wxHORIZONTAL);
+
+                       //wxPanel* panel1 = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL,
+                               //      _T("Panel 1"));
+
+                       //wxBoxSizer* sizerList1 = new wxBoxSizer(wxVERTICAL);
+
+                       //panel1->Add(m_listWx,0,wxEXPAND);
+                       //listBox = new wxListBox(panel1,-1,wxDefaultPosition,wxDefaultSize, 0, 0, 0,
+                               //      wxDefaultValidator, _("ListBox"));
+
+                       //sizerList1->Add(panel1,0,wxEXPAND);
+
+                       //panel1->SetSizer(sizerList1);
+                       //sizerList1->Fit(panel1);
+                       //sizerList1->SetSizeHints(panel1);
+
+                       sizerUp->Add(m_listWx, 0, wxEXPAND);
+               //========
+
+                       wxPanel* panel2 = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("Panel 2"));
+                       wxBoxSizer* sizerList2 = new wxBoxSizer(wxVERTICAL);
+
+                       buttonAdd = new wxButton(panel2, 1, _(">"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("Add"));
+                       sizerList2->Add(buttonAdd, 0, wxEXPAND);
+
+                       buttonDel = new wxButton(panel2, 2, _("<"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("Delete"));
+                       sizerList2->Add(buttonDel,  0, wxEXPAND);
+
+                       panel2->SetSizer(sizerList2);
+                       sizerList2->Fit(panel2);
+                       sizerList2->SetSizeHints(panel2);
+
+                       sizerUp->Add(panel2, 0, wxEXPAND|wxALL,7);
+
+               //========
+
+                       wxPanel* panel3 = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("Panel 3"));
+                       wxBoxSizer* sizerList3 = new wxBoxSizer(wxHORIZONTAL);
+
+                       //finalListBox = new wxListBox(panel3, -1, wxDefaultPosition, wxDefaultSize, 0, 0, 0,
+                               //      wxDefaultValidator, _T("finalListBox"));
+                       sizerList3->Add(m_finalListWx, 0, wxEXPAND);
+
+                       //panel3->SetSizer(sizerList3);
+                       //sizerList3->Fit(panel3);
+                       //sizerList3->SetSizeHints(panel3);
+
+                       sizerUp->Add(m_finalListWx, 0, wxEXPAND|wxALL);
+                       //sizer->Add(sizerUp, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
+
+                       //FillList();
+
+               //=======
+                       wxPanel* panel5 = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("Panel 5"));
+                       wxBoxSizer* sizerList4 = new wxBoxSizer(wxVERTICAL);
+
+                       upButton = new wxButton(panel5, 3, _("/\\"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("upButton"));
+                       sizerList4->Add(upButton, 0, wxEXPAND);
+
+                       downButton = new wxButton(panel5, 4, _("V"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("downButton"));
+                       sizerList4->Add(downButton, 0, wxEXPAND);
+
+                       panel5->SetSizer(sizerList4);
+                       sizerList4->Fit(panel5);
+                       sizerList4->SetSizeHints(panel5);
+                       sizerUp->Add(panel5,  0, wxEXPAND|wxALL,7);
+
+                       //========
+                       wxBoxSizer* sizerBotones = new wxBoxSizer(wxHORIZONTAL);
+                       wxPanel* panel4 = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("Panel 4"));
+
+                       okButton = new wxButton(panel4, 5, _("Ok"), wxPoint(0,8), wxDefaultSize, 0, wxDefaultValidator, _T("Ok"));
+                       cancelButton = new wxButton(panel4, 6, _("Cancel"), wxPoint(88,8), wxDefaultSize, 0, wxDefaultValidator, _T("Cancel"));
+
+                       sizerBotones->Add(panel4,  0, wxEXPAND);
+
+                       sizer->Add(sizerUp,0,wxEXPAND);
+                       sizer->Add(sizerBotones,  1, wxALL|wxALIGN_CENTER_HORIZONTAL);
+
+
+               //      SetSizer(sizer);
+                       //SetSizer(sizer);
+                       //Layout();
+
+               //---------------------------------------------------------------------------------------------
+               // Manejo de Eventos
+
+                       //Evento Cancel
+                       Connect(6,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ListConfigPanel::OnQuit);
+
+                       //EventoSeleccionarLista
+                       //Connect(wxEVT_COMMAND_LISTBOX_SELECTED,wxCommandEventHandler(ListConfigPanel::ListItemEvent));
+
+                       //EventoAdd
+                       Connect(1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ListConfigPanel::OnAdd);
+
+                       //EventoOk
+                       Connect(5,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ListConfigPanel::OkEvent);
+
+                       //EventoDelete
+                       Connect(2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ListConfigPanel::OnDelete);
+
+               }
+
+               ListConfigPanel::~ListConfigPanel()
+               {
+
+               }
+
+               ListConfigPanel::ItemsMap
+               ListConfigPanel::GetFinalItemsMap()
+               {
+                       return m_finalItems;
+               }
+
+               void
+               ListConfigPanel::SetFinalItems(ItemsMap finalItems)
+               {
+                       m_finalItems = finalItems;
+               }
+
+               void
+               ListConfigPanel::FillList(int i)
+               {
+                       /*if(i == 0)
+                       {
+                               m_itemsMap = m_listWx->GetItemsMap();
+
+                               for (ItemsMap::iterator it=this->m_itemsMap.begin(); it!=this->m_itemsMap.end(); ++it)
+                               {
+                                       std::string key = it->first;
+                                       listBox->Append( wxString(key.c_str(), wxConvUTF8));
+                               }
+                       }
+                       if(i == 1)
+                       {
+                               std::cout << "ListConfigPanel::FillList items : "<< m_finalItems.size()<<std::endl;
+                               finalListBox->Clear();
+
+                               if(!m_finalItems.empty())
+                               {
+                                       for (ItemsMap::iterator it=this->m_finalItems.begin(); it!=this->m_finalItems.end(); ++it)
+                                       {
+                                               std::string key = it->first;
+                                               int v = finalListBox->FindString(wxString(key.c_str(), wxConvUTF8));
+
+                                               if(v == -1)
+                                                       finalListBox->Append( wxString(key.c_str(), wxConvUTF8));
+                                       }
+                               }
+
+
+                       }*/
+               }
+
+               void
+               ListConfigPanel::OnQuit(wxCommandEvent& event)
+               {
+                       std::cout<<"Onquit"<<std::endl;
+                   Close();
+               }
+
+               void
+               ListConfigPanel::ListItemEvent(wxCommandEvent& event)
+               {
+                       /*std::cout<<"MLER |ListConfigPanel::ListItemEvent"<<std::endl;
+
+                       int iSelection;
+                       iSelection = listBox->GetSelection();
+
+                       wxString itemNom = listBox->GetString(iSelection);
+                       std::string itemNomC = std::string(itemNom.mb_str());*/
+
+               }
+
+
+               void
+               ListConfigPanel::OnAdd(wxCommandEvent& event)
+               {
+                       std::cout<<"MLER |ListConfigPanel::OnAdd"<<std::endl;
+
+                       wxString itSel = m_listWx->GetListBox()->GetStringSelection();
+                       std::string item = std::string(itSel.mb_str());
+
+
+                       if(!itSel.empty())
+                       {
+                               wxPanel* mPanel = m_listWx->GetItemsMap()[item];
+                               m_finalListWx->AddItemToMap(item, mPanel);
+                               m_finalListWx->FillList();
+                       }
+
+                                //wxMessageBox( _("Seleccione un elemento"), wxOK | wxICON_INFORMATION );
+
+                       std::cout << "FinalItemsAdd" << m_finalItems.size() << std::endl;
+               }
+
+               void
+               ListConfigPanel::OnDelete(wxCommandEvent& event)
+               {
+                       std::cout<<"MLER |ListConfigPanel::OnDelete"<<std::endl;
+
+                       wxString itSel = m_finalListWx->GetListBox()->GetStringSelection();
+                       std::string item = std::string(itSel.mb_str());
+                       if(!itSel.empty())
+                       {
+                               m_finalListWx->DeleteItemFromMap(item);
+                               m_finalListWx->FillList();
+                       }
+
+                       std::cout << "FinalItems Delete" << m_finalItems.size() << std::endl;
+               }
+
+               void
+               ListConfigPanel::OkEvent(wxCommandEvent& event)
+               {
+                       std::cout<<"MLER |ListConfigPanel::OkEvent"<<std::endl;
+
+                       this->EndModal(1);
+               }
+
+               void
+               ListConfigPanel::UpEvent(wxCommandEvent& event)
+               {
+                       std::cout<<"Up Event"<<std::endl;
+               }
+
+               void
+               ListConfigPanel::DownEvent(wxCommandEvent& event)
+               {
+                       std::cout<<"Down Event"<<std::endl;
+               }
+
+               void
+               ListConfigPanel::RefreshViewEvent(wxCommandEvent& event)
+               {
+                       std::cout<<"RefreshView Event"<<std::endl;
+               }
+
+
+               ListConfigPanel::ListWx*
+               ListConfigPanel::GetFinalListWx()
+               {
+                       return this->m_finalListWx;
+               }
+
+}
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/listConfigPanel.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/listConfigPanel.h
new file mode 100644 (file)
index 0000000..5e03947
--- /dev/null
@@ -0,0 +1,130 @@
+/*# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+#                        pour la Sant�)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+#  This software is governed by the CeCILL-B license under French law and
+#  abiding by the rules of distribution of free software. You can  use,
+#  modify and/ or redistribute the software under the terms of the CeCILL-B
+#  license as circulated by CEA, CNRS and INRIA at the following URL
+#  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+#  or in the file LICENSE.txt.
+#
+#  As a counterpart to the access to the source code and  rights to copy,
+#  modify and redistribute granted by the license, users are provided only
+#  with a limited warranty  and the software's author,  the holder of the
+#  economic rights,  and the successive licensors  have only  limited
+#  liability.
+#
+#  The fact that you are presently reading this means that you have had
+#  knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------ */
+
+#ifndef LISTCONFIGPANEL_H
+#define LISTCONFIGPANEL_H
+
+#include <wx/panel.h>
+#include <wx/sizer.h>
+#include <wx/wx.h>
+
+
+#include <map>
+#include <string>
+#include <vector>
+
+#include "functor.h"
+#include "listConfig.h"
+#include "listWx.h"
+
+
+namespace creaPanelButtonContainer
+{
+       /*namespace controller
+       {
+               //class ButtonContainerController;
+       }*/
+
+
+               class ListConfigPanel : public wxDialog
+               {
+                       public:
+
+                               typedef std::map<std::string, wxPanel*> ItemsMap;
+                               typedef creaButtonContainer::model::TFunctor TFunctor;
+                               typedef creaButtonContainer::model::ListConfig ListConfig;
+                               typedef creaButtonContainer::view::ListWx ListWx;
+                               //typedef std::vector<std::string> NomItem;
+
+
+                               ListConfigPanel(wxWindow* parent, wxWindowID id,const wxString& title, ListWx* modelList, ListWx* currentList);
+
+                               ~ListConfigPanel();
+
+                               ItemsMap
+                               GetFinalItemsMap();
+
+                               void
+                               SetFinalItems(ItemsMap finalItems);
+
+                               void
+                               FillList(int i);
+
+                               void
+                               OnQuit(wxCommandEvent& event);
+
+                               void
+                               ListItemEvent(wxCommandEvent& event);
+
+                               void
+                               OnAdd(wxCommandEvent& event);
+
+                               void
+                               OnDelete(wxCommandEvent& event);
+
+                               void
+                               OkEvent(wxCommandEvent& event);
+
+                               void
+                               UpEvent(wxCommandEvent& event);
+
+                               void
+                               DownEvent(wxCommandEvent& event);
+
+                               void
+                               RefreshViewEvent(wxCommandEvent& event);
+
+                               ListWx*
+                               GetFinalListWx();
+
+
+                       //public:
+                               //friend class creaButtonContainer::controller::ButtonContainerController;
+
+                       private:
+                               ItemsMap m_itemsMap;
+                               //TFunctor* functor;
+                               ItemsMap m_finalItems;
+                               //NomItem m_itemsVector;
+
+                               wxButton* buttonAdd;
+                               wxButton* buttonDel;
+
+                               wxButton* okButton;
+                               wxButton* cancelButton;
+
+                               wxButton* upButton;
+                               wxButton* downButton;
+
+                               ListWx* m_listWx;
+                               ListWx* m_finalListWx;
+                               ListConfig* m_listConfig;
+
+               };
+
+
+}
+
+#endif // LISTCONFIGPANEL_H