MorphoGraphX
Store.hpp
1 //
2 // This file is part of MorphoGraphX - http://www.MorphoGraphX.org
3 // Copyright (C) 2012-2015 Richard S. Smith and collaborators.
4 //
5 // If you use MorphoGraphX in your work, please cite:
6 // http://dx.doi.org/10.7554/eLife.05864
7 //
8 // MorphoGraphX is free software, and is licensed under under the terms of the
9 // GNU General (GPL) Public License version 2.0, http://www.gnu.org/licenses.
10 //
11 #ifndef STORE_HPP
12 #define STORE_HPP
13 
14 #include <Config.hpp>
15 
16 #include <Geometry.hpp>
17 #include <thrust/host_vector.h>
18 #include <TransferFunction.hpp>
19 
20 namespace mgx {
21 
22 namespace process {
23 class SetupProcess;
24 } // namespace process
25 
26 typedef unsigned short ushort;
27 typedef thrust::host_vector<ushort> HVecUS;
28 
29 class Stack;
35 class mgx_EXPORT Store {
36  friend class process::SetupProcess;
37 
38 public:
42  Store(Stack* stack);
43 
47  Store(const Store& copy);
48 
52  ~Store();
53 
59  HVecUS& data() {
60  return _data;
61  }
67  const HVecUS& data() const {
68  return _data;
69  }
73  bool labels() const {
74  return _label;
75  }
79  void setLabels(bool val) {
80  _label = val;
81  }
85  float opacity() const {
86  return _opacity;
87  }
91  void setOpacity(float f)
92  {
93  if(f < 0)
94  _opacity = 0;
95  else if(f > 1)
96  _opacity = 1;
97  else
98  _opacity = f;
99  }
103  float brightness() const {
104  return _brightness;
105  }
109  void setBrightness(float f)
110  {
111  if(f < 0)
112  _brightness = 0;
113  else if(f > 1)
114  _brightness = 1;
115  else
116  _brightness = f;
117  }
118 
123  return _fct;
124  }
129  {
130  if(_fct != f) {
131  _fct = f;
132  changed_function = true;
133  }
134  }
135 
139  bool transferFunctionChanged() const {
140  return changed_function;
141  }
142 
148  void changed();
149 
156  void changed(const BoundingBox3i& bbox) {
157  _changed |= bbox;
158  }
159 
163  bool wasChanged() const {
164  return _changed;
165  }
166 
170  const BoundingBox3i& changedBBox() const {
171  return _changed;
172  }
173 
177  void show() {
178  _isVisible = true;
179  }
183  void hide() {
184  _isVisible = false;
185  }
189  bool isVisible() const {
190  return _isVisible;
191  }
192 
196  const Stack* stack() const {
197  return _stack;
198  }
199 
203  void setStack(Stack* s);
204 
211  void allocate();
217  void reset();
218 
222  const QString& file() const {
223  return _filename;
224  }
228  void setFile(const QString& f = QString());
229 
233  uint size() const {
234  return _data.size();
235  }
239  bool empty() const {
240  return _data.empty();
241  }
242 
248  void copyMetaData(const Store* other);
249 
250 protected:
251  void resetModified();
252 
253  HVecUS _data;
254  bool _label;
255  bool changed_function;
256  float _opacity;
257  float _brightness;
258  BoundingBox3i _changed;
259  TransferFunction _fct;
260  bool _isVisible;
261  QString _filename;
262  const Stack* _stack;
263 };
264 
265 void mgx_EXPORT swapMetaData(Store* s1, Store* s2);
266 } // namespace mgx
267 #endif // STORE_HPP
void setOpacity(float f)
Changed the opacity of the volume.
Definition: Store.hpp:91
void show()
Ask the user interface to show this store.
Definition: Store.hpp:177
const HVecUS & data() const
Actual 3D data store linearly in a host vector.
Definition: Store.hpp:67
void setBrightness(float f)
Change the brightness of the volume.
Definition: Store.hpp:109
void setLabels(bool val)
Change the interpretation of the volume as labels.
Definition: Store.hpp:79
bool isVisible() const
Is the store currently visible.
Definition: Store.hpp:189
float brightness() const
Global brightness used to render the volume.
Definition: Store.hpp:103
bool empty() const
True if the store is of size 0.
Definition: Store.hpp:239
void setTransferFct(const TransferFunction &f)
Change the transfer function used to render the volume.
Definition: Store.hpp:128
HVecUS & data()
Actual 3D data store linearly in a host vector.
Definition: Store.hpp:59
const Stack * stack() const
Returns a constant pointer on the stack holding this store.
Definition: Store.hpp:196
TransferFunction transferFct() const
Retrieve the transfer function used to render the volume.
Definition: Store.hpp:122
The Store class holds the actual 3D data and properties specific to it.
Definition: Store.hpp:35
Common definitions and utilities for all geometry algorithms This file is shared by cuda...
This namespace contains all the API of MorphoGraphX.
Definition: Assert.hpp:26
const BoundingBox3i & changedBBox() const
Returns the current bounding box for the changes.
Definition: Store.hpp:170
bool labels() const
Returns true if the data is to be interpreted as labels rather than intensities.
Definition: Store.hpp:73
The Stack class represent the dimensions of the 3D data, and the frames transformations.
Definition: Stack.hpp:35
bool wasChanged() const
Returns true if the 3D data has been changed during this process.
Definition: Store.hpp:163
void hide()
Ask the user interface to hide this store.
Definition: Store.hpp:183
This namespace contains all the classes needed to define processes.
void changed(const BoundingBox3i &bbox)
A process that changed a range in the 3D data needs to call this method.
Definition: Store.hpp:156
float opacity() const
Opacity used to render the volume.
Definition: Store.hpp:85
bool transferFunctionChanged() const
Returns true if the transfer function has been changed within this process.
Definition: Store.hpp:139
Class defining a transfer function as linear interpolation between set values.
Definition: TransferFunction.hpp:33
uint size() const
Returns the size (in number of elements) of the store.
Definition: Store.hpp:233
const QString & file() const
Returns the file corresponding to this store.
Definition: Store.hpp:222