KiCad PCB EDA Suite
gerber_file_image_list.cpp File Reference
#include <gerbview.h>
#include <gerbview_frame.h>
#include <gerber_file_image.h>
#include <gerber_file_image_list.h>
#include <X2_gerber_attributes.h>
#include <map>

Go to the source code of this file.

Classes

struct  GERBER_ORDER
 

Functions

static bool sortFileExtension (const GERBER_FILE_IMAGE *const &ref, const GERBER_FILE_IMAGE *const &test)
 
static bool sortZorder (const GERBER_FILE_IMAGE *const &ref, const GERBER_FILE_IMAGE *const &test)
 

Variables

GERBER_FILE_IMAGE_LIST s_GERBER_List
 
static struct GERBER_ORDER gerberFileExtensionOrder []
 

Function Documentation

◆ sortFileExtension()

static bool sortFileExtension ( const GERBER_FILE_IMAGE *const &  ref,
const GERBER_FILE_IMAGE *const &  test 
)
static

Definition at line 328 of file gerber_file_image_list.cpp.

330{
331 // Do not change order: no criteria to sort items
332 if( !ref && !test )
333 return false;
334
335 // Not used: ref ordered after
336 if( !ref || !ref->m_InUse )
337 return false;
338
339 // Not used: ref ordered before
340 if( !test || !test->m_InUse )
341 return true;
342
343 enum GERBER_ORDER_ENUM ref_layer;
344 enum GERBER_ORDER_ENUM test_layer;
345 wxString ref_extension;
346 wxString test_extension;
347
349 ref_extension );
351 test_extension );
352
353 // Inner layers have a numeric code that we can compare against
354 if( ref_layer == GERBER_ORDER_ENUM::GERBER_INNER
355 && test_layer == GERBER_ORDER_ENUM::GERBER_INNER )
356 {
357 unsigned long ref_layer_number = 0;
358 unsigned long test_layer_number = 0;
359
360 // Strip extensions down to only the numbers in it. Later conversion to int will
361 // automatically skip the spaces
362 for( wxString::iterator it = ref_extension.begin(); it != ref_extension.end(); ++it )
363 {
364 if( !isdigit( *it ) )
365 *it = ' ';
366 }
367
368 for( wxString::iterator it = test_extension.begin(); it != test_extension.end(); ++it )
369 {
370 if( !isdigit( *it ) )
371 *it = ' ';
372 }
373
374 ref_extension.ToULong( &ref_layer_number );
375 test_extension.ToULong( &test_layer_number );
376
377 return ref_layer_number < test_layer_number;
378 }
379
380 return (int) ref_layer < (int) test_layer;
381}
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...

References GERBER_INNER, GERBER_FILE_IMAGE_LIST::GetGerberLayerFromFilename(), GERBER_FILE_IMAGE::m_FileName, and GERBER_FILE_IMAGE::m_InUse.

Referenced by GERBER_FILE_IMAGE_LIST::SortImagesByFileExtension().

◆ sortZorder()

static bool sortZorder ( const GERBER_FILE_IMAGE *const &  ref,
const GERBER_FILE_IMAGE *const &  test 
)
static

Definition at line 387 of file gerber_file_image_list.cpp.

388{
389 if( !ref && !test )
390 return false; // do not change order: no criteria to sort items
391
392 if( !ref || !ref->m_InUse )
393 return false; // Not used: ref ordered after
394
395 if( !test || !test->m_InUse )
396 return true; // Not used: ref ordered before
397
398 if( !ref->m_FileFunction && !test->m_FileFunction )
399 return false; // do not change order: no criteria to sort items
400
401 if( !ref->m_FileFunction )
402 return false;
403
404 if( !test->m_FileFunction )
405 return true;
406
407 if( ref->m_FileFunction->GetZOrder() != test->m_FileFunction->GetZOrder() )
408 return ref->m_FileFunction->GetZOrder() > test->m_FileFunction->GetZOrder();
409
410 return ref->m_FileFunction->GetZSubOrder() > test->m_FileFunction->GetZSubOrder();
411}
X2_ATTRIBUTE_FILEFUNCTION * m_FileFunction
int GetZSubOrder()
the Order of the bdr copper layer, from front (Top) side to back (Bot) side
int GetZOrder()
the Order of the board layer, from front (Top) side to back (Bot) side

References X2_ATTRIBUTE_FILEFUNCTION::GetZOrder(), X2_ATTRIBUTE_FILEFUNCTION::GetZSubOrder(), GERBER_FILE_IMAGE::m_FileFunction, and GERBER_FILE_IMAGE::m_InUse.

Referenced by GERBER_FILE_IMAGE_LIST::SortImagesByZOrder().

Variable Documentation

◆ gerberFileExtensionOrder

struct GERBER_ORDER gerberFileExtensionOrder[]
static

◆ s_GERBER_List

GERBER_FILE_IMAGE_LIST s_GERBER_List

Definition at line 40 of file gerber_file_image_list.cpp.

Referenced by GERBER_FILE_IMAGE_LIST::GetImagesList().