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

Method init

src/backend/worksheet/plots/cartesian/ReferenceLine.cpp:48–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46ReferenceLine::~ReferenceLine() = default;
47
48void ReferenceLine::init(bool loading) {
49 Q_D(ReferenceLine);
50
51 // create the line
52 d->line = new Line(QString());
53 d->line->setHidden(true);
54 addChild(d->line);
55 connect(d->line, &Line::updatePixmapRequested, [=] {
56 d->update();
57 Q_EMIT changed();
58 });
59 connect(d->line, &Line::updateRequested, [=] {
60 d->recalcShapeAndBoundingRect();
61 });
62
63 // init the properties
64 if (!loading) {
65 KConfig config;
66 KConfigGroup group = config.group(QStringLiteral("ReferenceLine"));
67 d->orientation = (Orientation)group.readEntry(QStringLiteral("Orientation"), static_cast<int>(Orientation::Vertical));
68 d->updatePositionLimit(); // set the position limit after the orientation was set
69 d->line->init(group);
70
71 if (plot()) {
72 d->coordinateBindingEnabled = true;
73 // default position
74 auto cs = plot()->coordinateSystem(plot()->defaultCoordinateSystemIndex());
75 const auto x = d->m_plot->range(Dimension::X, cs->index(Dimension::X)).center();
76 const auto y = d->m_plot->range(Dimension::Y, cs->index(Dimension::Y)).center();
77 DEBUG(Q_FUNC_INFO << ", x/y pos = " << x << " / " << y)
78 d->positionLogical = QPointF(x, y);
79 } else
80 d->position.point = QPointF(0, 0);
81 d->updatePosition(); // To update also scene coordinates
82 }
83}
84
85/*!
86 Returns an icon to be used in the project explorer.

Callers

nothing calls this directly

Calls 13

rangeMethod · 0.80
QPointFClass · 0.70
QStringClass · 0.50
setHiddenMethod · 0.45
updateMethod · 0.45
groupMethod · 0.45
updatePositionLimitMethod · 0.45
coordinateSystemMethod · 0.45
centerMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected