Public Member Functions

QwtPickerDragRectMachine Class Reference

A state machine for rectangle selections. More...

#include <qwt_picker_machine.h>

Inheritance diagram for QwtPickerDragRectMachine:
Inheritance graph
[legend]
Collaboration diagram for QwtPickerDragRectMachine:
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 selects the first point, releasing it the second point. Pressing QwtEventPattern::KeySelect1 also selects the first point, a second press selects the second point and terminates the selection.

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

Definition at line 128 of file qwt_picker_machine.h.


Member Function Documentation

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

Transition.

Implements QwtPickerMachine.

Definition at line 234 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) )
            {
                if ( state() == 0 )
                {
                    cmdList += Begin;
                    cmdList += Append;
                    cmdList += Append;
                    setState(2);
                }
            }
            break;
        }
        case QEvent::MouseMove:
        case QEvent::Wheel:
        {
            if ( state() != 0 )
                cmdList += Move;
            break;
        }
        case QEvent::MouseButtonRelease:
        {
            if ( state() == 2 )
            {
                cmdList += End;
                setState(0);
            }
            break;
        }
        case QEvent::KeyPress:
        {
            if ( eventPattern.keyMatch(
                QwtEventPattern::KeySelect1, (const QKeyEvent *)e) )
            {
                if ( state() == 0 )
                {
                    cmdList += Begin;
                    cmdList += Append;
                    cmdList += Append;
                    setState(2);
                }
                else
                {
                    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