CustusX  22.04-rc5
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
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
RepImpl(const QString &uid="", const QString &name="")
Definition: cxRepImpl.cpp:22
boost::shared_ptr< class Stream2DRep3D > Stream2DRep3DPtr
boost::shared_ptr< class TrackedStream > TrackedStreamPtr
static boost::shared_ptr< REP > wrap_new(REP *object, QString uid)
Definition: cxRepImpl.h:62
void newVideoSource(VideoSourcePtr videoSource)
Display a stream as 2D in 3D.
boost::shared_ptr< class View > ViewPtr
Helper class for displaying a VideoSource.
static Stream2DRep3DPtr New(SpaceProviderPtr spaceProvider, const QString &uid="")
virtual void removeRepActorsFromViewRenderer(ViewPtr view)
void newTool(ToolPtr tool)
virtual void addRepActorsToViewRenderer(ViewPtr view)
virtual QString getType() const
void setTrackedStream(TrackedStreamPtr trackedStream)
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr