Commit 1393eb0f authored by Dick Hollenbeck's avatar Dick Hollenbeck

finish up SCH_SHEET::{Set,Get}PageSettings() switch over

parent d3afe95c
......@@ -176,53 +176,53 @@ bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString )
//-----<PAGE_INFO>-------------------------------------------------------------
// Standard page sizes in 1/1000 inch
// Standard page sizes in mils
#if defined(KICAD_GOST)
static const PAGE_INFO pageA4( wxSize( 8283, 11700 ), wxT( "A4" ) );
const PAGE_INFO PAGE_INFO::pageA4( wxSize( 8283, 11700 ), wxT( "A4" ) );
#else
static const PAGE_INFO pageA4( wxSize( 11700, 8267 ), wxT( "A4" ) );
const PAGE_INFO PAGE_INFO::pageA4( wxSize( 11700, 8267 ), wxT( "A4" ) );
#endif
static const PAGE_INFO pageA3( wxSize( 16535, 11700 ), wxT( "A3" ) );
static const PAGE_INFO pageA2( wxSize( 23400, 16535 ), wxT( "A2" ) );
static const PAGE_INFO pageA1( wxSize( 33070, 23400 ), wxT( "A1" ) );
static const PAGE_INFO pageA0( wxSize( 46800, 33070 ), wxT( "A0" ) );
static const PAGE_INFO pageA( wxSize( 11000, 8500 ), wxT( "A" ) );
static const PAGE_INFO pageB( wxSize( 17000, 11000 ), wxT( "B" ) );
static const PAGE_INFO pageC( wxSize( 22000, 17000 ), wxT( "C" ) );
static const PAGE_INFO pageD( wxSize( 34000, 22000 ), wxT( "D" ) );
static const PAGE_INFO pageE( wxSize( 44000, 34000 ), wxT( "E" ) );
static const PAGE_INFO pageGERBER(wxSize( 32000, 32000 ), wxT( "GERBER" ) );
double PAGE_INFO::s_user_width = 17.0;
double PAGE_INFO::s_user_height = 11.0;
static const PAGE_INFO pageUser( wxSize( 17000, 11000 ), wxT( "User" ) );
static const PAGE_INFO* stdPageSizes[] = {
&pageA4,
&pageA3,
&pageA2,
&pageA1,
&pageA0,
&pageA,
&pageB,
&pageC,
&pageD,
&pageE,
// &pageGERBER, omitted, not standard
&pageUser,
};
const PAGE_INFO PAGE_INFO::pageA3( wxSize( 16535, 11700 ), wxT( "A3" ) );
const PAGE_INFO PAGE_INFO::pageA2( wxSize( 23400, 16535 ), wxT( "A2" ) );
const PAGE_INFO PAGE_INFO::pageA1( wxSize( 33070, 23400 ), wxT( "A1" ) );
const PAGE_INFO PAGE_INFO::pageA0( wxSize( 46800, 33070 ), wxT( "A0" ) );
const PAGE_INFO PAGE_INFO::pageA( wxSize( 11000, 8500 ), wxT( "A" ) );
const PAGE_INFO PAGE_INFO::pageB( wxSize( 17000, 11000 ), wxT( "B" ) );
const PAGE_INFO PAGE_INFO::pageC( wxSize( 22000, 17000 ), wxT( "C" ) );
const PAGE_INFO PAGE_INFO::pageD( wxSize( 34000, 22000 ), wxT( "D" ) );
const PAGE_INFO PAGE_INFO::pageE( wxSize( 44000, 34000 ), wxT( "E" ) );
const PAGE_INFO PAGE_INFO::pageGERBER(wxSize( 32000, 32000 ), wxT( "GERBER" ) );
const PAGE_INFO PAGE_INFO::pageUser( wxSize( 17000, 11000 ), wxT( "User" ) );
int PAGE_INFO::s_user_width = 17000;
int PAGE_INFO::s_user_height = 11000;
/*
wxArrayString PAGE_INFO::GetStandardSizes()
{
wxArrayString ret;
static const PAGE_INFO* stdPageSizes[] = {
&pageA4,
&pageA3,
&pageA2,
&pageA1,
&pageA0,
&pageA,
&pageB,
&pageC,
&pageD,
&pageE,
// &pageGERBER, // standard?
&pageUser,
};
for( unsigned i=0; i < DIM( stdPageSizes ); ++i )
ret.Add( stdPageSizes[i]->GetType() );
return ret;
}
*/
bool PAGE_INFO::SetType( const wxString& aType )
{
......@@ -252,9 +252,13 @@ bool PAGE_INFO::SetType( const wxString& aType )
*this = pageGERBER;
else if( aType == pageUser.GetType() )
{
// pageUser is const, and may not and does not hold the custom size,
// so customize *this later
*this = pageUser;
m_widthInches = s_user_width;
m_heightInches = s_user_height;
// customize:
m_size.x = s_user_width;
m_size.y = s_user_height;
}
else
rc = false;
......@@ -263,22 +267,18 @@ bool PAGE_INFO::SetType( const wxString& aType )
}
PAGE_INFO::PAGE_INFO( const wxSize& aSizeMils, const wxString& aType )
PAGE_INFO::PAGE_INFO( const wxSize& aSizeMils, const wxString& aType ) :
m_size( aSizeMils )
{
// aSizeMils is in 1/1000th of an inch
SetWidthInches( aSizeMils.x / 1000.0 );
SetHeightInches( aSizeMils.y / 1000.0 );
m_type = aType;
m_Type = aType;
// Adjust the default value for margins to 400 mils (0,4 inch or 10 mm)
#if defined(KICAD_GOST)
m_LeftMargin = GOST_LEFTMARGIN;
m_RightMargin = GOST_RIGHTMARGIN;
m_TopMargin = GOST_TOPMARGIN;
m_BottomMargin = GOST_BOTTOMMARGIN;
m_left_margin = GOST_LEFTMARGIN;
m_right_margin = GOST_RIGHTMARGIN;
m_top_margin = GOST_TOPMARGIN;
m_bottom_margin = GOST_BOTTOMMARGIN;
#else
m_LeftMargin = m_RightMargin = m_TopMargin = m_BottomMargin = 400;
m_left_margin = m_right_margin = m_top_margin = m_bottom_margin = 400;
#endif
}
......@@ -289,42 +289,24 @@ PAGE_INFO::PAGE_INFO( const wxString& aType )
}
void PAGE_INFO::SetWidthInches( double aWidthInInches )
{
// limit resolution to 1/1000th of an inch
int mils = aWidthInInches * 1000 + 0.5;
m_widthInches = mils / 1000.0;
}
void PAGE_INFO::SetHeightInches( double aHeightInInches )
{
// limit resolution to 1/1000th of an inch
int mils = aHeightInInches * 1000 + 0.5;
m_heightInches = mils / 1000.0;
}
void PAGE_INFO::SetUserWidthInches( double aWidthInInches )
void PAGE_INFO::SetUserWidthMils( int aWidthInMils )
{
if( aWidthInInches < 6.0 )
aWidthInInches = 6.0;
else if( aWidthInInches > 44.0 )
aWidthInInches = 44.0;
if( aWidthInMils < 6000 )
aWidthInMils = 6000;
else if( aWidthInMils > 44000 )
aWidthInMils = 44000;
s_user_width = aWidthInInches;
s_user_width = aWidthInMils;
}
void PAGE_INFO::SetUserHeightInches( double aHeightInInches )
void PAGE_INFO::SetUserHeightMils( int aHeightInMils )
{
if( aHeightInInches < 4.0 )
aHeightInInches = 4.0;
else if( aHeightInInches > 44.0 )
aHeightInInches = 44.0;
if( aHeightInMils < 4000 )
aHeightInMils = 4000;
else if( aHeightInMils > 44000 )
aHeightInMils = 44000;
s_user_height = aHeightInInches;
s_user_height = aHeightInMils;
}
......
......@@ -79,8 +79,8 @@ void DIALOG_PAGES_SETTINGS::initDialog()
switch( g_UserUnit )
{
case MILLIMETRES:
userSizeX = m_user_size.GetWidthInches() * 25.4;
userSizeY = m_user_size.GetHeightInches() * 25.4;
userSizeX = m_user_size.GetWidthMils() * 25.4e-3;
userSizeY = m_user_size.GetHeightMils() * 25.4e-3;
msg.Printf( wxT( "%.2f" ), userSizeX );
m_TextUserSizeX->SetValue( msg );
......@@ -91,8 +91,8 @@ void DIALOG_PAGES_SETTINGS::initDialog()
default:
case INCHES:
userSizeX = m_user_size.GetWidthInches();
userSizeY = m_user_size.GetHeightInches();
userSizeX = m_user_size.GetWidthMils() / 1000.0;
userSizeY = m_user_size.GetHeightMils() / 1000.0;
msg.Printf( wxT( "%.3f" ), userSizeX );
m_TextUserSizeX->SetValue( msg );
......@@ -101,10 +101,10 @@ void DIALOG_PAGES_SETTINGS::initDialog()
m_TextUserSizeY->SetValue( msg );
break;
/* // you want it in 1/1000ths of an inch, why?
/* // you want it in mils, why?
case UNSCALED_UNITS:
userSizeX = m_user_size.GetWidthInches() * 1000;
userSizeY = m_user_size.GetHeightInches() * 1000;
userSizeX = m_user_size.GetWidthMils();
userSizeY = m_user_size.GetHeightMils();
msg.Printf( wxT( "%f" ), m_userSizeX );
m_TextUserSizeX->SetValue( msg );
msg.Printf( wxT( "%f" ), m_userSizeY );
......@@ -204,20 +204,20 @@ void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event )
switch( g_UserUnit )
{
case MILLIMETRES:
PAGE_INFO::SetUserWidthInches( userSizeX / 25.4 );
PAGE_INFO::SetUserHeightInches( userSizeY / 25.4 );
PAGE_INFO::SetUserWidthMils( int( userSizeX * 1000.0 / 25.4 ) );
PAGE_INFO::SetUserHeightMils( int( userSizeY * 1000.0 / 25.4 ) );
break;
default:
case INCHES:
PAGE_INFO::SetUserWidthInches( userSizeX );
PAGE_INFO::SetUserHeightInches( userSizeY );
PAGE_INFO::SetUserWidthMils( int( 1000 * userSizeX ) );
PAGE_INFO::SetUserHeightMils( int( 1000 * userSizeY ) );
break;
/* // set in 1/1000ths of an inch, but why?
case UNSCALED_UNITS:
PAGE_INFO::SetUserWidthInches( userSizeX /1000 );
PAGE_INFO::SetUserHeightInches( userSizeY /1000 );
PAGE_INFO::SetUserWidthMils( (int) userSizeX );
PAGE_INFO::SetUserHeightMils( (int) userSizeY );
break;
*/
}
......
......@@ -238,7 +238,6 @@ bool DIALOG_SVG_PRINT::DrawSVGPage( EDA_DRAW_FRAME* frame,
screen->m_IsPrinting = false;
panel->m_ClipBox = tmp;
GRForceBlackPen( false );
screen->m_StartVisu = tmp_startvisu;
......
......@@ -100,7 +100,7 @@ private:
void OnPlotCurrent( wxCommandEvent& event );
void OnPlotAll( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
void AcceptplotOffset( wxCommandEvent& event );
void AcceptPlotOffset( wxCommandEvent& event );
void initDlg();
void SetPenSpeed();
......@@ -119,7 +119,7 @@ private:
// static members (static to remember last state):
HPGL_PAGEZ_T DIALOG_PLOT_SCHEMATIC_HPGL:: s_pageSizeSelect = PAGE_DEFAULT;
bool DIALOG_PLOT_SCHEMATIC_HPGL::s_plot_Sheet_Ref = true;
wxSize DIALOG_PLOT_SCHEMATIC_HPGL::s_Offset;
void SCH_EDIT_FRAME::ToPlot_HPGL( wxCommandEvent& event )
{
......@@ -202,7 +202,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::SetPageOffsetValue()
}
void DIALOG_PLOT_SCHEMATIC_HPGL::AcceptplotOffset( wxCommandEvent& event )
void DIALOG_PLOT_SCHEMATIC_HPGL::AcceptPlotOffset( wxCommandEvent& event )
{
s_pageSizeSelect = (HPGL_PAGEZ_T) m_SizeOption->GetSelection();
......
......@@ -95,7 +95,7 @@ DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( SCH_EDIT_FRAME* aParent
m_checkMonochrome->SetValue( aParent->GetPrintMonochrome() );
#ifdef __WXMAC__
/* Problems with modal on wx-2.9 - Anyway preview is standard for OSX */
// Problems with modal on wx-2.9 - Anyway preview is standard for OSX
m_buttonPreview->Hide();
#endif
}
......@@ -310,7 +310,7 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
{
int oldZoom;
wxPoint tmp_startvisu;
wxSize SheetSize; // Page size in internal units
wxSize pageSizeIU; // Page size in internal units
wxPoint old_org;
EDA_RECT oldClipBox;
wxRect fitRect;
......@@ -320,13 +320,13 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
wxBusyCursor dummy;
/* Save current scale factor, offsets, and clip box. */
// Save current scale factor, offsets, and clip box.
tmp_startvisu = aScreen->m_StartVisu;
oldZoom = aScreen->GetZoom();
old_org = aScreen->m_DrawOrg;
oldClipBox = panel->m_ClipBox;
/* Change scale factor, offsets, and clip box to print the whole page. */
// Change scale factor, offsets, and clip box to print the whole page.
panel->m_ClipBox.SetOrigin( wxPoint( 0, 0 ) );
panel->m_ClipBox.SetSize( wxSize( 0x7FFFFF0, 0x7FFFFF0 ) );
......@@ -346,16 +346,17 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
wxLogDebug( wxT( "MinX = %d, MaxX = %d, MinY = %d, MaxY = %d" ),
memDC.MinX(), memDC.MaxX(), memDC.MinY(), memDC.MaxY() );
SheetSize.x = memDC.MaxX() - memDC.MinX();
SheetSize.y = memDC.MaxY() - memDC.MinY();
pageSizeIU.x = memDC.MaxX() - memDC.MinX();
pageSizeIU.y = memDC.MaxY() - memDC.MinY();
FitThisSizeToPageMargins( SheetSize, parent->GetPageSetupData() );
FitThisSizeToPageMargins( pageSizeIU, parent->GetPageSetupData() );
fitRect = GetLogicalPageMarginsRect( parent->GetPageSetupData() );
}
else
{
SheetSize = aScreen->m_CurrentSheetDesc->m_Size;
FitThisSizeToPaper( SheetSize );
pageSizeIU = aScreen->GetPageSettings().GetSizeIU();
FitThisSizeToPaper( pageSizeIU );
fitRect = GetLogicalPaperRect();
}
......
......@@ -77,7 +77,7 @@ void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
break;
/* Hotkey IDs */
// Hotkey IDs
case ID_PREFERENCES_HOTKEY_SHOW_EDITOR:
InstallHotkeyFrame( this, s_Eeschema_Hokeys_Descr );
break;
......@@ -145,7 +145,7 @@ void SCH_EDIT_FRAME::Process_Config( wxCommandEvent& event )
break;
/* Hotkey IDs */
// Hotkey IDs
case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG:
ExportHotkeyConfigToFile( s_Eeschema_Hokeys_Descr );
break;
......@@ -267,7 +267,7 @@ PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetProjectFileParameters()
NET_TYPE_PCBNEW,
NET_TYPE_CUSTOM_MAX ) );
/* NOTE: Left as global until supporting code can be fixed. */
// NOTE: Left as global until supporting code can be fixed.
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "HPGLSpd" ),
&g_HPGL_Pen_Descr.m_Pen_Speed,
20, 2, 45 ) );
......@@ -277,6 +277,8 @@ PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetProjectFileParameters()
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "HPGLNum" ),
&g_HPGL_Pen_Descr.m_Pen_Num,
1, 1, 8 ) );
/* these globals don't exist
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offX_A4" ),
&g_Sheet_A4.m_Offset.x ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offY_A4" ),
......@@ -317,6 +319,8 @@ PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetProjectFileParameters()
&g_Sheet_E.m_Offset.x ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offY_E" ),
&g_Sheet_E.m_Offset.y ) );
*/
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "RptD_X" ),
&g_RepeatStep.x,
0, -1000, +1000 ) );
......@@ -362,7 +366,7 @@ bool SCH_EDIT_FRAME::LoadProjectFile( const wxString& aFileName, bool aForceRere
IsRead = false;
}
/* User library path takes precedent over default library search paths. */
// User library path takes precedent over default library search paths.
wxGetApp().InsertLibraryPath( m_userLibraryPath, 1 );
/* If the list is void, force loading the library "power.lib" that is
......@@ -382,7 +386,7 @@ void SCH_EDIT_FRAME::SaveProjectFile()
{
wxFileName fn;
fn = g_RootSheet->GetScreen()->GetFileName(); /*ConfigFileName*/
fn = g_RootSheet->GetScreen()->GetFileName(); //ConfigFileName
fn.SetExt( ProjectFileExtension );
if( !IsWritable( fn ) )
......@@ -528,7 +532,7 @@ void SCH_EDIT_FRAME::LoadSettings()
cfg->Read( ShowHiddenPinsEntry, &m_showAllPins, false );
cfg->Read( HorzVertLinesOnlyEntry, &g_HVLines, true );
/* Load print preview window session settings. */
// Load print preview window session settings.
cfg->Read( PreviewFramePositionXEntry, &tmp, -1 );
m_previewPosition.x = (int) tmp;
cfg->Read( PreviewFramePositionYEntry, &tmp, -1 );
......@@ -538,7 +542,7 @@ void SCH_EDIT_FRAME::LoadSettings()
cfg->Read( PreviewFrameHeightEntry, &tmp, -1 );
m_previewSize.SetHeight( (int) tmp );
/* Load print dialog session settings. */
// Load print dialog session settings.
cfg->Read( PrintDialogPositionXEntry, &tmp, -1 );
m_printDialogPosition.x = (int) tmp;
cfg->Read( PrintDialogPositionYEntry, &tmp, -1 );
......@@ -552,7 +556,7 @@ void SCH_EDIT_FRAME::LoadSettings()
cfg->Read( SpiceNetNamesEntry, &g_OptNetListUseNames, false );
cfg->Read( SimulatorCommandEntry, &m_simulatorCommand );
/* Load find dialog session setting. */
// Load find dialog session setting.
cfg->Read( FindDialogPositionXEntry, &tmp, -1 );
m_findDialogPosition.x = (int) tmp;
cfg->Read( FindDialogPositionYEntry, &tmp, -1 );
......@@ -568,7 +572,7 @@ void SCH_EDIT_FRAME::LoadSettings()
m_findReplaceData->SetFindString( cfg->Read( FindStringEntry, wxEmptyString ) );
m_findReplaceData->SetReplaceString( cfg->Read( ReplaceStringEntry, wxEmptyString ) );
/* Load the find and replace string history list. */
// Load the find and replace string history list.
for ( size_t i = 0; i < FR_HISTORY_LIST_CNT; i++ )
{
wxString tmpHistory;
......@@ -619,13 +623,13 @@ void SCH_EDIT_FRAME::SaveSettings()
cfg->Write( ShowHiddenPinsEntry, m_showAllPins );
cfg->Write( HorzVertLinesOnlyEntry, g_HVLines );
/* Save print preview window session settings. */
// Save print preview window session settings.
cfg->Write( PreviewFramePositionXEntry, m_previewPosition.x );
cfg->Write( PreviewFramePositionYEntry, m_previewPosition.y );
cfg->Write( PreviewFrameWidthEntry, m_previewSize.GetWidth() );
cfg->Write( PreviewFrameHeightEntry, m_previewSize.GetHeight() );
/* Save print dialog session settings. */
// Save print dialog session settings.
cfg->Write( PrintDialogPositionXEntry, m_printDialogPosition.x );
cfg->Write( PrintDialogPositionYEntry, m_printDialogPosition.y );
cfg->Write( PrintDialogWidthEntry, m_printDialogSize.GetWidth() );
......@@ -635,7 +639,7 @@ void SCH_EDIT_FRAME::SaveSettings()
cfg->Write( SpiceNetNamesEntry, g_OptNetListUseNames );
cfg->Write( SimulatorCommandEntry, m_simulatorCommand );
/* Save find dialog session setting. */
// Save find dialog session setting.
cfg->Write( FindDialogPositionXEntry, m_findDialogPosition.x );
cfg->Write( FindDialogPositionYEntry, m_findDialogPosition.y );
cfg->Write( FindDialogWidthEntry, m_findDialogSize.GetWidth() );
......@@ -647,7 +651,7 @@ void SCH_EDIT_FRAME::SaveSettings()
cfg->Write( FindStringEntry, m_findReplaceData->GetFindString() );
cfg->Write( ReplaceStringEntry, m_findReplaceData->GetReplaceString() );
/* Save the find and replace string history list. */
// Save the find and replace string history list.
size_t i;
wxString tmpHistory;
wxString entry; // invoke constructor outside of any loops
......
......@@ -244,7 +244,10 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& aFileName, bool aIsNew )
if( aIsNew )
{
screen->m_CurrentSheetDesc = &g_Sheet_A4;
/* SCH_SCREEN constructor does this now
screen->SetPageSettings( PAGE_INFO( wxT( "A4" ) ) );
*/
screen->SetZoom( 32 );
screen->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
screen->m_Title = NAMELESS_PROJECT;
......
......@@ -33,54 +33,71 @@ void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event )
switch( event.GetId() )
{
case ID_LIBEDIT_GEN_PNG_FILE:
{
bool fmt_is_jpeg = false; // could be selectable later. so keep this option.
file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" );
mask = wxT( "*." ) + file_ext;
wxFileName fn( cmp->GetName() );
fn.SetExt( file_ext );
FullFileName = EDA_FileSelector( _( "Filename:" ), wxGetCwd(),
fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE, true );
if( FullFileName.IsEmpty() )
return;
// calling wxYield is mandatory under Linux, after closing the file selector dialog
// to refresh the screen before creating the PNG or JPEG image from screen
wxYield();
CreatePNGorJPEGFile( FullFileName, fmt_is_jpeg );
}
{
bool fmt_is_jpeg = false; // could be selectable later. so keep this option.
file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" );
mask = wxT( "*." ) + file_ext;
wxFileName fn( cmp->GetName() );
fn.SetExt( file_ext );
FullFileName = EDA_FileSelector( _( "Filename:" ), wxGetCwd(),
fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE, true );
if( FullFileName.IsEmpty() )
return;
// calling wxYield is mandatory under Linux, after closing the file selector dialog
// to refresh the screen before creating the PNG or JPEG image from screen
wxYield();
CreatePNGorJPEGFile( FullFileName, fmt_is_jpeg );
}
break;
case ID_LIBEDIT_GEN_SVG_FILE:
{
file_ext = wxT( "svg" );
mask = wxT( "*." ) + file_ext;
wxFileName fn( cmp->GetName() );
fn.SetExt( file_ext );
FullFileName = EDA_FileSelector( _( "Filename:" ), wxGetCwd(),
fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE, true );
if( FullFileName.IsEmpty() )
return;
/* Give a size to the SVG draw area = component size + margin
* the margin is 10% the size of the component size
*/
wxSize pagesize = GetScreen()->ReturnPageSize( );
wxSize componentSize = m_component->GetBoundingBox( m_unit, m_convert ).GetSize();
// Add a small margin to the plot bounding box
componentSize.x = (int)(componentSize.x * 1.2);
componentSize.y = (int)(componentSize.y * 1.2);
GetScreen()->SetPageSize( componentSize );
SVG_Print_Component( FullFileName );
GetScreen()->SetPageSize( pagesize );
}
{
file_ext = wxT( "svg" );
mask = wxT( "*." ) + file_ext;
wxFileName fn( cmp->GetName() );
fn.SetExt( file_ext );
FullFileName = EDA_FileSelector( _( "Filename:" ), wxGetCwd(),
fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE, true );
if( FullFileName.IsEmpty() )
return;
#if 0 // would the PAGE_INFO margins work for this old code:
// Give a size to the SVG draw area = component size + margin
// the margin is 10% the size of the component size
wxSize pagesize = GetScreen()->ReturnPageSize( );
wxSize componentSize = m_component->GetBoundingBox( m_unit, m_convert ).GetSize();
// Add a small margin to the plot bounding box
componentSize.x = (int)(componentSize.x * 1.2);
componentSize.y = (int)(componentSize.y * 1.2);
GetScreen()->SetPageSize( componentSize );
SVG_Print_Component( FullFileName );
GetScreen()->SetPageSize( pagesize );
#else
PAGE_INFO pageSave = GetScreen()->GetPageSettings();
PAGE_INFO pageTemp = pageSave;
wxSize componentSize = m_component->GetBoundingBox( m_unit, m_convert ).GetSize();
// Add a small margin to the plot bounding box
pageTemp.SetWidthMils( int( componentSize.x * 1.2 ) );
pageTemp.SetHeightMils( int( componentSize.y * 1.2 ) );
GetScreen()->SetPageSettings( pageTemp );
SVG_Print_Component( FullFileName );
GetScreen()->SetPageSettings( pageSave );
#endif
}
break;
}
}
......@@ -116,7 +133,8 @@ void LIB_EDIT_FRAME::PrintPage( wxDC* aDC, int aPrintMask, bool aPrintMirrorMode
if( ! m_component )
return;
wxSize pagesize = GetScreen()->ReturnPageSize();
wxSize pagesize = GetScreen()->GetPageSettings().GetSizeIU();
/* Plot item centered to the page
* In libedit, the component is centered at 0,0 coordinates.
* So we must plot it with an offset = pagesize/2.
......
......@@ -209,7 +209,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent,
SetIcon( icon );
SetScreen( new SCH_SCREEN( GetPageSettings().GetSizeIU() ) );
SetScreen( new SCH_SCREEN() );
GetScreen()->m_Center = true;
......@@ -287,6 +287,39 @@ LIB_EDIT_FRAME::~LIB_EDIT_FRAME()
}
void LIB_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
{
GetScreen()->SetPageSettings( aPageSettings );
}
const PAGE_INFO& LIB_EDIT_FRAME::GetPageSettings () const
{
return GetScreen()->GetPageSettings();
}
const wxSize LIB_EDIT_FRAME::GetPageSizeIU() const
{
// GetSizeIU is compile time dependent:
return GetScreen()->GetPageSettings().GetSizeIU();
}
const wxPoint& LIB_EDIT_FRAME::GetOriginAxisPosition() const
{
wxASSERT( GetScreen() );
return GetScreen()->GetOriginAxisPosition();
}
void LIB_EDIT_FRAME::SetOriginAxisPosition( const wxPoint& aPosition )
{
wxASSERT( GetScreen() );
GetScreen()->SetOriginAxisPosition( aPosition );
}
void LIB_EDIT_FRAME::LoadSettings()
{
wxConfig* cfg;
......@@ -379,8 +412,11 @@ double LIB_EDIT_FRAME::BestZoom()
}
else
{
dx = GetScreen()->m_CurrentSheetDesc->m_Size.x;
dy = GetScreen()->m_CurrentSheetDesc->m_Size.y;
const PAGE_INFO& pageInfo = GetScreen()->GetPageSettings();
dx = pageInfo.GetSizeIU().x;
dy = pageInfo.GetSizeIU().y;
GetScreen()->SetScrollCenterPosition( wxPoint( 0, 0 ) );
}
......
......@@ -257,7 +257,17 @@ public:
double BestZoom(); // Returns the best zoom
void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
SCH_SCREEN* GetScreen() { return (SCH_SCREEN*) EDA_DRAW_FRAME::GetScreen(); }
SCH_SCREEN* GetScreen() const { return (SCH_SCREEN*) EDA_DRAW_FRAME::GetScreen(); }
// note: a common base class shared between LIB_EDIT_FRAME, LIB_VIEW_FRAME, and SCH_EDIT_FRAME
// would allow sharing of these 5 functions:
void SetPageSettings( const PAGE_INFO& aPageSettings ); // overload EDA_DRAW_FRAME
const PAGE_INFO& GetPageSettings () const; // overload EDA_DRAW_FRAME
const wxSize GetPageSizeIU() const; // overload EDA_DRAW_FRAME
const wxPoint& GetOriginAxisPosition() const; // overload EDA_DRAW_FRAME
void SetOriginAxisPosition( const wxPoint& aPosition ); // overload EDA_DRAW_FRAME
void OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem = NULL );
......
......@@ -48,7 +48,7 @@
#include "sch_bitmap.h"
bool ReadSchemaDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window );
bool ReadSchemaDescr( LINE_READER* aLine, wxString& aMsgDiag, SCH_SCREEN* Window );
static void LoadLayers( LINE_READER* aLine );
......@@ -300,45 +300,20 @@ static void LoadLayers( LINE_READER* aLine )
/* Read the schematic header. */
bool ReadSchemaDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* aScreen )
bool ReadSchemaDescr( LINE_READER* aLine, wxString& aMsgDiag, SCH_SCREEN* aScreen )
{
char Text[256];
char text[256];
char buf[1024];
int ii;
PAGE_INFO* wsheet = &g_Sheet_A4;
wxSize PageSize;
char* line;
static PAGE_INFO* SheetFormatList[] =
{
&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
};
line = aLine->Line();
wxSize pageSize;
char* line = aLine->Line();
sscanf( line, "%s %s %d %d", Text, Text, &PageSize.x, &PageSize.y );
sscanf( line, "%s %s %d %d", text, text, &pageSize.x, &pageSize.y );
wxString pagename = FROM_UTF8( Text );
for( ii = 0; SheetFormatList[ii] != NULL; ii++ )
{
wsheet = SheetFormatList[ii];
if( wsheet->m_Name.CmpNoCase( pagename ) == 0 ) /* Descr found ! */
{
// Get the user page size and make it the default
if( wsheet == &g_Sheet_user )
{
g_Sheet_user.m_Size = PageSize;
}
wxString pagename = FROM_UTF8( text );
break;
}
}
PAGE_INFO pageInfo;
if( SheetFormatList[ii] == NULL )
if( !pageInfo.SetType( pagename ) )
{
aMsgDiag.Printf( wxT( "Eeschema file dimension definition error \
line %d, \aAbort reading file.\n" ),
......@@ -346,7 +321,13 @@ line %d, \aAbort reading file.\n" ),
aMsgDiag << FROM_UTF8( line );
}
aScreen->m_CurrentSheetDesc = wsheet;
if( pagename == wxT( "User" ) )
{
pageInfo.SetWidthMils( pageSize.x );
pageInfo.SetHeightMils( pageSize.y );
}
aScreen->SetPageSettings( pageInfo );
for( ; ; )
{
......
......@@ -97,14 +97,15 @@ static GRID_TYPE SchematicGridList[] = {
#define SCHEMATIC_GRID_LIST_CNT ( sizeof( SchematicGridList ) / sizeof( GRID_TYPE ) )
SCH_SCREEN::SCH_SCREEN( const wxSize& aPageSizeIU ) :
BASE_SCREEN( SCH_SCREEN_T )
SCH_SCREEN::SCH_SCREEN() :
BASE_SCREEN( SCH_SCREEN_T ),
m_paper( wxT( "A4" ) )
{
size_t i;
SetDrawItems( NULL ); // Schematic items list
m_Zoom = 32;
SetZoom( 32 );
for( i = 0; i < SCHEMATIC_ZOOM_LIST_CNT; i++ )
m_ZoomList.Add( SchematicZoomList[i] );
......@@ -118,7 +119,7 @@ SCH_SCREEN::SCH_SCREEN( const wxSize& aPageSizeIU ) :
// Suitable for schematic only. For libedit and viewlib, must be set to true
m_Center = false;
InitDataPoints( aPageSizeIU );
InitDataPoints( m_paper.GetSizeIU() );
}
......@@ -574,8 +575,8 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
* sheet ( ScreenNumber = 1 ) within the files
*/
if( fprintf( aFile, "$Descr %s %d %d\n", TO_UTF8( m_CurrentSheetDesc->m_Name ),
m_CurrentSheetDesc->m_Size.x, m_CurrentSheetDesc->m_Size.y ) < 0
if( fprintf( aFile, "$Descr %s %d %d\n", TO_UTF8( m_paper.GetType() ),
m_paper.GetWidthMils(), m_paper.GetHeightMils() ) < 0
|| fprintf( aFile, "encoding utf-8\n") < 0
|| fprintf( aFile, "Sheet %d %d\n", m_ScreenNumber, m_NumberOfScreen ) < 0
|| fprintf( aFile, "Title %s\n", EscapedUTF8( m_Title ).c_str() ) < 0
......
......@@ -794,7 +794,7 @@ bool SCH_SHEET::Load( SCH_EDIT_FRAME* aFrame )
}
else
{
SetScreen( new SCH_SCREEN( GetPageSettings().GetSizeIU() ) );
SetScreen( new SCH_SCREEN() );
success = aFrame->LoadOneEEFile( m_screen, m_fileName );
if( success )
......
......@@ -243,6 +243,8 @@ typedef boost::ptr_vector<SCH_SHEET_PIN> SCH_SHEET_PINS;
*/
class SCH_SHEET : public SCH_ITEM
{
friend class SCH_SHEET_PIN;
/// Screen that contains the physical data for the sheet. In complex hierarchies
/// multiple sheets can share a common screen.
SCH_SCREEN* m_screen;
......@@ -270,8 +272,6 @@ class SCH_SHEET : public SCH_ITEM
/// The size of the sheet.
wxSize m_size;
friend class SCH_SHEET_PIN;
public:
SCH_SHEET( const wxPoint& pos = wxPoint( 0, 0 ) );
......
......@@ -285,6 +285,39 @@ SCH_EDIT_FRAME::~SCH_EDIT_FRAME()
}
void SCH_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
{
GetScreen()->SetPageSettings( aPageSettings );
}
const PAGE_INFO& SCH_EDIT_FRAME::GetPageSettings () const
{
return GetScreen()->GetPageSettings();
}
const wxSize SCH_EDIT_FRAME::GetPageSizeIU() const
{
// GetSizeIU is compile time dependent:
return GetScreen()->GetPageSettings().GetSizeIU();
}
const wxPoint& SCH_EDIT_FRAME::GetOriginAxisPosition() const
{
wxASSERT( GetScreen() );
return GetScreen()->GetOriginAxisPosition();
}
void SCH_EDIT_FRAME::SetOriginAxisPosition( const wxPoint& aPosition )
{
wxASSERT( GetScreen() );
GetScreen()->SetOriginAxisPosition( aPosition );
}
void SCH_EDIT_FRAME::SetSheetNumberAndCount()
{
SCH_SCREEN* screen = GetScreen();
......@@ -345,7 +378,7 @@ void SCH_EDIT_FRAME::CreateScreens()
if( g_RootSheet->GetScreen() == NULL )
{
g_RootSheet->SetScreen( new SCH_SCREEN( GetPageSettings().GetSizeIU() ) );
g_RootSheet->SetScreen( new SCH_SCREEN() );
SetScreen( g_RootSheet->GetScreen() );
}
......@@ -355,7 +388,7 @@ void SCH_EDIT_FRAME::CreateScreens()
m_CurrentSheet->Push( g_RootSheet );
if( GetScreen() == NULL )
SetScreen( new SCH_SCREEN( GetPageSettings().GetSizeIU() ) );
SetScreen( new SCH_SCREEN() );
GetScreen()->SetZoom( 32.0 );
GetScreen()->m_UndoRedoCountMax = 10;
......@@ -489,8 +522,8 @@ double SCH_EDIT_FRAME::BestZoom()
int dx, dy;
wxSize size;
dx = GetScreen()->m_CurrentSheetDesc->m_Size.x;
dy = GetScreen()->m_CurrentSheetDesc->m_Size.y;
dx = GetScreen()->GetPageSettings().GetWidthIU();
dy = GetScreen()->GetPageSettings().GetHeightIU();
size = m_canvas->GetClientSize();
......
......@@ -116,7 +116,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
}
else // New file.
{
aSheet->SetScreen( new SCH_SCREEN( GetPageSettings().GetSizeIU() ) );
aSheet->SetScreen( new SCH_SCREEN() );
aSheet->GetScreen()->SetFileName( fileName.GetFullPath() );
}
}
......
......@@ -125,7 +125,7 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library, wxSemaph
if( m_Semaphore )
MakeModal(true);
SetScreen( new SCH_SCREEN( GetPageSettings().GetSizeIU() ) );
SetScreen( new SCH_SCREEN() );
GetScreen()->m_Center = true; // Center coordinate origins on screen.
LoadSettings();
......@@ -265,6 +265,39 @@ LIB_VIEW_FRAME::~LIB_VIEW_FRAME()
}
void LIB_VIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
{
GetScreen()->SetPageSettings( aPageSettings );
}
const PAGE_INFO& LIB_VIEW_FRAME::GetPageSettings () const
{
return GetScreen()->GetPageSettings();
}
const wxSize LIB_VIEW_FRAME::GetPageSizeIU() const
{
// GetSizeIU is compile time dependent:
return GetScreen()->GetPageSettings().GetSizeIU();
}
const wxPoint& LIB_VIEW_FRAME::GetOriginAxisPosition() const
{
wxASSERT( GetScreen() );
return GetScreen()->GetOriginAxisPosition();
}
void LIB_VIEW_FRAME::SetOriginAxisPosition( const wxPoint& aPosition )
{
wxASSERT( GetScreen() );
GetScreen()->SetOriginAxisPosition( aPosition );
}
void LIB_VIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
{
SaveSettings();
......
......@@ -34,12 +34,11 @@
#include <wx/gdicmn.h>
#include "wxstruct.h"
#include "class_sch_screen.h"
class wxSashLayoutWindow;
class wxListBox;
class wxSemaphore;
class SCH_SCREEN;
class CMP_LIBRARY;
......@@ -108,7 +107,17 @@ public:
void ClickOnCmpList( wxCommandEvent& event );
void OnSetRelativeOffset( wxCommandEvent& event );
SCH_SCREEN* GetScreen() { return (SCH_SCREEN*) EDA_DRAW_FRAME::GetScreen(); }
SCH_SCREEN* GetScreen() const { return (SCH_SCREEN*) EDA_DRAW_FRAME::GetScreen(); }
// note: a common base class shared between LIB_EDIT_FRAME, LIB_VIEW_FRAME, and SCH_EDIT_FRAME
// would allow sharing of these 5 functions:
void SetPageSettings( const PAGE_INFO& aPageSettings ); // overload EDA_DRAW_FRAME
const PAGE_INFO& GetPageSettings () const; // overload EDA_DRAW_FRAME
const wxSize GetPageSizeIU() const; // overload EDA_DRAW_FRAME
const wxPoint& GetOriginAxisPosition() const; // overload EDA_DRAW_FRAME
void SetOriginAxisPosition( const wxPoint& aPosition ); // overload EDA_DRAW_FRAME
void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 );
......
......@@ -142,8 +142,7 @@ public:
wxString m_Commentaire3;
wxString m_Commentaire4;
/* Grid and zoom values. */
wxPoint m_GridOrigin;
wxPoint m_GridOrigin;
wxArrayDouble m_ZoomList; ///< Array of standard zoom (i.e. scale) coefficients.
bool m_IsPrinting;
......
......@@ -65,7 +65,10 @@ class SCH_SCREEN : public BASE_SCREEN
///< Delete when it goes to zero.
/// The size of the paper to print or plot on
PAGE_INFO m_paper; // keep with the MVC 'model' as this class gets split
PAGE_INFO m_paper; // keep with the MVC 'model' if this class gets split
/// Position of the origin axis, which is used in exports mostly, but not yet in EESCHEMA
wxPoint m_originAxisPosition;
SCH_ITEM* m_drawList; ///< Object list for the screen.
/// @todo use DLIST<SCH_ITEM> or superior container
......@@ -86,9 +89,8 @@ public:
/**
* Constructor
* @param aPageSizeIU is the size of the initial paper page in internal units.
*/
SCH_SCREEN( const wxSize& aPageSizeIU );
SCH_SCREEN();
~SCH_SCREEN();
......@@ -100,6 +102,9 @@ public:
const PAGE_INFO& GetPageSettings() const { return m_paper; }
void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; }
const wxPoint& GetOriginAxisPosition() const { return m_originAxisPosition; }
void SetOriginAxisPosition( const wxPoint& aPosition ) { m_originAxisPosition = aPosition; }
void DecRefCount();
void IncRefCount();
......
......@@ -126,13 +126,15 @@ enum EDA_UNITS_T {
class LibNameList;
class PAGE_INFO;
//class PAGE_INFO;
/**
* Class PAGE_INFO
* describes the page size and margins of a paper page on which to
* eventually print or plot. Here paper is described in inches, but
* accessors for mils, and internal units (IU) are supported.
* eventually print or plot. Paper sizes are often described in inches.
* Here paper is described in 1/1000th of an inch (mils). For convenience
* there are some read only accessors for internal units (IU), which is a compile
* time calculation, not runtime.
*
* @author Dick Hollenbeck
*/
......@@ -142,7 +144,7 @@ public:
PAGE_INFO( const wxString& aType = wxT( "A3" ) );
PAGE_INFO( const wxSize& aSizeMils, const wxString& aName );
const wxString& GetType() const { return m_Type; }
const wxString& GetType() const { return m_type; }
/**
* Function SetType
......@@ -152,80 +154,99 @@ public:
* @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 );
* to static PAGE_INFO::SetUserWidthMils() and
* static PAGE_INFO::SetUserHeightMils();
*
* @return bool - true iff @a aStandarePageDescription was a recognized type.
*/
bool SetType( const wxString& aStandardPageDescriptionName );
void SetWidthInches( double aWidthInInches );
void SetHeightInches( double aHeightInInches );
void SetWidthMils( int aWidthInMils ) { m_size.x = aWidthInMils; }
int GetWidthMils() const { return m_size.x; }
double GetWidthInches() const { return m_widthInches; }
double GetHeightInches() const { return m_heightInches; }
void SetHeightMils( int aHeightInMils ) { m_size.y = aHeightInMils; }
int GetHeightMils() const { return m_size.y; }
int GetWidthMils() const { return int( 1000 * m_widthInches ); }
int GetHeightMils() const { return int( 1000 * m_heightInches ); }
const wxSize GetSizeMils() const { return wxSize( GetWidthMils(), GetHeightMils() ); }
const wxSize& GetSizeMils() const { return m_size; }
// Accessors returning "Internal Units (IU)". IUs are mils in EESCHEMA,
// and either deci-mils or nanometers in PCBNew.
#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 ); }
int GetWidthIU() const { return int( 2.54e4 * GetWidthMils() ); }
int GetHeightIU() const { return int( 2.54e4 * GetHeightMils() ); }
# else
int GetWidthIU() const { return int( 10000 * m_widthInches ); }
int GetHeightIU() const { return int( 10000 * m_heightInches ); }
int GetWidthIU() const { return int( 10 * GetWidthMils() ); }
int GetHeightIU() const { return int( 10 * GetHeightMils() ); }
# 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 ); }
int GetWidthIU() const { return GetWidthMils(); }
int GetHeightIU() const { return GetHeightMils(); }
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; }
int GetLeftMarginMils() const { return m_left_margin; }
int GetRightMarginMils() const { return m_right_margin; }
int GetTopMarginMils() const { return m_top_margin; }
int GetBottomMarginMils() const { return m_bottom_margin; }
void SetLeftMarginMils( int aMargin ) { m_left_margin = aMargin; }
void SetRightMarginMils( int aMargin ) { m_right_margin = aMargin; }
void SetTopMarginMils( int aMargin ) { m_top_margin = aMargin; }
void SetBottomMarginMils( int aMargin ) { m_bottom_margin = aMargin; }
/**
* Function SetUserWidthInches
* sets the width of type "User" page in inches.
* Function SetUserWidthMils
* sets the width of type "User" page in mils.
*/
static void SetUserWidthInches( double aWidthInInches );
static void SetUserWidthMils( int aWidthInMils );
/**
* Function SetUserHeightInches
* sets the height type "User" page in inches.
* Function SetUserHeightMils
* sets the height type "User" page in mils.
*/
static void SetUserHeightInches( double aHeightInInches );
static void SetUserHeightMils( int aHeightInMils );
/**
* Function GetStandardSizes
* returns the standard page types, such as "A4", "A3", etc.
*/
static wxArrayString GetStandardSizes();
*/
private:
wxString m_Type; ///< paper type: A4, A3, etc.
double m_widthInches;
double m_heightInches;
// standard pre-defined sizes
static const PAGE_INFO pageA4;
static const PAGE_INFO pageA3;
static const PAGE_INFO pageA2;
static const PAGE_INFO pageA1;
static const PAGE_INFO pageA0;
static const PAGE_INFO pageA;
static const PAGE_INFO pageB;
static const PAGE_INFO pageC;
static const PAGE_INFO pageD;
static const PAGE_INFO pageE;
static const PAGE_INFO pageGERBER;
static const PAGE_INFO pageUser;
// all dimensions here are in mils
wxString m_type; ///< paper type: A4, A3, etc.
wxSize m_size; ///< mils
// wxPoint m_Offset; ///< plot offset in 1/1000 inches
// wxPoint m_offset_mils; ///< plot offset in mils
int m_LeftMargin;
int m_RightMargin;
int m_TopMargin;
int m_BottomMargin;
int m_left_margin;
int m_right_margin;
int m_top_margin;
int m_bottom_margin;
static double s_user_height;
static double s_user_width;
static int s_user_height;
static int s_user_width;
};
......
......@@ -133,8 +133,6 @@ public:
return m_Pcb;
}
BOARD_DESIGN_SETTINGS* GetDesignSettings();
// General
virtual void OnCloseWindow( wxCloseEvent& Event ) = 0;
virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) { }
......@@ -147,10 +145,7 @@ public:
virtual void SetToolID( int aId, int aCursor, const wxString& aToolMsg );
virtual void UpdateStatusBar();
virtual PCB_SCREEN* GetScreen() const
{
return (PCB_SCREEN*) EDA_DRAW_FRAME::GetScreen();
}
PCB_SCREEN* GetScreen() const { return (PCB_SCREEN*) EDA_DRAW_FRAME::GetScreen(); }
/**
* Function BestZoom
......
......@@ -342,6 +342,20 @@ public:
SCH_SCREEN* GetScreen() const;
// note: a common base class shared between LIB_EDIT_FRAME, LIB_VIEW_FRAME, and SCH_EDIT_FRAME
// would allow sharing of these three functions:
// note: a common base class shared between LIB_EDIT_FRAME, LIB_VIEW_FRAME, and SCH_EDIT_FRAME
// would allow sharing of these 5 functions:
void SetPageSettings( const PAGE_INFO& aPageSettings ); // overload EDA_DRAW_FRAME
const PAGE_INFO& GetPageSettings () const; // overload EDA_DRAW_FRAME
const wxSize GetPageSizeIU() const; // overload EDA_DRAW_FRAME
const wxPoint& GetOriginAxisPosition() const; // overload EDA_DRAW_FRAME
void SetOriginAxisPosition( const wxPoint& aPosition ); // overload EDA_DRAW_FRAME
virtual wxString GetScreenDesc();
void InstallConfigFrame( wxCommandEvent& event );
......
......@@ -363,6 +363,10 @@ public:
*/
class EDA_DRAW_FRAME : public EDA_BASE_FRAME
{
/// Let the #EDA_DRAW_PANEL object have access to the protected data since
/// it is closely tied to the #EDA_DRAW_FRAME.
friend class EDA_DRAW_PANEL;
///< Id of active button on the vertical toolbar.
int m_toolId;
......@@ -416,19 +420,13 @@ protected:
/// Panel used to display information at the bottom of the main window.
EDA_MSG_PANEL* m_messagePanel;
/// Let the #EDA_DRAW_PANEL object have access to the protected data since
/// it is closely tied to the #EDA_DRAW_FRAME.
friend class EDA_DRAW_PANEL;
private:
BASE_SCREEN* m_currentScreen; ///< current used SCREEN
bool m_snapToGrid; ///< Indicates if cursor should be snapped to grid.
protected:
void SetScreen( BASE_SCREEN* aScreen )
{
m_currentScreen = aScreen;
}
void SetScreen( BASE_SCREEN* aScreen ) { m_currentScreen = aScreen; }
/**
* Function unitsChangeRefresh
......@@ -439,6 +437,7 @@ protected:
*/
virtual void unitsChangeRefresh();
public:
EDA_DRAW_FRAME( wxWindow* father, int idtype, const wxString& title,
const wxPoint& pos, const wxSize& size,
......@@ -474,11 +473,12 @@ public:
virtual wxString GetScreenDesc();
/**
* Function GetBaseScreen
* is virtual and returns a pointer to a BASE_SCREEN or one of its
* derivatives. It may be overloaded by derived classes.
* Function GetScreen
* returns a pointer to a BASE_SCREEN or one of its
* derivatives. It is overloaded by derived classes to return
* SCH_SCREEN or PCB_SCREEN.
*/
virtual BASE_SCREEN* GetScreen() const { return m_currentScreen; }
virtual BASE_SCREEN* GetScreen() const { return m_currentScreen; }
void OnMenuOpen( wxMenuEvent& event );
void OnMouseEvent( wxMouseEvent& event );
......
......@@ -48,7 +48,7 @@
#include "class_drawpanel.h"
/* Configuration entry names. */
// Configuration entry names.
static const wxString UserGridSizeXEntry( wxT( "PcbUserGrid_X" ) );
static const wxString UserGridSizeYEntry( wxT( "PcbUserGrid_Y" ) );
static const wxString UserGridUnitsEntry( wxT( "PcbUserGrid_Unit" ) );
......@@ -94,7 +94,7 @@ PCB_BASE_FRAME::PCB_BASE_FRAME( wxWindow* father,
m_DisplayModEdge = FILLED; // How to display module drawings (line/ filled / sketch)
m_DisplayModText = FILLED; // How to display module texts (line/ filled / sketch)
m_DisplayPcbTrackFill = true; /* false = sketch , true = filled */
m_DisplayPcbTrackFill = true; // false = sketch , true = filled
m_Draw3DFrame = NULL; // Display Window in 3D mode (OpenGL)
m_ModuleEditFrame = NULL; // Frame for footprint edition
......@@ -194,14 +194,7 @@ EDA_RECT PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const
}
BOARD_DESIGN_SETTINGS* PCB_BASE_FRAME::GetDesignSettings()
{
wxASSERT( m_Pcb );
return m_Pcb ? &m_Pcb->GetDesignSettings() : NULL;
}
double PCB_BASE_FRAME::BestZoom( void )
double PCB_BASE_FRAME::BestZoom()
{
int dx, dy;
......@@ -236,7 +229,7 @@ double PCB_BASE_FRAME::BestZoom( void )
}
void PCB_BASE_FRAME::CursorGoto( const wxPoint& aPos )
void PCB_BASE_FRAME::CursorGoto( const wxPoint& aPos )
{
// factored out of pcbnew/find.cpp
......@@ -244,7 +237,7 @@ void PCB_BASE_FRAME::CursorGoto( const wxPoint& aPos )
wxClientDC dc( m_canvas );
/* There may be need to reframe the drawing. */
// There may be need to reframe the drawing.
if( !m_canvas->IsPointOnDisplay( aPos ) )
{
screen->SetCrossHairPosition( aPos );
......@@ -267,7 +260,7 @@ void PCB_BASE_FRAME::ReCreateMenuBar( void )
}
/* Virtual functions: Do nothing for PCB_BASE_FRAME window */
// Virtual functions: Do nothing for PCB_BASE_FRAME window
void PCB_BASE_FRAME::Show3D_Frame( wxCommandEvent& event )
{
}
......
......@@ -176,7 +176,7 @@ private:
COLORS_DESIGN_SETTINGS* m_colorsSettings; // Link to current colors settings
PAGE_INFO m_paper;
/// Position of the origin axis.
/// Position of the origin axis, which is used in exports mostly
wxPoint m_originAxisPosition;
/**
......
......@@ -476,8 +476,8 @@ void KICAD_PLUGIN::loadSHEET()
int w = intParse( width );
int h = intParse( height );
page.SetWidthInches( w / 1000.0 );
page.SetHeightInches( h / 1000.0 );
page.SetWidthMils( w );
page.SetHeightMils( h );
}
}
......
......@@ -41,7 +41,7 @@
#include "worksheet.h"
#include "dialog_hotkeys_editor.h"
#include "class_pad.h"
#include "class_board.h"
#include "pcbplot.h"
#include "pcbnew.h"
......@@ -210,7 +210,7 @@ void PCB_EDIT_FRAME::SaveProjectSettings()
PARAM_CFG_ARRAY PCB_EDIT_FRAME::GetProjectFileParameters()
{
PARAM_CFG_ARRAY pca;
BOARD_DESIGN_SETTINGS& bds = *GetDesignSettings();
BOARD_DESIGN_SETTINGS& bds = GetBoard()->GetDesignSettings();
pca.push_back( new PARAM_CFG_FILENAME( wxT( "LibDir" ),&g_UserLibDirBuffer,
GROUPLIB ) );
......
......@@ -152,6 +152,7 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
FILE* FichCmp, * NewFile;
char line[1024];
wxString msg;
char* ignore;
if( old_name == new_name )
return 0;
......@@ -189,7 +190,7 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
return 1;
}
fgets( line, sizeof(line), FichCmp );
ignore = fgets( line, sizeof(line), FichCmp );
fprintf( NewFile, "Cmp-Mod V01 Genere par PcbNew le %s\n", TO_UTF8( DateAndTime() ) );
......@@ -587,6 +588,7 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
MODULE* Module = GetBoard()->m_Modules;
wxString msg;
wxString wildcard;
char* ignore;
if( Module == NULL )
{
......@@ -617,7 +619,7 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
return;
}
fgets( line, sizeof(line), FichCmp );
ignore = fgets( line, sizeof(line), FichCmp );
fprintf( FichCmp, "Cmp-Mod V01 Genere par PcbNew le %s\n", TO_UTF8( DateAndTime() ) );
for( ; Module != NULL; Module = Module->Next() )
......
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