CVR-Lib last update 20 Sep 2009

cvr::viewerBase Class Reference

Class viewerBase. More...

#include <cvrViewerBase.h>

Inheritance diagram for cvr::viewerBase:

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

Collaboration graph
[legend]

List of all members.

Classes

class  configDialog
 Parent class for all configuration classes. More...
class  information
 Information block. More...
struct  interaction
 Interaction structure. More...
class  mainWindow
 Parent class of all main windows. More...
class  parameters
 Parameters of the cvr::viewerBase class. More...

Public Types

enum  eInteractionType {
  Idle = 0, KeyPressed, KeyReleased, ButtonPressed,
  ButtonReleased, MouseMoved, Closed
}
enum  eMouseButton {
  NoButton = 0, LeftButton = 1, MiddleButton = 2, RightButton = 4,
  WheelUp = 8, WheelDown = 16, OtherButton = 32
}
enum  eKeyModifiers { NoModifier = 0, ShiftKey = 1, CtrlKey = 2, AltKey = 4 }

Public Member Functions

 viewerBase ()
 viewerBase (const viewerBase &other)
 ~viewerBase ()
virtual const std::string & name () const
viewerBasecopy (const viewerBase &other)
bool hide ()
virtual bool updateParameters ()
const parametersgetParameters () const
Interaction functions.
The interaction activity with the viewer is not considered to alter its state.

So you can have a constant viewer (for example, you give the viewer as const argument to a method, where the viewer already shows something) and make some interaction with it. You can query for interaction with the viewer without problems.

virtual bool waitInteraction (interaction &action, ipoint &position, const bool onlyIfValid=true) const
virtual bool waitButtonPressed (interaction &action, ipoint &position, const bool onlyIfValid=true) const
virtual bool waitButtonReleased (interaction &action, ipoint &position, const bool onlyIfValid=true) const
virtual bool waitKey (interaction &action)
virtual bool waitKeyPressed (interaction &action)
virtual void getLastAction (interaction &action, ipoint &position) const

Protected Member Functions

parametersgetParametersRW ()
virtual bool validPosition (const ipoint &position) const
virtual bool onKMInteraction (const interaction &action, const ipoint &position)
const configDialoggetConfigDialog () const
configDialoggetConfigDialog ()
virtual bool useConfig (configDialog *dlg)
virtual bool attachConfig (configDialog *dlg)
virtual bool showConfig ()
virtual bool updateFromConfig (const bool keepConfigData)
virtual bool hideConfig ()
virtual bool ensureMainWindow ()
bool validMainWindow () const
const mainWindowgetMainWindow () const
mainWindowgetMainWindow ()
bool useMainWindow (mainWindow *newWnd)
bool attachMainWindow (mainWindow *newWnd)
bool validInformation () const
bool setInformation (const information &info)
const informationgetInformation () const
virtual bool updateInformation ()
informationgetInformation ()


Detailed Description

Class viewerBase.

Abstract class, parent for all CVR-Lib viewers.

It provides some basic interfacing that all viewers must support. The management of the viewer parameters is also provided here (similar to the functor concept).

The architecture of the class tree is supposed to support a strong encapsulation of the GUI toolkit specifics, which won't be found here, but in the internal (here still undefined) classes 'tk', which are defined in the files corresponding to the toolkit (like cvrViewerBaseGtk.h)


Member Enumeration Documentation

Interaction events recognized by the interface.

Enumerator:
Idle  No interaction reported.
KeyPressed  Key Pressed.
KeyReleased  Key Released.
ButtonPressed  Mouse Button Pressed.
ButtonReleased  Mouse Button Released.
MouseMoved  Mouse Pointer Moved.
Closed  Window has been closed.

Key Modifiers.

This flags can be combined with the bitwise logic operators.

Enumerator:
NoModifier  No modifier.
ShiftKey  Shift key.
CtrlKey  Control key.
AltKey  Alternate key.

Mouse button symbols.

Enumerator:
NoButton  No button pressed.
LeftButton  Left mouse button.
MiddleButton  Middle mouse button.
RightButton  Right mouse button.
WheelUp  Mouse wheel turned up.
WheelDown  Mouse wheel turned down.
OtherButton  Any other mouse button.


Constructor & Destructor Documentation

cvr::viewerBase::viewerBase (  ) 

Construct a viewerBase.

cvr::viewerBase::viewerBase ( const viewerBase other  ) 

Copy constructor.

cvr::viewerBase::~viewerBase (  ) 

Virtual destructor.


Member Function Documentation

virtual bool cvr::viewerBase::attachConfig ( configDialog dlg  )  [protected, virtual]

Give the configuration dialog to be used.

The memory management is taken from the user.

See also:
useConfig()

bool cvr::viewerBase::attachMainWindow ( mainWindow newWnd  )  [protected]

Set mainWindow.

Exactly the pointed object will be utilized, without copying it, and the memory management is taken from the user.

Warning:
The user should never remove the given instance.
See also:
useMainWindow()
Returns:
true if the new object was simply assigned, or false if a previous object had to be removed first.

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

copy all attributes of the viewerBase

virtual bool cvr::viewerBase::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 in cvr::viewer2D.

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

Return a writable reference to the configuration dialog.

Reimplemented in cvr::viewer2D.

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

Return a read-only reference to the configuration dialog.

Reimplemented in cvr::viewer2D.

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

Get a writable reference to the internal information block.

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

Reimplemented in cvr::viewer2D.

const information& cvr::viewerBase::getInformation (  )  const [protected]

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

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

