PixelCanvas.h

Classes

PixelCanvas -- Base class defining interface to pixel-based output devices. (full description)

class PixelCanvas

Interface

Public Members
virtual ~PixelCanvas()
void addRefreshEventHandler(const PCRefreshEH &eh)
void addMotionEventHandler(const PCMotionEH &eh)
void addPositionEventHandler(const PCPositionEH &eh)
void removeRefreshEventHandler(const PCRefreshEH &eh)
void removeMotionEventHandler(const PCMotionEH &eh)
void removePositionEventHandler(const PCPositionEH &eh)
void callRefreshEventHandlers(Display::RefreshReason reason)
void callMotionEventHandlers(Int x, Int y, uInt state)
void callPositionEventHandlers(Display::KeySym keysym, Bool keystate, Int x, Int y, uInt state)
virtual void enableMotionEvents() = 0
virtual void disableMotionEvents() = 0
virtual void enablePositionEvents() = 0
virtual void disablePositionEvents() = 0
virtual Bool supportsLists() = 0
virtual uInt newList() = 0
virtual void endList() = 0
virtual void drawList(uInt list) = 0
virtual void translateAllLists(Int xt, Int yt) = 0
virtual void translateList(uInt list, Int xt, Int yt) = 0
virtual void deleteList(uInt list) = 0
virtual void deleteLists() = 0
virtual Bool validList(uInt list) = 0
virtual Bool setFont(const String &fontName) = 0
virtual Bool setFont(DLFont* font)
virtual Bool setFont(const String& fontName, const Int fontSize)
virtual void drawText(Int x, Int y, const String &text, Display::TextAlign alignment = Display::AlignCenter) = 0
virtual void drawText(Int x, Int y, const String &text, const Float& angle, Display::TextAlign alignment = Display::AlignCenter)
virtual Int textWidth(const String& text)
virtual Int textHeight(const String& text)
virtual void drawImage(const Matrix<uInt> &data, Int x, Int y) = 0
virtual void drawImage(const Matrix<Int> &data, Int x, Int y) = 0
virtual void drawImage(const Matrix<uLong> &data, Int x, Int y) = 0
virtual void drawImage(const Matrix<Float> &data, Int x, Int y) = 0
virtual void drawImage(const Matrix<Double> &data, Int x, Int y) = 0
virtual void drawImage(const Int &x, const Int &y, const Matrix<uInt> &data, const Matrix<Bool> &mask)
virtual void drawImage(const Matrix<uInt> &data, Int x, Int y, uInt xzoom, uInt yzoom) = 0
virtual void drawImage(const Matrix<Int> &data, Int x, Int y, uInt xzoom, uInt yzoom) = 0
virtual void drawImage(const Matrix<uLong> &data, Int x, Int y, uInt xzoom, uInt yzoom) = 0
virtual void drawImage(const Matrix<Float> &data, Int x, Int y, uInt xzoom, uInt yzoom) = 0
virtual void drawImage(const Matrix<Double> &data, Int x, Int y, uInt xzoom, uInt yzoom) = 0
virtual void drawImage(const Matrix<uInt> &data, const Int &x, const Int &y, const Display::ColorComponent &colorcomponent) = 0
virtual void bufferComponent(const Matrix<uInt> &data, const Int &x, const Int &y, const Display::ColorComponent &colorcomponent) = 0
virtual void flushComponentBuffers() = 0
virtual void drawPoint(Int x1, Int y1) = 0
virtual void drawPoint(Float x1, Float y1) = 0
virtual void drawPoint(Double x1, Double y1) = 0
virtual void drawPoints(const Matrix<Int> &verts) = 0
virtual void drawPoints(const Matrix<Float> &verts) = 0
virtual void drawPoints(const Matrix<Double> &verts) = 0
virtual void drawPoints(const Vector<Int> &x1, const Vector<Int> &y1) = 0
virtual void drawPoints(const Vector<Float> &x1, const Vector<Float> &y1) = 0
virtual void drawPoints(const Vector<Double> &x1, const Vector<Double> &y1) = 0
virtual void drawLine(Int x1, Int y1, Int x2, Int y2) = 0
virtual void drawLine(Float x1, Float y1, Float x2, Float y2) = 0
virtual void drawLine(Double x1, Double y1, Double x2, Double y2) = 0
virtual void drawLines(const Matrix<Int> &verts) = 0
virtual void drawLines(const Matrix<Float> &verts) = 0
virtual void drawLines(const Matrix<Double> &verts) = 0
virtual void drawLines(const Vector<Int> &x1, const Vector<Int> &y1, const Vector<Int> &x2, const Vector<Int> &y2) = 0
virtual void drawLines(const Vector<Float> &x1, const Vector<Float> &y1, const Vector<Float> &x2, const Vector<Float> &y2) = 0
virtual void drawLines(const Vector<Double> &x1, const Vector<Double> &y1, const Vector<Double> &x2, const Vector<Double> &y2) = 0
virtual void drawPolyline(const Vector<Int> &x1, const Vector<Int> &y1) = 0
virtual void drawPolyline(const Vector<Float> &x1, const Vector<Float> &y1) = 0
virtual void drawPolyline(const Vector<Double> &x1, const Vector<Double> &y1) = 0
virtual void drawPolyline(const Matrix<Int> &verts) = 0
virtual void drawPolyline(const Matrix<Float> &verts) = 0
virtual void drawPolyline(const Matrix<Double> &verts) = 0
virtual void drawMarker(const Int& x1, const Int& y1, const Display::Marker& marker, const Int& pixelHeight)
virtual void drawMarker(const Float& x1, const Float& y1, const Display::Marker& marker, const Int& pixelHeight)
virtual void drawMarker(const Double& x1, const Double& y1, const Display::Marker& marker, const Int& pixelHeight)
virtual void drawPolygon(const Vector<Int> &x1, const Vector<Int> &y1) = 0
virtual void drawPolygon(const Vector<Float> &x1, const Vector<Float> &y1) = 0
virtual void drawPolygon(const Vector<Double> &x1, const Vector<Double> &y1) = 0
virtual void drawFilledPolygon(const Vector<Int> &x1, const Vector<Int> &y1) = 0
virtual void drawFilledPolygon(const Vector<Float> &x1, const Vector<Float> &y1) = 0
virtual void drawFilledPolygon(const Vector<Double> &x1, const Vector<Double> &y1) = 0
virtual void drawPolygon(const Matrix<Int> &verts) = 0
virtual void drawPolygon(const Matrix<Float> &verts) = 0
virtual void drawPolygon(const Matrix<Double> &verts) = 0
virtual void drawRectangle(Int x1, Int y1, Int x2, Int y2) = 0
virtual void drawRectangle(Float x1, Float y1, Float x2, Float y2) = 0
virtual void drawRectangle(Double x1, Double y1, Double x2, Double y2) = 0
virtual void drawFilledRectangle(Int x1, Int y1, Int x2, Int y2) = 0
virtual void drawFilledRectangle(Float x1, Float y1, Float x2, Float y2) = 0
virtual void drawFilledRectangle(Double x1, Double y1, Double x2, Double y2) = 0
virtual void drawColoredPoints(const Vector<Int> &x1, const Vector<Int> &y1, const Vector<uInt> &colors) = 0
virtual void drawColoredPoints(const Vector<Float> &x1, const Vector<Float> &y1, const Vector<uInt> &colors) = 0
virtual void drawColoredPoints(const Vector<Double> &x1, const Vector<Double> &y1, const Vector<uInt> &colors) = 0
virtual void drawColoredPoints(const Matrix<Int> &xy, const Vector<uInt> &colors)
virtual void drawColoredPoints(const Matrix<Float> &xy, const Vector<uInt> &colors)
virtual void drawColoredPoints(const Matrix<Double> &xy, const Vector<uInt> &colors)
virtual void drawColoredLines(const Vector<Int> &x1, const Vector<Int> &y1, const Vector<Int> &x2, const Vector<Int> &y2, const Vector<uInt> &colors) = 0
virtual void drawColoredLines(const Vector<Float> &x1, const Vector<Float> &y1, const Vector<Float> &x2, const Vector<Float> &y2, const Vector<uInt> &colors) = 0
virtual void drawColoredLines(const Vector<Double> &x1, const Vector<Double> &y1, const Vector<Double> &x2, const Vector<Double> &y2, const Vector<uInt> &colors) = 0
virtual void drawEllipse(const Float &cx, const Float &cy, const Float &smajor, const Float &sminor, const Float &pangle, Bool outline = True)
virtual void drawColoredEllipses(const Matrix<Float> &centres, const Vector<Float> &smajor, const Vector<Float> &sminor, const Vector<Float> &pangle, const Vector<uInt> &colors, const Float &scale = 1.0, const Bool &outline = True)
void bufferPoint(Float x, Float y)
void bufferLine(Float x1, Float y1, Float x2, Float y2)
void bufferPolylinePoint(Float x, Float y)
void bufferPolygonPoint(Float x, Float y)
void flushBuffer()
virtual void setDrawFunction(Display::DrawFunction function) = 0
virtual void setForeground(uLong color) = 0
virtual void setBackground(uLong color) = 0
virtual void setLineWidth(Float width) = 0
virtual void setLineStyle(Display::LineStyle style) = 0
virtual void setCapStyle(Display::CapStyle style) = 0
virtual void setJoinStyle(Display::JoinStyle style) = 0
virtual void setFillStyle(Display::FillStyle style) = 0
virtual void setFillRule(Display::FillRule rule) = 0
virtual void setArcMode(Display::ArcMode mode) = 0
virtual Display::DrawFunction getDrawFunction() const = 0
virtual uLong getForeground() const = 0
virtual uLong getBackground() const = 0
virtual Float getLineWidth() const = 0
virtual Display::LineStyle getLineStyle() const = 0
virtual Display::CapStyle getCapStyle() const = 0
virtual Display::JoinStyle getJoinStyle() const = 0
virtual Display::FillStyle getFillStyle() const = 0
virtual Display::FillRule getFillRule() const = 0
virtual Display::ArcMode getArcMode() const = 0
virtual Bool enable(Display::Option option) = 0
virtual Bool disable(Display::Option option) = 0
virtual void setImageCacheStrategy(Display::ImageCacheStrategy strategy) = 0
virtual Display::ImageCacheStrategy imageCacheStrategy() const = 0
virtual void setClipWindow(Int x1, Int y1, Int x2, Int y2) = 0
virtual void getClipWindow(Int &x1, Int &y1, Int &x2, Int &y2) = 0
void redraw()
virtual void refresh(const Display::RefreshReason &reason = Display::UserCommand, const Bool &explicitrequest = True) = 0
virtual void flush() = 0
virtual void clear() = 0
virtual void clear(Int x1, Int y1, Int x2, Int y2) = 0
virtual void setClearColor(uInt colorIndex) = 0
virtual void setClearColor(const String &colorname) = 0
virtual void setClearColor(float r, float g, float b) = 0
virtual uInt clearColor() const = 0
virtual void getClearColor(float &r, float &g, float &b) const = 0
virtual void setDeviceForegroundColor(const String colorname) = 0
virtual String deviceForegroundColor() const = 0
virtual void setDeviceBackgroundColor(const String colorname) = 0
virtual String deviceBackgroundColor() const = 0
virtual uInt width() const = 0
virtual uInt height() const = 0
virtual uInt depth() const = 0
virtual void pixelDensity(Float &xdpi, Float &ydpi) const = 0
virtual void setColor(uInt colorIndex) = 0
virtual void setColor(const String &colorname) = 0
virtual void setRGBColor(float r, float g, float b) = 0
virtual void setHSVColor(float h, float s, float v)
virtual Bool getColorComponents(const String &colorname, Float &r, Float &g, Float &b) = 0
virtual uInt color() const = 0
virtual void getColor(float &r, float &g, float &b) const = 0
virtual Bool getColor(Int x, Int y, uInt &color) = 0
virtual Bool getRGBColor(Int x, Int y, float &r, float &g, float &b) = 0
virtual Bool getHSVColor(Int x, Int y, float &h, float &s, float &v)
virtual Bool resize(uInt reqXSize, uInt reqYSize, Bool doCallbacks = True) = 0
virtual Bool resizeColorTable(uInt newSize) = 0
virtual Bool resizeColorTable(uInt nReds, uInt nGreens, uInt nBlues) = 0
virtual PixelCanvasColorTable * pcctbl() const = 0
virtual void setPcctbl(PixelCanvasColorTable * pcctbl) = 0
void setColormap(Colormap * map)
Colormap * colormap() const
Bool colormapRegistered()
void registerColormap(Colormap * dcmap, Float weight = 1.0)
void registerColormap(Colormap *cmap, Colormap *cmapToReplace)
void unregisterColormap(Colormap * dcmap)
uInt getColormapSize() const
void mapToColor(Array<uChar> &outArray, const Array<uChar> &inArray, Bool rangeCheck = False)
void mapToColor(Array<uShort> &outArray, const Array<uShort> &inArray, Bool rangeCheck = False)
void mapToColor(Array<uInt> &outArray, const Array<uInt> &inArray, Bool rangeCheck = False)
void mapToColor(Array<uLong> &outArray, const Array<uLong> &inArray, Bool rangeCheck = False)
void mapToColor(Array<uChar> &inOutArray, Bool rangeCheck = False)
void mapToColor(Array<uShort> &inOutArray, Bool rangeCheck = False)
void mapToColor(Array<uInt> &inOutArray, Bool rangeCheck = False)
void mapToColor(Array<uLong> &inOutArray, Bool rangeCheck = False)
void mapToColor3(Array<uLong> &out, const Array<Float> &chan1in, const Array<Float> &chan2in, const Array<Float> &chan3in)
void mapToColor3(Array<uLong> &out, const Array<Double> &chan1in, const Array<Double> &chan2in, const Array<Double> &chan3in)
virtual void mapToColor3(Array<uLong> &out, const Array<uInt> &chan1in, const Array<uInt> &chan2in, const Array<uInt> &chan3in)
virtual void pushMatrix() = 0
virtual void popMatrix() = 0
virtual void loadIdentity() = 0
virtual void translate(Int xt, Int yt) = 0
virtual void getTranslation(Int &xt, Int &yt) const = 0
virtual Int xTranslation() const = 0
virtual Int yTranslation() const = 0
Display::DrawBuffer drawBuffer() const
virtual void setDrawBuffer(Display::DrawBuffer buf) = 0
virtual void copyBackBufferToFrontBuffer() = 0
virtual void copyFrontBufferToBackBuffer() = 0
virtual void swapBuffers() = 0
virtual void copyBackBufferToFrontBuffer(Int x1, Int y1, Int x2, Int y2) = 0
virtual void copyFrontBufferToBackBuffer(Int x1, Int y1, Int x2, Int y2) = 0
virtual void swapBuffers(Int x1, Int y1, Int x2, Int y2) = 0
Display::DrawMode drawMode() const
Display::ColorModel colorModel() const
void setColorModel(Display::ColorModel colorModel)
Bool refreshActive() const
virtual Bool refreshAllowed() const
virtual Float pixelScaling() const
Protected Members
PixelCanvas()
PixelCanvas(PixelCanvasColorTable * pcctbl)
void setDrawMode(Display::DrawMode mode)
void setDrawBuffer_(Display::DrawBuffer buf)
Private Members
Matrix<Float> getMarker(const Display::Marker& marker, const Float& pixelHeight)

