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

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
......@@ -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
......
......@@ -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,
......
......@@ -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();
}
......
......@@ -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 );
......
......@@ -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 );
......
......@@ -13,8 +13,6 @@
#include "wxEeschemaStruct.h"
#include "general.h"
#include "macros.h"
#include "protos.h"
#include "class_library.h"
#include "lib_rectangle.h"
#include "lib_pin.h"
......
......@@ -22,6 +22,7 @@
#include "class_library.h"
#include "wxEeschemaStruct.h"
#include "class_sch_screen.h"
#include "sch_component.h"
#include "dialog_helpers.h"
#include "netlist_control.h"
......@@ -79,6 +80,7 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, SCH_EDIT_FRAME::SetLanguage )
EVT_TOOL( ID_TO_LIBRARY, SCH_EDIT_FRAME::OnOpenLibraryEditor )
EVT_TOOL( ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP, SCH_EDIT_FRAME::OnOpenLibraryEditor )
EVT_TOOL( ID_TO_LIBVIEW, SCH_EDIT_FRAME::OnOpenLibraryViewer )
EVT_TOOL( ID_TO_PCB, SCH_EDIT_FRAME::OnOpenPcbnew )
......@@ -707,13 +709,39 @@ void SCH_EDIT_FRAME::OnOpenLibraryViewer( wxCommandEvent& event )
void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
{
SCH_COMPONENT* component = NULL;
if( event.GetId() == ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP )
{
SCH_ITEM* item = GetScreen()->GetCurItem();
if( (item == NULL) || (item->GetFlags() != 0) ||
( item->Type() != SCH_COMPONENT_T ) )
{
wxMessageBox( _("Error: not a component or no component" ) );
return;
}
component = (SCH_COMPONENT*) item;
}
if( m_LibeditFrame )
m_LibeditFrame->Show( true );
{
if( m_LibeditFrame->IsIconized() )
m_LibeditFrame->Iconize( false );
m_LibeditFrame->Raise();
}
else
m_LibeditFrame = new LIB_EDIT_FRAME( this,
wxT( "Library Editor" ),
wxPoint( -1, -1 ),
wxSize( 600, 400 ) );
if( component )
{
LIB_ALIAS* entry = CMP_LIBRARY::FindLibraryEntry( component->GetLibName() );
if( entry == NULL ) // Should not occur
return;
CMP_LIBRARY* library = entry->GetLibrary();
m_LibeditFrame->LoadComponentAndSelectLib( entry, library );
}
}
......
......@@ -24,7 +24,7 @@
*/
static const int PcbZoomList[] =
{
5, 10, 15, 22, 30, 45, 70, 100, 150, 220, 350, 500, 800, 1200,
5, 10, 15, 20, 30, 45, 70, 100, 150, 220, 350, 500, 800, 1200,
2000, 3500, 5000, 10000, 20000
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment