NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxOrientationAnnotationRep.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 
14 
15 #include <vtkTextProperty.h>
16 #include <vtkRenderer.h>
17 #include <vtkTextMapper.h>
18 #include <vtkObjectFactory.h>
19 
20 #include "cxView.h"
21 #include "cxSliceProxy.h"
22 #include "cxVtkHelperClasses.h"
23 #include "cxTypeConversions.h"
24 #include "cxPatientModelService.h"
25 
26 
27 // --------------------------------------------------------
28 namespace cx
29 // --------------------------------------------------------
30 {
31 
32 
36 {
37  vtkObject* ret = vtkObjectFactory::CreateInstance("OrientationAnnotation");
38  if (ret)
39  {
40  return static_cast<OrientationAnnotation*>(ret);
41  }
42  return new OrientationAnnotation;
43 }
44 
46 {
47 
48 }
49 
51 {
52 }
53 
55 {
56  //Logger::log("nav.log","set text position");
57  this->TextActor[2]->SetPosition(5, vsize[1]/2);
58  this->TextActor[3]->SetPosition(vsize[0]/2, 7);
59  this->TextActor[0]->SetPosition(vsize[0]-7, vsize[1]/2);
60  this->TextActor[1]->SetPosition(vsize[0]/2, vsize[1]-7);
61 }
63 {
64  vtkTextProperty* tprop = this->TextMapper[2]->GetTextProperty();
65  tprop->SetJustificationToLeft();
66  tprop->SetVerticalJustificationToCentered();
67 
68  tprop = this->TextMapper[3]->GetTextProperty();
69  tprop->SetJustificationToCentered();
70  tprop->SetVerticalJustificationToBottom();
71 
72  tprop = this->TextMapper[0]->GetTextProperty();
73  tprop->SetJustificationToRight();
74  tprop->SetVerticalJustificationToCentered();
75 
76  tprop = this->TextMapper[1]->GetTextProperty();
77  tprop->SetJustificationToCentered();
78  tprop->SetVerticalJustificationToTop();
79 }
80 
81 
82 //---------------------------------------------------------
83 //---------------------------------------------------------
84 //---------------------------------------------------------
85 
86 
88  RepImpl(),
89  mDataManager(dataManager)
90 {
91  mPlane = ptCOUNT;
92  connect(mDataManager.get(), SIGNAL(clinicalApplicationChanged()), this, SLOT(clinicalApplicationChangedSlot()));
93 }
94 
96 {
97  return wrap_new(new OrientationAnnotationRep(dataManager), uid);
98 }
99 
101 {
102 
103 }
104 
106 {
107  mOrientation->SetVisibility(visible);
108 }
109 
110 
111 void OrientationAnnotationRep::clinicalApplicationChangedSlot()
112 {
113  this->setPlaneType(mPlane);
114 }
115 
117 {
118  switch (mDataManager->getClinicalApplication())
119  {
120  case mdRADIOLOGICAL:
121  {
122  this->setPlaneTypeRadiology(type);
123  break;
124  }
125  case mdNEUROLOGICAL:
126  default:
127  {
128  this->setPlaneTypeNeurology(type);
129  break;
130  }
131  }
132 
133  mPlane = type;
135 }
136 
138 {
139  switch (type)
140  {
141  case ptSAGITTAL:
142  {
143  mNorthAnnotation = "S";
144  mSouthAnnotation = "I";
145  mEastAnnotation = "P";
146  mWestAnnotation = "A";
147  break;
148  }
149  case ptCORONAL:
150  {
151  mNorthAnnotation = "S";
152  mSouthAnnotation = "I" ;
153  mEastAnnotation = "R" ;
154  mWestAnnotation = "L";
155  break;
156  }
157  case ptAXIAL:
158  {
159  mNorthAnnotation = "A";
160  mSouthAnnotation = "P";
161  mEastAnnotation = "R";
162  mWestAnnotation = "L";
163  break;
164  }
165  default:
166  {
167  mNorthAnnotation = "";
168  mSouthAnnotation = "";
169  mEastAnnotation = "";
170  mWestAnnotation = "";
171  }
172  }
173 }
174 
176 {
177  switch (type)
178  {
179  case ptSAGITTAL:
180  {
181  mNorthAnnotation = "S";
182  mSouthAnnotation = "I";
183  mEastAnnotation = "P";
184  mWestAnnotation = "A";
185  break;
186  }
187  case ptCORONAL:
188  {
189  mNorthAnnotation = "S";
190  mSouthAnnotation = "I" ;
191  mEastAnnotation = "L" ;
192  mWestAnnotation = "R";
193  break;
194  }
195  case ptAXIAL:
196  {
197  mNorthAnnotation = "A";
198  mSouthAnnotation = "P";
199  mEastAnnotation = "L";
200  mWestAnnotation = "R";
201  break;
202  }
203  default:
204  {
205  mNorthAnnotation = "";
206  mSouthAnnotation = "";
207  mEastAnnotation = "";
208  mWestAnnotation = "";
209  }
210  }
211 }
212 
214 {
216  view->getRenderer()->AddActor(mOrientation);
217 }
218 
220 {
221  view->getRenderer()->RemoveActor(mOrientation);
222 }
223 
225 {
226  if (!mOrientation)
227  {
228  mOrientation = OrientationAnnotationPtr::New();
229  mOrientation->SetNonlinearFontScaleFactor (0.35 );
230  mOrientation->GetTextProperty()->SetColor(0.7372, 0.815, 0.6039 );
231  }
236 }
237 
238 
239 // --------------------------------------------------------
240 } //end namespace
241 // --------------------------------------------------------
242 
243 
cx::OrientationAnnotation::SetTextActorsJustification
virtual void SetTextActorsJustification()
Definition: cxOrientationAnnotationRep.cpp:62
cx::OrientationAnnotationRep::mPlane
PLANE_TYPE mPlane
Definition: cxOrientationAnnotationRep.h:74
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::OrientationAnnotationRep::setPlaneTypeRadiology
void setPlaneTypeRadiology(PLANE_TYPE type)
Definition: cxOrientationAnnotationRep.cpp:175
cx::OrientationAnnotationRep::setPlaneType
void setPlaneType(PLANE_TYPE type)
Definition: cxOrientationAnnotationRep.cpp:116
cx::OrientationAnnotationRep::addRepActorsToViewRenderer
virtual void addRepActorsToViewRenderer(ViewPtr view)
Definition: cxOrientationAnnotationRep.cpp:213
mdNEUROLOGICAL
mdNEUROLOGICAL
Definition: cxDefinitions.h:60
cx::OrientationAnnotation::OrientationAnnotation
OrientationAnnotation()
Definition: cxOrientationAnnotationRep.cpp:45
cx::OrientationAnnotationRep::New
static OrientationAnnotationRepPtr New(PatientModelServicePtr dataManager, const QString &uid="")
Definition: cxOrientationAnnotationRep.cpp:95
cx::OrientationAnnotationRepPtr
boost::shared_ptr< class OrientationAnnotationRep > OrientationAnnotationRepPtr
Definition: cxForwardDeclarations.h:82
cstring_cast
cstring_cast_Placeholder cstring_cast(const T &val)
Definition: cxTypeConversions.h:69
cx::OrientationAnnotationRep::mWestAnnotation
QString mWestAnnotation
Definition: cxOrientationAnnotationRep.h:80
cx::OrientationAnnotationRep::setPlaneTypeNeurology
void setPlaneTypeNeurology(PLANE_TYPE type)
Definition: cxOrientationAnnotationRep.cpp:137
cx::OrientationAnnotationRep::mOrientation
OrientationAnnotationPtr mOrientation
Definition: cxOrientationAnnotationRep.h:73
cx::OrientationAnnotation
Definition: cxOrientationAnnotationRep.h:27
cx::OrientationAnnotationRep::OrientationAnnotationRep
OrientationAnnotationRep(PatientModelServicePtr dataManager)
Definition: cxOrientationAnnotationRep.cpp:87
cx::OrientationAnnotationRep::mEastAnnotation
QString mEastAnnotation
Definition: cxOrientationAnnotationRep.h:79
cx::PatientModelServicePtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Definition: cxLogicManager.h:25
cx::OrientationAnnotation::~OrientationAnnotation
~OrientationAnnotation()
Definition: cxOrientationAnnotationRep.cpp:50
cxTypeConversions.h
cxView.h
cx::OrientationAnnotationRep::createAnnotation
void createAnnotation()
Definition: cxOrientationAnnotationRep.cpp:224
ptCORONAL
ptCORONAL
a slice seen from the front of the patient
Definition: cxDefinitions.h:41
cxPatientModelService.h
cx::ViewPtr
boost::shared_ptr< class View > ViewPtr
Definition: cxForwardDeclarations.h:110
cx::RepImpl
Default implementation of Rep.
Definition: cxRepImpl.h:42
cx::OrientationAnnotationRep::mDataManager
PatientModelServicePtr mDataManager
Definition: cxOrientationAnnotationRep.h:75
cx::OrientationAnnotationRep::setVisible
void setVisible(bool visible)
Definition: cxOrientationAnnotationRep.cpp:105
cx::OrientationAnnotationRep::mSouthAnnotation
QString mSouthAnnotation
Definition: cxOrientationAnnotationRep.h:78
mdRADIOLOGICAL
mdRADIOLOGICAL
Definition: cxDefinitions.h:61
cx::OrientationAnnotationRep::~OrientationAnnotationRep
virtual ~OrientationAnnotationRep()
Definition: cxOrientationAnnotationRep.cpp:100
cx::OrientationAnnotation::SetTextActorsPosition
virtual void SetTextActorsPosition(int vsize[2])
Definition: cxOrientationAnnotationRep.cpp:54
cxVtkHelperClasses.h
ptAXIAL
ptAXIAL
a slice seen from the top of the patient
Definition: cxDefinitions.h:42
cx::OrientationAnnotation::New
static OrientationAnnotation * New()
Definition: cxOrientationAnnotationRep.cpp:35
ptSAGITTAL
ptSAGITTAL
a slice seen from the side of the patient
Definition: cxDefinitions.h:40
cxSliceProxy.h
cx::RepImpl::wrap_new
static boost::shared_ptr< REP > wrap_new(REP *object, QString uid)
Definition: cxRepImpl.h:62
cx::OrientationAnnotationRep::mNorthAnnotation
QString mNorthAnnotation
Definition: cxOrientationAnnotationRep.h:77
cxOrientationAnnotationRep.h
cx::OrientationAnnotationRep::removeRepActorsFromViewRenderer
virtual void removeRepActorsFromViewRenderer(ViewPtr view)
Definition: cxOrientationAnnotationRep.cpp:219