Commit 3f38a6d8 authored by jean-pierre charras's avatar jean-pierre charras

worksheetcode cleaning and fix plot sheet filename bug under Linux.

parent 001723e0
...@@ -37,36 +37,36 @@ ...@@ -37,36 +37,36 @@
#define GRID_REF_W 70 // height of the band reference grid #define GRID_REF_W 70 // height of the band reference grid
#define SIZETEXT 60 // worksheet text size #define TEXTSIZE 60 // worksheet text size
#define SIZETEXT_REF 50 // worksheet frame reference text size #define FRMREF_TXTSIZE 50 // worksheet frame reference text size
#define PAS_REF 2000 // reference markings on worksheet frame #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 // The coordinates below are relative to the bottom right corner of page and
// will be subtracted from this origin. // will be subtracted from this origin.
#define BLOCK_OX 4200 #define BLOCK_OX 4200
#define BLOCK_KICAD_VERSION_X BLOCK_OX - SIZETEXT #define BLOCK_KICAD_VERSION_X BLOCK_OX - TEXTSIZE
#define BLOCK_KICAD_VERSION_Y SIZETEXT #define BLOCK_KICAD_VERSION_Y TEXTSIZE
#define BLOCK_REV_X 820 #define BLOCK_REV_X 820
#define BLOCK_REV_Y (SIZETEXT * 3) #define BLOCK_REV_Y (TEXTSIZE * 3)
#define BLOCK_DATE_X BLOCK_OX - (SIZETEXT * 15) #define BLOCK_DATE_X BLOCK_OX - (TEXTSIZE * 15)
#define BLOCK_DATE_Y (SIZETEXT * 3) #define BLOCK_DATE_Y (TEXTSIZE * 3)
#define BLOCK_ID_SHEET_X 820 #define BLOCK_ID_SHEET_X 820
#define BLOCK_ID_SHEET_Y SIZETEXT #define BLOCK_ID_SHEET_Y TEXTSIZE
#define BLOCK_SIZE_SHEET_X BLOCK_OX - SIZETEXT #define BLOCK_SIZE_SHEET_X BLOCK_OX - TEXTSIZE
#define BLOCK_SIZE_SHEET_Y (SIZETEXT * 3) #define BLOCK_SIZE_SHEET_Y (TEXTSIZE * 3)
#define BLOCK_TITLE_X BLOCK_OX - SIZETEXT #define BLOCK_TITLE_X BLOCK_OX - TEXTSIZE
#define BLOCK_TITLE_Y (SIZETEXT * 5) #define BLOCK_TITLE_Y (TEXTSIZE * 5)
#define BLOCK_FULLSHEETNAME_X BLOCK_OX - SIZETEXT #define BLOCK_FULLSHEETNAME_X BLOCK_OX - TEXTSIZE
#define BLOCK_FULLSHEETNAME_Y (SIZETEXT * 7) #define BLOCK_FULLSHEETNAME_Y (TEXTSIZE * 7)
#define BLOCK_FILENAME_X BLOCK_OX - SIZETEXT #define BLOCK_FILENAME_X BLOCK_OX - TEXTSIZE
#define BLOCK_FILENAME_Y (SIZETEXT * 9) #define BLOCK_FILENAME_Y (TEXTSIZE * 9)
#define BLOCK_COMMENT_X BLOCK_OX - SIZETEXT #define BLOCK_COMMENT_X BLOCK_OX - TEXTSIZE
#define BLOCK_COMPANY_Y (SIZETEXT * 11) #define BLOCK_COMPANY_Y (TEXTSIZE * 11)
#define BLOCK_COMMENT1_Y (SIZETEXT * 13) #define BLOCK_COMMENT1_Y (TEXTSIZE * 13)
#define BLOCK_COMMENT2_Y (SIZETEXT * 15) #define BLOCK_COMMENT2_Y (TEXTSIZE * 15)
#define BLOCK_COMMENT3_Y (SIZETEXT * 17) #define BLOCK_COMMENT3_Y (TEXTSIZE * 17)
#define BLOCK_COMMENT4_Y (SIZETEXT * 19) #define BLOCK_COMMENT4_Y (TEXTSIZE * 19)
// Work sheet structure type definitions. // Work sheet structure type definitions.
enum TypeKi_WorkSheetData { enum TypeKi_WorkSheetData {
...@@ -89,32 +89,43 @@ enum TypeKi_WorkSheetData { ...@@ -89,32 +89,43 @@ enum TypeKi_WorkSheetData {
WS_CADRE WS_CADRE
}; };
extern Ki_WorkSheetData WS_Date;
extern Ki_WorkSheetData WS_Revision; // superior horizontal segment: should be after comments
extern Ki_WorkSheetData WS_Licence; // to know the exact position
extern Ki_WorkSheetData WS_SizeSheet; Ki_WorkSheetData WS_MostUpperLine =
extern Ki_WorkSheetData WS_IdentSheet; {
extern Ki_WorkSheetData WS_FullSheetName; WS_UPPER_SEGMENT,
extern Ki_WorkSheetData WS_SheetFilename; NULL,
extern Ki_WorkSheetData WS_Title; BLOCK_OX, TEXTSIZE * 16,
extern Ki_WorkSheetData WS_Company; 0, TEXTSIZE * 16,
extern Ki_WorkSheetData WS_Comment1; NULL, NULL
extern Ki_WorkSheetData WS_Comment2; };
extern Ki_WorkSheetData WS_Comment3;
extern Ki_WorkSheetData WS_Comment4; // Left vertical segment: should be after comments
extern Ki_WorkSheetData WS_SeparatorLine; // to know the exact position
extern Ki_WorkSheetData WS_MostLeftLine; Ki_WorkSheetData WS_MostLeftLine =
extern Ki_WorkSheetData WS_MostUpperLine; {
extern Ki_WorkSheetData WS_Segm3; WS_LEFT_SEGMENT,
extern Ki_WorkSheetData WS_Segm4; &WS_MostUpperLine,
extern Ki_WorkSheetData WS_Segm5; BLOCK_OX, TEXTSIZE * 16,
extern Ki_WorkSheetData WS_Segm6; BLOCK_OX, 0,
extern Ki_WorkSheetData WS_Segm7; 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 = Ki_WorkSheetData WS_Date =
{ {
WS_DATE, WS_DATE,
&WS_Licence, &WS_SeparatorLine,
BLOCK_DATE_X, BLOCK_DATE_Y, BLOCK_DATE_X, BLOCK_DATE_Y,
0, 0, 0, 0,
wxT( "Date: " ),NULL wxT( "Date: " ),NULL
...@@ -123,7 +134,7 @@ Ki_WorkSheetData WS_Date = ...@@ -123,7 +134,7 @@ Ki_WorkSheetData WS_Date =
Ki_WorkSheetData WS_Licence = Ki_WorkSheetData WS_Licence =
{ {
WS_KICAD_VERSION, WS_KICAD_VERSION,
&WS_Revision, &WS_Date,
BLOCK_KICAD_VERSION_X,BLOCK_KICAD_VERSION_Y, BLOCK_KICAD_VERSION_X,BLOCK_KICAD_VERSION_Y,
0, 0,
0, 0,
...@@ -133,7 +144,7 @@ Ki_WorkSheetData WS_Licence = ...@@ -133,7 +144,7 @@ Ki_WorkSheetData WS_Licence =
Ki_WorkSheetData WS_Revision = Ki_WorkSheetData WS_Revision =
{ {
WS_REV, WS_REV,
&WS_SizeSheet, &WS_Licence,
BLOCK_REV_X, BLOCK_REV_Y, BLOCK_REV_X, BLOCK_REV_Y,
0, 0, 0, 0,
wxT( "Rev: " ),NULL wxT( "Rev: " ),NULL
...@@ -142,7 +153,7 @@ Ki_WorkSheetData WS_Revision = ...@@ -142,7 +153,7 @@ Ki_WorkSheetData WS_Revision =
Ki_WorkSheetData WS_SizeSheet = Ki_WorkSheetData WS_SizeSheet =
{ {
WS_SIZESHEET, WS_SIZESHEET,
&WS_IdentSheet, &WS_Revision,
BLOCK_SIZE_SHEET_X,BLOCK_SIZE_SHEET_Y, BLOCK_SIZE_SHEET_X,BLOCK_SIZE_SHEET_Y,
0, 0, 0, 0,
wxT( "Size: " ), NULL wxT( "Size: " ), NULL
...@@ -151,7 +162,7 @@ Ki_WorkSheetData WS_SizeSheet = ...@@ -151,7 +162,7 @@ Ki_WorkSheetData WS_SizeSheet =
Ki_WorkSheetData WS_IdentSheet = Ki_WorkSheetData WS_IdentSheet =
{ {
WS_IDENTSHEET, WS_IDENTSHEET,
&WS_Title, &WS_SizeSheet,
BLOCK_ID_SHEET_X,BLOCK_ID_SHEET_Y, BLOCK_ID_SHEET_X,BLOCK_ID_SHEET_Y,
0, 0, 0, 0,
wxT( "Id: " ), NULL wxT( "Id: " ), NULL
...@@ -160,7 +171,7 @@ Ki_WorkSheetData WS_IdentSheet = ...@@ -160,7 +171,7 @@ Ki_WorkSheetData WS_IdentSheet =
Ki_WorkSheetData WS_Title = Ki_WorkSheetData WS_Title =
{ {
WS_TITLE, WS_TITLE,
&WS_SheetFilename, &WS_IdentSheet,
BLOCK_TITLE_X, BLOCK_TITLE_Y, BLOCK_TITLE_X, BLOCK_TITLE_Y,
0, 0, 0, 0,
wxT( "Title: " ), NULL wxT( "Title: " ), NULL
...@@ -169,7 +180,7 @@ Ki_WorkSheetData WS_Title = ...@@ -169,7 +180,7 @@ Ki_WorkSheetData WS_Title =
Ki_WorkSheetData WS_SheetFilename = Ki_WorkSheetData WS_SheetFilename =
{ {
WS_FILENAME, WS_FILENAME,
&WS_FullSheetName, &WS_Title,
BLOCK_FILENAME_X, BLOCK_FILENAME_Y, BLOCK_FILENAME_X, BLOCK_FILENAME_Y,
0, 0, 0, 0,
wxT( "File: " ), NULL wxT( "File: " ), NULL
...@@ -178,7 +189,7 @@ Ki_WorkSheetData WS_SheetFilename = ...@@ -178,7 +189,7 @@ Ki_WorkSheetData WS_SheetFilename =
Ki_WorkSheetData WS_FullSheetName = Ki_WorkSheetData WS_FullSheetName =
{ {
WS_FULLSHEETNAME, WS_FULLSHEETNAME,
&WS_Company, &WS_SheetFilename,
BLOCK_FULLSHEETNAME_X,BLOCK_FULLSHEETNAME_Y, BLOCK_FULLSHEETNAME_X,BLOCK_FULLSHEETNAME_Y,
0, 0,
0, 0,
...@@ -188,7 +199,7 @@ Ki_WorkSheetData WS_FullSheetName = ...@@ -188,7 +199,7 @@ Ki_WorkSheetData WS_FullSheetName =
Ki_WorkSheetData WS_Company = Ki_WorkSheetData WS_Company =
{ {
WS_COMPANY_NAME, WS_COMPANY_NAME,
&WS_Comment1, &WS_FullSheetName,
BLOCK_COMMENT_X,BLOCK_COMPANY_Y, BLOCK_COMMENT_X,BLOCK_COMPANY_Y,
0, 0, 0, 0,
NULL, NULL NULL, NULL
...@@ -197,7 +208,7 @@ Ki_WorkSheetData WS_Company = ...@@ -197,7 +208,7 @@ Ki_WorkSheetData WS_Company =
Ki_WorkSheetData WS_Comment1 = Ki_WorkSheetData WS_Comment1 =
{ {
WS_COMMENT1, WS_COMMENT1,
&WS_Comment2, &WS_Company,
BLOCK_COMMENT_X,BLOCK_COMMENT1_Y, BLOCK_COMMENT_X,BLOCK_COMMENT1_Y,
0, 0, 0, 0,
NULL, NULL NULL, NULL
...@@ -206,7 +217,7 @@ Ki_WorkSheetData WS_Comment1 = ...@@ -206,7 +217,7 @@ Ki_WorkSheetData WS_Comment1 =
Ki_WorkSheetData WS_Comment2 = Ki_WorkSheetData WS_Comment2 =
{ {
WS_COMMENT2, WS_COMMENT2,
&WS_Comment3, &WS_Comment1,
BLOCK_COMMENT_X,BLOCK_COMMENT2_Y, BLOCK_COMMENT_X,BLOCK_COMMENT2_Y,
0, 0, 0, 0,
NULL, NULL NULL, NULL
...@@ -215,7 +226,7 @@ Ki_WorkSheetData WS_Comment2 = ...@@ -215,7 +226,7 @@ Ki_WorkSheetData WS_Comment2 =
Ki_WorkSheetData WS_Comment3 = Ki_WorkSheetData WS_Comment3 =
{ {
WS_COMMENT3, WS_COMMENT3,
&WS_Comment4, &WS_Comment2,
BLOCK_COMMENT_X,BLOCK_COMMENT3_Y, BLOCK_COMMENT_X,BLOCK_COMMENT3_Y,
0, 0, 0, 0,
NULL, NULL NULL, NULL
...@@ -224,53 +235,20 @@ Ki_WorkSheetData WS_Comment3 = ...@@ -224,53 +235,20 @@ Ki_WorkSheetData WS_Comment3 =
Ki_WorkSheetData WS_Comment4 = Ki_WorkSheetData WS_Comment4 =
{ {
WS_COMMENT4, WS_COMMENT4,
&WS_MostLeftLine, &WS_Comment3,
BLOCK_COMMENT_X, BLOCK_COMMENT4_Y, BLOCK_COMMENT_X, BLOCK_COMMENT4_Y,
0, 0, 0, 0,
NULL, NULL 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 // horizontal segment above COMPANY NAME
Ki_WorkSheetData WS_Segm3 = Ki_WorkSheetData WS_Segm3 =
{ {
WS_SEGMENT, WS_SEGMENT,
&WS_Segm4, &WS_Comment4,
BLOCK_OX, SIZETEXT * 6, BLOCK_OX, TEXTSIZE * 6,
0, SIZETEXT * 6, 0, TEXTSIZE * 6,
NULL, NULL NULL, NULL
}; };
...@@ -279,9 +257,9 @@ Ki_WorkSheetData WS_Segm3 = ...@@ -279,9 +257,9 @@ Ki_WorkSheetData WS_Segm3 =
Ki_WorkSheetData WS_Segm4 = Ki_WorkSheetData WS_Segm4 =
{ {
WS_SEGMENT, WS_SEGMENT,
&WS_Segm5, &WS_Segm3,
BLOCK_REV_X + SIZETEXT,SIZETEXT * 4, BLOCK_REV_X + TEXTSIZE,TEXTSIZE * 4,
BLOCK_REV_X + SIZETEXT, 0, BLOCK_REV_X + TEXTSIZE, 0,
NULL, NULL NULL, NULL
}; };
...@@ -289,9 +267,9 @@ Ki_WorkSheetData WS_Segm4 = ...@@ -289,9 +267,9 @@ Ki_WorkSheetData WS_Segm4 =
Ki_WorkSheetData WS_Segm5 = Ki_WorkSheetData WS_Segm5 =
{ {
WS_SEGMENT, WS_SEGMENT,
&WS_Segm6, &WS_Segm4,
BLOCK_OX, SIZETEXT * 2, BLOCK_OX, TEXTSIZE * 2,
0, SIZETEXT * 2, 0, TEXTSIZE * 2,
NULL, NULL NULL, NULL
}; };
...@@ -299,9 +277,9 @@ Ki_WorkSheetData WS_Segm5 = ...@@ -299,9 +277,9 @@ Ki_WorkSheetData WS_Segm5 =
Ki_WorkSheetData WS_Segm6 = Ki_WorkSheetData WS_Segm6 =
{ {
WS_SEGMENT, WS_SEGMENT,
&WS_Segm7, &WS_Segm5,
BLOCK_OX, SIZETEXT * 4, BLOCK_OX, TEXTSIZE * 4,
0, SIZETEXT * 4, 0, TEXTSIZE * 4,
NULL, NULL NULL, NULL
}; };
...@@ -309,14 +287,22 @@ Ki_WorkSheetData WS_Segm6 = ...@@ -309,14 +287,22 @@ Ki_WorkSheetData WS_Segm6 =
Ki_WorkSheetData WS_Segm7 = Ki_WorkSheetData WS_Segm7 =
{ {
WS_SEGMENT, WS_SEGMENT,
NULL, &WS_Segm6,
BLOCK_OX - (SIZETEXT * 11),SIZETEXT * 4, BLOCK_OX - (TEXTSIZE * 11),TEXTSIZE * 4,
BLOCK_OX - (SIZETEXT * 11),SIZETEXT * 2, BLOCK_OX - (TEXTSIZE * 11),TEXTSIZE * 2,
NULL, NULL NULL, NULL
}; };
#include <worksheet_shape_builder.h> #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( void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
const wxString& aPaperFormat, const wxString& aPaperFormat,
const wxString& aFileName, const wxString& aFileName,
...@@ -326,22 +312,18 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( ...@@ -326,22 +312,18 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
EDA_COLOR_T aLineColor, EDA_COLOR_T aTextColor ) EDA_COLOR_T aLineColor, EDA_COLOR_T aTextColor )
{ {
wxPoint pos; wxPoint pos;
wxPoint end; wxSize textsize( TEXTSIZE * m_milsToIu, TEXTSIZE * m_milsToIu );
int refx, refy; wxSize size_ref( FRMREF_TXTSIZE * m_milsToIu,
wxString Line; FRMREF_TXTSIZE * m_milsToIu );
Ki_WorkSheetData* WsItem;
wxSize size( SIZETEXT * m_milsToIu, SIZETEXT * m_milsToIu );
wxSize size_ref( SIZETEXT_REF * m_milsToIu, SIZETEXT_REF * m_milsToIu );
wxString msg; wxString msg;
// Upper left corner // Upper left corner
refx = m_LTmargin.x; int refx = m_LTmargin.x;
refy = m_LTmargin.y; int refy = m_LTmargin.y;
// lower right corner // lower right corner
wxPoint currpos; wxPoint currpos;
currpos.x = m_pageSize.x - m_RBmargin.x; currpos = m_pageSize - m_RBmargin;
currpos.y = m_pageSize.y - m_RBmargin.y;
// Draw the border. // Draw the border.
int ii, jj, ipas, gxpas, gypas; int ii, jj, ipas, gxpas, gypas;
...@@ -372,7 +354,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( ...@@ -372,7 +354,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
for( ii = refx + gxpas, jj = 1; ipas > 0; ii += gxpas, jj++, ipas-- ) 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 ) if( ii < currpos.x - PAS_REF / 2 )
{ {
...@@ -382,7 +364,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( ...@@ -382,7 +364,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
m_penSize, aLineColor ) ); m_penSize, aLineColor ) );
} }
Append( new WS_DRAW_ITEM_TEXT( Line, Append( new WS_DRAW_ITEM_TEXT( msg,
wxPoint( ( ii - gxpas / 2 ) * m_milsToIu, wxPoint( ( ii - gxpas / 2 ) * m_milsToIu,
( refy + GRID_REF_W / 2 ) * m_milsToIu ), ( refy + GRID_REF_W / 2 ) * m_milsToIu ),
size_ref, m_penSize, aLineColor ) ); size_ref, m_penSize, aLineColor ) );
...@@ -395,7 +377,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( ...@@ -395,7 +377,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
m_penSize, aLineColor ) ); m_penSize, aLineColor ) );
} }
Append( new WS_DRAW_ITEM_TEXT( Line, Append( new WS_DRAW_ITEM_TEXT( msg,
wxPoint( ( ii - gxpas / 2 ) * m_milsToIu, wxPoint( ( ii - gxpas / 2 ) * m_milsToIu,
( currpos.y - GRID_REF_W / 2) * m_milsToIu ), ( currpos.y - GRID_REF_W / 2) * m_milsToIu ),
size_ref, m_penSize, aLineColor ) ); size_ref, m_penSize, aLineColor ) );
...@@ -407,9 +389,9 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( ...@@ -407,9 +389,9 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
for( ii = refy + gypas, jj = 0; ipas > 0; ii += gypas, jj++, ipas-- ) for( ii = refy + gypas, jj = 0; ipas > 0; ii += gypas, jj++, ipas-- )
{ {
if( jj < 26 ) if( jj < 26 )
Line.Printf( wxT( "%c" ), jj + 'A' ); msg.Printf( wxT( "%c" ), jj + 'A' );
else // I hope 52 identifiers are enough... 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 ) if( ii < currpos.y - PAS_REF / 2 )
{ {
...@@ -419,7 +401,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( ...@@ -419,7 +401,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
m_penSize, aLineColor ) ); 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, wxPoint( ( refx + GRID_REF_W / 2 ) * m_milsToIu,
( ii - gypas / 2 ) * m_milsToIu ), ( ii - gypas / 2 ) * m_milsToIu ),
size_ref, m_penSize, aLineColor ) ); size_ref, m_penSize, aLineColor ) );
...@@ -432,7 +414,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( ...@@ -432,7 +414,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
m_penSize, aLineColor ) ); 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, wxPoint( ( currpos.x - GRID_REF_W / 2 ) * m_milsToIu,
( ii - gxpas / 2 ) * m_milsToIu ), ( ii - gxpas / 2 ) * m_milsToIu ),
size_ref, m_penSize, aLineColor ) ); size_ref, m_penSize, aLineColor ) );
...@@ -443,241 +425,160 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( ...@@ -443,241 +425,160 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
refy = m_pageSize.y - m_RBmargin.y - GRID_REF_W; refy = m_pageSize.y - m_RBmargin.y - GRID_REF_W;
WS_DRAW_ITEM_TEXT* gtext; 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.x = (refx - WsItem->m_Posx) * m_milsToIu;
pos.y = (refy - WsItem->m_Posy) * m_milsToIu; pos.y = (refy - WsItem->m_Posy) * m_milsToIu;
msg.Empty();
switch( WsItem->m_Type ) msg.Empty();
{
case WS_DATE:
if( WsItem->m_Legende ) if( WsItem->m_Legende )
msg = WsItem->m_Legende; msg = WsItem->m_Legende;
msg += FindUserText( WsItem->m_Type, aTitleBlock, aPaperFormat, aFileName,
aSheetPathHumanReadable, aSheetCount, aSheetNumber );
msg += aTitleBlock.GetDate(); switch( WsItem->m_Type )
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; case WS_REV:
Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, size, case WS_TITLE:
GetPenSizeForBold( std::min( size. boldPenSize = GetPenSizeForBold( std::min( textsize.x, textsize.y ) );
x, Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, textsize, boldPenSize,
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 ) ),
aTextColor, false, true ) ); aTextColor, false, true ) );
gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
break; break;
case WS_KICAD_VERSION: 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: 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: 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: 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: case WS_FULLSHEETNAME:
case WS_DATE:
if( WsItem->m_Legende ) Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, textsize,
msg = WsItem->m_Legende;
msg += aSheetPathHumanReadable;
Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, size,
m_penSize, aLineColor ) ); m_penSize, aLineColor ) );
gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
break; break;
case WS_COMPANY_NAME: case WS_COMPANY_NAME:
if( WsItem->m_Legende )
msg = WsItem->m_Legende;
msg += aTitleBlock.GetCompany();
if( !msg.IsEmpty() ) if( !msg.IsEmpty() )
{ {
Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, size, boldPenSize = GetPenSizeForBold( std::min( textsize.x, textsize.y ) );
GetPenSizeForBold( std::min( size. Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, textsize ,boldPenSize,
x,
size.
y ) ),
aTextColor, false, true ) ); aTextColor, false, true ) );
gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
UpperLimit = std::max( UpperLimit, WsItem->m_Posy + SIZETEXT ); UpperLimit = std::max( UpperLimit, WsItem->m_Posy + TEXTSIZE );
} }
break; 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: case WS_COMMENT1:
case WS_COMMENT2:
if( WsItem->m_Legende ) case WS_COMMENT3:
msg = WsItem->m_Legende; case WS_COMMENT4:
msg += aTitleBlock.GetComment1();
if( !msg.IsEmpty() ) 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 ) ); m_penSize, aTextColor ) );
gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
UpperLimit = std::max( UpperLimit, WsItem->m_Posy + SIZETEXT ); UpperLimit = std::max( UpperLimit, WsItem->m_Posy + TEXTSIZE );
} }
break; break;
case WS_COMMENT2: case WS_UPPER_SEGMENT:
if( WsItem->m_Legende ) if( UpperLimit == 0 )
msg = WsItem->m_Legende; break;
msg += aTitleBlock.GetComment2(); case WS_LEFT_SEGMENT:
WS_MostUpperLine.m_Posy = WS_MostUpperLine.m_Endy =
WS_MostLeftLine.m_Posy = UpperLimit;
pos.y = (refy - WsItem->m_Posy) * m_milsToIu;
if( !msg.IsEmpty() ) case WS_SEGMENT:
{ currpos.x = m_pageSize.x - GRID_REF_W - m_RBmargin.x - WsItem->m_Endx;
Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, size, currpos.y = m_pageSize.y - GRID_REF_W - m_RBmargin.y - WsItem->m_Endy;
m_penSize, aTextColor ) ); Append( new WS_DRAW_ITEM_LINE( pos,
gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); wxPoint( currpos.x * m_milsToIu, currpos.y * m_milsToIu ),
UpperLimit = std::max( UpperLimit, WsItem->m_Posy + SIZETEXT ); m_penSize, aLineColor ) );
break;
}
} }
}
// 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; break;
case WS_COMMENT3: case WS_REV:
msg = aTitleBlock.GetRevision();
break;
if( WsItem->m_Legende ) case WS_KICAD_VERSION:
msg = WsItem->m_Legende; msg = g_ProductName + wxGetApp().GetAppName();
msg += wxT( " " ) + GetBuildVersion();
break;
msg += aTitleBlock.GetComment3(); case WS_SIZESHEET:
msg = aPaperFormat;
break;
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 );
}
case WS_IDENTSHEET:
msg << aSheetNumber << wxT( "/" ) << aSheetCount;
break; break;
case WS_COMMENT4: case WS_FILENAME:
{
wxFileName fn( aFileName );
msg = fn.GetFullName();
}
break;
if( WsItem->m_Legende ) case WS_FULLSHEETNAME:
msg = WsItem->m_Legende; msg = aSheetPathHumanReadable;
break;
msg += aTitleBlock.GetComment4(); case WS_COMPANY_NAME:
msg = aTitleBlock.GetCompany();
break;
if( !msg.IsEmpty() ) case WS_TITLE:
{ msg = aTitleBlock.GetTitle();
Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, size, break;
m_penSize, aTextColor ) );
gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
UpperLimit = std::max( UpperLimit, WsItem->m_Posy + SIZETEXT );
}
case WS_COMMENT1:
msg = aTitleBlock.GetComment1();
break; break;
case WS_UPPER_SEGMENT: case WS_COMMENT2:
msg = aTitleBlock.GetComment2();
break;
if( UpperLimit == 0 ) case WS_COMMENT3:
msg = aTitleBlock.GetComment3();
break; break;
case WS_LEFT_SEGMENT: case WS_COMMENT4:
WS_MostUpperLine.m_Posy = msg = aTitleBlock.GetComment4();
WS_MostUpperLine.m_Endy = break;
WS_MostLeftLine.m_Posy = UpperLimit;
pos.y = (refy - WsItem->m_Posy) * m_milsToIu;
case WS_SEGMENT: default:
currpos.x = m_pageSize.x - GRID_REF_W - m_RBmargin.x - WsItem->m_Endx;
currpos.y = m_pageSize.y - GRID_REF_W - m_RBmargin.y - WsItem->m_Endy;
Append( new WS_DRAW_ITEM_LINE( pos,
wxPoint( currpos.x * m_milsToIu, currpos.y * m_milsToIu ),
m_penSize, aLineColor ) );
break; break;
} }
}
return msg;
} }
...@@ -35,8 +35,7 @@ ...@@ -35,8 +35,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#define SIZETEXT 100 // worksheet text size #define TEXTSIZE 100 // worksheet text size
#define SIZETEXT_REF 50 // worksheet frame reference text size
#define PAS_REF 2000 // reference markings on worksheet frame #define PAS_REF 2000 // reference markings on worksheet frame
// used in worksheet.cpp // used in worksheet.cpp
...@@ -974,10 +973,8 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( ...@@ -974,10 +973,8 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
wxPoint pos; wxPoint pos;
wxPoint end; wxPoint end;
int refx, refy; int refx, refy;
wxString Line;
Ki_WorkSheetData* WsItem; Ki_WorkSheetData* WsItem;
wxSize size( SIZETEXT * m_milsToIu, SIZETEXT * m_milsToIu ); wxSize size( TEXTSIZE * m_milsToIu, TEXTSIZE * m_milsToIu );
wxSize size_ref( SIZETEXT_REF * m_milsToIu, SIZETEXT_REF * m_milsToIu );
wxString msg; wxString msg;
WS_DRAW_ITEM_TEXT* gtext; WS_DRAW_ITEM_TEXT* gtext;
...@@ -994,10 +991,10 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( ...@@ -994,10 +991,10 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
int lnWosn = m_penSize * 2; int lnWosn = m_penSize * 2;
int lnWtonk = m_penSize; int lnWtonk = m_penSize;
wxSize sz; wxSize sz;
wxSize size0_8( SIZETEXT * m_milsToIu * 0.8, SIZETEXT * m_milsToIu * 1 ); wxSize size0_8( TEXTSIZE * m_milsToIu * 0.8, TEXTSIZE * m_milsToIu * 1 );
wxSize size1_5( SIZETEXT * m_milsToIu * 1.5, SIZETEXT * m_milsToIu * 1.5 ); wxSize size1_5( TEXTSIZE * m_milsToIu * 1.5, TEXTSIZE * m_milsToIu * 1.5 );
wxSize size2( SIZETEXT * m_milsToIu * 2, SIZETEXT * m_milsToIu * 2 ); wxSize size2( TEXTSIZE * m_milsToIu * 2, TEXTSIZE * m_milsToIu * 2 );
wxSize size3( SIZETEXT * m_milsToIu * 3, SIZETEXT * m_milsToIu * 3 ); wxSize size3( TEXTSIZE * m_milsToIu * 3, TEXTSIZE * m_milsToIu * 3 );
// Draw the border. // Draw the border.
Append( new WS_DRAW_ITEM_RECT( Append( new WS_DRAW_ITEM_RECT(
...@@ -1112,9 +1109,9 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( ...@@ -1112,9 +1109,9 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
int index = 0; int index = 0;
wxString fullMsg = msg; 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; titleWidth = ReturnGraphicTextWidth( msg, sz.x, false, false ) / m_milsToIu;
...@@ -1122,7 +1119,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( ...@@ -1122,7 +1119,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
{ {
index = 0; index = 0;
do while( 1 )
{ {
msg = msg.Left( msg.Length() - 1 ); msg = msg.Left( msg.Length() - 1 );
...@@ -1163,7 +1160,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( ...@@ -1163,7 +1160,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
} }
} }
} }
} while( 1 ); }
} }
else else
{ {
...@@ -1180,7 +1177,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( ...@@ -1180,7 +1177,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
break; break;
} }
} while( 1 ); }
if( titleFieldHeight < (int) ( titleHeight * lines.Count() ) ) if( titleFieldHeight < (int) ( titleHeight * lines.Count() ) )
{ {
...@@ -1191,7 +1188,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( ...@@ -1191,7 +1188,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
} }
else else
break; break;
} while( 1 ); }
pos.x = ( refx - Mm2mils( 85 ) ) * m_milsToIu; pos.x = ( refx - Mm2mils( 85 ) ) * m_milsToIu;
pos.y = pos.y =
......
...@@ -133,6 +133,8 @@ public: ...@@ -133,6 +133,8 @@ public:
WS_DRAW_ITEM_LIST() WS_DRAW_ITEM_LIST()
{ {
m_idx = 0; m_idx = 0;
m_milsToIu = 1.0;
m_penSize = 1;
} }
~WS_DRAW_ITEM_LIST() ~WS_DRAW_ITEM_LIST()
......
...@@ -530,27 +530,24 @@ wxString SCH_EDIT_FRAME::GetUniqueFilenameForCurrentSheet() ...@@ -530,27 +530,24 @@ wxString SCH_EDIT_FRAME::GetUniqueFilenameForCurrentSheet()
* However if filename is too long name is <sheet filename>-<sheet number> * 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.GetName();
wxString filename = fn.GetFullPath(); wxString sheetFullName = m_CurrentSheet->PathHumanReadable();
if( ( filename.Len() + m_CurrentSheet->PathHumanReadable().Len() ) < FN_LEN_MAX ) sheetFullName.Trim( true );
{ sheetFullName.Trim( false );
filename += m_CurrentSheet->PathHumanReadable();
filename.Replace( wxT( "/" ), wxT( "-" ) ); // Remove the last '/' of the path human readable
filename.RemoveLast(); // (and for the root sheet, make sheetFullName empty):
// To avoid issues on unix, ensure the filename does not start sheetFullName.RemoveLast();
// by '-', which has a special meaning in command lines
#ifndef __WINDOWS__ // Convert path human readable separator to '-'
wxString newfn; sheetFullName.Replace( wxT( "/" ), wxT( "-" ) );
if( filename.StartsWith( wxT( "-" ), &newfn ) )
filename = newfn; if( ( filename.Len() + sheetFullName.Len() ) < FN_LEN_MAX )
#endif filename += sheetFullName;
}
else else
{
filename << wxT( "-" ) << GetScreen()->m_ScreenNumber; filename << wxT( "-" ) << GetScreen()->m_ScreenNumber;
}
return filename; return filename;
} }
......
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