diff --git a/CHANGELOG.txt b/CHANGELOG.txt index a2d9a4949f..b38753fc4f 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -5,6 +5,13 @@ Started 2007-June-11 Please add newer entries at the top, list the date and your name with email address. +2009-Jan-07 UPDATE Jean-Pierre Charras +================================================================================ +++Eeschema: + Print function now properly prints all sheets in a complex hierarchy + Note: plot functions are not updated and do not plot all sheets. + + 2009-Jan-07 UPDATE Wayne Stambaugh ================================================================================ ++all diff --git a/eeschema/class_drawsheetpath.cpp b/eeschema/class_drawsheetpath.cpp index 92d6411577..1a3e672962 100644 --- a/eeschema/class_drawsheetpath.cpp +++ b/eeschema/class_drawsheetpath.cpp @@ -1,27 +1,12 @@ ///////////////////////////////////////////////////////////////////////////// - // Name: class_drawsheet.cpp // Purpose: member functions for DrawSheetStruct // header = class_drawsheet.h // Author: jean-pierre Charras // Modified by: -// Created: 08/02/2006 18:37:02 -// RCS-ID: -// Copyright: // Licence: License GNU ///////////////////////////////////////////////////////////////////////////// -// For compilers that support precompilation, includes "wx/wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#ifndef WX_PRECOMP -#include "wx/wx.h" -#endif - #include "fctsys.h" #include "common.h" @@ -31,7 +16,7 @@ /**********************************************/ -/* class to handle a series of sheets *********/ +/* class to handle a serie of sheets *********/ /* a 'path' so to speak.. *********************/ /**********************************************/ DrawSheetPath::DrawSheetPath() @@ -42,6 +27,41 @@ DrawSheetPath::DrawSheetPath() m_numSheets = 0; } +/*********************************************************************************************/ +bool DrawSheetPath::BuildSheetPathInfoFromSheetPathValue(const wxString & aPath, bool aFound ) +/*********************************************************************************************/ +/** Function BuildSheetPathInfoFromSheetPathValue + * Fill this with data to acces to the hierarchical sheet known by its path aPath + * @param aPath = path of the sheet to reach (in non human readable format) + * @return true if success else false + */ +{ + if ( aFound ) + return true; + + if ( GetSheetsCount() == 0 ) + Push( g_RootSheet ); + + if ( aPath == Path() ) + return true; + + SCH_ITEM* schitem = LastDrawList(); + while( schitem && GetSheetsCount() < NB_MAX_SHEET ) + { + if( schitem->Type() == DRAW_SHEET_STRUCT_TYPE ) + { + DrawSheetStruct* sheet = (DrawSheetStruct*) schitem; + Push( sheet ); + if ( aPath == Path() ) + return true; + if ( BuildSheetPathInfoFromSheetPathValue( aPath ) ) + return true; + Pop(); + } + schitem = schitem->Next(); + } + return false; +} /*******************************************************************/ int DrawSheetPath::Cmp( const DrawSheetPath& aSheetPathToTest ) const @@ -59,7 +79,7 @@ int DrawSheetPath::Cmp( const DrawSheetPath& aSheetPathToTest ) const return -1; //otherwise, same number of sheets. - for( int i = 0; im_TimeStamp > aSheetPathToTest.m_sheets[i]->m_TimeStamp ) return 1; @@ -155,7 +175,7 @@ wxString DrawSheetPath::Path() //start at 1 to avoid the root sheet, //which does not need to be added to the path //it's timestamp changes anyway. - for( int i = 1; i< m_numSheets; i++ ) + for( unsigned i = 1; i< m_numSheets; i++ ) { t.Printf( _( "%8.8lX/" ), m_sheets[i]->m_TimeStamp ); s = s + t; @@ -180,7 +200,7 @@ wxString DrawSheetPath::PathHumanReadable() s = wxT( "/" ); //start at 1 to avoid the root sheet, as above. - for( int i = 1; i< m_numSheets; i++ ) + for( unsigned i = 1; i< m_numSheets; i++ ) { s = s + m_sheets[i]->m_SheetName + wxT( "/" ); } @@ -211,7 +231,7 @@ void DrawSheetPath::UpdateAllScreenReferences() bool DrawSheetPath::operator=( const DrawSheetPath& d1 ) { m_numSheets = d1.m_numSheets; - int i; + unsigned i; for( i = 0; iGetSelection(); *(m_Parent->m_CurrentSheet) = - ( (TreeItemData*) m_Tree->GetItemData( ItemSel ) )->m_SheetList; + ( (TreeItemData*) m_Tree->GetItemData( ItemSel ) )->m_SheetPath; UpdateScreenFromSheet( m_Parent ); Close( TRUE ); } diff --git a/include/build_version.h b/include/build_version.h index e9bd0d040d..c03e4fee61 100644 --- a/include/build_version.h +++ b/include/build_version.h @@ -9,7 +9,7 @@ COMMON_GLOBL wxString g_BuildVersion # include "config.h" (wxT(KICAD_SVN_VERSION)) # else - (wxT("(20081229-unstable)")) /* main program version */ + (wxT("(20090107-unstable)")) /* main program version */ # endif #endif ; @@ -20,7 +20,7 @@ COMMON_GLOBL wxString g_BuildAboutVersion # include "config.h" (wxT(KICAD_ABOUT_VERSION)) # else - (wxT("(20081229-unstable)")) /* svn date & rev (normally overridden) */ + (wxT("(20090107-unstable)")) /* svn date & rev (normally overridden) */ # endif #endif ; diff --git a/share/wxprint.cpp b/share/wxprint.cpp index 9d48babbae..f1a89292ba 100644 --- a/share/wxprint.cpp +++ b/share/wxprint.cpp @@ -40,8 +40,6 @@ #include "fctsys.h" -//#include "gr_basic.h" - #include "common.h" #ifdef EESCHEMA @@ -124,12 +122,12 @@ public: } - bool OnPrintPage( int page ); - bool HasPage( int page ); - bool OnBeginDocument( int startPage, int endPage ); - void GetPageInfo( int* minPage, int* maxPage, int* selPageFrom, int* selPageTo ); + bool OnPrintPage( int page ); + bool HasPage( int page ); + bool OnBeginDocument( int startPage, int endPage ); + void GetPageInfo( int* minPage, int* maxPage, int* selPageFrom, int* selPageTo ); - void DrawPage(); + void DrawPage(); }; /*******************************************************/ @@ -200,7 +198,8 @@ void WinEDA_PrintFrame::SetOthersDatas() { m_BoxSelecLayer[ii] = new wxCheckBox( this, -1, #if defined (PCBNEW) - ( (WinEDA_PcbFrame*) m_Parent )->GetBoard()->GetLayerName( + ( (WinEDA_PcbFrame*) m_Parent )->GetBoard()-> + GetLayerName( ii ) ); #else ReturnLayerName( ii ) ); @@ -528,23 +527,44 @@ bool EDA_Printout::OnPrintPage( int page ) #ifdef EESCHEMA - BASE_SCREEN* screen = m_Parent->GetBaseScreen(); - BASE_SCREEN* oldscreen = screen; + WinEDA_SchematicFrame* schframe = (WinEDA_SchematicFrame*) m_Parent; + SCH_SCREEN* screen = schframe->GetScreen(); + SCH_SCREEN* oldscreen = screen; + DrawSheetPath* oldsheetpath = schframe->GetSheet(); + + DrawSheetPath list; if( s_OptionPrintPage == 1 ) { - EDA_ScreenList ScreenList; - screen = ScreenList.GetScreen( page - 1 ); + /* Print all pages, so when called, the page is not the current page. + * We must select it and setup references and others parameters + * because in complex hierarchies a SCH_SCREEN (a schematic drawings) + * is shared between many sheets + */ + EDA_SheetList SheetList( NULL ); + DrawSheetPath* sheetpath = SheetList.GetSheet( page - 1 ); + if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) ) + { + schframe->m_CurrentSheet = &list; + schframe->m_CurrentSheet->UpdateAllScreenReferences(); + schframe->SetSheetNumberAndCount(); + screen = schframe->m_CurrentSheet->LastScreen(); + } + else + screen = NULL; } if( screen == NULL ) return FALSE; - ActiveScreen = (SCH_SCREEN*) screen; + ActiveScreen = screen; DrawPage(); - ActiveScreen = (SCH_SCREEN*) oldscreen; - + ActiveScreen = oldscreen; + schframe->m_CurrentSheet = oldsheetpath; + schframe->m_CurrentSheet->UpdateAllScreenReferences(); + schframe->SetSheetNumberAndCount(); #endif + #ifdef PCBNEW if( (m_Parent->m_Ident == PCB_FRAME) || (m_Parent->m_Ident == GERBER_FRAME) ) { @@ -589,8 +609,7 @@ void EDA_Printout::GetPageInfo( int* minPage, int* maxPage, #ifdef EESCHEMA if( s_OptionPrintPage == 1 ) { - EDA_ScreenList ScreenList; - ii = ScreenList.GetCount(); + ii = g_RootSheet->CountSheets(); } #endif @@ -619,10 +638,9 @@ bool EDA_Printout::HasPage( int pageNum ) /**************************************/ { #ifdef EESCHEMA - int PageCount; + int PageCount; - EDA_ScreenList ScreenList; - PageCount = ScreenList.GetCount(); + PageCount = g_RootSheet->CountSheets(); if( PageCount >= pageNum ) return TRUE; @@ -726,8 +744,8 @@ void EDA_Printout::DrawPage() { int w, h; GetPPIPrinter( &w, &h ); - accurate_Xscale = ( (double) (DrawZoom * w) ) / PCB_INTERNAL_UNIT; - accurate_Yscale = ( (double) (DrawZoom * h) ) / PCB_INTERNAL_UNIT; + accurate_Xscale = ( (double) ( DrawZoom * w ) ) / PCB_INTERNAL_UNIT; + accurate_Yscale = ( (double) ( DrawZoom * h ) ) / PCB_INTERNAL_UNIT; if( IsPreview() ) // Scale must take in account the DC size in Preview { // Get the size of the DC in pixels