|
INET Framework for OMNeT++/OMNEST
|
#include <SceneCanvasVisualizer.h>
◆ displayDescription()
| void inet::visualizer::SceneCanvasVisualizer::displayDescription |
( |
const char * |
descriptionFigurePath | ) |
|
|
protectedvirtual |
216 if (!descriptionFigure)
217 throw cRuntimeError(
"Figure \"%s\" not found", descriptionFigurePath);
218 auto descriptionTextFigure = check_and_cast<cAbstractTextFigure *>(descriptionFigure);
220 auto config = getEnvir()->getConfigEx();
221 const char *activeConfig = config->getActiveConfigName();
222 std::string description = std::string(activeConfig) +
": " + config->getConfigDescription(activeConfig);
223 descriptionTextFigure->setText(description.c_str());
Referenced by initialize().
◆ handleParameterChange()
| void inet::visualizer::SceneCanvasVisualizer::handleParameterChange |
( |
const char * |
name | ) |
|
|
overrideprotectedvirtual |
103 if (!hasGUI())
return;
104 if (name && !strcmp(name,
"viewAngle")) {
110 else if (name && !strcmp(name,
"viewScale")) {
114 else if (name && !strcmp(name,
"viewTranslation")) {
118 double axisLength = par(
"axisLength");
119 if (!std::isnan(axisLength))
◆ initialize()
| void inet::visualizer::SceneCanvasVisualizer::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
Reimplemented from inet::visualizer::SceneVisualizerBase.
21 if (!hasGUI())
return;
30 axisLayer =
new cGroupFigure(
"axisLayer");
32 axisLayer->insertBelow(canvas->getSubmodulesLayer());
33 double axisLength = par(
"axisLength");
34 if (!std::isnan(axisLength))
36 std::string descriptionFigurePath = par(
"descriptionFigure");
37 if (!descriptionFigurePath.empty())
◆ initializeAxis()
| void inet::visualizer::SceneCanvasVisualizer::initializeAxis |
( |
double |
axisLength | ) |
|
|
protectedvirtual |
44 cLineFigure *xAxis =
new cLineFigure(
"xAxis");
45 cLineFigure *yAxis =
new cLineFigure(
"yAxis");
46 cLineFigure *zAxis =
new cLineFigure(
"zAxis");
47 auto axisTags = std::string(
"axis ") +
tags;
48 xAxis->setTags(axisTags.c_str());
49 yAxis->setTags(axisTags.c_str());
50 zAxis->setTags(axisTags.c_str());
51 xAxis->setTooltip(
"Scene X axis");
52 yAxis->setTooltip(
"Scene Y axis");
53 zAxis->setTooltip(
"Scene Z axis");
54 xAxis->setLineWidth(1);
55 yAxis->setLineWidth(1);
56 zAxis->setLineWidth(1);
57 xAxis->setEndArrowhead(cFigure::ARROW_BARBED);
58 yAxis->setEndArrowhead(cFigure::ARROW_BARBED);
59 zAxis->setEndArrowhead(cFigure::ARROW_BARBED);
60 xAxis->setZoomLineWidth(
false);
61 yAxis->setZoomLineWidth(
false);
62 zAxis->setZoomLineWidth(
false);
66 cLabelFigure *xLabel =
new cLabelFigure(
"xAxisLabel");
67 cLabelFigure *yLabel =
new cLabelFigure(
"yAxisLabel");
68 cLabelFigure *zLabel =
new cLabelFigure(
"zAxisLabel");
69 auto axisLabelTags = std::string(
"axis label ") +
tags;
70 xLabel->setTags(axisLabelTags.c_str());
71 yLabel->setTags(axisLabelTags.c_str());
72 zLabel->setTags(axisLabelTags.c_str());
Referenced by initialize().
◆ parse2D()
| cFigure::Point inet::visualizer::SceneCanvasVisualizer::parse2D |
( |
const char * |
text, |
|
|
bool |
invertY = false |
|
) |
| |
|
protectedvirtual |
208 if (sscanf(text,
"%lf %lf", &x, &y) != 2)
209 throw cRuntimeError(
"The parameter must be a pair of doubles: %s", text);
210 return cFigure::Point(x, invertY ? -y : y);
Referenced by handleParameterChange(), and initialize().
◆ parseViewAngle()
| RotationMatrix inet::visualizer::SceneCanvasVisualizer::parseViewAngle |
( |
const char * |
viewAngle, |
|
|
bool & |
invertY |
|
) |
| |
|
protectedvirtual |
126 if (*viewAngle ==
'x' || *viewAngle ==
'y' || *viewAngle ==
'z') {
127 double matrix[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
128 cStringTokenizer tokenizer(viewAngle);
129 while (tokenizer.hasMoreTokens()) {
130 const char *axisToken = tokenizer.nextToken();
131 if (axisToken ==
nullptr)
132 throw cRuntimeError(
"Missing token in viewAngle parameter value");
134 if (!strcmp(axisToken,
"x"))
136 else if (!strcmp(axisToken,
"y"))
138 else if (!strcmp(axisToken,
"z"))
141 throw cRuntimeError(
"Invalid token in viewAngle parameter value: '%s'", axisToken);
142 const char *directionToken = tokenizer.nextToken();
143 if (directionToken ==
nullptr)
144 throw cRuntimeError(
"Missing token in viewAngle parameter value");
146 if (!strcmp(directionToken,
"right"))
148 else if (!strcmp(directionToken,
"left"))
150 else if (!strcmp(directionToken,
"up"))
152 else if (!strcmp(directionToken,
"down"))
154 else if (!strcmp(directionToken,
"out"))
156 else if (!strcmp(directionToken,
"in"))
159 throw cRuntimeError(
"Invalid token in viewAngle parameter value: '%s'", directionToken);
160 if (matrix[0][i] != 0 || matrix[1][i] != 0 || matrix[2][i] != 0)
161 throw cRuntimeError(
"Invalid viewAngle parameter vale: '%s'", viewAngle);
167 double determinant = matrix[0][0] * ((matrix[1][1] * matrix[2][2]) - (matrix[2][1] * matrix[1][2])) - matrix[0][1] * (matrix[1][0] * matrix[2][2] - matrix[2][0] * matrix[1][2]) + matrix[0][2] * (matrix[1][0] * matrix[2][1] - matrix[2][0] * matrix[1][1]);
168 if (determinant == -1) {
176 return RotationMatrix(matrix);
178 else if (!strncmp(viewAngle,
"isometric", 9)) {
180 int l = strlen(viewAngle);
182 case 9: v = 0;
break;
183 case 10: v = viewAngle[9] -
'0';
break;
184 case 11: v = (viewAngle[9] -
'0') * 10 + viewAngle[10] -
'0';
break;
185 default:
throw cRuntimeError(
"Invalid isometric viewAngle parameter");
192 deg beta =
deg(v / 24 % 2 ? 35.27 : -35.27);
193 deg gamma =
deg(30 + v / 4 % 6 * 60);
195 return RotationMatrix(EulerAngles(
alpha, beta, gamma));
197 else if (sscanf(viewAngle,
"%lf %lf %lf", &a, &
b, &
c) == 3) {
199 return RotationMatrix(EulerAngles(
deg(a),
deg(
b),
deg(
c)));
202 throw cRuntimeError(
"Invalid viewAngle parameter value: '%s'", viewAngle);
Referenced by handleParameterChange(), and initialize().
◆ refreshAxis()
| void inet::visualizer::SceneCanvasVisualizer::refreshAxis |
( |
double |
axisLength | ) |
|
|
protectedvirtual |
84 auto xAxis = check_and_cast<cLineFigure *>(
axisLayer->getFigure(0));
85 auto yAxis = check_and_cast<cLineFigure *>(
axisLayer->getFigure(1));
86 auto zAxis = check_and_cast<cLineFigure *>(
axisLayer->getFigure(2));
87 auto xLabel = check_and_cast<cLabelFigure *>(
axisLayer->getFigure(3));
88 auto yLabel = check_and_cast<cLabelFigure *>(
axisLayer->getFigure(4));
89 auto zLabel = check_and_cast<cLabelFigure *>(
axisLayer->getFigure(5));
Referenced by handleParameterChange(), and initializeAxis().
◆ axisLayer
| cGroupFigure* inet::visualizer::SceneCanvasVisualizer::axisLayer = nullptr |
|
protected |
◆ canvasProjection
| CanvasProjection* inet::visualizer::SceneCanvasVisualizer::canvasProjection = nullptr |
|
protected |
◆ zIndex
| double inet::visualizer::SceneCanvasVisualizer::zIndex = NaN |
|
protected |
The documentation for this class was generated from the following files:
void setTranslation(const cFigure::Point &translation)
Definition: CanvasProjection.h:36
const value< double, compose< units::m, pow< units::s, -1 > > > c(299792458)
virtual void displayDescription(const char *descriptionFigurePath)
Definition: SceneCanvasVisualizer.cc:213
double zIndex
Definition: SceneCanvasVisualizer.h:21
fscale< rad, rad2degScale > deg
Definition: Units.h:1158
static const Coord ZERO
Definition: Coord.h:27
static CanvasProjection * getCanvasProjection(const cCanvas *canvas)
Definition: CanvasProjection.cc:53
virtual void refreshAxis(double axisLength)
Definition: SceneCanvasVisualizer.cc:82
cModule * visualizationTargetModule
Definition: VisualizerBase.h:25
CanvasProjection * canvasProjection
Definition: SceneCanvasVisualizer.h:22
virtual RotationMatrix parseViewAngle(const char *viewAngle, bool &invertY)
Definition: SceneCanvasVisualizer.cc:123
cGroupFigure * axisLayer
Definition: SceneCanvasVisualizer.h:23
static const Coord Z_AXIS
Definition: Coord.h:31
cFigure::Point computeCanvasPoint(const Coord &point) const
Definition: CanvasProjection.cc:34
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
static const Coord X_AXIS
Definition: Coord.h:29
value< int64_t, units::b > b
Definition: Units.h:1241
const value< double, units::unit > alpha(7.2973525376e-3)
void setRotation(const RotationMatrix &rotation)
Definition: CanvasProjection.h:30
const char * tags
Definition: VisualizerBase.h:27
virtual void initializeAxis(double axisLength)
Definition: SceneCanvasVisualizer.cc:42
void setScale(const cFigure::Point &scale)
Definition: CanvasProjection.h:33
virtual cFigure::Point parse2D(const char *text, bool invertY=false)
Definition: SceneCanvasVisualizer.cc:205
virtual void initialize(int stage) override
Definition: SceneVisualizerBase.cc:20
static const Coord Y_AXIS
Definition: Coord.h:30