Ensure auto zoom is enabled when it's the first file

This commit is contained in:
Pradeepa Senanayake 2021-07-25 13:41:05 +10:00 committed by Jeff Young
parent 8f4ff1e954
commit 109e40c3a6
3 changed files with 25 additions and 1 deletions

View File

@ -193,7 +193,17 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName )
// Set the busy cursor // Set the busy cursor
wxBusyCursor wait; wxBusyCursor wait;
return LoadListOfGerberAndDrillFiles( currentPath, filenamesList ); bool isFirstFile = GetImagesList()->GetLoadedImageCount() == 0;
bool success = LoadListOfGerberAndDrillFiles( currentPath, filenamesList );
// Auto zoom is only applied if there is only one file loaded
if ( isFirstFile )
{
Zoom_Automatique( false );
}
return success;
} }

View File

@ -70,6 +70,13 @@ GERBER_FILE_IMAGE* GERBER_FILE_IMAGE_LIST::GetGbrImage( int aIdx )
} }
unsigned GERBER_FILE_IMAGE_LIST::GetLoadedImageCount()
{
auto notNull = []( GERBER_FILE_IMAGE* image ){ return image != nullptr; };
return std::count_if( m_GERBER_List.begin(), m_GERBER_List.end(), notNull );
}
int GERBER_FILE_IMAGE_LIST::AddGbrImage( GERBER_FILE_IMAGE* aGbrImage, int aIdx ) int GERBER_FILE_IMAGE_LIST::AddGbrImage( GERBER_FILE_IMAGE* aGbrImage, int aIdx )
{ {
int idx = aIdx; int idx = aIdx;

View File

@ -121,6 +121,13 @@ public:
*/ */
std::unordered_map<int, int> SortImagesByZOrder(); std::unordered_map<int, int> SortImagesByZOrder();
/**
* Get number of loaded images
*
* @return number of images loaded
*/
unsigned GetLoadedImageCount();
private: private:
// the list of loaded images (1 image = 1 gerber file) // the list of loaded images (1 image = 1 gerber file)
std::vector<GERBER_FILE_IMAGE*> m_GERBER_List; std::vector<GERBER_FILE_IMAGE*> m_GERBER_List;