Public Member Functions

QwtPickerPolygonMachine Class Reference

A state machine for polygon selections. More...

#include <qwt_picker_machine.h>

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

List of all members.

Public Member Functions

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

Detailed Description

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.

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

Definition at line 146 of file qwt_picker_machine.h.


Member Function Documentation

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;
}

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