X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdesigner%2Fselectionwrap.cpp;h=79268743b20de383d176fd46c63ac5549a03b38b;hb=a7e320b46a7d4070613b3210c28e65f579750f37;hp=fcc4df6b2a7fc561915a22e008782be322773b27;hpb=bde934f7d5ba07a9442a305192e10024820d13ed;p=r2c2.git diff --git a/source/designer/selectionwrap.cpp b/source/designer/selectionwrap.cpp index fcc4df6..7926874 100644 --- a/source/designer/selectionwrap.cpp +++ b/source/designer/selectionwrap.cpp @@ -18,6 +18,8 @@ SelectionWrap::~SelectionWrap() { for(map::iterator i=meshes.begin(); i!=meshes.end(); ++i) delete i->second; + for(map::iterator i=transient_meshes.begin(); i!=transient_meshes.end(); ++i) + delete i->second; } void SelectionWrap::render(GL::Renderer &renderer, const GL::Tag &) const @@ -40,13 +42,30 @@ void SelectionWrap::selection_changed() { Wrap wrap; wrap.object = *i; - wrap.mesh = &get_mesh((*i)->get_type()); + wrap.mesh = &get_mesh(**i); wraps.push_back(wrap); } + + set cobjects(objects.begin(), objects.end()); + for(map::iterator i=transient_meshes.begin(); i!=transient_meshes.end(); ) + { + if(!cobjects.count(i->first)) + { + delete i->second; + transient_meshes.erase(i++); + } + else + ++i; + } } -GL::Mesh &SelectionWrap::get_mesh(const ObjectType &type) +const GL::Mesh &SelectionWrap::get_mesh(const Object &obj) { + map::iterator i = transient_meshes.find(&obj); + if(i!=transient_meshes.end()) + return *i->second; + + const ObjectType &type = obj.get_type(); map::iterator j = meshes.find(&type); if(j!=meshes.end()) return *j->second; @@ -55,7 +74,7 @@ GL::Mesh &SelectionWrap::get_mesh(const ObjectType &type) GL::MeshBuilder bld(*mesh); bld.color(0.0f, 1.0f, 0.0f, 1.0f); - const Shape *shape = type.get_shape(); + const Shape *shape = obj.get_shape(); if(!shape) throw logic_error("No shape"); @@ -70,7 +89,10 @@ GL::Mesh &SelectionWrap::get_mesh(const ObjectType &type) bld.vertex(min_pt.x-0.005, max_pt.y+0.005); bld.end(); - meshes[&type] = mesh; + if(shape!=type.get_shape()) + transient_meshes[&obj] = mesh; + else + meshes[&type] = mesh; return *mesh; }