mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 06:03:15 +08:00
removeAllWidgets implementation, removed other remove methods
This commit is contained in:
parent
e106dcc606
commit
0bbaf5d47a
@ -37,6 +37,7 @@ namespace cv
|
||||
void showWidget(const String &id, const Widget &widget, const Affine3f &pose = Affine3f::Identity());
|
||||
void removeWidget(const String &id);
|
||||
Widget getWidget(const String &id) const;
|
||||
void removeAllWidgets();
|
||||
|
||||
void setWidgetPose(const String &id, const Affine3f &pose);
|
||||
void updateWidgetPose(const String &id, const Affine3f &pose);
|
||||
|
@ -79,6 +79,7 @@ void cv::viz::Viz3d::registerMouseCallback(MouseCallback callback, void* cookie)
|
||||
void cv::viz::Viz3d::showWidget(const String &id, const Widget &widget, const Affine3f &pose) { impl_->showWidget(id, widget, pose); }
|
||||
void cv::viz::Viz3d::removeWidget(const String &id) { impl_->removeWidget(id); }
|
||||
cv::viz::Widget cv::viz::Viz3d::getWidget(const String &id) const { return impl_->getWidget(id); }
|
||||
void cv::viz::Viz3d::removeAllWidgets() { impl_->removeAllWidgets(); }
|
||||
void cv::viz::Viz3d::setWidgetPose(const String &id, const Affine3f &pose) { impl_->setWidgetPose(id, pose); }
|
||||
void cv::viz::Viz3d::updateWidgetPose(const String &id, const Affine3f &pose) { impl_->updateWidgetPose(id, pose); }
|
||||
cv::Affine3f cv::viz::Viz3d::getWidgetPose(const String &id) const { return impl_->getWidgetPose(id); }
|
||||
|
@ -128,104 +128,13 @@ void cv::viz::Viz3d::VizImpl::spinOnce (int time, bool force_redraw)
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool cv::viz::Viz3d::VizImpl::removePointCloud (const std::string &id)
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
void cv::viz::Viz3d::VizImpl::removeAllWidgets()
|
||||
{
|
||||
CloudActorMap::iterator am_it = cloud_actor_map_->find (id);
|
||||
if (am_it == cloud_actor_map_->end ())
|
||||
return false;
|
||||
|
||||
if (removeActorFromRenderer (am_it->second.actor))
|
||||
return cloud_actor_map_->erase (am_it), true;
|
||||
|
||||
return false;
|
||||
widget_actor_map_->clear();
|
||||
renderer_->RemoveAllViewProps();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool cv::viz::Viz3d::VizImpl::removeShape (const std::string &id)
|
||||
{
|
||||
// Check to see if the given ID entry exists
|
||||
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
|
||||
// Extra step: check if there is a cloud with the same ID
|
||||
CloudActorMap::iterator ca_it = cloud_actor_map_->find (id);
|
||||
|
||||
bool shape = true;
|
||||
// Try to find a shape first
|
||||
if (am_it == shape_actor_map_->end ())
|
||||
{
|
||||
// There is no cloud or shape with this ID, so just exit
|
||||
if (ca_it == cloud_actor_map_->end ())
|
||||
return false;
|
||||
// Cloud found, set shape to false
|
||||
shape = false;
|
||||
}
|
||||
|
||||
// Remove the pointer/ID pair to the global actor map
|
||||
if (shape)
|
||||
{
|
||||
if (removeActorFromRenderer (am_it->second))
|
||||
{
|
||||
shape_actor_map_->erase (am_it);
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (removeActorFromRenderer (ca_it->second.actor))
|
||||
{
|
||||
cloud_actor_map_->erase (ca_it);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool cv::viz::Viz3d::VizImpl::removeText3D (const std::string &id)
|
||||
{
|
||||
// Check to see if the given ID entry exists
|
||||
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
|
||||
if (am_it == shape_actor_map_->end ())
|
||||
return false;
|
||||
|
||||
// Remove it from all renderers
|
||||
if (removeActorFromRenderer (am_it->second))
|
||||
return shape_actor_map_->erase (am_it), true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool cv::viz::Viz3d::VizImpl::removeAllPointClouds ()
|
||||
{
|
||||
// Check to see if the given ID entry exists
|
||||
CloudActorMap::iterator am_it = cloud_actor_map_->begin ();
|
||||
while (am_it != cloud_actor_map_->end () )
|
||||
{
|
||||
if (removePointCloud (am_it->first))
|
||||
am_it = cloud_actor_map_->begin ();
|
||||
else
|
||||
++am_it;
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool cv::viz::Viz3d::VizImpl::removeAllShapes ()
|
||||
{
|
||||
// Check to see if the given ID entry exists
|
||||
ShapeActorMap::iterator am_it = shape_actor_map_->begin ();
|
||||
while (am_it != shape_actor_map_->end ())
|
||||
{
|
||||
if (removeShape (am_it->first))
|
||||
am_it = shape_actor_map_->begin ();
|
||||
else
|
||||
++am_it;
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool cv::viz::Viz3d::VizImpl::removeActorFromRenderer (const vtkSmartPointer<vtkLODActor> &actor)
|
||||
{
|
||||
|
@ -17,23 +17,7 @@ public:
|
||||
VizImpl (const String &name);
|
||||
virtual ~VizImpl ();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//to refactor
|
||||
bool removePointCloud (const String& id = "cloud");
|
||||
inline bool removePolygonMesh (const String& id = "polygon") { return removePointCloud (id); }
|
||||
bool removeShape (const String& id = "cloud");
|
||||
bool removeText3D (const String& id = "cloud");
|
||||
bool removeAllPointClouds ();
|
||||
|
||||
//create Viz3d::removeAllWidgets()
|
||||
bool removeAllShapes ();
|
||||
void removeAllWidgets();
|
||||
|
||||
//to refactor
|
||||
bool addPolygonMesh (const Mesh3d& mesh, const cv::Mat& mask, const String& id = "polygon");
|
||||
|
Loading…
Reference in New Issue
Block a user