当前位置: 首页>>代码示例>>C++>>正文


C++ TOOL_EVENT::IsAction方法代码示例

本文整理汇总了C++中TOOL_EVENT::IsAction方法的典型用法代码示例。如果您正苦于以下问题:C++ TOOL_EVENT::IsAction方法的具体用法?C++ TOOL_EVENT::IsAction怎么用?C++ TOOL_EVENT::IsAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TOOL_EVENT的用法示例。


在下文中一共展示了TOOL_EVENT::IsAction方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: handleCommonEvents

void LENGTH_TUNER_TOOL::handleCommonEvents( const TOOL_EVENT& aEvent )
{
    if( aEvent.IsAction( &ACT_RouterOptions ) )
    {
        DIALOG_PNS_SETTINGS settingsDlg( m_frame, m_router->Settings() );

        if( settingsDlg.ShowModal() )
        {
            // FIXME: do we need an explicit update?
        }
    }

    PNS_MEANDER_PLACER_BASE* placer = static_cast<PNS_MEANDER_PLACER_BASE*>( m_router->Placer() );

    if( !placer )
        return;

    if( aEvent.IsAction( &ACT_Settings ) )
    {
        PNS_MEANDER_SETTINGS settings = placer->MeanderSettings();
        DIALOG_PNS_LENGTH_TUNING_SETTINGS settingsDlg( m_frame, settings, m_router->Mode() );

        if( settingsDlg.ShowModal() )
        {
            placer->UpdateSettings( settings );
        }

        m_savedMeanderSettings = placer->MeanderSettings();
    }
}
开发者ID:BTR1,项目名称:kicad-source-mirror,代码行数:30,代码来源:length_tuner_tool.cpp

示例2: ZoneDisplayMode

int PCBNEW_CONTROL::ZoneDisplayMode( const TOOL_EVENT& aEvent )
{
    KIGFX::PCB_PAINTER* painter =
            static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
    KIGFX::PCB_RENDER_SETTINGS* settings =
            static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
    DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)m_frame->GetDisplayOptions();

    // Apply new display options to the GAL canvas
    if( aEvent.IsAction( &COMMON_ACTIONS::zoneDisplayEnable ) )
        displ_opts->m_DisplayZonesMode = 0;
    else if( aEvent.IsAction( &COMMON_ACTIONS::zoneDisplayDisable ) )
        displ_opts->m_DisplayZonesMode = 1;
    else if( aEvent.IsAction( &COMMON_ACTIONS::zoneDisplayOutlines ) )
        displ_opts->m_DisplayZonesMode = 2;
    else
        assert( false );

    settings->LoadDisplayOptions( displ_opts );

    BOARD* board = getModel<BOARD>();
    for( int i = 0; i < board->GetAreaCount(); ++i )
        board->GetArea( i )->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );

    m_frame->GetGalCanvas()->Refresh();

    return 0;
}
开发者ID:PatMart,项目名称:kicad-source-mirror,代码行数:28,代码来源:pcbnew_control.cpp

示例3: handleCommonEvents

void ROUTER_TOOL::handleCommonEvents( const TOOL_EVENT& aEvent )
{
#ifdef DEBUG
    if( aEvent.IsKeyPressed() )
    {
        switch( aEvent.KeyCode() )
        {
            case '0':
                TRACEn( 2, "saving drag/route log...\n" );
                m_router->DumpLog();
                break;
        }
    }
    else
#endif
    if( aEvent.IsAction( &ACT_RouterOptions ) )
    {
        DIALOG_PNS_SETTINGS settingsDlg( m_frame, m_router->Settings() );

        if( settingsDlg.ShowModal() )
        {
            // FIXME: do we need an explicit update?
        }
    }
    else if( aEvent.IsAction( &ACT_SetDpDimensions ) )
    {
        PNS_SIZES_SETTINGS sizes = m_router->Sizes();
        DIALOG_PNS_DIFF_PAIR_DIMENSIONS settingsDlg( m_frame, sizes );

        if( settingsDlg.ShowModal() )
        {
            m_router->UpdateSizes( sizes );
        }
    }
    else if( aEvent.IsAction( &ACT_CustomTrackWidth ) )
    {
        BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings();
        DIALOG_TRACK_VIA_SIZE sizeDlg( m_frame, bds );

        if( sizeDlg.ShowModal() )
        {
            bds.UseCustomTrackViaSize( true );
            m_toolMgr->RunAction( COMMON_ACTIONS::trackViaSizeChanged );
        }
    }

    else if( aEvent.IsAction( &COMMON_ACTIONS::trackViaSizeChanged ) )
    {

        PNS_SIZES_SETTINGS sizes( m_router->Sizes() );
        sizes.ImportCurrent( m_board->GetDesignSettings() );
        m_router->UpdateSizes( sizes );
    }
}
开发者ID:general231,项目名称:kicad-source-mirror,代码行数:54,代码来源:router_tool.cpp

