MIRA
VisualizationTextTraceBasic.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 by
3  * MetraLabs GmbH (MLAB), GERMANY
4  * and
5  * Neuroinformatics and Cognitive Robotics Labs (NICR) at TU Ilmenau, GERMANY
6  * All rights reserved.
7  *
8  * Contact: info@mira-project.org
9  *
10  * Commercial Usage:
11  * Licensees holding valid commercial licenses may use this file in
12  * accordance with the commercial license agreement provided with the
13  * software or, alternatively, in accordance with the terms contained in
14  * a written agreement between you and MLAB or NICR.
15  *
16  * GNU General Public License Usage:
17  * Alternatively, this file may be used under the terms of the GNU
18  * General Public License version 3.0 as published by the Free Software
19  * Foundation and appearing in the file LICENSE.GPL3 included in the
20  * packaging of this file. Please review the following information to
21  * ensure the GNU General Public License version 3.0 requirements will be
22  * met: http://www.gnu.org/copyleft/gpl.html.
23  * Alternatively you may (at your option) use any later version of the GNU
24  * General Public License if such license has been publicly approved by
25  * MLAB and NICR (or its successors, if any).
26  *
27  * IN NO EVENT SHALL "MLAB" OR "NICR" BE LIABLE TO ANY PARTY FOR DIRECT,
28  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
29  * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF "MLAB" OR
30  * "NICR" HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  * "MLAB" AND "NICR" SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
33  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
34  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
35  * ON AN "AS IS" BASIS, AND "MLAB" AND "NICR" HAVE NO OBLIGATION TO
36  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.
37  */
38 
47 #ifndef _MIRA_VISUALIZATIONTEXTTRACEBASIC_H_
48 #define _MIRA_VISUALIZATIONTEXTTRACEBASIC_H_
49 
50 #include <QTreeWidget>
51 
53 
54 namespace mira {
55 
57 
58 template<typename T>
60 {
61 public:
62 
63  VisualizationTextTraceBasic(const std::string& channelName) :
64  mName(channelName),
65  mItem(NULL)
66  {
67  mChannel.setDataIntervalChangedCallback(boost::bind(&VisualizationTextTraceBasic::dataIntervalChanged, this, _1));
68  mChannel.setChannelChangedCallback(boost::bind(&VisualizationTextTraceBasic::channelChanged, this));
69  }
70 
72  {
73  if (getSite())
75  }
76 
77  template <typename Reflector>
78  void reflect(Reflector& r)
79  {
82  }
83 
85  {
86  mItem = site->addItem();
87  mItem->setName(mChannel.getID());
88  }
89 
91 
92  virtual void channelChanged()
93  {
94  try {
95  this->setName(mChannel.getID());
96  }
97  catch (XRuntime&) {}
98  if (!mItem)
99  return;
100  mItem->setName(mChannel.getID());
101  }
102 
103  virtual void dataChanged(ChannelRead<T> data) {}
104 
106  {
107  typename ChannelReadInterval<T>::const_iterator it = data.begin();
108  for (; it !=data.end(); it++) {
109  ChannelRead<T> r = it;
110  dataChanged(r);
111  }
112  }
113 
115 
116 protected:
117 
118  std::string mName;
121 };
122 
124 
125 }
126 
127 #endif
virtual IVisualizationTextTraceItem * getItem()
Get the visualization item.
Definition: VisualizationTextTraceBasic.h:114
An object that allows read access to a whole interval of channel data.
Definition: ChannelReadInterval.h:72
void setName(const std::string &name)
Sets the name of this visualization.
Definition: Visualization.h:157
virtual IVisualizationTextTraceSite * getSite()
Returns a pointer to the IVisualizationTextTraceSite interface that was set in the init() method...
Declaration of VisualizationTextTrace and related classes.
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
IVisualizationTextTraceItem * mItem
Definition: VisualizationTextTraceBasic.h:120
Definition: VisualizationTextTrace.h:70
#define MIRA_REFLECT_BASE(reflector, BaseClass)
Macro that can be used to reflect the base class easily.
Definition: ReflectorInterface.h:912
std::string mName
Definition: VisualizationTextTraceBasic.h:118
void channelProperty(Reflector &r, const std::string &name, ChannelProperty< T > &channel, const std::string &comment, OptionalMode optional=REQUIRED)
Special property-method that should be called within the reflect method to specify a ChannelProperty...
Definition: Visualization.h:249
An object that allows read access to data of a channel.
Definition: ChannelReadWrite.h:494
The data structure that is returned by getDataConnection.
Definition: Visualization.h:183
virtual IVisualizationTextTraceItem * addItem()=0
const_iterator end() const
Definition: ChannelReadInterval.h:164
const_iterator begin() const
Definition: ChannelReadInterval.h:163
Definition: VisualizationTextTrace.h:56
void reflect(Reflector &r)
Definition: VisualizationTextTraceBasic.h:78
Abstract base class for a text visualization tracing the data history.
Definition: VisualizationTextTrace.h:89
virtual void dataChanged(ChannelRead< T > data)
Definition: VisualizationTextTraceBasic.h:103
virtual void channelChanged()
Definition: VisualizationTextTraceBasic.h:92
Const iterator for iterating over the interval.
Definition: ChannelReadInterval.h:85
Definition: VisualizationTextTraceBasic.h:59
virtual DataConnection getDataConnection()
Returns information about the direct data connection for this visualization.
Definition: VisualizationTextTraceBasic.h:90
virtual void setupScene(IVisualizationTextTraceSite *site)
Must be implemented in derived classes.
Definition: VisualizationTextTraceBasic.h:84
virtual void destroyItem(IVisualizationTextTraceItem *item)=0
VisualizationTextTraceBasic(const std::string &channelName)
Definition: VisualizationTextTraceBasic.h:63
ChannelProperty< T > mChannel
Definition: VisualizationTextTraceBasic.h:119
The concrete typed ChannelProperty template class.
Definition: ChannelProperty.h:214
virtual void dataIntervalChanged(ChannelReadInterval< T > data)
Definition: VisualizationTextTraceBasic.h:105
virtual void setName(const std::string &name)=0
virtual ~VisualizationTextTraceBasic()
Definition: VisualizationTextTraceBasic.h:71