From 6bc393676df8083595a3ebb773f3cf7b3b89205d Mon Sep 17 00:00:00 2001 From: ozantonkal Date: Tue, 20 Aug 2013 20:22:14 +0200 Subject: [PATCH] cv::viz::get(window_name) implementation --- modules/viz/src/viz.cpp | 6 +++++- modules/viz/src/viz3d.cpp | 3 ++- modules/viz/src/viz3d_impl.cpp | 6 ++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/modules/viz/src/viz.cpp b/modules/viz/src/viz.cpp index dbd3120009..f3059a606c 100644 --- a/modules/viz/src/viz.cpp +++ b/modules/viz/src/viz.cpp @@ -112,7 +112,11 @@ cv::viz::VizAccessor * cv::viz::VizAccessor::getInstance() cv::viz::Viz3d cv::viz::VizAccessor::get(const String & window_name) { - VizMap::iterator vm_itr = viz_map_.find(window_name); + // Add the prefix Viz + String name("Viz"); + name = window_name.empty() ? name : name + " - " + window_name; + + VizMap::iterator vm_itr = viz_map_.find(name); bool exists = vm_itr != viz_map_.end(); if (exists) return vm_itr->second; else return viz_map_.insert(VizPair(window_name, Viz3d(window_name))).first->second; diff --git a/modules/viz/src/viz3d.cpp b/modules/viz/src/viz3d.cpp index 61502a7d3c..c31d5880a7 100644 --- a/modules/viz/src/viz3d.cpp +++ b/modules/viz/src/viz3d.cpp @@ -28,13 +28,14 @@ void cv::viz::Viz3d::create(const String &window_name) impl_ = new VizImpl(window_name); impl_->ref_counter = 1; // Register the window -// cv::viz::VizAccessor::getInstance()->add(*this); + cv::viz::VizAccessor::getInstance()->add(*this); } void cv::viz::Viz3d::release() { if (impl_ && CV_XADD(&impl_->ref_counter, -1) == 1) { + // Erase the window cv::viz::VizAccessor::getInstance()->remove(getWindowName()); delete impl_; impl_ = 0; diff --git a/modules/viz/src/viz3d_impl.cpp b/modules/viz/src/viz3d_impl.cpp index be389b241c..c1807a0155 100644 --- a/modules/viz/src/viz3d_impl.cpp +++ b/modules/viz/src/viz3d_impl.cpp @@ -83,10 +83,8 @@ cv::viz::Viz3d::VizImpl::VizImpl (const std::string &name) ///////////////////////////////////////////////////////////////////////////////////////////// cv::viz::Viz3d::VizImpl::~VizImpl () { - if (interactor_ != NULL) - interactor_->DestroyTimer (timer_id_); - - if (renderer_) renderer_->Clear(); + if (interactor_) + interactor_->DestroyTimer(timer_id_); } /////////////////////////////////////////////////////////////////////////////////////////////