]> Creatis software - creaImageIO.git/blob - src/creaImageIOWxDescriptorPanel.h
#3185 creaImageIO Feature New Normal - Clean code
[creaImageIO.git] / src / creaImageIOWxDescriptorPanel.h
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
5 #                        pour la Santé)
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
9 #
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.
16 #
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
21 #  liability. 
22 #
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 # ------------------------------------------------------------------------
26 */
27
28
29 #ifndef __creaImageIOWxDescriptorPanel_h_INCLUDED__
30 #define __creaImageIOWxDescriptorPanel_h_INCLUDED__
31
32 #ifdef USE_WXWIDGETS
33 #include <creaWx.h>
34 #include <string>
35 #include <map>
36 #include <vector>
37 #include <creaImageIOWxGimmickView.h>
38 #include <wx/listctrl.h>
39 #include <wx/statline.h>
40
41
42 #define ID_DESCRIPTOR 1500
43 #define ID_LEVEL_CTRL        ID_DESCRIPTOR+1
44 #define ID_LEVEL_ADD         ID_DESCRIPTOR+2
45 #define ID_GR_CTRL               ID_DESCRIPTOR+3
46 #define ID_EL_CTRL               ID_DESCRIPTOR+4
47 #define ID_NAME_CTRL         ID_DESCRIPTOR+5
48 #define ID_ATTRIBUTE_CTRL        ID_DESCRIPTOR+6
49 #define ID_ATTRIBUTE_ADD         ID_DESCRIPTOR+7
50 #define ID_REMOVE_ADD            ID_DESCRIPTOR+8
51 #define ID_DSCP_APPLY            ID_DESCRIPTOR+9
52
53 namespace creaImageIO
54 {
55
56   /**
57    * \ingroup GUI
58    */
59   //=====================================================================
60  //=====================================================================
61  /// Gimmick DB are based on descriptors with a tree structure .
62  /// Each level contains attributes (DICOM or other) to identify data
63  /// WxDescriptorPanel allows creation, modification and save of descriptors. 
64  ///
65
66   class WxDescriptorPanel : public wxDialog
67   {
68   public:
69     WxDescriptorPanel();    
70         WxDescriptorPanel(wxWindow *parent, const std::string path);
71     ~WxDescriptorPanel();
72
73         // Get file to load Descriptor
74         const std::string& GetDescriptor(){ return m_DscpFile;}
75
76   private :
77
78     // WxControls
79         wxTextCtrl *LevelCtrl;  //TextCtrl to enter level's name
80         wxTextCtrl *GRCtrl;     // TextCtrl to enter DICOM Group value
81         wxTextCtrl *ELCtrl;     // TextCtrl to enter DICOM element value
82         wxTextCtrl *ResultCtrl; //TextCtrl to visualize Descriptor
83         wxComboBox *AttributeCombo; // Combox to choose Attribute values
84
85         /// Add an attribute (DICOM or own) 
86         void OnAddAttribute(wxCommandEvent& event);
87
88         /// Add an attribute (DICOM or own)
89         void onAddAttribute( const std::string &att, const std::string &name_att, std::string level = "");
90
91         /// Add a Level 
92         void OnAddLevel(wxCommandEvent& event);
93         
94         /// Add a Level 
95         void onAddLevel(const std::string &level);
96
97         /// Find a DICOM attribute from group and element values
98         void OnDicomAttribute(wxCommandEvent& event);
99
100         /// Remove a value (level or attribute)
101         void OnRemove(wxCommandEvent& event);
102
103         /// Create a new descriptor
104         void OnNew(wxCommandEvent& event);
105
106         /// Load an exsitant descriptor
107         void OnLoad(wxCommandEvent& event);
108
109         /// Save a descriptor
110         void OnOK(wxCommandEvent& event);
111
112         /// Save a descriptor and use it
113         void OnApply(wxCommandEvent& event);
114
115         /// Cancel
116         void OnCancel(wxCommandEvent& event);
117
118         /// Create a descriptor structure
119         void CreateDescriptor(int type);
120
121         /// add a level
122         bool addLevel(const std::string &name);
123
124         /// add an attribute
125         bool addAtribute(const std::string &level, const std::string &name);
126
127         /// remove an attribute
128         bool RemoveAttribute(const std::string &level, const std::string &name);
129
130         /// remove a level
131         bool RemoveLevel(const std::string &name);
132
133         /// Create a descriptor file
134         void createDescriptorFile();
135         
136         /// load a descriptor file
137         void loadDescriptor(const std::string i_name);
138
139         /// find a level'name 
140         std::string findLevel();
141
142         /// determine values for own attributes
143         std::string OwnAttribute(const std::string name);
144
145         /// save a descriptor in a file
146         const std::string saveDescriptor();
147
148         /// number of level 
149         int lv;
150
151         /// Insert point in result control
152         long InsertPt;
153
154         /// Output file for Descriptor
155         std::string m_DscpFile;
156
157         /// Output Descriptor
158         std::string outDscp; 
159         
160         // Vector of attributes
161         std::vector<std::string> VLevel;
162
163         // map of level, attributes
164         std::map<std::string, std::vector<std::string> > DscpTree;
165
166         // map of own application attributes
167         std::map<std::string, std::string> ownatt;
168
169         // List of added level
170         std::map<int, std::string> lvlist;
171
172         // DB Gimmick path
173         std::string m_path;
174
175   }; // class WxDescriptorPanel
176   //=====================================================================
177
178   
179 } // EO namespace creaImageIO
180
181
182 #endif // USE_WIDGETS
183 // EOF
184 #endif
185