34 #include <vtkRenderer.h> 35 #include <vtkActor2D.h> 36 #include <vtkTextProperty.h> 37 #include <vtkTextMapper.h> 88 for (
unsigned i=0; i<
mMetrics.size(); ++i)
96 for (
unsigned i=0; i<
mMetrics.size(); ++i)
102 this->callSetColoredTextListSlot();
105 QTimer::singleShot(500,
this, &MetricNamesRep::callSetColoredTextListSlot);
108 void MetricNamesRep::callSetColoredTextListSlot()
115 std::vector<DataMetricPtr> metrics;
116 for (
unsigned i=0; i<data.size(); ++i)
120 metrics.push_back(metric);
127 if (a.size()!=b.size())
129 for (
unsigned i=0; i<a.size(); ++i)
137 std::vector<std::pair<QColor, QString> > text;
164 double meanHeight = bb.
range()[1]/text.size();
166 for (
unsigned i=0; i<text.size(); ++i)
170 rep->textProperty()->SetJustificationToLeft();
171 rep->getActor()->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
174 rep->setPosition(currentPos);
183 QStringList fullText;
184 for (
unsigned i=0; i<text.size(); ++i)
185 fullText << text[i].second;
188 double width_p = test.getMapper()->GetWidth(vp);
189 double height_p = test.getMapper()->GetHeight(vp);
192 Eigen::Array2i size_vp(vp->GetSize());
193 Eigen::Array2d normsize_box(width_p/size_vp[0], height_p/size_vp[1]);
196 double border = 0.02;
198 DoubleBoundingBox3D bb_box(pos[0], pos[0]+normsize_box[0], pos[1], pos[1]+normsize_box[1], 0, 0);
207 for (
unsigned i=0; i<2; ++i)
209 double shift = another[2*i+1] - box[2*i+1];
218 for (
unsigned i=0; i<3; ++i)
220 double shift = another[2*i] - box[2*i];
240 text << metric->getName();
241 if (metric->showValueInGraphics())
242 text << metric->getValueAsString();
243 return text.join(
" = ");
248 std::vector<std::pair<QColor, QString> > retval;
250 for (
unsigned i = 0; i <
mMetrics.size(); ++i)
253 QString line = metric->getName();
255 if (!metric->showValueInGraphics())
258 QString text = this->
getText(metric,
true);
259 retval.push_back(std::make_pair(metric->getColor(), text));
261 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.