creaImageIO_lib
creaImageIOGimmickView.h
Go to the documentation of this file.
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 __creaImageIOGimmickView_h_INCLUDED__
30 #define __creaImageIOGimmickView_h_INCLUDED__
31 
32 #include <creaImageIOGimmick.h>
33 #include <creaImageIOTreeView.h>
34 #include <creaImageIOSystem.h>
36 
37 //#include <map>
38 #include <vtkImageData.h>
39 #if defined (USE_WXWIDGETS)
41 #endif
42 
43 #if defined(USE_QT)
44 #include "Qt/creaImageIOQMultiThreadImageReader.h"
45 #endif
46 
47 
48 // Signal/slot mechanism for progress events
49 #include <boost/signal.hpp>
50 #include <boost/bind.hpp>
51 
52 #define GIMMICK_NO_IMAGE_SELECTION 0
53 #define GIMMICK_2D_IMAGE_SELECTION 2
54 #define GIMMICK_3D_IMAGE_SELECTION 3
55 #define GIMMICK_4D_IMAGE_SELECTION 4
56 
57 #define NATIVE 0
58 #define _2D 2
59 #define _3D 3
60 
61 namespace creaImageIO
62 {
63  typedef std::map<std::string, std::string> mapInfoDicom;
64 
65  typedef struct
66  {
67  vtkImageData *img;
68  //std::map<std::string, std::string> infos;
70  } OutStrGimmick;
71 
72 
77  class ImageExtent;
78  //=====================================================================
79 
80  //=====================================================================
83  {
84  public:
86  GimmickView(boost::shared_ptr<Gimmick>, int number_of_threads = 0 );
88  virtual ~GimmickView();
92  virtual void Initialize();
93 
96  typedef std::map<std::string, TreeView*> TreeViewMapType;
97 
102  { return mTreeViewMap; }
103 
105  virtual void Finalize();
106 
109 
111  virtual void GetSelectedImagesInVector(std::vector<vtkImageData*>& s, int dim)
112  { GimmickError("INTERNAL ERROR : GetSelectedImagesInVector not implemented"); }
113 
115  virtual void GetSelectedImages(std::vector<vtkImageData*>& s, int dim)
116  { GimmickError("INTERNAL ERROR : GetSelectedImages not implemented"); }
117 
118  virtual void GetSelectedFiles(std::vector<std::string>& s)
119  { GimmickError("INTERNAL ERROR : GetSelectedFiles not implemented"); }
120 
121  virtual void GetImages(int dim, std::vector<std::string> files, std::vector<vtkImageData*>& s)
122  { GimmickError("INTERNAL ERROR : GetImages not implemented"); }
123 
124  virtual void OnSelectionChange(const std::vector<tree::Node*>& s, bool isSelection, int selection, bool mProcess)
125  { GimmickError("INTERNAL ERROR : OnSelectionChange not implemented"); }
126 
127  virtual void ClearSelection()
128  { GimmickError("INTERNAL ERROR : ClearSelection not implemented"); }
129 
131  virtual void AddIgnoreFile(tree::Node* toRemove)
132  { GimmickError("INTERNAL ERROR : AddIgnoreFile not implemented"); }
133 
135  virtual void CopyFiles(const std::vector<std::string>& filenames)
136  { GimmickError("INTERNAL ERROR : CopyFiles not implemented"); }
137 
139  virtual void CreateEditFieldsDialog(tree::Node* node, std::vector<std::string> names, std::vector<std::string> keys)
140  { GimmickError("INTERNAL ERROR : EditFields not implemented"); }
141 
143  void Anonymize(std::vector<std::string> i_filenames, int type);
144 
146  virtual void DumpTags(const std::string filename)
147  {GimmickError("INTERNAL ERROR : DumpTags not implemented"); }
148 
150  virtual void ExportToStorage(const std::vector<std::string> keys)
151  { GimmickError("INTERNAL ERROR : ExportToStorage not implemented"); }
152 
154  virtual void SaveAs(const std::vector<std::string>& filenames)
155  { GimmickError("INTERNAL ERROR : SaveAs not implemented"); }
156 
158  bool NoValidateSelected();
159 
161  bool ValidateSelected (tree::Node* sel, int min_dim, int max_dim);
162 
164  void ReadImagesNotThreaded(std::vector<vtkImageData*>& s,std::vector<std::string> files, int dim);
165 
167  void ReadImagesNotThreadedInVector(std::vector<vtkImageData*>& s,std::vector<std::string> files, int dim);
168 
171  //void RequestReading(tree::Node* n, int prio, int selection_index , ImagePointerHolder *p);
172  void RequestReading(tree::Node* n, int prio, int selection_index , boost::shared_ptr<ImagePointerHolder> p);
173 
175  std::string GetMessage(){return mMess;}
176 
178  void SetMessage(std::string mess){mMess=mess;}
179 
181  void ResetExtent();
182 
184  void CreateTreeViews();
185 
187  void CreateSingleTreeView(std::string &i_name);
188 
190  virtual void CreateTreeView( TreeHandler* )
191  { GimmickError("INTERNAL ERROR : CreateTreeView not implemented"); }
192 
195  virtual void UpdateTreeViewLevel(const std::string&, int l);
196 
197  // Multi-thread image reader callback
198  void OnMultiThreadImageReaderEvent(const std::string& filename,
200  vtkImageData* image);
201 
202  vtkImageData* GetDefaultImage() { return mReader.GetImage(""); }
203 
204  //=============================================
205  typedef boost::signal<void (bool)> ValidationSignalType;
206  typedef ValidationSignalType::slot_function_type ValidationCallbackType;
207  //=============================================
208 
209  //==================================================================
218  //==================================================================
219 
220  void modifyValidationSignal(bool ivalid);
221 
222 
223  void readImages(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
224  OutputAttr i_attr, int i_dim, double i_zspc);
225  bool isSingle(const std::string i_file);
226 
227  void stopReader();
228  private:
229 
230 
231  typedef void (*readXD)(std::vector<OutStrGimmick>&, std::vector<std::string>, OutputAttr, double);
232 
233  void getAttributes(const std::string i_file, std::map<std::string, std::string> &o_infos, OutputAttr i_attr);
234 
235  virtual void readImages2(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
236  OutputAttr i_attr, double i_zspc);
237 
238  virtual void readImages3(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
239  OutputAttr i_attr, double i_zspc);
240 
241  virtual void readImages4(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
242  OutputAttr i_attr);
243 
244  virtual void readImages1(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
245  OutputAttr i_attr);
246 
247 
249  boost::shared_ptr< Gimmick> mGimmick;
250 
253 
255  std::string mMess;
256 
259 
264  {
266  int sel_index = -1)
267 // ImagePointerHolder* ph= 0)
268  : node(no), index(sel_index){}//, pointerHolder(ph){}
269  ImageEventType(vtkImageData* im )
270  : image(im) {}
272  vtkImageData* image;
273  int index;
274  boost::shared_ptr<ImagePointerHolder> pointerHolder;
275  };
276  typedef std::map<std::string,ImageEventType> ImageEventTypeMap;
280 
281  // queue of image event
282  typedef std::deque<ImageEventType> ImageEventQueueType;
283 
284  //ImageEventQueueType mImageEventQueue;
285 
287  boost::shared_ptr<ImageExtent> mImageExtent;
288 
291 
293  bool valid;
294 
297 
298  };
299  // EO class GimmickView
300  //=====================================================================
301 
302 
303 } // EO namespace creaImageIO
304 
305 // EOF
306 #endif