← Back to team overview

kicad-developers team mailing list archive

Patch: Fix grid cursor problem in "fill zone"

 

Problem: When you fill a zone, grid cursor artifacts appear on the
screen. This is especially noticeable with full-screen crosshair
cursors, but it also happens with the small crosshair.

To reproduce: In pcbnew (2006-03-28), select the full-screen crosshair
mode. Select the "Add zones" tool and execute the "Fill zone"
command. Notice that the crosshair cursor moves to a location near
the "fill" button on the "Fill Zones Options" dialog, while the mouse
cursor is restored to its former location. Also notices that
subsequent mouse motion causes multiple images of the crosshair cursor
to appear.

Root cause:
There are two situations that interact to cause this behavior.
a) During the execution of "ShowModal()" in "Fill_Zone()" in
pcbnew/zones.cpp, wxWidgets appears to generate a mouse motion event
whose position is the location of the Fill button in the dialog. This
event is handled by GeneraleControle(), causing a change in the grid
cursor position.
b) Later in Fill_Zone(), segments are drawn on the screen without
first removing the crosshair cursor.

Fix:
a) Bracket the "ShowModal()" sequence with calls to
SetEvtHandlerEnabled(FALSE) .. SetEvtHandlerEnabled(TRUE) to block the
undesired event during the dialog.
b) Bracket the drawing code in "Fill_Zones()" with a pair of calls to
"Trace_Curseur()", thus removing the crosshairs while the underlying
panel is being drawn upon.

The patch:

*** /c/v2006-03-28/kicad-dev/pcbnew/zones.cpp Mon Mar 6 11:23:54 2006
--- /c/kicad-dev/pcbnew/zones.cpp Sun Apr 2 18:27:16 2006
***************
*** 740,747 ****
--- 740,754 ----
return;
}
wxPoint curs_pos = GetScreen()->m_Curseur;
+ 
+ // Turn off our event handler during the modal dialog because
wxWidgets
+ // sends us a mouse-moved event during its execution. The
mouse position
+ // for that event is within the dialog box, and if we handle
the event,
+ // the grid cursor moves in a way the user does not expect.
+ DrawPanel->SetEvtHandlerEnabled(FALSE);
WinEDA_ZoneFrame * frame = new WinEDA_ZoneFrame(this);
ii = frame->ShowModal(); frame->Destroy();
+ DrawPanel->SetEvtHandlerEnabled(TRUE);
GetScreen()->m_Curseur = curs_pos;
DrawPanel->MouseToCursorSchema();
if ( ii ) return;
***************
*** 903,908 ****
--- 910,917 ----
  
if(Zone_Debug) DisplayBoard(DrawPanel, DC);
  
+ GetScreen()->Trace_Curseur(DrawPanel, DC);
+ 
/* Generation des segments de piste type Zone correspondants*/
if(g_HightLigth_NetCode < 0 )
Genere_Segments_Zone(this, DC, 0);
***************
*** 912,917 ****
--- 921,928 ----
g_DesignSettings.m_CurrentTrackWidth = lp_tmp;
if ( Zone_Exclude_Pads && Zone_Genere_Freins_Thermiques)
Genere_Pad_Connexion(this, DC,
GetScreen()->m_Active_Layer);
+ 
+ GetScreen()->Trace_Curseur(DrawPanel, DC);
  
g_DesignSettings.m_TrackClearence = save_isol;