From 4d25d2ffcc08e20d9ff40609db5c3e4e4f9a0ac5 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Thu, 5 Jan 2012 02:07:11 -0600 Subject: [PATCH] finish up SCH_SHEET::{Set,Get}PageSettings() switch over --- common/common.cpp | 136 ++++++++---------- common/dialogs/dialog_page_settings.cpp | 26 ++-- eeschema/dialogs/dialog_SVG_print.cpp | 1 - .../dialogs/dialog_plot_schematic_HPGL.cpp | 6 +- .../dialogs/dialog_print_using_printer.cpp | 19 +-- eeschema/eeschema_config.cpp | 30 ++-- eeschema/files-io.cpp | 5 +- eeschema/libedit_plot_component.cpp | 96 ++++++++----- eeschema/libeditframe.cpp | 42 +++++- eeschema/libeditframe.h | 12 +- eeschema/load_one_schematic_file.cpp | 51 +++---- eeschema/sch_screen.cpp | 13 +- eeschema/sch_sheet.cpp | 2 +- eeschema/sch_sheet.h | 4 +- eeschema/schframe.cpp | 41 +++++- eeschema/sheet.cpp | 2 +- eeschema/viewlib_frame.cpp | 35 ++++- eeschema/viewlib_frame.h | 15 +- include/class_base_screen.h | 3 +- include/class_sch_screen.h | 11 +- include/common.h | 101 +++++++------ include/wxBasePcbFrame.h | 7 +- include/wxEeschemaStruct.h | 14 ++ include/wxstruct.h | 24 ++-- pcbnew/basepcbframe.cpp | 19 +-- pcbnew/class_board.h | 2 +- pcbnew/kicad_plugin.cpp | 4 +- pcbnew/pcbnew_config.cpp | 4 +- pcbnew/xchgmod.cpp | 6 +- 29 files changed, 435 insertions(+), 296 deletions(-) diff --git a/common/common.cpp b/common/common.cpp index c8f4cf9a0a..38c80cf39f 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -176,53 +176,53 @@ bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString ) //------------------------------------------------------------------ -// 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 ) +void PAGE_INFO::SetUserWidthMils( int aWidthInMils ) { - // limit resolution to 1/1000th of an inch - int mils = aWidthInInches * 1000 + 0.5; + if( aWidthInMils < 6000 ) + aWidthInMils = 6000; + else if( aWidthInMils > 44000 ) + aWidthInMils = 44000; - m_widthInches = mils / 1000.0; + s_user_width = aWidthInMils; } - -void PAGE_INFO::SetHeightInches( double aHeightInInches ) +void PAGE_INFO::SetUserHeightMils( int aHeightInMils ) { - // limit resolution to 1/1000th of an inch - int mils = aHeightInInches * 1000 + 0.5; + if( aHeightInMils < 4000 ) + aHeightInMils = 4000; + else if( aHeightInMils > 44000 ) + aHeightInMils = 44000; - m_heightInches = mils / 1000.0; -} - - -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; + s_user_height = aHeightInMils; } diff --git a/common/dialogs/dialog_page_settings.cpp b/common/dialogs/dialog_page_settings.cpp index 629ef027eb..140df7f1c9 100644 --- a/common/dialogs/dialog_page_settings.cpp +++ b/common/dialogs/dialog_page_settings.cpp @@ -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; */ } diff --git a/eeschema/dialogs/dialog_SVG_print.cpp b/eeschema/dialogs/dialog_SVG_print.cpp index 3cc368eef7..79c6c0ccf3 100644 --- a/eeschema/dialogs/dialog_SVG_print.cpp +++ b/eeschema/dialogs/dialog_SVG_print.cpp @@ -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; diff --git a/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp b/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp index 426298b2be..af5b676bfb 100644 --- a/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp +++ b/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp @@ -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(); diff --git a/eeschema/dialogs/dialog_print_using_printer.cpp b/eeschema/dialogs/dialog_print_using_printer.cpp index 181d8bf89d..6e559604a3 100644 --- a/eeschema/dialogs/dialog_print_using_printer.cpp +++ b/eeschema/dialogs/dialog_print_using_printer.cpp @@ -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(); } diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index bbc57da4b0..39c98dbcb6 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -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 diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index f21c48174a..c81c41a5e7 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -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; diff --git a/eeschema/libedit_plot_component.cpp b/eeschema/libedit_plot_component.cpp index 792394cdba..fd39dc8e58 100644 --- a/eeschema/libedit_plot_component.cpp +++ b/eeschema/libedit_plot_component.cpp @@ -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. + { + 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 ); + 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 ); + FullFileName = EDA_FileSelector( _( "Filename:" ), wxGetCwd(), + fn.GetFullName(), file_ext, mask, this, + wxFD_SAVE, true ); - if( FullFileName.IsEmpty() ) - return; + 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 ); - } + // 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 ); + { + 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( 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(); +#if 0 // would the PAGE_INFO margins work for this old code: - // 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 ); - } + // 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. diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index 2c1a0af3a7..e756a78b1f 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -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 ) ); } diff --git a/eeschema/libeditframe.h b/eeschema/libeditframe.h index b1336874db..0bb97b3863 100644 --- a/eeschema/libeditframe.h +++ b/eeschema/libeditframe.h @@ -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 ); diff --git a/eeschema/load_one_schematic_file.cpp b/eeschema/load_one_schematic_file.cpp index 9ddae4cc26..a9ba6aad7f 100644 --- a/eeschema/load_one_schematic_file.cpp +++ b/eeschema/load_one_schematic_file.cpp @@ -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; + wxSize pageSize; + char* line = aLine->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 - }; + sscanf( line, "%s %s %d %d", text, text, &pageSize.x, &pageSize.y ); - line = aLine->Line(); + wxString pagename = FROM_UTF8( text ); - sscanf( line, "%s %s %d %d", Text, Text, &PageSize.x, &PageSize.y ); + PAGE_INFO pageInfo; - 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; - } - - break; - } - } - - 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( ; ; ) { diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index b70c41c2c3..1f7a777c11 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -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 diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 0b0d210553..91169bd542 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -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 ) diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index b427da8eb8..08171236bf 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -243,6 +243,8 @@ typedef boost::ptr_vector 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 ) ); diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 0e6f1b28e7..521ec1e45d 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -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(); diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index 278bab6ae7..f82c5bfceb 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -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() ); } } diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index 12a0e69897..a9a3d50b99 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -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(); diff --git a/eeschema/viewlib_frame.h b/eeschema/viewlib_frame.h index 1956e2b12e..89866393ab 100644 --- a/eeschema/viewlib_frame.h +++ b/eeschema/viewlib_frame.h @@ -34,12 +34,11 @@ #include #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 ); diff --git a/include/class_base_screen.h b/include/class_base_screen.h index b75a70071f..5c42b72182 100644 --- a/include/class_base_screen.h +++ b/include/class_base_screen.h @@ -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; diff --git a/include/class_sch_screen.h b/include/class_sch_screen.h index 7b31756d84..6eca332e66 100644 --- a/include/class_sch_screen.h +++ b/include/class_sch_screen.h @@ -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 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(); diff --git a/include/common.h b/include/common.h index a980ce22d8..7e908372ae 100644 --- a/include/common.h +++ b/include/common.h @@ -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; -// wxPoint m_Offset; ///< plot offset in 1/1000 inches + // all dimensions here are in mils - int m_LeftMargin; - int m_RightMargin; - int m_TopMargin; - int m_BottomMargin; + wxString m_type; ///< paper type: A4, A3, etc. - static double s_user_height; - static double s_user_width; + wxSize m_size; ///< mils + +// wxPoint m_offset_mils; ///< plot offset in mils + + int m_left_margin; + int m_right_margin; + int m_top_margin; + int m_bottom_margin; + + static int s_user_height; + static int s_user_width; }; diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index cbb2fb0fa5..ee8b5053cb 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -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 diff --git a/include/wxEeschemaStruct.h b/include/wxEeschemaStruct.h index 65f09de0bb..6edb2254a6 100644 --- a/include/wxEeschemaStruct.h +++ b/include/wxEeschemaStruct.h @@ -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 ); diff --git a/include/wxstruct.h b/include/wxstruct.h index ef2fc84997..cae1550d42 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -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 ); diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index ddb6372cf0..86d6940d04 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -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 ) { } diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index e50c20ba05..e56ac9480f 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -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; /** diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index a172b30c8a..71143b6830 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -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 ); } } diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 648d9e90f6..2fd6f6cd98 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -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 ) ); diff --git a/pcbnew/xchgmod.cpp b/pcbnew/xchgmod.cpp index 34b76b2d6f..b31e1ed5b5 100644 --- a/pcbnew/xchgmod.cpp +++ b/pcbnew/xchgmod.cpp @@ -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() )