casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Classes | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
casa::WorldCanvas Class Reference

Implementation of drawing in world coordinates on top of a PixelCanvas. More...

#include <WorldCanvas.h>

Inheritance diagram for casa::WorldCanvas:
casa::PCRefreshEH casa::PCMotionEH casa::PCPositionEH casa::DisplayEH casa::DisplayOptions

List of all members.

Classes

struct  ColorIndexedImage_
 ColorIndexedImage_ stores the state of a WorldCanvas::drawImage() rendering after the chosen data plane has been resampled to screen (Pixelcanvas) pixels and scaled to indices within a fixed-size Colormap, but prior to mapping to actual colors for display. More...

Public Member Functions

 WorldCanvas (PixelCanvas *pc, Double xOrigin=0.0, Double yOrigin=0.0, Double xSize=1.0, Double ySize=1.0)
 Construct a WorldCanvas on the given PixelCanvas, at the given origin (in fractions of the PixelCanvas extent), and having the given size (in the same units).
virtual ~WorldCanvas ()
 Destructor.
PixelCanvaspixelCanvas () const
 Return a pointer to the PixelCanvas on which this WorldCanvas is installed.
void addRefreshEventHandler (DisplayEH &eh)
 Add the given refresh, motion and position event handlers to the WorldCanvas.
void addMotionEventHandler (WCMotionEH &eh)
void addPositionEventHandler (WCPositionEH &eh)
void removeRefreshEventHandler (const DisplayEH &eh)
 Remove the given refresh, motion and position event handlers from the WorldCanvas.
void removeMotionEventHandler (const WCMotionEH &eh)
void removePositionEventHandler (const WCPositionEH &eh)
void callMotionEventHandlers (const WCMotionEvent &ev)
 Call all of the motion and position event handlers that are installed on the WorldCanvas.
void callPositionEventHandlers (const WCPositionEvent &ev)
virtual void handleEvent (DisplayEvent &ev)
 Handle other, generic types of events.
void operator() (const PCRefreshEvent &pev)
 Handle implicit refresh, motion and position events occuring on the PixelCanvas on which this WorldCanvas is installed.
void operator() (const PCMotionEvent &pev)
 Default just prints the event to cout.
void operator() (const PCPositionEvent &pev)
 Default just prints the event to cout.
void refresh (const Display::RefreshReason &reason=Display::UserCommand, const Bool &explicitrequest=True)
 Refresh the WorldCanvas for the given reason.
Bool refreshAllowed ()
 Is a refresh currently allowed?
void hold ()
 Hold and release response to refreshes requested with the refresh() member function.
void release ()
void setCoordinateHandler (WCCoordinateHandler *ch)
 Set Coordinate, SizeControl, Resample and DataScale handlers for the WorldCanvas.
void setSizeControlHandler (WCSizeControlHandler *sh)
void setResampleHandler (WCResampleHandler *rh)
void setDataScaleHandler (WCDataScaleHandler *sh)
void setWorldCanvasPosition (Double fracXOffset, Double fracYOffset, Double fracXSize, Double fracYSize)
 Set the location of the WorldCanvas on its PixelCanvas.
Bool pixToLin (Vector< Double > &lin, const Vector< Double > &pix)
 Pixel, linear and world coordinate transformation functions.
Bool pixToLin (Matrix< Double > &lin, Vector< Bool > &failures, const Matrix< Double > &pix)
Bool linToPix (Vector< Double > &pix, const Vector< Double > &lin)
Bool linToPix (Matrix< Double > &pix, Vector< Bool > &failures, const Matrix< Double > &lin)
Bool linToWorld (Vector< Double > &world, const Vector< Double > &lin)
Bool linToWorld (Matrix< Double > &world, Vector< Bool > &failures, const Matrix< Double > &lin)
Bool worldToLin (Vector< Double > &lin, const Vector< Double > &world)
Bool worldToLin (Matrix< Double > &lin, Vector< Bool > &failures, const Matrix< Double > &world)
Bool pixToWorld (Vector< Double > &world, const Vector< Double > &pix)
Bool pixToWorld (Matrix< Double > &world, Vector< Bool > &failures, const Matrix< Double > &pix)
Bool worldToPix (Vector< Double > &pix, const Vector< Double > &world)
Bool worldToPix (Matrix< Double > &pix, Vector< Bool > &failures, const Matrix< Double > &world)
void registerColormap (Colormap *cmap, Float weight=1.0)
 Register/unregister a Colormap on the PixelCanvas.
void registerColormap (Colormap *cmap, Colormap *cmapToReplace)
void unregisterColormap (Colormap *cmap)
void setColormap (Colormap *cmap)
 Set and retrieve the current Colormap on the PixelCanvas.
Colormapcolormap () const
uInt newList ()
 Display list support functions.
void endList ()
void drawList (uInt list)
void deleteList (uInt list)
void deleteLists ()
Bool validList (uInt list)
void setColor (const String &color)
 Set various graphics attributes.
void setClearColor (const String &color)
Bool setFont (const String &fontName)
void setForeground (uLong color)
void setBackground (uLong color)
void setLineWidth (Float width)
void setLineStyle (Display::LineStyle style)
void setCapStyle (Display::CapStyle style)
void setJoinStyle (Display::JoinStyle style)
void setFillStyle (Display::FillStyle style)
void setFillRule (Display::FillRule rule)
void setArcMode (Display::ArcMode mode)
Bool setWorldBackgroundColor (const String color)
 Set/retrieve the background and foreground colors of the WorldCanvas.
Bool setWorldForegroundColor (const String color)
String getWorldBackgroundColor ()
String getWorldForegroundColor ()
virtual void setDrawBuffer (Display::DrawBuffer buf)
 Set/retrieve the drawing buffer, the target destination for graphics.
Display::DrawBuffer drawBuffer () const
void setImageCacheStrategy (Display::ImageCacheStrategy strategy)
 Set/retrieve the caching strategy on the PixelCanvas.
Display::ImageCacheStrategy imageCacheStrategy () const
void clear ()
 Clear the WorldCanvas, or just the area on the WorldCanvas but outside the drawing area, ie.
void clearNonDrawArea ()
virtual void setDefaultOptions ()
 Install the default options for this DisplayData.
virtual Bool setOptions (const Record &rec, Record &updatedOptions)
 Apply options stored in rec to the DisplayData; return value True means a refresh is needed.
virtual Record getOptions () const
 Retrieve the current and default options and parameter types.
void setAttribute (Attribute &at)
 Set an Attribute or Attributes on the WorldCanvas.
void setAttributes (AttributeBuffer &at)
void removeAttribute (String &name)
 Remove an Attribute.
Bool getAttributeValue (const String &name, uInt &newValue) const
 User interface to get individual values from the attribute buffer.
Bool getAttributeValue (const String &name, Int &newValue) const
Bool getAttributeValue (const String &name, Float &newValue) const
Bool getAttributeValue (const String &name, Double &newValue) const
Bool getAttributeValue (const String &name, Bool &newValue) const
Bool getAttributeValue (const String &name, String &newValue) const
Bool getAttributeValue (const String &name, Vector< uInt > &newValue) const
Bool getAttributeValue (const String &name, Vector< Int > &newValue) const
Bool getAttributeValue (const String &name, Vector< Float > &newValue) const
Bool getAttributeValue (const String &name, Vector< Double > &newValue) const
Bool getAttributeValue (const String &name, Vector< Bool > &newValue) const
Bool getAttributeValue (const String &name, Vector< String > &newValue) const
Bool existsAttribute (String &name) const
 Check if a certain Attribute exists.
AttValue::ValueType attributeType (String &name) const
 Get the type of an Attribute.
virtual void acquirePGPLOTdevice (const Bool &linear=True)
 Position the PGPLOT filter on the WorldCanvas.
virtual void releasePGPLOTdevice ()
virtual Int pgid () const
 Return the PGPLOT device id for external use.
Bool drawText (const Vector< Double > &point, const String &text, Display::TextAlign alignment=Display::AlignCenter, const Bool &linear=False)
 Draw unrotated text at the given position.
Bool drawPoint (const Vector< Double > &point, const Bool &linear=False)
 Draw a single point using the current color.
Bool drawLine (const Vector< Double > &a, const Vector< Double > &b, const Bool &linear=False)
 Draw a single line using the current color.
Bool drawPoints (const Matrix< Double > &points, const Bool &linear=False)
 Draw a bunch of points using the current color.
Bool drawPoints (const Vector< Float > &px, const Vector< Float > &py, Bool linear=False)
 Draw a set of points using the current color.
Bool drawTextStrings (const Vector< Float > &px, const Vector< Float > &py, const Vector< String > &strings, const Float rotation=0.0, const Float xoffset=0.0, const Float yoffset=0.0, const Bool linear=False)
 Draw a set of text strings using the current color.
Bool drawMarkers (const Vector< Float > &px, const Vector< Float > &py, const Display::Marker=Display::Cross, const Int size=5, const Bool &linear=False)
 Draw a set of markers using the current color and a given pixel size.
Bool drawMappedMarkers (const Vector< Float > &px, const Vector< Float > &py, const Vector< Float > &values, const Int sizemin=1, const Int sizemax=20, const Display::Marker=Display::Cross, const Bool &linear=False)
Bool drawLines (const Matrix< Double > &vertices, const Bool &linear=False)
 Draw pairs of lines using the current color.
Bool drawPolyline (const Matrix< Double > &vertices, const Bool &linear=False)
 Draw a polyline (connected line) between the vertices using the current color.
Bool drawPolygon (const Matrix< Double > &vertices, const Bool &linear=False)
 Draw a polygon (closed line, or line loop using the points) using the current color.
Bool drawColormappedPoints (const Matrix< Double > &points, const Vector< Float > &values, const Bool &linear=False)
 Draw a set of points in colors which are taken from the current Colormap.
Bool drawColormappedEllipses (const Matrix< Double > &centres, const Vector< Float > &smajor, const Vector< Float > &sminor, const Vector< Float > &pangle, const Vector< Float > &colors, const Float &scale=1.0, const Bool &outline=True, const Bool &linear=False)
 Draw a set of colored ellipses, possibly with outlines.
Bool drawBeamEllipse (Float major, Float minor, Float pa, String majunit="arcsec", String minunit="arcsec", String paunit="deg", Float cx=.1f, Float cy=.1f, Bool outline=True)
 This routine is specialized for drawing image restoring-beam ellipses.
bool drawContourMap (const Vector< Double > &blPos, const Vector< Double > &trPos, const Matrix< Float > &data, const Vector< Float > &levels, const Bool usePixelEdges=False)
 Draw a contour map at the specified levels, and place the lower left pixel at blPos, and the upper right pixel at trPos.
bool drawContourMap (const Vector< Double > &blPos, const Vector< Double > &trPos, const Matrix< Complex > &data, const Vector< Float > &levels, const Bool usePixelEdges=False)
bool drawContourMap (const Vector< Double > &blPos, const Vector< Double > &trPos, const Matrix< Float > &data, const Matrix< Bool > &mask, const Vector< Float > &levels, const Bool usePixelEdges=False)
 Draw a contour map at the specified levels, and place the lower left pixel at blPos, and the upper right pixel at trPos.
bool drawContourMap (const Vector< Double > &blPos, const Vector< Double > &trPos, const Matrix< Complex > &data, const Matrix< Bool > &mask, const Vector< Float > &levels, const Bool usePixelEdges=False)
Bool redrawIndexedImage (void *drawObj, Display::RefreshReason reason, Bool opaqueMask=False)
 Optimization to speed up colormap fiddling in 24bit mode (software Colormap); see images_, below for usage.
Bool removeIndexedImage (void *drawObj)
 Remove image from the colormap change cache, if any (see images_, below).
void clearColormapChangeCache ()
 Clear the whole colormap change cache (see images_, below).
void drawImage (const Vector< Double > &blPos, const Vector< Double > &trPos, const Matrix< Float > &data, const Bool usePixelEdges=False, void *drawObj=0)
 Draw an image, mapping data values to Colormap entries, and place the lower left pixel at blPos, and the upper right pixel at trPos.
void drawImage (const Vector< Double > &blPos, const Vector< Double > &trPos, const Matrix< Complex > &data, const Bool usePixelEdges=False, void *drawObj=0)
void drawImage (const Vector< Double > &blPos, const Vector< Double > &trPos, const Matrix< Float > &data, const Matrix< Bool > &mask, const Bool usePixelEdges=False, void *drawObj=0, Bool opaqueMask=False)
 
    Draw an image, mapping data values to Colormap entries, and place

the lower left pixel at blPos, and the upper right pixel at trPos.

void drawImage (const Vector< Double > &blPos, const Vector< Double > &trPos, const Matrix< Complex > &data, const Matrix< Bool > &mask, const Bool usePixelEdges=False, void *drawObj=0, Bool opaqueMask=False)
void drawImage (const Vector< Double > &blPos, const Vector< Double > &trPos, const Matrix< Float > &data, const Display::ColorComponent &colorcomponent, const Bool usePixelEdges=False)
 Draw a component of a multi-channel image, mapping data values to component levels, and place the lower left pixel at blPos, and the upper right pixel at trPos.
void drawImage (const Vector< Double > &blPos, const Vector< Double > &trPos, const Matrix< Complex > &data, const Display::ColorComponent &colorcomponent, const Bool usePixelEdges=False)
bool drawVectorMap (const Vector< Double > &blc, const Vector< Double > &trc, const Matrix< Complex > &data, const Matrix< Bool > &mask, Float angleConversionFactor, Float phasePolarity, Bool debias, Float variance, Int xPixelInc, Int yPixelInc, Float scale, Bool arrow, Float barb, Float rotation, Double xWorldInc, Double yWorldInc, const Bool usePixelEdges)
 Draw a vector map.
bool drawVectorMap (const Vector< Double > &blc, const Vector< Double > &trc, const Matrix< Float > &data, const Matrix< Bool > &mask, Float angleConversionFactor, Float phasePolarity, Bool debias, Float variance, Int xPixelInc, Int yPixelInc, Float scale, Bool arrow, Float barb, Float rotation, Double xWorldInc, Double yWorldInc, const Bool usePixelEdges)
bool drawMarkerMap (const Vector< Double > &blc, const Vector< Double > &trc, const Matrix< Float > &data, const Matrix< Bool > &mask, Int xPixelInc, Int yPixelInc, Float scale, Double xWorldInc, Double yWorldInc, const String &markeType, Bool usePixelEdges)
 Draw marker maps.
bool drawMarkerMap (const Vector< Double > &blc, const Vector< Double > &trc, const Matrix< Complex > &data, const Matrix< Bool > &mask, Int xPixelInc, Int yPixelInc, Float scale, Double xWorldInc, Double yWorldInc, const String &markerType, Bool usePixelEdges)
void flushComponentImages ()
 Flush the component images, ie.
void copyBackBufferToFrontBuffer ()
 Buffer memory exchanges which operate only on the area of the WorldCanvas.
void copyFrontBufferToBackBuffer ()
void swapBuffers ()
Double linXMin () const
 Provide information on the extents of the linear coordinate system.
Double linYMin () const
Double linXMax () const
Double linYMax () const
Double linXMinLimit () const
 Provide information on the limits of the linear coordinate system.
Double linYMinLimit () const
Double linXMaxLimit () const
Double linYMaxLimit () const
uInt canvasXOffset () const
 Provide information on the WorldCanvas offset and size.
uInt canvasYOffset () const
uInt canvasXSize () const
uInt canvasYSize () const
uInt canvasDrawXOffset () const
 Provide information on the WorldCanvas drawable offset and size.
uInt canvasDrawYOffset () const
uInt canvasDrawXSize () const
uInt canvasDrawYSize () const
void setZoomRectangleLCS (const Vector< Double > &min, const Vector< Double > &max)
 Set the zoom rectangle to the specfied linear coordinate range.
void moveZoomRectangleLCS (double dx, double dy)
 Move the zoom rectangle across the screen, ie.
void resetZoomRectangle ()
 Reset the zoom to show the entire allowable range of the linear coordinate system.
void setLinearCoordinateSystem (const Vector< Double > &blc, const Vector< Double > &trc, Bool resetZoom=True)
 Set the allowable range of the linear coordinate system.
Double dataMin () const
 Functions to set and retrieve the minimum and maximum data values for scaling data that is drawn on the WorldCanvas.
void setDataMin (Double min)
Double dataMax () const
void setDataMax (Double max)
void setDataMinMax (Double min, Double max)
Display::ComplexToRealMethod complexToRealMethod () const
 ComplexToRealMethod defines which real component of a Complex image to extract when it is necessary to convert Complex data into real data.
void setComplexToRealMethod (const Display::ComplexToRealMethod method)
void setCoordinateSystem (const CoordinateSystem &csys)
 Set and retrieve the CoordinateSystem of this WorldCanvas.
const CoordinateSystemcoordinateSystem () const
Bool hasCS () const
Bool inDrawArea (Int x, Int y) const
 Convenience functions returning whether a pixel coordinate is within bounds of the WC's inner draw area, the WC, or the underlying PC.
Bool inWC (Int x, Int y) const
Bool inPC (Int x, Int y)
void setRestriction (const Attribute &restriction)
 Install a single restriction, or a buffer of restrictions, on the WorldCanvas which DisplayData must match in order that they be allowed to draw themselves.
void setRestrictions (const AttributeBuffer &resBuff)
const Bool existRestriction (const String &name) const
 Check if a named restriction exists.
void removeRestriction (const String &restrictionName)
 Remove the named restriction, or all restrictions, from the WorldCanvas.
void removeRestrictions ()
Bool matchesRestriction (const Attribute &restriction) const
 Determine whether the restrictions installed on the WorldCanvas match the given restriction or buffer of restrictions.
Bool matchesRestrictions (const AttributeBuffer &buffer) const
const AttributeBufferrestrictionBuffer () const
 Return the buffer of restrictions installed on this WorldCanvas.
int zIndex () const
 convienience function based on "restriction buffer"...
const DisplayDatacsMaster () const
 The DD in charge of setting WC coordinate state (0 if none).
DisplayData *& csMaster ()
Bool isCSmaster (const DisplayData *dd) const
 Is the specified DisplayData the one in charge of WC state? (During DD::sizeControl() execution, it means instead that the DD has permission to become CSmaster, if it can).
virtual Vector< StringworldAxisNames () const
 Return the names and units of the world coordinate axes.
virtual Vector< StringworldAxisUnits () const
const std::list< DisplayData * > & displaylist () const
 
   

Static Public Attributes

static const String LEFT_MARGIN_SPACE_PG
static const String RIGHT_MARGIN_SPACE_PG
static const String BOTTOM_MARGIN_SPACE_PG
static const String TOP_MARGIN_SPACE_PG

Private Member Functions

void ctorInit ()
 Support for construction.
void callRefreshEventHandlers (const WCRefreshEvent &ev)
 Call all registered refresh handlers (public method is refresh()).
void updateCanvasSizesOffsets ()
 Update canvas sizes/offsets from the fracOffsets, and vice versa.
void updateFracSizesOffsets ()
Bool castingConversion (Vector< Int > &pixelpt, const Vector< Double > &worldpt, const Bool &linear)
 Convert the given coordinate/s to pixel coordinates.
Bool castingConversion (Matrix< Int > &pixelpts, const Matrix< Double > &worldpts, const Bool &linear)
Bool castingConversion (Matrix< Float > &pixelpts, const Matrix< Double > &worldpts, const Bool &linear)
Bool castingClippingConversion (Vector< Int > &pixelx, Vector< Int > &pixely, Vector< Bool > &validConversions, const Vector< Float > &worldx, const Vector< Float > &worldy, const Bool linear)
 Convert the given coordinate/s to pixel coordinates.
bool drawVectorMap (const Vector< Double > &blc, const Vector< Double > &trc, const Matrix< Float > &amp, const Matrix< Float > &pa, const Matrix< Bool > &mask, Float angleConversionFactor, Float phasePolarity, Bool debias, Float variance, Int xPixelInc, Int yPixelInc, Float scale, Bool arrow, Float barb, Float rotation, Double xWorldInc, Double yWorldInc, const Bool usePixelEdges)
 Actually draw the vector field.
void trimAndResampleImage (Vector< Double > &drawBlc, Vector< Double > &drawTrc, Matrix< Float > &sampledImage, const Vector< Double > &blc, const Vector< Double > &trc, const Matrix< Float > &data, const Bool &usePixelEdges=False)
 Trim and resample an image, returning the actual world BLC and TRC for drawing, and the resampled image.
void trimAndResampleImage (Vector< Double > &drawBlc, Vector< Double > &drawTrc, Matrix< Float > &sampledImage, Matrix< Bool > &resampledMask, const Vector< Double > &blc, const Vector< Double > &trc, const Matrix< Float > &data, const Matrix< Bool > &mask, const Bool &usePixelEdges=False)
 Trim and resample an image, returning the actual world BLC and TRC for drawing, and the resampled image.
void mapToColorAndDrawImage (const Vector< Int > &blc, const Matrix< uInt > &scaledImage)
 Draw an image where scaledImage gives the Colormap index of each screen (PixelCanvas) pixel.
void mapToColorAndDrawImage (const Vector< Int > &blc, const Matrix< uInt > &scaledImage, const Matrix< Bool > &mask, Bool opaqueMask=False)
Bool mapToColorAndDrawPoints (const Matrix< Double > &points, const Vector< uInt > &scaledValues, const Bool &linear=False)
 Draw a set of points where scaledValues gives the Colormap index of each point.
Bool mapToColorAndDrawEllipses (const Matrix< Double > &centres, const Vector< Float > &smajor, const Vector< Float > &sminor, const Vector< Float > &pangle, const Vector< uInt > scaledValues, const Float &scale, const Bool &outline, const Bool &linear)
 Draw a set of ellipses where scaledValues gives the Colormap index of each point.
ColorIndexedImage_getClearedColorIndexedImage (void *drawObj=0)
 Retrieve an indexed image to write onto.

Private Attributes

uInt itsCanvasXOffset
 ***Cached*** blc pixel where this world canvas begins = itsPixelCanvas->width()*frac(X|Y)Offset_.
uInt itsCanvasYOffset
uInt itsCanvasXSize
 ***Cached*** number of pixels in each dimension given to the world canvas = itsPixelCanvas->width()*(frac(X|Y)Size_.
uInt itsCanvasYSize
Double itsFracXOffset
 Fractional position of world canvas on pixel canvas.
Double itsFracYOffset
Double itsFracXSize
Double itsFracYSize
uInt itsCanvasDrawXOffset
 ***Cached*** blc pixel where the world canvas 'draw area' (inside margins, labels) begins, relative to WC blc.
uInt itsCanvasDrawYOffset
uInt itsCanvasDrawXSize
 ***Cached*** number of pixels in each dimension given to the drawable part of the world canvas
uInt itsCanvasDrawYSize
Double itsLinXMin
 Linear Coordinate System ranges.
Double itsLinYMin
Double itsLinXMax
Double itsLinYMax
Double itsLinXMinLimit
 Linear Coordinate System Limits.
Double itsLinYMinLimit
Double itsLinXMaxLimit
Double itsLinYMaxLimit
Double itsDataMin
 Dynamic data minimum and maximum for this WorldCanvas.
Double itsDataMax
Display::ComplexToRealMethod itsComplexToRealMethod
 Method to use to convert complex data into real values.
List< DisplayEH * > itsRefreshEHList
 Event handler lists and convenient iterators.
List< WCPositionEH * > itsPositionEHList
List< WCMotionEH * > itsMotionEHList
ListIter< DisplayEH * > * itsREHListIter
ListIter< WCPositionEH * > * itsPEHListIter
ListIter< WCMotionEH * > * itsMEHListIter
WCSizeControlHandleritsSizeControlHandler
 Other handler lists.
WCCoordinateHandleritsCoordinateHandler
WCResampleHandleritsResampleHandler
WCDataScaleHandleritsDataScaleHandler
Bool itsOwnSizeControlHandler
 Store whether we "own" the various handlers.
Bool itsOwnCoordinateHandler
Bool itsOwnResampleHandler
Bool itsOwnDataScaleHandler
AttributeBuffer attributes
 Buffer for Attributes.
String itsWorldBackgroundColor
 Background/foreground colors.
String itsWorldForegroundColor
PixelCanvasitsPixelCanvas
 PixelCanvas pointer.
WCPGFilteritsPGFilter
 PGPLOT filter.
Int itsHoldCount
 Status of hold/release.
Bool itsRefreshHeld
Display::RefreshReason itsHeldReason
CoordinateSystemitsCoordinateSystem
 The CoordinateSystem for this WorldCanvas.
Bool itsGrabbing
 This state is set True when the pointer is in this WC and a pointer button is pressed (with no buttons pressed previously).
SimpleOrderedMap< void
*, ColorIndexedImage_ * > 
images_
 Cache of pre-drawn ColorIndexedImage_'s.
AttributeBuffer itsRestrictions
 A buffer to contain the restrictions that DisplayDatas must match if they are to be allowed to draw themselves.
DisplayDataitsCSmaster
 [First] responder to 'sizeControl', responsible for setting WC CS, zoom window and draw area.
uInt itsId
 itsId & itsRef used to ensure thread-safe execution of pgplot
uInt itsRef
 WorldCanvas::refresh is a recursive function.

Detailed Description

Implementation of drawing in world coordinates on top of a PixelCanvas.

Prerequisite

Etymology

WorldCanvas is a canvas on which primitives specified in world coordinates are drawn.

Synopsis

The world canvas manages a portion of a PixelCanvas and provides mechanisms to allow the user to draw images and vectors in world coordinates. The position of the WorldCanvas may be dynamically changed.

The WorldCanvas vector graphics commands assume world coordinates are specified and use a registered coordinate handler to map those coordinates via a linear system to pixel coordinates. The pixel coordinates are then sent on to the PixelCanvas where they are plotted.

Images are drawn by sending a Matrix and specifying the world-coordinate location of the center of the lower-left pixel. If the dataMin and dataMax values have been set, they will be used to scale the data, otherwise the min and max will be scanned.

Customizable tools associated with the WorldCanvas available to assist with various aspects of display.

The interface for these tools are implemented as abstract base classes, and the tools are implemented by deriving from these classes and overriding the functions contained therein.

The WorldCanvas provides an interface to the PixelCanvas caching mechanism. Clever use of caching and parsing of the reason field of a WCRefreshEvent can reduce unnecessary recomputation needed for refreshing the screen.

The WorldCanvas maintains a set of Attribute s which the user can set on the WorldCanvas. An Attribute is a combination of a name and a value, the value can be of type uInt, Int, Float, Double, Bool and String, and Vectors of these. These Attributes serve two purposes: 1) to allow to place (using the member functions setAttribute and setAttributes) more or less arbitrary information on the WorldCanvas that other classes can read from the WorldCanvas. Since the name of an Attribute can be defined at run time, any name can be used (i.e. there is no pre-defined set of names that can only be used), and 2) to have a generic interface to some of the internal variables of the WorldCanvas. Some internal variabels can be set/read with their own interface routine (e.g. linXMin and friends using setZoomRectangleLCS), but they can also be modified/read using the Attribute interface (using getAttributeValue). The use of e.g. SetZoomRectangleLCS() and setAttribute() is equivalent. See AttributeBuffer for more details. The following Attributes (and their types) are pre-defined on the WorldCanvas and can be accessed using the Attribute interface (note: these Attributes cannot be deleted using removeAttribute()):

