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
Please add newer entries at the top, list the date and your name with
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>
================================================================================
++all
......
/////////////////////////////////////////////////////////////////////////////
// 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; i<m_numSheets; i++ )
for( unsigned i = 0; i<m_numSheets; i++ )
{
if( m_sheets[i]->m_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; i<m_numSheets; i++ )
{
m_sheets[i] = d1.m_sheets[i];
......@@ -230,7 +250,7 @@ bool DrawSheetPath::operator==( const DrawSheetPath& d1 )
{
if( m_numSheets != d1.m_numSheets )
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] )
return false;
......@@ -244,7 +264,7 @@ bool DrawSheetPath::operator!=( const DrawSheetPath& d1 )
{
if( m_numSheets != d1.m_numSheets )
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] )
return true;
......
......@@ -60,16 +60,24 @@
*/
class DrawSheetPath
{
public:
int m_numSheets;
private:
unsigned m_numSheets;
public:
#define DSLSZ 32 // Max number of levels for a sheet path
DrawSheetStruct* m_sheets[DSLSZ];
public:
DrawSheetPath();
~DrawSheetPath() { };
void Clear() { m_numSheets = 0; }
void Clear()
{ m_numSheets = 0;
}
unsigned GetSheetsCount()
{
return m_numSheets;
}
/** Function Cmp
* Compare if this is the same sheet path as aSheetPathToTest
......@@ -124,6 +132,13 @@ public:
*/
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
* updates the reference and the m_Multi parameter (part selection) for all
......
......@@ -29,15 +29,16 @@ enum {
class WinEDA_HierFrame;
/* Cette classe permet de memoriser la feuille (sheet) associ�e a l'item
* pour l'arbre de hierarchie */
/* This class derived from wxTreeItemData stores the DrawSheetPath of each sheet in hierarcy
* in each TreeItem, in its associated data buffer
*/
class TreeItemData : public wxTreeItemData
{
public:
DrawSheetPath m_SheetList;
DrawSheetPath m_SheetPath;
TreeItemData( DrawSheetPath sheet ) : wxTreeItemData()
{
m_SheetList = sheet;
m_SheetPath = sheet;
}
};
......@@ -250,7 +251,7 @@ void WinEDA_HierFrame::OnSelect( wxTreeEvent& event )
wxTreeItemId ItemSel = m_Tree->GetSelection();
*(m_Parent->m_CurrentSheet) =
( (TreeItemData*) m_Tree->GetItemData( ItemSel ) )->m_SheetList;
( (TreeItemData*) m_Tree->GetItemData( ItemSel ) )->m_SheetPath;
UpdateScreenFromSheet( m_Parent );
Close( TRUE );
}
......
......@@ -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
;
......
......@@ -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
......
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