diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 06fc99cac5..2bfbdd1fa0 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,24 @@ +KiCad ChangeLog 2012 +==================== + +2012-Jan-9 UPDATE Dick Hollenbeck +================================================================================ +++all + * Carve out TITLE_BLOCK from BASE_SCREEN + * Add include/hashtables.h and put class PROPERTIES in there. + Change PROPERTIES to use "const char*" as the key instead of wxString. +++eeschema + * Add shim class SCH_BASE_FRAME which introduces the data model SCH_SCREEN + to the frame EESCHEMA frame class hierarchy and allows sharing of: + SCH_SCREEN* GetScreen() const; // overload EDA_DRAW_FRAME + 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 + const TITLE_BLOCK& GetTitleBlock() const; // overload EDA_DRAW_FRAME + void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ); // overload EDA_DRAW_FRAME + 2012-Jan-5 UPDATE Dick Hollenbeck ================================================================================ diff --git a/common/common_plot_functions.cpp b/common/common_plot_functions.cpp index d46ee07b79..02b1575ff3 100644 --- a/common/common_plot_functions.cpp +++ b/common/common_plot_functions.cpp @@ -14,7 +14,7 @@ #include "macros.h" #include "class_base_screen.h" #include "drawtxt.h" - +#include "class_title_block.h" /* Plot sheet references * margin is in mils (1/1000 inch) @@ -479,12 +479,12 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) switch( WsItem->m_Type ) { case WS_DATE: - msg += screen->m_Date; + msg += GetTitleBlock().GetDate(); bold = true; break; case WS_REV: - msg += screen->m_Revision; + msg += GetTitleBlock().GetRevision(); bold = true; break; @@ -517,37 +517,37 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) break; case WS_COMPANY_NAME: - msg += screen->m_Company; + msg += GetTitleBlock().GetCompany(); if( !msg.IsEmpty() ) UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT ); bold = true; break; case WS_TITLE: - msg += screen->m_Title; + msg += GetTitleBlock().GetTitle(); bold = true; break; case WS_COMMENT1: - msg += screen->m_Commentaire1; + msg += GetTitleBlock().GetComment1(); if( !msg.IsEmpty() ) UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT ); break; case WS_COMMENT2: - msg += screen->m_Commentaire2; + msg += GetTitleBlock().GetComment2(); if( !msg.IsEmpty() ) UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT ); break; case WS_COMMENT3: - msg += screen->m_Commentaire3; + msg += GetTitleBlock().GetComment3(); if( !msg.IsEmpty() ) UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT ); break; case WS_COMMENT4: - msg += screen->m_Commentaire4; + msg += GetTitleBlock().GetComment4(); if( !msg.IsEmpty() ) UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT ); break; diff --git a/common/dialogs/dialog_page_settings.cpp b/common/dialogs/dialog_page_settings.cpp index 140df7f1c9..d10a03fe72 100644 --- a/common/dialogs/dialog_page_settings.cpp +++ b/common/dialogs/dialog_page_settings.cpp @@ -72,9 +72,9 @@ void DIALOG_PAGES_SETTINGS::initDialog() msg.Printf( format, m_Screen->m_ScreenNumber ); m_TextSheetNumber->SetLabel( msg ); - m_page = m_Parent->GetPageSettings(); + PAGE_INFO pageInfo = m_Parent->GetPageSettings(); - setCurrentPageSizeSelection(); + setCurrentPageSizeSelection( pageInfo.GetType() ); switch( g_UserUnit ) { @@ -113,8 +113,7 @@ void DIALOG_PAGES_SETTINGS::initDialog() */ } - // Set validators -// m_PageSizeBox->SetValidator( wxGenericValidator( &m_CurrentSelection ) ); +#if 0 m_TextRevision->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Revision ) ); m_TextTitle->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Title ) ); m_TextCompany->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Company ) ); @@ -122,6 +121,18 @@ void DIALOG_PAGES_SETTINGS::initDialog() m_TextComment2->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Commentaire2 ) ); m_TextComment3->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Commentaire3 ) ); m_TextComment4->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Commentaire4 ) ); +#else + + TITLE_BLOCK tb = m_Parent->GetTitleBlock(); + + m_TextRevision->SetValue( tb.GetRevision() ); + m_TextTitle->SetValue( tb.GetTitle() ); + m_TextCompany->SetValue( tb.GetCompany() ); + m_TextComment1->SetValue( tb.GetComment1() ); + m_TextComment2->SetValue( tb.GetComment2() ); + m_TextComment3->SetValue( tb.GetComment3() ); + m_TextComment4->SetValue( tb.GetComment4() ); +#endif #ifndef EESCHEMA m_RevisionExport->Show( false ); @@ -175,14 +186,15 @@ void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event ) wxString msg; double userSizeX; double userSizeY; + TITLE_BLOCK tb; - m_Screen->m_Revision = m_TextRevision->GetValue(); - m_Screen->m_Company = m_TextCompany->GetValue(); - m_Screen->m_Title = m_TextTitle->GetValue(); - m_Screen->m_Commentaire1 = m_TextComment1->GetValue(); - m_Screen->m_Commentaire2 = m_TextComment2->GetValue(); - m_Screen->m_Commentaire3 = m_TextComment3->GetValue(); - m_Screen->m_Commentaire4 = m_TextComment4->GetValue(); + tb.SetRevision( m_TextRevision->GetValue() ); + tb.SetCompany( m_TextCompany->GetValue() ); + tb.SetTitle( m_TextTitle->GetValue() ); + tb.SetComment1( m_TextComment1->GetValue() ); + tb.SetComment2( m_TextComment2->GetValue() ); + tb.SetComment3( m_TextComment3->GetValue() ); + tb.SetComment4( m_TextComment4->GetValue() ); msg = m_TextUserSizeX->GetValue(); msg.ToDouble( &userSizeX ); @@ -195,11 +207,11 @@ void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event ) radioSelection = 0; // wxFormBuilder must use "A4", "A3", etc for choices, in all languages/translations - wxString paperType = m_PageSizeBox->GetString( radioSelection ); + wxString paperType = m_PageSizeBox->GetString( radioSelection ); + PAGE_INFO pageInfo( paperType ); - m_page.SetType( paperType ); - - m_Parent->SetPageSettings( m_page ); + m_Parent->SetPageSettings( pageInfo ); + m_Parent->SetTitleBlock( tb ); switch( g_UserUnit ) { @@ -229,32 +241,36 @@ void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event ) // Build the screen list SCH_SCREENS ScreenList; - // Update the datas + // Update title blocks for all screens for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) { if( screen == m_Screen ) continue; + TITLE_BLOCK tb2 = screen->GetTitleBlock(); + if( m_RevisionExport->IsChecked() ) - screen->m_Revision = m_Screen->m_Revision; + tb2.SetRevision( tb.GetRevision() ); if( m_TitleExport->IsChecked() ) - screen->m_Title = m_Screen->m_Title; + tb2.SetTitle( tb.GetTitle() ); if( m_CompanyExport->IsChecked() ) - screen->m_Company = m_Screen->m_Company; + tb2.SetCompany( tb.GetCompany() ); if( m_Comment1Export->IsChecked() ) - screen->m_Commentaire1 = m_Screen->m_Commentaire1; + tb2.SetComment1( tb.GetComment1() ); if( m_Comment2Export->IsChecked() ) - screen->m_Commentaire2 = m_Screen->m_Commentaire2; + tb2.SetComment2( tb.GetComment2() ); if( m_Comment3Export->IsChecked() ) - screen->m_Commentaire3 = m_Screen->m_Commentaire3; + tb2.SetComment3( tb.GetComment3() ); if( m_Comment4Export->IsChecked() ) - screen->m_Commentaire4 = m_Screen->m_Commentaire4; + tb2.SetComment4( tb.GetComment4() ); + + screen->SetTitleBlock( tb2 ); } #endif @@ -264,10 +280,8 @@ void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event ) } -void DIALOG_PAGES_SETTINGS::setCurrentPageSizeSelection() +void DIALOG_PAGES_SETTINGS::setCurrentPageSizeSelection( const wxString& aPaperSize ) { - wxString curPaperType = m_page.GetType(); - // use wxFormBuilder to store the sheet type in the wxRadioButton's label // i.e. "A4", "A3", etc, anywhere within the text of the label. @@ -276,12 +290,12 @@ void DIALOG_PAGES_SETTINGS::setCurrentPageSizeSelection() // search all the child wxRadioButtons for a label containing our paper type for( unsigned i = 0; i < m_PageSizeBox->GetCount(); ++i ) { - // parse each label looking for curPaperType within it + // parse each label looking for aPaperSize within it wxStringTokenizer st( m_PageSizeBox->GetString( i ) ); while( st.HasMoreTokens() ) { - if( st.GetNextToken() == curPaperType ) + if( st.GetNextToken() == aPaperSize ) { m_PageSizeBox->SetSelection( i ); return; diff --git a/common/dialogs/dialog_page_settings.h b/common/dialogs/dialog_page_settings.h index eeaff9e319..36a560b761 100644 --- a/common/dialogs/dialog_page_settings.h +++ b/common/dialogs/dialog_page_settings.h @@ -17,7 +17,6 @@ private: EDA_DRAW_FRAME* m_Parent; BASE_SCREEN* m_Screen; bool m_modified; - PAGE_INFO m_page; ///< the one being edited PAGE_INFO m_user_size; ///< instantiated just to get the size public: @@ -37,7 +36,7 @@ private: /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL void OnCancelClick( wxCommandEvent& event ); - void setCurrentPageSizeSelection(); + void setCurrentPageSizeSelection( const wxString& aPaperSize ); void SavePageSettings(wxCommandEvent& event); void ReturnSizeSelected(wxCommandEvent& event); diff --git a/common/worksheet.cpp b/common/worksheet.cpp index d9edb57cd3..7dc214fbe4 100644 --- a/common/worksheet.cpp +++ b/common/worksheet.cpp @@ -13,6 +13,7 @@ #include "wxstruct.h" #include "appl_wxstruct.h" #include "worksheet.h" +#include "class_title_block.h" #include "build_version.h" @@ -1423,7 +1424,7 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_wid case WS_DATE: if( WsItem->m_Legende ) msg = WsItem->m_Legende; - msg += screen->m_Date; + msg += GetTitleBlock().GetDate(); DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, @@ -1433,7 +1434,7 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_wid case WS_REV: if( WsItem->m_Legende ) msg = WsItem->m_Legende; - msg += screen->m_Revision; + msg += GetTitleBlock().GetRevision(); DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, @@ -1503,7 +1504,7 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_wid case WS_COMPANY_NAME: if( WsItem->m_Legende ) msg = WsItem->m_Legende; - msg += screen->m_Company; + msg += GetTitleBlock().GetCompany(); if( !msg.IsEmpty() ) { DrawGraphicText( m_canvas, DC, pos, Color, @@ -1518,7 +1519,7 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_wid case WS_TITLE: if( WsItem->m_Legende ) msg = WsItem->m_Legende; - msg += screen->m_Title; + msg += GetTitleBlock().GetTitle(); DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, @@ -1529,7 +1530,7 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_wid case WS_COMMENT1: if( WsItem->m_Legende ) msg = WsItem->m_Legende; - msg += screen->m_Commentaire1; + msg += GetTitleBlock().GetComment1(); if( !msg.IsEmpty() ) { DrawGraphicText( m_canvas, DC, pos, Color, @@ -1543,7 +1544,7 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_wid case WS_COMMENT2: if( WsItem->m_Legende ) msg = WsItem->m_Legende; - msg += screen->m_Commentaire2; + msg += GetTitleBlock().GetComment2(); if( !msg.IsEmpty() ) { DrawGraphicText( m_canvas, DC, pos, Color, @@ -1557,7 +1558,7 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_wid case WS_COMMENT3: if( WsItem->m_Legende ) msg = WsItem->m_Legende; - msg += screen->m_Commentaire3; + msg += GetTitleBlock().GetComment3(); if( !msg.IsEmpty() ) { DrawGraphicText( m_canvas, DC, pos, Color, @@ -1571,7 +1572,7 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_wid case WS_COMMENT4: if( WsItem->m_Legende ) msg = WsItem->m_Legende; - msg += screen->m_Commentaire4; + msg += GetTitleBlock().GetComment4(); if( !msg.IsEmpty() ) { DrawGraphicText( m_canvas, DC, pos, Color, diff --git a/copyright.h b/copyright.h index 525f06343d..f2822cace0 100644 --- a/copyright.h +++ b/copyright.h @@ -12,8 +12,8 @@ may choose to document this corresponding work in the CHANGELOG.txt file. /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2011 - * Copyright (C) 2011 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2012 + * Copyright (C) 2012 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 32a3fde814..e6e7538a2d 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -114,6 +114,7 @@ set(EESCHEMA_SRCS onrightclick.cpp operations_on_items_lists.cpp pinedit.cpp + sch_base_frame.cpp sch_bitmap.cpp sch_bus_entry.cpp sch_collectors.cpp diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index c81c41a5e7..29292571b2 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -250,14 +250,17 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& aFileName, bool aIsNew ) screen->SetZoom( 32 ); screen->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); - screen->m_Title = NAMELESS_PROJECT; - screen->m_Title += wxT( ".sch" ); - GetScreen()->SetFileName( screen->m_Title ); - screen->m_Company.Empty(); - screen->m_Commentaire1.Empty(); - screen->m_Commentaire2.Empty(); - screen->m_Commentaire3.Empty(); - screen->m_Commentaire4.Empty(); + + TITLE_BLOCK tb; + wxString title; + + title += NAMELESS_PROJECT; + title += wxT( ".sch" ); + tb.SetTitle( title ); + screen->SetTitleBlock( tb ); + + GetScreen()->SetFileName( title ); + LoadProjectFile( wxEmptyString, true ); Zoom_Automatique( false ); SetSheetNumberAndCount(); diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index 6e9d6540aa..c0e1b0856b 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -189,7 +189,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent, const wxPoint& pos, const wxSize& size, long style ) : - EDA_DRAW_FRAME( aParent, LIBEDITOR_FRAME, title, pos, size, style ) + SCH_BASE_FRAME( aParent, LIBEDITOR_FRAME, title, pos, size, style ) { wxASSERT( aParent ); @@ -287,39 +287,6 @@ 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; diff --git a/eeschema/libeditframe.h b/eeschema/libeditframe.h index 0bb97b3863..a6c63da557 100644 --- a/eeschema/libeditframe.h +++ b/eeschema/libeditframe.h @@ -28,14 +28,14 @@ * @brief Definition of class LIB_EDIT_FRAME */ -#ifndef __LIBEDITFRM_H__ -#define __LIBEDITFRM_H__ +#ifndef LIBEDITFRM_H_ +#define LIBEDITFRM_H_ -#include "wxstruct.h" -#include "class_sch_screen.h" +#include +#include -#include "lib_draw_item.h" -#include "lib_collectors.h" +#include +#include class SCH_EDIT_FRAME; @@ -49,7 +49,7 @@ class DIALOG_LIB_EDIT_TEXT; /** * The component library editor main window. */ -class LIB_EDIT_FRAME : public EDA_DRAW_FRAME +class LIB_EDIT_FRAME : public SCH_BASE_FRAME { LIB_COMPONENT* m_tempCopyComponent; ///< Temporary copy of current component during edit. LIB_COLLECTOR m_collectedItems; // Used for hit testing. @@ -122,9 +122,9 @@ class LIB_EDIT_FRAME : public EDA_DRAW_FRAME LIB_ITEM* locateItem( const wxPoint& aPosition, const KICAD_T aFilterList[] ); public: - LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent, const wxString& title, - const wxPoint& pos, const wxSize& size, - long style = KICAD_DEFAULT_DRAWFRAME_STYLE ); + LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent, const wxString& aTitle, + const wxPoint& aPosition, const wxSize& aSize, + long aStyle = KICAD_DEFAULT_DRAWFRAME_STYLE ); ~LIB_EDIT_FRAME(); @@ -257,18 +257,6 @@ public: double BestZoom(); // Returns the best zoom void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ); - 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 ); void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); @@ -599,4 +587,4 @@ public: DECLARE_EVENT_TABLE() }; -#endif /* __LIBEDITFRM_H__ */ +#endif // LIBEDITFRM_H_ diff --git a/eeschema/load_one_schematic_file.cpp b/eeschema/load_one_schematic_file.cpp index a9ba6aad7f..0847696c27 100644 --- a/eeschema/load_one_schematic_file.cpp +++ b/eeschema/load_one_schematic_file.cpp @@ -312,6 +312,7 @@ bool ReadSchemaDescr( LINE_READER* aLine, wxString& aMsgDiag, SCH_SCREEN* aScree wxString pagename = FROM_UTF8( text ); PAGE_INFO pageInfo; + TITLE_BLOCK tb; if( !pageInfo.SetType( pagename ) ) { @@ -337,7 +338,10 @@ line %d, \aAbort reading file.\n" ), line = aLine->Line(); if( strnicmp( line, "$End", 4 ) == 0 ) + { + aScreen->SetTitleBlock( tb ); break; + } if( strnicmp( line, "Sheet", 2 ) == 0 ) sscanf( line + 5, " %d %d", @@ -346,56 +350,56 @@ line %d, \aAbort reading file.\n" ), if( strnicmp( line, "Title", 2 ) == 0 ) { ReadDelimitedText( buf, line, 256 ); - aScreen->m_Title = FROM_UTF8( buf ); + tb.SetTitle( FROM_UTF8( buf ) ); continue; } if( strnicmp( line, "Date", 2 ) == 0 ) { ReadDelimitedText( buf, line, 256 ); - aScreen->m_Date = FROM_UTF8( buf ); + tb.SetDate( FROM_UTF8( buf ) ); continue; } if( strnicmp( line, "Rev", 2 ) == 0 ) { ReadDelimitedText( buf, line, 256 ); - aScreen->m_Revision = FROM_UTF8( buf ); + tb.SetRevision( FROM_UTF8( buf ) ); continue; } if( strnicmp( line, "Comp", 4 ) == 0 ) { ReadDelimitedText( buf, line, 256 ); - aScreen->m_Company = FROM_UTF8( buf ); + tb.SetCompany( FROM_UTF8( buf ) ); continue; } if( strnicmp( line, "Comment1", 8 ) == 0 ) { ReadDelimitedText( buf, line, 256 ); - aScreen->m_Commentaire1 = FROM_UTF8( buf ); + tb.SetComment1( FROM_UTF8( buf ) ); continue; } if( strnicmp( line, "Comment2", 8 ) == 0 ) { ReadDelimitedText( buf, line, 256 ); - aScreen->m_Commentaire2 = FROM_UTF8( buf ); + tb.SetComment2( FROM_UTF8( buf ) ); continue; } if( strnicmp( line, "Comment3", 8 ) == 0 ) { ReadDelimitedText( buf, line, 256 ); - aScreen->m_Commentaire3 = FROM_UTF8( buf ); + tb.SetComment3( FROM_UTF8( buf ) ); continue; } if( strnicmp( line, "Comment4", 8 ) == 0 ) { ReadDelimitedText( buf, line, 256 ); - aScreen->m_Commentaire4 = FROM_UTF8( buf ); + tb.SetComment4( FROM_UTF8( buf ) ); continue; } } diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp new file mode 100644 index 0000000000..9cc0492977 --- /dev/null +++ b/eeschema/sch_base_frame.cpp @@ -0,0 +1,78 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck + * Copyright (C) 2012 KiCad Developers, see change_log.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include + + +SCH_SCREEN* SCH_BASE_FRAME::GetScreen() const +{ + return (SCH_SCREEN*) EDA_DRAW_FRAME::GetScreen(); +} + + +void SCH_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings ) +{ + GetScreen()->SetPageSettings( aPageSettings ); +} + + +const PAGE_INFO& SCH_BASE_FRAME::GetPageSettings () const +{ + return GetScreen()->GetPageSettings(); +} + + +const wxSize SCH_BASE_FRAME::GetPageSizeIU() const +{ + // GetSizeIU is compile time dependent: + return GetScreen()->GetPageSettings().GetSizeIU(); +} + + +const wxPoint& SCH_BASE_FRAME::GetOriginAxisPosition() const +{ + wxASSERT( GetScreen() ); + return GetScreen()->GetOriginAxisPosition(); +} + + +void SCH_BASE_FRAME::SetOriginAxisPosition( const wxPoint& aPosition ) +{ + wxASSERT( GetScreen() ); + GetScreen()->SetOriginAxisPosition( aPosition ); +} + + +const TITLE_BLOCK& SCH_BASE_FRAME::GetTitleBlock() const +{ + wxASSERT( GetScreen() ); + return GetScreen()->GetTitleBlock(); +} + + +void SCH_BASE_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) +{ + wxASSERT( GetScreen() ); + GetScreen()->SetTitleBlock( aTitleBlock ); +} diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 5ddff19a21..58048a22d2 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -150,14 +150,9 @@ void SCH_SCREEN::Clear() /* Clear the project settings. */ m_ScreenNumber = m_NumberOfScreen = 1; - m_Title.Empty(); - m_Revision.Empty(); - m_Company.Empty(); - m_Commentaire1.Empty(); - m_Commentaire2.Empty(); - m_Commentaire3.Empty(); - m_Commentaire4.Empty(); - m_Date = GenDate(); + + m_titles.Clear(); + m_titles.SetDate(); } @@ -574,19 +569,20 @@ bool SCH_SCREEN::Save( FILE* aFile ) const * simple hierarchy and flat hierarchy. Used also to search the root * sheet ( ScreenNumber = 1 ) within the files */ + const TITLE_BLOCK& tb = GetTitleBlock(); 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 - || fprintf( aFile, "Date %s\n", EscapedUTF8( m_Date ).c_str() ) < 0 - || fprintf( aFile, "Rev %s\n", EscapedUTF8( m_Revision ).c_str() ) < 0 - || fprintf( aFile, "Comp %s\n", EscapedUTF8( m_Company ).c_str() ) < 0 - || fprintf( aFile, "Comment1 %s\n", EscapedUTF8( m_Commentaire1 ).c_str() ) < 0 - || fprintf( aFile, "Comment2 %s\n", EscapedUTF8( m_Commentaire2 ).c_str() ) < 0 - || fprintf( aFile, "Comment3 %s\n", EscapedUTF8( m_Commentaire3 ).c_str() ) < 0 - || fprintf( aFile, "Comment4 %s\n", EscapedUTF8( m_Commentaire4 ).c_str() ) < 0 + || fprintf( aFile, "Title %s\n", EscapedUTF8( tb.GetTitle() ).c_str() ) < 0 + || fprintf( aFile, "Date %s\n", EscapedUTF8( tb.GetDate() ).c_str() ) < 0 + || fprintf( aFile, "Rev %s\n", EscapedUTF8( tb.GetRevision() ).c_str() ) < 0 + || fprintf( aFile, "Comp %s\n", EscapedUTF8( tb.GetCompany() ).c_str() ) < 0 + || fprintf( aFile, "Comment1 %s\n", EscapedUTF8( tb.GetComment1() ).c_str() ) < 0 + || fprintf( aFile, "Comment2 %s\n", EscapedUTF8( tb.GetComment2() ).c_str() ) < 0 + || fprintf( aFile, "Comment3 %s\n", EscapedUTF8( tb.GetComment3() ).c_str() ) < 0 + || fprintf( aFile, "Comment4 %s\n", EscapedUTF8( tb.GetComment4() ).c_str() ) < 0 || fprintf( aFile, "$EndDescr\n" ) < 0 ) return false; @@ -1492,7 +1488,11 @@ int SCH_SCREENS::ReplaceDuplicateTimeStamps() void SCH_SCREENS::SetDate( const wxString& aDate ) { for( size_t i = 0; i < m_screens.size(); i++ ) - m_screens[i]->m_Date = aDate; + { + TITLE_BLOCK tb = m_screens[i]->GetTitleBlock(); + tb.SetDate( aDate ); + m_screens[i]->SetTitleBlock( tb ); + } } diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 273a614d26..4a16a57b4a 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -183,7 +183,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* father, const wxPoint& pos, const wxSize& size, long style ) : - EDA_DRAW_FRAME( father, SCHEMATIC_FRAME, title, pos, size, style ) + SCH_BASE_FRAME( father, SCHEMATIC_FRAME, title, pos, size, style ) { m_FrameName = wxT( "SchematicFrame" ); m_showAxis = false; // true to show axis @@ -285,39 +285,6 @@ 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(); @@ -383,7 +350,11 @@ void SCH_EDIT_FRAME::CreateScreens() } g_RootSheet->GetScreen()->SetFileName( m_DefaultSchematicFileName ); - g_RootSheet->GetScreen()->m_Date = GenDate(); + + TITLE_BLOCK tb = g_RootSheet->GetScreen()->GetTitleBlock(); + tb.SetDate(); + g_RootSheet->GetScreen()->SetTitleBlock( tb ); + m_CurrentSheet->Clear(); m_CurrentSheet->Push( g_RootSheet ); @@ -581,7 +552,6 @@ void SCH_EDIT_FRAME::OnModify() if( m_dlgFindReplace == NULL ) m_foundItems.SetForceSearch(); - wxString date = GenDate(); SCH_SCREENS s_list; // Set the date for each sheet @@ -589,10 +559,7 @@ void SCH_EDIT_FRAME::OnModify() // >> change only the current sheet // >> change all sheets. // I believe all sheets in a project must have the same date - SCH_SCREEN* screen = s_list.GetFirst(); - - for( ; screen != NULL; screen = s_list.GetNext() ) - screen->m_Date = date; + s_list.SetDate(); } diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index a9a3d50b99..e3f7915221 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -100,7 +100,7 @@ static wxAcceleratorEntry accels[] = LIB_VIEW_FRAME::LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library, wxSemaphore* semaphore ) : - EDA_DRAW_FRAME( father, VIEWER_FRAME, _( "Library Browser" ), + SCH_BASE_FRAME( father, VIEWER_FRAME, _( "Library Browser" ), wxDefaultPosition, wxDefaultSize ) { wxAcceleratorTable table( ACCEL_TABLE_CNT, accels ); @@ -265,39 +265,6 @@ 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 89866393ab..ff3630e06e 100644 --- a/eeschema/viewlib_frame.h +++ b/eeschema/viewlib_frame.h @@ -27,14 +27,14 @@ * @file viewlib_frame.h */ -#ifndef __LIBVIEWFRM_H__ -#define __LIBVIEWFRM_H__ +#ifndef LIBVIEWFRM_H_ +#define LIBVIEWFRM_H_ #include -#include "wxstruct.h" -#include "class_sch_screen.h" +#include +#include class wxSashLayoutWindow; class wxListBox; @@ -45,7 +45,7 @@ class CMP_LIBRARY; /** * Component library viewer main window. */ -class LIB_VIEW_FRAME : public EDA_DRAW_FRAME +class LIB_VIEW_FRAME : public SCH_BASE_FRAME { private: wxComboBox* SelpartBox; @@ -107,18 +107,6 @@ public: void ClickOnCmpList( wxCommandEvent& event ); void OnSetRelativeOffset( wxCommandEvent& event ); - 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 ); /** @@ -167,4 +155,4 @@ private: DECLARE_EVENT_TABLE() }; -#endif /* __LIBVIEWFRM_H__ */ +#endif // LIBVIEWFRM_H_ diff --git a/include/class_base_screen.h b/include/class_base_screen.h index 786180e6d7..e49b0fe37a 100644 --- a/include/class_base_screen.h +++ b/include/class_base_screen.h @@ -74,15 +74,16 @@ typedef std::vector< GRID_TYPE > GRIDS; */ class BASE_SCREEN : public EDA_ITEM { - GRIDS m_grids; ///< List of valid grid sizes. - wxString m_fileName; ///< File used to load the screen. - char m_FlagRefreshReq; ///< Indicates that the screen should be redrawn. - bool m_FlagModified; ///< Indicates current drawing has been modified. - bool m_FlagSave; ///< Indicates automatic file save. - EDA_ITEM* m_CurrentItem; ///< Currently selected object - GRID_TYPE m_Grid; ///< Current grid selection. - wxPoint m_scrollCenter; ///< Current scroll center point in logical units. - wxPoint m_MousePosition; ///< Mouse cursor coordinate in logical units. + GRIDS m_grids; ///< List of valid grid sizes. + wxString m_fileName; ///< File used to load the screen. + char m_FlagRefreshReq; ///< Indicates that the screen should be redrawn. + bool m_FlagModified; ///< Indicates current drawing has been modified. + bool m_FlagSave; ///< Indicates automatic file save. + EDA_ITEM* m_CurrentItem; ///< Currently selected object + GRID_TYPE m_Grid; ///< Current grid selection. + wxPoint m_scrollCenter; ///< Current scroll center point in logical units. + wxPoint m_MousePosition; ///< Mouse cursor coordinate in logical units. + /** * The cross hair position in logical (drawing) units. The cross hair is not the cursor @@ -132,15 +133,6 @@ public: int m_ScreenNumber; int m_NumberOfScreen; - wxString m_Title; - wxString m_Date; - wxString m_Revision; - wxString m_Company; - wxString m_Commentaire1; - wxString m_Commentaire2; - wxString m_Commentaire3; - wxString m_Commentaire4; - wxPoint m_GridOrigin; wxArrayDouble m_ZoomList; ///< Array of standard zoom (i.e. scale) coefficients. diff --git a/include/class_sch_screen.h b/include/class_sch_screen.h index 5127e2e8fb..0dfd7e3ace 100644 --- a/include/class_sch_screen.h +++ b/include/class_sch_screen.h @@ -34,6 +34,7 @@ #include "macros.h" #include "sch_item_struct.h" #include "class_base_screen.h" +#include "class_title_block.h" #include "../eeschema/general.h" @@ -67,6 +68,8 @@ class SCH_SCREEN : public BASE_SCREEN /// The size of the paper to print or plot on PAGE_INFO m_paper; // keep with the MVC 'model' if this class gets split + TITLE_BLOCK m_titles; + /// Position of the origin axis, which is used in exports mostly, but not yet in EESCHEMA wxPoint m_originAxisPosition; @@ -105,6 +108,10 @@ public: const wxPoint& GetOriginAxisPosition() const { return m_originAxisPosition; } void SetOriginAxisPosition( const wxPoint& aPosition ) { m_originAxisPosition = aPosition; } + const TITLE_BLOCK& GetTitleBlock() const { return m_titles; } + //TITLE_BLOCK& GetTitleBlock() const { return (TITLE_BLOCK&) m_titles; } + void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) { m_titles = aTitleBlock; } + void DecRefCount(); void IncRefCount(); @@ -521,7 +528,7 @@ public: * @see GetDate() * @param aDate The date string to set for each screen. */ - void SetDate( const wxString& aDate ); + void SetDate( const wxString& aDate = GenDate() ); /** * Function DeleteAllMarkers diff --git a/include/class_title_block.h b/include/class_title_block.h new file mode 100644 index 0000000000..9813af0c52 --- /dev/null +++ b/include/class_title_block.h @@ -0,0 +1,95 @@ +#ifndef TITLE_BLOCK_H_ +#define TITLE_BLOCK_H_ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include + + +extern wxString GenDate(); + + +/** + * Class TITLE_BLOCK + * holds the information shown in the lower right corner of a plot, printout, or + * editing view. + * + * @author Dick Hollenbeck + */ +class TITLE_BLOCK +{ +public: + // TITLE_BLOCK(); + + void SetTitle( const wxString& aTitle ) { m_title = aTitle; } + const wxString& GetTitle() const { return m_title; } + + /** + * Function SetDate + * sets the date field, and defaults to the current time and date. + */ + void SetDate( const wxString& aDate = GenDate() ) { m_date = aDate; } + const wxString& GetDate() const { return m_date; } + + void SetRevision( const wxString& aRevision ) { m_revision = aRevision; } + const wxString& GetRevision() const { return m_revision; } + + void SetCompany( const wxString& aCompany ) { m_company = aCompany; } + const wxString& GetCompany() const { return m_company; } + + void SetComment1( const wxString& aComment ) { m_comment1 = aComment; } + const wxString& GetComment1() const { return m_comment1; } + + void SetComment2( const wxString& aComment ) { m_comment2 = aComment; } + const wxString& GetComment2() const { return m_comment2; } + + void SetComment3( const wxString& aComment ) { m_comment3 = aComment; } + const wxString& GetComment3() const { return m_comment3; } + + void SetComment4( const wxString& aComment ) { m_comment4 = aComment; } + const wxString& GetComment4() const { return m_comment4; } + + void Clear() + { + m_title.clear(); + m_date.clear(); + m_revision.clear(); + m_company.clear(); + m_comment1.clear(); + m_comment2.clear(); + m_comment3.clear(); + m_comment4.clear(); + } + +private: + wxString m_title; + wxString m_date; + wxString m_revision; + wxString m_company; + wxString m_comment1; + wxString m_comment2; + wxString m_comment3; + wxString m_comment4; +}; + +#endif // TITLE_BLOCK_H_ diff --git a/include/hashtables.h b/include/hashtables.h new file mode 100644 index 0000000000..35de30f753 --- /dev/null +++ b/include/hashtables.h @@ -0,0 +1,35 @@ +#ifndef HASHTABLES_H_ +#define HASHTABLES_H_ + +// Declare some hashtables using a MACRO techique from here: +// http://docs.wxwidgets.org/trunk/classwx_hash_map.html +// This simplifies finding the correct hashtable header file. +// Ideally, std::unordered_map is what we are trying to use here, +// but its header file has been a moving target for some time. +// Let wx figure it out. +#include + +/** + * Class PROPERTIES + * is an associative array consisting of a key and value tuple. + */ +#if 1 + // key: const char* + // value: wxString + WX_DECLARE_HASH_MAP( char*, wxString, wxStringHash, wxStringEqual, PROPERTIES ); +#else + // key: wxString + // value: wxString + WX_DECLARE_STRING_HASH_MAP( wxString, PROPERTIES ); +#endif + + +/** + * Class KEYWORD_MAP + * is a hashtable consisting of a key and a value tuple. + * Key is a C string and value is an integer. + */ +//WX_DECLARE_HASH_MAP( char*, int, wxStringHash, wxStringEqual, KEYWORD_MAP ); + + +#endif // HASHTABLES_H_ diff --git a/include/richio.h b/include/richio.h index f9ad65f1f6..83e328d8d3 100644 --- a/include/richio.h +++ b/include/richio.h @@ -1,4 +1,5 @@ - +#ifndef RICHIO_H_ +#define RICHIO_H_ /* * This program source code file is part of KiCad, a free EDA CAD application. * @@ -23,9 +24,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef RICHIO_H_ -#define RICHIO_H_ - // This file defines 3 classes useful for working with DSN text files and is named // "richio" after its author, Richard Hollenbeck, aka Dick Hollenbeck. diff --git a/include/sch_base_frame.h b/include/sch_base_frame.h new file mode 100644 index 0000000000..d8cd707f29 --- /dev/null +++ b/include/sch_base_frame.h @@ -0,0 +1,69 @@ +#ifndef SCH_BASE_FRAME_H_ +#define SCH_BASE_FRAME_H_ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck + * Copyright (C) 2012 KiCad Developers, see change_log.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include + +class PAGE_INFO; +class TITLE_BLOCK; + + +/** + * Class SCH_BASE_FRAME + * is a shim class between EDA_DRAW_FRAME and several derived classes: + * LIB_EDIT_FRAME, LIB_VIEW_FRAME, and SCH_EDIT_FRAME, and it brings in a + * common way of handling the provided virtual functions for the derived classes. + *

+ * The motivation here is to switch onto GetScreen() for the underlying data model. + * + * @author Dick Hollenbeck + */ +class SCH_BASE_FRAME : public EDA_DRAW_FRAME +{ +public: + SCH_BASE_FRAME( wxWindow* aParent, + id_drawframe aWindowType, + const wxString& aTitle, + const wxPoint& aPosition, const wxSize& aSize, + long aStyle = KICAD_DEFAULT_DRAWFRAME_STYLE ) : + EDA_DRAW_FRAME( aParent, aWindowType, aTitle, aPosition, aSize, aStyle ) + { + } + + SCH_SCREEN* GetScreen() const; // overload EDA_DRAW_FRAME + + 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 + + const TITLE_BLOCK& GetTitleBlock() const; // overload EDA_DRAW_FRAME + void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ); // overload EDA_DRAW_FRAME +}; + +#endif // SCH_BASE_FRAME_H_ diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index 8848bd1654..003a8fc666 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -119,6 +119,9 @@ public: const wxPoint& GetOriginAxisPosition() const; // overload void SetOriginAxisPosition( const wxPoint& aPosition ); // overload + const TITLE_BLOCK& GetTitleBlock() const; // overload + void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ); // overload + /** * Function SetBoard * sets the m_Pcb member in such as way as to ensure deleting any previous diff --git a/include/wxEeschemaStruct.h b/include/wxEeschemaStruct.h index 1ae678bb48..c5a5a7f281 100644 --- a/include/wxEeschemaStruct.h +++ b/include/wxEeschemaStruct.h @@ -30,7 +30,7 @@ #ifndef WX_EESCHEMA_STRUCT_H #define WX_EESCHEMA_STRUCT_H -#include "wxstruct.h" +#include "sch_base_frame.h" #include "param_config.h" #include "class_undoredo_container.h" #include "template_fieldnames.h" @@ -110,7 +110,7 @@ enum SCH_SEARCH_T { /** * Schematic editor (Eeschema) main window. */ -class SCH_EDIT_FRAME : public EDA_DRAW_FRAME +class SCH_EDIT_FRAME : public SCH_BASE_FRAME { private: SCH_SHEET_PATH* m_CurrentSheet; ///< which sheet we are presently working on. @@ -198,6 +198,8 @@ public: ~SCH_EDIT_FRAME(); + SCH_SCREEN* GetScreen() const; // overload SCH_BASE_FRAME + void OnCloseWindow( wxCloseEvent& Event ); void SetLibraryEditorWindow( LIB_EDIT_FRAME* aFrame ) { m_LibeditFrame = aFrame; } @@ -348,22 +350,6 @@ public: */ void OnModify(); - 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 9f7348830b..0959be7eb4 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -28,8 +28,8 @@ * @brief Base window classes and related definitions. */ -#ifndef WXSTRUCT_H -#define WXSTRUCT_H +#ifndef WXSTRUCT_H_ +#define WXSTRUCT_H_ #include @@ -74,6 +74,7 @@ class BASE_SCREEN; class PARAM_CFG_BASE; class PAGE_INFO; class PLOTTER; +class TITLE_BLOCK; enum id_librarytype { LIBRARY_TYPE_EESCHEMA, @@ -462,6 +463,9 @@ public: virtual const wxPoint& GetOriginAxisPosition() const = 0; virtual void SetOriginAxisPosition( const wxPoint& aPosition ) = 0; + virtual const TITLE_BLOCK& GetTitleBlock() const = 0; + virtual void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) = 0; + int GetCursorShape() const { return m_cursorShape; } void SetCursorShape( int aCursorShape ) { m_cursorShape = aCursorShape; } @@ -1173,4 +1177,4 @@ public: }; -#endif /* WXSTRUCT_H */ +#endif // WXSTRUCT_H_ diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index a6b3f3683c..a00eed95d3 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -168,6 +168,20 @@ void PCB_BASE_FRAME::SetOriginAxisPosition( const wxPoint& aPosition ) } +const TITLE_BLOCK& PCB_BASE_FRAME::GetTitleBlock() const +{ + wxASSERT( m_Pcb ); + return m_Pcb->GetTitleBlock(); +} + + +void PCB_BASE_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) +{ + wxASSERT( m_Pcb ); + m_Pcb->SetTitleBlock( aTitleBlock ); +} + + EDA_RECT PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const { wxASSERT( m_Pcb ); @@ -618,11 +632,13 @@ void PCB_BASE_FRAME::SaveSettings() } -void PCB_BASE_FRAME::OnModify( ) +void PCB_BASE_FRAME::OnModify() { GetScreen()->SetModify(); GetScreen()->SetSave(); - GetScreen()->m_Date = GenDate(); + + wxASSERT( m_Pcb ); + m_Pcb->GetTitleBlock().SetDate(); } diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index 0726abb040..2666dcc4ef 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -15,6 +15,7 @@ #include "class_colors_design_settings.h" #include "class_board_design_settings.h" #include "common.h" // PAGE_INFO +#include "class_title_block.h" class PCB_BASE_FRAME; class PCB_EDIT_FRAME; @@ -173,8 +174,9 @@ private: NETINFO_LIST m_NetInfo; ///< net info list (name, design constraints .. BOARD_DESIGN_SETTINGS m_designSettings; - COLORS_DESIGN_SETTINGS* m_colorsSettings; // Link to current colors settings + COLORS_DESIGN_SETTINGS* m_colorsSettings; PAGE_INFO m_paper; + TITLE_BLOCK m_titles; ///< text in lower right of screen and plots /// Position of the origin axis, which is used in exports mostly wxPoint m_originAxisPosition; @@ -544,6 +546,9 @@ public: const wxPoint& GetOriginAxisPosition() const { return m_originAxisPosition; } void SetOriginAxisPosition( const wxPoint& aPosition ) { m_originAxisPosition = aPosition; } + TITLE_BLOCK& GetTitleBlock() { return m_titles; } + void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) { m_titles = aTitleBlock; } + /** * Function SetBoardSettings * @return the current COLORS_DESIGN_SETTINGS in use diff --git a/pcbnew/export_gencad.cpp b/pcbnew/export_gencad.cpp index 3fb0755ddb..627c33283f 100644 --- a/pcbnew/export_gencad.cpp +++ b/pcbnew/export_gencad.cpp @@ -683,12 +683,11 @@ static void CreateSignalsSection( FILE* aFile, BOARD* aPcb ) } -/* Creates the header section; some of the data come from the frame - * (actually the screen), not from the pcb */ +// Creates the header section static bool CreateHeaderInfoData( FILE* aFile, PCB_EDIT_FRAME* aFrame ) { wxString msg; - PCB_SCREEN* screen = (PCB_SCREEN*) ( aFrame->GetScreen() ); + PCB_SCREEN* screen = (PCB_SCREEN*) aFrame->GetScreen(); fputs( "$HEADER\n", aFile ); fputs( "GENCAD 1.4\n", aFile ); @@ -698,16 +697,22 @@ static bool CreateHeaderInfoData( FILE* aFile, PCB_EDIT_FRAME* aFrame ) GetChars( wxGetApp().GetAppName() ), GetChars( GetBuildVersion() ) ); fputs( TO_UTF8( msg ), aFile ); + msg = wxT( "DRAWING \"" ) + screen->GetFileName() + wxT( "\"\n" ); fputs( TO_UTF8( msg ), aFile ); - msg = wxT( "REVISION \"" ) + screen->m_Revision + wxT( " " ) + - screen->m_Date + wxT( "\"\n" ); + + const TITLE_BLOCK& tb = aFrame->GetTitleBlock(); + + msg = wxT( "REVISION \"" ) + tb.GetRevision() + wxT( " " ) + tb.GetDate() + wxT( "\"\n" ); + fputs( TO_UTF8( msg ), aFile ); fputs( "UNITS INCH\n", aFile ); + msg.Printf( wxT( "ORIGIN %g %g\n" ), MapXTo( aFrame->GetOriginAxisPosition().x ), MapYTo( aFrame->GetOriginAxisPosition().y ) ); fputs( TO_UTF8( msg ), aFile ); + fputs( "INTERTRACK 0\n", aFile ); fputs( "$ENDHEADER\n\n", aFile ); diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 443acc836d..029d4f0cf5 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -420,10 +420,13 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF GetScreen()->SetFileName( aFileName ); } - /* If changes are made, update the board date */ + // If changes are made, update the board date if( GetScreen()->IsModify() ) { - GetScreen()->m_Date = GenDate(); + TITLE_BLOCK tb = GetTitleBlock(); + + tb.SetDate(); + SetTitleBlock( tb ); } pcbFileName = GetScreen()->GetFileName(); @@ -480,9 +483,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF PROPERTIES props; - // wanting wxWidgets 2.9.x which can actually create a wxString() from - // a const char*, so don't have to use wxT() - props[ wxT("header") ] = header; + props["header"] = header; IO_MGR::Save( IO_MGR::KICAD, pcbFileName.GetFullPath(), GetBoard(), &props ); } diff --git a/pcbnew/io_mgr.h b/pcbnew/io_mgr.h index 92c8cb575c..1f3fa70393 100644 --- a/pcbnew/io_mgr.h +++ b/pcbnew/io_mgr.h @@ -25,13 +25,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include -#include #include - - -// http://docs.wxwidgets.org/trunk/classwx_hash_map.html -WX_DECLARE_STRING_HASH_MAP( wxString, PROPERTIES ); +#include class BOARD; class PLUGIN; diff --git a/pcbnew/ioascii.cpp b/pcbnew/ioascii.cpp index a02e17e59b..3133d54928 100644 --- a/pcbnew/ioascii.cpp +++ b/pcbnew/ioascii.cpp @@ -838,7 +838,7 @@ bool PCB_EDIT_FRAME::WriteGeneralDescrPcb( FILE* File ) * @param screen BASE_SCREEN to save * @param File = an open FILE to write info */ -static bool WriteSheetDescr( const PAGE_INFO& aPageSettings, BASE_SCREEN* screen, FILE* File ) +static bool WriteSheetDescr( const PAGE_INFO& aPageSettings, const TITLE_BLOCK& aTitleBlock, FILE* File ) { fprintf( File, "$SHEETDESCR\n" ); fprintf( File, "Sheet %s %d %d\n", @@ -846,14 +846,14 @@ static bool WriteSheetDescr( const PAGE_INFO& aPageSettings, BASE_SCREEN* screen aPageSettings.GetSizeMils().x, aPageSettings.GetSizeMils().y ); - fprintf( File, "Title %s\n", EscapedUTF8( screen->m_Title ).c_str() ); - fprintf( File, "Date %s\n", EscapedUTF8( screen->m_Date ).c_str() ); - fprintf( File, "Rev %s\n", EscapedUTF8( screen->m_Revision ).c_str() ); - fprintf( File, "Comp %s\n", EscapedUTF8( screen->m_Company ).c_str() ); - fprintf( File, "Comment1 %s\n", EscapedUTF8( screen->m_Commentaire1 ).c_str() ); - fprintf( File, "Comment2 %s\n", EscapedUTF8( screen->m_Commentaire2 ).c_str() ); - fprintf( File, "Comment3 %s\n", EscapedUTF8( screen->m_Commentaire3 ).c_str() ); - fprintf( File, "Comment4 %s\n", EscapedUTF8( screen->m_Commentaire4 ).c_str() ); + fprintf( File, "Title %s\n", EscapedUTF8( aTitleBlock.GetTitle() ).c_str() ); + fprintf( File, "Date %s\n", EscapedUTF8( aTitleBlock.GetDate() ).c_str() ); + fprintf( File, "Rev %s\n", EscapedUTF8( aTitleBlock.GetRevision() ).c_str() ); + fprintf( File, "Comp %s\n", EscapedUTF8( aTitleBlock.GetCompany() ).c_str() ); + fprintf( File, "Comment1 %s\n", EscapedUTF8( aTitleBlock.GetComment1() ).c_str() ); + fprintf( File, "Comment2 %s\n", EscapedUTF8( aTitleBlock.GetComment2() ).c_str() ); + fprintf( File, "Comment3 %s\n", EscapedUTF8( aTitleBlock.GetComment3() ).c_str() ); + fprintf( File, "Comment4 %s\n", EscapedUTF8( aTitleBlock.GetComment4() ).c_str() ); fprintf( File, "$EndSHEETDESCR\n\n" ); return true; @@ -862,16 +862,20 @@ static bool WriteSheetDescr( const PAGE_INFO& aPageSettings, BASE_SCREEN* screen #if !defined( USE_NEW_PCBNEW_LOAD ) -static bool ReadSheetDescr( BOARD* aBoard, BASE_SCREEN* screen, LINE_READER* aReader ) +static bool ReadSheetDescr( BOARD* aBoard, LINE_READER* aReader ) { - char buf[1024]; + char buf[1024]; + TITLE_BLOCK tb; while( aReader->ReadLine() ) { char* line = aReader->Line(); if( strnicmp( line, "$End", 4 ) == 0 ) + { + aBoard->SetTitleBlock( tb ); return true; + } if( strnicmp( line, "Sheet", 4 ) == 0 ) { @@ -920,56 +924,56 @@ static bool ReadSheetDescr( BOARD* aBoard, BASE_SCREEN* screen, LINE_READER* aRe if( strnicmp( line, "Title", 2 ) == 0 ) { ReadDelimitedText( buf, line, 256 ); - screen->m_Title = FROM_UTF8( buf ); + tb.SetTitle( FROM_UTF8( buf ) ); continue; } if( strnicmp( line, "Date", 2 ) == 0 ) { ReadDelimitedText( buf, line, 256 ); - screen->m_Date = FROM_UTF8( buf ); + tb.SetDate( FROM_UTF8( buf ) ); continue; } if( strnicmp( line, "Rev", 2 ) == 0 ) { ReadDelimitedText( buf, line, 256 ); - screen->m_Revision = FROM_UTF8( buf ); + tb.SetRevision( FROM_UTF8( buf ) ); continue; } if( strnicmp( line, "Comp", 4 ) == 0 ) { ReadDelimitedText( buf, line, 256 ); - screen->m_Company = FROM_UTF8( buf ); + tb.SetCompany( FROM_UTF8( buf ) ); continue; } if( strnicmp( line, "Comment1", 8 ) == 0 ) { ReadDelimitedText( buf, line, 256 ); - screen->m_Commentaire1 = FROM_UTF8( buf ); + tb.SetComment1( FROM_UTF8( buf ) ); continue; } if( strnicmp( line, "Comment2", 8 ) == 0 ) { ReadDelimitedText( buf, line, 256 ); - screen->m_Commentaire2 = FROM_UTF8( buf ); + tb.SetComment2( FROM_UTF8( buf ) ); continue; } if( strnicmp( line, "Comment3", 8 ) == 0 ) { ReadDelimitedText( buf, line, 256 ); - screen->m_Commentaire3 = FROM_UTF8( buf ); + tb.SetComment3( FROM_UTF8( buf ) ); continue; } if( strnicmp( line, "Comment4", 8 ) == 0 ) { ReadDelimitedText( buf, line, 256 ); - screen->m_Commentaire4 = FROM_UTF8( buf ); + tb.SetComment4( FROM_UTF8( buf ) ); continue; } } @@ -1111,7 +1115,7 @@ int PCB_EDIT_FRAME::ReadPcbFile( LINE_READER* aReader, bool Append ) if( TESTLINE( "SHEETDESCR" ) ) { - ReadSheetDescr( board, GetScreen(), aReader ); + ReadSheetDescr( board, aReader ); continue; } @@ -1187,7 +1191,7 @@ int PCB_EDIT_FRAME::SavePcbFormatAscii( FILE* aFile ) GetBoard()->SetCurrentNetClass( GetBoard()->m_NetClasses.GetDefault()->GetName() ); WriteGeneralDescrPcb( aFile ); - WriteSheetDescr( GetBoard()->GetPageSettings(), GetScreen(), aFile ); + WriteSheetDescr( GetBoard()->GetPageSettings(), GetBoard()->GetTitleBlock(), aFile ); WriteSetup( aFile, this, GetBoard() ); rc = GetBoard()->Save( aFile ); diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index 0b3a95914e..e1061d4638 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -439,7 +439,8 @@ void KICAD_PLUGIN::loadGENERAL() void KICAD_PLUGIN::loadSHEET() { - char buf[260]; + char buf[260]; + TITLE_BLOCK tb; while( READLINE() ) { @@ -488,56 +489,56 @@ void KICAD_PLUGIN::loadSHEET() else if( TESTLINE( "Title" ) ) { ReadDelimitedText( buf, line, sizeof(buf) ); - -#if 0 // @todo "screen" not available here - screen->m_Title = FROM_UTF8( buf ); + tb.SetTitle( FROM_UTF8( buf ) ); } else if( TESTLINE( "Date" ) ) { ReadDelimitedText( buf, line, sizeof(buf) ); - screen->m_Date = FROM_UTF8( buf ); + tb.SetDate( FROM_UTF8( buf ) ); } else if( TESTLINE( "Rev" ) ) { ReadDelimitedText( buf, line, sizeof(buf) ); - screen->m_Revision = FROM_UTF8( buf ); + tb.SetRevision( FROM_UTF8( buf ) ); } else if( TESTLINE( "Comp" ) ) { ReadDelimitedText( buf, line, sizeof(buf) ); - screen->m_Company = FROM_UTF8( buf ); + tb.SetCompany( FROM_UTF8( buf ) ); } else if( TESTLINE( "Comment1" ) ) { ReadDelimitedText( buf, line, sizeof(buf) ); - screen->m_Commentaire1 = FROM_UTF8( buf ); + tb.SetComment1( FROM_UTF8( buf ) ); } else if( TESTLINE( "Comment2" ) ) { ReadDelimitedText( buf, line, sizeof(buf) ); - screen->m_Commentaire2 = FROM_UTF8( buf ); + tb.SetComment2( FROM_UTF8( buf ) ); } else if( TESTLINE( "Comment3" ) ) { ReadDelimitedText( buf, line, sizeof(buf) ); - screen->m_Commentaire3 = FROM_UTF8( buf ); + tb.SetComment3( FROM_UTF8( buf ) ); } else if( TESTLINE( "Comment4" ) ) { ReadDelimitedText( buf, line, sizeof(buf) ); - screen->m_Commentaire4 = FROM_UTF8( buf ); -#endif + tb.SetComment4( FROM_UTF8( buf ) ); } else if( TESTLINE( "$EndSHEETDESCR" ) ) + { + m_board->SetTitleBlock( tb ); return; // preferred exit + } } THROW_IO_ERROR( "Missing '$EndSHEETDESCR'" ); @@ -2654,7 +2655,7 @@ void KICAD_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* a if( m_props ) { // save a file header, if caller provided one (with trailing \n hopefully). - fprintf( m_fp, "%s", TO_UTF8( (*m_props)[ wxT("header") ] ) ); + fprintf( m_fp, "%s", TO_UTF8( (*m_props)["header"] ) ); } saveAllSections(); @@ -2733,7 +2734,8 @@ void KICAD_PLUGIN::saveGENERAL() const void KICAD_PLUGIN::saveSHEET() const { - const PAGE_INFO& pageInfo = m_board->GetPageSettings(); + const PAGE_INFO& pageInfo = m_board->GetPageSettings(); + const TITLE_BLOCK& tb = m_board->GetTitleBlock(); fprintf( m_fp, "$SHEETDESCR\n" ); @@ -2743,18 +2745,14 @@ void KICAD_PLUGIN::saveSHEET() const pageInfo.GetSizeMils().x, pageInfo.GetSizeMils().y ); -#if 0 // @todo sheet not available here. The sheet needs to go into the board if it is important enough to be saved with the board - fprintf( m_fp, "Title %s\n", EscapedUTF8( screen->m_Title ).c_str() ); - fprintf( m_fp, "Date %s\n", EscapedUTF8( screen->m_Date ).c_str() ); - fprintf( m_fp, "Rev %s\n", EscapedUTF8( screen->m_Revision ).c_str() ); - fprintf( m_fp, "Comp %s\n", EscapedUTF8( screen->m_Company ).c_str() ); - fprintf( m_fp, "Comment1 %s\n", EscapedUTF8( screen->m_Commentaire1 ).c_str() ); - fprintf( m_fp, "Comment2 %s\n", EscapedUTF8( screen->m_Commentaire2 ).c_str() ); - fprintf( m_fp, "Comment3 %s\n", EscapedUTF8( screen->m_Commentaire3 ).c_str() ); - fprintf( m_fp, "Comment4 %s\n", EscapedUTF8( screen->m_Commentaire4 ).c_str() ); - -#endif - + fprintf( m_fp, "Title %s\n", EscapedUTF8( tb.GetTitle() ).c_str() ); + fprintf( m_fp, "Date %s\n", EscapedUTF8( tb.GetDate() ).c_str() ); + fprintf( m_fp, "Rev %s\n", EscapedUTF8( tb.GetRevision() ).c_str() ); + fprintf( m_fp, "Comp %s\n", EscapedUTF8( tb.GetCompany() ).c_str() ); + fprintf( m_fp, "Comment1 %s\n", EscapedUTF8( tb.GetComment1() ).c_str() ); + fprintf( m_fp, "Comment2 %s\n", EscapedUTF8( tb.GetComment2() ).c_str() ); + fprintf( m_fp, "Comment3 %s\n", EscapedUTF8( tb.GetComment3() ).c_str() ); + fprintf( m_fp, "Comment4 %s\n", EscapedUTF8( tb.GetComment4() ).c_str() ); fprintf( m_fp, "$EndSHEETDESCR\n\n" ); } diff --git a/pcbnew/pcb_plot_params.cpp b/pcbnew/pcb_plot_params.cpp index 3230f1e4c8..0cac29af90 100644 --- a/pcbnew/pcb_plot_params.cpp +++ b/pcbnew/pcb_plot_params.cpp @@ -29,6 +29,7 @@ #include "plot_common.h" #include "macros.h" + #define PLOT_LINEWIDTH_MIN 0 #define PLOT_LINEWIDTH_MAX 200 #define HPGL_PEN_DIAMETER_MIN 0 @@ -392,27 +393,28 @@ void PCB_PLOT_PARAMS_PARSER::Parse( PCB_PLOT_PARAMS* aPcbPlotParams ) throw( IO_ bool PCB_PLOT_PARAMS_PARSER::ParseBool() throw( IO_ERROR ) { - T token; - token = NeedSYMBOL(); + T token = NeedSYMBOL(); + if( token != T_false && token != T_true ) Expecting( "true|false" ); - return (token == T_true); + + return token == T_true; } int PCB_PLOT_PARAMS_PARSER::ParseInt( int aMin, int aMax ) throw( IO_ERROR ) { - T token; - int i; - token = NextTok(); + T token = NextTok(); + if( token != T_NUMBER ) Expecting( T_NUMBER ); - i = atoi( CurText() ); - if( i < aMin ) - i = aMin; - else if( i > aMax ) - i = aMax; + int val = atoi( CurText() ); - return i; + if( val < aMin ) + val = aMin; + else if( val > aMax ) + val = aMax; + + return val; } diff --git a/pcbnew/pcb_plot_params.h b/pcbnew/pcb_plot_params.h index 88203fdde7..bbeec353a4 100644 --- a/pcbnew/pcb_plot_params.h +++ b/pcbnew/pcb_plot_params.h @@ -1,4 +1,5 @@ - +#ifndef PCB_PLOT_PARAMS_H_ +#define PCB_PLOT_PARAMS_H_ /* * This program source code file is part of KiCad, a free EDA CAD application. * @@ -22,19 +23,12 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef PCB_PLOT_PARAMS_H_ -#define PCB_PLOT_PARAMS_H_ - #include -#include "base_struct.h" #include "pcb_plot_params_lexer.h" +#include "base_struct.h" -class PCB_PLOT_PARAMS; class PCB_PLOT_PARAMS_PARSER; -extern PCB_PLOT_PARAMS g_PcbPlotOptions; - - /** * Class PCB_PLOT_PARAMS * handles plot parameters and options when plotting/printing a board. @@ -43,31 +37,32 @@ class PCB_PLOT_PARAMS { friend class PCB_PLOT_PARAMS_PARSER; public: - bool m_ExcludeEdgeLayer; // True: do not plot edge layer when plotting other layers - // False: Edge layer always plotted (merged) when plotting other layers + bool m_ExcludeEdgeLayer; ///< True: do not plot edge layer when plotting other layers + ///< False: Edge layer always plotted (merged) when plotting other layers int m_PlotLineWidth; - bool m_PlotFrameRef; // True to plot/print frame references - bool m_PlotViaOnMaskLayer; // True if vias are drawn on Mask layer - // (ie protected by mask) - EDA_DRAW_MODE_T m_PlotMode; // LINE, FILLED or SKETCH: select how to plot filled objects. - // depending on plot format or layers, all options are not always allowed + bool m_PlotFrameRef; ///< True to plot/print frame references + bool m_PlotViaOnMaskLayer; ///< True if vias are drawn on Mask layer + ///< (ie protected by mask) + EDA_DRAW_MODE_T m_PlotMode; ///< LINE, FILLED or SKETCH: select how to plot filled objects. + ///< depending on plot format or layers, all options are not always allowed int m_HPGLPenNum; int m_HPGLPenSpeed; int m_HPGLPenDiam; int m_HPGLPenOvr; - int m_PlotPSColorOpt; // True for color Postscript output - bool m_PlotPSNegative; // True to create a negative board ps plot + int m_PlotPSColorOpt; ///< True for color Postscript output + bool m_PlotPSNegative; ///< True to create a negative board ps plot - // Flags to enable or disable ploting of various PCB elements. - bool m_SkipNPTH_Pads; // true to disable plot NPTH pads if hole and size have same value - // GERBER only + // Flags to enable or disable ploting of various PCB elements. + + bool m_SkipNPTH_Pads; ///< true to disable plot NPTH pads if hole and size have same value + ///< GERBER only bool m_PlotReference; bool m_PlotValue; bool m_PlotTextOther; bool m_PlotInvisibleTexts; - bool m_PlotPadsOnSilkLayer; // allows pads outlines on silkscreen layer (when pads are also o, silk screen + bool m_PlotPadsOnSilkLayer; ///< allows pads outlines on silkscreen layer (when pads are also o, silk screen - int m_PlotFormat; // id for plot format (see enum PlotFormat in plot_common.h) */ + int m_PlotFormat; ///< id for plot format (see enum PlotFormat in plot_common.h) */ bool m_PlotMirror; enum DrillShapeOptT { @@ -75,18 +70,21 @@ public: SMALL_DRILL_SHAPE = 1, FULL_DRILL_SHAPE = 2 }; - DrillShapeOptT m_DrillShapeOpt; // For postscript output: holes can be not plotted, - // or have a small size or plotted with their actual size - bool m_AutoScale; // If true, use the better scale to fit in page - double m_PlotScale; // The global scale factor. a 1.0 scale factor plot a board - // with its actual size. + DrillShapeOptT m_DrillShapeOpt; ///< For postscript output: holes can be not plotted, + ///< or have a small size or plotted with their actual size + bool m_AutoScale; ///< If true, use the better scale to fit in page + double m_PlotScale; ///< The global scale factor. a 1.0 scale factor plot a board + ///< with its actual size. // These next two scale factors are intended to compensable plotters (and mainly printers) X and Y scale error. // Therefore they are expected very near 1.0 // Only X and Y dimensions are adjusted: circles are plotted as circle, even if X and Y fine scale differ. - double m_FineScaleAdjustX; // fine scale adjust X axis - double m_FineScaleAdjustY; // dine scale adjust Y axis - // These width factor is intended to compensate plotters (and mainly printers) line width error. + + double m_FineScaleAdjustX; ///< fine scale adjust X axis + double m_FineScaleAdjustY; ///< dine scale adjust Y axis + + /// This width factor is intended to compensate printers and plotters that do + /// not strictly obey line width settings. double m_FineWidthAdjust; private: @@ -158,4 +156,7 @@ public: int ParseInt( int aMin, int aMax ) throw( IO_ERROR ); }; + +extern PCB_PLOT_PARAMS g_PcbPlotOptions; + #endif // PCB_PLOT_PARAMS_H_