More EESchema dialog file housekeeping
This commit is contained in:
parent
fdb18547a6
commit
e3b4eeb160
|
@ -4,6 +4,18 @@ KiCad ChangeLog 2010
|
|||
Please add newer entries at the top, list the date and your name with
|
||||
email address.
|
||||
|
||||
2010-nov-17 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
|
||||
================================================================================
|
||||
++EESchema
|
||||
* Move library text edit, library draw item edit, SVG print, and BOM dialogs
|
||||
to dialogs folder.
|
||||
* Rename library text edit dialog file and object names to comply with
|
||||
coding policy.
|
||||
* Set default button in library text edit, library draw item edit, SVG print,
|
||||
and BOM dialogs.
|
||||
* Move BOM dialog code into BOM dialog object source file.
|
||||
|
||||
|
||||
2010-nov-11 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
|
||||
================================================================================
|
||||
++EESchema
|
||||
|
|
|
@ -35,9 +35,10 @@ set(EESCHEMA_SRCS
|
|||
dialogs/dialog_plot_schematic_PS_base.cpp
|
||||
dialogs/annotate_dialog.cpp
|
||||
dialogs/dialog_annotate_base.cpp
|
||||
dialog_bodygraphictext_properties_base.cpp
|
||||
dialog_build_BOM.cpp
|
||||
dialog_build_BOM_base.cpp
|
||||
dialogs/dialog_lib_edit_text.cpp
|
||||
dialogs/dialog_lib_edit_text_base.cpp
|
||||
dialogs/dialog_build_BOM.cpp
|
||||
dialogs/dialog_build_BOM_base.cpp
|
||||
dialog_edit_component_in_lib.cpp
|
||||
dialog_edit_component_in_lib_base.cpp
|
||||
dialog_edit_component_in_schematic_fbp.cpp
|
||||
|
@ -54,8 +55,8 @@ set(EESCHEMA_SRCS
|
|||
dialogs/dialog_erc_base.cpp
|
||||
dialog_libedit_dimensions.cpp
|
||||
dialog_libedit_dimensions_base.cpp
|
||||
dialog_lib_edit_draw_item.cpp
|
||||
dialog_lib_edit_draw_item_base.cpp
|
||||
dialogs/dialog_lib_edit_draw_item.cpp
|
||||
dialogs/dialog_lib_edit_draw_item_base.cpp
|
||||
dialogs/dialog_lib_edit_pin.cpp
|
||||
dialogs/dialog_lib_edit_pin_base.cpp
|
||||
dialog_lib_new_component.cpp
|
||||
|
@ -66,8 +67,8 @@ set(EESCHEMA_SRCS
|
|||
dialog_sch_sheet_props_base.cpp
|
||||
dialogs/dialog_schematic_find.cpp
|
||||
dialogs/dialog_schematic_find_base.cpp
|
||||
dialog_SVG_print.cpp
|
||||
dialog_SVG_print_base.cpp
|
||||
dialogs/dialog_SVG_print.cpp
|
||||
dialogs/dialog_SVG_print_base.cpp
|
||||
edit_component_in_lib.cpp
|
||||
edit_component_in_schematic.cpp
|
||||
edit_label.cpp
|
||||
|
@ -130,7 +131,6 @@ set(EESCHEMA_SRCS
|
|||
sheetlab.cpp
|
||||
symbdraw.cpp
|
||||
symbedit.cpp
|
||||
edit_graphic_bodyitem_text.cpp
|
||||
template_fieldnames_keywords.cpp
|
||||
template_fieldnames.cpp
|
||||
tool_lib.cpp
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Name: build_BOM.cpp
|
||||
// Purpose:
|
||||
// Author: jean-pierre Charras
|
||||
|
@ -11,23 +10,15 @@
|
|||
|
||||
#include "fctsys.h"
|
||||
#include "common.h"
|
||||
#include "confirm.h"
|
||||
#include "kicad_string.h"
|
||||
#include "gestfich.h"
|
||||
#include "appl_wxstruct.h"
|
||||
#include "class_sch_screen.h"
|
||||
#include "kicad_string.h"
|
||||
|
||||
#include "general.h"
|
||||
#include "class_library.h"
|
||||
#include "netlist.h"
|
||||
#include "protos.h"
|
||||
#include "sch_sheet.h"
|
||||
#include "template_fieldnames.h"
|
||||
#include "sch_component.h"
|
||||
|
||||
#include "build_version.h"
|
||||
|
||||
#include "dialog_build_BOM.h"
|
||||
#include "template_fieldnames.h"
|
||||
|
||||
|
||||
/**
|
||||
|
@ -36,322 +27,6 @@
|
|||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Class LABEL_OBJECT
|
||||
* is used in build BOM to handle the list of labels in schematic
|
||||
* because in a complex hierarchy, a label is used more than once,
|
||||
* and had more than one sheet path, so we must create a flat list of labels
|
||||
*/
|
||||
class LABEL_OBJECT
|
||||
{
|
||||
public:
|
||||
int m_LabelType;
|
||||
SCH_ITEM* m_Label;
|
||||
|
||||
//have to store it here since the object references will be duplicated.
|
||||
SCH_SHEET_PATH m_SheetPath; //composed of UIDs
|
||||
|
||||
public: LABEL_OBJECT()
|
||||
{
|
||||
m_Label = NULL;
|
||||
m_LabelType = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static void BuildComponentsListFromSchematic(
|
||||
std::vector <OBJ_CMP_TO_LIST>& aList );
|
||||
|
||||
static void GenListeGLabels( std::vector <LABEL_OBJECT>& aList );
|
||||
static bool SortComponentsByReference( const OBJ_CMP_TO_LIST& obj1,
|
||||
const OBJ_CMP_TO_LIST& obj2 );
|
||||
static bool SortComponentsByValue( const OBJ_CMP_TO_LIST& obj1,
|
||||
const OBJ_CMP_TO_LIST& obj2 );
|
||||
static bool SortLabelsByValue( const LABEL_OBJECT& obj1,
|
||||
const LABEL_OBJECT& obj2 );
|
||||
static bool SortLabelsBySheet( const LABEL_OBJECT& obj1,
|
||||
const LABEL_OBJECT& obj2 );
|
||||
static void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList );
|
||||
static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList );
|
||||
|
||||
|
||||
// separator used in bom export to spreadsheet
|
||||
static char s_ExportSeparatorSymbol;
|
||||
|
||||
|
||||
void DIALOG_BUILD_BOM::Create_BOM_Lists( int aTypeFile,
|
||||
bool aIncludeSubComponents,
|
||||
char aExportSeparatorSymbol,
|
||||
bool aRunBrowser )
|
||||
{
|
||||
wxString wildcard;
|
||||
|
||||
static wxFileName fn;
|
||||
|
||||
wxFileName current = g_RootSheet->m_AssociatedScreen->m_FileName;
|
||||
|
||||
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 | wxFD_OVERWRITE_PROMPT );
|
||||
|
||||
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
|
||||
GenereListeOfItems( m_ListFileName, aIncludeSubComponents );
|
||||
break;
|
||||
|
||||
case 1: // speadsheet
|
||||
CreateExportList( m_ListFileName, aIncludeSubComponents );
|
||||
break;
|
||||
|
||||
case 2: // Single Part per line
|
||||
CreatePartsList( m_ListFileName, aIncludeSubComponents );
|
||||
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 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();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_BUILD_BOM::CreatePartsList( const wxString& aFullFileName, bool aIncludeSubComponents )
|
||||
{
|
||||
FILE* f;
|
||||
wxString msg;
|
||||
|
||||
if( ( f = wxFopen( aFullFileName, wxT( "wt" ) ) ) == NULL )
|
||||
{
|
||||
msg = _( "Failed to open file " );
|
||||
msg << aFullFileName;
|
||||
DisplayError( this, msg );
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector <OBJ_CMP_TO_LIST> cmplist;
|
||||
|
||||
BuildComponentsListFromSchematic( cmplist );
|
||||
|
||||
// sort component list by ref and remove sub components
|
||||
if( !aIncludeSubComponents )
|
||||
{
|
||||
sort( cmplist.begin(), cmplist.end(), SortComponentsByReference );
|
||||
DeleteSubCmp( cmplist );
|
||||
}
|
||||
|
||||
// sort component list by value
|
||||
sort( cmplist.begin(), cmplist.end(), SortComponentsByValue );
|
||||
PrintComponentsListByPart( f, cmplist,aIncludeSubComponents );
|
||||
|
||||
fclose( f );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Print a list of components, in a form which can be imported by a spreadsheet
|
||||
* form is:
|
||||
* cmp name; cmp val; fields;
|
||||
*/
|
||||
void DIALOG_BUILD_BOM::CreateExportList( const wxString& aFullFileName,
|
||||
bool aIncludeSubComponents )
|
||||
{
|
||||
FILE* f;
|
||||
wxString msg;
|
||||
|
||||
if( ( f = wxFopen( aFullFileName, wxT( "wt" ) ) ) == NULL )
|
||||
{
|
||||
msg = _( "Failed to open file " );
|
||||
msg << aFullFileName;
|
||||
DisplayError( this, msg );
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector <OBJ_CMP_TO_LIST> cmplist;
|
||||
BuildComponentsListFromSchematic( cmplist );
|
||||
|
||||
// sort component list
|
||||
sort( cmplist.begin(), cmplist.end(), SortComponentsByReference );
|
||||
|
||||
if( !aIncludeSubComponents )
|
||||
DeleteSubCmp( cmplist );
|
||||
|
||||
// create the file
|
||||
PrintComponentsListByRef( f, cmplist, TRUE, aIncludeSubComponents );
|
||||
|
||||
fclose( f );
|
||||
}
|
||||
|
||||
|
||||
/** GenereListeOfItems()
|
||||
* Main function to create the list of components and/or labels
|
||||
* (global labels and pin sheets" )
|
||||
*/
|
||||
void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName,
|
||||
bool aIncludeSubComponents )
|
||||
{
|
||||
FILE* f;
|
||||
int itemCount;
|
||||
char Line[1024];
|
||||
wxString msg;
|
||||
|
||||
if( ( f = wxFopen( aFullFileName, wxT( "wt" ) ) ) == NULL )
|
||||
{
|
||||
msg = _( "Failed to open file " );
|
||||
msg << aFullFileName;
|
||||
DisplayError( this, msg );
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector <OBJ_CMP_TO_LIST> cmplist;
|
||||
BuildComponentsListFromSchematic( cmplist );
|
||||
|
||||
itemCount = cmplist.size();
|
||||
if( itemCount )
|
||||
{
|
||||
// creates the list file
|
||||
DateAndTime( Line );
|
||||
|
||||
wxString Title = wxGetApp().GetAppName() + wxT( " " ) +
|
||||
GetBuildVersion();
|
||||
|
||||
fprintf( f, "%s >> Creation date: %s\n", CONV_TO_UTF8( Title ), Line );
|
||||
|
||||
// sort component list
|
||||
sort( cmplist.begin(), cmplist.end(), SortComponentsByReference );
|
||||
|
||||
if( !aIncludeSubComponents )
|
||||
DeleteSubCmp( cmplist );
|
||||
|
||||
if( m_ListCmpbyRefItems->GetValue() )
|
||||
PrintComponentsListByRef( f, cmplist, false, aIncludeSubComponents );
|
||||
|
||||
if( m_ListCmpbyValItems->GetValue() )
|
||||
{
|
||||
sort( cmplist.begin(), cmplist.end(), SortComponentsByValue );
|
||||
PrintComponentsListByVal( f, cmplist, aIncludeSubComponents );
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************/
|
||||
/* Create list of global labels and pins sheets */
|
||||
/*************************************************/
|
||||
std::vector <LABEL_OBJECT> listOfLabels;
|
||||
|
||||
GenListeGLabels( listOfLabels );
|
||||
if( ( itemCount = listOfLabels.size() ) > 0 )
|
||||
{
|
||||
if( m_GenListLabelsbySheet->GetValue() )
|
||||
{
|
||||
sort( listOfLabels.begin(), listOfLabels.end(), SortLabelsBySheet );
|
||||
|
||||
msg.Printf( _( "\n#Global, Hierarchical Labels and PinSheets \
|
||||
( order = Sheet Number ) count = %d\n" ),
|
||||
itemCount );
|
||||
|
||||
fprintf( f, "%s", CONV_TO_UTF8( msg ) );
|
||||
PrintListeGLabel( f, listOfLabels );
|
||||
}
|
||||
|
||||
if( m_GenListLabelsbyVal->GetValue() )
|
||||
{
|
||||
sort( listOfLabels.begin(), listOfLabels.end(), SortLabelsByValue );
|
||||
|
||||
msg.Printf( _( "\n#Global, Hierarchical Labels and PinSheets ( \
|
||||
order = Alphab. ) count = %d\n\n" ),
|
||||
itemCount );
|
||||
|
||||
fprintf( f, "%s", CONV_TO_UTF8( msg ) );
|
||||
PrintListeGLabel( f, listOfLabels );
|
||||
}
|
||||
}
|
||||
|
||||
msg = _( "\n#End List\n" );
|
||||
fprintf( f, "%s", CONV_TO_UTF8( msg ) );
|
||||
fclose( f );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function BuildComponentsListFromSchematic
|
||||
* creates the list of components found in the whole schematic.
|
||||
|
@ -397,7 +72,7 @@ void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList )
|
|||
|
||||
/* Fill aList with Glabel info
|
||||
*/
|
||||
static void GenListeGLabels( std::vector <LABEL_OBJECT>& aList )
|
||||
void GenListeGLabels( std::vector <LABEL_OBJECT>& aList )
|
||||
{
|
||||
// Build the sheet list
|
||||
SCH_SHEET_LIST sheetList;
|
||||
|
@ -479,8 +154,7 @@ bool SortComponentsByValue( const OBJ_CMP_TO_LIST& obj1, const OBJ_CMP_TO_LIST&
|
|||
* if same reference: by value
|
||||
* if same value: by unit number
|
||||
*/
|
||||
bool SortComponentsByReference( const OBJ_CMP_TO_LIST& obj1,
|
||||
const OBJ_CMP_TO_LIST& obj2 )
|
||||
bool SortComponentsByReference( const OBJ_CMP_TO_LIST& obj1, const OBJ_CMP_TO_LIST& obj2 )
|
||||
{
|
||||
int ii;
|
||||
const wxString* Text1, * Text2;
|
||||
|
@ -568,7 +242,7 @@ bool SortLabelsBySheet( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 )
|
|||
* found in this list
|
||||
* The component list **MUST** be sorted by reference and by unit number
|
||||
*/
|
||||
static void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList )
|
||||
void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList )
|
||||
{
|
||||
SCH_COMPONENT* libItem;
|
||||
wxString oldName;
|
||||
|
@ -597,398 +271,7 @@ static void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList )
|
|||
}
|
||||
|
||||
|
||||
void DIALOG_BUILD_BOM::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem,
|
||||
bool CompactForm )
|
||||
{
|
||||
int ii;
|
||||
|
||||
if( IsFieldChecked( FOOTPRINT ) )
|
||||
{
|
||||
if( CompactForm )
|
||||
{
|
||||
fprintf( f, "%c%s", s_ExportSeparatorSymbol,
|
||||
CONV_TO_UTF8( DrawLibItem->GetField( FOOTPRINT )->m_Text ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( f, "; %-12s",
|
||||
CONV_TO_UTF8( DrawLibItem->GetField( FOOTPRINT )->m_Text ) );
|
||||
}
|
||||
}
|
||||
|
||||
for( ii = FIELD1; ii < DrawLibItem->GetFieldCount(); ii++ )
|
||||
{
|
||||
if( ! IsFieldChecked( ii ) )
|
||||
continue;
|
||||
|
||||
if( CompactForm )
|
||||
fprintf( f, "%c%s", s_ExportSeparatorSymbol,
|
||||
CONV_TO_UTF8( DrawLibItem->GetField( ii )->m_Text ) );
|
||||
else
|
||||
fprintf( f, "; %-12s",
|
||||
CONV_TO_UTF8( DrawLibItem->GetField( ii )->m_Text ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Print the B.O.M sorted by reference
|
||||
*/
|
||||
int DIALOG_BUILD_BOM::PrintComponentsListByRef(
|
||||
FILE* f,
|
||||
std::vector <OBJ_CMP_TO_LIST>& aList,
|
||||
bool CompactForm,
|
||||
bool aIncludeSubComponents )
|
||||
{
|
||||
wxString msg;
|
||||
|
||||
if( CompactForm )
|
||||
{
|
||||
// Print comment line:
|
||||
#if defined(KICAD_GOST)
|
||||
fprintf( f, "ref%cvalue%cdatasheet", s_ExportSeparatorSymbol, s_ExportSeparatorSymbol );
|
||||
#else
|
||||
fprintf( f, "ref%cvalue", s_ExportSeparatorSymbol );
|
||||
#endif
|
||||
|
||||
if( aIncludeSubComponents )
|
||||
{
|
||||
fprintf( f, "%csheet path", s_ExportSeparatorSymbol );
|
||||
fprintf( f, "%clocation", s_ExportSeparatorSymbol );
|
||||
}
|
||||
|
||||
if( IsFieldChecked( FOOTPRINT ) )
|
||||
fprintf( f, "%cfootprint", s_ExportSeparatorSymbol );
|
||||
|
||||
for( int ii = FIELD1; ii <= FIELD8; ii++ )
|
||||
{
|
||||
if( !IsFieldChecked( ii ) )
|
||||
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 )" );
|
||||
|
||||
if( aIncludeSubComponents )
|
||||
msg << _( " (with SubCmp)" );
|
||||
|
||||
fprintf( f, "%s\n", CONV_TO_UTF8( msg ) );
|
||||
}
|
||||
|
||||
std::string CmpName;
|
||||
wxString subRef;
|
||||
|
||||
// Print list of items
|
||||
for( unsigned ii = 0; ii < aList.size(); ii++ )
|
||||
{
|
||||
EDA_BaseStruct* item = aList[ii].m_RootCmp;
|
||||
if( item == NULL )
|
||||
continue;
|
||||
|
||||
if( item->Type() != TYPE_SCH_COMPONENT )
|
||||
continue;
|
||||
|
||||
SCH_COMPONENT* comp = (SCH_COMPONENT*) item;
|
||||
|
||||
bool isMulti = false;
|
||||
|
||||
LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( comp->m_ChipName );
|
||||
if( entry )
|
||||
isMulti = entry->IsMulti();
|
||||
|
||||
if( isMulti && aIncludeSubComponents )
|
||||
subRef = LIB_COMPONENT::ReturnSubReference( aList[ii].m_Unit );
|
||||
else
|
||||
subRef.Empty();
|
||||
|
||||
CmpName = aList[ii].GetRefStr();
|
||||
|
||||
if( !CompactForm )
|
||||
CmpName += CONV_TO_UTF8(subRef);
|
||||
|
||||
if( CompactForm )
|
||||
#if defined(KICAD_GOST)
|
||||
fprintf( f, "%s%c%s%c%s", CmpName.c_str(), s_ExportSeparatorSymbol,
|
||||
CONV_TO_UTF8( comp->GetField( VALUE )->m_Text ), s_ExportSeparatorSymbol,
|
||||
CONV_TO_UTF8( comp->GetField( DATASHEET )->m_Text ) );
|
||||
#else
|
||||
fprintf( f, "%s%c%s", CmpName.c_str(), s_ExportSeparatorSymbol,
|
||||
CONV_TO_UTF8( comp->GetField( VALUE )->m_Text ) );
|
||||
#endif
|
||||
|
||||
else
|
||||
#if defined(KICAD_GOST)
|
||||
fprintf( f, "| %-10s %-12s %-20s", CmpName.c_str(),
|
||||
CONV_TO_UTF8( comp->GetField( VALUE )->m_Text ),
|
||||
CONV_TO_UTF8( comp->GetField( DATASHEET )->m_Text ) );
|
||||
#else
|
||||
fprintf( f, "| %-10s %-12s", CmpName.c_str(),
|
||||
CONV_TO_UTF8( comp->GetField( VALUE )->m_Text ) );
|
||||
#endif
|
||||
|
||||
if( aIncludeSubComponents )
|
||||
{
|
||||
msg = aList[ii].m_SheetPath.PathHumanReadable();
|
||||
|
||||
if( CompactForm )
|
||||
{
|
||||
fprintf( f, "%c%s", s_ExportSeparatorSymbol, CONV_TO_UTF8( msg ) );
|
||||
|
||||
msg = m_Parent->GetXYSheetReferences( (BASE_SCREEN*) comp->GetParent(),
|
||||
comp->m_Pos );
|
||||
|
||||
fprintf( f, "%c%s)", s_ExportSeparatorSymbol,
|
||||
CONV_TO_UTF8( msg ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( f, " (Sheet %s)", CONV_TO_UTF8( msg ) );
|
||||
|
||||
msg = m_Parent->GetXYSheetReferences( (BASE_SCREEN*) comp->GetParent(),
|
||||
comp->m_Pos );
|
||||
|
||||
fprintf( f, " (loc %s)", CONV_TO_UTF8( msg ) );
|
||||
}
|
||||
}
|
||||
|
||||
PrintFieldData( f, comp, CompactForm );
|
||||
|
||||
fprintf( f, "\n" );
|
||||
}
|
||||
|
||||
if( !CompactForm )
|
||||
{
|
||||
msg = _( "#End Cmp\n" );
|
||||
fputs( CONV_TO_UTF8( msg ), f );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Bom Output format option - single part per line
|
||||
* a common part being defined as have a common value.
|
||||
* This is true for most designs but will produce an
|
||||
* incorrect output if two or more parts with the same
|
||||
* value have different footprints, tolerances, voltage
|
||||
* rating, etc. Also usefull if the following fields
|
||||
* are edited:
|
||||
* FIELD1 - manufacture
|
||||
* FIELD2 - manufacture part number
|
||||
* FIELD3 - distributor part number
|
||||
*/
|
||||
int DIALOG_BUILD_BOM::PrintComponentsListByPart(
|
||||
FILE* f,
|
||||
std::vector <OBJ_CMP_TO_LIST>& aList,
|
||||
bool aIncludeSubComponents)
|
||||
{
|
||||
int qty = 0;
|
||||
wxString refName;
|
||||
wxString fullRefName; // reference + part Id (for multiple parts per package
|
||||
wxString valName;
|
||||
#if defined(KICAD_GOST)
|
||||
wxString footName;
|
||||
wxString datsName;
|
||||
#endif
|
||||
wxString refNames;
|
||||
wxString lastRef;
|
||||
wxString unitId;
|
||||
SCH_COMPONENT* currCmp;
|
||||
SCH_COMPONENT* nextCmp;
|
||||
SCH_COMPONENT dummyCmp; // A dummy component, to store fields
|
||||
|
||||
for( unsigned ii = 0; ii < aList.size(); ii++ )
|
||||
{
|
||||
currCmp = (SCH_COMPONENT*) aList[ii].m_RootCmp;
|
||||
|
||||
if( ii < aList.size() -1 )
|
||||
nextCmp = aList[ii+1].m_RootCmp;
|
||||
else
|
||||
nextCmp = NULL;
|
||||
|
||||
// Store fields. Store non empty fields only.
|
||||
for( int jj = FOOTPRINT; jj < currCmp->GetFieldCount(); jj++ )
|
||||
{
|
||||
// Ensure fields exists in dummy component
|
||||
if( dummyCmp.GetFieldCount() <= jj )
|
||||
dummyCmp.AddField( *currCmp->GetField( jj ) );
|
||||
|
||||
// store useful data
|
||||
if( !currCmp->GetField( jj )->m_Text.IsEmpty() )
|
||||
dummyCmp.GetField( jj )->m_Text = currCmp->GetField( jj )->m_Text;
|
||||
}
|
||||
|
||||
refName = aList[ii].GetRef();
|
||||
valName = currCmp->GetField( VALUE )->m_Text;
|
||||
#if defined(KICAD_GOST)
|
||||
footName = currCmp->GetField( FOOTPRINT )->m_Text;
|
||||
datsName = currCmp->GetField( DATASHEET )->m_Text;
|
||||
#endif
|
||||
|
||||
int multi = 0;
|
||||
if( aIncludeSubComponents )
|
||||
{
|
||||
LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( currCmp->m_ChipName );
|
||||
if( entry )
|
||||
multi = entry->GetPartCount();
|
||||
if ( multi <= 1 )
|
||||
multi = 0;
|
||||
}
|
||||
|
||||
if ( multi && aList[ii].m_Unit > 0 )
|
||||
unitId.Printf( wxT("%c"), 'A' -1 + aList[ii].m_Unit );
|
||||
else
|
||||
unitId.Empty();
|
||||
|
||||
fullRefName = refName + unitId;
|
||||
|
||||
if( refNames.IsEmpty() )
|
||||
refNames = fullRefName;
|
||||
else
|
||||
refNames << wxT( ", " ) << fullRefName;
|
||||
|
||||
// In multi parts per package, we have the reference more than once
|
||||
// but we must count only one package
|
||||
if( lastRef != refName )
|
||||
qty++;
|
||||
|
||||
lastRef = refName;
|
||||
|
||||
// if the next cmoponent has same value the line will be printed after.
|
||||
#if defined(KICAD_GOST)
|
||||
if( nextCmp && nextCmp->GetField( VALUE )->m_Text.CmpNoCase( valName ) == 0
|
||||
&& nextCmp->GetField( FOOTPRINT )->m_Text.CmpNoCase( footName ) == 0
|
||||
&& nextCmp->GetField( DATASHEET )->m_Text.CmpNoCase( datsName ) == 0 )
|
||||
#else
|
||||
if( nextCmp && nextCmp->GetField( VALUE )->m_Text.CmpNoCase( valName ) == 0 )
|
||||
#endif
|
||||
continue;
|
||||
|
||||
// Print line for the current component value:
|
||||
fprintf( f, "%15s%c%3d", CONV_TO_UTF8( valName ), s_ExportSeparatorSymbol, qty );
|
||||
|
||||
if( IsFieldChecked(FOOTPRINT ) )
|
||||
fprintf( f, "%c%15s", s_ExportSeparatorSymbol,
|
||||
#if defined(KICAD_GOST)
|
||||
CONV_TO_UTF8( footName ) );
|
||||
#else
|
||||
CONV_TO_UTF8( currCmp->GetField( FOOTPRINT )->m_Text ) );
|
||||
#endif
|
||||
|
||||
#if defined(KICAD_GOST)
|
||||
fprintf( f, "%c%20s", s_ExportSeparatorSymbol,
|
||||
CONV_TO_UTF8( datsName ) );
|
||||
#endif
|
||||
|
||||
// wrap the field in quotes, since it has commas in it.
|
||||
fprintf( f, "%c\"%s\"", s_ExportSeparatorSymbol,
|
||||
CONV_TO_UTF8( refNames ) );
|
||||
|
||||
// print fields, on demand
|
||||
int last_nonempty_field_idx = 0;
|
||||
|
||||
for( int jj = FOOTPRINT; jj < dummyCmp.GetFieldCount(); jj++ )
|
||||
if ( !dummyCmp.GetField( jj )->m_Text.IsEmpty() )
|
||||
last_nonempty_field_idx = jj;
|
||||
|
||||
for( int jj = FIELD1; jj <= last_nonempty_field_idx ; jj++ )
|
||||
{
|
||||
if ( IsFieldChecked( jj ) )
|
||||
fprintf( f, "%c%4s", s_ExportSeparatorSymbol,
|
||||
CONV_TO_UTF8( dummyCmp.GetField( jj )->m_Text ) );
|
||||
}
|
||||
|
||||
fprintf( f, "\n" );
|
||||
|
||||
// Clear strings and values, to prepare next component
|
||||
qty = 0;
|
||||
refNames.Empty();
|
||||
|
||||
for( int jj = FOOTPRINT; jj < dummyCmp.GetFieldCount(); jj++ )
|
||||
dummyCmp.GetField( jj )->m_Text.Empty();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int DIALOG_BUILD_BOM::PrintComponentsListByVal(
|
||||
FILE* f,
|
||||
std::vector <OBJ_CMP_TO_LIST>& aList,
|
||||
bool aIncludeSubComponents )
|
||||
{
|
||||
EDA_BaseStruct* schItem;
|
||||
SCH_COMPONENT* DrawLibItem;
|
||||
LIB_COMPONENT* entry;
|
||||
std::string CmpName;
|
||||
wxString msg;
|
||||
|
||||
msg = _( "\n#Cmp ( order = Value )" );
|
||||
|
||||
if( aIncludeSubComponents )
|
||||
msg << _( " (with SubCmp)" );
|
||||
msg << wxT( "\n" );
|
||||
|
||||
fputs( CONV_TO_UTF8( msg ), f );
|
||||
|
||||
for( unsigned ii = 0; ii < aList.size(); ii++ )
|
||||
{
|
||||
schItem = aList[ii].m_RootCmp;
|
||||
|
||||
if( schItem == NULL )
|
||||
continue;
|
||||
|
||||
if( schItem->Type() != TYPE_SCH_COMPONENT )
|
||||
continue;
|
||||
|
||||
DrawLibItem = (SCH_COMPONENT*) schItem;
|
||||
|
||||
bool isMulti = false;
|
||||
entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
|
||||
if( entry )
|
||||
isMulti = entry->IsMulti();
|
||||
|
||||
wxString subRef;
|
||||
if( isMulti && aIncludeSubComponents )
|
||||
subRef = LIB_COMPONENT::ReturnSubReference( aList[ii].m_Unit );
|
||||
else
|
||||
subRef.Empty();
|
||||
|
||||
CmpName = aList[ii].GetRefStr();
|
||||
CmpName += CONV_TO_UTF8(subRef);
|
||||
|
||||
fprintf( f, "| %-12s %-10s",
|
||||
CONV_TO_UTF8( DrawLibItem->GetField( VALUE )->m_Text ),
|
||||
CmpName.c_str() );
|
||||
|
||||
// print the sheet path
|
||||
if( aIncludeSubComponents )
|
||||
{
|
||||
msg = aList[ii].m_SheetPath.PathHumanReadable();
|
||||
fprintf( f, " (Sheet %s)", CONV_TO_UTF8( msg ) );
|
||||
msg = m_Parent->GetXYSheetReferences( (BASE_SCREEN*) DrawLibItem->GetParent(),
|
||||
DrawLibItem->m_Pos );
|
||||
fprintf( f, " (loc %s)", CONV_TO_UTF8( msg ) );
|
||||
}
|
||||
|
||||
PrintFieldData( f, DrawLibItem );
|
||||
|
||||
fputs( "\n", f );
|
||||
}
|
||||
|
||||
msg = _( "#End Cmp\n" );
|
||||
fputs( CONV_TO_UTF8( msg ), f );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList )
|
||||
int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList )
|
||||
{
|
||||
SCH_LABEL* DrawTextItem;
|
||||
SCH_SHEET_PIN* DrawSheetLabel;
|
||||
|
@ -1052,5 +335,3 @@ static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList )
|
|||
fputs( CONV_TO_UTF8( msg ), f );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,248 +0,0 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Name: dialog_build_BOM.cpp
|
||||
// Author: jean-pierre Charras
|
||||
// Modified by:
|
||||
// Licence: GPL
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include "fctsys.h"
|
||||
#include "appl_wxstruct.h"
|
||||
#include "common.h"
|
||||
#include "wxstruct.h"
|
||||
|
||||
#include "general.h"
|
||||
#include "netlist.h"
|
||||
|
||||
#include "wx/valgen.h"
|
||||
|
||||
#include "dialog_build_BOM.h"
|
||||
|
||||
|
||||
#include "protos.h"
|
||||
|
||||
|
||||
/* Local variables */
|
||||
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_BrowseCreatedList;
|
||||
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_Add_Alls_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,
|
||||
&s_Add_Alls_state,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
#define OPTION_BOM_FORMAT wxT( "BomFormat" )
|
||||
#define OPTION_BOM_LAUNCH_BROWSER wxT( "BomLaunchBrowser" )
|
||||
#define OPTION_BOM_SEPARATOR wxT( "BomExportSeparator" )
|
||||
#define OPTION_BOM_ADD_FIELD wxT( "BomAddField" )
|
||||
|
||||
/* 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( WinEDA_DrawFrame* parent ):
|
||||
DIALOG_BUILD_BOM_BASE(parent)
|
||||
{
|
||||
m_Config = wxGetApp().m_EDA_Config;
|
||||
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 */
|
||||
s_OutputFormOpt = m_Config->Read( OPTION_BOM_FORMAT, (long) 0 );
|
||||
s_BrowseCreatedList = m_Config->Read( OPTION_BOM_LAUNCH_BROWSER, (long) 0 );
|
||||
s_OutputSeparatorOpt = m_Config->Read( OPTION_BOM_SEPARATOR, (long) 0 );
|
||||
long addfields = m_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;
|
||||
}
|
||||
|
||||
// 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_ListBySheet) );
|
||||
m_OutputFormCtrl->SetValidator( wxGenericValidator(& s_OutputFormOpt) );
|
||||
m_OutputSeparatorCtrl->SetValidator( wxGenericValidator(& s_OutputSeparatorOpt) );
|
||||
m_GetListBrowser->SetValidator( wxGenericValidator(& s_BrowseCreatedList) );
|
||||
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) );
|
||||
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 );
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_RADIOBOX_SELECT_FORMAT
|
||||
*/
|
||||
|
||||
void DIALOG_BUILD_BOM::OnRadioboxSelectFormatSelected( wxCommandEvent& event )
|
||||
{
|
||||
if( m_OutputFormCtrl->GetSelection() == 0 )
|
||||
{
|
||||
m_OutputSeparatorCtrl->Enable( false );
|
||||
m_ListCmpbyValItems->Enable( true );
|
||||
m_GenListLabelsbyVal->Enable( true );
|
||||
m_GenListLabelsbySheet->Enable( true );
|
||||
} else {
|
||||
m_OutputSeparatorCtrl->Enable( true );
|
||||
m_ListCmpbyValItems->Enable( false );
|
||||
m_GenListLabelsbyVal->Enable( false );
|
||||
m_GenListLabelsbySheet->Enable( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* 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()
|
||||
/**************************************************/
|
||||
{
|
||||
wxASSERT( m_Config != NULL );
|
||||
|
||||
// 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_BrowseCreatedList = m_GetListBrowser->GetValue();
|
||||
|
||||
// (aved 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_FpField_state = m_AddFootprintField->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_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
|
||||
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 );
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: dialog_build_BOM.h
|
||||
// Copyright: GNU license
|
||||
// Licence:
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _DIALOG_BUILD_BOM_H_
|
||||
#define _DIALOG_BUILD_BOM_H_
|
||||
|
||||
#include "dialog_build_BOM_base.h"
|
||||
|
||||
|
||||
class WinEDA_DrawFrame;
|
||||
class SCH_COMPONENT;
|
||||
class wxConfig;
|
||||
|
||||
|
||||
class DIALOG_BUILD_BOM : public DIALOG_BUILD_BOM_BASE
|
||||
{
|
||||
private:
|
||||
WinEDA_DrawFrame * m_Parent;
|
||||
wxConfig* m_Config;
|
||||
wxString m_ListFileName;
|
||||
|
||||
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 GenereListeOfItems(const wxString & FullFileName, bool aIncludeSubComponents );
|
||||
void CreateExportList(const wxString & FullFileName, bool aIncludeSubComponents);
|
||||
|
||||
/**
|
||||
* Function CreateParstList
|
||||
* prints a list of components, in a form which can be imported by a
|
||||
* spreadsheet. Form is:
|
||||
* cmp value; number of components; <footprint>; <field1>; ...;
|
||||
* list of references having the same value
|
||||
*/
|
||||
void CreatePartsList( const wxString& aFullFileName, bool aIncludeSubComponents );
|
||||
|
||||
int PrintComponentsListByRef( FILE * f, std::vector <OBJ_CMP_TO_LIST>& aList,
|
||||
bool CompactForm, bool aIncludeSubComponents );
|
||||
|
||||
int PrintComponentsListByVal( FILE *f, std::vector <OBJ_CMP_TO_LIST>& aList,
|
||||
bool aIncludeSubComponents);
|
||||
|
||||
int PrintComponentsListByPart( FILE *f, std::vector <OBJ_CMP_TO_LIST>& aList,
|
||||
bool aIncludeSubComponents);
|
||||
|
||||
void PrintFieldData(FILE * f, SCH_COMPONENT * DrawLibItem, bool CompactForm = FALSE);
|
||||
|
||||
bool IsFieldChecked(int aFieldId);
|
||||
|
||||
public:
|
||||
DIALOG_BUILD_BOM( WinEDA_DrawFrame* parent );
|
||||
// ~DIALOG_BUILD_BOM() {};
|
||||
};
|
||||
|
||||
#endif // _DIALOG_BUILD_BOM_H_
|
||||
|
|
@ -15,80 +15,35 @@
|
|||
#include "class_sch_screen.h"
|
||||
#include "wxEeschemaStruct.h"
|
||||
|
||||
#include "dialog_SVG_print_base.h"
|
||||
#include "dcsvg.h"
|
||||
|
||||
#include "general.h"
|
||||
#include "libeditframe.h"
|
||||
#include "sch_sheet_path.h"
|
||||
|
||||
#include "dialog_SVG_print.h"
|
||||
|
||||
|
||||
// Keys for configuration
|
||||
#define PLOTSVGMODECOLOR_KEY wxT( "PlotSVGModeColor" )
|
||||
#define PLOTSVGMODECOLOR_KEY wxT( "PlotSVGModeColor" )
|
||||
|
||||
extern BASE_SCREEN* ActiveScreen;
|
||||
#define WIDTH_MAX_VALUE 100
|
||||
#define WIDTH_MIN_VALUE 1
|
||||
|
||||
// Variables locales
|
||||
static bool s_Print_Frame_Ref = true;
|
||||
static int s_PlotBlackAndWhite = 0;
|
||||
|
||||
class DIALOG_SVG_PRINT : public DIALOG_SVG_PRINT_base
|
||||
{
|
||||
private:
|
||||
WinEDA_DrawFrame * m_Parent;
|
||||
wxConfig* m_Config;
|
||||
|
||||
public:
|
||||
DIALOG_SVG_PRINT( WinEDA_DrawFrame* parent );
|
||||
~DIALOG_SVG_PRINT( ) {}
|
||||
|
||||
private:
|
||||
void OnCloseWindow( wxCloseEvent& event );
|
||||
void OnInitDialog( wxInitDialogEvent& event );
|
||||
void OnButtonPlotCurrentClick( wxCommandEvent& event );
|
||||
void OnButtonPlotAllClick( wxCommandEvent& event );
|
||||
void OnButtonCancelClick( wxCommandEvent& event );
|
||||
void OnSetColorModeSelected( wxCommandEvent& event );
|
||||
void SetPenWidth();
|
||||
void PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref );
|
||||
public:
|
||||
static bool DrawSVGPage( WinEDA_DrawFrame * frame,
|
||||
const wxString& FullFileName, BASE_SCREEN* screen,
|
||||
bool aPrintBlackAndWhite = false,
|
||||
bool aPrint_Sheet_Ref = false);
|
||||
};
|
||||
|
||||
|
||||
/* Prepare the data structures of print management and display the dialog
|
||||
* window for printing sheets.
|
||||
*/
|
||||
void WinEDA_DrawFrame::SVG_Print( wxCommandEvent& event )
|
||||
{
|
||||
DIALOG_SVG_PRINT frame( this );
|
||||
|
||||
frame.ShowModal();
|
||||
}
|
||||
|
||||
/* Creates the SVG print file for the current edited component.
|
||||
*/
|
||||
void WinEDA_LibeditFrame::SVG_Print_Component( const wxString& FullFileName )
|
||||
{
|
||||
DIALOG_SVG_PRINT::DrawSVGPage( this, FullFileName, GetScreen() );
|
||||
}
|
||||
|
||||
|
||||
static bool s_Print_Frame_Ref = true;
|
||||
static int s_PlotBlackAndWhite = 0;
|
||||
|
||||
|
||||
/*!
|
||||
* DIALOG_SVG_PRINT functions
|
||||
*/
|
||||
DIALOG_SVG_PRINT::DIALOG_SVG_PRINT( WinEDA_DrawFrame* parent )
|
||||
: DIALOG_SVG_PRINT_base( parent )
|
||||
DIALOG_SVG_PRINT::DIALOG_SVG_PRINT( WinEDA_DrawFrame* parent ) :
|
||||
DIALOG_SVG_PRINT_base( parent )
|
||||
{
|
||||
m_Parent = parent;
|
||||
m_Config = wxGetApp().m_EDA_Config;
|
||||
m_Parent = parent;
|
||||
m_Config = wxGetApp().m_EDA_Config;
|
||||
}
|
||||
|
||||
|
||||
|
@ -101,16 +56,17 @@ void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event )
|
|||
m_Config->Read( PLOTSVGMODECOLOR_KEY, &s_PlotBlackAndWhite );
|
||||
}
|
||||
|
||||
m_ModeColorOption->SetSelection(s_PlotBlackAndWhite);
|
||||
m_ModeColorOption->SetSelection( s_PlotBlackAndWhite );
|
||||
|
||||
AddUnitSymbol(* m_TextPenWidth, g_UserUnit );
|
||||
AddUnitSymbol( *m_TextPenWidth, g_UserUnit );
|
||||
m_DialogPenWidth->SetValue(
|
||||
ReturnStringFromValue(g_UserUnit, g_DrawDefaultLineThickness,
|
||||
m_Parent->m_InternalUnits ) );
|
||||
ReturnStringFromValue( g_UserUnit, g_DrawDefaultLineThickness,
|
||||
m_Parent->m_InternalUnits ) );
|
||||
m_Print_Sheet_Ref->SetValue( s_Print_Frame_Ref );
|
||||
if (GetSizer())
|
||||
|
||||
if( GetSizer() )
|
||||
{
|
||||
GetSizer()->SetSizeHints(this);
|
||||
GetSizer()->SetSizeHints( this );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,55 +94,58 @@ void DIALOG_SVG_PRINT::SetPenWidth()
|
|||
|
||||
void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref )
|
||||
{
|
||||
wxString msg;
|
||||
wxFileName fn;
|
||||
wxString msg;
|
||||
wxFileName fn;
|
||||
|
||||
SetPenWidth();
|
||||
|
||||
g_DrawDefaultLineThickness =
|
||||
ReturnValueFromTextCtrl( *m_DialogPenWidth, m_Parent->m_InternalUnits );
|
||||
|
||||
BASE_SCREEN* screen = m_Parent->GetBaseScreen();
|
||||
BASE_SCREEN* oldscreen = screen;
|
||||
BASE_SCREEN* screen = m_Parent->GetBaseScreen();
|
||||
BASE_SCREEN* oldscreen = screen;
|
||||
|
||||
if( aPrintAll && m_Parent->m_Ident == SCHEMATIC_FRAME )
|
||||
{
|
||||
WinEDA_SchematicFrame* schframe = (WinEDA_SchematicFrame*) m_Parent;
|
||||
SCH_SHEET_PATH* sheetpath, *oldsheetpath = schframe->GetSheet();
|
||||
SCH_SCREEN* schscreen = schframe->GetScreen();
|
||||
oldscreen = schscreen;
|
||||
SCH_SHEET_LIST SheetList( NULL );
|
||||
WinEDA_SchematicFrame* schframe = (WinEDA_SchematicFrame*) m_Parent;
|
||||
SCH_SHEET_PATH* sheetpath, * oldsheetpath = schframe->GetSheet();
|
||||
SCH_SCREEN* schscreen = schframe->GetScreen();
|
||||
oldscreen = schscreen;
|
||||
SCH_SHEET_LIST SheetList( NULL );
|
||||
sheetpath = SheetList.GetFirst();
|
||||
SCH_SHEET_PATH list;
|
||||
SCH_SHEET_PATH list;
|
||||
|
||||
for( ; ; )
|
||||
for( ; ; )
|
||||
{
|
||||
if( sheetpath == NULL )
|
||||
break;
|
||||
list.Clear();
|
||||
|
||||
if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) )
|
||||
{
|
||||
schframe->m_CurrentSheet = &list;
|
||||
schframe->m_CurrentSheet->UpdateAllScreenReferences();
|
||||
schframe->SetSheetNumberAndCount();
|
||||
schscreen = schframe->m_CurrentSheet->LastScreen();
|
||||
ActiveScreen = schscreen;
|
||||
schscreen = schframe->m_CurrentSheet->LastScreen();
|
||||
ActiveScreen = schscreen;
|
||||
}
|
||||
else // Should not happen
|
||||
return;
|
||||
|
||||
sheetpath = SheetList.GetNext();
|
||||
|
||||
fn = schframe->GetUniqueFilenameForCurrentSheet( ) + wxT( ".svg" );
|
||||
fn = schframe->GetUniqueFilenameForCurrentSheet() + wxT( ".svg" );
|
||||
|
||||
bool success = DrawSVGPage( m_Parent, fn.GetFullPath(), schscreen,
|
||||
m_ModeColorOption->GetSelection() == 0 ? false : true,
|
||||
aPrint_Sheet_Ref );
|
||||
m_ModeColorOption->GetSelection() == 0 ? false : true,
|
||||
aPrint_Sheet_Ref );
|
||||
msg = _( "Create file " ) + fn.GetFullPath();
|
||||
if( !success )
|
||||
msg += _( " error" );
|
||||
msg += wxT( "\n" );
|
||||
m_MessagesBox->AppendText( msg );
|
||||
}
|
||||
|
||||
schframe->m_CurrentSheet = oldsheetpath;
|
||||
schframe->m_CurrentSheet->UpdateAllScreenReferences();
|
||||
schframe->SetSheetNumberAndCount();
|
||||
|
@ -199,11 +158,11 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref )
|
|||
fn = screen->m_FileName;
|
||||
|
||||
fn.SetExt( wxT( "svg" ) );
|
||||
fn.MakeAbsolute( );
|
||||
fn.MakeAbsolute();
|
||||
|
||||
bool success = DrawSVGPage( m_Parent, fn.GetFullPath(), screen,
|
||||
m_ModeColorOption->GetSelection() == 0 ? false : true,
|
||||
aPrint_Sheet_Ref );
|
||||
m_ModeColorOption->GetSelection() == 0 ? false : true,
|
||||
aPrint_Sheet_Ref );
|
||||
msg = _( "Create file " ) + fn.GetFullPath();
|
||||
|
||||
if( !success )
|
||||
|
@ -216,11 +175,12 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref )
|
|||
ActiveScreen = oldscreen;
|
||||
}
|
||||
|
||||
bool DIALOG_SVG_PRINT::DrawSVGPage( WinEDA_DrawFrame * frame,
|
||||
const wxString& FullFileName,
|
||||
BASE_SCREEN* screen,
|
||||
bool aPrintBlackAndWhite,
|
||||
bool aPrint_Sheet_Ref)
|
||||
|
||||
bool DIALOG_SVG_PRINT::DrawSVGPage( WinEDA_DrawFrame* frame,
|
||||
const wxString& FullFileName,
|
||||
BASE_SCREEN* screen,
|
||||
bool aPrintBlackAndWhite,
|
||||
bool aPrint_Sheet_Ref )
|
||||
{
|
||||
int tmpzoom;
|
||||
wxPoint tmp_startvisu;
|
||||
|
@ -229,22 +189,23 @@ bool DIALOG_SVG_PRINT::DrawSVGPage( WinEDA_DrawFrame * frame,
|
|||
bool success = true;
|
||||
|
||||
tmp_startvisu = screen->m_StartVisu;
|
||||
tmpzoom = screen->GetZoom();
|
||||
old_org = screen->m_DrawOrg;
|
||||
screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0;
|
||||
screen->m_StartVisu.x = screen->m_StartVisu.y = 0;
|
||||
SheetSize = screen->ReturnPageSize( ); // page size in 1/1000 inch, ie in internal units
|
||||
tmpzoom = screen->GetZoom();
|
||||
old_org = screen->m_DrawOrg;
|
||||
screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0;
|
||||
screen->m_StartVisu.x = screen->m_StartVisu.y = 0;
|
||||
|
||||
SheetSize = screen->ReturnPageSize(); // page size in 1/1000 inch, ie in internal units
|
||||
|
||||
screen->SetScalingFactor( 1.0 );
|
||||
WinEDA_DrawPanel* panel = frame->DrawPanel;
|
||||
|
||||
SetLocaleTo_C_standard( ); // Switch the locale to standard C (needed
|
||||
// to print floating point numbers like 1.3)
|
||||
SetLocaleTo_C_standard(); // Switch the locale to standard C (needed
|
||||
// to print floating point numbers like 1.3)
|
||||
|
||||
float dpi = (float)frame->m_InternalUnits;
|
||||
float dpi = (float) frame->m_InternalUnits;
|
||||
wxSVGFileDC dc( FullFileName, SheetSize.x, SheetSize.y, dpi );
|
||||
|
||||
EDA_Rect tmp = panel->m_ClipBox;
|
||||
EDA_Rect tmp = panel->m_ClipBox;
|
||||
GRResetPenAndBrush( &dc );
|
||||
GRForceBlackPen( aPrintBlackAndWhite );
|
||||
|
||||
|
@ -256,15 +217,15 @@ bool DIALOG_SVG_PRINT::DrawSVGPage( WinEDA_DrawFrame * frame,
|
|||
|
||||
screen->m_IsPrinting = true;
|
||||
frame->PrintPage( &dc, aPrint_Sheet_Ref, 1, false );
|
||||
SetLocaleTo_Default( ); // revert to the current locale
|
||||
screen->m_IsPrinting = false;
|
||||
panel->m_ClipBox = tmp;
|
||||
SetLocaleTo_Default(); // revert to the current locale
|
||||
screen->m_IsPrinting = false;
|
||||
panel->m_ClipBox = tmp;
|
||||
|
||||
|
||||
GRForceBlackPen( false );
|
||||
|
||||
screen->m_StartVisu = tmp_startvisu;
|
||||
screen->m_DrawOrg = old_org;
|
||||
screen->m_StartVisu = tmp_startvisu;
|
||||
screen->m_DrawOrg = old_org;
|
||||
screen->SetZoom( tmpzoom );
|
||||
|
||||
return success;
|
||||
|
@ -276,6 +237,7 @@ void DIALOG_SVG_PRINT::OnButtonPlotAllClick( wxCommandEvent& event )
|
|||
PrintSVGDoc( true, m_Print_Sheet_Ref->GetValue() );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_SVG_PRINT::OnButtonPlotCurrentClick( wxCommandEvent& event )
|
||||
{
|
||||
PrintSVGDoc( false, m_Print_Sheet_Ref->GetValue() );
|
||||
|
@ -284,7 +246,7 @@ void DIALOG_SVG_PRINT::OnButtonPlotCurrentClick( wxCommandEvent& event )
|
|||
|
||||
void DIALOG_SVG_PRINT::OnButtonCancelClick( wxCommandEvent& event )
|
||||
{
|
||||
Close( );
|
||||
Close();
|
||||
}
|
||||
|
||||
|
||||
|
@ -300,7 +262,7 @@ void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event )
|
|||
|
||||
|
||||
/* called on radiobox color/black and white selection
|
||||
*/
|
||||
*/
|
||||
void DIALOG_SVG_PRINT::OnSetColorModeSelected( wxCommandEvent& event )
|
||||
{
|
||||
s_PlotBlackAndWhite = m_ModeColorOption->GetSelection();
|
|
@ -0,0 +1,41 @@
|
|||
|
||||
#ifndef _DIALOG_SVG_PRINT_H_
|
||||
#define _DIALOG_SVG_PRINT_H_
|
||||
|
||||
|
||||
class WinEDA_DrawFrame;
|
||||
class BASE_SCREEN;
|
||||
|
||||
|
||||
#include "dialog_SVG_print_base.h"
|
||||
|
||||
|
||||
class DIALOG_SVG_PRINT : public DIALOG_SVG_PRINT_base
|
||||
{
|
||||
private:
|
||||
WinEDA_DrawFrame* m_Parent;
|
||||
wxConfig* m_Config;
|
||||
|
||||
public:
|
||||
DIALOG_SVG_PRINT( WinEDA_DrawFrame* parent );
|
||||
~DIALOG_SVG_PRINT() {}
|
||||
|
||||
private:
|
||||
void OnCloseWindow( wxCloseEvent& event );
|
||||
void OnInitDialog( wxInitDialogEvent& event );
|
||||
void OnButtonPlotCurrentClick( wxCommandEvent& event );
|
||||
void OnButtonPlotAllClick( wxCommandEvent& event );
|
||||
void OnButtonCancelClick( wxCommandEvent& event );
|
||||
void OnSetColorModeSelected( wxCommandEvent& event );
|
||||
void SetPenWidth();
|
||||
void PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref );
|
||||
|
||||
public:
|
||||
static bool DrawSVGPage( WinEDA_DrawFrame* frame,
|
||||
const wxString& FullFileName, BASE_SCREEN* screen,
|
||||
bool aPrintBlackAndWhite = false,
|
||||
bool aPrint_Sheet_Ref = false );
|
||||
};
|
||||
|
||||
|
||||
#endif // _DIALOG_SVG_PRINT_H_
|
|
@ -0,0 +1,926 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Name: dialog_build_BOM.cpp
|
||||
// Author: jean-pierre Charras
|
||||
// Modified by:
|
||||
// Licence: GPL
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include "fctsys.h"
|
||||
#include "appl_wxstruct.h"
|
||||
#include "common.h"
|
||||
#include "confirm.h"
|
||||
#include "gestfich.h"
|
||||
#include "kicad_string.h"
|
||||
#include "class_sch_screen.h"
|
||||
#include "wxstruct.h"
|
||||
#include "build_version.h"
|
||||
|
||||
#include "general.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 "protos.h"
|
||||
|
||||
|
||||
/* Local variables */
|
||||
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_BrowseCreatedList;
|
||||
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_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,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
#define OPTION_BOM_FORMAT wxT( "BomFormat" )
|
||||
#define OPTION_BOM_LAUNCH_BROWSER wxT( "BomLaunchBrowser" )
|
||||
#define OPTION_BOM_SEPARATOR wxT( "BomExportSeparator" )
|
||||
#define OPTION_BOM_ADD_FIELD wxT( "BomAddField" )
|
||||
|
||||
/* 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( WinEDA_DrawFrame* parent ) :
|
||||
DIALOG_BUILD_BOM_BASE( parent )
|
||||
{
|
||||
m_Config = wxGetApp().m_EDA_Config;
|
||||
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 */
|
||||
s_OutputFormOpt = m_Config->Read( OPTION_BOM_FORMAT, (long) 0 );
|
||||
s_BrowseCreatedList = m_Config->Read( OPTION_BOM_LAUNCH_BROWSER, (long) 0 );
|
||||
s_OutputSeparatorOpt = m_Config->Read( OPTION_BOM_SEPARATOR, (long) 0 );
|
||||
long addfields = m_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;
|
||||
}
|
||||
|
||||
// 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_ListBySheet ) );
|
||||
m_OutputFormCtrl->SetValidator( wxGenericValidator( &s_OutputFormOpt ) );
|
||||
m_OutputSeparatorCtrl->SetValidator( wxGenericValidator( &s_OutputSeparatorOpt ) );
|
||||
m_GetListBrowser->SetValidator( wxGenericValidator( &s_BrowseCreatedList ) );
|
||||
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 ) );
|
||||
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 );
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_RADIOBOX_SELECT_FORMAT
|
||||
*/
|
||||
|
||||
void DIALOG_BUILD_BOM::OnRadioboxSelectFormatSelected( wxCommandEvent& event )
|
||||
{
|
||||
if( m_OutputFormCtrl->GetSelection() == 0 )
|
||||
{
|
||||
m_OutputSeparatorCtrl->Enable( false );
|
||||
m_ListCmpbyValItems->Enable( true );
|
||||
m_GenListLabelsbyVal->Enable( true );
|
||||
m_GenListLabelsbySheet->Enable( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_OutputSeparatorCtrl->Enable( true );
|
||||
m_ListCmpbyValItems->Enable( false );
|
||||
m_GenListLabelsbyVal->Enable( false );
|
||||
m_GenListLabelsbySheet->Enable( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* 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()
|
||||
{
|
||||
wxASSERT( m_Config != NULL );
|
||||
|
||||
// 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_BrowseCreatedList = m_GetListBrowser->GetValue();
|
||||
|
||||
// (aved 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_FpField_state = m_AddFootprintField->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_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
|
||||
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->m_AssociatedScreen->m_FileName;
|
||||
|
||||
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 | wxFD_OVERWRITE_PROMPT );
|
||||
|
||||
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
|
||||
GenereListeOfItems( m_ListFileName, aIncludeSubComponents );
|
||||
break;
|
||||
|
||||
case 1: // speadsheet
|
||||
CreateExportList( m_ListFileName, aIncludeSubComponents );
|
||||
break;
|
||||
|
||||
case 2: // Single Part per line
|
||||
CreatePartsList( m_ListFileName, aIncludeSubComponents );
|
||||
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 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();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_BUILD_BOM::CreatePartsList( const wxString& aFullFileName, bool aIncludeSubComponents )
|
||||
{
|
||||
FILE* f;
|
||||
wxString msg;
|
||||
|
||||
if( ( f = wxFopen( aFullFileName, wxT( "wt" ) ) ) == NULL )
|
||||
{
|
||||
msg = _( "Failed to open file " );
|
||||
msg << aFullFileName;
|
||||
DisplayError( this, msg );
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector <OBJ_CMP_TO_LIST> cmplist;
|
||||
|
||||
BuildComponentsListFromSchematic( cmplist );
|
||||
|
||||
// sort component list by ref and remove sub components
|
||||
if( !aIncludeSubComponents )
|
||||
{
|
||||
sort( cmplist.begin(), cmplist.end(), SortComponentsByReference );
|
||||
DeleteSubCmp( cmplist );
|
||||
}
|
||||
|
||||
// sort component list by value
|
||||
sort( cmplist.begin(), cmplist.end(), SortComponentsByValue );
|
||||
PrintComponentsListByPart( f, cmplist,aIncludeSubComponents );
|
||||
|
||||
fclose( f );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Print a list of components, in a form which can be imported by a spreadsheet
|
||||
* form is:
|
||||
* cmp name; cmp val; fields;
|
||||
*/
|
||||
void DIALOG_BUILD_BOM::CreateExportList( const wxString& aFullFileName,
|
||||
bool aIncludeSubComponents )
|
||||
{
|
||||
FILE* f;
|
||||
wxString msg;
|
||||
|
||||
if( ( f = wxFopen( aFullFileName, wxT( "wt" ) ) ) == NULL )
|
||||
{
|
||||
msg = _( "Failed to open file " );
|
||||
msg << aFullFileName;
|
||||
DisplayError( this, msg );
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector <OBJ_CMP_TO_LIST> cmplist;
|
||||
BuildComponentsListFromSchematic( cmplist );
|
||||
|
||||
// sort component list
|
||||
sort( cmplist.begin(), cmplist.end(), SortComponentsByReference );
|
||||
|
||||
if( !aIncludeSubComponents )
|
||||
DeleteSubCmp( cmplist );
|
||||
|
||||
// create the file
|
||||
PrintComponentsListByRef( f, cmplist, TRUE, aIncludeSubComponents );
|
||||
|
||||
fclose( f );
|
||||
}
|
||||
|
||||
|
||||
/** GenereListeOfItems()
|
||||
* Main function to create the list of components and/or labels
|
||||
* (global labels and pin sheets" )
|
||||
*/
|
||||
void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName,
|
||||
bool aIncludeSubComponents )
|
||||
{
|
||||
FILE* f;
|
||||
int itemCount;
|
||||
char Line[1024];
|
||||
wxString msg;
|
||||
|
||||
if( ( f = wxFopen( aFullFileName, wxT( "wt" ) ) ) == NULL )
|
||||
{
|
||||
msg = _( "Failed to open file " );
|
||||
msg << aFullFileName;
|
||||
DisplayError( this, msg );
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector <OBJ_CMP_TO_LIST> cmplist;
|
||||
BuildComponentsListFromSchematic( cmplist );
|
||||
|
||||
itemCount = cmplist.size();
|
||||
if( itemCount )
|
||||
{
|
||||
// creates the list file
|
||||
DateAndTime( Line );
|
||||
|
||||
wxString Title = wxGetApp().GetAppName() + wxT( " " ) +
|
||||
GetBuildVersion();
|
||||
|
||||
fprintf( f, "%s >> Creation date: %s\n", CONV_TO_UTF8( Title ), Line );
|
||||
|
||||
// sort component list
|
||||
sort( cmplist.begin(), cmplist.end(), SortComponentsByReference );
|
||||
|
||||
if( !aIncludeSubComponents )
|
||||
DeleteSubCmp( cmplist );
|
||||
|
||||
if( m_ListCmpbyRefItems->GetValue() )
|
||||
PrintComponentsListByRef( f, cmplist, false, aIncludeSubComponents );
|
||||
|
||||
if( m_ListCmpbyValItems->GetValue() )
|
||||
{
|
||||
sort( cmplist.begin(), cmplist.end(), SortComponentsByValue );
|
||||
PrintComponentsListByVal( f, cmplist, aIncludeSubComponents );
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************/
|
||||
/* Create list of global labels and pins sheets */
|
||||
/*************************************************/
|
||||
std::vector <LABEL_OBJECT> listOfLabels;
|
||||
|
||||
GenListeGLabels( listOfLabels );
|
||||
if( ( itemCount = listOfLabels.size() ) > 0 )
|
||||
{
|
||||
if( m_GenListLabelsbySheet->GetValue() )
|
||||
{
|
||||
sort( listOfLabels.begin(), listOfLabels.end(), SortLabelsBySheet );
|
||||
|
||||
msg.Printf( _( "\n#Global, Hierarchical Labels and PinSheets \
|
||||
( order = Sheet Number ) count = %d\n" ),
|
||||
itemCount );
|
||||
|
||||
fprintf( f, "%s", CONV_TO_UTF8( msg ) );
|
||||
PrintListeGLabel( f, listOfLabels );
|
||||
}
|
||||
|
||||
if( m_GenListLabelsbyVal->GetValue() )
|
||||
{
|
||||
sort( listOfLabels.begin(), listOfLabels.end(), SortLabelsByValue );
|
||||
|
||||
msg.Printf( _( "\n#Global, Hierarchical Labels and PinSheets ( \
|
||||
order = Alphab. ) count = %d\n\n" ),
|
||||
itemCount );
|
||||
|
||||
fprintf( f, "%s", CONV_TO_UTF8( msg ) );
|
||||
PrintListeGLabel( f, listOfLabels );
|
||||
}
|
||||
}
|
||||
|
||||
msg = _( "\n#End List\n" );
|
||||
fprintf( f, "%s", CONV_TO_UTF8( msg ) );
|
||||
fclose( f );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_BUILD_BOM::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem,
|
||||
bool CompactForm )
|
||||
{
|
||||
int ii;
|
||||
|
||||
if( IsFieldChecked( FOOTPRINT ) )
|
||||
{
|
||||
if( CompactForm )
|
||||
{
|
||||
fprintf( f, "%c%s", s_ExportSeparatorSymbol,
|
||||
CONV_TO_UTF8( DrawLibItem->GetField( FOOTPRINT )->m_Text ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( f, "; %-12s",
|
||||
CONV_TO_UTF8( DrawLibItem->GetField( FOOTPRINT )->m_Text ) );
|
||||
}
|
||||
}
|
||||
|
||||
for( ii = FIELD1; ii < DrawLibItem->GetFieldCount(); ii++ )
|
||||
{
|
||||
if( ! IsFieldChecked( ii ) )
|
||||
continue;
|
||||
|
||||
if( CompactForm )
|
||||
fprintf( f, "%c%s", s_ExportSeparatorSymbol,
|
||||
CONV_TO_UTF8( DrawLibItem->GetField( ii )->m_Text ) );
|
||||
else
|
||||
fprintf( f, "; %-12s",
|
||||
CONV_TO_UTF8( DrawLibItem->GetField( ii )->m_Text ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Print the B.O.M sorted by reference
|
||||
*/
|
||||
int DIALOG_BUILD_BOM::PrintComponentsListByRef(
|
||||
FILE* f,
|
||||
std::vector <OBJ_CMP_TO_LIST>& aList,
|
||||
bool CompactForm,
|
||||
bool aIncludeSubComponents )
|
||||
{
|
||||
wxString msg;
|
||||
|
||||
if( CompactForm )
|
||||
{
|
||||
// Print comment line:
|
||||
#if defined(KICAD_GOST)
|
||||
fprintf( f, "ref%cvalue%cdatasheet", s_ExportSeparatorSymbol, s_ExportSeparatorSymbol );
|
||||
#else
|
||||
fprintf( f, "ref%cvalue", s_ExportSeparatorSymbol );
|
||||
#endif
|
||||
|
||||
if( aIncludeSubComponents )
|
||||
{
|
||||
fprintf( f, "%csheet path", s_ExportSeparatorSymbol );
|
||||
fprintf( f, "%clocation", s_ExportSeparatorSymbol );
|
||||
}
|
||||
|
||||
if( IsFieldChecked( FOOTPRINT ) )
|
||||
fprintf( f, "%cfootprint", s_ExportSeparatorSymbol );
|
||||
|
||||
for( int ii = FIELD1; ii <= FIELD8; ii++ )
|
||||
{
|
||||
if( !IsFieldChecked( ii ) )
|
||||
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 )" );
|
||||
|
||||
if( aIncludeSubComponents )
|
||||
msg << _( " (with SubCmp)" );
|
||||
|
||||
fprintf( f, "%s\n", CONV_TO_UTF8( msg ) );
|
||||
}
|
||||
|
||||
std::string CmpName;
|
||||
wxString subRef;
|
||||
|
||||
// Print list of items
|
||||
for( unsigned ii = 0; ii < aList.size(); ii++ )
|
||||
{
|
||||
EDA_BaseStruct* item = aList[ii].m_RootCmp;
|
||||
if( item == NULL )
|
||||
continue;
|
||||
|
||||
if( item->Type() != TYPE_SCH_COMPONENT )
|
||||
continue;
|
||||
|
||||
SCH_COMPONENT* comp = (SCH_COMPONENT*) item;
|
||||
|
||||
bool isMulti = false;
|
||||
|
||||
LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( comp->m_ChipName );
|
||||
if( entry )
|
||||
isMulti = entry->IsMulti();
|
||||
|
||||
if( isMulti && aIncludeSubComponents )
|
||||
subRef = LIB_COMPONENT::ReturnSubReference( aList[ii].m_Unit );
|
||||
else
|
||||
subRef.Empty();
|
||||
|
||||
CmpName = aList[ii].GetRefStr();
|
||||
|
||||
if( !CompactForm )
|
||||
CmpName += CONV_TO_UTF8(subRef);
|
||||
|
||||
if( CompactForm )
|
||||
#if defined(KICAD_GOST)
|
||||
fprintf( f, "%s%c%s%c%s", CmpName.c_str(), s_ExportSeparatorSymbol,
|
||||
CONV_TO_UTF8( comp->GetField( VALUE )->m_Text ), s_ExportSeparatorSymbol,
|
||||
CONV_TO_UTF8( comp->GetField( DATASHEET )->m_Text ) );
|
||||
#else
|
||||
fprintf( f, "%s%c%s", CmpName.c_str(), s_ExportSeparatorSymbol,
|
||||
CONV_TO_UTF8( comp->GetField( VALUE )->m_Text ) );
|
||||
#endif
|
||||
|
||||
else
|
||||
#if defined(KICAD_GOST)
|
||||
fprintf( f, "| %-10s %-12s %-20s", CmpName.c_str(),
|
||||
CONV_TO_UTF8( comp->GetField( VALUE )->m_Text ),
|
||||
CONV_TO_UTF8( comp->GetField( DATASHEET )->m_Text ) );
|
||||
#else
|
||||
fprintf( f, "| %-10s %-12s", CmpName.c_str(),
|
||||
CONV_TO_UTF8( comp->GetField( VALUE )->m_Text ) );
|
||||
#endif
|
||||
|
||||
if( aIncludeSubComponents )
|
||||
{
|
||||
msg = aList[ii].m_SheetPath.PathHumanReadable();
|
||||
|
||||
if( CompactForm )
|
||||
{
|
||||
fprintf( f, "%c%s", s_ExportSeparatorSymbol, CONV_TO_UTF8( msg ) );
|
||||
|
||||
msg = m_Parent->GetXYSheetReferences( (BASE_SCREEN*) comp->GetParent(),
|
||||
comp->m_Pos );
|
||||
|
||||
fprintf( f, "%c%s)", s_ExportSeparatorSymbol,
|
||||
CONV_TO_UTF8( msg ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( f, " (Sheet %s)", CONV_TO_UTF8( msg ) );
|
||||
|
||||
msg = m_Parent->GetXYSheetReferences( (BASE_SCREEN*) comp->GetParent(),
|
||||
comp->m_Pos );
|
||||
|
||||
fprintf( f, " (loc %s)", CONV_TO_UTF8( msg ) );
|
||||
}
|
||||
}
|
||||
|
||||
PrintFieldData( f, comp, CompactForm );
|
||||
|
||||
fprintf( f, "\n" );
|
||||
}
|
||||
|
||||
if( !CompactForm )
|
||||
{
|
||||
msg = _( "#End Cmp\n" );
|
||||
fputs( CONV_TO_UTF8( msg ), f );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Bom Output format option - single part per line
|
||||
* a common part being defined as have a common value.
|
||||
* This is true for most designs but will produce an
|
||||
* incorrect output if two or more parts with the same
|
||||
* value have different footprints, tolerances, voltage
|
||||
* rating, etc. Also usefull if the following fields
|
||||
* are edited:
|
||||
* FIELD1 - manufacture
|
||||
* FIELD2 - manufacture part number
|
||||
* FIELD3 - distributor part number
|
||||
*/
|
||||
int DIALOG_BUILD_BOM::PrintComponentsListByPart(
|
||||
FILE* f,
|
||||
std::vector <OBJ_CMP_TO_LIST>& aList,
|
||||
bool aIncludeSubComponents)
|
||||
{
|
||||
int qty = 0;
|
||||
wxString refName;
|
||||
wxString fullRefName; // reference + part Id (for multiple parts per package
|
||||
wxString valName;
|
||||
#if defined(KICAD_GOST)
|
||||
wxString footName;
|
||||
wxString datsName;
|
||||
#endif
|
||||
wxString refNames;
|
||||
wxString lastRef;
|
||||
wxString unitId;
|
||||
SCH_COMPONENT* currCmp;
|
||||
SCH_COMPONENT* nextCmp;
|
||||
SCH_COMPONENT dummyCmp; // A dummy component, to store fields
|
||||
|
||||
for( unsigned ii = 0; ii < aList.size(); ii++ )
|
||||
{
|
||||
currCmp = (SCH_COMPONENT*) aList[ii].m_RootCmp;
|
||||
|
||||
if( ii < aList.size() -1 )
|
||||
nextCmp = aList[ii+1].m_RootCmp;
|
||||
else
|
||||
nextCmp = NULL;
|
||||
|
||||
// Store fields. Store non empty fields only.
|
||||
for( int jj = FOOTPRINT; jj < currCmp->GetFieldCount(); jj++ )
|
||||
{
|
||||
// Ensure fields exists in dummy component
|
||||
if( dummyCmp.GetFieldCount() <= jj )
|
||||
dummyCmp.AddField( *currCmp->GetField( jj ) );
|
||||
|
||||
// store useful data
|
||||
if( !currCmp->GetField( jj )->m_Text.IsEmpty() )
|
||||
dummyCmp.GetField( jj )->m_Text = currCmp->GetField( jj )->m_Text;
|
||||
}
|
||||
|
||||
refName = aList[ii].GetRef();
|
||||
valName = currCmp->GetField( VALUE )->m_Text;
|
||||
#if defined(KICAD_GOST)
|
||||
footName = currCmp->GetField( FOOTPRINT )->m_Text;
|
||||
datsName = currCmp->GetField( DATASHEET )->m_Text;
|
||||
#endif
|
||||
|
||||
int multi = 0;
|
||||
|
||||
if( aIncludeSubComponents )
|
||||
{
|
||||
LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( currCmp->m_ChipName );
|
||||
|
||||
if( entry )
|
||||
multi = entry->GetPartCount();
|
||||
|
||||
if ( multi <= 1 )
|
||||
multi = 0;
|
||||
}
|
||||
|
||||
if ( multi && aList[ii].m_Unit > 0 )
|
||||
unitId.Printf( wxT("%c"), 'A' -1 + aList[ii].m_Unit );
|
||||
else
|
||||
unitId.Empty();
|
||||
|
||||
fullRefName = refName + unitId;
|
||||
|
||||
if( refNames.IsEmpty() )
|
||||
refNames = fullRefName;
|
||||
else
|
||||
refNames << wxT( ", " ) << fullRefName;
|
||||
|
||||
// In multi parts per package, we have the reference more than once
|
||||
// but we must count only one package
|
||||
if( lastRef != refName )
|
||||
qty++;
|
||||
|
||||
lastRef = refName;
|
||||
|
||||
// if the next cmoponent has same value the line will be printed after.
|
||||
#if defined(KICAD_GOST)
|
||||
if( nextCmp && nextCmp->GetField( VALUE )->m_Text.CmpNoCase( valName ) == 0
|
||||
&& nextCmp->GetField( FOOTPRINT )->m_Text.CmpNoCase( footName ) == 0
|
||||
&& nextCmp->GetField( DATASHEET )->m_Text.CmpNoCase( datsName ) == 0 )
|
||||
#else
|
||||
if( nextCmp && nextCmp->GetField( VALUE )->m_Text.CmpNoCase( valName ) == 0 )
|
||||
#endif
|
||||
continue;
|
||||
|
||||
// Print line for the current component value:
|
||||
fprintf( f, "%15s%c%3d", CONV_TO_UTF8( valName ), s_ExportSeparatorSymbol, qty );
|
||||
|
||||
if( IsFieldChecked(FOOTPRINT ) )
|
||||
fprintf( f, "%c%15s", s_ExportSeparatorSymbol,
|
||||
#if defined(KICAD_GOST)
|
||||
CONV_TO_UTF8( footName ) );
|
||||
#else
|
||||
CONV_TO_UTF8( currCmp->GetField( FOOTPRINT )->m_Text ) );
|
||||
#endif
|
||||
|
||||
#if defined(KICAD_GOST)
|
||||
fprintf( f, "%c%20s", s_ExportSeparatorSymbol,CONV_TO_UTF8( datsName ) );
|
||||
#endif
|
||||
|
||||
// wrap the field in quotes, since it has commas in it.
|
||||
fprintf( f, "%c\"%s\"", s_ExportSeparatorSymbol, CONV_TO_UTF8( refNames ) );
|
||||
|
||||
// print fields, on demand
|
||||
int last_nonempty_field_idx = 0;
|
||||
|
||||
for( int jj = FOOTPRINT; jj < dummyCmp.GetFieldCount(); jj++ )
|
||||
if ( !dummyCmp.GetField( jj )->m_Text.IsEmpty() )
|
||||
last_nonempty_field_idx = jj;
|
||||
|
||||
for( int jj = FIELD1; jj <= last_nonempty_field_idx ; jj++ )
|
||||
{
|
||||
if ( IsFieldChecked( jj ) )
|
||||
fprintf( f, "%c%4s", s_ExportSeparatorSymbol,
|
||||
CONV_TO_UTF8( dummyCmp.GetField( jj )->m_Text ) );
|
||||
}
|
||||
|
||||
fprintf( f, "\n" );
|
||||
|
||||
// Clear strings and values, to prepare next component
|
||||
qty = 0;
|
||||
refNames.Empty();
|
||||
|
||||
for( int jj = FOOTPRINT; jj < dummyCmp.GetFieldCount(); jj++ )
|
||||
dummyCmp.GetField( jj )->m_Text.Empty();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int DIALOG_BUILD_BOM::PrintComponentsListByVal(
|
||||
FILE* f,
|
||||
std::vector <OBJ_CMP_TO_LIST>& aList,
|
||||
bool aIncludeSubComponents )
|
||||
{
|
||||
EDA_BaseStruct* schItem;
|
||||
SCH_COMPONENT* DrawLibItem;
|
||||
LIB_COMPONENT* entry;
|
||||
std::string CmpName;
|
||||
wxString msg;
|
||||
|
||||
msg = _( "\n#Cmp ( order = Value )" );
|
||||
|
||||
if( aIncludeSubComponents )
|
||||
msg << _( " (with SubCmp)" );
|
||||
msg << wxT( "\n" );
|
||||
|
||||
fputs( CONV_TO_UTF8( msg ), f );
|
||||
|
||||
for( unsigned ii = 0; ii < aList.size(); ii++ )
|
||||
{
|
||||
schItem = aList[ii].m_RootCmp;
|
||||
|
||||
if( schItem == NULL )
|
||||
continue;
|
||||
|
||||
if( schItem->Type() != TYPE_SCH_COMPONENT )
|
||||
continue;
|
||||
|
||||
DrawLibItem = (SCH_COMPONENT*) schItem;
|
||||
|
||||
bool isMulti = false;
|
||||
entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
|
||||
if( entry )
|
||||
isMulti = entry->IsMulti();
|
||||
|
||||
wxString subRef;
|
||||
|
||||
if( isMulti && aIncludeSubComponents )
|
||||
subRef = LIB_COMPONENT::ReturnSubReference( aList[ii].m_Unit );
|
||||
else
|
||||
subRef.Empty();
|
||||
|
||||
CmpName = aList[ii].GetRefStr();
|
||||
CmpName += CONV_TO_UTF8(subRef);
|
||||
|
||||
fprintf( f, "| %-12s %-10s",
|
||||
CONV_TO_UTF8( DrawLibItem->GetField( VALUE )->m_Text ),
|
||||
CmpName.c_str() );
|
||||
|
||||
// print the sheet path
|
||||
if( aIncludeSubComponents )
|
||||
{
|
||||
msg = aList[ii].m_SheetPath.PathHumanReadable();
|
||||
fprintf( f, " (Sheet %s)", CONV_TO_UTF8( msg ) );
|
||||
msg = m_Parent->GetXYSheetReferences( (BASE_SCREEN*) DrawLibItem->GetParent(),
|
||||
DrawLibItem->m_Pos );
|
||||
fprintf( f, " (loc %s)", CONV_TO_UTF8( msg ) );
|
||||
}
|
||||
|
||||
PrintFieldData( f, DrawLibItem );
|
||||
|
||||
fputs( "\n", f );
|
||||
}
|
||||
|
||||
msg = _( "#End Cmp\n" );
|
||||
fputs( CONV_TO_UTF8( msg ), f );
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: dialog_build_BOM.h
|
||||
// Copyright: GNU license
|
||||
// Licence:
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _DIALOG_BUILD_BOM_H_
|
||||
#define _DIALOG_BUILD_BOM_H_
|
||||
|
||||
#include "dialog_build_BOM_base.h"
|
||||
|
||||
|
||||
class WinEDA_DrawFrame;
|
||||
class SCH_COMPONENT;
|
||||
class wxConfig;
|
||||
|
||||
|
||||
class DIALOG_BUILD_BOM : public DIALOG_BUILD_BOM_BASE
|
||||
{
|
||||
private:
|
||||
WinEDA_DrawFrame* m_Parent;
|
||||
wxConfig* m_Config;
|
||||
wxString m_ListFileName;
|
||||
|
||||
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 GenereListeOfItems( const wxString& FullFileName, bool aIncludeSubComponents );
|
||||
void CreateExportList( const wxString& FullFileName, bool aIncludeSubComponents );
|
||||
|
||||
/**
|
||||
* Function CreateParstList
|
||||
* prints a list of components, in a form which can be imported by a
|
||||
* spreadsheet. Form is:
|
||||
* cmp value; number of components; <footprint>; <field1>; ...;
|
||||
* list of references having the same value
|
||||
*/
|
||||
void CreatePartsList( const wxString& aFullFileName, bool aIncludeSubComponents );
|
||||
|
||||
int PrintComponentsListByRef( FILE* f, std::vector <OBJ_CMP_TO_LIST>& aList,
|
||||
bool CompactForm, bool aIncludeSubComponents );
|
||||
|
||||
int PrintComponentsListByVal( FILE* f, std::vector <OBJ_CMP_TO_LIST>& aList,
|
||||
bool aIncludeSubComponents );
|
||||
|
||||
int PrintComponentsListByPart( FILE* f, std::vector <OBJ_CMP_TO_LIST>& aList,
|
||||
bool aIncludeSubComponents );
|
||||
|
||||
void PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem, bool CompactForm = FALSE );
|
||||
|
||||
bool IsFieldChecked( int aFieldId );
|
||||
|
||||
public:
|
||||
DIALOG_BUILD_BOM( WinEDA_DrawFrame* parent );
|
||||
|
||||
// ~DIALOG_BUILD_BOM() {};
|
||||
};
|
||||
|
||||
#endif // _DIALOG_BUILD_BOM_H_
|
|
@ -7,8 +7,9 @@ DIALOG_LIB_EDIT_DRAW_ITEM::DIALOG_LIB_EDIT_DRAW_ITEM( wxWindow* parent,
|
|||
{
|
||||
SetTitle( itemName + wxT( " " ) + GetTitle() );
|
||||
|
||||
// Required under wxGTK if we want to demiss the dialog with the ESC key
|
||||
// Required under wxGTK if we want to dismiss the dialog with the ESC key
|
||||
SetFocus();
|
||||
m_sdbSizer1OK->SetDefault();
|
||||
}
|
||||
|
||||
|
|
@ -10,45 +10,23 @@
|
|||
#include "class_drawpanel.h"
|
||||
|
||||
#include "general.h"
|
||||
#include "protos.h"
|
||||
#include "libeditframe.h"
|
||||
#include "class_libentry.h"
|
||||
#include "lib_text.h"
|
||||
|
||||
#include "dialog_bodygraphictext_properties_base.h"
|
||||
#include "dialog_lib_edit_text.h"
|
||||
|
||||
|
||||
class Dialog_BodyGraphicText_Properties : public Dialog_BodyGraphicText_Properties_base
|
||||
{
|
||||
private:
|
||||
WinEDA_LibeditFrame * m_Parent;
|
||||
LIB_TEXT* m_GraphicText;
|
||||
|
||||
public:
|
||||
Dialog_BodyGraphicText_Properties( WinEDA_LibeditFrame* aParent,
|
||||
LIB_TEXT* aGraphicText );
|
||||
~Dialog_BodyGraphicText_Properties() {};
|
||||
|
||||
private:
|
||||
void InitDialog( );
|
||||
void OnOkClick( wxCommandEvent& event );
|
||||
void OnCancelClick( wxCommandEvent& event );
|
||||
};
|
||||
|
||||
|
||||
Dialog_BodyGraphicText_Properties::Dialog_BodyGraphicText_Properties( WinEDA_LibeditFrame* aParent,
|
||||
LIB_TEXT* aGraphicText ) :
|
||||
Dialog_BodyGraphicText_Properties_base( aParent )
|
||||
DIALOG_LIB_EDIT_TEXT::DIALOG_LIB_EDIT_TEXT( WinEDA_LibeditFrame* aParent, LIB_TEXT* aText ) :
|
||||
DIALOG_LIB_EDIT_TEXT_BASE( aParent )
|
||||
{
|
||||
m_Parent = aParent;
|
||||
m_GraphicText = aGraphicText;
|
||||
InitDialog( );
|
||||
m_GraphicText = aText;
|
||||
InitDialog();
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************/
|
||||
void Dialog_BodyGraphicText_Properties::InitDialog( )
|
||||
/*****************************************************/
|
||||
void DIALOG_LIB_EDIT_TEXT::InitDialog( )
|
||||
{
|
||||
wxString msg;
|
||||
|
||||
|
@ -79,15 +57,15 @@ void Dialog_BodyGraphicText_Properties::InitDialog( )
|
|||
switch ( m_GraphicText->m_HJustify )
|
||||
{
|
||||
case GR_TEXT_HJUSTIFY_LEFT:
|
||||
m_TextHJustificationOpt->SetSelection(0);
|
||||
m_TextHJustificationOpt->SetSelection( 0 );
|
||||
break;
|
||||
|
||||
case GR_TEXT_HJUSTIFY_CENTER:
|
||||
m_TextHJustificationOpt->SetSelection(1);
|
||||
m_TextHJustificationOpt->SetSelection( 1 );
|
||||
break;
|
||||
|
||||
case GR_TEXT_HJUSTIFY_RIGHT:
|
||||
m_TextHJustificationOpt->SetSelection(2);
|
||||
m_TextHJustificationOpt->SetSelection( 2 );
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -95,15 +73,15 @@ void Dialog_BodyGraphicText_Properties::InitDialog( )
|
|||
switch ( m_GraphicText->m_VJustify )
|
||||
{
|
||||
case GR_TEXT_VJUSTIFY_BOTTOM:
|
||||
m_TextVJustificationOpt->SetSelection(0);
|
||||
m_TextVJustificationOpt->SetSelection( 0 );
|
||||
break;
|
||||
|
||||
case GR_TEXT_VJUSTIFY_CENTER:
|
||||
m_TextVJustificationOpt->SetSelection(1);
|
||||
m_TextVJustificationOpt->SetSelection( 1 );
|
||||
break;
|
||||
|
||||
case GR_TEXT_VJUSTIFY_TOP:
|
||||
m_TextVJustificationOpt->SetSelection(2);
|
||||
m_TextVJustificationOpt->SetSelection( 2 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -128,19 +106,19 @@ void Dialog_BodyGraphicText_Properties::InitDialog( )
|
|||
{
|
||||
GetSizer()->SetSizeHints(this);
|
||||
}
|
||||
|
||||
m_sdbSizer1OK->SetDefault();
|
||||
}
|
||||
|
||||
|
||||
void Dialog_BodyGraphicText_Properties::OnCancelClick( wxCommandEvent& event )
|
||||
void DIALOG_LIB_EDIT_TEXT::OnCancelClick( wxCommandEvent& event )
|
||||
{
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
void Dialog_BodyGraphicText_Properties::OnOkClick( wxCommandEvent& event )
|
||||
/***************************************************************************/
|
||||
/* Updates the different parameters for the component being edited */
|
||||
void DIALOG_LIB_EDIT_TEXT::OnOkClick( wxCommandEvent& event )
|
||||
{
|
||||
wxString Line;
|
||||
|
||||
|
@ -151,9 +129,9 @@ void Dialog_BodyGraphicText_Properties::OnOkClick( wxCommandEvent& event )
|
|||
m_Parent->m_drawSpecificConvert = m_CommonConvert->GetValue() ? false : true;
|
||||
m_Parent->m_drawSpecificUnit = m_CommonUnit->GetValue() ? false : true;
|
||||
|
||||
if ( m_GraphicText )
|
||||
if( m_GraphicText )
|
||||
{
|
||||
if ( ! Line.IsEmpty() )
|
||||
if( ! Line.IsEmpty() )
|
||||
m_GraphicText->SetText( Line );
|
||||
else
|
||||
m_GraphicText->SetText( wxT( "[null]" ) );
|
||||
|
@ -171,17 +149,17 @@ void Dialog_BodyGraphicText_Properties::OnOkClick( wxCommandEvent& event )
|
|||
else
|
||||
m_GraphicText->SetConvert( 0 );
|
||||
|
||||
if ( (m_TextShapeOpt->GetSelection() & 1 ) != 0 )
|
||||
if( ( m_TextShapeOpt->GetSelection() & 1 ) != 0 )
|
||||
m_GraphicText->m_Italic = true;
|
||||
else
|
||||
m_GraphicText->m_Italic = false;
|
||||
|
||||
if ( (m_TextShapeOpt->GetSelection() & 2 ) != 0 )
|
||||
if( ( m_TextShapeOpt->GetSelection() & 2 ) != 0 )
|
||||
m_GraphicText->m_Bold = true;
|
||||
else
|
||||
m_GraphicText->m_Bold = false;
|
||||
|
||||
switch ( m_TextHJustificationOpt->GetSelection() )
|
||||
switch( m_TextHJustificationOpt->GetSelection() )
|
||||
{
|
||||
case 0:
|
||||
m_GraphicText->m_HJustify = GR_TEXT_HJUSTIFY_LEFT;
|
||||
|
@ -196,7 +174,7 @@ void Dialog_BodyGraphicText_Properties::OnOkClick( wxCommandEvent& event )
|
|||
break;
|
||||
}
|
||||
|
||||
switch ( m_TextVJustificationOpt->GetSelection() )
|
||||
switch( m_TextVJustificationOpt->GetSelection() )
|
||||
{
|
||||
case 0:
|
||||
m_GraphicText->m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM;
|
||||
|
@ -211,33 +189,9 @@ void Dialog_BodyGraphicText_Properties::OnOkClick( wxCommandEvent& event )
|
|||
break;
|
||||
}
|
||||
}
|
||||
Close();
|
||||
|
||||
if ( m_Parent->GetDrawItem() )
|
||||
if( m_Parent->GetDrawItem() )
|
||||
m_Parent->GetDrawItem()->DisplayInfo( m_Parent );
|
||||
|
||||
Close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void WinEDA_LibeditFrame::EditSymbolText( wxDC* DC, LIB_DRAW_ITEM* DrawItem )
|
||||
{
|
||||
if ( ( DrawItem == NULL ) || ( DrawItem->Type() != COMPONENT_GRAPHIC_TEXT_DRAW_TYPE ) )
|
||||
return;
|
||||
|
||||
/* Deleting old text. */
|
||||
if( DC && !DrawItem->InEditMode() )
|
||||
DrawItem->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, NULL, DefaultTransform );
|
||||
|
||||
|
||||
Dialog_BodyGraphicText_Properties * frame =
|
||||
new Dialog_BodyGraphicText_Properties( this, (LIB_TEXT*) DrawItem );
|
||||
frame->ShowModal();
|
||||
frame->Destroy();
|
||||
OnModify();
|
||||
|
||||
/* Display new text. */
|
||||
if( DC && !DrawItem->InEditMode() )
|
||||
DrawItem->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, GR_DEFAULT_DRAWMODE, NULL,
|
||||
DefaultTransform );
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
#ifndef _DIALOG_LIB_EDIT_TEXT_H_
|
||||
#define _DIALOG_LIB_EDIT_TEXT_H_
|
||||
|
||||
|
||||
#include "dialog_lib_edit_text_base.h"
|
||||
|
||||
|
||||
class WinEDA_LibeditFrame;
|
||||
class LIB_TEXT;
|
||||
|
||||
|
||||
class DIALOG_LIB_EDIT_TEXT : public DIALOG_LIB_EDIT_TEXT_BASE
|
||||
{
|
||||
private:
|
||||
WinEDA_LibeditFrame* m_Parent;
|
||||
LIB_TEXT* m_GraphicText;
|
||||
|
||||
public:
|
||||
DIALOG_LIB_EDIT_TEXT( WinEDA_LibeditFrame* aParent, LIB_TEXT* aText );
|
||||
~DIALOG_LIB_EDIT_TEXT() {};
|
||||
|
||||
private:
|
||||
void InitDialog( );
|
||||
void OnOkClick( wxCommandEvent& aEvent );
|
||||
void OnCancelClick( wxCommandEvent& aEvent );
|
||||
};
|
||||
|
||||
|
||||
#endif // _DIALOG_LIB_EDIT_TEXT_H_
|
|
@ -1,127 +1,115 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Apr 16 2008)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "dialog_bodygraphictext_properties_base.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Dialog_BodyGraphicText_Properties_base::Dialog_BodyGraphicText_Properties_base( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
|
||||
{
|
||||
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
|
||||
|
||||
wxBoxSizer* bMainSizer;
|
||||
bMainSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
wxBoxSizer* bPropertiesSizer;
|
||||
bPropertiesSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxBoxSizer* bUpperBoxSizer;
|
||||
bUpperBoxSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
wxBoxSizer* bTextValueBoxSizer;
|
||||
bTextValueBoxSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_staticText1 = new wxStaticText( this, wxID_ANY, _("Text:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText1->Wrap( -1 );
|
||||
bTextValueBoxSizer->Add( m_staticText1, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_TextValue = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_TextValue->SetMinSize( wxSize( 200,-1 ) );
|
||||
|
||||
bTextValueBoxSizer->Add( m_TextValue, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
|
||||
|
||||
bUpperBoxSizer->Add( bTextValueBoxSizer, 1, wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bTextSizeSizer;
|
||||
bTextSizeSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_TextSizeText = new wxStaticText( this, wxID_ANY, _("Size"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_TextSizeText->Wrap( -1 );
|
||||
bTextSizeSizer->Add( m_TextSizeText, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_TextSize = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bTextSizeSizer->Add( m_TextSize, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
bUpperBoxSizer->Add( bTextSizeSizer, 0, 0, 5 );
|
||||
|
||||
bPropertiesSizer->Add( bUpperBoxSizer, 0, wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bBottomtBoxSizer;
|
||||
bBottomtBoxSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
wxStaticBoxSizer* sOptionsSizer;
|
||||
sOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _(" Text Options : ") ), wxVERTICAL );
|
||||
|
||||
m_Orient = new wxCheckBox( this, wxID_ANY, _("Vertical"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
|
||||
sOptionsSizer->Add( m_Orient, 0, wxALL, 5 );
|
||||
|
||||
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
|
||||
sOptionsSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
|
||||
|
||||
m_CommonUnit = new wxCheckBox( this, wxID_ANY, _("Common to Units"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
|
||||
sOptionsSizer->Add( m_CommonUnit, 0, wxALL, 5 );
|
||||
|
||||
m_CommonConvert = new wxCheckBox( this, wxID_ANY, _("Common to convert"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
|
||||
sOptionsSizer->Add( m_CommonConvert, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
bBottomtBoxSizer->Add( sOptionsSizer, 0, 0, 5 );
|
||||
|
||||
wxString m_TextShapeOptChoices[] = { _("Normal"), _("Italic"), _("Bold"), _("Bold Italic") };
|
||||
int m_TextShapeOptNChoices = sizeof( m_TextShapeOptChoices ) / sizeof( wxString );
|
||||
m_TextShapeOpt = new wxRadioBox( this, wxID_ANY, _("Text Shape:"), wxDefaultPosition, wxDefaultSize, m_TextShapeOptNChoices, m_TextShapeOptChoices, 1, wxRA_SPECIFY_COLS );
|
||||
m_TextShapeOpt->SetSelection( 0 );
|
||||
bBottomtBoxSizer->Add( m_TextShapeOpt, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
wxString m_TextHJustificationOptChoices[] = { _("Align left"), _("Align center"), _("Align right") };
|
||||
int m_TextHJustificationOptNChoices = sizeof( m_TextHJustificationOptChoices ) / sizeof( wxString );
|
||||
m_TextHJustificationOpt = new wxRadioBox( this, wxID_ANY, _("Horiz. Justify"), wxDefaultPosition, wxDefaultSize, m_TextHJustificationOptNChoices, m_TextHJustificationOptChoices, 1, wxRA_SPECIFY_COLS );
|
||||
m_TextHJustificationOpt->SetSelection( 1 );
|
||||
bBottomtBoxSizer->Add( m_TextHJustificationOpt, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
wxString m_TextVJustificationOptChoices[] = { _("Align bottom"), _("Align center"), _("Align top") };
|
||||
int m_TextVJustificationOptNChoices = sizeof( m_TextVJustificationOptChoices ) / sizeof( wxString );
|
||||
m_TextVJustificationOpt = new wxRadioBox( this, wxID_ANY, _("Vert. Justify"), wxDefaultPosition, wxDefaultSize, m_TextVJustificationOptNChoices, m_TextVJustificationOptChoices, 1, wxRA_SPECIFY_COLS );
|
||||
m_TextVJustificationOpt->SetSelection( 1 );
|
||||
bBottomtBoxSizer->Add( m_TextVJustificationOpt, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
bPropertiesSizer->Add( bBottomtBoxSizer, 1, wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bRightSizer;
|
||||
bRightSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
bPropertiesSizer->Add( bRightSizer, 0, wxEXPAND, 5 );
|
||||
|
||||
bMainSizer->Add( bPropertiesSizer, 1, wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bButtonsBoxSizer;
|
||||
bButtonsBoxSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_buttonOK = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bButtonsBoxSizer->Add( m_buttonOK, 0, wxALL, 5 );
|
||||
|
||||
m_buttonCANCEL = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bButtonsBoxSizer->Add( m_buttonCANCEL, 0, wxALL, 5 );
|
||||
|
||||
bMainSizer->Add( bButtonsBoxSizer, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
||||
|
||||
this->SetSizer( bMainSizer );
|
||||
this->Layout();
|
||||
|
||||
// Connect Events
|
||||
m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( Dialog_BodyGraphicText_Properties_base::OnOkClick ), NULL, this );
|
||||
m_buttonCANCEL->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( Dialog_BodyGraphicText_Properties_base::OnCancelClick ), NULL, this );
|
||||
}
|
||||
|
||||
Dialog_BodyGraphicText_Properties_base::~Dialog_BodyGraphicText_Properties_base()
|
||||
{
|
||||
// Disconnect Events
|
||||
m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( Dialog_BodyGraphicText_Properties_base::OnOkClick ), NULL, this );
|
||||
m_buttonCANCEL->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( Dialog_BodyGraphicText_Properties_base::OnCancelClick ), NULL, this );
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Sep 8 2010)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "dialog_lib_edit_text_base.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DIALOG_LIB_EDIT_TEXT_BASE::DIALOG_LIB_EDIT_TEXT_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
|
||||
{
|
||||
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
|
||||
|
||||
wxBoxSizer* bMainSizer;
|
||||
bMainSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxBoxSizer* bPropertiesSizer;
|
||||
bPropertiesSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxBoxSizer* bUpperBoxSizer;
|
||||
bUpperBoxSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
wxBoxSizer* bTextValueBoxSizer;
|
||||
bTextValueBoxSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_staticText1 = new wxStaticText( this, wxID_ANY, _("Text:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText1->Wrap( -1 );
|
||||
bTextValueBoxSizer->Add( m_staticText1, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_TextValue = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_TextValue->SetMinSize( wxSize( 200,-1 ) );
|
||||
|
||||
bTextValueBoxSizer->Add( m_TextValue, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
|
||||
|
||||
bUpperBoxSizer->Add( bTextValueBoxSizer, 1, wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bTextSizeSizer;
|
||||
bTextSizeSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_TextSizeText = new wxStaticText( this, wxID_ANY, _("Size"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_TextSizeText->Wrap( -1 );
|
||||
bTextSizeSizer->Add( m_TextSizeText, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_TextSize = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bTextSizeSizer->Add( m_TextSize, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
bUpperBoxSizer->Add( bTextSizeSizer, 0, 0, 5 );
|
||||
|
||||
bPropertiesSizer->Add( bUpperBoxSizer, 0, wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bBottomtBoxSizer;
|
||||
bBottomtBoxSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
wxStaticBoxSizer* sOptionsSizer;
|
||||
sOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _(" Text Options : ") ), wxVERTICAL );
|
||||
|
||||
m_Orient = new wxCheckBox( this, wxID_ANY, _("Vertical"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
sOptionsSizer->Add( m_Orient, 0, wxALL, 5 );
|
||||
|
||||
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
|
||||
sOptionsSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
|
||||
|
||||
m_CommonUnit = new wxCheckBox( this, wxID_ANY, _("Common to Units"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
sOptionsSizer->Add( m_CommonUnit, 0, wxALL, 5 );
|
||||
|
||||
m_CommonConvert = new wxCheckBox( this, wxID_ANY, _("Common to convert"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
sOptionsSizer->Add( m_CommonConvert, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
bBottomtBoxSizer->Add( sOptionsSizer, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
wxString m_TextShapeOptChoices[] = { _("Normal"), _("Italic"), _("Bold"), _("Bold Italic") };
|
||||
int m_TextShapeOptNChoices = sizeof( m_TextShapeOptChoices ) / sizeof( wxString );
|
||||
m_TextShapeOpt = new wxRadioBox( this, wxID_ANY, _("Text Shape:"), wxDefaultPosition, wxDefaultSize, m_TextShapeOptNChoices, m_TextShapeOptChoices, 1, wxRA_SPECIFY_COLS );
|
||||
m_TextShapeOpt->SetSelection( 0 );
|
||||
bBottomtBoxSizer->Add( m_TextShapeOpt, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
wxString m_TextHJustificationOptChoices[] = { _("Align left"), _("Align center"), _("Align right") };
|
||||
int m_TextHJustificationOptNChoices = sizeof( m_TextHJustificationOptChoices ) / sizeof( wxString );
|
||||
m_TextHJustificationOpt = new wxRadioBox( this, wxID_ANY, _("Horiz. Justify"), wxDefaultPosition, wxDefaultSize, m_TextHJustificationOptNChoices, m_TextHJustificationOptChoices, 1, wxRA_SPECIFY_COLS );
|
||||
m_TextHJustificationOpt->SetSelection( 1 );
|
||||
bBottomtBoxSizer->Add( m_TextHJustificationOpt, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
wxString m_TextVJustificationOptChoices[] = { _("Align bottom"), _("Align center"), _("Align top") };
|
||||
int m_TextVJustificationOptNChoices = sizeof( m_TextVJustificationOptChoices ) / sizeof( wxString );
|
||||
m_TextVJustificationOpt = new wxRadioBox( this, wxID_ANY, _("Vert. Justify"), wxDefaultPosition, wxDefaultSize, m_TextVJustificationOptNChoices, m_TextVJustificationOptChoices, 1, wxRA_SPECIFY_COLS );
|
||||
m_TextVJustificationOpt->SetSelection( 1 );
|
||||
bBottomtBoxSizer->Add( m_TextVJustificationOpt, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
bPropertiesSizer->Add( bBottomtBoxSizer, 1, wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bRightSizer;
|
||||
bRightSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
bPropertiesSizer->Add( bRightSizer, 0, wxEXPAND, 5 );
|
||||
|
||||
bMainSizer->Add( bPropertiesSizer, 1, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 6 );
|
||||
|
||||
m_sdbSizer1 = new wxStdDialogButtonSizer();
|
||||
m_sdbSizer1OK = new wxButton( this, wxID_OK );
|
||||
m_sdbSizer1->AddButton( m_sdbSizer1OK );
|
||||
m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL );
|
||||
m_sdbSizer1->AddButton( m_sdbSizer1Cancel );
|
||||
m_sdbSizer1->Realize();
|
||||
bMainSizer->Add( m_sdbSizer1, 0, wxALL|wxEXPAND, 12 );
|
||||
|
||||
this->SetSizer( bMainSizer );
|
||||
this->Layout();
|
||||
bMainSizer->Fit( this );
|
||||
}
|
||||
|
||||
DIALOG_LIB_EDIT_TEXT_BASE::~DIALOG_LIB_EDIT_TEXT_BASE()
|
||||
{
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,63 +1,60 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Apr 16 2008)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __dialog_bodygraphictext_properties_base__
|
||||
#define __dialog_bodygraphictext_properties_base__
|
||||
|
||||
#include <wx/intl.h>
|
||||
|
||||
#include <wx/string.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/font.h>
|
||||
#include <wx/colour.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/statline.h>
|
||||
#include <wx/statbox.h>
|
||||
#include <wx/radiobox.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/dialog.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Class Dialog_BodyGraphicText_Properties_base
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class Dialog_BodyGraphicText_Properties_base : public wxDialog
|
||||
{
|
||||
private:
|
||||
|
||||
protected:
|
||||
wxStaticText* m_staticText1;
|
||||
wxTextCtrl* m_TextValue;
|
||||
wxStaticText* m_TextSizeText;
|
||||
wxTextCtrl* m_TextSize;
|
||||
wxCheckBox* m_Orient;
|
||||
wxStaticLine* m_staticline1;
|
||||
wxCheckBox* m_CommonUnit;
|
||||
wxCheckBox* m_CommonConvert;
|
||||
wxRadioBox* m_TextShapeOpt;
|
||||
wxRadioBox* m_TextHJustificationOpt;
|
||||
wxRadioBox* m_TextVJustificationOpt;
|
||||
wxButton* m_buttonOK;
|
||||
wxButton* m_buttonCANCEL;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void OnOkClick( wxCommandEvent& event ){ event.Skip(); }
|
||||
virtual void OnCancelClick( wxCommandEvent& event ){ event.Skip(); }
|
||||
|
||||
|
||||
public:
|
||||
Dialog_BodyGraphicText_Properties_base( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Graphic text properties:"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 511,193 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
~Dialog_BodyGraphicText_Properties_base();
|
||||
|
||||
};
|
||||
|
||||
#endif //__dialog_bodygraphictext_properties_base__
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Sep 8 2010)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __dialog_lib_edit_text_base__
|
||||
#define __dialog_lib_edit_text_base__
|
||||
|
||||
#include <wx/intl.h>
|
||||
|
||||
#include <wx/string.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/font.h>
|
||||
#include <wx/colour.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/statline.h>
|
||||
#include <wx/statbox.h>
|
||||
#include <wx/radiobox.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/dialog.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Class DIALOG_LIB_EDIT_TEXT_BASE
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class DIALOG_LIB_EDIT_TEXT_BASE : public wxDialog
|
||||
{
|
||||
private:
|
||||
|
||||
protected:
|
||||
wxStaticText* m_staticText1;
|
||||
wxTextCtrl* m_TextValue;
|
||||
wxStaticText* m_TextSizeText;
|
||||
wxTextCtrl* m_TextSize;
|
||||
wxCheckBox* m_Orient;
|
||||
wxStaticLine* m_staticline1;
|
||||
wxCheckBox* m_CommonUnit;
|
||||
wxCheckBox* m_CommonConvert;
|
||||
wxRadioBox* m_TextShapeOpt;
|
||||
wxRadioBox* m_TextHJustificationOpt;
|
||||
wxRadioBox* m_TextVJustificationOpt;
|
||||
wxStdDialogButtonSizer* m_sdbSizer1;
|
||||
wxButton* m_sdbSizer1OK;
|
||||
wxButton* m_sdbSizer1Cancel;
|
||||
|
||||
public:
|
||||
|
||||
DIALOG_LIB_EDIT_TEXT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Library Text Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
~DIALOG_LIB_EDIT_TEXT_BASE();
|
||||
|
||||
};
|
||||
|
||||
#endif //__dialog_lib_edit_text_base__
|
|
@ -26,6 +26,9 @@
|
|||
#include "kicad_device_context.h"
|
||||
#include "hotkeys.h"
|
||||
|
||||
#include "dialogs/dialog_lib_edit_text.h"
|
||||
#include "dialogs/dialog_SVG_print.h"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
|
||||
|
@ -990,3 +993,33 @@ void WinEDA_LibeditFrame::ClearTempCopyComponent()
|
|||
delete m_tempCopyComponent;
|
||||
m_tempCopyComponent = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Creates the SVG print file for the current edited component.
|
||||
*/
|
||||
void WinEDA_LibeditFrame::SVG_Print_Component( const wxString& FullFileName )
|
||||
{
|
||||
DIALOG_SVG_PRINT::DrawSVGPage( this, FullFileName, GetScreen() );
|
||||
}
|
||||
|
||||
|
||||
void WinEDA_LibeditFrame::EditSymbolText( wxDC* DC, LIB_DRAW_ITEM* DrawItem )
|
||||
{
|
||||
if ( ( DrawItem == NULL ) || ( DrawItem->Type() != COMPONENT_GRAPHIC_TEXT_DRAW_TYPE ) )
|
||||
return;
|
||||
|
||||
/* Deleting old text. */
|
||||
if( DC && !DrawItem->InEditMode() )
|
||||
DrawItem->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, NULL, DefaultTransform );
|
||||
|
||||
|
||||
DIALOG_LIB_EDIT_TEXT* frame = new DIALOG_LIB_EDIT_TEXT( this, (LIB_TEXT*) DrawItem );
|
||||
frame->ShowModal();
|
||||
frame->Destroy();
|
||||
OnModify();
|
||||
|
||||
/* Display new text. */
|
||||
if( DC && !DrawItem->InEditMode() )
|
||||
DrawItem->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, GR_DEFAULT_DRAWMODE, NULL,
|
||||
DefaultTransform );
|
||||
}
|
||||
|
|
|
@ -16,8 +16,7 @@ class CMP_LIBRARY;
|
|||
class LIB_COMPONENT;
|
||||
class LIB_ALIAS;
|
||||
class LIB_FIELD;
|
||||
class WinEDA_bodygraphics_PropertiesFrame;
|
||||
class Dialog_BodyGraphicText_Properties;
|
||||
class DIALOG_LIB_EDIT_TEXT;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -317,7 +316,7 @@ protected:
|
|||
|
||||
static wxSize m_clientSize;
|
||||
|
||||
friend class Dialog_BodyGraphicText_Properties;
|
||||
friend class DIALOG_LIB_EDIT_TEXT;
|
||||
|
||||
/**
|
||||
* Function CreatePNGorJPEGFile
|
||||
|
@ -342,11 +341,11 @@ protected:
|
|||
bool aPrintMirrorMode, void* aData = NULL );
|
||||
|
||||
/**
|
||||
* Function SVG_Print_component
|
||||
* Function SVG_Print_Component
|
||||
* Creates the SVG print file for the current edited component.
|
||||
* @param aFullFileName = the full filename of the file
|
||||
*/
|
||||
void SVG_Print_Component( const wxString& aFullFileName );
|
||||
*/
|
||||
void SVG_Print_Component( const wxString& aFullFileName );
|
||||
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "block_commande.h"
|
||||
#include "colors.h"
|
||||
#include "sch_sheet_path.h"
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
|
@ -24,6 +25,8 @@ class SCH_SHEET_PIN;
|
|||
class PLOTTER;
|
||||
class SCH_SHEET;
|
||||
class LIB_PIN;
|
||||
class LABEL_OBJECT;
|
||||
class OBJ_CMP_TO_LIST;
|
||||
|
||||
|
||||
wxString ReturnDefaultFieldName( int aFieldNdx );
|
||||
|
@ -62,6 +65,40 @@ bool LibItemInBox( int x1, int y1, int x2, int y2, SCH_COMPONENT* Draw
|
|||
/************/
|
||||
void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct );
|
||||
|
||||
|
||||
// build_BOM.cpp
|
||||
/**
|
||||
* Class LABEL_OBJECT
|
||||
* is used in build BOM to handle the list of labels in schematic
|
||||
* because in a complex hierarchy, a label is used more than once,
|
||||
* and had more than one sheet path, so we must create a flat list of labels
|
||||
*/
|
||||
class LABEL_OBJECT
|
||||
{
|
||||
public:
|
||||
int m_LabelType;
|
||||
SCH_ITEM* m_Label;
|
||||
|
||||
//have to store it here since the object references will be duplicated.
|
||||
SCH_SHEET_PATH m_SheetPath; //composed of UIDs
|
||||
|
||||
public: LABEL_OBJECT()
|
||||
{
|
||||
m_Label = NULL;
|
||||
m_LabelType = 0;
|
||||
}
|
||||
};
|
||||
|
||||
void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList );
|
||||
void GenListeGLabels( std::vector <LABEL_OBJECT>& aList );
|
||||
bool SortComponentsByReference( const OBJ_CMP_TO_LIST& obj1, const OBJ_CMP_TO_LIST& obj2 );
|
||||
bool SortComponentsByValue( const OBJ_CMP_TO_LIST& obj1, const OBJ_CMP_TO_LIST& obj2 );
|
||||
bool SortLabelsByValue( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 );
|
||||
bool SortLabelsBySheet( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 );
|
||||
void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList );
|
||||
int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList );
|
||||
|
||||
|
||||
// operations_on_item_lists.cpp
|
||||
/**
|
||||
* Function DuplicateStruct
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "wxEeschemaStruct.h"
|
||||
#include "class_sch_screen.h"
|
||||
|
||||
#include "dialog_build_BOM.h"
|
||||
#include "netlist_control.h"
|
||||
#include "libeditframe.h"
|
||||
#include "viewlib_frame.h"
|
||||
|
@ -31,9 +30,11 @@
|
|||
#include "sch_sheet.h"
|
||||
|
||||
#include "dialogs/annotate_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_SVG_print.h"
|
||||
|
||||
|
||||
BEGIN_EVENT_TABLE( WinEDA_SchematicFrame, WinEDA_DrawFrame )
|
||||
|
@ -58,7 +59,7 @@ BEGIN_EVENT_TABLE( WinEDA_SchematicFrame, WinEDA_DrawFrame )
|
|||
EVT_MENU( wxID_PRINT, WinEDA_SchematicFrame::OnPrint )
|
||||
EVT_MENU( ID_GEN_PLOT_PS, WinEDA_SchematicFrame::ToPlot_PS )
|
||||
EVT_MENU( ID_GEN_PLOT_HPGL, WinEDA_SchematicFrame::ToPlot_HPGL )
|
||||
EVT_MENU( ID_GEN_PLOT_SVG, WinEDA_DrawFrame::SVG_Print )
|
||||
EVT_MENU( ID_GEN_PLOT_SVG, WinEDA_SchematicFrame::SVG_Print )
|
||||
EVT_MENU( ID_GEN_PLOT_DXF, WinEDA_SchematicFrame::ToPlot_DXF )
|
||||
EVT_MENU( ID_GEN_COPY_SHEET_TO_CLIPBOARD, WinEDA_DrawFrame::CopyToClipboard )
|
||||
EVT_MENU( ID_GEN_COPY_BLOCK_TO_CLIPBOARD, WinEDA_DrawFrame::CopyToClipboard )
|
||||
|
@ -782,3 +783,13 @@ void WinEDA_SchematicFrame::OnPrint( wxCommandEvent& event )
|
|||
wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Creates the SVG print file for the current edited component.
|
||||
*/
|
||||
void WinEDA_SchematicFrame::SVG_Print( wxCommandEvent& event )
|
||||
{
|
||||
DIALOG_SVG_PRINT frame( this );
|
||||
|
||||
frame.ShowModal();
|
||||
}
|
||||
|
|
|
@ -14,13 +14,14 @@
|
|||
#include "general.h"
|
||||
#include "libeditframe.h"
|
||||
#include "class_libentry.h"
|
||||
#include "dialog_lib_edit_draw_item.h"
|
||||
#include "lib_arc.h"
|
||||
#include "lib_circle.h"
|
||||
#include "lib_polyline.h"
|
||||
#include "lib_rectangle.h"
|
||||
#include "lib_text.h"
|
||||
|
||||
#include "dialogs/dialog_lib_edit_draw_item.h"
|
||||
|
||||
|
||||
static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
|
||||
static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
|
||||
|
|
|
@ -345,6 +345,7 @@ public:
|
|||
void SetPrintMonochrome( bool aMonochrome ) { m_printMonochrome = aMonochrome; }
|
||||
bool GetShowSheetReference() { return m_showSheetReference; }
|
||||
void SetShowSheetReference( bool aShow ) { m_showSheetReference = aShow; }
|
||||
void SVG_Print( wxCommandEvent& event );
|
||||
|
||||
// Plot functions:
|
||||
void ToPlot_PS( wxCommandEvent& event );
|
||||
|
|
|
@ -154,7 +154,10 @@ public:
|
|||
*/
|
||||
void ToPrinter( wxCommandEvent& event );
|
||||
|
||||
/** Virtual function PrintPage
|
||||
void SVG_Print( wxCommandEvent& event );
|
||||
|
||||
/**
|
||||
* Function PrintPage , virtual
|
||||
* used to print a page
|
||||
* Print the page pointed by ActiveScreen, set by the calling print function
|
||||
* @param aDC = wxDC given by the calling print function
|
||||
|
|
|
@ -392,8 +392,6 @@ public:
|
|||
/* Return the current zoom level */
|
||||
int GetZoom( void );
|
||||
|
||||
void SVG_Print( wxCommandEvent& event );
|
||||
|
||||
void TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_width );
|
||||
void PlotWorkSheet( PLOTTER *plotter, BASE_SCREEN* screen );
|
||||
|
||||
|
|
|
@ -12,14 +12,15 @@
|
|||
#include "confirm.h"
|
||||
#include "gestfich.h"
|
||||
|
||||
#include "dialog_SVG_print_base.h"
|
||||
|
||||
#include "dcsvg.h"
|
||||
|
||||
#include "pcbnew.h"
|
||||
#include "pcbplot.h"
|
||||
#include "printout_controler.h"
|
||||
|
||||
#include "dialog_SVG_print.h"
|
||||
|
||||
|
||||
// Keys for configuration
|
||||
#define PLOTSVGMODECOLOR_KEY wxT( "PlotSVGModeColor" )
|
||||
|
||||
|
@ -34,42 +35,6 @@ static PRINT_PARAMETERS s_Parameters;
|
|||
static long s_SelectedLayers = LAYER_BACK | LAYER_FRONT |
|
||||
SILKSCREEN_LAYER_FRONT | SILKSCREEN_LAYER_BACK;
|
||||
|
||||
class DIALOG_SVG_PRINT : public DIALOG_SVG_PRINT_base
|
||||
{
|
||||
private:
|
||||
WinEDA_BasePcbFrame* m_Parent;
|
||||
wxConfig* m_Config;
|
||||
long m_PrintMaskLayer;
|
||||
wxCheckBox* m_BoxSelectLayer[32];
|
||||
|
||||
public:
|
||||
DIALOG_SVG_PRINT( WinEDA_DrawFrame* parent );
|
||||
~DIALOG_SVG_PRINT() {}
|
||||
|
||||
private:
|
||||
void OnCloseWindow( wxCloseEvent& event );
|
||||
void initDialog( );
|
||||
void OnButtonPrintSelectedClick( wxCommandEvent& event );
|
||||
void OnButtonPrintBoardClick( wxCommandEvent& event );
|
||||
void OnButtonCancelClick( wxCommandEvent& event );
|
||||
void OnSetColorModeSelected( wxCommandEvent& event );
|
||||
void SetPenWidth();
|
||||
void PrintSVGDoc( bool aPrintAll, bool aPrint_Frame_Ref );
|
||||
bool DrawPage( const wxString& FullFileName, BASE_SCREEN* screen,
|
||||
bool aPrint_Frame_Ref );
|
||||
};
|
||||
|
||||
|
||||
/* Prepare the data structures of print management
|
||||
* And displays the dialog window management of printing sheets
|
||||
*/
|
||||
void WinEDA_DrawFrame::SVG_Print( wxCommandEvent& event )
|
||||
{
|
||||
DIALOG_SVG_PRINT frame( this );
|
||||
|
||||
frame.ShowModal();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* DIALOG_SVG_PRINT functions
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
|
||||
#ifndef _DIALOG_SVG_PRINT_H_
|
||||
#define _DIALOG_SVG_PRINT_H_
|
||||
|
||||
|
||||
#include "dialog_SVG_print_base.h"
|
||||
|
||||
|
||||
class BASE_SCREEN;
|
||||
class WinEDA_BasePcbFrame;
|
||||
class wxConfig;
|
||||
|
||||
|
||||
class DIALOG_SVG_PRINT : public DIALOG_SVG_PRINT_base
|
||||
{
|
||||
private:
|
||||
WinEDA_BasePcbFrame* m_Parent;
|
||||
wxConfig* m_Config;
|
||||
long m_PrintMaskLayer;
|
||||
wxCheckBox* m_BoxSelectLayer[32];
|
||||
|
||||
public:
|
||||
DIALOG_SVG_PRINT( WinEDA_DrawFrame* parent );
|
||||
~DIALOG_SVG_PRINT() {}
|
||||
|
||||
private:
|
||||
void OnCloseWindow( wxCloseEvent& event );
|
||||
void initDialog( );
|
||||
void OnButtonPrintSelectedClick( wxCommandEvent& event );
|
||||
void OnButtonPrintBoardClick( wxCommandEvent& event );
|
||||
void OnButtonCancelClick( wxCommandEvent& event );
|
||||
void OnSetColorModeSelected( wxCommandEvent& event );
|
||||
void SetPenWidth();
|
||||
void PrintSVGDoc( bool aPrintAll, bool aPrint_Frame_Ref );
|
||||
bool DrawPage( const wxString& FullFileName, BASE_SCREEN* screen, bool aPrint_Frame_Ref );
|
||||
};
|
||||
|
||||
|
||||
#endif // _DIALOG_SVG_PRINT_H_
|
|
@ -49,6 +49,7 @@
|
|||
#include "hotkeys.h"
|
||||
#include "pcbnew_config.h"
|
||||
#include "module_editor_frame.h"
|
||||
#include "dialog_SVG_print.h"
|
||||
|
||||
|
||||
extern int g_DrawDefaultLineThickness;
|
||||
|
@ -168,7 +169,7 @@ BEGIN_EVENT_TABLE( WinEDA_PcbFrame, WinEDA_BasePcbFrame )
|
|||
EVT_TOOL( wxID_UNDO, WinEDA_PcbFrame::GetBoardFromUndoList )
|
||||
EVT_TOOL( wxID_REDO, WinEDA_PcbFrame::GetBoardFromRedoList )
|
||||
EVT_TOOL( wxID_PRINT, WinEDA_PcbFrame::ToPrinter )
|
||||
EVT_TOOL( ID_GEN_PLOT_SVG, WinEDA_DrawFrame::SVG_Print )
|
||||
EVT_TOOL( ID_GEN_PLOT_SVG, WinEDA_PcbFrame::SVG_Print )
|
||||
EVT_TOOL( ID_GEN_PLOT, WinEDA_PcbFrame::Process_Special_Functions )
|
||||
EVT_TOOL( ID_FIND_ITEMS, WinEDA_PcbFrame::Process_Special_Functions )
|
||||
EVT_TOOL( ID_GET_NETLIST, WinEDA_PcbFrame::Process_Special_Functions )
|
||||
|
@ -721,3 +722,13 @@ void WinEDA_PcbFrame::OnModify( )
|
|||
m_Draw3DFrame->ReloadRequest( );
|
||||
}
|
||||
|
||||
|
||||
/* Prepare the data structures of print management
|
||||
* And displays the dialog window management of printing sheets
|
||||
*/
|
||||
void WinEDA_PcbFrame::SVG_Print( wxCommandEvent& event )
|
||||
{
|
||||
DIALOG_SVG_PRINT frame( this );
|
||||
|
||||
frame.ShowModal();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue