A simple X-window to display images. More...
#include <GUI/XWindow.H>
Classes | |
struct | XWinImage |
Public Member Functions | |
XWindow (const Dims &dims=Dims(320, 240), const int x=-1, const int y=-1, const char *title="USC Neuromorphic Vision") | |
Constructor: create, display and map the window. | |
virtual | ~XWindow () |
Destructor. | |
void | setVisible (const bool v) |
Change the window's visibility (map or unmap it as needed). | |
bool | isVisible (const bool v) const |
Check whether the window is currently mapped (i.e. visible on screen). | |
void | setPosition (const int x, const int y) |
Set the position of an XWindow. | |
Point2D< int > | getPosition () |
Get the position of an XWindow. | |
void | drawImage (const Image< PixRGB< byte > > &img, const int x=0, const int y=0, const bool resizeWindow=false) |
Draw an image into the XWindow. | |
void | drawImage (const Image< byte > &img, const int x=0, const int y=0, const bool resizeWindow=false) |
Draw an image into the XWindow. | |
void | drawImage (const Image< float > &img, const int x=0, const int y=0, bool normalize=true, const bool resizeWindow=false) |
Draw an image into the XWindow. | |
void | drawRgbLayout (const Layout< PixRGB< byte > > &layout, const int x=0, const int y=0, const bool resizeWindow=false) |
Draw an image layout into the XWindow. | |
void | drawGrayLayout (const Layout< byte > &layout, const int x=0, const int y=0, const bool resizeWindow=false) |
Draw an image layout into the XWindow. | |
const char * | getTitle () const |
Get the window title. | |
void | setTitle (const char *title) |
set the title bar to a new string | |
Dims | getDims () const |
return the dimensions of this window | |
void | setDims (const Dims &dims) |
change the dimensions of this window | |
Wrappers around X11 Xlib calls | |
void | selectInput (long event_mask) const |
Calls XSelectInput(). | |
Atom | setWMProtocol (const char *atomname) const |
Calls XInternAtom() followed by XSetWMProtocols(). | |
Bool | checkMaskEvent (long event_mask, XEvent *event) const |
Calls XCheckWindowEvent(). | |
Bool | checkTypedEvent (int event_type, XEvent *event) const |
Calls XCheckTypedWindowEvent(). | |
Protected Member Functions | |
void | redrawImage () |
A simple X-window to display images.
Use this class to create an window on your screen and display an image. It will use shared memory between us and the X server if supported by the X server and the display is local. Resizing is not allowed; so any image passed to drawImage() must have dimensions that match those specified at onstruction of the XWindow.
Definition at line 61 of file XWindow.H.
XWindow::XWindow | ( | const Dims & | dims = Dims(320, 240) , |
|
const int | x = -1 , |
|||
const int | y = -1 , |
|||
const char * | title = "USC Neuromorphic Vision" | |||
) |
Constructor: create, display and map the window.
dims | Dimensions of usable image area. | |
x | Horizontal position hint for window placement; use -1 for automatic placement. | |
y | Vertical position hint for window placement; use -1 for automatic placement. | |
title | String that will appear in the window title. |
Definition at line 542 of file XWindow.C.
References Dims::h(), Dims::isEmpty(), and Dims::w().
XWindow::~XWindow | ( | ) | [virtual] |
Bool XWindow::checkMaskEvent | ( | long | event_mask, | |
XEvent * | event | |||
) | const |
Bool XWindow::checkTypedEvent | ( | int | event_type, | |
XEvent * | event | |||
) | const |
void XWindow::drawGrayLayout | ( | const Layout< byte > & | layout, | |
const int | x = 0 , |
|||
const int | y = 0 , |
|||
const bool | resizeWindow = false | |||
) |
Draw an image layout into the XWindow.
This is equivalent to drawImage(layout.render()), but is implemented more efficiently by avoiding an intermediate copy rendered of the image.
resizeWindow | if true, then the window will be resized (if necessary) to precisely fit the dimensions of the image; if false (the default), then the dimension of the image must be equal to or less than the current dimensions of the window |
Definition at line 759 of file XWindow.C.
Referenced by ImageDisplayStream::writeFrame().
void XWindow::drawImage | ( | const Image< float > & | img, | |
const int | x = 0 , |
|||
const int | y = 0 , |
|||
bool | normalize = true , |
|||
const bool | resizeWindow = false | |||
) |
Draw an image into the XWindow.
img | the image to be drawn in the window | |
x | if the x coordinate where the image should start in the window. | |
y | if the y coordinate where the image should start in the window. | |
normalize | if true, inplaceNormalize() the image to [0,255]; if false, inplaceClamp() the image to [0,255] | |
resizeWindow | if true, then the window will be resized (if necessary) to precisely fit the dimensions of the image; if false (the default), then the dimension of the image must be equal to or less than the current dimensions of the window |
Definition at line 733 of file XWindow.C.
References drawImage(), Image< T >::getDims(), image, inplaceClamp(), inplaceNormalize(), and setDims().
void XWindow::drawImage | ( | const Image< byte > & | img, | |
const int | x = 0 , |
|||
const int | y = 0 , |
|||
const bool | resizeWindow = false | |||
) |
Draw an image into the XWindow.
img | the image to be drawn in the window | |
x | if the x coordinate where the image should start in the window. | |
y | if the y coordinate where the image should start in the window. | |
resizeWindow | if true, then the window will be resized (if necessary) to precisely fit the dimensions of the image; if false (the default), then the dimension of the image must be equal to or less than the current dimensions of the window |
Definition at line 708 of file XWindow.C.
References ASSERT, Image< T >::getDims(), Image< T >::getHeight(), Image< T >::getWidth(), Dims::h(), setDims(), and Dims::w().
void XWindow::drawImage | ( | const Image< PixRGB< byte > > & | img, | |
const int | x = 0 , |
|||
const int | y = 0 , |
|||
const bool | resizeWindow = false | |||
) |
Draw an image into the XWindow.
img | the image to be drawn in the window | |
x | if the x coordinate where the image should start in the window. | |
y | if the y coordinate where the image should start in the window. | |
resizeWindow | if true, then the window will be resized (if necessary) to precisely fit the dimensions of the image; if false (the default), then the dimension of the image must be equal to or less than the current dimensions of the window |
Definition at line 683 of file XWindow.C.
References ASSERT, Image< T >::getDims(), Image< T >::getHeight(), Image< T >::getWidth(), Dims::h(), setDims(), and Dims::w().
Referenced by MbariResultViewer::displayImage(), drawImage(), main(), plotData(), ImageDisplayStream::writeFrame(), and XWinManaged::XWinManaged().
void XWindow::drawRgbLayout | ( | const Layout< PixRGB< byte > > & | layout, | |
const int | x = 0 , |
|||
const int | y = 0 , |
|||
const bool | resizeWindow = false | |||
) |
Draw an image layout into the XWindow.
This is equivalent to drawImage(layout.render()), but is implemented more efficiently by avoiding an intermediate copy rendered of the image.
resizeWindow | if true, then the window will be resized (if necessary) to precisely fit the dimensions of the image; if false (the default), then the dimension of the image must be equal to or less than the current dimensions of the window |
Definition at line 751 of file XWindow.C.
Referenced by ImageDisplayStream::writeFrame().
Dims XWindow::getDims | ( | ) | const |
return the dimensions of this window
Definition at line 799 of file XWindow.C.
Referenced by MbariResultViewer::displayImage().
Point2D< int > XWindow::getPosition | ( | ) |
Get the position of an XWindow.
Definition at line 673 of file XWindow.C.
Referenced by setVisible().
const char * XWindow::getTitle | ( | ) | const |
bool XWindow::isVisible | ( | const bool | v | ) | const [inline] |
void XWindow::selectInput | ( | long | event_mask | ) | const |
void XWindow::setDims | ( | const Dims & | dims | ) |
change the dimensions of this window
Definition at line 805 of file XWindow.C.
Referenced by drawImage().
void XWindow::setPosition | ( | const int | x, | |
const int | y | |||
) |
void XWindow::setTitle | ( | const char * | title | ) |
set the title bar to a new string
Definition at line 656 of file XWindow.C.
Referenced by MbariResultViewer::displayImage().
void XWindow::setVisible | ( | const bool | v | ) |
Change the window's visibility (map or unmap it as needed).
Definition at line 620 of file XWindow.C.
References getPosition(), and Point2D< T >::i.
Atom XWindow::setWMProtocol | ( | const char * | atomname | ) | const |