Fraxinus  16.5.0-fx-rc9
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxVideoSourceSHM.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 
33 
34 /*
35  * sscVideoSourceSHM.h
36  *
37  * Created on: Oct 10, 2011
38  * Author: franka
39  */
40 
41 #ifndef CXVIDEOSOURCESHM_H_
42 #define CXVIDEOSOURCESHM_H_
43 
44 #include "cxResourceExport.h"
45 
46 #include <map>
47 #include <stdint.h>
48 
49 #include <boost/shared_ptr.hpp>
50 
51 #include "vtkSmartPointer.h"
52 
53 #include <QObject>
54 #include <QDateTime>
55 
56 #include "cxVideoSource.h"
57 #include "cxSharedMemory.h"
58 
59 typedef vtkSmartPointer<class vtkImageImport> vtkImageImportPtr;
60 
61 // Forward declaration
62 class QTimer;
63 
64 namespace cx
65 {
66 
73 class cxResource_EXPORT VideoSourceSHM : public VideoSource
74 {
75  Q_OBJECT
76 
77 public:
78 
79  VideoSourceSHM(int width = 0, int height = 0, int depth = 24);
80  virtual ~VideoSourceSHM();
81 
82  int width() const { return mImageWidth; }
83  int height() const { return mImageHeight; }
84  int depth() const { return mImageColorDepth; }
85 
86  virtual QString getUid();
87  virtual QString getName();
88  virtual vtkImageDataPtr getVtkImageData();
89  virtual double getTimestamp();
90 
91  virtual QString getInfoString() const;
92  virtual QString getStatusString() const;
93 
94  virtual void start();
95  virtual void stop();
96 
97  virtual bool validData() const;
98  virtual bool isConnected() const;
99  virtual bool isStreaming() const;
100 
101  void connectServer(const QString& key);
102  void disconnectServer();
103  virtual void setResolution(double resolution);
104 
105 protected:
106  void update();
107 
108 protected:
112 
113 private:
114 
115  SharedMemoryClient mSource;
116 
117  vtkImageDataPtr mImageData;
118  vtkImageImportPtr mImageImport;
119 
120  double mTimeStamp;
121 
122  bool mConnected;
123  bool mStreaming;
124  bool mImportInitialized;
125  bool mStartWhenConnected;
126 
127  QTimer* mPollTimer;
128 
129 private slots:
130 
131  void serverPollSlot();
132 };
133 
134 typedef boost::shared_ptr<VideoSourceSHM> VideoSourceSHMPtr;
135 
136 } // namespace cx
137 
138 #endif /* CXVIDEOSOURCESHM_H_ */
vtkSmartPointer< class vtkImageImport > vtkImageImportPtr
Shared Memory Client.
boost::shared_ptr< VideoSourceSHM > VideoSourceSHMPtr
video source interface.
Definition: cxVideoSource.h:64
vtkSmartPointer< class vtkImageImport > vtkImageImportPtr
VideoSource for connecting to shared memory.
vtkSmartPointer< class vtkImageData > vtkImageDataPtr