#include <QmitkTransferFunctionCanvas.h>
Classes | |
class | Element |
Public Member Functions | |
SimpleHistogramCache () | |
~SimpleHistogramCache () | |
SimpleHistogram * | operator[] (mitk::Image::Pointer sp_Image) |
Static Public Attributes | |
static const unsigned int | maxCacheSize = 64 |
Protected Types | |
typedef std::list< Element * > | CacheContainer |
Protected Member Functions | |
void | TrimCache (bool full=false) |
Protected Attributes | |
CacheContainer | cache |
Definition at line 100 of file QmitkTransferFunctionCanvas.h.
typedef std::list<Element*> mitk::SimpleHistogramCache::CacheContainer [protected] |
Definition at line 116 of file QmitkTransferFunctionCanvas.h.
mitk::SimpleHistogramCache::SimpleHistogramCache | ( | ) | [inline] |
Definition at line 122 of file QmitkTransferFunctionCanvas.h.
{ }
mitk::SimpleHistogramCache::~SimpleHistogramCache | ( | ) | [inline] |
Definition at line 127 of file QmitkTransferFunctionCanvas.h.
{ TrimCache(true); }
SimpleHistogram* mitk::SimpleHistogramCache::operator[] | ( | mitk::Image::Pointer | sp_Image ) | [inline] |
Definition at line 132 of file QmitkTransferFunctionCanvas.h.
References mitk::SimpleHistogram::ComputeFromImage(), mitk::BaseData::GetMTime(), mitk::WeakPointer< TObjectType >::GetPointer(), mitk::SimpleHistogramCache::Element::histogram, mitk::SimpleHistogramCache::Element::image, mitk::SimpleHistogramCache::Element::m_LastUpdateTime, and MITK_WARN.
{ mitk::Image *p_Image = sp_Image.GetPointer(); if(!p_Image) { MITK_WARN << "SimpleHistogramCache::operator[] with null image called"; return 0; } Element *elementToUpdate = 0; bool first = true; for(CacheContainer::iterator iter = cache.begin(); iter != cache.end(); iter++) { Element *e = *iter; mitk::Image *p_tmp = e->image.GetPointer(); if(p_tmp == p_Image) { if(!first) { cache.erase(iter); cache.push_front(e); } if( p_Image->GetMTime() > e->m_LastUpdateTime.GetMTime()) goto recomputeElement; //MITK_INFO << "using a cached histogram"; return &e->histogram; } first = false; } elementToUpdate = new Element(); elementToUpdate->image = p_Image; cache.push_front(elementToUpdate); TrimCache(); recomputeElement: //MITK_INFO << "computing a new histogram"; elementToUpdate->histogram.ComputeFromImage(p_Image); elementToUpdate->m_LastUpdateTime.Modified(); return &elementToUpdate->histogram; }
void mitk::SimpleHistogramCache::TrimCache | ( | bool | full = false ) |
[inline, protected] |
Definition at line 185 of file QmitkTransferFunctionCanvas.h.
{ unsigned int targetSize = full?0:maxCacheSize; while(cache.size()>targetSize) { delete cache.back(); cache.pop_back(); } }
CacheContainer mitk::SimpleHistogramCache::cache [protected] |
Definition at line 118 of file QmitkTransferFunctionCanvas.h.
const unsigned int mitk::SimpleHistogramCache::maxCacheSize = 64 [static] |
Definition at line 104 of file QmitkTransferFunctionCanvas.h.