Fraxinus
16.5.0-fx-rc9
An IGT application
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
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) 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
34
35
#include "
cxDataMetricRep.h
"
36
37
#include "
cxGraphicalPrimitives.h
"
38
#include "
cxView.h
"
39
#include "
cxDataMetric.h
"
40
41
#include "
cxVtkHelperClasses.h
"
42
43
namespace
cx
44
{
45
46
DataMetricRep::DataMetricRep
() :
47
RepImpl
(),
48
mGraphicsSize(1),
49
mShowLabel(false),
50
mLabelSize(2.5),
51
mShowAnnotation(true)
52
// mView(NULL)
53
{
54
}
55
56
void
DataMetricRep::setDataMetric
(
DataMetricPtr
value)
57
{
58
if
(
mMetric
)
59
{
60
disconnect(
mMetric
.get(), SIGNAL(transformChanged()),
this
, SLOT(
setModified
()));
61
disconnect(
mMetric
.get(), SIGNAL(propertiesChanged()),
this
, SLOT(
setModified
()));
62
}
63
64
mMetric
= value;
65
66
if
(
mMetric
)
67
{
68
connect(
mMetric
.get(), SIGNAL(propertiesChanged()),
this
, SLOT(
setModified
()));
69
connect(
mMetric
.get(), SIGNAL(transformChanged()),
this
, SLOT(
setModified
()));
70
}
71
72
this->
clear
();
73
this->
setModified
();
74
}
75
76
DataMetricPtr
DataMetricRep::getDataMetric
()
77
{
78
return
mMetric
;
79
}
80
81
void
DataMetricRep::setShowLabel
(
bool
on)
82
{
83
mShowLabel
= on;
84
this->
setModified
();
85
}
86
87
void
DataMetricRep::setGraphicsSize
(
double
size)
88
{
89
mGraphicsSize
= size;
90
this->
setModified
();
91
}
92
93
void
DataMetricRep::setLabelSize
(
double
size)
94
{
95
mLabelSize
= size;
96
this->
setModified
();
97
}
98
99
void
DataMetricRep::setShowAnnotation
(
bool
on)
100
{
101
mShowAnnotation
= on;
102
this->
setModified
();
103
}
104
105
void
DataMetricRep::clear
()
106
{
107
mText.reset();
108
}
109
110
void
DataMetricRep::addRepActorsToViewRenderer
(
ViewPtr
view)
111
{
112
// mView = view;
113
114
// vtkRendererPtr renderer = mView->getRenderer();
115
// renderer->AddObserver(vtkCommand::StartEvent, this->mCallbackCommand, 1.0);
116
117
this->
clear
();
118
this->
setModified
();
119
}
120
121
void
DataMetricRep::removeRepActorsFromViewRenderer
(
ViewPtr
view)
122
{
123
// vtkRendererPtr renderer = mView->getRenderer();
124
// renderer->RemoveObserver(this->mCallbackCommand);
125
126
// mView = NULL;
127
this->
clear
();
128
}
129
130
void
DataMetricRep::drawText
()
131
{
132
if
(!this->
getView
())
133
return
;
134
135
QString text = this->
getText
();
136
137
if
(text.isEmpty())
138
{
139
mText.reset();
140
return
;
141
}
142
143
if
(!mText)
144
{
145
mText.reset(
new
CaptionText3D
(this->
getRenderer
()));
146
}
147
mText->setColor(
mMetric
->getColor());
148
mText->setText(text);
149
mText->setPosition(
mMetric
->getRefCoord());
150
mText->setSize(
mLabelSize
/ 100);
151
}
152
153
QString
DataMetricRep::getText
()
154
{
155
if
(!
mShowAnnotation
)
156
return
""
;
157
QStringList text;
158
if
(
mShowLabel
)
159
text <<
mMetric
->getName();
160
if
(
mMetric
->showValueInGraphics())
161
text <<
mMetric
->getValueAsString();
162
return
text.join(
" = "
);
163
}
164
165
Vector3D
DataMetricRep::getColorAsVector3D
()
const
166
{
167
if
(!
mMetric
)
168
return
Vector3D
(1,1,1);
169
// QColor color = mMetric->getColor();
170
// Vector3D retval(color.redF(), color.greenF(), color.blueF());
171
// return retval;
172
return
cx::getColorAsVector3D
(
mMetric
->getColor());
173
}
174
175
}
cx::RepImpl::getView
ViewPtr getView() const
Definition:
cxRepImpl.cpp:104
cx::RepImpl::getRenderer
vtkRendererPtr getRenderer()
Definition:
cxRepImpl.cpp:109
cx::DataMetricRep::setDataMetric
void setDataMetric(DataMetricPtr value)
Definition:
cxDataMetricRep.cpp:56
cx::DataMetricRep::mGraphicsSize
double mGraphicsSize
Definition:
cxDataMetricRep.h:83
cx::getColorAsVector3D
Vector3D getColorAsVector3D(QColor color)
Definition:
cxVtkHelperClasses.cpp:67
cx::DataMetricRep::DataMetricRep
DataMetricRep()
Definition:
cxDataMetricRep.cpp:46
cx::DataMetricPtr
boost::shared_ptr< DataMetric > DataMetricPtr
Definition:
cxDataMetric.h:95
cx::DataMetricRep::clear
virtual void clear()
Definition:
cxDataMetricRep.cpp:105
cxDataMetricRep.h
cx::ViewPtr
boost::shared_ptr< class View > ViewPtr
Definition:
cxForwardDeclarations.h:129
cx::DataMetricRep::getDataMetric
DataMetricPtr getDataMetric()
Definition:
cxDataMetricRep.cpp:76
cxDataMetric.h
cx::DataMetricRep::drawText
void drawText()
Definition:
cxDataMetricRep.cpp:130
cx::DataMetricRep::addRepActorsToViewRenderer
void addRepActorsToViewRenderer(ViewPtr view)
Definition:
cxDataMetricRep.cpp:110
cxGraphicalPrimitives.h
cx::DataMetricRep::setShowLabel
void setShowLabel(bool on)
Definition:
cxDataMetricRep.cpp:81
cx::RepImpl
Default implementation of Rep.
Definition:
cxRepImpl.h:63
cx::CaptionText3D
Helper for rendering 3D text that faces the camera and has a constant viewed size, always on top.
Definition:
cxGraphicalPrimitives.h:286
cx::DataMetricRep::setShowAnnotation
void setShowAnnotation(bool on)
Definition:
cxDataMetricRep.cpp:99
cx::DataMetricRep::mShowLabel
bool mShowLabel
Definition:
cxDataMetricRep.h:84
cx::DataMetricRep::mLabelSize
double mLabelSize
Definition:
cxDataMetricRep.h:85
cx::Vector3D
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition:
cxVector3D.h:63
cxVtkHelperClasses.h
cx::DataMetricRep::removeRepActorsFromViewRenderer
void removeRepActorsFromViewRenderer(ViewPtr view)
Definition:
cxDataMetricRep.cpp:121
cx::DataMetricRep::getText
virtual QString getText()
Definition:
cxDataMetricRep.cpp:153
cx::DataMetricRep::setLabelSize
void setLabelSize(double size)
Definition:
cxDataMetricRep.cpp:93
cx::DataMetricRep::mShowAnnotation
bool mShowAnnotation
Definition:
cxDataMetricRep.h:86
cxView.h
cx::DataMetricRep::mMetric
DataMetricPtr mMetric
Definition:
cxDataMetricRep.h:89
cx::DataMetricRep::getColorAsVector3D
Vector3D getColorAsVector3D() const
Definition:
cxDataMetricRep.cpp:165
cx::RepImpl::setModified
void setModified()
Definition:
cxRepImpl.cpp:132
cx::DataMetricRep::setGraphicsSize
void setGraphicsSize(double size)
Definition:
cxDataMetricRep.cpp:87
CX
source
resource
view
Rep
cxDataMetricRep.cpp
Generated on Thu May 19 2016 11:15:34 for Fraxinus by
1.8.6