Close the viewer window

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Close the viewer window

Dominique Vaufreydaz
Hello,

     Context : PCL 1.8 compile from source on a Linux debian.

     I search for a while, try several approaches (remove the shared ptr from boost,
     call .reset on the shared ptr, called close() on the viewer) found in the mailing-list
     archive for instance. Here is my last source code :

void Viewer(pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud, pcl::PointXYZRGB * minPt = nullptr,  pcl::PointXYZRGB * maxPt = nullptr  )
{
   pcl::visualization::PCLVisualizer viewer("3D Viewer");
   viewer.setBackgroundColor (0, 0, 0);
   pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> rgb(cloud);
   viewer.addPointCloud<pcl::PointXYZRGB> (cloud, rgb, "sample cloud");
   viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "sample cloud");
   viewer.addCoordinateSystem (1.0);
   viewer.initCameraParameters ();
   viewer.setCameraPosition( -2.3, 0.0, 0.0, -0.15, 0.0, 1.0 );

   if ( minPt != nullptr && maxPt != nullptr )
   {
     viewer.addCube(minPt->x, maxPt->x, minPt->y, maxPt->y, minPt->z, maxPt->z );
   }


while (!viewer.wasStopped ())
   {
     viewer.spinOnce(100);
     boost::this_thread::sleep (boost::posix_time::microseconds (100000));
   }

   viewer.close();

return;
}

     If I close the windows clicking on 'x', the window do not close.

     Thank you for your help.

     Best regards. Doms.
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Close the viewer window

Sérgio Agostinho
Hey, 

The first issue you described seems to be related to PCL oldest open bug :)

Now the part where closing the window clicking on 'x' and that not working is a new one for me. Which VTK version are you using?

Cheers

_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Close the viewer window

nenadpol
In reply to this post by Dominique Vaufreydaz
Hi,

This solution works on Windows

     HWND hWnd= (HWND)cloud_viewer_->getRenderWindow()->GetGenericWindowId();

      // Visualize the data
      while (!cloud_viewer_->wasStopped ())
      {
        cloud_viewer_->spinOnce ();
        boost::this_thread::sleep (boost::posix_time::microseconds (100));
      }

        DestroyWindow(hWnd);


cheers
Nenad
Reply | Threaded
Open this post in threaded view
|

Re: Close the viewer window

Dominique Vaufreydaz
In reply to this post by Sérgio Agostinho
Hello,

 > The first issue you described seems to be related to PCL oldest open bug
 > https://github.com/PointCloudLibrary/pcl/issues/172

     Ok.

 > Now the part where closing the window clicking on 'x' and that not working is a new one for me. Which VTK version are you using?

     My python test says it is VtK 5.8.0.

     Best regards.

_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Close the viewer window

Dominique Vaufreydaz
In reply to this post by nenadpol
Hello,

> This solution works on Windows
>
>       HWND hWnd=
> (HWND)cloud_viewer_->getRenderWindow()->GetGenericWindowId();
>
>        // Visualize the data
>        while (!cloud_viewer_->wasStopped ())
>        {
>          cloud_viewer_->spinOnce ();
>          boost::this_thread::sleep (boost::posix_time::microseconds (100));
>        }
>
> DestroyWindow(hWnd);

        I work a lot on Windows, but I like to use a common way to do it
        under Linux/Ma OSX also.

        Thank you for your answer.

        Best regards. Doms.

_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Close the viewer window

nenadpol
Hi,

Did you try this solution on Linux/Ma OSX ?
Reply | Threaded
Open this post in threaded view
|

Re: Close the viewer window

Dominique Vaufreydaz
Hello,

> Did you try this solution on Linux/Ma OSX ?

        It is not mandaoty, these is no HWND under these environment. This code is windows
        specific.

        Best regards. Doms.

_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Close the viewer window

VictorLamoine
Administrator
Please post a message on the VTK bug tracker:
http://www.vtk.org/Bug/view.php?id=14985

The more the messages.. the more likely this bug will bring attention!