Commit 8ddbf84c authored by Felix Morgner's avatar Felix Morgner

merge with upstream

parents 24f95c66 81271ad4
......@@ -117,9 +117,9 @@ set(PCB_COMMON_SRCS
../pcbnew/class_zone_settings.cpp
../pcbnew/classpcb.cpp
../pcbnew/collectors.cpp
../pcbnew/netlist_reader_common.cpp
../pcbnew/netlist_reader_firstformat.cpp
../pcbnew/netlist_reader_kicad.cpp
../pcbnew/netlist_reader.cpp
../pcbnew/legacy_netlist_reader.cpp
../pcbnew/kicad_netlist_reader.cpp
../pcbnew/sel_layer.cpp
../pcbnew/pcb_plot_params.cpp
../pcbnew/io_mgr.cpp
......
......@@ -36,12 +36,8 @@ set(CVPCB_SRCS
cvframe.cpp
cvpcb.cpp
listboxes.cpp
loadcmp.cpp
menubar.cpp
readschematicnetlist.cpp
read_write_cmpfile.cpp
readwrite_dlgs.cpp
setvisu.cpp
tool_cvpcb.cpp
)
......
......@@ -35,19 +35,17 @@
#include <macros.h>
#include <bitmaps.h>
#include <msgpanel.h>
#include <wildcards_and_files_ext.h>
#include <io_mgr.h>
#include <class_module.h>
#include <class_board.h>
#include <cvpcb.h>
#include <cvpcb_mainframe.h>
#include <class_DisplayFootprintsFrame.h>
#include <cvpcb_id.h>
#include <cvstruct.h>
/*
* NOTE: There is something in 3d_viewer.h that causes a compiler error in
* <boost/foreach.hpp> in Linux so move it after cvpcb.h where it is
* included to prevent the error from occurring.
*/
#include <3d_viewer.h>
......@@ -70,9 +68,6 @@ END_EVENT_TABLE()
#define DISPLAY_FOOTPRINTS_FRAME_NAME wxT( "CmpFrame" )
/***************************************************************************/
/* DISPLAY_FOOTPRINTS_FRAME: the frame to display the current focused footprint */
/***************************************************************************/
DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( CVPCB_MAINFRAME* parent,
const wxString& title,
......@@ -98,6 +93,7 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( CVPCB_MAINFRAME* parent,
if( (m_LastGridSizeId <= 0) ||
(m_LastGridSizeId > (ID_POPUP_GRID_USER - ID_POPUP_GRID_LEVEL_1000)) )
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_500 - ID_POPUP_GRID_LEVEL_1000;
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
// Initialize some display options
......@@ -155,9 +151,6 @@ DISPLAY_FOOTPRINTS_FRAME::~DISPLAY_FOOTPRINTS_FRAME()
}
/* Called when the frame is closed
* Save current settings (frame position and size
*/
void DISPLAY_FOOTPRINTS_FRAME::OnCloseWindow( wxCloseEvent& event )
{
if( m_Draw3DFrame )
......@@ -426,9 +419,6 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPositi
}
/**
* Display 3D frame of current footprint selection.
*/
void DISPLAY_FOOTPRINTS_FRAME::Show3D_Frame( wxCommandEvent& event )
{
if( m_Draw3DFrame )
......@@ -463,33 +453,157 @@ void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER&, int )
}
/**
* Function IsGridVisible() , virtual
* @return true if the grid must be shown
*/
bool DISPLAY_FOOTPRINTS_FRAME::IsGridVisible() const
{
return m_DrawGrid;
}
/**
* Function SetGridVisibility() , virtual
* It may be overloaded by derived classes
* if you want to store/retrieve the grid visibility in configuration.
* @param aVisible = true if the grid must be shown
*/
void DISPLAY_FOOTPRINTS_FRAME::SetGridVisibility(bool aVisible)
{
m_DrawGrid = aVisible;
}
/**
* Function GetGridColor() , virtual
* @return the color of the grid
*/
EDA_COLOR_T DISPLAY_FOOTPRINTS_FRAME::GetGridColor() const
{
return DARKGRAY;
}
MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
{
CVPCB_MAINFRAME* parent = ( CVPCB_MAINFRAME* ) GetParent();
try
{
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
for( unsigned i = 0; i < parent->m_ModuleLibNames.GetCount(); ++i )
{
wxFileName fn = parent->m_ModuleLibNames[i];
fn.SetExt( LegacyFootprintLibPathExtension );
wxString libPath = wxGetApp().FindLibraryPath( fn );
if( !libPath )
{
wxString msg = wxString::Format( _( "PCB footprint library file <%s> could not "
"be found in the default search paths." ),
fn.GetFullName().GetData() );
// @todo we should not be using wxMessageBox directly.
wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR, this );
continue;
}
MODULE* footprint = pi->FootprintLoad( libPath, aFootprintName );
if( footprint )
{
footprint->SetParent( (EDA_ITEM*) GetBoard() );
footprint->SetPosition( wxPoint( 0, 0 ) );
return footprint;
}
}
}
catch( IO_ERROR ioe )
{
DisplayError( this, ioe.errorText );
return NULL;
}
wxString msg = wxString::Format( _( "Footprint '%s' not found" ), aFootprintName.GetData() );
DisplayError( this, msg );
return NULL;
}
void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
{
wxString msg;
CVPCB_MAINFRAME * parentframe = (CVPCB_MAINFRAME *) GetParent();
wxString footprintName = parentframe->m_FootprintList->GetSelectedFootprint();
if( !footprintName.IsEmpty() )
{
msg.Printf( _( "Footprint: %s" ), GetChars( footprintName ) );
SetTitle( msg );
FOOTPRINT_INFO* module_info = parentframe->m_footprints.GetModuleInfo( footprintName );
const wxChar *libname;
if( module_info )
libname = GetChars( module_info->m_LibName );
else
libname = GetChars( wxT( "???" ) );
msg.Printf( _( "Lib: %s" ), libname );
SetStatusText( msg, 0 );
if( GetBoard()->m_Modules.GetCount() )
{
// there is only one module in the list
GetBoard()->m_Modules.DeleteAll();
}
MODULE* module = Get_Module( footprintName );
if( module )
GetBoard()->m_Modules.PushBack( module );
Zoom_Automatique( false );
}
else // No footprint to display. Erase old footprint, if any
{
if( GetBoard()->m_Modules.GetCount() )
{
GetBoard()->m_Modules.DeleteAll();
Zoom_Automatique( false );
SetStatusText( wxEmptyString, 0 );
}
}
// Display new cursor coordinates and zoom value:
UpdateStatusBar();
GetCanvas()->Refresh();
if( m_Draw3DFrame )
m_Draw3DFrame->NewDisplay();
}
void DISPLAY_FOOTPRINTS_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{
if( !GetBoard() )
return;
m_canvas->DrawBackGround( DC );
GetBoard()->Draw( m_canvas, DC, GR_COPY );
MODULE* Module = GetBoard()->m_Modules;
if ( Module )
{
MSG_PANEL_ITEMS items;
Module->GetMsgPanelInfo( items );
SetMsgPanel( items );
}
m_canvas->DrawCrossHair( DC );
}
/*
* Redraw the BOARD items but not cursors, axis or grid.
*/
void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
GR_DRAWMODE aDrawMode, const wxPoint& aOffset )
{
if( m_Modules )
{
m_Modules->Draw( aPanel, aDC, GR_COPY );
}
}
/*
* 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) 2007-2011 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_DisplayFootprintsFrame.h
*/
......@@ -23,7 +47,12 @@ public:
~DISPLAY_FOOTPRINTS_FRAME();
void OnCloseWindow( wxCloseEvent& Event );
/*
* Draws the current highlighted footprint.
*/
void RedrawActiveWindow( wxDC* DC, bool EraseBg );
void ReCreateHToolbar();
void ReCreateVToolbar();
void ReCreateOptToolbar();
......@@ -69,6 +98,10 @@ public:
MODULE* Get_Module( const wxString& CmpName );
void Process_Settings( wxCommandEvent& event );
/**
* Display 3D frame of current footprint selection.
*/
void Show3D_Frame( wxCommandEvent& event );
/* SaveCopyInUndoList() virtual
......
......@@ -725,11 +725,7 @@ void CVPCB_MAINFRAME::UpdateTitle()
SetTitle( title );
}
/**
* Send a remote command to Eeschema via a socket,
* Commands are
* $PART: "reference" put cursor on component anchor
*/
void CVPCB_MAINFRAME::SendMessageToEESCHEMA()
{
char cmd[1024];
......@@ -754,3 +750,121 @@ void CVPCB_MAINFRAME::SendMessageToEESCHEMA()
SendCommand( MSG_TO_SCH, cmd );
}
int CVPCB_MAINFRAME::ReadSchematicNetlist()
{
wxBusyCursor dummy; // Shows an hourglass while loading.
NETLIST_READER* netlistReader;
wxString msg;
wxString compFootprintLinkFileName;
wxFileName fn = m_NetlistFileName;
// Load the footprint association file if it has already been created.
fn.SetExt( ComponentFileExtension );
if( fn.FileExists() && fn.IsFileReadable() )
compFootprintLinkFileName = fn.GetFullPath();
m_netlist.Clear();
try
{
netlistReader = NETLIST_READER::GetNetlistReader( &m_netlist,
m_NetlistFileName.GetFullPath(),
compFootprintLinkFileName );
std::auto_ptr< NETLIST_READER > nlr( netlistReader );
netlistReader->LoadNetlist();
}
catch( IO_ERROR& ioe )
{
msg = wxString::Format( _( "Error loading netlist.\n%s" ), ioe.errorText.GetData() );
wxMessageBox( msg, _( "Netlist Load Error" ), wxOK | wxICON_ERROR );
return 1;
}
// We also remove footprint name if it is "$noname" because this is a dummy name,
// not the actual name of the footprint.
for( unsigned ii = 0; ii < m_netlist.GetCount(); ii++ )
{
if( m_netlist.GetComponent( ii )->GetFootprintLibName() == wxT( "$noname" ) )
m_netlist.GetComponent( ii )->SetFootprintLibName( wxEmptyString );
}
// Sort components by reference:
m_netlist.SortByReference();
return 0;
}
/* File header. */
static char HeaderLinkFile[] = { "Cmp-Mod V01" };
bool CVPCB_MAINFRAME::WriteComponentLinkFile( const wxString& aFullFileName )
{
COMPONENT* component;
FILE* outputFile;
wxFileName fn( aFullFileName );
wxString Title = wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion();
outputFile = wxFopen( fn.GetFullPath(), wxT( "wt" ) );
if( outputFile == NULL )
return false;
int retval = 0;
/*
* The header is:
* Cmp-Mod V01 Created by CvPcb (2012-02-08 BZR 3403)-testing date = 10/02/2012 20:45:59
* and write block per component like:
* BeginCmp
* TimeStamp = /322D3011;
* Reference = BUS1;
* ValeurCmp = BUSPC;
* IdModule = BUS_PC;
* EndCmp
*/
retval |= fprintf( outputFile, "%s", HeaderLinkFile );
retval |= fprintf( outputFile, " Created by %s", TO_UTF8( Title ) );
retval |= fprintf( outputFile, " date = %s\n", TO_UTF8( DateAndTime() ) );
for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
{
component = m_netlist.GetComponent( i );
retval |= fprintf( outputFile, "\nBeginCmp\n" );
retval |= fprintf( outputFile, "TimeStamp = %s;\n", TO_UTF8( component->GetTimeStamp() ) );
retval |= fprintf( outputFile, "Reference = %s;\n", TO_UTF8( component->GetReference() ) );
retval |= fprintf( outputFile, "ValeurCmp = %s;\n", TO_UTF8( component->GetValue() ) );
retval |= fprintf( outputFile, "IdModule = %s;\n",
TO_UTF8( component->GetFootprintLibName() ) );
retval |= fprintf( outputFile, "EndCmp\n" );
}
retval |= fprintf( outputFile, "\nEndListe\n" );
fclose( outputFile );
return retval >= 0;
}
void CVPCB_MAINFRAME::CreateScreenCmp()
{
if( m_DisplayFootprintFrame == NULL )
{
m_DisplayFootprintFrame = new DISPLAY_FOOTPRINTS_FRAME( this, _( "Module" ),
wxPoint( 0, 0 ),
wxSize( 600, 400 ),
KICAD_DEFAULT_DRAWFRAME_STYLE );
m_DisplayFootprintFrame->Show( true );
}
else
{
if( m_DisplayFootprintFrame->IsIconized() )
m_DisplayFootprintFrame->Iconize( false );
}
m_DisplayFootprintFrame->InitDisplay();
}
......@@ -156,6 +156,11 @@ public:
void SetNewPkg( const wxString& aFootprintName );
void BuildCmpListBox();
void BuildFOOTPRINTS_LISTBOX();
/**
* Create or Update the frame showing the current highlighted footprint
* and (if showed) the 3D display frame
*/
void CreateScreenCmp();
/**
......
/**
* @file cvpcb/loadcmp.cpp
*/
#include <fctsys.h>
#include <wxstruct.h>
#include <gr_basic.h>
#include <confirm.h>
#include <kicad_string.h>
#include <gestfich.h>
#include <macros.h>
#include <appl_wxstruct.h>
#include <pcbstruct.h>
#include <class_module.h>
#include <class_board.h>
#include <cvpcb.h>
#include <cvpcb_mainframe.h>
#include <class_DisplayFootprintsFrame.h>
#include <io_mgr.h>
#include <wildcards_and_files_ext.h>
/* Read libraries to find a module.
* If this module is found, copy it into memory
*
* aFootprintName is the module name
* return - a pointer to the loaded module or NULL.
*/
MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
{
CVPCB_MAINFRAME* parent = ( CVPCB_MAINFRAME* ) GetParent();
try
{
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
for( unsigned i = 0; i < parent->m_ModuleLibNames.GetCount(); ++i )
{
wxFileName fn = parent->m_ModuleLibNames[i];
fn.SetExt( LegacyFootprintLibPathExtension );
wxString libPath = wxGetApp().FindLibraryPath( fn );
if( !libPath )
{
wxString msg = wxString::Format( _( "PCB footprint library file <%s> could not "
"be found in the default search paths." ),
fn.GetFullName().GetData() );
// @todo we should not be using wxMessageBox directly.
wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR, this );
continue;
}
MODULE* footprint = pi->FootprintLoad( libPath, aFootprintName );
if( footprint )
{
footprint->SetParent( (EDA_ITEM*) GetBoard() );
footprint->SetPosition( wxPoint( 0, 0 ) );
return footprint;
}
}
}
catch( IO_ERROR ioe )
{
DisplayError( this, ioe.errorText );
return NULL;
}
wxString msg = wxString::Format( _( "Footprint '%s' not found" ), aFootprintName.GetData() );
DisplayError( this, msg );
return NULL;
}
/**
* @file cvpcb/read_write_cmpfile.cpp
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h>
#include <kicad_string.h>
#include <appl_wxstruct.h>
#include <cvpcb.h>
#include <cvpcb_mainframe.h>
#include <build_version.h>
/* File header. */
static char HeaderLinkFile[] = { "Cmp-Mod V01" };
/* Write the link file:
* the header is:
* Cmp-Mod V01 Created by CvPcb (2012-02-08 BZR 3403)-testing date = 10/02/2012 20:45:59
* and write block per component like:
* BeginCmp
* TimeStamp = /322D3011;
* Reference = BUS1;
* ValeurCmp = BUSPC;
* IdModule = BUS_PC;
* EndCmp
*/
bool CVPCB_MAINFRAME::WriteComponentLinkFile( const wxString& aFullFileName )
{
COMPONENT* component;
FILE* outputFile;
wxFileName fn( aFullFileName );
wxString Title = wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion();
outputFile = wxFopen( fn.GetFullPath(), wxT( "wt" ) );
if( outputFile == NULL )
return false;
int retval = 0;
retval |= fprintf( outputFile, "%s", HeaderLinkFile );
retval |= fprintf( outputFile, " Created by %s", TO_UTF8( Title ) );
retval |= fprintf( outputFile, " date = %s\n", TO_UTF8( DateAndTime() ) );
for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
{
component = m_netlist.GetComponent( i );
retval |= fprintf( outputFile, "\nBeginCmp\n" );
retval |= fprintf( outputFile, "TimeStamp = %s;\n", TO_UTF8( component->GetTimeStamp() ) );
retval |= fprintf( outputFile, "Reference = %s;\n", TO_UTF8( component->GetReference() ) );
retval |= fprintf( outputFile, "ValeurCmp = %s;\n", TO_UTF8( component->GetValue() ) );
retval |= fprintf( outputFile, "IdModule = %s;\n",
TO_UTF8( component->GetFootprintLibName() ) );
retval |= fprintf( outputFile, "EndCmp\n" );
}
retval |= fprintf( outputFile, "\nEndListe\n" );
fclose( outputFile );
return retval >= 0;
}
/**
* @file cvpcb/readschematicnetlist.cpp
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 Jean-Pierre Charras.
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/* Read a netlist type Eeschema (New and Old format)
* or OrcadPCB2 and build the component list
*/
#include <fctsys.h>
#include <wxstruct.h>
#include <confirm.h>
#include <kicad_string.h>
#include <macros.h>
#include <wildcards_and_files_ext.h>
#include <cvpcb_mainframe.h>
#include <richio.h>
#include <netlist_reader.h>
int CVPCB_MAINFRAME::ReadSchematicNetlist()
{
wxBusyCursor dummy; // Shows an hourglass while loading.
NETLIST_READER* netlistReader;
wxString msg;
wxString compFootprintLinkFileName;
wxFileName fn = m_NetlistFileName;
// Load the footprint association file if it has already been created.
fn.SetExt( ComponentFileExtension );
if( fn.FileExists() && fn.IsFileReadable() )
compFootprintLinkFileName = fn.GetFullPath();
m_netlist.Clear();
try
{
netlistReader = NETLIST_READER::GetNetlistReader( &m_netlist,
m_NetlistFileName.GetFullPath(),
compFootprintLinkFileName );
std::auto_ptr< NETLIST_READER > nlr( netlistReader );
netlistReader->LoadNetlist();
}
catch( IO_ERROR& ioe )
{
msg = wxString::Format( _( "Error loading netlist.\n%s" ), ioe.errorText.GetData() );
wxMessageBox( msg, _( "Netlist Load Error" ), wxOK | wxICON_ERROR );
return 1;
}
// We also remove footprint name if it is "$noname" because this is a dummy name,
// not the actual name of the footprint.
for( unsigned ii = 0; ii < m_netlist.GetCount(); ii++ )
{
if( m_netlist.GetComponent( ii )->GetFootprintLibName() == wxT( "$noname" ) )
m_netlist.GetComponent( ii )->SetFootprintLibName( wxEmptyString );
}
// Sort components by reference:
m_netlist.SortByReference();
return 0;
}
/**
* @file setvisu.cpp
*/
#include <fctsys.h>
#include <common.h>
#include <gr_basic.h>
#include <class_drawpanel.h>
#include <bitmaps.h>
#include <msgpanel.h>
#include <class_board.h>
#include <class_module.h>
#include <cvpcb.h>
#include <cvpcb_mainframe.h>
#include <cvstruct.h>
#include <class_DisplayFootprintsFrame.h>
/*
* NOTE: There is something in 3d_viewer.h that causes a compiler error in
* <boost/foreach.hpp> in Linux so move it after cvpcb.h where it is
* included to prevent the error from occurring.
*/
#include <3d_viewer.h>
/*
* Create or Update the frame showing the current highlighted footprint
* and (if showed) the 3D display frame
*/
void CVPCB_MAINFRAME::CreateScreenCmp()
{
if( m_DisplayFootprintFrame == NULL )
{
m_DisplayFootprintFrame = new DISPLAY_FOOTPRINTS_FRAME( this, _( "Module" ),
wxPoint( 0, 0 ),
wxSize( 600, 400 ),
KICAD_DEFAULT_DRAWFRAME_STYLE );
m_DisplayFootprintFrame->Show( true );
}
else
{
if( m_DisplayFootprintFrame->IsIconized() )
m_DisplayFootprintFrame->Iconize( false );
}
m_DisplayFootprintFrame->InitDisplay();
}
/* Refresh the full display for this frame:
* Set the title, the status line and redraw the canvas
* Must be called after the footprint to display is modifed
*/
void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
{
wxString msg;
CVPCB_MAINFRAME * parentframe = (CVPCB_MAINFRAME *) GetParent();
wxString footprintName = parentframe->m_FootprintList->GetSelectedFootprint();
if( !footprintName.IsEmpty() )
{
msg.Printf( _( "Footprint: %s" ), GetChars( footprintName ) );
SetTitle( msg );
FOOTPRINT_INFO* module_info = parentframe->m_footprints.GetModuleInfo( footprintName );
const wxChar *libname;
if( module_info )
libname = GetChars( module_info->m_LibName );
else
libname = GetChars( wxT( "???" ) );
msg.Printf( _( "Lib: %s" ), libname );
SetStatusText( msg, 0 );
if( GetBoard()->m_Modules.GetCount() )
{
// there is only one module in the list
GetBoard()->m_Modules.DeleteAll();
}
MODULE* module = Get_Module( footprintName );
if( module )
GetBoard()->m_Modules.PushBack( module );
Zoom_Automatique( false );
}
else // No footprint to display. Erase old footprint, if any
{
if( GetBoard()->m_Modules.GetCount() )
{
GetBoard()->m_Modules.DeleteAll();
Zoom_Automatique( false );
SetStatusText( wxEmptyString, 0 );
}
}
// Display new cursor coordinates and zoom value:
UpdateStatusBar();
GetCanvas()->Refresh();
if( m_Draw3DFrame )
m_Draw3DFrame->NewDisplay();
}
/*
* Draws the current highlighted footprint.
*/
void DISPLAY_FOOTPRINTS_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{
if( !GetBoard() )
return;
m_canvas->DrawBackGround( DC );
GetBoard()->Draw( m_canvas, DC, GR_COPY );
MODULE* Module = GetBoard()->m_Modules;
if ( Module )
{
MSG_PANEL_ITEMS items;
Module->GetMsgPanelInfo( items );
SetMsgPanel( items );
}
m_canvas->DrawCrossHair( DC );
}
/*
* Redraw the BOARD items but not cursors, axis or grid.
*/
void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
GR_DRAWMODE aDrawMode, const wxPoint& aOffset )
{
if( m_Modules )
{
m_Modules->Draw( aPanel, aDC, GR_COPY );
}
}
......@@ -135,9 +135,6 @@ public:
return NULL;
}
/**
* @copydoc INSPECTOR::Inspect()
*/
SEARCH_RESULT Inspect( EDA_ITEM* aItem, const void* aTestData = NULL );
/**
......@@ -330,9 +327,6 @@ public:
*/
bool ReplaceItem();
/**
* @copydoc INSPECTOR::Inspect()
*/
SEARCH_RESULT Inspect( EDA_ITEM* aItem, const void* aTestData = NULL );
/**
......
......@@ -2386,23 +2386,25 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, REPORTER* aReporter )
{
if( aReporter )
{
msg.Printf( _( "Adding new component \"%s:%s\" footprint \"%s\".\n" ),
GetChars( component->GetReference() ),
GetChars( component->GetTimeStamp() ),
GetChars( component->GetFootprintLibName() ) );
if( component->GetModule() != NULL )
msg.Printf( _( "Adding new component \"%s:%s\" footprint \"%s\".\n" ),
GetChars( component->GetReference() ),
GetChars( component->GetTimeStamp() ),
GetChars( component->GetFootprintLibName() ) );
else
msg.Printf( _( "Cannot add new component \"%s:%s\" due to missing "
"footprint \"%s\".\n" ),
GetChars( component->GetReference() ),
GetChars( component->GetTimeStamp() ),
GetChars( component->GetFootprintLibName() ) );
aReporter->Report( msg );
}
// Owned by NETLIST, can only copy and read it.
footprint = component->GetModule();
wxCHECK2_MSG( footprint != NULL, continue,
wxString::Format( wxT( "No footprint loaded for component \"%s\"." ),
GetChars( component->GetReference() ) ) );
if( !aNetlist.IsDryRun() )
if( !aNetlist.IsDryRun() && (component->GetModule() != NULL) )
{
footprint = new MODULE( *footprint );
// Owned by NETLIST, can only copy it.
footprint = new MODULE( *component->GetModule() );
footprint->SetParent( this );
footprint->SetPosition( bestPosition );
footprint->SetTimeStamp( GetNewTimeStamp() );
......@@ -2419,15 +2421,24 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, REPORTER* aReporter )
{
if( aReporter )
{
msg.Printf( _( "Replacing component \"%s:%s\" footprint \"%s\" with \"%s\".\n" ),
GetChars( footprint->GetReference() ),
GetChars( footprint->GetPath() ),
GetChars( footprint->GetLibRef() ),
GetChars( component->GetFootprintLibName() ) );
if( component->GetModule() != NULL )
msg.Printf( _( "Replacing component \"%s:%s\" footprint \"%s\" with "
"\"%s\".\n" ),
GetChars( footprint->GetReference() ),
GetChars( footprint->GetPath() ),
GetChars( footprint->GetLibRef() ),
GetChars( component->GetFootprintLibName() ) );
else
msg.Printf( _( "Cannot replace component \"%s:%s\" due to missing "
"footprint \"%s\".\n" ),
GetChars( footprint->GetReference() ),
GetChars( footprint->GetPath() ),
GetChars( component->GetFootprintLibName() ) );
aReporter->Report( msg );
}
if( !aNetlist.IsDryRun() )
if( !aNetlist.IsDryRun() && (component->GetModule() != NULL) )
{
wxASSERT( footprint != NULL );
MODULE* newFootprint = new MODULE( *component->GetModule() );
......@@ -2495,7 +2506,8 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, REPORTER* aReporter )
}
}
wxASSERT( component != NULL );
if( footprint == NULL )
continue;
// At this point, the component footprint is updated. Now update the nets.
for( pad = footprint->Pads(); pad; pad = pad->Next() )
......
......@@ -253,7 +253,6 @@ public:
void SetOutline( CPolyLine* aOutline ) { m_Poly = aOutline; }
/** @copydoc EDA_ITEM::HitTest(const wxPoint&) */
virtual bool HitTest( const wxPoint& aPosition );
/**
......@@ -324,7 +323,6 @@ public:
*/
bool HitTestForEdge( const wxPoint& refPos );
/** @copydoc EDA_ITEM::HitTest(const EDA_RECT&)const */
virtual bool HitTest( const EDA_RECT& aRect ) const;
/**
......
/**
* @file pcbnew/dialogs/dialog_netlist.cpp
*/
......@@ -140,7 +141,8 @@ void DIALOG_NETLIST::OnReadNetlistFileClick( wxCommandEvent& event )
}
// Give the user a chance to bail out when making changes from a netlist.
if( !m_parent->GetBoard()->IsEmpty()
if( !m_checkDryRun->GetValue()
&& !m_parent->GetBoard()->IsEmpty()
&& !IsOK( NULL, _( "The changes made by reading the netlist cannot be undone. Are you "
"sure you want to read the netlist?" ) ) )
return;
......
......@@ -29,7 +29,6 @@
#include <appl_wxstruct.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <richio.h>
#include <dialog_helpers.h>
#include <wxPcbStruct.h>
#include <netlist_reader.h>
......@@ -41,8 +40,6 @@
#include <pcbnew.h>
#include <io_mgr.h>
#include <algorithm>
void PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFileName,
const wxString& aCmpFileName,
......@@ -182,6 +179,7 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
{
component = aNetlist.GetComponent( ii );
// @todo Check if component is already on BOARD and only load footprint if it's needed.
if( ii == 0 || component->GetFootprintLibName() != lastFootprintLibName )
{
module = NULL;
......@@ -207,11 +205,17 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
if( module == NULL )
{
wxString msg;
msg.Printf( _( "Component `%s` footprint <%s> was not found in any libraries." ),
GetChars( component->GetReference() ),
GetChars( component->GetFootprintLibName() ) );
THROW_IO_ERROR( msg );
if( aReporter )
{
wxString msg;
msg.Printf( _( "*** Warning: component `%s` footprint <%s> was not found in "
"any libraries. ***\n" ),
GetChars( component->GetReference() ),
GetChars( component->GetFootprintLibName() ) );
aReporter->Report( msg );
}
continue;
}
}
else
......
......@@ -28,7 +28,6 @@
#include <richio.h>
#include <kicad_string.h>
#include <reporter.h>
......@@ -207,7 +206,7 @@ static bool SortByLibName( const COMPONENT& ref, const COMPONENT& cmp )
void NETLIST::SortByFootprintLibName()
{
sort( m_components.begin(), m_components.end(), SortByLibName );
m_components.sort( SortByLibName );
}
......@@ -223,7 +222,7 @@ bool operator < ( const COMPONENT& item1, const COMPONENT& item2 )
void NETLIST::SortByReference()
{
sort( m_components.begin(), m_components.end() );
m_components.sort();
}
......
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