NorMIT-nav  22.09
An IGT application
cxStream2DRep3D.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #include "cxStream2DRep3D.h"
13 
14 #include <vtkRenderer.h>
15 
16 #include "cxTrackedStream.h"
17 #include "cxTool.h"
18 #include "cxVideoSourceGraphics.h"
19 #include "cxView.h"
20 #include "cxLogger.h"
21 
22 namespace cx
23 {
24 
25 Stream2DRep3DPtr Stream2DRep3D::New(SpaceProviderPtr spaceProvider, const QString& uid)
26 {
27  return wrap_new(new Stream2DRep3D(spaceProvider), uid);
28 }
29 
30 Stream2DRep3D::Stream2DRep3D(SpaceProviderPtr spaceProvider) :
31  RepImpl(),
32  mSpaceProvider(spaceProvider)
33 {
34  bool useMask = true;
35  mRTStream.reset(new VideoSourceGraphics(mSpaceProvider, useMask));
36 }
37 
38 QString Stream2DRep3D::getType() const
39 {
40  return "Stream2DRep3D";
41 }
42 
44 {
45  if(mTrackedStream)
46  {
47  disconnect(mTrackedStream.get(), &TrackedStream::newTool, this, &Stream2DRep3D::trackedStreamChanged);
48  disconnect(mTrackedStream.get(), &TrackedStream::newVideoSource, this, &Stream2DRep3D::trackedStreamChanged);
49  }
50 
51  mTrackedStream = trackedStream;
52 
53  if(mTrackedStream)
54  {
55  connect(mTrackedStream.get(), &TrackedStream::newTool, this, &Stream2DRep3D::trackedStreamChanged);
56  connect(mTrackedStream.get(), &TrackedStream::newVideoSource, this, &Stream2DRep3D::trackedStreamChanged);
57  }
58  this->trackedStreamChanged();
59 }
60 
62 {
63  view->getRenderer()->AddActor(mRTStream->getActor());
64 }
65 
67 {
68  view->getRenderer()->RemoveActor(mRTStream->getActor());
69 }
70 
71 void Stream2DRep3D::trackedStreamChanged()
72 {
73  ToolPtr tool = mTrackedStream->getProbeTool();
74  mRTStream->setTool(tool);
75  mRTStream->setRealtimeStream(mTrackedStream->getVideoSource());
76 }
77 
79 {
80  if(!mTrackedStream->getProbeTool())
81  return false;
82  if(!mTrackedStream->getVideoSource())
83  return false;
84  return true;
85 }
86 
87 } //cx
cx::VideoSourceGraphics
Helper class for displaying a VideoSource.
Definition: cxVideoSourceGraphics.h:37
cx::Stream2DRep3D
Display a stream as 2D in 3D.
Definition: cxStream2DRep3D.h:33
cx::Stream2DRep3D::addRepActorsToViewRenderer
virtual void addRepActorsToViewRenderer(ViewPtr view)
Definition: cxStream2DRep3D.cpp:61
cx::Stream2DRep3DPtr
boost::shared_ptr< class Stream2DRep3D > Stream2DRep3DPtr
Definition: cxForwardDeclarations.h:98
cxLogger.h
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::Stream2DRep3D::New
static Stream2DRep3DPtr New(SpaceProviderPtr spaceProvider, const QString &uid="")
Definition: cxStream2DRep3D.cpp:25
cxVideoSourceGraphics.h
cx::Stream2DRep3D::setTrackedStream
void setTrackedStream(TrackedStreamPtr trackedStream)
Definition: cxStream2DRep3D.cpp:43
cxTool.h
cxView.h
cx::Stream2DRep3D::isReady
bool isReady()
Definition: cxStream2DRep3D.cpp:78
cx::TrackedStream::newVideoSource
void newVideoSource(VideoSourcePtr videoSource)
cxStream2DRep3D.h
cx::ViewPtr
boost::shared_ptr< class View > ViewPtr
Definition: cxForwardDeclarations.h:110
cx::RepImpl
Default implementation of Rep.
Definition: cxRepImpl.h:42
cx::TrackedStream::newTool
void newTool(ToolPtr tool)
cx::ToolPtr
boost::shared_ptr< class Tool > ToolPtr
Definition: cxVideoConnectionWidget.h:43
cx::Stream2DRep3D::removeRepActorsFromViewRenderer
virtual void removeRepActorsFromViewRenderer(ViewPtr view)
Definition: cxStream2DRep3D.cpp:66
cx::RepImpl::wrap_new
static boost::shared_ptr< REP > wrap_new(REP *object, QString uid)
Definition: cxRepImpl.h:62
cx::TrackedStreamPtr
boost::shared_ptr< class TrackedStream > TrackedStreamPtr
Definition: cxStreamPropertiesWidget.h:22
cx::SpaceProviderPtr
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
Definition: cxLogicManager.h:23
cx::Stream2DRep3D::getType
virtual QString getType() const
Definition: cxStream2DRep3D.cpp:38
cxTrackedStream.h