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

#include <QueueFigure.h>

Inheritance diagram for inet::QueueFigure:

Public Member Functions

 QueueFigure (const char *name=nullptr)
 
cFigure::Color getColor () const
 
void setColor (cFigure::Color color)
 
double getSpacing () const
 
void setSpacing (double spacing)
 
void setElementCount (int elementCount)
 
void setMaxElementCount (int maxElementCount)
 

Protected Attributes

cFigure::Color color
 
bool continuous = false
 
double spacing = 2
 
double elementWidth = 16
 
double elementHeight = 4
 
int elementCount = -1
 
int maxElementCount = -1
 
std::vector< cRectangleFigure * > boxes
 

Constructor & Destructor Documentation

inet::QueueFigure::QueueFigure ( const char *  name = nullptr)
22  :
23  cRectangleFigure(name)
24 {
25 }

Member Function Documentation

cFigure::Color inet::QueueFigure::getColor ( ) const
inline
40 { return color; }
cFigure::Color color
Definition: QueueFigure.h:28
double inet::QueueFigure::getSpacing ( ) const
inline
43 { return spacing; }
double spacing
Definition: QueueFigure.h:30
void inet::QueueFigure::setColor ( cFigure::Color  color)
inline
41 { this->color = color; }
cFigure::Color color
Definition: QueueFigure.h:28
void inet::QueueFigure::setElementCount ( int  elementCount)

Referenced by inet::visualizer::QueueCanvasVisualizer::refreshQueueVisualization().

63 {
64  if (this->elementCount != elementCount) {
65  this->elementCount = elementCount;
66  if (continuous) {
67  const auto& bounds = getBounds();
68  double width = bounds.width - 2 * spacing;
69  double height = (bounds.height - 2 * spacing) * elementCount / maxElementCount;
70  boxes[0]->setBounds(cFigure::Rectangle(spacing, bounds.height - spacing - height, width, height));
71  }
72  else
73  for (int i = 0; i < boxes.size(); i++)
74  boxes[i]->setVisible((boxes.size() - i) <= elementCount);
75  }
76 }
double spacing
Definition: QueueFigure.h:30
std::vector< cRectangleFigure * > boxes
Definition: QueueFigure.h:35
int elementCount
Definition: QueueFigure.h:33
int maxElementCount
Definition: QueueFigure.h:34
bool continuous
Definition: QueueFigure.h:29
void inet::QueueFigure::setMaxElementCount ( int  maxElementCount)
28 {
29  if (this->maxElementCount != maxElementCount) {
31  for (auto box : boxes) {
32  removeFigure(box);
33  delete box;
34  }
35  boxes.clear();
36  const auto& bounds = getBounds();
37  elementWidth = bounds.width - 2 * spacing;
38  elementHeight = (bounds.height - (maxElementCount + 1) * spacing) / maxElementCount;
40  if (continuous) {
41  auto box = new cRectangleFigure("box");
42  box->setOutlined(false);
43  box->setFilled(true);
44  box->setFillColor(color);
45  boxes.push_back(box);
46  addFigure(box);
47  }
48  else {
49  for (int i = 0; i < maxElementCount; i++) {
50  auto box = new cRectangleFigure("box");
51  box->setOutlined(false);
52  box->setFilled(true);
53  box->setFillColor(color);
54  box->setBounds(cFigure::Rectangle(spacing, spacing + i * (elementHeight + spacing), elementWidth, elementHeight));
55  boxes.push_back(box);
56  addFigure(box);
57  }
58  }
59  }
60 }
double spacing
Definition: QueueFigure.h:30
cFigure::Color color
Definition: QueueFigure.h:28
std::vector< cRectangleFigure * > boxes
Definition: QueueFigure.h:35
double elementWidth
Definition: QueueFigure.h:31
int maxElementCount
Definition: QueueFigure.h:34
double elementHeight
Definition: QueueFigure.h:32
bool continuous
Definition: QueueFigure.h:29
void inet::QueueFigure::setSpacing ( double  spacing)
inline
44 { this->spacing = spacing; }
double spacing
Definition: QueueFigure.h:30

Member Data Documentation

std::vector<cRectangleFigure *> inet::QueueFigure::boxes
protected
cFigure::Color inet::QueueFigure::color
protected

Referenced by setMaxElementCount().

bool inet::QueueFigure::continuous = false
protected
int inet::QueueFigure::elementCount = -1
protected

Referenced by setElementCount().

double inet::QueueFigure::elementHeight = 4
protected

Referenced by setMaxElementCount().

double inet::QueueFigure::elementWidth = 16
protected

Referenced by setMaxElementCount().

int inet::QueueFigure::maxElementCount = -1
protected
double inet::QueueFigure::spacing = 2
protected

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