1 #ifndef __creaImageIOGimmickView_h_INCLUDED__
2 #define __creaImageIOGimmickView_h_INCLUDED__
4 #include <creaImageIOGimmick.h>
5 #include <creaImageIOTreeView.h>
6 #include <creaImageIOSystem.h>
9 #include <vtkImageData.h>
10 #include <creaImageIOMultiThreadImageReader.h>
12 #define GIMMICK_NO_IMAGE_SELECTION 0
13 #define GIMMICK_2D_IMAGE_SELECTION 2
14 #define GIMMICK_3D_IMAGE_SELECTION 3
15 #define GIMMICK_4D_IMAGE_SELECTION 4
27 //=====================================================================
29 //=====================================================================
30 ///Abstract class that handles views, attributes and previews (GUI) for Gimmick.
31 class GimmickView: public MultiThreadImageReaderUser
35 GimmickView(Gimmick*, int number_of_threads = 0 );
36 /// Virtual destructor
37 virtual ~GimmickView();
40 /// Initializes the view :
41 /// Creates the TreeViews for all the TreeHandler of the Controller
43 virtual void Initialize();
45 /// Type of map from View name to TreeView*
46 /// (This map is equivalent for Views of the TreeHandlerMap of Gimmick)
47 typedef std::map<std::string, TreeView*> TreeViewMapType;
49 /// Returns the TreeViewMap (ref)
50 TreeViewMapType& GetTreeViewMap() { return mTreeViewMap; }
51 /// Returns the TreeViewMap (const ref)
52 const TreeViewMapType& GetTreeViewMap() const
53 { return mTreeViewMap; }
56 virtual void Finalize();
58 ///Returns the selected Images and validates to see if they comply with the given parameter(<4D)
59 vtkImageData* GetSelectedImage(int dim);
60 ///Adds the selected Images to the given vector and validates to see if they comply with the given parameter (4D)
61 virtual void GetSelectedImages(std::vector<vtkImageData*>& s, int dim)
62 { GimmickError("INTERNAL ERROR : GetSelectedImages not implemented"); }
64 virtual void GetSelectedFiles(std::vector<std::string>& s)
65 { GimmickError("INTERNAL ERROR : GetSelectedFiles not implemented"); }
67 ///Validates the dimension compliance of the images with the maximum and minimum given, and between their sizes
68 bool ValidateSelected (std::vector<tree::Node*>& sel, int min_dim, int max_dim);
70 ///Reads the vector of nodes, builds images in the dimension required and returns them in the supplied vector.
71 void ReadImagesNotThreaded(std::vector<vtkImageData*>& s,std::vector<tree::Node*> im, int dim);
73 ///Obtains the message of the state
74 std::string GetMessage(){return mMess;}
75 ///Obtains the message of the state
76 void SetMessage(std::string mess){mMess=mess;}
78 /// Create the tree views
79 void CreateTreeViews();
81 /// Create the tree view for TreeHandler provided
82 virtual void CreateTreeView( TreeHandler*)
83 { GimmickError("INTERNAL ERROR : CreateTreeView not implemented"); }
85 /// Updates the TreeView of given name from level l to bottom
86 /// (calls the virtual method TreeView::UpdateLevel(l))
87 virtual void UpdateTreeViewLevel(const std::string&, int l);
90 /// Controller which manages the interaction with the model
93 TreeViewMapType mTreeViewMap;
94 /// The message that results from the validation
96 /// Multi-thread image reader
97 MultiThreadImageReader mReader;
101 // EO class GimmickView
102 //=====================================================================
114 //====================================================================
116 //====================================================================
118 /// Returns the size of the current selection
119 virtual int GetSelectionSize() { return 0; }
120 /// Returns true if there is a valid selection
121 virtual bool IsSelectionValid(){ return false; }
122 /// Returns the vector of full filenames of selected images
123 virtual void GetSelectedFiles(std::vector<std::string>&){ return; }
124 /// Returns the vector of images corresponding to selection
125 virtual void GetSelectedImages(std::vector<vtkImageData*>&){ return; }
126 /// Returns the vector of DicomNode corresponding to selection
127 virtual void GetSelectedDicomNodes(std::vector<DicomNode*>&){ return; }
128 /// Returns the DicomNode corresponding to the tree item
129 virtual DicomNode* GetDicomNodeOfItem(const TreeItemId& i);
132 /// Type of list of DicomDatabase
133 typedef std::vector<DicomDatabase*> DicomDatabaseListType;
134 /// Returns the list of DicomDatabase open
135 virtual DicomDatabaseListType& GetDicomDatabaseList()
137 /// Returns the list of DicomDatabase open (const)
138 virtual const DicomDatabaseListType& GetDicomDatabaseList() const
142 ///Opens an existing database, or else, creates a local database.
143 virtual void OpenOrNewDatabase(bool open){ return; }
145 virtual void ShowHelp();
148 ///Gets the extension of the database
149 const std::string& GetDatabaseExtension() { return null; }
150 ///Sets the extension of the database
151 virtual void SetDatabaseExtension(const std::string& ext){ return; }
154 //====================================================================
155 // Preview Display Related
156 //====================================================================
159 ///Shows the image sent as a parameter
161 virtual void ShowImage(vtkImageData* image){ return; }
163 //====================================================================
165 //====================================================================
169 ///Loads or creates a favorites database
170 virtual void LoadOrCreateFavoritesDatabase(){ return; }
172 ///Creates the user settings directory
173 void CreateUserSettingsDirectory(){ return; }
174 ///Obtains the user settings directory
175 const std::string& GetUserSettingsDirectory(){ return null; }
177 //====================================================================
178 // Attribute Display Related
179 //====================================================================
182 ///Shows the Information regarding the node sent as a parameter
184 virtual void ShowInformation(DicomNode*){ return; }
186 //====================================================================
187 // Tree Display Related
188 //====================================================================
191 /// Completely rebuilds the view with
192 /// current DicomDatabaseList
193 virtual void RebuildView(){ return; }
194 /// Recursively updates the part of the view corresponding
195 /// to the DicomDatabase passed
196 /// i.e. creates items for the DicomNode which do not have
197 /// deletes obsolete items (whose DicomNode has been deleted)
198 virtual void UpdateDicomDatabaseView(DicomDatabase*){ return; }
199 /// Recursively updates the part of the view corresponding
200 /// to the DicomNode provided.
201 /// parent is its parent in the tree (where to insert / remove it)
202 virtual void UpdateDicomNodeView(DicomNode* n, const TreeItemId& parent){ return; }
205 ///Type definition of the data regarding the tree
206 typedef WxGimmickTreeItemData TreeItemData;
207 ///Gets the item data of the tree item passed as a parameter
208 TreeItemData* GetItemData(const TreeItemId& id){ return null; }
209 ///Type definition of the data insid a node of the tree
210 typedef WxGimmickDicomNodeData NodeData;
213 //====================================================================
215 //====================================================================
219 int mSelectionMaxImageDimension;
220 int mCurrentSelectionImageSize[4];
222 ///Existent Database List
223 DicomDatabaseListType mDicomDatabaseList;
224 ///Favorites database
225 DicomDatabase* mFavoriteDatabase;
227 ///Path to the database list file
228 std::string mDatabaseListFile;
229 ///Extension of the database
230 std::string mDatabaseExtension;
234 int mFirstDicomDatabaseIconIndex;
237 vtkImageViewer2* mViewer;
239 int mx1,mx2,my1,my2,mz1,mz2;
240 double mspx,mspy,mspz;
243 // Multi-thread image reader
244 MultiThreadImageReader mReader;
245 // map of images name to node
246 std::map<std::string,DicomNode*> mImageFileNameToNode;
249 } // EO namespace creaImageIO