Internal unit improvements and Pcbnew s-expression file format changes.

* Move EDA_TEXT object into separate header and source file.
* Compile EDA_TEXT class separately for BOARD_ITEM and SCH_ITEM units.
* Compile PAGE_INFO  class separately for BOARD_ITEM and SCH_ITEM units.
* Minor formatting tweaks to Pcbnew s-expression file.
* Move internal unit formatting functions into BOARD_ITEM and SCH_ITEM.
This commit is contained in:
Wayne Stambaugh 2012-04-12 17:31:31 -04:00
parent 38ea600803
commit bed96be750
41 changed files with 986 additions and 837 deletions

View File

@ -427,17 +427,3 @@ bool EDA_APP::OnInit()
void EDA_APP::MacOpenFile(const wxString &fileName) void EDA_APP::MacOpenFile(const wxString &fileName)
{ {
} }
/**
* @copydoc
*
* This is a dummy since KiCad doesn't perform any interal unit formatting.
*/
/** @todo Remove FormatBIU() when the common DSO/DSL code is implemented. */
std::string FormatBIU( int aValue )
{
return "";
}

View File

@ -36,7 +36,6 @@ set(COMMON_SRCS
class_bitmap_base.cpp class_bitmap_base.cpp
class_colors_design_settings.cpp class_colors_design_settings.cpp
class_marker_base.cpp class_marker_base.cpp
class_page_info.cpp
class_plotter.cpp class_plotter.cpp
class_undoredo_container.cpp class_undoredo_container.cpp
common.cpp common.cpp
@ -84,6 +83,8 @@ add_library(common STATIC ${COMMON_SRCS})
set(PCB_COMMON_SRCS set(PCB_COMMON_SRCS
base_screen.cpp base_screen.cpp
eda_text.cpp
class_page_info.cpp
pcbcommon.cpp pcbcommon.cpp
footprint_info.cpp footprint_info.cpp
class_layer_box_selector.cpp class_layer_box_selector.cpp

View File

@ -24,11 +24,10 @@
/** /**
* @file base_struct.cpp * @file base_struct.cpp
* @brief Implementation of EDA_ITEM and EDA_TEXT base classes for KiCad. * @brief Implementation of EDA_ITEM base class for KiCad.
*/ */
#include <fctsys.h> #include <fctsys.h>
#include <gr_basic.h>
#include <trigo.h> #include <trigo.h>
#include <common.h> #include <common.h>
#include <macros.h> #include <macros.h>
@ -36,7 +35,6 @@
#include <wxstruct.h> #include <wxstruct.h>
#include <class_drawpanel.h> #include <class_drawpanel.h>
#include <class_base_screen.h> #include <class_base_screen.h>
#include <drawtxt.h>
#include "../eeschema/dialogs/dialog_schematic_find.h" #include "../eeschema/dialogs/dialog_schematic_find.h"
@ -274,364 +272,6 @@ std::ostream& EDA_ITEM::NestedSpace( int nestLevel, std::ostream& os )
#endif #endif
/*******************************************/
/* EDA_TEXT (base class, not directly used */
/*******************************************/
EDA_TEXT::EDA_TEXT( const wxString& text )
{
m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT; // Width and height of font.
m_Orient = 0; // Rotation angle in 0.1 degrees.
m_Attributs = 0;
m_Mirror = false; // display mirror if true
m_HJustify = GR_TEXT_HJUSTIFY_CENTER; // Default horizontal justification is centered.
m_VJustify = GR_TEXT_VJUSTIFY_CENTER; // Default vertical justification is centered.
m_Thickness = 0; // thickness
m_Italic = false; // true = italic shape.
m_Bold = false;
m_MultilineAllowed = false; // Set to true for multiline text.
m_Text = text;
}
EDA_TEXT::EDA_TEXT( const EDA_TEXT& aText )
{
m_Pos = aText.m_Pos;
m_Size = aText.m_Size;
m_Orient = aText.m_Orient;
m_Attributs = aText.m_Attributs;
m_Mirror = aText.m_Mirror;
m_HJustify = aText.m_HJustify;
m_VJustify = aText.m_VJustify;
m_Thickness = aText.m_Thickness;
m_Italic = aText.m_Italic;
m_Bold = aText.m_Bold;
m_MultilineAllowed = aText.m_MultilineAllowed;
m_Text = aText.m_Text;
}
EDA_TEXT::~EDA_TEXT()
{
}
int EDA_TEXT::LenSize( const wxString& aLine ) const
{
return ReturnGraphicTextWidth( aLine, m_Size.x, m_Italic, m_Bold );
}
EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
{
EDA_RECT rect;
wxPoint pos;
wxArrayString* list = NULL;
wxString text = m_Text;
int thickness = ( aThickness < 0 ) ? m_Thickness : aThickness;
if( m_MultilineAllowed )
{
list = wxStringSplit( m_Text, '\n' );
if ( list->GetCount() ) // GetCount() == 0 for void strings
{
if( aLine >= 0 && (aLine < (int)list->GetCount()) )
text = list->Item( aLine );
else
text = list->Item( 0 );
}
}
// calculate the H and V size
int dx = LenSize( text );
int dy = GetInterline();
/* Creates bounding box (rectangle) for an horizontal text */
wxSize textsize = wxSize( dx, dy );
if( aInvertY )
rect.SetOrigin( m_Pos.x, -m_Pos.y );
else
rect.SetOrigin( m_Pos );
// extra dy interval for letters like j and y and ]
int extra_dy = dy - m_Size.y;
rect.Move( wxPoint( 0, -extra_dy / 2 ) ); // move origin by the half extra interval
// for multiline texts and aLine < 0, merge all rectangles
if( m_MultilineAllowed && list && aLine < 0 )
{
for( unsigned ii = 1; ii < list->GetCount(); ii++ )
{
text = list->Item( ii );
dx = LenSize( text );
textsize.x = MAX( textsize.x, dx );
textsize.y += dy;
}
}
delete list;
rect.SetSize( textsize );
/* Now, calculate the rect origin, according to text justification
* At this point the rectangle origin is the text origin (m_Pos).
* This is true only for left and top text justified texts (using top to bottom Y axis
* orientation). and must be recalculated for others justifications
* also, note the V justification is relative to the first line
*/
switch( m_HJustify )
{
case GR_TEXT_HJUSTIFY_LEFT:
if( m_Mirror )
rect.SetX( rect.GetX() - rect.GetWidth() );
break;
case GR_TEXT_HJUSTIFY_CENTER:
rect.SetX( rect.GetX() - (rect.GetWidth() / 2) );
break;
case GR_TEXT_HJUSTIFY_RIGHT:
if( !m_Mirror )
rect.SetX( rect.GetX() - rect.GetWidth() );
break;
}
dy = m_Size.y + thickness;
switch( m_VJustify )
{
case GR_TEXT_VJUSTIFY_TOP:
break;
case GR_TEXT_VJUSTIFY_CENTER:
rect.SetY( rect.GetY() - (dy / 2) );
break;
case GR_TEXT_VJUSTIFY_BOTTOM:
rect.SetY( rect.GetY() - dy );
break;
}
rect.Inflate( thickness / 2 );
rect.Normalize(); // Make h and v sizes always >= 0
return rect;
}
bool EDA_TEXT::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const
{
EDA_RECT rect = GetTextBox( -1 ); // Get the full text area.
wxPoint location = aPoint;
rect.Inflate( aAccuracy );
RotatePoint( &location, m_Pos, -m_Orient );
return rect.Contains( location );
}
bool EDA_TEXT::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy ) const
{
EDA_RECT rect = aRect;
rect.Inflate( aAccuracy );
if( aContains )
return rect.Contains( GetTextBox( -1 ) );
return rect.Intersects( GetTextBox( -1 ) );
}
void EDA_TEXT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
EDA_COLOR_T aColor, int aDrawMode,
EDA_DRAW_MODE_T aFillMode, EDA_COLOR_T aAnchor_color )
{
if( m_MultilineAllowed )
{
wxPoint pos = m_Pos;
wxArrayString* list = wxStringSplit( m_Text, '\n' );
wxPoint offset;
offset.y = GetInterline();
RotatePoint( &offset, m_Orient );
for( unsigned i = 0; i<list->Count(); i++ )
{
wxString txt = list->Item( i );
DrawOneLineOfText( aPanel,
aDC,
aOffset,
aColor,
aDrawMode,
aFillMode,
i ? UNSPECIFIED : aAnchor_color,
txt,
pos );
pos += offset;
}
delete (list);
}
else
DrawOneLineOfText( aPanel,
aDC,
aOffset,
aColor,
aDrawMode,
aFillMode,
aAnchor_color,
m_Text,
m_Pos );
}
void EDA_TEXT::DrawOneLineOfText( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aOffset, EDA_COLOR_T aColor,
int aDrawMode, EDA_DRAW_MODE_T aFillMode,
EDA_COLOR_T aAnchor_color,
wxString& aText, wxPoint aPos )
{
int width = m_Thickness;
if( aFillMode == LINE )
width = 0;
if( aDrawMode != -1 )
GRSetDrawMode( aDC, aDrawMode );
/* Draw text anchor, if allowed */
if( aAnchor_color != UNSPECIFIED )
{
int anchor_size = aDC->DeviceToLogicalXRel( 2 );
aAnchor_color = (EDA_COLOR_T) ( aAnchor_color & MASKCOLOR );
int cX = aPos.x + aOffset.x;
int cY = aPos.y + aOffset.y;
GRLine( aPanel->GetClipBox(), aDC, cX - anchor_size, cY,
cX + anchor_size, cY, 0, aAnchor_color );
GRLine( aPanel->GetClipBox(), aDC, cX, cY - anchor_size,
cX, cY + anchor_size, 0, aAnchor_color );
}
if( aFillMode == SKETCH )
width = -width;
wxSize size = m_Size;
if( m_Mirror )
size.x = -size.x;
DrawGraphicText( aPanel, aDC, aOffset + aPos, aColor, aText, m_Orient, size,
m_HJustify, m_VJustify, width, m_Italic, m_Bold );
}
wxString EDA_TEXT::GetTextStyleName()
{
int style = 0;
if( m_Italic )
style = 1;
if( m_Bold )
style += 2;
wxString stylemsg[4] = {
_("Normal"),
_("Italic"),
_("Bold"),
_("Bold+Italic")
};
return stylemsg[style];
}
bool EDA_TEXT::IsDefaultFormatting() const
{
return ( ( m_Size.x == DEFAULT_SIZE_TEXT )
&& ( m_Size.y == DEFAULT_SIZE_TEXT )
&& ( m_Attributs == 0 )
&& ( m_Mirror == false )
&& ( m_HJustify == GR_TEXT_HJUSTIFY_CENTER )
&& ( m_VJustify == GR_TEXT_VJUSTIFY_CENTER )
&& ( m_Thickness == 0 )
&& ( m_Italic == false )
&& ( m_Bold == false )
&& ( m_MultilineAllowed == false ) );
}
void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR )
{
aFormatter->Print( aNestLevel, "(text %s (at %s",
aFormatter->Quotew( m_Text ).c_str(), FormatBIU( m_Pos ).c_str() );
if( m_Orient != 0.0 )
aFormatter->Print( 0, " %0.1f", m_Orient );
aFormatter->Print( 0, ")\n" );
if( !IsDefaultFormatting() )
{
aFormatter->Print( aNestLevel+1, "(effects\n" );
if( ( m_Size.x != DEFAULT_SIZE_TEXT ) || ( m_Size.y != DEFAULT_SIZE_TEXT ) || m_Bold
|| m_Italic )
{
aFormatter->Print( aNestLevel+2, "(font" );
// Add font support here at some point in the future.
if( ( m_Size.x != DEFAULT_SIZE_TEXT ) || ( m_Size.y != DEFAULT_SIZE_TEXT ) )
aFormatter->Print( 0, " (size %s)", FormatBIU( m_Size ).c_str() );
if( m_Bold )
aFormatter->Print( 0, " bold" );
if( m_Bold )
aFormatter->Print( 0, " italic" );
aFormatter->Print( 0, ")\n");
}
if( m_Mirror || ( m_HJustify != GR_TEXT_HJUSTIFY_CENTER )
|| ( m_VJustify != GR_TEXT_VJUSTIFY_CENTER ) )
{
aFormatter->Print( aNestLevel+2, "(justify");
if( m_HJustify != GR_TEXT_HJUSTIFY_CENTER )
aFormatter->Print( 0, (m_HJustify == GR_TEXT_HJUSTIFY_LEFT) ? " left" : " right" );
if( m_VJustify != GR_TEXT_VJUSTIFY_CENTER )
aFormatter->Print( 0, (m_VJustify == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" );
if( m_Mirror )
aFormatter->Print( 0, " mirror" );
aFormatter->Print( 0, ")\n" );
}
// As of now the only place this is used is in Eeschema to hide or show the text.
if( m_Attributs )
aFormatter->Print( aNestLevel+2, "hide\n" );
aFormatter->Print( aNestLevel+1, ")\n" );
}
aFormatter->Print( aNestLevel, ")\n" );
}
/******************/ /******************/
/* Class EDA_RECT */ /* Class EDA_RECT */
/******************/ /******************/

View File

@ -36,6 +36,7 @@
#define PAPER_A1 wxPAPER_A2 #define PAPER_A1 wxPAPER_A2
#endif #endif
// Standard paper sizes nicknames. // Standard paper sizes nicknames.
const wxString PAGE_INFO::A4( wxT( "A4" ) ); const wxString PAGE_INFO::A4( wxT( "A4" ) );
const wxString PAGE_INFO::A3( wxT( "A3" ) ); const wxString PAGE_INFO::A3( wxT( "A3" ) );
@ -318,11 +319,11 @@ void PAGE_INFO::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aContro
// If page is A3 landscape, then it is assumed to be the default and is not written. // If page is A3 landscape, then it is assumed to be the default and is not written.
if( !IsDefault() ) if( !IsDefault() )
{ {
aFormatter->Print( aNestLevel, "(page %s", TO_UTF8( GetType() ) ); aFormatter->Print( aNestLevel, "(page %s", aFormatter->Quotew( GetType() ).c_str() );
// The page dimensions are only required for user defined page sizes. // The page dimensions are only required for user defined page sizes.
if( GetType() == PAGE_INFO::Custom ) if( GetType() == PAGE_INFO::Custom )
aFormatter->Print( aNestLevel, " %d %d", GetWidthMils(), GetHeightMils() ); aFormatter->Print( aNestLevel, " %d %d", GetWidthIU(), GetHeightIU() );
if( IsCustom() && IsPortrait() ) if( IsCustom() && IsPortrait() )
aFormatter->Print( aNestLevel, " portrait" ); aFormatter->Print( aNestLevel, " portrait" );

View File

@ -560,15 +560,3 @@ wxString& operator <<( wxString& aString, const wxPoint& aPos )
return aString; return aString;
} }
std::string FormatBIU( const wxPoint& aPoint )
{
return FormatBIU( aPoint.x ) + " " + FormatBIU( aPoint.y );
}
std::string FormatBIU( const wxSize& aSize )
{
return FormatBIU( aSize.GetWidth() ) + " " + FormatBIU( aSize.GetHeight() );
}

View File

@ -4,10 +4,9 @@
*/ */
#include <fctsys.h> #include <fctsys.h>
#include <gr_basic.h> #include <gr_basic.h>
#include <common.h> #include <common.h>
#include <plot_common.h> #include <plot_common.h>
#include <eda_text.h> // EDA_TEXT_HJUSTIFY_T and EDA_TEXT_VJUSTIFY_T
#include <trigo.h> #include <trigo.h>
#include <macros.h> #include <macros.h>
#include <class_drawpanel.h> #include <class_drawpanel.h>

405
common/eda_text.cpp Normal file
View File

@ -0,0 +1,405 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2004-2011 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
*/
/**
* @file eda_text.cpp
* @brief Implementation of base KiCad text object.
*/
#include <eda_text.h>
#include <drawtxt.h>
#include <macros.h> // MAX
#include <trigo.h> // RotatePoint
#include <class_drawpanel.h> // EDA_DRAW_PANEL
// Conversion to application internal units defined at build time.
#if defined( PCBNEW )
#include <class_board_item.h>
#if defined( USE_PCBNEW_NANOMETRES )
#define MILS_TO_IU( x ) ( x * 25400 );
#else
#define MILS_TO_IU( x ) ( x * 10 )
#endif
#elif defined( EESCHEMA )
#include <sch_item_struct.h>
#define MILS_TO_IU( x ) ( x )
#else
#error "Cannot resolve units formatting due to no definition of EESCHEMA or PCBNEW."
#endif
EDA_TEXT::EDA_TEXT( const wxString& text )
{
m_Size.x = m_Size.y = MILS_TO_IU( DEFAULT_SIZE_TEXT ); // Width and height of font.
m_Orient = 0; // Rotation angle in 0.1 degrees.
m_Attributs = 0;
m_Mirror = false; // display mirror if true
m_HJustify = GR_TEXT_HJUSTIFY_CENTER; // Default horizontal justification is centered.
m_VJustify = GR_TEXT_VJUSTIFY_CENTER; // Default vertical justification is centered.
m_Thickness = 0; // thickness
m_Italic = false; // true = italic shape.
m_Bold = false;
m_MultilineAllowed = false; // Set to true for multiline text.
m_Text = text;
}
EDA_TEXT::EDA_TEXT( const EDA_TEXT& aText )
{
m_Pos = aText.m_Pos;
m_Size = aText.m_Size;
m_Orient = aText.m_Orient;
m_Attributs = aText.m_Attributs;
m_Mirror = aText.m_Mirror;
m_HJustify = aText.m_HJustify;
m_VJustify = aText.m_VJustify;
m_Thickness = aText.m_Thickness;
m_Italic = aText.m_Italic;
m_Bold = aText.m_Bold;
m_MultilineAllowed = aText.m_MultilineAllowed;
m_Text = aText.m_Text;
}
EDA_TEXT::~EDA_TEXT()
{
}
int EDA_TEXT::LenSize( const wxString& aLine ) const
{
return ReturnGraphicTextWidth( aLine, m_Size.x, m_Italic, m_Bold );
}
EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
{
EDA_RECT rect;
wxPoint pos;
wxArrayString* list = NULL;
wxString text = m_Text;
int thickness = ( aThickness < 0 ) ? m_Thickness : aThickness;
if( m_MultilineAllowed )
{
list = wxStringSplit( m_Text, '\n' );
if ( list->GetCount() ) // GetCount() == 0 for void strings
{
if( aLine >= 0 && (aLine < (int)list->GetCount()) )
text = list->Item( aLine );
else
text = list->Item( 0 );
}
}
// calculate the H and V size
int dx = LenSize( text );
int dy = GetInterline();
/* Creates bounding box (rectangle) for an horizontal text */
wxSize textsize = wxSize( dx, dy );
if( aInvertY )
rect.SetOrigin( m_Pos.x, -m_Pos.y );
else
rect.SetOrigin( m_Pos );
// extra dy interval for letters like j and y and ]
int extra_dy = dy - m_Size.y;
rect.Move( wxPoint( 0, -extra_dy / 2 ) ); // move origin by the half extra interval
// for multiline texts and aLine < 0, merge all rectangles
if( m_MultilineAllowed && list && aLine < 0 )
{
for( unsigned ii = 1; ii < list->GetCount(); ii++ )
{
text = list->Item( ii );
dx = LenSize( text );
textsize.x = MAX( textsize.x, dx );
textsize.y += dy;
}
}
delete list;
rect.SetSize( textsize );
/* Now, calculate the rect origin, according to text justification
* At this point the rectangle origin is the text origin (m_Pos).
* This is true only for left and top text justified texts (using top to bottom Y axis
* orientation). and must be recalculated for others justifications
* also, note the V justification is relative to the first line
*/
switch( m_HJustify )
{
case GR_TEXT_HJUSTIFY_LEFT:
if( m_Mirror )
rect.SetX( rect.GetX() - rect.GetWidth() );
break;
case GR_TEXT_HJUSTIFY_CENTER:
rect.SetX( rect.GetX() - (rect.GetWidth() / 2) );
break;
case GR_TEXT_HJUSTIFY_RIGHT:
if( !m_Mirror )
rect.SetX( rect.GetX() - rect.GetWidth() );
break;
}
dy = m_Size.y + thickness;
switch( m_VJustify )
{
case GR_TEXT_VJUSTIFY_TOP:
break;
case GR_TEXT_VJUSTIFY_CENTER:
rect.SetY( rect.GetY() - (dy / 2) );
break;
case GR_TEXT_VJUSTIFY_BOTTOM:
rect.SetY( rect.GetY() - dy );
break;
}
rect.Inflate( thickness / 2 );
rect.Normalize(); // Make h and v sizes always >= 0
return rect;
}
bool EDA_TEXT::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const
{
EDA_RECT rect = GetTextBox( -1 ); // Get the full text area.
wxPoint location = aPoint;
rect.Inflate( aAccuracy );
RotatePoint( &location, m_Pos, -m_Orient );
return rect.Contains( location );
}
bool EDA_TEXT::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy ) const
{
EDA_RECT rect = aRect;
rect.Inflate( aAccuracy );
if( aContains )
return rect.Contains( GetTextBox( -1 ) );
return rect.Intersects( GetTextBox( -1 ) );
}
void EDA_TEXT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
EDA_COLOR_T aColor, int aDrawMode,
EDA_DRAW_MODE_T aFillMode, EDA_COLOR_T aAnchor_color )
{
if( m_MultilineAllowed )
{
wxPoint pos = m_Pos;
wxArrayString* list = wxStringSplit( m_Text, '\n' );
wxPoint offset;
offset.y = GetInterline();
RotatePoint( &offset, m_Orient );
for( unsigned i = 0; i<list->Count(); i++ )
{
wxString txt = list->Item( i );
DrawOneLineOfText( aPanel,
aDC,
aOffset,
aColor,
aDrawMode,
aFillMode,
i ? UNSPECIFIED : aAnchor_color,
txt,
pos );
pos += offset;
}
delete (list);
}
else
DrawOneLineOfText( aPanel,
aDC,
aOffset,
aColor,
aDrawMode,
aFillMode,
aAnchor_color,
m_Text,
m_Pos );
}
void EDA_TEXT::DrawOneLineOfText( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aOffset, EDA_COLOR_T aColor,
int aDrawMode, EDA_DRAW_MODE_T aFillMode,
EDA_COLOR_T aAnchor_color,
wxString& aText, wxPoint aPos )
{
int width = m_Thickness;
if( aFillMode == LINE )
width = 0;
if( aDrawMode != -1 )
GRSetDrawMode( aDC, aDrawMode );
/* Draw text anchor, if allowed */
if( aAnchor_color != UNSPECIFIED )
{
int anchor_size = aDC->DeviceToLogicalXRel( 2 );
aAnchor_color = (EDA_COLOR_T) ( aAnchor_color & MASKCOLOR );
int cX = aPos.x + aOffset.x;
int cY = aPos.y + aOffset.y;
GRLine( aPanel->GetClipBox(), aDC, cX - anchor_size, cY,
cX + anchor_size, cY, 0, aAnchor_color );
GRLine( aPanel->GetClipBox(), aDC, cX, cY - anchor_size,
cX, cY + anchor_size, 0, aAnchor_color );
}
if( aFillMode == SKETCH )
width = -width;
wxSize size = m_Size;
if( m_Mirror )
size.x = -size.x;
DrawGraphicText( aPanel, aDC, aOffset + aPos, aColor, aText, m_Orient, size,
m_HJustify, m_VJustify, width, m_Italic, m_Bold );
}
wxString EDA_TEXT::GetTextStyleName()
{
int style = 0;
if( m_Italic )
style = 1;
if( m_Bold )
style += 2;
wxString stylemsg[4] = {
_("Normal"),
_("Italic"),
_("Bold"),
_("Bold+Italic")
};
return stylemsg[style];
}
bool EDA_TEXT::IsDefaultFormatting() const
{
return ( ( m_Size.x == DEFAULT_SIZE_TEXT )
&& ( m_Size.y == DEFAULT_SIZE_TEXT )
&& ( m_Attributs == 0 )
&& ( m_Mirror == false )
&& ( m_HJustify == GR_TEXT_HJUSTIFY_CENTER )
&& ( m_VJustify == GR_TEXT_VJUSTIFY_CENTER )
&& ( m_Thickness == 0 )
&& ( m_Italic == false )
&& ( m_Bold == false )
&& ( m_MultilineAllowed == false ) );
}
void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR )
{
aFormatter->Print( aNestLevel, "(text %s (at %s",
aFormatter->Quotew( m_Text ).c_str(), FMT_IU( m_Pos ).c_str() );
if( m_Orient != 0.0 )
aFormatter->Print( 0, " %s", FMT_ANGLE( m_Orient ).c_str() );
aFormatter->Print( 0, ")\n" );
if( !IsDefaultFormatting() )
{
aFormatter->Print( aNestLevel+1, "(effects\n" );
if( ( m_Size.x != DEFAULT_SIZE_TEXT ) || ( m_Size.y != DEFAULT_SIZE_TEXT ) || m_Bold
|| m_Italic )
{
aFormatter->Print( aNestLevel+2, "(font" );
// Add font support here at some point in the future.
if( ( m_Size.x != DEFAULT_SIZE_TEXT ) || ( m_Size.y != DEFAULT_SIZE_TEXT ) )
aFormatter->Print( 0, " (size %s)", FMT_IU( m_Size ).c_str() );
if( m_Bold )
aFormatter->Print( 0, " bold" );
if( m_Bold )
aFormatter->Print( 0, " italic" );
aFormatter->Print( 0, ")\n");
}
if( m_Mirror || ( m_HJustify != GR_TEXT_HJUSTIFY_CENTER )
|| ( m_VJustify != GR_TEXT_VJUSTIFY_CENTER ) )
{
aFormatter->Print( aNestLevel+2, "(justify");
if( m_HJustify != GR_TEXT_HJUSTIFY_CENTER )
aFormatter->Print( 0, (m_HJustify == GR_TEXT_HJUSTIFY_LEFT) ? " left" : " right" );
if( m_VJustify != GR_TEXT_VJUSTIFY_CENTER )
aFormatter->Print( 0, (m_VJustify == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" );
if( m_Mirror )
aFormatter->Print( 0, " mirror" );
aFormatter->Print( 0, ")\n" );
}
// As of now the only place this is used is in Eeschema to hide or show the text.
if( m_Attributs )
aFormatter->Print( aNestLevel+2, "hide\n" );
aFormatter->Print( aNestLevel+1, ")\n" );
}
aFormatter->Print( aNestLevel, ")\n" );
}

View File

@ -105,3 +105,52 @@ void SCH_ITEM::Plot( PLOTTER* aPlotter )
{ {
wxFAIL_MSG( wxT( "Plot() method not implemented for class " ) + GetClass() ); wxFAIL_MSG( wxT( "Plot() method not implemented for class " ) + GetClass() );
} }
std::string SCH_ITEM::FormatInternalUnits( int aValue )
{
char buf[50];
double engUnits = aValue;
int len;
if( engUnits != 0.0 && fabs( engUnits ) <= 0.0001 )
{
// printf( "f: " );
len = snprintf( buf, 49, "%.10f", engUnits );
while( --len > 0 && buf[len] == '0' )
buf[len] = '\0';
++len;
}
else
{
// printf( "g: " );
len = snprintf( buf, 49, "%.10g", engUnits );
}
return std::string( buf, len );
}
std::string SCH_ITEM::FormatAngle( double aAngle )
{
char temp[50];
int len;
len = snprintf( temp, 49, "%.10g", aAngle / 10.0 );
return std::string( temp, len );
}
std::string SCH_ITEM::FormatInternalUnits( const wxPoint& aPoint )
{
return FormatInternalUnits( aPoint.x ) + " " + FormatInternalUnits( aPoint.y );
}
std::string SCH_ITEM::FormatInternalUnits( const wxSize& aSize )
{
return FormatInternalUnits( aSize.GetWidth() ) + " " + FormatInternalUnits( aSize.GetHeight() );
}

View File

@ -160,6 +160,8 @@ set(EESCHEMA_SRCS
set(EESCHEMA_COMMON_SRCS set(EESCHEMA_COMMON_SRCS
../common/dialogs/dialog_page_settings.cpp ../common/dialogs/dialog_page_settings.cpp
../common/base_screen.cpp ../common/base_screen.cpp
../common/eda_text.cpp
../common/class_page_info.cpp
) )

View File

@ -35,6 +35,7 @@
#include <eda_dde.h> #include <eda_dde.h>
#include <id.h> #include <id.h>
#include <wxEeschemaStruct.h> #include <wxEeschemaStruct.h>
#include <eda_text.h>
#include <general.h> #include <general.h>
#include <protos.h> #include <protos.h>

View File

@ -29,6 +29,7 @@
#ifndef CLASS_LIBENTRY_FIELDS_H #ifndef CLASS_LIBENTRY_FIELDS_H
#define CLASS_LIBENTRY_FIELDS_H #define CLASS_LIBENTRY_FIELDS_H
#include <eda_text.h>
#include <lib_draw_item.h> #include <lib_draw_item.h>

View File

@ -29,9 +29,9 @@
#ifndef _LIB_TEXT_H_ #ifndef _LIB_TEXT_H_
#define _LIB_TEXT_H_ #define _LIB_TEXT_H_
#include <eda_text.h>
#include <lib_draw_item.h> #include <lib_draw_item.h>
/** /**
* Class LIB_TEXT * Class LIB_TEXT
* defines a component library graphical text item. * defines a component library graphical text item.

View File

@ -31,6 +31,7 @@
#define CLASS_SCH_FIELD_H #define CLASS_SCH_FIELD_H
#include <eda_text.h>
#include <sch_item_struct.h> #include <sch_item_struct.h>
#include <general.h> #include <general.h>

View File

@ -1498,20 +1498,3 @@ void SCH_SCREEN::Show( int nestLevel, std::ostream& os ) const
NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n"; NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
} }
#endif #endif
/**
* Function FormatBIU
* formats Eeschema internal units in mils to a string for s-expression output.
*
* @todo Move FormatBIU() where ever the common DSO/DSL code for Eeschema ends up.
*/
std::string FormatBIU( int aValue )
{
char buf[50];
int len;
len = snprintf( buf, 49, "%d", aValue );
return std::string( buf, len );
}

View File

@ -32,6 +32,7 @@
#include <macros.h> #include <macros.h>
#include <eda_text.h>
#include <sch_item_struct.h> #include <sch_item_struct.h>

View File

@ -131,6 +131,22 @@ enum KICAD_T {
}; };
/**
* Enum FILL_T
* is the set of fill types used in plotting or drawing enclosed areas.
*/
enum FILL_T {
NO_FILL, // Poly, Square, Circle, Arc = option No Fill
FILLED_SHAPE, /* Poly, Square, Circle, Arc = option Fill
* with current color ("Solid shape") */
FILLED_WITH_BG_BODYCOLOR /* Poly, Square, Circle, Arc = option Fill
* with background body color, translucent
* (texts inside this shape can be seen)
* not filled in B&W mode when plotting or
* printing */
};
enum SEARCH_RESULT { enum SEARCH_RESULT {
SEARCH_QUIT, SEARCH_QUIT,
SEARCH_CONTINUE SEARCH_CONTINUE
@ -771,252 +787,4 @@ inline EDA_ITEM* new_clone( const EDA_ITEM& aItem ) { return aItem.Clone(); }
typedef std::vector< EDA_ITEM* > EDA_ITEMS; typedef std::vector< EDA_ITEM* > EDA_ITEMS;
// Graphic Text justify:
// Values -1,0,1 are used in computations, do not change them
enum EDA_TEXT_HJUSTIFY_T {
GR_TEXT_HJUSTIFY_LEFT = -1,
GR_TEXT_HJUSTIFY_CENTER = 0,
GR_TEXT_HJUSTIFY_RIGHT = 1
};
enum EDA_TEXT_VJUSTIFY_T {
GR_TEXT_VJUSTIFY_TOP = -1,
GR_TEXT_VJUSTIFY_CENTER = 0,
GR_TEXT_VJUSTIFY_BOTTOM = 1
};
/* Options to show solid segments (segments, texts...) */
enum EDA_DRAW_MODE_T {
LINE = 0, // segments are drawn as lines
FILLED, // normal mode: segments have thickness
SKETCH // sketch mode: segments have thickness, but are not filled
};
/**
* Enum FILL_T
* is the set of fill types used in plotting or drawing enclosed areas.
*/
enum FILL_T {
NO_FILL, // Poly, Square, Circle, Arc = option No Fill
FILLED_SHAPE, /* Poly, Square, Circle, Arc = option Fill
* with current color ("Solid shape") */
FILLED_WITH_BG_BODYCOLOR /* Poly, Square, Circle, Arc = option Fill
* with background body color, translucent
* (texts inside this shape can be seen)
* not filled in B&W mode when plotting or
* printing */
};
#define DEFAULT_SIZE_TEXT 60 /* default text height (in mils or 1/1000") */
/**
* Class EDA_TEXT
* is a basic class to handle texts (labels, texts on components or footprints
* ..) not used directly. The "used" text classes are derived from EDA_ITEM and
* EDA_TEXT using multiple inheritance.
*/
class EDA_TEXT
{
public:
wxString m_Text;
int m_Thickness; ///< pen size used to draw this text
double m_Orient; ///< Orient in 0.1 degrees
wxPoint m_Pos; ///< XY position of anchor text.
wxSize m_Size; ///< XY size of text
bool m_Mirror; ///< true if mirrored
int m_Attributs; ///< bit flags such as visible, etc.
bool m_Italic; ///< should be italic font (if available)
bool m_Bold; ///< should be bold font (if available)
EDA_TEXT_HJUSTIFY_T m_HJustify; ///< horizontal justification
EDA_TEXT_VJUSTIFY_T m_VJustify; ///< vertical justification
bool m_MultilineAllowed; /**< true to use multiline option, false
* to use only single line text
* Single line is faster in
* calculations than multiline */
public:
EDA_TEXT( const wxString& text = wxEmptyString );
EDA_TEXT( const EDA_TEXT& aText );
virtual ~EDA_TEXT();
/**
* Function SetThickness
* sets text thickness.
* @param aNewThickness is the new text thickness.
*/
void SetThickness( int aNewThickness ) { m_Thickness = aNewThickness; };
/**
* Function GetThickness
* returns text thickness.
* @return int - text thickness.
*/
int GetThickness() const { return m_Thickness; };
void SetOrientation( double aOrientation ) { m_Orient = aOrientation; }
double GetOrientation() const { return m_Orient; }
void SetItalic( bool isItalic ) { m_Italic = isItalic; }
bool IsItalic() const { return m_Italic; }
void SetMirrored( bool isMirrored ) { m_Mirror = isMirrored; }
bool IsMirrored() const { return m_Mirror; }
bool IsDefaultFormatting() const;
/**
* Function SetSize
* sets text size.
* @param aNewSize is the new text size.
*/
void SetSize( const wxSize& aNewSize ) { m_Size = aNewSize; };
/**
* Function GetSize
* returns text size.
* @return wxSize - text size.
*/
const wxSize GetSize() const { return m_Size; };
/// named differently than the ones using multiple inheritance and including this class
void SetPos( const wxPoint& aPoint ) { m_Pos = aPoint; }
const wxPoint GetPos() const { return m_Pos; }
int GetLength() const { return m_Text.Length(); };
/**
* Function Draw
* @param aPanel = the current DrawPanel
* @param aDC = the current Device Context
* @param aOffset = draw offset (usually (0,0))
* @param aColor = text color
* @param aDrawMode = GR_OR, GR_XOR.., -1 to use the current mode.
* @param aDisplay_mode = LINE, FILLED or SKETCH
* @param aAnchor_color = anchor color ( UNSPECIFIED = do not draw anchor ).
*/
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aOffset, EDA_COLOR_T aColor,
int aDrawMode, EDA_DRAW_MODE_T aDisplay_mode = LINE,
EDA_COLOR_T aAnchor_color = UNSPECIFIED );
private:
/**
* Function DrawOneLineOfText
* Draw a single text line.
* Used to draw each line of this EDA_TEXT, that can be multiline
* @param aPanel = the current DrawPanel
* @param aDC = the current Device Context
* @param aOffset = draw offset (usually (0,0))
* @param aColor = text color
* @param aDrawMode = GR_OR, GR_XOR.., -1 to use the current mode.
* @param aFillMode = LINE, FILLED or SKETCH
* @param aAnchor_color = anchor color ( UNSPECIFIED = do not draw anchor ).
* @param aText = the single line of text to draw.
* @param aPos = the position of this line ).
*/
void DrawOneLineOfText( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aOffset, EDA_COLOR_T aColor,
int aDrawMode, EDA_DRAW_MODE_T aFillMode,
EDA_COLOR_T aAnchor_color, wxString& aText,
wxPoint aPos );
public:
/**
* Function TextHitTest
* Test if \a aPoint is within the bounds of this object.
* @param aPoint- A wxPoint to test
* @param aAccuracy - Amount to inflate the bounding box.
* @return bool - true if a hit, else false
*/
bool TextHitTest( const wxPoint& aPoint, int aAccuracy = 0 ) const;
/**
* Function TextHitTest (overloaded)
* Tests if object bounding box is contained within or intersects \a aRect.
*
* @param aRect - Rect to test against.
* @param aContains - Test for containment instead of intersection if true.
* @param aAccuracy - Amount to inflate the bounding box.
* @return bool - true if a hit, else false
*/
bool TextHitTest( const EDA_RECT& aRect, bool aContains = false, int aAccuracy = 0 ) const;
/**
* Function LenSize
* @return the text length in internal units
* @param aLine : the line of text to consider.
* For single line text, this parameter is always m_Text
*/
int LenSize( const wxString& aLine ) const;
/**
* Function GetTextBox
* useful in multiline texts to calculate the full text or a line area (for
* zones filling, locate functions....)
* @return the rect containing the line of text (i.e. the position and the
* size of one line) this rectangle is calculated for 0 orient text.
* If orientation is not 0 the rect must be rotated to match the
* physical area
* @param aLine The line of text to consider.
* for single line text, aLine is unused
* If aLine == -1, the full area (considering all lines) is returned
* @param aThickness Overrides the current thickness when greater than 0.
* @param aInvertY Invert the Y axis when calculating bounding box.
*/
EDA_RECT GetTextBox( int aLine = -1, int aThickness = -1, bool aInvertY = false ) const;
/**
* Function GetInterline
* return the distance between 2 text lines
* has meaning only for multiline texts
*/
int GetInterline() const
{
return (( m_Size.y * 14 ) / 10) + m_Thickness;
}
/**
* Function GetTextStyleName
* @return a wxString with the style name( Normal, Italic, Bold, Bold+Italic)
*/
wxString GetTextStyleName();
void SetText( const wxString& aText ) { m_Text = aText; }
/**
* Function GetText
* returns the string associated with the text object.
* <p>
* This function is virtual to allow derived classes to override getting the
* string to provide a way for modifying the base string by adding a suffix or
* prefix to the base string.
* </p>
* @return a const wxString object containing the string of the item.
*/
virtual const wxString GetText() const { return m_Text; }
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const { return m_HJustify; };
EDA_TEXT_VJUSTIFY_T GetVertJustify() const { return m_VJustify; };
void SetHorizJustify( EDA_TEXT_HJUSTIFY_T aType ) { m_HJustify = aType; };
void SetVertJustify( EDA_TEXT_VJUSTIFY_T aType ) { m_VJustify = aType; };
/**
* Function Format
* outputs the object to \a aFormatter in s-expression form.
*
* @param aFormatter The #OUTPUTFORMATTER object to write to.
* @param aNestLevel The indentation next level.
* @param aControlBits The control bit definition for object specific formatting.
* @throw IO_ERROR on write error.
*/
virtual void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
};
#endif // BASE_STRUCT_H_ #endif // BASE_STRUCT_H_

View File

@ -36,6 +36,10 @@
#include <boost/ptr_container/ptr_vector.hpp> #include <boost/ptr_container/ptr_vector.hpp>
/// Abbrevation for fomatting internal units to a string.
#define FMT_IU BOARD_ITEM::FormatInternalUnits
#define FMT_ANGLE BOARD_ITEM::FormatAngle
class BOARD; class BOARD;
class EDA_DRAW_PANEL; class EDA_DRAW_PANEL;
@ -247,6 +251,33 @@ public:
* @return wxString containing the layer name associated with this item. * @return wxString containing the layer name associated with this item.
*/ */
wxString GetLayerName() const; wxString GetLayerName() const;
/**
* Function FormatInternalUnits
* converts \a aValue from board internal units to a string appropriate for writing to file.
*
* @note Internal units for board items can be either deci-mils or nanometers depending
* on how KiCad is build.
* @param aValue A coordinate value to convert.
* @return A std::string object containing the converted value.
*/
static std::string FormatInternalUnits( int aValue );
/**
* Function FormatAngle
* converts \a aAngle from board units to a string appropriate for writing to file.
*
* @note Internal angles for board items can be either degrees or tenths of degree
* on how KiCad is built.
* @param aAngle A angle value to convert.
* @return A std::string object containing the converted angle.
*/
static std::string FormatAngle( double aAngle );
static std::string FormatInternalUnits( const wxPoint& aPoint );
static std::string FormatInternalUnits( const wxSize& aSize );
}; };
#endif /* BOARD_ITEM_STRUCT_H */ #endif /* BOARD_ITEM_STRUCT_H */

View File

@ -136,24 +136,6 @@ enum EDA_UNITS_T {
}; };
/**
* Function FormatBIU
* converts coordinate \a aValue from the application specific internal units to a string
* appropriate to write to an #OUTPUTFORMATTER in the s-expression file formats.
*
* @note A separate version of this function exists for Pcbnew and Eeschema. This removes
* the runtime dependency for converting coordinates to the appropriate application.
* Do not add any runtime conversions to either the Pcbnew or Eeschema implementation
* of this function.
* @param aValue The value in application specific internal units to convert.
* @return An s-expression appropriate string containing the converted value in millimeters.
*/
extern std::string FormatBIU( int aValue );
extern std::string FormatBIU( const wxPoint& aPoint );
extern std::string FormatBIU( const wxSize& aSize );
// forward declarations: // forward declarations:
class LibNameList; class LibNameList;

View File

@ -8,6 +8,7 @@
#define __INCLUDE__DRAWTXT_H__ 1 #define __INCLUDE__DRAWTXT_H__ 1
#include <base_struct.h> #include <base_struct.h>
#include <eda_text.h> // EDA_TEXT_HJUSTIFY_T and EDA_TEXT_VJUSTIFY_T
class EDA_DRAW_PANEL; class EDA_DRAW_PANEL;
class PLOTTER; class PLOTTER;

271
include/eda_text.h Normal file
View File

@ -0,0 +1,271 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2004-2011 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
*/
/**
* @file eda_text.h
* @brief Definition of base KiCad text object.
*/
#ifndef _EDA_TEXT_H_
#define _EDA_TEXT_H_
#include <common.h> // wxStringSplit
#include <gr_basic.h> // EDA_DRAW_MODE_T
#include <base_struct.h> // EDA_RECT
// Graphic Text justify:
// Values -1,0,1 are used in computations, do not change them
enum EDA_TEXT_HJUSTIFY_T {
GR_TEXT_HJUSTIFY_LEFT = -1,
GR_TEXT_HJUSTIFY_CENTER = 0,
GR_TEXT_HJUSTIFY_RIGHT = 1
};
enum EDA_TEXT_VJUSTIFY_T {
GR_TEXT_VJUSTIFY_TOP = -1,
GR_TEXT_VJUSTIFY_CENTER = 0,
GR_TEXT_VJUSTIFY_BOTTOM = 1
};
/* Options to show solid segments (segments, texts...) */
enum EDA_DRAW_MODE_T {
LINE = 0, // segments are drawn as lines
FILLED, // normal mode: segments have thickness
SKETCH // sketch mode: segments have thickness, but are not filled
};
#define DEFAULT_SIZE_TEXT 60 /* default text height (in mils or 1/1000") */
/**
* Class EDA_TEXT
* is a basic class to handle texts (labels, texts on components or footprints
* ..) not used directly. The "used" text classes are derived from EDA_ITEM and
* EDA_TEXT using multiple inheritance.
*/
class EDA_TEXT
{
public:
wxString m_Text;
int m_Thickness; ///< pen size used to draw this text
double m_Orient; ///< Orient in 0.1 degrees
wxPoint m_Pos; ///< XY position of anchor text.
wxSize m_Size; ///< XY size of text
bool m_Mirror; ///< true if mirrored
int m_Attributs; ///< bit flags such as visible, etc.
bool m_Italic; ///< should be italic font (if available)
bool m_Bold; ///< should be bold font (if available)
EDA_TEXT_HJUSTIFY_T m_HJustify; ///< horizontal justification
EDA_TEXT_VJUSTIFY_T m_VJustify; ///< vertical justification
bool m_MultilineAllowed; /**< true to use multiline option, false
* to use only single line text
* Single line is faster in
* calculations than multiline */
public:
EDA_TEXT( const wxString& text = wxEmptyString );
EDA_TEXT( const EDA_TEXT& aText );
virtual ~EDA_TEXT();
/**
* Function SetThickness
* sets text thickness.
* @param aNewThickness is the new text thickness.
*/
void SetThickness( int aNewThickness ) { m_Thickness = aNewThickness; };
/**
* Function GetThickness
* returns text thickness.
* @return int - text thickness.
*/
int GetThickness() const { return m_Thickness; };
void SetOrientation( double aOrientation ) { m_Orient = aOrientation; }
double GetOrientation() const { return m_Orient; }
void SetItalic( bool isItalic ) { m_Italic = isItalic; }
bool IsItalic() const { return m_Italic; }
void SetMirrored( bool isMirrored ) { m_Mirror = isMirrored; }
bool IsMirrored() const { return m_Mirror; }
bool IsDefaultFormatting() const;
/**
* Function SetSize
* sets text size.
* @param aNewSize is the new text size.
*/
void SetSize( const wxSize& aNewSize ) { m_Size = aNewSize; };
/**
* Function GetSize
* returns text size.
* @return wxSize - text size.
*/
const wxSize GetSize() const { return m_Size; };
/// named differently than the ones using multiple inheritance and including this class
void SetPos( const wxPoint& aPoint ) { m_Pos = aPoint; }
const wxPoint GetPos() const { return m_Pos; }
int GetLength() const { return m_Text.Length(); };
/**
* Function Draw
* @param aPanel = the current DrawPanel
* @param aDC = the current Device Context
* @param aOffset = draw offset (usually (0,0))
* @param aColor = text color
* @param aDrawMode = GR_OR, GR_XOR.., -1 to use the current mode.
* @param aDisplay_mode = LINE, FILLED or SKETCH
* @param aAnchor_color = anchor color ( UNSPECIFIED = do not draw anchor ).
*/
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aOffset, EDA_COLOR_T aColor,
int aDrawMode, EDA_DRAW_MODE_T aDisplay_mode = LINE,
EDA_COLOR_T aAnchor_color = UNSPECIFIED );
private:
/**
* Function DrawOneLineOfText
* Draw a single text line.
* Used to draw each line of this EDA_TEXT, that can be multiline
* @param aPanel = the current DrawPanel
* @param aDC = the current Device Context
* @param aOffset = draw offset (usually (0,0))
* @param aColor = text color
* @param aDrawMode = GR_OR, GR_XOR.., -1 to use the current mode.
* @param aFillMode = LINE, FILLED or SKETCH
* @param aAnchor_color = anchor color ( UNSPECIFIED = do not draw anchor ).
* @param aText = the single line of text to draw.
* @param aPos = the position of this line ).
*/
void DrawOneLineOfText( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aOffset, EDA_COLOR_T aColor,
int aDrawMode, EDA_DRAW_MODE_T aFillMode,
EDA_COLOR_T aAnchor_color, wxString& aText,
wxPoint aPos );
public:
/**
* Function TextHitTest
* Test if \a aPoint is within the bounds of this object.
* @param aPoint- A wxPoint to test
* @param aAccuracy - Amount to inflate the bounding box.
* @return bool - true if a hit, else false
*/
bool TextHitTest( const wxPoint& aPoint, int aAccuracy = 0 ) const;
/**
* Function TextHitTest (overloaded)
* Tests if object bounding box is contained within or intersects \a aRect.
*
* @param aRect - Rect to test against.
* @param aContains - Test for containment instead of intersection if true.
* @param aAccuracy - Amount to inflate the bounding box.
* @return bool - true if a hit, else false
*/
bool TextHitTest( const EDA_RECT& aRect, bool aContains = false, int aAccuracy = 0 ) const;
/**
* Function LenSize
* @return the text length in internal units
* @param aLine : the line of text to consider.
* For single line text, this parameter is always m_Text
*/
int LenSize( const wxString& aLine ) const;
/**
* Function GetTextBox
* useful in multiline texts to calculate the full text or a line area (for
* zones filling, locate functions....)
* @return the rect containing the line of text (i.e. the position and the
* size of one line) this rectangle is calculated for 0 orient text.
* If orientation is not 0 the rect must be rotated to match the
* physical area
* @param aLine The line of text to consider.
* for single line text, aLine is unused
* If aLine == -1, the full area (considering all lines) is returned
* @param aThickness Overrides the current thickness when greater than 0.
* @param aInvertY Invert the Y axis when calculating bounding box.
*/
EDA_RECT GetTextBox( int aLine = -1, int aThickness = -1, bool aInvertY = false ) const;
/**
* Function GetInterline
* return the distance between 2 text lines
* has meaning only for multiline texts
*/
int GetInterline() const
{
return (( m_Size.y * 14 ) / 10) + m_Thickness;
}
/**
* Function GetTextStyleName
* @return a wxString with the style name( Normal, Italic, Bold, Bold+Italic)
*/
wxString GetTextStyleName();
void SetText( const wxString& aText ) { m_Text = aText; }
/**
* Function GetText
* returns the string associated with the text object.
* <p>
* This function is virtual to allow derived classes to override getting the
* string to provide a way for modifying the base string by adding a suffix or
* prefix to the base string.
* </p>
* @return a const wxString object containing the string of the item.
*/
virtual const wxString GetText() const { return m_Text; }
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const { return m_HJustify; };
EDA_TEXT_VJUSTIFY_T GetVertJustify() const { return m_VJustify; };
void SetHorizJustify( EDA_TEXT_HJUSTIFY_T aType ) { m_HJustify = aType; };
void SetVertJustify( EDA_TEXT_VJUSTIFY_T aType ) { m_VJustify = aType; };
/**
* Function Format
* outputs the object to \a aFormatter in s-expression form.
*
* @param aFormatter The #OUTPUTFORMATTER object to write to.
* @param aNestLevel The indentation next level.
* @param aControlBits The control bit definition for object specific formatting.
* @throw IO_ERROR on write error.
*/
virtual void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
};
#endif // _EDA_TEXT_H_

