This commit is contained in:
Jeff Young 2019-05-10 20:57:24 +01:00
parent a9f663d5ef
commit 792c4328aa
37 changed files with 197 additions and 587 deletions

View File

@ -1,25 +1,5 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2004-2011 KiCad Developers, see change_log.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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
/**
* OBSOLETE
*/
#include <fctsys.h>
@ -35,9 +15,6 @@ BLOCK_SELECTOR::BLOCK_SELECTOR() :
{
m_state = STATE_NO_BLOCK; // State (enum BLOCK_STATE_T) of block.
m_command = BLOCK_IDLE; // Type (enum BLOCK_COMMAND_T) of operation.
m_color = BROWN;
m_appendUndo = false; // Indicates at least one undo record has been saved and
// any additional undo records should be appended.
}

View File

@ -478,6 +478,8 @@ void EDA_DRAW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMod
void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
{
wxMessageBox( "EDA_DRAW_FRAME::OnSelectGrid(): should be handled by common tools now...." );
int* clientData;
int eventId = ID_POPUP_GRID_LEVEL_100;
@ -1234,6 +1236,8 @@ void EDA_DRAW_FRAME::Window_Zoom( EDA_RECT& Rect )
void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
{
wxMessageBox( "EDA_DRAW_FRAME::OnZoom(): should be handled by zoom tool now...." );
if( m_canvas == NULL )
return;

View File

@ -111,13 +111,10 @@ set( EESCHEMA_WIDGETS
set ( EESCHEMA_LIBEDIT_SRCS
libedit/controller.cpp
libedit/libedit.cpp
libedit/libedit_onrightclick.cpp
libedit/libedit_plot_component.cpp
libedit/libedit_undo_redo.cpp
libedit/lib_edit_frame.cpp
libedit/libfield.cpp
libedit/menubar_libedit.cpp
libedit/symbedit.cpp
libedit/toolbars_libedit.cpp
@ -142,7 +139,6 @@ set( EESCHEMA_SRCS
cmp_library_keywords.cpp
cmp_library_lexer.cpp
component_references_lister.cpp
controle.cpp
connection_graph.cpp
cross-probing.cpp
drc_erc_item.cpp
@ -192,7 +188,7 @@ set( EESCHEMA_SRCS
sch_eagle_plugin.cpp
sch_field.cpp
sch_io_mgr.cpp
sch_item_struct.cpp
sch_item.cpp
sch_junction.cpp
sch_legacy_plugin.cpp
sch_line.cpp
@ -209,7 +205,6 @@ set( EESCHEMA_SRCS
sch_validators.cpp
schematic_undo_redo.cpp
sch_edit_frame.cpp
selpart.cpp
sheet.cpp
symbol_lib_table.cpp
symbol_tree_model_adapter.cpp

View File

@ -27,7 +27,7 @@
#include <common.h>
#include <erc_settings.h>
#include <sch_connection.h>
#include <sch_item_struct.h>
#include <sch_item.h>
#ifdef DEBUG

View File

@ -1,67 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* 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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h>
#include <sch_draw_panel.h>
#include <sch_edit_frame.h>
#include <eeschema_id.h>
#include <ee_hotkeys.h>
#include <lib_edit_frame.h>
#include <viewlib_frame.h>
#include <sch_view.h>
bool LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
{
bool eventHandled = true;
// Filter out the 'fake' mouse motion after a keyboard movement
if( !aHotKey && m_movingCursorWithKeyboard )
{
m_movingCursorWithKeyboard = false;
return false;
}
wxPoint pos = aPosition;
GeneralControlKeyMovement( aHotKey, &pos, true );
// Update cursor position.
m_canvas->CrossHairOn( aDC );
SetCrossHairPosition( pos, true );
if( aHotKey )
{
SCH_SCREEN* screen = GetScreen();
if( screen->GetCurItem() && screen->GetCurItem()->GetEditFlags() )
eventHandled = OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() );
else
eventHandled = OnHotKey( aDC, aHotKey, aPosition, NULL );
}
UpdateStatusBar(); // Display cursor coordinates info.
return eventHandled;
}

View File

@ -39,7 +39,7 @@
#include <lib_edit_frame.h>
#include <class_library.h>
#include <symbol_lib_table.h>
#include <sch_item_struct.h>
#include <sch_item.h>
#include <sch_component.h>
#include <dialog_helpers.h>
#include <bitmaps.h>

View File

@ -27,7 +27,7 @@
#include <collector.h>
#include <sch_item_struct.h>
#include <sch_item.h>
#include <sch_sheet_path.h>
#include <dialogs/dialog_schematic_find.h>

View File

@ -1,84 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* 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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h>
#include <gr_basic.h>
#include <sch_draw_panel.h>
#include <eda_dde.h>
#include <sch_edit_frame.h>
#include <menus_helpers.h>
#include <msgpanel.h>
#include <bitmaps.h>
#include <eeschema_id.h>
#include <general.h>
#include <ee_hotkeys.h>
#include <lib_edit_frame.h>
#include <viewlib_frame.h>
#include <lib_draw_item.h>
#include <lib_pin.h>
#include <sch_sheet.h>
#include <sch_sheet_path.h>
#include <sch_marker.h>
#include <sch_component.h>
#include <sch_view.h>
bool LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
{
bool keyHandled = false;
wxPoint pos = aPosition;
// Filter out the 'fake' mouse motion after a keyboard movement
if( !aHotKey && m_movingCursorWithKeyboard )
{
m_movingCursorWithKeyboard = false;
return false;
}
if( aHotKey )
keyHandled = GeneralControlKeyMovement( aHotKey, &pos, true );
if( GetToolId() == ID_NO_TOOL_SELECTED )
m_canvas->CrossHairOff( aDC );
else
m_canvas->CrossHairOn( aDC );
GetGalCanvas()->GetViewControls()->SetSnapping( false );
SetCrossHairPosition( pos, false );
if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( aDC, aPosition, true );
if( aHotKey && OnHotKey( aDC, aHotKey, aPosition, NULL ) )
keyHandled = true;
// Make sure current-part highlighting doesn't get lost in seleciton highlighting
ClearSearchTreeSelection();
UpdateStatusBar();
return keyHandled;
}

View File

@ -115,9 +115,6 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
// Main horizontal toolbar.
EVT_TOOL( ID_TO_LIBVIEW, LIB_EDIT_FRAME::OnOpenLibraryViewer )
EVT_TOOL( wxID_COPY, LIB_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( wxID_PASTE, LIB_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( wxID_CUT, LIB_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( wxID_UNDO, LIB_EDIT_FRAME::GetComponentFromUndoList )
EVT_TOOL( wxID_REDO, LIB_EDIT_FRAME::GetComponentFromRedoList )
EVT_TOOL( ID_LIBEDIT_GET_FRAME_EDIT_PART, LIB_EDIT_FRAME::OnEditComponentProperties )
@ -125,16 +122,15 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_TOOL( ID_DE_MORGAN_NORMAL_BUTT, LIB_EDIT_FRAME::OnSelectBodyStyle )
EVT_TOOL( ID_DE_MORGAN_CONVERT_BUTT, LIB_EDIT_FRAME::OnSelectBodyStyle )
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_SYNC_PIN_EDIT, LIB_EDIT_FRAME::OnSyncPinEditClick )
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::OnSelectUnit )
// Right vertical toolbar.
EVT_TOOL( ID_NO_TOOL_SELECTED, LIB_EDIT_FRAME::OnSelectTool )
EVT_TOOL_RANGE( ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_DELETE_ITEM_BUTT,
LIB_EDIT_FRAME::OnSelectTool )
EVT_TOOL( ID_LIBEDIT_IMPORT_BODY_BUTT, LIB_EDIT_FRAME::OnImportBody )
EVT_TOOL( ID_LIBEDIT_EXPORT_BODY_BUTT, LIB_EDIT_FRAME::OnExportBody )
// Left vertical toolbar (option toolbar).
EVT_TOOL( ID_LIBEDIT_SHOW_ELECTRICAL_TYPE, LIB_EDIT_FRAME::OnShowElectricalType )
@ -156,14 +152,6 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, LIB_EDIT_FRAME::Process_Config )
// Context menu events and commands.
EVT_MENU_RANGE( ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_ITEM,
ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT,
LIB_EDIT_FRAME::Process_Special_Functions )
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
LIB_EDIT_FRAME::Process_Special_Functions )
// Update user interface elements.
EVT_UPDATE_UI( wxID_PASTE, LIB_EDIT_FRAME::OnUpdatePaste )
EVT_UPDATE_UI( ID_LIBEDIT_EXPORT_PART, LIB_EDIT_FRAME::OnUpdateHavePart )
@ -522,7 +510,8 @@ void LIB_EDIT_FRAME::OnUpdateUndo( wxUpdateUIEvent& event )
{
EE_SELECTION_TOOL* selTool = m_toolManager->GetTool<EE_SELECTION_TOOL>();
event.Enable( GetCurPart() && GetScreen()
event.Enable( GetCurPart()
&& GetScreen()
&& GetScreen()->GetUndoCommandCount() != 0
&& EE_CONDITIONS::Idle( selTool->GetSelection() ) );
}
@ -532,7 +521,8 @@ void LIB_EDIT_FRAME::OnUpdateRedo( wxUpdateUIEvent& event )
{
EE_SELECTION_TOOL* selTool = m_toolManager->GetTool<EE_SELECTION_TOOL>();
event.Enable( GetCurPart() && GetScreen()
event.Enable( GetCurPart()
&& GetScreen()
&& GetScreen()->GetRedoCommandCount() != 0
&& EE_CONDITIONS::Idle( selTool->GetSelection() ) );
}
@ -568,9 +558,6 @@ void LIB_EDIT_FRAME::OnUpdatePartNumber( wxUpdateUIEvent& event )
void LIB_EDIT_FRAME::OnUpdateDeMorganNormal( wxUpdateUIEvent& event )
{
if( m_mainToolBar == NULL )
return;
LIB_PART* part = GetCurPart();
event.Enable( GetShowDeMorgan() || ( part && part->HasConversion() ) );
@ -580,9 +567,6 @@ void LIB_EDIT_FRAME::OnUpdateDeMorganNormal( wxUpdateUIEvent& event )
void LIB_EDIT_FRAME::OnUpdateDeMorganConvert( wxUpdateUIEvent& event )
{
if( m_mainToolBar == NULL )
return;
LIB_PART* part = GetCurPart();
event.Enable( GetShowDeMorgan() || ( part && part->HasConversion() ) );
@ -657,18 +641,9 @@ void LIB_EDIT_FRAME::OnSelectBodyStyle( wxCommandEvent& event )
}
void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
void LIB_EDIT_FRAME::OnSyncPinEditClick( wxCommandEvent& event )
{
switch( event.GetId() )
{
case ID_LIBEDIT_SYNC_PIN_EDIT:
m_syncPinEdit = m_mainToolBar->GetToolToggled( ID_LIBEDIT_SYNC_PIN_EDIT );
break;
default:
wxFAIL_MSG( "LIB_EDIT_FRAME::Process_Special_Functions error" );
break;
}
}
@ -789,35 +764,26 @@ void LIB_EDIT_FRAME::OnEditComponentProperties( wxCommandEvent& event )
DisplayCmpDoc();
RebuildView();
GetCanvas()->Refresh();
OnModify();
}
void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
void LIB_EDIT_FRAME::OnImportBody( wxCommandEvent& aEvent )
{
int id = aEvent.GetId();
switch( id )
{
case ID_LIBEDIT_IMPORT_BODY_BUTT:
m_toolManager->DeactivateTool();
SetToolID( id, GetGalCanvas()->GetDefaultCursor(), _( "Import" ) );
SetToolID( ID_LIBEDIT_IMPORT_BODY_BUTT, GetGalCanvas()->GetDefaultCursor(), _( "Import" ) );
LoadOneSymbol();
SetNoToolSelected();
break;
m_canvas->SetIgnoreMouseEvents( false );
}
case ID_LIBEDIT_EXPORT_BODY_BUTT:
void LIB_EDIT_FRAME::OnExportBody( wxCommandEvent& aEvent )
{
m_toolManager->DeactivateTool();
SetToolID( id, GetGalCanvas()->GetDefaultCursor(), _( "Export" ) );
SetToolID( ID_LIBEDIT_EXPORT_BODY_BUTT, GetGalCanvas()->GetDefaultCursor(), _( "Export" ) );
SaveOneSymbol();
SetNoToolSelected();
break;
default:
break;
}
m_canvas->SetIgnoreMouseEvents( false );
}
@ -845,7 +811,6 @@ void LIB_EDIT_FRAME::OnOpenPinTable( wxCommandEvent& aEvent )
return;
RebuildView();
GetCanvas()->Refresh();
OnModify();
}
@ -925,8 +890,7 @@ bool LIB_EDIT_FRAME::addLibraryFile( bool aCreateNew )
{
if( !m_libMgr->CreateLibrary( fn.GetFullPath(), libTable ) )
{
DisplayError( this,
wxString::Format( _( "Could not create the library file \"%s\".\n"
DisplayError( this, wxString::Format( _( "Could not create the library file '%s'.\n"
"Check write permission." ),
fn.GetFullPath() ) );
return false;
@ -1249,3 +1213,42 @@ void LIB_EDIT_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent )
// Set options specific to symbol editor (axies are always enabled):
GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
}
bool LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
{
bool keyHandled = false;
wxPoint pos = aPosition;
// Filter out the 'fake' mouse motion after a keyboard movement
if( !aHotKey && m_movingCursorWithKeyboard )
{
m_movingCursorWithKeyboard = false;
return false;
}
if( aHotKey )
keyHandled = GeneralControlKeyMovement( aHotKey, &pos, true );
if( GetToolId() == ID_NO_TOOL_SELECTED )
m_canvas->CrossHairOff( aDC );
else
m_canvas->CrossHairOn( aDC );
GetGalCanvas()->GetViewControls()->SetSnapping( false );
SetCrossHairPosition( pos, false );
if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( aDC, aPosition, true );
if( aHotKey && OnHotKey( aDC, aHotKey, aPosition, NULL ) )
keyHandled = true;
// Make sure current-part highlighting doesn't get lost in seleciton highlighting
ClearSearchTreeSelection();
UpdateStatusBar();
return keyHandled;
}

View File

@ -206,8 +206,10 @@ public:
* Plot the current symbol in SVG or PNG format.
*/
void OnPlotCurrentComponent( wxCommandEvent& event );
void Process_Special_Functions( wxCommandEvent& event );
void OnSelectTool( wxCommandEvent& aEvent );
void OnSyncPinEditClick( wxCommandEvent& event );
void OnImportBody( wxCommandEvent& aEvent );
void OnExportBody( wxCommandEvent& aEvent );
/**
* Creates a new library. The library is added to the project libraries table.
@ -431,6 +433,16 @@ private:
*/
void SelectActiveLibrary( const wxString& aLibrary = wxEmptyString );
/**
* Dispaly a list of loaded libraries in the symbol library and allows the user to select
* a library.
*
* This list is sorted, with the library cache always at end of the list
*
* @return the library nickname used in the symbol library table.
*/
wxString SelectLibraryFromList();
/**
* Loads a symbol from the current active library, optionally setting the selected
* unit and convert.

View File

@ -23,11 +23,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file libedit.cpp
* @brief Eeschema component library editor.
*/
#include <fctsys.h>
#include <kiway.h>
#include <gr_basic.h>
@ -82,6 +77,54 @@ void LIB_EDIT_FRAME::SelectActiveLibrary( const wxString& aLibrary )
}
wxString LIB_EDIT_FRAME::SelectLibraryFromList()
{
PROJECT& prj = Prj();
if( prj.SchSymbolLibTable()->IsEmpty() )
{
DisplayError( this, _( "No symbol libraries are loaded." ) );
return wxEmptyString;
}
wxArrayString headers;
headers.Add( _( "Library" ) );
std::vector< wxArrayString > itemsToDisplay;
std::vector< wxString > libNicknames = prj.SchSymbolLibTable()->GetLogicalLibs();
// Conversion from wxArrayString to vector of ArrayString
for( const auto& name : libNicknames )
{
wxArrayString item;
item.Add( name );
itemsToDisplay.push_back( item );
}
wxString old_lib_name = prj.GetRString( PROJECT::SCH_LIB_SELECT );
EDA_LIST_DIALOG dlg( this, _( "Select Symbol Library" ), headers, itemsToDisplay,
old_lib_name );
if( dlg.ShowModal() != wxID_OK )
return wxEmptyString;
wxString libname = dlg.GetTextSelection();
if( !libname.empty() )
{
if( prj.SchSymbolLibTable()->HasLibrary( libname ) )
prj.SetRString( PROJECT::SCH_LIB_SELECT, libname );
else
libname = wxEmptyString;
}
return libname;
}
bool LIB_EDIT_FRAME::saveCurrentPart()
{
if( GetCurPart() )

View File

@ -1,29 +0,0 @@
#if 0
case LIB_POLYLINE_T:
if( item->IsNew() )
{
if( ( (LIB_POLYLINE*) item )->GetCornerCount() > 2 )
{
msg = AddHotkeyName( _( "Delete" ), g_Libedit_Hotkeys_Descr, HK_DELETE );
AddMenuItem( PopMenu, ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT,
msg, KiBitmap( delete_xpm ) );
}
}
break;
//===============================================
case ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT:
{
// Delete the last created segment, while creating a polyline draw item
if( item == NULL )
break;
m_canvas->MoveCursorToCrossHair();
static_cast<LIB_POLYLINE*>( item )->DeleteSegment( GetCrossHairPosition( true ) );
}
break;
#endif

View File

@ -97,7 +97,6 @@ void LIB_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event )
updateTitle();
RebuildView();
GetCanvas()->Refresh();
OnModify();
}
@ -146,7 +145,6 @@ void LIB_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event )
updateTitle();
RebuildView();
GetCanvas()->Refresh();
OnModify();
}
@ -167,5 +165,4 @@ void LIB_EDIT_FRAME::RollbackPartFromUndo()
SetShowDeMorgan( part->HasConversion() );
RebuildView();
GetCanvas()->Refresh();
}

View File

@ -1,41 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2007 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2007-2017 KiCad Developers, see CHANGELOG.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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h>
#include <gr_basic.h>
#include <sch_draw_panel.h>
#include <confirm.h>
#include <sch_view.h>
#include <sch_component.h>
#include <lib_edit_frame.h>
#include <class_library.h>
#include <symbol_lib_table.h>
#include <template_fieldnames.h>
#include <dialog_edit_one_field.h>
#include <lib_manager.h>
#include <widgets/symbol_tree_pane.h>
#include <widgets/lib_tree.h>

View File

@ -34,7 +34,7 @@
#include <sch_sheet_path.h>
#include <lib_pin.h>
#include <sch_item_struct.h>
#include <sch_item.h>
class NETLIST_OBJECT_LIST;
class SCH_COMPONENT;

View File

@ -338,44 +338,6 @@ protected:
*/
void OnOpenLibraryViewer( wxCommandEvent& event );
/**
* Select a component from the list of components in a library
*
* @param aLibrary a reference to the library nickname to explore
* If empty, the user will be prompted tp chose a library
* @param aBuffer = a wxString to put the selected component name
* @param aPreviousChoice = the previously selected component name.
* it will be added to the selection list. Can be empty.
*
* @return true if a component is selected
* false on cancel
*/
bool DisplayListComponentsInLib( wxString& aLibrary, wxString& aBuffer,
wxString& aPreviousChoice );
/**
* Dispaly a list of loaded libraries in the symbol library and allows the user to select
* a library.
*
* This list is sorted, with the library cache always at end of the list
*
* @return the library nickname used in the symbol library table.
*/
wxString SelectLibraryFromList();
/**
* Function SelectPartNameToLoad
* Select a part name from the list of components (parts) found in a library.
*
* @param aLibrary is the nickname of the library in the symbol library table.
* If empty the user will be prompted tp chose a library
* @param aBufName a wxString to put the selected component name
*
* @return true if a component is selected
* false on cancel
*/
bool SelectPartNameToLoad( wxString& aLibrary, wxString& aBufName );
/**
* Saves Symbol Library Tables to disk.
*

View File

@ -31,7 +31,7 @@
#define _SCH_BITMAP_H_
#include <sch_item_struct.h>
#include <sch_item.h>
#include <bitmap_base.h>

View File

@ -30,7 +30,7 @@
#ifndef _SCH_BUS_ENTRY_H_
#define _SCH_BUS_ENTRY_H_
#include <sch_item_struct.h>
#include <sch_item.h>
#define TARGET_BUSENTRY_RADIUS 12 // Circle diameter drawn at the ends

View File

@ -27,7 +27,7 @@
#include <eda_text.h>
#include <sch_item_struct.h>
#include <sch_item.h>
#include <template_fieldnames.h>
#include <general.h>

View File

@ -27,7 +27,7 @@
#include <gr_basic.h>
#include <base_struct.h>
#include <trace_helpers.h>
#include <sch_item_struct.h>
#include <sch_item.h>
#include <sch_screen.h>
#include <sch_sheet_path.h>
#include <sch_draw_panel.h>

View File

@ -22,13 +22,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file sch_item_struct.h
* @brief Base schematic object class definition.
*/
#ifndef SCH_ITEM_STRUCT_H
#define SCH_ITEM_STRUCT_H
#ifndef SCH_ITEM_H
#define SCH_ITEM_H
#include <unordered_map>
#include <unordered_set>
@ -39,7 +34,6 @@
#include <sch_sheet_path.h>
class SCH_ITEM;
//class SCH_SHEET_PATH;
class SCH_CONNECTION;
class LINE_READER;
class SCH_EDIT_FRAME;
@ -420,4 +414,4 @@ private:
virtual bool doIsConnected( const wxPoint& aPosition ) const { return false; }
};
#endif /* SCH_ITEM_STRUCT_H */
#endif /* SCH_ITEM_H */

View File

@ -26,7 +26,7 @@
#define _SCH_JUNCTION_H_
#include <sch_item_struct.h>
#include <sch_item.h>
class NETLIST_OBJECT_LIST;
class SCH_JUNCTION : public SCH_ITEM

View File

@ -25,7 +25,7 @@
#ifndef _SCH_LINE_H_
#define _SCH_LINE_H_
#include <sch_item_struct.h>
#include <sch_item.h>
class NETLIST_OBJECT_LIST;

View File

@ -25,7 +25,7 @@
#ifndef TYPE_SCH_MARKER_H_
#define TYPE_SCH_MARKER_H_
#include <sch_item_struct.h>
#include <sch_item.h>
#include <marker_base.h>

View File

@ -30,7 +30,7 @@
#define _SCH_NO_CONNECT_H_
#include <sch_item_struct.h>
#include <sch_item.h>
class NETLIST_OBJECT_LIST;

View File

@ -24,7 +24,7 @@
*/
#include <sch_item_struct.h>
#include <sch_item.h>
#include <lib_draw_item.h>
#include <lib_rectangle.h>

View File

@ -22,7 +22,7 @@
#ifndef _SCH_PIN_CONNECTION_H
#define _SCH_PIN_CONNECTION_H
#include <sch_item_struct.h>
#include <sch_item.h>
#include <sch_sheet_path.h>
#include <lib_pin.h>

View File

@ -37,7 +37,7 @@
#include <pgm_base.h>
#include <kiway.h>
#include <sch_draw_panel.h>
#include <sch_item_struct.h>
#include <sch_item.h>
#include <draw_graphic_text.h>
#include <sch_edit_frame.h>
#include <plotter.h>

View File

@ -34,7 +34,7 @@
#include <macros.h>
#include <dlist.h>
#include <sch_item_struct.h>
#include <sch_item.h>
#include <lib_draw_item.h>
#include <base_screen.h>
#include <title_block.h>

View File

@ -32,7 +32,7 @@
#include <dlist.h>
#include <sch_screen.h>
#include <sch_item_struct.h>
#include <sch_item.h>
#include <sch_reference_list.h>
#include <class_library.h>

View File

@ -33,7 +33,7 @@
#include <macros.h>
#include <eda_text.h>
#include <sch_item_struct.h>
#include <sch_item.h>
#include <sch_connection.h> // for CONNECTION_TYPE

View File

@ -1,186 +0,0 @@
/*
* 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-2017 KiCad Developers, see CHANGELOG.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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file selpart.cpp
*/
#include <fctsys.h>
#include <gr_basic.h>
#include <confirm.h>
#include <pgm_base.h>
#include <sch_base_frame.h>
#include <symbol_lib_table.h>
#include <general.h>
#include <class_library.h>
#include <dialog_helpers.h>
static void DisplayCmpDocAndKeywords( wxString& aSelection, void* aData )
{
SYMBOL_LIB_TABLE* libs = (SYMBOL_LIB_TABLE*) aData;
wxASSERT( libs );
LIB_ID id;
if( id.Parse( aSelection, LIB_ID::ID_SCH ) != -1 )
{
aSelection = _( "Invalid symbol library identifier!" );
return;
}
LIB_ALIAS* part = nullptr;
try
{
part = libs->LoadSymbol( id );
}
catch( const IO_ERROR& )
{
aSelection.Printf( _( "Error occurred loading symbol \"%s\" from library \"%s\"." ),
id.GetLibItemName().wx_str(), id.GetLibNickname().wx_str() );
return;
}
if( !part )
return;
aSelection = _( "Description:" ) + " " + part->GetDescription() + "\n";
aSelection += _( "Key words:" ) + " " + part->GetKeyWords();
}
wxString SCH_BASE_FRAME::SelectLibraryFromList()
{
PROJECT& prj = Prj();
if( prj.SchSymbolLibTable()->IsEmpty() )
{
DisplayError( this, _( "No symbol libraries are loaded." ) );
return wxEmptyString;
}
wxArrayString headers;
headers.Add( _( "Library" ) );
std::vector< wxArrayString > itemsToDisplay;
std::vector< wxString > libNicknames = prj.SchSymbolLibTable()->GetLogicalLibs();
// Conversion from wxArrayString to vector of ArrayString
for( const auto& name : libNicknames )
{
wxArrayString item;
item.Add( name );
itemsToDisplay.push_back( item );
}
wxString old_lib_name = prj.GetRString( PROJECT::SCH_LIB_SELECT );
EDA_LIST_DIALOG dlg( this, _( "Select Symbol Library" ), headers, itemsToDisplay,
old_lib_name );
if( dlg.ShowModal() != wxID_OK )
return wxEmptyString;
wxString libname = dlg.GetTextSelection();
if( !libname.empty() )
{
if( prj.SchSymbolLibTable()->HasLibrary( libname ) )
prj.SetRString( PROJECT::SCH_LIB_SELECT, libname );
else
libname = wxEmptyString;
}
return libname;
}
bool SCH_BASE_FRAME::DisplayListComponentsInLib( wxString& aLibrary, wxString& aBuffer,
wxString& aPreviousChoice )
{
wxArrayString nameList;
if( !aLibrary )
aLibrary = SelectLibraryFromList();
if( !aLibrary )
return false;
try
{
Prj().SchSymbolLibTable()->EnumerateSymbolLib( aLibrary, nameList );
}
catch( const IO_ERROR& ioe )
{
wxString msg;
msg.Printf( _( "Error occurred loading symbol library \"%s\"." ), aLibrary );
DisplayErrorMessage( this, msg, ioe.What() );
return false;
}
wxArrayString headers;
headers.Add( _( "Library:Symbol" ) );
std::vector<wxArrayString> itemsToDisplay;
// Conversion from wxArrayString to vector of ArrayString
for( unsigned i = 0; i < nameList.GetCount(); i++ )
{
LIB_ID id;
wxArrayString item;
id.SetLibItemName( nameList[i], false );
id.SetLibNickname( aLibrary );
item.Add( id.Format() );
itemsToDisplay.push_back( item );
}
EDA_LIST_DIALOG dlg( this, _( "Select Symbol" ), headers, itemsToDisplay, aPreviousChoice,
DisplayCmpDocAndKeywords, Prj().SchSymbolLibTable() );
if( dlg.ShowModal() != wxID_OK )
return false;
aBuffer = dlg.GetTextSelection();
return true;
}
bool SCH_BASE_FRAME::SelectPartNameToLoad( wxString& aLibrary, wxString& aBufName )
{
static wxString previousCmpName;
if( !DisplayListComponentsInLib( aLibrary, aBufName, previousCmpName ) || aBufName.empty() )
return false;
previousCmpName = aBufName;
return true;
}

View File

@ -24,7 +24,7 @@
#include <ee_actions.h>
#include <core/typeinfo.h>
#include <sch_item_struct.h>
#include <sch_item.h>
#include <ee_selection_tool.h>
#include <sch_base_frame.h>
#include <sch_edit_frame.h>

View File

@ -33,14 +33,14 @@
#include <confirm.h>
#include <eda_doc.h>
#include <base_struct.h>
#include <sch_item_struct.h>
#include <sch_item.h>
#include <sch_component.h>
#include <sch_sheet.h>
#include <sch_text.h>
#include <sch_bitmap.h>
#include <sch_view.h>
#include <sch_line.h>
#include <sch_item_struct.h>
#include <sch_item.h>
#include <sch_bus_entry.h>
#include <sch_edit_frame.h>
#include <eeschema_id.h>

View File

@ -28,7 +28,7 @@
#include <ee_hotkeys.h>
#include <bitmaps.h>
#include <base_struct.h>
#include <sch_item_struct.h>
#include <sch_item.h>
#include <sch_component.h>
#include <sch_sheet.h>
#include <sch_view.h>

View File

@ -25,7 +25,7 @@
#include <functional>
#include <tool/selection.h>
#include <sch_item_struct.h>
#include <sch_item.h>
VECTOR2I SELECTION::GetPosition() const

View File

@ -36,7 +36,6 @@
#include <general.h>
#include <viewlib_frame.h>
#include <symbol_lib_table.h>
#include <sch_legacy_plugin.h>
#include <ee_hotkeys.h>
#include <dialog_helpers.h>
#include <class_libentry.h>
@ -236,9 +235,6 @@ void LIB_VIEW_FRAME::setupTools()
m_toolManager->InitTools();
// Run the selection tool, it is supposed to be always active
m_toolManager->InvokeTool( "eeschema.InteractiveSelection" );
GetCanvas()->SetEventDispatcher( m_toolDispatcher );
}
@ -856,3 +852,37 @@ void LIB_VIEW_FRAME::OnAddPartToSchematic( wxCommandEvent& aEvent )
schframe->GetToolManager()->RunAction( EE_ACTIONS::placeSymbol, true, component );
}
}
bool LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
{
bool eventHandled = true;
// Filter out the 'fake' mouse motion after a keyboard movement
if( !aHotKey && m_movingCursorWithKeyboard )
{
m_movingCursorWithKeyboard = false;
return false;
}
wxPoint pos = aPosition;
GeneralControlKeyMovement( aHotKey, &pos, true );
// Update cursor position.
m_canvas->CrossHairOn( aDC );
SetCrossHairPosition( pos, true );
if( aHotKey )
{
SCH_SCREEN* screen = GetScreen();
if( screen->GetCurItem() && screen->GetCurItem()->GetEditFlags() )
eventHandled = OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() );
else
eventHandled = OnHotKey( aDC, aHotKey, aPosition, NULL );
}
UpdateStatusBar(); // Display cursor coordinates info.
return eventHandled;
}