The WorldCanvas knows three coordinate systems.

Motivation

Wanted a world-coordinate plotting canvas

Example

See the test programs in Display/test

To Do

Definition at line 205 of file WorldCanvas.h.


Constructor & Destructor Documentation

casa::WorldCanvas::WorldCanvas ( PixelCanvas pc,
Double  xOrigin = 0.0,
Double  yOrigin = 0.0,
Double  xSize = 1.0,
Double  ySize = 1.0 
)

Construct a WorldCanvas on the given PixelCanvas, at the given origin (in fractions of the PixelCanvas extent), and having the given size (in the same units).

virtual casa::WorldCanvas::~WorldCanvas ( ) [virtual]

Destructor.


Member Function Documentation

virtual void casa::WorldCanvas::acquirePGPLOTdevice ( const Bool linear = True) [virtual]

Position the PGPLOT filter on the WorldCanvas.

If linear is specified False, then the alignment is done by world coordinates, assuming that a linear approximation is valid. void verifyPGFilterAlignment(const Bool &linear = True);

Acquire and release a PGPLOT device for this WorldCanvas. This is necessary since PGPLOT generally only supports 8 currently active devices. So refresh cycles on the WorldCanvas acquire a PGPLOT device at the start, and release it at the end. Cycles are counted so that external user-classes can call these functions if necessary in a nested state. If linear is specified as False, then the PGPLOT device is aligned by world coordinates, under the assumption that a linear approximation is valid, that is, the curvature is small.

Add the given refresh, motion and position event handlers to the WorldCanvas.

Get the type of an Attribute.

Call all of the motion and position event handlers that are installed on the WorldCanvas.

Call all registered refresh handlers (public method is refresh()).

Provide information on the WorldCanvas drawable offset and size.

Definition at line 894 of file WorldCanvas.h.

References itsCanvasDrawXOffset.

Definition at line 898 of file WorldCanvas.h.

References itsCanvasDrawXSize.

Definition at line 896 of file WorldCanvas.h.

References itsCanvasDrawYOffset.

Definition at line 900 of file WorldCanvas.h.

References itsCanvasDrawYSize.

Provide information on the WorldCanvas offset and size.

Definition at line 882 of file WorldCanvas.h.

References itsCanvasXOffset.

Definition at line 886 of file WorldCanvas.h.

References itsCanvasXSize.

Definition at line 884 of file WorldCanvas.h.

References itsCanvasYOffset.

Definition at line 888 of file WorldCanvas.h.

References itsCanvasYSize.

Bool casa::WorldCanvas::castingClippingConversion ( Vector< Int > &  pixelx,
Vector< Int > &  pixely,
Vector< Bool > &  validConversions,
const Vector< Float > &  worldx,
const Vector< Float > &  worldy,
const Bool  linear 
) [private]

Convert the given coordinate/s to pixel coordinates.

If linear is True, then the input coordinates are linear world coordinates, otherwise they are true world coordinates. This version applies clipping, so that any points in the series which lie outside the linear coordinate range of the WorldCanvas are discarded. Thus the output Vectors can be shorter than the input Vectors. A mask indicating which of the input points were valid is returned for user reference.

Bool casa::WorldCanvas::castingConversion ( Vector< Int > &  pixelpt,
const Vector< Double > &  worldpt,
const Bool linear 
) [private]

Convert the given coordinate/s to pixel coordinates.

If linear is True, then the given coordinates are in linear world coordinates, otherwise they are real world coordinates. A return value of False indicates the conversion failed.

Bool casa::WorldCanvas::castingConversion ( Matrix< Int > &  pixelpts,
const Matrix< Double > &  worldpts,
const Bool linear 
) [private]
Bool casa::WorldCanvas::castingConversion ( Matrix< Float > &  pixelpts,
const Matrix< Double > &  worldpts,
const Bool linear 
) [private]

Clear the WorldCanvas, or just the area on the WorldCanvas but outside the drawing area, ie.

the margins that are normally reserved for axis labels and the like.

Clear the whole colormap change cache (see images_, below).

ComplexToRealMethod defines which real component of a Complex image to extract when it is necessary to convert Complex data into real data.

Definition at line 941 of file WorldCanvas.h.

References itsComplexToRealMethod.

Buffer memory exchanges which operate only on the area of the WorldCanvas.

(Not cacheable yet.)

const DisplayData* casa::WorldCanvas::csMaster ( ) const [inline]

The DD in charge of setting WC coordinate state (0 if none).

Definition at line 1014 of file WorldCanvas.h.

References itsCSmaster.

Referenced by casa::WorldCanvasHolder::csMaster(), and isCSmaster().

Definition at line 1015 of file WorldCanvas.h.

References itsCSmaster.

void casa::WorldCanvas::ctorInit ( ) [private]

Support for construction.

Double casa::WorldCanvas::dataMax ( ) const [inline]

Definition at line 929 of file WorldCanvas.h.

References itsDataMax.

Double casa::WorldCanvas::dataMin ( ) const [inline]

Functions to set and retrieve the minimum and maximum data values for scaling data that is drawn on the WorldCanvas.

These values are forwarded to the scale handler, when, for example, images are drawn.

Definition at line 925 of file WorldCanvas.h.

References itsDataMin.

const std::list<DisplayData*>& casa::WorldCanvas::displaylist ( ) const

   

Bool casa::WorldCanvas::drawBeamEllipse ( Float  major,
Float  minor,
Float  pa,
String  majunit = "arcsec",
String  minunit = "arcsec",
String  paunit = "deg",
Float  cx = .1f,
Float  cy = .1f,
Bool  outline = True 
)

This routine is specialized for drawing image restoring-beam ellipses.

Its parameters are defined so as to require as little conversion as possible of restoring beam information as stored in an image header.

It does nothing unless the axes on display map to the two axes of a DirectionCoordinate within the WC CS (WorldCanvas::itsCoordinateSystem). Center location cx,cy is specified as a fraction of WC draw area: (0,0) is blc, (1,1) is trc; they default to (.1, .1).

The unit strings for major,minor are given in in majunit, minunit, and should be valid angular units (they default to "arcsec"). major/minor are the full major and minor axis sizes in terms of relative direction world coordinates.

pa specifies "position angle", in the angular units specified by paunit. pa uses the image header convention "North-to-East"; more precisely, 0 degrees aligns the major axis along increasing DirCoord(1) (commonly Dec), 90 degrees aligns it along increasing DirCoord(0) (commonly RA). (NB: increasing RA commonly means decreasing pixel/Lattice coordinates). In the common case, this means that pa increases counterclockwise from vertical. Note that this is not the pa convention in some other PixelCanvas/WorldCanvas drawEllipse() routines (where pa is always counterclockwise from horizontal).

Also note: this routine attempts to do the right thing in oddball cases such as displaying Dec on the horizontal axis (pa 0 would also be horizontal in that case), distorted ('flexible') aspect ratio (ellipse also distorted appropriately) or all-sky images in which the beam may be displayed in a canvas area where absolute world coordinates do not exist. It should even take care of uneven coordinate 'increments' (non-square image data pixels). (So far, it does not correctly handle non-identity transformation matrices in the DirectionCoordinate (e.g. rotated "North")-- which I think is true in many other places as well... -- for someone's to-do list (not mine, I hope)).

Bool casa::WorldCanvas::drawColormappedEllipses ( const Matrix< Double > &  centres,
const Vector< Float > &  smajor,
const Vector< Float > &  sminor,
const Vector< Float > &  pangle,
const Vector< Float > &  colors,
const Float scale = 1.0,
const Bool outline = True,
const Bool linear = False 
)

Draw a set of colored ellipses, possibly with outlines.

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.

Bool casa::WorldCanvas::drawColormappedPoints ( const Matrix< Double > &  points,
const Vector< Float > &  values,
const Bool linear = False 
)

Draw a set of points in colors which are taken from the current Colormap.

bool casa::WorldCanvas::drawContourMap ( const Vector< Double > &  blPos,
const Vector< Double > &  trPos,
const Matrix< Float > &  data,
const Vector< Float > &  levels,
const Bool  usePixelEdges = False 
)

Draw a contour map at the specified levels, and place the lower left pixel at blPos, and the upper right pixel at trPos.

If usePixelEdges is True, then the given world positions are the position of the blc and trc of the blc and trc pixels, otherwise they are the positions of the centres of the pixels. Note that the contours are not intrinsically drawn in world coordinates. For complex data, the conversion to real values is done according to the last call to setComplexToRealMethod. Returns true if OK, false if error...

bool casa::WorldCanvas::drawContourMap ( const Vector< Double > &  blPos,
const Vector< Double > &  trPos,
const Matrix< Complex > &  data,
const Vector< Float > &  levels,
const Bool  usePixelEdges = False 
)
bool casa::WorldCanvas::drawContourMap ( const Vector< Double > &  blPos,
const Vector< Double > &  trPos,
const Matrix< Float > &  data,
const Matrix< Bool > &  mask,
const Vector< Float > &  levels,
const Bool  usePixelEdges = False 
)

Draw a contour map at the specified levels, and place the lower left pixel at blPos, and the upper right pixel at trPos.

If usePixelEdges is True, then the given world positions are the position of the blc and trc of the blc and trc pixels, otherwise they are the positions of the centres of the pixels. Note that the contours are not intrinsically drawn in world coordinates. For complex data, the conversion to real values is done according to the last call to setComplexToRealMethod. These functions also have a mask argument, which is a Boolean pixel mask whose shape must match that of data, and only pixels in data where corresponding pixels in mask are True will be contoured. Returns true if OK, false if error...

bool casa::WorldCanvas::drawContourMap ( const Vector< Double > &  blPos,
const Vector< Double > &  trPos,
const Matrix< Complex > &  data,
const Matrix< Bool > &  mask,
const Vector< Float > &  levels,
const Bool  usePixelEdges = False 
)
void casa::WorldCanvas::drawImage ( const Vector< Double > &  blPos,
const Vector< Double > &  trPos,
const Matrix< Float > &  data,
const Bool  usePixelEdges = False,
void *  drawObj = 0 
)

Draw an image, mapping data values to Colormap entries, and place the lower left pixel at blPos, and the upper right pixel at trPos.

If usePixelEdges is True, then the given world positions are the position of the blc and trc of the blc and trc pixels, otherwise they are the positions of the centres of the pixels. See images_, below, for non-default usage of the drawObj parameter.

void casa::WorldCanvas::drawImage ( const Vector< Double > &  blPos,
const Vector< Double > &  trPos,
const Matrix< Complex > &  data,
const Bool  usePixelEdges = False,
void *  drawObj = 0 
)
void casa::WorldCanvas::drawImage ( const Vector< Double > &  blPos,
const Vector< Double > &  trPos,
const Matrix< Float > &  data,
const Matrix< Bool > &  mask,
const Bool  usePixelEdges = False,
void *  drawObj = 0,
Bool  opaqueMask = False 
)

    Draw an image, mapping data values to Colormap entries, and place

the lower left pixel at blPos, and the upper right pixel at trPos.

If usePixelEdges is True, then the given world positions are the position of the blc and trc of the blc and trc pixels, otherwise they are the positions of the centres of the pixels. These functions also have a mask argument, which is a Boolean pixel mask whose shape must match that of data, and only pixels in data where corresponding pixels in mask are True will be drawn. Set opaqueMask to True to draw masked pixels in the background color; otherwise they will be transparent (letting whatever was drawn previously at that point show through). See images_, below, for non-default usage of the drawObj parameter.

void casa::WorldCanvas::drawImage ( const Vector< Double > &  blPos,
const Vector< Double > &  trPos,
const Matrix< Complex > &  data,
const Matrix< Bool > &  mask,
const Bool  usePixelEdges = False,
void *  drawObj = 0,
Bool  opaqueMask = False 
)
void casa::WorldCanvas::drawImage ( const Vector< Double > &  blPos,
const Vector< Double > &  trPos,
const Matrix< Float > &  data,
const Display::ColorComponent colorcomponent,
const Bool  usePixelEdges = False 
)

Draw a component of a multi-channel image, mapping data values to component levels, and place the lower left pixel at blPos, and the upper right pixel at trPos.

If usePixelEdges is True, then the given world positions are the position of the blc and trc of the blc and trc pixels, otherwise they are the positions of the centres of the pixels. The components are not drawn until flushComponentImages() is called.

void casa::WorldCanvas::drawImage ( const Vector< Double > &  blPos,
const Vector< Double > &  trPos,
const Matrix< Complex > &  data,
const Display::ColorComponent colorcomponent,
const Bool  usePixelEdges = False 
)
Bool casa::WorldCanvas::drawLine ( const Vector< Double > &  a,
const Vector< Double > &  b,
const Bool linear = False 
)

Draw a single line using the current color.

If either of the conversions from world to pixel coordinates fail, then the line is not drawn, and False is returned. If linear is True, then the line endpoints are given in world canvas linear coordinates rather than real world coordinates.

Bool casa::WorldCanvas::drawLines ( const Matrix< Double > &  vertices,
const Bool linear = False 
)

Draw pairs of lines using the current color.

If any points fail to convert then the lines are not drawn and False is returned. If linear is True, then the vertices are given as linear world coordinates rather than true world coordinates.

Bool casa::WorldCanvas::drawMappedMarkers ( const Vector< Float > &  px,
const Vector< Float > &  py,
const Vector< Float > &  values,
const Int  sizemin = 1,
const Int  sizemax = 20,
const Display::Marker  = Display::Cross,
const Bool linear = False 
)
bool casa::WorldCanvas::drawMarkerMap ( const Vector< Double > &  blc,
const Vector< Double > &  trc,
const Matrix< Float > &  data,
const Matrix< Bool > &  mask,
Int  xPixelInc,
Int  yPixelInc,
Float  scale,
Double  xWorldInc,
Double  yWorldInc,
const String markeType,
Bool  usePixelEdges 
)

Draw marker maps.

Only makerType "square" available presently. The marker holds its shape in screen pixel coordinates. This means a square is always a square regardless of aspect ratio Returns true if OK, false if error...

bool casa::WorldCanvas::drawMarkerMap ( const Vector< Double > &  blc,
const Vector< Double > &  trc,
const Matrix< Complex > &  data,
const Matrix< Bool > &  mask,
Int  xPixelInc,
Int  yPixelInc,
Float  scale,
Double  xWorldInc,
Double  yWorldInc,
const String markerType,
Bool  usePixelEdges 
)
Bool casa::WorldCanvas::drawMarkers ( const Vector< Float > &  px,
const Vector< Float > &  py,
const Display::Marker  = Display::Cross,
const Int  size = 5,
const Bool linear = False 
)

Draw a set of markers using the current color and a given pixel size.

If any points fail to convert, then those particular points are not marked. markertype is an Display::Marker. If linear is True, then the points are given in linear world canvas coordinates rather than true world coordinates.

Bool casa::WorldCanvas::drawPoint ( const Vector< Double > &  point,
const Bool linear = False 
)

Draw a single point using the current color.

If the conversion from world to pixel coordinates fails, the point is not drawn, and False is the return value. If linear is True, then the point position is given in linear world canvas coordinates, not true world coordinates.

Bool casa::WorldCanvas::drawPoints ( const Matrix< Double > &  points,
const Bool linear = False 
)

Draw a bunch of points using the current color.

If any points fail to convert then none of them are drawn, and False is returned. If linear is True, then the vertices are given in linear world canvas coordinates rather than real world coordinates.

Bool casa::WorldCanvas::drawPoints ( const Vector< Float > &  px,
const Vector< Float > &  py,
Bool  linear = False 
)

Draw a set of points using the current color.

Those points which fail to convert, or lie outside the WorldCanvas drawing area, are not drawn.

Bool casa::WorldCanvas::drawPolygon ( const Matrix< Double > &  vertices,
const Bool linear = False 
)

Draw a polygon (closed line, or line loop using the points) using the current color.

If any coordinates fail to convert then the polygon is not drawn. The end point is implicitly connected to the start point. If linear is True, then the provided vertices are actually linear world coordinates.

Bool casa::WorldCanvas::drawPolyline ( const Matrix< Double > &  vertices,
const Bool linear = False 
)

Draw a polyline (connected line) between the vertices using the current color.

If any coordinates fail to convert from world to pixel, then the entire polyline is not drawn and False is returned. The end point is not implicitly connected to the starting point. If linear is True, then the provided vertices are actually linear world canvas coordinates.

Bool casa::WorldCanvas::drawText ( const Vector< Double > &  point,
const String text,
Display::TextAlign  alignment = Display::AlignCenter,
const Bool linear = False 
)

Draw unrotated text at the given position.

If the conversion from world to pixel coordinates fails, the text is not drawn, and False is returned. If linear is True, then the provided position is actually in linear world canvas coordinates, rather than true world coordinates.

Bool casa::WorldCanvas::drawTextStrings ( const Vector< Float > &  px,
const Vector< Float > &  py,
const Vector< String > &  strings,
const Float  rotation = 0.0,
const Float  xoffset = 0.0,
const Float  yoffset = 0.0,
const Bool  linear = False 
)

Draw a set of text strings using the current color.

If any points fail to convert, then those particular strings are not drawn. rotation gives the rotation of the text in degrees counter-clockwise from horizontal. xoffset and yoffset can be given to globally shift the labels by the specified amounts (in units of the character height). If linear is True, then the vertices are given in linear world canvas coordinates rather than true world coordinates.

bool casa::WorldCanvas::drawVectorMap ( const Vector< Double > &  blc,
const Vector< Double > &  trc,
const Matrix< Complex > &  data,
const Matrix< Bool > &  mask,
Float  angleConversionFactor,
Float  phasePolarity,
Bool  debias,
Float  variance,
Int  xPixelInc,
Int  yPixelInc,
Float  scale,
Bool  arrow,
Float  barb,
Float  rotation,
Double  xWorldInc,
Double  yWorldInc,
const Bool  usePixelEdges 
)

Draw a vector map.

bool casa::WorldCanvas::drawVectorMap ( const Vector< Double > &  blc,
const Vector< Double > &  trc,
const Matrix< Float > &  data,
const Matrix< Bool > &  mask,
Float  angleConversionFactor,
Float  phasePolarity,
Bool  debias,
Float  variance,
Int  xPixelInc,
Int  yPixelInc,
Float  scale,
Bool  arrow,
Float  barb,
Float  rotation,
Double  xWorldInc,
Double  yWorldInc,
const Bool  usePixelEdges 
)
bool casa::WorldCanvas::drawVectorMap ( const Vector< Double > &  blc,
const Vector< Double > &  trc,
const Matrix< Float > &  amp,
const Matrix< Float > &  pa,
const Matrix< Bool > &  mask,
Float  angleConversionFactor,
Float  phasePolarity,
Bool  debias,
Float  variance,
Int  xPixelInc,
Int  yPixelInc,
Float  scale,
Bool  arrow,
Float  barb,
Float  rotation,
Double  xWorldInc,
Double  yWorldInc,
const Bool  usePixelEdges 
) [private]

Actually draw the vector field.

All pa * angleConversionFactor must be radians. rotation must be radians. if amp is of dimension 0, amplitude unity is assumed. if mask if dimension 0 all data are assumed good.

const Bool casa::WorldCanvas::existRestriction ( const String name) const

Check if a named restriction exists.

Referenced by casa::WorldCanvasHolder::existRestriction().

Check if a certain Attribute exists.

Flush the component images, ie.

compose a single image from the buffered channel images and place it on the WorldCanvas. This effectively is passed on to the PixelCanvas where the component images are cached.

Bool casa::WorldCanvas::getAttributeValue ( const String name,
uInt newValue 
) const

User interface to get individual values from the attribute buffer.

Bool casa::WorldCanvas::getAttributeValue ( const String name,
Int newValue 
) const
Bool casa::WorldCanvas::getAttributeValue ( const String name,
Float newValue 
) const
Bool casa::WorldCanvas::getAttributeValue ( const String name,
Double newValue 
) const
Bool casa::WorldCanvas::getAttributeValue ( const String name,
Bool newValue 
) const
Bool casa::WorldCanvas::getAttributeValue ( const String name,
String newValue 
) const
Bool casa::WorldCanvas::getAttributeValue ( const String name,
Vector< uInt > &  newValue 
) const
Bool casa::WorldCanvas::getAttributeValue ( const String name,
Vector< Int > &  newValue 
) const
Bool casa::WorldCanvas::getAttributeValue ( const String name,
Vector< Float > &  newValue 
) const
Bool casa::WorldCanvas::getAttributeValue ( const String name,
Vector< Double > &  newValue 
) const
Bool casa::WorldCanvas::getAttributeValue ( const String name,
Vector< Bool > &  newValue 
) const
Bool casa::WorldCanvas::getAttributeValue ( const String name,
Vector< String > &  newValue 
) const

Retrieve an indexed image to write onto.

Used (exclusively) by WC::drawImage(). If one exists in the cache under this objId key, clear it for reuse; otherwise return a new one. If a (non-zero) objId was provided, it will be cached under that key; removeIndexedImage() can be used to remove such cached images explicitly, but the cache is also frequently cleared automatically. If no caching is requested, however, (objId=0), the caller must delete the image himself when finished -- that type of call is equivalent to 'new ColorIndexedImage_'.

virtual Record casa::WorldCanvas::getOptions ( ) const [virtual]

Retrieve the current and default options and parameter types.

Definition at line 404 of file WorldCanvas.h.

References itsWorldBackgroundColor.

Definition at line 406 of file WorldCanvas.h.

References itsWorldForegroundColor.

virtual void casa::WorldCanvas::handleEvent ( DisplayEvent ev) [virtual]

Handle other, generic types of events.

As with call*Handlers above, WC handles these new events by simply distributing them to event handlers registered on it. However, rather than create any more handler lists in WorldCanvas, generic event handlers (DisplayEHs) piggyback on the RefreshEHList. WorldCanvas is also a DisplayEH, and all DisplayEHs implement handling of these new events by overriding the (null) base class version of this method.

Reimplemented from casa::DisplayEH.

Bool casa::WorldCanvas::hasCS ( ) const [inline]

Definition at line 957 of file WorldCanvas.h.

References itsCoordinateSystem.

Hold and release response to refreshes requested with the refresh() member function.

Multiple calls to hold() can be made, and refreshes will not resume until the same number of calls have been made to release(). Note that these functions do not affect whether internally (implicitly) generated refreshes continue to occur. That is, refresh events due to PixelCanvas resize events, or Colormap changes, for example, will continue to be acted upon.

Bool casa::WorldCanvas::inDrawArea ( Int  x,
Int  y 
) const [inline]

Convenience functions returning whether a pixel coordinate is within bounds of the WC's inner draw area, the WC, or the underlying PC.

Definition at line 964 of file WorldCanvas.h.

References itsCanvasDrawXOffset, itsCanvasDrawXSize, itsCanvasDrawYOffset, itsCanvasDrawYSize, itsCanvasXOffset, and itsCanvasYOffset.

Bool casa::WorldCanvas::inWC ( Int  x,
Int  y 
) const [inline]

Definition at line 971 of file WorldCanvas.h.

References itsCanvasXOffset, itsCanvasXSize, itsCanvasYOffset, and itsCanvasYSize.

Bool casa::WorldCanvas::isCSmaster ( const DisplayData dd) const [inline]

Is the specified DisplayData the one in charge of WC state? (During DD::sizeControl() execution, it means instead that the DD has permission to become CSmaster, if it can).

Definition at line 1020 of file WorldCanvas.h.

References csMaster().

Referenced by casa::MSAsRaster::conformsToCS(), and casa::WorldCanvasHolder::isCSmaster().

Bool casa::WorldCanvas::linToPix ( Vector< Double > &  pix,
const Vector< Double > &  lin 
)
Bool casa::WorldCanvas::linToPix ( Matrix< Double > &  pix,
Vector< Bool > &  failures,
const Matrix< Double > &  lin 
)
Bool casa::WorldCanvas::linToWorld ( Vector< Double > &  world,
const Vector< Double > &  lin 
)
Bool casa::WorldCanvas::linToWorld ( Matrix< Double > &  world,
Vector< Bool > &  failures,
const Matrix< Double > &  lin 
)
Double casa::WorldCanvas::linXMax ( ) const [inline]

Definition at line 861 of file WorldCanvas.h.

References itsLinXMax.

Definition at line 874 of file WorldCanvas.h.

References itsLinXMaxLimit.

Double casa::WorldCanvas::linXMin ( ) const [inline]

Provide information on the extents of the linear coordinate system.

Definition at line 857 of file WorldCanvas.h.

References itsLinXMin.

Provide information on the limits of the linear coordinate system.

Definition at line 870 of file WorldCanvas.h.

References itsLinXMinLimit.

Double casa::WorldCanvas::linYMax ( ) const [inline]

Definition at line 863 of file WorldCanvas.h.

References itsLinYMax.

Definition at line 876 of file WorldCanvas.h.

References itsLinYMaxLimit.

Double casa::WorldCanvas::linYMin ( ) const [inline]

Definition at line 859 of file WorldCanvas.h.

References itsLinYMin.

Definition at line 872 of file WorldCanvas.h.

References itsLinYMinLimit.

Bool casa::WorldCanvas::mapToColorAndDrawEllipses ( const Matrix< Double > &  centres,
const Vector< Float > &  smajor,
const Vector< Float > &  sminor,
const Vector< Float > &  pangle,
const Vector< uInt scaledValues,
const Float scale,
const Bool outline,
const Bool linear 
) [private]

Draw a set of ellipses where scaledValues gives the Colormap index of each point.

Point coordinates ('points') are either linear or world coordinates, as specified by 'linear'.

void casa::WorldCanvas::mapToColorAndDrawImage ( const Vector< Int > &  blc,
const Matrix< uInt > &  scaledImage 
) [private]

Draw an image where scaledImage gives the Colormap index of each screen (PixelCanvas) pixel.

'blc' contains X and Y PixelCanvas coordinates. Masked version as well. For masked version, set opaqueMask to True to draw masked pixels in the background color; otherwise they will be transparent (letting whatever was drawn previously at that point show through).

void casa::WorldCanvas::mapToColorAndDrawImage ( const Vector< Int > &  blc,
const Matrix< uInt > &  scaledImage,
const Matrix< Bool > &  mask,
Bool  opaqueMask = False 
) [private]
Bool casa::WorldCanvas::mapToColorAndDrawPoints ( const Matrix< Double > &  points,
const Vector< uInt > &  scaledValues,
const Bool linear = False 
) [private]

Draw a set of points where scaledValues gives the Colormap index of each point.

Point coordinates ('points') are either linear or world coordinates, as specified by 'linear'.

Bool casa::WorldCanvas::matchesRestriction ( const Attribute restriction) const

Determine whether the restrictions installed on the WorldCanvas match the given restriction or buffer of restrictions.

Referenced by casa::WorldCanvasHolder::matchesRestriction().

void casa::WorldCanvas::moveZoomRectangleLCS ( double  dx,
double  dy 
)

Move the zoom rectangle across the screen, ie.

pan.

Display list support functions.

A display list is started with a call to newList(), finished with a call to endList(), and drawn with a call to drawList(x), with the argument x being the list number returned by the original call to newList(). Lists can be deleted individually with deleteList(x) or in total with deleteLists(). Requests are forwarded to the PixelCanvas.

void casa::WorldCanvas::operator() ( const PCRefreshEvent pev) [virtual]

Handle implicit refresh, motion and position events occuring on the PixelCanvas on which this WorldCanvas is installed.

These functions translate PixelCanvas events into WorldCanvas events.

Reimplemented from casa::PCRefreshEH.

void casa::WorldCanvas::operator() ( const PCMotionEvent eh) [virtual]

Default just prints the event to cout.

Reimplemented from casa::PCMotionEH.

void casa::WorldCanvas::operator() ( const PCPositionEvent eh) [virtual]

Default just prints the event to cout.

Reimplemented from casa::PCPositionEH.

virtual Int casa::WorldCanvas::pgid ( ) const [virtual]

Return the PGPLOT device id for external use.

Return a pointer to the PixelCanvas on which this WorldCanvas is installed.

Definition at line 224 of file WorldCanvas.h.

References itsPixelCanvas.

Bool casa::WorldCanvas::pixToLin ( Vector< Double > &  lin,
const Vector< Double > &  pix 
)

Pixel, linear and world coordinate transformation functions.

For the Vector versions, the coordinate mapping returns False if the transformation failed. For the Matrix versions, failures(i) on input should be set to True if the i'th transformation should not be attempted. On output, failures(i) is True if the transformation was not attempted, or failed. If on input the failures vector has zero length, it will be assumed that no prior failures have occurred.

Bool casa::WorldCanvas::pixToLin ( Matrix< Double > &  lin,
Vector< Bool > &  failures,
const Matrix< Double > &  pix 
)
Bool casa::WorldCanvas::pixToWorld ( Vector< Double > &  world,
const Vector< Double > &  pix 
)
Bool casa::WorldCanvas::pixToWorld ( Matrix< Double > &  world,
Vector< Bool > &  failures,
const Matrix< Double > &  pix 
)
Bool casa::WorldCanvas::redrawIndexedImage ( void *  drawObj,
Display::RefreshReason  reason,
Bool  opaqueMask = False 
)

Optimization to speed up colormap fiddling in 24bit mode (software Colormap); see images_, below for usage.

Set opaqueMask to True to draw masked pixels in the background color; otherwise they will be transparent (letting whatever was drawn previously at that point show through).

void casa::WorldCanvas::refresh ( const Display::RefreshReason reason = Display::UserCommand,
const Bool explicitrequest = True 
)

Refresh the WorldCanvas for the given reason.

The refresh is prevented from occuring if the PixelCanvas is not yet mapped to the screen, or if the refreshes have been held with earlier call/s to hold() which has/have not been matched with the same number of calls to release().

Is a refresh currently allowed?

void casa::WorldCanvas::registerColormap ( Colormap cmap,
Float  weight = 1.0 
)

Register/unregister a Colormap on the PixelCanvas.

Registration counts are remembered, so that a particular Colormap is guaranteed to be available as long as that Colormap has been registered more times than it has been unregistered. Requests are forwarded to the PixelCanvas.

void casa::WorldCanvas::registerColormap ( Colormap cmap,
Colormap cmapToReplace 
)
virtual void casa::WorldCanvas::releasePGPLOTdevice ( ) [virtual]

Remove an Attribute.

Pre-defined Attributes of the WorldCanvas cannot be removed (although nothing serious will happen if you try).

Remove image from the colormap change cache, if any (see images_, below).

Return value indicates whether there was anything to remove.

Remove the given refresh, motion and position event handlers from the WorldCanvas.

void casa::WorldCanvas::removeRestriction ( const String restrictionName)

Remove the named restriction, or all restrictions, from the WorldCanvas.

Referenced by casa::WorldCanvasHolder::removeRestriction().

Reset the zoom to show the entire allowable range of the linear coordinate system.

Return the buffer of restrictions installed on this WorldCanvas.

Referenced by casa::DisplayData::conformsToZIndex(), and casa::WorldCanvasHolder::restrictionBuffer().

Set an Attribute or Attributes on the WorldCanvas.

void casa::WorldCanvas::setClearColor ( const String color)
void casa::WorldCanvas::setColor ( const String color)

Set various graphics attributes.

All of these requests are passed directly to the PixelCanvas, except for setColor, which also installs the requested color for subsequent calls to PgPlot functions.

Set and retrieve the current Colormap on the PixelCanvas.

This function must be called prior to using a WorldCanvas (or PixelCanvas) drawing routines which is expected to use a Colormap. Passing an unregistered Colormap to setColormap will result in an exception being thrown. Requests are forwarded to the PixelCanvas.

Definition at line 943 of file WorldCanvas.h.

References itsComplexToRealMethod.

Set Coordinate, SizeControl, Resample and DataScale handlers for the WorldCanvas.

If the given handler is 0, then resort to using the default handler.

Set and retrieve the CoordinateSystem of this WorldCanvas.

Set with 0 and the WorldCanvas loses its CoordinateSystem!

void casa::WorldCanvas::setDataMax ( Double  max) [inline]

Definition at line 931 of file WorldCanvas.h.

References itsDataMax, and casa::max().

void casa::WorldCanvas::setDataMin ( Double  min) [inline]

Definition at line 927 of file WorldCanvas.h.

References itsDataMin, and casa::min().

void casa::WorldCanvas::setDataMinMax ( Double  min,
Double  max 
) [inline]

Definition at line 933 of file WorldCanvas.h.

References itsDataMax, itsDataMin, casa::max(), and casa::min().

virtual void casa::WorldCanvas::setDefaultOptions ( ) [virtual]

Install the default options for this DisplayData.

virtual void casa::WorldCanvas::setDrawBuffer ( Display::DrawBuffer  buf) [virtual]

Set/retrieve the drawing buffer, the target destination for graphics.

Requests are passed directly to the PixelCanvas.

Bool casa::WorldCanvas::setFont ( const String fontName)

Set/retrieve the caching strategy on the PixelCanvas.

Appropriate values are Display::ClientAlways (use client memory to cache images [safer]), Display::ServerAlways (use server memory to cache images [faster]), and Display::ServerMemoryThreshold (use server memory until a threshold is reached [not yet implemented]). Requests are passed to the PixelCanvas.

void casa::WorldCanvas::setLinearCoordinateSystem ( const Vector< Double > &  blc,
const Vector< Double > &  trc,
Bool  resetZoom = True 
)

Set the allowable range of the linear coordinate system.

virtual Bool casa::WorldCanvas::setOptions ( const Record rec,
Record updatedOptions 
) [virtual]

Apply options stored in rec to the DisplayData; return value True means a refresh is needed.

Any fields added to the updatedOptions argument are options which have changed in some way due to the setting of other options - ie. they are context sensitive.

void casa::WorldCanvas::setRestriction ( const Attribute restriction)

Install a single restriction, or a buffer of restrictions, on the WorldCanvas which DisplayData must match in order that they be allowed to draw themselves.

Referenced by casa::WorldCanvasHolder::setRestriction().

Set/retrieve the background and foreground colors of the WorldCanvas.

These can be different to those for the PixelCanvas. Indeed, they will be used as default colors on the WorldCanvas when necessary.

void casa::WorldCanvas::setWorldCanvasPosition ( Double  fracXOffset,
Double  fracYOffset,
Double  fracXSize,
Double  fracYSize 
)

Set the location of the WorldCanvas on its PixelCanvas.

void casa::WorldCanvas::setZoomRectangleLCS ( const Vector< Double > &  min,
const Vector< Double > &  max 
)

Set the zoom rectangle to the specfied linear coordinate range.

void casa::WorldCanvas::trimAndResampleImage ( Vector< Double > &  drawBlc,
Vector< Double > &  drawTrc,
Matrix< Float > &  sampledImage,
const Vector< Double > &  blc,
const Vector< Double > &  trc,
const Matrix< Float > &  data,
const Bool usePixelEdges = False 
) [private]

Trim and resample an image, returning the actual world BLC and TRC for drawing, and the resampled image.

void casa::WorldCanvas::trimAndResampleImage ( Vector< Double > &  drawBlc,
Vector< Double > &  drawTrc,
Matrix< Float > &  sampledImage,
Matrix< Bool > &  resampledMask,
const Vector< Double > &  blc,
const Vector< Double > &  trc,
const Matrix< Float > &  data,
const Matrix< Bool > &  mask,
const Bool usePixelEdges = False 
) [private]

Trim and resample an image, returning the actual world BLC and TRC for drawing, and the resampled image.

This function takes a mask indicating which pixels should be drawn. This function therefore also trims and resamples the mask.

Update canvas sizes/offsets from the fracOffsets, and vice versa.

virtual Vector<String> casa::WorldCanvas::worldAxisNames ( ) const [virtual]

Return the names and units of the world coordinate axes.

virtual Vector<String> casa::WorldCanvas::worldAxisUnits ( ) const [virtual]
Bool casa::WorldCanvas::worldToLin ( Vector< Double > &  lin,
const Vector< Double > &  world 
)
Bool casa::WorldCanvas::worldToLin ( Matrix< Double > &  lin,
Vector< Bool > &  failures,
const Matrix< Double > &  world 
)
Bool casa::WorldCanvas::worldToPix ( Vector< Double > &  pix,
const Vector< Double > &  world 
)
Bool casa::WorldCanvas::worldToPix ( Matrix< Double > &  pix,
Vector< Bool > &  failures,
const Matrix< Double > &  world 
)

convienience function based on "restriction buffer"...


Member Data Documentation

Buffer for Attributes.

Definition at line 1243 of file WorldCanvas.h.

Definition at line 1033 of file WorldCanvas.h.

Cache of pre-drawn ColorIndexedImage_'s.

When a caller of drawImage() wants to save one, it passes a drawing-object pointer in the 'drawObj' parameter for use as a retrieval key. It should provide the same key to redrawIndexedImage() in order to reuse the image.

Definition at line 1310 of file WorldCanvas.h.

***Cached*** blc pixel where the world canvas 'draw area' (inside margins, labels) begins, relative to WC blc.

Definition at line 1183 of file WorldCanvas.h.

Referenced by canvasDrawXOffset(), and inDrawArea().

***Cached*** number of pixels in each dimension given to the drawable part of the world canvas

Definition at line 1190 of file WorldCanvas.h.

Referenced by canvasDrawXSize(), and inDrawArea().

Definition at line 1184 of file WorldCanvas.h.

Referenced by canvasDrawYOffset(), and inDrawArea().

Definition at line 1191 of file WorldCanvas.h.

Referenced by canvasDrawYSize(), and inDrawArea().

***Cached*** blc pixel where this world canvas begins = itsPixelCanvas->width()*frac(X|Y)Offset_.

Definition at line 1159 of file WorldCanvas.h.

Referenced by canvasXOffset(), inDrawArea(), and inWC().

***Cached*** number of pixels in each dimension given to the world canvas = itsPixelCanvas->width()*(frac(X|Y)Size_.

Definition at line 1166 of file WorldCanvas.h.

Referenced by canvasXSize(), and inWC().

Definition at line 1160 of file WorldCanvas.h.

Referenced by canvasYOffset(), inDrawArea(), and inWC().

Definition at line 1167 of file WorldCanvas.h.

Referenced by canvasYSize(), and inWC().

Method to use to convert complex data into real values.

Definition at line 1214 of file WorldCanvas.h.

Referenced by complexToRealMethod(), and setComplexToRealMethod().

Definition at line 1229 of file WorldCanvas.h.

The CoordinateSystem for this WorldCanvas.

New addition, only supported and used by "new" classes.

Definition at line 1262 of file WorldCanvas.h.

Referenced by hasCS().

[First] responder to 'sizeControl', responsible for setting WC CS, zoom window and draw area.

It will be 0 initially, and whenever the old master is unregistered (until a new master responds). This is a further attempt toward a coherent sense of 'who's in charge' of WC[H] state (there is more to do).

Some day, the WC CS should be directly responsible for all the Canvas's coordinate conversions. For now at least we'll know that they're done by the DD below (which should be equivalent).

Definition at line 1336 of file WorldCanvas.h.

Referenced by csMaster().

Definition at line 1211 of file WorldCanvas.h.

Referenced by dataMax(), setDataMax(), and setDataMinMax().

Dynamic data minimum and maximum for this WorldCanvas.

Definition at line 1211 of file WorldCanvas.h.

Referenced by dataMin(), setDataMin(), and setDataMinMax().

Definition at line 1231 of file WorldCanvas.h.

Fractional position of world canvas on pixel canvas.

The offset values are always in the range of [0.0,1.0], and sizes must be smaller or equal to (1.0 - offset) for each dimension.

Definition at line 1174 of file WorldCanvas.h.

Definition at line 1176 of file WorldCanvas.h.

Definition at line 1175 of file WorldCanvas.h.

Definition at line 1177 of file WorldCanvas.h.

This state is set True when the pointer is in this WC and a pointer button is pressed (with no buttons pressed previously).

When True, all PC motion and pointer button events are propagated to this WC's handlers (only), regardless of whether the pointer has moved off the WC. It is reset to False when all buttons are released. This simulates the 'automatic grab' (implemented in X for whole windows), on the WC level.

Definition at line 1271 of file WorldCanvas.h.

Definition at line 1258 of file WorldCanvas.h.

Status of hold/release.

Definition at line 1256 of file WorldCanvas.h.

itsId & itsRef used to ensure thread-safe execution of pgplot

Definition at line 1340 of file WorldCanvas.h.

Definition at line 1198 of file WorldCanvas.h.

Referenced by linXMax().

Definition at line 1206 of file WorldCanvas.h.

Referenced by linXMaxLimit().

Linear Coordinate System ranges.

Definition at line 1196 of file WorldCanvas.h.

Referenced by linXMin().

Linear Coordinate System Limits.

Definition at line 1204 of file WorldCanvas.h.

Referenced by linXMinLimit().

Definition at line 1199 of file WorldCanvas.h.

Referenced by linYMax().

Definition at line 1207 of file WorldCanvas.h.

Referenced by linYMaxLimit().

Definition at line 1197 of file WorldCanvas.h.

Referenced by linYMin().

Definition at line 1205 of file WorldCanvas.h.

Referenced by linYMinLimit().

Definition at line 1223 of file WorldCanvas.h.

Definition at line 1220 of file WorldCanvas.h.

Definition at line 1237 of file WorldCanvas.h.

Definition at line 1239 of file WorldCanvas.h.

Definition at line 1238 of file WorldCanvas.h.

Store whether we "own" the various handlers.

Definition at line 1236 of file WorldCanvas.h.

Definition at line 1222 of file WorldCanvas.h.

PGPLOT filter.

Definition at line 1253 of file WorldCanvas.h.

PixelCanvas pointer.

Definition at line 1250 of file WorldCanvas.h.

Referenced by pixelCanvas().

Definition at line 1219 of file WorldCanvas.h.

WorldCanvas::refresh is a recursive function.

itsRef is used to determine when the recursion is over. i.e, when the initial refresh call is exiting

Definition at line 1346 of file WorldCanvas.h.

Event handler lists and convenient iterators.

Definition at line 1218 of file WorldCanvas.h.

Definition at line 1257 of file WorldCanvas.h.

Definition at line 1221 of file WorldCanvas.h.

Definition at line 1230 of file WorldCanvas.h.

A buffer to contain the restrictions that DisplayDatas must match if they are to be allowed to draw themselves.

Definition at line 1324 of file WorldCanvas.h.

Other handler lists.

Definition at line 1228 of file WorldCanvas.h.

Background/foreground colors.

Definition at line 1246 of file WorldCanvas.h.

Referenced by getWorldBackgroundColor().

Definition at line 1247 of file WorldCanvas.h.

Referenced by getWorldForegroundColor().

Definition at line 1031 of file WorldCanvas.h.

Definition at line 1032 of file WorldCanvas.h.

Definition at line 1034 of file WorldCanvas.h.


The documentation for this class was generated from the following file: