31 #include <rtabmap/core/Version.h>
39 #include <pcl/visualization/pcl_visualizer.h>
40 #include <pcl/common/transforms.h>
43 #include <QActionGroup>
44 #include <QtGui/QContextMenuEvent>
45 #include <QInputDialog>
46 #include <QtGui/QWheelEvent>
47 #include <QtGui/QKeyEvent>
48 #include <QColorDialog>
49 #include <QtGui/QVector3D>
50 #include <QMainWindow>
53 #include <vtkCamera.h>
54 #include <vtkRenderWindow.h>
55 #include <vtkCubeSource.h>
56 #include <vtkDataSetMapper.h>
57 #include <vtkDelaunay2D.h>
58 #include <vtkGlyph3D.h>
59 #include <vtkGlyph3DMapper.h>
60 #include <vtkSmartVolumeMapper.h>
61 #include <vtkVolumeProperty.h>
62 #include <vtkColorTransferFunction.h>
63 #include <vtkPiecewiseFunction.h>
64 #include <vtkImageData.h>
65 #include <vtkLookupTable.h>
66 #include <vtkTextureUnitManager.h>
67 #include <vtkJPEGReader.h>
68 #include <vtkBMPReader.h>
69 #include <vtkPNMReader.h>
70 #include <vtkPNGReader.h>
71 #include <vtkTIFFReader.h>
72 #include <vtkElevationFilter.h>
73 #include <vtkOpenGLRenderWindow.h>
74 #include <vtkPointPicker.h>
75 #include <vtkPointData.h>
76 #include <vtkTextActor.h>
77 #include <vtkTexture.h>
78 #include <vtkNamedColors.h>
79 #include <vtkOBBTree.h>
80 #include <vtkObjectFactory.h>
82 #include <vtkWarpScalar.h>
85 #if VTK_MAJOR_VERSION >= 7
86 #include <vtkEDLShading.h>
87 #include <vtkRenderStepsPass.h>
88 #include <vtkOpenGLRenderer.h>
91 #if VTK_MAJOR_VERSION >= 8
92 #include <vtkGenericOpenGLRenderWindow.h>
95 #ifdef RTABMAP_OCTOMAP
109 _aSetTrajectorySize(0),
110 _aClearTrajectory(0),
113 _aSetFrustumScale(0),
114 _aSetFrustumColor(0),
116 _aSetGridCellCount(0),
117 _aSetGridCellSize(0),
120 _aSetNormalsScale(0),
121 _aSetBackgroundColor(0),
122 _aSetRenderingRate(0),
126 _aSetEdgeVisibility(0),
127 _aBackfaceCulling(0),
129 _trajectory(new
pcl::PointCloud<
pcl::PointXYZ>),
130 _maxTrajectorySize(100),
132 _frustumColor(Qt::gray),
137 _buildLocator(
false),
138 _lastCameraOrientation(0,0,0),
139 _lastCameraPose(0,0,0),
140 _defaultBgColor(Qt::black),
141 _currentBgColor(Qt::black),
142 _frontfaceCulling(
false),
145 _intensityAbsMax(100.0
f),
146 _coordinateFrameScale(1.0)
148 this->setMinimumSize(200, 200);
153 style->AutoAdjustCameraClippingRangeOff();
154 #if VTK_MAJOR_VERSION > 8
157 renderWindow1->AddRenderer(renderer1);
158 _visualizer =
new pcl::visualization::PCLVisualizer(
167 _visualizer =
new pcl::visualization::PCLVisualizer(
179 _visualizer->createViewPort (0,0,1.0, 1.0, viewport);
180 _visualizer->createViewPort (0,0,1.0, 1.0, viewport);
181 _visualizer->createViewPort (0,0,1.0, 1.0, viewport);
182 _visualizer->getRendererCollection()->InitTraversal ();
183 vtkRenderer* renderer =
NULL;
185 while ((renderer =
_visualizer->getRendererCollection()->GetNextItem ()) !=
NULL)
187 renderer->SetLayer(
i);
190 #if VTK_MAJOR_VERSION >= 7
191 renderer->PreserveColorBufferOff();
193 renderer->PreserveDepthBufferOff();
194 _visualizer->getInteractorStyle()->SetDefaultRenderer(renderer);
198 #if VTK_MAJOR_VERSION >= 7
199 renderer->PreserveColorBufferOn();
201 renderer->PreserveDepthBufferOn();
205 _visualizer->getRenderWindow()->SetNumberOfLayers(4);
207 #ifdef VTK_GLOBAL_WARNING_DISPLAY_OFF
208 _visualizer->getRenderWindow()->GlobalWarningDisplayOff();
211 #if VTK_MAJOR_VERSION > 8
212 this->setRenderWindow(
_visualizer->getRenderWindow());
214 this->SetRenderWindow(
_visualizer->getRenderWindow());
219 #if VTK_MAJOR_VERSION > 8
221 this->interactor()->SetInteractorStyle (
_visualizer->getInteractorStyle());
224 this->GetInteractor()->SetInteractorStyle (
_visualizer->getInteractorStyle());
228 UDEBUG(
"pick tolerance=%f", pp->GetTolerance());
229 pp->SetTolerance (pp->GetTolerance()/2.0);
230 #if VTK_MAJOR_VERSION > 8
231 this->interactor()->SetPicker (pp);
233 this->GetInteractor()->SetPicker (pp);
250 setMouseTracking(
false);
293 QAction * freeCamera =
new QAction(
"Free",
this);
294 freeCamera->setCheckable(
true);
295 freeCamera->setChecked(
false);
338 #if VTK_MAJOR_VERSION < 7
357 QMenu * cameraMenu =
new QMenu(
"Camera",
this);
360 cameraMenu->addAction(freeCamera);
361 cameraMenu->addSeparator();
365 QActionGroup * group =
new QActionGroup(
this);
368 group->addAction(freeCamera);
370 QMenu * trajectoryMenu =
new QMenu(
"Trajectory",
this);
375 QMenu * frustumMenu =
new QMenu(
"Frustum",
this);
380 QMenu * gridMenu =
new QMenu(
"Grid",
this);
385 QMenu * normalsMenu =
new QMenu(
"Normals",
this);
390 QMenu * scanMenu =
new QMenu(
"Scan color",
this);
396 _menu =
new QMenu(
this);
397 _menu->addMenu(cameraMenu);
398 _menu->addMenu(trajectoryMenu);
401 _menu->addMenu(frustumMenu);
402 _menu->addMenu(gridMenu);
403 _menu->addMenu(normalsMenu);
404 _menu->addMenu(scanMenu);
419 settings.beginGroup(group);
422 float poseX, poseY, poseZ, focalX, focalY, focalZ, upX, upY, upZ;
423 this->
getCameraPosition(poseX, poseY, poseZ, focalX, focalY, focalZ, upX, upY, upZ);
424 QVector3D pose(poseX, poseY, poseZ);
425 QVector3D focal(focalX, focalY, focalZ);
438 pose = QVector3D(newPose.
x(), newPose.
y(), newPose.
z());
439 focal = QVector3D(newFocal.
x(), newFocal.
y(), newFocal.
z());
441 settings.setValue(
"camera_pose", pose);
442 settings.setValue(
"camera_focal", focal);
443 settings.setValue(
"camera_up", QVector3D(upX, upY, upZ));
484 settings.beginGroup(group);
487 float poseX, poseY, poseZ, focalX, focalY, focalZ, upX, upY, upZ;
488 this->
getCameraPosition(poseX, poseY, poseZ, focalX, focalY, focalZ, upX, upY, upZ);
489 QVector3D pose(poseX, poseY, poseZ), focal(focalX, focalY, focalZ), up(upX, upY, upZ);
490 pose = settings.value(
"camera_pose", pose).value<QVector3D>();
491 focal = settings.value(
"camera_focal", focal).value<QVector3D>();
492 up = settings.value(
"camera_up", up).value<QVector3D>();
494 this->
setCameraPosition(pose.x(),pose.y(),pose.z(), focal.x(),focal.y(),focal.z(), up.x(),up.y(),up.z());
498 this->
setGridCellSize(settings.value(
"grid_cell_size",
this->getGridCellSize()).toFloat());
515 this->
setFrustumScale(settings.value(
"frustum_scale",
this->getFrustumScale()).toDouble());
516 this->
setFrustumColor(settings.value(
"frustum_color",
this->getFrustumColor()).value<QColor>());
520 if(settings.value(
"camera_free",
this->isCameraFree()).toBool())
540 #if VTK_MAJOR_VERSION > 8
541 this->renderWindow()->Render();
548 const std::string &
id,
561 #if VTK_MAJOR_VERSION >= 7
565 pcl::visualization::ShapeActorMap::iterator am_it =
_visualizer->getShapeActorMap()->find (
id);
567 if (am_it !=
_visualizer->getShapeActorMap()->end ())
569 actor = vtkActor::SafeDownCast (am_it->second);
574 actor->SetUserMatrix (
matrix);
585 std::string idNormals =
id+
"-normals";
588 _visualizer->updatePointCloudPose(idNormals, posef);
600 typedef pcl::visualization::PointCloudColorHandler<pcl::PCLPointCloud2>::PointCloud
PointCloud;
610 pcl::visualization::PointCloudColorHandler<
pcl::PCLPointCloud2>::PointCloudColorHandler (cloud),
614 field_idx_ = pcl::getFieldIndex (*cloud,
"intensity");
615 if (field_idx_ != -1)
629 #if PCL_VERSION_COMPARE(>, 1, 11, 1)
632 if (!capable_ || !cloud_)
636 if (!capable_ || !cloud_)
641 scalars->SetNumberOfComponents (3);
643 vtkIdType nr_points = cloud_->width * cloud_->height;
645 float * intensities =
new float[nr_points];
647 size_t point_offset = cloud_->fields[field_idx_].offset;
651 int x_idx = pcl::getFieldIndex (*cloud_,
"x");
654 float x_data, y_data, z_data;
655 size_t x_point_offset = cloud_->fields[x_idx].offset;
658 for (vtkIdType cp = 0; cp < nr_points; ++cp,
659 point_offset += cloud_->point_step,
660 x_point_offset += cloud_->point_step)
663 memcpy (&intensity, &cloud_->data[point_offset], sizeof (
float));
665 memcpy (&x_data, &cloud_->data[x_point_offset], sizeof (
float));
666 memcpy (&y_data, &cloud_->data[x_point_offset + sizeof (
float)],
sizeof (
float));
667 memcpy (&z_data, &cloud_->data[x_point_offset + 2 * sizeof (
float)],
sizeof (
float));
672 intensities[
j++] = intensity;
679 for (vtkIdType cp = 0; cp < nr_points; ++cp, point_offset += cloud_->point_step)
682 memcpy (&intensity, &cloud_->data[point_offset], sizeof (
float));
684 intensities[
j++] = intensity;
690 unsigned char* colors =
new unsigned char[
j * 3];
700 for(
size_t k=0; k<
j; ++k)
702 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.0
f)):255;
712 colors[k*3+0] = r*255.0f;
713 colors[k*3+1] =
g*255.0f;
714 colors[k*3+2] =
b*255.0f;
717 reinterpret_cast<vtkUnsignedCharArray*
>(&(*scalars))->SetNumberOfTuples (
j);
718 reinterpret_cast<vtkUnsignedCharArray*
>(&(*scalars))->SetArray (colors,
j*3, 0, vtkUnsignedCharArray::VTK_DATA_ARRAY_DELETE);
721 reinterpret_cast<vtkUnsignedCharArray*
>(&(*scalars))->SetNumberOfTuples (0);
723 delete [] intensities;
724 #if PCL_VERSION_COMPARE(>, 1, 11, 1)
734 getName ()
const {
return (
"PointCloudColorHandlerIntensityField"); }
746 const std::string &
id,
747 const pcl::PCLPointCloud2Ptr & binaryCloud,
752 const QColor & color,
755 int previousColorIndex = -1;
756 if(_addedClouds.contains(
id))
758 previousColorIndex = _visualizer->getColorHandlerIndex(
id);
759 this->removeCloud(
id);
762 Eigen::Vector4f
origin(pose.
x(), pose.
y(), pose.
z(), 0.0f);
765 if(hasNormals && _aShowNormals->isChecked())
767 pcl::PointCloud<pcl::PointNormal>::Ptr cloud_xyz (
new pcl::PointCloud<pcl::PointNormal>);
768 pcl::fromPCLPointCloud2 (*binaryCloud, *cloud_xyz);
769 std::string idNormals =
id +
"-normals";
770 if(_visualizer->addPointCloudNormals<pcl::PointNormal>(cloud_xyz, _normalsStep, _normalsScale, idNormals, viewport))
772 _visualizer->updatePointCloudPose(idNormals, pose.
toEigen3f());
773 _addedClouds.insert(idNormals, pose);
778 pcl::visualization::PointCloudColorHandler<pcl::PCLPointCloud2>::Ptr colorHandler;
779 colorHandler.reset (
new pcl::visualization::PointCloudColorHandlerRandom<pcl::PCLPointCloud2> (binaryCloud));
780 if(_visualizer->addPointCloud (binaryCloud, colorHandler,
origin,
orientation,
id, viewport))
787 colorHandler.reset (
new pcl::visualization::PointCloudColorHandlerCustom<pcl::PCLPointCloud2> (binaryCloud,
c.red(),
c.green(),
c.blue()));
788 _visualizer->addPointCloud (binaryCloud, colorHandler,
origin,
orientation,
id, viewport);
791 colorHandler.reset (
new pcl::visualization::PointCloudColorHandlerGenericField<pcl::PCLPointCloud2> (binaryCloud,
"x"));
792 _visualizer->addPointCloud (binaryCloud, colorHandler,
origin,
orientation,
id, viewport);
793 colorHandler.reset (
new pcl::visualization::PointCloudColorHandlerGenericField<pcl::PCLPointCloud2> (binaryCloud,
"y"));
794 _visualizer->addPointCloud (binaryCloud, colorHandler,
origin,
orientation,
id, viewport);
795 colorHandler.reset (
new pcl::visualization::PointCloudColorHandlerGenericField<pcl::PCLPointCloud2> (binaryCloud,
"z"));
796 _visualizer->addPointCloud (binaryCloud, colorHandler,
origin,
orientation,
id, viewport);
801 colorHandler.reset(
new pcl::visualization::PointCloudColorHandlerRGBField<pcl::PCLPointCloud2>(binaryCloud));
802 _visualizer->addPointCloud (binaryCloud, colorHandler,
origin,
orientation,
id, viewport);
804 else if(hasIntensity)
807 colorHandler.reset(
new PointCloudColorHandlerIntensityField(binaryCloud, _intensityAbsMax, _aSetIntensityRedColormap->isChecked()?1:_aSetIntensityRainbowColormap->isChecked()?2:0));
808 _visualizer->addPointCloud (binaryCloud, colorHandler,
origin,
orientation,
id, viewport);
810 else if(previousColorIndex == 5)
812 previousColorIndex = -1;
818 colorHandler.reset (
new pcl::visualization::PointCloudColorHandlerGenericField<pcl::PCLPointCloud2> (binaryCloud,
"normal_x"));
819 _visualizer->addPointCloud (binaryCloud, colorHandler,
origin,
orientation,
id, viewport);
820 colorHandler.reset (
new pcl::visualization::PointCloudColorHandlerGenericField<pcl::PCLPointCloud2> (binaryCloud,
"normal_y"));
821 _visualizer->addPointCloud (binaryCloud, colorHandler,
origin,
orientation,
id, viewport);
822 colorHandler.reset (
new pcl::visualization::PointCloudColorHandlerGenericField<pcl::PCLPointCloud2> (binaryCloud,
"normal_z"));
823 _visualizer->addPointCloud (binaryCloud, colorHandler,
origin,
orientation,
id, viewport);
825 else if(previousColorIndex > 5)
827 previousColorIndex = -1;
830 if(previousColorIndex>=0)
832 _visualizer->updateColorHandlerIndex(
id, previousColorIndex);
836 _visualizer->updateColorHandlerIndex(
id, 5);
840 _visualizer->updateColorHandlerIndex(
id, hasIntensity?8:7);
842 else if(hasIntensity)
844 _visualizer->updateColorHandlerIndex(
id, 5);
846 else if(color.isValid())
848 _visualizer->updateColorHandlerIndex(
id, 1);
851 _addedClouds.insert(
id, pose);
858 const std::string &
id,
859 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
861 const QColor & color)
863 pcl::PCLPointCloud2Ptr binaryCloud(
new pcl::PCLPointCloud2);
864 pcl::toPCLPointCloud2(*cloud, *binaryCloud);
865 return addCloud(
id, binaryCloud, pose,
true,
true,
false, color);
869 const std::string &
id,
870 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
872 const QColor & color)
874 pcl::PCLPointCloud2Ptr binaryCloud(
new pcl::PCLPointCloud2);
875 pcl::toPCLPointCloud2(*cloud, *binaryCloud);
876 return addCloud(
id, binaryCloud, pose,
true,
false,
false, color);
880 const std::string &
id,
881 const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
883 const QColor & color)
885 pcl::PCLPointCloud2Ptr binaryCloud(
new pcl::PCLPointCloud2);
886 pcl::toPCLPointCloud2(*cloud, *binaryCloud);
887 return addCloud(
id, binaryCloud, pose,
false,
true,
true, color);
891 const std::string &
id,
892 const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
894 const QColor & color)
896 pcl::PCLPointCloud2Ptr binaryCloud(
new pcl::PCLPointCloud2);
897 pcl::toPCLPointCloud2(*cloud, *binaryCloud);
898 return addCloud(
id, binaryCloud, pose,
false,
false,
true, color);
902 const std::string &
id,
903 const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
905 const QColor & color)
907 pcl::PCLPointCloud2Ptr binaryCloud(
new pcl::PCLPointCloud2);
908 pcl::toPCLPointCloud2(*cloud, *binaryCloud);
909 return addCloud(
id, binaryCloud, pose,
false,
true,
false, color);
913 const std::string &
id,
914 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
916 const QColor & color)
918 pcl::PCLPointCloud2Ptr binaryCloud(
new pcl::PCLPointCloud2);
919 pcl::toPCLPointCloud2(*cloud, *binaryCloud);
920 return addCloud(
id, binaryCloud, pose,
false,
false,
false, color);
924 const std::string &
id,
925 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
926 const std::vector<pcl::Vertices> & polygons,
929 if(_addedClouds.contains(
id))
931 this->removeCloud(
id);
934 UDEBUG(
"Adding %s with %d points and %d polygons",
id.
c_str(), (
int)cloud->size(), (
int)polygons.size());
935 if(_visualizer->addPolygonMesh<pcl::PointXYZ>(cloud, polygons,
id, 1))
937 #if VTK_MAJOR_VERSION >= 7
938 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetAmbient(0.1);
940 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetAmbient(0.5);
942 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetLighting(_aSetLighting->isChecked());
943 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetInterpolation(_aSetFlatShading->isChecked()?VTK_FLAT:VTK_PHONG);
944 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked());
945 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetBackfaceCulling(_aBackfaceCulling->isChecked());
946 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetFrontfaceCulling(_frontfaceCulling);
947 _visualizer->updatePointCloudPose(
id, pose.
toEigen3f());
951 tree->SetDataSet(_visualizer->getCloudActorMap()->find(
id)->second.actor->GetMapper()->GetInput());
952 tree->BuildLocator();
953 _locators.insert(std::make_pair(
id,
tree));
955 _addedClouds.insert(
id, pose);
962 const std::string &
id,
963 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
964 const std::vector<pcl::Vertices> & polygons,
967 if(_addedClouds.contains(
id))
969 this->removeCloud(
id);
972 UDEBUG(
"Adding %s with %d points and %d polygons",
id.
c_str(), (
int)cloud->size(), (
int)polygons.size());
973 if(_visualizer->addPolygonMesh<pcl::PointXYZRGB>(cloud, polygons,
id, 1))
975 #if VTK_MAJOR_VERSION >= 7
976 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetAmbient(0.1);
978 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetAmbient(0.5);
980 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetLighting(_aSetLighting->isChecked());
981 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetInterpolation(_aSetFlatShading->isChecked()?VTK_FLAT:VTK_PHONG);
982 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked());
983 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetBackfaceCulling(_aBackfaceCulling->isChecked());
984 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetFrontfaceCulling(_frontfaceCulling);
985 _visualizer->updatePointCloudPose(
id, pose.
toEigen3f());
989 tree->SetDataSet(_visualizer->getCloudActorMap()->find(
id)->second.actor->GetMapper()->GetInput());
990 tree->BuildLocator();
991 _locators.insert(std::make_pair(
id,
tree));
993 _addedClouds.insert(
id, pose);
1000 const std::string &
id,
1001 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
1002 const std::vector<pcl::Vertices> & polygons,
1005 if(_addedClouds.contains(
id))
1007 this->removeCloud(
id);
1010 UDEBUG(
"Adding %s with %d points and %d polygons",
id.
c_str(), (
int)cloud->size(), (
int)polygons.size());
1011 if(_visualizer->addPolygonMesh<pcl::PointXYZRGBNormal>(cloud, polygons,
id, 1))
1013 #if VTK_MAJOR_VERSION >= 7
1014 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetAmbient(0.1);
1016 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetAmbient(0.5);
1018 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetLighting(_aSetLighting->isChecked());
1019 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetInterpolation(_aSetFlatShading->isChecked()?VTK_FLAT:VTK_PHONG);
1020 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked());
1021 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetBackfaceCulling(_aBackfaceCulling->isChecked());
1022 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetFrontfaceCulling(_frontfaceCulling);
1023 _visualizer->updatePointCloudPose(
id, pose.
toEigen3f());
1027 tree->SetDataSet(_visualizer->getCloudActorMap()->find(
id)->second.actor->GetMapper()->GetInput());
1028 tree->BuildLocator();
1029 _locators.insert(std::make_pair(
id,
tree));
1031 _addedClouds.insert(
id, pose);
1038 const std::string &
id,
1039 const pcl::PolygonMesh::Ptr & mesh,
1042 if(_addedClouds.contains(
id))
1044 this->removeCloud(
id);
1047 UDEBUG(
"Adding %s with %d polygons",
id.
c_str(), (
int)mesh->polygons.size());
1048 if(_visualizer->addPolygonMesh(*mesh,
id, 1))
1050 #if VTK_MAJOR_VERSION >= 7
1051 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetAmbient(0.1);
1053 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetAmbient(0.5);
1055 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetLighting(_aSetLighting->isChecked());
1056 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked());
1057 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetBackfaceCulling(_aBackfaceCulling->isChecked());
1058 _visualizer->getCloudActorMap()->find(
id)->second.actor->GetProperty()->SetFrontfaceCulling(_frontfaceCulling);
1059 _visualizer->updatePointCloudPose(
id, pose.
toEigen3f());
1063 tree->SetDataSet(_visualizer->getCloudActorMap()->find(
id)->second.actor->GetMapper()->GetInput());
1064 tree->BuildLocator();
1065 _locators.insert(std::make_pair(
id,
tree));
1067 _addedClouds.insert(
id, pose);
1075 const std::string &
id,
1076 const pcl::TextureMesh::Ptr & textureMesh,
1077 const cv::Mat & texture,
1080 if(_addedClouds.contains(
id))
1082 this->removeCloud(
id);
1086 if(this->addTextureMesh(*textureMesh, texture,
id, 1))
1088 #if VTK_MAJOR_VERSION >= 7
1089 vtkActor* actor = vtkActor::SafeDownCast (_visualizer->getShapeActorMap()->find(
id)->second);
1091 vtkActor* actor = vtkActor::SafeDownCast (_visualizer->getCloudActorMap()->find(
id)->second.actor);
1094 if(!textureMesh->cloud.is_dense)
1096 actor->GetTexture()->SetInterpolate(1);
1097 actor->GetTexture()->SetBlendingMode(vtkTexture::VTK_TEXTURE_BLENDING_MODE_REPLACE);
1102 tree->SetDataSet(actor->GetMapper()->GetInput());
1103 tree->BuildLocator();
1104 _locators.insert(std::make_pair(
id,
tree));
1107 this->updateCloudPose(
id, pose);
1116 #ifdef RTABMAP_OCTOMAP
1119 if(treeDepth == 0 || treeDepth > octomap->
octree()->getTreeDepth())
1123 UWARN(
"Tree depth requested (%d) is deeper than the "
1124 "actual maximum tree depth of %d. Using maximum depth.",
1125 (
int)treeDepth, (
int)octomap->
octree()->getTreeDepth());
1127 treeDepth = octomap->
octree()->getTreeDepth();
1132 if(!volumeRepresentation)
1134 pcl::IndicesPtr obstacles(
new std::vector<int>);
1135 pcl::IndicesPtr ground(
new std::vector<int>);
1137 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud = octomap->
createCloud(
1138 treeDepth, obstacles.get(), 0, ground.get(),
false);
1139 obstacles->insert(obstacles->end(), ground->begin(), ground->end());
1140 if(obstacles->size())
1146 colors->SetName(
"colors");
1147 colors->SetNumberOfValues(obstacles->size());
1150 lut->SetNumberOfTableValues(obstacles->size());
1155 points->SetNumberOfPoints(obstacles->size());
1156 double s = octomap->
octree()->getNodeSize(treeDepth) / 2.0;
1157 for (
unsigned int i = 0;
i < obstacles->size();
i++)
1159 points->InsertPoint(
i,
1160 cloud->at(obstacles->at(
i)).x,
1161 cloud->at(obstacles->at(
i)).y,
1162 cloud->at(obstacles->at(
i)).z);
1163 colors->InsertValue(
i,
i);
1165 lut->SetTableValue(
i,
1166 double(cloud->at(obstacles->at(
i)).r) / 255.0,
1167 double(cloud->at(obstacles->at(
i)).g) / 255.0,
1168 double(cloud->at(obstacles->at(
i)).b) / 255.0);
1173 polydata->SetPoints(points);
1174 polydata->GetPointData()->SetScalars(colors);
1178 cubeSource->SetBounds(-
s,
s, -
s,
s, -
s,
s);
1181 mapper->SetSourceConnection(cubeSource->GetOutputPort());
1182 #if VTK_MAJOR_VERSION <= 5
1183 mapper->SetInputConnection(polydata->GetProducerPort());
1185 mapper->SetInputData(polydata);
1187 mapper->SetScalarRange(0, obstacles->size() - 1);
1188 mapper->SetLookupTable(lut);
1189 mapper->ScalingOff();
1193 octomapActor->SetMapper(mapper);
1195 octomapActor->GetProperty()->SetRepresentationToSurface();
1196 octomapActor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked());
1197 octomapActor->GetProperty()->SetLighting(_aSetLighting->isChecked());
1199 _visualizer->getRendererCollection()->InitTraversal ();
1200 vtkRenderer* renderer =
NULL;
1201 renderer = _visualizer->getRendererCollection()->GetNextItem ();
1202 renderer = _visualizer->getRendererCollection()->GetNextItem ();
1204 renderer->AddActor(octomapActor);
1206 _octomapActor = octomapActor.GetPointer();
1212 if(octomap->
octree()->size())
1218 double sizeX, sizeY, sizeZ;
1219 double minX, minY, minZ;
1220 double maxX, maxY, maxZ;
1226 double cellSize = octomap->
octree()->getNodeSize(treeDepth);
1230 imageData->SetExtent(0,
int(sizeX/cellSize+0.5), 0,
int(sizeY/cellSize+0.5), 0,
int(sizeZ/cellSize+0.5));
1231 #if VTK_MAJOR_VERSION <= 5
1232 imageData->SetNumberOfScalarComponents(4);
1233 imageData->SetScalarTypeToUnsignedChar();
1235 imageData->AllocateScalars(VTK_UNSIGNED_CHAR,4);
1239 imageData->GetDimensions(dims);
1241 memset(imageData->GetScalarPointer(), 0, imageData->GetScalarSize()*imageData->GetNumberOfScalarComponents()*dims[0]*dims[1]*dims[2]);
1243 for (RtabmapColorOcTree::iterator it = octomap->
octree()->begin(treeDepth); it != octomap->
octree()->end(); ++it)
1245 if(octomap->
octree()->isNodeOccupied(*it))
1247 octomap::point3d pt = octomap->
octree()->keyToCoord(it.getKey());
1248 int x = (pt.x()-minX) / cellSize;
1249 int y = (pt.y()-minY) / cellSize;
1250 int z = (pt.z()-minZ) / cellSize;
1251 if(
x>=0 &&
x<dims[0] &&
y>=0 &&
y<dims[1] &&
z>=0 &&
z<dims[2])
1253 unsigned char* pixel =
static_cast<unsigned char*
>(imageData->GetScalarPointer(
x,
y,
z));
1254 if(octomap->
octree()->getTreeDepth() == it.getDepth() && it->isColorSet())
1256 pixel[0] = it->getColor().r;
1257 pixel[1] = it->getColor().g;
1258 pixel[2] = it->getColor().b;
1263 float H = (maxZ - pt.z())*299.0
f/(maxZ-minZ);
1266 pixel[0] = r*255.0f;
1267 pixel[1] =
g*255.0f;
1268 pixel[2] =
b*255.0f;
1276 volumeMapper->SetBlendModeToComposite();
1277 #if VTK_MAJOR_VERSION <= 5
1278 volumeMapper->SetInputConnection(imageData->GetProducerPort());
1280 volumeMapper->SetInputData(imageData);
1284 volumeProperty->ShadeOff();
1285 volumeProperty->IndependentComponentsOff();
1289 compositeOpacity->AddPoint(0.0,0.0);
1290 compositeOpacity->AddPoint(255.0,1.0);
1291 volumeProperty->SetScalarOpacity(0, compositeOpacity);
1295 volume->SetMapper(volumeMapper);
1296 volume->SetProperty(volumeProperty);
1297 volume->SetScale(cellSize);
1298 volume->SetPosition(minX, minY, minZ);
1300 _visualizer->getRendererCollection()->InitTraversal ();
1301 vtkRenderer* renderer =
NULL;
1302 renderer = _visualizer->getRendererCollection()->GetNextItem ();
1303 renderer = _visualizer->getRendererCollection()->GetNextItem ();
1305 renderer->AddViewProp(volume);
1308 #if !defined(VTK_LEGACY_REMOVE) && !defined(VTK_OPENGL2) && VTK_MAJOR_VERSION < 9
1309 volumeMapper->SetRequestedRenderModeToRayCastAndTexture();
1310 #endif // VTK_LEGACY_REMOVE
1314 volumeMapper->SetRequestedRenderModeToRayCast();
1315 _octomapActor = volume.GetPointer();
1327 #ifdef RTABMAP_OCTOMAP
1330 _visualizer->getRendererCollection()->InitTraversal ();
1331 vtkRenderer* renderer =
NULL;
1332 renderer = _visualizer->getRendererCollection()->GetNextItem ();
1333 renderer = _visualizer->getRendererCollection()->GetNextItem ();
1335 renderer->RemoveActor(_octomapActor);
1342 const pcl::TextureMesh &mesh,
1343 const cv::Mat & image,
1344 const std::string &
id,
1349 #if VTK_MAJOR_VERSION >= 7
1350 pcl::visualization::ShapeActorMap::iterator am_it = _visualizer->getShapeActorMap()->find (
id);
1351 if (am_it != _visualizer->getShapeActorMap()->end ())
1353 pcl::visualization::CloudActorMap::iterator am_it = _visualizer->getCloudActorMap()->find (
id);
1354 if (am_it != _visualizer->getCloudActorMap()->end ())
1357 PCL_ERROR (
"[PCLVisualizer::addTextureMesh] A shape with id <%s> already exists!"
1358 " Please choose a different id and retry.\n",
1363 if (mesh.tex_materials.size () == 0)
1365 PCL_ERROR(
"[PCLVisualizer::addTextureMesh] No textures found!\n");
1368 else if (mesh.tex_materials.size() > 1)
1370 PCL_ERROR(
"[PCLVisualizer::addTextureMesh] only one material per mesh is supported!\n");
1374 if (mesh.tex_materials.size () != mesh.tex_polygons.size ())
1376 PCL_ERROR(
"[PCLVisualizer::addTextureMesh] Materials number %lu differs from polygons number %lu!\n",
1377 mesh.tex_materials.size (), mesh.tex_polygons.size ());
1381 if (mesh.tex_materials.size () != mesh.tex_coordinates.size ())
1383 PCL_ERROR(
"[PCLVisualizer::addTextureMesh] Coordinates number %lu differs from materials number %lu!\n",
1384 mesh.tex_coordinates.size (), mesh.tex_materials.size ());
1388 std::size_t nb_vertices = 0;
1389 for (std::size_t
i = 0;
i < mesh.tex_polygons.size (); ++
i)
1390 nb_vertices+= mesh.tex_polygons[
i].size ();
1392 if (nb_vertices == 0)
1394 PCL_ERROR(
"[PCLVisualizer::addTextureMesh] No vertices found!\n");
1398 std::size_t nb_coordinates = 0;
1399 for (std::size_t
i = 0;
i < mesh.tex_coordinates.size (); ++
i)
1400 nb_coordinates+= mesh.tex_coordinates[
i].size ();
1402 if (nb_coordinates == 0)
1404 PCL_ERROR(
"[PCLVisualizer::addTextureMesh] No textures coordinates found!\n");
1411 bool has_color =
false;
1414 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (
new pcl::PointCloud<pcl::PointXYZ> ());
1415 pcl::fromPCLPointCloud2 (mesh.cloud, *cloud);
1417 if (cloud->points.size () == 0)
1419 PCL_ERROR(
"[PCLVisualizer::addTextureMesh] Cloud is empty!\n");
1422 pcl::visualization::PCLVisualizer::convertToVtkMatrix (cloud->sensor_origin_, cloud->sensor_orientation_,
transformation);
1423 poly_points->SetNumberOfPoints (cloud->points.size ());
1424 for (std::size_t
i = 0;
i < cloud->points.size (); ++
i)
1426 const pcl::PointXYZ &
p = cloud->points[
i];
1427 poly_points->InsertPoint (
i,
p.x,
p.y,
p.z);
1432 for (std::size_t
i = 0;
i < mesh.tex_polygons.size ();
i++)
1434 for (std::size_t
j = 0;
j < mesh.tex_polygons[
i].size ();
j++)
1436 std::size_t n_points = mesh.tex_polygons[
i][
j].vertices.size ();
1437 polys->InsertNextCell (
int (n_points));
1438 for (std::size_t k = 0; k < n_points; k++)
1439 polys->InsertCellPoint (mesh.tex_polygons[
i][
j].vertices[k]);
1444 polydata->SetPolys (polys);
1445 polydata->SetPoints (poly_points);
1447 polydata->GetPointData()->SetScalars(colors);
1450 #if VTK_MAJOR_VERSION < 6
1451 mapper->SetInput (polydata);
1453 mapper->SetInputData (polydata);
1456 #if VTK_MAJOR_VERSION >= 7
1461 vtkTextureUnitManager* tex_manager = vtkOpenGLRenderWindow::SafeDownCast (_visualizer->getRenderWindow())->GetTextureUnitManager ();
1468 cvImageToVtk->SetImage(image);
1469 cvImageToVtk->Update();
1470 texture->SetInputConnection(cvImageToVtk->GetOutputPort());
1474 coordinates->SetNumberOfComponents (2);
1475 coordinates->SetNumberOfTuples (mesh.tex_coordinates[0].size ());
1476 for (std::size_t tc = 0; tc < mesh.tex_coordinates[0].size (); ++tc)
1478 const Eigen::Vector2f &uv = mesh.tex_coordinates[0][tc];
1479 coordinates->SetTuple2 (tc, (
double)uv[0], (
double)uv[1]);
1481 coordinates->SetName (
"TCoords");
1482 polydata->GetPointData ()->SetTCoords(coordinates);
1484 actor->SetTexture (texture);
1487 actor->SetMapper (mapper);
1491 _visualizer->getRendererCollection()->InitTraversal ();
1492 vtkRenderer* renderer =
NULL;
1494 while ((renderer = _visualizer->getRendererCollection()->GetNextItem ()) !=
NULL)
1499 renderer->AddActor (actor);
1501 else if (viewport ==
i)
1503 renderer->AddActor (actor);
1509 #if VTK_MAJOR_VERSION >= 7
1510 (*_visualizer->getShapeActorMap())[
id] = actor;
1512 (*_visualizer->getCloudActorMap())[
id].actor = actor;
1514 (*_visualizer->getCloudActorMap())[
id].viewpoint_transformation_ =
transformation;
1517 #if VTK_MAJOR_VERSION >= 7
1518 actor->GetProperty()->SetAmbient(0.1);
1520 actor->GetProperty()->SetAmbient(0.5);
1522 actor->GetProperty()->SetLighting(_aSetLighting->isChecked());
1523 actor->GetProperty()->SetInterpolation(_aSetFlatShading->isChecked()?VTK_FLAT:VTK_PHONG);
1524 actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked());
1525 actor->GetProperty()->SetBackfaceCulling(_aBackfaceCulling->isChecked());
1526 actor->GetProperty()->SetFrontfaceCulling(_frontfaceCulling);
1531 const cv::Mat & map8U,
1537 UASSERT(map8U.channels() == 1 && map8U.type() == CV_8U);
1539 float xSize =
float(map8U.cols) * resolution;
1540 float ySize =
float(map8U.rows) * resolution;
1542 UDEBUG(
"resolution=%f, xSize=%f, ySize=%f, xMin=%f, yMin=%f", resolution, xSize, ySize, xMin, yMin);
1543 #if VTK_MAJOR_VERSION >= 7
1544 if(_visualizer->getShapeActorMap()->find(
"map") != _visualizer->getShapeActorMap()->end())
1546 _visualizer->removeShape(
"map");
1549 if(_visualizer->getCloudActorMap()->find(
"map") != _visualizer->getCloudActorMap()->end())
1551 _visualizer->removePointCloud(
"map");
1555 if(xSize > 0.0
f && ySize > 0.0
f)
1557 pcl::TextureMeshPtr mesh(
new pcl::TextureMesh());
1558 pcl::PointCloud<pcl::PointXYZ> cloud;
1559 cloud.push_back(pcl::PointXYZ(xMin, yMin, 0));
1560 cloud.push_back(pcl::PointXYZ(xSize+xMin, yMin, 0));
1561 cloud.push_back(pcl::PointXYZ(xSize+xMin, ySize+yMin, 0));
1562 cloud.push_back(pcl::PointXYZ(xMin, ySize+yMin, 0));
1563 pcl::toPCLPointCloud2(cloud, mesh->cloud);
1565 std::vector<pcl::Vertices> polygons(1);
1566 polygons[0].vertices.push_back(0);
1567 polygons[0].vertices.push_back(1);
1568 polygons[0].vertices.push_back(2);
1569 polygons[0].vertices.push_back(3);
1570 polygons[0].vertices.push_back(0);
1571 mesh->tex_polygons.push_back(polygons);
1576 mesh->tex_materials.push_back(
material);
1578 #if PCL_VERSION_COMPARE(>=, 1, 8, 0)
1579 std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > coordinates;
1581 std::vector<Eigen::Vector2f> coordinates;
1583 coordinates.push_back(Eigen::Vector2f(0,1));
1584 coordinates.push_back(Eigen::Vector2f(1,1));
1585 coordinates.push_back(Eigen::Vector2f(1,0));
1586 coordinates.push_back(Eigen::Vector2f(0,0));
1587 mesh->tex_coordinates.push_back(coordinates);
1589 this->addTextureMesh(*mesh, map8U,
"map", 1);
1590 setCloudOpacity(
"map", opacity);
1597 #if VTK_MAJOR_VERSION >= 7
1598 if(_visualizer->getShapeActorMap()->find(
"map") != _visualizer->getShapeActorMap()->end())
1600 _visualizer->removeShape(
"map");
1603 if(_visualizer->getCloudActorMap()->find(
"map") != _visualizer->getCloudActorMap()->end())
1605 _visualizer->removePointCloud(
"map");
1611 const cv::Mat & map32FC1,
1617 if(_visualizer->getShapeActorMap()->find(
"elevation_map") != _visualizer->getShapeActorMap()->end())
1619 _visualizer->removeShape(
"elevation_map");
1624 for (
int y = 0;
y < map32FC1.rows; ++
y)
1626 const float * previousRow =
y>0?map32FC1.ptr<
float>(
y-1):0;
1627 const float * rowPtr = map32FC1.ptr<
float>(
y);
1628 for (
int x = 0;
x < map32FC1.cols; ++
x)
1630 gridPoints->InsertNextPoint(xMin +
x*resolution, yMin +
y*resolution, rowPtr[
x]);
1634 previousRow[
x] != 0 &&
1635 previousRow[
x-1] != 0)
1637 gridCells->InsertNextCell(4);
1638 gridCells->InsertCellPoint(
x-1+
y*map32FC1.cols);
1639 gridCells->InsertCellPoint(
x+
y*map32FC1.cols);
1640 gridCells->InsertCellPoint(
x+(
y-1)*map32FC1.cols);
1641 gridCells->InsertCellPoint(
x-1+(
y-1)*map32FC1.cols);
1647 gridPoints->GetBounds(bounds);
1650 polyData->SetPoints(gridPoints);
1651 polyData->SetPolys(gridCells);
1654 elevationFilter->SetInputData(polyData);
1655 elevationFilter->SetLowPoint(0.0, 0.0, bounds[4]);
1656 elevationFilter->SetHighPoint(0.0, 0.0, bounds[5]);
1657 elevationFilter->Update();
1660 output->ShallowCopy(
dynamic_cast<vtkPolyData*
>(elevationFilter->GetOutput()));
1662 vtkFloatArray* elevation =
dynamic_cast<vtkFloatArray*
>(
1663 output->GetPointData()->GetArray(
"Elevation"));
1667 colorLookupTable->SetTableRange(bounds[4], bounds[5]);
1668 colorLookupTable->Build();
1672 colors->SetNumberOfComponents(3);
1673 colors->SetName(
"Colors");
1675 for (vtkIdType
i = 0;
i < output->GetNumberOfPoints();
i++)
1677 double val = elevation->GetValue(
i);
1679 colorLookupTable->GetColor(val, dcolor);
1680 unsigned char color[3];
1681 for (
unsigned int j = 0;
j < 3;
j++)
1683 color[
j] = 255 * dcolor[
j] / 1.0;
1686 #if VTK_MAJOR_VERSION > 7 || (VTK_MAJOR_VERSION==7 && VTK_MINOR_VERSION >= 1)
1687 colors->InsertNextTypedTuple(color);
1689 colors->InsertNextTupleValue(color);
1694 output->GetPointData()->AddArray(colors);
1697 mapper->SetInputData(output);
1700 actor->SetMapper(mapper);
1703 _visualizer->getRendererCollection()->InitTraversal ();
1704 vtkRenderer* renderer =
NULL;
1707 while ((renderer = _visualizer->getRendererCollection()->GetNextItem ()) !=
NULL)
1712 renderer->AddActor (actor);
1714 else if (viewport ==
i)
1716 renderer->AddActor (actor);
1721 (*_visualizer->getShapeActorMap())[
"elevation_map"] = actor;
1723 setCloudOpacity(
"elevation_map", opacity);
1729 if(_visualizer->getShapeActorMap()->find(
"elevation_map") != _visualizer->getShapeActorMap()->end())
1731 _visualizer->removeShape(
"elevation_map");
1736 const std::string &
id,
1743 UERROR(
"id should not be empty!");
1747 removeCoordinate(
id);
1751 _coordinates.insert(
id);
1752 #if PCL_VERSION_COMPARE(>=, 1, 7, 2)
1753 _visualizer->addCoordinateSystem(
scale*_coordinateFrameScale,
transform.toEigen3f(),
id, foreground?3:2);
1756 _visualizer->addCoordinateSystem(
scale*_coordinateFrameScale,
transform.toEigen3f(), 0);
1762 const std::string &
id,
1765 #if PCL_VERSION_COMPARE(>=, 1, 7, 2)
1766 if(_coordinates.find(
id) != _coordinates.end() && !pose.
isNull())
1769 return _visualizer->updateCoordinateSystemPose(
id, pose.
toEigen3f());
1772 UERROR(
"CloudViewer::updateCoordinatePose() is not available on PCL < 1.7.2");
1781 UERROR(
"id should not be empty!");
1785 if(_coordinates.find(
id) != _coordinates.end())
1787 #if PCL_VERSION_COMPARE(>=, 1, 7, 2)
1788 _visualizer->removeCoordinateSystem(
id);
1791 _visualizer->removeCoordinateSystem(0);
1793 _coordinates.erase(
id);
1799 std::set<std::string> coordinates = _coordinates;
1800 for(std::set<std::string>::iterator
iter = coordinates.begin();
iter!=coordinates.end(); ++
iter)
1802 if(prefix.empty() ||
iter->find(prefix) != std::string::npos)
1804 this->removeCoordinate(*
iter);
1807 UASSERT(!prefix.empty() || _coordinates.empty());
1811 const std::string &
id,
1814 const QColor & color,
1820 UERROR(
"id should not be empty!");
1830 QColor
c = Qt::gray;
1836 pcl::PointXYZ pt1(from.
x(), from.
y(), from.
z());
1837 pcl::PointXYZ pt2(to.
x(), to.
y(), to.
z());
1841 _visualizer->addArrow(pt2, pt1,
c.redF(),
c.greenF(),
c.blueF(),
false,
id, foreground?3:2);
1845 _visualizer->addLine(pt2, pt1,
c.redF(),
c.greenF(),
c.blueF(),
id, foreground?3:2);
1847 _visualizer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_OPACITY,
c.alphaF(),
id);
1855 UERROR(
"id should not be empty!");
1859 if(_lines.find(
id) != _lines.end())
1861 _visualizer->removeShape(
id);
1868 std::set<std::string> arrows = _lines;
1869 for(std::set<std::string>::iterator
iter = arrows.begin();
iter!=arrows.end(); ++
iter)
1871 this->removeLine(*
iter);
1877 const std::string &
id,
1880 const QColor & color,
1885 UERROR(
"id should not be empty!");
1893 _spheres.insert(
id);
1895 QColor
c = Qt::gray;
1901 pcl::PointXYZ center(pose.
x(), pose.
y(), pose.
z());
1902 _visualizer->addSphere(center, radius,
c.redF(),
c.greenF(),
c.blueF(),
id, foreground?3:2);
1903 _visualizer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_OPACITY,
c.alphaF(),
id);
1911 UERROR(
"id should not be empty!");
1915 if(_spheres.find(
id) != _spheres.end())
1917 _visualizer->removeShape(
id);
1924 std::set<std::string> spheres = _spheres;
1925 for(std::set<std::string>::iterator
iter = spheres.begin();
iter!=spheres.end(); ++
iter)
1927 this->removeSphere(*
iter);
1933 const std::string &
id,
1938 const QColor & color,
1944 UERROR(
"id should not be empty!");
1954 QColor
c = Qt::gray;
1959 _visualizer->addCube(Eigen::Vector3f(pose.
x(), pose.
y(), pose.
z()), pose.
getQuaternionf(), width, height, depth,
id, foreground?3:2);
1962 _visualizer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_REPRESENTATION, pcl::visualization::PCL_VISUALIZER_REPRESENTATION_WIREFRAME,
id);
1964 _visualizer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR,
c.redF(),
c.greenF(),
c.blueF(),
id);
1965 _visualizer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_OPACITY,
c.alphaF(),
id);
1973 UERROR(
"id should not be empty!");
1977 if(_cubes.find(
id) != _cubes.end())
1979 _visualizer->removeShape(
id);
1986 std::set<std::string> cubes = _cubes;
1987 for(std::set<std::string>::iterator
iter = cubes.begin();
iter!=cubes.end(); ++
iter)
1989 this->removeCube(*
iter);
1995 const std::string &
id,
1999 const QColor & color,
2002 addOrUpdateQuad(
id, pose, width/2.0
f, width/2.0
f, height/2.0
f, height/2.0
f, color, foreground);
2006 const std::string &
id,
2012 const QColor & color,
2017 UERROR(
"id should not be empty!");
2027 QColor
c = Qt::gray;
2034 double p0[3] = {0.0, -widthLeft, heightTop};
2035 double p1[3] = {0.0, -widthLeft, -heightBottom};
2036 double p2[3] = {0.0, widthRight, -heightBottom};
2037 double p3[3] = {0.0, widthRight, heightTop};
2042 points->InsertNextPoint(
p0);
2043 points->InsertNextPoint(
p1);
2044 points->InsertNextPoint(
p2);
2045 points->InsertNextPoint(
p3);
2050 quad->GetPointIds()->SetId(0,0);
2051 quad->GetPointIds()->SetId(1,1);
2052 quad->GetPointIds()->SetId(2,2);
2053 quad->GetPointIds()->SetId(3,3);
2058 quads->InsertNextCell(quad);
2065 polydata->SetPoints(points);
2066 polydata->SetPolys(quads);
2071 #if VTK_MAJOR_VERSION <= 5
2072 mapper->SetInput(polydata);
2074 mapper->SetInputData(polydata);
2079 actor->SetMapper(mapper);
2080 actor->GetProperty()->SetColor(
c.redF(),
c.greenF(),
c.blueF());
2084 _visualizer->getRendererCollection()->InitTraversal ();
2085 vtkRenderer* renderer =
NULL;
2087 while ((renderer = _visualizer->getRendererCollection()->GetNextItem ()) !=
NULL)
2089 if ((foreground?3:2) ==
i)
2091 renderer->AddActor (actor);
2097 (*_visualizer->getCloudActorMap())[
id].actor = actor;
2102 (*_visualizer->getCloudActorMap())[
id].viewpoint_transformation_ =
transformation;
2103 (*_visualizer->getCloudActorMap())[
id].actor->SetUserMatrix (
transformation);
2104 (*_visualizer->getCloudActorMap())[
id].actor->Modified ();
2106 (*_visualizer->getCloudActorMap())[
id].actor->GetProperty()->SetLighting(
false);
2107 _visualizer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_OPACITY,
c.alphaF(),
id);
2115 UERROR(
"id should not be empty!");
2119 if(_quads.find(
id) != _quads.end())
2121 _visualizer->removeShape(
id);
2128 std::set<std::string> quads = _quads;
2129 for(std::set<std::string>::iterator
iter = quads.begin();
iter!=quads.end(); ++
iter)
2131 this->removeQuad(*
iter);
2144 1, 2, 3, 4, 1, 0, 2, 0, 3, 0, 4};
2147 const std::string &
id,
2151 const QColor & color,
2157 UERROR(
"id should not be empty!");
2161 #if PCL_VERSION_COMPARE(<, 1, 7, 2)
2162 this->removeFrustum(
id);
2167 if(_frustums.find(
id)==_frustums.end())
2172 UASSERT(frustumSize>0 && frustumSize % 3 == 0);
2174 pcl::PointCloud<pcl::PointXYZ> frustumPoints;
2175 frustumPoints.resize(frustumSize);
2176 float scaleX =
tan((fovX>0?fovX:1.1)/2.0
f) *
scale;
2177 float scaleY =
tan((fovY>0?fovY:0.85)/2.0
f) *
scale;
2178 float scaleZ =
scale;
2179 QColor
c = Qt::gray;
2184 Transform opticalRotInv(0, -1, 0, 0, 0, 0, -1, 0, 1, 0, 0, 0);
2186 #if PCL_VERSION_COMPARE(<, 1, 7, 2)
2191 for(
int i=0;
i<frustumSize; ++
i)
2199 pcl::PolygonMesh mesh;
2202 for(
unsigned int i=0;
i<
vertices.vertices.size(); ++
i)
2206 pcl::toPCLPointCloud2(frustumPoints, mesh.cloud);
2208 _visualizer->addPolylineFromPolygonMesh(mesh,
id, 2);
2209 _visualizer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR,
c.redF(),
c.greenF(),
c.blueF(),
id);
2210 _visualizer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_OPACITY,
c.alphaF(),
id);
2212 #if PCL_VERSION_COMPARE(>=, 1, 7, 2)
2213 if(!this->updateFrustumPose(
id, pose))
2215 UERROR(
"Failed updating pose of frustum %s!?",
id.
c_str());
2226 const std::string &
id,
2229 #if PCL_VERSION_COMPARE(>=, 1, 7, 2)
2230 QMap<std::string, Transform>::iterator
iter=_frustums.find(
id);
2231 if(
iter != _frustums.end() && !pose.
isNull())
2239 pcl::visualization::ShapeActorMap::iterator am_it = _visualizer->getShapeActorMap()->find (
id);
2243 if (am_it == _visualizer->getShapeActorMap()->end ())
2246 actor = vtkActor::SafeDownCast (am_it->second);
2255 actor->SetUserMatrix (
matrix);
2263 UERROR(
"updateFrustumPose() cannot be used with PCL<1.7.2. Use addOrUpdateFrustum() instead.");
2272 UERROR(
"id should not be empty!");
2276 if(_frustums.find(
id) != _frustums.end())
2278 _visualizer->removeShape(
id);
2279 _frustums.remove(
id);
2285 QMap<std::string, Transform> frustums = _frustums;
2286 for(QMap<std::string, Transform>::iterator
iter = frustums.begin();
iter!=frustums.end(); ++
iter)
2288 if(!exceptCameraReference || !
uStrContains(
iter.key(),
"reference_frustum"))
2290 this->removeFrustum(
iter.key());
2293 UASSERT(exceptCameraReference || _frustums.empty());
2297 const std::string &
id,
2298 const pcl::PointCloud<pcl::PointXYZ>::Ptr & graph,
2299 const QColor & color)
2303 UERROR(
"id should not be empty!");
2311 _graphes.insert(
id);
2313 pcl::PolygonMesh mesh;
2316 for(
unsigned int i=0;
i<
vertices.vertices.size(); ++
i)
2320 pcl::toPCLPointCloud2(*
graph, mesh.cloud);
2322 _visualizer->addPolylineFromPolygonMesh(mesh,
id, 2);
2323 _visualizer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR, color.redF(), color.greenF(), color.blueF(),
id);
2324 _visualizer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_OPACITY, color.alphaF(),
id);
2326 pcl::PCLPointCloud2Ptr binaryCloud(
new pcl::PCLPointCloud2);
2327 pcl::toPCLPointCloud2(*
graph, *binaryCloud);
2329 this->setCloudPointSize(
id+
"_nodes", 5);
2337 UERROR(
"id should not be empty!");
2341 if(_graphes.find(
id) != _graphes.end())
2343 _visualizer->removeShape(
id);
2345 removeCloud(
id+
"_nodes");
2351 std::set<std::string> graphes = _graphes;
2352 for(std::set<std::string>::iterator
iter = graphes.begin();
iter!=graphes.end(); ++
iter)
2354 this->removeGraph(*
iter);
2360 const std::string &
id,
2361 const std::string & text,
2364 const QColor & color,
2369 UERROR(
"id should not be empty!");
2378 _visualizer->addText3D(
2394 UERROR(
"id should not be empty!");
2398 if(_texts.find(
id) != _texts.end())
2400 _visualizer->removeText3D(
id);
2407 std::set<std::string> texts = _texts;
2408 for(std::set<std::string>::iterator
iter = texts.begin();
iter!=texts.end(); ++
iter)
2410 this->removeText(*
iter);
2417 return _aShowTrajectory->isChecked();
2422 return _maxTrajectorySize;
2427 _aShowTrajectory->setChecked(shown);
2432 _maxTrajectorySize =
value;
2437 _trajectory->clear();
2438 _visualizer->removeShape(
"trajectory");
2439 this->refreshView();
2444 return _aShowCameraAxis->isChecked();
2451 this->removeCoordinate(
"reference");
2457 this->refreshView();
2458 _aShowCameraAxis->setChecked(shown);
2463 return _coordinateFrameScale;
2473 return _aShowFrustum->isChecked();
2478 return _frustumScale;
2483 return _frustumColor;
2490 QMap<std::string, Transform> frustumsCopy = _frustums;
2491 for(QMap<std::string, Transform>::iterator
iter=frustumsCopy.begin();
iter!=frustumsCopy.end(); ++
iter)
2495 this->removeFrustum(
iter.key());
2498 std::set<std::string> linesCopy = _lines;
2499 for(std::set<std::string>::iterator
iter=linesCopy.begin();
iter!=linesCopy.end(); ++
iter)
2503 this->removeLine(*
iter);
2506 this->refreshView();
2508 _aShowFrustum->setChecked(shown);
2513 _frustumScale =
value;
2518 if(!
value.isValid())
2522 for(QMap<std::string, Transform>::iterator
iter=_frustums.begin();
iter!=_frustums.end(); ++
iter)
2524 _visualizer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR,
value.redF(),
value.greenF(),
value.blueF(),
iter.key());
2526 this->refreshView();
2527 _frustumColor =
value;
2532 _lastCameraOrientation= _lastCameraPose = cv::Vec3f(0,0,0);
2533 if((_aFollowCamera->isChecked() || _aLockCamera->isChecked()) && !_lastPose.isNull())
2537 if(_aCameraOrtho->isChecked())
2539 this->setCameraPosition(
2540 _lastPose.x(), _lastPose.y(), _lastPose.z()+5,
2541 _lastPose.x(), _lastPose.y(), _lastPose.z(),
2544 else if(_aLockViewZ->isChecked())
2546 this->setCameraPosition(
2548 _lastPose.x(), _lastPose.y(), _lastPose.z(),
2553 this->setCameraPosition(
2555 _lastPose.x(), _lastPose.y(), _lastPose.z(),
2556 _lastPose.r31(), _lastPose.r32(), _lastPose.r33());
2559 else if(_aCameraOrtho->isChecked())
2561 this->setCameraPosition(
2568 this->setCameraPosition(
2577 QMap<std::string, Transform> addedClouds = _addedClouds;
2578 QList<std::string> ids = _addedClouds.keys();
2579 for(QList<std::string>::iterator
iter = ids.begin();
iter!=ids.end(); ++
iter)
2583 UASSERT(_addedClouds.empty());
2590 bool success = _visualizer->removePointCloud(
id);
2591 #if VTK_MAJOR_VERSION >= 7
2594 success = _visualizer->removeShape(
id);
2597 _visualizer->removePointCloud(
id+
"-normals");
2598 _addedClouds.remove(
id);
2599 _addedClouds.remove(
id+
"-normals");
2600 _locators.erase(
id);
2606 if(_addedClouds.contains(
id))
2608 pose = _addedClouds.value(
id);
2616 if(_lastPose.isNull())
2625 pcl::visualization::CloudActorMapPtr cloudActorMap = _visualizer->getCloudActorMap();
2626 for(pcl::visualization::CloudActorMap::iterator
iter=cloudActorMap->begin();
iter!=cloudActorMap->end(); ++
iter)
2628 if(
iter->second.actor.GetPointer() == actor)
2634 #if PCL_VERSION_COMPARE(>=, 1, 7, 2)
2636 pcl::visualization::ShapeActorMapPtr shapeActorMap = _visualizer->getShapeActorMap();
2637 for(pcl::visualization::ShapeActorMap::iterator
iter=shapeActorMap->begin();
iter!=shapeActorMap->end(); ++
iter)
2639 if(
iter->second.GetPointer() == actor)
2641 std::string
id =
iter->first;
2642 while(
id.
size() &&
id.at(
id.
size()-1) ==
'*')
2644 id.erase(
id.
size()-1);
2651 return std::string();
2657 pcl::visualization::CloudActorMap::iterator
iter = _visualizer->getCloudActorMap()->find(
id);
2658 if(
iter != _visualizer->getCloudActorMap()->end())
2661 iter->second.actor->GetProperty()->GetColor(r,
g,
b);
2662 a =
iter->second.actor->GetProperty()->GetOpacity();
2663 color.setRgbF(r,
g,
b,
a);
2665 #if PCL_VERSION_COMPARE(>=, 1, 7, 2)
2669 std::string idLayer1 =
id+
"*";
2670 std::string idLayer2 =
id+
"**";
2671 pcl::visualization::ShapeActorMap::iterator
iter = _visualizer->getShapeActorMap()->find(
id);
2672 if(
iter == _visualizer->getShapeActorMap()->end())
2674 iter = _visualizer->getShapeActorMap()->find(idLayer1);
2675 if(
iter == _visualizer->getShapeActorMap()->end())
2677 iter = _visualizer->getShapeActorMap()->find(idLayer2);
2680 if(
iter != _visualizer->getShapeActorMap()->end())
2682 vtkActor * actor = vtkActor::SafeDownCast(
iter->second);
2686 actor->GetProperty()->GetColor(r,
g,
b);
2687 a = actor->GetProperty()->GetOpacity();
2688 color.setRgbF(r,
g,
b,
a);
2698 pcl::visualization::CloudActorMap::iterator
iter = _visualizer->getCloudActorMap()->find(
id);
2699 if(
iter != _visualizer->getCloudActorMap()->end())
2701 iter->second.actor->GetProperty()->SetColor(color.redF(),color.greenF(),color.blueF());
2702 iter->second.actor->GetProperty()->SetOpacity(color.alphaF());
2704 #if PCL_VERSION_COMPARE(>=, 1, 7, 2)
2708 std::string idLayer1 =
id+
"*";
2709 std::string idLayer2 =
id+
"**";
2710 pcl::visualization::ShapeActorMap::iterator
iter = _visualizer->getShapeActorMap()->find(
id);
2711 if(
iter == _visualizer->getShapeActorMap()->end())
2713 iter = _visualizer->getShapeActorMap()->find(idLayer1);
2714 if(
iter == _visualizer->getShapeActorMap()->end())
2716 iter = _visualizer->getShapeActorMap()->find(idLayer2);
2719 if(
iter != _visualizer->getShapeActorMap()->end())
2721 vtkActor * actor = vtkActor::SafeDownCast(
iter->second);
2724 actor->GetProperty()->SetColor(color.redF(),color.greenF(),color.blueF());
2725 actor->GetProperty()->SetOpacity(color.alphaF());
2734 _aBackfaceCulling->setChecked(enabled);
2735 _frontfaceCulling = frontfaceCulling;
2737 pcl::visualization::CloudActorMapPtr cloudActorMap = _visualizer->getCloudActorMap();
2738 for(pcl::visualization::CloudActorMap::iterator
iter=cloudActorMap->begin();
iter!=cloudActorMap->end(); ++
iter)
2740 iter->second.actor->GetProperty()->SetBackfaceCulling(_aBackfaceCulling->isChecked());
2741 iter->second.actor->GetProperty()->SetFrontfaceCulling(_frontfaceCulling);
2743 #if VTK_MAJOR_VERSION >= 7
2744 pcl::visualization::ShapeActorMapPtr shapeActorMap = _visualizer->getShapeActorMap();
2745 for(pcl::visualization::ShapeActorMap::iterator
iter=shapeActorMap->begin();
iter!=shapeActorMap->end(); ++
iter)
2747 vtkActor* actor = vtkActor::SafeDownCast (
iter->second);
2750 actor->GetProperty()->SetBackfaceCulling(_aBackfaceCulling->isChecked());
2751 actor->GetProperty()->SetFrontfaceCulling(_frontfaceCulling);
2755 this->refreshView();
2760 _aPolygonPicking->setChecked(enabled);
2762 if(!_aPolygonPicking->isChecked())
2765 pp->SetTolerance (pp->GetTolerance());
2766 #if VTK_MAJOR_VERSION > 8
2767 this->interactor()->SetPicker (pp);
2769 this->GetInteractor()->SetPicker (pp);
2771 setMouseTracking(
false);
2776 pp->SetTolerance (pp->GetTolerance());
2777 #if VTK_MAJOR_VERSION > 8
2778 this->interactor()->SetPicker (pp);
2780 this->GetInteractor()->SetPicker (pp);
2782 setMouseTracking(
true);
2790 _renderingRate = rate;
2791 _visualizer->getInteractorStyle()->GetInteractor()->SetDesiredUpdateRate(_renderingRate);
2796 #if VTK_MAJOR_VERSION >= 7
2797 _aSetEDLShading->setChecked(on);
2798 _visualizer->getRendererCollection()->InitTraversal ();
2799 vtkRenderer* renderer =
NULL;
2800 renderer = _visualizer->getRendererCollection()->GetNextItem ();
2801 renderer = _visualizer->getRendererCollection()->GetNextItem ();
2804 vtkOpenGLRenderer* glrenderer = vtkOpenGLRenderer::SafeDownCast(renderer);
2811 edl->SetDelegatePass(basicPasses);
2812 glrenderer->SetPass(edl);
2814 else if(glrenderer->GetPass())
2816 glrenderer->GetPass()->ReleaseGraphicsResources(
NULL);
2817 glrenderer->SetPass(
NULL);
2820 this->refreshView();
2824 UERROR(
"RTAB-Map must be built with VTK>=7 to enable EDL shading!");
2831 _aSetLighting->setChecked(on);
2832 pcl::visualization::CloudActorMapPtr cloudActorMap = _visualizer->getCloudActorMap();
2833 for(pcl::visualization::CloudActorMap::iterator
iter=cloudActorMap->begin();
iter!=cloudActorMap->end(); ++
iter)
2835 iter->second.actor->GetProperty()->SetLighting(_aSetLighting->isChecked());
2837 #if VTK_MAJOR_VERSION >= 7
2838 pcl::visualization::ShapeActorMapPtr shapeActorMap = _visualizer->getShapeActorMap();
2839 for(pcl::visualization::ShapeActorMap::iterator
iter=shapeActorMap->begin();
iter!=shapeActorMap->end(); ++
iter)
2841 vtkActor* actor = vtkActor::SafeDownCast (
iter->second);
2842 if(actor && _addedClouds.contains(
iter->first))
2844 actor->GetProperty()->SetLighting(_aSetLighting->isChecked());
2848 this->refreshView();
2853 _aSetFlatShading->setChecked(on);
2854 pcl::visualization::CloudActorMapPtr cloudActorMap = _visualizer->getCloudActorMap();
2855 for(pcl::visualization::CloudActorMap::iterator
iter=cloudActorMap->begin();
iter!=cloudActorMap->end(); ++
iter)
2857 iter->second.actor->GetProperty()->SetInterpolation(_aSetFlatShading->isChecked()?VTK_FLAT:VTK_PHONG);
2859 #if VTK_MAJOR_VERSION >= 7
2860 pcl::visualization::ShapeActorMapPtr shapeActorMap = _visualizer->getShapeActorMap();
2861 for(pcl::visualization::ShapeActorMap::iterator
iter=shapeActorMap->begin();
iter!=shapeActorMap->end(); ++
iter)
2863 vtkActor* actor = vtkActor::SafeDownCast (
iter->second);
2864 if(actor && _addedClouds.contains(
iter->first))
2866 actor->GetProperty()->SetInterpolation(_aSetFlatShading->isChecked()?VTK_FLAT:VTK_PHONG);
2870 this->refreshView();
2875 _aSetEdgeVisibility->setChecked(visible);
2876 pcl::visualization::CloudActorMapPtr cloudActorMap = _visualizer->getCloudActorMap();
2877 for(pcl::visualization::CloudActorMap::iterator
iter=cloudActorMap->begin();
iter!=cloudActorMap->end(); ++
iter)
2879 iter->second.actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked());
2881 #if VTK_MAJOR_VERSION >= 7
2882 pcl::visualization::ShapeActorMapPtr shapeActorMap = _visualizer->getShapeActorMap();
2883 for(pcl::visualization::ShapeActorMap::iterator
iter=shapeActorMap->begin();
iter!=shapeActorMap->end(); ++
iter)
2885 vtkActor* actor = vtkActor::SafeDownCast (
iter->second);
2886 if(actor && _addedClouds.contains(
iter->first))
2888 actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked());
2892 this->refreshView();
2897 _visualizer->getRendererCollection()->InitTraversal ();
2898 vtkRenderer* renderer =
NULL;
2900 while ((renderer = _visualizer->getRendererCollection()->GetNextItem ()) !=
NULL)
2904 _visualizer->getInteractorStyle()->SetDefaultRenderer(renderer);
2905 _visualizer->getInteractorStyle()->SetCurrentRenderer(renderer);
2910 UWARN(
"Could not set layer %d to interactor (layers=%d).", layer, _visualizer->getRendererCollection()->GetNumberOfItems());
2914 float & x,
float & y,
float & z,
2915 float & focalX,
float & focalY,
float & focalZ,
2916 float & upX,
float & upY,
float & upZ)
const
2918 std::vector<pcl::visualization::Camera> cameras;
2919 _visualizer->getCameras(cameras);
2922 x = cameras.begin()->pos[0];
2923 y = cameras.begin()->pos[1];
2924 z = cameras.begin()->pos[2];
2925 focalX = cameras.begin()->focal[0];
2926 focalY = cameras.begin()->focal[1];
2927 focalZ = cameras.begin()->focal[2];
2928 upX = cameras.begin()->view[0];
2929 upY = cameras.begin()->view[1];
2930 upZ = cameras.begin()->view[2];
2934 UERROR(
"No camera set!?");
2939 float x,
float y,
float z,
2940 float focalX,
float focalY,
float focalZ,
2941 float upX,
float upY,
float upZ)
2943 vtkRenderer* renderer =
NULL;
2944 double boundingBox[6] = {1, -1, 1, -1, 1, -1};
2947 _visualizer->getRendererCollection()->InitTraversal ();
2948 while ((renderer = _visualizer->getRendererCollection()->GetNextItem ()) !=
NULL)
2951 cam->SetPosition (
x,
y,
z);
2952 cam->SetFocalPoint (focalX, focalY, focalZ);
2953 cam->SetViewUp (upX, upY, upZ);
2956 renderer->ComputeVisiblePropBounds(BB);
2957 for (
int i = 0;
i < 6;
i++) {
2960 if (BB[
i] < boundingBox[
i]) {
2961 boundingBox[
i] = BB[
i];
2965 if (BB[
i] > boundingBox[
i]) {
2966 boundingBox[
i] = BB[
i];
2972 _visualizer->getRendererCollection()->InitTraversal ();
2973 while ((renderer = _visualizer->getRendererCollection()->GetNextItem ()) !=
NULL)
2975 renderer->ResetCameraClippingRange(boundingBox);
2984 Eigen::Vector3f
pos =
m.translation();
2986 _trajectory->push_back(pcl::PointXYZ(
pos[0],
pos[1],
pos[2]));
2987 if(_maxTrajectorySize>0)
2989 while(_trajectory->size() > _maxTrajectorySize)
2991 _trajectory->erase(_trajectory->begin());
2994 if(_aShowTrajectory->isChecked())
2996 _visualizer->removeShape(
"trajectory");
2997 pcl::PolygonMesh mesh;
2999 vertices.vertices.resize(_trajectory->size());
3000 for(
unsigned int i=0;
i<
vertices.vertices.size(); ++
i)
3004 pcl::toPCLPointCloud2(*_trajectory, mesh.cloud);
3006 _visualizer->addPolylineFromPolygonMesh(mesh,
"trajectory", 2);
3009 if(pose != _lastPose || _lastPose.
isNull())
3011 if(_lastPose.isNull())
3013 _lastPose.setIdentity();
3016 std::vector<pcl::visualization::Camera> cameras;
3017 _visualizer->getCameras(cameras);
3019 if(_aLockCamera->isChecked() || _aCameraOrtho->isChecked())
3022 Eigen::Vector3f
diff =
pos - Eigen::Vector3f(_lastPose.x(), _lastPose.y(), _lastPose.z());
3023 cameras.front().pos[0] +=
diff[0];
3024 cameras.front().pos[1] +=
diff[1];
3025 cameras.front().pos[2] +=
diff[2];
3026 cameras.front().focal[0] +=
diff[0];
3027 cameras.front().focal[1] +=
diff[1];
3028 cameras.front().focal[2] +=
diff[2];
3030 else if(_aFollowCamera->isChecked())
3032 Eigen::Vector3f vPosToFocal = Eigen::Vector3f(cameras.front().focal[0] - cameras.front().pos[0],
3033 cameras.front().focal[1] - cameras.front().pos[1],
3034 cameras.front().focal[2] - cameras.front().pos[2]).normalized();
3035 Eigen::Vector3f zAxis(cameras.front().view[0], cameras.front().view[1], cameras.front().view[2]);
3036 Eigen::Vector3f yAxis = zAxis.cross(vPosToFocal);
3037 Eigen::Vector3f xAxis = yAxis.cross(zAxis);
3038 Transform PR(xAxis[0], xAxis[1], xAxis[2],0,
3039 yAxis[0], yAxis[1], yAxis[2],0,
3040 zAxis[0], zAxis[1], zAxis[2],0);
3044 Transform P(PR[0], PR[1], PR[2], cameras.front().pos[0],
3045 PR[4], PR[5], PR[6], cameras.front().pos[1],
3046 PR[8], PR[9], PR[10], cameras.front().pos[2]);
3047 Transform F(PR[0], PR[1], PR[2], cameras.front().focal[0],
3048 PR[4], PR[5], PR[6], cameras.front().focal[1],
3049 PR[8], PR[9], PR[10], cameras.front().focal[2]);
3059 cameras.front().pos[0] = Pp.
x();
3060 cameras.front().pos[1] = Pp.
y();
3061 cameras.front().pos[2] = Pp.
z();
3062 cameras.front().focal[0] = Fp.
x();
3063 cameras.front().focal[1] = Fp.
y();
3064 cameras.front().focal[2] = Fp.
z();
3066 cameras.front().view[0] = _aLockViewZ->isChecked()?0:Fp[8];
3067 cameras.front().view[1] = _aLockViewZ->isChecked()?0:Fp[9];
3068 cameras.front().view[2] = _aLockViewZ->isChecked()?1:Fp[10];
3071 if(_aShowCameraAxis->isChecked())
3073 #if PCL_VERSION_COMPARE(>=, 1, 7, 2)
3074 if(_coordinates.find(
"reference") != _coordinates.end())
3076 this->updateCoordinatePose(
"reference", pose);
3081 this->addOrUpdateCoordinate(
"reference", pose, 0.2);
3085 this->setCameraPosition(
3086 cameras.front().pos[0], cameras.front().pos[1], cameras.front().pos[2],
3087 cameras.front().focal[0], cameras.front().focal[1], cameras.front().focal[2],
3088 cameras.front().view[0], cameras.front().view[1], cameras.front().view[2]);
3097 std::vector<CameraModel> models;
3098 models.push_back(
model.left());
3100 if(!
model.left().localTransform().isNull())
3104 models.push_back(right);
3105 updateCameraFrustums(pose, models);
3110 std::vector<CameraModel> models;
3111 models.push_back(
model);
3112 updateCameraFrustums(pose, models);
3119 if(_aShowFrustum->isChecked())
3122 for(
unsigned int i=0;
i<models.size(); ++
i)
3127 baseToCamera = models[
i].localTransform();
3129 std::string
id =
uFormat(
"reference_frustum_%d",
i);
3130 this->removeFrustum(
id);
3131 this->addOrUpdateFrustum(
id, pose, baseToCamera, _frustumScale, _frustumColor, models[
i].fovX(), models[
i].fovY());
3134 this->addOrUpdateLine(
uFormat(
"reference_frustum_line_%d",
i), pose, pose * baseToCamera, _frustumColor);
3142 std::vector<CameraModel> models;
3143 for(
size_t i=0;
i<stereoModels.size(); ++
i)
3145 models.push_back(stereoModels[
i].left());
3147 if(!stereoModels[
i].left().localTransform().
isNull())
3151 models.push_back(right);
3152 updateCameraFrustums(pose, models);
3158 return _defaultBgColor;
3163 if(_currentBgColor == _defaultBgColor)
3165 setBackgroundColor(color);
3167 _defaultBgColor = color;
3172 return _currentBgColor;
3177 _currentBgColor = color;
3178 _visualizer->setBackgroundColor(color.redF(), color.greenF(), color.blueF());
3183 pcl::visualization::CloudActorMapPtr cloudActorMap = _visualizer->getCloudActorMap();
3184 pcl::visualization::CloudActorMap::iterator
iter = cloudActorMap->find(
id);
3185 if(
iter != cloudActorMap->end())
3187 iter->second.actor->SetVisibility(isVisible?1:0);
3189 iter = cloudActorMap->find(
id+
"-normals");
3190 if(
iter != cloudActorMap->end())
3192 iter->second.actor->SetVisibility(isVisible&&_aShowNormals->isChecked()?1:0);
3197 #if VTK_MAJOR_VERSION >= 7
3198 pcl::visualization::ShapeActorMapPtr shapeActorMap = _visualizer->getShapeActorMap();
3199 pcl::visualization::ShapeActorMap::iterator
iter = shapeActorMap->find(
id);
3200 if(
iter != shapeActorMap->end())
3202 vtkActor* actor = vtkActor::SafeDownCast (
iter->second);
3205 actor->SetVisibility(isVisible?1:0);
3210 UERROR(
"Cannot find actor named \"%s\".",
id.
c_str());
3216 pcl::visualization::CloudActorMapPtr cloudActorMap = _visualizer->getCloudActorMap();
3217 pcl::visualization::CloudActorMap::iterator
iter = cloudActorMap->find(
id);
3218 if(
iter != cloudActorMap->end())
3220 return iter->second.actor->GetVisibility() != 0;
3224 #if VTK_MAJOR_VERSION >= 7
3225 pcl::visualization::ShapeActorMapPtr shapeActorMap = _visualizer->getShapeActorMap();
3226 pcl::visualization::ShapeActorMap::iterator
iter = shapeActorMap->find(
id);
3227 if(
iter != shapeActorMap->end())
3229 vtkActor* actor = vtkActor::SafeDownCast (
iter->second);
3232 return actor->GetVisibility() != 0;
3236 UERROR(
"Cannot find actor named \"%s\".",
id.
c_str());
3245 _visualizer->updateColorHandlerIndex(
id, index-1);
3252 if(_visualizer->getPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_OPACITY, lastOpacity,
id))
3254 if(lastOpacity != opacity)
3256 _visualizer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_OPACITY, opacity,
id);
3259 #if VTK_MAJOR_VERSION >= 7
3262 pcl::visualization::ShapeActorMap::iterator am_it = _visualizer->getShapeActorMap()->find (
id);
3263 if (am_it != _visualizer->getShapeActorMap()->end ())
3265 vtkActor* actor = vtkActor::SafeDownCast (am_it->second);
3268 actor->GetProperty ()->SetOpacity (opacity);
3279 if(_visualizer->getPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, lastSize,
id))
3281 if((
int)lastSize !=
size)
3283 _visualizer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, (
double)
size,
id);
3290 _aLockCamera->setChecked(enabled);
3295 _aFollowCamera->setChecked(enabled);
3300 _aLockCamera->setChecked(
false);
3301 _aFollowCamera->setChecked(
false);
3306 _lastCameraOrientation= _lastCameraPose = cv::Vec3f(0,0,0);
3307 _aLockViewZ->setChecked(enabled);
3311 _lastCameraOrientation= _lastCameraPose = cv::Vec3f(0,0,0);
3312 #if VTK_MAJOR_VERSION > 8
3313 CloudViewerInteractorStyle * interactor = CloudViewerInteractorStyle::SafeDownCast(this->interactor()->GetInteractorStyle());
3315 CloudViewerInteractorStyle * interactor = CloudViewerInteractorStyle::SafeDownCast(this->GetInteractor()->GetInteractorStyle());
3320 this->refreshView();
3322 _aCameraOrtho->setChecked(enabled);
3326 return _aLockCamera->isChecked();
3330 return _aFollowCamera->isChecked();
3334 return !_aFollowCamera->isChecked() && !_aLockCamera->isChecked();
3338 return _aLockViewZ->isChecked();
3342 return _aCameraOrtho->isChecked();
3346 return _aBackfaceCulling->isChecked();
3350 return _frontfaceCulling;
3354 return _aPolygonPicking->isChecked();
3358 return _aSetEDLShading->isChecked();
3362 return _aSetLighting->isChecked();
3366 return _aSetFlatShading->isChecked();
3370 return _aSetEdgeVisibility->isChecked();
3374 return _renderingRate;
3379 _aShowGrid->setChecked(shown);
3391 return _aShowGrid->isChecked();
3395 return _gridCellCount;
3399 return _gridCellSize;
3405 _gridCellCount =
count;
3406 if(_aShowGrid->isChecked())
3414 UERROR(
"Cannot set grid cell count < 1, count=%d",
count);
3421 _gridCellSize =
size;
3422 if(_aShowGrid->isChecked())
3430 UERROR(
"Cannot set grid cell size <= 0, value=%f",
size);
3435 if(_gridLines.empty())
3437 float cellSize = _gridCellSize;
3438 int cellCount = _gridCellCount;
3443 float min = -
float(cellCount/2) * cellSize;
3444 float max =
float(cellCount/2) * cellSize;
3450 _visualizer->addLine(
3451 pcl::PointXYZ(
i,
min, 0.0
f),
3452 pcl::PointXYZ(
i,
max, 0.0
f),
3454 _gridLines.push_back(
name);
3457 _visualizer->addLine(
3458 pcl::PointXYZ(
min,
i, 0),
3459 pcl::PointXYZ(
max,
i, 0),
3461 _gridLines.push_back(
name);
3464 std::vector<pcl::visualization::Camera> cameras;
3465 _visualizer->getCameras(cameras);
3466 this->setCameraPosition(
3467 cameras.front().pos[0], cameras.front().pos[1], cameras.front().pos[2],
3468 cameras.front().focal[0], cameras.front().focal[1], cameras.front().focal[2],
3469 cameras.front().view[0], cameras.front().view[1], cameras.front().view[2]);
3475 for(std::list<std::string>::iterator
iter = _gridLines.begin();
iter!=_gridLines.end(); ++
iter)
3477 _visualizer->removeShape(*
iter);
3484 _aShowNormals->setChecked(shown);
3485 QList<std::string> ids = _addedClouds.keys();
3486 for(QList<std::string>::iterator
iter = ids.begin();
iter!=ids.end(); ++
iter)
3488 std::string idNormals = *
iter +
"-normals";
3489 if(_addedClouds.find(idNormals) != _addedClouds.end())
3491 this->setCloudVisibility(idNormals, this->getCloudVisibility(*
iter) && shown);
3497 return _aShowNormals->isChecked();
3501 return _normalsStep;
3505 return _normalsScale;
3511 _normalsStep =
step;
3515 UERROR(
"Cannot set normals step <= 0, step=%d",
step);
3522 _normalsScale=
scale;
3526 UERROR(
"Cannot set normals scale <= 0, value=%f",
scale);
3532 return _aSetIntensityRedColormap->isChecked();
3536 return _aSetIntensityRainbowColormap->isChecked();
3540 return _intensityAbsMax;
3545 _aSetIntensityRedColormap->setChecked(on);
3548 _aSetIntensityRainbowColormap->setChecked(
false);
3553 _aSetIntensityRainbowColormap->setChecked(on);
3556 _aSetIntensityRedColormap->setChecked(
false);
3563 _intensityAbsMax =
value;
3567 UERROR(
"Cannot set normals scale < 0, value=%f",
value);
3573 _buildLocator = enable;
3577 const Eigen::Vector3f & point,
3578 const Eigen::Vector3f &
axis,
3581 Eigen::Vector3f direction =
point;
3582 Eigen::Vector3f zAxis =
axis;
3583 float dotProdZ = zAxis.dot(direction);
3584 Eigen::Vector3f ptOnZaxis = zAxis * dotProdZ;
3585 direction -= ptOnZaxis;
3586 Eigen::Vector3f xAxis = direction.normalized();
3587 Eigen::Vector3f yAxis = zAxis.cross(xAxis);
3589 Eigen::Matrix3f newFrame;
3590 newFrame << xAxis[0], yAxis[0], zAxis[0],
3591 xAxis[1], yAxis[1], zAxis[1],
3592 xAxis[2], yAxis[2], zAxis[2];
3596 Eigen::Vector3f newDirection = newFrame.transpose() * direction;
3601 float magnitude = newDirection.norm();
3602 newDirection[0] = ( magnitude * cosTheta );
3603 newDirection[1] = ( magnitude * sinTheta );
3606 direction = newFrame * newDirection;
3608 return direction + ptOnZaxis;
3612 if(event->key() == Qt::Key_Up ||
3613 event->key() == Qt::Key_Down ||
3614 event->key() == Qt::Key_Left ||
3615 event->key() == Qt::Key_Right)
3617 _keysPressed -= (Qt::Key)event->key();
3621 PCLQVTKWidget::keyPressEvent(event);
3627 if(event->key() == Qt::Key_Up ||
3628 event->key() == Qt::Key_Down ||
3629 event->key() == Qt::Key_Left ||
3630 event->key() == Qt::Key_Right)
3632 _keysPressed += (Qt::Key)event->key();
3634 std::vector<pcl::visualization::Camera> cameras;
3635 _visualizer->getCameras(cameras);
3638 Eigen::Vector3f
pos(cameras.front().pos[0], cameras.front().pos[1], _aLockViewZ->isChecked()?0:cameras.front().pos[2]);
3639 Eigen::Vector3f focal(cameras.front().focal[0], cameras.front().focal[1], _aLockViewZ->isChecked()?0:cameras.front().focal[2]);
3640 Eigen::Vector3f viewUp(cameras.front().view[0], cameras.front().view[1], cameras.front().view[2]);
3641 Eigen::Vector3f cummulatedDir(0,0,0);
3642 Eigen::Vector3f cummulatedFocalDir(0,0,0);
3644 float stepRot = 0.02f;
3645 if(_keysPressed.contains(Qt::Key_Up))
3647 Eigen::Vector3f dir;
3648 if(event->modifiers() & Qt::ShiftModifier)
3650 dir = viewUp *
step;
3654 dir = (focal-
pos).normalized() *
step;
3656 cummulatedDir += dir;
3658 if(_keysPressed.contains(Qt::Key_Down))
3660 Eigen::Vector3f dir;
3661 if(event->modifiers() & Qt::ShiftModifier)
3663 dir = viewUp * -
step;
3667 dir = (focal-
pos).normalized() * -
step;
3669 cummulatedDir += dir;
3671 if(_keysPressed.contains(Qt::Key_Right))
3673 if(event->modifiers() & Qt::ShiftModifier)
3676 Eigen::Vector3f
point = (focal-
pos);
3678 Eigen::Vector3f
diff = newPoint -
point;
3679 cummulatedFocalDir +=
diff;
3683 Eigen::Vector3f dir = ((focal-
pos).
cross(viewUp)).normalized() *
step;
3684 cummulatedDir += dir;
3687 if(_keysPressed.contains(Qt::Key_Left))
3689 if(event->modifiers() & Qt::ShiftModifier)
3692 Eigen::Vector3f
point = (focal-
pos);
3694 Eigen::Vector3f
diff = newPoint -
point;
3695 cummulatedFocalDir +=
diff;
3699 Eigen::Vector3f dir = ((focal-
pos).
cross(viewUp)).normalized() * -
step;
3700 cummulatedDir += dir;
3704 cameras.front().pos[0] += cummulatedDir[0];
3705 cameras.front().pos[1] += cummulatedDir[1];
3706 cameras.front().pos[2] += cummulatedDir[2];
3707 cameras.front().focal[0] += cummulatedDir[0] + cummulatedFocalDir[0];
3708 cameras.front().focal[1] += cummulatedDir[1] + cummulatedFocalDir[1];
3709 cameras.front().focal[2] += cummulatedDir[2] + cummulatedFocalDir[2];
3710 this->setCameraPosition(
3711 cameras.front().pos[0], cameras.front().pos[1], cameras.front().pos[2],
3712 cameras.front().focal[0], cameras.front().focal[1], cameras.front().focal[2],
3713 cameras.front().view[0], cameras.front().view[1], cameras.front().view[2]);
3715 Q_EMIT configChanged();
3719 PCLQVTKWidget::keyPressEvent(event);
3725 if(event->button() == Qt::RightButton)
3731 PCLQVTKWidget::mousePressEvent(event);
3737 PCLQVTKWidget::mouseMoveEvent(event);
3739 std::vector<pcl::visualization::Camera> cameras;
3740 _visualizer->getCameras(cameras);
3743 if(_aLockViewZ->isChecked() && !_aCameraOrtho->isChecked())
3745 cv::Vec3d newCameraOrientation = cv::Vec3d(0,0,1).cross(cv::Vec3d(cameras.front().pos)-cv::Vec3d(cameras.front().focal));
3747 if( _lastCameraOrientation!=cv::Vec3d(0,0,0) &&
3748 _lastCameraPose!=cv::Vec3d(0,0,0) &&
3749 (
uSign(_lastCameraOrientation[0]) !=
uSign(newCameraOrientation[0]) &&
3750 uSign(_lastCameraOrientation[1]) !=
uSign(newCameraOrientation[1])))
3752 cameras.front().pos[0] = _lastCameraPose[0];
3753 cameras.front().pos[1] = _lastCameraPose[1];
3754 cameras.front().pos[2] = _lastCameraPose[2];
3756 else if(newCameraOrientation != cv::Vec3d(0,0,0))
3758 _lastCameraOrientation = newCameraOrientation;
3759 _lastCameraPose = cv::Vec3d(cameras.front().pos);
3763 if(cameras.front().view[2] == 0)
3765 cameras.front().pos[0] -= 0.00001*cameras.front().view[0];
3766 cameras.front().pos[1] -= 0.00001*cameras.front().view[1];
3770 cameras.front().pos[0] -= 0.00001;
3773 cameras.front().view[0] = 0;
3774 cameras.front().view[1] = 0;
3775 cameras.front().view[2] = 1;
3778 this->setCameraPosition(
3779 cameras.front().pos[0], cameras.front().pos[1], cameras.front().pos[2],
3780 cameras.front().focal[0], cameras.front().focal[1], cameras.front().focal[2],
3781 cameras.front().view[0], cameras.front().view[1], cameras.front().view[2]);
3783 Q_EMIT configChanged();
3788 PCLQVTKWidget::wheelEvent(event);
3790 std::vector<pcl::visualization::Camera> cameras;
3791 _visualizer->getCameras(cameras);
3793 if(_aLockViewZ->isChecked() && !_aCameraOrtho->isChecked())
3795 _lastCameraPose = cv::Vec3d(cameras.front().pos);
3798 this->setCameraPosition(
3799 cameras.front().pos[0], cameras.front().pos[1], cameras.front().pos[2],
3800 cameras.front().focal[0], cameras.front().focal[1], cameras.front().focal[2],
3801 cameras.front().view[0], cameras.front().view[1], cameras.front().view[2]);
3803 Q_EMIT configChanged();
3808 QAction *
a = _menu->exec(event->globalPos());
3812 Q_EMIT configChanged();
3818 if(
a == _aSetTrajectorySize)
3821 int value = QInputDialog::getInt(
this, tr(
"Set trajectory size"), tr(
"Size (0=infinite)"), _maxTrajectorySize, 0, 10000, 10, &ok);
3824 _maxTrajectorySize =
value;
3827 else if(
a == _aClearTrajectory)
3829 this->clearTrajectory();
3831 else if(
a == _aShowCameraAxis)
3833 this->setCameraAxisShown(
a->isChecked());
3835 else if(
a == _aSetFrameScale)
3838 double value = QInputDialog::getDouble(
this, tr(
"Set frame scale"), tr(
"Scale"), _coordinateFrameScale, 0.1, 999.0, 1, &ok);
3841 this->setCoordinateFrameScale(
value);
3844 else if(
a == _aShowFrustum)
3846 this->setFrustumShown(
a->isChecked());
3848 else if(
a == _aSetFrustumScale)
3851 double value = QInputDialog::getDouble(
this, tr(
"Set frustum scale"), tr(
"Scale"), _frustumScale, 0.0, 999.0, 1, &ok);
3854 this->setFrustumScale(
value);
3857 else if(
a == _aSetFrustumColor)
3859 QColor
value = QColorDialog::getColor(_frustumColor,
this);
3862 this->setFrustumColor(
value);
3865 else if(
a == _aResetCamera)
3867 this->resetCamera();
3869 else if(
a == _aShowGrid)
3871 if(_aShowGrid->isChecked())
3880 this->refreshView();
3882 else if(
a == _aSetGridCellCount)
3885 int value = QInputDialog::getInt(
this, tr(
"Set grid cell count"), tr(
"Count"), _gridCellCount, 1, 10000, 10, &ok);
3888 this->setGridCellCount(
value);
3891 else if(
a == _aSetGridCellSize)
3894 double value = QInputDialog::getDouble(
this, tr(
"Set grid cell size"), tr(
"Size (m)"), _gridCellSize, 0.01, 1000, 2, &ok);
3897 this->setGridCellSize(
value);
3900 else if(
a == _aShowNormals)
3902 this->setNormalsShown(_aShowNormals->isChecked());
3903 this->refreshView();
3905 else if(
a == _aSetNormalsStep)
3908 int value = QInputDialog::getInt(
this, tr(
"Set normals step"), tr(
"Step"), _normalsStep, 1, 10000, 1, &ok);
3911 this->setNormalsStep(
value);
3914 else if(
a == _aSetNormalsScale)
3917 double value = QInputDialog::getDouble(
this, tr(
"Set normals scale"), tr(
"Scale (m)"), _normalsScale, 0.01, 10, 2, &ok);
3920 this->setNormalsScale(
value);
3923 else if(
a == _aSetIntensityMaximum)
3926 double value = QInputDialog::getDouble(
this, tr(
"Set maximum absolute intensity"), tr(
"Intensity (0=auto)"), _intensityAbsMax, 0.0, 99999, 2, &ok);
3929 this->setIntensityMax(
value);
3932 else if(
a == _aSetIntensityRedColormap)
3934 this->setIntensityRedColormap(_aSetIntensityRedColormap->isChecked());
3936 else if(
a == _aSetIntensityRainbowColormap)
3938 this->setIntensityRainbowColormap(_aSetIntensityRainbowColormap->isChecked());
3940 else if(
a == _aSetBackgroundColor)
3942 QColor color = this->getDefaultBackgroundColor();
3943 color = QColorDialog::getColor(color,
this);
3946 this->setDefaultBackgroundColor(color);
3947 this->refreshView();
3950 else if(
a == _aSetRenderingRate)
3953 double value = QInputDialog::getDouble(
this, tr(
"Rendering rate"), tr(
"Rate (hz)"), _renderingRate, 0, 60, 0, &ok);
3956 this->setRenderingRate(
value);
3959 else if(
a == _aLockViewZ)
3961 if(_aLockViewZ->isChecked())
3963 this->refreshView();
3966 else if(
a == _aCameraOrtho)
3968 this->setCameraOrtho(_aCameraOrtho->isChecked());
3970 else if(
a == _aSetEDLShading)
3972 this->setEDLShading(_aSetEDLShading->isChecked());
3974 else if(
a == _aSetLighting)
3976 this->setLighting(_aSetLighting->isChecked());
3978 else if(
a == _aSetFlatShading)
3980 this->setShading(_aSetFlatShading->isChecked());
3982 else if(
a == _aSetEdgeVisibility)
3984 this->setEdgeVisibility(_aSetEdgeVisibility->isChecked());
3986 else if(
a == _aBackfaceCulling)
3988 this->setBackfaceCulling(_aBackfaceCulling->isChecked(), _frontfaceCulling);
3990 else if(
a == _aPolygonPicking)
3992 this->setPolygonPicking(_aPolygonPicking->isChecked());