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

Method updateValues

src/backend/worksheet/plots/cartesian/LollipopPlot.cpp:682–821  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

680}
681
682void LollipopPlotPrivate::updateValues() {
683 m_valuesPath = QPainterPath();
684 m_valuesPoints.clear();
685 m_valuesStrings.clear();
686
687 if (value->type() == Value::NoValues) {
688 recalcShapeAndBoundingRect();
689 return;
690 }
691
692 // determine the value string for all points that are currently visible in the plot
693 auto visiblePoints = std::vector<bool>(m_valuesPointsLogical.count(), false);
694 Points pointsScene;
695 q->cSystem->mapLogicalToScene(m_valuesPointsLogical, pointsScene, visiblePoints);
696 const auto& prefix = value->prefix();
697 const auto& suffix = value->suffix();
698 const auto numberLocale = QLocale();
699 if (value->type() == Value::BinEntries) {
700 for (int i = 0; i < m_valuesPointsLogical.count(); ++i) {
701 if (!visiblePoints[i])
702 continue;
703
704 auto& point = m_valuesPointsLogical.at(i);
705 if (orientation == LollipopPlot::Orientation::Vertical)
706 m_valuesStrings << prefix + numberToString(point.y(), numberLocale) + suffix;
707 else
708 m_valuesStrings << prefix + numberToString(point.x(), numberLocale) + suffix;
709 }
710 } else if (value->type() == Value::CustomColumn) {
711 const auto* valuesColumn = value->column();
712 if (!valuesColumn) {
713 recalcShapeAndBoundingRect();
714 return;
715 }
716
717 const int endRow = std::min(m_valuesPointsLogical.size(), static_cast<qsizetype>(valuesColumn->rowCount()));
718 const auto xColMode = valuesColumn->columnMode();
719 for (int i = 0; i < endRow; ++i) {
720 if (!valuesColumn->isValid(i) || valuesColumn->isMasked(i))
721 continue;
722
723 switch (xColMode) {
724 case AbstractColumn::ColumnMode::Double:
725 m_valuesStrings << prefix + numberToString(valuesColumn->valueAt(i), numberLocale, value->numericFormat(), value->precision()) + suffix;
726 break;
727 case AbstractColumn::ColumnMode::Integer:
728 case AbstractColumn::ColumnMode::BigInt:
729 m_valuesStrings << prefix + numberToString(valuesColumn->valueAt(i), numberLocale) + suffix;
730 break;
731 case AbstractColumn::ColumnMode::Text:
732 m_valuesStrings << prefix + valuesColumn->textAt(i) + suffix;
733 break;
734 case AbstractColumn::ColumnMode::DateTime:
735 case AbstractColumn::ColumnMode::Month:
736 case AbstractColumn::ColumnMode::Day:
737 m_valuesStrings << prefix + valuesColumn->dateTimeAt(i).toString(value->dateTimeFormat()) + suffix;
738 break;
739 }

Callers 1

updateLocaleMethod · 0.45

Calls 15

mapLogicalToSceneMethod · 0.80
suffixMethod · 0.80
xMethod · 0.80
numericFormatMethod · 0.80
fontMethod · 0.80
positionMethod · 0.80
appendMethod · 0.80
lengthMethod · 0.80
QPointFClass · 0.70
clearMethod · 0.45
typeMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected