2013-05-19 19:35:49 +00:00
|
|
|
/**
|
|
|
|
* @file worksheet.cpp
|
|
|
|
* @brief Common code to draw the title block and frame references
|
|
|
|
* @note it should include title_block_shape_gost.h or title_block_shape.h
|
|
|
|
* which defines most of draw shapes, and contains a part of the draw code
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1992-2013 KiCad Developers, see change_log.txt for contributors.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
2013-05-25 09:01:44 +00:00
|
|
|
#include <appl_wxstruct.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <class_base_screen.h>
|
|
|
|
#include <drawtxt.h>
|
|
|
|
#include <wxstruct.h>
|
|
|
|
#include <worksheet.h>
|
|
|
|
#include <class_title_block.h>
|
2013-05-25 09:01:44 +00:00
|
|
|
#include <build_version.h>
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2013-05-21 07:18:25 +00:00
|
|
|
#include <worksheet_shape_builder.h>
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2013-05-30 19:32:00 +00:00
|
|
|
static const wxString productName = wxT( "KiCad E.D.A. " );
|
|
|
|
|
2013-06-29 09:52:22 +00:00
|
|
|
void DrawPageLayout( wxDC* aDC, EDA_RECT* aClipBox,
|
|
|
|
const PAGE_INFO& aPageInfo,
|
|
|
|
const wxString &aFullSheetName,
|
|
|
|
const wxString& aFileName,
|
|
|
|
TITLE_BLOCK& aTitleBlock,
|
|
|
|
int aSheetCount, int aSheetNumber,
|
|
|
|
int aPenWidth, double aScalar,
|
|
|
|
EDA_COLOR_T aColor, EDA_COLOR_T aAltColor )
|
|
|
|
{
|
|
|
|
GRSetDrawMode( aDC, GR_COPY );
|
|
|
|
WS_DRAW_ITEM_LIST drawList;
|
|
|
|
|
|
|
|
drawList.SetPenSize( aPenWidth );
|
|
|
|
drawList.SetMilsToIUfactor( aScalar );
|
|
|
|
drawList.SetSheetNumber( aSheetNumber );
|
|
|
|
drawList.SetSheetCount( aSheetCount );
|
2013-07-19 18:27:22 +00:00
|
|
|
drawList.SetFileName( aFileName );
|
|
|
|
drawList.SetSheetName( aFullSheetName );
|
2013-06-29 09:52:22 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
drawList.BuildWorkSheetGraphicList( aPageInfo,
|
2013-06-29 09:52:22 +00:00
|
|
|
aTitleBlock, aColor, aAltColor );
|
|
|
|
|
|
|
|
// Draw item list
|
|
|
|
drawList.Draw( aClipBox, aDC );
|
|
|
|
}
|
|
|
|
|
2013-05-19 19:35:49 +00:00
|
|
|
|
2013-05-22 08:45:25 +00:00
|
|
|
void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth,
|
2012-08-29 16:59:50 +00:00
|
|
|
double aScalar, const wxString &aFilename )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-12-14 20:03:15 +00:00
|
|
|
if( !m_showBorderAndTitleBlock )
|
2008-03-04 14:27:48 +00:00
|
|
|
return;
|
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
const PAGE_INFO& pageInfo = GetPageSettings();
|
|
|
|
wxSize pageSize = pageInfo.GetSizeMils();
|
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
// if not printing, draw the page limits:
|
2012-04-16 01:25:26 +00:00
|
|
|
if( !aScreen->m_IsPrinting && g_ShowPageLimits )
|
2008-03-04 14:27:48 +00:00
|
|
|
{
|
2012-04-16 01:25:26 +00:00
|
|
|
GRSetDrawMode( aDC, GR_COPY );
|
|
|
|
GRRect( m_canvas->GetClipBox(), aDC, 0, 0,
|
|
|
|
pageSize.x * aScalar, pageSize.y * aScalar, aLineWidth,
|
2009-04-05 20:49:15 +00:00
|
|
|
g_DrawBgColor == WHITE ? LIGHTGRAY : DARKDARKGRAY );
|
2008-03-04 14:27:48 +00:00
|
|
|
}
|
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
TITLE_BLOCK t_block = GetTitleBlock();
|
2013-05-22 08:45:25 +00:00
|
|
|
EDA_COLOR_T color = RED;
|
2012-03-26 21:45:05 +00:00
|
|
|
|
2013-06-29 09:52:22 +00:00
|
|
|
DrawPageLayout( aDC, m_canvas->GetClipBox(), pageInfo,
|
2013-07-19 18:27:22 +00:00
|
|
|
GetScreenDesc(), aFilename, t_block,
|
2013-05-22 08:45:25 +00:00
|
|
|
aScreen->m_NumberOfScreens, aScreen->m_ScreenNumber,
|
|
|
|
aLineWidth, aScalar, color, color );
|
2012-03-26 21:45:05 +00:00
|
|
|
}
|
2011-12-22 21:57:50 +00:00
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
wxString EDA_DRAW_FRAME::GetScreenDesc()
|
2008-02-12 21:12:46 +00:00
|
|
|
{
|
2013-07-19 18:27:22 +00:00
|
|
|
// Virtual function. In basic class, returns
|
2013-05-27 09:17:37 +00:00
|
|
|
// an empty string.
|
|
|
|
return wxEmptyString;
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2012-04-01 20:51:56 +00:00
|
|
|
|
2013-05-25 09:01:44 +00:00
|
|
|
// returns the full text corresponding to the aTextbase,
|
|
|
|
// after replacing format symbols by the corresponding value
|
|
|
|
wxString WS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
/* Known formats
|
|
|
|
* %% = replaced by %
|
|
|
|
* %K = Kicad version
|
|
|
|
* %Z = paper format name (A4, USLetter)
|
|
|
|
* %Y = company name
|
|
|
|
* %D = date
|
|
|
|
* %R = revision
|
|
|
|
* %S = sheet number
|
|
|
|
* %N = number of sheets
|
|
|
|
* %Cx = comment (x = 0 to 9 to identify the comment)
|
|
|
|
* %F = filename
|
|
|
|
* %P = sheet path (sheet full name)
|
|
|
|
* %T = title
|
|
|
|
*/
|
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < aTextbase.Len(); ii++ )
|
|
|
|
{
|
|
|
|
if( aTextbase[ii] != '%' )
|
|
|
|
{
|
|
|
|
msg << aTextbase[ii];
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ii++;
|
|
|
|
if( ii >= aTextbase.Len() )
|
|
|
|
break;
|
|
|
|
|
|
|
|
wxChar format = aTextbase[ii];
|
|
|
|
switch( format )
|
|
|
|
{
|
|
|
|
case '%':
|
|
|
|
msg += '%';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'D':
|
|
|
|
msg += m_titleBlock->GetDate();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'R':
|
|
|
|
msg += m_titleBlock->GetRevision();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'K':
|
2013-05-30 19:32:00 +00:00
|
|
|
msg += productName + wxGetApp().GetAppName();
|
2013-05-25 09:01:44 +00:00
|
|
|
msg += wxT( " " ) + GetBuildVersion();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Z':
|
|
|
|
msg += *m_paperFormat;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'S':
|
|
|
|
msg << m_sheetNumber;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'N':
|
|
|
|
msg << m_sheetCount;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'F':
|
|
|
|
{
|
|
|
|
wxFileName fn( *m_fileName );
|
|
|
|
msg += fn.GetFullName();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'P':
|
|
|
|
msg += *m_sheetFullName;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Y':
|
|
|
|
msg = m_titleBlock->GetCompany();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'T':
|
|
|
|
msg += m_titleBlock->GetTitle();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'C':
|
|
|
|
format = aTextbase[++ii];
|
|
|
|
switch( format )
|
|
|
|
{
|
2013-06-05 12:03:16 +00:00
|
|
|
case '0':
|
2013-05-25 09:01:44 +00:00
|
|
|
case '1':
|
|
|
|
case '2':
|
|
|
|
case '3':
|
|
|
|
case '4':
|
2013-06-05 12:03:16 +00:00
|
|
|
case '5':
|
|
|
|
case '6':
|
|
|
|
case '7':
|
|
|
|
case '8':
|
|
|
|
case '9':
|
|
|
|
msg += m_titleBlock->GetComment( format - '0');
|
2013-05-25 09:01:44 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2012-04-01 20:51:56 +00:00
|
|
|
|
|
|
|
void TITLE_BLOCK::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
|
|
|
|
throw( IO_ERROR )
|
|
|
|
{
|
|
|
|
// Don't write the title block information if there is nothing to write.
|
2013-06-05 12:03:16 +00:00
|
|
|
bool isempty = true;
|
|
|
|
for( unsigned idx = 0; idx < m_tbTexts.GetCount(); idx++ )
|
|
|
|
{
|
|
|
|
if( ! m_tbTexts[idx].IsEmpty() )
|
|
|
|
{
|
|
|
|
isempty = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !isempty )
|
2012-04-01 20:51:56 +00:00
|
|
|
{
|
2013-05-23 18:45:23 +00:00
|
|
|
aFormatter->Print( aNestLevel, "(title_block\n" );
|
2012-04-01 20:51:56 +00:00
|
|
|
|
2013-06-05 12:03:16 +00:00
|
|
|
if( !GetTitle().IsEmpty() )
|
2012-06-09 17:00:13 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(title %s)\n",
|
2013-06-05 12:03:16 +00:00
|
|
|
aFormatter->Quotew( GetTitle() ).c_str() );
|
2012-04-01 20:51:56 +00:00
|
|
|
|
2013-06-05 12:03:16 +00:00
|
|
|
if( !GetDate().IsEmpty() )
|
2012-06-09 17:00:13 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(date %s)\n",
|
2013-06-05 12:03:16 +00:00
|
|
|
aFormatter->Quotew( GetDate() ).c_str() );
|
2012-04-01 20:51:56 +00:00
|
|
|
|
2013-06-05 12:03:16 +00:00
|
|
|
if( !GetRevision().IsEmpty() )
|
2012-06-09 17:00:13 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(rev %s)\n",
|
2013-06-05 12:03:16 +00:00
|
|
|
aFormatter->Quotew( GetRevision() ).c_str() );
|
2012-04-01 20:51:56 +00:00
|
|
|
|
2013-06-05 12:03:16 +00:00
|
|
|
if( !GetCompany().IsEmpty() )
|
2012-06-09 17:00:13 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(company %s)\n",
|
2013-06-05 12:03:16 +00:00
|
|
|
aFormatter->Quotew( GetCompany() ).c_str() );
|
2012-04-01 20:51:56 +00:00
|
|
|
|
2013-06-30 17:40:33 +00:00
|
|
|
for( int ii = 0; ii < 4; ii++ )
|
2013-06-05 12:03:16 +00:00
|
|
|
{
|
|
|
|
if( !GetComment(ii).IsEmpty() )
|
|
|
|
aFormatter->Print( aNestLevel+1, "(comment %d %s)\n", ii+1,
|
2013-06-30 17:40:33 +00:00
|
|
|
aFormatter->Quotew( GetComment(ii) ).c_str() );
|
2013-06-05 12:03:16 +00:00
|
|
|
}
|
2012-04-01 20:51:56 +00:00
|
|
|
|
2012-04-07 18:05:56 +00:00
|
|
|
aFormatter->Print( aNestLevel, ")\n\n" );
|
2012-04-01 20:51:56 +00:00
|
|
|
}
|
|
|
|
}
|