~ubuntu-branches/ubuntu/utopic/ginkgocadx/utopic-proposed

« back to all changes in this revision

Viewing changes to src/cadxcore/main/gui/anonymize/anonymizepanel.cpp

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2014-01-09 07:37:09 UTC
  • mfrom: (1.2.3)
  • Revision ID: package-import@ubuntu.com-20140109073709-rpuh5x3p3finvtze
Tags: 3.6.0.1228.33+dfsg-1
New upstream release [December 2013]

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include <main/controllers/commandcontroller.h>
23
23
#include <main/controllers/historycontroller.h>
24
24
#include <commands/comandoexportacion.h>
 
25
#include <wx/ginkgostyle/ginkgostyle.h>
 
26
/**dcmtk dictionary...*/
 
27
#include <dcmtk/config/osconfig.h>
 
28
#include <dcmtk/dcmdata/dcdict.h>
 
29
#include <dcmtk/dcmdata/dcdicent.h>
 
30
 
 
31
#include <wx/msgdlg.h>
 
32
 
 
33
/**/
 
34
namespace GNC
 
35
{
 
36
        namespace GUI 
 
37
        {
 
38
                class AnonymizeAddTagDialog: public AnonymizeAddTagDialogBase
 
39
                {
 
40
                public:
 
41
                        AnonymizeAddTagDialog(wxWindow* pParent): AnonymizeAddTagDialogBase(pParent)
 
42
                        {
 
43
                                DcmDataDictionary& globalDataDict = dcmDataDict.wrlock();
 
44
                                
 
45
                                wxArrayString listOfStrings;
 
46
                                for (DcmHashDictIterator it = globalDataDict.normalBegin(); it != globalDataDict.normalEnd(); ++it) 
 
47
                                {
 
48
                                        DcmDictEntry entry(*(*it));
 
49
                                        listOfStrings.push_back(wxString::FromUTF8(entry.getTagName()));
 
50
                                }
 
51
                                dcmDataDict.unlock();
 
52
 
 
53
                                listOfStrings.Sort();
 
54
                                m_pTag->Append(listOfStrings);
 
55
 
 
56
                                if (listOfStrings.size() > 0) {
 
57
                                        m_pTag->Select(0);
 
58
                                        wxCommandEvent evt;
 
59
                                        OnTagSelection(evt);
 
60
                                }
 
61
 
 
62
                                m_pBody->Layout();
 
63
                                Layout();
 
64
                        }
 
65
 
 
66
                        virtual void OnTagSelection(wxCommandEvent& /*evt*/)
 
67
                        {
 
68
                                if (m_pTag->GetSelection() >= 0) {
 
69
                                        wxString tagName = m_pTag->GetStringSelection();
 
70
                                        const DcmDataDictionary& globalDataDict = dcmDataDict.rdlock();
 
71
                                        const DcmDictEntry* entry = globalDataDict.findEntry(tagName.ToUTF8());
 
72
                                        dcmDataDict.unlock();
 
73
                                        if (entry != NULL) {
 
74
                                                m_pTextGroup->SetValue(wxString::Format(wxT("%04x"),entry->getGroup()));
 
75
                                                m_pTextElement->SetValue(wxString::Format(wxT("%04x"),entry->getElement()));
 
76
                                        }
 
77
                                }
 
78
                        }
 
79
 
 
80
                        std::string getKey()
 
81
                        {
 
82
                                wxString key;
 
83
                                long group,element;
 
84
                                if (m_pTextGroup->GetValue().ToLong(&group, 16) && m_pTextElement->GetValue().ToLong(&element, 16) && group >= 0 && group < 0xffff && element >= 0 && element < 0xffff) {
 
85
                                        key = wxString::Format(wxT("%04x|%04x"), group, element);
 
86
                                }
 
87
                                return std::string(key.ToUTF8());
 
88
                        }
 
89
 
 
90
                        std::string getValue()
 
91
                        {
 
92
                                return std::string(m_pTextValue->GetValue().ToUTF8());
 
93
                        }
 
94
 
 
95
                        virtual void OnOkClick(wxCommandEvent &evt)
 
96
                        {
 
97
                                long group,element;
 
98
                                if (m_pTextGroup->GetValue().ToLong(&group, 16) && m_pTextElement->GetValue().ToLong(&element, 16) && group >= 0 && group < 0xffff && element >= 0 && element < 0xffff) {
 
99
                                        evt.Skip(true);
 
100
                                } else {
 
101
                                        wxMessageBox(_("Element field or group field have invalid values"),_("Info"),wxOK | wxICON_INFORMATION, this);
 
102
                                        evt.Skip(false);
 
103
                                }
 
104
                        }
 
105
                };
 
106
        }
 
107
}
 
