CustusX  22.04-rc5
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 //---------------------------------------------------------
void setShaderPath(QString path)
static SliceProxyPtr create(PatientModelServicePtr dataManager)
Slices3DRep(SharedOpenGLContextPtr context)
boost::shared_ptr< class SliceProxy > SliceProxyPtr
static boost::shared_ptr< REP > wrap_new(REP *object, QString uid)
Definition: cxRepImpl.h:62
boost::shared_ptr< class View > ViewPtr
virtual void removeRepActorsFromViewRenderer(ViewPtr view)
boost::shared_ptr< class SharedOpenGLContext > SharedOpenGLContextPtr
boost::shared_ptr< class Slices3DRep > Slices3DRepPtr
void reportWarning(QString msg)
Definition: cxLogger.cpp:70
virtual ~Slices3DRep()
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Default implementation of Rep.
Definition: cxRepImpl.h:42
boost::shared_ptr< class Texture3DSlicerProxy > Texture3DSlicerProxyPtr
static Slices3DRepPtr New(SharedOpenGLContextPtr context, const QString &uid)
void setImages(std::vector< ImagePtr > images)
virtual void addRepActorsToViewRenderer(ViewPtr view)
void setTool(ToolPtr tool)
void addPlane(PLANE_TYPE plane, PatientModelServicePtr dataManager)
static Texture3DSlicerProxyPtr New(SharedOpenGLContextPtr context)
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr