QT Datavisualization visualize multiple Data sets on Scatter QT Example



  • Hi Guys :)

    I have a problem and i hope that sb can help me.

    i have the scatter example from QT.
    In this scatter i am adding some points to a QScatterDataItem and then adding it to the m_graph (scatter graph)
    now i want to add multiple Graphs to the scatter ...
    so i have done the same thin like in the example only with a second m_graph2 und second data set.

    The Problem is that QT is only printing the last Data Set i am adding... like this i can't for example change the color of the points only for one Data set.

    I hope that sb can help me :)

    ScatterDataModifier::ScatterDataModifier(Q3DScatter *scatter)
        : m_graph(scatter),
          m_graph2(scatter),
          m_fontSize(40.0f),
          m_style(QAbstract3DSeries::MeshPoint),
          m_smooth(true),
          m_itemCount(lowerNumberOfItems),
          m_curveDivider(lowerCurveDivider)
    
    {   
        m_graph->activeTheme()->setType(Q3DTheme::ThemeEbony);
        QFont font = m_graph->activeTheme()->font();
        font.setPointSize(m_fontSize);
        m_graph->activeTheme()->setFont(font);
        m_graph->setShadowQuality(QAbstract3DGraph::ShadowQualityNone);
        m_graph->scene()->activeCamera()->setCameraPreset(Q3DCamera::CameraPresetFront);
    
        m_graph2->activeTheme()->setType(Q3DTheme::ThemeEbony);
        QFont font2 = m_graph2->activeTheme()->font();
        font2.setPointSize(m_fontSize);
        m_graph2->activeTheme()->setFont(font);
        m_graph2->setShadowQuality(QAbstract3DGraph::ShadowQualityNone);
        m_graph2->scene()->activeCamera()->setCameraPreset(Q3DCamera::CameraPresetFront);
    
        QScatterDataProxy *proxy = new QScatterDataProxy;
        QScatter3DSeries *series = new QScatter3DSeries(proxy);
        series->setItemLabelFormat(QStringLiteral("@xTitle: @xLabel @yTitle: @yLabel @zTitle: @zLabel"));
        series->setMeshSmooth(m_smooth);
    
        QScatterDataProxy *proxy2 = new QScatterDataProxy;
        QScatter3DSeries *series2 = new QScatter3DSeries(proxy2);
        series->setItemLabelFormat(QStringLiteral("@xTeeeeitle: @xLaeeeebel @yTieeeeeeetle: @yLeeabel @zTieetle: @zeeLabel"));
        series->setMeshSmooth(m_smooth);
    
    
        m_graph->addSeries(series);
        m_graph2->addSeries(series2);
    
        // addData();
    }
    
    ScatterDataModifier::~ScatterDataModifier()
    {
        delete m_graph;
        delete m_graph2;
    }
    
    void ScatterDataModifier::addData()
    {
        // Configure the axes according to the data
        m_graph->axisX()->setTitle("X [AU]");
        m_graph->axisY()->setTitle("Y [AU]");
        m_graph->axisZ()->setTitle("Z [AU]");
        // Configure the axes according to the data
        m_graph2->axisX()->setTitle("X [AU]");
        m_graph2->axisY()->setTitle("Y [AU]");
        m_graph2->axisZ()->setTitle("Z [AU]");
    
        QScatterDataArray *dataArraySc = new QScatterDataArray;
        dataArraySc->resize(m_itemCount);
        QScatterDataArray *dataArrayObs = new QScatterDataArray;
        dataArrayObs->resize(m_itemCount);
        QScatterDataItem *ptrToDataArraySc = &dataArraySc->first();
        QScatterDataItem *ptrToDataArrayObs = &dataArrayObs->first();
    
         std::tie(TargetPosition,AllStepDates) = ScatterDataModifier::GetPositionsSpice(spacecraft_id);
    
         for(int i =0; i<TargetPosition.size();i++)
         {
         ptrToDataArraySc->setPosition(QVector3D(TargetPosition[i][0],TargetPosition[i][1],TargetPosition[i][2]));
         ptrToDataArraySc++;
         }
    
          std::tie(ObserverPosition,AllStepDates) = ScatterDataModifier::GetPositionsSpice("SUN");
          for(int i =0; i<ObserverPosition.size();i++)
          {
          ptrToDataArrayObs->setPosition(QVector3D(ObserverPosition[i][0],ObserverPosition[i][1],ObserverPosition[i][2]));
          ptrToDataArrayObs++;
          }
    
    
    
        m_graph2->seriesList().at(0)->setMesh(QAbstract3DSeries::MeshCube);
        m_graph2->seriesList().at(0)->dataProxy()->resetArray(dataArrayObs);
        m_graph->seriesList().at(0)->setMesh(QAbstract3DSeries::MeshPoint);
        m_graph->seriesList().at(0)->dataProxy()->resetArray(dataArraySc);
    
    }
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.