NorMIT-nav  22.09
An IGT application
cxSlices3DRep.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 "cxSlices3DRep.h"
13 
14 #include <vtkRenderer.h>
15 #include <vtkFloatArray.h>
16 #include <vtkPlaneSource.h>
17 #include <vtkPointData.h>
18 #include <vtkTriangleFilter.h>
19 #include <vtkStripper.h>
20 #include <vtkImageData.h>
21 #include <vtkLookupTable.h>
22 #include "cxLogger.h"
23 #include "cxImage.h"
24 #include "cxView.h"
25 #include "cxImageLUT2D.h"
26 #include "cxSliceProxy.h"
27 #include "cxTypeConversions.h"
28 #include "cxGPUImageBuffer.h"
29 #include "cxTexture3DSlicerProxy.h"
30 
31 
32 //---------------------------------------------------------
33 namespace cx
34 {
35 //---------------------------------------------------------
36 
38  RepImpl(),
39  mSharedOpenGLContext(context)
40 {
41 }
42 
44 {
45 }
46 
48 {
49  return wrap_new(new Slices3DRep(context), uid);
50 }
51 
52 void Slices3DRep::setShaderPath(QString path)
53 {
54  for (unsigned i=0; i<mProxy.size(); ++i)
55  mProxy[i]->setShaderPath(path);
56 }
57 
58 void Slices3DRep::setImages(std::vector<ImagePtr> images)
59 {
60  if (images.empty())
61  {
62  reportWarning("Slices3DRep::setImages: No input images (in ViewGroup)");
63  return;
64  }
65  for (unsigned i=0; i<mProxy.size(); ++i)
66  {
67  mProxy[i]->setImages(images);
68  mProxy[i]->getSliceProxy()->setDefaultCenter(images[0]->get_rMd().coord(images[0]->boundingBox().center()));
69  }
70 }
71 
72 void Slices3DRep::addPlane(PLANE_TYPE plane, PatientModelServicePtr dataManager)
73 {
74  SliceProxyPtr sliceProxy = SliceProxy::create(dataManager);
75  sliceProxy->initializeFromPlane(plane, false, true, 150, 0.25);
76  sliceProxy->setAlwaysUseDefaultCenter(true);
77 
78  Texture3DSlicerProxyPtr current = Texture3DSlicerProxy::New(mSharedOpenGLContext);
79  current->setSliceProxy(sliceProxy);
80  current->setTargetSpaceToR();
81 
82  mProxy.push_back(current);
83 }
84 
86 {
87  for (unsigned i=0; i<mProxy.size(); ++i)
88  mProxy[i]->getSliceProxy()->setTool(tool);
89 }
90 
92 {
93  for (unsigned i=0; i<mProxy.size(); ++i)
94  view->getRenderer()->AddActor(mProxy[i]->getActor());
95 }
96 
98 {
99  for (unsigned i=0; i<mProxy.size(); ++i)
100  view->getRenderer()->RemoveActor(mProxy[i]->getActor());
101 }
102 
103 //---------------------------------------------------------
104 }//end namespace
105 //---------------------------------------------------------
cx::Slices3DRepPtr
boost::shared_ptr< class Slices3DRep > Slices3DRepPtr
Definition: cxViewWrapper3D.h:38
cxLogger.h
cx::Slices3DRep::~Slices3DRep
virtual ~Slices3DRep()
Definition: cxSlices3DRep.cpp:43
cx::Slices3DRep::setTool
void setTool(ToolPtr tool)
Definition: cxSlices3DRep.cpp:85
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::Slices3DRep::setImages
void setImages(std::vector< ImagePtr > images)
Definition: cxSlices3DRep.cpp:58
cxImage.h
cx::Slices3DRep::addRepActorsToViewRenderer
virtual void addRepActorsToViewRenderer(ViewPtr view)
Definition: cxSlices3DRep.cpp:91
cx::Slices3DRep::New
static Slices3DRepPtr New(SharedOpenGLContextPtr context, const QString &uid)
Definition: cxSlices3DRep.cpp:47
cx::SliceProxyPtr
boost::shared_ptr< class SliceProxy > SliceProxyPtr
Definition: cxForwardDeclarations.h:96
cx::Slices3DRep::removeRepActorsFromViewRenderer
virtual void removeRepActorsFromViewRenderer(ViewPtr view)
Definition: cxSlices3DRep.cpp:97
cx::Slices3DRep::setShaderPath
void setShaderPath(QString path)
Definition: cxSlices3DRep.cpp:52
cx::Slices3DRep::Slices3DRep
Slices3DRep(SharedOpenGLContextPtr context)
Definition: cxSlices3DRep.cpp:37
cxSlices3DRep.h
cx::SliceProxy::create
static SliceProxyPtr create(PatientModelServicePtr dataManager)
Definition: cxSliceProxy.cpp:24
cx::Texture3DSlicerProxyPtr
boost::shared_ptr< class Texture3DSlicerProxy > Texture3DSlicerProxyPtr
Definition: cxTexture3DSlicerProxy.h:36
cx::PatientModelServicePtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Definition: cxLogicManager.h:25
cxGPUImageBuffer.h
cxTypeConversions.h
cxView.h
cx::Slices3DRep::addPlane
void addPlane(PLANE_TYPE plane, PatientModelServicePtr dataManager)
Definition: cxSlices3DRep.cpp:72
cx::ViewPtr
boost::shared_ptr< class View > ViewPtr
Definition: cxForwardDeclarations.h:110
cx::RepImpl
Default implementation of Rep.
Definition: cxRepImpl.h:42
cx::ToolPtr
boost::shared_ptr< class Tool > ToolPtr
Definition: cxVideoConnectionWidget.h:43
cxSliceProxy.h
cxImageLUT2D.h
cx::RepImpl::wrap_new
static boost::shared_ptr< REP > wrap_new(REP *object, QString uid)
Definition: cxRepImpl.h:62
cx::reportWarning
void reportWarning(QString msg)
Definition: cxLogger.cpp:70
cx::Texture3DSlicerProxy::New
static Texture3DSlicerProxyPtr New(SharedOpenGLContextPtr context)
Definition: cxTexture3DSlicerProxy.cpp:46
cxTexture3DSlicerProxy.h
cx::SharedOpenGLContextPtr
boost::shared_ptr< class SharedOpenGLContext > SharedOpenGLContextPtr
Definition: cxForwardDeclarations.h:164