MCPcopy Create free account
hub / github.com/KDE/labplot / init

Method init

src/backend/worksheet/plots/cartesian/ReferenceRange.cpp:49–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47ReferenceRange::~ReferenceRange() = default;
48
49void ReferenceRange::init(bool loading) {
50 Q_D(ReferenceRange);
51
52 // create the background
53 d->background = new Background(QString());
54 d->background->setEnabledAvailable(true);
55 addChild(d->background);
56 d->background->setHidden(true);
57 connect(d->background, &Background::updateRequested, [=] {
58 d->update();
59 Q_EMIT changed();
60 });
61
62 // create the border line
63 d->line = new Line(QString());
64 d->line->setHidden(true);
65 addChild(d->line);
66 connect(d->line, &Line::updatePixmapRequested, [=] {
67 d->update();
68 Q_EMIT changed();
69 });
70 connect(d->line, &Line::updateRequested, [=] {
71 d->recalcShapeAndBoundingRect();
72 });
73
74 // init the properties
75 if (!loading) {
76 KConfig config;
77 KConfigGroup group = config.group(QStringLiteral("ReferenceRange"));
78
79 d->orientation = (Orientation)group.readEntry(QStringLiteral("Orientation"), static_cast<int>(Orientation::Vertical));
80 d->updatePositionLimit(); // set the position limit after the orientation was set
81 d->background->init(group);
82 d->line->init(group);
83
84 if (plot()) {
85 m_cSystemIndex = plot()->defaultCoordinateSystemIndex();
86 cSystem = plot()->coordinateSystem(m_cSystemIndex);
87 d->coordinateBindingEnabled = true;
88 // default position - 10% of the plot width/height positioned around the center
89 auto cs = plot()->coordinateSystem(coordinateSystemIndex());
90 const auto x = d->m_plot->range(Dimension::X, cs->index(Dimension::X)).center();
91 const auto y = d->m_plot->range(Dimension::Y, cs->index(Dimension::Y)).center();
92 const auto w = d->m_plot->range(Dimension::X, cs->index(Dimension::X)).length() * 0.1;
93 const auto h = d->m_plot->range(Dimension::Y, cs->index(Dimension::Y)).length() * 0.1;
94 d->positionLogical = QPointF(x, y);
95 d->positionLogicalStart = QPointF(x - w / 2, y - h / 2);
96 d->positionLogicalEnd = QPointF(x + w / 2, y + h / 2);
97 } else
98 d->position.point = QPointF(0, 0); // center of parent
99 d->updatePosition(); // to update also scene coordinates
100 }
101
102 connect(this, &WorksheetElement::objectPositionChanged, this, &ReferenceRange::updateStartEndPositions);
103 retransform(); // TODO: why is this required here?!?
104}
105
106/*!

Callers

nothing calls this directly

Calls 15

setEnabledAvailableMethod · 0.80
rangeMethod · 0.80
lengthMethod · 0.80
QPointFClass · 0.70
QStringClass · 0.50
setHiddenMethod · 0.45
updateMethod · 0.45
groupMethod · 0.45
updatePositionLimitMethod · 0.45
coordinateSystemMethod · 0.45

Tested by

no test coverage detected