Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions visualization/include/pcl/visualization/impl/pcl_visualizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,53 @@ pcl::visualization::PCLVisualizer::addText3D (
return (true);
}

//////////////////////////////////////////////////
template <typename PointT> bool
pcl::visualization::PCLVisualizer::addText3D (
const std::string &text,
const PointT& position,
double orientation[3],
double textScale,
double r,
double g,
double b,
const std::string &id,
int viewport)
{
std::string tid;
if (id.empty ())
tid = text;
else
tid = id;

if (contains (tid))
{
PCL_WARN ("[addText3D] The id <%s> already exists! Please choose a different id and retry.\n", id.c_str ());
return (false);
}

vtkSmartPointer<vtkVectorText> textSource = vtkSmartPointer<vtkVectorText>::New ();
textSource->SetText (text.c_str());
textSource->Update ();

vtkSmartPointer<vtkPolyDataMapper> textMapper = vtkSmartPointer<vtkPolyDataMapper>::New ();
textMapper->SetInputConnection (textSource->GetOutputPort ());

vtkSmartPointer<vtkActor> textActor = vtkSmartPointer<vtkActor>::New ();
textActor->SetMapper (textMapper);
textActor->SetPosition (position.x, position.y, position.z);
textActor->SetScale (textScale);
textActor->GetProperty ()->SetColor (r, g, b);
textActor->SetOrientation (orientation);

addActorToRenderer (textActor, viewport);

// Save the pointer/ID pair to the global actor map. If we are saving multiple vtkFollowers
(*shape_actor_map_)[tid] = textActor;

return (true);
}

//////////////////////////////////////////////////////////////////////////////////////////////
template <typename PointNT> bool
pcl::visualization::PCLVisualizer::addPointCloudNormals (
Expand Down
22 changes: 22 additions & 0 deletions visualization/include/pcl/visualization/pcl_visualizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,28 @@ namespace pcl
double r = 1.0, double g = 1.0, double b = 1.0,
const std::string &id = "", int viewport = 0);

/** \brief Add a 3d text to the scene
* \param[in] text the text to add
* \param[in] position the world position where the text should be added
* \param[in] orientation the angles of rotation of the text around X, Y and Z axis,
in this order. The way the rotations are effectively done is the
Z-X-Y intrinsic rotations:
https://en.wikipedia.org/wiki/Euler_angles#Definition_by_intrinsic_rotations
* \param[in] textScale the scale of the text to render
* \param[in] r the red color value
* \param[in] g the green color value
* \param[in] b the blue color value
* \param[in] id the text object id (default: equal to the "text" parameter)
* \param[in] viewport the view port (default: all)
*/
template <typename PointT> bool
addText3D (const std::string &text,
const PointT &position,
double orientation[3],
double textScale = 1.0,
double r = 1.0, double g = 1.0, double b = 1.0,
const std::string &id = "", int viewport = 0);

/** \brief Check if the cloud, shape, or coordinate with the given id was already added to this visualizer.
* \param[in] id the id of the cloud, shape, or coordinate to check
* \return true if a cloud, shape, or coordinate with the specified id was found
Expand Down