mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 14:01:44 +00:00
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:
parent
5d9190038f
commit
0c459ced97
3d-viewer/3d_canvas
common
eeschema
autoplace_fields.cpp
dialogs
dialog_edit_component_in_schematic.cppdialog_edit_label.cppdialog_edit_libentry_fields_in_lib.cppdialog_edit_one_field.cppdialog_lib_edit_text.cpp
edit_component_in_schematic.cppedit_label.cpplib_field.cpplib_field.hlib_pin.cpplib_text.cpplib_text.hlibeditframe.cpplibeditframe.hsch_component.cppsch_field.cppsch_field.hsch_legacy_plugin.cppsch_screen.cppsch_sheet.cppsch_sheet.hsch_sheet_pin.cppsch_text.cppsch_text.hsheetlab.cppsymbdraw.cppgerbview
include
pcbnew
autorouter
block_module_editor.cppboard_items_to_polygon_shape_transform.cppclass_board.cppclass_dimension.cppclass_dimension.hclass_drawsegment.cppclass_module.cppclass_pad.cppclass_pcb_text.cppclass_pcb_text.hclass_text_mod.cppclass_text_mod.hdialogs
dialog_edit_module_for_BoardEditor.cppdialog_edit_module_for_Modedit.cppdialog_edit_module_text.cppdialog_global_modules_fields_edition.cppdialog_graphic_item_properties_for_Modedit.cppdialog_pcb_text_properties.cpp
dimension.cppeagle_plugin.cppedit_pcb_text.cppedtxtmod.cppexporters
gpcb_plugin.cppimport_dxf
kicad_plugin.cpplegacy_plugin.cpplibrairi.cppmuonde.cpppcad2kicadpcb_plugin
pcb_painter.cpppcb_parser.cppplot_brditems_plotter.cpptools
xchgmod.cpp@ -93,7 +93,7 @@ void CINFO3D_VISU::AddShapeWithClearanceToContainer( const TEXTE_PCB* aTextPCB,
|
||||
LAYER_ID aLayerId,
|
||||
int aClearanceValue )
|
||||
{
|
||||
wxSize size = aTextPCB->GetSize();
|
||||
wxSize size = aTextPCB->GetTextSize();
|
||||
|
||||
if( aTextPCB->IsMirrored() )
|
||||
size.x = -size.x;
|
||||
@ -121,7 +121,7 @@ void CINFO3D_VISU::AddShapeWithClearanceToContainer( const TEXTE_PCB* aTextPCB,
|
||||
wxString txt = strings_list.Item( ii );
|
||||
|
||||
DrawGraphicText( NULL, NULL, positions[ii], dummy_color,
|
||||
txt, aTextPCB->GetOrientation(), size,
|
||||
txt, aTextPCB->GetTextAngle(), size,
|
||||
aTextPCB->GetHorizJustify(), aTextPCB->GetVertJustify(),
|
||||
aTextPCB->GetThickness(), aTextPCB->IsItalic(),
|
||||
true, addTextSegmToContainer );
|
||||
@ -129,8 +129,8 @@ void CINFO3D_VISU::AddShapeWithClearanceToContainer( const TEXTE_PCB* aTextPCB,
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawGraphicText( NULL, NULL, aTextPCB->GetTextPosition(), dummy_color,
|
||||
aTextPCB->GetShownText(), aTextPCB->GetOrientation(), size,
|
||||
DrawGraphicText( NULL, NULL, aTextPCB->GetTextPos(), dummy_color,
|
||||
aTextPCB->GetShownText(), aTextPCB->GetTextAngle(), size,
|
||||
aTextPCB->GetHorizJustify(), aTextPCB->GetVertJustify(),
|
||||
aTextPCB->GetThickness(), aTextPCB->IsItalic(),
|
||||
true, addTextSegmToContainer );
|
||||
@ -199,12 +199,12 @@ void CINFO3D_VISU::AddGraphicsShapesWithClearanceToContainer( const MODULE* aMod
|
||||
{
|
||||
TEXTE_MODULE *textmod = texts[ii];
|
||||
s_textWidth = textmod->GetThickness() + ( 2 * aInflateValue );
|
||||
wxSize size = textmod->GetSize();
|
||||
wxSize size = textmod->GetTextSize();
|
||||
|
||||
if( textmod->IsMirrored() )
|
||||
size.x = -size.x;
|
||||
|
||||
DrawGraphicText( NULL, NULL, textmod->GetTextPosition(), BLACK,
|
||||
DrawGraphicText( NULL, NULL, textmod->GetTextPos(), BLACK,
|
||||
textmod->GetShownText(), textmod->GetDrawRotation(), size,
|
||||
textmod->GetHorizJustify(), textmod->GetVertJustify(),
|
||||
textmod->GetThickness(), textmod->IsItalic(),
|
||||
|
@ -128,9 +128,9 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
|
||||
case WS_DRAW_ITEM_BASE::wsg_text:
|
||||
{
|
||||
WS_DRAW_ITEM_TEXT* text = (WS_DRAW_ITEM_TEXT*) item;
|
||||
plotter->Text( text->GetTextPosition(), text->GetColor(),
|
||||
text->GetShownText(), text->GetOrientation(),
|
||||
text->GetSize(),
|
||||
plotter->Text( text->GetTextPos(), text->GetColor(),
|
||||
text->GetShownText(), text->GetTextAngle(),
|
||||
text->GetTextSize(),
|
||||
text->GetHorizJustify(), text->GetVertJustify(),
|
||||
text->GetPenWidth(),
|
||||
text->IsItalic(), text->IsBold(),
|
||||
|
@ -160,7 +160,7 @@ void DrawGraphicText( EDA_RECT* aClipBox,
|
||||
if( size.x < 0 )
|
||||
size.x = - size.x;
|
||||
|
||||
dummy.SetSize( size );
|
||||
dummy.SetTextSize( size );
|
||||
|
||||
basic_gal.SetTextAttributes( &dummy );
|
||||
basic_gal.SetPlotter( aPlotter );
|
||||
@ -172,6 +172,7 @@ void DrawGraphicText( EDA_RECT* aClipBox,
|
||||
basic_gal.StrokeText( aText, VECTOR2D( aPos ), aOrient * M_PI/1800 );
|
||||
}
|
||||
|
||||
|
||||
void DrawGraphicHaloText( EDA_RECT* aClipBox, wxDC * aDC,
|
||||
const wxPoint &aPos,
|
||||
enum EDA_COLOR_T aBgColor,
|
||||
|
@ -50,19 +50,12 @@
|
||||
|
||||
#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.
|
||||
m_Orient = 0; // Rotation angle in 0.1 degrees.
|
||||
m_Attributs = 0;
|
||||
m_Mirror = false; // display mirror if true
|
||||
m_HJustify = GR_TEXT_HJUSTIFY_CENTER; // Default horizontal justification is centered.
|
||||
m_VJustify = GR_TEXT_VJUSTIFY_CENTER; // Default vertical justification is centered.
|
||||
m_Thickness = 0; // thickness
|
||||
m_Italic = false; // true = italic shape.
|
||||
m_Bold = false;
|
||||
m_MultilineAllowed = false; // Set to true for multiline text.
|
||||
m_Text = text;
|
||||
int sz = Mils2iu( DEFAULT_SIZE_TEXT );
|
||||
SetTextSize( wxSize( sz, sz ) );
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
NORMALIZE_ANGLE_360( m_Orient );
|
||||
m_e = aSrc.m_e;
|
||||
}
|
||||
|
||||
|
||||
void EDA_TEXT::SwapEffects( EDA_TEXT& aTradingPartner )
|
||||
{
|
||||
std::swap( m_e, aTradingPartner.m_e );
|
||||
}
|
||||
|
||||
|
||||
int EDA_TEXT::LenSize( const wxString& aLine ) const
|
||||
{
|
||||
basic_gal.SetFontItalic( m_Italic );
|
||||
basic_gal.SetFontBold( m_Bold );
|
||||
basic_gal.SetGlyphSize( VECTOR2D( m_Size ) );
|
||||
basic_gal.SetFontItalic( IsItalic() );
|
||||
basic_gal.SetFontBold( IsBold() );
|
||||
basic_gal.SetGlyphSize( VECTOR2D( GetTextSize() ) );
|
||||
|
||||
VECTOR2D tsize = basic_gal.GetTextLineSize( aLine );
|
||||
|
||||
@ -93,6 +91,7 @@ int EDA_TEXT::LenSize( const wxString& aLine ) const
|
||||
wxString EDA_TEXT::ShortenedShownText() const
|
||||
{
|
||||
wxString tmp = GetShownText();
|
||||
|
||||
tmp.Replace( wxT( "\n" ), wxT( " " ) );
|
||||
tmp.Replace( wxT( "\r" ), 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 thickness = aTextThickness <= 0 ? m_Thickness : aTextThickness;
|
||||
return KiROUND( KIGFX::STROKE_FONT::GetInterline( m_Size.y, thickness ) );
|
||||
int thickness = aTextThickness <= 0 ? GetThickness() : aTextThickness;
|
||||
|
||||
return KiROUND( KIGFX::STROKE_FONT::GetInterline( GetTextHeight(), thickness ) );
|
||||
}
|
||||
|
||||
|
||||
EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
|
||||
{
|
||||
EDA_RECT rect;
|
||||
wxArrayString strings;
|
||||
wxString text = GetShownText();
|
||||
int thickness = ( aThickness < 0 ) ? m_Thickness : aThickness;
|
||||
int thickness = ( aThickness < 0 ) ? GetThickness() : aThickness;
|
||||
int linecount = 1;
|
||||
bool hasOverBar = false; // true if the first line of text as an overbar
|
||||
|
||||
if( m_MultilineAllowed )
|
||||
if( IsMultilineAllowed() )
|
||||
{
|
||||
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
|
||||
int dx = KiROUND( basic_gal.GetStrokeFont().ComputeStringBoundaryLimits(
|
||||
text, VECTOR2D( m_Size ), double( thickness ) ).x );
|
||||
text, VECTOR2D( GetTextSize() ), double( thickness ) ).x );
|
||||
int dy = GetInterline( thickness );
|
||||
|
||||
// Creates bounding box (rectangle) for an horizontal
|
||||
// and left and top justified text. the bounding box will be moved later
|
||||
// according to the actual text options
|
||||
wxSize textsize = wxSize( dx, dy );
|
||||
wxPoint pos = m_Pos;
|
||||
wxPoint pos = GetTextPos();
|
||||
|
||||
if( aInvertY )
|
||||
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.
|
||||
// The interval below the last line is not usefull, and we can use its half value
|
||||
// as vertical margin above the text
|
||||
// the full interval is roughly m_Size.y * 0.4 - aThickness/2
|
||||
rect.Move( wxPoint( 0, thickness/4 - KiROUND( m_Size.y * 0.22 ) ) );
|
||||
// the full interval is roughly GetTextHeight() * 0.4 - aThickness/2
|
||||
rect.Move( wxPoint( 0, thickness/4 - KiROUND( GetTextHeight() * 0.22 ) ) );
|
||||
|
||||
if( hasOverBar )
|
||||
{ // A overbar adds an extra size to the text
|
||||
// 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(
|
||||
basic_gal.GetStrokeFont().ComputeOverbarVerticalPosition( m_Size.y, thickness ) - curr_height );
|
||||
basic_gal.GetStrokeFont().ComputeOverbarVerticalPosition( GetTextHeight(), thickness ) - curr_height );
|
||||
extra_height += thickness/2;
|
||||
textsize.y += 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
|
||||
// ( 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++ )
|
||||
{
|
||||
text = strings.Item( ii );
|
||||
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.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
|
||||
* also, note the V justification is relative to the first line
|
||||
*/
|
||||
switch( m_HJustify )
|
||||
switch( GetHorizJustify() )
|
||||
{
|
||||
case GR_TEXT_HJUSTIFY_LEFT:
|
||||
if( m_Mirror )
|
||||
if( IsMirrored() )
|
||||
rect.SetX( rect.GetX() - rect.GetWidth() );
|
||||
break;
|
||||
|
||||
@ -219,14 +214,14 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
|
||||
break;
|
||||
|
||||
case GR_TEXT_HJUSTIFY_RIGHT:
|
||||
if( !m_Mirror )
|
||||
if( !IsMirrored() )
|
||||
rect.SetX( rect.GetX() - rect.GetWidth() );
|
||||
break;
|
||||
}
|
||||
|
||||
dy = m_Size.y + thickness;
|
||||
dy = GetTextHeight() + thickness;
|
||||
|
||||
switch( m_VJustify )
|
||||
switch( GetVertJustify() )
|
||||
{
|
||||
case GR_TEXT_VJUSTIFY_TOP:
|
||||
break;
|
||||
@ -245,7 +240,7 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
|
||||
int yoffset;
|
||||
linecount -= 1;
|
||||
|
||||
switch( m_VJustify )
|
||||
switch( GetVertJustify() )
|
||||
{
|
||||
case GR_TEXT_VJUSTIFY_TOP:
|
||||
break;
|
||||
@ -274,7 +269,7 @@ bool EDA_TEXT::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const
|
||||
wxPoint location = aPoint;
|
||||
|
||||
rect.Inflate( aAccuracy );
|
||||
RotatePoint( &location, m_Pos, -m_Orient );
|
||||
RotatePoint( &location, GetTextPos(), -GetTextAngle() );
|
||||
|
||||
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_DRAW_MODE_T aFillMode, EDA_COLOR_T aAnchor_color )
|
||||
{
|
||||
if( m_MultilineAllowed )
|
||||
if( IsMultilineAllowed() )
|
||||
{
|
||||
std::vector<wxPoint> positions;
|
||||
wxArrayString strings;
|
||||
wxStringSplit( GetShownText(), strings, '\n' );
|
||||
|
||||
positions.reserve( strings.Count() );
|
||||
|
||||
GetPositionsOfLinesOfMultilineText(positions, strings.Count() );
|
||||
GetPositionsOfLinesOfMultilineText( positions, strings.Count() );
|
||||
|
||||
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
|
||||
drawOneLineOfText( aClipBox, aDC, aOffset, aColor,
|
||||
aDrawMode, aFillMode, GetShownText(), m_Pos );
|
||||
aDrawMode, aFillMode, GetShownText(), GetTextPos() );
|
||||
|
||||
// Draw text anchor, if requested
|
||||
if( aAnchor_color != UNSPECIFIED_COLOR )
|
||||
{
|
||||
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 );
|
||||
}
|
||||
}
|
||||
@ -330,17 +326,17 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
|
||||
void EDA_TEXT::GetPositionsOfLinesOfMultilineText(
|
||||
std::vector<wxPoint>& aPositions, int aLineCount ) const
|
||||
{
|
||||
wxPoint pos = m_Pos; // Position of first line of the
|
||||
// multiline text according to
|
||||
// the center of the multiline text block
|
||||
wxPoint pos = GetTextPos(); // Position of first line of the
|
||||
// multiline text according to
|
||||
// the center of the multiline text block
|
||||
|
||||
wxPoint offset; // Offset to next line.
|
||||
wxPoint offset; // Offset to next line.
|
||||
|
||||
offset.y = GetInterline();
|
||||
|
||||
if( aLineCount > 1 )
|
||||
{
|
||||
switch( m_VJustify )
|
||||
switch( GetVertJustify() )
|
||||
{
|
||||
case GR_TEXT_VJUSTIFY_TOP:
|
||||
break;
|
||||
@ -357,10 +353,10 @@ void EDA_TEXT::GetPositionsOfLinesOfMultilineText(
|
||||
|
||||
// Rotate the position of the first line
|
||||
// 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
|
||||
RotatePoint( &offset, m_Orient );
|
||||
RotatePoint( &offset, GetTextAngle() );
|
||||
|
||||
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,
|
||||
const wxString& aText, const wxPoint &aPos )
|
||||
{
|
||||
int width = m_Thickness;
|
||||
int width = GetThickness();
|
||||
|
||||
if( aDrawMode != UNSPECIFIED_DRAWMODE )
|
||||
GRSetDrawMode( aDC, aDrawMode );
|
||||
@ -382,13 +378,14 @@ void EDA_TEXT::drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC,
|
||||
if( aFillMode == SKETCH )
|
||||
width = -width;
|
||||
|
||||
wxSize size = m_Size;
|
||||
wxSize size = GetTextSize();
|
||||
|
||||
if( m_Mirror )
|
||||
if( IsMirrored() )
|
||||
size.x = -size.x;
|
||||
|
||||
DrawGraphicText( aClipBox, aDC, aOffset + aPos, aColor, aText, m_Orient, size,
|
||||
m_HJustify, m_VJustify, width, m_Italic, m_Bold );
|
||||
DrawGraphicText( aClipBox, aDC, aOffset + aPos, aColor, aText, GetTextAngle(), size,
|
||||
GetHorizJustify(), GetVertJustify(),
|
||||
width, IsItalic(), IsBold() );
|
||||
}
|
||||
|
||||
|
||||
@ -396,10 +393,10 @@ wxString EDA_TEXT::GetTextStyleName()
|
||||
{
|
||||
int style = 0;
|
||||
|
||||
if( m_Italic )
|
||||
if( IsItalic() )
|
||||
style = 1;
|
||||
|
||||
if( m_Bold )
|
||||
if( IsBold() )
|
||||
style += 2;
|
||||
|
||||
wxString stylemsg[4] = {
|
||||
@ -415,16 +412,17 @@ wxString EDA_TEXT::GetTextStyleName()
|
||||
|
||||
bool EDA_TEXT::IsDefaultFormatting() const
|
||||
{
|
||||
return ( ( m_Size.x == Mils2iu( DEFAULT_SIZE_TEXT ) )
|
||||
&& ( m_Size.y == Mils2iu( DEFAULT_SIZE_TEXT ) )
|
||||
&& ( m_Attributs == 0 )
|
||||
&& ( m_Mirror == false )
|
||||
&& ( m_HJustify == GR_TEXT_HJUSTIFY_CENTER )
|
||||
&& ( m_VJustify == GR_TEXT_VJUSTIFY_CENTER )
|
||||
&& ( m_Thickness == 0 )
|
||||
&& ( m_Italic == false )
|
||||
&& ( m_Bold == false )
|
||||
&& ( m_MultilineAllowed == false ) );
|
||||
return ( GetTextWidth() == Mils2iu( DEFAULT_SIZE_TEXT )
|
||||
&& GetTextHeight() == Mils2iu( DEFAULT_SIZE_TEXT )
|
||||
&& IsVisible()
|
||||
&& !IsMirrored()
|
||||
&& GetHorizJustify() == GR_TEXT_HJUSTIFY_CENTER
|
||||
&& GetVertJustify() == GR_TEXT_VJUSTIFY_CENTER
|
||||
&& GetThickness() == 0
|
||||
&& !IsItalic()
|
||||
&& !IsBold()
|
||||
&& !IsMultilineAllowed()
|
||||
);
|
||||
}
|
||||
|
||||
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" );
|
||||
|
||||
if( ( m_Size.x != Mils2iu( DEFAULT_SIZE_TEXT ) )
|
||||
|| ( m_Size.y != Mils2iu( DEFAULT_SIZE_TEXT ) )
|
||||
|| ( m_Thickness != 0 ) || m_Bold || m_Italic )
|
||||
if( ( GetTextWidth() != Mils2iu( DEFAULT_SIZE_TEXT ) )
|
||||
|| ( GetTextHeight() != Mils2iu( DEFAULT_SIZE_TEXT ) )
|
||||
|| ( GetThickness() != 0 ) || IsBold() || IsItalic() )
|
||||
{
|
||||
aFormatter->Print( 0, " (font" );
|
||||
|
||||
// Add font support here at some point in the future.
|
||||
|
||||
if( ( m_Size.x != Mils2iu( DEFAULT_SIZE_TEXT ) )
|
||||
|| ( m_Size.y != Mils2iu( DEFAULT_SIZE_TEXT ) ) )
|
||||
aFormatter->Print( 0, " (size %s %s)", FMT_IU( m_Size.GetHeight() ).c_str(),
|
||||
FMT_IU( m_Size.GetWidth() ).c_str() );
|
||||
if( GetTextWidth() != Mils2iu( DEFAULT_SIZE_TEXT )
|
||||
|| GetTextHeight() != Mils2iu( DEFAULT_SIZE_TEXT ) )
|
||||
{
|
||||
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() );
|
||||
|
||||
if( m_Bold )
|
||||
if( IsBold() )
|
||||
aFormatter->Print( 0, " bold" );
|
||||
|
||||
if( IsItalic() )
|
||||
@ -462,25 +464,25 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
|
||||
aFormatter->Print( 0, ")");
|
||||
}
|
||||
|
||||
if( m_Mirror || ( m_HJustify != GR_TEXT_HJUSTIFY_CENTER )
|
||||
|| ( m_VJustify != GR_TEXT_VJUSTIFY_CENTER ) )
|
||||
if( IsMirrored() || ( GetHorizJustify() != GR_TEXT_HJUSTIFY_CENTER )
|
||||
|| ( GetVertJustify() != GR_TEXT_VJUSTIFY_CENTER ) )
|
||||
{
|
||||
aFormatter->Print( 0, " (justify");
|
||||
|
||||
if( m_HJustify != GR_TEXT_HJUSTIFY_CENTER )
|
||||
aFormatter->Print( 0, (m_HJustify == GR_TEXT_HJUSTIFY_LEFT) ? " left" : " right" );
|
||||
if( GetHorizJustify() != GR_TEXT_HJUSTIFY_CENTER )
|
||||
aFormatter->Print( 0, (GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT) ? " left" : " right" );
|
||||
|
||||
if( m_VJustify != GR_TEXT_VJUSTIFY_CENTER )
|
||||
aFormatter->Print( 0, (m_VJustify == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" );
|
||||
if( GetVertJustify() != GR_TEXT_VJUSTIFY_CENTER )
|
||||
aFormatter->Print( 0, (GetVertJustify() == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" );
|
||||
|
||||
if( m_Mirror )
|
||||
if( IsMirrored() )
|
||||
aFormatter->Print( 0, " mirror" );
|
||||
|
||||
aFormatter->Print( 0, ")" );
|
||||
}
|
||||
|
||||
// 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, ")\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
|
||||
{
|
||||
wxSize size = GetSize();
|
||||
wxSize size = GetTextSize();
|
||||
|
||||
if( IsMirrored() )
|
||||
size.x = -size.x;
|
||||
@ -523,7 +525,7 @@ void EDA_TEXT::TransformTextShapeToSegmentList( std::vector<wxPoint>& aCornerBuf
|
||||
{
|
||||
wxString txt = strings_list.Item( ii );
|
||||
DrawGraphicText( NULL, NULL, positions[ii], color,
|
||||
txt, GetOrientation(), size,
|
||||
txt, GetTextAngle(), size,
|
||||
GetHorizJustify(), GetVertJustify(),
|
||||
GetThickness(), IsItalic(),
|
||||
true, addTextSegmToBuffer );
|
||||
@ -531,8 +533,8 @@ void EDA_TEXT::TransformTextShapeToSegmentList( std::vector<wxPoint>& aCornerBuf
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawGraphicText( NULL, NULL, GetTextPosition(), color,
|
||||
GetText(), GetOrientation(), size,
|
||||
DrawGraphicText( NULL, NULL, GetTextPos(), color,
|
||||
GetText(), GetTextAngle(), size,
|
||||
GetHorizJustify(), GetVertJustify(),
|
||||
GetThickness(), IsItalic(),
|
||||
true, addTextSegmToBuffer );
|
||||
|
@ -78,7 +78,7 @@ GAL::~GAL()
|
||||
|
||||
void GAL::SetTextAttributes( const EDA_TEXT* aText )
|
||||
{
|
||||
SetGlyphSize( VECTOR2D( aText->GetSize() ) );
|
||||
SetGlyphSize( VECTOR2D( aText->GetTextSize() ) );
|
||||
SetHorizontalJustify( aText->GetHorizJustify() );
|
||||
SetVerticalJustify( aText->GetVertJustify() );
|
||||
SetFontBold( aText->IsBold() );
|
||||
@ -86,6 +86,7 @@ void GAL::SetTextAttributes( const EDA_TEXT* aText )
|
||||
SetTextMirrored( aText->IsMirrored() );
|
||||
}
|
||||
|
||||
|
||||
VECTOR2D GAL::GetTextLineSize( const UTF8& aText ) const
|
||||
{
|
||||
// Compute the X and Y size of a given text.
|
||||
|
@ -467,7 +467,7 @@ void WORKSHEET_DATAITEM_TEXT::TransfertSetupToGraphicText( WS_DRAW_ITEM_TEXT* aG
|
||||
{
|
||||
aGText->SetHorizJustify( m_Hjustify ) ;
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
||||
if( markerSize )
|
||||
drawMarker( aClipBox, aDC, text->GetTextPosition(),
|
||||
drawMarker( aClipBox, aDC, text->GetTextPos(),
|
||||
markerSize );
|
||||
}
|
||||
break;
|
||||
@ -179,8 +179,8 @@ WS_DRAW_ITEM_TEXT::WS_DRAW_ITEM_TEXT( WORKSHEET_DATAITEM* aParent,
|
||||
bool aItalic, bool aBold ) :
|
||||
WS_DRAW_ITEM_BASE( aParent, wsg_text, aColor ), EDA_TEXT( aText )
|
||||
{
|
||||
SetTextPosition( aPos );
|
||||
SetSize( aSize );
|
||||
SetTextPos( aPos );
|
||||
SetTextSize( aSize );
|
||||
SetThickness( aPenWidth );
|
||||
SetItalic( aItalic );
|
||||
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)
|
||||
{
|
||||
wxPoint pos = GetTextPosition();
|
||||
wxPoint pos = GetTextPos();
|
||||
|
||||
if( std::abs( pos.x - aPosition.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
|
||||
std::abs( pos.y - aPosition.y) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 )
|
||||
|
@ -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
|
||||
{
|
||||
VECTOR2D position( aItem->GetTextPosition().x, aItem->GetTextPosition().y );
|
||||
VECTOR2D position( aItem->GetTextPos().x, aItem->GetTextPos().y );
|
||||
|
||||
aGal->Save();
|
||||
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->SetLineWidth( aItem->GetThickness() );
|
||||
aGal->SetTextAttributes( aItem );
|
||||
|
@ -195,11 +195,11 @@ protected:
|
||||
|
||||
if( m_component->GetTransform().y1 )
|
||||
{
|
||||
field->SetOrientation( TEXT_ORIENT_VERT );
|
||||
field->SetTextAngle( TEXT_ANGLE_VERT );
|
||||
}
|
||||
else
|
||||
{
|
||||
field->SetOrientation( TEXT_ORIENT_HORIZ );
|
||||
field->SetTextAngle( TEXT_ANGLE_HORIZ );
|
||||
}
|
||||
|
||||
field_width = field->GetBoundingBox().GetWidth();
|
||||
|
@ -480,7 +480,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event
|
||||
// change all field positions from relative to absolute
|
||||
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 );
|
||||
@ -514,7 +514,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::addFieldButtonHandler( wxCommandEvent&
|
||||
|
||||
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[fieldNdx].SetName( TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldNdx ) );
|
||||
@ -680,8 +680,9 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
|
||||
#if 0 && defined(DEBUG)
|
||||
for( int i = 0; i<aComponent->GetFieldCount(); ++i )
|
||||
{
|
||||
printf( "Orig[%d] (x=%d, y=%d)\n", i, aComponent->m_Fields[i].GetTextPosition().x,
|
||||
aComponent->m_Fields[i].GetTextPosition().y );
|
||||
printf( "Orig[%d] (x=%d, y=%d)\n", i,
|
||||
aComponent->m_Fields[i].GetTextPos().x,
|
||||
aComponent->m_Fields[i].GetTextPos().y );
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -698,7 +699,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
|
||||
m_FieldsBuf.push_back( aComponent->m_Fields[i] );
|
||||
|
||||
// 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:
|
||||
@ -731,7 +732,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
|
||||
fld = *schField;
|
||||
|
||||
// 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 );
|
||||
@ -750,8 +751,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
|
||||
m_FieldsBuf.push_back( *cmp );
|
||||
|
||||
// make the editable field position relative to the component
|
||||
m_FieldsBuf[newNdx].SetTextPosition( m_FieldsBuf[newNdx].GetTextPosition() -
|
||||
m_cmp->m_Pos );
|
||||
m_FieldsBuf[newNdx].Offset( -m_cmp->m_Pos );
|
||||
}
|
||||
}
|
||||
|
||||
@ -837,7 +837,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
|
||||
|
||||
showCheckBox->SetValue( field.IsVisible() );
|
||||
|
||||
rotateCheckBox->SetValue( field.GetOrientation() == TEXT_ORIENT_VERT );
|
||||
rotateCheckBox->SetValue( field.GetTextAngle() == TEXT_ANGLE_VERT );
|
||||
|
||||
int style = 0;
|
||||
|
||||
@ -910,9 +910,9 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
|
||||
else
|
||||
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
|
||||
|
||||
// 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.
|
||||
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;
|
||||
|
||||
coord.y = m_FieldsBuf[REFERENCE].GetTextPosition().y
|
||||
coord.y = m_FieldsBuf[REFERENCE].GetTextPos().y
|
||||
+ ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100;
|
||||
|
||||
// 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() );
|
||||
|
||||
if( rotateCheckBox->GetValue() )
|
||||
field.SetOrientation( TEXT_ORIENT_VERT );
|
||||
field.SetTextAngle( TEXT_ANGLE_VERT );
|
||||
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
|
||||
static const EDA_TEXT_HJUSTIFY_T hjustify[] = {
|
||||
@ -994,7 +994,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField()
|
||||
setRowItem( fieldNdx, field ); // update fieldListCtrl
|
||||
|
||||
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();
|
||||
|
||||
field.SetItalic( (style & 1 ) != 0 );
|
||||
@ -1003,7 +1003,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField()
|
||||
wxPoint pos;
|
||||
pos.x = ValueFromString( g_UserUnit, posXTextCtrl->GetValue() );
|
||||
pos.y = ValueFromString( g_UserUnit, posYTextCtrl->GetValue() );
|
||||
field.SetTextPosition( pos );
|
||||
field.SetTextPos( pos );
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1110,19 +1110,19 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
|
||||
// Only VALUE, REFERENCE , FOOTPRINT and DATASHEET are re-initialized
|
||||
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 );
|
||||
|
||||
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 );
|
||||
|
||||
LIB_FIELD* field = part->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 );
|
||||
}
|
||||
|
||||
@ -1130,7 +1130,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ void DIALOG_LABEL_EDITOR::InitDialog()
|
||||
EnsureTextCtrlWidth( m_textLabel, &textWidth );
|
||||
|
||||
// Set validators
|
||||
m_TextOrient->SetSelection( m_CurrentText->GetOrientation() );
|
||||
m_TextOrient->SetSelection( m_CurrentText->GetTextAngle() );
|
||||
m_TextShape->SetSelection( m_CurrentText->GetShape() );
|
||||
|
||||
int style = 0;
|
||||
@ -223,7 +223,7 @@ void DIALOG_LABEL_EDITOR::InitDialog()
|
||||
msg.Printf( _( "H%s x W%s" ), GetChars( units ), GetChars( units ) );
|
||||
m_staticSizeUnits->SetLabel( msg );
|
||||
|
||||
msg = StringFromValue( g_UserUnit, m_CurrentText->GetSize().x );
|
||||
msg = StringFromValue( g_UserUnit, m_CurrentText->GetTextWidth() );
|
||||
m_TextSize->SetValue( msg );
|
||||
|
||||
if( m_CurrentText->Type() != SCH_GLOBAL_LABEL_T
|
||||
@ -290,10 +290,10 @@ void DIALOG_LABEL_EDITOR::TextPropertiesAccept( wxCommandEvent& aEvent )
|
||||
return;
|
||||
}
|
||||
|
||||
m_CurrentText->SetOrientation( m_TextOrient->GetSelection() );
|
||||
m_CurrentText->SetLabelSpinStyle( m_TextOrient->GetSelection() );
|
||||
text = m_TextSize->GetValue();
|
||||
value = ValueFromString( g_UserUnit, text );
|
||||
m_CurrentText->SetSize( wxSize( value, value ) );
|
||||
m_CurrentText->SetTextSize( wxSize( value, value ) );
|
||||
|
||||
if( m_TextShape )
|
||||
/// @todo move cast to widget
|
||||
@ -306,7 +306,7 @@ void DIALOG_LABEL_EDITOR::TextPropertiesAccept( wxCommandEvent& aEvent )
|
||||
if( ( style & 2 ) )
|
||||
{
|
||||
m_CurrentText->SetBold( true );
|
||||
m_CurrentText->SetThickness( GetPenSizeForBold( m_CurrentText->GetSize().x ) );
|
||||
m_CurrentText->SetThickness( GetPenSizeForBold( m_CurrentText->GetTextWidth() ) );
|
||||
}
|
||||
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 ):
|
||||
if( m_CurrentText->IsNew() )
|
||||
SetDefaultTextSize( m_CurrentText->GetSize().x );
|
||||
SetDefaultTextSize( m_CurrentText->GetTextWidth() );
|
||||
|
||||
m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentText->GetBoundingBox() );
|
||||
m_Parent->GetCanvas()->MoveCursorToCrossHair();
|
||||
|
@ -671,7 +671,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
|
||||
|
||||
showCheckBox->SetValue( field.IsVisible() );
|
||||
|
||||
rotateCheckBox->SetValue( field.GetOrientation() == TEXT_ORIENT_VERT );
|
||||
rotateCheckBox->SetValue( field.GetTextAngle() == TEXT_ANGLE_VERT );
|
||||
|
||||
int style = 0;
|
||||
|
||||
@ -730,7 +730,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
|
||||
fieldValueTextCtrl->SetValidator( SCH_FIELD_VALIDATOR( true, field.GetId() ) );
|
||||
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 );
|
||||
|
||||
@ -754,7 +754,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
|
||||
_("Used only for fields Footprint and Datasheet.") );
|
||||
}
|
||||
|
||||
wxPoint coord = field.GetTextPosition();
|
||||
wxPoint coord = field.GetTextPos();
|
||||
wxPoint zero;
|
||||
|
||||
// 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.
|
||||
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;
|
||||
coord.y = m_FieldsBuf[REFERENCE].GetTextPosition().y +
|
||||
coord.y = m_FieldsBuf[REFERENCE].GetTextPos().y +
|
||||
(fieldNdx - MANDATORY_FIELDS + 1) * 100;
|
||||
|
||||
// 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 );
|
||||
|
||||
if( rotateCheckBox->GetValue() )
|
||||
field.SetOrientation( TEXT_ORIENT_VERT );
|
||||
field.SetTextAngle( TEXT_ANGLE_VERT );
|
||||
else
|
||||
field.SetOrientation( TEXT_ORIENT_HORIZ );
|
||||
field.SetTextAngle( TEXT_ANGLE_HORIZ );
|
||||
|
||||
// Copy the text justification
|
||||
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 );
|
||||
|
||||
field.SetSize( wxSize( tmp, tmp ) );
|
||||
field.SetTextSize( wxSize( tmp, tmp ) );
|
||||
|
||||
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
|
||||
pos.y = -pos.y;
|
||||
|
||||
field.SetTextPosition( pos );
|
||||
field.SetTextPos( pos );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -89,8 +89,8 @@ DIALOG_EDIT_ONE_FIELD::DIALOG_EDIT_ONE_FIELD( SCH_BASE_FRAME* aParent, const wxS
|
||||
m_text = aTextItem->GetText();
|
||||
m_style = aTextItem->IsItalic() ? 1 : 0;
|
||||
m_style += aTextItem->IsBold() ? 2 : 0;
|
||||
m_size = aTextItem->GetSize().x;
|
||||
m_orientation = ( aTextItem->GetOrientation() == TEXT_ORIENT_VERT );
|
||||
m_size = aTextItem->GetTextWidth();
|
||||
m_orientation = ( aTextItem->GetTextAngle() == TEXT_ANGLE_VERT );
|
||||
m_verticalJustification = aTextItem->GetVertJustify() + 1;
|
||||
m_horizontalJustification = aTextItem->GetHorizJustify() + 1;
|
||||
m_isVisible = aTextItem->IsVisible();
|
||||
@ -211,9 +211,9 @@ bool DIALOG_EDIT_ONE_FIELD::TransferDataFromWindow()
|
||||
|
||||
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->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->SetBold( (m_style & 2) != 0 );
|
||||
aText->SetHorizJustify( IntToEdaTextHorizJustify( m_horizontalJustification - 1 ) );
|
||||
|
@ -64,41 +64,40 @@ void DIALOG_LIB_EDIT_TEXT::initDlg( )
|
||||
// Disable options for fieldedition, not existing in graphic text
|
||||
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_TextValue->SetValue( m_graphicText->GetText() );
|
||||
|
||||
if ( m_graphicText->GetUnit() == 0 )
|
||||
if( m_graphicText->GetUnit() == 0 )
|
||||
m_CommonUnit->SetValue( true );
|
||||
if ( m_graphicText->GetConvert() == 0 )
|
||||
if( m_graphicText->GetConvert() == 0 )
|
||||
m_CommonConvert->SetValue( true );
|
||||
if ( m_graphicText->GetOrientation() == TEXT_ORIENT_VERT )
|
||||
if( m_graphicText->GetTextAngle() == TEXT_ANGLE_VERT )
|
||||
m_Orient->SetValue( true );
|
||||
|
||||
int shape = 0;
|
||||
if ( m_graphicText->IsItalic() )
|
||||
if( m_graphicText->IsItalic() )
|
||||
shape = 1;
|
||||
if ( m_graphicText->IsBold() )
|
||||
if( m_graphicText->IsBold() )
|
||||
shape |= 2;
|
||||
|
||||
m_TextShapeOpt->SetSelection( shape );
|
||||
|
||||
switch ( m_graphicText->GetHorizJustify() )
|
||||
{
|
||||
case GR_TEXT_HJUSTIFY_LEFT:
|
||||
m_TextHJustificationOpt->SetSelection( 0 );
|
||||
break;
|
||||
case GR_TEXT_HJUSTIFY_LEFT:
|
||||
m_TextHJustificationOpt->SetSelection( 0 );
|
||||
break;
|
||||
|
||||
case GR_TEXT_HJUSTIFY_CENTER:
|
||||
m_TextHJustificationOpt->SetSelection( 1 );
|
||||
break;
|
||||
|
||||
case GR_TEXT_HJUSTIFY_RIGHT:
|
||||
m_TextHJustificationOpt->SetSelection( 2 );
|
||||
break;
|
||||
case GR_TEXT_HJUSTIFY_CENTER:
|
||||
m_TextHJustificationOpt->SetSelection( 1 );
|
||||
break;
|
||||
|
||||
case GR_TEXT_HJUSTIFY_RIGHT:
|
||||
m_TextHJustificationOpt->SetSelection( 2 );
|
||||
break;
|
||||
}
|
||||
|
||||
switch ( m_graphicText->GetVertJustify() )
|
||||
@ -121,11 +120,11 @@ void DIALOG_LIB_EDIT_TEXT::initDlg( )
|
||||
msg = StringFromValue( g_UserUnit, m_parent->m_textSize );
|
||||
m_TextSize->SetValue( msg );
|
||||
|
||||
if ( ! m_parent->m_drawSpecificUnit )
|
||||
if( ! m_parent->m_drawSpecificUnit )
|
||||
m_CommonUnit->SetValue( true );
|
||||
if ( ! m_parent->m_drawSpecificConvert )
|
||||
if( ! m_parent->m_drawSpecificConvert )
|
||||
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 );
|
||||
}
|
||||
|
||||
@ -155,7 +154,7 @@ void DIALOG_LIB_EDIT_TEXT::OnOkClick( wxCommandEvent& event )
|
||||
wxString Line;
|
||||
|
||||
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();
|
||||
m_parent->m_textSize = ValueFromString( g_UserUnit, msg );
|
||||
m_parent->m_drawSpecificConvert = m_CommonConvert->GetValue() ? false : true;
|
||||
@ -168,8 +167,8 @@ void DIALOG_LIB_EDIT_TEXT::OnOkClick( wxCommandEvent& event )
|
||||
else
|
||||
m_graphicText->SetText( wxT( "[null]" ) );
|
||||
|
||||
m_graphicText->SetSize( wxSize( m_parent->m_textSize, m_parent->m_textSize ) );
|
||||
m_graphicText->SetOrientation( m_parent->m_textOrientation );
|
||||
m_graphicText->SetTextSize( wxSize( m_parent->m_textSize, m_parent->m_textSize ) );
|
||||
m_graphicText->SetTextAngle( m_parent->m_current_text_angle );
|
||||
|
||||
if( m_parent->m_drawSpecificUnit )
|
||||
m_graphicText->SetUnit( m_parent->GetUnit() );
|
||||
|
@ -107,10 +107,10 @@ void SCH_EDIT_FRAME::RotateField( SCH_FIELD* aField )
|
||||
if( aField->GetFlags() == 0 )
|
||||
SaveCopyInUndoList( component, UR_CHANGED );
|
||||
|
||||
if( aField->GetOrientation() == TEXT_ORIENT_HORIZ )
|
||||
aField->SetOrientation( TEXT_ORIENT_VERT );
|
||||
if( aField->GetTextAngle() == TEXT_ANGLE_HORIZ )
|
||||
aField->SetTextAngle( TEXT_ANGLE_VERT );
|
||||
else
|
||||
aField->SetOrientation( TEXT_ORIENT_HORIZ );
|
||||
aField->SetTextAngle( TEXT_ANGLE_HORIZ );
|
||||
|
||||
OnModify();
|
||||
}
|
||||
|
@ -52,13 +52,13 @@ void SCH_EDIT_FRAME::ChangeTextOrient( SCH_TEXT* aTextItem )
|
||||
wxCHECK_RET( (aTextItem != NULL) && aTextItem->CanIncrementLabel(),
|
||||
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.
|
||||
if( aTextItem->GetFlags() == 0 )
|
||||
SaveCopyInUndoList( aTextItem, UR_CHANGED );
|
||||
|
||||
aTextItem->SetOrientation( orient );
|
||||
aTextItem->SetLabelSpinStyle( orient );
|
||||
OnModify();
|
||||
}
|
||||
|
||||
@ -96,8 +96,8 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* aDC, int aType )
|
||||
|
||||
textItem->SetBold( lastTextBold );
|
||||
textItem->SetItalic( lastTextItalic );
|
||||
textItem->SetOrientation( lastTextOrientation );
|
||||
textItem->SetSize( wxSize( GetDefaultTextSize(), GetDefaultTextSize() ) );
|
||||
textItem->SetLabelSpinStyle( lastTextOrientation );
|
||||
textItem->SetTextSize( wxSize( GetDefaultTextSize(), GetDefaultTextSize() ) );
|
||||
textItem->SetFlags( IS_NEW | IS_MOVED );
|
||||
|
||||
EditSchematicText( textItem );
|
||||
@ -110,7 +110,7 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* aDC, int aType )
|
||||
|
||||
lastTextBold = textItem->IsBold();
|
||||
lastTextItalic = textItem->IsItalic();
|
||||
lastTextOrientation = textItem->GetOrientation();
|
||||
lastTextOrientation = textItem->GetLabelSpinStyle();
|
||||
|
||||
if( ( textItem->Type() == SCH_GLOBAL_LABEL_T ) ||
|
||||
( textItem->Type() == SCH_HIERARCHICAL_LABEL_T ) )
|
||||
@ -205,8 +205,8 @@ void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent )
|
||||
*/
|
||||
newtext->SetFlags( text->GetFlags() );
|
||||
newtext->SetShape( text->GetShape() );
|
||||
newtext->SetOrientation( text->GetOrientation() );
|
||||
newtext->SetSize( text->GetSize() );
|
||||
newtext->SetLabelSpinStyle( text->GetLabelSpinStyle() );
|
||||
newtext->SetTextSize( text->GetTextSize() );
|
||||
newtext->SetThickness( text->GetThickness() );
|
||||
newtext->SetItalic( text->IsItalic() );
|
||||
newtext->SetBold( text->IsBold() );
|
||||
|
@ -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 );
|
||||
}
|
||||
@ -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 )
|
||||
{
|
||||
m_id = id;
|
||||
m_Size.x = GetDefaultTextSize();
|
||||
m_Size.y = GetDefaultTextSize();
|
||||
|
||||
SetTextWidth( GetDefaultTextSize() );
|
||||
SetTextHeight( GetDefaultTextSize() );
|
||||
|
||||
m_typeName = _( "Field" );
|
||||
m_Orient = TEXT_ORIENT_HORIZ;
|
||||
|
||||
SetTextAngle( TEXT_ANGLE_HORIZ ); // constructor already did this.
|
||||
|
||||
m_rotate = false;
|
||||
m_updateText = false;
|
||||
|
||||
@ -99,27 +115,27 @@ bool LIB_FIELD::Save( OUTPUTFORMATTER& aFormatter )
|
||||
|
||||
hjustify = 'C';
|
||||
|
||||
if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT )
|
||||
if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
|
||||
hjustify = 'L';
|
||||
else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT )
|
||||
else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
|
||||
hjustify = 'R';
|
||||
|
||||
vjustify = 'C';
|
||||
|
||||
if( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM )
|
||||
if( GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
|
||||
vjustify = 'B';
|
||||
else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP )
|
||||
else if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
|
||||
vjustify = 'T';
|
||||
|
||||
aFormatter.Print( 0, "F%d %s %d %d %d %c %c %c %c%c%c",
|
||||
m_id,
|
||||
EscapedUTF8( text ).c_str(), // wraps in quotes
|
||||
m_Pos.x, m_Pos.y, m_Size.x,
|
||||
m_Orient == 0 ? 'H' : 'V',
|
||||
(m_Attributs & TEXT_NO_VISIBLE ) ? 'I' : 'V',
|
||||
GetTextPos().x, GetTextPos().y, GetTextWidth(),
|
||||
GetTextAngle() == 0 ? 'H' : 'V',
|
||||
IsVisible() ? 'V' : 'I',
|
||||
hjustify, vjustify,
|
||||
m_Italic ? 'I' : 'N',
|
||||
m_Bold ? 'B' : 'N' );
|
||||
IsItalic() ? 'I' : 'N',
|
||||
IsBold() ? 'B' : 'N' );
|
||||
|
||||
/* Save field name, if necessary
|
||||
* 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 )
|
||||
{
|
||||
int cnt;
|
||||
int x, y, size;
|
||||
char textOrient;
|
||||
char textVisible;
|
||||
char textHJustify;
|
||||
@ -171,7 +188,7 @@ bool LIB_FIELD::Load( LINE_READER& aLineReader, wxString& errorMsg )
|
||||
|
||||
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 );
|
||||
|
||||
if( cnt < 5 )
|
||||
@ -181,12 +198,13 @@ bool LIB_FIELD::Load( LINE_READER& aLineReader, wxString& errorMsg )
|
||||
return false;
|
||||
}
|
||||
|
||||
m_Size.x = m_Size.y;
|
||||
SetTextPos( wxPoint( x, y ) );
|
||||
SetTextSize( wxSize( size, size ) );
|
||||
|
||||
if( textOrient == 'H' )
|
||||
m_Orient = TEXT_ORIENT_HORIZ;
|
||||
SetTextAngle( TEXT_ANGLE_HORIZ );
|
||||
else if( textOrient == 'V' )
|
||||
m_Orient = TEXT_ORIENT_VERT;
|
||||
SetTextAngle( TEXT_ANGLE_VERT );
|
||||
else
|
||||
{
|
||||
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' )
|
||||
m_Attributs &= ~TEXT_NO_VISIBLE;
|
||||
else if ( textVisible == 'I' )
|
||||
m_Attributs |= TEXT_NO_VISIBLE;
|
||||
SetVisible( true );
|
||||
else if( textVisible == 'I' )
|
||||
SetVisible( false );
|
||||
else
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
m_HJustify = GR_TEXT_HJUSTIFY_CENTER;
|
||||
m_VJustify = GR_TEXT_VJUSTIFY_CENTER;
|
||||
SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
|
||||
SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
|
||||
|
||||
if( cnt >= 6 )
|
||||
{
|
||||
if( textHJustify == 'C' )
|
||||
m_HJustify = GR_TEXT_HJUSTIFY_CENTER;
|
||||
SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
|
||||
else if( textHJustify == 'L' )
|
||||
m_HJustify = GR_TEXT_HJUSTIFY_LEFT;
|
||||
SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
||||
else if( textHJustify == 'R' )
|
||||
m_HJustify = GR_TEXT_HJUSTIFY_RIGHT;
|
||||
SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
||||
else
|
||||
{
|
||||
errorMsg.Printf(
|
||||
@ -225,11 +243,11 @@ bool LIB_FIELD::Load( LINE_READER& aLineReader, wxString& errorMsg )
|
||||
}
|
||||
|
||||
if( textVJustify[0] == 'C' )
|
||||
m_VJustify = GR_TEXT_VJUSTIFY_CENTER;
|
||||
SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
|
||||
else if( textVJustify[0] == 'B' )
|
||||
m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM;
|
||||
SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
|
||||
else if( textVJustify[0] == 'T' )
|
||||
m_VJustify = GR_TEXT_VJUSTIFY_TOP;
|
||||
SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
|
||||
else
|
||||
{
|
||||
errorMsg.Printf(
|
||||
@ -238,10 +256,10 @@ bool LIB_FIELD::Load( LINE_READER& aLineReader, wxString& errorMsg )
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( textVJustify[1] == 'I' ) // Italic
|
||||
m_Italic = true;
|
||||
if ( textVJustify[2] == 'B' ) // Bold
|
||||
m_Bold = true;
|
||||
if( textVJustify[1] == 'I' ) // Italic
|
||||
SetItalic( true );
|
||||
if( textVJustify[2] == 'B' ) // Bold
|
||||
SetBold( true );
|
||||
}
|
||||
|
||||
// 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
|
||||
{
|
||||
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 linewidth = GetPenSize();
|
||||
|
||||
if( m_Bold )
|
||||
linewidth = GetPenSizeForBold( m_Size.x );
|
||||
if( IsBold() )
|
||||
linewidth = GetPenSizeForBold( GetTextWidth() );
|
||||
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();
|
||||
}
|
||||
else if( IsSelected() && ( aColor < 0 ) )
|
||||
else if( IsSelected() && aColor < 0 )
|
||||
{
|
||||
color = GetItemSelectedColor();
|
||||
}
|
||||
@ -296,7 +314,7 @@ void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a
|
||||
if( color < 0 )
|
||||
color = GetDefaultColor();
|
||||
|
||||
text_pos = aTransform.TransformCoordinate( m_Pos ) + aOffset;
|
||||
text_pos = aTransform.TransformCoordinate( GetTextPos() ) + aOffset;
|
||||
|
||||
wxString text;
|
||||
|
||||
@ -307,8 +325,10 @@ void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a
|
||||
|
||||
GRSetDrawMode( aDC, aDrawMode );
|
||||
EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL;
|
||||
DrawGraphicText( clipbox, aDC, text_pos, (EDA_COLOR_T) color, text, m_Orient, m_Size,
|
||||
m_HJustify, m_VJustify, linewidth, m_Italic, m_Bold );
|
||||
DrawGraphicText( clipbox, aDC, text_pos, (EDA_COLOR_T) color, text,
|
||||
GetTextAngle(), GetTextSize(),
|
||||
GetHorizJustify(), GetVertJustify(),
|
||||
linewidth, IsItalic(), IsBold() );
|
||||
|
||||
/* Set to one (1) to draw bounding box around field text to validate
|
||||
* bounding box calculation. */
|
||||
@ -347,21 +367,21 @@ bool LIB_FIELD::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFO
|
||||
{
|
||||
wxString extended_text = tmp_text.GetText();
|
||||
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 ) )
|
||||
extended_text.Append('A');
|
||||
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
|
||||
* transformation matrix causes xy axes to be flipped.
|
||||
* this simple algo works only for schematic matrix (rot 90 or/and mirror)
|
||||
*/
|
||||
int t1 = ( aTransform.x1 != 0 ) ^ ( m_Orient != 0 );
|
||||
tmp_text.SetOrientation( t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT );
|
||||
bool t1 = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 );
|
||||
tmp_text.SetTextAngle( t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT );
|
||||
|
||||
return tmp_text.TextHitTest( aPosition );
|
||||
}
|
||||
@ -379,18 +399,11 @@ EDA_ITEM* LIB_FIELD::Clone() 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->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 )
|
||||
return result;
|
||||
|
||||
if( m_Pos.x != tmp->m_Pos.x )
|
||||
return m_Pos.x - tmp->m_Pos.x;
|
||||
if( GetTextPos().x != tmp->GetTextPos().x )
|
||||
return GetTextPos().x - tmp->GetTextPos().x;
|
||||
|
||||
if( m_Pos.y != tmp->m_Pos.y )
|
||||
return m_Pos.y - tmp->m_Pos.y;
|
||||
if( GetTextPos().y != tmp->GetTextPos().y )
|
||||
return GetTextPos().y - tmp->GetTextPos().y;
|
||||
|
||||
if( m_Size.x != tmp->m_Size.x )
|
||||
return m_Size.x - tmp->m_Size.x;
|
||||
if( GetTextWidth() != tmp->GetTextWidth() )
|
||||
return GetTextWidth() - tmp->GetTextWidth();
|
||||
|
||||
if( m_Size.y != tmp->m_Size.y )
|
||||
return m_Size.y - tmp->m_Size.y;
|
||||
if( GetTextHeight() != tmp->GetTextHeight() )
|
||||
return GetTextHeight() - tmp->GetTextHeight();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -426,7 +439,7 @@ int LIB_FIELD::compare( const LIB_ITEM& other ) const
|
||||
|
||||
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
|
||||
* 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 )
|
||||
{
|
||||
m_Pos = newPosition;
|
||||
EDA_TEXT::SetTextPos( newPosition );
|
||||
}
|
||||
|
||||
|
||||
void LIB_FIELD::MirrorHorizontal( const wxPoint& center )
|
||||
{
|
||||
m_Pos.x -= center.x;
|
||||
m_Pos.x *= -1;
|
||||
m_Pos.x += center.x;
|
||||
int x = GetTextPos().x;
|
||||
|
||||
x -= center.x;
|
||||
x *= -1;
|
||||
x += center.x;
|
||||
|
||||
SetTextX( x );
|
||||
}
|
||||
|
||||
|
||||
void LIB_FIELD::MirrorVertical( const wxPoint& center )
|
||||
{
|
||||
m_Pos.y -= center.y;
|
||||
m_Pos.y *= -1;
|
||||
m_Pos.y += center.y;
|
||||
int y = GetTextPos().y;
|
||||
|
||||
y -= center.y;
|
||||
y *= -1;
|
||||
y += center.y;
|
||||
|
||||
SetTextY( y );
|
||||
}
|
||||
|
||||
|
||||
void LIB_FIELD::Rotate( const wxPoint& center, bool aRotateCCW )
|
||||
{
|
||||
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
|
||||
* orientation/mirror */
|
||||
int orient = m_Orient;
|
||||
int orient = GetTextAngle();
|
||||
|
||||
if( aTransform.y1 ) // Rotate component 90 deg.
|
||||
{
|
||||
if( orient == TEXT_ORIENT_HORIZ )
|
||||
orient = TEXT_ORIENT_VERT;
|
||||
if( orient == TEXT_ANGLE_HORIZ )
|
||||
orient = TEXT_ANGLE_VERT;
|
||||
else
|
||||
orient = TEXT_ORIENT_HORIZ;
|
||||
orient = TEXT_ANGLE_HORIZ;
|
||||
}
|
||||
|
||||
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() )
|
||||
+ aOffset;
|
||||
|
||||
aPlotter->Text( textpos, GetDefaultColor(), GetShownText(), orient, m_Size,
|
||||
aPlotter->Text( textpos, GetDefaultColor(), GetShownText(),
|
||||
orient, GetTextSize(),
|
||||
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.
|
||||
wxPoint orig = rect.GetOrigin();
|
||||
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.SetEnd( end );
|
||||
|
||||
@ -569,7 +599,7 @@ void LIB_FIELD::Rotate()
|
||||
}
|
||||
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 )
|
||||
{
|
||||
m_initialPos = m_Pos;
|
||||
m_initialPos = GetTextPos();
|
||||
m_initialCursorPos = aPosition;
|
||||
SetEraseLastDrawItem();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Pos = aPosition;
|
||||
SetTextPos( aPosition );
|
||||
}
|
||||
|
||||
m_Flags = aEditMode;
|
||||
@ -726,7 +756,7 @@ void LIB_FIELD::calcEdit( const wxPoint& aPosition )
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -738,7 +768,7 @@ void LIB_FIELD::calcEdit( const wxPoint& aPosition )
|
||||
|
||||
if( m_Flags == IS_NEW )
|
||||
{
|
||||
m_Pos = aPosition;
|
||||
SetTextPos( aPosition );
|
||||
}
|
||||
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 )
|
||||
{
|
||||
wxString msg;
|
||||
@ -756,10 +787,10 @@ void LIB_FIELD::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
|
||||
msg = GetTextStyleName();
|
||||
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 ) );
|
||||
|
||||
msg = StringFromValue( g_UserUnit, m_Size.y, true );
|
||||
msg = StringFromValue( g_UserUnit, GetTextHeight(), true );
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, BLUE ) );
|
||||
|
||||
// Display field name (ref, value ...)
|
||||
|
@ -165,10 +165,7 @@ public:
|
||||
* Function IsVisible
|
||||
* @return true is this field is visible, false if flagged invisible
|
||||
*/
|
||||
bool IsVisible()
|
||||
{
|
||||
return (m_Attributs & TEXT_NO_VISIBLE) == 0 ? true : false;
|
||||
}
|
||||
bool IsVisible() const { return EDA_TEXT::IsVisible(); } // why needed?
|
||||
|
||||
const EDA_RECT GetBoundingBox() const override;
|
||||
|
||||
@ -178,23 +175,7 @@ public:
|
||||
|
||||
bool HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const override;
|
||||
|
||||
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;
|
||||
}
|
||||
void operator=( const LIB_FIELD& field );
|
||||
|
||||
/**
|
||||
* Return the text of a field.
|
||||
@ -239,7 +220,7 @@ public:
|
||||
|
||||
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;
|
||||
|
||||
@ -250,9 +231,9 @@ public:
|
||||
void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
|
||||
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;
|
||||
|
||||
|
@ -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.
|
||||
wxString utf8line = FROM_UTF8( aLineReader.Line() + 2 );
|
||||
wxStringTokenizer tokenizer( utf8line, wxT(" \n\r" ) );
|
||||
wxStringTokenizer tokenizer( utf8line, wxT(" \n\r" ) );
|
||||
int prms_count = tokenizer.CountTokens();
|
||||
|
||||
if( prms_count < 11 )
|
||||
@ -1258,7 +1258,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
|
||||
x = x1 + TextInside;
|
||||
DrawGraphicText( clipbox, DC, wxPoint( x, y1 ), NameColor,
|
||||
m_name,
|
||||
TEXT_ORIENT_HORIZ,
|
||||
TEXT_ANGLE_HORIZ,
|
||||
PinNameSize,
|
||||
GR_TEXT_HJUSTIFY_LEFT,
|
||||
GR_TEXT_VJUSTIFY_CENTER, nameLineWidth,
|
||||
@ -1269,7 +1269,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
|
||||
x = x1 - TextInside;
|
||||
DrawGraphicText( clipbox, DC, wxPoint( x, y1 ), NameColor,
|
||||
m_name,
|
||||
TEXT_ORIENT_HORIZ,
|
||||
TEXT_ANGLE_HORIZ,
|
||||
PinNameSize,
|
||||
GR_TEXT_HJUSTIFY_RIGHT,
|
||||
GR_TEXT_VJUSTIFY_CENTER, nameLineWidth,
|
||||
@ -1283,7 +1283,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
|
||||
wxPoint( (x1 + pin_pos.x) / 2,
|
||||
y1 - num_offset ), NumColor,
|
||||
StringPinNum,
|
||||
TEXT_ORIENT_HORIZ, PinNumSize,
|
||||
TEXT_ANGLE_HORIZ, PinNumSize,
|
||||
GR_TEXT_HJUSTIFY_CENTER,
|
||||
GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth,
|
||||
false, false );
|
||||
@ -1299,7 +1299,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
|
||||
if( DrawPinName )
|
||||
DrawGraphicText( clipbox, DC, wxPoint( x1, y ), NameColor,
|
||||
m_name,
|
||||
TEXT_ORIENT_VERT, PinNameSize,
|
||||
TEXT_ANGLE_VERT, PinNameSize,
|
||||
GR_TEXT_HJUSTIFY_RIGHT,
|
||||
GR_TEXT_VJUSTIFY_CENTER, nameLineWidth,
|
||||
false, false );
|
||||
@ -1309,7 +1309,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
|
||||
wxPoint( x1 - num_offset,
|
||||
(y1 + pin_pos.y) / 2 ), NumColor,
|
||||
StringPinNum,
|
||||
TEXT_ORIENT_VERT, PinNumSize,
|
||||
TEXT_ANGLE_VERT, PinNumSize,
|
||||
GR_TEXT_HJUSTIFY_CENTER,
|
||||
GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth,
|
||||
false, false );
|
||||
@ -1321,7 +1321,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
|
||||
if( DrawPinName )
|
||||
DrawGraphicText( clipbox, DC, wxPoint( x1, y ), NameColor,
|
||||
m_name,
|
||||
TEXT_ORIENT_VERT, PinNameSize,
|
||||
TEXT_ANGLE_VERT, PinNameSize,
|
||||
GR_TEXT_HJUSTIFY_LEFT,
|
||||
GR_TEXT_VJUSTIFY_CENTER, nameLineWidth,
|
||||
false, false );
|
||||
@ -1331,7 +1331,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
|
||||
wxPoint( x1 - num_offset,
|
||||
(y1 + pin_pos.y) / 2 ), NumColor,
|
||||
StringPinNum,
|
||||
TEXT_ORIENT_VERT, PinNumSize,
|
||||
TEXT_ANGLE_VERT, PinNumSize,
|
||||
GR_TEXT_HJUSTIFY_CENTER,
|
||||
GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth,
|
||||
false, false );
|
||||
@ -1348,7 +1348,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
|
||||
x = (x1 + pin_pos.x) / 2;
|
||||
DrawGraphicText( clipbox, DC, wxPoint( x, y1 - name_offset ),
|
||||
NameColor, m_name,
|
||||
TEXT_ORIENT_HORIZ, PinNameSize,
|
||||
TEXT_ANGLE_HORIZ, PinNameSize,
|
||||
GR_TEXT_HJUSTIFY_CENTER,
|
||||
GR_TEXT_VJUSTIFY_BOTTOM, nameLineWidth,
|
||||
false, false );
|
||||
@ -1358,7 +1358,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
|
||||
x = (x1 + pin_pos.x) / 2;
|
||||
DrawGraphicText( clipbox, DC, wxPoint( x, y1 + num_offset ),
|
||||
NumColor, StringPinNum,
|
||||
TEXT_ORIENT_HORIZ, PinNumSize,
|
||||
TEXT_ANGLE_HORIZ, PinNumSize,
|
||||
GR_TEXT_HJUSTIFY_CENTER,
|
||||
GR_TEXT_VJUSTIFY_TOP, numLineWidth,
|
||||
false, false );
|
||||
@ -1371,7 +1371,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
|
||||
y = (y1 + pin_pos.y) / 2;
|
||||
DrawGraphicText( clipbox, DC, wxPoint( x1 - name_offset, y ),
|
||||
NameColor, m_name,
|
||||
TEXT_ORIENT_VERT, PinNameSize,
|
||||
TEXT_ANGLE_VERT, PinNameSize,
|
||||
GR_TEXT_HJUSTIFY_CENTER,
|
||||
GR_TEXT_VJUSTIFY_BOTTOM, nameLineWidth,
|
||||
false, false );
|
||||
@ -1383,7 +1383,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
|
||||
wxPoint( x1 + num_offset, (y1 + pin_pos.y)
|
||||
/ 2 ),
|
||||
NumColor, StringPinNum,
|
||||
TEXT_ORIENT_VERT, PinNumSize,
|
||||
TEXT_ANGLE_VERT, PinNumSize,
|
||||
GR_TEXT_HJUSTIFY_CENTER,
|
||||
GR_TEXT_VJUSTIFY_TOP, numLineWidth,
|
||||
false, false );
|
||||
@ -1421,19 +1421,19 @@ void LIB_PIN::DrawPinElectricalTypeName( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
||||
wxPoint txtpos = aPosition;
|
||||
int offset = Millimeter2iu( 0.4 );
|
||||
EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_LEFT;
|
||||
int orient = TEXT_ORIENT_HORIZ;
|
||||
int orient = TEXT_ANGLE_HORIZ;
|
||||
|
||||
switch( aOrientation )
|
||||
{
|
||||
case PIN_UP:
|
||||
txtpos.y += offset;
|
||||
orient = TEXT_ORIENT_VERT;
|
||||
orient = TEXT_ANGLE_VERT;
|
||||
hjustify = GR_TEXT_HJUSTIFY_RIGHT;
|
||||
break;
|
||||
|
||||
case PIN_DOWN:
|
||||
txtpos.y -= offset;
|
||||
orient = TEXT_ORIENT_VERT;
|
||||
orient = TEXT_ANGLE_VERT;
|
||||
break;
|
||||
|
||||
case PIN_LEFT:
|
||||
@ -1676,7 +1676,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
|
||||
x = x1 + TextInside;
|
||||
plotter->Text( wxPoint( x, y1 ), NameColor,
|
||||
m_name,
|
||||
TEXT_ORIENT_HORIZ,
|
||||
TEXT_ANGLE_HORIZ,
|
||||
PinNameSize,
|
||||
GR_TEXT_HJUSTIFY_LEFT,
|
||||
GR_TEXT_VJUSTIFY_CENTER,
|
||||
@ -1688,7 +1688,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
|
||||
|
||||
if( DrawPinName )
|
||||
plotter->Text( wxPoint( x, y1 ),
|
||||
NameColor, m_name, TEXT_ORIENT_HORIZ,
|
||||
NameColor, m_name, TEXT_ANGLE_HORIZ,
|
||||
PinNameSize,
|
||||
GR_TEXT_HJUSTIFY_RIGHT,
|
||||
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,
|
||||
y1 - num_offset ),
|
||||
NumColor, StringPinNum,
|
||||
TEXT_ORIENT_HORIZ, PinNumSize,
|
||||
TEXT_ANGLE_HORIZ, PinNumSize,
|
||||
GR_TEXT_HJUSTIFY_CENTER,
|
||||
GR_TEXT_VJUSTIFY_BOTTOM,
|
||||
aWidth, false, false );
|
||||
@ -1715,7 +1715,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
|
||||
if( DrawPinName )
|
||||
plotter->Text( wxPoint( x1, y ), NameColor,
|
||||
m_name,
|
||||
TEXT_ORIENT_VERT, PinNameSize,
|
||||
TEXT_ANGLE_VERT, PinNameSize,
|
||||
GR_TEXT_HJUSTIFY_RIGHT,
|
||||
GR_TEXT_VJUSTIFY_CENTER,
|
||||
aWidth, false, false );
|
||||
@ -1725,7 +1725,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
|
||||
plotter->Text( wxPoint( x1 - num_offset,
|
||||
(y1 + pin_pos.y) / 2 ),
|
||||
NumColor, StringPinNum,
|
||||
TEXT_ORIENT_VERT, PinNumSize,
|
||||
TEXT_ANGLE_VERT, PinNumSize,
|
||||
GR_TEXT_HJUSTIFY_CENTER,
|
||||
GR_TEXT_VJUSTIFY_BOTTOM,
|
||||
aWidth, false, false );
|
||||
@ -1738,7 +1738,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
|
||||
if( DrawPinName )
|
||||
plotter->Text( wxPoint( x1, y ), NameColor,
|
||||
m_name,
|
||||
TEXT_ORIENT_VERT, PinNameSize,
|
||||
TEXT_ANGLE_VERT, PinNameSize,
|
||||
GR_TEXT_HJUSTIFY_LEFT,
|
||||
GR_TEXT_VJUSTIFY_CENTER,
|
||||
aWidth, false, false );
|
||||
@ -1748,7 +1748,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
|
||||
plotter->Text( wxPoint( x1 - num_offset,
|
||||
(y1 + pin_pos.y) / 2 ),
|
||||
NumColor, StringPinNum,
|
||||
TEXT_ORIENT_VERT, PinNumSize,
|
||||
TEXT_ANGLE_VERT, PinNumSize,
|
||||
GR_TEXT_HJUSTIFY_CENTER,
|
||||
GR_TEXT_VJUSTIFY_BOTTOM,
|
||||
aWidth, false, false );
|
||||
@ -1766,7 +1766,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
|
||||
x = (x1 + pin_pos.x) / 2;
|
||||
plotter->Text( wxPoint( x, y1 - name_offset ),
|
||||
NameColor, m_name,
|
||||
TEXT_ORIENT_HORIZ, PinNameSize,
|
||||
TEXT_ANGLE_HORIZ, PinNameSize,
|
||||
GR_TEXT_HJUSTIFY_CENTER,
|
||||
GR_TEXT_VJUSTIFY_BOTTOM,
|
||||
aWidth, false, false );
|
||||
@ -1777,7 +1777,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
|
||||
x = ( x1 + pin_pos.x ) / 2;
|
||||
plotter->Text( wxPoint( x, y1 + num_offset ),
|
||||
NumColor, StringPinNum,
|
||||
TEXT_ORIENT_HORIZ, PinNumSize,
|
||||
TEXT_ANGLE_HORIZ, PinNumSize,
|
||||
GR_TEXT_HJUSTIFY_CENTER,
|
||||
GR_TEXT_VJUSTIFY_TOP,
|
||||
aWidth, false, false );
|
||||
@ -1790,7 +1790,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
|
||||
y = ( y1 + pin_pos.y ) / 2;
|
||||
plotter->Text( wxPoint( x1 - name_offset, y ),
|
||||
NameColor, m_name,
|
||||
TEXT_ORIENT_VERT, PinNameSize,
|
||||
TEXT_ANGLE_VERT, PinNameSize,
|
||||
GR_TEXT_HJUSTIFY_CENTER,
|
||||
GR_TEXT_VJUSTIFY_BOTTOM,
|
||||
aWidth, false, false );
|
||||
@ -1801,7 +1801,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
|
||||
plotter->Text( wxPoint( x1 + num_offset,
|
||||
( y1 + pin_pos.y ) / 2 ),
|
||||
NumColor, StringPinNum,
|
||||
TEXT_ORIENT_VERT, PinNumSize,
|
||||
TEXT_ANGLE_VERT, PinNumSize,
|
||||
GR_TEXT_HJUSTIFY_CENTER,
|
||||
GR_TEXT_VJUSTIFY_TOP,
|
||||
aWidth, false, false );
|
||||
|
@ -47,7 +47,7 @@ LIB_TEXT::LIB_TEXT( LIB_PART * aParent ) :
|
||||
LIB_ITEM( LIB_TEXT_T, aParent ),
|
||||
EDA_TEXT()
|
||||
{
|
||||
m_Size = wxSize( 50, 50 );
|
||||
SetTextSize( wxSize( 50, 50 ) );
|
||||
m_typeName = _( "Text" );
|
||||
m_rotate = false;
|
||||
m_updateText = false;
|
||||
@ -71,23 +71,24 @@ bool LIB_TEXT::Save( OUTPUTFORMATTER& aFormatter )
|
||||
text.Replace( wxT( " " ), wxT( "~" ) );
|
||||
}
|
||||
|
||||
aFormatter.Print( 0, "T %g %d %d %d %d %d %d %s", GetOrientation(), m_Pos.x, m_Pos.y,
|
||||
m_Size.x, m_Attributs, m_Unit, m_Convert, TO_UTF8( text ) );
|
||||
aFormatter.Print( 0, "T %g %d %d %d %d %d %d %s", GetTextAngle(),
|
||||
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';
|
||||
|
||||
if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT )
|
||||
if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
|
||||
hjustify = 'L';
|
||||
else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT )
|
||||
else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
|
||||
hjustify = 'R';
|
||||
|
||||
char vjustify = 'C';
|
||||
|
||||
if( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM )
|
||||
if( GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
|
||||
vjustify = 'B';
|
||||
else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP )
|
||||
else if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
|
||||
vjustify = 'T';
|
||||
|
||||
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* line = (char*) aLineReader;
|
||||
double angle;
|
||||
int not_visible;
|
||||
int x, y, size;
|
||||
|
||||
buf[0] = 0;
|
||||
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",
|
||||
&angle, &m_Pos.x, &m_Pos.y, &m_Size.x, &m_Attributs,
|
||||
&angle, &x, &y, &size, ¬_visible,
|
||||
&m_Unit, &m_Convert, buf, tmp, &thickness, &hjustify,
|
||||
&vjustify );
|
||||
|
||||
SetVisible( !not_visible );
|
||||
|
||||
if( cnt >= 8 ) // if quoted loading failed, load as not quoted
|
||||
{
|
||||
m_Text = FROM_UTF8( buf );
|
||||
@ -123,7 +128,7 @@ bool LIB_TEXT::Load( LINE_READER& aLineReader, wxString& errorMsg )
|
||||
else
|
||||
{
|
||||
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, ¬_visible,
|
||||
&m_Unit, &m_Convert, buf, tmp, &thickness, &hjustify,
|
||||
&vjustify );
|
||||
|
||||
@ -133,54 +138,56 @@ bool LIB_TEXT::Load( LINE_READER& aLineReader, wxString& errorMsg )
|
||||
return false;
|
||||
}
|
||||
|
||||
SetVisible( !not_visible );
|
||||
|
||||
/* Convert '~' to spaces (only if text is not quoted). */
|
||||
m_Text = FROM_UTF8( buf );
|
||||
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 )
|
||||
m_Italic = true;
|
||||
SetItalic( true );
|
||||
|
||||
if( thickness > 0 )
|
||||
{
|
||||
m_Bold = true;
|
||||
SetBold( true );
|
||||
}
|
||||
|
||||
switch( hjustify )
|
||||
{
|
||||
case 'L':
|
||||
m_HJustify = GR_TEXT_HJUSTIFY_LEFT;
|
||||
SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
m_HJustify = GR_TEXT_HJUSTIFY_CENTER;
|
||||
SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
m_HJustify = GR_TEXT_HJUSTIFY_RIGHT;
|
||||
SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
||||
break;
|
||||
}
|
||||
|
||||
switch( vjustify )
|
||||
{
|
||||
case 'T':
|
||||
m_VJustify = GR_TEXT_VJUSTIFY_TOP;
|
||||
SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
m_VJustify = GR_TEXT_VJUSTIFY_CENTER;
|
||||
SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM;
|
||||
SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -197,14 +204,15 @@ bool LIB_TEXT::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFOR
|
||||
aThreshold = 0;
|
||||
|
||||
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
|
||||
* 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)
|
||||
*/
|
||||
int t1 = ( aTransform.x1 != 0 ) ^ ( m_Orient != 0 );
|
||||
tmp_text.SetOrientation( t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT );
|
||||
bool t1 = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 );
|
||||
|
||||
tmp_text.SetTextAngle( t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT );
|
||||
return tmp_text.TextHitTest( aPosition );
|
||||
}
|
||||
|
||||
@ -213,19 +221,13 @@ EDA_ITEM* LIB_TEXT::Clone() const
|
||||
{
|
||||
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_Convert = m_Convert;
|
||||
newitem->m_Flags = m_Flags;
|
||||
newitem->m_Text = m_Text;
|
||||
newitem->m_Thickness = m_Thickness;
|
||||
newitem->m_Italic = m_Italic;
|
||||
newitem->m_Bold = m_Bold;
|
||||
newitem->m_HJustify = m_HJustify;
|
||||
newitem->m_VJustify = m_VJustify;
|
||||
|
||||
newitem->SetEffects( *this );
|
||||
|
||||
return newitem;
|
||||
}
|
||||
|
||||
@ -241,17 +243,17 @@ int LIB_TEXT::compare( const LIB_ITEM& other ) const
|
||||
if( result != 0 )
|
||||
return result;
|
||||
|
||||
if( m_Pos.x != tmp->m_Pos.x )
|
||||
return m_Pos.x - tmp->m_Pos.x;
|
||||
if( GetTextPos().x != tmp->GetTextPos().x )
|
||||
return GetTextPos().x - tmp->GetTextPos().x;
|
||||
|
||||
if( m_Pos.y != tmp->m_Pos.y )
|
||||
return m_Pos.y - tmp->m_Pos.y;
|
||||
if( GetTextPos().y != tmp->GetTextPos().y )
|
||||
return GetTextPos().y - tmp->GetTextPos().y;
|
||||
|
||||
if( m_Size.x != tmp->m_Size.x )
|
||||
return m_Size.x - tmp->m_Size.x;
|
||||
if( GetTextWidth() != tmp->GetTextWidth() )
|
||||
return GetTextWidth() - tmp->GetTextWidth();
|
||||
|
||||
if( m_Size.y != tmp->m_Size.y )
|
||||
return m_Size.y - tmp->m_Size.y;
|
||||
if( GetTextHeight() != tmp->GetTextHeight() )
|
||||
return GetTextHeight() - tmp->GetTextHeight();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -259,7 +261,7 @@ int LIB_TEXT::compare( const LIB_ITEM& other ) const
|
||||
|
||||
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
|
||||
* 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 )
|
||||
{
|
||||
m_Pos = newPosition;
|
||||
SetTextPos( newPosition );
|
||||
}
|
||||
|
||||
|
||||
void LIB_TEXT::MirrorHorizontal( const wxPoint& center )
|
||||
{
|
||||
m_Pos.x -= center.x;
|
||||
m_Pos.x *= -1;
|
||||
m_Pos.x += center.x;
|
||||
int x = GetTextPos().x;
|
||||
|
||||
x -= center.x;
|
||||
x *= -1;
|
||||
x += center.x;
|
||||
|
||||
SetTextX( x );
|
||||
}
|
||||
|
||||
|
||||
void LIB_TEXT::MirrorVertical( const wxPoint& center )
|
||||
{
|
||||
m_Pos.y -= center.y;
|
||||
m_Pos.y *= -1;
|
||||
m_Pos.y += center.y;
|
||||
int y = GetTextPos().y;
|
||||
|
||||
y -= center.y;
|
||||
y *= -1;
|
||||
y += center.y;
|
||||
|
||||
SetTextY( y );
|
||||
}
|
||||
|
||||
|
||||
void LIB_TEXT::Rotate( const wxPoint& center, bool aRotateCCW )
|
||||
{
|
||||
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 );
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
* 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;
|
||||
|
||||
// Get color
|
||||
@ -326,26 +341,26 @@ void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill,
|
||||
color = BLACK;
|
||||
|
||||
plotter->Text( pos, color, GetShownText(),
|
||||
t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT,
|
||||
m_Size, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
|
||||
GetPenSize(), m_Italic, m_Bold );
|
||||
t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT,
|
||||
GetTextSize(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
|
||||
GetPenSize(), IsItalic(), IsBold() );
|
||||
}
|
||||
|
||||
|
||||
int LIB_TEXT::GetPenSize() const
|
||||
{
|
||||
int pensize = m_Thickness;
|
||||
int pensize = GetThickness();
|
||||
|
||||
if( pensize == 0 ) // Use default values for pen size
|
||||
{
|
||||
if( m_Bold )
|
||||
pensize = GetPenSizeForBold( m_Size.x );
|
||||
if( IsBold() )
|
||||
pensize = GetPenSizeForBold( GetTextWidth() );
|
||||
else
|
||||
pensize = GetDefaultLineThickness();
|
||||
}
|
||||
|
||||
// Clip pen size for small texts:
|
||||
pensize = Clamp_Text_PenSize( pensize, m_Size, m_Bold );
|
||||
pensize = Clamp_Text_PenSize( pensize, GetTextSize(), IsBold() );
|
||||
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
|
||||
* orientation/mirror (needed when draw text in schematic)
|
||||
*/
|
||||
int orient = m_Orient;
|
||||
int orient = GetTextAngle();
|
||||
|
||||
if( aTransform.y1 ) // Rotate component 90 degrees.
|
||||
{
|
||||
if( orient == TEXT_ORIENT_HORIZ )
|
||||
orient = TEXT_ORIENT_VERT;
|
||||
if( orient == TEXT_ANGLE_HORIZ )
|
||||
orient = TEXT_ANGLE_VERT;
|
||||
else
|
||||
orient = TEXT_ORIENT_HORIZ;
|
||||
orient = TEXT_ANGLE_HORIZ;
|
||||
}
|
||||
|
||||
/* 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
|
||||
*/
|
||||
EDA_RECT bBox = GetBoundingBox();
|
||||
|
||||
// convert coordinates from draw Y axis to libedit Y axis:
|
||||
bBox.RevertYAxis();
|
||||
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;
|
||||
|
||||
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(),
|
||||
m_Italic, m_Bold );
|
||||
IsItalic(), IsBold() );
|
||||
|
||||
|
||||
/* 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 );
|
||||
|
||||
msg = StringFromValue( g_UserUnit, m_Thickness, true );
|
||||
msg = StringFromValue( g_UserUnit, GetThickness(), true );
|
||||
|
||||
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.
|
||||
wxPoint orig = rect.GetOrigin();
|
||||
wxPoint end = rect.GetEnd();
|
||||
RotatePoint( &orig, m_Pos, -m_Orient );
|
||||
RotatePoint( &end, m_Pos, -m_Orient );
|
||||
wxPoint end = rect.GetEnd();
|
||||
|
||||
RotatePoint( &orig, GetTextPos(), -GetTextAngle() );
|
||||
RotatePoint( &end, GetTextPos(), -GetTextAngle() );
|
||||
|
||||
rect.SetOrigin( orig );
|
||||
rect.SetEnd( end );
|
||||
@ -462,7 +479,7 @@ void LIB_TEXT::Rotate()
|
||||
}
|
||||
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 )
|
||||
{
|
||||
m_initialPos = m_Pos;
|
||||
m_initialPos = GetTextPos();
|
||||
m_initialCursorPos = aPosition;
|
||||
SetEraseLastDrawItem();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Pos = aPosition;
|
||||
SetTextPos( aPosition );
|
||||
}
|
||||
|
||||
m_Flags = aEditMode;
|
||||
@ -537,7 +554,7 @@ void LIB_TEXT::calcEdit( const wxPoint& aPosition )
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -550,7 +567,7 @@ void LIB_TEXT::calcEdit( const wxPoint& aPosition )
|
||||
if( m_Flags == IS_NEW )
|
||||
{
|
||||
SetEraseLastDrawItem();
|
||||
m_Pos = aPosition;
|
||||
SetTextPos( aPosition );
|
||||
}
|
||||
else if( m_Flags == IS_MOVED )
|
||||
{
|
||||
|
@ -112,7 +112,7 @@ public:
|
||||
|
||||
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;
|
||||
|
||||
@ -123,9 +123,9 @@ public:
|
||||
void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
|
||||
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;
|
||||
|
||||
|
@ -71,7 +71,7 @@ LIB_ITEM* LIB_EDIT_FRAME::m_drawItem = NULL;
|
||||
bool LIB_EDIT_FRAME:: m_showDeMorgan = false;
|
||||
wxSize LIB_EDIT_FRAME:: m_clientSize = wxSize( -1, -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;
|
||||
|
||||
// these values are overridden when reading the config
|
||||
|
@ -108,8 +108,8 @@ class LIB_EDIT_FRAME : public SCH_BASE_FRAME
|
||||
/// The current text size setting.
|
||||
static int m_textSize;
|
||||
|
||||
/// Current text orientation setting.
|
||||
static int m_textOrientation;
|
||||
/// Current text angle setting.
|
||||
static double m_current_text_angle;
|
||||
|
||||
/// The default pin num text size setting.
|
||||
static int m_textPinNumDefaultSize;
|
||||
|
@ -102,7 +102,7 @@ static LIB_PART* dummy()
|
||||
|
||||
LIB_TEXT* text = new LIB_TEXT( part );
|
||||
|
||||
text->SetSize( wxSize( 150, 150 ) );
|
||||
text->SetTextSize( wxSize( 150, 150 ) );
|
||||
text->SetText( wxString( wxT( "??" ) ) );
|
||||
|
||||
part->AddDrawItem( square );
|
||||
@ -171,7 +171,7 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_PART& aPart, SCH_SHEET_PATH* sheet, int unit,
|
||||
schField = AddField( fld );
|
||||
}
|
||||
|
||||
schField->SetTextPosition( m_Pos + it->GetTextPosition() );
|
||||
schField->SetTextPos( m_Pos + it->GetTextPos() );
|
||||
schField->ImportValues( *it );
|
||||
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 );
|
||||
|
||||
if( rf->GetText().IsEmpty()
|
||||
|| ( abs( rf->GetTextPosition().x - m_Pos.x ) +
|
||||
abs( rf->GetTextPosition().y - m_Pos.y ) > 10000 ) )
|
||||
|| ( abs( rf->GetTextPos().x - m_Pos.x ) +
|
||||
abs( rf->GetTextPos().y - m_Pos.y ) > 10000 ) )
|
||||
{
|
||||
// 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.
|
||||
@ -1209,7 +1209,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
||||
{
|
||||
m_part_name.Empty();
|
||||
GetField( VALUE )->Empty();
|
||||
GetField( VALUE )->SetOrientation( TEXT_ORIENT_HORIZ );
|
||||
GetField( VALUE )->SetTextAngle( TEXT_ANGLE_HORIZ );
|
||||
GetField( VALUE )->SetVisible( false );
|
||||
}
|
||||
|
||||
@ -1276,7 +1276,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
||||
for( int i = 0; i<GetFieldCount(); i++ )
|
||||
{
|
||||
if( GetField( i )->GetText().IsEmpty() )
|
||||
GetField( i )->SetTextPosition( m_Pos );
|
||||
GetField( i )->SetTextPos( m_Pos );
|
||||
}
|
||||
}
|
||||
else if( line[0] == 'A' && line[1] == 'R' )
|
||||
@ -1386,17 +1386,17 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
||||
continue;
|
||||
}
|
||||
|
||||
GetField( fieldNdx )->SetTextPosition( wxPoint( x, y ) );
|
||||
GetField( fieldNdx )->SetAttributes( attr );
|
||||
GetField( fieldNdx )->SetTextPos( wxPoint( x, y ) );
|
||||
GetField( fieldNdx )->SetVisible( !attr );
|
||||
|
||||
if( (w == 0 ) || (ii == 4) )
|
||||
w = GetDefaultTextSize();
|
||||
|
||||
GetField( fieldNdx )->SetSize( wxSize( w, w ) );
|
||||
GetField( fieldNdx )->SetOrientation( TEXT_ORIENT_HORIZ );
|
||||
GetField( fieldNdx )->SetTextSize( wxSize( w, w ) );
|
||||
GetField( fieldNdx )->SetTextAngle( TEXT_ANGLE_HORIZ );
|
||||
|
||||
if( char1[0] == 'V' )
|
||||
GetField( fieldNdx )->SetOrientation( TEXT_ORIENT_VERT );
|
||||
GetField( fieldNdx )->SetTextAngle( TEXT_ANGLE_VERT );
|
||||
|
||||
if( ii >= 7 )
|
||||
{
|
||||
@ -1577,9 +1577,9 @@ void SCH_COMPONENT::MirrorY( int aYaxis_position )
|
||||
for( int ii = 0; ii < GetFieldCount(); ii++ )
|
||||
{
|
||||
// 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;
|
||||
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++ )
|
||||
{
|
||||
// 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;
|
||||
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++ )
|
||||
{
|
||||
// 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.y -= prev.y - m_Pos.y;
|
||||
GetField( ii )->SetTextPosition( pos );
|
||||
GetField( ii )->SetTextPos( pos );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,11 +55,11 @@ SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent,
|
||||
SCH_ITEM( aParent, SCH_FIELD_T ),
|
||||
EDA_TEXT()
|
||||
{
|
||||
m_Pos = aPos;
|
||||
SetTextPos( aPos );
|
||||
m_id = aFieldId;
|
||||
m_Attributs = TEXT_NO_VISIBLE;
|
||||
m_name = aName;
|
||||
|
||||
SetVisible( false );
|
||||
SetLayer( LAYER_FIELDS );
|
||||
}
|
||||
|
||||
@ -98,18 +98,18 @@ const wxString SCH_FIELD::GetFullyQualifiedText() const
|
||||
|
||||
int SCH_FIELD::GetPenSize() const
|
||||
{
|
||||
int pensize = m_Thickness;
|
||||
int pensize = GetThickness();
|
||||
|
||||
if( pensize == 0 ) // Use default values for pen size
|
||||
{
|
||||
if( m_Bold )
|
||||
pensize = GetPenSizeForBold( m_Size.x );
|
||||
if( IsBold() )
|
||||
pensize = GetPenSizeForBold( GetTextWidth() );
|
||||
else
|
||||
pensize = GetDefaultLineThickness();
|
||||
}
|
||||
|
||||
// Clip pen size for small texts:
|
||||
pensize = Clamp_Text_PenSize( pensize, m_Size, m_Bold );
|
||||
pensize = Clamp_Text_PenSize( pensize, GetTextSize(), IsBold() );
|
||||
return pensize;
|
||||
}
|
||||
|
||||
@ -121,33 +121,33 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
|
||||
EDA_COLOR_T color;
|
||||
wxPoint textpos;
|
||||
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 )
|
||||
LineWidth = GetPenSizeForBold( m_Size.x );
|
||||
if( IsBold() )
|
||||
lineWidth = GetPenSizeForBold( GetTextWidth() );
|
||||
else
|
||||
LineWidth = GetDefaultLineThickness();
|
||||
lineWidth = GetDefaultLineThickness();
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
GRSetDrawMode( aDC, aDrawMode );
|
||||
|
||||
// Calculate the text orientation according to the component orientation.
|
||||
orient = m_Orient;
|
||||
orient = GetTextAngle();
|
||||
|
||||
if( parentComponent->GetTransform().y1 ) // Rotate component 90 degrees.
|
||||
{
|
||||
if( orient == TEXT_ORIENT_HORIZ )
|
||||
orient = TEXT_ORIENT_VERT;
|
||||
if( orient == TEXT_ANGLE_HORIZ )
|
||||
orient = TEXT_ANGLE_VERT;
|
||||
else
|
||||
orient = TEXT_ORIENT_HORIZ;
|
||||
orient = TEXT_ANGLE_HORIZ;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
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,
|
||||
LineWidth, m_Italic, m_Bold );
|
||||
lineWidth, IsItalic(), IsBold() );
|
||||
|
||||
// While moving: don't loose visual contact to which component this label belongs.
|
||||
if ( IsWireImage() )
|
||||
{
|
||||
const wxPoint origin = parentComponent->GetPosition();
|
||||
textpos = m_Pos - origin;
|
||||
textpos = GetTextPos() - origin;
|
||||
textpos = parentComponent->GetScreenCoord( textpos );
|
||||
textpos += parentComponent->GetPosition();
|
||||
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 )
|
||||
{
|
||||
m_Orient = aSource.GetOrientation();
|
||||
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();
|
||||
SetEffects( aSource );
|
||||
}
|
||||
|
||||
|
||||
void SCH_FIELD::ExportValues( LIB_FIELD& aDest ) const
|
||||
{
|
||||
aDest.SetId( GetId() );
|
||||
aDest.SetText( m_Text ); // Set field value
|
||||
aDest.SetName( GetName() );
|
||||
aDest.SetOrientation( GetOrientation() );
|
||||
aDest.SetSize( GetSize() );
|
||||
aDest.SetTextPosition( GetTextPosition() );
|
||||
aDest.SetHorizJustify( GetHorizJustify() );
|
||||
aDest.SetVertJustify( GetVertJustify() );
|
||||
aDest.SetItalic( IsItalic() );
|
||||
aDest.SetBold( IsBold() );
|
||||
aDest.SetThickness( GetThickness() );
|
||||
aDest.SetAttributes( GetAttributes() );
|
||||
|
||||
aDest.SetEffects( *this );
|
||||
}
|
||||
|
||||
|
||||
@ -256,27 +242,19 @@ void SCH_FIELD::SwapData( SCH_ITEM* aItem )
|
||||
|
||||
std::swap( m_Text, item->m_Text );
|
||||
std::swap( m_Layer, item->m_Layer );
|
||||
std::swap( m_Pos, item->m_Pos );
|
||||
std::swap( m_Size, item->m_Size );
|
||||
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 );
|
||||
|
||||
SwapEffects( *item );
|
||||
}
|
||||
|
||||
|
||||
const EDA_RECT SCH_FIELD::GetBoundingBox() const
|
||||
{
|
||||
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
|
||||
// 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:
|
||||
EDA_RECT rect;
|
||||
@ -293,11 +271,11 @@ const EDA_RECT SCH_FIELD::GetBoundingBox() const
|
||||
|
||||
// Calculate the bounding box position relative to the component:
|
||||
wxPoint origin = parentComponent->GetPosition();
|
||||
wxPoint pos = m_Pos - origin;
|
||||
wxPoint pos = GetTextPos() - origin;
|
||||
wxPoint begin = rect.GetOrigin() - origin;
|
||||
wxPoint end = rect.GetEnd() - origin;
|
||||
RotatePoint( &begin, pos, m_Orient );
|
||||
RotatePoint( &end, pos, m_Orient );
|
||||
RotatePoint( &begin, pos, GetTextAngle() );
|
||||
RotatePoint( &end, pos, GetTextAngle() );
|
||||
|
||||
// Due to the Y axis direction, we must mirror the bounding box,
|
||||
// relative to the text position:
|
||||
@ -336,28 +314,28 @@ bool SCH_FIELD::Save( FILE* aFile ) const
|
||||
{
|
||||
char hjustify = 'C';
|
||||
|
||||
if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT )
|
||||
if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
|
||||
hjustify = 'L';
|
||||
else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT )
|
||||
else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
|
||||
hjustify = 'R';
|
||||
|
||||
char vjustify = 'C';
|
||||
|
||||
if( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM )
|
||||
if( GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
|
||||
vjustify = 'B';
|
||||
else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP )
|
||||
else if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
|
||||
vjustify = 'T';
|
||||
|
||||
if( fprintf( aFile, "F %d %s %c %-3d %-3d %-3d %4.4X %c %c%c%c",
|
||||
m_id,
|
||||
EscapedUTF8( m_Text ).c_str(), // wraps in quotes too
|
||||
m_Orient == TEXT_ORIENT_HORIZ ? 'H' : 'V',
|
||||
m_Pos.x, m_Pos.y,
|
||||
m_Size.x,
|
||||
m_Attributs,
|
||||
GetTextAngle() == TEXT_ANGLE_HORIZ ? 'H' : 'V',
|
||||
GetTextPos().x, GetTextPos().y,
|
||||
GetTextWidth(),
|
||||
!IsVisible(),
|
||||
hjustify, vjustify,
|
||||
m_Italic ? 'I' : 'N',
|
||||
m_Bold ? 'B' : 'N' ) == EOF )
|
||||
IsItalic() ? 'I' : 'N',
|
||||
IsBold() ? 'B' : 'N' ) == EOF )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -476,7 +454,9 @@ bool SCH_FIELD::Replace( wxFindReplaceData& aSearchData, void* aAuxData )
|
||||
|
||||
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() );
|
||||
|
||||
if( m_Attributs & TEXT_NO_VISIBLE )
|
||||
if( !IsVisible() )
|
||||
return;
|
||||
|
||||
if( IsVoid() )
|
||||
@ -563,14 +543,14 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter )
|
||||
|
||||
/* Calculate the text orientation, according to the component
|
||||
* orientation/mirror */
|
||||
int orient = m_Orient;
|
||||
int orient = GetTextAngle();
|
||||
|
||||
if( parent->GetTransform().y1 ) // Rotate component 90 deg.
|
||||
{
|
||||
if( orient == TEXT_ORIENT_HORIZ )
|
||||
orient = TEXT_ORIENT_VERT;
|
||||
if( orient == TEXT_ANGLE_HORIZ )
|
||||
orient = TEXT_ANGLE_VERT;
|
||||
else
|
||||
orient = TEXT_ORIENT_HORIZ;
|
||||
orient = TEXT_ANGLE_HORIZ;
|
||||
}
|
||||
|
||||
/* Calculate the text justification, according to the component
|
||||
@ -591,8 +571,9 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter )
|
||||
|
||||
int thickness = GetPenSize();
|
||||
|
||||
aPlotter->Text( textpos, color, GetFullyQualifiedText(), orient, m_Size, hjustify, vjustify,
|
||||
thickness, m_Italic, m_Bold );
|
||||
aPlotter->Text( textpos, color, GetFullyQualifiedText(), orient, GetTextSize(),
|
||||
hjustify, vjustify,
|
||||
thickness, IsItalic(), IsBold() );
|
||||
}
|
||||
|
||||
|
||||
@ -607,16 +588,15 @@ void SCH_FIELD::SetPosition( const wxPoint& aPosition )
|
||||
// the position relative to the parent component.
|
||||
wxPoint pt = aPosition - pos;
|
||||
|
||||
m_Pos = pos + component->GetTransform().InverseTransform().TransformCoordinate( pt );
|
||||
SetTextPos( pos + component->GetTransform().InverseTransform().TransformCoordinate( pt ) );
|
||||
}
|
||||
|
||||
|
||||
wxPoint SCH_FIELD::GetPosition() const
|
||||
{
|
||||
|
||||
SCH_COMPONENT* component = (SCH_COMPONENT*) GetParent();
|
||||
|
||||
wxPoint pos = m_Pos - component->GetPosition();
|
||||
wxPoint pos = GetTextPos() - component->GetPosition();
|
||||
|
||||
return component->GetTransform().TransformCoordinate( pos ) + component->GetPosition();
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user