remove widget implementation

This commit is contained in:
ozantonkal 2013-07-04 18:36:26 +03:00
parent ecdd8513fd
commit 5bb95c4110
4 changed files with 26 additions and 0 deletions

View File

@ -72,6 +72,7 @@ namespace temp_viz
bool wasStopped() const;
void showWidget(const String &id, const Widget &widget);
bool removeWidget(const String &id);
private:
Viz3d(const Viz3d&);
Viz3d& operator=(const Viz3d&);

View File

@ -247,6 +247,8 @@ public:
void setSize (int xw, int yw);
void showWidget(const String &id, const Widget &widget);
bool removeWidget(const String &id);
void all_data();
private:

View File

@ -143,3 +143,8 @@ void temp_viz::Viz3d::showWidget(const String &id, const Widget &widget)
{
impl_->showWidget(id, widget);
}
bool temp_viz::Viz3d::removeWidget(const String &id)
{
return impl_->removeWidget(id);
}

View File

@ -1183,3 +1183,21 @@ void temp_viz::Viz3d::VizImpl::showWidget(const String &id, const Widget &widget
renderer_->AddActor(WidgetAccessor::getActor(widget));
(*widget_actor_map_)[id].actor = WidgetAccessor::getActor(widget);
}
bool temp_viz::Viz3d::VizImpl::removeWidget(const String &id)
{
WidgetActorMap::iterator wam_itr = widget_actor_map_->find(id);
bool exists = !(wam_itr == widget_actor_map_->end());
if (!exists)
{
std::cout << "[removeWidget] A widget with id <" << id << "> does not exist!" << std::endl;
return false;
}
if (!removeActorFromRenderer (wam_itr->second.actor))
return false;
widget_actor_map_->erase(wam_itr);
return true;
}