LibEdit: finished SVG plot.
Build BOM: in one part per line, fields are now selectable (like others formats)
This commit is contained in:
parent
72d5813dce
commit
41dd975313
|
@ -90,9 +90,19 @@ int BASE_SCREEN::GetInternalUnits( void )
|
|||
wxSize BASE_SCREEN::ReturnPageSize( void )
|
||||
{
|
||||
int internal_units = GetInternalUnits();
|
||||
wxSize size = m_CurrentSheetDesc->m_Size;
|
||||
size.x = (int)( (double)size.x * internal_units / 1000 );
|
||||
size.y = (int)( (double)size.y * internal_units / 1000 );
|
||||
|
||||
return wxSize( ( m_CurrentSheetDesc->m_Size.x * internal_units ) / 1000,
|
||||
( m_CurrentSheetDesc->m_Size.y * internal_units ) / 1000 );
|
||||
return size;
|
||||
}
|
||||
|
||||
void BASE_SCREEN::SetPageSize( wxSize& aPageSize )
|
||||
{
|
||||
int internal_units = GetInternalUnits();
|
||||
|
||||
m_CurrentSheetDesc->m_Size.x = (int) ((double)aPageSize.x * 1000 / internal_units);
|
||||
m_CurrentSheetDesc->m_Size.y = (int) ((double)aPageSize.y * 1000 / internal_units);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -138,11 +138,46 @@ void DIALOG_BUILD_BOM::Create_BOM_Lists( int aTypeFile,
|
|||
}
|
||||
}
|
||||
|
||||
/** 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;
|
||||
}
|
||||
|
||||
/*
|
||||
* Print a list of components, in a form which can be imported by a spreadsheet
|
||||
* form is:
|
||||
* cmp value; number of components; <footprint>; field1; field2; field3; list of references having the same value
|
||||
* cmp value; number of components; <footprint>; <field1>; ...; list of references having the same value
|
||||
*/
|
||||
void DIALOG_BUILD_BOM::CreatePartsList( const wxString& aFullFileName, bool aIncludeSubComponents )
|
||||
{
|
||||
|
@ -553,23 +588,9 @@ static void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList )
|
|||
void DIALOG_BUILD_BOM::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem,
|
||||
bool CompactForm )
|
||||
{
|
||||
// @todo make this variable length
|
||||
const wxCheckBox* FieldListCtrl[] =
|
||||
{
|
||||
m_AddField1,
|
||||
m_AddField2,
|
||||
m_AddField3,
|
||||
m_AddField4,
|
||||
m_AddField5,
|
||||
m_AddField6,
|
||||
m_AddField7,
|
||||
m_AddField8
|
||||
};
|
||||
|
||||
int ii;
|
||||
const wxCheckBox* FieldCtrl = FieldListCtrl[0];
|
||||
|
||||
if( m_AddFootprintField->IsChecked() )
|
||||
if( IsFieldChecked( FOOTPRINT ) )
|
||||
{
|
||||
if( CompactForm )
|
||||
{
|
||||
|
@ -585,20 +606,8 @@ void DIALOG_BUILD_BOM::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem,
|
|||
|
||||
for( ii = FIELD1; ii < DrawLibItem->GetFieldCount(); ii++ )
|
||||
{
|
||||
if( ii <= FIELD8 ) // see users fields 1 to 8
|
||||
{
|
||||
FieldCtrl = FieldListCtrl[ii - FIELD1];
|
||||
if( FieldCtrl == NULL )
|
||||
continue;
|
||||
|
||||
if( !FieldCtrl->IsChecked() && !m_AddAllFields->IsChecked() )
|
||||
continue;
|
||||
}
|
||||
|
||||
if( !m_AddAllFields->IsChecked() )
|
||||
break;
|
||||
|
||||
|
||||
if( ! IsFieldChecked( ii ) )
|
||||
continue;
|
||||
if( CompactForm )
|
||||
fprintf( f, "%c%s", s_ExportSeparatorSymbol,
|
||||
CONV_TO_UTF8( DrawLibItem->GetField( ii )->m_Text ) );
|
||||
|
@ -626,19 +635,6 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef(
|
|||
|
||||
if( CompactForm )
|
||||
{
|
||||
// @todo make this variable length
|
||||
const wxCheckBox* FieldListCtrl[FIELD8 - FIELD1 + 1] =
|
||||
{
|
||||
m_AddField1,
|
||||
m_AddField2,
|
||||
m_AddField3,
|
||||
m_AddField4,
|
||||
m_AddField5,
|
||||
m_AddField6,
|
||||
m_AddField7,
|
||||
m_AddField8
|
||||
};
|
||||
|
||||
// Print comment line:
|
||||
#if defined(KICAD_GOST)
|
||||
fprintf( f, "ref%cvalue%cdatasheet", s_ExportSeparatorSymbol, s_ExportSeparatorSymbol );
|
||||
|
@ -652,16 +648,12 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef(
|
|||
fprintf( f, "%clocation", s_ExportSeparatorSymbol );
|
||||
}
|
||||
|
||||
if( m_AddFootprintField->IsChecked() )
|
||||
if( IsFieldChecked( FOOTPRINT ) )
|
||||
fprintf( f, "%cfootprint", s_ExportSeparatorSymbol );
|
||||
|
||||
for( int ii = FIELD1; ii <= FIELD8; ii++ )
|
||||
{
|
||||
const wxCheckBox* FieldCtrl = FieldListCtrl[ii - FIELD1];
|
||||
if( FieldCtrl == NULL )
|
||||
continue;
|
||||
|
||||
if( !FieldCtrl->IsChecked() )
|
||||
if( !IsFieldChecked( ii ) )
|
||||
continue;
|
||||
|
||||
msg = _( "Field" );
|
||||
|
@ -871,7 +863,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart(
|
|||
fprintf( f, "%15s%c%3d", CONV_TO_UTF8( ValName ), s_ExportSeparatorSymbol, qty );
|
||||
qty = 1;
|
||||
|
||||
if( m_AddFootprintField->IsChecked() )
|
||||
if( IsFieldChecked(FOOTPRINT ) )
|
||||
fprintf( f, "%c%15s", s_ExportSeparatorSymbol,
|
||||
CONV_TO_UTF8( DrawLibItem->GetField( FOOTPRINT )->m_Text ) );
|
||||
|
||||
|
@ -880,10 +872,13 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart(
|
|||
CONV_TO_UTF8( DrawLibItem->GetField( DATASHEET) ->m_Text ) );
|
||||
#endif
|
||||
|
||||
// print fields
|
||||
// print fields, on demand
|
||||
for( int jj = FIELD1; jj <= FIELD8 ; jj++ )
|
||||
fprintf( f, "%c%4s", s_ExportSeparatorSymbol,
|
||||
CONV_TO_UTF8( dummyCmp.GetField( jj )->m_Text ) );
|
||||
{
|
||||
if ( IsFieldChecked( jj ) )
|
||||
fprintf( f, "%c%4s", s_ExportSeparatorSymbol,
|
||||
CONV_TO_UTF8( dummyCmp.GetField( jj )->m_Text ) );
|
||||
}
|
||||
|
||||
fprintf( f, "%c%s%s", s_ExportSeparatorSymbol,
|
||||
CONV_TO_UTF8( RefName ),
|
||||
|
|
|
@ -88,6 +88,8 @@ void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event )
|
|||
m_Config->Read( PLOTSVGMODECOLOR_KEY, &s_PlotBlackAndWhite );
|
||||
}
|
||||
|
||||
m_ModeColorOption->SetSelection(s_PlotBlackAndWhite);
|
||||
|
||||
AddUnitSymbol(* m_TextPenWidth, g_UnitMetric );
|
||||
m_DialogPenWidth->SetValue(
|
||||
ReturnStringFromValue(g_UnitMetric, g_DrawDefaultLineThickness,
|
||||
|
@ -203,7 +205,7 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName,
|
|||
wxPoint tmp_startvisu;
|
||||
wxSize SheetSize; // Sheet size in internal units
|
||||
wxPoint old_org;
|
||||
float dpi;
|
||||
double dpi;
|
||||
bool success = true;
|
||||
|
||||
tmp_startvisu = screen->m_StartVisu;
|
||||
|
@ -211,12 +213,10 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName,
|
|||
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->m_CurrentSheetDesc->m_Size; // size in 1/1000 inch
|
||||
SheetSize.x *= m_Parent->m_InternalUnits / 1000;
|
||||
SheetSize.y *= m_Parent->m_InternalUnits / 1000; // size in pixels
|
||||
SheetSize = screen->ReturnPageSize( );
|
||||
|
||||
screen->SetScalingFactor( 1.0 );
|
||||
dpi = (float) SheetSize.x * 25.4 / m_ImageXSize_mm;
|
||||
dpi = (double) SheetSize.x * 25.4 / m_ImageXSize_mm;
|
||||
|
||||
WinEDA_DrawPanel* panel = m_Parent->DrawPanel;
|
||||
|
||||
|
@ -226,7 +226,7 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName,
|
|||
GRResetPenAndBrush( &dc );
|
||||
g_DrawDefaultLineThickness =
|
||||
ReturnValueFromTextCtrl( *m_DialogPenWidth, m_Parent->m_InternalUnits );
|
||||
GRForceBlackPen( m_ModeColorOption->GetSelection() == 0 ? FALSE : true );
|
||||
GRForceBlackPen( m_ModeColorOption->GetSelection() == 0 ? false : true );
|
||||
|
||||
|
||||
panel->m_ClipBox.SetX( -0x3FFFFF0 );
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "dialog_build_BOM_base.h"
|
||||
|
||||
class DIALOG_BUILD_BOM : public DIALOG_BUILD_BOM_BASE
|
||||
class DIALOG_BUILD_BOM : public DIALOG_BUILD_BOM_BASE
|
||||
{
|
||||
private:
|
||||
WinEDA_DrawFrame * m_Parent;
|
||||
|
@ -36,12 +36,13 @@ private:
|
|||
bool aIncludeSubComponents);
|
||||
int PrintComponentsListByPart( FILE *f, std::vector <OBJ_CMP_TO_LIST>& aList);
|
||||
void PrintFieldData(FILE * f, SCH_COMPONENT * DrawLibItem, bool CompactForm = FALSE);
|
||||
bool IsFieldChecked(int aFieldId);
|
||||
|
||||
|
||||
public:
|
||||
DIALOG_BUILD_BOM( WinEDA_DrawFrame* parent );
|
||||
~DIALOG_BUILD_BOM() {};
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -56,8 +56,22 @@ void WinEDA_LibeditFrame::OnPlotCurrentComponent( wxCommandEvent& event )
|
|||
break;
|
||||
|
||||
case ID_LIBEDIT_GEN_SVG_FILE:
|
||||
{
|
||||
GetScreen()->m_FileName = cmp->GetName();
|
||||
/* Give a size to the SVG draw area = component size + margin
|
||||
* the margin is 10% the size of the component size
|
||||
*/
|
||||
wxSize pagesize = GetScreen()->ReturnPageSize( );
|
||||
wxSize componentSize =
|
||||
m_component->GetBoundaryBox(m_unit, m_convert).m_Size;
|
||||
// Add a small margin to the plot bounding box
|
||||
componentSize.x = (int)(componentSize.x * 1.2);
|
||||
componentSize.y = (int)(componentSize.y * 1.2);
|
||||
|
||||
GetScreen()->SetPageSize( componentSize );
|
||||
WinEDA_DrawFrame::SVG_Print( event );
|
||||
GetScreen()->SetPageSize( pagesize );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -107,9 +121,20 @@ void WinEDA_LibeditFrame::PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref,
|
|||
int aPrintMask, bool aPrintMirrorMode,
|
||||
void * aData)
|
||||
{
|
||||
if( m_component )
|
||||
m_component->Draw( DrawPanel, aDC, wxPoint( 0, 0 ), m_unit,
|
||||
m_convert, GR_DEFAULT_DRAWMODE );
|
||||
if( ! m_component )
|
||||
return;
|
||||
|
||||
wxSize pagesize = GetScreen()->ReturnPageSize( );
|
||||
/* Plot item centered to the page
|
||||
* In libedit, the component is centered at 0,0 coordinates.
|
||||
* So we must plot it with an offset = pagesize/2.
|
||||
*/
|
||||
wxPoint plot_offset;
|
||||
plot_offset.x = pagesize.x/2;
|
||||
plot_offset.y = pagesize.y/2;
|
||||
|
||||
m_component->Draw( DrawPanel, aDC, plot_offset, m_unit,
|
||||
m_convert, GR_DEFAULT_DRAWMODE );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -156,6 +156,7 @@ public:
|
|||
|
||||
void InitDatas();
|
||||
|
||||
void SetPageSize( wxSize& aPageSize );
|
||||
wxSize ReturnPageSize( void );
|
||||
virtual int GetInternalUnits( void );
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS()
|
|||
// The final margin is the sum of these 2 values
|
||||
// Usually < 0 because the mask is smaller than pad
|
||||
|
||||
m_BoardThickness = 1.6 * PCB_INTERNAL_UNIT / 25.4; // Epoxy thickness for 3D view (and microwave calculations) // Layer Thickness for 3D viewer
|
||||
m_BoardThickness = (int)(1.6 * PCB_INTERNAL_UNIT / 25.4); // Epoxy thickness for 3D view (and microwave calculations) // Layer Thickness for 3D viewer
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue