Add "portrait" support to the page size settings for all standard paper

sizes.  Tested with postscript output only.  Required minor file format changes
    to reflect the "portrait" setting.  common/dialogs/dialog_page_settings.cpp
    uses a checkbox but its name is "Landscape", which is inverted from portrait,
    but since it is the more common choice, I used that rather than portrait.
    The tooltip for that checkbox makes it clear.  No portrait mode is supported
    for "User" paper size.
This commit is contained in:
Dick Hollenbeck 2012-01-15 22:11:43 -06:00
parent 9147e66dce
commit 0025ac7d38
12 changed files with 331 additions and 78 deletions

View File

@ -4,6 +4,17 @@ KiCad ChangeLog 2012
Please add newer entries at the top, list the date and your name with
email address.
2012-Jan-15 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++all
Add "portrait" support to the page size settings for all standard paper
sizes. Tested with postscript output only. Required minor file format changes
to reflect the "portrait" setting. common/dialogs/dialog_page_settings.cpp
uses a checkbox but its name is "Landscape", which is inverted from portrait,
but since it is the more common choice, I used that rather than portrait.
The tooltip for that checkbox makes it clear. No portrait mode is supported
for "User" paper size.
2012-Jan-9 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================

View File

@ -176,7 +176,7 @@ bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString )
//-----<PAGE_INFO>-------------------------------------------------------------
// Standard page sizes in mils
// Standard page sizes in mils, all constants
#if defined(KICAD_GOST)
const PAGE_INFO PAGE_INFO::pageA4( wxSize( 8283, 11700 ), wxT( "A4" ) );
#else
@ -224,6 +224,27 @@ wxArrayString PAGE_INFO::GetStandardSizes()
}
*/
PAGE_INFO::PAGE_INFO( const wxSize& aSizeMils, const wxString& aType ) :
m_type( aType ),
m_size( aSizeMils ),
m_portrait( false )
{
#if defined(KICAD_GOST)
m_left_margin = GOST_LEFTMARGIN;
m_right_margin = GOST_RIGHTMARGIN;
m_top_margin = GOST_TOPMARGIN;
m_bottom_margin = GOST_BOTTOMMARGIN;
#else
m_left_margin = m_right_margin = m_top_margin = m_bottom_margin = 400;
#endif
}
PAGE_INFO::PAGE_INFO( const wxString& aType )
{
SetType( aType );
}
bool PAGE_INFO::SetType( const wxString& aType )
{
bool rc = true;
@ -267,47 +288,79 @@ bool PAGE_INFO::SetType( const wxString& aType )
}
PAGE_INFO::PAGE_INFO( const wxSize& aSizeMils, const wxString& aType ) :
m_size( aSizeMils )
void PAGE_INFO::SetPortrait( bool isPortrait )
{
m_type = aType;
if( m_portrait != isPortrait )
{
// swap x and y in m_size
m_size = wxSize( m_size.y, m_size.x );
#if defined(KICAD_GOST)
m_left_margin = GOST_LEFTMARGIN;
m_right_margin = GOST_RIGHTMARGIN;
m_top_margin = GOST_TOPMARGIN;
m_bottom_margin = GOST_BOTTOMMARGIN;
#else
m_left_margin = m_right_margin = m_top_margin = m_bottom_margin = 400;
#endif
m_portrait = isPortrait;
// margins are not touched.
}
}
PAGE_INFO::PAGE_INFO( const wxString& aType )
static int clampWidth( int aWidthInMils )
{
SetType( aType );
}
void PAGE_INFO::SetUserWidthMils( int aWidthInMils )
{
if( aWidthInMils < 6000 )
aWidthInMils = 6000;
else if( aWidthInMils > 44000 )
if( aWidthInMils < 4000 ) // 4" is about a baseball card
aWidthInMils = 4000;
else if( aWidthInMils > 44000 ) //44" is plotter size
aWidthInMils = 44000;
s_user_width = aWidthInMils;
return aWidthInMils;
}
void PAGE_INFO::SetUserHeightMils( int aHeightInMils )
static int clampHeight( int aHeightInMils )
{
if( aHeightInMils < 4000 )
aHeightInMils = 4000;
else if( aHeightInMils > 44000 )
aHeightInMils = 44000;
return aHeightInMils;
}
s_user_height = aHeightInMils;
void PAGE_INFO::SetUserWidthMils( int aWidthInMils )
{
s_user_width = clampWidth( aWidthInMils );
}
void PAGE_INFO::SetUserHeightMils( int aHeightInMils )
{
s_user_height = clampHeight( aHeightInMils );
}
void PAGE_INFO::SetWidthMils( int aWidthInMils )
{
m_size.x = clampWidth( aWidthInMils );
}
int PAGE_INFO::GetWidthMils() const
{
return m_size.x;
}
void PAGE_INFO::SetHeightMils( int aHeightInMils )
{
m_size.y = clampHeight( aHeightInMils );
}
int PAGE_INFO::GetHeightMils() const
{
return m_size.y;
}
const wxSize& PAGE_INFO::GetSizeMils() const
{
return m_size;
}
//-----</PAGE_INFO>------------------------------------------------------------

View File

@ -72,10 +72,16 @@ void DIALOG_PAGES_SETTINGS::initDialog()
msg.Printf( format, m_Screen->m_ScreenNumber );
m_TextSheetNumber->SetLabel( msg );
PAGE_INFO pageInfo = m_Parent->GetPageSettings();
const PAGE_INFO& pageInfo = m_Parent->GetPageSettings();
if( wxT( "User" ) != pageInfo.GetType() )
m_landscapeCheckbox->SetValue( !pageInfo.IsPortrait() );
setCurrentPageSizeSelection( pageInfo.GetType() );
// only a click fires the radiobutton selected event, so have to fabricate this check
onRadioButtonSelected();
switch( g_UserUnit )
{
case MILLIMETRES:
@ -149,20 +155,12 @@ void DIALOG_PAGES_SETTINGS::initDialog()
}
/*!
* wxEVT_CLOSE_WINDOW event handler for ID_DIALOG
*/
void DIALOG_PAGES_SETTINGS::OnCloseWindow( wxCloseEvent& event )
{
EndModal( m_modified );
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
*/
void DIALOG_PAGES_SETTINGS::OnOkClick( wxCommandEvent& event )
{
SavePageSettings( event );
@ -171,16 +169,31 @@ void DIALOG_PAGES_SETTINGS::OnOkClick( wxCommandEvent& event )
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
*/
void DIALOG_PAGES_SETTINGS::OnCancelClick( wxCommandEvent& event )
{
Close( true );
}
void DIALOG_PAGES_SETTINGS::onRadioButtonSelected()
{
if( wxT( "User" ) == m_PageSizeBox->GetStringSelection() )
{
m_landscapeCheckbox->Enable( false );
}
else
{
m_landscapeCheckbox->Enable( true );
}
}
void DIALOG_PAGES_SETTINGS::onRadioButtonSelected( wxCommandEvent& event )
{
onRadioButtonSelected(); // no event arg
}
void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event )
{
wxString msg;
@ -236,6 +249,9 @@ void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event )
// paperType is "User", otherwise User with and height will not go into effect right away.
PAGE_INFO pageInfo( paperType );
if( wxT( "User" ) != paperType )
pageInfo.SetPortrait( !m_landscapeCheckbox->IsChecked() );
m_Parent->SetPageSettings( pageInfo );
#ifdef EESCHEMA
@ -306,7 +322,5 @@ void DIALOG_PAGES_SETTINGS::setCurrentPageSizeSelection( const wxString& aPaperS
}
}
}
// m_PageSizeBox->SetSelection( 1 ); // wxFormBuilder does this, control there
}

View File

@ -36,10 +36,14 @@ private:
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
void OnCancelClick( wxCommandEvent& event );
/// wxEVT_COMMAND_RADIOBOX_SELECTED
void onRadioButtonSelected( wxCommandEvent& event );
void setCurrentPageSizeSelection( const wxString& aPaperSize );
void SavePageSettings(wxCommandEvent& event);
void ReturnSizeSelected(wxCommandEvent& event);
void onRadioButtonSelected();
};
#endif // _DIALOG_PAGES_SETTINGS_H_

View File

