Commit 0d459865 authored by Dick Hollenbeck's avatar Dick Hollenbeck

rename Ki_PageDescr to PAGE_INFO, encapsulate it in accessors, and move it into the BOARD

parent 0e27f45f
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) : EDA_ITEM( aType ) BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) : EDA_ITEM( aType )
{ {
m_drawList = NULL; /* Draw items list */
m_UndoRedoCountMax = 10; /* undo/Redo command Max depth, 10 is a reasonable value */ m_UndoRedoCountMax = 10; /* undo/Redo command Max depth, 10 is a reasonable value */
m_FirstRedraw = true; m_FirstRedraw = true;
m_ScreenNumber = 1; m_ScreenNumber = 1;
...@@ -49,12 +48,9 @@ BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) : EDA_ITEM( aType ) ...@@ -49,12 +48,9 @@ BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) : EDA_ITEM( aType )
m_Grid.m_Size = wxRealPoint( 50, 50 ); /* Default grid size */ m_Grid.m_Size = wxRealPoint( 50, 50 ); /* Default grid size */
m_Grid.m_Id = ID_POPUP_GRID_LEVEL_50; m_Grid.m_Id = ID_POPUP_GRID_LEVEL_50;
m_Center = true; m_Center = true;
m_CurrentSheetDesc = &g_Sheet_A4;
m_IsPrinting = false; m_IsPrinting = false;
m_ScrollPixelsPerUnitX = 1; m_ScrollPixelsPerUnitX = 1;
m_ScrollPixelsPerUnitY = 1; m_ScrollPixelsPerUnitY = 1;
InitDatas();
} }
...@@ -63,26 +59,49 @@ BASE_SCREEN::~BASE_SCREEN() ...@@ -63,26 +59,49 @@ BASE_SCREEN::~BASE_SCREEN()
} }
void BASE_SCREEN::InitDatas() /*
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 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);
}
*/
void BASE_SCREEN::InitDataPoints( const wxSize& aPageSizeInternalUnits )
{ {
if( m_Center ) if( m_Center )
{ {
m_crossHairPosition.x = m_crossHairPosition.y = 0; m_crossHairPosition.x = m_crossHairPosition.y = 0;
m_DrawOrg.x = -ReturnPageSize().x / 2;
m_DrawOrg.y = -ReturnPageSize().y / 2; m_DrawOrg.x = -aPageSizeInternalUnits.x / 2;
m_DrawOrg.y = -aPageSizeInternalUnits.y / 2;
} }
else else
{ {
m_DrawOrg.x = m_DrawOrg.y = 0; m_DrawOrg.x = m_DrawOrg.y = 0;
m_crossHairPosition.x = ReturnPageSize().x / 2;
m_crossHairPosition.y = ReturnPageSize().y / 2; m_crossHairPosition.x = aPageSizeInternalUnits.x / 2;
m_crossHairPosition.y = aPageSizeInternalUnits.y / 2;
} }
m_O_Curseur.x = m_O_Curseur.y = 0; m_O_Curseur.x = m_O_Curseur.y = 0;
SetCurItem( NULL ); SetCurItem( NULL );
m_FlagModified = false; // Set when any change is made on broad. m_FlagModified = false; // Set when any change is made on board.
m_FlagSave = false; // Used in auto save set when an auto save is required. m_FlagSave = false; // Used in auto save set when an auto save is required.
} }
...@@ -93,25 +112,6 @@ int BASE_SCREEN::GetInternalUnits( void ) ...@@ -93,25 +112,6 @@ 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 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);
}
double BASE_SCREEN::GetScalingFactor() const double BASE_SCREEN::GetScalingFactor() const
{ {
double scale = 1.0 / GetZoom(); double scale = 1.0 / GetZoom();
...@@ -513,22 +513,3 @@ void BASE_SCREEN::InsertItem( EDA_ITEMS::iterator aIter, EDA_ITEM* aItem ) ...@@ -513,22 +513,3 @@ void BASE_SCREEN::InsertItem( EDA_ITEMS::iterator aIter, EDA_ITEM* aItem )
m_items.insert( aIter, aItem ); m_items.insert( aIter, aItem );
} }
#if defined(DEBUG)
void BASE_SCREEN::Show( int nestLevel, std::ostream& os ) const
{
EDA_ITEM* item = m_drawList;
// for now, make it look like XML, expand on this later.
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n";
for( ; item; item = item->Next() )
{
item->Show( nestLevel+1, os );
}
NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
}
#endif
...@@ -32,7 +32,6 @@ PLOTTER::PLOTTER( PlotFormat aPlotType ) ...@@ -32,7 +32,6 @@ PLOTTER::PLOTTER( PlotFormat aPlotType )
output_file = 0; output_file = 0;
color_mode = false; /* Start as a BW plot */ color_mode = false; /* Start as a BW plot */
negative_mode = false; negative_mode = false;
sheet = NULL;
} }
...@@ -424,12 +423,12 @@ void PLOTTER::thick_circle( wxPoint pos, int diametre, int width, ...@@ -424,12 +423,12 @@ void PLOTTER::thick_circle( wxPoint pos, int diametre, int width,
} }
void PLOTTER::set_paper_size( Ki_PageDescr* asheet ) void PLOTTER::SetPageSettings( const PAGE_INFO& aPageSettings )
{ {
wxASSERT( !output_file ); wxASSERT( !output_file );
sheet = asheet; pageInfo = aPageSettings;
// Sheets are in mils, plotter works with decimals // PAGE_INFO is in mils, plotter works with decimals
paper_size.x = sheet->m_Size.x * 10; paper_size = pageInfo.GetSizeMils() * 10;
paper_size.y = sheet->m_Size.y * 10;
} }
...@@ -46,31 +46,6 @@ ...@@ -46,31 +46,6 @@
* application class. * application class.
*/ */
/* Standard page sizes in 1/1000 inch */
#if defined(KICAD_GOST)
Ki_PageDescr g_Sheet_A4( wxSize( 8283, 11700 ), wxPoint( 0, 0 ), wxT( "A4" ) );
#else
Ki_PageDescr g_Sheet_A4( wxSize( 11700, 8267 ), wxPoint( 0, 0 ), wxT( "A4" ) );
#endif
Ki_PageDescr g_Sheet_A3( wxSize( 16535, 11700 ), wxPoint( 0, 0 ), wxT( "A3" ) );
Ki_PageDescr g_Sheet_A2( wxSize( 23400, 16535 ), wxPoint( 0, 0 ), wxT( "A2" ) );
Ki_PageDescr g_Sheet_A1( wxSize( 33070, 23400 ), wxPoint( 0, 0 ), wxT( "A1" ) );
Ki_PageDescr g_Sheet_A0( wxSize( 46800, 33070 ), wxPoint( 0, 0 ), wxT( "A0" ) );
Ki_PageDescr g_Sheet_A( wxSize( 11000, 8500 ), wxPoint( 0, 0 ), wxT( "A" ) );
Ki_PageDescr g_Sheet_B( wxSize( 17000, 11000 ), wxPoint( 0, 0 ), wxT( "B" ) );
Ki_PageDescr g_Sheet_C( wxSize( 22000, 17000 ), wxPoint( 0, 0 ), wxT( "C" ) );
Ki_PageDescr g_Sheet_D( wxSize( 34000, 22000 ), wxPoint( 0, 0 ), wxT( "D" ) );
Ki_PageDescr g_Sheet_E( wxSize( 44000, 34000 ), wxPoint( 0, 0 ), wxT( "E" ) );
Ki_PageDescr g_Sheet_GERBER( wxSize( 32000, 32000 ), wxPoint( 0, 0 ), wxT( "GERBER" ) );
Ki_PageDescr g_Sheet_user( wxSize( 17000, 11000 ), wxPoint( 0, 0 ), wxT( "User" ) );
Ki_PageDescr* g_SheetSizeList[NB_ITEMS + 1] =
{
&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_user, NULL
};
const wxString ProjectFileExtension( wxT( "pro" ) ); const wxString ProjectFileExtension( wxT( "pro" ) );
const wxString SchematicFileExtension( wxT( "sch" ) ); const wxString SchematicFileExtension( wxT( "sch" ) );
...@@ -199,12 +174,88 @@ bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString ) ...@@ -199,12 +174,88 @@ bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString )
} }
Ki_PageDescr::Ki_PageDescr( const wxSize& size, const wxPoint& offset, const wxString& name ) //-----<PAGE_INFO>-------------------------------------------------------------
// Standard page sizes in 1/1000 inch
#if defined(KICAD_GOST)
static const PAGE_INFO pageA4( wxSize( 8283, 11700 ), wxPoint( 0, 0 ), wxT( "A4" ) );
#else
static const PAGE_INFO pageA4( wxSize( 11700, 8267 ), wxPoint( 0, 0 ), 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" ) );
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* pageSizes[] =
{
&pageA4, &pageA3, &pageA2, &pageA1, &pageA0,
&pageA, &pageB, &pageC, &pageD, &pageE, &pageUser,
};
PAGE_INFOS PAGE_INFO::GetStandardSizes()
{
return PAGE_INFOS( pageSizes, pageSizes + DIM( pageSizes ) );
}
*/
bool PAGE_INFO::SetType( const wxString& aType )
{
bool rc = true;
if( aType == pageA4.GetType() )
*this = pageA4;
else if( aType == pageA3.GetType() )
*this = pageA3;
else if( aType == pageA2.GetType() )
*this = pageA2;
else if( aType == pageA1.GetType() )
*this = pageA1;
else if( aType == pageA0.GetType() )
*this = pageA0;
else if( aType == pageA.GetType() )
*this = pageA;
else if( aType == pageB.GetType() )
*this = pageB;
else if( aType == pageC.GetType() )
*this = pageC;
else if( aType == pageD.GetType() )
*this = pageD;
else if( aType == pageE.GetType() )
*this = pageE;
else if( aType == pageUser.GetType() )
{
*this = pageUser;
m_widthInches = s_user_width;
m_heightInches = s_user_height;
}
else
rc = false;
return rc;
}
PAGE_INFO::PAGE_INFO( const wxSize& aSizeMils, const wxPoint& aOffsetMils, const wxString& aType )
{ {
// All sizes are in 1/1000 inch // aSizeMils is in 1/1000th of an inch
m_Size = size; SetWidthInches( aSizeMils.x / 1000.0 );
m_Offset = offset; SetHeightInches( aSizeMils.y / 1000.0 );
m_Name = name;
m_Offset = aOffsetMils;
m_Type = aType;
// Adjust the default value for margins to 400 mils (0,4 inch or 10 mm) // Adjust the default value for margins to 400 mils (0,4 inch or 10 mm)
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
...@@ -218,6 +269,50 @@ Ki_PageDescr::Ki_PageDescr( const wxSize& size, const wxPoint& offset, const wxS ...@@ -218,6 +269,50 @@ Ki_PageDescr::Ki_PageDescr( const wxSize& size, const wxPoint& offset, const wxS
} }
PAGE_INFO::PAGE_INFO( const wxString& aType )
{
SetType( aType );
}
void PAGE_INFO::SetWidthInches( double aWidthInInches )
{
// limit resolution to 1/1000th of an inch
m_widthInches = double( int( aWidthInInches * 1000 + 500 ) / 1000 );
}
void PAGE_INFO::SetHeightInches( double aHeightInInches )
{
// limit resolution to 1/1000th of an inch
m_heightInches = double( int( aHeightInInches * 1000 + 500 ) / 1000 );
}
void PAGE_INFO::SetUserWidthInches( double aWidthInInches )
{
if( aWidthInInches < 6.0 )
aWidthInInches = 6.0;
else if( aWidthInInches > 44.0 )
aWidthInInches = 44.0;
s_user_width = aWidthInInches;
}
void PAGE_INFO::SetUserHeightInches( double aHeightInInches )
{
if( aHeightInInches < 4.0 )
aHeightInInches = 4.0;
else if( aHeightInInches > 44.0 )
aHeightInInches = 44.0;
s_user_height = aHeightInInches;
}
//-----</PAGE_INFO>------------------------------------------------------------
wxString ReturnUnitSymbol( EDA_UNITS_T aUnit, const wxString& formatString ) wxString ReturnUnitSymbol( EDA_UNITS_T aUnit, const wxString& formatString )
{ {
wxString tmp; wxString tmp;
......
...@@ -366,7 +366,7 @@ bool PS_PLOTTER::start_plot( FILE* fout ) ...@@ -366,7 +366,7 @@ bool PS_PLOTTER::start_plot( FILE* fout )
fprintf( output_file, "%%%%Pages: 1\n" ); fprintf( output_file, "%%%%Pages: 1\n" );
fprintf( output_file, "%%%%PageOrder: Ascend\n" ); fprintf( output_file, "%%%%PageOrder: Ascend\n" );
// Print boundary box in 1/72 pixels per inch, box is in decimals // Print boundary box in 1/72 pixels per inch, box is in deci-mils
const double CONV_SCALE = DECIMIL_TO_INCH * 72; const double CONV_SCALE = DECIMIL_TO_INCH * 72;
// The coordinates of the lower left corner of the boundary // The coordinates of the lower left corner of the boundary
...@@ -388,18 +388,20 @@ bool PS_PLOTTER::start_plot( FILE* fout ) ...@@ -388,18 +388,20 @@ bool PS_PLOTTER::start_plot( FILE* fout )
// //
// (NOTE: m_Size.y is *supposed* to be listed before m_Size.x; // (NOTE: m_Size.y is *supposed* to be listed before m_Size.x;
// the order in which they are specified is not wrong!) // the order in which they are specified is not wrong!)
// Also note sheet->m_Size is given in mils, not in decimils and must be // Also note pageSize is given in mils, not in internal units and must be
// sheet->m_Size * 10 in decimals // converted to internal units.
if( sheet->m_Name.Cmp( wxT( "User" ) ) == 0 ) wxSize pageSize = pageInfo.GetSizeMils();
if( pageInfo.GetType().Cmp( wxT( "User" ) ) == 0 )
fprintf( output_file, "%%%%DocumentMedia: Custom %d %d 0 () ()\n", fprintf( output_file, "%%%%DocumentMedia: Custom %d %d 0 () ()\n",
wxRound( sheet->m_Size.y * 10 * CONV_SCALE ), wxRound( pageSize.y * 10 * CONV_SCALE ),
wxRound( sheet->m_Size.x * 10 * CONV_SCALE ) ); wxRound( pageSize.x * 10 * CONV_SCALE ) );
else // ( if sheet->m_Name does not equal "User" ) else // ( if sheet->m_Name does not equal "User" )
fprintf( output_file, "%%%%DocumentMedia: %s %d %d 0 () ()\n", fprintf( output_file, "%%%%DocumentMedia: %s %d %d 0 () ()\n",
TO_UTF8( sheet->m_Name ), TO_UTF8( pageInfo.GetType() ),
wxRound( sheet->m_Size.y * 10 * CONV_SCALE ), wxRound( pageSize.y * 10 * CONV_SCALE ),
wxRound( sheet->m_Size.x * 10 * CONV_SCALE ) ); wxRound( pageSize.x * 10 * CONV_SCALE ) );
fprintf( output_file, "%%%%Orientation: Landscape\n" ); fprintf( output_file, "%%%%Orientation: Landscape\n" );
......
...@@ -22,15 +22,17 @@ ...@@ -22,15 +22,17 @@
void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
{ {
#define WSTEXTSIZE 50 // Text size in mils #define WSTEXTSIZE 50 // Text size in mils
Ki_PageDescr* Sheet = screen->m_CurrentSheetDesc; const PAGE_INFO& pageInfo = GetPageSettings();
wxSize pageSize = pageInfo.GetSizeMils(); // mils
int xg, yg; int xg, yg;
wxSize PageSize;
wxPoint pos, ref; wxPoint pos, ref;
EDA_Colors color; EDA_Colors color;
/* Scale to convert dimension in 1/1000 in into internal units /* Scale to convert dimension in 1/1000 in into internal units
* (1/1000 inc for Eeschema, 1/10000 for Pcbnew. */ * (1/1000 inc for Eeschema, 1/10000 for Pcbnew. */
int conv_unit = screen->GetInternalUnits() / 1000; int conv_unit = screen->GetInternalUnits() / 1000;
wxString msg; wxString msg;
wxSize text_size; wxSize text_size;
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
...@@ -47,14 +49,11 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) ...@@ -47,14 +49,11 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
color = BLACK; color = BLACK;
plotter->set_color( color ); plotter->set_color( color );
PageSize.x = Sheet->m_Size.x;
PageSize.y = Sheet->m_Size.y;
/* Plot edge. */ /* Plot edge. */
ref.x = Sheet->m_LeftMargin * conv_unit; ref.x = pageInfo.GetLeftMarginMils() * conv_unit;
ref.y = Sheet->m_TopMargin * conv_unit; ref.y = pageInfo.GetTopMarginMils() * conv_unit;
xg = ( PageSize.x - Sheet->m_RightMargin ) * conv_unit; xg = ( pageSize.x - pageInfo.GetRightMarginMils() ) * conv_unit;
yg = ( PageSize.y - Sheet->m_BottomMargin ) * conv_unit; yg = ( pageSize.y - pageInfo.GetBottomMarginMils() ) * conv_unit;
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
plotter->move_to( ref ); plotter->move_to( ref );
...@@ -93,12 +92,13 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) ...@@ -93,12 +92,13 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
text_size.x = WSTEXTSIZE * conv_unit; text_size.x = WSTEXTSIZE * conv_unit;
text_size.y = WSTEXTSIZE * conv_unit; text_size.y = WSTEXTSIZE * conv_unit;
ref.x = Sheet->m_LeftMargin; // upper left corner in mils
ref.y = Sheet->m_TopMargin; /* Upper left corner in ref.x = pageInfo.GetLeftMarginMils();
* 1/1000 inch */ ref.y = pageInfo.GetTopMarginMils();
xg = ( PageSize.x - Sheet->m_RightMargin );
yg = ( PageSize.y - Sheet->m_BottomMargin ); /* lower right corner // lower right corner in mils
* in 1/1000 inch */ xg = ( pageSize.x - pageInfo.GetRightMarginMils() );
yg = ( pageSize.y - pageInfo.GetBottomMarginMils() );
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
for( Ki_WorkSheetData* WsItem = &WS_Segm1_LU; for( Ki_WorkSheetData* WsItem = &WS_Segm1_LU;
...@@ -240,6 +240,7 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) ...@@ -240,6 +240,7 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
/* Plot the worksheet. */ /* Plot the worksheet. */
text_size.x = SIZETEXT * conv_unit; text_size.x = SIZETEXT * conv_unit;
text_size.y = SIZETEXT * conv_unit; text_size.y = SIZETEXT * conv_unit;
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
text_size2.x = SIZETEXT * conv_unit * 2; text_size2.x = SIZETEXT * conv_unit * 2;
text_size2.y = SIZETEXT * conv_unit * 2; text_size2.y = SIZETEXT * conv_unit * 2;
...@@ -247,8 +248,8 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) ...@@ -247,8 +248,8 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
text_size3.y = SIZETEXT * conv_unit * 3; text_size3.y = SIZETEXT * conv_unit * 3;
text_size1_5.x = SIZETEXT * conv_unit * 1.5; text_size1_5.x = SIZETEXT * conv_unit * 1.5;
text_size1_5.y = SIZETEXT * conv_unit * 1.5; text_size1_5.y = SIZETEXT * conv_unit * 1.5;
ref.x = PageSize.x - Sheet->m_RightMargin; ref.x = pageSize.x - pageInfo.GetRightMarginMils();
ref.y = PageSize.y - Sheet->m_BottomMargin; ref.y = pageSize.y - pageInfo.GetBottomMarginMils();
if( screen->m_ScreenNumber == 1 ) if( screen->m_ScreenNumber == 1 )
{ {
...@@ -334,8 +335,8 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) ...@@ -334,8 +335,8 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
msg, TEXT_ORIENT_HORIZ, text_size3, msg, TEXT_ORIENT_HORIZ, text_size3,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false ); thickness, italic, false );
pos.x = (Sheet->m_LeftMargin + 1260) * conv_unit; pos.x = (pageInfo.GetLeftMarginMils() + 1260) * conv_unit;
pos.y = (Sheet->m_TopMargin + 270) * conv_unit; pos.y = (pageInfo.GetTopMarginMils() + 270) * conv_unit;
plotter->text( pos, color, plotter->text( pos, color,
msg.GetData(), 1800, text_size2, msg.GetData(), 1800, text_size2,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
...@@ -408,8 +409,8 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) ...@@ -408,8 +409,8 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
msg, TEXT_ORIENT_HORIZ, text_size3, msg, TEXT_ORIENT_HORIZ, text_size3,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false ); thickness, italic, false );
pos.x = (Sheet->m_LeftMargin + 1260) * conv_unit; pos.x = (pageInfo.GetLeftMarginMils() + 1260) * conv_unit;
pos.y = (Sheet->m_TopMargin + 270) * conv_unit; pos.y = (pageInfo.GetTopMarginMils() + 270) * conv_unit;
plotter->text( pos, color, plotter->text( pos, color,
msg, 1800, text_size2, msg, 1800, text_size2,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
...@@ -444,9 +445,11 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) ...@@ -444,9 +445,11 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
} }
} }
} }
#else #else
ref.x = PageSize.x - GRID_REF_W - Sheet->m_RightMargin;
ref.y = PageSize.y - GRID_REF_W - Sheet->m_BottomMargin; ref.x = pageSize.x - GRID_REF_W - pageInfo.GetRightMarginMils();
ref.y = pageSize.y - GRID_REF_W - pageInfo.GetBottomMarginMils();
for( Ki_WorkSheetData* WsItem = &WS_Date; for( Ki_WorkSheetData* WsItem = &WS_Date;
WsItem != NULL; WsItem != NULL;
...@@ -477,7 +480,7 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) ...@@ -477,7 +480,7 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
break; break;
case WS_SIZESHEET: case WS_SIZESHEET:
msg += screen->m_CurrentSheetDesc->m_Name; msg += pageInfo.GetType();
break; break;
case WS_IDENTSHEET: case WS_IDENTSHEET:
......
...@@ -23,14 +23,6 @@ ...@@ -23,14 +23,6 @@
#include "dialog_page_settings.h" #include "dialog_page_settings.h"
#define NB_ITEMS 11
Ki_PageDescr* SheetList[NB_ITEMS + 1] =
{
&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_user, NULL
};
void EDA_DRAW_FRAME::Process_PageSettings( wxCommandEvent& event ) void EDA_DRAW_FRAME::Process_PageSettings( wxCommandEvent& event )
{ {
...@@ -43,13 +35,12 @@ void EDA_DRAW_FRAME::Process_PageSettings( wxCommandEvent& event ) ...@@ -43,13 +35,12 @@ void EDA_DRAW_FRAME::Process_PageSettings( wxCommandEvent& event )
DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* parent ) : DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* parent ) :
DIALOG_PAGES_SETTINGS_BASE( parent ) DIALOG_PAGES_SETTINGS_BASE( parent ),
m_user_size( wxT( "User" ) )
{ {
m_Parent = parent; m_Parent = parent;
m_Screen = m_Parent->GetScreen(); m_Screen = m_Parent->GetScreen();
m_Modified = 0; m_modified = false;
m_SelectedSheet = NULL;
m_CurrentSelection = 0;
initDialog(); initDialog();
...@@ -66,9 +57,10 @@ DIALOG_PAGES_SETTINGS::~DIALOG_PAGES_SETTINGS() ...@@ -66,9 +57,10 @@ DIALOG_PAGES_SETTINGS::~DIALOG_PAGES_SETTINGS()
void DIALOG_PAGES_SETTINGS::initDialog() void DIALOG_PAGES_SETTINGS::initDialog()
{ {
wxString msg; wxString msg;
double userSizeX;
double userSizeY;
SetFocus(); SetFocus();
SearchPageSizeSelection();
// Init display value for sheet User size // Init display value for sheet User size
wxString format = m_TextSheetCount->GetLabel(); wxString format = m_TextSheetCount->GetLabel();
...@@ -78,38 +70,49 @@ void DIALOG_PAGES_SETTINGS::initDialog() ...@@ -78,38 +70,49 @@ void DIALOG_PAGES_SETTINGS::initDialog()
msg.Printf( format, m_Screen->m_ScreenNumber ); msg.Printf( format, m_Screen->m_ScreenNumber );
m_TextSheetNumber->SetLabel( msg ); m_TextSheetNumber->SetLabel( msg );
m_page = m_Parent->GetPageSettings();
setCurrentPageSizeSelection();
switch( g_UserUnit ) switch( g_UserUnit )
{ {
case MILLIMETRES: case MILLIMETRES:
UserSizeX = (double) g_Sheet_user.m_Size.x * 25.4 / 1000; userSizeX = m_user_size.GetWidthInches() * 25.4;
UserSizeY = (double) g_Sheet_user.m_Size.y * 25.4 / 1000; userSizeY = m_user_size.GetHeightInches() * 25.4;
msg.Printf( wxT( "%.2f" ), UserSizeX );
msg.Printf( wxT( "%.2f" ), userSizeX );
m_TextUserSizeX->SetValue( msg ); m_TextUserSizeX->SetValue( msg );
msg.Printf( wxT( "%.2f" ), UserSizeY );
msg.Printf( wxT( "%.2f" ), userSizeY );
m_TextUserSizeY->SetValue( msg ); m_TextUserSizeY->SetValue( msg );
break; break;
default:
case INCHES: case INCHES:
UserSizeX = (double) g_Sheet_user.m_Size.x / 1000; userSizeX = m_user_size.GetWidthInches();
UserSizeY = (double) g_Sheet_user.m_Size.y / 1000; userSizeY = m_user_size.GetHeightInches();
msg.Printf( wxT( "%.3f" ), UserSizeX );
msg.Printf( wxT( "%.3f" ), userSizeX );
m_TextUserSizeX->SetValue( msg ); m_TextUserSizeX->SetValue( msg );
msg.Printf( wxT( "%.3f" ), UserSizeY );
msg.Printf( wxT( "%.3f" ), userSizeY );
m_TextUserSizeY->SetValue( msg ); m_TextUserSizeY->SetValue( msg );
break; break;
/* // you want it in 1/1000ths of an inch, why?
case UNSCALED_UNITS: case UNSCALED_UNITS:
UserSizeX = g_Sheet_user.m_Size.x; userSizeX = m_user_size.GetWidthInches() * 1000;
UserSizeY = g_Sheet_user.m_Size.y; userSizeY = m_user_size.GetHeightInches() * 1000;
msg.Printf( wxT( "%f" ), UserSizeX ); msg.Printf( wxT( "%f" ), m_userSizeX );
m_TextUserSizeX->SetValue( msg ); m_TextUserSizeX->SetValue( msg );
msg.Printf( wxT( "%f" ), UserSizeY ); msg.Printf( wxT( "%f" ), m_userSizeY );
m_TextUserSizeY->SetValue( msg ); m_TextUserSizeY->SetValue( msg );
break; break;
*/
} }
// Set validators // Set validators
m_PageSizeBox->SetValidator( wxGenericValidator( &m_CurrentSelection ) ); // m_PageSizeBox->SetValidator( wxGenericValidator( &m_CurrentSelection ) );
m_TextRevision->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Revision ) ); m_TextRevision->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Revision ) );
m_TextTitle->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Title ) ); m_TextTitle->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Title ) );
m_TextCompany->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Company ) ); m_TextCompany->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Company ) );
...@@ -139,7 +142,7 @@ void DIALOG_PAGES_SETTINGS::initDialog() ...@@ -139,7 +142,7 @@ void DIALOG_PAGES_SETTINGS::initDialog()
void DIALOG_PAGES_SETTINGS::OnCloseWindow( wxCloseEvent& event ) void DIALOG_PAGES_SETTINGS::OnCloseWindow( wxCloseEvent& event )
{ {
EndModal( m_Modified ); EndModal( m_modified );
} }
...@@ -150,7 +153,7 @@ void DIALOG_PAGES_SETTINGS::OnCloseWindow( wxCloseEvent& event ) ...@@ -150,7 +153,7 @@ void DIALOG_PAGES_SETTINGS::OnCloseWindow( wxCloseEvent& event )
void DIALOG_PAGES_SETTINGS::OnOkClick( wxCommandEvent& event ) void DIALOG_PAGES_SETTINGS::OnOkClick( wxCommandEvent& event )
{ {
SavePageSettings( event ); SavePageSettings( event );
m_Modified = 1; m_modified = true;
Close( true ); Close( true );
} }
...@@ -167,8 +170,9 @@ void DIALOG_PAGES_SETTINGS::OnCancelClick( wxCommandEvent& event ) ...@@ -167,8 +170,9 @@ void DIALOG_PAGES_SETTINGS::OnCancelClick( wxCommandEvent& event )
void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event ) void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event )
{ {
double dtmp;
wxString msg; wxString msg;
double userSizeX;
double userSizeY;
m_Screen->m_Revision = m_TextRevision->GetValue(); m_Screen->m_Revision = m_TextRevision->GetValue();
m_Screen->m_Company = m_TextCompany->GetValue(); m_Screen->m_Company = m_TextCompany->GetValue();
...@@ -179,50 +183,42 @@ void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event ) ...@@ -179,50 +183,42 @@ void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event )
m_Screen->m_Commentaire4 = m_TextComment4->GetValue(); m_Screen->m_Commentaire4 = m_TextComment4->GetValue();
msg = m_TextUserSizeX->GetValue(); msg = m_TextUserSizeX->GetValue();
msg.ToDouble( &dtmp ); msg.ToDouble( &userSizeX );
UserSizeX = dtmp;
msg = m_TextUserSizeY->GetValue(); msg = m_TextUserSizeY->GetValue();
msg.ToDouble( &dtmp ); msg.ToDouble( &userSizeY );
UserSizeY = dtmp;
int ii = m_PageSizeBox->GetSelection(); int radioSelection = m_PageSizeBox->GetSelection();
if( radioSelection < 0 )
radioSelection = 0;
if( ii < 0 ) wxString paperType = m_PageSizeBox->GetString( radioSelection );
ii = 0;
m_SelectedSheet = SheetList[ii]; m_page.SetType( paperType );
m_Screen->m_CurrentSheetDesc = m_SelectedSheet;
m_Parent->SetPageSettings( m_page );
switch( g_UserUnit ) switch( g_UserUnit )
{ {
case MILLIMETRES: case MILLIMETRES:
g_Sheet_user.m_Size.x = (int) ( UserSizeX * 1000 / 25.4 ); PAGE_INFO::SetUserWidthInches( userSizeX / 25.4 );
g_Sheet_user.m_Size.y = (int) ( UserSizeY * 1000 / 25.4 ); PAGE_INFO::SetUserHeightInches( userSizeY / 25.4 );
break; break;
default:
case INCHES: case INCHES:
g_Sheet_user.m_Size.x = (int) ( UserSizeX * 1000 ); PAGE_INFO::SetUserWidthInches( userSizeX );
g_Sheet_user.m_Size.y = (int) ( UserSizeY * 1000 ); PAGE_INFO::SetUserHeightInches( userSizeY );
break; break;
/* // set in 1/1000ths of an inch, but why?
case UNSCALED_UNITS: case UNSCALED_UNITS:
g_Sheet_user.m_Size.x = (int) ( UserSizeX ); PAGE_INFO::SetUserWidthInches( userSizeX /1000 );
g_Sheet_user.m_Size.y = (int) ( UserSizeY ); PAGE_INFO::SetUserHeightInches( userSizeY /1000 );
break; break;
*/
} }
if( g_Sheet_user.m_Size.x < 6000 )
g_Sheet_user.m_Size.x = 6000;
if( g_Sheet_user.m_Size.x > 44000 )
g_Sheet_user.m_Size.x = 44000;
if( g_Sheet_user.m_Size.y < 4000 )
g_Sheet_user.m_Size.y = 4000;
if( g_Sheet_user.m_Size.y > 44000 )
g_Sheet_user.m_Size.y = 44000;
#ifdef EESCHEMA #ifdef EESCHEMA
/* Exports settings to other sheets if requested: */ /* Exports settings to other sheets if requested: */
SCH_SCREEN* screen; SCH_SCREEN* screen;
...@@ -265,21 +261,19 @@ void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event ) ...@@ -265,21 +261,19 @@ void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event )
} }
/* Search the correct index to activate the radiobox list size selection void DIALOG_PAGES_SETTINGS::setCurrentPageSizeSelection()
* according to the current page size
*/
void DIALOG_PAGES_SETTINGS::SearchPageSizeSelection()
{ {
Ki_PageDescr* sheet; wxString curPaperType = m_page.GetType();
int ii;
m_CurrentSelection = NB_ITEMS - 1;
for( ii = 0; ii < NB_ITEMS; ii++ ) for( unsigned i = 0; i < m_PageSizeBox->GetCount(); ++i )
{ {
sheet = SheetList[ii]; if( m_PageSizeBox->GetString( i ) == curPaperType )
{
if( m_Parent->GetScreen()->m_CurrentSheetDesc == sheet ) m_PageSizeBox->SetSelection( i );
m_CurrentSelection = ii; return;
}
} }
// m_PageSizeBox->SetSelection( 1 ); // wxFormBuilder does this, control there
} }
...@@ -14,12 +14,11 @@ ...@@ -14,12 +14,11 @@
class DIALOG_PAGES_SETTINGS: public DIALOG_PAGES_SETTINGS_BASE class DIALOG_PAGES_SETTINGS: public DIALOG_PAGES_SETTINGS_BASE
{ {
private: private:
EDA_DRAW_FRAME *m_Parent; EDA_DRAW_FRAME* m_Parent;
BASE_SCREEN * m_Screen; BASE_SCREEN* m_Screen;
int m_Modified; bool m_modified;
Ki_PageDescr * m_SelectedSheet; PAGE_INFO m_page; ///< the one being edited
float UserSizeX, UserSizeY; PAGE_INFO m_user_size; ///< instantiated just to get the size
int m_CurrentSelection;
public: public:
DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* parent ); DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* parent );
...@@ -37,7 +36,8 @@ private: ...@@ -37,7 +36,8 @@ private:
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
void OnCancelClick( wxCommandEvent& event ); void OnCancelClick( wxCommandEvent& event );
void SearchPageSizeSelection();
void setCurrentPageSizeSelection();
void SavePageSettings(wxCommandEvent& event); void SavePageSettings(wxCommandEvent& event);
void ReturnSizeSelected(wxCommandEvent& event); void ReturnSizeSelected(wxCommandEvent& event);
......
...@@ -524,12 +524,11 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition ) ...@@ -524,12 +524,11 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition )
logicalClientSize.x = wxRound( (double) clientSize.x / scalar ); logicalClientSize.x = wxRound( (double) clientSize.x / scalar );
logicalClientSize.y = wxRound( (double) clientSize.y / scalar ); logicalClientSize.y = wxRound( (double) clientSize.y / scalar );
// The upper left corner of the drawing in device units. // A corner of the drawing in internal units.
int w = screen->ReturnPageSize().x; wxSize corner = GetPageSizeIU();
int h = screen->ReturnPageSize().y;
// The drawing rectangle logical units // The drawing rectangle logical units
wxRect drawingRect( wxPoint( 0, 0 ), wxSize( w, h ) ); wxRect drawingRect( wxPoint( 0, 0 ), corner );
wxLogTrace( traceScrollSettings, wxT( "Logical drawing rect = ( %d, %d, %d, %d )." ), wxLogTrace( traceScrollSettings, wxT( "Logical drawing rect = ( %d, %d, %d, %d )." ),
drawingRect.x, drawingRect.y, drawingRect.width, drawingRect.height ); drawingRect.x, drawingRect.y, drawingRect.width, drawingRect.height );
......
...@@ -527,23 +527,24 @@ void EDA_DRAW_PANEL::ReDraw( wxDC* DC, bool erasebg ) ...@@ -527,23 +527,24 @@ void EDA_DRAW_PANEL::ReDraw( wxDC* DC, bool erasebg )
void EDA_DRAW_PANEL::DrawBackGround( wxDC* DC ) void EDA_DRAW_PANEL::DrawBackGround( wxDC* DC )
{ {
int axis_color = BLUE; int axis_color = BLUE;
BASE_SCREEN* screen = GetScreen();
GRSetDrawMode( DC, GR_COPY ); GRSetDrawMode( DC, GR_COPY );
if( GetParent()->IsGridVisible() ) if( GetParent()->IsGridVisible() )
DrawGrid( DC ); DrawGrid( DC );
/* Draw axis */ // Draw axis
if( GetParent()->m_showAxis ) if( GetParent()->m_showAxis )
{ {
/* Draw the Y axis */ wxSize pageSize = GetParent()->GetPageSizeIU();
GRDashedLine( &m_ClipBox, DC, 0, -screen->ReturnPageSize().y,
0, screen->ReturnPageSize().y, 0, axis_color ); // Draw the Y axis
GRDashedLine( &m_ClipBox, DC, 0, -pageSize.y,
0, pageSize.y, 0, axis_color );
/* Draw the X axis */ // Draw the X axis
GRDashedLine( &m_ClipBox, DC, -screen->ReturnPageSize().x, 0, GRDashedLine( &m_ClipBox, DC, -pageSize.x, 0,
screen->ReturnPageSize().x, 0, 0, axis_color ); pageSize.x, 0, 0, axis_color );
} }
if( GetParent()->m_showOriginAxis ) if( GetParent()->m_showOriginAxis )
...@@ -679,26 +680,26 @@ void EDA_DRAW_PANEL::DrawAuxiliaryAxis( wxDC* aDC, int aDrawMode ) ...@@ -679,26 +680,26 @@ void EDA_DRAW_PANEL::DrawAuxiliaryAxis( wxDC* aDC, int aDrawMode )
if( GetParent()->m_originAxisPosition == wxPoint( 0, 0 ) ) if( GetParent()->m_originAxisPosition == wxPoint( 0, 0 ) )
return; return;
int Color = DARKRED; int color = DARKRED;
BASE_SCREEN* screen = GetScreen(); wxSize pageSize = GetParent()->GetPageSizeIU();
GRSetDrawMode( aDC, aDrawMode ); GRSetDrawMode( aDC, aDrawMode );
/* Draw the Y axis */ // Draw the Y axis
GRDashedLine( &m_ClipBox, aDC, GRDashedLine( &m_ClipBox, aDC,
GetParent()->m_originAxisPosition.x, GetParent()->m_originAxisPosition.x,
-screen->ReturnPageSize().y, -pageSize.y,
GetParent()->m_originAxisPosition.x, GetParent()->m_originAxisPosition.x,
screen->ReturnPageSize().y, pageSize.y,
0, Color ); 0, color );
/* Draw the X axis */ // Draw the X axis
GRDashedLine( &m_ClipBox, aDC, GRDashedLine( &m_ClipBox, aDC,
-screen->ReturnPageSize().x, -pageSize.x,
GetParent()->m_originAxisPosition.y, GetParent()->m_originAxisPosition.y,
screen->ReturnPageSize().x, pageSize.x,
GetParent()->m_originAxisPosition.y, GetParent()->m_originAxisPosition.y,
0, Color ); 0, color );
} }
...@@ -710,25 +711,26 @@ void EDA_DRAW_PANEL::DrawGridAxis( wxDC* aDC, int aDrawMode ) ...@@ -710,25 +711,26 @@ void EDA_DRAW_PANEL::DrawGridAxis( wxDC* aDC, int aDrawMode )
|| ( screen->m_GridOrigin.x == 0 && screen->m_GridOrigin.y == 0 ) ) || ( screen->m_GridOrigin.x == 0 && screen->m_GridOrigin.y == 0 ) )
return; return;
int Color = GetParent()->GetGridColor(); int color = GetParent()->GetGridColor();
wxSize pageSize = GetParent()->GetPageSizeIU();
GRSetDrawMode( aDC, aDrawMode ); GRSetDrawMode( aDC, aDrawMode );
/* Draw the Y axis */ // Draw the Y axis
GRDashedLine( &m_ClipBox, aDC, GRDashedLine( &m_ClipBox, aDC,
screen->m_GridOrigin.x, screen->m_GridOrigin.x,
-screen->ReturnPageSize().y, -pageSize.y,
screen->m_GridOrigin.x, screen->m_GridOrigin.x,
screen->ReturnPageSize().y, pageSize.y,
0, Color ); 0, color );
/* Draw the X axis */ // Draw the X axis
GRDashedLine( &m_ClipBox, aDC, GRDashedLine( &m_ClipBox, aDC,
-screen->ReturnPageSize().x, -pageSize.x,
screen->m_GridOrigin.y, screen->m_GridOrigin.y,
screen->ReturnPageSize().x, pageSize.x,
screen->m_GridOrigin.y, screen->m_GridOrigin.y,
0, Color ); 0, color );
} }
......
This diff is collapsed.
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
class EDA_DRAW_FRAME; class EDA_DRAW_FRAME;
class BASE_SCREEN;
#include "dialog_SVG_print_base.h" #include "dialog_SVG_print_base.h"
......
...@@ -750,11 +750,11 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( FILE* f, ...@@ -750,11 +750,11 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( FILE* f,
{ {
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
strCur.Printf( wxT( "%c%s" ), s_ExportSeparatorSymbol, GetChars( msg ) ); strCur.Printf( wxT( "%c%s" ), s_ExportSeparatorSymbol, GetChars( msg ) );
msg = m_Parent->GetXYSheetReferences( screen, comp->GetPosition() ); msg = m_Parent->GetXYSheetReferences( comp->GetPosition() );
strCur.Printf( wxT( "%c%s)" ), s_ExportSeparatorSymbol, GetChars( msg ) ); strCur.Printf( wxT( "%c%s)" ), s_ExportSeparatorSymbol, GetChars( msg ) );
#else #else
fprintf( f, "%c%s", s_ExportSeparatorSymbol, TO_UTF8( msg ) ); fprintf( f, "%c%s", s_ExportSeparatorSymbol, TO_UTF8( msg ) );
msg = m_Parent->GetXYSheetReferences( screen, comp->GetPosition() ); msg = m_Parent->GetXYSheetReferences( comp->GetPosition() );
fprintf( f, "%c%s)", s_ExportSeparatorSymbol, fprintf( f, "%c%s)", s_ExportSeparatorSymbol,
TO_UTF8( msg ) ); TO_UTF8( msg ) );
#endif #endif
...@@ -762,7 +762,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( FILE* f, ...@@ -762,7 +762,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( FILE* f,
else else
{ {
fprintf( f, " (Sheet %s)", TO_UTF8( msg ) ); fprintf( f, " (Sheet %s)", TO_UTF8( msg ) );
msg = m_Parent->GetXYSheetReferences( screen, comp->GetPosition() ); msg = m_Parent->GetXYSheetReferences( comp->GetPosition() );
fprintf( f, " (loc %s)", TO_UTF8( msg ) ); fprintf( f, " (loc %s)", TO_UTF8( msg ) );
} }
} }
...@@ -1060,7 +1060,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal( FILE* f, ...@@ -1060,7 +1060,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal( FILE* f,
{ {
msg = aList[ii].GetSheetPath().PathHumanReadable(); msg = aList[ii].GetSheetPath().PathHumanReadable();
fprintf( f, " (Sheet %s)", TO_UTF8( msg ) ); fprintf( f, " (Sheet %s)", TO_UTF8( msg ) );
msg = m_Parent->GetXYSheetReferences( screen, DrawLibItem->GetPosition() ); msg = m_Parent->GetXYSheetReferences( DrawLibItem->GetPosition() );
fprintf( f, " (loc %s)", TO_UTF8( msg ) ); fprintf( f, " (loc %s)", TO_UTF8( msg ) );
} }
} }
......
...@@ -64,7 +64,7 @@ private: ...@@ -64,7 +64,7 @@ private:
void initOptVars(); void initOptVars();
void CreateDXFFile(); void CreateDXFFile();
void PlotOneSheetDXF( const wxString& FileName, void PlotOneSheetDXF( const wxString& FileName,
SCH_SCREEN* screen, Ki_PageDescr* sheet, SCH_SCREEN* screen, PAGE_INFO* sheet,
wxPoint plot_offset, double scale ); wxPoint plot_offset, double scale );
}; };
/* static members (static to remember last state): */ /* static members (static to remember last state): */
...@@ -148,7 +148,7 @@ void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( ) ...@@ -148,7 +148,7 @@ void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( )
SCH_SHEET_PATH* sheetpath; SCH_SHEET_PATH* sheetpath;
SCH_SHEET_PATH oldsheetpath = schframe->GetCurrentSheet(); SCH_SHEET_PATH oldsheetpath = schframe->GetCurrentSheet();
wxString PlotFileName; wxString PlotFileName;
Ki_PageDescr* PlotSheet; PAGE_INFO* PlotSheet;
wxPoint plot_offset; wxPoint plot_offset;
/* When printing all pages, the printed page is not the current page. /* When printing all pages, the printed page is not the current page.
...@@ -208,7 +208,7 @@ void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( ) ...@@ -208,7 +208,7 @@ void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( )
void DIALOG_PLOT_SCHEMATIC_DXF::PlotOneSheetDXF( const wxString& FileName, void DIALOG_PLOT_SCHEMATIC_DXF::PlotOneSheetDXF( const wxString& FileName,
SCH_SCREEN* screen, SCH_SCREEN* screen,
Ki_PageDescr* sheet, PAGE_INFO* sheet,
wxPoint plot_offset, wxPoint plot_offset,
double scale ) double scale )
{ {
......
...@@ -54,7 +54,7 @@ enum PageFormatReq ...@@ -54,7 +54,7 @@ enum PageFormatReq
PAGE_SIZE_E PAGE_SIZE_E
}; };
static Ki_PageDescr* Plot_sheet_list[] = static PAGE_INFO* Plot_sheet_list[] =
{ {
NULL, NULL,
&g_Sheet_A4, &g_Sheet_A4,
...@@ -99,7 +99,7 @@ private: ...@@ -99,7 +99,7 @@ private:
void HPGL_Plot( bool aPlotAll ); void HPGL_Plot( bool aPlotAll );
void Plot_Schematic_HPGL( bool aPlotAll, int HPGL_SheetSize ); void Plot_Schematic_HPGL( bool aPlotAll, int HPGL_SheetSize );
void Plot_1_Page_HPGL( const wxString& FileName, void Plot_1_Page_HPGL( const wxString& FileName,
SCH_SCREEN* screen, Ki_PageDescr* sheet, SCH_SCREEN* screen, PAGE_INFO* sheet,
wxPoint& offset, double plot_scale ); wxPoint& offset, double plot_scale );
void ReturnSheetDims( SCH_SCREEN* screen, wxSize& SheetSize, wxPoint& SheetOffset ); void ReturnSheetDims( SCH_SCREEN* screen, wxSize& SheetSize, wxPoint& SheetOffset );
}; };
...@@ -245,7 +245,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::HPGL_Plot( bool aPlotAll ) ...@@ -245,7 +245,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::HPGL_Plot( bool aPlotAll )
if( m_pageSizeSelect != PAGE_DEFAULT ) if( m_pageSizeSelect != PAGE_DEFAULT )
{ {
Ki_PageDescr* plot_sheet = Plot_sheet_list[m_pageSizeSelect]; PAGE_INFO* plot_sheet = Plot_sheet_list[m_pageSizeSelect];
wxString msg = m_PlotOrgPosition_X->GetValue(); wxString msg = m_PlotOrgPosition_X->GetValue();
plot_sheet->m_Offset.x = plot_sheet->m_Offset.x =
ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT ); ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT );
...@@ -265,7 +265,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::ReturnSheetDims( SCH_SCREEN* screen, ...@@ -265,7 +265,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::ReturnSheetDims( SCH_SCREEN* screen,
wxSize& SheetSize, wxSize& SheetSize,
wxPoint& SheetOffset ) wxPoint& SheetOffset )
{ {
Ki_PageDescr* PlotSheet; PAGE_INFO* PlotSheet;
if( screen == NULL ) if( screen == NULL )
screen = m_Parent->GetScreen(); screen = m_Parent->GetScreen();
...@@ -283,7 +283,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_Schematic_HPGL( bool aPlotAll, int HPGL_Sh ...@@ -283,7 +283,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_Schematic_HPGL( bool aPlotAll, int HPGL_Sh
SCH_SCREEN* screen = m_Parent->GetScreen(); SCH_SCREEN* screen = m_Parent->GetScreen();
SCH_SHEET_PATH* sheetpath; SCH_SHEET_PATH* sheetpath;
SCH_SHEET_PATH oldsheetpath = m_Parent->GetCurrentSheet(); SCH_SHEET_PATH oldsheetpath = m_Parent->GetCurrentSheet();
Ki_PageDescr* PlotSheet; PAGE_INFO* PlotSheet;
wxSize SheetSize; wxSize SheetSize;
wxPoint SheetOffset, PlotOffset; wxPoint SheetOffset, PlotOffset;
...@@ -353,7 +353,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_Schematic_HPGL( bool aPlotAll, int HPGL_Sh ...@@ -353,7 +353,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, void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_1_Page_HPGL( const wxString& FileName,
SCH_SCREEN* screen, SCH_SCREEN* screen,
Ki_PageDescr* sheet, PAGE_INFO* sheet,
wxPoint& offset, wxPoint& offset,
double plot_scale ) double plot_scale )
{ {
......
...@@ -70,7 +70,7 @@ private: ...@@ -70,7 +70,7 @@ private:
void initOptVars(); void initOptVars();
void createPSFile(); void createPSFile();
void plotOneSheetPS( const wxString& FileName, void plotOneSheetPS( const wxString& FileName,
SCH_SCREEN* screen, Ki_PageDescr* sheet, SCH_SCREEN* screen, PAGE_INFO* sheet,
wxPoint plot_offset, double scale ); wxPoint plot_offset, double scale );
}; };
/* static members (static to remember last state): */ /* static members (static to remember last state): */
...@@ -176,8 +176,8 @@ void DIALOG_PLOT_SCHEMATIC_PS::createPSFile() ...@@ -176,8 +176,8 @@ void DIALOG_PLOT_SCHEMATIC_PS::createPSFile()
SCH_SHEET_PATH* sheetpath; SCH_SHEET_PATH* sheetpath;
SCH_SHEET_PATH oldsheetpath = m_Parent->GetCurrentSheet(); // sheetpath is saved here SCH_SHEET_PATH oldsheetpath = m_Parent->GetCurrentSheet(); // sheetpath is saved here
wxString plotFileName; wxString plotFileName;
Ki_PageDescr* actualPage; // page size selected in schematic PAGE_INFO* actualPage; // page size selected in schematic
Ki_PageDescr* plotPage; // page size selected to plot PAGE_INFO* plotPage; // page size selected to plot
wxPoint plot_offset; wxPoint plot_offset;
/* When printing all pages, the printed page is not the current page. /* When printing all pages, the printed page is not the current page.
...@@ -254,7 +254,7 @@ void DIALOG_PLOT_SCHEMATIC_PS::createPSFile() ...@@ -254,7 +254,7 @@ void DIALOG_PLOT_SCHEMATIC_PS::createPSFile()
void DIALOG_PLOT_SCHEMATIC_PS::plotOneSheetPS( const wxString& FileName, void DIALOG_PLOT_SCHEMATIC_PS::plotOneSheetPS( const wxString& FileName,
SCH_SCREEN* screen, SCH_SCREEN* screen,
Ki_PageDescr* sheet, PAGE_INFO* sheet,
wxPoint plot_offset, wxPoint plot_offset,
double scale ) double scale )
{ {
......
...@@ -305,11 +305,11 @@ bool ReadSchemaDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* aScre ...@@ -305,11 +305,11 @@ bool ReadSchemaDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* aScre
char Text[256]; char Text[256];
char buf[1024]; char buf[1024];
int ii; int ii;
Ki_PageDescr* wsheet = &g_Sheet_A4; PAGE_INFO* wsheet = &g_Sheet_A4;
wxSize PageSize; wxSize PageSize;
char* line; char* line;
static Ki_PageDescr* SheetFormatList[] = static PAGE_INFO* SheetFormatList[] =
{ {
&g_Sheet_A4, &g_Sheet_A3, &g_Sheet_A2, &g_Sheet_A1, &g_Sheet_A0, &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_A, &g_Sheet_B, &g_Sheet_C, &g_Sheet_D, &g_Sheet_E,
......
...@@ -101,7 +101,8 @@ SCH_SCREEN::SCH_SCREEN( KICAD_T type ) : BASE_SCREEN( type ) ...@@ -101,7 +101,8 @@ SCH_SCREEN::SCH_SCREEN( KICAD_T type ) : BASE_SCREEN( type )
{ {
size_t i; size_t i;
SetDrawItems( NULL ); /* Schematic items list */ SetDrawItems( NULL ); // Schematic items list
m_Zoom = 32; m_Zoom = 32;
for( i = 0; i < SCHEMATIC_ZOOM_LIST_CNT; i++ ) for( i = 0; i < SCHEMATIC_ZOOM_LIST_CNT; i++ )
...@@ -110,12 +111,12 @@ SCH_SCREEN::SCH_SCREEN( KICAD_T type ) : BASE_SCREEN( type ) ...@@ -110,12 +111,12 @@ SCH_SCREEN::SCH_SCREEN( KICAD_T type ) : BASE_SCREEN( type )
for( i = 0; i < SCHEMATIC_GRID_LIST_CNT; i++ ) for( i = 0; i < SCHEMATIC_GRID_LIST_CNT; i++ )
AddGrid( SchematicGridList[i] ); AddGrid( SchematicGridList[i] );
SetGrid( wxRealPoint( 50, 50 ) ); /* Default grid size. */ SetGrid( wxRealPoint( 50, 50 ) ); // Default grid size.
m_refCount = 0; m_refCount = 0;
m_Center = false; /* Suitable for schematic only. For
* libedit and viewlib, must be set m_Center = false; // Suitable for schematic only. For
* to true */ // libedit and viewlib, must be set
InitDatas(); // to true
} }
...@@ -1547,3 +1548,18 @@ int SCH_SCREENS::GetMarkerCount( int aMarkerType ) ...@@ -1547,3 +1548,18 @@ int SCH_SCREENS::GetMarkerCount( int aMarkerType )
return count; return count;
} }
#if defined(DEBUG)
void SCH_SCREEN::Show( int nestLevel, std::ostream& os ) const
{
// for now, make it look like XML, expand on this later.
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n";
for( EDA_ITEM* item = m_drawList; item; item = item->Next() )
{
item->Show( nestLevel+1, os );
}
NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
}
#endif
...@@ -32,7 +32,7 @@ int g_DisplayPolygonsModeSketch; ...@@ -32,7 +32,7 @@ int g_DisplayPolygonsModeSketch;
GERBER_IMAGE* g_GERBER_List[32]; GERBER_IMAGE* g_GERBER_List[32];
// List of page sizes // List of page sizes
Ki_PageDescr* g_GerberPageSizeList[] = PAGE_INFO* g_GerberPageSizeList[] =
{ {
&g_Sheet_GERBER, // Full size page selection, and do not show page limits &g_Sheet_GERBER, // Full size page selection, and do not show page limits
&g_Sheet_GERBER, // Full size page selection, and show page limits &g_Sheet_GERBER, // Full size page selection, and show page limits
......
...@@ -19,7 +19,7 @@ class GERBVIEW_FRAME; ...@@ -19,7 +19,7 @@ class GERBVIEW_FRAME;
//class BOARD; //class BOARD;
class GERBER_IMAGE; class GERBER_IMAGE;
class Ki_PageDescr; class PAGE_INFO;
// Type of photoplotter action: // Type of photoplotter action:
...@@ -57,8 +57,6 @@ extern int g_DisplayPolygonsModeSketch; ...@@ -57,8 +57,6 @@ extern int g_DisplayPolygonsModeSketch;
extern const wxString GerbviewProjectFileExt; extern const wxString GerbviewProjectFileExt;
extern const wxString GerbviewProjectFileWildcard; extern const wxString GerbviewProjectFileWildcard;
extern Ki_PageDescr* g_GerberPageSizeList[];
// Interpolation type // Interpolation type
enum Gerb_Interpolation enum Gerb_Interpolation
{ {
......
...@@ -83,13 +83,13 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father, ...@@ -83,13 +83,13 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father,
icon.CopyFromBitmap( KiBitmap( icon_gerbview_xpm ) ); icon.CopyFromBitmap( KiBitmap( icon_gerbview_xpm ) );
SetIcon( icon ); SetIcon( icon );
SetScreen( new PCB_SCREEN() );
GetScreen()->m_CurrentSheetDesc = &g_Sheet_GERBER;
SetBoard( new BOARD() ); SetBoard( new BOARD() );
GetBoard()->SetEnabledLayers( FULL_LAYERS ); // All 32 layers enabled at first. GetBoard()->SetEnabledLayers( FULL_LAYERS ); // All 32 layers enabled at first.
GetBoard()->SetVisibleLayers( FULL_LAYERS ); // All 32 layers visible. GetBoard()->SetVisibleLayers( FULL_LAYERS ); // All 32 layers visible.
SetScreen( new PCB_SCREEN() );
GetScreen()->m_CurrentSheetDesc = &g_Sheet_GERBER;
// Create the PCB_LAYER_WIDGET *after* SetBoard(): // Create the PCB_LAYER_WIDGET *after* SetBoard():
wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
int pointSize = font.GetPointSize(); int pointSize = font.GetPointSize();
...@@ -209,17 +209,15 @@ void GERBVIEW_FRAME::LoadSettings() ...@@ -209,17 +209,15 @@ void GERBVIEW_FRAME::LoadSettings()
wxGetApp().ReadCurrentSetupValues( GetConfigurationSettings() ); wxGetApp().ReadCurrentSetupValues( GetConfigurationSettings() );
long pageSize_opt; wxString pageType;
config->Read( GerbviewShowPageSizeOption, &pageSize_opt, 0l );
int imax = 0; config->Read( GerbviewShowPageSizeOption, &pageType, wxT( "GERBER" ) );
for( ; g_GerberPageSizeList[imax] != NULL; imax++ ) PAGE_INFO pageInfo( pageType );
;
if( pageSize_opt < 0 || pageSize_opt >= imax ) SetPageSettings( pageInfo );
pageSize_opt = 0;
GetScreen()->m_CurrentSheetDesc = g_GerberPageSizeList[pageSize_opt]; GetScreen()->InitDataPoints( pageInfo.GetSizeIU() );
if( pageSize_opt > 0 ) if( pageSize_opt > 0 )
{ {
...@@ -268,7 +266,7 @@ void GERBVIEW_FRAME::SaveSettings() ...@@ -268,7 +266,7 @@ void GERBVIEW_FRAME::SaveSettings()
} }
} }
config->Write( GerbviewShowPageSizeOption, pageSize_opt ); config->Write( GerbviewShowPageSizeOption, GetPageSettings().GetType() );
config->Write( GerbviewShowDCodes, IsElementVisible( DCODES_VISIBLE ) ); config->Write( GerbviewShowDCodes, IsElementVisible( DCODES_VISIBLE ) );
// Save the drill file history list. // Save the drill file history list.
// Because we have 2 file histories, we must save this one // Because we have 2 file histories, we must save this one
......
...@@ -70,6 +70,7 @@ bool GERBVIEW_FRAME::Clear_Pcb( bool query ) ...@@ -70,6 +70,7 @@ bool GERBVIEW_FRAME::Clear_Pcb( bool query )
SetScreen( new PCB_SCREEN() ); SetScreen( new PCB_SCREEN() );
GetScreen()->Init(); GetScreen()->Init();
setActiveLayer(FIRST_COPPER_LAYER); setActiveLayer(FIRST_COPPER_LAYER);
m_LayersManager->UpdateLayerIcons(); m_LayersManager->UpdateLayerIcons();
syncLayerBox(); syncLayerBox();
......
...@@ -37,11 +37,10 @@ ...@@ -37,11 +37,10 @@
#include "common.h" #include "common.h"
// Forward declarations: /**
class Ki_PageDescr; * Class GRID_TYPE
* is for grid arrays.
*/
/* Simple class for handling grid arrays. */
class GRID_TYPE class GRID_TYPE
{ {
public: public:
...@@ -59,7 +58,6 @@ public: ...@@ -59,7 +58,6 @@ public:
return *this; return *this;
} }
const bool operator==( const GRID_TYPE& item ) const const bool operator==( const GRID_TYPE& item ) const
{ {
return m_Size == item.m_Size && m_Id == item.m_Id; return m_Size == item.m_Size && m_Id == item.m_Id;
...@@ -72,13 +70,12 @@ typedef std::vector< GRID_TYPE > GRIDS; ...@@ -72,13 +70,12 @@ typedef std::vector< GRID_TYPE > GRIDS;
/** /**
* Class BASE_SCREEN * Class BASE_SCREEN
* handle how to draw a screen (a board, a schematic ...) * handles how to draw a screen (a board, a schematic ...)
*/ */
class BASE_SCREEN : public EDA_ITEM class BASE_SCREEN : public EDA_ITEM
{ {
EDA_ITEMS m_items; ///< The drawing items associated with this screen. EDA_ITEMS m_items; ///< The drawing items associated with this screen.
GRIDS m_grids; ///< List of valid grid sizes. GRIDS m_grids; ///< List of valid grid sizes.
EDA_ITEM* m_drawList; ///< Object list for the screen.
wxString m_fileName; ///< File used to load the screen. wxString m_fileName; ///< File used to load the screen.
char m_FlagRefreshReq; ///< Indicates that the screen should be redrawn. char m_FlagRefreshReq; ///< Indicates that the screen should be redrawn.
bool m_FlagModified; ///< Indicates current drawing has been modified. bool m_FlagModified; ///< Indicates current drawing has been modified.
...@@ -96,18 +93,19 @@ class BASE_SCREEN : public EDA_ITEM ...@@ -96,18 +93,19 @@ class BASE_SCREEN : public EDA_ITEM
wxPoint m_crossHairPosition; wxPoint m_crossHairPosition;
public: public:
wxPoint m_DrawOrg; /* offsets for drawing the circuit on the screen */ wxPoint m_DrawOrg; ///< offsets for drawing the circuit on the screen
wxPoint m_O_Curseur; /* Relative Screen cursor coordinate (on grid) wxPoint m_O_Curseur; /* Relative Screen cursor coordinate (on grid)
* in user units. (coordinates from last reset position)*/ * in user units. (coordinates from last reset position)*/
// Scrollbars management: // Scrollbars management:
int m_ScrollPixelsPerUnitX; /* Pixels per scroll unit in the horizontal direction. */ int m_ScrollPixelsPerUnitX; ///< Pixels per scroll unit in the horizontal direction.
int m_ScrollPixelsPerUnitY; /* Pixels per scroll unit in the vertical direction. */ int m_ScrollPixelsPerUnitY; ///< Pixels per scroll unit in the vertical direction.
wxSize m_ScrollbarNumber; /* Current virtual draw area size in scroll units. wxSize m_ScrollbarNumber; /* Current virtual draw area size in scroll units.
* m_ScrollbarNumber * m_ScrollPixelsPerUnit = * m_ScrollbarNumber * m_ScrollPixelsPerUnit =
* virtual draw area size in pixels */ * virtual draw area size in pixels */
wxPoint m_ScrollbarPos; /* Current scroll bar position in scroll units. */
wxPoint m_ScrollbarPos; ///< Current scroll bar position in scroll units.
wxPoint m_StartVisu; /* Coordinates in drawing units of the current wxPoint m_StartVisu; /* Coordinates in drawing units of the current
* view position (upper left corner of device) * view position (upper left corner of device)
...@@ -121,15 +119,13 @@ public: ...@@ -121,15 +119,13 @@ public:
bool m_FirstRedraw; bool m_FirstRedraw;
// Undo/redo list of commands // Undo/redo list of commands
UNDO_REDO_CONTAINER m_UndoList; /* Objects list for the undo command (old data) */ UNDO_REDO_CONTAINER m_UndoList; ///< Objects list for the undo command (old data)
UNDO_REDO_CONTAINER m_RedoList; /* Objects list for the redo command (old data) */ UNDO_REDO_CONTAINER m_RedoList; ///< Objects list for the redo command (old data)
unsigned m_UndoRedoCountMax; // undo/Redo command Max depth unsigned m_UndoRedoCountMax; ///< undo/Redo command Max depth
/* block control */ // block control
BLOCK_SELECTOR m_BlockLocate; /* Block description for block commands */ BLOCK_SELECTOR m_BlockLocate; ///< Block description for block commands
/* Page description */
Ki_PageDescr* m_CurrentSheetDesc;
int m_ScreenNumber; int m_ScreenNumber;
int m_NumberOfScreen; int m_NumberOfScreen;
...@@ -145,8 +141,8 @@ public: ...@@ -145,8 +141,8 @@ public:
/* Grid and zoom values. */ /* Grid and zoom values. */
wxPoint m_GridOrigin; wxPoint m_GridOrigin;
wxArrayDouble m_ZoomList; /* Array of standard zoom (i.e. scale) coefficients. */ wxArrayDouble m_ZoomList; ///< Array of standard zoom (i.e. scale) coefficients.
double m_Zoom; /* Current zoom coefficient. */ double m_Zoom; ///< Current zoom coefficient.
bool m_IsPrinting; bool m_IsPrinting;
public: public:
...@@ -162,24 +158,12 @@ public: ...@@ -162,24 +158,12 @@ public:
EDA_ITEM* GetCurItem() const { return m_CurrentItem; } EDA_ITEM* GetCurItem() const { return m_CurrentItem; }
/** void InitDataPoints( const wxSize& aPageSizeInternalUnits );
* Function GetDrawItems().
*
* @return - A pointer to the first item in the linked list of draw items.
*/
virtual EDA_ITEM* GetDrawItems() const { return m_drawList; }
virtual void SetDrawItems( EDA_ITEM* aItem ) { m_drawList = aItem; }
void InitDatas();
void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; } void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; }
wxString GetFileName() const { return m_fileName; } wxString GetFileName() const { return m_fileName; }
void SetPageSize( wxSize& aPageSize );
wxSize ReturnPageSize( void );
/** /**
* Function GetInternalUnits * Function GetInternalUnits
* @return the screen units scalar. * @return the screen units scalar.
...@@ -469,9 +453,8 @@ public: ...@@ -469,9 +453,8 @@ public:
} }
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
#endif #endif
}; };
#endif // CLASS_BASE_SCREEN_H_ #endif // CLASS_BASE_SCREEN_H_
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
* @file class_pcb_screen.h * @file class_pcb_screen.h
*/ */
#ifndef __CLASSPCB_SCREEN_H__ #ifndef CLASS_PCB_SCREEN_H_
#define __CLASSPCB_SCREEN_H__ #define CLASS_PCB_SCREEN_H_
#include "class_base_screen.h" #include "class_base_screen.h"
...@@ -26,17 +26,17 @@ public: ...@@ -26,17 +26,17 @@ public:
~PCB_SCREEN(); ~PCB_SCREEN();
PCB_SCREEN* Next() { return (PCB_SCREEN*) Pnext; } PCB_SCREEN* Next() { return (PCB_SCREEN*) Pnext; }
void Init();
void SetNextZoom(); void SetNextZoom();
void SetPreviousZoom(); void SetPreviousZoom();
void SetLastZoom(); void SetLastZoom();
virtual int GetInternalUnits( void ); virtual int GetInternalUnits();
/** /**
* Function GetCurItem * Function GetCurItem
* returns the currently selected BOARD_ITEM, overriding * returns the currently selected BOARD_ITEM, overriding
*BASE_SCREEN::GetCurItem(). * BASE_SCREEN::GetCurItem().
* @return BOARD_ITEM* - the one selected, or NULL. * @return BOARD_ITEM* - the one selected, or NULL.
*/ */
BOARD_ITEM* GetCurItem() const BOARD_ITEM* GetCurItem() const
...@@ -73,5 +73,4 @@ public: ...@@ -73,5 +73,4 @@ public:
void ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount = -1 ); void ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount = -1 );
}; };
#endif // CLASS_PCB_SCREEN_H_
#endif /* __CLASSPCB_SCREEN_H__ */
...@@ -55,7 +55,7 @@ enum SCH_LINE_TEST_T ...@@ -55,7 +55,7 @@ enum SCH_LINE_TEST_T
}; };
/* Max number of sheets in a hierarchy project: */ /// Max number of sheets in a hierarchy project
#define NB_MAX_SHEET 500 #define NB_MAX_SHEET 500
...@@ -64,6 +64,12 @@ class SCH_SCREEN : public BASE_SCREEN ...@@ -64,6 +64,12 @@ class SCH_SCREEN : public BASE_SCREEN
int m_refCount; ///< Number of sheets referencing this screen. int m_refCount; ///< Number of sheets referencing this screen.
///< Delete when it goes to zero. ///< 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
SCH_ITEM* m_drawList; ///< Object list for the screen.
/// @todo use DLIST<SCH_ITEM> or superior container
/** /**
* Function addConnectedItemsToBlock * Function addConnectedItemsToBlock
* add items connected at \a aPosition to the block pick list. * add items connected at \a aPosition to the block pick list.
...@@ -85,6 +91,9 @@ public: ...@@ -85,6 +91,9 @@ public:
return wxT( "SCH_SCREEN" ); return wxT( "SCH_SCREEN" );
} }
const PAGE_INFO& GetPageSettings() const { return m_paper; }
void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; }
void DecRefCount(); void DecRefCount();
void IncRefCount(); void IncRefCount();
...@@ -93,12 +102,10 @@ public: ...@@ -93,12 +102,10 @@ public:
/** /**
* Function GetDrawItems(). * Function GetDrawItems().
*
* @return - A pointer to the first item in the linked list of draw items. * @return - A pointer to the first item in the linked list of draw items.
*/ */
virtual SCH_ITEM* GetDrawItems() const { return (SCH_ITEM*) BASE_SCREEN::GetDrawItems(); } SCH_ITEM* GetDrawItems() const { return m_drawList; }
void SetDrawItems( SCH_ITEM* aItem ) { m_drawList = aItem; }
virtual void SetDrawItems( SCH_ITEM* aItem ) { BASE_SCREEN::SetDrawItems( aItem ); }
/** /**
* Function GetCurItem * Function GetCurItem
...@@ -456,6 +463,10 @@ public: ...@@ -456,6 +463,10 @@ public:
{ {
BASE_SCREEN::InsertItem( aIter, (EDA_ITEM*) aItem ); BASE_SCREEN::InsertItem( aIter, (EDA_ITEM*) aItem );
} }
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload
#endif
}; };
......
...@@ -32,10 +32,13 @@ ...@@ -32,10 +32,13 @@
#ifndef INCLUDE__COMMON_H_ #ifndef INCLUDE__COMMON_H_
#define INCLUDE__COMMON_H_ #define INCLUDE__COMMON_H_
#include <vector>
#include "wx/wx.h" #include "wx/wx.h"
#include "wx/confbase.h" #include "wx/confbase.h"
#include "wx/fileconf.h" #include "wx/fileconf.h"
class wxAboutDialogInfo; class wxAboutDialogInfo;
class BASE_SCREEN; class BASE_SCREEN;
class EDA_DRAW_FRAME; class EDA_DRAW_FRAME;
...@@ -54,12 +57,11 @@ class EDA_DRAW_PANEL; ...@@ -54,12 +57,11 @@ class EDA_DRAW_PANEL;
* flag for block commands * flag for block commands
*/ */
// default name for nameless projects /// default name for nameless projects
#define NAMELESS_PROJECT wxT( "noname" ) #define NAMELESS_PROJECT wxT( "noname" )
#define NB_ITEMS 11
/* Pseudo key codes for command panning */ /// Pseudo key codes for command panning
enum pseudokeys { enum pseudokeys {
EDA_PANNING_UP_KEY = 1, EDA_PANNING_UP_KEY = 1,
EDA_PANNING_DOWN_KEY, EDA_PANNING_DOWN_KEY,
...@@ -124,40 +126,103 @@ enum EDA_UNITS_T { ...@@ -124,40 +126,103 @@ enum EDA_UNITS_T {
class LibNameList; class LibNameList;
/* Class to handle pages sizes: 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.
*/ */
class Ki_PageDescr class PAGE_INFO
{ {
// All sizes are in 1/1000 inch
public: public:
wxSize m_Size; /* page size in 1/1000 inch */ PAGE_INFO( const wxString& aType = wxT( "A3" ) );
wxPoint m_Offset; /* plot offset in 1/1000 inch */ PAGE_INFO( const wxSize& aSizeMils, const wxPoint& aOffsetMils, const wxString& aName );
wxString m_Name;
const wxString& GetType() const { return m_Type; }
/**
* Function SetType
* sets the name of the page type and also the sizes and margins
* commonly associated with that type name.
*
* @param aStandardPageDescriptionName is a wxString constant giving one of:
* "A4" "A3" "A2" "A1" "A0" "A" "B" "C" "D" "E" "GERBER", or "User". If "User"
* then the width and height are custom, and will be set according to previous calls
* to static PAGE_INFO::SetUserWidthInches( double aWidthInInches ) and
* static PAGE_INFO::SetUserHeightInches( double aHeightInInches );
*
* @return bool - true iff @a aStandarePageDescription was a recognized type.
*/
bool SetType( const wxString& aStandardPageDescriptionName );
void SetWidthInches( double aWidthInInches );
void SetHeightInches( double aHeightInInches );
double GetWidthInches() const { return m_widthInches; }
double GetHeightInches() const { return m_heightInches; }
int GetWidthMils() const { return int( 1000 * m_widthInches ); }
int GetHeightMils() const { return int( 1000 * m_heightInches ); }
const wxSize GetSizeMils() const { return wxSize( GetWidthMils(), GetHeightMils() ); }
// accessors returning Internal Units
#if defined(PCBNEW)
# if defined(KICAD_NANOMETRE)
int GetWidthIU() const { return int( 2.54e7 * m_widthInches ); }
int GetHeightIU() const { return int( 2.54e7 * m_heightInches ); }
# else
int GetWidthIU() const { return int( 10000 * m_widthInches ); }
int GetHeightIU() const { return int( 10000 * m_heightInches ); }
# endif
const wxSize GetSizeIU() const { return wxSize( GetWidthIU(), GetHeightIU() ); }
#elif defined(EESCHEMA)
int GetWidthIU() const { return int( 1000 * m_widthInches ); }
int GetHeightIU() const { return int( 1000 * m_heightInches ); }
const wxSize GetSizeIU() const { return wxSize( GetWidthIU(), GetHeightIU() ); }
#endif
wxPoint GetOffsetMils() const { return m_Offset; }
int GetLeftMarginMils() const { return m_LeftMargin; }
int GetRightMarginMils() const { return m_RightMargin; }
int GetTopMarginMils() const { return m_TopMargin; }
int GetBottomMarginMils() const { return m_BottomMargin; }
/**
* Function SetUserWidthInches
* sets the width of type "User" page in inches.
*/
static void SetUserWidthInches( double aWidthInInches );
/**
* Function SetUserHeightInches
* sets the height type "User" page in inches.
*/
static void SetUserHeightInches( double aHeightInInches );
#define PAGE_INFO_COUNT 11 ///< count of standard page sizes
private:
wxString m_Type; ///< paper type: A4, A3, etc.
double m_widthInches;
double m_heightInches;
wxPoint m_Offset; ///< plot offset in 1/1000 inches
int m_LeftMargin; int m_LeftMargin;
int m_RightMargin; int m_RightMargin;
int m_TopMargin; int m_TopMargin;
int m_BottomMargin; int m_BottomMargin;
public: static double s_user_height;
Ki_PageDescr( const wxSize& size, const wxPoint& offset, const wxString& name ); static double s_user_width;
}; };
extern Ki_PageDescr g_Sheet_A4;
extern Ki_PageDescr g_Sheet_A3;
extern Ki_PageDescr g_Sheet_A2;
extern Ki_PageDescr g_Sheet_A1;
extern Ki_PageDescr g_Sheet_A0;
extern Ki_PageDescr g_Sheet_A;
extern Ki_PageDescr g_Sheet_B;
extern Ki_PageDescr g_Sheet_C;
extern Ki_PageDescr g_Sheet_D;
extern Ki_PageDescr g_Sheet_E;
extern Ki_PageDescr g_Sheet_GERBER;
extern Ki_PageDescr g_Sheet_user;
extern Ki_PageDescr* g_SheetSizeList[];
extern wxString g_ProductName; 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 */
......
...@@ -10,10 +10,7 @@ ...@@ -10,10 +10,7 @@
#include <vector> #include <vector>
#include "drawtxt.h" #include "drawtxt.h"
#include "common.h" // PAGE_INFO
class Ki_PageDescr;
/** /**
* Enum PlotFormat * Enum PlotFormat
...@@ -27,6 +24,7 @@ enum PlotFormat { ...@@ -27,6 +24,7 @@ enum PlotFormat {
PLOT_FORMAT_DXF PLOT_FORMAT_DXF
}; };
class PLOTTER class PLOTTER
{ {
public: public:
...@@ -70,8 +68,8 @@ public: PLOTTER( PlotFormat aPlotType ); ...@@ -70,8 +68,8 @@ public: PLOTTER( PlotFormat aPlotType );
return color_mode; return color_mode;
} }
void SetPageSettings( const PAGE_INFO& aPageSettings );
virtual void set_paper_size( Ki_PageDescr* sheet );
virtual void set_current_line_width( int width ) = 0; virtual void set_current_line_width( int width ) = 0;
virtual void set_default_line_width( int width ) = 0; virtual void set_default_line_width( int width ) = 0;
virtual void set_color( int color ) = 0; virtual void set_color( int color ) = 0;
...@@ -226,7 +224,7 @@ protected: ...@@ -226,7 +224,7 @@ protected:
bool plotMirror; bool plotMirror;
wxString creator; wxString creator;
wxString filename; wxString filename;
Ki_PageDescr* sheet; PAGE_INFO pageInfo;
wxSize paper_size; wxSize paper_size;
}; };
......
...@@ -112,6 +112,10 @@ public: ...@@ -112,6 +112,10 @@ public:
*/ */
EDA_RECT GetBoardBoundingBox( bool aBoardEdgesOnly = false ) const; EDA_RECT GetBoardBoundingBox( bool aBoardEdgesOnly = false ) const;
void SetPageSettings( const PAGE_INFO& aPageSettings ); // overload
const PAGE_INFO& GetPageSettings() const; // overload
const wxSize GetPageSizeIU() const; // overload
/** /**
* Function SetBoard * Function SetBoard
* sets the m_Pcb member in such as way as to ensure deleting any previous * sets the m_Pcb member in such as way as to ensure deleting any previous
......
...@@ -72,7 +72,7 @@ class EDA_DRAW_PANEL; ...@@ -72,7 +72,7 @@ class EDA_DRAW_PANEL;
class EDA_MSG_PANEL; class EDA_MSG_PANEL;
class BASE_SCREEN; class BASE_SCREEN;
class PARAM_CFG_BASE; class PARAM_CFG_BASE;
class Ki_PageDescr; class PAGE_INFO;
class PLOTTER; class PLOTTER;
enum id_librarytype { enum id_librarytype {
...@@ -449,6 +449,16 @@ public: ...@@ -449,6 +449,16 @@ public:
~EDA_DRAW_FRAME(); ~EDA_DRAW_FRAME();
virtual void SetPageSettings( const PAGE_INFO& aPageSettings ) = 0;
virtual const PAGE_INFO& GetPageSettings() const = 0;
/**
* Function GetPageSizeIU
* works off of GetPageSettings() to return the size of the paper page in
* the internal units of this particular view.
*/
virtual const wxSize GetPageSizeIU() const = 0;
wxPoint GetOriginAxisPosition() const { return m_originAxisPosition; } wxPoint GetOriginAxisPosition() const { return m_originAxisPosition; }
void SetOriginAxisPosition( const wxPoint& aPosition ) { m_originAxisPosition = aPosition; } void SetOriginAxisPosition( const wxPoint& aPosition ) { m_originAxisPosition = aPosition; }
...@@ -653,13 +663,13 @@ public: ...@@ -653,13 +663,13 @@ public:
/** /**
* Function GetXYSheetReferences * Function GetXYSheetReferences
* Return the X,Y sheet references where the point position is located * returns the X,Y sheet references where the point position is located
* @param aScreen = screen to use * @param aScreen = screen to use
* @param aPosition = position to identify by YX ref * @param aPosition = position to identify by YX ref
* @return a wxString containing the message locator like A3 or B6 * @return a wxString containing the message locator like A3 or B6
* (or ?? if out of page limits) * (or ?? if out of page limits)
*/ */
wxString GetXYSheetReferences( BASE_SCREEN* aScreen, const wxPoint& aPosition ); const wxString GetXYSheetReferences( const wxPoint& aPosition );
void DisplayToolMsg( const wxString& msg ); void DisplayToolMsg( const wxString& msg );
virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) = 0; virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) = 0;
......
...@@ -125,6 +125,33 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard ) ...@@ -125,6 +125,33 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
m_Pcb = aBoard; m_Pcb = aBoard;
} }
void PCB_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
{
wxASSERT( m_Pcb );
m_Pcb->SetPageSettings( aPageSettings );
}
const PAGE_INFO& PCB_BASE_FRAME::GetPageSettings() const
{
wxASSERT( m_Pcb );
return m_Pcb->GetPageSettings();
}
const wxSize PCB_BASE_FRAME::GetPageSizeIU() const
{
wxASSERT( m_Pcb );
const PAGE_INFO& page = m_Pcb->GetPageSettings();
// convert paper size into internal units.
#if defined( KICAD_NANOMETRE )
return page.GetSizeMils() * 25400; // nanometers
#else
return page.GetSizeMils() * 10; // deci-mils
#endif
}
EDA_RECT PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const EDA_RECT PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const
{ {
...@@ -134,18 +161,17 @@ EDA_RECT PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const ...@@ -134,18 +161,17 @@ EDA_RECT PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const
if( area.GetWidth() == 0 && area.GetHeight() == 0 ) if( area.GetWidth() == 0 && area.GetHeight() == 0 )
{ {
wxSize pageSize = GetPageSizeIU();
if( m_showBorderAndTitleBlock ) if( m_showBorderAndTitleBlock )
{ {
area.SetOrigin( 0, 0 ); area.SetOrigin( 0, 0 );
area.SetEnd( GetScreen()->ReturnPageSize().x, area.SetEnd( pageSize.x, pageSize.y );
GetScreen()->ReturnPageSize().y );
} }
else else
{ {
area.SetOrigin( -GetScreen()->ReturnPageSize().x / 2, area.SetOrigin( -pageSize.x / 2, -pageSize.y / 2 );
-GetScreen()->ReturnPageSize().y / 2 ); area.SetEnd( pageSize.x / 2, pageSize.y / 2 );
area.SetEnd( GetScreen()->ReturnPageSize().x / 2,
GetScreen()->ReturnPageSize().y / 2 );
} }
} }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "class_pad.h" #include "class_pad.h"
#include "class_colors_design_settings.h" #include "class_colors_design_settings.h"
#include "class_board_design_settings.h" #include "class_board_design_settings.h"
#include "common.h" // PAGE_INFO
class PCB_BASE_FRAME; class PCB_BASE_FRAME;
class PCB_EDIT_FRAME; class PCB_EDIT_FRAME;
...@@ -27,7 +27,7 @@ class D_PAD; ...@@ -27,7 +27,7 @@ class D_PAD;
class MARKER_PCB; class MARKER_PCB;
// buffer of item candidates when search for items on the same track. // non-owning container of item candidates when searching for items on the same track.
typedef std::vector< TRACK* > TRACK_PTRS; typedef std::vector< TRACK* > TRACK_PTRS;
...@@ -174,6 +174,7 @@ private: ...@@ -174,6 +174,7 @@ private:
BOARD_DESIGN_SETTINGS m_designSettings; BOARD_DESIGN_SETTINGS m_designSettings;
COLORS_DESIGN_SETTINGS* m_colorsSettings; // Link to current colors settings COLORS_DESIGN_SETTINGS* m_colorsSettings; // Link to current colors settings
PAGE_INFO m_paper;
/** /**
* Function chainMarkedSegments * Function chainMarkedSegments
...@@ -534,15 +535,14 @@ public: ...@@ -534,15 +535,14 @@ public:
*/ */
void SetDesignSettings( const BOARD_DESIGN_SETTINGS& aDesignSettings ); void SetDesignSettings( const BOARD_DESIGN_SETTINGS& aDesignSettings );
const PAGE_INFO& GetPageSettings() const { return m_paper; }
void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; }
/** /**
* Function SetBoardSettings * Function SetBoardSettings
* @return the current COLORS_DESIGN_SETTINGS in use * @return the current COLORS_DESIGN_SETTINGS in use
*/ */
COLORS_DESIGN_SETTINGS* GetColorsSettings() const COLORS_DESIGN_SETTINGS* GetColorsSettings() const { return m_colorsSettings; }
{
return m_colorsSettings;
}
/** /**
* Function SetColorsSettings * Function SetColorsSettings
...@@ -553,7 +553,6 @@ public: ...@@ -553,7 +553,6 @@ public:
m_colorsSettings = aColorsSettings; m_colorsSettings = aColorsSettings;
} }
/** /**
* Function GetLayerName * Function GetLayerName
* returns the name of the layer given by aLayerIndex. * returns the name of the layer given by aLayerIndex.
......
...@@ -184,12 +184,9 @@ void D_PAD::ReturnStringPadName( wxString& text ) const ...@@ -184,12 +184,9 @@ void D_PAD::ReturnStringPadName( wxString& text ) const
text.Empty(); text.Empty();
for( int ii = 0; ii < PADNAMEZ; ii++ ) for( int ii = 0; ii < PADNAMEZ && m_Padname[ii]; ii++ )
{ {
if( !m_Padname[ii] ) // m_Padname is 8 bit KiCad font junk, do not sign extend
break;
// add an unsigned 8 bit byte, which is LATIN1 or CRYLIC
text.Append( (unsigned char) m_Padname[ii] ); text.Append( (unsigned char) m_Padname[ii] );
} }
#endif #endif
......
...@@ -197,9 +197,9 @@ public: ...@@ -197,9 +197,9 @@ public:
int aCircleToSegmentsCount, int aCircleToSegmentsCount,
double aCorrectionFactor ); double aCorrectionFactor );
/** /**
* Function SetDrillValue * Function SetDrill
* Set the drill value for vias * Set the drill value for vias
* @param drill_value = new drill value * @param aDrill is the new drill diameter
*/ */
void SetDrill( int aDrill ) { m_Drill = aDrill; } void SetDrill( int aDrill ) { m_Drill = aDrill; }
......
...@@ -33,7 +33,7 @@ static const double PcbZoomList[] = ...@@ -33,7 +33,7 @@ static const double PcbZoomList[] =
}; };
#define PCB_ZOOM_LIST_CNT ( sizeof( PcbZoomList ) / sizeof( PcbZoomList[0] ) ) #define PCB_ZOOM_LIST_CNT ( sizeof( PcbZoomList ) / sizeof( PcbZoomList[0] ) )
#define MM_TO_PCB_UNITS 10000.0 / 25.4 #define MM_TO_PCB_UNITS (10000.0 / 25.4)
/* Default grid sizes for PCB editor screens. */ /* Default grid sizes for PCB editor screens. */
...@@ -82,8 +82,13 @@ PCB_SCREEN::PCB_SCREEN() : BASE_SCREEN( SCREEN_T ) ...@@ -82,8 +82,13 @@ PCB_SCREEN::PCB_SCREEN() : BASE_SCREEN( SCREEN_T )
for( i = 0; i < PCB_GRID_LIST_CNT; i++ ) for( i = 0; i < PCB_GRID_LIST_CNT; i++ )
AddGrid( PcbGridList[i] ); AddGrid( PcbGridList[i] );
SetGrid( wxRealPoint( 500, 500 ) ); /* Set the working grid size to a reasonnable value (in 1/10000 inch) */ // Set the working grid size to a reasonnable value (in 1/10000 inch)
Init(); SetGrid( wxRealPoint( 500, 500 ) );
m_Active_Layer = LAYER_N_BACK; // default active layer = bottom layer
m_Route_Layer_TOP = LAYER_N_FRONT; // default layers pair for vias (bottom to top)
m_Route_Layer_BOTTOM = LAYER_N_BACK;
m_Zoom = 150; // a default value for zoom
} }
...@@ -93,17 +98,7 @@ PCB_SCREEN::~PCB_SCREEN() ...@@ -93,17 +98,7 @@ PCB_SCREEN::~PCB_SCREEN()
} }
void PCB_SCREEN::Init() int PCB_SCREEN::GetInternalUnits()
{
InitDatas();
m_Active_Layer = LAYER_N_BACK; /* default active layer = bottom layer */
m_Route_Layer_TOP = LAYER_N_FRONT; /* default layers pair for vias (bottom to top) */
m_Route_Layer_BOTTOM = LAYER_N_BACK;
m_Zoom = 150; /* a default value for zoom */
}
int PCB_SCREEN::GetInternalUnits( void )
{ {
return PCB_INTERNAL_UNIT; return PCB_INTERNAL_UNIT;
} }
......
...@@ -226,39 +226,40 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, ...@@ -226,39 +226,40 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName,
BASE_SCREEN* screen, BASE_SCREEN* screen,
bool aPrint_Frame_Ref ) bool aPrint_Frame_Ref )
{ {
// const PAGE_INFO& pageInfo = m_Parent->GetPageSettings();
LOCALE_IO toggle;
int tmpzoom; int tmpzoom;
wxPoint tmp_startvisu; wxPoint tmp_startvisu;
wxSize SheetSize; // Sheet size in internal units
wxPoint old_org; wxPoint old_org;
bool success = true; bool success = true;
/* Change frames and local settings */ // Change frames and local settings
tmp_startvisu = screen->m_StartVisu; tmp_startvisu = screen->m_StartVisu;
tmpzoom = screen->GetZoom(); tmpzoom = screen->GetZoom();
old_org = screen->m_DrawOrg; old_org = screen->m_DrawOrg;
screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0; screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0;
screen->m_StartVisu.x = screen->m_StartVisu.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->GetInternalUnits() / 1000;
SheetSize.y *= m_Parent->GetInternalUnits() / 1000; // size in pixels
screen->SetScalingFactor( 1.0 ); screen->SetScalingFactor( 1.0 );
float dpi = (float)m_Parent->GetInternalUnits(); float dpi = (float)m_Parent->GetInternalUnits();
EDA_DRAW_PANEL* panel = m_Parent->DrawPanel; EDA_DRAW_PANEL* panel = m_Parent->DrawPanel;
SetLocaleTo_C_standard(); // Switch the locale to standard C (needed // paper pageSize is in internal units, either nanometers or deci-mils
// to print floating point numbers like 1.3) wxSize pageSize = m_Parent->GetPageSizeIU();
wxSVGFileDC dc( FullFileName, SheetSize.x, SheetSize.y, dpi );
wxSVGFileDC dc( FullFileName, pageSize.x, pageSize.y, dpi );
EDA_RECT tmp = panel->m_ClipBox; EDA_RECT tmp = panel->m_ClipBox;
GRResetPenAndBrush( &dc ); GRResetPenAndBrush( &dc );
GRForceBlackPen( m_ModeColorOption->GetSelection() == 0 ? false : true ); GRForceBlackPen( m_ModeColorOption->GetSelection() == 0 ? false : true );
s_Parameters.m_DrillShapeOpt = PRINT_PARAMETERS::FULL_DRILL_SHAPE; s_Parameters.m_DrillShapeOpt = PRINT_PARAMETERS::FULL_DRILL_SHAPE;
panel->m_ClipBox.SetX( 0 ); panel->m_ClipBox.SetX( 0 );
panel->m_ClipBox.SetY( 0 ); panel->m_ClipBox.SetY( 0 );
// Set clip box to the max size // Set clip box to the max size
#define MAX_VALUE (INT_MAX/2) // MAX_VALUE is the max we can use in an integer #define MAX_VALUE (INT_MAX/2) // MAX_VALUE is the max we can use in an integer
// and that allows calculations without overflow // and that allows calculations without overflow
...@@ -275,7 +276,7 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, ...@@ -275,7 +276,7 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName,
m_Parent->PrintPage( &dc, m_PrintMaskLayer, false, &s_Parameters); m_Parent->PrintPage( &dc, m_PrintMaskLayer, false, &s_Parameters);
g_DrawBgColor = bg_color; g_DrawBgColor = bg_color;
SetLocaleTo_Default(); // revert to the current locale
screen->m_IsPrinting = false; screen->m_IsPrinting = false;
panel->m_ClipBox = tmp; panel->m_ClipBox = tmp;
......
...@@ -54,7 +54,8 @@ private: ...@@ -54,7 +54,8 @@ private:
static bool m_createRpt; // true to create a drill file report static bool m_createRpt; // true to create a drill file report
static int m_createMap; // > 0 to create a map file report static int m_createMap; // > 0 to create a map file report
public: DIALOG_GENDRILL( PCB_EDIT_FRAME* parent ); public:
DIALOG_GENDRILL( PCB_EDIT_FRAME* parent );
~DIALOG_GENDRILL(); ~DIALOG_GENDRILL();
private: private:
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
Ki_PageDescr* aSheet, const PAGE_INFO& aSheet,
std::vector<HOLE_INFO> aHoleListBuffer, std::vector<HOLE_INFO> aHoleListBuffer,
std::vector<DRILL_TOOL> aToolListBuffer, std::vector<DRILL_TOOL> aToolListBuffer,
bool aUnit_Drill_is_Inch, int format, bool aUnit_Drill_is_Inch, int format,
...@@ -37,8 +37,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, ...@@ -37,8 +37,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
wxPoint offset; wxPoint offset;
wxString msg; wxString msg;
PLOTTER* plotter = NULL; PLOTTER* plotter = NULL;
LOCALE_IO toggle; // use standard notation for float numbers
SetLocaleTo_C_standard(); // Use the standard notation for float numbers
// Calculate dimensions and center of PCB // Calculate dimensions and center of PCB
EDA_RECT bbbox = aPcb->ComputeBoundingBox(); EDA_RECT bbbox = aPcb->ComputeBoundingBox();
...@@ -58,7 +57,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, ...@@ -58,7 +57,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
plotter->set_viewport( offset, scale, 0 ); plotter->set_viewport( offset, scale, 0 );
break; break;
case PLOT_FORMAT_HPGL: /* Scale for HPGL format. */ case PLOT_FORMAT_HPGL: // Scale for HPGL format.
{ {
offset.x = 0; offset.x = 0;
offset.y = 0; offset.y = 0;
...@@ -68,29 +67,29 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, ...@@ -68,29 +67,29 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
hpgl_plotter->set_pen_number( g_PcbPlotOptions.m_HPGLPenNum ); hpgl_plotter->set_pen_number( g_PcbPlotOptions.m_HPGLPenNum );
hpgl_plotter->set_pen_speed( g_PcbPlotOptions.m_HPGLPenSpeed ); hpgl_plotter->set_pen_speed( g_PcbPlotOptions.m_HPGLPenSpeed );
hpgl_plotter->set_pen_overlap( 0 ); hpgl_plotter->set_pen_overlap( 0 );
plotter->set_paper_size( aSheet ); plotter->SetPageSettings( aSheet );
plotter->set_viewport( offset, scale, 0 ); plotter->set_viewport( offset, scale, 0 );
} }
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
{ {
Ki_PageDescr* SheetPS = &g_Sheet_A4; PAGE_INFO pageA4( wxT( "A4" ) );
wxSize SheetSize; wxSize pageSizeIU = pageA4.GetSizeIU();
SheetSize.x = SheetPS->m_Size.x * U_PCB;
SheetSize.y = SheetPS->m_Size.y * U_PCB; // Keep size for drill legend
/* Keep size for drill legend */ double Xscale = (double) ( pageSizeIU.x * 0.8 ) / dX;
double Xscale = (double) ( SheetSize.x * 0.8 ) / dX; double Yscale = (double) ( pageSizeIU.y * 0.6 ) / dY;
double Yscale = (double) ( SheetSize.y * 0.6 ) / dY;
scale = MIN( Xscale, Yscale ); scale = MIN( Xscale, Yscale );
offset.x = (int) ( (double) BoardCentre.x - ( (double) SheetSize.x / 2.0 ) / scale ); offset.x = (int) ( (double) BoardCentre.x - ( (double) pageSizeIU.x / 2.0 ) / scale );
offset.y = (int) ( (double) BoardCentre.y - ( (double) SheetSize.y / 2.0 ) / scale ); offset.y = (int) ( (double) BoardCentre.y - ( (double) pageSizeIU.y / 2.0 ) / scale );
offset.y += SheetSize.y / 8; /* offset to legend */
offset.y += pageSizeIU.y / 8; // offset to legend
PS_PLOTTER* ps_plotter = new PS_PLOTTER; PS_PLOTTER* ps_plotter = new PS_PLOTTER;
plotter = ps_plotter; plotter = ps_plotter;
ps_plotter->set_paper_size( SheetPS ); ps_plotter->SetPageSettings( pageA4 );
plotter->set_viewport( offset, scale, 0 ); plotter->set_viewport( offset, scale, 0 );
break; break;
} }
...@@ -102,7 +101,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, ...@@ -102,7 +101,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
scale = 1; scale = 1;
DXF_PLOTTER* dxf_plotter = new DXF_PLOTTER; DXF_PLOTTER* dxf_plotter = new DXF_PLOTTER;
plotter = dxf_plotter; plotter = dxf_plotter;
plotter->set_paper_size( aSheet ); plotter->SetPageSettings( aSheet );
plotter->set_viewport( offset, scale, 0 ); plotter->set_viewport( offset, scale, 0 );
break; break;
} }
...@@ -116,7 +115,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, ...@@ -116,7 +115,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
plotter->set_default_line_width( 10 ); plotter->set_default_line_width( 10 );
plotter->start_plot( aFile ); plotter->start_plot( aFile );
/* Draw items on edge layer */ // Draw items on edge layer
for( PtStruct = aPcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() ) for( PtStruct = aPcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() )
{ {
...@@ -154,19 +153,19 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, ...@@ -154,19 +153,19 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
// Plot board outlines and drill map // Plot board outlines and drill map
Gen_Drill_PcbMap( aPcb, plotter, aHoleListBuffer, aToolListBuffer ); Gen_Drill_PcbMap( aPcb, plotter, aHoleListBuffer, aToolListBuffer );
/* Print a list of symbols used. */ // Print a list of symbols used.
CharSize = 800; /* text size in 1/10000 mils */ CharSize = 800; // text size in 1/10000 mils
double CharScale = 1.0 / scale; /* real scale will be CharScale double CharScale = 1.0 / scale; /* real scale will be CharScale
* scale_x, because the global * scale_x, because the global
* plot scale is scale_x */ * plot scale is scale_x */
TextWidth = (int) ( (CharSize * CharScale) / 10 ); // Set text width (thickness) TextWidth = (int) ( (CharSize * CharScale) / 10 ); // Set text width (thickness)
intervalle = (int) ( CharSize * CharScale ) + TextWidth; intervalle = (int) ( CharSize * CharScale ) + TextWidth;
/* Trace information. */ // Trace information.
plotX = (int) ( (double) bbbox.GetX() + 200.0 * CharScale ); plotX = (int) ( (double) bbbox.GetX() + 200.0 * CharScale );
plotY = bbbox.GetBottom() + intervalle; plotY = bbbox.GetBottom() + intervalle;
/* Plot title "Info" */ // Plot title "Info"
wxString Text = wxT( "Drill Map:" ); wxString Text = wxT( "Drill Map:" );
plotter->text( wxPoint( plotX, plotY ), BLACK, Text, 0, plotter->text( wxPoint( plotX, plotY ), BLACK, Text, 0,
wxSize( (int) ( CharSize * CharScale ), wxSize( (int) ( CharSize * CharScale ),
...@@ -188,7 +187,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, ...@@ -188,7 +187,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
y = (int) ( (double) plotY + (double) CharSize * CharScale ); y = (int) ( (double) plotY + (double) CharSize * CharScale );
plotter->marker( wxPoint( x, y ), plot_diam, ii ); plotter->marker( wxPoint( x, y ), plot_diam, ii );
/* Trace the legends. */ // Trace the legends.
// List the diameter of each drill in the selected Drill Unit, // List the diameter of each drill in the selected Drill Unit,
// and then its diameter in the other Drill Unit. // and then its diameter in the other Drill Unit.
...@@ -235,7 +234,6 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, ...@@ -235,7 +234,6 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
plotter->end_plot(); plotter->end_plot();
delete plotter; delete plotter;
SetLocaleTo_Default(); // Revert to local notation for float numbers
} }
...@@ -251,7 +249,7 @@ void Gen_Drill_PcbMap( BOARD* aPcb, PLOTTER* aPlotter, ...@@ -251,7 +249,7 @@ void Gen_Drill_PcbMap( BOARD* aPcb, PLOTTER* aPlotter,
{ {
wxPoint pos; wxPoint pos;
/* create the drill list */ // create the drill list
if( aToolListBuffer.size() > 13 ) if( aToolListBuffer.size() > 13 )
{ {
DisplayInfoMessage( NULL, DisplayInfoMessage( NULL,
......
...@@ -635,7 +635,7 @@ void DIALOG_GENDRILL::GenDrillMap( const wxString aFileName, ...@@ -635,7 +635,7 @@ void DIALOG_GENDRILL::GenDrillMap( const wxString aFileName,
GenDrillMapFile( m_Parent->GetBoard(), GenDrillMapFile( m_Parent->GetBoard(),
plotfile, plotfile,
dlg.GetPath(), dlg.GetPath(),
m_Parent->GetScreen()->m_CurrentSheetDesc, m_Parent->GetPageSettings(),
s_HoleListBuffer, s_HoleListBuffer,
s_ToolListBuffer, s_ToolListBuffer,
m_UnitDrillIsInch, m_UnitDrillIsInch,
......
...@@ -217,7 +217,7 @@ void Build_Holes_List( BOARD* aPcb, std::vector<HOLE_INFO>& aHoleListBuffer, ...@@ -217,7 +217,7 @@ void Build_Holes_List( BOARD* aPcb, std::vector<HOLE_INFO>& aHoleListBuffer,
void GenDrillMapFile( BOARD* aPcb, void GenDrillMapFile( BOARD* aPcb,
FILE* aFile, FILE* aFile,
const wxString& aFullFileName, const wxString& aFullFileName,
Ki_PageDescr* aSheet, const PAGE_INFO& aSheet,
std::vector<HOLE_INFO> aHoleListBuffer, std::vector<HOLE_INFO> aHoleListBuffer,
std::vector<DRILL_TOOL> aToolListBuffer, std::vector<DRILL_TOOL> aToolListBuffer,
bool aUnit_Drill_is_Inch, bool aUnit_Drill_is_Inch,
......
...@@ -42,21 +42,22 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery ) ...@@ -42,21 +42,22 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery )
SetBoard( new BOARD() ); SetBoard( new BOARD() );
SetCurItem( NULL ); SetCurItem( NULL );
/* clear filename, to avoid overwriting an old file */ // clear filename, to avoid overwriting an old file
GetScreen()->GetFileName().Empty(); GetScreen()->GetFileName().Empty();
/* Init new grid size */ // preserve grid size accross call to InitDataPoints()
wxRealPoint gridsize = GetScreen()->GetGridSize();
GetScreen()->Init(); // wxRealPoint gridsize = GetScreen()->GetGridSize();
GetScreen()->SetGrid( gridsize ); GetScreen()->InitDataPoints( GetPageSizeIU() );
// GetScreen()->SetGrid( gridsize );
GetBoard()->ResetHighLight(); GetBoard()->ResetHighLight();
// Enable all layers (SetCopperLayerCount() will adjust the copper layers enabled) // Enable all layers (SetCopperLayerCount() will adjust the copper layers enabled)
GetBoard()->SetEnabledLayers(ALL_LAYERS); GetBoard()->SetEnabledLayers( ALL_LAYERS );
// Default copper layers count set to 2: double layer board // Default copper layers count set to 2: double layer board
GetBoard()->SetCopperLayerCount(2); GetBoard()->SetCopperLayerCount( 2 );
// Update display: // Update display:
GetBoard()->SetVisibleLayers( ALL_LAYERS ); GetBoard()->SetVisibleLayers( ALL_LAYERS );
...@@ -91,15 +92,15 @@ bool FOOTPRINT_EDIT_FRAME::Clear_Pcb( bool aQuery ) ...@@ -91,15 +92,15 @@ bool FOOTPRINT_EDIT_FRAME::Clear_Pcb( bool aQuery )
// Delete the current footprint // Delete the current footprint
GetBoard()->m_Modules.DeleteAll(); GetBoard()->m_Modules.DeleteAll();
/* init pointeurs et variables */ // init pointeurs et variables
GetScreen()->GetFileName().Empty(); GetScreen()->GetFileName().Empty();
SetCurItem( NULL ); SetCurItem( NULL );
/* Init parametres de gestion */ // preserve grid size accross call to InitDataPoints()
wxRealPoint gridsize = GetScreen()->GetGridSize(); // wxRealPoint gridsize = GetScreen()->GetGridSize();
GetScreen()->Init(); GetScreen()->InitDataPoints( GetPageSizeIU() );
GetScreen()->SetGrid( gridsize ); // GetScreen()->SetGrid( gridsize );
Zoom_Automatique( false ); Zoom_Automatique( false );
......
...@@ -119,6 +119,8 @@ public: ...@@ -119,6 +119,8 @@ public:
* implementation knows about, or it can be used to write a portion of * implementation knows about, or it can be used to write a portion of
* aBoard to a special kind of export file. * aBoard to a special kind of export file.
* *
* @param aFileType is the PCB_FILE_T of file to save.
*
* @param aFileName is the name of a file to save to on disk. * @param aFileName is the name of a file to save to on disk.
* @param aBoard is the BOARD document (data tree) to save or export to disk. * @param aBoard is the BOARD document (data tree) to save or export to disk.
* *
......
...@@ -786,7 +786,7 @@ bool PCB_EDIT_FRAME::WriteGeneralDescrPcb( FILE* File ) ...@@ -786,7 +786,7 @@ bool PCB_EDIT_FRAME::WriteGeneralDescrPcb( FILE* File )
EDA_ITEM* PtStruct = GetBoard()->m_Modules; EDA_ITEM* PtStruct = GetBoard()->m_Modules;
int NbModules, NbDrawItem, NbLayers; int NbModules, NbDrawItem, NbLayers;
/* Write copper layer count */ // Write copper layer count
NbLayers = GetBoard()->GetCopperLayerCount(); NbLayers = GetBoard()->GetCopperLayerCount();
fprintf( File, "$GENERAL\n" ); fprintf( File, "$GENERAL\n" );
fprintf( File, "encoding utf-8\n"); fprintf( File, "encoding utf-8\n");
...@@ -801,7 +801,7 @@ bool PCB_EDIT_FRAME::WriteGeneralDescrPcb( FILE* File ) ...@@ -801,7 +801,7 @@ bool PCB_EDIT_FRAME::WriteGeneralDescrPcb( FILE* File )
fprintf( File, "Links %d\n", GetBoard()->GetRatsnestsCount() ); fprintf( File, "Links %d\n", GetBoard()->GetRatsnestsCount() );
fprintf( File, "NoConn %d\n", GetBoard()->m_NbNoconnect ); fprintf( File, "NoConn %d\n", GetBoard()->m_NbNoconnect );
// Write Bounding box info // Write board's bounding box info
EDA_RECT bbbox = GetBoard()->ComputeBoundingBox(); EDA_RECT bbbox = GetBoard()->ComputeBoundingBox();
fprintf( File, "Di %d %d %d %d\n", fprintf( File, "Di %d %d %d %d\n",
bbbox.GetX(), bbbox.GetX(),
...@@ -809,8 +809,8 @@ bool PCB_EDIT_FRAME::WriteGeneralDescrPcb( FILE* File ) ...@@ -809,8 +809,8 @@ bool PCB_EDIT_FRAME::WriteGeneralDescrPcb( FILE* File )
bbbox.GetRight(), bbbox.GetRight(),
bbbox.GetBottom() ); bbbox.GetBottom() );
/* Write segment count for footprints, drawings, track and zones */ // Write segment count for footprints, drawings, track and zones
/* Calculate the footprint count */ // Calculate the footprint count
for( NbModules = 0; PtStruct != NULL; PtStruct = PtStruct->Next() ) for( NbModules = 0; PtStruct != NULL; PtStruct = PtStruct->Next() )
NbModules++; NbModules++;
...@@ -836,13 +836,14 @@ bool PCB_EDIT_FRAME::WriteGeneralDescrPcb( FILE* File ) ...@@ -836,13 +836,14 @@ bool PCB_EDIT_FRAME::WriteGeneralDescrPcb( FILE* File )
* @param screen BASE_SCREEN to save * @param screen BASE_SCREEN to save
* @param File = an open FILE to write info * @param File = an open FILE to write info
*/ */
bool WriteSheetDescr( BASE_SCREEN* screen, FILE* File ) static bool WriteSheetDescr( const PAGE_INFO& aPageSettings, BASE_SCREEN* screen, FILE* File )
{ {
Ki_PageDescr* sheet = screen->m_CurrentSheetDesc;
fprintf( File, "$SHEETDESCR\n" ); fprintf( File, "$SHEETDESCR\n" );
fprintf( File, "Sheet %s %d %d\n", fprintf( File, "Sheet %s %d %d\n",
TO_UTF8( sheet->m_Name ), sheet->m_Size.x, sheet->m_Size.y ); TO_UTF8( aPageSettings.GetType() ),
aPageSettings.GetSizeMils().x,
aPageSettings.GetSizeMils().y );
fprintf( File, "Title %s\n", EscapedUTF8( screen->m_Title ).c_str() ); fprintf( File, "Title %s\n", EscapedUTF8( screen->m_Title ).c_str() );
fprintf( File, "Date %s\n", EscapedUTF8( screen->m_Date ).c_str() ); fprintf( File, "Date %s\n", EscapedUTF8( screen->m_Date ).c_str() );
fprintf( File, "Rev %s\n", EscapedUTF8( screen->m_Revision ).c_str() ); fprintf( File, "Rev %s\n", EscapedUTF8( screen->m_Revision ).c_str() );
...@@ -859,7 +860,7 @@ bool WriteSheetDescr( BASE_SCREEN* screen, FILE* File ) ...@@ -859,7 +860,7 @@ bool WriteSheetDescr( BASE_SCREEN* screen, FILE* File )
#if !defined( USE_NEW_PCBNEW_LOAD ) #if !defined( USE_NEW_PCBNEW_LOAD )
static bool ReadSheetDescr( BASE_SCREEN* screen, LINE_READER* aReader ) static bool ReadSheetDescr( BOARD* aBoard, BASE_SCREEN* screen, LINE_READER* aReader )
{ {
char buf[1024]; char buf[1024];
char* text; char* text;
...@@ -873,32 +874,41 @@ static bool ReadSheetDescr( BASE_SCREEN* screen, LINE_READER* aReader ) ...@@ -873,32 +874,41 @@ static bool ReadSheetDescr( BASE_SCREEN* screen, LINE_READER* aReader )
if( strnicmp( line, "Sheet", 4 ) == 0 ) if( strnicmp( line, "Sheet", 4 ) == 0 )
{ {
text = strtok( line, " \t\n\r" ); // e.g. "Sheet A3 16535 11700"
text = strtok( NULL, " \t\n\r" ); // width and height are in 1/1000th of an inch, always
Ki_PageDescr* sheet = g_SheetSizeList[0];
int ii; PAGE_INFO page;
char* sname = strtok( line + SZ( "Sheet" ), delims );
for( ii = 0; sheet != NULL; ii++, sheet = g_SheetSizeList[ii] ) if( sname )
{ {
if( stricmp( TO_UTF8( sheet->m_Name ), text ) == 0 ) wxString wname = FROM_UTF8( sname );
if( !page.SetType( wname ) )
{ {
screen->m_CurrentSheetDesc = sheet; m_error.Printf( _( "Unknown sheet type '%s' on line:%d" ),
wname.GetData(), m_reader->LineNumber() );
THROW_IO_ERROR( m_error );
}
if( sheet == &g_Sheet_user ) // only parse the width and height if page size is "User"
if( wname == wxT( "User" ) )
{ {
text = strtok( NULL, " \t\n\r" ); char* width = strtok( line, delims );
char* height = strtok( line, delims );
if( text )
sheet->m_Size.x = atoi( text );
text = strtok( NULL, " \t\n\r" ); if( width && height )
{
// legacy disk file describes paper in mils
// (1/1000th of an inch)
int w = intParse( width );
int h = intParse( height );
if( text ) page.SetWidthInches( w / 1000.0 );
sheet->m_Size.y = atoi( text ); page.SetHeightInches( h / 1000.0 );
} }
break;
} }
aBoard->SetPageSettings( page );
} }
continue; continue;
...@@ -1098,7 +1108,7 @@ int PCB_EDIT_FRAME::ReadPcbFile( LINE_READER* aReader, bool Append ) ...@@ -1098,7 +1108,7 @@ int PCB_EDIT_FRAME::ReadPcbFile( LINE_READER* aReader, bool Append )
if( TESTLINE( "SHEETDESCR" ) ) if( TESTLINE( "SHEETDESCR" ) )
{ {
ReadSheetDescr( GetScreen(), aReader ); ReadSheetDescr( board, GetScreen(), aReader );
continue; continue;
} }
...@@ -1162,7 +1172,7 @@ int PCB_EDIT_FRAME::SavePcbFormatAscii( FILE* aFile ) ...@@ -1162,7 +1172,7 @@ int PCB_EDIT_FRAME::SavePcbFormatAscii( FILE* aFile )
// like 1.3) // like 1.3)
LOCALE_IO toggle; LOCALE_IO toggle;
/* Writing file header. */ // Writing file header.
fprintf( aFile, "PCBNEW-BOARD Version %d date %s\n\n", BOARD_FILE_VERSION, fprintf( aFile, "PCBNEW-BOARD Version %d date %s\n\n", BOARD_FILE_VERSION,
TO_UTF8( DateAndTime() ) ); TO_UTF8( DateAndTime() ) );
fprintf( aFile, "# Created by Pcbnew%s\n\n", TO_UTF8( GetBuildVersion() ) ); fprintf( aFile, "# Created by Pcbnew%s\n\n", TO_UTF8( GetBuildVersion() ) );
...@@ -1174,7 +1184,7 @@ int PCB_EDIT_FRAME::SavePcbFormatAscii( FILE* aFile ) ...@@ -1174,7 +1184,7 @@ int PCB_EDIT_FRAME::SavePcbFormatAscii( FILE* aFile )
GetBoard()->SetCurrentNetClass( GetBoard()->m_NetClasses.GetDefault()->GetName() ); GetBoard()->SetCurrentNetClass( GetBoard()->m_NetClasses.GetDefault()->GetName() );
WriteGeneralDescrPcb( aFile ); WriteGeneralDescrPcb( aFile );
WriteSheetDescr( GetScreen(), aFile ); WriteSheetDescr( GetBoard()->GetPageSettings(), GetScreen(), aFile );
WriteSetup( aFile, this, GetBoard() ); WriteSetup( aFile, this, GetBoard() );
rc = GetBoard()->Save( aFile ); rc = GetBoard()->Save( aFile );
......
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
/// C string compare test for a specific length of characters. /// C string compare test for a specific length of characters.
/// The -1 is to omit the trailing \0 which is included in sizeof() on a /// The -1 is to omit the trailing \0 which is included in sizeof() on a
/// string constant. /// string constant.
#define TESTLINE( x ) (strncmp( line, x, sizeof(x) - 1 ) == 0) #define TESTLINE( x ) (strnicmp( line, x, sizeof(x)-1 ) == 0)
/// Get the length of a string constant, at compile time /// Get the length of a string constant, at compile time
#define SZ( x ) (sizeof(x)-1) #define SZ( x ) (sizeof(x)-1)
...@@ -440,7 +440,6 @@ void KICAD_PLUGIN::loadGENERAL() ...@@ -440,7 +440,6 @@ void KICAD_PLUGIN::loadGENERAL()
void KICAD_PLUGIN::loadSHEET() void KICAD_PLUGIN::loadSHEET()
{ {
char buf[260]; char buf[260];
char* text;
while( READLINE() ) while( READLINE() )
{ {
...@@ -448,33 +447,41 @@ void KICAD_PLUGIN::loadSHEET() ...@@ -448,33 +447,41 @@ void KICAD_PLUGIN::loadSHEET()
if( TESTLINE( "Sheet" ) ) if( TESTLINE( "Sheet" ) )
{ {
text = strtok( line, delims ); // e.g. "Sheet A3 16535 11700"
text = strtok( NULL, delims ); // width and height are in 1/1000th of an inch, always
Ki_PageDescr* sheet = g_SheetSizeList[0]; PAGE_INFO page;
int ii; char* sname = strtok( line + SZ( "Sheet" ), delims );
for( ii = 0; sheet != NULL; ii++, sheet = g_SheetSizeList[ii] ) if( sname )
{ {
if( !stricmp( TO_UTF8( sheet->m_Name ), text ) ) wxString wname = FROM_UTF8( sname );
if( !page.SetType( wname ) )
{ {
// @todo screen->m_CurrentSheetDesc = sheet; m_error.Printf( _( "Unknown sheet type '%s' on line:%d" ),
wname.GetData(), m_reader->LineNumber() );
THROW_IO_ERROR( m_error );
}
if( sheet == &g_Sheet_user ) // only parse the width and height if page size is "User"
if( wname == wxT( "User" ) )
{ {
text = strtok( NULL, delims ); char* width = strtok( line, delims );
char* height = strtok( line, delims );
if( text ) if( width && height )
sheet->m_Size.x = intParse( text ); {
// legacy disk file describes paper in mils
text = strtok( NULL, delims ); // (1/1000th of an inch)
int w = intParse( width );
int h = intParse( height );
if( text ) page.SetWidthInches( w / 1000.0 );
sheet->m_Size.y = intParse( text ); page.SetHeightInches( h / 1000.0 );
} }
break;
} }
m_board->SetPageSettings( page );
} }
} }
...@@ -2727,14 +2734,17 @@ void KICAD_PLUGIN::saveGENERAL() const ...@@ -2727,14 +2734,17 @@ void KICAD_PLUGIN::saveGENERAL() const
void KICAD_PLUGIN::saveSHEET() const void KICAD_PLUGIN::saveSHEET() const
{ {
#if 0 // @todo sheet not available here. The sheet needs to go into the board if it is important enough to be saved with the board const PAGE_INFO& pageInfo = m_board->GetPageSettings();
Ki_PageDescr* sheet = screen->m_CurrentSheetDesc;
fprintf( m_fp, "$SHEETDESCR\n" ); fprintf( m_fp, "$SHEETDESCR\n" );
// paper is described in mils
fprintf( m_fp, "Sheet %s %d %d\n", fprintf( m_fp, "Sheet %s %d %d\n",
TO_UTF8( sheet->m_Name ), sheet->m_Size.x, sheet->m_Size.y ); // in mm ? TO_UTF8( pageInfo.GetType() ),
pageInfo.GetSizeMils().x,
pageInfo.GetSizeMils().y );
#if 0 // @todo sheet not available here. The sheet needs to go into the board if it is important enough to be saved with the board
fprintf( m_fp, "Title %s\n", EscapedUTF8( screen->m_Title ).c_str() ); fprintf( m_fp, "Title %s\n", EscapedUTF8( screen->m_Title ).c_str() );
fprintf( m_fp, "Date %s\n", EscapedUTF8( screen->m_Date ).c_str() ); fprintf( m_fp, "Date %s\n", EscapedUTF8( screen->m_Date ).c_str() );
fprintf( m_fp, "Rev %s\n", EscapedUTF8( screen->m_Revision ).c_str() ); fprintf( m_fp, "Rev %s\n", EscapedUTF8( screen->m_Revision ).c_str() );
...@@ -2744,8 +2754,9 @@ void KICAD_PLUGIN::saveSHEET() const ...@@ -2744,8 +2754,9 @@ void KICAD_PLUGIN::saveSHEET() const
fprintf( m_fp, "Comment3 %s\n", EscapedUTF8( screen->m_Commentaire3 ).c_str() ); fprintf( m_fp, "Comment3 %s\n", EscapedUTF8( screen->m_Commentaire3 ).c_str() );
fprintf( m_fp, "Comment4 %s\n", EscapedUTF8( screen->m_Commentaire4 ).c_str() ); fprintf( m_fp, "Comment4 %s\n", EscapedUTF8( screen->m_Commentaire4 ).c_str() );
fprintf( m_fp, "$EndSHEETDESCR\n\n" );
#endif #endif
fprintf( m_fp, "$EndSHEETDESCR\n\n" );
} }
...@@ -3077,26 +3088,29 @@ void KICAD_PLUGIN::savePAD( const D_PAD* me ) const ...@@ -3077,26 +3088,29 @@ void KICAD_PLUGIN::savePAD( const D_PAD* me ) const
THROW_IO_ERROR( wxString::Format( UNKNOWN_PAD_FORMAT, me->GetShape() ) ); THROW_IO_ERROR( wxString::Format( UNKNOWN_PAD_FORMAT, me->GetShape() ) );
} }
// universal character set padname #if BOARD_FORMAT_VERSION == 1 // saving mode is a compile time option
wxString padname = me->GetPadName();
#if BOARD_FORMAT_VERSION == 1 wxString wpadname = me->GetPadName(); // universal character set padname
std::string spadname;
char mypadname[PADNAMEZ+1]; for( unsigned i = 0; wpadname.size(); ++i )
int i;
for( i = 0; i<PADNAMEZ && padname[i]; ++i )
{ {
// truncate from universal character down to 8 bit foreign jibber jabber byte // truncate from universal character down to 8 bit foreign jibber
mypadname[i] = (char) padname[i]; // jabber byte. This basically duplicates what was done in the old
// BOARD_FORMAT_VERSION 1 code. Any characters that were in the 8 bit
// character space were OK.
spadname += (char) wpadname[i];
} }
mypadname[i] = 0;
fprintf( m_fp, "Sh \"%s\" %c %s %s %s\n", fprintf( m_fp, "Sh \"%s\" %c %s %s %s\n",
mypadname, // probably ASCII, but possibly jibber jabber spadname.c_str(), // probably ASCII, but possibly jibber jabber
#else #else
fprintf( m_fp, "Sh %s %c %s %s %s\n", fprintf( m_fp, "Sh %s %c %s %s %s\n",
// legacy VERSION 2 simply uses UTF8, wrapped in quotes,
// and 99.99 % of the time there is no difference between 1 & 2,
// since ASCII is a subset of UTF8. But if they were not using
// ASCII pad names, then there is a difference in the file.
EscapedUTF8( me->GetPadName() ).c_str(), EscapedUTF8( me->GetPadName() ).c_str(),
#endif #endif
cshape, cshape,
......
...@@ -70,7 +70,7 @@ private: ...@@ -70,7 +70,7 @@ private:
* updates d so that the values are correct (goes through target's * updates d so that the values are correct (goes through target's
* neighbours making sure that the distances between them and the tree * neighbours making sure that the distances between them and the tree
* are indeed minimum) * are indeed minimum)
* @param target = index of curr item * @param aTarget = index of curr item
*/ */
void updateDistances( int aTarget ); void updateDistances( int aTarget );
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
bool PCB_BASE_FRAME::ExportToDxfFile( const wxString& aFullFileName, int aLayer, bool PCB_BASE_FRAME::ExportToDxfFile( const wxString& aFullFileName, int aLayer,
GRTraceMode aTraceMode ) GRTraceMode aTraceMode )
{ {
Ki_PageDescr* currentsheet = GetScreen()->m_CurrentSheetDesc; LOCALE_IO toggle;
FILE* output_file = wxFopen( aFullFileName, wxT( "wt" ) ); FILE* output_file = wxFopen( aFullFileName, wxT( "wt" ) );
...@@ -27,10 +27,8 @@ bool PCB_BASE_FRAME::ExportToDxfFile( const wxString& aFullFileName, int aLayer, ...@@ -27,10 +27,8 @@ bool PCB_BASE_FRAME::ExportToDxfFile( const wxString& aFullFileName, int aLayer,
return false; return false;
} }
SetLocaleTo_C_standard();
DXF_PLOTTER* plotter = new DXF_PLOTTER(); DXF_PLOTTER* plotter = new DXF_PLOTTER();
plotter->set_paper_size( currentsheet ); plotter->SetPageSettings( GetPageSettings() );
plotter->set_viewport( wxPoint( 0, 0 ), 1, 0 ); plotter->set_viewport( wxPoint( 0, 0 ), 1, 0 );
plotter->set_creator( wxT( "PCBNEW-DXF" ) ); plotter->set_creator( wxT( "PCBNEW-DXF" ) );
plotter->set_filename( aFullFileName ); plotter->set_filename( aFullFileName );
...@@ -42,7 +40,5 @@ bool PCB_BASE_FRAME::ExportToDxfFile( const wxString& aFullFileName, int aLayer, ...@@ -42,7 +40,5 @@ bool PCB_BASE_FRAME::ExportToDxfFile( const wxString& aFullFileName, int aLayer,
Plot_Layer( plotter, aLayer, aTraceMode ); Plot_Layer( plotter, aLayer, aTraceMode );
plotter->end_plot(); plotter->end_plot();
delete plotter; delete plotter;
SetLocaleTo_Default();
return true; return true;
} }
...@@ -20,13 +20,12 @@ ...@@ -20,13 +20,12 @@
bool PCB_BASE_FRAME::ExportToHpglFile( const wxString& aFullFileName, int aLayer, bool PCB_BASE_FRAME::ExportToHpglFile( const wxString& aFullFileName, int aLayer,
GRTraceMode aTraceMode ) GRTraceMode aTraceMode )
{ {
wxSize SheetSize; wxSize boardSize;
wxSize BoardSize; wxPoint boardCenter;
wxPoint BoardCenter; bool center = false;
bool Center = false;
Ki_PageDescr* currentsheet = GetScreen()->m_CurrentSheetDesc;
double scale; double scale;
wxPoint offset; wxPoint offset;
LOCALE_IO toggle;
FILE* output_file = wxFopen( aFullFileName, wxT( "wt" ) ); FILE* output_file = wxFopen( aFullFileName, wxT( "wt" ) );
...@@ -52,29 +51,26 @@ bool PCB_BASE_FRAME::ExportToHpglFile( const wxString& aFullFileName, int aLayer ...@@ -52,29 +51,26 @@ bool PCB_BASE_FRAME::ExportToHpglFile( const wxString& aFullFileName, int aLayer
g_PcbPlotOptions.m_PlotScale ); g_PcbPlotOptions.m_PlotScale );
SetLocaleTo_C_standard();
if( g_PcbPlotOptions.m_PlotScale != 1.0 || g_PcbPlotOptions.m_AutoScale ) if( g_PcbPlotOptions.m_PlotScale != 1.0 || g_PcbPlotOptions.m_AutoScale )
Center = true; // when scale != 1.0 we must calculate the position in page {
// when scale != 1.0 we must calculate the position in page
// because actual position has no meaning // because actual position has no meaning
center = true;
}
// Scale units from 0.0001" to HPGL plot units. wxSize pageSizeIU = GetPageSizeIU();
SheetSize.x = currentsheet->m_Size.x * U_PCB;
SheetSize.y = currentsheet->m_Size.y * U_PCB;
// Calculate the center of the PCB // Calculate the center of the PCB
EDA_RECT bbbox = GetBoardBoundingBox(); EDA_RECT bbbox = GetBoardBoundingBox();
BoardSize = bbbox.GetSize(); boardSize = bbbox.GetSize();
BoardCenter = bbbox.Centre(); boardCenter = bbbox.Centre();
if( g_PcbPlotOptions.m_AutoScale ) // Optimum scale if( g_PcbPlotOptions.m_AutoScale ) // Optimum scale
{ {
double Xscale, Yscale;
// Fit to 80% of the page // Fit to 80% of the page
Xscale = ( ( SheetSize.x * 0.8 ) / BoardSize.x ); double Xscale = ( ( pageSizeIU.x * 0.8 ) / boardSize.x );
Yscale = ( ( SheetSize.y * 0.8 ) / BoardSize.y ); double Yscale = ( ( pageSizeIU.y * 0.8 ) / boardSize.y );
scale = MIN( Xscale, Yscale ); scale = MIN( Xscale, Yscale );
} }
else else
...@@ -83,12 +79,12 @@ bool PCB_BASE_FRAME::ExportToHpglFile( const wxString& aFullFileName, int aLayer ...@@ -83,12 +79,12 @@ bool PCB_BASE_FRAME::ExportToHpglFile( const wxString& aFullFileName, int aLayer
} }
// Calculate the page size offset. // Calculate the page size offset.
if( Center ) if( center )
{ {
offset.x = wxRound( (double) BoardCenter.x - offset.x = wxRound( (double) boardCenter.x -
( (double) SheetSize.x / 2.0 ) / scale ); ( (double) pageSizeIU.x / 2.0 ) / scale );
offset.y = wxRound( (double) BoardCenter.y - offset.y = wxRound( (double) boardCenter.y -
( (double) SheetSize.y / 2.0 ) / scale ); ( (double) pageSizeIU.y / 2.0 ) / scale );
} }
else else
{ {
...@@ -97,7 +93,9 @@ bool PCB_BASE_FRAME::ExportToHpglFile( const wxString& aFullFileName, int aLayer ...@@ -97,7 +93,9 @@ bool PCB_BASE_FRAME::ExportToHpglFile( const wxString& aFullFileName, int aLayer
} }
HPGL_PLOTTER* plotter = new HPGL_PLOTTER(); HPGL_PLOTTER* plotter = new HPGL_PLOTTER();
plotter->set_paper_size( currentsheet );
plotter->SetPageSettings( GetPageSettings() );
plotter->set_viewport( offset, scale, g_PcbPlotOptions.m_PlotMirror ); plotter->set_viewport( offset, scale, g_PcbPlotOptions.m_PlotMirror );
plotter->set_default_line_width( g_PcbPlotOptions.m_PlotLineWidth ); plotter->set_default_line_width( g_PcbPlotOptions.m_PlotLineWidth );
plotter->set_creator( wxT( "PCBNEW-HPGL" ) ); plotter->set_creator( wxT( "PCBNEW-HPGL" ) );
...@@ -108,14 +106,13 @@ bool PCB_BASE_FRAME::ExportToHpglFile( const wxString& aFullFileName, int aLayer ...@@ -108,14 +106,13 @@ bool PCB_BASE_FRAME::ExportToHpglFile( const wxString& aFullFileName, int aLayer
plotter->set_pen_diameter( pen_diam ); plotter->set_pen_diameter( pen_diam );
plotter->start_plot( output_file ); plotter->start_plot( output_file );
/* The worksheet is not significant with scale!=1... It is with paperscale!=1, anyway */ // The worksheet is not significant with scale!=1... It is with paperscale!=1, anyway
if( g_PcbPlotOptions.m_PlotFrameRef && !Center ) if( g_PcbPlotOptions.m_PlotFrameRef && !center )
PlotWorkSheet( plotter, GetScreen() ); PlotWorkSheet( plotter, GetScreen() );
Plot_Layer( plotter, aLayer, aTraceMode ); Plot_Layer( plotter, aLayer, aTraceMode );
plotter->end_plot(); plotter->end_plot();
delete plotter; delete plotter;
SetLocaleTo_Default();
return true; return true;
} }
...@@ -24,15 +24,19 @@ ...@@ -24,15 +24,19 @@
bool PCB_BASE_FRAME::ExportToPostScriptFile( const wxString& aFullFileName, int aLayer, bool PCB_BASE_FRAME::ExportToPostScriptFile( const wxString& aFullFileName, int aLayer,
bool aUseA4, GRTraceMode aTraceMode ) bool aUseA4, GRTraceMode aTraceMode )
{ {
wxSize SheetSize; const PAGE_INFO& pageInfo = GetPageSettings();
wxSize PaperSize;
wxSize BoardSize; wxSize paperSizeIU;
wxPoint BoardCenter; wxSize boardSize;
bool Center = false; wxPoint boardCenter;
Ki_PageDescr* currentsheet = GetScreen()->m_CurrentSheetDesc; bool center = false;
double scale, paperscale; double scale;
Ki_PageDescr* SheetPS; double paperscale;
wxPoint offset; wxPoint offset;
LOCALE_IO toggle;
PAGE_INFO pageA4( wxT( "A4" ) );
const PAGE_INFO* sheetPS;
FILE* output_file = wxFopen( aFullFileName, wxT( "wt" ) ); FILE* output_file = wxFopen( aFullFileName, wxT( "wt" ) );
...@@ -41,45 +45,43 @@ bool PCB_BASE_FRAME::ExportToPostScriptFile( const wxString& aFullFileName, int ...@@ -41,45 +45,43 @@ bool PCB_BASE_FRAME::ExportToPostScriptFile( const wxString& aFullFileName, int
return false; return false;
} }
SetLocaleTo_C_standard();
if( g_PcbPlotOptions.m_PlotScale != 1.0 || g_PcbPlotOptions.m_AutoScale ) if( g_PcbPlotOptions.m_PlotScale != 1.0 || g_PcbPlotOptions.m_AutoScale )
Center = true; // when scale != 1.0 we must calculate the position in page {
// when scale != 1.0 we must calculate the position in page
// because actual position has no meaning // because actual position has no meaning
center = true;
}
// Set default line width // Set default line width
if( g_PcbPlotOptions.m_PlotLineWidth < 1 ) if( g_PcbPlotOptions.m_PlotLineWidth < 1 )
g_PcbPlotOptions.m_PlotLineWidth = 1; g_PcbPlotOptions.m_PlotLineWidth = 1;
SheetSize.x = currentsheet->m_Size.x * U_PCB; wxSize pageSizeIU = GetPageSizeIU();
SheetSize.y = currentsheet->m_Size.y * U_PCB;
if( aUseA4 ) if( aUseA4 )
{ {
SheetPS = &g_Sheet_A4; sheetPS = &pageA4;
PaperSize.x = g_Sheet_A4.m_Size.x * U_PCB; paperSizeIU = pageA4.GetSizeIU();
PaperSize.y = g_Sheet_A4.m_Size.y * U_PCB; paperscale = (double) paperSizeIU.x / pageSizeIU.x;
paperscale = (float) PaperSize.x / SheetSize.x;
} }
else else
{ {
SheetPS = currentsheet; sheetPS = &pageInfo;
PaperSize = SheetSize; paperSizeIU = pageSizeIU;
paperscale = 1; paperscale = 1;
} }
EDA_RECT bbbox = GetBoardBoundingBox(); EDA_RECT bbbox = GetBoardBoundingBox();
BoardSize = bbbox.GetSize(); boardSize = bbbox.GetSize();
BoardCenter = bbbox.Centre(); boardCenter = bbbox.Centre();
if( g_PcbPlotOptions.m_AutoScale ) // Optimum scale if( g_PcbPlotOptions.m_AutoScale ) // Optimum scale
{ {
double Xscale, Yscale;
// Fit to 80% of the page // Fit to 80% of the page
Xscale = (PaperSize.x * 0.8) / BoardSize.x; double Xscale = (paperSizeIU.x * 0.8) / boardSize.x;
Yscale = (PaperSize.y * 0.8) / BoardSize.y; double Yscale = (paperSizeIU.y * 0.8) / boardSize.y;
scale = MIN( Xscale, Yscale ); scale = MIN( Xscale, Yscale );
} }
else else
...@@ -87,10 +89,10 @@ bool PCB_BASE_FRAME::ExportToPostScriptFile( const wxString& aFullFileName, int ...@@ -87,10 +89,10 @@ bool PCB_BASE_FRAME::ExportToPostScriptFile( const wxString& aFullFileName, int
scale = g_PcbPlotOptions.m_PlotScale * paperscale; scale = g_PcbPlotOptions.m_PlotScale * paperscale;
} }
if( Center ) if( center )
{ {
offset.x = wxRound( (double) BoardCenter.x - ( (double) PaperSize.x / 2.0 ) / scale ); offset.x = wxRound( (double) boardCenter.x - ( (double) paperSizeIU.x / 2.0 ) / scale );
offset.y = wxRound( (double) BoardCenter.y - ( (double) PaperSize.y / 2.0 ) / scale ); offset.y = wxRound( (double) boardCenter.y - ( (double) paperSizeIU.y / 2.0 ) / scale );
} }
else else
{ {
...@@ -99,7 +101,9 @@ bool PCB_BASE_FRAME::ExportToPostScriptFile( const wxString& aFullFileName, int ...@@ -99,7 +101,9 @@ bool PCB_BASE_FRAME::ExportToPostScriptFile( const wxString& aFullFileName, int
} }
PS_PLOTTER* plotter = new PS_PLOTTER(); PS_PLOTTER* plotter = new PS_PLOTTER();
plotter->set_paper_size( SheetPS );
plotter->SetPageSettings( *sheetPS );
plotter->set_scale_adjust( g_PcbPlotOptions.m_FineScaleAdjustX, plotter->set_scale_adjust( g_PcbPlotOptions.m_FineScaleAdjustX,
g_PcbPlotOptions.m_FineScaleAdjustY ); g_PcbPlotOptions.m_FineScaleAdjustY );
plotter->set_viewport( offset, scale, g_PcbPlotOptions.m_PlotMirror ); plotter->set_viewport( offset, scale, g_PcbPlotOptions.m_PlotMirror );
...@@ -109,7 +113,7 @@ bool PCB_BASE_FRAME::ExportToPostScriptFile( const wxString& aFullFileName, int ...@@ -109,7 +113,7 @@ bool PCB_BASE_FRAME::ExportToPostScriptFile( const wxString& aFullFileName, int
plotter->start_plot( output_file ); plotter->start_plot( output_file );
/* The worksheet is not significant with scale!=1... It is with paperscale!=1, anyway */ /* The worksheet is not significant with scale!=1... It is with paperscale!=1, anyway */
if( g_PcbPlotOptions.m_PlotFrameRef && !Center ) if( g_PcbPlotOptions.m_PlotFrameRef && !center )
PlotWorkSheet( plotter, GetScreen() ); PlotWorkSheet( plotter, GetScreen() );
// If plot a negative board: // If plot a negative board:
...@@ -131,7 +135,6 @@ bool PCB_BASE_FRAME::ExportToPostScriptFile( const wxString& aFullFileName, int ...@@ -131,7 +135,6 @@ bool PCB_BASE_FRAME::ExportToPostScriptFile( const wxString& aFullFileName, int
Plot_Layer( plotter, aLayer, aTraceMode ); Plot_Layer( plotter, aLayer, aTraceMode );
plotter->end_plot(); plotter->end_plot();
delete plotter; delete plotter;
SetLocaleTo_Default();
return true; return true;
} }
...@@ -31,12 +31,11 @@ void FOOTPRINT_EDIT_FRAME::PrintPage( wxDC* aDC, ...@@ -31,12 +31,11 @@ void FOOTPRINT_EDIT_FRAME::PrintPage( wxDC* aDC,
bool aPrintMirrorMode, bool aPrintMirrorMode,
void * aData) void * aData)
{ {
MODULE* Module;
int drawmode = GR_COPY; int drawmode = GR_COPY;
DISPLAY_OPTIONS save_opt;
BOARD* Pcb = GetBoard();
int defaultPenSize = 50; int defaultPenSize = 50;
DISPLAY_OPTIONS save_opt;
PRINT_PARAMETERS * printParameters = (PRINT_PARAMETERS*) aData; // can be null PRINT_PARAMETERS * printParameters = (PRINT_PARAMETERS*) aData; // can be null
PRINT_PARAMETERS::DrillShapeOptT drillShapeOpt = PRINT_PARAMETERS::FULL_DRILL_SHAPE; PRINT_PARAMETERS::DrillShapeOptT drillShapeOpt = PRINT_PARAMETERS::FULL_DRILL_SHAPE;
...@@ -74,21 +73,17 @@ void FOOTPRINT_EDIT_FRAME::PrintPage( wxDC* aDC, ...@@ -74,21 +73,17 @@ void FOOTPRINT_EDIT_FRAME::PrintPage( wxDC* aDC,
// Draw footprints, this is done at last in order to print the pad holes in // Draw footprints, this is done at last in order to print the pad holes in
// white (or g_DrawBgColor) after the tracks and zones // white (or g_DrawBgColor) after the tracks and zones
Module = (MODULE*) Pcb->m_Modules;
int tmp = D_PAD::m_PadSketchModePenSize; int tmp = D_PAD::m_PadSketchModePenSize;
D_PAD::m_PadSketchModePenSize = defaultPenSize; D_PAD::m_PadSketchModePenSize = defaultPenSize;
wxPoint offset;
offset.x = GetScreen()->m_CurrentSheetDesc->m_Size.x / 2;
offset.y = GetScreen()->m_CurrentSheetDesc->m_Size.y / 2;
// offset is in mils, converts in internal units
offset.x *= m_internalUnits / 1000;
offset.y *= m_internalUnits / 1000;
for( ; Module != NULL; Module = Module->Next() ) wxSize pageSizeIU = GetPageSizeIU() / 2;
wxPoint offset( pageSizeIU.x, pageSizeIU.y );
for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() )
{ {
Module->Move( offset ); module->Move( offset );
Print_Module( DrawPanel, aDC, Module, drawmode, aPrintMaskLayer, drillShapeOpt ); Print_Module( DrawPanel, aDC, module, drawmode, aPrintMaskLayer, drillShapeOpt );
Module->Move( -offset ); module->Move( -offset );
} }
D_PAD::m_PadSketchModePenSize = tmp; D_PAD::m_PadSketchModePenSize = tmp;
...@@ -100,7 +95,7 @@ void FOOTPRINT_EDIT_FRAME::PrintPage( wxDC* aDC, ...@@ -100,7 +95,7 @@ void FOOTPRINT_EDIT_FRAME::PrintPage( wxDC* aDC,
m_DisplayPadFill = DisplayOpt.DisplayPadFill; m_DisplayPadFill = DisplayOpt.DisplayPadFill;
m_DisplayViaFill = DisplayOpt.DisplayViaFill; m_DisplayViaFill = DisplayOpt.DisplayViaFill;
m_DisplayPadNum = DisplayOpt.DisplayPadNum; m_DisplayPadNum = DisplayOpt.DisplayPadNum;
GetBoard()->SetElementVisibility(NO_CONNECTS_VISIBLE, nctmp); GetBoard()->SetElementVisibility( NO_CONNECTS_VISIBLE, nctmp );
} }
......
...@@ -142,7 +142,6 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() ...@@ -142,7 +142,6 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
{ {
int tmpzoom; int tmpzoom;
wxPoint tmp_startvisu; wxPoint tmp_startvisu;
wxSize SheetSize; // Page size in internal units
wxPoint old_org; wxPoint old_org;
wxPoint DrawOffset; // Offset de trace wxPoint DrawOffset; // Offset de trace
double userscale; double userscale;
...@@ -153,65 +152,68 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() ...@@ -153,65 +152,68 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
wxBusyCursor dummy; wxBusyCursor dummy;
/* Save old draw scale and draw offset */ // Save old draw scale and draw offset
tmp_startvisu = screen->m_StartVisu; tmp_startvisu = screen->m_StartVisu;
tmpzoom = screen->GetZoom(); tmpzoom = screen->GetZoom();
old_org = screen->m_DrawOrg; old_org = screen->m_DrawOrg;
/* Change draw scale and offset to draw the whole page */
// Change draw scale and offset to draw the whole page
screen->SetScalingFactor( DrawZoom ); screen->SetScalingFactor( DrawZoom );
screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0; screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0;
screen->m_StartVisu.x = screen->m_StartVisu.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->GetInternalUnits() / 1000;
SheetSize.y *= m_Parent->GetInternalUnits() / 1000; // size in internal units
PCB_BASE_FRAME* pcbframe = (PCB_BASE_FRAME*) m_Parent; PCB_BASE_FRAME* pcbframe = (PCB_BASE_FRAME*) m_Parent;
EDA_RECT brd_BBox = pcbframe->GetBoard()->ComputeBoundingBox(); wxSize pageSizeIU = pcbframe->GetPageSizeIU(); // internal units
EDA_RECT bbbox = pcbframe->GetBoard()->ComputeBoundingBox();
// In module editor, the module is located at 0,0 but for printing // In module editor, the module is located at 0,0 but for printing
// it is moved to SheetSize.x/2, SheetSize.y/2. // it is moved to pageSizeIU.x/2, pageSizeIU.y/2.
// So the equivalent board must be moved: // So the equivalent board must be moved:
if( m_Parent->IsType( MODULE_EDITOR_FRAME ) ) if( m_Parent->IsType( MODULE_EDITOR_FRAME ) )
{ {
wxPoint mv_offset; bbbox.Move( wxPoint( pageSizeIU.x/2, pageSizeIU.y/2 ) );
mv_offset.x = SheetSize.x / 2;
mv_offset.y = SheetSize.y / 2;
brd_BBox.Move( mv_offset );
} }
/* Compute the PCB size in internal units*/ // Compute the PCB size in internal units
userscale = m_PrintParams.m_PrintScale; userscale = m_PrintParams.m_PrintScale;
if( userscale == 0 ) // fit in page if( userscale == 0 ) // fit in page
{ {
int extra_margin = 4000*2; // Margin = 4000 units pcb = 0.4 inch // Margin = 0.4 inch
SheetSize.x = brd_BBox.GetWidth() + extra_margin; #if defined(KICAD_NANOMETRE)
SheetSize.y = brd_BBox.GetHeight() + extra_margin; int extra_margin = int( 0.4 * 25400 ); // nanometers
#else
int extra_margin = int( 0.4 * 1000 ); // deci-mils
#endif
pageSizeIU.x = bbbox.GetWidth() + extra_margin * 2;
pageSizeIU.y = bbbox.GetHeight() + extra_margin * 2;
userscale = 0.99; userscale = 0.99;
} }
if( (m_PrintParams.m_PrintScale > 1.0) // scale > 1 -> Recadrage if( (m_PrintParams.m_PrintScale > 1.0) // scale > 1 -> Recadrage
|| (m_PrintParams.m_PrintScale == 0) ) // fit in page || (m_PrintParams.m_PrintScale == 0) ) // fit in page
{ {
DrawOffset += brd_BBox.Centre(); DrawOffset += bbbox.Centre();
} }
if( m_PrintParams.m_PageSetupData ) if( m_PrintParams.m_PageSetupData )
{ {
wxSize pagesize; wxSize pagesize;
pagesize.x = (int) (SheetSize.x / userscale);
pagesize.y = (int) (SheetSize.y / userscale); pagesize.x = int( pageSizeIU.x / userscale );
FitThisSizeToPageMargins(pagesize, *m_PrintParams.m_PageSetupData ); pagesize.y = int( pageSizeIU.y / userscale );
FitThisSizeToPageMargins( pagesize, *m_PrintParams.m_PageSetupData );
} }
// Compute Accurate scale 1 // Compute Accurate scale 1
if( userscale == 1.0 ) if( userscale == 1.0 )
{ {
// We want a 1:1 scale and margins for printing // We want a 1:1 scale and margins for printing
MapScreenSizeToPaper( ); MapScreenSizeToPaper();
int w, h; int w, h;
GetPPIPrinter( &w, &h ); GetPPIPrinter( &w, &h );
double accurate_Xscale = ( (double) ( DrawZoom * w ) ) / (double) PCB_INTERNAL_UNIT; double accurate_Xscale = ( (double) ( DrawZoom * w ) ) / (double) PCB_INTERNAL_UNIT;
...@@ -263,7 +265,6 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() ...@@ -263,7 +265,6 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
if( m_PrintParams.m_Print_Black_and_White ) if( m_PrintParams.m_Print_Black_and_White )
GRForceBlackPen( true ); GRForceBlackPen( true );
EDA_DRAW_PANEL* panel = m_Parent->DrawPanel; EDA_DRAW_PANEL* panel = m_Parent->DrawPanel;
EDA_RECT tmp = panel->m_ClipBox; EDA_RECT tmp = panel->m_ClipBox;
...@@ -303,7 +304,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() ...@@ -303,7 +304,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
* for scales > 1, the DrawOffset was already computed to have the board centre * for scales > 1, the DrawOffset was already computed to have the board centre
* to the middle of the page. * to the middle of the page.
*/ */
wxPoint pcb_centre = brd_BBox.Centre(); wxPoint pcb_centre = bbbox.Centre();
if( userscale <= 1.0 ) if( userscale <= 1.0 )
DrawOffset.y += pcb_centre.y - (ysize / 2); DrawOffset.y += pcb_centre.y - (ysize / 2);
......
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