A state machine for polygon selections. More...
#include <qwt_picker_machine.h>


Public Member Functions | |
| virtual CommandList | transition (const QwtEventPattern &, const QEvent *) |
| Transition. | |
A state machine for polygon selections.
Pressing QwtEventPattern::MouseSelect1 or QwtEventPattern::KeySelect1 starts the selection and selects the first point, or appends a point. Pressing QwtEventPattern::MouseSelect2 or QwtEventPattern::KeySelect2 appends the last point and terminates the selection.
Definition at line 146 of file qwt_picker_machine.h.
| QwtPickerMachine::CommandList QwtPickerPolygonMachine::transition | ( | const QwtEventPattern & | eventPattern, |
| const QEvent * | e | ||
| ) | [virtual] |
Transition.
Implements QwtPickerMachine.
Definition at line 300 of file qwt_picker_machine.cpp.
References QwtPickerMachine::Append, QwtPickerMachine::Begin, QwtPickerMachine::End, QwtEventPattern::keyMatch(), QwtEventPattern::KeySelect1, QwtEventPattern::KeySelect2, QwtEventPattern::mouseMatch(), QwtEventPattern::MouseSelect1, QwtEventPattern::MouseSelect2, QwtPickerMachine::Move, QwtPickerMachine::setState(), and QwtPickerMachine::state().
{
QwtPickerMachine::CommandList cmdList;
switch(e->type())
{
case QEvent::MouseButtonPress:
{
if ( eventPattern.mouseMatch(
QwtEventPattern::MouseSelect1, (const QMouseEvent *)e) )
{
if (state() == 0)
{
cmdList += Begin;
cmdList += Append;
cmdList += Append;
setState(1);
}
else
{
cmdList += End;
setState(0);
}
}
if ( eventPattern.mouseMatch(
QwtEventPattern::MouseSelect2, (const QMouseEvent *)e) )
{
if (state() == 1)
cmdList += Append;
}
break;
}
case QEvent::MouseMove:
case QEvent::Wheel:
{
if ( state() != 0 )
cmdList += Move;
break;
}
case QEvent::KeyPress:
{
if ( eventPattern.keyMatch(
QwtEventPattern::KeySelect1, (const QKeyEvent *)e) )
{
if ( state() == 0 )
{
cmdList += Begin;
cmdList += Append;
cmdList += Append;
setState(1);
}
else
{
cmdList += End;
setState(0);
}
}
else if ( eventPattern.keyMatch(
QwtEventPattern::KeySelect2, (const QKeyEvent *)e) )
{
if ( state() == 1 )
cmdList += Append;
}
break;
}
default:
break;
}
return cmdList;
}
1.7.2