Commit d3afe95c authored by Dick Hollenbeck's avatar Dick Hollenbeck

remove page size globals from eeschema

parent 697f9123
......@@ -22,8 +22,8 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
option(USE_PNG_BITMAPS "use PNG bitmaps instead of XPM (default ON)" ON)
option(USE_NEW_PCBNEW_LOAD "use new plugin support for legacy file format (default OFF)" OFF)
option(USE_NEW_PCBNEW_SAVE "use new plugin support for legacy file format (default OFF)" OFF)
option(USE_NEW_PCBNEW_LOAD "use new plugin support for legacy file format (default ON)" ON)
option(USE_NEW_PCBNEW_SAVE "use new plugin support for legacy file format (default ON)" ON)
# Russian GOST patch
option(wxUSE_UNICODE "enable/disable building unicode (default OFF)")
......@@ -265,6 +265,11 @@ add_subdirectory(bitmap2component)
add_subdirectory(pcb_calculator)
#add_subdirectory(new)
add_executable( container_test EXCLUDE_FROM_ALL container_test.cpp )
target_link_libraries( container_test common polygon bitmaps ${wxWidgets_LIBRARIES} )
#############
# Resources #
#############
......
......@@ -178,24 +178,24 @@ bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString )
// Standard page sizes in 1/1000 inch
#if defined(KICAD_GOST)
static const PAGE_INFO pageA4( wxSize( 8283, 11700 ), wxPoint( 0, 0 ), wxT( "A4" ) );
static const PAGE_INFO pageA4( wxSize( 8283, 11700 ), wxT( "A4" ) );
#else
static const PAGE_INFO pageA4( wxSize( 11700, 8267 ), wxPoint( 0, 0 ), wxT( "A4" ) );
static const PAGE_INFO pageA4( wxSize( 11700, 8267 ), wxT( "A4" ) );
#endif
static const PAGE_INFO pageA3( wxSize( 16535, 11700 ), wxPoint( 0, 0 ), wxT( "A3" ) );
static const PAGE_INFO pageA2( wxSize( 23400, 16535 ), wxPoint( 0, 0 ), wxT( "A2" ) );
static const PAGE_INFO pageA1( wxSize( 33070, 23400 ), wxPoint( 0, 0 ), wxT( "A1" ) );
static const PAGE_INFO pageA0( wxSize( 46800, 33070 ), wxPoint( 0, 0 ), wxT( "A0" ) );
static const PAGE_INFO pageA( wxSize( 11000, 8500 ), wxPoint( 0, 0 ), wxT( "A" ) );
static const PAGE_INFO pageB( wxSize( 17000, 11000 ), wxPoint( 0, 0 ), wxT( "B" ) );
static const PAGE_INFO pageC( wxSize( 22000, 17000 ), wxPoint( 0, 0 ), wxT( "C" ) );
static const PAGE_INFO pageD( wxSize( 34000, 22000 ), wxPoint( 0, 0 ), wxT( "D" ) );
static const PAGE_INFO pageE( wxSize( 44000, 34000 ), wxPoint( 0, 0 ), wxT( "E" ) );
static const PAGE_INFO pageGERBER(wxSize( 32000, 32000 ), wxPoint( 0, 0 ), wxT( "GERBER" ) );
static const PAGE_INFO pageA3( wxSize( 16535, 11700 ), wxT( "A3" ) );
static const PAGE_INFO pageA2( wxSize( 23400, 16535 ), wxT( "A2" ) );
static const PAGE_INFO pageA1( wxSize( 33070, 23400 ), wxT( "A1" ) );
static const PAGE_INFO pageA0( wxSize( 46800, 33070 ), wxT( "A0" ) );
static const PAGE_INFO pageA( wxSize( 11000, 8500 ), wxT( "A" ) );
static const PAGE_INFO pageB( wxSize( 17000, 11000 ), wxT( "B" ) );
static const PAGE_INFO pageC( wxSize( 22000, 17000 ), wxT( "C" ) );
static const PAGE_INFO pageD( wxSize( 34000, 22000 ), wxT( "D" ) );
static const PAGE_INFO pageE( wxSize( 44000, 34000 ), wxT( "E" ) );
static const PAGE_INFO pageGERBER(wxSize( 32000, 32000 ), wxT( "GERBER" ) );
double PAGE_INFO::s_user_width = 17.0;
double PAGE_INFO::s_user_height = 11.0;
static const PAGE_INFO pageUser( wxSize( 17000, 11000 ), wxPoint( 0, 0 ), wxT( "User" ) );
static const PAGE_INFO pageUser( wxSize( 17000, 11000 ), wxT( "User" ) );
static const PAGE_INFO* stdPageSizes[] = {
&pageA4,
......@@ -263,13 +263,12 @@ bool PAGE_INFO::SetType( const wxString& aType )
}
PAGE_INFO::PAGE_INFO( const wxSize& aSizeMils, const wxPoint& aOffsetMils, const wxString& aType )
PAGE_INFO::PAGE_INFO( const wxSize& aSizeMils, const wxString& aType )
{
// aSizeMils is in 1/1000th of an inch
SetWidthInches( aSizeMils.x / 1000.0 );
SetHeightInches( aSizeMils.y / 1000.0 );
m_Offset = aOffsetMils;
m_Type = aType;
// Adjust the default value for margins to 400 mils (0,4 inch or 10 mm)
......
......@@ -87,7 +87,7 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( CVPCB_MAINFRAME* father,
SetIcon( icon );
SetBoard( new BOARD() );
SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
LoadSettings();
......
......@@ -119,7 +119,7 @@ void FOOTPRINTS_LISTBOX::SetFootprintFullList( FOOTPRINT_LIST& list )
for( unsigned ii = 0; ii < list.GetCount(); ii++ )
{
FOOTPRINT_INFO & footprint = list.GetItem(ii);
msg.Printf( wxT( "%3d %s" ), m_FullFootprintList.GetCount() + 1,
msg.Printf( wxT( "%3d %s" ), (int) m_FullFootprintList.GetCount() + 1,
GetChars(footprint.m_Module) );
m_FullFootprintList.Add( msg );
}
......
......@@ -605,7 +605,7 @@ void CVPCB_MAINFRAME::DisplayStatus()
{
wxString msg;
msg.Printf( _( "Components: %d (free: %d)" ), m_components.size(), m_undefinedComponentCnt );
msg.Printf( _( "Components: %d (free: %d)" ), (int) m_components.size(), m_undefinedComponentCnt );
SetStatusText( msg, 0 );
SetStatusText( wxEmptyString, 1 );
......@@ -614,10 +614,10 @@ void CVPCB_MAINFRAME::DisplayStatus()
{
if( m_FootprintList->m_UseFootprintFullList )
msg.Printf( _( "Footprints (All): %d" ),
m_FootprintList->m_ActiveFootprintList->GetCount() );
(int) m_FootprintList->m_ActiveFootprintList->GetCount() );
else
msg.Printf( _( "Footprints (filtered): %d" ),
m_FootprintList->m_ActiveFootprintList->GetCount() );
(int) m_FootprintList->m_ActiveFootprintList->GetCount() );
}
else
{
......
......@@ -199,7 +199,7 @@ bool DIALOG_SVG_PRINT::DrawSVGPage( EDA_DRAW_FRAME* frame,
{
int tmpzoom;
wxPoint tmp_startvisu;
wxSize SheetSize; // Sheet size in internal units
wxSize sheetSize; // Sheet size in internal units
wxPoint old_org;
bool success = true;
......@@ -209,16 +209,15 @@ bool DIALOG_SVG_PRINT::DrawSVGPage( EDA_DRAW_FRAME* frame,
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
sheetSize = screen->GetPageSettings().GetSizeIU(); // page size in 1/1000 inch, ie in internal units
screen->SetScalingFactor( 1.0 );
EDA_DRAW_PANEL* panel = frame->GetCanvas();
SetLocaleTo_C_standard(); // Switch the locale to standard C (needed
// to print floating point numbers like 1.3)
LOCALE_IO toggle;
float dpi = (float) frame->GetInternalUnits();
wxSVGFileDC dc( FullFileName, SheetSize.x, SheetSize.y, dpi );
wxSVGFileDC dc( FullFileName, sheetSize.x, sheetSize.y, dpi );
EDA_RECT tmp = panel->m_ClipBox;
GRResetPenAndBrush( &dc );
......@@ -236,7 +235,6 @@ bool DIALOG_SVG_PRINT::DrawSVGPage( EDA_DRAW_FRAME* frame,
if( aPrint_Sheet_Ref )
frame->TraceWorkSheet( &dc, screen, g_DrawDefaultLineThickness );
SetLocaleTo_Default(); // revert to the current locale
screen->m_IsPrinting = false;
panel->m_ClipBox = tmp;
......
......@@ -63,11 +63,11 @@ private:
void initDlg();
void initOptVars();
void CreateDXFFile();
void PlotOneSheetDXF( const wxString& FileName,
SCH_SCREEN* screen, PAGE_INFO* sheet,
void PlotOneSheetDXF( const wxString& FileName, SCH_SCREEN* screen,
wxPoint plot_offset, double scale );
};
/* static members (static to remember last state): */
// static members (static to remember last state):
bool DIALOG_PLOT_SCHEMATIC_DXF::m_plotColorOpt = false;
bool DIALOG_PLOT_SCHEMATIC_DXF::m_plot_Sheet_Ref = true;
......@@ -147,8 +147,7 @@ void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( )
SCH_SCREEN* screen = schframe->GetScreen();
SCH_SHEET_PATH* sheetpath;
SCH_SHEET_PATH oldsheetpath = schframe->GetCurrentSheet();
wxString PlotFileName;
PAGE_INFO* PlotSheet;
wxString plotFileName;
wxPoint plot_offset;
/* When printing all pages, the printed page is not the current page.
......@@ -186,15 +185,14 @@ void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( )
sheetpath = SheetList.GetNext();
}
PlotSheet = screen->m_CurrentSheetDesc;
double scale = 10;
plot_offset.x = 0;
plot_offset.y = 0;
PlotFileName = schframe->GetUniqueFilenameForCurrentSheet() + wxT( ".dxf" );
plotFileName = schframe->GetUniqueFilenameForCurrentSheet() + wxT( ".dxf" );
PlotOneSheetDXF( PlotFileName, screen, PlotSheet, plot_offset, scale );
PlotOneSheetDXF( plotFileName, screen, plot_offset, scale );
if( !m_select_PlotAll )
break;
......@@ -208,12 +206,12 @@ void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( )
void DIALOG_PLOT_SCHEMATIC_DXF::PlotOneSheetDXF( const wxString& FileName,
SCH_SCREEN* screen,
PAGE_INFO* sheet,
wxPoint plot_offset,
double scale )
{
wxString msg;
wxString msg;
FILE* output_file = wxFopen( FileName, wxT( "wt" ) );
if( output_file == NULL )
......@@ -227,13 +225,17 @@ void DIALOG_PLOT_SCHEMATIC_DXF::PlotOneSheetDXF( const wxString& FileName,
msg.Printf( _( "Plot: %s " ), GetChars( FileName ) );
m_MsgBox->AppendText( msg );
SetLocaleTo_C_standard();
LOCALE_IO toggle;
DXF_PLOTTER* plotter = new DXF_PLOTTER();
plotter->set_paper_size( sheet );
const PAGE_INFO& pageInfo = screen->GetPageSettings();
plotter->SetPageSettings( pageInfo );
plotter->set_viewport( plot_offset, scale, 0 );
plotter->set_color_mode( m_plotColorOpt );
/* Init : */
// Init :
plotter->set_creator( wxT( "Eeschema-DXF" ) );
plotter->set_filename( FileName );
plotter->start_plot( output_file );
......@@ -246,10 +248,9 @@ void DIALOG_PLOT_SCHEMATIC_DXF::PlotOneSheetDXF( const wxString& FileName,
screen->Plot( plotter );
/* fin */
// finish
plotter->end_plot();
delete plotter;
SetLocaleTo_Default();
m_MsgBox->AppendText( wxT( "Ok\n" ) );
}
......@@ -39,7 +39,8 @@
#include "dialog_plot_schematic_HPGL_base.h"
enum PageFormatReq
enum HPGL_PAGEZ_T
{
PAGE_DEFAULT = 0,
PAGE_SIZE_A4,
......@@ -51,26 +52,34 @@ enum PageFormatReq
PAGE_SIZE_B,
PAGE_SIZE_C,
PAGE_SIZE_D,
PAGE_SIZE_E
PAGE_SIZE_E,
};
static PAGE_INFO* Plot_sheet_list[] =
static const wxChar* plot_sheet_list( HPGL_PAGEZ_T aSize )
{
NULL,
&g_Sheet_A4,
&g_Sheet_A3,
&g_Sheet_A2,
&g_Sheet_A1,
&g_Sheet_A0,
&g_Sheet_A,
&g_Sheet_B,
&g_Sheet_C,
&g_Sheet_D,
&g_Sheet_E,
&g_Sheet_GERBER,
&g_Sheet_user
const wxChar* ret;
switch( aSize )
{
default:
case PAGE_DEFAULT: ret = NULL; break;
case PAGE_SIZE_A4: ret = wxT( "A4" ); break;
case PAGE_SIZE_A3: ret = wxT( "A3" ); break;
case PAGE_SIZE_A2: ret = wxT( "A2" ); break;
case PAGE_SIZE_A1: ret = wxT( "A1" ); break;
case PAGE_SIZE_A0: ret = wxT( "A0" ); break;
case PAGE_SIZE_A: ret = wxT( "A" ); break;
case PAGE_SIZE_B: ret = wxT( "B" ); break;
case PAGE_SIZE_C: ret = wxT( "C" ); break;
case PAGE_SIZE_D: ret = wxT( "D" ); break;
case PAGE_SIZE_E: ret = wxT( "E" ); break;
}
return ret;
};
class DIALOG_PLOT_SCHEMATIC_HPGL : public DIALOG_PLOT_SCHEMATIC_HPGL_BASE
{
private:
......@@ -80,8 +89,10 @@ public:
DIALOG_PLOT_SCHEMATIC_HPGL( SCH_EDIT_FRAME* parent );
private:
static PageFormatReq m_pageSizeSelect;
static bool m_plot_Sheet_Ref;
static HPGL_PAGEZ_T s_pageSizeSelect;
static bool s_plot_Sheet_Ref;
static wxSize s_Offset;
bool m_select_PlotAll;
private:
......@@ -89,7 +100,7 @@ private:
void OnPlotCurrent( wxCommandEvent& event );
void OnPlotAll( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
void AcceptPlotOffset( wxCommandEvent& event );
void AcceptplotOffset( wxCommandEvent& event );
void initDlg();
void SetPenSpeed();
......@@ -97,15 +108,17 @@ private:
void SetPenWidth();
void SetPageOffsetValue();
void HPGL_Plot( bool aPlotAll );
void Plot_Schematic_HPGL( bool aPlotAll, int HPGL_SheetSize );
void Plot_Schematic_HPGL( bool aPlotAll );
void Plot_1_Page_HPGL( const wxString& FileName,
SCH_SCREEN* screen, PAGE_INFO* sheet,
SCH_SCREEN* screen, const PAGE_INFO& aPageInfo,
wxPoint& offset, double plot_scale );
void ReturnSheetDims( SCH_SCREEN* screen, wxSize& SheetSize, wxPoint& SheetOffset );
};
/* static members (static to remember last state): */
PageFormatReq DIALOG_PLOT_SCHEMATIC_HPGL:: m_pageSizeSelect = PAGE_DEFAULT;
bool DIALOG_PLOT_SCHEMATIC_HPGL::m_plot_Sheet_Ref = true;
// static members (static to remember last state):
HPGL_PAGEZ_T DIALOG_PLOT_SCHEMATIC_HPGL:: s_pageSizeSelect = PAGE_DEFAULT;
bool DIALOG_PLOT_SCHEMATIC_HPGL::s_plot_Sheet_Ref = true;
void SCH_EDIT_FRAME::ToPlot_HPGL( wxCommandEvent& event )
......@@ -115,8 +128,8 @@ void SCH_EDIT_FRAME::ToPlot_HPGL( wxCommandEvent& event )
}
DIALOG_PLOT_SCHEMATIC_HPGL::DIALOG_PLOT_SCHEMATIC_HPGL( SCH_EDIT_FRAME* parent )
:DIALOG_PLOT_SCHEMATIC_HPGL_BASE(parent)
DIALOG_PLOT_SCHEMATIC_HPGL::DIALOG_PLOT_SCHEMATIC_HPGL( SCH_EDIT_FRAME* parent ) :
DIALOG_PLOT_SCHEMATIC_HPGL_BASE( parent )
{
m_Parent = parent;
initDlg();
......@@ -130,16 +143,14 @@ DIALOG_PLOT_SCHEMATIC_HPGL::DIALOG_PLOT_SCHEMATIC_HPGL( SCH_EDIT_FRAME* parent )
void DIALOG_PLOT_SCHEMATIC_HPGL::initDlg()
{
SetFocus(); // Make ESC key working
SetFocus(); // Make ESC key work
// Set validators
m_SizeOption->SetSelection( m_pageSizeSelect );
m_SizeOption->SetSelection( s_pageSizeSelect );
AddUnitSymbol( *m_penWidthTitle, g_UserUnit );
PutValueInLocalUnits( *m_penWidthCtrl, g_HPGL_Pen_Descr. m_Pen_Diam, EESCHEMA_INTERNAL_UNIT );
m_penSpeedCtrl->SetValue( g_HPGL_Pen_Descr. m_Pen_Speed );
m_penNumCtrl->SetValue( g_HPGL_Pen_Descr. m_Pen_Num );
}
......@@ -153,25 +164,31 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::OnPlotAll( wxCommandEvent& event )
HPGL_Plot( true );
}
void DIALOG_PLOT_SCHEMATIC_HPGL::OnCancelClick( wxCommandEvent& event )
{
EndModal( 0 );
}
void DIALOG_PLOT_SCHEMATIC_HPGL::SetPageOffsetValue()
{
wxString msg;
m_pageSizeSelect = (PageFormatReq) m_SizeOption->GetSelection();
if( m_pageSizeSelect != PAGE_DEFAULT )
s_pageSizeSelect = (HPGL_PAGEZ_T) m_SizeOption->GetSelection();
if( s_pageSizeSelect != PAGE_DEFAULT )
{
msg = ReturnStringFromValue( g_UserUnit,
Plot_sheet_list[m_pageSizeSelect]->m_Offset.x,
s_Offset.x,
EESCHEMA_INTERNAL_UNIT );
m_PlotOrgPosition_X->SetValue( msg );
msg = ReturnStringFromValue( g_UserUnit,
Plot_sheet_list[m_pageSizeSelect]-> m_Offset.y,
s_Offset.y,
EESCHEMA_INTERNAL_UNIT );
m_PlotOrgPosition_Y->SetValue( msg );
m_PlotOrgPosition_X->Enable( TRUE );
......@@ -185,18 +202,19 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::SetPageOffsetValue()
}
void DIALOG_PLOT_SCHEMATIC_HPGL::AcceptPlotOffset( wxCommandEvent& event )
void DIALOG_PLOT_SCHEMATIC_HPGL::AcceptplotOffset( wxCommandEvent& event )
{
m_pageSizeSelect = (PageFormatReq) m_SizeOption->GetSelection();
s_pageSizeSelect = (HPGL_PAGEZ_T) m_SizeOption->GetSelection();
if( m_pageSizeSelect != PAGE_DEFAULT )
if( s_pageSizeSelect != PAGE_DEFAULT )
{
wxString msg = m_PlotOrgPosition_X->GetValue();
Plot_sheet_list[m_pageSizeSelect]->m_Offset.x =
ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT );
s_Offset.x = ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT );
msg = m_PlotOrgPosition_Y->GetValue();
Plot_sheet_list[m_pageSizeSelect]->m_Offset.y =
ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT );
s_Offset.y = ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT );
}
}
......@@ -243,52 +261,32 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::HPGL_Plot( bool aPlotAll )
SetPenNum( );
SetPenSpeed( );
if( m_pageSizeSelect != PAGE_DEFAULT )
if( s_pageSizeSelect != PAGE_DEFAULT )
{
PAGE_INFO* plot_sheet = Plot_sheet_list[m_pageSizeSelect];
wxString msg = m_PlotOrgPosition_X->GetValue();
plot_sheet->m_Offset.x =
ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT );
msg = m_PlotOrgPosition_Y->GetValue();
plot_sheet->m_Offset.y =
ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT );
}
Plot_Schematic_HPGL( aPlotAll, m_pageSizeSelect );
}
s_Offset.x = ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT );
/* Function calculates the offsets and dimensions of any trace of the
* selected sheet
*/
void DIALOG_PLOT_SCHEMATIC_HPGL::ReturnSheetDims( SCH_SCREEN* screen,
wxSize& SheetSize,
wxPoint& SheetOffset )
{
PAGE_INFO* PlotSheet;
if( screen == NULL )
screen = m_Parent->GetScreen();
msg = m_PlotOrgPosition_Y->GetValue();
PlotSheet = screen->m_CurrentSheetDesc;
s_Offset.y = ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT );
}
SheetSize = PlotSheet->m_Size;
SheetOffset = PlotSheet->m_Offset;
Plot_Schematic_HPGL( aPlotAll );
}
void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_Schematic_HPGL( bool aPlotAll, int HPGL_SheetSize )
void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_Schematic_HPGL( bool aPlotAll )
{
wxString PlotFileName;
wxString plotFileName;
SCH_SCREEN* screen = m_Parent->GetScreen();
SCH_SHEET_PATH* sheetpath;
SCH_SHEET_PATH oldsheetpath = m_Parent->GetCurrentSheet();
PAGE_INFO* PlotSheet;
wxSize SheetSize;
wxPoint SheetOffset, PlotOffset;
wxPoint plotOffset;
/* When printing all pages, the printed page is not the current page.
* In complex hierarchies, we must setup references and others parameters
* In complex hierarchies, we must setup references and other parameters
* in the printed SCH_SCREEN
* because in complex hierarchies a SCH_SCREEN (a schematic drawings)
* is shared between many sheets
......@@ -312,7 +310,11 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_Schematic_HPGL( bool aPlotAll, int HPGL_Sh
m_Parent->SetCurrentSheet( list );
m_Parent->GetCurrentSheet().UpdateAllScreenReferences();
m_Parent->SetSheetNumberAndCount();
screen = m_Parent->GetCurrentSheet().LastScreen();
if( !screen ) // LastScreen() may return NULL
screen = m_Parent->GetScreen();
}
else // Should not happen
return;
......@@ -320,26 +322,28 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_Schematic_HPGL( bool aPlotAll, int HPGL_Sh
sheetpath = SheetList.GetNext();
}
ReturnSheetDims( screen, SheetSize, SheetOffset );
const PAGE_INFO& curPage = screen->GetPageSettings();
/* Calculation of conversion scales. */
if( HPGL_SheetSize )
PlotSheet = Plot_sheet_list[HPGL_SheetSize];
else
PlotSheet = screen->m_CurrentSheetDesc;
PAGE_INFO plotPage = curPage;
// if plotting on a page size other than curPage
if( s_pageSizeSelect != PAGE_DEFAULT )
plotPage.SetType( plot_sheet_list( s_pageSizeSelect ) );
// Calculation of conversion scales.
/* 10x because Eeschema works in mils, not decimals */
double plot_scale = 10 * (double) PlotSheet->m_Size.x / (double) SheetSize.x;
// 10x because Eeschema works in mils, not deci-mils
double plot_scale = 10 * (double) plotPage.GetWidthMils() / curPage.GetWidthMils();
/* Calculate offsets */
PlotOffset.x = -SheetOffset.x;
PlotOffset.y = -SheetOffset.y;
// Calculate offsets
plotOffset.x = -s_Offset.x;
plotOffset.y = -s_Offset.y;
PlotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + wxT( ".plt" );
plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + wxT( ".plt" );
SetLocaleTo_C_standard();
Plot_1_Page_HPGL( PlotFileName, screen, PlotSheet, PlotOffset, plot_scale );
SetLocaleTo_Default();
LOCALE_IO toggle;
Plot_1_Page_HPGL( plotFileName, screen, plotPage, plotOffset, plot_scale );
if( !aPlotAll )
break;
......@@ -353,7 +357,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_Schematic_HPGL( bool aPlotAll, int HPGL_Sh
void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_1_Page_HPGL( const wxString& FileName,
SCH_SCREEN* screen,
PAGE_INFO* sheet,
const PAGE_INFO& pageInfo,
wxPoint& offset,
double plot_scale )
{
......@@ -370,15 +374,19 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_1_Page_HPGL( const wxString& FileName,
return;
}
SetLocaleTo_C_standard();
LOCALE_IO toggle;
msg.Printf( _( "Plot: %s " ), FileName.GetData() );
m_MsgBox->AppendText( msg );
HPGL_PLOTTER* plotter = new HPGL_PLOTTER();
plotter->set_paper_size( sheet );
plotter->SetPageSettings( pageInfo );
plotter->set_viewport( offset, plot_scale, 0 );
plotter->set_default_line_width( g_DrawDefaultLineThickness );
/* Init : */
// Init :
plotter->set_creator( wxT( "Eeschema-HPGL" ) );
plotter->set_filename( FileName );
plotter->set_pen_speed( g_HPGL_Pen_Descr.m_Pen_Speed );
......@@ -389,14 +397,13 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_1_Page_HPGL( const wxString& FileName,
plotter->set_color( BLACK );
if( m_plot_Sheet_Ref )
if( s_plot_Sheet_Ref )
m_Parent->PlotWorkSheet( plotter, screen );
screen->Plot( plotter );
plotter->end_plot();
delete plotter;
SetLocaleTo_Default();
m_MsgBox->AppendText( wxT( "Ok\n" ) );
}
......@@ -406,7 +413,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_1_Page_HPGL( const wxString& FileName,
*/
void DIALOG_PLOT_SCHEMATIC_HPGL::OnPageSelected( wxCommandEvent& event )
{
m_pageSizeSelect = (PageFormatReq) m_SizeOption->GetSelection();
s_pageSizeSelect = (HPGL_PAGEZ_T) m_SizeOption->GetSelection();
SetPageOffsetValue();
}
......
......@@ -70,12 +70,13 @@ private:
void initOptVars();
void createPSFile();
void plotOneSheetPS( const wxString& FileName,
SCH_SCREEN* screen, PAGE_INFO* sheet,
SCH_SCREEN* screen, const PAGE_INFO& pageInfo,
wxPoint plot_offset, double scale );
};
/* static members (static to remember last state): */
// static members (static to remember last state):
bool DIALOG_PLOT_SCHEMATIC_PS::m_plotColorOpt = false;
int DIALOG_PLOT_SCHEMATIC_PS:: m_pageSizeSelect = PAGE_SIZE_AUTO;
int DIALOG_PLOT_SCHEMATIC_PS::m_pageSizeSelect = PAGE_SIZE_AUTO;
bool DIALOG_PLOT_SCHEMATIC_PS::m_plot_Sheet_Ref = true;
......@@ -176,8 +177,8 @@ void DIALOG_PLOT_SCHEMATIC_PS::createPSFile()
SCH_SHEET_PATH* sheetpath;
SCH_SHEET_PATH oldsheetpath = m_Parent->GetCurrentSheet(); // sheetpath is saved here
wxString plotFileName;
PAGE_INFO* actualPage; // page size selected in schematic
PAGE_INFO* plotPage; // page size selected to plot
PAGE_INFO actualPage; // page size selected in schematic
PAGE_INFO plotPage; // page size selected to plot
wxPoint plot_offset;
/* When printing all pages, the printed page is not the current page.
......@@ -213,16 +214,16 @@ void DIALOG_PLOT_SCHEMATIC_PS::createPSFile()
sheetpath = SheetList.GetNext();
}
actualPage = screen->m_CurrentSheetDesc;
actualPage = screen->GetPageSettings();
switch( m_pageSizeSelect )
{
case PAGE_SIZE_A:
plotPage = &g_Sheet_A;
plotPage.SetType( wxT( "A" ) );
break;
case PAGE_SIZE_A4:
plotPage = &g_Sheet_A4;
plotPage.SetType( wxT( "A4" ) );
break;
case PAGE_SIZE_AUTO:
......@@ -231,8 +232,9 @@ void DIALOG_PLOT_SCHEMATIC_PS::createPSFile()
break;
}
double scalex = (double) plotPage->m_Size.x / actualPage->m_Size.x;
double scaley = (double) plotPage->m_Size.y / actualPage->m_Size.y;
double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
double scale = 10 * MIN( scalex, scaley );
plot_offset.x = 0;
......@@ -254,7 +256,7 @@ void DIALOG_PLOT_SCHEMATIC_PS::createPSFile()
void DIALOG_PLOT_SCHEMATIC_PS::plotOneSheetPS( const wxString& FileName,
SCH_SCREEN* screen,
PAGE_INFO* sheet,
const PAGE_INFO& pageInfo,
wxPoint plot_offset,
double scale )
{
......@@ -276,12 +278,12 @@ void DIALOG_PLOT_SCHEMATIC_PS::plotOneSheetPS( const wxString& FileName,
m_MsgBox->AppendText( msg );
PS_PLOTTER* plotter = new PS_PLOTTER();
plotter->set_paper_size( sheet );
plotter->SetPageSettings( pageInfo );
plotter->set_viewport( plot_offset, scale, 0 );
plotter->set_default_line_width( g_DrawDefaultLineThickness );
plotter->set_color_mode( m_plotColorOpt );
/* Init : */
// Init :
plotter->set_creator( wxT( "Eeschema-PS" ) );
plotter->set_filename( FileName );
plotter->start_plot( output_file );
......
......@@ -620,7 +620,7 @@ void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, int aDrawMode, int aC
void SCH_SCREEN::Plot( PLOTTER* aPlotter )
{
for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() )
for( SCH_ITEM* item = GetDrawItems(); item; item = item->Next() )
{
aPlotter->set_current_line_width( item->GetPenSize() );
item->Plot( aPlotter );
......
......@@ -65,7 +65,7 @@ class SCH_SCREEN : public BASE_SCREEN
///< Delete when it goes to zero.
/// The size of the paper to print or plot on
PAGE_INFO m_paper; // keep with the MVC model as this class gets split
PAGE_INFO m_paper; // keep with the MVC 'model' as this class gets split
SCH_ITEM* m_drawList; ///< Object list for the screen.
/// @todo use DLIST<SCH_ITEM> or superior container
......
......@@ -44,13 +44,13 @@ class BASE_SCREEN;
class EDA_DRAW_FRAME;
class EDA_DRAW_PANEL;
/* Flag for special keys */
// Flag for special keys
#define GR_KB_RIGHTSHIFT 0x10000000 /* Keybd states: right
* shift key depressed */
#define GR_KB_LEFTSHIFT 0x20000000 /* left shift key depressed
*/
#define GR_KB_CTRL 0x40000000 /* CTRL depressed */
#define GR_KB_ALT 0x80000000 /* ALT depressed */
#define GR_KB_CTRL 0x40000000 // CTRL depressed
#define GR_KB_ALT 0x80000000 // ALT depressed
#define GR_KB_SHIFT (GR_KB_LEFTSHIFT | GR_KB_RIGHTSHIFT)
#define GR_KB_SHIFTCTRL (GR_KB_SHIFT | GR_KB_CTRL)
#define MOUSE_MIDDLE 0x08000000 /* Middle button mouse
......@@ -74,7 +74,7 @@ enum pseudokeys {
#define ESC 27
/* TODO Executable names TODO*/
// TODO Executable names TODO
#ifdef __WINDOWS__
#define CVPCB_EXE wxT( "cvpcb.exe" )
#define PCBNEW_EXE wxT( "pcbnew.exe" )
......@@ -101,7 +101,7 @@ enum pseudokeys {
#endif
/* Graphic Texts Orientation in 0.1 degree*/
// Graphic Texts Orientation in 0.1 degree
#define TEXT_ORIENT_HORIZ 0
#define TEXT_ORIENT_VERT 900
......@@ -116,13 +116,13 @@ enum EDA_UNITS_T {
};
#if defined(KICAD_GOST)
#define GOST_LEFTMARGIN 800 /* 20mm */
#define GOST_RIGHTMARGIN 200 /* 5mm */
#define GOST_TOPMARGIN 200 /* 5mm */
#define GOST_BOTTOMMARGIN 200 /* 5mm */
#define GOST_LEFTMARGIN 800 // 20mm
#define GOST_RIGHTMARGIN 200 // 5mm
#define GOST_TOPMARGIN 200 // 5mm
#define GOST_BOTTOMMARGIN 200 // 5mm
#endif
/* forward declarations: */
// forward declarations:
class LibNameList;
......@@ -131,9 +131,8 @@ class PAGE_INFO;
/**
* Class PAGE_INFO
* describes the page size and margins of a paper page on which to
* eventually print or plot. Since paper is often described in inches,
* (and due to legacy code), inches, mils, and internal units (IU) are supported
* in the accessors. Again, we are describing paper in this class.
* eventually print or plot. Here paper is described in inches, but
* accessors for mils, and internal units (IU) are supported.
*
* @author Dick Hollenbeck
*/
......@@ -141,7 +140,7 @@ class PAGE_INFO
{
public:
PAGE_INFO( const wxString& aType = wxT( "A3" ) );
PAGE_INFO( const wxSize& aSizeMils, const wxPoint& aOffsetMils, const wxString& aName );
PAGE_INFO( const wxSize& aSizeMils, const wxString& aName );
const wxString& GetType() const { return m_Type; }
......@@ -187,7 +186,7 @@ public:
const wxSize GetSizeIU() const { return wxSize( GetWidthIU(), GetHeightIU() ); }
#endif
wxPoint GetOffsetMils() const { return m_Offset; }
// wxPoint GetOffsetMils() const { return m_Offset; }
int GetLeftMarginMils() const { return m_LeftMargin; }
int GetRightMarginMils() const { return m_RightMargin; }
......@@ -218,7 +217,7 @@ private:
double m_widthInches;
double m_heightInches;
wxPoint m_Offset; ///< plot offset in 1/1000 inches
// wxPoint m_Offset; ///< plot offset in 1/1000 inches
int m_LeftMargin;
int m_RightMargin;
......@@ -232,10 +231,10 @@ private:
extern wxString g_ProductName;
/* Default user lib path can be left void, if the standard lib path is used */
/// Default user lib path can be left void, if the standard lib path is used
extern wxString g_UserLibDirBuffer;
extern bool g_ShowPageLimits; // true to display the page limits
extern bool g_ShowPageLimits; ///< true to display the page limits
/**
* File extension definitions. Please do not changes these. If a different
......@@ -263,10 +262,10 @@ extern const wxString MacrosFileWildcard;
extern const wxString AllFilesWildcard;
// Name of default configuration file. (kicad.pro)
/// Name of default configuration file. (kicad.pro)
extern wxString g_Prj_Default_Config_FullFilename;
// Name of local configuration file. (<curr projet>.pro)
/// Name of local configuration file. (<curr projet>.pro)
extern wxString g_Prj_Config_LocalFilename;
extern EDA_UNITS_T g_UserUnit; ///< display units
......@@ -275,7 +274,7 @@ extern EDA_UNITS_T g_UserUnit; ///< display units
extern int g_GhostColor;
/* COMMON.CPP */
// COMMON.CPP
/**
* Function SetLocaleTo_C_standard
......
......@@ -343,7 +343,7 @@ void DIALOG_PAD_PROPERTIES::initValues()
break;
}
msg.Printf( wxT( "%d" ), m_dummyPad->m_Orient );
msg.Printf( wxT( "%g" ), m_dummyPad->GetOrientation() );
m_PadOrientCtrl->SetValue( msg );
// Type of pad selection
......@@ -493,7 +493,7 @@ void DIALOG_PAD_PROPERTIES::PadOrientEvent( wxCommandEvent& event )
}
wxString msg;
msg.Printf( wxT( "%d" ), m_dummyPad->m_Orient );
msg.Printf( wxT( "%g" ), m_dummyPad->GetOrientation() );
m_PadOrientCtrl->SetValue( msg );
TransfertDataToPad( m_dummyPad );
......@@ -775,10 +775,11 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError
aPad->m_Offset.x = ReturnValueFromTextCtrl( *m_ShapeOffset_X_Ctrl, internalUnits );
aPad->m_Offset.y = ReturnValueFromTextCtrl( *m_ShapeOffset_Y_Ctrl, internalUnits );
long orient_value = 0;
double orient_value = 0;
msg = m_PadOrientCtrl->GetValue();
msg.ToLong( &orient_value );
aPad->m_Orient = orient_value;
msg.ToDouble( &orient_value );
aPad->SetOrientation( orient_value );
msg = m_PadNumCtrl->GetValue().Left( 4 );
aPad->SetPadName( msg );
......
......@@ -299,9 +299,10 @@ this file again." ) );
}
}
catch( IO_ERROR ioe )
{wxMessageBox("catch");
{
wxString msg = wxString::Format( _( "Error loading board.\n%s" ),
ioe.errorText.GetData() );
wxMessageBox( msg, _( "Open Board File" ), wxOK | wxICON_ERROR );
}
......
......@@ -367,7 +367,7 @@ wxString PCB_BASE_FRAME::Select_1_Module_From_List( EDA_DRAW_FRAME* aWindow,
if( footprint_names_list.GetCount() )
{
msg.Printf( _( "Modules [%d items]" ), footprint_names_list.GetCount() );
msg.Printf( _( "Modules [%d items]" ), (int) footprint_names_list.GetCount() );
EDA_LIST_DIALOG dlg( aWindow, msg, footprint_names_list, OldName,
DisplayCmpDoc, GetComponentDialogPosition() );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment