13 #include <vtkRenderer.h> 14 #include <vtkActor2D.h> 15 #include <vtkTextProperty.h> 16 #include <vtkTextMapper.h> 67 for (
unsigned i=0; i<
mMetrics.size(); ++i)
75 for (
unsigned i=0; i<
mMetrics.size(); ++i)
81 this->callSetColoredTextListSlot();
84 QTimer::singleShot(500,
this, &MetricNamesRep::callSetColoredTextListSlot);
87 void MetricNamesRep::callSetColoredTextListSlot()
94 std::vector<DataMetricPtr> metrics;
95 for (
unsigned i=0; i<data.size(); ++i)
99 metrics.push_back(metric);
106 if (a.size()!=b.size())
108 for (
unsigned i=0; i<a.size(); ++i)
116 std::vector<std::pair<QColor, QString> > text;
143 double meanHeight = bb.
range()[1]/text.size();
145 for (
unsigned i=0; i<text.size(); ++i)
149 rep->textProperty()->SetJustificationToLeft();
150 rep->getActor()->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
153 rep->setPosition(currentPos);
162 QStringList fullText;
163 for (
unsigned i=0; i<text.size(); ++i)
164 fullText << text[i].second;
167 double width_p = test.getMapper()->GetWidth(vp);
168 double height_p = test.getMapper()->GetHeight(vp);
171 Eigen::Array2i size_vp(vp->GetSize());
172 Eigen::Array2d normsize_box(width_p/size_vp[0], height_p/size_vp[1]);
175 double border = 0.02;
177 DoubleBoundingBox3D bb_box(pos[0], pos[0]+normsize_box[0], pos[1], pos[1]+normsize_box[1], 0, 0);
186 for (
unsigned i=0; i<2; ++i)
188 double shift = another[2*i+1] - box[2*i+1];
197 for (
unsigned i=0; i<3; ++i)
199 double shift = another[2*i] - box[2*i];
219 text << metric->getName();
220 if (metric->showValueInGraphics())
221 text << metric->getValueAsString();
222 return text.join(
" = ");
227 std::vector<std::pair<QColor, QString> > retval;
229 for (
unsigned i = 0; i <
mMetrics.size(); ++i)
232 QString line = metric->getName();
234 if (!metric->showValueInGraphics())
237 QString text = this->
getText(metric,
true);
238 retval.push_back(std::make_pair(metric->getColor(), text));
240 std::reverse(retval.begin(), retval.end());
vtkTextProperty * textProperty()
vtkRendererPtr getRenderer()
virtual ~MetricNamesRep()
#define CX_ASSERT(statement)
boost::shared_ptr< DataMetric > DataMetricPtr
std::vector< DataMetricPtr > convertToMetrics(std::vector< DataPtr > data)
void setFontSize(int size)
must be set before setting data
Vector3D bottomLeft() const
static boost::shared_ptr< REP > wrap_new(REP *object, QString uid)
boost::shared_ptr< class View > ViewPtr
void setColoredTextList(std::vector< std::pair< QColor, QString > > text, Eigen::Array2d pos, vtkViewport *vp=0)
boost::shared_ptr< class MetricNamesRep > MetricNamesRepPtr
static MetricNamesRepPtr New(const QString &uid="")
void setData(std::vector< DataPtr > data)
virtual void addRepActorsToViewRenderer(ViewPtr view)
Helper for drawing text in 2D.
boost::shared_ptr< class TextDisplay > TextDisplayPtr
Default implementation of Rep.
Representation of a floating-point bounding box in 3D. The data are stored as {xmin,xmax,ymin,ymax,zmin,zmax}, in order to simplify communication with vtk.
virtual void onModifiedStartRender()
DoubleBoundingBox3D moveBoxIntoAnother(DoubleBoundingBox3D box, DoubleBoundingBox3D another)
std::vector< std::pair< QColor, QString > > getAllMetricTexts() const
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
std::vector< TextDisplayPtr > mDisplayText
QString getText(DataMetricPtr metric, bool showLabel) const
virtual void removeRepActorsFromViewRenderer(ViewPtr view)
Base class for all Data Metrics.
bool equal(std::vector< DataMetricPtr > a, std::vector< DataMetricPtr > b) const
DoubleBoundingBox3D findNormalizedBoundingBoxAroundText(std::vector< std::pair< QColor, QString > > text, Eigen::Array2d pos, vtkViewport *vp)
std::vector< DataMetricPtr > mMetrics
Namespace for all CustusX production code.