Commit 858401d2 authored by jean-pierre charras's avatar jean-pierre charras

Eeschema & Pcbnew: fix incorrect position of cursor when crossprobing items.

parent 97003fef
...@@ -105,10 +105,10 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere ...@@ -105,10 +105,10 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere
const wxString& text_to_find, const wxString& text_to_find,
bool mouseWarp ) bool mouseWarp )
{ {
SCH_SHEET_PATH* sheet, * SheetWithComponentFound = NULL; SCH_SHEET_PATH* sheet;
SCH_SHEET_PATH* sheetWithComponentFound = NULL;
SCH_ITEM* DrawList = NULL; SCH_ITEM* DrawList = NULL;
SCH_COMPONENT* Component = NULL; SCH_COMPONENT* Component = NULL;
wxSize DrawAreaSize = DrawPanel->GetClientSize();
wxPoint pos, curpos; wxPoint pos, curpos;
bool DoCenterAndRedraw = false; bool DoCenterAndRedraw = false;
bool NotFound = true; bool NotFound = true;
...@@ -135,7 +135,7 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere ...@@ -135,7 +135,7 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere
if( component_reference.CmpNoCase( pSch->GetRef( sheet ) ) == 0 ) if( component_reference.CmpNoCase( pSch->GetRef( sheet ) ) == 0 )
{ {
Component = pSch; Component = pSch;
SheetWithComponentFound = sheet; sheetWithComponentFound = sheet;
switch( SearchType ) switch( SearchType )
{ {
...@@ -180,9 +180,8 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere ...@@ -180,9 +180,8 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere
if( Component ) if( Component )
{ {
sheet = SheetWithComponentFound; sheet = sheetWithComponentFound;
if( *sheet != *GetSheet() )
if( sheet != GetSheet() )
{ {
sheet->LastScreen()->SetZoom( GetScreen()->GetZoom() ); sheet->LastScreen()->SetZoom( GetScreen()->GetZoom() );
*m_CurrentSheet = *sheet; *m_CurrentSheet = *sheet;
...@@ -195,46 +194,36 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere ...@@ -195,46 +194,36 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere
delta = Component->GetTransform().TransformCoordinate( pos ); delta = Component->GetTransform().TransformCoordinate( pos );
pos = delta + Component->m_Pos; pos = delta + Component->m_Pos;
wxPoint old_cursor_position = sheet->LastScreen()->GetCrossHairPosition();
sheet->LastScreen()->SetCrossHairPosition( pos );
curpos = GetScreen()->GetCrossHairScreenPosition();
DrawPanel->GetViewStart( &( GetScreen()->m_StartVisu.x ),
&( GetScreen()->m_StartVisu.y ) );
// Calculating cursor position with original screen.
curpos -= GetScreen()->m_StartVisu;
/* There may be need to reframe the drawing */ /* There may be need to reframe the drawing */
#define MARGIN 30 if( ! DrawPanel->IsPointOnDisplay( pos ) )
if( ( curpos.x <= MARGIN ) || ( curpos.x >= DrawAreaSize.x - MARGIN )
|| ( curpos.y <= MARGIN ) || ( curpos.y >= DrawAreaSize.y - MARGIN ) )
{ {
DoCenterAndRedraw = true;; DoCenterAndRedraw = true;
} }
#undef MARGIN
if( DoCenterAndRedraw ) if( DoCenterAndRedraw )
RedrawScreen( curpos, mouseWarp ); {
GetScreen()->SetCrossHairPosition(pos);
RedrawScreen( pos, mouseWarp );
}
else else
{ {
INSTALL_UNBUFFERED_DC( dc, DrawPanel ); INSTALL_UNBUFFERED_DC( dc, DrawPanel );
EXCHG( old_cursor_position, sheet->LastScreen()->GetCrossHairPosition() );
DrawPanel->CrossHairOff( &dc ); DrawPanel->CrossHairOff( &dc );
if( mouseWarp ) if( mouseWarp )
DrawPanel->MoveCursor( curpos ); DrawPanel->MoveCursor( pos );
EXCHG( old_cursor_position, sheet->LastScreen()->GetCrossHairPosition() ); GetScreen()->SetCrossHairPosition(pos);
DrawPanel->CrossHairOn( &dc ); DrawPanel->CrossHairOn( &dc );
} }
} }
/* Print diaq */ /* Print diag */
wxString msg_item; wxString msg_item;
msg = component_reference; msg = component_reference;
......
...@@ -122,7 +122,10 @@ void RemoteCommand( const char* cmdline ) ...@@ -122,7 +122,10 @@ void RemoteCommand( const char* cmdline )
} }
if( module ) // if found, center the module on screen, and redraw the screen. if( module ) // if found, center the module on screen, and redraw the screen.
{
frame->GetScreen()->SetCrossHairPosition(pos);
frame->RedrawScreen( pos, false ); frame->RedrawScreen( pos, false );
}
} }
......
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