EDA_TEXT object refactor.

Make all EDA_TEXT data private and rename accessors to avoid function
name collisions in derived classes.

Overload EDA_TEXT's SetTextAngle() and SetEffects() in TEXTE_PCB.

Add support for preserving Reference text position, size, orientation
during a netlist import into a BOARD, as well as the one off footprint
update dialog.
This commit is contained in:
Dick Hollenbeck 2017-01-23 14:30:11 -06:00 committed by Wayne Stambaugh
parent 5d9190038f
commit 0c459ced97
80 changed files with 1530 additions and 1281 deletions

View File

@ -93,7 +93,7 @@ void CINFO3D_VISU::AddShapeWithClearanceToContainer( const TEXTE_PCB* aTextPCB,
LAYER_ID aLayerId, LAYER_ID aLayerId,
int aClearanceValue ) int aClearanceValue )
{ {
wxSize size = aTextPCB->GetSize(); wxSize size = aTextPCB->GetTextSize();
if( aTextPCB->IsMirrored() ) if( aTextPCB->IsMirrored() )
size.x = -size.x; size.x = -size.x;
@ -121,7 +121,7 @@ void CINFO3D_VISU::AddShapeWithClearanceToContainer( const TEXTE_PCB* aTextPCB,
wxString txt = strings_list.Item( ii ); wxString txt = strings_list.Item( ii );
DrawGraphicText( NULL, NULL, positions[ii], dummy_color, DrawGraphicText( NULL, NULL, positions[ii], dummy_color,
txt, aTextPCB->GetOrientation(), size, txt, aTextPCB->GetTextAngle(), size,
aTextPCB->GetHorizJustify(), aTextPCB->GetVertJustify(), aTextPCB->GetHorizJustify(), aTextPCB->GetVertJustify(),
aTextPCB->GetThickness(), aTextPCB->IsItalic(), aTextPCB->GetThickness(), aTextPCB->IsItalic(),
true, addTextSegmToContainer ); true, addTextSegmToContainer );
@ -129,8 +129,8 @@ void CINFO3D_VISU::AddShapeWithClearanceToContainer( const TEXTE_PCB* aTextPCB,
} }
else else
{ {
DrawGraphicText( NULL, NULL, aTextPCB->GetTextPosition(), dummy_color, DrawGraphicText( NULL, NULL, aTextPCB->GetTextPos(), dummy_color,
aTextPCB->GetShownText(), aTextPCB->GetOrientation(), size, aTextPCB->GetShownText(), aTextPCB->GetTextAngle(), size,
aTextPCB->GetHorizJustify(), aTextPCB->GetVertJustify(), aTextPCB->GetHorizJustify(), aTextPCB->GetVertJustify(),
aTextPCB->GetThickness(), aTextPCB->IsItalic(), aTextPCB->GetThickness(), aTextPCB->IsItalic(),
true, addTextSegmToContainer ); true, addTextSegmToContainer );
@ -199,12 +199,12 @@ void CINFO3D_VISU::AddGraphicsShapesWithClearanceToContainer( const MODULE* aMod
{ {
TEXTE_MODULE *textmod = texts[ii]; TEXTE_MODULE *textmod = texts[ii];
s_textWidth = textmod->GetThickness() + ( 2 * aInflateValue ); s_textWidth = textmod->GetThickness() + ( 2 * aInflateValue );
wxSize size = textmod->GetSize(); wxSize size = textmod->GetTextSize();
if( textmod->IsMirrored() ) if( textmod->IsMirrored() )
size.x = -size.x; size.x = -size.x;
DrawGraphicText( NULL, NULL, textmod->GetTextPosition(), BLACK, DrawGraphicText( NULL, NULL, textmod->GetTextPos(), BLACK,
textmod->GetShownText(), textmod->GetDrawRotation(), size, textmod->GetShownText(), textmod->GetDrawRotation(), size,
textmod->GetHorizJustify(), textmod->GetVertJustify(), textmod->GetHorizJustify(), textmod->GetVertJustify(),
textmod->GetThickness(), textmod->IsItalic(), textmod->GetThickness(), textmod->IsItalic(),

View File

@ -128,9 +128,9 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
case WS_DRAW_ITEM_BASE::wsg_text: case WS_DRAW_ITEM_BASE::wsg_text:
{ {
WS_DRAW_ITEM_TEXT* text = (WS_DRAW_ITEM_TEXT*) item; WS_DRAW_ITEM_TEXT* text = (WS_DRAW_ITEM_TEXT*) item;
plotter->Text( text->GetTextPosition(), text->GetColor(), plotter->Text( text->GetTextPos(), text->GetColor(),
text->GetShownText(), text->GetOrientation(), text->GetShownText(), text->GetTextAngle(),
text->GetSize(), text->GetTextSize(),
text->GetHorizJustify(), text->GetVertJustify(), text->GetHorizJustify(), text->GetVertJustify(),
text->GetPenWidth(), text->GetPenWidth(),
text->IsItalic(), text->IsBold(), text->IsItalic(), text->IsBold(),

View File

@ -160,7 +160,7 @@ void DrawGraphicText( EDA_RECT* aClipBox,
if( size.x < 0 ) if( size.x < 0 )
size.x = - size.x; size.x = - size.x;
dummy.SetSize( size ); dummy.SetTextSize( size );
basic_gal.SetTextAttributes( &dummy ); basic_gal.SetTextAttributes( &dummy );
basic_gal.SetPlotter( aPlotter ); basic_gal.SetPlotter( aPlotter );
@ -172,6 +172,7 @@ void DrawGraphicText( EDA_RECT* aClipBox,
basic_gal.StrokeText( aText, VECTOR2D( aPos ), aOrient * M_PI/1800 ); basic_gal.StrokeText( aText, VECTOR2D( aPos ), aOrient * M_PI/1800 );
} }
void DrawGraphicHaloText( EDA_RECT* aClipBox, wxDC * aDC, void DrawGraphicHaloText( EDA_RECT* aClipBox, wxDC * aDC,
const wxPoint &aPos, const wxPoint &aPos,
enum EDA_COLOR_T aBgColor, enum EDA_COLOR_T aBgColor,

View File

@ -50,19 +50,12 @@
#include <convert_to_biu.h> #include <convert_to_biu.h>
EDA_TEXT::EDA_TEXT( const wxString& text ) EDA_TEXT::EDA_TEXT( const wxString& text ) :
m_Text( text ),
m_e( 1<<TE_VISIBLE )
{ {
m_Size.x = m_Size.y = Mils2iu( DEFAULT_SIZE_TEXT ); // Width and height of font. int sz = Mils2iu( DEFAULT_SIZE_TEXT );
m_Orient = 0; // Rotation angle in 0.1 degrees. SetTextSize( wxSize( sz, sz ) );
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;
} }
@ -71,18 +64,23 @@ EDA_TEXT::~EDA_TEXT()
} }
void EDA_TEXT::SetOrientation( double aOrientation ) void EDA_TEXT::SetEffects( const EDA_TEXT& aSrc )
{ {
m_Orient = aOrientation; m_e = aSrc.m_e;
NORMALIZE_ANGLE_360( m_Orient ); }
void EDA_TEXT::SwapEffects( EDA_TEXT& aTradingPartner )
{
std::swap( m_e, aTradingPartner.m_e );
} }
int EDA_TEXT::LenSize( const wxString& aLine ) const int EDA_TEXT::LenSize( const wxString& aLine ) const
{ {
basic_gal.SetFontItalic( m_Italic ); basic_gal.SetFontItalic( IsItalic() );
basic_gal.SetFontBold( m_Bold ); basic_gal.SetFontBold( IsBold() );
basic_gal.SetGlyphSize( VECTOR2D( m_Size ) ); basic_gal.SetGlyphSize( VECTOR2D( GetTextSize() ) );
VECTOR2D tsize = basic_gal.GetTextLineSize( aLine ); VECTOR2D tsize = basic_gal.GetTextLineSize( aLine );
@ -93,6 +91,7 @@ int EDA_TEXT::LenSize( const wxString& aLine ) const
wxString EDA_TEXT::ShortenedShownText() const wxString EDA_TEXT::ShortenedShownText() const
{ {
wxString tmp = GetShownText(); wxString tmp = GetShownText();
tmp.Replace( wxT( "\n" ), wxT( " " ) ); tmp.Replace( wxT( "\n" ), wxT( " " ) );
tmp.Replace( wxT( "\r" ), wxT( " " ) ); tmp.Replace( wxT( "\r" ), wxT( " " ) );
tmp.Replace( wxT( "\t" ), wxT( " " ) ); tmp.Replace( wxT( "\t" ), wxT( " " ) );
@ -104,28 +103,24 @@ wxString EDA_TEXT::ShortenedShownText() const
} }
/*
* calculate the distance (pitch) between 2 text lines
* the distance includes the interline + room for chars like j { and [
* Is used for multiline texts, but also for single line texts, to calculate
* the text bounding box
*/
int EDA_TEXT::GetInterline( int aTextThickness ) const int EDA_TEXT::GetInterline( int aTextThickness ) const
{ {
int thickness = aTextThickness <= 0 ? m_Thickness : aTextThickness; int thickness = aTextThickness <= 0 ? GetThickness() : aTextThickness;
return KiROUND( KIGFX::STROKE_FONT::GetInterline( m_Size.y, thickness ) );
return KiROUND( KIGFX::STROKE_FONT::GetInterline( GetTextHeight(), thickness ) );
} }
EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
{ {
EDA_RECT rect; EDA_RECT rect;
wxArrayString strings; wxArrayString strings;
wxString text = GetShownText(); wxString text = GetShownText();
int thickness = ( aThickness < 0 ) ? m_Thickness : aThickness; int thickness = ( aThickness < 0 ) ? GetThickness() : aThickness;
int linecount = 1; int linecount = 1;
bool hasOverBar = false; // true if the first line of text as an overbar bool hasOverBar = false; // true if the first line of text as an overbar
if( m_MultilineAllowed ) if( IsMultilineAllowed() )
{ {
wxStringSplit( text, strings, '\n' ); wxStringSplit( text, strings, '\n' );
@ -153,14 +148,14 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
// calculate the H and V size // calculate the H and V size
int dx = KiROUND( basic_gal.GetStrokeFont().ComputeStringBoundaryLimits( int dx = KiROUND( basic_gal.GetStrokeFont().ComputeStringBoundaryLimits(
text, VECTOR2D( m_Size ), double( thickness ) ).x ); text, VECTOR2D( GetTextSize() ), double( thickness ) ).x );
int dy = GetInterline( thickness ); int dy = GetInterline( thickness );
// Creates bounding box (rectangle) for an horizontal // Creates bounding box (rectangle) for an horizontal
// and left and top justified text. the bounding box will be moved later // and left and top justified text. the bounding box will be moved later
// according to the actual text options // according to the actual text options
wxSize textsize = wxSize( dx, dy ); wxSize textsize = wxSize( dx, dy );
wxPoint pos = m_Pos; wxPoint pos = GetTextPos();
if( aInvertY ) if( aInvertY )
pos.y = -pos.y; pos.y = -pos.y;
@ -171,15 +166,15 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
// includes letters like j and y and ] + interval between lines. // includes letters like j and y and ] + interval between lines.
// The interval below the last line is not usefull, and we can use its half value // The interval below the last line is not usefull, and we can use its half value
// as vertical margin above the text // as vertical margin above the text
// the full interval is roughly m_Size.y * 0.4 - aThickness/2 // the full interval is roughly GetTextHeight() * 0.4 - aThickness/2
rect.Move( wxPoint( 0, thickness/4 - KiROUND( m_Size.y * 0.22 ) ) ); rect.Move( wxPoint( 0, thickness/4 - KiROUND( GetTextHeight() * 0.22 ) ) );
if( hasOverBar ) if( hasOverBar )
{ // A overbar adds an extra size to the text { // A overbar adds an extra size to the text
// Height from the base line text of chars like [ or { // Height from the base line text of chars like [ or {
double curr_height = m_Size.y * 1.15; double curr_height = GetTextHeight() * 1.15;
int extra_height = KiROUND( int extra_height = KiROUND(
basic_gal.GetStrokeFont().ComputeOverbarVerticalPosition( m_Size.y, thickness ) - curr_height ); basic_gal.GetStrokeFont().ComputeOverbarVerticalPosition( GetTextHeight(), thickness ) - curr_height );
extra_height += thickness/2; extra_height += thickness/2;
textsize.y += extra_height; textsize.y += extra_height;
rect.Move( wxPoint( 0, -extra_height ) ); rect.Move( wxPoint( 0, -extra_height ) );
@ -187,13 +182,13 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
// for multiline texts and aLine < 0, merge all rectangles // for multiline texts and aLine < 0, merge all rectangles
// ( if aLine < 0, we want the full text bounding box ) // ( if aLine < 0, we want the full text bounding box )
if( m_MultilineAllowed && aLine < 0 ) if( IsMultilineAllowed() && aLine < 0 )
{ {
for( unsigned ii = 1; ii < strings.GetCount(); ii++ ) for( unsigned ii = 1; ii < strings.GetCount(); ii++ )
{ {
text = strings.Item( ii ); text = strings.Item( ii );
dx = KiROUND( basic_gal.GetStrokeFont().ComputeStringBoundaryLimits( dx = KiROUND( basic_gal.GetStrokeFont().ComputeStringBoundaryLimits(
text, VECTOR2D( m_Size ), double( thickness ) ).x ); text, VECTOR2D( GetTextSize() ), double( thickness ) ).x );
textsize.x = std::max( textsize.x, dx ); textsize.x = std::max( textsize.x, dx );
textsize.y += dy; textsize.y += dy;
} }
@ -207,10 +202,10 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
* orientation). and must be recalculated for others justifications * orientation). and must be recalculated for others justifications
* also, note the V justification is relative to the first line * also, note the V justification is relative to the first line
*/ */
switch( m_HJustify ) switch( GetHorizJustify() )
{ {
case GR_TEXT_HJUSTIFY_LEFT: case GR_TEXT_HJUSTIFY_LEFT:
if( m_Mirror ) if( IsMirrored() )
rect.SetX( rect.GetX() - rect.GetWidth() ); rect.SetX( rect.GetX() - rect.GetWidth() );
break; break;
@ -219,14 +214,14 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
break; break;
case GR_TEXT_HJUSTIFY_RIGHT: case GR_TEXT_HJUSTIFY_RIGHT:
if( !m_Mirror ) if( !IsMirrored() )
rect.SetX( rect.GetX() - rect.GetWidth() ); rect.SetX( rect.GetX() - rect.GetWidth() );
break; break;
} }
dy = m_Size.y + thickness; dy = GetTextHeight() + thickness;
switch( m_VJustify ) switch( GetVertJustify() )
{ {
case GR_TEXT_VJUSTIFY_TOP: case GR_TEXT_VJUSTIFY_TOP:
break; break;
@ -245,7 +240,7 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
int yoffset; int yoffset;
linecount -= 1; linecount -= 1;
switch( m_VJustify ) switch( GetVertJustify() )
{ {
case GR_TEXT_VJUSTIFY_TOP: case GR_TEXT_VJUSTIFY_TOP:
break; break;
@ -274,7 +269,7 @@ bool EDA_TEXT::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const
wxPoint location = aPoint; wxPoint location = aPoint;
rect.Inflate( aAccuracy ); rect.Inflate( aAccuracy );
RotatePoint( &location, m_Pos, -m_Orient ); RotatePoint( &location, GetTextPos(), -GetTextAngle() );
return rect.Contains( location ); return rect.Contains( location );
} }
@ -297,14 +292,15 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode,
EDA_DRAW_MODE_T aFillMode, EDA_COLOR_T aAnchor_color ) EDA_DRAW_MODE_T aFillMode, EDA_COLOR_T aAnchor_color )
{ {
if( m_MultilineAllowed ) if( IsMultilineAllowed() )
{ {
std::vector<wxPoint> positions; std::vector<wxPoint> positions;
wxArrayString strings; wxArrayString strings;
wxStringSplit( GetShownText(), strings, '\n' ); wxStringSplit( GetShownText(), strings, '\n' );
positions.reserve( strings.Count() ); positions.reserve( strings.Count() );
GetPositionsOfLinesOfMultilineText(positions, strings.Count() ); GetPositionsOfLinesOfMultilineText( positions, strings.Count() );
for( unsigned ii = 0; ii < strings.Count(); ii++ ) for( unsigned ii = 0; ii < strings.Count(); ii++ )
{ {
@ -315,13 +311,13 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
} }
else else
drawOneLineOfText( aClipBox, aDC, aOffset, aColor, drawOneLineOfText( aClipBox, aDC, aOffset, aColor,
aDrawMode, aFillMode, GetShownText(), m_Pos ); aDrawMode, aFillMode, GetShownText(), GetTextPos() );
// Draw text anchor, if requested // Draw text anchor, if requested
if( aAnchor_color != UNSPECIFIED_COLOR ) if( aAnchor_color != UNSPECIFIED_COLOR )
{ {
GRDrawAnchor( aClipBox, aDC, GRDrawAnchor( aClipBox, aDC,
m_Pos.x + aOffset.x, m_Pos.y + aOffset.y, GetTextPos().x + aOffset.x, GetTextPos().y + aOffset.y,
DIM_ANCRE_TEXTE, aAnchor_color ); DIM_ANCRE_TEXTE, aAnchor_color );
} }
} }
@ -330,17 +326,17 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
void EDA_TEXT::GetPositionsOfLinesOfMultilineText( void EDA_TEXT::GetPositionsOfLinesOfMultilineText(
std::vector<wxPoint>& aPositions, int aLineCount ) const std::vector<wxPoint>& aPositions, int aLineCount ) const
{ {
wxPoint pos = m_Pos; // Position of first line of the wxPoint pos = GetTextPos(); // Position of first line of the
// multiline text according to // multiline text according to
// the center of the multiline text block // the center of the multiline text block
wxPoint offset; // Offset to next line. wxPoint offset; // Offset to next line.
offset.y = GetInterline(); offset.y = GetInterline();
if( aLineCount > 1 ) if( aLineCount > 1 )
{ {
switch( m_VJustify ) switch( GetVertJustify() )
{ {
case GR_TEXT_VJUSTIFY_TOP: case GR_TEXT_VJUSTIFY_TOP:
break; break;
@ -357,10 +353,10 @@ void EDA_TEXT::GetPositionsOfLinesOfMultilineText(
// Rotate the position of the first line // Rotate the position of the first line
// around the center of the multiline text block // around the center of the multiline text block
RotatePoint( &pos, m_Pos, m_Orient ); RotatePoint( &pos, GetTextPos(), GetTextAngle() );
// Rotate the offset lines to increase happened in the right direction // Rotate the offset lines to increase happened in the right direction
RotatePoint( &offset, m_Orient ); RotatePoint( &offset, GetTextAngle() );
for( int ii = 0; ii < aLineCount; ii++ ) for( int ii = 0; ii < aLineCount; ii++ )
{ {
@ -374,7 +370,7 @@ void EDA_TEXT::drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC,
GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aFillMode, GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aFillMode,
const wxString& aText, const wxPoint &aPos ) const wxString& aText, const wxPoint &aPos )
{ {
int width = m_Thickness; int width = GetThickness();
if( aDrawMode != UNSPECIFIED_DRAWMODE ) if( aDrawMode != UNSPECIFIED_DRAWMODE )
GRSetDrawMode( aDC, aDrawMode ); GRSetDrawMode( aDC, aDrawMode );
@ -382,13 +378,14 @@ void EDA_TEXT::drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC,
if( aFillMode == SKETCH ) if( aFillMode == SKETCH )
width = -width; width = -width;
wxSize size = m_Size; wxSize size = GetTextSize();
if( m_Mirror ) if( IsMirrored() )
size.x = -size.x; size.x = -size.x;
DrawGraphicText( aClipBox, aDC, aOffset + aPos, aColor, aText, m_Orient, size, DrawGraphicText( aClipBox, aDC, aOffset + aPos, aColor, aText, GetTextAngle(), size,
m_HJustify, m_VJustify, width, m_Italic, m_Bold ); GetHorizJustify(), GetVertJustify(),
width, IsItalic(), IsBold() );
} }
@ -396,10 +393,10 @@ wxString EDA_TEXT::GetTextStyleName()
{ {
int style = 0; int style = 0;
if( m_Italic ) if( IsItalic() )
style = 1; style = 1;
if( m_Bold ) if( IsBold() )
style += 2; style += 2;
wxString stylemsg[4] = { wxString stylemsg[4] = {
@ -415,16 +412,17 @@ wxString EDA_TEXT::GetTextStyleName()
bool EDA_TEXT::IsDefaultFormatting() const bool EDA_TEXT::IsDefaultFormatting() const
{ {
return ( ( m_Size.x == Mils2iu( DEFAULT_SIZE_TEXT ) ) return ( GetTextWidth() == Mils2iu( DEFAULT_SIZE_TEXT )
&& ( m_Size.y == Mils2iu( DEFAULT_SIZE_TEXT ) ) && GetTextHeight() == Mils2iu( DEFAULT_SIZE_TEXT )
&& ( m_Attributs == 0 ) && IsVisible()
&& ( m_Mirror == false ) && !IsMirrored()
&& ( m_HJustify == GR_TEXT_HJUSTIFY_CENTER ) && GetHorizJustify() == GR_TEXT_HJUSTIFY_CENTER
&& ( m_VJustify == GR_TEXT_VJUSTIFY_CENTER ) && GetVertJustify() == GR_TEXT_VJUSTIFY_CENTER
&& ( m_Thickness == 0 ) && GetThickness() == 0
&& ( m_Italic == false ) && !IsItalic()
&& ( m_Bold == false ) && !IsBold()
&& ( m_MultilineAllowed == false ) ); && !IsMultilineAllowed()
);
} }
void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
@ -437,23 +435,27 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
{ {
aFormatter->Print( aNestLevel+1, "(effects" ); aFormatter->Print( aNestLevel+1, "(effects" );
if( ( m_Size.x != Mils2iu( DEFAULT_SIZE_TEXT ) ) if( ( GetTextWidth() != Mils2iu( DEFAULT_SIZE_TEXT ) )
|| ( m_Size.y != Mils2iu( DEFAULT_SIZE_TEXT ) ) || ( GetTextHeight() != Mils2iu( DEFAULT_SIZE_TEXT ) )
|| ( m_Thickness != 0 ) || m_Bold || m_Italic ) || ( GetThickness() != 0 ) || IsBold() || IsItalic() )
{ {
aFormatter->Print( 0, " (font" ); aFormatter->Print( 0, " (font" );
// Add font support here at some point in the future. // Add font support here at some point in the future.
if( ( m_Size.x != Mils2iu( DEFAULT_SIZE_TEXT ) ) if( GetTextWidth() != Mils2iu( DEFAULT_SIZE_TEXT )
|| ( m_Size.y != Mils2iu( DEFAULT_SIZE_TEXT ) ) ) || GetTextHeight() != Mils2iu( DEFAULT_SIZE_TEXT ) )
aFormatter->Print( 0, " (size %s %s)", FMT_IU( m_Size.GetHeight() ).c_str(), {
FMT_IU( m_Size.GetWidth() ).c_str() ); aFormatter->Print( 0, " (size %s %s)",
FMT_IU( GetTextHeight() ).c_str(),
FMT_IU( GetTextWidth() ).c_str()
);
}
if( m_Thickness != 0 ) if( GetThickness() )
aFormatter->Print( 0, " (thickness %s)", FMT_IU( GetThickness() ).c_str() ); aFormatter->Print( 0, " (thickness %s)", FMT_IU( GetThickness() ).c_str() );
if( m_Bold ) if( IsBold() )
aFormatter->Print( 0, " bold" ); aFormatter->Print( 0, " bold" );
if( IsItalic() ) if( IsItalic() )
@ -462,25 +464,25 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
aFormatter->Print( 0, ")"); aFormatter->Print( 0, ")");
} }
if( m_Mirror || ( m_HJustify != GR_TEXT_HJUSTIFY_CENTER ) if( IsMirrored() || ( GetHorizJustify() != GR_TEXT_HJUSTIFY_CENTER )
|| ( m_VJustify != GR_TEXT_VJUSTIFY_CENTER ) ) || ( GetVertJustify() != GR_TEXT_VJUSTIFY_CENTER ) )
{ {
aFormatter->Print( 0, " (justify"); aFormatter->Print( 0, " (justify");
if( m_HJustify != GR_TEXT_HJUSTIFY_CENTER ) if( GetHorizJustify() != GR_TEXT_HJUSTIFY_CENTER )
aFormatter->Print( 0, (m_HJustify == GR_TEXT_HJUSTIFY_LEFT) ? " left" : " right" ); aFormatter->Print( 0, (GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT) ? " left" : " right" );
if( m_VJustify != GR_TEXT_VJUSTIFY_CENTER ) if( GetVertJustify() != GR_TEXT_VJUSTIFY_CENTER )
aFormatter->Print( 0, (m_VJustify == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" ); aFormatter->Print( 0, (GetVertJustify() == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" );
if( m_Mirror ) if( IsMirrored() )
aFormatter->Print( 0, " mirror" ); aFormatter->Print( 0, " mirror" );
aFormatter->Print( 0, ")" ); aFormatter->Print( 0, ")" );
} }
// As of now the only place this is used is in Eeschema to hide or show the text. // As of now the only place this is used is in Eeschema to hide or show the text.
if( m_Attributs ) if( !IsVisible() )
aFormatter->Print( 0, " hide" ); aFormatter->Print( 0, " hide" );
aFormatter->Print( 0, ")\n" ); aFormatter->Print( 0, ")\n" );
@ -503,7 +505,7 @@ static void addTextSegmToBuffer( int x0, int y0, int xf, int yf )
void EDA_TEXT::TransformTextShapeToSegmentList( std::vector<wxPoint>& aCornerBuffer ) const void EDA_TEXT::TransformTextShapeToSegmentList( std::vector<wxPoint>& aCornerBuffer ) const
{ {
wxSize size = GetSize(); wxSize size = GetTextSize();
if( IsMirrored() ) if( IsMirrored() )
size.x = -size.x; size.x = -size.x;
@ -523,7 +525,7 @@ void EDA_TEXT::TransformTextShapeToSegmentList( std::vector<wxPoint>& aCornerBuf
{ {
wxString txt = strings_list.Item( ii ); wxString txt = strings_list.Item( ii );
DrawGraphicText( NULL, NULL, positions[ii], color, DrawGraphicText( NULL, NULL, positions[ii], color,
txt, GetOrientation(), size, txt, GetTextAngle(), size,
GetHorizJustify(), GetVertJustify(), GetHorizJustify(), GetVertJustify(),
GetThickness(), IsItalic(), GetThickness(), IsItalic(),
true, addTextSegmToBuffer ); true, addTextSegmToBuffer );
@ -531,8 +533,8 @@ void EDA_TEXT::TransformTextShapeToSegmentList( std::vector<wxPoint>& aCornerBuf
} }
else else
{ {
DrawGraphicText( NULL, NULL, GetTextPosition(), color, DrawGraphicText( NULL, NULL, GetTextPos(), color,
GetText(), GetOrientation(), size, GetText(), GetTextAngle(), size,
GetHorizJustify(), GetVertJustify(), GetHorizJustify(), GetVertJustify(),
GetThickness(), IsItalic(), GetThickness(), IsItalic(),
true, addTextSegmToBuffer ); true, addTextSegmToBuffer );

View File

@ -78,7 +78,7 @@ GAL::~GAL()
void GAL::SetTextAttributes( const EDA_TEXT* aText ) void GAL::SetTextAttributes( const EDA_TEXT* aText )
{ {
SetGlyphSize( VECTOR2D( aText->GetSize() ) ); SetGlyphSize( VECTOR2D( aText->GetTextSize() ) );
SetHorizontalJustify( aText->GetHorizJustify() ); SetHorizontalJustify( aText->GetHorizJustify() );
SetVerticalJustify( aText->GetVertJustify() ); SetVerticalJustify( aText->GetVertJustify() );
SetFontBold( aText->IsBold() ); SetFontBold( aText->IsBold() );
@ -86,6 +86,7 @@ void GAL::SetTextAttributes( const EDA_TEXT* aText )
SetTextMirrored( aText->IsMirrored() ); SetTextMirrored( aText->IsMirrored() );
} }
VECTOR2D GAL::GetTextLineSize( const UTF8& aText ) const VECTOR2D GAL::GetTextLineSize( const UTF8& aText ) const
{ {
// Compute the X and Y size of a given text. // Compute the X and Y size of a given text.

View File

@ -467,7 +467,7 @@ void WORKSHEET_DATAITEM_TEXT::TransfertSetupToGraphicText( WS_DRAW_ITEM_TEXT* aG
{ {
aGText->SetHorizJustify( m_Hjustify ) ; aGText->SetHorizJustify( m_Hjustify ) ;
aGText->SetVertJustify( m_Vjustify ); aGText->SetVertJustify( m_Vjustify );
aGText->SetOrientation( m_Orient * 10 ); // graphic text orient unit = 0.1 degree aGText->SetTextAngle( m_Orient * 10 ); // graphic text orient unit = 0.1 degree
} }

View File

@ -140,7 +140,7 @@ void WS_DRAW_ITEM_LIST::Draw( EDA_RECT* aClipBox, wxDC* aDC )
WS_DRAW_ITEM_TEXT* text = (WS_DRAW_ITEM_TEXT*) item; WS_DRAW_ITEM_TEXT* text = (WS_DRAW_ITEM_TEXT*) item;
if( markerSize ) if( markerSize )
drawMarker( aClipBox, aDC, text->GetTextPosition(), drawMarker( aClipBox, aDC, text->GetTextPos(),
markerSize ); markerSize );
} }
break; break;
@ -179,8 +179,8 @@ WS_DRAW_ITEM_TEXT::WS_DRAW_ITEM_TEXT( WORKSHEET_DATAITEM* aParent,
bool aItalic, bool aBold ) : bool aItalic, bool aBold ) :
WS_DRAW_ITEM_BASE( aParent, wsg_text, aColor ), EDA_TEXT( aText ) WS_DRAW_ITEM_BASE( aParent, wsg_text, aColor ), EDA_TEXT( aText )
{ {
SetTextPosition( aPos ); SetTextPos( aPos );
SetSize( aSize ); SetTextSize( aSize );
SetThickness( aPenWidth ); SetThickness( aPenWidth );
SetItalic( aItalic ); SetItalic( aItalic );
SetBold( aBold ); SetBold( aBold );
@ -211,7 +211,7 @@ bool WS_DRAW_ITEM_TEXT::HitTest( const EDA_RECT& aRect ) const
bool WS_DRAW_ITEM_TEXT::HitTestStartPoint( const wxPoint& aPosition) bool WS_DRAW_ITEM_TEXT::HitTestStartPoint( const wxPoint& aPosition)
{ {
wxPoint pos = GetTextPosition(); wxPoint pos = GetTextPos();
if( std::abs( pos.x - aPosition.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 && if( std::abs( pos.x - aPosition.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
std::abs( pos.y - aPosition.y) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 ) std::abs( pos.y - aPosition.y) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 )

View File

@ -184,11 +184,11 @@ void WORKSHEET_VIEWITEM::draw( const WS_DRAW_ITEM_POLYGON* aItem, GAL* aGal ) co
void WORKSHEET_VIEWITEM::draw( const WS_DRAW_ITEM_TEXT* aItem, GAL* aGal ) const void WORKSHEET_VIEWITEM::draw( const WS_DRAW_ITEM_TEXT* aItem, GAL* aGal ) const
{ {
VECTOR2D position( aItem->GetTextPosition().x, aItem->GetTextPosition().y ); VECTOR2D position( aItem->GetTextPos().x, aItem->GetTextPos().y );
aGal->Save(); aGal->Save();
aGal->Translate( position ); aGal->Translate( position );
aGal->Rotate( -aItem->GetOrientation() * M_PI / 1800.0 ); aGal->Rotate( -aItem->GetTextAngle() * M_PI / 1800.0 );
aGal->SetStrokeColor( COLOR4D( aItem->GetColor() ) ); aGal->SetStrokeColor( COLOR4D( aItem->GetColor() ) );
aGal->SetLineWidth( aItem->GetThickness() ); aGal->SetLineWidth( aItem->GetThickness() );
aGal->SetTextAttributes( aItem ); aGal->SetTextAttributes( aItem );

View File

@ -195,11 +195,11 @@ protected:
if( m_component->GetTransform().y1 ) if( m_component->GetTransform().y1 )
{ {
field->SetOrientation( TEXT_ORIENT_VERT ); field->SetTextAngle( TEXT_ANGLE_VERT );
} }
else else
{ {
field->SetOrientation( TEXT_ORIENT_HORIZ ); field->SetTextAngle( TEXT_ANGLE_HORIZ );
} }
field_width = field->GetBoundingBox().GetWidth(); field_width = field->GetBoundingBox().GetWidth();

View File

@ -480,7 +480,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event
// change all field positions from relative to absolute // change all field positions from relative to absolute
for( unsigned i = 0; i<m_FieldsBuf.size(); ++i ) for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
{ {
m_FieldsBuf[i].SetTextPosition( m_FieldsBuf[i].GetTextPosition() + m_cmp->m_Pos ); m_FieldsBuf[i].Offset( m_cmp->m_Pos );
} }
LIB_PART* entry = Prj().SchLibs()->FindLibPart( m_cmp->m_part_name ); LIB_PART* entry = Prj().SchLibs()->FindLibPart( m_cmp->m_part_name );
@ -514,7 +514,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::addFieldButtonHandler( wxCommandEvent&
SCH_FIELD blank( wxPoint(), fieldNdx, m_cmp ); SCH_FIELD blank( wxPoint(), fieldNdx, m_cmp );
blank.SetOrientation( m_FieldsBuf[REFERENCE].GetOrientation() ); blank.SetTextAngle( m_FieldsBuf[REFERENCE].GetTextAngle() );
m_FieldsBuf.push_back( blank ); m_FieldsBuf.push_back( blank );
m_FieldsBuf[fieldNdx].SetName( TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldNdx ) ); m_FieldsBuf[fieldNdx].SetName( TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldNdx ) );
@ -680,8 +680,9 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
#if 0 && defined(DEBUG) #if 0 && defined(DEBUG)
for( int i = 0; i<aComponent->GetFieldCount(); ++i ) for( int i = 0; i<aComponent->GetFieldCount(); ++i )
{ {
printf( "Orig[%d] (x=%d, y=%d)\n", i, aComponent->m_Fields[i].GetTextPosition().x, printf( "Orig[%d] (x=%d, y=%d)\n", i,
aComponent->m_Fields[i].GetTextPosition().y ); aComponent->m_Fields[i].GetTextPos().x,
aComponent->m_Fields[i].GetTextPos().y );
} }
#endif #endif
@ -698,7 +699,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
m_FieldsBuf.push_back( aComponent->m_Fields[i] ); m_FieldsBuf.push_back( aComponent->m_Fields[i] );
// make the editable field position relative to the component // make the editable field position relative to the component
m_FieldsBuf[i].SetTextPosition( m_FieldsBuf[i].GetTextPosition() - m_cmp->m_Pos ); m_FieldsBuf[i].Offset( -m_cmp->m_Pos );
} }
// Add template fieldnames: // Add template fieldnames:
@ -731,7 +732,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
fld = *schField; fld = *schField;
// make the editable field position relative to the component // make the editable field position relative to the component
fld.SetTextPosition( fld.GetTextPosition() - m_cmp->m_Pos ); fld.Offset( -m_cmp->m_Pos );
} }
m_FieldsBuf.push_back( fld ); m_FieldsBuf.push_back( fld );
@ -750,8 +751,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
m_FieldsBuf.push_back( *cmp ); m_FieldsBuf.push_back( *cmp );
// make the editable field position relative to the component // make the editable field position relative to the component
m_FieldsBuf[newNdx].SetTextPosition( m_FieldsBuf[newNdx].GetTextPosition() - m_FieldsBuf[newNdx].Offset( -m_cmp->m_Pos );
m_cmp->m_Pos );
} }
} }
@ -837,7 +837,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
showCheckBox->SetValue( field.IsVisible() ); showCheckBox->SetValue( field.IsVisible() );
rotateCheckBox->SetValue( field.GetOrientation() == TEXT_ORIENT_VERT ); rotateCheckBox->SetValue( field.GetTextAngle() == TEXT_ANGLE_VERT );
int style = 0; int style = 0;
@ -910,9 +910,9 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
else else
fieldValueTextCtrl->Enable( true ); fieldValueTextCtrl->Enable( true );
textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.GetSize().x ) ); textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.GetTextWidth() ) );
wxPoint coord = field.GetTextPosition(); wxPoint coord = field.GetTextPos();
wxPoint zero = -m_cmp->m_Pos; // relative zero wxPoint zero = -m_cmp->m_Pos; // relative zero
// If the field value is empty and the position is at relative zero, we // If the field value is empty and the position is at relative zero, we
@ -921,12 +921,12 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
// close to the desired position. // close to the desired position.
if( coord == zero && field.GetText().IsEmpty() ) if( coord == zero && field.GetText().IsEmpty() )
{ {
rotateCheckBox->SetValue( m_FieldsBuf[REFERENCE].GetOrientation() == TEXT_ORIENT_VERT ); rotateCheckBox->SetValue( m_FieldsBuf[REFERENCE].GetTextAngle() == TEXT_ANGLE_VERT );
coord.x = m_FieldsBuf[REFERENCE].GetTextPosition().x coord.x = m_FieldsBuf[REFERENCE].GetTextPos().x
+ ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100; + ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100;
coord.y = m_FieldsBuf[REFERENCE].GetTextPosition().y coord.y = m_FieldsBuf[REFERENCE].GetTextPos().y
+ ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100; + ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100;
// coord can compute negative if field is < MANDATORY_FIELDS, e.g. FOOTPRINT. // coord can compute negative if field is < MANDATORY_FIELDS, e.g. FOOTPRINT.
@ -959,11 +959,11 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField()
field.SetVisible( showCheckBox->GetValue() ); field.SetVisible( showCheckBox->GetValue() );
if( rotateCheckBox->GetValue() ) if( rotateCheckBox->GetValue() )
field.SetOrientation( TEXT_ORIENT_VERT ); field.SetTextAngle( TEXT_ANGLE_VERT );
else else
field.SetOrientation( TEXT_ORIENT_HORIZ ); field.SetTextAngle( TEXT_ANGLE_HORIZ );
rotateCheckBox->SetValue( field.GetOrientation() == TEXT_ORIENT_VERT ); rotateCheckBox->SetValue( field.GetTextAngle() == TEXT_ANGLE_VERT );
// Copy the text justification // Copy the text justification
static const EDA_TEXT_HJUSTIFY_T hjustify[] = { static const EDA_TEXT_HJUSTIFY_T hjustify[] = {
@ -994,7 +994,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField()
setRowItem( fieldNdx, field ); // update fieldListCtrl setRowItem( fieldNdx, field ); // update fieldListCtrl
int tmp = EDA_GRAPHIC_TEXT_CTRL::ParseSize( textSizeTextCtrl->GetValue(), g_UserUnit ); int tmp = EDA_GRAPHIC_TEXT_CTRL::ParseSize( textSizeTextCtrl->GetValue(), g_UserUnit );
field.SetSize( wxSize( tmp, tmp ) ); field.SetTextSize( wxSize( tmp, tmp ) );
int style = m_StyleRadioBox->GetSelection(); int style = m_StyleRadioBox->GetSelection();
field.SetItalic( (style & 1 ) != 0 ); field.SetItalic( (style & 1 ) != 0 );
@ -1003,7 +1003,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField()
wxPoint pos; wxPoint pos;
pos.x = ValueFromString( g_UserUnit, posXTextCtrl->GetValue() ); pos.x = ValueFromString( g_UserUnit, posXTextCtrl->GetValue() );
pos.y = ValueFromString( g_UserUnit, posYTextCtrl->GetValue() ); pos.y = ValueFromString( g_UserUnit, posYTextCtrl->GetValue() );
field.SetTextPosition( pos ); field.SetTextPos( pos );
return true; return true;
} }
@ -1110,19 +1110,19 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
// Only VALUE, REFERENCE , FOOTPRINT and DATASHEET are re-initialized // Only VALUE, REFERENCE , FOOTPRINT and DATASHEET are re-initialized
LIB_FIELD& refField = part->GetReferenceField(); LIB_FIELD& refField = part->GetReferenceField();
m_cmp->GetField( REFERENCE )->SetTextPosition( refField.GetTextPosition() + m_cmp->m_Pos ); m_cmp->GetField( REFERENCE )->SetTextPos( refField.GetTextPos() + m_cmp->m_Pos );
m_cmp->GetField( REFERENCE )->ImportValues( refField ); m_cmp->GetField( REFERENCE )->ImportValues( refField );
LIB_FIELD& valField = part->GetValueField(); LIB_FIELD& valField = part->GetValueField();
m_cmp->GetField( VALUE )->SetTextPosition( valField.GetTextPosition() + m_cmp->m_Pos ); m_cmp->GetField( VALUE )->SetTextPos( valField.GetTextPos() + m_cmp->m_Pos );
m_cmp->GetField( VALUE )->ImportValues( valField ); m_cmp->GetField( VALUE )->ImportValues( valField );
LIB_FIELD* field = part->GetField(FOOTPRINT); LIB_FIELD* field = part->GetField(FOOTPRINT);
if( field && m_cmp->GetField( FOOTPRINT ) ) if( field && m_cmp->GetField( FOOTPRINT ) )
{ {
m_cmp->GetField( FOOTPRINT )->SetTextPosition( field->GetTextPosition() + m_cmp->m_Pos ); m_cmp->GetField( FOOTPRINT )->SetTextPos( field->GetTextPos() + m_cmp->m_Pos );
m_cmp->GetField( FOOTPRINT )->ImportValues( *field ); m_cmp->GetField( FOOTPRINT )->ImportValues( *field );
} }
@ -1130,7 +1130,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
if( field && m_cmp->GetField( DATASHEET ) ) if( field && m_cmp->GetField( DATASHEET ) )
{ {
m_cmp->GetField( DATASHEET )->SetTextPosition( field->GetTextPosition() + m_cmp->m_Pos ); m_cmp->GetField( DATASHEET )->SetTextPos( field->GetTextPos() + m_cmp->m_Pos );
m_cmp->GetField( DATASHEET )->ImportValues( *field ); m_cmp->GetField( DATASHEET )->ImportValues( *field );
} }

View File

@ -206,7 +206,7 @@ void DIALOG_LABEL_EDITOR::InitDialog()
EnsureTextCtrlWidth( m_textLabel, &textWidth ); EnsureTextCtrlWidth( m_textLabel, &textWidth );
// Set validators // Set validators
m_TextOrient->SetSelection( m_CurrentText->GetOrientation() ); m_TextOrient->SetSelection( m_CurrentText->GetTextAngle() );
m_TextShape->SetSelection( m_CurrentText->GetShape() ); m_TextShape->SetSelection( m_CurrentText->GetShape() );
int style = 0; int style = 0;
@ -223,7 +223,7 @@ void DIALOG_LABEL_EDITOR::InitDialog()
msg.Printf( _( "H%s x W%s" ), GetChars( units ), GetChars( units ) ); msg.Printf( _( "H%s x W%s" ), GetChars( units ), GetChars( units ) );
m_staticSizeUnits->SetLabel( msg ); m_staticSizeUnits->SetLabel( msg );
msg = StringFromValue( g_UserUnit, m_CurrentText->GetSize().x ); msg = StringFromValue( g_UserUnit, m_CurrentText->GetTextWidth() );
m_TextSize->SetValue( msg ); m_TextSize->SetValue( msg );
if( m_CurrentText->Type() != SCH_GLOBAL_LABEL_T if( m_CurrentText->Type() != SCH_GLOBAL_LABEL_T
@ -290,10 +290,10 @@ void DIALOG_LABEL_EDITOR::TextPropertiesAccept( wxCommandEvent& aEvent )
return; return;
} }
m_CurrentText->SetOrientation( m_TextOrient->GetSelection() ); m_CurrentText->SetLabelSpinStyle( m_TextOrient->GetSelection() );
text = m_TextSize->GetValue(); text = m_TextSize->GetValue();
value = ValueFromString( g_UserUnit, text ); value = ValueFromString( g_UserUnit, text );
m_CurrentText->SetSize( wxSize( value, value ) ); m_CurrentText->SetTextSize( wxSize( value, value ) );
if( m_TextShape ) if( m_TextShape )
/// @todo move cast to widget /// @todo move cast to widget
@ -306,7 +306,7 @@ void DIALOG_LABEL_EDITOR::TextPropertiesAccept( wxCommandEvent& aEvent )
if( ( style & 2 ) ) if( ( style & 2 ) )
{ {
m_CurrentText->SetBold( true ); m_CurrentText->SetBold( true );
m_CurrentText->SetThickness( GetPenSizeForBold( m_CurrentText->GetSize().x ) ); m_CurrentText->SetThickness( GetPenSizeForBold( m_CurrentText->GetTextWidth() ) );
} }
else else
{ {
@ -318,7 +318,7 @@ void DIALOG_LABEL_EDITOR::TextPropertiesAccept( wxCommandEvent& aEvent )
// Make the text size the new default size ( if it is a new text ): // Make the text size the new default size ( if it is a new text ):
if( m_CurrentText->IsNew() ) if( m_CurrentText->IsNew() )
SetDefaultTextSize( m_CurrentText->GetSize().x ); SetDefaultTextSize( m_CurrentText->GetTextWidth() );
m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentText->GetBoundingBox() ); m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentText->GetBoundingBox() );
m_Parent->GetCanvas()->MoveCursorToCrossHair(); m_Parent->GetCanvas()->MoveCursorToCrossHair();

View File

@ -671,7 +671,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
showCheckBox->SetValue( field.IsVisible() ); showCheckBox->SetValue( field.IsVisible() );
rotateCheckBox->SetValue( field.GetOrientation() == TEXT_ORIENT_VERT ); rotateCheckBox->SetValue( field.GetTextAngle() == TEXT_ANGLE_VERT );
int style = 0; int style = 0;
@ -730,7 +730,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
fieldValueTextCtrl->SetValidator( SCH_FIELD_VALIDATOR( true, field.GetId() ) ); fieldValueTextCtrl->SetValidator( SCH_FIELD_VALIDATOR( true, field.GetId() ) );
fieldValueTextCtrl->SetValue( field.GetText() ); fieldValueTextCtrl->SetValue( field.GetText() );
textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.GetSize().x ) ); textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.GetTextSize().x ) );
m_show_datasheet_button->Enable( fieldNdx == DATASHEET || fieldNdx == FOOTPRINT ); m_show_datasheet_button->Enable( fieldNdx == DATASHEET || fieldNdx == FOOTPRINT );
@ -754,7 +754,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
_("Used only for fields Footprint and Datasheet.") ); _("Used only for fields Footprint and Datasheet.") );
} }
wxPoint coord = field.GetTextPosition(); wxPoint coord = field.GetTextPos();
wxPoint zero; wxPoint zero;
// If the field value is empty and the position is at relative zero, we set the // If the field value is empty and the position is at relative zero, we set the
@ -763,11 +763,11 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
// close to the desired position. // close to the desired position.
if( coord == zero && field.GetText().IsEmpty() ) if( coord == zero && field.GetText().IsEmpty() )
{ {
rotateCheckBox->SetValue( m_FieldsBuf[REFERENCE].GetOrientation() == TEXT_ORIENT_VERT ); rotateCheckBox->SetValue( m_FieldsBuf[REFERENCE].GetTextAngle() == TEXT_ANGLE_VERT );
coord.x = m_FieldsBuf[REFERENCE].GetTextPosition().x + coord.x = m_FieldsBuf[REFERENCE].GetTextPos().x +
(fieldNdx - MANDATORY_FIELDS + 1) * 100; (fieldNdx - MANDATORY_FIELDS + 1) * 100;
coord.y = m_FieldsBuf[REFERENCE].GetTextPosition().y + coord.y = m_FieldsBuf[REFERENCE].GetTextPos().y +
(fieldNdx - MANDATORY_FIELDS + 1) * 100; (fieldNdx - MANDATORY_FIELDS + 1) * 100;
// coord can compute negative if field is < MANDATORY_FIELDS, e.g. FOOTPRINT. // coord can compute negative if field is < MANDATORY_FIELDS, e.g. FOOTPRINT.
@ -806,9 +806,9 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField()
field.SetVisible( false ); field.SetVisible( false );
if( rotateCheckBox->GetValue() ) if( rotateCheckBox->GetValue() )
field.SetOrientation( TEXT_ORIENT_VERT ); field.SetTextAngle( TEXT_ANGLE_VERT );
else else
field.SetOrientation( TEXT_ORIENT_HORIZ ); field.SetTextAngle( TEXT_ANGLE_HORIZ );
// Copy the text justification // Copy the text justification
static const EDA_TEXT_HJUSTIFY_T hjustify[3] = { static const EDA_TEXT_HJUSTIFY_T hjustify[3] = {
@ -842,7 +842,7 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField()
int tmp = EDA_GRAPHIC_TEXT_CTRL::ParseSize( textSizeTextCtrl->GetValue(), g_UserUnit ); int tmp = EDA_GRAPHIC_TEXT_CTRL::ParseSize( textSizeTextCtrl->GetValue(), g_UserUnit );
field.SetSize( wxSize( tmp, tmp ) ); field.SetTextSize( wxSize( tmp, tmp ) );
int style = m_StyleRadioBox->GetSelection(); int style = m_StyleRadioBox->GetSelection();
@ -856,7 +856,7 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField()
// and the screen axis is top to bottom: we must change the y coord sign for editing // and the screen axis is top to bottom: we must change the y coord sign for editing
pos.y = -pos.y; pos.y = -pos.y;
field.SetTextPosition( pos ); field.SetTextPos( pos );
return true; return true;
} }

View File

@ -89,8 +89,8 @@ DIALOG_EDIT_ONE_FIELD::DIALOG_EDIT_ONE_FIELD( SCH_BASE_FRAME* aParent, const wxS
m_text = aTextItem->GetText(); m_text = aTextItem->GetText();
m_style = aTextItem->IsItalic() ? 1 : 0; m_style = aTextItem->IsItalic() ? 1 : 0;
m_style += aTextItem->IsBold() ? 2 : 0; m_style += aTextItem->IsBold() ? 2 : 0;
m_size = aTextItem->GetSize().x; m_size = aTextItem->GetTextWidth();
m_orientation = ( aTextItem->GetOrientation() == TEXT_ORIENT_VERT ); m_orientation = ( aTextItem->GetTextAngle() == TEXT_ANGLE_VERT );
m_verticalJustification = aTextItem->GetVertJustify() + 1; m_verticalJustification = aTextItem->GetVertJustify() + 1;
m_horizontalJustification = aTextItem->GetHorizJustify() + 1; m_horizontalJustification = aTextItem->GetHorizJustify() + 1;
m_isVisible = aTextItem->IsVisible(); m_isVisible = aTextItem->IsVisible();
@ -211,9 +211,9 @@ bool DIALOG_EDIT_ONE_FIELD::TransferDataFromWindow()
void DIALOG_EDIT_ONE_FIELD::updateText( EDA_TEXT* aText ) void DIALOG_EDIT_ONE_FIELD::updateText( EDA_TEXT* aText )
{ {
aText->SetSize( wxSize( m_size, m_size ) ); aText->SetTextSize( wxSize( m_size, m_size ) );
aText->SetVisible( m_isVisible ); aText->SetVisible( m_isVisible );
aText->SetOrientation( m_orientation ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ ); aText->SetTextAngle( m_orientation ? TEXT_ANGLE_VERT : TEXT_ANGLE_HORIZ );
aText->SetItalic( (m_style & 1) != 0 ); aText->SetItalic( (m_style & 1) != 0 );
aText->SetBold( (m_style & 2) != 0 ); aText->SetBold( (m_style & 2) != 0 );
aText->SetHorizJustify( IntToEdaTextHorizJustify( m_horizontalJustification - 1 ) ); aText->SetHorizJustify( IntToEdaTextHorizJustify( m_horizontalJustification - 1 ) );

View File

@ -64,41 +64,40 @@ void DIALOG_LIB_EDIT_TEXT::initDlg( )
// Disable options for fieldedition, not existing in graphic text // Disable options for fieldedition, not existing in graphic text
m_Invisible->Show(false); m_Invisible->Show(false);
if ( m_graphicText ) if( m_graphicText )
{ {
msg = StringFromValue( g_UserUnit, m_graphicText->GetSize().x ); msg = StringFromValue( g_UserUnit, m_graphicText->GetTextWidth() );
m_TextSize->SetValue( msg ); m_TextSize->SetValue( msg );
m_TextValue->SetValue( m_graphicText->GetText() ); m_TextValue->SetValue( m_graphicText->GetText() );
if ( m_graphicText->GetUnit() == 0 ) if( m_graphicText->GetUnit() == 0 )
m_CommonUnit->SetValue( true ); m_CommonUnit->SetValue( true );
if ( m_graphicText->GetConvert() == 0 ) if( m_graphicText->GetConvert() == 0 )
m_CommonConvert->SetValue( true ); m_CommonConvert->SetValue( true );
if ( m_graphicText->GetOrientation() == TEXT_ORIENT_VERT ) if( m_graphicText->GetTextAngle() == TEXT_ANGLE_VERT )
m_Orient->SetValue( true ); m_Orient->SetValue( true );
int shape = 0; int shape = 0;
if ( m_graphicText->IsItalic() ) if( m_graphicText->IsItalic() )
shape = 1; shape = 1;
if ( m_graphicText->IsBold() ) if( m_graphicText->IsBold() )
shape |= 2; shape |= 2;
m_TextShapeOpt->SetSelection( shape ); m_TextShapeOpt->SetSelection( shape );
switch ( m_graphicText->GetHorizJustify() ) switch ( m_graphicText->GetHorizJustify() )
{ {
case GR_TEXT_HJUSTIFY_LEFT: case GR_TEXT_HJUSTIFY_LEFT:
m_TextHJustificationOpt->SetSelection( 0 ); m_TextHJustificationOpt->SetSelection( 0 );
break; break;
case GR_TEXT_HJUSTIFY_CENTER: case GR_TEXT_HJUSTIFY_CENTER:
m_TextHJustificationOpt->SetSelection( 1 ); m_TextHJustificationOpt->SetSelection( 1 );
break; break;
case GR_TEXT_HJUSTIFY_RIGHT:
m_TextHJustificationOpt->SetSelection( 2 );
break;
case GR_TEXT_HJUSTIFY_RIGHT:
m_TextHJustificationOpt->SetSelection( 2 );
break;
} }
switch ( m_graphicText->GetVertJustify() ) switch ( m_graphicText->GetVertJustify() )
@ -121,11 +120,11 @@ void DIALOG_LIB_EDIT_TEXT::initDlg( )
msg = StringFromValue( g_UserUnit, m_parent->m_textSize ); msg = StringFromValue( g_UserUnit, m_parent->m_textSize );
m_TextSize->SetValue( msg ); m_TextSize->SetValue( msg );
if ( ! m_parent->m_drawSpecificUnit ) if( ! m_parent->m_drawSpecificUnit )
m_CommonUnit->SetValue( true ); m_CommonUnit->SetValue( true );
if ( ! m_parent->m_drawSpecificConvert ) if( ! m_parent->m_drawSpecificConvert )
m_CommonConvert->SetValue( true ); m_CommonConvert->SetValue( true );
if ( m_parent->m_textOrientation == TEXT_ORIENT_VERT ) if( m_parent->m_current_text_angle == TEXT_ANGLE_VERT )
m_Orient->SetValue( true ); m_Orient->SetValue( true );
} }
@ -155,7 +154,7 @@ void DIALOG_LIB_EDIT_TEXT::OnOkClick( wxCommandEvent& event )
wxString Line; wxString Line;
Line = m_TextValue->GetValue(); Line = m_TextValue->GetValue();
m_parent->m_textOrientation = m_Orient->GetValue() ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ; m_parent->m_current_text_angle = m_Orient->GetValue() ? TEXT_ANGLE_VERT : TEXT_ANGLE_HORIZ;
wxString msg = m_TextSize->GetValue(); wxString msg = m_TextSize->GetValue();
m_parent->m_textSize = ValueFromString( g_UserUnit, msg ); m_parent->m_textSize = ValueFromString( g_UserUnit, msg );
m_parent->m_drawSpecificConvert = m_CommonConvert->GetValue() ? false : true; m_parent->m_drawSpecificConvert = m_CommonConvert->GetValue() ? false : true;
@ -168,8 +167,8 @@ void DIALOG_LIB_EDIT_TEXT::OnOkClick( wxCommandEvent& event )
else else
m_graphicText->SetText( wxT( "[null]" ) ); m_graphicText->SetText( wxT( "[null]" ) );
m_graphicText->SetSize( wxSize( m_parent->m_textSize, m_parent->m_textSize ) ); m_graphicText->SetTextSize( wxSize( m_parent->m_textSize, m_parent->m_textSize ) );
m_graphicText->SetOrientation( m_parent->m_textOrientation ); m_graphicText->SetTextAngle( m_parent->m_current_text_angle );
if( m_parent->m_drawSpecificUnit ) if( m_parent->m_drawSpecificUnit )
m_graphicText->SetUnit( m_parent->GetUnit() ); m_graphicText->SetUnit( m_parent->GetUnit() );

View File

@ -107,10 +107,10 @@ void SCH_EDIT_FRAME::RotateField( SCH_FIELD* aField )
if( aField->GetFlags() == 0 ) if( aField->GetFlags() == 0 )
SaveCopyInUndoList( component, UR_CHANGED ); SaveCopyInUndoList( component, UR_CHANGED );
if( aField->GetOrientation() == TEXT_ORIENT_HORIZ ) if( aField->GetTextAngle() == TEXT_ANGLE_HORIZ )
aField->SetOrientation( TEXT_ORIENT_VERT ); aField->SetTextAngle( TEXT_ANGLE_VERT );
else else
aField->SetOrientation( TEXT_ORIENT_HORIZ ); aField->SetTextAngle( TEXT_ANGLE_HORIZ );
OnModify(); OnModify();
} }

View File

@ -52,13 +52,13 @@ void SCH_EDIT_FRAME::ChangeTextOrient( SCH_TEXT* aTextItem )
wxCHECK_RET( (aTextItem != NULL) && aTextItem->CanIncrementLabel(), wxCHECK_RET( (aTextItem != NULL) && aTextItem->CanIncrementLabel(),
wxT( "Invalid schematic text item." ) ); wxT( "Invalid schematic text item." ) );
int orient = ( aTextItem->GetOrientation() + 1 ) & 3; int orient = ( aTextItem->GetLabelSpinStyle() + 1 ) & 3;
// Save current text orientation in undo list if is not already in edit. // Save current text orientation in undo list if is not already in edit.
if( aTextItem->GetFlags() == 0 ) if( aTextItem->GetFlags() == 0 )
SaveCopyInUndoList( aTextItem, UR_CHANGED ); SaveCopyInUndoList( aTextItem, UR_CHANGED );
aTextItem->SetOrientation( orient ); aTextItem->SetLabelSpinStyle( orient );
OnModify(); OnModify();
} }
@ -96,8 +96,8 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* aDC, int aType )
textItem->SetBold( lastTextBold ); textItem->SetBold( lastTextBold );
textItem->SetItalic( lastTextItalic ); textItem->SetItalic( lastTextItalic );
textItem->SetOrientation( lastTextOrientation ); textItem->SetLabelSpinStyle( lastTextOrientation );
textItem->SetSize( wxSize( GetDefaultTextSize(), GetDefaultTextSize() ) ); textItem->SetTextSize( wxSize( GetDefaultTextSize(), GetDefaultTextSize() ) );
textItem->SetFlags( IS_NEW | IS_MOVED ); textItem->SetFlags( IS_NEW | IS_MOVED );
EditSchematicText( textItem ); EditSchematicText( textItem );
@ -110,7 +110,7 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* aDC, int aType )
lastTextBold = textItem->IsBold(); lastTextBold = textItem->IsBold();
lastTextItalic = textItem->IsItalic(); lastTextItalic = textItem->IsItalic();
lastTextOrientation = textItem->GetOrientation(); lastTextOrientation = textItem->GetLabelSpinStyle();
if( ( textItem->Type() == SCH_GLOBAL_LABEL_T ) || if( ( textItem->Type() == SCH_GLOBAL_LABEL_T ) ||
( textItem->Type() == SCH_HIERARCHICAL_LABEL_T ) ) ( textItem->Type() == SCH_HIERARCHICAL_LABEL_T ) )
@ -205,8 +205,8 @@ void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent )
*/ */
newtext->SetFlags( text->GetFlags() ); newtext->SetFlags( text->GetFlags() );
newtext->SetShape( text->GetShape() ); newtext->SetShape( text->GetShape() );
newtext->SetOrientation( text->GetOrientation() ); newtext->SetLabelSpinStyle( text->GetLabelSpinStyle() );
newtext->SetSize( text->GetSize() ); newtext->SetTextSize( text->GetTextSize() );
newtext->SetThickness( text->GetThickness() ); newtext->SetThickness( text->GetThickness() );
newtext->SetItalic( text->IsItalic() ); newtext->SetItalic( text->IsItalic() );
newtext->SetBold( text->IsBold() ); newtext->SetBold( text->IsBold() );

View File

@ -53,7 +53,8 @@ LIB_FIELD::LIB_FIELD(LIB_PART * aParent, int idfield ) :
} }
LIB_FIELD::LIB_FIELD( int idfield ) : LIB_ITEM( LIB_FIELD_T, NULL ) LIB_FIELD::LIB_FIELD( int idfield ) :
LIB_ITEM( LIB_FIELD_T, NULL )
{ {
Init( idfield ); Init( idfield );
} }
@ -64,13 +65,28 @@ LIB_FIELD::~LIB_FIELD()
} }
void LIB_FIELD::operator=( const LIB_FIELD& field )
{
m_id = field.m_id;
m_Text = field.m_Text;
m_name = field.m_name;
m_Parent = field.m_Parent;
SetEffects( field );
}
void LIB_FIELD::Init( int id ) void LIB_FIELD::Init( int id )
{ {
m_id = id; m_id = id;
m_Size.x = GetDefaultTextSize();
m_Size.y = GetDefaultTextSize(); SetTextWidth( GetDefaultTextSize() );
SetTextHeight( GetDefaultTextSize() );
m_typeName = _( "Field" ); m_typeName = _( "Field" );
m_Orient = TEXT_ORIENT_HORIZ;
SetTextAngle( TEXT_ANGLE_HORIZ ); // constructor already did this.
m_rotate = false; m_rotate = false;
m_updateText = false; m_updateText = false;
@ -99,27 +115,27 @@ bool LIB_FIELD::Save( OUTPUTFORMATTER& aFormatter )
hjustify = 'C'; hjustify = 'C';
if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT ) if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
hjustify = 'L'; hjustify = 'L';
else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT ) else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
hjustify = 'R'; hjustify = 'R';
vjustify = 'C'; vjustify = 'C';
if( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM ) if( GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
vjustify = 'B'; vjustify = 'B';
else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP ) else if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
vjustify = 'T'; vjustify = 'T';
aFormatter.Print( 0, "F%d %s %d %d %d %c %c %c %c%c%c", aFormatter.Print( 0, "F%d %s %d %d %d %c %c %c %c%c%c",
m_id, m_id,
EscapedUTF8( text ).c_str(), // wraps in quotes EscapedUTF8( text ).c_str(), // wraps in quotes
m_Pos.x, m_Pos.y, m_Size.x, GetTextPos().x, GetTextPos().y, GetTextWidth(),
m_Orient == 0 ? 'H' : 'V', GetTextAngle() == 0 ? 'H' : 'V',
(m_Attributs & TEXT_NO_VISIBLE ) ? 'I' : 'V', IsVisible() ? 'V' : 'I',
hjustify, vjustify, hjustify, vjustify,
m_Italic ? 'I' : 'N', IsItalic() ? 'I' : 'N',
m_Bold ? 'B' : 'N' ); IsBold() ? 'B' : 'N' );
/* Save field name, if necessary /* Save field name, if necessary
* Field name is saved only if it is not the default name. * Field name is saved only if it is not the default name.
@ -140,6 +156,7 @@ bool LIB_FIELD::Save( OUTPUTFORMATTER& aFormatter )
bool LIB_FIELD::Load( LINE_READER& aLineReader, wxString& errorMsg ) bool LIB_FIELD::Load( LINE_READER& aLineReader, wxString& errorMsg )
{ {
int cnt; int cnt;
int x, y, size;
char textOrient; char textOrient;
char textVisible; char textVisible;
char textHJustify; char textHJustify;
@ -171,7 +188,7 @@ bool LIB_FIELD::Load( LINE_READER& aLineReader, wxString& errorMsg )
memset( textVJustify, 0, sizeof( textVJustify ) ); memset( textVJustify, 0, sizeof( textVJustify ) );
cnt = sscanf( line, " %d %d %d %c %c %c %255s", &m_Pos.x, &m_Pos.y, &m_Size.y, cnt = sscanf( line, " %d %d %d %c %c %c %255s", &x, &y, &size,
&textOrient, &textVisible, &textHJustify, textVJustify ); &textOrient, &textVisible, &textHJustify, textVJustify );
if( cnt < 5 ) if( cnt < 5 )
@ -181,12 +198,13 @@ bool LIB_FIELD::Load( LINE_READER& aLineReader, wxString& errorMsg )
return false; return false;
} }
m_Size.x = m_Size.y; SetTextPos( wxPoint( x, y ) );
SetTextSize( wxSize( size, size ) );
if( textOrient == 'H' ) if( textOrient == 'H' )
m_Orient = TEXT_ORIENT_HORIZ; SetTextAngle( TEXT_ANGLE_HORIZ );
else if( textOrient == 'V' ) else if( textOrient == 'V' )
m_Orient = TEXT_ORIENT_VERT; SetTextAngle( TEXT_ANGLE_VERT );
else else
{ {
errorMsg.Printf( wxT( "field %d text orientation parameter <%c> is not valid" ), errorMsg.Printf( wxT( "field %d text orientation parameter <%c> is not valid" ),
@ -195,9 +213,9 @@ bool LIB_FIELD::Load( LINE_READER& aLineReader, wxString& errorMsg )
} }
if( textVisible == 'V' ) if( textVisible == 'V' )
m_Attributs &= ~TEXT_NO_VISIBLE; SetVisible( true );
else if ( textVisible == 'I' ) else if( textVisible == 'I' )
m_Attributs |= TEXT_NO_VISIBLE; SetVisible( false );
else else
{ {
errorMsg.Printf( wxT( "field %d text visible parameter <%c> is not valid" ), errorMsg.Printf( wxT( "field %d text visible parameter <%c> is not valid" ),
@ -205,17 +223,17 @@ bool LIB_FIELD::Load( LINE_READER& aLineReader, wxString& errorMsg )
return false; return false;
} }
m_HJustify = GR_TEXT_HJUSTIFY_CENTER; SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
m_VJustify = GR_TEXT_VJUSTIFY_CENTER; SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
if( cnt >= 6 ) if( cnt >= 6 )
{ {
if( textHJustify == 'C' ) if( textHJustify == 'C' )
m_HJustify = GR_TEXT_HJUSTIFY_CENTER; SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
else if( textHJustify == 'L' ) else if( textHJustify == 'L' )
m_HJustify = GR_TEXT_HJUSTIFY_LEFT; SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
else if( textHJustify == 'R' ) else if( textHJustify == 'R' )
m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
else else
{ {
errorMsg.Printf( errorMsg.Printf(
@ -225,11 +243,11 @@ bool LIB_FIELD::Load( LINE_READER& aLineReader, wxString& errorMsg )
} }
if( textVJustify[0] == 'C' ) if( textVJustify[0] == 'C' )
m_VJustify = GR_TEXT_VJUSTIFY_CENTER; SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
else if( textVJustify[0] == 'B' ) else if( textVJustify[0] == 'B' )
m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM; SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
else if( textVJustify[0] == 'T' ) else if( textVJustify[0] == 'T' )
m_VJustify = GR_TEXT_VJUSTIFY_TOP; SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
else else
{ {
errorMsg.Printf( errorMsg.Printf(
@ -238,10 +256,10 @@ bool LIB_FIELD::Load( LINE_READER& aLineReader, wxString& errorMsg )
return false; return false;
} }
if ( textVJustify[1] == 'I' ) // Italic if( textVJustify[1] == 'I' ) // Italic
m_Italic = true; SetItalic( true );
if ( textVJustify[2] == 'B' ) // Bold if( textVJustify[2] == 'B' ) // Bold
m_Bold = true; SetBold( true );
} }
// fields in RAM must always have names. // fields in RAM must always have names.
@ -263,7 +281,7 @@ bool LIB_FIELD::Load( LINE_READER& aLineReader, wxString& errorMsg )
int LIB_FIELD::GetPenSize() const int LIB_FIELD::GetPenSize() const
{ {
return ( m_Thickness == 0 ) ? GetDefaultLineThickness() : m_Thickness; return GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
} }
@ -275,16 +293,16 @@ void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a
int color; int color;
int linewidth = GetPenSize(); int linewidth = GetPenSize();
if( m_Bold ) if( IsBold() )
linewidth = GetPenSizeForBold( m_Size.x ); linewidth = GetPenSizeForBold( GetTextWidth() );
else else
linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
if( ( m_Attributs & TEXT_NO_VISIBLE ) && ( aColor < 0 ) ) if( !IsVisible() && aColor < 0 )
{ {
color = GetInvisibleItemColor(); color = GetInvisibleItemColor();
} }
else if( IsSelected() && ( aColor < 0 ) ) else if( IsSelected() && aColor < 0 )
{ {
color = GetItemSelectedColor(); color = GetItemSelectedColor();
} }
@ -296,7 +314,7 @@ void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a
if( color < 0 ) if( color < 0 )
color = GetDefaultColor(); color = GetDefaultColor();
text_pos = aTransform.TransformCoordinate( m_Pos ) + aOffset; text_pos = aTransform.TransformCoordinate( GetTextPos() ) + aOffset;
wxString text; wxString text;
@ -307,8 +325,10 @@ void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a
GRSetDrawMode( aDC, aDrawMode ); GRSetDrawMode( aDC, aDrawMode );
EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL; EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL;
DrawGraphicText( clipbox, aDC, text_pos, (EDA_COLOR_T) color, text, m_Orient, m_Size, DrawGraphicText( clipbox, aDC, text_pos, (EDA_COLOR_T) color, text,
m_HJustify, m_VJustify, linewidth, m_Italic, m_Bold ); GetTextAngle(), GetTextSize(),
GetHorizJustify(), GetVertJustify(),
linewidth, IsItalic(), IsBold() );
/* Set to one (1) to draw bounding box around field text to validate /* Set to one (1) to draw bounding box around field text to validate
* bounding box calculation. */ * bounding box calculation. */
@ -347,21 +367,21 @@ bool LIB_FIELD::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFO
{ {
wxString extended_text = tmp_text.GetText(); wxString extended_text = tmp_text.GetText();
extended_text.Append('?'); extended_text.Append('?');
const LIB_PART* parent = static_cast<const LIB_PART* >( m_Parent ); const LIB_PART* parent = static_cast<const LIB_PART*>( m_Parent );
if ( parent && ( parent->GetUnitCount() > 1 ) ) if ( parent && ( parent->GetUnitCount() > 1 ) )
extended_text.Append('A'); extended_text.Append('A');
tmp_text.SetText( extended_text ); tmp_text.SetText( extended_text );
} }
tmp_text.SetTextPosition( aTransform.TransformCoordinate( m_Pos ) ); tmp_text.SetTextPos( aTransform.TransformCoordinate( GetTextPos() ) );
/* The text orientation may need to be flipped if the /* The text orientation may need to be flipped if the
* transformation matrix causes xy axes to be flipped. * transformation matrix causes xy axes to be flipped.
* this simple algo works only for schematic matrix (rot 90 or/and mirror) * this simple algo works only for schematic matrix (rot 90 or/and mirror)
*/ */
int t1 = ( aTransform.x1 != 0 ) ^ ( m_Orient != 0 ); bool t1 = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 );
tmp_text.SetOrientation( t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT ); tmp_text.SetTextAngle( t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT );
return tmp_text.TextHitTest( aPosition ); return tmp_text.TextHitTest( aPosition );
} }
@ -379,18 +399,11 @@ EDA_ITEM* LIB_FIELD::Clone() const
void LIB_FIELD::Copy( LIB_FIELD* aTarget ) const void LIB_FIELD::Copy( LIB_FIELD* aTarget ) const
{ {
aTarget->m_Text = m_Text;
aTarget->m_name = m_name;
aTarget->SetEffects( *this );
aTarget->SetParent( m_Parent ); aTarget->SetParent( m_Parent );
aTarget->m_Pos = m_Pos;
aTarget->m_Size = m_Size;
aTarget->m_Thickness = m_Thickness;
aTarget->m_Orient = m_Orient;
aTarget->m_Attributs = m_Attributs;
aTarget->m_Text = m_Text;
aTarget->m_name = m_name;
aTarget->m_HJustify = m_HJustify;
aTarget->m_VJustify = m_VJustify;
aTarget->m_Italic = m_Italic;
aTarget->m_Bold = m_Bold;
} }
@ -408,17 +421,17 @@ int LIB_FIELD::compare( const LIB_ITEM& other ) const
if( result != 0 ) if( result != 0 )
return result; return result;
if( m_Pos.x != tmp->m_Pos.x ) if( GetTextPos().x != tmp->GetTextPos().x )
return m_Pos.x - tmp->m_Pos.x; return GetTextPos().x - tmp->GetTextPos().x;
if( m_Pos.y != tmp->m_Pos.y ) if( GetTextPos().y != tmp->GetTextPos().y )
return m_Pos.y - tmp->m_Pos.y; return GetTextPos().y - tmp->GetTextPos().y;
if( m_Size.x != tmp->m_Size.x ) if( GetTextWidth() != tmp->GetTextWidth() )
return m_Size.x - tmp->m_Size.x; return GetTextWidth() - tmp->GetTextWidth();
if( m_Size.y != tmp->m_Size.y ) if( GetTextHeight() != tmp->GetTextHeight() )
return m_Size.y - tmp->m_Size.y; return GetTextHeight() - tmp->GetTextHeight();
return 0; return 0;
} }
@ -426,7 +439,7 @@ int LIB_FIELD::compare( const LIB_ITEM& other ) const
void LIB_FIELD::SetOffset( const wxPoint& aOffset ) void LIB_FIELD::SetOffset( const wxPoint& aOffset )
{ {
m_Pos += aOffset; EDA_TEXT::Offset( aOffset );
} }
@ -436,35 +449,49 @@ bool LIB_FIELD::Inside( EDA_RECT& rect ) const
* FIXME: This fails to take into account the size and/or orientation of * FIXME: This fails to take into account the size and/or orientation of
* the text. * the text.
*/ */
return rect.Contains( m_Pos.x, -m_Pos.y ); return rect.Contains( GetTextPos().x, -GetTextPos().y );
} }
void LIB_FIELD::Move( const wxPoint& newPosition ) void LIB_FIELD::Move( const wxPoint& newPosition )
{ {
m_Pos = newPosition; EDA_TEXT::SetTextPos( newPosition );
} }
void LIB_FIELD::MirrorHorizontal( const wxPoint& center ) void LIB_FIELD::MirrorHorizontal( const wxPoint& center )
{ {
m_Pos.x -= center.x; int x = GetTextPos().x;
m_Pos.x *= -1;
m_Pos.x += center.x; x -= center.x;
x *= -1;
x += center.x;
SetTextX( x );
} }
void LIB_FIELD::MirrorVertical( const wxPoint& center ) void LIB_FIELD::MirrorVertical( const wxPoint& center )
{ {
m_Pos.y -= center.y; int y = GetTextPos().y;
m_Pos.y *= -1;
m_Pos.y += center.y; y -= center.y;
y *= -1;
y += center.y;
SetTextY( y );
} }
void LIB_FIELD::Rotate( const wxPoint& center, bool aRotateCCW ) void LIB_FIELD::Rotate( const wxPoint& center, bool aRotateCCW )
{ {
int rot_angle = aRotateCCW ? -900 : 900; int rot_angle = aRotateCCW ? -900 : 900;
RotatePoint( &m_Pos, center, rot_angle );
m_Orient = m_Orient ? 0 : 900; wxPoint pt = GetTextPos();
RotatePoint( &pt, center, rot_angle );
SetTextPos( pt );
SetTextAngle( GetTextAngle() != 0.0 ? 0 : 900 );
} }
@ -476,14 +503,14 @@ void LIB_FIELD::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
/* Calculate the text orientation, according to the component /* Calculate the text orientation, according to the component
* orientation/mirror */ * orientation/mirror */
int orient = m_Orient; int orient = GetTextAngle();
if( aTransform.y1 ) // Rotate component 90 deg. if( aTransform.y1 ) // Rotate component 90 deg.
{ {
if( orient == TEXT_ORIENT_HORIZ ) if( orient == TEXT_ANGLE_HORIZ )
orient = TEXT_ORIENT_VERT; orient = TEXT_ANGLE_VERT;
else else
orient = TEXT_ORIENT_HORIZ; orient = TEXT_ANGLE_HORIZ;
} }
EDA_RECT BoundaryBox = GetBoundingBox(); EDA_RECT BoundaryBox = GetBoundingBox();
@ -494,9 +521,10 @@ void LIB_FIELD::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
wxPoint textpos = aTransform.TransformCoordinate( BoundaryBox.Centre() ) wxPoint textpos = aTransform.TransformCoordinate( BoundaryBox.Centre() )
+ aOffset; + aOffset;
aPlotter->Text( textpos, GetDefaultColor(), GetShownText(), orient, m_Size, aPlotter->Text( textpos, GetDefaultColor(), GetShownText(),
orient, GetTextSize(),
hjustify, vjustify, hjustify, vjustify,
GetPenSize(), m_Italic, m_Bold ); GetPenSize(), IsItalic(), IsBold() );
} }
@ -526,8 +554,10 @@ const EDA_RECT LIB_FIELD::GetBoundingBox() const
// We are using now a bottom to top Y axis. // We are using now a bottom to top Y axis.
wxPoint orig = rect.GetOrigin(); wxPoint orig = rect.GetOrigin();
wxPoint end = rect.GetEnd(); wxPoint end = rect.GetEnd();
RotatePoint( &orig, m_Pos, -m_Orient );
RotatePoint( &end, m_Pos, -m_Orient ); RotatePoint( &orig, GetTextPos(), -GetTextAngle() );
RotatePoint( &end, GetTextPos(), -GetTextAngle() );
rect.SetOrigin( orig ); rect.SetOrigin( orig );
rect.SetEnd( end ); rect.SetEnd( end );
@ -569,7 +599,7 @@ void LIB_FIELD::Rotate()
} }
else else
{ {
m_Orient = ( m_Orient == TEXT_ORIENT_VERT ) ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT; SetTextAngle( GetTextAngle() == TEXT_ANGLE_VERT ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT );
} }
} }
@ -688,13 +718,13 @@ void LIB_FIELD::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
if( aEditMode == IS_MOVED ) if( aEditMode == IS_MOVED )
{ {
m_initialPos = m_Pos; m_initialPos = GetTextPos();
m_initialCursorPos = aPosition; m_initialCursorPos = aPosition;
SetEraseLastDrawItem(); SetEraseLastDrawItem();
} }
else else
{ {
m_Pos = aPosition; SetTextPos( aPosition );
} }
m_Flags = aEditMode; m_Flags = aEditMode;
@ -726,7 +756,7 @@ void LIB_FIELD::calcEdit( const wxPoint& aPosition )
{ {
if( m_rotate ) if( m_rotate )
{ {
m_Orient = ( m_Orient == TEXT_ORIENT_VERT ) ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT; SetTextAngle( GetTextAngle() == TEXT_ANGLE_VERT ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT );
m_rotate = false; m_rotate = false;
} }
@ -738,7 +768,7 @@ void LIB_FIELD::calcEdit( const wxPoint& aPosition )
if( m_Flags == IS_NEW ) if( m_Flags == IS_NEW )
{ {
m_Pos = aPosition; SetTextPos( aPosition );
} }
else if( m_Flags == IS_MOVED ) else if( m_Flags == IS_MOVED )
{ {
@ -746,6 +776,7 @@ void LIB_FIELD::calcEdit( const wxPoint& aPosition )
} }
} }
void LIB_FIELD::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) void LIB_FIELD::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
{ {
wxString msg; wxString msg;
@ -756,10 +787,10 @@ void LIB_FIELD::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
msg = GetTextStyleName(); msg = GetTextStyleName();
aList.push_back( MSG_PANEL_ITEM( _( "Style" ), msg, MAGENTA ) ); aList.push_back( MSG_PANEL_ITEM( _( "Style" ), msg, MAGENTA ) );
msg = StringFromValue( g_UserUnit, m_Size.x, true ); msg = StringFromValue( g_UserUnit, GetTextWidth(), true );
aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, BLUE ) ); aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, BLUE ) );
msg = StringFromValue( g_UserUnit, m_Size.y, true ); msg = StringFromValue( g_UserUnit, GetTextHeight(), true );
aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, BLUE ) ); aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, BLUE ) );
// Display field name (ref, value ...) // Display field name (ref, value ...)

View File

@ -165,10 +165,7 @@ public:
* Function IsVisible * Function IsVisible
* @return true is this field is visible, false if flagged invisible * @return true is this field is visible, false if flagged invisible
*/ */
bool IsVisible() bool IsVisible() const { return EDA_TEXT::IsVisible(); } // why needed?
{
return (m_Attributs & TEXT_NO_VISIBLE) == 0 ? true : false;
}
const EDA_RECT GetBoundingBox() const override; const EDA_RECT GetBoundingBox() const override;
@ -178,23 +175,7 @@ public:
bool HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const override; bool HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const override;
void operator=( const LIB_FIELD& field ) void operator=( const LIB_FIELD& field );
{
m_id = field.m_id;
m_Text = field.m_Text;
m_name = field.m_name;
m_Pos = field.m_Pos;
m_Size = field.m_Size;
m_Thickness = field.m_Thickness;
m_Orient = field.m_Orient;
m_Mirror = field.m_Mirror;
m_Attributs = field.m_Attributs;
m_Italic = field.m_Italic;
m_Bold = field.m_Bold;
m_HJustify = field.m_HJustify;
m_VJustify = field.m_VJustify;
m_Parent = field.m_Parent;
}
/** /**
* Return the text of a field. * Return the text of a field.
@ -239,7 +220,7 @@ public:
void Move( const wxPoint& aPosition ) override; void Move( const wxPoint& aPosition ) override;
wxPoint GetPosition() const override { return m_Pos; } wxPoint GetPosition() const override { return EDA_TEXT::GetTextPos(); }
void MirrorHorizontal( const wxPoint& aCenter ) override; void MirrorHorizontal( const wxPoint& aCenter ) override;
@ -250,9 +231,9 @@ public:
void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform ) override; const TRANSFORM& aTransform ) override;
int GetWidth() const override { return m_Thickness; } int GetWidth() const override { return GetThickness(); }
void SetWidth( int aWidth ) override { m_Thickness = aWidth; } void SetWidth( int aWidth ) override { SetThickness( aWidth ); }
wxString GetSelectMenuText() const override; wxString GetSelectMenuText() const override;

View File

@ -700,7 +700,7 @@ bool LIB_PIN::Load( LINE_READER& aLineReader, wxString& aErrorMsg )
// the full line starts by "X ". The pin data starts at line + 2. // the full line starts by "X ". The pin data starts at line + 2.
wxString utf8line = FROM_UTF8( aLineReader.Line() + 2 ); wxString utf8line = FROM_UTF8( aLineReader.Line() + 2 );
wxStringTokenizer tokenizer( utf8line, wxT(" \n\r" ) ); wxStringTokenizer tokenizer( utf8line, wxT(" \n\r" ) );
int prms_count = tokenizer.CountTokens(); int prms_count = tokenizer.CountTokens();
if( prms_count < 11 ) if( prms_count < 11 )
@ -1258,7 +1258,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
x = x1 + TextInside; x = x1 + TextInside;
DrawGraphicText( clipbox, DC, wxPoint( x, y1 ), NameColor, DrawGraphicText( clipbox, DC, wxPoint( x, y1 ), NameColor,
m_name, m_name,
TEXT_ORIENT_HORIZ, TEXT_ANGLE_HORIZ,
PinNameSize, PinNameSize,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_LEFT,
GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, GR_TEXT_VJUSTIFY_CENTER, nameLineWidth,
@ -1269,7 +1269,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
x = x1 - TextInside; x = x1 - TextInside;
DrawGraphicText( clipbox, DC, wxPoint( x, y1 ), NameColor, DrawGraphicText( clipbox, DC, wxPoint( x, y1 ), NameColor,
m_name, m_name,
TEXT_ORIENT_HORIZ, TEXT_ANGLE_HORIZ,
PinNameSize, PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_HJUSTIFY_RIGHT,
GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, GR_TEXT_VJUSTIFY_CENTER, nameLineWidth,
@ -1283,7 +1283,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
wxPoint( (x1 + pin_pos.x) / 2, wxPoint( (x1 + pin_pos.x) / 2,
y1 - num_offset ), NumColor, y1 - num_offset ), NumColor,
StringPinNum, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize, TEXT_ANGLE_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth, GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth,
false, false ); false, false );
@ -1299,7 +1299,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
if( DrawPinName ) if( DrawPinName )
DrawGraphicText( clipbox, DC, wxPoint( x1, y ), NameColor, DrawGraphicText( clipbox, DC, wxPoint( x1, y ), NameColor,
m_name, m_name,
TEXT_ORIENT_VERT, PinNameSize, TEXT_ANGLE_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_HJUSTIFY_RIGHT,
GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, GR_TEXT_VJUSTIFY_CENTER, nameLineWidth,
false, false ); false, false );
@ -1309,7 +1309,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
wxPoint( x1 - num_offset, wxPoint( x1 - num_offset,
(y1 + pin_pos.y) / 2 ), NumColor, (y1 + pin_pos.y) / 2 ), NumColor,
StringPinNum, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize, TEXT_ANGLE_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth, GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth,
false, false ); false, false );
@ -1321,7 +1321,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
if( DrawPinName ) if( DrawPinName )
DrawGraphicText( clipbox, DC, wxPoint( x1, y ), NameColor, DrawGraphicText( clipbox, DC, wxPoint( x1, y ), NameColor,
m_name, m_name,
TEXT_ORIENT_VERT, PinNameSize, TEXT_ANGLE_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_LEFT,
GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, GR_TEXT_VJUSTIFY_CENTER, nameLineWidth,
false, false ); false, false );
@ -1331,7 +1331,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
wxPoint( x1 - num_offset, wxPoint( x1 - num_offset,
(y1 + pin_pos.y) / 2 ), NumColor, (y1 + pin_pos.y) / 2 ), NumColor,
StringPinNum, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize, TEXT_ANGLE_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth, GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth,
false, false ); false, false );
@ -1348,7 +1348,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
x = (x1 + pin_pos.x) / 2; x = (x1 + pin_pos.x) / 2;
DrawGraphicText( clipbox, DC, wxPoint( x, y1 - name_offset ), DrawGraphicText( clipbox, DC, wxPoint( x, y1 - name_offset ),
NameColor, m_name, NameColor, m_name,
TEXT_ORIENT_HORIZ, PinNameSize, TEXT_ANGLE_HORIZ, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, nameLineWidth, GR_TEXT_VJUSTIFY_BOTTOM, nameLineWidth,
false, false ); false, false );
@ -1358,7 +1358,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
x = (x1 + pin_pos.x) / 2; x = (x1 + pin_pos.x) / 2;
DrawGraphicText( clipbox, DC, wxPoint( x, y1 + num_offset ), DrawGraphicText( clipbox, DC, wxPoint( x, y1 + num_offset ),
NumColor, StringPinNum, NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize, TEXT_ANGLE_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_TOP, numLineWidth, GR_TEXT_VJUSTIFY_TOP, numLineWidth,
false, false ); false, false );
@ -1371,7 +1371,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
y = (y1 + pin_pos.y) / 2; y = (y1 + pin_pos.y) / 2;
DrawGraphicText( clipbox, DC, wxPoint( x1 - name_offset, y ), DrawGraphicText( clipbox, DC, wxPoint( x1 - name_offset, y ),
NameColor, m_name, NameColor, m_name,
TEXT_ORIENT_VERT, PinNameSize, TEXT_ANGLE_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, nameLineWidth, GR_TEXT_VJUSTIFY_BOTTOM, nameLineWidth,
false, false ); false, false );
@ -1383,7 +1383,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
wxPoint( x1 + num_offset, (y1 + pin_pos.y) wxPoint( x1 + num_offset, (y1 + pin_pos.y)
/ 2 ), / 2 ),
NumColor, StringPinNum, NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize, TEXT_ANGLE_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_TOP, numLineWidth, GR_TEXT_VJUSTIFY_TOP, numLineWidth,
false, false ); false, false );
@ -1421,19 +1421,19 @@ void LIB_PIN::DrawPinElectricalTypeName( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
wxPoint txtpos = aPosition; wxPoint txtpos = aPosition;
int offset = Millimeter2iu( 0.4 ); int offset = Millimeter2iu( 0.4 );
EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_LEFT; EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_LEFT;
int orient = TEXT_ORIENT_HORIZ; int orient = TEXT_ANGLE_HORIZ;
switch( aOrientation ) switch( aOrientation )
{ {
case PIN_UP: case PIN_UP:
txtpos.y += offset; txtpos.y += offset;
orient = TEXT_ORIENT_VERT; orient = TEXT_ANGLE_VERT;
hjustify = GR_TEXT_HJUSTIFY_RIGHT; hjustify = GR_TEXT_HJUSTIFY_RIGHT;
break; break;
case PIN_DOWN: case PIN_DOWN:
txtpos.y -= offset; txtpos.y -= offset;
orient = TEXT_ORIENT_VERT; orient = TEXT_ANGLE_VERT;
break; break;
case PIN_LEFT: case PIN_LEFT:
@ -1676,7 +1676,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
x = x1 + TextInside; x = x1 + TextInside;
plotter->Text( wxPoint( x, y1 ), NameColor, plotter->Text( wxPoint( x, y1 ), NameColor,
m_name, m_name,
TEXT_ORIENT_HORIZ, TEXT_ANGLE_HORIZ,
PinNameSize, PinNameSize,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_LEFT,
GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
@ -1688,7 +1688,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
if( DrawPinName ) if( DrawPinName )
plotter->Text( wxPoint( x, y1 ), plotter->Text( wxPoint( x, y1 ),
NameColor, m_name, TEXT_ORIENT_HORIZ, NameColor, m_name, TEXT_ANGLE_HORIZ,
PinNameSize, PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_HJUSTIFY_RIGHT,
GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
@ -1700,7 +1700,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
plotter->Text( wxPoint( (x1 + pin_pos.x) / 2, plotter->Text( wxPoint( (x1 + pin_pos.x) / 2,
y1 - num_offset ), y1 - num_offset ),
NumColor, StringPinNum, NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize, TEXT_ANGLE_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_BOTTOM,
aWidth, false, false ); aWidth, false, false );
@ -1715,7 +1715,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
if( DrawPinName ) if( DrawPinName )
plotter->Text( wxPoint( x1, y ), NameColor, plotter->Text( wxPoint( x1, y ), NameColor,
m_name, m_name,
TEXT_ORIENT_VERT, PinNameSize, TEXT_ANGLE_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_HJUSTIFY_RIGHT,
GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
aWidth, false, false ); aWidth, false, false );
@ -1725,7 +1725,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
plotter->Text( wxPoint( x1 - num_offset, plotter->Text( wxPoint( x1 - num_offset,
(y1 + pin_pos.y) / 2 ), (y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum, NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize, TEXT_ANGLE_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_BOTTOM,
aWidth, false, false ); aWidth, false, false );
@ -1738,7 +1738,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
if( DrawPinName ) if( DrawPinName )
plotter->Text( wxPoint( x1, y ), NameColor, plotter->Text( wxPoint( x1, y ), NameColor,
m_name, m_name,
TEXT_ORIENT_VERT, PinNameSize, TEXT_ANGLE_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_LEFT,
GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
aWidth, false, false ); aWidth, false, false );
@ -1748,7 +1748,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
plotter->Text( wxPoint( x1 - num_offset, plotter->Text( wxPoint( x1 - num_offset,
(y1 + pin_pos.y) / 2 ), (y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum, NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize, TEXT_ANGLE_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_BOTTOM,
aWidth, false, false ); aWidth, false, false );
@ -1766,7 +1766,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
x = (x1 + pin_pos.x) / 2; x = (x1 + pin_pos.x) / 2;
plotter->Text( wxPoint( x, y1 - name_offset ), plotter->Text( wxPoint( x, y1 - name_offset ),
NameColor, m_name, NameColor, m_name,
TEXT_ORIENT_HORIZ, PinNameSize, TEXT_ANGLE_HORIZ, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_BOTTOM,
aWidth, false, false ); aWidth, false, false );
@ -1777,7 +1777,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
x = ( x1 + pin_pos.x ) / 2; x = ( x1 + pin_pos.x ) / 2;
plotter->Text( wxPoint( x, y1 + num_offset ), plotter->Text( wxPoint( x, y1 + num_offset ),
NumColor, StringPinNum, NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize, TEXT_ANGLE_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_TOP, GR_TEXT_VJUSTIFY_TOP,
aWidth, false, false ); aWidth, false, false );
@ -1790,7 +1790,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
y = ( y1 + pin_pos.y ) / 2; y = ( y1 + pin_pos.y ) / 2;
plotter->Text( wxPoint( x1 - name_offset, y ), plotter->Text( wxPoint( x1 - name_offset, y ),
NameColor, m_name, NameColor, m_name,
TEXT_ORIENT_VERT, PinNameSize, TEXT_ANGLE_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_BOTTOM,
aWidth, false, false ); aWidth, false, false );
@ -1801,7 +1801,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
plotter->Text( wxPoint( x1 + num_offset, plotter->Text( wxPoint( x1 + num_offset,
( y1 + pin_pos.y ) / 2 ), ( y1 + pin_pos.y ) / 2 ),
NumColor, StringPinNum, NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize, TEXT_ANGLE_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_TOP, GR_TEXT_VJUSTIFY_TOP,
aWidth, false, false ); aWidth, false, false );

View File

@ -47,7 +47,7 @@ LIB_TEXT::LIB_TEXT( LIB_PART * aParent ) :
LIB_ITEM( LIB_TEXT_T, aParent ), LIB_ITEM( LIB_TEXT_T, aParent ),
EDA_TEXT() EDA_TEXT()
{ {
m_Size = wxSize( 50, 50 ); SetTextSize( wxSize( 50, 50 ) );
m_typeName = _( "Text" ); m_typeName = _( "Text" );
m_rotate = false; m_rotate = false;
m_updateText = false; m_updateText = false;
@ -71,23 +71,24 @@ bool LIB_TEXT::Save( OUTPUTFORMATTER& aFormatter )
text.Replace( wxT( " " ), wxT( "~" ) ); text.Replace( wxT( " " ), wxT( "~" ) );
} }
aFormatter.Print( 0, "T %g %d %d %d %d %d %d %s", GetOrientation(), m_Pos.x, m_Pos.y, aFormatter.Print( 0, "T %g %d %d %d %d %d %d %s", GetTextAngle(),
m_Size.x, m_Attributs, m_Unit, m_Convert, TO_UTF8( text ) ); GetTextPos().x, GetTextPos().y,
GetTextWidth(), !IsVisible(), m_Unit, m_Convert, TO_UTF8( text ) );
aFormatter.Print( 0, " %s %d", m_Italic ? "Italic" : "Normal", ( m_Bold > 0 ) ? 1 : 0 ); aFormatter.Print( 0, " %s %d", IsItalic() ? "Italic" : "Normal", IsBold() );
char hjustify = 'C'; char hjustify = 'C';
if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT ) if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
hjustify = 'L'; hjustify = 'L';
else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT ) else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
hjustify = 'R'; hjustify = 'R';
char vjustify = 'C'; char vjustify = 'C';
if( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM ) if( GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
vjustify = 'B'; vjustify = 'B';
else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP ) else if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
vjustify = 'T'; vjustify = 'T';
aFormatter.Print( 0, " %c %c\n", hjustify, vjustify ); aFormatter.Print( 0, " %c %c\n", hjustify, vjustify );
@ -104,15 +105,19 @@ bool LIB_TEXT::Load( LINE_READER& aLineReader, wxString& errorMsg )
char tmp[256]; char tmp[256];
char* line = (char*) aLineReader; char* line = (char*) aLineReader;
double angle; double angle;
int not_visible;
int x, y, size;
buf[0] = 0; buf[0] = 0;
tmp[0] = 0; // For italic option, Not in old versions tmp[0] = 0; // For italic option, Not in old versions
cnt = sscanf( line + 2, "%lf %d %d %d %d %d %d \"%[^\"]\" %255s %d %c %c", cnt = sscanf( line + 2, "%lf %d %d %d %d %d %d \"%[^\"]\" %255s %d %c %c",
&angle, &m_Pos.x, &m_Pos.y, &m_Size.x, &m_Attributs, &angle, &x, &y, &size, &not_visible,
&m_Unit, &m_Convert, buf, tmp, &thickness, &hjustify, &m_Unit, &m_Convert, buf, tmp, &thickness, &hjustify,
&vjustify ); &vjustify );
SetVisible( !not_visible );
if( cnt >= 8 ) // if quoted loading failed, load as not quoted if( cnt >= 8 ) // if quoted loading failed, load as not quoted
{ {
m_Text = FROM_UTF8( buf ); m_Text = FROM_UTF8( buf );
@ -123,7 +128,7 @@ bool LIB_TEXT::Load( LINE_READER& aLineReader, wxString& errorMsg )
else else
{ {
cnt = sscanf( line + 2, "%lf %d %d %d %d %d %d %255s %255s %d %c %c", cnt = sscanf( line + 2, "%lf %d %d %d %d %d %d %255s %255s %d %c %c",
&angle, &m_Pos.x, &m_Pos.y, &m_Size.x, &m_Attributs, &angle, &x, &y, &size, &not_visible,
&m_Unit, &m_Convert, buf, tmp, &thickness, &hjustify, &m_Unit, &m_Convert, buf, tmp, &thickness, &hjustify,
&vjustify ); &vjustify );
@ -133,54 +138,56 @@ bool LIB_TEXT::Load( LINE_READER& aLineReader, wxString& errorMsg )
return false; return false;
} }
SetVisible( !not_visible );
/* Convert '~' to spaces (only if text is not quoted). */ /* Convert '~' to spaces (only if text is not quoted). */
m_Text = FROM_UTF8( buf ); m_Text = FROM_UTF8( buf );
m_Text.Replace( wxT( "~" ), wxT( " " ) ); m_Text.Replace( wxT( "~" ), wxT( " " ) );
} }
SetOrientation( angle ); SetTextAngle( angle );
m_Size.y = m_Size.x; SetTextSize( wxSize( size, size ) );
SetTextPos( wxPoint( x, y ) );
if( strncasecmp( tmp, "Italic", 6 ) == 0 ) if( strncasecmp( tmp, "Italic", 6 ) == 0 )
m_Italic = true; SetItalic( true );
if( thickness > 0 ) if( thickness > 0 )
{ {
m_Bold = true; SetBold( true );
} }
switch( hjustify ) switch( hjustify )
{ {
case 'L': case 'L':
m_HJustify = GR_TEXT_HJUSTIFY_LEFT; SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
break; break;
case 'C': case 'C':
m_HJustify = GR_TEXT_HJUSTIFY_CENTER; SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
break; break;
case 'R': case 'R':
m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
break; break;
} }
switch( vjustify ) switch( vjustify )
{ {
case 'T': case 'T':
m_VJustify = GR_TEXT_VJUSTIFY_TOP; SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
break; break;
case 'C': case 'C':
m_VJustify = GR_TEXT_VJUSTIFY_CENTER; SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
break; break;
case 'B': case 'B':
m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM; SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
break; break;
} }
return true; return true;
} }
@ -197,14 +204,15 @@ bool LIB_TEXT::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFOR
aThreshold = 0; aThreshold = 0;
EDA_TEXT tmp_text( *this ); EDA_TEXT tmp_text( *this );
tmp_text.SetTextPosition( aTransform.TransformCoordinate( m_Pos ) ); tmp_text.SetTextPos( aTransform.TransformCoordinate( GetTextPos() ) );
/* The text orientation may need to be flipped if the /* The text orientation may need to be flipped if the
* transformation matrix causes xy axes to be flipped. * transformation matrix causes xy axes to be flipped.
* this simple algo works only for schematic matrix (rot 90 or/and mirror) * this simple algo works only for schematic matrix (rot 90 or/and mirror)
*/ */
int t1 = ( aTransform.x1 != 0 ) ^ ( m_Orient != 0 ); bool t1 = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 );
tmp_text.SetOrientation( t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT );
tmp_text.SetTextAngle( t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT );
return tmp_text.TextHitTest( aPosition ); return tmp_text.TextHitTest( aPosition );
} }
@ -213,19 +221,13 @@ EDA_ITEM* LIB_TEXT::Clone() const
{ {
LIB_TEXT* newitem = new LIB_TEXT(NULL); LIB_TEXT* newitem = new LIB_TEXT(NULL);
newitem->m_Pos = m_Pos;
newitem->m_Orient = m_Orient;
newitem->m_Size = m_Size;
newitem->m_Attributs = m_Attributs;
newitem->m_Unit = m_Unit; newitem->m_Unit = m_Unit;
newitem->m_Convert = m_Convert; newitem->m_Convert = m_Convert;
newitem->m_Flags = m_Flags; newitem->m_Flags = m_Flags;
newitem->m_Text = m_Text; newitem->m_Text = m_Text;
newitem->m_Thickness = m_Thickness;
newitem->m_Italic = m_Italic; newitem->SetEffects( *this );
newitem->m_Bold = m_Bold;
newitem->m_HJustify = m_HJustify;
newitem->m_VJustify = m_VJustify;
return newitem; return newitem;
} }
@ -241,17 +243,17 @@ int LIB_TEXT::compare( const LIB_ITEM& other ) const
if( result != 0 ) if( result != 0 )
return result; return result;
if( m_Pos.x != tmp->m_Pos.x ) if( GetTextPos().x != tmp->GetTextPos().x )
return m_Pos.x - tmp->m_Pos.x; return GetTextPos().x - tmp->GetTextPos().x;
if( m_Pos.y != tmp->m_Pos.y ) if( GetTextPos().y != tmp->GetTextPos().y )
return m_Pos.y - tmp->m_Pos.y; return GetTextPos().y - tmp->GetTextPos().y;
if( m_Size.x != tmp->m_Size.x ) if( GetTextWidth() != tmp->GetTextWidth() )
return m_Size.x - tmp->m_Size.x; return GetTextWidth() - tmp->GetTextWidth();
if( m_Size.y != tmp->m_Size.y ) if( GetTextHeight() != tmp->GetTextHeight() )
return m_Size.y - tmp->m_Size.y; return GetTextHeight() - tmp->GetTextHeight();
return 0; return 0;
} }
@ -259,7 +261,7 @@ int LIB_TEXT::compare( const LIB_ITEM& other ) const
void LIB_TEXT::SetOffset( const wxPoint& aOffset ) void LIB_TEXT::SetOffset( const wxPoint& aOffset )
{ {
m_Pos += aOffset; EDA_TEXT::Offset( aOffset );
} }
@ -269,36 +271,49 @@ bool LIB_TEXT::Inside( EDA_RECT& rect ) const
* FIXME: This should calculate the text size and justification and * FIXME: This should calculate the text size and justification and
* use rectangle intersect. * use rectangle intersect.
*/ */
return rect.Contains( m_Pos.x, -m_Pos.y ); return rect.Contains( GetTextPos().x, -GetTextPos().y );
} }
void LIB_TEXT::Move( const wxPoint& newPosition ) void LIB_TEXT::Move( const wxPoint& newPosition )
{ {
m_Pos = newPosition; SetTextPos( newPosition );
} }
void LIB_TEXT::MirrorHorizontal( const wxPoint& center ) void LIB_TEXT::MirrorHorizontal( const wxPoint& center )
{ {
m_Pos.x -= center.x; int x = GetTextPos().x;
m_Pos.x *= -1;
m_Pos.x += center.x; x -= center.x;
x *= -1;
x += center.x;
SetTextX( x );
} }
void LIB_TEXT::MirrorVertical( const wxPoint& center ) void LIB_TEXT::MirrorVertical( const wxPoint& center )
{ {
m_Pos.y -= center.y; int y = GetTextPos().y;
m_Pos.y *= -1;
m_Pos.y += center.y; y -= center.y;
y *= -1;
y += center.y;
SetTextY( y );
} }
void LIB_TEXT::Rotate( const wxPoint& center, bool aRotateCCW ) void LIB_TEXT::Rotate( const wxPoint& center, bool aRotateCCW )
{ {
int rot_angle = aRotateCCW ? -900 : 900; int rot_angle = aRotateCCW ? -900 : 900;
RotatePoint( &m_Pos, center, rot_angle ); wxPoint pt = GetTextPos();
m_Orient = m_Orient ? 0 : 900; RotatePoint( &pt, center, rot_angle );
SetTextPos( pt );
SetTextAngle( GetTextAngle() != 0.0 ? 0 : 900 );
} }
@ -314,7 +329,7 @@ void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill,
/* The text orientation may need to be flipped if the /* The text orientation may need to be flipped if the
* transformation matrix causes xy axes to be flipped. */ * transformation matrix causes xy axes to be flipped. */
int t1 = ( aTransform.x1 != 0 ) ^ ( m_Orient != 0 ); int t1 = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 );
wxPoint pos = aTransform.TransformCoordinate( txtpos ) + offset; wxPoint pos = aTransform.TransformCoordinate( txtpos ) + offset;
// Get color // Get color
@ -326,26 +341,26 @@ void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill,
color = BLACK; color = BLACK;
plotter->Text( pos, color, GetShownText(), plotter->Text( pos, color, GetShownText(),
t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT, t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT,
m_Size, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GetTextSize(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
GetPenSize(), m_Italic, m_Bold ); GetPenSize(), IsItalic(), IsBold() );
} }
int LIB_TEXT::GetPenSize() const int LIB_TEXT::GetPenSize() const
{ {
int pensize = m_Thickness; int pensize = GetThickness();
if( pensize == 0 ) // Use default values for pen size if( pensize == 0 ) // Use default values for pen size
{ {
if( m_Bold ) if( IsBold() )
pensize = GetPenSizeForBold( m_Size.x ); pensize = GetPenSizeForBold( GetTextWidth() );
else else
pensize = GetDefaultLineThickness(); pensize = GetDefaultLineThickness();
} }
// Clip pen size for small texts: // Clip pen size for small texts:
pensize = Clamp_Text_PenSize( pensize, m_Size, m_Bold ); pensize = Clamp_Text_PenSize( pensize, GetTextSize(), IsBold() );
return pensize; return pensize;
} }
@ -371,14 +386,14 @@ void LIB_TEXT::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aO
/* Calculate the text orientation, according to the component /* Calculate the text orientation, according to the component
* orientation/mirror (needed when draw text in schematic) * orientation/mirror (needed when draw text in schematic)
*/ */
int orient = m_Orient; int orient = GetTextAngle();
if( aTransform.y1 ) // Rotate component 90 degrees. if( aTransform.y1 ) // Rotate component 90 degrees.
{ {
if( orient == TEXT_ORIENT_HORIZ ) if( orient == TEXT_ANGLE_HORIZ )
orient = TEXT_ORIENT_VERT; orient = TEXT_ANGLE_VERT;
else else
orient = TEXT_ORIENT_HORIZ; orient = TEXT_ANGLE_HORIZ;
} }
/* Calculate the text justification, according to the component /* Calculate the text justification, according to the component
@ -393,6 +408,7 @@ void LIB_TEXT::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aO
* and use GetBoundaryBox to know the text coordinate considered as centered * and use GetBoundaryBox to know the text coordinate considered as centered
*/ */
EDA_RECT bBox = GetBoundingBox(); EDA_RECT bBox = GetBoundingBox();
// convert coordinates from draw Y axis to libedit Y axis: // convert coordinates from draw Y axis to libedit Y axis:
bBox.RevertYAxis(); bBox.RevertYAxis();
wxPoint txtpos = bBox.Centre(); wxPoint txtpos = bBox.Centre();
@ -401,9 +417,9 @@ void LIB_TEXT::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aO
txtpos = aTransform.TransformCoordinate( txtpos ) + aOffset; txtpos = aTransform.TransformCoordinate( txtpos ) + aOffset;
EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL; EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL;
DrawGraphicText( clipbox, aDC, txtpos, color, GetShownText(), orient, m_Size, DrawGraphicText( clipbox, aDC, txtpos, color, GetShownText(), orient, GetTextSize(),
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GetPenSize(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GetPenSize(),
m_Italic, m_Bold ); IsItalic(), IsBold() );
/* Enable this to draw the bounding box around the text field to validate /* Enable this to draw the bounding box around the text field to validate
@ -424,7 +440,7 @@ void LIB_TEXT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
LIB_ITEM::GetMsgPanelInfo( aList ); LIB_ITEM::GetMsgPanelInfo( aList );
msg = StringFromValue( g_UserUnit, m_Thickness, true ); msg = StringFromValue( g_UserUnit, GetThickness(), true );
aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) ); aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) );
} }
@ -440,9 +456,10 @@ const EDA_RECT LIB_TEXT::GetBoundingBox() const
// We are using now a bottom to top Y axis. // We are using now a bottom to top Y axis.
wxPoint orig = rect.GetOrigin(); wxPoint orig = rect.GetOrigin();
wxPoint end = rect.GetEnd(); wxPoint end = rect.GetEnd();
RotatePoint( &orig, m_Pos, -m_Orient );
RotatePoint( &end, m_Pos, -m_Orient ); RotatePoint( &orig, GetTextPos(), -GetTextAngle() );
RotatePoint( &end, GetTextPos(), -GetTextAngle() );
rect.SetOrigin( orig ); rect.SetOrigin( orig );
rect.SetEnd( end ); rect.SetEnd( end );
@ -462,7 +479,7 @@ void LIB_TEXT::Rotate()
} }
else else
{ {
m_Orient = ( m_Orient == TEXT_ORIENT_VERT ) ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT; SetTextAngle( GetTextAngle() == TEXT_ANGLE_VERT ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT );
} }
} }
@ -499,13 +516,13 @@ void LIB_TEXT::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
if( aEditMode == IS_MOVED ) if( aEditMode == IS_MOVED )
{ {
m_initialPos = m_Pos; m_initialPos = GetTextPos();
m_initialCursorPos = aPosition; m_initialCursorPos = aPosition;
SetEraseLastDrawItem(); SetEraseLastDrawItem();
} }
else else
{ {
m_Pos = aPosition; SetTextPos( aPosition );
} }
m_Flags = aEditMode; m_Flags = aEditMode;
@ -537,7 +554,7 @@ void LIB_TEXT::calcEdit( const wxPoint& aPosition )
{ {
if( m_rotate ) if( m_rotate )
{ {
m_Orient = ( m_Orient == TEXT_ORIENT_VERT ) ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT; SetTextAngle( GetTextAngle() == TEXT_ANGLE_VERT ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT );
m_rotate = false; m_rotate = false;
} }
@ -550,7 +567,7 @@ void LIB_TEXT::calcEdit( const wxPoint& aPosition )
if( m_Flags == IS_NEW ) if( m_Flags == IS_NEW )
{ {
SetEraseLastDrawItem(); SetEraseLastDrawItem();
m_Pos = aPosition; SetTextPos( aPosition );
} }
else if( m_Flags == IS_MOVED ) else if( m_Flags == IS_MOVED )
{ {

View File

@ -112,7 +112,7 @@ public:
void Move( const wxPoint& aPosition ) override; void Move( const wxPoint& aPosition ) override;
wxPoint GetPosition() const override { return m_Pos; } wxPoint GetPosition() const override { return EDA_TEXT::GetTextPos(); }
void MirrorHorizontal( const wxPoint& aCenter ) override; void MirrorHorizontal( const wxPoint& aCenter ) override;
@ -123,9 +123,9 @@ public:
void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform ) override; const TRANSFORM& aTransform ) override;
int GetWidth() const override { return m_Thickness; } int GetWidth() const override { return GetThickness(); }
void SetWidth( int aWidth ) override { m_Thickness = aWidth; } void SetWidth( int aWidth ) override { SetThickness( aWidth ); }
wxString GetSelectMenuText() const override; wxString GetSelectMenuText() const override;

View File

@ -71,7 +71,7 @@ LIB_ITEM* LIB_EDIT_FRAME::m_drawItem = NULL;
bool LIB_EDIT_FRAME:: m_showDeMorgan = false; bool LIB_EDIT_FRAME:: m_showDeMorgan = false;
wxSize LIB_EDIT_FRAME:: m_clientSize = wxSize( -1, -1 ); wxSize LIB_EDIT_FRAME:: m_clientSize = wxSize( -1, -1 );
int LIB_EDIT_FRAME:: m_textSize = -1; int LIB_EDIT_FRAME:: m_textSize = -1;
int LIB_EDIT_FRAME:: m_textOrientation = TEXT_ORIENT_HORIZ; double LIB_EDIT_FRAME:: m_current_text_angle = TEXT_ANGLE_HORIZ;
int LIB_EDIT_FRAME:: m_drawLineWidth = 0; int LIB_EDIT_FRAME:: m_drawLineWidth = 0;
// these values are overridden when reading the config // these values are overridden when reading the config

View File

@ -108,8 +108,8 @@ class LIB_EDIT_FRAME : public SCH_BASE_FRAME
/// The current text size setting. /// The current text size setting.
static int m_textSize; static int m_textSize;
/// Current text orientation setting. /// Current text angle setting.
static int m_textOrientation; static double m_current_text_angle;
/// The default pin num text size setting. /// The default pin num text size setting.
static int m_textPinNumDefaultSize; static int m_textPinNumDefaultSize;

View File

@ -102,7 +102,7 @@ static LIB_PART* dummy()
LIB_TEXT* text = new LIB_TEXT( part ); LIB_TEXT* text = new LIB_TEXT( part );
text->SetSize( wxSize( 150, 150 ) ); text->SetTextSize( wxSize( 150, 150 ) );
text->SetText( wxString( wxT( "??" ) ) ); text->SetText( wxString( wxT( "??" ) ) );
part->AddDrawItem( square ); part->AddDrawItem( square );
@ -171,7 +171,7 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_PART& aPart, SCH_SHEET_PATH* sheet, int unit,
schField = AddField( fld ); schField = AddField( fld );
} }
schField->SetTextPosition( m_Pos + it->GetTextPosition() ); schField->SetTextPos( m_Pos + it->GetTextPos() );
schField->ImportValues( *it ); schField->ImportValues( *it );
schField->SetText( it->GetText() ); schField->SetText( it->GetText() );
} }
@ -541,11 +541,11 @@ void SCH_COMPONENT::SetRef( const SCH_SHEET_PATH* sheet, const wxString& ref )
SCH_FIELD* rf = GetField( REFERENCE ); SCH_FIELD* rf = GetField( REFERENCE );
if( rf->GetText().IsEmpty() if( rf->GetText().IsEmpty()
|| ( abs( rf->GetTextPosition().x - m_Pos.x ) + || ( abs( rf->GetTextPos().x - m_Pos.x ) +
abs( rf->GetTextPosition().y - m_Pos.y ) > 10000 ) ) abs( rf->GetTextPos().y - m_Pos.y ) > 10000 ) )
{ {
// move it to a reasonable position // move it to a reasonable position
rf->SetTextPosition( m_Pos + wxPoint( 50, 50 ) ); rf->SetTextPos( m_Pos + wxPoint( 50, 50 ) );
} }
rf->SetText( ref ); // for drawing. rf->SetText( ref ); // for drawing.
@ -1209,7 +1209,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
{ {
m_part_name.Empty(); m_part_name.Empty();
GetField( VALUE )->Empty(); GetField( VALUE )->Empty();
GetField( VALUE )->SetOrientation( TEXT_ORIENT_HORIZ ); GetField( VALUE )->SetTextAngle( TEXT_ANGLE_HORIZ );
GetField( VALUE )->SetVisible( false ); GetField( VALUE )->SetVisible( false );
} }
@ -1276,7 +1276,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
for( int i = 0; i<GetFieldCount(); i++ ) for( int i = 0; i<GetFieldCount(); i++ )
{ {
if( GetField( i )->GetText().IsEmpty() ) if( GetField( i )->GetText().IsEmpty() )
GetField( i )->SetTextPosition( m_Pos ); GetField( i )->SetTextPos( m_Pos );
} }
} }
else if( line[0] == 'A' && line[1] == 'R' ) else if( line[0] == 'A' && line[1] == 'R' )
@ -1386,17 +1386,17 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
continue; continue;
} }
GetField( fieldNdx )->SetTextPosition( wxPoint( x, y ) ); GetField( fieldNdx )->SetTextPos( wxPoint( x, y ) );
GetField( fieldNdx )->SetAttributes( attr ); GetField( fieldNdx )->SetVisible( !attr );
if( (w == 0 ) || (ii == 4) ) if( (w == 0 ) || (ii == 4) )
w = GetDefaultTextSize(); w = GetDefaultTextSize();
GetField( fieldNdx )->SetSize( wxSize( w, w ) ); GetField( fieldNdx )->SetTextSize( wxSize( w, w ) );
GetField( fieldNdx )->SetOrientation( TEXT_ORIENT_HORIZ ); GetField( fieldNdx )->SetTextAngle( TEXT_ANGLE_HORIZ );
if( char1[0] == 'V' ) if( char1[0] == 'V' )
GetField( fieldNdx )->SetOrientation( TEXT_ORIENT_VERT ); GetField( fieldNdx )->SetTextAngle( TEXT_ANGLE_VERT );
if( ii >= 7 ) if( ii >= 7 )
{ {
@ -1577,9 +1577,9 @@ void SCH_COMPONENT::MirrorY( int aYaxis_position )
for( int ii = 0; ii < GetFieldCount(); ii++ ) for( int ii = 0; ii < GetFieldCount(); ii++ )
{ {
// Move the fields to the new position because the component itself has moved. // Move the fields to the new position because the component itself has moved.
wxPoint pos = GetField( ii )->GetTextPosition(); wxPoint pos = GetField( ii )->GetTextPos();
pos.x -= dx; pos.x -= dx;
GetField( ii )->SetTextPosition( pos ); GetField( ii )->SetTextPos( pos );
} }
} }
@ -1595,9 +1595,9 @@ void SCH_COMPONENT::MirrorX( int aXaxis_position )
for( int ii = 0; ii < GetFieldCount(); ii++ ) for( int ii = 0; ii < GetFieldCount(); ii++ )
{ {
// Move the fields to the new position because the component itself has moved. // Move the fields to the new position because the component itself has moved.
wxPoint pos = GetField( ii )->GetTextPosition(); wxPoint pos = GetField( ii )->GetTextPos();
pos.y -= dy; pos.y -= dy;
GetField( ii )->SetTextPosition( pos ); GetField( ii )->SetTextPos( pos );
} }
} }
@ -1613,10 +1613,10 @@ void SCH_COMPONENT::Rotate( wxPoint aPosition )
for( int ii = 0; ii < GetFieldCount(); ii++ ) for( int ii = 0; ii < GetFieldCount(); ii++ )
{ {
// Move the fields to the new position because the component itself has moved. // Move the fields to the new position because the component itself has moved.
wxPoint pos = GetField( ii )->GetTextPosition(); wxPoint pos = GetField( ii )->GetTextPos();
pos.x -= prev.x - m_Pos.x; pos.x -= prev.x - m_Pos.x;
pos.y -= prev.y - m_Pos.y; pos.y -= prev.y - m_Pos.y;
GetField( ii )->SetTextPosition( pos ); GetField( ii )->SetTextPos( pos );
} }
} }

View File

@ -55,11 +55,11 @@ SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent,
SCH_ITEM( aParent, SCH_FIELD_T ), SCH_ITEM( aParent, SCH_FIELD_T ),
EDA_TEXT() EDA_TEXT()
{ {
m_Pos = aPos; SetTextPos( aPos );
m_id = aFieldId; m_id = aFieldId;
m_Attributs = TEXT_NO_VISIBLE;
m_name = aName; m_name = aName;
SetVisible( false );
SetLayer( LAYER_FIELDS ); SetLayer( LAYER_FIELDS );
} }
@ -98,18 +98,18 @@ const wxString SCH_FIELD::GetFullyQualifiedText() const
int SCH_FIELD::GetPenSize() const int SCH_FIELD::GetPenSize() const
{ {
int pensize = m_Thickness; int pensize = GetThickness();
if( pensize == 0 ) // Use default values for pen size if( pensize == 0 ) // Use default values for pen size
{ {
if( m_Bold ) if( IsBold() )
pensize = GetPenSizeForBold( m_Size.x ); pensize = GetPenSizeForBold( GetTextWidth() );
else else
pensize = GetDefaultLineThickness(); pensize = GetDefaultLineThickness();
} }
// Clip pen size for small texts: // Clip pen size for small texts:
pensize = Clamp_Text_PenSize( pensize, m_Size, m_Bold ); pensize = Clamp_Text_PenSize( pensize, GetTextSize(), IsBold() );
return pensize; return pensize;
} }
@ -121,33 +121,33 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
EDA_COLOR_T color; EDA_COLOR_T color;
wxPoint textpos; wxPoint textpos;
SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent; SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent;
int LineWidth = m_Thickness; int lineWidth = GetThickness();
if( LineWidth == 0 ) // Use default values for pen size if( lineWidth == 0 ) // Use default values for pen size
{ {
if( m_Bold ) if( IsBold() )
LineWidth = GetPenSizeForBold( m_Size.x ); lineWidth = GetPenSizeForBold( GetTextWidth() );
else else
LineWidth = GetDefaultLineThickness(); lineWidth = GetDefaultLineThickness();
} }
// Clip pen size for small texts: // Clip pen size for small texts:
LineWidth = Clamp_Text_PenSize( LineWidth, m_Size, m_Bold ); lineWidth = Clamp_Text_PenSize( lineWidth, GetTextSize(), IsBold() );
if( ((m_Attributs & TEXT_NO_VISIBLE) && !m_forceVisible) || IsVoid() ) if( ( !IsVisible() && !m_forceVisible) || IsVoid() )
return; return;
GRSetDrawMode( aDC, aDrawMode ); GRSetDrawMode( aDC, aDrawMode );
// Calculate the text orientation according to the component orientation. // Calculate the text orientation according to the component orientation.
orient = m_Orient; orient = GetTextAngle();
if( parentComponent->GetTransform().y1 ) // Rotate component 90 degrees. if( parentComponent->GetTransform().y1 ) // Rotate component 90 degrees.
{ {
if( orient == TEXT_ORIENT_HORIZ ) if( orient == TEXT_ANGLE_HORIZ )
orient = TEXT_ORIENT_VERT; orient = TEXT_ANGLE_VERT;
else else
orient = TEXT_ORIENT_HORIZ; orient = TEXT_ANGLE_HORIZ;
} }
/* Calculate the text justification, according to the component /* Calculate the text justification, according to the component
@ -179,15 +179,15 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
} }
EDA_RECT* clipbox = aPanel ? aPanel->GetClipBox() : NULL; EDA_RECT* clipbox = aPanel ? aPanel->GetClipBox() : NULL;
DrawGraphicText( clipbox, aDC, textpos, color, GetFullyQualifiedText(), orient, m_Size, DrawGraphicText( clipbox, aDC, textpos, color, GetFullyQualifiedText(), orient, GetTextSize(),
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
LineWidth, m_Italic, m_Bold ); lineWidth, IsItalic(), IsBold() );
// While moving: don't loose visual contact to which component this label belongs. // While moving: don't loose visual contact to which component this label belongs.
if ( IsWireImage() ) if ( IsWireImage() )
{ {
const wxPoint origin = parentComponent->GetPosition(); const wxPoint origin = parentComponent->GetPosition();
textpos = m_Pos - origin; textpos = GetTextPos() - origin;
textpos = parentComponent->GetScreenCoord( textpos ); textpos = parentComponent->GetScreenCoord( textpos );
textpos += parentComponent->GetPosition(); textpos += parentComponent->GetPosition();
GRLine( clipbox, aDC, origin, textpos, 2, DARKGRAY ); GRLine( clipbox, aDC, origin, textpos, 2, DARKGRAY );
@ -219,31 +219,17 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
void SCH_FIELD::ImportValues( const LIB_FIELD& aSource ) void SCH_FIELD::ImportValues( const LIB_FIELD& aSource )
{ {
m_Orient = aSource.GetOrientation(); SetEffects( aSource );
m_Size = aSource.GetSize();
m_HJustify = aSource.GetHorizJustify();
m_VJustify = aSource.GetVertJustify();
m_Italic = aSource.IsItalic();
m_Bold = aSource.IsBold();
m_Thickness = aSource.GetThickness();
m_Attributs = aSource.GetAttributes();
m_Mirror = aSource.IsMirrored();
} }
void SCH_FIELD::ExportValues( LIB_FIELD& aDest ) const void SCH_FIELD::ExportValues( LIB_FIELD& aDest ) const
{ {
aDest.SetId( GetId() ); aDest.SetId( GetId() );
aDest.SetText( m_Text ); // Set field value aDest.SetText( m_Text ); // Set field value
aDest.SetName( GetName() ); aDest.SetName( GetName() );
aDest.SetOrientation( GetOrientation() );
aDest.SetSize( GetSize() ); aDest.SetEffects( *this );
aDest.SetTextPosition( GetTextPosition() );
aDest.SetHorizJustify( GetHorizJustify() );
aDest.SetVertJustify( GetVertJustify() );
aDest.SetItalic( IsItalic() );
aDest.SetBold( IsBold() );
aDest.SetThickness( GetThickness() );
aDest.SetAttributes( GetAttributes() );
} }
@ -256,27 +242,19 @@ void SCH_FIELD::SwapData( SCH_ITEM* aItem )
std::swap( m_Text, item->m_Text ); std::swap( m_Text, item->m_Text );
std::swap( m_Layer, item->m_Layer ); std::swap( m_Layer, item->m_Layer );
std::swap( m_Pos, item->m_Pos );
std::swap( m_Size, item->m_Size ); SwapEffects( *item );
std::swap( m_Thickness, item->m_Thickness );
std::swap( m_Orient, item->m_Orient );
std::swap( m_Mirror, item->m_Mirror );
std::swap( m_Attributs, item->m_Attributs );
std::swap( m_Italic, item->m_Italic );
std::swap( m_Bold, item->m_Bold );
std::swap( m_HJustify, item->m_HJustify );
std::swap( m_VJustify, item->m_VJustify );
} }
const EDA_RECT SCH_FIELD::GetBoundingBox() const const EDA_RECT SCH_FIELD::GetBoundingBox() const
{ {
SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent; SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent;
int linewidth = ( m_Thickness == 0 ) ? GetDefaultLineThickness() : m_Thickness; int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
// We must pass the effective text thickness to GetTextBox // We must pass the effective text thickness to GetTextBox
// when calculating the bounding box // when calculating the bounding box
linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
// Calculate the text bounding box: // Calculate the text bounding box:
EDA_RECT rect; EDA_RECT rect;
@ -293,11 +271,11 @@ const EDA_RECT SCH_FIELD::GetBoundingBox() const
// Calculate the bounding box position relative to the component: // Calculate the bounding box position relative to the component:
wxPoint origin = parentComponent->GetPosition(); wxPoint origin = parentComponent->GetPosition();
wxPoint pos = m_Pos - origin; wxPoint pos = GetTextPos() - origin;
wxPoint begin = rect.GetOrigin() - origin; wxPoint begin = rect.GetOrigin() - origin;
wxPoint end = rect.GetEnd() - origin; wxPoint end = rect.GetEnd() - origin;
RotatePoint( &begin, pos, m_Orient ); RotatePoint( &begin, pos, GetTextAngle() );
RotatePoint( &end, pos, m_Orient ); RotatePoint( &end, pos, GetTextAngle() );
// Due to the Y axis direction, we must mirror the bounding box, // Due to the Y axis direction, we must mirror the bounding box,
// relative to the text position: // relative to the text position:
@ -336,28 +314,28 @@ bool SCH_FIELD::Save( FILE* aFile ) const
{ {
char hjustify = 'C'; char hjustify = 'C';
if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT ) if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
hjustify = 'L'; hjustify = 'L';
else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT ) else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
hjustify = 'R'; hjustify = 'R';
char vjustify = 'C'; char vjustify = 'C';
if( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM ) if( GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
vjustify = 'B'; vjustify = 'B';
else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP ) else if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
vjustify = 'T'; vjustify = 'T';
if( fprintf( aFile, "F %d %s %c %-3d %-3d %-3d %4.4X %c %c%c%c", if( fprintf( aFile, "F %d %s %c %-3d %-3d %-3d %4.4X %c %c%c%c",
m_id, m_id,
EscapedUTF8( m_Text ).c_str(), // wraps in quotes too EscapedUTF8( m_Text ).c_str(), // wraps in quotes too
m_Orient == TEXT_ORIENT_HORIZ ? 'H' : 'V', GetTextAngle() == TEXT_ANGLE_HORIZ ? 'H' : 'V',
m_Pos.x, m_Pos.y, GetTextPos().x, GetTextPos().y,
m_Size.x, GetTextWidth(),
m_Attributs, !IsVisible(),
hjustify, vjustify, hjustify, vjustify,
m_Italic ? 'I' : 'N', IsItalic() ? 'I' : 'N',
m_Bold ? 'B' : 'N' ) == EOF ) IsBold() ? 'B' : 'N' ) == EOF )
{ {
return false; return false;
} }
@ -476,7 +454,9 @@ bool SCH_FIELD::Replace( wxFindReplaceData& aSearchData, void* aAuxData )
void SCH_FIELD::Rotate( wxPoint aPosition ) void SCH_FIELD::Rotate( wxPoint aPosition )
{ {
RotatePoint( &m_Pos, aPosition, 900 ); wxPoint pt = GetTextPos();
RotatePoint( &pt, aPosition, 900 );
SetTextPos( pt );
} }
@ -555,7 +535,7 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter )
EDA_COLOR_T color = GetLayerColor( GetLayer() ); EDA_COLOR_T color = GetLayerColor( GetLayer() );
if( m_Attributs & TEXT_NO_VISIBLE ) if( !IsVisible() )
return; return;
if( IsVoid() ) if( IsVoid() )
@ -563,14 +543,14 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter )
/* Calculate the text orientation, according to the component /* Calculate the text orientation, according to the component
* orientation/mirror */ * orientation/mirror */
int orient = m_Orient; int orient = GetTextAngle();
if( parent->GetTransform().y1 ) // Rotate component 90 deg. if( parent->GetTransform().y1 ) // Rotate component 90 deg.
{ {
if( orient == TEXT_ORIENT_HORIZ ) if( orient == TEXT_ANGLE_HORIZ )
orient = TEXT_ORIENT_VERT; orient = TEXT_ANGLE_VERT;
else else
orient = TEXT_ORIENT_HORIZ; orient = TEXT_ANGLE_HORIZ;
} }
/* Calculate the text justification, according to the component /* Calculate the text justification, according to the component
@ -591,8 +571,9 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter )
int thickness = GetPenSize(); int thickness = GetPenSize();
aPlotter->Text( textpos, color, GetFullyQualifiedText(), orient, m_Size, hjustify, vjustify, aPlotter->Text( textpos, color, GetFullyQualifiedText(), orient, GetTextSize(),
thickness, m_Italic, m_Bold ); hjustify, vjustify,
thickness, IsItalic(), IsBold() );
} }
@ -607,16 +588,15 @@ void SCH_FIELD::SetPosition( const wxPoint& aPosition )
// the position relative to the parent component. // the position relative to the parent component.
wxPoint pt = aPosition - pos; wxPoint pt = aPosition - pos;
m_Pos = pos + component->GetTransform().InverseTransform().TransformCoordinate( pt ); SetTextPos( pos + component->GetTransform().InverseTransform().TransformCoordinate( pt ) );
} }
wxPoint SCH_FIELD::GetPosition() const wxPoint SCH_FIELD::GetPosition() const
{ {
SCH_COMPONENT* component = (SCH_COMPONENT*) GetParent(); SCH_COMPONENT* component = (SCH_COMPONENT*) GetParent();
wxPoint pos = m_Pos - component->GetPosition(); wxPoint pos = GetTextPos() - component->GetPosition();
return component->GetTransform().TransformCoordinate( pos ) + component->GetPosition(); return component->GetTransform().TransformCoordinate( pos ) + component->GetPosition();
} }

View File

@ -140,15 +140,6 @@ public:
int GetPenSize() const override; int GetPenSize() const override;
/**
* Function IsVisible
* @return true is this field is visible, false if flagged invisible
*/
bool IsVisible() const
{
return !( m_Attributs & TEXT_NO_VISIBLE );
}
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override; GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
@ -158,10 +149,9 @@ public:
void Move( const wxPoint& aMoveVector ) override void Move( const wxPoint& aMoveVector ) override
{ {
m_Pos += aMoveVector; Offset( aMoveVector );
} }
void Rotate( wxPoint aPosition ) override; void Rotate( wxPoint aPosition ) override;
/** /**
@ -196,7 +186,7 @@ public:
bool IsReplaceable() const override { return true; } bool IsReplaceable() const override { return true; }
wxPoint GetLibPosition() const { return m_Pos; } wxPoint GetLibPosition() const { return EDA_TEXT::GetTextPos(); }
wxPoint GetPosition() const override; wxPoint GetPosition() const override;

View File

@ -881,7 +881,7 @@ SCH_SHEET* SCH_LEGACY_PLUGIN::loadSheet( FILE_LINE_READER& aReader )
size = parseInt( aReader, line, &line ); size = parseInt( aReader, line, &line );
sheetPin->SetSize( wxSize( size, size ) ); sheetPin->SetTextSize( wxSize( size, size ) );
sheet->AddPin( sheetPin.release() ); sheet->AddPin( sheetPin.release() );
} }
@ -1131,11 +1131,11 @@ SCH_TEXT* SCH_LEGACY_PLUGIN::loadText( FILE_LINE_READER& aReader )
position.x = parseInt( aReader, line, &line ); position.x = parseInt( aReader, line, &line );
position.y = parseInt( aReader, line, &line ); position.y = parseInt( aReader, line, &line );
text->SetPosition( position ); text->SetPosition( position );
text->SetOrientation( parseInt( aReader, line, &line ) ); text->SetLabelSpinStyle( parseInt( aReader, line, &line ) );
int size = parseInt( aReader, line, &line ); int size = parseInt( aReader, line, &line );
text->SetSize( wxSize( size, size ) ); text->SetTextSize( wxSize( size, size ) );
// Parse the global and hierarchical label type. // Parse the global and hierarchical label type.
if( text->Type() == SCH_HIERARCHICAL_LABEL_T || text->Type() == SCH_GLOBAL_LABEL_T ) if( text->Type() == SCH_HIERARCHICAL_LABEL_T || text->Type() == SCH_GLOBAL_LABEL_T )
@ -1379,14 +1379,14 @@ SCH_COMPONENT* SCH_LEGACY_PLUGIN::loadComponent( FILE_LINE_READER& aReader )
} }
component->GetField( index )->SetText( text ); component->GetField( index )->SetText( text );
component->GetField( index )->SetTextPosition( pos ); component->GetField( index )->SetTextPos( pos );
component->GetField( index )->SetAttributes( attributes ); component->GetField( index )->SetVisible( !attributes );
component->GetField( index )->SetSize( wxSize( size, size ) ); component->GetField( index )->SetTextSize( wxSize( size, size ) );
if( orientation == 'H' ) if( orientation == 'H' )
component->GetField( index )->SetOrientation( TEXT_ORIENT_HORIZ ); component->GetField( index )->SetTextAngle( TEXT_ANGLE_HORIZ );
else if( orientation == 'V' ) else if( orientation == 'V' )
component->GetField( index )->SetOrientation( TEXT_ORIENT_VERT ); component->GetField( index )->SetTextAngle( TEXT_ANGLE_VERT );
else else
SCH_PARSE_ERROR( _( "component field orientation must be H or V" ), SCH_PARSE_ERROR( _( "component field orientation must be H or V" ),
aReader, line ); aReader, line );
@ -1671,10 +1671,10 @@ void SCH_LEGACY_PLUGIN::saveField( SCH_FIELD* aField )
m_out->Print( 0, "F %d %s %c %-3d %-3d %-3d %4.4X %c %c%c%c", m_out->Print( 0, "F %d %s %c %-3d %-3d %-3d %4.4X %c %c%c%c",
aField->GetId(), aField->GetId(),
EscapedUTF8( aField->GetText() ).c_str(), // wraps in quotes too EscapedUTF8( aField->GetText() ).c_str(), // wraps in quotes too
aField->GetOrientation() == TEXT_ORIENT_HORIZ ? 'H' : 'V', aField->GetTextAngle() == TEXT_ANGLE_HORIZ ? 'H' : 'V',
aField->GetLibPosition().x, aField->GetLibPosition().y, aField->GetLibPosition().x, aField->GetLibPosition().y,
aField->GetSize().x, aField->GetTextWidth(),
aField->GetAttributes(), !aField->IsVisible(),
hjustify, vjustify, hjustify, vjustify,
aField->IsItalic() ? 'I' : 'N', aField->IsItalic() ? 'I' : 'N',
aField->IsBold() ? 'B' : 'N' ); aField->IsBold() ? 'B' : 'N' );
@ -1732,7 +1732,8 @@ void SCH_LEGACY_PLUGIN::saveSheet( SCH_SHEET* aSheet )
wxCHECK_RET( aSheet != NULL, "SCH_SHEET* is NULL" ); wxCHECK_RET( aSheet != NULL, "SCH_SHEET* is NULL" );
m_out->Print( 0, "$Sheet\n" ); m_out->Print( 0, "$Sheet\n" );
m_out->Print( 0, "S %-4d %-4d %-4d %-4d\n", aSheet->GetPosition().x, aSheet->GetPosition().y, m_out->Print( 0, "S %-4d %-4d %-4d %-4d\n",
aSheet->GetPosition().x, aSheet->GetPosition().y,
aSheet->GetSize().x, aSheet->GetSize().y ); aSheet->GetSize().x, aSheet->GetSize().y );
m_out->Print( 0, "U %8.8lX\n", (unsigned long) aSheet->GetTimeStamp() ); m_out->Print( 0, "U %8.8lX\n", (unsigned long) aSheet->GetTimeStamp() );
@ -1794,7 +1795,7 @@ void SCH_LEGACY_PLUGIN::saveSheet( SCH_SHEET* aSheet )
m_out->Print( 0, "F%d %s %c %c %-3d %-3d %-3d\n", pin.GetNumber(), m_out->Print( 0, "F%d %s %c %c %-3d %-3d %-3d\n", pin.GetNumber(),
EscapedUTF8( pin.GetText() ).c_str(), // supplies wrapping quotes EscapedUTF8( pin.GetText() ).c_str(), // supplies wrapping quotes
type, side, pin.GetPosition().x, pin.GetPosition().y, type, side, pin.GetPosition().x, pin.GetPosition().y,
pin.GetSize().x ); pin.GetTextWidth() );
} }
m_out->Print( 0, "$EndSheet\n" ); m_out->Print( 0, "$EndSheet\n" );
@ -1894,16 +1895,21 @@ void SCH_LEGACY_PLUGIN::saveText( SCH_TEXT* aText )
} }
m_out->Print( 0, "Text %s %-4d %-4d %-4d %-4d %s %d\n%s\n", textType, m_out->Print( 0, "Text %s %-4d %-4d %-4d %-4d %s %d\n%s\n", textType,
aText->GetPosition().x, aText->GetPosition().y, aText->GetOrientation(), aText->GetPosition().x, aText->GetPosition().y,
aText->GetSize().x, italics, aText->GetThickness(), TO_UTF8( text ) ); aText->GetLabelSpinStyle(),
aText->GetTextWidth(),
italics, aText->GetThickness(), TO_UTF8( text ) );
} }
else if( layer == LAYER_GLOBLABEL || layer == LAYER_HIERLABEL ) else if( layer == LAYER_GLOBLABEL || layer == LAYER_HIERLABEL )
{ {
textType = ( layer == LAYER_GLOBLABEL ) ? "GLabel" : "HLabel"; textType = ( layer == LAYER_GLOBLABEL ) ? "GLabel" : "HLabel";
m_out->Print( 0, "Text %s %-4d %-4d %-4d %-4d %s %s %d\n%s\n", textType, m_out->Print( 0, "Text %s %-4d %-4d %-4d %-4d %s %s %d\n%s\n", textType,
aText->GetPosition().x, aText->GetPosition().y, aText->GetOrientation(), aText->GetPosition().x, aText->GetPosition().y,
aText->GetSize().x, SheetLabelType[aText->GetShape()], italics, aText->GetLabelSpinStyle(),
aText->GetTextWidth(),
SheetLabelType[aText->GetShape()],
italics,
aText->GetThickness(), TO_UTF8( text ) ); aText->GetThickness(), TO_UTF8( text ) );
} }
} }
@ -2524,14 +2530,14 @@ void SCH_LEGACY_PLUGIN_CACHE::loadField( std::unique_ptr< LIB_PART >& aPart,
wxSize textSize; wxSize textSize;
textSize.x = textSize.y = parseInt( aReader, line, &line ); textSize.x = textSize.y = parseInt( aReader, line, &line );
field->SetSize( textSize ); field->SetTextSize( textSize );
char textOrient = parseChar( aReader, line, &line ); char textOrient = parseChar( aReader, line, &line );
if( textOrient == 'H' ) if( textOrient == 'H' )
field->SetOrientation( TEXT_ORIENT_HORIZ ); field->SetTextAngle( TEXT_ANGLE_HORIZ );
else if( textOrient == 'V' ) else if( textOrient == 'V' )
field->SetOrientation( TEXT_ORIENT_VERT ); field->SetTextAngle( TEXT_ANGLE_VERT );
else else
SCH_PARSE_ERROR( _( "invalid field text orientation parameter" ), aReader, line ); SCH_PARSE_ERROR( _( "invalid field text orientation parameter" ), aReader, line );
@ -2818,7 +2824,7 @@ LIB_TEXT* SCH_LEGACY_PLUGIN_CACHE::loadText( std::unique_ptr< LIB_PART >& aPart,
std::unique_ptr< LIB_TEXT > text( new LIB_TEXT( aPart.get() ) ); std::unique_ptr< LIB_TEXT > text( new LIB_TEXT( aPart.get() ) );
text->SetOrientation( (double) parseInt( aReader, line, &line ) ); text->SetTextAngle( (double) parseInt( aReader, line, &line ) );
wxPoint center; wxPoint center;
@ -2829,8 +2835,8 @@ LIB_TEXT* SCH_LEGACY_PLUGIN_CACHE::loadText( std::unique_ptr< LIB_PART >& aPart,
wxSize size; wxSize size;
size.x = size.y = parseInt( aReader, line, &line ); size.x = size.y = parseInt( aReader, line, &line );
text->SetSize( size ); text->SetTextSize( size );
text->SetAttributes( parseInt( aReader, line, &line ) ); text->SetVisible( !parseInt( aReader, line, &line ) );
text->SetUnit( parseInt( aReader, line, &line ) ); text->SetUnit( parseInt( aReader, line, &line ) );
text->SetConvert( parseInt( aReader, line, &line ) ); text->SetConvert( parseInt( aReader, line, &line ) );

View File

@ -1104,13 +1104,13 @@ bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxStri
*/ */
SCH_FIELD * fpfield = component->GetField( FOOTPRINT ); SCH_FIELD * fpfield = component->GetField( FOOTPRINT );
if( fpfield->GetText().IsEmpty() if( fpfield->GetText().IsEmpty()
&& ( fpfield->GetTextPosition() == component->GetPosition() ) ) && ( fpfield->GetTextPos() == component->GetPosition() ) )
{ {
fpfield->SetOrientation( component->GetField( VALUE )->GetOrientation() ); fpfield->SetTextAngle( component->GetField( VALUE )->GetTextAngle() );
fpfield->SetTextPosition( component->GetField( VALUE )->GetTextPosition() ); fpfield->SetTextPos( component->GetField( VALUE )->GetTextPos() );
fpfield->SetSize( component->GetField( VALUE )->GetSize() ); fpfield->SetTextSize( component->GetField( VALUE )->GetTextSize() );
if( fpfield->GetOrientation() == 0 ) if( fpfield->GetTextAngle() == 0.0 )
fpfield->Offset( wxPoint( 0, 100 ) ); fpfield->Offset( wxPoint( 0, 100 ) );
else else
fpfield->Offset( wxPoint( 100, 0 ) ); fpfield->Offset( wxPoint( 100, 0 ) );

View File

@ -606,9 +606,9 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
pos_filename = GetFileNamePosition() + aOffset; pos_filename = GetFileNamePosition() + aOffset;
if( IsVerticalOrientation() ) if( IsVerticalOrientation() )
name_orientation = TEXT_ORIENT_VERT; name_orientation = TEXT_ANGLE_VERT;
else else
name_orientation = TEXT_ORIENT_HORIZ; name_orientation = TEXT_ANGLE_HORIZ;
/* Draw text : SheetName */ /* Draw text : SheetName */
if( aColor > 0 ) if( aColor > 0 )
@ -1162,13 +1162,13 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter )
{ {
pos_sheetname = wxPoint( m_pos.x - 8, m_pos.y + m_size.y ); pos_sheetname = wxPoint( m_pos.x - 8, m_pos.y + m_size.y );
pos_filename = wxPoint( m_pos.x + m_size.x + 4, m_pos.y + m_size.y ); pos_filename = wxPoint( m_pos.x + m_size.x + 4, m_pos.y + m_size.y );
name_orientation = TEXT_ORIENT_VERT; name_orientation = TEXT_ANGLE_VERT;
} }
else else
{ {
pos_sheetname = wxPoint( m_pos.x, m_pos.y - 4 ); pos_sheetname = wxPoint( m_pos.x, m_pos.y - 4 );
pos_filename = wxPoint( m_pos.x, m_pos.y + m_size.y + 4 ); pos_filename = wxPoint( m_pos.x, m_pos.y + m_size.y + 4 );
name_orientation = TEXT_ORIENT_HORIZ; name_orientation = TEXT_ANGLE_HORIZ;
} }
/* Draw texts: SheetName */ /* Draw texts: SheetName */

View File

@ -172,7 +172,7 @@ public:
void Move( const wxPoint& aMoveVector ) override void Move( const wxPoint& aMoveVector ) override
{ {
m_Pos += aMoveVector; Offset( aMoveVector );
} }
void MirrorY( int aYaxis_position ) override; void MirrorY( int aYaxis_position ) override;

View File

@ -47,7 +47,8 @@ SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxStr
SetParent( parent ); SetParent( parent );
wxASSERT( parent ); wxASSERT( parent );
m_Layer = LAYER_SHEETLABEL; m_Layer = LAYER_SHEETLABEL;
m_Pos = pos;
SetTextPos( pos );
if( parent->IsVerticalOrientation() ) if( parent->IsVerticalOrientation() )
SetEdge( SHEET_TOP_SIDE ); SetEdge( SHEET_TOP_SIDE );
@ -125,26 +126,26 @@ void SCH_SHEET_PIN::SetEdge( SCH_SHEET_PIN::SHEET_SIDE aEdge )
{ {
case SHEET_LEFT_SIDE: case SHEET_LEFT_SIDE:
m_edge = aEdge; m_edge = aEdge;
m_Pos.x = Sheet->m_pos.x; SetTextX( Sheet->m_pos.x );
SetOrientation( 2 ); /* Orientation horiz inverse */ SetLabelSpinStyle( 2 ); // Orientation horiz inverse
break; break;
case SHEET_RIGHT_SIDE: case SHEET_RIGHT_SIDE:
m_edge = aEdge; m_edge = aEdge;
m_Pos.x = Sheet->m_pos.x + Sheet->m_size.x; SetTextX( Sheet->m_pos.x + Sheet->m_size.x );
SetOrientation( 0 ); /* Orientation horiz normal */ SetLabelSpinStyle( 0 ); // Orientation horiz normal
break; break;
case SHEET_TOP_SIDE: case SHEET_TOP_SIDE:
m_edge = aEdge; m_edge = aEdge;
m_Pos.y = Sheet->m_pos.y; SetTextY( Sheet->m_pos.y );
SetOrientation( 3 ); /* Orientation vert BOTTOM */ SetLabelSpinStyle( 3 ); // Orientation vert BOTTOM
break; break;
case SHEET_BOTTOM_SIDE: case SHEET_BOTTOM_SIDE:
m_edge = aEdge; m_edge = aEdge;
m_Pos.y = Sheet->m_pos.y + Sheet->m_size.y; SetTextY( Sheet->m_pos.y + Sheet->m_size.y );
SetOrientation( 1 ); /* Orientation vert UP */ SetLabelSpinStyle( 1 ); // Orientation vert UP
break; break;
default: default:
@ -179,15 +180,15 @@ void SCH_SHEET_PIN::ConstrainOnEdge( wxPoint Pos )
SetEdge( SHEET_LEFT_SIDE ); SetEdge( SHEET_LEFT_SIDE );
} }
m_Pos.y = Pos.y; SetTextY( Pos.y );
if( m_Pos.y < sheet->m_pos.y ) if( GetTextPos().y < sheet->m_pos.y )
m_Pos.y = sheet->m_pos.y; SetTextY( sheet->m_pos.y );
if( m_Pos.y > (sheet->m_pos.y + sheet->m_size.y) ) if( GetTextPos().y > (sheet->m_pos.y + sheet->m_size.y) )
m_Pos.y = sheet->m_pos.y + sheet->m_size.y; SetTextY( sheet->m_pos.y + sheet->m_size.y );
} }
else /* vertical sheetpin*/ else // vertical sheetpin
{ {
if( Pos.y > center.y ) if( Pos.y > center.y )
{ {
@ -198,17 +199,17 @@ void SCH_SHEET_PIN::ConstrainOnEdge( wxPoint Pos )
SetEdge( SHEET_TOP_SIDE ); //top SetEdge( SHEET_TOP_SIDE ); //top
} }
m_Pos.x = Pos.x; SetTextX( Pos.x );
if( m_Pos.x < sheet->m_pos.x ) if( GetTextPos().x < sheet->m_pos.x )
m_Pos.x = sheet->m_pos.x; SetTextX( sheet->m_pos.x );
if( m_Pos.x > (sheet->m_pos.x + sheet->m_size.x) ) if( GetTextPos().x > (sheet->m_pos.x + sheet->m_size.x) )
m_Pos.x = sheet->m_pos.x + sheet->m_size.x; SetTextX( sheet->m_pos.x + sheet->m_size.x );
} }
printf( "centre %d %d, pos %d %d, pinpos %d %d, edge %d\n", printf( "centre %d %d, pos %d %d, pinpos %d %d, edge %d\n",
center.x, center.y, Pos.x, Pos.y, m_Pos.x, m_Pos.y, m_edge); center.x, center.y, Pos.x, Pos.y, GetTextPos().x, GetTextPos().y, m_edge);
} }
@ -259,8 +260,8 @@ bool SCH_SHEET_PIN::Save( FILE* aFile ) const
if( fprintf( aFile, "F%d %s %c %c %-3d %-3d %-3d\n", m_number, if( fprintf( aFile, "F%d %s %c %c %-3d %-3d %-3d\n", m_number,
EscapedUTF8( m_Text ).c_str(), // supplies wrapping quotes EscapedUTF8( m_Text ).c_str(), // supplies wrapping quotes
type, side, m_Pos.x, m_Pos.y, type, side, GetTextPos().x, GetTextPos().y,
m_Size.x ) == EOF ) GetTextWidth() ) == EOF )
{ {
return false; return false;
} }
@ -271,7 +272,7 @@ bool SCH_SHEET_PIN::Save( FILE* aFile ) const
bool SCH_SHEET_PIN::Load( LINE_READER& aLine, wxString& aErrorMsg ) bool SCH_SHEET_PIN::Load( LINE_READER& aLine, wxString& aErrorMsg )
{ {
int size; int x, y, size;
char number[256]; char number[256];
char name[256]; char name[256];
char connectType[256]; char connectType[256];
@ -303,7 +304,7 @@ bool SCH_SHEET_PIN::Load( LINE_READER& aLine, wxString& aErrorMsg )
cp += strlen( sheetSide ) + 1; cp += strlen( sheetSide ) + 1;
int r = sscanf( cp, "%d %d %d", &m_Pos.x, &m_Pos.y, &size ); int r = sscanf( cp, "%d %d %d", &x, &y, &size );
if( r != 3 ) if( r != 3 )
{ {
aErrorMsg.Printf( wxT( "Eeschema file sheet hierarchical label error at line %d.\n" ), aErrorMsg.Printf( wxT( "Eeschema file sheet hierarchical label error at line %d.\n" ),
@ -318,7 +319,8 @@ bool SCH_SHEET_PIN::Load( LINE_READER& aLine, wxString& aErrorMsg )
if( size == 0 ) if( size == 0 )
size = GetDefaultTextSize(); size = GetDefaultTextSize();
m_Size.x = m_Size.y = size; SetTextSize( wxSize( size, size ) );
SetTextPos( wxPoint( x, y ) );
switch( connectType[0] ) switch( connectType[0] )
{ {
@ -345,19 +347,19 @@ bool SCH_SHEET_PIN::Load( LINE_READER& aLine, wxString& aErrorMsg )
switch( sheetSide[0] ) switch( sheetSide[0] )
{ {
case 'R' : /* pin on right side */ case 'R' : // pin on right side
SetEdge( SHEET_RIGHT_SIDE ); SetEdge( SHEET_RIGHT_SIDE );
break; break;
case 'T' : /* pin on top side */ case 'T' : // pin on top side
SetEdge( SHEET_TOP_SIDE ); SetEdge( SHEET_TOP_SIDE );
break; break;
case 'B' : /* pin on bottom side */ case 'B' : // pin on bottom side
SetEdge( SHEET_BOTTOM_SIDE ); SetEdge( SHEET_BOTTOM_SIDE );
break; break;
case 'L' : /* pin on left side */ case 'L' : // pin on left side
default : default :
SetEdge( SHEET_LEFT_SIDE ); SetEdge( SHEET_LEFT_SIDE );
break; break;
@ -389,9 +391,9 @@ bool SCH_SHEET_PIN::Matches( wxFindReplaceData& aSearchData,
void SCH_SHEET_PIN::MirrorX( int aXaxis_position ) void SCH_SHEET_PIN::MirrorX( int aXaxis_position )
{ {
int p = m_Pos.y - aXaxis_position; int p = GetTextPos().y - aXaxis_position;
m_Pos.y = aXaxis_position - p; SetTextY( aXaxis_position - p );
switch( m_edge ) switch( m_edge )
{ {
@ -411,9 +413,9 @@ void SCH_SHEET_PIN::MirrorX( int aXaxis_position )
void SCH_SHEET_PIN::MirrorY( int aYaxis_position ) void SCH_SHEET_PIN::MirrorY( int aYaxis_position )
{ {
int p = m_Pos.x - aYaxis_position; int p = GetTextPos().x - aYaxis_position;
m_Pos.x = aYaxis_position - p; SetTextX( aYaxis_position - p );
switch( m_edge ) switch( m_edge )
{ {
@ -433,7 +435,9 @@ void SCH_SHEET_PIN::MirrorY( int aYaxis_position )
void SCH_SHEET_PIN::Rotate( wxPoint aPosition ) void SCH_SHEET_PIN::Rotate( wxPoint aPosition )
{ {
RotatePoint( &m_Pos, aPosition, 900 ); wxPoint pt = GetTextPos();
RotatePoint( &pt, aPosition, 900 );
SetTextPos( pt );
switch( m_edge ) switch( m_edge )
{ {
@ -489,7 +493,7 @@ void SCH_SHEET_PIN::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wx
void SCH_SHEET_PIN::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) void SCH_SHEET_PIN::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
{ {
DANGLING_END_ITEM item( SHEET_LABEL_END, this, m_Pos ); DANGLING_END_ITEM item( SHEET_LABEL_END, this, GetTextPos() );
aItemList.push_back( item ); aItemList.push_back( item );
} }

File diff suppressed because it is too large Load Diff

View File

@ -54,6 +54,7 @@ enum PINSHEETLABEL_SHAPE {
extern const char* SheetLabelType[]; /* names of types of labels */ extern const char* SheetLabelType[]; /* names of types of labels */
class SCH_TEXT : public SCH_ITEM, public EDA_TEXT class SCH_TEXT : public SCH_ITEM, public EDA_TEXT
{ {
protected: protected:
@ -70,9 +71,9 @@ protected:
* 2 is horizontal and right justified. It is the equivalent of the mirrored 0 orentation. * 2 is horizontal and right justified. It is the equivalent of the mirrored 0 orentation.
* 3 is veritcal and bottom justifiend. It is the equivalent of the mirrored 1 orentation. * 3 is veritcal and bottom justifiend. It is the equivalent of the mirrored 1 orentation.
* This is a duplicattion of m_Orient, m_HJustified, and m_VJustified in #EDA_TEXT but is * This is a duplicattion of m_Orient, m_HJustified, and m_VJustified in #EDA_TEXT but is
* easier to handle that 3 parameters when editing and reading and saving files. * easier to handle than 3 parameters when editing and reading and saving files.
*/ */
int m_schematicOrientation; int m_spin_style;
public: public:
SCH_TEXT( const wxPoint& pos = wxPoint( 0, 0 ), SCH_TEXT( const wxPoint& pos = wxPoint( 0, 0 ),
@ -104,22 +105,20 @@ public:
void IncrementLabel( int aIncrement ); void IncrementLabel( int aIncrement );
/** /**
* Function SetOrientation * Function SetLabelSpinStyle
* Set m_schematicOrientation, and initialize * sets a spin or rotation angle, along with specific horizontal and vertical
* m_orient,m_HJustified and m_VJustified, according to the value of * justification styles with each angle.
* m_schematicOrientation (for a text ) *
* must be called after changing m_schematicOrientation * @param aSpinStyle =
* @param aSchematicOrientation =
* 0 = normal (horizontal, left justified). * 0 = normal (horizontal, left justified).
* 1 = up (vertical) * 1 = up (vertical)
* 2 = (horizontal, right justified). This can be seen as the mirrored position of 0 * 2 = (horizontal, right justified). This can be seen as the mirrored position of 0
* 3 = bottom . This can be seen as the mirrored position of up * 3 = bottom . This can be seen as the mirrored position of up
*/ */
virtual void SetOrientation( int aSchematicOrientation ); virtual void SetLabelSpinStyle( int aSpinStyle );
int GetLabelSpinStyle() const { return m_spin_style; }
int GetOrientation() { return m_schematicOrientation; } PINSHEETLABEL_SHAPE GetShape() const { return m_shape; }
PINSHEETLABEL_SHAPE GetShape() const { return m_shape; }
void SetShape( PINSHEETLABEL_SHAPE aShape ) { m_shape = aShape; } void SetShape( PINSHEETLABEL_SHAPE aShape ) { m_shape = aShape; }
@ -161,7 +160,7 @@ public:
virtual void Move( const wxPoint& aMoveVector ) override virtual void Move( const wxPoint& aMoveVector ) override
{ {
m_Pos += aMoveVector; EDA_TEXT::Offset( aMoveVector );
} }
virtual void MirrorY( int aYaxis_position ) override; virtual void MirrorY( int aYaxis_position ) override;
@ -198,9 +197,9 @@ public:
virtual void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, virtual void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
SCH_SHEET_PATH* aSheetPath ) override; SCH_SHEET_PATH* aSheetPath ) override;
virtual wxPoint GetPosition() const override { return m_Pos; } virtual wxPoint GetPosition() const override { return EDA_TEXT::GetTextPos(); }
virtual void SetPosition( const wxPoint& aPosition ) override { m_Pos = aPosition; } virtual void SetPosition( const wxPoint& aPosition ) override { EDA_TEXT::SetTextPos( aPosition ); }
virtual bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override; virtual bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override;
@ -236,7 +235,7 @@ public:
return wxT( "SCH_LABEL" ); return wxT( "SCH_LABEL" );
} }
void SetOrientation( int aSchematicOrientation ) override; void SetLabelSpinStyle( int aSpinStyle ) override;
wxPoint GetSchematicTextOffset() const override; wxPoint GetSchematicTextOffset() const override;
@ -261,7 +260,7 @@ public:
EDA_ITEM* Clone() const override; EDA_ITEM* Clone() const override;
private: private:
bool doIsConnected( const wxPoint& aPosition ) const override { return m_Pos == aPosition; } bool doIsConnected( const wxPoint& aPosition ) const override { return EDA_TEXT::GetTextPos() == aPosition; }
}; };
@ -282,7 +281,7 @@ public:
return wxT( "SCH_GLOBALLABEL" ); return wxT( "SCH_GLOBALLABEL" );
} }
void SetOrientation( int aSchematicOrientation ) override; void SetLabelSpinStyle( int aSpinStyle ) override;
wxPoint GetSchematicTextOffset() const override; wxPoint GetSchematicTextOffset() const override;
@ -309,7 +308,7 @@ public:
EDA_ITEM* Clone() const override; EDA_ITEM* Clone() const override;
private: private:
bool doIsConnected( const wxPoint& aPosition ) const override { return m_Pos == aPosition; } bool doIsConnected( const wxPoint& aPosition ) const override { return EDA_TEXT::GetTextPos() == aPosition; }
}; };
@ -332,7 +331,7 @@ public:
return wxT( "SCH_HIERLABEL" ); return wxT( "SCH_HIERLABEL" );
} }
void SetOrientation( int aSchematicOrientation ) override; void SetLabelSpinStyle( int aSpinStyle ) override;
wxPoint GetSchematicTextOffset() const override; wxPoint GetSchematicTextOffset() const override;
@ -359,7 +358,7 @@ public:
EDA_ITEM* Clone() const override; EDA_ITEM* Clone() const override;
private: private:
bool doIsConnected( const wxPoint& aPosition ) const override { return m_Pos == aPosition; } bool doIsConnected( const wxPoint& aPosition ) const override { return EDA_TEXT::GetTextPos() == aPosition; }
}; };
#endif /* CLASS_TEXT_LABEL_H */ #endif /* CLASS_TEXT_LABEL_H */

View File

@ -66,9 +66,9 @@ int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, bool aRedraw )
DIALOG_SCH_EDIT_SHEET_PIN dlg( this ); DIALOG_SCH_EDIT_SHEET_PIN dlg( this );
dlg.SetLabelName( aSheetPin->GetText() ); dlg.SetLabelName( aSheetPin->GetText() );
dlg.SetTextHeight( StringFromValue( g_UserUnit, aSheetPin->GetSize().y ) ); dlg.SetTextHeight( StringFromValue( g_UserUnit, aSheetPin->GetTextHeight() ) );
dlg.SetTextHeightUnits( GetUnitsLabel( g_UserUnit ) ); dlg.SetTextHeightUnits( GetUnitsLabel( g_UserUnit ) );
dlg.SetTextWidth( StringFromValue( g_UserUnit, aSheetPin->GetSize().x ) ); dlg.SetTextWidth( StringFromValue( g_UserUnit, aSheetPin->GetTextWidth() ) );
dlg.SetTextWidthUnits( GetUnitsLabel( g_UserUnit ) ); dlg.SetTextWidthUnits( GetUnitsLabel( g_UserUnit ) );
dlg.SetConnectionType( aSheetPin->GetShape() ); dlg.SetConnectionType( aSheetPin->GetShape() );
@ -91,8 +91,11 @@ int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, bool aRedraw )
} }
aSheetPin->SetText( dlg.GetLabelName() ); aSheetPin->SetText( dlg.GetLabelName() );
aSheetPin->SetSize( wxSize( ValueFromString( g_UserUnit, dlg.GetTextWidth() ),
ValueFromString( g_UserUnit, dlg.GetTextHeight() ) ) ); aSheetPin->SetTextSize( wxSize(
ValueFromString( g_UserUnit, dlg.GetTextWidth() ),
ValueFromString( g_UserUnit, dlg.GetTextHeight() ) ) );
aSheetPin->SetShape( dlg.GetConnectionType() ); aSheetPin->SetShape( dlg.GetConnectionType() );
OnModify(); OnModify();
@ -111,7 +114,7 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet, wxDC* aDC )
sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), line ); sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), line );
sheetPin->SetFlags( IS_NEW ); sheetPin->SetFlags( IS_NEW );
sheetPin->SetSize( GetLastSheetPinTextSize() ); sheetPin->SetTextSize( GetLastSheetPinTextSize() );
sheetPin->SetShape( m_lastSheetPinType ); sheetPin->SetShape( m_lastSheetPinType );
int response = EditSheetPin( sheetPin, false ); int response = EditSheetPin( sheetPin, false );
@ -123,7 +126,7 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet, wxDC* aDC )
} }
m_lastSheetPinType = sheetPin->GetShape(); m_lastSheetPinType = sheetPin->GetShape();
m_lastSheetPinTextSize = sheetPin->GetSize(); m_lastSheetPinTextSize = sheetPin->GetTextSize();
sheetPin->SetPosition( GetCrossHairPosition() ); sheetPin->SetPosition( GetCrossHairPosition() );
sheetPin->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode ); sheetPin->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode );
@ -167,7 +170,7 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::ImportSheetPin( SCH_SHEET* aSheet, wxDC* aDC )
sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), label->GetText() ); sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), label->GetText() );
sheetPin->SetFlags( IS_NEW ); sheetPin->SetFlags( IS_NEW );
sheetPin->SetSize( GetLastSheetPinTextSize() ); sheetPin->SetTextSize( GetLastSheetPinTextSize() );
m_lastSheetPinType = label->GetShape(); m_lastSheetPinType = label->GetShape();
sheetPin->SetShape( label->GetShape() ); sheetPin->SetShape( label->GetShape() );
sheetPin->SetPosition( GetCrossHairPosition() ); sheetPin->SetPosition( GetCrossHairPosition() );

View File

@ -147,7 +147,7 @@ static void AbortSymbolTraceOn( EDA_DRAW_PANEL* Panel, wxDC* DC )
} }
LIB_ITEM* LIB_EDIT_FRAME::CreateGraphicItem( LIB_PART* LibEntry, wxDC* DC ) LIB_ITEM* LIB_EDIT_FRAME::CreateGraphicItem( LIB_PART* LibEntry, wxDC* DC )
{ {
m_canvas->SetMouseCapture( SymbolDisplayDraw, AbortSymbolTraceOn ); m_canvas->SetMouseCapture( SymbolDisplayDraw, AbortSymbolTraceOn );
wxPoint drawPos = GetCrossHairPosition( true ); wxPoint drawPos = GetCrossHairPosition( true );
@ -176,24 +176,25 @@ LIB_ITEM* LIB_EDIT_FRAME::CreateGraphicItem( LIB_PART* LibEntry, wxDC* DC )
case ID_LIBEDIT_BODY_TEXT_BUTT: case ID_LIBEDIT_BODY_TEXT_BUTT:
{ {
LIB_TEXT* Text = new LIB_TEXT( LibEntry ); LIB_TEXT* text = new LIB_TEXT( LibEntry );
Text->SetSize( wxSize( m_textSize, m_textSize ) ); text->SetTextSize( wxSize( m_textSize, m_textSize ) );
Text->SetOrientation( m_textOrientation ); text->SetTextAngle( m_current_text_angle );
// Enter the graphic text info // Enter the graphic text info
m_canvas->SetIgnoreMouseEvents( true ); m_canvas->SetIgnoreMouseEvents( true );
EditSymbolText( NULL, Text ); EditSymbolText( NULL, text );
m_canvas->SetIgnoreMouseEvents( false ); m_canvas->SetIgnoreMouseEvents( false );
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
if( Text->GetText().IsEmpty() ) if( text->GetText().IsEmpty() )
{ {
delete Text; delete text;
m_drawItem = NULL; m_drawItem = NULL;
} }
else else
{ {
m_drawItem = Text; m_drawItem = text;
} }
} }
break; break;

View File

@ -407,7 +407,7 @@ void GBR_LAYOUT::DrawItemsDCodeID( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
else else
width = std::min( item->m_Size.x, item->m_Size.y ); width = std::min( item->m_Size.x, item->m_Size.y );
double orient = TEXT_ORIENT_HORIZ; double orient = TEXT_ANGLE_HORIZ;
if( item->m_Flashed ) if( item->m_Flashed )
{ {
@ -419,7 +419,7 @@ void GBR_LAYOUT::DrawItemsDCodeID( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
wxPoint delta = item->m_Start - item->m_End; wxPoint delta = item->m_Start - item->m_End;
if( abs( delta.x ) < abs( delta.y ) ) if( abs( delta.x ) < abs( delta.y ) )
orient = TEXT_ORIENT_VERT; orient = TEXT_ANGLE_VERT;
// A reasonable size for text is width/2 because text needs margin below and above it. // A reasonable size for text is width/2 because text needs margin below and above it.
// a margin = width/4 seems good // a margin = width/4 seems good

View File

@ -107,11 +107,10 @@ enum pseudokeys {
#endif #endif
// Graphic Texts Orientation in 0.1 degree /// Frequent text rotations, used with {Set,Get}TextAngle(),
#define TEXT_ORIENT_HORIZ 0 /// in 0.1 degrees for now, hoping to migrate to degrees eventually.
#define TEXT_ORIENT_VERT 900 #define TEXT_ANGLE_HORIZ 0
#define TEXT_ANGLE_VERT 900
//-----<KiROUND KIT>------------------------------------------------------------ //-----<KiROUND KIT>------------------------------------------------------------

View File

@ -65,36 +65,48 @@ enum EDA_DRAW_MODE_T {
* you do not fully realize the effect it has on sexp serialization * you do not fully realize the effect it has on sexp serialization
* (text size equal to this is not explicitly wrote, so it would change * (text size equal to this is not explicitly wrote, so it would change
* subsequent reads) */ * subsequent reads) */
#define DEFAULT_SIZE_TEXT 60 // default text height (in mils, i.e. 1/1000") #define DEFAULT_SIZE_TEXT 60 // default text height (in mils, i.e. 1/1000")
#define TEXT_NO_VISIBLE 1 //< EDA_TEXT::m_Attribut(e?) visibility flag. #define DIM_ANCRE_TEXTE 2 // Anchor size for text
#define DIM_ANCRE_TEXTE 2 // Anchor size for text
/**
* Struct TEXT_EFFECTS
* is a bucket for text effects. These fields are bundled so they
* can be easily copied together as a lot. The privacy policy is established
* by client (incorporating) code.
*/
struct TEXT_EFFECTS
{
TEXT_EFFECTS( int aSetOfBits = 0 ) :
bits( aSetOfBits ),
hjustify( GR_TEXT_HJUSTIFY_CENTER ),
vjustify( GR_TEXT_VJUSTIFY_CENTER ),
penwidth( 0 ),
angle( 0.0 )
{}
short bits; ///< any set of booleans a client uses.
signed char hjustify; ///< horizontal justification
signed char vjustify; ///< vertical justification
wxSize size;
int penwidth;
double angle; ///< now: 0.1 degrees; future: degrees
wxPoint pos;
void Bit( int aBit, bool aValue ) { aValue ? bits |= (1<<aBit) : bits &= ~(1<<aBit); }
bool Bit( int aBit ) const { return bits & (1<<aBit); }
};
/** /**
* Class EDA_TEXT * Class EDA_TEXT
* is a basic class to handle texts (labels, texts on components or footprints * is a mix-in class (via multiple inheritance) that handles texts such as
* ..) not used directly. The "used" text classes are derived from EDA_ITEM and * labels, parts, components, or footprints. Because it's a mix-in class, care
* EDA_TEXT using multiple inheritance. * is used to provide function names (accessors) that to not collide with function
* names likely to be seen in the combined derived classes.
*/ */
class EDA_TEXT class EDA_TEXT
{ {
protected:
wxString m_Text; ///< The 'base' text, maybe later processed for display
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: public:
EDA_TEXT( const wxString& text = wxEmptyString ); EDA_TEXT( const wxString& text = wxEmptyString );
@ -124,74 +136,93 @@ public:
/** /**
* Function SetThickness * Function SetThickness
* sets text thickness. * sets pen width.
* @param aNewThickness is the new text thickness. * @param aNewThickness is the new pen width
*/ */
void SetThickness( int aNewThickness ) { m_Thickness = aNewThickness; }; void SetThickness( int aNewThickness ) { m_e.penwidth = aNewThickness; };
/** /**
* Function GetThickness * Function GetThickness
* returns text thickness. * returns pen width.
* @return int - text thickness.
*/ */
int GetThickness() const { return m_Thickness; }; int GetThickness() const { return m_e.penwidth; };
void SetOrientation( double aOrientation ); void SetTextAngle( double aAngle )
void SetOrientationDegrees( double aOrientation ) { SetOrientation( aOrientation*10.0 ); }
double GetOrientation() const { return m_Orient; }
double GetOrientationDegrees() const { return m_Orient/10.0; }
double GetOrientationRadians() const { return m_Orient*M_PI/1800; }
void SetItalic( bool isItalic ) { m_Italic = isItalic; }
bool IsItalic() const { return m_Italic; }
void SetBold( bool aBold ) { m_Bold = aBold; }
bool IsBold() const { return m_Bold; }
void SetVisible( bool aVisible )
{ {
( aVisible ) ? m_Attributs &= ~TEXT_NO_VISIBLE : m_Attributs |= TEXT_NO_VISIBLE; // Higher level classes may be more restrictive than this by
// overloading SetTextAngle() (probably non-virtual) or merely
// calling EDA_TEXT::SetTextAngle() after clamping aAngle
// before calling this lowest inline accessor.
m_e.angle = aAngle;
} }
bool IsVisible() const { return !( m_Attributs & TEXT_NO_VISIBLE ); } double GetTextAngle() const { return m_e.angle; }
void SetMirrored( bool isMirrored ) { m_Mirror = isMirrored; } double GetTextAngleDegrees() const { return GetTextAngle() / 10.0; }
bool IsMirrored() const { return m_Mirror; } double GetTextAngleRadians() const { return GetTextAngle() * M_PI/1800; }
void SetAttributes( int aAttributes ) { m_Attributs = aAttributes; } void SetItalic( bool isItalic ) { m_e.Bit( TE_ITALIC, isItalic ); }
int GetAttributes() const { return m_Attributs; } bool IsItalic() const { return m_e.Bit( TE_ITALIC ); }
void SetBold( bool aBold ) { m_e.Bit( TE_BOLD, aBold); }
bool IsBold() const { return m_e.Bit( TE_BOLD ); }
void SetVisible( bool aVisible ) { m_e.Bit( TE_VISIBLE, aVisible ); }
bool IsVisible() const { return m_e.Bit( TE_VISIBLE ); }
void SetMirrored( bool isMirrored ) { m_e.Bit( TE_MIRROR, isMirrored ); }
bool IsMirrored() const { return m_e.Bit( TE_MIRROR ); }
/**
* Function SetMultiLineAllowed
* @param aAllow true if ok to use multiline option, false
* if ok to use only single line text. (Single line is faster in
* calculations than multiline.)
*/
void SetMultilineAllowed( bool aAllow ) { m_e.Bit( TE_MULTILINE, aAllow ); }
bool IsMultilineAllowed() const { return m_e.Bit( TE_MULTILINE ); }
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const { return EDA_TEXT_HJUSTIFY_T( m_e.hjustify ); };
EDA_TEXT_VJUSTIFY_T GetVertJustify() const { return EDA_TEXT_VJUSTIFY_T( m_e.vjustify ); };
void SetHorizJustify( EDA_TEXT_HJUSTIFY_T aType ) { m_e.hjustify = aType; };
void SetVertJustify( EDA_TEXT_VJUSTIFY_T aType ) { m_e.vjustify = aType; };
/**
* Function SetEffects
* sets the text effects from another instance. (TEXT_EFFECTS
* is not exposed in the public API, but includes everything except the actual
* text string itself.)
*/
void SetEffects( const EDA_TEXT& aSrc );
/**
* Function SwapEffects
* swaps the text effects of the two involved instances. (TEXT_EFECTS
* is not exposed in the public API, but includes everything except the actual
* text string itself.)
*/
void SwapEffects( EDA_TEXT& aTradingPartner );
bool IsDefaultFormatting() const; bool IsDefaultFormatting() const;
/** void SetTextSize( const wxSize& aNewSize ) { m_e.size = aNewSize; };
* Function SetSize const wxSize& GetTextSize() const { return m_e.size; };
* sets text size.
* @param aNewSize is the new text size.
*/
void SetSize( const wxSize& aNewSize ) { m_Size = aNewSize; };
/** void SetTextWidth( int aWidth ) { m_e.size.x = aWidth; }
* Function GetSize int GetTextWidth() const { return m_e.size.x; }
* returns text size.
* @return wxSize - text size.
*/
const wxSize& GetSize() const { return m_Size; };
void SetWidth( int aWidth ) { m_Size.x = aWidth; } void SetTextHeight( int aHeight ) { m_e.size.y = aHeight; }
int GetWidth() const { return m_Size.x; } int GetTextHeight() const { return m_e.size.y; }
void SetHeight( int aHeight ) { m_Size.y = aHeight; } void SetTextPos( const wxPoint& aPoint ) { m_e.pos = aPoint; }
int GetHeight() const { return m_Size.y; } const wxPoint& GetTextPos() const { return m_e.pos; }
/// named differently than the ones using multiple inheritance and including this class void SetTextX( int aX ) { m_e.pos.x = aX; }
void SetTextPosition( const wxPoint& aPoint ) { m_Pos = aPoint; } void SetTextY( int aY ) { m_e.pos.y = aY; }
const wxPoint& GetTextPosition() const { return m_Pos; }
void SetMultilineAllowed( bool aAllow ) { m_MultilineAllowed = aAllow; } void Offset( const wxPoint& aOffset ) { m_e.pos += aOffset; }
bool IsMultilineAllowed() const { return m_MultilineAllowed; }
void Offset( const wxPoint& aOffset ) { m_Pos += aOffset; } void Empty() { m_Text.Empty(); }
void Empty() { m_Text.Empty(); }
/** /**
* Function Draw * Function Draw
@ -256,9 +287,8 @@ public:
* @param aLine The line of text to consider. * @param aLine The line of text to consider.
* for single line text, aLine is unused * for single line text, aLine is unused
* If aLine == -1, the full area (considering all lines) is returned * If aLine == -1, the full area (considering all lines) is returned
* @param aThickness Overrides the current thickness when greater than 0. * @param aThickness Overrides the current penwidth when greater than 0.
* this is needed when the current m_Thickness is 0 and a default line thickness * This is needed when the current penwidth is 0 and a default penwidth is used.
* is used
* @param aInvertY Invert the Y axis when calculating bounding box. * @param aInvertY Invert the Y axis when calculating bounding box.
*/ */
EDA_RECT GetTextBox( int aLine = -1, int aThickness = -1, bool aInvertY = false ) const; EDA_RECT GetTextBox( int aLine = -1, int aThickness = -1, bool aInvertY = false ) const;
@ -267,6 +297,12 @@ public:
* Function GetInterline * Function GetInterline
* return the distance between 2 text lines * return the distance between 2 text lines
* has meaning only for multiline texts * has meaning only for multiline texts
* <p>
* Calculates the distance (pitch) between 2 text lines
* the distance includes the interline + room for chars like j { and [
* Is used for multiline texts, but also for single line texts, to calculate
* the text bounding box
*.
* @param aTextThickness Overrides the current thickness when greater than 0. * @param aTextThickness Overrides the current thickness when greater than 0.
* this is needed when the current m_Thickness is 0 and a default line thickness * this is needed when the current m_Thickness is 0 and a default line thickness
* is used * is used
@ -279,12 +315,6 @@ public:
*/ */
wxString GetTextStyleName(); wxString GetTextStyleName();
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 GetPositionsOfLinesOfMultilineText * Function GetPositionsOfLinesOfMultilineText
* Populates aPositions with the position of each line of * Populates aPositions with the position of each line of
@ -308,11 +338,13 @@ public:
virtual void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const virtual void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR ); throw( IO_ERROR );
private: protected:
wxString m_Text;
private:
/** /**
* Function drawOneLineOfText * Function drawOneLineOfText
* Draw a single text line. * draws a single text line.
* Used to draw each line of this EDA_TEXT, that can be multiline * Used to draw each line of this EDA_TEXT, that can be multiline
* @param aClipBox = the clipping rect, or NULL if no clipping * @param aClipBox = the clipping rect, or NULL if no clipping
* @param aDC = the current Device Context * @param aDC = the current Device Context
@ -326,7 +358,20 @@ private:
void drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC, void drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC,
const wxPoint& aOffset, EDA_COLOR_T aColor, const wxPoint& aOffset, EDA_COLOR_T aColor,
GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aFillMode, GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aFillMode,
const wxString& aText, const wxPoint &aPos ); const wxString& aText, const wxPoint& aPos );
// Private text effects data. API above provides accessor funcs.
TEXT_EFFECTS m_e;
/// EDA_TEXT effects bools
enum TE_FLAGS {
// start at zero, sequence is irrelevant
TE_MIRROR,
TE_ITALIC,
TE_BOLD,
TE_MULTILINE,
TE_VISIBLE,
};
}; };

View File

@ -103,9 +103,14 @@ static inline const wxChar* GetChars( const wxString& s )
* Mirror @a aPoint in @a aMirrorRef. * Mirror @a aPoint in @a aMirrorRef.
*/ */
template<typename T> template<typename T>
T Mirror( T aPoint, T aMirrorRef )
{
return -( aPoint - aMirrorRef ) + aMirrorRef;
}
template<typename T>
void MIRROR( T& aPoint, const T& aMirrorRef ) void MIRROR( T& aPoint, const T& aMirrorRef )
{ {
aPoint = -( aPoint - aMirrorRef ) + aMirrorRef; aPoint = Mirror( aPoint, aMirrorRef );
} }

View File

@ -199,32 +199,45 @@ inline double RAD2DECIDEG( double rad ) { return rad * 1800.0 / M_PI; }
is still using int for angles in some place */ is still using int for angles in some place */
/// Normalize angle to be in the -360.0 .. 360.0: /// Normalize angle to be in the -360.0 .. 360.0:
template <class T> inline void NORMALIZE_ANGLE_360( T &Angle ) template <class T> inline T NormalizeAngle360( T Angle )
{ {
while( Angle <= -3600 ) while( Angle <= -3600 )
Angle += 3600; Angle += 3600;
while( Angle >= 3600 ) while( Angle >= 3600 )
Angle -= 3600; Angle -= 3600;
return Angle;
} }
/// Normalize angle to be in the 0.0 .. 360.0 range: /// Normalize angle to be in the 0.0 .. 360.0 range:
/// angle is in 1/10 degees /// angle is in 1/10 degees
template <class T> inline void NORMALIZE_ANGLE_POS( T &Angle ) template <class T> inline T NormalizeAnglePos( T Angle )
{ {
while( Angle < 0 ) while( Angle < 0 )
Angle += 3600; Angle += 3600;
while( Angle >= 3600 ) while( Angle >= 3600 )
Angle -= 3600; Angle -= 3600;
return Angle;
} }
template <class T> inline void NORMALIZE_ANGLE_POS( T& Angle )
{
Angle = NormalizeAnglePos( Angle );
}
/// Normalize angle to be in the 0.0 .. 360.0 range: /// Normalize angle to be in the 0.0 .. 360.0 range:
/// angle is in degrees /// angle is in degrees
inline void NORMALIZE_ANGLE_DEGREES_POS( double &Angle ) inline double NormalizeAngleDegreesPos( double Angle )
{ {
while( Angle < 0 ) while( Angle < 0 )
Angle += 360.0; Angle += 360.0;
while( Angle >= 360.0 ) while( Angle >= 360.0 )
Angle -= 360.0; Angle -= 360.0;
return Angle;
}
inline void NORMALIZE_ANGLE_DEGREES_POS( double& Angle )
{
Angle = NormalizeAngleDegreesPos( Angle );
} }
/// Add two angles (keeping the result normalized). T2 is here /// Add two angles (keeping the result normalized). T2 is here
@ -237,32 +250,50 @@ template <class T, class T2> inline T AddAngles( T a1, T2 a2 )
return a1; return a1;
} }
template <class T> inline void NEGATE_AND_NORMALIZE_ANGLE_POS( T &Angle ) template <class T> inline T NegateAndNormalizeAnglePos( T Angle )
{ {
Angle = -Angle; Angle = -Angle;
while( Angle < 0 ) while( Angle < 0 )
Angle += 3600; Angle += 3600;
while( Angle >= 3600 ) while( Angle >= 3600 )
Angle -= 3600; Angle -= 3600;
return Angle;
}
template <class T> inline void NEGATE_AND_NORMALIZE_ANGLE_POS( T& Angle )
{
Angle = NegateAndNormalizeAnglePos( Angle );
} }
/// Normalize angle to be in the -90.0 .. 90.0 range /// Normalize angle to be in the -90.0 .. 90.0 range
template <class T> inline void NORMALIZE_ANGLE_90( T &Angle ) template <class T> inline T NormalizeAngle90( T Angle )
{ {
while( Angle < -900 ) while( Angle < -900 )
Angle += 1800; Angle += 1800;
while( Angle > 900 ) while( Angle > 900 )
Angle -= 1800; Angle -= 1800;
return Angle;
}
template <class T> inline void NORMALIZE_ANGLE_90( T& Angle )
{
Angle = NormalizeAngle90( Angle );
} }
/// Normalize angle to be in the -180.0 .. 180.0 range /// Normalize angle to be in the -180.0 .. 180.0 range
template <class T> inline void NORMALIZE_ANGLE_180( T &Angle ) template <class T> inline T NormalizeAngle180( T Angle )
{ {
while( Angle <= -1800 ) while( Angle <= -1800 )
Angle += 3600; Angle += 3600;
while( Angle > 1800 ) while( Angle > 1800 )
Angle -= 3600; Angle -= 3600;
return Angle;
} }
template <class T> inline void NORMALIZE_ANGLE_180( T& Angle )
{
Angle = NormalizeAngle180( Angle );
}
/** /**
* Circle generation utility: computes r * sin(a) * Circle generation utility: computes r * sin(a)

View File

@ -297,6 +297,11 @@ public:
// Accessors: // Accessors:
int GetPenWidth() { return GetThickness(); } int GetPenWidth() { return GetThickness(); }
void SetTextAngle( double aAngle )
{
EDA_TEXT::SetTextAngle( NormalizeAngle360( aAngle ) );
}
/** /**
* Virtual function * Virtual function
* return true if the point aPosition is on the text * return true if the point aPosition is on the text

View File

@ -302,12 +302,12 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag )
layerMask = LSET( PtText->GetLayer() ); layerMask = LSET( PtText->GetLayer() );
TraceFilledRectangle( ux0 - marge, uy0 - marge, ux1 + marge, TraceFilledRectangle( ux0 - marge, uy0 - marge, ux1 + marge,
uy1 + marge, PtText->GetOrientation(), uy1 + marge, PtText->GetTextAngle(),
layerMask, HOLE, WRITE_CELL ); layerMask, HOLE, WRITE_CELL );
TraceFilledRectangle( ux0 - via_marge, uy0 - via_marge, TraceFilledRectangle( ux0 - via_marge, uy0 - via_marge,
ux1 + via_marge, uy1 + via_marge, ux1 + via_marge, uy1 + via_marge,
PtText->GetOrientation(), PtText->GetTextAngle(),
layerMask, VIA_IMPOSSIBLE, WRITE_OR_CELL ); layerMask, VIA_IMPOSSIBLE, WRITE_OR_CELL );
} }
break; break;

View File

@ -809,7 +809,7 @@ int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect )
ClearMarkItems( module ); // Just in case ... ClearMarkItems( module ); // Just in case ...
pos = module->Reference().GetTextPosition(); pos = module->Reference().GetTextPos();
if( Rect.Contains( pos ) ) if( Rect.Contains( pos ) )
{ {
@ -817,7 +817,7 @@ int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect )
ItemsCount++; ItemsCount++;
} }
pos = module->Value().GetTextPosition(); pos = module->Value().GetTextPos();
if( Rect.Contains( pos ) ) if( Rect.Contains( pos ) )
{ {
@ -857,7 +857,7 @@ int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect )
break; break;
case PCB_MODULE_TEXT_T: case PCB_MODULE_TEXT_T:
pos = static_cast<TEXTE_MODULE*>( item )->GetTextPosition(); pos = static_cast<TEXTE_MODULE*>( item )->GetTextPos();
if( Rect.Contains( pos ) ) if( Rect.Contains( pos ) )
{ {

View File

@ -259,12 +259,12 @@ void MODULE::TransformGraphicShapesWithClearanceToPolygonSet(
{ {
TEXTE_MODULE *textmod = texts[ii]; TEXTE_MODULE *textmod = texts[ii];
s_textWidth = textmod->GetThickness() + ( 2 * aInflateValue ); s_textWidth = textmod->GetThickness() + ( 2 * aInflateValue );
wxSize size = textmod->GetSize(); wxSize size = textmod->GetTextSize();
if( textmod->IsMirrored() ) if( textmod->IsMirrored() )
size.x = -size.x; size.x = -size.x;
DrawGraphicText( NULL, NULL, textmod->GetTextPosition(), BLACK, DrawGraphicText( NULL, NULL, textmod->GetTextPos(), BLACK,
textmod->GetShownText(), textmod->GetDrawRotation(), size, textmod->GetShownText(), textmod->GetDrawRotation(), size,
textmod->GetHorizJustify(), textmod->GetVertJustify(), textmod->GetHorizJustify(), textmod->GetVertJustify(),
textmod->GetThickness(), textmod->IsItalic(), textmod->GetThickness(), textmod->IsItalic(),
@ -328,12 +328,12 @@ void MODULE::TransformGraphicTextWithClearanceToPolygonSet(
{ {
TEXTE_MODULE *textmod = texts[ii]; TEXTE_MODULE *textmod = texts[ii];
s_textWidth = textmod->GetThickness() + ( 2 * aInflateValue ); s_textWidth = textmod->GetThickness() + ( 2 * aInflateValue );
wxSize size = textmod->GetSize(); wxSize size = textmod->GetTextSize();
if( textmod->IsMirrored() ) if( textmod->IsMirrored() )
size.x = -size.x; size.x = -size.x;
DrawGraphicText( NULL, NULL, textmod->GetTextPosition(), BLACK, DrawGraphicText( NULL, NULL, textmod->GetTextPos(), BLACK,
textmod->GetShownText(), textmod->GetDrawRotation(), size, textmod->GetShownText(), textmod->GetDrawRotation(), size,
textmod->GetHorizJustify(), textmod->GetVertJustify(), textmod->GetHorizJustify(), textmod->GetVertJustify(),
textmod->GetThickness(), textmod->IsItalic(), textmod->GetThickness(), textmod->IsItalic(),
@ -413,7 +413,7 @@ void TEXTE_PCB::TransformBoundingBoxWithClearanceToPolygon(
for( int ii = 0; ii < 4; ii++ ) for( int ii = 0; ii < 4; ii++ )
{ {
// Rotate polygon // Rotate polygon
RotatePoint( &corners[ii].x, &corners[ii].y, m_Pos.x, m_Pos.y, m_Orient ); RotatePoint( &corners[ii].x, &corners[ii].y, GetTextPos().x, GetTextPos().y, GetTextAngle() );
aCornerBuffer.Append( corners[ii].x, corners[ii].y ); aCornerBuffer.Append( corners[ii].x, corners[ii].y );
} }
} }
@ -437,7 +437,7 @@ void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(
int aCircleToSegmentsCount, int aCircleToSegmentsCount,
double aCorrectionFactor ) const double aCorrectionFactor ) const
{ {
wxSize size = GetSize(); wxSize size = GetTextSize();
if( IsMirrored() ) if( IsMirrored() )
size.x = -size.x; size.x = -size.x;
@ -459,7 +459,7 @@ void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(
{ {
wxString txt = strings_list.Item( ii ); wxString txt = strings_list.Item( ii );
DrawGraphicText( NULL, NULL, positions[ii], color, DrawGraphicText( NULL, NULL, positions[ii], color,
txt, GetOrientation(), size, txt, GetTextAngle(), size,
GetHorizJustify(), GetVertJustify(), GetHorizJustify(), GetVertJustify(),
GetThickness(), IsItalic(), GetThickness(), IsItalic(),
true, addTextSegmToPoly ); true, addTextSegmToPoly );
@ -467,8 +467,8 @@ void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(
} }
else else
{ {
DrawGraphicText( NULL, NULL, GetTextPosition(), color, DrawGraphicText( NULL, NULL, GetTextPos(), color,
GetShownText(), GetOrientation(), size, GetShownText(), GetTextAngle(), size,
GetHorizJustify(), GetVertJustify(), GetHorizJustify(), GetVertJustify(),
GetThickness(), IsItalic(), GetThickness(), IsItalic(),
true, addTextSegmToPoly ); true, addTextSegmToPoly );

View File

@ -2550,6 +2550,16 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
// will be used // will be used
footprint->CopyNetlistSettings( newFootprint, false ); footprint->CopyNetlistSettings( newFootprint, false );
// Compare the footprint name only, in case the nickname is empty or in case
// user moved the footprint to a new library. Chances are if footprint name is
// same then the footprint is very nearly the same and the two texts should
// be kept at same size, position, and rotation.
if( newFootprint->GetFPID().GetLibItemName() == footprint->GetFPID().GetLibItemName() )
{
newFootprint->Reference().SetEffects( footprint->Reference() );
newFootprint->Value().SetEffects( footprint->Value() );
}
Remove( footprint ); Remove( footprint );
Add( newFootprint, ADD_APPEND ); Add( newFootprint, ADD_APPEND );
footprint = newFootprint; footprint = newFootprint;

View File

@ -60,13 +60,13 @@ DIMENSION::~DIMENSION()
void DIMENSION::SetPosition( const wxPoint& aPos ) void DIMENSION::SetPosition( const wxPoint& aPos )
{ {
m_Text.SetTextPosition( aPos ); m_Text.SetTextPos( aPos );
} }
const wxPoint& DIMENSION::GetPosition() const const wxPoint& DIMENSION::GetPosition() const
{ {
return m_Text.GetTextPosition(); return m_Text.GetTextPos();
} }
@ -91,7 +91,8 @@ void DIMENSION::SetLayer( LAYER_ID aLayer )
void DIMENSION::Move( const wxPoint& offset ) void DIMENSION::Move( const wxPoint& offset )
{ {
m_Text.SetTextPosition( m_Text.GetTextPosition() + offset ); m_Text.Offset( offset );
m_crossBarO += offset; m_crossBarO += offset;
m_crossBarF += offset; m_crossBarF += offset;
m_featureLineGO += offset; m_featureLineGO += offset;
@ -107,11 +108,11 @@ void DIMENSION::Move( const wxPoint& offset )
void DIMENSION::Rotate( const wxPoint& aRotCentre, double aAngle ) void DIMENSION::Rotate( const wxPoint& aRotCentre, double aAngle )
{ {
wxPoint tmp = m_Text.GetTextPosition(); wxPoint tmp = m_Text.GetTextPos();
RotatePoint( &tmp, aRotCentre, aAngle ); RotatePoint( &tmp, aRotCentre, aAngle );
m_Text.SetTextPosition( tmp ); m_Text.SetTextPos( tmp );
double newAngle = m_Text.GetOrientation() + aAngle; double newAngle = m_Text.GetTextAngle() + aAngle;
if( newAngle >= 3600 ) if( newAngle >= 3600 )
newAngle -= 3600; newAngle -= 3600;
@ -119,7 +120,7 @@ void DIMENSION::Rotate( const wxPoint& aRotCentre, double aAngle )
if( newAngle > 900 && newAngle < 2700 ) if( newAngle > 900 && newAngle < 2700 )
newAngle -= 1800; newAngle -= 1800;
m_Text.SetOrientation( newAngle ); m_Text.SetTextAngle( newAngle );
RotatePoint( &m_crossBarO, aRotCentre, aAngle ); RotatePoint( &m_crossBarO, aRotCentre, aAngle );
RotatePoint( &m_crossBarF, aRotCentre, aAngle ); RotatePoint( &m_crossBarF, aRotCentre, aAngle );
@ -146,15 +147,15 @@ void DIMENSION::Flip( const wxPoint& aCentre )
void DIMENSION::Mirror( const wxPoint& axis_pos ) void DIMENSION::Mirror( const wxPoint& axis_pos )
{ {
wxPoint newPos = m_Text.GetTextPosition(); wxPoint newPos = m_Text.GetTextPos();
#define INVERT( pos ) (pos) = axis_pos.y - ( (pos) - axis_pos.y ) #define INVERT( pos ) (pos) = axis_pos.y - ( (pos) - axis_pos.y )
INVERT( newPos.y ); INVERT( newPos.y );
m_Text.SetTextPosition( newPos ); m_Text.SetTextPos( newPos );
// invert angle // invert angle
m_Text.SetOrientation( -m_Text.GetOrientation() ); m_Text.SetTextAngle( -m_Text.GetTextAngle() );
INVERT( m_crossBarO.y ); INVERT( m_crossBarO.y );
INVERT( m_crossBarF.y ); INVERT( m_crossBarF.y );
@ -220,7 +221,7 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText )
m_Text.SetLayer( GetLayer() ); m_Text.SetLayer( GetLayer() );
// calculate the size of the dimension (text + line above the text) // calculate the size of the dimension (text + line above the text)
ii = m_Text.GetSize().y + m_Text.GetThickness() + (m_Width * 3); ii = m_Text.GetTextHeight() + m_Text.GetThickness() + (m_Width * 3);
deltax = m_featureLineDO.x - m_featureLineGO.x; deltax = m_featureLineDO.x - m_featureLineGO.x;
deltay = m_featureLineDO.y - m_featureLineGO.y; deltay = m_featureLineDO.y - m_featureLineGO.y;
@ -291,7 +292,7 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText )
wxPoint textPos; wxPoint textPos;
textPos.x = (m_crossBarF.x + m_featureLineGF.x) / 2; textPos.x = (m_crossBarF.x + m_featureLineGF.x) / 2;
textPos.y = (m_crossBarF.y + m_featureLineGF.y) / 2; textPos.y = (m_crossBarF.y + m_featureLineGF.y) / 2;
m_Text.SetTextPosition( textPos ); m_Text.SetTextPos( textPos );
double newAngle = -RAD2DECIDEG( angle ); double newAngle = -RAD2DECIDEG( angle );
@ -300,7 +301,7 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText )
if( newAngle > 900 && newAngle < 2700 ) if( newAngle > 900 && newAngle < 2700 )
newAngle -= 1800; newAngle -= 1800;
m_Text.SetOrientation( newAngle ); m_Text.SetTextAngle( newAngle );
if( !aDoNotChangeText ) if( !aDoNotChangeText )
{ {

View File

@ -93,15 +93,15 @@ public:
void SetTextSize( const wxSize& aTextSize ) void SetTextSize( const wxSize& aTextSize )
{ {
m_Text.SetSize( aTextSize ); m_Text.SetTextSize( aTextSize );
} }
void SetLayer( LAYER_ID aLayer ) override; void SetLayer( LAYER_ID aLayer ) override;
void SetShape( int aShape ) { m_Shape = aShape; } void SetShape( int aShape ) { m_Shape = aShape; }
int GetShape() const { return m_Shape; } int GetShape() const { return m_Shape; }
int GetWidth() const { return m_Width; } int GetWidth() const { return m_Width; }
void SetWidth( int aWidth ) { m_Width = aWidth; } void SetWidth( int aWidth ) { m_Width = aWidth; }
/** /**

View File

@ -184,9 +184,7 @@ double DRAWSEGMENT::GetArcAngleStart() const
void DRAWSEGMENT::SetAngle( double aAngle ) void DRAWSEGMENT::SetAngle( double aAngle )
{ {
NORMALIZE_ANGLE_360( aAngle ); m_Angle = NormalizeAngle360( aAngle );
m_Angle = aAngle;
} }

View File

@ -958,8 +958,9 @@ void MODULE::SetPosition( const wxPoint& newpos )
wxPoint delta = newpos - m_Pos; wxPoint delta = newpos - m_Pos;
m_Pos += delta; m_Pos += delta;
m_Reference->SetTextPosition( m_Reference->GetTextPosition() + delta );
m_Value->SetTextPosition( m_Value->GetTextPosition() + delta ); m_Reference->EDA_TEXT::Offset( delta );
m_Value->EDA_TEXT::Offset( delta );
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() ) for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{ {
@ -980,7 +981,7 @@ void MODULE::SetPosition( const wxPoint& newpos )
case PCB_MODULE_TEXT_T: case PCB_MODULE_TEXT_T:
{ {
TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item ); TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
text->SetTextPosition( text->GetTextPosition() + delta ); text->EDA_TEXT::Offset( delta );
break; break;
} }

View File

@ -835,8 +835,8 @@ int D_PAD::Compare( const D_PAD* padref, const D_PAD* padcmp )
void D_PAD::Rotate( const wxPoint& aRotCentre, double aAngle ) void D_PAD::Rotate( const wxPoint& aRotCentre, double aAngle )
{ {
RotatePoint( &m_Pos, aRotCentre, aAngle ); RotatePoint( &m_Pos, aRotCentre, aAngle );
m_Orient += aAngle;
NORMALIZE_ANGLE_360( m_Orient ); m_Orient = NormalizeAngle360( m_Orient + aAngle );
SetLocalCoord(); SetLocalCoord();
} }

View File

@ -51,15 +51,21 @@ TEXTE_PCB::TEXTE_PCB( BOARD_ITEM* parent ) :
BOARD_ITEM( parent, PCB_TEXT_T ), BOARD_ITEM( parent, PCB_TEXT_T ),
EDA_TEXT() EDA_TEXT()
{ {
m_MultilineAllowed = true; SetMultilineAllowed( true );
} }
TEXTE_PCB:: ~TEXTE_PCB() TEXTE_PCB::~TEXTE_PCB()
{ {
} }
void TEXTE_PCB::SetTextAngle( double aAngle )
{
EDA_TEXT::SetTextAngle( NormalizeAngle360( aAngle ) );
}
void TEXTE_PCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, void TEXTE_PCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
GR_DRAWMODE DrawMode, const wxPoint& offset ) GR_DRAWMODE DrawMode, const wxPoint& offset )
{ {
@ -118,30 +124,31 @@ void TEXTE_PCB::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), BLUE ) ); aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), BLUE ) );
if( !m_Mirror ) if( !IsMirrored() )
aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), _( "No" ), DARKGREEN ) ); aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), _( "No" ), DARKGREEN ) );
else else
aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), _( "Yes" ), DARKGREEN ) ); aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), _( "Yes" ), DARKGREEN ) );
msg.Printf( wxT( "%.1f" ), m_Orient / 10.0 ); msg.Printf( wxT( "%.1f" ), GetTextAngle() / 10.0 );
aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, DARKGREEN ) ); aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, DARKGREEN ) );
msg = ::CoordinateToString( m_Thickness ); msg = ::CoordinateToString( GetThickness() );
aList.push_back( MSG_PANEL_ITEM( _( "Thickness" ), msg, MAGENTA ) ); aList.push_back( MSG_PANEL_ITEM( _( "Thickness" ), msg, MAGENTA ) );
msg = ::CoordinateToString( m_Size.x ); msg = ::CoordinateToString( GetTextWidth() );
aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, RED ) ); aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, RED ) );
msg = ::CoordinateToString( m_Size.y ); msg = ::CoordinateToString( GetTextHeight() );
aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, RED ) ); aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, RED ) );
} }
const EDA_RECT TEXTE_PCB::GetBoundingBox() const const EDA_RECT TEXTE_PCB::GetBoundingBox() const
{ {
EDA_RECT rect = GetTextBox( -1, -1 ); EDA_RECT rect = GetTextBox( -1, -1 );
if( m_Orient ) if( GetTextAngle() )
rect = rect.GetBoundingBoxRotated( m_Pos, m_Orient ); rect = rect.GetBoundingBoxRotated( GetTextPos(), GetTextAngle() );
return rect; return rect;
} }
@ -149,18 +156,22 @@ const EDA_RECT TEXTE_PCB::GetBoundingBox() const
void TEXTE_PCB::Rotate( const wxPoint& aRotCentre, double aAngle ) void TEXTE_PCB::Rotate( const wxPoint& aRotCentre, double aAngle )
{ {
RotatePoint( &m_Pos, aRotCentre, aAngle ); wxPoint pt = GetTextPos();
m_Orient += aAngle; RotatePoint( &pt, aRotCentre, aAngle );
NORMALIZE_ANGLE_360( m_Orient ); SetTextPos( pt );
SetTextAngle( GetTextAngle() + aAngle );
} }
void TEXTE_PCB::Flip(const wxPoint& aCentre ) void TEXTE_PCB::Flip( const wxPoint& aCentre )
{ {
m_Pos.y = aCentre.y - ( m_Pos.y - aCentre.y ); SetTextY( aCentre.y - ( GetTextPos().y - aCentre.y ) );
int copperLayerCount = GetBoard()->GetCopperLayerCount(); int copperLayerCount = GetBoard()->GetCopperLayerCount();
SetLayer( FlipLayer( GetLayer(), copperLayerCount ) ); SetLayer( FlipLayer( GetLayer(), copperLayerCount ) );
m_Mirror = !m_Mirror; SetMirrored( !IsMirrored() );
} }

View File

@ -57,19 +57,21 @@ public:
virtual const wxPoint& GetPosition() const override virtual const wxPoint& GetPosition() const override
{ {
return m_Pos; return EDA_TEXT::GetTextPos();
} }
virtual void SetPosition( const wxPoint& aPos ) override virtual void SetPosition( const wxPoint& aPos ) override
{ {
m_Pos = aPos; EDA_TEXT::SetTextPos( aPos );
} }
void Move( const wxPoint& aMoveVector ) override void Move( const wxPoint& aMoveVector ) override
{ {
m_Pos += aMoveVector; EDA_TEXT::Offset( aMoveVector );
} }
void SetTextAngle( double aAngle );
void Rotate( const wxPoint& aRotCentre, double aAngle ) override; void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
void Flip( const wxPoint& aCentre ) override; void Flip( const wxPoint& aCentre ) override;

View File

@ -57,20 +57,20 @@ TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, TEXT_TYPE text_type ) :
MODULE* module = static_cast<MODULE*>( m_Parent ); MODULE* module = static_cast<MODULE*>( m_Parent );
m_Type = text_type; m_Type = text_type;
m_NoShow = false;
// Set text thickness to a default value // Set text thickness to a default value
m_Thickness = Millimeter2iu( 0.15 ); SetThickness( Millimeter2iu( 0.15 ) );
SetLayer( F_SilkS ); SetLayer( F_SilkS );
// Set position and give a default layer if a valid parent footprint exists // Set position and give a default layer if a valid parent footprint exists
if( module && ( module->Type() == PCB_MODULE_T ) ) if( module && ( module->Type() == PCB_MODULE_T ) )
{ {
m_Pos = module->GetPosition(); SetTextPos( module->GetPosition() );
if( IsBackLayer( module->GetLayer() ) ) if( IsBackLayer( module->GetLayer() ) )
{ {
SetLayer( B_SilkS ); SetLayer( B_SilkS );
m_Mirror = true; SetMirrored( true );
} }
} }
@ -83,12 +83,22 @@ TEXTE_MODULE::~TEXTE_MODULE()
} }
void TEXTE_MODULE::SetTextAngle( double aAngle )
{
EDA_TEXT::SetTextAngle( NormalizeAngle360( aAngle ) );
}
void TEXTE_MODULE::Rotate( const wxPoint& aRotCentre, double aAngle ) void TEXTE_MODULE::Rotate( const wxPoint& aRotCentre, double aAngle )
{ {
// Used in footprint edition // Used in footprint edition
// Note also in module editor, m_Pos0 = m_Pos // Note also in module editor, m_Pos0 = m_Pos
RotatePoint( &m_Pos, aRotCentre, aAngle );
SetOrientation( GetOrientation() + aAngle ); wxPoint pt = GetTextPos();
RotatePoint( &pt, aRotCentre, aAngle );
SetTextPos( pt );
SetTextAngle( GetTextAngle() + aAngle );
SetLocalCoord(); SetLocalCoord();
} }
@ -96,10 +106,12 @@ void TEXTE_MODULE::Rotate( const wxPoint& aRotCentre, double aAngle )
void TEXTE_MODULE::Flip( const wxPoint& aCentre ) void TEXTE_MODULE::Flip( const wxPoint& aCentre )
{ {
// flipping the footprint is relative to the X axis // flipping the footprint is relative to the X axis
MIRROR( m_Pos.y, aCentre.y ); SetTextY( ::Mirror( GetTextPos().y, aCentre.y ) );
NEGATE_AND_NORMALIZE_ANGLE_POS( m_Orient );
SetTextAngle( -GetTextAngle() );
SetLayer( FlipLayer( GetLayer() ) ); SetLayer( FlipLayer( GetLayer() ) );
m_Mirror = IsBackLayer( GetLayer() ); SetMirrored( IsBackLayer( GetLayer() ) );
SetLocalCoord(); SetLocalCoord();
} }
@ -110,18 +122,17 @@ void TEXTE_MODULE::Mirror( const wxPoint& aCentre, bool aMirrorAroundXAxis )
// the mirror is around the Y axis or X axis if aMirrorAroundXAxis = true // the mirror is around the Y axis or X axis if aMirrorAroundXAxis = true
// the position is mirrored, but the text itself is not mirrored // the position is mirrored, but the text itself is not mirrored
if( aMirrorAroundXAxis ) if( aMirrorAroundXAxis )
MIRROR( m_Pos.y, aCentre.y ); SetTextY( ::Mirror( GetTextPos().y, aCentre.y ) );
else else
MIRROR( m_Pos.x, aCentre.x ); SetTextX( ::Mirror( GetTextPos().x, aCentre.x ) );
NEGATE_AND_NORMALIZE_ANGLE_POS( m_Orient );
SetLocalCoord(); SetLocalCoord();
} }
void TEXTE_MODULE::Move( const wxPoint& aMoveVector ) void TEXTE_MODULE::Move( const wxPoint& aMoveVector )
{ {
m_Pos += aMoveVector; Offset( aMoveVector );
SetLocalCoord(); SetLocalCoord();
} }
@ -136,14 +147,17 @@ void TEXTE_MODULE::SetDrawCoord()
{ {
const MODULE* module = static_cast<const MODULE*>( m_Parent ); const MODULE* module = static_cast<const MODULE*>( m_Parent );
m_Pos = m_Pos0; SetTextPos( m_Pos0 );
if( module ) if( module )
{ {
double angle = module->GetOrientation(); double angle = module->GetOrientation();
RotatePoint( &m_Pos.x, &m_Pos.y, angle ); wxPoint pt = GetTextPos();
m_Pos += module->GetPosition(); RotatePoint( &pt, angle );
SetTextPos( pt );
Offset( module->GetPosition() );
} }
} }
@ -154,13 +168,15 @@ void TEXTE_MODULE::SetLocalCoord()
if( module ) if( module )
{ {
m_Pos0 = m_Pos - module->GetPosition(); m_Pos0 = GetTextPos() - module->GetPosition();
double angle = module->GetOrientation(); double angle = module->GetOrientation();
RotatePoint( &m_Pos0.x, &m_Pos0.y, -angle ); RotatePoint( &m_Pos0.x, &m_Pos0.y, -angle );
} }
else else
{ {
m_Pos0 = m_Pos; m_Pos0 = GetTextPos();
} }
} }
@ -174,7 +190,7 @@ bool TEXTE_MODULE::HitTest( const wxPoint& aPosition ) const
* is relative to an horizontal text) * is relative to an horizontal text)
*/ */
rel_pos = aPosition; rel_pos = aPosition;
RotatePoint( &rel_pos, m_Pos, -GetDrawRotation() ); RotatePoint( &rel_pos, GetTextPos(), -GetDrawRotation() );
if( area.Contains( rel_pos ) ) if( area.Contains( rel_pos ) )
return true; return true;
@ -189,7 +205,7 @@ const EDA_RECT TEXTE_MODULE::GetBoundingBox() const
EDA_RECT text_area = GetTextBox( -1, -1 ); EDA_RECT text_area = GetTextBox( -1, -1 );
if( angle ) if( angle )
text_area = text_area.GetBoundingBoxRotated( m_Pos, angle ); text_area = text_area.GetBoundingBoxRotated( GetTextPos(), angle );
return text_area; return text_area;
} }
@ -216,7 +232,7 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMod
// Invisible texts are still drawn (not plotted) in MOD_TEXT_INVISIBLE // Invisible texts are still drawn (not plotted) in MOD_TEXT_INVISIBLE
// Just because we must have to edit them (at least to make them visible) // Just because we must have to edit them (at least to make them visible)
if( m_NoShow ) if( !IsVisible() )
{ {
if( !brd->IsElementVisible( MOD_TEXT_INVISIBLE ) ) if( !brd->IsElementVisible( MOD_TEXT_INVISIBLE ) )
return; return;
@ -236,13 +252,13 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMod
} }
// Draw mode compensation for the width // Draw mode compensation for the width
int width = m_Thickness; int width = GetThickness();
if( displ_opts && displ_opts->m_DisplayModTextFill == SKETCH ) if( displ_opts && displ_opts->m_DisplayModTextFill == SKETCH )
width = -width; width = -width;
GRSetDrawMode( aDC, aDrawMode ); GRSetDrawMode( aDC, aDrawMode );
wxPoint pos = m_Pos - aOffset; wxPoint pos = GetTextPos() - aOffset;
// Draw the text anchor point // Draw the text anchor point
if( brd->IsElementVisible( ANCHOR_VISIBLE ) ) if( brd->IsElementVisible( ANCHOR_VISIBLE ) )
@ -252,15 +268,16 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMod
} }
// Draw the text proper, with the right attributes // Draw the text proper, with the right attributes
wxSize size = m_Size; wxSize size = GetTextSize();
double orient = GetDrawRotation(); double orient = GetDrawRotation();
// If the text is mirrored : negate size.x (mirror / Y axis) // If the text is mirrored : negate size.x (mirror / Y axis)
if( m_Mirror ) if( IsMirrored() )
size.x = -size.x; size.x = -size.x;
DrawGraphicText( aPanel->GetClipBox(), aDC, pos, color, GetShownText(), orient, DrawGraphicText( aPanel->GetClipBox(), aDC, pos, color, GetShownText(), orient,
size, m_HJustify, m_VJustify, width, m_Italic, m_Bold ); size, GetHorizJustify(), GetVertJustify(),
width, IsItalic(), IsBold() );
// Enable these line to draw the bounding box (debug test purpose only) // Enable these line to draw the bounding box (debug test purpose only)
#if 0 #if 0
@ -284,7 +301,7 @@ void TEXTE_MODULE::DrawUmbilical( EDA_DRAW_PANEL* aPanel,
GRSetDrawMode( aDC, GR_XOR ); GRSetDrawMode( aDC, GR_XOR );
GRLine( aPanel->GetClipBox(), aDC, GRLine( aPanel->GetClipBox(), aDC,
parent->GetPosition(), GetTextPosition() + aOffset, parent->GetPosition(), GetTextPos() + aOffset,
0, UMBILICAL_COLOR); 0, UMBILICAL_COLOR);
} }
@ -292,7 +309,7 @@ void TEXTE_MODULE::DrawUmbilical( EDA_DRAW_PANEL* aPanel,
double TEXTE_MODULE::GetDrawRotation() const double TEXTE_MODULE::GetDrawRotation() const
{ {
MODULE* module = (MODULE*) m_Parent; MODULE* module = (MODULE*) m_Parent;
double rotation = m_Orient; double rotation = GetTextAngle();
if( module ) if( module )
rotation += module->GetOrientation(); rotation += module->GetOrientation();
@ -332,7 +349,7 @@ void TEXTE_MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
wxASSERT( m_Type >= TEXT_is_REFERENCE && m_Type <= TEXT_is_DIVERS ); wxASSERT( m_Type >= TEXT_is_REFERENCE && m_Type <= TEXT_is_DIVERS );
aList.push_back( MSG_PANEL_ITEM( _( "Type" ), text_type_msg[m_Type], DARKGREEN ) ); aList.push_back( MSG_PANEL_ITEM( _( "Type" ), text_type_msg[m_Type], DARKGREEN ) );
if( m_NoShow ) if( !IsVisible() )
msg = _( "No" ); msg = _( "No" );
else else
msg = _( "Yes" ); msg = _( "Yes" );
@ -342,23 +359,23 @@ void TEXTE_MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
// Display text layer // Display text layer
aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), DARKGREEN ) ); aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), DARKGREEN ) );
if( m_Mirror ) if( IsMirrored() )
msg = _( " Yes" ); msg = _( " Yes" );
else else
msg = _( " No" ); msg = _( " No" );
aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), msg, DARKGREEN ) ); aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), msg, DARKGREEN ) );
msg.Printf( wxT( "%.1f" ), GetOrientationDegrees() ); msg.Printf( wxT( "%.1f" ), GetTextAngleDegrees() );
aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, DARKGREEN ) ); aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, DARKGREEN ) );
msg = ::CoordinateToString( m_Thickness ); msg = ::CoordinateToString( GetThickness() );
aList.push_back( MSG_PANEL_ITEM( _( "Thickness" ), msg, DARKGREEN ) ); aList.push_back( MSG_PANEL_ITEM( _( "Thickness" ), msg, DARKGREEN ) );
msg = ::CoordinateToString( m_Size.x ); msg = ::CoordinateToString( GetTextWidth() );
aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, RED ) ); aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, RED ) );
msg = ::CoordinateToString( m_Size.y ); msg = ::CoordinateToString( GetTextHeight() );
aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, RED ) ); aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, RED ) );
} }
@ -400,7 +417,7 @@ const BOX2I TEXTE_MODULE::ViewBBox() const
EDA_RECT text_area = GetTextBox( -1, -1 ); EDA_RECT text_area = GetTextBox( -1, -1 );
if( angle ) if( angle )
text_area = text_area.GetBoundingBoxRotated( m_Pos, angle ); text_area = text_area.GetBoundingBoxRotated( GetTextPos(), angle );
return BOX2I( text_area.GetPosition(), text_area.GetSize() ); return BOX2I( text_area.GetPosition(), text_area.GetSize() );
} }
@ -408,7 +425,7 @@ const BOX2I TEXTE_MODULE::ViewBBox() const
void TEXTE_MODULE::ViewGetLayers( int aLayers[], int& aCount ) const void TEXTE_MODULE::ViewGetLayers( int aLayers[], int& aCount ) const
{ {
if( m_NoShow ) // Hidden text if( !IsVisible() ) // Hidden text
aLayers[0] = ITEM_GAL_LAYER( MOD_TEXT_INVISIBLE ); aLayers[0] = ITEM_GAL_LAYER( MOD_TEXT_INVISIBLE );
//else if( IsFrontLayer( m_Layer ) ) //else if( IsFrontLayer( m_Layer ) )
//aLayers[0] = ITEM_GAL_LAYER( MOD_TEXT_FR_VISIBLE ); //aLayers[0] = ITEM_GAL_LAYER( MOD_TEXT_FR_VISIBLE );

View File

@ -76,15 +76,17 @@ public:
virtual const wxPoint& GetPosition() const override virtual const wxPoint& GetPosition() const override
{ {
return m_Pos; return EDA_TEXT::GetTextPos();
} }
virtual void SetPosition( const wxPoint& aPos ) override virtual void SetPosition( const wxPoint& aPos ) override
{ {
m_Pos = aPos; EDA_TEXT::SetTextPos( aPos );
SetLocalCoord(); SetLocalCoord();
} }
void SetTextAngle( double aAngle );
/// Rotate text, in footprint editor /// Rotate text, in footprint editor
/// (for instance in footprint rotation transform) /// (for instance in footprint rotation transform)
void Rotate( const wxPoint& aOffset, double aAngle ) override; void Rotate( const wxPoint& aOffset, double aAngle ) override;
@ -106,8 +108,28 @@ public:
void SetType( TEXT_TYPE aType ) { m_Type = aType; } void SetType( TEXT_TYPE aType ) { m_Type = aType; }
TEXT_TYPE GetType() const { return m_Type; } TEXT_TYPE GetType() const { return m_Type; }
void SetVisible( bool isVisible ) { m_NoShow = !isVisible; } /**
bool IsVisible() const { return !m_NoShow; } * Function SetEffects
* sets the text effects from another instance.
*/
void SetEffects( const TEXTE_MODULE& aSrc )
{
EDA_TEXT::SetEffects( aSrc );
SetLocalCoord();
// SetType( aSrc.GetType() );
}
/**
* Function SwapEffects
* swaps the text effects of the two involved instances.
*/
void SwapEffects( TEXTE_MODULE& aTradingPartner )
{
EDA_TEXT::SwapEffects( aTradingPartner );
SetLocalCoord();
aTradingPartner.SetLocalCoord();
// std::swap( m_Type, aTradingPartner.m_Type );
}
// The Pos0 accessors are for module-relative coordinates // The Pos0 accessors are for module-relative coordinates
void SetPos0( const wxPoint& aPos ) { m_Pos0 = aPos; SetDrawCoord(); } void SetPos0( const wxPoint& aPos ) { m_Pos0 = aPos; SetDrawCoord(); }
@ -196,10 +218,9 @@ private:
*/ */
TEXT_TYPE m_Type; ///< 0=ref, 1=val, etc. TEXT_TYPE m_Type; ///< 0=ref, 1=val, etc.
bool m_NoShow; ///< true = invisible
wxPoint m_Pos0; ///< text coordinates relatives to the footprint anchor, orient 0. wxPoint m_Pos0; ///< text coordinates relative to the footprint anchor, orient 0.
///< text coordinate ref point is the text centre ///< text coordinate ref point is the text center
}; };
#endif // TEXT_MODULE_H_ #endif // TEXT_MODULE_H_