@ -31,12 +31,23 @@ DIALOG_PAGES_SETTINGS_BASE::DIALOG_PAGES_SETTINGS_BASE( wxWindow* parent, wxWind
wxString m_PageSizeBoxChoices[] = { _("A4"), _("A3"), _("A2"), _("A1"), _("A0"), _("A"), _("B"), _("C"), _("D"), _("E"), _("User") };
int m_PageSizeBoxNChoices = sizeof( m_PageSizeBoxChoices ) / sizeof( wxString );
m_PageSizeBox = new wxRadioBox( this, wxID_ANY, _("Page Size:"), wxDefaultPosition, wxDefaultSize, m_PageSizeBoxNChoices, m_PageSizeBoxChoices, 1, wxRA_SPECIFY_COLS );
m_PageSizeBox->SetSelection( 1 );
m_PageSizeBox->SetSelection( 9 );
LeftColumnSizer->Add( m_PageSizeBox, 0, wxALL|wxEXPAND, 5 );
LeftColumnSizer->Add( 5, 0, 1, wxEXPAND, 5 );
wxStaticBoxSizer* sbSizer8;
sbSizer8 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Orientation:") ), wxVERTICAL );
m_landscapeCheckbox = new wxCheckBox( this, wxID_ANY, _("Landscape"), wxDefaultPosition, wxDefaultSize, 0 );
m_landscapeCheckbox->SetValue(true);
m_landscapeCheckbox->SetToolTip( _("Check for landscape, uncheck for portrait") );
sbSizer8->Add( m_landscapeCheckbox, 0, wxALL|wxEXPAND, 5 );
LeftColumnSizer->Add( sbSizer8, 1, wxALL|wxEXPAND, 5 );
wxBoxSizer* bSizerXsize;
bSizerXsize = new wxBoxSizer( wxVERTICAL );
@ -204,9 +215,11 @@ DIALOG_PAGES_SETTINGS_BASE::DIALOG_PAGES_SETTINGS_BASE( wxWindow* parent, wxWind
this->SetSizer( bMainSizer );
this->Layout();
bMainSizer->Fit( this );
// Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnCloseWindow ) );
m_PageSizeBox->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::onRadioButtonSelected ), NULL, this );
m_TextUserSizeX->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnTextctrlUserPageSizeXTextUpdated ), NULL, this );
m_TextUserSizeY->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnTextctrlUserPageSizeYTextUpdated ), NULL, this );
m_TitleExport->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnCheckboxTitleClick ), NULL, this );
@ -218,6 +231,7 @@ DIALOG_PAGES_SETTINGS_BASE::~DIALOG_PAGES_SETTINGS_BASE()
{
// Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnCloseWindow ) );
m_PageSizeBox->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::onRadioButtonSelected ), NULL, this );
m_TextUserSizeX->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnTextctrlUserPageSizeXTextUpdated ), NULL, this );
m_TextUserSizeY->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnTextctrlUserPageSizeYTextUpdated ), NULL, this );
m_TitleExport->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnCheckboxTitleClick ), NULL, this );

View File

@ -69,7 +69,7 @@
<property name="resize">Resizable</property>
<property name="row"></property>
<property name="show">1</property>
<property name="size">439,497</property>
<property name="size">-1,-1</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass"></property>
<property name="title">Page Settings</property>
@ -198,7 +198,7 @@
<property name="position"></property>
<property name="resize">Resizable</property>
<property name="row"></property>
<property name="selection">1</property>
<property name="selection">9</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxRA_SPECIFY_COLS</property>
@ -229,7 +229,7 @@
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRadioBox"></event>
<event name="OnRadioBox">onRadioButtonSelected</event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
@ -248,6 +248,108 @@
<property name="width">5</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label">Orientation:</property>
<property name="minimum_size"></property>
<property name="name">sbSizer8</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<event name="OnUpdateUI"></event>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_name"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">1</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Landscape</property>
<property name="layer"></property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_landscapeCheckbox</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="resize">Resizable</property>
<property name="row"></property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip">Check for landscape, uncheck for portrait</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnCheckBox"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>

View File

