NorMIT-nav  16.5
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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) 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 
35 
36 #include <vtkTextProperty.h>
37 #include <vtkRenderer.h>
38 #include <vtkTextMapper.h>
39 #include <vtkObjectFactory.h>
40 
41 #include "cxView.h"
42 #include "cxSliceProxy.h"
43 #include "cxVtkHelperClasses.h"
44 #include "cxTypeConversions.h"
45 #include "cxPatientModelService.h"
46 
47 
48 // --------------------------------------------------------
49 namespace cx
50 // --------------------------------------------------------
51 {
52 
53 
57 {
58  vtkObject* ret = vtkObjectFactory::CreateInstance("OrientationAnnotation");
59  if (ret)
60  {
61  return static_cast<OrientationAnnotation*>(ret);
62  }
63  return new OrientationAnnotation;
64 }
65 
67 {
68 
69 }
70 
72 {
73 }
74 
76 {
77  //Logger::log("nav.log","set text position");
78  this->TextActor[2]->SetPosition(5, vsize[1]/2);
79  this->TextActor[3]->SetPosition(vsize[0]/2, 7);
80  this->TextActor[0]->SetPosition(vsize[0]-7, vsize[1]/2);
81  this->TextActor[1]->SetPosition(vsize[0]/2, vsize[1]-7);
82 }
84 {
85  vtkTextProperty* tprop = this->TextMapper[2]->GetTextProperty();
86  tprop->SetJustificationToLeft();
87  tprop->SetVerticalJustificationToCentered();
88 
89  tprop = this->TextMapper[3]->GetTextProperty();
90  tprop->SetJustificationToCentered();
91  tprop->SetVerticalJustificationToBottom();
92 
93  tprop = this->TextMapper[0]->GetTextProperty();
94  tprop->SetJustificationToRight();
95  tprop->SetVerticalJustificationToCentered();
96 
97  tprop = this->TextMapper[1]->GetTextProperty();
98  tprop->SetJustificationToCentered();
99  tprop->SetVerticalJustificationToTop();
100 }
101 
102 
103 //---------------------------------------------------------
104 //---------------------------------------------------------
105 //---------------------------------------------------------
106 
107 
109  RepImpl(),
110  mDataManager(dataManager)
111 {
112  mPlane = ptCOUNT;
113  connect(mDataManager.get(), SIGNAL(clinicalApplicationChanged()), this, SLOT(clinicalApplicationChangedSlot()));
114 }
115 
117 {
118  return wrap_new(new OrientationAnnotationRep(dataManager), uid);
119 }
120 
122 {
123 
124 }
125 
127 {
128  mOrientation->SetVisibility(visible);
129 }
130 
131 
132 void OrientationAnnotationRep::clinicalApplicationChangedSlot()
133 {
134  this->setPlaneType(mPlane);
135 }
136 
138 {
139  switch (mDataManager->getClinicalApplication())
140  {
141  case mdRADIOLOGICAL:
142  {
143  this->setPlaneTypeRadiology(type);
144  break;
145  }
146  case mdNEUROLOGICAL:
147  default:
148  {
149  this->setPlaneTypeNeurology(type);
150  break;
151  }
152  }
153 
154  mPlane = type;
156 }
157 
159 {
160  switch (type)
161  {
162  case ptSAGITTAL:
163  {
164  mNorthAnnotation = "S";
165  mSouthAnnotation = "I";
166  mEastAnnotation = "P";
167  mWestAnnotation = "A";
168  break;
169  }
170  case ptCORONAL:
171  {
172  mNorthAnnotation = "S";
173  mSouthAnnotation = "I" ;
174  mEastAnnotation = "R" ;
175  mWestAnnotation = "L";
176  break;
177  }
178  case ptAXIAL:
179  {
180  mNorthAnnotation = "A";
181  mSouthAnnotation = "P";
182  mEastAnnotation = "R";
183  mWestAnnotation = "L";
184  break;
185  }
186  default:
187  {
188  mNorthAnnotation = "";
189  mSouthAnnotation = "";
190  mEastAnnotation = "";
191  mWestAnnotation = "";
192  }
193  }
194 }
195 
197 {
198  switch (type)
199  {
200  case ptSAGITTAL:
201  {
202  mNorthAnnotation = "S";
203  mSouthAnnotation = "I";
204  mEastAnnotation = "P";
205  mWestAnnotation = "A";
206  break;
207  }
208  case ptCORONAL:
209  {
210  mNorthAnnotation = "S";
211  mSouthAnnotation = "I" ;
212  mEastAnnotation = "L" ;
213  mWestAnnotation = "R";
214  break;
215  }
216  case ptAXIAL:
217  {
218  mNorthAnnotation = "A";
219  mSouthAnnotation = "P";
220  mEastAnnotation = "L";
221  mWestAnnotation = "R";
222  break;
223  }
224  default:
225  {
226  mNorthAnnotation = "";
227  mSouthAnnotation = "";
228  mEastAnnotation = "";
229  mWestAnnotation = "";
230  }
231  }
232 }
233 
235 {
237  view->getRenderer()->AddActor(mOrientation);
238 }
239 
241 {
242  view->getRenderer()->RemoveActor(mOrientation);
243 }
244 
246 {
247  if (!mOrientation)
248  {
249  mOrientation = OrientationAnnotationPtr::New();
250  mOrientation->SetNonlinearFontScaleFactor (0.35 );
251  mOrientation->GetTextProperty()->SetColor(0.7372, 0.815, 0.6039 );
252  }
257 }
258 
259 
260 // --------------------------------------------------------
261 } //end namespace
262 // --------------------------------------------------------
263 
264 
ptCORONAL
a slice seen from the front of the patient
Definition: cxDefinitions.h:56
virtual void addRepActorsToViewRenderer(ViewPtr view)
mdRADIOLOGICAL
Definition: cxDefinitions.h:75
static OrientationAnnotation * New()
static boost::shared_ptr< REP > wrap_new(REP *object, QString uid)
Definition: cxRepImpl.h:83
cstring_cast_Placeholder cstring_cast(const T &val)
ptAXIAL
a slice seen from the top of the patient
Definition: cxDefinitions.h:56
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:56
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Default implementation of Rep.
Definition: cxRepImpl.h:63
mdNEUROLOGICAL
Definition: cxDefinitions.h:75
OrientationAnnotationPtr mOrientation
virtual void removeRepActorsFromViewRenderer(ViewPtr view)
virtual void SetTextActorsPosition(int vsize[2])
static OrientationAnnotationRepPtr New(PatientModelServicePtr dataManager, const QString &uid="")