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

Method init

src/backend/worksheet/plots/cartesian/CustomPoint.cpp:56–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54CustomPoint::~CustomPoint() = default;
55
56void CustomPoint::init(bool loading) {
57 Q_D(CustomPoint);
58
59 // create the symbol
60 d->symbol = new Symbol(QString());
61 addChild(d->symbol);
62 d->symbol->setHidden(true);
63 connect(d->symbol, &Symbol::updateRequested, [=] {
64 d->recalcShapeAndBoundingRect();
65 });
66 connect(d->symbol, &Symbol::updatePixmapRequested, [=] {
67 d->update();
68 Q_EMIT changed();
69 });
70
71 // init the properties
72 if (!loading) {
73 KConfig config;
74 d->symbol->init(config.group(QStringLiteral("CustomPoint")));
75
76 // default position
77 if (plot()) {
78 d->coordinateBindingEnabled = true; // By default on
79 auto cs = plot()->coordinateSystem(plot()->defaultCoordinateSystemIndex());
80 const auto x = d->m_plot->range(Dimension::X, cs->index(Dimension::X)).center();
81 const auto y = d->m_plot->range(Dimension::Y, cs->index(Dimension::Y)).center();
82 DEBUG(Q_FUNC_INFO << ", x/y pos = " << x << " / " << y)
83 d->positionLogical = QPointF(x, y);
84 } else
85 d->position.point = QPointF(0, 0);
86 d->updatePosition(); // To update also scene coordinates
87 }
88}
89
90/*!
91 Returns an icon to be used in the project explorer.

Callers

nothing calls this directly

Calls 12

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

Tested by

no test coverage detected