iRoCS Toolbox  1.1.0
ChannelSpecs.hh
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * This file belongs to the iRoCS Toolbox.
4  *
5  * Copyright (C) 2015 Thorsten Falk
6  *
7  * Image Analysis Lab, University of Freiburg, Germany
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  *
23  **************************************************************************/
24 
25 #ifndef CHANNELSPECS_HH
26 #define CHANNELSPECS_HH
27 
28 #ifdef HAVE_CONFIG_H
29 #include <config.hh>
30 #endif
31 
32 #include <QtCore/QObject>
33 #include <QtGui/QIcon>
34 #include <QtGui/QToolButton>
35 
36 #include <string>
37 #include <vector>
38 #include <map>
39 
40 #include <blitz/array.h>
41 
42 class QFormLayout;
43 
46 class BoolControlElement;
48 class OrthoViewWidget;
50 class ViewWidget;
51 class MultiChannelModel;
52 
53 class ChannelSpecs : public QObject
54 {
55 
56  Q_OBJECT
57 
58 public:
59 
60  enum ChannelType {
61  Data = 0x0001,
62  Visualization = 0x0002,
63  RGB = 0x0004,
64  Annotation = 0x0008,
65  SplineCurve = 0x0010,
66  IRoCS = 0x0020,
67  IRoCSSCT = 0x0040
68  };
69  Q_DECLARE_FLAGS(ChannelTypes, ChannelType)
70  static ChannelTypes const Any;
71 
73  virtual ~ChannelSpecs();
74 
75  virtual ChannelType channelType() const = 0;
76 
78  MultiChannelModel *model() const;
79 
80  std::string name() const;
81 
82  QIcon icon() const;
83 
84  float alpha() const;
85 
86  bool visible() const;
87 
88  bool hasNewData() const;
89 
90  virtual blitz::TinyVector<double,3> const &lowerBoundUm() const;
91  virtual blitz::TinyVector<double,3> const &upperBoundUm() const;
92  virtual blitz::TinyVector<double,3> const &elementSizeUm() const;
93  virtual blitz::TinyMatrix<double,4,4> const &transformation() const;
94 
95  QWidget *channelControlWidget() const;
96 
97  virtual float valueAt(
98  blitz::TinyVector<double,3> const &positionUm) const = 0;
99 
100  virtual std::string stringValueAt(
101  blitz::TinyVector<double,3> const &positionUm) const = 0;
102 
103  virtual ChannelSpecsRenderer *addRenderer(ViewWidget *view) = 0;
104  void removeRenderer(ViewWidget *view);
106  std::map<ViewWidget*,ChannelSpecsRenderer*> const &renderers() const;
107  std::map<ViewWidget*,ChannelSpecsRenderer*> &renderers();
108 
109 /*======================================================================*/
115 /*======================================================================*/
116  bool updatesEnabled() const;
117 
118 public slots:
119 
120  void setName(std::string const &name);
121  void setIcon(QIcon const &icon);
122  void setAlpha(float alpha);
123  void setVisible(bool visible);
124  void setHasNewData(bool hasNewData);
125  virtual void setTransformation(
126  blitz::TinyMatrix<double,4,4> const &transformation);
127 
128 /*======================================================================*/
138 /*======================================================================*/
139  void setUpdatesEnabled(bool enable);
140 
141 /*======================================================================*/
148 /*======================================================================*/
149  void update();
150 
151 /*======================================================================*/
158 /*======================================================================*/
159  virtual void revalidate();
160 
161 signals:
162 
163  void boundingBoxChanged(
164  blitz::TinyVector<double,3> const &lowerBoundUm,
165  blitz::TinyVector<double,3> const &upperBoundUm);
166  void iconChanged();
167  void nameChanged();
168  void transformationChanged();
169 
170 /*======================================================================*/
178 /*======================================================================*/
179  void viewChanged();
180 
181 protected slots:
182 
183 /*======================================================================*/
190 /*======================================================================*/
191  void emitUpdateRequest();
192 
193 private slots:
194 
195  void toggleAdvanced(bool toggle);
196  void setTransformationFromControl();
197 
198 protected:
199 
201  std::map<ViewWidget*,ChannelSpecsRenderer*> _renderers;
206 
210 
212 
215 
218 
219 private:
220 
221  bool _updatesEnabled;
222  std::string _name;
223  QIcon _icon;
224 
225 };
226 
227 Q_DECLARE_OPERATORS_FOR_FLAGS(ChannelSpecs::ChannelTypes)
228 
229 #endif
float alpha() const
QFormLayout * p_channelControlLayout
void setModel(MultiChannelModel *model)
virtual ChannelType channelType() const =0
QFormLayout * p_advancedControlLayout
bool hasNewData() const
virtual void revalidate()
Reset the channel shape, element size, transformation and bounding box from the underlying data...
bool _oldVisibilityState
void emitUpdateRequest()
This function sets the hasNewData flag for this channel to true, to inform the renderers that this ch...
MultiChannelModel * p_model
blitz::TinyMatrix< double, 4, 4 > _originalTransformation
blitz::TinyVector< double, 3 > _upperBoundUm
STL namespace.
bool updatesEnabled() const
Check whether cache updates for this channel are enabled.
std::string name() const
std::map< ViewWidget *, ChannelSpecsRenderer * > const & renderers() const
virtual ChannelSpecsRenderer * addRenderer(ViewWidget *view)=0
void viewChanged()
This signal is emitted whenever the contents or visualization of the channel are altered and an updat...
void boundingBoxChanged(blitz::TinyVector< double, 3 > const &lowerBoundUm, blitz::TinyVector< double, 3 > const &upperBoundUm)
virtual blitz::TinyVector< double, 3 > const & lowerBoundUm() const
void nameChanged()
void setAlpha(float alpha)
QWidget * channelControlWidget() const
virtual std::string stringValueAt(blitz::TinyVector< double, 3 > const &positionUm) const =0
void setName(std::string const &name)
void iconChanged()
QWidget * p_advancedControlWidget
virtual blitz::TinyMatrix< double, 4, 4 > const & transformation() const
ChannelSpecsRenderer * renderer(ViewWidget *view) const
void update()
Explicitely trigger a cache update for all associated renderers.
void removeRenderer(ViewWidget *view)
BoolControlElement * p_visibleControl
void setUpdatesEnabled(bool enable)
Enables/Disables cache updates for this channel.
void setIcon(QIcon const &icon)
void transformationChanged()
virtual float valueAt(blitz::TinyVector< double, 3 > const &positionUm) const =0
bool visible() const
MultiChannelModel * model() const
DoubleControlElement * p_alphaControl
virtual void setTransformation(blitz::TinyMatrix< double, 4, 4 > const &transformation)
void setVisible(bool visible)
QWidget * p_channelControlWidget
Double4x4ControlElement * p_transformationControl
blitz::TinyVector< double, 3 > _elementSizeUm
blitz::TinyMatrix< double, 4, 4 > _transformation
blitz::TinyVector< double, 3 > _lowerBoundUm
std::map< ViewWidget *, ChannelSpecsRenderer * > _renderers
virtual blitz::TinyVector< double, 3 > const & upperBoundUm() const
QToolButton * p_toggleAdvancedButton
void setHasNewData(bool hasNewData)
QIcon icon() const
virtual blitz::TinyVector< double, 3 > const & elementSizeUm() const
static ChannelTypes const Any
Definition: ChannelSpecs.hh:70