View File

@ -761,7 +761,7 @@ void DIALOG_MODULE_BOARD_EDITOR::OnEditReference( wxCommandEvent& event )
{ {
wxPoint tmp = m_Parent->GetCrossHairPosition(); wxPoint tmp = m_Parent->GetCrossHairPosition();
m_Parent->SetCrossHairPosition( m_ReferenceCopy->GetTextPosition() ); m_Parent->SetCrossHairPosition( m_ReferenceCopy->GetTextPos() );
m_ReferenceCopy->SetParent( m_CurrentModule ); m_ReferenceCopy->SetParent( m_CurrentModule );
m_Parent->InstallTextModOptionsFrame( m_ReferenceCopy, NULL ); m_Parent->InstallTextModOptionsFrame( m_ReferenceCopy, NULL );
m_Parent->SetCrossHairPosition( tmp ); m_Parent->SetCrossHairPosition( tmp );
@ -773,7 +773,7 @@ void DIALOG_MODULE_BOARD_EDITOR::OnEditValue( wxCommandEvent& event )
{ {
wxPoint tmp = m_Parent->GetCrossHairPosition(); wxPoint tmp = m_Parent->GetCrossHairPosition();
m_Parent->SetCrossHairPosition( m_ValueCopy->GetTextPosition() ); m_Parent->SetCrossHairPosition( m_ValueCopy->GetTextPos() );
m_ValueCopy->SetParent( m_CurrentModule ); m_ValueCopy->SetParent( m_CurrentModule );
m_Parent->InstallTextModOptionsFrame( m_ValueCopy, NULL ); m_Parent->InstallTextModOptionsFrame( m_ValueCopy, NULL );
m_Parent->SetCrossHairPosition( tmp ); m_Parent->SetCrossHairPosition( tmp );

View File

@ -534,7 +534,7 @@ void DIALOG_MODULE_MODULE_EDITOR::OnOkClick( wxCommandEvent& event )
void DIALOG_MODULE_MODULE_EDITOR::OnEditReference(wxCommandEvent& event) void DIALOG_MODULE_MODULE_EDITOR::OnEditReference(wxCommandEvent& event)
{ {
wxPoint tmp = m_parent->GetCrossHairPosition(); wxPoint tmp = m_parent->GetCrossHairPosition();
m_parent->SetCrossHairPosition( m_referenceCopy->GetTextPosition() ); m_parent->SetCrossHairPosition( m_referenceCopy->GetTextPos() );
m_parent->InstallTextModOptionsFrame( m_referenceCopy, NULL ); m_parent->InstallTextModOptionsFrame( m_referenceCopy, NULL );
m_parent->SetCrossHairPosition( tmp ); m_parent->SetCrossHairPosition( tmp );
m_ReferenceCtrl->SetValue( m_referenceCopy->GetText() ); m_ReferenceCtrl->SetValue( m_referenceCopy->GetText() );
@ -544,7 +544,7 @@ void DIALOG_MODULE_MODULE_EDITOR::OnEditReference(wxCommandEvent& event)
void DIALOG_MODULE_MODULE_EDITOR::OnEditValue(wxCommandEvent& event) void DIALOG_MODULE_MODULE_EDITOR::OnEditValue(wxCommandEvent& event)
{ {
wxPoint tmp = m_parent->GetCrossHairPosition(); wxPoint tmp = m_parent->GetCrossHairPosition();
m_parent->SetCrossHairPosition( m_valueCopy->GetTextPosition() ); m_parent->SetCrossHairPosition( m_valueCopy->GetTextPos() );
m_parent->InstallTextModOptionsFrame( m_valueCopy, NULL ); m_parent->InstallTextModOptionsFrame( m_valueCopy, NULL );
m_parent->SetCrossHairPosition( tmp ); m_parent->SetCrossHairPosition( tmp );
m_ValueCtrl->SetValue( m_valueCopy->GetText() ); m_ValueCtrl->SetValue( m_valueCopy->GetText() );

View File

@ -136,10 +136,10 @@ bool DialogEditModuleText::TransferDataToWindow()
m_Style->SetSelection( m_currentText->IsItalic() ? 1 : 0 ); m_Style->SetSelection( m_currentText->IsItalic() ? 1 : 0 );
AddUnitSymbol( *m_SizeXTitle ); AddUnitSymbol( *m_SizeXTitle );
PutValueInLocalUnits( *m_TxtSizeCtrlX, m_currentText->GetSize().x ); PutValueInLocalUnits( *m_TxtSizeCtrlX, m_currentText->GetTextWidth() );
AddUnitSymbol( *m_SizeYTitle ); AddUnitSymbol( *m_SizeYTitle );
PutValueInLocalUnits( *m_TxtSizeCtrlY, m_currentText->GetSize().y ); PutValueInLocalUnits( *m_TxtSizeCtrlY, m_currentText->GetTextHeight() );
AddUnitSymbol( *m_PosXTitle ); AddUnitSymbol( *m_PosXTitle );
PutValueInLocalUnits( *m_TxtPosCtrlX, m_currentText->GetPos0().x ); PutValueInLocalUnits( *m_TxtPosCtrlX, m_currentText->GetPos0().x );
@ -150,10 +150,10 @@ bool DialogEditModuleText::TransferDataToWindow()
AddUnitSymbol( *m_WidthTitle ); AddUnitSymbol( *m_WidthTitle );
PutValueInLocalUnits( *m_TxtWidthCtlr, m_currentText->GetThickness() ); PutValueInLocalUnits( *m_TxtWidthCtlr, m_currentText->GetThickness() );
double text_orient = m_currentText->GetOrientation(); double text_orient = m_currentText->GetTextAngle();
NORMALIZE_ANGLE_90( text_orient ); NORMALIZE_ANGLE_90( text_orient );
if( (text_orient != 0) ) if( text_orient != 0.0 )
m_Orient->SetSelection( 1 ); m_Orient->SetSelection( 1 );
if( !m_currentText->IsVisible() ) if( !m_currentText->IsVisible() )
@ -244,7 +244,7 @@ bool DialogEditModuleText::TransferDataFromWindow()
if( textSize.y < TEXTS_MIN_SIZE ) if( textSize.y < TEXTS_MIN_SIZE )
textSize.y = TEXTS_MIN_SIZE; textSize.y = TEXTS_MIN_SIZE;
m_currentText->SetSize( textSize ); m_currentText->SetTextSize( textSize );
int width = ValueFromString( g_UserUnit, m_TxtWidthCtlr->GetValue() ); int width = ValueFromString( g_UserUnit, m_TxtWidthCtlr->GetValue() );
@ -252,7 +252,7 @@ bool DialogEditModuleText::TransferDataFromWindow()
if( width <= 1 ) if( width <= 1 )
width = 1; width = 1;
int maxthickness = Clamp_Text_PenSize(width, m_currentText->GetSize() ); int maxthickness = Clamp_Text_PenSize(width, m_currentText->GetTextSize() );
if( width > maxthickness ) if( width > maxthickness )
{ {
@ -269,24 +269,24 @@ bool DialogEditModuleText::TransferDataFromWindow()
switch( m_Orient->GetSelection() ) switch( m_Orient->GetSelection() )
{ {
case 0: case 0:
m_currentText->SetOrientation( 0 ); m_currentText->SetTextAngle( 0 );
break; break;
case 1: case 1:
m_currentText->SetOrientation( 900 ); m_currentText->SetTextAngle( 900 );
break; break;
case 2: case 2:
m_currentText->SetOrientation( -900 ); m_currentText->SetTextAngle( -900 );
break; break;
default: default:
custom_orientation = true; custom_orientation = true;
m_currentText->SetOrientation( KiROUND( m_OrientValue * 10.0 ) ); m_currentText->SetTextAngle( KiROUND( m_OrientValue * 10.0 ) );
break; break;
}; };
switch( int( m_currentText->GetOrientation() ) ) switch( int( m_currentText->GetTextAngle() ) )
{ {
case 0: case 0:
m_Orient->SetSelection( 0 ); m_Orient->SetSelection( 0 );
@ -304,11 +304,11 @@ bool DialogEditModuleText::TransferDataFromWindow()
default: default:
m_Orient->SetSelection( 3 ); m_Orient->SetSelection( 3 );
m_currentText->SetOrientation( KiROUND( m_OrientValue * 10.0 ) ); m_currentText->SetTextAngle( KiROUND( m_OrientValue * 10.0 ) );
custom_orientation = true; custom_orientation = true;
break; break;
} }
m_OrientValue = 10.0 * m_currentText->GetOrientation(); m_OrientValue = 10.0 * m_currentText->GetTextAngle();
m_OrientValueCtrl->Enable( custom_orientation ); m_OrientValueCtrl->Enable( custom_orientation );
m_OrientValidator.TransferToWindow(); m_OrientValidator.TransferToWindow();

View File

@ -162,12 +162,12 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( const wxString & aFilter, bool aRef,
{ {
TEXTE_MODULE* item = &module->Reference(); TEXTE_MODULE* item = &module->Reference();
if( item->GetSize() != GetDesignSettings().m_ModuleTextSize || if( item->GetTextSize() != GetDesignSettings().m_ModuleTextSize ||
item->GetThickness() != GetDesignSettings().m_ModuleTextWidth ) item->GetThickness() != GetDesignSettings().m_ModuleTextWidth )
{ {
commit.Modify( item ); commit.Modify( item );
item->SetThickness( modTextWidth ); item->SetThickness( modTextWidth );
item->SetSize( modTextSize ); item->SetTextSize( modTextSize );
} }
} }
@ -175,12 +175,12 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( const wxString & aFilter, bool aRef,
{ {
TEXTE_MODULE* item = &module->Value(); TEXTE_MODULE* item = &module->Value();
if( item->GetSize() != GetDesignSettings().m_ModuleTextSize || if( item->GetTextSize() != GetDesignSettings().m_ModuleTextSize ||
item->GetThickness() != GetDesignSettings().m_ModuleTextWidth ) item->GetThickness() != GetDesignSettings().m_ModuleTextWidth )
{ {
commit.Modify( item ); commit.Modify( item );
item->SetThickness( modTextWidth ); item->SetThickness( modTextWidth );
item->SetSize( modTextSize ); item->SetTextSize( modTextSize );
} }
} }
@ -193,12 +193,12 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( const wxString & aFilter, bool aRef,
{ {
TEXTE_MODULE* item = static_cast<TEXTE_MODULE*>( boardItem ); TEXTE_MODULE* item = static_cast<TEXTE_MODULE*>( boardItem );
if( item->GetSize() != GetDesignSettings().m_ModuleTextSize if( item->GetTextSize() != GetDesignSettings().m_ModuleTextSize
|| item->GetThickness() != GetDesignSettings().m_ModuleTextWidth ) || item->GetThickness() != GetDesignSettings().m_ModuleTextWidth )
{ {
commit.Modify( item ); commit.Modify( item );
item->SetThickness( modTextWidth ); item->SetThickness( modTextWidth );
item->SetSize( modTextSize ); item->SetTextSize( modTextSize );
} }
} }
} }

View File

@ -290,7 +290,7 @@ bool DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::Validate()
// Check angle of arc. // Check angle of arc.
double angle; double angle;
m_AngleCtrl->GetValue().ToDouble( &angle ); m_AngleCtrl->GetValue().ToDouble( &angle );
NORMALIZE_ANGLE_360( angle ); angle = NormalizeAngle360( angle );
if( angle == 0 ) if( angle == 0 )
{ {

View File

@ -136,11 +136,11 @@ bool DIALOG_PCB_TEXT_PROPERTIES::TransferDataToWindow()
// Fill fields with current values // Fill fields with current values
*m_TextContentCtrl << m_SelectedPCBText->GetText(); *m_TextContentCtrl << m_SelectedPCBText->GetText();
PutValueInLocalUnits( *m_SizeXCtrl, m_SelectedPCBText->GetSize().x ); PutValueInLocalUnits( *m_SizeXCtrl, m_SelectedPCBText->GetTextWidth() );
PutValueInLocalUnits( *m_SizeYCtrl, m_SelectedPCBText->GetSize().y ); PutValueInLocalUnits( *m_SizeYCtrl, m_SelectedPCBText->GetTextHeight() );
PutValueInLocalUnits( *m_ThicknessCtrl, m_SelectedPCBText->GetThickness() ); PutValueInLocalUnits( *m_ThicknessCtrl, m_SelectedPCBText->GetThickness() );
PutValueInLocalUnits( *m_PositionXCtrl, m_SelectedPCBText->GetTextPosition().x ); PutValueInLocalUnits( *m_PositionXCtrl, m_SelectedPCBText->GetTextPos().x );
PutValueInLocalUnits( *m_PositionYCtrl, m_SelectedPCBText->GetTextPosition().y ); PutValueInLocalUnits( *m_PositionYCtrl, m_SelectedPCBText->GetTextPos().y );
// Configure the layers list selector // Configure the layers list selector
m_LayerSelectionCtrl->SetLayersHotkeys( false ); m_LayerSelectionCtrl->SetLayersHotkeys( false );
@ -151,7 +151,7 @@ bool DIALOG_PCB_TEXT_PROPERTIES::TransferDataToWindow()
m_LayerSelectionCtrl->Resync(); m_LayerSelectionCtrl->Resync();
m_LayerSelectionCtrl->SetLayerSelection( m_SelectedPCBText->GetLayer() ); m_LayerSelectionCtrl->SetLayerSelection( m_SelectedPCBText->GetLayer() );
m_OrientValue = m_SelectedPCBText->GetOrientation() / 10.0; m_OrientValue = m_SelectedPCBText->GetTextAngleDegrees();
if( m_SelectedPCBText->IsMirrored() ) if( m_SelectedPCBText->IsMirrored() )
m_DisplayCtrl->SetSelection( 1 ); m_DisplayCtrl->SetSelection( 1 );
@ -235,7 +235,7 @@ bool DIALOG_PCB_TEXT_PROPERTIES::TransferDataFromWindow()
// Set PCB Text position // Set PCB Text position
newPosition.x = ValueFromString( g_UserUnit, m_PositionXCtrl->GetValue() ); newPosition.x = ValueFromString( g_UserUnit, m_PositionXCtrl->GetValue() );
newPosition.y = ValueFromString( g_UserUnit, m_PositionYCtrl->GetValue() ); newPosition.y = ValueFromString( g_UserUnit, m_PositionYCtrl->GetValue() );
m_SelectedPCBText->SetTextPosition( newPosition ); m_SelectedPCBText->SetTextPos( newPosition );
// Check constraints and set PCB Text size // Check constraints and set PCB Text size
newSize.x = ValueFromString( g_UserUnit, m_SizeXCtrl->GetValue() ); newSize.x = ValueFromString( g_UserUnit, m_SizeXCtrl->GetValue() );
@ -253,7 +253,7 @@ bool DIALOG_PCB_TEXT_PROPERTIES::TransferDataFromWindow()
if( newSize.y > TEXTS_MAX_WIDTH ) if( newSize.y > TEXTS_MAX_WIDTH )
newSize.y = TEXTS_MAX_WIDTH; newSize.y = TEXTS_MAX_WIDTH;
m_SelectedPCBText->SetSize( newSize ); m_SelectedPCBText->SetTextSize( newSize );
// Set the new thickness // Set the new thickness
m_SelectedPCBText->SetThickness( ValueFromString( g_UserUnit, m_SelectedPCBText->SetThickness( ValueFromString( g_UserUnit,
@ -261,7 +261,7 @@ bool DIALOG_PCB_TEXT_PROPERTIES::TransferDataFromWindow()
// Test for acceptable values for thickness and size and clamp if fails // Test for acceptable values for thickness and size and clamp if fails
int maxthickness = Clamp_Text_PenSize( m_SelectedPCBText->GetThickness(), int maxthickness = Clamp_Text_PenSize( m_SelectedPCBText->GetThickness(),
m_SelectedPCBText->GetSize() ); m_SelectedPCBText->GetTextSize() );
if( m_SelectedPCBText->GetThickness() > maxthickness ) if( m_SelectedPCBText->GetThickness() > maxthickness )
{ {
@ -276,8 +276,8 @@ bool DIALOG_PCB_TEXT_PROPERTIES::TransferDataFromWindow()
// Set whether the PCB text is mirrored (faced down from layer face perspective) // Set whether the PCB text is mirrored (faced down from layer face perspective)
m_SelectedPCBText->SetMirrored( m_DisplayCtrl->GetSelection() == 1 ); m_SelectedPCBText->SetMirrored( m_DisplayCtrl->GetSelection() == 1 );
// Set the text orientation // Set the text angle
m_SelectedPCBText->SetOrientation( m_OrientValue * 10.0 ); m_SelectedPCBText->SetTextAngle( m_OrientValue * 10.0 );
// Set whether the PCB text is slanted (it is not italics, as italics has additional curves in style) // Set whether the PCB text is slanted (it is not italics, as italics has additional curves in style)
m_SelectedPCBText->SetItalic( m_StyleCtrl->GetSelection() ); m_SelectedPCBText->SetItalic( m_StyleCtrl->GetSelection() );

View File

@ -118,9 +118,9 @@ DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR( PCB_EDIT_FRAME* aParent,
m_Name->SetValue( aDimension->Text().GetText() ); m_Name->SetValue( aDimension->Text().GetText() );
// Enter size value in dialog // Enter size value in dialog
PutValueInLocalUnits( *m_TxtSizeXCtrl, aDimension->Text().GetSize().x ); PutValueInLocalUnits( *m_TxtSizeXCtrl, aDimension->Text().GetTextWidth() );
AddUnitSymbol( *m_staticTextSizeX ); AddUnitSymbol( *m_staticTextSizeX );
PutValueInLocalUnits( *m_TxtSizeYCtrl, aDimension->Text().GetSize().y ); PutValueInLocalUnits( *m_TxtSizeYCtrl, aDimension->Text().GetTextHeight() );
AddUnitSymbol( *m_staticTextSizeY ); AddUnitSymbol( *m_staticTextSizeY );
// Enter lines thickness value in dialog // Enter lines thickness value in dialog
@ -128,9 +128,9 @@ DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR( PCB_EDIT_FRAME* aParent,
AddUnitSymbol( *m_staticTextWidth ); AddUnitSymbol( *m_staticTextWidth );
// Enter position value in dialog // Enter position value in dialog
PutValueInLocalUnits( *m_textCtrlPosX, aDimension->Text().GetTextPosition().x ); PutValueInLocalUnits( *m_textCtrlPosX, aDimension->Text().GetTextPos().x );
AddUnitSymbol( *m_staticTextPosX ); AddUnitSymbol( *m_staticTextPosX );
PutValueInLocalUnits( *m_textCtrlPosY, aDimension->Text().GetTextPosition().y ); PutValueInLocalUnits( *m_textCtrlPosY, aDimension->Text().GetTextPos().y );
AddUnitSymbol( *m_staticTextPosY ); AddUnitSymbol( *m_staticTextPosY );
// Configure the layers list selector // Configure the layers list selector
@ -191,9 +191,9 @@ void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event )
// Get new size value: // Get new size value:
msg = m_TxtSizeXCtrl->GetValue(); msg = m_TxtSizeXCtrl->GetValue();
m_currentDimension->Text().SetWidth( ValueFromString( g_UserUnit, msg ) ); m_currentDimension->Text().SetTextWidth( ValueFromString( g_UserUnit, msg ) );
msg = m_TxtSizeYCtrl->GetValue(); msg = m_TxtSizeYCtrl->GetValue();
m_currentDimension->Text().SetHeight( ValueFromString( g_UserUnit, msg ) ); m_currentDimension->Text().SetTextHeight( ValueFromString( g_UserUnit, msg ) );
// Get new position value: // Get new position value:
// It will be copied later in dimension, because // It will be copied later in dimension, because
@ -202,12 +202,12 @@ void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event )
pos.x = ValueFromString( g_UserUnit, msg ); pos.x = ValueFromString( g_UserUnit, msg );
msg = m_textCtrlPosY->GetValue(); msg = m_textCtrlPosY->GetValue();
pos.y = ValueFromString( g_UserUnit, msg ); pos.y = ValueFromString( g_UserUnit, msg );
m_currentDimension->Text().SetTextPosition( pos ); m_currentDimension->Text().SetTextPos( pos );
// Get new line thickness value: // Get new line thickness value:
msg = m_TxtWidthCtrl->GetValue(); msg = m_TxtWidthCtrl->GetValue();
int width = ValueFromString( g_UserUnit, msg ); int width = ValueFromString( g_UserUnit, msg );
int maxthickness = Clamp_Text_PenSize( width, m_currentDimension->Text().GetSize() ); int maxthickness = Clamp_Text_PenSize( width, m_currentDimension->Text().GetTextSize() );
if( width > maxthickness ) if( width > maxthickness )
{ {
@ -273,9 +273,9 @@ DIMENSION* PCB_EDIT_FRAME::EditDimension( DIMENSION* aDimension, wxDC* aDC )
aDimension->SetOrigin( pos ); aDimension->SetOrigin( pos );
aDimension->SetEnd( pos ); aDimension->SetEnd( pos );
aDimension->Text().SetSize( GetBoard()->GetDesignSettings().m_PcbTextSize ); aDimension->Text().SetTextSize( GetBoard()->GetDesignSettings().m_PcbTextSize );
int width = GetBoard()->GetDesignSettings().m_PcbTextWidth; int width = GetBoard()->GetDesignSettings().m_PcbTextWidth;
int maxthickness = Clamp_Text_PenSize(width, aDimension->Text().GetSize() ); int maxthickness = Clamp_Text_PenSize(width, aDimension->Text().GetTextSize() );
if( width > maxthickness ) if( width > maxthickness )
{ {
@ -386,13 +386,13 @@ void PCB_EDIT_FRAME::BeginMoveDimensionText( DIMENSION* aItem, wxDC* DC )
return; return;
// Store the initial position for undo/abort command // Store the initial position for undo/abort command
initialTextPosition = aItem->Text().GetTextPosition(); initialTextPosition = aItem->Text().GetTextPos();
aItem->Draw( m_canvas, DC, GR_XOR ); aItem->Draw( m_canvas, DC, GR_XOR );
aItem->SetFlags( IS_MOVED ); aItem->SetFlags( IS_MOVED );
SetMsgPanel( aItem ); SetMsgPanel( aItem );
SetCrossHairPosition( aItem->Text().GetTextPosition() ); SetCrossHairPosition( aItem->Text().GetTextPos() );
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
m_canvas->SetMouseCapture( MoveDimensionText, AbortMoveDimensionText ); m_canvas->SetMouseCapture( MoveDimensionText, AbortMoveDimensionText );
@ -413,7 +413,7 @@ static void MoveDimensionText( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
if( aErase ) if( aErase )
dimension->Draw( aPanel, aDC, GR_XOR ); dimension->Draw( aPanel, aDC, GR_XOR );
dimension->Text().SetTextPosition( aPanel->GetParent()->GetCrossHairPosition() ); dimension->Text().SetTextPos( aPanel->GetParent()->GetCrossHairPosition() );
dimension->Draw( aPanel, aDC, GR_XOR ); dimension->Draw( aPanel, aDC, GR_XOR );
} }
@ -435,7 +435,7 @@ void AbortMoveDimensionText( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
return; return;
dimension->Draw( aPanel, aDC, GR_XOR ); dimension->Draw( aPanel, aDC, GR_XOR );
dimension->Text().SetTextPosition( initialTextPosition ); dimension->Text().SetTextPos( initialTextPosition );
dimension->ClearFlags(); dimension->ClearFlags();
dimension->Draw( aPanel, aDC, GR_OR ); dimension->Draw( aPanel, aDC, GR_OR );
} }
@ -455,9 +455,9 @@ void PCB_EDIT_FRAME::PlaceDimensionText( DIMENSION* aItem, wxDC* DC )
aItem->Draw( m_canvas, DC, GR_OR ); aItem->Draw( m_canvas, DC, GR_OR );
OnModify(); OnModify();
wxPoint tmp = aItem->Text().GetTextPosition(); wxPoint tmp = aItem->Text().GetTextPos();
aItem->Text().SetTextPosition( initialTextPosition ); aItem->Text().SetTextPos( initialTextPosition );
SaveCopyInUndoList( aItem, UR_CHANGED ); SaveCopyInUndoList( aItem, UR_CHANGED );
aItem->Text().SetTextPosition( tmp ); aItem->Text().SetTextPos( tmp );
aItem->ClearFlags(); aItem->ClearFlags();
} }

View File

@ -1491,9 +1491,9 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics )
pcbtxt->SetLayer( layer ); pcbtxt->SetLayer( layer );
pcbtxt->SetTimeStamp( timeStamp( gr->second ) ); pcbtxt->SetTimeStamp( timeStamp( gr->second ) );
pcbtxt->SetText( FROM_UTF8( t.text.c_str() ) ); pcbtxt->SetText( FROM_UTF8( t.text.c_str() ) );
pcbtxt->SetTextPosition( wxPoint( kicad_x( t.x ), kicad_y( t.y ) ) ); pcbtxt->SetTextPos( wxPoint( kicad_x( t.x ), kicad_y( t.y ) ) );
pcbtxt->SetSize( kicad_fontz( t.size ) ); pcbtxt->SetTextSize( kicad_fontz( t.size ) );
double ratio = t.ratio ? *t.ratio : 8; // DTD says 8 is default double ratio = t.ratio ? *t.ratio : 8; // DTD says 8 is default
@ -1509,12 +1509,12 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics )
double degrees = t.rot->degrees; double degrees = t.rot->degrees;
if( degrees == 90 || t.rot->spin ) if( degrees == 90 || t.rot->spin )
pcbtxt->SetOrientation( sign * t.rot->degrees * 10 ); pcbtxt->SetTextAngle( sign * t.rot->degrees * 10 );
else if( degrees == 180 ) else if( degrees == 180 )
align = ETEXT::TOP_RIGHT; align = ETEXT::TOP_RIGHT;
else if( degrees == 270 ) else if( degrees == 270 )
{ {
pcbtxt->SetOrientation( sign * 90 * 10 ); pcbtxt->SetTextAngle( sign * 90 * 10 );
align = ETEXT::TOP_RIGHT; align = ETEXT::TOP_RIGHT;
} }
} }
@ -1681,10 +1681,10 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics )
// The origin and end are assumed to always be in this order from eagle // The origin and end are assumed to always be in this order from eagle
dimension->SetOrigin( wxPoint( kicad_x( d.x1 ), kicad_y( d.y1 ) ) ); dimension->SetOrigin( wxPoint( kicad_x( d.x1 ), kicad_y( d.y1 ) ) );
dimension->SetEnd( wxPoint( kicad_x( d.x2 ), kicad_y( d.y2 ) ) ); dimension->SetEnd( wxPoint( kicad_x( d.x2 ), kicad_y( d.y2 ) ) );
dimension->Text().SetSize( m_board->GetDesignSettings().m_PcbTextSize ); dimension->Text().SetTextSize( m_board->GetDesignSettings().m_PcbTextSize );
int width = m_board->GetDesignSettings().m_PcbTextWidth; int width = m_board->GetDesignSettings().m_PcbTextWidth;
int maxThickness = Clamp_Text_PenSize( width, dimension->Text().GetSize() ); int maxThickness = Clamp_Text_PenSize( width, dimension->Text().GetTextSize() );
if( width > maxThickness ) if( width > maxThickness )
width = maxThickness; width = maxThickness;
@ -2031,18 +2031,18 @@ void EAGLE_PLUGIN::orientModuleText( MODULE* m, const EELEMENT& e,
if( a.x && a.y ) // boost::optional if( a.x && a.y ) // boost::optional
{ {
wxPoint pos( kicad_x( *a.x ), kicad_y( *a.y ) ); wxPoint pos( kicad_x( *a.x ), kicad_y( *a.y ) );
txt->SetTextPosition( pos ); txt->SetTextPos( pos );
} }
// Even though size and ratio are both optional, I am not seeing // Even though size and ratio are both optional, I am not seeing
// a case where ratio is present but size is not. // a case where ratio is present but size is not.
double ratio = 8; double ratio = 8;
wxSize fontz = txt->GetSize(); wxSize fontz = txt->GetTextSize();
if( a.size ) if( a.size )
{ {
fontz = kicad_fontz( *a.size ); fontz = kicad_fontz( *a.size );
txt->SetSize( fontz ); txt->SetTextSize( fontz );
if( a.ratio ) if( a.ratio )
ratio = *a.ratio; ratio = *a.ratio;
@ -2073,24 +2073,24 @@ void EAGLE_PLUGIN::orientModuleText( MODULE* m, const EELEMENT& e,
if( degrees == 90 || degrees == 0 || spin ) if( degrees == 90 || degrees == 0 || spin )
{ {
orient = degrees - m->GetOrientation() / 10; orient = degrees - m->GetOrientation() / 10;
txt->SetOrientation( sign * orient * 10 ); txt->SetTextAngle( sign * orient * 10 );
} }
else if( degrees == 180 ) else if( degrees == 180 )
{ {
orient = 0 - m->GetOrientation() / 10; orient = 0 - m->GetOrientation() / 10;
txt->SetOrientation( sign * orient * 10 ); txt->SetTextAngle( sign * orient * 10 );
align = ETEXT::TOP_RIGHT; align = ETEXT::TOP_RIGHT;
} }
else if( degrees == 270 ) else if( degrees == 270 )
{ {
orient = 90 - m->GetOrientation() / 10; orient = 90 - m->GetOrientation() / 10;
align = ETEXT::TOP_RIGHT; align = ETEXT::TOP_RIGHT;
txt->SetOrientation( sign * orient * 10 ); txt->SetTextAngle( sign * orient * 10 );
} }
else else
{ {
orient = 90 - degrees - m->GetOrientation() / 10; orient = 90 - degrees - m->GetOrientation() / 10;
txt->SetOrientation( sign * orient * 10 ); txt->SetTextAngle( sign * orient * 10 );
} }
switch( align ) switch( align )
@ -2111,7 +2111,7 @@ void EAGLE_PLUGIN::orientModuleText( MODULE* m, const EELEMENT& e,
} }
else // Part is not smash so use Lib default for NAME/VALUE // the text is per the original package, sans <attribute> else // Part is not smash so use Lib default for NAME/VALUE // the text is per the original package, sans <attribute>
{ {
double degrees = ( txt->GetOrientation() + m->GetOrientation() ) / 10; double degrees = ( txt->GetTextAngle() + m->GetOrientation() ) / 10;
// @todo there are a few more cases than these to contend with: // @todo there are a few more cases than these to contend with:
if( (!txt->IsMirrored() && ( abs( degrees ) == 180 || abs( degrees ) == 270 )) if( (!txt->IsMirrored() && ( abs( degrees ) == 180 || abs( degrees ) == 270 ))
@ -2322,12 +2322,11 @@ void EAGLE_PLUGIN::packageText( MODULE* aModule, CPTREE& aTree ) const
wxPoint pos( kicad_x( t.x ), kicad_y( t.y ) ); wxPoint pos( kicad_x( t.x ), kicad_y( t.y ) );
txt->SetTextPosition( pos ); txt->SetTextPos( pos );
txt->SetPos0( pos - aModule->GetPosition() ); txt->SetPos0( pos - aModule->GetPosition() );
txt->SetLayer( layer ); txt->SetLayer( layer );
txt->SetTextSize( kicad_fontz( t.size ) );
txt->SetSize( kicad_fontz( t.size ) );
double ratio = t.ratio ? *t.ratio : 8; // DTD says 8 is default double ratio = t.ratio ? *t.ratio : 8; // DTD says 8 is default
@ -2346,13 +2345,13 @@ void EAGLE_PLUGIN::packageText( MODULE* aModule, CPTREE& aTree ) const
double degrees = t.rot->degrees; double degrees = t.rot->degrees;
if( degrees == 90 || t.rot->spin ) if( degrees == 90 || t.rot->spin )
txt->SetOrientation( sign * degrees * 10 ); txt->SetTextAngle( sign * degrees * 10 );
else if( degrees == 180 ) else if( degrees == 180 )
align = ETEXT::TOP_RIGHT; align = ETEXT::TOP_RIGHT;
else if( degrees == 270 ) else if( degrees == 270 )
{ {
align = ETEXT::TOP_RIGHT; align = ETEXT::TOP_RIGHT;
txt->SetOrientation( sign * 90 * 10 ); txt->SetTextAngle( sign * 90 * 10 );
} }
} }

View File

@ -110,7 +110,7 @@ void PCB_EDIT_FRAME::Place_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
if( TextePcb->IsMoving() ) // If moved only if( TextePcb->IsMoving() ) // If moved only
{ {
SaveCopyInUndoList( TextePcb, UR_MOVED, SaveCopyInUndoList( TextePcb, UR_MOVED,
TextePcb->GetTextPosition() - s_TextCopy.GetTextPosition() ); TextePcb->GetTextPos() - s_TextCopy.GetTextPos() );
} }
else else
{ {
@ -145,7 +145,7 @@ void PCB_EDIT_FRAME::StartMoveTextePcb( TEXTE_PCB* aTextePcb, wxDC* aDC, bool aE
m_canvas->Refresh(); m_canvas->Refresh();
#endif #endif
SetCrossHairPosition( aTextePcb->GetTextPosition() ); SetCrossHairPosition( aTextePcb->GetTextPos() );
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
m_canvas->SetMouseCapture( Move_Texte_Pcb, Abort_Edit_Pcb_Text ); m_canvas->SetMouseCapture( Move_Texte_Pcb, Abort_Edit_Pcb_Text );
@ -166,7 +166,7 @@ static void Move_Texte_Pcb( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aP
if( aErase ) if( aErase )
TextePcb->Draw( aPanel, aDC, GR_XOR ); TextePcb->Draw( aPanel, aDC, GR_XOR );
TextePcb->SetTextPosition( aPanel->GetParent()->GetCrossHairPosition() ); TextePcb->SetTextPos( aPanel->GetParent()->GetCrossHairPosition() );
TextePcb->Draw( aPanel, aDC, GR_XOR ); TextePcb->Draw( aPanel, aDC, GR_XOR );
} }
@ -214,8 +214,8 @@ TEXTE_PCB* PCB_EDIT_FRAME::CreateTextePcb( wxDC* aDC, TEXTE_PCB* aText )
) )
textePcb->SetMirrored( true ); textePcb->SetMirrored( true );
textePcb->SetSize( GetBoard()->GetDesignSettings().m_PcbTextSize ); textePcb->SetTextSize( GetBoard()->GetDesignSettings().m_PcbTextSize );
textePcb->SetTextPosition( GetCrossHairPosition() ); textePcb->SetTextPos( GetCrossHairPosition() );
textePcb->SetThickness( GetBoard()->GetDesignSettings().m_PcbTextWidth ); textePcb->SetThickness( GetBoard()->GetDesignSettings().m_PcbTextWidth );
InstallTextPCBOptionsFrame( textePcb, aDC ); InstallTextPCBOptionsFrame( textePcb, aDC );
@ -243,14 +243,14 @@ void PCB_EDIT_FRAME::Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
// Erase previous text: // Erase previous text:
TextePcb->Draw( m_canvas, DC, GR_XOR ); TextePcb->Draw( m_canvas, DC, GR_XOR );
TextePcb->SetOrientation( TextePcb->GetOrientation() + 900 ); TextePcb->SetTextAngle( TextePcb->GetTextAngle() + 900 );
// Redraw text in new position: // Redraw text in new position:
TextePcb->Draw( m_canvas, DC, GR_XOR ); TextePcb->Draw( m_canvas, DC, GR_XOR );
SetMsgPanel( TextePcb ); SetMsgPanel( TextePcb );
if( TextePcb->GetFlags() == 0 ) // i.e. not edited, or moved if( TextePcb->GetFlags() == 0 ) // i.e. not edited, or moved
SaveCopyInUndoList( TextePcb, UR_ROTATED, TextePcb->GetTextPosition() ); SaveCopyInUndoList( TextePcb, UR_ROTATED, TextePcb->GetTextPos() );
else // set flag edit, to show it was a complex command else // set flag edit, to show it was a complex command
TextePcb->SetFlags( IN_EDIT ); TextePcb->SetFlags( IN_EDIT );
@ -268,13 +268,13 @@ void PCB_EDIT_FRAME::FlipTextePcb( TEXTE_PCB* aTextePcb, wxDC* aDC )
aTextePcb->Draw( m_canvas, aDC, GR_XOR ); aTextePcb->Draw( m_canvas, aDC, GR_XOR );
aTextePcb->Flip( aTextePcb->GetTextPosition() ); aTextePcb->Flip( aTextePcb->GetTextPos() );
aTextePcb->Draw( m_canvas, aDC, GR_XOR ); aTextePcb->Draw( m_canvas, aDC, GR_XOR );
SetMsgPanel( aTextePcb ); SetMsgPanel( aTextePcb );
if( aTextePcb->GetFlags() == 0 ) // i.e. not edited, or moved if( aTextePcb->GetFlags() == 0 ) // i.e. not edited, or moved
SaveCopyInUndoList( aTextePcb, UR_FLIPPED, aTextePcb->GetTextPosition() ); SaveCopyInUndoList( aTextePcb, UR_FLIPPED, aTextePcb->GetTextPos() );
else // set edit flag, for the current command else // set edit flag, for the current command
aTextePcb->SetFlags( IN_EDIT ); aTextePcb->SetFlags( IN_EDIT );

View File

@ -71,7 +71,7 @@ TEXTE_MODULE* FOOTPRINT_EDIT_FRAME::CreateTextModule( MODULE* aModule, wxDC* aDC
GetDesignSettings().m_ModuleTextWidth = Clamp_Text_PenSize( GetDesignSettings().m_ModuleTextWidth, GetDesignSettings().m_ModuleTextWidth = Clamp_Text_PenSize( GetDesignSettings().m_ModuleTextWidth,
std::min( GetDesignSettings().m_ModuleTextSize.x, GetDesignSettings().m_ModuleTextSize.y ), true ); std::min( GetDesignSettings().m_ModuleTextSize.x, GetDesignSettings().m_ModuleTextSize.y ), true );
text->SetSize( GetDesignSettings().m_ModuleTextSize ); text->SetTextSize( GetDesignSettings().m_ModuleTextSize );
text->SetThickness( GetDesignSettings().m_ModuleTextWidth ); text->SetThickness( GetDesignSettings().m_ModuleTextWidth );
text->SetPosition( GetCrossHairPosition() ); text->SetPosition( GetCrossHairPosition() );
@ -121,7 +121,7 @@ void PCB_BASE_FRAME::RotateTextModule( TEXTE_MODULE* Text, wxDC* DC )
// we expect MoveVector to be (0,0) if there is no move in progress // we expect MoveVector to be (0,0) if there is no move in progress
Text->Draw( m_canvas, DC, GR_XOR, MoveVector ); Text->Draw( m_canvas, DC, GR_XOR, MoveVector );
Text->SetOrientation( Text->GetOrientation() + 900 ); Text->SetTextAngle( Text->GetTextAngle() + 900 );
Text->Draw( m_canvas, DC, GR_XOR, MoveVector ); Text->Draw( m_canvas, DC, GR_XOR, MoveVector );
SetMsgPanel( Text ); SetMsgPanel( Text );
@ -179,7 +179,7 @@ static void AbortMoveTextModule( EDA_DRAW_PANEL* Panel, wxDC* DC )
// If the text was moved (the move does not change internal data) // If the text was moved (the move does not change internal data)
// it could be rotated while moving. So set old value for orientation // it could be rotated while moving. So set old value for orientation
if( Text->IsMoving() ) if( Text->IsMoving() )
Text->SetOrientation( TextInitialOrientation ); Text->SetTextAngle( TextInitialOrientation );
// Redraw the text // Redraw the text
Panel->RefreshDrawingRect( Text->GetBoundingBox() ); Panel->RefreshDrawingRect( Text->GetBoundingBox() );
@ -208,8 +208,8 @@ void PCB_BASE_FRAME::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC )
MoveVector.x = MoveVector.y = 0; MoveVector.x = MoveVector.y = 0;
TextInitialPosition = Text->GetTextPosition(); TextInitialPosition = Text->GetTextPos();
TextInitialOrientation = Text->GetOrientation(); TextInitialOrientation = Text->GetTextAngle();
// Center cursor on initial position of text // Center cursor on initial position of text
SetCrossHairPosition( TextInitialPosition ); SetCrossHairPosition( TextInitialPosition );
@ -237,19 +237,19 @@ void PCB_BASE_FRAME::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
if( Module ) if( Module )
{ {
// Prepare undo command (a rotation can be made while moving) // Prepare undo command (a rotation can be made while moving)
double tmp = Text->GetOrientation(); double tmp = Text->GetTextAngle();
Text->SetOrientation( TextInitialOrientation ); Text->SetTextAngle( TextInitialOrientation );
if( IsType( FRAME_PCB ) ) if( IsType( FRAME_PCB ) )
SaveCopyInUndoList( Module, UR_CHANGED ); SaveCopyInUndoList( Module, UR_CHANGED );
else else
SaveCopyInUndoList( Module, UR_CHANGED ); SaveCopyInUndoList( Module, UR_CHANGED );
Text->SetOrientation( tmp ); Text->SetTextAngle( tmp );
// Set the new position for text. // Set the new position for text.
Text->SetTextPosition( GetCrossHairPosition() ); Text->SetTextPos( GetCrossHairPosition() );
wxPoint textRelPos = Text->GetTextPosition() - Module->GetPosition(); wxPoint textRelPos = Text->GetTextPos() - Module->GetPosition();
RotatePoint( &textRelPos, -Module->GetOrientation() ); RotatePoint( &textRelPos, -Module->GetOrientation() );
Text->SetPos0( textRelPos ); Text->SetPos0( textRelPos );
Text->ClearFlags(); Text->ClearFlags();
@ -262,7 +262,7 @@ void PCB_BASE_FRAME::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
} }
else else
{ {
Text->SetTextPosition( GetCrossHairPosition() ); Text->SetTextPos( GetCrossHairPosition() );
} }
} }
@ -311,11 +311,11 @@ void PCB_BASE_FRAME::ResetTextSize( BOARD_ITEM* aItem, wxDC* aDC )
TEXTE_PCB* text = static_cast<TEXTE_PCB*>( aItem ); TEXTE_PCB* text = static_cast<TEXTE_PCB*>( aItem );
// Exit if there's nothing to do // Exit if there's nothing to do
if( text->GetSize() == newSize && text->GetThickness() == newThickness ) if( text->GetTextSize() == newSize && text->GetThickness() == newThickness )
return; return;
SaveCopyInUndoList( text, UR_CHANGED ); SaveCopyInUndoList( text, UR_CHANGED );
text->SetSize( newSize ); text->SetTextSize( newSize );
text->SetThickness( newThickness ); text->SetThickness( newThickness );
} }
@ -326,11 +326,11 @@ void PCB_BASE_FRAME::ResetTextSize( BOARD_ITEM* aItem, wxDC* aDC )
TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( aItem ); TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( aItem );
// Exit if there's nothing to do // Exit if there's nothing to do
if( text->GetSize() == newSize && text->GetThickness() == newThickness ) if( text->GetTextSize() == newSize && text->GetThickness() == newThickness )
return; return;
SaveCopyInUndoList( text->GetParent(), UR_CHANGED ); SaveCopyInUndoList( text->GetParent(), UR_CHANGED );
text->SetSize( newSize ); text->SetTextSize( newSize );
text->SetThickness( newThickness ); text->SetThickness( newThickness );
} }
else else

View File

@ -733,13 +733,13 @@ static void CreateComponentsSection( FILE* aFile, BOARD* aPcb )
for( int ii = 0; ii < 2; ii++ ) for( int ii = 0; ii < 2; ii++ )
{ {
double txt_orient = textmod->GetOrientation(); double txt_orient = textmod->GetTextAngle();
std::string layer = GenCADLayerName( cu_count, module->GetFlag() ? B_SilkS : F_SilkS ); std::string layer = GenCADLayerName( cu_count, module->GetFlag() ? B_SilkS : F_SilkS );
fprintf( aFile, "TEXT %g %g %g %g %s %s \"%s\"", fprintf( aFile, "TEXT %g %g %g %g %s %s \"%s\"",
textmod->GetPos0().x / SCALE_FACTOR, textmod->GetPos0().x / SCALE_FACTOR,
-textmod->GetPos0().y / SCALE_FACTOR, -textmod->GetPos0().y / SCALE_FACTOR,
textmod->GetSize().x / SCALE_FACTOR, textmod->GetTextWidth() / SCALE_FACTOR,
txt_orient / 10.0, txt_orient / 10.0,
mirror, mirror,
layer.c_str(), layer.c_str(),
@ -747,8 +747,8 @@ static void CreateComponentsSection( FILE* aFile, BOARD* aPcb )
// Please note, the width is approx // Please note, the width is approx
fprintf( aFile, " 0 0 %g %g\n", fprintf( aFile, " 0 0 %g %g\n",
( textmod->GetSize().x * textmod->GetLength() ) / SCALE_FACTOR, ( textmod->GetTextWidth() * textmod->GetLength() ) / SCALE_FACTOR,
textmod->GetSize().y / SCALE_FACTOR ); textmod->GetTextHeight() / SCALE_FACTOR );
textmod = &module->Value(); // Dirty trick for the second iteration textmod = &module->Value(); // Dirty trick for the second iteration
} }

View File

@ -729,7 +729,7 @@ static void export_vrml_pcbtext( MODEL_VRML& aModel, TEXTE_PCB* text )
model_vrml->m_text_layer = text->GetLayer(); model_vrml->m_text_layer = text->GetLayer();
model_vrml->m_text_width = text->GetThickness(); model_vrml->m_text_width = text->GetThickness();
wxSize size = text->GetSize(); wxSize size = text->GetTextSize();
if( text->IsMirrored() ) if( text->IsMirrored() )
size.x = -size.x; size.x = -size.x;
@ -748,7 +748,7 @@ static void export_vrml_pcbtext( MODEL_VRML& aModel, TEXTE_PCB* text )
{ {
wxString& txt = strings_list.Item( ii ); wxString& txt = strings_list.Item( ii );
DrawGraphicText( NULL, NULL, positions[ii], color, DrawGraphicText( NULL, NULL, positions[ii], color,
txt, text->GetOrientation(), size, txt, text->GetTextAngle(), size,
text->GetHorizJustify(), text->GetVertJustify(), text->GetHorizJustify(), text->GetVertJustify(),
text->GetThickness(), text->IsItalic(), text->GetThickness(), text->IsItalic(),
true, true,
@ -757,8 +757,8 @@ static void export_vrml_pcbtext( MODEL_VRML& aModel, TEXTE_PCB* text )
} }
else else
{ {
DrawGraphicText( NULL, NULL, text->GetTextPosition(), color, DrawGraphicText( NULL, NULL, text->GetTextPos(), color,
text->GetShownText(), text->GetOrientation(), size, text->GetShownText(), text->GetTextAngle(), size,
text->GetHorizJustify(), text->GetVertJustify(), text->GetHorizJustify(), text->GetVertJustify(),
text->GetThickness(), text->IsItalic(), text->GetThickness(), text->IsItalic(),
true, true,
@ -983,7 +983,7 @@ static void export_vrml_text_module( TEXTE_MODULE* module )
{ {
if( module->IsVisible() ) if( module->IsVisible() )
{ {
wxSize size = module->GetSize(); wxSize size = module->GetTextSize();
if( module->IsMirrored() ) if( module->IsMirrored() )
size.x = -size.x; // Text is mirrored size.x = -size.x; // Text is mirrored
@ -991,7 +991,7 @@ static void export_vrml_text_module( TEXTE_MODULE* module )
model_vrml->m_text_layer = module->GetLayer(); model_vrml->m_text_layer = module->GetLayer();
model_vrml->m_text_width = module->GetThickness(); model_vrml->m_text_width = module->GetThickness();
DrawGraphicText( NULL, NULL, module->GetTextPosition(), BLACK, DrawGraphicText( NULL, NULL, module->GetTextPos(), BLACK,
module->GetShownText(), module->GetDrawRotation(), size, module->GetShownText(), module->GetDrawRotation(), size,
module->GetHorizJustify(), module->GetVertJustify(), module->GetHorizJustify(), module->GetVertJustify(),
module->GetThickness(), module->IsItalic(), module->GetThickness(), module->IsItalic(),

View File

@ -480,7 +480,7 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader ) throw( IO_ERROR,
} }
int orientation = parseInt( parameters[paramCnt-4], 1.0 ); int orientation = parseInt( parameters[paramCnt-4], 1.0 );
module->Reference().SetOrientation( (orientation % 2) ? 900 : 0 ); module->Reference().SetTextAngle( (orientation % 2) ? 900 : 0 );
// Calculate size: default height is 40 mils, width 30 mil. // Calculate size: default height is 40 mils, width 30 mil.
// real size is: default * ibuf[idx+3] / 100 (size in gpcb is given in percent of default size // real size is: default * ibuf[idx+3] / 100 (size in gpcb is given in percent of default size
@ -500,19 +500,19 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader ) throw( IO_ERROR,
textPos.x -= thsize / 10; textPos.x -= thsize / 10;
textPos.y += thsize / 2; textPos.y += thsize / 2;
module->Reference().SetTextPosition( textPos ); module->Reference().SetTextPos( textPos );
module->Reference().SetPos0( textPos ); module->Reference().SetPos0( textPos );
module->Reference().SetSize( wxSize( twsize, thsize ) ); module->Reference().SetTextSize( wxSize( twsize, thsize ) );
module->Reference().SetThickness( thickness ); module->Reference().SetThickness( thickness );
// gEDA/pcb shows only one of value/reference/description at a time. Which // gEDA/pcb shows only one of value/reference/description at a time. Which
// one is selectable by a global menu setting. pcbnew needs reference as // one is selectable by a global menu setting. pcbnew needs reference as
// well as value visible, so place the value right below the reference. // well as value visible, so place the value right below the reference.
module->Value().SetOrientation( module->Reference().GetOrientation() ); module->Value().SetTextAngle( module->Reference().GetTextAngle() );
module->Value().SetSize( module->Reference().GetSize() ); module->Value().SetTextSize( module->Reference().GetTextSize() );
module->Value().SetThickness( module->Reference().GetThickness() ); module->Value().SetThickness( module->Reference().GetThickness() );
textPos.y += thsize * 13 / 10; // 130% line height textPos.y += thsize * 13 / 10; // 130% line height
module->Value().SetTextPosition( textPos ); module->Value().SetTextPos( textPos );
module->Value().SetPos0( textPos ); module->Value().SetPos0( textPos );
while( aLineReader->ReadLine() ) while( aLineReader->ReadLine() )

View File

@ -378,12 +378,12 @@ void DXF2BRD_CONVERTER::addText( const DRW_Text& aData )
wxString text = toNativeString( wxString::FromUTF8( aData.text.c_str() ) ); wxString text = toNativeString( wxString::FromUTF8( aData.text.c_str() ) );
textItem->SetTextPosition( refPoint ); textItem->SetTextPos( refPoint );
textItem->SetOrientation( aData.angle * 10 ); textItem->SetTextAngle( aData.angle * 10 );
// The 0.8 factor gives a better height/width ratio with our font // The 0.8 factor gives a better height/width ratio with our font
textItem->SetWidth( mapDim( aData.height * 0.8 ) ); textItem->SetTextWidth( mapDim( aData.height * 0.8 ) );
textItem->SetHeight( mapDim( aData.height ) ); textItem->SetTextHeight( mapDim( aData.height ) );
textItem->SetThickness( mapDim( aData.thickness == 0 ? m_defaultThickness : aData.thickness ) ); textItem->SetThickness( mapDim( aData.thickness == 0 ? m_defaultThickness : aData.thickness ) );
textItem->SetText( text ); textItem->SetText( text );
@ -440,12 +440,12 @@ void DXF2BRD_CONVERTER::addMText( const DRW_MText& aData )
brdItem->SetLayer( ToLAYER_ID( m_brdLayer ) ); brdItem->SetLayer( ToLAYER_ID( m_brdLayer ) );
wxPoint textpos( mapX( aData.basePoint.x ), mapY( aData.basePoint.y ) ); wxPoint textpos( mapX( aData.basePoint.x ), mapY( aData.basePoint.y ) );
textItem->SetTextPosition( textpos ); textItem->SetTextPos( textpos );
textItem->SetOrientation( aData.angle * 10 ); textItem->SetTextAngle( aData.angle * 10 );
// The 0.8 factor gives a better height/width ratio with our font // The 0.8 factor gives a better height/width ratio with our font
textItem->SetWidth( mapDim( aData.height * 0.8 ) ); textItem->SetTextWidth( mapDim( aData.height * 0.8 ) );
textItem->SetHeight( mapDim( aData.height ) ); textItem->SetTextHeight( mapDim( aData.height ) );
textItem->SetThickness( mapDim( aData.thickness == 0 ? m_defaultThickness : aData.thickness ) ); textItem->SetThickness( mapDim( aData.thickness == 0 ? m_defaultThickness : aData.thickness ) );
textItem->SetText( text ); textItem->SetText( text );

View File

@ -1355,10 +1355,10 @@ void PCB_IO::format( TEXTE_PCB* aText, int aNestLevel ) const
{ {
m_out->Print( aNestLevel, "(gr_text %s (at %s", m_out->Print( aNestLevel, "(gr_text %s (at %s",
m_out->Quotew( aText->GetText() ).c_str(), m_out->Quotew( aText->GetText() ).c_str(),
FMT_IU( aText->GetTextPosition() ).c_str() ); FMT_IU( aText->GetTextPos() ).c_str() );
if( aText->GetOrientation() != 0.0 ) if( aText->GetTextAngle() != 0.0 )
m_out->Print( 0, " %s", FMT_ANGLE( aText->GetOrientation() ).c_str() ); m_out->Print( 0, " %s", FMT_ANGLE( aText->GetTextAngle() ).c_str() );
m_out->Print( 0, ")" ); m_out->Print( 0, ")" );
@ -1378,27 +1378,44 @@ void PCB_IO::format( TEXTE_PCB* aText, int aNestLevel ) const
void PCB_IO::format( TEXTE_MODULE* aText, int aNestLevel ) const void PCB_IO::format( TEXTE_MODULE* aText, int aNestLevel ) const
throw( IO_ERROR ) throw( IO_ERROR )
{ {
MODULE* parent = (MODULE*) aText->GetParent();
double orient = aText->GetOrientation();
wxString type; wxString type;
switch( aText->GetType() ) switch( aText->GetType() )
{ {
case TEXTE_MODULE::TEXT_is_REFERENCE: type = wxT( "reference" ); break; case TEXTE_MODULE::TEXT_is_REFERENCE: type = "reference"; break;
case TEXTE_MODULE::TEXT_is_VALUE: type = wxT( "value" ); break; case TEXTE_MODULE::TEXT_is_VALUE: type = "value"; break;
case TEXTE_MODULE::TEXT_is_DIVERS: type = wxT( "user" ); case TEXTE_MODULE::TEXT_is_DIVERS: type = "user";
} }
// Due to the Pcbnew history, m_Orient is saved in screen value
// but it is handled as relative to its parent footprint
if( parent )
orient += parent->GetOrientation();
m_out->Print( aNestLevel, "(fp_text %s %s (at %s", m_out->Print( aNestLevel, "(fp_text %s %s (at %s",
m_out->Quotew( type ).c_str(), m_out->Quotew( type ).c_str(),
m_out->Quotew( aText->GetText() ).c_str(), m_out->Quotew( aText->GetText() ).c_str(),
FMT_IU( aText->GetPos0() ).c_str() ); FMT_IU( aText->GetPos0() ).c_str() );
// Due to Pcbnew history, fp_text angle is saved as an absolute on screen angle,
// but internally the angle is held relative to its parent footprint. parent
// may be NULL when saving a footprint outside a BOARD.
double orient = aText->GetTextAngle();
MODULE* parent = (MODULE*) aText->GetParent();
if( parent )
{
// GetTextAngle() is always in -360..+360 range because of
// TEXTE_MODULE::SetTextAngle(), but summing that angle with an
// additional board angle could kick sum up >= 360 or <= -360, so to have
// consistent results, normalize again for the BOARD save. A footprint
// save does not use this code path since parent is NULL.
#if 0
// This one could be considered reasonable if you like positive angles
// in your board text.
orient = NormalizeAnglePos( orient + parent->GetOrientation() );
#else
// Choose compatibility for now, even though this is only a 720 degree clamp
// with two possible values for every angle.
orient = NormalizeAngle360( orient + parent->GetOrientation() );
#endif
}
if( orient != 0.0 ) if( orient != 0.0 )
m_out->Print( 0, " %s", FMT_ANGLE( orient ).c_str() ); m_out->Print( 0, " %s", FMT_ANGLE( orient ).c_str() );

View File

@ -1832,11 +1832,11 @@ void LEGACY_PLUGIN::loadMODULE_TEXT( TEXTE_MODULE* aText )
aText->SetType( static_cast<TEXTE_MODULE::TEXT_TYPE>( type ) ); aText->SetType( static_cast<TEXTE_MODULE::TEXT_TYPE>( type ) );
aText->SetPos0( wxPoint( pos0_x, pos0_y ) ); aText->SetPos0( wxPoint( pos0_x, pos0_y ) );
aText->SetSize( wxSize( size0_x, size0_y ) ); aText->SetTextSize( wxSize( size0_x, size0_y ) );
orient -= ( static_cast<MODULE*>( aText->GetParent() ) )->GetOrientation(); orient -= ( static_cast<MODULE*>( aText->GetParent() ) )->GetOrientation();
aText->SetOrientation( orient ); aText->SetTextAngle( orient );
// @todo put in accessors? // @todo put in accessors?
// Set a reasonable width: // Set a reasonable width:
@ -2174,7 +2174,7 @@ void LEGACY_PLUGIN::loadPCB_TEXT()
sz.y = 5; sz.y = 5;
*/ */
pcbtxt->SetSize( size ); pcbtxt->SetTextSize( size );
/* @todo move into an accessor /* @todo move into an accessor
// Set a reasonable width: // Set a reasonable width:
@ -2185,9 +2185,9 @@ void LEGACY_PLUGIN::loadPCB_TEXT()
*/ */
pcbtxt->SetThickness( thickn ); pcbtxt->SetThickness( thickn );
pcbtxt->SetOrientation( angle ); pcbtxt->SetTextAngle( angle );
pcbtxt->SetTextPosition( wxPoint( pos_x, pos_y ) ); pcbtxt->SetTextPos( wxPoint( pos_x, pos_y ) );
} }
else if( TESTLINE( "De" ) ) else if( TESTLINE( "De" ) )
@ -2823,7 +2823,7 @@ void LEGACY_PLUGIN::loadDIMENSION()
dim->Text().SetMirrored( mirror && *mirror == '0' ); dim->Text().SetMirrored( mirror && *mirror == '0' );
dim->Text().SetThickness( thickn ); dim->Text().SetThickness( thickn );
dim->Text().SetOrientation( orient ); dim->Text().SetTextAngle( orient );
} }
else if( TESTLINE( "Sb" ) ) else if( TESTLINE( "Sb" ) )

View File

@ -791,7 +791,7 @@ MODULE* PCB_BASE_FRAME::CreateNewModule( const wxString& aModuleName )
module->SetReference( settings.m_RefDefaultText ); module->SetReference( settings.m_RefDefaultText );
module->Reference().SetThickness( settings.m_ModuleTextWidth ); module->Reference().SetThickness( settings.m_ModuleTextWidth );
module->Reference().SetSize( settings.m_ModuleTextSize ); module->Reference().SetTextSize( settings.m_ModuleTextSize );
default_pos.y = GetDesignSettings().m_ModuleTextSize.y / 2; default_pos.y = GetDesignSettings().m_ModuleTextSize.y / 2;
module->Reference().SetPosition( default_pos ); module->Reference().SetPosition( default_pos );
module->Reference().SetLayer( ToLAYER_ID( settings.m_RefDefaultlayer ) ); module->Reference().SetLayer( ToLAYER_ID( settings.m_RefDefaultlayer ) );
@ -804,7 +804,7 @@ MODULE* PCB_BASE_FRAME::CreateNewModule( const wxString& aModuleName )
module->SetValue( settings.m_ValueDefaultText ); module->SetValue( settings.m_ValueDefaultText );
module->Value().SetThickness( GetDesignSettings().m_ModuleTextWidth ); module->Value().SetThickness( GetDesignSettings().m_ModuleTextWidth );
module->Value().SetSize( GetDesignSettings().m_ModuleTextSize ); module->Value().SetTextSize( GetDesignSettings().m_ModuleTextSize );
default_pos.y = -default_pos.y; default_pos.y = -default_pos.y;
module->Value().SetPosition( default_pos ); module->Value().SetPosition( default_pos );
module->Value().SetLayer( ToLAYER_ID( settings.m_ValueDefaultlayer ) ); module->Value().SetLayer( ToLAYER_ID( settings.m_ValueDefaultlayer ) );

View File

@ -338,9 +338,9 @@ MODULE* CreateMicrowaveInductor( PCB_EDIT_FRAME* aPcbFrame, wxString& aErrorMess
wxPoint valPos = refPos; wxPoint valPos = refPos;
refPos.y -= module->Reference().GetSize().y; refPos.y -= module->Reference().GetTextSize().y;
module->Reference().SetPosition( refPos ); module->Reference().SetPosition( refPos );
valPos.y += module->Value().GetSize().y; valPos.y += module->Value().GetTextSize().y;
module->Value().SetPosition( valPos ); module->Value().SetPosition( valPos );
module->CalculateBoundingBox(); module->CalculateBoundingBox();
@ -579,9 +579,9 @@ MODULE* PCB_EDIT_FRAME::CreateMuWaveBaseFootprint( const wxString& aValue,
if( aTextSize > 0 ) if( aTextSize > 0 )
{ {
module->Reference().SetSize( wxSize( aTextSize, aTextSize ) ); module->Reference().SetTextSize( wxSize( aTextSize, aTextSize ) );
module->Reference().SetThickness( aTextSize/5 ); module->Reference().SetThickness( aTextSize/5 );
module->Value().SetSize( wxSize( aTextSize, aTextSize ) ); module->Value().SetTextSize( wxSize( aTextSize, aTextSize ) );
module->Value().SetThickness( aTextSize/5 ); module->Value().SetThickness( aTextSize/5 );
} }

View File

@ -548,12 +548,14 @@ void CorrectTextPosition( TTEXTVALUE* aValue )
} }
} }
void SetTextSizeFromStrokeFontHeight( EDA_TEXT* aText, int aTextHeight ) void SetTextSizeFromStrokeFontHeight( EDA_TEXT* aText, int aTextHeight )
{ {
aText->SetSize( wxSize( KiROUND( aTextHeight * TEXT_WIDTH_TO_SIZE ), aText->SetTextSize( wxSize( KiROUND( aTextHeight * TEXT_WIDTH_TO_SIZE ),
KiROUND( aTextHeight * TEXT_HEIGHT_TO_SIZE ) ) ); KiROUND( aTextHeight * TEXT_HEIGHT_TO_SIZE ) ) );
} }
XNODE* FindNode( XNODE* aChild, wxString aTag ) XNODE* FindNode( XNODE* aChild, wxString aTag )
{ {
aChild = aChild->GetChildren(); aChild = aChild->GetChildren();

View File

@ -536,7 +536,7 @@ void PCB_MODULE::AddToBoard()
SetTextSizeFromStrokeFontHeight( ref_text, m_name.textHeight ); SetTextSizeFromStrokeFontHeight( ref_text, m_name.textHeight );
r = m_name.textRotation - m_rotation; r = m_name.textRotation - m_rotation;
ref_text->SetOrientation( r ); ref_text->SetTextAngle( r );
ref_text->SetThickness( m_name.textstrokeWidth ); ref_text->SetThickness( m_name.textstrokeWidth );
@ -558,7 +558,7 @@ void PCB_MODULE::AddToBoard()
SetTextSizeFromStrokeFontHeight( val_text, m_value.textHeight ); SetTextSizeFromStrokeFontHeight( val_text, m_value.textHeight );
r = m_value.textRotation - m_rotation; r = m_value.textRotation - m_rotation;
val_text->SetOrientation( r ); val_text->SetTextAngle( r );
val_text->SetThickness( m_value.textstrokeWidth ); val_text->SetThickness( m_value.textstrokeWidth );

View File

@ -113,11 +113,11 @@ void PCB_TEXT::AddToBoard()
SetTextSizeFromStrokeFontHeight( pcbtxt, m_name.textHeight ); SetTextSizeFromStrokeFontHeight( pcbtxt, m_name.textHeight );
pcbtxt->SetThickness( m_name.textstrokeWidth ); pcbtxt->SetThickness( m_name.textstrokeWidth );
pcbtxt->SetOrientation( m_name.textRotation ); pcbtxt->SetTextAngle( m_name.textRotation );
SetTextJustify( pcbtxt, m_name.justify ); SetTextJustify( pcbtxt, m_name.justify );
pcbtxt->SetTextPosition( wxPoint( m_name.textPositionX, pcbtxt->SetTextPos( wxPoint( m_name.textPositionX,
m_name.textPositionY ) ); m_name.textPositionY ) );
pcbtxt->SetMirrored( m_name.mirror ); pcbtxt->SetMirrored( m_name.mirror );
pcbtxt->SetTimeStamp( 0 ); pcbtxt->SetTimeStamp( 0 );

View File

@ -804,7 +804,7 @@ void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer )
return; return;
const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() ); const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() );
VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y ); VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
if( m_pcbSettings.m_sketchMode[aLayer] ) if( m_pcbSettings.m_sketchMode[aLayer] )
{ {
@ -821,7 +821,7 @@ void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer )
m_gal->SetIsFill( false ); m_gal->SetIsFill( false );
m_gal->SetIsStroke( true ); m_gal->SetIsStroke( true );
m_gal->SetTextAttributes( aText ); m_gal->SetTextAttributes( aText );
m_gal->StrokeText( shownText, position, aText->GetOrientationRadians() ); m_gal->StrokeText( shownText, position, aText->GetTextAngleRadians() );
} }
@ -832,7 +832,7 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
return; return;
const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer ); const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y ); VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
if( m_pcbSettings.m_sketchMode[aLayer] ) if( m_pcbSettings.m_sketchMode[aLayer] )
{ {
@ -933,8 +933,8 @@ void PCB_PAINTER::draw( const ZONE_CONTAINER* aZone )
for( int i = 0; i < polySet.OutlineCount(); i++ ) for( int i = 0; i < polySet.OutlineCount(); i++ )
{ {
const SHAPE_LINE_CHAIN& outline = polySet.COutline( i ); const SHAPE_LINE_CHAIN& outline = polySet.COutline( i );
// fixme: GAL drawing API that accepts SHAPEs directly (this fiddling with double<>int conversion // fixme: GAL drawing API that accepts SHAPEs directly (this fiddling with double<>int conversion
// is just a performance hog) // is just a performance hog)
for( int j = 0; j < outline.PointCount(); j++ ) for( int j = 0; j < outline.PointCount(); j++ )
corners.push_back ( (VECTOR2D) outline.CPoint( j ) ); corners.push_back ( (VECTOR2D) outline.CPoint( j ) );
@ -979,11 +979,11 @@ void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer )
// Draw text // Draw text
TEXTE_PCB& text = aDimension->Text(); TEXTE_PCB& text = aDimension->Text();
VECTOR2D position( text.GetTextPosition().x, text.GetTextPosition().y ); VECTOR2D position( text.GetTextPos().x, text.GetTextPos().y );
m_gal->SetLineWidth( text.GetThickness() ); m_gal->SetLineWidth( text.GetThickness() );
m_gal->SetTextAttributes( &text ); m_gal->SetTextAttributes( &text );
m_gal->StrokeText( text.GetShownText(), position, text.GetOrientationRadians() ); m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngleRadians() );
} }

View File

@ -264,7 +264,7 @@ void PCB_PARSER::parseEDA_TEXT( EDA_TEXT* aText ) throw( PARSE_ERROR, IO_ERROR )
wxSize sz; wxSize sz;
sz.SetHeight( parseBoardUnits( "text height" ) ); sz.SetHeight( parseBoardUnits( "text height" ) );
sz.SetWidth( parseBoardUnits( "text width" ) ); sz.SetWidth( parseBoardUnits( "text width" ) );
aText->SetSize( sz ); aText->SetTextSize( sz );
NeedRIGHT(); NeedRIGHT();
break; break;
} }
@ -1518,14 +1518,14 @@ TEXTE_PCB* PCB_PARSER::parseTEXTE_PCB() throw( IO_ERROR, PARSE_ERROR )
pt.x = parseBoardUnits( "X coordinate" ); pt.x = parseBoardUnits( "X coordinate" );
pt.y = parseBoardUnits( "Y coordinate" ); pt.y = parseBoardUnits( "Y coordinate" );
text->SetTextPosition( pt ); text->SetTextPos( pt );
// If there is no orientation defined, then it is the default value of 0 degrees. // If there is no orientation defined, then it is the default value of 0 degrees.
token = NextTok(); token = NextTok();
if( token == T_NUMBER ) if( token == T_NUMBER )
{ {
text->SetOrientation( parseDouble() * 10.0 ); text->SetTextAngle( parseDouble() * 10.0 );
NeedRIGHT(); NeedRIGHT();
} }
else if( token != T_RIGHT ) else if( token != T_RIGHT )
@ -1607,7 +1607,7 @@ DIMENSION* PCB_PARSER::parseDIMENSION() throw( IO_ERROR, PARSE_ERROR )
{ {
TEXTE_PCB* text = parseTEXTE_PCB(); TEXTE_PCB* text = parseTEXTE_PCB();
dimension->Text() = *text; dimension->Text() = *text;
dimension->SetPosition( text->GetTextPosition() ); dimension->SetPosition( text->GetTextPos() );
delete text; delete text;
break; break;
} }
@ -1919,9 +1919,9 @@ MODULE* PCB_PARSER::parseMODULE_unchecked( wxArrayString* aInitialComments )
{ {
TEXTE_MODULE* text = parseTEXTE_MODULE(); TEXTE_MODULE* text = parseTEXTE_MODULE();
text->SetParent( module.get() ); text->SetParent( module.get() );
double orientation = text->GetOrientation(); double orientation = text->GetTextAngle();
orientation -= module->GetOrientation(); orientation -= module->GetOrientation();
text->SetOrientation( orientation ); text->SetTextAngle( orientation );
text->SetDrawCoord(); text->SetDrawCoord();
switch( text->GetType() ) switch( text->GetType() )
@ -2017,6 +2017,18 @@ TEXTE_MODULE* PCB_PARSER::parseTEXTE_MODULE() throw( IO_ERROR, PARSE_ERROR )
NeedSYMBOLorNUMBER(); NeedSYMBOLorNUMBER();
#if defined(DEBUG)
{
wxString ref = FromUTF8();
if( ref == "LED7" )
{
int breakhere = 1;
(void) breakhere;
}
}
#endif
text->SetText( FromUTF8() ); text->SetText( FromUTF8() );
NeedLEFT(); NeedLEFT();
token = NextTok(); token = NextTok();
@ -2034,7 +2046,7 @@ TEXTE_MODULE* PCB_PARSER::parseTEXTE_MODULE() throw( IO_ERROR, PARSE_ERROR )
// If there is no orientation defined, then it is the default value of 0 degrees. // If there is no orientation defined, then it is the default value of 0 degrees.
if( token == T_NUMBER ) if( token == T_NUMBER )
{ {
text->SetOrientation( parseDouble() * 10.0 ); text->SetTextAngle( parseDouble() * 10.0 );
NeedRIGHT(); NeedRIGHT();
} }
else if( token != T_RIGHT ) else if( token != T_RIGHT )

View File

@ -305,8 +305,8 @@ void BRDITEMS_PLOTTER::PlotTextModule( TEXTE_MODULE* pt_texte, EDA_COLOR_T aColo
m_plotter->SetColor( aColor ); m_plotter->SetColor( aColor );
// calculate some text parameters : // calculate some text parameters :
size = pt_texte->GetSize(); size = pt_texte->GetTextSize();
pos = pt_texte->GetTextPosition(); pos = pt_texte->GetTextPos();
orient = pt_texte->GetDrawRotation(); orient = pt_texte->GetDrawRotation();
@ -565,9 +565,9 @@ void BRDITEMS_PLOTTER::PlotTextePcb( TEXTE_PCB* pt_texte )
m_plotter->SetColor( getColor( pt_texte->GetLayer() ) ); m_plotter->SetColor( getColor( pt_texte->GetLayer() ) );
size = pt_texte->GetSize(); size = pt_texte->GetTextSize();
pos = pt_texte->GetTextPosition(); pos = pt_texte->GetTextPos();
orient = pt_texte->GetOrientation(); orient = pt_texte->GetTextAngle();
thickness = pt_texte->GetThickness(); thickness = pt_texte->GetThickness();
if( pt_texte->IsMirrored() ) if( pt_texte->IsMirrored() )

View File

@ -264,9 +264,9 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
TEXTE_MODULE* textMod = new TEXTE_MODULE( (MODULE*) m_frame->GetModel() ); TEXTE_MODULE* textMod = new TEXTE_MODULE( (MODULE*) m_frame->GetModel() );
textMod->SetLayer( m_frame->GetActiveLayer() ); textMod->SetLayer( m_frame->GetActiveLayer() );
textMod->SetSize( dsnSettings.m_ModuleTextSize ); textMod->SetTextSize( dsnSettings.m_ModuleTextSize );
textMod->SetThickness( dsnSettings.m_ModuleTextWidth ); textMod->SetThickness( dsnSettings.m_ModuleTextWidth );
textMod->SetTextPosition( wxPoint( cursorPos.x, cursorPos.y ) ); textMod->SetTextPos( wxPoint( cursorPos.x, cursorPos.y ) );
DialogEditModuleText textDialog( m_frame, textMod, NULL ); DialogEditModuleText textDialog( m_frame, textMod, NULL );
bool placing; bool placing;
@ -293,9 +293,9 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
if( IsBackLayer( layer ) ) if( IsBackLayer( layer ) )
textPcb->SetMirrored( true ); textPcb->SetMirrored( true );
textPcb->SetSize( dsnSettings.m_PcbTextSize ); textPcb->SetTextSize( dsnSettings.m_PcbTextSize );
textPcb->SetThickness( dsnSettings.m_PcbTextWidth ); textPcb->SetThickness( dsnSettings.m_PcbTextWidth );
textPcb->SetTextPosition( wxPoint( cursorPos.x, cursorPos.y ) ); textPcb->SetTextPos( wxPoint( cursorPos.x, cursorPos.y ) );
RunMainStack( [&]() { RunMainStack( [&]() {
getEditFrame<PCB_EDIT_FRAME>()->InstallTextPCBOptionsFrame( textPcb, NULL ); getEditFrame<PCB_EDIT_FRAME>()->InstallTextPCBOptionsFrame( textPcb, NULL );
@ -319,7 +319,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
else else
{ {
//assert( text->GetText().Length() > 0 ); //assert( text->GetText().Length() > 0 );
//assert( text->GetSize().x > 0 && text->GetSize().y > 0 ); //assert( text->GetTextSize().x > 0 && text->GetTextSize().y > 0 );
text->ClearFlags(); text->ClearFlags();
preview.Remove( text ); preview.Remove( text );
@ -448,10 +448,10 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
dimension->SetLayer( layer ); dimension->SetLayer( layer );
dimension->SetOrigin( wxPoint( cursorPos.x, cursorPos.y ) ); dimension->SetOrigin( wxPoint( cursorPos.x, cursorPos.y ) );
dimension->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) ); dimension->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
dimension->Text().SetSize( m_board->GetDesignSettings().m_PcbTextSize ); dimension->Text().SetTextSize( m_board->GetDesignSettings().m_PcbTextSize );
int width = m_board->GetDesignSettings().m_PcbTextWidth; int width = m_board->GetDesignSettings().m_PcbTextWidth;
maxThickness = Clamp_Text_PenSize( width, dimension->Text().GetSize() ); maxThickness = Clamp_Text_PenSize( width, dimension->Text().GetTextSize() );
if( width > maxThickness ) if( width > maxThickness )
width = maxThickness; width = maxThickness;
@ -663,22 +663,27 @@ int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
{ {
TEXTE_PCB* text = static_cast<TEXTE_PCB*>( item ); TEXTE_PCB* text = static_cast<TEXTE_PCB*>( item );
TEXTE_MODULE* textMod = new TEXTE_MODULE( (MODULE*) parent ); TEXTE_MODULE* textMod = new TEXTE_MODULE( (MODULE*) parent );
// Assignment operator also copies the item PCB_TEXT_T type, // Assignment operator also copies the item PCB_TEXT_T type,
// so it cannot be added to a module which handles PCB_MODULE_TEXT_T // so it cannot be added to a module which handles PCB_MODULE_TEXT_T
textMod->SetPosition( text->GetPosition() );
textMod->SetText( text->GetText() ); textMod->SetText( text->GetText() );
textMod->SetSize( text->GetSize() ); #if 0
textMod->SetTextSize( text->GetTextSize() );
textMod->SetThickness( text->GetThickness() ); textMod->SetThickness( text->GetThickness() );
textMod->SetOrientation( text->GetOrientation() ); textMod->SetOrientation( text->GetTextAngle() );
textMod->SetTextPosition( text->GetTextPosition() ); textMod->SetTextPos( text->GetTextPos() );
textMod->SetSize( text->GetSize() ); textMod->SetTextSize( text->GetTextSize() );
textMod->SetVisible( text->GetVisible() );
textMod->SetMirrored( text->IsMirrored() ); textMod->SetMirrored( text->IsMirrored() );
textMod->SetAttributes( text->GetAttributes() );
textMod->SetItalic( text->IsItalic() ); textMod->SetItalic( text->IsItalic() );
textMod->SetBold( text->IsBold() ); textMod->SetBold( text->IsBold() );
textMod->SetHorizJustify( text->GetHorizJustify() ); textMod->SetHorizJustify( text->GetHorizJustify() );
textMod->SetVertJustify( text->GetVertJustify() ); textMod->SetVertJustify( text->GetVertJustify() );
textMod->SetMultilineAllowed( text->IsMultilineAllowed() ); textMod->SetMultilineAllowed( text->IsMultilineAllowed() );
#else
textMod->EDA_TEXT::SetEffects( *text );
textMod->SetLocalCoord(); // using changed SetTexPos() via SetEffects()
#endif
converted = textMod; converted = textMod;
break; break;
} }

View File

@ -395,6 +395,16 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule,
aNewModule->SetReference( aOldModule->GetReference() ); aNewModule->SetReference( aOldModule->GetReference() );
aNewModule->SetValue( aOldModule->GetValue() ); aNewModule->SetValue( aOldModule->GetValue() );
// Compare the footprint name only, in case the nickname is empty or in case
// user moved the footprint to a new library. Chances are if footprint name is
// same then the footprint is very nearly the same and the two texts should
// be kept at same size, position, and rotation.
if( aNewModule->GetFPID().GetLibItemName() == aOldModule->GetFPID().GetLibItemName() )
{
aNewModule->Reference().SetEffects( aOldModule->Reference() );
aNewModule->Value().SetEffects( aOldModule->Value() );
}
// Updating other parameters // Updating other parameters
aNewModule->SetTimeStamp( aOldModule->GetTimeStamp() ); aNewModule->SetTimeStamp( aOldModule->GetTimeStamp() );
aNewModule->SetPath( aOldModule->GetPath() ); aNewModule->SetPath( aOldModule->GetPath() );