2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------
29 #include <creaImageIOWxAttributeSelectionPanel.h>
30 #include <creaImageIOSystem.h>
32 #include <creaImageIOGimmick.h>
38 const int ID_COMBO = 180;
40 WxAttributeSelectionPanel::WxAttributeSelectionPanel(wxWindow *parent,
43 std::vector<std::string> sAtts,
44 std::vector<std::string> nsAtts,
47 -1, wxDefaultPosition,
61 GimmickDebugMessage(1,"WxCustomizeConfigPanel::WxCustomizeConfigPanel"
63 /// \TODO fix warning: unused variable aa
64 wxStaticText * aa = new wxStaticText(this,-1,_T(" Currently shown attributes for level: "), wxPoint(5,10));
66 std::stringstream out;
67 for(int i=1;i<=numLev;i++)
70 as.Add(crea::std2wx(out.str()));
73 levels=new wxComboBox(this, ID_COMBO,_T("1"),wxPoint(190, 5),wxDefaultSize,as);
74 /// \TODO fix warning: unused variable na
75 wxStaticText * na=new wxStaticText(this,-1,_T(" Currently hidden attributes: "), wxPoint(255,10));
77 shownAtts=new wxListCtrl(this, wxID_ANY, wxPoint(5,30), wxSize(160,90), wxLC_REPORT | wxLC_NO_HEADER );
79 shownAtts->InsertColumn(0,
82 shownAtts->SetColumnWidth(0,155);
85 wxButton *add = new wxButton(this,wxID_ANY,_T(">>"), wxPoint(170,50) );
86 Connect( add->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAttributeSelectionPanel::OnAdd );
88 wxButton *remove = new wxButton(this,wxID_ANY,_T("<<"), wxPoint(170,70) );
89 Connect( remove->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAttributeSelectionPanel::OnRemove );
91 notShownAtts=new wxListCtrl(this, wxID_ANY, wxPoint(255,30), wxSize(160,90), wxLC_REPORT | wxLC_NO_HEADER );
93 notShownAtts->InsertColumn(0,
96 notShownAtts->SetColumnWidth(0,155);
100 wxButton *save = new wxButton(this,wxID_ANY,_T("Save Changes"), wxPoint(5,130) );
101 Connect( save->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAttributeSelectionPanel::OnSaveConfig );
107 WxAttributeSelectionPanel::~WxAttributeSelectionPanel()
109 GimmickDebugMessage(1,"WxAttributeSelectionPanel::~WxAttributeSelectionPanel"
113 void WxAttributeSelectionPanel::OnSaveConfig(wxCommandEvent& event)
115 int n=levels->GetSelection();
117 mView->OnAttributesChanged(notShownA,n);
121 void WxAttributeSelectionPanel::OnAdd(wxCommandEvent& event)
126 item = shownAtts->GetNextItem(item,
128 wxLIST_STATE_SELECTED);
132 std::string change = crea::wx2std(shownAtts->GetItemText(item));
133 std::vector<std::string>::iterator it;
135 for(it=shownA.begin();it!=shownA.end()&&!found;++it)
137 if((*it).compare(change)==0)
143 notShownA.push_back(change);
149 void WxAttributeSelectionPanel::OnRemove(wxCommandEvent& event)
155 item = notShownAtts->GetNextItem(item,
157 wxLIST_STATE_SELECTED);
161 std::string change = crea::wx2std(notShownAtts->GetItemText(item));
162 std::vector<std::string>::iterator it;
164 for(it=notShownA.begin();it!=notShownA.end()&&!found;++it)
166 if((*it).compare(change)==0)
171 notShownA.erase(it-1);
172 shownA.push_back(change);
180 void WxAttributeSelectionPanel::LoadCtrls()
184 item.SetMask(wxLIST_MASK_STATE |
186 // wxLIST_MASK_IMAGE |
188 // wxLIST_MASK_WIDTH |
191 std::vector<std::string>::iterator it;
192 shownAtts->DeleteAllItems();
193 notShownAtts->DeleteAllItems();
194 for(it=shownA.begin();it!=shownA.end();++it)
196 item.SetText(crea::std2wx(*it));
197 shownAtts->InsertItem(item);
201 for(it=notShownA.begin();it!=notShownA.end();++it)
203 item.SetText(crea::std2wx(*it));
204 notShownAtts->InsertItem(item);
208 void WxAttributeSelectionPanel::OnComboChange(wxCommandEvent& event)
210 int n=levels->GetSelection()+1;
211 mView->GetVisibleAttributes(shownA,notShownA,n);
215 //======================================================================
216 BEGIN_EVENT_TABLE(WxAttributeSelectionPanel, wxPanel)
217 EVT_COMBOBOX (ID_COMBO,WxAttributeSelectionPanel::OnComboChange)
219 //======================================================================
221 } // EO namespace creaImageIO