ilDisplay - displays multiple images in an X window
This is a base class with no inheritance.
#include <il/ilDisplay.h>
ilDisplay manages the display of multiple ilImages in an X window. An
ilImage of any size, color model, or orientation can be displayed. In
addition, any combination of ilImage can be displayed. OpenGL is used to
render the images if supported by the visual associated with the X
window, otherwise X is used. Multiple images are managed as a stack and
only the exposed area of each image is painted for optimal performance.
Adding Images
Any ilImage can be added to the display by using the addView() member
function. ilDisplay creates an ilView for the image and puts it into a
view stack. By default, views are put on top of the stack. However, an
index can be specified or the mode can be used to control where the view
is inserted in the stack. Views are displayed based on their stacking
order. Therefore the view on top of the stack is unobscured and other
views in the stack may be obscured. Member functions are provided for
manipulating the view stack such as push, pop, swap and delete.
An ilView pointer is returned by addView() and can be used to manipulate
the view. For example the view can be repositioned and resized. See
ilView for more information. The pointer to an ilView can be found in
several ways using the image or index of the view or by specifying an xy
location. When finding a view by xy location, a pointer to the topmost
view at that location is returned. Note that all views in the view stack
are deleted when ilDisplay is deleted.
Display Operators
ilDisplay provides several functions or display operators to manipulate
views within the display window. Display operators are used to do such
things as move the view within the display, change the size of the view
or moved the image within the view. These display operators can be
applied to one or more views in the view stack. Typical arguments passed
to a display operator include an xy coordinate pair, a pointer to a view,
and a mode.
An ilView* is passed to a display operator to specify which view to
operate on. If NULL is specified, all views in the stack are operated on.
However, a view is unaffected if its nop (no-operation) flag is set. The
function setNop() can be used to set the nop flag on a single view or all
views in the stack.
The mode parameter passed to display operators is comprised of one or
more bit fields. It is passed as an int value to allow the bit fields to
be combined using a bitwise OR. These bit fields are defined as
enumerated values in il/ilDisplayDefs.h. There are several types of modes
defined, including: ilDefer to defer painting, ilClip to prevent moving
beyond the edge of the image, ilNoSwap to prevent swapping back/front
buffers, and operator-specific flags such as ilRightEdge for the wipe
operator and coordinate interpretation.
The x, y coordinates passed to a display operator can be interpreted as
absolute values, change from current view configuration, or as relative
to the values initialized by setMouse(). Coordinate interpretation is
specified by the following flags in mode:
ilRelVal Interpreted relative to the starting xy position
established with setMouse(). The difference between the
specified xy parameters and the starting xy location is
used. The starting xy location is then updated. Useful
for interactive manipulation.
ilOldRel Same as ilRelVal except that the starting x,y location
is not updated. This is useful when doing several
operations based on the same x,y coordinates.
ilDelVal Interpreted as changes (delta) to the current view
configuration.
ilAbsVal Interpreted as absolute values relative to the ilDisplay
origin (upper-left).
Constructor
ilDisplay(Display* display, Window parentWin, int mode = ilDefault)
ilDisplay(Display* display, int width, int height,
int attr=ilVisDoubleBuffer,
int minComponentSize=8, int maxComponentSize=0,
int mode = ilDefault,
long eventMask = ExposureMask|KeyPressMask|
PointerMotionMask|PointerMotionHintMask|
ButtonPressMask|ButtonReleaseMask|
StructureNotifyMask)
Synchronization and aborting
void syncPaint()
void flush()
void abort()
int isAutoAbortEnabled()
void enableQueueing(int enable=TRUE)
int isQueueingEnabled()
X Window access and control
void updateWindow()
void setWindow(Window win, int mode = ilDefault)
ilXWindowImg* getXWindowImg()
GLXContext getGLXContext()
Window getWindow()
Display* getDisplay()
Display* getILDisplay()
void calcWindowSize(int& width, int& height)
void destroyNotify()
Controlling display modes
void setMode(int mode = 0)
void enableFrontRedraw(int enable)
int isFrontRedrawEnabled()
Rendering callbacks
void setCallback(ilCallback* prepare, ilCallback* render,
ilCallback* finish = NULL)
void getCallback(ilCallback*& prepare, ilCallback*& render,
ilCallback*& finish)
void enableCallback(int enable = TRUE)
int isCallbackEnabled()
Tile mapping
void mapTile(iflOrientation fromOrientation, iflTile2Dint& tile,
iflOrientation toOrientation=iflOrientation(0))
void mapTile(iflOrientation fromOrientation, iflTile2Dfloat& tile,
iflOrientation toOrientation=iflOrientation(0))
void mapXY(iflOrientation fromOrientation, int& x, int& y,
iflOrientation toOrientation=iflOrientation(0))
void mapXY(iflOrientation fromOrientation, float& x, float& y,
iflOrientation toOrientation=iflOrientation(0))
Visible area control
void setVisibleArea(int x = 0, int y = 0, int nx = 0,
int ny = 0)
void getVisibleArea(int& x, int& y, int& nx, int& ny)
Attribute get and set
void getPos(int& x, int& y)
void getSize(int& x, int& y)
int isRgb()
int isDoubleBuffer()
int isDefer(ilView* view = NULL)
void setDefer(int def, ilView* view = NULL)
int isStereo()
int getMargin()
void setMargin(int margin)
float getRoamLimit()
void setRoamLimit(float maxRoamDel = 0.0)
void getRoamRate(float& x, float& y)
void getBackground(float& red, float& green, float& blue)
void setBackground(float red, float green, float blue)
iflColorModel getColorModel()
void setColormap(iflColormap& cmap)
ilStatus getColormap(iflColormap& cmap)
ilStatus getStatus()
void setStatus(ilStatus stat)
void setBackgroundDirty()
View manipulation
ilView* addView(ilImage* img, int index, int mode)
ilView* addView(ilImage* img, int mode = ilCenter)
ilStereoView* addStereoView(ilImage* imgL, ilImage* imgR,
int index, int mode)
ilStereoView* addStereoView(ilImage* imgL, ilImage* imgR,
int mode = ilCenter)
ilStereoView* addStereoView(ilImage* zImg, int zLeft,
int zRight, int index, int mode)
ilStereoView* addStereoView(ilImage* zImg, int zLeft = 0,
int zRight = 1, int mode = ilCenter)
ilView* addView(ilView* view, int index = 0, int mode = ilCenter)
void deleteView(ilView* view)
void deleteView(int index = 0)
void addViewChangeCallback(ilCallback* cb, int autoDelete=FALSE)
ilStatus removeViewChangeCallback(ilCallback* cb)
void push(ilView* view = NULL, int count = 0)
void pop(ilView* view = NULL, int count = 0)
void swap(ilView* view1, ilView* view2)
ilView* findView(int x, int y, int mode = ilDspCoord)
ilView* getView(int index = 0)
ilView* getView(ilImage* img)
int getViewIndex(ilView* view)
int getViewIndex(ilImage* img)
int getNumViews()
ilView* getLoc(float x, float y, float& ix, float& iy,
int mode = ilLocIn)
ilView* setLoc(float ix, float iy, float x, float y,
int mode = ilLocIn)
ilView* getPixel(int x, int y, iflPixel& pix)
ilView* setPixel(int x, int y, iflPixel& pix)
int isNop(ilView* view = NULL)
void setNop(int noOp, ilView* view = NULL)
void select(ilView* view = NULL)
void unselect(ilView* view = NULL)
int isSelected(ilView* view)
void setBorders(int enable, int mode = ilDefault)
void setBorderStyle(int style = ilViewBdrSolidLines)
void setBorderColor(float red, float green, float blue)
void setBorderWidth(int width)
Display operator support
void setMouse(int x, int y, int mode = 0)
void getMouse(int& x, int& y)
void getMouse(int& x, int& y, iflOrientation orientation)
int findEdge(int x, int y, int margin = -1, int mode = ilDspCoord)
Display operators
void display(ilView* view = NULL, int vMode = ilCenter,
int iMode = ilCenter)
void redraw(int x, int y, int nx, int ny,
iflOrientation orientation = iflUpperLeftOrigin,
int mode = ilDefault)
void redraw(int mode = ilDefault)
void paint(int x, int y, int nx, int ny,
iflOrientation orientation = iflUpperLeftOrigin,
ilView* view = NULL, int mode = 0)
void paint(ilView* view = NULL, int mode = 0)
void qPaint(ilMpNode* parent, int x, int y, int nx, int ny,
iflOrientation orientation = iflUpperLeftOrigin,
ilView* view = NULL, int mode = 0,
ilMpManager** pMgr = NULL)
void qPaint(ilMpNode* parent, ilView* view = NULL, int mode = 0,
ilMpManager** pMgr = NULL)
void moveView(int x, int y, ilView* view = NULL, int mode = ilRelVal)
void moveImg(float x, float y, ilView* view = NULL,
int mode = ilRelVal)
void moveImgIdx(float x, float y, ilView* view,
int idx, int mode)
void wipe(int x, int y, ilView* view = NULL, int mode = ilRelVal)
void wipeSplit(int x, int y, int mode = ilRelVal)
void wipeSize(int x, int y, ilView* view = NULL,
int mode = ilDelVal|ilTopRight)
void split(int mode = ilAbsSplit|ilRowSplit|ilColSplit)
void alignImg(ilView* view = NULL, int mode = ilCenter)
void alignView(ilView* view = NULL, int mode = ilCenter,
ilView* rView = NULL)
void update(int x = 0, int y = 0, int nx = 0, int ny = 0,
float imgX = 0, float imgY = 0, ilView* view = NULL,
int mode = ilDelVal)
ilStatus save(ilImage* img, int x = 0, int y = 0, int mode = 0)
ilDisplay()
ilDisplay(Display* display, Window parentWin, int mode = ilDefault)
ilDisplay(Display* display, int width, int height,
int attr=ilVisDoubleBuffer,
int minComponentSize=8, int maxComponentSize=0,
int mode = ilDefault,
long eventMask = ExposureMask|KeyPressMask|
PointerMotionMask|PointerMotionHintMask|
ButtonPressMask|ButtonReleaseMask|
StructureNotifyMask)
Both versions of the constructor create an ilDisplay object to
manage views of images within an X window. The mode parameter is
used to specify the view mode when adding ilViews objects with
addView(). For example, ilDefer could be used to add views without
painting each one as it is added to the display.
Since OpenGL and X rendering can be mixed, the render mode is
determined automatically. If the X visual associated with the window
supports OpenGL rendering then OpenGL rendering will be used.
Otherwise X rendering will be used. Note that hardware acceleration
only occurs during OpenGL rendering.
The second version of the constructor creates an X window as
specified by the various parameters. The created window will be
width wide, height high with the attributes specified by attr,
minComponentSize and maxComponentSize for the visual class. See
ilXWindowImg for more information. In addition, it will select the X
events passed in eventMask.
A background view is created and is painted by default. However, if
ilDefer is passed in mode, painting will be deferred. Also, an RGB
colormap will be loaded if needed. However, an application can load
a colormap or use the default colormap by passing ilDefaultCmap in
mode. This will cause ilDisplay to not load a colormap.
abort()
void abort()
This method aborts any queued paint requests. It works in
conjunction with the enableQueueing() method.
addStereoView()
ilStereoView* addStereoView(ilImage* imgL, ilImage* imgR,
int index, int mode)
ilStereoView* addStereoView(ilImage* imgL, ilImage* imgR,
int mode = ilCenter)
ilStereoView* addStereoView(ilImage* zImg, int zLeft = 0,
int zRight = 1, int mode = ilCenter)
ilStereoView* addStereoView(ilImage* zImg, int zLeft,
int zRight, int index, int mode)
These methods allow a pair of ilImages to be specified as the left
image and the right image of a stereo pair. In addition, a stereo
pair may be stored in a single image using the Z dimension. In this
case, the image is specified as zImg. The Z index to the left image
is specified as zLeft and the Z index to the right image is
specified as zRight. By default, zLeft is 0 and zRight is 1. The
advantage of this approach, is that a single IL chain can be used to
process the stereo pair, rather than having a chain to process each
image.
addView()
ilView* addView(ilImage* img, int index, int mode)
ilView* addView(ilImage* img, int mode = ilCenter)
ilView* addView(ilView* view, int index = 0, int mode = ilCenter)
Creates an ilView for the image specified by, img, and adds it to
the view stack at the index specified by, idx. By default, the view
is added to the top of the stack. If idx equals ilLast, the view is
added to the bottom of the stack. The mode parameter controls the
creation and position of the ilView. By default, the ilView is the
size of the image. However, if ilClip is passed in mode, then the
ilView will be clipped to the size of the display window. By
default, the view is painted after it is added to the stack.
However, if ilDefer is passed, then painting is deferred. Also, an
alignment mode such as ilCenter may be passed to control how the
image is aligned within the view and how the view is aligned within
the display window. Center alignment is used by default.
Several versions of addView() are provided for convenience. The
version that takes an index, allows the position in the view stack
to be specified. Often however, putting the image on top of the
stack is acceptable and only the image and mode need to be
specified. Therefore, a second version is provided that only
requires an image and a mode to be specified.
addViewChangeCallback()
void addViewChangeCallback(ilCallback* cb, int autoDelete=FALSE)
This method adds a callback that will be triggered whenever a view
is added to or deleted from this object. Either
ilViewChangeMethodCB or ilViewChangeFunctionCB can used with this
method. The callback method or function will have the prototype:
func(UserArgType userArg, ilViewChangeArg* callerArg)
To define and use a view change callback to a member function you
might do something like:
...
ilStatus Bar::change(Foo*, ilViewChangeArg*) { ... }
...
typedef ilViewChangeMethodCB<Bar,Foo*> ViewChangeCallback;
Bar bar;
Foo foo;
ViewChangeCallback changeCb(&bar, Bar::change, &foo);
disp->addViewChangeCallback(&changeCb);
The passed ilViewChangeArg contains two members:
reason The reason for this callback: either ilViewAdded or
ilViewDeleted.
view The view being added or the view about to be deleted.
alignImg()
void alignImg(ilView* view = NULL, int mode = ilCenter)
Aligns the image in the specified view based on mode. If NULL is
passed, then the image in all views in the view stack are aligned
(expect those with nop flag set). For example, if ilCenter is
specified, the images are centered within the view. Similarly, if
ilBottomLeft is specified, the lower left corner of the image is
aligned to the lower left corner of the view. See il/ilDisplayDef.h
for a complete list of modes.
alignView()
void alignView(ilView* view = NULL, int mode = ilCenter,
ilView* rView = NULL)
Aligns the specified view to the reference view specified in rView.
If NULL is passed then all views are aligned (except those with nop
flag set). The two views are aligned based on bit flags passed in
mode. For example, it ilCenter is specified, the center of the view
is aligned to the center of the reference view. Similarly, if
ilTopRight is specified, the upper right corner of the view is
aligned to the upper right corner of the reference view. If NULL is
passed in rView, the background view in ilDisplay is used. See
il/ilDisplayDef.h for a complete list of modes.
calcWindowSize()
void calcWindowSize(int& width, int& height)
This method computes a window size that won't clip any of the images
in the current set of views, this size is clipped to the size of the
screen.
deleteView()
void deleteView(ilView* view)
void deleteView(int index = 0)
Removes the specified view from the view stack and deletes the
ilView. The display is then repainted.
destroyNotify()
void destroyNotify()
This method is intended to be called when the X window used by this
object has been destroyed, typically when a DestroyNotify X event is
handled.
display()
void display(ilView* view = NULL, int vMode =ilCenter,
int iMode =ilCenter)
This function resizes, aligns, and paints the specified view. If
NULL is passed, then all views are operated on (except those with
nop flag set). If ilDefer is specified, then painting is deferred.
The view is resized to the size of the image. However, if ilClip is
specified, the view is clipped to the size of the display. The view
is aligned as specified in vMode, and the image mapped to the view
is aligned as specified in iMode.
enableAutoAbort()
void enableAutoAbort(int enable=TRUE)
This method enables automatic aborting of queued requests; when this
mode is turned on any new painting operations will automatically
cancel paint operations in progress. This mode only makes sense if
queueing is enabled (see enableQueueing()).
enableCallback()
void enableCallback(int enable = TRUE)
This member function enables (True) or disables (False) the post-
render callback setup with setCallback(). Note that the callback
must be set and enabled to be operable.
enableFrontRedraw()
void enableFrontRedraw(int enable)
This member function enables or disables drawing to the front buffer
when redraw() is called. This allows better visual feedback when in
double buffer mode. If True is passed then front redraw is enabled.
Otherwise, it is disabled.
enableQueueing()
void enableQueueing(int enable=TRUE)
This method controls whether queued painting is actually allowed,
the default mode is that queued painting will not be done. When the
mode is enabled, call to various display operation (like moveImg())
will return before the rendering is completed. When another
operations is requested it will be started before waiting for the
last operation to complete to allow overlapped prefetching of data.
This mode is currently only supported on MP machines.
Completion of the queued operation can be ensured by calling the
syncPaint() method. Queued operations can be aborted with the
abort() method.
findEdge()
int findEdge(int x, int y, int margin = -1, int mode = ilDspCoord)
Returns the edge or edges within margin pixels of x and y. The view
stack is searched from top to bottom so that edges of the top view
are returned. However, ilNoEdge is returned if no edge is found and
ilNoView is returned if there is no view at the location specified
by x and y.
findView()
ilView* findView(int x, int y, int mode = ilDspCoord)
Returns a pointer to the top-most ilView found at location (x,y)
within the display. If there is no view at (x,y), NULL is returned.
If ilDspCoord is passed in mode (default), then the (x,y)
coordinates are interpreted relative to the display window. If
ilScrCoord is passed in mode, then the (x,y) coordinates are
interpreted relative to the screen.
flush()
void flush()
Flushes graphics commands that may be buffered. Usually, it is not
necessary to call flush in interactive applications.
getBackground()
void getBackground(float& red, float& green, float& blue)
Returns the current background color in red, green and blue. See
setBackground()
getCallback()
void getCallback(ilCallback*& prepare, ilCallback*& render,
ilCallback*& finish)
Returns pointers to the prepare callback, render callback and finish
callback in the repective parameters. These callbacks were
previousely set with setCallback(). See ilView and ilViewCallback
for more information.
getColorModel()
iflColorModel getColorModel()
Returns the color model of the display image.
getColormap()
ilStatus getColormap(iflColormap& cmap)
Returns the current colormap in lut. The colormap is used by
ilXDisplayImg or ilGLDisplayImg, depending on the render mode.
getDisplay()
Display* getDisplay()
Returns the X Display currently being used.
getGLXContext()
GLXContext getGLXContext()
This method returns the OpenGL rendering context used by IL. This
can be used to create display lists in a user context that can be
shared with the IL context, and thus used in the rendering
callbacks. To do this the user context must be created specifying
the IL context as the shareList parameter of glXCreateContext().
getILDisplay()
Display* getILDisplay()
This method returns the internal Display* that IL uses. This is not
intended for use outside of IL.
getLoc()
ilView* getLoc(float x, float y, float& ix, float& iy,
int mode = ilLocIn)
This function finds the view at (x, y) and returns the corresponding
location in the image in ix and iy. If ilLocIn is passed in mode,
the location is returned in the input space of the image. If
ilLocOut is passed in mode, the location is returned in the output
space of the image. For example, if an ilRotZoomIng is mapped to the
view and ilLocIn is specified, ix and iy will correspond to the
location in the unzoomed image. However, if ilLocOut is specified,
ix and iy correspond to the location in the zoomed image.
getMargin()
int getMargin()
Returns the current margin in pixels that is used for findEdge().
getMouse()
void getMouse(int& x, int& y)
void getMouse(int& x, int& y, iflOrientation orientation)
Returns the current XY location of the mouse. The mouse position is
set with setMouse() and is updated by display operators that are
passed ilRelVal parameter mode. The values x and y, are returned for
the specified orientation. The first version, uses the current event
orientation. This method is useful for some interactive
applications.
getNumViews()
int getNumViews()
Returns the number of ilViews in the view stack. The background view
can not be accessed and is not included in the count.
getPixel()
ilView* getPixel(int x, int y, iflPixel& pix)
Copies into pix the pixel value at coordinates (x, y), in ilDisplay
coordinates. The pixel value is obtained from view. If view is
NULL, then the view at x,y is found first.
getPos()
void getPos(int& x, int& y)
Returns the current position of the ilDisplayImg within the display
window. ilDisplay creates a ilDisplayImg (X or GL) to perform the
actual rendering to the frame buffer. It is maintained at position
0, 0 within the display window.
getRoamLimit()
float getRoamLimit()
Returns the roam limit previously set with setRoamLimit(). The roam
limit causes image movement to be limited in order to facilitate
smooth roaming with moveImg() or moveImgIdx(). The roam limit is
used to calculate the maximum roam rate in x and y for a given
direction.
getRoamRate()
void getRoamRate(float& x, float& y)
Returns the horizontal and vertical roam rate in x and y. If a roam
limit has been set with setRoamLimit(), then image movement may be
clipped when using moveImg() or moveImgIdx(). The returned values
give the number of pixels the image was moved in the x and y
directions. The roam rate is updated each time moveImg() or
moveImgIdx() is called.
getSize()
void getSize(int& x, int& y)
Returns the size of the ilDisplayImg into x and y.
getStatus()
ilStatus getStatus()
Returns the current status. See /usr/include/il/ilError.h for a list
of error codes.
getView()
ilView* getView(ilImage* img)
ilView* getView(int index = 0)
Returns a pointer to the ilView that corresponds to idx in the view
stack, or the bottom-most ilView containing img. If no ilView is
found, NULL is returned. Note that the back view can not be
accessed.
getViewIndex()
int getViewIndex(ilImage* img)
int getViewIndex(ilView* view)
Returns the index into the display's ilView corresponding to view
or, the index of the bottom-most ilView containing img. If view or
img is not in the list, ilNoListIndex is returned.
getVisibleArea()
void getVisibleArea(int& x, int& y, int& nx, int& ny)
Returns the current visible area. If the area is valid, then
painting is limited to this area. This feature is useful for
scrolled windows. See setVisibleArea() for more information.
getWindow()
Window getWindow()
Returns the X Window currently being used.
getXWindowImg()
ilXWindowImg* getXWindowImg()
This method returns the ilXWindowImg created by this object. It is
used for all rendering operations.
isAutoAbortEnabled()
int isAutoAbortEnabled()
Returns TRUE if auto-abort is enabled, FALSE otherwise. See
enableAutoAbort().
isCallbackEnabled()
int isCallbackEnabled()
Returns TRUE if the post-render callback is enabled. Otherwise it
rerutns FALSE. See setCallback() and enableCallback().
isDefer()
int isDefer(ilView* view = NULL)
Returns the state of the defer flag for the specified view. If view
is NULL, the state of the defer flag on ilDisplay is returned.
Returns TRUE if painting is deferred, FALSE otherwise.
isDoubleBuffer()
int isDoubleBuffer()
Returns TRUE if double buffer mode is set, FALSE otherwise.
isFrontRedrawEnabled()
int isFrontRedrawEnabled()
This member function returns TRUE if front redraw is enabled,
otherwise it returns FALSE. See also enableFrontRedraw().
isNop()
int isNop(ilView* view = NULL)
Returns TRUE if the nop flag is set on the specified view, FALSE
otherwise. If view is NULL, then the view on the top of the stack
is tested.
isQueueingEnabled()
int isQueueingEnabled()
Returns TRUE if queued rendering is enabled, FALSE otherwise. See
enableQueueing().
isRgb()
int isRgb()
Returns the GL color mode: TRUE for RGBmode, FALSE for colormap.
isSelected()
int isSelected(ilView* view)
Returns TRUE if the specified view is selected, FALSE otherwise.
When an ilView is selected, its nop flag is FALSE and its borders
are enabled.
isStereo()
int isStereo()
Returns TRUE if stereo viewing mode is available, FALSE otherwise.
ilDisplay supports both monoscopic and stereoscopic views
simultaneously within the same GL window. Stereo is only supported
on InfiniteReality, RealityEngine and Impact graphics systems.
mapTile()
void mapTile(iflOrientation fromOrientation, iflTile2Dfloat& tile,
iflOrientation toOrientation=iflOrientation(0))
void mapTile(iflOrientation fromOrientation, iflTile2Dint& tile,
iflOrientation toOrientation=iflOrientation(0))
Maps the specified tile from the fromOrientation to the
toOrientation relative to the ilXWindowImg used by ilDisplay. By
default, the orientation of ilDisplay (upper-left) is used for
toOrientation.
mapXY()
void mapXY(iflOrientation fromOrientation, float& x, float& y,
iflOrientation toOrientation=iflOrientation(0))
void mapXY(iflOrientation fromOrientation, int& x, int& y,
iflOrientation toOrientation=iflOrientation(0))
Maps ix and iy from fromOrientation to toOrientation and returns the
result in ox and oy. By default, the orientation of ilDisplay
(upper-left) is used for toOrientation.
moveImg()
void moveImg(float x, float y, ilView* view = NULL,
int mode = ilRelVal)
void moveImgIdx(float x, float y, ilView* view,
int idx, int mode)
These functions move the image within the specified view. If NULL is
passed as view, then the images are moved in all views in the stack
(except those with nop flag set). The image is moved as specified by
x and y. The mode controls how the function operates. If ilClip is
passed in mode, the image position is clipped to prevent moving
beyond the edge of the image. However, by default, the image can be
moved beyond its edge, exposing the image's fill value. The view is
painted after the image has been moved, unless ilDefer is passed in
mode.
The mode also controls how the x and y parameters are interpreted.
If ilDelVal is passed in mode, x and y specify the change (delta) in
the image position. If ilAbsVal is specified, x and y specify the
new position of the image. Note that the image position corresponds
to the upper-left corner of the view, rather than the origin of the
image.
If ilRelVal is passed in mode, then x and y are interpreted relative
to a starting xy coordinate maintained within ilDisplay. Typically,
ilRelVal is used for interactive applications that use the mouse to
control movement. The setMouse() function on ilDisplay must be
called to set the starting xy location. Then the difference between
the starting xy location and the specified xy location is used to
adjust the image position. The starting xy location is then updated.
Specifying ilOldRel has the same effect as ilRelVal except that the
starting xy location is not updated.
The portion of the image being displayed resides in the cache of the
input image. So as the image is moved within the view, old pages are
discarded and new pages are brought into the cache.
Note that if a roam limit has been set with setRoamLimit(), that
image movement may be clipped. See setRoamLimit() for more
information.
For those views displaying multiple images (i.e., ilStereoView), the
moveImgIdx() ilDisplayMoveImgIdx() function allows independent
movement of each image within the view. For stereo views, the valid
values for idx are ilViewImgPairLeft and ilViewImgPairRight.
moveView()
void moveView(int x, int y, ilView* view = NULL, int mode = ilRelVal)
This function moves the specified view within the display. If NULL
is passed, then the image is moved in all views in the stack (except
those with nop flag set). The image is moved as specified by x and
y. The mode controls how the function operates. If ilClip is passed
in mode, the view position is clipped to prevent moving beyond the
edge of the display. However, by default, the view can be moved
beyond the edge of the display. The view is painted after the view
has been moved, unless ilDefer is passed in mode. The mode also
controls how the x and y parameters are interpreted.
If ilDelVal is passed in mode, x and y specify the change (delta) in
the view position. If ilAbsVal is specified, x and y specify the new
position of the view. Note that the view position corresponds to the
upper-left corner of the view relative to the upper-left corner of
the display.
If ilRelVal is passed in mode, then x and y are interpreted relative
to a starting xy coordinate maintained within ilDisplay. Typically,
ilRelVal is used for interactive applications that use the mouse to
control movement. The setMouse() function on ilDisplay must be
called to set the starting xy location. Then the difference between
the starting xy location and the specified xy location is used to
adjust the view position. The starting xy location is then updated.
Specifying ilOldRel has the same effect as ilRelVal except that the
starting xy location is not updated.
paint()
void paint(ilView* view = NULL, int mode = 0)
void paint(int x, int y, int nx, int ny,
iflOrientation orientation = iflUpperLeftOrigin,
ilView* view = NULL, int mode = 0)
This function paints the specified view if it needs to be painted.
If NULL is passed, then all views are painted if needed (except
those with nop flag set). If an area is specified with origin x, y
and size nx, ny then only the specified area is painted. The area
parameters are interpreted based on the orientation specified.
If ilPaintExpose is passed in mode, the view is forced to be
painted. If ilDefer is passed in mode, or if the view is deferred
(see setDefer()), then the view is not be painted. The view
position, size, and image position are unaffected.
pop()
void pop(ilView* view = NULL, int count = 0)
Pops view up count positions in the stack. If count is zero, the
view is popped to the top of the stack. If view is NULL, the bottom
view is popped.
push()
void push(ilView* view = NULL, int count = 0)
Pushes view down count positions in the stack. If count is zero, the
view is pushed to the bottom of the stack. If view is NULL, the top
view is pushed.
qPaint()
void qPaint(ilMpNode* parent, ilView* view = NULL, int mode = 0,
ilMpManager** pMgr = NULL)
void qPaint(ilMpNode* parent, int x, int y, int nx, int ny,
iflOrientation orientation = iflUpperLeftOrigin,
ilView* view = NULL, int mode = 0,
ilMpManager** pMgr = NULL)
This function is identical to paint() except that the paint
operation is queued and the function returns immediately. This
allows the application thread to return to processing events and
thus provide a responsive UI. See ilMpManager and ilMpNode for more
information.
If an ilMpNode is passed as parent, the paint requests are queued on
the parent node. If pMgr is specified, the ilMpManager created to
queue the paint requests is returned. This allows an application to
setup a completion callback or wait for the queued requests to
complete.
redraw()
void redraw(int mode = ilDefault)
void redraw(int x, int y, int nx, int ny,
iflOrientation orientation = iflUpperLeftOrigin,
int mode = ilDefault)
Resizes the display and back view to the size of the display window
and repaints all views. If an area is specified with origin x, y and
size nx, ny then only the specified area is painted. If ilDefer is
passed in mode, the display and back view are resized but not
painted and all views are unaffected. This function is useful when
an expose event occurs.
removeViewChangeCallback()
ilStatus removeViewChangeCallback(ilCallback* cb)
This method removes a view add/delete callback previously added with
addViewChangeCallback().
save()
ilStatus save(ilImage* img, int x = 0, int y = 0, int mode = 0)
This function saves a region of the display area into the ilImage
specified by img. The region that is saved starts at the location
specified by x and y and is the size of img. By default, borders are
not painted. However, if ilPaintBorder is passed in mode, then
borders are painted on views with borders turned on.
select()
void select(ilView* view = NULL)
Selects the specified view. If NULL is passed, then all views in the
view stack are selected. When a view is selected, its nop flag is
FALSE and its borders are enabled.
setBackground()
void setBackground(float red, float green, float blue)
Sets the ilDisplay's background color to that specified by red,
green and blue. The values are assumed to be normalized to the range
0.0 to 1.0.
setBackgroundDirty()
void setBackgroundDirty()
Indicates that the ilDisplay's background needs to be repainted for
some external reason (e.g. graphics drawn on top that need to be
updated).
setBorderColor()
void setBorderColor(float red, float green, float blue)
Sets the border color to red, green and blue on all views in the
stack. The values are assumed to be normalized to the range 0.0 to
1.0. See also ilView.
setBorderStyle()
void setBorderStyle(int style = ilViewBdrSolidLines)
Sets the border style on all views, to that specified by style. By
default, view borders are set to ilViewBdrSolidLines. See ilView
for more information.
setBorderWidth()
void setBorderWidth(int width)
Sets the border width to width on all views in the stack.
setBorders()
void setBorders(int enable, int mode = ilDefault)
Sets the border flag on all views in the stack to the specified
value. If flag is TRUE, then borders are turned on, otherwise
borders are turned off. Borders will be painted or erased unless
defer mode has been set.
setCallback()
void setCallback(ilCallback* prepare, ilCallback* render,
ilCallback* finish = NULL)
Sets the post-render callback which is associated with the back
view. The callback is called after all views have been rendered.
There are actually three callbacks: prepare, render and finish. The
prepare callback is called by one of the compute threads to perform
any pre-rendering allocations or computations. Then the render
callback is called by the IL's render thread to perform actual
rendering into the display window. This callback must execute as
efficiently as possible to achieve maximum performance. It is called
by the IL's render thread to minimize context switching. Any state
changes made by the callback must be restored prior to completion.
Finally, the finish callback is called by one of the compute threads
to perform any de-allocation or cleanup required. The prepare and
finish callbacks may be set to NULL if not required. See ilView and
ilViewCallback for more information.
setColormap()
void setColormap(iflColormap& cmap)
Sets the colormap to the ilLut specified by cmap. The colormap is
used by ilXDisplayImg or ilGLDisplayImg depending on the render
mode. Note that this will override the ilDefaultCmap mode passed to
the constructor.
setDefer()
void setDefer(int def, ilView* view = NULL)
Sets the state of the defer flag on the specified view. If view is
NULL, then the defer flag on ilDisplay is set. If defer is TRUE,
then painting does not occur or is deferred. When painting is
deferred, changes to a view's position, size or image position are
accumulated until the view can be painted. Note that ilDisplay can
be deferred or each individual ilView can be deferred.
setLoc()
ilView* setLoc(float ix, float iy, float x, float y,
int mode = ilLocIn)
This function finds the view at xy and sets the location in the
image specified by ix and iy to the location in the display
specified by x and y. The image is moved as needed to relocate the
specified point. If ilLocIn is passed in mode, the location is found
in the input space of the image. If ilLocIn is passed in mode, the
location is found in the output space of the image. For example, if
an ilRotZoomIng is mapped to the view and ilLocIn is specified, ix
and iy correspond to the location in the unrotated image. However,
if ilLocOut is specified, ix and iy correspond to the location in
the rotated image. The relocation can be accomplished by moving
either the image or the view. If ilLocView is specified then the
view is moved, alternatively if ilLocImg is specified (default) then
the image is moved.
setMargin()
void setMargin(int margin)
Sets the default margin to the number of pixels specified in margin.
This margin is used by findEdge() if no margin is specified.
setMode()
void setMode(int mode = 0)
Sets the display mode as specified by mode. This display mode is
added to the mode used to create new views with addView(). For
example, if ilDefer is set in the display mode, then ilDefer will be
added to the mode passed to addView().
setMouse()
void setMouse(int x, int y, int mode = 0)
Sets the starting mouse location to the coordinate x, y. Note that
x and y are interpreted in the current event space, which is
determined by the type of window (X or GL) being used. This method
is typically used to preset mouse values to initialize an
interactive display operation loop such as moving a view.
setNop()
void setNop(int noOp, ilView* view = NULL)
Sets NOP state for the specified view. If view is NULL, then all
views are set. If set to TRUE, display operations are disabled on
this view until the flag is set to FALSE.
setPixel()
ilView* setPixel(int x, int y, iflPixel& pix)
Sets the pixel located x and y to the value specified in pix. First
the view at x,y is found using findView() and setPixel() is called
on that ilView. See the ilView man page for more information.
setRoamLimit()
void setRoamLimit(float maxRoamDel = 0.0)
Sets the maximum number of pixels an image can move. The roam limit
causes image movement to be limited in order to facilitate smooth
roaming with moveImg(). The roam limit is used to calculate the
maximum roam rate in x and y for a given direction. If maxRoamDel is
set to 0.0 or negative, the roam limit is disabled.
setStatus()
void setStatus(ilStatus stat)
Sets the status of ilDisplay to the ilStatus specified in stat. See
also getStatus().
setVisibleArea()
void setVisibleArea(int x = 0, int y = 0, int nx = 0,
int ny = 0)
Sets the visible area within the display window in order to
optimally support scrolled windows. The origin of the area is
specified as x, y and the size of the area is specified by nx, ny.
This causes painting to be clipped to the visual area. If 0 is
passed for all area parameters then this function is disabled.
setWindow()
void setWindow(Window win, int mode = ilDefault)
Sets the display window to the X window specified in win and
reinitializes ilDisplay. The render mode and display mode are
specified as in the constructor. This function is used to change the
configuration of the display window used by ilDisplay.
split()
void split(int mode = ilAbsSplit|ilRowSplit|ilColSplit)
This function repositions and resizes all views in the view stack so
that all views are visible. The mode specifies how the views are
arranged. Starting at the bottom of the view stack, views are placed
starting at the upper left corner of the display. The various split
modes are listed below:
ilAbsSplit All images are aligned based on the align mode
specified (ilBottomLeft by default).
ilRelSplit All images are positioned relative to the view
position.
ilRowSplit The views are arranged in rows.
ilColSplit The views are arranged in columns.
ilPackSplit Views sizes are clipped to the size of the image and
packed together.
The relative split mode causes images to be positioned so that the
image continues from one view to the next. Any combination of these
split modes can be used. For example, if
ilRowSplit | ilColSplit is specified in mode, views are arranged
into an equal number of rows and columns.
swap()
void swap(ilView* view1, ilView* view2)
Swaps the positions in the view stack of the two views specified.
syncPaint()
void syncPaint()
This method will not return until all queued rendering requests are
completed. See enableQueueing().
unselect()
void unselect(ilView* view = NULL)
Unselects the specified view. If NULL is passed, then all views in
the view stack are unselected (except those with nop flag set).
When a view is unselected, its nop flag is TRUE and its borders are
disabled.
update()
void update(int x = 0, int y = 0, int nx = 0, int ny = 0,
float imgX = 0, float imgY = 0, ilView* view = NULL,
int mode = ilDelVal)
This function allows the view position, view size and image position
to be adjusted for the specified view. If no view is specified, then
all views are updated. The view is moved as specified by x and y.
The view size is adjusted as specified by nx and ny. The image is
moved within the view as specified by imgX and imgY. All three
adjustments are clipped if ilClip is passed in mode. After all three
adjustments are made the view is painted, unless ilDefer is passed
in mode.
If ilDelVal is passed in mode, all parameters specify the change
(delta) in position and size. If ilAbsVal is specified, all
parameters specify the absolute position or size. If ilRelVal is
passed in mode, then all parameters are interpreted relative to a
starting xy coordinate maintained within ilDisplay. ilRelVal is not
recommended for use with this operator. See moveView and moveImg for
more details.
updateWindow()
void updateWindow()
This function is used to reinitialize the ilDisplay when the
configuration of the display window has been changed. For example,
if the GL window is changed from RGB mode to color index,
updateWindow() must be called.
wipe()
void wipe(int x, int y, ilView* view = NULL, int mode = ilRelVal)
This function moves one or more edges on the specified view. If NULL
is passed, then all views are wiped (except those with nop flag
set). The edge or edges to move are specified in mode. For example,
if ilRightEdge is passed in mode, the right edge of the view moves
as specified by x and y. In addition, if ilTopEdge | ilRightEdge (or
ilTopRight) is specified, then the upper right corner is moved. Note
that the value returned by findEdge() can be used directly.
In general, a wipe operation resizes the view. However, if ilAllEdge
is passed in mode, then all edges of the view are moved and the view
size is unchanged. This operation is referred to as an inset - the
image is stationary and the view moves. This is the opposite of
moving the image within the view. When comparing images, wiping is
very useful.
If ilDelVal is passed in mode, x and y specify the change (delta) in
the image position. If ilAbsVal is specified, x and y specify the
new position of the image. If ilRelVal is passed in mode, then x and
y are interpreted relative to a starting xy coordinate maintained
within ilDisplay.
If ilClip is passed in mode, the the edge is not allowed to move
beyond the edge of the image. However, by default the edge can be
moved beyond the edge of the image, exposing the image's fill value.
If ilDefer is passed in mode, then the view is not painted after the
operation.
wipeSize()
void wipeSize(int x, int y, ilView* view = NULL,
int mode = ilDelVal|ilTopRight)
This function moves an edge or corner and the opposite edge or
corner on the specified view. If NULL is passed, then all views in
the view stack are affected (except those with nop flag set). The
edge or corner passed in mode is moved as specified by x and y. In
addition, the opposite edge or corner is moved in the opposite
direction. This causes the view to grow or shrink by moving opposite
edges or corners. For example, if the right edge is moved right by
ten pixels, the left edge is also moved left by ten pixels. Note
that the value returned by findEdge() can be used directly.
If ilDelVal is passed in mode, x and y specify the change (delta) in
the image position. If ilAbsVal is specified, x and y specify the
new position of the image. If ilRelVal is passed in mode, then x and
y are interpreted relative to a starting xy coordinate maintained
within ilDisplay.
wipeSplit()
void wipeSplit(int x, int y, int mode = ilRelVal)
This function moves the edge on all views, found by calling
findEdge() on ilDisplay. All of these edges are moved as specified
by x and y. For example, if two views are displayed side-by-side,
the right edge of the left view and the left edge of the right view
can be moved simultaneously. This is useful after a split operation.
If ilDelVal is passed in mode, x and y specify the change (delta) in
the image position. If ilAbsVal is specified, x and y specify the
new position of the image. If ilRelVal is passed in mode, then x and
y are interpreted relative to a starting xy coordinate maintained
within ilDisplay.
ilXWindowImg, ilView, ilViewIter, <il/ilDisplayDefs.h>
Many display operators take a mode parameter which is a bit-wise
inclusive OR of various flags defined in ilDisplayDefs.h. These flags are
interpreted based on which operator is called. For example, ilCenter can
be used to align a view or can be used to locate the center of a view.
All views in the view stack are deleted when ilDisplay is deleted.
ilViewIter can be used to iterate through the view stack. It is declared
in ilDisplay.h