I am trying to use the PCL Visializer as it is inside an MFC CStatic control :
pcl::visualization::PCLVisualizer::Ptr simpleVis(pcl::PointCloud<pcl::PointXYZ>::ConstPtr cloud , HWND hParent_display )
{
// --------------------------------------------
// -----Open 3D viewer and add point cloud-----
// --------------------------------------------
pcl::visualization::PCLVisualizer::Ptr viewer(new pcl::visualization::PCLVisualizer("3D Viewer"));
if (hParent_display) {
SetParent((HWND)viewer->getRenderWindow()->GetGenericWindowId(), hParent_display);
viewer->setWindowBorders(false);
viewer->getRenderWindow()->SetParentId(hParent_display);
//viewer->setPosition(-10, -50); // Hacky way to hide the window borders
viewer->setBackgroundColor(0, 0, 0);
viewer->addPointCloud<pcl::PointXYZ>(cloud, "sample cloud");
viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "sample cloud");
viewer->addCoordinateSystem(1.0);
viewer->initCameraParameters();
}
return (viewer);
}
I call the above function in MFC OnInitDialog()
like this :
viewer = simpleVis(basic_cloud_ptr , GetDlgItem(IDC_STATIC_3D_VIWER)->m_hWnd);
and this is the result :
As you can see the child window title bar is visible and the user can move it using a mouse.
viewer->setWindowBorders(false);
didn't work.
Using viewer->setPosition(-10, -50);
hides the title bar but I am not sure if this is the proper way to achieve that.
Is there a better way to integrate the Visualizer?
Update :
This is what worked :
pcl::visualization::PCLVisualizer::Ptr simpleVis(pcl::PointCloud<pcl::PointXYZ>::ConstPtr cloud , HWND hParent_display ,int width , int height)
{
// --------------------------------------------
// -----Open 3D viewer and add point cloud-----
// --------------------------------------------
pcl::visualization::PCLVisualizer::Ptr viewer(new pcl::visualization::PCLVisualizer("3D Viewer"));
if (hParent_display) {
viewer->setWindowBorders(false);
//viewer->getRenderWindow()->SetParentId(hParent_display);
SetParent((HWND)viewer->getRenderWindow()->GetGenericWindowId(), hParent_display);
SetWindowLongPtr((HWND)viewer->getRenderWindow()->GetGenericWindowId(), GWL_STYLE, WS_POPUP);
SetWindowPos((HWND)viewer->getRenderWindow()->GetGenericWindowId(), HWND_TOPMOST, 0, 0, width, height, SWP_SHOWWINDOW);
ShowWindow((HWND)viewer->getRenderWindow()->GetGenericWindowId(), SW_SHOW);
viewer->setBackgroundColor(0, 0, 0);
//viewer->addPointCloud<pcl::PointXYZ>(cloud, "sample cloud");
//viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "sample cloud");
viewer->addCoordinateSystem(1.0);
viewer->initCameraParameters();
}
return (viewer);
}
I am not sure what your viewer->setWindowBorders(false);
does.
I would use plain Win32 API to remove the title bar.
Please note that you would need to redraw that window frame after the style is modified:
SetWindowPos(hwnd,0,0,0,0,0,SWP_DRAWFRAME|SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);