Allow adding symbols/footprints from editors and browsers.
This was always possible from modal browsers and from the footprint editor, but it's now also possible from non-modal browsers and the symbol editor. Fixes: lp:920380 * https://bugs.launchpad.net/kicad/+bug/920380
This commit is contained in:
parent
32c86a4ca4
commit
ecfa05e2ca
|
@ -210,6 +210,7 @@ enum id_eeschema_frm
|
|||
|
||||
ID_HOTKEY_HIGHLIGHT,
|
||||
ID_HIGHLIGHT_NET,
|
||||
ID_ADD_PART_TO_SCHEMATIC,
|
||||
|
||||
/* Library editor: edit events */
|
||||
ID_LIBEDIT_NEW_LIBRARY,
|
||||
|
@ -289,7 +290,6 @@ enum id_eeschema_frm
|
|||
ID_LIBVIEW_SELECT_PART_NUMBER,
|
||||
ID_LIBVIEW_LIB_LIST,
|
||||
ID_LIBVIEW_CMP_LIST,
|
||||
ID_LIBVIEW_CMP_EXPORT_TO_SCHEMATIC,
|
||||
ID_SET_RELATIVE_OFFSET,
|
||||
ID_LIBVIEW_SHOW_ELECTRICAL_TYPE,
|
||||
|
||||
|
|
|
@ -52,8 +52,7 @@
|
|||
|
||||
|
||||
SCH_BASE_FRAME::COMPONENT_SELECTION SCH_BASE_FRAME::SelectComponentFromLibBrowser(
|
||||
wxTopLevelWindow* aParent,
|
||||
const SCHLIB_FILTER* aFilter, const LIB_ID& aPreselectedLibId,
|
||||
wxTopLevelWindow* aParent, const SCHLIB_FILTER* aFilter, const LIB_ID& aPreselectedLibId,
|
||||
int aUnit, int aConvert )
|
||||
{
|
||||
// Close any open non-modal Lib browser, and open a new one, in "modal" mode:
|
||||
|
@ -78,8 +77,7 @@ SCH_BASE_FRAME::COMPONENT_SELECTION SCH_BASE_FRAME::SelectComponentFromLibBrowse
|
|||
viewlibFrame->Refresh();
|
||||
|
||||
COMPONENT_SELECTION sel;
|
||||
|
||||
wxString symbol = sel.LibId.Format();
|
||||
wxString symbol;
|
||||
|
||||
if( viewlibFrame->ShowModal( &symbol, aParent ) )
|
||||
{
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
#include <tool/context_menu.h>
|
||||
#include <sch_view.h>
|
||||
#include <sch_painter.h>
|
||||
#include <tools/sch_actions.h>
|
||||
|
||||
int LIB_EDIT_FRAME:: m_unit = 1;
|
||||
int LIB_EDIT_FRAME:: m_convert = 1;
|
||||
|
@ -119,6 +120,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
|
|||
EVT_TOOL( ID_LIBEDIT_VIEW_DOC, LIB_EDIT_FRAME::OnViewEntryDoc )
|
||||
EVT_TOOL( ID_LIBEDIT_SYNC_PIN_EDIT, LIB_EDIT_FRAME::Process_Special_Functions )
|
||||
EVT_TOOL( ID_LIBEDIT_EDIT_PIN_BY_TABLE, LIB_EDIT_FRAME::OnOpenPinTable )
|
||||
EVT_TOOL( ID_ADD_PART_TO_SCHEMATIC, LIB_EDIT_FRAME::OnAddPartToSchematic )
|
||||
|
||||
EVT_COMBOBOX( ID_LIBEDIT_SELECT_PART_NUMBER, LIB_EDIT_FRAME::OnSelectPart )
|
||||
|
||||
|
@ -171,7 +173,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
|
|||
EVT_UPDATE_UI( ID_LIBEDIT_EXPORT_PART, LIB_EDIT_FRAME::OnUpdateHavePart )
|
||||
EVT_UPDATE_UI( ID_LIBEDIT_SAVE, LIB_EDIT_FRAME::OnUpdateSave )
|
||||
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_ALL, LIB_EDIT_FRAME::OnUpdateSave )
|
||||
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_AS, LIB_EDIT_FRAME::OnUpdateSaveAs )
|
||||
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_AS, LIB_EDIT_FRAME::OnUpdateHavePart )
|
||||
EVT_UPDATE_UI( ID_LIBEDIT_REVERT, LIB_EDIT_FRAME::OnUpdateRevert )
|
||||
EVT_UPDATE_UI( ID_LIBEDIT_CHECK_PART, LIB_EDIT_FRAME::OnUpdateEditingPart )
|
||||
EVT_UPDATE_UI( ID_LIBEDIT_GET_FRAME_EDIT_PART, LIB_EDIT_FRAME::OnUpdateEditingPart )
|
||||
|
@ -458,16 +460,6 @@ void LIB_EDIT_FRAME::OnUpdateSave( wxUpdateUIEvent& aEvent )
|
|||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::OnUpdateSaveAs( wxUpdateUIEvent& aEvent )
|
||||
{
|
||||
LIB_ID libId = getTargetLibId();
|
||||
const wxString& libName = libId.GetLibNickname();
|
||||
const wxString& partName = libId.GetLibItemName();
|
||||
|
||||
aEvent.Enable( !libName.IsEmpty() || !partName.IsEmpty() );
|
||||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::OnUpdateRevert( wxUpdateUIEvent& aEvent )
|
||||
{
|
||||
LIB_ID libId = getTargetLibId();
|
||||
|
@ -627,10 +619,7 @@ void LIB_EDIT_FRAME::OnSelectBodyStyle( wxCommandEvent& event )
|
|||
{
|
||||
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() );
|
||||
|
||||
if( event.GetId() == ID_DE_MORGAN_NORMAL_BUTT )
|
||||
m_convert = 1;
|
||||
else
|
||||
m_convert = 2;
|
||||
m_convert = event.GetId() == ID_DE_MORGAN_NORMAL_BUTT ? 1 : 2;
|
||||
|
||||
m_lastDrawItem = NULL;
|
||||
|
||||
|
@ -703,10 +692,10 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
|
||||
case ID_POPUP_LIBEDIT_END_CREATE_ITEM:
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
|
||||
if( item )
|
||||
{
|
||||
EndDrawGraphicItem( nullptr );
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case ID_POPUP_LIBEDIT_BODY_EDIT_ITEM:
|
||||
|
@ -742,7 +731,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
break;
|
||||
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
( (LIB_POLYLINE*) item )->DeleteSegment( GetCrossHairPosition( true ) );
|
||||
static_cast<LIB_POLYLINE*>( item )->DeleteSegment( GetCrossHairPosition( true ) );
|
||||
m_lastDrawItem = NULL;
|
||||
}
|
||||
break;
|
||||
|
@ -765,7 +754,6 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
break;
|
||||
|
||||
case ID_POPUP_LIBEDIT_MODIFY_ITEM:
|
||||
|
||||
if( item == NULL )
|
||||
break;
|
||||
|
||||
|
@ -773,8 +761,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
if( item->Type() == LIB_RECTANGLE_T
|
||||
|| item->Type() == LIB_CIRCLE_T
|
||||
|| item->Type() == LIB_POLYLINE_T
|
||||
|| item->Type() == LIB_ARC_T
|
||||
)
|
||||
|| item->Type() == LIB_ARC_T )
|
||||
{
|
||||
StartModifyDrawSymbol( nullptr, item );
|
||||
}
|
||||
|
@ -1307,15 +1294,14 @@ LIB_ITEM* LIB_EDIT_FRAME::LocateItemUsingCursor( const wxPoint& aPosition,
|
|||
|
||||
LIB_ITEM* LIB_EDIT_FRAME::locateItem( const wxPoint& aPosition, const KICAD_T aFilterList[] )
|
||||
{
|
||||
LIB_PART* part = GetCurPart();
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
if( !part )
|
||||
return NULL;
|
||||
|
||||
LIB_ITEM* item = NULL;
|
||||
|
||||
m_collectedItems.Collect( part->GetDrawItems(), aFilterList, aPosition,
|
||||
m_unit, m_convert );
|
||||
m_collectedItems.Collect( part->GetDrawItems(), aFilterList, aPosition, m_unit, m_convert );
|
||||
|
||||
if( m_collectedItems.GetCount() == 0 )
|
||||
{
|
||||
|
@ -1327,32 +1313,28 @@ LIB_ITEM* LIB_EDIT_FRAME::locateItem( const wxPoint& aPosition, const KICAD_T aF
|
|||
}
|
||||
else
|
||||
{
|
||||
if( item == NULL )
|
||||
wxASSERT_MSG( m_collectedItems.GetCount() <= MAX_SELECT_ITEM_IDS,
|
||||
"Select item clarification context menu size limit exceeded." );
|
||||
|
||||
wxMenu selectMenu;
|
||||
AddMenuItem( &selectMenu, wxID_NONE, _( "Clarify Selection" ), KiBitmap( info_xpm ) );
|
||||
|
||||
selectMenu.AppendSeparator();
|
||||
|
||||
for( int i = 0; i < m_collectedItems.GetCount() && i < MAX_SELECT_ITEM_IDS; i++ )
|
||||
{
|
||||
wxASSERT_MSG( m_collectedItems.GetCount() <= MAX_SELECT_ITEM_IDS,
|
||||
"Select item clarification context menu size limit exceeded." );
|
||||
wxString text = m_collectedItems[i]->GetSelectMenuText( m_UserUnits );
|
||||
BITMAP_DEF xpm = m_collectedItems[i]->GetMenuImage();
|
||||
|
||||
wxMenu selectMenu;
|
||||
AddMenuItem( &selectMenu, wxID_NONE, _( "Clarify Selection" ),
|
||||
KiBitmap( info_xpm ) );
|
||||
|
||||
selectMenu.AppendSeparator();
|
||||
|
||||
for( int i = 0; i < m_collectedItems.GetCount() && i < MAX_SELECT_ITEM_IDS; i++ )
|
||||
{
|
||||
wxString text = m_collectedItems[i]->GetSelectMenuText( m_UserUnits );
|
||||
BITMAP_DEF xpm = m_collectedItems[i]->GetMenuImage();
|
||||
|
||||
AddMenuItem( &selectMenu, ID_SELECT_ITEM_START + i, text, KiBitmap( xpm ) );
|
||||
}
|
||||
|
||||
// Set to NULL in case user aborts the clarification context menu.
|
||||
SetDrawItem( NULL );
|
||||
m_canvas->SetAbortRequest( true ); // Changed to false if an item is selected
|
||||
PopupMenu( &selectMenu );
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
item = GetDrawItem();
|
||||
AddMenuItem( &selectMenu, ID_SELECT_ITEM_START + i, text, KiBitmap( xpm ) );
|
||||
}
|
||||
|
||||
// Set to NULL in case user aborts the clarification context menu.
|
||||
SetDrawItem( NULL );
|
||||
m_canvas->SetAbortRequest( true ); // Changed to false if an item is selected
|
||||
PopupMenu( &selectMenu );
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
item = GetDrawItem();
|
||||
}
|
||||
|
||||
if( item )
|
||||
|
@ -1377,7 +1359,7 @@ void LIB_EDIT_FRAME::deleteItem( wxDC* aDC, LIB_ITEM* aItem )
|
|||
|
||||
m_canvas->CrossHairOff( aDC );
|
||||
|
||||
LIB_PART* part = GetCurPart();
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
SaveCopyInUndoList( part );
|
||||
|
||||
|
@ -1476,6 +1458,38 @@ bool LIB_EDIT_FRAME::SynchronizePins()
|
|||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::OnAddPartToSchematic( wxCommandEvent& event )
|
||||
{
|
||||
if( GetCurPart() )
|
||||
{
|
||||
SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false );
|
||||
|
||||
if( schframe == NULL ) // happens when the schematic editor is not active (or closed)
|
||||
{
|
||||
DisplayErrorMessage( this, _("No schematic currently open." ) );
|
||||
return;
|
||||
}
|
||||
|
||||
SCH_COMPONENT* component = new SCH_COMPONENT( *GetCurPart(), GetCurPart()->GetLibId(),
|
||||
g_CurrentSheet, GetUnit(), GetConvert(),
|
||||
wxPoint( 0, 0 ), true );
|
||||
|
||||
// Be sure the link to the corresponding LIB_PART is OK:
|
||||
component->Resolve( *Prj().SchSymbolLibTable() );
|
||||
|
||||
MSG_PANEL_ITEMS items;
|
||||
component->GetMsgPanelInfo( schframe->GetUserUnits(), items );
|
||||
schframe->SetMsgPanel( items );
|
||||
|
||||
if( schframe->GetAutoplaceFields() )
|
||||
component->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false );
|
||||
|
||||
schframe->Raise();
|
||||
schframe->GetToolManager()->RunAction( SCH_ACTIONS::placeSymbol, true, component );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::refreshSchematic()
|
||||
{
|
||||
// There may be no parent window so use KIWAY message to refresh the schematic editor
|
||||
|
@ -1489,9 +1503,8 @@ bool LIB_EDIT_FRAME::addLibraryFile( bool aCreateNew )
|
|||
{
|
||||
wxFileName fn = m_libMgr->GetUniqueLibraryName();
|
||||
|
||||
if( !LibraryFileBrowser( !aCreateNew, fn,
|
||||
SchematicLibraryFileWildcard(), SchematicLibraryFileExtension,
|
||||
false ) )
|
||||
if( !LibraryFileBrowser( !aCreateNew, fn, SchematicLibraryFileWildcard(),
|
||||
SchematicLibraryFileExtension, false ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -1670,8 +1683,7 @@ bool LIB_EDIT_FRAME::backupFile( const wxFileName& aOriginalFile, const wxString
|
|||
|
||||
if( !wxCopyFile( aOriginalFile.GetFullPath(), backupFileName.GetFullPath() ) )
|
||||
{
|
||||
DisplayError( this, _( "Failed to save backup document to file " ) +
|
||||
backupFileName.GetFullPath() );
|
||||
DisplayError( this, _( "Failed to save backup to " ) + backupFileName.GetFullPath() );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2017 CERN
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
|
@ -25,11 +25,6 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file lib_edit_frame.h
|
||||
* @brief Definition of class LIB_EDIT_FRAME
|
||||
*/
|
||||
|
||||
#ifndef LIB_EDIT_FRAME_H
|
||||
#define LIB_EDIT_FRAME_H
|
||||
|
||||
|
@ -272,6 +267,11 @@ public:
|
|||
*/
|
||||
void OnExportPart( wxCommandEvent& event );
|
||||
|
||||
/**
|
||||
* Add the current part to the schematic
|
||||
*/
|
||||
void OnAddPartToSchematic( wxCommandEvent& event );
|
||||
|
||||
/**
|
||||
* Saves the selected part or library.
|
||||
*/
|
||||
|
@ -297,7 +297,6 @@ public:
|
|||
*/
|
||||
void OnRemovePart( wxCommandEvent& aEvent );
|
||||
|
||||
void OnDuplicatePart( wxCommandEvent& aEvent );
|
||||
void OnCopyCutPart( wxCommandEvent& aEvent );
|
||||
void OnPasteDuplicatePart( wxCommandEvent& aEvent );
|
||||
|
||||
|
@ -330,7 +329,6 @@ public:
|
|||
void OnUpdateEditingPart( wxUpdateUIEvent& event );
|
||||
void OnUpdateHavePart( wxUpdateUIEvent& aEvent );
|
||||
void OnUpdateSave( wxUpdateUIEvent& aEvent );
|
||||
void OnUpdateSaveAs( wxUpdateUIEvent& aEvent );
|
||||
void OnUpdateRevert( wxUpdateUIEvent& aEvent );
|
||||
void OnUpdateUndo( wxUpdateUIEvent& event );
|
||||
void OnUpdateRedo( wxUpdateUIEvent& event );
|
||||
|
@ -401,38 +399,21 @@ public:
|
|||
void OnModify();
|
||||
|
||||
int GetUnit() { return m_unit; }
|
||||
|
||||
void SetUnit( int unit )
|
||||
{
|
||||
wxASSERT( unit >= 1 );
|
||||
m_unit = unit;
|
||||
}
|
||||
void SetUnit( int unit ) { m_unit = unit; }
|
||||
|
||||
int GetConvert() { return m_convert; }
|
||||
|
||||
void SetConvert( int convert )
|
||||
{
|
||||
wxASSERT( convert >= 0 );
|
||||
m_convert = convert;
|
||||
}
|
||||
void SetConvert( int convert ) { m_convert = convert; }
|
||||
|
||||
LIB_ITEM* GetLastDrawItem() { return m_lastDrawItem; }
|
||||
|
||||
void SetLastDrawItem( LIB_ITEM* drawItem )
|
||||
{
|
||||
m_lastDrawItem = drawItem;
|
||||
}
|
||||
void SetLastDrawItem( LIB_ITEM* drawItem ) { m_lastDrawItem = drawItem; }
|
||||
|
||||
LIB_ITEM* GetDrawItem() const { return GetScreen()->GetCurLibItem(); }
|
||||
|
||||
void SetDrawItem( LIB_ITEM* drawItem ) { GetScreen()->SetCurLibItem( drawItem ); }
|
||||
|
||||
bool GetShowDeMorgan() { return m_showDeMorgan; }
|
||||
|
||||
void SetShowDeMorgan( bool show ) { m_showDeMorgan = show; }
|
||||
|
||||
bool GetShowElectricalType() { return m_showPinElectricalTypeName; }
|
||||
|
||||
void SetShowElectricalType( bool aShow ) { m_showPinElectricalTypeName = aShow; }
|
||||
|
||||
FILL_T GetFillStyle() { return m_drawFillStyle; }
|
||||
|
|
|
@ -190,6 +190,12 @@ void LIB_EDIT_FRAME::ReCreateHToolbar()
|
|||
m_mainToolBar->AddTool( ID_LIBEDIT_SYNC_PIN_EDIT, wxEmptyString,
|
||||
KiScaledBitmap( pin2pin_xpm, this ), msg, wxITEM_CHECK );
|
||||
|
||||
KiScaledSeparator( m_mainToolBar, this );
|
||||
|
||||
m_mainToolBar->AddTool( ID_ADD_PART_TO_SCHEMATIC, wxEmptyString,
|
||||
KiScaledBitmap( export_xpm, this ),
|
||||
_( "Add symbol to schematic" ) );
|
||||
|
||||
// after adding the buttons to the toolbar, must call Realize() to reflect the changes
|
||||
m_mainToolBar->Realize();
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
|
@ -19,11 +19,6 @@
|
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file tool_viewlib.cpp
|
||||
* @brief Build the toolbars for the library browser.
|
||||
*/
|
||||
|
||||
|
||||
#include <dialog_helpers.h>
|
||||
#include <macros.h>
|
||||
|
@ -52,7 +47,7 @@ void LIB_VIEW_FRAME::ReCreateHToolbar()
|
|||
KiScaledBitmap( add_component_xpm, this ),
|
||||
_( "Select symbol to browse" ) );
|
||||
|
||||
m_mainToolBar->AddSeparator();
|
||||
KiScaledSeparator( m_mainToolBar, this );
|
||||
m_mainToolBar->AddTool( ID_LIBVIEW_PREVIOUS, wxEmptyString,
|
||||
KiScaledBitmap( lib_previous_xpm, this ),
|
||||
_( "Display previous symbol" ) );
|
||||
|
@ -61,7 +56,7 @@ void LIB_VIEW_FRAME::ReCreateHToolbar()
|
|||
KiScaledBitmap( lib_next_xpm, this ),
|
||||
_( "Display next symbol" ) );
|
||||
|
||||
m_mainToolBar->AddSeparator();
|
||||
KiScaledSeparator( m_mainToolBar, this );
|
||||
msg = AddHotkeyName( _( "Zoom in" ), g_Viewlib_Hotkeys_Descr,
|
||||
HK_ZOOM_IN, IS_COMMENT );
|
||||
m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString,
|
||||
|
@ -82,7 +77,7 @@ void LIB_VIEW_FRAME::ReCreateHToolbar()
|
|||
m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString,
|
||||
KiScaledBitmap( zoom_fit_in_page_xpm, this ), msg );
|
||||
|
||||
m_mainToolBar->AddSeparator();
|
||||
KiScaledSeparator( m_mainToolBar, this );
|
||||
m_mainToolBar->AddTool( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, wxEmptyString,
|
||||
KiScaledBitmap( morgan1_xpm, this ),
|
||||
_( "Show as \"De Morgan\" normal symbol" ),
|
||||
|
@ -93,24 +88,21 @@ void LIB_VIEW_FRAME::ReCreateHToolbar()
|
|||
_( "Show as \"De Morgan\" convert symbol" ),
|
||||
wxITEM_CHECK );
|
||||
|
||||
m_mainToolBar->AddSeparator();
|
||||
KiScaledSeparator( m_mainToolBar, this );
|
||||
|
||||
m_unitChoice = new wxChoice( m_mainToolBar, ID_LIBVIEW_SELECT_PART_NUMBER,
|
||||
wxDefaultPosition, wxSize( 150, -1 ) );
|
||||
m_mainToolBar->AddControl( m_unitChoice );
|
||||
|
||||
m_mainToolBar->AddSeparator();
|
||||
KiScaledSeparator( m_mainToolBar, this );
|
||||
m_mainToolBar->AddTool( ID_LIBVIEW_VIEWDOC, wxEmptyString,
|
||||
KiScaledBitmap( datasheet_xpm, this ),
|
||||
_( "View symbol documents" ) );
|
||||
|
||||
if( IsModal() )
|
||||
{
|
||||
m_mainToolBar->AddSeparator();
|
||||
m_mainToolBar->AddTool( ID_LIBVIEW_CMP_EXPORT_TO_SCHEMATIC,
|
||||
wxEmptyString, KiScaledBitmap( export_xpm, this ),
|
||||
_( "Insert symbol in schematic" ) );
|
||||
}
|
||||
KiScaledSeparator( m_mainToolBar, this );
|
||||
m_mainToolBar->AddTool( ID_ADD_PART_TO_SCHEMATIC, wxEmptyString,
|
||||
KiScaledBitmap( export_xpm, this ),
|
||||
_( "Add symbol to schematic" ) );
|
||||
|
||||
// after adding the buttons to the toolbar, must call Realize() to
|
||||
// reflect the changes
|
||||
|
|
|
@ -336,9 +336,8 @@ int SCH_EDITOR_CONTROL::placeComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTER
|
|||
m_frame->SetRepeatItem( NULL );
|
||||
m_frame->GetCanvas()->SetIgnoreMouseEvents( true );
|
||||
|
||||
auto sel = m_frame->SelectComponentFromLibTree(
|
||||
aFilter, aHistoryList, true, 1, 1,
|
||||
m_frame->GetShowFootprintPreviews() );
|
||||
auto sel = m_frame->SelectComponentFromLibTree( aFilter, aHistoryList, true, 1, 1,
|
||||
m_frame->GetShowFootprintPreviews() );
|
||||
|
||||
// Restore cursor after dialog
|
||||
m_frame->GetCanvas()->MoveCursorToCrossHair();
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -23,10 +23,6 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file viewlib_frame.cpp
|
||||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <kiface_i.h>
|
||||
#include <pgm_base.h>
|
||||
|
@ -49,6 +45,7 @@
|
|||
#include <sch_painter.h>
|
||||
#include <confirm.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/sch_actions.h>
|
||||
|
||||
// Save previous component library viewer state.
|
||||
wxString LIB_VIEW_FRAME::m_libraryName;
|
||||
|
@ -71,8 +68,8 @@ BEGIN_EVENT_TABLE( LIB_VIEW_FRAME, EDA_DRAW_FRAME )
|
|||
EVT_TOOL( ID_LIBVIEW_VIEWDOC, LIB_VIEW_FRAME::onViewSymbolDocument )
|
||||
EVT_TOOL_RANGE( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT,
|
||||
LIB_VIEW_FRAME::onSelectSymbolBodyStyle )
|
||||
EVT_TOOL( ID_LIBVIEW_CMP_EXPORT_TO_SCHEMATIC, LIB_VIEW_FRAME::ExportToSchematicLibraryPart )
|
||||
EVT_CHOICE( ID_LIBVIEW_SELECT_PART_NUMBER, LIB_VIEW_FRAME::onSelectSymbolUnit )
|
||||
EVT_TOOL( ID_ADD_PART_TO_SCHEMATIC, LIB_VIEW_FRAME::OnAddPartToSchematic )
|
||||
|
||||
// listbox events
|
||||
EVT_LISTBOX( ID_LIBVIEW_LIB_LIST, LIB_VIEW_FRAME::ClickOnLibList )
|
||||
|
@ -240,9 +237,7 @@ LIB_ALIAS* LIB_VIEW_FRAME::getSelectedAlias() const
|
|||
LIB_ALIAS* alias = NULL;
|
||||
|
||||
if( !m_libraryName.IsEmpty() && !m_entryName.IsEmpty() )
|
||||
{
|
||||
alias = Prj().SchSymbolLibTable()->LoadSymbol( m_libraryName, m_entryName );
|
||||
}
|
||||
|
||||
return alias;
|
||||
}
|
||||
|
@ -673,46 +668,22 @@ void LIB_VIEW_FRAME::SetSelectedComponent( const wxString& aComponentName )
|
|||
|
||||
void LIB_VIEW_FRAME::DClickOnCmpList( wxCommandEvent& event )
|
||||
{
|
||||
if( IsModal() )
|
||||
OnAddPartToSchematic( event );
|
||||
|
||||
// The schematic editor might not be the parent of the library viewer.
|
||||
// It could be a python window.
|
||||
SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
|
||||
|
||||
if( schframe )
|
||||
{
|
||||
ExportToSchematicLibraryPart( event );
|
||||
|
||||
// The schematic editor might not be the parent of the library viewer.
|
||||
// It could be a python window.
|
||||
SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
|
||||
|
||||
if( schframe )
|
||||
{
|
||||
// Prevent the double click from being as a single click in the parent
|
||||
// window which would cause the part to be parked rather than staying
|
||||
// in drag mode.
|
||||
schframe->SkipNextLeftButtonReleaseEvent();
|
||||
}
|
||||
// Prevent the double click from being as a single click in the parent
|
||||
// window which would cause the part to be parked rather than staying
|
||||
// in drag mode.
|
||||
schframe->SkipNextLeftButtonReleaseEvent();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LIB_VIEW_FRAME::ExportToSchematicLibraryPart( wxCommandEvent& event )
|
||||
{
|
||||
int ii = m_cmpList->GetSelection();
|
||||
|
||||
if( ii >= 0 )
|
||||
{
|
||||
wxString part_name = m_libraryName + ':' + m_cmpList->GetString( ii );
|
||||
|
||||
// a selection was made, pass true
|
||||
DismissModal( true, part_name );
|
||||
}
|
||||
else
|
||||
{
|
||||
// no selection was made, pass false
|
||||
DismissModal( false );
|
||||
}
|
||||
|
||||
Close( true );
|
||||
}
|
||||
|
||||
|
||||
#define LIBLIST_WIDTH_KEY "ViewLiblistWidth"
|
||||
#define CMPLIST_WIDTH_KEY "ViewCmplistWidth"
|
||||
#define CMPVIEW_SHOW_PINELECTRICALTYPE_KEY "ViewCmpShowPinElectricalType"
|
||||
|
@ -801,6 +772,7 @@ void LIB_VIEW_FRAME::SetFilter( const SCHLIB_FILTER* aFilter )
|
|||
ReCreateListLib();
|
||||
}
|
||||
|
||||
|
||||
const BOX2I LIB_VIEW_FRAME::GetDocumentExtents() const
|
||||
{
|
||||
LIB_ALIAS* alias = getSelectedAlias();
|
||||
|
@ -817,3 +789,49 @@ const BOX2I LIB_VIEW_FRAME::GetDocumentExtents() const
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LIB_VIEW_FRAME::OnAddPartToSchematic( wxCommandEvent& aEvent )
|
||||
{
|
||||
if( IsModal() )
|
||||
{
|
||||
// if we're modal then we just need to return the symbol selection; the caller is
|
||||
// already in a SCH_ACTIONS::placeSymbol coroutine.
|
||||
if( m_cmpList->GetSelection() >= 0 )
|
||||
DismissModal( true, m_libraryName + ':' + m_cmpList->GetStringSelection() );
|
||||
else
|
||||
DismissModal( false );
|
||||
|
||||
Close( true );
|
||||
return;
|
||||
}
|
||||
|
||||
if( getSelectedSymbol() )
|
||||
{
|
||||
SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false );
|
||||
|
||||
if( schframe == NULL ) // happens when the schematic editor is not active (or closed)
|
||||
{
|
||||
DisplayErrorMessage( this, _("No schematic currently open." ) );
|
||||
return;
|
||||
}
|
||||
|
||||
SCH_COMPONENT* component = new SCH_COMPONENT( *getSelectedSymbol(),
|
||||
getSelectedAlias()->GetLibId(),
|
||||
g_CurrentSheet, m_unit, m_convert,
|
||||
wxPoint( 0, 0 ), true );
|
||||
|
||||
// Be sure the link to the corresponding LIB_PART is OK:
|
||||
component->Resolve( *Prj().SchSymbolLibTable() );
|
||||
|
||||
MSG_PANEL_ITEMS items;
|
||||
component->GetMsgPanelInfo( schframe->GetUserUnits(), items );
|
||||
schframe->SetMsgPanel( items );
|
||||
|
||||
if( schframe->GetAutoplaceFields() )
|
||||
component->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false );
|
||||
|
||||
schframe->Raise();
|
||||
schframe->GetToolManager()->RunAction( SCH_ACTIONS::placeSymbol, true, component );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -25,7 +25,6 @@
|
|||
|
||||
|
||||
#ifndef LIB_VIEW_FRAME_H__
|
||||
|
||||
#define LIB_VIEW_FRAME_H__
|
||||
|
||||
#include <sch_base_frame.h>
|
||||
|
@ -164,11 +163,6 @@ private:
|
|||
*/
|
||||
virtual void OnActivate( wxActivateEvent& event ) override;
|
||||
|
||||
/**
|
||||
* Function ExportToSchematicLibraryPart
|
||||
* exports the current component to schematic and close the library browser.
|
||||
*/
|
||||
void ExportToSchematicLibraryPart( wxCommandEvent& event );
|
||||
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) override;
|
||||
void DClickOnCmpList( wxCommandEvent& event );
|
||||
|
||||
|
@ -177,11 +171,13 @@ private:
|
|||
void onUpdateDocButton( wxUpdateUIEvent& aEvent );
|
||||
void OnUpdateElectricalType( wxUpdateUIEvent& aEvent );
|
||||
void onUpdateUnitChoice( wxUpdateUIEvent& aEvent );
|
||||
|
||||
void onSelectNextSymbol( wxCommandEvent& aEvent );
|
||||
void onSelectPreviousSymbol( wxCommandEvent& aEvent );
|
||||
void onViewSymbolDocument( wxCommandEvent& aEvent );
|
||||
void onSelectSymbolBodyStyle( wxCommandEvent& aEvent );
|
||||
void onSelectSymbolUnit( wxCommandEvent& aEvent );
|
||||
void OnAddPartToSchematic( wxCommandEvent& aEvent );
|
||||
|
||||
LIB_ALIAS* getSelectedAlias() const;
|
||||
LIB_PART* getSelectedSymbol() const;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2015-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2015-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -22,10 +22,6 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file viewlibs.cpp
|
||||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <kiway.h>
|
||||
#include <pgm_base.h>
|
||||
|
@ -138,19 +134,10 @@ void LIB_VIEW_FRAME::onViewSymbolDocument( wxCommandEvent& aEvent )
|
|||
|
||||
void LIB_VIEW_FRAME::onSelectSymbolBodyStyle( wxCommandEvent& aEvent )
|
||||
{
|
||||
int id = aEvent.GetId();
|
||||
|
||||
switch( id )
|
||||
{
|
||||
default:
|
||||
case ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT:
|
||||
m_convert = LIB_ITEM::LIB_CONVERT::BASE;
|
||||
break;
|
||||
|
||||
case ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT:
|
||||
if( aEvent.GetId() == ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT )
|
||||
m_convert = LIB_ITEM::LIB_CONVERT::DEMORGAN;
|
||||
break;
|
||||
}
|
||||
else
|
||||
m_convert = LIB_ITEM::LIB_CONVERT::BASE;
|
||||
|
||||
updatePreviewSymbol();
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
|
|||
EVT_TOOL( ID_MODEDIT_CHECK, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
||||
EVT_TOOL( ID_MODEDIT_PAD_SETTINGS, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
||||
EVT_TOOL( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, FOOTPRINT_EDIT_FRAME::LoadModuleFromBoard )
|
||||
EVT_TOOL( ID_MODEDIT_INSERT_MODULE_IN_BOARD, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
||||
EVT_TOOL( ID_ADD_FOOTPRINT_TO_BOARD, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
||||
EVT_TOOL( ID_MODEDIT_EDIT_MODULE_PROPERTIES, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
||||
EVT_TOOL( wxID_UNDO, FOOTPRINT_EDIT_FRAME::RestoreCopyFromUndoList )
|
||||
EVT_TOOL( wxID_REDO, FOOTPRINT_EDIT_FRAME::RestoreCopyFromRedoList )
|
||||
|
@ -183,7 +183,7 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
|
|||
EVT_UPDATE_UI( ID_MODEDIT_DELETE_PART, FOOTPRINT_EDIT_FRAME::OnUpdateModuleTargeted )
|
||||
EVT_UPDATE_UI( ID_MODEDIT_LOAD_MODULE_FROM_BOARD,
|
||||
FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard )
|
||||
EVT_UPDATE_UI( ID_MODEDIT_INSERT_MODULE_IN_BOARD,
|
||||
EVT_UPDATE_UI( ID_ADD_FOOTPRINT_TO_BOARD,
|
||||
FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard )
|
||||
EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, FOOTPRINT_EDIT_FRAME::OnUpdateSelectTool )
|
||||
EVT_UPDATE_UI( ID_ZOOM_SELECTION, FOOTPRINT_EDIT_FRAME::OnUpdateSelectTool )
|
||||
|
|
|
@ -545,7 +545,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
}
|
||||
break;
|
||||
|
||||
case ID_MODEDIT_INSERT_MODULE_IN_BOARD:
|
||||
case ID_ADD_FOOTPRINT_TO_BOARD:
|
||||
SaveFootprintToBoard( true );
|
||||
break;
|
||||
|
||||
|
|
|
@ -855,6 +855,12 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew )
|
|||
pcbframe->SetCrossHairPosition( cursor_pos );
|
||||
newmodule->SetTimeStamp( GetNewTimeStamp() );
|
||||
commit.Push( wxT( "Insert module" ) );
|
||||
|
||||
if( pcbframe->IsGalCanvasActive() )
|
||||
{
|
||||
pcbframe->Raise();
|
||||
pcbframe->GetToolManager()->RunAction( PCB_ACTIONS::placeModule, true, newmodule );
|
||||
}
|
||||
}
|
||||
|
||||
newmodule->ClearFlags();
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2012-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2008-2016 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -23,10 +23,6 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file footprint_viewer_frame.cpp
|
||||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <pgm_base.h>
|
||||
#include <kiway.h>
|
||||
|
@ -60,6 +56,7 @@
|
|||
#include "tools/selection_tool.h"
|
||||
#include "tools/pcbnew_control.h"
|
||||
#include "tools/pcb_actions.h"
|
||||
#include "board_commit.h"
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
@ -92,7 +89,7 @@ BEGIN_EVENT_TABLE( FOOTPRINT_VIEWER_FRAME, EDA_DRAW_FRAME )
|
|||
EVT_TOOL( ID_MODVIEW_OPTIONS, FOOTPRINT_VIEWER_FRAME::InstallDisplayOptions )
|
||||
EVT_TOOL( ID_MODVIEW_NEXT, FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList )
|
||||
EVT_TOOL( ID_MODVIEW_PREVIOUS, FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList )
|
||||
EVT_TOOL( ID_MODVIEW_EXPORT_TO_BOARD, FOOTPRINT_VIEWER_FRAME::ExportSelectedFootprint )
|
||||
EVT_TOOL( ID_ADD_FOOTPRINT_TO_BOARD, FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB )
|
||||
EVT_TOOL( ID_MODVIEW_SHOW_3D_VIEW, FOOTPRINT_VIEWER_FRAME::Show3D_Frame )
|
||||
EVT_CHOICE( ID_ON_ZOOM_SELECT, FOOTPRINT_VIEWER_FRAME::OnSelectZoom )
|
||||
EVT_CHOICE( ID_ON_GRID_SELECT, FOOTPRINT_VIEWER_FRAME::OnSelectGrid )
|
||||
|
@ -240,8 +237,7 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent
|
|||
m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
|
||||
m_auimgr.AddPane( GetGalCanvas(), EDA_PANE().Canvas().Name( "DrawFrameGal" ).Center().Hide() );
|
||||
|
||||
// after changing something to the aui manager,
|
||||
// call Update()() to reflect the changes
|
||||
// after changing something to the aui manager call Update() to reflect the changes
|
||||
m_auimgr.Update();
|
||||
|
||||
GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
|
||||
|
@ -452,48 +448,74 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& event )
|
|||
|
||||
void FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList( wxCommandEvent& event )
|
||||
{
|
||||
if( IsModal() )
|
||||
{
|
||||
// @todo(DICK)
|
||||
ExportSelectedFootprint( event );
|
||||
AddFootprintToPCB( event );
|
||||
|
||||
// Prevent the double click from being as a single mouse button release
|
||||
// event in the parent window which would cause the part to be parked
|
||||
// rather than staying in move mode.
|
||||
// Remember the mouse button will be released in the parent window
|
||||
// thus creating a mouse button release event which should be ignored
|
||||
PCB_EDIT_FRAME* pcbframe = dynamic_cast<PCB_EDIT_FRAME*>( GetParent() );
|
||||
// Prevent the double click from being as a single mouse button release
|
||||
// event in the parent window which would cause the part to be parked
|
||||
// rather than staying in move mode.
|
||||
// Remember the mouse button will be released in the parent window
|
||||
// thus creating a mouse button release event which should be ignored
|
||||
PCB_EDIT_FRAME* pcbframe = dynamic_cast<PCB_EDIT_FRAME*>( GetParent() );
|
||||
|
||||
// The parent may not be the board editor:
|
||||
if( pcbframe )
|
||||
{
|
||||
pcbframe->SkipNextLeftButtonReleaseEvent();
|
||||
}
|
||||
}
|
||||
// The parent may not be the board editor:
|
||||
if( pcbframe )
|
||||
pcbframe->SkipNextLeftButtonReleaseEvent();
|
||||
}
|
||||
|
||||
|
||||
void FOOTPRINT_VIEWER_FRAME::ExportSelectedFootprint( wxCommandEvent& event )
|
||||
void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& event )
|
||||
{
|
||||
int ii = m_footprintList->GetSelection();
|
||||
|
||||
if( ii >= 0 )
|
||||
if( IsModal() )
|
||||
{
|
||||
wxString fp_name = m_footprintList->GetString( ii );
|
||||
if( m_footprintList->GetSelection() >= 0 )
|
||||
{
|
||||
LIB_ID fpid( getCurNickname(), m_footprintList->GetStringSelection() );
|
||||
DismissModal( true, fpid.Format() );
|
||||
}
|
||||
else
|
||||
{
|
||||
DismissModal( false );
|
||||
}
|
||||
|
||||
LIB_ID fpid;
|
||||
|
||||
fpid.SetLibNickname( getCurNickname() );
|
||||
fpid.SetLibItemName( fp_name );
|
||||
|
||||
DismissModal( true, fpid.Format() );
|
||||
Close( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
DismissModal( false );
|
||||
}
|
||||
PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB, false );
|
||||
|
||||
Close( true );
|
||||
if( pcbframe == NULL ) // happens when the board editor is not active (or closed)
|
||||
{
|
||||
DisplayErrorMessage( this, _( "No board currently open." ) );
|
||||
return;
|
||||
}
|
||||
|
||||
pcbframe->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||
BOARD_COMMIT commit( pcbframe );
|
||||
|
||||
// Create the "new" module
|
||||
MODULE* newmodule = new MODULE( *GetBoard()->m_Modules );
|
||||
newmodule->SetParent( pcbframe->GetBoard() );
|
||||
newmodule->SetLink( 0 );
|
||||
|
||||
wxPoint cursor_pos = pcbframe->GetCrossHairPosition();
|
||||
|
||||
commit.Add( newmodule );
|
||||
pcbframe->SetCrossHairPosition( wxPoint( 0, 0 ) );
|
||||
pcbframe->PlaceModule( newmodule, NULL );
|
||||
newmodule->SetPosition( wxPoint( 0, 0 ) );
|
||||
pcbframe->SetCrossHairPosition( cursor_pos );
|
||||
newmodule->SetTimeStamp( GetNewTimeStamp() );
|
||||
commit.Push( wxT( "Insert module" ) );
|
||||
|
||||
if( pcbframe->IsGalCanvasActive() )
|
||||
{
|
||||
pcbframe->Raise();
|
||||
pcbframe->GetToolManager()->RunAction( PCB_ACTIONS::placeModule, true, newmodule );
|
||||
}
|
||||
|
||||
newmodule->ClearFlags();
|
||||
pcbframe->SetCurItem( NULL );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -735,12 +757,10 @@ void FOOTPRINT_VIEWER_FRAME::UpdateTitle()
|
|||
wxString path;
|
||||
|
||||
title.Printf( _( "Footprint Library Browser" ) + L" \u2014 %s",
|
||||
getCurNickname().size()
|
||||
? getCurNickname()
|
||||
: _( "no library selected" ) );
|
||||
getCurNickname().IsEmpty() ? _( "no library selected" ) : getCurNickname() );
|
||||
|
||||
// Now, add the full path, for info
|
||||
if( getCurNickname().size() )
|
||||
if( !getCurNickname().IsEmpty() )
|
||||
{
|
||||
FP_LIB_TABLE* libtable = Prj().PcbFootprintLibs();
|
||||
const LIB_TABLE_ROW* row = libtable->FindRow( getCurNickname() );
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2018 Jean-Pierre Charras, jap.charras at wanadoo.fr
|
||||
* Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -22,10 +22,6 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file footprint_viewer_frame.h
|
||||
*/
|
||||
|
||||
#ifndef FOOTPRINT_VIEWER_FRAME_H
|
||||
#define FOOTPRINT_VIEWER_FRAME_H
|
||||
|
||||
|
@ -167,10 +163,10 @@ private:
|
|||
void SelectCurrentFootprint( wxCommandEvent& event );
|
||||
|
||||
/**
|
||||
* Function ExportSelectedFootprint
|
||||
* Function AddFootprintToPCB
|
||||
* exports the current footprint name and close the library browser.
|
||||
*/
|
||||
void ExportSelectedFootprint( wxCommandEvent& event );
|
||||
void AddFootprintToPCB( wxCommandEvent& event );
|
||||
|
||||
/**
|
||||
* Function SelectAndViewFootprint
|
||||
|
|
|
@ -405,7 +405,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
|
|||
_( "Load a footprint from the current board into the editor" ),
|
||||
KiBitmap( load_module_board_xpm ) );
|
||||
|
||||
AddMenuItem( toolsMenu, ID_MODEDIT_INSERT_MODULE_IN_BOARD,
|
||||
AddMenuItem( toolsMenu, ID_ADD_FOOTPRINT_TO_BOARD,
|
||||
_( "&Insert Footprint on PCB" ),
|
||||
_( "Insert footprint onto current board" ),
|
||||
KiBitmap( insert_module_board_xpm ) );
|
||||
|
|
|
@ -345,7 +345,6 @@ enum pcbnew_ids
|
|||
ID_POPUP_MODEDIT_GLOBAL_EDIT_EDGE,
|
||||
ID_POPUP_MODEDIT_EDIT_WIDTH_ALL_EDGE,
|
||||
ID_POPUP_MODEDIT_EDIT_LAYER_ALL_EDGE,
|
||||
ID_POPUP_MODEDIT_EDIT_EDGE,
|
||||
ID_MODEDIT_CHECK,
|
||||
ID_MODEDIT_CREATE_NEW_LIB,
|
||||
ID_MODEDIT_ADD_LIBRARY,
|
||||
|
@ -363,7 +362,6 @@ enum pcbnew_ids
|
|||
ID_MODEDIT_EDIT_MODULE,
|
||||
ID_MODEDIT_PAD_SETTINGS,
|
||||
ID_MODEDIT_LOAD_MODULE_FROM_BOARD,
|
||||
ID_MODEDIT_INSERT_MODULE_IN_BOARD,
|
||||
ID_MODEDIT_EDIT_MODULE_PROPERTIES,
|
||||
ID_MODEDIT_TRANSFORM_MODULE,
|
||||
ID_MODEDIT_MODULE_ROTATE,
|
||||
|
@ -381,23 +379,17 @@ enum pcbnew_ids
|
|||
ID_MODVIEW_PREVIOUS,
|
||||
ID_MODVIEW_NEXT,
|
||||
ID_MODVIEW_SHOW_3D_VIEW,
|
||||
ID_MODVIEW_EXPORT_TO_BOARD,
|
||||
|
||||
ID_FOOTPRINT_WIZARD_WINDOW,
|
||||
ID_FOOTPRINT_WIZARD_PAGES,
|
||||
ID_FOOTPRINT_WIZARD_PARAMETERS,
|
||||
ID_FOOTPRINT_WIZARD_NEXT,
|
||||
ID_FOOTPRINT_WIZARD_PREVIOUS,
|
||||
ID_FOOTPRINT_WIZARD_DONE,
|
||||
ID_FOOTPRINT_WIZARD_SHOW_3D_VIEW,
|
||||
ID_FOOTPRINT_WIZARD_PAGE_LIST,
|
||||
ID_FOOTPRINT_WIZARD_PARAMETER_LIST,
|
||||
ID_FOOTPRINT_WIZARD_PAGES_WINDOW,
|
||||
ID_FOOTPRINT_WIZARD_PARAMETERS_WINDOW,
|
||||
ID_FOOTPRINT_WIZARD_SELECT_WIZARD,
|
||||
ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT,
|
||||
ID_FOOTPRINT_WIZARD_EXPORT_TO_BOARD,
|
||||
|
||||
ID_ADD_FOOTPRINT_TO_BOARD,
|
||||
ID_UPDATE_PCB_FROM_SCH,
|
||||
ID_RUN_EESCHEMA,
|
||||
ID_EDIT_CUT,
|
||||
|
|
|
@ -118,8 +118,8 @@ void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar()
|
|||
KiScaledBitmap( load_module_board_xpm, this ),
|
||||
_( "Load footprint from current board" ) );
|
||||
|
||||
m_mainToolBar->AddTool( ID_MODEDIT_INSERT_MODULE_IN_BOARD, wxEmptyString,
|
||||
KiScaledBitmap( insert_module_board_xpm, this ),
|
||||
m_mainToolBar->AddTool( ID_ADD_FOOTPRINT_TO_BOARD, wxEmptyString,
|
||||
KiScaledBitmap( export_xpm, this ),
|
||||
_( "Insert footprint into current board" ) );
|
||||
|
||||
#if 0 // Currently there is no check footprint function defined, so do not show this tool
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
|
@ -20,12 +20,6 @@
|
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file tool_footprint_viewer.cpp
|
||||
* @brief Build the toolbars for the footprint library browser.
|
||||
*/
|
||||
|
||||
|
||||
#include <dialog_helpers.h>
|
||||
#include <macros.h>
|
||||
#include <menus_helpers.h>
|
||||
|
@ -99,12 +93,9 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateHToolbar()
|
|||
KiScaledBitmap( three_d_xpm, this ),
|
||||
_( "Show footprint in 3D viewer" ) );
|
||||
|
||||
if( IsModal() )
|
||||
{
|
||||
m_mainToolBar->AddTool( ID_MODVIEW_EXPORT_TO_BOARD, wxEmptyString,
|
||||
KiScaledBitmap( export_footprint_names_xpm, this ),
|
||||
_( "Insert footprint in board" ) );
|
||||
}
|
||||
m_mainToolBar->AddTool( ID_ADD_FOOTPRINT_TO_BOARD, wxEmptyString,
|
||||
KiScaledBitmap( export_xpm, this ),
|
||||
_( "Insert footprint in board" ) );
|
||||
|
||||
KiScaledSeparator( m_mainToolBar, this );
|
||||
|
||||
|
|
Loading…
Reference in New Issue