Public Member Functions

QwtPickerClickRectMachine Class Reference

A state machine for rectangle selections. More...

#include <qwt_picker_machine.h>

Inheritance diagram for QwtPickerClickRectMachine:
Inheritance graph
[legend]
Collaboration diagram for QwtPickerClickRectMachine:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual CommandList transition (const QwtEventPattern &, const QEvent *)
 Transition.

Detailed Description

A state machine for rectangle selections.

Pressing QwtEventPattern::MouseSelect1 starts the selection, releasing it selects the first point. Pressing it again selects the second point and terminates the selection. Pressing QwtEventPattern::KeySelect1 also starts the selection, a second press selects the first point. A third one selects the second point and terminates the selection.

See also:
QwtEventPattern::MousePatternCode, QwtEventPattern::KeyPatternCode

Definition at line 109 of file qwt_picker_machine.h.


Member Function Documentation

QwtPickerMachine::CommandList QwtPickerClickRectMachine::transition ( const QwtEventPattern eventPattern,
const QEvent *  e 
) [virtual]

Transition.

Implements QwtPickerMachine.

Definition at line 145 of file qwt_picker_machine.cpp.

References QwtPickerMachine::Append, QwtPickerMachine::Begin, QwtPickerMachine::End, QwtEventPattern::keyMatch(), QwtEventPattern::KeySelect1, QwtEventPattern::mouseMatch(), QwtEventPattern::MouseSelect1, QwtPickerMachine::Move, QwtPickerMachine::setState(), and QwtPickerMachine::state().

{   
    QwtPickerMachine::CommandList cmdList;

    switch(e->type())
    {
        case QEvent::MouseButtonPress:
        {
            if ( eventPattern.mouseMatch(
                QwtEventPattern::MouseSelect1, (const QMouseEvent *)e) )
            {
                switch(state())
                {
                    case 0:
                    {   
                        cmdList += Begin;
                        cmdList += Append;
                        setState(1);
                        break;
                    }
                    case 1:
                    {
                        // Uh, strange we missed the MouseButtonRelease
                        break; 
                    }
                    default:
                    {
                        cmdList += End;
                        setState(0);
                    }
                }
            }
        }
        case QEvent::MouseMove:
        case QEvent::Wheel:
        {
            if ( state() != 0 )
                cmdList += Move;
            break;
        }
        case QEvent::MouseButtonRelease:
        {
            if ( eventPattern.mouseMatch(
                QwtEventPattern::MouseSelect1, (const QMouseEvent *)e) )
            {
                if ( state() == 1 )
                {
                    cmdList += Append;
                    setState(2);
                }
            }
            break;
        }
        case QEvent::KeyPress:
        {   
            if ( eventPattern.keyMatch(
                QwtEventPattern::KeySelect1, (const QKeyEvent *)e) )
            {
                if ( state() == 0 )
                {
                    cmdList += Begin;
                    cmdList += Append;
                    setState(1);
                }
                else
                {
                    if ( state() == 1 )
                    {
                        cmdList += Append;
                        setState(2);
                    }
                    else if ( state() == 2 )
                    {
                        cmdList += End;
                        setState(0);
                    }
                }
            }   
            break;
        }
        default:
            break;
    }

    return cmdList;
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines