Skip to content
Snippets Groups Projects
Commit 2810d9bb authored by marco's avatar marco
Browse files

added scene.RemoveAll() method

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2510 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent f10cade5
Branches
Tags
No related merge requests found
......@@ -214,7 +214,12 @@ It is interesting to note that the offset from center (`trans`) is given in rota
:param obj:
:type obj: :class:`GfxNode`
.. method:: RemoveAll()
Remove all objects from the scene
.. method:: RenderGL()
Renders the scene.
......
......@@ -127,6 +127,7 @@ void export_Scene()
.def("GetSelectionMode",&Scene::GetSelectionMode)
.def("SetBlur",&Scene::SetBlur)
.def("BlurSnapshot",&Scene::BlurSnapshot)
.def("RemoveAll", &Scene::RemoveAll)
.def("SetShadow",&Scene::SetShadow)
.def("SetShadowQuality",&Scene::SetShadowQuality)
.def("AttachObserver",&Scene::AttachObserver)
......
......@@ -16,6 +16,7 @@
// along with this library; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//------------------------------------------------------------------------------
#include <boost/bind.hpp>
#include <ost/dyn_cast.hh>
#include "gfx_node.hh"
#include "gfx_object.hh"
......@@ -113,6 +114,17 @@ void GfxNode::Remove(GfxObjP obj)
node_vector_.erase(it);
}
}
using boost::bind;
void GfxNode::RemoveAll()
{
GfxNodeVector v=node_vector_;
node_vector_.clear();
for (GfxNodeVector::iterator i=v.begin(), e=v.end(); i!=e; ++i) {
if (GfxObjP o=dyn_cast<GfxObj>(*i)) {
Scene::Instance().NotifyObservers(bind(&SceneObserver::NodeRemoved, _1, o));
}
}
}
void GfxNode::Add(GfxNodeP node)
{
......
......@@ -68,6 +68,8 @@ class DLLEXPORT_OST_GFX GfxNode: public boost::enable_shared_from_this<GfxNode>
// return name
String GetName() const;
// remove all child nodes
void RemoveAll();
// change name
void Rename(const String& name);
......
......@@ -607,6 +607,12 @@ void Scene::Remove(const GfxNodeP& go)
this->RequestRedraw();
}
void Scene::RemoveAll()
{
root_node_->RemoveAll();
this->RequestRedraw();
}
void Scene::Remove(const String& name)
{
FindNode fn(name);
......
......@@ -281,6 +281,10 @@ class DLLEXPORT_OST_GFX Scene {
void Remove(const GfxNodeP& go);
/// remove graphical object from the scene
void Remove(const String& name);
/// \brief remove all objects from the scene
void RemoveAll();
/// \brief rename an existing graphical object
/// defunct for now
bool Rename(const String& old_name, const String& new_name);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment