| 981 | } |
| 982 | |
| 983 | void CartesianPlot::processDropEvent(const QVector<quintptr>& vec) { |
| 984 | PERFTRACE(QLatin1String(Q_FUNC_INFO)); |
| 985 | |
| 986 | QVector<AbstractColumn*> columns; |
| 987 | for (auto a : vec) { |
| 988 | auto* aspect = (AbstractAspect*)a; |
| 989 | auto* column = qobject_cast<AbstractColumn*>(aspect); |
| 990 | if (column) |
| 991 | columns << column; |
| 992 | } |
| 993 | |
| 994 | // return if there are no columns being dropped. |
| 995 | // TODO: extend this later when we allow to drag&drop plots, etc. |
| 996 | if (columns.isEmpty()) |
| 997 | return; |
| 998 | |
| 999 | // determine the first column with "x plot designation" as the x-data column for all curves to be created |
| 1000 | const AbstractColumn* xColumn = nullptr; |
| 1001 | for (const auto* column : std::as_const(columns)) { |
| 1002 | if (column->plotDesignation() == AbstractColumn::PlotDesignation::X) { |
| 1003 | xColumn = column; |
| 1004 | break; |
| 1005 | } |
| 1006 | } |
| 1007 | |
| 1008 | // if no column with "x plot designation" is available, use the x-data column of the first curve in the plot, |
| 1009 | if (xColumn == nullptr) { |
| 1010 | QVector<XYCurve*> curves = children<XYCurve>(); |
| 1011 | if (!curves.isEmpty()) |
| 1012 | xColumn = curves.at(0)->xColumn(); |
| 1013 | } |
| 1014 | |
| 1015 | // use the first dropped column if no column with "x plot designation" nor curves are available |
| 1016 | if (xColumn == nullptr) |
| 1017 | xColumn = columns.at(0); |
| 1018 | |
| 1019 | // create curves |
| 1020 | bool curvesAdded = false; |
| 1021 | for (const auto* column : std::as_const(columns)) { |
| 1022 | if (column == xColumn) |
| 1023 | continue; |
| 1024 | |
| 1025 | XYCurve* curve = new XYCurve(column->name()); |
| 1026 | curve->setSuppressRetransform(true); // suppress retransform, all curved will be recalculated at the end |
| 1027 | curve->setXColumn(xColumn); |
| 1028 | curve->setYColumn(column); |
| 1029 | addChild(curve); |
| 1030 | curve->setSuppressRetransform(false); |
| 1031 | curvesAdded = true; |
| 1032 | } |
| 1033 | |
| 1034 | if (curvesAdded) { |
| 1035 | // In addChild() the curve gets the coordinatesystem which is the default coordinate system |
| 1036 | dataChanged(defaultCoordinateSystem()->index(Dimension::X), defaultCoordinateSystem()->index(Dimension::Y)); |
| 1037 | } |
| 1038 | } |
| 1039 | |
| 1040 | bool CartesianPlot::isPanningActive() const { |
nothing calls this directly
no test coverage detected