Fraxinus  2023.01.05-dev+develop.0da12
An IGT application
cxSlicerRepSW.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 "cxSlicerRepSW.h"
14 
15 #include <vtkImageActor.h>
16 #include <vtkRenderer.h>
17 #include <vtkImageData.h>
18 
19 #include "cxView.h"
20 #include "cxImage.h"
21 #include "cxSlicedImageProxy.h"
22 #include "vtkImageMapper3D.h"
23 #include "vtkImageAlgorithm.h"
24 
25 namespace cx
26 {
27 
29  RepImpl()
30 {
31  mImageSlicer.reset(new SlicedImageProxy());
32  mImageActor = vtkImageActorPtr::New();
33  mImageActor->GetMapper()->SetInputConnection(mImageSlicer->getOutputPort()->GetOutputPort());
34 // mImageActor->SetInput(mImageSlicer->getOutputPort());
35 }
36 
38 {
39 }
40 
41 SliceRepSWPtr SliceRepSW::New(const QString& uid)
42 {
43  return wrap_new(new SliceRepSW(), uid);
44 }
45 
47 {
48  return mImageSlicer->getImage();
49 }
50 
52 {
53  return mImageActor;
54 }
55 
60 {
61  if (image == getImage())
62  return;
63  mImageSlicer->setImage(image);
64 }
65 
67 {
68  return mImageSlicer->getImage() ? mImageSlicer->getImage()->getUid() : "";
69 }
70 
72 {
73  mImageSlicer->setSliceProxy(slicer);
74 }
75 
77 {
78  view->getRenderer()->AddActor(mImageActor);
79 }
80 
82 {
83  view->getRenderer()->RemoveActor(mImageActor);
84 }
85 
86 bool SliceRepSW::hasImage(ImagePtr image) const
87 {
88  return (mImageSlicer->getImage() != NULL);
89 }
90 
92 {
93  mImageSlicer->update();
94 }
95 
96 void SliceRepSW::printSelf(std::ostream & os, Indent indent)
97 {
98  mImageSlicer->printSelf(os, indent);
99 }
100 
101 }// namespace cx
QString getImageUid() const
virtual void removeRepActorsFromViewRenderer(ViewPtr view)
virtual void printSelf(std::ostream &os, Indent indent)
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:27
void setSliceProxy(SliceProxyInterfacePtr slicer)
static boost::shared_ptr< REP > wrap_new(REP *object, QString uid)
Definition: cxRepImpl.h:62
ImagePtr getImage()
vtkSmartPointer< class vtkImageActor > vtkImageActorPtr
boost::shared_ptr< class View > ViewPtr
Helper class for slicing an image given a SliceProxy and an image.
virtual void addRepActorsToViewRenderer(ViewPtr view)
boost::shared_ptr< class SliceRepSW > SliceRepSWPtr
bool hasImage(ImagePtr image) const
Formatting class for debug printing of the ssc library.
Definition: cxIndent.h:28
static SliceRepSWPtr New(const QString &uid="")
Default implementation of Rep.
Definition: cxRepImpl.h:42
vtkImageActorPtr getActor()
void setImage(ImagePtr image)
virtual ~SliceRepSW()
boost::shared_ptr< class SliceProxyInterface > SliceProxyInterfacePtr
Namespace for all CustusX production code.