int EDIT_TOOL::Remove( TOOL_EVENT& aEvent )
{
    const SELECTION& selection = m_selectionTool->GetSelection();

    if( !makeSelection( selection ) || m_selectionTool->CheckLock() )
    {
        setTransitions();

        return 0;
    }

    // Get a copy of the selected items set
    PICKED_ITEMS_LIST selectedItems = selection.items;
    PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();

    // As we are about to remove items, they have to be removed from the selection first
    m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );

    // Save them
    for( unsigned int i = 0; i < selectedItems.GetCount(); ++i )
        selectedItems.SetPickedItemStatus( UR_DELETED, i );

    editFrame->OnModify();
    editFrame->SaveCopyInUndoList( selectedItems, UR_DELETED );

    // And now remove
    for( unsigned int i = 0; i < selectedItems.GetCount(); ++i )
        remove( static_cast<BOARD_ITEM*>( selectedItems.GetPickedItem( i ) ) );

    getModel<BOARD>()->GetRatsnest()->Recalculate();

    setTransitions();

    return 0;
}
int EDIT_TOOL::Flip( TOOL_EVENT& aEvent )
{
    const SELECTION& selection = m_selectionTool->GetSelection();
    PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();

    // Shall the selection be cleared at the end?
    bool unselect = selection.Empty();

    if( !makeSelection( selection ) || m_selectionTool->CheckLock() )
    {
        setTransitions();

        return 0;
    }

    wxPoint flipPoint = getModificationPoint( selection );

    if( !m_dragging )   // If it is being dragged, then it is already saved with UR_CHANGED flag
    {
        editFrame->OnModify();
        editFrame->SaveCopyInUndoList( selection.items, UR_FLIPPED, flipPoint );
    }

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

        item->Flip( flipPoint );

        if( !m_dragging )
            item->ViewUpdate( KIGFX::VIEW_ITEM::LAYERS );
    }

    updateRatsnest( m_dragging );

    // Update dragging offset (distance between cursor and the first dragged item)
    m_offset = static_cast<BOARD_ITEM*>( selection.items.GetPickedItem( 0 ) )->GetPosition() -
                                         flipPoint;

    if( m_dragging )
        selection.group->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
    else
        getModel<BOARD>()->GetRatsnest()->Recalculate();

    if( unselect )
        m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );

    m_toolMgr->RunAction( COMMON_ACTIONS::pointEditorUpdate, true );
    setTransitions();

    return 0;
}
Example #3
0
int PCBNEW_CONTROL::GridPrev( TOOL_EVENT& aEvent )
{
    getEditFrame<PCB_EDIT_FRAME>()->SetPrevGrid();
    setTransitions();

    return 0;
}
int SELECTION_TOOL::SingleSelection( TOOL_EVENT& aEvent )
{
    selectSingle( getView()->ToWorld( getViewControls()->GetMousePosition() ) );
    setTransitions();

    return 0;
}
int SELECTION_TOOL::ClearSelection( TOOL_EVENT& aEvent )
{
    clearSelection();
    setTransitions();

    return 0;
}
Example #6
0
int PCBNEW_CONTROL::GridFast2( TOOL_EVENT& aEvent )
{
    getEditFrame<PCB_EDIT_FRAME>()->SetFastGrid2();
    setTransitions();

    return 0;
}
Example #7
0
int PCBNEW_CONTROL::HighContrastDec( TOOL_EVENT& aEvent )
{
    std::cout << __PRETTY_FUNCTION__ << std::endl;
    setTransitions();

    return 0;
}
bool EDIT_TOOL::Init()
{
    // Find the selection tool, so they can cooperate
    m_selectionTool = static_cast<SELECTION_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) );

    if( !m_selectionTool )
    {
        DisplayError( NULL, wxT( "pcbnew.InteractiveSelection tool is not available" ) );
        return false;
    }

    // Add context menu entries that are displayed when selection tool is active
    m_selectionTool->AddMenuItem( COMMON_ACTIONS::editActivate, SELECTION_CONDITIONS::NotEmpty );
    m_selectionTool->AddMenuItem( COMMON_ACTIONS::rotate, SELECTION_CONDITIONS::NotEmpty );
    m_selectionTool->AddMenuItem( COMMON_ACTIONS::flip, SELECTION_CONDITIONS::NotEmpty );
    m_selectionTool->AddMenuItem( COMMON_ACTIONS::remove, SELECTION_CONDITIONS::NotEmpty );
    m_selectionTool->AddMenuItem( COMMON_ACTIONS::properties, SELECTION_CONDITIONS::NotEmpty );

    m_offset.x = 0;
    m_offset.y = 0;

    setTransitions();

    return true;
}
Example #9
0
int PCBNEW_CONTROL::LayerBottom( TOOL_EVENT& aEvent )
{
    getEditFrame<PCB_EDIT_FRAME>()->SetActiveLayer( LAYER_N_BACK, true );
    getEditFrame<PCB_EDIT_FRAME>()->GetGalCanvas()->SetFocus();
    setTransitions();

    return 0;
}
Example #10
0
int PCBNEW_CONTROL::LayerInner6( TOOL_EVENT& aEvent )
{
    getEditFrame<PCB_EDIT_FRAME>()->SwitchLayer( NULL, LAYER_N_7 );
    getEditFrame<PCB_EDIT_FRAME>()->GetGalCanvas()->SetFocus();
    setTransitions();

    return 0;
}
Example #11
0
int PCBNEW_CONTROL::PadDisplayMode( TOOL_EVENT& aEvent )
{
    wxCommandEvent dummy;
    getEditFrame<PCB_EDIT_FRAME>()->OnTogglePadDrawMode( dummy );
    setTransitions();

    return 0;
}
Example #12
0
int PCBNEW_CONTROL::ShowHelp( TOOL_EVENT& aEvent )
{
    // TODO
    DisplayInfoMessage( m_frame, _( "Not implemented yet." ) );
    setTransitions();

    return 0;
}
Example #13
0
int PCBNEW_CONTROL::ZoomCenter( TOOL_EVENT& aEvent )
{
    KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
    view->SetCenter( getViewControls()->GetCursorPosition() );
    setTransitions();

    return 0;
}
Example #14
0
// Miscellaneous
int PCBNEW_CONTROL::ResetCoords( TOOL_EVENT& aEvent )
{
    VECTOR2I cursorPos = getViewControls()->GetCursorPosition();

    m_frame->GetScreen()->m_O_Curseur = wxPoint( cursorPos.x, cursorPos.y );
    m_frame->UpdateStatusBar();
    setTransitions();

    return 0;
}
int PCB_EDITOR_CONTROL::SelectionCrossProbe( const TOOL_EVENT& aEvent )
{
    SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
    const SELECTION& selection = selTool->GetSelection();

    if( selection.Size() == 1 )
        m_frame->SendMessageToEESCHEMA( selection.Item<BOARD_ITEM>( 0 ) );

    setTransitions();

    return 0;
}
Example #16
0
int PCBNEW_CONTROL::LayerNext( TOOL_EVENT& aEvent )
{
    PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
    LAYER_NUM layer = editFrame->GetActiveLayer();
    layer = ( layer + 1 ) % ( LAST_COPPER_LAYER + 1 );
    assert( IsCopperLayer( layer ) );

    editFrame->SwitchLayer( NULL, layer );
    editFrame->GetGalCanvas()->SetFocus();
    setTransitions();

    return 0;
}
bool PCB_EDITOR_CONTROL::Init()
{
    SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();

    if( selTool )
    {
        selTool->AddSubMenu( new ZONE_CONTEXT_MENU, wxT( "Zones" ),
                             SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) );
    }

    setTransitions();

    return true;
}
Example #18
0
int PCBNEW_CONTROL::SwitchUnits( TOOL_EVENT& aEvent )
{
    // TODO should not it be refactored to pcb_frame member function?
    wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );

    if( g_UserUnit == INCHES )
        evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_MM );
    else
        evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_INCH );

    m_frame->ProcessEvent( evt );
    setTransitions();

    return 0;
}
Example #19
0
int PCBNEW_CONTROL::HighContrastMode( 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() );

    DisplayOpt.ContrastModeDisplay = !DisplayOpt.ContrastModeDisplay;
    settings->LoadDisplayOptions( DisplayOpt );
    m_frame->SetHighContrastLayer( m_frame->GetActiveLayer() );

    setTransitions();

    return 0;
}
bool POINT_EDITOR::Init()
{
    // Find the selection tool, so they can cooperate
    m_selectionTool = static_cast<SELECTION_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) );

    if( !m_selectionTool )
    {
        DisplayError( NULL, wxT( "pcbnew.InteractiveSelection tool is not available" ) );
        return false;
    }

    setTransitions();

    return true;
}
Example #21
0
int PCBNEW_CONTROL::ViaSizeDec( TOOL_EVENT& aEvent )
{
    BOARD* board = getModel<BOARD>( PCB_T );
    int sizeIndex = board->GetViaSizeIndex() - 1;

    if( sizeIndex < 0 )
        sizeIndex = 0;

    board->SetViaSizeIndex( sizeIndex );

    wxUpdateUIEvent dummy;
    getEditFrame<PCB_EDIT_FRAME>()->OnUpdateSelectViaSize( dummy );
    setTransitions();

    return 0;
}
Example #22
0
int PCBNEW_CONTROL::TrackWidthDec( TOOL_EVENT& aEvent )
{
    BOARD* board = getModel<BOARD>( PCB_T );
    int widthIndex = board->GetTrackWidthIndex() - 1;

    if( widthIndex < 0 )
        widthIndex = 0;

    board->SetTrackWidthIndex( widthIndex );

    wxUpdateUIEvent dummy;
    getEditFrame<PCB_EDIT_FRAME>()->OnUpdateSelectTrackWidth( dummy );
    setTransitions();

    return 0;
}
int PCB_EDITOR_CONTROL::ZoneUnfillAll( const TOOL_EVENT& aEvent )
{
    BOARD* board = getModel<BOARD>();

    for( int i = 0; i < board->GetAreaCount(); ++i )
    {
        ZONE_CONTAINER* zone = board->GetArea( i );
        zone->SetIsFilled( false );
        zone->ClearFilledPolysList();
        zone->ViewUpdate();
    }

    setTransitions();

    return 0;
}
int PCB_EDITOR_CONTROL::ZoneFillAll( TOOL_EVENT& aEvent )
{
    BOARD* board = getModel<BOARD>();

    for( int i = 0; i < board->GetAreaCount(); ++i )
    {
        ZONE_CONTAINER* zone = board->GetArea( i );
        m_frame->Fill_Zone( zone );
        zone->SetIsFilled( true );
        zone->ViewUpdate();
    }

    setTransitions();

    return 0;
}
Example #25
0
int PCBNEW_CONTROL::ZoomInOutCenter( TOOL_EVENT& aEvent )
{
    KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
    KIGFX::GAL* gal = m_frame->GetGalCanvas()->GetGAL();

    if( aEvent.IsAction( &COMMON_ACTIONS::zoomInCenter ) )
        m_frame->SetPrevZoom();
    else if( aEvent.IsAction( &COMMON_ACTIONS::zoomOutCenter ) )
        m_frame->SetNextZoom();

    double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
    double zoom = 1.0 / ( zoomFactor * m_frame->GetZoom() );

    view->SetScale( zoom );
    setTransitions();

    return 0;
}
int PCB_EDITOR_CONTROL::TrackWidthDec( TOOL_EVENT& aEvent )
{
    BOARD* board = getModel<BOARD>();
    int widthIndex = board->GetDesignSettings().GetTrackWidthIndex() - 1;

    if( widthIndex < 0 )
        widthIndex = 0;

    board->GetDesignSettings().SetTrackWidthIndex( widthIndex );
    board->GetDesignSettings().UseCustomTrackViaSize( false );

    wxUpdateUIEvent dummy;
    m_frame->OnUpdateSelectTrackWidth( dummy );
    setTransitions();

    m_toolMgr->RunAction( COMMON_ACTIONS::trackViaSizeChanged );

    return 0;
}
int PCB_EDITOR_CONTROL::ZoneUnfill( TOOL_EVENT& aEvent )
{
    SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
    const SELECTION& selection = selTool->GetSelection();

    for( int i = 0; i < selection.Size(); ++i )
    {
        assert( selection.Item<BOARD_ITEM>( i )->Type() == PCB_ZONE_AREA_T );

        ZONE_CONTAINER* zone = selection.Item<ZONE_CONTAINER>( i );
        zone->SetIsFilled( false );
        zone->ClearFilledPolysList();
        zone->ViewUpdate();
    }

    setTransitions();

    return 0;
}
int PCB_EDITOR_CONTROL::ViaSizeInc( TOOL_EVENT& aEvent )
{
    BOARD* board = getModel<BOARD>();
    int sizeIndex = board->GetDesignSettings().GetViaSizeIndex() + 1;

    if( sizeIndex >= (int) board->GetDesignSettings().m_ViasDimensionsList.size() )
        sizeIndex = board->GetDesignSettings().m_ViasDimensionsList.size() - 1;

    board->GetDesignSettings().SetViaSizeIndex( sizeIndex );
    board->GetDesignSettings().UseCustomTrackViaSize( false );

    wxUpdateUIEvent dummy;
    m_frame->OnUpdateSelectViaSize( dummy );
    setTransitions();

    m_toolMgr->RunAction( COMMON_ACTIONS::trackViaSizeChanged );

    return 0;
}
void SELECTION_TOOL::Reset( RESET_REASON aReason )
{
    if( aReason == TOOL_BASE::MODEL_RELOAD )
        // Remove pointers to the selected items from containers
        // without changing their properties (as they are already deleted)
        m_selection.clear();
    else
        // Restore previous properties of selected items and remove them from containers
        clearSelection();

    m_frame = getEditFrame<PCB_BASE_FRAME>();
    m_locked = true;

    // Reinsert the VIEW_GROUP, in case it was removed from the VIEW
    getView()->Remove( m_selection.group );
    getView()->Add( m_selection.group );

    setTransitions();
}
Example #30
0
int PCBNEW_CONTROL::TrackDisplayMode( 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() );

    // Apply new display options to the GAL canvas
    DisplayOpt.DisplayPcbTrackFill = !DisplayOpt.DisplayPcbTrackFill;
    m_frame->m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
    settings->LoadDisplayOptions( DisplayOpt );

    BOARD* board = getModel<BOARD>( PCB_T );
    for( TRACK* track = board->m_Track; track; track = track->Next() )
        track->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );

    setTransitions();

    return 0;
}