! * \brief Datapicker::addNewPoint * \param pos position in scene coordinates * \param parentAspect */
| 215 | * \param parentAspect |
| 216 | */ |
| 217 | void Datapicker::addNewPoint(QPointF pos, AbstractAspect* parentAspect) { |
| 218 | auto points = parentAspect->children<DatapickerPoint>(ChildIndexFlag::IncludeHidden); |
| 219 | |
| 220 | auto* newPoint = new DatapickerPoint(i18n("Point %1", points.count() + 1)); |
| 221 | newPoint->setHidden(true); |
| 222 | |
| 223 | beginMacro(i18n("%1: add %2", parentAspect->name(), newPoint->name())); |
| 224 | if (parentAspect->addChild(newPoint)) { |
| 225 | const QPointF oldPos = newPoint->position(); |
| 226 | newPoint->setPosition(pos); |
| 227 | if (oldPos == pos) { |
| 228 | // Just if pos == oldPos, setPosition will not trigger retransform() then |
| 229 | newPoint->retransform(); |
| 230 | } |
| 231 | |
| 232 | auto* datapickerCurve = static_cast<DatapickerCurve*>(parentAspect); |
| 233 | if (m_image == parentAspect) |
| 234 | newPoint->setIsReferencePoint(true); |
| 235 | else if (datapickerCurve) |
| 236 | newPoint->initErrorBar(datapickerCurve->curveErrorTypes()); |
| 237 | } else |
| 238 | delete newPoint; |
| 239 | endMacro(); |
| 240 | Q_EMIT requestUpdateActions(); |
| 241 | } |
| 242 | |
| 243 | bool Datapicker::xDateTime() const { |
| 244 | return m_image->axisPoints().datetime; |