| 54 | CustomPoint::~CustomPoint() = default; |
| 55 | |
| 56 | void 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. |
nothing calls this directly
no test coverage detected