CustusX  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 
ptCORONAL
a slice seen from the front of the patient
Definition: cxDefinitions.h:39
virtual void addRepActorsToViewRenderer(ViewPtr view)
mdRADIOLOGICAL
Definition: cxDefinitions.h:60
static OrientationAnnotation * New()
static boost::shared_ptr< REP > wrap_new(REP *object, QString uid)
Definition: cxRepImpl.h:62
cstring_cast_Placeholder cstring_cast(const T &val)
ptAXIAL
a slice seen from the top of the patient
Definition: cxDefinitions.h:39
boost::shared_ptr< class View > ViewPtr
OrientationAnnotationRep(PatientModelServicePtr dataManager)
boost::shared_ptr< class OrientationAnnotationRep > OrientationAnnotationRepPtr
ptSAGITTAL
a slice seen from the side of the patient
Definition: cxDefinitions.h:39
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Default implementation of Rep.
Definition: cxRepImpl.h:42
mdNEUROLOGICAL
Definition: cxDefinitions.h:60
OrientationAnnotationPtr mOrientation
virtual void removeRepActorsFromViewRenderer(ViewPtr view)
virtual void SetTextActorsPosition(int vsize[2])
static OrientationAnnotationRepPtr New(PatientModelServicePtr dataManager, const QString &uid="")
Namespace for all CustusX production code.