Ignore:
Timestamp:
May 10, 2017, 3:20:54 PM (7 years ago)
Author:
stoecker
Message:

update qwt and qwtpolar, many QT5 fixes (unfinished)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/qwt/qwt_picker_machine.cpp

    r4271 r8127  
    9898//! Transition
    9999QList<QwtPickerMachine::Command> QwtPickerClickPointMachine::transition(
    100     const QwtEventPattern &eventPattern, const QEvent *e )
    101 {
    102     QList<QwtPickerMachine::Command> cmdList;
    103 
    104     switch ( e->type() )
     100    const QwtEventPattern &eventPattern, const QEvent *event )
     101{
     102    QList<QwtPickerMachine::Command> cmdList;
     103
     104    switch ( event->type() )
    105105    {
    106106        case QEvent::MouseButtonPress:
    107107        {
    108             if ( eventPattern.mouseMatch(
    109                 QwtEventPattern::MouseSelect1, ( const QMouseEvent * )e ) )
     108            if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1,
     109                static_cast<const QMouseEvent *>( event ) ) )
    110110            {
    111111                cmdList += Begin;
     
    117117        case QEvent::KeyPress:
    118118        {
    119             if ( eventPattern.keyMatch(
    120                 QwtEventPattern::KeySelect1, ( const QKeyEvent * )e ) )
    121             {
    122                 cmdList += Begin;
    123                 cmdList += Append;
    124                 cmdList += End;
     119            const QKeyEvent *keyEvent = static_cast<const QKeyEvent *> ( event );
     120            if ( eventPattern.keyMatch( QwtEventPattern::KeySelect1, keyEvent ) )
     121            {
     122                if ( !keyEvent->isAutoRepeat() )
     123                {
     124                    cmdList += Begin;
     125                    cmdList += Append;
     126                    cmdList += End;
     127                }
    125128            }
    126129            break;
     
    141144//! Transition
    142145QList<QwtPickerMachine::Command> QwtPickerDragPointMachine::transition(
    143     const QwtEventPattern &eventPattern, const QEvent *e )
    144 {
    145     QList<QwtPickerMachine::Command> cmdList;
    146 
    147     switch ( e->type() )
     146    const QwtEventPattern &eventPattern, const QEvent *event )
     147{
     148    QList<QwtPickerMachine::Command> cmdList;
     149
     150    switch ( event->type() )
    148151    {
    149152        case QEvent::MouseButtonPress:
    150153        {
    151             if ( eventPattern.mouseMatch(
    152                 QwtEventPattern::MouseSelect1, ( const QMouseEvent * )e ) )
     154            if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1,
     155                static_cast<const QMouseEvent *>( event ) ) )
    153156            {
    154157                if ( state() == 0 )
     
    179182        case QEvent::KeyPress:
    180183        {
    181             if ( eventPattern.keyMatch(
    182                 QwtEventPattern::KeySelect1, ( const QKeyEvent * )e ) )
    183             {
    184                 if ( state() == 0 )
    185                 {
    186                     cmdList += Begin;
    187                     cmdList += Append;
    188                     setState( 1 );
    189                 }
    190                 else
    191                 {
    192                     cmdList += End;
    193                     setState( 0 );
     184            const QKeyEvent *keyEvent = static_cast<const QKeyEvent *> ( event );
     185            if ( eventPattern.keyMatch( QwtEventPattern::KeySelect1, keyEvent ) )
     186            {
     187                if ( !keyEvent->isAutoRepeat() )
     188                {
     189                    if ( state() == 0 )
     190                    {
     191                        cmdList += Begin;
     192                        cmdList += Append;
     193                        setState( 1 );
     194                    }
     195                    else
     196                    {
     197                        cmdList += End;
     198                        setState( 0 );
     199                    }
    194200                }
    195201            }
     
    211217//! Transition
    212218QList<QwtPickerMachine::Command> QwtPickerClickRectMachine::transition(
    213     const QwtEventPattern &eventPattern, const QEvent *e )
    214 {
    215     QList<QwtPickerMachine::Command> cmdList;
    216 
    217     switch ( e->type() )
     219    const QwtEventPattern &eventPattern, const QEvent *event )
     220{
     221    QList<QwtPickerMachine::Command> cmdList;
     222
     223    switch ( event->type() )
    218224    {
    219225        case QEvent::MouseButtonPress:
    220226        {
    221             if ( eventPattern.mouseMatch(
    222                 QwtEventPattern::MouseSelect1, ( const QMouseEvent * )e ) )
     227            if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1,
     228                static_cast<const QMouseEvent *>( event ) ) )
    223229            {
    224230                switch ( state() )
     
    243249                }
    244250            }
     251            break;
    245252        }
    246253        case QEvent::MouseMove:
     
    253260        case QEvent::MouseButtonRelease:
    254261        {
    255             if ( eventPattern.mouseMatch(
    256                 QwtEventPattern::MouseSelect1, ( const QMouseEvent * )e ) )
     262            if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1,
     263                static_cast<const QMouseEvent *>( event ) ) )
    257264            {
    258265                if ( state() == 1 )
     
    266273        case QEvent::KeyPress:
    267274        {
    268             if ( eventPattern.keyMatch(
    269                 QwtEventPattern::KeySelect1, ( const QKeyEvent * )e ) )
     275            const QKeyEvent *keyEvent = static_cast<const QKeyEvent *> ( event );
     276            if ( eventPattern.keyMatch( QwtEventPattern::KeySelect1, keyEvent ) )
     277            {
     278                if ( !keyEvent->isAutoRepeat() )
     279                {
     280                    if ( state() == 0 )
     281                    {
     282                        cmdList += Begin;
     283                        cmdList += Append;
     284                        setState( 1 );
     285                    }
     286                    else
     287                    {
     288                        if ( state() == 1 )
     289                        {
     290                            cmdList += Append;
     291                            setState( 2 );
     292                        }
     293                        else if ( state() == 2 )
     294                        {
     295                            cmdList += End;
     296                            setState( 0 );
     297                        }
     298                    }
     299                }
     300            }
     301            break;
     302        }
     303        default:
     304            break;
     305    }
     306
     307    return cmdList;
     308}
     309
     310//! Constructor
     311QwtPickerDragRectMachine::QwtPickerDragRectMachine():
     312    QwtPickerMachine( RectSelection )
     313{
     314}
     315
     316//! Transition
     317QList<QwtPickerMachine::Command> QwtPickerDragRectMachine::transition(
     318    const QwtEventPattern &eventPattern, const QEvent *event )
     319{
     320    QList<QwtPickerMachine::Command> cmdList;
     321
     322    switch ( event->type() )
     323    {
     324        case QEvent::MouseButtonPress:
     325        {
     326            if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1,
     327                static_cast<const QMouseEvent *>( event ) ) )
    270328            {
    271329                if ( state() == 0 )
     
    273331                    cmdList += Begin;
    274332                    cmdList += Append;
     333                    cmdList += Append;
     334                    setState( 2 );
     335                }
     336            }
     337            break;
     338        }
     339        case QEvent::MouseMove:
     340        case QEvent::Wheel:
     341        {
     342            if ( state() != 0 )
     343                cmdList += Move;
     344            break;
     345        }
     346        case QEvent::MouseButtonRelease:
     347        {
     348            if ( state() == 2 )
     349            {
     350                cmdList += End;
     351                setState( 0 );
     352            }
     353            break;
     354        }
     355        case QEvent::KeyPress:
     356        {
     357            if ( eventPattern.keyMatch( QwtEventPattern::KeySelect1,
     358                static_cast<const QKeyEvent *> ( event ) ) )
     359            {
     360                if ( state() == 0 )
     361                {
     362                    cmdList += Begin;
     363                    cmdList += Append;
     364                    cmdList += Append;
     365                    setState( 2 );
     366                }
     367                else
     368                {
     369                    cmdList += End;
     370                    setState( 0 );
     371                }
     372            }
     373            break;
     374        }
     375        default:
     376            break;
     377    }
     378
     379    return cmdList;
     380}
     381
     382//! Constructor
     383QwtPickerPolygonMachine::QwtPickerPolygonMachine():
     384    QwtPickerMachine( PolygonSelection )
     385{
     386}
     387
     388//! Transition
     389QList<QwtPickerMachine::Command> QwtPickerPolygonMachine::transition(
     390    const QwtEventPattern &eventPattern, const QEvent *event )
     391{
     392    QList<QwtPickerMachine::Command> cmdList;
     393
     394    switch ( event->type() )
     395    {
     396        case QEvent::MouseButtonPress:
     397        {
     398            if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1,
     399                static_cast<const QMouseEvent *>( event ) ) )
     400            {
     401                if ( state() == 0 )
     402                {
     403                    cmdList += Begin;
     404                    cmdList += Append;
     405                    cmdList += Append;
    275406                    setState( 1 );
    276407                }
    277408                else
    278409                {
     410                    cmdList += Append;
     411                }
     412            }
     413            if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect2,
     414                static_cast<const QMouseEvent *>( event ) ) )
     415            {
     416                if ( state() == 1 )
     417                {
     418                    cmdList += End;
     419                    setState( 0 );
     420                }
     421            }
     422            break;
     423        }
     424        case QEvent::MouseMove:
     425        case QEvent::Wheel:
     426        {
     427            if ( state() != 0 )
     428                cmdList += Move;
     429            break;
     430        }
     431        case QEvent::KeyPress:
     432        {
     433            const QKeyEvent *keyEvent = static_cast<const QKeyEvent *> ( event );
     434            if ( eventPattern.keyMatch( QwtEventPattern::KeySelect1, keyEvent ) )
     435            {
     436                if ( !keyEvent->isAutoRepeat() )
     437                {
     438                    if ( state() == 0 )
     439                    {
     440                        cmdList += Begin;
     441                        cmdList += Append;
     442                        cmdList += Append;
     443                        setState( 1 );
     444                    }
     445                    else
     446                    {
     447                        cmdList += Append;
     448                    }
     449                }
     450            }
     451            else if ( eventPattern.keyMatch( QwtEventPattern::KeySelect2, keyEvent ) )
     452            {
     453                if ( !keyEvent->isAutoRepeat() )
     454                {
    279455                    if ( state() == 1 )
    280                     {
    281                         cmdList += Append;
    282                         setState( 2 );
    283                     }
    284                     else if ( state() == 2 )
    285456                    {
    286457                        cmdList += End;
     
    299470
    300471//! Constructor
    301 QwtPickerDragRectMachine::QwtPickerDragRectMachine():
    302     QwtPickerMachine( RectSelection )
    303 {
    304 }
    305 
    306 //! Transition
    307 QList<QwtPickerMachine::Command> QwtPickerDragRectMachine::transition(
    308     const QwtEventPattern &eventPattern, const QEvent *e )
    309 {
    310     QList<QwtPickerMachine::Command> cmdList;
    311 
    312     switch ( e->type() )
     472QwtPickerDragLineMachine::QwtPickerDragLineMachine():
     473    QwtPickerMachine( PolygonSelection )
     474{
     475}
     476
     477//! Transition
     478QList<QwtPickerMachine::Command> QwtPickerDragLineMachine::transition(
     479    const QwtEventPattern &eventPattern, const QEvent *event )
     480{
     481    QList<QwtPickerMachine::Command> cmdList;
     482
     483    switch( event->type() )
    313484    {
    314485        case QEvent::MouseButtonPress:
    315486        {
    316             if ( eventPattern.mouseMatch(
    317                 QwtEventPattern::MouseSelect1, ( const QMouseEvent * )e ) )
     487            if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1,
     488                static_cast<const QMouseEvent *>( event ) ) )
    318489            {
    319490                if ( state() == 0 )
     
    322493                    cmdList += Append;
    323494                    cmdList += Append;
    324                     setState( 2 );
     495                    setState( 1 );
     496                }
     497            }
     498            break;
     499        }
     500        case QEvent::KeyPress:
     501        {
     502            if ( eventPattern.keyMatch( QwtEventPattern::KeySelect1,
     503                static_cast<const QKeyEvent *> ( event ) ) )
     504            {
     505                if ( state() == 0 )
     506                {
     507                    cmdList += Begin;
     508                    cmdList += Append;
     509                    cmdList += Append;
     510                    setState( 1 );
     511                }
     512                else
     513                {
     514                    cmdList += End;
     515                    setState( 0 );
    325516                }
    326517            }
     
    332523            if ( state() != 0 )
    333524                cmdList += Move;
     525
    334526            break;
    335527        }
    336528        case QEvent::MouseButtonRelease:
    337529        {
    338             if ( state() == 2 )
     530            if ( state() != 0 )
    339531            {
    340532                cmdList += End;
    341533                setState( 0 );
    342534            }
    343             break;
    344         }
    345         case QEvent::KeyPress:
    346         {
    347             if ( eventPattern.keyMatch(
    348                 QwtEventPattern::KeySelect1, ( const QKeyEvent * )e ) )
    349             {
    350                 if ( state() == 0 )
    351                 {
    352                     cmdList += Begin;
    353                     cmdList += Append;
    354                     cmdList += Append;
    355                     setState( 2 );
    356                 }
    357                 else
    358                 {
    359                     cmdList += End;
    360                     setState( 0 );
    361                 }
    362             }
    363             break;
    364         }
    365         default:
    366             break;
    367     }
    368 
    369     return cmdList;
    370 }
    371 
    372 //! Constructor
    373 QwtPickerPolygonMachine::QwtPickerPolygonMachine():
    374     QwtPickerMachine( PolygonSelection )
    375 {
    376 }
    377 
    378 //! Transition
    379 QList<QwtPickerMachine::Command> QwtPickerPolygonMachine::transition(
    380     const QwtEventPattern &eventPattern, const QEvent *e )
    381 {
    382     QList<QwtPickerMachine::Command> cmdList;
    383 
    384     switch ( e->type() )
    385     {
    386         case QEvent::MouseButtonPress:
    387         {
    388             if ( eventPattern.mouseMatch(
    389                 QwtEventPattern::MouseSelect1, ( const QMouseEvent * )e ) )
    390             {
    391                 if ( state() == 0 )
    392                 {
    393                     cmdList += Begin;
    394                     cmdList += Append;
    395                     cmdList += Append;
    396                     setState( 1 );
    397                 }
    398                 else
    399                 {
    400                     cmdList += End;
    401                     setState( 0 );
    402                 }
    403             }
    404             if ( eventPattern.mouseMatch(
    405                 QwtEventPattern::MouseSelect2, ( const QMouseEvent * )e ) )
    406             {
    407                 if ( state() == 1 )
    408                     cmdList += Append;
    409             }
    410             break;
    411         }
    412         case QEvent::MouseMove:
    413         case QEvent::Wheel:
    414         {
    415             if ( state() != 0 )
    416                 cmdList += Move;
    417             break;
    418         }
    419         case QEvent::KeyPress:
    420         {
    421             if ( eventPattern.keyMatch(
    422                 QwtEventPattern::KeySelect1, ( const QKeyEvent * )e ) )
    423             {
    424                 if ( state() == 0 )
    425                 {
    426                     cmdList += Begin;
    427                     cmdList += Append;
    428                     cmdList += Append;
    429                     setState( 1 );
    430                 }
    431                 else
    432                 {
    433                     cmdList += End;
    434                     setState( 0 );
    435                 }
    436             }
    437             else if ( eventPattern.keyMatch(
    438                 QwtEventPattern::KeySelect2, ( const QKeyEvent * )e ) )
    439             {
    440                 if ( state() == 1 )
    441                     cmdList += Append;
    442             }
    443             break;
    444         }
    445         default:
    446             break;
    447     }
    448 
    449     return cmdList;
    450 }
     535        }
     536        default:
     537            break;
     538    }
     539
     540    return cmdList;
     541}
Note: See TracChangeset for help on using the changeset viewer.