示例4: ZoomInOutCenter

int PCBNEW_CONTROL::ZoomInOutCenter( const TOOL_EVENT& aEvent )
{
    KIGFX::VIEW* view = getView();
    double zoomScale = 1.0;

    if( aEvent.IsAction( &COMMON_ACTIONS::zoomInCenter ) )
        zoomScale = 1.3;
    else if( aEvent.IsAction( &COMMON_ACTIONS::zoomOutCenter ) )
        zoomScale = 0.7;

    view->SetScale( view->GetScale() * zoomScale );

    return 0;
}
开发者ID:PatMart,项目名称:kicad-source-mirror,代码行数:14,代码来源:pcbnew_control.cpp

示例5: ZoomInOut

int PCBNEW_CONTROL::ZoomInOut( const TOOL_EVENT& aEvent )
{
    KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
    double zoomScale = 1.0;

    if( aEvent.IsAction( &COMMON_ACTIONS::zoomIn ) )
        zoomScale = 1.3;
    else if( aEvent.IsAction( &COMMON_ACTIONS::zoomOut ) )
        zoomScale = 0.7;

    view->SetScale( view->GetScale() * zoomScale, getViewControls()->GetCursorPosition() );

    return 0;
}
开发者ID:hermixy,项目名称:kicad-source-mirror,代码行数:14,代码来源:pcbnew_control.cpp

示例6: Duplicate

int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
{
    bool increment = aEvent.IsAction( &COMMON_ACTIONS::duplicateIncrement );

    // first, check if we have a selection, or try to get one
    SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
    const SELECTION& selection = selTool->GetSelection();

    // Be sure that there is at least one item that we can modify
    if( !hoverSelection( selection ) )
        return 0;

    // we have a selection to work on now, so start the tool process

    PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();
    editFrame->OnModify();

    // prevent other tools making undo points while the duplicate is going on
    // so that if you cancel, you don't get a duplicate object hiding over
    // the original
    incUndoInhibit();

    if( m_editModules )
        editFrame->SaveCopyInUndoList( editFrame->GetBoard()->m_Modules, UR_MODEDIT );

    std::vector<BOARD_ITEM*> old_items;

    for( int i = 0; i < selection.Size(); ++i )
    {
        BOARD_ITEM* item = selection.Item<BOARD_ITEM>( i );

        if( item )
            old_items.push_back( item );
    }

    for( unsigned i = 0; i < old_items.size(); ++i )
    {
        BOARD_ITEM* item = old_items[i];

        // Unselect the item, so we won't pick it up again
        // Do this first, so a single-item duplicate will correctly call
        // SetCurItem and show the item properties
        m_toolMgr->RunAction( COMMON_ACTIONS::unselectItem, true, item );

        BOARD_ITEM* new_item = NULL;

        if( m_editModules )
            new_item = editFrame->GetBoard()->m_Modules->DuplicateAndAddItem( item, increment );
        else
        {
#if 0
            // @TODO: see if we allow zone duplication here
            // Duplicate zones is especially tricky (overlaping zones must be merged)
            // so zones are not duplicated
            if( item->Type() != PCB_ZONE_AREA_T )
#endif
                new_item = editFrame->GetBoard()->DuplicateAndAddItem( item, increment );
        }

        if( new_item )
        {
            if( new_item->Type() == PCB_MODULE_T )
            {
                static_cast<MODULE*>( new_item )->RunOnChildren( boost::bind( &KIGFX::VIEW::Add,
                        getView(), _1 ) );
            }

            editFrame->GetGalCanvas()->GetView()->Add( new_item );

            // Select the new item, so we can pick it up
            m_toolMgr->RunAction( COMMON_ACTIONS::selectItem, true, new_item );
        }
    }

    // record the new items as added
    if( !m_editModules )
        editFrame->SaveCopyInUndoList( selection.items, UR_NEW );

    editFrame->DisplayToolMsg( wxString::Format( _( "Duplicated %d item(s)" ),
                               (int) old_items.size() ) );

    // pick up the selected item(s) and start moving
    // this works well for "dropping" copies around
    TOOL_EVENT evt = COMMON_ACTIONS::editActivate.MakeEvent();
    Main( evt );

    // and re-enable undos
    decUndoInhibit();

    return 0;
}
开发者ID:OpenEE,项目名称:micad,代码行数:91,代码来源:edit_tool.cpp

