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

Method setAxesTitles

src/frontend/spreadsheet/PlotDataDialog.cpp:878–1076  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

876}
877
878void PlotDataDialog::setAxesTitles(CartesianPlot* plot, const QString& name) const {
879 DEBUG(Q_FUNC_INFO)
880 const auto& axes = plot->children<Axis>();
881 switch (m_plotType) {
882 case Plot::PlotType::Line:
883 case Plot::PlotType::LineHorizontalStep:
884 case Plot::PlotType::LineVerticalStep:
885 case Plot::PlotType::LineSpline:
886 case Plot::PlotType::Scatter:
887 case Plot::PlotType::ScatterYError:
888 case Plot::PlotType::ScatterXYError:
889 case Plot::PlotType::LineSymbol:
890 case Plot::PlotType::LineSymbol2PointSegment:
891 case Plot::PlotType::LineSymbol3PointSegment:
892 case Plot::PlotType::Formula: {
893 // x-axis title
894 const QString& xColumnName = ui->cbXColumn->currentText();
895 // DEBUG(Q_FUNC_INFO << ", x column name = " << STDSTRING(xColumnName))
896
897 for (auto* axis : axes) {
898 if (axis->orientation() == Axis::Orientation::Horizontal) {
899 axis->title()->setText(xColumnName);
900 break;
901 }
902 }
903
904 // y-axis title
905 for (auto* axis : axes) {
906 if (axis->orientation() == Axis::Orientation::Vertical) {
907 if (!name.isEmpty()) {
908 // multiple columns are plotted with "one curve per plot",
909 // the function is called with the column name.
910 // use it for the x-axis title
911 axis->title()->setText(name);
912 } else if (m_columnComboBoxes.size() == 2) {
913 // if we only have one single y-column to plot, we can set the title of the y-axes
914 const QString& yColumnName = m_columnComboBoxes[1]->currentText();
915 axis->title()->setText(yColumnName);
916 }
917
918 break;
919 }
920 }
921 break;
922 }
923 case Plot::PlotType::Histogram:
924 case Plot::PlotType::KDEPlot: {
925 // x-axis title
926 for (auto* axis : axes) {
927 if (axis->orientation() == Axis::Orientation::Horizontal) {
928 if (!name.isEmpty()) {
929 // multiple columns are plotted with "one curve per plot",
930 // the function is called with the column name.
931 // use it for the x-axis title
932 axis->title()->setText(name);
933 } else if (m_columnComboBoxes.size() == 1) {
934 const QString& yColumnName = m_columnComboBoxes.constFirst()->currentText();
935 axis->title()->setText(yColumnName);

Callers

nothing calls this directly

Calls 15

currentTextMethod · 0.80
coordinateSystemIndexMethod · 0.80
setMajorTicksTypeMethod · 0.80
setMajorTicksSpacingMethod · 0.80
setMinorTicksNumberMethod · 0.80
setNiceExtendMethod · 0.80
setLabelsPositionMethod · 0.80
setRightPaddingMethod · 0.80
QStringClass · 0.50
orientationMethod · 0.45

Tested by

no test coverage detected