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

Method checkAxisFormat

src/backend/worksheet/plots/cartesian/CartesianPlot.cpp:2486–2526  ·  view source on GitHub ↗

set format of axis from data column

Source from the content-addressed store, hash-verified

2484
2485// set format of axis from data column
2486void CartesianPlot::checkAxisFormat(const int cSystemIndex, const AbstractColumn* column, Axis::Orientation orientation) {
2487 if (isLoading())
2488 return;
2489
2490 const auto* col = qobject_cast<const Column*>(column);
2491 if (!col)
2492 return;
2493
2494 const int xIndex = coordinateSystem(cSystemIndex)->index(Dimension::X);
2495 const int yIndex = coordinateSystem(cSystemIndex)->index(Dimension::Y);
2496
2497 Q_D(CartesianPlot);
2498 if (col->columnMode() == AbstractColumn::ColumnMode::DateTime) {
2499 setUndoAware(false);
2500 if (orientation == Axis::Orientation::Horizontal)
2501 setXRangeFormat(xIndex, RangeT::Format::DateTime);
2502 else
2503 setYRangeFormat(yIndex, RangeT::Format::DateTime);
2504 setUndoAware(true);
2505
2506 // set column's datetime format for all horizontal axis
2507 for (auto* axis : children<Axis>()) {
2508 if (axis->orientation() == orientation) {
2509 const auto* cSystem{coordinateSystem(axis->coordinateSystemIndex())};
2510 const auto* filter = static_cast<DateTime2StringFilter*>(col->outputFilter());
2511 d->xRanges[cSystem ? cSystem->index(Dimension::X) : 0].range.setDateTimeFormat(filter->format());
2512 axis->setUndoAware(false);
2513 axis->setLabelsDateTimeFormat(rangeDateTimeFormat(Dimension::X, xIndex));
2514 axis->setUndoAware(true);
2515 }
2516 }
2517 } else {
2518 setUndoAware(false);
2519 if (orientation == Axis::Orientation::Horizontal)
2520 setXRangeFormat(xIndex, RangeT::Format::Numeric);
2521 else
2522 setYRangeFormat(yIndex, RangeT::Format::Numeric);
2523
2524 setUndoAware(true);
2525 }
2526}
2527
2528void CartesianPlot::boxPlotOrientationChanged(BoxPlot::Orientation orientation) {
2529 const auto& axes = children<Axis>();

Callers

nothing calls this directly

Calls 9

coordinateSystemIndexMethod · 0.80
setUndoAwareMethod · 0.80
indexMethod · 0.45
columnModeMethod · 0.45
orientationMethod · 0.45
outputFilterMethod · 0.45
setDateTimeFormatMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected