0
votes

I'm drawing circle diagram using my own inbuilt libraries. I'm able to draw circles using table data (x1,y1 & r) ,sharing code
I'm using datachange signal with table, whenever enter any table item data then its creating no. of graph with circles. Is there other signal I can use or what change can make in code ? I want single graph with no. of circles(based on no. of entries in table).
Also when circles are drawn lines coming like we draw without removing our pen to draw another circle how to overcome this ?

  • CHPlotGraph2D - this class to create graph

  • CHPlotCurveData- this Class hold the data points for the curves

  • CHPlotCurve-Class to draw the data as a line curve

    CHPlotCurveData* curvedata1 = new CHPlotCurveData();
    QAbstractItemModel* table1 = ui.tableView->model();
    for (int irows = 0, maxI = table1->rowCount(); irows < maxI; ++irows)
    {
    double x1 = table1->data(table1->index(irows, 1)).toDouble();
    double y1 = table1->data(table1->index(irows, 2)).toDouble();
    double r = table1->data(table1->index(irows, 6)).toDouble();
    for (double angle = 0; angle <= 360; angle++)
    {
    double theta = (angle * 180) / 3.14;
    double zx = x1 + r * cos(theta);
    double zy = y1 + r * sin(theta);
    QPointF pt(zx, zy);
    curvedata1->append((pt));
    }
    }
    CHPlotCurve* curve1 = (CHPlotCurve*)pGr->insertCurve("circle",
    CHPlotGraph2D::Line, false );
    curve1->setSamples(curvedata1);
    connect(ui.tableView->model(), &QAbstractItemModel::dataChanged,
    this, &tablemodel::drawCircle);

1

1 Answers

0
votes

Thank you ..I have solved the problem .When anything changes in the table, I need to remove the existing curve containing all the circles and build/add a new one, or replace the data