210 std::vector<cFigure::Rectangle> rcs;
211 std::vector<cFigure::Point> pts;
217 rcs.push_back(extendendSubmoduleBounds);
218 pts.push_back(getTopLeft(extendendSubmoduleBounds));
219 pts.push_back(getTopCenter(extendendSubmoduleBounds));
220 pts.push_back(getTopRight(extendendSubmoduleBounds));
221 pts.push_back(getCenterLeft(extendendSubmoduleBounds));
222 pts.push_back(getCenterRight(extendendSubmoduleBounds));
223 pts.push_back(getBottomLeft(extendendSubmoduleBounds));
224 pts.push_back(getBottomCenter(extendendSubmoduleBounds));
225 pts.push_back(getBottomRight(extendendSubmoduleBounds));
231 auto& annotation = *it;
232 annotation.bounds.x =
NaN;
233 annotation.bounds.y =
NaN;
237 auto& annotation = *it;
238 if (!annotation.figure->isVisible())
243 double bestDistance = std::numeric_limits<double>::infinity();
244 cFigure::Rectangle bestRc;
247 for (
int j = 0; j < (int)pts.size(); j++) {
248 cFigure::Point pt = pts[j];
251 for (
int k = 0;
k < 8;
k++) {
252 cFigure::Rectangle candidateRc;
256 candidateRc = createRectangle(pt - cFigure::Point(0, 0), rs);
260 candidateRc = createRectangle(pt - cFigure::Point(rs.x / 2, 0), rs);
264 candidateRc = createRectangle(pt - cFigure::Point(rs.x, 0), rs);
268 candidateRc = createRectangle(pt - cFigure::Point(0, rs.y / 2), rs);
272 candidateRc = createRectangle(pt - cFigure::Point(rs.x, rs.y / 2), rs);
276 candidateRc = createRectangle(pt - cFigure::Point(0, rs.y), rs);
280 candidateRc = createRectangle(pt - cFigure::Point(rs.x / 2, rs.y), rs);
284 candidateRc = createRectangle(pt - cFigure::Point(rs.x, rs.y), rs);
295 bool intersects =
false;
296 for (
int l = 0; l < (int)rcs.size(); l++) {
297 cFigure::Rectangle rc = rcs[l];
298 if (intersectsRectangle(candidateRc, rc)) {
307 distance += getCenterCenter(
submoduleBounds).distanceTo(getCenterCenter(candidateRc));
308 if (distance < bestDistance) {
309 bestRc = candidateRc;
310 bestDistance = distance;
321 annotation.figure->setTransform(cFigure::Transform().translate(annotation.bounds.x, annotation.bounds.y));
324 for (
int j = 0; j < (int)pts.size(); j++) {
325 cFigure::Point pt = pts[j];
327 if (containsPoint(bestRc, pt))
328 pts.erase(pts.begin() + j--);
332 pushUnlessContains(pts, rcs, getTopLeft(bestRc));
333 pushUnlessContains(pts, rcs, getTopCenter(bestRc));
334 pushUnlessContains(pts, rcs, getTopRight(bestRc));
335 pushUnlessContains(pts, rcs, getCenterLeft(bestRc));
336 pushUnlessContains(pts, rcs, getCenterRight(bestRc));
337 pushUnlessContains(pts, rcs, getBottomLeft(bestRc));
338 pushUnlessContains(pts, rcs, getBottomCenter(bestRc));
339 pushUnlessContains(pts, rcs, getBottomRight(bestRc));
341 rcs.push_back(bestRc);
double annotationSpacing
Definition: NetworkNodeCanvasVisualization.h:46
#define NaN
Definition: INETMath.h:103
std::vector< Annotation > annotations
Definition: NetworkNodeCanvasVisualization.h:51
void sort(std::vector< T > &v)
Definition: stlutils.h:112
static bool compareDisplacementPriority(const Annotation &a1, const Annotation &a2)
Definition: NetworkNodeCanvasVisualization.cc:204
double displacementPenalty
Definition: NetworkNodeCanvasVisualization.h:47
cFigure::Rectangle submoduleBounds
Definition: NetworkNodeCanvasVisualization.h:50
const double k
Definition: QAM16Modulation.cc:24