15 #include <boost/array.hpp> 18 #include <vtkImageData.h> 19 #include <vtkImageImport.h> 20 #include <vtkPNGReader.h> 29 : mImageWidth(width), mImageHeight(height), mImageColorDepth(depth), mImageImport(
vtkImageImportPtr::New())
31 mImportInitialized =
false;
32 mStartWhenConnected =
false;
34 mImageImport->SetDataScalarTypeToUnsignedChar();
35 mImageImport->SetNumberOfScalarComponents(3);
40 mPollTimer =
new QTimer(
this);
41 mPollTimer->setInterval(40);
45 mImageData = mImageImport->GetOutput();
66 return mImageImport->GetOutput();
71 return (
double) mSource.
timestamp().toMSecsSinceEpoch();
77 return "NOT YET IMPLEMENTED";
83 return QString(
"%1 and %2").arg(
isConnected() ?
"Connected" :
"Not connected").arg(
isStreaming() ?
"streaming" :
"not streaming");;
90 mStartWhenConnected =
true;
93 mStartWhenConnected =
false;
106 mStartWhenConnected =
false;
140 unsigned char* buffer = (
unsigned char*) mSource.
isNew();
144 mTimeStamp = mSource.
timestamp().currentMSecsSinceEpoch();
147 Q_UNUSED(numChannels);
150 mImageImport->SetDataExtentToWholeExtent();
152 mImageImport->SetImportVoidPointer(buffer);
153 mImageImport->Update();
154 mImportInitialized =
true;
165 mConnected = mSource.
attach(key);
169 connect(mPollTimer, SIGNAL(timeout()),
this, SLOT(serverPollSlot()));
172 if (mStartWhenConnected)
188 disconnect(mPollTimer, SIGNAL(timeout()),
this, SLOT(serverPollSlot()));
199 void VideoSourceSHM::serverPollSlot()
206 mImageImport->SetDataSpacing(resolution, resolution, 1);
virtual ~VideoSourceSHM()
virtual QString getInfoString() const
Returns a short info message.
void release()
Release our read buffer.
void streaming(bool on)
emitted when streaming started/stopped
virtual double getTimestamp()
virtual void start()
start streaming
virtual vtkImageDataPtr getVtkImageData()
const void * isNew()
Return new buffer only if new is available, otherwise return NULL.
virtual QString getName()
virtual bool isConnected() const
return true when a connection to the data source is established.
void connectServer(const QString &key)
virtual QString getStatusString() const
Returns a short status message.
vtkSmartPointer< class vtkImageImport > vtkImageImportPtr
virtual bool isStreaming() const
return true when the source is streaming data.
VideoSourceSHM(int width=0, int height=0, int depth=24)
bool attach(const QString &key)
virtual void stop()
stop streaming
void newFrame()
emitted when a new frame has arrived (getVtkImageData() returns something new). info/status/name/vali...
virtual bool validData() const
return true is data stream is ok to display. This is a heuristic based on the data rate...
virtual void setResolution(double resolution)
Namespace for all CustusX production code.