Fraxinus  17.12
An IGT application
cxTexture3DSlicerRep.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) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 
34 #include "cxTexture3DSlicerRep.h"
35 
36 #include <vtkRenderer.h>
37 #include <vtkFloatArray.h>
38 #include <vtkPlaneSource.h>
39 #include <vtkPointData.h>
40 #include <vtkTriangleFilter.h>
41 #include <vtkStripper.h>
42 #include <vtkImageData.h>
43 #include <vtkLookupTable.h>
44 
45 #include "cxImage.h"
46 #include "cxView.h"
47 #include "cxImageLUT2D.h"
48 #include "cxSliceProxy.h"
49 #include "cxTypeConversions.h"
50 #include "cxGPUImageBuffer.h"
51 #include "cxTexture3DSlicerProxy.h"
52 
53 #include "cxSharedOpenGLContext.h"
54 
55 //---------------------------------------------------------
56 namespace cx
57 {
58 //---------------------------------------------------------
59 
61 {
62  mProxy->setTargetSpaceToR();
63 }
64 
66  RepImpl()
67 {
68  mProxy = Texture3DSlicerProxy::New(context);
69 }
70 
72 {
73 }
74 
76 {
77  return "Texture3DSlicerRep";
78 }
79 
81 {
82  return wrap_new(new Texture3DSlicerRep(context), uid);
83 }
84 
86 {
87  mProxy->setShaderPath(path);
88 }
89 
90 void Texture3DSlicerRep::viewChanged()
91 {
92  if (!this->getView())
93  return;
94  if (this->getView()->getZoomFactor() < 0)
95  return; // ignore if zoom is invalid
96  mProxy->setViewportData(this->getView()->get_vpMs(), this->getView()->getViewport());
97 }
98 
99 void Texture3DSlicerRep::setImages(std::vector<ImagePtr> images)
100 {
101  mProxy->setImages(images);
102 }
103 
104 std::vector<ImagePtr> Texture3DSlicerRep::getImages()
105 {
106  return mProxy->getImages();
107 }
108 
110 {
111  mProxy->setSliceProxy(slicer);
112 }
113 
115 {
116  view->getRenderer()->AddActor(mProxy->getActor());
117  connect(view.get(), SIGNAL(resized(QSize)), this, SLOT(viewChanged()));
118  this->viewChanged();
119 }
120 
122 {
123  view->getRenderer()->RemoveActor(mProxy->getActor());
124  disconnect(view.get(), SIGNAL(resized(QSize)), this, SLOT(viewChanged()));
125 }
126 
127 void Texture3DSlicerRep::printSelf(std::ostream & os, Indent indent)
128 {
129 
130 }
131 
133 {
134  mProxy->setViewportData(vpMs, vp);
135 }
136 
138 {
139  return Texture3DSlicerProxy::isSupported(window);
140 }
141 
143 {
144  mProxy->setRenderWindow(window);
145 }
146 
147 //---------------------------------------------------------
148 }//end namespace
149 //---------------------------------------------------------
boost::shared_ptr< class Texture3DSlicerRep > Texture3DSlicerRepPtr
ViewPtr getView() const
Definition: cxRepImpl.cpp:104
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< class SliceProxy > SliceProxyPtr
void setRenderWindow(vtkRenderWindowPtr window)
virtual void printSelf(std::ostream &os, Indent indent)
void setSliceProxy(SliceProxyPtr slicer)
static boost::shared_ptr< REP > wrap_new(REP *object, QString uid)
Definition: cxRepImpl.h:83
vtkSmartPointer< class vtkRenderWindow > vtkRenderWindowPtr
Texture3DSlicerRep(SharedOpenGLContextPtr context)
boost::shared_ptr< class View > ViewPtr
void setShaderPath(QString path)
virtual void removeRepActorsFromViewRenderer(ViewPtr view)
boost::shared_ptr< class SharedOpenGLContext > SharedOpenGLContextPtr
std::vector< ImagePtr > getImages()
virtual QString getType() const
static Texture3DSlicerRepPtr New(SharedOpenGLContextPtr context, const QString &uid="")
Formatting class for debug printing of the ssc library.
Definition: cxIndent.h:49
Default implementation of Rep.
Definition: cxRepImpl.h:63
void setImages(std::vector< ImagePtr > images)
Representation of a floating-point bounding box in 3D. The data are stored as {xmin,xmax,ymin,ymax,zmin,zmax}, in order to simplify communication with vtk.
virtual void addRepActorsToViewRenderer(ViewPtr view)
static bool isSupported(vtkRenderWindowPtr window)
static bool isSupported(vtkRenderWindowPtr window)
void setViewportData(const Transform3D &vpMs, const DoubleBoundingBox3D &vp)
static Texture3DSlicerProxyPtr New(SharedOpenGLContextPtr context)
Namespace for all CustusX production code.