NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxStreamRep3D.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 
13 #include <vtkRenderer.h>
14 #include <vtkVolumeMapper.h>
15 #include <vtkImageData.h>
16 
17 #include "cxStreamRep3D.h"
18 #include "cxTrackedStream.h"
19 #include "cxVideoSourceGraphics.h"
20 #include "cxView.h"
21 #include "cxTool.h"
22 #include "cxPatientModelService.h"
23 #include "cxVolumeProperty.h"
24 #include "cxReporter.h"
25 #include "cxSettings.h"
26 
27 //To be removed
28 #include "cxImageTF3D.h"
30 
31 
32 namespace cx
33 {
34 
35 StreamRep3DPtr StreamRep3D::New(SpaceProviderPtr spaceProvider, PatientModelServicePtr patientModelService, const QString& uid)
36 {
37  return wrap_new(new StreamRep3D(spaceProvider, patientModelService), uid);
38 }
39 
40 StreamRep3D::StreamRep3D(SpaceProviderPtr spaceProvider, PatientModelServicePtr patientModelService) :
41  VolumetricRep(),
42  mTrackedStream(TrackedStreamPtr()),
43  mPatientModelService(patientModelService)
44 {
45  this->setVisualizerType();
46 }
47 
49 {
50  if(mTrackedStream)
51  {
52  disconnect(mTrackedStream.get(), &TrackedStream::newTool, this, &StreamRep3D::newTool);
53  disconnect(mTrackedStream.get(), &TrackedStream::newVideoSource, this, &StreamRep3D::newVideoSource);
54  disconnect(mTrackedStream.get(), &TrackedStream::newFrame, this, &StreamRep3D::vtkImageDataChangedSlot);
55  }
56 
57  mTrackedStream = trackedStream;
58 
59  if(mTrackedStream)
60  {
61  connect(mTrackedStream.get(), &TrackedStream::newTool, this, &StreamRep3D::newTool);
62  connect(mTrackedStream.get(), &TrackedStream::newVideoSource, this, &StreamRep3D::newVideoSource);
63  connect(mTrackedStream.get(), &TrackedStream::newFrame, this, &StreamRep3D::vtkImageDataChangedSlot);
64  this->newTool(mTrackedStream->getProbeTool());
65  this->newVideoSource(mTrackedStream->getVideoSource());
66  }
67 }
68 
69 void StreamRep3D::newTool(ToolPtr tool)
70 {
71 }
72 
73 void StreamRep3D::newVideoSource(VideoSourcePtr videoSource)
74 {
75  if(!videoSource)
76  return;
77 
78  ImagePtr image = mTrackedStream->getChangingImage();
79  this->setImage(image);
80 // mPatientModelService->insertData(image);
81 
82  this->initTransferFunction(image);
83 
84  mVideoSource = videoSource;
85 }
86 
87 // Set transfer function so that we can see the volume change.
88 // Should be replaced with GUI for TrackedStream
89 void StreamRep3D::initTransferFunction(ImagePtr image)
90 {
91  ImageTF3DPtr tf3D = image->getTransferFunctions3D();
92  IntIntMap opacity;
93  opacity[90] = 0;
94  opacity[100] = 5;
95  opacity[200] = image->getMaxAlphaValue();
96  tf3D->resetAlpha(opacity);
97  image->setTransferFunctions3D(tf3D);
98 }
99 
101 {
102  return mTrackedStream;
103 }
104 
105 QString StreamRep3D::getType() const
106 {
107  return "StreamRep3D";
108 }
109 
110 void StreamRep3D::setVisualizerType()
111 {
112  QString visualizerType = settings()->value("View3D/ImageRender3DVisualizer").toString();
113  if(visualizerType == "vtkVolumeTextureMapper3D")
115  else if(visualizerType == "vtkGPUVolumeRayCastMapper")
117  else
118  reportError(QString("StreamRep3D::setVisualizerType(): No visualizer found for string=%1").arg(visualizerType));
119 }
120 
121 } //cx
cxVolumeProperty.h
cx::Settings::value
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
Definition: cxSettings.cpp:66
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::VolumetricRep::setUseVolumeTextureMapper
void setUseVolumeTextureMapper()
Definition: cxVolumetricRep.cpp:69
cx::StreamRep3D::getType
virtual QString getType() const
Definition: cxStreamRep3D.cpp:105
cxReporter.h
cx::StreamRep3D::New
static StreamRep3DPtr New(SpaceProviderPtr spaceProvider, PatientModelServicePtr patientModelService, const QString &uid="")
Definition: cxStreamRep3D.cpp:35
cx::ImageTF3DPtr
boost::shared_ptr< class ImageTF3D > ImageTF3DPtr
Definition: cxForwardDeclarations.h:50
cxVideoSourceGraphics.h
cx::VideoSourcePtr
boost::shared_ptr< class VideoSource > VideoSourcePtr
Definition: cxForwardDeclarations.h:109
cx::TrackedStream::newFrame
void newFrame()
cx::StreamRep3D
Display a 3D stream in 3D.
Definition: cxStreamRep3D.h:31
cx::StreamRep3D::getTrackedStream
TrackedStreamPtr getTrackedStream()
Definition: cxStreamRep3D.cpp:100
cxStreamRep3D.h
cx::VolumetricRep::vtkImageDataChangedSlot
void vtkImageDataChangedSlot()
Definition: cxVolumetricRep.cpp:134
cx::PatientModelServicePtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Definition: cxLogicManager.h:25
cxTool.h
cxView.h
cxPatientModelService.h
cx::VolumetricRep::setImage
virtual void setImage(ImagePtr image)
set the reps image
Definition: cxVolumetricRep.cpp:98
cx::ImagePtr
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:27
cxSettings.h
cx::IntIntMap
std::map< int, int > IntIntMap
Definition: cxImage.h:35
cxRegistrationTransform.h
cx::TrackedStream::newVideoSource
void newVideoSource(VideoSourcePtr videoSource)
cx::VolumetricRep::setUseGPUVolumeRayCastMapper
void setUseGPUVolumeRayCastMapper()
Definition: cxVolumetricRep.cpp:58
cx::TrackedStream::newTool
void newTool(ToolPtr tool)
cx::ToolPtr
boost::shared_ptr< class Tool > ToolPtr
Definition: cxVideoConnectionWidget.h:43
cx::VolumetricRep
Display a volume in 3D.
Definition: cxVolumetricRep.h:69
cx::StreamRep3D::setTrackedStream
void setTrackedStream(TrackedStreamPtr trackedStream)
Definition: cxStreamRep3D.cpp:48
cxImageTF3D.h
cx::StreamRep3DPtr
boost::shared_ptr< class StreamRep3D > StreamRep3DPtr
Definition: cxForwardDeclarations.h:99
cx::reportError
void reportError(QString msg)
Definition: cxLogger.cpp:71
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::settings
Settings * settings()
Shortcut for accessing the settings instance.
Definition: cxSettings.cpp:21
cxTrackedStream.h