34 #include <vtkRenderer.h>
35 #include <vtkActor2D.h>
36 #include <vtkTextProperty.h>
37 #include <vtkTextMapper.h>
87 for (
unsigned i=0; i<
mMetrics.size(); ++i)
95 for (
unsigned i=0; i<
mMetrics.size(); ++i)
106 std::vector<DataMetricPtr> metrics;
107 for (
unsigned i=0; i<data.size(); ++i)
111 metrics.push_back(metric);
118 if (a.size()!=b.size())
120 for (
unsigned i=0; i<a.size(); ++i)
128 std::vector<std::pair<QColor, QString> > text;
155 double meanHeight = bb.
range()[1]/text.size();
157 for (
unsigned i=0; i<text.size(); ++i)
161 rep->textProperty()->SetJustificationToLeft();
162 rep->getActor()->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
165 rep->setPosition(currentPos);
174 QStringList fullText;
175 for (
unsigned i=0; i<text.size(); ++i)
176 fullText << text[i].second;
179 double width_p = test.getMapper()->GetWidth(vp);
180 double height_p = test.getMapper()->GetHeight(vp);
183 Eigen::Array2i size_vp(vp->GetSize());
184 Eigen::Array2d normsize_box(width_p/size_vp[0], height_p/size_vp[1]);
187 double border = 0.02;
189 DoubleBoundingBox3D bb_box(pos[0], pos[0]+normsize_box[0], pos[1], pos[1]+normsize_box[1], 0, 0);
198 for (
unsigned i=0; i<2; ++i)
200 double shift = another[2*i+1] - box[2*i+1];
209 for (
unsigned i=0; i<3; ++i)
211 double shift = another[2*i] - box[2*i];
231 text << metric->getName();
232 if (metric->showValueInGraphics())
233 text << metric->getValueAsString();
234 return text.join(
" = ");
239 std::vector<std::pair<QColor, QString> > retval;
241 for (
unsigned i = 0; i <
mMetrics.size(); ++i)
244 QString line = metric->getName();
246 if (!metric->showValueInGraphics())
249 QString text = this->
getText(metric,
true);
250 retval.push_back(std::make_pair(metric->getColor(), text));
252 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