Commit 515f5fbe authored by Dick Hollenbeck's avatar Dick Hollenbeck

*) Introduce "invoke_a_dialog.h" to information hide between top frame

   and various DIALOG classes called from top frames.  See comments in
   {eeschema,pcbnew}/invoke_a_dialog.h.
*) Move some dialog classes into *.cpp files from *.h files.
*) void SCH_EDIT_FRAME::OnErc( wxCommandEvent& event ) was opening the modeless
   ERC dialog more than once if icon was clicked more than once.
*) Remove BOM stuff.
parent 0c5d9fa2
/**
* @file BOM_lister.h
*/
/* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef _BOM_LISTER_H_
#define _BOM_LISTER_H_
#include <netlist.h>
// A helper class to build item lists for BOM,
// and write lists on files
class BOM_LISTER
{
private:
BOM_LABEL_LIST m_labelList; // a list of global and hierarchical labels
SCH_REFERENCE_LIST m_cmplist; // a flat list of components in the full hierarchy
FILE* m_outFile; // the output file for BOM generation
char m_separatorSymbol; // the separator used for csv files ( usually \t ; or , )
bool m_outputFmtCsv; // true to create Csv files, false to create text lists
bool m_includeSubComponents; // true to list each part
// of a multiple part per package component
// false to list only once this kind of component
bool m_csvForm; // true to print less verbose component list
// false to print more verbose component list
bool m_groupReferences; // true to group in list by reference (when possible,
// i.e. when other fields have the same value
// false to list one reference per line
bool m_printLocation; // true to print component location in list by reference
std::vector <int> m_fieldIDactive; // list of field IDs to print
public:
BOM_LISTER()
{
m_outFile = NULL;
m_separatorSymbol = '\t';
m_outputFmtCsv = false;
m_includeSubComponents = false;
m_csvForm = true;
m_printLocation = false;
m_groupReferences = false;
}
// Accessors:
void SetGroupReferences( bool aGroupRef )
{
m_groupReferences = aGroupRef;
}
void SetPrintLocation( bool aPrintLoc )
{
m_printLocation = aPrintLoc;
}
void SetIncludeSubCmp( bool aIncludeSubCmp )
{
m_includeSubComponents = aIncludeSubCmp;
}
/**
* Function SetCvsFormOn
* prepare parameters to create a BOM list in comma separated value (cvs)
* @param aSeparator = the character used as "csv" separator
*/
void SetCvsFormOn( char aSeparator )
{
m_csvForm = true;
m_separatorSymbol = aSeparator;
}
/**
* Function SetCvsFormOff
* prepare parameters to create a BOM list in full text readable mode
* (not csv format)
*/
void SetCvsFormOff()
{
m_csvForm = false;
}
void AddFieldIdToPrintList( int aFieldId );
void ClearFieldIdPrintList() { m_fieldIDactive.clear(); }
/**
* Function CreateCsvBOMListByValues
* print the list of components, grouped by values:
* One line by value. The format is something like:
* value;quantity;references;other fields
* 18pF;2;"C404 C405";SM0402
* 22nF/25V;4;"C128 C168 C228 C268";SM0402
* @param aFile = the file to write to (will be closed)
*/
void CreateCsvBOMListByValues( FILE* aFile );
/**
* Function PrintGlobalAndHierarchicalLabelsList
* print the list of global and hierarchical labels by sheet or by name
* @param aSortBySheet = true to print by sheet name order
* false to print by label name order
* @param aFile = the file to write to (will be NOT closed)
*/
void PrintGlobalAndHierarchicalLabelsList( FILE* aFile, bool aSortBySheet );
/**
* Function PrintComponentsListByReferenceHumanReadable
* print a BOM list in human readable form
* @param aFile = the file to write to (will be NOT closed)
*/
bool PrintComponentsListByReferenceHumanReadable( FILE* aFile );
/**
* Function PrintComponentsListByReferenceCsvForm
* print the list of components ordered by references. Generate 2 formats:
* - full component list in csv form
* - "short" component list in csv form, grouped by common fields values
* (mainly component value)
* @param aFile = the file to write to (will be NOT closed)
*/
bool PrintComponentsListByReferenceCsvForm( FILE* aFile );
/**
* Function PrintComponentsListByValue
* print the list of components, sorted by value, one line per component
* not useable for csv format (use CreateCsvBOMListByValues instead)
* @param aFile = the file to write to (will be NOT closed)
*/
int PrintComponentsListByValue( FILE* aFile );
private:
/**
* Helper function isFieldPrintable
* @return true if the field aFieldId should be printed.
* @param aFieldId = the field Id (FOOTPRIN, FIELD4 ...)
*/
bool isFieldPrintable( int aFieldId );
/**
* Helper function buildGlobalAndHierarchicalLabelsList
* Populate m_labelList with global and hierarchical labels
* and sheet pins labels
*/
void buildGlobalAndHierarchicalLabelsList();
/**
* Helper function returnFieldsString
* @return a string containing all selected fields texts,
* @param aComponent = the schematic component
* separated by the csv separator symbol
*/
const wxString returnFieldsString( SCH_COMPONENT* aComponent );
/**
* Helper function returnURLItemLocation
* @param aPathName = the full sheet name of item
* @param aPosition = a position (in internal units) to print
* @return a formated string to print the full location:
* /sheet name/( X Y position)
*/
const wxString returnURLItemLocation( const wxString& aPathName,
wxPoint aPosition );
};
#endif // _BOM_LISTER_H_
...@@ -12,7 +12,7 @@ include_directories( ...@@ -12,7 +12,7 @@ include_directories(
set(EESCHEMA_DLGS set(EESCHEMA_DLGS
dialogs/dialog_color_config.cpp dialogs/dialog_color_config.cpp
dialogs/annotate_dialog.cpp dialogs/dialog_annotate.cpp
dialogs/dialog_annotate_base.cpp dialogs/dialog_annotate_base.cpp
dialogs/dialog_lib_edit_text.cpp dialogs/dialog_lib_edit_text.cpp
dialogs/dialog_lib_edit_text_base.cpp dialogs/dialog_lib_edit_text_base.cpp
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file build_BOM.cpp
* @brief Code used to generate bill of materials.
*/
#include <algorithm> // to use sort vector
#include <vector>
#include <fctsys.h>
#include <sch_sheet.h>
#include <sch_component.h>
#include <template_fieldnames.h>
#include <class_library.h>
#include <base_units.h>
#include <BOM_lister.h>
/* Creates the list of components, grouped by values:
* One line by value. The format is something like:
* value;quantity;references;other fields
* 18pF;2;"C404 C405";SM0402
* 22nF/25V;4;"C128 C168 C228 C268";SM0402
* param aFile = the file to write to (will be closed)
*/
void BOM_LISTER::CreateCsvBOMListByValues( FILE* aFile )
{
m_outFile = aFile;
SCH_SHEET_LIST sheetList;
sheetList.GetComponents( m_cmplist, false );
// sort component list by ref and remove sub components
m_cmplist.RemoveSubComponentsFromList();
// sort component list by value
m_cmplist.SortByValueOnly();
unsigned int index = 0;
while( index < m_cmplist.GetCount() )
{
SCH_COMPONENT* component = m_cmplist[index].GetComponent();
wxString referenceListStr;
int qty = 1;
referenceListStr.append( m_cmplist[index].GetRef() );
for( unsigned int ii = index + 1; ii < m_cmplist.GetCount(); )
{
if( *( m_cmplist[ii].GetComponent() ) == *component )
{
referenceListStr.append( wxT( " " ) + m_cmplist[ii].GetRef() );
m_cmplist.RemoveItem( ii );
qty++;
}
else
ii++; // Increment index only when current item is not removed from the list
}
// Write value, quantity and list of references
fprintf( m_outFile, "%s%c%d%c\"%s\"",
TO_UTF8( component->GetField( VALUE )->GetText() ),
m_separatorSymbol, qty,
m_separatorSymbol, TO_UTF8( referenceListStr ) );
for( int ii = FOOTPRINT; ii < component->GetFieldCount(); ii++ )
{
if( isFieldPrintable( ii ) )
fprintf( m_outFile, "%c%s", m_separatorSymbol,
TO_UTF8( component->GetField( ii )->GetText() ) );
}
fprintf( m_outFile, "\n" );
index++;
}
fclose( m_outFile );
m_outFile = NULL;
}
bool BOM_LISTER::isFieldPrintable( int aFieldId )
{
for( unsigned ii = 0; ii < m_fieldIDactive.size(); ii++ )
if( m_fieldIDactive[ii] == aFieldId )
return true;
return false;
}
void BOM_LISTER::AddFieldIdToPrintList( int aFieldId )
{
for( unsigned ii = 0; ii < m_fieldIDactive.size(); ii++ )
if( m_fieldIDactive[ii] == aFieldId )
return;
m_fieldIDactive.push_back( aFieldId );
}
/* compare function for sorting labels by value, then by sheet
*/
static bool SortLabelsByValue( const BOM_LABEL& obj1, const BOM_LABEL& obj2 )
{
int ii = obj1.GetText().CmpNoCase( obj2.GetText() );
if( ii == 0 )
ii = obj1.GetSheetPath().Cmp( obj2.GetSheetPath() );
return ii < 0;
}
/* compare function for sorting labels by sheet, then by alphabetic order
*/
static bool SortLabelsBySheet( const BOM_LABEL& obj1, const BOM_LABEL& obj2 )
{
int ii = obj1.GetSheetPath().Cmp( obj2.GetSheetPath() );
if( ii == 0 )
ii = obj1.GetText().CmpNoCase( obj2.GetText() );
return ii < 0;
}
// Creates the flat list of global, hierachycal labels and pin sheets
// and populate m_labelList
void BOM_LISTER::buildGlobalAndHierarchicalLabelsList()
{
m_labelList.clear();
// Explore the flat sheet list
SCH_SHEET_LIST sheetList;
for( SCH_SHEET_PATH* path = sheetList.GetFirst(); path; path = sheetList.GetNext() )
{
SCH_ITEM* schItem = (SCH_ITEM*) path->LastDrawList();
for( ; schItem; schItem = schItem->Next() )
{
switch( schItem->Type() )
{
case SCH_HIERARCHICAL_LABEL_T:
case SCH_GLOBAL_LABEL_T:
m_labelList.push_back( BOM_LABEL( schItem->Type(), schItem, *path ) );
break;
case SCH_SHEET_T:
{
SCH_SHEET* sheet = (SCH_SHEET*) schItem;
BOOST_FOREACH( SCH_SHEET_PIN & sheetPin, sheet->GetPins() ) {
m_labelList.push_back( BOM_LABEL( SCH_SHEET_PIN_T,
&sheetPin, *path ) );
}
}
break;
default:
break;
}
}
}
}
// Print the flat list of global, hierachycal labels and pin sheets
// contained by m_labelList
void BOM_LISTER::PrintGlobalAndHierarchicalLabelsList( FILE* aFile, bool aSortBySheet )
{
m_outFile = aFile;
buildGlobalAndHierarchicalLabelsList();
wxString msg;
if( aSortBySheet )
{
sort( m_labelList.begin(), m_labelList.end(), SortLabelsBySheet );
msg.Printf( _(
"\n#Global, Hierarchical Labels and PinSheets \
( order = Sheet Number ) count = %d\n" ),
m_labelList.size() );
}
else
{
sort( m_labelList.begin(), m_labelList.end(), SortLabelsByValue );
msg.Printf( _(
"\n#Global, Hierarchical Labels and PinSheets ( \
order = Alphab. ) count = %d\n\n" ),
m_labelList.size() );
}
fprintf( m_outFile, "%s", TO_UTF8( msg ) );
SCH_LABEL* label;
SCH_SHEET_PIN* pinsheet;
wxString sheetpath;
wxString labeltype;
for( unsigned ii = 0; ii < m_labelList.size(); ii++ )
{
switch( m_labelList[ii].GetType() )
{
case SCH_HIERARCHICAL_LABEL_T:
case SCH_GLOBAL_LABEL_T:
label = (SCH_LABEL*) ( m_labelList[ii].GetLabel() );
if( m_labelList[ii].GetType() == SCH_HIERARCHICAL_LABEL_T )
labeltype = wxT( "Hierarchical" );
else
labeltype = wxT( "Global " );
sheetpath = m_labelList[ii].GetSheetPath().PathHumanReadable();
msg.Printf( wxT( "> %-28.28s %s %s\n" ),
GetChars( label->GetText() ),
GetChars( labeltype ),
GetChars( returnURLItemLocation( sheetpath, label->GetPosition() ) ) );
fputs( TO_UTF8( msg ), m_outFile );
break;
case SCH_SHEET_PIN_T:
pinsheet = (SCH_SHEET_PIN*) m_labelList[ii].GetLabel();
labeltype = FROM_UTF8( SheetLabelType[pinsheet->GetShape()] );
msg.Printf( _( "> %-28.28s PinSheet %-7.7s %s\n" ),
GetChars( pinsheet->GetText() ),
GetChars( labeltype ),
GetChars( returnURLItemLocation( m_labelList[ii].GetSheetPath().
PathHumanReadable(),
pinsheet->GetPosition() ) ) );
fputs( TO_UTF8( msg ), m_outFile );
break;
default:
break;
}
}
msg = _( "#End labels\n" );
fputs( TO_UTF8( msg ), m_outFile );
}
/*
* Helper function
* returns a string containing all selected fields texts,
* separated by the csv separator symbol (csv form) or a ;
*/
const wxString BOM_LISTER::returnFieldsString( SCH_COMPONENT* aComponent )
{
wxString outStr;
wxString tmpStr;
wxString text;
for( int ii = FOOTPRINT; ii <= FIELD8; ii++ )
{
if( !isFieldPrintable( ii ) )
continue;
if( aComponent->GetFieldCount() > ii )
text = aComponent->GetField( ii )->GetText();
else
text = wxEmptyString;
if( m_csvForm )
tmpStr.Printf( wxT( "%c%s" ), m_separatorSymbol, GetChars( text ) );
else
tmpStr.Printf( wxT( "; %-12s" ), GetChars( text ) );
outStr += tmpStr;
}
return outStr;
}
/* print the list of components ordered by references,
* full component list in human readable form
* param aFile = the file to write to (will be NOT closed)
*/
/* full list in human readable form sample:
* #Cmp ( order = Reference )with sub-composants
* | C101 47pF Loc /(X=344,170 mm, Y=116,840 mm); C1 ; field1 ;
* | C102 47pF Loc /(X=364,490 mm, Y=116,840 mm); C1 ; ;
* | C103 47uF Loc /(X=66,040 mm, Y=231,140 mm); CP6 ; ;
*/
bool BOM_LISTER::PrintComponentsListByReferenceHumanReadable( FILE* aFile )
{
m_outFile = aFile;
bool addDatasheet = isFieldPrintable( DATASHEET );
// Print component location if needed, but only when
// include sub component option is enabled, because for multiple
// parts per package there are more than one location per reference
bool printLocCmp = m_printLocation && m_includeSubComponents;
wxString msg;
if( m_cmplist.GetCount() == 0 ) // Build component list
{
SCH_SHEET_LIST sheetList;
sheetList.GetComponents( m_cmplist, false );
// sort component list
m_cmplist.SortByReferenceOnly();
if( !m_includeSubComponents )
m_cmplist.RemoveSubComponentsFromList();
}
else
m_cmplist.SortByReferenceOnly();
// Print comment line:
msg = _( "#Cmp ( order = Reference )" );
if( m_includeSubComponents )
msg << _( " (with SubCmp)" );
fprintf( m_outFile, "%s\n", TO_UTF8( msg ) );
wxString subReference; // Unit ident, for mutiple parts per package
std::string CmpName;
// Print list of items
for( unsigned ii = 0; ii < m_cmplist.GetCount(); ii++ )
{
EDA_ITEM* item = m_cmplist[ii].GetComponent();
if( item == NULL )
continue;
if( item->Type() != SCH_COMPONENT_T )
continue;
SCH_COMPONENT* comp = (SCH_COMPONENT*) item;
bool isMulti = false;
LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( comp->GetLibName() );
if( entry )
isMulti = entry->IsMulti();
CmpName = m_cmplist[ii].GetRefStr();
if( isMulti && m_includeSubComponents )
{
subReference = LIB_COMPONENT::ReturnSubReference( m_cmplist[ii].GetUnit() );
CmpName += TO_UTF8( subReference );
}
fprintf( m_outFile, "| %-10s %-12s", CmpName.c_str(),
TO_UTF8( comp->GetField( VALUE )->GetText() ) );
if( addDatasheet )
fprintf( m_outFile, "%-20s",
TO_UTF8( comp->GetField( DATASHEET )->GetText() ) );
if( m_includeSubComponents )
{
if( printLocCmp )
{
msg = returnURLItemLocation( m_cmplist[ii].GetSheetPath().PathHumanReadable(),
comp->GetPosition() );
fprintf( m_outFile, "%s", TO_UTF8( msg ) );
}
}
wxString tmpStr = returnFieldsString( comp );
fprintf( m_outFile, "%s\n", TO_UTF8( tmpStr ) );
}
// Print the last line:
fputs( "#End Cmp\n", m_outFile );
return true;
}
/* print the list of components ordered by references. Generate 2 formats:
* - full component list in csv form
* - "short" component list in csv form, grouped by common fields values
* (mainly component value)
* param aFile = the file to write to (will be NOT closed)
*/
/* full csv format sample:
* ref;value;sheet path(location);footprint;field1;field2
* C101;47pF;Loc /(X=57,150 mm, Y=74,930 mm);Loc /(X=344,170 mm, Y=116,840 mm));C1;field1;
* C102;47pF;Loc /(X=344,170 mm, Y=116,840 mm);Loc /(X=364,490 mm, Y=116,840 mm));C1;;
* C103;47uF;Loc /(X=364,490 mm, Y=116,840 mm);Loc /(X=66,040 mm, Y=231,140 mm));CP6;;
* C104;47uF;Loc /(X=66,040 mm, Y=231,140 mm);Loc /(X=82,550 mm, Y=231,140 mm));CP6;;
*/
/* short csv format sample:
* ref;value;footprint;Champ1;Champ2
* C101;47pF;C1;field1;;1
* C102;47pF;C1;;;1
* C103..C106;47uF;CP6;;;4
*/
bool BOM_LISTER::PrintComponentsListByReferenceCsvForm( FILE* aFile )
{
m_outFile = aFile;
bool addDatasheet = isFieldPrintable( DATASHEET );
// Set option group references, for components having same field values
// (same value, same footprint ...)
// obviously, this is possible only when print location
// and include Sub Components are not enabled.
bool groupRefs = m_groupReferences;
bool includeSubComponents = m_includeSubComponents && !groupRefs;
// Print component location if needed, but only when
// include sub component option is enabled, because for multiple
// parts per package there are more than one location per reference
bool printLocCmp = m_printLocation && !groupRefs && m_includeSubComponents;
wxString msg;
if( m_cmplist.GetCount() == 0 ) // Build component list
{
SCH_SHEET_LIST sheetList;
sheetList.GetComponents( m_cmplist, false );
// sort component list
m_cmplist.SortByReferenceOnly();
if( !includeSubComponents )
m_cmplist.RemoveSubComponentsFromList();
}
else
m_cmplist.SortByReferenceOnly();
// Print comment line:
msg = wxT( "ref" );
msg << (wxChar)m_separatorSymbol << wxT( "value" );
if( addDatasheet )
msg << (wxChar)m_separatorSymbol << wxT( "datasheet" );
if( printLocCmp )
msg << (wxChar)m_separatorSymbol << wxT( "sheet path(location)" );
if( isFieldPrintable( FOOTPRINT ) )
msg << (wxChar)m_separatorSymbol << wxT( "footprint" );
for( int ii = FIELD1; ii <= FIELD8; ii++ )
{
if( isFieldPrintable( ii ) )
msg << (wxChar)m_separatorSymbol << _( "Field" ) << ii - FIELD1 + 1;
}
if( groupRefs )
msg << (wxChar)m_separatorSymbol << _( "Item count" );
fprintf( m_outFile, "%s\n", TO_UTF8( msg ) );
// Print BOM list
wxString strCur;
wxString strPred;
int amount = 0; // number of items, on the same line
wxString cmpName;
wxString cmpNameFirst;
wxString cmpNameLast;
// Print list of items, by reference
for( unsigned ii = 0; ii < m_cmplist.GetCount(); ii++ )
{
EDA_ITEM* item = m_cmplist[ii].GetComponent();
if( item == NULL )
continue;
if( item->Type() != SCH_COMPONENT_T )
continue;
SCH_COMPONENT* comp = (SCH_COMPONENT*) item;
LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( comp->GetLibName() );
bool isMulti = false;
if( entry )
isMulti = entry->IsMulti();
cmpName = m_cmplist[ii].GetRef();
if( isMulti && includeSubComponents )
// Add unit ident, for mutiple parts per package
cmpName += LIB_COMPONENT::ReturnSubReference( m_cmplist[ii].GetUnit() );
if( groupRefs )
{
// Store value and datasheet (will be printed later)
strCur.Empty();
strCur << (wxChar)m_separatorSymbol << comp->GetField( VALUE )->GetText();
if( addDatasheet )
strCur << (wxChar)m_separatorSymbol << comp->GetField( DATASHEET )->GetText();
}
else
{
// Print the current component reference, value and datasheet
msg = cmpName;
msg << (wxChar)m_separatorSymbol << comp->GetField( VALUE )->GetText();
if( addDatasheet )
msg << (wxChar)m_separatorSymbol << comp->GetField( DATASHEET )->GetText();
fprintf( m_outFile, "%s", TO_UTF8( msg ) );
}
if( printLocCmp ) // Is allowed only for full list (not grouped)
{
msg = returnURLItemLocation(
m_cmplist[ii].GetSheetPath().PathHumanReadable(),
comp->GetPosition() );
fprintf( m_outFile, "%c%s", m_separatorSymbol, TO_UTF8( msg ) );
}
if( groupRefs )
{
wxString tmpStr = returnFieldsString( comp );
strCur += tmpStr;
if( strPred.Len() == 0 )
cmpNameFirst = cmpName;
else
{
// print a BOM line
msg.Empty();
if( !strCur.IsSameAs( strPred ) )
{
switch( amount )
{
case 1: // One reference to print
// format C103;47uF;CP6;;;1
msg << cmpNameFirst <<strPred << (wxChar)m_separatorSymbol << amount;
break;
case 2: // 2 references to print
// format C103,C104;47uF;CP6;;;2
msg << cmpNameFirst << wxT(",") << cmpNameLast
<< strPred << (wxChar)m_separatorSymbol << amount;
break;
default: // Many references to print :
// format: C103..C106;47uF;CP6;;;4
msg << cmpNameFirst << wxT("..") << cmpNameLast
<< strPred << (wxChar)m_separatorSymbol << amount;
break;
}
fprintf( m_outFile, "%s\n", TO_UTF8( msg ) );
cmpNameFirst = cmpName;
amount = 0;
}
}
strPred = strCur;
cmpNameLast = cmpName;
amount++;
}
else
{
msg = returnFieldsString( comp );
fprintf( m_outFile, "%s\n", TO_UTF8( msg ) );
}
}
// Print the last line:
if( groupRefs )
{
msg.Empty();
switch( amount )
{
case 1:
msg << cmpNameFirst << strPred << (wxChar)m_separatorSymbol << amount;
break;
case 2:
msg << cmpNameFirst << wxT(",") << cmpNameLast
<< strPred << (wxChar)m_separatorSymbol << amount;
break;
default:
msg << cmpNameFirst << wxT("..") << cmpNameFirst << cmpNameLast
<< strPred << (wxChar)m_separatorSymbol << amount;
break;
}
fprintf( m_outFile, "%s\n", TO_UTF8( msg ) );
}
return true;
}
/* PrintComponentsListByValue
* print the list of components, sorted by value, one line per component
* param aFile = the file to write to (will be NOT closed)
* not useable for csv format (use CreateCsvBOMListByValues instead)
* format:
* | 10pF C15 Loc /controle/(X=48,260 mm, Y=83,820 mm); <fields>
* | 10pF C16 Loc /controle/(X=68,580 mm, Y=83,820 mm); <fields>
*/
int BOM_LISTER::PrintComponentsListByValue( FILE* aFile )
{
m_outFile = aFile;
if( m_cmplist.GetCount() == 0 ) // Build component list
{
SCH_SHEET_LIST sheetList;
sheetList.GetComponents( m_cmplist, false );
if( !m_includeSubComponents )
{
// sort component list
m_cmplist.SortByReferenceOnly();
m_cmplist.RemoveSubComponentsFromList();
}
}
m_cmplist.SortByValueOnly();
wxString msg;
msg = _( "\n#Cmp ( order = Value )" );
if( m_includeSubComponents )
msg << _( " (with SubCmp)" );
msg << wxT( "\n" );
fputs( TO_UTF8( msg ), m_outFile );
std::string cmpName;
for( unsigned ii = 0; ii < m_cmplist.GetCount(); ii++ )
{
EDA_ITEM* schItem = m_cmplist[ii].GetComponent();
if( schItem == NULL )
continue;
if( schItem->Type() != SCH_COMPONENT_T )
continue;
SCH_COMPONENT* drawLibItem = (SCH_COMPONENT*) schItem;
bool isMulti = false;
LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( drawLibItem->GetLibName() );
if( entry )
isMulti = entry->IsMulti();
cmpName = m_cmplist[ii].GetRefStr();
if( isMulti && m_includeSubComponents )
// Add unit ident, for mutiple parts per package
cmpName += TO_UTF8( LIB_COMPONENT::ReturnSubReference( m_cmplist[ii].GetUnit() ) );
fprintf( m_outFile, "| %-12s %-10s",
TO_UTF8( drawLibItem->GetField( VALUE )->GetText() ),
cmpName.c_str() );
// print the sheet path and location
if( m_includeSubComponents )
{
msg = returnURLItemLocation( m_cmplist[ii].GetSheetPath().PathHumanReadable(),
drawLibItem->GetPosition() );
fprintf( m_outFile, "%s", TO_UTF8( msg ) );
}
fprintf( m_outFile, "%s\n", TO_UTF8( returnFieldsString( drawLibItem ) ) );
}
msg = _( "#End Cmp\n" );
fputs( TO_UTF8( msg ), m_outFile );
return 0;
}
/* returnURLItemLocation
* return a formated string to print the full location:
* <sheet name>/( X Y position)
* param aPathName = the full sheet name of item
* param aPosition = a position (in internal units) to print
*/
const wxString BOM_LISTER::returnURLItemLocation( const wxString& aPathName,
wxPoint aPosition )
{
wxString text;
text.Printf( wxT( "Loc %s(X=%s, Y=%s)" ), GetChars( aPathName ),
GetChars( ReturnStringFromValue( g_UserUnit, aPosition.x, true ) ),
GetChars( ReturnStringFromValue( g_UserUnit, aPosition.y, true ) ) );
return text;
}
...@@ -33,75 +33,132 @@ ...@@ -33,75 +33,132 @@
#include <wxEeschemaStruct.h> #include <wxEeschemaStruct.h>
#include <class_drawpanel.h> #include <class_drawpanel.h>
#include <annotate_dialog.h> #include <invoke_a_dialog.h>
#include <dialog_annotate_base.h>
#define KEY_ANNOTATE_SORT_OPTION wxT( "AnnotateSortOption" )
#define KEY_ANNOTATE_ALGO_OPTION wxT( "AnnotateAlgoOption" )
#define KEY_ANNOTATE_AUTOCLOSE_OPTION wxT( "AnnotateAutoCloseOption" )
#define KEY_ANNOTATE_USE_SILENTMODE wxT( "AnnotateSilentMode" )
class wxConfig;
/**
* Class DIALOG_ANNOTATE
*/
class DIALOG_ANNOTATE: public DIALOG_ANNOTATE_BASE
{
public:
DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent );
private:
SCH_EDIT_FRAME* m_Parent;
wxConfig* m_Config;
/// Initialises member variables
void InitValues();
void OnCancelClick( wxCommandEvent& event );
void OnClearAnnotationCmpClick( wxCommandEvent& event );
void OnApplyClick( wxCommandEvent& event );
// User functions:
bool GetLevel();
bool GetResetItems();
/**
* Function GetSortOrder
* @return 0 if annotation by X position,
* 1 if annotation by Y position,
* 2 if annotation by value
*/
int GetSortOrder();
/**
* Function GetAnnotateAlgo
* @return 0 if annotation using first not used Id value
* 1 if annotation using first not used Id value inside sheet num * 100 to sheet num * 100 + 99
* 2 if annotation using first nhot used Id value inside sheet num * 1000 to sheet num * 1000 + 999
*/
int GetAnnotateAlgo();
bool GetAnnotateAutoCloseOpt()
{
return m_cbAutoCloseDlg->GetValue();
}
bool GetAnnotateSilentMode()
{
return m_cbUseSilentMode->GetValue();
}
};
#define KEY_ANNOTATE_SORT_OPTION wxT("AnnotateSortOption")
#define KEY_ANNOTATE_ALGO_OPTION wxT("AnnotateAlgoOption")
#define KEY_ANNOTATE_AUTOCLOSE_OPTION wxT("AnnotateAutoCloseOption")
#define KEY_ANNOTATE_USE_SILENTMODE wxT("AnnotateSilentMode")
DIALOG_ANNOTATE::DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent ) DIALOG_ANNOTATE::DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent )
: DIALOG_ANNOTATE_BASE( parent ) : DIALOG_ANNOTATE_BASE( parent )
{ {
m_Parent = parent; m_Parent = parent;
InitValues(); InitValues();
Layout(); Layout();
GetSizer()->SetSizeHints(this); GetSizer()->SetSizeHints( this );
Centre(); Centre();
} }
/*********************************/
void DIALOG_ANNOTATE::InitValues() void DIALOG_ANNOTATE::InitValues()
/*********************************/
{ {
m_Config = wxGetApp().GetSettings(); m_Config = wxGetApp().GetSettings();
SetFocus(); // needed to close dialog by escape key
if( m_Config ) if( m_Config )
{ {
long option; long option;
m_Config->Read(KEY_ANNOTATE_SORT_OPTION, &option, 0l);
m_Config->Read( KEY_ANNOTATE_SORT_OPTION, &option, 0l );
switch( option ) switch( option )
{ {
default: default:
case 0: case 0:
m_rbSortBy_X_Position->SetValue(1); m_rbSortBy_X_Position->SetValue( 1 );
break; break;
case 1: case 1:
m_rbSortBy_Y_Position->SetValue(1); m_rbSortBy_Y_Position->SetValue( 1 );
break; break;
case 2: case 2:
m_rbUseIncremental->SetValue(1); m_rbUseIncremental->SetValue( 1 );
break; break;
} }
m_Config->Read(KEY_ANNOTATE_ALGO_OPTION, &option, 0l); m_Config->Read( KEY_ANNOTATE_ALGO_OPTION, &option, 0l );
switch( option ) switch( option )
{ {
default: default:
case 0: case 0:
m_rbUseIncremental->SetValue(1); m_rbUseIncremental->SetValue( 1 );
break; break;
case 1: case 1:
m_rbUseSheetNum->SetValue(1); m_rbUseSheetNum->SetValue( 1 );
break; break;
case 2: case 2:
m_rbStartSheetNumLarge->SetValue(1); m_rbStartSheetNumLarge->SetValue( 1 );
break; break;
} }
m_Config->Read(KEY_ANNOTATE_AUTOCLOSE_OPTION, &option, 0l); m_Config->Read( KEY_ANNOTATE_AUTOCLOSE_OPTION, &option, 0l );
if( option ) if( option )
m_cbAutoCloseDlg->SetValue(1); m_cbAutoCloseDlg->SetValue( 1 );
m_Config->Read(KEY_ANNOTATE_USE_SILENTMODE, &option, 0l); m_Config->Read( KEY_ANNOTATE_USE_SILENTMODE, &option, 0l );
if( option ) if( option )
m_cbUseSilentMode->SetValue(1); m_cbUseSilentMode->SetValue( 1 );
} }
annotate_down_right_bitmap->SetBitmap( KiBitmap( annotate_down_right_xpm ) ); annotate_down_right_bitmap->SetBitmap( KiBitmap( annotate_down_right_xpm ) );
...@@ -111,19 +168,17 @@ void DIALOG_ANNOTATE::InitValues() ...@@ -111,19 +168,17 @@ void DIALOG_ANNOTATE::InitValues()
} }
/*********************************************************/
void DIALOG_ANNOTATE::OnApplyClick( wxCommandEvent& event ) void DIALOG_ANNOTATE::OnApplyClick( wxCommandEvent& event )
/*********************************************************/
{ {
int response; int response;
wxString message; wxString message;
if( m_Config ) if( m_Config )
{ {
m_Config->Write(KEY_ANNOTATE_SORT_OPTION, GetSortOrder()); m_Config->Write( KEY_ANNOTATE_SORT_OPTION, GetSortOrder() );
m_Config->Write(KEY_ANNOTATE_ALGO_OPTION, GetAnnotateAlgo()); m_Config->Write( KEY_ANNOTATE_ALGO_OPTION, GetAnnotateAlgo() );
m_Config->Write(KEY_ANNOTATE_AUTOCLOSE_OPTION, GetAnnotateAutoCloseOpt()); m_Config->Write( KEY_ANNOTATE_AUTOCLOSE_OPTION, GetAnnotateAutoCloseOpt() );
m_Config->Write(KEY_ANNOTATE_USE_SILENTMODE, GetAnnotateSilentMode()); m_Config->Write( KEY_ANNOTATE_USE_SILENTMODE, GetAnnotateSilentMode() );
} }
// Display a message info in verbose mode, // Display a message info in verbose mode,
...@@ -152,7 +207,7 @@ void DIALOG_ANNOTATE::OnApplyClick( wxCommandEvent& event ) ...@@ -152,7 +207,7 @@ void DIALOG_ANNOTATE::OnApplyClick( wxCommandEvent& event )
{ {
response = wxMessageBox( message, wxT( "" ), wxICON_EXCLAMATION | wxOK | wxCANCEL ); response = wxMessageBox( message, wxT( "" ), wxICON_EXCLAMATION | wxOK | wxCANCEL );
if (response == wxCANCEL) if( response == wxCANCEL )
return; return;
} }
...@@ -176,13 +231,11 @@ void DIALOG_ANNOTATE::OnApplyClick( wxCommandEvent& event ) ...@@ -176,13 +231,11 @@ void DIALOG_ANNOTATE::OnApplyClick( wxCommandEvent& event )
} }
/************************************************************************/
void DIALOG_ANNOTATE::OnClearAnnotationCmpClick( wxCommandEvent& event ) void DIALOG_ANNOTATE::OnClearAnnotationCmpClick( wxCommandEvent& event )
/************************************************************************/
{ {
int response; int response;
wxString message;
wxString message;
if( GetLevel() ) if( GetLevel() )
message = _( "Clear the existing annotation for the entire schematic?" ); message = _( "Clear the existing annotation for the entire schematic?" );
else else
...@@ -191,19 +244,17 @@ void DIALOG_ANNOTATE::OnClearAnnotationCmpClick( wxCommandEvent& event ) ...@@ -191,19 +244,17 @@ void DIALOG_ANNOTATE::OnClearAnnotationCmpClick( wxCommandEvent& event )
message += _( "\n\nThis operation will clear the existing annotation and cannot be undone." ); message += _( "\n\nThis operation will clear the existing annotation and cannot be undone." );
response = wxMessageBox( message, wxT( "" ), wxICON_EXCLAMATION | wxOK | wxCANCEL ); response = wxMessageBox( message, wxT( "" ), wxICON_EXCLAMATION | wxOK | wxCANCEL );
if (response == wxCANCEL) if( response == wxCANCEL )
return; return;
m_Parent->DeleteAnnotation( GetLevel() ? false : true ); m_Parent->DeleteAnnotation( GetLevel() ? false : true );
m_Parent->GetCanvas()->Refresh(); m_Parent->GetCanvas()->Refresh();
m_btnClear->Enable(false); m_btnClear->Enable( false );
} }
/************************************************************/
void DIALOG_ANNOTATE::OnCancelClick( wxCommandEvent& event ) void DIALOG_ANNOTATE::OnCancelClick( wxCommandEvent& event )
/************************************************************/
{ {
if( IsModal() ) if( IsModal() )
EndModal( wxID_CANCEL ); EndModal( wxID_CANCEL );
...@@ -215,44 +266,46 @@ void DIALOG_ANNOTATE::OnCancelClick( wxCommandEvent& event ) ...@@ -215,44 +266,46 @@ void DIALOG_ANNOTATE::OnCancelClick( wxCommandEvent& event )
} }
/**************************************/ bool DIALOG_ANNOTATE::GetLevel()
bool DIALOG_ANNOTATE::GetLevel( void )
/**************************************/
{ {
return m_rbEntireSchematic->GetValue(); return m_rbEntireSchematic->GetValue();
} }
/******************************************/
bool DIALOG_ANNOTATE::GetResetItems( void ) bool DIALOG_ANNOTATE::GetResetItems()
/******************************************/
{ {
return m_rbResetAnnotation->GetValue(); return m_rbResetAnnotation->GetValue();
} }
int DIALOG_ANNOTATE::GetSortOrder( void )
/** int DIALOG_ANNOTATE::GetSortOrder()
* @return 0 if annotation by X position,
* 1 if annotation by Y position,
* 2 if annotation by value
*/
{ {
if ( m_rbSortBy_X_Position->GetValue() ) if( m_rbSortBy_X_Position->GetValue() )
return 0; return 0;
if ( m_rbSortBy_Y_Position->GetValue() )
if( m_rbSortBy_Y_Position->GetValue() )
return 1; return 1;
return 2; return 2;
} }
int DIALOG_ANNOTATE::GetAnnotateAlgo( void )
/** int DIALOG_ANNOTATE::GetAnnotateAlgo()
* @return 0 if annotation using first not used Id value
* 1 if annotation using first not used Id value inside sheet num * 100 to sheet num * 100 + 99
* 2 if annotation using first nhot used Id value inside sheet num * 1000 to sheet num * 1000 + 999
*/
{ {
if ( m_rbUseIncremental->GetValue() ) if( m_rbUseIncremental->GetValue() )
return 0; return 0;
if ( m_rbUseSheetNum->GetValue() )
if( m_rbUseSheetNum->GetValue() )
return 1; return 1;
return 2; return 2;
} }
int InvokeDialogAnnotate( SCH_EDIT_FRAME* aCaller )
{
DIALOG_ANNOTATE dlg( aCaller );
return dlg.ShowModal();
}
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file dialog_build_BOM.cpp
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <confirm.h>
#include <gestfich.h>
#include <kicad_string.h>
#include <class_sch_screen.h>
#include <wxstruct.h>
#include <build_version.h>
#include <netlist.h>
#include <template_fieldnames.h>
#include <sch_component.h>
#include <sch_sheet.h>
#include <class_library.h>
#include <wx/valgen.h>
#include <dialog_build_BOM.h>
#include <BOM_lister.h>
/* Local variables */
static bool s_ListByRef = true;
static bool s_ListByValue = true;
static bool s_ListWithSubCmponents;
static bool s_ListHierarchicalPinByName;
static bool s_ListHierarchicalPinBySheet;
static bool s_BrowseCreatedList;
static int s_OutputFormOpt;
static int s_OutputSeparatorOpt;
static bool s_Add_Location = false;
static bool s_Add_FpField_state = true;
static bool s_Add_DatasheetField_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_Add_Alls_state;
static char s_ExportSeparatorSymbol;
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,
&s_Add_Alls_state,
&s_Add_DatasheetField_state,
NULL
};
const wxString OPTION_BOM_LIST_REF( wxT("BomListPerRef") );
const wxString OPTION_BOM_LIST_VALUE( wxT("BomListPerValue") );
const wxString OPTION_BOM_LIST_HPINS( wxT("BomListPerHPins") );
const wxString OPTION_BOM_LIST_HPINS_BY_SHEET( wxT("BomListHPinsPerSheet") );
const wxString OPTION_BOM_LIST_HPINS_BY_NAME_( wxT("BomListHPinsPerName") );
const wxString OPTION_BOM_LIST_SUB_CMP( wxT("BomListSubCmps") );
const wxString OPTION_BOM_FORMAT( wxT("BomFormat") );
const wxString OPTION_BOM_LAUNCH_BROWSER( wxT("BomLaunchBrowser") );
const wxString OPTION_BOM_SEPARATOR( wxT("BomExportSeparator") );
const wxString OPTION_BOM_ADD_FIELD ( wxT("BomAddField") );
const wxString OPTION_BOM_ADD_LOCATION ( wxT("BomAddLocation") );
/* list of separators used in bom export to spreadsheet
* (selected by s_OutputSeparatorOpt, and s_OutputSeparatorOpt radiobox)
*/
static char s_ExportSeparator[] = ("\t;,.");
/*!
* DIALOG_BUILD_BOM dialog type definition
*/
DIALOG_BUILD_BOM::DIALOG_BUILD_BOM( EDA_DRAW_FRAME* parent ) :
DIALOG_BUILD_BOM_BASE( parent )
{
m_config = wxGetApp().GetSettings();
wxASSERT( m_config != NULL );
m_parent = parent;
Init();
if( GetSizer() )
{
GetSizer()->SetSizeHints( this );
}
Centre();
}
/*!
* Init Controls for DIALOG_BUILD_BOM
*/
void DIALOG_BUILD_BOM::Init()
{
SetFocus();
/* Get options */
m_config->Read( OPTION_BOM_LIST_REF, &s_ListByRef );
m_config->Read( OPTION_BOM_LIST_VALUE , &s_ListByValue );
m_config->Read( OPTION_BOM_LIST_HPINS, &s_ListHierarchicalPinByName );
m_config->Read( OPTION_BOM_LIST_HPINS_BY_SHEET, &s_ListWithSubCmponents );
m_config->Read( OPTION_BOM_LIST_HPINS_BY_NAME_, &s_ListWithSubCmponents );
m_config->Read( OPTION_BOM_LIST_SUB_CMP, &s_ListWithSubCmponents );
m_config->Read( OPTION_BOM_LIST_HPINS_BY_SHEET, &s_ListHierarchicalPinBySheet );
m_config->Read( OPTION_BOM_LIST_HPINS_BY_NAME_, &s_ListHierarchicalPinByName );
s_OutputFormOpt = m_config->Read( OPTION_BOM_FORMAT, 0l );
m_config->Read( OPTION_BOM_LAUNCH_BROWSER, &s_BrowseCreatedList );
s_OutputSeparatorOpt = m_config->Read( OPTION_BOM_SEPARATOR, 0l );
m_config->Read( OPTION_BOM_ADD_LOCATION, &s_Add_Location );
long addfields = m_config->Read( OPTION_BOM_ADD_FIELD, 0l );
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;
}
// Set validators
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_ListHierarchicalPinBySheet ) );
m_OutputFormCtrl->SetValidator( wxGenericValidator( &s_OutputFormOpt ) );
m_OutputSeparatorCtrl->SetValidator( wxGenericValidator( &s_OutputSeparatorOpt ) );
m_GetListBrowser->SetValidator( wxGenericValidator( &s_BrowseCreatedList ) );
m_AddLocationField->SetValidator( wxGenericValidator( &s_Add_Location ) );
m_AddFootprintField->SetValidator( wxGenericValidator( &s_Add_FpField_state ) );
m_AddDatasheetField->SetValidator( wxGenericValidator( &s_Add_DatasheetField_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 ) );
m_AddAllFields->SetValidator( wxGenericValidator( &s_Add_Alls_state ) );
m_OutputFormCtrl->SetSelection( s_OutputFormOpt );
m_OutputSeparatorCtrl->SetSelection( s_OutputSeparatorOpt );
// Enable/disable options:
wxCommandEvent dummy;
OnRadioboxSelectFormatSelected( dummy );
}
/*
* Called on BOM format selection:
* Enable/disable options in dialog
*/
void DIALOG_BUILD_BOM::OnRadioboxSelectFormatSelected( wxCommandEvent& event )
{
switch( m_OutputFormCtrl->GetSelection() )
{
case 0: // Human readable text full report
m_OutputSeparatorCtrl->Enable( false );
m_ListCmpbyRefItems->Enable( true );
m_ListCmpbyValItems->Enable( true );
m_GenListLabelsbyVal->Enable( true );
m_GenListLabelsbySheet->Enable( true );
m_ListSubCmpItems->Enable( true );
m_AddLocationField->Enable( true );
break;
case 1: // Csv format, full list by reference
m_OutputSeparatorCtrl->Enable( true );
m_ListCmpbyRefItems->Enable( false );
m_ListCmpbyValItems->Enable( false );
m_GenListLabelsbyVal->Enable( false );
m_GenListLabelsbySheet->Enable( false );
m_ListSubCmpItems->Enable( true );
m_AddLocationField->Enable( true );
break;
case 2: // Csv format, grouped list by reference
m_OutputSeparatorCtrl->Enable( true );
m_ListCmpbyRefItems->Enable( false );
m_ListCmpbyValItems->Enable( false );
m_GenListLabelsbyVal->Enable( false );
m_GenListLabelsbySheet->Enable( false );
m_ListSubCmpItems->Enable( false );
m_AddLocationField->Enable( false );
break;
case 3: // Csv format, short list by values
m_OutputSeparatorCtrl->Enable( true );
m_ListCmpbyRefItems->Enable( false );
m_ListCmpbyValItems->Enable( false );
m_GenListLabelsbyVal->Enable( false );
m_GenListLabelsbySheet->Enable( false );
m_ListSubCmpItems->Enable( false );
m_AddLocationField->Enable( false );
break;
}
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
*/
void DIALOG_BUILD_BOM::OnOkClick( wxCommandEvent& event )
{
char ExportSeparatorSymbol = s_ExportSeparator[0];
if( m_OutputSeparatorCtrl->GetSelection() > 0 )
ExportSeparatorSymbol = s_ExportSeparator[m_OutputSeparatorCtrl->GetSelection()];
int ExportFileType = m_OutputFormCtrl->GetSelection();
SavePreferences();
Create_BOM_Lists( ExportFileType, m_ListSubCmpItems->GetValue(),
ExportSeparatorSymbol, m_GetListBrowser->GetValue() );
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
*/
void DIALOG_BUILD_BOM::OnCancelClick( wxCommandEvent& event )
{
EndModal( -1 );
}
void DIALOG_BUILD_BOM::SavePreferences()
{
// Determine current settings of "List items" and "Options" checkboxes
s_ListByRef = m_ListCmpbyRefItems->GetValue();
s_ListWithSubCmponents = m_ListSubCmpItems->GetValue();
s_ListByValue = m_ListCmpbyValItems->GetValue();
s_ListHierarchicalPinByName = m_GenListLabelsbyVal->GetValue();
s_ListHierarchicalPinBySheet = m_GenListLabelsbySheet->GetValue();
s_BrowseCreatedList = m_GetListBrowser->GetValue();
// (saved in config ):
// 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 "Fields to add" checkboxes
s_Add_Location = m_AddLocationField->GetValue();
s_Add_FpField_state = m_AddFootprintField->GetValue();
s_Add_DatasheetField_state = m_AddDatasheetField->GetValue();
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();
s_Add_Alls_state = m_AddAllFields->GetValue();
// Now save current settings of both radiobutton groups
m_config->Write( OPTION_BOM_LIST_REF, s_ListByRef );
m_config->Write( OPTION_BOM_LIST_VALUE , s_ListByValue );
m_config->Write( OPTION_BOM_LIST_HPINS, s_ListHierarchicalPinByName );
m_config->Write( OPTION_BOM_LIST_HPINS_BY_SHEET, s_ListHierarchicalPinBySheet );
m_config->Write( OPTION_BOM_LIST_HPINS_BY_NAME_, s_ListHierarchicalPinByName );
m_config->Write( OPTION_BOM_LIST_SUB_CMP, s_ListWithSubCmponents );
m_config->Write( OPTION_BOM_FORMAT, (long) s_OutputFormOpt );
m_config->Write( OPTION_BOM_SEPARATOR, (long) s_OutputSeparatorOpt );
m_config->Write( OPTION_BOM_LAUNCH_BROWSER, (long) s_BrowseCreatedList );
// Now save current settings of all "Fields to add" checkboxes
m_config->Write( OPTION_BOM_ADD_LOCATION, s_Add_Location );
long addfields = 0;
for( int ii = 0, bitmask = 1; s_AddFieldList[ii] != NULL; ii++ )
{
if( *s_AddFieldList[ii] )
addfields |= bitmask;
bitmask <<= 1;
}
m_config->Write( OPTION_BOM_ADD_FIELD, addfields );
}
void DIALOG_BUILD_BOM::Create_BOM_Lists( int aTypeFile,
bool aIncludeSubComponents,
char aExportSeparatorSymbol,
bool aRunBrowser )
{
wxString wildcard;
static wxFileName fn;
wxFileName current = g_RootSheet->GetScreen()->GetFileName();
s_ExportSeparatorSymbol = aExportSeparatorSymbol;
if( !fn.HasName() || fn.GetName()==NAMELESS_PROJECT )
{
fn.SetName( current.GetName() );
}
// else use a previous run's name, because fn was set before and user
// is probably just iteratively refining the BOM.
if( fn.GetPath().IsEmpty() )
{
fn.SetPath( current.GetPath() );
}
// else use a previous run's path, because fn was set before and user
// is probably just iteratively refining the BOM.
wxString bomDesc = _( "Bill of Materials" ); // translate once, use twice.
if( aTypeFile == 0 )
{
fn.SetExt( wxT( "lst" ) );
wildcard = bomDesc + wxT( " (*.lst)|*.lst" );
}
else
{
fn.SetExt( wxT( "csv" ) );
wildcard = bomDesc + wxT( " (*.csv)|*.csv" );
}
wxFileDialog dlg( this, bomDesc, fn.GetPath(),
fn.GetFullName(), wildcard, wxFD_SAVE );
if( dlg.ShowModal() == wxID_CANCEL )
return;
fn = dlg.GetPath(); // remember path+filename+ext for subsequent runs.
m_listFileName = dlg.GetPath();
// Close dialog, then show the list (if so requested)
switch( aTypeFile )
{
case 0: // list
CreatePartsAndLabelsFullList( aIncludeSubComponents );
break;
case 1: // spreadsheet, Single Part per line
CreateSpreadSheetPartsFullList( aIncludeSubComponents, s_Add_Location, false );
break;
case 2: // spreadsheet, group Part with same fields per line
CreateSpreadSheetPartsFullList( aIncludeSubComponents, s_Add_Location, true );
break;
case 3: // spreadsheet, one value per line and no sub-component
CreateSpreadSheetPartsShortList();
break;
}
EndModal( 1 );
if( aRunBrowser )
{
wxString editorname = wxGetApp().GetEditorName();
wxString filename = m_listFileName;
AddDelimiterString( filename );
ExecuteFile( this, editorname, filename );
}
}
/** Helper function IsFieldChecked
* return the state of the wxCheckbox corresponding to the
* field aFieldId (FOOTPRINT, DATASHEET and FIELD1 to FIELD8
* if the option "All user fields" is checked, return always true
* for fileds ids >= FIELD1
* @param aFieldId = the field id : FOOTPRINT to FIELD8
*/
bool DIALOG_BUILD_BOM::IsFieldChecked(int aFieldId)
{
if( m_AddAllFields->IsChecked() && (aFieldId>= FIELD1) )
return true;
switch ( aFieldId )
{
case FIELD1:
return m_AddField1->IsChecked();
case FIELD2:
return m_AddField2->IsChecked();
case FIELD3:
return m_AddField3->IsChecked();
case FIELD4:
return m_AddField4->IsChecked();
case FIELD5:
return m_AddField5->IsChecked();
case FIELD6:
return m_AddField6->IsChecked();
case FIELD7:
return m_AddField7->IsChecked();
case FIELD8:
return m_AddField8->IsChecked();
case FOOTPRINT:
return m_AddFootprintField->IsChecked();
case DATASHEET:
return m_AddDatasheetField->IsChecked();
}
return false;
}
/* Prints a list of components, in a form which can be imported by a spreadsheet.
* components having the same value and the same footprint
* are grouped on the same line
* Form is:
* value; number of components; list of references; <footprint>; <field1>; ...;
* list is sorted by values
*/
void DIALOG_BUILD_BOM::CreateSpreadSheetPartsShortList( )
{
FILE* f;
if( ( f = wxFopen( m_listFileName, wxT( "wt" ) ) ) == NULL )
{
wxString msg;
msg.Printf( _( "Failed to open file <%s>" ), GetChars(m_listFileName) );
DisplayError( this, msg );
return;
}
BOM_LISTER bom_lister;
bom_lister.SetCvsFormOn( s_ExportSeparatorSymbol );
// Set the list of fields to add to list
for( int ii = FOOTPRINT; ii <= FIELD8; ii++ )
if( IsFieldChecked( ii ) )
bom_lister.AddFieldIdToPrintList( ii );
// Write the list of components grouped by values:
bom_lister.CreateCsvBOMListByValues( f );
}
/*
* Print a list of components, in a form which can be imported by a spreadsheet
* form is:
* cmp ref; cmp val; fields;
* Components are sorted by reference
* param aIncludeSubComponents = true to print sub components
* param aPrintLocation = true to print components location
* (only possible when aIncludeSubComponents == true)
* param aGroupRefs = true to group components references, when other fieds
* have the same value
*/
void DIALOG_BUILD_BOM::CreateSpreadSheetPartsFullList( bool aIncludeSubComponents,
bool aPrintLocation,
bool aGroupRefs )
{
FILE* f;
wxString msg;
if( ( f = wxFopen( m_listFileName, wxT( "wt" ) ) ) == NULL )
{
msg.Printf( _( "Failed to open file <%s>" ), GetChars( m_listFileName ) );
DisplayError( this, msg );
return;
}
BOM_LISTER bom_lister;
bom_lister.SetCvsFormOn( s_ExportSeparatorSymbol );
// Set group refs option (hight priority):
// Obvioulsy only useful when not including sub-components
bom_lister.SetGroupReferences( aGroupRefs );
bom_lister.SetIncludeSubCmp( aIncludeSubComponents && !aGroupRefs );
// Set print location option:
// Obvioulsy only possible when including sub components
// and not grouping references
bom_lister.SetPrintLocation( aPrintLocation && !aGroupRefs &&
aIncludeSubComponents );
// Set the list of fields to add to list
for( int ii = FOOTPRINT; ii <= FIELD8; ii++ )
if( IsFieldChecked( ii ) )
bom_lister.AddFieldIdToPrintList( ii );
// create the file
bom_lister.PrintComponentsListByReferenceCsvForm( f );
fclose( f );
}
/*
* CreatePartsAndLabelsFullList()
* Main function to create the list of components and/or labels
* (global labels, hierarchical labels and pin sheets )
*/
void DIALOG_BUILD_BOM::CreatePartsAndLabelsFullList( bool aIncludeSubComponents )
{
FILE* f;
wxString msg;
if( ( f = wxFopen( m_listFileName, wxT( "wt" ) ) ) == NULL )
{
msg.Printf( _( "Failed to open file <%s>" ), GetChars( m_listFileName ) );
DisplayError( this, msg );
return;
}
BOM_LISTER bom_lister;
bom_lister.SetIncludeSubCmp( aIncludeSubComponents );
bom_lister.SetCvsFormOff();
bom_lister.SetPrintLocation( s_Add_Location );
// Set the list of fields to add to list
for( int ii = FOOTPRINT; ii <= FIELD8; ii++ )
if( IsFieldChecked( ii ) )
bom_lister.AddFieldIdToPrintList( ii );
// creates the list file
wxString Title = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion();
fprintf( f, "%s >> Creation date: %s\n", TO_UTF8( Title ), TO_UTF8( DateAndTime() ) );
if( m_ListCmpbyRefItems->GetValue() )
bom_lister.PrintComponentsListByReferenceHumanReadable( f );
if( m_ListCmpbyValItems->GetValue() )
bom_lister.PrintComponentsListByValue( f );
// Create list of global labels, hierachical labels and pins sheets
if( m_GenListLabelsbySheet->GetValue() )
bom_lister.PrintGlobalAndHierarchicalLabelsList( f, true );
if( m_GenListLabelsbyVal->GetValue() )
bom_lister.PrintGlobalAndHierarchicalLabelsList( f, false );
msg = _( "\n#End List\n" );
fprintf( f, "%s", TO_UTF8( msg ) );
fclose( f );
}
/**
* @file dialog_build_BOM.h
*/
/* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef _DIALOG_BUILD_BOM_H_
#define _DIALOG_BUILD_BOM_H_
#include <dialog_build_BOM_base.h>
class EDA_DRAW_FRAME;
class SCH_COMPONENT;
class wxConfig;
class DIALOG_BUILD_BOM : public DIALOG_BUILD_BOM_BASE
{
private:
EDA_DRAW_FRAME* m_parent;
wxConfig* m_config;
wxString m_listFileName; // The full filename of the file report.
private:
void OnRadioboxSelectFormatSelected( wxCommandEvent& event );
void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
void SavePreferences();
void Init();
void Create_BOM_Lists( int aTypeFile,
bool aIncludeSubComponents,
char aExportSeparatorSymbol,
bool aRunBrowser );
void CreatePartsAndLabelsFullList( bool aIncludeSubComponents );
/**
* Function CreateSpreadSheetPartsFullList
* prints a list of components, in a form which can be imported by a
* spreadsheet. Form is:
* reference; cmp value; \<footprint\>; \<field1\>; ...;
* Components are sorted by reference
* @param aIncludeSubComponents = true to print sub components
* @param aPrintLocation = true to print components location
* (only possible when aIncludeSubComponents == true)
* @param aGroupRefs = true to group components references, when other fieds
* have the same value
*/
void CreateSpreadSheetPartsFullList( bool aIncludeSubComponents,
bool aPrintLocation,
bool aGroupRefs );
/**
* Function CreateSpreadSheetPartsShortList
* prints a list of components, in a form which can be imported by a spreadsheet.
* components having the same value and the same footprint
* are grouped on the same line
* Form is:
* value; number of components; list of references; \<footprint\>; \<field1\>; ...;
* list is sorted by values
*/
void CreateSpreadSheetPartsShortList();
bool IsFieldChecked( int aFieldId );
public:
DIALOG_BUILD_BOM( EDA_DRAW_FRAME* parent );
// ~DIALOG_BUILD_BOM() {};
};
#endif // _DIALOG_BUILD_BOM_H_
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_build_BOM_base.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_BUILD_BOM_BASE::DIALOG_BUILD_BOM_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bMainSizer;
bMainSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizerUpper;
bSizerUpper = new wxBoxSizer( wxHORIZONTAL );
wxStaticBoxSizer* sbOptionsSizer;
sbOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options:") ), wxVERTICAL );
wxStaticBoxSizer* sbListOptionsSizer;
sbListOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("List items:") ), wxVERTICAL );
m_ListCmpbyRefItems = new wxCheckBox( this, wxID_ANY, _("Components by reference"), wxDefaultPosition, wxDefaultSize, 0 );
sbListOptionsSizer->Add( m_ListCmpbyRefItems, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_ListSubCmpItems = new wxCheckBox( this, wxID_ANY, _("Sub components (i.e. U2A, U2B ...)"), wxDefaultPosition, wxDefaultSize, 0 );
sbListOptionsSizer->Add( m_ListSubCmpItems, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_ListCmpbyValItems = new wxCheckBox( this, wxID_ANY, _("Components by value"), wxDefaultPosition, wxDefaultSize, 0 );
sbListOptionsSizer->Add( m_ListCmpbyValItems, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_GenListLabelsbyVal = new wxCheckBox( this, wxID_ANY, _("Hierarchical pins by name"), wxDefaultPosition, wxDefaultSize, 0 );
sbListOptionsSizer->Add( m_GenListLabelsbyVal, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_GenListLabelsbySheet = new wxCheckBox( this, wxID_ANY, _("Hierarchical pins by sheet"), wxDefaultPosition, wxDefaultSize, 0 );
sbListOptionsSizer->Add( m_GenListLabelsbySheet, 0, wxALL, 5 );
sbOptionsSizer->Add( sbListOptionsSizer, 0, wxEXPAND, 5 );
wxString m_OutputFormCtrlChoices[] = { _("List"), _("List for spreadsheet import (by ref)"), _("List for spreadsheet import (by grouped ref)"), _("List for spreadsheet import (by value)") };
int m_OutputFormCtrlNChoices = sizeof( m_OutputFormCtrlChoices ) / sizeof( wxString );
m_OutputFormCtrl = new wxRadioBox( this, ID_RADIOBOX_SELECT_FORMAT, _("Output format:"), wxDefaultPosition, wxDefaultSize, m_OutputFormCtrlNChoices, m_OutputFormCtrlChoices, 1, wxRA_SPECIFY_COLS );
m_OutputFormCtrl->SetSelection( 1 );
sbOptionsSizer->Add( m_OutputFormCtrl, 0, wxEXPAND|wxTOP, 5 );
wxString m_OutputSeparatorCtrlChoices[] = { _("Tab"), _(";"), _(",") };
int m_OutputSeparatorCtrlNChoices = sizeof( m_OutputSeparatorCtrlChoices ) / sizeof( wxString );
m_OutputSeparatorCtrl = new wxRadioBox( this, wxID_ANY, _("Field separator for spreadsheet import:"), wxDefaultPosition, wxDefaultSize, m_OutputSeparatorCtrlNChoices, m_OutputSeparatorCtrlChoices, 1, wxRA_SPECIFY_ROWS );
m_OutputSeparatorCtrl->SetSelection( 0 );
sbOptionsSizer->Add( m_OutputSeparatorCtrl, 0, wxEXPAND|wxTOP, 5 );
m_GetListBrowser = new wxCheckBox( this, wxID_ANY, _("Launch list browser"), wxDefaultPosition, wxDefaultSize, 0 );
sbOptionsSizer->Add( m_GetListBrowser, 0, wxALL|wxEXPAND, 5 );
bSizerUpper->Add( sbOptionsSizer, 3, wxALL|wxEXPAND, 5 );
wxBoxSizer* bRightSizer;
bRightSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* sbAddToListSelectionSizer;
sbAddToListSelectionSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Add to list:") ), wxVERTICAL );
m_AddLocationField = new wxCheckBox( this, wxID_ANY, _("Component location"), wxDefaultPosition, wxDefaultSize, 0 );
sbAddToListSelectionSizer->Add( m_AddLocationField, 0, wxALL, 5 );
wxStaticBoxSizer* sbFixedFieldsSizer;
sbFixedFieldsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("System Fields:") ), wxVERTICAL );
m_AddDatasheetField = new wxCheckBox( this, wxID_ANY, _("Datasheet"), wxDefaultPosition, wxDefaultSize, 0 );
sbFixedFieldsSizer->Add( m_AddDatasheetField, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_AddFootprintField = new wxCheckBox( this, wxID_ANY, _("Footprint"), wxDefaultPosition, wxDefaultSize, 0 );
sbFixedFieldsSizer->Add( m_AddFootprintField, 0, wxALL|wxEXPAND, 5 );
sbAddToListSelectionSizer->Add( sbFixedFieldsSizer, 0, wxEXPAND, 5 );
wxStaticBoxSizer* sbUsersFiledsSizer;
sbUsersFiledsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Users fields:") ), wxVERTICAL );
m_AddField1 = new wxCheckBox( this, wxID_ANY, _("Field 1"), wxDefaultPosition, wxDefaultSize, 0 );
sbUsersFiledsSizer->Add( m_AddField1, 0, wxEXPAND|wxALL, 5 );
m_AddField2 = new wxCheckBox( this, wxID_ANY, _("Field 2"), wxDefaultPosition, wxDefaultSize, 0 );
sbUsersFiledsSizer->Add( m_AddField2, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_AddField3 = new wxCheckBox( this, wxID_ANY, _("Field 3"), wxDefaultPosition, wxDefaultSize, 0 );
sbUsersFiledsSizer->Add( m_AddField3, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_AddField4 = new wxCheckBox( this, wxID_ANY, _("Field 4"), wxDefaultPosition, wxDefaultSize, 0 );
sbUsersFiledsSizer->Add( m_AddField4, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_AddField5 = new wxCheckBox( this, wxID_ANY, _("Field 5"), wxDefaultPosition, wxDefaultSize, 0 );
sbUsersFiledsSizer->Add( m_AddField5, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_AddField6 = new wxCheckBox( this, wxID_ANY, _("Field 6"), wxDefaultPosition, wxDefaultSize, 0 );
sbUsersFiledsSizer->Add( m_AddField6, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_AddField7 = new wxCheckBox( this, wxID_ANY, _("Field 7"), wxDefaultPosition, wxDefaultSize, 0 );
sbUsersFiledsSizer->Add( m_AddField7, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_AddField8 = new wxCheckBox( this, wxID_ANY, _("Field 8"), wxDefaultPosition, wxDefaultSize, 0 );
sbUsersFiledsSizer->Add( m_AddField8, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
sbAddToListSelectionSizer->Add( sbUsersFiledsSizer, 0, wxEXPAND|wxTOP, 5 );
m_AddAllFields = new wxCheckBox( this, wxID_ANY, _("All existing user fields"), wxDefaultPosition, wxDefaultSize, 0 );
sbAddToListSelectionSizer->Add( m_AddAllFields, 0, wxALL, 5 );
bRightSizer->Add( sbAddToListSelectionSizer, 1, wxEXPAND, 5 );
bSizerUpper->Add( bRightSizer, 2, wxALL|wxEXPAND, 5 );
bMainSizer->Add( bSizerUpper, 1, wxEXPAND, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bMainSizer->Add( m_staticline1, 0, wxEXPAND|wxLEFT|wxRIGHT, 5 );
m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
m_sdbSizer->AddButton( m_sdbSizerOK );
m_sdbSizerCancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer->AddButton( m_sdbSizerCancel );
m_sdbSizer->Realize();
bMainSizer->Add( m_sdbSizer, 0, wxALL|wxEXPAND, 5 );
this->SetSizer( bMainSizer );
this->Layout();
bMainSizer->Fit( this );
// Connect Events
m_OutputFormCtrl->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_BUILD_BOM_BASE::OnRadioboxSelectFormatSelected ), NULL, this );
m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BUILD_BOM_BASE::OnCancelClick ), NULL, this );
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BUILD_BOM_BASE::OnOkClick ), NULL, this );
}
DIALOG_BUILD_BOM_BASE::~DIALOG_BUILD_BOM_BASE()
{
// Disconnect Events
m_OutputFormCtrl->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_BUILD_BOM_BASE::OnRadioboxSelectFormatSelected ), NULL, this );
m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BUILD_BOM_BASE::OnCancelClick ), NULL, this );
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BUILD_BOM_BASE::OnOkClick ), NULL, this );
}
This source diff could not be displayed because it is too large. You can view the blob instead.
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_BUILD_BOM_BASE_H__
#define __DIALOG_BUILD_BOM_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/checkbox.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/radiobox.h>
#include <wx/statline.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_BUILD_BOM_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_BUILD_BOM_BASE : public DIALOG_SHIM
{
private:
protected:
enum
{
ID_RADIOBOX_SELECT_FORMAT = 1000
};
wxCheckBox* m_ListCmpbyRefItems;
wxCheckBox* m_ListSubCmpItems;
wxCheckBox* m_ListCmpbyValItems;
wxCheckBox* m_GenListLabelsbyVal;
wxCheckBox* m_GenListLabelsbySheet;
wxRadioBox* m_OutputFormCtrl;
wxRadioBox* m_OutputSeparatorCtrl;
wxCheckBox* m_GetListBrowser;
wxCheckBox* m_AddLocationField;
wxCheckBox* m_AddDatasheetField;
wxCheckBox* m_AddFootprintField;
wxCheckBox* m_AddField1;
wxCheckBox* m_AddField2;
wxCheckBox* m_AddField3;
wxCheckBox* m_AddField4;
wxCheckBox* m_AddField5;
wxCheckBox* m_AddField6;
wxCheckBox* m_AddField7;
wxCheckBox* m_AddField8;
wxCheckBox* m_AddAllFields;
wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnRadioboxSelectFormatSelected( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }
public:
DIALOG_BUILD_BOM_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("List of Materials"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_BUILD_BOM_BASE();
};
#endif //__DIALOG_BUILD_BOM_BASE_H__
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <appl_wxstruct.h> #include <appl_wxstruct.h>
#include <class_sch_screen.h> #include <class_sch_screen.h>
#include <wxEeschemaStruct.h> #include <wxEeschemaStruct.h>
#include <invoke_a_dialog.h>
#include <general.h> #include <general.h>
#include <netlist.h> #include <netlist.h>
...@@ -45,6 +46,7 @@ ...@@ -45,6 +46,7 @@
#include <dialog_erc.h> #include <dialog_erc.h>
#include <dialog_erc_listbox.h> #include <dialog_erc_listbox.h>
#include <erc.h> #include <erc.h>
#include <id.h>
bool DIALOG_ERC::m_writeErcFile = false; bool DIALOG_ERC::m_writeErcFile = false;
...@@ -57,7 +59,10 @@ END_EVENT_TABLE() ...@@ -57,7 +59,10 @@ END_EVENT_TABLE()
DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) : DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) :
DIALOG_ERC_BASE( parent ) DIALOG_ERC_BASE(
parent,
ID_DIALOG_ERC // parent looks for this ID explicitly
)
{ {
m_parent = parent; m_parent = parent;
Init(); Init();
...@@ -564,3 +569,14 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) ...@@ -564,3 +569,14 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
} }
} }
} }
wxDialog* InvokeDialogERC( SCH_EDIT_FRAME* aCaller )
{
// This is a modeless dialog, so new it rather than instantiating on stack.
DIALOG_ERC* dlg = new DIALOG_ERC( aCaller );
dlg->Show( true );
return dlg; // wxDialog is information hiding about DIALOG_ERC.
}
...@@ -50,7 +50,6 @@ ...@@ -50,7 +50,6 @@
#include <sch_sheet.h> #include <sch_sheet.h>
#include <dialog_helpers.h> #include <dialog_helpers.h>
#include <dialog_netlist.h> #include <dialog_netlist.h>
#include <dialogs/annotate_dialog.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
......
...@@ -16,7 +16,35 @@ ...@@ -16,7 +16,35 @@
#include <sch_sheet.h> #include <sch_sheet.h>
#include <sch_sheet_path.h> #include <sch_sheet_path.h>
#include <dialog_print_using_printer.h> #include <invoke_a_dialog.h>
#include <dialog_print_using_printer_base.h>
/**
* Class DIALOG_PRINT_USING_PRINTER
* offers to print a schematic dialog.
*
* Derived from DIALOG_PRINT_USING_PRINTER_base created by wxFormBuilder
*/
class DIALOG_PRINT_USING_PRINTER : public DIALOG_PRINT_USING_PRINTER_BASE
{
public:
DIALOG_PRINT_USING_PRINTER( SCH_EDIT_FRAME* aParent );
SCH_EDIT_FRAME* GetParent() const;
private:
void OnCloseWindow( wxCloseEvent& event );
void OnInitDialog( wxInitDialogEvent& event );
void OnPageSetup( wxCommandEvent& event );
void OnPrintPreview( wxCommandEvent& event );
void OnPrintButtonClick( wxCommandEvent& event );
void OnButtonCancelClick( wxCommandEvent& event ){ Close(); }
void GetPrintOptions();
};
/** /**
...@@ -415,3 +443,11 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen ) ...@@ -415,3 +443,11 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
aScreen->m_DrawOrg = old_org; aScreen->m_DrawOrg = old_org;
aScreen->SetZoom( oldZoom ); aScreen->SetZoom( oldZoom );
} }
int InvokeDialogPrintUsingPrinter( SCH_EDIT_FRAME* aCaller )
{
DIALOG_PRINT_USING_PRINTER dlg( aCaller );
return dlg.ShowModal();
}
#ifndef _DIALOG_PRINT_USING_PRINTER_H_
#define _DIALOG_PRINT_USING_PRINTER_H_
#include <dialog_print_using_printer_base.h>
/**
* Print schematic dialog.
*
* Class derived from DIALOG_PRINT_USING_PRINTER_base created by wxFormBuilder
*/
class DIALOG_PRINT_USING_PRINTER : public DIALOG_PRINT_USING_PRINTER_BASE
{
public:
DIALOG_PRINT_USING_PRINTER( SCH_EDIT_FRAME* aParent );
~DIALOG_PRINT_USING_PRINTER() {};
SCH_EDIT_FRAME* GetParent() const;
private:
void OnCloseWindow( wxCloseEvent& event );
void OnInitDialog( wxInitDialogEvent& event );
void OnPageSetup( wxCommandEvent& event );
void OnPrintPreview( wxCommandEvent& event );
void OnPrintButtonClick( wxCommandEvent& event );
void OnButtonCancelClick( wxCommandEvent& event ){ Close(); }
void GetPrintOptions();
};
#endif // _DIALOG_PRINT_USING_PRINTER_H_
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2013 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -21,51 +23,44 @@ ...@@ -21,51 +23,44 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#ifndef _ANNOTATE_DIALOG_H_ // This header is an insolation layer between top most frames and any number of
#define _ANNOTATE_DIALOG_H_ // DIALOG classes which can be called from a frame window.
// It is a place to put invocation functions for [modal] dialogs, with benefits:
//
// 1) The information about each dialog class is not exposed to the frame.
// So therefore the DIALOG class can often be kept out of a header file entirely.
//
// 2) The information about the calling frame is not necessarily exposed to
// to the called dialog class, at least not in here.
// The actual InvokeDialog<class>() function is usually coded at the bottom of the
// DIALOG_<class>.cpp file.
#include <dialog_annotate_base.h> #ifndef INVOKE_A_DIALOG_H_
#define INVOKE_A_DIALOG_H_
class wxFrame;
class wxDialog;
// Often this is not used in the prototypes, since wxFrame is good enough and would
// represent maximum information hiding.
class SCH_EDIT_FRAME; class SCH_EDIT_FRAME;
class wxConfig;
/*! /// Create and show DIALOG_ANNOTATE and return whatever
* DIALOG_ANNOTATE class declaration /// DIALOG_ANNOTATE::ShowModal() returns.
*/ int InvokeDialogAnnotate( SCH_EDIT_FRAME* aCaller );
class DIALOG_ANNOTATE: public DIALOG_ANNOTATE_BASE /// Create the modeless DIALOG_ERC and show it, return something to
{ /// destroy or close it. The dialog will have ID_DIALOG_ERC from id.h
private: wxDialog* InvokeDialogERC( SCH_EDIT_FRAME* aCaller );
SCH_EDIT_FRAME * m_Parent;
wxConfig* m_Config;
public: /// Create and show DIALOG_PRINT_USING_PRINTER and return whatever
DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent ); /// DIALOG_PRINT_USING_PRINTER::ShowModal() returns.
~DIALOG_ANNOTATE(){}; int InvokeDialogPrintUsingPrinter( SCH_EDIT_FRAME* aCaller );
private:
/// Initialises member variables
void InitValues();
void OnCancelClick( wxCommandEvent& event );
void OnClearAnnotationCmpClick( wxCommandEvent& event );
void OnApplyClick( wxCommandEvent& event );
// User functions:
bool GetLevel( void );
bool GetResetItems( void );
int GetSortOrder( void );
int GetAnnotateAlgo( void );
bool GetAnnotateAutoCloseOpt()
{
return m_cbAutoCloseDlg->GetValue();
}
bool GetAnnotateSilentMode()
{
return m_cbUseSilentMode->GetValue();
}
};
#endif #endif // INVOKE_A_DIALOG_H_
// _ANNOTATE_DIALOG_H_
...@@ -51,10 +51,7 @@ ...@@ -51,10 +51,7 @@
#include <eeschema_config.h> #include <eeschema_config.h>
#include <sch_sheet.h> #include <sch_sheet.h>
#include <dialogs/annotate_dialog.h> #include <invoke_a_dialog.h>
#include <dialogs/dialog_build_BOM.h>
#include <dialogs/dialog_erc.h>
#include <dialogs/dialog_print_using_printer.h>
#include <dialogs/dialog_schematic_find.h> #include <dialogs/dialog_schematic_find.h>
#include <wx/display.h> #include <wx/display.h>
...@@ -200,6 +197,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* aParent, const wxString& aTitle, ...@@ -200,6 +197,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* aParent, const wxString& aTitle,
m_findReplaceData = new wxFindReplaceData( wxFR_DOWN ); m_findReplaceData = new wxFindReplaceData( wxFR_DOWN );
m_undoItem = NULL; m_undoItem = NULL;
m_hasAutoSave = true; m_hasAutoSave = true;
SetForceHVLines( true ); SetForceHVLines( true );
SetDefaultLabelSize( DEFAULT_SIZE_TEXT ); SetDefaultLabelSize( DEFAULT_SIZE_TEXT );
...@@ -244,8 +242,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* aParent, const wxString& aTitle, ...@@ -244,8 +242,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* aParent, const wxString& aTitle,
EDA_PANEINFO mesg; EDA_PANEINFO mesg;
mesg.MessageToolbarPane(); mesg.MessageToolbarPane();
if( m_mainToolBar ) if( m_mainToolBar )
m_auimgr.AddPane( m_mainToolBar, m_auimgr.AddPane( m_mainToolBar,
wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top().Row( 0 ) ); wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top().Row( 0 ) );
...@@ -602,19 +598,19 @@ void SCH_EDIT_FRAME::OnUpdateHiddenPins( wxUpdateUIEvent& aEvent ) ...@@ -602,19 +598,19 @@ void SCH_EDIT_FRAME::OnUpdateHiddenPins( wxUpdateUIEvent& aEvent )
void SCH_EDIT_FRAME::OnAnnotate( wxCommandEvent& event ) void SCH_EDIT_FRAME::OnAnnotate( wxCommandEvent& event )
{ {
DIALOG_ANNOTATE* dlg = new DIALOG_ANNOTATE( this ); InvokeDialogAnnotate( this );
dlg->ShowModal();
dlg->Destroy();
} }
void SCH_EDIT_FRAME::OnErc( wxCommandEvent& event ) void SCH_EDIT_FRAME::OnErc( wxCommandEvent& event )
{ {
DIALOG_ERC* dlg = new DIALOG_ERC( this ); // See if its already open...
wxWindow* erc = FindWindowById( ID_DIALOG_ERC, this );
dlg->Show( true ); if( erc )
// dlg->Destroy(); erc->Raise(); // bring it to the top if already open.
else
InvokeDialogERC( this );
} }
...@@ -827,9 +823,8 @@ void SCH_EDIT_FRAME::SetLanguage( wxCommandEvent& event ) ...@@ -827,9 +823,8 @@ void SCH_EDIT_FRAME::SetLanguage( wxCommandEvent& event )
void SCH_EDIT_FRAME::OnPrint( wxCommandEvent& event ) void SCH_EDIT_FRAME::OnPrint( wxCommandEvent& event )
{ {
wxFileName fn; wxFileName fn;
DIALOG_PRINT_USING_PRINTER dlg( this );
dlg.ShowModal(); InvokeDialogPrintUsingPrinter( this );
fn = g_RootSheet->GetScreen()->GetFileName(); fn = g_RootSheet->GetScreen()->GetFileName();
......
...@@ -241,11 +241,13 @@ enum main_id ...@@ -241,11 +241,13 @@ enum main_id
ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH, ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH,
ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH, ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH,
ID_TB_OPTIONS_SHOW_PADS_SKETCH, ID_TB_OPTIONS_SHOW_PADS_SKETCH,
// zoom commands for non center zooming // zoom commands for non center zooming
ID_OFFCENTER_ZOOM_IN, ID_OFFCENTER_ZOOM_IN,
ID_OFFCENTER_ZOOM_OUT, ID_OFFCENTER_ZOOM_OUT,
ID_DIALOG_ERC, ///< eeschema ERC modeless dialog ID
ID_END_LIST ID_END_LIST
}; };
......
...@@ -115,52 +115,52 @@ enum SCH_SEARCH_T { ...@@ -115,52 +115,52 @@ enum SCH_SEARCH_T {
class SCH_EDIT_FRAME : public SCH_BASE_FRAME class SCH_EDIT_FRAME : public SCH_BASE_FRAME
{ {
private: private:
SCH_SHEET_PATH* m_CurrentSheet; ///< which sheet we are presently working on. SCH_SHEET_PATH* m_CurrentSheet; ///< which sheet we are presently working on.
wxString m_DefaultSchematicFileName; wxString m_DefaultSchematicFileName;
int m_TextFieldSize; int m_TextFieldSize;
PARAM_CFG_ARRAY m_projectFileParams; PARAM_CFG_ARRAY m_projectFileParams;
PARAM_CFG_ARRAY m_configSettings; PARAM_CFG_ARRAY m_configSettings;
wxPageSetupDialogData m_pageSetupData; wxPageSetupDialogData m_pageSetupData;
wxFindReplaceData* m_findReplaceData; wxFindReplaceData* m_findReplaceData;
wxPoint m_previewPosition; wxPoint m_previewPosition;
wxSize m_previewSize; wxSize m_previewSize;
wxPoint m_printDialogPosition; wxPoint m_printDialogPosition;
wxSize m_printDialogSize; wxSize m_printDialogSize;
bool m_printMonochrome; ///< Print monochrome instead of grey scale. bool m_printMonochrome; ///< Print monochrome instead of grey scale.
bool m_printSheetReference; bool m_printSheetReference;
DIALOG_SCH_FIND* m_dlgFindReplace; DIALOG_SCH_FIND* m_dlgFindReplace;
wxPoint m_findDialogPosition; wxPoint m_findDialogPosition;
wxSize m_findDialogSize; wxSize m_findDialogSize;
wxArrayString m_findStringHistoryList; wxArrayString m_findStringHistoryList;
wxArrayString m_replaceStringHistoryList; wxArrayString m_replaceStringHistoryList;
BLOCK_SELECTOR m_blockItems; ///< List of selected items. BLOCK_SELECTOR m_blockItems; ///< List of selected items.
SCH_ITEM* m_itemToRepeat; ///< Last item to insert by the repeat command. SCH_ITEM* m_itemToRepeat; ///< Last item to insert by the repeat command.
int m_repeatLabelDelta; ///< Repeat label number increment step. int m_repeatLabelDelta; ///< Repeat label number increment step.
SCH_COLLECTOR m_collectedItems; ///< List of collected items. SCH_COLLECTOR m_collectedItems; ///< List of collected items.
SCH_FIND_COLLECTOR m_foundItems; ///< List of find/replace items. SCH_FIND_COLLECTOR m_foundItems; ///< List of find/replace items.
SCH_ITEM* m_undoItem; ///< Copy of the current item being edited. SCH_ITEM* m_undoItem; ///< Copy of the current item being edited.
wxString m_simulatorCommand; ///< Command line used to call the circuit wxString m_simulatorCommand; ///< Command line used to call the circuit
///< simulator (gnucap, spice, ...) ///< simulator (gnucap, spice, ...)
wxString m_netListerCommand; ///< Command line to call a custom net list wxString m_netListerCommand; ///< Command line to call a custom net list
///< generator. ///< generator.
bool m_forceHVLines; ///< force H or V directions for wires, bus, line bool m_forceHVLines; ///< force H or V directions for wires, bus, line
int m_defaultLabelSize; ///< size of a new label int m_defaultLabelSize; ///< size of a new label
/// An index to the last find item in the found items list #m_foundItems. /// An index to the last find item in the found items list #m_foundItems.
int m_foundItemIndex; int m_foundItemIndex;
/// Flag to indicate show hidden pins. /// Flag to indicate show hidden pins.
bool m_showAllPins; bool m_showAllPins;
/// The name of the format to use when generating a net list. /// The name of the format to use when generating a net list.
wxString m_netListFormat; wxString m_netListFormat;
/// Add X prefix to componen referencess when generating spice net lists. /// Add X prefix to componen referencess when generating spice net lists.
bool m_addReferencPrefix; bool m_addReferencPrefix;
wxString m_userLibraryPath; wxString m_userLibraryPath;
wxArrayString m_componentLibFiles; wxArrayString m_componentLibFiles;
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2013 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
// This header is an insolation layer between top most frames and any number of
// DIALOG classes which can be called from a frame window.
// It is a place to put invocation functions for [modal] dialogs, with benefits:
//
// 1) The information about each dialog class is not exposed to the frame.
// So therefore the DIALOG class can often be kept out of a header file entirely.
//
// 2) The information about the calling frame is not necessarily exposed to
// to the called dialog class, at least not in here.
// The actual InvokeDialog<class>() function is usually coded at the bottom of the
// DIALOG_<class>.cpp file.
#ifndef INVOKE_A_DIALOG_H_
#define INVOKE_A_DIALOG_H_
class wxFrame;
class wxDialog;
// Often this is not used in the prototypes, since wxFrame is good enough and would
// represent maximum information hiding.
class PCB_EDIT_FRAME;
/* template: junk it after some are added:
/// Create and show DIALOG_ANNOTATE and return whatever
/// DIALOG_ANNOTATE::ShowModal() returns.
int InvokeDialogAnnotate( SCH_EDIT_FRAME* aCaller );
/// Create the modeless DIALOG_ERC and show it, return something to
/// destroy or close it. The dialog will have ID_DIALOG_ERC from id.h
wxDialog* InvokeDialogERC( SCH_EDIT_FRAME* aCaller );
/// Create and show DIALOG_PRINT_USING_PRINTER and return whatever
/// DIALOG_PRINT_USING_PRINTER::ShowModal() returns.
int InvokeDialogPrintUsingPrinter( SCH_EDIT_FRAME* aCaller );
*/
#endif // INVOKE_A_DIALOG_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment