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

#include <LabeledLineFigure.h>

Inheritance diagram for inet::LabeledLineFigure:

Public Member Functions

 LabeledLineFigure (const char *name=nullptr)
 
cLineFigure * getLineFigure () const
 
cTextFigure * getLabelFigure () const
 
void setStart (cFigure::Point point)
 
void setEnd (cFigure::Point point)
 

Protected Member Functions

void updateLabelPosition ()
 

Protected Attributes

cLineFigure * lineFigure
 
cPanelFigurepanelFigure
 
cTextFigure * labelFigure
 

Constructor & Destructor Documentation

inet::LabeledLineFigure::LabeledLineFigure ( const char *  name = nullptr)
22  :
23  cGroupFigure(name)
24 {
25  lineFigure = new cLineFigure("line");
26  panelFigure = new cPanelFigure("panel");
27  addFigure(lineFigure);
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: LabeledLineFigure.h:30
cLineFigure * lineFigure
Definition: LabeledLineFigure.h:28
cPanelFigure * panelFigure
Definition: LabeledLineFigure.h:29

Member Function Documentation

void inet::LabeledLineFigure::setEnd ( cFigure::Point  point)
void inet::LabeledLineFigure::setStart ( cFigure::Point  point)
void inet::LabeledLineFigure::updateLabelPosition ( )
protected

Referenced by setEnd(), and setStart().

49 {
50  auto position = (lineFigure->getStart() + lineFigure->getEnd()) / 2;
51  auto direction = lineFigure->getEnd() - lineFigure->getStart();
52  double alpha = atan2(-direction.y, direction.x);
53  if (alpha > M_PI / 2 || alpha < -M_PI / 2)
54  alpha += M_PI;
55  panelFigure->setTransform(cFigure::Transform().rotate(-alpha));
56  panelFigure->setPosition(position);
57  labelFigure->setPosition(cFigure::Point(0, -lineFigure->getLineWidth() / 2));
58 }
virtual void setPosition(const Point &position)
Definition: cPanelFigure.h:72
cTextFigure * labelFigure
Definition: LabeledLineFigure.h:30
cLineFigure * lineFigure
Definition: LabeledLineFigure.h:28
#define M_PI
Definition: PlotFigure.cc:27
cPanelFigure * panelFigure
Definition: LabeledLineFigure.h:29
const value< double, units::unit > alpha(7.2973525376e-3)

Member Data Documentation

cTextFigure* inet::LabeledLineFigure::labelFigure
protected
cLineFigure* inet::LabeledLineFigure::lineFigure
protected
cPanelFigure* inet::LabeledLineFigure::panelFigure
protected

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