Пример #1
0
/**
 * Function SelectCurrentFootprint
 * Selects the current footprint name and display it
 */
void FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint( wxCommandEvent& event )
{
    wxString libname = m_libraryName + wxT(".") + LegacyFootprintLibPathExtension;
    MODULE* oldmodule = GetBoard()->m_Modules;
    MODULE * module = Load_Module_From_Library( libname, false );
    if( module )
    {
        module->SetPosition( wxPoint( 0, 0 ) );

        // Only one fotprint allowed: remove the previous footprint (if exists)
        if( oldmodule )
        {
            GetBoard()->Remove( oldmodule );
            delete oldmodule;
        }
        m_footprintName = module->GetLibRef();
        module->ClearFlags();
        SetCurItem( NULL );

        Zoom_Automatique( false );
        m_canvas->Refresh( );
        Update3D_Frame();
        m_FootprintList->SetStringSelection( m_footprintName );
   }
}
Пример #2
0
void WinEDA_PcbFrame::OnLeftClick(wxDC * DC, const wxPoint& MousePos)
/********************************************************************/
/* Traite les commandes declenchée par le bouton gauche de la souris,
	quand un outil est deja selectionné
*/
{
    EDA_BaseStruct * DrawStruct = CURRENT_ITEM;

    if ( (m_ID_current_state == 0) || ( DrawStruct && DrawStruct->m_Flags ))
    {
        DrawPanel->m_AutoPAN_Request = FALSE;
        if ( DrawStruct && DrawStruct->m_Flags ) // Commande "POPUP" en cours
        {
            switch (DrawStruct->m_StructType )
            {
            case TYPETRACK:
            case TYPEVIA:
                if ( CURRENT_ITEM->m_Flags & IS_DRAGGED )
                {
                    PlaceDraggedTrackSegment((TRACK *)DrawStruct, DC);
                    return;
                }
                break;

            case TYPETEXTE:
                Place_Texte_Pcb((TEXTE_PCB *)DrawStruct, DC);
                return;
                break;

            case TYPETEXTEMODULE:
                PlaceTexteModule( (TEXTE_MODULE *) DrawStruct, DC);
                return;
                break;

            case TYPEPAD:
                PlacePad((D_PAD *)DrawStruct, DC);
                return;
                break;

            case TYPEMODULE:
                Place_Module((MODULE *)DrawStruct, DC);
                return;
                break;

            case TYPEMIRE:
                Place_Mire((MIREPCB *)DrawStruct, DC);
                return;
                break;

            case TYPEDRAWSEGMENT:
                if (m_ID_current_state == 0)
                {
                    Place_DrawItem( (DRAWSEGMENT * )DrawStruct, DC);
                    return;
                }
                break;

            default:
                if (m_ID_current_state == 0)
                {
                    DisplayError(this,
                                 wxT("WinEDA_PcbFrame::OnLeftClick() err: m_Flags != 0") );
                    return;
                }
            }
        }
        else
        {
            DrawStruct = PcbGeneralLocateAndDisplay();
        }
    }

    switch ( m_ID_current_state )
    {
    case ID_MAIN_MENUBAR:
    case 0:
        break;

    case ID_NO_SELECT_BUTT:
        break;


    case ID_PCB_MUWAVE_TOOL_SELF_CMD:
    case ID_PCB_MUWAVE_TOOL_GAP_CMD:
    case ID_PCB_MUWAVE_TOOL_STUB_CMD:
    case ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD:
    case ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD:
        MuWaveCommand(DC, MousePos);
        break;


    case ID_PCB_HIGHLIGHT_BUTT:
    {
        int netcode = Select_High_Light(DC);
        if ( netcode < 0 ) Affiche_Infos_Status_Pcb(this);
        else Affiche_Infos_Equipot(netcode, this);
    }
    break;

    case ID_PCB_SHOW_1_RATSNEST_BUTT:
        DrawStruct = PcbGeneralLocateAndDisplay();
        Show_1_Ratsnest(DrawStruct, DC);
        break;

    case ID_PCB_MIRE_BUTT:
        if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
        {
            GetScreen()->m_CurrentItem = Create_Mire( DC );
            DrawPanel->MouseToCursorSchema();
        }
        else if (DrawStruct->m_StructType == TYPEMIRE )
        {
            Place_Mire((MIREPCB *)DrawStruct, DC);
        }
        else DisplayError(this, wxT("Internal err: Struct not TYPEMIRE"));
        break;

    case ID_PCB_CIRCLE_BUTT:
    case ID_PCB_ARC_BUTT:
    case ID_LINE_COMMENT_BUTT:
    {
        int shape = S_SEGMENT;
        if ( m_ID_current_state == ID_PCB_CIRCLE_BUTT) shape = S_CIRCLE;
        if ( m_ID_current_state == ID_PCB_ARC_BUTT) shape = S_ARC;

        if ( GetScreen()->m_Active_Layer <= CMP_N )
        {
            DisplayError(this, _("Graphic not autorized on Copper layers"));
            break;
        }
        if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
        {
            GetScreen()->m_CurrentItem = DrawStruct =
                                             Begin_DrawSegment(NULL, shape, DC);
            DrawPanel->m_AutoPAN_Request = TRUE;
        }
        else if (DrawStruct &&
                 (DrawStruct->m_StructType == TYPEDRAWSEGMENT) &&
                 (DrawStruct->m_Flags & IS_NEW) )
        {
            GetScreen()->m_CurrentItem = DrawStruct =
                                             Begin_DrawSegment((DRAWSEGMENT *)DrawStruct, shape, DC);
            DrawPanel->m_AutoPAN_Request = TRUE;
        }
        break;
    }

    case ID_TRACK_BUTT:
        if ( GetScreen()->m_Active_Layer > CMP_N )
        {
            DisplayError(this, _("Tracks on Copper layers only "));
            break;
        }

        if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
        {
            GetScreen()->m_CurrentItem = DrawStruct =
                                             Begin_Route(NULL, DC);
            if ( DrawStruct ) DrawPanel->m_AutoPAN_Request = TRUE;
        }
        else if (DrawStruct &&
//					(DrawStruct->m_StructType == TYPETRACK) &&
                 (DrawStruct->m_Flags & IS_NEW) )
        {
            TRACK * track = Begin_Route((TRACK *) DrawStruct, DC);
            if ( track )	// c'est a dire si OK
                GetScreen()->m_CurrentItem = DrawStruct = track;
            DrawPanel->m_AutoPAN_Request = TRUE;
        }
        break;


    case ID_PCB_ZONES_BUTT:
        if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
        {
            GetScreen()->m_CurrentItem = DrawStruct =
                                             Begin_Zone();
        }
        else if (DrawStruct &&
                 (DrawStruct->m_StructType == TYPEEDGEZONE) &&
                 (DrawStruct->m_Flags & IS_NEW) )
        {
            GetScreen()->m_CurrentItem = DrawStruct =
                                             Begin_Zone();
        }
        else DisplayError(this, wxT("Edit: zone internal error"));
        break;

    case ID_TEXT_COMMENT_BUTT:
        if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
        {
            GetScreen()->m_CurrentItem = Create_Texte_Pcb( DC );
            DrawPanel->MouseToCursorSchema();
            DrawPanel->m_AutoPAN_Request = TRUE;
        }
        else if (DrawStruct->m_StructType == TYPETEXTE )
        {
            Place_Texte_Pcb((TEXTE_PCB *)DrawStruct, DC);
            DrawPanel->m_AutoPAN_Request = FALSE;
        }
        else DisplayError(this, wxT("Internal err: Struct not TYPETEXTE"));
        break;

    case ID_COMPONENT_BUTT:
        if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
        {
            DrawPanel->MouseToCursorSchema();
            GetScreen()->m_CurrentItem = DrawStruct =
                                             Load_Module_From_Library(wxEmptyString, DC);
            if ( DrawStruct )
                StartMove_Module((MODULE *)DrawStruct, DC);
        }
        else if (DrawStruct->m_StructType == TYPEMODULE )
        {
            Place_Module((MODULE *)DrawStruct, DC);
            DrawPanel->m_AutoPAN_Request = FALSE;
        }
        else DisplayError(this, wxT("Internal err: Struct not TYPEMODULE"));
        break;

    case ID_PCB_COTATION_BUTT:
        if ( GetScreen()->m_Active_Layer <= CMP_N )
        {
            DisplayError(this, _("Cotation not autorized on Copper layers"));
            break;
        }
        if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
        {
            GetScreen()->m_CurrentItem = DrawStruct =
                                             Begin_Cotation(NULL, DC);
            DrawPanel->m_AutoPAN_Request = TRUE;
        }
        else if (DrawStruct &&
                 (DrawStruct->m_StructType == TYPECOTATION) &&
                 (DrawStruct->m_Flags & IS_NEW) )
        {
            GetScreen()->m_CurrentItem = DrawStruct =
                                             Begin_Cotation((COTATION * )DrawStruct, DC);
            DrawPanel->m_AutoPAN_Request = TRUE;
        }
        else DisplayError(this, wxT("Internal err: Struct not COTATION"));
        break;

    case ID_PCB_DELETE_ITEM_BUTT:
        if ( !DrawStruct || (DrawStruct->m_Flags == 0) )
        {
            DrawStruct = PcbGeneralLocateAndDisplay();
            if ( DrawStruct && (DrawStruct->m_Flags == 0) )
            {
                RemoveStruct(DrawStruct, DC);
                GetScreen()->m_CurrentItem = DrawStruct = NULL;
            }
        }
        break;

    case ID_PCB_PLACE_OFFSET_COORD_BUTT:
        GetScreen()->Trace_Curseur(DrawPanel, DC);
        DrawPanel->m_Draw_Auxiliary_Axe(DC, GR_XOR);
        m_Auxiliary_Axe_Position = GetScreen()->m_Curseur;
        DrawPanel->m_Draw_Auxiliary_Axe( DC, GR_COPY);
        GetScreen()->Trace_Curseur(DrawPanel, DC);
        break;

    default :
        DrawPanel->SetCursor(wxCURSOR_ARROW);
        DisplayError(this, wxT("WinEDA_PcbFrame::OnLeftClick() id error"));
        SetToolID(0, wxCURSOR_ARROW,wxEmptyString);
        break;
    }
}
Пример #3
0
void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
    int        id = event.GetId();
    wxPoint    pos;
    bool       redraw = false;

    INSTALL_UNBUFFERED_DC( dc, m_canvas );

    wxGetMousePosition( &pos.x, &pos.y );

    pos.y += 20;

    switch( id )
    {
    case wxID_CUT:
    case wxID_COPY:
    case ID_TOOLBARH_PCB_SELECT_LAYER:
    case ID_MODEDIT_PAD_SETTINGS:
    case ID_PCB_USER_GRID_SETUP:
    case ID_POPUP_PCB_ROTATE_TEXTEPCB:
    case ID_POPUP_PCB_EDIT_TEXTEPCB:
    case ID_POPUP_PCB_ROTATE_TEXTMODULE:
    case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE:
    case ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE:
    case ID_POPUP_PCB_EDIT_TEXTMODULE:
    case ID_POPUP_PCB_IMPORT_PAD_SETTINGS:
    case ID_POPUP_PCB_EXPORT_PAD_SETTINGS:
    case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS:
    case ID_POPUP_PCB_STOP_CURRENT_DRAWING:
    case ID_POPUP_MODEDIT_EDIT_BODY_ITEM:
    case ID_POPUP_MODEDIT_EDIT_WIDTH_CURRENT_EDGE:
    case ID_POPUP_MODEDIT_EDIT_WIDTH_ALL_EDGE:
    case ID_POPUP_MODEDIT_EDIT_LAYER_CURRENT_EDGE:
    case ID_POPUP_MODEDIT_EDIT_LAYER_ALL_EDGE:
    case ID_POPUP_MODEDIT_ENTER_EDGE_WIDTH:
    case ID_POPUP_PCB_DELETE_EDGE:
    case ID_POPUP_PCB_DELETE_TEXTMODULE:
    case ID_POPUP_PCB_DELETE_PAD:
    case ID_POPUP_DELETE_BLOCK:
    case ID_POPUP_PLACE_BLOCK:
    case ID_POPUP_ZOOM_BLOCK:
    case ID_POPUP_MIRROR_X_BLOCK:
    case ID_POPUP_ROTATE_BLOCK:
    case ID_POPUP_COPY_BLOCK:
        break;

    case ID_POPUP_CANCEL_CURRENT_COMMAND:
    default:
        if( m_canvas->IsMouseCaptured() )
        {
            //  for all other commands: stop the move in progress
            m_canvas->CallEndMouseCapture( &dc );
        }

        if( id != ID_POPUP_CANCEL_CURRENT_COMMAND )
            SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString );

        break;
    }

    switch( id )
    {
    case ID_EXIT:
        Close( true );
        break;

    case ID_MODEDIT_SELECT_CURRENT_LIB:
        Select_Active_Library();
        break;

    case ID_OPEN_MODULE_VIEWER:
        {
            FOOTPRINT_VIEWER_FRAME * viewer = FOOTPRINT_VIEWER_FRAME::GetActiveFootprintViewer();
            if( viewer == NULL )
            {
                viewer = new FOOTPRINT_VIEWER_FRAME( this, NULL );
                viewer->Show( true );
                viewer->Zoom_Automatique( false );
            }
            else
            {
                if( viewer->IsIconized() )
                     viewer->Iconize( false );

                viewer->Raise();

                // Raising the window does not set the focus on Linux.  This should work on
                // any platform.
                if( wxWindow::FindFocus() != viewer )
                    viewer->SetFocus();
            }
        }
        break;

    case ID_MODEDIT_DELETE_PART:
        DeleteModuleFromCurrentLibrary();
        break;

    case ID_MODEDIT_NEW_MODULE:
        {
            Clear_Pcb( true );
            GetScreen()->ClearUndoRedoList();
            SetCurItem( NULL );
            GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) );

            MODULE* module = Create_1_Module( wxEmptyString );

            if( module )        // i.e. if create module command not aborted
            {
                // Initialize data relative to nets and netclasses (for a new
                // module the defaults are used)
                // This is mandatory to handle and draw pads
                GetBoard()->BuildListOfNets();
                redraw = true;
                module->SetPosition( wxPoint( 0, 0 ) );

                if( GetBoard()->m_Modules )
                    GetBoard()->m_Modules->ClearFlags();

                Zoom_Automatique( false );
            }
        }
        break;

    case ID_MODEDIT_NEW_MODULE_FROM_WIZARD:
        {
            Clear_Pcb( true );
            GetScreen()->ClearUndoRedoList();
            SetCurItem( NULL );
            GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) );

            wxSemaphore semaphore( 0, 1 );
            FOOTPRINT_WIZARD_FRAME *wizard = new FOOTPRINT_WIZARD_FRAME( this, &semaphore,
                                KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT );
            wizard->Show( true );
            wizard->Zoom_Automatique( false );

            while( semaphore.TryWait() == wxSEMA_BUSY ) // Wait for viewer closing event
            {
                wxYield();
                wxMilliSleep( 50 );
            }

            MODULE* module = wizard->GetBuiltFootprint();

            if( module )        // i.e. if create module command not aborted
            {
                /* Here we should make a copy of the object before adding to board*/
                module->SetParent( (EDA_ITEM*)GetBoard() );
                GetBoard()->m_Modules.Append( module );

                // Initialize data relative to nets and netclasses (for a new
                // module the defaults are used)
                // This is mandatory to handle and draw pads
                GetBoard()->BuildListOfNets();
                redraw = true;
                module->SetPosition( wxPoint( 0, 0 ) );

                if( GetBoard()->m_Modules )
                    GetBoard()->m_Modules->ClearFlags();


            }

            wizard->Destroy();
        }
        break;

    case ID_MODEDIT_SAVE_LIBMODULE:
        if( GetBoard()->m_Modules && getLibPath() != wxEmptyString )
        {
            Save_Module_In_Library( getLibPath(), GetBoard()->m_Modules, true, true );
            GetScreen()->ClrModify();
        }
        break;

    case ID_MODEDIT_INSERT_MODULE_IN_BOARD:
    case ID_MODEDIT_UPDATE_MODULE_IN_BOARD:
        {
            // update module in the current board,
            // not just add it to the board with total disregard for the netlist...
            PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) GetParent();
            BOARD*          mainpcb  = pcbframe->GetBoard();
            MODULE*         source_module  = NULL;
            MODULE*         module_in_edit = GetBoard()->m_Modules;

            // Search the old module (source) if exists
            // Because this source could be deleted when editing the main board...
            if( module_in_edit->m_Link )        // this is not a new module ...
            {
                source_module = mainpcb->m_Modules;

                for( ; source_module != NULL; source_module = (MODULE*) source_module->Next() )
                {
                    if( module_in_edit->m_Link == source_module->GetTimeStamp() )
                        break;
                }
            }

            if( ( source_module == NULL )
                && ( id == ID_MODEDIT_UPDATE_MODULE_IN_BOARD ) ) // source not found
            {
                wxString msg;
                msg.Printf( _( "Unable to find the footprint source on the main board" ) );
                msg << _( "\nCannot update the footprint" );
                DisplayError( this, msg );
                break;
            }

            if( ( source_module != NULL )
                && ( id == ID_MODEDIT_INSERT_MODULE_IN_BOARD ) ) // source not found
            {
                wxString msg;
                msg.Printf( _( "A footprint source was found on the main board" ) );
                msg << _( "\nCannot insert this footprint" );
                DisplayError( this, msg );
                break;
            }

            // Create the "new" module
            MODULE* newmodule = new MODULE( *module_in_edit );
            newmodule->SetParent( mainpcb );
            newmodule->m_Link = 0;

            // Put the footprint in the main pcb linked list.
            mainpcb->Add( newmodule );

            if( source_module )         // this is an update command
            {
                // In the main board,
                // the new module replace the old module (pos, orient, ref, value
                // and connexions are kept)
                // and the source_module (old module) is deleted
                PICKED_ITEMS_LIST pickList;
                pcbframe->Exchange_Module( source_module, newmodule, &pickList );
                newmodule->SetTimeStamp( module_in_edit->m_Link );

                if( pickList.GetCount() )
                    pcbframe->SaveCopyInUndoList( pickList, UR_UNSPECIFIED );
            }
            else        // This is an insert command
            {
                wxPoint cursor_pos = pcbframe->GetScreen()->GetCrossHairPosition();
                pcbframe->GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) );
                pcbframe->PlaceModule( newmodule, NULL );
                pcbframe->GetScreen()->SetCrossHairPosition( cursor_pos );
                newmodule->SetTimeStamp( GetNewTimeStamp() );
                pcbframe->SaveCopyInUndoList( newmodule, UR_NEW );
            }

            newmodule->ClearFlags();
            GetScreen()->ClrModify();
            pcbframe->SetCurItem( NULL );
            mainpcb->m_Status_Pcb = 0;
        }
        break;

    case ID_MODEDIT_IMPORT_PART:
        if( ! Clear_Pcb( true ) )
            break;                  // //this command is aborted

        GetScreen()->ClearUndoRedoList();
        SetCurItem( NULL );
        GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) );
        Import_Module();
        redraw = true;

        if( GetBoard()->m_Modules )
            GetBoard()->m_Modules->ClearFlags();

        GetScreen()->ClrModify();
        Zoom_Automatique( false );

        if( m_Draw3DFrame )
            m_Draw3DFrame->NewDisplay();

        break;

    case ID_MODEDIT_EXPORT_PART:
        if( GetBoard()->m_Modules )
            Export_Module( GetBoard()->m_Modules );
        break;

    case ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART:
        if( GetBoard()->m_Modules )
        {
            // CreateModuleLibrary() only creates a new library, does not save footprint
            wxString libPath = CreateNewLibrary();
            if( libPath.size() )
                SaveCurrentModule( &libPath );
        }
        break;

    case ID_MODEDIT_SHEET_SET:
        break;

    case ID_MODEDIT_LOAD_MODULE:
        {
            wxString libPath = getLibPath();    // might be empty

            wxLogDebug( wxT( "Loading module from library " ) + libPath );

            GetScreen()->ClearUndoRedoList();
            SetCurItem( NULL );
            Clear_Pcb( true );
            GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) );
            Load_Module_From_Library( libPath, true );
            redraw = true;
        }

        if( GetBoard()->m_Modules )
            GetBoard()->m_Modules->ClearFlags();

        // if either m_Reference or m_Value are gone, reinstall them -
        // otherwise you cannot see what you are doing on board
        if( GetBoard() && GetBoard()->m_Modules )
        {
            TEXTE_MODULE* ref = GetBoard()->m_Modules->m_Reference;
            TEXTE_MODULE* val = GetBoard()->m_Modules->m_Value;

            if( val && ref )
            {
                ref->SetType( TEXT_is_REFERENCE );    // just in case ...

                if( ref->m_Text.Length() == 0 )
                    ref->m_Text = L"Ref**";

                val->SetType( TEXT_is_VALUE );        // just in case ...

                if( val->m_Text.Length() == 0 )
                    val->m_Text = L"Val**";
            }
        }

        GetScreen()->ClrModify();
        Zoom_Automatique( false );

        if( m_Draw3DFrame )
            m_Draw3DFrame->NewDisplay();

        break;

    case ID_MODEDIT_PAD_SETTINGS:
        InstallPadOptionsFrame( NULL );
        break;

    case ID_MODEDIT_CHECK:
        break;

    case ID_MODEDIT_EDIT_MODULE_PROPERTIES:
        if( GetBoard()->m_Modules )
        {
            SetCurItem( GetBoard()->m_Modules );
            DIALOG_MODULE_MODULE_EDITOR dialog( this, (MODULE*) GetScreen()-> GetCurItem() );
            int ret = dialog.ShowModal();
            GetScreen()->GetCurItem()->ClearFlags();

            if( ret > 0 )
                m_canvas->Refresh();
        }
        break;

    case ID_POPUP_CLOSE_CURRENT_TOOL:
        break;

    case ID_POPUP_CANCEL_CURRENT_COMMAND:
        break;

    case ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE:
        m_canvas->MoveCursorToCrossHair();
        Rotate_Module( NULL, (MODULE*) GetScreen()->GetCurItem(), 900, true );
        redraw = true;
        break;

    case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE:
        m_canvas->MoveCursorToCrossHair();
        Rotate_Module( NULL, (MODULE*) GetScreen()->GetCurItem(), -900, true );
        redraw = true;
        break;

    case ID_POPUP_PCB_EDIT_MODULE:
        {
            DIALOG_MODULE_MODULE_EDITOR dialog( this, (MODULE*) GetScreen()->GetCurItem() );
            int ret = dialog.ShowModal();
            GetScreen()->GetCurItem()->ClearFlags();
            GetScreen()->GetCurItem()->ClearFlags();
            m_canvas->MoveCursorToCrossHair();

            if( ret > 0 )
                m_canvas->Refresh();
        }
        break;

    case ID_POPUP_PCB_MOVE_PAD_REQUEST:
        m_canvas->MoveCursorToCrossHair();
        StartMovePad( (D_PAD*) GetScreen()->GetCurItem(), &dc, false );
        break;

    case ID_POPUP_PCB_EDIT_PAD:
        InstallPadOptionsFrame( (D_PAD*) GetScreen()->GetCurItem() );
        m_canvas->MoveCursorToCrossHair();
    break;

    case ID_POPUP_PCB_DELETE_PAD:
        SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
        DeletePad( (D_PAD*) GetScreen()->GetCurItem(), false );
        SetCurItem( NULL );
        m_canvas->MoveCursorToCrossHair();
        break;

    case ID_POPUP_PCB_IMPORT_PAD_SETTINGS:
        SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
        m_canvas->MoveCursorToCrossHair();
        Import_Pad_Settings( (D_PAD*) GetScreen()->GetCurItem(), true );
        break;

    case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS:
        SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
        // Calls the global change dialog:
        DlgGlobalChange_PadSettings( (D_PAD*) GetScreen()->GetCurItem() );
        m_canvas->MoveCursorToCrossHair();
        break;

    case ID_POPUP_PCB_EXPORT_PAD_SETTINGS:
        m_canvas->MoveCursorToCrossHair();
        Export_Pad_Settings( (D_PAD*) GetScreen()->GetCurItem() );
        break;

    case ID_POPUP_PCB_EDIT_TEXTMODULE:
        InstallTextModOptionsFrame( (TEXTE_MODULE*) GetScreen()->GetCurItem(), &dc );
        m_canvas->MoveCursorToCrossHair();
        break;

    case ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST:
        m_canvas->MoveCursorToCrossHair();
        StartMoveTexteModule( (TEXTE_MODULE*) GetScreen()->GetCurItem(), &dc );
        break;

    case ID_POPUP_PCB_ROTATE_TEXTMODULE:
        RotateTextModule( (TEXTE_MODULE*) GetScreen()->GetCurItem(), &dc );
        m_canvas->MoveCursorToCrossHair();
        break;

    case ID_POPUP_PCB_DELETE_TEXTMODULE:
        SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
        DeleteTextModule( (TEXTE_MODULE*) GetScreen()->GetCurItem() );
        SetCurItem( NULL );
        m_canvas->MoveCursorToCrossHair();
        break;

    case ID_POPUP_PCB_MOVE_EDGE:
        Start_Move_EdgeMod( (EDGE_MODULE*) GetScreen()->GetCurItem(), &dc );
        m_canvas->MoveCursorToCrossHair();
        break;

    case ID_POPUP_PCB_STOP_CURRENT_DRAWING:
        m_canvas->MoveCursorToCrossHair();

        if( GetScreen()->GetCurItem()->IsNew() )
        {
            End_Edge_Module( (EDGE_MODULE*) GetScreen()->GetCurItem() );
            SetCurItem( NULL );
        }
        break;

    case ID_POPUP_MODEDIT_ENTER_EDGE_WIDTH:
        {
            EDGE_MODULE* edge = NULL;
            if( GetScreen()->GetCurItem()
              && ( GetScreen()->GetCurItem()->Type() == PCB_MODULE_EDGE_T ) )
            {
                edge = (EDGE_MODULE*) GetScreen()->GetCurItem();
            }

            Enter_Edge_Width( edge );
            m_canvas->MoveCursorToCrossHair();

            if( edge )
                m_canvas->Refresh();
        }
        break;

    case  ID_POPUP_MODEDIT_EDIT_BODY_ITEM :
        m_canvas->MoveCursorToCrossHair();
        InstallFootprintBodyItemPropertiesDlg( (EDGE_MODULE*) GetScreen()->GetCurItem() );
        m_canvas->Refresh();
        break;

    case ID_POPUP_MODEDIT_EDIT_WIDTH_CURRENT_EDGE:
        m_canvas->MoveCursorToCrossHair();
        Edit_Edge_Width( (EDGE_MODULE*) GetScreen()->GetCurItem() );
        m_canvas->Refresh();
        break;

    case ID_POPUP_MODEDIT_EDIT_WIDTH_ALL_EDGE:
        m_canvas->MoveCursorToCrossHair();
        Edit_Edge_Width( NULL );
        m_canvas->Refresh();
        break;

    case ID_POPUP_MODEDIT_EDIT_LAYER_CURRENT_EDGE:
        m_canvas->MoveCursorToCrossHair();
        Edit_Edge_Layer( (EDGE_MODULE*) GetScreen()->GetCurItem() );
        m_canvas->Refresh();
        break;

    case ID_POPUP_MODEDIT_EDIT_LAYER_ALL_EDGE:
        m_canvas->MoveCursorToCrossHair();
        Edit_Edge_Layer( NULL );
        m_canvas->Refresh();
        break;

    case ID_POPUP_PCB_DELETE_EDGE:
        SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
        m_canvas->MoveCursorToCrossHair();
        RemoveStruct( GetScreen()->GetCurItem() );
        SetCurItem( NULL );
        break;

    case ID_MODEDIT_MODULE_ROTATE:
    case ID_MODEDIT_MODULE_MIRROR:
        SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
        Transform( (MODULE*) GetScreen()->GetCurItem(), id );
        redraw = true;
        break;

    case ID_PCB_DRAWINGS_WIDTHS_SETUP:
        InstallOptionsFrame( pos );
        break;

    case ID_PCB_PAD_SETUP:
        {
            BOARD_ITEM* item = GetCurItem();

            if( item )
            {
                if( item->Type() != PCB_PAD_T )
                    item = NULL;
            }

            InstallPadOptionsFrame( (D_PAD*) item );
        }
        break;

    case ID_PCB_USER_GRID_SETUP:
        InstallGridFrame( pos );
        break;

    case ID_POPUP_PLACE_BLOCK:
        GetScreen()->m_BlockLocate.SetCommand( BLOCK_MOVE );
        m_canvas->SetAutoPanRequest( false );
        HandleBlockPlace( &dc );
        break;

    case ID_POPUP_COPY_BLOCK:
        GetScreen()->m_BlockLocate.SetCommand( BLOCK_COPY );
        GetScreen()->m_BlockLocate.SetMessageBlock( this );
        m_canvas->SetAutoPanRequest( false );
        HandleBlockPlace( &dc );
        break;

    case ID_POPUP_ZOOM_BLOCK:
        GetScreen()->m_BlockLocate.SetCommand( BLOCK_ZOOM );
        GetScreen()->m_BlockLocate.SetMessageBlock( this );
        HandleBlockEnd( &dc );
        break;

    case ID_POPUP_DELETE_BLOCK:
        GetScreen()->m_BlockLocate.SetCommand( BLOCK_DELETE );
        GetScreen()->m_BlockLocate.SetMessageBlock( this );
        HandleBlockEnd( &dc );
        break;

    case ID_POPUP_ROTATE_BLOCK:
        GetScreen()->m_BlockLocate.SetCommand( BLOCK_ROTATE );
        GetScreen()->m_BlockLocate.SetMessageBlock( this );
        HandleBlockEnd( &dc );
        break;

    case ID_POPUP_MIRROR_X_BLOCK:
        GetScreen()->m_BlockLocate.SetCommand( BLOCK_MIRROR_X );
        GetScreen()->m_BlockLocate.SetMessageBlock( this );
        HandleBlockEnd( &dc );
        break;

    default:
        DisplayError( this,
                      wxT( "FOOTPRINT_EDIT_FRAME::Process_Special_Functions error" ) );
        break;
    }

    if( redraw )
        m_canvas->Refresh();
}