From ec400bf7c727ea42941ea233852907da6e16323e Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 1 Mar 2011 19:45:21 +0100 Subject: [PATCH] Eeschema, Pcbnew: fix minor issues about mouse cursor position, when loading files or entering sheets. --- common/zoom.cpp | 7 +++++-- eeschema/files-io.cpp | 12 ++++++------ eeschema/hierarch.cpp | 14 ++++++++++++-- gerbview/files.cpp | 2 +- gerbview/gerbview.cpp | 5 +++-- pcbnew/edit.cpp | 2 +- pcbnew/files.cpp | 1 - pcbnew/initpcb.cpp | 4 ++-- pcbnew/loadcmp.cpp | 2 +- pcbnew/modedit.cpp | 6 +++--- pcbnew/pcbnew.cpp | 1 + 11 files changed, 35 insertions(+), 21 deletions(-) diff --git a/common/zoom.cpp b/common/zoom.cpp index 9b4a042602..89a8eee9dd 100644 --- a/common/zoom.cpp +++ b/common/zoom.cpp @@ -48,8 +48,11 @@ void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointe */ void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer ) { - GetScreen()->SetZoom( BestZoom() ); // Set the best zoom and get center point. - RedrawScreen( GetScreen()->GetScrollCenterPosition(), aWarpPointer ); + BASE_SCREEN * screen = GetScreen(); + screen->SetZoom( BestZoom() ); // Set the best zoom and get center point. + if( screen->m_FirstRedraw ) + screen->SetCrossHairPosition( screen->GetScrollCenterPosition() ); + RedrawScreen( screen->GetScrollCenterPosition(), aWarpPointer ); } diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 3c6a050eae..ac3bd3ef0a 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -21,7 +21,7 @@ /***************************************************************************** * Routine to save an EESchema file. * * FileSave controls how the file is to be saved - under what name. * -* Returns TRUE if the file has been saved. * +* Returns true if the file has been saved. * *****************************************************************************/ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* screen, int FileSave ) { @@ -212,8 +212,8 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& FileName, bool IsNew ) screen->m_Commentaire2.Empty(); screen->m_Commentaire3.Empty(); screen->m_Commentaire4.Empty(); - LoadProjectFile( wxEmptyString, TRUE ); - Zoom_Automatique( TRUE ); + LoadProjectFile( wxEmptyString, true ); + Zoom_Automatique( false ); SetSheetNumberAndCount(); DrawPanel->Refresh(); return true; @@ -223,7 +223,7 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& FileName, bool IsNew ) msg = _( "Ready\nWorking dir: \n" ) + wxGetCwd(); PrintMsg( msg ); - LoadProjectFile( wxEmptyString, FALSE ); + LoadProjectFile( wxEmptyString, false ); // Clear (if needed) the current active library in libedit because it could be // removed from memory @@ -292,7 +292,7 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& FileName, bool IsNew ) if( !wxFileExists( g_RootSheet->GetScreen()->GetFileName() ) && !LibCacheExist ) { - Zoom_Automatique( FALSE ); + Zoom_Automatique( false ); msg.Printf( _( "File <%s> not found." ), GetChars( g_RootSheet->GetScreen()->GetFileName() ) ); DisplayInfoMessage( this, msg, 0 ); @@ -306,7 +306,7 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& FileName, bool IsNew ) /* Redraw base screen (ROOT) if necessary. */ GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); - Zoom_Automatique( FALSE ); + Zoom_Automatique( false ); SetSheetNumberAndCount(); DrawPanel->Refresh( true ); return diag; diff --git a/eeschema/hierarch.cpp b/eeschema/hierarch.cpp index f001bddd90..72012442f5 100644 --- a/eeschema/hierarch.cpp +++ b/eeschema/hierarch.cpp @@ -263,12 +263,22 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet() if( screen->m_FirstRedraw ) { + Zoom_Automatique( false ); screen->m_FirstRedraw = false; - Zoom_Automatique( true ); + screen->SetCrossHairPosition( screen->GetScrollCenterPosition() ); + DrawPanel->MoveCursorToCrossHair(); } else { - DrawPanel->MoveCursorToCrossHair(); RedrawScreen( screen->GetScrollCenterPosition(), true ); } + + // Now refresh DrawPanel. Should be not necessary, but because screen has changed + // the previous refresh has set all new draw parameters (scroll position ..) + // but most of time there were some inconsitencies about cursor parameters + // ( previous position of cursor ...) and artefacts can happen + // mainly when sheet size has changed + // This second refresh clears artefacts because at this point, + // all parameters are now updated + DrawPanel->Refresh(); } diff --git a/gerbview/files.cpp b/gerbview/files.cpp index 939ffec5c8..4fc9bd206a 100644 --- a/gerbview/files.cpp +++ b/gerbview/files.cpp @@ -175,7 +175,7 @@ bool WinEDA_GerberFrame::LoadGerberFiles( const wxString& aFullFileName ) } } - Zoom_Automatique( true ); + Zoom_Automatique( false ); g_SaveTime = time( NULL ); // Synchronize layers tools with actual active layer: diff --git a/gerbview/gerbview.cpp b/gerbview/gerbview.cpp index a881117111..1f91508ca6 100644 --- a/gerbview/gerbview.cpp +++ b/gerbview/gerbview.cpp @@ -122,8 +122,9 @@ bool WinEDA_App::OnInit() // meaning here SetTopWindow( frame ); // Set GerbView mainframe on top - frame->Show( TRUE ); // Show GerbView mainframe - frame->Zoom_Automatique( TRUE ); // Zoomfit drawing in frame + frame->Show( true ); // Show GerbView mainframe + frame->Zoom_Automatique( true ); // Zoom fit in frame + frame->GetScreen()->m_FirstRedraw = false; Read_Config(); diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 5ed36b09aa..c5e71fc79c 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -164,7 +164,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) wxPoint( -1, -1 ), wxSize( 600, 400 ) ); m_ModuleEditFrame->Show( true ); - m_ModuleEditFrame->Zoom_Automatique( true ); + m_ModuleEditFrame->Zoom_Automatique( false ); } else m_ModuleEditFrame->Iconize( false ); diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 5f29c3a620..d94cb7adb1 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -30,7 +30,6 @@ void WinEDA_PcbFrame::OnFileHistory( wxCommandEvent& event ) DrawPanel->EndMouseCapture( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor() ); ::wxSetWorkingDirectory( ::wxPathOnly( fn ) ); LoadOnePcbFile( fn ); - DrawPanel->MoveCursorToCrossHair(); } } diff --git a/pcbnew/initpcb.cpp b/pcbnew/initpcb.cpp index 747c68505f..39894221e4 100644 --- a/pcbnew/initpcb.cpp +++ b/pcbnew/initpcb.cpp @@ -66,7 +66,7 @@ bool WinEDA_PcbFrame::Clear_Pcb( bool aQuery ) ReFillLayerWidget(); - Zoom_Automatique( true ); + Zoom_Automatique( false ); return true; } @@ -109,7 +109,7 @@ bool WinEDA_ModuleEditFrame::Clear_Pcb( bool aQuery ) GetScreen()->Init(); GetScreen()->SetGrid( gridsize ); - Zoom_Automatique( true ); + Zoom_Automatique( false ); return true; } diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index 4a00340e0b..9c331c0052 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -73,7 +73,7 @@ bool WinEDA_ModuleEditFrame::Load_Module_From_BOARD( MODULE* Module ) Rotate_Module( NULL, Module, 0, false ); GetScreen()->ClrModify(); - Zoom_Automatique( TRUE ); + Zoom_Automatique( false ); return true; } diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index 587d877a82..6fba18fc78 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -254,7 +254,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) module->SetPosition( wxPoint( 0, 0 ) ); if( GetBoard()->m_Modules ) GetBoard()->m_Modules->m_Flags = 0; - Zoom_Automatique( true ); + Zoom_Automatique( false ); } break; } @@ -360,7 +360,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) if( GetBoard()->m_Modules ) GetBoard()->m_Modules->m_Flags = 0; GetScreen()->ClrModify(); - Zoom_Automatique( true ); + Zoom_Automatique( false ); if( m_Draw3DFrame ) m_Draw3DFrame->NewDisplay(); break; @@ -416,7 +416,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) } } GetScreen()->ClrModify(); - Zoom_Automatique( true ); + Zoom_Automatique( false ); if( m_Draw3DFrame ) m_Draw3DFrame->NewDisplay(); break; diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index 3268e47ecc..9805ca4da7 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -150,6 +150,7 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) ); } frame->Zoom_Automatique( true ); + frame->GetScreen()->m_FirstRedraw = false; /* Load file specified in the command line. */ if( fn.IsOk() )