Commit 00dadcbb authored by charras's avatar charras

Print function now properly prints all sheets in a complex hierarchy.Plot functions not yet updated

parent 1b5baa6b
...@@ -5,6 +5,13 @@ Started 2007-June-11 ...@@ -5,6 +5,13 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2009-Jan-07 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
++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 <stambaughw@verizon.net> 2009-Jan-07 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================ ================================================================================
++all ++all
......
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: class_drawsheet.cpp // Name: class_drawsheet.cpp
// Purpose: member functions for DrawSheetStruct // Purpose: member functions for DrawSheetStruct
// header = class_drawsheet.h // header = class_drawsheet.h
// Author: jean-pierre Charras // Author: jean-pierre Charras
// Modified by: // Modified by:
// Created: 08/02/2006 18:37:02
// RCS-ID:
// Copyright:
// Licence: License GNU // 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 "fctsys.h"
#include "common.h" #include "common.h"
...@@ -31,7 +16,7 @@ ...@@ -31,7 +16,7 @@
/**********************************************/ /**********************************************/
/* class to handle a series of sheets *********/ /* class to handle a serie of sheets *********/
/* a 'path' so to speak.. *********************/ /* a 'path' so to speak.. *********************/
/**********************************************/ /**********************************************/
DrawSheetPath::DrawSheetPath() DrawSheetPath::DrawSheetPath()
...@@ -42,6 +27,41 @@ DrawSheetPath::DrawSheetPath() ...@@ -42,6 +27,41 @@ DrawSheetPath::DrawSheetPath()
m_numSheets = 0; 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 int DrawSheetPath::Cmp( const DrawSheetPath& aSheetPathToTest ) const
...@@ -59,7 +79,7 @@ int DrawSheetPath::Cmp( const DrawSheetPath& aSheetPathToTest ) const ...@@ -59,7 +79,7 @@ int DrawSheetPath::Cmp( const DrawSheetPath& aSheetPathToTest ) const
return -1; return -1;
//otherwise, same number of sheets. //otherwise, same number of sheets.
for( int i = 0; i<m_numSheets; i++ ) for( unsigned i = 0; i<m_numSheets; i++ )
{ {
if( m_sheets[i]->m_TimeStamp > aSheetPathToTest.m_sheets[i]->m_TimeStamp ) if( m_sheets[i]->m_TimeStamp > aSheetPathToTest.m_sheets[i]->m_TimeStamp )
return 1; return 1;
...@@ -155,7 +175,7 @@ wxString DrawSheetPath::Path() ...@@ -155,7 +175,7 @@ wxString DrawSheetPath::Path()
//start at 1 to avoid the root sheet, //start at 1 to avoid the root sheet,
//which does not need to be added to the path //which does not need to be added to the path
//it's timestamp changes anyway. //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 ); t.Printf( _( "%8.8lX/" ), m_sheets[i]->m_TimeStamp );
s = s + t; s = s + t;
...@@ -180,7 +200,7 @@ wxString DrawSheetPath::PathHumanReadable() ...@@ -180,7 +200,7 @@ wxString DrawSheetPath::PathHumanReadable()
s = wxT( "/" ); s = wxT( "/" );
//start at 1 to avoid the root sheet, as above. //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( "/" ); s = s + m_sheets[i]->m_SheetName + wxT( "/" );
} }
...@@ -211,7 +231,7 @@ void DrawSheetPath::UpdateAllScreenReferences() ...@@ -211,7 +231,7 @@ void DrawSheetPath::UpdateAllScreenReferences()
bool DrawSheetPath::operator=( const DrawSheetPath& d1 ) bool DrawSheetPath::operator=( const DrawSheetPath& d1 )
{ {
m_numSheets = d1.m_numSheets; m_numSheets = d1.m_numSheets;
int i; unsigned i;
for( i = 0; i<m_numSheets; i++ ) for( i = 0; i<m_numSheets; i++ )
{ {
m_sheets[i] = d1.m_sheets[i]; m_sheets[i] = d1.m_sheets[i];
...@@ -230,7 +250,7 @@ bool DrawSheetPath::operator==( const DrawSheetPath& d1 ) ...@@ -230,7 +250,7 @@ bool DrawSheetPath::operator==( const DrawSheetPath& d1 )
{ {
if( m_numSheets != d1.m_numSheets ) if( m_numSheets != d1.m_numSheets )
return false; return false;
for( int i = 0; i<m_numSheets; i++ ) for( unsigned i = 0; i<m_numSheets; i++ )
{ {
if( m_sheets[i] != d1.m_sheets[i] ) if( m_sheets[i] != d1.m_sheets[i] )
return false; return false;
...@@ -244,7 +264,7 @@ bool DrawSheetPath::operator!=( const DrawSheetPath& d1 ) ...@@ -244,7 +264,7 @@ bool DrawSheetPath::operator!=( const DrawSheetPath& d1 )
{ {
if( m_numSheets != d1.m_numSheets ) if( m_numSheets != d1.m_numSheets )
return true; return true;
for( int i = 0; i<m_numSheets; i++ ) for( unsigned i = 0; i<m_numSheets; i++ )
{ {
if( m_sheets[i] != d1.m_sheets[i] ) if( m_sheets[i] != d1.m_sheets[i] )
return true; return true;
......
...@@ -60,16 +60,24 @@ ...@@ -60,16 +60,24 @@
*/ */
class DrawSheetPath class DrawSheetPath
{ {
public: private:
int m_numSheets; unsigned m_numSheets;
public:
#define DSLSZ 32 // Max number of levels for a sheet path #define DSLSZ 32 // Max number of levels for a sheet path
DrawSheetStruct* m_sheets[DSLSZ]; DrawSheetStruct* m_sheets[DSLSZ];
public: public:
DrawSheetPath(); DrawSheetPath();
~DrawSheetPath() { }; ~DrawSheetPath() { };
void Clear() { m_numSheets = 0; } void Clear()
{ m_numSheets = 0;
}
unsigned GetSheetsCount()
{
return m_numSheets;
}
/** Function Cmp /** Function Cmp
* Compare if this is the same sheet path as aSheetPathToTest * Compare if this is the same sheet path as aSheetPathToTest
...@@ -124,6 +132,13 @@ public: ...@@ -124,6 +132,13 @@ public:
*/ */
wxString PathHumanReadable(); wxString PathHumanReadable();
/** 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
*/
bool BuildSheetPathInfoFromSheetPathValue(const wxString & aPath, bool aFound = false );
/** /**
* Function UpdateAllScreenReferences * Function UpdateAllScreenReferences
* updates the reference and the m_Multi parameter (part selection) for all * updates the reference and the m_Multi parameter (part selection) for all
......
...@@ -29,15 +29,16 @@ enum { ...@@ -29,15 +29,16 @@ enum {
class WinEDA_HierFrame; class WinEDA_HierFrame;
/* Cette classe permet de memoriser la feuille (sheet) associ�e a l'item /* This class derived from wxTreeItemData stores the DrawSheetPath of each sheet in hierarcy
* pour l'arbre de hierarchie */ * in each TreeItem, in its associated data buffer
*/
class TreeItemData : public wxTreeItemData class TreeItemData : public wxTreeItemData
{ {
public: public:
DrawSheetPath m_SheetList; DrawSheetPath m_SheetPath;
TreeItemData( DrawSheetPath sheet ) : wxTreeItemData() TreeItemData( DrawSheetPath sheet ) : wxTreeItemData()
{ {
m_SheetList = sheet; m_SheetPath = sheet;
} }
}; };
...@@ -250,7 +251,7 @@ void WinEDA_HierFrame::OnSelect( wxTreeEvent& event ) ...@@ -250,7 +251,7 @@ void WinEDA_HierFrame::OnSelect( wxTreeEvent& event )
wxTreeItemId ItemSel = m_Tree->GetSelection(); wxTreeItemId ItemSel = m_Tree->GetSelection();
*(m_Parent->m_CurrentSheet) = *(m_Parent->m_CurrentSheet) =
( (TreeItemData*) m_Tree->GetItemData( ItemSel ) )->m_SheetList; ( (TreeItemData*) m_Tree->GetItemData( ItemSel ) )->m_SheetPath;
UpdateScreenFromSheet( m_Parent ); UpdateScreenFromSheet( m_Parent );
Close( TRUE ); Close( TRUE );
} }
......
...@@ -9,7 +9,7 @@ COMMON_GLOBL wxString g_BuildVersion ...@@ -9,7 +9,7 @@ COMMON_GLOBL wxString g_BuildVersion
# include "config.h" # include "config.h"
(wxT(KICAD_SVN_VERSION)) (wxT(KICAD_SVN_VERSION))
# else # else
(wxT("(20081229-unstable)")) /* main program version */ (wxT("(20090107-unstable)")) /* main program version */
# endif # endif
#endif #endif
; ;
...@@ -20,7 +20,7 @@ COMMON_GLOBL wxString g_BuildAboutVersion ...@@ -20,7 +20,7 @@ COMMON_GLOBL wxString g_BuildAboutVersion
# include "config.h" # include "config.h"
(wxT(KICAD_ABOUT_VERSION)) (wxT(KICAD_ABOUT_VERSION))
# else # else
(wxT("(20081229-unstable)")) /* svn date & rev (normally overridden) */ (wxT("(20090107-unstable)")) /* svn date & rev (normally overridden) */
# endif # endif
#endif #endif
; ;
......
...@@ -40,8 +40,6 @@ ...@@ -40,8 +40,6 @@
#include "fctsys.h" #include "fctsys.h"
//#include "gr_basic.h"
#include "common.h" #include "common.h"
#ifdef EESCHEMA #ifdef EESCHEMA
...@@ -200,7 +198,8 @@ void WinEDA_PrintFrame::SetOthersDatas() ...@@ -200,7 +198,8 @@ void WinEDA_PrintFrame::SetOthersDatas()
{ {
m_BoxSelecLayer[ii] = new wxCheckBox( this, -1, m_BoxSelecLayer[ii] = new wxCheckBox( this, -1,
#if defined (PCBNEW) #if defined (PCBNEW)
( (WinEDA_PcbFrame*) m_Parent )->GetBoard()->GetLayerName( ( (WinEDA_PcbFrame*) m_Parent )->GetBoard()->
GetLayerName(
ii ) ); ii ) );
#else #else
ReturnLayerName( ii ) ); ReturnLayerName( ii ) );
...@@ -528,23 +527,44 @@ bool EDA_Printout::OnPrintPage( int page ) ...@@ -528,23 +527,44 @@ bool EDA_Printout::OnPrintPage( int page )
#ifdef EESCHEMA #ifdef EESCHEMA
BASE_SCREEN* screen = m_Parent->GetBaseScreen(); WinEDA_SchematicFrame* schframe = (WinEDA_SchematicFrame*) m_Parent;
BASE_SCREEN* oldscreen = screen; SCH_SCREEN* screen = schframe->GetScreen();
SCH_SCREEN* oldscreen = screen;
DrawSheetPath* oldsheetpath = schframe->GetSheet();
DrawSheetPath list;
if( s_OptionPrintPage == 1 ) if( s_OptionPrintPage == 1 )
{ {
EDA_ScreenList ScreenList; /* Print all pages, so when called, the page is not the current page.
screen = ScreenList.GetScreen( page - 1 ); * 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 ) if( screen == NULL )
return FALSE; return FALSE;
ActiveScreen = (SCH_SCREEN*) screen; ActiveScreen = screen;
DrawPage(); DrawPage();
ActiveScreen = (SCH_SCREEN*) oldscreen; ActiveScreen = oldscreen;
schframe->m_CurrentSheet = oldsheetpath;
schframe->m_CurrentSheet->UpdateAllScreenReferences();
schframe->SetSheetNumberAndCount();
#endif #endif
#ifdef PCBNEW #ifdef PCBNEW
if( (m_Parent->m_Ident == PCB_FRAME) || (m_Parent->m_Ident == GERBER_FRAME) ) 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, ...@@ -589,8 +609,7 @@ void EDA_Printout::GetPageInfo( int* minPage, int* maxPage,
#ifdef EESCHEMA #ifdef EESCHEMA
if( s_OptionPrintPage == 1 ) if( s_OptionPrintPage == 1 )
{ {
EDA_ScreenList ScreenList; ii = g_RootSheet->CountSheets();
ii = ScreenList.GetCount();
} }
#endif #endif
...@@ -621,8 +640,7 @@ bool EDA_Printout::HasPage( int pageNum ) ...@@ -621,8 +640,7 @@ bool EDA_Printout::HasPage( int pageNum )
#ifdef EESCHEMA #ifdef EESCHEMA
int PageCount; int PageCount;
EDA_ScreenList ScreenList; PageCount = g_RootSheet->CountSheets();
PageCount = ScreenList.GetCount();
if( PageCount >= pageNum ) if( PageCount >= pageNum )
return TRUE; return TRUE;
...@@ -726,8 +744,8 @@ void EDA_Printout::DrawPage() ...@@ -726,8 +744,8 @@ void EDA_Printout::DrawPage()
{ {
int w, h; int w, h;
GetPPIPrinter( &w, &h ); GetPPIPrinter( &w, &h );
accurate_Xscale = ( (double) (DrawZoom * w) ) / PCB_INTERNAL_UNIT; accurate_Xscale = ( (double) ( DrawZoom * w ) ) / PCB_INTERNAL_UNIT;
accurate_Yscale = ( (double) (DrawZoom * h) ) / PCB_INTERNAL_UNIT; accurate_Yscale = ( (double) ( DrawZoom * h ) ) / PCB_INTERNAL_UNIT;
if( IsPreview() ) // Scale must take in account the DC size in Preview if( IsPreview() ) // Scale must take in account the DC size in Preview
{ {
// Get the size of the DC in pixels // Get the size of the DC in pixels
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment