When I use both PCL and QVTKOpenGLNativeWidget
Three-party library. When I change the color of the point cloud, the point cloud is not updated, and I need to click the mouse to update it My code:
m_LidarWidget = new QVTKOpenGLNativeWidget;
/*m_PtrQVtkWindow = new QVTKWindow(this, this);*/
m_dockMain->setWidget(m_LidarWidget);
renderer2 = vtkSmartPointer<vtkRenderer>::New();
renderWindow2 = vtkSmartPointer<vtkGenericOpenGLRenderWindow>::New();
renderWindow2->AddRenderer(renderer2);
viewer.reset(new pcl::visualization::PCLVisualizer(renderer2, renderWindow2, "viewer", false));
m_Cloud.reset(new pcl::PointCloudpcl::PointXYZ);
pcl::PolygonMesh meshData;//读取原始数据
pcl::io::loadPolygonFile(lidarFile.toStdString(), meshData);
pcl::fromPCLPointCloud2(meshData.cloud, *m_Cloud);//将obj数据转换为点云数据
viewer->setBackgroundColor(0, 0, 0); //设置背景
// viewer->addCoordinateSystem (15.0); //设置坐标系
pcl::visualization::PointCloudColorHandlerGenericField<pcl::PointXYZ> fildColor(m_Cloud, "z");
viewer->addPointCloud<pcl::PointXYZ>(m_Cloud, fildColor, "cloud");
viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "cloud");
viewer->resetCamera();
m_LidarWidget->update();
(2)When i change the color:
if (color.isValid() && viewer)
{
viewer->setBackgroundColor(color.redF(), color.greenF(), color.blueF());
m_LidarWidget->update();
}