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 #include <creaImageIOMultiThreadImageReader.h>
00012
00013
00014 #include <boost/signal.hpp>
00015 #include <boost/bind.hpp>
00016
00017 #define GIMMICK_NO_IMAGE_SELECTION 0
00018 #define GIMMICK_2D_IMAGE_SELECTION 2
00019 #define GIMMICK_3D_IMAGE_SELECTION 3
00020 #define GIMMICK_4D_IMAGE_SELECTION 4
00021
00022 #define NATIVE 0
00023 #define _2D 2
00024 #define _3D 3
00025
00026
00027 namespace creaImageIO
00028 {
00033 class ImageExtent;
00034
00035
00036
00038 class GimmickView: public MultiThreadImageReaderUser
00039 {
00040 public:
00042 GimmickView(Gimmick*, int number_of_threads = 0 );
00044 virtual ~GimmickView();
00048 virtual void Initialize();
00049
00052 typedef std::map<std::string, TreeView*> TreeViewMapType;
00053
00055 TreeViewMapType& GetTreeViewMap() { return mTreeViewMap; }
00057 const TreeViewMapType& GetTreeViewMap() const
00058 { return mTreeViewMap; }
00059
00061 virtual void Finalize();
00062
00063
00064 int GetMaximalPriority(){return mReader.GetMaximalPriority();}
00065
00067 virtual void GetSelectedImages(std::vector<vtkImageData*>& s, int dim)
00068 { GimmickError("INTERNAL ERROR : GetSelectedImages not implemented"); }
00069
00070 virtual void GetSelectedFiles(std::vector<std::string>& s)
00071 { GimmickError("INTERNAL ERROR : GetSelectedFiles not implemented"); }
00072
00073 virtual void GetImages(int dim, std::vector<std::string> files, std::vector<vtkImageData*>& s)
00074 { GimmickError("INTERNAL ERROR : GetImages not implemented"); }
00075
00076 virtual void OnSelectionChange(const std::vector<tree::Node*>& s, bool isSelection, int selection, bool mProcess)
00077 { GimmickError("INTERNAL ERROR : OnSelectionChange not implemented"); }
00078
00079 virtual void ClearSelection()
00080 { GimmickError("INTERNAL ERROR : ClearSelection not implemented"); }
00081
00083 virtual void AddIgnoreFile(tree::Node* toRemove)
00084 { GimmickError("INTERNAL ERROR : AddIgnoreFile not implemented"); }
00085
00087 virtual void CopyFiles(const std::vector<std::string>& filenames)
00088 { GimmickError("INTERNAL ERROR : CopyFiles not implemented"); }
00089
00091 virtual void CreateEditFieldsDialog(tree::Node* node, std::vector<std::string> names, std::vector<std::string> keys)
00092 { GimmickError("INTERNAL ERROR : EditFields not implemented"); }
00093
00095 bool ValidateSelected (tree::Node* sel, int min_dim, int max_dim);
00096
00098 void ReadImagesNotThreaded(std::vector<vtkImageData*>& s,std::vector<std::string> files, int dim);
00101 void RequestReading(tree::Node* n, int prio, int selection_index , ImagePointerHolder *p);
00102
00103
00105 std::string GetMessage(){return mMess;}
00107 void SetMessage(std::string mess){mMess=mess;}
00109 void ResetExtent();
00110
00112 void CreateTreeViews();
00113
00115 void CreateSingleTreeView(std::string &i_name);
00116
00118 virtual void CreateTreeView( TreeHandler* )
00119 { GimmickError("INTERNAL ERROR : CreateTreeView not implemented"); }
00120
00123 virtual void UpdateTreeViewLevel(const std::string&, int l);
00124
00125 void OnMultiThreadImageReaderEvent(const std::string& filename,
00126 MultiThreadImageReaderUser::EventType t,
00127 vtkImageData* image);
00128
00129 vtkImageData* GetDefaultImage() { return mReader.GetImage(""); }
00130
00131
00132
00133 typedef boost::signal<void (bool)> ValidationSignalType;
00134 typedef ValidationSignalType::slot_function_type ValidationCallbackType;
00135
00136
00137
00145 void ConnectValidationObserver(ValidationCallbackType callback);
00146
00147
00148
00149
00150 void modifyValidationSignal(bool ivalid);
00151
00152 private:
00153
00155 Gimmick* mGimmick;
00157 TreeViewMapType mTreeViewMap;
00159 std::string mMess;
00160
00162 MultiThreadImageReader mReader;
00166 struct ImageEventType
00167 {
00168 ImageEventType( tree::Node* no = 0,
00169 int sel_index = -1,
00170 ImagePointerHolder* ph= 0)
00171 : node(no), index(sel_index), pointerHolder(ph){}
00172 ImageEventType(vtkImageData* im )
00173 : image(im) {}
00174 tree::Node* node;
00175 vtkImageData* image;
00176 int index;
00177 ImagePointerHolder* pointerHolder;
00178 };
00179 typedef std::map<std::string,ImageEventType> ImageEventTypeMap;
00182 ImageEventTypeMap mImageEventMap;
00183
00184 typedef std::deque<ImageEventType> ImageEventQueueType;
00185
00186
00188 ImageExtent* mImageExtent;
00190 ValidationSignalType mValidationSignal;
00192 bool valid;
00194 bool mReaderStarted;
00195
00196 };
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00215
00217
00219
00221
00223
00225
00226
00227
00229
00231
00232
00234
00235
00236
00237
00239
00241
00242
00243
00245
00247
00248
00249
00250
00251
00252
00253
00254
00256
00257
00258
00259
00260
00261
00262
00263
00264
00266
00267
00269
00271
00272
00273
00274
00275
00276
00277
00279
00280
00281
00282
00283
00284
00285
00286
00289
00294
00298
00299
00300
00302
00304
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00319
00321
00322
00324
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345 }
00346
00347
00348 #endif