QCustomPlot Discussion and Comments

In Polar plot, point cannot be selected in 270°~360°Return to overview

Hi, I have a requirement of selecting one point in polar plot. Above all, I have done all the steps referred to the example of polar plot. In order to make point in polar plot selectable, I Called

Then connect signal and slot like this
QCPPolarGraph* pgraph = new QCPPolarGraph(polarAxisAngular, polarAxisAngular->radialAxis());
        static_cast<void(QCPPolarGraph::*)(const QCPDataSelection&)>(&QCPPolarGraph::selectionChanged),
        [pgraph](const QCPDataSelection& selection){
    QSharedPointer<QCPGraphDataContainer> pGraphData = pgraph->data();
    QCPDataRange range = selection.dataRange();
When I test clicking point in QCPPolarGraph, I found that if I only add one data in 270°~360°, it can be selected and trigger slot with a nonempty selection. If I add one point additionally in the same pgraph, the previous point trigger slot with an empty selection when clicked. This only occurred when the previous point appears in 270°~360°.

Maybe my usage of polar plot is so inelegant, I came up with this idea just because I cannot threat QCPPolarGraph as QCPGraph, signal QCustomPlot::plottableClick not emitted. If there is any solution of what I encountered :) Thanks a lot.

Best regards.

When calculating the distance interval of the clicked area, the position of the area is calculated according to the arctangent, and the result of the third quadrant is obtained.

void QCPPolarAxisRadial::pixelToCoord(QPointF pixelPos, double &angleCoord, double &radiusCoord) const
  QCPVector2D posVector(pixelPos-mCenter);
  radiusCoord = radiusToCoord(posVector.length());
  angleCoord = mAngularAxis->angleRadToCoord(posVector.angle()); // atan2()
Therefore QCPPorarAxisAngular:: angleRadToCoord() returns a negative angle incorrectly, which should actually return 270 °~360 °.
In function angleRadToCoord. Add judgment on angle quadrant, if it is in the third quadrant, angleRad + 2.0*M_PI.