Q3DScatter --> How to add a point with a different color to a point cloud

前端 未结 1 1995
一个人的身影
一个人的身影 2021-01-27 00:46

I wrote a program in Qt, which visualizes a processed pointcloud (3D-points) by using Q3DScatter. Now I want to add calculated keypoints with a different color. Is that possibl

相关标签:
1条回答
  • 2021-01-27 00:53

    You can only set a color/gradient for a whole point list:

    Q3DScatter scatter;
    scatter.setFlags(scatter.flags() ^ Qt::FramelessWindowHint);
    
    scatter.addSeries(new QScatter3DSeries);
    scatter.addSeries(new QScatter3DSeries);
    
    {
        QScatterDataArray *data = new QScatterDataArray;
        *data << QVector3D(0.5f, 0.5f, 0.5f) << QVector3D(-0.3f, -0.5f, -0.4f) << QVector3D(0.0f, -0.3f, 0.2f);
    
        scatter.seriesList().at(0)->dataProxy()->resetArray(data);
    
        QLinearGradient linearGrad(QPointF(100, 100), QPointF(200, 200));
        linearGrad.setColorAt(0, Qt::blue);
        linearGrad.setColorAt(1, Qt::red);
    
        scatter.seriesList().at(0)->setBaseGradient(linearGrad);
        scatter.seriesList().at(0)->setColorStyle(Q3DTheme::ColorStyle::ColorStyleObjectGradient);
    }
    
    {
        QScatterDataArray *data = new QScatterDataArray;
        *data << QVector3D(0.f, 0.f, 0.f);
    
        scatter.seriesList().at(1)->dataProxy()->resetArray(data);
        scatter.seriesList().at(1)->setBaseColor(Qt::green);
    }
    
    scatter.show();
    
    0 讨论(0)
提交回复
热议问题