NorMIT-nav  22.09
An IGT application
cxDistanceMetricRep.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 "cxDistanceMetricRep.h"
14 #include "cxView.h"
15 
16 #include <vtkVectorText.h>
17 #include <vtkFollower.h>
18 #include <vtkPolyDataMapper.h>
19 #include <vtkProperty.h>
20 #include <vtkRenderer.h>
21 #include <vtkCamera.h>
22 #include <vtkRenderWindow.h>
23 #include "cxTypeConversions.h"
24 
25 namespace cx
26 {
27 
29 {
30  return wrap_new(new DistanceMetricRep(), uid);
31 }
32 
33 DistanceMetricRep::DistanceMetricRep()
34 {
35 }
36 
38 {
40  mGraphicalLine.reset();
41 }
42 
43 DistanceMetricPtr DistanceMetricRep::getDistanceMetric()
44 {
45  return boost::dynamic_pointer_cast<DistanceMetric>(mMetric);
46 }
47 
49 {
50  DistanceMetricPtr distanceMetric = this->getDistanceMetric();
51  if (!distanceMetric)
52  return;
53 
54  if (!mMetric->isValid())
55  return;
56 
57  if (!mGraphicalLine && this->getView())
58  {
59  mGraphicalLine.reset(new GraphicalLine3D(this->getRenderer()));
60  }
61 
62  if (mGraphicalLine)
63  {
64  mGraphicalLine->setColor(mMetric->getColor());
65  std::vector<Vector3D> p = distanceMetric->getEndpoints();
66  mGraphicalLine->setValue(p[0], p[1]);
67  mGraphicalLine->setStipple(0xF0FF);
68  }
69 
70  this->drawText();
71 }
72 
73 
74 }
cx::DistanceMetricRepPtr
boost::shared_ptr< class DistanceMetricRep > DistanceMetricRepPtr
Definition: cxDistanceMetricRep.h:30
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::DistanceMetricRep::onModifiedStartRender
virtual void onModifiedStartRender()
Definition: cxDistanceMetricRep.cpp:48
cx::DataMetricRep::clear
virtual void clear()
Definition: cxDataMetricRep.cpp:84
cx::RepImpl::getRenderer
vtkRendererPtr getRenderer()
Definition: cxRepImpl.cpp:88
cx::GraphicalLine3D
Helper for rendering a line in 3D.
Definition: cxGraphicalPrimitives.h:146
cxDistanceMetricRep.h
cx::DistanceMetricRep
Rep for visualizing a DistanceMetric.
Definition: cxDistanceMetricRep.h:40
cx::RepImpl::getView
ViewPtr getView() const
Definition: cxRepImpl.cpp:83
cxTypeConversions.h
cxView.h
cx::DataMetricRep::drawText
void drawText()
Definition: cxDataMetricRep.cpp:109
cx::DistanceMetricRep::clear
virtual void clear()
Definition: cxDistanceMetricRep.cpp:37
cx::DistanceMetricRep::New
static DistanceMetricRepPtr New(const QString &uid="")
Definition: cxDistanceMetricRep.cpp:28
cx::DistanceMetricPtr
boost::shared_ptr< class DistanceMetric > DistanceMetricPtr
Definition: cxForwardDeclarations.h:67
cx::DataMetricRep::mMetric
DataMetricPtr mMetric
Definition: cxDataMetricRep.h:68
cx::RepImpl::wrap_new
static boost::shared_ptr< REP > wrap_new(REP *object, QString uid)
Definition: cxRepImpl.h:62