NorMIT-nav  22.09
An IGT application
cxCrossHairRep2D.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 /*
14  * vmCrossHairRep2D.cpp
15  *
16  * Created on: Jan 13, 2009
17  * Author: christiana
18  */
19 
20 #include "cxCrossHairRep2D.h"
21 
22 #include <vtkActor2D.h>
23 #include <vtkRenderer.h>
24 
25 #include "cxTool.h"
26 #include "cxView.h"
27 #include "cxSliceProxy.h"
28 #include "cxVtkHelperClasses.h"
29 #include "cxSpaceProvider.h"
30 
31 namespace cx
32 {
33 
35  RepImpl(),
36  m_vpMs(Transform3D::Identity()),
37  mSpaceProvider(spaceProvider)
38 {
39 }
40 
42 {
43 }
44 
45 CrossHairRep2DPtr CrossHairRep2D::New(SpaceProviderPtr spaceProvider, const QString& uid)
46 {
47  return wrap_new(new CrossHairRep2D(spaceProvider), uid);
48 }
49 
50 QString CrossHairRep2D::getType() const
51 {
52  return "vm::CrossHairRep2D";
53 }
54 
56 {
57  m_vpMs = vpMs;
58  update();
59 }
60 
62 {
63  if (mSlicer)
64  {
65  disconnect(mSlicer.get(), SIGNAL(transformChanged(Transform3D)), this, SLOT(sliceTransformChangedSlot(Transform3D)));
66  disconnect(mSlicer.get(), SIGNAL(toolTransformAndTimestamp(Transform3D,double)), this, SLOT(toolTransformAndTimestampSlot(Transform3D,double)));
67  disconnect(mSlicer.get(), SIGNAL(toolVisible(bool)), this, SLOT(toolVisibleSlot(bool)));
68  }
69 
70  mSlicer = slicer;
71 
72  connect(mSlicer.get(), SIGNAL(transformChanged(Transform3D)), this, SLOT(sliceTransformChangedSlot(Transform3D)));
73  connect(mSlicer.get(), SIGNAL(toolTransformAndTimestamp(Transform3D,double)), this, SLOT(toolTransformAndTimestampSlot(Transform3D,double)));
74  connect(mSlicer.get(), SIGNAL(toolVisible(bool)), this, SLOT(toolVisibleSlot(bool)));
75 
76  update();
77 }
78 
80 {
81  mCursor.reset( new CrossHair2D(view->getRenderer()) ) ;
82  double bordarOffset = 150.0;
83  RGBColor color( 1.0, 0.8, 0.0 );
84  mCursor->setValue( Vector3D(0,0,0), 100, 100, bordarOffset, color );
85  update();
86 }
87 
89 {
90  mCursor.reset();
91 }
92 
93 void CrossHairRep2D::sliceTransformChangedSlot(Transform3D sMr)
94 {
95  update();
96 }
97 void CrossHairRep2D::toolTransformAndTimestampSlot(Transform3D prMt, double timestamp)
98 {
99  update();
100 }
101 void CrossHairRep2D::toolVisibleSlot(bool visible)
102 {
103  update();
104 }
105 
106 void CrossHairRep2D::update()
107 {
108  if (!mSlicer || !mSlicer->getTool())
109  return;
110 
111  Transform3D prMt = mSlicer->getTool()->get_prMt();
112  Transform3D rMpr = mSpaceProvider->get_rMpr();
113  Transform3D sMr = mSlicer->get_sMr();
114 
115  if (mCursor)
116  {
117  Transform3D vpMt = m_vpMs*sMr*rMpr*prMt;
118  mCursor->updateRegCross( vpMt.coord(Vector3D(0,0,0)) );
119  //Logger::log("vm.log", "CrossHairRep2D::update(), center=" + string_cast(vpMt.coord(Vector3D(0,0,0))));
120  }
121 }
122 
123 }
cx::CrossHairRep2D::set_vpMs
void set_vpMs(const Transform3D &vpMs)
Definition: cxCrossHairRep2D.cpp:55
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::CrossHairRep2D::removeRepActorsFromViewRenderer
virtual void removeRepActorsFromViewRenderer(ViewPtr view)
Definition: cxCrossHairRep2D.cpp:88
cx::CrossHairRep2D::New
static CrossHairRep2DPtr New(SpaceProviderPtr spaceProvider, const QString &uid="")
Definition: cxCrossHairRep2D.cpp:45
cx::SliceProxyPtr
boost::shared_ptr< class SliceProxy > SliceProxyPtr
Definition: cxForwardDeclarations.h:96
cx::CrossHairRep2D::CrossHairRep2D
CrossHairRep2D(SpaceProviderPtr spaceProvider)
Definition: cxCrossHairRep2D.cpp:34
cx::CrossHairRep2D::getType
virtual QString getType() const
Definition: cxCrossHairRep2D.cpp:50
cx::CrossHair2D
Helper for drawing a crosshair in 2D.
Definition: cxVtkHelperClasses.h:147
cx::Transform3D
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
Definition: cxLandmarkPatientRegistrationWidget.h:33
cxTool.h
cxView.h
cx::CrossHairRep2DPtr
boost::shared_ptr< class CrossHairRep2D > CrossHairRep2DPtr
Definition: cxForwardDeclarations.h:65
cx::CrossHairRep2D::~CrossHairRep2D
virtual ~CrossHairRep2D()
Definition: cxCrossHairRep2D.cpp:41
cxCrossHairRep2D.h
cx::ViewPtr
boost::shared_ptr< class View > ViewPtr
Definition: cxForwardDeclarations.h:110
cx::RepImpl
Default implementation of Rep.
Definition: cxRepImpl.h:42
cx::CrossHairRep2D::addRepActorsToViewRenderer
virtual void addRepActorsToViewRenderer(ViewPtr view)
Definition: cxCrossHairRep2D.cpp:79
cx::CrossHairRep2D::setSliceProxy
void setSliceProxy(SliceProxyPtr slicer)
Definition: cxCrossHairRep2D.cpp:61
cxVtkHelperClasses.h
cx::RGBColor
RGB color data.
Definition: cxVtkHelperClasses.h:48
cxSliceProxy.h
cx::RepImpl::wrap_new
static boost::shared_ptr< REP > wrap_new(REP *object, QString uid)
Definition: cxRepImpl.h:62
cx::Vector3D
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
cx::SpaceProviderPtr
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
Definition: cxLogicManager.h:23
cxSpaceProvider.h