Image Component Library (ICL)
Public Types | Public Slots | Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
icl::qt::MouseHandler Class Reference

MouseEvent Handler. More...

#include <MouseHandler.h>

Inheritance diagram for icl::qt::MouseHandler:
icl::geom::SceneMouseHandler icl::physics::PhysicsPaper3MouseHandler icl::qt::AdjustGridMouseHandler icl::qt::DefineQuadrangleMouseHandler icl::qt::DefineRectanglesMouseHandler icl::qt::DragRectangleMouseHandler icl::physics::PhysicsMouseHandler

Public Types

typedef void(* mouse_handler) (const MouseEvent &event)
 mouse_handler function type More...
 

Public Slots

void handleEvent (const MouseEvent &event)
 connected to the ICLWidget's signal mouseEventOccured More...
 

Public Member Functions

 MouseHandler (mouse_handler handler)
 Create a mouse handler with given callback function. More...
 
virtual void process (const MouseEvent &event)
 this function is called automatically when the handleEvent slot is invoked More...
 

Protected Member Functions

 MouseHandler ()
 This constructor can be called from derived classes. More...
 

Private Attributes

mouse_handler m_handler
 internal mouse handler function More...
 

Friends

class ICLWidget
 ICLWidget is allowed to connect to the private slot handleEvent. More...
 

Detailed Description

MouseEvent Handler.

Here's a short example:

#include <ICLQt/Common.h>
#include <iterator>
GenericGrabber *grabber;
ICLWidget *widget;
class Mouse : public MouseHandler{
public:
virtual void process(const MouseEvent &event){
std::cout << "image location: " << event.getPos() << std::endl;
std::cout << "widget location: " << event.getWidgetPos() << std::endl;
std::string eventNames[] = {"MoveEvent","DragEvent","PressEvent","ReleaseEvent", "EnterEvent","LeaveEvent"};
std::cout << "type: " << eventNames[event.getType()] << std::endl;
if(event.isPressEvent()){
if(event.getColor().size()){
std::cout << "color:";
std::copy(event.getColor().begin(),event.getColor().end(),std::ostream_iterator<icl64f>(std::cout,","));
std::cout << endl;
}else{
std::cout << "no color here!" << std::endl;
}
}
}
} mouse;
void init(){
widget = new ICLWidget(0);
widget->setGeometry(200,200,640,480);
widget->show();
grabber = new GenericGrabber;
widget->install(&mouse);
}
void run(){
widget->setImage(grabber->grab());
widget->update();
}
int main(int n, char **ppc){
return ICLApp(n,ppc,"",init,run).exec();
}

Member Typedef Documentation

typedef void(* icl::qt::MouseHandler::mouse_handler) (const MouseEvent &event)

mouse_handler function type

Constructor & Destructor Documentation

icl::qt::MouseHandler::MouseHandler ( mouse_handler  handler)
inlineexplicit

Create a mouse handler with given callback function.

In most cases a MouseHandler can be used directly by passing a mouse_handler function to it's constructor. The mouse handler function is called by virtual void process automatically

icl::qt::MouseHandler::MouseHandler ( )
inlineprotected

This constructor can be called from derived classes.

derived classes will reimplement virtual void process(const MouseEvent &event), so in this case, no external mouse_handler function needs to be passed

Member Function Documentation

void icl::qt::MouseHandler::handleEvent ( const MouseEvent event)
slot

connected to the ICLWidget's signal mouseEventOccured

virtual void icl::qt::MouseHandler::process ( const MouseEvent event)
virtual

this function is called automatically when the handleEvent slot is invoked

It can be reimplemented for custom mouse interaction. If a mouse handling function is enough for your purpose, you can also pass a function of type mouse_handler to the constructor of a MouseHandler instance. The default implementation of process calls the handler function if it's not null.

Reimplemented in icl::geom::SceneMouseHandler, icl::qt::DefineRectanglesMouseHandler, icl::qt::DragRectangleMouseHandler, icl::qt::DefineQuadrangleMouseHandler, icl::qt::AdjustGridMouseHandler, icl::physics::PhysicsMouseHandler, and icl::physics::PhysicsPaper3MouseHandler.

Friends And Related Function Documentation

friend class ICLWidget
friend

ICLWidget is allowed to connect to the private slot handleEvent.

Member Data Documentation

mouse_handler icl::qt::MouseHandler::m_handler
private

internal mouse handler function


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