MorphoGraphX
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Store.hpp
1 #ifndef STORE_HPP
2 #define STORE_HPP
3 
4 #include <Config.hpp>
5 
6 #include <Geometry.hpp>
7 #include <thrust/host_vector.h>
8 #include <TransferFunction.hpp>
9 
10 namespace mgx {
11 
12 namespace process {
13 class SetupProcess;
14 } // namespace process
15 
16 typedef unsigned short ushort;
17 typedef thrust::host_vector<ushort> HVecUS;
18 
19 class Stack;
25 class mgx_EXPORT Store {
26  friend class process::SetupProcess;
27 
28 public:
32  Store(Stack* stack);
33 
37  Store(const Store& copy);
38 
42  ~Store();
43 
49  HVecUS& data() {
50  return _data;
51  }
57  const HVecUS& data() const {
58  return _data;
59  }
63  bool labels() const {
64  return _label;
65  }
69  void setLabels(bool val) {
70  _label = val;
71  }
75  float opacity() const {
76  return _opacity;
77  }
81  void setOpacity(float f)
82  {
83  if(f < 0)
84  _opacity = 0;
85  else if(f > 1)
86  _opacity = 1;
87  else
88  _opacity = f;
89  }
93  float brightness() const {
94  return _brightness;
95  }
99  void setBrightness(float f)
100  {
101  if(f < 0)
102  _brightness = 0;
103  else if(f > 1)
104  _brightness = 1;
105  else
106  _brightness = f;
107  }
108 
113  return _fct;
114  }
119  {
120  if(_fct != f) {
121  _fct = f;
122  changed_function = true;
123  }
124  }
125 
129  bool transferFunctionChanged() const {
130  return changed_function;
131  }
132 
138  void changed();
139 
146  void changed(const BoundingBox3i& bbox) {
147  _changed |= bbox;
148  }
149 
153  bool wasChanged() const {
154  return _changed;
155  }
156 
160  const BoundingBox3i& changedBBox() const {
161  return _changed;
162  }
163 
167  void show() {
168  _isVisible = true;
169  }
173  void hide() {
174  _isVisible = false;
175  }
179  bool isVisible() const {
180  return _isVisible;
181  }
182 
186  const Stack* stack() const {
187  return _stack;
188  }
189 
193  void setStack(Stack* s);
194 
201  void allocate();
207  void reset();
208 
212  const QString& file() const {
213  return _filename;
214  }
218  void setFile(const QString& f = QString());
219 
223  uint size() const {
224  return _data.size();
225  }
229  bool empty() const {
230  return _data.empty();
231  }
232 
238  void copyMetaData(const Store* other);
239 
240 protected:
241  void resetModified();
242 
243  HVecUS _data;
244  bool _label;
245  bool changed_function;
246  float _opacity;
247  float _brightness;
248  BoundingBox3i _changed;
249  TransferFunction _fct;
250  bool _isVisible;
251  QString _filename;
252  const Stack* _stack;
253 };
254 
255 void mgx_EXPORT swapMetaData(Store* s1, Store* s2);
256 } // namespace mgx
257 #endif // STORE_HPP
void setOpacity(float f)
Changed the opacity of the volume.
Definition: Store.hpp:81
void show()
Ask the user interface to show this store.
Definition: Store.hpp:167
const HVecUS & data() const
Actual 3D data store linearly in a host vector.
Definition: Store.hpp:57
void setBrightness(float f)
Change the brightness of the volume.
Definition: Store.hpp:99
void setLabels(bool val)
Change the interpretation of the volume as labels.
Definition: Store.hpp:69
bool isVisible() const
Is the store currently visible.
Definition: Store.hpp:179
float brightness() const
Global brightness used to render the volume.
Definition: Store.hpp:93
bool empty() const
True if the store is of size 0.
Definition: Store.hpp:229
void setTransferFct(const TransferFunction &f)
Change the transfer function used to render the volume.
Definition: Store.hpp:118
HVecUS & data()
Actual 3D data store linearly in a host vector.
Definition: Store.hpp:49
const Stack * stack() const
Returns a constant pointer on the stack holding this store.
Definition: Store.hpp:186
TransferFunction transferFct() const
Retrieve the transfer function used to render the volume.
Definition: Store.hpp:112
The Store class holds the actual 3D data and properties specific to it.
Definition: Store.hpp:25
Common definitions and utilities for all geometry algorithms This file is shared by cuda...
const BoundingBox3i & changedBBox() const
Returns the current bounding box for the changes.
Definition: Store.hpp:160
bool labels() const
Returns true if the data is to be interpreted as labels rather than intensities.
Definition: Store.hpp:63
The Stack class represent the dimensions of the 3D data, and the frames transformations.
Definition: Stack.hpp:25
bool wasChanged() const
Returns true if the 3D data has been changed during this process.
Definition: Store.hpp:153
void hide()
Ask the user interface to hide this store.
Definition: Store.hpp:173
void changed(const BoundingBox3i &bbox)
A process that changed a range in the 3D data needs to call this method.
Definition: Store.hpp:146
float opacity() const
Opacity used to render the volume.
Definition: Store.hpp:75
bool transferFunctionChanged() const
Returns true if the transfer function has been changed within this process.
Definition: Store.hpp:129
Class defining a transfer function as linear interpolation between set values.
Definition: TransferFunction.hpp:23
uint size() const
Returns the size (in number of elements) of the store.
Definition: Store.hpp:223
const QString & file() const
Returns the file corresponding to this store.
Definition: Store.hpp:212