@ -16,11 +16,11 @@
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/checkbox.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/stattext.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/statbox.h>
#include <wx/button.h>
#include <wx/dialog.h>
@ -52,6 +52,7 @@ class DIALOG_PAGES_SETTINGS_BASE : public wxDialog
protected:
wxRadioBox* m_PageSizeBox;
wxCheckBox* m_landscapeCheckbox;
wxStaticText* UserPageSizeX;
wxTextCtrl* m_TextUserSizeX;
wxStaticText* UserPageSizeY;
@ -81,6 +82,7 @@ class DIALOG_PAGES_SETTINGS_BASE : public wxDialog
// Virtual event handlers, overide them in your derived class
virtual void OnCloseWindow( wxCloseEvent& event ) { event.Skip(); }
virtual void onRadioButtonSelected( wxCommandEvent& event ) { event.Skip(); }
virtual void OnTextctrlUserPageSizeXTextUpdated( wxCommandEvent& event ) { event.Skip(); }
virtual void OnTextctrlUserPageSizeYTextUpdated( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCheckboxTitleClick( wxCommandEvent& event ) { event.Skip(); }
@ -90,7 +92,7 @@ class DIALOG_PAGES_SETTINGS_BASE : public wxDialog
public:
DIALOG_PAGES_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Page Settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 439,497 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
DIALOG_PAGES_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Page Settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_PAGES_SETTINGS_BASE();
};

View File

@ -298,18 +298,22 @@ static void LoadLayers( LINE_READER* aLine )
}
}
/// Get the length of a string constant, at compile time
#define SZ( x ) (sizeof(x)-1)
static const char delims[] = " \t\r\n";
/* Read the schematic header. */
bool ReadSchemaDescr( LINE_READER* aLine, wxString& aMsgDiag, SCH_SCREEN* aScreen )
{
char text[256];
char buf[1024];
wxSize pageSize;
char* line = aLine->Line();
sscanf( line, "%s %s %d %d", text, text, &pageSize.x, &pageSize.y );
char* pageType = strtok( line + SZ( "$Descr" ), delims );
char* width = strtok( NULL, delims );
char* height = strtok( NULL, delims );
char* orient = strtok( NULL, delims );
wxString pagename = FROM_UTF8( text );
wxString pagename = FROM_UTF8( pageType );
PAGE_INFO pageInfo;
TITLE_BLOCK tb;
@ -324,14 +328,28 @@ line %d, \aAbort reading file.\n" ),
if( pagename == wxT( "User" ) )
{
pageInfo.SetWidthMils( pageSize.x );
pageInfo.SetHeightMils( pageSize.y );
if( width && height )
{
int w = atoi( width );
int h = atoi( height );
pageInfo.SetWidthMils( w );
pageInfo.SetHeightMils( h );
}
}
// portrait only supported in non "User" sizes
else if( orient && !strcmp( orient, "portrait" ) )
{
pageInfo.SetPortrait( true );
}
aScreen->SetPageSettings( pageInfo );
for(;;)
{
char buf[1024];
if( !aLine->ReadLine() )
return true;

View File

@ -571,8 +571,12 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
*/
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
if( fprintf( aFile, "$Descr %s %d %d%s\n", TO_UTF8( m_paper.GetType() ),
m_paper.GetWidthMils(),
m_paper.GetHeightMils(),
m_paper.GetType() != wxT( "User" ) && m_paper.IsPortrait() ?
" portrait" : ""
) < 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( tb.GetTitle() ).c_str() ) < 0

View File

@ -139,8 +139,6 @@ public:
PAGE_INFO( const wxString& aType = wxT( "A3" ) );
PAGE_INFO( const wxSize& aSizeMils, const wxString& aName );
const wxString& GetType() const { return m_type; }
/**
* Function SetType
* sets the name of the page type and also the sizes and margins
@ -155,14 +153,27 @@ public:
* @return bool - true iff @a aStandarePageDescription was a recognized type.
*/
bool SetType( const wxString& aStandardPageDescriptionName );
const wxString& GetType() const { return m_type; }
void SetWidthMils( int aWidthInMils ) { m_size.x = aWidthInMils; }
int GetWidthMils() const { return m_size.x; }
/**
* Function SetPortrait
* will rotate the paper page 90 degrees. This PAGE_INFO may either be in
* portrait or landscape mode. Use this function to change from one to the
* other mode.
* @param isPortrait if true and not already in portrait mode, will change
* this PAGE_INFO to portrait mode. Or if false and not already in landscape mode,
* will change this PAGE_INFO to landscape mode.
*/
void SetPortrait( bool isPortrait );
bool IsPortrait() const { return m_portrait; }
void SetHeightMils( int aHeightInMils ) { m_size.y = aHeightInMils; }
int GetHeightMils() const { return m_size.y; }
void SetWidthMils( int aWidthInMils );
int GetWidthMils() const;
const wxSize& GetSizeMils() const { return m_size; }
void SetHeightMils( int aHeightInMils );
int GetHeightMils() const;
const wxSize& GetSizeMils() const;
// Accessors returning "Internal Units (IU)". IUs are mils in EESCHEMA,
// and either deci-mils or nanometers in PCBNew.
@ -239,6 +250,8 @@ private:
int m_top_margin;
int m_bottom_margin;
bool m_portrait; ///< true if portrait, false if landscape
static int s_user_height;
static int s_user_width;
};

View File

@ -841,10 +841,13 @@ bool PCB_EDIT_FRAME::WriteGeneralDescrPcb( 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",
fprintf( File, "Sheet %s %d %d%s\n",
TO_UTF8( aPageSettings.GetType() ),
aPageSettings.GetSizeMils().x,
aPageSettings.GetSizeMils().y );
aPageSettings.GetSizeMils().y,
aPageSettings.GetType() != wxT( "User" ) && aPageSettings.IsPortrait() ?
" portrait" : ""
);
fprintf( File, "Title %s\n", EscapedUTF8( aTitleBlock.GetTitle() ).c_str() );
fprintf( File, "Date %s\n", EscapedUTF8( aTitleBlock.GetDate() ).c_str() );
@ -897,12 +900,13 @@ static bool ReadSheetDescr( BOARD* aBoard, LINE_READER* aReader )
*/
}
// only parse the width and height if page size is "User"
if( wname == wxT( "User" ) )
{
char* width = strtok( NULL, delims );
char* height = strtok( NULL, delims );
char* orient = strtok( NULL, delims );
// only keep width and height if page size is "User"
if( wname == wxT( "User" ) )
{
if( width && height )
{
// legacy disk file describes paper in mils
@ -915,6 +919,11 @@ static bool ReadSheetDescr( BOARD* aBoard, LINE_READER* aReader )
}
}
if( orient && !strcmp( orient, "portrait" ) )
{
page.SetPortrait( true );
}
aBoard->SetPageSettings( page );
}

