beautification
This commit is contained in:
parent
461d75de4c
commit
2aa1a26b58
|
@ -342,6 +342,7 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
|
|||
|
||||
if( m_TextDrawings == NULL ) /* pointeur sur la liste des segments de dessin */
|
||||
CreateDrawData();
|
||||
|
||||
if( m_TextDrawings == NULL )
|
||||
return;
|
||||
|
||||
|
@ -349,6 +350,7 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
|
|||
width = m_Width / zoom;
|
||||
if( display_mode == FILAIRE )
|
||||
width = 0;
|
||||
|
||||
/* choix de la couleur du texte : */
|
||||
if( draw_mode != -1 )
|
||||
GRSetDrawMode( DC, draw_mode );
|
||||
|
@ -370,12 +372,15 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
|
|||
{
|
||||
int anchor_size = 2 * zoom;
|
||||
anchor_color &= MASKCOLOR;
|
||||
|
||||
/* calcul de la position du texte */
|
||||
int cX = m_Pos.x - offset.x;
|
||||
int cY = m_Pos.y - offset.y;
|
||||
|
||||
/* trace ancre du texte */
|
||||
GRLine( &panel->m_ClipBox, DC, cX - anchor_size, cY,
|
||||
cX + anchor_size, cY, 0, anchor_color );
|
||||
|
||||
GRLine( &panel->m_ClipBox, DC, cX, cY - anchor_size,
|
||||
cX, cY + anchor_size, 0, anchor_color );
|
||||
}
|
||||
|
@ -385,15 +390,14 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
|
|||
nbpoints = m_TextDrawings[jj];
|
||||
if( nbpoints > 50 )
|
||||
nbpoints = 50;
|
||||
|
||||
for( kk = 0, ll = 0; (kk < nbpoints) && (ii < m_TextDrawingsSize); kk++ )
|
||||
{
|
||||
coord[ll] = m_TextDrawings[ii] + offset.x + m_Pos.x;
|
||||
ll++; ii++;
|
||||
coord[ll] = m_TextDrawings[ii] + offset.y + m_Pos.y;
|
||||
ll++; ii++;
|
||||
coord[ll++] = m_TextDrawings[ii++] + offset.x + m_Pos.x;
|
||||
coord[ll++] = m_TextDrawings[ii++] + offset.y + m_Pos.y;
|
||||
}
|
||||
|
||||
jj = ii; ii++;
|
||||
jj = ii++;
|
||||
|
||||
if( width > 2 )
|
||||
{
|
||||
|
@ -544,8 +548,13 @@ void EDA_TextStruct::CreateDrawData()
|
|||
m_ZoomLevelDrawable = m_Size.x / 3;
|
||||
dx = (espacement * nbchar) / 2;
|
||||
dy = size_v / 2; /* Decalage du debut du texte / centre */
|
||||
ux0 = cX - dx; uy0 = cY;
|
||||
dx += cX; dy = cY;
|
||||
|
||||
ux0 = cX - dx;
|
||||
uy0 = cY;
|
||||
|
||||
dx += cX;
|
||||
dy = cY;
|
||||
|
||||
RotatePoint( &ux0, &uy0, cX, cY, m_Orient );
|
||||
RotatePoint( &dx, &dy, cX, cY, m_Orient );
|
||||
|
||||
|
@ -582,9 +591,10 @@ void EDA_TextStruct::CreateDrawData()
|
|||
coord = (int*) realloc( coord, coord_count_max * sizeof(int) );
|
||||
}
|
||||
coord[jj] = nbpoints;
|
||||
jj = ii; ii++;
|
||||
jj = ii++;
|
||||
}
|
||||
plume = f_cod; nbpoints = 0;
|
||||
plume = f_cod;
|
||||
nbpoints = 0;
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
|
@ -600,14 +610,20 @@ void EDA_TextStruct::CreateDrawData()
|
|||
f_cod = *ptcar;
|
||||
k2 = f_cod; /* trace sur axe H */
|
||||
k2 = (k2 * size_h) / 9;
|
||||
dx = k2 + ox; dy = k1 + oy;
|
||||
|
||||
dx = k2 + ox;
|
||||
dy = k1 + oy;
|
||||
|
||||
RotatePoint( &dx, &dy, cX, cY, m_Orient );
|
||||
if( ii >= coord_count_max )
|
||||
{
|
||||
coord_count_max *= 2;
|
||||
coord = (int*) realloc( coord, coord_count_max * sizeof(int) );
|
||||
}
|
||||
coord[ii] = dx; ii++; coord[ii] = dy; ii++;
|
||||
|
||||
coord[ii++] = dx;
|
||||
coord[ii++] = dy;
|
||||
|
||||
nbpoints++;
|
||||
break;
|
||||
}
|
||||
|
@ -618,7 +634,8 @@ void EDA_TextStruct::CreateDrawData()
|
|||
|
||||
/* end boucle for = end trace de 1 caractere */
|
||||
|
||||
ptr++; ox += espacement;
|
||||
ptr++;
|
||||
ox += espacement;
|
||||
}
|
||||
|
||||
/* end trace du texte */
|
||||
|
@ -661,13 +678,16 @@ bool EDA_Rect::Inside( const wxPoint& point )
|
|||
|
||||
if( size.x < 0 )
|
||||
{
|
||||
size.x = -size.x; rel_posx += size.x;
|
||||
size.x = -size.x;
|
||||
rel_posx += size.x;
|
||||
}
|
||||
|
||||
if( size.y < 0 )
|
||||
{
|
||||
size.y = -size.y; rel_posy += size.y;
|
||||
size.y = -size.y;
|
||||
rel_posy += size.y;
|
||||
}
|
||||
|
||||
return (rel_posx >= 0) && (rel_posy >= 0)
|
||||
&& ( rel_posy <= size.y)
|
||||
&& ( rel_posx <= size.x)
|
||||
|
|
|
@ -26,16 +26,17 @@ void DrawGraphicText(WinEDA_DrawPanel * panel, wxDC * DC,
|
|||
const wxPoint& Pos, int gcolor, const wxString& Text,
|
||||
int orient, const wxSize& Size, int h_justify, int v_justify, int width )
|
||||
/*****************************************************************************/
|
||||
|
||||
/* Draw a graphic text (like module texts)
|
||||
Text = text to draw
|
||||
Pos = text position (according to h_justify, v_justify)
|
||||
Size = text size (size.x or size.y can be < 0 for mirrored texts)
|
||||
orient = angle in 0.1 degree
|
||||
mode_color = GR_OR, GR_XOR..
|
||||
h_justify = horizontal justification (Left, center, right)
|
||||
v_justify = vertical justification (bottom, center, top)
|
||||
width = line width (pen width) (default = 0)
|
||||
if width < 0 : draw segments in sketch mode, width = abs(width)
|
||||
* Text = text to draw
|
||||
* Pos = text position (according to h_justify, v_justify)
|
||||
* Size = text size (size.x or size.y can be < 0 for mirrored texts)
|
||||
* orient = angle in 0.1 degree
|
||||
* mode_color = GR_OR, GR_XOR..
|
||||
* h_justify = horizontal justification (Left, center, right)
|
||||
* v_justify = vertical justification (bottom, center, top)
|
||||
* width = line width (pen width) (default = 0)
|
||||
* if width < 0 : draw segments in sketch mode, width = abs(width)
|
||||
*/
|
||||
{
|
||||
int ii, kk, nbchar, AsciiCode, endcar;
|
||||
|
@ -61,13 +62,16 @@ bool sketch_mode = FALSE;
|
|||
width = -width;
|
||||
sketch_mode = TRUE;
|
||||
}
|
||||
kk = 0 ; ptr = 0; /* ptr = text index */
|
||||
kk = 0;
|
||||
ptr = 0; /* ptr = text index */
|
||||
|
||||
nbchar = Text.Len();
|
||||
if ( nbchar == 0 ) return;
|
||||
if( nbchar == 0 )
|
||||
return;
|
||||
|
||||
espacement = (10 * size_h ) / 9; // this is the pitch between chars
|
||||
ox = cX = Pos.x; oy = cY = Pos.y;
|
||||
ox = cX = Pos.x;
|
||||
oy = cY = Pos.y;
|
||||
|
||||
/* Do not draw the text if out of draw area! */
|
||||
if( panel )
|
||||
|
@ -75,16 +79,23 @@ bool sketch_mode = FALSE;
|
|||
int xm, ym, ll, xc, yc;
|
||||
int textsize = ABS( espacement );
|
||||
ll = (textsize * nbchar) / zoom;
|
||||
|
||||
xc = GRMapX( cX );
|
||||
yc = GRMapY( cY );
|
||||
|
||||
x0 = panel->m_ClipBox.GetX() - ll;
|
||||
y0 = panel->m_ClipBox.GetY() - ll;
|
||||
xm = panel->m_ClipBox.GetRight() + ll;
|
||||
ym = panel->m_ClipBox.GetBottom() + ll;
|
||||
if ( xc < x0 ) return;
|
||||
if ( yc < y0 ) return;
|
||||
if ( xc > xm ) return;
|
||||
if ( yc > ym ) return;
|
||||
|
||||
if( xc < x0 )
|
||||
return;
|
||||
if( yc < y0 )
|
||||
return;
|
||||
if( xc > xm )
|
||||
return;
|
||||
if( yc > ym )
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -124,7 +135,6 @@ bool sketch_mode = FALSE;
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else /* Vertical Text */
|
||||
{
|
||||
switch( h_justify )
|
||||
|
@ -155,20 +165,30 @@ bool sketch_mode = FALSE;
|
|||
break;
|
||||
}
|
||||
}
|
||||
cX += ux0; cY += uy0;
|
||||
ox = cX - dx; ; oy = cY + dy;
|
||||
|
||||
if( (Size.x/zoom) == 0 ) return;
|
||||
cX += ux0;
|
||||
cY += uy0;
|
||||
|
||||
ox = cX - dx;
|
||||
oy = cY + dy;
|
||||
|
||||
if( (Size.x / zoom) == 0 )
|
||||
return;
|
||||
|
||||
if( ABS( (Size.x / zoom) ) < 3 ) /* chars trop petits pour etre dessines */
|
||||
{ /* le texte est symbolise par une barre */
|
||||
dx = (espacement * nbchar) / 2;
|
||||
dy = size_v / 2; /* Decalage du debut du texte / centre */
|
||||
|
||||
ux0 = cX - dx; uy0 = cY;
|
||||
dx += cX; dy = cY;
|
||||
ux0 = cX - dx;
|
||||
uy0 = cY;
|
||||
|
||||
dx += cX;
|
||||
dy = cY;
|
||||
|
||||
RotatePoint( &ux0, &uy0, cX, cY, orient );
|
||||
RotatePoint( &dx, &dy, cX, cY, orient );
|
||||
|
||||
GRLine( &panel->m_ClipBox, DC, ux0, uy0, dx, dy, width, gcolor );
|
||||
|
||||
return;
|
||||
|
@ -177,14 +197,21 @@ bool sketch_mode = FALSE;
|
|||
#if 0
|
||||
dx = (espacement * nbchar) / 2;
|
||||
dy = size_v / 2;/* Decalage du debut du texte / centre */
|
||||
ux0 = cX - dx; uy0 = cY;
|
||||
dx += cX; dy = cY;
|
||||
|
||||
ux0 = cX - dx;
|
||||
uy0 = cY;
|
||||
|
||||
dx += cX;
|
||||
dy = cY;
|
||||
|
||||
RotatePoint( &ux0, &uy0, cX, cY, orient );
|
||||
RotatePoint( &dx, &dy, cX, cY, orient );
|
||||
|
||||
DC->SetTextForeground( wxColour(
|
||||
ColorRefs[gcolor].r,
|
||||
ColorRefs[gcolor].g,
|
||||
ColorRefs[gcolor].b ) );
|
||||
|
||||
DC->DrawRotatedText( Text, GRMapX( ux0 ), GRMapY( uy0 ), (double) orient / 10.0 );
|
||||
return;
|
||||
#endif
|
||||
|
@ -194,11 +221,13 @@ return;
|
|||
x0 = 0; y0 = 0;
|
||||
AsciiCode = Text.GetChar( ptr ) & 255;
|
||||
ptcar = graphic_fonte_shape[AsciiCode]; /* ptcar pointe la description
|
||||
du caractere a dessiner */
|
||||
* du caractere a dessiner */
|
||||
|
||||
for( ii = 0, endcar = FALSE; !endcar; ptcar++ )
|
||||
{
|
||||
f_cod = *ptcar ; /* get code n de la forme selectionnee */
|
||||
f_cod = *ptcar;
|
||||
|
||||
/* get code n de la forme selectionnee */
|
||||
switch( f_cod )
|
||||
{
|
||||
case 'X':
|
||||
|
@ -219,7 +248,6 @@ return;
|
|||
GRCSegm( &panel->m_ClipBox, DC, *coordptr, *(coordptr + 1),
|
||||
*(coordptr + 2), *(coordptr + 3), width, gcolor );
|
||||
}
|
||||
|
||||
else
|
||||
GRPoly( &panel->m_ClipBox, DC, ii / 2, coord, 0,
|
||||
width, gcolor, gcolor );
|
||||
|
@ -227,27 +255,38 @@ return;
|
|||
plume = f_cod; ii = 0;
|
||||
break;
|
||||
|
||||
case 'D' : plume = f_cod ; break ;
|
||||
case 'D':
|
||||
plume = f_cod;
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
k1 = f_cod; /* trace sur axe V */
|
||||
k1 = -( (k1 * size_v) / 9 );
|
||||
|
||||
ptcar++;
|
||||
f_cod = *ptcar;
|
||||
|
||||
k2 = f_cod; /* trace sur axe H */
|
||||
k2 = (k2 * size_h) / 9;
|
||||
dx = k2 + ox; dy = k1 + oy;
|
||||
|
||||
RotatePoint( &dx, &dy, cX, cY, orient );
|
||||
coord[ii] = dx; ii++; coord[ii] = dy; ii++;
|
||||
coord[ii++] = dx;
|
||||
coord[ii++] = dy;
|
||||
break;
|
||||
}
|
||||
} /* end switch */
|
||||
} /* end boucle for = end trace de 1 caractere */
|
||||
}
|
||||
|
||||
/* end switch */
|
||||
}
|
||||
|
||||
/* end boucle for = end trace de 1 caractere */
|
||||
|
||||
ptr++; ox += espacement;
|
||||
} /* end trace du texte */
|
||||
}
|
||||
|
||||
/* end trace du texte */
|
||||
}
|
||||
|
||||
|
||||
|
@ -256,8 +295,9 @@ void PlotGraphicText(int format_plot, const wxPoint & Pos, int gcolor,
|
|||
const wxString& Text,
|
||||
int orient, const wxSize& Size, int h_justify, int v_justify )
|
||||
/******************************************************************************************/
|
||||
|
||||
/*
|
||||
id DrawGraphicText, for plot graphic text
|
||||
* id DrawGraphicText, for plot graphic text
|
||||
*/
|
||||
{
|
||||
int kk, nbchar, end, AsciiCode;
|
||||
|
@ -268,6 +308,7 @@ const SH_CODE * ptcar;
|
|||
int ptr;
|
||||
int ux0, uy0, dx, dy; // Coord de trace des segments de texte & variables de calcul */
|
||||
int cX, cY; // Centre du texte
|
||||
|
||||
void (*FctPlume)( wxPoint pos, int state );
|
||||
|
||||
switch( format_plot )
|
||||
|
@ -290,16 +331,20 @@ void (*FctPlume)(wxPoint pos, int state);
|
|||
|
||||
size_h = Size.x;
|
||||
size_v = Size.y;
|
||||
if(size_h == 0) size_h = DEFAULT_SIZE_TEXT;
|
||||
if(size_v == 0) size_v = DEFAULT_SIZE_TEXT;
|
||||
if( size_h == 0 )
|
||||
size_h = DEFAULT_SIZE_TEXT;
|
||||
if( size_v == 0 )
|
||||
size_v = DEFAULT_SIZE_TEXT;
|
||||
|
||||
kk = 0 ; ptr = 0; /* ptr = text index */
|
||||
kk = 0;
|
||||
ptr = 0; /* ptr = text index */
|
||||
|
||||
/* calcul de la position du debut des textes: ox et oy */
|
||||
nbchar = Text.Len();
|
||||
|
||||
espacement = (10 * size_h ) / 9;
|
||||
ox = cX = Pos.x; oy = cY = Pos.y;
|
||||
ox = cX = Pos.x;
|
||||
oy = cY = Pos.y;
|
||||
|
||||
/* Calcul du cadrage du texte */
|
||||
dx = (espacement * nbchar) / 2;
|
||||
|
@ -337,7 +382,6 @@ void (*FctPlume)(wxPoint pos, int state);
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else /* Texte Vertical */
|
||||
{
|
||||
switch( h_justify )
|
||||
|
@ -368,8 +412,12 @@ void (*FctPlume)(wxPoint pos, int state);
|
|||
break;
|
||||
}
|
||||
}
|
||||
cX += ux0; cY += uy0; /* cX, cY = coord du centre du texte */
|
||||
ox = -dx; oy = +dy; /* ox, oy = coord debut texte, relativement au centre */
|
||||
|
||||
cX += ux0;
|
||||
cY += uy0; /* cX, cY = coord du centre du texte */
|
||||
|
||||
ox = -dx;
|
||||
oy = +dy; /* ox, oy = coord debut texte, relativement au centre */
|
||||
|
||||
FctPlume( wxPoint( 0, 0 ), 'Z' );
|
||||
|
||||
|
@ -377,36 +425,51 @@ void (*FctPlume)(wxPoint pos, int state);
|
|||
{
|
||||
AsciiCode = Text.GetChar( ptr ) & 255;
|
||||
ptcar = graphic_fonte_shape[AsciiCode]; /* ptcar pointe la description
|
||||
du caractere a dessiner */
|
||||
* du caractere a dessiner */
|
||||
|
||||
for( end = 0; end == 0; ptcar++ )
|
||||
{
|
||||
f_cod = *ptcar ; /* get code n de la forme selectionnee */
|
||||
f_cod = *ptcar;
|
||||
|
||||
/* get code n de la forme selectionnee */
|
||||
switch( f_cod )
|
||||
{
|
||||
case 'X' : end = 1 ;/* fin du caractere */
|
||||
case 'X':
|
||||
end = 1; /* fin du caractere */
|
||||
|
||||
case 'U':
|
||||
case 'D' : plume = f_cod ; break ;
|
||||
case 'D':
|
||||
plume = f_cod; break;
|
||||
|
||||
default:
|
||||
k1 = f_cod; /* trace sur axe V */
|
||||
k1 = -(k1 * size_v) / 9;
|
||||
ptcar++;
|
||||
f_cod = *ptcar;
|
||||
|
||||
k2 = f_cod; /* trace sur axe H */
|
||||
k2 = (k2 * size_h) / 9;
|
||||
dx = k2 + ox; dy = k1 + oy;
|
||||
|
||||
dx = k2 + ox;
|
||||
dy = k1 + oy;
|
||||
|
||||
RotatePoint( &dx, &dy, orient );
|
||||
FctPlume( wxPoint( cX + dx, cY + dy ), plume );
|
||||
x0 = k2 ; y0 = k1 ;
|
||||
|
||||
x0 = k2;
|
||||
y0 = k1;
|
||||
break;
|
||||
} /* end switch */
|
||||
} /* end boucle for = end trace de 1 caractere */
|
||||
}
|
||||
|
||||
/* end switch */
|
||||
}
|
||||
|
||||
/* end boucle for = end trace de 1 caractere */
|
||||
|
||||
FctPlume( wxPoint( 0, 0 ), 'Z' );
|
||||
ptr++; ox += espacement;
|
||||
} /* end trace du texte */
|
||||
FctPlume(wxPoint(0,0), 'Z');
|
||||
}
|
||||
|
||||
/* end trace du texte */
|
||||
FctPlume( wxPoint( 0, 0 ), 'Z' );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue