2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file gen_modules_placefile.cpp
|
|
|
|
*/
|
2012-02-15 10:41:16 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/*
|
2007-08-23 04:28:46 +00:00
|
|
|
* 1 - create ascii files for automatic placement of smd components
|
|
|
|
* 2 - create a module report (pos and module descr) (ascii file)
|
|
|
|
*/
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <kicad_string.h>
|
|
|
|
#include <gestfich.h>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <trigo.h>
|
|
|
|
#include <appl_wxstruct.h>
|
|
|
|
#include <build_version.h>
|
|
|
|
#include <macros.h>
|
|
|
|
|
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_drawsegment.h>
|
2012-04-17 01:35:43 +00:00
|
|
|
#include <legacy_plugin.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
|
|
|
|
#include <pcbnew.h>
|
2012-02-15 10:41:16 +00:00
|
|
|
#include <pcb_plot_params.h>
|
2012-02-16 20:03:33 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2012-02-15 10:41:16 +00:00
|
|
|
|
|
|
|
#include <dialog_gen_module_position_file_base.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2010-01-05 08:48:49 +00:00
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
class LIST_MOD // An helper class used to build a list of useful footprints.
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MODULE* m_Module; // Link to the actual footprint
|
|
|
|
const wxChar* m_Reference; // Its schematic reference
|
|
|
|
const wxChar* m_Value; // Its schematic value
|
2013-03-31 13:27:46 +00:00
|
|
|
LAYER_NUM m_Layer; // its side (LAYER_N_BACK, or LAYER_N_FRONT)
|
2012-02-15 10:41:16 +00:00
|
|
|
};
|
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
|
|
|
|
/**
|
2012-02-15 10:41:16 +00:00
|
|
|
* The dialog to create footprint position files,
|
|
|
|
* and choose options (one or 2 files, units and force all SMD footprints in list)
|
|
|
|
*/
|
|
|
|
class DIALOG_GEN_MODULE_POSITION : public DIALOG_GEN_MODULE_POSITION_BASE
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2012-04-05 18:27:56 +00:00
|
|
|
DIALOG_GEN_MODULE_POSITION( PCB_EDIT_FRAME * aParent ):
|
|
|
|
DIALOG_GEN_MODULE_POSITION_BASE( aParent ),
|
|
|
|
m_parent( aParent ),
|
|
|
|
m_plotOpts( aParent->GetPlotSettings() )
|
2012-02-15 10:41:16 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-04-05 18:27:56 +00:00
|
|
|
PCB_EDIT_FRAME* m_parent;
|
|
|
|
PCB_PLOT_PARAMS m_plotOpts;
|
|
|
|
|
|
|
|
static int m_unitsOpt;
|
|
|
|
static int m_fileOpt;
|
|
|
|
|
|
|
|
void OnInitDialog( wxInitDialogEvent& event );
|
|
|
|
void OnOutputDirectoryBrowseClicked( wxCommandEvent& event );
|
|
|
|
void OnCancelButton( wxCommandEvent& event )
|
2012-02-15 10:41:16 +00:00
|
|
|
{
|
|
|
|
EndModal( wxID_CANCEL );
|
|
|
|
}
|
2012-04-05 18:27:56 +00:00
|
|
|
void OnOKButton( wxCommandEvent& event );
|
2012-02-15 10:41:16 +00:00
|
|
|
|
|
|
|
bool CreateFiles();
|
|
|
|
|
|
|
|
// accessors to options:
|
|
|
|
wxString GetOutputDirectory()
|
|
|
|
{
|
|
|
|
return m_outputDirectoryName->GetValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool UnitsMM()
|
|
|
|
{
|
|
|
|
return m_radioBoxUnits->GetSelection() == 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OneFileOnly()
|
|
|
|
{
|
|
|
|
return m_radioBoxFilesCount->GetSelection() == 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ForceAllSmd()
|
|
|
|
{
|
|
|
|
return m_radioBoxForceSmd->GetSelection() == 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AddMessage( const wxString & aMessage )
|
|
|
|
{
|
|
|
|
m_messagesBox->AppendText( aMessage );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
// Static members to remember choices
|
|
|
|
int DIALOG_GEN_MODULE_POSITION::m_unitsOpt = 0;
|
|
|
|
int DIALOG_GEN_MODULE_POSITION::m_fileOpt = 0;
|
|
|
|
|
|
|
|
void DIALOG_GEN_MODULE_POSITION::OnInitDialog( wxInitDialogEvent& event )
|
|
|
|
{
|
|
|
|
// Output directory
|
2012-04-05 18:27:56 +00:00
|
|
|
m_outputDirectoryName->SetValue( m_plotOpts.GetOutputDirectory() );
|
2012-02-15 10:41:16 +00:00
|
|
|
m_radioBoxUnits->SetSelection( m_unitsOpt );
|
|
|
|
m_radioBoxFilesCount->SetSelection( m_fileOpt );
|
|
|
|
|
|
|
|
m_sdbSizerButtonsOK->SetDefault();
|
|
|
|
GetSizer()->SetSizeHints(this);
|
|
|
|
Centre();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DIALOG_GEN_MODULE_POSITION::OnOutputDirectoryBrowseClicked( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
// Build the absolute path of current output plot directory
|
|
|
|
// to preselect it when opening the dialog.
|
|
|
|
wxFileName fn( m_outputDirectoryName->GetValue() );
|
|
|
|
wxString path;
|
|
|
|
|
|
|
|
if( fn.IsRelative() )
|
|
|
|
path = wxGetCwd() + fn.GetPathSeparator() + m_outputDirectoryName->GetValue();
|
|
|
|
else
|
|
|
|
path = m_outputDirectoryName->GetValue();
|
|
|
|
|
|
|
|
wxDirDialog dirDialog( this, _( "Select Output Directory" ), path );
|
|
|
|
|
|
|
|
if( dirDialog.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
|
|
|
|
|
|
|
|
wxMessageDialog dialog( this, _( "Use a relative path? "),
|
|
|
|
_( "Plot Output Directory" ),
|
|
|
|
wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT );
|
|
|
|
|
|
|
|
if( dialog.ShowModal() == wxID_YES )
|
|
|
|
{
|
2012-08-29 16:59:50 +00:00
|
|
|
wxString boardFilePath = ( (wxFileName) m_parent->GetBoard()->GetFileName()).GetPath();
|
2012-02-15 10:41:16 +00:00
|
|
|
|
|
|
|
if( !dirName.MakeRelativeTo( boardFilePath ) )
|
|
|
|
wxMessageBox( _( "Cannot make path relative (target volume different from board file volume)!" ),
|
|
|
|
_( "Plot Output Directory" ), wxOK | wxICON_ERROR );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_outputDirectoryName->SetValue( dirName.GetFullPath() );
|
|
|
|
}
|
|
|
|
|
|
|
|
void DIALOG_GEN_MODULE_POSITION::OnOKButton( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
m_unitsOpt = m_radioBoxUnits->GetSelection();
|
|
|
|
m_fileOpt = m_radioBoxFilesCount->GetSelection();
|
|
|
|
|
|
|
|
// Set output directory and replace backslashes with forward ones
|
|
|
|
// (Keep unix convention in cfg files)
|
|
|
|
wxString dirStr;
|
|
|
|
dirStr = m_outputDirectoryName->GetValue();
|
|
|
|
dirStr.Replace( wxT( "\\" ), wxT( "/" ) );
|
2012-04-05 18:27:56 +00:00
|
|
|
|
|
|
|
m_plotOpts.SetOutputDirectory( dirStr );
|
|
|
|
|
|
|
|
m_parent->SetPlotSettings( m_plotOpts );
|
2012-02-15 10:41:16 +00:00
|
|
|
|
|
|
|
CreateFiles();
|
|
|
|
}
|
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
bool DIALOG_GEN_MODULE_POSITION::CreateFiles()
|
|
|
|
{
|
|
|
|
BOARD * brd = m_parent->GetBoard();
|
|
|
|
wxFileName fn;
|
|
|
|
wxString msg;
|
|
|
|
wxString frontLayerName;
|
|
|
|
wxString backLayerName;
|
|
|
|
bool singleFile = OneFileOnly();
|
|
|
|
int fullcount = 0;
|
|
|
|
|
2012-08-29 16:59:50 +00:00
|
|
|
fn = m_parent->GetBoard()->GetFileName();
|
2012-02-15 10:41:16 +00:00
|
|
|
fn.SetPath( GetOutputDirectory() );
|
|
|
|
frontLayerName = brd->GetLayerName( LAYER_N_FRONT );
|
|
|
|
backLayerName = brd->GetLayerName( LAYER_N_BACK );
|
|
|
|
|
|
|
|
// Create the the Front or Top side placement file,
|
|
|
|
// or the single file
|
|
|
|
int side = 1;
|
|
|
|
if( singleFile )
|
|
|
|
{
|
|
|
|
side = 2;
|
2012-05-03 18:37:56 +00:00
|
|
|
fn.SetName( fn.GetName() + wxT( "-" ) + wxT("all") );
|
2012-02-15 10:41:16 +00:00
|
|
|
}
|
|
|
|
else
|
2012-05-03 18:37:56 +00:00
|
|
|
fn.SetName( fn.GetName() + wxT( "-" ) + frontLayerName );
|
2012-02-15 10:41:16 +00:00
|
|
|
|
2012-02-16 20:03:33 +00:00
|
|
|
fn.SetExt( FootprintPlaceFileExtension );
|
2012-02-15 10:41:16 +00:00
|
|
|
|
|
|
|
int fpcount = m_parent->DoGenFootprintsPositionFile( fn.GetFullPath(), UnitsMM(),
|
|
|
|
ForceAllSmd(), side );
|
|
|
|
if( fpcount < 0 )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "Unable to create <%s>" ), GetChars( fn.GetFullPath() ) );
|
|
|
|
AddMessage( msg + wxT("\n") );
|
|
|
|
wxMessageBox( msg );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( fpcount == 0)
|
|
|
|
{
|
|
|
|
wxMessageBox( _( "No modules for automated placement." ) );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( singleFile )
|
2013-04-09 17:49:01 +00:00
|
|
|
msg.Printf( _( "Place file: <%s>\n" ), GetChars( fn.GetFullPath() ) );
|
2012-02-15 10:41:16 +00:00
|
|
|
else
|
2013-04-10 07:23:20 +00:00
|
|
|
msg.Printf( _( "Front side (top side) place file: <%s>\n" ),
|
|
|
|
GetChars( fn.GetFullPath() ) );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
AddMessage( msg );
|
|
|
|
msg.Printf( _( "Footprint count %d\n" ), fpcount );
|
|
|
|
AddMessage( msg );
|
|
|
|
|
|
|
|
if( singleFile )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// Create the Back or Bottom side placement file
|
|
|
|
fullcount = fpcount;
|
|
|
|
side = 0;
|
2012-08-29 16:59:50 +00:00
|
|
|
fn = brd->GetFileName();
|
2012-02-15 10:41:16 +00:00
|
|
|
fn.SetPath( GetOutputDirectory() );
|
2012-05-03 18:37:56 +00:00
|
|
|
fn.SetName( fn.GetName() + wxT( "-" ) + backLayerName );
|
2012-02-15 10:41:16 +00:00
|
|
|
fn.SetExt( wxT( "pos" ) );
|
|
|
|
|
|
|
|
fpcount = m_parent->DoGenFootprintsPositionFile( fn.GetFullPath(), UnitsMM(),
|
|
|
|
ForceAllSmd(), side );
|
|
|
|
|
|
|
|
if( fpcount < 0 )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "Unable to create <%s>" ), GetChars( fn.GetFullPath() ) );
|
|
|
|
AddMessage( msg + wxT("\n") );
|
|
|
|
wxMessageBox( msg );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Display results
|
|
|
|
if( !singleFile )
|
|
|
|
{
|
2013-04-10 07:23:20 +00:00
|
|
|
msg.Printf( _( "Back side (bottom side) place file: <%s>\n" ), GetChars( fn.GetFullPath() ) );
|
2012-02-15 10:41:16 +00:00
|
|
|
AddMessage( msg );
|
|
|
|
msg.Printf( _( "Footprint count %d\n" ), fpcount );
|
|
|
|
AddMessage( msg );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !singleFile )
|
|
|
|
{
|
|
|
|
fullcount += fpcount;
|
|
|
|
msg.Printf( _( "Full footprint count %d\n" ), fullcount );
|
|
|
|
AddMessage( msg );
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Defined values to write coordinates using inches or mm:
|
2012-05-03 18:37:56 +00:00
|
|
|
static const double conv_unit_inch = 0.001 / IU_PER_MILS ; // units = INCHES
|
2012-02-15 10:41:16 +00:00
|
|
|
static const char unit_text_inch[] = "## Unit = inches, Angle = deg.\n";
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
static const double conv_unit_mm = 1.0 / IU_PER_MM; // units = mm
|
2012-02-15 10:41:16 +00:00
|
|
|
static const char unit_text_mm[] = "## Unit = mm, Angle = deg.\n";
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
|
2012-02-11 18:54:36 +00:00
|
|
|
static wxPoint File_Place_Offset; // Offset coordinates for generated file.
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
static void WriteDrawSegmentPcb( DRAWSEGMENT* PtDrawSegment, FILE* rptfile,
|
|
|
|
double aConvUnit );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2012-02-11 18:54:36 +00:00
|
|
|
// Sort function use by GenereModulesPosition()
|
2012-02-15 10:41:16 +00:00
|
|
|
// sort is made by side (layer) top layer first
|
|
|
|
// then by reference increasing order
|
|
|
|
static bool sortFPlist( const LIST_MOD& ref, const LIST_MOD& tst )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-02-15 10:41:16 +00:00
|
|
|
if( ref.m_Layer == tst.m_Layer )
|
|
|
|
return StrNumCmp( ref.m_Reference, tst.m_Reference, 16 ) < 0;
|
2008-10-01 23:35:31 +00:00
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
return ref.m_Layer > tst.m_Layer;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-23 18:11:36 +00:00
|
|
|
/**
|
2012-02-15 10:41:16 +00:00
|
|
|
* Helper function HasNonSMDPins
|
2008-04-23 18:11:36 +00:00
|
|
|
* returns true if the given module has any non smd pins, such as through hole
|
|
|
|
* and therefore cannot be placed automatically.
|
|
|
|
*/
|
|
|
|
static bool HasNonSMDPins( MODULE* aModule )
|
|
|
|
{
|
|
|
|
D_PAD* pad;
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
for( pad = aModule->Pads(); pad; pad = pad->Next() )
|
2008-04-23 18:11:36 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
if( pad->GetAttribute() != PAD_SMD )
|
2008-04-23 18:11:36 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
void PCB_EDIT_FRAME::GenFootprintsPositionFile( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
DIALOG_GEN_MODULE_POSITION dlg( this );
|
|
|
|
dlg.ShowModal();
|
|
|
|
}
|
2008-04-23 18:11:36 +00:00
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
/*
|
|
|
|
* Creates a footprint position file
|
|
|
|
* aSide = 0 -> Back (bottom) side)
|
|
|
|
* aSide = 1 -> Front (top) side)
|
|
|
|
* aSide = 2 -> both sides
|
2012-12-06 21:53:00 +00:00
|
|
|
*
|
|
|
|
* The format is:
|
|
|
|
* ### Module positions - created on 04/12/2012 15:24:24 ###
|
|
|
|
* ### Printed by Pcbnew version pcbnew (2012-11-30 BZR 3828)-testing
|
|
|
|
* ## Unit = inches, Angle = deg.
|
|
|
|
* ## Side : Front
|
|
|
|
* # Ref Val Package PosX PosY Rot Side
|
|
|
|
* C123 0,1uF/50V SM0603 1.6024 -2.6280 180.0 Front
|
|
|
|
* C124 0,1uF/50V SM0603 1.6063 -2.7579 180.0 Front
|
|
|
|
* C125 0,1uF/50V SM0603 1.6010 -2.8310 180.0 Front
|
|
|
|
* ## End
|
|
|
|
*
|
2012-02-15 10:41:16 +00:00
|
|
|
*/
|
|
|
|
int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName,
|
|
|
|
bool aUnitsMM,
|
|
|
|
bool aForceSmdItems, int aSide )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-10-01 16:00:35 +00:00
|
|
|
MODULE* module;
|
|
|
|
char line[1024];
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
File_Place_Offset = GetOriginAxisPosition();
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2012-02-11 18:54:36 +00:00
|
|
|
// Calculating the number of useful modules (CMS attribute, not VIRTUAL)
|
2008-10-01 16:00:35 +00:00
|
|
|
int moduleCount = 0;
|
2008-04-23 18:11:36 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
for( module = GetBoard()->m_Modules; module; module = module->Next() )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2012-02-15 10:41:16 +00:00
|
|
|
if( aSide < 2 )
|
|
|
|
{
|
|
|
|
if( module->GetLayer() == LAYER_N_BACK && aSide == 1)
|
|
|
|
continue;
|
|
|
|
if( module->GetLayer() == LAYER_N_FRONT && aSide == 0)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
if( module->GetAttributes() & MOD_VIRTUAL )
|
2008-04-23 18:11:36 +00:00
|
|
|
{
|
2013-09-10 08:47:42 +00:00
|
|
|
DBG( printf( "skipping module %s because it's virtual\n",
|
2011-02-28 18:36:19 +00:00
|
|
|
TO_UTF8( module->GetReference() ) );)
|
2007-08-23 04:28:46 +00:00
|
|
|
continue;
|
2008-04-23 18:11:36 +00:00
|
|
|
}
|
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
if( ( module->GetAttributes() & MOD_CMS ) == 0 )
|
2008-04-23 18:11:36 +00:00
|
|
|
{
|
2012-02-15 10:41:16 +00:00
|
|
|
if( aForceSmdItems ) // true to fix a bunch of mis-labeled modules:
|
2008-04-23 18:11:36 +00:00
|
|
|
{
|
2012-02-15 10:41:16 +00:00
|
|
|
if( !HasNonSMDPins( module ) )
|
|
|
|
{
|
|
|
|
// all module's pins are SMD, mark the part for pick and place
|
2013-03-13 18:53:58 +00:00
|
|
|
module->SetAttributes( module->GetAttributes() | MOD_CMS );
|
2012-02-15 10:41:16 +00:00
|
|
|
OnModify();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-10 08:47:42 +00:00
|
|
|
DBG(printf( "skipping %s because its attribute is not CMS and it has non SMD pins\n",
|
2013-03-13 18:53:58 +00:00
|
|
|
TO_UTF8(module->GetReference()) ) );
|
2012-02-15 10:41:16 +00:00
|
|
|
continue;
|
|
|
|
}
|
2008-04-23 18:11:36 +00:00
|
|
|
}
|
2012-12-06 21:53:00 +00:00
|
|
|
else
|
|
|
|
continue;
|
2008-04-23 18:11:36 +00:00
|
|
|
}
|
|
|
|
|
2008-10-01 16:00:35 +00:00
|
|
|
moduleCount++;
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
FILE * file = wxFopen( aFullFileName, wxT( "wt" ) );
|
|
|
|
if( file == NULL )
|
|
|
|
return -1;
|
2011-02-27 23:25:07 +00:00
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
// Select units:
|
|
|
|
double conv_unit = aUnitsMM ? conv_unit_mm : conv_unit_inch;
|
|
|
|
const char *unit_text = aUnitsMM ? unit_text_mm : unit_text_inch;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
// Build and sort the list of modules alphabetically
|
|
|
|
std::vector<LIST_MOD> list;
|
|
|
|
list.reserve(moduleCount);
|
2012-12-06 21:53:00 +00:00
|
|
|
for( module = GetBoard()->m_Modules; module; module = module->Next() )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2012-02-15 10:41:16 +00:00
|
|
|
if( aSide < 2 )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2012-02-15 10:41:16 +00:00
|
|
|
if( module->GetLayer() == LAYER_N_BACK && aSide == 1)
|
|
|
|
continue;
|
|
|
|
if( module->GetLayer() == LAYER_N_FRONT && aSide == 0)
|
|
|
|
continue;
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
if( module->GetAttributes() & MOD_VIRTUAL )
|
2007-08-23 04:28:46 +00:00
|
|
|
continue;
|
2008-10-01 23:35:31 +00:00
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
if( (module->GetAttributes() & MOD_CMS) == 0 )
|
2007-08-23 04:28:46 +00:00
|
|
|
continue;
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
LIST_MOD item;
|
|
|
|
item.m_Module = module;
|
2013-03-13 18:53:58 +00:00
|
|
|
item.m_Reference = module->GetReference();
|
|
|
|
item.m_Value = module->GetValue();
|
2012-02-15 10:41:16 +00:00
|
|
|
item.m_Layer = module->GetLayer();
|
|
|
|
list.push_back( item );
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
|
2012-12-06 21:53:00 +00:00
|
|
|
if( list.size() > 1 )
|
2012-02-15 10:41:16 +00:00
|
|
|
sort( list.begin(), list.end(), sortFPlist );
|
|
|
|
|
|
|
|
wxString frontLayerName = GetBoard()->GetLayerName( LAYER_N_FRONT );
|
|
|
|
wxString backLayerName = GetBoard()->GetLayerName( LAYER_N_BACK );
|
|
|
|
|
2012-12-06 21:53:00 +00:00
|
|
|
// Switch the locale to standard C (needed to print floating point numbers)
|
|
|
|
LOCALE_IO toggle;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2011-02-27 23:25:07 +00:00
|
|
|
// Write file header
|
2011-11-08 16:37:25 +00:00
|
|
|
sprintf( line, "### Module positions - created on %s ###\n", TO_UTF8( DateAndTime() ) );
|
2012-02-15 10:41:16 +00:00
|
|
|
fputs( line, file );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
wxString Title = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion();
|
2011-09-30 18:15:37 +00:00
|
|
|
sprintf( line, "### Printed by Pcbnew version %s\n", TO_UTF8( Title ) );
|
2012-02-15 10:41:16 +00:00
|
|
|
fputs( line, file );
|
2011-02-27 23:25:07 +00:00
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
fputs( unit_text, file );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
sprintf( line, "## Side : %s\n",
|
|
|
|
( aSide < 2 ) ? TO_UTF8( frontLayerName ) : "All" );
|
|
|
|
fputs( line, file );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2008-10-01 16:00:35 +00:00
|
|
|
sprintf( line,
|
2012-05-03 18:37:56 +00:00
|
|
|
"# Ref Val Package PosX PosY Rot Side\n" );
|
2012-02-15 10:41:16 +00:00
|
|
|
fputs( line, file );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2008-10-01 16:00:35 +00:00
|
|
|
for( int ii = 0; ii < moduleCount; ii++ )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
|
|
|
wxPoint module_pos;
|
2012-05-03 18:37:56 +00:00
|
|
|
const wxString& ref = list[ii].m_Reference;
|
|
|
|
const wxString& val = list[ii].m_Value;
|
2013-03-13 18:53:58 +00:00
|
|
|
const wxString& pkg = list[ii].m_Module->GetLibRef();
|
2012-12-06 21:53:00 +00:00
|
|
|
sprintf( line, "%-8.8s %-16.16s %-16.16s",
|
2013-03-13 18:53:58 +00:00
|
|
|
TO_UTF8( ref ), TO_UTF8( val ), TO_UTF8( pkg ) );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
module_pos = list[ii].m_Module->GetPosition();
|
2012-02-15 10:41:16 +00:00
|
|
|
module_pos -= File_Place_Offset;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2008-10-01 16:00:35 +00:00
|
|
|
char* text = line + strlen( line );
|
2012-05-03 18:37:56 +00:00
|
|
|
/* Keep the coordinates in the first quadrant, like the gerbers
|
|
|
|
* (i.e. change sign to y) */
|
2007-08-23 04:28:46 +00:00
|
|
|
sprintf( text, " %9.4f %9.4f %8.1f ",
|
2009-03-15 21:11:12 +00:00
|
|
|
module_pos.x * conv_unit,
|
2012-05-03 18:37:56 +00:00
|
|
|
-module_pos.y * conv_unit,
|
2013-05-01 17:32:36 +00:00
|
|
|
list[ii].m_Module->GetOrientation() / 10.0 );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
LAYER_NUM layer = list[ii].m_Module->GetLayer();
|
2008-10-01 23:35:31 +00:00
|
|
|
|
2009-12-07 03:46:13 +00:00
|
|
|
wxASSERT( layer==LAYER_N_FRONT || layer==LAYER_N_BACK );
|
2008-10-01 23:35:31 +00:00
|
|
|
|
2009-12-07 03:46:13 +00:00
|
|
|
if( layer == LAYER_N_FRONT )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2011-02-28 18:36:19 +00:00
|
|
|
strcat( line, TO_UTF8( frontLayerName ) );
|
2008-10-01 16:00:35 +00:00
|
|
|
strcat( line, "\n" );
|
2012-02-15 10:41:16 +00:00
|
|
|
fputs( line, file );
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
2009-12-07 03:46:13 +00:00
|
|
|
else if( layer == LAYER_N_BACK )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2011-02-28 18:36:19 +00:00
|
|
|
strcat( line, TO_UTF8( backLayerName ) );
|
2008-10-01 16:00:35 +00:00
|
|
|
strcat( line, "\n" );
|
2012-02-15 10:41:16 +00:00
|
|
|
fputs( line, file );
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-27 23:25:07 +00:00
|
|
|
// Write EOF
|
2012-02-15 10:41:16 +00:00
|
|
|
fputs( "## End\n", file );
|
2008-10-01 16:00:35 +00:00
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
fclose( file );
|
|
|
|
return moduleCount;
|
|
|
|
}
|
2008-10-01 16:00:35 +00:00
|
|
|
|
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
void PCB_EDIT_FRAME::GenFootprintsReport( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
wxFileName fn;
|
2008-10-01 23:35:31 +00:00
|
|
|
|
2012-08-29 16:59:50 +00:00
|
|
|
wxString boardFilePath = ( (wxFileName) GetBoard()->GetFileName()).GetPath();
|
2012-02-15 10:41:16 +00:00
|
|
|
wxDirDialog dirDialog( this, _( "Select Output Directory" ), boardFilePath );
|
2008-10-01 23:35:31 +00:00
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
if( dirDialog.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
2008-10-01 23:35:31 +00:00
|
|
|
|
2012-08-29 16:59:50 +00:00
|
|
|
fn = GetBoard()->GetFileName();
|
2012-02-15 10:41:16 +00:00
|
|
|
fn.SetPath( dirDialog.GetPath() );
|
|
|
|
fn.SetExt( wxT( "rpt" ) );
|
2008-10-01 16:05:20 +00:00
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
bool success = DoGenFootprintsReport( fn.GetFullPath(), false );
|
2008-10-01 16:00:35 +00:00
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
wxString msg;
|
|
|
|
if( success )
|
|
|
|
{
|
2013-04-09 17:49:01 +00:00
|
|
|
msg.Printf( _( "Module report file created:\n<%s>" ),
|
2012-02-15 10:41:16 +00:00
|
|
|
GetChars( fn.GetFullPath() ) );
|
|
|
|
wxMessageBox( msg, _( "Module Report" ), wxICON_INFORMATION );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
msg.Printf( _( "Unable to create <%s>" ), GetChars( fn.GetFullPath() ) );
|
|
|
|
DisplayError( this, msg );
|
|
|
|
}
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/* Print a module report.
|
2007-08-23 04:28:46 +00:00
|
|
|
*/
|
2012-02-15 10:41:16 +00:00
|
|
|
bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool aUnitsMM )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-23 04:28:46 +00:00
|
|
|
D_PAD* pad;
|
2011-11-08 16:37:25 +00:00
|
|
|
char line[1024];
|
2009-04-05 20:49:15 +00:00
|
|
|
wxString fnFront, msg;
|
2007-08-23 04:28:46 +00:00
|
|
|
FILE* rptfile;
|
|
|
|
wxPoint module_pos;
|
|
|
|
|
|
|
|
File_Place_Offset = wxPoint( 0, 0 );
|
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
rptfile = wxFopen( aFullFilename, wxT( "wt" ) );
|
2011-02-27 23:25:07 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
if( rptfile == NULL )
|
2012-02-15 10:41:16 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
// Select units:
|
|
|
|
double conv_unit = aUnitsMM ? conv_unit_mm : conv_unit_inch;
|
|
|
|
const char *unit_text = aUnitsMM ? unit_text_mm : unit_text_inch;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2012-04-17 01:35:43 +00:00
|
|
|
LOCALE_IO toggle;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2012-02-11 18:54:36 +00:00
|
|
|
// Generate header file comments.)
|
2011-11-08 16:37:25 +00:00
|
|
|
sprintf( line, "## Module report - date %s\n", TO_UTF8( DateAndTime() ) );
|
2008-10-01 16:00:35 +00:00
|
|
|
fputs( line, rptfile );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
wxString Title = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion();
|
2011-09-30 18:15:37 +00:00
|
|
|
sprintf( line, "## Created by Pcbnew version %s\n", TO_UTF8( Title ) );
|
2008-10-01 16:00:35 +00:00
|
|
|
fputs( line, rptfile );
|
2012-02-11 18:54:36 +00:00
|
|
|
fputs( unit_text, rptfile );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
fputs( "##\n", rptfile );
|
|
|
|
fputs( "\n$BeginDESCRIPTION\n", rptfile );
|
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
EDA_RECT bbbox = GetBoard()->ComputeBoundingBox();
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
fputs( "\n$BOARD\n", rptfile );
|
|
|
|
fputs( "unit INCH\n", rptfile );
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
|
2008-10-01 16:00:35 +00:00
|
|
|
sprintf( line, "upper_left_corner %9.6f %9.6f\n",
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
bbbox.GetX() * conv_unit,
|
|
|
|
bbbox.GetY() * conv_unit );
|
|
|
|
|
2008-10-01 16:00:35 +00:00
|
|
|
fputs( line, rptfile );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2008-10-01 16:00:35 +00:00
|
|
|
sprintf( line, "lower_right_corner %9.6f %9.6f\n",
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
bbbox.GetRight() * conv_unit,
|
|
|
|
bbbox.GetBottom() * conv_unit );
|
2008-10-01 16:00:35 +00:00
|
|
|
fputs( line, rptfile );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
fputs( "$EndBOARD\n\n", rptfile );
|
|
|
|
|
2012-04-17 01:35:43 +00:00
|
|
|
try
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2012-04-17 01:35:43 +00:00
|
|
|
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2012-04-17 01:35:43 +00:00
|
|
|
LEGACY_PLUGIN* legacy = (LEGACY_PLUGIN*) (PLUGIN*) pi;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-04-17 01:35:43 +00:00
|
|
|
legacy->SetFilePtr( rptfile );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-04-17 01:35:43 +00:00
|
|
|
for( MODULE* Module = GetBoard()->m_Modules; Module; Module = Module->Next() )
|
|
|
|
{
|
2013-03-13 18:53:58 +00:00
|
|
|
sprintf( line, "$MODULE %s\n", EscapedUTF8( Module->GetReference() ).c_str() );
|
2012-04-17 01:35:43 +00:00
|
|
|
fputs( line, rptfile );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
sprintf( line, "reference %s\n", EscapedUTF8( Module->GetReference() ).c_str() );
|
2012-04-17 01:35:43 +00:00
|
|
|
fputs( line, rptfile );
|
2013-03-13 18:53:58 +00:00
|
|
|
sprintf( line, "value %s\n", EscapedUTF8( Module->GetValue() ).c_str() );
|
2012-04-17 01:35:43 +00:00
|
|
|
fputs( line, rptfile );
|
2013-03-13 18:53:58 +00:00
|
|
|
sprintf( line, "footprint %s\n", EscapedUTF8( Module->GetLibRef() ).c_str() );
|
2012-04-17 01:35:43 +00:00
|
|
|
fputs( line, rptfile );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2012-04-17 01:35:43 +00:00
|
|
|
msg = wxT( "attribut" );
|
2009-03-15 21:11:12 +00:00
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
if( Module->GetAttributes() & MOD_VIRTUAL )
|
2012-04-17 01:35:43 +00:00
|
|
|
msg += wxT( " virtual" );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
if( Module->GetAttributes() & MOD_CMS )
|
2012-04-17 01:35:43 +00:00
|
|
|
msg += wxT( " smd" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
if( ( Module->GetAttributes() & (MOD_VIRTUAL | MOD_CMS) ) == 0 )
|
2012-04-17 01:35:43 +00:00
|
|
|
msg += wxT( " none" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-04-17 01:35:43 +00:00
|
|
|
msg += wxT( "\n" );
|
|
|
|
fputs( TO_UTF8( msg ), rptfile );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
module_pos = Module->GetPosition();
|
2012-04-17 01:35:43 +00:00
|
|
|
module_pos.x -= File_Place_Offset.x;
|
|
|
|
module_pos.y -= File_Place_Offset.y;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2008-10-01 16:00:35 +00:00
|
|
|
sprintf( line, "position %9.6f %9.6f\n",
|
2012-04-17 01:35:43 +00:00
|
|
|
module_pos.x * conv_unit,
|
|
|
|
module_pos.y * conv_unit );
|
2008-10-01 16:00:35 +00:00
|
|
|
fputs( line, rptfile );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2013-05-01 17:32:36 +00:00
|
|
|
sprintf( line, "orientation %.2f\n", Module->GetOrientation() / 10.0 );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2012-04-17 01:35:43 +00:00
|
|
|
if( Module->GetLayer() == LAYER_N_FRONT )
|
|
|
|
strcat( line, "layer component\n" );
|
|
|
|
else if( Module->GetLayer() == LAYER_N_BACK )
|
|
|
|
strcat( line, "layer copper\n" );
|
|
|
|
else
|
|
|
|
strcat( line, "layer other\n" );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2008-10-01 16:00:35 +00:00
|
|
|
fputs( line, rptfile );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2012-04-17 01:35:43 +00:00
|
|
|
legacy->SaveModule3D( Module );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
for( pad = Module->Pads(); pad != NULL; pad = pad->Next() )
|
2012-04-17 01:35:43 +00:00
|
|
|
{
|
|
|
|
fprintf( rptfile, "$PAD \"%s\"\n", TO_UTF8( pad->GetPadName() ) );
|
|
|
|
sprintf( line, "position %9.6f %9.6f\n",
|
|
|
|
pad->GetPos0().x * conv_unit,
|
|
|
|
pad->GetPos0().y * conv_unit );
|
|
|
|
fputs( line, rptfile );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2012-04-17 01:35:43 +00:00
|
|
|
sprintf( line, "size %9.6f %9.6f\n",
|
|
|
|
pad->GetSize().x * conv_unit,
|
|
|
|
pad->GetSize().y * conv_unit );
|
|
|
|
fputs( line, rptfile );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2012-04-17 01:35:43 +00:00
|
|
|
sprintf( line, "drill %9.6f\n", pad->GetDrillSize().x * conv_unit );
|
|
|
|
fputs( line, rptfile );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-04-17 01:35:43 +00:00
|
|
|
sprintf( line, "shape_offset %9.6f %9.6f\n",
|
|
|
|
pad->GetOffset().x * conv_unit,
|
|
|
|
pad->GetOffset().y * conv_unit );
|
|
|
|
fputs( line, rptfile );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-04-17 01:35:43 +00:00
|
|
|
sprintf( line, "orientation %.2f\n",
|
2013-05-01 17:32:36 +00:00
|
|
|
(pad->GetOrientation() - Module->GetOrientation()) / 10.0 );
|
2012-04-17 01:35:43 +00:00
|
|
|
fputs( line, rptfile );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-04-07 11:55:18 +00:00
|
|
|
static const char* shape_name[6] = { "???", "Circ", "Rect", "Oval", "Trap", "Spec" };
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2012-04-17 01:35:43 +00:00
|
|
|
sprintf( line, "Shape %s\n", shape_name[pad->GetShape()] );
|
|
|
|
fputs( line, rptfile );
|
|
|
|
|
|
|
|
int layer = 0;
|
|
|
|
|
|
|
|
if( pad->GetLayerMask() & LAYER_BACK )
|
|
|
|
layer = 1;
|
|
|
|
|
|
|
|
if( pad->GetLayerMask() & LAYER_FRONT )
|
|
|
|
layer |= 2;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2013-04-07 11:55:18 +00:00
|
|
|
static const char* layer_name[4] = { "none", "back", "front", "both" };
|
2012-04-17 01:35:43 +00:00
|
|
|
|
|
|
|
sprintf( line, "Layer %s\n", layer_name[layer] );
|
|
|
|
fputs( line, rptfile );
|
|
|
|
fprintf( rptfile, "$EndPAD\n" );
|
|
|
|
}
|
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
fprintf( rptfile, "$EndMODULE %s\n\n", TO_UTF8 (Module->GetReference() ) );
|
2012-04-17 01:35:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( IO_ERROR ioe )
|
|
|
|
{
|
|
|
|
DisplayError( NULL, ioe.errorText );
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
|
2012-02-11 18:54:36 +00:00
|
|
|
// Write board Edges
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* PtStruct;
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
for( PtStruct = GetBoard()->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
if( PtStruct->Type() != PCB_LINE_T )
|
2007-08-23 04:28:46 +00:00
|
|
|
continue;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
if( ( (DRAWSEGMENT*) PtStruct )->GetLayer() != EDGE_N )
|
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
WriteDrawSegmentPcb( (DRAWSEGMENT*) PtStruct, rptfile, conv_unit );
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
|
2012-02-11 18:54:36 +00:00
|
|
|
// Generate EOF.
|
2007-08-23 04:28:46 +00:00
|
|
|
fputs( "$EndDESCRIPTION\n", rptfile );
|
|
|
|
fclose( rptfile );
|
2011-02-27 23:25:07 +00:00
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
return true;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Output to rpt file a segment type from the PCB drawing.
|
|
|
|
* The contours are of different types:
|
|
|
|
* Segment
|
|
|
|
* Circle
|
|
|
|
* Arc
|
2007-08-23 04:28:46 +00:00
|
|
|
*/
|
2012-02-15 10:41:16 +00:00
|
|
|
void WriteDrawSegmentPcb( DRAWSEGMENT* PtDrawSegment, FILE* rptfile, double aConvUnit )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
double ux0, uy0, dx, dy;
|
2011-09-07 19:41:04 +00:00
|
|
|
double radius, width;
|
2008-10-01 16:00:35 +00:00
|
|
|
char line[1024];
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
ux0 = PtDrawSegment->GetStart().x * aConvUnit;
|
|
|
|
uy0 = PtDrawSegment->GetStart().y * aConvUnit;
|
2008-10-01 16:00:35 +00:00
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
dx = PtDrawSegment->GetEnd().x * aConvUnit;
|
|
|
|
dy = PtDrawSegment->GetEnd().y * aConvUnit;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2012-02-15 10:41:16 +00:00
|
|
|
width = PtDrawSegment->GetWidth() * aConvUnit;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
switch( PtDrawSegment->GetShape() )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
|
|
|
case S_CIRCLE:
|
2013-05-01 17:32:36 +00:00
|
|
|
radius = Distance( ux0, uy0, dx, dy );
|
2009-01-18 15:51:06 +00:00
|
|
|
fprintf( rptfile, "$CIRCLE \n" );
|
|
|
|
fprintf( rptfile, "centre %.6lf %.6lf\n", ux0, uy0 );
|
2011-09-07 19:41:04 +00:00
|
|
|
fprintf( rptfile, "radius %.6lf\n", radius );
|
2009-01-18 15:51:06 +00:00
|
|
|
fprintf( rptfile, "width %.6lf\n", width );
|
|
|
|
fprintf( rptfile, "$EndCIRCLE \n" );
|
2007-08-23 04:28:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_ARC:
|
2008-10-01 16:00:35 +00:00
|
|
|
{
|
2011-12-14 04:29:25 +00:00
|
|
|
int endx = PtDrawSegment->GetEnd().x;
|
|
|
|
int endy = PtDrawSegment->GetEnd().y;
|
|
|
|
|
2013-05-01 17:32:36 +00:00
|
|
|
radius = Distance( ux0, uy0, dx, dy );
|
2008-10-01 16:00:35 +00:00
|
|
|
RotatePoint( &endx,
|
|
|
|
&endy,
|
2011-12-14 04:29:25 +00:00
|
|
|
PtDrawSegment->GetStart().x,
|
|
|
|
PtDrawSegment->GetStart().y,
|
|
|
|
PtDrawSegment->GetAngle() );
|
2008-10-01 16:00:35 +00:00
|
|
|
|
2009-01-18 15:51:06 +00:00
|
|
|
fprintf( rptfile, "$ARC \n" );
|
|
|
|
fprintf( rptfile, "centre %.6lf %.6lf\n", ux0, uy0 );
|
2009-11-14 22:15:22 +00:00
|
|
|
fprintf( rptfile, "start %.6lf %.6lf\n",
|
2012-02-15 10:41:16 +00:00
|
|
|
endx * aConvUnit, endy * aConvUnit );
|
2009-01-18 15:51:06 +00:00
|
|
|
fprintf( rptfile, "end %.6lf %.6lf\n", dx, dy );
|
|
|
|
fprintf( rptfile, "width %.6lf\n", width );
|
|
|
|
fprintf( rptfile, "$EndARC \n" );
|
2008-10-01 16:00:35 +00:00
|
|
|
}
|
2007-08-23 04:28:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2008-10-01 16:00:35 +00:00
|
|
|
sprintf( line, "$LINE \n" );
|
|
|
|
fputs( line, rptfile );
|
|
|
|
|
2009-01-18 15:51:06 +00:00
|
|
|
fprintf( rptfile, "start %.6lf %.6lf\n", ux0, uy0 );
|
|
|
|
fprintf( rptfile, "end %.6lf %.6lf\n", dx, dy );
|
|
|
|
fprintf( rptfile, "width %.6lf\n", width );
|
|
|
|
fprintf( rptfile, "$EndLINE \n" );
|
2007-08-23 04:28:46 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|