View File

@ -461,12 +461,13 @@ void KICAD_PLUGIN::loadSHEET()
THROW_IO_ERROR( m_error );
}
char* width = strtok( NULL, delims );
char* height = strtok( NULL, delims );
char* orient = strtok( NULL, delims );
// only parse the width and height if page size is "User"
if( wname == wxT( "User" ) )
{
char* width = strtok( NULL, delims );
char* height = strtok( NULL, delims );
if( width && height )
{
// legacy disk file describes paper in mils
@ -479,6 +480,11 @@ void KICAD_PLUGIN::loadSHEET()
}
}
if( orient && !strcmp( orient, "portrait" ) )
{
page.SetPortrait( true );
}
m_board->SetPageSettings( page );
}
}
@ -2734,10 +2740,13 @@ void KICAD_PLUGIN::saveSHEET() const
fprintf( m_fp, "$SHEETDESCR\n" );
// paper is described in mils
fprintf( m_fp, "Sheet %s %d %d\n",
fprintf( m_fp, "Sheet %s %d %d%s\n",
TO_UTF8( pageInfo.GetType() ),
pageInfo.GetSizeMils().x,
pageInfo.GetSizeMils().y );
pageInfo.GetSizeMils().y
pageInfo.GetType() != wxT( "User" ) && pageInfo.IsPortrait() ?
" portrait" : ""
);
fprintf( m_fp, "Title %s\n", EscapedUTF8( tb.GetTitle() ).c_str() );
fprintf( m_fp, "Date %s\n", EscapedUTF8( tb.GetDate() ).c_str() );