View File

@ -11,6 +11,7 @@
#include <vector> #include <vector>
#include <drawtxt.h> #include <drawtxt.h>
#include <common.h> // PAGE_INFO #include <common.h> // PAGE_INFO
#include <eda_text.h> // FILL_T
/** /**
* Enum PlotFormat * Enum PlotFormat

View File

@ -60,6 +60,10 @@ typedef vector< SCH_ITEMS_ITR > SCH_ITEMS_ITRS;
#endif #endif
#define FMT_IU SCH_ITEM::FormatInternalUnits
#define FMT_ANGLE SCH_ITEM::FormatAngle
/// Flag to enable find and replace tracing using the WXTRACE environment variable. /// Flag to enable find and replace tracing using the WXTRACE environment variable.
extern const wxString traceFindReplace; extern const wxString traceFindReplace;
@ -365,6 +369,31 @@ public:
virtual bool operator <( const SCH_ITEM& aItem ) const; virtual bool operator <( const SCH_ITEM& aItem ) const;
/**
* Function FormatInternalUnits
* converts \a aValue from schematic internal units to a string appropriate for writing
* to file.
*
* @param aValue A coordinate value to convert.
* @return A std::string object containing the converted value.
*/
static std::string FormatInternalUnits( int aValue );
/**
* Function FormatAngle
* converts \a aAngle from board units to a string appropriate for writing to file.
*
* @note Internal angles for board items can be either degrees or tenths of degree
* on how KiCad is built.
* @param aAngle A angle value to convert.
* @return A std::string object containing the converted angle.
*/
static std::string FormatAngle( double aAngle );
static std::string FormatInternalUnits( const wxPoint& aPoint );
static std::string FormatInternalUnits( const wxSize& aSize );
private: private:
/** /**
* Function doIsConnected * Function doIsConnected

View File

@ -36,6 +36,7 @@
#include <wxstruct.h> #include <wxstruct.h>
#include <base_struct.h> #include <base_struct.h>
#include <eda_text.h> // EDA_DRAW_MODE_T
#include <richio.h> #include <richio.h>
#include <class_pcb_screen.h> #include <class_pcb_screen.h>

View File

@ -299,16 +299,3 @@ void KICAD_MANAGER_FRAME::SaveSettings()
cfg->Write( TreeFrameWidthEntry, m_LeftWin->GetSize().x ); cfg->Write( TreeFrameWidthEntry, m_LeftWin->GetSize().x );
} }
/**
* Function FormatBIU
* is a dummy function to prevent link errors since KiCad doesn't perform any interal
* unit formatting.
*
* @todo Remove FormatBIU() when the common DSO/DSL code is implemented.
*/
std::string FormatBIU( int aValue )
{
return "";
}

