INET Framework for OMNeT++/OMNEST
inet::LabeledPolylineFigure Class Reference

#include <LabeledPolylineFigure.h>

Inheritance diagram for inet::LabeledPolylineFigure:

Public Member Functions

 LabeledPolylineFigure (const char *name=nullptr)
 
cPolylineFigure * getPolylineFigure () const
 
cTextFigure * getLabelFigure () const
 
void setPoints (const std::vector< cFigure::Point > &points)
 

Protected Member Functions

void updateLabelPosition ()
 

Protected Attributes

cPolylineFigure * polylineFigure
 
cPanelFigurepanelFigure
 
cTextFigure * labelFigure
 

Constructor & Destructor Documentation

inet::LabeledPolylineFigure::LabeledPolylineFigure ( const char *  name = nullptr)
22  :
23  cGroupFigure(name)
24 {
25  polylineFigure = new cPolylineFigure("line");
26  panelFigure = new cPanelFigure("panel");
27  addFigure(polylineFigure);
28  addFigure(panelFigure);
29  labelFigure = new cTextFigure("label");
30  labelFigure->setAnchor(cFigure::ANCHOR_S);
31  labelFigure->setTags("label");
32  labelFigure->setHalo(true);
33  panelFigure->addFigure(labelFigure);
34 }
cTextFigure * labelFigure
Definition: LabeledPolylineFigure.h:30
cPolylineFigure * polylineFigure
Definition: LabeledPolylineFigure.h:28
cPanelFigure * panelFigure
Definition: LabeledPolylineFigure.h:29

Member Function Documentation

cTextFigure* inet::LabeledPolylineFigure::getLabelFigure ( ) const
inline

Referenced by inet::visualizer::PathCanvasVisualizerBase::createPathVisualization().

39 { return labelFigure; }
cTextFigure * labelFigure
Definition: LabeledPolylineFigure.h:30
cPolylineFigure* inet::LabeledPolylineFigure::getPolylineFigure ( ) const
inline
void inet::LabeledPolylineFigure::setPoints ( const std::vector< cFigure::Point > &  points)
37 {
38  polylineFigure->setPoints(points);
40 }
cPolylineFigure * polylineFigure
Definition: LabeledPolylineFigure.h:28
void updateLabelPosition()
Definition: LabeledPolylineFigure.cc:42
void inet::LabeledPolylineFigure::updateLabelPosition ( )
protected

Referenced by setPoints().

43 {
44  auto points = polylineFigure->getPoints();
45  int index = (points.size() - 1) / 2;
46  auto position = (points[index] + points[index + 1]) / 2;
47  auto direction = points[index + 1] - points[index];
48  double alpha = atan2(-direction.y, direction.x);
49  if (alpha > M_PI / 2 || alpha < -M_PI / 2)
50  alpha += M_PI;
51  panelFigure->setTransform(cFigure::Transform().rotate(-alpha));
52  panelFigure->setPosition(position);
53  labelFigure->setPosition(cFigure::Point(0, -polylineFigure->getLineWidth() / 2));
54 }
cTextFigure * labelFigure
Definition: LabeledPolylineFigure.h:30
virtual void setPosition(const Point &position)
Definition: cPanelFigure.h:72
cPolylineFigure * polylineFigure
Definition: LabeledPolylineFigure.h:28
#define M_PI
Definition: PlotFigure.cc:27
cPanelFigure * panelFigure
Definition: LabeledPolylineFigure.h:29
const value< double, units::unit > alpha(7.2973525376e-3)

Member Data Documentation

cTextFigure* inet::LabeledPolylineFigure::labelFigure
protected
cPanelFigure* inet::LabeledPolylineFigure::panelFigure
protected
cPolylineFigure* inet::LabeledPolylineFigure::polylineFigure
protected

The documentation for this class was generated from the following files: