void FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng( wxCommandEvent& event )
{
    wxString   fullFileName;

    LIB_ID id = GetLoadedFPID();

    if( id.empty() )
    {
        wxMessageBox( _( "No footprint selected." ) );
        return;
    }

    wxFileName fn( id.GetLibItemName() );
    fn.SetExt( "png" );

    wxString projectPath = wxPathOnly( Prj().GetProjectFullName() );

    wxFileDialog dlg( this, _( "Footprint Image File Name" ), projectPath,
                      fn.GetFullName(), PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );

    if( dlg.ShowModal() == wxID_CANCEL || dlg.GetPath().IsEmpty() )
        return;

    // calling wxYield is mandatory under Linux, after closing the file selector dialog
    // to refresh the screen before creating the PNG or JPEG image from screen
    wxYield();
    saveCanvasImageToFile( dlg.GetPath() );
}
Ejemplo n.º 2
0
bool FOOTPRINT_EDIT_FRAME::RevertFootprint()
{
    if( GetScreen()->IsModify() && m_revertModule )
    {
        wxString msg = wxString::Format( _( "Revert \"%s\" to last version saved?" ),
                                         GetChars( GetLoadedFPID().GetLibItemName() ) );

        if( ConfirmRevertDialog( this, msg ) )
        {
            Clear_Pcb( false );
            AddModuleToBoard( (MODULE*) m_revertModule->Clone() );

            Zoom_Automatique( false );

            Update3DView();

            GetScreen()->ClearUndoRedoList();
            GetScreen()->ClrModify();

            updateView();
            m_canvas->Refresh();

            return true;
        }
    }

    return false;
}
void FOOTPRINT_EDIT_FRAME::retainLastFootprint()
{
    LIB_ID id = GetLoadedFPID();

    if( id.IsValid() )
    {
        Prj().SetRString( PROJECT::PCB_FOOTPRINT_EDITOR_NICKNAME, id.GetLibNickname() );
        Prj().SetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FPNAME, id.GetLibItemName() );
    }
}
LIB_ID FOOTPRINT_EDIT_FRAME::getTargetFPID() const
{
    LIB_ID   id = m_treePane->GetLibTree()->GetSelectedLibId();
    wxString nickname = id.GetLibNickname();

    if( nickname.IsEmpty() )
        return GetLoadedFPID();

    return id;
}
void FOOTPRINT_EDIT_FRAME::updateTitle()
{
    wxString title = _( "Footprint Editor" );
    LIB_ID   fpid = GetLoadedFPID();
    bool     writable = true;

    if( IsCurrentFPFromBoard() )
    {
        title += wxString::Format( wxT( " \u2014 %s [from %s.%s]" ),
                                   GetBoard()->m_Modules->GetReference(),
                                   Prj().GetProjectName(), PcbFileExtension );
    }
    else if( fpid.IsValid() )
    {
        try
        {
            writable = Prj().PcbFootprintLibs()->IsFootprintLibWritable( fpid.GetLibNickname() );
        }
        catch( const IO_ERROR& )
        {
            // best efforts...
        }

        // Note: don't used GetLoadedFPID(); footprint name may have been edited
        title += wxString::Format( wxT( " \u2014 %s %s" ),
                                   FROM_UTF8( GetBoard()->m_Modules->GetFPID().Format().c_str() ),
                                   writable ? wxString( wxEmptyString ) : _( "[Read Only]" ) );
    }
    else if( !fpid.GetLibItemName().empty() )
    {
        // Note: don't used GetLoadedFPID(); footprint name may have been edited
        title += wxString::Format( wxT( " \u2014 %s %s" ),
                                   FROM_UTF8( GetBoard()->m_Modules->GetFPID().GetLibItemName().c_str() ),
                                   _( "[Unsaved]" ) );
    }

    SetTitle( title );
}