KiCad PCB EDA Suite
GERBER_FILE_IMAGE Class Reference

GERBER_FILE_IMAGE holds the Image data and parameters for one gerber file and layer parameters (TODO: move them in GERBER_LAYER class. More...

#include <gerber_file_image.h>

Inheritance diagram for GERBER_FILE_IMAGE:
EDA_ITEM KIGFX::VIEW_ITEM INSPECTABLE EXCELLON_IMAGE

Public Member Functions

 GERBER_FILE_IMAGE (int layer)
 
virtual ~GERBER_FILE_IMAGE ()
 
wxString GetClass () const override
 Function GetClass returns the class name. More...
 
bool LoadGerberFile (const wxString &aFullFileName)
 Read and load a gerber file. More...
 
const wxArrayString & GetMessages () const
 
int GetDcodesCount ()
 
virtual void ResetDefaultValues ()
 
COLOR4D GetPositiveDrawColor () const
 
GERBER_DRAW_ITEMSGetItems ()
 
int GetItemsCount ()
 
void AddItemToList (GERBER_DRAW_ITEM *aItem)
 Add a new GERBER_DRAW_ITEM item to the drawings list. More...
 
GERBER_DRAW_ITEMGetLastItemInList () const
 
GERBER_LAYERGetLayerParams ()
 Function GetLayerParams. More...
 
bool HasNegativeItems ()
 Function HasNegativeItems. More...
 
void ClearMessageList ()
 Function ClearMessageList Clear the message list Call it before reading a Gerber file. More...
 
void AddMessageToList (const wxString &aMessage)
 Function AddMessageToList Add a message to the message list. More...
 
void InitToolTable ()
 Function InitToolTable. More...
 
wxPoint ReadXYCoord (char *&aText, bool aExcellonMode=false)
 Function ReadXYCoord Returns the current coordinate type pointed to by XnnYnn Text (XnnnnYmmmm) More...
 
wxPoint ReadIJCoord (char *&Text)
 Returns the current coordinate type pointed to by InnJnn Text (InnnnJmmmm) These coordinates are relative, so if coordinate is absent, it's value defaults to 0. More...
 
int GCodeNumber (char *&Text)
 
int DCodeNumber (char *&Text)
 
D_CODEGetDCODEOrCreate (int aDCODE, bool aCreateIfNoExist=true)
 Function GetDCODEOrCreate returns a pointer to the D_CODE within this GERBER for the given aDCODE. More...
 
D_CODEGetDCODE (int aDCODE) const
 Function GetDCODE returns a pointer to the D_CODE within this GERBER for the given aDCODE. More...
 
APERTURE_MACROFindApertureMacro (const APERTURE_MACRO &aLookup)
 Function FindApertureMacro looks up a previously read in aperture macro. More...
 
void StepAndRepeatItem (const GERBER_DRAW_ITEM &aItem)
 Function StepAndRepeatItem Gerber format has a command Step an Repeat This function must be called when reading a gerber file and after creating a new gerber item that must be repeated (i.e when m_XRepeatCount or m_YRepeatCount are > 1) More...
 
void DisplayImageInfo (GERBVIEW_FRAME *aMainFrame)
 Function DisplayImageInfo has knowledge about the frame and how and where to put status information about this object into the frame's message panel. More...
 
void RemoveAttribute (X2_ATTRIBUTE &aAttribute)
 Function RemoveAttribute. More...
 
SEARCH_RESULT Visit (INSPECTOR inspector, void *testData, const KICAD_T scanTypes[]) override
 

More...
 
KICAD_T Type () const
 Function Type() More...
 
EDA_ITEMGetParent () const
 
virtual void SetParent (EDA_ITEM *aParent)
 
bool IsModified () const
 
bool IsNew () const
 
bool IsMoving () const
 
bool IsDragging () const
 
bool IsWireImage () const
 
bool IsSelected () const
 
bool IsResized () const
 
bool IsBrightened () const
 
void SetWireImage ()
 
void SetSelected ()
 
void SetBrightened ()
 
void ClearSelected ()
 
void ClearBrightened ()
 
void SetModified ()
 
int GetState (int type) const
 
void SetState (int type, int state)
 
STATUS_FLAGS GetStatus () const
 
void SetStatus (STATUS_FLAGS aStatus)
 
void SetFlags (STATUS_FLAGS aMask)
 
void ClearFlags (STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
 
STATUS_FLAGS GetFlags () const
 
bool HasFlag (STATUS_FLAGS aFlag)
 
STATUS_FLAGS GetEditFlags () const
 
void ClearTempFlags ()
 
void ClearEditFlags ()
 
virtual bool IsType (const KICAD_T aScanTypes[]) const
 Function IsType Checks whether the item is one of the listed types. More...
 
void SetForceVisible (bool aEnable)
 Function SetForceVisible is used to set and cleag force visible flag used to force the item to be drawn even if it's draw attribute is set to not visible. More...
 
bool IsForceVisible () const
 
virtual void GetMsgPanelInfo (EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
 Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for display purposes. More...
 
virtual bool HitTest (const wxPoint &aPosition, int aAccuracy=0) const
 Function HitTest tests if aPosition is contained within or on the bounding box of an item. More...
 
virtual bool HitTest (const EDA_RECT &aRect, bool aContained, int aAccuracy=0) const
 Function HitTest tests if aRect intersects or is contained within the bounding box of an item. More...
 
virtual const EDA_RECT GetBoundingBox () const
 Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes. More...
 
virtual wxPoint GetPosition () const
 
virtual const wxPoint GetFocusPosition () const
 Function GetFocusPosition similar to GetPosition, but allows items to return their visual center rather than their anchor. More...
 
virtual EDA_ITEMClone () const
 Function Clone creates a duplicate of this item with linked list members set to NULL. More...
 
virtual wxString GetSelectMenuText (EDA_UNITS aUnits) const
 Function GetSelectMenuText returns the text to display to be used in the selection clarification context menu when multiple items are found at the current cursor position. More...
 
virtual BITMAP_DEF GetMenuImage () const
 Function GetMenuImage returns a pointer to an image to be used in menus. More...
 
virtual bool Matches (wxFindReplaceData &aSearchData, void *aAuxData)
 Function Matches compares the item against the search criteria in aSearchData. More...
 
virtual bool Replace (wxFindReplaceData &aSearchData, void *aAuxData=NULL)
 Function Replace performs a text replace using the find and replace criteria in aSearchData on items that support text find and replace. More...
 
virtual bool IsReplaceable () const
 Function IsReplaceable. More...
 
bool operator< (const EDA_ITEM &aItem) const
 Test if another item is less than this object. More...
 
virtual const BOX2I ViewBBox () const override
 Function ViewBBox() returns the bounding box of the item covering all its layers. More...
 
virtual void ViewGetLayers (int aLayers[], int &aCount) const override
 Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on. More...
 
virtual void ViewDraw (int aLayer, VIEW *aView) const
 Function ViewDraw() Draws the parts of the object belonging to layer aLayer. More...
 
virtual unsigned int ViewGetLOD (int aLayer, VIEW *aView) const
 Function ViewGetLOD() Returns the level of detail (LOD) of the item. More...
 
VIEW_ITEM_DATA * viewPrivData () const
 
void ClearViewPrivData ()
 
bool Set (PROPERTY_BASE *aProperty, wxAny &aValue)
 
template<typename T >
bool Set (PROPERTY_BASE *aProperty, T aValue)
 
template<typename T >
bool Set (const wxString &aProperty, T aValue)
 
wxAny Get (PROPERTY_BASE *aProperty)
 
template<typename T >
Get (PROPERTY_BASE *aProperty)
 
template<typename T >
boost::optional< T > Get (const wxString &aProperty)
 

Static Public Member Functions

template<class T >
static SEARCH_RESULT IterateForward (std::deque< T > &aList, INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
 IterateForward( EDA_ITEM*, INSPECTOR, void*, const KICAD_T ) More...
 
template<class T >
static SEARCH_RESULT IterateForward (std::vector< T > &aList, INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
 IterateForward( EDA_ITEM*, INSPECTOR, void*, const KICAD_T ) More...
 
static bool Replace (wxFindReplaceData &aSearchData, wxString &aText)
 Helper function used in search and replace dialog Function Replace performs a text replace on aText using the find and replace criteria in aSearchData on items that support text find and replace. More...
 
static bool Sort (const EDA_ITEM *aLeft, const EDA_ITEM *aRight)
 Function Sort is a helper function to be used by the C++ STL sort algorithm for sorting a STL container of EDA_ITEM pointers. More...
 

Public Attributes

bool m_InUse
 
bool m_IsVisible
 
COLOR4D m_PositiveDrawColor
 
wxString m_FileName
 
wxString m_ImageName
 
bool m_IsX2_file
 
X2_ATTRIBUTE_FILEFUNCTIONm_FileFunction
 
wxString m_MD5_value
 
wxString m_PartString
 
int m_GraphicLayer
 
bool m_ImageNegative
 
bool m_ImageJustifyXCenter
 
bool m_ImageJustifyYCenter
 
wxPoint m_ImageJustifyOffset
 
bool m_GerbMetric
 
bool m_Relative
 
bool m_NoTrailingZeros
 
wxPoint m_ImageOffset
 
wxSize m_FmtScale
 
wxSize m_FmtLen
 
int m_ImageRotation
 
double m_LocalRotation
 
wxPoint m_Offset
 
wxRealPoint m_Scale
 
bool m_SwapAxis
 
bool m_MirrorA
 
bool m_MirrorB
 
int m_Iterpolation
 
int m_Current_Tool
 
int m_Last_Pen_Command
 
int m_CommandState
 
int m_LineNum
 
wxPoint m_CurrentPos
 
wxPoint m_PreviousPos
 
wxPoint m_IJPos
 
bool m_LastCoordIsIJPos
 
int m_ArcRadius
 
LAST_EXTRA_ARC_DATA_TYPE m_LastArcDataType
 
FILE * m_Current_File
 
int m_Selected_Tool
 
bool m_Has_DCode
 
bool m_Has_MissingDCode
 
bool m_360Arc_enbl
 
bool m_AsArcG74G75Cmd
 
bool m_PolygonFillMode
 
int m_PolygonFillModeState
 
APERTURE_MACRO_SET m_aperture_macros
 a collection of APERTURE_MACROS, sorted by name More...
 
GBR_NETLIST_METADATA m_NetAttributeDict
 
wxString m_AperFunction
 
std::map< wxString, int > m_ComponentsList
 
std::map< wxString, int > m_NetnamesList
 
const KIID m_Uuid
 

Protected Member Functions

bool Matches (const wxString &aText, wxFindReplaceData &aSearchData)
 Function Matches compares aText against search criteria in aSearchData. More...
 

Protected Attributes

STATUS_FLAGS m_Status
 
EDA_ITEMm_Parent
 Linked list: Link (parent struct) More...
 
bool m_forceVisible
 
STATUS_FLAGS m_Flags
 

Private Member Functions

char * GetNextLine (char *aBuff, unsigned int aBuffSize, char *aText, FILE *aFile)
 test for an end of line if a end of line is found: read a new line More...
 
bool GetEndOfBlock (char *aBuff, unsigned int aBuffSize, char *&aText, FILE *aGerberFile)
 
bool ReadRS274XCommand (char *aBuff, unsigned int aBuffSize, char *&aText)
 reads a single RS274X command terminated with a % More...
 
bool ExecuteRS274XCommand (int aCommand, char *aBuff, unsigned int aBuffSize, char *&aText)
 executes a RS274X command More...
 
int ReadXCommandID (char *&text)
 reads two bytes of data and assembles them into an int with the first byte in the sequence put into the most significant part of a 16 bit value to build a RS274X command identifier. More...
 
bool ReadApertureMacro (char *aBuff, unsigned int aBuffSize, char *&text, FILE *gerber_file)
 reads in an aperture macro and saves it in m_aperture_macros. More...
 
bool Execute_G_Command (char *&text, int G_command)
 
bool Execute_DCODE_Command (char *&text, int D_command)
 

Private Attributes

D_CODEm_Aperture_List [TOOLS_MAX_COUNT]
 Dcode (Aperture) List for this layer (max TOOLS_MAX_COUNT: see dcode.h) More...
 
bool m_Exposure
 whether an aperture macro tool is flashed on or off More...
 
GERBER_LAYER m_GBRLayerParams
 
GERBER_DRAW_ITEMS m_drawings
 
wxArrayString m_messagesList
 
int m_hasNegativeItems
 

Detailed Description

GERBER_FILE_IMAGE holds the Image data and parameters for one gerber file and layer parameters (TODO: move them in GERBER_LAYER class.

Definition at line 109 of file gerber_file_image.h.

Constructor & Destructor Documentation

◆ GERBER_FILE_IMAGE()

GERBER_FILE_IMAGE::GERBER_FILE_IMAGE ( int  layer)

Definition at line 89 of file gerber_file_image.cpp.

89  :
91 {
92  m_GraphicLayer = aLayer; // Graphic layer Number
93  m_IsVisible = true; // must be drawn
94  m_PositiveDrawColor = WHITE; // The color used to draw positive items for this image
95 
96  m_Selected_Tool = 0;
97  m_FileFunction = NULL; // file function parameters
98 
100 
101  for( unsigned ii = 0; ii < arrayDim( m_Aperture_List ); ii++ )
102  m_Aperture_List[ii] = 0;
103 }
X2_ATTRIBUTE_FILEFUNCTION * m_FileFunction
D_CODE * m_Aperture_List[TOOLS_MAX_COUNT]
Dcode (Aperture) List for this layer (max TOOLS_MAX_COUNT: see dcode.h)
#define NULL
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType)
Definition: base_struct.cpp:59
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:160
Definition: color4d.h:48
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
virtual void ResetDefaultValues()

References arrayDim(), m_Aperture_List, m_FileFunction, m_GraphicLayer, m_IsVisible, m_PositiveDrawColor, m_Selected_Tool, NULL, ResetDefaultValues(), and WHITE.

◆ ~GERBER_FILE_IMAGE()

GERBER_FILE_IMAGE::~GERBER_FILE_IMAGE ( )
virtual

Definition at line 106 of file gerber_file_image.cpp.

107 {
108 
109  for( auto item : GetItems() )
110  delete item;
111 
112  m_drawings.clear();
113 
114  for( unsigned ii = 0; ii < arrayDim( m_Aperture_List ); ii++ )
115  {
116  delete m_Aperture_List[ii];
117  }
118 
119  delete m_FileFunction;
120 }
X2_ATTRIBUTE_FILEFUNCTION * m_FileFunction
GERBER_DRAW_ITEMS & GetItems()
D_CODE * m_Aperture_List[TOOLS_MAX_COUNT]
Dcode (Aperture) List for this layer (max TOOLS_MAX_COUNT: see dcode.h)
GERBER_DRAW_ITEMS m_drawings
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:160

References arrayDim(), GetItems(), m_Aperture_List, m_drawings, and m_FileFunction.

Member Function Documentation

◆ AddItemToList()

void GERBER_FILE_IMAGE::AddItemToList ( GERBER_DRAW_ITEM aItem)
inline

Add a new GERBER_DRAW_ITEM item to the drawings list.

Parameters
aItemis the GERBER_DRAW_ITEM to add to list

Definition at line 290 of file gerber_file_image.h.

291  {
292  m_drawings.push_back( aItem );
293  }
GERBER_DRAW_ITEMS m_drawings

References m_drawings.

Referenced by Execute_DCODE_Command(), EXCELLON_IMAGE::Execute_Drill_Command(), EXCELLON_IMAGE::FinishRouteCommand(), and StepAndRepeatItem().

◆ AddMessageToList()

void GERBER_FILE_IMAGE::AddMessageToList ( const wxString &  aMessage)
inline

◆ ClearBrightened()

void EDA_ITEM::ClearBrightened ( )
inlineinherited

◆ ClearEditFlags()

◆ ClearFlags()

void EDA_ITEM::ClearFlags ( STATUS_FLAGS  aMask = EDA_ITEM_ALL_FLAGS)
inlineinherited

Definition at line 233 of file base_struct.h.

233 { m_Flags &= ~aMask; }
STATUS_FLAGS m_Flags
Definition: base_struct.h:176

References EDA_ITEM::m_Flags.

Referenced by FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), PNS_KICAD_IFACE::AddItem(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), SCH_SCREEN::ClearAnnotation(), EDA_ITEM::ClearBrightened(), EDA_ITEM::ClearEditFlags(), clearModuleItemFlags(), EDA_ITEM::ClearSelected(), EDA_ITEM::ClearTempFlags(), SCH_EDIT_FRAME::ConvertPart(), LIB_EDIT_TOOL::Copy(), MICROWAVE_TOOL::createMicrowaveInductor(), SCH_EDIT_FRAME::DeleteAnnotation(), DIALOG_LIB_EDIT_PIN::DIALOG_LIB_EDIT_PIN(), DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES(), KIGFX::SCH_PAINTER::draw(), LIB_EDIT_TOOL::Duplicate(), SCH_ITEM::Duplicate(), PCB_EDIT_FRAME::Exchange_Module(), LIB_EDIT_FRAME::GetComponentFromRedoList(), LIB_EDIT_FRAME::GetComponentFromUndoList(), FOOTPRINT_EDITOR_TOOLS::ImportFootprint(), FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD(), FOOTPRINT_EDIT_FRAME::LoadModuleFromLibrary(), FOOTPRINT_EDIT_FRAME::OpenProjectFiles(), PCB_BASE_FRAME::PlaceModule(), LIB_PIN_TOOL::PlacePin(), DRAWING_TOOL::PlaceText(), FOOTPRINT_EDIT_FRAME::Process_Special_Functions(), BOARD_COMMIT::Push(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_PIN_TOOL::RepeatPin(), LIB_EDIT_FRAME::RollbackPartFromUndo(), SCH_EDIT_FRAME::SaveCopyForRepeatItem(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), SCH_SEXPR_PLUGIN_CACHE::savePin(), SCH_LEGACY_PLUGIN_CACHE::savePin(), EE_SELECTION_TOOL::SelectPoint(), SCH_EDIT_FRAME::SelectUnit(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ ClearMessageList()

void GERBER_FILE_IMAGE::ClearMessageList ( )
inline

Function ClearMessageList Clear the message list Call it before reading a Gerber file.

Definition at line 325 of file gerber_file_image.h.

326  {
327  m_messagesList.Clear();
328  }
wxArrayString m_messagesList

References m_messagesList.

Referenced by EXCELLON_IMAGE::LoadFile(), and LoadGerberFile().

◆ ClearSelected()

◆ ClearTempFlags()

void EDA_ITEM::ClearTempFlags ( )
inlineinherited

Definition at line 245 of file base_struct.h.

246  {
248  DO_NOT_DRAW );
249  }
#define IS_LINKED
Used in calculation to mark linked items (temporary use)
Definition: base_struct.h:114
#define TEMP_SELECTED
flag indicating that the structure has already selected
Definition: base_struct.h:125
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: base_struct.h:128
#define CANDIDATE
flag indicating that the structure is connected
Definition: base_struct.h:127
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:123
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:233
#define DO_NOT_DRAW
Used to disable draw function.
Definition: base_struct.h:129
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: base_struct.h:122

References CANDIDATE, EDA_ITEM::ClearFlags(), DO_NOT_DRAW, ENDPOINT, IS_LINKED, SKIP_STRUCT, STARTPOINT, and TEMP_SELECTED.

Referenced by SCH_EDIT_FRAME::PutDataInPreviousState().

◆ ClearViewPrivData()

void KIGFX::VIEW_ITEM::ClearViewPrivData ( )
inlineinherited

Definition at line 154 of file view_item.h.

155  {
157  }
VIEW_ITEM_DATA * m_viewPrivData
Definition: view_item.h:162
#define NULL

References KIGFX::VIEW_ITEM::m_viewPrivData, and NULL.

Referenced by KIGFX::VIEW::OnDestroy().

◆ Clone()

EDA_ITEM * EDA_ITEM::Clone ( ) const
virtualinherited

Function Clone creates a duplicate of this item with linked list members set to NULL.

The default version will return NULL in release builds and likely crash the program. In debug builds, a warning message indicating the derived class has not implemented cloning. This really should be a pure virtual function. Due to the fact that there are so many objects derived from EDA_ITEM, the decision was made to return NULL until all the objects derived from EDA_ITEM implement cloning. Once that happens, this function should be made pure.

Returns
A clone of the item.

Reimplemented in MODULE_ZONE_CONTAINER, ZONE_CONTAINER, SCH_COMPONENT, MODULE, SCH_SHEET, D_PAD, SCH_HIERLABEL, LIB_PIN, VIA, SCH_GLOBALLABEL, SCH_LABEL, ARC, SCH_TEXT, DRAWSEGMENT, DIMENSION, SCH_LINE, TRACK, TEXTE_MODULE, SCH_BUS_BUS_ENTRY, SCH_SHEET_PIN, SCH_FIELD, LIB_FIELD, SCH_BUS_WIRE_ENTRY, SCH_BITMAP, EDGE_MODULE, LIB_ARC, TEXTE_PCB, SCH_NO_CONNECT, SCH_JUNCTION, LIB_POLYLINE, SCH_MARKER, LIB_TEXT, PCB_TARGET, LIB_BEZIER, LIB_CIRCLE, LIB_RECTANGLE, and KIGFX::ORIGIN_VIEWITEM.

Definition at line 110 of file base_struct.cpp.

111 {
112  wxCHECK_MSG( false, NULL, wxT( "Clone not implemented in derived class " ) + GetClass() +
113  wxT( ". Bad programmer!" ) );
114 }
#define NULL
virtual wxString GetClass() const =0
Function GetClass returns the class name.

References EDA_ITEM::GetClass(), and NULL.

Referenced by LIB_DRAWING_TOOLS::DrawShape(), LIB_EDIT_TOOL::Duplicate(), BOARD_ITEM::Duplicate(), SCH_ITEM::Duplicate(), LIB_PART::LIB_PART(), LIB_EDIT_FRAME::LoadOneSymbol(), new_clone(), LIB_PART::operator=(), LIB_EDIT_TOOL::Paste(), SCH_SEXPR_PLUGIN_CACHE::removeSymbol(), SCH_LEGACY_PLUGIN_CACHE::removeSymbol(), SCH_EDIT_FRAME::SaveCopyForRepeatItem(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), LIB_PART::SetConversion(), LIB_PART::SetUnitCount(), SCH_DRAWING_TOOLS::SingleClickPlace(), COMMIT::Stage(), LIB_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ DCodeNumber()

int GERBER_FILE_IMAGE::DCodeNumber ( char *&  Text)

Definition at line 434 of file rs274d.cpp.

435 {
436  int ii = 0;
437  char* text;
438  char line[1024];
439 
440  if( Text == NULL )
441  return 0;
442 
443  Text++;
444  text = line;
445  while( IsNumber( *Text ) )
446  *(text++) = *(Text++);
447 
448  *text = 0;
449  ii = atoi( line );
450  return ii;
451 }
#define NULL
#define IsNumber(x)

References IsNumber, and NULL.

Referenced by Execute_G_Command(), LoadGerberFile(), and EXCELLON_IMAGE::TCodeNumber().

◆ DisplayImageInfo()

void GERBER_FILE_IMAGE::DisplayImageInfo ( GERBVIEW_FRAME aMainFrame)

Function DisplayImageInfo has knowledge about the frame and how and where to put status information about this object into the frame's message panel.

Display info about Image Parameters.

Parameters
aMainFrame= the GERBVIEW_FRAME to display messages

Display info about Image Parameters. These parameters are valid for the entire file, and must set only once (If more than once, only the last value is used)

Definition at line 334 of file gerber_file_image.cpp.

335 {
336  wxString msg;
337 
338  aMainFrame->ClearMsgPanel();
339 
340  // Display Image name (Image specific)
341  aMainFrame->AppendMsgPanel( _( "Image name" ), m_ImageName, CYAN );
342 
343  // Display graphic layer number used to draw this Image
344  // (not a Gerber parameter but is also image specific)
345  msg.Printf( wxT( "%d" ), m_GraphicLayer + 1 );
346  aMainFrame->AppendMsgPanel( _( "Graphic layer" ), msg, BROWN );
347 
348  // Display Image rotation (Image specific)
349  msg.Printf( wxT( "%d" ), m_ImageRotation );
350  aMainFrame->AppendMsgPanel( _( "Img Rot." ), msg, CYAN );
351 
352  // Display Image polarity (Image specific)
353  msg = m_ImageNegative ? _("Negative") : _("Normal");
354  aMainFrame->AppendMsgPanel( _( "Polarity" ), msg, BROWN );
355 
356  // Display Image justification and offset for justification (Image specific)
357  msg = m_ImageJustifyXCenter ? _("Center") : _("Normal");
358  aMainFrame->AppendMsgPanel( _( "X Justify" ), msg, DARKRED );
359 
360  msg = m_ImageJustifyYCenter ? _("Center") : _("Normal");
361  aMainFrame->AppendMsgPanel( _( "Y Justify" ), msg, DARKRED );
362 
363  if( aMainFrame->GetUserUnits() == EDA_UNITS::INCHES )
364  msg.Printf( wxT( "X=%f Y=%f" ), Iu2Mils( m_ImageJustifyOffset.x ) / 1000.0,
365  Iu2Mils( m_ImageJustifyOffset.y ) / 1000.0 );
366  else
367  msg.Printf( wxT( "X=%f Y=%f" ), Iu2Millimeter( m_ImageJustifyOffset.x ),
368  Iu2Millimeter( m_ImageJustifyOffset.y ) );
369 
370  aMainFrame->AppendMsgPanel( _( "Image Justify Offset" ), msg, DARKRED );
371 }
Definition: color4d.h:61
Definition: color4d.h:58
virtual void ClearMsgPanel()
Clear all messages from the message panel.
void AppendMsgPanel(const wxString &textUpper, const wxString &textLower, COLOR4D color, int pad=6)
Append a message to the message panel.
#define _(s)
Definition: 3d_actions.cpp:33
EDA_UNITS GetUserUnits() const
Return the user units currently in use.

References _, EDA_DRAW_FRAME::AppendMsgPanel(), BROWN, EDA_DRAW_FRAME::ClearMsgPanel(), CYAN, DARKRED, EDA_BASE_FRAME::GetUserUnits(), INCHES, m_GraphicLayer, m_ImageJustifyOffset, m_ImageJustifyXCenter, m_ImageJustifyYCenter, m_ImageName, m_ImageNegative, m_ImageRotation, wxPoint::x, and wxPoint::y.

Referenced by GERBVIEW_FRAME::UpdateTitleAndInfo().

◆ Execute_DCODE_Command()

bool GERBER_FILE_IMAGE::Execute_DCODE_Command ( char *&  text,
int  D_command 
)
private

Definition at line 587 of file rs274d.cpp.

588 {
589  wxSize size( 15, 15 );
590 
591  APERTURE_T aperture = APT_CIRCLE;
592  GERBER_DRAW_ITEM* gbritem;
593 
594  int dcode = 0;
595  D_CODE* tool = NULL;
596  wxString msg;
597 
598  if( D_commande >= FIRST_DCODE ) // This is a "Set tool" command
599  {
600  if( D_commande > (TOOLS_MAX_COUNT - 1) )
601  D_commande = TOOLS_MAX_COUNT - 1;
602 
603  // remember which tool is selected, nothing is done with it in this
604  // call
605  m_Current_Tool = D_commande;
606 
607  D_CODE* pt_Dcode = GetDCODE( D_commande );
608 
609  if( pt_Dcode )
610  pt_Dcode->m_InUse = true;
611  else
612  m_Has_MissingDCode = true;
613 
614  return true;
615  }
616  else // D_commande = 0..9: this is a pen command (usually D1, D2 or D3)
617  {
618  m_Last_Pen_Command = D_commande;
619  }
620 
621  if( m_PolygonFillMode ) // Enter a polygon description:
622  {
623  switch( D_commande )
624  {
625  case 1: // code D01 Draw line, exposure ON
626  if( !m_Exposure ) // Start a new polygon outline:
627  {
628  m_Exposure = true;
629  gbritem = new GERBER_DRAW_ITEM( this );
630  AddItemToList( gbritem );
631  gbritem->m_Shape = GBR_POLYGON;
632  gbritem->m_Flashed = false;
633  gbritem->m_DCode = 0; // No DCode for a Polygon (Region in Gerber dialect)
634 
635 
636  if( gbritem->m_GerberImageFile )
637  {
639  gbritem->m_AperFunction = gbritem->m_GerberImageFile->m_AperFunction;
640  }
641  }
642 
643  switch( m_Iterpolation )
644  {
647  // Before any arc command, a G74 or G75 command must be set.
648  // Otherwise the Gerber file is invalid
649  if( !m_AsArcG74G75Cmd )
650  {
651  AddMessageToList( _( "Invalid Gerber file: missing G74 or G75 arc command" ) );
652  // Disable further warning messages:
653  m_AsArcG74G75Cmd = true;
654  }
655 
656  gbritem = GetLastItemInList();
657 
658  fillArcPOLY( gbritem, m_PreviousPos,
660  ( m_Iterpolation == GERB_INTERPOL_ARC_NEG ) ? false : true,
661  m_360Arc_enbl, GetLayerParams().m_LayerNegative );
662  break;
663 
664  default:
665  gbritem = GetLastItemInList();
666 
667  gbritem->m_Start = m_PreviousPos; // m_Start is used as temporary storage
668  if( gbritem->m_Polygon.OutlineCount() == 0 )
669  {
670  gbritem->m_Polygon.NewOutline();
671  gbritem->m_Polygon.Append( VECTOR2I( gbritem->m_Start ) );
672  }
673 
674  gbritem->m_End = m_CurrentPos; // m_End is used as temporary storage
675  gbritem->m_Polygon.Append( VECTOR2I( gbritem->m_End ) );
676  break;
677  }
678 
681  break;
682 
683  case 2: // code D2: exposure OFF (i.e. "move to")
684  if( m_Exposure && GetLastItemInList() ) // End of polygon
685  {
686  gbritem = GetLastItemInList();
687  gbritem->m_Polygon.Append( gbritem->m_Polygon.CVertex( 0 ) );
688  StepAndRepeatItem( *gbritem );
689  }
690  m_Exposure = false;
693  break;
694 
695  default:
696  return false;
697  }
698  }
699  else
700  {
701  switch( D_commande )
702  {
703  case 1: // code D01 Draw line, exposure ON
704  m_Exposure = true;
705 
706  tool = GetDCODE( m_Current_Tool );
707 
708  if( tool )
709  {
710  size = tool->m_Size;
711  dcode = tool->m_Num_Dcode;
712  aperture = tool->m_Shape;
713  }
714 
715  switch( m_Iterpolation )
716  {
718  gbritem = new GERBER_DRAW_ITEM( this );
719  AddItemToList( gbritem );
720 
721  fillLineGBRITEM( gbritem, dcode, m_PreviousPos,
722  m_CurrentPos, size, GetLayerParams().m_LayerNegative );
723  StepAndRepeatItem( *gbritem );
724  break;
725 
728  gbritem = new GERBER_DRAW_ITEM( this );
729  AddItemToList( gbritem );
730 
731  if( m_LastCoordIsIJPos )
732  {
733  fillArcGBRITEM( gbritem, dcode, m_PreviousPos,
734  m_CurrentPos, m_IJPos, size,
736  false : true, m_360Arc_enbl, GetLayerParams().m_LayerNegative );
737  m_LastCoordIsIJPos = false;
738  }
739  else
740  {
741  fillLineGBRITEM( gbritem, dcode, m_PreviousPos,
742  m_CurrentPos, size, GetLayerParams().m_LayerNegative );
743  }
744 
745  StepAndRepeatItem( *gbritem );
746 
747  break;
748 
749  default:
750  msg.Printf( wxT( "RS274D: DCODE Command: interpol error (type %X)" ),
751  m_Iterpolation );
752  AddMessageToList( msg );
753  break;
754  }
755 
757  break;
758 
759  case 2: // code D2: exposure OFF (i.e. "move to")
760  m_Exposure = false;
762  break;
763 
764  case 3: // code D3: flash aperture
765  tool = GetDCODE( m_Current_Tool );
766  if( tool )
767  {
768  size = tool->m_Size;
769  dcode = tool->m_Num_Dcode;
770  aperture = tool->m_Shape;
771  }
772 
773  gbritem = new GERBER_DRAW_ITEM( this );
774  AddItemToList( gbritem );
775  fillFlashedGBRITEM( gbritem, aperture, dcode, m_CurrentPos,
776  size, GetLayerParams().m_LayerNegative );
777  StepAndRepeatItem( *gbritem );
779  break;
780 
781  default:
782  return false;
783  }
784  }
785 
786  return true;
787 }
void AddMessageToList(const wxString &aMessage)
Function AddMessageToList Add a message to the message list.
int OutlineCount() const
Returns the number of outlines in the set
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:94
static void fillArcPOLY(GERBER_DRAW_ITEM *aGbrItem, const wxPoint &aStart, const wxPoint &aEnd, const wxPoint &rel_center, bool aClockwise, bool aMultiquadrant, bool aLayerNegative)
Function fillArcPOLY creates an arc G code when found in poly outlines.
Definition: rs274d.cpp:334
bool m_InUse
false if the aperure (previously defined) is not used to draw something
Definition: dcode.h:102
APERTURE_T m_Shape
shape ( Line, rectangle, circle , oval .. )
Definition: dcode.h:95
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Returns the index-th vertex in a given hole outline within a given outline
D_CODE * GetDCODE(int aDCODE) const
Function GetDCODE returns a pointer to the D_CODE within this GERBER for the given aDCODE.
void SetNetAttributes(const GBR_NETLIST_METADATA &aNetAttributes)
void fillLineGBRITEM(GERBER_DRAW_ITEM *aGbrItem, int Dcode_index, const wxPoint &aStart, const wxPoint &aEnd, wxSize aPenSize, bool aLayerNegative)
Function fillLineGBRITEM initializes a given GBRITEM so that it can draw a linear D code.
Definition: rs274d.cpp:158
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
SHAPE_POLY_SET m_Polygon
GERBER_DRAW_ITEM * GetLastItemInList() const
void AddItemToList(GERBER_DRAW_ITEM *aItem)
Add a new GERBER_DRAW_ITEM item to the drawings list.
#define NULL
#define FIRST_DCODE
Definition: dcode.h:71
APERTURE_T
Enum APERTURE_T is the set of all gerber aperture types allowed, according to page 16 of http://gerbv...
Definition: dcode.h:50
int m_Num_Dcode
D code value ( >= 10 )
Definition: dcode.h:96
int NewOutline()
Creates a new empty polygon in the set and returns its index
void fillArcGBRITEM(GERBER_DRAW_ITEM *aGbrItem, int Dcode_index, const wxPoint &aStart, const wxPoint &aEnd, const wxPoint &aRelCenter, wxSize aPenSize, bool aClockwise, bool aMultiquadrant, bool aLayerNegative)
Function fillArcGBRITEM initializes a given GBRITEM so that it can draw an arc G code.
Definition: rs274d.cpp:207
bool m_Exposure
whether an aperture macro tool is flashed on or off
D_CODE holds a gerber DCODE (also called Aperture) definition.
Definition: dcode.h:82
void fillFlashedGBRITEM(GERBER_DRAW_ITEM *aGbrItem, APERTURE_T aAperture, int Dcode_index, const wxPoint &aPos, wxSize aSize, bool aLayerNegative)
Function fillFlashedGBRITEM initializes a given GBRITEM so that it can draw a circle which is filled ...
Definition: rs274d.cpp:103
#define _(s)
Definition: 3d_actions.cpp:33
GBR_NETLIST_METADATA m_NetAttributeDict
#define TOOLS_MAX_COUNT
Definition: dcode.h:73
void StepAndRepeatItem(const GERBER_DRAW_ITEM &aItem)
Function StepAndRepeatItem Gerber format has a command Step an Repeat This function must be called wh...
GERBER_FILE_IMAGE * m_GerberImageFile
GERBER_LAYER & GetLayerParams()
Function GetLayerParams.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)

References _, AddItemToList(), AddMessageToList(), SHAPE_POLY_SET::Append(), APT_CIRCLE, SHAPE_POLY_SET::CVertex(), fillArcGBRITEM(), fillArcPOLY(), fillFlashedGBRITEM(), fillLineGBRITEM(), FIRST_DCODE, GBR_POLYGON, GERB_INTERPOL_ARC_NEG, GERB_INTERPOL_ARC_POS, GERB_INTERPOL_LINEAR_1X, GetDCODE(), GetLastItemInList(), GetLayerParams(), m_360Arc_enbl, GERBER_DRAW_ITEM::m_AperFunction, m_AperFunction, m_AsArcG74G75Cmd, m_Current_Tool, m_CurrentPos, GERBER_DRAW_ITEM::m_DCode, GERBER_DRAW_ITEM::m_End, m_Exposure, GERBER_DRAW_ITEM::m_Flashed, GERBER_DRAW_ITEM::m_GerberImageFile, m_Has_MissingDCode, m_IJPos, D_CODE::m_InUse, m_Iterpolation, m_Last_Pen_Command, m_LastCoordIsIJPos, m_NetAttributeDict, D_CODE::m_Num_Dcode, GERBER_DRAW_ITEM::m_Polygon, m_PolygonFillMode, m_PolygonFillModeState, m_PreviousPos, GERBER_DRAW_ITEM::m_Shape, D_CODE::m_Shape, D_CODE::m_Size, GERBER_DRAW_ITEM::m_Start, SHAPE_POLY_SET::NewOutline(), NULL, SHAPE_POLY_SET::OutlineCount(), GERBER_DRAW_ITEM::SetNetAttributes(), StepAndRepeatItem(), and TOOLS_MAX_COUNT.

Referenced by LoadGerberFile().

◆ Execute_G_Command()

bool GERBER_FILE_IMAGE::Execute_G_Command ( char *&  text,
int  G_command 
)
private

Definition at line 454 of file rs274d.cpp.

455 {
456 // D( printf( "%22s: G_CODE<%d>\n", __func__, G_command ); )
457 
458  switch( G_command )
459  {
460  case GC_PHOTO_MODE: // can starts a D03 flash command: redundant, can
461  // be safely ignored
462  break;
463 
466  break;
467 
470  break;
471 
474  break;
475 
476  case GC_COMMENT:
477  // Skip comment, but only if the line does not start by "G04 #@! "
478  // which is a metadata, i.e. a X2 command inside the comment.
479  // this comment is called a "structured comment"
480  if( strncmp( text, " #@! ", 5 ) == 0 )
481  {
482  text += 5;
483  // The string starting at text is the same as the X2 attribute,
484  // but a X2 attribute ends by '%'. So we build the X2 attribute string
485  std::string x2buf;
486 
487  while( *text && (*text != '*') )
488  {
489  x2buf += *text;
490  text++;
491  }
492  // add the end of X2 attribute string
493  x2buf += "*%";
494  x2buf += '\0';
495 
496  char* cptr = (char*)x2buf.data();
497  int code_command = ReadXCommandID( cptr );
498  ExecuteRS274XCommand( code_command, NULL, 0, cptr );
499  }
500 
501  while( *text && (*text != '*') )
502  text++;
503  break;
504 
505  case GC_SELECT_TOOL:
506  {
507  int D_commande = DCodeNumber( text );
508 
509  if( D_commande < FIRST_DCODE )
510  return false;
511  if( D_commande > (TOOLS_MAX_COUNT - 1) )
512  D_commande = TOOLS_MAX_COUNT - 1;
513  m_Current_Tool = D_commande;
514  D_CODE* pt_Dcode = GetDCODE( D_commande );
515 
516  if( pt_Dcode )
517  pt_Dcode->m_InUse = true;
518 
519  break;
520  }
521 
522  case GC_SPECIFY_INCHES:
523  m_GerbMetric = false; // false = Inches, true = metric
524  break;
525 
527  m_GerbMetric = true; // false = Inches, true = metric
528  break;
529 
530  case GC_TURN_OFF_360_INTERPOL: // disable Multi cadran arc and Arc interpol
531  m_360Arc_enbl = false;
532  m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // not sure it should be done
533  m_AsArcG74G75Cmd = true;
534  break;
535 
537  m_360Arc_enbl = true;
538  m_AsArcG74G75Cmd = true;
539  break;
540 
542  m_Relative = false; // false = absolute Coord, true = relative
543  // Coord
544  break;
545 
547  m_Relative = true; // false = absolute Coord, true = relative
548  // Coord
549  break;
550 
552  m_PolygonFillMode = true;
553  m_Exposure = false;
554  break;
555 
557  if( m_Exposure && GetLastItemInList() ) // End of polygon
558  {
559  GERBER_DRAW_ITEM * gbritem = GetLastItemInList();
560 
561  if( gbritem->m_Polygon.VertexCount() )
562  gbritem->m_Polygon.Append( gbritem->m_Polygon.CVertex( 0 ) );
563 
564  StepAndRepeatItem( *gbritem );
565  }
566  m_Exposure = false;
567  m_PolygonFillMode = false;
569  m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // not sure it should be done
570  break;
571 
572  case GC_MOVE: // Non existent
573  default:
574  {
575  wxString msg;
576  msg.Printf( wxT( "G%0.2d command not handled" ), G_command );
577  AddMessageToList( msg );
578  return false;
579  }
580  }
581 
582 
583  return true;
584 }
void AddMessageToList(const wxString &aMessage)
Function AddMessageToList Add a message to the message list.
bool m_InUse
false if the aperure (previously defined) is not used to draw something
Definition: dcode.h:102
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Returns the index-th vertex in a given hole outline within a given outline
int VertexCount(int aOutline=-1, int aHole=-1) const
Returns the number of vertices in a given outline/hole
D_CODE * GetDCODE(int aDCODE) const
Function GetDCODE returns a pointer to the D_CODE within this GERBER for the given aDCODE.
SHAPE_POLY_SET m_Polygon
int ReadXCommandID(char *&text)
reads two bytes of data and assembles them into an int with the first byte in the sequence put into t...
Definition: rs274x.cpp:116
bool ExecuteRS274XCommand(int aCommand, char *aBuff, unsigned int aBuffSize, char *&aText)
executes a RS274X command
Definition: rs274x.cpp:199
GERBER_DRAW_ITEM * GetLastItemInList() const
#define NULL
#define FIRST_DCODE
Definition: dcode.h:71
int DCodeNumber(char *&Text)
Definition: rs274d.cpp:434
bool m_Exposure
whether an aperture macro tool is flashed on or off
D_CODE holds a gerber DCODE (also called Aperture) definition.
Definition: dcode.h:82
#define TOOLS_MAX_COUNT
Definition: dcode.h:73
void StepAndRepeatItem(const GERBER_DRAW_ITEM &aItem)
Function StepAndRepeatItem Gerber format has a command Step an Repeat This function must be called wh...
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)

References AddMessageToList(), SHAPE_POLY_SET::Append(), SHAPE_POLY_SET::CVertex(), DCodeNumber(), ExecuteRS274XCommand(), FIRST_DCODE, GC_CIRCLE_NEG_INTERPOL, GC_CIRCLE_POS_INTERPOL, GC_COMMENT, GC_LINEAR_INTERPOL_1X, GC_MOVE, GC_PHOTO_MODE, GC_SELECT_TOOL, GC_SPECIFY_ABSOLUES_COORD, GC_SPECIFY_INCHES, GC_SPECIFY_MILLIMETERS, GC_SPECIFY_RELATIVEES_COORD, GC_TURN_OFF_360_INTERPOL, GC_TURN_OFF_POLY_FILL, GC_TURN_ON_360_INTERPOL, GC_TURN_ON_POLY_FILL, GERB_INTERPOL_ARC_NEG, GERB_INTERPOL_ARC_POS, GERB_INTERPOL_LINEAR_1X, GetDCODE(), GetLastItemInList(), m_360Arc_enbl, m_AsArcG74G75Cmd, m_Current_Tool, m_Exposure, m_GerbMetric, D_CODE::m_InUse, m_Iterpolation, GERBER_DRAW_ITEM::m_Polygon, m_PolygonFillMode, m_PolygonFillModeState, m_Relative, NULL, ReadXCommandID(), StepAndRepeatItem(), TOOLS_MAX_COUNT, and SHAPE_POLY_SET::VertexCount().

Referenced by LoadGerberFile().

◆ ExecuteRS274XCommand()

bool GERBER_FILE_IMAGE::ExecuteRS274XCommand ( int  aCommand,
char *  aBuff,
unsigned int  aBuffSize,
char *&  aText 
)
private

executes a RS274X command

Definition at line 199 of file rs274x.cpp.

201 {
202  int code;
203  int seq_len; // not used, just provided
204  int seq_char;
205  bool ok = true;
206  wxString msg;
207  double fcoord;
208  bool x_fmt_known = false;
209  bool y_fmt_known = false;
210 
211  // conv_scale = scaling factor from inch to Internal Unit
212  double conv_scale = IU_PER_MILS * 1000;
213 
214  if( m_GerbMetric )
215  conv_scale /= 25.4;
216 
217  switch( aCommand )
218  {
219  case FORMAT_STATEMENT:
220  seq_len = 2;
221 
222  while( *aText != '*' )
223  {
224  switch( *aText )
225  {
226  case ' ':
227  aText++;
228  break;
229 
230  case 'D': // Non-standard option for all zeros (leading + tailing)
231  msg.Printf( _( "RS274X: Invalid GERBER format command '%c' at line %d: \"%s\"" ),
232  'D', m_LineNum, aBuff );
233  AddMessageToList( msg );
234  msg.Printf( _("GERBER file \"%s\" may not display as intended." ),
235  m_FileName.ToAscii() );
236  AddMessageToList( msg );
238 
239  case 'L': // No Leading 0
240  m_NoTrailingZeros = false;
241  aText++;
242  break;
243 
244  case 'T': // No trailing 0
245  m_NoTrailingZeros = true;
246  aText++;
247  break;
248 
249  case 'A': // Absolute coord
250  m_Relative = false;
251  aText++;
252  break;
253 
254  case 'I': // Relative coord
255  m_Relative = true;
256  aText++;
257  break;
258 
259  case 'G':
260  case 'N': // Sequence code (followed by one digit: the sequence len)
261  // (sometimes found before the X,Y sequence)
262  // Obscure option
263  aText++;
264  seq_char = *aText++;
265  if( (seq_char >= '0') && (seq_char <= '9') )
266  seq_len = seq_char - '0';
267  break;
268 
269  case 'M': // Sequence code (followed by one digit: the sequence len)
270  // (sometimes found after the X,Y sequence)
271  // Obscure option
272  code = *aText++;
273  if( ( *aText >= '0' ) && ( *aText<= '9' ) )
274  aText++; // skip the digit
275  break;
276 
277  case 'X':
278  case 'Y':
279  {
280  code = *(aText++);
281  char ctmp = *(aText++) - '0';
282  if( code == 'X' )
283  {
284  x_fmt_known = true;
285  // number of digits after the decimal point (0 to 7 allowed)
286  m_FmtScale.x = *aText - '0';
287  m_FmtLen.x = ctmp + m_FmtScale.x;
288 
289  // m_FmtScale is 0 to 7
290  // (Old Gerber specification was 0 to 6)
291  if( m_FmtScale.x < 0 )
292  m_FmtScale.x = 0;
293  if( m_FmtScale.x > 7 )
294  m_FmtScale.x = 7;
295  }
296  else
297  {
298  y_fmt_known = true;
299  m_FmtScale.y = *aText - '0';
300  m_FmtLen.y = ctmp + m_FmtScale.y;
301  if( m_FmtScale.y < 0 )
302  m_FmtScale.y = 0;
303  if( m_FmtScale.y > 7 )
304  m_FmtScale.y = 7;
305  }
306  aText++;
307  }
308  break;
309 
310  case '*':
311  break;
312 
313  default:
314  msg.Printf( wxT( "Unknown id (%c) in FS command" ),
315  *aText );
316  AddMessageToList( msg );
317  GetEndOfBlock( aBuff, aBuffSize, aText, m_Current_File );
318  ok = false;
319  break;
320  }
321  }
322  if( !x_fmt_known || !y_fmt_known )
323  AddMessageToList( wxT( "RS274X: Format Statement (FS) without X or Y format" ) );
324 
325  break;
326 
327  case AXIS_SELECT: // command ASAXBY*% or %ASAYBX*%
328  m_SwapAxis = false;
329  if( strncasecmp( aText, "AYBX", 4 ) == 0 )
330  m_SwapAxis = true;
331  break;
332 
333  case MIRROR_IMAGE: // command %MIA0B0*%, %MIA0B1*%, %MIA1B0*%, %MIA1B1*%
334  m_MirrorA = m_MirrorB = 0;
335  while( *aText && *aText != '*' )
336  {
337  switch( *aText )
338  {
339  case 'A': // Mirror A axis ?
340  aText++;
341  if( *aText == '1' )
342  m_MirrorA = true;
343  break;
344 
345  case 'B': // Mirror B axis ?
346  aText++;
347  if( *aText == '1' )
348  m_MirrorB = true;
349  break;
350 
351  default:
352  aText++;
353  break;
354  }
355  }
356  break;
357 
358  case MODE_OF_UNITS:
359  code = ReadXCommandID( aText );
360  if( code == INCH )
361  m_GerbMetric = false;
362  else if( code == MILLIMETER )
363  m_GerbMetric = true;
364  conv_scale = m_GerbMetric ? IU_PER_MILS / 25.4 : IU_PER_MILS;
365  break;
366 
367  case FILE_ATTRIBUTE: // Command %TF ...
368  m_IsX2_file = true;
369  {
371  dummy.ParseAttribCmd( m_Current_File, aBuff, aBuffSize, aText, m_LineNum );
372 
373  if( dummy.IsFileFunction() )
374  {
375  delete m_FileFunction;
377  }
378  else if( dummy.IsFileMD5() )
379  {
380  m_MD5_value = dummy.GetPrm( 1 );
381  }
382  else if( dummy.IsFilePart() )
383  {
384  m_PartString = dummy.GetPrm( 1 );
385  }
386  }
387  break;
388 
389  case APERTURE_ATTRIBUTE: // Command %TA
390  {
392  dummy.ParseAttribCmd( m_Current_File, aBuff, aBuffSize, aText, m_LineNum );
393 
394  if( dummy.GetAttribute() == ".AperFunction" )
395  {
396  m_AperFunction = dummy.GetPrm( 1 );
397 
398  // A few function values can have other parameters. Add them
399  for( int ii = 2; ii < dummy.GetPrmCount(); ii++ )
400  m_AperFunction << "," << dummy.GetPrm( ii );
401  }
402  }
403  break;
404 
405  case NET_ATTRIBUTE: // Command %TO currently %TO.P %TO.N and %TO.C
406  {
408 
409  dummy.ParseAttribCmd( m_Current_File, aBuff, aBuffSize, aText, m_LineNum );
410 
411  if( dummy.GetAttribute() == ".N" )
412  {
415  }
416  else if( dummy.GetAttribute() == ".C" )
417  {
420  }
421  else if( dummy.GetAttribute() == ".P" )
422  {
425  m_NetAttributeDict.m_Padname.SetField( FormatStringFromGerber( dummy.GetPrm( 2 ) ), true, true );
426 
427  if( dummy.GetPrmCount() > 3 )
429  FormatStringFromGerber( dummy.GetPrm( 3 ) ), true, true );
430  else
432  }
433  }
434  break;
435 
436  case REMOVE_APERTURE_ATTRIBUTE: // Command %TD ...
437  {
439  dummy.ParseAttribCmd( m_Current_File, aBuff, aBuffSize, aText, m_LineNum );
441  }
442  break;
443 
444  case OFFSET: // command: OFAnnBnn (nn = float number) = layer Offset
445  m_Offset.x = m_Offset.y = 0;
446  while( *aText != '*' )
447  {
448  switch( *aText )
449  {
450  case 'A': // A axis offset in current unit (inch or mm)
451  aText++;
452  fcoord = ReadDouble( aText );
453  m_Offset.x = KiROUND( fcoord * conv_scale );
454  break;
455 
456  case 'B': // B axis offset in current unit (inch or mm)
457  aText++;
458  fcoord = ReadDouble( aText );
459  m_Offset.y = KiROUND( fcoord * conv_scale );
460  break;
461  }
462  }
463  break;
464 
465  case SCALE_FACTOR:
466  m_Scale.x = m_Scale.y = 1.0;
467  while( *aText != '*' )
468  {
469  switch( *aText )
470  {
471  case 'A': // A axis scale
472  aText++;
473  m_Scale.x = ReadDouble( aText );
474  break;
475 
476  case 'B': // B axis scale
477  aText++;
478  m_Scale.y = ReadDouble( aText );
479  break;
480  }
481  }
482  break;
483 
484  case IMAGE_OFFSET: // command: IOAnnBnn (nn = float number) = Image Offset
486  while( *aText != '*' )
487  {
488  switch( *aText )
489  {
490  case 'A': // A axis offset in current unit (inch or mm)
491  aText++;
492  fcoord = ReadDouble( aText );
493  m_ImageOffset.x = KiROUND( fcoord * conv_scale );
494  break;
495 
496  case 'B': // B axis offset in current unit (inch or mm)
497  aText++;
498  fcoord = ReadDouble( aText );
499  m_ImageOffset.y = KiROUND( fcoord * conv_scale );
500  break;
501  }
502  }
503  break;
504 
505  case IMAGE_ROTATION: // command IR0* or IR90* or IR180* or IR270*
506  if( strncasecmp( aText, "0*", 2 ) == 0 )
507  m_ImageRotation = 0;
508  else if( strncasecmp( aText, "90*", 3 ) == 0 )
509  m_ImageRotation = 90;
510  else if( strncasecmp( aText, "180*", 4 ) == 0 )
511  m_ImageRotation = 180;
512  else if( strncasecmp( aText, "270*", 4 ) == 0 )
513  m_ImageRotation = 270;
514  else
515  AddMessageToList( _( "RS274X: Command \"IR\" rotation value not allowed" ) );
516  break;
517 
518  case STEP_AND_REPEAT: // command SR, like %SRX3Y2I5.0J2*%
519  m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Start a new Gerber layer
521  GetLayerParams().m_StepForRepeat.x = 0.0; // offset for Step and Repeat command
523  GetLayerParams().m_YRepeatCount = 1; // The repeat count
524  GetLayerParams().m_StepForRepeatMetric = m_GerbMetric; // the step units
525  while( *aText && *aText != '*' )
526  {
527  switch( *aText )
528  {
529  case 'I': // X axis offset
530  aText++;
532  break;
533 
534  case 'J': // Y axis offset
535  aText++;
537  break;
538 
539  case 'X': // X axis repeat count
540  aText++;
542  break;
543 
544  case 'Y': // Y axis offset
545  aText++;
547  break;
548  default:
549  aText++;
550  break;
551  }
552  }
553  break;
554 
555  case IMAGE_JUSTIFY: // Command IJAnBn*
556  m_ImageJustifyXCenter = false; // Image Justify Center on X axis (default = false)
557  m_ImageJustifyYCenter = false; // Image Justify Center on Y axis (default = false)
558  m_ImageJustifyOffset = wxPoint(0,0); // Image Justify Offset on XY axis (default = 0,0)
559  while( *aText && *aText != '*' )
560  {
561  // IJ command is (for A or B axis) AC or AL or A<coordinate>
562  switch( *aText )
563  {
564  case 'A': // A axis justify
565  aText++;
566  if( *aText == 'C' )
567  {
568  m_ImageJustifyXCenter = true;
569  aText++;
570  }
571  else if( *aText == 'L' )
572  {
573  m_ImageJustifyXCenter = true;
574  aText++;
575  }
576  else m_ImageJustifyOffset.x = KiROUND( ReadDouble( aText ) * conv_scale);
577  break;
578 
579  case 'B': // B axis justify
580  aText++;
581  if( *aText == 'C' )
582  {
583  m_ImageJustifyYCenter = true;
584  aText++;
585  }
586  else if( *aText == 'L' )
587  {
588  m_ImageJustifyYCenter = true;
589  aText++;
590  }
591  else m_ImageJustifyOffset.y = KiROUND( ReadDouble( aText ) * conv_scale);
592  break;
593  default:
594  aText++;
595  break;
596  }
597  }
602  break;
603 
604  case KNOCKOUT:
605  m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Start a new Gerber layer
606  msg = _( "RS274X: Command KNOCKOUT ignored by GerbView" ) ;
607  AddMessageToList( msg );
608  break;
609 
610  case ROTATE: // Layer rotation: command like %RO45*%
611  m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Start a new Gerber layer
612  m_LocalRotation =ReadDouble( aText ); // Store layer rotation in degrees
613  break;
614 
615  case IMAGE_NAME:
616  m_ImageName.Empty();
617  while( *aText != '*' )
618  {
619  m_ImageName.Append( *aText++ );
620  }
621 
622  break;
623 
624  case LOAD_NAME:
625  // %LN is a (deprecated) equivalentto G04: a comment
626  while( *aText && *aText != '*' )
627  {
628  aText++; // Skip text
629  }
630 
631  break;
632 
633  case IMAGE_POLARITY:
634  if( strncasecmp( aText, "NEG", 3 ) == 0 )
635  m_ImageNegative = true;
636  else
637  m_ImageNegative = false;
638 
639  break;
640 
641  case LOAD_POLARITY:
642  if( *aText == 'C' )
644  else
646 
647  break;
648 
649  case AP_MACRO: // lines like %AMMYMACRO*
650  // 5,1,8,0,0,1.08239X$1,22.5*
651  // %
652  /*ok = */ReadApertureMacro( aBuff, aBuffSize, aText, m_Current_File );
653  break;
654 
655  case AP_DEFINITION:
656  /* input example: %ADD30R,0.081800X0.101500*%
657  * Aperture definition has 4 options: C, R, O, P
658  * (Circle, Rect, Oval, regular Polygon)
659  * and shapes can have a hole (round or rectangular).
660  * All optional parameters values start by X
661  * at this point, text points to 2nd 'D'
662  */
663  if( *aText++ != 'D' )
664  {
665  ok = false;
666  break;
667  }
668 
669  m_Has_DCode = true;
670 
671  code = ReadInt( aText );
672 
673  D_CODE* dcode;
674  dcode = GetDCODEOrCreate( code );
675 
676  if( dcode == NULL )
677  break;
678 
680 
681  // at this point, text points to character after the ADD<num>,
682  // i.e. R in example above. If aText[0] is one of the usual
683  // apertures: (C,R,O,P), there is a comma after it.
684  if( aText[1] == ',' )
685  {
686  char stdAperture = *aText;
687 
688  aText += 2; // skip "C," for example
689 
690  // First parameter is the size X:
691  dcode->m_Size.x = KiROUND( ReadDouble( aText ) * conv_scale );
692  dcode->m_Size.y = dcode->m_Size.x;
693 
694  switch( stdAperture ) // Aperture desceiption has optional parameters. Read them
695  {
696  case 'C': // Circle
697  dcode->m_Shape = APT_CIRCLE;
698  while( *aText == ' ' )
699  aText++;
700 
701  if( *aText == 'X' )
702  {
703  aText++;
704  dcode->m_Drill.x = dcode->m_Drill.y =
705  KiROUND( ReadDouble( aText ) * conv_scale );
707  }
708 
709  while( *aText == ' ' )
710  aText++;
711 
712  if( *aText == 'X' )
713  {
714  aText++;
715  dcode->m_Drill.y =
716  KiROUND( ReadDouble( aText ) * conv_scale );
717 
719  }
720  dcode->m_Defined = true;
721  break;
722 
723  case 'O': // oval
724  case 'R': // rect
725  dcode->m_Shape = (stdAperture == 'O') ? APT_OVAL : APT_RECT;
726 
727  while( *aText == ' ' )
728  aText++;
729 
730  if( *aText == 'X' ) // Second parameter: size Y
731  {
732  aText++;
733  dcode->m_Size.y =
734  KiROUND( ReadDouble( aText ) * conv_scale );
735  }
736 
737  while( *aText == ' ' )
738  aText++;
739 
740  if( *aText == 'X' ) // third parameter: drill size (or drill size X)
741  {
742  aText++;
743  dcode->m_Drill.x = KiROUND( ReadDouble( aText ) * conv_scale );
744  dcode->m_Drill.y = dcode->m_Drill.x;
746  }
747 
748  while( *aText == ' ' )
749  aText++;
750 
751  if( *aText == 'X' ) // fourth parameter: drill size Y
752  {
753  aText++;
754  dcode->m_Drill.y =
755  KiROUND( ReadDouble( aText ) * conv_scale );
757  }
758 
759  dcode->m_Defined = true;
760  break;
761 
762  case 'P':
763 
764  /* Regular polygon: a command line like %ADD12P,0.040X10X25X0.025X0.025X0.0150*%
765  * params are: <diameter>, X<edge count>, X<Rotation>, X<X hole dim>, X<Y hole dim>
766  */
767  dcode->m_Shape = APT_POLYGON;
768  while( *aText == ' ' )
769  aText++;
770 
771  if( *aText == 'X' )
772  {
773  aText++;
774  dcode->m_EdgesCount = ReadInt( aText );
775  }
776 
777  while( *aText == ' ' )
778  aText++;
779 
780  if( *aText == 'X' )
781  {
782  aText++;
783  dcode->m_Rotation = ReadDouble( aText );
784  }
785 
786  while( *aText == ' ' )
787  aText++;
788 
789  if( *aText == 'X' )
790  {
791  aText++;
792  dcode->m_Drill.x = KiROUND( ReadDouble( aText ) * conv_scale );
793  dcode->m_Drill.y = dcode->m_Drill.x;
795  }
796 
797  while( *aText == ' ' )
798  aText++;
799 
800  if( *aText == 'X' )
801  {
802  aText++;
803  dcode->m_Drill.y = KiROUND( ReadDouble( aText ) * conv_scale );
805  }
806  dcode->m_Defined = true;
807  break;
808  }
809  }
810  else // aText[0] starts an aperture macro name
811  {
812  APERTURE_MACRO am_lookup;
813 
814  while( *aText && *aText != '*' && *aText != ',' )
815  am_lookup.name.Append( *aText++ );
816 
817  // When an aperture definition is like %AMLINE2* 22,1,$1,$2,0,0,-45*
818  // the ADDxx<MACRO_NAME> command has parameters, like %ADD14LINE2,0.8X0.5*%
819  if( *aText == ',' )
820  { // Read aperture macro parameters and store them
821  aText++; // aText points the first parameter
822 
823  while( *aText && *aText != '*' )
824  {
825  double param = ReadDouble( aText );
826  dcode->AppendParam( param );
827 
828  while( isspace( *aText ) )
829  aText++;
830 
831  // Skip 'X' separator:
832  if( *aText == 'X' || *aText == 'x' )
833  aText++;
834  }
835  }
836 
837  // lookup the aperture macro here.
838  APERTURE_MACRO* pam = FindApertureMacro( am_lookup );
839 
840  if( !pam )
841  {
842  msg.Printf( wxT( "RS274X: aperture macro %s not found\n" ),
843  TO_UTF8( am_lookup.name ) );
844  AddMessageToList( msg );
845  ok = false;
846  break;
847  }
848 
849  dcode->m_Shape = APT_MACRO;
850  dcode->SetMacro( pam );
851  }
852 
853  break;
854 
855  default:
856  ok = false;
857  break;
858  }
859 
860  (void) seq_len; // quiet g++, or delete the unused variable.
861 
862  ok = GetEndOfBlock( aBuff, aBuffSize, aText, m_Current_File );
863 
864  return ok;
865 }
X2_ATTRIBUTE_FILEFUNCTION ( from TF.FileFunction in Gerber file) Example file function: TF....
void AddMessageToList(const wxString &aMessage)
Function AddMessageToList Add a message to the message list.
X2_ATTRIBUTE_FILEFUNCTION * m_FileFunction
X2_ATTRIBUTE The attribute value consists of a number of substrings separated by a comma.
#define KI_FALLTHROUGH
wxString name
The name of the aperture macro.
Definition: am_primitive.h:165
print info associated to a component (TO.C attribute)
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:94
int ReadInt(char *&text, bool aSkipSeparator=true)
Function ReadInt reads an int from an ASCII character buffer.
Definition: dcode.h:53
APERTURE_T m_Shape
shape ( Line, rectangle, circle , oval .. )
Definition: dcode.h:95
double m_Rotation
shape rotation in degrees
Definition: dcode.h:99
wxSize m_Drill
dimension of the hole (if any) (draill file)
Definition: dcode.h:97
wxRealPoint m_StepForRepeat
wxString m_Cmpref
the component reference parent of the data
int ReadXCommandID(char *&text)
reads two bytes of data and assembles them into an int with the first byte in the sequence put into t...
Definition: rs274x.cpp:116
Definition: dcode.h:52
GBR_DATA_FIELD m_PadPinFunction
for a pad: the pin function (defined in schematic)
void SetField(const wxString &aField, bool aUseUTF8, bool aEscapeString)
double ReadDouble(char *&text, bool aSkipSeparator=true)
Function ReadDouble reads a double from an ASCII character buffer.
bool m_Defined
false if the aperture is not defined in the header
Definition: dcode.h:104
void AppendParam(double aValue)
AppendParam() Add a parameter to the D_CODE parameter list.
Definition: dcode.h:122
#define NULL
GBR_DATA_FIELD m_Padname
for a flashed pad: the pad name ((TO.P attribute)
wxString m_Netname
for items associated to a net: the netname
APERTURE_MACRO * FindApertureMacro(const APERTURE_MACRO &aLookup)
Function FindApertureMacro looks up a previously read in aperture macro.
bool m_StepForRepeatMetric
bool ReadApertureMacro(char *aBuff, unsigned int aBuffSize, char *&text, FILE *gerber_file)
reads in an aperture macro and saves it in m_aperture_macros.
Definition: rs274x.cpp:922
wxString m_AperFunction
the aperture attribute (created by a TA.AperFunction command) attached to the D_CODE
Definition: dcode.h:105
void RemoveAttribute(X2_ATTRIBUTE &aAttribute)
Function RemoveAttribute.
APERTURE_DEF_HOLETYPE m_DrillShape
shape of the hole (0 = no hole, round = 1, rect = 2) */
Definition: dcode.h:98
D_CODE holds a gerber DCODE (also called Aperture) definition.
Definition: dcode.h:82
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
Definition: rs274x.cpp:64
#define _(s)
Definition: 3d_actions.cpp:33
GBR_NETLIST_METADATA m_NetAttributeDict
void SetMacro(APERTURE_MACRO *aMacro)
Definition: dcode.h:151
bool GetEndOfBlock(char *aBuff, unsigned int aBuffSize, char *&aText, FILE *aGerberFile)
Definition: rs274x.cpp:868
#define IU_PER_MILS
Definition: plotter.cpp:138
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68
#define TO_UTF8(wxstring)
int m_EdgesCount
in aperture definition Polygon only: number of edges for the polygon
Definition: dcode.h:100
print info associated to a flashed pad (TO.P attribute)
wxString FormatStringFromGerber(const wxString &aString)
This helper function make the inverse conversion of FormatStringToGerber() It converts a "normalized"...
Struct APERTURE_MACRO helps support the "aperture macro" defined within standard RS274X.
Definition: am_primitive.h:163
print info associated to a net (TO.N attribute)
D_CODE * GetDCODEOrCreate(int aDCODE, bool aCreateIfNoExist=true)
Function GetDCODEOrCreate returns a pointer to the D_CODE within this GERBER for the given aDCODE.
GERBER_LAYER & GetLayerParams()
Function GetLayerParams.
int m_NetAttribType
the type of net info (used to define the gerber string to create)

References _, AddMessageToList(), AP_DEFINITION, AP_MACRO, APERTURE_ATTRIBUTE, D_CODE::AppendParam(), APT_CIRCLE, APT_DEF_RECT_HOLE, APT_DEF_ROUND_HOLE, APT_MACRO, APT_OVAL, APT_POLYGON, APT_RECT, AXIS_SELECT, GBR_DATA_FIELD::Clear(), dummy(), FILE_ATTRIBUTE, FindApertureMacro(), FORMAT_STATEMENT, FormatStringFromGerber(), GBR_NETLIST_METADATA::GBR_NETINFO_CMP, GBR_NETLIST_METADATA::GBR_NETINFO_NET, GBR_NETLIST_METADATA::GBR_NETINFO_PAD, GERB_INTERPOL_LINEAR_1X, GetDCODEOrCreate(), GetEndOfBlock(), GetLayerParams(), IMAGE_JUSTIFY, IMAGE_NAME, IMAGE_OFFSET, IMAGE_POLARITY, IMAGE_ROTATION, INCH, IU_PER_MILS, KI_FALLTHROUGH, KiROUND(), KNOCKOUT, LOAD_NAME, LOAD_POLARITY, D_CODE::m_AperFunction, m_AperFunction, GBR_NETLIST_METADATA::m_Cmpref, m_Current_File, D_CODE::m_Defined, D_CODE::m_Drill, D_CODE::m_DrillShape, D_CODE::m_EdgesCount, m_FileFunction, m_FileName, m_FmtLen, m_FmtScale, m_GerbMetric, m_Has_DCode, m_ImageJustifyOffset, m_ImageJustifyXCenter, m_ImageJustifyYCenter, m_ImageName, m_ImageNegative, m_ImageOffset, m_ImageRotation, m_IsX2_file, m_Iterpolation, GERBER_LAYER::m_LayerNegative, m_LineNum, m_LocalRotation, m_MD5_value, m_MirrorA, m_MirrorB, GBR_NETLIST_METADATA::m_NetAttribType, m_NetAttributeDict, GBR_NETLIST_METADATA::m_Netname, m_NoTrailingZeros, m_Offset, GBR_NETLIST_METADATA::m_Padname, GBR_NETLIST_METADATA::m_PadPinFunction, m_PartString, m_Relative, D_CODE::m_Rotation, m_Scale, D_CODE::m_Shape, D_CODE::m_Size, GERBER_LAYER::m_StepForRepeat, GERBER_LAYER::m_StepForRepeatMetric, m_SwapAxis, GERBER_LAYER::m_XRepeatCount, GERBER_LAYER::m_YRepeatCount, MILLIMETER, MIRROR_IMAGE, MODE_OF_UNITS, APERTURE_MACRO::name, NET_ATTRIBUTE, NULL, OFFSET, ReadApertureMacro(), ReadDouble(), ReadInt(), ReadXCommandID(), REMOVE_APERTURE_ATTRIBUTE, RemoveAttribute(), ROTATE, SCALE_FACTOR, GBR_DATA_FIELD::SetField(), D_CODE::SetMacro(), STEP_AND_REPEAT, TO_UTF8, wxPoint::x, and wxPoint::y.

Referenced by Execute_G_Command(), and ReadRS274XCommand().

◆ FindApertureMacro()

APERTURE_MACRO * GERBER_FILE_IMAGE::FindApertureMacro ( const APERTURE_MACRO aLookup)

Function FindApertureMacro looks up a previously read in aperture macro.

Parameters
aLookupA dummy APERTURE_MACRO with [only] the name field set.
Returns
APERTURE_MACRO* - the one with a matching name, or NULL if not found.

Definition at line 156 of file gerber_file_image.cpp.

157 {
158  APERTURE_MACRO_SET::iterator iter = m_aperture_macros.find( aLookup );
159 
160  if( iter != m_aperture_macros.end() )
161  {
162  APERTURE_MACRO* pam = (APERTURE_MACRO*) &(*iter);
163  return pam;
164  }
165 
166  return NULL; // not found
167 }
APERTURE_MACRO_SET m_aperture_macros
a collection of APERTURE_MACROS, sorted by name
#define NULL
Struct APERTURE_MACRO helps support the "aperture macro" defined within standard RS274X.
Definition: am_primitive.h:163

References m_aperture_macros, and NULL.

Referenced by ExecuteRS274XCommand().

◆ GCodeNumber()

int GERBER_FILE_IMAGE::GCodeNumber ( char *&  Text)

Definition at line 411 of file rs274d.cpp.

412 {
413  int ii = 0;
414  char* text;
415  char line[1024];
416 
417  if( Text == NULL )
418  return 0;
419  Text++;
420  text = line;
421  while( IsNumber( *Text ) )
422  {
423  *(text++) = *(Text++);
424  }
425 
426  *text = 0;
427  ii = atoi( line );
428  return ii;
429 }
#define NULL
#define IsNumber(x)

References IsNumber, and NULL.

Referenced by LoadGerberFile().

◆ Get() [1/3]

wxAny INSPECTABLE::Get ( PROPERTY_BASE aProperty)
inlineinherited

Definition at line 84 of file inspectable.h.

85  {
87  TYPE_ID thisType = TYPE_HASH( *this );
88  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
89  return object ? aProperty->getter( object ) : wxAny();
90  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:61
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:53
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:38
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
virtual wxAny getter(void *aObject) const =0
Provides class metadata.
Definition: property_mgr.h:58
virtual size_t OwnerHash() const =0
Returns type-id of the Owner class.

References PROPERTY_BASE::getter(), PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

Referenced by CLASS_D_DESC::CLASS_D_DESC(), and PAD_DESC::PAD_DESC().

◆ Get() [2/3]

template<typename T >
T INSPECTABLE::Get ( PROPERTY_BASE aProperty)
inlineinherited

Definition at line 93 of file inspectable.h.

94  {
96  TYPE_ID thisType = TYPE_HASH( *this );
97  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
98  return object ? aProperty->get<T>( object ) : T();
99  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:61
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:53
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:38
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
T
enum T contains all this lexer's tokens.
Provides class metadata.
Definition: property_mgr.h:58
T get(void *aObject)
Definition: property.h:271
virtual size_t OwnerHash() const =0
Returns type-id of the Owner class.

References PROPERTY_BASE::get(), PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

◆ Get() [3/3]

template<typename T >
boost::optional<T> INSPECTABLE::Get ( const wxString &  aProperty)
inlineinherited

Definition at line 102 of file inspectable.h.

103  {
105  TYPE_ID thisType = TYPE_HASH( *this );
106  PROPERTY_BASE* prop = propMgr.GetProperty( thisType, aProperty );
107  boost::optional<T> ret;
108 
109  if( prop )
110  {
111  void* object = propMgr.TypeCast( this, thisType, prop->OwnerHash() );
112 
113  if( object )
114  ret = prop->get<T>( object );
115  }
116 
117  return ret;
118  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:61
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:53
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:38
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
T
enum T contains all this lexer's tokens.
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Returns a property for a specific type.
Provides class metadata.
Definition: property_mgr.h:58
T get(void *aObject)
Definition: property.h:271
virtual size_t OwnerHash() const =0
Returns type-id of the Owner class.

References PROPERTY_BASE::get(), PROPERTY_MANAGER::GetProperty(), PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

◆ GetBoundingBox()

const EDA_RECT EDA_ITEM::GetBoundingBox ( ) const
virtualinherited

Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.

This box should be an enclosing perimeter for visible components of this object, and the units should be in the pcb or schematic coordinate system. It is OK to overestimate the size by a few counts.

Reimplemented in BOARD, D_PAD, SCH_HIERLABEL, SCH_SHEET, SCH_GLOBALLABEL, SCH_COMPONENT, SCH_LABEL, WS_DRAW_ITEM_BITMAP, WS_DRAW_ITEM_TEXT, SCH_TEXT, WS_DRAW_ITEM_PAGE, DRAWSEGMENT, DIMENSION, GERBER_DRAW_ITEM, LIB_PART, WS_DRAW_ITEM_RECT, LIB_ITEM, TEXTE_MODULE, WS_DRAW_ITEM_POLYPOLYGONS, MODULE, LIB_FIELD, SCH_LINE, WS_DRAW_ITEM_LINE, TRACK, TEXTE_PCB, LIB_PIN, SCH_FIELD, ZONE_CONTAINER, MARKER_PCB, WS_DRAW_ITEM_BASE, MARKER_PCB, SCH_BITMAP, PCB_TARGET, SCH_BUS_ENTRY_BASE, SCH_PIN, GBR_LAYOUT, LIB_POLYLINE, LIB_ARC, SCH_NO_CONNECT, LIB_TEXT, LIB_BEZIER, SCH_MARKER, LIB_RECTANGLE, SCH_JUNCTION, and LIB_CIRCLE.

Definition at line 97 of file base_struct.cpp.

98 {
99 #if defined(DEBUG)
100  printf( "Missing GetBoundingBox()\n" );
101  Show( 0, std::cout ); // tell me which classes still need GetBoundingBox support
102 #endif
103 
104  // return a zero-sized box per default. derived classes should override
105  // this
106  return EDA_RECT( wxPoint( 0, 0 ), wxSize( 0, 0 ) );
107 }
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44

Referenced by CN_ITEM::BBox(), EE_RTREE::contains(), MODULE::CoverageRatio(), SELECTION::GetBoundingBox(), LIB_ITEM::GetBoundingBox(), GetBoundingBoxes(), GERBVIEW_SELECTION::GetCenter(), getRect(), EE_RTREE::insert(), SCH_EDIT_TOOL::Mirror(), SCH_EAGLE_PLUGIN::moveLabels(), EE_RTREE::remove(), GERBVIEW_SELECTION::ViewBBox(), and EDA_ITEM::ViewBBox().

◆ GetClass()

wxString GERBER_FILE_IMAGE::GetClass ( ) const
inlineoverridevirtual

Function GetClass returns the class name.

Returns
wxString

Implements EDA_ITEM.

Definition at line 251 of file gerber_file_image.h.

252  {
253  return wxT( "GERBER_FILE_IMAGE" );
254  }

◆ GetDCODE()

D_CODE * GERBER_FILE_IMAGE::GetDCODE ( int  aDCODE) const

Function GetDCODE returns a pointer to the D_CODE within this GERBER for the given aDCODE.

Parameters
aDCODEThe numeric value of the D_CODE to look up.
Returns
D_CODE* - the one implied by the given aDCODE, or NULL if the requested aDCODE is out of range.

Definition at line 143 of file gerber_file_image.cpp.

144 {
145  unsigned ndx = aDCODE - FIRST_DCODE;
146 
147  if( ndx < (unsigned) arrayDim( m_Aperture_List ) )
148  {
149  return m_Aperture_List[ndx];
150  }
151 
152  return NULL;
153 }
D_CODE * m_Aperture_List[TOOLS_MAX_COUNT]
Dcode (Aperture) List for this layer (max TOOLS_MAX_COUNT: see dcode.h)
#define NULL
#define FIRST_DCODE
Definition: dcode.h:71
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:160

References arrayDim(), FIRST_DCODE, m_Aperture_List, and NULL.

Referenced by Execute_DCODE_Command(), EXCELLON_IMAGE::Execute_Drill_Command(), Execute_G_Command(), EXCELLON_IMAGE::FinishRouteCommand(), GERBER_DRAW_ITEM::GetDcodeDescr(), GERBVIEW_FRAME::Liste_D_Codes(), EXCELLON_IMAGE::Select_Tool(), GERBVIEW_FRAME::updateAperAttributesSelectBox(), and GERBVIEW_FRAME::updateDCodeSelectBox().

◆ GetDCODEOrCreate()

D_CODE * GERBER_FILE_IMAGE::GetDCODEOrCreate ( int  aDCODE,
bool  aCreateIfNoExist = true 
)

Function GetDCODEOrCreate returns a pointer to the D_CODE within this GERBER for the given aDCODE.

Parameters
aDCODEThe numeric value of the D_CODE to look up.
aCreateIfNoExistIf true, then create the D_CODE if it does not exist in list.
Returns
D_CODE* - the one implied by the given aDCODE, or NULL if the requested aDCODE is out of range.

Definition at line 123 of file gerber_file_image.cpp.

124 {
125  unsigned ndx = aDCODE - FIRST_DCODE;
126 
127  if( ndx < (unsigned) arrayDim( m_Aperture_List ) )
128  {
129  // lazily create the D_CODE if it does not exist.
130  if( aCreateIfNoExist )
131  {
132  if( m_Aperture_List[ndx] == NULL )
133  m_Aperture_List[ndx] = new D_CODE( ndx + FIRST_DCODE );
134  }
135 
136  return m_Aperture_List[ndx];
137  }
138 
139  return NULL;
140 }
D_CODE * m_Aperture_List[TOOLS_MAX_COUNT]
Dcode (Aperture) List for this layer (max TOOLS_MAX_COUNT: see dcode.h)
#define NULL
#define FIRST_DCODE
Definition: dcode.h:71
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:160
D_CODE holds a gerber DCODE (also called Aperture) definition.
Definition: dcode.h:82

References arrayDim(), FIRST_DCODE, m_Aperture_List, and NULL.

Referenced by ExecuteRS274XCommand(), EXCELLON_IMAGE::readToolInformation(), and EXCELLON_IMAGE::Select_Tool().

◆ GetDcodesCount()

int GERBER_FILE_IMAGE::GetDcodesCount ( )
Returns
the count of Dcode tools in use in the image

Definition at line 259 of file gerber_file_image.cpp.

260 {
261  int count = 0;
262 
263  for( unsigned ii = 0; ii < arrayDim( m_Aperture_List ); ii++ )
264  {
265  if( m_Aperture_List[ii] )
266  if( m_Aperture_List[ii]->m_InUse || m_Aperture_List[ii]->m_Defined )
267  ++count;
268  }
269 
270  return count;
271 }
D_CODE * m_Aperture_List[TOOLS_MAX_COUNT]
Dcode (Aperture) List for this layer (max TOOLS_MAX_COUNT: see dcode.h)
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:160

References arrayDim(), m_Aperture_List, and m_InUse.

Referenced by GERBVIEW_FRAME::Liste_D_Codes(), GERBVIEW_FRAME::updateAperAttributesSelectBox(), and GERBVIEW_FRAME::updateDCodeSelectBox().

◆ GetEditFlags()

STATUS_FLAGS EDA_ITEM::GetEditFlags ( ) const
inlineinherited

Definition at line 237 of file base_struct.h.

238  {
239  constexpr int mask = ( IS_NEW | IS_PASTED | IS_MOVED | IS_RESIZED | IS_DRAGGED |
241 
242  return m_Flags & mask;
243  }
#define IS_NEW
New item, just created.
Definition: base_struct.h:117
#define IS_DRAGGED
Item being dragged.
Definition: base_struct.h:119
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:126
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.
Definition: base_struct.h:121
STATUS_FLAGS m_Flags
Definition: base_struct.h:176
#define IS_RESIZED
Item being resized.
Definition: base_struct.h:118
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
Definition: base_struct.h:130
#define IS_MOVED
Item being moved.
Definition: base_struct.h:116

References IS_DRAGGED, IS_MOVED, IS_NEW, IS_PASTED, IS_RESIZED, IS_WIRE_IMAGE, EDA_ITEM::m_Flags, and STRUCT_DELETED.

Referenced by SCH_EDIT_TOOL::ChangeTextType(), EDA_ITEM::ClearEditFlags(), SCH_EDIT_FRAME::DeleteJunction(), SCH_EDIT_TOOL::editFieldText(), SCH_EDITOR_CONTROL::EditWithLibEdit(), SCH_COMPONENT::GetMsgPanelInfo(), LIB_MOVE_TOOL::Main(), POINT_EDITOR::OnSelectionChange(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), PAD_TOOL::recombinePad(), SCH_EDIT_FRAME::SchematicCleanUp(), SCH_EDIT_FRAME::SelectUnit(), DIALOG_TARGET_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_EDIT_PIN::TransferDataFromWindow(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LABEL_EDITOR::TransferDataFromWindow(), DIALOG_FOOTPRINT_BOARD_EDITOR::TransferDataFromWindow(), and SCH_EDIT_FRAME::TrimWire().

◆ GetEndOfBlock()

bool GERBER_FILE_IMAGE::GetEndOfBlock ( char *  aBuff,
unsigned int  aBuffSize,
char *&  aText,
FILE *  aGerberFile 
)
private

Definition at line 868 of file rs274x.cpp.

869 {
870  for( ; ; )
871  {
872  while( (aText < aBuff + aBuffSize) && *aText )
873  {
874  if( *aText == '*' )
875  return true;
876 
877  if( *aText == '%' )
878  return true;
879 
880  aText++;
881  }
882 
883  if( fgets( aBuff, aBuffSize, gerber_file ) == NULL )
884  break;
885 
886  m_LineNum++;
887  aText = aBuff;
888  }
889 
890  return false;
891 }
#define NULL

References m_LineNum, and NULL.

Referenced by ExecuteRS274XCommand().

◆ GetFlags()

◆ GetFocusPosition()

virtual const wxPoint EDA_ITEM::GetFocusPosition ( ) const
inlinevirtualinherited

Function GetFocusPosition similar to GetPosition, but allows items to return their visual center rather than their anchor.

Reimplemented in DRAWSEGMENT, and TRACK.

Definition at line 344 of file base_struct.h.

344 { return GetPosition(); }
virtual wxPoint GetPosition() const
Definition: base_struct.h:337

References EDA_ITEM::GetPosition().

Referenced by PCB_BASE_FRAME::FocusOnItem(), and SCH_EDIT_FRAME::FocusOnItem().

◆ GetItems()

GERBER_DRAW_ITEMS& GERBER_FILE_IMAGE::GetItems ( )
inline

◆ GetItemsCount()

int GERBER_FILE_IMAGE::GetItemsCount ( )
inline
Returns
the count of GERBER_DRAW_ITEMS in the image

Definition at line 284 of file gerber_file_image.h.

284 { return m_drawings.size(); }
GERBER_DRAW_ITEMS m_drawings

References m_drawings.

Referenced by GERBVIEW_FRAME::Read_GERBER_File().

◆ GetLastItemInList()

GERBER_DRAW_ITEM* GERBER_FILE_IMAGE::GetLastItemInList ( ) const
inline
Returns
the last GERBER_DRAW_ITEM* item of the items list

Definition at line 298 of file gerber_file_image.h.

299  {
300  return m_drawings.back();
301  }
GERBER_DRAW_ITEMS m_drawings

References m_drawings.

Referenced by Execute_DCODE_Command(), and Execute_G_Command().

◆ GetLayerParams()

GERBER_LAYER& GERBER_FILE_IMAGE::GetLayerParams ( )
inline

Function GetLayerParams.

Returns
the current layers params

Definition at line 307 of file gerber_file_image.h.

308  {
309  return m_GBRLayerParams;
310  }
GERBER_LAYER m_GBRLayerParams

References m_GBRLayerParams.

Referenced by Execute_DCODE_Command(), ExecuteRS274XCommand(), GERBER_DRAW_ITEM::SetLayerParameters(), StepAndRepeatItem(), and GERBVIEW_FRAME::UpdateTitleAndInfo().

◆ GetMenuImage()

BITMAP_DEF EDA_ITEM::GetMenuImage ( ) const
virtualinherited

Function GetMenuImage returns a pointer to an image to be used in menus.

The default version returns the right arrow image. Override this function to provide object specific menu images.

Returns
The menu image associated with the item.

Reimplemented in ZONE_CONTAINER, SCH_COMPONENT, MODULE, SCH_SHEET, D_PAD, SCH_HIERLABEL, LIB_PIN, VIA, SCH_GLOBALLABEL, SCH_LABEL, SCH_TEXT, GERBER_DRAW_ITEM, DRAWSEGMENT, DIMENSION, TRACK, TEXTE_MODULE, SCH_BUS_BUS_ENTRY, SCH_LINE, SCH_SHEET_PIN, LIB_FIELD, SCH_FIELD, SCH_BUS_WIRE_ENTRY, EDGE_MODULE, SCH_BITMAP, LIB_ARC, TEXTE_PCB, LIB_POLYLINE, SCH_NO_CONNECT, LIB_TEXT, SCH_MARKER, PCB_TARGET, MARKER_PCB, SCH_JUNCTION, MARKER_PCB, LIB_CIRCLE, and LIB_RECTANGLE.

Definition at line 235 of file base_struct.cpp.

236 {
237  return dummy_xpm;
238 }
static const BITMAP_OPAQUE dummy_xpm[1]
Definition: base_struct.cpp:56

References dummy_xpm.

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), and SELECTION_TOOL::doSelectionMenu().

◆ GetMessages()

const wxArrayString& GERBER_FILE_IMAGE::GetMessages ( ) const
inline

Definition at line 265 of file gerber_file_image.h.

265 { return m_messagesList; }
wxArrayString m_messagesList

References m_messagesList.

Referenced by GERBVIEW_FRAME::Read_EXCELLON_File(), and GERBVIEW_FRAME::Read_GERBER_File().

◆ GetMsgPanelInfo()

virtual void EDA_ITEM::GetMsgPanelInfo ( EDA_DRAW_FRAME aFrame,
std::vector< MSG_PANEL_ITEM > &  aList 
)
inlinevirtualinherited

◆ GetNextLine()

char * GERBER_FILE_IMAGE::GetNextLine ( char *  aBuff,
unsigned int  aBuffSize,
char *  aText,
FILE *  aFile 
)
private

test for an end of line if a end of line is found: read a new line

Parameters
aBuff= buffer (size = GERBER_BUFZ) to fill with a new line
aText= pointer to the last useful char in aBuff on return: points the beginning of the next line.
aBuffSize= the size in bytes of aBuff
aFile= the opened GERBER file to read
Returns
a pointer to the beginning of the next line or NULL if end of file

Definition at line 894 of file rs274x.cpp.

895 {
896  for( ; ; )
897  {
898  switch (*aText )
899  {
900  case ' ': // skip blanks
901  case '\n':
902  case '\r': // Skip line terminators
903  ++aText;
904  break;
905 
906  case 0: // End of text found in aBuff: Read a new string
907  if( fgets( aBuff, aBuffSize, aFile ) == NULL )
908  return NULL;
909 
910  m_LineNum++;
911  aText = aBuff;
912  return aText;
913 
914  default:
915  return aText;
916  }
917  }
918  return aText;
919 }
#define NULL

References m_LineNum, and NULL.

Referenced by ReadApertureMacro().

◆ GetParent()

◆ GetPosition()

virtual wxPoint EDA_ITEM::GetPosition ( ) const
inlinevirtualinherited

Reimplemented in SCH_COMPONENT, SCH_SHEET, LIB_PIN, VIA, WS_DRAW_ITEM_BITMAP, SCH_TEXT, BOARD, WS_DRAW_ITEM_TEXT, ARC, WS_DRAW_ITEM_PAGE, WS_DRAW_ITEM_RECT, SCH_LINE, MODULE, GERBER_DRAW_ITEM, SCH_FIELD, LIB_FIELD, WS_DRAW_ITEM_POLYPOLYGONS, D_PAD, SCH_BITMAP, WS_DRAW_ITEM_LINE, DRAWSEGMENT, SCH_BUS_ENTRY_BASE, DIMENSION, SCH_NO_CONNECT, TRACK, KIGFX::ORIGIN_VIEWITEM, NETINFO_ITEM, SCH_MARKER, SCH_JUNCTION, TEXTE_MODULE, LIB_POLYLINE, LIB_ARC, ZONE_CONTAINER, LIB_TEXT, SCH_PIN, LIB_BEZIER, TEXTE_PCB, DELETED_BOARD_ITEM, LIB_RECTANGLE, MARKER_PCB, MARKER_PCB, LIB_CIRCLE, and PCB_TARGET.

Definition at line 337 of file base_struct.h.

337 { return wxPoint(); }

Referenced by GRID_HELPER::computeAnchors(), SCH_EDIT_FRAME::DeleteJunction(), KIGFX::PCB_PAINTER::draw(), CONNECTION_GRAPH::ercCheckBusToBusConflicts(), CONNECTION_GRAPH::ercCheckBusToNetConflicts(), CONNECTION_GRAPH::ercCheckNoConnects(), SELECTION_TOOL::findCallback(), GERBVIEW_SELECTION::GetCenter(), BOARD_ITEM::GetCenter(), EDA_ITEM::GetFocusPosition(), SCH_FIELD::GetParentPosition(), POSITION_RELATIVE_TOOL::GetSelectionAnchorPosition(), SCH_SCREEN::GetSheets(), PCBNEW_SELECTION::GetTopLeftItem(), BOARD_ITEM::GetX(), BOARD_ITEM::GetY(), LIB_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), EDIT_POINTS_FACTORY::Make(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_ITEM::operator<(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PCBNEW_CONTROL::placeBoardItems(), DRAWING_TOOL::PlaceImportedGraphics(), DRAWING_TOOL::PlaceText(), BACK_ANNOTATE::processNetNameChange(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), SELECTION_TOOL::selectConnectedTracks(), RC_ITEM::ShowReport(), DRC::testDisabledLayers(), TransformItem(), DIALOG_POSITION_RELATIVE::UpdateAnchor(), LIB_MOVE_TOOL::updateModificationPoint(), PL_EDIT_TOOL::updateModificationPoint(), and EE_POINT_EDITOR::updatePoints().

◆ GetPositiveDrawColor()

COLOR4D GERBER_FILE_IMAGE::GetPositiveDrawColor ( ) const
inline

Definition at line 274 of file gerber_file_image.h.

274 { return m_PositiveDrawColor; }

References m_PositiveDrawColor.

Referenced by GERBER_DRAW_ITEM::Print().

◆ GetSelectMenuText()

wxString EDA_ITEM::GetSelectMenuText ( EDA_UNITS  aUnits) const
virtualinherited

Function GetSelectMenuText returns the text to display to be used in the selection clarification context menu when multiple items are found at the current cursor position.

The default version of this function raises an assertion in the debug mode and returns a string to indicate that it was not overridden to provide the object specific text.

Returns
The menu text string.

Reimplemented in ZONE_CONTAINER, SCH_COMPONENT, BOARD, MODULE, SCH_SHEET, D_PAD, SCH_HIERLABEL, LIB_PIN, VIA, SCH_GLOBALLABEL, SCH_LABEL, WS_DRAW_ITEM_BITMAP, WS_DRAW_ITEM_TEXT, SCH_TEXT, GERBER_DRAW_ITEM, DRAWSEGMENT, WS_DRAW_ITEM_PAGE, DIMENSION, WS_DRAW_ITEM_RECT, TRACK, TEXTE_MODULE, SCH_BUS_BUS_ENTRY, SCH_LINE, SCH_SHEET_PIN, LIB_FIELD, WS_DRAW_ITEM_POLYPOLYGONS, SCH_FIELD, SCH_BUS_WIRE_ENTRY, WS_DRAW_ITEM_LINE, EDGE_MODULE, LIB_ARC, SCH_BITMAP, TEXTE_PCB, LIB_POLYLINE, SCH_NO_CONNECT, LIB_TEXT, PCB_TARGET, SCH_MARKER, MARKER_PCB, MARKER_PCB, LIB_CIRCLE, LIB_RECTANGLE, SCH_JUNCTION, SCH_PIN, DELETED_BOARD_ITEM, and DELETED_SHEET_ITEM.

Definition at line 136 of file base_struct.cpp.

137 {
138  wxFAIL_MSG( wxT( "GetSelectMenuText() was not overridden for schematic item type " ) +
139  GetClass() );
140 
141  return wxString( wxT( "Undefined menu text for " ) + GetClass() );
142 }
virtual wxString GetClass() const =0
Function GetClass returns the class name.

References EDA_ITEM::GetClass().

Referenced by CONNECTION_GRAPH::buildConnectionGraph(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), MARKER_PCB::GetMsgPanelInfo(), RC_TREE_MODEL::GetValue(), DRC_ITEM::ShowHtml(), RC_ITEM::ShowReport(), and DIALOG_POSITION_RELATIVE::UpdateAnchor().

◆ GetState()

int EDA_ITEM::GetState ( int  type) const
inlineinherited

Definition at line 216 of file base_struct.h.

217  {
218  return m_Status & type;
219  }
STATUS_FLAGS m_Status
Definition: base_struct.h:173

References EDA_ITEM::m_Status.

Referenced by TRACK::GetMsgPanelInfoBase_Common(), and TRACK::IsLocked().

◆ GetStatus()

STATUS_FLAGS EDA_ITEM::GetStatus ( ) const
inlineinherited

Definition at line 229 of file base_struct.h.

229 { return m_Status; }
STATUS_FLAGS m_Status
Definition: base_struct.h:173

References EDA_ITEM::m_Status.

Referenced by PCB_IO::format().

◆ HasFlag()

◆ HasNegativeItems()

bool GERBER_FILE_IMAGE::HasNegativeItems ( )

Function HasNegativeItems.

Returns
true if at least one item must be drawn in background color used to optimize screen refresh (when no items are in background color refresh can be faster)

Definition at line 235 of file gerber_file_image.cpp.

236 {
237  if( m_hasNegativeItems < 0 ) // negative items are not yet searched: find them if any
238  {
239  if( m_ImageNegative ) // A negative layer is expected having always negative objects.
240  m_hasNegativeItems = 1;
241  else
242  {
243  m_hasNegativeItems = 0;
244  for( GERBER_DRAW_ITEM* item : GetItems() )
245  {
246  if( item->GetLayer() != m_GraphicLayer )
247  continue;
248  if( item->HasNegativeItems() )
249  {
250  m_hasNegativeItems = 1;
251  break;
252  }
253  }
254  }
255  }
256  return m_hasNegativeItems == 1;
257 }
GERBER_DRAW_ITEMS & GetItems()

References GetItems(), m_GraphicLayer, m_hasNegativeItems, and m_ImageNegative.

◆ HitTest() [1/2]

virtual bool EDA_ITEM::HitTest ( const wxPoint aPosition,
int  aAccuracy = 0 
) const
inlinevirtualinherited

◆ HitTest() [2/2]

virtual bool EDA_ITEM::HitTest ( const EDA_RECT aRect,
bool  aContained,
int  aAccuracy = 0 
) const
inlinevirtualinherited

Function HitTest tests if aRect intersects or is contained within the bounding box of an item.

Parameters
aRectA reference to a EDA_RECT object containing the rectangle to test.
aContainedSet to true to test for containment instead of an intersection.
aAccuracyIncrease aRect by this amount.
Returns
True if aRect contains or intersects the item bounding box.

Reimplemented in SCH_COMPONENT, SCH_SHEET, D_PAD, MODULE, VIA, ZONE_CONTAINER, WS_DRAW_ITEM_BITMAP, SCH_TEXT, ARC, WS_DRAW_ITEM_TEXT, GERBER_DRAW_ITEM, DRAWSEGMENT, DIMENSION, SCH_LINE, TEXTE_MODULE, LIB_ITEM, SCH_FIELD, TRACK, WS_DRAW_ITEM_POLYPOLYGONS, SCH_BITMAP, LIB_PIN, SCH_BUS_ENTRY_BASE, SCH_NO_CONNECT, TEXTE_PCB, SCH_JUNCTION, WS_DRAW_ITEM_BASE, PCB_TARGET, LIB_POLYLINE, LIB_ARC, LIB_BEZIER, LIB_TEXT, and LIB_CIRCLE.

Definition at line 321 of file base_struct.h.

322  {
323  return false; // derived classes should override this function
324  }

◆ InitToolTable()

void GERBER_FILE_IMAGE::InitToolTable ( )

Function InitToolTable.

Definition at line 274 of file gerber_file_image.cpp.

275 {
276  for( int count = 0; count < TOOLS_MAX_COUNT; count++ )
277  {
278  if( m_Aperture_List[count] == NULL )
279  continue;
280 
281  m_Aperture_List[count]->m_Num_Dcode = count + FIRST_DCODE;
283  }
284 
285  m_aperture_macros.clear();
286 }
APERTURE_MACRO_SET m_aperture_macros
a collection of APERTURE_MACROS, sorted by name
D_CODE * m_Aperture_List[TOOLS_MAX_COUNT]
Dcode (Aperture) List for this layer (max TOOLS_MAX_COUNT: see dcode.h)
#define NULL
#define FIRST_DCODE
Definition: dcode.h:71
int m_Num_Dcode
D code value ( >= 10 )
Definition: dcode.h:96
#define TOOLS_MAX_COUNT
Definition: dcode.h:73
void Clear_D_CODE_Data()
Definition: dcode.cpp:77

References D_CODE::Clear_D_CODE_Data(), FIRST_DCODE, m_Aperture_List, m_aperture_macros, D_CODE::m_Num_Dcode, NULL, and TOOLS_MAX_COUNT.

◆ IsBrightened()

bool EDA_ITEM::IsBrightened ( ) const
inlineinherited

◆ IsDragging()

bool EDA_ITEM::IsDragging ( ) const
inlineinherited

Definition at line 201 of file base_struct.h.

201 { return m_Flags & IS_DRAGGED; }
#define IS_DRAGGED
Item being dragged.
Definition: base_struct.h:119
STATUS_FLAGS m_Flags
Definition: base_struct.h:176

References IS_DRAGGED, and EDA_ITEM::m_Flags.

Referenced by DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC(), and KIGFX::SCH_PAINTER::setDeviceColors().

◆ IsForceVisible()

bool EDA_ITEM::IsForceVisible ( ) const
inlineinherited

Definition at line 286 of file base_struct.h.

286 { return m_forceVisible; }
bool m_forceVisible
Definition: base_struct.h:175

References EDA_ITEM::m_forceVisible.

Referenced by KIGFX::SCH_PAINTER::draw(), and SCH_FIELD::Print().

◆ IsModified()

bool EDA_ITEM::IsModified ( ) const
inlineinherited

Definition at line 198 of file base_struct.h.

198 { return m_Flags & IS_CHANGED; }
#define IS_CHANGED
std::function passed to nested users by ref, avoids copying std::function
Definition: base_struct.h:113
STATUS_FLAGS m_Flags
Definition: base_struct.h:176

References IS_CHANGED, and EDA_ITEM::m_Flags.

Referenced by PCB_EDIT_FRAME::OpenProjectFiles().

◆ IsMoving()

◆ IsNew()

◆ IsReplaceable()

virtual bool EDA_ITEM::IsReplaceable ( ) const
inlinevirtualinherited

Function IsReplaceable.

Override this method in any derived object that supports test find and replace.

Returns
True if the item has replaceable text that can be modified using the find and replace dialog.

Reimplemented in SCH_COMPONENT, SCH_SHEET, SCH_LABEL, SCH_TEXT, SCH_SHEET_PIN, and SCH_FIELD.

Definition at line 501 of file base_struct.h.

501 { return false; }

Referenced by EDA_ITEM::Matches().

◆ IsResized()

bool EDA_ITEM::IsResized ( ) const
inlineinherited

Definition at line 204 of file base_struct.h.

204 { return m_Flags & IS_RESIZED; }
STATUS_FLAGS m_Flags
Definition: base_struct.h:176
#define IS_RESIZED
Item being resized.
Definition: base_struct.h:118

References IS_RESIZED, and EDA_ITEM::m_Flags.

Referenced by KIGFX::SCH_PAINTER::setDeviceColors().

◆ IsSelected()

◆ IsType()

virtual bool EDA_ITEM::IsType ( const KICAD_T  aScanTypes[]) const
inlinevirtualinherited

Function IsType Checks whether the item is one of the listed types.

Parameters
aScanTypesList of item types
Returns
true if the item type is contained in the list aScanTypes

Reimplemented in VIA, SCH_LABEL, DIMENSION, D_PAD, DRAWSEGMENT, TEXTE_MODULE, SCH_FIELD, SCH_LINE, EDGE_MODULE, and TEXTE_PCB.

Definition at line 262 of file base_struct.h.

263  {
264  if( aScanTypes[0] == SCH_LOCATE_ANY_T )
265  return true;
266 
267  for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
268  {
269  if( m_StructType == *p )
270  return true;
271  }
272 
273  return false;
274  }
KICAD_T m_StructType
Run time identification, keep private so it can never be changed after a constructor sets it.
Definition: base_struct.h:170
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78

References EOT, EDA_ITEM::m_StructType, and SCH_LOCATE_ANY_T.

Referenced by GetRule(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingBus(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingLine(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingWire(), TEXTE_PCB::IsType(), EDGE_MODULE::IsType(), SCH_LINE::IsType(), SCH_FIELD::IsType(), TEXTE_MODULE::IsType(), DRAWSEGMENT::IsType(), D_PAD::IsType(), DIMENSION::IsType(), SCH_LABEL::IsType(), VIA::IsType(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), EE_SELECTION_TOOL::RequestSelection(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), EDA_ITEM::Visit(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ IsWireImage()

bool EDA_ITEM::IsWireImage ( ) const
inlineinherited

Definition at line 202 of file base_struct.h.

202 { return m_Flags & IS_WIRE_IMAGE; }
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.
Definition: base_struct.h:121
STATUS_FLAGS m_Flags
Definition: base_struct.h:176

References IS_WIRE_IMAGE, and EDA_ITEM::m_Flags.

◆ IterateForward() [1/2]

template<class T >
static SEARCH_RESULT EDA_ITEM::IterateForward ( std::deque< T > &  aList,
INSPECTOR  inspector,
void *  testData,
const KICAD_T  scanTypes[] 
)
inlinestaticinherited

IterateForward( EDA_ITEM*, INSPECTOR, void*, const KICAD_T )

IterateForward( EDA_ITEM*, INSPECTOR, void*, const KICAD_T )

This changes first parameter to avoid the DList and use the main queue instead

Definition at line 383 of file base_struct.h.

387  {
388  for( auto it : aList )
389  {
390  if( static_cast<EDA_ITEM*>( it )->Visit( inspector, testData, scanTypes )
392  return SEARCH_RESULT::QUIT;
393  }
394 
396  }
virtual SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
Function Visit may be re-implemented for each derived class in order to handle all the types given by...

References CONTINUE, QUIT, and EDA_ITEM::Visit().

Referenced by Visit(), and BOARD::Visit().

◆ IterateForward() [2/2]

template<class T >
static SEARCH_RESULT EDA_ITEM::IterateForward ( std::vector< T > &  aList,
INSPECTOR  inspector,
void *  testData,
const KICAD_T  scanTypes[] 
)
inlinestaticinherited

IterateForward( EDA_ITEM*, INSPECTOR, void*, const KICAD_T )

IterateForward( EDA_ITEM*, INSPECTOR, void*, const KICAD_T )

This changes first parameter to avoid the DList and use std::vector instead

Definition at line 404 of file base_struct.h.

406  {
407  for( auto it : aList )
408  {
409  if( static_cast<EDA_ITEM*>( it )->Visit( inspector, testData, scanTypes )
411  return SEARCH_RESULT::QUIT;
412  }
413 
415  }
virtual SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
Function Visit may be re-implemented for each derived class in order to handle all the types given by...

References CONTINUE, QUIT, and EDA_ITEM::Visit().

◆ LoadGerberFile()

bool GERBER_FILE_IMAGE::LoadGerberFile ( const wxString &  aFullFileName)

Read and load a gerber file.

Parameters
aFullFileName= the full filename of the Gerber file when the file cannot be loaded Warning and info messages are stored in m_messagesList
Returns
bool if OK, false if the gerber file was not loaded

Definition at line 117 of file readgerb.cpp.

118 {
119  int G_command = 0; // command number for G commands like G04
120  int D_commande = 0; // command number for D commands like D02
121  char* text;
122 
123  ClearMessageList( );
125 
126  // Read the gerber file */
127  m_Current_File = wxFopen( aFullFileName, wxT( "rt" ) );
128 
129  if( m_Current_File == 0 )
130  return false;
131 
132  m_FileName = aFullFileName;
133 
134  LOCALE_IO toggleIo;
135 
136  wxString msg;
137 
138  while( true )
139  {
140  if( fgets( lineBuffer, GERBER_BUFZ, m_Current_File ) == NULL )
141  break;
142 
143  m_LineNum++;
144  text = StrPurge( lineBuffer );
145 
146  while( text && *text )
147  {
148  switch( *text )
149  {
150  case ' ':
151  case '\r':
152  case '\n':
153  text++;
154  break;
155 
156  case '*': // End command
158  text++;
159  break;
160 
161  case 'M': // End file
163  while( *text )
164  text++;
165  break;
166 
167  case 'G': /* Line type Gxx : command */
168  G_command = GCodeNumber( text );
169  Execute_G_Command( text, G_command );
170  break;
171 
172  case 'D': /* Line type Dxx : Tool selection (xx > 0) or
173  * command if xx = 0..9 */
174  D_commande = DCodeNumber( text );
175  Execute_DCODE_Command( text, D_commande );
176  break;
177 
178  case 'X':
179  case 'Y': /* Move or draw command */
180  m_CurrentPos = ReadXYCoord( text );
181  if( *text == '*' ) // command like X12550Y19250*
182  {
184  }
185  break;
186 
187  case 'I':
188  case 'J': /* Auxiliary Move command */
189  m_IJPos = ReadIJCoord( text );
190 
191  if( *text == '*' ) // command like X35142Y15945J504*
192  {
194  }
195  break;
196 
197  case '%':
199  {
202  }
203  else //Error
204  {
205  AddMessageToList( "Expected RS274X Command" );
207  text++;
208  }
209  break;
210 
211  default:
212  msg.Printf( "Unexpected char 0x%2.2X &lt;%c&lt;", *text, *text );
213  AddMessageToList( msg );
214  text++;
215  break;
216  }
217  }
218  }
219 
220  fclose( m_Current_File );
221 
222  m_InUse = true;
223 
224  return true;
225 }
void AddMessageToList(const wxString &aMessage)
Function AddMessageToList Add a message to the message list.
bool Execute_DCODE_Command(char *&text, int D_command)
Definition: rs274d.cpp:587
char * StrPurge(char *text)
Remove leading and training spaces, tabs and end of line chars in text.
Definition: string.cpp:344
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:216
wxPoint ReadIJCoord(char *&Text)
Returns the current coordinate type pointed to by InnJnn Text (InnnnJmmmm) These coordinates are rela...
void ClearMessageList()
Function ClearMessageList Clear the message list Call it before reading a Gerber file.
int GCodeNumber(char *&Text)
Definition: rs274d.cpp:411
static char lineBuffer[GERBER_BUFZ+1]
Definition: readgerb.cpp:115
#define NULL
int DCodeNumber(char *&Text)
Definition: rs274d.cpp:434
#define GERBER_BUFZ
Definition: readgerb.cpp:113
wxPoint ReadXYCoord(char *&aText, bool aExcellonMode=false)
Function ReadXYCoord Returns the current coordinate type pointed to by XnnYnn Text (XnnnnYmmmm)
bool Execute_G_Command(char *&text, int G_command)
Definition: rs274d.cpp:454
bool ReadRS274XCommand(char *aBuff, unsigned int aBuffSize, char *&aText)
reads a single RS274X command terminated with a %
Definition: rs274x.cpp:144
virtual void ResetDefaultValues()

References AddMessageToList(), ClearMessageList(), CMD_IDLE, DCodeNumber(), END_BLOCK, ENTER_RS274X_CMD, Execute_DCODE_Command(), Execute_G_Command(), GCodeNumber(), GERBER_BUFZ, lineBuffer, m_CommandState, m_Current_File, m_CurrentPos, m_FileName, m_IJPos, m_InUse, m_Last_Pen_Command, m_LineNum, NULL, ReadIJCoord(), ReadRS274XCommand(), ReadXYCoord(), ResetDefaultValues(), and StrPurge().

Referenced by GERBVIEW_FRAME::Read_GERBER_File().

◆ Matches() [1/2]

virtual bool EDA_ITEM::Matches ( wxFindReplaceData &  aSearchData,
void *  aAuxData 
)
inlinevirtualinherited

Function Matches compares the item against the search criteria in aSearchData.

The base class returns false since many of the objects derived from EDA_ITEM do not have any text to search.

Parameters
aSearchDataA reference to a wxFindReplaceData object containing the search criteria.
aAuxDataA pointer to optional data required for the search or NULL if not used.
Returns
True if the item's text matches the search criteria in aSearchData.

Reimplemented in SCH_COMPONENT, SCH_SHEET, SCH_TEXT, SCH_SHEET_PIN, SCH_FIELD, LIB_PIN, SCH_PIN, TEXTE_MODULE, SCH_MARKER, MARKER_PCB, MARKER_PCB, and TEXTE_PCB.

Definition at line 457 of file base_struct.h.

458  {
459  return false;
460  }

Referenced by SCH_EDITOR_CONTROL::HasMatch(), TEXTE_PCB::Matches(), MARKER_PCB::Matches(), SCH_MARKER::Matches(), TEXTE_MODULE::Matches(), LIB_PIN::Matches(), SCH_FIELD::Matches(), SCH_SHEET_PIN::Matches(), SCH_TEXT::Matches(), and SCH_EDITOR_CONTROL::ReplaceAndFindNext().

◆ Matches() [2/2]

bool EDA_ITEM::Matches ( const wxString &  aText,
wxFindReplaceData &  aSearchData 
)
protectedinherited

Function Matches compares aText against search criteria in aSearchData.

This is a helper function for simplify derived class logic.

Parameters
aTextA reference to a wxString object containing the string to test.
aSearchDataThe criteria to search against.
Returns
True if aText matches the search criteria in aSearchData.

Definition at line 145 of file base_struct.cpp.

146 {
147  wxString text = aText;
148  wxString searchText = aSearchData.GetFindString();
149 
150  // Don't match if searching for replaceable item and the item doesn't support text replace.
151  if( (aSearchData.GetFlags() & FR_SEARCH_REPLACE) && !IsReplaceable() )
152  return false;
153 
154  if( aSearchData.GetFlags() & wxFR_WHOLEWORD )
155  return aText.IsSameAs( searchText, aSearchData.GetFlags() & wxFR_MATCHCASE );
156 
157  if( aSearchData.GetFlags() & FR_MATCH_WILDCARD )
158  {
159  if( aSearchData.GetFlags() & wxFR_MATCHCASE )
160  return text.Matches( searchText );
161 
162  return text.MakeUpper().Matches( searchText.MakeUpper() );
163  }
164 
165  if( aSearchData.GetFlags() & wxFR_MATCHCASE )
166  return aText.Find( searchText ) != wxNOT_FOUND;
167 
168  return text.MakeUpper().Find( searchText.MakeUpper() ) != wxNOT_FOUND;
169 }
virtual bool IsReplaceable() const
Function IsReplaceable.
Definition: base_struct.h:501

References FR_MATCH_WILDCARD, FR_SEARCH_REPLACE, and EDA_ITEM::IsReplaceable().

◆ operator<()

bool EDA_ITEM::operator< ( const EDA_ITEM aItem) const
inherited

Test if another item is less than this object.

Parameters
aItem- Item to compare against.
Returns
- True if aItem is less than the item.

Definition at line 199 of file base_struct.cpp.

200 {
201  wxFAIL_MSG( wxString::Format( wxT( "Less than operator not defined for item type %s." ),
202  GetChars( GetClass() ) ) );
203 
204  return false;
205 }
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:153
virtual wxString GetClass() const =0
Function GetClass returns the class name.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205

References Format(), GetChars(), and EDA_ITEM::GetClass().

◆ ReadApertureMacro()

bool GERBER_FILE_IMAGE::ReadApertureMacro ( char *  aBuff,
unsigned int  aBuffSize,
char *&  text,
FILE *  gerber_file 
)
private

reads in an aperture macro and saves it in m_aperture_macros.

Parameters
aBuffa character buffer at least GERBER_BUFZ long that can be used to read successive lines from the gerber file.
textA reference to a character pointer which gives the initial text to read from.
aBuffSizeis the size of aBuff
gerber_fileWhich file to read from for continuation.
Returns
bool - true if a macro was read in successfully, else false.

Definition at line 922 of file rs274x.cpp.

925 {
926  wxString msg;
927  APERTURE_MACRO am;
928 
929  // read macro name
930  while( *aText )
931  {
932  if( *aText == '*' )
933  {
934  ++aText;
935  break;
936  }
937 
938  am.name.Append( *aText++ );
939  }
940 
941  // Read aperture macro parameters
942  for( ; ; )
943  {
944  if( *aText == '*' )
945  ++aText;
946 
947  aText = GetNextLine( aBuff, aBuffSize, aText, gerber_file );
948 
949  if( aText == NULL ) // End of File
950  return false;
951 
952  // aText points the beginning of a new line.
953 
954  // Test for the last line in aperture macro lis:
955  // last line is % or *% sometime found.
956  if( *aText == '*' )
957  ++aText;
958 
959  if( *aText == '%' )
960  break; // exit with aText still pointing at %
961 
962  int paramCount = 0; // will be set to the minimal parameters count,
963  // depending on the actual primitive
964  int primitive_type = AMP_UNKNOWN;
965  // Test for a valid symbol at the beginning of a description:
966  // it can be: a parameter declaration like $1=$2/4
967  // or a digit (macro primitive selection)
968  // all other symbols are illegal.
969  if( *aText == '$' ) // local parameter declaration, inside the aperture macro
970  {
971  am.m_localparamStack.push_back( AM_PARAM() );
972  AM_PARAM& param = am.m_localparamStack.back();
973  aText = GetNextLine( aBuff, aBuffSize, aText, gerber_file );
974  if( aText == NULL) // End of File
975  return false;
976  param.ReadParam( aText );
977  continue;
978  }
979  else if( !isdigit(*aText) ) // Ill. symbol
980  {
981  msg.Printf( wxT( "RS274X: Aperture Macro \"%s\": ill. symbol, line: \"%s\"" ),
982  GetChars( am.name ), GetChars( FROM_UTF8( aBuff ) ) );
983  AddMessageToList( msg );
984  primitive_type = AMP_COMMENT;
985  }
986  else
987  primitive_type = ReadInt( aText );
988 
989  bool is_comment = false;
990 
991  switch( primitive_type )
992  {
993  case AMP_COMMENT: // lines starting by 0 are a comment
994  paramCount = 0;
995  is_comment = true;
996  // Skip comment
997  while( *aText && ( *aText != '*' ) )
998  aText++;
999  break;
1000 
1001  case AMP_CIRCLE:
1002  paramCount = 4; // minimal count. can have a optional parameter (rotation)
1003  break;
1004 
1005  case AMP_LINE2:
1006  case AMP_LINE20:
1007  paramCount = 7;
1008  break;
1009 
1010  case AMP_LINE_CENTER:
1011  case AMP_LINE_LOWER_LEFT:
1012  paramCount = 6;
1013  break;
1014 
1015  case AMP_EOF:
1016  paramCount = 0;
1017  break;
1018 
1019  case AMP_OUTLINE:
1020  paramCount = 4; // partial count. other parameters are vertices and rotation
1021  // Second parameter is vertice (coordinate pairs) count.
1022  break;
1023 
1024  case AMP_POLYGON:
1025  paramCount = 6;
1026  break;
1027 
1028  case AMP_MOIRE:
1029  paramCount = 9;
1030  break;
1031 
1032  case AMP_THERMAL:
1033  paramCount = 6;
1034  break;
1035 
1036  default:
1037  msg.Printf( wxT( "RS274X: Aperture Macro \"%s\": Invalid primitive id code %d, line %d: \"%s\"" ),
1038  GetChars( am.name ), primitive_type, m_LineNum, GetChars( FROM_UTF8( aBuff ) ) );
1039  AddMessageToList( msg );
1040  return false;
1041  }
1042 
1043  if( is_comment )
1044  continue;
1045 
1046  AM_PRIMITIVE prim( m_GerbMetric );
1047  prim.primitive_id = (AM_PRIMITIVE_ID) primitive_type;
1048  int ii;
1049 
1050  for( ii = 0; ii < paramCount && *aText && *aText != '*'; ++ii )
1051  {
1052  prim.params.push_back( AM_PARAM() );
1053 
1054  AM_PARAM& param = prim.params.back();
1055 
1056  aText = GetNextLine( aBuff, aBuffSize, aText, gerber_file );
1057 
1058  if( aText == NULL) // End of File
1059  return false;
1060 
1061  param.ReadParam( aText );
1062  }
1063 
1064  if( ii < paramCount )
1065  {
1066  // maybe some day we can throw an exception and track a line number
1067  msg.Printf( "RS274X: read macro descr type %d: read %d parameters, insufficient parameters\n",
1068  prim.primitive_id, ii );
1069  AddMessageToList( msg );
1070  }
1071 
1072  // there are more parameters to read if this is an AMP_OUTLINE
1073  if( prim.primitive_id == AMP_OUTLINE )
1074  {
1075  // so far we have read [0]:exposure, [1]:#points, [2]:X start, [3]: Y start
1076  // Now read all the points, plus trailing rotation in degrees.
1077 
1078  // params[1] is a count of polygon points, so it must be given
1079  // in advance, i.e. be immediate.
1080  wxASSERT( prim.params[1].IsImmediate() );
1081 
1082  paramCount = (int) prim.params[1].GetValue( 0 ) * 2 + 1;
1083 
1084  for( int jj = 0; jj < paramCount && *aText != '*'; ++jj )
1085  {
1086  prim.params.push_back( AM_PARAM() );
1087 
1088  AM_PARAM& param = prim.params.back();
1089 
1090  aText = GetNextLine( aBuff, aBuffSize, aText, gerber_file );
1091 
1092  if( aText == NULL ) // End of File
1093  return false;
1094 
1095  param.ReadParam( aText );
1096  }
1097  }
1098 
1099  // AMP_CIRCLE can have a optional parameter (rotation)
1100  if( prim.primitive_id == AMP_CIRCLE && aText && *aText != '*' )
1101  {
1102  prim.params.push_back( AM_PARAM() );
1103  AM_PARAM& param = prim.params.back();
1104  param.ReadParam( aText );
1105  }
1106 
1107  am.primitives.push_back( prim );
1108  }
1109 
1110  m_aperture_macros.insert( am );
1111 
1112  return true;
1113 }
APERTURE_MACRO_SET m_aperture_macros
a collection of APERTURE_MACROS, sorted by name
void AddMessageToList(const wxString &aMessage)
Function AddMessageToList Add a message to the message list.
wxString name
The name of the aperture macro.
Definition: am_primitive.h:165
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:114
int ReadInt(char *&text, bool aSkipSeparator=true)
Function ReadInt reads an int from an ASCII character buffer.
bool ReadParam(char *&aText)
Function ReadParam Read one aperture macro parameter a parameter can be: a number a reference to an a...
Definition: am_param.cpp:172
AM_PARAMS m_localparamStack
Definition: am_primitive.h:174
char * GetNextLine(char *aBuff, unsigned int aBuffSize, char *aText, FILE *aFile)
test for an end of line if a end of line is found: read a new line
Definition: rs274x.cpp:894
#define NULL
AM_PARAM holds a parameter value for an "aperture macro" as defined within standard RS274X.
Definition: am_param.h:286
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:153
AM_PRIMITIVES primitives
A sequence of AM_PRIMITIVEs.
Definition: am_primitive.h:166
Struct AM_PRIMITIVE holds an aperture macro primitive as given in Table 3 of http://gerbv....
Definition: am_primitive.h:92
AM_PRIMITIVE_ID
Enum AM_PRIMITIVE_ID is the set of all "aperture macro primitives" (primitive numbers).
Definition: am_primitive.h:71
Struct APERTURE_MACRO helps support the "aperture macro" defined within standard RS274X.
Definition: am_primitive.h:163

References AddMessageToList(), AMP_CIRCLE, AMP_COMMENT, AMP_EOF, AMP_LINE2, AMP_LINE20, AMP_LINE_CENTER, AMP_LINE_LOWER_LEFT, AMP_MOIRE, AMP_OUTLINE, AMP_POLYGON, AMP_THERMAL, AMP_UNKNOWN, FROM_UTF8(), GetChars(), GetNextLine(), m_aperture_macros, m_GerbMetric, m_LineNum, APERTURE_MACRO::m_localparamStack, APERTURE_MACRO::name, NULL, AM_PRIMITIVE::params, AM_PRIMITIVE::primitive_id, APERTURE_MACRO::primitives, ReadInt(), and AM_PARAM::ReadParam().

Referenced by ExecuteRS274XCommand().

◆ ReadIJCoord()

wxPoint GERBER_FILE_IMAGE::ReadIJCoord ( char *&  Text)

Returns the current coordinate type pointed to by InnJnn Text (InnnnJmmmm) These coordinates are relative, so if coordinate is absent, it's value defaults to 0.

Definition at line 191 of file rs274_read_XY_and_IJ_coordinates.cpp.

192 {
193  wxPoint pos( 0, 0 );
194 
195  int type_coord = 0, current_coord, nbdigits;
196  bool is_float = false;
197  char* text;
198  char line[256];
199 
200  if( Text == NULL )
201  return pos;
202 
203  text = line;
204  while( *Text )
205  {
206  if( (*Text == 'I') || (*Text == 'J') )
207  {
208  type_coord = *Text;
209  Text++;
210  text = line;
211  nbdigits = 0;
212  while( IsNumber( *Text ) )
213  {
214  if( *Text == '.' )
215  is_float = true;
216 
217  // count digits only (sign and decimal point are not counted)
218  if( (*Text >= '0') && (*Text <='9') )
219  nbdigits++;
220 
221  *(text++) = *(Text++);
222  }
223 
224  *text = 0;
225  if( is_float )
226  {
227  // When X or Y values are float numbers, they are given in mm or inches
228  if( m_GerbMetric ) // units are mm
229  current_coord = KiROUND( atof( line ) * IU_PER_MILS / 0.0254 );
230  else // units are inches
231  current_coord = KiROUND( atof( line ) * IU_PER_MILS * 1000 );
232  }
233  else
234  {
235  int fmt_scale =
236  (type_coord == 'I') ? m_FmtScale.x : m_FmtScale.y;
237 
238  if( m_NoTrailingZeros )
239  {
240  int min_digit =
241  (type_coord == 'I') ? m_FmtLen.x : m_FmtLen.y;
242  while( nbdigits < min_digit )
243  {
244  *(text++) = '0';
245  nbdigits++;
246  }
247 
248  *text = 0;
249  }
250 
251  current_coord = atoi( line );
252 
253  double real_scale = scale_list[fmt_scale];
254 
255  if( m_GerbMetric )
256  real_scale = real_scale / 25.4;
257 
258  current_coord = KiROUND( current_coord * real_scale );
259  }
260  if( type_coord == 'I' )
261  pos.x = current_coord;
262  else if( type_coord == 'J' )
263  pos.y = current_coord;
264 
265  continue;
266  }
267  else
268  break;
269  }
270 
271  m_IJPos = pos;
273  m_LastCoordIsIJPos = true;
274 
275  return pos;
276 }
#define NULL
static double scale_list[SCALE_LIST_SIZE]
LAST_EXTRA_ARC_DATA_TYPE m_LastArcDataType
#define IU_PER_MILS
Definition: plotter.cpp:138
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68
#define IsNumber(x)

References ARC_INFO_TYPE_CENTER, IsNumber, IU_PER_MILS, KiROUND(), m_FmtLen, m_FmtScale, m_GerbMetric, m_IJPos, m_LastArcDataType, m_LastCoordIsIJPos, m_NoTrailingZeros, NULL, scale_list, wxPoint::x, and wxPoint::y.

Referenced by EXCELLON_IMAGE::Execute_Drill_Command(), EXCELLON_IMAGE::Execute_EXCELLON_G_Command(), EXCELLON_IMAGE::LoadFile(), and LoadGerberFile().

◆ ReadRS274XCommand()

bool GERBER_FILE_IMAGE::ReadRS274XCommand ( char *  aBuff,
unsigned int  aBuffSize,
char *&  aText 
)
private

reads a single RS274X command terminated with a %

Definition at line 144 of file rs274x.cpp.

145 {
146  bool ok = true;
147  int code_command;
148 
149  aText++;
150 
151  for( ; ; )
152  {
153  while( *aText )
154  {
155  switch( *aText )
156  {
157  case '%': // end of command
158  aText++;
160  goto exit; // success completion
161 
162  case ' ':
163  case '\r':
164  case '\n':
165  aText++;
166  break;
167 
168  case '*':
169  aText++;
170  break;
171 
172  default:
173  code_command = ReadXCommandID( aText );
174  ok = ExecuteRS274XCommand( code_command, aBuff, aBuffSize, aText );
175 
176  if( !ok )
177  goto exit;
178 
179  break;
180  }
181  }
182 
183  // end of current line, read another one.
184  if( fgets( aBuff, aBuffSize, m_Current_File ) == NULL )
185  {
186  // end of file
187  ok = false;
188  break;
189  }
190  m_LineNum++;
191  aText = aBuff;
192  }
193 
194 exit:
195  return ok;
196 }
int ReadXCommandID(char *&text)
reads two bytes of data and assembles them into an int with the first byte in the sequence put into t...
Definition: rs274x.cpp:116
bool ExecuteRS274XCommand(int aCommand, char *aBuff, unsigned int aBuffSize, char *&aText)
executes a RS274X command
Definition: rs274x.cpp:199
#define NULL

References CMD_IDLE, ExecuteRS274XCommand(), m_CommandState, m_Current_File, m_LineNum, NULL, and ReadXCommandID().

Referenced by LoadGerberFile().

◆ ReadXCommandID()

int GERBER_FILE_IMAGE::ReadXCommandID ( char *&  text)
private

reads two bytes of data and assembles them into an int with the first byte in the sequence put into the most significant part of a 16 bit value to build a RS274X command identifier.

Parameters
textA reference to a pointer to read bytes from and to advance as they are read.
Returns
a RS274X command identifier.

Definition at line 116 of file rs274x.cpp.

117 {
118  /* reads two bytes of data and assembles them into an int with the first
119  * byte in the sequence put into the most significant part of a 16 bit value
120  */
121  int result;
122  int currbyte;
123 
124  if( text && *text )
125  {
126  currbyte = *text++;
127  result = ( currbyte & 0xFF ) << 8;
128  }
129  else
130  return -1;
131 
132  if( text && *text )
133  {
134  currbyte = *text++;
135  result += currbyte & 0xFF;
136  }
137  else
138  return -1;
139 
140  return result;
141 }

Referenced by Execute_G_Command(), ExecuteRS274XCommand(), and ReadRS274XCommand().

◆ ReadXYCoord()

wxPoint GERBER_FILE_IMAGE::ReadXYCoord ( char *&  aText,
bool  aExcellonMode = false 
)

Function ReadXYCoord Returns the current coordinate type pointed to by XnnYnn Text (XnnnnYmmmm)

Parameters
aTextis a pointer to the text to parse.
aExcellonMode= true to parse a Excellon drill file. it force truncation of a digit string to a max len because the exact coordinate format is not always known

Definition at line 73 of file rs274_read_XY_and_IJ_coordinates.cpp.

74 {
75  wxPoint pos;
76  int type_coord = 0, current_coord, nbdigits;
77  bool is_float = false;
78  char* text;
79  char line[256];
80 
81 
82  if( m_Relative )
83  pos.x = pos.y = 0;
84  else
85  pos = m_CurrentPos;
86 
87  if( Text == NULL )
88  return pos;
89 
90  text = line;
91  while( *Text )
92  {
93  if( (*Text == 'X') || (*Text == 'Y') || (*Text == 'A') )
94  {
95  type_coord = *Text;
96  Text++;
97  text = line;
98  nbdigits = 0;
99 
100  while( IsNumber( *Text ) )
101  {
102  if( *Text == '.' ) // Force decimat format if reading a floating point number
103  is_float = true;
104 
105  // count digits only (sign and decimal point are not counted)
106  if( (*Text >= '0') && (*Text <='9') )
107  nbdigits++;
108  *(text++) = *(Text++);
109  }
110 
111  *text = 0;
112 
113  if( is_float )
114  {
115  // When X or Y (or A) values are float numbers, they are given in mm or inches
116  if( m_GerbMetric ) // units are mm
117  current_coord = KiROUND( atof( line ) * IU_PER_MILS / 0.0254 );
118  else // units are inches
119  current_coord = KiROUND( atof( line ) * IU_PER_MILS * 1000 );
120  }
121  else
122  {
123  int fmt_scale = (type_coord == 'X') ? m_FmtScale.x : m_FmtScale.y;
124 
125  if( m_NoTrailingZeros )
126  {
127  // no trailing zero format, we need to add missing zeros.
128  int digit_count = (type_coord == 'X') ? m_FmtLen.x : m_FmtLen.y;
129 
130  while( nbdigits < digit_count )
131  {
132  *(text++) = '0';
133  nbdigits++;
134  }
135 
136  if( aExcellonMode )
137  {
138  // Truncate the extra digits if the len is more than expected
139  // because the conversion to internal units expect exactly
140  // digit_count digits
141  while( nbdigits > digit_count )
142  {
143  *(text--) = 0;
144  nbdigits--;
145  }
146  }
147 
148  *text = 0;
149  }
150 
151  current_coord = atoi( line );
152  double real_scale = scale_list[fmt_scale];
153 
154  if( m_GerbMetric )
155  real_scale = real_scale / 25.4;
156 
157  current_coord = KiROUND( current_coord * real_scale );
158  }
159 
160  if( type_coord == 'X' )
161  pos.x = current_coord;
162  else if( type_coord == 'Y' )
163  pos.y = current_coord;
164  else if( type_coord == 'A' )
165  {
166  m_ArcRadius = current_coord;
168  }
169 
170  continue;
171  }
172  else
173  break;
174  }
175 
176  if( m_Relative )
177  {
178  pos.x += m_CurrentPos.x;
179  pos.y += m_CurrentPos.y;
180  }
181 
182  m_CurrentPos = pos;
183  return pos;
184 }
#define NULL
static double scale_list[SCALE_LIST_SIZE]
LAST_EXTRA_ARC_DATA_TYPE m_LastArcDataType
#define IU_PER_MILS
Definition: plotter.cpp:138
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68
#define IsNumber(x)

References ARC_INFO_TYPE_RADIUS, IsNumber, IU_PER_MILS, KiROUND(), m_ArcRadius, m_CurrentPos, m_FmtLen, m_FmtScale, m_GerbMetric, m_LastArcDataType, m_NoTrailingZeros, m_Relative, NULL, scale_list, wxPoint::x, and wxPoint::y.

Referenced by EXCELLON_IMAGE::Execute_Drill_Command(), EXCELLON_IMAGE::Execute_EXCELLON_G_Command(), and LoadGerberFile().

◆ RemoveAttribute()

void GERBER_FILE_IMAGE::RemoveAttribute ( X2_ATTRIBUTE aAttribute)

Function RemoveAttribute.

Called when a TD command is found the Gerber file

Parameters
aAttributeis the X2_ATTRIBUTE which stores the full command Remove the attribute specified by the TD command. is no attribute, all current attributes specified by the TO and the TA commands are cleared. if a attribute name is specified (for instance TD.CN*%) is specified, only this attribute is cleared

Definition at line 374 of file gerber_file_image.cpp.

375 {
376  /* Called when a %TD command is found
377  * Remove the attribute specified by the %TD command.
378  * is no attribute, all current attributes specified by the %TO and the %TA
379  * commands are cleared.
380  * if a attribute name is specified (for instance %TD.CN*%) is specified,
381  * only this attribute is cleared
382  */
383  wxString cmd = aAttribute.GetPrm( 0 );
385 
386  if( cmd.IsEmpty() || cmd == ".AperFunction" )
387  m_AperFunction.Clear();
388 }
const wxString & GetPrm(int aIdx)
GBR_NETLIST_METADATA m_NetAttributeDict
void ClearAttribute(const wxString *aName)
remove the net attribute specified by aName If aName == NULL or empty, remove all attributes

References GBR_NETLIST_METADATA::ClearAttribute(), X2_ATTRIBUTE::GetPrm(), m_AperFunction, and m_NetAttributeDict.

Referenced by ExecuteRS274XCommand().

◆ Replace() [1/2]

bool EDA_ITEM::Replace ( wxFindReplaceData &  aSearchData,
wxString &  aText 
)
staticinherited

Helper function used in search and replace dialog Function Replace performs a text replace on aText using the find and replace criteria in aSearchData on items that support text find and replace.

Parameters
aSearchDataA reference to a wxFindReplaceData object containing the search and replace criteria.
aTextA reference to a wxString object containing the text to be replaced.
Returns
True if aText was modified, otherwise false.

Definition at line 172 of file base_struct.cpp.

173 {
174  wxString searchString = (aSearchData.GetFlags() & wxFR_MATCHCASE) ? aText : aText.Upper();
175 
176  int result = searchString.Find( (aSearchData.GetFlags() & wxFR_MATCHCASE) ?
177  aSearchData.GetFindString() :
178  aSearchData.GetFindString().Upper() );
179 
180  if( result == wxNOT_FOUND )
181  return false;
182 
183  wxString prefix = aText.Left( result );
184  wxString suffix;
185 
186  if( aSearchData.GetFindString().length() + result < aText.length() )
187  suffix = aText.Right( aText.length() - ( aSearchData.GetFindString().length() + result ) );
188 
189  wxLogTrace( traceFindReplace, wxT( "Replacing '%s', prefix '%s', replace '%s', suffix '%s'." ),
190  GetChars( aText ), GetChars( prefix ), GetChars( aSearchData.GetReplaceString() ),
191  GetChars( suffix ) );
192 
193  aText = prefix + aSearchData.GetReplaceString() + suffix;
194 
195  return true;
196 }
const wxChar *const traceFindReplace
Flag to enable find and replace debug tracing.
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:153

References GetChars(), and traceFindReplace.

Referenced by SCH_FIELD::Replace(), EDA_TEXT::Replace(), and SCH_EDITOR_CONTROL::ReplaceAndFindNext().

◆ Replace() [2/2]

virtual bool EDA_ITEM::Replace ( wxFindReplaceData &  aSearchData,
void *  aAuxData = NULL 
)
inlinevirtualinherited

Function Replace performs a text replace using the find and replace criteria in aSearchData on items that support text find and replace.

This function must be overridden for items that support text replace.

Parameters
aSearchDataA reference to a wxFindReplaceData object containing the search and replace criteria.
aAuxDataA pointer to optional data required for the search or NULL if not used.
Returns
True if the item text was modified, otherwise false.

Reimplemented in SCH_TEXT, SCH_SHEET_PIN, and SCH_FIELD.

Definition at line 489 of file base_struct.h.

489 { return false; }

◆ ResetDefaultValues()

void GERBER_FILE_IMAGE::ResetDefaultValues ( )
virtual

Reimplemented in EXCELLON_IMAGE.

Definition at line 170 of file gerber_file_image.cpp.

171 {
172  m_InUse = false;
174  m_FileName.Empty();
175  m_ImageName = wxT( "no name" ); // Image name from the IN command
176  m_ImageNegative = false; // true = Negative image
177  m_IsX2_file = false; // true only if a %TF, %TA or %TD command
178  delete m_FileFunction; // file function parameters
180  m_MD5_value.Empty(); // MD5 value found in a %TF.MD5 command
181  m_PartString.Empty(); // string found in a %TF.Part command
182  m_hasNegativeItems = -1; // set to uninitialized
183  m_ImageJustifyOffset = wxPoint(0,0); // Image justify Offset
184  m_ImageJustifyXCenter = false; // Image Justify Center on X axis (default = false)
185  m_ImageJustifyYCenter = false; // Image Justify Center on Y axis (default = false)
186  m_GerbMetric = false; // false = Inches (default), true = metric
187  m_Relative = false; // false = absolute Coord,
188  // true = relative Coord
189  m_NoTrailingZeros = false; // true: trailing zeros deleted
190  m_ImageOffset.x = m_ImageOffset.y = 0; // Coord Offset, from IO command
191  m_ImageRotation = 0; // Allowed 0, 90, 180, 270 (in degree)
192  m_LocalRotation = 0.0; // Layer totation from RO command (in 0.1 degree)
193  m_Offset.x = 0;
194  m_Offset.y = 0; // Coord Offset, from OF command
195  m_Scale.x = m_Scale.y = 1.0; // scale (A and B) this layer
196  m_MirrorA = false; // true: miror / axe A (default = X)
197  m_MirrorB = false; // true: miror / axe B (default = Y)
198  m_SwapAxis = false; // false if A = X, B = Y; true if A =Y, B = Y
199  m_Has_DCode = false; // true = DCodes in file
200  // false = no DCode-> perhaps deprecated RS274D file
201  m_Has_MissingDCode = false; // true = some D_Codes are used, but not defined
202  // perhaps deprecated RS274D file
203  m_FmtScale.x = m_FmtScale.y = 4; // Initialize default format to 3.4 => 4
204  m_FmtLen.x = m_FmtLen.y = 3 + 4; // Initialize default format len = 3+4
205 
206  m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Linear, 90 arc, Circ.
207  m_360Arc_enbl = false; // 360 deg circular
208  // interpolation disable
209  m_AsArcG74G75Cmd = false; // false untile a G74 or G75 comand is found
210  m_Current_Tool = 0; // Current Dcode selected
211  m_CommandState = 0; // State of the current command
212  m_CurrentPos.x = m_CurrentPos.y = 0; // current specified coord
213  m_PreviousPos.x = m_PreviousPos.y = 0; // last specified coord
214  m_IJPos.x = m_IJPos.y = 0; // current centre coord for
215  // plot arcs & circles
216  m_LastCoordIsIJPos = false; // True only after a IJ coordinate is read
217  m_ArcRadius = 0; // radius of arcs in circular interpol (given by A## command).
218  // in command like X##Y##A##
219  m_LastArcDataType = ARC_INFO_TYPE_NONE; // Extra coordinate info type for arcs
220  // (radius or IJ center coord)
221  m_LineNum = 0; // line number in file being read
222  m_Current_File = NULL; // Gerber file to read
223  m_PolygonFillMode = false;
225  m_Selected_Tool = 0;
226  m_Last_Pen_Command = 0;
227  m_Exposure = false;
228 }
X2_ATTRIBUTE_FILEFUNCTION * m_FileFunction
GERBER_LAYER m_GBRLayerParams
#define NULL
bool m_Exposure
whether an aperture macro tool is flashed on or off
LAST_EXTRA_ARC_DATA_TYPE m_LastArcDataType

References ARC_INFO_TYPE_NONE, GERB_INTERPOL_LINEAR_1X, m_360Arc_enbl, m_ArcRadius, m_AsArcG74G75Cmd, m_CommandState, m_Current_File, m_Current_Tool, m_CurrentPos, m_Exposure, m_FileFunction, m_FileName, m_FmtLen, m_FmtScale, m_GBRLayerParams, m_GerbMetric, m_Has_DCode, m_Has_MissingDCode, m_hasNegativeItems, m_IJPos, m_ImageJustifyOffset, m_ImageJustifyXCenter, m_ImageJustifyYCenter, m_ImageName, m_ImageNegative, m_ImageOffset, m_ImageRotation, m_InUse, m_IsX2_file, m_Iterpolation, m_Last_Pen_Command, m_LastArcDataType, m_LastCoordIsIJPos, m_LineNum, m_LocalRotation, m_MD5_value, m_MirrorA, m_MirrorB, m_NoTrailingZeros, m_Offset, m_PartString, m_PolygonFillMode, m_PolygonFillModeState, m_PreviousPos, m_Relative, m_Scale, m_Selected_Tool, m_SwapAxis, NULL, GERBER_LAYER::ResetDefaultValues(), wxPoint::x, and wxPoint::y.

Referenced by GERBER_FILE_IMAGE(), LoadGerberFile(), and EXCELLON_IMAGE::ResetDefaultValues().

◆ Set() [1/3]

bool INSPECTABLE::Set ( PROPERTY_BASE aProperty,
wxAny &  aValue 
)
inlineinherited

Definition at line 40 of file inspectable.h.

41  {
43  TYPE_ID thisType = TYPE_HASH( *this );
44  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
45 
46  if( object )
47  aProperty->setter( object, aValue );
48 
49  return object != nullptr;
50  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:61
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:53
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:38
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
virtual void setter(void *aObject, wxAny &aValue)=0
Provides class metadata.
Definition: property_mgr.h:58
virtual size_t OwnerHash() const =0
Returns type-id of the Owner class.

References PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), PROPERTY_BASE::setter(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

◆ Set() [2/3]

template<typename T >
bool INSPECTABLE::Set ( PROPERTY_BASE aProperty,
aValue 
)
inlineinherited

Definition at line 53 of file inspectable.h.

54  {
56  TYPE_ID thisType = TYPE_HASH( *this );
57  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
58 
59  if( object )
60  aProperty->set<T>( object, aValue );
61 
62  return object != nullptr;
63  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:61
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:53
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:38
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
T
enum T contains all this lexer's tokens.
Provides class metadata.
Definition: property_mgr.h:58
void set(void *aObject, T aValue)
Definition: property.h:264
virtual size_t OwnerHash() const =0
Returns type-id of the Owner class.

References PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), PROPERTY_BASE::set(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

◆ Set() [3/3]

template<typename T >
bool INSPECTABLE::Set ( const wxString &  aProperty,
aValue 
)
inlineinherited

Definition at line 66 of file inspectable.h.

67  {
69  TYPE_ID thisType = TYPE_HASH( *this );
70  PROPERTY_BASE* prop = propMgr.GetProperty( thisType, aProperty );
71  void* object = nullptr;
72 
73  if( prop )
74  {
75  object = propMgr.TypeCast( this, thisType, prop->OwnerHash() );
76 
77  if( object )
78  prop->set<T>( object, aValue );
79  }
80 
81  return object != nullptr;
82  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:61
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:53
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:38
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
T
enum T contains all this lexer's tokens.
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Returns a property for a specific type.
Provides class metadata.
Definition: property_mgr.h:58
void set(void *aObject, T aValue)
Definition: property.h:264
virtual size_t OwnerHash() const =0
Returns type-id of the Owner class.

References PROPERTY_MANAGER::GetProperty(), PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), PROPERTY_BASE::set(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

◆ SetBrightened()

void EDA_ITEM::SetBrightened ( )
inlineinherited

◆ SetFlags()

void EDA_ITEM::SetFlags ( STATUS_FLAGS  aMask)
inlineinherited

Definition at line 232 of file base_struct.h.

232 { m_Flags |= aMask; }
STATUS_FLAGS m_Flags
Definition: base_struct.h:176

References EDA_ITEM::m_Flags.

Referenced by SCH_EAGLE_PLUGIN::addBusEntries(), PCB_BASE_FRAME::AddModuleToBoard(), PCBNEW_CONTROL::AppendBoard(), SCH_EDIT_TOOL::ChangeTextType(), GRAPHICS_CLEANER::cleanupSegments(), TRACKS_CLEANER::cleanupSegments(), SCH_EDIT_FRAME::ConvertPart(), SCH_DRAWING_TOOLS::createNewText(), LIB_PIN_TOOL::CreatePin(), SCH_EDIT_FRAME::CreateSheetPin(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), KIGFX::SCH_PAINTER::draw(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), DRAWING_TOOL::DrawRectangle(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SCH_EDIT_TOOL::Duplicate(), LIB_EDIT_FRAME::GetComponentFromRedoList(), LIB_EDIT_FRAME::GetComponentFromUndoList(), SCH_MOVE_TOOL::getConnectedDragItems(), EDIT_POINTS_FACTORY::Make(), TRACKS_CLEANER::mergeCollinearSegments(), LIB_MOVE_TOOL::moveItem(), SCH_MOVE_TOOL::moveItem(), KIGFX::ORIGIN_VIEWITEM::ORIGIN_VIEWITEM(), LIB_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), DRAWING_TOOL::PlaceText(), BACK_ANNOTATE::processNetNameChange(), SCH_EDIT_FRAME::PutDataInPreviousState(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_PIN_TOOL::RepeatPin(), LIB_EDIT_FRAME::SaveCopyInUndoList(), EE_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectPoint(), SCH_EDIT_FRAME::SelectUnit(), EDA_ITEM::SetBrightened(), LIB_PIN::SetConversion(), EDA_ITEM::SetModified(), EDA_ITEM::SetSelected(), EDA_ITEM::SetWireImage(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_LINE_WIRE_BUS_TOOL::startSegments(), WS_DATA_ITEM::SyncDrawItems(), WS_DATA_ITEM_TEXT::SyncDrawItems(), DIALOG_TARGET_PROPERTIES::TransferDataFromWindow(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), LIB_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ SetForceVisible()

void EDA_ITEM::SetForceVisible ( bool  aEnable)
inlineinherited

Function SetForceVisible is used to set and cleag force visible flag used to force the item to be drawn even if it's draw attribute is set to not visible.

Parameters
aEnableTrue forces the item to be drawn. False uses the item's visibility setting to determine if the item is to be drawn.

Definition at line 284 of file base_struct.h.

284 { m_forceVisible = aEnable; }
bool m_forceVisible
Definition: base_struct.h:175

References EDA_ITEM::m_forceVisible.

◆ SetModified()

◆ SetParent()

virtual void EDA_ITEM::SetParent ( EDA_ITEM aParent)
inlinevirtualinherited

Definition at line 196 of file base_struct.h.

196 { m_Parent = aParent; }
EDA_ITEM * m_Parent
Linked list: Link (parent struct)
Definition: base_struct.h:174

References EDA_ITEM::m_Parent.

Referenced by MODULE::Add(), BOARD::Add(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), BOARD_NETLIST_UPDATER::addNewComponent(), SCH_SHEET::AddPin(), LIB_CONTROL::AddSymbolToSchematic(), SCH_SCREEN::Append(), LIB_FIELD::Copy(), LIB_EDIT_FRAME::CreateNewPart(), SCH_DRAWING_TOOLS::createNewText(), DIALOG_LIB_EDIT_PIN::DIALOG_LIB_EDIT_PIN(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), SCH_EDIT_TOOL::Duplicate(), PCB_EDIT_FRAME::Exchange_Module(), LIB_PART::Flatten(), PCB_IO::FootprintSave(), DISPLAY_FOOTPRINTS_FRAME::GetModule(), LIB_PART::LIB_PART(), FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD(), SCH_LEGACY_PLUGIN_CACHE::loadAliases(), SCH_SEXPR_PLUGIN::loadHierarchy(), SCH_LEGACY_PLUGIN::loadHierarchy(), LIB_EDIT_FRAME::LoadOneSymbol(), MODULE::MODULE(), DIALOG_LIB_EDIT_PIN::OnPaintShowPanel(), MODULE::operator=(), LIB_PART::operator=(), PCB_PARSER::parseMODULE_unchecked(), SCH_SEXPR_PARSER::ParseSchematic(), SCH_SEXPR_PARSER::ParseSymbol(), LIB_EDIT_TOOL::Paste(), PCBNEW_CONTROL::Paste(), SCH_EDITOR_CONTROL::Paste(), pasteModuleItemsToModEdit(), SCH_DRAWING_TOOLS::PlaceComponent(), PCB_EDITOR_CONTROL::PlaceModule(), BACK_ANNOTATE::processNetNameChange(), BOARD_COMMIT::Push(), SCH_SEXPR_PLUGIN_CACHE::removeSymbol(), SCH_LEGACY_PLUGIN_CACHE::removeSymbol(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), SaveCopyOfZones(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), SCH_SHEET_PIN::SCH_SHEET_PIN(), LIB_PART::SetFields(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_SHEET::SwapData(), SCH_COMPONENT::SwapData(), SwapItemData(), and DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::UpdateFieldsFromLibrary().

◆ SetSelected()

◆ SetState()

void EDA_ITEM::SetState ( int  type,
int  state 
)
inlineinherited

Definition at line 221 of file base_struct.h.

222  {
223  if( state )
224  m_Status |= type; // state = ON or OFF
225  else
226  m_Status &= ~type;
227  }
STATUS_FLAGS m_Status
Definition: base_struct.h:173

References EDA_ITEM::m_Status.

Referenced by LEGACY_PLUGIN::loadTrackList(), TRACKS_CLEANER::mergeCollinearSegments(), SELECTION_TOOL::selectConnectedTracks(), and TRACK::SetLocked().

◆ SetStatus()

void EDA_ITEM::SetStatus ( STATUS_FLAGS  aStatus)
inlineinherited

Definition at line 230 of file base_struct.h.

230 { m_Status = aStatus; }
STATUS_FLAGS m_Status
Definition: base_struct.h:173

References EDA_ITEM::m_Status.

Referenced by BOARD_NETLIST_UPDATER::UpdateNetlist().

◆ SetWireImage()

void EDA_ITEM::SetWireImage ( )
inlineinherited

Definition at line 207 of file base_struct.h.

207 { SetFlags( IS_WIRE_IMAGE ); }
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:232
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.
Definition: base_struct.h:121

References IS_WIRE_IMAGE, and EDA_ITEM::SetFlags().

◆ Sort()

static bool EDA_ITEM::Sort ( const EDA_ITEM aLeft,
const EDA_ITEM aRight 
)
inlinestaticinherited

Function Sort is a helper function to be used by the C++ STL sort algorithm for sorting a STL container of EDA_ITEM pointers.

Parameters
aLeftThe left hand item to compare.
aRightThe right hand item to compare.
Returns
True if aLeft is less than aRight.

Definition at line 520 of file base_struct.h.

520 { return *aLeft < *aRight; }

◆ StepAndRepeatItem()

void GERBER_FILE_IMAGE::StepAndRepeatItem ( const GERBER_DRAW_ITEM aItem)

Function StepAndRepeatItem Gerber format has a command Step an Repeat This function must be called when reading a gerber file and after creating a new gerber item that must be repeated (i.e when m_XRepeatCount or m_YRepeatCount are > 1)

Parameters
aItem= the item to repeat

Definition at line 297 of file gerber_file_image.cpp.

298 {
299  if( GetLayerParams().m_XRepeatCount < 2 &&
300  GetLayerParams().m_YRepeatCount < 2 )
301  return; // Nothing to repeat
302 
303  // Duplicate item:
304  for( int ii = 0; ii < GetLayerParams().m_XRepeatCount; ii++ )
305  {
306  for( int jj = 0; jj < GetLayerParams().m_YRepeatCount; jj++ )
307  {
308  // the first gerber item already exists (this is the template)
309  // create duplicate only if ii or jj > 0
310  if( jj == 0 && ii == 0 )
311  continue;
312 
313  GERBER_DRAW_ITEM* dupItem = new GERBER_DRAW_ITEM( aItem );
314  wxPoint move_vector;
315  move_vector.x = scaletoIU( ii * GetLayerParams().m_StepForRepeat.x,
316  GetLayerParams().m_StepForRepeatMetric );
317  move_vector.y = scaletoIU( jj * GetLayerParams().m_StepForRepeat.y,
318  GetLayerParams().m_StepForRepeatMetric );
319  dupItem->MoveXY( move_vector );
320  AddItemToList( dupItem );
321  }
322  }
323 }
int scaletoIU(double aCoord, bool isMetric)
Function scaletoIU converts a distance given in floating point to our internal units.
void AddItemToList(GERBER_DRAW_ITEM *aItem)
Add a new GERBER_DRAW_ITEM item to the drawings list.
void MoveXY(const wxPoint &aMoveVector)
Function MoveXY move this object.
GERBER_LAYER & GetLayerParams()
Function GetLayerParams.

References AddItemToList(), GetLayerParams(), GERBER_LAYER::m_XRepeatCount, GERBER_LAYER::m_YRepeatCount, GERBER_DRAW_ITEM::MoveXY(), scaletoIU(), wxPoint::x, and wxPoint::y.

Referenced by Execute_DCODE_Command(), EXCELLON_IMAGE::Execute_Drill_Command(), Execute_G_Command(), and EXCELLON_IMAGE::FinishRouteCommand().

◆ Type()

KICAD_T EDA_ITEM::Type ( ) const
inlineinherited

Function Type()

returns the type of object. This attribute should never be changed after a constructor sets it, so there is no public "setter" method.

Returns
KICAD_T - the type of object.

Definition at line 193 of file base_struct.h.

193 { return m_StructType; }
KICAD_T m_StructType
Run time identification, keep private so it can never be changed after a constructor sets it.
Definition: base_struct.h:170

References EDA_ITEM::m_StructType.

Referenced by MODULE::Add(), CN_CONNECTIVITY_ALGO::Add(), BOARD::Add(), CN_CLUSTER::Add(), POINT_EDITOR::addCorner(), CONNECTION_SUBGRAPH::AddItem(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), SCH_LINE_WIRE_BUS_TOOL::AddJunctionsIfNeeded(), ZONE_FILLER::addKnockout(), SCH_SHEET::AddPin(), ALIGN_DISTRIBUTE_TOOL::AlignBottom(), ALIGN_DISTRIBUTE_TOOL::AlignCenterX(), ALIGN_DISTRIBUTE_TOOL::AlignCenterY(), ALIGN_DISTRIBUTE_TOOL::AlignTop(), CN_ITEM::AnchorCount(), SCH_SCREEN::Append(), CONNECTION_GRAPH::buildConnectionGraph(), DIALOG_SELECT_NET_FROM_LIST::buildNetsList(), SCH_SCREENS::buildScreenList(), calcArea(), calcMaxArea(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), POINT_EDITOR::canAddCorner(), SCH_JUNCTION::CanConnect(), SCH_NO_CONNECT::CanConnect(), SCH_BUS_WIRE_ENTRY::CanConnect(), SCH_BUS_BUS_ENTRY::CanConnect(), SCH_LINE::CanConnect(), SCH_LABEL::CanConnect(), SCH_GLOBALLABEL::CanConnect(), SCH_HIERLABEL::CanConnect(), SCH_SHEET::CanConnect(), SCH_COMPONENT::CanConnect(), ROUTER_TOOL::CanInlineDrag(), SCH_EDIT_TOOL::ChangeTextType(), SCH_MARKER::ClassOf(), SCH_JUNCTION::ClassOf(), TEXTE_PCB::ClassOf(), SCH_NO_CONNECT::ClassOf(), BOARD_CONNECTED_ITEM::ClassOf(), MARKER_PCB::ClassOf(), SCH_PIN::ClassOf(), EDGE_MODULE::ClassOf(), SCH_LINE::ClassOf(), PCB_TARGET::ClassOf(), SCH_FIELD::ClassOf(), TEXTE_MODULE::ClassOf(), DRAWSEGMENT::ClassOf(), ZONE_CONTAINER::ClassOf(), SCH_BITMAP::ClassOf(), D_PAD::ClassOf(), DIMENSION::ClassOf(), TRACK::ClassOf(), NETINFO_ITEM::ClassOf(), SCH_SHEET_PIN::ClassOf(), MODULE::ClassOf(), SCH_BUS_WIRE_ENTRY::ClassOf(), SCH_SCREEN::ClassOf(), SCH_COMPONENT::ClassOf(), SCH_BUS_BUS_ENTRY::ClassOf(), SCH_TEXT::ClassOf(), SCH_SHEET::ClassOf(), BOARD::ClassOf(), ARC::ClassOf(), SCH_LABEL::ClassOf(), VIA::ClassOf(), SCH_GLOBALLABEL::ClassOf(), SCH_HIERLABEL::ClassOf(), TRACKS_CLEANER::cleanupSegments(), LIB_BEZIER::compare(), LIB_CIRCLE::compare(), LIB_RECTANGLE::compare(), LIB_TEXT::compare(), LIB_POLYLINE::compare(), LIB_ARC::compare(), LIB_FIELD::compare(), LIB_ITEM::compare(), LIB_PIN::compare(), GRID_HELPER::computeAnchors(), SCH_BUS_WIRE_ENTRY::ConnectionPropagatesTo(), EE_RTREE::contains(), DIALOG_TEXT_PROPERTIES::convertKIIDsToReferences(), DIALOG_LABEL_EDITOR::convertKIIDsToReferences(), MODULE::CoverageRatio(), BOARD_ADAPTER::createLayers(), PCB_BASE_FRAME::CreateNewModule(), SCH_DRAWING_TOOLS::createNewText(), BOARD_ADAPTER::createNewTrack(), D_PAD::D_PAD(), SCH_SCREEN::DeleteItem(), DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR(), DIALOG_SCH_EDIT_ONE_FIELD::DIALOG_SCH_EDIT_ONE_FIELD(), DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES(), ALIGN_DISTRIBUTE_TOOL::doAlignLeft(), ALIGN_DISTRIBUTE_TOOL::doAlignRight(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDIT_TOOL::DoDelete(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersVertically(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsVertically(), test::DRC_TEST_PROVIDER_COPPER_CLEARANCE::doTrackDrc(), DRC::doTrackDrc(), KIGFX::SCH_PAINTER::draw(), KIGFX::GERBVIEW_PAINTER::Draw(), KIGFX::PCB_PAINTER::Draw(), CN_ITEM::Dump(), EDIT_TOOL::Duplicate(), SCH_ITEM::Duplicate(), MODULE::DuplicateItem(), EDA_ITEM_DESC::EDA_ITEM_DESC(), SCH_EDIT_TOOL::EditField(), SCH_EDIT_TOOL::editFieldText(), LIB_EDIT_TOOL::editTextProperties(), EditToolSelectionFilter(), CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts(), CONNECTION_GRAPH::ercCheckLabels(), NETLIST_EXPORTER::findNextComponent(), PCB_BASE_FRAME::FocusOnItem(), EDIT_TOOL::FootprintFilter(), SCH_SEXPR_PLUGIN::Format(), SCH_LEGACY_PLUGIN::Format(), PCB_IO::Format(), PCB_IO::format(), FormatProbeItem(), POINT_EDITOR::get45DegConstrainer(), CN_ITEM::GetAnchor(), BOARD_ITEM::GetBoard(), SCH_FIELD::GetBoundingBox(), TRACK::GetBoundingBox(), SCH_FIELD::GetCanonicalName(), KIGFX::GERBVIEW_RENDER_SETTINGS::GetColor(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), NETLIST_OBJECT::GetComponentParent(), SCH_MOVE_TOOL::getConnectedDragItems(), SCH_TEXT::GetConnectionPoints(), SCH_TEXT::GetContextualTextVars(), CONNECTION_GRAPH::getDefaultConnection(), CONNECTION_SUBGRAPH::GetDriverPriority(), SCH_TEXT::GetEndPoints(), PL_EDITOR_FRAME::GetLayoutFromRedoList(), PL_EDITOR_FRAME::GetLayoutFromUndoList(), SCH_FIELD::GetMenuImage(), TEXTE_PCB::GetMsgPanelInfo(), SCH_TEXT::GetMsgPanelInfo(), SCH_FIELD::GetName(), CONNECTION_SUBGRAPH::GetNameForDriver(), CONNECTIVITY_DATA::GetNetItems(), LIB_PART::GetNextDrawItem(), DRAWSEGMENT::GetParentModule(), LIB_PART::GetPin(), SCH_COMPONENT::GetPinPhysicalPosition(), SCH_FIELD::GetPosition(), getRect(), KIGFX::SCH_PAINTER::getRenderColor(), TEXTE_PCB::GetShownText(), SCH_FIELD::GetShownText(), SCH_TEXT::GetShownText(), SELECTION_TOOL::GuessSelectionCandidates(), EE_SELECTION_TOOL::GuessSelectionCandidates(), hash_eda(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlight(), highlightNet(), SCH_EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), EE_RTREE::insert(), EE_COLLECTOR::Inspect(), GENERAL_COLLECTOR::Inspect(), PCB_LAYER_COLLECTOR::Inspect(), ARRAY_CREATOR::Invoke(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingLineWireOrBus(), TRACK::IsNull(), SCH_LINE::IsParallel(), SCH_FIELD::IsReplaceable(), SCH_SCREEN::IsTerminalPoint(), BOARD_ITEM::IsTrack(), itemIsIncludedByFilter(), SELECTION_TOOL::itemPassesFilter(), CLIPBOARD_IO::Load(), PNS_PCBNEW_RULE_RESOLVER::localPadClearance(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), EE_SELECTION_TOOL::Main(), EDIT_POINTS_FACTORY::Make(), SCH_SCREEN::MarkConnections(), CN_CONNECTIVITY_ALGO::markItemNetAsDirty(), CONNECTIVITY_DATA::MarkItemNetAsDirty(), SCH_FIELD::Matches(), SCH_LINE::MergeOverlap(), SCH_EDIT_TOOL::Mirror(), SCH_MOVE_TOOL::moveItem(), SCH_EDITOR_CONTROL::nextMatch(), FOOTPRINT_EDIT_FRAME::OnEditItemRequest(), PCB_EDIT_FRAME::OnEditItemRequest(), SCH_JUNCTION::operator<(), SCH_BUS_ENTRY_BASE::operator<(), SCH_FIELD::operator<(), SCH_LINE::operator<(), LIB_ITEM::operator<(), SCH_TEXT::operator<(), SCH_ITEM::operator<(), SCH_SHEET::operator<(), SCH_COMPONENT::operator<(), SCH_BITMAP::operator=(), SCH_SHEET::operator=(), SCH_COMPONENT::operator=(), EDIT_TOOL::PadFilter(), BOARD_COMMIT::parentObject(), PCBNEW_CONTROL::Paste(), SCH_EDITOR_CONTROL::Paste(), DRAWING_TOOL::PlaceImportedGraphics(), SCH_FIELD::Plot(), SCH_SCREEN::Plot(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), SCH_FIELD::Print(), SCH_SCREEN::Print(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::processItem(), BACK_ANNOTATE::processNetNameChange(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), BOARD_COMMIT::Push(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), SELECTION_TOOL::RebuildSelection(), SCH_CONNECTION::recacheName(), SCH_BASE_FRAME::RefreshItem(), SCH_BASE_FRAME::RefreshSelection(), EE_RTREE::remove(), MODULE::Remove(), CN_CONNECTIVITY_ALGO::Remove(), SCH_SCREEN::Remove(), BOARD::Remove(), POINT_EDITOR::removeCorner(), POINT_EDITOR::removeCornerCondition(), LIB_PART::RemoveDrawItem(), SCH_SHEET::RemovePin(), SCH_EDIT_TOOL::RepeatDrawItem(), SCH_FIELD::Replace(), WS_PROXY_UNDO_ITEM::Restore(), PL_EDITOR_FRAME::RollbackFromUndo(), SCH_EDIT_TOOL::Rotate(), SCH_TEXT::Rotate(), DRC_TEXTVAR_TESTER::RunDRC(), SCH_SEXPR_PLUGIN_CACHE::saveArc(), SCH_LEGACY_PLUGIN_CACHE::saveArc(), SCH_SEXPR_PLUGIN_CACHE::saveBezier(), SCH_LEGACY_PLUGIN_CACHE::saveBezier(), SCH_SEXPR_PLUGIN_CACHE::saveCircle(), SCH_LEGACY_PLUGIN_CACHE::saveCircle(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), EE_TOOL_BASE< SCH_BASE_FRAME >::saveCopyInUndoList(), SCH_SEXPR_PLUGIN::saveField(), SCH_SEXPR_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_SEXPR_PLUGIN_CACHE::savePin(), SCH_LEGACY_PLUGIN_CACHE::savePin(), SCH_SEXPR_PLUGIN_CACHE::savePolyLine(), SCH_LEGACY_PLUGIN_CACHE::savePolyLine(), SCH_SEXPR_PLUGIN_CACHE::saveRectangle(), SCH_LEGACY_PLUGIN_CACHE::saveRectangle(), SCH_SEXPR_PLUGIN_CACHE::saveSymbolDrawItem(), SCH_SEXPR_PLUGIN::saveText(), SCH_SEXPR_PLUGIN_CACHE::saveText(), SCH_LEGACY_PLUGIN_CACHE::saveText(), SCH_SCREEN::Schematic(), SCH_ITEM::Schematic(), SELECTION_TOOL::select(), SELECTION_TOOL::Selectable(), EE_SELECTION_TOOL::Selectable(), SELECTION_TOOL::selectConnectedTracks(), SCH_FIELD::SetId(), ITEM_PICKER::SetItem(), SCH_FIELD::SetPosition(), DIALOG_LABEL_EDITOR::SetTitle(), PCB_EDIT_FRAME::SetTrackSegmentWidth(), BOARD_COMMIT::Stage(), SCH_JUNCTION::SwapData(), SCH_NO_CONNECT::SwapData(), SCH_BITMAP::SwapData(), PCB_TARGET::SwapData(), SCH_SHEET_PIN::SwapData(), SCH_FIELD::SwapData(), TEXTE_PCB::SwapData(), TRACK::SwapData(), DIMENSION::SwapData(), ARC::SwapData(), SCH_SHEET::SwapData(), VIA::SwapData(), SCH_COMPONENT::SwapData(), D_PAD::SwapData(), MODULE::SwapData(), ZONE_CONTAINER::SwapData(), SwapItemData(), TEXTE_MODULE::TEXTE_MODULE(), DIALOG_LABEL_EDITOR::TransferDataFromWindow(), DIALOG_FIELDS_EDITOR_GLOBAL::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_LABEL_EDITOR::TransferDataToWindow(), TRACK::TransformShapeWithClearanceToPolygon(), LIB_DRAWING_TOOLS::TwoClickPlace(), EE_SELECTION_TOOL::unhighlight(), SELECTION_TOOL::unhighlight(), SCH_TEXT::UpdateDanglingState(), DIALOG_SCH_EDIT_ONE_FIELD::UpdateField(), EE_POINT_EDITOR::updateItem(), PL_POINT_EDITOR::updateItem(), POINT_EDITOR::updateItem(), CONNECTION_GRAPH::updateItemConnectivity(), DIALOG_SELECT_NET_FROM_LIST::updateNet(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), POINT_EDITOR::updatePoints(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateView(), PCB_BRIGHT_BOX::ViewDraw(), SCH_BUS_ENTRY_BASE::ViewGetLayers(), TRACK::Visit(), GERBER_DRAW_ITEM::Visit(), SCH_SHEET::Visit(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ ViewBBox()

const BOX2I EDA_ITEM::ViewBBox ( ) const
overridevirtualinherited

Function ViewBBox() returns the bounding box of the item covering all its layers.

Returns
BOX2I - the current bounding box

Implements KIGFX::VIEW_ITEM.

Reimplemented in MODULE, D_PAD, EDIT_POINTS, DRAWSEGMENT, GERBER_DRAW_ITEM, DIMENSION, TRACK, TEXTE_MODULE, ROUTER_PREVIEW_ITEM, MARKER_PCB, MARKER_PCB, KIGFX::WS_PROXY_VIEW_ITEM, MY_DRAWING, KIGFX::ORIGIN_VIEWITEM, KIGFX::PREVIEW::CENTRELINE_RECT_ITEM, KIGFX::PREVIEW::POLYGON_ITEM, KIGFX::PREVIEW::TWO_POINT_ASSISTANT, KIGFX::PREVIEW::SELECTION_AREA, KIGFX::PREVIEW::RULER_ITEM, KIGFX::RATSNEST_VIEWITEM, KIGFX::PREVIEW::ARC_ASSISTANT, and BRIGHT_BOX.

Definition at line 220 of file base_struct.cpp.

221 {
222  // Basic fallback
223  return BOX2I( VECTOR2I( GetBoundingBox().GetOrigin() ),
224  VECTOR2I( GetBoundingBox().GetSize() ) );
225 }
BOX2< VECTOR2I > BOX2I
Definition: box2.h:521
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
virtual const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: base_struct.cpp:97

References EDA_ITEM::GetBoundingBox().

Referenced by GERBVIEW_FRAME::GetDocumentExtents(), BRIGHT_BOX::ViewBBox(), DIMENSION::ViewBBox(), DRAWSEGMENT::ViewBBox(), and BRIGHT_BOX::ViewDraw().

◆ ViewDraw()

virtual void KIGFX::VIEW_ITEM::ViewDraw ( int  aLayer,
VIEW aView 
) const
inlinevirtualinherited

Function ViewDraw() Draws the parts of the object belonging to layer aLayer.

viewDraw() is an alternative way for drawing objects if if there is no PAINTER assigned for the view or if the PAINTER doesn't know how to paint this particular implementation of VIEW_ITEM. The preferred way of drawing is to design an appropriate PAINTER object, the method below is intended only for quick hacks and debugging purposes.

Parameters
aLayercurrent drawing layer
aViewpointer to the VIEW device we are drawing on

Reimplemented in EDIT_POINTS, ROUTER_PREVIEW_ITEM, KIGFX::VIEW_GROUP, KIGFX::WS_PROXY_VIEW_ITEM, KIGFX::PREVIEW::SELECTION_AREA, MY_DRAWING, KIGFX::PREVIEW::SIMPLE_OVERLAY_ITEM, KIGFX::VIEW_OVERLAY, KIGFX::ORIGIN_VIEWITEM, KIGFX::PREVIEW::TWO_POINT_ASSISTANT, BRIGHT_BOX, KIGFX::PREVIEW::RULER_ITEM, KIGFX::RATSNEST_VIEWITEM, KIGFX::PREVIEW::ARC_ASSISTANT, and PCB_BRIGHT_BOX.

Definition at line 117 of file view_item.h.

118  {}

Referenced by KIGFX::VIEW::draw(), and KIGFX::VIEW::updateItemGeometry().

◆ ViewGetLayers()

void EDA_ITEM::ViewGetLayers ( int  aLayers[],
int &  aCount 
) const
overridevirtualinherited

Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on.

For instance, a D_PAD spans zero or more copper layers and a few technical layers. ViewDraw() or PAINTER::Draw() is repeatedly called for each of the layers returned by ViewGetLayers(), depending on the rendering order.

Parameters
aLayers[]output layer index array
aCountnumber of layer indices in aLayers[]

Implements KIGFX::VIEW_ITEM.

Reimplemented in MODULE, D_PAD, SCH_SHEET, EDIT_POINTS, VIA, BOARD_ITEM, GERBER_DRAW_ITEM, SCH_ITEM, TEXTE_MODULE, TRACK, LIB_PART, LIB_ITEM, SCH_COMPONENT, MY_DRAWING, LIB_FIELD, ZONE_CONTAINER, SCH_LINE, ROUTER_PREVIEW_ITEM, SCH_BITMAP, MARKER_PCB, MARKER_PCB, KIGFX::WS_PROXY_VIEW_ITEM, SCH_BUS_ENTRY_BASE, WS_DRAW_ITEM_BASE, SCH_NO_CONNECT, KIGFX::ORIGIN_VIEWITEM, KIGFX::PREVIEW::SIMPLE_OVERLAY_ITEM, LIB_TEXT, SCH_JUNCTION, BRIGHT_BOX, SCH_MARKER, KIGFX::RATSNEST_VIEWITEM, and KIGFX::PREVIEW::RULER_ITEM.

Definition at line 228 of file base_struct.cpp.

229 {
230  // Basic fallback
231  aCount = 1;
232  aLayers[0] = 0;
233 }

◆ ViewGetLOD()

virtual unsigned int KIGFX::VIEW_ITEM::ViewGetLOD ( int  aLayer,
VIEW aView 
) const
inlinevirtualinherited

Function ViewGetLOD() Returns the level of detail (LOD) of the item.

A level of detail is the minimal VIEW scale that is sufficient for an item to be shown on a given layer.

Parameters
aLayercurrent drawing layer
aViewpointer to the VIEW device we are drawing on
Returns
the level of detail. 0 always show the item, because the actual zoom level (or VIEW scale) is always > 0

Reimplemented in MODULE_ZONE_CONTAINER, MODULE, D_PAD, VIA, GERBER_DRAW_ITEM, TEXTE_MODULE, TRACK, and EDGE_MODULE.

Definition at line 141 of file view_item.h.

142  {
143  // By default always show the item
144  return 0;
145  }

Referenced by KIGFX::VIEW::drawItem::operator()(), GRID_HELPER::queryVisible(), and SELECTION_TOOL::Selectable().

◆ viewPrivData()

◆ Visit()

SEARCH_RESULT GERBER_FILE_IMAGE::Visit ( INSPECTOR  inspector,
void *  testData,
const KICAD_T  scanTypes[] 
)
overridevirtual

Reimplemented from EDA_ITEM.

Definition at line 391 of file gerber_file_image.cpp.

392 {
393  KICAD_T stype;
395  const KICAD_T* p = scanTypes;
396  bool done = false;
397 
398  while( !done )
399  {
400  stype = *p;
401 
402  switch( stype )
403  {
404  case GERBER_IMAGE_T:
405  case GERBER_LAYOUT_T:
406  ++p;
407  break;
408 
409  case GERBER_DRAW_ITEM_T:
410  result = IterateForward( GetItems(), inspector, testData, p );
411  ++p;
412  break;
413 
414  case EOT:
415  default: // catch EOT or ANY OTHER type here and return.
416  done = true;
417  break;
418  }
419 
420  if( result == SEARCH_RESULT::QUIT )
421  break;
422  }
423 
424  return result;
425 }
GERBER_DRAW_ITEMS & GetItems()
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
static SEARCH_RESULT IterateForward(std::deque< T > &aList, INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
IterateForward( EDA_ITEM*, INSPECTOR, void*, const KICAD_T )
Definition: base_struct.h:383
SEARCH_RESULT
Definition: base_struct.h:51

References CONTINUE, EOT, GERBER_DRAW_ITEM_T, GERBER_IMAGE_T, GERBER_LAYOUT_T, GetItems(), EDA_ITEM::IterateForward(), and QUIT.

Referenced by GBR_LAYOUT::Visit().

Member Data Documentation

◆ m_360Arc_enbl

bool GERBER_FILE_IMAGE::m_360Arc_enbl

◆ m_AperFunction

wxString GERBER_FILE_IMAGE::m_AperFunction

◆ m_Aperture_List

D_CODE* GERBER_FILE_IMAGE::m_Aperture_List[TOOLS_MAX_COUNT]
private

Dcode (Aperture) List for this layer (max TOOLS_MAX_COUNT: see dcode.h)

Definition at line 111 of file gerber_file_image.h.

Referenced by GERBER_FILE_IMAGE(), GetDCODE(), GetDCODEOrCreate(), GetDcodesCount(), InitToolTable(), and ~GERBER_FILE_IMAGE().

◆ m_aperture_macros

APERTURE_MACRO_SET GERBER_FILE_IMAGE::m_aperture_macros

a collection of APERTURE_MACROS, sorted by name

Definition at line 175 of file gerber_file_image.h.

Referenced by FindApertureMacro(), InitToolTable(), and ReadApertureMacro().

◆ m_ArcRadius

int GERBER_FILE_IMAGE::m_ArcRadius

◆ m_AsArcG74G75Cmd

bool GERBER_FILE_IMAGE::m_AsArcG74G75Cmd

◆ m_CommandState

int GERBER_FILE_IMAGE::m_CommandState

Definition at line 154 of file gerber_file_image.h.

Referenced by LoadGerberFile(), ReadRS274XCommand(), and ResetDefaultValues().

◆ m_ComponentsList

std::map<wxString, int> GERBER_FILE_IMAGE::m_ComponentsList

◆ m_Current_File

FILE* GERBER_FILE_IMAGE::m_Current_File

◆ m_Current_Tool

◆ m_CurrentPos

◆ m_drawings

GERBER_DRAW_ITEMS GERBER_FILE_IMAGE::m_drawings
private