|
INET Framework for OMNeT++/OMNEST
|
#include <CounterFigure.h>
◆ CounterFigure()
| inet::CounterFigure::CounterFigure |
( |
const char * |
name = nullptr | ) |
|
◆ ~CounterFigure()
| virtual inet::CounterFigure::~CounterFigure |
( |
| ) |
|
|
inlinevirtual |
◆ addChildren()
| void inet::CounterFigure::addChildren |
( |
| ) |
|
|
protected |
◆ calculateBounds()
| void inet::CounterFigure::calculateBounds |
( |
| ) |
|
|
protected |
◆ calculateRealPos()
| cFigure::Point inet::CounterFigure::calculateRealPos |
( |
const Point & |
pos | ) |
|
|
protected |
263 Point position = pos;
265 case cFigure::ANCHOR_CENTER:
266 position.x -= bounds.width / 2;
267 position.y -= bounds.height / 2;
270 case cFigure::ANCHOR_N:
271 position.x -= bounds.width / 2;
274 case cFigure::ANCHOR_E:
275 position.x -= bounds.width;
276 position.y -= bounds.height / 2;
279 case cFigure::ANCHOR_S:
280 case cFigure::ANCHOR_BASELINE_MIDDLE:
281 position.x -= bounds.width / 2;
282 position.y -= bounds.height;
285 case cFigure::ANCHOR_W:
286 position.y -= bounds.height / 2;
289 case cFigure::ANCHOR_NW:
292 case cFigure::ANCHOR_NE:
293 position.x -= bounds.width;
296 case cFigure::ANCHOR_SE:
297 case cFigure::ANCHOR_BASELINE_END:
298 position.x -= bounds.width;
299 position.y -= bounds.height;
302 case cFigure::ANCHOR_SW:
303 case cFigure::ANCHOR_BASELINE_START:
304 position.y -= bounds.width;
Referenced by calculateBounds(), and setPos().
◆ getAllowedPropertyKeys()
| const char ** inet::CounterFigure::getAllowedPropertyKeys |
( |
| ) |
const |
|
overrideprotectedvirtual |
364 static const char *
keys[32];
366 const char *localKeys[] = {
367 PKEY_BACKGROUND_COLOR, PKEY_DECIMAL_PLACES, PKEY_DIGIT_BACKGROUND_COLOR,
368 PKEY_DIGIT_BORDER_COLOR, PKEY_DIGIT_FONT, PKEY_DIGIT_COLOR, PKEY_LABEL, PKEY_LABEL_FONT,
369 PKEY_LABEL_COLOR, PKEY_INITIAL_VALUE, PKEY_POS, PKEY_ANCHOR, PKEY_LABEL_OFFSET,
nullptr
371 concatArrays(
keys, cGroupFigure::getAllowedPropertyKeys(), localKeys);
◆ getAnchor()
| cFigure::Anchor inet::CounterFigure::getAnchor |
( |
| ) |
const |
◆ getBackgroundColor()
| const cFigure::Color & inet::CounterFigure::getBackgroundColor |
( |
| ) |
const |
◆ getDecimalPlaces()
| int inet::CounterFigure::getDecimalPlaces |
( |
| ) |
const |
◆ getDigitBackgroundColor()
| cFigure::Color inet::CounterFigure::getDigitBackgroundColor |
( |
| ) |
const |
◆ getDigitBorderColor()
| cFigure::Color inet::CounterFigure::getDigitBorderColor |
( |
| ) |
const |
107 return digits.size() ?
digits[0].bounds->getLineColor() :
Color(INIT_DIGIT_BORDER_COLOR);
◆ getDigitColor()
| cFigure::Color inet::CounterFigure::getDigitColor |
( |
| ) |
const |
132 return digits.size() ?
digits[0].text->getColor() :
Color(INIT_DIGIT_TEXT_COLOR);
◆ getDigitFont()
| cFigure::Font inet::CounterFigure::getDigitFont |
( |
| ) |
const |
◆ getLabel()
| const char * inet::CounterFigure::getLabel |
( |
| ) |
const |
◆ getLabelAnchor()
| Anchor inet::CounterFigure::getLabelAnchor |
( |
| ) |
const |
◆ getLabelColor()
| const cFigure::Color & inet::CounterFigure::getLabelColor |
( |
| ) |
const |
◆ getLabelFont()
| const cFigure::Font & inet::CounterFigure::getLabelFont |
( |
| ) |
const |
◆ getLabelOffset()
| int inet::CounterFigure::getLabelOffset |
( |
| ) |
const |
◆ getLabelPos()
| const Point& inet::CounterFigure::getLabelPos |
( |
| ) |
const |
◆ getPos()
| cFigure::Point inet::CounterFigure::getPos |
( |
| ) |
const |
188 case cFigure::ANCHOR_CENTER:
189 bounds.x += bounds.width / 2;
190 bounds.y += bounds.height / 2;
193 case cFigure::ANCHOR_N:
194 bounds.x += bounds.width / 2;
197 case cFigure::ANCHOR_E:
198 bounds.x += bounds.width;
199 bounds.y += bounds.height / 2;
202 case cFigure::ANCHOR_S:
203 case cFigure::ANCHOR_BASELINE_MIDDLE:
204 bounds.x += bounds.width / 2;
205 bounds.y += bounds.height;
208 case cFigure::ANCHOR_W:
209 bounds.y += bounds.height / 2;
212 case cFigure::ANCHOR_NW:
215 case cFigure::ANCHOR_NE:
216 bounds.x += bounds.width;
219 case cFigure::ANCHOR_SE:
220 case cFigure::ANCHOR_BASELINE_END:
221 bounds.x += bounds.width;
222 bounds.y += bounds.height;
225 case cFigure::ANCHOR_SW:
226 case cFigure::ANCHOR_BASELINE_START:
227 bounds.y += bounds.width;
230 return Point(bounds.x, bounds.y);
◆ getSize()
| virtual const Point inet::CounterFigure::getSize |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ layout()
| void inet::CounterFigure::layout |
( |
| ) |
|
|
protected |
381 bounds.x += PADDING + DIGIT_PADDING / 2;
383 for (uint32_t i = 0; i <
digits.size(); ++i) {
384 double rectWidth =
getDigitFont().pointSize * DIGIT_WIDTH_PERCENT;
385 double rectHeight =
getDigitFont().pointSize * DIGIT_HEIGHT_PERCENT;
386 double x = bounds.x + (rectWidth + DIGIT_PADDING) * i;
387 double y = bounds.y + PADDING;
389 digits[i].bounds->setBounds(Rectangle(x, y, rectWidth, rectHeight));
390 digits[i].text->setPosition(
digits[i].bounds->getBounds().getCenter());
Referenced by setAnchor(), setDecimalPlaces(), setDigitFont(), and setPos().
◆ parse()
| void inet::CounterFigure::parse |
( |
cProperty * |
property | ) |
|
|
overrideprotectedvirtual |
326 cGroupFigure::parse(property);
330 setPos(parsePoint(property, PKEY_POS, 0));
332 if ((
s = property->getValue(PKEY_BACKGROUND_COLOR)) !=
nullptr)
334 if ((
s = property->getValue(PKEY_ANCHOR)) !=
nullptr)
336 if ((
s = property->getValue(PKEY_DECIMAL_PLACES)) !=
nullptr)
340 if ((
s = property->getValue(PKEY_DIGIT_FONT)) !=
nullptr)
342 if ((
s = property->getValue(PKEY_DIGIT_BACKGROUND_COLOR)) !=
nullptr)
344 if ((
s = property->getValue(PKEY_DIGIT_BORDER_COLOR)) !=
nullptr)
346 if ((
s = property->getValue(PKEY_DIGIT_COLOR)) !=
nullptr)
348 if ((
s = property->getValue(PKEY_LABEL)) !=
nullptr)
350 if ((
s = property->getValue(PKEY_LABEL_OFFSET)) !=
nullptr)
352 if ((
s = property->getValue(PKEY_LABEL_FONT)) !=
nullptr)
354 if ((
s = property->getValue(PKEY_LABEL_COLOR)) !=
nullptr)
356 if ((
s = property->getValue(PKEY_INITIAL_VALUE)) !=
nullptr)
◆ refresh()
| void inet::CounterFigure::refresh |
( |
| ) |
|
|
protected |
426 if (std::isnan(
value))
427 for (Digit digit :
digits)
428 digit.text->setText(
"");
431 for (Digit digit :
digits)
432 digit.text->setText(
"*");
436 for (
int i =
digits.size() - 1; i >= 0; --i) {
439 int actValue = ((int)
value % pow) / (pow / 10);
440 sprintf(buf,
"%d", actValue);
441 digits[i].text->setText(buf);
Referenced by parse(), and setValue().
◆ setAnchor()
| void inet::CounterFigure::setAnchor |
( |
Anchor |
anchor | ) |
|
◆ setBackgroundColor()
| void inet::CounterFigure::setBackgroundColor |
( |
const Color & |
color | ) |
|
◆ setDecimalPlaces()
| void inet::CounterFigure::setDecimalPlaces |
( |
int |
radius | ) |
|
65 if (
digits.size() != (
unsigned int)number) {
66 if (
digits.size() > (
unsigned int)number)
68 for (
int i =
digits.size() - 1; i > number - 1; --i) {
69 delete removeFigure(
digits[i].bounds);
70 delete removeFigure(
digits[i].text);
75 while (
digits.size() < (
unsigned int)number) {
76 Digit digit(
new cRectangleFigure(),
new cTextFigure());
77 digit.bounds->setFilled(
true);
79 digit.bounds->setZoomLineWidth(
true);
80 digit.text->setAnchor(ANCHOR_CENTER);
83 addFigure(digit.bounds);
84 addFigure(digit.text);
Referenced by parse().
◆ setDigitBackgroundColor()
| void inet::CounterFigure::setDigitBackgroundColor |
( |
const Color & |
color | ) |
|
101 for (Digit digit :
digits)
102 digit.bounds->setFillColor(color);
Referenced by parse().
◆ setDigitBorderColor()
| void inet::CounterFigure::setDigitBorderColor |
( |
const Color & |
color | ) |
|
112 for (Digit digit :
digits)
113 digit.bounds->setLineColor(color);
Referenced by parse().
◆ setDigitColor()
| void inet::CounterFigure::setDigitColor |
( |
const Color & |
color | ) |
|
137 for (Digit digit :
digits)
138 digit.text->setColor(color);
Referenced by parse().
◆ setDigitFont()
| void inet::CounterFigure::setDigitFont |
( |
const Font & |
font | ) |
|
123 for (Digit digit :
digits)
124 digit.text->setFont(font);
Referenced by parse().
◆ setLabel()
| void inet::CounterFigure::setLabel |
( |
const char * |
text | ) |
|
◆ setLabelAnchor()
| void inet::CounterFigure::setLabelAnchor |
( |
Anchor |
anchor | ) |
|
◆ setLabelColor()
| void inet::CounterFigure::setLabelColor |
( |
const Color & |
color | ) |
|
◆ setLabelFont()
| void inet::CounterFigure::setLabelFont |
( |
const Font & |
font | ) |
|
◆ setLabelOffset()
| void inet::CounterFigure::setLabelOffset |
( |
int |
offset | ) |
|
◆ setLabelPos()
| void inet::CounterFigure::setLabelPos |
( |
const Point & |
pos | ) |
|
◆ setPos()
| void inet::CounterFigure::setPos |
( |
const Point & |
bounds | ) |
|
237 bounds.x = backgroundPos.x;
238 bounds.y = backgroundPos.y;
Referenced by parse().
◆ setValue()
| void inet::CounterFigure::setValue |
( |
int |
series, |
|
|
simtime_t |
timestamp, |
|
|
double |
value |
|
) |
| |
|
overridevirtual |
◆ anchor
| Anchor inet::CounterFigure::anchor = ANCHOR_NW |
|
private |
◆ backgroundFigure
| cRectangleFigure* inet::CounterFigure::backgroundFigure |
|
private |
◆ digits
| std::vector<Digit> inet::CounterFigure::digits |
|
private |
Referenced by calculateBounds(), getDecimalPlaces(), getDigitBackgroundColor(), getDigitBorderColor(), getDigitColor(), getDigitFont(), layout(), refresh(), setDecimalPlaces(), setDigitBackgroundColor(), setDigitBorderColor(), setDigitColor(), and setDigitFont().
◆ labelFigure
| cTextFigure* inet::CounterFigure::labelFigure |
|
private |
◆ labelOffset
| int inet::CounterFigure::labelOffset = 10 |
|
private |
◆ value
| double inet::CounterFigure::value = NaN |
|
private |
The documentation for this class was generated from the following files:
value< double, units::s > s
Definition: Units.h:1235
double atod(const char *s)
Converts string to double.
Definition: INETUtils.cc:80
std::vector< K > keys(const std::map< K, V > &m)
Definition: stlutils.h:113
double max(const double a, const double b)
Returns the maximum of a and b.
Definition: SctpAssociation.h:266
Color
Definition: DiffservUtil.h:17