CustusX
2023.01.05-dev+develop.0da12
An IGT application
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
cxDataMetricRep.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
14
#include "
cxDataMetricRep.h
"
15
16
#include "
cxGraphicalPrimitives.h
"
17
#include "
cxView.h
"
18
#include "
cxDataMetric.h
"
19
20
#include "
cxVtkHelperClasses.h
"
21
22
namespace
cx
23
{
24
25
DataMetricRep::DataMetricRep
() :
26
RepImpl
(),
27
mGraphicsSize(1),
28
mShowLabel(false),
29
mLabelSize(2.5),
30
mShowAnnotation(true)
31
// mView(NULL)
32
{
33
}
34
35
void
DataMetricRep::setDataMetric
(
DataMetricPtr
value)
36
{
37
if
(
mMetric
)
38
{
39
disconnect(
mMetric
.get(), SIGNAL(transformChanged()),
this
, SLOT(
setModified
()));
40
disconnect(
mMetric
.get(), SIGNAL(propertiesChanged()),
this
, SLOT(
setModified
()));
41
}
42
43
mMetric
= value;
44
45
if
(mMetric)
46
{
47
connect(mMetric.get(), SIGNAL(propertiesChanged()),
this
, SLOT(
setModified
()));
48
connect(mMetric.get(), SIGNAL(transformChanged()),
this
, SLOT(
setModified
()));
49
}
50
51
this->
clear
();
52
this->
setModified
();
53
}
54
55
DataMetricPtr
DataMetricRep::getDataMetric
()
56
{
57
return
mMetric
;
58
}
59
60
void
DataMetricRep::setShowLabel
(
bool
on)
61
{
62
mShowLabel
= on;
63
this->
setModified
();
64
}
65
66
void
DataMetricRep::setGraphicsSize
(
double
size)
67
{
68
mGraphicsSize
= size;
69
this->
setModified
();
70
}
71
72
void
DataMetricRep::setLabelSize
(
double
size)
73
{
74
mLabelSize
= size;
75
this->
setModified
();
76
}
77
78
void
DataMetricRep::setShowAnnotation
(
bool
on)
79
{
80
mShowAnnotation
= on;
81
this->
setModified
();
82
}
83
84
void
DataMetricRep::clear
()
85
{
86
mText.reset();
87
}
88
89
void
DataMetricRep::addRepActorsToViewRenderer
(
ViewPtr
view)
90
{
91
// mView = view;
92
93
// vtkRendererPtr renderer = mView->getRenderer();
94
// renderer->AddObserver(vtkCommand::StartEvent, this->mCallbackCommand, 1.0);
95
96
this->
clear
();
97
this->
setModified
();
98
}
99
100
void
DataMetricRep::removeRepActorsFromViewRenderer
(
ViewPtr
view)
101
{
102
// vtkRendererPtr renderer = mView->getRenderer();
103
// renderer->RemoveObserver(this->mCallbackCommand);
104
105
// mView = NULL;
106
this->
clear
();
107
}
108
109
void
DataMetricRep::drawText
()
110
{
111
if
(!this->
getView
())
112
return
;
113
114
QString text = this->
getText
();
115
116
if
(text.isEmpty())
117
{
118
mText.reset();
119
return
;
120
}
121
122
if
(!mText)
123
{
124
mText.reset(
new
CaptionText3D
(this->
getRenderer
()));
125
}
126
mText->setColor(
mMetric
->getColor());
127
mText->setText(text);
128
mText->setPosition(
mMetric
->getRefCoord());
129
mText->setSize(
mLabelSize
/ 100);
130
}
131
132
QString
DataMetricRep::getText
()
133
{
134
if
(!
mShowAnnotation
)
135
return
""
;
136
QStringList text;
137
if
(
mShowLabel
)
138
text <<
mMetric
->getName();
139
if
(
mMetric
->showValueInGraphics())
140
text <<
mMetric
->getValueAsString();
141
return
text.join(
" = "
);
142
}
143
144
Vector3D
DataMetricRep::getColorAsVector3D
()
const
145
{
146
if
(!
mMetric
)
147
return
Vector3D
(1,1,1);
148
// QColor color = mMetric->getColor();
149
// Vector3D retval(color.redF(), color.greenF(), color.blueF());
150
// return retval;
151
return
cx::getColorAsVector3D
(
mMetric
->getColor());
152
}
153
154
}
cx::RepImpl::getView
ViewPtr getView() const
Definition:
cxRepImpl.cpp:83
cx::RepImpl::getRenderer
vtkRendererPtr getRenderer()
Definition:
cxRepImpl.cpp:88
cx::DataMetricRep::setDataMetric
void setDataMetric(DataMetricPtr value)
Definition:
cxDataMetricRep.cpp:35
cx::DataMetricRep::mGraphicsSize
double mGraphicsSize
Definition:
cxDataMetricRep.h:62
cx::getColorAsVector3D
Vector3D getColorAsVector3D(QColor color)
Definition:
cxVtkHelperClasses.cpp:40
cx::DataMetricRep::DataMetricRep
DataMetricRep()
Definition:
cxDataMetricRep.cpp:25
cx::DataMetricPtr
boost::shared_ptr< DataMetric > DataMetricPtr
Definition:
cxDataMetric.h:73
cx::DataMetricRep::clear
virtual void clear()
Definition:
cxDataMetricRep.cpp:84
cxDataMetricRep.h
cx::ViewPtr
boost::shared_ptr< class View > ViewPtr
Definition:
cxForwardDeclarations.h:110
cx::DataMetricRep::getDataMetric
DataMetricPtr getDataMetric()
Definition:
cxDataMetricRep.cpp:55
cxDataMetric.h
cx::DataMetricRep::drawText
void drawText()
Definition:
cxDataMetricRep.cpp:109
cx::DataMetricRep::addRepActorsToViewRenderer
void addRepActorsToViewRenderer(ViewPtr view)
Definition:
cxDataMetricRep.cpp:89
cxGraphicalPrimitives.h
cx::DataMetricRep::setShowLabel
void setShowLabel(bool on)
Definition:
cxDataMetricRep.cpp:60
cx::RepImpl
Default implementation of Rep.
Definition:
cxRepImpl.h:42
cx::CaptionText3D
Helper for rendering 3D text that faces the camera and has a constant viewed size, always on top.
Definition:
cxGraphicalPrimitives.h:258
cx::DataMetricRep::setShowAnnotation
void setShowAnnotation(bool on)
Definition:
cxDataMetricRep.cpp:78
cx::DataMetricRep::mShowLabel
bool mShowLabel
Definition:
cxDataMetricRep.h:63
cx::DataMetricRep::mLabelSize
double mLabelSize
Definition:
cxDataMetricRep.h:64
cx::Vector3D
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition:
cxVector3D.h:42
cxVtkHelperClasses.h
cx::DataMetricRep::removeRepActorsFromViewRenderer
void removeRepActorsFromViewRenderer(ViewPtr view)
Definition:
cxDataMetricRep.cpp:100
cx::DataMetricRep::getText
virtual QString getText()
Definition:
cxDataMetricRep.cpp:132
cx::DataMetricRep::setLabelSize
void setLabelSize(double size)
Definition:
cxDataMetricRep.cpp:72
cx::DataMetricRep::mShowAnnotation
bool mShowAnnotation
Definition:
cxDataMetricRep.h:65
cxView.h
cx::DataMetricRep::mMetric
DataMetricPtr mMetric
Definition:
cxDataMetricRep.h:68
cx::DataMetricRep::getColorAsVector3D
Vector3D getColorAsVector3D() const
Definition:
cxDataMetricRep.cpp:144
cx::RepImpl::setModified
void setModified()
Definition:
cxRepImpl.cpp:112
cx::DataMetricRep::setGraphicsSize
void setGraphicsSize(double size)
Definition:
cxDataMetricRep.cpp:66
cx
Namespace for all CustusX production code.
Definition:
cx_dev_group_definitions.h:13
CX
source
resource
view
Rep
cxDataMetricRep.cpp
Generated on Thu Jan 5 2023 00:50:43 for CustusX by
1.8.11