Commit 31e3e985 authored by charras's avatar charras

Print and plot functions now properly prints all sheets in a complex hierarchy

parent 1fd73dff
...@@ -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-08 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
++Eeschema:
Print and plot functions now properly prints all sheets in a complex hierarchy
plot files created have now a new filename in order to be compatible with complex hierarchies
2009-Jan-07 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2009-Jan-07 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================ ================================================================================
++Eeschema: ++Eeschema:
......
This diff is collapsed.
...@@ -376,12 +376,11 @@ void WinEDA_PlotPSFrame::CreatePSFile( int AllPages, int pagesize ) ...@@ -376,12 +376,11 @@ void WinEDA_PlotPSFrame::CreatePSFile( int AllPages, int pagesize )
WinEDA_SchematicFrame* schframe = (WinEDA_SchematicFrame*) m_Parent; WinEDA_SchematicFrame* schframe = (WinEDA_SchematicFrame*) m_Parent;
SCH_SCREEN* screen = schframe->GetScreen(); SCH_SCREEN* screen = schframe->GetScreen();
SCH_SCREEN* oldscreen = screen; SCH_SCREEN* oldscreen = screen;
DrawSheetPath* oldsheetpath = schframe->GetSheet(); DrawSheetPath* sheetpath, *oldsheetpath = schframe->GetSheet();
wxString PlotFileName, ShortFileName; wxString PlotFileName;
Ki_PageDescr* PlotSheet, * RealSheet; Ki_PageDescr* PlotSheet, * RealSheet;
int BBox[4]; int BBox[4];
wxPoint plot_offset; wxPoint plot_offset;
DrawSheetPath* sheetpath;
g_PlotFormat = PLOT_FORMAT_POST; g_PlotFormat = PLOT_FORMAT_POST;
...@@ -433,32 +432,7 @@ void WinEDA_PlotPSFrame::CreatePSFile( int AllPages, int pagesize ) ...@@ -433,32 +432,7 @@ void WinEDA_PlotPSFrame::CreatePSFile( int AllPages, int pagesize )
plot_offset.x = 0; plot_offset.x = 0;
plot_offset.y = PlotSheet->m_Size.y; plot_offset.y = PlotSheet->m_Size.y;
/* If a screen is used more than once (complex hierarchy) we create more than once file PlotFileName = schframe->GetUniqueFilenameForCurrentSheet( ) + wxT( ".ps" );
* with the same basic filename
* To avoid that, we use the root filename and and the sheet path
* Or, if filename too long, sheet_name + sheet number
*/
wxSplitPath( g_RootSheet->GetFileName().GetData(), (wxString*) NULL,
&ShortFileName, (wxString*) NULL );
if ( (ShortFileName.Len() + schframe->m_CurrentSheet->PathHumanReadable().Len() ) < 50 )
{
ShortFileName += schframe->m_CurrentSheet->PathHumanReadable();
ShortFileName.Replace( wxT( "/" ), wxT( "-" ) );
ShortFileName.RemoveLast();
}
else
{
wxSplitPath( g_RootSheet->GetFileName().GetData(), (wxString*) NULL,
&ShortFileName, (wxString*) NULL );
ShortFileName << wxT("-") << screen->m_ScreenNumber;
}
wxString dirbuf = wxGetCwd() + STRING_DIR_SEP;
if( !ShortFileName.IsEmpty() )
PlotFileName = MakeFileName( dirbuf, ShortFileName, wxT( ".ps" ) );
else
PlotFileName = MakeFileName( dirbuf, g_DefaultSchematicFileName, wxT( ".ps" ) );
PlotOneSheetPS( PlotFileName, screen, RealSheet, BBox, plot_offset ); PlotOneSheetPS( PlotFileName, screen, RealSheet, BBox, plot_offset );
......
...@@ -450,7 +450,9 @@ void WinEDA_SchematicFrame::SetToolbars() ...@@ -450,7 +450,9 @@ void WinEDA_SchematicFrame::SetToolbars()
} }
/************************************/
int WinEDA_SchematicFrame::BestZoom() int WinEDA_SchematicFrame::BestZoom()
/************************************/
{ {
int dx, dy, ii, jj; int dx, dy, ii, jj;
int bestzoom; int bestzoom;
...@@ -471,6 +473,40 @@ int WinEDA_SchematicFrame::BestZoom() ...@@ -471,6 +473,40 @@ int WinEDA_SchematicFrame::BestZoom()
return bestzoom; return bestzoom;
} }
/*******************************************************************/
wxString WinEDA_SchematicFrame::GetUniqueFilenameForCurrentSheet( )
/*******************************************************************/
/** Function GetUniqueFilenameForCurrentSheet
* @return a filename that can be used in plot and print functions
* for the current screen anad sheet path.
* This filename is unique and must be used insteed of the sreen filename
* (or scheen filename) when one must creates file for each sheet in the heierarchy.
* because in complex hierarchies a sheet and a SCH_SCREEN is used more than once
* Name is <root sheet filename>-<sheet path>
* and has no extension.
* However if filename is too long name is <sheet filename>-<sheet number>
*/
{
wxString filename;
wxSplitPath( g_RootSheet->GetFileName().GetData(), (wxString*) NULL,
&filename, (wxString*) NULL );
if ( (filename.Len() + m_CurrentSheet->PathHumanReadable().Len() ) < 50 )
{
filename += m_CurrentSheet->PathHumanReadable();
filename.Replace( wxT( "/" ), wxT( "-" ) );
filename.RemoveLast();
}
else
{
wxSplitPath( g_RootSheet->GetFileName().GetData(), (wxString*) NULL,
&filename, (wxString*) NULL );
filename << wxT("-") << GetScreen()->m_ScreenNumber;
}
return filename;
}
/**************************************************************/ /**************************************************************/
void WinEDA_SchematicFrame::OnAnnotate( wxCommandEvent& event ) void WinEDA_SchematicFrame::OnAnnotate( wxCommandEvent& event )
......
...@@ -159,9 +159,20 @@ public: ...@@ -159,9 +159,20 @@ public:
*/ */
void DeleteAnnotation( bool aCurrentSheetOnly, bool aRedraw ); void DeleteAnnotation( bool aCurrentSheetOnly, bool aRedraw );
// FUnctions used for hierarchy handling // Functions used for hierarchy handling
void InstallPreviousSheet(); void InstallPreviousSheet();
void InstallNextScreen( DrawSheetStruct* Sheet ); void InstallNextScreen( DrawSheetStruct* Sheet );
/** Function GetUniqueFilenameForCurrentSheet
* @return a filename that can be used in plot and print functions
* for the current screen anad sheet path.
* This filename is unique and must be used insteed of the sreen filename
* (or scheen filename) when one must creates file for each sheet in the heierarchy.
* because in complex hierarchies a sheet and a SCH_SCREEN is used more than once
* Name is <root sheet filename>-<sheet path>
* and has no extension.
* However if filename is too long name is <sheet filename>-<sheet number>
*/
wxString GetUniqueFilenameForCurrentSheet( );
/** /**
* Function SetSheetNumberAndCount * Function SetSheetNumberAndCount
......
...@@ -192,7 +192,7 @@ void WinEDA_PrintSVGFrame::CreateControls() ...@@ -192,7 +192,7 @@ void WinEDA_PrintSVGFrame::CreateControls()
SetFont( *g_DialogFont ); SetFont( *g_DialogFont );
////@begin WinEDA_PrintSVGFrame content construction ////@begin WinEDA_PrintSVGFrame content construction
// Generated by DialogBlocks, 27/08/2008 08:07:11 (unregistered) // Generated by DialogBlocks, 08/01/2009 12:58:57 (unregistered)
WinEDA_PrintSVGFrame* itemDialog1 = this; WinEDA_PrintSVGFrame* itemDialog1 = this;
...@@ -227,7 +227,7 @@ void WinEDA_PrintSVGFrame::CreateControls() ...@@ -227,7 +227,7 @@ void WinEDA_PrintSVGFrame::CreateControls()
wxArrayString m_PagesOptionStrings; wxArrayString m_PagesOptionStrings;
m_PagesOptionStrings.Add(_("Current")); m_PagesOptionStrings.Add(_("Current"));
m_PagesOptionStrings.Add(_("All")); m_PagesOptionStrings.Add(_("All"));
m_PagesOption = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("Page Print:"), wxDefaultPosition, wxDefaultSize, m_PagesOptionStrings, 1, wxRA_SPECIFY_COLS ); m_PagesOption = new wxRadioBox( itemDialog1, ID_RADIOBOX_SELPAGE, _("Page Print:"), wxDefaultPosition, wxDefaultSize, m_PagesOptionStrings, 1, wxRA_SPECIFY_COLS );
m_PagesOption->SetSelection(0); m_PagesOption->SetSelection(0);
itemBoxSizer9->Add(m_PagesOption, 0, wxALIGN_LEFT|wxALL, 5); itemBoxSizer9->Add(m_PagesOption, 0, wxALIGN_LEFT|wxALL, 5);
...@@ -240,22 +240,14 @@ void WinEDA_PrintSVGFrame::CreateControls() ...@@ -240,22 +240,14 @@ void WinEDA_PrintSVGFrame::CreateControls()
itemButton12->SetForegroundColour(wxColour(0, 0, 198)); itemButton12->SetForegroundColour(wxColour(0, 0, 198));
itemBoxSizer9->Add(itemButton12, 0, wxGROW|wxALL, 5); itemBoxSizer9->Add(itemButton12, 0, wxGROW|wxALL, 5);
wxGrid* itemGrid13 = new wxGrid( itemDialog1, ID_GRID1, wxDefaultPosition, wxSize(200, 150), wxSUNKEN_BORDER|wxHSCROLL|wxVSCROLL ); wxStaticText* itemStaticText13 = new wxStaticText( itemDialog1, wxID_STATIC, _("Filename:"), wxDefaultPosition, wxDefaultSize, 0 );
itemGrid13->SetDefaultColSize(50); itemBoxSizer2->Add(itemStaticText13, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
itemGrid13->SetDefaultRowSize(25);
itemGrid13->SetColLabelSize(25);
itemGrid13->SetRowLabelSize(50);
itemGrid13->CreateGrid(5, 5, wxGrid::wxGridSelectCells);
itemBoxSizer3->Add(itemGrid13, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText14 = new wxStaticText( itemDialog1, wxID_STATIC, _("Filename:"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer2->Add(itemStaticText14, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
m_FileNameCtrl = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); m_FileNameCtrl = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer2->Add(m_FileNameCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); itemBoxSizer2->Add(m_FileNameCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
wxStaticText* itemStaticText16 = new wxStaticText( itemDialog1, wxID_STATIC, _("Messages:"), wxDefaultPosition, wxDefaultSize, 0 ); wxStaticText* itemStaticText15 = new wxStaticText( itemDialog1, wxID_STATIC, _("Messages:"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer2->Add(itemStaticText16, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); itemBoxSizer2->Add(itemStaticText15, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
m_MessagesBox = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxSize(-1, 100), wxTE_MULTILINE|wxTE_READONLY ); m_MessagesBox = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxSize(-1, 100), wxTE_MULTILINE|wxTE_READONLY );
itemBoxSizer2->Add(m_MessagesBox, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); itemBoxSizer2->Add(m_MessagesBox, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
...@@ -311,18 +303,6 @@ wxIcon WinEDA_PrintSVGFrame::GetIconResource( const wxString& name ) ...@@ -311,18 +303,6 @@ wxIcon WinEDA_PrintSVGFrame::GetIconResource( const wxString& name )
} }
/******************************************************/
wxString WinEDA_PrintSVGFrame::ReturnFullFileName()
/******************************************************/
{
wxString name, ext;
name = m_Parent->GetBaseScreen()->m_FileName;
ChangeFileNameExt( name, wxT( ".svg" ) );
return name;
}
/********************************************/ /********************************************/
void WinEDA_PrintSVGFrame::SetPenWidth() void WinEDA_PrintSVGFrame::SetPenWidth()
/********************************************/ /********************************************/
...@@ -362,7 +342,7 @@ void WinEDA_PrintSVGFrame::PrintSVGDoc( wxCommandEvent& event ) ...@@ -362,7 +342,7 @@ void WinEDA_PrintSVGFrame::PrintSVGDoc( wxCommandEvent& event )
SetPenWidth(); SetPenWidth();
wxString FullFileName;
BASE_SCREEN* screen = m_Parent->GetBaseScreen(); BASE_SCREEN* screen = m_Parent->GetBaseScreen();
BASE_SCREEN* oldscreen = screen; BASE_SCREEN* oldscreen = screen;
#ifndef EESCHEMA #ifndef EESCHEMA
...@@ -388,14 +368,33 @@ void WinEDA_PrintSVGFrame::PrintSVGDoc( wxCommandEvent& event ) ...@@ -388,14 +368,33 @@ void WinEDA_PrintSVGFrame::PrintSVGDoc( wxCommandEvent& event )
#ifdef EESCHEMA #ifdef EESCHEMA
if( Select_PrintAll && m_Parent->m_Ident == SCHEMATIC_FRAME ) if( Select_PrintAll && m_Parent->m_Ident == SCHEMATIC_FRAME )
{ {
EDA_ScreenList ScreenList; WinEDA_SchematicFrame* schframe = (WinEDA_SchematicFrame*) m_Parent;
for( SCH_SCREEN* schscreen = ScreenList.GetFirst(); schscreen != NULL; DrawSheetPath* sheetpath, *oldsheetpath = schframe->GetSheet();
schscreen = ScreenList.GetNext() ) SCH_SCREEN* schscreen = schframe->GetScreen();
oldscreen = schscreen;
EDA_SheetList SheetList( NULL );
sheetpath = SheetList.GetFirst();
DrawSheetPath list;
for( ; ; )
{ {
/* Create all files *.svg */ if( sheetpath == NULL )
( (WinEDA_SchematicFrame*) m_Parent )->SetScreen( schscreen ); break;
wxString FullFileName = schscreen->m_FileName; list.Clear();
ChangeFileNameExt( FullFileName, wxT( ".svg" ) ); if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) )
{
schframe->m_CurrentSheet = &list;
schframe->m_CurrentSheet->UpdateAllScreenReferences();
schframe->SetSheetNumberAndCount();
schscreen = schframe->m_CurrentSheet->LastScreen();
ActiveScreen = schscreen;
}
else // Should not happen
return;
sheetpath = SheetList.GetNext();
FullFileName = schframe->GetUniqueFilenameForCurrentSheet( ) + wxT( ".svg" );
bool success = DrawPage( FullFileName, schscreen ); bool success = DrawPage( FullFileName, schscreen );
msg = _( "Create file " ) + FullFileName; msg = _( "Create file " ) + FullFileName;
if( !success ) if( !success )
...@@ -403,11 +402,14 @@ void WinEDA_PrintSVGFrame::PrintSVGDoc( wxCommandEvent& event ) ...@@ -403,11 +402,14 @@ void WinEDA_PrintSVGFrame::PrintSVGDoc( wxCommandEvent& event )
msg += wxT( "\n" ); msg += wxT( "\n" );
m_MessagesBox->AppendText( msg ); m_MessagesBox->AppendText( msg );
} }
schframe->m_CurrentSheet = oldsheetpath;
schframe->m_CurrentSheet->UpdateAllScreenReferences();
schframe->SetSheetNumberAndCount();
} }
else else
#endif #endif
{ {
wxString FullFileName = m_FileNameCtrl->GetValue(); FullFileName = m_FileNameCtrl->GetValue();
if( FullFileName.IsEmpty() ) if( FullFileName.IsEmpty() )
{ {
FullFileName = screen->m_FileName; FullFileName = screen->m_FileName;
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
////@begin includes ////@begin includes
#include "wx/valgen.h" #include "wx/valgen.h"
#include "wx/grid.h"
////@end includes ////@end includes
/*! /*!
...@@ -43,9 +42,8 @@ class wxBoxSizer; ...@@ -43,9 +42,8 @@ class wxBoxSizer;
#define ID_DIALOG 10000 #define ID_DIALOG 10000
#define ID_RADIOBOX_SETPRINTMODE 10007 #define ID_RADIOBOX_SETPRINTMODE 10007
#define ID_CHECKBOX 10004 #define ID_CHECKBOX 10004
#define ID_RADIOBOX1 10008 #define ID_RADIOBOX_SELPAGE 10008
#define ID_PRINT_EXECUTE 10002 #define ID_PRINT_EXECUTE 10002
#define ID_GRID1 10003
#define ID_TEXTCTRL 10001 #define ID_TEXTCTRL 10001
#define ID_TEXTCTRL1 10006 #define ID_TEXTCTRL1 10006
#define SYMBOL_WINEDA_PRINTSVGFRAME_STYLE wxCAPTION|wxSYSTEM_MENU|wxCLOSE_BOX|wxFRAME_FLOAT_ON_PARENT|MAYBE_RESIZE_BORDER #define SYMBOL_WINEDA_PRINTSVGFRAME_STYLE wxCAPTION|wxSYSTEM_MENU|wxCLOSE_BOX|wxFRAME_FLOAT_ON_PARENT|MAYBE_RESIZE_BORDER
...@@ -118,7 +116,6 @@ public: ...@@ -118,7 +116,6 @@ public:
void PrintSVGDoc(wxCommandEvent& event); void PrintSVGDoc(wxCommandEvent& event);
bool DrawPage(const wxString & FullFileName, BASE_SCREEN* screen); bool DrawPage(const wxString & FullFileName, BASE_SCREEN* screen);
wxString ReturnFullFileName();
////@begin WinEDA_PrintSVGFrame member variables ////@begin WinEDA_PrintSVGFrame member variables
wxBoxSizer* m_DialogPenWidthSizer; wxBoxSizer* m_DialogPenWidthSizer;
......
...@@ -556,7 +556,7 @@ ...@@ -556,7 +556,7 @@
<bool name="proxy-wxFIXED_MINSIZE">0</bool> <bool name="proxy-wxFIXED_MINSIZE">0</bool>
<string name="proxy-Platform">"&lt;Any platform&gt;"</string> <string name="proxy-Platform">"&lt;Any platform&gt;"</string>
<document> <document>
<string name="title">"wxRadioBox: ID_RADIOBOX1"</string> <string name="title">"wxRadioBox: ID_RADIOBOX_SELPAGE"</string>
<string name="type">"dialog-control-document"</string> <string name="type">"dialog-control-document"</string>
<string name="filename">""</string> <string name="filename">""</string>
<string name="icon-name">"radiobox"</string> <string name="icon-name">"radiobox"</string>
...@@ -566,7 +566,7 @@ ...@@ -566,7 +566,7 @@
<long name="locked">0</long> <long name="locked">0</long>
<string name="created">"23/12/2006"</string> <string name="created">"23/12/2006"</string>
<string name="proxy-type">"wbRadioBoxProxy"</string> <string name="proxy-type">"wbRadioBoxProxy"</string>
<string name="proxy-Id name">"ID_RADIOBOX1"</string> <string name="proxy-Id name">"ID_RADIOBOX_SELPAGE"</string>
<long name="proxy-Id value">10008</long> <long name="proxy-Id value">10008</long>
<string name="proxy-Name">""</string> <string name="proxy-Name">""</string>
<string name="proxy-Class">"wxRadioBox"</string> <string name="proxy-Class">"wxRadioBox"</string>
......
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