SIVIC API  0.9.26
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
svkDataModel.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2009-2014 The Regents of the University of California.
3  * All Rights Reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * • Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  * • Redistributions in binary form must reproduce the above copyright notice,
10  * this list of conditions and the following disclaimer in the documentation
11  * and/or other materials provided with the distribution.
12  * • None of the names of any campus of the University of California, the name
13  * "The Regents of the University of California," or the names of any of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
26  * OF SUCH DAMAGE.
27  */
28 
29 
30 
31 /*
32  * $URL$
33  * $Rev$
34  * $Author$
35  * $Date$
36  *
37  * Authors:
38  * Jason C. Crane, Ph.D.
39  * Beck Olson
40  */
41 
42 
43 #ifndef SVK_DATA_MODEL_H
44 #define SVK_DATA_MODEL_H
45 
46 
47 #include <svkImageData.h>
48 #include <map>
49 #include <vtkObject.h>
50 #include <string>
51 #include <vtkImageData.h>
52 #include <vtkObjectFactory.h>
53 #include <vtkImageFlip.h>
54 #include <vtkCallbackCommand.h>
55 #include <svkImageReaderFactory.h>
56 #include <svkImageDataFactory.h>
57 #include <vtkAlgorithmOutput.h>
58 #include <vtkTrivialProducer.h>
59 #include <vtkSmartPointer.h>
60 
61 #include <vtkAlgorithm.h>
62 #include <vtkImageReader2.h>
63 
64 #include <svkImageWriterFactory.h>
65 #include <svkImageWriter.h>
66 
67 
68 namespace svk {
69 
70 
71 using std::string;
72 using std::map;
73 
74 
83 class svkDataModel : public vtkObject
84 {
85 
86  public:
87 
88  // vtk type revision macro
89  vtkTypeMacro( svkDataModel,vtkObject );
90 
91  static svkDataModel* New();
92 
93  svkDataModel();
94  ~svkDataModel();
95 
96  // DataObject manipulators
97  virtual bool AddDataObject( string objectName, svkImageData* dataObject );
98  virtual bool RemoveDataObject( string objectName );
99  virtual void RemoveAllDataObjects( );
100  virtual bool ChangeDataObject(string objectName, svkImageData* dataObject);
101  virtual bool ReplaceDataFromFile(string objectName, string fileName);
102  virtual svkImageData* GetDataObject( string objectName );
103  virtual map<string, svkImageData*> GetAllDataObjects( );
104 
105  // For storing filenames...
106  virtual bool SetDataFileName( string objectName, string fileName );
107  virtual string GetDataFileName( string objectName );
108 
109  // File loaders
110  virtual svkImageData* LoadFile( string fileName, bool onlyOneInputFile = false );
111  svkDcmHeader* GetDcmHeader( string fileName );
112  virtual svkImageData* AddFileToModel(string objectName, string fileName, bool onlyOneInputFile = false);
113 
114  // File writers
115  virtual bool WriteToFile( string objectName, string fileName);
116 
117  // File writers
118  virtual bool WriteToFile(svkImageData *data, const char *fileName);
119 
120  // State manipulators
121  virtual map < string, void* > GetModelState();
122  virtual void SetModelState( map< string, void* > modelState );
123  virtual bool AddState( string stateName, void* stateValue );
124  virtual bool ChangeState( string stateName, void* stateValue );
125  virtual void* GetState( string stateName );
126 
127  // Existence checks for objects and states
128  virtual bool DataExists( string objectName );
129  virtual bool StateExists( string stateName );
130  string GetProgressText( );
131  void SetProgressText( string progressText );
132 
133 
134  private:
135 
141  map<string, svkImageData*> allDataObjectsByKeyName;
142  map<string, string > allDataFileNamesByKeyName;
143  static void UpdateProgressCallback(vtkObject* subject, unsigned long, void* thisObject, void* callData);
144  void UpdateProgress(double amount);
145 
146 
152  map<string, void*> modelState;
153  svkImageReader2* reader;
154 
155  svkImageData* currentData;
156 
157  string progressText;
158  vtkCallbackCommand* progressCallback;
159 
160 };
161 
162 
163 } //svk
164 
165 
166 #endif //SVK_DATA_MODEL_H
string GetProgressText()
Definition: svkDataModel.cc:517
vtkTypeMacro(svkDataModel, vtkObject)
Definition: svkDcmHeader.h:66
Definition: svkImageReader2.h:60
virtual void SetModelState(map< string, void * > modelState)
Definition: svkDataModel.cc:399
virtual void * GetState(string stateName)
Definition: svkDataModel.cc:457
svkDcmHeader * GetDcmHeader(string fileName)
Definition: svkDataModel.cc:322
virtual svkImageData * GetDataObject(string objectName)
Definition: svkDataModel.cc:214
static svkDataModel * New()
virtual bool RemoveDataObject(string objectName)
Definition: svkDataModel.cc:124
virtual map< string, svkImageData * > GetAllDataObjects()
Definition: svkDataModel.cc:226
virtual string GetDataFileName(string objectName)
Definition: svkDataModel.cc:250
virtual bool ChangeDataObject(string objectName, svkImageData *dataObject)
Definition: svkDataModel.cc:162
virtual bool ReplaceDataFromFile(string objectName, string fileName)
Definition: svkDataModel.cc:190
virtual bool DataExists(string objectName)
Definition: svkDataModel.cc:474
virtual svkImageData * AddFileToModel(string objectName, string fileName, bool onlyOneInputFile=false)
Definition: svkDataModel.cc:336
~svkDataModel()
Destructor.
Definition: svkDataModel.cc:69
virtual map< string, void * > GetModelState()
Definition: svkDataModel.cc:388
virtual svkImageData * LoadFile(string fileName, bool onlyOneInputFile=false)
Definition: svkDataModel.cc:273
virtual bool StateExists(string stateName)
Definition: svkDataModel.cc:497
void SetProgressText(string progressText)
Definition: svkDataModel.cc:512
virtual bool AddDataObject(string objectName, svkImageData *dataObject)
Definition: svkDataModel.cc:102
virtual bool ChangeState(string stateName, void *stateValue)
Definition: svkDataModel.cc:436
virtual void RemoveAllDataObjects()
Definition: svkDataModel.cc:140
Definition: svkDataModel.h:83
virtual bool SetDataFileName(string objectName, string fileName)
Definition: svkDataModel.cc:235
Definition: svkImageData.h:107
svkDataModel()
Constructor.
Definition: svkDataModel.cc:53
virtual bool AddState(string stateName, void *stateValue)
Definition: svkDataModel.cc:415
virtual bool WriteToFile(string objectName, string fileName)
Definition: svkDataModel.cc:352