Commit 5759f734 authored by charras's avatar charras

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.
parent 804e5397
...@@ -4,6 +4,17 @@ KiCad ChangeLog 2009 ...@@ -4,6 +4,17 @@ KiCad ChangeLog 2009
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. 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> 2009-may-01 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================ ================================================================================
++pcbnew: ++pcbnew:
......
...@@ -254,8 +254,8 @@ EDA_Rect EDA_TextStruct::GetTextBox( int aLine ) ...@@ -254,8 +254,8 @@ EDA_Rect EDA_TextStruct::GetTextBox( int aLine )
rect.SetSize( textsize ); rect.SetSize( textsize );
/* Now, calculate the rect origin, according to text justification /* Now, calculate the rect origin, according to text justification
* At this point the area origin is the text origin. * At this point the area origin is the text origin (m_Pos).
* This is true only for left and top text justified. * This is true only for left and top text justified texts.
* and must be recalculated for others justifications * and must be recalculated for others justifications
* also, note the V justification is relative to the first line * also, note the V justification is relative to the first line
*/ */
...@@ -284,7 +284,7 @@ EDA_Rect EDA_TextStruct::GetTextBox( int aLine ) ...@@ -284,7 +284,7 @@ EDA_Rect EDA_TextStruct::GetTextBox( int aLine )
break; break;
case GR_TEXT_VJUSTIFY_BOTTOM: case GR_TEXT_VJUSTIFY_BOTTOM:
rect.SetY( rect.GetY() + (dy / 2) ); rect.SetY( rect.GetY() - dy );
break; break;
} }
......
...@@ -20,6 +20,14 @@ ...@@ -20,6 +20,14 @@
#define EDA_DRAWBASE #define EDA_DRAWBASE
#include "grfonte.h" #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 /** Function NegableTextLength
* Return the text length of a negable string, excluding the ~ markers */ * Return the text length of a negable string, excluding the ~ markers */
int NegableTextLength( const wxString& aText ) int NegableTextLength( const wxString& aText )
...@@ -48,7 +56,7 @@ static void DrawGraphicTextPline( ...@@ -48,7 +56,7 @@ static void DrawGraphicTextPline(
bool sketch_mode, bool sketch_mode,
int point_count, int point_count,
wxPoint* coord, wxPoint* coord,
void (* aCallback)(int x0, int y0, int xf, int yf) ) void (*aCallback)( int x0, int y0, int xf, int yf ) )
{ {
if( aCallback ) if( aCallback )
{ {
...@@ -107,7 +115,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, ...@@ -107,7 +115,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
int aWidth, int aWidth,
bool aItalic, bool aItalic,
bool aNegable, 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; int char_count, AsciiCode;
...@@ -116,10 +124,9 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, ...@@ -116,10 +124,9 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
SH_CODE f_cod, plume = 'U'; SH_CODE f_cod, plume = 'U';
const SH_CODE* ptcar; const SH_CODE* ptcar;
int ptr; int ptr;
int ux0, uy0, dx, dy; // Draw coordinate for segments to draw. also used in some other calculation int dx, dy; // Draw coordinate for segments to draw. also used in some other calculation
int cX, cY; // Texte center wxPoint current_char_pos; // Draw coordinates for the current char
int ox, oy; // Draw coordinates for the current char wxPoint overbar_pos; // Start point for the current overbar
int overbar_x, overbar_y; // Start point for the current overbar
int overbars; // Number of ~ seen int overbars; // Number of ~ seen
#define BUF_SIZE 100 #define BUF_SIZE 100
...@@ -156,8 +163,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, ...@@ -156,8 +163,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
else else
pitch -= thickness; pitch -= thickness;
ox = cX = aPos.x; current_char_pos = aPos;
oy = cY = aPos.y;
/* Do not draw the text if out of draw area! */ /* Do not draw the text if out of draw area! */
if( aPanel ) if( aPanel )
...@@ -166,8 +172,8 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, ...@@ -166,8 +172,8 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
int textsize = ABS( pitch ); int textsize = ABS( pitch );
ll = aPanel->GetScreen()->Scale( textsize * char_count ); ll = aPanel->GetScreen()->Scale( textsize * char_count );
xc = GRMapX( cX ); xc = GRMapX( current_char_pos.x );
yc = GRMapY( cY ); yc = GRMapY( current_char_pos.y );
x0 = aPanel->m_ClipBox.GetX() - ll; x0 = aPanel->m_ClipBox.GetX() - ll;
y0 = aPanel->m_ClipBox.GetY() - ll; y0 = aPanel->m_ClipBox.GetY() - ll;
...@@ -185,81 +191,60 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, ...@@ -185,81 +191,60 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
} }
/* Compute the position ux0, uy0 of the first letter , next */ /* Compute the position of the first letter of the text
dx = (pitch * char_count) / 2; * this position is the position of the left bottom point of the letter
dy = size_v / 2; /* dx, dy = draw offset between first letter and text center */ * 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
ux0 = uy0 = 0; /* for ux0 = uy0 = 0, the text is centered */ */
dx = pitch * char_count;
wxPoint offset_org( dx, dy ); dy = size_v; /* dx, dy = draw offset between first letter and text center */
int irot = aOrient;
while( irot >= 1800 )
irot -= 1800;
while( irot < 0 )
irot += 1800;
if( irot != 0 )
EXCHG( offset_org.x, offset_org.y );
switch( aH_justify ) switch( aH_justify )
{ {
case GR_TEXT_HJUSTIFY_CENTER: case GR_TEXT_HJUSTIFY_CENTER:
current_char_pos.x -= dx / 2;
break; break;
case GR_TEXT_HJUSTIFY_RIGHT: case GR_TEXT_HJUSTIFY_RIGHT:
ux0 = -offset_org.x; current_char_pos.x -= dx;
break; break;
case GR_TEXT_HJUSTIFY_LEFT: case GR_TEXT_HJUSTIFY_LEFT:
ux0 = offset_org.x;
break; break;
} }
switch( aV_justify ) switch( aV_justify )
{ {
case GR_TEXT_VJUSTIFY_CENTER: case GR_TEXT_VJUSTIFY_CENTER:
current_char_pos.y += dy/2;
break; break;
case GR_TEXT_VJUSTIFY_TOP: case GR_TEXT_VJUSTIFY_TOP:
uy0 = offset_org.y; current_char_pos.y += dy;
break; break;
case GR_TEXT_VJUSTIFY_BOTTOM: case GR_TEXT_VJUSTIFY_BOTTOM:
uy0 = -offset_org.y;
break; break;
} }
cX += ux0;
cY += uy0;
ox = cX - dx;
oy = cY + dy;
// Note: if aPanel == NULL, we are using a GL Canvas that handle scaling // Note: if aPanel == NULL, we are using a GL Canvas that handle scaling
if( aPanel && aPanel->GetScreen()->Scale( aSize.x ) == 0 ) if( aPanel && aPanel->GetScreen()->Scale( aSize.x ) == 0 )
return; 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 */ /* draw the text as a line always vertically centered */
dx = (pitch * char_count) / 2; wxPoint end( current_char_pos.x + dx, current_char_pos.y);
dy = size_v / 2; /* line is always centered */
ux0 = cX - dx;
uy0 = cY;
dx += cX;
dy = cY;
RotatePoint( &ux0, &uy0, cX, cY, aOrient ); RotatePoint( &current_char_pos, aPos, aOrient );
RotatePoint( &dx, &dy, cX, cY, aOrient ); RotatePoint( &end, aPos, aOrient );
if( aCallback ) if( aCallback )
aCallback( ux0, uy0, dx, dy ); aCallback( current_char_pos.x, current_char_pos.y, end.x, end.y );
else 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; return;
} }
...@@ -278,20 +263,18 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, ...@@ -278,20 +263,18 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
if( overbars % 2 ) if( overbars % 2 )
{ {
/* Starting the overbar */ /* Starting the overbar */
overbar_x = ox; overbar_pos = current_char_pos;
overbar_y = oy - overbar_position( size_v, thickness ); overbar_pos.y -= overbar_position( size_v, thickness );
RotatePoint( &overbar_x, &overbar_y, cX, cY, aOrient ); RotatePoint( &overbar_pos, aPos, aOrient );
} }
else else
{ {
/* Ending the overbar */ /* Ending the overbar */
coord[0].x = overbar_x; coord[0] = overbar_pos;
coord[0].y = overbar_y; overbar_pos = current_char_pos;
overbar_x = ox; overbar_pos.y -= overbar_position( size_v, thickness );
overbar_y = oy - overbar_position( size_v, thickness ); RotatePoint( &overbar_pos, aPos, aOrient );
RotatePoint( &overbar_x, &overbar_y, cX, cY, aOrient ); coord[1] = overbar_pos;
coord[1].x = overbar_x;
coord[1].y = overbar_y;
/* Plot the overbar segment */ /* Plot the overbar segment */
DrawGraphicTextPline( aPanel, aDC, aColor, aWidth, DrawGraphicTextPline( aPanel, aDC, aColor, aWidth,
sketch_mode, 2, coord, aCallback ); sketch_mode, 2, coord, aCallback );
...@@ -345,6 +328,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, ...@@ -345,6 +328,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
default: default:
{ {
int y, k1, k2; int y, k1, k2;
wxPoint currpoint;
y = k1 = f_cod; /* trace sur axe V */ y = k1 = f_cod; /* trace sur axe V */
k1 = -( (k1 * size_v) / 9 ); k1 = -( (k1 * size_v) / 9 );
...@@ -357,12 +341,12 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, ...@@ -357,12 +341,12 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
// To simulate an italic font, add a x offset depending on the y offset // To simulate an italic font, add a x offset depending on the y offset
if( aItalic ) if( aItalic )
k2 -= italic_reverse ? -k1 / 8 : k1 / 8; 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 ); RotatePoint( &currpoint, aPos, aOrient );
coord[point_count].x = dx; coord[point_count] = currpoint;
coord[point_count].y = dy; if( point_count < BUF_SIZE - 1 )
if( point_count < BUF_SIZE - 1 )
point_count++; point_count++;
break; break;
} }
...@@ -373,19 +357,18 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, ...@@ -373,19 +357,18 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
/* end draw 1 char */ /* end draw 1 char */
ptr++; ox += pitch; ptr++;
current_char_pos.x += pitch; // current_char_pos is now the next position
} }
if( overbars % 2 ) if( overbars % 2 )
{ {
/* Close the last overbar */ /* Close the last overbar */
coord[0].x = overbar_x; coord[0] = overbar_pos;
coord[0].y = overbar_y; overbar_pos = current_char_pos;
overbar_x = ox; overbar_pos.y -= overbar_position( size_v, thickness );
overbar_y = oy - overbar_position( size_v, thickness ); RotatePoint( &overbar_pos, aPos, aOrient );
RotatePoint( &overbar_x, &overbar_y, cX, cY, aOrient ); coord[1] = overbar_pos;
coord[1].x = overbar_x;
coord[1].y = overbar_y;
/* Plot the overbar segment */ /* Plot the overbar segment */
DrawGraphicTextPline( aPanel, aDC, aColor, aWidth, DrawGraphicTextPline( aPanel, aDC, aColor, aWidth,
sketch_mode, 2, coord, aCallback ); sketch_mode, 2, coord, aCallback );
......
...@@ -469,8 +469,8 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, ...@@ -469,8 +469,8 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
/* Get the num and name colors */ /* Get the num and name colors */
if( (Color < 0) && (m_Selected & IS_SELECTED) ) if( (Color < 0) && (m_Selected & IS_SELECTED) )
Color = g_ItemSelectetColor; Color = g_ItemSelectetColor;
NameColor = (EDA_Colors) (Color == -1 ? ReturnLayerColor( LAYER_PINNAM ) : Color); NameColor = (EDA_Colors) ( Color == -1 ? ReturnLayerColor( LAYER_PINNAM ) : Color );
NumColor = (EDA_Colors) (Color == -1 ? ReturnLayerColor( LAYER_PINNUM ) : Color); NumColor = (EDA_Colors) ( Color == -1 ? ReturnLayerColor( LAYER_PINNUM ) : Color );
/* Create the pin num string */ /* Create the pin num string */
ReturnPinStringNum( StringPinNum ); ReturnPinStringNum( StringPinNum );
...@@ -545,41 +545,45 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, ...@@ -545,41 +545,45 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
else /* Its a vertical line. */ else /* Its a vertical line. */
{ {
// Text is drawn from bottom to top (i.e. to negative value for Y axis) // 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, DrawGraphicText( panel, DC, wxPoint( x1, y ), NameColor,
m_PinName, m_PinName,
TEXT_ORIENT_VERT, PinNameSize, TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_RIGHT,
GR_TEXT_VJUSTIFY_TOP, LineWidth, GR_TEXT_VJUSTIFY_CENTER, LineWidth,
false, true ); false, true );
} if( DrawPinNum )
else /* PIN_UP */ DrawGraphicText( panel, DC,
{ wxPoint( x1 - TXTMARGE,
y = y1 - TextInside; (y1 + pin_pos.y) / 2 ), NumColor,
StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, LineWidth );
}
else /* PIN_UP */
{
y = y1 - TextInside;
if( DrawPinName )
DrawGraphicText( panel, DC, wxPoint( x1, y ), NameColor, DrawGraphicText( panel, DC, wxPoint( x1, y ), NameColor,
m_PinName, m_PinName,
TEXT_ORIENT_VERT, PinNameSize, TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT,
GR_TEXT_VJUSTIFY_BOTTOM, LineWidth, GR_TEXT_VJUSTIFY_CENTER, LineWidth,
false, true ); false, true );
} if( DrawPinNum )
} DrawGraphicText( panel, DC,
wxPoint( x1 - TXTMARGE,
if( DrawPinNum ) (y1 + pin_pos.y) / 2 ), NumColor,
{ StringPinNum,
DrawGraphicText( panel, DC, TEXT_ORIENT_VERT, PinNumSize,
wxPoint( x1 - TXTMARGE, GR_TEXT_HJUSTIFY_CENTER,
(y1 + pin_pos.y) / 2 ), NumColor, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth );
StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_RIGHT,
GR_TEXT_VJUSTIFY_CENTER, LineWidth );
} }
} }
} }
...@@ -606,7 +610,8 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, ...@@ -606,7 +610,8 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
y1 + TXTMARGE ), y1 + TXTMARGE ),
NumColor, StringPinNum, NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize, TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_TOP,
LineWidth ); LineWidth );
} }
} }
...@@ -619,8 +624,8 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, ...@@ -619,8 +624,8 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
y ), y ),
NameColor, m_PinName, NameColor, m_PinName,
TEXT_ORIENT_VERT, PinNameSize, TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_CENTER, LineWidth, false, true ); GR_TEXT_VJUSTIFY_BOTTOM, LineWidth, false, true );
} }
if( DrawPinNum ) if( DrawPinNum )
...@@ -630,8 +635,8 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, ...@@ -630,8 +635,8 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
(y1 + pin_pos.y) / 2 ), (y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum, NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize, TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_CENTER, LineWidth ); GR_TEXT_VJUSTIFY_TOP, LineWidth );
} }
} }
} }
...@@ -667,8 +672,8 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, ...@@ -667,8 +672,8 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
&& g_PlotPSColorOpt; && g_PlotPSColorOpt;
/* Get the num and name colors */ /* Get the num and name colors */
NameColor = (EDA_Colors) (plot_color ? ReturnLayerColor( LAYER_PINNAM ) : -1); NameColor = (EDA_Colors) ( plot_color ? ReturnLayerColor( LAYER_PINNAM ) : -1 );
NumColor = (EDA_Colors) (plot_color ? ReturnLayerColor( LAYER_PINNUM ) : -1); NumColor = (EDA_Colors) ( plot_color ? ReturnLayerColor( LAYER_PINNUM ) : -1 );
/* Create the pin num string */ /* Create the pin num string */
ReturnPinStringNum( StringPinNum ); ReturnPinStringNum( StringPinNum );
...@@ -697,7 +702,7 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, ...@@ -697,7 +702,7 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
DrawPinName = FALSE; DrawPinName = FALSE;
PinTxtLen = (int) ( fPinTextPitch * PinTxtLen ); 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. */ if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) ) /* Its an horizontal line. */
{ {
...@@ -717,66 +722,74 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, ...@@ -717,66 +722,74 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
else // orient == PIN_LEFT else // orient == PIN_LEFT
{ {
x = x1 - TextInside; x = x1 - TextInside;
PlotGraphicText( g_PlotFormat, wxPoint( x, y1 ), if( DrawPinName )
NameColor, m_PinName, TEXT_ORIENT_HORIZ, PlotGraphicText( g_PlotFormat, wxPoint( x, y1 ),
PinNameSize, NameColor, m_PinName, TEXT_ORIENT_HORIZ,
GR_TEXT_HJUSTIFY_RIGHT, PinNameSize,
GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_RIGHT,
aWidth, aItalic, true ); 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. */ 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, PlotGraphicText( g_PlotFormat, wxPoint( x1, y ), NameColor,
m_PinName, m_PinName,
TEXT_ORIENT_VERT, PinNameSize, TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_RIGHT,
GR_TEXT_VJUSTIFY_TOP, GR_TEXT_VJUSTIFY_CENTER,
aWidth, aItalic, true ); aWidth, aItalic, true );
} if( DrawPinNum )
else /* PIN_UP */
{ {
y = y1 - TextInside; 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 );
}
}
else /* PIN_UP */
{
y = y1 - TextInside;
if( DrawPinName )
PlotGraphicText( g_PlotFormat, wxPoint( x1, y ), NameColor, PlotGraphicText( g_PlotFormat, wxPoint( x1, y ), NameColor,
m_PinName, m_PinName,
TEXT_ORIENT_VERT, PinNameSize, 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_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_BOTTOM,
aWidth, aItalic, true ); aWidth, aItalic );
} }
} }
if( DrawPinNum )
{
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 );
}
} }
} }
else /* Draw num & text pin outside */ else /* Draw num & text pin outside */
...@@ -801,7 +814,8 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, ...@@ -801,7 +814,8 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
PlotGraphicText( g_PlotFormat, wxPoint( x, y1 + TXTMARGE ), PlotGraphicText( g_PlotFormat, wxPoint( x, y1 + TXTMARGE ),
NumColor, StringPinNum, NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize, TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_TOP,
aWidth, aItalic ); aWidth, aItalic );
} }
} }
...@@ -814,8 +828,8 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, ...@@ -814,8 +828,8 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
y ), y ),
NameColor, m_PinName, NameColor, m_PinName,
TEXT_ORIENT_VERT, PinNameSize, TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM,
aWidth, aItalic, true ); aWidth, aItalic, true );
} }
...@@ -826,8 +840,8 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, ...@@ -826,8 +840,8 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
(y1 + pin_pos.y) / 2 ), (y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum, NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize, TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP,
aWidth, aItalic ); aWidth, aItalic );
} }
} }
...@@ -937,7 +951,7 @@ void LibDrawPin::SetPinNumFromString( wxString& buffer ) ...@@ -937,7 +951,7 @@ void LibDrawPin::SetPinNumFromString( wxString& buffer )
len = 4; len = 4;
for( ii = 0; ii < len; ii++ ) for( ii = 0; ii < len; ii++ )
{ {
ascii_buf[ii] = buffer.GetChar( ii ); ascii_buf[ii] = buffer.GetChar( ii );
ascii_buf[ii] &= 0xFF; ascii_buf[ii] &= 0xFF;
} }
......
...@@ -39,32 +39,32 @@ const char* SheetLabelType[] = ...@@ -39,32 +39,32 @@ const char* SheetLabelType[] =
* others are the corners coordinates in reduced units * others are the corners coordinates in reduced units
* the real coordinate is the reduced coordinate * text half size * 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 }; static 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 }; static 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 }; static int TemplateIN_UP[] = { 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_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 }; static 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 }; static 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 }; static int TemplateOUT_UP[] = { 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_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 }; static 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 }; static 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 }; static int TemplateUNSPC_UP[] = { 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_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 }; static 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 }; static 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 }; static int TemplateBIDI_UP[] = { 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_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 }; static 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 }; static 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 }; static int Template3STATE_UP[] = { 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_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 }, { TemplateIN_HN, TemplateIN_UP, TemplateIN_HI, TemplateIN_BOTTOM },
{ TemplateOUT_HN, TemplateOUT_UP, TemplateOUT_HI, TemplateOUT_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 ) : ...@@ -84,7 +84,8 @@ SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
m_Pos = pos; m_Pos = pos;
m_Shape = 0; m_Shape = 0;
m_IsDangling = FALSE; 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 ) : ...@@ -94,9 +95,7 @@ SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
*/ */
bool SCH_TEXT::HitTest( const wxPoint& aPosRef ) bool SCH_TEXT::HitTest( const wxPoint& aPosRef )
{ {
EDA_Rect rect = GetBoundingBox(); return EDA_TextStruct::HitTest( aPosRef );
return rect.Inside( aPosRef );
} }
...@@ -135,11 +134,292 @@ SCH_TEXT* SCH_TEXT::GenCopy() ...@@ -135,11 +134,292 @@ SCH_TEXT* SCH_TEXT::GenCopy()
newitem->m_VJustify = m_VJustify; newitem->m_VJustify = m_VJustify;
newitem->m_IsDangling = m_IsDangling; newitem->m_IsDangling = m_IsDangling;
newitem->m_Italic = m_Italic; newitem->m_Italic = m_Italic;
newitem->m_SchematicOrientation = m_SchematicOrientation;
return newitem; 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 ) void SCH_TEXT::SwapData( SCH_TEXT* copyitem )
/********************************************************/ /********************************************************/
...@@ -155,6 +435,7 @@ 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_HJustify, copyitem->m_HJustify );
EXCHG( m_VJustify, copyitem->m_VJustify ); EXCHG( m_VJustify, copyitem->m_VJustify );
EXCHG( m_IsDangling, copyitem->m_IsDangling ); 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, ...@@ -198,52 +479,16 @@ void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aOffset,
color = ReturnLayerColor( m_Layer ); color = ReturnLayerColor( m_Layer );
GRSetDrawMode( DC, DrawMode ); GRSetDrawMode( DC, DrawMode );
int orientation; wxPoint text_offset = aOffset + GetSchematicTextOffset();
wxPoint text_offset = aOffset;
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 EXCHG( width, m_Width ); // Set the minimum width
EDA_TextStruct::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR ); 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 EXCHG( width, m_Width ); // set initial value
if( m_IsDangling ) if( m_IsDangling )
DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color ); DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color );
} }
/** /**
* Function Save * Function Save
* writes the data structures for this object out to a FILE in "*.brd" format. * 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 ...@@ -257,28 +502,28 @@ bool SCH_TEXT::Save( FILE* aFile ) const
if( m_Italic ) if( m_Italic )
shape = "Italic"; shape = "Italic";
wxString text=m_Text; wxString text = m_Text;
for (;;) for( ; ; )
{ {
int i=text.find('\n'); int i = text.find( '\n' );
if (i==wxNOT_FOUND) if( i==wxNOT_FOUND )
break; break;
text.erase(i,1); text.erase( i, 1 );
text.insert(i,_("\\n")); text.insert( i, _( "\\n" ) );
} }
if( fprintf( aFile, "Text Notes %-4d %-4d %-4d %-4d %s %d\n%s\n", if( fprintf( aFile, "Text Notes %-4d %-4d %-4d %-4d %s %d\n%s\n",
m_Pos.x, m_Pos.y, m_Pos.x, m_Pos.y,
m_Orient, m_Size.x, m_SchematicOrientation, m_Size.x,
shape, m_Width, shape, m_Width,
CONV_TO_UTF8( text ) ) == EOF ) CONV_TO_UTF8( text ) ) == EOF )
{ {
success = false; success = false;
} }
return success; return success;
} }
...@@ -310,6 +555,7 @@ SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) : ...@@ -310,6 +555,7 @@ SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) :
m_Layer = LAYER_LOCLABEL; m_Layer = LAYER_LOCLABEL;
m_Shape = NET_INPUT; m_Shape = NET_INPUT;
m_IsDangling = TRUE; m_IsDangling = TRUE;
m_MultilineAllowed = false;
} }
...@@ -329,7 +575,7 @@ bool SCH_LABEL::Save( FILE* aFile ) const ...@@ -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", if( fprintf( aFile, "Text Label %-4d %-4d %-4d %-4d %s %d\n%s\n",
m_Pos.x, m_Pos.y, 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 ) CONV_TO_UTF8( m_Text ) ) == EOF )
{ {
success = false; success = false;
...@@ -347,6 +593,7 @@ SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) : ...@@ -347,6 +593,7 @@ SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) :
m_Layer = LAYER_GLOBLABEL; m_Layer = LAYER_GLOBLABEL;
m_Shape = NET_BIDI; m_Shape = NET_BIDI;
m_IsDangling = TRUE; m_IsDangling = TRUE;
m_MultilineAllowed = false;
} }
...@@ -365,7 +612,7 @@ bool SCH_GLOBALLABEL::Save( FILE* aFile ) const ...@@ -365,7 +612,7 @@ bool SCH_GLOBALLABEL::Save( FILE* aFile ) const
shape = "Italic"; shape = "Italic";
if( fprintf( aFile, "Text GLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n", if( fprintf( aFile, "Text GLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n",
m_Pos.x, m_Pos.y, m_Pos.x, m_Pos.y,
m_Orient, m_Size.x, m_SchematicOrientation, m_Size.x,
SheetLabelType[m_Shape], SheetLabelType[m_Shape],
shape, m_Width, shape, m_Width,
CONV_TO_UTF8( m_Text ) ) == EOF ) CONV_TO_UTF8( m_Text ) ) == EOF )
...@@ -400,6 +647,7 @@ SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text ) : ...@@ -400,6 +647,7 @@ SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text ) :
m_Layer = LAYER_HIERLABEL; m_Layer = LAYER_HIERLABEL;
m_Shape = NET_INPUT; m_Shape = NET_INPUT;
m_IsDangling = TRUE; m_IsDangling = TRUE;
m_MultilineAllowed = false;
} }
...@@ -418,7 +666,7 @@ bool SCH_HIERLABEL::Save( FILE* aFile ) const ...@@ -418,7 +666,7 @@ bool SCH_HIERLABEL::Save( FILE* aFile ) const
shape = "Italic"; shape = "Italic";
if( fprintf( aFile, "Text HLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n", if( fprintf( aFile, "Text HLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n",
m_Pos.x, m_Pos.y, m_Pos.x, m_Pos.y,
m_Orient, m_Size.x, m_SchematicOrientation, m_Size.x,
SheetLabelType[m_Shape], SheetLabelType[m_Shape],
shape, m_Width, shape, m_Width,
CONV_TO_UTF8( m_Text ) ) == EOF ) CONV_TO_UTF8( m_Text ) ) == EOF )
...@@ -463,9 +711,8 @@ void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offs ...@@ -463,9 +711,8 @@ void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offs
*/ */
{ {
static std::vector <wxPoint> Poly; static std::vector <wxPoint> Poly;
int ii;
EDA_Colors color; EDA_Colors color;
wxPoint AnchorPos = m_Pos + offset; wxPoint text_offset = offset + GetSchematicTextOffset();
int width = MAX( m_Width, g_DrawMinimunLineWidth ); int width = MAX( m_Width, g_DrawMinimunLineWidth );
...@@ -476,40 +723,11 @@ void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offs ...@@ -476,40 +723,11 @@ void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offs
GRSetDrawMode( DC, DrawMode ); 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 );
switch( m_Orient ) EXCHG( width, m_Width ); // set initial value
{
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 ); GRPoly( &panel->m_ClipBox, DC, Poly.size(), &Poly[0], 0, width, color, color );
if( m_IsDangling ) if( m_IsDangling )
...@@ -517,17 +735,14 @@ void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offs ...@@ -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 * 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 * @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 ) 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 HalfSize = m_Size.x / 2;
int imax = *Template; Template++; int imax = *Template; Template++;
...@@ -559,11 +774,13 @@ EDA_Rect SCH_HIERLABEL::GetBoundingBox() ...@@ -559,11 +774,13 @@ EDA_Rect SCH_HIERLABEL::GetBoundingBox()
int width = MAX( m_Width, g_DrawMinimunLineWidth ); int width = MAX( m_Width, g_DrawMinimunLineWidth );
height = m_Size.y + 2 * TXTMARGE; 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; dx = -length;
dy = height; dy = height;
x += DANGLING_SYMBOL_SIZE; x += DANGLING_SYMBOL_SIZE;
...@@ -572,9 +789,9 @@ EDA_Rect SCH_HIERLABEL::GetBoundingBox() ...@@ -572,9 +789,9 @@ EDA_Rect SCH_HIERLABEL::GetBoundingBox()
case 1: /* Vert Orientation UP */ case 1: /* Vert Orientation UP */
dx = height; dx = height;
dy = length; dy = -length;
x -= height / 2; x -= height / 2;
y -= DANGLING_SYMBOL_SIZE; y += DANGLING_SYMBOL_SIZE;
break; break;
case 2: /* Horiz Orientation - Right justified */ case 2: /* Horiz Orientation - Right justified */
...@@ -586,9 +803,9 @@ EDA_Rect SCH_HIERLABEL::GetBoundingBox() ...@@ -586,9 +803,9 @@ EDA_Rect SCH_HIERLABEL::GetBoundingBox()
case 3: /* Vert Orientation BOTTOM */ case 3: /* Vert Orientation BOTTOM */
dx = height; dx = height;
dy = -length; dy = length;
x -= height / 2; x -= height / 2;
y += DANGLING_SYMBOL_SIZE; y -= DANGLING_SYMBOL_SIZE;
break; break;
} }
...@@ -599,7 +816,7 @@ EDA_Rect SCH_HIERLABEL::GetBoundingBox() ...@@ -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 ) int DrawMode, int Color )
/******************************************************************************************/ /******************************************************************************************/
...@@ -607,10 +824,8 @@ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& dr ...@@ -607,10 +824,8 @@ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& dr
*/ */
{ {
static std::vector <wxPoint> Poly; static std::vector <wxPoint> Poly;
int offset;
EDA_Colors color; EDA_Colors color;
int HalfSize; wxPoint text_offset = aOffset + GetSchematicTextOffset();
wxPoint AnchorPos = m_Pos + draw_offset;;
int width = MAX( m_Width, g_DrawMinimunLineWidth ); int width = MAX( m_Width, g_DrawMinimunLineWidth );
...@@ -621,67 +836,21 @@ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& dr ...@@ -621,67 +836,21 @@ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& dr
GRSetDrawMode( DC, DrawMode ); GRSetDrawMode( DC, DrawMode );
HalfSize = m_Size.x / 2; EXCHG( width, m_Width ); // Set the minimum width
offset = 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 ); GRPoly( &panel->m_ClipBox, DC, Poly.size(), &Poly[0], 0, width, color, color );
if( m_IsDangling ) if( m_IsDangling )
DrawDanglingSymbol( panel, DC, AnchorPos, color ); DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color );
} }
/** function CreateGraphicShape /** function CreateGraphicShape
* Calculates the graphic shape (a polygon) associated to the text * 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 * @param Pos = Position of the shape
*/ */
void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint& Pos ) 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 ...@@ -730,13 +899,13 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, c
int angle = 0; int angle = 0;
switch( m_Orient ) switch( m_SchematicOrientation )
{ {
case 0: /* Orientation horiz normale */ case 0: /* Orientation horiz normale */
break; break;
case 1: /* Orientation vert UP */ case 1: /* Orientation vert UP */
angle = 900; angle = -900;
break; break;
case 2: /* Orientation horiz inverse */ case 2: /* Orientation horiz inverse */
...@@ -744,12 +913,12 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, c ...@@ -744,12 +913,12 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, c
break; break;
case 3: /* Orientation vert BOTTOM */ case 3: /* Orientation vert BOTTOM */
angle = -900; angle = 900;
break; break;
} }
// Rotate outlines and move corners in real position // 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; aCorner_list[ii].x += x_offset;
if( angle ) if( angle )
...@@ -772,13 +941,15 @@ EDA_Rect SCH_GLOBALLABEL::GetBoundingBox() ...@@ -772,13 +941,15 @@ EDA_Rect SCH_GLOBALLABEL::GetBoundingBox()
dx = dy = 0; dx = dy = 0;
int width = MAX( m_Width, g_DrawMinimunLineWidth ); int width = MAX( m_Width, g_DrawMinimunLineWidth );
height = m_Size.y + 2 * TXTMARGE; height = ( (m_Size.y * 15) / 10 ) + width + 2 * TXTMARGE;
length = 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; dx = -length;
dy = height; dy = height;
x += DANGLING_SYMBOL_SIZE; x += DANGLING_SYMBOL_SIZE;
...@@ -787,9 +958,9 @@ EDA_Rect SCH_GLOBALLABEL::GetBoundingBox() ...@@ -787,9 +958,9 @@ EDA_Rect SCH_GLOBALLABEL::GetBoundingBox()
case 1: /* Vert Orientation UP */ case 1: /* Vert Orientation UP */
dx = height; dx = height;
dy = length; dy = -length;
x -= height / 2; x -= height / 2;
y -= DANGLING_SYMBOL_SIZE; y += DANGLING_SYMBOL_SIZE;
break; break;
case 2: /* Horiz Orientation - Right justified */ case 2: /* Horiz Orientation - Right justified */
...@@ -801,9 +972,9 @@ EDA_Rect SCH_GLOBALLABEL::GetBoundingBox() ...@@ -801,9 +972,9 @@ EDA_Rect SCH_GLOBALLABEL::GetBoundingBox()
case 3: /* Vert Orientation BOTTOM */ case 3: /* Vert Orientation BOTTOM */
dx = height; dx = height;
dy = -length; dy = length;
x -= height / 2; x -= height / 2;
y += DANGLING_SYMBOL_SIZE; y -= DANGLING_SYMBOL_SIZE;
break; break;
} }
...@@ -826,7 +997,7 @@ EDA_Rect SCH_TEXT::GetBoundingBox() ...@@ -826,7 +997,7 @@ EDA_Rect SCH_TEXT::GetBoundingBox()
height = m_Size.y; height = m_Size.y;
dx = dy = 0; dx = dy = 0;
switch( m_Orient ) // respect orientation switch( m_SchematicOrientation )
{ {
case 0: /* Horiz Normal Orientation (left justified) */ case 0: /* Horiz Normal Orientation (left justified) */
dx = 2 * DANGLING_SYMBOL_SIZE + length; dx = 2 * DANGLING_SYMBOL_SIZE + length;
......
...@@ -8,33 +8,42 @@ ...@@ -8,33 +8,42 @@
#include "macros.h" #include "macros.h"
#include "base_struct.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 { typedef enum {
NET_INPUT, NET_INPUT,
NET_OUTPUT, NET_OUTPUT,
NET_BIDI, NET_BIDI,
NET_TRISTATE, NET_TRISTATE,
NET_UNSPECIFIED, NET_UNSPECIFIED,
NET_TMAX /* Derniere valeur: fin de tableau */ NET_TMAX /* Last value */
} TypeSheetLabel; } TypeSheetLabel;
/* Messages correspondants aux types ou forme des labels */
extern const char* SheetLabelType[];
extern int* TemplateShape[5][4];
class SCH_TEXT : public SCH_ITEM extern const char* SheetLabelType[]; /* names of types of labels */
, public EDA_TextStruct
{
class SCH_TEXT : public SCH_ITEM,
public EDA_TextStruct
{
public: public:
int m_Layer; int m_Layer;
int m_Shape; 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: public:
SCH_TEXT( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString, 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() { } ~SCH_TEXT() { }
virtual wxString GetClass() const virtual wxString GetClass() const
...@@ -43,21 +52,42 @@ public: ...@@ -43,21 +52,42 @@ public:
} }
SCH_TEXT* GenCopy(); /** function SetTextOrientAndJustifyParmeters
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode, * Set m_SchematicOrientation, and initialize
int Color = -1 ); * 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 );
int GetSchematicTextOrientation() { return m_SchematicOrientation;}
/** 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 SwapData( SCH_TEXT* copyitem );
void Place( WinEDA_SchematicFrame* frame, wxDC* DC ); void Place( WinEDA_SchematicFrame* frame, wxDC* DC );
/** Function HitTest /** Function HitTest
* @return true if the point aPosRef is within item area * @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test * @param aPosRef = a wxPoint to test
*/ */
bool HitTest( const wxPoint& aPosRef ); bool HitTest( const wxPoint& aPosRef );
EDA_Rect GetBoundingBox(); EDA_Rect GetBoundingBox();
/** /**
* Function Save * Function Save
...@@ -65,15 +95,12 @@ public: ...@@ -65,15 +95,12 @@ public:
* @param aFile The FILE to write to. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ); void Show( int nestLevel, std::ostream& os );
#endif #endif
}; };
...@@ -82,21 +109,41 @@ class SCH_LABEL : public SCH_TEXT ...@@ -82,21 +109,41 @@ class SCH_LABEL : public SCH_TEXT
public: public:
SCH_LABEL( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString ); SCH_LABEL( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString );
~SCH_LABEL() { } ~SCH_LABEL() { }
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode, virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode,
int Color = -1 ); int Color = -1 );
virtual wxString GetClass() const virtual wxString GetClass() const
{ {
return wxT( "SCH_LABEL" ); 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 * Function Save
* writes the data structures for this object out to a FILE in "*.brd" format. * writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @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 ...@@ -104,10 +151,10 @@ class SCH_GLOBALLABEL : public SCH_TEXT
{ {
public: public:
SCH_GLOBALLABEL( const wxPoint& pos = wxPoint( 0, 0 ), SCH_GLOBALLABEL( const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString ); const wxString& text = wxEmptyString );
~SCH_GLOBALLABEL() { } ~SCH_GLOBALLABEL() { }
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode, virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode,
int Color = -1 ); int Color = -1 );
virtual wxString GetClass() const virtual wxString GetClass() const
{ {
...@@ -115,43 +162,58 @@ public: ...@@ -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 * Function Save
* writes the data structures for this object out to a FILE in "*.brd" format. * writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
/** Function HitTest /** Function HitTest
* @return true if the point aPosRef is within item area * @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test * @param aPosRef = a wxPoint to test
*/ */
bool HitTest( const wxPoint& aPosRef ); bool HitTest( const wxPoint& aPosRef );
EDA_Rect GetBoundingBox(); EDA_Rect GetBoundingBox();
/** function CreateGraphicShape /** function CreateGraphicShape
* Calculates the graphic shape (a polygon) associated to the text * Calculates the graphic shape (a polygon) associated to the text
* @param aCorner_list = coordinates list fill with polygon corners ooordinates * @param aCorner_list = a buffer to fill with polygon corners coordinates
* @param Pos = Postion of the shape * @param Pos = Position of the shape
* format list is
* <corner_count>, x0, y0, ... xn, yn
*/ */
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 class SCH_HIERLABEL : public SCH_TEXT
{ {
public: public:
SCH_HIERLABEL( const wxPoint& pos = wxPoint( 0, 0 ), SCH_HIERLABEL( const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString ); const wxString& text = wxEmptyString );
~SCH_HIERLABEL() { } ~SCH_HIERLABEL() { }
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode, virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode,
int Color = -1 ); int Color = -1 );
virtual wxString GetClass() const virtual wxString GetClass() const
{ {
...@@ -159,14 +221,31 @@ public: ...@@ -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 /** function CreateGraphicShape
* Calculates the graphic shape (a polygon) associated to the text * Calculates the graphic shape (a polygon) associated to the text
* @param aCorner_list = coordinates list fill with polygon corners ooordinates * @param aCorner_list = a buffer to fill with polygon corners coordinates
* @param Pos = Postion of the shape * @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 );
*/
void CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint & Pos );
/** /**
* Function Save * Function Save
...@@ -174,15 +253,15 @@ public: ...@@ -174,15 +253,15 @@ public:
* @param aFile The FILE to write to. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
/** Function HitTest /** Function HitTest
* @return true if the point aPosRef is within item area * @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test * @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 */ #endif /* CLASS_TEXT_LABEL_H */
...@@ -21,21 +21,8 @@ ...@@ -21,21 +21,8 @@
int DialogLabelEditor::ShowModally( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText ) int DialogLabelEditor::ShowModally( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText )
{ {
int ret; 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 ); DialogLabelEditor* dialog = new DialogLabelEditor( parent, CurrentText, multiline );
// doing any post construction resizing is better done here than in // doing any post construction resizing is better done here than in
...@@ -97,7 +84,7 @@ void DialogLabelEditor::init() ...@@ -97,7 +84,7 @@ void DialogLabelEditor::init()
EnsureTextCtrlWidth( m_TextLabel ); EnsureTextCtrlWidth( m_TextLabel );
// Set validators // Set validators
m_TextOrient->SetSelection( m_CurrentText->m_Orient ); m_TextOrient->SetSelection( m_CurrentText->GetSchematicTextOrientation() );
m_TextShape->SetSelection( m_CurrentText->m_Shape ); m_TextShape->SetSelection( m_CurrentText->m_Shape );
int style = 0; int style = 0;
......
...@@ -525,6 +525,13 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel() ...@@ -525,6 +525,13 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
else else
m_FieldHJustifyCtrl->SetSelection(1); 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 ); fieldNameTextCtrl->SetValue( field.m_Name );
// if fieldNdx == REFERENCE, VALUE, FOOTPRINT, or DATASHEET, then disable filed name editing // if fieldNdx == REFERENCE, VALUE, FOOTPRINT, or DATASHEET, then disable filed name editing
...@@ -605,16 +612,7 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField() ...@@ -605,16 +612,7 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField()
field.m_HJustify = hjustify[m_FieldHJustifyCtrl->GetSelection()]; field.m_HJustify = hjustify[m_FieldHJustifyCtrl->GetSelection()];
field.m_VJustify = vjustify[m_FieldVJustifyCtrl->GetSelection()]; field.m_VJustify = vjustify[m_FieldVJustifyCtrl->GetSelection()];
if( field.m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM ) /* Void fields texts for REFERENCE and VALUE (value is the name of the component in lib ! ) are not allowed
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
* change them only for a new non void value * change them only for a new non void value
*/ */
if( !fieldValueTextCtrl->GetValue().IsEmpty() || fieldNdx > VALUE ) if( !fieldValueTextCtrl->GetValue().IsEmpty() || fieldNdx > VALUE )
......
...@@ -47,7 +47,7 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event ) ...@@ -47,7 +47,7 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event )
else if( (m_CurrentText->m_Flags & IS_NEW) == 0 ) else if( (m_CurrentText->m_Flags & IS_NEW) == 0 )
DisplayError( this, _( "Empty Text!" ) ); DisplayError( this, _( "Empty Text!" ) );
m_CurrentText->m_Orient = m_TextOrient->GetSelection(); m_CurrentText->SetSchematicTextOrientation( m_TextOrient->GetSelection() );
text = m_TextSize->GetValue(); text = m_TextSize->GetValue();
value = ReturnValueFromString( g_UnitMetric, text, m_Parent->m_InternalUnits ); value = ReturnValueFromString( g_UnitMetric, text, m_Parent->m_InternalUnits );
m_CurrentText->m_Size.x = m_CurrentText->m_Size.y = value; m_CurrentText->m_Size.x = m_CurrentText->m_Size.y = value;
...@@ -101,7 +101,7 @@ void WinEDA_SchematicFrame::StartMoveTexte( SCH_TEXT* TextStruct, wxDC* DC ) ...@@ -101,7 +101,7 @@ void WinEDA_SchematicFrame::StartMoveTexte( SCH_TEXT* TextStruct, wxDC* DC )
case TYPE_SCH_TEXT: case TYPE_SCH_TEXT:
ItemInitialPosition = TextStruct->m_Pos; ItemInitialPosition = TextStruct->m_Pos;
OldSize = TextStruct->m_Size; OldSize = TextStruct->m_Size;
OldOrient = TextStruct->m_Orient; OldOrient = TextStruct->GetSchematicTextOrientation();
break; break;
default: default:
...@@ -163,14 +163,16 @@ void WinEDA_SchematicFrame::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC ) ...@@ -163,14 +163,16 @@ void WinEDA_SchematicFrame::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC )
RedrawOneStruct( DrawPanel, DC, TextStruct, g_XorMode ); RedrawOneStruct( DrawPanel, DC, TextStruct, g_XorMode );
/* Rotation du texte */ /* Rotation du texte */
int orient;
switch( TextStruct->Type() ) switch( TextStruct->Type() )
{ {
case TYPE_SCH_LABEL: case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL: case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL: case TYPE_SCH_HIERLABEL:
case TYPE_SCH_TEXT: case TYPE_SCH_TEXT:
TextStruct->m_Orient++; orient = TextStruct->GetSchematicTextOrientation() + 1;
TextStruct->m_Orient &= 3; orient &= 3;
TextStruct->SetSchematicTextOrientation( orient );
break; break;
default: default:
...@@ -209,13 +211,13 @@ SCH_TEXT* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type ) ...@@ -209,13 +211,13 @@ SCH_TEXT* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type )
case LAYER_HIERLABEL: case LAYER_HIERLABEL:
NewText = new SCH_HIERLABEL( GetScreen()->m_Curseur ); NewText = new SCH_HIERLABEL( GetScreen()->m_Curseur );
NewText->m_Shape = s_DefaultShapeGLabel; NewText->m_Shape = s_DefaultShapeGLabel;
NewText->m_Orient = s_DefaultOrientGLabel; NewText->SetSchematicTextOrientation( s_DefaultOrientGLabel );
break; break;
case LAYER_GLOBLABEL: case LAYER_GLOBLABEL:
NewText = new SCH_GLOBALLABEL( GetScreen()->m_Curseur ); NewText = new SCH_GLOBALLABEL( GetScreen()->m_Curseur );
NewText->m_Shape = s_DefaultShapeGLabel; NewText->m_Shape = s_DefaultShapeGLabel;
NewText->m_Orient = s_DefaultOrientGLabel; NewText->SetSchematicTextOrientation( s_DefaultOrientGLabel );
break; break;
default: default:
...@@ -238,7 +240,7 @@ SCH_TEXT* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type ) ...@@ -238,7 +240,7 @@ SCH_TEXT* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type )
if( type == LAYER_GLOBLABEL || type == LAYER_HIERLABEL ) if( type == LAYER_GLOBLABEL || type == LAYER_HIERLABEL )
{ {
s_DefaultShapeGLabel = NewText->m_Shape; s_DefaultShapeGLabel = NewText->m_Shape;
s_DefaultOrientGLabel = NewText->m_Orient; s_DefaultOrientGLabel = NewText->GetSchematicTextOrientation();
} }
RedrawOneStruct( DrawPanel, DC, NewText, GR_DEFAULT_DRAWMODE ); RedrawOneStruct( DrawPanel, DC, NewText, GR_DEFAULT_DRAWMODE );
...@@ -317,7 +319,7 @@ static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -317,7 +319,7 @@ static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC )
SCH_TEXT* Text = (SCH_TEXT*) Struct; SCH_TEXT* Text = (SCH_TEXT*) Struct;
Text->m_Pos = ItemInitialPosition; Text->m_Pos = ItemInitialPosition;
Text->m_Size = OldSize; Text->m_Size = OldSize;
Text->m_Orient = OldOrient; Text->SetSchematicTextOrientation( OldOrient );
} }
break; break;
...@@ -372,11 +374,9 @@ void WinEDA_SchematicFrame::ConvertTextType( SCH_TEXT* Text, ...@@ -372,11 +374,9 @@ void WinEDA_SchematicFrame::ConvertTextType( SCH_TEXT* Text,
/* copy the old text settings */ /* copy the old text settings */
newtext->m_Shape = Text->m_Shape; newtext->m_Shape = Text->m_Shape;
newtext->m_Orient = Text->m_Orient; newtext->SetSchematicTextOrientation( Text->GetSchematicTextOrientation() );
newtext->m_Size = Text->m_Size; newtext->m_Size = Text->m_Size;
newtext->m_Width = Text->m_Width; newtext->m_Width = Text->m_Width;
newtext->m_HJustify = Text->m_HJustify;
newtext->m_VJustify = Text->m_VJustify;
newtext->m_IsDangling = Text->m_IsDangling; newtext->m_IsDangling = Text->m_IsDangling;
// save current text flag: // save current text flag:
......
...@@ -311,11 +311,10 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, ...@@ -311,11 +311,10 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
break; break;
} }
case TYPE_SCH_LABEL:
case TYPE_SCH_TEXT: case TYPE_SCH_TEXT:
#undef STRUCT #undef STRUCT
#define STRUCT ( (SCH_TEXT*) DrawList ) #define STRUCT ( (SCH_TEXT*) DrawList )
if( !( SearchMask & (TEXTITEM | LABELITEM) ) ) if( !( SearchMask & TEXTITEM) )
break; break;
if( STRUCT->HitTest( aPosRef ) ) if( STRUCT->HitTest( aPosRef ) )
{ {
...@@ -325,21 +324,11 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, ...@@ -325,21 +324,11 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
break; break;
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL: 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: case TYPE_SCH_HIERLABEL:
#undef STRUCT #undef STRUCT
#define STRUCT ( (SCH_HIERLABEL*) DrawList ) #define STRUCT ( (SCH_TEXT*) DrawList ) // SCH_TEXT is the base class of these labels
if( !(SearchMask & LABELITEM) ) if( !(SearchMask & LABELITEM) )
break; break;
if( STRUCT->HitTest( aPosRef ) ) if( STRUCT->HitTest( aPosRef ) )
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "grfonte.h" #include "grfonte.h"
#include "base_struct.h" #include "base_struct.h"
#include "drawtxt.h" #include "drawtxt.h"
#include "trigo.h"
#include "program.h" #include "program.h"
#include "libcmp.h" #include "libcmp.h"
...@@ -20,7 +21,7 @@ ...@@ -20,7 +21,7 @@
static void Plot_Hierarchical_PIN_Sheet( Hierarchical_PIN_Sheet_Struct* Struct ); static void Plot_Hierarchical_PIN_Sheet( Hierarchical_PIN_Sheet_Struct* Struct );
static void PlotTextField( SCH_COMPONENT* DrawLibItem, static void PlotTextField( SCH_COMPONENT* DrawLibItem,
int FieldNumber, int IsMulti, int DrawMode ); 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 ) ...@@ -29,8 +30,8 @@ static void PlotPinSymbol( const wxPoint & pos, int len, int orient, int Shape )
#define NOFILL false #define NOFILL false
/* routine de lever ou baisser de plume. /* routine de lever ou baisser de plume.
* si plume = 'U' 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 * si plume = 'D' les traces suivants se feront plume levee
*/ */
void Plume( int plume ) void Plume( int plume )
{ {
...@@ -69,6 +70,7 @@ void SetCurrentLineWidth( int width ) ...@@ -69,6 +70,7 @@ void SetCurrentLineWidth( int width )
} }
} }
/*******************************************************************************/ /*******************************************************************************/
void PlotRect( wxPoint p1, wxPoint p2, int fill, 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 ) ...@@ -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 ) void PlotArc( wxPoint aCentre, int aStAngle, int aEndAngle, int aRadius, bool aFill, int aWidth )
/*****************************************************************************************/ /*****************************************************************************************/
/** Function PlotArc /** Function PlotArc
* Plot an arc: * Plot an arc:
* @param aCentre = Arc centre * @param aCentre = Arc centre
* @param aStAngle = begining of arc in 0.1 degrees * @param aStAngle = begining of arc in 0.1 degrees
* @param aEndAngle = end of arc in 0.1 degrees * @param aEndAngle = end of arc in 0.1 degrees
* @param aRadius = Arc radius * @param aRadius = Arc radius
* @param aFill = fill option * @param aFill = fill option
* @param aWidth = Tickness of outlines * @param aWidth = Tickness of outlines
*/ */
{ {
switch( g_PlotFormat ) switch( g_PlotFormat )
...@@ -134,9 +137,9 @@ void PlotPoly( int nb, int* coord, bool fill, int width ) ...@@ -134,9 +137,9 @@ void PlotPoly( int nb, int* coord, bool fill, int width )
/******************************************************************/ /******************************************************************/
/* Trace un polygone ferme /* Trace un polygone ferme
* coord = tableau des coord des sommets * coord = tableau des coord des sommets
* nb = nombre de coord ( 1 coord = 2 elements: X et Y du tableau ) * nb = nombre de coord ( 1 coord = 2 elements: X et Y du tableau )
* fill : si != 0 polygone rempli * fill : si != 0 polygone rempli
*/ */
{ {
if( nb <= 1 ) if( nb <= 1 )
...@@ -181,7 +184,7 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem ) ...@@ -181,7 +184,7 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
/*************************************************/ /*************************************************/
/* Polt a component */ /* Polt a component */
{ {
int ii, t1, t2, * Poly, orient; int ii, t1, t2, * Poly, orient;
LibEDA_BaseStruct* DEntry; LibEDA_BaseStruct* DEntry;
EDA_LibComponentStruct* Entry; EDA_LibComponentStruct* Entry;
int TransMat[2][2], Multi, convert; int TransMat[2][2], Multi, convert;
...@@ -214,122 +217,131 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem ) ...@@ -214,122 +217,131 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
switch( DEntry->Type() ) switch( DEntry->Type() )
{ {
case COMPONENT_ARC_DRAW_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; SetColorMapPS( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
t1 = Arc->t1; t2 = Arc->t2; PlotArc( pos, t1, t2, Arc->m_Rayon, true, 0 );
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 );
} }
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: 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; SetColorMapPS( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
pos = TransformCoordinate( TransMat, Circle->m_Pos ) + DrawLibItem->m_Pos; PlotCercle( pos, Circle->m_Rayon * 2, true, 0 );
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 );
} }
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: case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
{ {
LibDrawText* Text = (LibDrawText*) DEntry; LibDrawText* Text = (LibDrawText*) DEntry;
/* The text orientation may need to be flipped if the /* The text orientation may need to be flipped if the
* transformation matrix causes xy axes to be flipped. */ * transformation matrix causes xy axes to be flipped. */
t1 = (TransMat[0][0] != 0) ^ (Text->m_Orient != 0); t1 = (TransMat[0][0] != 0) ^ (Text->m_Orient != 0);
pos = TransformCoordinate( TransMat, Text->m_Pos ) + DrawLibItem->m_Pos; pos = TransformCoordinate( TransMat, Text->m_Pos ) + DrawLibItem->m_Pos;
SetCurrentLineWidth( -1 ); SetCurrentLineWidth( -1 );
int thickness = Text->m_Width; int thickness = Text->m_Width;
if( thickness == 0 ) // if( thickness == 0 ) //
thickness = MAX( g_PlotLine_Width, g_DrawMinimunLineWidth ); thickness = MAX( g_PlotLine_Width, g_DrawMinimunLineWidth );
PlotGraphicText( g_PlotFormat, pos, CharColor, PlotGraphicText( g_PlotFormat, pos, CharColor,
Text->m_Text, Text->m_Text,
t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT, t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT,
Text->m_Size, Text->m_Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
thickness, false, true); thickness, false, true );
} }
break; break;
case COMPONENT_RECT_DRAW_TYPE: 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;
if( draw_bgfill && Square->m_Fill == FILLED_WITH_BG_BODYCOLOR )
{ {
LibDrawSquare* Square = (LibDrawSquare*) DEntry; SetColorMapPS( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
pos = TransformCoordinate( TransMat, Square->m_Pos ) + DrawLibItem->m_Pos; PlotRect( pos, end, true, 0 );
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 );
} }
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 */ case COMPONENT_PIN_DRAW_TYPE: /* Trace des Pins */
{
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;
/* 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++ )
{ {
LibDrawPin* Pin = (LibDrawPin*) DEntry; pos = polyline->m_PolyPoints[ii];
if( Pin->m_Attributs & PINNOTDRAW ) pos = TransformCoordinate( TransMat, pos ) + DrawLibItem->m_Pos;
break; Poly[ii * 2] = pos.x;
Poly[ii * 2 + 1] = pos.y;
/* 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;
case COMPONENT_POLYLINE_DRAW_TYPE: if( draw_bgfill && polyline->m_Fill == FILLED_WITH_BG_BODYCOLOR )
{ {
LibDrawPolyline* polyline = (LibDrawPolyline*) DEntry; SetColorMapPS( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
Poly = (int*) MyMalloc( sizeof(int) * 2 * polyline->GetCornerCount() ); PlotPoly( ii, Poly, true, 0 );
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 );
} }
break; 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: default:
D(printf("Drawing Type=%d\n", DEntry->Type() )) ; D( printf( "Drawing Type=%d\n", DEntry->Type() ) );
} }
/* Fin Switch */ /* Fin Switch */
...@@ -339,8 +351,8 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem ) ...@@ -339,8 +351,8 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
/* Fin Boucle de dessin */ /* Fin Boucle de dessin */
/* Trace des champs, avec placement et orientation selon orient. du /* Trace des champs, avec placement et orientation selon orient. du
* composant * composant
* Si la reference commence par # elle n'est pas tracee * Si la reference commence par # elle n'est pas tracee
*/ */
if( (Entry->m_Prefix.m_Attributs & TEXT_NO_VISIBLE) == 0 ) if( (Entry->m_Prefix.m_Attributs & TEXT_NO_VISIBLE) == 0 )
...@@ -367,20 +379,20 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem, ...@@ -367,20 +379,20 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem,
/**************************************************************/ /**************************************************************/
/* Routine de trace des textes type Field du composant. /* Routine de trace des textes type Field du composant.
* entree: * entree:
* DrawLibItem: pointeur sur le composant * DrawLibItem: pointeur sur le composant
* FieldNumber: Numero du champ * FieldNumber: Numero du champ
* IsMulti: flag Non Null si il y a plusieurs parts par boitier. * 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 * n'est utile que pour le champ reference pour ajouter a celui ci
* l'identification de la part ( A, B ... ) * l'identification de la part ( A, B ... )
* DrawMode: mode de trace * DrawMode: mode de trace
*/ */
{ {
wxPoint textpos; /* Position des textes */ wxPoint textpos; /* Position des textes */
SCH_CMP_FIELD* field = DrawLibItem->GetField( FieldNumber ); SCH_CMP_FIELD* field = DrawLibItem->GetField( FieldNumber );
int orient; int orient;
EDA_Colors color = UNSPECIFIED_COLOR; EDA_Colors color = UNSPECIFIED_COLOR;
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt ) if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
color = ReturnLayerColor( field->GetLayer() ); color = ReturnLayerColor( field->GetLayer() );
...@@ -392,9 +404,9 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem, ...@@ -392,9 +404,9 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem,
return; return;
/* Calcul de la position des textes, selon orientation du composant */ /* Calcul de la position des textes, selon orientation du composant */
orient = field->m_Orient; orient = field->m_Orient;
GRTextHorizJustifyType hjustify = field->m_HJustify; 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 = 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; textpos = TransformCoordinate( DrawLibItem->m_Transform, textpos ) + DrawLibItem->m_Pos;
...@@ -412,62 +424,74 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem, ...@@ -412,62 +424,74 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem,
vjustify = (GRTextVertJustifyType) tmp; vjustify = (GRTextVertJustifyType) tmp;
if( DrawLibItem->m_Transform[1][0] < 0 ) if( DrawLibItem->m_Transform[1][0] < 0 )
switch ( vjustify ) switch( vjustify )
{ {
case GR_TEXT_VJUSTIFY_BOTTOM: case GR_TEXT_VJUSTIFY_BOTTOM:
vjustify = GR_TEXT_VJUSTIFY_TOP; vjustify = GR_TEXT_VJUSTIFY_TOP;
break; break;
case GR_TEXT_VJUSTIFY_TOP:
vjustify = GR_TEXT_VJUSTIFY_BOTTOM; case GR_TEXT_VJUSTIFY_TOP:
break; vjustify = GR_TEXT_VJUSTIFY_BOTTOM;
default: break;
break;
default:
break;
} }
if( DrawLibItem->m_Transform[1][0] > 0 ) if( DrawLibItem->m_Transform[1][0] > 0 )
switch ( hjustify ) switch( hjustify )
{ {
case GR_TEXT_HJUSTIFY_LEFT: case GR_TEXT_HJUSTIFY_LEFT:
hjustify = GR_TEXT_HJUSTIFY_RIGHT; hjustify = GR_TEXT_HJUSTIFY_RIGHT;
break; break;
case GR_TEXT_HJUSTIFY_RIGHT:
hjustify = GR_TEXT_HJUSTIFY_LEFT; case GR_TEXT_HJUSTIFY_RIGHT:
break; hjustify = GR_TEXT_HJUSTIFY_LEFT;
default: break;
break;
default:
break;
} }
} }
else else
{ {
/* Texte horizontal: Y a t-il miroir (pour les justifications)*/ /* Texte horizontal: Y a t-il miroir (pour les justifications)*/
if( DrawLibItem->m_Transform[0][0] < 0 ) if( DrawLibItem->m_Transform[0][0] < 0 )
switch ( hjustify ) switch( hjustify )
{ {
case GR_TEXT_HJUSTIFY_LEFT: case GR_TEXT_HJUSTIFY_LEFT:
hjustify = GR_TEXT_HJUSTIFY_RIGHT; hjustify = GR_TEXT_HJUSTIFY_RIGHT;
break; break;
case GR_TEXT_HJUSTIFY_RIGHT:
hjustify = GR_TEXT_HJUSTIFY_LEFT; case GR_TEXT_HJUSTIFY_RIGHT:
break; hjustify = GR_TEXT_HJUSTIFY_LEFT;
default: break;
break;
default:
break;
} }
if( DrawLibItem->m_Transform[1][1] > 0 ) if( DrawLibItem->m_Transform[1][1] > 0 )
switch ( vjustify ) switch( vjustify )
{ {
case GR_TEXT_VJUSTIFY_BOTTOM: case GR_TEXT_VJUSTIFY_BOTTOM:
vjustify = GR_TEXT_VJUSTIFY_TOP; vjustify = GR_TEXT_VJUSTIFY_TOP;
break; break;
case GR_TEXT_VJUSTIFY_TOP:
vjustify = GR_TEXT_VJUSTIFY_BOTTOM; case GR_TEXT_VJUSTIFY_TOP:
break; vjustify = GR_TEXT_VJUSTIFY_BOTTOM;
default: break;
break;
default:
break;
} }
} }
int thickness = field->m_Width; int thickness = field->m_Width;
if( thickness == 0 ) if( thickness == 0 )
thickness = MAX( g_PlotLine_Width, g_DrawMinimunLineWidth ); thickness = MAX( g_PlotLine_Width, g_DrawMinimunLineWidth );
SetCurrentLineWidth( thickness ); SetCurrentLineWidth( thickness );
if( !IsMulti || (FieldNumber != REFERENCE) ) if( !IsMulti || (FieldNumber != REFERENCE) )
...@@ -476,14 +500,14 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem, ...@@ -476,14 +500,14 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem,
orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
field->m_Size, field->m_Size,
hjustify, vjustify, hjustify, vjustify,
thickness, field->m_Italic, true); thickness, field->m_Italic, true );
} }
else /* We plt the reference, for a multiple parts per package */ 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; wxString Text;
Text = field->m_Text; Text = field->m_Text;
char unit_id; char unit_id;
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
Text.Append( '.' ); Text.Append( '.' );
unit_id = '1' - 1 + DrawLibItem->m_Multi; unit_id = '1' - 1 + DrawLibItem->m_Multi;
...@@ -494,19 +518,19 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem, ...@@ -494,19 +518,19 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem,
PlotGraphicText( g_PlotFormat, textpos, color, Text, PlotGraphicText( g_PlotFormat, textpos, color, Text,
orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
field->m_Size, hjustify, vjustify, 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 /* Trace la pin du symbole en cours de trace
*/ */
{ {
int MapX1, MapY1, x1, y1; int MapX1, MapY1, x1, y1;
EDA_Colors color = UNSPECIFIED_COLOR; EDA_Colors color = UNSPECIFIED_COLOR;
color = ReturnLayerColor( LAYER_PIN ); color = ReturnLayerColor( LAYER_PIN );
...@@ -540,7 +564,7 @@ static void PlotPinSymbol( const wxPoint & pos, int len, int orient, int Shape ) ...@@ -540,7 +564,7 @@ static void PlotPinSymbol( const wxPoint & pos, int len, int orient, int Shape )
if( Shape & INVERT ) if( Shape & INVERT )
{ {
PlotCercle( wxPoint( MapX1 * INVERT_PIN_RADIUS + x1, PlotCercle( wxPoint( MapX1 * INVERT_PIN_RADIUS + x1,
MapY1 * INVERT_PIN_RADIUS + y1), MapY1 * INVERT_PIN_RADIUS + y1 ),
INVERT_PIN_RADIUS * 2, // diameter INVERT_PIN_RADIUS * 2, // diameter
false, // fill false, // fill
-1 ); // width -1 ); // width
...@@ -612,18 +636,11 @@ void PlotTextStruct( EDA_BaseStruct* Struct ) ...@@ -612,18 +636,11 @@ void PlotTextStruct( EDA_BaseStruct* Struct )
/*******************************************/ /*******************************************/
/* /*
* Routine de trace des Textes, Labels et Global-Labels. * Routine de trace des Textes, Labels et Global-Labels.
* Les textes peuvent avoir 4 directions. * Les textes peuvent avoir 4 directions.
*/ */
{ {
static std::vector <wxPoint> Poly; 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;
switch( Struct->Type() ) switch( Struct->Type() )
{ {
...@@ -631,117 +648,60 @@ void PlotTextStruct( EDA_BaseStruct* Struct ) ...@@ -631,117 +648,60 @@ void PlotTextStruct( EDA_BaseStruct* Struct )
case TYPE_SCH_HIERLABEL: case TYPE_SCH_HIERLABEL:
case TYPE_SCH_LABEL: case TYPE_SCH_LABEL:
case TYPE_SCH_TEXT: 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; break;
default: default:
return; return;
} }
if( Size.x == 0 ) SCH_TEXT* schText = (SCH_TEXT*) Struct;
Size = wxSize( DEFAULT_SIZE_TEXT, DEFAULT_SIZE_TEXT ); EDA_Colors color = UNSPECIFIED_COLOR;
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
if ( Struct->Type() == TYPE_SCH_GLOBALLABEL ) color = ReturnLayerColor( schText->m_Layer );
{ wxPoint textpos = schText->m_Pos + schText->GetSchematicTextOffset();
offset = ( (SCH_GLOBALLABEL*) Struct )->m_Width; int thickness = schText->m_Width;
switch( Shape ) if( thickness == 0 )
{ thickness = MAX( g_PlotLine_Width, g_DrawMinimunLineWidth );
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 ); SetCurrentLineWidth( thickness );
switch( Orient ) if( schText->m_MultilineAllowed )
{ {
case 0: /* Orientation horiz normale */ wxPoint pos = textpos;
if( Struct->Type() == TYPE_SCH_GLOBALLABEL || Struct->Type() == TYPE_SCH_HIERLABEL ) wxArrayString* list = wxStringSplit( schText->m_Text, '\n' );
PlotGraphicText( g_PlotFormat, wxPoint( pX - offset, pY ), wxPoint offset;
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;
case 1: /* Orientation vert UP */ offset.y = schText->GetInterline();
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;
case 2: /* Horiz Orientation - Right justified */ RotatePoint( &offset, schText->m_Orient );
if( Struct->Type() == TYPE_SCH_GLOBALLABEL || Struct->Type() == TYPE_SCH_HIERLABEL ) for( unsigned i = 0; i<list->Count(); i++ )
PlotGraphicText( g_PlotFormat, wxPoint( pX + offset, pY ), {
color, Text, TEXT_ORIENT_HORIZ, Size, wxString txt = list->Item( i );
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, PlotGraphicText( g_PlotFormat, pos,
thickness, italic, true ); color, txt, schText->m_Orient, schText->m_Size,
else schText->m_HJustify, schText->m_VJustify,
PlotGraphicText( g_PlotFormat, wxPoint( pX, pY - offset ), thickness, schText->m_Italic, true );
color, Text, TEXT_ORIENT_HORIZ, Size, pos += offset;
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, }
thickness, italic, true );
break;
case 3: /* Orientation vert BOTTOM */ delete (list);
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;
} }
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 */ /* Draw graphic symbol for global or hierachical labels */
if( Struct->Type() == TYPE_SCH_GLOBALLABEL ) 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 ); PlotPoly( Poly.size(), &Poly[0].x, NOFILL );
} }
if( Struct->Type() == TYPE_SCH_HIERLABEL ) 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 ); PlotPoly( Poly.size(), &Poly[0].x, NOFILL );
} }
} }
...@@ -750,11 +710,13 @@ void PlotTextStruct( EDA_BaseStruct* Struct ) ...@@ -750,11 +710,13 @@ void PlotTextStruct( EDA_BaseStruct* Struct )
/*****************************************************************************************/ /*****************************************************************************************/
static void Plot_Hierarchical_PIN_Sheet( Hierarchical_PIN_Sheet_Struct* aHierarchical_PIN ) static void Plot_Hierarchical_PIN_Sheet( Hierarchical_PIN_Sheet_Struct* aHierarchical_PIN )
/****************************************************************************************/ /****************************************************************************************/
/* Plot a Hierarchical_PIN_Sheet /* Plot a Hierarchical_PIN_Sheet
*/ */
{ {
EDA_Colors txtcolor = UNSPECIFIED_COLOR; EDA_Colors txtcolor = UNSPECIFIED_COLOR;
int posx, tposx, posy, size; int posx, tposx, posy, size;
static std::vector <wxPoint> Poly; static std::vector <wxPoint> Poly;
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt ) if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
...@@ -775,14 +737,14 @@ static void Plot_Hierarchical_PIN_Sheet( Hierarchical_PIN_Sheet_Struct* aHierarc ...@@ -775,14 +737,14 @@ static void Plot_Hierarchical_PIN_Sheet( Hierarchical_PIN_Sheet_Struct* aHierarc
side = GR_TEXT_HJUSTIFY_LEFT; side = GR_TEXT_HJUSTIFY_LEFT;
} }
int thickness = aHierarchical_PIN->m_Width; int thickness = aHierarchical_PIN->m_Width;
if( thickness == 0 ) if( thickness == 0 )
thickness = MAX( g_PlotLine_Width, g_DrawMinimunLineWidth ); thickness = MAX( g_PlotLine_Width, g_DrawMinimunLineWidth );
SetCurrentLineWidth( thickness ); SetCurrentLineWidth( thickness );
PlotGraphicText( g_PlotFormat, wxPoint( tposx, posy ), txtcolor, PlotGraphicText( g_PlotFormat, wxPoint( tposx, posy ), txtcolor,
aHierarchical_PIN->m_Text, TEXT_ORIENT_HORIZ, wxSize( size, size ), aHierarchical_PIN->m_Text, TEXT_ORIENT_HORIZ, wxSize( size, size ),
side, GR_TEXT_VJUSTIFY_CENTER, side, GR_TEXT_VJUSTIFY_CENTER,
thickness, aHierarchical_PIN->m_Italic, true ); thickness, aHierarchical_PIN->m_Italic, true );
/* Draw the associated graphic symbol */ /* Draw the associated graphic symbol */
aHierarchical_PIN->CreateGraphicShape( Poly, aHierarchical_PIN->m_Pos ); aHierarchical_PIN->CreateGraphicShape( Poly, aHierarchical_PIN->m_Pos );
...@@ -798,9 +760,9 @@ void PlotSheetStruct( DrawSheetStruct* Struct ) ...@@ -798,9 +760,9 @@ void PlotSheetStruct( DrawSheetStruct* Struct )
{ {
Hierarchical_PIN_Sheet_Struct* SheetLabelStruct; Hierarchical_PIN_Sheet_Struct* SheetLabelStruct;
EDA_Colors txtcolor = UNSPECIFIED_COLOR; EDA_Colors txtcolor = UNSPECIFIED_COLOR;
wxSize size; wxSize size;
wxString Text; wxString Text;
wxPoint pos; wxPoint pos;
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt ) if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS( ReturnLayerColor( Struct->m_Layer ) ); SetColorMapPS( ReturnLayerColor( Struct->m_Layer ) );
...@@ -834,7 +796,7 @@ void PlotSheetStruct( DrawSheetStruct* Struct ) ...@@ -834,7 +796,7 @@ void PlotSheetStruct( DrawSheetStruct* Struct )
PlotGraphicText( g_PlotFormat, pos, txtcolor, PlotGraphicText( g_PlotFormat, pos, txtcolor,
Text, TEXT_ORIENT_HORIZ, size, Text, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM,
thickness, italic ); thickness, italic );
/*Draw texts : FileName */ /*Draw texts : FileName */
Text = Struct->GetFileName(); Text = Struct->GetFileName();
...@@ -848,7 +810,7 @@ void PlotSheetStruct( DrawSheetStruct* Struct ) ...@@ -848,7 +810,7 @@ void PlotSheetStruct( DrawSheetStruct* Struct )
txtcolor, txtcolor,
Text, TEXT_ORIENT_HORIZ, size, Text, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP,
thickness, italic ); thickness, italic );
/* Draw texts : SheetLabel */ /* Draw texts : SheetLabel */
SheetLabelStruct = Struct->m_Label; SheetLabelStruct = Struct->m_Label;
......
...@@ -75,7 +75,7 @@ SCH_ITEM* ReadTextDescr( FILE* aFile, ...@@ -75,7 +75,7 @@ SCH_ITEM* ReadTextDescr( FILE* aFile,
new SCH_LABEL( pos, CONV_FROM_UTF8( text ) ); new SCH_LABEL( pos, CONV_FROM_UTF8( text ) );
TextStruct->m_Size.x = TextStruct->m_Size.y = size; TextStruct->m_Size.x = TextStruct->m_Size.y = size;
TextStruct->m_Orient = orient; TextStruct->SetSchematicTextOrientation( orient );
if( isdigit( Name3[0] ) ) if( isdigit( Name3[0] ) )
{ {
thickness = atol( Name3 ); thickness = atol( Name3 );
...@@ -92,7 +92,7 @@ SCH_ITEM* ReadTextDescr( FILE* aFile, ...@@ -92,7 +92,7 @@ SCH_ITEM* ReadTextDescr( FILE* aFile,
Struct = TextStruct; Struct = TextStruct;
TextStruct->m_Size.x = TextStruct->m_Size.y = size; TextStruct->m_Size.x = TextStruct->m_Size.y = size;
TextStruct->m_Orient = orient; TextStruct->SetSchematicTextOrientation( orient );
TextStruct->m_Shape = NET_INPUT; TextStruct->m_Shape = NET_INPUT;
TextStruct->m_Width = thickness; TextStruct->m_Width = thickness;
...@@ -115,7 +115,7 @@ SCH_ITEM* ReadTextDescr( FILE* aFile, ...@@ -115,7 +115,7 @@ SCH_ITEM* ReadTextDescr( FILE* aFile,
Struct = TextStruct; Struct = TextStruct;
TextStruct->m_Size.x = TextStruct->m_Size.y = size; TextStruct->m_Size.x = TextStruct->m_Size.y = size;
TextStruct->m_Orient = orient; TextStruct->SetSchematicTextOrientation( orient );
TextStruct->m_Shape = NET_INPUT; TextStruct->m_Shape = NET_INPUT;
TextStruct->m_Width = thickness; TextStruct->m_Width = thickness;
...@@ -138,14 +138,14 @@ SCH_ITEM* ReadTextDescr( FILE* aFile, ...@@ -138,14 +138,14 @@ SCH_ITEM* ReadTextDescr( FILE* aFile,
int i=val.find(_("\\n")); int i=val.find(_("\\n"));
if (i==wxNOT_FOUND) if (i==wxNOT_FOUND)
break; break;
val.erase(i,2); val.erase(i,2);
val.insert(i,_("\n")); val.insert(i,_("\n"));
} }
SCH_TEXT* TextStruct = new SCH_TEXT( pos, val ); SCH_TEXT* TextStruct = new SCH_TEXT( pos, val );
TextStruct->m_Size.x = TextStruct->m_Size.y = size; TextStruct->m_Size.x = TextStruct->m_Size.y = size;
TextStruct->m_Orient = orient; TextStruct->SetSchematicTextOrientation( orient );
if( isdigit( Name3[0] ) ) if( isdigit( Name3[0] ) )
{ {
thickness = atol( Name3 ); thickness = atol( Name3 );
......
...@@ -353,7 +353,7 @@ static void PlotTextModule( TEXTE_MODULE* pt_texte, int format_plot ) ...@@ -353,7 +353,7 @@ static void PlotTextModule( TEXTE_MODULE* pt_texte, int format_plot )
pt_texte->m_Text, pt_texte->m_Text,
orient, size, orient, size,
pt_texte->m_HJustify, pt_texte->m_VJustify, 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 ) ...@@ -620,11 +620,34 @@ void PlotTextePcb( TEXTE_PCB* pt_texte, int format_plot, int masque_layer )
break; 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, pt_texte->m_Text,
orient, size, orient, size,
pt_texte->m_HJustify, pt_texte->m_VJustify, pt_texte->m_HJustify, pt_texte->m_VJustify,
thickness, pt_texte->m_Italic ); thickness, pt_texte->m_Italic, true );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment