CVR-Lib last update 20 Sep 2009

cvr::viewer2D Class Reference
[Visualization Tools]

Class viewer2D. More...

#include <cvrViewer2D.h>

Inheritance diagram for cvr::viewer2D:

Inheritance graph
[legend]
Collaboration diagram for cvr::viewer2D:

Collaboration graph
[legend]

List of all members.

Classes

class  configDialog
 Configuration dialog for 2D data. More...
class  information
 Information block. More...
class  mainWindow
 Main window of the 2D viewer. More...
class  parameters
 There are parameters related with the GUI, for example which interaction configuration starts the config dialog, the position of the window, etc. More...

Public Types

enum  eDataType

Public Member Functions

 viewer2D (const std::string &title="Unknown")
 viewer2D (const viewer2D &other)
 viewer2D (const parameters &params)
 ~viewer2D ()
virtual viewer2Dclone () const
virtual viewer2DnewInstance () const
viewer2Dcopy (const viewer2D &other)
const parametersgetParameters () const
virtual bool setPainter (const viewer2DPainter &painter)
virtual bool saveButtonPressed (const std::string &filename)
const informationgetInformation () const
Show images or matrices
bool show (const matrix< rgbaPixel > &img)
bool show (const matrix< float > &chnl)
bool show (const matrix< int32 > &mask)
bool show (const matrix< ubyte > &chnl8)

Protected Member Functions

virtual viewer2DPainternewDefaultPainter () const
informationgetInformation ()
bool ensureInformationType (const eDataType &type, const ipoint &matrixSize)
virtual bool updateInformation ()
virtual bool validPosition (const ipoint &position) const
virtual bool onKMInteraction (const interaction &action, const ipoint &position)
virtual bool ensureMainWindow ()
const mainWindowgetMainWindow () const
mainWindowgetMainWindow ()
const configDialoggetConfigDialog () const
configDialoggetConfigDialog ()
virtual bool getFormattedData (const irectangle &area, image &img)
const matrix< rgbaPixel > * getDataAsImage () const
const matrix< float > * getDataAsChannel () const
const matrix< ubyte > * getDataAsChannel8 () const
const matrix< int32 > * getDataAsChannel32 () const

Protected Attributes

mutex lock_
const containerdata_
viewer2DPainterpainter_


Detailed Description

Class viewer2D.

Viewer class to display images, channels and masks.

It handles the following general matrix types and their corresponding derived classes:

As default behaviour you can get the configuration window pressing the right button of the mouse, but you can change this behaviour setting the parameters accordingly.

If you like the way the viewer displays your data, and you would like the images, then you may want to take a look at cvr::viewer2DPainter, the class responsible for painting the images you see.

Warning:
: You may experience some problems while debugging your code if you use viewers. We are looking for the problem, but as a simple workaround you just need to give the main loop enough time to initialize. Just insert following lines before any forks, or threads or viewers are created:
   guiServer::start();
   passiveWait(250000); // wait 1/4 of a second

Member Enumeration Documentation

Types of data that can be displayed with the viewer2D.


Constructor & Destructor Documentation

cvr::viewer2D::viewer2D ( const std::string &  title = "Unknown"  ) 

Constructor.

cvr::viewer2D::viewer2D ( const viewer2D other  ) 

Copy constructor.

Create a new viewer, with its own window and configuration dialog, with the same content as the other viewer. If that viewer is still inactive, this viewer will also be.

cvr::viewer2D::viewer2D ( const parameters params  ) 

Constructor.

Sets the given params

cvr::viewer2D::~viewer2D (  ) 

Destructor.


Member Function Documentation

virtual viewer2D* cvr::viewer2D::clone (  )  const [virtual]

Returns a copy of this object.

Implements cvr::ioObject.

viewer2D& cvr::viewer2D::copy ( const viewer2D other  ) 

Returns a copy of this object.

bool cvr::viewer2D::ensureInformationType ( const eDataType type,
const ipoint matrixSize 
) [protected]

Ensure that the current information block has the given type and the correct data size.

This saves time getting the information and allows the viewer more speed if a sort of video-out use is planned.

Returns false if it already had the given type or true if it was changed. This is important to know in order to setup the configuration dialog accordingly.

virtual bool cvr::viewer2D::ensureMainWindow (  )  [protected, virtual]

Ensure that a main window of the proper type has been created.

Returns:
true if a new mainWindow instance was created or false if it already existed.

Reimplemented from cvr::viewerBase.

configDialog& cvr::viewer2D::getConfigDialog (  )  [protected]

Return a writable reference to the configuration dialog.

Reimplemented from cvr::viewerBase.

const configDialog& cvr::viewer2D::getConfigDialog (  )  const [protected]

Return a read-only reference to the configuration dialog.

Reimplemented from cvr::viewerBase.

const matrix<float>* cvr::viewer2D::getDataAsChannel (  )  const [inline, protected]

Cast data_ as channel.

const matrix<int32>* cvr::viewer2D::getDataAsChannel32 (  )  const [inline, protected]

Cast data_ as channel32.

const matrix<ubyte>* cvr::viewer2D::getDataAsChannel8 (  )  const [inline, protected]

Cast data_ as channel8.

const matrix<rgbaPixel>* cvr::viewer2D::getDataAsImage (  )  const [inline, protected]

Cast data_ as image.

virtual bool cvr::viewer2D::getFormattedData ( const irectangle area,
image img 
) [protected, virtual]

Get data as an image for the window indicated by area.

information& cvr::viewer2D::getInformation (  )  [protected]

Get a writable reference to the internal information block.

This can return a wrong reference. You should check validInformation() first.

Reimplemented from cvr::viewerBase.

const information& cvr::viewer2D::getInformation (  )  const

Get a read-only reference to the internal information block.

This can return a wrong reference. You should check validInformation() first.

Reimplemented from cvr::viewerBase.

mainWindow& cvr::viewer2D::getMainWindow (  )  [protected]

Return the main window as reference.

This will throw an assertion if the mainWindow has not been set yet.

Reimplemented from cvr::viewerBase.

const mainWindow& cvr::viewer2D::getMainWindow (  )  const [protected]

Return the main window as read-only reference.

This will throw an assertion if the mainWindow has not been set yet.

Reimplemented from cvr::viewerBase.

const parameters& cvr::viewer2D::getParameters (  )  const

Return a read-only copy of the parameters.

Reimplemented from cvr::viewerBase.

virtual viewer2DPainter* cvr::viewer2D::newDefaultPainter (  )  const [protected, virtual]

Return a pointer to a new instance of the default painter you want to use.

virtual viewer2D* cvr::viewer2D::newInstance (  )  const [virtual]

Returns a copy of this object.

Implements cvr::ioObject.

virtual bool cvr::viewer2D::onKMInteraction ( const interaction action,
const ipoint position 
) [protected, virtual]

Mouse/Keyboard interaction handler.

This virtual function can be completely overriden and is called each time some interaction with the main window occurs. The default behaviour is to display the position of the mouse pointer within the window in the status bar.

Usually, derived classes override this method to intercept the interaction used to display some information under the mouse pointer.

Reimplemented from cvr::viewerBase.

virtual bool cvr::viewer2D::saveButtonPressed ( const std::string &  filename  )  [virtual]

Save button pressed.

Method called when the user pressed the save button. Usually this method just call the viewer2D::saveButtonPressed();

Note that if you call this method you can force from the code that the displayed image is saved at the location specified in the parameters.

virtual bool cvr::viewer2D::setPainter ( const viewer2DPainter painter  )  [virtual]

The user can specify a viewer2DPainter object.

Usually you will only use this method if you want to completely change the way 2D data is displayed, beyond the configuration posibilities through parameters, which is only possible if you create your own cvr::viewer2DPainter derived class.

A clone of the given painter will be done.

If you derive a class of cvr::viewer2D and want to always set your own painter, then you should only overload the method newDefaultPainter()

bool cvr::viewer2D::show ( const matrix< ubyte > &  chnl8  ) 

Show a two dimensional channel with 8 bit pixels.

Parameters:
chnl8 the fixed point channel to be displayed.
Returns:
true if successful, false otherwise

bool cvr::viewer2D::show ( const matrix< int32 > &  mask  ) 

Show a two dimensional image mask with integer values.

Parameters:
mask the mask to be displayed.
Returns:
true if successful, false otherwise

bool cvr::viewer2D::show ( const matrix< float > &  chnl  ) 

Show a two dimensional channel with float values.

Parameters:
chnl the channel to be displayed.
Returns:
true if successful, false otherwise

bool cvr::viewer2D::show ( const matrix< rgbaPixel > &  img  ) 

Show a two dimensional color image.

Parameters:
img the color image to be displayed.
Returns:
true if successful, false otherwise

virtual bool cvr::viewer2D::updateInformation (  )  [protected, virtual]

This virtual method is called just before the configuration dialog is to be displayed, in order to update the information block to the data being processed.

Reimplemented from cvr::viewerBase.

virtual bool cvr::viewer2D::validPosition ( const ipoint position  )  const [protected, virtual]

Determine if the given position is valid.

Reimplemented from cvr::viewerBase.


Member Data Documentation

const container* cvr::viewer2D::data_ [protected]

Pointer to the last object shown.

Protect access to critical data.

Reimplemented from cvr::viewerBase.

The painter.


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

Generated on Sun Sep 20 22:09:09 2009 for CVR-Lib by Doxygen 1.5.8