Description

Prerequisite

Etymology

PixelCanvas is the mechanism for drawing on the screen.

Synopsis

The philosophy of the PixelCanvas is to provide flexible fast interface to an underlying graphics system in terms of integer pixel positions and color values. The interface should be as simple as possible and not demand complicated structures on its interface.

The PixelCanvas performs minimal management, leaving up to the derived classes for most of the work required to interface to the underlying graphics library. /

To make it flexible, the fundamental interface accepts pointers to arrays of all the scalar AIPS++ types. The Bool type is not acceptable at the PixelCanvas level because it cannot be used to represent a color index, as are the two complex number types.

To make it fast, a caching mechanism is used to allow display lists to be created in the format native to the underlying graphics library. The caching works like OpenGL display lists.

To create a display list:

  1. Call the function newList() which will return a list id. You need to store the returned id somewhere so that it may be recalled later.
  2. Perform some drawing commands. These commands are output-only commands that change the state of the PixelCanvas or draw some graphics or other function that affects the canvas.
  3. Call the function endList()

To recall the drawing commands:

  1. Call drawList(), passing the list id as the parameter

To delete the list, call deleteList(), with the id

The PixelCanvas maintains a translation stack which may be driven by calls to translate and calls to pushMatrix, popMatrix.

The translation stack is an effective way to draw the same graphic in different places:

    
    uInt myGraphic = newList();
    ...
    endList();
    Matrix m(n,2);
    for (uInt i = 0; i < n; i++)
      {
        pc->pushMatrix();
        pc->translate(m(i,0), m(i,1));
        pc->drawList(myGraphic);
        pc->popMatrix();
      }
    
    

Images are most correctly drawn through the following sequence of operations

  1. Obtain the size of the current colormap with getColormapSize()
  2. scale your data to fit in the range of [0,size-1];
  3. call mapToColor() to get a proper color image (which you may consider saving).
  4. call drawImage()

You may find that a class derived from WCDataScaleHandler, such as WCLinearScaleHandler may be useful in step #2 above.

mapToColor is also useful for transforming values that are associated with vector graphics as well (e.g., contour lines).

The PixelCanvas layer is quite thin. Most functionality is implemented in the derived classes.

Motivation

Want a generic interface to possibly a variety of graphics hardware types. Want base class to maintain callback lists

Example

see the Display test directory

Member Description

virtual ~PixelCanvas()

void addRefreshEventHandler(const PCRefreshEH &eh)
void addMotionEventHandler(const PCMotionEH &eh)
void addPositionEventHandler(const PCPositionEH &eh)

add event handlers

void removeRefreshEventHandler(const PCRefreshEH &eh)
void removeMotionEventHandler(const PCMotionEH &eh)
void removePositionEventHandler(const PCPositionEH &eh)

remove event handlers

void callRefreshEventHandlers(Display::RefreshReason reason)
void callMotionEventHandlers(Int x, Int y, uInt state)
void callPositionEventHandlers(Display::KeySym keysym, Bool keystate, Int x, Int y, uInt state)

