31#include <wx/filename.h>
74 return image !=
nullptr;
139 wxString filename = fn.GetFullName();
142 const int maxlen = 30;
144 if( !aFullName && filename.Length() > maxlen )
146 wxString shortenedfn = filename.Left(2) + wxT(
"..." ) + filename.Right(maxlen-5);
147 filename = shortenedfn;
154 name.Printf( wxT(
"%s (%s, %s, %s)" ),
162 name.Printf( wxT(
"%s (%s,%s,%s,%s)" ),
171 name.Printf( wxT(
"%s (%s, %s)" ),
187 fullname.Printf( wxT(
"%d " ), aIdx + 1 );
193 name.Printf(
_(
"Graphic layer %d" ), aIdx + 1 );
306 wxString& matchedExtension )
309 matchedExtension =
"";
313 wxString ext = filename.Right( o.m_FilenameMask.length() ).Upper();
315 if( ext.Matches( o.m_FilenameMask ) )
318 matchedExtension = ext;
342 wxString ref_extension;
343 wxString test_extension;
354 unsigned long ref_layer_number = 0;
355 unsigned long test_layer_number = 0;
359 for( wxString::iterator it = ref_extension.begin(); it != ref_extension.end(); ++it )
361 if( !isdigit( *it ) )
365 for( wxString::iterator it = test_extension.begin(); it != test_extension.end(); ++it )
367 if( !isdigit( *it ) )
371 ref_extension.ToULong( &ref_layer_number );
372 test_extension.ToULong( &test_layer_number );
374 return ref_layer_number < test_layer_number;
377 return (
int) ref_layer < (int) test_layer;
401 if( !
test->m_FileFunction )
417 std::unordered_map<int, int> tab_lyr;
419 for(
unsigned layer = 0; layer <
m_GERBER_List.size(); ++layer )
434std::unordered_map<int, int>
455 unsigned int layer2 )
458 return std::unordered_map<int, int>();
467 return std::unordered_map<int, int>();
GERBER_FILE_IMAGE_LIST is a helper class to handle a list of GERBER_FILE_IMAGE files which are loaded...
int AddGbrImage(GERBER_FILE_IMAGE *aGbrImage, int aIdx)
Add a GERBER_FILE_IMAGE* at index aIdx or at the first free location if aIdx < 0.
std::unordered_map< int, int > SwapImages(unsigned int layer1, unsigned int layer2)
Swap two images and their orders.
unsigned GetLoadedImageCount()
Get number of loaded images.
static void GetGerberLayerFromFilename(const wxString &filename, enum GERBER_ORDER_ENUM &order, wxString &matchedExtension)
Utility function to guess which PCB layer of a gerber/drill file corresponds to based on its file ext...
std::unordered_map< int, int > SortImagesByZOrder()
Sort loaded images by Z order priority, if they have the X2 FileFormat info (SortImagesByZOrder updat...
void DeleteImage(unsigned int aIdx)
Delete the loaded data of image aIdx, freeing the memory.
std::unordered_map< int, int > SortImagesByFileExtension()
Sort loaded images by file extension matching.
static GERBER_FILE_IMAGE_LIST & GetImagesList()
const wxString GetDisplayName(int aIdx, bool aNameOnly=false, bool aFullName=false)
Get the display name for the layer at aIdx.
void DeleteAllImages()
Remove all loaded data in list, and delete all images, freeing the memory.
std::vector< GERBER_FILE_IMAGE * > m_GERBER_List
std::unordered_map< int, int > RemoveImage(unsigned int layer)
Removes (and deletes) an image, rotating the removed image to the end.
~GERBER_FILE_IMAGE_LIST()
std::unordered_map< int, int > GetLayerRemap()
When the image order has changed, call this to get a mapping to pass to the frame's Remap() function ...
std::unordered_map< int, int > SortImagesByFunction(LayerSortFunction sortFunction)
Sort loaded images by file extension matching.
GERBER_FILE_IMAGE * GetGbrImage(int aIdx)
Hold the image data and parameters for one gerber file and layer parameters.
X2_ATTRIBUTE_FILEFUNCTION * m_FileFunction
file function parameters, found in a TF command or a G04
wxString m_FileName
Full File Name for this layer.
bool m_InUse
true if this image is currently in use (a file is loaded in it) false if it must be not drawn
int m_GraphicLayer
Graphic layer Number.
bool IsCopper()
return true if the filefunction type is "Copper"
const wxString & GetLPType()
const wxString & GetRouteType()
const wxString & GetBrdLayerSide()
the brd layer Pos: Top, Bot, Inr same as GetBrdLayerId() for non copper type
const wxString & GetFileType()
the type of layer (Copper, Soldermask ... )
int GetZSubOrder()
the Order of the bdr copper layer, from front (Top) side to back (Bot) side
const wxString & GetBrdLayerId()
the brd layer identifier: Ln, only for Copper type or Top, Bot for other types
const wxString GetDrillLayerPair()
int GetZOrder()
the Order of the board layer, from front (Top) side to back (Bot) side
static struct GERBER_ORDER gerberFileExtensionOrder[]
static bool sortZorder(const GERBER_FILE_IMAGE *const &ref, const GERBER_FILE_IMAGE *const &test)
GERBER_FILE_IMAGE_LIST s_GERBER_List
static bool sortFileExtension(const GERBER_FILE_IMAGE *const &ref, const GERBER_FILE_IMAGE *const &test)
bool LayerSortFunction(const GERBER_FILE_IMAGE *const &ref, const GERBER_FILE_IMAGE *const &test)
@ GERBER_BOTTOM_SILK_SCREEN
@ GERBER_BOTTOM_SOLDER_MASK
#define GERBER_DRAWLAYERS_COUNT
Number of draw layers in Gerbview.
std::string m_FilenameMask
GERBER_ORDER_ENUM m_Order