CustusX  2023.01.05-dev+develop.0da12
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 }
boost::shared_ptr< class DistanceMetricRep > DistanceMetricRepPtr
ViewPtr getView() const
Definition: cxRepImpl.cpp:83
vtkRendererPtr getRenderer()
Definition: cxRepImpl.cpp:88
virtual void onModifiedStartRender()
boost::shared_ptr< class DistanceMetric > DistanceMetricPtr
virtual void clear()
static boost::shared_ptr< REP > wrap_new(REP *object, QString uid)
Definition: cxRepImpl.h:62
Helper for rendering a line in 3D.
Data class that represents a distance between two points, or a point and a plane. ...
Rep for visualizing a DistanceMetric.
DataMetricPtr mMetric
static DistanceMetricRepPtr New(const QString &uid="")
Namespace for all CustusX production code.