Eeschema: code cleaning, remove dead code and not used #define or#include in some cpp files.

This commit is contained in:
jean-pierre charras 2015-02-20 09:17:54 +01:00
parent 6c7744e286
commit 11e2bdf17b
15 changed files with 139 additions and 283 deletions

View File

@ -84,7 +84,6 @@ set( EESCHEMA_SRCS
component_references_lister.cpp
controle.cpp
cross-probing.cpp
database.cpp
${EESCHEMA_DLGS}
edit_component_in_schematic.cpp
edit_bitmap.cpp

View File

@ -1,132 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2013 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
*/
/**
* @file database.cpp
*/
#include <fctsys.h>
#include <confirm.h>
#include <eda_doc.h>
#include <kicad_string.h>
#include <draw_frame.h>
#include <macros.h>
#include <protos.h>
#include <class_library.h>
#include <dialog_helpers.h>
#include <boost/foreach.hpp>
// Used in DataBaseGetName: this is a callback function for EDA_LIST_DIALOG
// to display keywords and description of a component
void DisplayCmpDocAndKeywords( wxString& aName, void* aData )
{
PART_LIBS* libs = (PART_LIBS*) aData;
wxASSERT( libs );
LIB_ALIAS* part = libs->FindLibraryEntry( aName );
if( !part )
return;
aName = wxT( "Description: " ) + part->GetDescription();
aName += wxT( "\nKey Words: " ) + part->GetKeyWords();
}
#if 0 // not used, should be wxFrame member for KIWAY and PROJECT access.
/*
* Displays a list of filtered components found in libraries for selection,
* Keys is a list of keywords to filter components which do not match these keywords
* If Keys is empty, list components that match BufName mask (with * and?)
*
* Returns the name of the selected component, or an empty string
*/
wxString DataBaseGetName( EDA_DRAW_FRAME* frame, wxString& Keys, wxString& BufName )
{
std::vector<wxArrayString> nameList;
wxString msg;
// BufName.MakeUpper();
Keys.MakeUpper();
/* Review the list of libraries for counting. */
BOOST_FOREACH( PART_LIB& lib, PART_LIB::GetLibraryList() )
{
lib.SearchEntryNames( nameList, BufName, Keys );
}
if( nameList.empty() )
{
if( !BufName.IsEmpty() )
{
if( !Keys.IsEmpty() )
{
msg.Printf( _( "No components found matching name search criteria '%s' and key search criteria '%s'" ),
GetChars( BufName ), GetChars( Keys ) );
}
else
{
msg.Printf( _( "No components found matching name search criteria '%s'" ),
GetChars( BufName ) );
}
}
else
{
if( !Keys.IsEmpty() )
{
msg.Printf( _( "No components found matching key search criteria '%s'" ),
GetChars( Keys ) );
}
else
{
msg = _( "No components found matching" );
}
}
DisplayInfoMessage( frame, msg );
return wxEmptyString;
}
wxArrayString headers;
headers.Add( _( "Component" ) );
headers.Add( _( "Library" ) );
// Show candidate list:
wxString cmpname;
EDA_LIST_DIALOG dlg( frame, _( "Select Component" ), headers, nameList, cmpname,
DisplayCmpDocAndKeywords, true );
if( dlg.ShowModal() != wxID_OK )
return wxEmptyString;
cmpname = dlg.GetTextSelection();
return cmpname;
}
#endif

View File

@ -43,7 +43,6 @@
#include <base_units.h>
#include <general.h>
#include <protos.h>
#include <class_library.h>
#include <lib_pin.h>
#include <sch_marker.h>

View File

@ -40,7 +40,6 @@
#include <eeschema_id.h>
#include <general.h>
#include <protos.h>
#include <libeditframe.h>
#include <class_library.h>
#include <template_fieldnames.h>
@ -73,7 +72,7 @@ void LIB_EDIT_FRAME::DisplayLibInfos()
void LIB_EDIT_FRAME::SelectActiveLibrary( PART_LIB* aLibrary )
{
if( !aLibrary )
aLibrary = SelectLibraryFromList( this );
aLibrary = SelectLibraryFromList();
if( aLibrary )
{

View File

@ -39,7 +39,6 @@
#include <msgpanel.h>
#include <general.h>
#include <protos.h>
#include <eeschema_id.h>
#include <libeditframe.h>
#include <class_library.h>

View File

@ -41,7 +41,6 @@
#include <class_libentry.h>
#include <lib_pin.h>
#include <general.h>
#include <protos.h>
#include <../common/dialogs/dialog_display_info_HTML_base.h>
#include <dialog_lib_edit_pin.h>

View File

@ -29,13 +29,9 @@
#include <colors.h>
class EDA_DRAW_PANEL;
class EDA_DRAW_FRAME;
class PICKED_ITEMS_LIST;
class PART_LIB;
class SCH_ITEM;
//void DisplayCmpDoc( wxString& Name );
wxString DataBaseGetName( EDA_DRAW_FRAME* frame, wxString& Keys, wxString& BufName );
// operations_on_item_lists.cpp
void DeleteItemsInList( EDA_DRAW_PANEL* panel, PICKED_ITEMS_LIST& aItemsList );
@ -59,43 +55,4 @@ void DrawDanglingSymbol( EDA_DRAW_PANEL* panel, wxDC* DC,
const wxPoint& pos, EDA_COLOR_T Color );
/***************/
/* SELPART.CPP */
/***************/
/**
* Function DisplayComponentsNamesInLib
* Select component from list of components in this library
*
* If == NULL Library, selection of library REQUESTED
* If only in research library
*
* Returns
* 1 if selected component
* 0 if canceled order
*/
int DisplayComponentsNamesInLib( EDA_DRAW_FRAME* frame,
PART_LIB* Library,
wxString& Buffer,
wxString& OldName );
/**
* Function SelectLibraryFromList
* displays a list of current loaded libraries, and allows the user to select
* a library
* This list is sorted, with the library cache always at end of the list
*/
PART_LIB* SelectLibraryFromList( EDA_DRAW_FRAME* frame );
/**
* Get the name component from a library to load.
*
* If no library specified, there will be demand for selection of a library.
* Returns
* 1 if selected component
* 0 if canceled order
* Place the name of the selected component list in BufName
*/
int GetNameOfPartToLoad( EDA_DRAW_FRAME* frame, PART_LIB* Lib, wxString& BufName );
#endif /* __PROTOS_H__ */

View File

@ -38,7 +38,6 @@
#include <eeschema_config.h>
#include <general.h>
#include <protos.h>
#include <sch_bus_entry.h>

View File

@ -46,7 +46,6 @@
#include <plot_common.h>
#include <general.h>
#include <protos.h>
#include <class_library.h>
#include <sch_component.h>
#include <sch_field.h>

View File

@ -1,8 +1,8 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2015 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
@ -31,8 +31,6 @@
#include <gr_basic.h>
#include <macros.h>
#include <class_drawpanel.h>
#include <trigo.h>
#include <richio.h>
#include <plot_common.h>
#include <base_units.h>
#include <eeschema_config.h>

View File

@ -1,8 +1,8 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2015 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
@ -32,12 +32,9 @@
#include <macros.h>
#include <class_drawpanel.h>
#include <common.h>
#include <trigo.h>
#include <richio.h>
#include <plot_common.h>
#include <general.h>
#include <protos.h>
#include <sch_no_connect.h>
#include <class_netlist_object.h>

View File

@ -1,8 +1,8 @@
/*
* 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) 2014 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2015 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
@ -29,23 +29,40 @@
#include <fctsys.h>
#include <gr_basic.h>
#include <confirm.h>
#include <draw_frame.h>
#include <pgm_base.h>
#include <sch_base_frame.h>
#include <general.h>
#include <protos.h>
#include <class_library.h>
#include <dialog_helpers.h>
PART_LIB* SelectLibraryFromList( EDA_DRAW_FRAME* aFrame )
// Used in DisplayListComponentsInLib: this is a callback function for EDA_LIST_DIALOG
// to display keywords and description of a component
static void DisplayCmpDocAndKeywords( wxString& aName, void* aData )
{
PROJECT& prj = aFrame->Prj();
PART_LIBS* libs = (PART_LIBS*) aData;
wxASSERT( libs );
LIB_ALIAS* part = libs->FindLibraryEntry( aName );
if( !part )
return;
aName = wxT( "Description: " ) + part->GetDescription();
aName += wxT( "\nKey Words: " ) + part->GetKeyWords();
}
PART_LIB* SCH_BASE_FRAME::SelectLibraryFromList()
{
PROJECT& prj = Prj();
if( PART_LIBS* libs = prj.SchLibs() )
{
if( !libs->GetLibraryCount() )
{
DisplayError( aFrame, _( "No component libraries are loaded." ) );
DisplayError( this, _( "No component libraries are loaded." ) );
return NULL;
}
@ -69,7 +86,7 @@ PART_LIB* SelectLibraryFromList( EDA_DRAW_FRAME* aFrame )
wxString old_lib_name = prj.GetRString( PROJECT::SCH_LIB_SELECT );
EDA_LIST_DIALOG dlg( aFrame, _( "Select Library" ), headers, itemsToDisplay, old_lib_name );
EDA_LIST_DIALOG dlg( this, _( "Select Library" ), headers, itemsToDisplay, old_lib_name );
if( dlg.ShowModal() != wxID_OK )
return NULL;
@ -91,22 +108,19 @@ PART_LIB* SelectLibraryFromList( EDA_DRAW_FRAME* aFrame )
}
void DisplayCmpDocAndKeywords( wxString& aName, void* aData );
int DisplayComponentsNamesInLib( EDA_DRAW_FRAME* frame,
PART_LIB* Library,
wxString& Buffer, wxString& OldName )
bool SCH_BASE_FRAME::DisplayListComponentsInLib( PART_LIB* aLibrary,
wxString& aBuffer, wxString& aPreviousChoice )
{
wxArrayString nameList;
if( Library == NULL )
Library = SelectLibraryFromList( frame );
if( aLibrary == NULL )
aLibrary = SelectLibraryFromList();
if( Library == NULL )
return 0;
if( aLibrary == NULL )
return false;
Library->GetEntryNames( nameList );
aLibrary->GetEntryNames( nameList );
wxArrayString headers;
headers.Add( wxT("Component") );
@ -118,32 +132,32 @@ int DisplayComponentsNamesInLib( EDA_DRAW_FRAME* frame,
{
wxArrayString item;
item.Add( nameList[i] );
item.Add( Library->GetLogicalName() );
item.Add( aLibrary->GetLogicalName() );
itemsToDisplay.push_back( item );
}
EDA_LIST_DIALOG dlg( frame, _( "Select Component" ), headers, itemsToDisplay,
OldName, DisplayCmpDocAndKeywords, frame->Prj().SchLibs() );
EDA_LIST_DIALOG dlg( this, _( "Select Component" ), headers, itemsToDisplay,
aPreviousChoice, DisplayCmpDocAndKeywords, Prj().SchLibs() );
if( dlg.ShowModal() != wxID_OK )
return 0;
return false;
Buffer = dlg.GetTextSelection();
aBuffer = dlg.GetTextSelection();
return 1;
return true;
}
int GetNameOfPartToLoad( EDA_DRAW_FRAME* frame, PART_LIB* Library, wxString& BufName )
bool SCH_BASE_FRAME::SelectPartNameToLoad( PART_LIB* aLibrary, wxString& aBufName )
{
int ii;
static wxString OldCmpName;
static wxString previousCmpName;
ii = DisplayComponentsNamesInLib( frame, Library, BufName, OldCmpName );
ii = DisplayListComponentsInLib( aLibrary, aBufName, previousCmpName );
if( ii <= 0 || BufName.IsEmpty() )
return 0;
if( ii <= 0 || aBufName.IsEmpty() )
return false;
OldCmpName = BufName;
return 1;
previousCmpName = aBufName;
return true;
}

View File

@ -1,8 +1,8 @@
/*
* 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) 2014 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2015 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
@ -36,7 +36,6 @@
#include <class_sch_screen.h>
#include <general.h>
#include <protos.h>
#include <viewlib_frame.h>
#include <eeschema_id.h>
#include <class_library.h>
@ -152,7 +151,7 @@ void LIB_VIEW_FRAME::SelectCurrentLibrary()
{
PART_LIB* Lib;
Lib = SelectLibraryFromList( this );
Lib = SelectLibraryFromList();
if( Lib )
{
@ -179,6 +178,7 @@ void LIB_VIEW_FRAME::SelectAndViewLibraryPart( int option )
{
if( m_libraryName.IsEmpty() )
SelectCurrentLibrary();
if( m_libraryName.IsEmpty() )
return;
@ -224,9 +224,7 @@ void LIB_VIEW_FRAME::ViewOneLibraryContent( PART_LIB* Lib, int Flag )
return;
if( Flag == NEW_PART )
{
DisplayComponentsNamesInLib( this, Lib, CmpName, m_entryName );
}
DisplayListComponentsInLib( Lib, CmpName, m_entryName );
if( Flag == NEXT_PART )
{
@ -259,59 +257,56 @@ void LIB_VIEW_FRAME::ViewOneLibraryContent( PART_LIB* Lib, int Flag )
if( id >= 0 )
m_cmpList->SetSelection( id );
}
ReCreateHToolbar();
}
void LIB_VIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{
if( PART_LIBS* libs = Prj().SchLibs() )
LIB_ALIAS* entry = Prj().SchLibs()->FindLibraryEntry( m_entryName, m_libraryName );
if( !entry )
return;
LIB_PART* part = entry->GetPart();
if( !part )
return;
wxString msg;
wxString tmp;
m_canvas->DrawBackGround( DC );
if( !entry->IsRoot() )
{
if( PART_LIB* lib = libs->FindLibrary( m_libraryName ) )
{
if( LIB_ALIAS* entry = lib->FindEntry( m_entryName ) )
{
if( LIB_PART* part = entry->GetPart() )
{
wxString msg;
wxString tmp;
// Temporarily change the name field text to reflect the alias name.
msg = entry->GetName();
tmp = part->GetName();
m_canvas->DrawBackGround( DC );
part->SetName( msg );
if( !entry->IsRoot() )
{
// Temporarily change the name field text to reflect the alias name.
msg = entry->GetName();
tmp = part->GetName();
if( m_unit < 1 )
m_unit = 1;
part->SetName( msg );
if( m_unit < 1 )
m_unit = 1;
if( m_convert < 1 )
m_convert = 1;
}
else
{
msg = _( "None" );
}
part->Draw( m_canvas, DC, wxPoint( 0, 0 ), m_unit, m_convert, GR_DEFAULT_DRAWMODE );
// Redraw the cursor
m_canvas->DrawCrossHair( DC );
if( !tmp.IsEmpty() )
part->SetName( tmp );
ClearMsgPanel();
AppendMsgPanel( _( "Part" ), part->GetName(), BLUE, 6 );
AppendMsgPanel( _( "Alias" ), msg, RED, 6 );
AppendMsgPanel( _( "Description" ), entry->GetDescription(), CYAN, 6 );
AppendMsgPanel( _( "Key words" ), entry->GetKeyWords(), DARKDARKGRAY );
}
}
}
if( m_convert < 1 )
m_convert = 1;
}
else
msg = _( "None" );
part->Draw( m_canvas, DC, wxPoint( 0, 0 ), m_unit, m_convert, GR_DEFAULT_DRAWMODE );
// Redraw the cursor
m_canvas->DrawCrossHair( DC );
if( !tmp.IsEmpty() )
part->SetName( tmp );
ClearMsgPanel();
AppendMsgPanel( _( "Part" ), part->GetName(), BLUE, 6 );
AppendMsgPanel( _( "Alias" ), msg, RED, 6 );
AppendMsgPanel( _( "Description" ), entry->GetDescription(), CYAN, 6 );
AppendMsgPanel( _( "Key words" ), entry->GetKeyWords(), DARKDARKGRAY );
}

View File

@ -3,8 +3,8 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2012 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2015 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
@ -32,6 +32,7 @@ class TITLE_BLOCK;
class LIB_VIEW_FRAME;
class LIB_EDIT_FRAME;
class LIB_ALIAS;
class PART_LIB;
/**
* Class SCH_BASE_FRAME
@ -132,6 +133,42 @@ protected:
* If the viewed is already opened from an other window, close it and reopen
*/
void OnOpenLibraryViewer( wxCommandEvent& event );
/**
* Function DisplayComponentsNamesInLib
* Select a component from the list of components in a library
*
* @param aLibrary = a reference to the library to explore
* If NULL the user will be prompted tp chose a library
* @param aBuffer = a wxString to put the selected component name
*
* @return true if a component is selected
* false on cancel
*/
bool DisplayListComponentsInLib( PART_LIB* aLibrary, wxString& aBuffer,
wxString& aPreviousChoice );
/**
* Function SelectLibraryFromList
* displays a list of current loaded libraries, and allows the user to select
* a library
* This list is sorted, with the library cache always at end of the list
* @return a reference to the selected library, or NULL
*/
PART_LIB* SelectLibraryFromList();
/**
* Function SelectPartNameToLoad
* Select a part name from the list of components (parts) found in a library.
*
* @param aLibrary = a reference to the library to explore
* If NULL 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( PART_LIB* aLibrary, wxString& aBufName );
};
#endif // SCH_BASE_FRAME_H_

View File

@ -1,9 +1,9 @@
/*
* 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) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras wanadoo.fr
* Copyright (C) 2008-2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2015 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
@ -44,9 +44,6 @@ class LIB_VIEW_FRAME;
class DRAWSEGMENT;
class SCH_ITEM;
class SCH_NO_CONNECT;
class CMP_LIBRARY;
class LIB_COMPONENT;
class LIB_DRAW_ITEM;
class EDA_ITEM;
class SCH_BUS_ENTRY_BASE;
class SCH_BUS_WIRE_ENTRY;