View File

@ -358,15 +358,3 @@ void PCB_CALCULATOR_FRAME::SetDataFilename( const wxString & aFilename)
m_regulators_fileNameCtrl->SetValue( fn.GetFullPath() ); m_regulators_fileNameCtrl->SetValue( fn.GetFullPath() );
} }
} }
/**
* @copydoc
*
* This is a dummy since KiCad doesn't perform any interal unit formatting.
*/
/** @todo Remove FormatBIU() when the common DSO/DSL code is implemented. */
std::string FormatBIU( int aValue )
{
return "";
}

View File

@ -2151,12 +2151,12 @@ void BOARD::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBit
// Write Bounding box info // Write Bounding box info
aFormatter->Print( aNestLevel+1, "(area %s %s %s %s)\n", aFormatter->Print( aNestLevel+1, "(area %s %s %s %s)\n",
FormatBIU( m_BoundingBox.GetX() ).c_str(), FMT_IU( m_BoundingBox.GetX() ).c_str(),
FormatBIU( m_BoundingBox.GetY() ).c_str(), FMT_IU( m_BoundingBox.GetY() ).c_str(),
FormatBIU( m_BoundingBox.GetRight() ).c_str(), FMT_IU( m_BoundingBox.GetRight() ).c_str(),
FormatBIU( m_BoundingBox.GetBottom() ).c_str() ); FMT_IU( m_BoundingBox.GetBottom() ).c_str() );
aFormatter->Print( aNestLevel+1, "(thickness %s)\n", aFormatter->Print( aNestLevel+1, "(thickness %s)\n",
FormatBIU( GetDesignSettings().m_BoardThickness ).c_str() ); FMT_IU( GetDesignSettings().m_BoardThickness ).c_str() );
aFormatter->Print( aNestLevel+1, "(drawings %d)\n", m_Drawings.GetCount() ); aFormatter->Print( aNestLevel+1, "(drawings %d)\n", m_Drawings.GetCount() );
aFormatter->Print( aNestLevel+1, "(tracks %d)\n", GetNumSegmTrack() ); aFormatter->Print( aNestLevel+1, "(tracks %d)\n", GetNumSegmTrack() );
@ -2195,92 +2195,92 @@ void BOARD::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBit
// Save current default track width, for compatibility with older Pcbnew version; // Save current default track width, for compatibility with older Pcbnew version;
aFormatter->Print( aNestLevel+1, "(last_trace_width %s)\n", aFormatter->Print( aNestLevel+1, "(last_trace_width %s)\n",
FormatBIU( m_TrackWidthList[m_TrackWidthSelector] ).c_str() ); FMT_IU( m_TrackWidthList[m_TrackWidthSelector] ).c_str() );
// Save custom tracks width list (the first is not saved here: this is the netclass value // Save custom tracks width list (the first is not saved here: this is the netclass value
for( unsigned ii = 1; ii < m_TrackWidthList.size(); ii++ ) for( unsigned ii = 1; ii < m_TrackWidthList.size(); ii++ )
aFormatter->Print( aNestLevel+1, "(user_trace_width%d %s)\n", aFormatter->Print( aNestLevel+1, "(user_trace_width%d %s)\n",
ii+1, FormatBIU( m_TrackWidthList[ii] ).c_str() ); ii+1, FMT_IU( m_TrackWidthList[ii] ).c_str() );
aFormatter->Print( aNestLevel+1, "(trace_clearance %s)\n", aFormatter->Print( aNestLevel+1, "(trace_clearance %s)\n",
FormatBIU( m_NetClasses.GetDefault()->GetClearance() ).c_str() ); FMT_IU( m_NetClasses.GetDefault()->GetClearance() ).c_str() );
// ZONE_SETTINGS // ZONE_SETTINGS
aFormatter->Print( aNestLevel+1, "(zone_clearance %s)\n", aFormatter->Print( aNestLevel+1, "(zone_clearance %s)\n",
FormatBIU( GetZoneSettings().m_ZoneClearance ).c_str() ); FMT_IU( GetZoneSettings().m_ZoneClearance ).c_str() );
aFormatter->Print( aNestLevel+1, "(zone_45_only %d)\n", GetZoneSettings().m_Zone_45_Only ); aFormatter->Print( aNestLevel+1, "(zone_45_only %d)\n", GetZoneSettings().m_Zone_45_Only );
aFormatter->Print( aNestLevel+1, "(trace_min %s)\n", aFormatter->Print( aNestLevel+1, "(trace_min %s)\n",
FormatBIU( GetDesignSettings().m_TrackMinWidth ).c_str() ); FMT_IU( GetDesignSettings().m_TrackMinWidth ).c_str() );
aFormatter->Print( aNestLevel+1, "(segment_width %s)\n", aFormatter->Print( aNestLevel+1, "(segment_width %s)\n",
FormatBIU( GetDesignSettings().m_DrawSegmentWidth ).c_str() ); FMT_IU( GetDesignSettings().m_DrawSegmentWidth ).c_str() );
aFormatter->Print( aNestLevel+1, "(edge_width %s)\n", aFormatter->Print( aNestLevel+1, "(edge_width %s)\n",
FormatBIU( GetDesignSettings().m_EdgeSegmentWidth ).c_str() ); FMT_IU( GetDesignSettings().m_EdgeSegmentWidth ).c_str() );
// Save current default via size, for compatibility with older Pcbnew version; // Save current default via size, for compatibility with older Pcbnew version;
aFormatter->Print( aNestLevel+1, "(via_size %s)\n", aFormatter->Print( aNestLevel+1, "(via_size %s)\n",
FormatBIU( m_NetClasses.GetDefault()->GetViaDiameter() ).c_str() ); FMT_IU( m_NetClasses.GetDefault()->GetViaDiameter() ).c_str() );
aFormatter->Print( aNestLevel+1, "(via_drill %s)\n", aFormatter->Print( aNestLevel+1, "(via_drill %s)\n",
FormatBIU( m_NetClasses.GetDefault()->GetViaDrill() ).c_str() ); FMT_IU( m_NetClasses.GetDefault()->GetViaDrill() ).c_str() );
aFormatter->Print( aNestLevel+1, "(via_min_size %s)\n", aFormatter->Print( aNestLevel+1, "(via_min_size %s)\n",
FormatBIU( GetDesignSettings().m_ViasMinSize ).c_str() ); FMT_IU( GetDesignSettings().m_ViasMinSize ).c_str() );
aFormatter->Print( aNestLevel+1, "(via_min_drill %s)\n", aFormatter->Print( aNestLevel+1, "(via_min_drill %s)\n",
FormatBIU( GetDesignSettings().m_ViasMinDrill ).c_str() ); FMT_IU( GetDesignSettings().m_ViasMinDrill ).c_str() );
// Save custom vias diameters list (the first is not saved here: this is // Save custom vias diameters list (the first is not saved here: this is
// the netclass value // the netclass value
for( unsigned ii = 1; ii < m_ViasDimensionsList.size(); ii++ ) for( unsigned ii = 1; ii < m_ViasDimensionsList.size(); ii++ )
aFormatter->Print( aNestLevel+1, "(user_via%d %s %s)\n", ii, aFormatter->Print( aNestLevel+1, "(user_via%d %s %s)\n", ii,
FormatBIU( m_ViasDimensionsList[ii].m_Diameter ).c_str(), FMT_IU( m_ViasDimensionsList[ii].m_Diameter ).c_str(),
FormatBIU( m_ViasDimensionsList[ii].m_Drill ).c_str() ); FMT_IU( m_ViasDimensionsList[ii].m_Drill ).c_str() );
// for old versions compatibility: // for old versions compatibility:
aFormatter->Print( aNestLevel+1, "(uvia_size %s)\n", aFormatter->Print( aNestLevel+1, "(uvia_size %s)\n",
FormatBIU( m_NetClasses.GetDefault()->GetuViaDiameter() ).c_str() ); FMT_IU( m_NetClasses.GetDefault()->GetuViaDiameter() ).c_str() );
aFormatter->Print( aNestLevel+1, "(uvia_drill %s)\n", aFormatter->Print( aNestLevel+1, "(uvia_drill %s)\n",
FormatBIU( m_NetClasses.GetDefault()->GetuViaDrill() ).c_str() ); FMT_IU( m_NetClasses.GetDefault()->GetuViaDrill() ).c_str() );
aFormatter->Print( aNestLevel+1, "(uvias_allow %s)\n", aFormatter->Print( aNestLevel+1, "(uvias_allow %s)\n",
FormatBIU( GetDesignSettings().m_MicroViasAllowed ).c_str() ); FMT_IU( GetDesignSettings().m_MicroViasAllowed ).c_str() );
aFormatter->Print( aNestLevel+1, "(uvia_min_size %s)\n", aFormatter->Print( aNestLevel+1, "(uvia_min_size %s)\n",
FormatBIU( GetDesignSettings().m_MicroViasMinSize ).c_str() ); FMT_IU( GetDesignSettings().m_MicroViasMinSize ).c_str() );
aFormatter->Print( aNestLevel+1, "(uvia_min_drill %s)\n", aFormatter->Print( aNestLevel+1, "(uvia_min_drill %s)\n",
FormatBIU( GetDesignSettings().m_MicroViasMinDrill ).c_str() ); FMT_IU( GetDesignSettings().m_MicroViasMinDrill ).c_str() );
aFormatter->Print( aNestLevel+1, "(pcb_text_width %s)\n", aFormatter->Print( aNestLevel+1, "(pcb_text_width %s)\n",
FormatBIU( GetDesignSettings().m_PcbTextWidth ).c_str() ); FMT_IU( GetDesignSettings().m_PcbTextWidth ).c_str() );
aFormatter->Print( aNestLevel+1, "(pcb_text_size %s %s)\n", aFormatter->Print( aNestLevel+1, "(pcb_text_size %s %s)\n",
FormatBIU( GetDesignSettings().m_PcbTextSize.x ).c_str(), FMT_IU( GetDesignSettings().m_PcbTextSize.x ).c_str(),
FormatBIU( GetDesignSettings().m_PcbTextSize.y ).c_str() ); FMT_IU( GetDesignSettings().m_PcbTextSize.y ).c_str() );
aFormatter->Print( aNestLevel+1, "(mod_edge_width %s)\n", aFormatter->Print( aNestLevel+1, "(mod_edge_width %s)\n",
FormatBIU( GetDesignSettings().m_ModuleSegmentWidth ).c_str() ); FMT_IU( GetDesignSettings().m_ModuleSegmentWidth ).c_str() );
aFormatter->Print( aNestLevel+1, "(mod_text_size %s %s)\n", aFormatter->Print( aNestLevel+1, "(mod_text_size %s %s)\n",
FormatBIU( GetDesignSettings().m_ModuleTextSize.x ).c_str(), FMT_IU( GetDesignSettings().m_ModuleTextSize.x ).c_str(),
FormatBIU( GetDesignSettings().m_ModuleTextSize.y ).c_str() ); FMT_IU( GetDesignSettings().m_ModuleTextSize.y ).c_str() );
aFormatter->Print( aNestLevel+1, "(mod_text_width %s)\n", aFormatter->Print( aNestLevel+1, "(mod_text_width %s)\n",
FormatBIU( GetDesignSettings().m_ModuleTextWidth ).c_str() ); FMT_IU( GetDesignSettings().m_ModuleTextWidth ).c_str() );
aFormatter->Print( aNestLevel+1, "(pad_size %s %s)\n", aFormatter->Print( aNestLevel+1, "(pad_size %s %s)\n",
FormatBIU( GetDesignSettings().m_Pad_Master.GetSize().x ).c_str(), FMT_IU( GetDesignSettings().m_Pad_Master.GetSize().x ).c_str(),
FormatBIU( GetDesignSettings().m_Pad_Master.GetSize().x ).c_str() ); FMT_IU( GetDesignSettings().m_Pad_Master.GetSize().x ).c_str() );
aFormatter->Print( aNestLevel+1, "(pad_drill %s)\n", aFormatter->Print( aNestLevel+1, "(pad_drill %s)\n",
FormatBIU( GetDesignSettings().m_Pad_Master.GetDrillSize().x ).c_str() ); FMT_IU( GetDesignSettings().m_Pad_Master.GetDrillSize().x ).c_str() );
aFormatter->Print( aNestLevel+1, "(pad_to_mask_clearance %s)\n", aFormatter->Print( aNestLevel+1, "(pad_to_mask_clearance %s)\n",
FormatBIU( GetDesignSettings().m_SolderMaskMargin ).c_str() ); FMT_IU( GetDesignSettings().m_SolderMaskMargin ).c_str() );
if( GetDesignSettings().m_SolderPasteMargin != 0 ) if( GetDesignSettings().m_SolderPasteMargin != 0 )
aFormatter->Print( aNestLevel+1, "(pad_to_paste_clearance %s)\n", aFormatter->Print( aNestLevel+1, "(pad_to_paste_clearance %s)\n",
FormatBIU( GetDesignSettings().m_SolderPasteMargin ).c_str() ); FMT_IU( GetDesignSettings().m_SolderPasteMargin ).c_str() );
if( GetDesignSettings().m_SolderPasteMarginRatio != 0 ) if( GetDesignSettings().m_SolderPasteMarginRatio != 0 )
aFormatter->Print( aNestLevel+1, "(pad_to_paste_clearance_ratio %g)\n", aFormatter->Print( aNestLevel+1, "(pad_to_paste_clearance_ratio %g)\n",
GetDesignSettings().m_SolderPasteMarginRatio ); GetDesignSettings().m_SolderPasteMarginRatio );
aFormatter->Print( aNestLevel+1, "(aux_axis_origin %s %s)\n", aFormatter->Print( aNestLevel+1, "(aux_axis_origin %s %s)\n",
FormatBIU( GetOriginAxisPosition().x ).c_str(), FMT_IU( GetOriginAxisPosition().x ).c_str(),
FormatBIU( GetOriginAxisPosition().y ).c_str() ); FMT_IU( GetOriginAxisPosition().y ).c_str() );
aFormatter->Print( aNestLevel+1, "(visible_elements %X)\n", aFormatter->Print( aNestLevel+1, "(visible_elements %X)\n",
GetDesignSettings().GetVisibleElements() ); GetDesignSettings().GetVisibleElements() );

View File

@ -64,15 +64,16 @@ wxString BOARD_ITEM::GetLayerName() const
} }
/** @todo Move Pcbnew version of FormatBIU() where ever the common DSO/DSL code ends up. */ std::string BOARD_ITEM::FormatInternalUnits( int aValue )
std::string FormatBIU( int aValue )
{ {
#if !defined( USE_PCBNEW_NANOMETRES ) char buf[50];
wxFAIL_MSG( wxT( "Cannot use FormatBIU() unless Pcbnew is build with PCBNEW_NANOMETERS=ON." ) );
#if defined( USE_PCBNEW_NANOMETRES )
double engUnits = aValue / 1000000.0;
#else
double engUnits = ( aValue * 10000.0 ) / 25.4 / 1000000.0;
#endif #endif
char buf[50];
double engUnits = aValue / 1000000.0;
int len; int len;
if( engUnits != 0.0 && fabs( engUnits ) <= 0.0001 ) if( engUnits != 0.0 && fabs( engUnits ) <= 0.0001 )
@ -93,3 +94,30 @@ std::string FormatBIU( int aValue )
return std::string( buf, len ); return std::string( buf, len );
} }
std::string BOARD_ITEM::FormatAngle( double aAngle )
{
char temp[50];
int len;
#if defined( USE_PCBNEW_SEXPR_FILE_FORMAT )
len = snprintf( temp, 49, "%.10g", aAngle / 10.0 );
#else
len = snprintf( temp, 49, "%.10g", aAngle );
#endif
return std::string( temp, len );
}
std::string BOARD_ITEM::FormatInternalUnits( const wxPoint& aPoint )
{
return FormatInternalUnits( aPoint.x ) + " " + FormatInternalUnits( aPoint.y );
}
std::string BOARD_ITEM::FormatInternalUnits( const wxSize& aSize )
{
return FormatInternalUnits( aSize.GetWidth() ) + " " + FormatInternalUnits( aSize.GetHeight() );
}