示例7: IsRotateToolEvt

bool TOOL_EVT_UTILS::IsRotateToolEvt( const TOOL_EVENT& aEvt )
{
    return aEvt.IsAction( &PCB_ACTIONS::rotateCw )
            || aEvt.IsAction( &PCB_ACTIONS::rotateCcw );
}
开发者ID:AlexanderBrevig,项目名称:kicad-source-mirror,代码行数:5,代码来源:tool_event_utils.cpp

示例8: IsCancelInteractive

bool TOOL_EVT_UTILS::IsCancelInteractive( const TOOL_EVENT& aEvt )
{
    return aEvt.IsAction( &ACTIONS::cancelInteractive )
            || aEvt.IsActivate()
            || aEvt.IsCancel();
}
开发者ID:AlexanderBrevig,项目名称:kicad-source-mirror,代码行数:6,代码来源:tool_event_utils.cpp

示例9: DrawShape

int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
{
    // We might be running as the same shape in another co-routine.  Make sure that one
    // gets whacked.
    m_toolMgr->DeactivateTool();

    bool isDrawLine;
    bool isImmediate = false;

    if( aEvent.IsAction( &PL_ACTIONS::drawLine ) )
    {
        isDrawLine = true;
        m_frame->SetToolID( ID_PL_LINE_TOOL, wxCURSOR_PENCIL, _( "Draw line" ) );
    }
    else if( aEvent.IsAction( &PL_ACTIONS::drawRectangle ) )
    {
        isDrawLine = false;
        m_frame->SetToolID( ID_PL_RECTANGLE_TOOL, wxCURSOR_PENCIL, _( "Draw rectangle" ) );
    }
    else if( aEvent.IsAction( &PL_ACTIONS::addLine ) )
    {
        isDrawLine = true;
        isImmediate = true;
    }
    else if( aEvent.IsAction( &PL_ACTIONS::addRectangle ) )
    {
        isDrawLine = false;
        isImmediate = true;
    }
    else
        wxCHECK_MSG( false, 0, "Unknown action in PL_DRAWING_TOOLS::DrawShape()" );

    m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
    getViewControls()->ShowCursor( true );

    Activate();

    WS_DRAW_ITEM_BASE* item = nullptr;

    // Main loop: keep receiving events
    while( auto evt = Wait() )
    {
        VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );

        if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
        {
            m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );

            if( item )
            {
                item = nullptr;
                m_frame->RollbackFromUndo();

                if( !evt->IsActivate() && !isImmediate )
                    continue;
            }

            break;
        }

        else if( evt->IsClick( BUT_LEFT ) || ( isImmediate && !item ) )
        {
            if( !item ) // start drawing
            {
                m_frame->SaveCopyInUndoList();
                m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );

                WS_DATA_ITEM::WS_ITEM_TYPE dataType;

                if( isDrawLine )
                    dataType = WS_DATA_ITEM::WS_SEGMENT;
                else
                    dataType = WS_DATA_ITEM::WS_RECT;

                WS_DATA_ITEM* dataItem = m_frame->AddPageLayoutItem( dataType );
                dataItem->MoveToUi( (wxPoint) cursorPos );

                item = dataItem->GetDrawItems()[0];
                item->SetFlags( IS_NEW );
                m_selectionTool->AddItemToSel( item );
            }
            else    // finish drawing
            {
                item->ClearEditFlags();
                item = nullptr;

                m_frame->OnModify();

                if( isImmediate )
                {
                    m_toolMgr->RunAction( ACTIONS::activatePointEditor );
                    break;
                }
            }
        }

        else if( evt->IsAction( &PL_ACTIONS::refreshPreview ) || evt->IsMotion() )
        {
            if( item )
            {
//.........这里部分代码省略.........
开发者ID:KiCad,项目名称:kicad-source-mirror,代码行数:101,代码来源:pl_drawing_tools.cpp

示例10: PlaceItem

int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
{
    bool isText;
    bool isImmediate = false;

    if( aEvent.IsAction( &PL_ACTIONS::placeText ) )
    {
        isText = true;
        m_frame->SetToolID( ID_PL_TEXT_TOOL, wxCURSOR_PENCIL, _( "Add text" ) );
    }
    else if( aEvent.IsAction( &PL_ACTIONS::placeImage ) )
    {
        isText = false;
        m_frame->SetToolID( ID_PL_IMAGE_TOOL, wxCURSOR_PENCIL, _( "Add image" ) );
    }
    else if( aEvent.IsAction( & PL_ACTIONS::addText ) )
    {
        isText = true;
        isImmediate = true;
    }
    else if( aEvent.IsAction( & PL_ACTIONS::addImage ) )
    {
        isText = false;
        isImmediate = true;
    }
    else
        wxCHECK_MSG( false, 0, "Unknown action in PL_DRAWING_TOOLS::PlaceItem()" );

    VECTOR2I           cursorPos;
    WS_DRAW_ITEM_BASE* item = nullptr;

    m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
    getViewControls()->ShowCursor( true );

    Activate();

    // Main loop: keep receiving events
    while( OPT_TOOL_EVENT evt = Wait() )
    {
        cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );

        if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
        {
            if( item )
            {
                m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
                delete item;
                item = nullptr;

                // There's nothing to roll-back, but we still need to pop the undo stack
                m_frame->RollbackFromUndo();

                if( !evt->IsActivate() && !isImmediate )
                    continue;
            }

            break;
        }

        else if( evt->IsClick( BUT_LEFT ) || ( isImmediate && !item ) )
        {
            // First click creates...
            if( !item )
            {
                m_frame->SaveCopyInUndoList();

                m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );

                WS_DATA_ITEM* dataItem;
                dataItem = m_frame->AddPageLayoutItem( isText ? WS_DATA_ITEM::WS_TEXT
                                                              : WS_DATA_ITEM::WS_BITMAP );
                item = dataItem->GetDrawItems()[0];
                item->SetFlags( IS_NEW | IS_MOVED );
                m_selectionTool->AddItemToSel( item );
            }

            // ... and second click places:
            else
            {
                item->GetPeer()->MoveStartPointToUi( (wxPoint) cursorPos );
                item->SetPosition( item->GetPeer()->GetStartPosUi( 0 ) );
                item->ClearEditFlags();
                getView()->Update( item );

                item = nullptr;

                m_frame->OnModify();

                if( isImmediate )
                    break;
            }
        }
        else if( evt->IsClick( BUT_RIGHT ) )
        {
            // Warp after context menu only if dragging...
            if( !item )
                m_toolMgr->VetoContextMenuMouseWarp();

            m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
        }
//.........这里部分代码省略.........
开发者ID:KiCad,项目名称:kicad-source-mirror,代码行数:101,代码来源:pl_drawing_tools.cpp

示例11: Duplicate

int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
{
    // Note: original items are no more modified.

    bool increment = aEvent.IsAction( &COMMON_ACTIONS::duplicateIncrement );

    // first, check if we have a selection, or try to get one
    SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
    const SELECTION& selection = selTool->GetSelection();

    // Be sure that there is at least one item that we can modify
    if( !hoverSelection() )
        return 0;

    // we have a selection to work on now, so start the tool process
    PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();

    std::vector<BOARD_ITEM*> old_items;

    for( int i = 0; i < selection.Size(); ++i )
    {
        BOARD_ITEM* item = selection.Item<BOARD_ITEM>( i );

        if( item )
            old_items.push_back( item );
    }

    for( unsigned i = 0; i < old_items.size(); ++i )
    {
        BOARD_ITEM* item = old_items[i];

        // Unselect the item, so we won't pick it up again
        // Do this first, so a single-item duplicate will correctly call
        // SetCurItem and show the item properties
        m_toolMgr->RunAction( COMMON_ACTIONS::unselectItem, true, item );

        BOARD_ITEM* new_item = NULL;

        if( m_editModules )
            new_item = editFrame->GetBoard()->m_Modules->Duplicate( item, increment );
        else
        {
#if 0
            // @TODO: see if we allow zone duplication here
            // Duplicate zones is especially tricky (overlaping zones must be merged)
            // so zones are not duplicated
            if( item->Type() != PCB_ZONE_AREA_T )
#endif
            new_item = editFrame->GetBoard()->Duplicate( item );
        }

        if( new_item )
        {
            m_commit->Add( new_item );

            // Select the new item, so we can pick it up
            m_toolMgr->RunAction( COMMON_ACTIONS::selectItem, true, new_item );
        }
    }

    // record the new items as added
    if( !selection.Empty() )
    {
        editFrame->DisplayToolMsg( wxString::Format( _( "Duplicated %d item(s)" ),
                (int) old_items.size() ) );

        // If items were duplicated, pick them up
        // this works well for "dropping" copies around and pushes the commit
        TOOL_EVENT evt = COMMON_ACTIONS::editActivate.MakeEvent();
        Main( evt );
    }

    return 0;
};
开发者ID:nikgul,项目名称:kicad-source-mirror,代码行数:74,代码来源:edit_tool.cpp


注:本文中的TOOL_EVENT::IsAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。