Skip to content

Commit 6077bbf

Browse files
PCLVisualizer: make coordinate system actor unpickable (#5719)
* make coordinate system unpickable * add pickable option to addCoordinateSystem and make coordinate actors gettable * remove pickable parameter, only use coordinateactormap * pickable = true by default
1 parent b6c78e7 commit 6077bbf

File tree

3 files changed

+31
-23
lines changed

3 files changed

+31
-23
lines changed

tools/pcd_viewer.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ isOnly2DImage (const pcl::PCLPointField &field)
9393
return (true);
9494
return (false);
9595
}
96-
96+
9797
void
9898
printHelp (int, char **argv)
9999
{
@@ -219,7 +219,7 @@ pp_callback (const pcl::visualization::PointPickingEvent& event, void* cookie)
219219
event.getPoint (pos.x, pos.y, pos.z);
220220
p->addText3D<pcl::PointXYZ> (idx_string, pos, 0.0005, 1.0, 1.0, 1.0, idx_string);
221221
}
222-
222+
223223
}
224224

225225
/* ---[ */
@@ -286,7 +286,7 @@ main (int argc, char** argv)
286286

287287
bool use_vbos = false;
288288
pcl::console::parse_argument (argc, argv, "-vbo_rendering", use_vbos);
289-
if (use_vbos)
289+
if (use_vbos)
290290
print_highlight ("Vertex Buffer Object (VBO) visualization enabled.\n");
291291

292292
bool useEDLRendering = false;
@@ -295,7 +295,7 @@ main (int argc, char** argv)
295295
print_highlight("EDL visualization enabled.\n");
296296

297297
bool use_pp = pcl::console::find_switch (argc, argv, "-use_point_picking");
298-
if (use_pp)
298+
if (use_pp)
299299
print_highlight ("Point picking enabled.\n");
300300

301301
bool use_ap = pcl::console::find_switch(argc, argv, "-use_area_picking");
@@ -311,7 +311,7 @@ main (int argc, char** argv)
311311
if (!use_vbos)
312312
{
313313
pcl::console::parse_argument (argc, argv, "-immediate_rendering", use_immediate_rendering);
314-
if (use_immediate_rendering)
314+
if (use_immediate_rendering)
315315
print_highlight ("Using immediate mode rendering.\n");
316316
}
317317

@@ -486,7 +486,7 @@ main (int argc, char** argv)
486486
{
487487
print_info ("[done, "); print_value ("%g", tt.toc ()); print_info (" ms : "); print_value ("%u", cloud->width * cloud->height); print_info (" points]\n");
488488
print_info ("Available dimensions: "); print_value ("%s\n", pcl::getFieldsList (*cloud).c_str ());
489-
489+
490490
std::string name = "PCD Viewer :: " + std::string(argv[p_file_indices.at (i)]);
491491
pcl::visualization::ImageViewer::Ptr img (new pcl::visualization::ImageViewer (name));
492492
pcl::PointCloud<pcl::RGB> rgb_cloud;
@@ -719,7 +719,8 @@ main (int argc, char** argv)
719719
float ax_x = 0.0, ax_y = 0.0, ax_z = 0.0;
720720
pcl::console::parse_3x_arguments (argc, argv, "-ax_pos", ax_x, ax_y, ax_z);
721721
// Draw XYZ axes if command-line enabled
722-
p->addCoordinateSystem (axes, ax_x, ax_y, ax_z, "global");
722+
p->addCoordinateSystem (axes, ax_x, ax_y, ax_z, "global", 0);
723+
p->getCoordinateActorMap()->at("global")->SetPickable(false);
723724
}
724725

725726
// Clean up the memory used by the binary blob
@@ -747,7 +748,7 @@ main (int argc, char** argv)
747748
}
748749
img->spinOnce ();
749750
}
750-
751+
751752
if (p)
752753
{
753754
if (p->wasStopped ())

visualization/include/pcl/visualization/pcl_visualizer.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1714,7 +1714,7 @@ namespace pcl
17141714
* @brief Eye-Dome Lighting makes dark areas to improve depth perception
17151715
* See https://www.kitware.com/eye-dome-lighting-a-non-photorealistic-shading-technique/
17161716
* It is applied to all actors, including texts.
1717-
* @param viewport
1717+
* @param viewport
17181718
*/
17191719
void
17201720
enableEDLRendering(int viewport = 0);
@@ -1942,6 +1942,13 @@ namespace pcl
19421942
return (shape_actor_map_);
19431943
}
19441944

1945+
/** \brief Return a pointer to the CoordinateActorMap this visualizer uses. */
1946+
CoordinateActorMapPtr
1947+
getCoordinateActorMap ()
1948+
{
1949+
return (coordinate_actor_map_);
1950+
}
1951+
19451952
/** \brief Set the position in screen coordinates.
19461953
* \param[in] x where to move the window to (X)
19471954
* \param[in] y where to move the window to (Y)

visualization/src/pcl_visualizer.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,7 @@ pcl::visualization::PCLVisualizer::setPointCloudRenderingProperties (
14001400
// Check if the mapper has scalars
14011401
if (!actor->GetMapper ()->GetInput ()->GetPointData ()->GetScalars ())
14021402
break;
1403-
1403+
14041404
// Check that scalars are not unisgned char (i.e. check if a LUT is used to colormap scalars assuming vtk ColorMode is Default)
14051405
if (actor->GetMapper ()->GetInput ()->GetPointData ()->GetScalars ()->IsA ("vtkUnsignedCharArray"))
14061406
break;
@@ -1411,7 +1411,7 @@ pcl::visualization::PCLVisualizer::setPointCloudRenderingProperties (
14111411
PCL_WARN ("[setPointCloudRenderingProperties] Range max must be greater than range min!\n");
14121412
return (false);
14131413
}
1414-
1414+
14151415
// Update LUT
14161416
actor->GetMapper ()->GetLookupTable ()->SetRange (val1, val2);
14171417
actor->GetMapper()->UseLookupTableScalarRangeOn ();
@@ -1563,15 +1563,15 @@ pcl::visualization::PCLVisualizer::setPointCloudRenderingProperties (
15631563
// Check if the mapper has scalars
15641564
if (!actor->GetMapper ()->GetInput ()->GetPointData ()->GetScalars ())
15651565
break;
1566-
1566+
15671567
// Check that scalars are not unisgned char (i.e. check if a LUT is used to colormap scalars assuming vtk ColorMode is Default)
15681568
if (actor->GetMapper ()->GetInput ()->GetPointData ()->GetScalars ()->IsA ("vtkUnsignedCharArray"))
15691569
break;
15701570

15711571
// Get range limits from existing LUT
15721572
double *range;
15731573
range = actor->GetMapper ()->GetLookupTable ()->GetRange ();
1574-
1574+
15751575
actor->GetMapper ()->ScalarVisibilityOn ();
15761576
actor->GetMapper ()->SetScalarRange (range[0], range[1]);
15771577
vtkSmartPointer<vtkLookupTable> table;
@@ -1587,7 +1587,7 @@ pcl::visualization::PCLVisualizer::setPointCloudRenderingProperties (
15871587
// Check if the mapper has scalars
15881588
if (!actor->GetMapper ()->GetInput ()->GetPointData ()->GetScalars ())
15891589
break;
1590-
1590+
15911591
// Check that scalars are not unisgned char (i.e. check if a LUT is used to colormap scalars assuming vtk ColorMode is Default)
15921592
if (actor->GetMapper ()->GetInput ()->GetPointData ()->GetScalars ()->IsA ("vtkUnsignedCharArray"))
15931593
break;
@@ -1717,7 +1717,7 @@ pcl::visualization::PCLVisualizer::setShapeRenderingProperties (
17171717
// Check if the mapper has scalars
17181718
if (!actor->GetMapper ()->GetInput ()->GetPointData ()->GetScalars ())
17191719
break;
1720-
1720+
17211721
// Check that scalars are not unisgned char (i.e. check if a LUT is used to colormap scalars assuming vtk ColorMode is Default)
17221722
if (actor->GetMapper ()->GetInput ()->GetPointData ()->GetScalars ()->IsA ("vtkUnsignedCharArray"))
17231723
break;
@@ -1728,7 +1728,7 @@ pcl::visualization::PCLVisualizer::setShapeRenderingProperties (
17281728
PCL_WARN ("[setShapeRenderingProperties] Range max must be greater than range min!\n");
17291729
return (false);
17301730
}
1731-
1731+
17321732
// Update LUT
17331733
actor->GetMapper ()->GetLookupTable ()->SetRange (val1, val2);
17341734
actor->GetMapper()->UseLookupTableScalarRangeOn ();
@@ -1861,11 +1861,11 @@ pcl::visualization::PCLVisualizer::setShapeRenderingProperties (
18611861
// Check that scalars are not unisgned char (i.e. check if a LUT is used to colormap scalars assuming vtk ColorMode is Default)
18621862
if (actor->GetMapper ()->GetInput ()->GetPointData ()->GetScalars ()->IsA ("vtkUnsignedCharArray"))
18631863
break;
1864-
1864+
18651865
// Get range limits from existing LUT
18661866
double *range;
18671867
range = actor->GetMapper ()->GetLookupTable ()->GetRange ();
1868-
1868+
18691869
actor->GetMapper ()->ScalarVisibilityOn ();
18701870
actor->GetMapper ()->SetScalarRange (range[0], range[1]);
18711871
vtkSmartPointer<vtkLookupTable> table;
@@ -3005,7 +3005,7 @@ pcl::visualization::PCLVisualizer::addPolygonMesh (const pcl::PolygonMesh &poly_
30053005
pcl::fromPCLPointCloud2 (poly_mesh.cloud, *point_cloud);
30063006
poly_points->SetNumberOfPoints (point_cloud->size ());
30073007

3008-
for (std::size_t i = 0; i < point_cloud->size (); ++i)
3008+
for (std::size_t i = 0; i < point_cloud->size (); ++i)
30093009
{
30103010
const pcl::PointXYZ& p = (*point_cloud)[i];
30113011
poly_points->InsertPoint (i, p.x, p.y, p.z);
@@ -3175,7 +3175,7 @@ pcl::visualization::PCLVisualizer::updatePolygonMesh (
31753175

31763176
// Update the cells
31773177
cells = vtkSmartPointer<vtkCellArray>::New ();
3178-
3178+
31793179
const auto idx = details::fillCells(lookup, verts, cells, max_size_of_polygon);
31803180

31813181
cells->GetData ()->SetNumberOfValues (idx);
@@ -3419,7 +3419,7 @@ pcl::visualization::PCLVisualizer::addTextureMesh (const pcl::TextureMesh &mesh,
34193419
mapper->MapDataArrayToMultiTextureAttribute(tu,
34203420
this_coordinates_name.c_str(),
34213421
vtkDataObject::FIELD_ASSOCIATION_POINTS);
3422-
3422+
34233423
polydata->GetPointData ()->AddArray (coordinates);
34243424
actor->GetProperty ()->SetTexture (tu, texture);
34253425
++tex_id;
@@ -4338,7 +4338,7 @@ pcl::visualization::PCLVisualizer::close ()
43384338
void
43394339
pcl::visualization::PCLVisualizer::removeCorrespondences (
43404340
const std::string &id, int viewport)
4341-
{
4341+
{
43424342
removeShape (id, viewport);
43434343
}
43444344

@@ -4571,7 +4571,7 @@ pcl::visualization::PCLVisualizer::getUniqueCameraFile (int argc, char **argv)
45714571
p_file_indices = pcl::console::parse_file_extension_argument (argc, argv, ".pcd");
45724572
if (!p_file_indices.empty ())
45734573
{
4574-
boost::uuids::detail::sha1 sha1;
4574+
boost::uuids::detail::sha1 sha1;
45754575
bool valid = false;
45764576

45774577
// Calculate sha1 using canonical paths

0 commit comments

Comments
 (0)