Reimplemented in cvr::viewer2D.

virtual void cvr::viewerBase::getLastAction ( interaction action,
ipoint position 
) const [virtual]

Returns the information available about the last action.

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

Return the main window as reference.

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

Reimplemented in cvr::viewer2D.

const mainWindow& cvr::viewerBase::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 in cvr::viewer2D.

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

Return current parameter's instance.

Reimplemented from cvr::parametersManager.

Reimplemented in cvr::viewer2D.

parameters& cvr::viewerBase::getParametersRW (  )  [protected]

Return current parameter's instance.

bool cvr::viewerBase::hide (  ) 

Hide the current window and all its configuration dialogs if displayed.

Returns:
true if window was hidden or false if it was already hidden or it has not been shown up yet.

virtual bool cvr::viewerBase::hideConfig (  )  [protected, virtual]

Function called if for some reason the configuration dialog has to be hidden.

virtual const std::string& cvr::viewerBase::name (  )  const [virtual]

Name of the class.

Implements cvr::ioObject.

virtual bool cvr::viewerBase::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 in cvr::viewer2D.

bool cvr::viewerBase::setInformation ( const information info  )  [protected]

Make a copy of the given information block and store it internally.

virtual bool cvr::viewerBase::showConfig (  )  [protected, virtual]

Function called if the configuration dialog is to be shown.

The derived classes have to set the data of the configuration dialog

virtual bool cvr::viewerBase::updateFromConfig ( const bool  keepConfigData  )  [protected, virtual]

Function called if the user pressed "apply" or "ok" on the configuration dialog, which is normally used to apply all changes in the dialog parameters to the displayed data.

Parameters:
keepConfigData if true, the configuration dialog has to keep its data, which is desired when "apply" is pressed. if false, the parameters won't be copied, but just transfered to the viewer.

virtual bool cvr::viewerBase::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 in cvr::viewer2D.

virtual bool cvr::viewerBase::updateParameters (  )  [virtual]

Update parameters.

Overload necessary to transfer some data to the corresponding windows

Reimplemented from cvr::parametersManager.

virtual bool cvr::viewerBase::useConfig ( configDialog dlg  )  [protected, virtual]

Give the configuration dialog to be used.

The memory management is responsibility of the user.

See also:
setConfig()

bool cvr::viewerBase::useMainWindow ( mainWindow newWnd  )  [protected]

Set mainWindow.

Exactly the pointed object will be utilized, without copying it, and the memory management is assumed to be done by the user himself.

See also:
attachMainWindow
Returns:
true if the new object was simply assigned, or false if a previous object had to be removed first.

bool cvr::viewerBase::validInformation (  )  const [protected]

Returns true if the information block has been set or false otherwise.

bool cvr::viewerBase::validMainWindow (  )  const [protected]

Returns true if the mainWindow has been set.

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

Determine if the given position is valid.

Reimplemented in cvr::viewer2D.

virtual bool cvr::viewerBase::waitButtonPressed ( interaction action,
ipoint position,
const bool  onlyIfValid = true 
) const [virtual]

Waits until a mouse button is pressed.

Parameters:
action interaction object where all information about key/button, modifiers and type of interaction is stored.
position position where the mouse was clicked
onlyIfValid if true, this method waits until the mouse pointer and focus of the window lies on the main viewer window. If false, only the focus is required to report any interaction
Returns:
true if an interaction took place, false if the function returns due to the destruction of the viewer object (for example, the user closed the window).

virtual bool cvr::viewerBase::waitButtonReleased ( interaction action,
ipoint position,
const bool  onlyIfValid = true 
) const [virtual]

Waits until a mouse button is released.

Parameters:
action interaction object where all information about key/button, modifiers and type of interaction is stored.
position position where the mouse was clicked
onlyIfValid if true, this method waits until the mouse pointer and focus of the window lies on the main viewer window. If false, only the focus is required to report any interaction
Returns:
true if an interaction took place, false if the function returns due to the destruction of the viewer object (for example, the user closed the window).

virtual bool cvr::viewerBase::waitInteraction ( interaction action,
ipoint position,
const bool  onlyIfValid = true 
) const [virtual]

The most complete interaction function reports almost anything.

Parameters:
action interaction object where all information about key/button, modifiers and type of interaction is stored.
position position where the mouse was clicked
onlyIfValid if true, this method waits until the mouse pointer and focus of the window lies on the main viewer window. If false, only the focus is required to report any interaction
Returns:
true if an interaction took place, false if the function returns due to the destruction of the viewer object (for example, the user closed the window).

virtual bool cvr::viewerBase::waitKey ( interaction action  )  [virtual]

Waits until a keyboard key is pressed.

Note. This get triggered for key down and for key up. In a loop that executes quickly and uses waitKey() to stop for viewing after each iteration you might get the impression that two steps are taken at once. This is because iteration time is faster than the time it takes to lift the finger. Consider using waitKeyPressed instead.

Parameters:
action interaction object where all information about key/button, modifiers and type of interaction is stored.
Returns:
true if an interaction took place, false if the function returns due to the destruction of the viewer object (for example, the user closed the window).

virtual bool cvr::viewerBase::waitKeyPressed ( interaction action  )  [virtual]

Waits until a keyboard key is pressed down.

Parameters:
action interaction object where all information about key/button, modifiers and type of interaction is stored.
Returns:
true if an interaction took place, false if the function returns due to the destruction of the viewer object (for example, the user closed the window).


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

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