call event handlers

virtual void enableMotionEvents() = 0
virtual void disableMotionEvents() = 0
virtual void enablePositionEvents() = 0
virtual void disablePositionEvents() = 0

enabling/disabling of event tracking

virtual Bool supportsLists() = 0

Does this canvas support cached display lists? The user of the canvas should always check this, because undefined behaviour can result when an attempt is made to use a list on a PixelCanvas which does not support lists.

virtual uInt newList() = 0

begin caching display commands - return list ID

virtual void endList() = 0

end caching display commands

virtual void drawList(uInt list) = 0

(Cacheable) recall cached display commands

virtual void translateAllLists(Int xt, Int yt) = 0

translate all lists

virtual void translateList(uInt list, Int xt, Int yt) = 0

translate the list

virtual void deleteList(uInt list) = 0

remove list from cache

virtual void deleteLists() = 0

flush all lists from the cache

virtual Bool validList(uInt list) = 0

return True if the list exists

virtual Bool setFont(const String &fontName) = 0

(Cacheable) Set the font to the recognizable font name

virtual Bool setFont(DLFont* font)

TODO: These should become abstract Set the font via the DisplayLibrary Font class

virtual Bool setFont(const String& fontName, const Int fontSize)

Set the font to font name / size

virtual void drawText(Int x, Int y, const String &text, Display::TextAlign alignment = Display::AlignCenter) = 0

(Cacheable) Draw text using that font aligned in some way to the position

virtual void drawText(Int x, Int y, const String &text, const Float& angle, Display::TextAlign alignment = Display::AlignCenter)

TODO This should become abstract - NYI in GLPixelCanvas currently Draw text at a specified angle.

virtual Int textWidth(const String& text)
virtual Int textHeight(const String& text)

TODO : This should become abstract Determine the width / height of a string of text based on current settings.

virtual void drawImage(const Matrix<uInt> &data, Int x, Int y) = 0
virtual void drawImage(const Matrix<Int> &data, Int x, Int y) = 0
virtual void drawImage(const Matrix<uLong> &data, Int x, Int y) = 0
virtual void drawImage(const Matrix<Float> &data, Int x, Int y) = 0
virtual void drawImage(const Matrix<Double> &data, Int x, Int y) = 0

(Cacheable) Draw an array of 2D color data as a raster image for zoom = <1,1>

virtual void drawImage(const Int &x, const Int &y, const Matrix<uInt> &data, const Matrix<Bool> &mask)

(Cacheable) Draw an array of 2D color data as a raster image, taking note of the Bool mask.

virtual void drawImage(const Matrix<uInt> &data, Int x, Int y, uInt xzoom, uInt yzoom) = 0
virtual void drawImage(const Matrix<Int> &data, Int x, Int y, uInt xzoom, uInt yzoom) = 0
virtual void drawImage(const Matrix<uLong> &data, Int x, Int y, uInt xzoom, uInt yzoom) = 0
virtual void drawImage(const Matrix<Float> &data, Int x, Int y, uInt xzoom, uInt yzoom) = 0
virtual void drawImage(const Matrix<Double> &data, Int x, Int y, uInt xzoom, uInt yzoom) = 0

(Cacheable) Draw an array of 2D color data as a raster image for any positive integer zoom

virtual void drawImage(const Matrix<uInt> &data, const Int &x, const Int &y, const Display::ColorComponent &colorcomponent) = 0

(Cacheable) Draw a component of a multi-channel image, storing it in buffers until flushComponentImages() is called.

virtual void bufferComponent(const Matrix<uInt> &data, const Int &x, const Int &y, const Display::ColorComponent &colorcomponent) = 0

Fill one of the channel buffers.

virtual void flushComponentBuffers() = 0

(NOT CACHEABLE!) Flush the component buffers.

virtual void drawPoint(Int x1, Int y1) = 0
virtual void drawPoint(Float x1, Float y1) = 0
virtual void drawPoint(Double x1, Double y1) = 0

(Cacheable) Draw a single point using current color

virtual void drawPoints(const Matrix<Int> &verts) = 0
virtual void drawPoints(const Matrix<Float> &verts) = 0
virtual void drawPoints(const Matrix<Double> &verts) = 0

(Cacheable) Draw N points specified as a Nx2 matrix

virtual void drawPoints(const Vector<Int> &x1, const Vector<Int> &y1) = 0
virtual void drawPoints(const Vector<Float> &x1, const Vector<Float> &y1) = 0
virtual void drawPoints(const Vector<Double> &x1, const Vector<Double> &y1) = 0

(Cacheable) Draw a bunch of points using current color

virtual void drawLine(Int x1, Int y1, Int x2, Int y2) = 0
virtual void drawLine(Float x1, Float y1, Float x2, Float y2) = 0
virtual void drawLine(Double x1, Double y1, Double x2, Double y2) = 0

(Cacheable) Draw a single line using current color

virtual void drawLines(const Matrix<Int> &verts) = 0
virtual void drawLines(const Matrix<Float> &verts) = 0
virtual void drawLines(const Matrix<Double> &verts) = 0

(Cacheable) Draw N/2 lines from an Nx2 matrix

virtual void drawLines(const Vector<Int> &x1, const Vector<Int> &y1, const Vector<Int> &x2, const Vector<Int> &y2) = 0
virtual void drawLines(const Vector<Float> &x1, const Vector<Float> &y1, const Vector<Float> &x2, const Vector<Float> &y2) = 0
virtual void drawLines(const Vector<Double> &x1, const Vector<Double> &y1, const Vector<Double> &x2, const Vector<Double> &y2) = 0

(Cacheable) Draw a bunch of unrelated lines using current color

virtual void drawPolyline(const Vector<Int> &x1, const Vector<Int> &y1) = 0
virtual void drawPolyline(const Vector<Float> &x1, const Vector<Float> &y1) = 0
virtual void drawPolyline(const Vector<Double> &x1, const Vector<Double> &y1) = 0

(Cacheable) Draw a single connected line between the points given

virtual void drawPolyline(const Matrix<Int> &verts) = 0
virtual void drawPolyline(const Matrix<Float> &verts) = 0
virtual void drawPolyline(const Matrix<Double> &verts) = 0

(Cacheable) Draw N-1 connected lines from Nx2 matrix of vertices

virtual void drawMarker(const Int& x1, const Int& y1, const Display::Marker& marker, const Int& pixelHeight)
virtual void drawMarker(const Float& x1, const Float& y1, const Display::Marker& marker, const Int& pixelHeight)
virtual void drawMarker(const Double& x1, const Double& y1, const Display::Marker& marker, const Int& pixelHeight)

Draw a "marker". See Display for a list of available markers.

virtual void drawPolygon(const Vector<Int> &x1, const Vector<Int> &y1) = 0
virtual void drawPolygon(const Vector<Float> &x1, const Vector<Float> &y1) = 0
virtual void drawPolygon(const Vector<Double> &x1, const Vector<Double> &y1) = 0

(Cacheable) Draw a closed polygon

virtual void drawFilledPolygon(const Vector<Int> &x1, const Vector<Int> &y1) = 0
virtual void drawFilledPolygon(const Vector<Float> &x1, const Vector<Float> &y1) = 0
virtual void drawFilledPolygon(const Vector<Double> &x1, const Vector<Double> &y1) = 0

(Cacheable) Draw and fill a closed polygon

virtual void drawPolygon(const Matrix<Int> &verts) = 0
virtual void drawPolygon(const Matrix<Float> &verts) = 0
virtual void drawPolygon(const Matrix<Double> &verts) = 0

(Cacheable) Draw a closed N-sided polygon from Nx2 matrix of vertices

virtual void drawRectangle(Int x1, Int y1, Int x2, Int y2) = 0
virtual void drawRectangle(Float x1, Float y1, Float x2, Float y2) = 0
virtual void drawRectangle(Double x1, Double y1, Double x2, Double y2) = 0

(Cacheable) Draw a rectangle

virtual void drawFilledRectangle(Int x1, Int y1, Int x2, Int y2) = 0
virtual void drawFilledRectangle(Float x1, Float y1, Float x2, Float y2) = 0
virtual void drawFilledRectangle(Double x1, Double y1, Double x2, Double y2) = 0

(Cacheable) Draw a filled rectangle

virtual void drawColoredPoints(const Vector<Int> &x1, const Vector<Int> &y1, const Vector<uInt> &colors) = 0
virtual void drawColoredPoints(const Vector<Float> &x1, const Vector<Float> &y1, const Vector<uInt> &colors) = 0
virtual void drawColoredPoints(const Vector<Double> &x1, const Vector<Double> &y1, const Vector<uInt> &colors) = 0
virtual void drawColoredPoints(const Matrix<Int> &xy, const Vector<uInt> &colors)
virtual void drawColoredPoints(const Matrix<Float> &xy, const Vector<uInt> &colors)
virtual void drawColoredPoints(const Matrix<Double> &xy, const Vector<uInt> &colors)

(Cacheable) Draw a set of points, specifying a color per point to be drawn.

virtual void drawColoredLines(const Vector<Int> &x1, const Vector<Int> &y1, const Vector<Int> &x2, const Vector<Int> &y2, const Vector<uInt> &colors) = 0
virtual void drawColoredLines(const Vector<Float> &x1, const Vector<Float> &y1, const Vector<Float> &x2, const Vector<Float> &y2, const Vector<uInt> &colors) = 0
virtual void drawColoredLines(const Vector<Double> &x1, const Vector<Double> &y1, const Vector<Double> &x2, const Vector<Double> &y2, const Vector<uInt> &colors) = 0

(Cacheable) Draw a set of lines, specifying a color per line to be drawn.

virtual void drawEllipse(const Float &cx, const Float &cy, const Float &smajor, const Float &sminor, const Float &pangle, Bool outline = True)

Draw a single ellipse using the current pen (ie. color, thickness, style). The x and y location must be given, along with the semi-major and -minor axis lengths, and the position angle measured in degrees positive from the x axis in a counter-clockwise direction. If outline is False, the ellipse is solid filled, else it is just outlined.

virtual void drawColoredEllipses(const Matrix<Float> &centres, const Vector<Float> &smajor, const Vector<Float> &sminor, const Vector<Float> &pangle, const Vector<uInt> &colors, const Float &scale = 1.0, const Bool &outline = True)

Draw a set of colored ellipses, possibly with borders. The x and y locations must given, along with semi-major and semi-minor axes, and position angle measured in degrees positive from the x axis in a counter-clockwise direction. The size of the ellipses is globally scaled by the scale factor, and if outline is True, then each ellipse will have an outline in the current pen color.

void bufferPoint(Float x, Float y)

vector primitive buffering

void bufferLine(Float x1, Float y1, Float x2, Float y2)

void bufferPolylinePoint(Float x, Float y)

void bufferPolygonPoint(Float x, Float y)

void flushBuffer()

virtual void setLineWidth(Float width) = 0

Set Graphics Attributes Options for functions with enum argument listed in DisplayEnums

virtual void setLineWidth(uInt width) = 0;

virtual void setDrawFunction(Display::DrawFunction function) = 0
virtual void setForeground(uLong color) = 0
virtual void setBackground(uLong color) = 0
virtual void setLineStyle(Display::LineStyle style) = 0
virtual void setCapStyle(Display::CapStyle style) = 0
virtual void setJoinStyle(Display::JoinStyle style) = 0
virtual void setFillStyle(Display::FillStyle style) = 0
virtual void setFillRule(Display::FillRule rule) = 0
virtual void setArcMode(Display::ArcMode mode) = 0

Set Graphics Attributes Options for functions with enum argument listed in DisplayEnums

virtual Float getLineWidth() const = 0

Get Graphics Attributes

virtual uInt getLineWidth() const = 0;

virtual Display::DrawFunction getDrawFunction() const = 0
virtual uLong getForeground() const = 0
virtual uLong getBackground() const = 0
virtual Display::LineStyle getLineStyle() const = 0
virtual Display::CapStyle getCapStyle() const = 0
virtual Display::JoinStyle getJoinStyle() const = 0
virtual Display::FillStyle getFillStyle() const = 0
virtual Display::FillRule getFillRule() const = 0
virtual Display::ArcMode getArcMode() const = 0

Get Graphics Attributes

virtual Bool enable(Display::Option option) = 0
virtual Bool disable(Display::Option option) = 0

(Cacheable) Option Control Options listed in DisplayEnums

virtual void setImageCacheStrategy(Display::ImageCacheStrategy strategy) = 0

Control the image-caching strategy

virtual Display::ImageCacheStrategy imageCacheStrategy() const = 0

virtual void setClipWindow(Int x1, Int y1, Int x2, Int y2) = 0
virtual void getClipWindow(Int &x1, Int &y1, Int &x2, Int &y2) = 0

(Cacheable) Setup the clip window. The clip window, when enabled, allows a user to clip all graphics output to a rectangular region on the screen.

void redraw()
virtual void refresh(const Display::RefreshReason &reason = Display::UserCommand, const Bool &explicitrequest = True) = 0

(Not Cacheable) Redraw the window

virtual void flush() = 0

Cause display to flush any graphics commands not yet drawn

virtual void clear() = 0
virtual void clear(Int x1, Int y1, Int x2, Int y2) = 0

(Cacheable) Clear the window using the background color

virtual void setClearColor(uInt colorIndex) = 0
virtual void setClearColor(const String &colorname) = 0
virtual void setClearColor(float r, float g, float b) = 0

(Cacheable) Set the color to use for clearing the display

virtual uInt clearColor() const = 0

(Not Cacheable) Get the current color to use for clearing the display.

virtual void getClearColor(float &r, float &g, float &b) const = 0

virtual void setDeviceForegroundColor(const String colorname) = 0
virtual String deviceForegroundColor() const = 0
virtual void setDeviceBackgroundColor(const String colorname) = 0
virtual String deviceBackgroundColor() const = 0

Get/set the current foreground/background colors. These colors should be used when the special Strings "foreground" and "background" are given for a color.

virtual uInt width() const = 0

Return the width of the PixelCanvas in pixels

virtual uInt height() const = 0

Return the height of the PixelCanvas in pixels

virtual uInt depth() const = 0

Return the depth of the PixelCanvas in bits

virtual void pixelDensity(Float &xdpi, Float &ydpi) const = 0

Get the pixel density (in dots per inch [dpi]) of the PixelCanvas

virtual void setColor(uInt colorIndex) = 0
virtual void setColor(const String &colorname) = 0
virtual void setRGBColor(float r, float g, float b) = 0
virtual void setHSVColor(float h, float s, float v)

(Cacheable) Set current color (works in RGB or colormap mode)

virtual Bool getColorComponents(const String &colorname, Float &r, Float &g, Float &b) = 0

Get color components in range 0 to 1 without actually allocating the color. This is needed to set up other devices, for example PgPlot.

virtual uInt color() const = 0

(Not Cacheable) Returns the current color as a color index

virtual void getColor(float &r, float &g, float &b) const = 0

(Not Cacheable) Retuns the current color as an RGB triple

virtual Bool getColor(Int x, Int y, uInt &color) = 0
virtual Bool getRGBColor(Int x, Int y, float &r, float &g, float &b) = 0
virtual Bool getHSVColor(Int x, Int y, float &h, float &s, float &v)

(Not Cacheable) Get color index value (works in RGB or colormap mode)

virtual Bool resize(uInt reqXSize, uInt reqYSize, Bool doCallbacks = True) = 0

(Not Cacheable) resize request. returns true if window was resized. Will refresh if doCallbacks is True.

virtual Bool resizeColorTable(uInt newSize) = 0

(Not Cacheable) resize the colortable by requesting a new number of cells

virtual Bool resizeColorTable(uInt nReds, uInt nGreens, uInt nBlues) = 0

(Not Cacheable) resize the colortable by requesting a new RGB/HSV cube

virtual PixelCanvasColorTable * pcctbl() const = 0

Need a mechanism to return the PixelCanvasColorTable so drawing functions within classes can operate.

virtual void setPcctbl(PixelCanvasColorTable * pcctbl) = 0

void setColormap(Colormap * map)
Colormap * colormap() const
Bool colormapRegistered()

(Not Cacheable) set/get the current colormap. Undefined behavior results from setting the colormap to a map that is not registered. This cannot be cached because it affects the result of getColormapSize(). Remember that once data is mapped with mapToColor, it is no longer important to worry about which colormap is active for purposes of drawing the image or vectors. colormapRegistered() can be used to determine whether the currently set colormap() is indeed registered/installed (i.e., color cells have been allocated within the pcctbl).

void registerColormap(Colormap * dcmap, Float weight = 1.0)

register a colormap to the pixelcanvas. Registration counts are remembered, so that map A is guaranteed to be available as long as the number of register(A)'s exceed the number of unregister(A)'s. Requests are forwarded to the PixelCanvas' PixelCanvasColorTable.

void registerColormap(Colormap *cmap, Colormap *cmapToReplace)

Register the cmap Colormap on the PixelCanvas, replacing the cmapToReplace<src> Colormap if possible.

void unregisterColormap(Colormap * dcmap)

unregister a colormap from a pixelcanvas. Unregistering the current map may result in undefined behavior.

uInt getColormapSize() const

return the size of the current colormap

void mapToColor(Array<uChar> &outArray, const Array<uChar> &inArray, Bool rangeCheck = False)
void mapToColor(Array<uShort> &outArray, const Array<uShort> &inArray, Bool rangeCheck = False)
void mapToColor(Array<uInt> &outArray, const Array<uInt> &inArray, Bool rangeCheck = False)
void mapToColor(Array<uLong> &outArray, const Array<uLong> &inArray, Bool rangeCheck = False)

map [0,N-1] into colorpixels, where N is the current colormap size The values are returned as unsigned integers in their respective array.

WarninguChar type may not have enough bits to hold the pixel index on some high-end graphics systems
WarninguShort type may not have enough bits to hold the pixel index on some high-end graphics systems

void mapToColor(Array<uChar> &inOutArray, Bool rangeCheck = False)
void mapToColor(Array<uShort> &inOutArray, Bool rangeCheck = False)
void mapToColor(Array<uInt> &inOutArray, Bool rangeCheck = False)
void mapToColor(Array<uLong> &inOutArray, Bool rangeCheck = False)

same as above except the matrix is operated on in place. Only unsigned values make sense here.

void mapToColor3(Array<uLong> &out, const Array<Float> &chan1in, const Array<Float> &chan2in, const Array<Float> &chan3in)
void mapToColor3(Array<uLong> &out, const Array<Double> &chan1in, const Array<Double> &chan2in, const Array<Double> &chan3in)

Multi-Channel functions that combine separate array channels into a single array of output colors for use with functions that take color values. These two functions accept color values from [0-1] for each channel. The colorModel is compared with the model of the PixelCanvasColorTable and is used to perform the correct mapping.

virtual void mapToColor3(Array<uLong> &out, const Array<uInt> &chan1in, const Array<uInt> &chan2in, const Array<uInt> &chan3in)

This one maps values between 0 and the integer maximum value for each channel into a single output image suitable for PixelCanvas::drawImage.

virtual void pushMatrix() = 0
virtual void popMatrix() = 0

save/restore the current translation. This is called pushMatrix because eventually we may want scaling or rotation to play a modest role here.

virtual void loadIdentity() = 0

zero the current translation

virtual void translate(Int xt, Int yt) = 0
virtual void getTranslation(Int &xt, Int &yt) const = 0
virtual Int xTranslation() const = 0
virtual Int yTranslation() const = 0

translation functions translate applies a relative translation to the current matrix and can be used to position graphics. Together with pushMatrix and popMatrix it can be used to build heirarchical scenes.

Display::DrawBuffer drawBuffer() const

return the drawing buffer, the target destination for graphics

virtual void setDrawBuffer(Display::DrawBuffer buf) = 0

(Not cacheable) set the draw buffer

virtual void copyBackBufferToFrontBuffer() = 0
virtual void copyFrontBufferToBackBuffer() = 0
virtual void swapBuffers() = 0

buffer memory exchanges (Not cacheable)

virtual void copyBackBufferToFrontBuffer(Int x1, Int y1, Int x2, Int y2) = 0
virtual void copyFrontBufferToBackBuffer(Int x1, Int y1, Int x2, Int y2) = 0
virtual void swapBuffers(Int x1, Int y1, Int x2, Int y2) = 0

partial buffer memory exchanges. (x1,y1 are blc, x2,y2 are trc)

Display::DrawMode drawMode() const

return the drawmode (Compile or Draw) Compile drawmode means that a display list is currently being built Draw drawmode means that drawing commands are not cached but instead are sent to the display. This command is controlled by the caching state using newList()

Display::ColorModel colorModel() const

return the colorModel used for multichannel color

void setColorModel(Display::ColorModel colorModel)

Set the input color model for multichannel color

Bool refreshActive() const

return True if the refresh is active (Added for X11PixelCanvas DefaultBuffer)

virtual Bool refreshAllowed() const

return True if refresh is allowed right now...

virtual Float pixelScaling() const

PixelCanvas()

Abstract base class idiom

PixelCanvas(PixelCanvasColorTable * pcctbl)

void setDrawMode(Display::DrawMode mode)

Only allowed by derived classes

void setDrawBuffer_(Display::DrawBuffer buf)

Also allowed only by derived classes

Matrix<Float> getMarker(const Display::Marker& marker, const Float& pixelHeight)