2007-06-05 12:10:51 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2008-02-29 15:31:32 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// Name: dialog_build_BOM.cpp
|
2008-02-29 15:31:32 +00:00
|
|
|
// Purpose:
|
2007-06-05 12:10:51 +00:00
|
|
|
// Author: jean-pierre Charras
|
2008-02-29 15:31:32 +00:00
|
|
|
// Modified by:
|
2007-06-05 12:10:51 +00:00
|
|
|
// Created: 01/15/06 18:18:44
|
2008-02-29 15:31:32 +00:00
|
|
|
// RCS-ID:
|
2007-06-05 12:10:51 +00:00
|
|
|
// Copyright: GNU license
|
2008-02-29 15:31:32 +00:00
|
|
|
// Licence:
|
2007-06-05 12:10:51 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Generated by DialogBlocks (unregistered), 01/15/06 18:18:44
|
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
#if defined (__GNUG__) && !defined (__APPLE__)
|
2007-06-05 12:10:51 +00:00
|
|
|
#pragma implementation "dialog_build_BOM.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// For compilers that support precompilation, includes "wx/wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/wx.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
|
|
|
|
////@begin includes
|
|
|
|
////@end includes
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "netlist.h"
|
|
|
|
|
|
|
|
#include "dialog_build_BOM.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
////@begin XPM images
|
|
|
|
////@end XPM images
|
|
|
|
|
|
|
|
|
|
|
|
/* fonctions locales */
|
2008-02-29 15:31:32 +00:00
|
|
|
static int GenListeGLabels( ListLabel* List );
|
|
|
|
int GenListeCmp( ListComponent* List );
|
|
|
|
static int ListTriComposantByRef( ListComponent* Objet1,
|
|
|
|
ListComponent* Objet2 );
|
|
|
|
static int ListTriComposantByVal( ListComponent* Objet1,
|
|
|
|
ListComponent* Objet2 );
|
|
|
|
static int ListTriGLabelBySheet( ListLabel* Objet1, ListLabel* Objet2 );
|
|
|
|
static int ListTriGLabelByVal( ListLabel* Objet1, ListLabel* Objet2 );
|
|
|
|
static void DeleteSubCmp( ListComponent* List, int NbItems );
|
|
|
|
|
|
|
|
static int PrintListeGLabel( FILE* f, ListLabel* List, int NbItems );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/* Local variables */
|
2008-02-29 15:31:32 +00:00
|
|
|
static bool s_ListByRef = TRUE;
|
|
|
|
static bool s_ListByValue = TRUE;
|
|
|
|
static bool s_ListWithSubCmponents;
|
|
|
|
static bool s_ListHierarchicalPinByName;
|
|
|
|
static bool s_ListBySheet;
|
|
|
|
static bool s_BrowsList;
|
|
|
|
static int s_OutputFormOpt;
|
|
|
|
static int s_OutputSeparatorOpt;
|
|
|
|
static bool s_Add_FpField_state;
|
|
|
|
static bool s_Add_F1_state;
|
|
|
|
static bool s_Add_F2_state;
|
|
|
|
static bool s_Add_F3_state;
|
|
|
|
static bool s_Add_F4_state;
|
|
|
|
static bool s_Add_F5_state;
|
|
|
|
static bool s_Add_F6_state;
|
|
|
|
static bool s_Add_F7_state;
|
|
|
|
static bool s_Add_F8_state;
|
|
|
|
static bool* s_AddFieldList[] = {
|
|
|
|
&s_Add_FpField_state,
|
|
|
|
&s_Add_F1_state,
|
|
|
|
&s_Add_F2_state,
|
|
|
|
&s_Add_F3_state,
|
|
|
|
&s_Add_F4_state,
|
|
|
|
&s_Add_F5_state,
|
|
|
|
&s_Add_F6_state,
|
|
|
|
&s_Add_F7_state,
|
|
|
|
&s_Add_F8_state,
|
|
|
|
NULL
|
2007-07-02 12:48:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
#define OPTION_BOM_FORMAT wxT( "BomFormat" )
|
|
|
|
#define OPTION_BOM_SEPARATOR wxT( "BomExportSeparator" )
|
|
|
|
#define OPTION_BOM_ADD_FIELD wxT( "BomAddField" )
|
2007-07-02 12:48:10 +00:00
|
|
|
|
|
|
|
/* list of separators used in bom export to spreadsheet
|
2007-10-13 05:56:37 +00:00
|
|
|
* (selected by s_OutputSeparatorOpt, and s_OutputSeparatorOpt radiobox)
|
|
|
|
*/
|
2007-07-02 12:48:10 +00:00
|
|
|
static char s_ExportSeparator[] = ("\t;,.");
|
|
|
|
static char s_ExportSeparatorSymbol;
|
2008-02-29 15:31:32 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*!
|
|
|
|
* WinEDA_Build_BOM_Frame type definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS( WinEDA_Build_BOM_Frame, wxDialog )
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* WinEDA_Build_BOM_Frame event table definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE( WinEDA_Build_BOM_Frame, wxDialog )
|
|
|
|
|
|
|
|
////@begin WinEDA_Build_BOM_Frame event table entries
|
2008-02-29 15:31:32 +00:00
|
|
|
EVT_RADIOBOX( ID_RADIOBOX_SELECT_FORMAT, WinEDA_Build_BOM_Frame::OnRadioboxSelectFormatSelected )
|
2007-07-02 12:48:10 +00:00
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
EVT_BUTTON( ID_CREATE_LIST, WinEDA_Build_BOM_Frame::OnCreateListClick )
|
2007-10-13 05:56:37 +00:00
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
EVT_BUTTON( wxID_OK, WinEDA_Build_BOM_Frame::OnOkClick )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
EVT_BUTTON( wxID_CANCEL, WinEDA_Build_BOM_Frame::OnCancelClick )
|
2007-10-13 05:56:37 +00:00
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
EVT_BUTTON( wxID_APPLY, WinEDA_Build_BOM_Frame::OnApplyClick )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
////@end WinEDA_Build_BOM_Frame event table entries
|
|
|
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* WinEDA_Build_BOM_Frame constructors
|
|
|
|
*/
|
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
WinEDA_Build_BOM_Frame::WinEDA_Build_BOM_Frame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
WinEDA_Build_BOM_Frame::WinEDA_Build_BOM_Frame( WinEDA_DrawFrame* parent,
|
2008-02-29 15:31:32 +00:00
|
|
|
wxWindowID id,
|
|
|
|
const wxString& caption,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-29 15:31:32 +00:00
|
|
|
m_Parent = parent;
|
|
|
|
|
|
|
|
/* Get options */
|
|
|
|
s_OutputFormOpt = m_Parent->m_Parent->m_EDA_Config->Read( OPTION_BOM_FORMAT, (long) 0 );
|
|
|
|
s_OutputSeparatorOpt = m_Parent->m_Parent->m_EDA_Config->Read( OPTION_BOM_SEPARATOR, (long) 0 );
|
|
|
|
long addfields = m_Parent->m_Parent->m_EDA_Config->Read( OPTION_BOM_ADD_FIELD, (long) 0 );
|
|
|
|
for( int ii = 0, bitmask = 1; s_AddFieldList[ii] != NULL; ii++ )
|
|
|
|
{
|
|
|
|
if( (addfields & bitmask) )
|
|
|
|
*s_AddFieldList[ii] = true;
|
|
|
|
else
|
|
|
|
*s_AddFieldList[ii] = false;
|
|
|
|
|
|
|
|
bitmask <<= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
Create( parent, id, caption, pos, size, style );
|
|
|
|
|
|
|
|
m_OutputFormCtrl->SetSelection( s_OutputFormOpt );
|
|
|
|
m_OutputSeparatorCtrl->SetSelection( s_OutputSeparatorOpt );
|
|
|
|
if( s_OutputFormOpt == 1 )
|
|
|
|
m_OutputSeparatorCtrl->Enable( true );
|
|
|
|
else
|
|
|
|
m_OutputSeparatorCtrl->Enable( false );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*!
|
|
|
|
* WinEDA_Build_BOM_Frame creator
|
|
|
|
*/
|
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
bool WinEDA_Build_BOM_Frame::Create( wxWindow* parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxString& caption,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
////@begin WinEDA_Build_BOM_Frame member initialisation
|
2008-02-29 15:31:32 +00:00
|
|
|
m_ListCmpbyRefItems = NULL;
|
|
|
|
m_ListSubCmpItems = NULL;
|
|
|
|
m_ListCmpbyValItems = NULL;
|
|
|
|
m_GenListLabelsbyVal = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
m_GenListLabelsbySheet = NULL;
|
2008-02-29 15:31:32 +00:00
|
|
|
m_OutputFormCtrl = NULL;
|
2007-07-02 12:48:10 +00:00
|
|
|
m_OutputSeparatorCtrl = NULL;
|
|
|
|
m_GetListBrowser = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
m_FieldsToAppendListSizer = NULL;
|
2007-10-30 20:40:08 +00:00
|
|
|
m_AddFootprintField = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
m_AddField1 = NULL;
|
|
|
|
m_AddField2 = NULL;
|
|
|
|
m_AddField3 = NULL;
|
|
|
|
m_AddField4 = NULL;
|
|
|
|
m_AddField5 = NULL;
|
|
|
|
m_AddField6 = NULL;
|
|
|
|
m_AddField7 = NULL;
|
|
|
|
m_AddField8 = NULL;
|
2008-02-29 15:31:32 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
////@end WinEDA_Build_BOM_Frame member initialisation
|
|
|
|
|
|
|
|
////@begin WinEDA_Build_BOM_Frame creation
|
2008-02-29 15:31:32 +00:00
|
|
|
SetExtraStyle( wxWS_EX_BLOCK_EVENTS );
|
2007-06-05 12:10:51 +00:00
|
|
|
wxDialog::Create( parent, id, caption, pos, size, style );
|
|
|
|
|
|
|
|
CreateControls();
|
2008-02-29 15:31:32 +00:00
|
|
|
if( GetSizer() )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-29 15:31:32 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
Centre();
|
2008-02-29 15:31:32 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
////@end WinEDA_Build_BOM_Frame creation
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*!
|
|
|
|
* Control creation for WinEDA_Build_BOM_Frame
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_Build_BOM_Frame::CreateControls()
|
2008-02-29 15:31:32 +00:00
|
|
|
{
|
|
|
|
SetFont( *g_DialogFont );
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
////@begin WinEDA_Build_BOM_Frame content construction
|
2007-11-06 07:14:31 +00:00
|
|
|
// Generated by DialogBlocks, Вск 04 Ноя 2007 18:43:07 (unregistered)
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
WinEDA_Build_BOM_Frame* itemDialog1 = this;
|
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer( wxVERTICAL );
|
|
|
|
itemDialog1->SetSizer( itemBoxSizer2 );
|
|
|
|
|
|
|
|
wxBoxSizer* itemBoxSizer3 = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
itemBoxSizer2->Add( itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT, 5 );
|
|
|
|
|
|
|
|
wxBoxSizer* itemBoxSizer4 = new wxBoxSizer( wxVERTICAL );
|
|
|
|
itemBoxSizer3->Add( itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM, 5 );
|
|
|
|
|
|
|
|
wxStaticBox* itemStaticBoxSizer5Static = new wxStaticBox( itemDialog1, wxID_ANY,
|
|
|
|
_( "List items:" ) );
|
|
|
|
wxStaticBoxSizer* itemStaticBoxSizer5 = new wxStaticBoxSizer( itemStaticBoxSizer5Static,
|
|
|
|
wxVERTICAL );
|
|
|
|
itemBoxSizer4->Add( itemStaticBoxSizer5, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
m_ListCmpbyRefItems = new wxCheckBox( itemDialog1, ID_CHECKBOX1, _(
|
|
|
|
"Components by Reference" ), wxDefaultPosition,
|
|
|
|
wxDefaultSize, wxCHK_2STATE );
|
|
|
|
m_ListCmpbyRefItems->SetValue( true );
|
|
|
|
itemStaticBoxSizer5->Add( m_ListCmpbyRefItems, 0, wxALIGN_LEFT | wxALL, 5 );
|
|
|
|
|
|
|
|
m_ListSubCmpItems = new wxCheckBox( itemDialog1, ID_CHECKBOX2,
|
|
|
|
_(
|
|
|
|
"Sub Components (i.e. U2A, U2B ...)" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
|
|
|
|
m_ListSubCmpItems->SetValue( false );
|
|
|
|
itemStaticBoxSizer5->Add( m_ListSubCmpItems, 0, wxALIGN_LEFT | wxALL, 5 );
|
|
|
|
|
|
|
|
m_ListCmpbyValItems = new wxCheckBox( itemDialog1, ID_CHECKBOX3, _(
|
|
|
|
"Components by Value" ), wxDefaultPosition,
|
|
|
|
wxDefaultSize, wxCHK_2STATE );
|
|
|
|
m_ListCmpbyValItems->SetValue( true );
|
|
|
|
itemStaticBoxSizer5->Add( m_ListCmpbyValItems, 0, wxALIGN_LEFT | wxALL, 5 );
|
|
|
|
|
|
|
|
m_GenListLabelsbyVal = new wxCheckBox( itemDialog1, ID_CHECKBOX4, _(
|
|
|
|
"Hierachy Pins by Name" ), wxDefaultPosition,
|
|
|
|
wxDefaultSize, wxCHK_2STATE );
|
|
|
|
m_GenListLabelsbyVal->SetValue( false );
|
|
|
|
itemStaticBoxSizer5->Add( m_GenListLabelsbyVal, 0, wxALIGN_LEFT | wxALL, 5 );
|
|
|
|
|
|
|
|
m_GenListLabelsbySheet = new wxCheckBox( itemDialog1, ID_CHECKBOX5,
|
|
|
|
_(
|
|
|
|
"Hierachy Pins by Sheets" ), wxDefaultPosition,
|
|
|
|
wxDefaultSize, wxCHK_2STATE );
|
|
|
|
m_GenListLabelsbySheet->SetValue( false );
|
|
|
|
itemStaticBoxSizer5->Add( m_GenListLabelsbySheet, 0, wxALIGN_LEFT | wxALL, 5 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
wxArrayString m_OutputFormCtrlStrings;
|
2008-02-29 15:31:32 +00:00
|
|
|
m_OutputFormCtrlStrings.Add( _( "List" ) );
|
|
|
|
m_OutputFormCtrlStrings.Add( _( "Text for spreadsheet import" ) );
|
|
|
|
m_OutputFormCtrl = new wxRadioBox( itemDialog1, ID_RADIOBOX_SELECT_FORMAT, _(
|
|
|
|
"Output format:" ), wxDefaultPosition, wxDefaultSize,
|
|
|
|
m_OutputFormCtrlStrings, 1,
|
|
|
|
wxRA_SPECIFY_COLS );
|
|
|
|
m_OutputFormCtrl->SetSelection( 0 );
|
|
|
|
itemBoxSizer4->Add( m_OutputFormCtrl, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
|
2007-07-02 12:48:10 +00:00
|
|
|
|
|
|
|
wxArrayString m_OutputSeparatorCtrlStrings;
|
2008-02-29 15:31:32 +00:00
|
|
|
m_OutputSeparatorCtrlStrings.Add( _( "Tab" ) );
|
|
|
|
m_OutputSeparatorCtrlStrings.Add( _( ";" ) );
|
|
|
|
m_OutputSeparatorCtrlStrings.Add( _( "," ) );
|
|
|
|
m_OutputSeparatorCtrl = new wxRadioBox( itemDialog1, ID_RADIOBOX_SEPARATOR,
|
|
|
|
_(
|
|
|
|
"Field separator for spreadsheet import:" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
m_OutputSeparatorCtrlStrings, 1, wxRA_SPECIFY_ROWS );
|
|
|
|
m_OutputSeparatorCtrl->SetSelection( 0 );
|
|
|
|
itemBoxSizer4->Add( m_OutputSeparatorCtrl, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
|
|
|
|
|
|
|
|
wxStaticBox* itemStaticBoxSizer13Static = new wxStaticBox( itemDialog1, wxID_ANY,
|
|
|
|
_( "Options:" ) );
|
|
|
|
wxStaticBoxSizer* itemStaticBoxSizer13 = new wxStaticBoxSizer( itemStaticBoxSizer13Static,
|
|
|
|
wxHORIZONTAL );
|
|
|
|
itemBoxSizer4->Add( itemStaticBoxSizer13, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
m_GetListBrowser = new wxCheckBox( itemDialog1, ID_CHECKBOX6, _(
|
|
|
|
"Launch list browser" ), wxDefaultPosition,
|
|
|
|
wxDefaultSize, wxCHK_2STATE );
|
|
|
|
m_GetListBrowser->SetValue( false );
|
|
|
|
itemStaticBoxSizer13->Add( m_GetListBrowser, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
|
|
|
|
|
|
|
wxBoxSizer* itemBoxSizer15 = new wxBoxSizer( wxVERTICAL );
|
|
|
|
itemBoxSizer3->Add( itemBoxSizer15, 0, wxALIGN_TOP | wxLEFT | wxTOP | wxBOTTOM, 5 );
|
|
|
|
|
|
|
|
wxStaticBox* itemStaticBoxSizer16Static = new wxStaticBox( itemDialog1, wxID_ANY,
|
|
|
|
_( "Fields to add:" ) );
|
|
|
|
m_FieldsToAppendListSizer = new wxStaticBoxSizer( itemStaticBoxSizer16Static, wxVERTICAL );
|
|
|
|
itemBoxSizer15->Add( m_FieldsToAppendListSizer, 0, wxALIGN_LEFT | wxALL, 5 );
|
|
|
|
|
|
|
|
m_AddFootprintField = new wxCheckBox( itemDialog1, ID_CHECKBOX_FOOTPRINT_FIELD, _(
|
|
|
|
"Footprint" ), wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxCHK_2STATE );
|
|
|
|
m_AddFootprintField->SetValue( false );
|
|
|
|
m_FieldsToAppendListSizer->Add( m_AddFootprintField, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
m_AddField1 = new wxCheckBox( itemDialog1, ID_CHECKBOX_FIELD1, _(
|
|
|
|
"Field 1" ), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
|
|
|
|
m_AddField1->SetValue( false );
|
|
|
|
m_FieldsToAppendListSizer->Add( m_AddField1, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
m_AddField2 = new wxCheckBox( itemDialog1, ID_CHECKBOX_FIELD2, _(
|
|
|
|
"Field 2" ), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
|
|
|
|
m_AddField2->SetValue( false );
|
|
|
|
m_FieldsToAppendListSizer->Add( m_AddField2, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
m_AddField3 = new wxCheckBox( itemDialog1, ID_CHECKBOX_FIELD3, _(
|
|
|
|
"Field 3" ), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
|
|
|
|
m_AddField3->SetValue( false );
|
|
|
|
m_FieldsToAppendListSizer->Add( m_AddField3, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
m_AddField4 = new wxCheckBox( itemDialog1, ID_CHECKBOX_FIELD4, _(
|
|
|
|
"Field 4" ), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
|
|
|
|
m_AddField4->SetValue( false );
|
|
|
|
m_FieldsToAppendListSizer->Add( m_AddField4, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
m_AddField5 = new wxCheckBox( itemDialog1, ID_CHECKBOX_FIELD5, _(
|
|
|
|
"Field 5" ), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
|
|
|
|
m_AddField5->SetValue( false );
|
|
|
|
m_FieldsToAppendListSizer->Add( m_AddField5, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
m_AddField6 = new wxCheckBox( itemDialog1, ID_CHECKBOX_FIELD6, _(
|
|
|
|
"Field 6" ), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
|
|
|
|
m_AddField6->SetValue( false );
|
|
|
|
m_FieldsToAppendListSizer->Add( m_AddField6, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
m_AddField7 = new wxCheckBox( itemDialog1, ID_CHECKBOX_FIELD7, _(
|
|
|
|
"Field 7" ), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
|
|
|
|
m_AddField7->SetValue( false );
|
|
|
|
m_FieldsToAppendListSizer->Add( m_AddField7, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
m_AddField8 = new wxCheckBox( itemDialog1, ID_CHECKBOX_FIELD8, _(
|
|
|
|
"Field 8" ), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
|
|
|
|
m_AddField8->SetValue( false );
|
|
|
|
m_FieldsToAppendListSizer->Add( m_AddField8, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
itemBoxSizer15->Add( 5, 5, 0, wxGROW | wxALL, 10 );
|
|
|
|
|
|
|
|
wxButton* itemButton27 = new wxButton( itemDialog1, ID_CREATE_LIST, _(
|
|
|
|
"Create &List" ), wxDefaultPosition, wxDefaultSize,
|
|
|
|
0 );
|
2007-10-30 20:40:08 +00:00
|
|
|
itemButton27->SetDefault();
|
2008-02-29 15:31:32 +00:00
|
|
|
itemButton27->SetForegroundColour( wxColour( 166, 0, 0 ) );
|
|
|
|
itemBoxSizer15->Add( itemButton27, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
wxBoxSizer* itemBoxSizer28 = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
itemBoxSizer2->Add( itemBoxSizer28,
|
|
|
|
0,
|
|
|
|
wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxBOTTOM,
|
|
|
|
5 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
wxButton* itemButton29 = new wxButton( itemDialog1, wxID_OK, _(
|
|
|
|
"&OK" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
itemButton29->SetForegroundColour( wxColour( 255, 0, 0 ) );
|
|
|
|
itemBoxSizer28->Add( itemButton29, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
wxButton* itemButton30 = new wxButton( itemDialog1, wxID_CANCEL, _(
|
|
|
|
"&Cancel" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
itemButton30->SetForegroundColour( wxColour( 0, 0, 255 ) );
|
|
|
|
itemBoxSizer28->Add( itemButton30, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
2007-10-13 05:56:37 +00:00
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
wxButton* itemButton31 = new wxButton( itemDialog1, wxID_APPLY, _(
|
|
|
|
"&Apply" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
itemBoxSizer28->Add( itemButton31, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
// Set validators
|
2008-02-29 15:31:32 +00:00
|
|
|
m_ListCmpbyRefItems->SetValidator( wxGenericValidator( &s_ListByRef ) );
|
|
|
|
m_ListSubCmpItems->SetValidator( wxGenericValidator( &s_ListWithSubCmponents ) );
|
|
|
|
m_ListCmpbyValItems->SetValidator( wxGenericValidator( &s_ListByValue ) );
|
|
|
|
m_GenListLabelsbyVal->SetValidator( wxGenericValidator( &s_ListHierarchicalPinByName ) );
|
|
|
|
m_GenListLabelsbySheet->SetValidator( wxGenericValidator( &s_ListBySheet ) );
|
|
|
|
m_OutputFormCtrl->SetValidator( wxGenericValidator( &s_OutputFormOpt ) );
|
|
|
|
m_OutputSeparatorCtrl->SetValidator( wxGenericValidator( &s_OutputSeparatorOpt ) );
|
|
|
|
m_GetListBrowser->SetValidator( wxGenericValidator( &s_BrowsList ) );
|
|
|
|
m_AddFootprintField->SetValidator( wxGenericValidator( &s_Add_FpField_state ) );
|
|
|
|
m_AddField1->SetValidator( wxGenericValidator( &s_Add_F1_state ) );
|
|
|
|
m_AddField2->SetValidator( wxGenericValidator( &s_Add_F2_state ) );
|
|
|
|
m_AddField3->SetValidator( wxGenericValidator( &s_Add_F3_state ) );
|
|
|
|
m_AddField4->SetValidator( wxGenericValidator( &s_Add_F4_state ) );
|
|
|
|
m_AddField5->SetValidator( wxGenericValidator( &s_Add_F5_state ) );
|
|
|
|
m_AddField6->SetValidator( wxGenericValidator( &s_Add_F6_state ) );
|
|
|
|
m_AddField7->SetValidator( wxGenericValidator( &s_Add_F7_state ) );
|
|
|
|
m_AddField8->SetValidator( wxGenericValidator( &s_Add_F8_state ) );
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
////@end WinEDA_Build_BOM_Frame content construction
|
|
|
|
}
|
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*!
|
|
|
|
* Should we show tooltips?
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool WinEDA_Build_BOM_Frame::ShowToolTips()
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*!
|
|
|
|
* Get bitmap resources
|
|
|
|
*/
|
|
|
|
|
|
|
|
wxBitmap WinEDA_Build_BOM_Frame::GetBitmapResource( const wxString& name )
|
|
|
|
{
|
|
|
|
// Bitmap retrieval
|
|
|
|
////@begin WinEDA_Build_BOM_Frame bitmap retrieval
|
2008-02-29 15:31:32 +00:00
|
|
|
wxUnusedVar( name );
|
2007-06-05 12:10:51 +00:00
|
|
|
return wxNullBitmap;
|
2008-02-29 15:31:32 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
////@end WinEDA_Build_BOM_Frame bitmap retrieval
|
|
|
|
}
|
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*!
|
|
|
|
* Get icon resources
|
|
|
|
*/
|
|
|
|
|
|
|
|
wxIcon WinEDA_Build_BOM_Frame::GetIconResource( const wxString& name )
|
|
|
|
{
|
|
|
|
// Icon retrieval
|
|
|
|
////@begin WinEDA_Build_BOM_Frame icon retrieval
|
2008-02-29 15:31:32 +00:00
|
|
|
wxUnusedVar( name );
|
2007-06-05 12:10:51 +00:00
|
|
|
return wxNullIcon;
|
2008-02-29 15:31:32 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
////@end WinEDA_Build_BOM_Frame icon retrieval
|
|
|
|
}
|
2007-10-13 05:56:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_RADIOBOX_SELECT_FORMAT
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_Build_BOM_Frame::OnRadioboxSelectFormatSelected( wxCommandEvent& event )
|
|
|
|
{
|
2008-02-29 15:31:32 +00:00
|
|
|
if( m_OutputFormCtrl->GetSelection() == 1 )
|
|
|
|
m_OutputSeparatorCtrl->Enable( true );
|
|
|
|
else
|
|
|
|
m_OutputSeparatorCtrl->Enable( false );
|
2007-10-13 05:56:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_CREATE_LIST
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_Build_BOM_Frame::OnCreateListClick( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
GenList();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_Build_BOM_Frame::OnOkClick( wxCommandEvent& event )
|
|
|
|
{
|
2007-10-13 05:56:37 +00:00
|
|
|
SavePreferences();
|
|
|
|
EndModal( 0 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2007-10-13 05:56:37 +00:00
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
|
2007-06-05 12:10:51 +00:00
|
|
|
*/
|
|
|
|
|
2007-10-13 05:56:37 +00:00
|
|
|
void WinEDA_Build_BOM_Frame::OnCancelClick( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-10-13 05:56:37 +00:00
|
|
|
EndModal( -1 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-10-13 05:56:37 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_APPLY
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_Build_BOM_Frame::OnApplyClick( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-10-13 05:56:37 +00:00
|
|
|
SavePreferences();
|
|
|
|
}
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-13 05:56:37 +00:00
|
|
|
/**************************************************/
|
|
|
|
void WinEDA_Build_BOM_Frame::SavePreferences()
|
|
|
|
/**************************************************/
|
|
|
|
{
|
2008-02-29 15:31:32 +00:00
|
|
|
// Determine current settings of "List items" and "Options" checkboxes
|
|
|
|
// (NOTE: These 6 settings are restored when the dialog box is next
|
|
|
|
// invoked, but are *not* still saved after EESchema is next shut down.)
|
|
|
|
s_ListByRef = m_ListCmpbyRefItems->GetValue();
|
|
|
|
s_ListWithSubCmponents = m_ListSubCmpItems->GetValue();
|
|
|
|
s_ListByValue = m_ListCmpbyValItems->GetValue();
|
|
|
|
s_ListHierarchicalPinByName = m_GenListLabelsbyVal->GetValue();
|
|
|
|
s_ListBySheet = m_GenListLabelsbySheet->GetValue();
|
|
|
|
s_BrowsList = m_GetListBrowser->GetValue();
|
|
|
|
|
|
|
|
// Determine current settings of both radiobutton groups
|
|
|
|
s_OutputFormOpt = m_OutputFormCtrl->GetSelection();
|
|
|
|
s_OutputSeparatorOpt = m_OutputSeparatorCtrl->GetSelection();
|
|
|
|
if( s_OutputSeparatorOpt < 0 )
|
|
|
|
s_OutputSeparatorOpt = 0;
|
|
|
|
|
|
|
|
// Determine current settings of all 8 "Fields to add" checkboxes
|
|
|
|
s_Add_F1_state = m_AddField1->GetValue();
|
|
|
|
s_Add_F2_state = m_AddField2->GetValue();
|
|
|
|
s_Add_F3_state = m_AddField3->GetValue();
|
|
|
|
s_Add_F4_state = m_AddField4->GetValue();
|
|
|
|
s_Add_F5_state = m_AddField5->GetValue();
|
|
|
|
s_Add_F6_state = m_AddField6->GetValue();
|
|
|
|
s_Add_F7_state = m_AddField7->GetValue();
|
|
|
|
s_Add_F8_state = m_AddField8->GetValue();
|
|
|
|
|
|
|
|
// Now save current settings of both radiobutton groups
|
|
|
|
m_Parent->m_Parent->m_EDA_Config->Write( OPTION_BOM_FORMAT, (long) s_OutputFormOpt );
|
|
|
|
m_Parent->m_Parent->m_EDA_Config->Write( OPTION_BOM_SEPARATOR, (long) s_OutputSeparatorOpt );
|
|
|
|
|
|
|
|
// Now save current settings of all 8 "Fields to add" checkboxes
|
|
|
|
long addfields = 0;
|
|
|
|
for( int ii = 0, bitmask = 1; s_AddFieldList[ii] != NULL; ii++ )
|
|
|
|
{
|
|
|
|
if( *s_AddFieldList[ii] )
|
|
|
|
addfields |= bitmask;
|
|
|
|
bitmask <<= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Parent->m_Parent->m_EDA_Config->Write( OPTION_BOM_ADD_FIELD, addfields );
|
2007-10-13 05:56:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
void WinEDA_Build_BOM_Frame::GenList()
|
|
|
|
/**********************************************************/
|
|
|
|
{
|
2008-02-29 15:31:32 +00:00
|
|
|
#define EXT_LIST wxT( ".lst" )
|
|
|
|
wxString mask, filename;
|
|
|
|
|
|
|
|
// Although the currently selected options determine the contents
|
|
|
|
// and format of the subsequently generated file, they are still
|
|
|
|
// *not* "restored" if the dialog box is ever subsequently invoked
|
|
|
|
// again (unless those options had been specifically "saved" before
|
|
|
|
// now (by clicking on either of the "OK" or "Apply" buttons)).
|
|
|
|
//
|
|
|
|
// Hence the following previously provided commands are now
|
|
|
|
// commented out, and the currently selected options are now
|
|
|
|
// read "directly" by the relevant functions instead. (The previous
|
|
|
|
// behavior of the dialog box in this regard had been inconsistent,
|
|
|
|
// in that the settings of the "Fields to add" checkboxes were *not*
|
|
|
|
// "restored", whereas all of the other settings *were* "restored";
|
|
|
|
// now, *none* of those settings are subsequently "restored".)
|
2007-10-13 05:56:37 +00:00
|
|
|
|
|
|
|
// s_ListByRef = m_ListCmpbyRefItems->GetValue();
|
|
|
|
// s_ListWithSubCmponents = m_ListSubCmpItems->GetValue();
|
|
|
|
// s_ListByValue = m_ListCmpbyValItems->GetValue();
|
|
|
|
// s_ListHierarchicalPinByName = m_GenListLabelsbyVal->GetValue();
|
|
|
|
// s_ListBySheet = m_GenListLabelsbySheet->GetValue();
|
|
|
|
// s_BrowsList = m_GetListBrowser->GetValue();
|
|
|
|
// s_OutputFormOpt = m_OutputFormCtrl->GetSelection();
|
|
|
|
|
|
|
|
// s_OutputSeparatorOpt = m_OutputSeparatorCtrl->GetSelection();
|
|
|
|
// if( s_OutputSeparatorOpt < 0 )
|
|
|
|
// s_OutputSeparatorOpt = 0;
|
|
|
|
// s_ExportSeparatorSymbol = s_ExportSeparator[s_OutputSeparatorOpt];
|
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
// Updated code for determining the value of s_ExportSeparatorSymbol
|
|
|
|
if( m_OutputSeparatorCtrl->GetSelection() > 0 )
|
|
|
|
s_ExportSeparatorSymbol
|
|
|
|
= s_ExportSeparator[m_OutputSeparatorCtrl->GetSelection()];
|
|
|
|
else
|
|
|
|
s_ExportSeparatorSymbol = s_ExportSeparator[0];
|
|
|
|
|
|
|
|
m_ListFileName = g_RootSheet->m_AssociatedScreen->m_FileName;
|
|
|
|
ChangeFileNameExt( m_ListFileName, EXT_LIST );
|
|
|
|
|
|
|
|
//need to get rid of the path.
|
|
|
|
m_ListFileName = m_ListFileName.AfterLast( '/' );
|
|
|
|
mask = wxT( "*" );
|
|
|
|
mask += EXT_LIST;
|
|
|
|
|
|
|
|
filename = EDA_FileSelector( _( "Bill of materials:" ),
|
|
|
|
wxEmptyString, /* Chemin par defaut (ici dir courante) */
|
|
|
|
m_ListFileName, /* nom fichier par defaut, et resultat */
|
|
|
|
EXT_LIST, /* extension par defaut */
|
|
|
|
mask, /* Masque d'affichage */
|
|
|
|
this,
|
|
|
|
wxFD_SAVE,
|
|
|
|
TRUE
|
|
|
|
);
|
|
|
|
if( filename.IsEmpty() )
|
|
|
|
return;
|
|
|
|
else
|
|
|
|
m_ListFileName = filename;
|
|
|
|
|
|
|
|
/* Close dialog, then show the list (if so requested) */
|
|
|
|
|
2007-10-13 05:56:37 +00:00
|
|
|
// if( s_OutputFormOpt == 0 )
|
2008-02-29 15:31:32 +00:00
|
|
|
if( m_OutputFormCtrl->GetSelection() == 0 )
|
|
|
|
GenereListeOfItems( m_ListFileName );
|
|
|
|
else
|
|
|
|
CreateExportList( m_ListFileName );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
EndModal( 1 );
|
2008-02-18 09:39:15 +00:00
|
|
|
|
2007-10-13 05:56:37 +00:00
|
|
|
// if( s_BrowsList )
|
2008-02-29 15:31:32 +00:00
|
|
|
if( m_GetListBrowser->GetValue() )
|
|
|
|
{
|
|
|
|
wxString editorname = GetEditorName();
|
|
|
|
AddDelimiterString( filename );
|
|
|
|
ExecuteFile( this, editorname, filename );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************/
|
2008-02-29 15:31:32 +00:00
|
|
|
void WinEDA_Build_BOM_Frame::CreateExportList( const wxString& FullFileName )
|
2007-06-05 12:10:51 +00:00
|
|
|
/****************************************************************************/
|
2008-02-29 15:31:32 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*
|
2007-10-13 05:56:37 +00:00
|
|
|
* Print a list of components, in a form which can be imported by a spreadsheet
|
|
|
|
* form is:
|
|
|
|
* cmp name; cmp val; fields;
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-29 15:31:32 +00:00
|
|
|
FILE* f;
|
|
|
|
ListComponent* List;
|
|
|
|
int NbItems;
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
/* Creation de la liste des elements */
|
|
|
|
if( ( f = wxFopen( FullFileName, wxT( "wt" ) ) ) == NULL )
|
|
|
|
{
|
|
|
|
msg = _( "Failed to open file " );
|
|
|
|
msg << FullFileName;
|
|
|
|
DisplayError( this, msg );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
NbItems = GenListeCmp( NULL );
|
|
|
|
if( NbItems )
|
|
|
|
{
|
|
|
|
List = (ListComponent*) MyZMalloc( NbItems * sizeof(ListComponent) );
|
|
|
|
if( List == NULL )
|
|
|
|
{
|
|
|
|
fclose( f );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GenListeCmp( List );
|
|
|
|
|
|
|
|
/* sort component list */
|
|
|
|
qsort( List, NbItems, sizeof( ListComponent ),
|
|
|
|
( int( * ) ( const void*, const void* ) )ListTriComposantByRef );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-13 05:56:37 +00:00
|
|
|
// if( ! s_ListWithSubCmponents )
|
2008-02-29 15:31:32 +00:00
|
|
|
if( !m_ListSubCmpItems->GetValue() )
|
|
|
|
DeleteSubCmp( List, NbItems );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
/* create the file */
|
|
|
|
PrintListeCmpByRef( f, List, NbItems, TRUE );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
MyFree( List );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
fclose( f );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************/
|
2008-02-29 15:31:32 +00:00
|
|
|
void WinEDA_Build_BOM_Frame::GenereListeOfItems( const wxString& FullFileName )
|
2007-06-05 12:10:51 +00:00
|
|
|
/****************************************************************************/
|
2008-02-29 15:31:32 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*
|
2007-10-13 05:56:37 +00:00
|
|
|
* Routine principale pour la creation des listings ( composants et/ou labels
|
|
|
|
* globaux et "sheet labels" )
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-29 15:31:32 +00:00
|
|
|
FILE* f;
|
|
|
|
ListComponent* List;
|
|
|
|
ListLabel* ListOfLabels;
|
|
|
|
int NbItems;
|
|
|
|
char Line[1024];
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
/* Creation de la liste des elements */
|
|
|
|
if( ( f = wxFopen( FullFileName, wxT( "wt" ) ) ) == NULL )
|
|
|
|
{
|
|
|
|
msg = _( "Failed to open file " );
|
|
|
|
msg << FullFileName;
|
|
|
|
DisplayError( this, msg );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
NbItems = GenListeCmp( NULL );
|
|
|
|
if( NbItems )
|
|
|
|
{
|
2008-02-29 16:19:56 +00:00
|
|
|
List = (ListComponent*) MyZMalloc( NbItems * sizeof(ListComponent) );
|
|
|
|
if( List == NULL ) // Error memory alloc
|
2008-02-29 15:31:32 +00:00
|
|
|
{
|
|
|
|
fclose( f );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GenListeCmp( List );
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
for( int i = 0; i<NbItems; i++ )
|
|
|
|
{
|
|
|
|
printf( "found component: %s\n", List[i].m_Ref );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* generation du fichier listing */
|
|
|
|
DateAndTime( Line );
|
|
|
|
wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion();
|
|
|
|
fprintf( f, "%s >> Creation date: %s\n", CONV_TO_UTF8( Title ), Line );
|
|
|
|
|
|
|
|
/* Tri et impression de la liste des composants */
|
|
|
|
|
|
|
|
qsort( List, NbItems, sizeof( ListComponent ),
|
|
|
|
( int( * ) ( const void*, const void* ) )ListTriComposantByRef );
|
|
|
|
#if 0
|
|
|
|
printf( "sorted by reference:\n" );
|
|
|
|
for( int i = 0; i<NbItems; i++ )
|
|
|
|
{
|
|
|
|
printf( "found component: %s\n", List[i].m_Ref );
|
|
|
|
}
|
|
|
|
#endif
|
2007-10-13 05:56:37 +00:00
|
|
|
// if( ! s_ListWithSubCmponents )
|
2008-02-29 15:31:32 +00:00
|
|
|
if( !m_ListSubCmpItems->GetValue() )
|
|
|
|
DeleteSubCmp( List, NbItems );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-13 05:56:37 +00:00
|
|
|
// if( s_ListByRef )
|
2008-02-29 15:31:32 +00:00
|
|
|
if( m_ListCmpbyRefItems->GetValue() )
|
|
|
|
{
|
|
|
|
PrintListeCmpByRef( f, List, NbItems );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-13 05:56:37 +00:00
|
|
|
// if( s_ListByValue )
|
2008-02-29 15:31:32 +00:00
|
|
|
if( m_ListCmpbyValItems->GetValue() )
|
|
|
|
{
|
|
|
|
qsort( List, NbItems, sizeof( ListComponent ),
|
|
|
|
( int( * ) ( const void*, const void* ) )ListTriComposantByVal );
|
|
|
|
PrintListeCmpByVal( f, List, NbItems );
|
|
|
|
}
|
|
|
|
MyFree( List );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************/
|
|
|
|
/* Generation liste des Labels globaux */
|
|
|
|
/***************************************/
|
|
|
|
NbItems = GenListeGLabels( NULL );
|
|
|
|
if( NbItems )
|
|
|
|
{
|
|
|
|
ListOfLabels = (ListLabel*) MyZMalloc( NbItems * sizeof(ListLabel) );
|
|
|
|
if( ListOfLabels == NULL )
|
|
|
|
{
|
|
|
|
fclose( f );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GenListeGLabels( ListOfLabels );
|
|
|
|
|
|
|
|
/* Tri de la liste */
|
|
|
|
|
2007-10-13 05:56:37 +00:00
|
|
|
// if( s_ListBySheet )
|
2008-02-29 15:31:32 +00:00
|
|
|
if( m_GenListLabelsbySheet->GetValue() )
|
|
|
|
{
|
|
|
|
qsort( ListOfLabels, NbItems, sizeof( ListLabel ),
|
|
|
|
( int( * ) ( const void*, const void* ) )ListTriGLabelBySheet );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-29 16:19:56 +00:00
|
|
|
msg.Printf( _( "\n#Global, Hierarchical Labels and PinSheets ( order = Sheet Number ) count = %d\n" ), NbItems );
|
2008-02-29 15:31:32 +00:00
|
|
|
fprintf( f, "%s", CONV_TO_UTF8( msg ) );
|
|
|
|
PrintListeGLabel( f, ListOfLabels, NbItems );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-13 05:56:37 +00:00
|
|
|
// if( s_ListHierarchicalPinByName )
|
2008-02-29 15:31:32 +00:00
|
|
|
if( m_GenListLabelsbyVal->GetValue() )
|
|
|
|
{
|
|
|
|
qsort( ListOfLabels, NbItems, sizeof( ListLabel ),
|
|
|
|
( int( * ) ( const void*, const void* ) )ListTriGLabelByVal );
|
|
|
|
|
2008-02-29 16:19:56 +00:00
|
|
|
msg.Printf( _( "\n#Global, Hierarchical Labels and PinSheets ( order = Alphab. ) count = %d\n\n" ), NbItems );
|
2008-02-29 15:31:32 +00:00
|
|
|
fprintf( f, "%s", CONV_TO_UTF8( msg ) );
|
|
|
|
PrintListeGLabel( f, ListOfLabels, NbItems );
|
|
|
|
}
|
|
|
|
MyFree( ListOfLabels );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
msg = _( "\n#End List\n" );
|
|
|
|
fprintf( f, "%s", CONV_TO_UTF8( msg ) );
|
|
|
|
fclose( f );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
/****************************************/
|
2008-02-29 15:31:32 +00:00
|
|
|
int GenListeCmp( ListComponent* List )
|
2007-06-05 12:10:51 +00:00
|
|
|
/****************************************/
|
2008-02-29 15:31:32 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Routine de generation de la liste des elements utiles du dessin
|
2007-10-13 05:56:37 +00:00
|
|
|
* Si List == NULL: comptage des elements
|
|
|
|
* Sinon remplissage de la liste
|
|
|
|
* Initialise "FlagControlMulti" a SheetNumber pour la sortie des listes
|
|
|
|
* et m_Father comme pointeur sur la sheet d'appartenance
|
2008-02-29 15:31:32 +00:00
|
|
|
*
|
|
|
|
* routine for generating a list of the used components.
|
2008-02-12 21:12:46 +00:00
|
|
|
* if List == null, just returns the count. if not, fills the list.
|
2008-02-29 15:31:32 +00:00
|
|
|
* goes through the sheets, not the screens, so that we account for
|
|
|
|
* multiple instances of a given screen.
|
2007-10-13 05:56:37 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-29 15:31:32 +00:00
|
|
|
int ItemCount = 0;
|
|
|
|
EDA_BaseStruct* DrawList;
|
|
|
|
EDA_SchComponentStruct* DrawLibItem;
|
|
|
|
DrawSheetPath* sheet;
|
|
|
|
|
|
|
|
/* Build the sheet (not screen) list */
|
|
|
|
EDA_SheetList SheetList( NULL );
|
|
|
|
|
|
|
|
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
|
|
|
|
{
|
|
|
|
DrawList = sheet->LastDrawList();
|
|
|
|
while( DrawList )
|
|
|
|
{
|
|
|
|
switch( DrawList->Type() )
|
|
|
|
{
|
|
|
|
case DRAW_LIB_ITEM_STRUCT_TYPE:
|
|
|
|
ItemCount++;
|
|
|
|
DrawLibItem = (EDA_SchComponentStruct*) DrawList;
|
|
|
|
DrawLibItem->m_Parent = sheet->LastScreen();
|
|
|
|
if( List )
|
|
|
|
{
|
|
|
|
List->m_Comp = DrawLibItem;
|
|
|
|
List->m_SheetList = *sheet;
|
|
|
|
strncpy( List->m_Ref,
|
|
|
|
CONV_TO_UTF8( DrawLibItem->GetRef( sheet ) ),
|
|
|
|
sizeof( List->m_Ref ) );
|
|
|
|
List++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawList = DrawList->Pnext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ItemCount;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-10-13 05:56:37 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*********************************************/
|
2008-02-29 15:31:32 +00:00
|
|
|
static int GenListeGLabels( ListLabel* List )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*********************************************/
|
2008-02-29 15:31:32 +00:00
|
|
|
|
|
|
|
/* Count the Glabels, or fill the list Listwith Glabel pointers
|
2007-10-13 05:56:37 +00:00
|
|
|
* If List == NULL: Item count only
|
|
|
|
* Else fill list of Glabels
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-29 15:31:32 +00:00
|
|
|
int ItemCount = 0;
|
|
|
|
EDA_BaseStruct* DrawList;
|
|
|
|
DrawSheetLabelStruct* SheetLabel;
|
|
|
|
DrawSheetPath* sheet;
|
|
|
|
|
|
|
|
/* Build the screen list */
|
|
|
|
EDA_SheetList SheetList( NULL );
|
|
|
|
|
|
|
|
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
|
|
|
|
{
|
|
|
|
DrawList = sheet->LastDrawList();
|
|
|
|
wxString path = sheet->PathHumanReadable();
|
|
|
|
while( DrawList )
|
|
|
|
{
|
|
|
|
switch( DrawList->Type() )
|
|
|
|
{
|
|
|
|
case DRAW_HIER_LABEL_STRUCT_TYPE:
|
|
|
|
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
|
|
|
|
ItemCount++;
|
|
|
|
if( List )
|
|
|
|
{
|
|
|
|
List->m_LabelType = DrawList->Type();
|
|
|
|
snprintf( List->m_SheetPath, sizeof(List->m_SheetPath),
|
|
|
|
"%s", CONV_TO_UTF8( path ) );
|
|
|
|
List->m_Label = DrawList;
|
|
|
|
List++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_SHEET_STRUCT_TYPE:
|
|
|
|
{
|
|
|
|
#define Sheet ( (DrawSheetStruct*) DrawList )
|
|
|
|
SheetLabel = Sheet->m_Label;
|
|
|
|
while( SheetLabel != NULL )
|
|
|
|
{
|
|
|
|
if( List )
|
|
|
|
{
|
|
|
|
List->m_LabelType = DRAW_SHEETLABEL_STRUCT_TYPE;
|
|
|
|
snprintf( List->m_SheetPath, sizeof(List->m_SheetPath),
|
|
|
|
"%s", CONV_TO_UTF8( path ) );
|
|
|
|
List->m_Label = SheetLabel;
|
|
|
|
List++;
|
|
|
|
}
|
|
|
|
ItemCount++;
|
|
|
|
SheetLabel = (DrawSheetLabelStruct*) (SheetLabel->Pnext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
DrawList = DrawList->Pnext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ItemCount;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-10-13 05:56:37 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/**********************************************************/
|
2008-02-29 15:31:32 +00:00
|
|
|
static int ListTriComposantByVal( ListComponent* Objet1,
|
|
|
|
ListComponent* Objet2 )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**********************************************************/
|
2008-02-29 15:31:32 +00:00
|
|
|
|
2007-10-13 05:56:37 +00:00
|
|
|
/* Routine de comparaison pour le tri du Tableau par qsort()
|
|
|
|
* Les composants sont tries
|
|
|
|
* par valeur
|
|
|
|
* si meme valeur: par reference
|
|
|
|
* si meme valeur: par numero d'unite
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-29 15:31:32 +00:00
|
|
|
int ii;
|
|
|
|
const wxString* Text1, * Text2;
|
|
|
|
|
|
|
|
if( ( Objet1 == NULL ) && ( Objet2 == NULL ) )
|
|
|
|
return 0;
|
|
|
|
if( Objet1 == NULL )
|
|
|
|
return -1;
|
|
|
|
if( Objet2 == NULL )
|
|
|
|
return 1;
|
|
|
|
if( ( Objet1->m_Comp == NULL ) && ( Objet2->m_Comp == NULL ) )
|
|
|
|
return 0;
|
|
|
|
if( Objet1->m_Comp == NULL )
|
|
|
|
return -1;
|
|
|
|
if( Objet2->m_Comp == NULL )
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
Text1 = &(Objet1->m_Comp->m_Field[VALUE].m_Text);
|
|
|
|
Text2 = &(Objet2->m_Comp->m_Field[VALUE].m_Text);
|
|
|
|
ii = Text1->CmpNoCase( *Text2 );
|
|
|
|
|
|
|
|
if( ii == 0 )
|
|
|
|
{
|
|
|
|
ii = strcmp( Objet1->m_Ref, Objet2->m_Ref );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ii == 0 )
|
|
|
|
{
|
|
|
|
ii = Objet1->m_Comp->m_Multi - Objet2->m_Comp->m_Multi;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ii;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-10-13 05:56:37 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/**********************************************************/
|
2008-02-29 15:31:32 +00:00
|
|
|
static int ListTriComposantByRef( ListComponent* Objet1,
|
|
|
|
ListComponent* Objet2 )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**********************************************************/
|
2008-02-29 15:31:32 +00:00
|
|
|
|
2007-10-13 05:56:37 +00:00
|
|
|
/* Routine de comparaison pour le tri du Tableau par qsort()
|
|
|
|
* Les composants sont tries
|
|
|
|
* par reference
|
|
|
|
* si meme referenece: par valeur
|
|
|
|
* si meme valeur: par numero d'unite
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-29 15:31:32 +00:00
|
|
|
int ii;
|
|
|
|
const wxString* Text1, * Text2;
|
|
|
|
|
|
|
|
if( ( Objet1 == NULL ) && ( Objet2 == NULL ) )
|
|
|
|
return 0;
|
|
|
|
if( Objet1 == NULL )
|
|
|
|
return -1;
|
|
|
|
if( Objet2 == NULL )
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if( ( Objet1->m_Comp == NULL ) && ( Objet2->m_Comp == NULL ) )
|
|
|
|
return 0;
|
|
|
|
if( Objet1->m_Comp == NULL )
|
|
|
|
return -1;
|
|
|
|
if( Objet2->m_Comp == NULL )
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
ii = strcmp( Objet1->m_Ref, Objet2->m_Ref );
|
|
|
|
|
|
|
|
if( ii == 0 )
|
|
|
|
{
|
|
|
|
Text1 = &( Objet1->m_Comp->m_Field[VALUE].m_Text );
|
|
|
|
Text2 = &( Objet2->m_Comp->m_Field[VALUE].m_Text );
|
|
|
|
ii = Text1->CmpNoCase( *Text2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ii == 0 )
|
|
|
|
{
|
|
|
|
ii = Objet1->m_Comp->m_Multi - Objet2->m_Comp->m_Multi;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ii;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-10-13 05:56:37 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/******************************************************************/
|
2008-02-29 15:31:32 +00:00
|
|
|
static int ListTriGLabelByVal( ListLabel* Objet1, ListLabel* Objet2 )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*******************************************************************/
|
2008-02-29 15:31:32 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Routine de comparaison pour le tri du Tableau par qsort()
|
2007-10-13 05:56:37 +00:00
|
|
|
* Les labels sont tries
|
|
|
|
* par comparaison ascii
|
|
|
|
* si meme valeur: par numero de sheet
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-29 15:31:32 +00:00
|
|
|
int ii;
|
|
|
|
const wxString* Text1, * Text2;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
if( Objet1->m_LabelType == DRAW_SHEETLABEL_STRUCT_TYPE )
|
|
|
|
Text1 = &( (DrawSheetLabelStruct*) Objet1->m_Label )->m_Text;
|
|
|
|
else
|
|
|
|
Text1 = &( (DrawTextStruct*) Objet1->m_Label )->m_Text;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
if( Objet2->m_LabelType == DRAW_SHEETLABEL_STRUCT_TYPE )
|
|
|
|
Text2 = &( (DrawSheetLabelStruct*) Objet2->m_Label )->m_Text;
|
|
|
|
else
|
|
|
|
Text2 = &( (DrawTextStruct*) Objet2->m_Label )->m_Text;
|
2007-10-13 05:56:37 +00:00
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
ii = Text1->CmpNoCase( *Text2 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
if( ii == 0 )
|
|
|
|
{
|
|
|
|
ii = strcmp( Objet1->m_SheetPath, Objet2->m_SheetPath );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
return ii;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-10-13 05:56:37 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*******************************************************************/
|
2008-02-29 15:31:32 +00:00
|
|
|
static int ListTriGLabelBySheet( ListLabel* Objet1, ListLabel* Objet2 )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*******************************************************************/
|
2008-02-29 15:31:32 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Routine de comparaison pour le tri du Tableau par qsort()
|
2007-10-13 05:56:37 +00:00
|
|
|
* Les labels sont tries
|
|
|
|
* par sheet number
|
|
|
|
* si meme valeur, par ordre alphabetique
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-29 15:31:32 +00:00
|
|
|
int ii;
|
|
|
|
const wxString* Text1, * Text2;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
ii = strcmp( Objet1->m_SheetPath, Objet2->m_SheetPath );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
if( ii == 0 )
|
|
|
|
{
|
|
|
|
if( Objet1->m_LabelType == DRAW_SHEETLABEL_STRUCT_TYPE )
|
|
|
|
Text1 = &( (DrawSheetLabelStruct*) Objet1->m_Label )->m_Text;
|
|
|
|
else
|
|
|
|
Text1 = &( (DrawTextStruct*) Objet1->m_Label )->m_Text;
|
2007-10-13 05:56:37 +00:00
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
if( Objet2->m_LabelType == DRAW_SHEETLABEL_STRUCT_TYPE )
|
|
|
|
Text2 = &( (DrawSheetLabelStruct*) Objet2->m_Label )->m_Text;
|
|
|
|
else
|
|
|
|
Text2 = &( (DrawTextStruct*) Objet2->m_Label )->m_Text;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
ii = Text1->CmpNoCase( *Text2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
return ii;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************/
|
2008-02-29 15:31:32 +00:00
|
|
|
static void DeleteSubCmp( ListComponent* List, int NbItems )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**************************************************************/
|
2008-02-29 15:31:32 +00:00
|
|
|
|
2008-02-18 09:39:15 +00:00
|
|
|
/* Remove sub components from the list, when multiples parts per package are found in this list
|
|
|
|
* The component list **MUST** be sorted by reference and by unit number
|
2007-10-13 05:56:37 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-29 15:31:32 +00:00
|
|
|
int ii;
|
|
|
|
EDA_SchComponentStruct* LibItem;
|
|
|
|
wxString OldName, CurrName;
|
|
|
|
|
|
|
|
for( ii = 0; ii < NbItems; ii++ )
|
|
|
|
{
|
|
|
|
LibItem = List[ii].m_Comp;
|
|
|
|
if( LibItem == NULL )
|
|
|
|
continue;
|
|
|
|
CurrName = CONV_FROM_UTF8( List[ii].m_Ref );
|
|
|
|
if( !OldName.IsEmpty() )
|
|
|
|
{
|
|
|
|
if( OldName == CurrName ) // CurrName is a subpart of OldName: remove it
|
|
|
|
{
|
|
|
|
List[ii].m_Comp = NULL;
|
|
|
|
List[ii].m_SheetList.Clear();
|
|
|
|
List[ii].m_Ref[0] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
OldName = CurrName;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************************/
|
2008-02-29 15:31:32 +00:00
|
|
|
void WinEDA_Build_BOM_Frame::PrintFieldData( FILE* f, EDA_SchComponentStruct* DrawLibItem,
|
|
|
|
bool CompactForm )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*******************************************************************************************/
|
|
|
|
{
|
2008-02-29 15:31:32 +00:00
|
|
|
wxCheckBox* FieldListCtrl[FIELD8 - FIELD1 + 1] = {
|
|
|
|
m_AddField1,
|
|
|
|
m_AddField2,
|
|
|
|
m_AddField3,
|
|
|
|
m_AddField4,
|
|
|
|
m_AddField5,
|
|
|
|
m_AddField6,
|
|
|
|
m_AddField7,
|
|
|
|
m_AddField8
|
|
|
|
};
|
|
|
|
int ii;
|
|
|
|
wxCheckBox* FieldCtrl = FieldListCtrl[0];
|
|
|
|
|
|
|
|
if( CompactForm )
|
|
|
|
{
|
|
|
|
fprintf( f, "%c%s", s_ExportSeparatorSymbol,
|
|
|
|
CONV_TO_UTF8( DrawLibItem->m_Field[FOOTPRINT].m_Text ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( ii = FIELD1; ii <= FIELD8; ii++ )
|
|
|
|
{
|
|
|
|
FieldCtrl = FieldListCtrl[ii - FIELD1];
|
|
|
|
if( FieldCtrl == NULL )
|
|
|
|
continue;
|
|
|
|
if( !FieldCtrl->IsChecked() )
|
|
|
|
continue;
|
|
|
|
if( CompactForm )
|
|
|
|
fprintf( f, "%c%s", s_ExportSeparatorSymbol,
|
|
|
|
CONV_TO_UTF8( DrawLibItem->m_Field[ii].m_Text ) );
|
|
|
|
else
|
|
|
|
fprintf( f, "; %-12s", CONV_TO_UTF8( DrawLibItem->m_Field[ii].m_Text ) );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-10-13 05:56:37 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*********************************************************************************************/
|
2008-02-29 15:31:32 +00:00
|
|
|
int WinEDA_Build_BOM_Frame::PrintListeCmpByRef( FILE* f, ListComponent* List, int NbItems,
|
|
|
|
bool CompactForm )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*********************************************************************************************/
|
2008-02-29 15:31:32 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Print the B.O.M sorted by reference
|
2007-10-13 05:56:37 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-29 15:31:32 +00:00
|
|
|
int ii, Multi, Unit;
|
|
|
|
EDA_BaseStruct* DrawList;
|
|
|
|
EDA_SchComponentStruct* DrawLibItem;
|
|
|
|
EDA_LibComponentStruct* Entry;
|
|
|
|
char NameCmp[80];
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
if( CompactForm )
|
|
|
|
{
|
|
|
|
wxCheckBox* FieldListCtrl[FIELD8 - FIELD1 + 1] = {
|
|
|
|
m_AddField1,
|
|
|
|
m_AddField2,
|
|
|
|
m_AddField3,
|
|
|
|
m_AddField4,
|
|
|
|
m_AddField5,
|
|
|
|
m_AddField6,
|
|
|
|
m_AddField7,
|
|
|
|
m_AddField8
|
|
|
|
};
|
|
|
|
|
|
|
|
// Print comment line:
|
|
|
|
fprintf( f, "ref%cvalue", s_ExportSeparatorSymbol );
|
|
|
|
|
|
|
|
if( m_ListSubCmpItems->GetValue() )
|
|
|
|
fprintf( f, "%csheet path", s_ExportSeparatorSymbol );
|
|
|
|
|
|
|
|
fprintf( f, "%cfootprint", s_ExportSeparatorSymbol );
|
|
|
|
|
|
|
|
for( ii = FIELD1; ii <= FIELD8; ii++ )
|
|
|
|
{
|
|
|
|
wxCheckBox* FieldCtrl = FieldListCtrl[ii - FIELD1];
|
|
|
|
if( FieldCtrl == NULL )
|
|
|
|
continue;
|
|
|
|
if( !FieldCtrl->IsChecked() )
|
|
|
|
continue;
|
|
|
|
msg = _( "Field" );
|
|
|
|
fprintf( f, "%c%s%d", s_ExportSeparatorSymbol, CONV_TO_UTF8( msg ), ii - FIELD1 + 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf( f, "\n" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
msg = _( "\n#Cmp ( order = Reference )" );
|
|
|
|
|
2007-10-13 05:56:37 +00:00
|
|
|
// if( s_ListWithSubCmponents )
|
2008-02-29 15:31:32 +00:00
|
|
|
if( m_ListSubCmpItems->GetValue() )
|
|
|
|
msg << _( " (with SubCmp)" );
|
|
|
|
fprintf( f, "%s\n", CONV_TO_UTF8( msg ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Print list of items
|
|
|
|
for( ii = 0; ii < NbItems; ii++ )
|
|
|
|
{
|
|
|
|
DrawList = List[ii].m_Comp;
|
|
|
|
|
|
|
|
if( DrawList == NULL )
|
|
|
|
continue;
|
|
|
|
if( DrawList->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
DrawLibItem = (EDA_SchComponentStruct*) DrawList;
|
|
|
|
if( List[ii].m_Ref[0] == '#' )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
Multi = 0;
|
|
|
|
Unit = ' ';
|
|
|
|
Entry = FindLibPart( DrawLibItem->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
|
|
|
|
if( Entry )
|
|
|
|
Multi = Entry->m_UnitCount;
|
|
|
|
|
2007-10-13 05:56:37 +00:00
|
|
|
// if( ( Multi > 1 ) && s_ListWithSubCmponents )
|
2008-02-29 15:31:32 +00:00
|
|
|
if( ( Multi > 1 ) && m_ListSubCmpItems->GetValue() )
|
|
|
|
Unit = DrawLibItem->m_Multi + 'A' - 1;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
sprintf( NameCmp, "%s", List[ii].m_Ref );
|
|
|
|
if( !CompactForm || Unit != ' ' )
|
|
|
|
sprintf( NameCmp + strlen( NameCmp ), "%c", Unit );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
if( CompactForm )
|
|
|
|
fprintf( f, "%s%c%s", NameCmp, s_ExportSeparatorSymbol,
|
|
|
|
CONV_TO_UTF8( DrawLibItem->m_Field[VALUE].m_Text ) );
|
|
|
|
else
|
|
|
|
fprintf( f, "| %-10s %-12s", NameCmp,
|
|
|
|
CONV_TO_UTF8( DrawLibItem->m_Field[VALUE].m_Text ) );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-13 05:56:37 +00:00
|
|
|
// if( s_ListWithSubCmponents )
|
2008-02-29 15:31:32 +00:00
|
|
|
if( m_ListSubCmpItems->GetValue() )
|
|
|
|
{
|
|
|
|
msg = List[ii].m_SheetList.PathHumanReadable();
|
|
|
|
if( CompactForm )
|
|
|
|
fprintf( f, "%c%s", s_ExportSeparatorSymbol, CONV_TO_UTF8( msg ) );
|
|
|
|
else
|
|
|
|
fprintf( f, " (Sheet %s)", CONV_TO_UTF8( msg ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
PrintFieldData( f, DrawLibItem, CompactForm );
|
|
|
|
|
|
|
|
fprintf( f, "\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !CompactForm )
|
|
|
|
{
|
|
|
|
msg = _( "#End Cmp\n" );
|
|
|
|
fprintf( f, CONV_TO_UTF8( msg ) );
|
|
|
|
}
|
|
|
|
return 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-02-29 15:31:32 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*********************************************************************************************/
|
2008-02-29 15:31:32 +00:00
|
|
|
int WinEDA_Build_BOM_Frame::PrintListeCmpByVal( FILE* f, ListComponent* List, int NbItems )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**********************************************************************************************/
|
|
|
|
{
|
2008-02-29 15:31:32 +00:00
|
|
|
int ii, Multi;
|
|
|
|
wxChar Unit;
|
|
|
|
EDA_BaseStruct* DrawList;
|
|
|
|
EDA_SchComponentStruct* DrawLibItem;
|
|
|
|
EDA_LibComponentStruct* Entry;
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
msg = _( "\n#Cmp ( order = Value )" );
|
|
|
|
|
2007-10-13 05:56:37 +00:00
|
|
|
// if( s_ListWithSubCmponents )
|
2008-02-29 15:31:32 +00:00
|
|
|
if( m_ListSubCmpItems->GetValue() )
|
|
|
|
msg << _( " (with SubCmp)" );
|
|
|
|
msg << wxT( "\n" );
|
|
|
|
fprintf( f, CONV_TO_UTF8( msg ) );
|
|
|
|
|
|
|
|
for( ii = 0; ii < NbItems; ii++ )
|
|
|
|
{
|
|
|
|
DrawList = List[ii].m_Comp;
|
|
|
|
|
|
|
|
if( DrawList == NULL )
|
|
|
|
continue;
|
|
|
|
if( DrawList->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
DrawLibItem = (EDA_SchComponentStruct*) DrawList;
|
|
|
|
if( List[ii].m_Ref[0] == '#' )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
Multi = 0;
|
|
|
|
Unit = ' ';
|
|
|
|
Entry = FindLibPart( DrawLibItem->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
|
|
|
|
if( Entry )
|
|
|
|
Multi = Entry->m_UnitCount;
|
|
|
|
|
2007-10-13 05:56:37 +00:00
|
|
|
// if( ( Multi > 1 ) && s_ListWithSubCmponents )
|
2008-02-29 15:31:32 +00:00
|
|
|
if( ( Multi > 1 ) && m_ListSubCmpItems->GetValue() )
|
|
|
|
{
|
|
|
|
Unit = DrawLibItem->m_Multi + 'A' - 1;
|
|
|
|
}
|
|
|
|
fprintf( f, "| %-12s %-10s%c",
|
|
|
|
CONV_TO_UTF8( DrawLibItem->m_Field[VALUE].m_Text ),
|
|
|
|
List[ii].m_Ref, Unit );
|
|
|
|
|
2007-10-13 05:56:37 +00:00
|
|
|
// if( s_ListWithSubCmponents )
|
2008-02-29 15:31:32 +00:00
|
|
|
// print the sheet path
|
|
|
|
if( m_ListSubCmpItems->GetValue() )
|
|
|
|
{
|
|
|
|
msg = List[ii].m_SheetList.PathHumanReadable();
|
|
|
|
fprintf( f, " (Sheet %s)", CONV_TO_UTF8( msg ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
PrintFieldData( f, DrawLibItem );
|
|
|
|
|
|
|
|
fprintf( f, "\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
msg = _( "#End Cmp\n" );
|
|
|
|
fprintf( f, CONV_TO_UTF8( msg ) );
|
|
|
|
return 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************/
|
2008-02-29 15:31:32 +00:00
|
|
|
static int PrintListeGLabel( FILE* f, ListLabel* List, int NbItems )
|
2007-06-05 12:10:51 +00:00
|
|
|
/******************************************************************/
|
|
|
|
{
|
2008-02-29 15:31:32 +00:00
|
|
|
int ii, jj;
|
|
|
|
DrawLabelStruct* DrawTextItem;
|
|
|
|
DrawSheetLabelStruct* DrawSheetLabel;
|
|
|
|
ListLabel* LabelItem;
|
2008-02-29 16:19:56 +00:00
|
|
|
wxString msg, sheetpath;
|
|
|
|
wxString labeltype;
|
2008-02-29 15:31:32 +00:00
|
|
|
|
|
|
|
for( ii = 0; ii < NbItems; ii++ )
|
|
|
|
{
|
|
|
|
LabelItem = &List[ii];
|
|
|
|
|
|
|
|
switch( LabelItem->m_LabelType )
|
|
|
|
{
|
|
|
|
case DRAW_HIER_LABEL_STRUCT_TYPE:
|
|
|
|
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
|
|
|
|
DrawTextItem = (DrawLabelStruct*) (LabelItem->m_Label);
|
|
|
|
if( LabelItem->m_LabelType == DRAW_HIER_LABEL_STRUCT_TYPE )
|
2008-02-29 16:19:56 +00:00
|
|
|
labeltype = wxT("Hierarchical");
|
2008-02-29 15:31:32 +00:00
|
|
|
else
|
2008-02-29 16:19:56 +00:00
|
|
|
labeltype = wxT("Global ");
|
|
|
|
sheetpath = CONV_FROM_UTF8(LabelItem->m_SheetPath);
|
2008-02-29 15:31:32 +00:00
|
|
|
msg.Printf(
|
|
|
|
_( "> %-28.28s %s (Sheet %s) pos: %3.3f, %3.3f\n" ),
|
|
|
|
DrawTextItem->m_Text.GetData(),
|
2008-02-29 16:19:56 +00:00
|
|
|
labeltype.GetData(),
|
|
|
|
sheetpath.GetData(),
|
2008-02-29 15:31:32 +00:00
|
|
|
(float) DrawTextItem->m_Pos.x / 1000,
|
|
|
|
(float) DrawTextItem->m_Pos.y / 1000 );
|
|
|
|
|
|
|
|
fprintf( f, CONV_TO_UTF8( msg ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_SHEETLABEL_STRUCT_TYPE:
|
|
|
|
{
|
|
|
|
DrawSheetLabel = (DrawSheetLabelStruct*) LabelItem->m_Label;
|
|
|
|
jj = DrawSheetLabel->m_Shape;
|
|
|
|
if( jj < 0 )
|
|
|
|
jj = NET_TMAX;
|
|
|
|
if( jj > NET_TMAX )
|
|
|
|
jj = 4;
|
|
|
|
wxString labtype = CONV_FROM_UTF8( SheetLabelType[jj] );
|
|
|
|
msg.Printf(
|
2008-02-29 16:19:56 +00:00
|
|
|
_( "> %-28.28s PinSheet %-7.7s (Sheet %s) pos: %3.3f, %3.3f\n" ),
|
2008-02-29 15:31:32 +00:00
|
|
|
DrawSheetLabel->m_Text.GetData(),
|
|
|
|
labtype.GetData(),
|
|
|
|
LabelItem->m_SheetPath,
|
|
|
|
(float) DrawSheetLabel->m_Pos.x / 1000,
|
|
|
|
(float) DrawSheetLabel->m_Pos.y / 1000 );
|
|
|
|
fprintf( f, CONV_TO_UTF8( msg ) );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
msg = _( "#End labels\n" );
|
|
|
|
fprintf( f, CONV_TO_UTF8( msg ) );
|
|
|
|
return 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|