XWindow Class Reference

A simple X-window to display images. More...

#include <GUI/XWindow.H>

Inheritance diagram for XWindow:
Inheritance graph
[legend]
Collaboration diagram for XWindow:
Collaboration graph
[legend]

List of all members.

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

We wrap these calls, rather than exposing a Display* and Window directly, so that we can get the threading issues right; namely, we need to lock a global mutex each time any window wants to use the Display*, since multiple threads may be running and accessing the Display*.

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 ()

Detailed Description

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.


Constructor & Destructor Documentation

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.

Parameters:
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]

Destructor.

Definition at line 767 of file XWindow.C.

References rutz::shared_ptr< T >::reset().


Member Function Documentation

Bool XWindow::checkMaskEvent ( long  event_mask,
XEvent *  event 
) const

Calls XCheckWindowEvent().

Note that XCheckWindowEvent() is just like XCheckMaskEvent(), but restricted to a specific Window)

Definition at line 836 of file XWindow.C.

Bool XWindow::checkTypedEvent ( int  event_type,
XEvent *  event 
) const

Calls XCheckTypedWindowEvent().

Definition at line 843 of file XWindow.C.

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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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

Get the window title.

Definition at line 650 of file XWindow.C.

bool XWindow::isVisible ( const bool  v  )  const [inline]

Check whether the window is currently mapped (i.e. visible on screen).

Definition at line 81 of file XWindow.H.

void XWindow::selectInput ( long  event_mask  )  const

Calls XSelectInput().

Definition at line 816 of file XWindow.C.

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 
)

Set the position of an XWindow.

Parameters:
x Horizontal position hint for window placement
y Vertical position hint for window placement

Definition at line 665 of file XWindow.C.

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

Calls XInternAtom() followed by XSetWMProtocols().

Definition at line 824 of file XWindow.C.


The documentation for this class was generated from the following files:
Generated on Sun May 8 08:26:57 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3