Пример #1
0
void KICAD_MANAGER_FRAME::RunEeschema( const wxString& aProjectSchematicFileName )
{
    KIWAY_PLAYER* frame = Kiway.Player( FRAME_SCH, false );

    // Please: note: DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers() calls
    // Kiway.Player( FRAME_SCH, true )
    // therefore, the schematic editor is sometimes running, but the schematic project
    // is not loaded, if the library editor was called, and the dialog field editor was used.
    // On linux, it happens the first time the schematic editor is launched, if
    // library editor was running, and the dialog field editor was open
    // On Windows, it happens always after the library editor was called,
    // and the dialog field editor was used
    if( !frame )
    {
        frame = Kiway.Player( FRAME_SCH, true );
    }

    if( !frame->IsShown() ) // the frame exists, (created by the dialog field editor)
                            // but no project loaded.
    {
        frame->OpenProjectFiles( std::vector<wxString>( 1, aProjectSchematicFileName ) );
        frame->Show( true );
    }

    // On Windows, Raise() does not bring the window on screen, when iconized or not shown
    // On linux, Raise() brings the window on screen, but this code works fine
    if( frame->IsIconized() )
        frame->Iconize( false );

    frame->Raise();
}
Пример #2
0
void PCB_EDIT_FRAME::OnUpdatePCBFromSch( wxCommandEvent& event )
{
    if( Kiface().IsSingle() )
    {
        DisplayError( this,  _( "Cannot update the PCB, because the Kicad is"
                                 " opened in stand-alone mode. In order to create/update"
                                 " PCBs from schematics, you need to launch Kicad shell"
                                 " and create a PCB project." ) );
        return;
    }
    else
    {
        KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, true );
        wxFileName schfn = Prj().AbsolutePath( Prj().GetProjectName() );

        schfn.SetExt( SchematicFileExtension );

        if( !frame->IsVisible() )
        {
            frame->OpenProjectFiles( std::vector<wxString>( 1, schfn.GetFullPath() ) );
            frame->Show( false );
        }

        Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_PCB_UPDATE_REQUEST, "", this );
    }
}
Пример #3
0
void KICAD_MANAGER_FRAME::RunPcbNew( const wxString& aProjectBoardFileName )
{
    KIWAY_PLAYER* frame;

    try
    {
        frame = Kiway().Player( FRAME_PCB, true );
    }
    catch( const IO_ERROR& err )
    {
        wxMessageBox( _( "Pcbnew failed to load:\n" ) + err.What(), _( "KiCad Error" ),
                      wxOK | wxICON_ERROR, this );
        return;
    }

    if( !frame->IsVisible() )   // A hidden frame might not have the board loaded.
    {
        if( !frame->OpenProjectFiles( std::vector<wxString>( 1, aProjectBoardFileName ) ) )
            return;

        frame->Show( true );
    }

    // On Windows, Raise() does not bring the window on screen, when iconized
    if( frame->IsIconized() )
        frame->Iconize( false );

    frame->Raise();
}
Пример #4
0
void KICAD_MANAGER_FRAME::RunEeschema( const wxString& aProjectSchematicFileName )
{
    KIWAY_PLAYER* frame;

    try
    {
        frame = Kiway().Player( FRAME_SCH, true );
    }
    catch( const IO_ERROR& err )
    {
        wxMessageBox( _( "Eeschema failed to load:\n" ) + err.What(),
                      _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
        return;
    }

    if( !frame->IsShown() ) // A hidden frame might not have the project loaded.
    {
        if( !frame->OpenProjectFiles( std::vector<wxString>( 1, aProjectSchematicFileName ) ) )
            return;

        frame->Show( true );
    }

    // On Windows, Raise() does not bring the window on screen, when iconized or not shown
    // On linux, Raise() brings the window on screen, but this code works fine
    if( frame->IsIconized() )
    {
        frame->Iconize( false );
        // If an iconized frame was created by Pcbnew, Iconize( false ) is not enough
        // to show the frame at its normal size: Maximize should be called.
        frame->Maximize( false );
    }

    frame->Raise();
}
Пример #5
0
void KICAD_MANAGER_FRAME::RunEeschema( const wxString& aProjectSchematicFileName )
{
    KIWAY_PLAYER* frame = Kiway.Player( FRAME_SCH, false );
    if( !frame )
    {
        frame = Kiway.Player( FRAME_SCH, true );
        frame->OpenProjectFiles( std::vector<wxString>( 1, aProjectSchematicFileName ) );
        frame->Show( true );
    }
    frame->Raise();
}
Пример #6
0
void KICAD_MANAGER_FRAME::RunPcbNew( const wxString& aProjectBoardFileName )
{
#if 0   // line 171 of modview_frame.cpp breaks this code
    KIWAY_PLAYER* frame = Kiway.Player( FRAME_PCB, false );
    if( !frame )
    {
        frame = Kiway.Player( FRAME_PCB, true );
        frame->OpenProjectFiles( std::vector<wxString>( 1, aProjectBoardFileName ) );
        frame->Show( true );
    }
#else
    KIWAY_PLAYER* frame = Kiway.Player( FRAME_PCB, true );

    if( !frame->IsVisible() )
    {
        frame->OpenProjectFiles( std::vector<wxString>( 1, aProjectBoardFileName ) );
        frame->Show( true );
    }

#endif
    frame->Raise();
}
Пример #7
0
void KICAD_MANAGER_FRAME::OnRunCvpcb( wxCommandEvent& event )
{
    wxFileName fn( GetProjectFileName() );

    fn.SetExt( NetlistFileExtension );

    KIWAY_PLAYER* frame = Kiway.Player( FRAME_CVPCB, false );
    if( !frame )
    {
        frame = Kiway.Player( FRAME_CVPCB, true );
        frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
        frame->Show( true );
    }
    frame->Raise();
}
Пример #8
0
void PGM_SINGLE_TOP::MacOpenFile( const wxString& aFileName )
{
    wxFileName  filename( aFileName );

    if( filename.FileExists() )
    {
#if 0
        // this pulls in EDA_DRAW_FRAME type info, which we don't want in
        // the single_top link image.
        KIWAY_PLAYER* frame = dynamic_cast<KIWAY_PLAYER*>( App().GetTopWindow() );
#else
        KIWAY_PLAYER* frame = (KIWAY_PLAYER*) App().GetTopWindow();
#endif
        if( frame )
            frame->OpenProjectFiles( std::vector<wxString>( 1, aFileName ) );
    }
}
Пример #9
0
void KICAD_MANAGER_FRAME::RunPcbNew( const wxString& aProjectBoardFileName )
{
    KIWAY_PLAYER* frame = Kiway.Player( FRAME_PCB, true );

    // a pcb frame can be already existing, but not yet used.
    // this is the case when running the footprint editor, or the footprint viewer first
    // if the frame is not visible, the board is not yet loaded
    if( !frame->IsVisible() )
    {
        frame->OpenProjectFiles( std::vector<wxString>( 1, aProjectBoardFileName ) );
        frame->Show( true );
    }

    // On Windows, Raise() does not bring the window on screen, when iconized
    if( frame->IsIconized() )
        frame->Iconize( false );

    frame->Raise();
}
Пример #10
0
bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp )
{
    // first thing: set m_wx_app
    m_wx_app = aWxApp;

    wxString absoluteArgv0 = wxStandardPaths::Get().GetExecutablePath();

    if( !wxIsAbsolutePath( absoluteArgv0 ) )
    {
        wxLogError( wxT( "No meaningful argv[0]" ) );
        return false;
    }

    if( !initPgm() )
        return false;

#if !defined(BUILD_KIWAY_DLL)
    // Get the getter, it is statically linked into this binary image.
    KIFACE_GETTER_FUNC* getter = &KIFACE_GETTER;

    int  kiface_version;

    // Get the KIFACE.
    KIFACE* kiface = getter( &kiface_version, KIFACE_VERSION, this );

    // Trick the KIWAY into thinking it loaded a KIFACE, by recording the KIFACE
    // in the KIWAY.  It needs to be there for KIWAY::OnKiwayEnd() anyways.
    Kiway.set_kiface( KIWAY::KifaceType( TOP_FRAME ), kiface );
#endif

    // Use KIWAY to create a top window, which registers its existence also.
    // "TOP_FRAME" is a macro that is passed on compiler command line from CMake,
    // and is one of the types in FRAME_T.
    KIWAY_PLAYER* frame = Kiway.Player( TOP_FRAME, true );

    Kiway.SetTop( frame );

    App().SetTopWindow( frame );      // wxApp gets a face.

    // Open project or file specified on the command line:
    int argc = App().argc;

    if( argc > 1 )
    {
        /*
            gerbview handles multiple project data files, i.e. gerber files on
            cmd line. Others currently do not, they handle only one. For common
            code simplicity we simply pass all the arguments in however, each
            program module can do with them what they want, ignore, complain
            whatever.  We don't establish policy here, as this is a multi-purpose
            launcher.
        */

        std::vector<wxString>   argSet;

        for( int i=1;  i<argc;  ++i )
        {
            argSet.push_back( App().argv[i] );
        }

        // special attention to the first argument: argv[1] (==argSet[0])
        wxFileName argv1( argSet[0] );

        if( argc == 2 )
        {
#if defined(PGM_DATA_FILE_EXT)
            // PGM_DATA_FILE_EXT, if present, may be different for each compile,
            // it may come from CMake on the compiler command line, but often does not.
            // This facillity is mostly useful for those program modules
            // supporting a single argv[1].
            if( !argv1.GetExt() )
                argv1.SetExt( wxT( PGM_DATA_FILE_EXT ) );

#endif
            argv1.MakeAbsolute();

            argSet[0] = argv1.GetFullPath();
        }

        // Use the KIWAY_PLAYER::OpenProjectFiles() API function:
        if( !frame->OpenProjectFiles( argSet ) )
        {
            // OpenProjectFiles() API asks that it report failure to the UI.
            // Nothing further to say here.

            // We've already initialized things at this point, but wx won't call OnExit if
            // we fail out. Call our own cleanup routine here to ensure the relevant resources
            // are freed at the right time (if they aren't, segfaults will occur).
            OnPgmExit();

            // Fail the process startup if the file could not be opened,
            // although this is an optional choice, one that can be reversed
            // also in the KIFACE specific OpenProjectFiles() return value.
            return false;
        }
    }

    frame->Show();

    return true;
}