normals_item.cpp
Go to the documentation of this file.
00001 #include <pcl/apps/cloud_composer/qt.h>
00002 #include <pcl/apps/cloud_composer/items/normals_item.h>
00003 #include <pcl/apps/cloud_composer/items/cloud_item.h>
00004 
00005 
00006 pcl::cloud_composer::NormalsItem::NormalsItem (QString name, pcl::PointCloud<pcl::Normal>::Ptr normals_ptr, double radius)
00007   : CloudComposerItem (name)
00008   , normals_ptr_ (normals_ptr)
00009 
00010 {
00011   pcl::PointCloud<pcl::Normal>::ConstPtr normals_const = normals_ptr;
00012   this->setData (QVariant::fromValue (normals_const), ItemDataRole::CLOUD_TEMPLATED);
00013   properties_->addCategory ("Core Properties");
00014   properties_->addProperty ("Radius", QVariant (radius), Qt::ItemIsSelectable, "Core Properties");
00015   properties_->addCategory ("Display Variables");
00016   properties_->addProperty ("Scale", QVariant (0.02), Qt::ItemIsEditable | Qt::ItemIsEnabled, "Display Variables");
00017   properties_->addProperty ("Level", QVariant (100), Qt::ItemIsEditable | Qt::ItemIsEnabled, "Display Variables");
00018 }
00019 
00020 pcl::cloud_composer::NormalsItem*
00021 pcl::cloud_composer::NormalsItem::clone () const
00022 {
00023   pcl::PointCloud<pcl::Normal>::Ptr normals_copy (new pcl::PointCloud<pcl::Normal> (*normals_ptr_));
00024   //Vector4f and Quaternionf do deep copies using copy constructor
00025   NormalsItem* new_item = new NormalsItem (this->text (), normals_copy, 0);
00026   
00027   PropertiesModel* new_item_properties = new_item->getPropertiesModel ();
00028   new_item_properties->copyProperties (properties_);
00029   
00030   return new_item;  
00031 }
00032 
00033 pcl::cloud_composer::NormalsItem::~NormalsItem ()
00034 {
00035   
00036 }
00037 
00038 void
00039 pcl::cloud_composer::NormalsItem::paintView (boost::shared_ptr<pcl::visualization::PCLVisualizer> vis) const
00040 {
00041   //Get the parent cloud, convert to XYZ 
00042   if (parent ()->type () == CLOUD_ITEM)
00043   {
00044     QVariant cloud_ptr = parent ()->data (ItemDataRole::CLOUD_BLOB);
00045     pcl::PCLPointCloud2::ConstPtr cloud_blob = cloud_ptr.value<pcl::PCLPointCloud2::ConstPtr> ();
00046     pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
00047     pcl::fromPCLPointCloud2 (*cloud_blob, *cloud);
00048     double scale = properties_->getProperty ("Scale").toDouble ();
00049     int level = properties_->getProperty ("Level").toInt ();
00050     qDebug () << "Removing old normals...";
00051     vis->removePointCloud (getId ().toStdString ());
00052     qDebug () << QString("Adding point cloud normals, level=%1, scale=%2").arg(level).arg(scale);
00053     vis->addPointCloudNormals<pcl::PointXYZ, pcl::Normal> (cloud, normals_ptr_, level, scale, getId ().toStdString ());
00054     std::cout << cloud->points[0]<<std::endl;
00055     std::cout << normals_ptr_->points[0]<<std::endl;
00056     
00057   }
00058   else
00059     qWarning () << "Normal item inserted, but parent not a cloud. Don't know how to draw that!";
00060 }
00061 
00062 void
00063 pcl::cloud_composer::NormalsItem::removeFromView (boost::shared_ptr<pcl::visualization::PCLVisualizer> vis) const
00064 {  
00065   //qDebug () << "Removing Normals "<<item_id_;
00066   vis->removePointCloud (getId ().toStdString ());
00067 }


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:26:09