worksheetcode cleaning and fix plot sheet filename bug under Linux.

This commit is contained in:
jean-pierre charras 2013-05-22 17:08:57 +02:00
parent 001723e077
commit 3f38a6d89a
4 changed files with 228 additions and 331 deletions

View File

@ -37,36 +37,36 @@
#define GRID_REF_W 70 // height of the band reference grid
#define SIZETEXT 60 // worksheet text size
#define SIZETEXT_REF 50 // worksheet frame reference text size
#define TEXTSIZE 60 // worksheet text size
#define FRMREF_TXTSIZE 50 // worksheet frame reference text size
#define PAS_REF 2000 // reference markings on worksheet frame
#define VARIABLE_BLOCK_START_POSITION (SIZETEXT * 10)
#define VARIABLE_BLOCK_START_POSITION (TEXTSIZE * 10)
// The coordinates below are relative to the bottom right corner of page and
// will be subtracted from this origin.
#define BLOCK_OX 4200
#define BLOCK_KICAD_VERSION_X BLOCK_OX - SIZETEXT
#define BLOCK_KICAD_VERSION_Y SIZETEXT
#define BLOCK_KICAD_VERSION_X BLOCK_OX - TEXTSIZE
#define BLOCK_KICAD_VERSION_Y TEXTSIZE
#define BLOCK_REV_X 820
#define BLOCK_REV_Y (SIZETEXT * 3)
#define BLOCK_DATE_X BLOCK_OX - (SIZETEXT * 15)
#define BLOCK_DATE_Y (SIZETEXT * 3)
#define BLOCK_REV_Y (TEXTSIZE * 3)
#define BLOCK_DATE_X BLOCK_OX - (TEXTSIZE * 15)
#define BLOCK_DATE_Y (TEXTSIZE * 3)
#define BLOCK_ID_SHEET_X 820
#define BLOCK_ID_SHEET_Y SIZETEXT
#define BLOCK_SIZE_SHEET_X BLOCK_OX - SIZETEXT
#define BLOCK_SIZE_SHEET_Y (SIZETEXT * 3)
#define BLOCK_TITLE_X BLOCK_OX - SIZETEXT
#define BLOCK_TITLE_Y (SIZETEXT * 5)
#define BLOCK_FULLSHEETNAME_X BLOCK_OX - SIZETEXT
#define BLOCK_FULLSHEETNAME_Y (SIZETEXT * 7)
#define BLOCK_FILENAME_X BLOCK_OX - SIZETEXT
#define BLOCK_FILENAME_Y (SIZETEXT * 9)
#define BLOCK_COMMENT_X BLOCK_OX - SIZETEXT
#define BLOCK_COMPANY_Y (SIZETEXT * 11)
#define BLOCK_COMMENT1_Y (SIZETEXT * 13)
#define BLOCK_COMMENT2_Y (SIZETEXT * 15)
#define BLOCK_COMMENT3_Y (SIZETEXT * 17)
#define BLOCK_COMMENT4_Y (SIZETEXT * 19)
#define BLOCK_ID_SHEET_Y TEXTSIZE
#define BLOCK_SIZE_SHEET_X BLOCK_OX - TEXTSIZE
#define BLOCK_SIZE_SHEET_Y (TEXTSIZE * 3)
#define BLOCK_TITLE_X BLOCK_OX - TEXTSIZE
#define BLOCK_TITLE_Y (TEXTSIZE * 5)
#define BLOCK_FULLSHEETNAME_X BLOCK_OX - TEXTSIZE
#define BLOCK_FULLSHEETNAME_Y (TEXTSIZE * 7)
#define BLOCK_FILENAME_X BLOCK_OX - TEXTSIZE
#define BLOCK_FILENAME_Y (TEXTSIZE * 9)
#define BLOCK_COMMENT_X BLOCK_OX - TEXTSIZE
#define BLOCK_COMPANY_Y (TEXTSIZE * 11)
#define BLOCK_COMMENT1_Y (TEXTSIZE * 13)
#define BLOCK_COMMENT2_Y (TEXTSIZE * 15)
#define BLOCK_COMMENT3_Y (TEXTSIZE * 17)
#define BLOCK_COMMENT4_Y (TEXTSIZE * 19)
// Work sheet structure type definitions.
enum TypeKi_WorkSheetData {
@ -89,32 +89,43 @@ enum TypeKi_WorkSheetData {
WS_CADRE
};
extern Ki_WorkSheetData WS_Date;
extern Ki_WorkSheetData WS_Revision;
extern Ki_WorkSheetData WS_Licence;
extern Ki_WorkSheetData WS_SizeSheet;
extern Ki_WorkSheetData WS_IdentSheet;
extern Ki_WorkSheetData WS_FullSheetName;
extern Ki_WorkSheetData WS_SheetFilename;
extern Ki_WorkSheetData WS_Title;
extern Ki_WorkSheetData WS_Company;
extern Ki_WorkSheetData WS_Comment1;
extern Ki_WorkSheetData WS_Comment2;
extern Ki_WorkSheetData WS_Comment3;
extern Ki_WorkSheetData WS_Comment4;
extern Ki_WorkSheetData WS_SeparatorLine;
extern Ki_WorkSheetData WS_MostLeftLine;
extern Ki_WorkSheetData WS_MostUpperLine;
extern Ki_WorkSheetData WS_Segm3;
extern Ki_WorkSheetData WS_Segm4;
extern Ki_WorkSheetData WS_Segm5;
extern Ki_WorkSheetData WS_Segm6;
extern Ki_WorkSheetData WS_Segm7;
// superior horizontal segment: should be after comments
// to know the exact position
Ki_WorkSheetData WS_MostUpperLine =
{
WS_UPPER_SEGMENT,
NULL,
BLOCK_OX, TEXTSIZE * 16,
0, TEXTSIZE * 16,
NULL, NULL
};
// Left vertical segment: should be after comments
// to know the exact position
Ki_WorkSheetData WS_MostLeftLine =
{
WS_LEFT_SEGMENT,
&WS_MostUpperLine,
BLOCK_OX, TEXTSIZE * 16,
BLOCK_OX, 0,
NULL, NULL
};
// horizontal segment between filename and comments
Ki_WorkSheetData WS_SeparatorLine =
{
WS_SEGMENT,
&WS_MostLeftLine,
BLOCK_OX, VARIABLE_BLOCK_START_POSITION,
0, VARIABLE_BLOCK_START_POSITION,
NULL, NULL
};
Ki_WorkSheetData WS_Date =
{
WS_DATE,
&WS_Licence,
&WS_SeparatorLine,
BLOCK_DATE_X, BLOCK_DATE_Y,
0, 0,
wxT( "Date: " ),NULL
@ -123,7 +134,7 @@ Ki_WorkSheetData WS_Date =
Ki_WorkSheetData WS_Licence =
{
WS_KICAD_VERSION,
&WS_Revision,
&WS_Date,
BLOCK_KICAD_VERSION_X,BLOCK_KICAD_VERSION_Y,
0,
0,
@ -133,7 +144,7 @@ Ki_WorkSheetData WS_Licence =
Ki_WorkSheetData WS_Revision =
{
WS_REV,
&WS_SizeSheet,
&WS_Licence,
BLOCK_REV_X, BLOCK_REV_Y,
0, 0,
wxT( "Rev: " ),NULL
@ -142,7 +153,7 @@ Ki_WorkSheetData WS_Revision =
Ki_WorkSheetData WS_SizeSheet =
{
WS_SIZESHEET,
&WS_IdentSheet,
&WS_Revision,
BLOCK_SIZE_SHEET_X,BLOCK_SIZE_SHEET_Y,
0, 0,
wxT( "Size: " ), NULL
@ -151,7 +162,7 @@ Ki_WorkSheetData WS_SizeSheet =
Ki_WorkSheetData WS_IdentSheet =
{
WS_IDENTSHEET,
&WS_Title,
&WS_SizeSheet,
BLOCK_ID_SHEET_X,BLOCK_ID_SHEET_Y,
0, 0,
wxT( "Id: " ), NULL
@ -160,7 +171,7 @@ Ki_WorkSheetData WS_IdentSheet =
Ki_WorkSheetData WS_Title =
{
WS_TITLE,
&WS_SheetFilename,
&WS_IdentSheet,
BLOCK_TITLE_X, BLOCK_TITLE_Y,
0, 0,
wxT( "Title: " ), NULL
@ -169,7 +180,7 @@ Ki_WorkSheetData WS_Title =
Ki_WorkSheetData WS_SheetFilename =
{
WS_FILENAME,
&WS_FullSheetName,
&WS_Title,
BLOCK_FILENAME_X, BLOCK_FILENAME_Y,
0, 0,
wxT( "File: " ), NULL
@ -178,7 +189,7 @@ Ki_WorkSheetData WS_SheetFilename =
Ki_WorkSheetData WS_FullSheetName =
{
WS_FULLSHEETNAME,
&WS_Company,
&WS_SheetFilename,
BLOCK_FULLSHEETNAME_X,BLOCK_FULLSHEETNAME_Y,
0,
0,
@ -188,7 +199,7 @@ Ki_WorkSheetData WS_FullSheetName =
Ki_WorkSheetData WS_Company =
{
WS_COMPANY_NAME,
&WS_Comment1,
&WS_FullSheetName,
BLOCK_COMMENT_X,BLOCK_COMPANY_Y,
0, 0,
NULL, NULL
@ -197,7 +208,7 @@ Ki_WorkSheetData WS_Company =
Ki_WorkSheetData WS_Comment1 =
{
WS_COMMENT1,
&WS_Comment2,
&WS_Company,
BLOCK_COMMENT_X,BLOCK_COMMENT1_Y,
0, 0,
NULL, NULL
@ -206,7 +217,7 @@ Ki_WorkSheetData WS_Comment1 =
Ki_WorkSheetData WS_Comment2 =
{
WS_COMMENT2,
&WS_Comment3,
&WS_Comment1,
BLOCK_COMMENT_X,BLOCK_COMMENT2_Y,
0, 0,
NULL, NULL
@ -215,7 +226,7 @@ Ki_WorkSheetData WS_Comment2 =
Ki_WorkSheetData WS_Comment3 =
{
WS_COMMENT3,
&WS_Comment4,
&WS_Comment2,
BLOCK_COMMENT_X,BLOCK_COMMENT3_Y,
0, 0,
NULL, NULL
@ -224,53 +235,20 @@ Ki_WorkSheetData WS_Comment3 =
Ki_WorkSheetData WS_Comment4 =
{
WS_COMMENT4,
&WS_MostLeftLine,
&WS_Comment3,
BLOCK_COMMENT_X, BLOCK_COMMENT4_Y,
0, 0,
NULL, NULL
};
// Left vertical segment
Ki_WorkSheetData WS_MostLeftLine =
{
WS_LEFT_SEGMENT,
&WS_SeparatorLine,
BLOCK_OX, SIZETEXT * 16,
BLOCK_OX, 0,
NULL, NULL
};
// horizontal segment between filename and comments
Ki_WorkSheetData WS_SeparatorLine =
{
WS_SEGMENT,
&WS_MostUpperLine,
BLOCK_OX, VARIABLE_BLOCK_START_POSITION,
0, VARIABLE_BLOCK_START_POSITION,
NULL, NULL
};
// superior horizontal segment
Ki_WorkSheetData WS_MostUpperLine =
{
WS_UPPER_SEGMENT,
&WS_Segm3,
BLOCK_OX, SIZETEXT * 16,
0, SIZETEXT * 16,
NULL, NULL
};
// horizontal segment above COMPANY NAME
Ki_WorkSheetData WS_Segm3 =
{
WS_SEGMENT,
&WS_Segm4,
BLOCK_OX, SIZETEXT * 6,
0, SIZETEXT * 6,
&WS_Comment4,
BLOCK_OX, TEXTSIZE * 6,
0, TEXTSIZE * 6,
NULL, NULL
};
@ -279,9 +257,9 @@ Ki_WorkSheetData WS_Segm3 =
Ki_WorkSheetData WS_Segm4 =
{
WS_SEGMENT,
&WS_Segm5,
BLOCK_REV_X + SIZETEXT,SIZETEXT * 4,
BLOCK_REV_X + SIZETEXT, 0,
&WS_Segm3,
BLOCK_REV_X + TEXTSIZE,TEXTSIZE * 4,
BLOCK_REV_X + TEXTSIZE, 0,
NULL, NULL
};
@ -289,9 +267,9 @@ Ki_WorkSheetData WS_Segm4 =
Ki_WorkSheetData WS_Segm5 =
{
WS_SEGMENT,
&WS_Segm6,
BLOCK_OX, SIZETEXT * 2,
0, SIZETEXT * 2,
&WS_Segm4,
BLOCK_OX, TEXTSIZE * 2,
0, TEXTSIZE * 2,
NULL, NULL
};
@ -299,9 +277,9 @@ Ki_WorkSheetData WS_Segm5 =
Ki_WorkSheetData WS_Segm6 =
{
WS_SEGMENT,
&WS_Segm7,
BLOCK_OX, SIZETEXT * 4,
0, SIZETEXT * 4,
&WS_Segm5,
BLOCK_OX, TEXTSIZE * 4,
0, TEXTSIZE * 4,
NULL, NULL
};
@ -309,14 +287,22 @@ Ki_WorkSheetData WS_Segm6 =
Ki_WorkSheetData WS_Segm7 =
{
WS_SEGMENT,
NULL,
BLOCK_OX - (SIZETEXT * 11),SIZETEXT * 4,
BLOCK_OX - (SIZETEXT * 11),SIZETEXT * 2,
&WS_Segm6,
BLOCK_OX - (TEXTSIZE * 11),TEXTSIZE * 4,
BLOCK_OX - (TEXTSIZE * 11),TEXTSIZE * 2,
NULL, NULL
};
#include <worksheet_shape_builder.h>
// Helper function which returns the text corresponding to the aIdent identifier
static wxString FindUserText( int aIdent, const TITLE_BLOCK& aTitleBlock,
const wxString& aPaperFormat,
const wxString& aFileName,
const wxString& aSheetPathHumanReadable,
int aSheetCount, int aSheetNumber );
void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
const wxString& aPaperFormat,
const wxString& aFileName,
@ -326,22 +312,18 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
EDA_COLOR_T aLineColor, EDA_COLOR_T aTextColor )
{
wxPoint pos;
wxPoint end;
int refx, refy;
wxString Line;
Ki_WorkSheetData* WsItem;
wxSize size( SIZETEXT * m_milsToIu, SIZETEXT * m_milsToIu );
wxSize size_ref( SIZETEXT_REF * m_milsToIu, SIZETEXT_REF * m_milsToIu );
wxSize textsize( TEXTSIZE * m_milsToIu, TEXTSIZE * m_milsToIu );
wxSize size_ref( FRMREF_TXTSIZE * m_milsToIu,
FRMREF_TXTSIZE * m_milsToIu );
wxString msg;
// Upper left corner
refx = m_LTmargin.x;
refy = m_LTmargin.y;
int refx = m_LTmargin.x;
int refy = m_LTmargin.y;
// lower right corner
wxPoint currpos;
currpos.x = m_pageSize.x - m_RBmargin.x;
currpos.y = m_pageSize.y - m_RBmargin.y;
currpos = m_pageSize - m_RBmargin;
// Draw the border.
int ii, jj, ipas, gxpas, gypas;
@ -372,7 +354,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
for( ii = refx + gxpas, jj = 1; ipas > 0; ii += gxpas, jj++, ipas-- )
{
Line.Printf( wxT( "%d" ), jj );
msg.Printf( wxT( "%d" ), jj );
if( ii < currpos.x - PAS_REF / 2 )
{
@ -382,7 +364,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
m_penSize, aLineColor ) );
}
Append( new WS_DRAW_ITEM_TEXT( Line,
Append( new WS_DRAW_ITEM_TEXT( msg,
wxPoint( ( ii - gxpas / 2 ) * m_milsToIu,
( refy + GRID_REF_W / 2 ) * m_milsToIu ),
size_ref, m_penSize, aLineColor ) );
@ -395,7 +377,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
m_penSize, aLineColor ) );
}
Append( new WS_DRAW_ITEM_TEXT( Line,
Append( new WS_DRAW_ITEM_TEXT( msg,
wxPoint( ( ii - gxpas / 2 ) * m_milsToIu,
( currpos.y - GRID_REF_W / 2) * m_milsToIu ),
size_ref, m_penSize, aLineColor ) );
@ -407,9 +389,9 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
for( ii = refy + gypas, jj = 0; ipas > 0; ii += gypas, jj++, ipas-- )
{
if( jj < 26 )
Line.Printf( wxT( "%c" ), jj + 'A' );
msg.Printf( wxT( "%c" ), jj + 'A' );
else // I hope 52 identifiers are enough...
Line.Printf( wxT( "%c" ), 'a' + jj - 26 );
msg.Printf( wxT( "%c" ), 'a' + jj - 26 );
if( ii < currpos.y - PAS_REF / 2 )
{
@ -419,7 +401,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
m_penSize, aLineColor ) );
}
Append( new WS_DRAW_ITEM_TEXT( Line,
Append( new WS_DRAW_ITEM_TEXT( msg,
wxPoint( ( refx + GRID_REF_W / 2 ) * m_milsToIu,
( ii - gypas / 2 ) * m_milsToIu ),
size_ref, m_penSize, aLineColor ) );
@ -432,7 +414,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
m_penSize, aLineColor ) );
}
Append( new WS_DRAW_ITEM_TEXT( Line,
Append( new WS_DRAW_ITEM_TEXT( msg,
wxPoint( ( currpos.x - GRID_REF_W / 2 ) * m_milsToIu,
( ii - gxpas / 2 ) * m_milsToIu ),
size_ref, m_penSize, aLineColor ) );
@ -443,219 +425,64 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
refy = m_pageSize.y - m_RBmargin.y - GRID_REF_W;
WS_DRAW_ITEM_TEXT* gtext;
Ki_WorkSheetData* WsItem;
int boldPenSize;
for( WsItem = &WS_Date; WsItem != NULL; WsItem = WsItem->Pnext )
for( WsItem = &WS_Segm7; WsItem != NULL; WsItem = WsItem->Pnext )
{
pos.x = (refx - WsItem->m_Posx) * m_milsToIu;
pos.y = (refy - WsItem->m_Posy) * m_milsToIu;
msg.Empty();
if( WsItem->m_Legende )
msg = WsItem->m_Legende;
msg += FindUserText( WsItem->m_Type, aTitleBlock, aPaperFormat, aFileName,
aSheetPathHumanReadable, aSheetCount, aSheetNumber );
switch( WsItem->m_Type )
{
case WS_DATE:
if( WsItem->m_Legende )
msg = WsItem->m_Legende;
msg += aTitleBlock.GetDate();
Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos,
size, m_penSize, aLineColor, false,
true ) );
gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
break;
case WS_REV:
if( WsItem->m_Legende )
{
msg = WsItem->m_Legende;
Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, size,
GetPenSizeForBold( std::min( size.
x,
size.
y ) ),
aLineColor, false, true ) );
gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
pos.x += ReturnGraphicTextWidth( msg, size.x, false, false );
}
msg = aTitleBlock.GetRevision();
Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, size,
GetPenSizeForBold( std::min( size.x,
size.y ) ),
case WS_TITLE:
boldPenSize = GetPenSizeForBold( std::min( textsize.x, textsize.y ) );
Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, textsize, boldPenSize,
aTextColor, false, true ) );
gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
break;
case WS_KICAD_VERSION:
if( WsItem->m_Legende )
msg = WsItem->m_Legende;
msg += g_ProductName + wxGetApp().GetAppName();
msg += wxT( " " ) + GetBuildVersion();
Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, size,
m_penSize, aLineColor ) );
gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
break;
case WS_SIZESHEET:
if( WsItem->m_Legende )
msg = WsItem->m_Legende;
msg += aPaperFormat;
Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, size,
m_penSize, aLineColor ) );
gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
break;
case WS_IDENTSHEET:
if( WsItem->m_Legende )
msg = WsItem->m_Legende;
msg << aSheetNumber << wxT( "/" ) << aSheetCount;
Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, size,
m_penSize, aLineColor ) );
gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
break;
case WS_FILENAME:
{
wxFileName fn( aFileName );
if( WsItem->m_Legende )
msg = WsItem->m_Legende;
msg << fn.GetFullName();
Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, size,
m_penSize, aLineColor ) );
gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
}
break;
case WS_FULLSHEETNAME:
if( WsItem->m_Legende )
msg = WsItem->m_Legende;
msg += aSheetPathHumanReadable;
Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, size,
case WS_DATE:
Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, textsize,
m_penSize, aLineColor ) );
gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
break;
case WS_COMPANY_NAME:
if( WsItem->m_Legende )
msg = WsItem->m_Legende;
msg += aTitleBlock.GetCompany();
if( !msg.IsEmpty() )
{
Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, size,
GetPenSizeForBold( std::min( size.
x,
size.
y ) ),
boldPenSize = GetPenSizeForBold( std::min( textsize.x, textsize.y ) );
Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, textsize ,boldPenSize,
aTextColor, false, true ) );
gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
UpperLimit = std::max( UpperLimit, WsItem->m_Posy + SIZETEXT );
UpperLimit = std::max( UpperLimit, WsItem->m_Posy + TEXTSIZE );
}
break;
case WS_TITLE:
if( WsItem->m_Legende )
{
msg = WsItem->m_Legende;
Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, size,
GetPenSizeForBold( std::min( size.
x,
size.
y ) ),
aLineColor, false, true ) );
gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
pos.x += ReturnGraphicTextWidth( msg, size.x, false, false );
}
msg = aTitleBlock.GetTitle();
Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, size,
GetPenSizeForBold( std::min( size.x,
size.y ) ),
aTextColor, false, true ) );
gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
break;
case WS_COMMENT1:
if( WsItem->m_Legende )
msg = WsItem->m_Legende;
msg += aTitleBlock.GetComment1();
if( !msg.IsEmpty() )
{
Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, size,
m_penSize, aTextColor ) );
gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
UpperLimit = std::max( UpperLimit, WsItem->m_Posy + SIZETEXT );
}
break;
case WS_COMMENT2:
if( WsItem->m_Legende )
msg = WsItem->m_Legende;
msg += aTitleBlock.GetComment2();
if( !msg.IsEmpty() )
{
Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, size,
m_penSize, aTextColor ) );
gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
UpperLimit = std::max( UpperLimit, WsItem->m_Posy + SIZETEXT );
}
break;
case WS_COMMENT3:
if( WsItem->m_Legende )
msg = WsItem->m_Legende;
msg += aTitleBlock.GetComment3();
if( !msg.IsEmpty() )
{
Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, size,
m_penSize, aTextColor ) );
gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
UpperLimit = std::max( UpperLimit, WsItem->m_Posy + SIZETEXT );
}
break;
case WS_COMMENT4:
if( WsItem->m_Legende )
msg = WsItem->m_Legende;
msg += aTitleBlock.GetComment4();
if( !msg.IsEmpty() )
{
Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, size,
Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, textsize,
m_penSize, aTextColor ) );
gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
UpperLimit = std::max( UpperLimit, WsItem->m_Posy + SIZETEXT );
UpperLimit = std::max( UpperLimit, WsItem->m_Posy + TEXTSIZE );
}
break;
@ -666,8 +493,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
break;
case WS_LEFT_SEGMENT:
WS_MostUpperLine.m_Posy =
WS_MostUpperLine.m_Endy =
WS_MostUpperLine.m_Posy = WS_MostUpperLine.m_Endy =
WS_MostLeftLine.m_Posy = UpperLimit;
pos.y = (refy - WsItem->m_Posy) * m_milsToIu;
@ -681,3 +507,78 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
}
}
}
// returns the text corresponding to the aIdent identifier
wxString FindUserText( int aIdent, const TITLE_BLOCK& aTitleBlock,
const wxString& aPaperFormat,
const wxString& aFileName,
const wxString& aSheetPathHumanReadable,
int aSheetCount, int aSheetNumber )
{
wxString msg;
switch( aIdent )
{
case WS_DATE:
msg = aTitleBlock.GetDate();
break;
case WS_REV:
msg = aTitleBlock.GetRevision();
break;
case WS_KICAD_VERSION:
msg = g_ProductName + wxGetApp().GetAppName();
msg += wxT( " " ) + GetBuildVersion();
break;
case WS_SIZESHEET:
msg = aPaperFormat;
break;
case WS_IDENTSHEET:
msg << aSheetNumber << wxT( "/" ) << aSheetCount;
break;
case WS_FILENAME:
{
wxFileName fn( aFileName );
msg = fn.GetFullName();
}
break;
case WS_FULLSHEETNAME:
msg = aSheetPathHumanReadable;
break;
case WS_COMPANY_NAME:
msg = aTitleBlock.GetCompany();
break;
case WS_TITLE:
msg = aTitleBlock.GetTitle();
break;
case WS_COMMENT1:
msg = aTitleBlock.GetComment1();
break;
case WS_COMMENT2:
msg = aTitleBlock.GetComment2();
break;
case WS_COMMENT3:
msg = aTitleBlock.GetComment3();
break;
case WS_COMMENT4:
msg = aTitleBlock.GetComment4();
break;
default:
break;
}
return msg;
}

