Fraxinus  16.5.0-fx-rc6
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 <vtkPainterPolyDataMapper.h>
44 #include <vtkLookupTable.h>
45 
46 #include "cxImage.h"
47 #include "cxView.h"
48 #include "cxImageLUT2D.h"
49 #include "cxSliceProxy.h"
50 #include "cxTypeConversions.h"
51 #include "cxGPUImageBuffer.h"
52 #include "cxTexture3DSlicerProxy.h"
53 
54 //---------------------------------------------------------
55 namespace cx
56 {
57 //---------------------------------------------------------
58 
60 {
61  mProxy->setTargetSpaceToR();
62 }
63 
65  RepImpl()
66 {
67  mProxy = Texture3DSlicerProxy::New();
68 }
69 
71 {
72 }
73 
75 {
76  return wrap_new(new Texture3DSlicerRep(), uid);
77 }
78 
80 {
81  mProxy->setShaderPath(path);
82 }
83 
84 void Texture3DSlicerRep::viewChanged()
85 {
86  if (!this->getView())
87  return;
88  if (this->getView()->getZoomFactor() < 0)
89  return; // ignore if zoom is invalid
90  mProxy->setViewportData(this->getView()->get_vpMs(), this->getView()->getViewport());
91 }
92 
93 void Texture3DSlicerRep::setImages(std::vector<ImagePtr> images)
94 {
95  mProxy->setImages(images);
96 }
97 
98 std::vector<ImagePtr> Texture3DSlicerRep::getImages()
99 {
100  return mProxy->getImages();
101 }
102 
104 {
105  mProxy->setSliceProxy(slicer);
106 }
107 
109 {
110  view->getRenderer()->AddActor(mProxy->getActor());
111  connect(view.get(), SIGNAL(resized(QSize)), this, SLOT(viewChanged()));
112  this->viewChanged();
113 }
114 
116 {
117  view->getRenderer()->RemoveActor(mProxy->getActor());
118  disconnect(view.get(), SIGNAL(resized(QSize)), this, SLOT(viewChanged()));
119 }
120 
122 {
123  mProxy->update();
124 }
125 
126 void Texture3DSlicerRep::printSelf(std::ostream & os, Indent indent)
127 {
128 
129 }
130 
132 {
133  mProxy->setViewportData(vpMs, vp);
134 }
135 
137 {
138  return Texture3DSlicerProxy::isSupported(window);
139 }
140 
141 //---------------------------------------------------------
142 }//end namespace
143 //---------------------------------------------------------
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
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
static Texture3DSlicerProxyPtr New()
vtkSmartPointer< class vtkRenderWindow > vtkRenderWindowPtr
static Texture3DSlicerRepPtr New(const QString &uid="")
boost::shared_ptr< class View > ViewPtr
void setShaderPath(QString path)
virtual void removeRepActorsFromViewRenderer(ViewPtr view)
std::vector< ImagePtr > getImages()
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)
void setViewportData(const Transform3D &vpMs, const DoubleBoundingBox3D &vp)
static bool isSupported(vtkRenderWindowPtr window)