View File

@ -610,53 +610,53 @@ EDA_ITEM* DIMENSION::Clone() const
void DIMENSION::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const void DIMENSION::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR ) throw( IO_ERROR )
{ {
aFormatter->Print( aNestLevel, "(dimension %s\n", FormatBIU( m_Value ).c_str() ); aFormatter->Print( aNestLevel, "(dimension %s\n", FMT_IU( m_Value ).c_str() );
aFormatter->Print( aNestLevel+1, "(width %s)\n(layer %d)\n(tstamp %lX)\n", aFormatter->Print( aNestLevel+1, "(width %s)\n(layer %d)\n(tstamp %lX)\n",
FormatBIU( m_Width ).c_str(), GetLayer(), GetTimeStamp() ); FMT_IU( m_Width ).c_str(), GetLayer(), GetTimeStamp() );
m_Text.EDA_TEXT::Format( aFormatter, aNestLevel+1, aControlBits ); m_Text.EDA_TEXT::Format( aFormatter, aNestLevel+1, aControlBits );
aFormatter->Print( aNestLevel+1, "(feature1 pts((xy %s %s) (xy %s %s)))\n", aFormatter->Print( aNestLevel+1, "(feature1 pts((xy %s %s) (xy %s %s)))\n",
FormatBIU( m_featureLineDOx ).c_str(), FMT_IU( m_featureLineDOx ).c_str(),
FormatBIU( m_featureLineDOy ).c_str(), FMT_IU( m_featureLineDOy ).c_str(),
FormatBIU( m_featureLineDFx ).c_str(), FMT_IU( m_featureLineDFx ).c_str(),
FormatBIU( m_featureLineDFy ).c_str() ); FMT_IU( m_featureLineDFy ).c_str() );
aFormatter->Print( aNestLevel+1, "(feature2 pts((xy %s %s) (xy %s %s)))\n", aFormatter->Print( aNestLevel+1, "(feature2 pts((xy %s %s) (xy %s %s)))\n",
FormatBIU( m_featureLineGOx ).c_str(), FMT_IU( m_featureLineGOx ).c_str(),
FormatBIU( m_featureLineGOy ).c_str(), FMT_IU( m_featureLineGOy ).c_str(),
FormatBIU( m_featureLineGFx ).c_str(), FMT_IU( m_featureLineGFx ).c_str(),
FormatBIU( m_featureLineGFy ).c_str() ); FMT_IU( m_featureLineGFy ).c_str() );
aFormatter->Print( aNestLevel+1, "(crossbar pts((xy %s %s) (xy %s %s)))\n", aFormatter->Print( aNestLevel+1, "(crossbar pts((xy %s %s) (xy %s %s)))\n",
FormatBIU( m_crossBarOx ).c_str(), FMT_IU( m_crossBarOx ).c_str(),
FormatBIU( m_crossBarOy ).c_str(), FMT_IU( m_crossBarOy ).c_str(),
FormatBIU( m_crossBarFx ).c_str(), FMT_IU( m_crossBarFx ).c_str(),
FormatBIU( m_crossBarFy ).c_str() ); FMT_IU( m_crossBarFy ).c_str() );
aFormatter->Print( aNestLevel+1, "(arrow1a pts((xy %s %s) (xy %s %s)))\n", aFormatter->Print( aNestLevel+1, "(arrow1a pts((xy %s %s) (xy %s %s)))\n",
FormatBIU( m_arrowD1Ox ).c_str(), FMT_IU( m_arrowD1Ox ).c_str(),
FormatBIU( m_arrowD1Oy ).c_str(), FMT_IU( m_arrowD1Oy ).c_str(),
FormatBIU( m_arrowD1Fx ).c_str(), FMT_IU( m_arrowD1Fx ).c_str(),
FormatBIU( m_arrowD1Fy ).c_str() ); FMT_IU( m_arrowD1Fy ).c_str() );
aFormatter->Print( aNestLevel+1, "(arrow1b pts((xy %s %s) (xy %s %s)))\n", aFormatter->Print( aNestLevel+1, "(arrow1b pts((xy %s %s) (xy %s %s)))\n",
FormatBIU( m_arrowD2Ox ).c_str(), FMT_IU( m_arrowD2Ox ).c_str(),
FormatBIU( m_arrowD2Oy ).c_str(), FMT_IU( m_arrowD2Oy ).c_str(),
FormatBIU( m_arrowD2Fx ).c_str(), FMT_IU( m_arrowD2Fx ).c_str(),
FormatBIU( m_arrowD2Fy ).c_str() ); FMT_IU( m_arrowD2Fy ).c_str() );
aFormatter->Print( aNestLevel+1, "(arrow2a pts((xy %s %s) (xy %s %s)))\n", aFormatter->Print( aNestLevel+1, "(arrow2a pts((xy %s %s) (xy %s %s)))\n",
FormatBIU( m_arrowG1Ox ).c_str(), FMT_IU( m_arrowG1Ox ).c_str(),
FormatBIU( m_arrowG1Oy ).c_str(), FMT_IU( m_arrowG1Oy ).c_str(),
FormatBIU( m_arrowG1Fx ).c_str(), FMT_IU( m_arrowG1Fx ).c_str(),
FormatBIU( m_arrowG1Fy ).c_str() ); FMT_IU( m_arrowG1Fy ).c_str() );
aFormatter->Print( aNestLevel+1, "(arrow2b pts((xy %s %s) (xy %s %s)))\n", aFormatter->Print( aNestLevel+1, "(arrow2b pts((xy %s %s) (xy %s %s)))\n",
FormatBIU( m_arrowG2Ox ).c_str(), FMT_IU( m_arrowG2Ox ).c_str(),
FormatBIU( m_arrowG2Oy ).c_str(), FMT_IU( m_arrowG2Oy ).c_str(),
FormatBIU( m_arrowG2Fx ).c_str(), FMT_IU( m_arrowG2Fx ).c_str(),
FormatBIU( m_arrowG2Fy ).c_str() ); FMT_IU( m_arrowG2Fy ).c_str() );
aFormatter->Print( aNestLevel, ")\n" ); aFormatter->Print( aNestLevel, ")\n" );
} }