View File

@ -35,8 +35,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define SIZETEXT 100 // worksheet text size
#define SIZETEXT_REF 50 // worksheet frame reference text size
#define TEXTSIZE 100 // worksheet text size
#define PAS_REF 2000 // reference markings on worksheet frame
// used in worksheet.cpp
@ -974,10 +973,8 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
wxPoint pos;
wxPoint end;
int refx, refy;
wxString Line;
Ki_WorkSheetData* WsItem;
wxSize size( SIZETEXT * m_milsToIu, SIZETEXT * m_milsToIu );
wxSize size_ref( SIZETEXT_REF * m_milsToIu, SIZETEXT_REF * m_milsToIu );
wxSize size( TEXTSIZE * m_milsToIu, TEXTSIZE * m_milsToIu );
wxString msg;
WS_DRAW_ITEM_TEXT* gtext;
@ -994,10 +991,10 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
int lnWosn = m_penSize * 2;
int lnWtonk = m_penSize;
wxSize sz;
wxSize size0_8( SIZETEXT * m_milsToIu * 0.8, SIZETEXT * m_milsToIu * 1 );
wxSize size1_5( SIZETEXT * m_milsToIu * 1.5, SIZETEXT * m_milsToIu * 1.5 );
wxSize size2( SIZETEXT * m_milsToIu * 2, SIZETEXT * m_milsToIu * 2 );
wxSize size3( SIZETEXT * m_milsToIu * 3, SIZETEXT * m_milsToIu * 3 );
wxSize size0_8( TEXTSIZE * m_milsToIu * 0.8, TEXTSIZE * m_milsToIu * 1 );
wxSize size1_5( TEXTSIZE * m_milsToIu * 1.5, TEXTSIZE * m_milsToIu * 1.5 );
wxSize size2( TEXTSIZE * m_milsToIu * 2, TEXTSIZE * m_milsToIu * 2 );
wxSize size3( TEXTSIZE * m_milsToIu * 3, TEXTSIZE * m_milsToIu * 3 );
// Draw the border.
Append( new WS_DRAW_ITEM_RECT(
@ -1112,9 +1109,9 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
int index = 0;
wxString fullMsg = msg;
do // Reduce the height of wrapped title until the fit
while( 1 ) // Reduce the height of wrapped title until the fit
{
do // Wrap the title
while( 1 ) // Wrap the title
{
titleWidth = ReturnGraphicTextWidth( msg, sz.x, false, false ) / m_milsToIu;
@ -1122,7 +1119,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
{
index = 0;
do
while( 1 )
{
msg = msg.Left( msg.Length() - 1 );
@ -1163,7 +1160,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
}
}
}
} while( 1 );
}
}
else
{
@ -1180,7 +1177,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
break;
}
} while( 1 );
}
if( titleFieldHeight < (int) ( titleHeight * lines.Count() ) )
{
@ -1191,7 +1188,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
}
else
break;
} while( 1 );
}
pos.x = ( refx - Mm2mils( 85 ) ) * m_milsToIu;
pos.y =

