| 266 | } |
| 267 | |
| 268 | void Worksheet::handleAspectAdded(const AbstractAspect* aspect) { |
| 269 | DEBUG(Q_FUNC_INFO) |
| 270 | Q_D(Worksheet); |
| 271 | const auto* addedElement = dynamic_cast<const WorksheetElement*>(aspect); |
| 272 | if (!addedElement) |
| 273 | return; |
| 274 | |
| 275 | if (aspect->parentAspect() != this) |
| 276 | return; |
| 277 | |
| 278 | // add the GraphicsItem of the added child to the scene |
| 279 | DEBUG(Q_FUNC_INFO << ", ADDING child to SCENE") |
| 280 | auto* item = addedElement->graphicsItem(); |
| 281 | d->m_scene->addItem(item); |
| 282 | |
| 283 | connect(aspect, &AbstractAspect::contextMenuRequested, this, &Worksheet::childContextMenuRequested); |
| 284 | connect(addedElement, &WorksheetElement::changed, this, &Worksheet::changed); |
| 285 | |
| 286 | // for containers, connect to visilibity changes and update the layout accordingly |
| 287 | if (dynamic_cast<const WorksheetElementContainer*>(addedElement)) |
| 288 | connect(addedElement, &WorksheetElement::visibleChanged, this, [=]() { |
| 289 | if (layout() != Worksheet::Layout::NoLayout) |
| 290 | updateLayout(); |
| 291 | }); |
| 292 | |
| 293 | const auto* plot = dynamic_cast<const CartesianPlot*>(aspect); |
| 294 | if (plot) { |
| 295 | connect(plot, &CartesianPlot::axisShiftSignal, this, &Worksheet::cartesianPlotAxisShift); |
| 296 | connect(plot, &CartesianPlot::wheelEventSignal, this, &Worksheet::cartesianPlotWheelEvent); |
| 297 | connect(plot, &CartesianPlot::mouseMoveCursorModeSignal, this, &Worksheet::cartesianPlotMouseMoveCursorMode); |
| 298 | connect(plot, &CartesianPlot::mouseMoveSelectionModeSignal, this, &Worksheet::cartesianPlotMouseMoveSelectionMode); |
| 299 | connect(plot, &CartesianPlot::mouseMoveZoomSelectionModeSignal, this, &Worksheet::cartesianPlotMouseMoveZoomSelectionMode); |
| 300 | connect(plot, &CartesianPlot::mousePressCursorModeSignal, this, &Worksheet::cartesianPlotMousePressCursorMode); |
| 301 | connect(plot, &CartesianPlot::mousePressZoomSelectionModeSignal, this, &Worksheet::cartesianPlotMousePressZoomSelectionMode); |
| 302 | connect(plot, &CartesianPlot::mouseReleaseZoomSelectionModeSignal, this, &Worksheet::cartesianPlotMouseReleaseZoomSelectionMode); |
| 303 | connect(plot, &CartesianPlot::mouseHoverZoomSelectionModeSignal, this, &Worksheet::cartesianPlotMouseHoverZoomSelectionMode); |
| 304 | connect(plot, &CartesianPlot::mouseHoverOutsideDataRectSignal, this, &Worksheet::cartesianPlotMouseHoverOutsideDataRect); |
| 305 | connect(plot, &CartesianPlot::aspectDescriptionChanged, this, &Worksheet::updateCompleteCursorTreeModel); |
| 306 | connect(plot, &CartesianPlot::curveNameChanged, this, &Worksheet::updateCompleteCursorTreeModel); |
| 307 | connect(plot, &CartesianPlot::curveRemoved, this, &Worksheet::curveRemoved); |
| 308 | connect(plot, &CartesianPlot::curveAdded, this, &Worksheet::curveAdded); |
| 309 | connect(plot, &CartesianPlot::visibleChanged, this, &Worksheet::updateCompleteCursorTreeModel); |
| 310 | connect(plot, &CartesianPlot::curveVisibilityChangedSignal, this, &Worksheet::updateCompleteCursorTreeModel); |
| 311 | connect(plot, &CartesianPlot::curveDataChanged, this, &Worksheet::curveDataChanged); |
| 312 | connect(plot, |
| 313 | static_cast<void (CartesianPlot::*)(const QColor&, const QString&)>(&CartesianPlot::plotColorChanged), |
| 314 | this, |
| 315 | &Worksheet::updateCurveBackground); |
| 316 | connect(plot, &CartesianPlot::mouseModeChanged, this, &Worksheet::cartesianPlotMouseModeChangedSlot); |
| 317 | auto* p = const_cast<CartesianPlot*>(plot); |
| 318 | p->setInteractive(d->plotsInteractive); |
| 319 | |
| 320 | cursorModelPlotAdded(p->name()); |
| 321 | } |
| 322 | qreal zVal = 0; |
| 323 | const auto& children = this->children<WorksheetElement>(ChildIndexFlag::IncludeHidden); |
| 324 | for (auto* child : children) |
| 325 | child->graphicsItem()->setZValue(zVal++); |
nothing calls this directly
no test coverage detected