Browse Source

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

6.0.7
Pradeepa Senanayake 4 years ago
committed by Jeff Young
parent
commit
109e40c3a6
  1. 12
      gerbview/files.cpp
  2. 7
      gerbview/gerber_file_image_list.cpp
  3. 7
      gerbview/gerber_file_image_list.h

12
gerbview/files.cpp

@ -193,7 +193,17 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName )
// Set the busy cursor
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;
}

7
gerbview/gerber_file_image_list.cpp

@ -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 idx = aIdx;

7
gerbview/gerber_file_image_list.h

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

Loading…
Cancel
Save