last update 20 Sep 2009 |
#include <cvrViewerBase.h>
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 |
viewerBase & | copy (const viewerBase &other) |
bool | hide () |
virtual bool | updateParameters () |
const parameters & | getParameters () 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 | |
parameters & | getParametersRW () |
virtual bool | validPosition (const ipoint &position) const |
virtual bool | onKMInteraction (const interaction &action, const ipoint &position) |
const configDialog & | getConfigDialog () const |
configDialog & | getConfigDialog () |
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 mainWindow & | getMainWindow () const |
mainWindow & | getMainWindow () |
bool | useMainWindow (mainWindow *newWnd) |
bool | attachMainWindow (mainWindow *newWnd) |
bool | validInformation () const |
bool | setInformation (const information &info) |
const information & | getInformation () const |
virtual bool | updateInformation () |
information & | getInformation () |
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)
Interaction events recognized by the interface.
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. |
cvr::viewerBase::viewerBase | ( | ) |
Construct a viewerBase.
cvr::viewerBase::viewerBase | ( | const viewerBase & | other | ) |
Copy constructor.
cvr::viewerBase::~viewerBase | ( | ) |
Virtual destructor.
virtual bool cvr::viewerBase::attachConfig | ( | configDialog * | dlg | ) | [protected, virtual] |
Give the configuration dialog to be used.
The memory management is taken from the user.
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.
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.
Reimplemented in cvr::viewer2D.
configDialog& cvr::viewerBase::getConfigDialog | ( | ) | [protected] |
const configDialog& cvr::viewerBase::getConfigDialog | ( | ) | const [protected] |
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.
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] |
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.
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.
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.
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] |
virtual bool cvr::viewerBase::waitButtonPressed | ( | interaction & | action, | |
ipoint & | position, | |||
const bool | onlyIfValid = true | |||
) | const [virtual] |
Waits until a mouse button is pressed.
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 |
virtual bool cvr::viewerBase::waitButtonReleased | ( | interaction & | action, | |
ipoint & | position, | |||
const bool | onlyIfValid = true | |||
) | const [virtual] |
Waits until a mouse button is released.
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 |
virtual bool cvr::viewerBase::waitInteraction | ( | interaction & | action, | |
ipoint & | position, | |||
const bool | onlyIfValid = true | |||
) | const [virtual] |
The most complete interaction function reports almost anything.
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 |
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.
action | interaction object where all information about key/button, modifiers and type of interaction is stored. |
virtual bool cvr::viewerBase::waitKeyPressed | ( | interaction & | action | ) | [virtual] |
Waits until a keyboard key is pressed down.
action | interaction object where all information about key/button, modifiers and type of interaction is stored. |