CachingDisplayData.h

Classes

CachingDisplayData -- Base class for auto-caching DisplayData objects. (full description)

class CachingDisplayData : public DisplayData

Interface

Public Members
CachingDisplayData()
virtual ~CachingDisplayData()
virtual void setDefaultOptions()
virtual Bool setOptions(Record &rec, Record &recOut)
virtual Record getOptions()
virtual void refreshEH(const WCRefreshEvent &ev)
virtual void notifyRegister(WorldCanvasHolder *wcHolder)
virtual void notifyUnregister(WorldCanvasHolder& wcHolder, Bool ignoreRefresh = False)
virtual void setColormap(Colormap *cmap, Float weight)
virtual void purgeCache()
virtual void purgeCache(const WorldCanvasHolder& wch)
Protected Members
virtual CachingDisplayMethod *newDisplayMethod(WorldCanvas *worldCanvas, AttributeBuffer *wchAttributes, AttributeBuffer *ddAttributes, CachingDisplayData *dd) = 0
virtual AttributeBuffer optionsAsAttributes()
virtual void setCaching(const Bool caching)
CachingDisplayData(const CachingDisplayData &other)
void operator=(const CachingDisplayData &other)
Private Members
void trimCache()
void installDefaultOptions()

Description

Prerequisite

Etymology

"CachingDisplayData" is an implementation of a DisplayData which provides automatic caching of individual depictions of the data.

Synopsis

This class adds to the interface defined in DisplayData . It adds an "automagic" caching system, which takes care of managing a set of individual drawings made by the DisplayData, and using previously generated drawing commands where applicable. For example, the user might be playing a movie of several frames in a DisplayData. The automagic caching will ensure that after one complete loop, while parameters affecting the display of the data do not change, all subsequent drawings will be made from a cache of drawing commands. Furthermore, provided the cache is large enough, the user may alter parameters, view some more frames, then return the parameters to their original state, and there may still be older cached drawings which can be used.

The automagic caching also handles the case where a single DisplayData is registered on more than one WorldCanvasHolder . Thus a miniature view of the data could be shown in one window, and an expanded view in another, with full automagic caching available on both.

This is a base class. Derived classes must implement the newDisplayMethod method, which is called to construct a new CachingDisplayMethod when the cache cannot satisfy the current drawing request. The method optionsAsAttributes should also be implemented: when a new CachingDisplayMethod is constructed, the return value of this method will be used to tag the parameters used in the drawing itself. Finally, the method cachingAttributes can be over-ridden, and should return any additional Attributes which should be considered in searches of the cache.

Motivation

Most DisplayData classes will offer more than one view of the data. Caching is therefore desirable to improve display speed for re-display of individual views of the data. It is nice to keep the caching in one place, hence this class.

Member Description

CachingDisplayData()

Constructor.

virtual ~CachingDisplayData()

Destructor.

virtual void setDefaultOptions()

Install the default options for this DisplayData.

virtual Bool setOptions(Record &rec, Record &recOut)

Apply options stored in rec to the DisplayData. A return value of True means a refresh is needed. recOut contains any fields which were implicitly changed as a result of the call to this function. The options handled by this class are:

  • cachesize: an integer specifying the maximum number of views which can be stored in the cache. The default value can be specified by the display.cachesize variable in the user's .aipsrc file, and in lieu of that, will be 256. If cachesize is lowered by a call to this method, the cache will be shrunk in size, with the oldest drawings being removed first.
  • virtual Record getOptions()

    Retrieve the current and default options and parameter types.

    virtual void refreshEH(const WCRefreshEvent &ev)

    Refresh event handler which is called indirectly by the WorldCanvas, via the WorldCanvasHolder. This function will take care of calling newDisplayMethod when necessary, and otherwise using an existing (previously cached) draw list.

    virtual void notifyRegister(WorldCanvasHolder *wcHolder)
    virtual void notifyUnregister(WorldCanvasHolder& wcHolder, Bool ignoreRefresh = False)

    virtual void setColormap(Colormap *cmap, Float weight)

    Purges cache, to avoid reusing images with the wrong colormap, then calls base class version.

    virtual void purgeCache()

    Empty cache completely.

    virtual void purgeCache(const WorldCanvasHolder& wch)

    Empty cache of all DMs for a given WCH.

    virtual CachingDisplayMethod *newDisplayMethod(WorldCanvas *worldCanvas, AttributeBuffer *wchAttributes, AttributeBuffer *ddAttributes, CachingDisplayData *dd) = 0

    Create a new (Caching)DisplayMethod for drawing on the given WorldCanvas when the AttributeBuffers are suitably matched to the current state of this DisplayData and of the WorldCanvas/Holder.

    virtual AttributeBuffer optionsAsAttributes()

    Return the current options of this DisplayData as an AttributeBuffer. The caller must delete the returned buffer.

    virtual void setCaching(const Bool caching)

    Turn caching on/off.

    CachingDisplayData(const CachingDisplayData &other)

    (Required) copy constructor.

    void operator=(const CachingDisplayData &other)

    (Required) copy assignment.

    void trimCache()

    Clear out cache entries beyond end of list.

    void installDefaultOptions()

    Install the default options for this DisplayData.