31 #include <rtabmap/core/Version.h> 39 #include <pcl/visualization/pcl_visualizer.h> 40 #include <pcl/common/transforms.h> 43 #include <QtGui/QContextMenuEvent> 44 #include <QInputDialog> 45 #include <QtGui/QWheelEvent> 46 #include <QtGui/QKeyEvent> 47 #include <QColorDialog> 48 #include <QtGui/QVector3D> 49 #include <QMainWindow> 52 #include <vtkCamera.h> 53 #include <vtkRenderWindow.h> 54 #include <vtkCubeSource.h> 55 #include <vtkGlyph3D.h> 56 #include <vtkGlyph3DMapper.h> 57 #include <vtkSmartVolumeMapper.h> 58 #include <vtkVolumeProperty.h> 59 #include <vtkColorTransferFunction.h> 60 #include <vtkPiecewiseFunction.h> 61 #include <vtkImageData.h> 62 #include <vtkLookupTable.h> 63 #include <vtkTextureUnitManager.h> 64 #include <vtkJPEGReader.h> 65 #include <vtkBMPReader.h> 66 #include <vtkPNMReader.h> 67 #include <vtkPNGReader.h> 68 #include <vtkTIFFReader.h> 69 #include <vtkOpenGLRenderWindow.h> 70 #include <vtkPointPicker.h> 71 #include <vtkTextActor.h> 72 #include <vtkTexture.h> 73 #include <vtkOBBTree.h> 74 #include <vtkObjectFactory.h> 78 #if VTK_MAJOR_VERSION >= 7 79 #include <vtkEDLShading.h> 80 #include <vtkRenderStepsPass.h> 81 #include <vtkOpenGLRenderer.h> 84 #ifdef RTABMAP_OCTOMAP 98 _aSetTrajectorySize(0),
102 _aSetFrustumScale(0),
103 _aSetFrustumColor(0),
105 _aSetGridCellCount(0),
106 _aSetGridCellSize(0),
109 _aSetNormalsScale(0),
110 _aSetBackgroundColor(0),
111 _aSetRenderingRate(0),
115 _aSetEdgeVisibility(0),
116 _aBackfaceCulling(0),
118 _trajectory(new
pcl::PointCloud<
pcl::PointXYZ>),
119 _maxTrajectorySize(100),
121 _frustumColor(Qt::gray),
126 _buildLocator(
false),
127 _lastCameraOrientation(0,0,0),
128 _lastCameraPose(0,0,0),
129 _defaultBgColor(Qt::black),
130 _currentBgColor(Qt::black),
131 _frontfaceCulling(
false),
134 _intensityAbsMax(0.0
f),
135 _coordinateFrameScale(1.0)
138 this->setMinimumSize(200, 200);
139 #if VTK_MAJOR_VERSION >= 8 140 vtkObject::GlobalWarningDisplayOff();
146 style->AutoAdjustCameraClippingRangeOff();
147 _visualizer =
new pcl::visualization::PCLVisualizer(
158 _visualizer->createViewPort (0,0,1.0, 1.0, viewport);
159 _visualizer->createViewPort (0,0,1.0, 1.0, viewport);
160 _visualizer->createViewPort (0,0,1.0, 1.0, viewport);
161 _visualizer->getRendererCollection()->InitTraversal ();
162 vtkRenderer* renderer =
NULL;
164 while ((renderer =
_visualizer->getRendererCollection()->GetNextItem ()) !=
NULL)
166 renderer->SetLayer(i);
169 #if VTK_MAJOR_VERSION >= 7 170 renderer->PreserveColorBufferOff();
172 renderer->PreserveDepthBufferOff();
173 _visualizer->getInteractorStyle()->SetDefaultRenderer(renderer);
177 #if VTK_MAJOR_VERSION >= 7 178 renderer->PreserveColorBufferOn();
180 renderer->PreserveDepthBufferOn();
184 _visualizer->getRenderWindow()->SetNumberOfLayers(4);
186 this->SetRenderWindow(
_visualizer->getRenderWindow());
191 this->GetInteractor()->SetInteractorStyle (
_visualizer->getInteractorStyle());
194 UDEBUG(
"pick tolerance=%f", pp->GetTolerance());
195 pp->SetTolerance (pp->GetTolerance()/2.0);
196 this->GetInteractor()->SetPicker (pp);
212 setMouseTracking(
false);
254 QAction * freeCamera =
new QAction(
"Free",
this);
255 freeCamera->setCheckable(
true);
256 freeCamera->setChecked(
false);
299 #if VTK_MAJOR_VERSION < 7 318 QMenu * cameraMenu =
new QMenu(
"Camera",
this);
321 cameraMenu->addAction(freeCamera);
322 cameraMenu->addSeparator();
326 QActionGroup * group =
new QActionGroup(
this);
329 group->addAction(freeCamera);
331 QMenu * trajectoryMenu =
new QMenu(
"Trajectory",
this);
336 QMenu * frustumMenu =
new QMenu(
"Frustum",
this);
341 QMenu * gridMenu =
new QMenu(
"Grid",
this);
346 QMenu * normalsMenu =
new QMenu(
"Normals",
this);
351 QMenu * scanMenu =
new QMenu(
"Scan color",
this);
357 _menu =
new QMenu(
this);
358 _menu->addMenu(cameraMenu);
359 _menu->addMenu(trajectoryMenu);
362 _menu->addMenu(frustumMenu);
363 _menu->addMenu(gridMenu);
364 _menu->addMenu(normalsMenu);
365 _menu->addMenu(scanMenu);
380 settings.beginGroup(group);
383 float poseX, poseY, poseZ, focalX, focalY, focalZ, upX, upY, upZ;
384 this->
getCameraPosition(poseX, poseY, poseZ, focalX, focalY, focalZ, upX, upY, upZ);
385 QVector3D pose(poseX, poseY, poseZ);
386 QVector3D focal(focalX, focalY, focalZ);
395 Transform F(focalX, focalY, focalZ, 0,0,0);
399 pose = QVector3D(newPose.
x(), newPose.
y(), newPose.
z());
400 focal = QVector3D(newFocal.
x(), newFocal.
y(), newFocal.
z());
402 settings.setValue(
"camera_pose", pose);
403 settings.setValue(
"camera_focal", focal);
404 settings.setValue(
"camera_up", QVector3D(upX, upY, upZ));
445 settings.beginGroup(group);
448 float poseX, poseY, poseZ, focalX, focalY, focalZ, upX, upY, upZ;
449 this->
getCameraPosition(poseX, poseY, poseZ, focalX, focalY, focalZ, upX, upY, upZ);
450 QVector3D pose(poseX, poseY, poseZ), focal(focalX, focalY, focalZ), up(upX, upY, upZ);
451 pose = settings.value(
"camera_pose", pose).value<QVector3D>();
452 focal = settings.value(
"camera_focal", focal).value<QVector3D>();
453 up = settings.value(
"camera_up", up).value<QVector3D>();
455 this->
setCameraPosition(pose.x(),pose.y(),pose.z(), focal.x(),focal.y(),focal.z(), up.x(),up.y(),up.z());
457 this->
setGridShown(settings.value(
"grid", this->isGridShown()).toBool());
458 this->
setGridCellCount(settings.value(
"grid_cell_count", this->getGridCellCount()).toUInt());
459 this->
setGridCellSize(settings.value(
"grid_cell_size", this->getGridCellSize()).toFloat());
461 this->
setNormalsShown(settings.value(
"normals", this->isNormalsShown()).toBool());
462 this->
setNormalsStep(settings.value(
"normals_step", this->getNormalsStep()).toInt());
463 this->
setNormalsScale(settings.value(
"normals_scale", this->getNormalsScale()).toFloat());
465 this->
setIntensityRedColormap(settings.value(
"intensity_red_colormap", this->isIntensityRedColormap()).toBool());
467 this->
setIntensityMax(settings.value(
"intensity_max", this->getIntensityMax()).toFloat());
469 this->
setTrajectoryShown(settings.value(
"trajectory_shown", this->isTrajectoryShown()).toBool());
470 this->
setTrajectorySize(settings.value(
"trajectory_size", this->getTrajectorySize()).toUInt());
472 this->
setCameraAxisShown(settings.value(
"camera_axis_shown", this->isCameraAxisShown()).toBool());
473 this->
setCoordinateFrameScale(settings.value(
"coordinate_frame_scale", this->getCoordinateFrameScale()).toDouble());
475 this->
setFrustumShown(settings.value(
"frustum_shown", this->isFrustumShown()).toBool());
476 this->
setFrustumScale(settings.value(
"frustum_scale", this->getFrustumScale()).toDouble());
477 this->
setFrustumColor(settings.value(
"frustum_color", this->getFrustumColor()).value<QColor>());
479 this->
setCameraTargetLocked(settings.value(
"camera_target_locked", this->isCameraTargetLocked()).toBool());
480 this->
setCameraTargetFollow(settings.value(
"camera_target_follow", this->isCameraTargetFollow()).toBool());
481 if(settings.value(
"camera_free", this->isCameraFree()).toBool())
485 this->
setCameraLockZ(settings.value(
"camera_lockZ", this->isCameraLockZ()).toBool());
489 this->
setRenderingRate(settings.value(
"rendering_rate", this->getRenderingRate()).toDouble());
500 const std::string &
id,
507 Eigen::Affine3f posef = pose.
toEigen3f();
511 bool updated =
_visualizer->updatePointCloudPose(
id, posef);
513 #if VTK_MAJOR_VERSION >= 7 517 pcl::visualization::ShapeActorMap::iterator am_it =
_visualizer->getShapeActorMap()->find (
id);
519 if (am_it !=
_visualizer->getShapeActorMap()->end ())
521 actor = vtkActor::SafeDownCast (am_it->second);
525 pcl::visualization::PCLVisualizer::convertToVtkMatrix (pose.
toEigen3f().matrix (), matrix);
526 actor->SetUserMatrix (matrix);
537 std::string idNormals =
id+
"-normals";
540 _visualizer->updatePointCloudPose(idNormals, posef);
552 typedef pcl::visualization::PointCloudColorHandler<pcl::PCLPointCloud2>::PointCloud
PointCloud;
562 pcl::visualization::PointCloudColorHandler<
pcl::PCLPointCloud2>::PointCloudColorHandler (cloud),
563 maxAbsIntensity_(maxAbsIntensity),
566 field_idx_ = pcl::getFieldIndex (*cloud,
"intensity");
567 if (field_idx_ != -1)
581 #if PCL_VERSION_COMPARE(>, 1, 11, 1) 584 if (!capable_ || !cloud_)
588 if (!capable_ || !cloud_)
593 scalars->SetNumberOfComponents (3);
595 vtkIdType nr_points = cloud_->width * cloud_->height;
597 float * intensities =
new float[nr_points];
599 size_t point_offset = cloud_->fields[field_idx_].offset;
603 int x_idx = pcl::getFieldIndex (*cloud_,
"x");
606 float x_data, y_data, z_data;
607 size_t x_point_offset = cloud_->fields[x_idx].offset;
610 for (vtkIdType cp = 0; cp < nr_points; ++cp,
611 point_offset += cloud_->point_step,
612 x_point_offset += cloud_->point_step)
615 memcpy (&intensity, &cloud_->data[point_offset], sizeof (
float));
617 memcpy (&x_data, &cloud_->data[x_point_offset], sizeof (
float));
618 memcpy (&y_data, &cloud_->data[x_point_offset + sizeof (
float)],
sizeof (
float));
619 memcpy (&z_data, &cloud_->data[x_point_offset + 2 * sizeof (
float)],
sizeof (
float));
624 intensities[j++] = intensity;
631 for (vtkIdType cp = 0; cp < nr_points; ++cp, point_offset += cloud_->point_step)
634 memcpy (&intensity, &cloud_->data[point_offset], sizeof (
float));
636 intensities[j++] = intensity;
642 unsigned char* colors =
new unsigned char[j * 3];
644 if(maxAbsIntensity_>0.0
f)
646 max = maxAbsIntensity_;
650 uMinMax(intensities, j, min, max);
652 for(
size_t k=0; k<j; ++k)
654 colors[k*3+0] = colors[k*3+1] = colors[k*3+2] = max>0?(
unsigned char)(
std::min(intensities[k]/max*255.0
f, 255.0f)):255;
660 else if(colormap_ == 2)
664 colors[k*3+0] = r*255.0f;
665 colors[k*3+1] = g*255.0f;
666 colors[k*3+2] = b*255.0f;
669 reinterpret_cast<vtkUnsignedCharArray*
>(&(*scalars))->SetNumberOfTuples (j);
670 reinterpret_cast<vtkUnsignedCharArray*
>(&(*scalars))->SetArray (colors, j*3, 0, vtkUnsignedCharArray::VTK_DATA_ARRAY_DELETE);
673 reinterpret_cast<vtkUnsignedCharArray*
>(&(*scalars))->SetNumberOfTuples (0);
675 delete [] intensities;
676 #if PCL_VERSION_COMPARE(>, 1, 11, 1) 686 getName ()
const {
return (
"PointCloudColorHandlerIntensityField"); }
698 const std::string &
id,
699 const pcl::PCLPointCloud2Ptr & binaryCloud,
704 const QColor & color,
707 int previousColorIndex = -1;
710 previousColorIndex =
_visualizer->getColorHandlerIndex(
id);
714 Eigen::Vector4f origin(pose.
x(), pose.
y(), pose.
z(), 0.0f);
719 pcl::PointCloud<pcl::PointNormal>::Ptr cloud_xyz (
new pcl::PointCloud<pcl::PointNormal>);
720 pcl::fromPCLPointCloud2 (*binaryCloud, *cloud_xyz);
721 std::string idNormals =
id +
"-normals";
730 pcl::visualization::PointCloudColorHandler<pcl::PCLPointCloud2>::Ptr colorHandler;
731 colorHandler.reset (
new pcl::visualization::PointCloudColorHandlerRandom<pcl::PCLPointCloud2> (binaryCloud));
732 if(
_visualizer->addPointCloud (binaryCloud, colorHandler, origin, orientation,
id, viewport))
739 colorHandler.reset (
new pcl::visualization::PointCloudColorHandlerCustom<pcl::PCLPointCloud2> (binaryCloud, c.red(), c.green(), c.blue()));
740 _visualizer->addPointCloud (binaryCloud, colorHandler, origin, orientation,
id, viewport);
743 colorHandler.reset (
new pcl::visualization::PointCloudColorHandlerGenericField<pcl::PCLPointCloud2> (binaryCloud,
"x"));
744 _visualizer->addPointCloud (binaryCloud, colorHandler, origin, orientation,
id, viewport);
745 colorHandler.reset (
new pcl::visualization::PointCloudColorHandlerGenericField<pcl::PCLPointCloud2> (binaryCloud,
"y"));
746 _visualizer->addPointCloud (binaryCloud, colorHandler, origin, orientation,
id, viewport);
747 colorHandler.reset (
new pcl::visualization::PointCloudColorHandlerGenericField<pcl::PCLPointCloud2> (binaryCloud,
"z"));
748 _visualizer->addPointCloud (binaryCloud, colorHandler, origin, orientation,
id, viewport);
753 colorHandler.reset(
new pcl::visualization::PointCloudColorHandlerRGBField<pcl::PCLPointCloud2>(binaryCloud));
754 _visualizer->addPointCloud (binaryCloud, colorHandler, origin, orientation,
id, viewport);
756 else if(hasIntensity)
760 _visualizer->addPointCloud (binaryCloud, colorHandler, origin, orientation,
id, viewport);
762 else if(previousColorIndex == 5)
764 previousColorIndex = -1;
770 colorHandler.reset (
new pcl::visualization::PointCloudColorHandlerGenericField<pcl::PCLPointCloud2> (binaryCloud,
"normal_x"));
771 _visualizer->addPointCloud (binaryCloud, colorHandler, origin, orientation,
id, viewport);
772 colorHandler.reset (
new pcl::visualization::PointCloudColorHandlerGenericField<pcl::PCLPointCloud2> (binaryCloud,
"normal_y"));
773 _visualizer->addPointCloud (binaryCloud, colorHandler, origin, orientation,
id, viewport);
774 colorHandler.reset (
new pcl::visualization::PointCloudColorHandlerGenericField<pcl::PCLPointCloud2> (binaryCloud,
"normal_z"));
775 _visualizer->addPointCloud (binaryCloud, colorHandler, origin, orientation,
id, viewport);
777 else if(previousColorIndex > 5)
779 previousColorIndex = -1;
782 if(previousColorIndex>=0)
784 _visualizer->updateColorHandlerIndex(
id, previousColorIndex);
792 _visualizer->updateColorHandlerIndex(
id, hasIntensity?8:7);
794 else if(hasIntensity)
798 else if(color.isValid())
810 const std::string &
id,
811 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
813 const QColor & color)
815 pcl::PCLPointCloud2Ptr binaryCloud(
new pcl::PCLPointCloud2);
816 pcl::toPCLPointCloud2(*cloud, *binaryCloud);
817 return addCloud(
id, binaryCloud, pose,
true,
true,
false, color);
821 const std::string &
id,
822 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
824 const QColor & color)
826 pcl::PCLPointCloud2Ptr binaryCloud(
new pcl::PCLPointCloud2);
827 pcl::toPCLPointCloud2(*cloud, *binaryCloud);
828 return addCloud(
id, binaryCloud, pose,
true,
false,
false, color);
832 const std::string &
id,
833 const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
835 const QColor & color)
837 pcl::PCLPointCloud2Ptr binaryCloud(
new pcl::PCLPointCloud2);
838 pcl::toPCLPointCloud2(*cloud, *binaryCloud);
839 return addCloud(
id, binaryCloud, pose,
false,
true,
true, color);
843 const std::string &
id,
844 const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
846 const QColor & color)
848 pcl::PCLPointCloud2Ptr binaryCloud(
new pcl::PCLPointCloud2);
849 pcl::toPCLPointCloud2(*cloud, *binaryCloud);
850 return addCloud(
id, binaryCloud, pose,
false,
false,
true, color);
854 const std::string &
id,
855 const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
857 const QColor & color)
859 pcl::PCLPointCloud2Ptr binaryCloud(
new pcl::PCLPointCloud2);
860 pcl::toPCLPointCloud2(*cloud, *binaryCloud);
861 return addCloud(
id, binaryCloud, pose,
false,
true,
false, color);
865 const std::string &
id,
866 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
868 const QColor & color)
870 pcl::PCLPointCloud2Ptr binaryCloud(
new pcl::PCLPointCloud2);
871 pcl::toPCLPointCloud2(*cloud, *binaryCloud);
872 return addCloud(
id, binaryCloud, pose,
false,
false,
false, color);
876 const std::string &
id,
877 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
878 const std::vector<pcl::Vertices> & polygons,
886 UDEBUG(
"Adding %s with %d points and %d polygons",
id.c_str(), (
int)cloud->size(), (int)polygons.size());
887 if(
_visualizer->addPolygonMesh<pcl::PointXYZ>(cloud, polygons,
id, 1))
889 #if VTK_MAJOR_VERSION >= 7 890 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetAmbient(0.1);
892 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetAmbient(0.5);
895 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetInterpolation(
_aSetFlatShading->isChecked()?VTK_FLAT:VTK_PHONG);
903 tree->SetDataSet(
_visualizer->getCloudActorMap()->find(
id)->second.actor->GetMapper()->GetInput());
904 tree->BuildLocator();
905 _locators.insert(std::make_pair(
id, tree));
914 const std::string &
id,
915 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
916 const std::vector<pcl::Vertices> & polygons,
924 UDEBUG(
"Adding %s with %d points and %d polygons",
id.c_str(), (
int)cloud->size(), (int)polygons.size());
925 if(
_visualizer->addPolygonMesh<pcl::PointXYZRGB>(cloud, polygons,
id, 1))
927 #if VTK_MAJOR_VERSION >= 7 928 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetAmbient(0.1);
930 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetAmbient(0.5);
933 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetInterpolation(
_aSetFlatShading->isChecked()?VTK_FLAT:VTK_PHONG);
941 tree->SetDataSet(
_visualizer->getCloudActorMap()->find(
id)->second.actor->GetMapper()->GetInput());
942 tree->BuildLocator();
943 _locators.insert(std::make_pair(
id, tree));
952 const std::string &
id,
953 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
954 const std::vector<pcl::Vertices> & polygons,
962 UDEBUG(
"Adding %s with %d points and %d polygons",
id.c_str(), (
int)cloud->size(), (int)polygons.size());
963 if(
_visualizer->addPolygonMesh<pcl::PointXYZRGBNormal>(cloud, polygons,
id, 1))
965 #if VTK_MAJOR_VERSION >= 7 966 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetAmbient(0.1);
968 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetAmbient(0.5);
971 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetInterpolation(
_aSetFlatShading->isChecked()?VTK_FLAT:VTK_PHONG);
979 tree->SetDataSet(
_visualizer->getCloudActorMap()->find(
id)->second.actor->GetMapper()->GetInput());
980 tree->BuildLocator();
981 _locators.insert(std::make_pair(
id, tree));
990 const std::string &
id,
991 const pcl::PolygonMesh::Ptr & mesh,
999 UDEBUG(
"Adding %s with %d polygons",
id.c_str(), (
int)mesh->polygons.size());
1002 #if VTK_MAJOR_VERSION >= 7 1003 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetAmbient(0.1);
1005 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetAmbient(0.5);
1015 tree->SetDataSet(
_visualizer->getCloudActorMap()->find(
id)->second.actor->GetMapper()->GetInput());
1016 tree->BuildLocator();
1017 _locators.insert(std::make_pair(
id, tree));
1027 const std::string &
id,
1028 const pcl::TextureMesh::Ptr & textureMesh,
1029 const cv::Mat & texture,
1037 UDEBUG(
"Adding %s",
id.c_str());
1040 #if VTK_MAJOR_VERSION >= 7 1041 vtkActor* actor = vtkActor::SafeDownCast (
_visualizer->getShapeActorMap()->find(
id)->second);
1043 vtkActor* actor = vtkActor::SafeDownCast (
_visualizer->getCloudActorMap()->find(
id)->second.actor);
1046 if(!textureMesh->cloud.is_dense)
1048 actor->GetTexture()->SetInterpolate(1);
1049 actor->GetTexture()->SetBlendingMode(vtkTexture::VTK_TEXTURE_BLENDING_MODE_REPLACE);
1054 tree->SetDataSet(actor->GetMapper()->GetInput());
1055 tree->BuildLocator();
1056 _locators.insert(std::make_pair(
id, tree));
1068 #ifdef RTABMAP_OCTOMAP 1071 pcl::IndicesPtr obstacles(
new std::vector<int>);
1077 UWARN(
"Tree depth requested (%d) is deeper than the " 1078 "actual maximum tree depth of %d. Using maximum depth.",
1086 if(!volumeRepresentation)
1088 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud = octomap->
createCloud(treeDepth, obstacles.get(), 0, 0,
false);
1089 if(obstacles->size())
1095 colors->SetName(
"colors");
1096 colors->SetNumberOfValues(obstacles->size());
1099 lut->SetNumberOfTableValues(obstacles->size());
1104 points->SetNumberOfPoints(obstacles->size());
1106 for (
unsigned int i = 0; i < obstacles->size(); i++)
1108 points->InsertPoint(i,
1109 cloud->at(obstacles->at(i)).x,
1110 cloud->at(obstacles->at(i)).y,
1111 cloud->at(obstacles->at(i)).z);
1112 colors->InsertValue(i,i);
1114 lut->SetTableValue(i,
1115 double(cloud->at(obstacles->at(i)).r) / 255.0,
1116 double(cloud->at(obstacles->at(i)).g) / 255.0,
1117 double(cloud->at(obstacles->at(i)).b) / 255.0);
1122 polydata->SetPoints(points);
1123 polydata->GetPointData()->SetScalars(colors);
1127 cubeSource->SetBounds(-s, s, -s, s, -s, s);
1130 mapper->SetSourceConnection(cubeSource->GetOutputPort());
1131 #if VTK_MAJOR_VERSION <= 5 1132 mapper->SetInputConnection(polydata->GetProducerPort());
1134 mapper->SetInputData(polydata);
1136 mapper->SetScalarRange(0, obstacles->size() - 1);
1137 mapper->SetLookupTable(lut);
1138 mapper->ScalingOff();
1142 octomapActor->SetMapper(mapper);
1144 octomapActor->GetProperty()->SetRepresentationToSurface();
1146 octomapActor->GetProperty()->SetLighting(
_aSetLighting->isChecked());
1148 _visualizer->getRendererCollection()->InitTraversal ();
1149 vtkRenderer* renderer =
NULL;
1150 renderer =
_visualizer->getRendererCollection()->GetNextItem ();
1151 renderer =
_visualizer->getRendererCollection()->GetNextItem ();
1153 renderer->AddActor(octomapActor);
1167 double sizeX, sizeY, sizeZ;
1168 double minX, minY, minZ;
1169 double maxX, maxY, maxZ;
1179 imageData->SetExtent(0,
int(sizeX/cellSize+0.5), 0,
int(sizeY/cellSize+0.5), 0,
int(sizeZ/cellSize+0.5));
1180 #if VTK_MAJOR_VERSION <= 5 1181 imageData->SetNumberOfScalarComponents(4);
1182 imageData->SetScalarTypeToUnsignedChar();
1184 imageData->AllocateScalars(VTK_UNSIGNED_CHAR,4);
1188 imageData->GetDimensions(dims);
1190 memset(imageData->GetScalarPointer(), 0, imageData->GetScalarSize()*imageData->GetNumberOfScalarComponents()*dims[0]*dims[1]*dims[2]);
1194 if(octomap->
octree()->isNodeOccupied(*it))
1197 int x = (pt.
x()-minX) / cellSize;
1198 int y = (pt.
y()-minY) / cellSize;
1199 int z = (pt.
z()-minZ) / cellSize;
1200 if(x>=0 && x<dims[0] && y>=0 && y<dims[1] && z>=0 && z<dims[2])
1202 unsigned char* pixel =
static_cast<unsigned char*
>(imageData->GetScalarPointer(x,y,z));
1205 pixel[0] = it->getColor().r;
1206 pixel[1] = it->getColor().g;
1207 pixel[2] = it->getColor().b;
1212 float H = (maxZ - pt.
z())*299.0
f/(maxZ-minZ);
1215 pixel[0] = r*255.0f;
1216 pixel[1] = g*255.0f;
1217 pixel[2] = b*255.0f;
1225 volumeMapper->SetBlendModeToComposite();
1226 #if VTK_MAJOR_VERSION <= 5 1227 volumeMapper->SetInputConnection(imageData->GetProducerPort());
1229 volumeMapper->SetInputData(imageData);
1233 volumeProperty->ShadeOff();
1234 volumeProperty->IndependentComponentsOff();
1238 compositeOpacity->AddPoint(0.0,0.0);
1239 compositeOpacity->AddPoint(255.0,1.0);
1240 volumeProperty->SetScalarOpacity(0, compositeOpacity);
1244 volume->SetMapper(volumeMapper);
1245 volume->SetProperty(volumeProperty);
1246 volume->SetScale(cellSize);
1247 volume->SetPosition(minX, minY, minZ);
1249 _visualizer->getRendererCollection()->InitTraversal ();
1250 vtkRenderer* renderer =
NULL;
1251 renderer =
_visualizer->getRendererCollection()->GetNextItem ();
1252 renderer =
_visualizer->getRendererCollection()->GetNextItem ();
1254 renderer->AddViewProp(volume);
1257 #if !defined(VTK_LEGACY_REMOVE) && !defined(VTK_OPENGL2) 1258 volumeMapper->SetRequestedRenderModeToRayCastAndTexture();
1259 #endif // VTK_LEGACY_REMOVE 1263 volumeMapper->SetRequestedRenderModeToRayCast();
1276 #ifdef RTABMAP_OCTOMAP 1279 _visualizer->getRendererCollection()->InitTraversal ();
1280 vtkRenderer* renderer =
NULL;
1281 renderer =
_visualizer->getRendererCollection()->GetNextItem ();
1282 renderer =
_visualizer->getRendererCollection()->GetNextItem ();
1291 const pcl::TextureMesh &mesh,
1292 const cv::Mat & image,
1293 const std::string &
id,
1298 #if VTK_MAJOR_VERSION >= 7 1299 pcl::visualization::ShapeActorMap::iterator am_it =
_visualizer->getShapeActorMap()->find (
id);
1300 if (am_it !=
_visualizer->getShapeActorMap()->end ())
1302 pcl::visualization::CloudActorMap::iterator am_it =
_visualizer->getCloudActorMap()->find (
id);
1303 if (am_it !=
_visualizer->getCloudActorMap()->end ())
1306 PCL_ERROR (
"[PCLVisualizer::addTextureMesh] A shape with id <%s> already exists!" 1307 " Please choose a different id and retry.\n",
1312 if (mesh.tex_materials.size () == 0)
1314 PCL_ERROR(
"[PCLVisualizer::addTextureMesh] No textures found!\n");
1317 else if (mesh.tex_materials.size() > 1)
1319 PCL_ERROR(
"[PCLVisualizer::addTextureMesh] only one material per mesh is supported!\n");
1323 if (mesh.tex_materials.size () != mesh.tex_polygons.size ())
1325 PCL_ERROR(
"[PCLVisualizer::addTextureMesh] Materials number %lu differs from polygons number %lu!\n",
1326 mesh.tex_materials.size (), mesh.tex_polygons.size ());
1330 if (mesh.tex_materials.size () != mesh.tex_coordinates.size ())
1332 PCL_ERROR(
"[PCLVisualizer::addTextureMesh] Coordinates number %lu differs from materials number %lu!\n",
1333 mesh.tex_coordinates.size (), mesh.tex_materials.size ());
1337 std::size_t nb_vertices = 0;
1338 for (std::size_t i = 0; i < mesh.tex_polygons.size (); ++i)
1339 nb_vertices+= mesh.tex_polygons[i].size ();
1341 if (nb_vertices == 0)
1343 PCL_ERROR(
"[PCLVisualizer::addTextureMesh] No vertices found!\n");
1347 std::size_t nb_coordinates = 0;
1348 for (std::size_t i = 0; i < mesh.tex_coordinates.size (); ++i)
1349 nb_coordinates+= mesh.tex_coordinates[i].size ();
1351 if (nb_coordinates == 0)
1353 PCL_ERROR(
"[PCLVisualizer::addTextureMesh] No textures coordinates found!\n");
1360 bool has_color =
false;
1363 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (
new pcl::PointCloud<pcl::PointXYZ> ());
1364 pcl::fromPCLPointCloud2 (mesh.cloud, *cloud);
1366 if (cloud->points.size () == 0)
1368 PCL_ERROR(
"[PCLVisualizer::addTextureMesh] Cloud is empty!\n");
1371 pcl::visualization::PCLVisualizer::convertToVtkMatrix (cloud->sensor_origin_, cloud->sensor_orientation_, transformation);
1372 poly_points->SetNumberOfPoints (cloud->points.size ());
1373 for (std::size_t i = 0; i < cloud->points.size (); ++i)
1375 const pcl::PointXYZ &p = cloud->points[i];
1376 poly_points->InsertPoint (i, p.x, p.y, p.z);
1381 for (std::size_t i = 0; i < mesh.tex_polygons.size (); i++)
1383 for (std::size_t j = 0; j < mesh.tex_polygons[i].size (); j++)
1385 std::size_t n_points = mesh.tex_polygons[i][j].vertices.size ();
1386 polys->InsertNextCell (
int (n_points));
1387 for (std::size_t k = 0; k < n_points; k++)
1388 polys->InsertCellPoint (mesh.tex_polygons[i][j].vertices[k]);
1393 polydata->SetPolys (polys);
1394 polydata->SetPoints (poly_points);
1396 polydata->GetPointData()->SetScalars(colors);
1399 #if VTK_MAJOR_VERSION < 6 1400 mapper->SetInput (polydata);
1402 mapper->SetInputData (polydata);
1405 #if VTK_MAJOR_VERSION >= 7 1410 vtkTextureUnitManager* tex_manager = vtkOpenGLRenderWindow::SafeDownCast (
_visualizer->getRenderWindow())->GetTextureUnitManager ();
1417 cvImageToVtk->SetImage(image);
1418 cvImageToVtk->Update();
1419 texture->SetInputConnection(cvImageToVtk->GetOutputPort());
1423 coordinates->SetNumberOfComponents (2);
1424 coordinates->SetNumberOfTuples (mesh.tex_coordinates[0].size ());
1425 for (std::size_t tc = 0; tc < mesh.tex_coordinates[0].size (); ++tc)
1427 const Eigen::Vector2f &uv = mesh.tex_coordinates[0][tc];
1428 coordinates->SetTuple2 (tc, (
double)uv[0], (
double)uv[1]);
1430 coordinates->SetName (
"TCoords");
1431 polydata->GetPointData ()->SetTCoords(coordinates);
1433 actor->SetTexture (texture);
1436 actor->SetMapper (mapper);
1440 _visualizer->getRendererCollection()->InitTraversal ();
1441 vtkRenderer* renderer =
NULL;
1443 while ((renderer =
_visualizer->getRendererCollection()->GetNextItem ()) !=
NULL)
1448 renderer->AddActor (actor);
1450 else if (viewport == i)
1452 renderer->AddActor (actor);
1458 #if VTK_MAJOR_VERSION >= 7 1461 (*
_visualizer->getCloudActorMap())[
id].actor = actor;
1463 (*
_visualizer->getCloudActorMap())[
id].viewpoint_transformation_ = transformation;
1466 #if VTK_MAJOR_VERSION >= 7 1467 actor->GetProperty()->SetAmbient(0.1);
1469 actor->GetProperty()->SetAmbient(0.5);
1471 actor->GetProperty()->SetLighting(
_aSetLighting->isChecked());
1472 actor->GetProperty()->SetInterpolation(
_aSetFlatShading->isChecked()?VTK_FLAT:VTK_PHONG);
1480 const cv::Mat & map8U,
1486 UASSERT(map8U.channels() == 1 && map8U.type() == CV_8U);
1488 float xSize = float(map8U.cols) * resolution;
1489 float ySize = float(map8U.rows) * resolution;
1491 UDEBUG(
"resolution=%f, xSize=%f, ySize=%f, xMin=%f, yMin=%f", resolution, xSize, ySize, xMin, yMin);
1492 #if VTK_MAJOR_VERSION >= 7 1504 if(xSize > 0.0
f && ySize > 0.0
f)
1506 pcl::TextureMeshPtr mesh(
new pcl::TextureMesh());
1507 pcl::PointCloud<pcl::PointXYZ> cloud;
1508 cloud.push_back(pcl::PointXYZ(xMin, yMin, 0));
1509 cloud.push_back(pcl::PointXYZ(xSize+xMin, yMin, 0));
1510 cloud.push_back(pcl::PointXYZ(xSize+xMin, ySize+yMin, 0));
1511 cloud.push_back(pcl::PointXYZ(xMin, ySize+yMin, 0));
1512 pcl::toPCLPointCloud2(cloud, mesh->cloud);
1514 std::vector<pcl::Vertices> polygons(1);
1515 polygons[0].vertices.push_back(0);
1516 polygons[0].vertices.push_back(1);
1517 polygons[0].vertices.push_back(2);
1518 polygons[0].vertices.push_back(3);
1519 polygons[0].vertices.push_back(0);
1520 mesh->tex_polygons.push_back(polygons);
1524 material.tex_file =
"";
1525 mesh->tex_materials.push_back(material);
1527 #if PCL_VERSION_COMPARE(>=, 1, 8, 0) 1528 std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > coordinates;
1530 std::vector<Eigen::Vector2f> coordinates;
1532 coordinates.push_back(Eigen::Vector2f(0,1));
1533 coordinates.push_back(Eigen::Vector2f(1,1));
1534 coordinates.push_back(Eigen::Vector2f(1,0));
1535 coordinates.push_back(Eigen::Vector2f(0,0));
1536 mesh->tex_coordinates.push_back(coordinates);
1546 #if VTK_MAJOR_VERSION >= 7 1560 const std::string &
id,
1567 UERROR(
"id should not be empty!");
1576 #if PCL_VERSION_COMPARE(>=, 1, 7, 2) 1586 const std::string &
id,
1589 #if PCL_VERSION_COMPARE(>=, 1, 7, 2) 1596 UERROR(
"CloudViewer::updateCoordinatePose() is not available on PCL < 1.7.2");
1605 UERROR(
"id should not be empty!");
1611 #if PCL_VERSION_COMPARE(>=, 1, 7, 2) 1624 for(std::set<std::string>::iterator iter = coordinates.begin(); iter!=coordinates.end(); ++iter)
1626 if(prefix.empty() || iter->find(prefix) != std::string::npos)
1635 const std::string &
id,
1638 const QColor & color,
1644 UERROR(
"id should not be empty!");
1654 QColor c = Qt::gray;
1660 pcl::PointXYZ pt1(from.
x(), from.
y(), from.
z());
1661 pcl::PointXYZ pt2(to.
x(), to.
y(), to.
z());
1665 _visualizer->addArrow(pt2, pt1, c.redF(), c.greenF(), c.blueF(),
false, id, foreground?3:2);
1669 _visualizer->addLine(pt2, pt1, c.redF(), c.greenF(), c.blueF(), id, foreground?3:2);
1671 _visualizer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_OPACITY, c.alphaF(), id);
1679 UERROR(
"id should not be empty!");
1692 std::set<std::string> arrows =
_lines;
1693 for(std::set<std::string>::iterator iter = arrows.begin(); iter!=arrows.end(); ++iter)
1701 const std::string &
id,
1704 const QColor & color,
1709 UERROR(
"id should not be empty!");
1719 QColor c = Qt::gray;
1725 pcl::PointXYZ center(pose.
x(), pose.
y(), pose.
z());
1726 _visualizer->addSphere(center, radius, c.redF(), c.greenF(), c.blueF(), id, foreground?3:2);
1727 _visualizer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_OPACITY, c.alphaF(), id);
1735 UERROR(
"id should not be empty!");
1748 std::set<std::string> spheres =
_spheres;
1749 for(std::set<std::string>::iterator iter = spheres.begin(); iter!=spheres.end(); ++iter)
1757 const std::string &
id,
1762 const QColor & color,
1768 UERROR(
"id should not be empty!");
1778 QColor c = Qt::gray;
1786 _visualizer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_REPRESENTATION, pcl::visualization::PCL_VISUALIZER_REPRESENTATION_WIREFRAME,
id);
1788 _visualizer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR, c.redF(), c.greenF(), c.blueF(), id);
1789 _visualizer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_OPACITY, c.alphaF(), id);
1797 UERROR(
"id should not be empty!");
1810 std::set<std::string> cubes =
_cubes;
1811 for(std::set<std::string>::iterator iter = cubes.begin(); iter!=cubes.end(); ++iter)
1819 const std::string &
id,
1823 const QColor & color,
1826 addOrUpdateQuad(
id, pose, width/2.0
f, width/2.0
f, height/2.0
f, height/2.0
f, color, foreground);
1830 const std::string &
id,
1836 const QColor & color,
1841 UERROR(
"id should not be empty!");
1851 QColor c = Qt::gray;
1858 double p0[3] = {0.0, -widthLeft, heightTop};
1859 double p1[3] = {0.0, -widthLeft, -heightBottom};
1860 double p2[3] = {0.0, widthRight, -heightBottom};
1861 double p3[3] = {0.0, widthRight, heightTop};
1866 points->InsertNextPoint(p0);
1867 points->InsertNextPoint(p1);
1868 points->InsertNextPoint(p2);
1869 points->InsertNextPoint(p3);
1874 quad->GetPointIds()->SetId(0,0);
1875 quad->GetPointIds()->SetId(1,1);
1876 quad->GetPointIds()->SetId(2,2);
1877 quad->GetPointIds()->SetId(3,3);
1882 quads->InsertNextCell(quad);
1889 polydata->SetPoints(points);
1890 polydata->SetPolys(quads);
1895 #if VTK_MAJOR_VERSION <= 5 1896 mapper->SetInput(polydata);
1898 mapper->SetInputData(polydata);
1903 actor->SetMapper(mapper);
1904 actor->GetProperty()->SetColor(c.redF(), c.greenF(), c.blueF());
1908 _visualizer->getRendererCollection()->InitTraversal ();
1909 vtkRenderer* renderer =
NULL;
1911 while ((renderer =
_visualizer->getRendererCollection()->GetNextItem ()) !=
NULL)
1913 if ((foreground?3:2) == i)
1915 renderer->AddActor (actor);
1921 (*
_visualizer->getCloudActorMap())[
id].actor = actor;
1925 pcl::visualization::PCLVisualizer::convertToVtkMatrix (pose.
toEigen3f().matrix (), transformation);
1926 (*
_visualizer->getCloudActorMap())[
id].viewpoint_transformation_ = transformation;
1927 (*
_visualizer->getCloudActorMap())[
id].actor->SetUserMatrix (transformation);
1928 (*
_visualizer->getCloudActorMap())[
id].actor->Modified ();
1930 (*
_visualizer->getCloudActorMap())[
id].actor->GetProperty()->SetLighting(
false);
1931 _visualizer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_OPACITY, c.alphaF(), id);
1939 UERROR(
"id should not be empty!");
1952 std::set<std::string> quads =
_quads;
1953 for(std::set<std::string>::iterator iter = quads.begin(); iter!=quads.end(); ++iter)
1968 1, 2, 3, 4, 1, 0, 2, 0, 3, 0, 4};
1971 const std::string &
id,
1975 const QColor & color,
1981 UERROR(
"id should not be empty!");
1985 #if PCL_VERSION_COMPARE(<, 1, 7, 2) 1996 UASSERT(frustumSize>0 && frustumSize % 3 == 0);
1998 pcl::PointCloud<pcl::PointXYZ> frustumPoints;
1999 frustumPoints.resize(frustumSize);
2000 float scaleX =
tan((fovX>0?fovX:1.1)/2.0
f) *
scale;
2001 float scaleY =
tan((fovY>0?fovY:0.85)/2.0
f) *
scale;
2002 float scaleZ =
scale;
2003 QColor c = Qt::gray;
2008 Transform opticalRotInv(0, -1, 0, 0, 0, 0, -1, 0, 1, 0, 0, 0);
2010 #if PCL_VERSION_COMPARE(<, 1, 7, 2) 2011 Eigen::Affine3f t = (pose*localTransform).toEigen3f();
2013 Eigen::Affine3f t = (localTransform).toEigen3f();
2015 for(
int i=0; i<frustumSize; ++i)
2017 frustumPoints[i].x = frustum_vertices[i*3]*scaleX;
2018 frustumPoints[i].y = frustum_vertices[i*3+1]*scaleY;
2019 frustumPoints[i].z = frustum_vertices[i*3+2]*scaleZ;
2023 pcl::PolygonMesh mesh;
2025 vertices.vertices.resize(
sizeof(frustum_indices)/
sizeof(
int));
2026 for(
unsigned int i=0; i<vertices.vertices.size(); ++i)
2028 vertices.vertices[i] = frustum_indices[i];
2030 pcl::toPCLPointCloud2(frustumPoints, mesh.cloud);
2031 mesh.polygons.push_back(vertices);
2032 _visualizer->addPolylineFromPolygonMesh(mesh,
id, 2);
2033 _visualizer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR, c.redF(), c.greenF(), c.blueF(), id);
2034 _visualizer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_OPACITY, c.alphaF(), id);
2036 #if PCL_VERSION_COMPARE(>=, 1, 7, 2) 2039 UERROR(
"Failed updating pose of frustum %s!?",
id.c_str());
2050 const std::string &
id,
2053 #if PCL_VERSION_COMPARE(>=, 1, 7, 2) 2054 QMap<std::string, Transform>::iterator iter=
_frustums.find(
id);
2057 if(iter.value() == pose)
2063 pcl::visualization::ShapeActorMap::iterator am_it =
_visualizer->getShapeActorMap()->find (
id);
2067 if (am_it ==
_visualizer->getShapeActorMap()->end ())
2070 actor = vtkActor::SafeDownCast (am_it->second);
2077 pcl::visualization::PCLVisualizer::convertToVtkMatrix (pose.
toEigen3f().matrix (), matrix);
2079 actor->SetUserMatrix (matrix);
2082 iter.value() = pose;
2087 UERROR(
"updateFrustumPose() cannot be used with PCL<1.7.2. Use addOrUpdateFrustum() instead.");
2096 UERROR(
"id should not be empty!");
2109 QMap<std::string, Transform> frustums =
_frustums;
2110 for(QMap<std::string, Transform>::iterator iter = frustums.begin(); iter!=frustums.end(); ++iter)
2112 if(!exceptCameraReference || !
uStrContains(iter.key(),
"reference_frustum"))
2121 const std::string &
id,
2122 const pcl::PointCloud<pcl::PointXYZ>::Ptr & graph,
2123 const QColor & color)
2127 UERROR(
"id should not be empty!");
2137 pcl::PolygonMesh mesh;
2139 vertices.vertices.resize(graph->size());
2140 for(
unsigned int i=0; i<vertices.vertices.size(); ++i)
2142 vertices.vertices[i] = i;
2144 pcl::toPCLPointCloud2(*graph, mesh.cloud);
2145 mesh.polygons.push_back(vertices);
2146 _visualizer->addPolylineFromPolygonMesh(mesh,
id, 2);
2147 _visualizer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR, color.redF(), color.greenF(), color.blueF(), id);
2148 _visualizer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_OPACITY, color.alphaF(), id);
2150 pcl::PCLPointCloud2Ptr binaryCloud(
new pcl::PCLPointCloud2);
2151 pcl::toPCLPointCloud2(*graph, *binaryCloud);
2161 UERROR(
"id should not be empty!");
2175 std::set<std::string> graphes =
_graphes;
2176 for(std::set<std::string>::iterator iter = graphes.begin(); iter!=graphes.end(); ++iter)
2184 const std::string &
id,
2185 const std::string & text,
2188 const QColor & color,
2193 UERROR(
"id should not be empty!");
2204 pcl::PointXYZ(position.
x(), position.
y(), position.
z()),
2218 UERROR(
"id should not be empty!");
2231 std::set<std::string> texts =
_texts;
2232 for(std::set<std::string>::iterator iter = texts.begin(); iter!=texts.end(); ++iter)
2314 QMap<std::string, Transform> frustumsCopy =
_frustums;
2315 for(QMap<std::string, Transform>::iterator iter=frustumsCopy.begin(); iter!=frustumsCopy.end(); ++iter)
2322 std::set<std::string> linesCopy =
_lines;
2323 for(std::set<std::string>::iterator iter=linesCopy.begin(); iter!=linesCopy.end(); ++iter)
2342 if(!value.isValid())
2346 for(QMap<std::string, Transform>::iterator iter=
_frustums.begin(); iter!=
_frustums.end(); ++iter)
2348 _visualizer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR, value.redF(), value.greenF(), value.blueF(), iter.key());
2401 QMap<std::string, Transform> addedClouds =
_addedClouds;
2403 for(QList<std::string>::iterator iter = ids.begin(); iter!=ids.end(); ++iter)
2415 #if VTK_MAJOR_VERSION >= 7 2449 pcl::visualization::CloudActorMapPtr cloudActorMap =
_visualizer->getCloudActorMap();
2450 for(pcl::visualization::CloudActorMap::iterator iter=cloudActorMap->begin(); iter!=cloudActorMap->end(); ++iter)
2452 if(iter->second.actor.GetPointer() == actor)
2458 #if PCL_VERSION_COMPARE(>=, 1, 7, 2) 2460 pcl::visualization::ShapeActorMapPtr shapeActorMap =
_visualizer->getShapeActorMap();
2461 for(pcl::visualization::ShapeActorMap::iterator iter=shapeActorMap->begin(); iter!=shapeActorMap->end(); ++iter)
2463 if(iter->second.GetPointer() == actor)
2465 std::string
id = iter->first;
2466 while(
id.size() &&
id.at(
id.size()-1) ==
'*')
2468 id.erase(
id.size()-1);
2475 return std::string();
2481 pcl::visualization::CloudActorMap::iterator iter =
_visualizer->getCloudActorMap()->find(
id);
2482 if(iter !=
_visualizer->getCloudActorMap()->end())
2485 iter->second.actor->GetProperty()->GetColor(r,g,b);
2486 a = iter->second.actor->GetProperty()->GetOpacity();
2487 color.setRgbF(r, g, b, a);
2489 #if PCL_VERSION_COMPARE(>=, 1, 7, 2) 2493 std::string idLayer1 =
id+
"*";
2494 std::string idLayer2 =
id+
"**";
2495 pcl::visualization::ShapeActorMap::iterator iter =
_visualizer->getShapeActorMap()->find(
id);
2496 if(iter ==
_visualizer->getShapeActorMap()->end())
2498 iter =
_visualizer->getShapeActorMap()->find(idLayer1);
2499 if(iter ==
_visualizer->getShapeActorMap()->end())
2501 iter =
_visualizer->getShapeActorMap()->find(idLayer2);
2504 if(iter !=
_visualizer->getShapeActorMap()->end())
2506 vtkActor * actor = vtkActor::SafeDownCast(iter->second);
2510 actor->GetProperty()->GetColor(r,g,b);
2511 a = actor->GetProperty()->GetOpacity();
2512 color.setRgbF(r, g, b, a);
2522 pcl::visualization::CloudActorMap::iterator iter =
_visualizer->getCloudActorMap()->find(
id);
2523 if(iter !=
_visualizer->getCloudActorMap()->end())
2525 iter->second.actor->GetProperty()->SetColor(color.redF(),color.greenF(),color.blueF());
2526 iter->second.actor->GetProperty()->SetOpacity(color.alphaF());
2528 #if PCL_VERSION_COMPARE(>=, 1, 7, 2) 2532 std::string idLayer1 =
id+
"*";
2533 std::string idLayer2 =
id+
"**";
2534 pcl::visualization::ShapeActorMap::iterator iter =
_visualizer->getShapeActorMap()->find(
id);
2535 if(iter ==
_visualizer->getShapeActorMap()->end())
2537 iter =
_visualizer->getShapeActorMap()->find(idLayer1);
2538 if(iter ==
_visualizer->getShapeActorMap()->end())
2540 iter =
_visualizer->getShapeActorMap()->find(idLayer2);
2543 if(iter !=
_visualizer->getShapeActorMap()->end())
2545 vtkActor * actor = vtkActor::SafeDownCast(iter->second);
2548 actor->GetProperty()->SetColor(color.redF(),color.greenF(),color.blueF());
2549 actor->GetProperty()->SetOpacity(color.alphaF());
2561 pcl::visualization::CloudActorMapPtr cloudActorMap =
_visualizer->getCloudActorMap();
2562 for(pcl::visualization::CloudActorMap::iterator iter=cloudActorMap->begin(); iter!=cloudActorMap->end(); ++iter)
2564 iter->second.actor->GetProperty()->SetBackfaceCulling(
_aBackfaceCulling->isChecked());
2567 #if VTK_MAJOR_VERSION >= 7 2568 pcl::visualization::ShapeActorMapPtr shapeActorMap =
_visualizer->getShapeActorMap();
2569 for(pcl::visualization::ShapeActorMap::iterator iter=shapeActorMap->begin(); iter!=shapeActorMap->end(); ++iter)
2571 vtkActor* actor = vtkActor::SafeDownCast (iter->second);
2589 pp->SetTolerance (pp->GetTolerance());
2590 this->GetInteractor()->SetPicker (pp);
2591 setMouseTracking(
false);
2596 pp->SetTolerance (pp->GetTolerance());
2597 this->GetInteractor()->SetPicker (pp);
2598 setMouseTracking(
true);
2612 #if VTK_MAJOR_VERSION >= 7 2614 _visualizer->getRendererCollection()->InitTraversal ();
2615 vtkRenderer* renderer =
NULL;
2616 renderer =
_visualizer->getRendererCollection()->GetNextItem ();
2617 renderer =
_visualizer->getRendererCollection()->GetNextItem ();
2620 vtkOpenGLRenderer* glrenderer = vtkOpenGLRenderer::SafeDownCast(renderer);
2627 edl->SetDelegatePass(basicPasses);
2628 glrenderer->SetPass(edl);
2630 else if(glrenderer->GetPass())
2632 glrenderer->GetPass()->ReleaseGraphicsResources(
NULL);
2633 glrenderer->SetPass(
NULL);
2640 UERROR(
"RTAB-Map must be built with VTK>=7 to enable EDL shading!");
2648 pcl::visualization::CloudActorMapPtr cloudActorMap =
_visualizer->getCloudActorMap();
2649 for(pcl::visualization::CloudActorMap::iterator iter=cloudActorMap->begin(); iter!=cloudActorMap->end(); ++iter)
2651 iter->second.actor->GetProperty()->SetLighting(
_aSetLighting->isChecked());
2653 #if VTK_MAJOR_VERSION >= 7 2654 pcl::visualization::ShapeActorMapPtr shapeActorMap =
_visualizer->getShapeActorMap();
2655 for(pcl::visualization::ShapeActorMap::iterator iter=shapeActorMap->begin(); iter!=shapeActorMap->end(); ++iter)
2657 vtkActor* actor = vtkActor::SafeDownCast (iter->second);
2660 actor->GetProperty()->SetLighting(
_aSetLighting->isChecked());
2670 pcl::visualization::CloudActorMapPtr cloudActorMap =
_visualizer->getCloudActorMap();
2671 for(pcl::visualization::CloudActorMap::iterator iter=cloudActorMap->begin(); iter!=cloudActorMap->end(); ++iter)
2673 iter->second.actor->GetProperty()->SetInterpolation(
_aSetFlatShading->isChecked()?VTK_FLAT:VTK_PHONG);
2675 #if VTK_MAJOR_VERSION >= 7 2676 pcl::visualization::ShapeActorMapPtr shapeActorMap =
_visualizer->getShapeActorMap();
2677 for(pcl::visualization::ShapeActorMap::iterator iter=shapeActorMap->begin(); iter!=shapeActorMap->end(); ++iter)
2679 vtkActor* actor = vtkActor::SafeDownCast (iter->second);
2682 actor->GetProperty()->SetInterpolation(
_aSetFlatShading->isChecked()?VTK_FLAT:VTK_PHONG);
2692 pcl::visualization::CloudActorMapPtr cloudActorMap =
_visualizer->getCloudActorMap();
2693 for(pcl::visualization::CloudActorMap::iterator iter=cloudActorMap->begin(); iter!=cloudActorMap->end(); ++iter)
2697 #if VTK_MAJOR_VERSION >= 7 2698 pcl::visualization::ShapeActorMapPtr shapeActorMap =
_visualizer->getShapeActorMap();
2699 for(pcl::visualization::ShapeActorMap::iterator iter=shapeActorMap->begin(); iter!=shapeActorMap->end(); ++iter)
2701 vtkActor* actor = vtkActor::SafeDownCast (iter->second);
2713 _visualizer->getRendererCollection()->InitTraversal ();
2714 vtkRenderer* renderer =
NULL;
2716 while ((renderer =
_visualizer->getRendererCollection()->GetNextItem ()) !=
NULL)
2720 _visualizer->getInteractorStyle()->SetDefaultRenderer(renderer);
2721 _visualizer->getInteractorStyle()->SetCurrentRenderer(renderer);
2726 UWARN(
"Could not set layer %d to interactor (layers=%d).", layer,
_visualizer->getRendererCollection()->GetNumberOfItems());
2730 float & x,
float & y,
float & z,
2731 float & focalX,
float & focalY,
float & focalZ,
2732 float & upX,
float & upY,
float & upZ)
const 2734 std::vector<pcl::visualization::Camera> cameras;
2738 x = cameras.begin()->pos[0];
2739 y = cameras.begin()->pos[1];
2740 z = cameras.begin()->pos[2];
2741 focalX = cameras.begin()->focal[0];
2742 focalY = cameras.begin()->focal[1];
2743 focalZ = cameras.begin()->focal[2];
2744 upX = cameras.begin()->view[0];
2745 upY = cameras.begin()->view[1];
2746 upZ = cameras.begin()->view[2];
2750 UERROR(
"No camera set!?");
2755 float x,
float y,
float z,
2756 float focalX,
float focalY,
float focalZ,
2757 float upX,
float upY,
float upZ)
2759 vtkRenderer* renderer =
NULL;
2760 double boundingBox[6] = {1, -1, 1, -1, 1, -1};
2763 _visualizer->getRendererCollection()->InitTraversal ();
2764 while ((renderer =
_visualizer->getRendererCollection()->GetNextItem ()) !=
NULL)
2767 cam->SetPosition (x, y, z);
2768 cam->SetFocalPoint (focalX, focalY, focalZ);
2769 cam->SetViewUp (upX, upY, upZ);
2772 renderer->ComputeVisiblePropBounds(BB);
2773 for (
int i = 0; i < 6; i++) {
2776 if (BB[i] < boundingBox[i]) {
2777 boundingBox[i] = BB[i];
2781 if (BB[i] > boundingBox[i]) {
2782 boundingBox[i] = BB[i];
2788 _visualizer->getRendererCollection()->InitTraversal ();
2789 while ((renderer =
_visualizer->getRendererCollection()->GetNextItem ()) !=
NULL)
2791 renderer->ResetCameraClippingRange(boundingBox);
2802 Eigen::Vector3f pos = m.translation();
2804 Eigen::Vector3f lastPos(0,0,0);
2812 _trajectory->push_back(pcl::PointXYZ(pos[0], pos[1], pos[2]));
2823 pcl::PolygonMesh mesh;
2826 for(
unsigned int i=0; i<vertices.vertices.size(); ++i)
2828 vertices.vertices[i] = i;
2831 mesh.polygons.push_back(vertices);
2832 _visualizer->addPolylineFromPolygonMesh(mesh,
"trajectory", 2);
2842 std::vector<pcl::visualization::Camera> cameras;
2849 cameras.front().pos[0] += diff[0];
2850 cameras.front().pos[1] += diff[1];
2851 cameras.front().pos[2] += diff[2];
2852 cameras.front().focal[0] += diff[0];
2853 cameras.front().focal[1] += diff[1];
2854 cameras.front().focal[2] += diff[2];
2858 Eigen::Vector3f vPosToFocal = Eigen::Vector3f(cameras.front().focal[0] - cameras.front().pos[0],
2859 cameras.front().focal[1] - cameras.front().pos[1],
2860 cameras.front().focal[2] - cameras.front().pos[2]).normalized();
2861 Eigen::Vector3f zAxis(cameras.front().view[0], cameras.front().view[1], cameras.front().view[2]);
2862 Eigen::Vector3f yAxis = zAxis.cross(vPosToFocal);
2863 Eigen::Vector3f xAxis = yAxis.cross(zAxis);
2864 Transform PR(xAxis[0], xAxis[1], xAxis[2],0,
2865 yAxis[0], yAxis[1], yAxis[2],0,
2866 zAxis[0], zAxis[1], zAxis[2],0);
2870 Transform P(PR[0], PR[1], PR[2], cameras.front().pos[0],
2871 PR[4], PR[5], PR[6], cameras.front().pos[1],
2872 PR[8], PR[9], PR[10], cameras.front().pos[2]);
2873 Transform F(PR[0], PR[1], PR[2], cameras.front().focal[0],
2874 PR[4], PR[5], PR[6], cameras.front().focal[1],
2875 PR[8], PR[9], PR[10], cameras.front().focal[2]);
2885 cameras.front().pos[0] = Pp.
x();
2886 cameras.front().pos[1] = Pp.
y();
2887 cameras.front().pos[2] = Pp.
z();
2888 cameras.front().focal[0] = Fp.
x();
2889 cameras.front().focal[1] = Fp.
y();
2890 cameras.front().focal[2] = Fp.
z();
2892 cameras.front().view[0] =
_aLockViewZ->isChecked()?0:Fp[8];
2893 cameras.front().view[1] =
_aLockViewZ->isChecked()?0:Fp[9];
2894 cameras.front().view[2] =
_aLockViewZ->isChecked()?1:Fp[10];
2899 #if PCL_VERSION_COMPARE(>=, 1, 7, 2) 2912 cameras.front().pos[0], cameras.front().pos[1], cameras.front().pos[2],
2913 cameras.front().focal[0], cameras.front().focal[1], cameras.front().focal[2],
2914 cameras.front().view[0], cameras.front().view[1], cameras.front().view[2]);
2923 std::vector<CameraModel> models;
2924 models.push_back(model.
left());
2930 models.push_back(right);
2936 std::vector<CameraModel> models;
2937 models.push_back(model);
2948 for(
unsigned int i=0; i<models.size(); ++i)
2951 if(!models[i].localTransform().
isNull() && !models[i].localTransform().
isIdentity())
2953 baseToCamera = models[i].localTransform();
2955 std::string
id =
uFormat(
"reference_frustum_%d", i);
2989 _visualizer->setBackgroundColor(color.redF(), color.greenF(), color.blueF());
2994 pcl::visualization::CloudActorMapPtr cloudActorMap =
_visualizer->getCloudActorMap();
2995 pcl::visualization::CloudActorMap::iterator iter = cloudActorMap->find(
id);
2996 if(iter != cloudActorMap->end())
2998 iter->second.actor->SetVisibility(isVisible?1:0);
3000 iter = cloudActorMap->find(
id+
"-normals");
3001 if(iter != cloudActorMap->end())
3003 iter->second.actor->SetVisibility(isVisible&&
_aShowNormals->isChecked()?1:0);
3008 #if VTK_MAJOR_VERSION >= 7 3009 pcl::visualization::ShapeActorMapPtr shapeActorMap =
_visualizer->getShapeActorMap();
3010 pcl::visualization::ShapeActorMap::iterator iter = shapeActorMap->find(
id);
3011 if(iter != shapeActorMap->end())
3013 vtkActor* actor = vtkActor::SafeDownCast (iter->second);
3016 actor->SetVisibility(isVisible?1:0);
3021 UERROR(
"Cannot find actor named \"%s\".",
id.c_str());
3027 pcl::visualization::CloudActorMapPtr cloudActorMap =
_visualizer->getCloudActorMap();
3028 pcl::visualization::CloudActorMap::iterator iter = cloudActorMap->find(
id);
3029 if(iter != cloudActorMap->end())
3031 return iter->second.actor->GetVisibility() != 0;
3035 #if VTK_MAJOR_VERSION >= 7 3036 pcl::visualization::ShapeActorMapPtr shapeActorMap =
_visualizer->getShapeActorMap();
3037 pcl::visualization::ShapeActorMap::iterator iter = shapeActorMap->find(
id);
3038 if(iter != shapeActorMap->end())
3040 vtkActor* actor = vtkActor::SafeDownCast (iter->second);
3043 return actor->GetVisibility() != 0;
3047 UERROR(
"Cannot find actor named \"%s\".",
id.c_str());
3056 _visualizer->updateColorHandlerIndex(
id, index-1);
3063 if(
_visualizer->getPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_OPACITY, lastOpacity,
id))
3065 if(lastOpacity != opacity)
3067 _visualizer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_OPACITY, opacity,
id);
3070 #if VTK_MAJOR_VERSION >= 7 3073 pcl::visualization::ShapeActorMap::iterator am_it =
_visualizer->getShapeActorMap()->find (
id);
3074 if (am_it !=
_visualizer->getShapeActorMap()->end ())
3076 vtkActor* actor = vtkActor::SafeDownCast (am_it->second);
3079 actor->GetProperty ()->SetOpacity (opacity);
3090 if(
_visualizer->getPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, lastSize,
id))
3092 if((
int)lastSize != size)
3094 _visualizer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, (
double)size,
id);
3123 CloudViewerInteractorStyle * interactor = CloudViewerInteractorStyle::SafeDownCast(this->GetInteractor()->GetInteractorStyle());
3221 UERROR(
"Cannot set grid cell count < 1, count=%d", count);
3237 UERROR(
"Cannot set grid cell size <= 0, value=%f", size);
3250 float min = -float(cellCount/2) * cellSize;
3251 float max = float(cellCount/2) * cellSize;
3253 for(
float i=min; i<=
max; i += cellSize)
3256 name =
uFormat(
"line%d", ++
id);
3258 pcl::PointXYZ(i, min, 0.0
f),
3259 pcl::PointXYZ(i, max, 0.0
f),
3263 name =
uFormat(
"line%d", ++
id);
3265 pcl::PointXYZ(min, i, 0),
3266 pcl::PointXYZ(max, i, 0),
3271 std::vector<pcl::visualization::Camera> cameras;
3274 cameras.front().pos[0], cameras.front().pos[1], cameras.front().pos[2],
3275 cameras.front().focal[0], cameras.front().focal[1], cameras.front().focal[2],
3276 cameras.front().view[0], cameras.front().view[1], cameras.front().view[2]);
3282 for(std::list<std::string>::iterator iter =
_gridLines.begin(); iter!=
_gridLines.end(); ++iter)
3293 for(QList<std::string>::iterator iter = ids.begin(); iter!=ids.end(); ++iter)
3295 std::string idNormals = *iter +
"-normals";
3322 UERROR(
"Cannot set normals step <= 0, step=%d", step);
3333 UERROR(
"Cannot set normals scale <= 0, value=%f", scale);
3374 UERROR(
"Cannot set normals scale < 0, value=%f", value);
3384 const Eigen::Vector3f & point,
3385 const Eigen::Vector3f &
axis,
3388 Eigen::Vector3f direction = point;
3389 Eigen::Vector3f zAxis =
axis;
3390 float dotProdZ = zAxis.dot(direction);
3391 Eigen::Vector3f ptOnZaxis = zAxis * dotProdZ;
3392 direction -= ptOnZaxis;
3393 Eigen::Vector3f xAxis = direction.normalized();
3394 Eigen::Vector3f yAxis = zAxis.cross(xAxis);
3396 Eigen::Matrix3f newFrame;
3397 newFrame << xAxis[0], yAxis[0], zAxis[0],
3398 xAxis[1], yAxis[1], zAxis[1],
3399 xAxis[2], yAxis[2], zAxis[2];
3403 Eigen::Vector3f newDirection = newFrame.transpose() * direction;
3406 float cosTheta =
cos(angle);
3407 float sinTheta =
sin(angle);
3408 float magnitude = newDirection.norm();
3409 newDirection[0] = ( magnitude * cosTheta );
3410 newDirection[1] = ( magnitude * sinTheta );
3413 direction = newFrame * newDirection;
3415 return direction + ptOnZaxis;
3419 if(event->key() == Qt::Key_Up ||
3420 event->key() == Qt::Key_Down ||
3421 event->key() == Qt::Key_Left ||
3422 event->key() == Qt::Key_Right)
3428 QVTKWidget::keyPressEvent(event);
3434 if(event->key() == Qt::Key_Up ||
3435 event->key() == Qt::Key_Down ||
3436 event->key() == Qt::Key_Left ||
3437 event->key() == Qt::Key_Right)
3441 std::vector<pcl::visualization::Camera> cameras;
3445 Eigen::Vector3f pos(cameras.front().pos[0], cameras.front().pos[1],
_aLockViewZ->isChecked()?0:cameras.front().pos[2]);
3446 Eigen::Vector3f focal(cameras.front().focal[0], cameras.front().focal[1],
_aLockViewZ->isChecked()?0:cameras.front().focal[2]);
3447 Eigen::Vector3f viewUp(cameras.front().view[0], cameras.front().view[1], cameras.front().view[2]);
3448 Eigen::Vector3f cummulatedDir(0,0,0);
3449 Eigen::Vector3f cummulatedFocalDir(0,0,0);
3451 float stepRot = 0.02f;
3454 Eigen::Vector3f dir;
3455 if(event->modifiers() & Qt::ShiftModifier)
3457 dir = viewUp *
step;
3461 dir = (focal-pos).normalized() *
step;
3463 cummulatedDir += dir;
3467 Eigen::Vector3f dir;
3468 if(event->modifiers() & Qt::ShiftModifier)
3470 dir = viewUp * -
step;
3474 dir = (focal-pos).normalized() * -
step;
3476 cummulatedDir += dir;
3480 if(event->modifiers() & Qt::ShiftModifier)
3483 Eigen::Vector3f point = (focal-pos);
3485 Eigen::Vector3f diff = newPoint - point;
3486 cummulatedFocalDir += diff;
3490 Eigen::Vector3f dir = ((focal-pos).
cross(viewUp)).normalized() *
step;
3491 cummulatedDir += dir;
3496 if(event->modifiers() & Qt::ShiftModifier)
3499 Eigen::Vector3f point = (focal-pos);
3501 Eigen::Vector3f diff = newPoint - point;
3502 cummulatedFocalDir += diff;
3506 Eigen::Vector3f dir = ((focal-pos).
cross(viewUp)).normalized() * -
step;
3507 cummulatedDir += dir;
3511 cameras.front().pos[0] += cummulatedDir[0];
3512 cameras.front().pos[1] += cummulatedDir[1];
3513 cameras.front().pos[2] += cummulatedDir[2];
3514 cameras.front().focal[0] += cummulatedDir[0] + cummulatedFocalDir[0];
3515 cameras.front().focal[1] += cummulatedDir[1] + cummulatedFocalDir[1];
3516 cameras.front().focal[2] += cummulatedDir[2] + cummulatedFocalDir[2];
3518 cameras.front().pos[0], cameras.front().pos[1], cameras.front().pos[2],
3519 cameras.front().focal[0], cameras.front().focal[1], cameras.front().focal[2],
3520 cameras.front().view[0], cameras.front().view[1], cameras.front().view[2]);
3526 QVTKWidget::keyPressEvent(event);
3532 if(event->button() == Qt::RightButton)
3538 QVTKWidget::mousePressEvent(event);
3544 QVTKWidget::mouseMoveEvent(event);
3546 std::vector<pcl::visualization::Camera> cameras;
3552 cv::Vec3d newCameraOrientation = cv::Vec3d(0,0,1).cross(cv::Vec3d(cameras.front().pos)-cv::Vec3d(cameras.front().focal));
3563 else if(newCameraOrientation != cv::Vec3d(0,0,0))
3570 if(cameras.front().view[2] == 0)
3572 cameras.front().pos[0] -= 0.00001*cameras.front().view[0];
3573 cameras.front().pos[1] -= 0.00001*cameras.front().view[1];
3577 cameras.front().pos[0] -= 0.00001;
3580 cameras.front().view[0] = 0;
3581 cameras.front().view[1] = 0;
3582 cameras.front().view[2] = 1;
3586 cameras.front().pos[0], cameras.front().pos[1], cameras.front().pos[2],
3587 cameras.front().focal[0], cameras.front().focal[1], cameras.front().focal[2],
3588 cameras.front().view[0], cameras.front().view[1], cameras.front().view[2]);
3595 QVTKWidget::wheelEvent(event);
3597 std::vector<pcl::visualization::Camera> cameras;
3606 cameras.front().pos[0], cameras.front().pos[1], cameras.front().pos[2],
3607 cameras.front().focal[0], cameras.front().focal[1], cameras.front().focal[2],
3608 cameras.front().view[0], cameras.front().view[1], cameras.front().view[2]);
3615 QAction * a =
_menu->exec(event->globalPos());
3628 int value = QInputDialog::getInt(
this, tr(
"Set trajectory size"), tr(
"Size (0=infinite)"),
_maxTrajectorySize, 0, 10000, 10, &ok);
3645 double value = QInputDialog::getDouble(
this, tr(
"Set frame scale"), tr(
"Scale"),
_coordinateFrameScale, 0.1, 999.0, 1, &ok);
3658 double value = QInputDialog::getDouble(
this, tr(
"Set frustum scale"), tr(
"Scale"),
_frustumScale, 0.0, 999.0, 1, &ok);
3692 int value = QInputDialog::getInt(
this, tr(
"Set grid cell count"), tr(
"Count"),
_gridCellCount, 1, 10000, 10, &ok);
3701 double value = QInputDialog::getDouble(
this, tr(
"Set grid cell size"), tr(
"Size (m)"),
_gridCellSize, 0.01, 1000, 2, &ok);
3715 int value = QInputDialog::getInt(
this, tr(
"Set normals step"), tr(
"Step"),
_normalsStep, 1, 10000, 1, &ok);
3724 double value = QInputDialog::getDouble(
this, tr(
"Set normals scale"), tr(
"Scale (m)"),
_normalsScale, 0.01, 10, 2, &ok);
3733 double value = QInputDialog::getDouble(
this, tr(
"Set maximum absolute intensity"), tr(
"Intensity (0=auto)"),
_intensityAbsMax, 0.0, 99999, 2, &ok);
3750 color = QColorDialog::getColor(color,
this);
3760 double value = QInputDialog::getDouble(
this, tr(
"Rendering rate"), tr(
"Rate (hz)"),
_renderingRate, 0, 60, 0, &ok);
void setDefaultBackgroundColor(const QColor &color)
void setLocalTransform(const Transform &transform)
QAction * _aShowCameraAxis
bool isPolygonPicking() const
void removeGraph(const std::string &id)
QAction * _aBackfaceCulling
QAction * _aSetFrustumScale
void setTrajectoryShown(bool shown)
void setFrustumShown(bool shown)
rtabmap::CameraThread * cam
boost::shared_ptr< const PointCloudColorHandlerIntensityField > ConstPtr
std::set< std::string > _coordinates
void setInteractorLayer(int layer)
iterator begin(unsigned char maxDepth=0) const
void setTrajectorySize(unsigned int value)
unsigned int getGridCellCount() const
pcl::visualization::PCLVisualizer * _visualizer
GLM_FUNC_DECL bool isfinite(genType const &x)
Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)...
GLM_FUNC_DECL genType min(genType const &x, genType const &y)
cv::Point3f RTABMAP_EXP transformPoint(const cv::Point3f &pt, const Transform &transform)
std::map< std::string, vtkSmartPointer< vtkOBBTree > > _locators
void setNormalsStep(int step)
virtual void keyPressEvent(QKeyEvent *event)
void setNormalsScale(float scale)
double getCoordinateFrameScale() const
QAction * _aSetIntensityRainbowColormap
void updateCameraFrustum(const Transform &pose, const StereoCameraModel &model)
void setCoordinateFrameScale(double scale)
void setGridShown(bool shown)
QAction * _aSetEdgeVisibility
void uMinMax(const T *v, unsigned int size, T &min, T &max, unsigned int &indexMin, unsigned int &indexMax)
void setCloudVisibility(const std::string &id, bool isVisible)
std::list< std::string > _gridLines
void addOrUpdateCoordinate(const std::string &id, const Transform &transform, double scale, bool foreground=false)
void addOrUpdateText(const std::string &id, const std::string &text, const Transform &position, double scale, const QColor &color, bool foreground=true)
unsigned int _maxTrajectorySize
unsigned int getTrajectorySize() const
void removeCube(const std::string &id)
void setCloudViewer(CloudViewer *cloudViewer)
void removeFrustum(const std::string &id)
void addOrUpdateCube(const std::string &id, const Transform &pose, float width, float height, float depth, const QColor &color, bool wireframe=false, bool foreground=false)
void removeQuad(const std::string &id)
GLM_FUNC_DECL detail::tvec3< T, P > axis(detail::tquat< T, P > const &x)
std::set< std::string > _quads
bool removeCloud(const std::string &id)
const iterator end() const
QAction * _aPolygonPicking
static const float vertices[]
bool addOccupancyGridMap(const cv::Mat &map8U, float resolution, float xMin, float yMin, float opacity)
cv::Vec3d _lastCameraOrientation
void setGridCellSize(float size)
void setEDLShading(bool on)
void setLighting(bool on)
Transform getTargetPose() const
Eigen::Vector3f rotatePointAroundAxe(const Eigen::Vector3f &point, const Eigen::Vector3f &axis, float angle)
unsigned int getTreeDepth() const
Basic mathematics functions.
const QColor & getDefaultBackgroundColor() const
GLM_FUNC_DECL T angle(detail::tquat< T, P > const &x)
Some conversion functions.
void addOrUpdateSphere(const std::string &id, const Transform &pose, float radius, const QColor &color, bool foreground=false)
bool isNormalsShown() const
void setPolygonPicking(bool enabled)
std::set< std::string > _spheres
QSet< Qt::Key > _keysPressed
void buildPickingLocator(bool enable)
void setCameraOrtho(bool enabled=true)
void removeLine(const std::string &id)
virtual void contextMenuEvent(QContextMenuEvent *event)
float getGridCellSize() const
bool uStrContains(const std::string &string, const std::string &substring)
GLM_FUNC_DECL genType step(genType const &edge, genType const &x)
boost::shared_ptr< PointCloudColorHandlerIntensityField > Ptr
std::set< std::string > _graphes
QAction * _aSetEDLShading
bool updateCoordinatePose(const std::string &id, const Transform &transform)
QAction * _aSetNormalsScale
bool addCloudTextureMesh(const std::string &id, const pcl::TextureMesh::Ptr &textureMesh, const cv::Mat &texture, const Transform &pose=Transform::getIdentity())
double keyToCoord(unsigned short int key, unsigned depth) const
std::set< std::string > _texts
void setIntensityRedColormap(bool value)
GLM_FUNC_DECL bool isNull(detail::tmat2x2< T, P > const &m, T const &epsilon)
pcl::visualization::PointCloudColorHandler< pcl::PCLPointCloud2 >::PointCloud PointCloud
bool isCameraAxisShown() const
virtual std::string getName() const
Get the name of the class.
std::string getIdByActor(vtkProp *actor) const
bool isCameraFree() const
void getCameraPosition(float &x, float &y, float &z, float &focalX, float &focalY, float &focalZ, float &upX, float &upY, float &upZ) const
void addOrUpdateLine(const std::string &id, const Transform &from, const Transform &to, const QColor &color, bool arrow=false, bool foreground=false)
#define UASSERT(condition)
GLM_FUNC_DECL genType cos(genType const &angle)
QAction * _aSetFrustumColor
QMap< std::string, Transform > _addedClouds
QAction * _aSetTrajectorySize
Wrappers of STL for convenient functions.
void setCameraAxisShown(bool shown)
QAction * _aSetBackgroundColor
virtual bool getColor(vtkSmartPointer< vtkDataArray > &scalars) const
Obtain the actual color for the input dataset as vtk scalars.
GLM_FUNC_DECL genType sin(genType const &angle)
const CameraModel & left() const
virtual std::string getFieldName() const
Get the name of the field used.
GLM_FUNC_DECL detail::tvec3< T, P > cross(detail::tvec3< T, P > const &x, detail::tvec3< T, P > const &y)
int getNormalsStep() const
void removeAllCoordinates(const std::string &prefix="")
bool isLightingOn() const
void setColor(const std::string &id, const QColor &color)
void saveSettings(QSettings &settings, const QString &group="") const
void addOrUpdateQuad(const std::string &id, const Transform &pose, float width, float height, const QColor &color, bool foreground=false)
void setGridCellCount(unsigned int count)
void setCameraPosition(float x, float y, float z, float focalX, float focalY, float focalZ, float upX, float upY, float upZ)
float getFrustumScale() const
virtual ~PointCloudColorHandlerIntensityField()
Empty destructor.
bool isEdgeVisible() const
void getGridMax(double &x, double &y, double &z) const
bool isCameraTargetFollow() const
void setEdgeVisibility(bool visible)
void setFrustumScale(float value)
void removeText(const std::string &id)
void removeOccupancyGridMap()
void setCloudPointSize(const std::string &id, int size)
PointCloud::ConstPtr PointCloudConstPtr
void setNormalsShown(bool shown)
bool isFrontfaceCulling() const
const RtabmapColorOcTree * octree() const
void setFrustumColor(QColor value)
void updateCameraTargetPosition(const Transform &pose)
void addOrUpdateFrustum(const std::string &id, const Transform &pose, const Transform &localTransform, double scale, const QColor &color=QColor(), float fovX=1.1, float fovY=0.85)
bool isCameraLockZ() const
QAction * _aShowTrajectory
const QColor & getBackgroundColor() const
double _coordinateFrameScale
void setBackgroundColor(const QColor &color)
static const int frustum_indices[]
CloudViewer(QWidget *parent=0, CloudViewerInteractorStyle *style=CloudViewerInteractorStyle::New())
bool updateFrustumPose(const std::string &id, const Transform &pose)
void setCameraLockZ(bool enabled=true)
float getIntensityMax() const
GLM_FUNC_DECL bool isIdentity(matType< T, P > const &m, T const &epsilon)
bool isFrustumShown() const
pcl::PointCloud< pcl::PointXYZ >::Ptr _trajectory
bool addCloud(const std::string &id, const pcl::PCLPointCloud2Ptr &binaryCloud, const Transform &pose, bool rgb, bool hasNormals, bool hasIntensity, const QColor &color=QColor(), int viewport=1)
bool getCloudVisibility(const std::string &id)
void getGridMin(double &x, double &y, double &z) const
QAction * _aSetNormalsStep
GLM_FUNC_DECL genType tan(genType const &angle)
std::set< std::string > _lines
bool isBackfaceCulling() const
QAction * _aClearTrajectory
pcl::PointCloud< pcl::PointXYZRGB >::Ptr createCloud(unsigned int treeDepth=0, std::vector< int > *obstacleIndices=0, std::vector< int > *emptyIndices=0, std::vector< int > *groundIndices=0, bool originalRefPoints=true, std::vector< int > *frontierIndices=0, std::vector< double > *cloudProb=0) const
void addOrUpdateGraph(const std::string &id, const pcl::PointCloud< pcl::PointXYZ >::Ptr &graph, const QColor &color=Qt::gray)
QAction * _aSetIntensityMaximum
void setCameraTargetLocked(bool enabled=true)
GLM_FUNC_DECL genType max(genType const &x, genType const &y)
void setOrthoMode(bool enabled)
QAction * _aSetGridCellSize
void updateCameraFrustums(const Transform &pose, const std::vector< CameraModel > &models)
const CameraModel & right() const
void removeSphere(const std::string &id)
static const float frustum_vertices[]
void loadSettings(QSettings &settings, const QString &group="")
void setIntensityMax(float value)
double getRenderingRate() const
unsigned int _gridCellCount
virtual void keyReleaseEvent(QKeyEvent *event)
ULogger class and convenient macros.
void setBackfaceCulling(bool enabled, bool frontfaceCulling)
bool isCameraOrtho() const
QAction * _aSetFrameScale
void setCameraTargetFollow(bool enabled=true)
std::set< std::string > _cubes
QMap< std::string, Transform > _frustums
virtual void mousePressEvent(QMouseEvent *event)
virtual void mouseMoveEvent(QMouseEvent *event)
double getNodeSize(unsigned depth) const
bool isEDLShadingOn() const
void setCloudColorIndex(const std::string &id, int index)
virtual void handleAction(QAction *event)
void removeCoordinate(const std::string &id)
bool isIntensityRedColormap() const
QAction * _aSetFlatShading
QAction * _aSetGridCellCount
bool addOctomap(const OctoMap *octomap, unsigned int treeDepth=0, bool volumeRepresentation=true)
bool addCloudMesh(const std::string &id, const pcl::PointCloud< pcl::PointXYZ >::Ptr &cloud, const std::vector< pcl::Vertices > &polygons, const Transform &pose=Transform::getIdentity())
bool addTextureMesh(const pcl::TextureMesh &mesh, const cv::Mat &texture, const std::string &id="texture", int viewport=0)
bool isIntensityRainbowColormap() const
QAction * _aSetIntensityRedColormap
QColor getFrustumColor() const
bool isTrajectoryShown() const
cv::Vec3d _lastCameraPose
void RTABMAP_EXP HSVtoRGB(float *r, float *g, float *b, float h, float s, float v)
PointCloudColorHandlerIntensityField(const PointCloudConstPtr &cloud, float maxAbsIntensity=0.0f, int colorMap=0)
Constructor.
virtual void wheelEvent(QWheelEvent *event)
QColor getColor(const std::string &id)
std::string UTILITE_EXP uFormat(const char *fmt,...)
PointCloud::Ptr PointCloudPtr
bool getPose(const std::string &id, Transform &pose)
bool isCameraTargetLocked() const
void removeAllFrustums(bool exceptCameraReference=false)
virtual size_t size() const
QAction * _aSetRenderingRate
float getNormalsScale() const
bool updateCloudPose(const std::string &id, const Transform &pose)
void setRenderingRate(double rate)
void setCloudOpacity(const std::string &id, double opacity=1.0)
GLM_FUNC_DECL detail::tmat4x4< T, P > orientation(detail::tvec3< T, P > const &Normal, detail::tvec3< T, P > const &Up)
void setIntensityRainbowColormap(bool value)
const Transform & localTransform() const