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

#include <GateFigure.h>

Inheritance diagram for inet::GateFigure:

Public Member Functions

 GateFigure (const char *name=nullptr)
 
virtual void setBounds (const Rectangle &bounds) override
 
const char * getLabel () const
 
void setLabel (const char *text)
 
double getSpacing () const
 
void setSpacing (double spacing)
 
double getPosition () const
 
void setPosition (double position)
 
void addSchedule (double start, double end, bool open)
 
void clearSchedule ()
 

Protected Attributes

double spacing = 2
 
double position = 0
 
cLabelFigure * labelFigure = nullptr
 
cLineFigure * positionFigure = nullptr
 
std::vector< cRectangleFigure * > scheduleFigures
 

Constructor & Destructor Documentation

◆ GateFigure()

inet::GateFigure::GateFigure ( const char *  name = nullptr)
12  :
13  cRectangleFigure(name)
14 {
15  labelFigure = new cLabelFigure();
16  labelFigure->setAnchor(cFigure::ANCHOR_W);
17  addFigure(labelFigure);
18  positionFigure = new cLineFigure();
19  positionFigure->setLineColor(cFigure::BLACK);
20  positionFigure->setLineStyle(cFigure::LINE_DOTTED);
21  addFigure(positionFigure);
22 }

Member Function Documentation

◆ addSchedule()

void inet::GateFigure::addSchedule ( double  start,
double  end,
bool  open 
)
53 {
54  auto size = getBounds().getSize();
55  auto scheduleFigure = new cRectangleFigure();
56  scheduleFigure->setOutlined(false);
57  scheduleFigure->setFilled(true);
58  scheduleFigure->setFillColor(open ? cFigure::GREEN : cFigure::RED);
59  scheduleFigure->setBounds(cFigure::Rectangle(start, 0, end - start, size.y));
60  scheduleFigures.push_back(scheduleFigure);
61  addFigure(scheduleFigure, 0);
62 }

◆ clearSchedule()

void inet::GateFigure::clearSchedule ( )
65 {
66  for (auto scheduleFigure : scheduleFigures)
67  delete removeFigure(scheduleFigure);
68  scheduleFigures.clear();
69 }

◆ getLabel()

const char* inet::GateFigure::getLabel ( ) const
inline
29 { return labelFigure->getText(); }

◆ getPosition()

double inet::GateFigure::getPosition ( ) const
inline
35 { return position; }

◆ getSpacing()

double inet::GateFigure::getSpacing ( ) const
inline
32 { return spacing; }

◆ setBounds()

void inet::GateFigure::setBounds ( const Rectangle &  bounds)
overridevirtual
25 {
26  cRectangleFigure::setBounds(bounds);
27  labelFigure->setPosition(cFigure::Point(0, bounds.height / 2));
28 }

◆ setLabel()

void inet::GateFigure::setLabel ( const char *  text)
31 {
32  auto size = getBounds().getSize();
33  labelFigure->setText(text);
34  auto font = labelFigure->getFont();
35  font.pointSize = size.y;
36  double outWidth;
37  double outHeight;
38  double outAscent;
39  getEnvir()->getTextExtent(font, text, outWidth, outHeight, outAscent);
40  font.pointSize *= size.y / outHeight;
41  labelFigure->setFont(font);
42 }

◆ setPosition()

void inet::GateFigure::setPosition ( double  position)
45 {
46  auto size = getBounds().getSize();
47  this->position = position;
48  positionFigure->setStart(cFigure::Point(position, 0));
49  positionFigure->setEnd(cFigure::Point(position, size.y));
50 }

◆ setSpacing()

void inet::GateFigure::setSpacing ( double  spacing)
inline
33 { this->spacing = spacing; }

Member Data Documentation

◆ labelFigure

cLabelFigure* inet::GateFigure::labelFigure = nullptr
protected

Referenced by GateFigure(), setBounds(), and setLabel().

◆ position

double inet::GateFigure::position = 0
protected

Referenced by setPosition().

◆ positionFigure

cLineFigure* inet::GateFigure::positionFigure = nullptr
protected

Referenced by GateFigure(), and setPosition().

◆ scheduleFigures

std::vector<cRectangleFigure *> inet::GateFigure::scheduleFigures
protected

Referenced by addSchedule(), and clearSchedule().

◆ spacing

double inet::GateFigure::spacing = 2
protected

The documentation for this class was generated from the following files:
inet::DiffservUtil::RED
@ RED
Definition: DiffservUtil.h:17
inet::GateFigure::position
double position
Definition: GateFigure.h:19
inet::GateFigure::spacing
double spacing
Definition: GateFigure.h:18
inet::DiffservUtil::GREEN
@ GREEN
Definition: DiffservUtil.h:17
inet::GateFigure::positionFigure
cLineFigure * positionFigure
Definition: GateFigure.h:21
inet::GateFigure::scheduleFigures
std::vector< cRectangleFigure * > scheduleFigures
Definition: GateFigure.h:22
inet::GateFigure::labelFigure
cLabelFigure * labelFigure
Definition: GateFigure.h:20