Commit 0cd108b5 authored by Maciej Suminski's avatar Maciej Suminski

Upstream merge.

parents 3ff70dea 61b4f8a9
...@@ -217,7 +217,7 @@ void Draw3D_SolidHorizontalPolyPolygons( const std::vector<CPolyPt>& aPolysList, ...@@ -217,7 +217,7 @@ void Draw3D_SolidHorizontalPolyPolygons( const std::vector<CPolyPt>& aPolysList,
/* draw the solid polygon found in aPolysList /* draw the solid polygon found in aPolysList
* The first polygonj is the main polygon, others are holes * The first polygon is the main polygon, others are holes
* See Draw3D_SolidHorizontalPolyPolygons for more info * See Draw3D_SolidHorizontalPolyPolygons for more info
*/ */
void Draw3D_SolidHorizontalPolygonWithHoles( const std::vector<CPolyPt>& aPolysList, void Draw3D_SolidHorizontalPolygonWithHoles( const std::vector<CPolyPt>& aPolysList,
......
...@@ -112,7 +112,8 @@ public: ...@@ -112,7 +112,8 @@ public:
* Function GetNodeProperties * Function GetNodeProperties
* Collects all node properties to map. * Collects all node properties to map.
* *
* @param aProps contains map of found properties * @param aNode is an XML node.
* @param aProps contains map of found properties.
*/ */
static void GetNodeProperties( wxXmlNode* aNode, PROPERTY_MAP& aProps ); static void GetNodeProperties( wxXmlNode* aNode, PROPERTY_MAP& aProps );
......
...@@ -10,7 +10,7 @@ WXMAC Platform ...@@ -10,7 +10,7 @@ WXMAC Platform
Common Common
------ ------
* Grep for @TODO or TODO for sourcecode tasks * Grep for @TODO or TODO for sourcecode tasks
* Use doxygen compatible comments on member functions (.h files) * Use Doxygen compatible comments on member functions (.h files)
* Add tooltip text to all non-obvious controls in every dialog window. * Add tooltip text to all non-obvious controls in every dialog window.
Use wxFormBuilder. Use wxFormBuilder.
* Component and module search displays in which library the * Component and module search displays in which library the
...@@ -113,9 +113,9 @@ const wxString FP_LIB_TABLE::ExpandSubtitutions( const wxString aString ) ...@@ -113,9 +113,9 @@ const wxString FP_LIB_TABLE::ExpandSubtitutions( const wxString aString )
EESchema Eeschema
-------- --------
* Drag and drop between two EESchema windows. * Drag and drop between two Eeschema windows.
Wayne: Wayne:
E3) Hook up perform last library search hot key to replace search libraries for E3) Hook up perform last library search hot key to replace search libraries for
...@@ -159,5 +159,6 @@ PCBNew ...@@ -159,5 +159,6 @@ PCBNew
of PLUGIN::Footprint*() functions. At least LEGACY and KICAD are both needed of PLUGIN::Footprint*() functions. At least LEGACY and KICAD are both needed
concurrently. concurrently.
*) Add a hot key to toggle the 45 degree constraint on and off so that it can be
changed when drawing a trace.
...@@ -93,6 +93,7 @@ set(COMMON_SRCS ...@@ -93,6 +93,7 @@ set(COMMON_SRCS
newstroke_font.cpp newstroke_font.cpp
projet_config.cpp projet_config.cpp
ptree.cpp ptree.cpp
reporter.cpp
richio.cpp richio.cpp
selcolor.cpp selcolor.cpp
string.cpp string.cpp
...@@ -145,6 +146,9 @@ set(PCB_COMMON_SRCS ...@@ -145,6 +146,9 @@ set(PCB_COMMON_SRCS
../pcbnew/class_zone_settings.cpp ../pcbnew/class_zone_settings.cpp
../pcbnew/classpcb.cpp ../pcbnew/classpcb.cpp
../pcbnew/collectors.cpp ../pcbnew/collectors.cpp
../pcbnew/netlist_reader_common.cpp
../pcbnew/netlist_reader_firstformat.cpp
../pcbnew/netlist_reader_kicad.cpp
../pcbnew/sel_layer.cpp ../pcbnew/sel_layer.cpp
../pcbnew/pcb_plot_params.cpp ../pcbnew/pcb_plot_params.cpp
../pcbnew/io_mgr.cpp ../pcbnew/io_mgr.cpp
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
// the translated and the not translated version. // the translated and the not translated version.
// when displayed in dialog we should explicitely call wxGetTranslation() // when displayed in dialog we should explicitely call wxGetTranslation()
// to show the translated version. // to show the translated version.
const wxString pageFmts[] = static const wxString pageFmts[] =
{ {
_("A4 210x297mm"), _("A4 210x297mm"),
_("A3 297x420mm"), _("A3 297x420mm"),
...@@ -63,11 +63,10 @@ const wxString pageFmts[] = ...@@ -63,11 +63,10 @@ const wxString pageFmts[] =
_("C 17x22in"), _("C 17x22in"),
_("D 22x34in"), _("D 22x34in"),
_("E 34x44in"), _("E 34x44in"),
_("US Letter 8.5x11in"), _("USLetter 8.5x11in"), // USLetter without space is correct
_("US Legal 8.5x14in"), _("USLegal 8.5x14in"), // USLegal without space is correct
_("US Ledger 11x17in"), _("USLedger 11x17in"), // USLedger without space is correct
_("User (Custom)"), _("User (Custom)"),
wxT("") // end of list
}; };
void EDA_DRAW_FRAME::Process_PageSettings( wxCommandEvent& event ) void EDA_DRAW_FRAME::Process_PageSettings( wxCommandEvent& event )
...@@ -115,11 +114,8 @@ void DIALOG_PAGES_SETTINGS::initDialog() ...@@ -115,11 +114,8 @@ void DIALOG_PAGES_SETTINGS::initDialog()
// The first shows translated strings, the second contains not translated strings // The first shows translated strings, the second contains not translated strings
m_paperSizeComboBox->Clear(); m_paperSizeComboBox->Clear();
for( unsigned ii = 0; ; ii++ ) for( unsigned ii = 0; ii<DIM(pageFmts); ii++ )
{ {
if( pageFmts[ii].IsEmpty() )
break;
m_pageFmt.Add( pageFmts[ii] ); m_pageFmt.Add( pageFmts[ii] );
m_paperSizeComboBox->Append( wxGetTranslation( pageFmts[ii] ) ); m_paperSizeComboBox->Append( wxGetTranslation( pageFmts[ii] ) );
} }
......
...@@ -495,11 +495,6 @@ void EDA_DRAW_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg ) ...@@ -495,11 +495,6 @@ void EDA_DRAW_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
} }
void EDA_DRAW_FRAME::OnGrid( int grid_type )
{
}
wxPoint EDA_DRAW_FRAME::GetGridPosition( const wxPoint& aPosition ) const wxPoint EDA_DRAW_FRAME::GetGridPosition( const wxPoint& aPosition ) const
{ {
wxPoint pos = aPosition; wxPoint pos = aPosition;
......
...@@ -54,11 +54,9 @@ ...@@ -54,11 +54,9 @@
double s_HersheyScaleFactor = HERSHEY_SCALE_FACTOR; double s_HersheyScaleFactor = HERSHEY_SCALE_FACTOR;
/* Helper function for texts with over bar int OverbarPositionY( int size_v )
*/
int OverbarPositionY( int size_v, int thickness )
{ {
return KiROUND( ( (double) size_v * 1.1 ) + ( (double) thickness * 1.5 ) ); return KiROUND( size_v * 1.22 );
} }
...@@ -155,7 +153,7 @@ static const char* GetHersheyShapeDescription( int AsciiCode ) ...@@ -155,7 +153,7 @@ static const char* GetHersheyShapeDescription( int AsciiCode )
AsciiCode = '?'; AsciiCode = '?';
if( AsciiCode < 32 ) if( AsciiCode < 32 )
AsciiCode = 32; /* Clamp control chars */ AsciiCode = 32; // Clamp control chars
AsciiCode -= 32; AsciiCode -= 32;
...@@ -391,9 +389,9 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, ...@@ -391,9 +389,9 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
/* if a text size is too small, the text cannot be drawn, and it is drawn as a single /* if a text size is too small, the text cannot be drawn, and it is drawn as a single
* graphic line */ * graphic line */
if( std::abs( aSize.x ) < 3 ) if( aDC && ( aDC->LogicalToDeviceYRel( std::abs( aSize.y ) ) < MIN_DRAWABLE_TEXT_SIZE ))
{ {
/* draw the text as a line always vertically centered */ // draw the text as a line always vertically centered
wxPoint end( current_char_pos.x + dx, current_char_pos.y ); wxPoint end( current_char_pos.x + dx, current_char_pos.y );
RotatePoint( &current_char_pos, aPos, aOrient ); RotatePoint( &current_char_pos, aPos, aOrient );
...@@ -417,7 +415,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, ...@@ -417,7 +415,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
if( aItalic ) if( aItalic )
{ {
overbar_italic_comp = OverbarPositionY( size_v, aWidth ) / 8; overbar_italic_comp = OverbarPositionY( size_v ) / 8;
if( italic_reverse ) if( italic_reverse )
{ {
...@@ -450,7 +448,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, ...@@ -450,7 +448,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
// Starting the overbar // Starting the overbar
overbar_pos = current_char_pos; overbar_pos = current_char_pos;
overbar_pos.x += overbar_italic_comp; overbar_pos.x += overbar_italic_comp;
overbar_pos.y -= OverbarPositionY( size_v, aWidth ); overbar_pos.y -= OverbarPositionY( size_v );
RotatePoint( &overbar_pos, aPos, aOrient ); RotatePoint( &overbar_pos, aPos, aOrient );
} }
else else
...@@ -459,7 +457,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, ...@@ -459,7 +457,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
coord[0] = overbar_pos; coord[0] = overbar_pos;
overbar_pos = current_char_pos; overbar_pos = current_char_pos;
overbar_pos.x += overbar_italic_comp; overbar_pos.x += overbar_italic_comp;
overbar_pos.y -= OverbarPositionY( size_v, aWidth ); overbar_pos.y -= OverbarPositionY( size_v );
RotatePoint( &overbar_pos, aPos, aOrient ); RotatePoint( &overbar_pos, aPos, aOrient );
coord[1] = overbar_pos; coord[1] = overbar_pos;
// Plot the overbar segment // Plot the overbar segment
...@@ -520,7 +518,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, ...@@ -520,7 +518,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
else else
{ {
wxPoint currpoint; wxPoint currpoint;
hc1 -= xsta; hc2 -= 11; // Align the midpoint hc1 -= xsta; hc2 -= 10; // Align the midpoint
hc1 = KiROUND( hc1 * size_h * s_HersheyScaleFactor ); hc1 = KiROUND( hc1 * size_h * s_HersheyScaleFactor );
hc2 = KiROUND( hc2 * size_v * s_HersheyScaleFactor ); hc2 = KiROUND( hc2 * size_v * s_HersheyScaleFactor );
...@@ -551,7 +549,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, ...@@ -551,7 +549,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
// Close the last overbar // Close the last overbar
coord[0] = overbar_pos; coord[0] = overbar_pos;
overbar_pos = current_char_pos; overbar_pos = current_char_pos;
overbar_pos.y -= OverbarPositionY( size_v, aWidth ); overbar_pos.y -= OverbarPositionY( size_v );
RotatePoint( &overbar_pos, aPos, aOrient ); RotatePoint( &overbar_pos, aPos, aOrient );
coord[1] = overbar_pos; coord[1] = overbar_pos;
...@@ -585,12 +583,12 @@ void DrawGraphicHaloText( EDA_DRAW_PANEL * aPanel, ...@@ -585,12 +583,12 @@ void DrawGraphicHaloText( EDA_DRAW_PANEL * aPanel,
aColor2 = c; aColor2 = c;
} }
DrawGraphicText( aPanel, aDC, aPos, aColor1, aText, aOrient, aSize, DrawGraphicText( aPanel, aDC, aPos, aColor1, aText, aOrient, aSize,
aH_justify, aV_justify, aWidth, aItalic, aBold, aH_justify, aV_justify, aWidth, aItalic, aBold,
aCallback, aPlotter ); aCallback, aPlotter );
DrawGraphicText( aPanel, aDC, aPos, aColor2, aText, aOrient, aSize, DrawGraphicText( aPanel, aDC, aPos, aColor2, aText, aOrient, aSize,
aH_justify, aV_justify, aWidth / 4, aItalic, aBold, aH_justify, aV_justify, aWidth / 4, aItalic, aBold,
aCallback, aPlotter ); aCallback, aPlotter );
} }
......
...@@ -310,6 +310,26 @@ std::string FPID::Format( const std::string& aLogicalLib, const std::string& aFo ...@@ -310,6 +310,26 @@ std::string FPID::Format( const std::string& aLogicalLib, const std::string& aFo
} }
int FPID::compare( const FPID& aFPID ) const
{
// Don't bother comparing the same object.
if( this == &aFPID )
return 0;
int retv = nickname.compare( aFPID.nickname );
if( retv != 0 )
return retv;
retv = footprint.compare( aFPID.footprint );
if( retv != 0 )
return retv;
return revision.compare( aFPID.revision );
}
#if 0 && defined(DEBUG) #if 0 && defined(DEBUG)
// build this with Debug CMAKE_BUILD_TYPE // build this with Debug CMAKE_BUILD_TYPE
......
...@@ -563,7 +563,7 @@ int EDA_BASE_FRAME::ReadHotkeyConfigFile( const wxString& aFilename, ...@@ -563,7 +563,7 @@ int EDA_BASE_FRAME::ReadHotkeyConfigFile( const wxString& aFilename,
ParseHotkeyConfig( data, aDescList ); ParseHotkeyConfig( data, aDescList );
/* cleanup */ /* cleanup */
delete buffer; delete[] buffer;
cfgfile.Close(); cfgfile.Close();
return 1; return 1;
} }
......
/**
* @file reporter.h
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2013 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
*/
#include <macros.h>
#include <reporter.h>
REPORTER& REPORTER::Report( const char *aText )
{
Report( FROM_UTF8( aText ) );
return *this;
}
REPORTER& WX_TEXT_CTRL_REPORTER::Report( const wxString& aText )
{
wxCHECK_MSG( m_textCtrl != NULL, *this,
wxT( "No wxTextCtrl object defined in WX_TEXT_CTRL_REPORTER." ) );
m_textCtrl->AppendText( aText );
return *this;
}
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 20012 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2012 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2012 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2008-2012 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
* *
...@@ -96,3 +96,4 @@ const wxString PSFileWildcard( _( "PostScript files (.ps)|*.ps" ) ); ...@@ -96,3 +96,4 @@ const wxString PSFileWildcard( _( "PostScript files (.ps)|*.ps" ) );
const wxString ReportFileWildcard = _( "Report files (*.rpt)|*.rpt" ); const wxString ReportFileWildcard = _( "Report files (*.rpt)|*.rpt" );
const wxString FootprintPlaceFileWildcard = _( "Footprint place files (*.pos)|*.pos" ); const wxString FootprintPlaceFileWildcard = _( "Footprint place files (*.pos)|*.pos" );
const wxString Shapes3DFileWildcard( _( "Vrml and x3d files (*.wrl *.x3d)|*.wrl;*.x3d" ) ); const wxString Shapes3DFileWildcard( _( "Vrml and x3d files (*.wrl *.x3d)|*.wrl;*.x3d" ) );
const wxString TextWildcard( _( "Text files (*.txt)|*.txt" ) );
...@@ -27,9 +27,6 @@ set(CVPCB_DIALOGS ...@@ -27,9 +27,6 @@ set(CVPCB_DIALOGS
set(CVPCB_SRCS set(CVPCB_SRCS
../common/base_units.cpp ../common/base_units.cpp
../pcbnew/netlist_reader_common.cpp
../pcbnew/netlist_reader_kicad.cpp
../pcbnew/netlist_reader_firstformat.cpp
../pcbnew/class_drc_item.cpp ../pcbnew/class_drc_item.cpp
autosel.cpp autosel.cpp
cfg.cpp cfg.cpp
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2012 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 autosel.cpp * @file autosel.cpp
*/ */
...@@ -39,10 +62,16 @@ typedef boost::ptr_vector< FOOTPRINT_ALIAS > FOOTPRINT_ALIAS_LIST; ...@@ -39,10 +62,16 @@ typedef boost::ptr_vector< FOOTPRINT_ALIAS > FOOTPRINT_ALIAS_LIST;
wxString GetQuotedText( wxString & text ) wxString GetQuotedText( wxString & text )
{ {
int i = text.Find( QUOTE ); int i = text.Find( QUOTE );
if( wxNOT_FOUND == i ) return wxT( "" );
if( wxNOT_FOUND == i )
return wxT( "" );
wxString shrt = text.Mid( i + 1 ); wxString shrt = text.Mid( i + 1 );
i = shrt.Find( QUOTE ); i = shrt.Find( QUOTE );
if( wxNOT_FOUND == i ) return wxT( "" );
if( wxNOT_FOUND == i )
return wxT( "" );
text = shrt.Mid( i + 1 ); text = shrt.Mid( i + 1 );
return shrt.Mid( 0, i ); return shrt.Mid( 0, i );
} }
...@@ -52,13 +81,14 @@ void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event ) ...@@ -52,13 +81,14 @@ void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event )
{ {
FOOTPRINT_ALIAS_LIST aliases; FOOTPRINT_ALIAS_LIST aliases;
FOOTPRINT_ALIAS* alias; FOOTPRINT_ALIAS* alias;
COMPONENT* component;
wxFileName fn; wxFileName fn;
wxString msg, tmp; wxString msg, tmp;
char Line[1024]; char Line[1024];
FILE* file; FILE* file;
size_t ii; size_t ii;
if( m_components.empty() ) if( m_netlist.IsEmpty() )
return; return;
/* Find equivalents in all available files. */ /* Find equivalents in all available files. */
...@@ -79,8 +109,8 @@ void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event ) ...@@ -79,8 +109,8 @@ void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event )
if( !tmp ) if( !tmp )
{ {
msg.Printf( _( "Footprint alias library file <%s> could not be \ msg.Printf( _( "Footprint alias library file <%s> could not be found in the "
found in the default search paths." ), "default search paths." ),
GetChars( fn.GetFullName() ) ); GetChars( fn.GetFullName() ) );
wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR ); wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR );
continue; continue;
...@@ -127,18 +157,21 @@ found in the default search paths." ), ...@@ -127,18 +157,21 @@ found in the default search paths." ),
m_skipComponentSelect = true; m_skipComponentSelect = true;
ii = 0; ii = 0;
BOOST_FOREACH( COMPONENT_INFO& component, m_components )
for( unsigned kk = 0; kk < m_netlist.GetCount(); kk++ )
{ {
component = m_netlist.GetComponent( kk );
bool found = false; bool found = false;
m_ListCmp->SetSelection( ii++, true ); m_ListCmp->SetSelection( ii++, true );
if( !component.m_Footprint.IsEmpty() ) if( !component->GetFootprintLibName().IsEmpty() )
continue; continue;
BOOST_FOREACH( FOOTPRINT_ALIAS& alias, aliases ) BOOST_FOREACH( FOOTPRINT_ALIAS& alias, aliases )
{ {
if( alias.m_Name.CmpNoCase( component.m_Value ) != 0 ) if( alias.m_Name.CmpNoCase( component->GetValue() ) != 0 )
continue; continue;
/* filter alias so one can use multiple aliases (for polar and nonpolar caps for /* filter alias so one can use multiple aliases (for polar and nonpolar caps for
...@@ -147,23 +180,23 @@ found in the default search paths." ), ...@@ -147,23 +180,23 @@ found in the default search paths." ),
if( module ) if( module )
{ {
size_t filtercount = component.m_FootprintFilter.GetCount(); size_t filtercount = component->GetFootprintFilters().GetCount();
found = ( 0 == filtercount ); // if no entries, do not filter found = ( 0 == filtercount ); // if no entries, do not filter
for( size_t jj = 0; jj < filtercount && !found; jj++ ) for( size_t jj = 0; jj < filtercount && !found; jj++ )
{ {
found = module->m_Module.Matches( component.m_FootprintFilter[jj] ); found = module->m_Module.Matches( component->GetFootprintFilters()[jj] );
} }
} }
else else
{ {
msg.Printf( _( "Component %s: footprint %s not found in \ msg.Printf( _( "Component %s: footprint %s not found in any of the project "
any of the project footprint libraries." ), "footprint libraries." ),
GetChars( component.m_Reference ), GetChars( component->GetReference() ),
GetChars( alias.m_FootprintName ) ); GetChars( alias.m_FootprintName ) );
wxMessageBox( msg, _( "CvPcb Error" ), wxOK | wxICON_ERROR, wxMessageBox( msg, _( "CvPcb Error" ), wxOK | wxICON_ERROR, this );
this );
} }
if( found ) if( found )
{ {
SetNewPkg( alias.m_FootprintName ); SetNewPkg( alias.m_FootprintName );
...@@ -171,15 +204,20 @@ any of the project footprint libraries." ), ...@@ -171,15 +204,20 @@ any of the project footprint libraries." ),
} }
} }
/* obviously the last chance: there's only one filter matching one footprint */ /* obviously the last chance: there's only one filter matching one footprint */
if( !found && 1 == component.m_FootprintFilter.GetCount() ) { if( !found && 1 == component->GetFootprintFilters().GetCount() )
{
/* we do not need to analyse wildcards: single footprint do not contain them */ /* we do not need to analyse wildcards: single footprint do not contain them */
/* and if there are wildcards it just will not match any */ /* and if there are wildcards it just will not match any */
FOOTPRINT_INFO *module = m_footprints.GetModuleInfo( component.m_FootprintFilter[0] ); FOOTPRINT_INFO *module = m_footprints.GetModuleInfo( component->GetFootprintFilters()[0] );
if( module ) {
SetNewPkg( component.m_FootprintFilter[0] ); if( module )
{
SetNewPkg( component->GetFootprintFilters()[0] );
} }
} }
} }
m_skipComponentSelect = false; m_skipComponentSelect = false;
} }
/*
* 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-2012 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 class_footprints_listbox.cpp * @file class_footprints_listbox.cpp
* class to display the list fo available footprints * class to display the list of available footprints
*/ */
#include <fctsys.h> #include <fctsys.h>
...@@ -119,7 +143,7 @@ void FOOTPRINTS_LISTBOX::SetFootprintFullList( FOOTPRINT_LIST& list ) ...@@ -119,7 +143,7 @@ void FOOTPRINTS_LISTBOX::SetFootprintFullList( FOOTPRINT_LIST& list )
for( unsigned ii = 0; ii < list.GetCount(); ii++ ) for( unsigned ii = 0; ii < list.GetCount(); ii++ )
{ {
FOOTPRINT_INFO & footprint = list.GetItem(ii); FOOTPRINT_INFO & footprint = list.GetItem(ii);
msg.Printf( wxT( "%3d %s" ), (int) m_FullFootprintList.GetCount() + 1, msg.Printf( wxT( "%3zu %s" ), m_FullFootprintList.GetCount() + 1,
GetChars(footprint.m_Module) ); GetChars(footprint.m_Module) );
m_FullFootprintList.Add( msg ); m_FullFootprintList.Add( msg );
} }
...@@ -132,7 +156,7 @@ void FOOTPRINTS_LISTBOX::SetFootprintFullList( FOOTPRINT_LIST& list ) ...@@ -132,7 +156,7 @@ void FOOTPRINTS_LISTBOX::SetFootprintFullList( FOOTPRINT_LIST& list )
} }
void FOOTPRINTS_LISTBOX::SetFootprintFilteredList( COMPONENT_INFO* Component, void FOOTPRINTS_LISTBOX::SetFootprintFilteredList( COMPONENT* aComponent,
FOOTPRINT_LIST& list ) FOOTPRINT_LIST& list )
{ {
wxString msg; wxString msg;
...@@ -149,13 +173,16 @@ void FOOTPRINTS_LISTBOX::SetFootprintFilteredList( COMPONENT_INFO* Component, ...@@ -149,13 +173,16 @@ void FOOTPRINTS_LISTBOX::SetFootprintFilteredList( COMPONENT_INFO* Component,
// The search is case insensitive // The search is case insensitive
wxString module = footprint.m_Module.Upper(); wxString module = footprint.m_Module.Upper();
wxString candidate; wxString candidate;
for( jj = 0; jj < Component->m_FootprintFilter.GetCount(); jj++ )
for( jj = 0; jj < aComponent->GetFootprintFilters().GetCount(); jj++ )
{ {
candidate = Component->m_FootprintFilter[jj].Upper(); candidate = aComponent->GetFootprintFilters()[jj].Upper();
if( !module.Matches( candidate ) ) if( !module.Matches( candidate ) )
continue; continue;
msg.Printf( wxT( "%3d %s" ), m_FilteredFootprintList.GetCount() + 1,
footprint.m_Module.GetData() ); msg.Printf( wxT( "%3zu %s" ), m_FilteredFootprintList.GetCount() + 1,
footprint.m_Module.GetData() );
m_FilteredFootprintList.Add( msg ); m_FilteredFootprintList.Add( msg );
hasItem = true; hasItem = true;
} }
...@@ -172,8 +199,10 @@ void FOOTPRINTS_LISTBOX::SetFootprintFilteredList( COMPONENT_INFO* Component, ...@@ -172,8 +199,10 @@ void FOOTPRINTS_LISTBOX::SetFootprintFilteredList( COMPONENT_INFO* Component,
Refresh(); Refresh();
} }
void FOOTPRINTS_LISTBOX::SetFootprintFilteredByPinCount( COMPONENT_INFO* Component,
FOOTPRINT_LIST& list ) { void FOOTPRINTS_LISTBOX::SetFootprintFilteredByPinCount( COMPONENT* aComponent,
FOOTPRINT_LIST& list )
{
wxString msg; wxString msg;
int oldSelection = GetSelection(); int oldSelection = GetSelection();
bool hasItem = false; bool hasItem = false;
...@@ -184,10 +213,10 @@ void FOOTPRINTS_LISTBOX::SetFootprintFilteredByPinCount( COMPONENT_INFO* Compone ...@@ -184,10 +213,10 @@ void FOOTPRINTS_LISTBOX::SetFootprintFilteredByPinCount( COMPONENT_INFO* Compone
{ {
FOOTPRINT_INFO& footprint = list.GetItem(ii); FOOTPRINT_INFO& footprint = list.GetItem(ii);
if( Component->m_pinCount == footprint.m_padCount ) if( aComponent->GetNetCount() == footprint.m_padCount )
{ {
msg.Printf( wxT( "%3d %s" ), m_FilteredFootprintList.GetCount() + 1, msg.Printf( wxT( "%3zu %s" ), m_FilteredFootprintList.GetCount() + 1,
footprint.m_Module.GetData() ); footprint.m_Module.GetData() );
m_FilteredFootprintList.Add( msg ); m_FilteredFootprintList.Add( msg );
hasItem = true; hasItem = true;
} }
...@@ -204,13 +233,7 @@ void FOOTPRINTS_LISTBOX::SetFootprintFilteredByPinCount( COMPONENT_INFO* Compone ...@@ -204,13 +233,7 @@ void FOOTPRINTS_LISTBOX::SetFootprintFilteredByPinCount( COMPONENT_INFO* Compone
Refresh(); Refresh();
} }
/** Set the footprint list. We can have 2 footprint list:
* The full footprint list
* The filtered footprint list (if the current selected component has a
* filter for footprints)
* @param FullList true = full footprint list, false = filtered footprint list
* @param Redraw = true to redraw the window
*/
void FOOTPRINTS_LISTBOX::SetActiveFootprintList( bool FullList, bool Redraw ) void FOOTPRINTS_LISTBOX::SetActiveFootprintList( bool FullList, bool Redraw )
{ {
bool old_selection = m_UseFootprintFullList; bool old_selection = m_UseFootprintFullList;
...@@ -226,10 +249,12 @@ void FOOTPRINTS_LISTBOX::SetActiveFootprintList( bool FullList, bool Redraw ) ...@@ -226,10 +249,12 @@ void FOOTPRINTS_LISTBOX::SetActiveFootprintList( bool FullList, bool Redraw )
if( m_ActiveFootprintList ) if( m_ActiveFootprintList )
{ {
bool new_selection; bool new_selection;
if( FullList ) if( FullList )
new_selection = true; new_selection = true;
else else
new_selection = false; new_selection = false;
if( new_selection != old_selection ) if( new_selection != old_selection )
SetSelection( 0, true ); SetSelection( 0, true );
} }
...@@ -264,14 +289,12 @@ void FOOTPRINTS_LISTBOX::SetActiveFootprintList( bool FullList, bool Redraw ) ...@@ -264,14 +289,12 @@ void FOOTPRINTS_LISTBOX::SetActiveFootprintList( bool FullList, bool Redraw )
/**************************************/ /**************************************/
BEGIN_EVENT_TABLE( FOOTPRINTS_LISTBOX, ITEMS_LISTBOX_BASE ) BEGIN_EVENT_TABLE( FOOTPRINTS_LISTBOX, ITEMS_LISTBOX_BASE )
EVT_SIZE( ITEMS_LISTBOX_BASE::OnSize ) EVT_SIZE( ITEMS_LISTBOX_BASE::OnSize )
EVT_CHAR( FOOTPRINTS_LISTBOX::OnChar ) EVT_CHAR( FOOTPRINTS_LISTBOX::OnChar )
END_EVENT_TABLE() END_EVENT_TABLE()
/********************************************************/
void FOOTPRINTS_LISTBOX::OnLeftClick( wxListEvent& event ) void FOOTPRINTS_LISTBOX::OnLeftClick( wxListEvent& event )
/********************************************************/
{ {
FOOTPRINT_INFO* Module; FOOTPRINT_INFO* Module;
wxString footprintName = GetSelectedFootprint(); wxString footprintName = GetSelectedFootprint();
...@@ -297,9 +320,7 @@ void FOOTPRINTS_LISTBOX::OnLeftClick( wxListEvent& event ) ...@@ -297,9 +320,7 @@ void FOOTPRINTS_LISTBOX::OnLeftClick( wxListEvent& event )
} }
/******************************************************/
void FOOTPRINTS_LISTBOX::OnLeftDClick( wxListEvent& event ) void FOOTPRINTS_LISTBOX::OnLeftDClick( wxListEvent& event )
/******************************************************/
{ {
wxString footprintName = GetSelectedFootprint(); wxString footprintName = GetSelectedFootprint();
...@@ -307,21 +328,10 @@ void FOOTPRINTS_LISTBOX::OnLeftDClick( wxListEvent& event ) ...@@ -307,21 +328,10 @@ void FOOTPRINTS_LISTBOX::OnLeftDClick( wxListEvent& event )
} }
/**
* Function OnChar
* called on a key pressed
* Call default handler for some special keys,
* and for "ascii" keys, select the first footprint
* that the name starts by the letter.
* This is the defaut behaviour of a listbox, but because we use
* virtual lists, the listbox does not know anything to what is displayed,
* we must handle this behaviour here.
* Furthermore the footprint name is not at the beginning of
* displayed lines (the first word is the line number)
*/
void FOOTPRINTS_LISTBOX::OnChar( wxKeyEvent& event ) void FOOTPRINTS_LISTBOX::OnChar( wxKeyEvent& event )
{ {
int key = event.GetKeyCode(); int key = event.GetKeyCode();
switch( key ) switch( key )
{ {
case WXK_LEFT: case WXK_LEFT:
...@@ -343,16 +353,20 @@ void FOOTPRINTS_LISTBOX::OnChar( wxKeyEvent& event ) ...@@ -343,16 +353,20 @@ void FOOTPRINTS_LISTBOX::OnChar( wxKeyEvent& event )
default: default:
break; break;
} }
// Search for an item name starting by the key code: // Search for an item name starting by the key code:
key = toupper(key); key = toupper(key);
for( unsigned ii = 0; ii < m_ActiveFootprintList->GetCount(); ii++ ) for( unsigned ii = 0; ii < m_ActiveFootprintList->GetCount(); ii++ )
{ {
wxString text = m_ActiveFootprintList->Item(ii); wxString text = m_ActiveFootprintList->Item(ii);
/* search for the start char of the footprint name. /* search for the start char of the footprint name.
* we must skip the line number * we must skip the line number
*/ */
text.Trim(false); // Remove leading spaces in line text.Trim(false); // Remove leading spaces in line
unsigned jj = 0; unsigned jj = 0;
for( ; jj < text.Len(); jj++ ) for( ; jj < text.Len(); jj++ )
{ {
// skip line number // skip line number
...@@ -367,6 +381,7 @@ void FOOTPRINTS_LISTBOX::OnChar( wxKeyEvent& event ) ...@@ -367,6 +381,7 @@ void FOOTPRINTS_LISTBOX::OnChar( wxKeyEvent& event )
} }
int start_char = toupper( text[jj] ); int start_char = toupper( text[jj] );
if( key == start_char ) if( key == start_char )
{ {
Focus( ii ); Focus( ii );
......
...@@ -334,7 +334,7 @@ void CVPCB_MAINFRAME::ToFirstNA( wxCommandEvent& event ) ...@@ -334,7 +334,7 @@ void CVPCB_MAINFRAME::ToFirstNA( wxCommandEvent& event )
int ii = 0; int ii = 0;
int selection; int selection;
if( m_components.empty() ) if( m_netlist.IsEmpty() )
return; return;
selection = m_ListCmp->GetSelection(); selection = m_ListCmp->GetSelection();
...@@ -342,9 +342,9 @@ void CVPCB_MAINFRAME::ToFirstNA( wxCommandEvent& event ) ...@@ -342,9 +342,9 @@ void CVPCB_MAINFRAME::ToFirstNA( wxCommandEvent& event )
if( selection < 0 ) if( selection < 0 )
selection = 0; selection = 0;
BOOST_FOREACH( COMPONENT_INFO & component, m_components ) for( unsigned jj = 0; jj < m_netlist.GetCount(); jj++ )
{ {
if( component.m_Footprint.IsEmpty() && ii > selection ) if( m_netlist.GetComponent( jj )->GetFootprintLibName().IsEmpty() && ii > selection )
{ {
m_ListCmp->SetSelection( ii ); m_ListCmp->SetSelection( ii );
SendMessageToEESCHEMA(); SendMessageToEESCHEMA();
...@@ -363,7 +363,7 @@ void CVPCB_MAINFRAME::ToPreviousNA( wxCommandEvent& event ) ...@@ -363,7 +363,7 @@ void CVPCB_MAINFRAME::ToPreviousNA( wxCommandEvent& event )
int ii; int ii;
int selection; int selection;
if( m_components.empty() ) if( m_netlist.IsEmpty() )
return; return;
ii = m_ListCmp->GetCount() - 1; ii = m_ListCmp->GetCount() - 1;
...@@ -372,9 +372,9 @@ void CVPCB_MAINFRAME::ToPreviousNA( wxCommandEvent& event ) ...@@ -372,9 +372,9 @@ void CVPCB_MAINFRAME::ToPreviousNA( wxCommandEvent& event )
if( selection < 0 ) if( selection < 0 )
selection = m_ListCmp->GetCount() - 1; selection = m_ListCmp->GetCount() - 1;
BOOST_REVERSE_FOREACH( COMPONENT_INFO & component, m_components ) for( unsigned kk = m_netlist.GetCount() - 1; kk >= 0; kk-- )
{ {
if( component.m_Footprint.IsEmpty() && ii < selection ) if( m_netlist.GetComponent( kk )->GetFootprintLibName().IsEmpty() && ii < selection )
{ {
m_ListCmp->SetSelection( ii ); m_ListCmp->SetSelection( ii );
SendMessageToEESCHEMA(); SendMessageToEESCHEMA();
...@@ -412,15 +412,15 @@ void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event ) ...@@ -412,15 +412,15 @@ void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event )
m_skipComponentSelect = true; m_skipComponentSelect = true;
m_ListCmp->SetSelection( 0 ); m_ListCmp->SetSelection( 0 );
BOOST_FOREACH( COMPONENT_INFO & component, m_components ) for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
{ {
component.m_Footprint.Empty(); m_netlist.GetComponent( i )->SetFootprintLibName( wxEmptyString );
SetNewPkg( wxEmptyString ); SetNewPkg( wxEmptyString );
} }
m_skipComponentSelect = false; m_skipComponentSelect = false;
m_ListCmp->SetSelection( 0 ); m_ListCmp->SetSelection( 0 );
m_undefinedComponentCnt = m_components.size(); m_undefinedComponentCnt = m_netlist.GetCount();
} }
DisplayStatus(); DisplayStatus();
...@@ -538,18 +538,18 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event ) ...@@ -538,18 +538,18 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
else else
{ {
if( &m_components[ selection ] == NULL ) if( m_netlist.GetComponent( selection ) == NULL )
m_FootprintList->SetActiveFootprintList( SELECT_FULL_LIST, REDRAW_LIST ); m_FootprintList->SetActiveFootprintList( SELECT_FULL_LIST, REDRAW_LIST );
else else
{ {
if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST ) ) if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST ) )
{ {
m_FootprintList->SetFootprintFilteredByPinCount( &m_components[ selection ], m_FootprintList->SetFootprintFilteredByPinCount( m_netlist.GetComponent( selection ),
m_footprints ); m_footprints );
} }
else else
{ {
m_FootprintList->SetFootprintFilteredList( &m_components[ selection ], m_FootprintList->SetFootprintFilteredList( m_netlist.GetComponent( selection ),
m_footprints ); m_footprints );
} }
} }
...@@ -568,7 +568,7 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event ) ...@@ -568,7 +568,7 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
if( FindFocus() == m_ListCmp ) if( FindFocus() == m_ListCmp )
{ {
wxString module = *(&m_components[ selection ].m_Footprint); wxString module = m_netlist.GetComponent( selection )->GetFootprintLibName();
bool found = false; bool found = false;
for( int ii = 0; ii < m_FootprintList->GetCount(); ii++ ) for( int ii = 0; ii < m_FootprintList->GetCount(); ii++ )
...@@ -642,7 +642,8 @@ void CVPCB_MAINFRAME::DisplayStatus() ...@@ -642,7 +642,8 @@ void CVPCB_MAINFRAME::DisplayStatus()
{ {
wxString msg; wxString msg;
msg.Printf( _( "Components: %d (free: %d)" ), (int) m_components.size(), m_undefinedComponentCnt ); msg.Printf( _( "Components: %d (free: %d)" ), (int) m_netlist.GetCount(),
m_undefinedComponentCnt );
SetStatusText( msg, 0 ); SetStatusText( msg, 0 );
SetStatusText( wxEmptyString, 1 ); SetStatusText( wxEmptyString, 1 );
...@@ -733,9 +734,9 @@ void CVPCB_MAINFRAME::SendMessageToEESCHEMA() ...@@ -733,9 +734,9 @@ void CVPCB_MAINFRAME::SendMessageToEESCHEMA()
{ {
char cmd[1024]; char cmd[1024];
int selection; int selection;
COMPONENT_INFO* Component; COMPONENT* Component;
if( m_components.empty() ) if( m_netlist.IsEmpty() )
return; return;
selection = m_ListCmp->GetSelection(); selection = m_ListCmp->GetSelection();
...@@ -743,12 +744,12 @@ void CVPCB_MAINFRAME::SendMessageToEESCHEMA() ...@@ -743,12 +744,12 @@ void CVPCB_MAINFRAME::SendMessageToEESCHEMA()
if ( selection < 0 ) if ( selection < 0 )
selection = 0; selection = 0;
if( &m_components[ selection ] == NULL ) if( m_netlist.GetComponent( selection ) == NULL )
return; return;
Component = &m_components[ selection ]; Component = m_netlist.GetComponent( selection );
sprintf( cmd, "$PART: \"%s\"", TO_UTF8( Component->m_Reference ) ); sprintf( cmd, "$PART: \"%s\"", TO_UTF8( Component->GetReference() ) );
SendCommand( MSG_TO_SCH, cmd ); SendCommand( MSG_TO_SCH, cmd );
......
...@@ -21,10 +21,6 @@ ...@@ -21,10 +21,6 @@
#define LISTB_STYLE (wxSUNKEN_BORDER | wxLC_NO_HEADER | wxLC_REPORT | wxLC_VIRTUAL) #define LISTB_STYLE (wxSUNKEN_BORDER | wxLC_NO_HEADER | wxLC_REPORT | wxLC_VIRTUAL)
#include <netlist_reader.h>
typedef boost::ptr_vector< COMPONENT_INFO > COMPONENT_LIST;
extern const wxString FootprintAliasFileExtension; extern const wxString FootprintAliasFileExtension;
extern const wxString RetroFileExtension; extern const wxString RetroFileExtension;
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2011 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2012 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 cvpcb_mainframe.h * @file cvpcb_mainframe.h
*/ */
...@@ -7,6 +31,7 @@ ...@@ -7,6 +31,7 @@
#include <wx/listctrl.h> #include <wx/listctrl.h>
#include <wx/filename.h> #include <wx/filename.h>
#include <netlist_reader.h>
#include <wxBasePcbFrame.h> #include <wxBasePcbFrame.h>
#include <param_config.h> #include <param_config.h>
...@@ -28,19 +53,19 @@ class CVPCB_MAINFRAME : public EDA_BASE_FRAME ...@@ -28,19 +53,19 @@ class CVPCB_MAINFRAME : public EDA_BASE_FRAME
{ {
public: public:
bool m_KeepCvpcbOpen; bool m_KeepCvpcbOpen;
FOOTPRINTS_LISTBOX* m_FootprintList; FOOTPRINTS_LISTBOX* m_FootprintList;
COMPONENTS_LISTBOX* m_ListCmp; COMPONENTS_LISTBOX* m_ListCmp;
DISPLAY_FOOTPRINTS_FRAME* m_DisplayFootprintFrame; DISPLAY_FOOTPRINTS_FRAME* m_DisplayFootprintFrame;
wxAuiToolBar* m_mainToolBar; wxAuiToolBar* m_mainToolBar;
wxFileName m_NetlistFileName; wxFileName m_NetlistFileName;
wxArrayString m_ModuleLibNames; wxArrayString m_ModuleLibNames;
wxArrayString m_AliasLibNames; wxArrayString m_AliasLibNames;
wxString m_UserLibraryPath; wxString m_UserLibraryPath;
wxString m_NetlistFileExtension; wxString m_NetlistFileExtension;
wxString m_DocModulesFileName; wxString m_DocModulesFileName;
FOOTPRINT_LIST m_footprints; FOOTPRINT_LIST m_footprints;
COMPONENT_LIST m_components; NETLIST m_netlist;
protected: protected:
int m_undefinedComponentCnt; int m_undefinedComponentCnt;
...@@ -60,7 +85,7 @@ public: ...@@ -60,7 +85,7 @@ public:
/** /**
* Function OnSelectComponent * Function OnSelectComponent
* Called when clicking on a component in component list window * Called when clicking on a component in component list window
* * Updates the filtered foorprint list, if the filtered list option is selected * * Updates the filtered footprint list, if the filtered list option is selected
* * Updates the current selected footprint in footprint list * * Updates the current selected footprint in footprint list
* * Updates the footprint shown in footprint display window (if opened) * * Updates the footprint shown in footprint display window (if opened)
*/ */
...@@ -141,22 +166,12 @@ public: ...@@ -141,22 +166,12 @@ public:
* file name of the netlist or cmp file. * file name of the netlist or cmp file.
* If aFullFileName is empty, a file name will be asked to the user * If aFullFileName is empty, a file name will be asked to the user
* @return 0 if an error occurred saving the link file to \a aFullFileName. * @return 0 if an error occurred saving the link file to \a aFullFileName.
* -1 if cancelled * -1 if canceled
* 1 if OK * 1 if OK
*/ */
int SaveCmpLinkFile( const wxString& aFullFileName ); int SaveCmpLinkFile( const wxString& aFullFileName );
/**
* Function LoadComponentFile
* loads the .cmp link file \a aCmpFileName which stores
* the component/footprint association.
*
* @param aFileName The full filename of .cmp file to load
* If empty, a filename will be asked to the user
*/
bool LoadComponentLinkFile( const wxString& aFileName );
/** /**
* Function WriteComponentLinkFile * Function WriteComponentLinkFile
* Writes the component footprint link file \a aFullFileName on disk. * Writes the component footprint link file \a aFullFileName on disk.
...@@ -166,16 +181,6 @@ public: ...@@ -166,16 +181,6 @@ public:
*/ */
bool WriteComponentLinkFile( const wxString& aFullFileName ); bool WriteComponentLinkFile( const wxString& aFullFileName );
/**
* Function ReadComponentLinkFile
* Reads the component footprint link file \a aFullFileName.
*
* @param aFile = the opened the opened file to read.
* ReadComponentLinkFile will close the file
* @return true if OK, false if error.
*/
bool ReadComponentLinkFile( FILE * aFile );
/** /**
* Function ReadNetList * Function ReadNetList
* reads the netlist (.net) file defined by #m_NetlistFileName. * reads the netlist (.net) file defined by #m_NetlistFileName.
......
/*********************************************************/ /*
/* cvstruct.h */ * This program source code file is part of KiCad, a free EDA CAD application.
/*********************************************************/ *
* Copyright (C) 1992-2012 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 cvstruct.h
*/
#ifndef CVSTRUCT_H #ifndef CVSTRUCT_H
#define CVSTRUCT_H #define CVSTRUCT_H
...@@ -10,6 +33,8 @@ ...@@ -10,6 +33,8 @@
/* Forward declarations of all top-level window classes. */ /* Forward declarations of all top-level window classes. */
class CVPCB_MAINFRAME; class CVPCB_MAINFRAME;
class COMPONENT;
/*********************************************************************/ /*********************************************************************/
/* ListBox (base class) to display lists of components or footprints */ /* ListBox (base class) to display lists of components or footprints */
...@@ -53,10 +78,19 @@ public: ...@@ -53,10 +78,19 @@ public:
void SetString( unsigned linecount, const wxString& text ); void SetString( unsigned linecount, const wxString& text );
void AppendLine( const wxString& text ); void AppendLine( const wxString& text );
void SetFootprintFullList( FOOTPRINT_LIST& list ); void SetFootprintFullList( FOOTPRINT_LIST& list );
void SetFootprintFilteredList( COMPONENT_INFO* Component, void SetFootprintFilteredList( COMPONENT* aComponent,
FOOTPRINT_LIST& list ); FOOTPRINT_LIST& aList );
void SetFootprintFilteredByPinCount( COMPONENT_INFO* Component, void SetFootprintFilteredByPinCount( COMPONENT* aComponent,
FOOTPRINT_LIST& list ); FOOTPRINT_LIST& aList );
/**
* Set the footprint list. We can have 2 footprint list:
* The full footprint list
* The filtered footprint list (if the current selected component has a
* filter for footprints)
* @param FullList true = full footprint list, false = filtered footprint list
* @param Redraw = true to redraw the window
*/
void SetActiveFootprintList( bool FullList, bool Redraw = false ); void SetActiveFootprintList( bool FullList, bool Redraw = false );
wxString GetSelectedFootprint(); wxString GetSelectedFootprint();
...@@ -65,6 +99,19 @@ public: ...@@ -65,6 +99,19 @@ public:
// Events functions: // Events functions:
void OnLeftClick( wxListEvent& event ); void OnLeftClick( wxListEvent& event );
void OnLeftDClick( wxListEvent& event ); void OnLeftDClick( wxListEvent& event );
/**
* Function OnChar
* called on a key pressed
* Call default handler for some special keys,
* and for "ascii" keys, select the first footprint
* that the name starts by the letter.
* This is the default behavior of a listbox, but because we use
* virtual lists, the listbox does not know anything to what is displayed,
* we must handle this behavior here.
* Furthermore the footprint name is not at the beginning of
* displayed lines (the first word is the line number)
*/
void OnChar( wxKeyEvent& event ); void OnChar( wxKeyEvent& event );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
...@@ -78,7 +125,7 @@ class COMPONENTS_LISTBOX : public ITEMS_LISTBOX_BASE ...@@ -78,7 +125,7 @@ class COMPONENTS_LISTBOX : public ITEMS_LISTBOX_BASE
{ {
public: public:
wxArrayString m_ComponentList; wxArrayString m_ComponentList;
CVPCB_MAINFRAME* m_Parent; CVPCB_MAINFRAME* m_Parent;
public: public:
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2012 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 listboxes.cpp * @file listboxes.cpp
* @brief Implementation of class for displaying footprint list and component lists. * @brief Implementation of class for displaying footprint list and component lists.
...@@ -67,9 +90,10 @@ CVPCB_MAINFRAME* ITEMS_LISTBOX_BASE::GetParent() ...@@ -67,9 +90,10 @@ CVPCB_MAINFRAME* ITEMS_LISTBOX_BASE::GetParent()
*/ */
void CVPCB_MAINFRAME::BuildCmpListBox() void CVPCB_MAINFRAME::BuildCmpListBox()
{ {
wxString msg; COMPONENT* component;
wxSize size( 10, 10 ); wxString msg;
wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); wxSize size( 10, 10 );
wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
if( m_ListCmp == NULL ) if( m_ListCmp == NULL )
{ {
...@@ -86,11 +110,14 @@ void CVPCB_MAINFRAME::BuildCmpListBox() ...@@ -86,11 +110,14 @@ void CVPCB_MAINFRAME::BuildCmpListBox()
m_ListCmp->m_ComponentList.Clear(); m_ListCmp->m_ComponentList.Clear();
BOOST_FOREACH( COMPONENT_INFO & component, m_components ) { for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
{
component = m_netlist.GetComponent( i );
msg.Printf( CMP_FORMAT, m_ListCmp->GetCount() + 1, msg.Printf( CMP_FORMAT, m_ListCmp->GetCount() + 1,
GetChars(component.m_Reference), GetChars( component->GetReference() ),
GetChars(component.m_Value), GetChars( component->GetValue() ),
GetChars(component.m_Footprint) ); GetChars( component->GetFootprintLibName() ) );
m_ListCmp->m_ComponentList.Add( msg ); m_ListCmp->m_ComponentList.Add( msg );
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <pcbstruct.h> #include <pcbstruct.h>
#include <class_module.h> #include <class_module.h>
#include <class_board.h>
#include <cvpcb.h> #include <cvpcb.h>
#include <cvpcb_mainframe.h> #include <cvpcb_mainframe.h>
...@@ -45,9 +46,9 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName ) ...@@ -45,9 +46,9 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
if( !libPath ) if( !libPath )
{ {
wxString msg = wxString::Format( wxString msg = wxString::Format( _( "PCB footprint library file <%s> could not "
_("PCB foot print library file <%s> could not be found in the default search paths." ), "be found in the default search paths." ),
fn.GetFullName().GetData() ); fn.GetFullName().GetData() );
// @todo we should not be using wxMessageBox directly. // @todo we should not be using wxMessageBox directly.
wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR, this ); wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR, this );
...@@ -58,7 +59,7 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName ) ...@@ -58,7 +59,7 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
if( footprint ) if( footprint )
{ {
footprint->SetParent( GetBoard() ); footprint->SetParent( (EDA_ITEM*) GetBoard() );
footprint->SetPosition( wxPoint( 0, 0 ) ); footprint->SetPosition( wxPoint( 0, 0 ) );
return footprint; return footprint;
} }
...@@ -74,4 +75,3 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName ) ...@@ -74,4 +75,3 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
DisplayError( this, msg ); DisplayError( this, msg );
return NULL; return NULL;
} }
...@@ -54,6 +54,7 @@ static char HeaderLinkFile[] = { "Cmp-Mod V01" }; ...@@ -54,6 +54,7 @@ static char HeaderLinkFile[] = { "Cmp-Mod V01" };
bool CVPCB_MAINFRAME::WriteComponentLinkFile( const wxString& aFullFileName ) bool CVPCB_MAINFRAME::WriteComponentLinkFile( const wxString& aFullFileName )
{ {
COMPONENT* component;
FILE* outputFile; FILE* outputFile;
wxFileName fn( aFullFileName ); wxFileName fn( aFullFileName );
wxString Title = wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion(); wxString Title = wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion();
...@@ -69,13 +70,15 @@ bool CVPCB_MAINFRAME::WriteComponentLinkFile( const wxString& aFullFileName ) ...@@ -69,13 +70,15 @@ bool CVPCB_MAINFRAME::WriteComponentLinkFile( const wxString& aFullFileName )
retval |= fprintf( outputFile, " Created by %s", TO_UTF8( Title ) ); retval |= fprintf( outputFile, " Created by %s", TO_UTF8( Title ) );
retval |= fprintf( outputFile, " date = %s\n", TO_UTF8( DateAndTime() ) ); retval |= fprintf( outputFile, " date = %s\n", TO_UTF8( DateAndTime() ) );
BOOST_FOREACH( COMPONENT_INFO& component, m_components ) for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
{ {
component = m_netlist.GetComponent( i );
retval |= fprintf( outputFile, "\nBeginCmp\n" ); retval |= fprintf( outputFile, "\nBeginCmp\n" );
retval |= fprintf( outputFile, "TimeStamp = %s;\n", TO_UTF8( component.m_TimeStamp ) ); retval |= fprintf( outputFile, "TimeStamp = %s;\n", TO_UTF8( component->GetTimeStamp() ) );
retval |= fprintf( outputFile, "Reference = %s;\n", TO_UTF8( component.m_Reference ) ); retval |= fprintf( outputFile, "Reference = %s;\n", TO_UTF8( component->GetReference() ) );
retval |= fprintf( outputFile, "ValeurCmp = %s;\n", TO_UTF8( component.m_Value ) ); retval |= fprintf( outputFile, "ValeurCmp = %s;\n", TO_UTF8( component->GetValue() ) );
retval |= fprintf( outputFile, "IdModule = %s;\n", TO_UTF8( component.m_Footprint ) ); retval |= fprintf( outputFile, "IdModule = %s;\n",
TO_UTF8( component->GetFootprintLibName() ) );
retval |= fprintf( outputFile, "EndCmp\n" ); retval |= fprintf( outputFile, "EndCmp\n" );
} }
...@@ -83,98 +86,3 @@ bool CVPCB_MAINFRAME::WriteComponentLinkFile( const wxString& aFullFileName ) ...@@ -83,98 +86,3 @@ bool CVPCB_MAINFRAME::WriteComponentLinkFile( const wxString& aFullFileName )
fclose( outputFile ); fclose( outputFile );
return retval >= 0; return retval >= 0;
} }
bool CVPCB_MAINFRAME::ReadComponentLinkFile( FILE * aFile )
{
wxString timestamp, valeur, ilib, namecmp, msg;
bool read_cmp_data = false, eof = false;
char Line[1024], * ident, * data;
// Identification of the type of link file
if( fgets( Line, sizeof(Line), aFile ) == 0 ||
strnicmp( Line, HeaderLinkFile, 11 ) != 0 )
{
fclose( aFile );
return false;
}
while( !eof && fgets( Line, sizeof(Line), aFile ) != 0 )
{
if( strnicmp( Line, "EndListe", 8 ) == 0 )
break;
/* Search the beginning of the component description. */
if( strnicmp( Line, "BeginCmp", 8 ) != 0 )
continue;
timestamp.Empty();
valeur.Empty();
ilib.Empty();
namecmp.Empty();
read_cmp_data = true;
while( !eof && read_cmp_data )
{
if( fgets( Line, 1024, aFile ) == 0 )
{
eof = true;
break;
}
if( strnicmp( Line, "EndCmp", 6 ) == 0 )
{
read_cmp_data = true;
break;
}
ident = strtok( Line, "=;\n\r" );
data = strtok( NULL, ";\n\r" );
if( strnicmp( ident, "TimeStamp", 9 ) == 0 )
{
timestamp = FROM_UTF8( data );
timestamp.Trim( true );
timestamp.Trim( false );
continue;
}
if( strnicmp( ident, "Reference", 9 ) == 0 )
{
namecmp = FROM_UTF8( data );
namecmp.Trim( true );
namecmp.Trim( false );
continue;
}
if( strnicmp( ident, "ValeurCmp", 9 ) == 0 )
{
valeur = FROM_UTF8( data );
valeur.Trim( true );
valeur.Trim( false );
continue;
}
if( strnicmp( ident, "IdModule", 8 ) == 0 )
{
ilib = FROM_UTF8( data );
ilib.Trim( true );
ilib.Trim( false );
continue;
}
} // End reading one component link block.
// Search corresponding component info in list and update its parameters.
BOOST_FOREACH( COMPONENT_INFO& component, m_components )
{
if( namecmp != component.m_Reference )
continue;
/* Copy the name of the corresponding module. */
component.m_Footprint = ilib;
}
}
fclose( aFile );
return true;
}
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
/* Read a nelist type Eeschema (New and Old format) /* Read a netlist type Eeschema (New and Old format)
* or OrcadPCB2 and build the component list * or OrcadPCB2 and build the component list
*/ */
...@@ -35,82 +35,56 @@ ...@@ -35,82 +35,56 @@
#include <confirm.h> #include <confirm.h>
#include <kicad_string.h> #include <kicad_string.h>
#include <macros.h> #include <macros.h>
#include <wildcards_and_files_ext.h>
#include <cvpcb_mainframe.h> #include <cvpcb_mainframe.h>
#include <richio.h> #include <richio.h>
#include <netlist_reader.h> #include <netlist_reader.h>
// COMPONENT_INFO object list sort function:
bool operator < ( const COMPONENT_INFO& item1, const COMPONENT_INFO& item2 )
{
return StrNumCmp( item1.m_Reference, item2.m_Reference, INT_MAX, true ) < 0;
}
int CVPCB_MAINFRAME::ReadSchematicNetlist() int CVPCB_MAINFRAME::ReadSchematicNetlist()
{ {
FILE* netfile = wxFopen( m_NetlistFileName.GetFullPath(), wxT( "rt" ) ); wxBusyCursor dummy; // Shows an hourglass while loading.
NETLIST_READER* netlistReader;
if( netfile == NULL ) wxString msg;
{ wxString compFootprintLinkFileName;
wxString msg; wxFileName fn = m_NetlistFileName;
msg.Printf( _( "Could not open file <%>" ),
GetChars( m_NetlistFileName.GetFullPath() ) );
wxMessageBox( msg );
return -1;
}
NETLIST_READER netList_Reader( NULL, NULL ); // Load the footprint association file if it has already been created.
netList_Reader.m_UseTimeStamp = false; fn.SetExt( ComponentFileExtension );
netList_Reader.m_ChangeFootprints = false;
netList_Reader.m_UseCmpFile = false;
netList_Reader.SetFilesnames( m_NetlistFileName.GetFullPath(), wxEmptyString );
// True to read footprint filters section: true for CvPcb, false for Pcbnew if( fn.FileExists() && fn.IsFileReadable() )
netList_Reader.ReadLibpartSectionSetOpt( true ); compFootprintLinkFileName = fn.GetFullPath();
// on OSX otherwise reloading a file you will see duplicates m_netlist.Clear();
m_components.clear();
bool success = netList_Reader.ReadNetList( netfile ); try
if( !success )
{ {
wxMessageBox( _("Netlist read error") ); netlistReader = NETLIST_READER::GetNetlistReader( &m_netlist,
return false; m_NetlistFileName.GetFullPath(),
compFootprintLinkFileName );
std::auto_ptr< NETLIST_READER > nlr( netlistReader );
netlistReader->LoadNetlist();
} }
catch( IO_ERROR& ioe )
// Now copy footprints info into Cvpcb list:
// We also remove footprint name if it is "$noname"
// because this is a dummy name,, not an actual name
COMPONENT_INFO_LIST& cmpInfo = netList_Reader.GetComponentInfoList();
for( unsigned ii = 0; ii < cmpInfo.size(); ii++ )
{ {
m_components.push_back( cmpInfo[ii] ); msg = wxString::Format( _( "Error loading netlist.\n%s" ), ioe.errorText.GetData() );
if( cmpInfo[ii]->m_Footprint == wxT( "$noname" ) ) wxMessageBox( msg, _( "Netlist Load Error" ), wxOK | wxICON_ERROR );
cmpInfo[ii]->m_Footprint.Empty(); return 1;
} }
cmpInfo.clear(); // cmpInfo is no more owner of the list.
// Sort components by reference:
sort( m_components.begin(), m_components.end() );
// Now copy filters in m_components, if netlist type is KICAD // We also remove footprint name if it is "$noname" because this is a dummy name,
// ( when the format is the "old" PCBNEW format, filters are already in // not the actual name of the footprint.
// m_component list for( unsigned ii = 0; ii < m_netlist.GetCount(); ii++ )
if( NETLIST_TYPE_KICAD == netList_Reader.GetNetlistType() )
{ {
for( unsigned ii = 0; ii < m_components.size(); ii++ ) if( m_netlist.GetComponent( ii )->GetFootprintLibName() == wxT( "$noname" ) )
{ m_netlist.GetComponent( ii )->SetFootprintLibName( wxEmptyString );
LIPBART_INFO* libpart = netList_Reader.GetLibpart(m_components[ii].m_Libpart);
if( libpart == NULL )
continue;
// now copy filter list
m_components[ii].m_FootprintFilter = libpart->m_FootprintFilter;
}
} }
// Sort components by reference:
m_netlist.SortByReference();
return 0; return 0;
} }
...@@ -41,17 +41,17 @@ ...@@ -41,17 +41,17 @@
void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName ) void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName )
{ {
COMPONENT_INFO* component; COMPONENT* component;
bool hasFootprint = false; bool hasFootprint = false;
int componentIndex; int componentIndex;
wxString description; wxString description;
if( m_components.empty() ) if( m_netlist.IsEmpty() )
return; return;
// if no component is selected, select the first one // If no component is selected, select the first one
if(m_ListCmp->GetFirstSelected() < 0) if( m_ListCmp->GetFirstSelected() < 0 )
{ {
componentIndex = 0; componentIndex = 0;
m_ListCmp->SetSelection( componentIndex, true ); m_ListCmp->SetSelection( componentIndex, true );
...@@ -61,28 +61,28 @@ void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName ) ...@@ -61,28 +61,28 @@ void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName )
while( m_ListCmp->GetFirstSelected() != -1) while( m_ListCmp->GetFirstSelected() != -1)
{ {
// get the component for the current iteration // Get the component for the current iteration
componentIndex = m_ListCmp->GetFirstSelected(); componentIndex = m_ListCmp->GetFirstSelected();
component = &m_components[componentIndex]; component = m_netlist.GetComponent( componentIndex );
if( component == NULL ) if( component == NULL )
return; return;
// check to see if the component has allready a footprint set. // Check to see if the component has already a footprint set.
hasFootprint = !(component->m_Footprint.IsEmpty()); hasFootprint = !(component->GetFootprintLibName().IsEmpty());
component->m_Footprint = aFootprintName; component->SetFootprintLibName( aFootprintName );
// create the new component description // create the new component description
description.Printf( CMP_FORMAT, componentIndex + 1, description.Printf( CMP_FORMAT, componentIndex + 1,
GetChars( component->m_Reference ), GetChars( component->GetReference() ),
GetChars( component->m_Value ), GetChars( component->GetValue() ),
GetChars( component->m_Footprint ) ); GetChars( component->GetFootprintLibName() ) );
// if the component hasn't had a footprint associated with it // If the component hasn't had a footprint associated with it
// it now has, so we decrement the count of components without // it now has, so we decrement the count of components without
// a footprint assigned. // a footprint assigned.
...@@ -92,12 +92,12 @@ void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName ) ...@@ -92,12 +92,12 @@ void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName )
m_undefinedComponentCnt -= 1; m_undefinedComponentCnt -= 1;
} }
// set the new description and deselect the processed component // Set the new description and deselect the processed component
m_ListCmp->SetString( componentIndex, description ); m_ListCmp->SetString( componentIndex, description );
m_ListCmp->SetSelection( componentIndex, false ); m_ListCmp->SetSelection( componentIndex, false );
} }
// mark this "session" as modified // Mark this "session" as modified
m_modified = true; m_modified = true;
// select the next component, if there is one // select the next component, if there is one
...@@ -113,22 +113,10 @@ void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName ) ...@@ -113,22 +113,10 @@ void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName )
bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles() bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles()
{ {
COMPONENT* component;
wxString msg; wxString msg;
int error_level;
error_level = ReadSchematicNetlist(); ReadSchematicNetlist();
if( error_level < 0 )
{
msg.Printf( _( "File <%s> does not appear to be a valid KiCad net list file." ),
GetChars( m_NetlistFileName.GetFullPath() ) );
wxMessageBox( msg, _( "File Error" ), wxOK | wxICON_ERROR, this );
m_NetlistFileName.Clear();
UpdateTitle();
return false;
}
LoadComponentLinkFile( m_NetlistFileName.GetFullPath() );
if( m_ListCmp == NULL ) if( m_ListCmp == NULL )
return false; return false;
...@@ -140,19 +128,21 @@ bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles() ...@@ -140,19 +128,21 @@ bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles()
m_ListCmp->Clear(); m_ListCmp->Clear();
m_undefinedComponentCnt = 0; m_undefinedComponentCnt = 0;
BOOST_FOREACH( COMPONENT_INFO& component, m_components ) for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
{ {
component = m_netlist.GetComponent( i );
msg.Printf( CMP_FORMAT, m_ListCmp->GetCount() + 1, msg.Printf( CMP_FORMAT, m_ListCmp->GetCount() + 1,
GetChars( component.m_Reference ), GetChars( component->GetReference() ),
GetChars( component.m_Value ), GetChars( component->GetValue() ),
GetChars( component.m_Footprint ) ); GetChars( component->GetFootprintLibName() ) );
m_ListCmp->AppendLine( msg ); m_ListCmp->AppendLine( msg );
if( component.m_Footprint.IsEmpty() ) if( component->GetFootprintLibName().IsEmpty() )
m_undefinedComponentCnt += 1; m_undefinedComponentCnt += 1;
} }
if( !m_components.empty() ) if( !m_netlist.IsEmpty() )
m_ListCmp->SetSelection( 0, true ); m_ListCmp->SetSelection( 0, true );
DisplayStatus(); DisplayStatus();
...@@ -165,37 +155,6 @@ bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles() ...@@ -165,37 +155,6 @@ bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles()
} }
bool CVPCB_MAINFRAME::LoadComponentLinkFile( const wxString& aFileName )
{
FILE* linkfile;
wxFileName fn = aFileName;
fn.SetExt( ComponentFileExtension );
linkfile = wxFopen( fn.GetFullPath(), wxT( "rt" ) );
if( linkfile == NULL )
{
wxString msg;
msg.Printf( _( "Cannot open CvPcb component file <%s>." ),
GetChars( fn.GetFullPath() ) );
msg << wxT( "\n" ) << _( "This is normal if you are opening a new netlist file" );
wxMessageBox( msg, titleComponentLibErr, wxOK | wxICON_ERROR );
return false;
}
// read and close the file
if( ! ReadComponentLinkFile( linkfile ) )
{
wxString msg;
msg.Printf( _( " <%s> does not appear to be a valid KiCad component link file." ),
GetChars( fn.GetFullPath() ) );
wxMessageBox( msg, titleComponentLibErr, wxOK | wxICON_ERROR );
return false;
}
return true;
}
int CVPCB_MAINFRAME::SaveCmpLinkFile( const wxString& aFullFileName ) int CVPCB_MAINFRAME::SaveCmpLinkFile( const wxString& aFullFileName )
{ {
wxFileName fn; wxFileName fn;
...@@ -207,7 +166,7 @@ int CVPCB_MAINFRAME::SaveCmpLinkFile( const wxString& aFullFileName ) ...@@ -207,7 +166,7 @@ int CVPCB_MAINFRAME::SaveCmpLinkFile( const wxString& aFullFileName )
} }
else else
{ {
wxFileDialog dlg( this, _( "Save Component/Footprint Link File" ), wxGetCwd(), wxFileDialog dlg( this, _( "Save Component Footprint Link File" ), wxGetCwd(),
wxEmptyString, ComponentFileWildcard, wxFD_SAVE ); wxEmptyString, ComponentFileWildcard, wxFD_SAVE );
if( dlg.ShowModal() == wxID_CANCEL ) if( dlg.ShowModal() == wxID_CANCEL )
...@@ -224,7 +183,7 @@ int CVPCB_MAINFRAME::SaveCmpLinkFile( const wxString& aFullFileName ) ...@@ -224,7 +183,7 @@ int CVPCB_MAINFRAME::SaveCmpLinkFile( const wxString& aFullFileName )
if( WriteComponentLinkFile( fn.GetFullPath() ) == 0 ) if( WriteComponentLinkFile( fn.GetFullPath() ) == 0 )
{ {
DisplayError( this, _( "Unable to create component file (.cmp)" ) ); DisplayError( this, _( "Unable to create component footprint link file (.cmp)" ) );
return 0; return 0;
} }
......
...@@ -148,7 +148,7 @@ void CMP_LIBRARY::GetEntryNames( wxArrayString& aNames, bool aSort, bool aMakeUp ...@@ -148,7 +148,7 @@ void CMP_LIBRARY::GetEntryNames( wxArrayString& aNames, bool aSort, bool aMakeUp
* simple function used as comparator to sort a std::vector<wxArrayString>&. * simple function used as comparator to sort a std::vector<wxArrayString>&.
* *
* @param aItem1 is the first comparison parameter. * @param aItem1 is the first comparison parameter.
* @param aItem1 is the second. * @param aItem2 is the second.
* @return bool - which item should be put first in the sorted list. * @return bool - which item should be put first in the sorted list.
*/ */
bool sortFunction( wxArrayString aItem1, wxArrayString aItem2 ) bool sortFunction( wxArrayString aItem1, wxArrayString aItem2 )
......
...@@ -188,9 +188,6 @@ NETLIST_DIALOG::NETLIST_DIALOG( SCH_EDIT_FRAME* parent ) : ...@@ -188,9 +188,6 @@ NETLIST_DIALOG::NETLIST_DIALOG( SCH_EDIT_FRAME* parent ) :
long tmp; long tmp;
m_config->Read( NETLIST_USE_DEFAULT_NETNAME, &tmp, 0l ); m_config->Read( NETLIST_USE_DEFAULT_NETNAME, &tmp, 0l );
m_cbUseDefaultNetlistName->SetValue( tmp ); m_cbUseDefaultNetlistName->SetValue( tmp );
m_config->Read( NETLIST_PSPICE_USE_NETNAME, &m_spiceNetlistUseNames, true );
m_NetFmtName = m_Parent->GetNetListFormatName(); m_NetFmtName = m_Parent->GetNetListFormatName();
for( int ii = 0; ii < PANELCUSTOMBASE + CUSTOMPANEL_COUNTMAX; ii++ ) for( int ii = 0; ii < PANELCUSTOMBASE + CUSTOMPANEL_COUNTMAX; ii++ )
...@@ -268,18 +265,6 @@ void NETLIST_DIALOG::InstallPageSpice() ...@@ -268,18 +265,6 @@ void NETLIST_DIALOG::InstallPageSpice()
page->m_AddSubPrefix->SetValue( m_Parent->GetAddReferencePrefix() ); page->m_AddSubPrefix->SetValue( m_Parent->GetAddReferencePrefix() );
page->m_LeftBoxSizer->Add( page->m_AddSubPrefix, 0, wxGROW | wxALL, 5 ); page->m_LeftBoxSizer->Add( page->m_AddSubPrefix, 0, wxGROW | wxALL, 5 );
wxString netlist_opt[2] = { _( "Use Net Names" ), _( "Use Net Numbers" ) };
page->m_NetOption = new wxRadioBox( page, -1, _( "Netlist Options:" ),
wxDefaultPosition, wxDefaultSize,
2, netlist_opt, 1,
wxRA_SPECIFY_COLS );
if( !m_spiceNetlistUseNames )
page->m_NetOption->SetSelection( 1 );
page->m_LeftBoxSizer->Add( page->m_NetOption, 0, wxGROW | wxALL, 5 );
page->m_LowBoxSizer->Add( new wxStaticText( page, -1, _( "Simulator command:" ) ), 0, page->m_LowBoxSizer->Add( new wxStaticText( page, -1, _( "Simulator command:" ) ), 0,
wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
...@@ -438,11 +423,6 @@ void NETLIST_DIALOG::NetlistUpdateOpt() ...@@ -438,11 +423,6 @@ void NETLIST_DIALOG::NetlistUpdateOpt()
if( m_PanelNetType[ii]->m_IsCurrentFormat->GetValue() == true ) if( m_PanelNetType[ii]->m_IsCurrentFormat->GetValue() == true )
m_Parent->SetNetListFormatName( m_PanelNetType[ii]->GetPageNetFmtName() ); m_Parent->SetNetListFormatName( m_PanelNetType[ii]->GetPageNetFmtName() );
} }
m_spiceNetlistUseNames = true; // Used for pspice, gnucap
if( m_PanelNetType[PANELSPICE]->m_NetOption->GetSelection() == 1 )
m_spiceNetlistUseNames = false;
} }
...@@ -475,8 +455,6 @@ void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event ) ...@@ -475,8 +455,6 @@ void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event )
{ {
case NET_TYPE_SPICE: case NET_TYPE_SPICE:
// Set spice netlist options: // Set spice netlist options:
if( m_spiceNetlistUseNames )
netlist_opt |= NET_USE_NETNAMES;
if( currPage->m_AddSubPrefix->GetValue() ) if( currPage->m_AddSubPrefix->GetValue() )
netlist_opt |= NET_USE_X_PREFIX; netlist_opt |= NET_USE_X_PREFIX;
break; break;
...@@ -647,13 +625,10 @@ void NETLIST_DIALOG::RunSimulator( wxCommandEvent& event ) ...@@ -647,13 +625,10 @@ void NETLIST_DIALOG::RunSimulator( wxCommandEvent& event )
NETLIST_PAGE_DIALOG* currPage; NETLIST_PAGE_DIALOG* currPage;
currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage(); currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage();
m_spiceNetlistUseNames = currPage->m_NetOption->GetSelection() == 0;
// Set spice netlist options: // Set spice netlist options:
unsigned netlist_opt = 0; unsigned netlist_opt = 0;
if( m_spiceNetlistUseNames )
netlist_opt |= NET_USE_NETNAMES;
if( currPage->m_AddSubPrefix && currPage->m_AddSubPrefix->GetValue() ) if( currPage->m_AddSubPrefix && currPage->m_AddSubPrefix->GetValue() )
netlist_opt |= NET_USE_X_PREFIX; netlist_opt |= NET_USE_X_PREFIX;
...@@ -676,7 +651,6 @@ void NETLIST_DIALOG::WriteCurrentNetlistSetup( void ) ...@@ -676,7 +651,6 @@ void NETLIST_DIALOG::WriteCurrentNetlistSetup( void )
NetlistUpdateOpt(); NetlistUpdateOpt();
m_config->Write( NETLIST_USE_DEFAULT_NETNAME, GetUseDefaultNetlistName() ); m_config->Write( NETLIST_USE_DEFAULT_NETNAME, GetUseDefaultNetlistName() );
m_config->Write( NETLIST_PSPICE_USE_NETNAME, m_spiceNetlistUseNames );
// Update the new titles // Update the new titles
for( int ii = 0; ii < CUSTOMPANEL_COUNTMAX; ii++ ) for( int ii = 0; ii < CUSTOMPANEL_COUNTMAX; ii++ )
......
...@@ -110,7 +110,6 @@ public: ...@@ -110,7 +110,6 @@ public:
// Options for Spice netlist generation (OR'ed bits // Options for Spice netlist generation (OR'ed bits
enum netlistOptions { enum netlistOptions {
NET_USE_NETNAMES = 1, // for Spice netlist : use netnames instead of numbers
NET_USE_X_PREFIX = 2, // for Spice netlist : change "U" and "IC" reference prefix to "X" NET_USE_X_PREFIX = 2, // for Spice netlist : change "U" and "IC" reference prefix to "X"
NET_PCBNEW_USE_NEW_FORMAT = 1, // For Pcbnew use the new format (S expression and SWEET) NET_PCBNEW_USE_NEW_FORMAT = 1, // For Pcbnew use the new format (S expression and SWEET)
}; };
...@@ -125,8 +124,6 @@ public: ...@@ -125,8 +124,6 @@ public:
private: private:
wxConfig* m_config; wxConfig* m_config;
bool m_spiceNetlistUseNames; /* true to use names rather than net
* numbers (PSPICE netlist only) */
public: public:
......
...@@ -32,10 +32,9 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event ) ...@@ -32,10 +32,9 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event )
newitem->SetTimeStamp( GetNewTimeStamp() ); newitem->SetTimeStamp( GetNewTimeStamp() );
newitem->ClearAnnotation( NULL ); newitem->ClearAnnotation( NULL );
newitem->SetFlags( IS_NEW ); newitem->SetFlags( IS_NEW );
MoveItem( (SCH_ITEM*) newitem, &dc ); // Draw the new part, MoveItem() expects it to be already on screen.
newitem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
// Redraw the original part, because StartMovePart() erased it from screen. MoveItem( newitem, &dc );
curr_item->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
} }
break; break;
...@@ -46,10 +45,9 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event ) ...@@ -46,10 +45,9 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event )
{ {
SCH_TEXT* newitem = (SCH_TEXT*) curr_item->Clone(); SCH_TEXT* newitem = (SCH_TEXT*) curr_item->Clone();
newitem->SetFlags( IS_NEW ); newitem->SetFlags( IS_NEW );
MoveItem( (SCH_ITEM*) newitem, &dc ); // Draw the new item, MoveItem() expects it to be already on screen.
newitem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
/* Redraw the original part in XOR mode */ MoveItem( newitem, &dc );
curr_item->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
} }
break; break;
......
...@@ -298,12 +298,10 @@ public: ...@@ -298,12 +298,10 @@ public:
* .-PSpice or .-gnucap put at beginning of the netlist * .-PSpice or .-gnucap put at beginning of the netlist
* .+PSpice or .-genucap are put at end of the netList * .+PSpice or .-genucap are put at end of the netList
* @param f = the file to write to * @param f = the file to write to
* @param use_netnames = true, to use netnames in netlist,
* false to use net number.
* @param aUsePrefix = true, adds an 'X' prefix to any reference designator starting with "U" or "IC", * @param aUsePrefix = true, adds an 'X' prefix to any reference designator starting with "U" or "IC",
* false to leave reference designator unchanged. * false to leave reference designator unchanged.
*/ */
bool WriteNetListPspice( FILE* f, bool use_netnames, bool aUsePrefix ); bool WriteNetListPspice( FILE* f, bool aUsePrefix );
/** /**
* Function MakeCommandLine * Function MakeCommandLine
...@@ -360,8 +358,6 @@ wxString NETLIST_EXPORT_TOOL::MakeCommandLine( const wxString& aFormatString, ...@@ -360,8 +358,6 @@ wxString NETLIST_EXPORT_TOOL::MakeCommandLine( const wxString& aFormatString,
* param aFullFileName = full netlist file name * param aFullFileName = full netlist file name
* param aNetlistOptions = netlist options using OR'ed bits. * param aNetlistOptions = netlist options using OR'ed bits.
* For SPICE netlist only: * For SPICE netlist only:
* if NET_USE_NETNAMES is set, use net names from labels in schematic
* else use net numbers (net codes)
* if NET_USE_X_PREFIX is set : change "U" and "IC" refernce prefix to "X" * if NET_USE_X_PREFIX is set : change "U" and "IC" refernce prefix to "X"
* return true if success. * return true if success.
*/ */
...@@ -381,7 +377,7 @@ bool SCH_EDIT_FRAME::WriteNetListFile( int aFormat, const wxString& aFullFileNam ...@@ -381,7 +377,7 @@ bool SCH_EDIT_FRAME::WriteNetListFile( int aFormat, const wxString& aFullFileNam
if( ( f = wxFopen( aFullFileName, wxT( "wt" ) ) ) == NULL ) if( ( f = wxFopen( aFullFileName, wxT( "wt" ) ) ) == NULL )
{ {
wxString msg; wxString msg;
msg.Printf( _( "Failed to create file <%s>" ), msg.Printf( _( "Failed to create file <%s>" ),
GetChars( aFullFileName ) ); GetChars( aFullFileName ) );
DisplayError( this, msg ); DisplayError( this, msg );
return false; return false;
...@@ -413,9 +409,7 @@ bool SCH_EDIT_FRAME::WriteNetListFile( int aFormat, const wxString& aFullFileNam ...@@ -413,9 +409,7 @@ bool SCH_EDIT_FRAME::WriteNetListFile( int aFormat, const wxString& aFullFileNam
break; break;
case NET_TYPE_SPICE: case NET_TYPE_SPICE:
ret = helper.WriteNetListPspice( f, ret = helper.WriteNetListPspice( f, aNetlistOptions & NET_USE_X_PREFIX );
aNetlistOptions & NET_USE_NETNAMES,
aNetlistOptions & NET_USE_X_PREFIX );
fclose( f ); fclose( f );
break; break;
...@@ -1086,110 +1080,16 @@ bool NETLIST_EXPORT_TOOL::WriteGENERICNetList( const wxString& aOutFileName ) ...@@ -1086,110 +1080,16 @@ bool NETLIST_EXPORT_TOOL::WriteGENERICNetList( const wxString& aOutFileName )
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ ) for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
g_NetObjectslist[ii]->m_Flag = 0; g_NetObjectslist[ii]->m_Flag = 0;
#if 1
// output the XML format netlist. // output the XML format netlist.
wxXmlDocument xdoc; wxXmlDocument xdoc;
xdoc.SetRoot( makeGenericRoot() ); xdoc.SetRoot( makeGenericRoot() );
return xdoc.Save( aOutFileName, 2 /* indent bug, today was ignored by wxXml lib */ ); return xdoc.Save( aOutFileName, 2 /* indent bug, today was ignored by wxXml lib */ );
#else // output the well established/old generic net list format which was not XML.
wxString field;
wxString footprint;
wxString netname;
FILE* out;
int ret = 0; // OR on each call, test sign bit at very end.
if( ( out = wxFopen( aOutFileName, wxT( "wt" ) ) ) == NULL )
{
wxString msg;
msg.Printf( _( "Failed to create file <%s>" ), GetChars( aOutFileName ) );
DisplayError( NULL, msg );
return false;
}
m_ReferencesAlreadyFound.Clear();
ret |= fprintf( out, "$BeginNetlist\n" );
// Create netlist module section
ret |= fprintf( out, "$BeginComponentList\n" );
SCH_SHEET_LIST sheetList;
for( SCH_SHEET_PATH* path = sheetList.GetFirst(); path; path = sheetList.GetNext() )
{
for( EDA_ITEM* schItem = path->LastDrawList(); schItem; schItem = schItem->Next() )
{
SCH_COMPONENT* comp = findNextComponentAndCreatePinList( schItem, path );
if( !comp )
break; // No component left
schItem = comp;
footprint.Empty();
if( !comp->GetField( FOOTPRINT )->IsVoid() )
{
footprint = comp->GetField( FOOTPRINT )->m_Text;
footprint.Replace( wxT( " " ), wxT( "_" ) );
}
ret |= fprintf( out, "\n$BeginComponent\n" );
ret |= fprintf( out, "TimeStamp=%8.8lX\n", comp->m_TimeStamp );
ret |= fprintf( out, "Footprint=%s\n", TO_UTF8( footprint ) );
field = wxT( "Reference=" ) + comp->GetRef( path ) + wxT( "\n" );
field.Replace( wxT( " " ), wxT( "_" ) );
ret |= fputs( TO_UTF8( field ), out );
field = comp->GetField( VALUE )->m_Text;
field.Replace( wxT( " " ), wxT( "_" ) );
ret |= fprintf( out, "Value=%s\n", TO_UTF8( field ) );
field = comp->GetLibName();
field.Replace( wxT( " " ), wxT( "_" ) );
ret |= fprintf( out, "Libref=%s\n", TO_UTF8( field ) );
// Write pin list:
ret |= fprintf( out, "$BeginPinList\n" );
for( unsigned ii = 0; ii < m_SortedComponentPinList.size(); ii++ )
{
NETLIST_OBJECT* Pin = m_SortedComponentPinList[ii];
if( !Pin )
continue;
sprintPinNetName( &netname, wxT( "$-%.6d" ), Pin );
if( netname.IsEmpty() )
netname = wxT( "?" );
ret |= fprintf( out, "%.4s=%s\n", (char*) &Pin->m_PinNum, TO_UTF8( netname ) );
}
ret |= fprintf( out, "$EndPinList\n" );
ret |= fprintf( out, "$EndComponent\n" );
}
}
ret |= fprintf( out, "$EndComponentList\n" );
ret |= fprintf( out, "\n$BeginNets\n" );
if( !writeGENERICListOfNets( out, g_NetObjectslist ) )
ret = -1;
ret |= fprintf( out, "$EndNets\n" );
ret |= fprintf( out, "\n$EndNetlist\n" );
ret |= fclose( out );
return ret >= 0;
#endif
} }
bool NETLIST_EXPORT_TOOL::WriteNetListPspice( FILE* f, bool use_netnames, bool aUsePrefix ) bool NETLIST_EXPORT_TOOL::WriteNetListPspice( FILE* f, bool aUsePrefix )
{ {
int ret = 0; int ret = 0;
int nbitems; int nbitems;
...@@ -1406,17 +1306,8 @@ bool NETLIST_EXPORT_TOOL::WriteNetListPspice( FILE* f, bool use_netnames, bool a ...@@ -1406,17 +1306,8 @@ bool NETLIST_EXPORT_TOOL::WriteNetListPspice( FILE* f, bool use_netnames, bool a
if( netName.IsEmpty() ) if( netName.IsEmpty() )
netName = wxT( "?" ); netName = wxT( "?" );
if( use_netnames ) ret |= fprintf( f, " %s", TO_UTF8( netName ) );
ret |= fprintf( f, " %s", TO_UTF8( netName ) );
else // Use number for net names (net number = 0 for "GND")
{
// NetName = "0" is "GND" net for Spice
if( netName == wxT( "0" ) || netName == wxT( "GND" ) )
ret |= fprintf( f, " 0" );
else
ret |= fprintf( f, " %d", pin->GetNet() );
}
} }
// Get Component Value Name: // Get Component Value Name:
......
...@@ -146,7 +146,10 @@ void SCH_EDIT_FRAME::BuildNetListBase() ...@@ -146,7 +146,10 @@ void SCH_EDIT_FRAME::BuildNetListBase()
if( g_NetObjectslist.size() == 0 ) if( g_NetObjectslist.size() == 0 )
return; // no objects return; // no objects
activity += wxString::Format( _( " net count = %u" ), g_NetObjectslist.size() ); /* The new %zu specification is needed to properly format a size_t
* value (returned by size(), here) */
activity += wxString::Format( _( " net count = %zu" ),
g_NetObjectslist.size() );
SetStatusText( activity ); SetStatusText( activity );
/* Sort objects by Sheet */ /* Sort objects by Sheet */
......
if(UNIX) # Install the *.xsl file(s), user will need to install 'xsltproc' and setup
add_definitions(-D__UNIX__) # EESCHEMA's netlist plugins
endif(UNIX) # See chapter 14 of eeschema.pdf
# add_executable(netlist_form_pads-pcb netlist_form_pads-pcb.cpp)
# install(TARGETS netlist_form_pads-pcb DESTINATION ${KICAD_PLUGINS} COMPONENT binary)
# install the *.xsl file(s), user will need to install 'xsltproc' and setup set( xsl_lst
# EESCHEMA's netlist plugins bom2csv.xsl
install( FILES bom_cvs.xsl
netlist_form_pads-pcb.xsl netlist_form_cadstar-RINF.xsl
DESTINATION ${KICAD_PLUGINS} netlist_form_cadstar.xsl
COMPONENT binary netlist_form_OrcadPcb2.xsl
) netlist_form_pads-pcb.xsl
)
install( FILES ${xsl_lst}
DESTINATION ${KICAD_PLUGINS}
COMPONENT binary
)
<!--XSL style sheet to convert EESCHEMA XML Partlist Format to CSV BOM Format
Copyright (C) 2013, Stefan Helmert.
GPL v2.
Functionality:
Generation of csv table with table head of all existing field names
and correct assigned cell entries
How to use this is explained in eeschema.pdf chapter 14. You enter a command line into the
netlist exporter using a new (custom) tab in the netlist export dialog. The command is
similar to
on Windows:
xsltproc -o "%O.csv" "C:\Program Files (x86)\KiCad\bin\plugins\bom2csv.xsl" "%I"
on Linux:
xsltproc -o "%O.csv" /usr/local/lib/kicad/plugins/bom2csv.xsl "%I"
Instead of "%O.csv" you can alternatively use "%O" if you will supply your own file extension when
prompted in the UI. The double quotes are there to account for the possibility of space(s)
in the filename.
-->
<!DOCTYPE xsl:stylesheet [
<!ENTITY nl "&#xd;&#xa;"> <!--new line CR, LF, or LF, your choice -->
]>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text"/>
<!-- for table head and empty table fields-->
<xsl:key name="headentr" match="field" use="@name"/>
<!-- main part -->
<xsl:template match="/export">
<xsl:text>Reference, Value, Footprint, Datasheet</xsl:text>
<!-- find all existing table head entries and list each one once -->
<xsl:for-each select="components/comp/fields/field[generate-id(.) = generate-id(key('headentr',@name)[1])]">
<xsl:text>, </xsl:text>
<xsl:value-of select="@name"/>
</xsl:for-each>
<xsl:text>&nl;</xsl:text>
<!-- all table entries -->
<xsl:apply-templates select="components/comp"/>
</xsl:template>
<!-- the table entries -->
<xsl:template match="components/comp">
<xsl:value-of select="@ref"/><xsl:text>,</xsl:text>
<xsl:value-of select="value"/><xsl:text>,</xsl:text>
<xsl:value-of select="footprint"/><xsl:text>,</xsl:text>
<xsl:value-of select="datasheet"/>
<xsl:apply-templates select="fields"/>
<xsl:text>&nl;</xsl:text>
</xsl:template>
<!-- table entries with dynamic table head -->
<xsl:template match="fields">
<!-- remember current fields section -->
<xsl:variable name="fieldvar" select="field"/>
<!-- for all existing head entries -->
<xsl:for-each select="/export/components/comp/fields/field[generate-id(.) = generate-id(key('headentr',@name)[1])]">
<xsl:variable name="allnames" select="@name"/>
<xsl:text>,</xsl:text>
<!-- for all field entries in the remembered fields section -->
<xsl:for-each select="$fieldvar">
<!-- only if this field entry exists in this fields section -->
<xsl:if test="@name=$allnames">
<!-- content of the field -->
<xsl:value-of select="."/>
</xsl:if>
<!--
If it does not exist, use an empty cell in output for this row.
Every non-blank entry is assigned to its proper column.
-->
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
...@@ -46,7 +46,6 @@ ...@@ -46,7 +46,6 @@
extern void IncrementLabelMember( wxString& name ); extern void IncrementLabelMember( wxString& name );
extern int OverbarPositionY( int size_v, int thickness );
/* Names of sheet label types. */ /* Names of sheet label types. */
...@@ -1320,11 +1319,11 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const ...@@ -1320,11 +1319,11 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const
int x = symb_len + linewidth + 3; int x = symb_len + linewidth + 3;
// Use negation bar Y position to calculate full vertical size // Use negation bar Y position to calculate full vertical size
#define Y_CORRECTION 1.22 #define Y_CORRECTION 1.3
// Note: this factor is due to the fact the negation bar Y position // Note: this factor is due to the fact the negation bar Y position
// does not give exactly the full Y size of text // does not give exactly the full Y size of text
// and is experimentally set to this value // and is experimentally set to this value
int y = KiROUND( OverbarPositionY( HalfSize, linewidth ) * Y_CORRECTION ); int y = KiROUND( OverbarPositionY( HalfSize ) * Y_CORRECTION );
// add room for line thickness and space between top of text and graphic shape // add room for line thickness and space between top of text and graphic shape
y += linewidth; y += linewidth;
......
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2004-2013 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
......
...@@ -758,6 +758,8 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command, ...@@ -758,6 +758,8 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
break; break;
} }
(void) seq_len; // quiet g++, or delete the unused variable.
ok = GetEndOfBlock( buff, text, m_Current_File ); ok = GetEndOfBlock( buff, text, m_Current_File );
return ok; return ok;
...@@ -788,6 +790,7 @@ bool GetEndOfBlock( char buff[GERBER_BUFZ], char*& text, FILE* gerber_file ) ...@@ -788,6 +790,7 @@ bool GetEndOfBlock( char buff[GERBER_BUFZ], char*& text, FILE* gerber_file )
return false; return false;
} }
/** /**
* Function GetNextLine * Function GetNextLine
* test for an end of line * test for an end of line
......
...@@ -259,7 +259,7 @@ public: ...@@ -259,7 +259,7 @@ public:
* true. * true.
* @param aList = array of PARAM_CFG_BASE pointers * @param aList = array of PARAM_CFG_BASE pointers
*/ */
void SaveCurrentSetupValues( const PARAM_CFG_ARRAY& List ); void SaveCurrentSetupValues( const PARAM_CFG_ARRAY& aList );
/** /**
* Function ReadCurrentSetupValues * Function ReadCurrentSetupValues
...@@ -268,7 +268,7 @@ public: ...@@ -268,7 +268,7 @@ public:
* true. * true.
* @param aList = array of PARAM_CFG_BASE pointers * @param aList = array of PARAM_CFG_BASE pointers
*/ */
void ReadCurrentSetupValues( const PARAM_CFG_ARRAY& List ); void ReadCurrentSetupValues( const PARAM_CFG_ARRAY& aList );
/** /**
* Function ReadProjectConfig * Function ReadProjectConfig
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2010 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2012 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 dialog_helpers.h * @file dialog_helpers.h
* @brief Helper dialog and control classes. * @brief Helper dialog and control classes.
...@@ -38,6 +62,7 @@ public: ...@@ -38,6 +62,7 @@ public:
* Constructor: * Constructor:
* @param aParent Pointer to the parent window. * @param aParent Pointer to the parent window.
* @param aTitle = The title shown on top. * @param aTitle = The title shown on top.
* @param aItemHeaders is an array containing the column header names for the dialog.
* @param aItemList = A wxArrayString of the list of elements. * @param aItemList = A wxArrayString of the list of elements.
* @param aRefText = An item name if an item must be preselected. * @param aRefText = An item name if an item must be preselected.
* @param aCallBackFunction = callback function to display comments * @param aCallBackFunction = callback function to display comments
......
...@@ -10,9 +10,20 @@ ...@@ -10,9 +10,20 @@
#include <base_struct.h> #include <base_struct.h>
#include <eda_text.h> // EDA_TEXT_HJUSTIFY_T and EDA_TEXT_VJUSTIFY_T #include <eda_text.h> // EDA_TEXT_HJUSTIFY_T and EDA_TEXT_VJUSTIFY_T
/// Minimum dimension in pixel for drawing text /* Minimum dimension in pixel for drawing/no drawing a text
* used in Pcbnew to decide to draw (or not) some texts
* ( like net names on pads/tracks )
* When a text height is smaller than MIN_TEXT_SIZE,
* it is not drawn by Pcbnew
*/
#define MIN_TEXT_SIZE 5 #define MIN_TEXT_SIZE 5
/* Absolute minimum dimension in pixel to draw a text as text or a line
* When a text height is smaller than MIN_DRAWABLE_TEXT_SIZE,
* it is drawn, but like a line by the draw text function
*/
#define MIN_DRAWABLE_TEXT_SIZE 3
class EDA_DRAW_PANEL; class EDA_DRAW_PANEL;
class PLOTTER; class PLOTTER;
...@@ -50,6 +61,12 @@ int ReturnGraphicTextWidth( const wxString& aText, int size_h, bool italic, bool ...@@ -50,6 +61,12 @@ int ReturnGraphicTextWidth( const wxString& aText, int size_h, bool italic, bool
* Return the text length of a negable string, excluding the ~ markers */ * Return the text length of a negable string, excluding the ~ markers */
int NegableTextLength( const wxString& aText ); int NegableTextLength( const wxString& aText );
/**
* Helper function for texts with over bar, can be used as strut value
* for multiline text (add interline spacing)
*/
int OverbarPositionY( int size_v );
/** /**
* Function DrawGraphicText * Function DrawGraphicText
* Draw a graphic text (like module texts) * Draw a graphic text (like module texts)
......
...@@ -133,8 +133,31 @@ public: ...@@ -133,8 +133,31 @@ public:
const std::string& aRevision ) const std::string& aRevision )
throw( PARSE_ERROR ); throw( PARSE_ERROR );
/**
* Function clear
* clears the contents of the library nickname, footprint name, and revision strings.
*/
void clear(); void clear();
/**
* Function empty
* @return a boolean true value if the FPID is empty. Otherwise return false.
*/
bool empty() const { return nickname.empty() && footprint.empty() && revision.empty(); }
/**
* Function Compare
* compares the contents of FPID objects by performing a std::string comparison of the
* library nickname, footprint name, and revision strings respectively.
*
* @param aFPID is the FPID to compare against.
* @return -1 if less than \a aFPID, 1 if greater than \a aFPID, and 0 if equal to \a aFPID.
*/
int compare( const FPID& aFPID ) const;
bool operator <( const FPID& aFPID ) const { return this->compare( aFPID ) < 0; }
bool operator ==( const FPID& aFPID ) const { return this->compare( aFPID ) == 0; }
#if defined(DEBUG) #if defined(DEBUG)
static void Test(); static void Test();
#endif #endif
......
#ifndef _REPORTER_H_
#define _REPORTER_H_
/**
* @file reporter.h
* @author Wayne Stambaugh
* @note A special thanks to Dick Hollenbeck who came up with the idea that inspired
* me to write this.
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2013 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
*/
class wxString;
class wxTextCtrl;
/**
* Class REPORTER
* is a pure virtual class used to derive REPORTOR objects from.
*
* The purpose of the REPORTER object is to hide an object that take a string as an input
* from other objects. This prevents objects such as wxWidgets UI control internals from
* being exposed to low level KiCad objects dervice from #BOARD_ITEM and #SCH_ITEM.
*/
class REPORTER
{
public:
/**
* Function Report
* is a pure virtual function to override in the derived object.
*
* @param aText is the string to report.
*/
virtual REPORTER& Report( const wxString& aText ) = 0;
REPORTER& Report( const char *aText );
REPORTER& operator <<( const wxString& aText ) { return Report( aText ); }
REPORTER& operator <<( const wxChar* aText ) { return Report( wxString( aText ) ); }
REPORTER& operator <<( wxChar aChar ) { return Report( wxString( aChar ) ); }
REPORTER& operator <<( const char* aText ) { return Report( aText ); }
};
/**
* Class WX_TEXT_CTRL_REPORTER
* is wrapper for reporting to a wxTextCtrl object.
*/
class WX_TEXT_CTRL_REPORTER : public REPORTER
{
wxTextCtrl* m_textCtrl;
public:
WX_TEXT_CTRL_REPORTER( wxTextCtrl* aTextCtrl ) :
REPORTER(),
m_textCtrl( aTextCtrl )
{
}
REPORTER& Report( const wxString& aText );
};
#endif // _REPORTER_H_
...@@ -98,6 +98,7 @@ extern const wxString KiCadFootprintLibFileWildcard; ...@@ -98,6 +98,7 @@ extern const wxString KiCadFootprintLibFileWildcard;
extern const wxString KiCadFootprintLibPathWildcard; extern const wxString KiCadFootprintLibPathWildcard;
extern const wxString GedaPcbFootprintLibFileWildcard; extern const wxString GedaPcbFootprintLibFileWildcard;
extern const wxString EagleFootprintLibPathWildcard; extern const wxString EagleFootprintLibPathWildcard;
extern const wxString TextWildcard;
#endif // INCLUDE_WILDCARDS_AND_FILES_EXT_H_ #endif // INCLUDE_WILDCARDS_AND_FILES_EXT_H_
...@@ -91,6 +91,19 @@ protected: ...@@ -91,6 +91,19 @@ protected:
void updateZoomSelectBox(); void updateZoomSelectBox();
virtual void unitsChangeRefresh(); virtual void unitsChangeRefresh();
/**
* Function loadFootprint
* attempts to load \a aFootprintName from the list of libraries.
*
* @param aFootprintName is the name of component footprint to load.
* @return the #MODULE if found or NULL if \a aFootprintName not found in any of the
* libraries.
* @throw IO_ERROR if an I/O error occurs or a #PARSE_ERROR if a file parsing error
* occurs while reading footprint library files.
*/
MODULE* loadFootprint( const wxString& aFootprintName )
throw( IO_ERROR, PARSE_ERROR );
public: public:
PCB_BASE_FRAME( wxWindow* aParent, ID_DRAWFRAME_TYPE aFrameType, PCB_BASE_FRAME( wxWindow* aParent, ID_DRAWFRAME_TYPE aFrameType,
const wxString& aTitle, const wxString& aTitle,
......
...@@ -59,6 +59,10 @@ class PCB_LAYER_WIDGET; ...@@ -59,6 +59,10 @@ class PCB_LAYER_WIDGET;
class MARKER_PCB; class MARKER_PCB;
class BOARD_ITEM; class BOARD_ITEM;
class PCB_LAYER_BOX_SELECTOR; class PCB_LAYER_BOX_SELECTOR;
class NETLIST;
class REPORTER;
class PARSE_ERROR;
class IO_ERROR;
/** /**
...@@ -80,6 +84,18 @@ class PCB_EDIT_FRAME : public PCB_BASE_FRAME ...@@ -80,6 +84,18 @@ class PCB_EDIT_FRAME : public PCB_BASE_FRAME
/// The auxiliary right vertical tool bar used to access the microwave tools. /// The auxiliary right vertical tool bar used to access the microwave tools.
wxAuiToolBar* m_microWaveToolBar; wxAuiToolBar* m_microWaveToolBar;
/**
* Function loadFootprints
* loads the footprints for each #COMPONENT in \a aNetlist from the list of libraries.
*
* @param aNetlist is the netlist of components to load the footprints into.
* @param aReporter is the #REPORTER object to report to.
* @throw IO_ERROR if an I/O error occurs or a #PARSE_ERROR if a file parsing error
* occurs while reading footprint library files.
*/
void loadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
throw( IO_ERROR, PARSE_ERROR );
protected: protected:
#ifdef KICAD_SCRIPTING_WXPYTHON #ifdef KICAD_SCRIPTING_WXPYTHON
...@@ -414,27 +430,6 @@ public: ...@@ -414,27 +430,6 @@ public:
m_useCmpFileForFpNames = aUseCmpfile; m_useCmpFileForFpNames = aUseCmpfile;
} }
/**
* Function Test_Duplicate_Missing_And_Extra_Footprints
* Build a list of duplicate, missing and extra footprints
* from the current board and a netlist netlist :
* Shows 3 lists:
* 1 - duplicate footprints on board
* 2 - missing footprints (found in netlist but not on board)
* 3 - footprints not in netlist but on board
* @param aFilename = the full filename netlist
* @param aDuplicate = the list of duplicate modules to populate
* @param aMissing = the list of missing module references and values
* to populate. For each missing item, the first string is the ref,
* the second is the value.
* @param aNotInNetlist = the list of not-in-netlist modules to populate
* @return true if the netlist was read, or false
*/
bool Test_Duplicate_Missing_And_Extra_Footprints( const wxString& aFilename,
std::vector <MODULE*>& aDuplicate,
wxArrayString& aMissing,
std::vector <MODULE*>& aNotInNetlist );
/** /**
* Function OnHotKey. * Function OnHotKey.
* ** Commands are case insensitive ** * ** Commands are case insensitive **
...@@ -967,6 +962,11 @@ public: ...@@ -967,6 +962,11 @@ public:
*/ */
void Access_to_External_Tool( wxCommandEvent& event ); void Access_to_External_Tool( wxCommandEvent& event );
/**
* Function ListAndSelectModuleName
* builds and shows a list of existing modules on board that the user can select.
* @return a pointer to the selected module or NULL.
*/
MODULE* ListAndSelectModuleName(); MODULE* ListAndSelectModuleName();
/** /**
...@@ -1428,29 +1428,31 @@ public: ...@@ -1428,29 +1428,31 @@ public:
/** /**
* Function ReadPcbNetlist * Function ReadPcbNetlist
* Update footprints (load missing footprints and delete on demand extra * reads \a aNetlistFileName and ppdates the footprints (load missing footprints and
* footprints) * delete on demand extra footprints) on the board.
* Update connectivity info, references, values and "TIME STAMP" * Update connectivity info, references, values and "TIME STAMP"
* @param aNetlistFullFilename = netlist file name (*.net) *
* @param aCmpFullFileName = cmp/footprint link file name (*.cmp). * @param aNetlistFileName = netlist file name (*.net)
* if not found or empty, only the netlist will be used * @param aCmpFileName = cmp/footprint link file name (*.cmp).
* @param aMessageWindow = a reference to a wxTextCtrl where to display messages. * if not found or empty, only the netlist will be used
* can be NULL * @param aReporter is a pointer to a #REPORTER object to write display messages.
* can be NULL.
* @param aChangeFootprint if true, footprints that have changed in netlist will be changed * @param aChangeFootprint if true, footprints that have changed in netlist will be changed
* @param aDeleteBadTracks if true, erroneous tracks will be deleted * @param aDeleteBadTracks if true, erroneous tracks will be deleted
* @param aDeleteExtraFootprints if true, remove unlocked footprints that are not in netlist * @param aDeleteExtraFootprints if true, remove unlocked footprints that are not in netlist
* @param aSelect_By_Timestamp if true, use timestamp instead of reference to identify * @param aSelectByTimestamp if true, use timestamp instead of reference to identify
* footprints from components (use after reannotation of the * footprints from components (use after reannotation of the
* schematic) * schematic)
* @return true if Ok * @param aIsDryRun performs a dry run without making any changes if true.
*/ */
bool ReadPcbNetlist( const wxString& aNetlistFullFilename, void ReadPcbNetlist( const wxString& aNetlistFileName,
const wxString& aCmpFullFileName, const wxString& aCmpFileName,
wxTextCtrl* aMessageWindow, REPORTER* aReporter,
bool aChangeFootprint, bool aChangeFootprint,
bool aDeleteBadTracks, bool aDeleteBadTracks,
bool aDeleteExtraFootprints, bool aDeleteExtraFootprints,
bool aSelect_By_Timestamp ); bool aSelectByTimestamp,
bool aIsDryRun );
/** /**
* Function RemoveMisConnectedTracks * Function RemoveMisConnectedTracks
...@@ -1487,8 +1489,7 @@ public: ...@@ -1487,8 +1489,7 @@ public:
* @param include_fixe = true to orient locked footprints * @param include_fixe = true to orient locked footprints
* @return true if some footprints modified, false if no change * @return true if some footprints modified, false if no change
*/ */
bool ReOrientModules( const wxString& ModuleMask, int Orient, bool ReOrientModules( const wxString& ModuleMask, int Orient, bool include_fixe );
bool include_fixe );
void LockModule( MODULE* aModule, bool aLocked ); void LockModule( MODULE* aModule, bool aLocked );
void AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ); void AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb );
......
...@@ -670,7 +670,6 @@ public: ...@@ -670,7 +670,6 @@ public:
void OnEraseBackground( wxEraseEvent& SizeEvent ); void OnEraseBackground( wxEraseEvent& SizeEvent );
virtual void OnZoom( wxCommandEvent& event ); virtual void OnZoom( wxCommandEvent& event );
void OnGrid( int grid_type );
/** /**
* Function RedrawScreen * Function RedrawScreen
......
...@@ -114,7 +114,7 @@ void TEMPLATE_WIDGET::OnMouse( wxMouseEvent& event ) ...@@ -114,7 +114,7 @@ void TEMPLATE_WIDGET::OnMouse( wxMouseEvent& event )
void DIALOG_TEMPLATE_SELECTOR::onNotebookResize(wxSizeEvent& event) void DIALOG_TEMPLATE_SELECTOR::onNotebookResize(wxSizeEvent& event)
{ {
for ( size_t i=0; i < m_notebook->GetPageCount(); i++ ) for( size_t i=0; i < m_notebook->GetPageCount(); i++ )
{ {
m_panels[i]->SetSize( m_notebook->GetSize().GetWidth() - 6, 140 ); m_panels[i]->SetSize( m_notebook->GetSize().GetWidth() - 6, 140 );
m_panels[i]->m_SizerBase->FitInside( m_panels[i] ); m_panels[i]->m_SizerBase->FitInside( m_panels[i] );
...@@ -190,24 +190,29 @@ void DIALOG_TEMPLATE_SELECTOR::AddPage( const wxString& aTitle, wxFileName& aPat ...@@ -190,24 +190,29 @@ void DIALOG_TEMPLATE_SELECTOR::AddPage( const wxString& aTitle, wxFileName& aPat
m_panels.push_back( p ); m_panels.push_back( p );
// Get a list of files under the template path to include as choices... // Get a list of files under the template path to include as choices...
wxArrayString files; wxArrayString files;
wxDir dir, sub; wxDir dir;
if ( dir.Open( aPath.GetPath() ) ) wxString path = aPath.GetFullPath(); // caller ensures this ends with file separator.
if( dir.Open( path ) )
{ {
wxString filename; wxDir sub_dir;
bool cont = dir.GetFirst( &filename, wxEmptyString, wxDIR_FILES | wxDIR_DIRS ); wxString sub_name;
bool cont = dir.GetFirst( &sub_name, wxEmptyString, wxDIR_DIRS );
while( cont ) while( cont )
{ {
if( sub.Open( aPath.GetPathWithSep() + filename ) ) wxString sub_full = path + sub_name;
if( sub_dir.Open( sub_full ) )
{ {
files.Add( filename ); files.Add( sub_name );
PROJECT_TEMPLATE* pt = new PROJECT_TEMPLATE( aPath.GetPathWithSep() + filename );
PROJECT_TEMPLATE* pt = new PROJECT_TEMPLATE( sub_full );
AddTemplate( m_notebook->GetPageCount() - 1, pt ); AddTemplate( m_notebook->GetPageCount() - 1, pt );
} }
cont = dir.GetNext( &filename ); cont = dir.GetNext( &sub_name );
} }
} }
} }
...@@ -56,10 +56,12 @@ static const wxString GeneralGroupName( wxT( "/general" ) ); ...@@ -56,10 +56,12 @@ static const wxString GeneralGroupName( wxT( "/general" ) );
PARAM_CFG_ARRAY s_KicadManagerParams; PARAM_CFG_ARRAY s_KicadManagerParams;
void KICAD_MANAGER_FRAME::CreateNewProject( const wxString aPrjFullFileName, bool aTemplateSelector = false ) void KICAD_MANAGER_FRAME::CreateNewProject( const wxString aPrjFullFileName,
bool aTemplateSelector = false )
{ {
wxString filename; wxString filename;
wxFileName newProjectName = aPrjFullFileName; wxFileName newProjectName = aPrjFullFileName;
wxChar sep[2] = { SEP(), 0 }; // nul terminated separator wxChar string.
ClearMsg(); ClearMsg();
...@@ -71,50 +73,62 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString aPrjFullFileName, boo ...@@ -71,50 +73,62 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString aPrjFullFileName, boo
{ {
DIALOG_TEMPLATE_SELECTOR* ps = new DIALOG_TEMPLATE_SELECTOR( this ); DIALOG_TEMPLATE_SELECTOR* ps = new DIALOG_TEMPLATE_SELECTOR( this );
wxFileName templatePath; wxFileName templatePath;
wxString envStr;
wxGetEnv( wxT( "KICAD" ), &envStr );
// Add a new tab for system templates // Add a new tab for system templates
if( ::wxGetEnv( wxT( "KICAD" ), NULL ) ) if( !envStr.empty() )
{ {
wxString kicadEnv; // user may or may not have including terminating separator.
wxGetEnv( wxT( "KICAD"), &kicadEnv ); if( !envStr.EndsWith( sep ) )
templatePath = kicadEnv + SEP() + wxT("template")+SEP(); envStr += sep;
templatePath = envStr + wxT("template") + sep;
} }
else else
{ {
wxFileName templatePath = wxPathOnly(wxStandardPaths::Get().GetExecutablePath()) + templatePath = wxPathOnly(wxStandardPaths::Get().GetExecutablePath()) +
SEP() + wxT( ".." ) + SEP() + wxT( "share" ) + SEP() + wxT( "template" ) + SEP(); sep + wxT( ".." ) + sep + wxT( "share" ) + sep + wxT( "template" ) + sep;
} }
ps->AddPage( _( "System Templates" ), templatePath ); ps->AddPage( _( "System Templates" ), templatePath );
// Add a new tab for user templates // Add a new tab for user templates
wxFileName userPath = wxStandardPaths::Get().GetDocumentsDir() + wxFileName userPath = wxStandardPaths::Get().GetDocumentsDir() +
SEP() + wxT( "kicad" ) + SEP() + wxT( "template" ) + SEP(); sep + wxT( "kicad" ) + sep + wxT( "template" ) + sep;
ps->AddPage( _( "User Templates" ), userPath ); ps->AddPage( _( "User Templates" ), userPath );
// Check to see if a custom template location is available and setup a new selection tab // Check to see if a custom template location is available and setup a
// if there is // new selection tab if there is.
wxString envStr; envStr.clear();
wxGetEnv( wxT("KICAD_PTEMPLATES"), &envStr ); wxGetEnv( wxT( "KICAD_PTEMPLATES" ), &envStr );
wxFileName envPath = envStr;
if( envStr != wxEmptyString ) if( !envStr.empty() )
{ {
if( !envStr.EndsWith( sep ) )
envStr += sep;
wxFileName envPath = envStr; wxFileName envPath = envStr;
ps->AddPage( _("Portable Templates"), envPath );
ps->AddPage( _( "Portable Templates" ), envPath );
} }
// Show the project template selector dialog // Show the project template selector dialog
int result = ps->ShowModal(); int result = ps->ShowModal();
if( result != wxID_OK ) if( (result != wxID_OK) || (ps->GetWidget() == NULL) )
{ {
wxMessageBox( _( "Did not generate new project from template" ), if( ps->GetWidget() == NULL )
_( "Cancelled new project from template" ), {
wxOK | wxICON_EXCLAMATION, wxMessageBox( _( "No project template was selected. Cannot generate new "
this ); "project." ),
_( "Error" ),
wxOK | wxICON_ERROR,
this );
}
} }
else else
{ {
...@@ -123,7 +137,7 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString aPrjFullFileName, boo ...@@ -123,7 +137,7 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString aPrjFullFileName, boo
if( !ps->GetWidget()->GetTemplate()->CreateProject( newProjectName ) ) if( !ps->GetWidget()->GetTemplate()->CreateProject( newProjectName ) )
{ {
wxMessageBox( _( "Problem whilst creating new project from template!" ), wxMessageBox( _( "Problem whilst creating new project from template!" ),
_( "Could not generate new project" ), _( "Template Error" ),
wxOK | wxICON_ERROR, wxOK | wxICON_ERROR,
this ); this );
} }
...@@ -196,17 +210,19 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event ) ...@@ -196,17 +210,19 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
// Check if the project directory is empty // Check if the project directory is empty
wxDir directory ( m_ProjectFileName.GetPath() ); wxDir directory ( m_ProjectFileName.GetPath() );
if( directory.HasFiles() ) if( directory.HasFiles() )
{ {
wxString msg = _( "The selected directory is not empty. " wxString msg = _( "The selected directory is not empty. We recommend you "
"We recommend you create projects in their own clean directory.\n\n" "create projects in their own clean directory.\n\nDo you "
"Do you want to create a new empty directory for the project?" ); "want to create a new empty directory for the project?" );
if( IsOK( this, msg ) ) if( IsOK( this, msg ) )
{ {
// Append a new directory with the same name of the project file // Append a new directory with the same name of the project file
// and try to create it // and try to create it
m_ProjectFileName.AppendDir( m_ProjectFileName.GetName() ); m_ProjectFileName.AppendDir( m_ProjectFileName.GetName() );
if( !wxMkdir( m_ProjectFileName.GetPath() ) ) if( !wxMkdir( m_ProjectFileName.GetPath() ) )
// There was a problem, undo // There was a problem, undo
m_ProjectFileName.RemoveLastDir(); m_ProjectFileName.RemoveLastDir();
...@@ -236,7 +252,7 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event ) ...@@ -236,7 +252,7 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
if( !m_ProjectFileName.FileExists() && !filename.IsSameAs( nameless_prj ) ) if( !m_ProjectFileName.FileExists() && !filename.IsSameAs( nameless_prj ) )
{ {
wxString msg; wxString msg;
msg.Printf( _( "KiCad project file <%s> not found" ), msg.Printf( _( "KiCad project file <%s> not found" ),
GetChars( m_ProjectFileName.GetFullPath() ) ); GetChars( m_ProjectFileName.GetFullPath() ) );
DisplayError( this, msg ); DisplayError( this, msg );
...@@ -256,6 +272,7 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event ) ...@@ -256,6 +272,7 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
SetTitle( title ); SetTitle( title );
UpdateFileHistory( m_ProjectFileName.GetFullPath() ); UpdateFileHistory( m_ProjectFileName.GetFullPath() );
m_LeftWin->ReCreateTreePrj(); m_LeftWin->ReCreateTreePrj();
#ifdef KICAD_USE_FILES_WATCHER #ifdef KICAD_USE_FILES_WATCHER
// Rebuild the list of watched paths. // Rebuild the list of watched paths.
// however this is possible only when the main loop event handler is running, // however this is possible only when the main loop event handler is running,
...@@ -263,6 +280,7 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event ) ...@@ -263,6 +280,7 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_INIT_WATCHED_PATHS ); wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_INIT_WATCHED_PATHS );
wxPostEvent( this, cmd); wxPostEvent( this, cmd);
#endif #endif
wxString msg; wxString msg;
msg.Format( _( "Working dir: <%s>\nProject: <%s>\n" ), msg.Format( _( "Working dir: <%s>\nProject: <%s>\n" ),
GetChars( m_ProjectFileName.GetPath() ), GetChars( m_ProjectFileName.GetPath() ),
......
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
wxStandardPaths::GetExecutableDir()/../share/template/ wxStandardPaths::GetExecutableDir()/../share/template/
wxStandardPaths::GetUserDataDir()/templates/ wxStandardPaths::GetUserDataDir()/templates/
wxGetEnv(wxT("KICAD_TEMPLATES")) wxGetEnv(wxT("KICAD_PTEMPLATES"))
wxGetEnv(wxT("KICAD"))/template/ wxGetEnv(wxT("KICAD"))/template/
*/ */
......
This source diff could not be displayed because it is too large. You can view the blob instead.
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Mar 17 2012) // C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
...@@ -11,7 +11,11 @@ ...@@ -11,7 +11,11 @@
#include <wx/artprov.h> #include <wx/artprov.h>
#include <wx/xrc/xmlres.h> #include <wx/xrc/xmlres.h>
#include <wx/intl.h> #include <wx/intl.h>
#include "UnitSelector.h" class UNIT_SELECTOR_ANGLE;
class UNIT_SELECTOR_FREQUENCY;
class UNIT_SELECTOR_LEN;
class UNIT_SELECTOR_RESISTOR;
#include <wx/string.h> #include <wx/string.h>
#include <wx/menu.h> #include <wx/menu.h>
#include <wx/gdicmn.h> #include <wx/gdicmn.h>
......
...@@ -181,9 +181,6 @@ set(PCBNEW_CLASS_SRCS ...@@ -181,9 +181,6 @@ set(PCBNEW_CLASS_SRCS
muonde.cpp muonde.cpp
muwave_command.cpp muwave_command.cpp
netlist.cpp netlist.cpp
netlist_reader_common.cpp
netlist_reader_firstformat.cpp
netlist_reader_kicad.cpp
onleftclick.cpp onleftclick.cpp
onrightclick.cpp onrightclick.cpp
pad_edition_functions.cpp pad_edition_functions.cpp
......
This diff is collapsed.
/*
* 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-2012 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 class_board.h * @file class_board.h
* @brief Class BOARD to handle a board. * @brief Class BOARD to handle a board.
...@@ -30,6 +54,8 @@ class TRACK; ...@@ -30,6 +54,8 @@ class TRACK;
class D_PAD; class D_PAD;
class MARKER_PCB; class MARKER_PCB;
class MSG_PANEL_ITEM; class MSG_PANEL_ITEM;
class NETLIST;
class REPORTER;
// non-owning container of item candidates when searching for items on the same track. // non-owning container of item candidates when searching for items on the same track.
...@@ -282,6 +308,12 @@ public: ...@@ -282,6 +308,12 @@ public:
BOARD(); BOARD();
~BOARD(); ~BOARD();
bool IsEmpty() const
{
return m_Drawings.GetCount() == 0 && m_Modules.GetCount() == 0 &&
m_Track.GetCount() == 0 && m_Zone.GetCount() == 0;
}
void Move( const wxPoint& aMoveVector ); // overload void Move( const wxPoint& aMoveVector ); // overload
void SetFileFormatVersionAtLoad( int aVersion ) { m_fileFormatVersionAtLoad = aVersion; } void SetFileFormatVersionAtLoad( int aVersion ) { m_fileFormatVersionAtLoad = aVersion; }
...@@ -849,6 +881,47 @@ public: ...@@ -849,6 +881,47 @@ public:
*/ */
MODULE* FindModuleByReference( const wxString& aReference ) const; MODULE* FindModuleByReference( const wxString& aReference ) const;
/**
* Function FindModule
* searches for a module matching \a aRefOrTimeStamp depending on the state of
* \a aSearchByTimeStamp.
* @param aRefOrTimeStamp is the search string.
* @param aSearchByTimeStamp searches by the module time stamp value if true. Otherwise
* search by reference designator.
* @return the module found or NULL if not module is found that meets the search criteria.
*/
MODULE* FindModule( const wxString& aRefOrTimeStamp, bool aSearchByTimeStamp = false );
/**
* Function ReplaceNetlist
* updates the #BOARD according to \a aNetlist.
*
* The changes are made to the board are as follows they are not disabled in the status
* settings in the #NETLIST:
* - If a new component is found in the #NETLIST and not in the #BOARD, it is added
* to the #BOARD.
* - If a the component in the #NETLIST is already on the #BOARD, then one or more of the
* following actions can occur:
* + If the footprint name in the #NETLIST does not match the footprint name on the
* #BOARD, the footprint on the #BOARD is replaced with the footprint specified in
* the #NETLIST and the proper parameters are copied from the existing footprint.
* + If the reference designator in the #NETLIST does not match the reference designator
* on the #BOARD, the reference designator is updated from the #NETLIST.
* + If the value field in the #NETLIST does not match the value field on the #BOARD,
* the value field is updated from the #NETLIST.
* + If the time stamp in the #NETLIST does not match the time stamp on the #BOARD,
* the time stamp is updated from the #NETLIST.
* - After each footprint is added or update as described above, each footprint pad net
* name is compared and updated to the value defined in the #NETLIST.
* - After all of the footprints have been added, updated, and net names properly set,
* any extra unlock footprints are removed from the #BOARD.
*
* @param aNetlist is the new netlist to revise the contents of the #BOARD with.
* @param aReporter is a #REPORTER object to report the changes \a aNetlist makes to
* the #BOARD. If NULL, no change reporting occurs.
*/
void ReplaceNetlist( NETLIST& aNetlist, REPORTER* aReporter = NULL );
/** /**
* Function ReturnSortedNetnamesList * Function ReturnSortedNetnamesList
* @param aNames An array string to fill with net names. * @param aNames An array string to fill with net names.
...@@ -1229,12 +1302,12 @@ public: ...@@ -1229,12 +1302,12 @@ public:
/** /**
* Function GetPadFast * Function GetPadFast
* return pad found at \a aPosition on \a aLayer using the fast search method. * return pad found at \a aPosition on \a aLayerMask using the fast search method.
* <p> * <p>
* The fast search method only works if the pad list has already been built. * The fast search method only works if the pad list has already been built.
* </p> * </p>
* @param aPosition A wxPoint object containing the position to hit test. * @param aPosition A wxPoint object containing the position to hit test.
* @param aLayer A layer or layers to mask the hit test. * @param aLayerMask A layer or layers to mask the hit test.
* @return A pointer to a D_PAD object if found or NULL if not found. * @return A pointer to a D_PAD object if found or NULL if not found.
*/ */
D_PAD* GetPadFast( const wxPoint& aPosition, LAYER_MSK aLayerMask ); D_PAD* GetPadFast( const wxPoint& aPosition, LAYER_MSK aLayerMask );
......
...@@ -320,8 +320,7 @@ void DRAWSEGMENT::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) ...@@ -320,8 +320,7 @@ void DRAWSEGMENT::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
wxString msg; wxString msg;
wxString coords; wxString coords;
BOARD* board = (BOARD*) m_Parent; wxASSERT( m_Parent );
wxASSERT( board );
msg = wxT( "DRAWING" ); msg = wxT( "DRAWING" );
......
...@@ -290,15 +290,45 @@ void MODULE::Copy( MODULE* aModule ) ...@@ -290,15 +290,45 @@ void MODULE::Copy( MODULE* aModule )
} }
/** void MODULE::CopyNetlistSettings( MODULE* aModule )
* Function Draw {
* Draws the footprint to the current Device Context // Don't do anything foolish like trying to copy to yourself.
* @param aPanel = draw panel, Used to know the clip box wxCHECK_RET( aModule != NULL && aModule != this, wxT( "Cannot copy to NULL or yourself." ) );
* @param aDC = Current Device Context
* @param aDrawMode = GR_OR, GR_XOR.. // Not sure what to do with the value field. Use netlist for now.
* @param aOffset = draw offset (usually wxPoint(0,0) aModule->SetPosition( GetPosition() );
*/
void MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aOffset ) if( aModule->GetLayer() != GetLayer() )
aModule->Flip( aModule->GetPosition() );
if( aModule->GetOrientation() != GetOrientation() )
aModule->Rotate( aModule->GetPosition(), GetOrientation() );
aModule->SetLocalSolderMaskMargin( GetLocalSolderMaskMargin() );
aModule->SetLocalClearance( GetLocalClearance() );
aModule->SetLocalSolderPasteMargin( GetLocalSolderPasteMargin() );
aModule->SetLocalSolderPasteMarginRatio( GetLocalSolderPasteMarginRatio() );
aModule->SetZoneConnection( GetZoneConnection() );
aModule->SetThermalWidth( GetThermalWidth() );
aModule->SetThermalGap( GetThermalGap() );
for( D_PAD* pad = Pads(); pad; pad = pad->Next() )
{
D_PAD* newPad = aModule->FindPadByName( pad->GetPadName() );
if( newPad )
pad->CopyNetlistSettings( newPad );
}
// Not sure about copying description, keywords, 3D models or any other
// local user changes to footprint. Stick with the new footprint settings
// called out in the footprint loaded in the netlist.
aModule->CalculateBoundingBox();
}
void MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
const wxPoint& aOffset )
{ {
if( (m_Flags & DO_NOT_DRAW) || (IsMoving()) ) if( (m_Flags & DO_NOT_DRAW) || (IsMoving()) )
return; return;
...@@ -354,14 +384,6 @@ void MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode, con ...@@ -354,14 +384,6 @@ void MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode, con
} }
/**
* Function DrawEdgesOnly
* Draws the footprint edges only to the current Device Context
* @param panel = The active Draw Panel (used to know the clip box)
* @param DC = current Device Context
* @param offset = draw offset (usually wxPoint(0,0)
* @param draw_mode = GR_OR, GR_XOR, GR_AND
*/
void MODULE::DrawEdgesOnly( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset, void MODULE::DrawEdgesOnly( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
GR_DRAWMODE draw_mode ) GR_DRAWMODE draw_mode )
{ {
...@@ -687,6 +709,7 @@ EDA_ITEM* MODULE::Clone() const ...@@ -687,6 +709,7 @@ EDA_ITEM* MODULE::Clone() const
return new MODULE( *this ); return new MODULE( *this );
} }
/* Test for validity of the name in a library of the footprint /* Test for validity of the name in a library of the footprint
* ( no spaces, dir separators ... ) * ( no spaces, dir separators ... )
* return true if the given name is valid * return true if the given name is valid
...@@ -874,6 +897,7 @@ void MODULE::SetPosition( const wxPoint& newpos ) ...@@ -874,6 +897,7 @@ void MODULE::SetPosition( const wxPoint& newpos )
CalculateBoundingBox(); CalculateBoundingBox();
} }
void MODULE::MoveAnchorPosition( const wxPoint& aMoveVector ) void MODULE::MoveAnchorPosition( const wxPoint& aMoveVector )
{ {
/* Move the reference point of the footprint /* Move the reference point of the footprint
...@@ -932,6 +956,7 @@ void MODULE::MoveAnchorPosition( const wxPoint& aMoveVector ) ...@@ -932,6 +956,7 @@ void MODULE::MoveAnchorPosition( const wxPoint& aMoveVector )
CalculateBoundingBox(); CalculateBoundingBox();
} }
void MODULE::SetOrientation( double newangle ) void MODULE::SetOrientation( double newangle )
{ {
double angleChange = newangle - m_Orient; // change in rotation double angleChange = newangle - m_Orient; // change in rotation
......
...@@ -229,6 +229,14 @@ public: ...@@ -229,6 +229,14 @@ public:
/* drawing functions */ /* drawing functions */
/**
* Function Draw
* draws the footprint to the \a aDC.
* @param aPanel = draw panel, Used to know the clip box
* @param aDC = Current Device Context
* @param aDrawMode = GR_OR, GR_XOR..
* @param aOffset = draw offset (usually wxPoint(0,0)
*/
void Draw( EDA_DRAW_PANEL* aPanel, void Draw( EDA_DRAW_PANEL* aPanel,
wxDC* aDC, wxDC* aDC,
GR_DRAWMODE aDrawMode, GR_DRAWMODE aDrawMode,
...@@ -236,6 +244,14 @@ public: ...@@ -236,6 +244,14 @@ public:
void Draw3D( EDA_3D_CANVAS* glcanvas ); void Draw3D( EDA_3D_CANVAS* glcanvas );
/**
* Function DrawEdgesOnly
* Draws the footprint edges only to the current Device Context
* @param panel = The active Draw Panel (used to know the clip box)
* @param DC = current Device Context
* @param offset = draw offset (usually wxPoint(0,0)
* @param draw_mode = GR_OR, GR_XOR, GR_AND
*/
void DrawEdgesOnly( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset, void DrawEdgesOnly( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
GR_DRAWMODE draw_mode ); GR_DRAWMODE draw_mode );
...@@ -306,7 +322,7 @@ public: ...@@ -306,7 +322,7 @@ public:
/** /**
* Function GetPad * Function GetPad
* get a pad at \a aPosition on \a aLayer in the footprint. * get a pad at \a aPosition on \a aLayerMask in the footprint.
* *
* @param aPosition A wxPoint object containing the position to hit test. * @param aPosition A wxPoint object containing the position to hit test.
* @param aLayerMask A layer or layers to mask the hit test. * @param aLayerMask A layer or layers to mask the hit test.
...@@ -361,6 +377,19 @@ public: ...@@ -361,6 +377,19 @@ public:
EDA_ITEM* Clone() const; EDA_ITEM* Clone() const;
/**
* Function CopyNetlistSettings
* copies the netlist settings to \a aModule.
*
* The netlist settings are all of the #MODULE settings not define by a #MODULE in
* a netlist. These setting include position, orientation, local clearances, ets.
* The reference designator, value, path, and physical geometry settings are not
* copied.
*
* @param aModule is the #MODULE to copy the settings to.
*/
void CopyNetlistSettings( MODULE* aModule );
/** /**
* static function IsLibNameValid * static function IsLibNameValid
* Test for validity of a name of a footprint to be used in a footprint library * Test for validity of a name of a footprint to be used in a footprint library
......
/*
* 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-2012 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 class_netinfo.h * @file class_netinfo.h
*/ */
...@@ -384,6 +408,13 @@ public: ...@@ -384,6 +408,13 @@ public:
*/ */
void SetNetname( const wxString& aNetname ); void SetNetname( const wxString& aNetname );
/**
* Function GetMsgPanelInfo
* returns the information about the #NETINFO_ITEM in \a aList to display in the
* message panel.
*
* @param aList is the list in which to place the status information.
*/
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ); void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
}; };
......
...@@ -99,13 +99,6 @@ void NETINFO_ITEM::Draw( EDA_DRAW_PANEL* panel, ...@@ -99,13 +99,6 @@ void NETINFO_ITEM::Draw( EDA_DRAW_PANEL* panel,
} }
/**
* Function DisplayInfo
* has knowledge about the frame and how and where to put status information
* about this object into the frame's message panel.
* Is virtual from EDA_ITEM.
* @param frame A EDA_DRAW_FRAME in which to print status information.
*/
void NETINFO_ITEM::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) void NETINFO_ITEM::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
{ {
int count; int count;
......
...@@ -301,10 +301,6 @@ void D_PAD::SetPadName( const wxString& name ) ...@@ -301,10 +301,6 @@ void D_PAD::SetPadName( const wxString& name )
} }
/**
* Function SetNetname
* @param aNetname: the new netname
*/
void D_PAD::SetNetname( const wxString& aNetname ) void D_PAD::SetNetname( const wxString& aNetname )
{ {
m_Netname = aNetname; m_Netname = aNetname;
...@@ -348,14 +344,23 @@ void D_PAD::Copy( D_PAD* source ) ...@@ -348,14 +344,23 @@ void D_PAD::Copy( D_PAD* source )
} }
/** void D_PAD::CopyNetlistSettings( D_PAD* aPad )
* Function GetClearance (virtual) {
* returns the clearance in internal units. If \a aItem is not NULL then the // Don't do anything foolish like trying to copy to yourself.
* returned clearance is the greater of this object's clearance and wxCHECK_RET( aPad != NULL && aPad != this, wxT( "Cannot copy to NULL or yourself." ) );
* aItem's clearance. If \a aItem is NULL, then this object clearance is returned.
* @param aItem is another BOARD_CONNECTED_ITEM or NULL aPad->SetNetname( GetNetname() );
* @return int - the clearance in internal units.
*/ aPad->SetLocalClearance( m_LocalClearance );
aPad->SetLocalSolderMaskMargin( m_LocalSolderMaskMargin );
aPad->SetLocalSolderPasteMargin( m_LocalSolderPasteMargin );
aPad->SetLocalSolderPasteMarginRatio( m_LocalSolderPasteMarginRatio );
aPad->SetZoneConnection( m_ZoneConnection );
aPad->SetThermalWidth( m_ThermalWidth );
aPad->SetThermalGap( m_ThermalGap );
}
int D_PAD::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const int D_PAD::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
{ {
// A pad can have specific clearance parameters that // A pad can have specific clearance parameters that
...@@ -387,15 +392,6 @@ int D_PAD::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const ...@@ -387,15 +392,6 @@ int D_PAD::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
// Mask margins handling: // Mask margins handling:
/**
* Function GetSolderMaskMargin
* @return the margin for the solder mask layer
* usually > 0 (mask shape bigger than pad
* value is
* 1 - the local value
* 2 - if null, the parent footprint value
* 1 - if null, the global value
*/
int D_PAD::GetSolderMaskMargin() int D_PAD::GetSolderMaskMargin()
{ {
int margin = m_LocalSolderMaskMargin; int margin = m_LocalSolderMaskMargin;
...@@ -429,15 +425,6 @@ int D_PAD::GetSolderMaskMargin() ...@@ -429,15 +425,6 @@ int D_PAD::GetSolderMaskMargin()
} }
/**
* Function GetSolderPasteMargin
* @return the margin for the solder mask layer
* usually < 0 (mask shape smaller than pad
* value is
* 1 - the local value
* 2 - if null, the parent footprint value
* 3 - if null, the global value
*/
wxSize D_PAD::GetSolderPasteMargin() wxSize D_PAD::GetSolderPasteMargin()
{ {
int margin = m_LocalSolderPasteMargin; int margin = m_LocalSolderPasteMargin;
...@@ -538,7 +525,7 @@ void D_PAD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM>& aList ) ...@@ -538,7 +525,7 @@ void D_PAD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM>& aList )
board = GetBoard(); board = GetBoard();
aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), aList.push_back( MSG_PANEL_ITEM( _( "Layer" ),
LayerMaskDescribe( board, m_layerMask ), DARKGREEN ) ); LayerMaskDescribe( board, m_layerMask ), DARKGREEN ) );
aList.push_back( MSG_PANEL_ITEM( ShowPadShape(), ShowPadAttr(), DARKGREEN ) ); aList.push_back( MSG_PANEL_ITEM( ShowPadShape(), ShowPadAttr(), DARKGREEN ) );
...@@ -754,6 +741,7 @@ wxString D_PAD::GetSelectMenuText() const ...@@ -754,6 +741,7 @@ wxString D_PAD::GetSelectMenuText() const
return text; return text;
} }
EDA_ITEM* D_PAD::Clone() const EDA_ITEM* D_PAD::Clone() const
{ {
return new D_PAD( *this ); return new D_PAD( *this );
......
...@@ -398,6 +398,18 @@ public: ...@@ -398,6 +398,18 @@ public:
/// @copydoc VIEW_ITEM::ViewGetLayers() /// @copydoc VIEW_ITEM::ViewGetLayers()
virtual void ViewGetLayers( int aLayers[], int& aCount ) const; virtual void ViewGetLayers( int aLayers[], int& aCount ) const;
/**
* Function CopyNetlistSettings
* copies the netlist settings to \a aPad.
*
* The netlist settings are all of the #D_PAD settings not define by a #D_PAD in
* a netlist. These setting include local clearances, net names, etc. The pad
* physical geometry settings are not copied.
*
* @param aPad is the #D_PAD to copy the settings to.
*/
void CopyNetlistSettings( D_PAD* aPad );
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload void Show( int nestLevel, std::ostream& os ) const; // overload
#endif #endif
......
...@@ -551,7 +551,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) ...@@ -551,7 +551,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
if( aDC->LogicalToDeviceXRel( tsize ) >= MIN_TEXT_SIZE ) // Not drawable when size too small. if( aDC->LogicalToDeviceXRel( tsize ) >= MIN_TEXT_SIZE ) // Not drawable when size too small.
{ {
// tsize reserve room for marges and segments thickness // tsize reserve room for marges and segments thickness
tsize = ( tsize * 8 ) / 10; tsize = ( tsize * 7 ) / 10;
DrawGraphicHaloText( aDrawInfo.m_DrawPanel, aDC, tpos, DrawGraphicHaloText( aDrawInfo.m_DrawPanel, aDC, tpos,
aDrawInfo.m_Color, BLACK, WHITE, aDrawInfo.m_Color, BLACK, WHITE,
buffer, t_angle, buffer, t_angle,
...@@ -578,7 +578,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) ...@@ -578,7 +578,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
RotatePoint( &tpos, shape_pos, angle ); RotatePoint( &tpos, shape_pos, angle );
// tsize reserve room for marges and segments thickness // tsize reserve room for marges and segments thickness
tsize = ( tsize * 8 ) / 10; tsize = ( tsize * 7 ) / 10;
DrawGraphicHaloText( aDrawInfo.m_DrawPanel, aDC, tpos, DrawGraphicHaloText( aDrawInfo.m_DrawPanel, aDC, tpos,
aDrawInfo.m_Color, BLACK, WHITE, aDrawInfo.m_Color, BLACK, WHITE,
m_ShortNetname, t_angle, m_ShortNetname, t_angle,
......
...@@ -214,9 +214,14 @@ void PCB_LAYER_WIDGET::ReFillRender() ...@@ -214,9 +214,14 @@ void PCB_LAYER_WIDGET::ReFillRender()
ClearRenderRows(); ClearRenderRows();
// Add "Render" tab rows to LAYER_WIDGET, after setting color and checkbox state. // Add "Render" tab rows to LAYER_WIDGET, after setting color and checkbox state.
// Because s_render_rows is created static, we must explicitely call
// wxGetTranslation for texts which are internationalized (tool tips
// and item names)
for( unsigned row=0; row<DIM(s_render_rows); ++row ) for( unsigned row=0; row<DIM(s_render_rows); ++row )
{ {
LAYER_WIDGET::ROW renderRow = s_render_rows[row]; LAYER_WIDGET::ROW renderRow = s_render_rows[row];
renderRow.tooltip = wxGetTranslation( s_render_rows[row].tooltip);
renderRow.rowName = wxGetTranslation( s_render_rows[row].rowName);
if( renderRow.color != -1 ) // does this row show a color? if( renderRow.color != -1 ) // does this row show a color?
{ {
...@@ -293,12 +298,15 @@ void PCB_LAYER_WIDGET::ReFill() ...@@ -293,12 +298,15 @@ void PCB_LAYER_WIDGET::ReFill()
} }
AppendLayerRow( LAYER_WIDGET::ROW( AppendLayerRow( LAYER_WIDGET::ROW(
brd->GetLayerName( layer ), layer, brd->GetLayerColor( layer ), dsc, true ) ); brd->GetLayerName( layer ), layer, brd->GetLayerColor( layer ),
dsc, true ) );
} }
} }
// technical layers are shown in this order: // technical layers are shown in this order:
// Because they are static, wxGetTranslation must be explicitely
// called for tooltips.
static const struct { static const struct {
LAYER_NUM layerId; LAYER_NUM layerId;
wxString tooltip; wxString tooltip;
...@@ -327,7 +335,7 @@ void PCB_LAYER_WIDGET::ReFill() ...@@ -327,7 +335,7 @@ void PCB_LAYER_WIDGET::ReFill()
AppendLayerRow( LAYER_WIDGET::ROW( AppendLayerRow( LAYER_WIDGET::ROW(
brd->GetLayerName( layer ), layer, brd->GetLayerColor( layer ), brd->GetLayerName( layer ), layer, brd->GetLayerColor( layer ),
techLayerSeq[i].tooltip, true ) ); wxGetTranslation( techLayerSeq[i].tooltip ), true ) );
} }
installRightLayerClickHandler(); installRightLayerClickHandler();
......
...@@ -111,17 +111,18 @@ void TEXTE_PCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, ...@@ -111,17 +111,18 @@ void TEXTE_PCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
void TEXTE_PCB::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) void TEXTE_PCB::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
{ {
wxString msg; wxString msg;
BOARD* board;
BOARD_ITEM* parent = (BOARD_ITEM*) m_Parent;
#if defined(DEBUG)
BOARD_ITEM* parent = (BOARD_ITEM*) m_Parent;
wxASSERT( parent ); wxASSERT( parent );
BOARD* board;
if( parent->Type() == PCB_DIMENSION_T ) if( parent->Type() == PCB_DIMENSION_T )
board = (BOARD*) parent->GetParent(); board = (BOARD*) parent->GetParent();
else else
board = (BOARD*) parent; board = (BOARD*) parent;
wxASSERT( board ); wxASSERT( board );
#endif
if( m_Parent && m_Parent->Type() == PCB_DIMENSION_T ) if( m_Parent && m_Parent->Type() == PCB_DIMENSION_T )
aList.push_back( MSG_PANEL_ITEM( _( "Dimension" ), m_Text, DARKGREEN ) ); aList.push_back( MSG_PANEL_ITEM( _( "Dimension" ), m_Text, DARKGREEN ) );
......
...@@ -750,7 +750,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, ...@@ -750,7 +750,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
if( (aDrawMode & GR_XOR) == 0 ) if( (aDrawMode & GR_XOR) == 0 )
GRSetDrawMode( aDC, GR_COPY ); GRSetDrawMode( aDC, GR_COPY );
tsize = (tsize * 8) / 10; // small reduction to give a better look tsize = (tsize * 7) / 10; // small reduction to give a better look
DrawGraphicHaloText( panel, aDC, tpos, DrawGraphicHaloText( panel, aDC, tpos,
color, BLACK, WHITE, net->GetShortNetname(), angle, color, BLACK, WHITE, net->GetShortNetname(), angle,
wxSize( tsize, tsize ), wxSize( tsize, tsize ),
...@@ -961,7 +961,7 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, ...@@ -961,7 +961,7 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
if( aDC->LogicalToDeviceXRel( tsize ) >= MIN_TEXT_SIZE ) if( aDC->LogicalToDeviceXRel( tsize ) >= MIN_TEXT_SIZE )
{ {
tsize = (tsize * 8) / 10; // small reduction to give a better look, inside via tsize = (tsize * 7) / 10; // small reduction to give a better look, inside via
if( (aDrawMode & GR_XOR) == 0 ) if( (aDrawMode & GR_XOR) == 0 )
GRSetDrawMode( aDC, GR_COPY ); GRSetDrawMode( aDC, GR_COPY );
......
...@@ -118,11 +118,11 @@ void DIALOG_SVG_PRINT::initDialog() ...@@ -118,11 +118,11 @@ void DIALOG_SVG_PRINT::initDialog()
// (Front or Top to Back or Bottom) // (Front or Top to Back or Bottom)
DECLARE_LAYERS_ORDER_LIST( layersOrder ); DECLARE_LAYERS_ORDER_LIST( layersOrder );
for( LAYER_NUM layer_idx = FIRST_LAYER; layer_idx < NB_LAYERS; ++layer_idx ) for( LAYER_NUM layer_idx = FIRST_LAYER; layer_idx < NB_PCB_LAYERS; ++layer_idx )
{ {
layer = layersOrder[layer_idx]; layer = layersOrder[layer_idx];
wxASSERT( layer < NB_LAYERS ); wxASSERT( layer < NB_PCB_LAYERS );
if( m_boxSelectLayer[layer] == NULL ) if( m_boxSelectLayer[layer] == NULL )
continue; continue;
...@@ -148,7 +148,7 @@ void DIALOG_SVG_PRINT::initDialog() ...@@ -148,7 +148,7 @@ void DIALOG_SVG_PRINT::initDialog()
{ {
wxString layerKey; wxString layerKey;
for( LAYER_NUM layer = FIRST_LAYER; layer < NB_LAYERS; ++layer ) for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer )
{ {
bool option; bool option;
...@@ -237,7 +237,7 @@ void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile ) ...@@ -237,7 +237,7 @@ void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile )
// Build layers mask // Build layers mask
LAYER_MSK printMaskLayer = NO_LAYERS; LAYER_MSK printMaskLayer = NO_LAYERS;
for( LAYER_NUM layer = FIRST_LAYER; layer < NB_LAYERS; ++layer ) for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer )
{ {
if( m_boxSelectLayer[layer] && m_boxSelectLayer[layer]->GetValue() ) if( m_boxSelectLayer[layer] && m_boxSelectLayer[layer]->GetValue() )
printMaskLayer |= GetLayerMask( layer ); printMaskLayer |= GetLayerMask( layer );
...@@ -363,7 +363,7 @@ void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event ) ...@@ -363,7 +363,7 @@ void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event )
wxString layerKey; wxString layerKey;
for( LAYER_NUM layer = FIRST_LAYER; layer<NB_LAYERS; ++layer ) for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer )
{ {
if( m_boxSelectLayer[layer] == NULL ) if( m_boxSelectLayer[layer] == NULL )
continue; continue;
......
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 10 2012) // C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
...@@ -24,6 +24,7 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c ...@@ -24,6 +24,7 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c
bSizer4 = new wxBoxSizer( wxHORIZONTAL ); bSizer4 = new wxBoxSizer( wxHORIZONTAL );
m_outputDirectoryName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_outputDirectoryName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_outputDirectoryName->SetMaxLength( 0 );
m_outputDirectoryName->SetToolTip( _("Enter a filename if you do not want to use default file names\nCan be used only when printing the current sheet") ); m_outputDirectoryName->SetToolTip( _("Enter a filename if you do not want to use default file names\nCan be used only when printing the current sheet") );
m_outputDirectoryName->SetMinSize( wxSize( 450,-1 ) ); m_outputDirectoryName->SetMinSize( wxSize( 450,-1 ) );
...@@ -64,6 +65,7 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c ...@@ -64,6 +65,7 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c
sbOptionsSizer->Add( m_TextPenWidth, 0, wxRIGHT|wxLEFT, 5 ); sbOptionsSizer->Add( m_TextPenWidth, 0, wxRIGHT|wxLEFT, 5 );
m_DialogDefaultPenSize = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_DialogDefaultPenSize = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_DialogDefaultPenSize->SetMaxLength( 0 );
sbOptionsSizer->Add( m_DialogDefaultPenSize, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); sbOptionsSizer->Add( m_DialogDefaultPenSize, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
wxString m_ModeColorOptionChoices[] = { _("Color"), _("Black and white") }; wxString m_ModeColorOptionChoices[] = { _("Color"), _("Black and white") };
...@@ -118,6 +120,7 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c ...@@ -118,6 +120,7 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c
bMainSizer->Add( m_staticText2, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); bMainSizer->Add( m_staticText2, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_messagesBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); m_messagesBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
m_messagesBox->SetMaxLength( 0 );
m_messagesBox->SetMinSize( wxSize( -1,100 ) ); m_messagesBox->SetMinSize( wxSize( -1,100 ) );
bMainSizer->Add( m_messagesBox, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); bMainSizer->Add( m_messagesBox, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
......
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 10 2012) // C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include <wx/artprov.h> #include <wx/artprov.h>
#include <wx/xrc/xmlres.h> #include <wx/xrc/xmlres.h>
#include <wx/intl.h> #include <wx/intl.h>
class DIALOG_SHIM;
#include "dialog_shim.h" #include "dialog_shim.h"
#include <wx/string.h> #include <wx/string.h>
#include <wx/stattext.h> #include <wx/stattext.h>
......
/** /**
* @file dialog_edit_module_text.cpp. * @file dialog_edit_module_text.cpp
* @brief dialog editor for texts (fields) in footprints * @brief dialog editor for texts (fields) in footprints.
*/ */
/* /*
......
This diff is collapsed.
...@@ -31,31 +31,68 @@ ...@@ -31,31 +31,68 @@
#include <dialog_netlist_fbp.h> #include <dialog_netlist_fbp.h>
class MODULE;
class NETLIST;
class DIALOG_NETLIST : public DIALOG_NETLIST_FBP class DIALOG_NETLIST : public DIALOG_NETLIST_FBP
{ {
private: private:
PCB_EDIT_FRAME * m_parent; PCB_EDIT_FRAME* m_parent;
wxDC * m_dc; wxDC* m_dc;
public: public:
DIALOG_NETLIST( PCB_EDIT_FRAME* aParent, wxDC * aDC, DIALOG_NETLIST( PCB_EDIT_FRAME* aParent, wxDC* aDC, const wxString & aNetlistFullFilename );
const wxString & aNetlistFullFilename );
~DIALOG_NETLIST() {}; ~DIALOG_NETLIST() {};
// return true if the user choice is tu use the .cmp file
// created by CvPcb to know footprin names associated to components // return true if the user choice is to use the .cmp file
// and false tu use the netlist only // created by CvPcb to know footprint names associated to components
// and false to use the netlist only
bool UseCmpFileForFpNames() bool UseCmpFileForFpNames()
{ {
return m_cmpNameSourceOpt->GetSelection() == 1; return m_cmpNameSourceOpt->GetSelection() == 1;
} }
private: private:
/**
* Function verifyFootprints
* compares the netlist to the board and builds a list of duplicate, missing, and
* extra footprints.
*
* @param aNetlistFilename the netlist filename.
* @param aCmpFilename the component link filename.
* @param aDuplicate the list of duplicate modules to populate
* @param aMissing the list of missing module references and values to populate. For
* each missing item, the first string is the reference designator and
* the second is the value.
* @param aNotInNetlist is the list of component footprint found in the netlist but not on
* the board.
* @return true if no errors occurred while reading the netlist. Otherwise false.
*/
bool verifyFootprints( const wxString& aNetlistFilename,
const wxString& aCmpFilename,
std::vector< MODULE* >& aDuplicate,
wxArrayString& aMissing,
std::vector< MODULE* >& aNotInNetlist );
/**
* Function loadFootprints
* loads the footprints for each #COMPONENT in \a aNetlist from the list of libraries.
*
* @param aNetlist is the netlist of components to load the footprints into.
*/
void loadFootprints( NETLIST& aNetlist );
// Virtual event handlers: // Virtual event handlers:
void OnOpenNetlistClick( wxCommandEvent& event ); void OnOpenNetlistClick( wxCommandEvent& event );
void OnReadNetlistFileClick( wxCommandEvent& event ); void OnReadNetlistFileClick( wxCommandEvent& event );
void OnTestFootprintsClick( wxCommandEvent& event ); void OnTestFootprintsClick( wxCommandEvent& event );
void OnCompileRatsnestClick( wxCommandEvent& event ); void OnCompileRatsnestClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event ); void OnCancelClick( wxCommandEvent& event );
void OnSaveMessagesToFile( wxCommandEvent& aEvent );
void OnUpdateUISaveMessagesToFile( wxUpdateUIEvent& aEvent );
void OnUpdateUIValidNetlistFile( wxUpdateUIEvent& aEvent );
}; };
......
...@@ -24,7 +24,7 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w ...@@ -24,7 +24,7 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w
wxString m_Select_By_TimestampChoices[] = { _("Reference"), _("Timestamp") }; wxString m_Select_By_TimestampChoices[] = { _("Reference"), _("Timestamp") };
int m_Select_By_TimestampNChoices = sizeof( m_Select_By_TimestampChoices ) / sizeof( wxString ); int m_Select_By_TimestampNChoices = sizeof( m_Select_By_TimestampChoices ) / sizeof( wxString );
m_Select_By_Timestamp = new wxRadioBox( this, wxID_ANY, _("Module Selection:"), wxDefaultPosition, wxDefaultSize, m_Select_By_TimestampNChoices, m_Select_By_TimestampChoices, 1, wxRA_SPECIFY_COLS ); m_Select_By_Timestamp = new wxRadioBox( this, wxID_ANY, _("Module Selection"), wxDefaultPosition, wxDefaultSize, m_Select_By_TimestampNChoices, m_Select_By_TimestampChoices, 1, wxRA_SPECIFY_COLS );
m_Select_By_Timestamp->SetSelection( 0 ); m_Select_By_Timestamp->SetSelection( 0 );
m_Select_By_Timestamp->SetToolTip( _("Select how footprints are recognized:\nby their reference (U1, R3...) (normal setting)\nor their time stamp (special setting after a full schematic reannotation)") ); m_Select_By_Timestamp->SetToolTip( _("Select how footprints are recognized:\nby their reference (U1, R3...) (normal setting)\nor their time stamp (special setting after a full schematic reannotation)") );
...@@ -32,7 +32,7 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w ...@@ -32,7 +32,7 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w
wxString m_cmpNameSourceOptChoices[] = { _("From netlist"), _("From separate .cmp file") }; wxString m_cmpNameSourceOptChoices[] = { _("From netlist"), _("From separate .cmp file") };
int m_cmpNameSourceOptNChoices = sizeof( m_cmpNameSourceOptChoices ) / sizeof( wxString ); int m_cmpNameSourceOptNChoices = sizeof( m_cmpNameSourceOptChoices ) / sizeof( wxString );
m_cmpNameSourceOpt = new wxRadioBox( this, wxID_ANY, _("Module Name Source:"), wxDefaultPosition, wxDefaultSize, m_cmpNameSourceOptNChoices, m_cmpNameSourceOptChoices, 1, wxRA_SPECIFY_COLS ); m_cmpNameSourceOpt = new wxRadioBox( this, wxID_ANY, _("Module Name Source"), wxDefaultPosition, wxDefaultSize, m_cmpNameSourceOptNChoices, m_cmpNameSourceOptChoices, 1, wxRA_SPECIFY_COLS );
m_cmpNameSourceOpt->SetSelection( 0 ); m_cmpNameSourceOpt->SetSelection( 0 );
m_cmpNameSourceOpt->SetToolTip( _("Source of footprints names for component:\n- the netlist (if you have filled the footprint field of each component in schematic)\n- the .cmp file created by CvPcb") ); m_cmpNameSourceOpt->SetToolTip( _("Source of footprints names for component:\n- the netlist (if you have filled the footprint field of each component in schematic)\n- the .cmp file created by CvPcb") );
...@@ -40,7 +40,7 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w ...@@ -40,7 +40,7 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w
wxString m_ChangeExistingFootprintCtrlChoices[] = { _("Keep"), _("Change") }; wxString m_ChangeExistingFootprintCtrlChoices[] = { _("Keep"), _("Change") };
int m_ChangeExistingFootprintCtrlNChoices = sizeof( m_ChangeExistingFootprintCtrlChoices ) / sizeof( wxString ); int m_ChangeExistingFootprintCtrlNChoices = sizeof( m_ChangeExistingFootprintCtrlChoices ) / sizeof( wxString );
m_ChangeExistingFootprintCtrl = new wxRadioBox( this, wxID_ANY, _("Exchange Module:"), wxDefaultPosition, wxDefaultSize, m_ChangeExistingFootprintCtrlNChoices, m_ChangeExistingFootprintCtrlChoices, 1, wxRA_SPECIFY_COLS ); m_ChangeExistingFootprintCtrl = new wxRadioBox( this, wxID_ANY, _("Exchange Module"), wxDefaultPosition, wxDefaultSize, m_ChangeExistingFootprintCtrlNChoices, m_ChangeExistingFootprintCtrlChoices, 1, wxRA_SPECIFY_COLS );
m_ChangeExistingFootprintCtrl->SetSelection( 0 ); m_ChangeExistingFootprintCtrl->SetSelection( 0 );
m_ChangeExistingFootprintCtrl->SetToolTip( _("Keep or change an existing footprint when the netlist gives a different footprint") ); m_ChangeExistingFootprintCtrl->SetToolTip( _("Keep or change an existing footprint when the netlist gives a different footprint") );
...@@ -54,7 +54,7 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w ...@@ -54,7 +54,7 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w
wxString m_DeleteBadTracksChoices[] = { _("Keep"), _("Delete") }; wxString m_DeleteBadTracksChoices[] = { _("Keep"), _("Delete") };
int m_DeleteBadTracksNChoices = sizeof( m_DeleteBadTracksChoices ) / sizeof( wxString ); int m_DeleteBadTracksNChoices = sizeof( m_DeleteBadTracksChoices ) / sizeof( wxString );
m_DeleteBadTracks = new wxRadioBox( this, wxID_ANY, _("Bad Tracks Deletion:"), wxDefaultPosition, wxDefaultSize, m_DeleteBadTracksNChoices, m_DeleteBadTracksChoices, 1, wxRA_SPECIFY_COLS ); m_DeleteBadTracks = new wxRadioBox( this, wxID_ANY, _("Unconnected Tracks"), wxDefaultPosition, wxDefaultSize, m_DeleteBadTracksNChoices, m_DeleteBadTracksChoices, 1, wxRA_SPECIFY_COLS );
m_DeleteBadTracks->SetSelection( 0 ); m_DeleteBadTracks->SetSelection( 0 );
m_DeleteBadTracks->SetToolTip( _("Keep or delete bad tracks after a netlist change") ); m_DeleteBadTracks->SetToolTip( _("Keep or delete bad tracks after a netlist change") );
...@@ -74,7 +74,7 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w ...@@ -74,7 +74,7 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w
wxBoxSizer* bRightSizerButtons; wxBoxSizer* bRightSizerButtons;
bRightSizerButtons = new wxBoxSizer( wxVERTICAL ); bRightSizerButtons = new wxBoxSizer( wxVERTICAL );
m_buttonBrowse = new wxButton( this, ID_OPEN_NELIST, _("Browse Netlist Files"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonBrowse = new wxButton( this, ID_OPEN_NELIST, _("Open Netlist File"), wxDefaultPosition, wxDefaultSize, 0 );
bRightSizerButtons->Add( m_buttonBrowse, 0, wxEXPAND|wxALL, 5 ); bRightSizerButtons->Add( m_buttonBrowse, 0, wxEXPAND|wxALL, 5 );
m_buttonRead = new wxButton( this, ID_READ_NETLIST_FILE, _("Read Current Netlist"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonRead = new wxButton( this, ID_READ_NETLIST_FILE, _("Read Current Netlist"), wxDefaultPosition, wxDefaultSize, 0 );
...@@ -83,7 +83,7 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w ...@@ -83,7 +83,7 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w
bRightSizerButtons->Add( m_buttonRead, 0, wxEXPAND|wxALL, 5 ); bRightSizerButtons->Add( m_buttonRead, 0, wxEXPAND|wxALL, 5 );
m_buttonFPTest = new wxButton( this, ID_TEST_NETLIST, _("Footprints Test"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonFPTest = new wxButton( this, ID_TEST_NETLIST, _("Test Footprints"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonFPTest->SetToolTip( _("Read the current neltist file and list missing and extra footprints") ); m_buttonFPTest->SetToolTip( _("Read the current neltist file and list missing and extra footprints") );
bRightSizerButtons->Add( m_buttonFPTest, 0, wxEXPAND|wxALL, 5 ); bRightSizerButtons->Add( m_buttonFPTest, 0, wxEXPAND|wxALL, 5 );
...@@ -93,15 +93,27 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w ...@@ -93,15 +93,27 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w
bRightSizerButtons->Add( m_buttonRebild, 0, wxEXPAND|wxALL, 5 ); bRightSizerButtons->Add( m_buttonRebild, 0, wxEXPAND|wxALL, 5 );
m_buttonSaveMessages = new wxButton( this, wxID_ANY, _("Save Messages to File"), wxDefaultPosition, wxDefaultSize, 0 );
bRightSizerButtons->Add( m_buttonSaveMessages, 0, wxALL|wxEXPAND, 5 );
m_buttonClose = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonClose = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 );
bRightSizerButtons->Add( m_buttonClose, 0, wxALL|wxEXPAND, 5 ); bRightSizerButtons->Add( m_buttonClose, 0, wxALL|wxEXPAND, 5 );
bUpperSizer->Add( bRightSizerButtons, 0, wxALIGN_CENTER_VERTICAL, 5 ); bUpperSizer->Add( bRightSizerButtons, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxTOP, 5 );
bMainSizer->Add( bUpperSizer, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 ); bMainSizer->Add( bUpperSizer, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 );
wxBoxSizer* bCenterSizer;
bCenterSizer = new wxBoxSizer( wxVERTICAL );
m_checkDryRun = new wxCheckBox( this, wxID_ANY, _("Only report changes in message panel"), wxDefaultPosition, wxDefaultSize, 0 );
bCenterSizer->Add( m_checkDryRun, 0, wxALL, 5 );
bMainSizer->Add( bCenterSizer, 0, wxALL|wxEXPAND, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bMainSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); bMainSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
...@@ -137,8 +149,13 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w ...@@ -137,8 +149,13 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w
// Connect Events // Connect Events
m_buttonBrowse->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnOpenNetlistClick ), NULL, this ); m_buttonBrowse->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnOpenNetlistClick ), NULL, this );
m_buttonRead->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnReadNetlistFileClick ), NULL, this ); m_buttonRead->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnReadNetlistFileClick ), NULL, this );
m_buttonRead->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_NETLIST_FBP::OnUpdateUIValidNetlistFile ), NULL, this );
m_buttonFPTest->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnTestFootprintsClick ), NULL, this ); m_buttonFPTest->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnTestFootprintsClick ), NULL, this );
m_buttonFPTest->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_NETLIST_FBP::OnUpdateUIValidNetlistFile ), NULL, this );
m_buttonRebild->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnCompileRatsnestClick ), NULL, this ); m_buttonRebild->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnCompileRatsnestClick ), NULL, this );
m_buttonRebild->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_NETLIST_FBP::OnUpdateUIValidNetlistFile ), NULL, this );
m_buttonSaveMessages->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnSaveMessagesToFile ), NULL, this );
m_buttonSaveMessages->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_NETLIST_FBP::OnUpdateUISaveMessagesToFile ), NULL, this );
m_buttonClose->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnCancelClick ), NULL, this ); m_buttonClose->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnCancelClick ), NULL, this );
} }
...@@ -147,8 +164,13 @@ DIALOG_NETLIST_FBP::~DIALOG_NETLIST_FBP() ...@@ -147,8 +164,13 @@ DIALOG_NETLIST_FBP::~DIALOG_NETLIST_FBP()
// Disconnect Events // Disconnect Events
m_buttonBrowse->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnOpenNetlistClick ), NULL, this ); m_buttonBrowse->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnOpenNetlistClick ), NULL, this );
m_buttonRead->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnReadNetlistFileClick ), NULL, this ); m_buttonRead->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnReadNetlistFileClick ), NULL, this );
m_buttonRead->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_NETLIST_FBP::OnUpdateUIValidNetlistFile ), NULL, this );
m_buttonFPTest->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnTestFootprintsClick ), NULL, this ); m_buttonFPTest->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnTestFootprintsClick ), NULL, this );
m_buttonFPTest->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_NETLIST_FBP::OnUpdateUIValidNetlistFile ), NULL, this );
m_buttonRebild->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnCompileRatsnestClick ), NULL, this ); m_buttonRebild->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnCompileRatsnestClick ), NULL, this );
m_buttonRebild->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_NETLIST_FBP::OnUpdateUIValidNetlistFile ), NULL, this );
m_buttonSaveMessages->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnSaveMessagesToFile ), NULL, this );
m_buttonSaveMessages->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_NETLIST_FBP::OnUpdateUISaveMessagesToFile ), NULL, this );
m_buttonClose->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnCancelClick ), NULL, this ); m_buttonClose->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnCancelClick ), NULL, this );
} }
This diff is collapsed.
...@@ -22,6 +22,7 @@ class DIALOG_SHIM; ...@@ -22,6 +22,7 @@ class DIALOG_SHIM;
#include <wx/settings.h> #include <wx/settings.h>
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/button.h> #include <wx/button.h>
#include <wx/checkbox.h>
#include <wx/statline.h> #include <wx/statline.h>
#include <wx/stattext.h> #include <wx/stattext.h>
#include <wx/textctrl.h> #include <wx/textctrl.h>
...@@ -54,7 +55,9 @@ class DIALOG_NETLIST_FBP : public DIALOG_SHIM ...@@ -54,7 +55,9 @@ class DIALOG_NETLIST_FBP : public DIALOG_SHIM
wxButton* m_buttonRead; wxButton* m_buttonRead;
wxButton* m_buttonFPTest; wxButton* m_buttonFPTest;
wxButton* m_buttonRebild; wxButton* m_buttonRebild;
wxButton* m_buttonSaveMessages;
wxButton* m_buttonClose; wxButton* m_buttonClose;
wxCheckBox* m_checkDryRun;
wxStaticLine* m_staticline1; wxStaticLine* m_staticline1;
wxStaticText* m_staticTextNetfilename; wxStaticText* m_staticTextNetfilename;
wxTextCtrl* m_NetlistFilenameCtrl; wxTextCtrl* m_NetlistFilenameCtrl;
...@@ -64,8 +67,11 @@ class DIALOG_NETLIST_FBP : public DIALOG_SHIM ...@@ -64,8 +67,11 @@ class DIALOG_NETLIST_FBP : public DIALOG_SHIM
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnOpenNetlistClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnOpenNetlistClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnReadNetlistFileClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnReadNetlistFileClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnUpdateUIValidNetlistFile( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void OnTestFootprintsClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnTestFootprintsClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCompileRatsnestClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnCompileRatsnestClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnSaveMessagesToFile( wxCommandEvent& event ) { event.Skip(); }
virtual void OnUpdateUISaveMessagesToFile( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
......
/** /**
* @file DIALOG_ORIENT_FOOTPRINTS.cpp * @file dialog_orient_footprints.cpp
*/ */
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
...@@ -58,10 +58,12 @@ public: ...@@ -58,10 +58,12 @@ public:
{ {
return m_ApplyToLocked->IsChecked(); return m_ApplyToLocked->IsChecked();
} }
int GetOrientation() int GetOrientation()
{ {
return newOrientation; return newOrientation;
} }
wxString GetFilter() wxString GetFilter()
{ {
return m_FilterPattern->GetValue(); return m_FilterPattern->GetValue();
...@@ -73,6 +75,8 @@ private: ...@@ -73,6 +75,8 @@ private:
void OnOkClick( wxCommandEvent& event ); void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event ); void OnCancelClick( wxCommandEvent& event );
}; };
int DIALOG_ORIENT_FOOTPRINTS::newOrientation = 0; int DIALOG_ORIENT_FOOTPRINTS::newOrientation = 0;
...@@ -81,23 +85,18 @@ DIALOG_ORIENT_FOOTPRINTS::DIALOG_ORIENT_FOOTPRINTS( PCB_EDIT_FRAME* parent ) ...@@ -81,23 +85,18 @@ DIALOG_ORIENT_FOOTPRINTS::DIALOG_ORIENT_FOOTPRINTS( PCB_EDIT_FRAME* parent )
{ {
m_Parent = parent; m_Parent = parent;
wxString txt; wxString txt;
txt.Printf(wxT("%g"), (double) newOrientation/10); txt.Printf( wxT( "%g" ), (double) newOrientation/10 );
m_OrientationCtrl->SetValue(txt); m_OrientationCtrl->SetValue( txt );
SetFocus( ); SetFocus();
GetSizer()->SetSizeHints(this); GetSizer()->SetSizeHints( this );
Centre(); Centre();
} }
/****************************************************************/
void PCB_EDIT_FRAME::OnOrientFootprints( wxCommandEvent& event ) void PCB_EDIT_FRAME::OnOrientFootprints( wxCommandEvent& event )
/****************************************************************/
/**
* Function OnOrientFootprints
* install the dialog box for the comman Orient Footprints
*/
{ {
DIALOG_ORIENT_FOOTPRINTS dlg(this); DIALOG_ORIENT_FOOTPRINTS dlg( this );
if( dlg.ShowModal() != wxID_OK ) if( dlg.ShowModal() != wxID_OK )
return; return;
...@@ -111,23 +110,13 @@ void PCB_EDIT_FRAME::OnOrientFootprints( wxCommandEvent& event ) ...@@ -111,23 +110,13 @@ void PCB_EDIT_FRAME::OnOrientFootprints( wxCommandEvent& event )
} }
/*******************************************************************/ bool PCB_EDIT_FRAME::ReOrientModules( const wxString& ModuleMask, int Orient, bool include_fixe )
bool PCB_EDIT_FRAME::ReOrientModules( const wxString& ModuleMask,
int Orient, bool include_fixe )
/*******************************************************************/
/**
* Function ReOrientModules
* Set the orientation of footprints
* @param ModuleMask = mask (wildcard allowed) selection
* @param Orient = new orientation
* @param include_fixe = true to orient locked footprints
* @return true if some footprints modified, false if no change
*/
{ {
wxString line; wxString line;
bool modified = false; bool modified = false;
line.Printf( _( "OK to set footprints orientation to %.1f degrees ?" ), (double)Orient / 10 ); line.Printf( _( "OK to set footprints orientation to %.1f degrees ?" ), (double)Orient / 10 );
if( !IsOK( this, line ) ) if( !IsOK( this, line ) )
return false; return false;
...@@ -155,13 +144,13 @@ void DIALOG_ORIENT_FOOTPRINTS::OnOkClick( wxCommandEvent& event ) ...@@ -155,13 +144,13 @@ void DIALOG_ORIENT_FOOTPRINTS::OnOkClick( wxCommandEvent& event )
double d_orient; double d_orient;
wxString text = m_OrientationCtrl->GetValue(); wxString text = m_OrientationCtrl->GetValue();
if ( ! text.ToDouble(&d_orient) ) if ( ! text.ToDouble( &d_orient ) )
{ {
DisplayError(this, _("Bad value for footprints orientation")); DisplayError( this, _( "Bad value for footprints orientation" ) );
return; return;
} }
newOrientation = KiROUND(d_orient * 10); newOrientation = KiROUND( d_orient * 10 );
NORMALIZE_ANGLE_180( newOrientation ); NORMALIZE_ANGLE_180( newOrientation );
EndModal( wxID_OK ); EndModal( wxID_OK );
} }
......
/** /**
* @file dialog_pad_properties.cpp. * @file dialog_pad_properties.cpp
* @brief Pad editing functions and dialog pad editor * @brief Pad editing functions and dialog pad editor.
*/ */
/* /*
......
...@@ -278,7 +278,7 @@ void GPCB_FPL_CACHE::Remove( const wxString& aFootprintName ) ...@@ -278,7 +278,7 @@ void GPCB_FPL_CACHE::Remove( const wxString& aFootprintName )
if( it == m_modules.end() ) if( it == m_modules.end() )
{ {
THROW_IO_ERROR( wxString::Format( _( "library <%s> has no footprint %s to delete" ), THROW_IO_ERROR( wxString::Format( _( "library <%s> has no footprint '%s' to delete" ),
m_lib_path.GetPath().GetData(), m_lib_path.GetPath().GetData(),
aFootprintName.GetData() ) ); aFootprintName.GetData() ) );
} }
......
...@@ -170,8 +170,10 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit ...@@ -170,8 +170,10 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
if( GetCanvas()->IsMouseCaptured() ) if( GetCanvas()->IsMouseCaptured() )
GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false ); GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false );
GetBoard()->SetTrackWidthIndex( ( GetBoard()->GetTrackWidthIndex() + 1 ) % if( GetBoard()->GetTrackWidthIndex() < GetBoard()->m_TrackWidthList.size() - 1)
GetBoard()->m_TrackWidthList.size() ); GetBoard()->SetTrackWidthIndex( GetBoard()->GetTrackWidthIndex() + 1 );
else
GetBoard()->SetTrackWidthIndex( 0 );
if( GetCanvas()->IsMouseCaptured() ) if( GetCanvas()->IsMouseCaptured() )
GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false ); GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false );
...@@ -182,10 +184,10 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit ...@@ -182,10 +184,10 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
if( GetCanvas()->IsMouseCaptured() ) if( GetCanvas()->IsMouseCaptured() )
GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false ); GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false );
if( GetBoard()->GetTrackWidthIndex() == 0 ) if( GetBoard()->GetTrackWidthIndex() <= 0 )
GetBoard()->SetTrackWidthIndex( GetBoard()->m_TrackWidthList.size() ); GetBoard()->SetTrackWidthIndex( GetBoard()->m_TrackWidthList.size() -1 );
else
GetBoard()->SetTrackWidthIndex( GetBoard()->GetTrackWidthIndex() - 1 ); GetBoard()->SetTrackWidthIndex( GetBoard()->GetTrackWidthIndex() - 1 );
if( GetCanvas()->IsMouseCaptured() ) if( GetCanvas()->IsMouseCaptured() )
GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false ); GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false );
......
...@@ -249,7 +249,7 @@ void FP_CACHE::Remove( const wxString& aFootprintName ) ...@@ -249,7 +249,7 @@ void FP_CACHE::Remove( const wxString& aFootprintName )
if( it == m_modules.end() ) if( it == m_modules.end() )
{ {
THROW_IO_ERROR( wxString::Format( _( "library <%s> has no footprint %s to delete" ), THROW_IO_ERROR( wxString::Format( _( "library <%s> has no footprint '%s' to delete" ),
m_lib_path.GetPath().GetData(), m_lib_path.GetPath().GetData(),
aFootprintName.GetData() ) ); aFootprintName.GetData() ) );
} }
...@@ -425,7 +425,7 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const ...@@ -425,7 +425,7 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const
m_out->Print( aNestLevel, "(layers\n" ); m_out->Print( aNestLevel, "(layers\n" );
// Save only the used copper layers from front to back. // Save only the used copper layers from front to back.
for( LAYER_NUM layer = LAST_COPPER_LAYER; layer >= FIRST_COPPER_LAYER; --layer) for( LAYER_NUM layer = LAST_COPPER_LAYER; layer >= FIRST_COPPER_LAYER; --layer)
{ {
LAYER_MSK mask = GetLayerMask( layer ); LAYER_MSK mask = GetLayerMask( layer );
if( mask & aBoard->GetEnabledLayers() ) if( mask & aBoard->GetEnabledLayers() )
...@@ -1087,8 +1087,10 @@ void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const ...@@ -1087,8 +1087,10 @@ void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const
m_out->Print( 0, " (rect_delta %s )", FMT_IU( aPad->GetDelta() ).c_str() ); m_out->Print( 0, " (rect_delta %s )", FMT_IU( aPad->GetDelta() ).c_str() );
wxSize sz = aPad->GetDrillSize(); wxSize sz = aPad->GetDrillSize();
wxPoint shapeoffset = aPad->GetOffset();
if( (sz.GetWidth() > 0) || (sz.GetHeight() > 0) ) if( (sz.GetWidth() > 0) || (sz.GetHeight() > 0) ||
(shapeoffset.x > 0) || (shapeoffset.y > 0) )
{ {
m_out->Print( 0, " (drill" ); m_out->Print( 0, " (drill" );
...@@ -1101,7 +1103,7 @@ void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const ...@@ -1101,7 +1103,7 @@ void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const
if( sz.GetHeight() > 0 && sz.GetWidth() != sz.GetHeight() ) if( sz.GetHeight() > 0 && sz.GetWidth() != sz.GetHeight() )
m_out->Print( 0, " %s", FMT_IU( sz.GetHeight() ).c_str() ); m_out->Print( 0, " %s", FMT_IU( sz.GetHeight() ).c_str() );
if( (aPad->GetOffset().x != 0) || (aPad->GetOffset().y != 0) ) if( (shapeoffset.x != 0) || (shapeoffset.y != 0) )
m_out->Print( 0, " (offset %s)", FMT_IU( aPad->GetOffset() ).c_str() ); m_out->Print( 0, " (offset %s)", FMT_IU( aPad->GetOffset() ).c_str() );
m_out->Print( 0, ")" ); m_out->Print( 0, ")" );
......
...@@ -4322,7 +4322,7 @@ void LEGACY_PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxStrin ...@@ -4322,7 +4322,7 @@ void LEGACY_PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxStrin
if( erasedCount != 1 ) if( erasedCount != 1 )
{ {
THROW_IO_ERROR( wxString::Format( THROW_IO_ERROR( wxString::Format(
_( "library <%s> has no footprint %s to delete" ), _( "library <%s> has no footprint '%s' to delete" ),
aLibraryPath.GetData(), aFootprintName.GetData() ) ); aLibraryPath.GetData(), aFootprintName.GetData() ) );
} }
......
...@@ -132,7 +132,12 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser( void ) ...@@ -132,7 +132,12 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser( void )
wxMilliSleep( 50 ); wxMilliSleep( 50 );
} }
wxString fpname = viewer->GetSelectedFootprint(); // Returns the full fp name, i.e. the lib name and th fp name,
// separated by a '/'
// (/ is now an illegal char in fp names)
wxString fpname = viewer->GetSelectedLibraryFullName();
fpname << wxT("/") << viewer->GetSelectedFootprint();
viewer->Destroy(); viewer->Destroy();
return fpname; return fpname;
...@@ -146,6 +151,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -146,6 +151,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
MODULE* module; MODULE* module;
wxPoint curspos = GetScreen()->GetCrossHairPosition(); wxPoint curspos = GetScreen()->GetCrossHairPosition();
wxString moduleName, keys; wxString moduleName, keys;
wxString libName = aLibrary;
bool allowWildSeach = true; bool allowWildSeach = true;
static wxArrayString HistoryList; static wxArrayString HistoryList;
...@@ -162,7 +168,12 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -162,7 +168,12 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
if( dlg.m_GetExtraFunction ) if( dlg.m_GetExtraFunction )
{ {
moduleName = SelectFootprintFromLibBrowser(); // SelectFootprintFromLibBrowser() returns the
// "full" footprint name, i.e.
// <lib_name>/<footprint name>
wxString full_fpname = SelectFootprintFromLibBrowser();
moduleName = full_fpname.AfterLast( '/' );
libName = full_fpname.BeforeLast( '/' );
} }
else else
{ {
...@@ -179,7 +190,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -179,7 +190,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
{ {
allowWildSeach = false; allowWildSeach = false;
keys = moduleName; keys = moduleName;
moduleName = Select_1_Module_From_List( this, aLibrary, wxEmptyString, keys ); moduleName = Select_1_Module_From_List( this, libName, wxEmptyString, keys );
if( moduleName.IsEmpty() ) // Cancel command if( moduleName.IsEmpty() ) // Cancel command
{ {
...@@ -191,7 +202,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -191,7 +202,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
|| ( moduleName.Contains( wxT( "*" ) ) ) ) // Selection wild card || ( moduleName.Contains( wxT( "*" ) ) ) ) // Selection wild card
{ {
allowWildSeach = false; allowWildSeach = false;
moduleName = Select_1_Module_From_List( this, aLibrary, moduleName, wxEmptyString ); moduleName = Select_1_Module_From_List( this, libName, moduleName, wxEmptyString );
if( moduleName.IsEmpty() ) if( moduleName.IsEmpty() )
{ {
...@@ -200,7 +211,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -200,7 +211,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
} }
} }
module = GetModuleLibrary( aLibrary, moduleName, false ); module = GetModuleLibrary( libName, moduleName, false );
if( !module && allowWildSeach ) // Search with wild card if( !module && allowWildSeach ) // Search with wild card
{ {
...@@ -209,7 +220,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -209,7 +220,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
wxString wildname = wxChar( '*' ) + moduleName + wxChar( '*' ); wxString wildname = wxChar( '*' ) + moduleName + wxChar( '*' );
moduleName = wildname; moduleName = wildname;
moduleName = Select_1_Module_From_List( this, aLibrary, moduleName, wxEmptyString ); moduleName = Select_1_Module_From_List( this, libName, moduleName, wxEmptyString );
if( moduleName.IsEmpty() ) if( moduleName.IsEmpty() )
{ {
...@@ -218,7 +229,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -218,7 +229,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
} }
else else
{ {
module = GetModuleLibrary( aLibrary, moduleName, true ); module = GetModuleLibrary( libName, moduleName, true );
} }
} }
...@@ -258,15 +269,6 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -258,15 +269,6 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
} }
/* scans active libraries to find and load aFootprintName.
* If found the module is added to the BOARD, just for good measure.
* aLibraryPath is the full/short name of the library.
* if empty, search in all libraries
* aFootprintName is the footprint to load
* aDisplayError = true to display an error message if any.
*
* return a pointer to the new module, or NULL
*/
MODULE* PCB_BASE_FRAME::GetModuleLibrary( const wxString& aLibraryPath, MODULE* PCB_BASE_FRAME::GetModuleLibrary( const wxString& aLibraryPath,
const wxString& aFootprintName, const wxString& aFootprintName,
bool aDisplayError ) bool aDisplayError )
...@@ -278,12 +280,6 @@ MODULE* PCB_BASE_FRAME::GetModuleLibrary( const wxString& aLibraryPath, ...@@ -278,12 +280,6 @@ MODULE* PCB_BASE_FRAME::GetModuleLibrary( const wxString& aLibraryPath,
} }
/* loads aFootprintName from aLibraryPath.
* If found the module is added to the BOARD, just for good measure.
*
* aLibraryPath - the full filename or the short name of the library to read.
* if it is a short name, the file is searched in all library valid paths
*/
MODULE* PCB_BASE_FRAME::loadFootprintFromLibrary( const wxString& aLibraryPath, MODULE* PCB_BASE_FRAME::loadFootprintFromLibrary( const wxString& aLibraryPath,
const wxString& aFootprintName, const wxString& aFootprintName,
bool aDisplayError, bool aDisplayError,
...@@ -326,10 +322,6 @@ MODULE* PCB_BASE_FRAME::loadFootprintFromLibrary( const wxString& aLibraryPath, ...@@ -326,10 +322,6 @@ MODULE* PCB_BASE_FRAME::loadFootprintFromLibrary( const wxString& aLibraryPath,
} }
/* Explore the libraries list and
* loads aFootprintName from the first library it is found
* If found add the module is also added to the BOARD, just for good measure.
*/
MODULE* PCB_BASE_FRAME::loadFootprintFromLibraries( MODULE* PCB_BASE_FRAME::loadFootprintFromLibraries(
const wxString& aFootprintName, bool aDisplayError ) const wxString& aFootprintName, bool aDisplayError )
{ {
...@@ -388,6 +380,35 @@ MODULE* PCB_BASE_FRAME::loadFootprintFromLibraries( ...@@ -388,6 +380,35 @@ MODULE* PCB_BASE_FRAME::loadFootprintFromLibraries(
{ {
DisplayError( this, ioe.errorText ); DisplayError( this, ioe.errorText );
} }
return NULL;
}
MODULE* PCB_BASE_FRAME::loadFootprint( const wxString& aFootprintName )
throw( IO_ERROR, PARSE_ERROR )
{
wxString libPath;
wxFileName fn;
MODULE* footprint;
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
for( unsigned ii = 0; ii < g_LibraryNames.GetCount(); ii++ )
{
fn = wxFileName( wxEmptyString, g_LibraryNames[ii], LegacyFootprintLibPathExtension );
libPath = wxGetApp().FindLibraryPath( fn );
if( !libPath )
continue;
footprint = pi->FootprintLoad( libPath, aFootprintName );
if( footprint )
return footprint;
}
return NULL; return NULL;
} }
...@@ -475,9 +496,6 @@ wxString PCB_BASE_FRAME::Select_1_Module_From_List( EDA_DRAW_FRAME* aWindow, ...@@ -475,9 +496,6 @@ wxString PCB_BASE_FRAME::Select_1_Module_From_List( EDA_DRAW_FRAME* aWindow,
} }
/* Find and display the doc Component Name
* The list of doc is pointed to by mlist.
*/
static void DisplayCmpDoc( wxString& Name ) static void DisplayCmpDoc( wxString& Name )
{ {
FOOTPRINT_INFO* module_info = MList.GetModuleInfo( Name ); FOOTPRINT_INFO* module_info = MList.GetModuleInfo( Name );
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
#include <menus_helpers.h> #include <menus_helpers.h>
#include <footprint_wizard_frame.h> #include <footprint_wizard_frame.h>
#include <pcbnew_config.h>
// Functions defined in block_module_editor, but used here // Functions defined in block_module_editor, but used here
...@@ -877,3 +878,9 @@ void FOOTPRINT_EDIT_FRAME::OnVerticalToolbar( wxCommandEvent& aEvent ) ...@@ -877,3 +878,9 @@ void FOOTPRINT_EDIT_FRAME::OnVerticalToolbar( wxCommandEvent& aEvent )
SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString ); SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString );
} }
} }
EDA_COLOR_T FOOTPRINT_EDIT_FRAME::GetGridColor() const
{
return g_ColorsSettings.GetItemColor( GRID_VISIBLE );
}
...@@ -375,6 +375,8 @@ public: ...@@ -375,6 +375,8 @@ public:
void Select_Active_Library(); void Select_Active_Library();
virtual EDA_COLOR_T GetGridColor( void ) const;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
protected: protected:
......
...@@ -87,7 +87,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectCurrentLibrary( wxCommandEvent& event ) ...@@ -87,7 +87,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectCurrentLibrary( wxCommandEvent& event )
wxArrayString headers; wxArrayString headers;
headers.Add( wxT("Library") ); headers.Add( wxT("Library") );
std::vector<wxArrayString> itemsToDisplay; std::vector<wxArrayString> itemsToDisplay;
// Conversion from wxArrayString to vector of ArrayString // Conversion from wxArrayString to vector of ArrayString
for( unsigned i = 0; i < g_LibraryNames.GetCount(); i++ ) for( unsigned i = 0; i < g_LibraryNames.GetCount(); i++ )
{ {
...@@ -145,6 +145,13 @@ void FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint( wxCommandEvent& event ) ...@@ -145,6 +145,13 @@ void FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint( wxCommandEvent& event )
} }
const wxString FOOTPRINT_VIEWER_FRAME::GetSelectedLibraryFullName( void )
{
wxString fullname = m_libraryName + wxT(".") + LegacyFootprintLibPathExtension;
return fullname;
}
/* Routine to view one selected library content. */ /* Routine to view one selected library content. */
void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode ) void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode )
{ {
...@@ -171,8 +178,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode ) ...@@ -171,8 +178,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode )
SetCurItem( NULL ); SetCurItem( NULL );
// Delete the current footprint // Delete the current footprint
GetBoard()->m_Modules.DeleteAll(); GetBoard()->m_Modules.DeleteAll();
GetModuleLibrary( m_libraryName + wxT(".") + LegacyFootprintLibPathExtension, GetModuleLibrary( GetSelectedLibraryFullName(), m_footprintName, true );
m_footprintName, true );
Update3D_Frame(); Update3D_Frame();
} }
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <hotkeys.h> #include <hotkeys.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
#include <pcbnew_config.h>
/** /**
...@@ -697,3 +698,9 @@ void FOOTPRINT_VIEWER_FRAME::Update3D_Frame( bool aForceReloadFootprint ) ...@@ -697,3 +698,9 @@ void FOOTPRINT_VIEWER_FRAME::Update3D_Frame( bool aForceReloadFootprint )
m_Draw3DFrame->NewDisplay(); m_Draw3DFrame->NewDisplay();
} }
} }
EDA_COLOR_T FOOTPRINT_VIEWER_FRAME::GetGridColor() const
{
return g_ColorsSettings.GetItemColor( GRID_VISIBLE );
}
...@@ -58,10 +58,10 @@ private: ...@@ -58,10 +58,10 @@ private:
wxString m_configPath; // subpath for configuration wxString m_configPath; // subpath for configuration
protected: protected:
static wxString m_libraryName; // Current selected libary static wxString m_libraryName; // Current selected libary
static wxString m_footprintName; // Current selected footprint static wxString m_footprintName; // Current selected footprint
static wxString m_selectedFootprintName; // When the viewer is used to select a footprint static wxString m_selectedFootprintName; // When the viewer is used to select a footprint
// the selected footprint is here // the selected footprint is here
public: public:
FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* parent, wxSemaphore* semaphore = NULL, FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* parent, wxSemaphore* semaphore = NULL,
...@@ -84,7 +84,9 @@ public: ...@@ -84,7 +84,9 @@ public:
static FOOTPRINT_VIEWER_FRAME* GetActiveFootprintViewer(); static FOOTPRINT_VIEWER_FRAME* GetActiveFootprintViewer();
wxString& GetSelectedFootprint( void ) const { return m_selectedFootprintName; } wxString& GetSelectedFootprint( void ) const { return m_selectedFootprintName; }
const wxString GetSelectedLibraryFullName( void );
virtual EDA_COLOR_T GetGridColor( void ) const;
private: private:
void OnSize( wxSizeEvent& event ); void OnSize( wxSizeEvent& event );
......
...@@ -688,40 +688,40 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type ) ...@@ -688,40 +688,40 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type )
break; break;
case 2: // Arc Stub created by a polygonal approach: case 2: // Arc Stub created by a polygonal approach:
{ {
EDGE_MODULE* edge = new EDGE_MODULE( module ); EDGE_MODULE* edge = new EDGE_MODULE( module );
module->GraphicalItems().PushFront( edge ); module->GraphicalItems().PushFront( edge );
edge->SetShape( S_POLYGON ); edge->SetShape( S_POLYGON );
edge->SetLayer( LAYER_N_FRONT ); edge->SetLayer( LAYER_N_FRONT );
int numPoints = angle / 50 + 3; // Note: angles are in 0.1 degrees int numPoints = angle / 50 + 3; // Note: angles are in 0.1 degrees
std::vector<wxPoint> polyPoints = edge->GetPolyPoints(); std::vector<wxPoint> polyPoints = edge->GetPolyPoints();
polyPoints.reserve( numPoints ); polyPoints.reserve( numPoints );
edge->m_Start0.y = -pad->GetSize().y / 2; edge->m_Start0.y = -pad->GetSize().y / 2;
polyPoints.push_back( wxPoint( 0, 0 ) ); polyPoints.push_back( wxPoint( 0, 0 ) );
int theta = -angle / 2; int theta = -angle / 2;
for( int ii = 1; ii<numPoints - 1; ii++ ) for( int ii = 1; ii<numPoints - 1; ii++ )
{ {
wxPoint pt( 0, -gap_size ); wxPoint pt( 0, -gap_size );
RotatePoint( &pt.x, &pt.y, theta );
polyPoints.push_back( pt ); RotatePoint( &pt.x, &pt.y, theta );
theta += 50; polyPoints.push_back( pt );
if( theta > angle / 2 ) theta += 50;
theta = angle / 2;
}
// Close the polygon: if( theta > angle / 2 )
polyPoints.push_back( polyPoints[0] ); theta = angle / 2;
} }
// Close the polygon:
polyPoints.push_back( polyPoints[0] );
}
break; break;
default: default:
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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