108
 
 
109
/**********************************************************/
25
110
 
26
111
GNC::GUI::AnonymizePanel::AnonymizePanel(wxWindow* pParent): GNC::GUI::AnonymizePanelBase(pParent)
27
112
{
65
150
        for (GNC::GCS::IConfigurationController::TListGroups::iterator it = groups.begin(); it != groups.end(); ++it)
66
151
        {
67
152
                if ((*it).find("tag") != (*it).end() && (*it).find("value") != (*it).end()) {
68
 
                        Anonymize((*it)["tag"], true, (*it)["value"]);
 
153
                        Anonymize((*it)["tag"], true, (*it)["value"], false);
69
154
                }
70
155
        }
71
156
 
171
256
        }
172
257
}
173
258
 
 
259
void GNC::GUI::AnonymizePanel::OnAddNewTag( wxCommandEvent &)
 
260
{
 
261
        AnonymizeAddTagDialog dlg(this);
 
262
        if (dlg.ShowModal() == wxID_OK) {
 
263
                Anonymize(dlg.getKey(), true, dlg.getValue());
 
264
        }
 
265
}
 
266
 
174
267
void GNC::GUI::AnonymizePanel::Anonymize(const std::string& clave, bool anonimizar)
175
268
{
176
269
        wxString value = wxEmptyString;
185
278
        Anonymize(clave, anonimizar, std::string(value.ToUTF8()));
186
279
}
187
280
 
188
 
void GNC::GUI::AnonymizePanel::Anonymize(const std::string& clave, bool anonimizar, const std::string& value)
 
281
void GNC::GUI::AnonymizePanel::Anonymize(const std::string& clave, bool anonimizar, const std::string& value, bool anonymizeIfNotExists )
189
282
{
190
283
        if (MapOfCheck.find(clave) != MapOfCheck.end()) {
191
284
                MapOfCheck[clave]->SetValue(anonimizar);
203
296
                        }
204
297
                        it->ChangeFlag(wxPG_PROP_MODIFIED,anonimizar);
205
298
                        m_pTagsList->RefreshProperty(it);
 
299
                        m_pTagsList->SelectProperty(it, true);
206
300
                        return;
207
301
                }
208
302
        }
 
303
        if (anonymizeIfNotExists) {
 
304
                //key not found... add it to property grid
 
305
                wxStringProperty* prop = NULL;
 
306
                GIL::DICOM::IDICOMManager*      pDICOMManager = GNC::GCS::IEntorno::Instance()->GetPACSController()->CrearInstanciaDeDICOMManager();
 
307
                wxString helpString = wxString::FromUTF8(pDICOMManager->GetDescription(clave).c_str());
 
308
                if(helpString.size()>0) {
 
309
                        helpString = wxT("(") + wxString::FromUTF8(clave.c_str()) + wxT(") ") + helpString;
 
310
                        prop = new wxStringProperty(helpString,
 
311
                                wxPG_LABEL,wxEmptyString);
 
312
                }else{
 
313
                        prop = new wxStringProperty(wxString::FromUTF8(clave.c_str()),
 
314
                                wxPG_LABEL,wxEmptyString);
 
315
                }
 
316
                prop->SetHelpString(wxString::FromUTF8(clave.c_str()));
 
317
                GNC::Entorno::Instance()->GetPACSController()->LiberarInstanciaDeDICOMManager(pDICOMManager);
 
318
 
 
319
                prop->SetValue(wxString::FromUTF8(value.c_str()));
 
320
                prop->ChangeFlag(wxPG_PROP_MODIFIED,anonimizar);
 
321
                if(anonimizar){
 
322
                        m_pTagsList->SetPropertyCell(prop,0,prop->GetLabel(),wxNullBitmap,*wxWHITE,*wxRED);
 
323
                        m_pTagsList->SetPropertyCell(prop,1,prop->GetValue(),wxNullBitmap,*wxWHITE,*wxRED);
 
324
                }
 
325
                m_pTagsList->AppendIn(m_pTagsList->GetRoot(), prop);
 
326
                m_pTagsList->SelectProperty(prop, true);
 
327
        }
209
328
}
210
329
 
211
330