Fixed: incorrect refresh of screen area after closing a popup menu (texts and polygons sometimes not redrawn)

This commit is contained in:
charras 2009-04-17 12:45:22 +00:00
parent 9edace2f5f
commit bb5832c863
2 changed files with 170 additions and 154 deletions

View File

@ -25,15 +25,20 @@
int NegableTextLength( const wxString& aText ) int NegableTextLength( const wxString& aText )
{ {
int char_count = aText.length(); int char_count = aText.length();
/* Fix the character count, removing the ~ found */ /* Fix the character count, removing the ~ found */
for (int i = char_count-1; i >= 0; i--) { for( int i = char_count - 1; i >= 0; i-- )
if (aText[i] == '~') { {
if( aText[i] == '~' )
{
char_count--; char_count--;
} }
} }
return char_count; return char_count;
} }
/* Helper function for drawing character polygons */ /* Helper function for drawing character polygons */
static void DrawGraphicTextPline( static void DrawGraphicTextPline(
WinEDA_DrawPanel* aPanel, WinEDA_DrawPanel* aPanel,
@ -53,7 +58,6 @@ static void DrawGraphicTextPline(
coord[ik + 1].x, coord[ik + 1].y ); coord[ik + 1].x, coord[ik + 1].y );
} }
} }
else if( sketch_mode ) else if( sketch_mode )
{ {
for( int ik = 0; ik < (point_count - 1); ik++ ) for( int ik = 0; ik < (point_count - 1); ik++ )
@ -65,11 +69,13 @@ static void DrawGraphicTextPline(
aWidth, aColor, aColor ); aWidth, aColor, aColor );
} }
static int overbar_position( int size_v, int thickness ) static int overbar_position( int size_v, int thickness )
{ {
return size_v * 1.1 + thickness; return size_v * 1.1 + thickness;
} }
/** Function DrawGraphicText /** Function DrawGraphicText
* Draw a graphic text (like module texts) * Draw a graphic text (like module texts)
* @param aPanel = the current DrawPanel. NULL if draw within a 3D GL Canvas * @param aPanel = the current DrawPanel. NULL if draw within a 3D GL Canvas
@ -115,6 +121,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
int ox, oy; // Draw coordinates for the current char int ox, oy; // Draw coordinates for the current char
int overbar_x, overbar_y; // 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
wxPoint coord[BUF_SIZE + 1]; // Buffer coordinate used to draw polylines (one char shape) wxPoint coord[BUF_SIZE + 1]; // Buffer coordinate used to draw polylines (one char shape)
bool sketch_mode = false; bool sketch_mode = false;
@ -132,9 +139,12 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
if( aSize.x < 0 ) // text is mirrored using size.x < 0 (mirror / Y axis) if( aSize.x < 0 ) // text is mirrored using size.x < 0 (mirror / Y axis)
italic_reverse = true; italic_reverse = true;
if (aNegable) { if( aNegable )
{
char_count = NegableTextLength( aText ); char_count = NegableTextLength( aText );
} else { }
else
{
char_count = aText.Len(); char_count = aText.Len();
} }
if( char_count == 0 ) if( char_count == 0 )
@ -253,7 +263,8 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
return; return;
if( aPanel && ABS( ( aPanel->GetScreen()->Scale( aSize.x ) ) ) < 3 ) /* shapes are too small: connot be drawn */ if( aPanel && ABS( ( aPanel->GetScreen()->Scale( aSize.x ) ) ) < 3 ) /* shapes are too small: connot be drawn */
{ /* insteed the text is drawn as a line */ {
/* insteed the text is drawn as a line */
dx = (pitch * char_count) / 2; dx = (pitch * char_count) / 2;
dy = size_v / 2; /* line is always centered */ dy = size_v / 2; /* line is always centered */
@ -278,17 +289,22 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
ptr = 0; /* ptr = text index */ ptr = 0; /* ptr = text index */
while( ptr < char_count ) while( ptr < char_count )
{ {
if (aNegable) { if( aNegable )
if (aText[ptr+overbars] == '~') { {
if( aText[ptr + overbars] == '~' )
{
/* Found an overbar, adjust the pointers */ /* Found an overbar, adjust the pointers */
overbars++; overbars++;
if (overbars % 2) { if( overbars % 2 )
{
/* Starting the overbar */ /* Starting the overbar */
overbar_x = ox; overbar_x = ox;
overbar_y = oy - overbar_position( size_v, thickness ); overbar_y = oy - overbar_position( size_v, thickness );
RotatePoint( &overbar_x, &overbar_y, cX, cY, aOrient ); RotatePoint( &overbar_x, &overbar_y, cX, cY, aOrient );
} else { }
else
{
/* Ending the overbar */ /* Ending the overbar */
coord[0].x = overbar_x; coord[0].x = overbar_x;
coord[0].y = overbar_y; coord[0].y = overbar_y;
@ -358,6 +374,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
k2 = f_cod; /* trace sur axe H */ k2 = f_cod; /* trace sur axe H */
k2 = (k2 * size_h) / 9; k2 = (k2 * size_h) / 9;
// 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;
@ -379,7 +396,9 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
ptr++; ox += pitch; ptr++; ox += pitch;
} }
if (overbars % 2) {
if( overbars % 2 )
{
/* Close the last overbar */ /* Close the last overbar */
coord[0].x = overbar_x; coord[0].x = overbar_x;
coord[0].y = overbar_y; coord[0].y = overbar_y;
@ -395,7 +414,6 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
} }
/* functions used to plot texts, using DrawGraphicText() with a call back function */ /* functions used to plot texts, using DrawGraphicText() with a call back function */
static void (*MovePenFct)( wxPoint pos, int state ); // a pointer to actual plot function (HPGL, PS, ..) static void (*MovePenFct)( wxPoint pos, int state ); // a pointer to actual plot function (HPGL, PS, ..)
static bool s_Plotbegin; // Flag to init plot static bool s_Plotbegin; // Flag to init plot
@ -405,8 +423,7 @@ static bool s_Plotbegin; // Flag to init plot
* The call back function * The call back function
*/ */
/**********************/ /**********************/
static void static void s_Callback_plot( int x0,
s_Callback_plot(int x0,
int y0, int y0,
int xf, int xf,
int yf ) int yf )
@ -414,6 +431,7 @@ s_Callback_plot(int x0,
{ {
static wxPoint PenLastPos; static wxPoint PenLastPos;
wxPoint pstart; wxPoint pstart;
pstart.x = x0; pstart.x = x0;
pstart.y = y0; pstart.y = y0;
wxPoint pend; wxPoint pend;
@ -425,7 +443,6 @@ s_Callback_plot(int x0,
MovePenFct( pend, 'D' ); MovePenFct( pend, 'D' );
s_Plotbegin = false; s_Plotbegin = false;
} }
else else
{ {
if( PenLastPos == pstart ) // this is a next segment in a polyline if( PenLastPos == pstart ) // this is a next segment in a polyline
@ -504,4 +521,3 @@ void PlotGraphicText( int aFormat_plot,
/* end text : pen UP ,no move */ /* end text : pen UP ,no move */
MovePenFct( wxPoint( 0, 0 ), 'Z' ); MovePenFct( wxPoint( 0, 0 ), 'Z' );
} }

View File

@ -856,7 +856,7 @@ static bool IsGRSPolyDrawable( EDA_Rect* ClipBox, int n, wxPoint Points[] )
xcliplo = ClipBox->GetX(); xcliplo = ClipBox->GetX();
ycliplo = ClipBox->GetY(); ycliplo = ClipBox->GetY();
xcliphi = ClipBox->GetRight(); xcliphi = ClipBox->GetRight();
ycliphi = ClipBox->GetHeight(); ycliphi = ClipBox->GetBottom();
if( Xmax < xcliplo ) if( Xmax < xcliplo )
return FALSE; return FALSE;