View File

@ -554,39 +554,39 @@ void DRAWSEGMENT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aCont
switch( m_Shape ) switch( m_Shape )
{ {
case S_SEGMENT: // Line case S_SEGMENT: // Line
aFormatter->Print( 0, "line (pts xy(%s) xy(%s))", aFormatter->Print( 0, "line (pts (xy %s) (xy %s))",
FormatBIU( m_Start ).c_str(), FMT_IU( m_Start ).c_str(),
FormatBIU( m_End ).c_str() ); FMT_IU( m_End ).c_str() );
break; break;
case S_CIRCLE: // Circle case S_CIRCLE: // Circle
aFormatter->Print( 0, "circle (center (xy %s)) (end (xy %s))", aFormatter->Print( 0, "circle (center (xy %s)) (end (xy %s))",
FormatBIU( m_Start ).c_str(), FMT_IU( m_Start ).c_str(),
FormatBIU( m_End ).c_str() ); FMT_IU( m_End ).c_str() );
break; break;
case S_ARC: // Arc case S_ARC: // Arc
aFormatter->Print( 0, "arc (start (xy %s)) (end (xy %s)) (angle %0.1f)", aFormatter->Print( 0, "arc (start (xy %s)) (end (xy %s)) (angle %s)",
FormatBIU( m_Start ).c_str(), FMT_IU( m_Start ).c_str(),
FormatBIU( m_End ).c_str(), FMT_IU( m_End ).c_str(),
m_Angle ); FMT_ANGLE( m_Angle ).c_str() );
break; break;
case S_POLYGON: // Polygon case S_POLYGON: // Polygon
aFormatter->Print( 0, "line (pts" ); aFormatter->Print( 0, "line (pts" );
for( i = 0; i<m_PolyPoints.size(); ++i ) for( i = 0; i<m_PolyPoints.size(); ++i )
aFormatter->Print( 0, " (xy %s)", FormatBIU( m_PolyPoints[i] ).c_str() ); aFormatter->Print( 0, " (xy %s)", FMT_IU( m_PolyPoints[i] ).c_str() );
aFormatter->Print( 0, ")" ); aFormatter->Print( 0, ")" );
break; break;
case S_CURVE: // Bezier curve case S_CURVE: // Bezier curve
aFormatter->Print( 0, "curve pts(xy(%s) xy(%s) xy(%s) xy(%s))", aFormatter->Print( 0, "curve pts(xy(%s) xy(%s) xy(%s) xy(%s))",
FormatBIU( m_Start ).c_str(), FMT_IU( m_Start ).c_str(),
FormatBIU( m_BezierC1 ).c_str(), FMT_IU( m_BezierC1 ).c_str(),
FormatBIU( m_BezierC2 ).c_str(), FMT_IU( m_BezierC2 ).c_str(),
FormatBIU( m_End ).c_str() ); FMT_IU( m_End ).c_str() );
break; break;
default: default:
@ -596,7 +596,7 @@ void DRAWSEGMENT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aCont
aFormatter->Print( 0, " (layer %d)", GetLayer() ); aFormatter->Print( 0, " (layer %d)", GetLayer() );
if( m_Width != 0 ) if( m_Width != 0 )
aFormatter->Print( 0, " (width %s)", FormatBIU( m_Width ).c_str() ); aFormatter->Print( 0, " (width %s)", FMT_IU( m_Width ).c_str() );
if( GetTimeStamp() ) if( GetTimeStamp() )
aFormatter->Print( 0, " (tstamp %lX)", GetTimeStamp() ); aFormatter->Print( 0, " (tstamp %lX)", GetTimeStamp() );

View File

@ -283,7 +283,7 @@ void EDGE_MODULE::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aCont
throw( IO_ERROR ) throw( IO_ERROR )
{ {
aFormatter->Print( aNestLevel, "(edge (start (xy %s)) (end (xy %s))\n", aFormatter->Print( aNestLevel, "(edge (start (xy %s)) (end (xy %s))\n",
FormatBIU( m_Start0 ).c_str(), FormatBIU( m_End0 ).c_str() ); FMT_IU( m_Start0 ).c_str(), FMT_IU( m_End0 ).c_str() );
DRAWSEGMENT::Format( aFormatter, aNestLevel+1, aControlBits ); DRAWSEGMENT::Format( aFormatter, aNestLevel+1, aControlBits );
aFormatter->Print( aNestLevel, ")\n" ); aFormatter->Print( aNestLevel, ")\n" );
} }

View File

@ -230,11 +230,11 @@ void PCB_TARGET::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aContr
{ {
aFormatter->Print( aNestLevel, "(target %c (pos (xy %s)) (size %s)", aFormatter->Print( aNestLevel, "(target %c (pos (xy %s)) (size %s)",
( m_Shape ) ? 'x' : '+', ( m_Shape ) ? 'x' : '+',
FormatBIU( m_Pos ).c_str(), FMT_IU( m_Pos ).c_str(),
FormatBIU( m_Size ).c_str() ); FMT_IU( m_Size ).c_str() );
if( m_Width != 0 ) if( m_Width != 0 )
aFormatter->Print( aNestLevel, " (width %s)", FormatBIU( m_Width ).c_str() ); aFormatter->Print( aNestLevel, " (width %s)", FMT_IU( m_Width ).c_str() );
aFormatter->Print( aNestLevel, " (layer %d)", GetLayer() ); aFormatter->Print( aNestLevel, " (layer %d)", GetLayer() );

View File

@ -677,10 +677,10 @@ void MODULE::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBi
aFormatter->Print( 0, " (tedit %lX) (tstamp %lX)\n", aFormatter->Print( 0, " (tedit %lX) (tstamp %lX)\n",
GetLastEditTime(), GetTimeStamp() ); GetLastEditTime(), GetTimeStamp() );
aFormatter->Print( aNestLevel+1, "(at %s", FormatBIU( m_Pos ).c_str() ); aFormatter->Print( aNestLevel+1, "(at %s", FMT_IU( m_Pos ).c_str() );
if( m_Orient != 0.0 ) if( m_Orient != 0.0 )
aFormatter->Print( 0, " %0.1f", m_Orient ); aFormatter->Print( 0, " %s", FMT_ANGLE( m_Orient ).c_str() );
aFormatter->Print( 0, ")\n" ); aFormatter->Print( 0, ")\n" );
@ -701,11 +701,11 @@ void MODULE::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBi
if( m_LocalSolderMaskMargin != 0 ) if( m_LocalSolderMaskMargin != 0 )
aFormatter->Print( aNestLevel+1, "(solder_mask_margin %s)\n", aFormatter->Print( aNestLevel+1, "(solder_mask_margin %s)\n",
FormatBIU( m_LocalSolderMaskMargin ).c_str() ); FMT_IU( m_LocalSolderMaskMargin ).c_str() );
if( m_LocalSolderPasteMargin != 0 ) if( m_LocalSolderPasteMargin != 0 )
aFormatter->Print( aNestLevel+1, "(solder_paste_margin %s)\n", aFormatter->Print( aNestLevel+1, "(solder_paste_margin %s)\n",
FormatBIU( m_LocalSolderPasteMargin ).c_str() ); FMT_IU( m_LocalSolderPasteMargin ).c_str() );
if( m_LocalSolderPasteMarginRatio != 0 ) if( m_LocalSolderPasteMarginRatio != 0 )
aFormatter->Print( aNestLevel+1, "(solder_paste_ratio %g)\n", aFormatter->Print( aNestLevel+1, "(solder_paste_ratio %g)\n",
@ -713,18 +713,18 @@ void MODULE::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBi
if( m_LocalClearance != 0 ) if( m_LocalClearance != 0 )
aFormatter->Print( aNestLevel+1, "(clearance %s)\n", aFormatter->Print( aNestLevel+1, "(clearance %s)\n",
FormatBIU( m_LocalClearance ).c_str() ); FMT_IU( m_LocalClearance ).c_str() );
if( m_ZoneConnection != UNDEFINED_CONNECTION ) if( m_ZoneConnection != UNDEFINED_CONNECTION )
aFormatter->Print( aNestLevel+1, "(zone_connect %d)\n", m_ZoneConnection ); aFormatter->Print( aNestLevel+1, "(zone_connect %d)\n", m_ZoneConnection );
if( m_ThermalWidth != 0 ) if( m_ThermalWidth != 0 )
aFormatter->Print( aNestLevel+1, "(thermal_width %s)\n", aFormatter->Print( aNestLevel+1, "(thermal_width %s)\n",
FormatBIU( m_ThermalWidth ).c_str() ); FMT_IU( m_ThermalWidth ).c_str() );
if( m_ThermalGap != 0 ) if( m_ThermalGap != 0 )
aFormatter->Print( aNestLevel+1, "(thermal_gap %s)\n", aFormatter->Print( aNestLevel+1, "(thermal_gap %s)\n",
FormatBIU( m_ThermalGap ).c_str() ); FMT_IU( m_ThermalGap ).c_str() );
// Attributes // Attributes
if( m_Attributs != MOD_DEFAULT ) if( m_Attributs != MOD_DEFAULT )

View File

@ -328,14 +328,14 @@ void NETCLASS::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
aFormatter->Quotew( GetName() ).c_str(), aFormatter->Quotew( GetName() ).c_str(),
aFormatter->Quotew( GetDescription() ).c_str() ); aFormatter->Quotew( GetDescription() ).c_str() );
aFormatter->Print( aNestLevel+1, "(clearance %s)\n", FormatBIU( GetClearance() ).c_str() ); aFormatter->Print( aNestLevel+1, "(clearance %s)\n", FMT_IU( GetClearance() ).c_str() );
aFormatter->Print( aNestLevel+1, "(trace_width %s)\n", FormatBIU( GetTrackWidth() ).c_str() ); aFormatter->Print( aNestLevel+1, "(trace_width %s)\n", FMT_IU( GetTrackWidth() ).c_str() );
aFormatter->Print( aNestLevel+1, "(via_dia %s)\n", FormatBIU( GetViaDiameter() ).c_str() ); aFormatter->Print( aNestLevel+1, "(via_dia %s)\n", FMT_IU( GetViaDiameter() ).c_str() );
aFormatter->Print( aNestLevel+1, "(via_drill %s)\n", FormatBIU( GetViaDrill() ).c_str() ); aFormatter->Print( aNestLevel+1, "(via_drill %s)\n", FMT_IU( GetViaDrill() ).c_str() );
aFormatter->Print( aNestLevel+1, "(uvia_dia %s)\n", FormatBIU( GetuViaDiameter() ).c_str() ); aFormatter->Print( aNestLevel+1, "(uvia_dia %s)\n", FMT_IU( GetuViaDiameter() ).c_str() );
aFormatter->Print( aNestLevel+1, "(uvia_drill %s)\n", FormatBIU( GetuViaDrill() ).c_str() ); aFormatter->Print( aNestLevel+1, "(uvia_drill %s)\n", FMT_IU( GetuViaDrill() ).c_str() );
for( NETCLASS::const_iterator it = begin(); it!= end(); ++it ) for( NETCLASS::const_iterator it = begin(); it!= end(); ++it )
aFormatter->Print( aNestLevel+1, "(add_net %s)\n", aFormatter->Quotew( *it ).c_str() ); aFormatter->Print( aNestLevel+1, "(add_net %s)\n", aFormatter->Quotew( *it ).c_str() );

View File

@ -860,25 +860,25 @@ void D_PAD::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBit
aFormatter->Print( aNestLevel, "(pad %s %s %s (size %s)\n", aFormatter->Print( aNestLevel, "(pad %s %s %s (size %s)\n",
aFormatter->Quotew( GetPadName() ).c_str(), type.c_str(), shape.c_str(), aFormatter->Quotew( GetPadName() ).c_str(), type.c_str(), shape.c_str(),
FormatBIU( m_Size ).c_str() ); FMT_IU( m_Size ).c_str() );
aFormatter->Print( aNestLevel+1, "(at %s", FormatBIU( m_Pos0 ).c_str() ); aFormatter->Print( aNestLevel+1, "(at %s", FMT_IU( m_Pos0 ).c_str() );
if( m_Orient != 0.0 ) if( m_Orient != 0.0 )
aFormatter->Print( 0, " %0.1f", m_Orient ); aFormatter->Print( 0, " %s", FMT_ANGLE( m_Orient ).c_str() );
aFormatter->Print( 0, ")\n" ); aFormatter->Print( 0, ")\n" );
if( (m_Drill.GetWidth() > 0) || (m_Drill.GetHeight() > 0) ) if( (m_Drill.GetWidth() > 0) || (m_Drill.GetHeight() > 0) )
{ {
std::string drill = (m_Drill.GetHeight() > 0) ? FormatBIU( m_Drill ).c_str() : std::string drill = (m_Drill.GetHeight() > 0) ? FMT_IU( m_Drill ).c_str() :
FormatBIU( m_Drill.GetWidth() ).c_str(); FMT_IU( m_Drill.GetWidth() ).c_str();
aFormatter->Print( aNestLevel+1, "(drill %s", drill.c_str() ); aFormatter->Print( aNestLevel+1, "(drill %s", drill.c_str() );
if( (m_Offset.x > 0) || (m_Offset.y > 0) ) if( (m_Offset.x > 0) || (m_Offset.y > 0) )
{ {
std::string drillOffset = ( m_Offset.x > 0 ) ? std::string drillOffset = ( m_Offset.x > 0 ) ?
FormatBIU( m_Offset ).c_str() : FMT_IU( m_Offset ).c_str() :
FormatBIU( m_Offset.x ).c_str(); FMT_IU( m_Offset.x ).c_str();
aFormatter->Print( 0, " (offset %s)", drillOffset.c_str() ); aFormatter->Print( 0, " (offset %s)", drillOffset.c_str() );
} }
@ -891,15 +891,15 @@ void D_PAD::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBit
GetNet(), aFormatter->Quotew( m_Netname ).c_str() ); GetNet(), aFormatter->Quotew( m_Netname ).c_str() );
if( m_LengthDie != 0 ) if( m_LengthDie != 0 )
aFormatter->Print( aNestLevel+1, "(die_length %s)\n", FormatBIU( m_LengthDie ).c_str() ); aFormatter->Print( aNestLevel+1, "(die_length %s)\n", FMT_IU( m_LengthDie ).c_str() );
if( m_LocalSolderMaskMargin != 0 ) if( m_LocalSolderMaskMargin != 0 )
aFormatter->Print( aNestLevel+1, "(solder_mask_margin %s)\n", aFormatter->Print( aNestLevel+1, "(solder_mask_margin %s)\n",
FormatBIU( m_LocalSolderMaskMargin ).c_str() ); FMT_IU( m_LocalSolderMaskMargin ).c_str() );
if( m_LocalSolderPasteMargin != 0 ) if( m_LocalSolderPasteMargin != 0 )
aFormatter->Print( aNestLevel+1, "(solder_paste_margin %s)\n", aFormatter->Print( aNestLevel+1, "(solder_paste_margin %s)\n",
FormatBIU( m_LocalSolderPasteMargin ).c_str() ); FMT_IU( m_LocalSolderPasteMargin ).c_str() );
if( m_LocalSolderPasteMarginRatio != 0 ) if( m_LocalSolderPasteMarginRatio != 0 )
aFormatter->Print( aNestLevel+1, "(solder_paste_margin_ratio %g)\n", aFormatter->Print( aNestLevel+1, "(solder_paste_margin_ratio %g)\n",
@ -907,18 +907,18 @@ void D_PAD::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBit
if( m_LocalClearance != 0 ) if( m_LocalClearance != 0 )
aFormatter->Print( aNestLevel+1, "(clearance %s)\n", aFormatter->Print( aNestLevel+1, "(clearance %s)\n",
FormatBIU( m_LocalClearance ).c_str() ); FMT_IU( m_LocalClearance ).c_str() );
if( GetZoneConnection() != UNDEFINED_CONNECTION ) if( GetZoneConnection() != UNDEFINED_CONNECTION )
aFormatter->Print( aNestLevel+1, "(zone_connect %d)\n", GetZoneConnection() ); aFormatter->Print( aNestLevel+1, "(zone_connect %d)\n", GetZoneConnection() );
if( GetThermalWidth() != 0 ) if( GetThermalWidth() != 0 )
aFormatter->Print( aNestLevel+1, "(thermal_width %s)\n", aFormatter->Print( aNestLevel+1, "(thermal_width %s)\n",
FormatBIU( GetThermalWidth() ).c_str() ); FMT_IU( GetThermalWidth() ).c_str() );
if( GetThermalGap() != 0 ) if( GetThermalGap() != 0 )
aFormatter->Print( aNestLevel+1, "(thermal_gap %s)\n", aFormatter->Print( aNestLevel+1, "(thermal_gap %s)\n",
FormatBIU( GetThermalGap() ).c_str() ); FMT_IU( GetThermalGap() ).c_str() );
aFormatter->Print( aNestLevel, ")\n" ); aFormatter->Print( aNestLevel, ")\n" );
} }

View File

@ -30,6 +30,7 @@
#ifndef CLASS_PCB_TEXT_H #ifndef CLASS_PCB_TEXT_H
#define CLASS_PCB_TEXT_H #define CLASS_PCB_TEXT_H
#include <eda_text.h>
#include <class_board_item.h> #include <class_board_item.h>
#include <PolyLine.h> #include <PolyLine.h>

View File

@ -492,7 +492,7 @@ void TEXTE_MODULE::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aCon
orient += parent->GetOrientation(); orient += parent->GetOrientation();
aFormatter->Print( aNestLevel, "(module_text %d (at %s %0.1f)%s\n", m_Type, aFormatter->Print( aNestLevel, "(module_text %d (at %s %0.1f)%s\n", m_Type,
FormatBIU( m_Pos0 ).c_str(), orient, (m_NoShow) ? "hide" : "" ); FMT_IU( m_Pos0 ).c_str(), orient, (m_NoShow) ? "hide" : "" );
EDA_TEXT::Format( aFormatter, aNestLevel+1, aControlBits ); EDA_TEXT::Format( aFormatter, aNestLevel+1, aControlBits );

View File

@ -32,6 +32,7 @@
#define TEXT_MODULE_H_ #define TEXT_MODULE_H_
#include <eda_text.h>
#include <class_board_item.h> #include <class_board_item.h>

View File

@ -1576,16 +1576,16 @@ void TRACK::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBit
} }
aFormatter->Print( aNestLevel, "(via %s (at %s) (size %s)", type.c_str(), aFormatter->Print( aNestLevel, "(via %s (at %s) (size %s)", type.c_str(),
FormatBIU( m_Start ).c_str(), FormatBIU( m_Width ).c_str() ); FMT_IU( m_Start ).c_str(), FMT_IU( m_Width ).c_str() );
if( m_Drill != UNDEFINED_DRILL_DIAMETER ) if( m_Drill != UNDEFINED_DRILL_DIAMETER )
aFormatter->Print( 0, " (drill %s)", FormatBIU( m_Drill ).c_str() ); aFormatter->Print( 0, " (drill %s)", FMT_IU( m_Drill ).c_str() );
} }
else else
{ {
aFormatter->Print( aNestLevel, "(segment (start %s) (end %s) (width %s)", aFormatter->Print( aNestLevel, "(segment (start %s) (end %s) (width %s)",
FormatBIU( m_Start ).c_str(), FormatBIU( m_End ).c_str(), FMT_IU( m_Start ).c_str(), FMT_IU( m_End ).c_str(),
FormatBIU( m_Width ).c_str() ); FMT_IU( m_Width ).c_str() );
} }
aFormatter->Print( 0, " (layer %d) (net %d)", GetLayer(), GetNet() ); aFormatter->Print( 0, " (layer %d) (net %d)", GetLayer(), GetNet() );

