MorphoGraphX  2.0-1-227
Store.hpp
Go to the documentation of this file.
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  class SetupProcess;
23 
24  typedef unsigned short ushort;
25  typedef thrust::host_vector<ushort> HVecUS;
26 
27  class Stack;
33  class mgx_EXPORT Store
34  {
35  friend class SetupProcess;
36 
37  public:
41  Store(Stack* stack);
42 
46  Store(const Store& copy);
47 
51  ~Store();
52 
58  HVecUS& data() { return _data; }
59 
65  const HVecUS& data() const { return _data; }
66 
70  bool labels() const { return _label; }
71 
75  void setLabels(bool val) { _label = val; }
76 
80  float opacity() const { return _opacity; }
81 
85  void setOpacity(float f)
86  {
87  if(f < 0)
88  _opacity = 0;
89  else if(f > 1)
90  _opacity = 1;
91  else
92  _opacity = f;
93  }
94 
98  float brightness() const { return _brightness; }
99 
103  void setBrightness(float f)
104  {
105  if(f < 0)
106  _brightness = 0;
107  else if(f > 1)
108  _brightness = 1;
109  else
110  _brightness = f;
111  }
112 
116  TransferFunction transferFct() const { return _fct; }
117 
122  {
123  if(_fct != f) {
124  _fct = f;
125  changed_function = true;
126  }
127  }
128 
132  bool transferFunctionChanged() const { return changed_function; }
133 
139  void changed();
140 
147  void changed(const BoundingBox3i& bbox) { _changed |= bbox; }
148 
152  bool wasChanged() const { return _changed; }
153 
157  const BoundingBox3i& changedBBox() const { return _changed; }
158 
162  void show() { _isVisible = true; }
163 
167  void hide() { _isVisible = false; }
168 
172  bool isVisible() const { return _isVisible; }
173 
177  const Stack* stack() const { return _stack; }
178 
182  void setStack(Stack* s);
183 
190  void allocate();
191 
197  void reset();
198 
202  const QString& file() const { return _filename; }
203 
207  void setFile(const QString& f = QString());
208 
212  uint size() const { return _data.size(); }
213 
217  bool empty() const { return _data.empty(); }
218 
224  void copyMetaData(const Store* other);
225 
226  protected:
227  void resetModified();
228 
230  bool _label;
232  float _opacity;
233  float _brightness;
237  QString _filename;
238  const Stack* _stack;
239  };
240 
241  void mgx_EXPORT swapMetaData(Store* s1, Store* s2);
242 }
243 #endif
mgx::Store::_isVisible
bool _isVisible
Definition: Store.hpp:236
mgx::uint
unsigned int uint
Definition: Geometry.hpp:41
mgx::Store::_fct
TransferFunction _fct
Definition: Store.hpp:235
mgx::Store::setTransferFct
void setTransferFct(const TransferFunction &f)
Change the transfer function used to render the volume.
Definition: Store.hpp:121
TransferFunction.hpp
mgx::Store::size
uint size() const
Returns the size (in number of elements) of the store.
Definition: Store.hpp:212
mgx::Store::_filename
QString _filename
Definition: Store.hpp:237
mgx::Store::changed
void changed(const BoundingBox3i &bbox)
A process that changed a range in the 3D data needs to call this method.
Definition: Store.hpp:147
mgx::Store::labels
bool labels() const
Returns true if the data is to be interpreted as labels rather than intensities.
Definition: Store.hpp:70
mgx::TransferFunction
Definition: TransferFunction.hpp:34
mgx::HVecUS
thrust::host_vector< ushort > HVecUS
Definition: CudaExport.hpp:23
mgx::Store::setBrightness
void setBrightness(float f)
Change the brightness of the volume.
Definition: Store.hpp:103
mgx::Store::setOpacity
void setOpacity(float f)
Changed the opacity of the volume.
Definition: Store.hpp:85
mgx::ushort
unsigned short ushort
Simpler names for the various containers and iterators.
Definition: Geometry.hpp:42
mgx::Store::_label
bool _label
Definition: Store.hpp:230
mgx::Stack
Definition: Stack.hpp:33
Geometry.hpp
mgx::Store::_changed
BoundingBox3i _changed
Definition: Store.hpp:234
mgx::Store::_brightness
float _brightness
Definition: Store.hpp:233
mgx
Distributed matrix library.
Definition: Assert.hpp:26
mgx::Store::hide
void hide()
Ask the user interface to hide this store.
Definition: Store.hpp:167
mgx::Store::data
const HVecUS & data() const
Actual 3D data store linearly in a host vector.
Definition: Store.hpp:65
mgx::Store::file
const QString & file() const
Returns the file corresponding to this store.
Definition: Store.hpp:202
mgx::Store::_stack
const Stack * _stack
Definition: Store.hpp:238
mgx::Store::transferFct
TransferFunction transferFct() const
Retrieve the transfer function used to render the volume.
Definition: Store.hpp:116
mgx::Store::changedBBox
const BoundingBox3i & changedBBox() const
Returns the current bounding box for the changes.
Definition: Store.hpp:157
mgx::Store::show
void show()
Ask the user interface to show this store.
Definition: Store.hpp:162
mgx::Store::_data
HVecUS _data
Definition: Store.hpp:229
mgx::Store::isVisible
bool isVisible() const
Is the store currently visible.
Definition: Store.hpp:172
mgx::swapMetaData
void mgx_EXPORT swapMetaData(Store *s1, Store *s2)
mgx::Store::_opacity
float _opacity
Definition: Store.hpp:232
mgx::Store::setLabels
void setLabels(bool val)
Change the interpretation of the volume as labels.
Definition: Store.hpp:75
mgx::Store::opacity
float opacity() const
Opacity used to render the volume.
Definition: Store.hpp:80
mgx::Store::transferFunctionChanged
bool transferFunctionChanged() const
Returns true if the transfer function has been changed within this process.
Definition: Store.hpp:132
mgx::Store::brightness
float brightness() const
Global brightness used to render the volume.
Definition: Store.hpp:98
mgx::Store::wasChanged
bool wasChanged() const
Returns true if the 3D data has been changed during this process.
Definition: Store.hpp:152
mgx::Store::changed_function
bool changed_function
Definition: Store.hpp:231
mgx::Store::data
HVecUS & data()
Actual 3D data store linearly in a host vector.
Definition: Store.hpp:58
mgx::Store::stack
const Stack * stack() const
Returns a constant pointer on the stack holding this store.
Definition: Store.hpp:177
mgx::BoundingBox< 3, int >
mgx::Store::empty
bool empty() const
True if the store is of size 0.
Definition: Store.hpp:217
mgx::Store
Definition: Store.hpp:33