00001 #ifndef __creaImageIOGimmickView_h_INCLUDED__
00002 #define __creaImageIOGimmickView_h_INCLUDED__
00003
00004 #include <creaImageIOGimmick.h>
00005 #include <creaImageIOTreeView.h>
00006 #include <creaImageIOSystem.h>
00007 #include <creaImageIOImagePointerHolder.h>
00008
00009
00010 #include <vtkImageData.h>
00011 #if defined (USE_WXWIDGETS)
00012 #include <creaImageIOMultiThreadImageReader.h>
00013 #endif
00014
00015 #if defined(USE_QT4)
00016 #include <creaImageIOQMultiThreadImageReader.h>
00017 #endif
00018
00019
00020
00021 #include <boost/signal.hpp>
00022 #include <boost/bind.hpp>
00023
00024 #define GIMMICK_NO_IMAGE_SELECTION 0
00025 #define GIMMICK_2D_IMAGE_SELECTION 2
00026 #define GIMMICK_3D_IMAGE_SELECTION 3
00027 #define GIMMICK_4D_IMAGE_SELECTION 4
00028
00029 #define NATIVE 0
00030 #define _2D 2
00031 #define _3D 3
00032
00033 namespace creaImageIO
00034 {
00035 typedef std::map<std::string, std::string> mapInfoDicom;
00036
00037 typedef struct
00038 {
00039 vtkImageData *img;
00040
00041 mapInfoDicom infos;
00042 } OutStrGimmick;
00043
00044
00049 class ImageExtent;
00050
00051
00052
00054 class GimmickView: public MultiThreadImageReaderUser
00055 {
00056 public:
00058 GimmickView(boost::shared_ptr<Gimmick>, int number_of_threads = 0 );
00060 virtual ~GimmickView();
00064 virtual void Initialize();
00065
00068 typedef std::map<std::string, TreeView*> TreeViewMapType;
00069
00071 TreeViewMapType& GetTreeViewMap() { return mTreeViewMap; }
00073 const TreeViewMapType& GetTreeViewMap() const
00074 { return mTreeViewMap; }
00075
00077 virtual void Finalize();
00078
00080 int GetMaximalPriority(){return mReader.GetMaximalPriority();}
00081
00083 virtual void GetSelectedImagesInVector(std::vector<vtkImageData*>& s, int dim)
00084 { GimmickError("INTERNAL ERROR : GetSelectedImagesInVector not implemented"); }
00085
00087 virtual void GetSelectedImages(std::vector<vtkImageData*>& s, int dim)
00088 { GimmickError("INTERNAL ERROR : GetSelectedImages not implemented"); }
00089
00090 virtual void GetSelectedFiles(std::vector<std::string>& s)
00091 { GimmickError("INTERNAL ERROR : GetSelectedFiles not implemented"); }
00092
00093 virtual void GetImages(int dim, std::vector<std::string> files, std::vector<vtkImageData*>& s)
00094 { GimmickError("INTERNAL ERROR : GetImages not implemented"); }
00095
00096 virtual void OnSelectionChange(const std::vector<tree::Node*>& s, bool isSelection, int selection, bool mProcess)
00097 { GimmickError("INTERNAL ERROR : OnSelectionChange not implemented"); }
00098
00099 virtual void ClearSelection()
00100 { GimmickError("INTERNAL ERROR : ClearSelection not implemented"); }
00101
00103 virtual void AddIgnoreFile(tree::Node* toRemove)
00104 { GimmickError("INTERNAL ERROR : AddIgnoreFile not implemented"); }
00105
00107 virtual void CopyFiles(const std::vector<std::string>& filenames)
00108 { GimmickError("INTERNAL ERROR : CopyFiles not implemented"); }
00109
00111 virtual void CreateEditFieldsDialog(tree::Node* node, std::vector<std::string> names, std::vector<std::string> keys)
00112 { GimmickError("INTERNAL ERROR : EditFields not implemented"); }
00113
00115 virtual void Anonymize(std::vector<std::string> i_filenames, int type)
00116 { GimmickError("INTERNAL ERROR : Anonymize not implemented"); }
00117
00119 virtual void DumpTags(const std::string filename)
00120 {GimmickError("INTERNAL ERROR : DumpTags not implemented"); }
00121
00123 virtual void ExportToStorage(const std::vector<std::string> keys)
00124 { GimmickError("INTERNAL ERROR : ExportToStorage not implemented"); }
00125
00127 virtual void SaveAs(const std::vector<std::string>& filenames)
00128 { GimmickError("INTERNAL ERROR : SaveAs not implemented"); }
00129
00131 bool NoValidateSelected();
00132
00134 bool ValidateSelected (tree::Node* sel, int min_dim, int max_dim);
00135
00137 void ReadImagesNotThreaded(std::vector<vtkImageData*>& s,std::vector<std::string> files, int dim);
00138
00140 void ReadImagesNotThreadedInVector(std::vector<vtkImageData*>& s,std::vector<std::string> files, int dim);
00141
00144
00145 void RequestReading(tree::Node* n, int prio, int selection_index , boost::shared_ptr<ImagePointerHolder> p);
00146
00148 std::string GetMessage(){return mMess;}
00149
00151 void SetMessage(std::string mess){mMess=mess;}
00152
00154 void ResetExtent();
00155
00157 void CreateTreeViews();
00158
00160 void CreateSingleTreeView(std::string &i_name);
00161
00163 virtual void CreateTreeView( TreeHandler* )
00164 { GimmickError("INTERNAL ERROR : CreateTreeView not implemented"); }
00165
00168 virtual void UpdateTreeViewLevel(const std::string&, int l);
00169
00170
00171 void OnMultiThreadImageReaderEvent(const std::string& filename,
00172 MultiThreadImageReaderUser::EventType t,
00173 vtkImageData* image);
00174
00175 vtkImageData* GetDefaultImage() { return mReader.GetImage(""); }
00176
00177
00178 typedef boost::signal<void (bool)> ValidationSignalType;
00179 typedef ValidationSignalType::slot_function_type ValidationCallbackType;
00180
00181
00182
00190 void ConnectValidationObserver(ValidationCallbackType callback);
00191
00192
00193 void modifyValidationSignal(bool ivalid);
00194
00195
00196 void readImages(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
00197 OutputAttr i_attr, int i_dim, double i_zspc);
00198 bool isSingle(const std::string i_file);
00199
00200 void stopReader();
00201 private:
00202
00203
00204 typedef void (*readXD)(std::vector<OutStrGimmick>&, std::vector<std::string>, OutputAttr, double);
00205
00206 void getAttributes(const std::string i_file, std::map<std::string, std::string> &o_infos, OutputAttr i_attr);
00207
00208 virtual void readImages2(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
00209 OutputAttr i_attr, double i_zspc);
00210
00211 virtual void readImages3(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
00212 OutputAttr i_attr, double i_zspc);
00213
00214 virtual void readImages4(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
00215 OutputAttr i_attr);
00216
00217 virtual void readImages1(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
00218 OutputAttr i_attr);
00219
00220
00222 boost::shared_ptr< Gimmick> mGimmick;
00223
00225 TreeViewMapType mTreeViewMap;
00226
00228 std::string mMess;
00229
00231 MultiThreadImageReader mReader;
00232
00236 struct ImageEventType
00237 {
00238 ImageEventType( tree::Node* no = 0,
00239 int sel_index = -1)
00240
00241 : node(no), index(sel_index){}
00242 ImageEventType(vtkImageData* im )
00243 : image(im) {}
00244 tree::Node* node;
00245 vtkImageData* image;
00246 int index;
00247 boost::shared_ptr<ImagePointerHolder> pointerHolder;
00248 };
00249 typedef std::map<std::string,ImageEventType> ImageEventTypeMap;
00252 ImageEventTypeMap mImageEventMap;
00253
00254
00255 typedef std::deque<ImageEventType> ImageEventQueueType;
00256
00257
00258
00260 boost::shared_ptr<ImageExtent> mImageExtent;
00261
00263 ValidationSignalType mValidationSignal;
00264
00266 bool valid;
00267
00269 bool mReaderStarted;
00270
00271 };
00272
00273
00274
00275
00276 }
00277
00278
00279 #endif