Commit 09c038be authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Eeschema: add direct acces to LibEdit in popup menu, when a component is...

Eeschema: add direct acces to LibEdit in popup menu, when a component is selected ( Whishlist #788621 ). This new command calls Libedit and load the lib component corresponding to the selected schematic component.
parent fb8a6bf1
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -92,6 +92,11 @@ bool LIB_ALIAS::IsRoot() const
    return name.CmpNoCase( root->GetName() ) == 0;
}

CMP_LIBRARY* LIB_ALIAS::GetLibrary()
{
    return root->GetLibrary();
}


/**
 * Function SaveDoc
+2 −0
Original line number Diff line number Diff line
@@ -102,6 +102,8 @@ enum id_eeschema_frm
    ID_POPUP_SCH_GETINFO_MARKER,
    ID_POPUP_END_RANGE,

    ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP,

    // Unit select context menus command IDs.
    ID_POPUP_SCH_SELECT_UNIT_CMP,
    ID_POPUP_SCH_SELECT_UNIT1,
+46 −16
Original line number Diff line number Diff line
@@ -39,18 +39,57 @@ void LIB_EDIT_FRAME::DisplayLibInfos()


/* Function to select the current library (working library) */
void LIB_EDIT_FRAME::SelectActiveLibrary()
void LIB_EDIT_FRAME::SelectActiveLibrary( CMP_LIBRARY* aLibrary )
{
    CMP_LIBRARY* Lib;

    Lib = SelectLibraryFromList( this );
    if( Lib )
    if( aLibrary == NULL )
        aLibrary = SelectLibraryFromList( this );
    if( aLibrary )
    {
        m_library = Lib;
        m_library = aLibrary;
    }
    DisplayLibInfos();
}

/*
 * function LoadComponentAndSelectLib
 * Select the current active library.
 * aLibrary = the CMP_LIBRARY aLibrary to select
 * aLibEntry = the lib component to load from aLibrary (can be an alias
 * return true if OK.
 */
bool LIB_EDIT_FRAME::LoadComponentAndSelectLib( LIB_ALIAS* aLibEntry, CMP_LIBRARY* aLibrary )
{
    if( GetScreen()->IsModify()
        && !IsOK( this, _( "Current part not saved.\n\nDiscard current changes?" ) ) )
        return false;

    SelectActiveLibrary( aLibrary );
    return LoadComponentFromCurrentLib( aLibEntry );
}


/**
 * function LoadComponentFromCurrentLib
 * load a lib component from the current active library.
 * @param aLibEntry = the lib component to load from aLibrary (can be an alias
 * @return true if OK.
 */
bool LIB_EDIT_FRAME::LoadComponentFromCurrentLib( LIB_ALIAS* aLibEntry )
{
    if( !LoadOneLibraryPartAux( aLibEntry, m_library ) )
        return false;

    g_EditPinByPinIsOn = m_component->UnitsLocked() ? true : false;
    m_HToolBar->ToggleTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, g_EditPinByPinIsOn );

    GetScreen()->ClearUndoRedoList();
    Zoom_Automatique( false );
    DrawPanel->Refresh();
    SetShowDeMorgan( m_component->HasConversion() );
    m_HToolBar->Refresh();

    return true;
}

/**
 * Function LoadOneLibraryPart
@@ -106,17 +145,8 @@ void LIB_EDIT_FRAME::LoadOneLibraryPart( wxCommandEvent& event )
        return;
    }

    if( !LoadOneLibraryPartAux( LibEntry, m_library ) )
    if( ! LoadComponentFromCurrentLib( LibEntry ) )
        return;

    g_EditPinByPinIsOn = m_component->UnitsLocked() ? true : false;
    m_HToolBar->ToggleTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, g_EditPinByPinIsOn );

    GetScreen()->ClearUndoRedoList();
    Zoom_Automatique( false );
    DrawPanel->Refresh();
    SetShowDeMorgan( m_component->HasConversion() );
    m_HToolBar->Refresh();
}


+26 −1
Original line number Diff line number Diff line
@@ -222,9 +222,25 @@ private:

    // General:
    void           SaveOnePartInMemory();
    void           SelectActiveLibrary();

    /**
     * function SelectActiveLibrary
     * Select the current active library.
     * @param aLibrary = the CMP_LIBRARY aLibrary to select, or NULL
     * to select from a list
     */
    void           SelectActiveLibrary( CMP_LIBRARY* aLibrary = NULL);

    void           SaveActiveLibrary( wxCommandEvent& event );

    /**
     * function LoadComponentFromCurrentLib
     * load a lib component from the current active library.
     * @param aLibEntry = the lib component to load from aLibrary (can be an alias
     * @return true if OK.
     */
    bool           LoadComponentFromCurrentLib( LIB_ALIAS* aLibEntry );

    bool           LoadOneLibraryPartAux( LIB_ALIAS* LibEntry, CMP_LIBRARY* Library );

    void           DisplayCmpDoc();
@@ -272,6 +288,15 @@ private:
    void           EditField( wxDC* DC, LIB_FIELD* Field );

public:
    /**
     * function LoadComponentAndSelectLib
     * Select the current active library.
     * @param aLibrary = the CMP_LIBRARY aLibrary to select
     * @param aLibEntry = the lib component to load from aLibrary (can be an alias
     * @return true if OK.
     */
    bool           LoadComponentAndSelectLib( LIB_ALIAS* aLibEntry, CMP_LIBRARY* aLibrary );

    /* Block commands: */
    virtual int    ReturnBlockCommand( int aKey );
    virtual void   HandleBlockPlace( wxDC* DC );
+6 −0
Original line number Diff line number Diff line
@@ -299,6 +299,12 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
                                   _( "Unit" ), component_select_unit_xpm );
    }

    if( !Component->GetFlags() )
    {
        ADD_MENUITEM( editmenu, ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP, _( "Edit with Libedit" ),
                      library_xpm );
    }

    ADD_MENUITEM_WITH_SUBMENU( PopMenu, editmenu, ID_POPUP_SCH_GENERIC_EDIT_CMP,
                               _( "Edit Component" ), edit_component_xpm );

Loading