Fraxinus  16.5.0-fx-rc9
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxTestVideoSource.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 #ifndef CXTESTVIDEOSOURCE_H_
33 #define CXTESTVIDEOSOURCE_H_
34 
35 #include "cxResourceExport.h"
36 
37 #include "vtkSmartPointer.h"
38 #include <stdint.h>
39 #include <boost/shared_ptr.hpp>
40 #include <QObject>
41 #include <QDateTime>
42 
43 #include "cxVideoSource.h"
44 
45 typedef vtkSmartPointer<class vtkImageData> vtkImageDataPtr;
46 typedef vtkSmartPointer<class vtkImageImport> vtkImageImportPtr;
47 class QTimer;
48 
49 namespace cx
50 {
51 
62 class cxResource_EXPORT TestVideoSource : public VideoSource
63 {
64  Q_OBJECT
65 
66 public:
67  TestVideoSource( QString uid, QString name, int width, int height);
68  virtual ~TestVideoSource();
69 
70  virtual QString getUid() { return mUid; }
71  virtual QString getName() { return mName; }
72  virtual vtkImageDataPtr getVtkImageData();
73  virtual double getTimestamp();
74  virtual TimeInfo getAdvancedTimeInfo();
75 
76  virtual QString getInfoString() const { return QString("TestVideo Info"); }
77  virtual QString getStatusString() const { return QString("TestVideo Status"); }
78 
79  virtual void start();
80  virtual void stop();
81 
82  virtual bool validData() const { return isStreaming() && mInitialized && mValidData; }
83  virtual bool isConnected() const { return mConnected; }
84  virtual bool isStreaming() const { return mConnected && mStreaming; }
85 
86  virtual void setConnected(bool state) { mConnected = state; }
87  virtual void setValidData(bool valid) { mValidData = valid; }
88 
89  virtual void setResolution(double resolution);
90 private slots:
91  void processBuffer();
92 private:
93  bool mConnected;
94  bool mValidData;
95  QString mUid;
96  QString mName;
97  int mFrames;
98  double mResolution;
99  vtkImageImportPtr mImageImport;
100  int mWidth;
101  int mHeight;
102  bool mStreaming;
103  QTimer *mImageTimer;
104  uint8_t *mBuffer;
105  bool mInitialized;
106 };
107 typedef boost::shared_ptr<TestVideoSource> TestVideoSourcePtr;
108 
109 } // namespace cx
110 
111 #endif /* CXTESTVIDEOSOURCE_H_ */
vtkSmartPointer< class vtkImageImport > vtkImageImportPtr
test video source generator
virtual bool isStreaming() const
return true when the source is streaming data.
virtual QString getInfoString() const
an information text intended to be visible along with the data stream at all times ...
virtual bool isConnected() const
return true when a connection to the data source is established.
boost::shared_ptr< class TestVideoSource > TestVideoSourcePtr
virtual bool validData() const
return true is data stream is ok to display. This is a heuristic based on the data rate...
virtual void setConnected(bool state)
virtual QString getName()
virtual QString getUid()
video source interface.
Definition: cxVideoSource.h:64
vtkSmartPointer< class vtkImageImport > vtkImageImportPtr
virtual void setValidData(bool valid)
vtkSmartPointer< class vtkImageData > vtkImageDataPtr
virtual QString getStatusString() const
status text describing the stream state, display instead of stream when the stream is invalid...
vtkSmartPointer< class vtkImageData > vtkImageDataPtr