View File

@ -993,18 +993,18 @@ void ZONE_CONTAINER::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aC
} }
aFormatter->Print( aNestLevel+1, "(connect_pads %s (clearance %s))\n", aFormatter->Print( aNestLevel+1, "(connect_pads %s (clearance %s))\n",
padoption.c_str(), FormatBIU( m_ZoneClearance ).c_str() ); padoption.c_str(), FMT_IU( m_ZoneClearance ).c_str() );
aFormatter->Print( aNestLevel+1, "(min_thickness %s)\n", aFormatter->Print( aNestLevel+1, "(min_thickness %s)\n",
FormatBIU( m_ZoneMinThickness ).c_str() ); FMT_IU( m_ZoneMinThickness ).c_str() );
aFormatter->Print( aNestLevel+1, aFormatter->Print( aNestLevel+1,
"(fill %s (mode %s) (arc_segments %d) (thermal_gap %s) (thermal_bridge_width %s)\n", "(fill %s (mode %s) (arc_segments %d) (thermal_gap %s) (thermal_bridge_width %s)\n",
(m_IsFilled) ? "yes" : "no", (m_IsFilled) ? "yes" : "no",
(m_FillMode) ? "segment" : "polygon", (m_FillMode) ? "segment" : "polygon",
m_ArcToSegmentsCount, m_ArcToSegmentsCount,
FormatBIU( m_ThermalReliefGap ).c_str(), FMT_IU( m_ThermalReliefGap ).c_str(),
FormatBIU( m_ThermalReliefCopperBridge ).c_str() ); FMT_IU( m_ThermalReliefCopperBridge ).c_str() );
std::string smoothing; std::string smoothing;
@ -1019,7 +1019,7 @@ void ZONE_CONTAINER::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aC
} }
aFormatter->Print( aNestLevel+1, "(smoothing %s (radius %s))\n", aFormatter->Print( aNestLevel+1, "(smoothing %s (radius %s))\n",
smoothing.c_str(), FormatBIU( cornerRadius ).c_str() ); smoothing.c_str(), FMT_IU( cornerRadius ).c_str() );
const std::vector< CPolyPt >& cv = m_Poly->corner; const std::vector< CPolyPt >& cv = m_Poly->corner;
@ -1031,7 +1031,7 @@ void ZONE_CONTAINER::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aC
for( std::vector< CPolyPt >::const_iterator it = cv.begin(); it != cv.end(); ++it ) for( std::vector< CPolyPt >::const_iterator it = cv.begin(); it != cv.end(); ++it )
{ {
aFormatter->Print( aNestLevel+3, "(xy %s %s)\n", aFormatter->Print( aNestLevel+3, "(xy %s %s)\n",
FormatBIU( it->x ).c_str(), FormatBIU( it->y ).c_str() ); FMT_IU( it->x ).c_str(), FMT_IU( it->y ).c_str() );
if( it->end_contour ) if( it->end_contour )
{ {
@ -1060,7 +1060,7 @@ void ZONE_CONTAINER::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aC
for( std::vector< CPolyPt >::const_iterator it = fv.begin(); it != fv.end(); ++it ) for( std::vector< CPolyPt >::const_iterator it = fv.begin(); it != fv.end(); ++it )
{ {
aFormatter->Print( aNestLevel+3, "(xy %s %s)\n", aFormatter->Print( aNestLevel+3, "(xy %s %s)\n",
FormatBIU( it->x ).c_str(), FormatBIU( it->y ).c_str() ); FMT_IU( it->x ).c_str(), FMT_IU( it->y ).c_str() );
if( it->end_contour ) if( it->end_contour )
{ {
@ -1088,8 +1088,8 @@ void ZONE_CONTAINER::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aC
for( std::vector< SEGMENT >::const_iterator it = segs.begin(); it != segs.end(); ++it ) for( std::vector< SEGMENT >::const_iterator it = segs.begin(); it != segs.end(); ++it )
{ {
aFormatter->Print( aNestLevel+2, "(pts (xy %s) (xy %s))\n", aFormatter->Print( aNestLevel+2, "(pts (xy %s) (xy %s))\n",
FormatBIU( it->m_Start ).c_str(), FMT_IU( it->m_Start ).c_str(),
FormatBIU( it->m_End ).c_str() ); FMT_IU( it->m_End ).c_str() );
} }
aFormatter->Print( aNestLevel+1, ")\n" ); aFormatter->Print( aNestLevel+1, ")\n" );

View File

@ -9,6 +9,8 @@
#include <macros.h> #include <macros.h>
#include <trigo.h> #include <trigo.h>
#include <class_pcb_screen.h> #include <class_pcb_screen.h>
#include <eda_text.h> // FILLED
#include <pcbnew.h> #include <pcbnew.h>
#include <class_board_design_settings.h> #include <class_board_design_settings.h>
#include <layers_id_colors_and_visibility.h> #include <layers_id_colors_and_visibility.h>

View File

@ -25,7 +25,7 @@
#include <wx/wx.h> #include <wx/wx.h>
#include <pcb_plot_params_lexer.h> #include <pcb_plot_params_lexer.h>
#include <base_struct.h> #include <eda_text.h> // EDA_DRAW_MODE_T
class PCB_PLOT_PARAMS_PARSER; class PCB_PLOT_PARAMS_PARSER;
class LINE_READER; class LINE_READER;