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