Rework on TEXTE_PCB, SCH_TEXT and EDA_TextStruct classes.

Code seriously cleaned, obscure and duplicated code removed, and some oddities removed.
Better support of multiline texts.
This commit is contained in:
charras 2009-05-12 12:12:34 +00:00
parent 804e539710
commit 5759f734a8
13 changed files with 959 additions and 742 deletions

View File

@ -4,6 +4,17 @@ KiCad ChangeLog 2009
Please add newer entries at the top, list the date and your name with
email address.
2009-may-12 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
++All:
Rework on TEXTE_PCB, SCH_TEXT and EDA_TextStruct classes.
Code seriously cleaned, obscure and duplicated code removed,
and some oddities removed ( like different .m_Orient values in eeschema and
pcbnew, for the same text orientation )
Multiline texts (in comments and Pcb texts) are now supported.
In pcbnew text justifications could work (but not yet used and tested)
2009-may-01 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
++pcbnew:

View File

@ -254,8 +254,8 @@ EDA_Rect EDA_TextStruct::GetTextBox( int aLine )
rect.SetSize( textsize );
/* Now, calculate the rect origin, according to text justification
* At this point the area origin is the text origin.
* This is true only for left and top text justified.
* At this point the area origin is the text origin (m_Pos).
* This is true only for left and top text justified texts.
* and must be recalculated for others justifications
* also, note the V justification is relative to the first line
*/
@ -284,7 +284,7 @@ EDA_Rect EDA_TextStruct::GetTextBox( int aLine )
break;
case GR_TEXT_VJUSTIFY_BOTTOM:
rect.SetY( rect.GetY() + (dy / 2) );
rect.SetY( rect.GetY() - dy );
break;
}

View File

@ -20,6 +20,14 @@
#define EDA_DRAWBASE
#include "grfonte.h"
/* Functions to draw / plot a string.
* texts have only one line.
* They can be in italic.
* Horizontal and Vertical justification are handled.
* Texts can be rotated
* substrings between ~ markers can be "negated" (i.e. with an over bar
*/
/** Function NegableTextLength
* Return the text length of a negable string, excluding the ~ markers */
int NegableTextLength( const wxString& aText )
@ -48,7 +56,7 @@ static void DrawGraphicTextPline(
bool sketch_mode,
int point_count,
wxPoint* coord,
void (* aCallback)(int x0, int y0, int xf, int yf) )
void (*aCallback)( int x0, int y0, int xf, int yf ) )
{
if( aCallback )
{
@ -107,7 +115,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
int aWidth,
bool aItalic,
bool aNegable,
void (* aCallback)(int x0, int y0, int xf, int yf) )
void (*aCallback)( int x0, int y0, int xf, int yf ) )
/****************************************************************************************************/
{
int char_count, AsciiCode;
@ -116,10 +124,9 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
SH_CODE f_cod, plume = 'U';
const SH_CODE* ptcar;
int ptr;
int ux0, uy0, dx, dy; // Draw coordinate for segments to draw. also used in some other calculation
int cX, cY; // Texte center
int ox, oy; // Draw coordinates for the current char
int overbar_x, overbar_y; // Start point for the current overbar
int dx, dy; // Draw coordinate for segments to draw. also used in some other calculation
wxPoint current_char_pos; // Draw coordinates for the current char
wxPoint overbar_pos; // Start point for the current overbar
int overbars; // Number of ~ seen
#define BUF_SIZE 100
@ -156,8 +163,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
else
pitch -= thickness;
ox = cX = aPos.x;
oy = cY = aPos.y;
current_char_pos = aPos;
/* Do not draw the text if out of draw area! */
if( aPanel )
@ -166,8 +172,8 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
int textsize = ABS( pitch );
ll = aPanel->GetScreen()->Scale( textsize * char_count );
xc = GRMapX( cX );
yc = GRMapY( cY );
xc = GRMapX( current_char_pos.x );
yc = GRMapY( current_char_pos.y );
x0 = aPanel->m_ClipBox.GetX() - ll;
y0 = aPanel->m_ClipBox.GetY() - ll;
@ -185,81 +191,60 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
}
/* Compute the position ux0, uy0 of the first letter , next */
dx = (pitch * char_count) / 2;
dy = size_v / 2; /* dx, dy = draw offset between first letter and text center */
ux0 = uy0 = 0; /* for ux0 = uy0 = 0, the text is centered */
wxPoint offset_org( dx, dy );
int irot = aOrient;
while( irot >= 1800 )
irot -= 1800;
while( irot < 0 )
irot += 1800;
if( irot != 0 )
EXCHG( offset_org.x, offset_org.y );
/* Compute the position of the first letter of the text
* this position is the position of the left bottom point of the letter
* this is the same as the text position only for a left and bottom justified text
* In others cases, this position must be calculated from the text position ans size
*/
dx = pitch * char_count;
dy = size_v; /* dx, dy = draw offset between first letter and text center */
switch( aH_justify )
{
case GR_TEXT_HJUSTIFY_CENTER:
current_char_pos.x -= dx / 2;
break;
case GR_TEXT_HJUSTIFY_RIGHT:
ux0 = -offset_org.x;
current_char_pos.x -= dx;
break;
case GR_TEXT_HJUSTIFY_LEFT:
ux0 = offset_org.x;
break;
}
switch( aV_justify )
{
case GR_TEXT_VJUSTIFY_CENTER:
current_char_pos.y += dy/2;
break;
case GR_TEXT_VJUSTIFY_TOP:
uy0 = offset_org.y;
current_char_pos.y += dy;
break;
case GR_TEXT_VJUSTIFY_BOTTOM:
uy0 = -offset_org.y;
break;
}
cX += ux0;
cY += uy0;
ox = cX - dx;
oy = cY + dy;
// Note: if aPanel == NULL, we are using a GL Canvas that handle scaling
if( aPanel && aPanel->GetScreen()->Scale( aSize.x ) == 0 )
return;
if( aPanel && ABS( ( aPanel->GetScreen()->Scale( aSize.x ) ) ) < 3 ) /* shapes are too small: connot be drawn */
/* if a text size is too small, the text cannot be drawn, and it is drawn as a single graphic line */
if( aPanel && ABS( ( aPanel->GetScreen()->Scale( aSize.x ) ) ) < 3 )
{
/* insteed the text is drawn as a line */
dx = (pitch * char_count) / 2;
dy = size_v / 2; /* line is always centered */
/* draw the text as a line always vertically centered */
wxPoint end( current_char_pos.x + dx, current_char_pos.y);
ux0 = cX - dx;
uy0 = cY;
dx += cX;
dy = cY;
RotatePoint( &ux0, &uy0, cX, cY, aOrient );
RotatePoint( &dx, &dy, cX, cY, aOrient );
RotatePoint( &current_char_pos, aPos, aOrient );
RotatePoint( &end, aPos, aOrient );
if( aCallback )
aCallback( ux0, uy0, dx, dy );
aCallback( current_char_pos.x, current_char_pos.y, end.x, end.y );
else
GRLine( &aPanel->m_ClipBox, aDC, ux0, uy0, dx, dy, aWidth, aColor );
GRLine( &aPanel->m_ClipBox, aDC,
current_char_pos.x, current_char_pos.y, end.x, end.y , aWidth, aColor );
return;
}
@ -278,20 +263,18 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
if( overbars % 2 )
{
/* Starting the overbar */
overbar_x = ox;
overbar_y = oy - overbar_position( size_v, thickness );
RotatePoint( &overbar_x, &overbar_y, cX, cY, aOrient );
overbar_pos = current_char_pos;
overbar_pos.y -= overbar_position( size_v, thickness );
RotatePoint( &overbar_pos, aPos, aOrient );
}
else
{
/* Ending the overbar */
coord[0].x = overbar_x;
coord[0].y = overbar_y;
overbar_x = ox;
overbar_y = oy - overbar_position( size_v, thickness );
RotatePoint( &overbar_x, &overbar_y, cX, cY, aOrient );
coord[1].x = overbar_x;
coord[1].y = overbar_y;
coord[0] = overbar_pos;
overbar_pos = current_char_pos;
overbar_pos.y -= overbar_position( size_v, thickness );
RotatePoint( &overbar_pos, aPos, aOrient );
coord[1] = overbar_pos;
/* Plot the overbar segment */
DrawGraphicTextPline( aPanel, aDC, aColor, aWidth,
sketch_mode, 2, coord, aCallback );
@ -345,6 +328,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
default:
{
int y, k1, k2;
wxPoint currpoint;
y = k1 = f_cod; /* trace sur axe V */
k1 = -( (k1 * size_v) / 9 );
@ -357,12 +341,12 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
// To simulate an italic font, add a x offset depending on the y offset
if( aItalic )
k2 -= italic_reverse ? -k1 / 8 : k1 / 8;
dx = k2 + ox; dy = k1 + oy;
currpoint.x = k2 + current_char_pos.x;
currpoint.y = k1 + current_char_pos.y;
RotatePoint( &dx, &dy, cX, cY, aOrient );
coord[point_count].x = dx;
coord[point_count].y = dy;
if( point_count < BUF_SIZE - 1 )
RotatePoint( &currpoint, aPos, aOrient );
coord[point_count] = currpoint;
if( point_count < BUF_SIZE - 1 )
point_count++;
break;
}
@ -373,19 +357,18 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
/* end draw 1 char */
ptr++; ox += pitch;
ptr++;
current_char_pos.x += pitch; // current_char_pos is now the next position
}
if( overbars % 2 )
{
/* Close the last overbar */
coord[0].x = overbar_x;
coord[0].y = overbar_y;
overbar_x = ox;
overbar_y = oy - overbar_position( size_v, thickness );
RotatePoint( &overbar_x, &overbar_y, cX, cY, aOrient );
coord[1].x = overbar_x;
coord[1].y = overbar_y;
coord[0] = overbar_pos;
overbar_pos = current_char_pos;
overbar_pos.y -= overbar_position( size_v, thickness );
RotatePoint( &overbar_pos, aPos, aOrient );
coord[1] = overbar_pos;
/* Plot the overbar segment */
DrawGraphicTextPline( aPanel, aDC, aColor, aWidth,
sketch_mode, 2, coord, aCallback );

View File

@ -469,8 +469,8 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
/* Get the num and name colors */
if( (Color < 0) && (m_Selected & IS_SELECTED) )
Color = g_ItemSelectetColor;
NameColor = (EDA_Colors) (Color == -1 ? ReturnLayerColor( LAYER_PINNAM ) : Color);
NumColor = (EDA_Colors) (Color == -1 ? ReturnLayerColor( LAYER_PINNUM ) : Color);
NameColor = (EDA_Colors) ( Color == -1 ? ReturnLayerColor( LAYER_PINNAM ) : Color );
NumColor = (EDA_Colors) ( Color == -1 ? ReturnLayerColor( LAYER_PINNUM ) : Color );
/* Create the pin num string */
ReturnPinStringNum( StringPinNum );
@ -545,41 +545,45 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
else /* Its a vertical line. */
{
// Text is drawn from bottom to top (i.e. to negative value for Y axis)
if( DrawPinName )
if( orient == PIN_DOWN )
{
if( orient == PIN_DOWN )
{
y = y1 + TextInside;
y = y1 + TextInside;
if( DrawPinName )
DrawGraphicText( panel, DC, wxPoint( x1, y ), NameColor,
m_PinName,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_TOP, LineWidth,
GR_TEXT_HJUSTIFY_RIGHT,
GR_TEXT_VJUSTIFY_CENTER, LineWidth,
false, true );
}
else /* PIN_UP */
{
y = y1 - TextInside;
DrawGraphicText( panel, DC, wxPoint( x1, y ), NameColor,
m_PinName,
TEXT_ORIENT_VERT, PinNameSize,
if( DrawPinNum )
DrawGraphicText( panel, DC,
wxPoint( x1 - TXTMARGE,
(y1 + pin_pos.y) / 2 ), NumColor,
StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, LineWidth,
false, true );
}
GR_TEXT_VJUSTIFY_BOTTOM, LineWidth );
}
if( DrawPinNum )
else /* PIN_UP */
{
DrawGraphicText( panel, DC,
wxPoint( x1 - TXTMARGE,
(y1 + pin_pos.y) / 2 ), NumColor,
StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_RIGHT,
GR_TEXT_VJUSTIFY_CENTER, LineWidth );
y = y1 - TextInside;
if( DrawPinName )
DrawGraphicText( panel, DC, wxPoint( x1, y ), NameColor,
m_PinName,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_LEFT,
GR_TEXT_VJUSTIFY_CENTER, LineWidth,
false, true );
if( DrawPinNum )
DrawGraphicText( panel, DC,
wxPoint( x1 - TXTMARGE,
(y1 + pin_pos.y) / 2 ), NumColor,
StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, LineWidth );
}
}
}
@ -606,7 +610,8 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
y1 + TXTMARGE ),
NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_TOP,
LineWidth );
}
}
@ -619,8 +624,8 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
y ),
NameColor, m_PinName,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT,
GR_TEXT_VJUSTIFY_CENTER, LineWidth, false, true );
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, LineWidth, false, true );
}
if( DrawPinNum )
@ -630,8 +635,8 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
(y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_LEFT,
GR_TEXT_VJUSTIFY_CENTER, LineWidth );
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_TOP, LineWidth );
}
}
}
@ -667,8 +672,8 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
&& g_PlotPSColorOpt;
/* Get the num and name colors */
NameColor = (EDA_Colors) (plot_color ? ReturnLayerColor( LAYER_PINNAM ) : -1);
NumColor = (EDA_Colors) (plot_color ? ReturnLayerColor( LAYER_PINNUM ) : -1);
NameColor = (EDA_Colors) ( plot_color ? ReturnLayerColor( LAYER_PINNAM ) : -1 );
NumColor = (EDA_Colors) ( plot_color ? ReturnLayerColor( LAYER_PINNUM ) : -1 );
/* Create the pin num string */
ReturnPinStringNum( StringPinNum );
@ -697,7 +702,7 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
DrawPinName = FALSE;
PinTxtLen = (int) ( fPinTextPitch * PinTxtLen );
if( TextInside ) /* Draw the text inside, but the pin numbers outside. */
if( TextInside ) /* Draw the text inside, but the pin numbers outside. */
{
if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) ) /* Its an horizontal line. */
{
@ -717,65 +722,73 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
else // orient == PIN_LEFT
{
x = x1 - TextInside;
PlotGraphicText( g_PlotFormat, wxPoint( x, y1 ),
NameColor, m_PinName, TEXT_ORIENT_HORIZ,
PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT,
GR_TEXT_VJUSTIFY_CENTER,
aWidth, aItalic, true );
if( DrawPinName )
PlotGraphicText( g_PlotFormat, wxPoint( x, y1 ),
NameColor, m_PinName, TEXT_ORIENT_HORIZ,
PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT,
GR_TEXT_VJUSTIFY_CENTER,
aWidth, aItalic, true );
}
if( DrawPinNum )
{
PlotGraphicText( g_PlotFormat,
wxPoint( (x1 + pin_pos.x) / 2, y1 - TXTMARGE ),
NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM,
aWidth, aItalic );
}
}
if( DrawPinNum )
{
PlotGraphicText( g_PlotFormat,
wxPoint( (x1 + pin_pos.x) / 2,
y1 - TXTMARGE ),
NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM,
aWidth, aItalic );
}
}
else /* Its a vertical line. */
{
if( DrawPinName )
if( orient == PIN_DOWN )
{
if( orient == PIN_DOWN )
{
y = y1 + TextInside;
y = y1 + TextInside;
if( DrawPinName )
PlotGraphicText( g_PlotFormat, wxPoint( x1, y ), NameColor,
m_PinName,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_TOP,
GR_TEXT_HJUSTIFY_RIGHT,
GR_TEXT_VJUSTIFY_CENTER,
aWidth, aItalic, true );
}
else /* PIN_UP */
if( DrawPinNum )
{
y = y1 - TextInside;
PlotGraphicText( g_PlotFormat, wxPoint( x1, y ), NameColor,
m_PinName,
TEXT_ORIENT_VERT, PinNameSize,
PlotGraphicText( g_PlotFormat,
wxPoint( x1 - TXTMARGE,
(y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM,
aWidth, aItalic, true );
aWidth, aItalic );
}
}
if( DrawPinNum )
else /* PIN_UP */
{
PlotGraphicText( g_PlotFormat,
wxPoint( x1 - TXTMARGE,
(y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_RIGHT,
GR_TEXT_VJUSTIFY_CENTER,
aWidth, aItalic );
y = y1 - TextInside;
if( DrawPinName )
PlotGraphicText( g_PlotFormat, wxPoint( x1, y ), NameColor,
m_PinName,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_LEFT,
GR_TEXT_VJUSTIFY_CENTER,
aWidth, aItalic, true );
if( DrawPinNum )
{
PlotGraphicText( g_PlotFormat,
wxPoint( x1 - TXTMARGE,
(y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM,
aWidth, aItalic );
}
}
}
}
@ -801,7 +814,8 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
PlotGraphicText( g_PlotFormat, wxPoint( x, y1 + TXTMARGE ),
NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_TOP,
aWidth, aItalic );
}
}
@ -814,8 +828,8 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
y ),
NameColor, m_PinName,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT,
GR_TEXT_VJUSTIFY_CENTER,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM,
aWidth, aItalic, true );
}
@ -826,8 +840,8 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
(y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_LEFT,
GR_TEXT_VJUSTIFY_CENTER,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_TOP,
aWidth, aItalic );
}
}
@ -937,7 +951,7 @@ void LibDrawPin::SetPinNumFromString( wxString& buffer )
len = 4;
for( ii = 0; ii < len; ii++ )
{
ascii_buf[ii] = buffer.GetChar( ii );
ascii_buf[ii] = buffer.GetChar( ii );
ascii_buf[ii] &= 0xFF;
}

View File

@ -39,32 +39,32 @@ const char* SheetLabelType[] =
* others are the corners coordinates in reduced units
* the real coordinate is the reduced coordinate * text half size
*/
int TemplateIN_HN[] = { 6, 0, 0, -1, -1, -2, -1, -2, 1, -1, 1, 0, 0 };
int TemplateIN_HI[] = { 6, 0, 0, 1, 1, 2, 1, 2, -1, 1, -1, 0, 0 };
int TemplateIN_BOTTOM[] = { 6, 0, 0, 1, -1, 1, -2, -1, -2, -1, -1, 0, 0 };
int TemplateIN_UP[] = { 6, 0, 0, 1, 1, 1, 2, -1, 2, -1, 1, 0, 0 };
static int TemplateIN_HN[] = { 6, 0, 0, -1, -1, -2, -1, -2, 1, -1, 1, 0, 0 };
static int TemplateIN_HI[] = { 6, 0, 0, 1, 1, 2, 1, 2, -1, 1, -1, 0, 0 };
static int TemplateIN_UP[] = { 6, 0, 0, 1, -1, 1, -2, -1, -2, -1, -1, 0, 0 };
static int TemplateIN_BOTTOM[] = { 6, 0, 0, 1, 1, 1, 2, -1, 2, -1, 1, 0, 0 };
int TemplateOUT_HN[] = { 6, -2, 0, -1, 1, 0, 1, 0, -1, -1, -1, -2, 0 };
int TemplateOUT_HI[] = { 6, 2, 0, 1, -1, 0, -1, 0, 1, 1, 1, 2, 0 };
int TemplateOUT_BOTTOM[] = { 6, 0, -2, 1, -1, 1, 0, -1, 0, -1, -1, 0, -2 };
int TemplateOUT_UP[] = { 6, 0, 2, 1, 1, 1, 0, -1, 0, -1, 1, 0, 2 };
static int TemplateOUT_HN[] = { 6, -2, 0, -1, 1, 0, 1, 0, -1, -1, -1, -2, 0 };
static int TemplateOUT_HI[] = { 6, 2, 0, 1, -1, 0, -1, 0, 1, 1, 1, 2, 0 };
static int TemplateOUT_UP[] = { 6, 0, -2, 1, -1, 1, 0, -1, 0, -1, -1, 0, -2 };
static int TemplateOUT_BOTTOM[] = { 6, 0, 2, 1, 1, 1, 0, -1, 0, -1, 1, 0, 2 };
int TemplateUNSPC_HN[] = { 5, 0, -1, -2, -1, -2, 1, 0, 1, 0, -1 };
int TemplateUNSPC_HI[] = { 5, 0, -1, 2, -1, 2, 1, 0, 1, 0, -1 };
int TemplateUNSPC_BOTTOM[] = { 5, 1, 0, 1, -2, -1, -2, -1, 0, 1, 0 };
int TemplateUNSPC_UP[] = { 5, 1, 0, 1, 2, -1, 2, -1, 0, 1, 0 };
static int TemplateUNSPC_HN[] = { 5, 0, -1, -2, -1, -2, 1, 0, 1, 0, -1 };
static int TemplateUNSPC_HI[] = { 5, 0, -1, 2, -1, 2, 1, 0, 1, 0, -1 };
static int TemplateUNSPC_UP[] = { 5, 1, 0, 1, -2, -1, -2, -1, 0, 1, 0 };
static int TemplateUNSPC_BOTTOM[] = { 5, 1, 0, 1, 2, -1, 2, -1, 0, 1, 0 };
int TemplateBIDI_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
int TemplateBIDI_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
int TemplateBIDI_BOTTOM[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
int TemplateBIDI_UP[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
static int TemplateBIDI_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
static int TemplateBIDI_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
static int TemplateBIDI_UP[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
static int TemplateBIDI_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
int Template3STATE_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
int Template3STATE_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
int Template3STATE_BOTTOM[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
int Template3STATE_UP[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
static int Template3STATE_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
static int Template3STATE_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
static int Template3STATE_UP[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
static int Template3STATE_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
int* TemplateShape[5][4] =
static int* TemplateShape[5][4] =
{
{ TemplateIN_HN, TemplateIN_UP, TemplateIN_HI, TemplateIN_BOTTOM },
{ TemplateOUT_HN, TemplateOUT_UP, TemplateOUT_HI, TemplateOUT_BOTTOM },
@ -84,7 +84,8 @@ SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
m_Pos = pos;
m_Shape = 0;
m_IsDangling = FALSE;
m_MultilineAllowed=true;
m_MultilineAllowed = true;
m_SchematicOrientation = 0;
}
@ -94,9 +95,7 @@ SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
*/
bool SCH_TEXT::HitTest( const wxPoint& aPosRef )
{
EDA_Rect rect = GetBoundingBox();
return rect.Inside( aPosRef );
return EDA_TextStruct::HitTest( aPosRef );
}
@ -135,11 +134,292 @@ SCH_TEXT* SCH_TEXT::GenCopy()
newitem->m_VJustify = m_VJustify;
newitem->m_IsDangling = m_IsDangling;
newitem->m_Italic = m_Italic;
newitem->m_SchematicOrientation = m_SchematicOrientation;
return newitem;
}
/** function GetSchematicTextOffset (virtual)
* @return the offset between the SCH_TEXT position and the text itself position
* This offset depend on orientation, and the type of text
* (room to draw an associated graphic symbol, or put the text above a wire)
*/
wxPoint SCH_TEXT::GetSchematicTextOffset()
{
wxPoint text_offset;
// add a small offset (TXTMARGE) to x ( or y) position to allow a text to be on a wire or a line and be readable
switch( m_SchematicOrientation )
{
default:
case 0: /* Horiz Normal Orientation (left justified) */
text_offset.y = -TXTMARGE;
break;
case 1: /* Vert Orientation UP */
text_offset.x = -TXTMARGE;
break;
case 2: /* Horiz Orientation - Right justified */
text_offset.y = -TXTMARGE;
break;
case 3: /* Vert Orientation BOTTOM */
text_offset.x = -TXTMARGE;
break;
}
return text_offset;
}
/** function GetSchematicTextOffset (virtual)
* @return the offset between the SCH_TEXT position and the text itself position
* This offset depend on orientation, and the type of text
* (room to draw an associated graphic symbol, or put the text above a wire)
*/
wxPoint SCH_LABEL::GetSchematicTextOffset()
{
return SCH_TEXT::GetSchematicTextOffset();
}
/** function GetSchematicTextOffset (virtual)
* @return the offset between the SCH_TEXT position and the text itself position
* This offset depend on orientation, and the type of text
* (room to draw an associated graphic symbol, or put the text above a wire)
*/
wxPoint SCH_HIERLABEL::GetSchematicTextOffset()
{
wxPoint text_offset;
int width = MAX( m_Width, g_DrawMinimunLineWidth );
int ii = m_Size.x + TXTMARGE + width;
switch( m_SchematicOrientation )
{
case 0: /* Orientation horiz normale */
text_offset.x = -ii;
break;
case 1: /* Orientation vert UP */
text_offset.y = -ii;
break;
case 2: /* Orientation horiz inverse */
text_offset.x = ii;
break;
case 3: /* Orientation vert BOTTOM */
text_offset.y = ii;
break;
}
return text_offset;
}
/** function GetSchematicTextOffset (virtual)
* @return the offset between the SCH_TEXT position and the text itself position
* This offset depend on orientation, and the type of text
* (room to draw an associated graphic symbol, or put the text above a wire)
*/
wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset()
{
wxPoint text_offset;
int width = MAX( m_Width, g_DrawMinimunLineWidth );
int HalfSize = m_Size.x / 2;
int offset = width;
switch( m_Shape )
{
case NET_INPUT:
case NET_BIDI:
case NET_TRISTATE:
offset += HalfSize;
break;
case NET_OUTPUT:
offset += TXTMARGE;
break;
default:
break;
}
switch( m_SchematicOrientation )
{
case 0: /* Orientation horiz normale */
text_offset.x -= offset;
break;
case 1: /* Orientation vert UP */
text_offset.y -= offset;
break;
case 2: /* Orientation horiz inverse */
text_offset.x += offset;
break;
case 3: /* Orientation vert BOTTOM */
text_offset.y += offset;
break;
}
return text_offset;
}
/** function SetTextOrientAndJustifyParmeters (virtual)
* Set m_SchematicOrientation, and initialize
* m_orient,m_HJustified and m_VJustified, according to the value of m_SchematicOrientation
* must be called after changing m_SchematicOrientation
* @param aSchematicOrientation =
* 0 = normal (horizontal, left justified).
* 1 = up (vertical)
* 2 = (horizontal, rignt justified). This can be seen as the mirrored position of 0
* 3 = bottom . This can be seen as the mirrored position of up
*/
void SCH_TEXT::SetSchematicTextOrientation( int aSchematicOrientation )
{
m_SchematicOrientation = aSchematicOrientation;
switch( m_SchematicOrientation )
{
default:
case 0: /* Horiz Normal Orientation (left justified) */
m_Orient = TEXT_ORIENT_HORIZ;
m_HJustify = GR_TEXT_HJUSTIFY_LEFT;
m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM;
break;
case 1: /* Vert Orientation UP */
m_Orient = TEXT_ORIENT_VERT;
m_HJustify = GR_TEXT_HJUSTIFY_LEFT;
m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM;
break;
case 2: /* Horiz Orientation - Right justified */
m_Orient = TEXT_ORIENT_HORIZ;
m_HJustify = GR_TEXT_HJUSTIFY_RIGHT;
m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM;
break;
case 3: /* Vert Orientation BOTTOM */
m_Orient = TEXT_ORIENT_VERT;
m_HJustify = GR_TEXT_HJUSTIFY_RIGHT;
m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM;
break;
}
}
/** function SetTextOrientAndJustifyParmeters
* Set m_SchematicOrientation, and initialize
* m_orient,m_HJustified and m_VJustified, according to the value of m_SchematicOrientation (for a label)
* must be called after changing m_SchematicOrientation
* @param aSchematicOrientation =
* 0 = normal (horizontal, left justified).
* 1 = up (vertical)
* 2 = (horizontal, rignt justified). This can be seen as the mirrored position of 0
* 3 = bottom . This can be seen as the mirrored position of up
*/
void SCH_LABEL::SetSchematicTextOrientation( int aSchematicOrientation )
{
SCH_TEXT::SetSchematicTextOrientation( aSchematicOrientation );
}
/** function SetTextOrientAndJustifyParmeters
* Set m_SchematicOrientation, and initialize
* m_orient,m_HJustified and m_VJustified, according to the value of m_SchematicOrientation
* must be called after changing m_SchematicOrientation
* @param aSchematicOrientation =
* 0 = normal (horizontal, left justified).
* 1 = up (vertical)
* 2 = (horizontal, rignt justified). This can be seen as the mirrored position of 0
* 3 = bottom . This can be seen as the mirrored position of up
*/
void SCH_GLOBALLABEL::SetSchematicTextOrientation( int aSchematicOrientation )
{
m_SchematicOrientation = aSchematicOrientation;
switch( m_SchematicOrientation )
{
default:
case 0: /* Horiz Normal Orientation */
m_Orient = TEXT_ORIENT_HORIZ;
m_HJustify = GR_TEXT_HJUSTIFY_RIGHT;
m_VJustify = GR_TEXT_VJUSTIFY_CENTER;
break;
case 1: /* Vert Orientation UP */
m_Orient = TEXT_ORIENT_VERT;
m_HJustify = GR_TEXT_HJUSTIFY_LEFT;
m_VJustify = GR_TEXT_VJUSTIFY_CENTER;
break;
case 2: /* Horiz Orientation */
m_Orient = TEXT_ORIENT_HORIZ;
m_HJustify = GR_TEXT_HJUSTIFY_LEFT;
m_VJustify = GR_TEXT_VJUSTIFY_CENTER;
break;
case 3: /* Vert Orientation BOTTOM */
m_Orient = TEXT_ORIENT_VERT;
m_HJustify = GR_TEXT_HJUSTIFY_RIGHT;
m_VJustify = GR_TEXT_VJUSTIFY_CENTER;
break;
}
}
/** function SetTextOrientAndJustifyParmeters
* Set m_SchematicOrientation, and initialize
* m_orient,m_HJustified and m_VJustified, according to the value of m_SchematicOrientation
* must be called after changing m_SchematicOrientation
* @param aSchematicOrientation =
* 0 = normal (horizontal, left justified).
* 1 = up (vertical)
* 2 = (horizontal, rignt justified). This can be seen as the mirrored position of 0
* 3 = bottom . This can be seen as the mirrored position of up
*/
void SCH_HIERLABEL::SetSchematicTextOrientation( int aSchematicOrientation )
{
m_SchematicOrientation = aSchematicOrientation;
switch( m_SchematicOrientation )
{
default:
case 0: /* Horiz Normal Orientation */
m_Orient = TEXT_ORIENT_HORIZ;
m_HJustify = GR_TEXT_HJUSTIFY_RIGHT;
m_VJustify = GR_TEXT_VJUSTIFY_CENTER;
break;
case 1: /* Vert Orientation UP */
m_Orient = TEXT_ORIENT_VERT;
m_HJustify = GR_TEXT_HJUSTIFY_LEFT;
m_VJustify = GR_TEXT_VJUSTIFY_CENTER;
break;
case 2: /* Horiz Orientation */
m_Orient = TEXT_ORIENT_HORIZ;
m_HJustify = GR_TEXT_HJUSTIFY_LEFT;
m_VJustify = GR_TEXT_VJUSTIFY_CENTER;
break;
case 3: /* Vert Orientation BOTTOM */
m_Orient = TEXT_ORIENT_VERT;
m_HJustify = GR_TEXT_HJUSTIFY_RIGHT;
m_VJustify = GR_TEXT_VJUSTIFY_CENTER;
break;
}
}
/********************************************************/
void SCH_TEXT::SwapData( SCH_TEXT* copyitem )
/********************************************************/
@ -155,6 +435,7 @@ void SCH_TEXT::SwapData( SCH_TEXT* copyitem )
EXCHG( m_HJustify, copyitem->m_HJustify );
EXCHG( m_VJustify, copyitem->m_VJustify );
EXCHG( m_IsDangling, copyitem->m_IsDangling );
EXCHG( m_SchematicOrientation, copyitem->m_SchematicOrientation );
}
@ -198,52 +479,16 @@ void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aOffset,
color = ReturnLayerColor( m_Layer );
GRSetDrawMode( DC, DrawMode );
int orientation;
wxPoint text_offset = aOffset;
wxPoint text_offset = aOffset + GetSchematicTextOffset();
switch( m_Orient )
{
default:
case 0: /* Horiz Normal Orientation (left justified) */
orientation = TEXT_ORIENT_HORIZ;
m_HJustify = GR_TEXT_HJUSTIFY_LEFT;
m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM;
text_offset.y -= TXTMARGE;
break;
case 1: /* Vert Orientation UP */
orientation = TEXT_ORIENT_VERT;
m_HJustify = GR_TEXT_HJUSTIFY_RIGHT;
m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM;
text_offset.x -= TXTMARGE;
break;
case 2: /* Horiz Orientation - Right justified */
orientation = TEXT_ORIENT_HORIZ;
m_HJustify = GR_TEXT_HJUSTIFY_RIGHT;
m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM;
text_offset.y -= TXTMARGE;
break;
case 3: /* Vert Orientation BOTTOM */
orientation = TEXT_ORIENT_VERT;
m_HJustify = GR_TEXT_HJUSTIFY_RIGHT;
m_VJustify = GR_TEXT_VJUSTIFY_TOP;
text_offset.x -= TXTMARGE;
break;
}
// Due to eeschema history; texts orientations are in 0.1 deg, and m_Orient is 0,1,2,3 for label
// Set m_Orient to is value in deg, and after call EDA_TextStruct::Draw retrieve its previous value
EXCHG( orientation, m_Orient );
EXCHG( width, m_Width ); // Set the minimum width
EDA_TextStruct::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR );
EXCHG( orientation, m_Orient ); // set initial value
EXCHG( width, m_Width ); // set initial value
if( m_IsDangling )
DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color );
}
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
@ -257,28 +502,28 @@ bool SCH_TEXT::Save( FILE* aFile ) const
if( m_Italic )
shape = "Italic";
wxString text=m_Text;
for (;;)
wxString text = m_Text;
for( ; ; )
{
int i=text.find('\n');
if (i==wxNOT_FOUND)
break;
text.erase(i,1);
text.insert(i,_("\\n"));
int i = text.find( '\n' );
if( i==wxNOT_FOUND )
break;
text.erase( i, 1 );
text.insert( i, _( "\\n" ) );
}
if( fprintf( aFile, "Text Notes %-4d %-4d %-4d %-4d %s %d\n%s\n",
m_Pos.x, m_Pos.y,
m_Orient, m_Size.x,
shape, m_Width,
CONV_TO_UTF8( text ) ) == EOF )
m_Pos.x, m_Pos.y,
m_SchematicOrientation, m_Size.x,
shape, m_Width,
CONV_TO_UTF8( text ) ) == EOF )
{
success = false;
}
return success;
}
@ -310,6 +555,7 @@ SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) :
m_Layer = LAYER_LOCLABEL;
m_Shape = NET_INPUT;
m_IsDangling = TRUE;
m_MultilineAllowed = false;
}
@ -329,7 +575,7 @@ bool SCH_LABEL::Save( FILE* aFile ) const
if( fprintf( aFile, "Text Label %-4d %-4d %-4d %-4d %s %d\n%s\n",
m_Pos.x, m_Pos.y,
m_Orient, m_Size.x, shape, m_Width,
m_SchematicOrientation, m_Size.x, shape, m_Width,
CONV_TO_UTF8( m_Text ) ) == EOF )
{
success = false;
@ -347,6 +593,7 @@ SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) :
m_Layer = LAYER_GLOBLABEL;
m_Shape = NET_BIDI;
m_IsDangling = TRUE;
m_MultilineAllowed = false;
}
@ -365,7 +612,7 @@ bool SCH_GLOBALLABEL::Save( FILE* aFile ) const
shape = "Italic";
if( fprintf( aFile, "Text GLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n",
m_Pos.x, m_Pos.y,
m_Orient, m_Size.x,
m_SchematicOrientation, m_Size.x,
SheetLabelType[m_Shape],
shape, m_Width,
CONV_TO_UTF8( m_Text ) ) == EOF )
@ -400,6 +647,7 @@ SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text ) :
m_Layer = LAYER_HIERLABEL;
m_Shape = NET_INPUT;
m_IsDangling = TRUE;
m_MultilineAllowed = false;
}
@ -418,7 +666,7 @@ bool SCH_HIERLABEL::Save( FILE* aFile ) const
shape = "Italic";
if( fprintf( aFile, "Text HLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n",
m_Pos.x, m_Pos.y,
m_Orient, m_Size.x,
m_SchematicOrientation, m_Size.x,
SheetLabelType[m_Shape],
shape, m_Width,
CONV_TO_UTF8( m_Text ) ) == EOF )
@ -463,9 +711,8 @@ void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offs
*/
{
static std::vector <wxPoint> Poly;
int ii;
EDA_Colors color;
wxPoint AnchorPos = m_Pos + offset;
wxPoint text_offset = offset + GetSchematicTextOffset();
int width = MAX( m_Width, g_DrawMinimunLineWidth );
@ -476,40 +723,11 @@ void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offs
GRSetDrawMode( DC, DrawMode );
ii = m_Size.x + TXTMARGE;
EXCHG( width, m_Width ); // Set the minimum width
EDA_TextStruct::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR );
EXCHG( width, m_Width ); // set initial value
switch( m_Orient )
{
case 0: /* Orientation horiz normale */
DrawGraphicText( panel, DC,
wxPoint( AnchorPos.x - ii, AnchorPos.y ), color,
m_Text, TEXT_ORIENT_HORIZ, m_Size,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, width, m_Italic, true );
break;
case 1: /* Orientation vert UP */
DrawGraphicText( panel, DC,
wxPoint( AnchorPos.x, AnchorPos.y + ii ), color,
m_Text, TEXT_ORIENT_VERT, m_Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, width, m_Italic, true );
break;
case 2: /* Orientation horiz inverse */
DrawGraphicText( panel, DC,
wxPoint( AnchorPos.x + ii, AnchorPos.y ), color,
m_Text, TEXT_ORIENT_HORIZ, m_Size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, m_Italic, true );
break;
case 3: /* Orientation vert BOTTOM */
DrawGraphicText( panel, DC,
wxPoint( AnchorPos.x, AnchorPos.y - ii ), color,
m_Text, TEXT_ORIENT_VERT, m_Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, width, m_Italic, true );
break;
}
CreateGraphicShape( Poly, AnchorPos );
CreateGraphicShape( Poly, m_Pos + offset );
GRPoly( &panel->m_ClipBox, DC, Poly.size(), &Poly[0], 0, width, color, color );
if( m_IsDangling )
@ -517,17 +735,14 @@ void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offs
}
/**
* Function CreateGraphicShape
/** Function CreateGraphicShape
* calculates the graphic shape (a polygon) associated to the text
* @param aCorner_list = coordinates list fill with polygon corners ooordinates (size > 20)
* @param aCorner_list = a buffer to fill with polygon corners coordinates
* @param Pos = Postion of the shape
* format list is
* corner_count, x0, y0, ... xn, yn
*/
void SCH_HIERLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint& Pos )
{
int* Template = TemplateShape[m_Shape][m_Orient];
int* Template = TemplateShape[m_Shape][m_SchematicOrientation];
int HalfSize = m_Size.x / 2;
int imax = *Template; Template++;
@ -559,11 +774,13 @@ EDA_Rect SCH_HIERLABEL::GetBoundingBox()
int width = MAX( m_Width, g_DrawMinimunLineWidth );
height = m_Size.y + 2 * TXTMARGE;
length = ( Pitch( width ) * NegableTextLength( m_Text ) ) + height + 2 * DANGLING_SYMBOL_SIZE; // add height for triangular shapes
length = ( Pitch( width ) * NegableTextLength( m_Text ) )
+ height // add height for triangular shapes
+ 2 * DANGLING_SYMBOL_SIZE;
switch( m_Orient ) // respect orientation
switch( m_SchematicOrientation ) // respect orientation
{
case 0: /* Horiz Normal Orientation (left justified) */
case 0: /* Horiz Normal Orientation (left justified) */
dx = -length;
dy = height;
x += DANGLING_SYMBOL_SIZE;
@ -572,9 +789,9 @@ EDA_Rect SCH_HIERLABEL::GetBoundingBox()
case 1: /* Vert Orientation UP */
dx = height;
dy = length;
dy = -length;
x -= height / 2;
y -= DANGLING_SYMBOL_SIZE;
y += DANGLING_SYMBOL_SIZE;
break;
case 2: /* Horiz Orientation - Right justified */
@ -586,9 +803,9 @@ EDA_Rect SCH_HIERLABEL::GetBoundingBox()
case 3: /* Vert Orientation BOTTOM */
dx = height;
dy = -length;
dy = length;
x -= height / 2;
y += DANGLING_SYMBOL_SIZE;
y -= DANGLING_SYMBOL_SIZE;
break;
}
@ -599,7 +816,7 @@ EDA_Rect SCH_HIERLABEL::GetBoundingBox()
/*******************************************************************************************/
void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& draw_offset,
void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aOffset,
int DrawMode, int Color )
/******************************************************************************************/
@ -607,10 +824,8 @@ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& dr
*/
{
static std::vector <wxPoint> Poly;
int offset;
EDA_Colors color;
int HalfSize;
wxPoint AnchorPos = m_Pos + draw_offset;;
wxPoint text_offset = aOffset + GetSchematicTextOffset();
int width = MAX( m_Width, g_DrawMinimunLineWidth );
@ -621,67 +836,21 @@ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& dr
GRSetDrawMode( DC, DrawMode );
HalfSize = m_Size.x / 2;
offset = width;
EXCHG( width, m_Width ); // Set the minimum width
EDA_TextStruct::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR );
EXCHG( width, m_Width ); // set initial value
switch( m_Shape )
{
case NET_INPUT:
case NET_BIDI:
case NET_TRISTATE:
offset += HalfSize;
break;
case NET_OUTPUT:
offset += TXTMARGE;
break;
default:
break;
}
switch( m_Orient )
{
case 0: /* Orientation horiz normale */
DrawGraphicText( panel, DC,
wxPoint( AnchorPos.x - offset, AnchorPos.y ), color,
m_Text, TEXT_ORIENT_HORIZ, m_Size,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, width, m_Italic, true );
break;
case 1: /* Orientation vert UP */
DrawGraphicText( panel, DC,
wxPoint( AnchorPos.x, AnchorPos.y + offset ), color,
m_Text, TEXT_ORIENT_VERT, m_Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, width, m_Italic, true );
break;
case 2: /* Orientation horiz inverse */
DrawGraphicText( panel, DC,
wxPoint( AnchorPos.x + offset, AnchorPos.y ), color,
m_Text, TEXT_ORIENT_HORIZ, m_Size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, m_Italic, true );
break;
case 3: /* Orientation vert BOTTOM */
DrawGraphicText( panel, DC,
wxPoint( AnchorPos.x, AnchorPos.y - offset ), color,
m_Text, TEXT_ORIENT_VERT, m_Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, width, m_Italic, true );
break;
}
CreateGraphicShape( Poly, AnchorPos );
CreateGraphicShape( Poly, m_Pos + aOffset );
GRPoly( &panel->m_ClipBox, DC, Poly.size(), &Poly[0], 0, width, color, color );
if( m_IsDangling )
DrawDanglingSymbol( panel, DC, AnchorPos, color );
DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color );
}
/** function CreateGraphicShape
* Calculates the graphic shape (a polygon) associated to the text
* @param aCorner_list = list to fill with polygon corners coordinates
* @param aCorner_list = a buffer to fill with polygon corners coordinates
* @param Pos = Position of the shape
*/
void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint& Pos )
@ -730,13 +899,13 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, c
int angle = 0;
switch( m_Orient )
switch( m_SchematicOrientation )
{
case 0: /* Orientation horiz normale */
break;
case 1: /* Orientation vert UP */
angle = 900;
angle = -900;
break;
case 2: /* Orientation horiz inverse */
@ -744,12 +913,12 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, c
break;
case 3: /* Orientation vert BOTTOM */
angle = -900;
angle = 900;
break;
}
// Rotate outlines and move corners in real position
for( unsigned ii = 0; ii < aCorner_list.size(); ii ++ )
for( unsigned ii = 0; ii < aCorner_list.size(); ii++ )
{
aCorner_list[ii].x += x_offset;
if( angle )
@ -772,13 +941,15 @@ EDA_Rect SCH_GLOBALLABEL::GetBoundingBox()
dx = dy = 0;
int width = MAX( m_Width, g_DrawMinimunLineWidth );
height = m_Size.y + 2 * TXTMARGE;
height = ( (m_Size.y * 15) / 10 ) + width + 2 * TXTMARGE;
length =
( Pitch( width ) * NegableTextLength( m_Text ) ) + 2 * height + 2 * DANGLING_SYMBOL_SIZE; // add 2*height for triangular shapes (bidirectional)
( Pitch( width ) * NegableTextLength( m_Text ) ) // text X size
+ height // add height for triangular shapes (bidirectional)
+ DANGLING_SYMBOL_SIZE;
switch( m_Orient ) // respect orientation
switch( m_SchematicOrientation ) // respect orientation
{
case 0: /* Horiz Normal Orientation (left justified) */
case 0: /* Horiz Normal Orientation (left justified) */
dx = -length;
dy = height;
x += DANGLING_SYMBOL_SIZE;
@ -787,9 +958,9 @@ EDA_Rect SCH_GLOBALLABEL::GetBoundingBox()
case 1: /* Vert Orientation UP */
dx = height;
dy = length;
dy = -length;
x -= height / 2;
y -= DANGLING_SYMBOL_SIZE;
y += DANGLING_SYMBOL_SIZE;
break;
case 2: /* Horiz Orientation - Right justified */
@ -801,9 +972,9 @@ EDA_Rect SCH_GLOBALLABEL::GetBoundingBox()
case 3: /* Vert Orientation BOTTOM */
dx = height;
dy = -length;
dy = length;
x -= height / 2;
y += DANGLING_SYMBOL_SIZE;
y -= DANGLING_SYMBOL_SIZE;
break;
}
@ -826,7 +997,7 @@ EDA_Rect SCH_TEXT::GetBoundingBox()
height = m_Size.y;
dx = dy = 0;
switch( m_Orient ) // respect orientation
switch( m_SchematicOrientation )
{
case 0: /* Horiz Normal Orientation (left justified) */
dx = 2 * DANGLING_SYMBOL_SIZE + length;

View File

@ -8,33 +8,42 @@
#include "macros.h"
#include "base_struct.h"
/* Type des labels sur sheet (Labels sur hierarchie) et forme des Global-Labels*/
/* Type of SCH_HIERLABEL and SCH_GLOBALLABEL
* mainly used to handle the graphic associated shape
*/
typedef enum {
NET_INPUT,
NET_OUTPUT,
NET_BIDI,
NET_TRISTATE,
NET_UNSPECIFIED,
NET_TMAX /* Derniere valeur: fin de tableau */
NET_TMAX /* Last value */
} TypeSheetLabel;
/* Messages correspondants aux types ou forme des labels */
extern const char* SheetLabelType[];
extern int* TemplateShape[5][4];
class SCH_TEXT : public SCH_ITEM
, public EDA_TextStruct
extern const char* SheetLabelType[]; /* names of types of labels */
class SCH_TEXT : public SCH_ITEM,
public EDA_TextStruct
{
public:
int m_Layer;
int m_Shape;
bool m_IsDangling; // TRUE if not connected
bool m_IsDangling; // true if not connected (used to draw the "not connected" symbol
protected:
int m_SchematicOrientation; /* orientation of texts (comments) and labels in schematic
* 0 = normal (horizontal, left justified).
* 1 = up (vertical)
* 2 = (horizontal, rignt justified). This can be seen as the mirrored position of 0
* 3 = bottom . This can be seen as the mirrored position of up
* this is perhaps a duplicate of m_Orient and m_HJustified or m_VJustified,
* but is more easy to handle that 3 parmeters in editions, Reading and Saving file
*/
public:
SCH_TEXT( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString,
KICAD_T aType = TYPE_SCH_TEXT );
KICAD_T aType = TYPE_SCH_TEXT );
~SCH_TEXT() { }
virtual wxString GetClass() const
@ -43,21 +52,42 @@ public:
}
SCH_TEXT* GenCopy();
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode,
int Color = -1 );
/** function SetTextOrientAndJustifyParmeters
* Set m_SchematicOrientation, and initialize
* m_orient,m_HJustified and m_VJustified, according to the value of m_SchematicOrientation (for a text )
* must be called after changing m_SchematicOrientation
* @param aSchematicOrientation =
* 0 = normal (horizontal, left justified).
* 1 = up (vertical)
* 2 = (horizontal, rignt justified). This can be seen as the mirrored position of 0
* 3 = bottom . This can be seen as the mirrored position of up
*/
virtual void SetSchematicTextOrientation( int aSchematicOrientation );
void SwapData( SCH_TEXT* copyitem );
int GetSchematicTextOrientation() { return m_SchematicOrientation;}
void Place( WinEDA_SchematicFrame* frame, wxDC* DC );
/** function GetSchematicTextOffset (virtual)
* @return the offset between the SCH_TEXT position and the text itself position
* This offset depend on orientation, and the type of text
* (room to draw an associated graphic symbol, or put the text above a wire)
*/
virtual wxPoint GetSchematicTextOffset( );
SCH_TEXT* GenCopy();
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode,
int Color = -1 );
void SwapData( SCH_TEXT* copyitem );
void Place( WinEDA_SchematicFrame* frame, wxDC* DC );
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool HitTest( const wxPoint& aPosRef );
bool HitTest( const wxPoint& aPosRef );
EDA_Rect GetBoundingBox();
EDA_Rect GetBoundingBox();
/**
* Function Save
@ -65,15 +95,12 @@ public:
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
bool Save( FILE* aFile ) const;
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os );
void Show( int nestLevel, std::ostream& os );
#endif
};
@ -82,21 +109,41 @@ class SCH_LABEL : public SCH_TEXT
public:
SCH_LABEL( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString );
~SCH_LABEL() { }
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode,
int Color = -1 );
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode,
int Color = -1 );
virtual wxString GetClass() const
{
return wxT( "SCH_LABEL" );
}
/** function SetTextOrientAndJustifyParmeters
* Set m_SchematicOrientation, and initialize
* m_orient,m_HJustified and m_VJustified, according to the value of m_SchematicOrientation (for a label)
* must be called after changing m_SchematicOrientation
* @param aSchematicOrientation =
* 0 = normal (horizontal, left justified).
* 1 = up (vertical)
* 2 = (horizontal, rignt justified). This can be seen as the mirrored position of 0
* 3 = bottom . This can be seen as the mirrored position of up
*/
virtual void SetSchematicTextOrientation( int aSchematicOrientation );
/** function GetSchematicTextOffset (virtual)
* @return the offset between the SCH_TEXT position and the text itself position
* This offset depend on orientation, and the type of text
* (room to draw an associated graphic symbol, or put the text above a wire)
*/
virtual wxPoint GetSchematicTextOffset( );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
bool Save( FILE* aFile ) const;
};
@ -104,10 +151,10 @@ class SCH_GLOBALLABEL : public SCH_TEXT
{
public:
SCH_GLOBALLABEL( const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString );
const wxString& text = wxEmptyString );
~SCH_GLOBALLABEL() { }
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode,
int Color = -1 );
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode,
int Color = -1 );
virtual wxString GetClass() const
{
@ -115,43 +162,58 @@ public:
}
/** function SetTextOrientAndJustifyParmeters
* Set m_SchematicOrientation, and initialize
* m_orient,m_HJustified and m_VJustified, according to the value of m_SchematicOrientation
* must be called after changing m_SchematicOrientation
* @param aSchematicOrientation =
* 0 = normal (horizontal, left justified).
* 1 = up (vertical)
* 2 = (horizontal, rignt justified). This can be seen as the mirrored position of 0
* 3 = bottom . This can be seen as the mirrored position of up
*/
virtual void SetSchematicTextOrientation( int aSchematicOrientation );
/** function GetSchematicTextOffset (virtual)
* @return the offset between the SCH_TEXT position and the text itself position
* This offset depend on orientation, and the type of text
* (room to draw an associated graphic symbol, or put the text above a wire)
*/
virtual wxPoint GetSchematicTextOffset( );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
bool Save( FILE* aFile ) const;
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool HitTest( const wxPoint& aPosRef );
bool HitTest( const wxPoint& aPosRef );
EDA_Rect GetBoundingBox();
EDA_Rect GetBoundingBox();
/** function CreateGraphicShape
* Calculates the graphic shape (a polygon) associated to the text
* @param aCorner_list = coordinates list fill with polygon corners ooordinates
* @param Pos = Postion of the shape
* format list is
* <corner_count>, x0, y0, ... xn, yn
* Calculates the graphic shape (a polygon) associated to the text
* @param aCorner_list = a buffer to fill with polygon corners coordinates
* @param Pos = Position of the shape
*/
void CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint & Pos );
void CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint& Pos );
};
class SCH_HIERLABEL : public SCH_TEXT
{
public:
SCH_HIERLABEL( const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString );
const wxString& text = wxEmptyString );
~SCH_HIERLABEL() { }
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode,
int Color = -1 );
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode,
int Color = -1 );
virtual wxString GetClass() const
{
@ -159,14 +221,31 @@ public:
}
/** function SetTextOrientAndJustifyParmeters
* Set m_SchematicOrientation, and initialize
* m_orient,m_HJustified and m_VJustified, according to the value of m_SchematicOrientation
* must be called after changing m_SchematicOrientation
* @param aSchematicOrientation =
* 0 = normal (horizontal, left justified).
* 1 = up (vertical)
* 2 = (horizontal, rignt justified). This can be seen as the mirrored position of 0
* 3 = bottom . This can be seen as the mirrored position of up
*/
virtual void SetSchematicTextOrientation( int aSchematicOrientation );
/** function GetSchematicTextOffset (virtual)
* @return the offset between the SCH_TEXT position and the text itself position
* This offset depend on orientation, and the type of text
* (room to draw an associated graphic symbol, or put the text above a wire)
*/
virtual wxPoint GetSchematicTextOffset( );
/** function CreateGraphicShape
* Calculates the graphic shape (a polygon) associated to the text
* @param aCorner_list = coordinates list fill with polygon corners ooordinates
* @param Pos = Postion of the shape
* format list is
* <corner_count>, x0, y0, ... xn, yn
*/
void CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint & Pos );
* Calculates the graphic shape (a polygon) associated to the text
* @param aCorner_list = a buffer to fill with polygon corners coordinates
* @param Pos = Postion of the shape
*/
void CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint& Pos );
/**
* Function Save
@ -174,15 +253,15 @@ public:
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
bool Save( FILE* aFile ) const;
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool HitTest( const wxPoint& aPosRef );
bool HitTest( const wxPoint& aPosRef );
EDA_Rect GetBoundingBox();
EDA_Rect GetBoundingBox();
};
#endif /* CLASS_TEXT_LABEL_H */

View File

@ -21,21 +21,8 @@
int DialogLabelEditor::ShowModally( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText )
{
int ret;
bool multiline;
bool multiline = CurrentText->m_MultilineAllowed;
switch( CurrentText->Type() )
{
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_LABEL:
multiline = false;
break;
default:
multiline = true;
break;
}
DialogLabelEditor* dialog = new DialogLabelEditor( parent, CurrentText, multiline );
// doing any post construction resizing is better done here than in
@ -97,7 +84,7 @@ void DialogLabelEditor::init()
EnsureTextCtrlWidth( m_TextLabel );
// Set validators
m_TextOrient->SetSelection( m_CurrentText->m_Orient );
m_TextOrient->SetSelection( m_CurrentText->GetSchematicTextOrientation() );
m_TextShape->SetSelection( m_CurrentText->m_Shape );
int style = 0;

View File

@ -525,6 +525,13 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
else
m_FieldHJustifyCtrl->SetSelection(1);
if( field.m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM )
m_FieldVJustifyCtrl->SetSelection(0);
else if( field.m_VJustify == GR_TEXT_VJUSTIFY_TOP )
m_FieldVJustifyCtrl->SetSelection(2);
else
m_FieldVJustifyCtrl->SetSelection(1);
fieldNameTextCtrl->SetValue( field.m_Name );
// if fieldNdx == REFERENCE, VALUE, FOOTPRINT, or DATASHEET, then disable filed name editing
@ -605,16 +612,7 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField()
field.m_HJustify = hjustify[m_FieldHJustifyCtrl->GetSelection()];
field.m_VJustify = vjustify[m_FieldVJustifyCtrl->GetSelection()];
if( field.m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM )
m_FieldVJustifyCtrl->SetSelection(0);
else if( field.m_VJustify == GR_TEXT_VJUSTIFY_TOP )
m_FieldVJustifyCtrl->SetSelection(2);
else
m_FieldVJustifyCtrl->SetSelection(1);
rotateCheckBox->SetValue( field.m_Orient == TEXT_ORIENT_VERT );
/* Void fields texts for REFERENCE and VALUE (value is the name of the compinent in lib ! ) are not allowed
/* Void fields texts for REFERENCE and VALUE (value is the name of the component in lib ! ) are not allowed
* change them only for a new non void value
*/
if( !fieldValueTextCtrl->GetValue().IsEmpty() || fieldNdx > VALUE )

View File

@ -47,7 +47,7 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event )
else if( (m_CurrentText->m_Flags & IS_NEW) == 0 )
DisplayError( this, _( "Empty Text!" ) );
m_CurrentText->m_Orient = m_TextOrient->GetSelection();
m_CurrentText->SetSchematicTextOrientation( m_TextOrient->GetSelection() );
text = m_TextSize->GetValue();
value = ReturnValueFromString( g_UnitMetric, text, m_Parent->m_InternalUnits );
m_CurrentText->m_Size.x = m_CurrentText->m_Size.y = value;
@ -101,7 +101,7 @@ void WinEDA_SchematicFrame::StartMoveTexte( SCH_TEXT* TextStruct, wxDC* DC )
case TYPE_SCH_TEXT:
ItemInitialPosition = TextStruct->m_Pos;
OldSize = TextStruct->m_Size;
OldOrient = TextStruct->m_Orient;
OldOrient = TextStruct->GetSchematicTextOrientation();
break;
default:
@ -163,14 +163,16 @@ void WinEDA_SchematicFrame::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC )
RedrawOneStruct( DrawPanel, DC, TextStruct, g_XorMode );
/* Rotation du texte */
int orient;
switch( TextStruct->Type() )
{
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_TEXT:
TextStruct->m_Orient++;
TextStruct->m_Orient &= 3;
orient = TextStruct->GetSchematicTextOrientation() + 1;
orient &= 3;
TextStruct->SetSchematicTextOrientation( orient );
break;
default:
@ -209,13 +211,13 @@ SCH_TEXT* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type )
case LAYER_HIERLABEL:
NewText = new SCH_HIERLABEL( GetScreen()->m_Curseur );
NewText->m_Shape = s_DefaultShapeGLabel;
NewText->m_Orient = s_DefaultOrientGLabel;
NewText->SetSchematicTextOrientation( s_DefaultOrientGLabel );
break;
case LAYER_GLOBLABEL:
NewText = new SCH_GLOBALLABEL( GetScreen()->m_Curseur );
NewText->m_Shape = s_DefaultShapeGLabel;
NewText->m_Orient = s_DefaultOrientGLabel;
NewText->SetSchematicTextOrientation( s_DefaultOrientGLabel );
break;
default:
@ -238,7 +240,7 @@ SCH_TEXT* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type )
if( type == LAYER_GLOBLABEL || type == LAYER_HIERLABEL )
{
s_DefaultShapeGLabel = NewText->m_Shape;
s_DefaultOrientGLabel = NewText->m_Orient;
s_DefaultOrientGLabel = NewText->GetSchematicTextOrientation();
}
RedrawOneStruct( DrawPanel, DC, NewText, GR_DEFAULT_DRAWMODE );
@ -317,7 +319,7 @@ static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC )
SCH_TEXT* Text = (SCH_TEXT*) Struct;
Text->m_Pos = ItemInitialPosition;
Text->m_Size = OldSize;
Text->m_Orient = OldOrient;
Text->SetSchematicTextOrientation( OldOrient );
}
break;
@ -372,11 +374,9 @@ void WinEDA_SchematicFrame::ConvertTextType( SCH_TEXT* Text,
/* copy the old text settings */
newtext->m_Shape = Text->m_Shape;
newtext->m_Orient = Text->m_Orient;
newtext->SetSchematicTextOrientation( Text->GetSchematicTextOrientation() );
newtext->m_Size = Text->m_Size;
newtext->m_Width = Text->m_Width;
newtext->m_HJustify = Text->m_HJustify;
newtext->m_VJustify = Text->m_VJustify;
newtext->m_IsDangling = Text->m_IsDangling;
// save current text flag:

View File

@ -311,11 +311,10 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
break;
}
case TYPE_SCH_LABEL:
case TYPE_SCH_TEXT:
#undef STRUCT
#define STRUCT ( (SCH_TEXT*) DrawList )
if( !( SearchMask & (TEXTITEM | LABELITEM) ) )
if( !( SearchMask & TEXTITEM) )
break;
if( STRUCT->HitTest( aPosRef ) )
{
@ -325,21 +324,11 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
break;
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
#undef STRUCT
#define STRUCT ( (SCH_GLOBALLABEL*) DrawList )
if( !(SearchMask & LABELITEM) )
break;
if( STRUCT->HitTest( aPosRef ) )
{
LastSnappedStruct = DrawList;
return TRUE;
}
break;
case TYPE_SCH_HIERLABEL:
#undef STRUCT
#define STRUCT ( (SCH_HIERLABEL*) DrawList )
#define STRUCT ( (SCH_TEXT*) DrawList ) // SCH_TEXT is the base class of these labels
if( !(SearchMask & LABELITEM) )
break;
if( STRUCT->HitTest( aPosRef ) )

View File

@ -10,6 +10,7 @@
#include "grfonte.h"
#include "base_struct.h"
#include "drawtxt.h"
#include "trigo.h"
#include "program.h"
#include "libcmp.h"
@ -20,7 +21,7 @@
static void Plot_Hierarchical_PIN_Sheet( Hierarchical_PIN_Sheet_Struct* Struct );
static void PlotTextField( SCH_COMPONENT* DrawLibItem,
int FieldNumber, int IsMulti, int DrawMode );
static void PlotPinSymbol( const wxPoint & pos, int len, int orient, int Shape );
static void PlotPinSymbol( const wxPoint& pos, int len, int orient, int Shape );
/***/
@ -29,8 +30,8 @@ static void PlotPinSymbol( const wxPoint & pos, int len, int orient, int Shape )
#define NOFILL false
/* routine de lever ou baisser de plume.
* si plume = 'U' les traces suivants se feront plume levee
* si plume = 'D' les traces suivants se feront plume levee
* si plume = 'U' les traces suivants se feront plume levee
* si plume = 'D' les traces suivants se feront plume levee
*/
void Plume( int plume )
{
@ -69,6 +70,7 @@ void SetCurrentLineWidth( int width )
}
}
/*******************************************************************************/
void PlotRect( wxPoint p1, wxPoint p2, int fill, int width )
/*******************************************************************************/
@ -85,18 +87,19 @@ void PlotRect( wxPoint p1, wxPoint p2, int fill, int width )
}
}
/*****************************************************************************************/
void PlotArc( wxPoint aCentre, int aStAngle, int aEndAngle, int aRadius, bool aFill, int aWidth )
/*****************************************************************************************/
/** Function PlotArc
* Plot an arc:
* @param aCentre = Arc centre
* @param aStAngle = begining of arc in 0.1 degrees
* @param aEndAngle = end of arc in 0.1 degrees
* @param aRadius = Arc radius
* @param aFill = fill option
* @param aWidth = Tickness of outlines
* Plot an arc:
* @param aCentre = Arc centre
* @param aStAngle = begining of arc in 0.1 degrees
* @param aEndAngle = end of arc in 0.1 degrees
* @param aRadius = Arc radius
* @param aFill = fill option
* @param aWidth = Tickness of outlines
*/
{
switch( g_PlotFormat )
@ -134,9 +137,9 @@ void PlotPoly( int nb, int* coord, bool fill, int width )
/******************************************************************/
/* Trace un polygone ferme
* coord = tableau des coord des sommets
* nb = nombre de coord ( 1 coord = 2 elements: X et Y du tableau )
* fill : si != 0 polygone rempli
* coord = tableau des coord des sommets
* nb = nombre de coord ( 1 coord = 2 elements: X et Y du tableau )
* fill : si != 0 polygone rempli
*/
{
if( nb <= 1 )
@ -181,7 +184,7 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
/*************************************************/
/* Polt a component */
{
int ii, t1, t2, * Poly, orient;
int ii, t1, t2, * Poly, orient;
LibEDA_BaseStruct* DEntry;
EDA_LibComponentStruct* Entry;
int TransMat[2][2], Multi, convert;
@ -214,122 +217,131 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
switch( DEntry->Type() )
{
case COMPONENT_ARC_DRAW_TYPE:
{
LibDrawArc* Arc = (LibDrawArc*) DEntry;
t1 = Arc->t1; t2 = Arc->t2;
pos = TransformCoordinate( TransMat, Arc->m_Pos ) + DrawLibItem->m_Pos;
MapAngles( &t1, &t2, TransMat );
if( draw_bgfill && Arc->m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
LibDrawArc* Arc = (LibDrawArc*) DEntry;
t1 = Arc->t1; t2 = Arc->t2;
pos = TransformCoordinate( TransMat, Arc->m_Pos ) + DrawLibItem->m_Pos;
MapAngles( &t1, &t2, TransMat );
if ( draw_bgfill && Arc->m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
PlotArc( pos, t1, t2, Arc->m_Rayon, true, 0 );
}
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE ) );
PlotArc( pos, t1, t2, Arc->m_Rayon, Arc->m_Fill == FILLED_SHAPE ? true : false, Arc->m_Width );
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
PlotArc( pos, t1, t2, Arc->m_Rayon, true, 0 );
}
break;
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE ) );
PlotArc( pos,
t1,
t2,
Arc->m_Rayon,
Arc->m_Fill == FILLED_SHAPE ? true : false,
Arc->m_Width );
}
break;
case COMPONENT_CIRCLE_DRAW_TYPE:
{
LibDrawCircle* Circle = (LibDrawCircle*) DEntry;
pos = TransformCoordinate( TransMat, Circle->m_Pos ) + DrawLibItem->m_Pos;
if( draw_bgfill && Circle->m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
LibDrawCircle* Circle = (LibDrawCircle*) DEntry;
pos = TransformCoordinate( TransMat, Circle->m_Pos ) + DrawLibItem->m_Pos;
if ( draw_bgfill && Circle->m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
PlotCercle( pos, Circle->m_Rayon * 2, true, 0 );
}
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE ) );
PlotCercle( pos, Circle->m_Rayon * 2, Circle->m_Fill == FILLED_SHAPE ? true : false, Circle->m_Width );
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
PlotCercle( pos, Circle->m_Rayon * 2, true, 0 );
}
break;
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE ) );
PlotCercle( pos,
Circle->m_Rayon * 2,
Circle->m_Fill == FILLED_SHAPE ? true : false,
Circle->m_Width );
}
break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
{
{
LibDrawText* Text = (LibDrawText*) DEntry;
/* The text orientation may need to be flipped if the
* transformation matrix causes xy axes to be flipped. */
t1 = (TransMat[0][0] != 0) ^ (Text->m_Orient != 0);
* transformation matrix causes xy axes to be flipped. */
t1 = (TransMat[0][0] != 0) ^ (Text->m_Orient != 0);
pos = TransformCoordinate( TransMat, Text->m_Pos ) + DrawLibItem->m_Pos;
SetCurrentLineWidth( -1 );
int thickness = Text->m_Width;
if( thickness == 0 ) //
thickness = MAX( g_PlotLine_Width, g_DrawMinimunLineWidth );
if( thickness == 0 ) //
thickness = MAX( g_PlotLine_Width, g_DrawMinimunLineWidth );
PlotGraphicText( g_PlotFormat, pos, CharColor,
Text->m_Text,
t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT,
Text->m_Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
thickness, false, true);
}
break;
Text->m_Text,
t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT,
Text->m_Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
thickness, false, true );
}
break;
case COMPONENT_RECT_DRAW_TYPE:
{
LibDrawSquare* Square = (LibDrawSquare*) DEntry;
pos = TransformCoordinate( TransMat, Square->m_Pos ) + DrawLibItem->m_Pos;
wxPoint end = TransformCoordinate( TransMat, Square->m_End ) + DrawLibItem->m_Pos;
{
LibDrawSquare* Square = (LibDrawSquare*) DEntry;
pos = TransformCoordinate( TransMat, Square->m_Pos ) + DrawLibItem->m_Pos;
wxPoint end =
TransformCoordinate( TransMat, Square->m_End ) + DrawLibItem->m_Pos;
if ( draw_bgfill && Square->m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
PlotRect( pos, end, true, 0 );
}
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE ) );
PlotRect( pos, end, Square->m_Fill == FILLED_SHAPE ? true : false, Square->m_Width );
if( draw_bgfill && Square->m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
PlotRect( pos, end, true, 0 );
}
break;
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE ) );
PlotRect( pos, end, Square->m_Fill == FILLED_SHAPE ? true : false, Square->m_Width );
}
break;
case COMPONENT_PIN_DRAW_TYPE: /* Trace des Pins */
{
LibDrawPin* Pin = (LibDrawPin*) DEntry;
if( Pin->m_Attributs & PINNOTDRAW )
break;
{
LibDrawPin* Pin = (LibDrawPin*) DEntry;
if( Pin->m_Attributs & PINNOTDRAW )
break;
/* Calcul de l'orientation reelle de la Pin */
orient = Pin->ReturnPinDrawOrient( TransMat );
/* compute Pin Pos */
pos = TransformCoordinate( TransMat, Pin->m_Pos ) + DrawLibItem->m_Pos;
/* Calcul de l'orientation reelle de la Pin */
orient = Pin->ReturnPinDrawOrient( TransMat );
/* compute Pin Pos */
pos = TransformCoordinate( TransMat, Pin->m_Pos ) + DrawLibItem->m_Pos;
/* Dessin de la pin et du symbole special associe */
PlotPinSymbol( pos, Pin->m_PinLen, orient, Pin->m_PinShape );
int thickness = MAX( g_PlotLine_Width, g_DrawMinimunLineWidth );;
Pin->PlotPinTexts( pos, orient,
Entry->m_TextInside,
Entry->m_DrawPinNum, Entry->m_DrawPinName,
thickness, false);
}
break;
/* Dessin de la pin et du symbole special associe */
PlotPinSymbol( pos, Pin->m_PinLen, orient, Pin->m_PinShape );
int thickness = MAX( g_PlotLine_Width, g_DrawMinimunLineWidth );;
Pin->PlotPinTexts( pos, orient,
Entry->m_TextInside,
Entry->m_DrawPinNum, Entry->m_DrawPinName,
thickness, false );
}
break;
case COMPONENT_POLYLINE_DRAW_TYPE:
{
LibDrawPolyline* polyline = (LibDrawPolyline*) DEntry;
Poly = (int*) MyMalloc( sizeof(int) * 2 * polyline->GetCornerCount() );
for( ii = 0; ii < (int) polyline->GetCornerCount(); ii++ )
{
LibDrawPolyline* polyline = (LibDrawPolyline*) DEntry;
Poly = (int*) MyMalloc( sizeof(int) * 2 * polyline->GetCornerCount() );
for( ii = 0; ii < (int)polyline->GetCornerCount(); ii++ )
{
pos = polyline->m_PolyPoints[ii];
pos = TransformCoordinate( TransMat, pos ) + DrawLibItem->m_Pos;
Poly[ii * 2] = pos.x;
Poly[ii * 2 + 1] = pos.y;
}
if ( draw_bgfill && polyline->m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
PlotPoly( ii, Poly, true, 0 );
}
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE ) );
PlotPoly( ii, Poly, polyline->m_Fill == FILLED_SHAPE ? true : false, polyline->m_Width );
MyFree( Poly );
pos = polyline->m_PolyPoints[ii];
pos = TransformCoordinate( TransMat, pos ) + DrawLibItem->m_Pos;
Poly[ii * 2] = pos.x;
Poly[ii * 2 + 1] = pos.y;
}
break;
if( draw_bgfill && polyline->m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
PlotPoly( ii, Poly, true, 0 );
}
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE ) );
PlotPoly( ii, Poly, polyline->m_Fill == FILLED_SHAPE ? true : false, polyline->m_Width );
MyFree( Poly );
}
break;
default:
D(printf("Drawing Type=%d\n", DEntry->Type() )) ;
D( printf( "Drawing Type=%d\n", DEntry->Type() ) );
}
/* Fin Switch */
@ -339,8 +351,8 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
/* Fin Boucle de dessin */
/* Trace des champs, avec placement et orientation selon orient. du
* composant
* Si la reference commence par # elle n'est pas tracee
* composant
* Si la reference commence par # elle n'est pas tracee
*/
if( (Entry->m_Prefix.m_Attributs & TEXT_NO_VISIBLE) == 0 )
@ -367,20 +379,20 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem,
/**************************************************************/
/* Routine de trace des textes type Field du composant.
* entree:
* DrawLibItem: pointeur sur le composant
* FieldNumber: Numero du champ
* IsMulti: flag Non Null si il y a plusieurs parts par boitier.
* n'est utile que pour le champ reference pour ajouter a celui ci
* l'identification de la part ( A, B ... )
* DrawMode: mode de trace
* entree:
* DrawLibItem: pointeur sur le composant
* FieldNumber: Numero du champ
* IsMulti: flag Non Null si il y a plusieurs parts par boitier.
* n'est utile que pour le champ reference pour ajouter a celui ci
* l'identification de la part ( A, B ... )
* DrawMode: mode de trace
*/
{
wxPoint textpos; /* Position des textes */
SCH_CMP_FIELD* field = DrawLibItem->GetField( FieldNumber );
int orient;
EDA_Colors color = UNSPECIFIED_COLOR;
wxPoint textpos; /* Position des textes */
SCH_CMP_FIELD* field = DrawLibItem->GetField( FieldNumber );
int orient;
EDA_Colors color = UNSPECIFIED_COLOR;
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
color = ReturnLayerColor( field->GetLayer() );
@ -392,9 +404,9 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem,
return;
/* Calcul de la position des textes, selon orientation du composant */
orient = field->m_Orient;
orient = field->m_Orient;
GRTextHorizJustifyType hjustify = field->m_HJustify;
GRTextVertJustifyType vjustify = field->m_VJustify;
GRTextVertJustifyType vjustify = field->m_VJustify;
textpos = field->m_Pos - DrawLibItem->m_Pos; // textpos is the text position relative to the component anchor
textpos = TransformCoordinate( DrawLibItem->m_Transform, textpos ) + DrawLibItem->m_Pos;
@ -412,62 +424,74 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem,
vjustify = (GRTextVertJustifyType) tmp;
if( DrawLibItem->m_Transform[1][0] < 0 )
switch ( vjustify )
switch( vjustify )
{
case GR_TEXT_VJUSTIFY_BOTTOM:
vjustify = GR_TEXT_VJUSTIFY_TOP;
break;
case GR_TEXT_VJUSTIFY_TOP:
vjustify = GR_TEXT_VJUSTIFY_BOTTOM;
break;
default:
break;
case GR_TEXT_VJUSTIFY_BOTTOM:
vjustify = GR_TEXT_VJUSTIFY_TOP;
break;
case GR_TEXT_VJUSTIFY_TOP:
vjustify = GR_TEXT_VJUSTIFY_BOTTOM;
break;
default:
break;
}
if( DrawLibItem->m_Transform[1][0] > 0 )
switch ( hjustify )
switch( hjustify )
{
case GR_TEXT_HJUSTIFY_LEFT:
hjustify = GR_TEXT_HJUSTIFY_RIGHT;
break;
case GR_TEXT_HJUSTIFY_RIGHT:
hjustify = GR_TEXT_HJUSTIFY_LEFT;
break;
default:
break;
case GR_TEXT_HJUSTIFY_LEFT:
hjustify = GR_TEXT_HJUSTIFY_RIGHT;
break;
case GR_TEXT_HJUSTIFY_RIGHT:
hjustify = GR_TEXT_HJUSTIFY_LEFT;
break;
default:
break;
}
}
else
{
/* Texte horizontal: Y a t-il miroir (pour les justifications)*/
if( DrawLibItem->m_Transform[0][0] < 0 )
switch ( hjustify )
switch( hjustify )
{
case GR_TEXT_HJUSTIFY_LEFT:
hjustify = GR_TEXT_HJUSTIFY_RIGHT;
break;
case GR_TEXT_HJUSTIFY_RIGHT:
hjustify = GR_TEXT_HJUSTIFY_LEFT;
break;
default:
break;
case GR_TEXT_HJUSTIFY_LEFT:
hjustify = GR_TEXT_HJUSTIFY_RIGHT;
break;
case GR_TEXT_HJUSTIFY_RIGHT:
hjustify = GR_TEXT_HJUSTIFY_LEFT;
break;
default:
break;
}
if( DrawLibItem->m_Transform[1][1] > 0 )
switch ( vjustify )
switch( vjustify )
{
case GR_TEXT_VJUSTIFY_BOTTOM:
vjustify = GR_TEXT_VJUSTIFY_TOP;
break;
case GR_TEXT_VJUSTIFY_TOP:
vjustify = GR_TEXT_VJUSTIFY_BOTTOM;
break;
default:
break;
case GR_TEXT_VJUSTIFY_BOTTOM:
vjustify = GR_TEXT_VJUSTIFY_TOP;
break;
case GR_TEXT_VJUSTIFY_TOP:
vjustify = GR_TEXT_VJUSTIFY_BOTTOM;
break;
default:
break;
}
}
int thickness = field->m_Width;
if( thickness == 0 )
thickness = MAX( g_PlotLine_Width, g_DrawMinimunLineWidth );
if( thickness == 0 )
thickness = MAX( g_PlotLine_Width, g_DrawMinimunLineWidth );
SetCurrentLineWidth( thickness );
if( !IsMulti || (FieldNumber != REFERENCE) )
@ -476,14 +500,14 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem,
orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
field->m_Size,
hjustify, vjustify,
thickness, field->m_Italic, true);
thickness, field->m_Italic, true );
}
else /* We plt the reference, for a multiple parts per package */
{
/* Adding A, B ... to the reference */
/* Adding A, B ... to the reference */
wxString Text;
Text = field->m_Text;
char unit_id;
char unit_id;
#if defined(KICAD_GOST)
Text.Append( '.' );
unit_id = '1' - 1 + DrawLibItem->m_Multi;
@ -494,19 +518,19 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem,
PlotGraphicText( g_PlotFormat, textpos, color, Text,
orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
field->m_Size, hjustify, vjustify,
thickness, field->m_Italic );
thickness, field->m_Italic );
}
}
/**************************************************************************/
static void PlotPinSymbol( const wxPoint & pos, int len, int orient, int Shape )
static void PlotPinSymbol( const wxPoint& pos, int len, int orient, int Shape )
/**************************************************************************/
/* Trace la pin du symbole en cours de trace
*/
{
int MapX1, MapY1, x1, y1;
int MapX1, MapY1, x1, y1;
EDA_Colors color = UNSPECIFIED_COLOR;
color = ReturnLayerColor( LAYER_PIN );
@ -540,7 +564,7 @@ static void PlotPinSymbol( const wxPoint & pos, int len, int orient, int Shape )
if( Shape & INVERT )
{
PlotCercle( wxPoint( MapX1 * INVERT_PIN_RADIUS + x1,
MapY1 * INVERT_PIN_RADIUS + y1),
MapY1 * INVERT_PIN_RADIUS + y1 ),
INVERT_PIN_RADIUS * 2, // diameter
false, // fill
-1 ); // width
@ -612,18 +636,11 @@ void PlotTextStruct( EDA_BaseStruct* Struct )
/*******************************************/
/*
* Routine de trace des Textes, Labels et Global-Labels.
* Les textes peuvent avoir 4 directions.
* Routine de trace des Textes, Labels et Global-Labels.
* Les textes peuvent avoir 4 directions.
*/
{
static std::vector <wxPoint> Poly;
int pX, pY, Shape = 0, Orient = 0, offset;
wxSize Size;
wxString Text;
EDA_Colors color = UNSPECIFIED_COLOR;
bool italic = false;
int thickness = 0;
static std::vector <wxPoint> Poly;
switch( Struct->Type() )
{
@ -631,117 +648,60 @@ void PlotTextStruct( EDA_BaseStruct* Struct )
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_LABEL:
case TYPE_SCH_TEXT:
Text = ( (SCH_TEXT*) Struct )->m_Text;
Size = ( (SCH_TEXT*) Struct )->m_Size;
thickness = ( (SCH_TEXT*) Struct )->m_Width;
italic = ( (SCH_TEXT*) Struct )->m_Italic;
Orient = ( (SCH_TEXT*) Struct )->m_Orient;
Shape = ( (SCH_TEXT*) Struct )->m_Shape;
pX = ( (SCH_TEXT*) Struct )->m_Pos.x;
pY = ( (SCH_TEXT*) Struct )->m_Pos.y;
offset = TXTMARGE;
if( Struct->Type() == TYPE_SCH_GLOBALLABEL
|| Struct->Type() == TYPE_SCH_HIERLABEL )
offset += Size.x; // We must draw the Glabel graphic symbol
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
color = ReturnLayerColor( ( (SCH_TEXT*) Struct )->m_Layer );
break;
default:
return;
}
if( Size.x == 0 )
Size = wxSize( DEFAULT_SIZE_TEXT, DEFAULT_SIZE_TEXT );
SCH_TEXT* schText = (SCH_TEXT*) Struct;
EDA_Colors color = UNSPECIFIED_COLOR;
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
color = ReturnLayerColor( schText->m_Layer );
wxPoint textpos = schText->m_Pos + schText->GetSchematicTextOffset();
int thickness = schText->m_Width;
if( thickness == 0 )
thickness = MAX( g_PlotLine_Width, g_DrawMinimunLineWidth );
if ( Struct->Type() == TYPE_SCH_GLOBALLABEL )
{
offset = ( (SCH_GLOBALLABEL*) Struct )->m_Width;
switch( Shape )
{
case NET_INPUT:
case NET_BIDI:
case NET_TRISTATE:
offset += Size.x/2;
break;
case NET_OUTPUT:
offset += TXTMARGE;
break;
default:
break;
}
}
if( thickness == 0 )
thickness = MAX( g_PlotLine_Width, g_DrawMinimunLineWidth );
SetCurrentLineWidth( thickness );
switch( Orient )
if( schText->m_MultilineAllowed )
{
case 0: /* Orientation horiz normale */
if( Struct->Type() == TYPE_SCH_GLOBALLABEL || Struct->Type() == TYPE_SCH_HIERLABEL )
PlotGraphicText( g_PlotFormat, wxPoint( pX - offset, pY ),
color, Text, TEXT_ORIENT_HORIZ, Size,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, true );
else
PlotGraphicText( g_PlotFormat, wxPoint( pX, pY - offset ),
color, Text, TEXT_ORIENT_HORIZ, Size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM,
thickness, italic, true );
break;
wxPoint pos = textpos;
wxArrayString* list = wxStringSplit( schText->m_Text, '\n' );
wxPoint offset;
case 1: /* Orientation vert UP */
if( Struct->Type() == TYPE_SCH_GLOBALLABEL || Struct->Type() == TYPE_SCH_HIERLABEL )
PlotGraphicText( g_PlotFormat, wxPoint( pX, pY + offset ),
color, Text, TEXT_ORIENT_VERT, Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP,
thickness, italic, true );
else
PlotGraphicText( g_PlotFormat, wxPoint( pX - offset, pY ),
color, Text, TEXT_ORIENT_VERT, Size,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM,
thickness, italic, true );
break;
offset.y = schText->GetInterline();
case 2: /* Horiz Orientation - Right justified */
if( Struct->Type() == TYPE_SCH_GLOBALLABEL || Struct->Type() == TYPE_SCH_HIERLABEL )
PlotGraphicText( g_PlotFormat, wxPoint( pX + offset, pY ),
color, Text, TEXT_ORIENT_HORIZ, Size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, true );
else
PlotGraphicText( g_PlotFormat, wxPoint( pX, pY - offset ),
color, Text, TEXT_ORIENT_HORIZ, Size,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM,
thickness, italic, true );
break;
RotatePoint( &offset, schText->m_Orient );
for( unsigned i = 0; i<list->Count(); i++ )
{
wxString txt = list->Item( i );
PlotGraphicText( g_PlotFormat, pos,
color, txt, schText->m_Orient, schText->m_Size,
schText->m_HJustify, schText->m_VJustify,
thickness, schText->m_Italic, true );
pos += offset;
}
case 3: /* Orientation vert BOTTOM */
if( Struct->Type() == TYPE_SCH_GLOBALLABEL || Struct->Type() == TYPE_SCH_HIERLABEL )
PlotGraphicText( g_PlotFormat, wxPoint( pX, pY - offset ),
color, Text, TEXT_ORIENT_VERT, Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM,
thickness, italic, true );
else
PlotGraphicText( g_PlotFormat, wxPoint( pX - offset, pY ),
color, Text, TEXT_ORIENT_VERT, Size,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_TOP,
thickness, italic, true );
break;
delete (list);
}
else
PlotGraphicText( g_PlotFormat, textpos,
color, schText->m_Text, schText->m_Orient, schText->m_Size,
schText->m_HJustify, schText->m_VJustify,
thickness, schText->m_Italic, true );
/* Draw graphic symbol for global or hierachical labels */
if( Struct->Type() == TYPE_SCH_GLOBALLABEL )
{
( (SCH_GLOBALLABEL*) Struct )->CreateGraphicShape( Poly, wxPoint(pX, pY) );
( (SCH_GLOBALLABEL*) Struct )->CreateGraphicShape( Poly, schText->m_Pos );
PlotPoly( Poly.size(), &Poly[0].x, NOFILL );
}
if( Struct->Type() == TYPE_SCH_HIERLABEL )
{
( (SCH_HIERLABEL*) Struct )->CreateGraphicShape( Poly, wxPoint(pX, pY) );
( (SCH_HIERLABEL*) Struct )->CreateGraphicShape( Poly, schText->m_Pos );
PlotPoly( Poly.size(), &Poly[0].x, NOFILL );
}
}
@ -750,11 +710,13 @@ void PlotTextStruct( EDA_BaseStruct* Struct )
/*****************************************************************************************/
static void Plot_Hierarchical_PIN_Sheet( Hierarchical_PIN_Sheet_Struct* aHierarchical_PIN )
/****************************************************************************************/
/* Plot a Hierarchical_PIN_Sheet
*/
*/
{
EDA_Colors txtcolor = UNSPECIFIED_COLOR;
int posx, tposx, posy, size;
int posx, tposx, posy, size;
static std::vector <wxPoint> Poly;
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
@ -775,14 +737,14 @@ static void Plot_Hierarchical_PIN_Sheet( Hierarchical_PIN_Sheet_Struct* aHierarc
side = GR_TEXT_HJUSTIFY_LEFT;
}
int thickness = aHierarchical_PIN->m_Width;
if( thickness == 0 )
thickness = MAX( g_PlotLine_Width, g_DrawMinimunLineWidth );
if( thickness == 0 )
thickness = MAX( g_PlotLine_Width, g_DrawMinimunLineWidth );
SetCurrentLineWidth( thickness );
PlotGraphicText( g_PlotFormat, wxPoint( tposx, posy ), txtcolor,
aHierarchical_PIN->m_Text, TEXT_ORIENT_HORIZ, wxSize( size, size ),
side, GR_TEXT_VJUSTIFY_CENTER,
thickness, aHierarchical_PIN->m_Italic, true );
thickness, aHierarchical_PIN->m_Italic, true );
/* Draw the associated graphic symbol */
aHierarchical_PIN->CreateGraphicShape( Poly, aHierarchical_PIN->m_Pos );
@ -798,9 +760,9 @@ void PlotSheetStruct( DrawSheetStruct* Struct )
{
Hierarchical_PIN_Sheet_Struct* SheetLabelStruct;
EDA_Colors txtcolor = UNSPECIFIED_COLOR;
wxSize size;
wxString Text;
wxPoint pos;
wxSize size;
wxString Text;
wxPoint pos;
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS( ReturnLayerColor( Struct->m_Layer ) );
@ -834,7 +796,7 @@ void PlotSheetStruct( DrawSheetStruct* Struct )
PlotGraphicText( g_PlotFormat, pos, txtcolor,
Text, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM,
thickness, italic );
thickness, italic );
/*Draw texts : FileName */
Text = Struct->GetFileName();
@ -848,7 +810,7 @@ void PlotSheetStruct( DrawSheetStruct* Struct )
txtcolor,
Text, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP,
thickness, italic );
thickness, italic );
/* Draw texts : SheetLabel */
SheetLabelStruct = Struct->m_Label;

View File

@ -75,7 +75,7 @@ SCH_ITEM* ReadTextDescr( FILE* aFile,
new SCH_LABEL( pos, CONV_FROM_UTF8( text ) );
TextStruct->m_Size.x = TextStruct->m_Size.y = size;
TextStruct->m_Orient = orient;
TextStruct->SetSchematicTextOrientation( orient );
if( isdigit( Name3[0] ) )
{
thickness = atol( Name3 );
@ -92,7 +92,7 @@ SCH_ITEM* ReadTextDescr( FILE* aFile,
Struct = TextStruct;
TextStruct->m_Size.x = TextStruct->m_Size.y = size;
TextStruct->m_Orient = orient;
TextStruct->SetSchematicTextOrientation( orient );
TextStruct->m_Shape = NET_INPUT;
TextStruct->m_Width = thickness;
@ -115,7 +115,7 @@ SCH_ITEM* ReadTextDescr( FILE* aFile,
Struct = TextStruct;
TextStruct->m_Size.x = TextStruct->m_Size.y = size;
TextStruct->m_Orient = orient;
TextStruct->SetSchematicTextOrientation( orient );
TextStruct->m_Shape = NET_INPUT;
TextStruct->m_Width = thickness;
@ -138,14 +138,14 @@ SCH_ITEM* ReadTextDescr( FILE* aFile,
int i=val.find(_("\\n"));
if (i==wxNOT_FOUND)
break;
val.erase(i,2);
val.insert(i,_("\n"));
}
SCH_TEXT* TextStruct = new SCH_TEXT( pos, val );
TextStruct->m_Size.x = TextStruct->m_Size.y = size;
TextStruct->m_Orient = orient;
TextStruct->SetSchematicTextOrientation( orient );
if( isdigit( Name3[0] ) )
{
thickness = atol( Name3 );

View File

@ -353,7 +353,7 @@ static void PlotTextModule( TEXTE_MODULE* pt_texte, int format_plot )
pt_texte->m_Text,
orient, size,
pt_texte->m_HJustify, pt_texte->m_VJustify,
thickness, pt_texte->m_Italic );
thickness, pt_texte->m_Italic, true );
}
@ -620,11 +620,34 @@ void PlotTextePcb( TEXTE_PCB* pt_texte, int format_plot, int masque_layer )
break;
}
PlotGraphicText( format_plot, pos, BLACK,
if( pt_texte->m_MultilineAllowed )
{
wxArrayString* list = wxStringSplit( pt_texte->m_Text, '\n' );
wxPoint offset;
offset.y = pt_texte->GetInterline();
RotatePoint( &offset, orient );
for( unsigned i = 0; i<list->Count(); i++ )
{
wxString txt = list->Item( i );
PlotGraphicText( format_plot, pos, BLACK,
txt,
orient, size,
pt_texte->m_HJustify, pt_texte->m_VJustify,
thickness, pt_texte->m_Italic, true );
pos += offset;
}
delete (list);
}
else
PlotGraphicText( format_plot, pos, BLACK,
pt_texte->m_Text,
orient, size,
pt_texte->m_HJustify, pt_texte->m_VJustify,
thickness, pt_texte->m_Italic );
thickness, pt_texte->m_Italic, true );
}