View File

@ -133,6 +133,8 @@ public:
WS_DRAW_ITEM_LIST()
{
m_idx = 0;
m_milsToIu = 1.0;
m_penSize = 1;
}
~WS_DRAW_ITEM_LIST()

View File

@ -530,27 +530,24 @@ wxString SCH_EDIT_FRAME::GetUniqueFilenameForCurrentSheet()
* However if filename is too long name is <sheet filename>-<sheet number>
*/
#define FN_LEN_MAX 100 // A reasonnable value for the full file name len
#define FN_LEN_MAX 80 // A reasonable value for the short filename len
fn.ClearExt();
wxString filename = fn.GetFullPath();
if( ( filename.Len() + m_CurrentSheet->PathHumanReadable().Len() ) < FN_LEN_MAX )
{
filename += m_CurrentSheet->PathHumanReadable();
filename.Replace( wxT( "/" ), wxT( "-" ) );
filename.RemoveLast();
// To avoid issues on unix, ensure the filename does not start
// by '-', which has a special meaning in command lines
#ifndef __WINDOWS__
wxString newfn;
if( filename.StartsWith( wxT( "-" ), &newfn ) )
filename = newfn;
#endif
}
wxString filename = fn.GetName();
wxString sheetFullName = m_CurrentSheet->PathHumanReadable();
sheetFullName.Trim( true );
sheetFullName.Trim( false );
// Remove the last '/' of the path human readable
// (and for the root sheet, make sheetFullName empty):
sheetFullName.RemoveLast();
// Convert path human readable separator to '-'
sheetFullName.Replace( wxT( "/" ), wxT( "-" ) );
if( ( filename.Len() + sheetFullName.Len() ) < FN_LEN_MAX )
filename += sheetFullName;
else
{
filename << wxT( "-" ) << GetScreen()->m_ScreenNumber;
}
return filename;
}