KiCad PCB EDA Suite
EXCELLON_IMAGE Class Reference

Handle a drill image. More...

#include <excellon_image.h>

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

Public Member Functions

 EXCELLON_IMAGE (int layer)
 
 ~EXCELLON_IMAGE ()
 
virtual void ResetDefaultValues () override
 Set all parameters to a default value, before reading a file. More...
 
bool LoadFile (const wxString &aFullFileName, EXCELLON_DEFAULTS *aDefaults)
 Read and load a drill (EXCELLON format) file. More...
 
wxString GetClass () const override
 Return the class name. More...
 
bool LoadGerberFile (const wxString &aFullFileName)
 Read and load a gerber file. More...
 
const wxArrayString & GetMessages () const
 
int GetDcodesCount ()
 
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 ()
 
bool HasNegativeItems ()
 
void ClearMessageList ()
 Clear the message list. More...
 
void AddMessageToList (const wxString &aMessage)
 Add a message to the message list. More...
 
VECTOR2I ReadXYCoord (char *&aText, bool aExcellonMode=false)
 Return the current coordinate type pointed to by XnnYnn Text (XnnnnYmmmm). More...
 
VECTOR2I ReadIJCoord (char *&Text)
 Return the current coordinate type pointed to by InnJnn Text (InnnnJmmmm) More...
 
int CodeNumber (char *&aText)
 Reads the next number and returns the value. More...
 
D_CODEGetDCODEOrCreate (int aDCODE, bool aCreateIfNoExist=true)
 Return a pointer to the D_CODE within this GERBER for the given aDCODE. More...
 
D_CODEGetDCODE (int aDCODE) const
 Return a pointer to the D_CODE within this GERBER for the given aDCODE. More...
 
APERTURE_MACROFindApertureMacro (const APERTURE_MACRO &aLookup)
 Look up a previously read in aperture macro. More...
 
void StepAndRepeatItem (const GERBER_DRAW_ITEM &aItem)
 Gerber format has a command Step an Repeat. More...
 
void DisplayImageInfo (GERBVIEW_FRAME *aMainFrame)
 Display information about image parameters in the status bar. More...
 
void RemoveAttribute (X2_ATTRIBUTE &aAttribute)
 Called when a TD command is found the Gerber file. More...
 
INSPECT_RESULT Visit (INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes) override
 May be re-implemented for each derived class in order to handle all the types given by its member data. More...
 
KICAD_T Type () const
 Returns the type of object. More...
 
EDA_ITEMGetParent () const
 
virtual void SetParent (EDA_ITEM *aParent)
 
bool IsModified () const
 
bool IsNew () const
 
bool IsMoving () const
 
bool IsSelected () const
 
bool IsEntered () const
 
bool IsBrightened () const
 
bool IsRollover () const
 
void SetSelected ()
 
void SetBrightened ()
 
void ClearSelected ()
 
void ClearBrightened ()
 
void SetModified ()
 
int GetState (EDA_ITEM_FLAGS type) const
 
void SetState (EDA_ITEM_FLAGS type, bool state)
 
EDA_ITEM_FLAGS GetStatus () const
 
void SetStatus (EDA_ITEM_FLAGS aStatus)
 
void SetFlags (EDA_ITEM_FLAGS aMask)
 
void XorFlags (EDA_ITEM_FLAGS aMask)
 
void ClearFlags (EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
 
EDA_ITEM_FLAGS GetFlags () const
 
bool HasFlag (EDA_ITEM_FLAGS aFlag) const
 
EDA_ITEM_FLAGS GetEditFlags () const
 
void ClearTempFlags ()
 
void ClearEditFlags ()
 
virtual bool RenderAsBitmap (double aWorldScale) const
 
void SetIsShownAsBitmap (bool aBitmap)
 
bool IsShownAsBitmap () const
 
virtual bool IsType (const std::vector< KICAD_T > &aScanTypes) const
 Check whether the item is one of the listed types. More...
 
void SetForceVisible (bool aEnable)
 Set and clear 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)
 Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes. More...
 
virtual wxString GetFriendlyName () const
 
virtual bool HitTest (const VECTOR2I &aPosition, int aAccuracy=0) const
 Test if aPosition is inside or on the boundary of this item. More...
 
virtual bool HitTest (const BOX2I &aRect, bool aContained, int aAccuracy=0) const
 Test if aRect intersects this item. More...
 
virtual const BOX2I GetBoundingBox () const
 Return the orthogonal bounding box of this object for display purposes. More...
 
virtual VECTOR2I GetPosition () const
 
virtual void SetPosition (const VECTOR2I &aPos)
 
virtual const VECTOR2I GetFocusPosition () const
 Similar to GetPosition, but allows items to return their visual center rather than their anchor. More...
 
virtual VECTOR2I GetSortPosition () const
 Return the coordinates that should be used for sorting this element visually compared to other elements. More...
 
virtual EDA_ITEMClone () const
 Create a duplicate of this item with linked list members set to NULL. More...
 
wxString GetTypeDesc () const
 Return a translated description of the type for this EDA_ITEM for display in user facing messages. More...
 
virtual wxString GetItemDescription (UNITS_PROVIDER *aUnitsProvider) const
 Return a user-visible description string of this item. More...
 
virtual BITMAPS GetMenuImage () const
 Return a pointer to an image to be used in menus. More...
 
virtual bool Matches (const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
 Compare the item against the search criteria in aSearchData. More...
 
virtual bool Replace (const EDA_SEARCH_DATA &aSearchData, void *aAuxData=nullptr)
 Perform a text replace using the find and replace criteria in aSearchData on items that support text find and replace. More...
 
virtual bool IsReplaceable () const
 Override this method in any derived object that supports test find and replace. More...
 
bool operator< (const EDA_ITEM &aItem) const
 Test if another item is less than this object. More...
 
virtual const BOX2I ViewBBox () const override
 Return the bounding box of the item covering all its layers. More...
 
virtual void ViewGetLayers (int aLayers[], int &aCount) const override
 Return the all the layers within the VIEW the object is painted on. More...
 
virtual void ViewDraw (int aLayer, VIEW *aView) const
 Draw the parts of the object belonging to layer aLayer. More...
 
virtual double ViewGetLOD (int aLayer, VIEW *aView) const
 Return 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) const
 
template<typename T >
Get (PROPERTY_BASE *aProperty) const
 
template<typename T >
std::optional< T > Get (const wxString &aProperty) const
 

Static Public Member Functions

static bool TestFileIsExcellon (const wxString &aFullFileName)
 Performs a heuristics-based check of whether the file is an Excellon drill file. More...
 
static bool TestFileIsRS274 (const wxString &aFullFileName)
 Performs a heuristics-based check of whether the file is an RS274 gerber file. More...
 
template<class T >
static INSPECT_RESULT IterateForward (std::deque< T > &aList, INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &scanTypes)
 This changes first parameter to avoid the DList and use the main queue instead. More...
 
template<class T >
static INSPECT_RESULT IterateForward (std::vector< T > &aList, INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &scanTypes)
 Change first parameter to avoid the DList and use std::vector instead. More...
 
static bool Replace (const EDA_SEARCH_DATA &aSearchData, wxString &aText)
 Perform 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)
 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
 true if this image is currently in use (a file is loaded in it) false if it must be not drawn More...
 
COLOR4D m_PositiveDrawColor
 The color used to draw positive items. More...
 
wxString m_FileName
 Full File Name for this layer. More...
 
wxString m_ImageName
 Image name, from IN <name>* command. More...
 
bool m_IsX2_file
 True if a X2 gerber attribute was found in file. More...
 
X2_ATTRIBUTE_FILEFUNCTIONm_FileFunction
 file function parameters, found in a TF command or a G04 More...
 
wxString m_MD5_value
 MD5 value found in a TF.MD5 command. More...
 
wxString m_PartString
 string found in a TF.Part command More...
 
int m_GraphicLayer
 Graphic layer Number. More...
 
bool m_ImageNegative
 true = Negative image More...
 
bool m_ImageJustifyXCenter
 Image Justify Center on X axis (default = false) More...
 
bool m_ImageJustifyYCenter
 Image Justify Center on Y axis (default = false) More...
 
VECTOR2I m_ImageJustifyOffset
 Image Justify Offset on XY axis (default = 0,0) More...
 
bool m_GerbMetric
 false = Inches, true = metric More...
 
bool m_Relative
 false = absolute Coord, true = relative Coord. More...
 
bool m_NoTrailingZeros
 true: remove tailing zeros. More...
 
VECTOR2I m_ImageOffset
 Coord Offset, from IO command. More...
 
wxSize m_FmtScale
 Fmt 2.3: m_FmtScale = 3, fmt 3.4: m_FmtScale = 4. More...
 
wxSize m_FmtLen
 Nb chars per coord. ex fmt 2.3, m_FmtLen = 5. More...
 
int m_ImageRotation
 Image rotation (0, 90, 180, 270 only) in degrees. More...
 
double m_LocalRotation
 Local rotation added to m_ImageRotation. More...
 
VECTOR2I m_Offset
 Coord Offset, from OF command. More...
 
VECTOR2I m_Scale
 scale (X and Y) of layer. More...
 
bool m_SwapAxis
 false if A = X and B = Y (default); true if A = Y, B = X More...
 
bool m_MirrorA
 true: mirror / axis A (X) More...
 
bool m_MirrorB
 true: mirror / axis B (Y) More...
 
int m_Iterpolation
 Linear, 90 arc, Circ. More...
 
int m_Current_Tool
 Current Tool (Dcode) number selected. More...
 
int m_Last_Pen_Command
 Current or last pen state (0..9, set by Dn option with n < 10. More...
 
int m_CommandState
 state of gerber analysis command More...
 
int m_LineNum
 Line number of the gerber file while reading. More...
 
VECTOR2I m_CurrentPos
 current specified coord for plot More...
 
VECTOR2I m_PreviousPos
 old current specified coord for plot More...
 
VECTOR2I m_IJPos
 IJ coord (for arcs & circles ) More...
 
bool m_LastCoordIsIJPos
 A value ( = radius in circular routing in Excellon files ). More...
 
int m_ArcRadius
 Identifier for arc data type (IJ (center) or A## (radius)). More...
 
LAST_EXTRA_ARC_DATA_TYPE m_LastArcDataType
 
FILE * m_Current_File
 
int m_Selected_Tool
 
bool m_Has_DCode
 < True if has DCodes in file or false if no DCodes found. Perhaps deprecated RS274D file. More...
 
bool m_Has_MissingDCode
 
bool m_360Arc_enbl
 
bool m_AsArcG74G75Cmd
 
bool m_PolygonFillMode
 
int m_PolygonFillModeState
 a collection of APERTURE_MACROS, sorted by name More...
 
APERTURE_MACRO_SET m_aperture_macros
 
GBR_NETLIST_METADATA m_NetAttributeDict
 
wxString m_AperFunction
 
std::map< wxString, int > m_ComponentsList
 
std::map< wxString, int > m_NetnamesList
 
D_CODEm_Aperture_List [TOOLS_MAX_COUNT]
 < Dcode (Aperture) List for this layer (max TOOLS_MAX_COUNT: see dcode.h) More...
 
bool m_Exposure
 
GERBER_LAYER m_GBRLayerParams
 
GERBER_DRAW_ITEMS m_drawings
 
const KIID m_Uuid
 

Protected Member Functions

bool Matches (const wxString &aText, const EDA_SEARCH_DATA &aSearchData) const
 Compare aText against search criteria in aSearchData. More...
 

Protected Attributes

EDA_ITEM_FLAGS m_status
 
EDA_ITEMm_parent
 Linked list: Link (parent struct) More...
 
bool m_forceVisible
 
EDA_ITEM_FLAGS m_flags
 

Private Types

enum  EXCELLON_STATE { READ_HEADER_STATE , READ_PROGRAM_STATE }
 

Private Member Functions

bool Execute_HEADER_And_M_Command (char *&text)
 
bool Select_Tool (char *&text)
 
bool Execute_EXCELLON_G_Command (char *&text)
 
bool Execute_Drill_Command (char *&text)
 
void readFileFormat (char *&aText)
 Read an Altium-specific FILE_FORMAT=X:X attribute that specifies the length and mantissa of the numbers in the gerber file. More...
 
bool readToolInformation (char *&aText)
 Read a tool definition like T1C0.02 or T1F00S00C0.02 or T1C0.02F00S00 and enter params in TCODE list. More...
 
void FinishRouteCommand ()
 End a route command started by M15 ot G01, G02 or G03 command. More...
 
void SelectUnits (bool aMetric, EXCELLON_DEFAULTS *aDefaults)
 Switch unit selection, and the coordinate format (nn:mm) if not yet set. More...
 
char * GetNextLine (char *aBuff, unsigned int aBuffSize, char *aText, FILE *aFile)
 Test for an end of line. More...
 
bool GetEndOfBlock (char *aBuff, unsigned int aBuffSize, char *&aText, FILE *aGerberFile)
 
bool ReadRS274XCommand (char *aBuff, unsigned int aBuffSize, char *&aText)
 Read a single RS274X command terminated with a %. More...
 
bool ExecuteRS274XCommand (int aCommand, char *aBuff, unsigned int aBuffSize, char *&aText)
 Execute a RS274X command. More...
 
int ReadXCommandID (char *&text)
 Read 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)
 Read 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

EXCELLON_STATE m_State
 
bool m_SlotOn
 
bool m_RouteModeOn
 
std::vector< EXCELLON_ROUTE_COORDm_RoutePositions
 
bool m_hasFormat
 Excellon file do not have a format statement to specify the coordinate format like nn:mm. More...
 
wxArrayString m_messagesList
 
int m_hasNegativeItems
 True if the image is negative or has some negative items. More...
 
KICAD_T m_structType
 Run time identification, keep private so it can never be changed after a ctor sets it. More...
 
VIEW_ITEM_DATA * m_viewPrivData
 

Detailed Description

Handle a drill image.

It is derived from GERBER_FILE_IMAGE because there is a lot of likeness between EXCELLON files and GERBER files. DCode apertures are also similar to T Codes.

Definition at line 137 of file excellon_image.h.

Member Enumeration Documentation

◆ EXCELLON_STATE

Enumerator
READ_HEADER_STATE 
READ_PROGRAM_STATE 

Definition at line 209 of file excellon_image.h.

209 {
210 READ_HEADER_STATE, // When we are in this state, we are reading header
211 READ_PROGRAM_STATE // When we are in this state, we are reading drill data
212 };

Constructor & Destructor Documentation

◆ EXCELLON_IMAGE()

EXCELLON_IMAGE::EXCELLON_IMAGE ( int  layer)
inline

Definition at line 139 of file excellon_image.h.

139 : EXCELLON_IMAGE( int layer ) :
140 GERBER_FILE_IMAGE( layer )
141 {
143 m_SlotOn = false;
144 m_RouteModeOn = false;
145 m_hasFormat = false;
146 }
EXCELLON_STATE m_State
bool m_hasFormat
Excellon file do not have a format statement to specify the coordinate format like nn:mm.
EXCELLON_IMAGE(int layer)
Hold the image data and parameters for one gerber file and layer parameters.

References m_hasFormat, m_RouteModeOn, m_SlotOn, m_State, and READ_HEADER_STATE.

◆ ~EXCELLON_IMAGE()

EXCELLON_IMAGE::~EXCELLON_IMAGE ( )
inline

Definition at line 149 of file excellon_image.h.

149{};

Member Function Documentation

◆ AddItemToList()

void GERBER_FILE_IMAGE::AddItemToList ( GERBER_DRAW_ITEM aItem)
inlineinherited

Add a new GERBER_DRAW_ITEM item to the drawings list.

Parameters
aItemis the GERBER_DRAW_ITEM to add to list

Definition at line 167 of file gerber_file_image.h.

168 {
169 m_drawings.push_back( aItem );
170 }
GERBER_DRAW_ITEMS m_drawings

References GERBER_FILE_IMAGE::m_drawings.

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

◆ AddMessageToList()

◆ ClearBrightened()

void EDA_ITEM::ClearBrightened ( )
inlineinherited

Definition at line 119 of file eda_item.h.

void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:141
#define BRIGHTENED
item is drawn with a bright contour

References BRIGHTENED, and EDA_ITEM::ClearFlags().

Referenced by SCH_EDIT_FRAME::FocusOnItem(), PCB_BASE_FRAME::FocusOnItems(), EE_SELECTION_TOOL::unhighlight(), PL_SELECTION_TOOL::unhighlight(), PCB_SELECTION_TOOL::unhighlightInternal(), and SCH_EDITOR_CONTROL::UpdateNetHighlighting().

◆ ClearEditFlags()

◆ ClearFlags()

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

Definition at line 141 of file eda_item.h.

141{ m_flags &= ~aMask; }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:498

References EDA_ITEM::m_flags.

Referenced by FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), PNS_KICAD_IFACE::AddItem(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), SCH_MOVE_TOOL::AlignElements(), SCH_EDIT_TOOL::BreakWire(), FOOTPRINT::BuildCourtyardCaches(), EDA_ITEM::ClearBrightened(), EDA_ITEM::ClearEditFlags(), EDA_ITEM::ClearSelected(), EDA_ITEM::ClearTempFlags(), SCH_EDIT_FRAME::ConvertPart(), SYMBOL_EDITOR_EDIT_TOOL::Copy(), FOOTPRINT_EDITOR_CONTROL::CreateFootprint(), SYMBOL_EDITOR_PIN_TOOL::CreateImagePins(), MICROWAVE_TOOL::createMicrowaveInductor(), DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES(), PCB_TOOL_BASE::doInteractiveItemPlacement(), KIGFX::SCH_PAINTER::draw(), SCH_ITEM::Duplicate(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PCB_EDIT_FRAME::ExchangeFootprint(), PCB_SELECTION_TOOL::ExitGroup(), SYMBOL_EDIT_FRAME::GetSymbolFromRedoList(), SYMBOL_EDIT_FRAME::GetSymbolFromUndoList(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), DRC_INTERACTIVE_COURTYARD_CLEARANCE::Init(), EE_COLLECTOR::Inspect(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromLibrary(), FOOTPRINT_EDITOR_CONTROL::NewFootprint(), DIALOG_SYMBOL_PROPERTIES::OnUnitChoice(), FOOTPRINT_EDIT_FRAME::OpenProjectFiles(), PCB_BASE_FRAME::PlaceFootprint(), SYMBOL_EDITOR_PIN_TOOL::PlacePin(), BOARD_COMMIT::Push(), PCB_SELECTION_TOOL::RebuildSelection(), PAD_TOOL::RecombinePad(), SCH_EDIT_TOOL::RepeatDrawItem(), SYMBOL_EDIT_FRAME::RollbackSymbolFromUndo(), DRC_TEST_PROVIDER_DISALLOW::Run(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), SCH_SEXPR_PLUGIN_CACHE::savePin(), EE_SELECTION_TOOL::selectMultiple(), SCH_EDIT_FRAME::SelectUnit(), EDA_ITEM::SetIsShownAsBitmap(), BOARD_COMMIT::Stage(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), SCH_DRAWING_TOOLS::TwoClickPlace(), and EE_SELECTION_TOOL::unhighlight().

◆ ClearMessageList()

void GERBER_FILE_IMAGE::ClearMessageList ( )
inlineinherited

Clear the message list.

Call it before reading a Gerber file

Definition at line 199 of file gerber_file_image.h.

200 {
201 m_messagesList.Clear();
202 }

References GERBER_FILE_IMAGE::m_messagesList.

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

◆ ClearSelected()

◆ ClearTempFlags()

void EDA_ITEM::ClearTempFlags ( )
inlineinherited

Definition at line 153 of file eda_item.h.

154 {
156 }
#define IS_LINKED
Used in calculation to mark linked items (temporary use)
#define SELECTED_BY_DRAG
Item was algorithmically selected as a dragged item.
#define SKIP_STRUCT
flag indicating that the structure should be ignored
#define CANDIDATE
flag indicating that the structure is connected

References CANDIDATE, EDA_ITEM::ClearFlags(), IS_LINKED, SELECTED_BY_DRAG, and SKIP_STRUCT.

Referenced by PCB_EDIT_FRAME::OpenProjectFiles(), and SCH_EDIT_FRAME::PutDataInPreviousState().

◆ ClearViewPrivData()

void KIGFX::VIEW_ITEM::ClearViewPrivData ( )
inlineinherited

Definition at line 143 of file view_item.h.

144 {
145 m_viewPrivData = nullptr;
146 }
VIEW_ITEM_DATA * m_viewPrivData
Definition: view_item.h:151

References KIGFX::VIEW_ITEM::m_viewPrivData.

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

◆ Clone()

EDA_ITEM * EDA_ITEM::Clone ( ) const
virtualinherited

Create 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 LIB_FIELD, LIB_PIN, LIB_SHAPE, LIB_TEXT, LIB_TEXTBOX, SCH_BITMAP, SCH_BUS_WIRE_ENTRY, SCH_BUS_BUS_ENTRY, SCH_FIELD, SCH_JUNCTION, SCH_LABEL, SCH_DIRECTIVE_LABEL, SCH_GLOBALLABEL, SCH_HIERLABEL, SCH_LINE, SCH_MARKER, SCH_NO_CONNECT, SCH_PIN, SCH_SHAPE, SCH_SHEET, SCH_SHEET_PIN, SCH_SYMBOL, SCH_TEXT, SCH_TEXTBOX, KIGFX::ORIGIN_VIEWITEM, PCB_GROUP, FOOTPRINT, FP_SHAPE, FP_TEXT, FP_TEXTBOX, NETINFO_ITEM, PAD, PCB_BITMAP, PCB_DIM_ALIGNED, PCB_DIM_ORTHOGONAL, PCB_DIM_RADIAL, PCB_DIM_LEADER, PCB_DIM_CENTER, PCB_MARKER, PCB_SHAPE, PCB_TARGET, PCB_TEXT, PCB_TEXTBOX, PCB_TRACK, PCB_ARC, PCB_VIA, ZONE, and FP_ZONE.

Definition at line 82 of file eda_item.cpp.

83{
84 wxCHECK_MSG( false, nullptr, wxT( "Clone not implemented in derived class " ) + GetClass() +
85 wxT( ". Bad programmer!" ) );
86}
virtual wxString GetClass() const =0
Return the class name.

References EDA_ITEM::GetClass().

Referenced by SCH_EDIT_FRAME::AddCopyForRepeatItem(), DIALOG_DIMENSION_PROPERTIES::DIALOG_DIMENSION_PROPERTIES(), BOARD_ITEM::Duplicate(), SCH_ITEM::Duplicate(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PCB_DIMENSION_BASE::GetEffectiveShape(), LIB_SYMBOL::LIB_SYMBOL(), BOARD_COMMIT::makeImage(), new_clone(), LIB_SYMBOL::operator=(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), SCH_LIB_PLUGIN_CACHE::removeSymbol(), PCB_BASE_EDIT_FRAME::saveCopyInUndoList(), CLIPBOARD_IO::SaveSelection(), LIB_SYMBOL::SetConversion(), LIB_SYMBOL::SetUnitCount(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace().

◆ CodeNumber()

int GERBER_FILE_IMAGE::CodeNumber ( char *&  aText)
inherited

Reads the next number and returns the value.

Parameters
aTextPointer to the input string vector
Returns

Definition at line 401 of file rs274d.cpp.

402{
403 int retval;
404 char* endptr;
405
406 errno = 0;
407
408 retval = strtol( aText + 1, &endptr, 10 );
409
410 if( endptr == aText || errno != 0 )
411 return 0;
412
413 wxCHECK_MSG( retval < std::numeric_limits<int>::max(), 0, _( "Invalid Code Number" ) );
414
415 aText = endptr;
416
417 return static_cast<int>( retval );
418}
#define _(s)

References _.

Referenced by GERBER_FILE_IMAGE::Execute_G_Command(), GERBER_FILE_IMAGE::LoadGerberFile(), and Select_Tool().

◆ DisplayImageInfo()

void GERBER_FILE_IMAGE::DisplayImageInfo ( GERBVIEW_FRAME aMainFrame)
inherited

Display information about image parameters in the status bar.

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

Parameters
aMainFrameThe 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) Some are deprecated

Definition at line 314 of file gerber_file_image.cpp.

315{
316 wxString msg;
317
318 aMainFrame->ClearMsgPanel();
319
320 // Display the Gerber variant (X1 / X2
321 aMainFrame->AppendMsgPanel( _( "Format" ), m_IsX2_file ? wxT( "X2" ) : wxT( "X1" ) );
322
323 // Display Image name (Image specific). IM command (Image Name) is deprecated
324 // So non empty image name is very rare, probably never found
325 if( !m_ImageName.IsEmpty() )
326 aMainFrame->AppendMsgPanel( _( "Image name" ), m_ImageName );
327
328 // Display graphic layer number used to draw this Image
329 // (not a Gerber parameter but is also image specific)
330 msg.Printf( wxT( "%d" ), m_GraphicLayer + 1 );
331 aMainFrame->AppendMsgPanel( _( "Graphic layer" ), msg );
332
333 // Display Image rotation (Image specific)
334 msg.Printf( wxT( "%d" ), m_ImageRotation );
335 aMainFrame->AppendMsgPanel( _( "Img Rot." ), msg );
336
337 // Display Image polarity (Image specific)
338 msg = m_ImageNegative ? _("Negative") : _("Normal");
339 aMainFrame->AppendMsgPanel( _( "Polarity" ), msg );
340
341 // Display Image justification and offset for justification (Image specific)
342 msg = m_ImageJustifyXCenter ? _("Center") : _("Normal");
343 aMainFrame->AppendMsgPanel( _( "X Justify" ), msg );
344
345 msg = m_ImageJustifyYCenter ? _("Center") : _("Normal");
346 aMainFrame->AppendMsgPanel( _( "Y Justify" ), msg );
347
348 msg.Printf( wxT( "X=%s Y=%s" ),
351
352 aMainFrame->AppendMsgPanel( _( "Image Justify Offset" ), msg );
353}
virtual void ClearMsgPanel()
Clear all messages from the message panel.
void AppendMsgPanel(const wxString &aTextUpper, const wxString &aTextLower, int aPadding=6)
Append a message to the message panel.
bool m_ImageJustifyXCenter
Image Justify Center on X axis (default = false)
bool m_ImageJustifyYCenter
Image Justify Center on Y axis (default = false)
bool m_ImageNegative
true = Negative image
wxString m_ImageName
Image name, from IN <name>* command.
bool m_IsX2_file
True if a X2 gerber attribute was found in file.
int m_ImageRotation
Image rotation (0, 90, 180, 270 only) in degrees.
int m_GraphicLayer
Graphic layer Number.
VECTOR2I m_ImageJustifyOffset
Image Justify Offset on XY axis (default = 0,0)
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().

References _, EDA_DRAW_FRAME::AppendMsgPanel(), EDA_DRAW_FRAME::ClearMsgPanel(), GERBER_FILE_IMAGE::m_GraphicLayer, GERBER_FILE_IMAGE::m_ImageJustifyOffset, GERBER_FILE_IMAGE::m_ImageJustifyXCenter, GERBER_FILE_IMAGE::m_ImageJustifyYCenter, GERBER_FILE_IMAGE::m_ImageName, GERBER_FILE_IMAGE::m_ImageNegative, GERBER_FILE_IMAGE::m_ImageRotation, GERBER_FILE_IMAGE::m_IsX2_file, UNITS_PROVIDER::MessageTextFromValue(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by GERBVIEW_FRAME::UpdateTitleAndInfo().

◆ Execute_DCODE_Command()

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

Definition at line 557 of file rs274d.cpp.

558{
559 wxSize size( 15, 15 );
560
561 APERTURE_T aperture = APT_CIRCLE;
562 GERBER_DRAW_ITEM* gbritem;
563
564 int dcode = 0;
565 D_CODE* tool = nullptr;
566 wxString msg;
567
568 if( D_commande >= FIRST_DCODE ) // This is a "Set tool" command
569 {
570 if( D_commande > (TOOLS_MAX_COUNT - 1) )
571 D_commande = TOOLS_MAX_COUNT - 1;
572
573 // remember which tool is selected, nothing is done with it in this
574 // call
575 m_Current_Tool = D_commande;
576
577 D_CODE* pt_Dcode = GetDCODE( D_commande );
578
579 if( pt_Dcode )
580 pt_Dcode->m_InUse = true;
581 else
582 m_Has_MissingDCode = true;
583
584 return true;
585 }
586 else // D_commande = 0..9: this is a pen command (usually D1, D2 or D3)
587 {
588 m_Last_Pen_Command = D_commande;
589 }
590
591 if( m_PolygonFillMode ) // Enter a polygon description:
592 {
593 switch( D_commande )
594 {
595 case 1: // code D01 Draw line, exposure ON
596 if( !m_Exposure ) // Start a new polygon outline:
597 {
598 m_Exposure = true;
599 gbritem = new GERBER_DRAW_ITEM( this );
600 AddItemToList( gbritem );
601 gbritem->m_Shape = GBR_POLYGON;
602 gbritem->m_Flashed = false;
603 gbritem->m_DCode = 0; // No DCode for a Polygon (Region in Gerber dialect)
604
605
606 if( gbritem->m_GerberImageFile )
607 {
610 }
611 }
612
613 switch( m_Iterpolation )
614 {
617 // Before any arc command, a G74 or G75 command must be set.
618 // Otherwise the Gerber file is invalid
619 if( !m_AsArcG74G75Cmd )
620 {
621 AddMessageToList( _( "Invalid Gerber file: missing G74 or G75 arc command" ) );
622
623 // Disable further warning messages:
624 m_AsArcG74G75Cmd = true;
625 }
626
627 gbritem = GetLastItemInList();
628
629 fillArcPOLY( gbritem, m_PreviousPos,
631 ( m_Iterpolation == GERB_INTERPOL_ARC_NEG ) ? false : true,
632 m_360Arc_enbl, GetLayerParams().m_LayerNegative );
633 break;
634
635 default:
636 gbritem = GetLastItemInList();
637
638 gbritem->m_Start = m_PreviousPos; // m_Start is used as temporary storage
639
640 if( gbritem->m_Polygon.OutlineCount() == 0 )
641 {
642 gbritem->m_Polygon.NewOutline();
643 gbritem->m_Polygon.Append( VECTOR2I( gbritem->m_Start ) );
644 }
645
646 gbritem->m_End = m_CurrentPos; // m_End is used as temporary storage
647 gbritem->m_Polygon.Append( VECTOR2I( gbritem->m_End ) );
648 break;
649 }
650
653 break;
654
655 case 2: // code D2: exposure OFF (i.e. "move to")
656 if( m_Exposure && GetLastItemInList() ) // End of polygon
657 {
658 gbritem = GetLastItemInList();
659 gbritem->m_Polygon.Append( gbritem->m_Polygon.CVertex( 0 ) );
660 StepAndRepeatItem( *gbritem );
661 }
662
663 m_Exposure = false;
666 break;
667
668 default:
669 return false;
670 }
671 }
672 else
673 {
674 switch( D_commande )
675 {
676 case 1: // code D01 Draw line, exposure ON
677 m_Exposure = true;
678
679 tool = GetDCODE( m_Current_Tool );
680
681 if( tool )
682 {
683 size = tool->m_Size;
684 dcode = tool->m_Num_Dcode;
685 aperture = tool->m_Shape;
686 }
687
688 switch( m_Iterpolation )
689 {
691 gbritem = new GERBER_DRAW_ITEM( this );
692 AddItemToList( gbritem );
693
694 fillLineGBRITEM( gbritem, dcode, m_PreviousPos,
695 m_CurrentPos, size, GetLayerParams().m_LayerNegative );
696 StepAndRepeatItem( *gbritem );
697 break;
698
701 gbritem = new GERBER_DRAW_ITEM( this );
702 AddItemToList( gbritem );
703
705 {
706 fillArcGBRITEM( gbritem, dcode, m_PreviousPos,
707 m_CurrentPos, m_IJPos, size,
709 false : true, m_360Arc_enbl, GetLayerParams().m_LayerNegative );
710 m_LastCoordIsIJPos = false;
711 }
712 else
713 {
714 fillLineGBRITEM( gbritem, dcode, m_PreviousPos,
715 m_CurrentPos, size, GetLayerParams().m_LayerNegative );
716 }
717
718 StepAndRepeatItem( *gbritem );
719
720 break;
721
722 default:
723 msg.Printf( wxT( "RS274D: DCODE Command: interpol error (type %X)" ),
725 AddMessageToList( msg );
726 break;
727 }
728
730 break;
731
732 case 2: // code D2: exposure OFF (i.e. "move to")
733 m_Exposure = false;
735 break;
736
737 case 3: // code D3: flash aperture
738 tool = GetDCODE( m_Current_Tool );
739
740 if( tool )
741 {
742 size = tool->m_Size;
743 dcode = tool->m_Num_Dcode;
744 aperture = tool->m_Shape;
745 }
746
747 gbritem = new GERBER_DRAW_ITEM( this );
748 AddItemToList( gbritem );
749 fillFlashedGBRITEM( gbritem, aperture, dcode, m_CurrentPos,
750 size, GetLayerParams().m_LayerNegative );
751 StepAndRepeatItem( *gbritem );
753 break;
754
755 default:
756 return false;
757 }
758 }
759
760 return true;
761}
A gerber DCODE (also called Aperture) definition.
Definition: dcode.h:80
int m_Num_Dcode
D code value ( >= 10 )
Definition: dcode.h:191
APERTURE_T m_Shape
shape ( Line, rectangle, circle , oval .. )
Definition: dcode.h:190
bool m_InUse
false if the aperture (previously defined) is not used to draw something
Definition: dcode.h:198
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:189
SHAPE_POLY_SET m_Polygon
GERBER_FILE_IMAGE * m_GerberImageFile
void SetNetAttributes(const GBR_NETLIST_METADATA &aNetAttributes)
int m_Last_Pen_Command
Current or last pen state (0..9, set by Dn option with n < 10.
GERBER_DRAW_ITEM * GetLastItemInList() const
void StepAndRepeatItem(const GERBER_DRAW_ITEM &aItem)
Gerber format has a command Step an Repeat.
VECTOR2I m_PreviousPos
old current specified coord for plot
void AddMessageToList(const wxString &aMessage)
Add a message to the message list.
VECTOR2I m_IJPos
IJ coord (for arcs & circles )
D_CODE * GetDCODE(int aDCODE) const
Return a pointer to the D_CODE within this GERBER for the given aDCODE.
int m_PolygonFillModeState
a collection of APERTURE_MACROS, sorted by name
int m_Current_Tool
Current Tool (Dcode) number selected.
void AddItemToList(GERBER_DRAW_ITEM *aItem)
Add a new GERBER_DRAW_ITEM item to the drawings list.
GBR_NETLIST_METADATA m_NetAttributeDict
int m_Iterpolation
Linear, 90 arc, Circ.
VECTOR2I m_CurrentPos
current specified coord for plot
bool m_LastCoordIsIJPos
A value ( = radius in circular routing in Excellon files ).
GERBER_LAYER & GetLayerParams()
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
int NewOutline()
Creates a new hole in a given outline.
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the aGlobalIndex-th vertex in the poly set.
int OutlineCount() const
Return the number of vertices in a given outline/hole.
APERTURE_T
The set of all gerber aperture types allowed, according to page 16 of http://gerbv....
Definition: dcode.h:48
@ APT_CIRCLE
Definition: dcode.h:49
#define FIRST_DCODE
Definition: dcode.h:69
#define TOOLS_MAX_COUNT
Definition: dcode.h:71
@ GBR_POLYGON
@ GERB_INTERPOL_ARC_NEG
Definition: gerbview.h:36
@ GERB_INTERPOL_LINEAR_1X
Definition: gerbview.h:35
@ GERB_INTERPOL_ARC_POS
Definition: gerbview.h:37
void fillLineGBRITEM(GERBER_DRAW_ITEM *aGbrItem, int Dcode_index, const VECTOR2I &aStart, const VECTOR2I &aEnd, wxSize aPenSize, bool aLayerNegative)
Initialize a given GBRITEM so that it can draw a linear D code.
Definition: rs274d.cpp:153
void fillArcGBRITEM(GERBER_DRAW_ITEM *aGbrItem, int Dcode_index, const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aRelCenter, wxSize aPenSize, bool aClockwise, bool aMultiquadrant, bool aLayerNegative)
Initialize a given GBRITEM so that it can draw an arc G code.
Definition: rs274d.cpp:202
static void fillArcPOLY(GERBER_DRAW_ITEM *aGbrItem, const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &rel_center, bool aClockwise, bool aMultiquadrant, bool aLayerNegative)
Create an arc G code when found in polygon outlines.
Definition: rs274d.cpp:328
void fillFlashedGBRITEM(GERBER_DRAW_ITEM *aGbrItem, APERTURE_T aAperture, int Dcode_index, const VECTOR2I &aPos, wxSize aSize, bool aLayerNegative)
Initializes a given GBRITEM so that it can draw a circle which is filled and has no pen border.
Definition: rs274d.cpp:99
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

References _, GERBER_FILE_IMAGE::AddItemToList(), GERBER_FILE_IMAGE::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, GERBER_FILE_IMAGE::GetDCODE(), GERBER_FILE_IMAGE::GetLastItemInList(), GERBER_FILE_IMAGE::GetLayerParams(), GERBER_FILE_IMAGE::m_360Arc_enbl, GERBER_DRAW_ITEM::m_AperFunction, GERBER_FILE_IMAGE::m_AperFunction, GERBER_FILE_IMAGE::m_AsArcG74G75Cmd, GERBER_FILE_IMAGE::m_Current_Tool, GERBER_FILE_IMAGE::m_CurrentPos, GERBER_DRAW_ITEM::m_DCode, GERBER_DRAW_ITEM::m_End, GERBER_FILE_IMAGE::m_Exposure, GERBER_DRAW_ITEM::m_Flashed, GERBER_DRAW_ITEM::m_GerberImageFile, GERBER_FILE_IMAGE::m_Has_MissingDCode, GERBER_FILE_IMAGE::m_IJPos, D_CODE::m_InUse, GERBER_FILE_IMAGE::m_Iterpolation, GERBER_FILE_IMAGE::m_Last_Pen_Command, GERBER_FILE_IMAGE::m_LastCoordIsIJPos, GERBER_FILE_IMAGE::m_NetAttributeDict, D_CODE::m_Num_Dcode, GERBER_DRAW_ITEM::m_Polygon, GERBER_FILE_IMAGE::m_PolygonFillMode, GERBER_FILE_IMAGE::m_PolygonFillModeState, GERBER_FILE_IMAGE::m_PreviousPos, D_CODE::m_Shape, GERBER_DRAW_ITEM::m_Shape, D_CODE::m_Size, GERBER_DRAW_ITEM::m_Start, SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::OutlineCount(), GERBER_DRAW_ITEM::SetNetAttributes(), GERBER_FILE_IMAGE::StepAndRepeatItem(), and TOOLS_MAX_COUNT.

Referenced by GERBER_FILE_IMAGE::LoadGerberFile().

◆ Execute_Drill_Command()

bool EXCELLON_IMAGE::Execute_Drill_Command ( char *&  text)
private

Definition at line 809 of file excellon_read_drill_file.cpp.

810{
811 D_CODE* tool;
812 GERBER_DRAW_ITEM * gbritem;
813
814 while( true )
815 {
816 switch( *text )
817 {
818 case 'X':
819 case 'Y':
820 ReadXYCoord( text, true );
821
822 if( *text == 'I' || *text == 'J' )
823 ReadIJCoord( text );
824
825 break;
826
827 case 'G': // G85 is found here for oval holes
830 break;
831
832 case 0: // E.O.L: execute command
833 if( m_RouteModeOn )
834 {
835 // We are in routing mode, and this is an intermediate point.
836 // So just store it
837 int rmode = 0; // linear routing.
838
840 rmode = ROUTE_CW;
842 rmode = ROUTE_CCW;
843
845 {
847 m_RoutePositions.push_back( point );
848 }
849 else
850 {
852 m_RoutePositions.push_back( point );
853 }
854 return true;
855 }
856
857 tool = GetDCODE( m_Current_Tool );
858 if( !tool )
859 {
860 wxString msg;
861 msg.Printf( _( "Tool %d not defined" ), m_Current_Tool );
862 AddMessageToList( msg );
863 return false;
864 }
865
866 gbritem = new GERBER_DRAW_ITEM( this );
867 AddItemToList( gbritem );
868
869 if( m_SlotOn ) // Oblong hole
870 {
871 fillLineGBRITEM( gbritem, tool->m_Num_Dcode,
873 tool->m_Size, false );
874 // the hole is made: reset the slot on command (G85)
875 // (it is needed for each oblong hole)
876 m_SlotOn = false;
877 }
878 else
879 {
880 fillFlashedGBRITEM( gbritem, tool->m_Shape, tool->m_Num_Dcode,
881 m_CurrentPos, tool->m_Size, false );
882 }
883
884 StepAndRepeatItem( *gbritem );
886 return true;
887 break;
888
889 default:
890 text++;
891 break;
892 }
893 }
894
895 return true;
896}
bool Execute_EXCELLON_G_Command(char *&text)
std::vector< EXCELLON_ROUTE_COORD > m_RoutePositions
VECTOR2I ReadIJCoord(char *&Text)
Return the current coordinate type pointed to by InnJnn Text (InnnnJmmmm)
int m_ArcRadius
Identifier for arc data type (IJ (center) or A## (radius)).
LAST_EXTRA_ARC_DATA_TYPE m_LastArcDataType
VECTOR2I ReadXYCoord(char *&aText, bool aExcellonMode=false)
Return the current coordinate type pointed to by XnnYnn Text (XnnnnYmmmm).
#define ROUTE_CW
#define ROUTE_CCW
void fillLineGBRITEM(GERBER_DRAW_ITEM *aGbrItem, int Dcode_index, const VECTOR2I &aStart, const VECTOR2I &aEnd, wxSize aPenSize, bool aLayerNegative)
Initialize a given GBRITEM so that it can draw a linear D code.
Definition: rs274d.cpp:153
void fillFlashedGBRITEM(GERBER_DRAW_ITEM *aGbrItem, APERTURE_T aAperture, int Dcode_index, const VECTOR2I &aPos, wxSize aSize, bool aLayerNegative)
Initializes a given GBRITEM so that it can draw a circle which is filled and has no pen border.
Definition: rs274d.cpp:99
@ ARC_INFO_TYPE_CENTER

References _, GERBER_FILE_IMAGE::AddItemToList(), GERBER_FILE_IMAGE::AddMessageToList(), ARC_INFO_TYPE_CENTER, Execute_EXCELLON_G_Command(), fillFlashedGBRITEM(), fillLineGBRITEM(), GERB_INTERPOL_ARC_NEG, GERB_INTERPOL_ARC_POS, GERBER_FILE_IMAGE::GetDCODE(), GERBER_FILE_IMAGE::m_ArcRadius, GERBER_FILE_IMAGE::m_Current_Tool, GERBER_FILE_IMAGE::m_CurrentPos, GERBER_FILE_IMAGE::m_IJPos, GERBER_FILE_IMAGE::m_Iterpolation, GERBER_FILE_IMAGE::m_LastArcDataType, D_CODE::m_Num_Dcode, GERBER_FILE_IMAGE::m_PreviousPos, m_RouteModeOn, m_RoutePositions, D_CODE::m_Shape, D_CODE::m_Size, m_SlotOn, GERBER_FILE_IMAGE::ReadIJCoord(), GERBER_FILE_IMAGE::ReadXYCoord(), ROUTE_CCW, ROUTE_CW, GERBER_FILE_IMAGE::StepAndRepeatItem(), and text.

Referenced by LoadFile().

◆ Execute_EXCELLON_G_Command()

bool EXCELLON_IMAGE::Execute_EXCELLON_G_Command ( char *&  text)
private

Definition at line 942 of file excellon_read_drill_file.cpp.

943{
944 EXCELLON_CMD* cmd = nullptr;
945 bool success = false;
946 int id = DRILL_G_UNKNOWN;
947
948 // Search command in list
949 EXCELLON_CMD* candidate;
950 char * gcmd = text; // gcmd points the G command, for error messages.
951
952 for( unsigned ii = 0; ; ii++ )
953 {
954 candidate = &excellon_G_CmdList[ii];
955 int len = candidate->m_Name.size();
956 if( len == 0 ) // End of list reached
957 break;
958 if( candidate->m_Name.compare( 0, len, text, len ) == 0 ) // found.
959 {
960 cmd = candidate;
961 text += len;
962 success = true;
963 id = cmd->m_Code;
964 break;
965 }
966 }
967
968 switch( id )
969 {
970 case DRILL_G_ZERO_SET:
971 ReadXYCoord( text, true );
973 break;
974
975 case DRILL_G_ROUT:
976 m_SlotOn = false;
977
978 if( m_RouteModeOn )
980
981 m_RouteModeOn = true;
982 m_RoutePositions.clear();
984 ReadXYCoord( text, true );
985 // This is the first point (starting point) of routing
986 m_RoutePositions.emplace_back( m_CurrentPos );
987 break;
988
989 case DRILL_G_DRILL:
990 m_SlotOn = false;
991
992 if( m_RouteModeOn )
994
995 m_RouteModeOn = false;
996 m_RoutePositions.clear();
998 break;
999
1000 case DRILL_G_SLOT:
1001 m_SlotOn = true;
1002 break;
1003
1004 case DRILL_G_LINEARMOVE:
1007 ReadXYCoord( text, true );
1008 m_RoutePositions.emplace_back( m_CurrentPos );
1009 break;
1010
1011 case DRILL_G_CWMOVE:
1013 ReadXYCoord( text, true );
1014
1015 if( *text == 'I' || *text == 'J' )
1016 ReadIJCoord( text );
1017
1020 else
1022 break;
1023
1024 case DRILL_G_CCWMOVE:
1026 ReadXYCoord( text, true );
1027
1028 if( *text == 'I' || *text == 'J' )
1029 ReadIJCoord( text );
1030
1033 else
1035 break;
1036
1037 case DRILL_G_ABSOLUTE:
1038 m_Relative = false; // false = absolute coord
1039 break;
1040
1042 m_Relative = true; // true = relative coord
1043 break;
1044
1045 case DRILL_G_UNKNOWN:
1046 default:
1047 AddMessageToList( wxString::Format( _( "Unknown Excellon G Code: &lt;%s&gt;" ), FROM_UTF8(gcmd) ) );
1048 while( *text )
1049 text++;
1050 return false;
1051 }
1052
1053 return success;
1054}
void FinishRouteCommand()
End a route command started by M15 ot G01, G02 or G03 command.
VECTOR2I m_Offset
Coord Offset, from OF command.
bool m_Relative
false = absolute Coord, true = relative Coord.
@ DRILL_G_CWMOVE
@ DRILL_G_ZERO_SET
@ DRILL_G_INCREMENTAL
@ DRILL_G_DRILL
@ DRILL_G_LINEARMOVE
@ DRILL_G_ABSOLUTE
@ DRILL_G_SLOT
@ DRILL_G_ROUT
@ DRILL_G_UNKNOWN
@ DRILL_G_CCWMOVE
static EXCELLON_CMD excellon_G_CmdList[]
@ ARC_INFO_TYPE_NONE
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
std::string m_Name

References _, GERBER_FILE_IMAGE::AddMessageToList(), ARC_INFO_TYPE_CENTER, ARC_INFO_TYPE_NONE, DRILL_G_ABSOLUTE, DRILL_G_CCWMOVE, DRILL_G_CWMOVE, DRILL_G_DRILL, DRILL_G_INCREMENTAL, DRILL_G_LINEARMOVE, DRILL_G_ROUT, DRILL_G_SLOT, DRILL_G_UNKNOWN, DRILL_G_ZERO_SET, excellon_G_CmdList, FinishRouteCommand(), Format(), FROM_UTF8(), GERB_INTERPOL_ARC_NEG, GERB_INTERPOL_ARC_POS, GERB_INTERPOL_LINEAR_1X, GERBER_FILE_IMAGE::m_ArcRadius, EXCELLON_CMD::m_Code, GERBER_FILE_IMAGE::m_CurrentPos, GERBER_FILE_IMAGE::m_IJPos, GERBER_FILE_IMAGE::m_Iterpolation, GERBER_FILE_IMAGE::m_LastArcDataType, EXCELLON_CMD::m_Name, GERBER_FILE_IMAGE::m_Offset, GERBER_FILE_IMAGE::m_Relative, m_RouteModeOn, m_RoutePositions, m_SlotOn, GERBER_FILE_IMAGE::ReadIJCoord(), GERBER_FILE_IMAGE::ReadXYCoord(), ROUTE_CCW, ROUTE_CW, and text.

Referenced by Execute_Drill_Command(), and LoadFile().

◆ Execute_G_Command()

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

Definition at line 421 of file rs274d.cpp.

422{
423 switch( G_command )
424 {
425 case GC_PHOTO_MODE: // can starts a D03 flash command: redundant, can be safely ignored.
426 break;
427
430 break;
431
434 break;
435
438 break;
439
440 case GC_COMMENT:
441 // Skip comment, but only if the line does not start by "G04 #@! "
442 // which is a metadata, i.e. a X2 command inside the comment.
443 // this comment is called a "structured comment"
444 if( strncmp( text, " #@! ", 5 ) == 0 )
445 {
446 text += 5;
447
448 // The string starting at text is the same as the X2 attribute,
449 // but a X2 attribute ends by '%'. So we build the X2 attribute string
450 std::string x2buf;
451
452 while( *text && (*text != '*') )
453 {
454 x2buf += *text;
455 text++;
456 }
457
458 // add the end of X2 attribute string
459 x2buf += "*%";
460 x2buf += '\0';
461
462 char* cptr = (char*)x2buf.data();
463 int code_command = ReadXCommandID( cptr );
464 ExecuteRS274XCommand( code_command, nullptr, 0, cptr );
465 }
466
467 while( *text && (*text != '*') )
468 text++;
469
470 break;
471
472 case GC_SELECT_TOOL:
473 {
474 int D_commande = CodeNumber( text );
475
476 if( D_commande < FIRST_DCODE )
477 return false;
478
479 if( D_commande > (TOOLS_MAX_COUNT - 1) )
480 D_commande = TOOLS_MAX_COUNT - 1;
481
482 m_Current_Tool = D_commande;
483 D_CODE* pt_Dcode = GetDCODE( D_commande );
484
485 if( pt_Dcode )
486 pt_Dcode->m_InUse = true;
487
488 break;
489 }
490
492 m_GerbMetric = false; // false = Inches, true = metric
493 break;
494
496 m_GerbMetric = true; // false = Inches, true = metric
497 break;
498
499 case GC_TURN_OFF_360_INTERPOL: // disable Multi cadran arc and Arc interpol
500 m_360Arc_enbl = false;
501 m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // not sure it should be done
502 m_AsArcG74G75Cmd = true;
503 break;
504
506 m_360Arc_enbl = true;
507 m_AsArcG74G75Cmd = true;
508 break;
509
511 m_Relative = false; // false = absolute Coord, true = relative
512 // Coord
513 break;
514
516 m_Relative = true; // false = absolute Coord, true = relative
517 // Coord
518 break;
519
521 m_PolygonFillMode = true;
522 m_Exposure = false;
523 break;
524
526 if( m_Exposure && GetLastItemInList() ) // End of polygon
527 {
529
530 if( gbritem->m_Polygon.VertexCount() )
531 gbritem->m_Polygon.Append( gbritem->m_Polygon.CVertex( 0 ) );
532
533 StepAndRepeatItem( *gbritem );
534 }
535
536 m_Exposure = false;
537 m_PolygonFillMode = false;
539 m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // not sure it should be done
540 break;
541
542 case GC_MOVE: // Non existent
543 default:
544 {
545 wxString msg;
546 msg.Printf( wxT( "G%0.2d command not handled" ), G_command );
547 AddMessageToList( msg );
548 return false;
549 }
550 }
551
552
553 return true;
554}
bool ExecuteRS274XCommand(int aCommand, char *aBuff, unsigned int aBuffSize, char *&aText)
Execute a RS274X command.
Definition: rs274x.cpp:199
int ReadXCommandID(char *&text)
Read two bytes of data and assembles them into an int with the first byte in the sequence put into th...
Definition: rs274x.cpp:116
bool m_GerbMetric
false = Inches, true = metric
int CodeNumber(char *&aText)
Reads the next number and returns the value.
Definition: rs274d.cpp:401
int VertexCount(int aOutline=-1, int aHole=-1) const
Return the number of points in the shape poly set.
@ GC_SPECIFY_MILLIMETERS
Definition: gerbview.h:54
@ GC_SPECIFY_RELATIVEES_COORD
Definition: gerbview.h:58
@ GC_COMMENT
Definition: gerbview.h:48
@ GC_TURN_ON_360_INTERPOL
Definition: gerbview.h:56
@ GC_LINEAR_INTERPOL_1X
Definition: gerbview.h:45
@ GC_TURN_OFF_360_INTERPOL
Definition: gerbview.h:55
@ GC_SELECT_TOOL
Definition: gerbview.h:51
@ GC_TURN_OFF_POLY_FILL
Definition: gerbview.h:50
@ GC_CIRCLE_POS_INTERPOL
Definition: gerbview.h:47
@ GC_PHOTO_MODE
Definition: gerbview.h:52
@ GC_MOVE
Definition: gerbview.h:44
@ GC_SPECIFY_INCHES
Definition: gerbview.h:53
@ GC_TURN_ON_POLY_FILL
Definition: gerbview.h:49
@ GC_CIRCLE_NEG_INTERPOL
Definition: gerbview.h:46
@ GC_SPECIFY_ABSOLUES_COORD
Definition: gerbview.h:57

References GERBER_FILE_IMAGE::AddMessageToList(), SHAPE_POLY_SET::Append(), GERBER_FILE_IMAGE::CodeNumber(), SHAPE_POLY_SET::CVertex(), GERBER_FILE_IMAGE::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, GERBER_FILE_IMAGE::GetDCODE(), GERBER_FILE_IMAGE::GetLastItemInList(), GERBER_FILE_IMAGE::m_360Arc_enbl, GERBER_FILE_IMAGE::m_AsArcG74G75Cmd, GERBER_FILE_IMAGE::m_Current_Tool, GERBER_FILE_IMAGE::m_Exposure, GERBER_FILE_IMAGE::m_GerbMetric, D_CODE::m_InUse, GERBER_FILE_IMAGE::m_Iterpolation, GERBER_DRAW_ITEM::m_Polygon, GERBER_FILE_IMAGE::m_PolygonFillMode, GERBER_FILE_IMAGE::m_PolygonFillModeState, GERBER_FILE_IMAGE::m_Relative, GERBER_FILE_IMAGE::ReadXCommandID(), GERBER_FILE_IMAGE::StepAndRepeatItem(), text, TOOLS_MAX_COUNT, and SHAPE_POLY_SET::VertexCount().

Referenced by GERBER_FILE_IMAGE::LoadGerberFile().

◆ Execute_HEADER_And_M_Command()

bool EXCELLON_IMAGE::Execute_HEADER_And_M_Command ( char *&  text)
private

Definition at line 553 of file excellon_read_drill_file.cpp.

554{
555 EXCELLON_CMD* cmd = nullptr;
556 wxString msg;
557
558 // Search command in list
559 for( unsigned ii = 0; ; ii++ )
560 {
561 EXCELLON_CMD* candidate = &excellonHeaderCmdList[ii];
562 int len = candidate->m_Name.size();
563
564 if( len == 0 ) // End of list reached
565 break;
566
567 if( candidate->m_Name.compare( 0, len, text, len ) == 0 ) // found.
568 {
569 cmd = candidate;
570 text += len;
571 break;
572 }
573 }
574
575 if( !cmd )
576 {
577 msg.Printf( _( "Unknown Excellon command &lt;%s&gt;" ), text );
578 AddMessageToList( msg );
579 while( *text )
580 text++;
581
582 return false;
583 }
584
585 // Execute command
586 // some do nothing
587 switch( cmd->m_Code )
588 {
589 case DRILL_SKIP:
590 case DRILL_M_UNKNOWN:
591 break;
592
593 case DRILL_M_END:
594 case DRILL_M_ENDFILE:
595 // if a route command is in progress, finish it
596 if( m_RouteModeOn )
598
599 break;
600
601 case DRILL_M_MESSAGE:
602 break;
603
605 break;
606
607 case DRILL_M_HEADER:
609 break;
610
613 break;
614
615 case DRILL_REWIND_STOP: // End of header. No action in a viewer
617 break;
618
621 break;
622
624 break;
625
626 case DRILL_M_METRIC:
627 SelectUnits( true, nullptr );
628 break;
629
630 case DRILL_IMPERIAL_HEADER: // command like INCH,TZ or INCH,LZ
631 case DRILL_METRIC_HEADER: // command like METRIC,TZ or METRIC,LZ
632 SelectUnits( cmd->m_Code == DRILL_METRIC_HEADER ? true : false, nullptr );
633
634 if( *text != ',' )
635 {
636 // No TZ or LZ specified. Should be a decimal format
637 // but this is not always the case. Use our default setting
638 break;
639 }
640
641 text++; // skip separator
642 if( *text == 'T' )
643 m_NoTrailingZeros = false;
644 else
645 m_NoTrailingZeros = true;
646 break;
647
649 break;
650
652 break;
653
655 break;
656
657 case DRILL_M_TIPCHECK:
658 break;
659
661 break;
662
664 if( *text != ',' )
665 {
666 AddMessageToList( wxT( "ICI command has no parameter" ) );
667 break;
668 }
669 text++; // skip separator
670 // Parameter should be ON or OFF
671 if( strncasecmp( text, "OFF", 3 ) == 0 )
672 m_Relative = false;
673 else if( strncasecmp( text, "ON", 2 ) == 0 )
674 m_Relative = true;
675 else
676 AddMessageToList( wxT( "ICI command has incorrect parameter" ) );
677 break;
678
680 break;
681
683 break;
684
686 break;
687
688 case DRILL_RESET_CMD:
689 break;
690
692 break;
693
694 case DRILL_FMT:
695 break;
696
699 break;
700
701 case DRILL_M_TOOL_DOWN: // tool down (starting a routed hole or polyline)
702 // Only the last position is useful:
703 if( m_RoutePositions.size() > 1 )
704 m_RoutePositions.erase( m_RoutePositions.begin(), m_RoutePositions.begin() + m_RoutePositions.size() - 1 );
705
706 break;
707
708 case DRILL_M_TOOL_UP: // tool up (ending a routed polyline)
710 break;
711 }
712
713 while( *text )
714 text++;
715
716 return true;
717}
void readFileFormat(char *&aText)
Read an Altium-specific FILE_FORMAT=X:X attribute that specifies the length and mantissa of the numbe...
bool readToolInformation(char *&aText)
Read a tool definition like T1C0.02 or T1F00S00C0.02 or T1C0.02F00S00 and enter params in TCODE list.
void SelectUnits(bool aMetric, EXCELLON_DEFAULTS *aDefaults)
Switch unit selection, and the coordinate format (nn:mm) if not yet set.
bool m_NoTrailingZeros
true: remove tailing zeros.
@ DRILL_M_UNKNOWN
@ DRILL_M_TOOL_UP
@ DRILL_SKIP
@ DRILL_M_ENDPATTERN
@ DRILL_M_TOOL_DOWN
@ DRILL_AUTOMATIC_SPEED
@ DRILL_M_END
@ DRILL_TOOL_CHANGE_STOP
@ DRILL_TOOL_INFORMATION
@ DRILL_AUTOMATIC_TOOL_CHANGE
@ DRILL_M_ENDHEADER
@ DRILL_M_HEADER
@ DRILL_FORMAT_ALTIUM
@ DRILL_M_METRIC
@ DRILL_DETECT_BROKEN
@ DRILL_HEADER_SKIP
@ DRILL_REWIND_STOP
@ DRILL_M_TIPCHECK
@ DRILL_M_LONGMESSAGE
@ DRILL_INCREMENTALHEADER
@ DRILL_AXIS_VERSION
@ DRILL_RESET_CMD
@ DRILL_M_MESSAGE
@ DRILL_METRIC_HEADER
@ DRILL_M_BEGINPATTERN
@ DRILL_IMPERIAL_HEADER
@ DRILL_M_ENDFILE
@ DRILL_FMT
@ DRILL_M_CANNEDTEXT
static EXCELLON_CMD excellonHeaderCmdList[]

References _, GERBER_FILE_IMAGE::AddMessageToList(), DRILL_AUTOMATIC_SPEED, DRILL_AUTOMATIC_TOOL_CHANGE, DRILL_AXIS_VERSION, DRILL_DETECT_BROKEN, DRILL_FMT, DRILL_FORMAT_ALTIUM, DRILL_HEADER_SKIP, DRILL_IMPERIAL_HEADER, DRILL_INCREMENTALHEADER, DRILL_M_BEGINPATTERN, DRILL_M_CANNEDTEXT, DRILL_M_END, DRILL_M_ENDFILE, DRILL_M_ENDHEADER, DRILL_M_ENDPATTERN, DRILL_M_HEADER, DRILL_M_LONGMESSAGE, DRILL_M_MESSAGE, DRILL_M_METRIC, DRILL_M_TIPCHECK, DRILL_M_TOOL_DOWN, DRILL_M_TOOL_UP, DRILL_M_UNKNOWN, DRILL_METRIC_HEADER, DRILL_RESET_CMD, DRILL_REWIND_STOP, DRILL_SKIP, DRILL_TOOL_CHANGE_STOP, DRILL_TOOL_INFORMATION, excellonHeaderCmdList, FinishRouteCommand(), EXCELLON_CMD::m_Code, EXCELLON_CMD::m_Name, GERBER_FILE_IMAGE::m_NoTrailingZeros, GERBER_FILE_IMAGE::m_Relative, m_RouteModeOn, m_RoutePositions, m_State, READ_HEADER_STATE, READ_PROGRAM_STATE, readFileFormat(), readToolInformation(), SelectUnits(), and text.

Referenced by LoadFile().

◆ ExecuteRS274XCommand()

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

Execute 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 = gerbIUScale.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
266 if( (seq_char >= '0') && (seq_char <= '9') )
267 seq_len = seq_char - '0';
268
269 break;
270
271 case 'M': // Sequence code (followed by one digit: the sequence len)
272 // (sometimes found after the X,Y sequence)
273 // Obscure option
274 aText++;
275 code = *aText;
276
277 if( ( code >= '0' ) && ( code <= '9' ) )
278 aText++; // skip the digit
279
280 break;
281
282 case 'X':
283 case 'Y':
284 {
285 code = *(aText++);
286 char ctmp = *(aText++) - '0';
287
288 if( code == 'X' )
289 {
290 x_fmt_known = true;
291 // number of digits after the decimal point (0 to 7 allowed)
292 m_FmtScale.x = *aText - '0';
293 m_FmtLen.x = ctmp + m_FmtScale.x;
294
295 // m_FmtScale is 0 to 7
296 // (Old Gerber specification was 0 to 6)
297 if( m_FmtScale.x < 0 )
298 m_FmtScale.x = 0;
299
300 if( m_FmtScale.x > 7 )
301 m_FmtScale.x = 7;
302 }
303 else
304 {
305 y_fmt_known = true;
306 m_FmtScale.y = *aText - '0';
307 m_FmtLen.y = ctmp + m_FmtScale.y;
308
309 if( m_FmtScale.y < 0 )
310 m_FmtScale.y = 0;
311
312 if( m_FmtScale.y > 7 )
313 m_FmtScale.y = 7;
314 }
315
316 aText++;
317 }
318 break;
319
320 case '*':
321 break;
322
323 default:
324 msg.Printf( wxT( "Unknown id (%c) in FS command" ),
325 *aText );
326 AddMessageToList( msg );
327 GetEndOfBlock( aBuff, aBuffSize, aText, m_Current_File );
328 ok = false;
329 break;
330 }
331 }
332
333 if( !x_fmt_known || !y_fmt_known )
334 AddMessageToList( wxT( "RS274X: Format Statement (FS) without X or Y format" ) );
335
336 break;
337
338 case AXIS_SELECT: // command ASAXBY*% or %ASAYBX*%
339 m_SwapAxis = false;
340
341 if( strncasecmp( aText, "AYBX", 4 ) == 0 )
342 m_SwapAxis = true;
343
344 break;
345
346 case MIRROR_IMAGE: // command %MIA0B0*%, %MIA0B1*%, %MIA1B0*%, %MIA1B1*%
347 m_MirrorA = m_MirrorB = false;
348
349 while( *aText && *aText != '*' )
350 {
351 switch( *aText )
352 {
353 case 'A': // Mirror A axis ?
354 aText++;
355
356 if( *aText == '1' )
357 m_MirrorA = true;
358
359 break;
360
361 case 'B': // Mirror B axis ?
362 aText++;
363
364 if( *aText == '1' )
365 m_MirrorB = true;
366
367 break;
368
369 default:
370 aText++;
371 break;
372 }
373 }
374 break;
375
376 case MODE_OF_UNITS:
377 code = ReadXCommandID( aText );
378
379 if( code == INCH )
380 m_GerbMetric = false;
381 else if( code == MILLIMETER )
382 m_GerbMetric = true;
383
385 break;
386
387 case FILE_ATTRIBUTE: // Command %TF ...
388 {
390 dummy.ParseAttribCmd( m_Current_File, aBuff, aBuffSize, aText, m_LineNum );
391
392 if( dummy.IsFileFunction() )
393 {
394 delete m_FileFunction;
396
397 // Don't set this until we get a file function; other code expects m_IsX2_file == true
398 // to mean that we have a valid m_FileFunction
399 m_IsX2_file = true;
400 }
401 else if( dummy.IsFileMD5() )
402 {
403 m_MD5_value = dummy.GetPrm( 1 );
404 }
405 else if( dummy.IsFilePart() )
406 {
407 m_PartString = dummy.GetPrm( 1 );
408 }
409 }
410 break;
411
412 case APERTURE_ATTRIBUTE: // Command %TA
413 {
415 dummy.ParseAttribCmd( m_Current_File, aBuff, aBuffSize, aText, m_LineNum );
416
417 if( dummy.GetAttribute() == wxT( ".AperFunction" ) )
418 {
419 m_AperFunction = dummy.GetPrm( 1 );
420
421 // A few function values can have other parameters. Add them
422 for( int ii = 2; ii < dummy.GetPrmCount(); ii++ )
423 m_AperFunction << wxT( "," ) << dummy.GetPrm( ii );
424 }
425 }
426 break;
427
428 case NET_ATTRIBUTE: // Command %TO currently %TO.P %TO.N and %TO.C
429 {
431
432 dummy.ParseAttribCmd( m_Current_File, aBuff, aBuffSize, aText, m_LineNum );
433
434 if( dummy.GetAttribute() == wxT( ".N" ) )
435 {
438 }
439 else if( dummy.GetAttribute() == wxT( ".C" ) )
440 {
443 }
444 else if( dummy.GetAttribute() == wxT( ".P" ) )
445 {
449
450 if( dummy.GetPrmCount() > 3 )
451 {
453 FormatStringFromGerber( dummy.GetPrm( 3 ) ), true, true );
454 }
455 else
456 {
458 }
459 }
460 }
461 break;
462
463 case REMOVE_APERTURE_ATTRIBUTE: // Command %TD ...
464 {
466 dummy.ParseAttribCmd( m_Current_File, aBuff, aBuffSize, aText, m_LineNum );
468 }
469 break;
470
471 case OFFSET: // command: OFAnnBnn (nn = float number) = layer Offset
472 m_Offset.x = m_Offset.y = 0;
473 while( *aText != '*' )
474 {
475 switch( *aText )
476 {
477 case 'A': // A axis offset in current unit (inch or mm)
478 aText++;
479 fcoord = ReadDouble( aText );
480 m_Offset.x = KiROUND( fcoord * conv_scale );
481 break;
482
483 case 'B': // B axis offset in current unit (inch or mm)
484 aText++;
485 fcoord = ReadDouble( aText );
486 m_Offset.y = KiROUND( fcoord * conv_scale );
487 break;
488 }
489 }
490 break;
491
492 case SCALE_FACTOR:
493 m_Scale.x = m_Scale.y = 1.0;
494 while( *aText != '*' )
495 {
496 switch( *aText )
497 {
498 case 'A': // A axis scale
499 aText++;
500 m_Scale.x = ReadDouble( aText );
501 break;
502
503 case 'B': // B axis scale
504 aText++;
505 m_Scale.y = ReadDouble( aText );
506 break;
507 }
508 }
509 break;
510
511 case IMAGE_OFFSET: // command: IOAnnBnn (nn = float number) = Image Offset
513 while( *aText != '*' )
514 {
515 switch( *aText )
516 {
517 case 'A': // A axis offset in current unit (inch or mm)
518 aText++;
519 fcoord = ReadDouble( aText );
520 m_ImageOffset.x = KiROUND( fcoord * conv_scale );
521 break;
522
523 case 'B': // B axis offset in current unit (inch or mm)
524 aText++;
525 fcoord = ReadDouble( aText );
526 m_ImageOffset.y = KiROUND( fcoord * conv_scale );
527 break;
528 }
529 }
530 break;
531
532 case IMAGE_ROTATION: // command IR0* or IR90* or IR180* or IR270*
533 if( strncasecmp( aText, "0*", 2 ) == 0 )
534 m_ImageRotation = 0;
535 else if( strncasecmp( aText, "90*", 3 ) == 0 )
536 m_ImageRotation = 90;
537 else if( strncasecmp( aText, "180*", 4 ) == 0 )
538 m_ImageRotation = 180;
539 else if( strncasecmp( aText, "270*", 4 ) == 0 )
540 m_ImageRotation = 270;
541 else
542 AddMessageToList( _( "RS274X: Command \"IR\" rotation value not allowed" ) );
543
544 break;
545
546 case STEP_AND_REPEAT: // command SR, like %SRX3Y2I5.0J2*%
547 m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Start a new Gerber layer
549 GetLayerParams().m_StepForRepeat.x = 0.0; // offset for Step and Repeat command
551 GetLayerParams().m_YRepeatCount = 1; // The repeat count
553
554 while( *aText && *aText != '*' )
555 {
556 switch( *aText )
557 {
558 case 'I': // X axis offset
559 aText++;
561 break;
562
563 case 'J': // Y axis offset
564 aText++;
566 break;
567
568 case 'X': // X axis repeat count
569 aText++;
571 break;
572
573 case 'Y': // Y axis offset
574 aText++;
576 break;
577
578 default:
579 aText++;
580 break;
581 }
582 }
583 break;
584
585 case IMAGE_JUSTIFY: // Command IJAnBn*
586 m_ImageJustifyXCenter = false; // Image Justify Center on X axis (default = false)
587 m_ImageJustifyYCenter = false; // Image Justify Center on Y axis (default = false)
588 m_ImageJustifyOffset = VECTOR2I( 0, 0 ); // Image Justify Offset on XY axis (default = 0,0)
589 while( *aText && *aText != '*' )
590 {
591 // IJ command is (for A or B axis) AC or AL or A<coordinate>
592 switch( *aText )
593 {
594 case 'A': // A axis justify
595 aText++;
596
597 if( *aText == 'C' )
598 {
600 aText++;
601 }
602 else if( *aText == 'L' )
603 {
605 aText++;
606 }
607 else
608 {
609 m_ImageJustifyOffset.x = KiROUND( ReadDouble( aText ) * conv_scale);
610 }
611
612 break;
613
614 case 'B': // B axis justify
615 aText++;
616
617 if( *aText == 'C' )
618 {
620 aText++;
621 }
622 else if( *aText == 'L' )
623 {
625 aText++;
626 }
627 else
628 {
629 m_ImageJustifyOffset.y = KiROUND( ReadDouble( aText ) * conv_scale);
630 }
631
632 break;
633
634 default:
635 aText++;
636 break;
637 }
638 }
639
642
645
646 break;
647
648 case KNOCKOUT:
649 m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Start a new Gerber layer
650 msg = _( "RS274X: Command KNOCKOUT ignored by GerbView" ) ;
651 AddMessageToList( msg );
652 break;
653
654 case ROTATE: // Layer rotation: command like %RO45*%
655 m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Start a new Gerber layer
656 m_LocalRotation = ReadDouble( aText ); // Store layer rotation in degrees
657 break;
658
659 case IMAGE_NAME:
660 m_ImageName.Empty();
661
662 while( *aText != '*' )
663 m_ImageName.Append( *aText++ );
664
665 break;
666
667 case LOAD_NAME:
668 // %LN is a (deprecated) equivalentto G04: a comment
669 while( *aText && *aText != '*' )
670 aText++; // Skip text
671
672 break;
673
674 case IMAGE_POLARITY:
675 if( strncasecmp( aText, "NEG", 3 ) == 0 )
676 m_ImageNegative = true;
677 else
678 m_ImageNegative = false;
679
680 break;
681
682 case LOAD_POLARITY:
683 if( *aText == 'C' )
685 else
687
688 break;
689
690 case AP_MACRO: // lines like %AMMYMACRO*
691 // 5,1,8,0,0,1.08239X$1,22.5*
692 // %
693 /*ok = */ReadApertureMacro( aBuff, aBuffSize, aText, m_Current_File );
694 break;
695
696 case AP_DEFINITION:
697 /* input example: %ADD30R,0.081800X0.101500*%
698 * Aperture definition has 4 options: C, R, O, P
699 * (Circle, Rect, Oval, regular Polygon)
700 * and shapes can have a hole (round or rectangular).
701 * All optional parameters values start by X
702 * at this point, text points to 2nd 'D'
703 */
704 if( *aText++ != 'D' )
705 {
706 ok = false;
707 break;
708 }
709
710 m_Has_DCode = true;
711
712 code = ReadInt( aText );
713
714 D_CODE* dcode;
715 dcode = GetDCODEOrCreate( code );
716
717 if( dcode == nullptr )
718 break;
719
721
722 // at this point, text points to character after the ADD<num>,
723 // i.e. R in example above. If aText[0] is one of the usual
724 // apertures: (C,R,O,P), there is a comma after it.
725 if( aText[1] == ',' )
726 {
727 char stdAperture = *aText;
728
729 aText += 2; // skip "C," for example
730
731 // First parameter is the size X:
732 dcode->m_Size.x = KiROUND( ReadDouble( aText ) * conv_scale );
733 dcode->m_Size.y = dcode->m_Size.x;
734
735 switch( stdAperture ) // Aperture desceiption has optional parameters. Read them
736 {
737 case 'C': // Circle
738 dcode->m_Shape = APT_CIRCLE;
739 while( *aText == ' ' )
740 aText++;
741
742 if( *aText == 'X' )
743 {
744 aText++;
745 dcode->m_Drill.x = dcode->m_Drill.y =
746 KiROUND( ReadDouble( aText ) * conv_scale );
748 }
749
750 while( *aText == ' ' )
751 aText++;
752
753 if( *aText == 'X' )
754 {
755 aText++;
756 dcode->m_Drill.y =
757 KiROUND( ReadDouble( aText ) * conv_scale );
758
760 }
761 dcode->m_Defined = true;
762 break;
763
764 case 'O': // oval
765 case 'R': // rect
766 dcode->m_Shape = (stdAperture == 'O') ? APT_OVAL : APT_RECT;
767
768 while( *aText == ' ' )
769 aText++;
770
771 if( *aText == 'X' ) // Second parameter: size Y
772 {
773 aText++;
774 dcode->m_Size.y =
775 KiROUND( ReadDouble( aText ) * conv_scale );
776 }
777
778 while( *aText == ' ' )
779 aText++;
780
781 if( *aText == 'X' ) // third parameter: drill size (or drill size X)
782 {
783 aText++;
784 dcode->m_Drill.x = KiROUND( ReadDouble( aText ) * conv_scale );
785 dcode->m_Drill.y = dcode->m_Drill.x;
787 }
788
789 while( *aText == ' ' )
790 aText++;
791
792 if( *aText == 'X' ) // fourth parameter: drill size Y
793 {
794 aText++;
795 dcode->m_Drill.y =
796 KiROUND( ReadDouble( aText ) * conv_scale );
798 }
799
800 dcode->m_Defined = true;
801 break;
802
803 case 'P':
804
805 /* Regular polygon: a command line like %ADD12P,0.040X10X25X0.025X0.025X0.0150*%
806 * params are: <diameter>, X<edge count>, X<Rotation>, X<X hole dim>, X<Y hole dim>
807 */
808 dcode->m_Shape = APT_POLYGON;
809 while( *aText == ' ' )
810 aText++;
811
812 if( *aText == 'X' )
813 {
814 aText++;
815 dcode->m_EdgesCount = ReadInt( aText );
816 }
817
818 while( *aText == ' ' )
819 aText++;
820
821 if( *aText == 'X' )
822 {
823 aText++;
824 dcode->m_Rotation = EDA_ANGLE( ReadDouble( aText ), DEGREES_T );
825 }
826
827 while( *aText == ' ' )
828 aText++;
829
830 if( *aText == 'X' )
831 {
832 aText++;
833 dcode->m_Drill.x = KiROUND( ReadDouble( aText ) * conv_scale );
834 dcode->m_Drill.y = dcode->m_Drill.x;
836 }
837
838 while( *aText == ' ' )
839 aText++;
840
841 if( *aText == 'X' )
842 {
843 aText++;
844 dcode->m_Drill.y = KiROUND( ReadDouble( aText ) * conv_scale );
846 }
847 dcode->m_Defined = true;
848 break;
849 }
850 }
851 else // aText[0] starts an aperture macro name
852 {
853 APERTURE_MACRO am_lookup;
854
855 while( *aText && *aText != '*' && *aText != ',' )
856 am_lookup.m_AmName.Append( *aText++ );
857
858 // When an aperture definition is like %AMLINE2* 22,1,$1,$2,0,0,-45*
859 // the ADDxx<MACRO_NAME> command has parameters, like %ADD14LINE2,0.8X0.5*%
860 if( *aText == ',' )
861 { // Read aperture macro parameters and store them
862 aText++; // aText points the first parameter
863
864 while( *aText && *aText != '*' )
865 {
866 double param = ReadDouble( aText );
867 dcode->AppendParam( param );
868
869 if( !( isspace( *aText ) || *aText == 'X' || *aText == 'x' || *aText == '*' ) )
870 {
871 msg.Printf( wxT( "RS274X: aperture macro %s has invalid template "
872 "parameters\n" ),
873 TO_UTF8( am_lookup.m_AmName ) );
874 AddMessageToList( msg );
875 ok = false;
876 break;
877 }
878
879 while( isspace( *aText ) )
880 aText++;
881
882 // Skip 'X' separator:
883 if( *aText == 'X' || *aText == 'x' )
884 aText++;
885 }
886 }
887
888 // lookup the aperture macro here.
889 APERTURE_MACRO* pam = FindApertureMacro( am_lookup );
890
891 if( !pam )
892 {
893 msg.Printf( wxT( "RS274X: aperture macro %s not found\n" ),
894 TO_UTF8( am_lookup.m_AmName ) );
895 AddMessageToList( msg );
896 ok = false;
897 break;
898 }
899
900 dcode->m_Shape = APT_MACRO;
901 dcode->SetMacro( pam );
902 dcode->m_Defined = true;
903 }
904
905 break;
906
907 default:
908 ok = false;
909 break;
910 }
911
912 ignore_unused( seq_len );
913
914 ok = GetEndOfBlock( aBuff, aBuffSize, aText, m_Current_File );
915
916 return ok;
917}
constexpr EDA_IU_SCALE gerbIUScale
Definition: base_units.h:108
Support the "aperture macro" defined within standard RS274X.
wxString m_AmName
The name of the aperture macro as defined like AMVB_RECTANGLE* (name is VB_RECTANGLE)
wxString m_AperFunction
the aperture attribute (created by a TA.AperFunction command).
Definition: dcode.h:201
EDA_ANGLE m_Rotation
shape rotation
Definition: dcode.h:195
void SetMacro(APERTURE_MACRO *aMacro)
Definition: dcode.h:119
wxSize m_Drill
dimension of the hole (if any) (drill file)
Definition: dcode.h:192
int m_EdgesCount
in aperture definition Polygon only: number of edges for the polygon
Definition: dcode.h:196
bool m_Defined
false if the aperture is not defined in the header
Definition: dcode.h:200
APERTURE_DEF_HOLETYPE m_DrillShape
shape of the hole (0 = no hole, round = 1, rect = 2).
Definition: dcode.h:193
void AppendParam(double aValue)
Add a parameter to the D_CODE parameter list.
Definition: dcode.h:91
void SetField(const wxString &aField, bool aUseUTF8, bool aEscapeString)
int m_NetAttribType
the type of net info (used to define the gerber string to create)
wxString m_Cmpref
the component reference parent of the data
@ GBR_NETINFO_NET
print info associated to a net (TO.N attribute)
@ GBR_NETINFO_CMP
print info associated to a component (TO.C attribute)
@ GBR_NETINFO_PAD
print info associated to a flashed pad (TO.P attribute)
GBR_DATA_FIELD m_PadPinFunction
for a pad: the pin function (defined in schematic)
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)
Look up a previously read in aperture macro.
X2_ATTRIBUTE_FILEFUNCTION * m_FileFunction
file function parameters, found in a TF command or a G04
void RemoveAttribute(X2_ATTRIBUTE &aAttribute)
Called when a TD command is found the Gerber file.
bool m_SwapAxis
false if A = X and B = Y (default); true if A = Y, B = X
double m_LocalRotation
Local rotation added to m_ImageRotation.
wxSize m_FmtScale
Fmt 2.3: m_FmtScale = 3, fmt 3.4: m_FmtScale = 4.
wxString m_FileName
Full File Name for this layer.
int m_LineNum
Line number of the gerber file while reading.
wxString m_MD5_value
MD5 value found in a TF.MD5 command.
bool m_MirrorB
true: mirror / axis B (Y)
wxString m_PartString
string found in a TF.Part command
VECTOR2I m_ImageOffset
Coord Offset, from IO command.
bool m_Has_DCode
< True if has DCodes in file or false if no DCodes found. Perhaps deprecated RS274D file.
bool GetEndOfBlock(char *aBuff, unsigned int aBuffSize, char *&aText, FILE *aGerberFile)
Definition: rs274x.cpp:920
bool ReadApertureMacro(char *aBuff, unsigned int aBuffSize, char *&text, FILE *gerber_file)
Read in an aperture macro and saves it in m_aperture_macros.
Definition: rs274x.cpp:974
D_CODE * GetDCODEOrCreate(int aDCODE, bool aCreateIfNoExist=true)
Return a pointer to the D_CODE within this GERBER for the given aDCODE.
wxSize m_FmtLen
Nb chars per coord. ex fmt 2.3, m_FmtLen = 5.
bool m_MirrorA
true: mirror / axis A (X)
VECTOR2I m_Scale
scale (X and Y) of layer.
wxRealPoint m_StepForRepeat
bool m_StepForRepeatMetric
X2_ATTRIBUTE_FILEFUNCTION ( from TF.FileFunction in Gerber file) Example file function: TF....
The attribute value consists of a number of substrings separated by a comma.
@ APT_DEF_ROUND_HOLE
Definition: dcode.h:62
@ APT_DEF_RECT_HOLE
Definition: dcode.h:63
@ APT_RECT
Definition: dcode.h:50
@ APT_OVAL
Definition: dcode.h:51
@ APT_POLYGON
Definition: dcode.h:52
@ APT_MACRO
Definition: dcode.h:54
@ DEGREES_T
Definition: eda_angle.h:31
wxString FormatStringFromGerber(const wxString &aString)
Convert a gerber string into a 16 bit Unicode string.
void ignore_unused(const T &)
Definition: ignore.h:24
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
@ FILE_ATTRIBUTE
Definition: rs274x.cpp:87
@ IMAGE_JUSTIFY
Definition: rs274x.cpp:71
@ APERTURE_ATTRIBUTE
Definition: rs274x.cpp:95
@ FORMAT_STATEMENT
Definition: rs274x.cpp:61
@ NET_ATTRIBUTE
Definition: rs274x.cpp:92
@ IMAGE_OFFSET
Definition: rs274x.cpp:73
@ ROTATE
Definition: rs274x.cpp:109
@ STEP_AND_REPEAT
Definition: rs274x.cpp:108
@ LOAD_NAME
Definition: rs274x.cpp:112
@ REMOVE_APERTURE_ATTRIBUTE
Definition: rs274x.cpp:101
@ KNOCKOUT
Definition: rs274x.cpp:107
@ AP_MACRO
Definition: rs274x.cpp:80
@ MIRROR_IMAGE
Definition: rs274x.cpp:62
@ MODE_OF_UNITS
Definition: rs274x.cpp:63
@ INCH
Definition: rs274x.cpp:64
@ IMAGE_NAME
Definition: rs274x.cpp:72
@ OFFSET
Definition: rs274x.cpp:66
@ MILLIMETER
Definition: rs274x.cpp:65
@ AXIS_SELECT
Definition: rs274x.cpp:60
@ SCALE_FACTOR
Definition: rs274x.cpp:67
@ IMAGE_ROTATION
Definition: rs274x.cpp:75
@ LOAD_POLARITY
Definition: rs274x.cpp:111
@ IMAGE_POLARITY
Definition: rs274x.cpp:74
@ AP_DEFINITION
Definition: rs274x.cpp:79
int ReadInt(char *&text, bool aSkipSeparator=true)
Read an integer from an ASCII character buffer.
double ReadDouble(char *&text, bool aSkipSeparator=true)
Read a double precision floating point number from an ASCII character buffer.
std::vector< FAB_LAYER_COLOR > dummy
const double IU_PER_MILS
Definition: base_units.h:78
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:85

References _, GERBER_FILE_IMAGE::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(), DEGREES_T, dummy, FILE_ATTRIBUTE, GERBER_FILE_IMAGE::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, gerbIUScale, GERBER_FILE_IMAGE::GetDCODEOrCreate(), GERBER_FILE_IMAGE::GetEndOfBlock(), GERBER_FILE_IMAGE::GetLayerParams(), ignore_unused(), IMAGE_JUSTIFY, IMAGE_NAME, IMAGE_OFFSET, IMAGE_POLARITY, IMAGE_ROTATION, INCH, EDA_IU_SCALE::IU_PER_MILS, KI_FALLTHROUGH, KiROUND(), KNOCKOUT, LOAD_NAME, LOAD_POLARITY, APERTURE_MACRO::m_AmName, D_CODE::m_AperFunction, GERBER_FILE_IMAGE::m_AperFunction, GBR_NETLIST_METADATA::m_Cmpref, GERBER_FILE_IMAGE::m_Current_File, D_CODE::m_Defined, D_CODE::m_Drill, D_CODE::m_DrillShape, D_CODE::m_EdgesCount, GERBER_FILE_IMAGE::m_FileFunction, GERBER_FILE_IMAGE::m_FileName, GERBER_FILE_IMAGE::m_FmtLen, GERBER_FILE_IMAGE::m_FmtScale, GERBER_FILE_IMAGE::m_GerbMetric, GERBER_FILE_IMAGE::m_Has_DCode, GERBER_FILE_IMAGE::m_ImageJustifyOffset, GERBER_FILE_IMAGE::m_ImageJustifyXCenter, GERBER_FILE_IMAGE::m_ImageJustifyYCenter, GERBER_FILE_IMAGE::m_ImageName, GERBER_FILE_IMAGE::m_ImageNegative, GERBER_FILE_IMAGE::m_ImageOffset, GERBER_FILE_IMAGE::m_ImageRotation, GERBER_FILE_IMAGE::m_IsX2_file, GERBER_FILE_IMAGE::m_Iterpolation, GERBER_LAYER::m_LayerNegative, GERBER_FILE_IMAGE::m_LineNum, GERBER_FILE_IMAGE::m_LocalRotation, GERBER_FILE_IMAGE::m_MD5_value, GERBER_FILE_IMAGE::m_MirrorA, GERBER_FILE_IMAGE::m_MirrorB, GBR_NETLIST_METADATA::m_NetAttribType, GERBER_FILE_IMAGE::m_NetAttributeDict, GBR_NETLIST_METADATA::m_Netname, GERBER_FILE_IMAGE::m_NoTrailingZeros, GERBER_FILE_IMAGE::m_Offset, GBR_NETLIST_METADATA::m_Padname, GBR_NETLIST_METADATA::m_PadPinFunction, GERBER_FILE_IMAGE::m_PartString, GERBER_FILE_IMAGE::m_Relative, D_CODE::m_Rotation, GERBER_FILE_IMAGE::m_Scale, D_CODE::m_Shape, D_CODE::m_Size, GERBER_LAYER::m_StepForRepeat, GERBER_LAYER::m_StepForRepeatMetric, GERBER_FILE_IMAGE::m_SwapAxis, GERBER_LAYER::m_XRepeatCount, GERBER_LAYER::m_YRepeatCount, MILLIMETER, MIRROR_IMAGE, MODE_OF_UNITS, NET_ATTRIBUTE, OFFSET, GERBER_FILE_IMAGE::ReadApertureMacro(), ReadDouble(), ReadInt(), GERBER_FILE_IMAGE::ReadXCommandID(), REMOVE_APERTURE_ATTRIBUTE, GERBER_FILE_IMAGE::RemoveAttribute(), ROTATE, SCALE_FACTOR, GBR_DATA_FIELD::SetField(), D_CODE::SetMacro(), STEP_AND_REPEAT, TO_UTF8, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by GERBER_FILE_IMAGE::Execute_G_Command(), and GERBER_FILE_IMAGE::ReadRS274XCommand().

◆ FindApertureMacro()

APERTURE_MACRO * GERBER_FILE_IMAGE::FindApertureMacro ( const APERTURE_MACRO aLookup)
inherited

Look up a previously read in aperture macro.

Parameters
aLookupA dummy APERTURE_MACRO with [only] the name field set.
Returns
the aperture macro with a matching name or NULL if not found.

Definition at line 143 of file gerber_file_image.cpp.

144{
145 APERTURE_MACRO_SET::iterator iter = m_aperture_macros.find( aLookup );
146
147 if( iter != m_aperture_macros.end() )
148 {
149 APERTURE_MACRO* pam = (APERTURE_MACRO*) &(*iter);
150 return pam;
151 }
152
153 return nullptr; // not found
154}
APERTURE_MACRO_SET m_aperture_macros

References GERBER_FILE_IMAGE::m_aperture_macros.

Referenced by GERBER_FILE_IMAGE::ExecuteRS274XCommand().

◆ FinishRouteCommand()

void EXCELLON_IMAGE::FinishRouteCommand ( )
private

End a route command started by M15 ot G01, G02 or G03 command.

Definition at line 1115 of file excellon_read_drill_file.cpp.

1116{
1117 // Ends a route command started by M15 ot G01, G02 or G03 command
1118 // if a route command is not in progress, do nothing
1119
1120 if( !m_RouteModeOn )
1121 return;
1122
1123 D_CODE* tool = GetDCODE( m_Current_Tool );
1124
1125 if( !tool )
1126 {
1127 AddMessageToList( wxString::Format( wxT( "Unknown tool code %d" ), m_Current_Tool ) );
1128 return;
1129 }
1130
1131 for( size_t ii = 1; ii < m_RoutePositions.size(); ii++ )
1132 {
1133 GERBER_DRAW_ITEM* gbritem = new GERBER_DRAW_ITEM( this );
1134
1135 if( m_RoutePositions[ii].m_rmode == 0 ) // linear routing
1136 {
1137 fillLineGBRITEM( gbritem, tool->m_Num_Dcode,
1138 m_RoutePositions[ii-1].GetPos(), m_RoutePositions[ii].GetPos(),
1139 tool->m_Size, false );
1140 }
1141 else // circular (cw or ccw) routing
1142 {
1143 bool rot_ccw = m_RoutePositions[ii].m_rmode == ROUTE_CW;
1144 int radius = m_RoutePositions[ii].m_radius; // Can be adjusted by computeCenter.
1145 VECTOR2I center;
1146
1147 if( m_RoutePositions[ii].m_arc_type_info == ARC_INFO_TYPE_CENTER )
1148 center = VECTOR2I( m_RoutePositions[ii].m_cx, m_RoutePositions[ii].m_cy );
1149 else
1150 center = computeCenter( m_RoutePositions[ii-1].GetPos(),
1151 m_RoutePositions[ii].GetPos(), radius, rot_ccw );
1152
1153 fillArcGBRITEM( gbritem, tool->m_Num_Dcode,
1154 m_RoutePositions[ii-1].GetPos(), m_RoutePositions[ii].GetPos(),
1155 center - m_RoutePositions[ii-1].GetPos(),
1156 tool->m_Size, not rot_ccw , true,
1157 false );
1158 }
1159
1160 AddItemToList( gbritem );
1161
1162 StepAndRepeatItem( *gbritem );
1163 }
1164
1165 m_RoutePositions.clear();
1166 m_RouteModeOn = false;
1167}
void fillArcGBRITEM(GERBER_DRAW_ITEM *aGbrItem, int Dcode_index, const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aRelCenter, wxSize aPenSize, bool aClockwise, bool aMultiquadrant, bool aLayerNegative)
Initialize a given GBRITEM so that it can draw an arc G code.
Definition: rs274d.cpp:202
static VECTOR2I computeCenter(VECTOR2I aStart, VECTOR2I aEnd, int &aRadius, bool aRotCCW)

References GERBER_FILE_IMAGE::AddItemToList(), GERBER_FILE_IMAGE::AddMessageToList(), ARC_INFO_TYPE_CENTER, computeCenter(), fillArcGBRITEM(), fillLineGBRITEM(), Format(), GERBER_FILE_IMAGE::GetDCODE(), GERBER_FILE_IMAGE::m_Current_Tool, D_CODE::m_Num_Dcode, m_RouteModeOn, m_RoutePositions, D_CODE::m_Size, ROUTE_CW, and GERBER_FILE_IMAGE::StepAndRepeatItem().

Referenced by Execute_EXCELLON_G_Command(), and Execute_HEADER_And_M_Command().

◆ Get() [1/3]

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

Definition at line 104 of file inspectable.h.

105 {
107 TYPE_ID thisType = TYPE_HASH( *this );
108 PROPERTY_BASE* prop = propMgr.GetProperty( thisType, aProperty );
109 std::optional<T> ret;
110
111 if( prop )
112 {
113 const void* object = propMgr.TypeCast( this, thisType, prop->OwnerHash() );
114
115 if( object )
116 ret = prop->get<T>( object );
117 }
118
119 return ret;
120 }
virtual size_t OwnerHash() const =0
Return type-id of the Owner class.
T get(const void *aObject) const
Definition: property.h:316
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:74
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:76
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Return a property for a specific type.
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Cast a type to another type.
#define TYPE_HASH(x)
Definition: property.h:62
size_t TYPE_ID
Unique type identifier.
Definition: property_mgr.h:46

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

◆ Get() [2/3]

wxAny INSPECTABLE::Get ( PROPERTY_BASE aProperty) const
inlineinherited

Definition at line 84 of file inspectable.h.

85 {
87 const void* object = propMgr.TypeCast( this, TYPE_HASH( *this ), aProperty->OwnerHash() );
88 return object ? aProperty->getter( object ) : wxAny();
89 }
virtual wxAny getter(const void *aObject) const =0

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

Referenced by BOOST_AUTO_TEST_CASE(), CLASS_D_DESC::CLASS_D_DESC(), EDA_SHAPE_DESC::EDA_SHAPE_DESC(), PROPERTIES_PANEL::getItemValue(), PCB_EXPR_VAR_REF::GetValue(), and PAD_DESC::PAD_DESC().

◆ Get() [3/3]

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

Definition at line 92 of file inspectable.h.

93 {
95 const void* object = propMgr.TypeCast( this, TYPE_HASH( *this ), aProperty->OwnerHash() );
96
97 if( !object )
98 throw std::runtime_error( "Could not cast INSPECTABLE to the requested type" );
99
100 return aProperty->get<T>( object );
101 }

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

◆ GetBoundingBox()

const BOX2I EDA_ITEM::GetBoundingBox ( ) const
virtualinherited

Return 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 LIB_FIELD, LIB_ITEM, LIB_PIN, LIB_SHAPE, LIB_SYMBOL, LIB_TEXT, SCH_BITMAP, SCH_BUS_ENTRY_BASE, SCH_FIELD, SCH_JUNCTION, SCH_LABEL_BASE, SCH_LINE, SCH_MARKER, SCH_NO_CONNECT, SCH_PIN, SCH_SHAPE, SCH_SHEET, SCH_SYMBOL, SCH_TEXT, GBR_LAYOUT, GERBER_DRAW_ITEM, DS_DRAW_ITEM_LINE, DS_DRAW_ITEM_POLYPOLYGONS, DS_DRAW_ITEM_RECT, DS_DRAW_ITEM_PAGE, DS_DRAW_ITEM_TEXT, DS_DRAW_ITEM_BITMAP, PCB_GROUP, BOARD, FOOTPRINT, FP_TEXT, NETINFO_ITEM, PAD, PCB_BITMAP, PCB_DIMENSION_BASE, PCB_DIM_CENTER, PCB_MARKER, PCB_SHAPE, PCB_TARGET, PCB_TEXT, PCB_TRACK, ZONE, and DS_DRAW_ITEM_BASE.

Definition at line 74 of file eda_item.cpp.

75{
76 // return a zero-sized box per default. derived classes should override
77 // this
78 return BOX2I( VECTOR2I( 0, 0 ), VECTOR2I( 0, 0 ) );
79}
BOX2< VECTOR2I > BOX2I
Definition: box2.h:847

Referenced by CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings(), CN_ITEM::BBox(), SCH_EDIT_TOOL::ChangeTextType(), TEST_BOARD_ITEM_FIXTURE::CompareItems(), TEST_EE_ITEM_FIXTURE::CompareItems(), EE_RTREE::contains(), BOARD_COMMIT::dirtyIntersectingZones(), KIGFX::SCH_PAINTER::draw(), KIGFX::PCB_PAINTER::Draw(), SCH_DRAWING_TOOLS::DrawSheet(), enclosedByAreaFunc(), PCB_SELECTION_TOOL::FindItem(), SCH_FIND_REPLACE_TOOL::FindNext(), LIB_ITEM::GetBoundingBox(), GetBoundingBoxes(), BOARD_ITEM::GetCenter(), SCH_MOVE_TOOL::getConnectedDragItems(), SCH_MOVE_TOOL::getConnectedItems(), EE_SELECTION_TOOL::GuessSelectionCandidates(), EE_RTREE::insert(), intersectsAreaFunc(), SCH_SCREEN::MarkConnections(), SCH_EDIT_TOOL::Mirror(), DRC_RTREE::QueryColliding(), EE_RTREE::remove(), SCH_EDIT_TOOL::Rotate(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZone(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones(), DRC_TEST_PROVIDER_SOLDER_MASK::testMaskBridges(), GERBVIEW_SELECTION::ViewBBox(), and EDA_ITEM::ViewBBox().

◆ GetClass()

wxString GERBER_FILE_IMAGE::GetClass ( ) const
inlineoverridevirtualinherited

Return the class name.

Implements EDA_ITEM.

Definition at line 113 of file gerber_file_image.h.

114 {
115 return wxT( "GERBER_FILE_IMAGE" );
116 }

◆ GetDCODE()

D_CODE * GERBER_FILE_IMAGE::GetDCODE ( int  aDCODE) const
inherited

Return 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
The D code implied by the given aDCODE or NULL if the requested aDCODE is out of range.

Definition at line 132 of file gerber_file_image.cpp.

133{
134 unsigned ndx = aDCODE - FIRST_DCODE;
135
136 if( ndx < (unsigned) arrayDim( m_Aperture_List ) )
137 return m_Aperture_List[ndx];
138
139 return nullptr;
140}
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition: arraydim.h:31
D_CODE * m_Aperture_List[TOOLS_MAX_COUNT]
< Dcode (Aperture) List for this layer (max TOOLS_MAX_COUNT: see dcode.h)

References arrayDim(), FIRST_DCODE, and GERBER_FILE_IMAGE::m_Aperture_List.

Referenced by GERBER_FILE_IMAGE::Execute_DCODE_Command(), Execute_Drill_Command(), GERBER_FILE_IMAGE::Execute_G_Command(), FinishRouteCommand(), GERBER_DRAW_ITEM::GetDcodeDescr(), Select_Tool(), GERBVIEW_INSPECTION_TOOL::ShowDCodes(), GERBVIEW_FRAME::updateAperAttributesSelectBox(), and GERBVIEW_FRAME::updateDCodeSelectBox().

◆ GetDCODEOrCreate()

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

Return 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
The one implied by the given aDCODE or NULL if the requested aDCODE is out of range.

Definition at line 112 of file gerber_file_image.cpp.

113{
114 unsigned ndx = aDCODE - FIRST_DCODE;
115
116 if( ndx < (unsigned) arrayDim( m_Aperture_List ) )
117 {
118 // lazily create the D_CODE if it does not exist.
119 if( aCreateIfNoExist )
120 {
121 if( m_Aperture_List[ndx] == nullptr )
122 m_Aperture_List[ndx] = new D_CODE( ndx + FIRST_DCODE );
123 }
124
125 return m_Aperture_List[ndx];
126 }
127
128 return nullptr;
129}

References arrayDim(), FIRST_DCODE, and GERBER_FILE_IMAGE::m_Aperture_List.

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

◆ GetDcodesCount()

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

Definition at line 251 of file gerber_file_image.cpp.

252{
253 int count = 0;
254
255 for( unsigned ii = 0; ii < arrayDim( m_Aperture_List ); ii++ )
256 {
257 if( m_Aperture_List[ii] )
258 {
259 if( m_Aperture_List[ii]->m_InUse || m_Aperture_List[ii]->m_Defined )
260 ++count;
261 }
262
263 }
264
265 return count;
266}
bool m_InUse
true if this image is currently in use (a file is loaded in it) false if it must be not drawn

References arrayDim(), GERBER_FILE_IMAGE::m_Aperture_List, and GERBER_FILE_IMAGE::m_InUse.

Referenced by GERBVIEW_INSPECTION_TOOL::ShowDCodes(), GERBVIEW_FRAME::updateAperAttributesSelectBox(), and GERBVIEW_FRAME::updateDCodeSelectBox().

◆ GetEditFlags()

EDA_ITEM_FLAGS EDA_ITEM::GetEditFlags ( ) const
inlineinherited

Definition at line 145 of file eda_item.h.

146 {
147 constexpr int mask =
149
150 return m_flags & mask;
151 }
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
#define IS_CHANGED
Item was edited, and modified.
#define IS_NEW
New item, just created.
#define IS_BROKEN
Is a segment just broken by BreakSegment.
#define STRUCT_DELETED
flag indication structures to be erased
#define IS_MOVING
Item being moved.

References IS_BROKEN, IS_CHANGED, IS_MOVING, IS_NEW, IS_PASTED, EDA_ITEM::m_flags, and STRUCT_DELETED.

Referenced by SCH_EDIT_TOOL::ChangeTextType(), EDA_ITEM::ClearEditFlags(), SCH_EDIT_FRAME::DeleteJunction(), SCH_EDIT_TOOL::editFieldText(), SYMBOL_EDITOR_PIN_TOOL::EditPinProperties(), SCH_EDITOR_CONTROL::EditWithSymbolEditor(), SCH_SYMBOL::GetMsgPanelInfo(), SELECTION_CONDITIONS::Idle(), SELECTION_CONDITIONS::IdleSelection(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PCB_POINT_EDITOR::OnSelectionChange(), SYMBOL_EDITOR_EDIT_TOOL::Properties(), SCH_EDIT_FRAME::SelectUnit(), DIALOG_IMAGE_PROPERTIES::TransferDataFromWindow(), DIALOG_LABEL_PROPERTIES::TransferDataFromWindow(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_DIMENSION_PROPERTIES::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow(), DIALOG_TARGET_PROPERTIES::TransferDataFromWindow(), and DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow().

◆ GetEndOfBlock()

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

Definition at line 920 of file rs274x.cpp.

921{
922 for( ; ; )
923 {
924 while( (aText < aBuff + aBuffSize) && *aText )
925 {
926 if( *aText == '*' )
927 return true;
928
929 if( *aText == '%' )
930 return true;
931
932 aText++;
933 }
934
935 if( fgets( aBuff, aBuffSize, gerber_file ) == nullptr )
936 break;
937
938 m_LineNum++;
939 aText = aBuff;
940 }
941
942 return false;
943}

References gerber_file, and GERBER_FILE_IMAGE::m_LineNum.

Referenced by GERBER_FILE_IMAGE::ExecuteRS274XCommand().

◆ GetFlags()

◆ GetFocusPosition()

virtual const VECTOR2I EDA_ITEM::GetFocusPosition ( ) const
inlinevirtualinherited

Similar to GetPosition, but allows items to return their visual center rather than their anchor.

Reimplemented in BOARD, PCB_SHAPE, and PCB_TRACK.

Definition at line 256 of file eda_item.h.

256{ return GetPosition(); }
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:249

References EDA_ITEM::GetPosition().

Referenced by SCH_EDIT_FRAME::FocusOnItem().

◆ GetFriendlyName()

wxString EDA_ITEM::GetFriendlyName ( ) const
virtualinherited

Reimplemented in PCB_SHAPE, PCB_TRACK, and ZONE.

Definition at line 310 of file eda_item.cpp.

311{
312 return GetTypeDesc();
313}
wxString GetTypeDesc() const
Return a translated description of the type for this EDA_ITEM for display in user facing messages.
Definition: eda_item.cpp:301

References EDA_ITEM::GetTypeDesc().

Referenced by PROPERTIES_PANEL::rebuildProperties().

◆ GetItemDescription()

wxString EDA_ITEM::GetItemDescription ( UNITS_PROVIDER aUnitsProvider) const
virtualinherited

Return a user-visible description string of this item.

This description is used in disambiguation menus, the message panel, ERC/DRC reports, etc.

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 LIB_FIELD, LIB_PIN, LIB_SHAPE, LIB_TEXT, LIB_TEXTBOX, SCH_BITMAP, SCH_BUS_WIRE_ENTRY, SCH_BUS_BUS_ENTRY, SCH_FIELD, SCH_JUNCTION, SCH_LABEL, SCH_DIRECTIVE_LABEL, SCH_GLOBALLABEL, SCH_HIERLABEL, SCH_LINE, SCH_MARKER, SCH_NO_CONNECT, SCH_PIN, SCH_SHAPE, SCH_SHEET, DELETED_SHEET_ITEM, SCH_SHEET_PIN, SCH_SYMBOL, SCH_TEXT, SCH_TEXTBOX, GERBER_DRAW_ITEM, DELETED_BOARD_ITEM, DS_DRAW_ITEM_LINE, DS_DRAW_ITEM_POLYPOLYGONS, DS_DRAW_ITEM_RECT, DS_DRAW_ITEM_PAGE, DS_DRAW_ITEM_TEXT, DS_DRAW_ITEM_BITMAP, PCB_GROUP, BOARD, FOOTPRINT, FP_SHAPE, FP_TEXT, FP_TEXTBOX, PAD, PCB_BITMAP, PCB_DIMENSION_BASE, PCB_MARKER, PCB_SHAPE, PCB_TARGET, PCB_TEXT, PCB_TEXTBOX, PCB_TRACK, PCB_VIA, and ZONE.

Definition at line 108 of file eda_item.cpp.

109{
110 wxFAIL_MSG( wxT( "GetItemDescription() was not overridden for schematic item type " ) +
111 GetClass() );
112
113 return wxString( wxT( "Undefined item description for " ) + GetClass() );
114}

References EDA_ITEM::GetClass().

Referenced by CONNECTION_GRAPH::collectAllDriverValues(), DIALOG_GROUP_PROPERTIES::DoAddMember(), SELECTION_TOOL::doSelectionMenu(), DRC_ENGINE::EvalRules(), BOARD_INSPECTION_TOOL::getItemDescription(), PCB_MARKER::GetMsgPanelInfo(), ERC_TREE_MODEL::GetValue(), RC_TREE_MODEL::GetValue(), RC_ITEM::ShowReport(), DIALOG_POSITION_RELATIVE::updateAnchorInfo(), and PCB_CONTROL::UpdateMessagePanel().

◆ GetItems()

◆ GetItemsCount()

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

Definition at line 160 of file gerber_file_image.h.

160{ return m_drawings.size(); }

References GERBER_FILE_IMAGE::m_drawings.

Referenced by GERBVIEW_FRAME::Read_GERBER_File().

◆ GetLastItemInList()

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

Definition at line 175 of file gerber_file_image.h.

176 {
177 return m_drawings.back();
178 }

References GERBER_FILE_IMAGE::m_drawings.

Referenced by GERBER_FILE_IMAGE::Execute_DCODE_Command(), and GERBER_FILE_IMAGE::Execute_G_Command().

◆ GetLayerParams()

GERBER_LAYER & GERBER_FILE_IMAGE::GetLayerParams ( )
inlineinherited

◆ GetMenuImage()

BITMAPS EDA_ITEM::GetMenuImage ( ) const
virtualinherited

Return 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 LIB_FIELD, LIB_PIN, LIB_SHAPE, LIB_TEXT, LIB_TEXTBOX, SCH_BITMAP, SCH_BUS_WIRE_ENTRY, SCH_BUS_BUS_ENTRY, SCH_FIELD, SCH_JUNCTION, SCH_LABEL, SCH_GLOBALLABEL, SCH_HIERLABEL, SCH_LINE, SCH_MARKER, SCH_NO_CONNECT, SCH_SHAPE, SCH_SHEET, SCH_SHEET_PIN, SCH_SYMBOL, SCH_TEXT, SCH_TEXTBOX, GERBER_DRAW_ITEM, PCB_GROUP, FOOTPRINT, FP_SHAPE, FP_TEXT, FP_TEXTBOX, PAD, PCB_BITMAP, PCB_DIM_ALIGNED, PCB_DIM_ORTHOGONAL, PCB_DIM_RADIAL, PCB_DIM_LEADER, PCB_DIM_CENTER, PCB_MARKER, PCB_SHAPE, PCB_TARGET, PCB_TEXT, PCB_TEXTBOX, PCB_TRACK, PCB_VIA, and ZONE.

Definition at line 269 of file eda_item.cpp.

270{
271 return BITMAPS::dummy_item;
272}

References dummy_item.

Referenced by SELECTION_TOOL::doSelectionMenu().

◆ GetMessages()

const wxArrayString & GERBER_FILE_IMAGE::GetMessages ( ) const
inlineinherited

◆ GetMsgPanelInfo()

◆ GetNextLine()

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

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 946 of file rs274x.cpp.

947{
948 for( ; ; )
949 {
950 switch (*aText )
951 {
952 case ' ': // skip blanks
953 case '\n':
954 case '\r': // Skip line terminators
955 ++aText;
956 break;
957
958 case 0: // End of text found in aBuff: Read a new string
959 if( fgets( aBuff, aBuffSize, aFile ) == nullptr )
960 return nullptr;
961
962 m_LineNum++;
963 aText = aBuff;
964 return aText;
965
966 default:
967 return aText;
968 }
969 }
970 return aText;
971}

References GERBER_FILE_IMAGE::m_LineNum.

Referenced by GERBER_FILE_IMAGE::ReadApertureMacro().

◆ GetParent()

◆ GetPosition()

virtual VECTOR2I EDA_ITEM::GetPosition ( ) const
inlinevirtualinherited

Reimplemented in LIB_FIELD, LIB_PIN, LIB_SHAPE, LIB_TEXT, SCH_BITMAP, SCH_BUS_ENTRY_BASE, SCH_FIELD, SCH_JUNCTION, SCH_LINE, SCH_MARKER, SCH_NO_CONNECT, SCH_PIN, SCH_SHAPE, SCH_SHEET, SCH_SYMBOL, SCH_TEXT, GERBER_DRAW_ITEM, DELETED_BOARD_ITEM, DS_DRAW_ITEM_LINE, DS_DRAW_ITEM_POLYPOLYGONS, DS_DRAW_ITEM_RECT, DS_DRAW_ITEM_PAGE, DS_DRAW_ITEM_TEXT, DS_DRAW_ITEM_BITMAP, KIGFX::ORIGIN_VIEWITEM, PCB_GROUP, BOARD, FOOTPRINT, FP_TEXT, NETINFO_ITEM, PAD, PCB_BITMAP, PCB_DIMENSION_BASE, PCB_MARKER, PCB_SHAPE, PCB_TARGET, PCB_TEXT, PCB_TRACK, PCB_ARC, PCB_VIA, and ZONE.

Definition at line 249 of file eda_item.h.

249{ return VECTOR2I(); }

Referenced by SCH_MOVE_TOOL::AlignElements(), SCH_EDITOR_CONTROL::AssignNetclass(), SCH_EDIT_TOOL::ChangeTextType(), TEST_BOARD_ITEM_FIXTURE::CompareItems(), TEST_EE_ITEM_FIXTURE::CompareItems(), PCB_GRID_HELPER::computeAnchors(), EE_GRID_HELPER::computeAnchors(), CONVERT_TOOL::CreatePolys(), SCH_EDIT_FRAME::DeleteJunction(), EDIT_TOOL::doMoveSelection(), KIGFX::PCB_PAINTER::draw(), CONNECTION_GRAPH::ercCheckBusToBusConflicts(), CONNECTION_GRAPH::ercCheckBusToNetConflicts(), CONNECTION_GRAPH::ercCheckMultipleDrivers(), CONNECTION_GRAPH::ercCheckNetclassConflicts(), CONNECTION_GRAPH::ercCheckNoConnects(), PCB_SELECTION_TOOL::FindItem(), GERBVIEW_SELECTION::GetCenter(), EDA_ITEM::GetFocusPosition(), getMinDist(), SCH_FIELD::GetParentPosition(), EDA_ITEM::GetSortPosition(), PCB_SELECTION::GetTopLeftItem(), EE_SELECTION::GetTopLeftItem(), BOARD_ITEM::GetX(), BOARD_ITEM::GetY(), SCH_MOVE_TOOL::Main(), SCH_EDIT_TOOL::Mirror(), SYMBOL_EDITOR_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_FIND_REPLACE_TOOL::nextMatch(), DIALOG_MIGRATE_BUSES::onItemSelected(), BOARD::cmp_items::operator()(), SCH_ITEM::operator<(), SCH_EDITOR_CONTROL::Paste(), PL_EDIT_TOOL::Paste(), PCB_CONTROL::placeBoardItems(), POSITION_RELATIVE_TOOL::PositionRelative(), BACK_ANNOTATE::processNetNameChange(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), SCH_EDIT_TOOL::RepeatDrawItem(), SCH_EDIT_TOOL::Rotate(), SYMBOL_EDITOR_EDIT_TOOL::Rotate(), test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run(), DRC_TEST_PROVIDER_TEXT_DIMS::Run(), RC_ITEM::ShowReport(), SCH_EDIT_TOOL::Swap(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testShapeLineChain(), DRC_TEST_PROVIDER_MISC::testTextVars(), TransformItem(), DIALOG_POSITION_RELATIVE::UpdateAnchor(), EDIT_TOOL::updateModificationPoint(), and PL_EDIT_TOOL::updateModificationPoint().

◆ GetPositiveDrawColor()

COLOR4D GERBER_FILE_IMAGE::GetPositiveDrawColor ( ) const
inlineinherited

Definition at line 150 of file gerber_file_image.h.

150{ return m_PositiveDrawColor; }
COLOR4D m_PositiveDrawColor
The color used to draw positive items.

References GERBER_FILE_IMAGE::m_PositiveDrawColor.

Referenced by GERBER_DRAW_ITEM::Print().

◆ GetSortPosition()

virtual VECTOR2I EDA_ITEM::GetSortPosition ( ) const
inlinevirtualinherited

Return the coordinates that should be used for sorting this element visually compared to other elements.

For instance, for lines the midpoint might be a better sorting point than either end.

Returns
X,Y coordinate of the sort point

Reimplemented in SCH_LINE.

Definition at line 265 of file eda_item.h.

265{ return GetPosition(); }

References EDA_ITEM::GetPosition().

◆ GetState()

int EDA_ITEM::GetState ( EDA_ITEM_FLAGS  type) const
inlineinherited

Definition at line 123 of file eda_item.h.

124 {
125 return m_status & type;
126 }
EDA_ITEM_FLAGS m_status
Definition: eda_item.h:495

References EDA_ITEM::m_status.

◆ GetStatus()

EDA_ITEM_FLAGS EDA_ITEM::GetStatus ( ) const
inlineinherited

Definition at line 136 of file eda_item.h.

136{ return m_status; }

References EDA_ITEM::m_status.

◆ GetTypeDesc()

wxString EDA_ITEM::GetTypeDesc ( ) const
inherited

Return a translated description of the type for this EDA_ITEM for display in user facing messages.

Definition at line 301 of file eda_item.cpp.

302{
303 //@see EDA_ITEM_DESC for definition of ENUM_MAP<KICAD_T>
304 wxString typeDescr = ENUM_MAP<KICAD_T>::Instance().ToString( Type() );
305
306 return wxGetTranslation( typeDescr );
307}
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
static ENUM_MAP< T > & Instance()
Definition: property.h:573

References ENUM_MAP< T >::Instance(), and EDA_ITEM::Type().

Referenced by PCB_GROUP::AddItem(), EDIT_TOOL::doMoveSelection(), and EDA_ITEM::GetFriendlyName().

◆ HasFlag()

◆ HasNegativeItems()

bool GERBER_FILE_IMAGE::HasNegativeItems ( )
inherited
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 222 of file gerber_file_image.cpp.

223{
224 if( m_hasNegativeItems < 0 ) // negative items are not yet searched: find them if any
225 {
226 if( m_ImageNegative ) // A negative layer is expected having always negative objects.
227 {
229 }
230 else
231 {
233
234 for( GERBER_DRAW_ITEM* item : GetItems() )
235 {
236 if( item->GetLayer() != m_GraphicLayer )
237 continue;
238
239 if( item->HasNegativeItems() )
240 {
242 break;
243 }
244 }
245 }
246 }
247
248 return m_hasNegativeItems == 1;
249}
int m_hasNegativeItems
True if the image is negative or has some negative items.
GERBER_DRAW_ITEMS & GetItems()

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

◆ HitTest() [1/2]

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

Test if aRect intersects this item.

Parameters
aRectA reference to a BOX2I 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 LIB_ITEM, LIB_PIN, LIB_SHAPE, LIB_TEXT, LIB_TEXTBOX, SCH_BITMAP, SCH_BUS_ENTRY_BASE, SCH_FIELD, SCH_JUNCTION, SCH_LABEL_BASE, SCH_LINE, SCH_NO_CONNECT, SCH_PIN, SCH_SHAPE, SCH_SHEET, SCH_SYMBOL, SCH_TEXT, SCH_TEXTBOX, DS_DRAW_ITEM_BASE, DS_DRAW_ITEM_POLYPOLYGONS, DS_DRAW_ITEM_RECT, DS_DRAW_ITEM_TEXT, DS_DRAW_ITEM_BITMAP, PCB_GROUP, FOOTPRINT, FP_TEXT, FP_TEXTBOX, PAD, PCB_BITMAP, PCB_DIMENSION_BASE, PCB_SHAPE, PCB_TARGET, PCB_TEXT, PCB_TEXTBOX, PCB_TRACK, PCB_VIA, PCB_ARC, ZONE, and GERBER_DRAW_ITEM.

Definition at line 235 of file eda_item.h.

236 {
237 return false; // derived classes should override this function
238 }

◆ HitTest() [2/2]

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

◆ IsBrightened()

◆ IsEntered()

bool EDA_ITEM::IsEntered ( ) const
inlineinherited

Definition at line 107 of file eda_item.h.

107{ return m_flags & ENTERED; }
#define ENTERED
indicates a group has been entered

References ENTERED, and EDA_ITEM::m_flags.

Referenced by KIGFX::PCB_PAINTER::draw().

◆ IsForceVisible()

bool EDA_ITEM::IsForceVisible ( ) const
inlineinherited

Definition at line 201 of file eda_item.h.

201{ return m_forceVisible; }
bool m_forceVisible
Definition: eda_item.h:497

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 102 of file eda_item.h.

102{ return m_flags & IS_CHANGED; }

References IS_CHANGED, and EDA_ITEM::m_flags.

Referenced by PCB_EDIT_FRAME::OpenProjectFiles().

◆ IsMoving()

◆ IsNew()

◆ IsReplaceable()

virtual bool EDA_ITEM::IsReplaceable ( ) const
inlinevirtualinherited

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 LIB_TEXTBOX, SCH_FIELD, SCH_LABEL, SCH_SHEET, SCH_SHEET_PIN, SCH_SYMBOL, SCH_TEXT, and SCH_TEXTBOX.

Definition at line 420 of file eda_item.h.

420{ return false; }

Referenced by EDA_ITEM::Matches().

◆ IsRollover()

bool EDA_ITEM::IsRollover ( ) const
inlineinherited

Definition at line 110 of file eda_item.h.

111 {
112 return ( m_flags & ( IS_ROLLOVER | IS_MOVING ) ) == IS_ROLLOVER;
113 }
#define IS_ROLLOVER
Rollover active. Used for hyperlink highlighting.

References IS_MOVING, IS_ROLLOVER, and EDA_ITEM::m_flags.

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

◆ IsSelected()

bool EDA_ITEM::IsSelected ( ) const
inlineinherited

Definition at line 106 of file eda_item.h.

106{ return m_flags & SELECTED; }

References EDA_ITEM::m_flags, and SELECTED.

Referenced by ALIGN_DISTRIBUTE_TOOL::AlignBottom(), ALIGN_DISTRIBUTE_TOOL::AlignCenterX(), ALIGN_DISTRIBUTE_TOOL::AlignCenterY(), ALIGN_DISTRIBUTE_TOOL::AlignTop(), SCH_EDIT_TOOL::ChangeTextType(), SCH_EDIT_FRAME::ConvertPart(), DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS(), ALIGN_DISTRIBUTE_TOOL::doAlignLeft(), ALIGN_DISTRIBUTE_TOOL::doAlignRight(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersVertically(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsVertically(), EDIT_TOOL::doMoveSelection(), KIGFX::SCH_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), KIGFX::PCB_PAINTER::Draw(), DS_PROXY_UNDO_ITEM::DS_PROXY_UNDO_ITEM(), KIGFX::GERBVIEW_RENDER_SETTINGS::GetColor(), KIGFX::DS_RENDER_SETTINGS::GetColor(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), SCH_MOVE_TOOL::getConnectedDragItems(), KIGFX::SCH_PAINTER::getLineWidth(), DIALOG_EXCHANGE_FOOTPRINTS::isMatch(), DIALOG_CHANGE_SYMBOLS::isMatch(), SCH_SCREEN::MarkConnections(), SCH_LINE::MergeOverlap(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), KIGFX::SCH_PAINTER::nonCached(), SCH_MOVE_TOOL::orthoLineDrag(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), BOARD_COMMIT::Push(), EE_SELECTION_TOOL::RebuildSelection(), PCB_SELECTION_TOOL::RebuildSelection(), RENDER_3D_OPENGL::renderFootprint(), SCH_EDIT_TOOL::Rotate(), EE_TOOL_BASE< T >::saveCopyInUndoList(), GERBVIEW_SELECTION_TOOL::select(), PCB_SELECTION_TOOL::select(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), KIGFX::SCH_PAINTER::setDeviceColors(), GERBVIEW_SELECTION_TOOL::unselect(), HIERARCHY_PANE::UpdateHierarchySelection(), PCB_BASE_FRAME::UpdateUserUnits(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem(), and DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::visitItem().

◆ IsShownAsBitmap()

bool EDA_ITEM::IsShownAsBitmap ( ) const
inlineinherited

Definition at line 173 of file eda_item.h.

173{ return m_flags & IS_SHOWN_AS_BITMAP; }
#define IS_SHOWN_AS_BITMAP

References IS_SHOWN_AS_BITMAP, and EDA_ITEM::m_flags.

◆ IsType()

virtual bool EDA_ITEM::IsType ( const std::vector< KICAD_T > &  aScanTypes) const
inlinevirtualinherited

Check 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 SCH_FIELD, SCH_ITEM, SCH_LABEL_BASE, SCH_LINE, FP_SHAPE, FP_TEXT, FP_TEXTBOX, PAD, PCB_DIMENSION_BASE, PCB_SHAPE, PCB_TEXT, PCB_TEXTBOX, and PCB_VIA.

Definition at line 181 of file eda_item.h.

182 {
183 for( KICAD_T scanType : aScanTypes )
184 {
185 if( scanType == SCH_LOCATE_ANY_T || scanType == m_structType )
186 return true;
187 }
188
189 return false;
190 }
KICAD_T m_structType
Run time identification, keep private so it can never be changed after a ctor sets it.
Definition: eda_item.h:505
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_LOCATE_ANY_T
Definition: typeinfo.h:183

References EDA_ITEM::m_structType, and SCH_LOCATE_ANY_T.

Referenced by SCH_EDIT_TOOL::AutoplaceFields(), ROUTER_TOOL::CanInlineDrag(), DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES(), SCH_FIELD::GetCanonicalName(), KIGFX::SCH_PAINTER::getLineWidth(), SCH_FIELD::GetName(), KIGFX::SCH_PAINTER::getRenderColor(), SCH_FIELD::GetShownText(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingBus(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingLine(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingWire(), SCH_ITEM::IsType(), FP_TEXT::IsType(), FP_TEXTBOX::IsType(), PAD::IsType(), PCB_DIMENSION_BASE::IsType(), PCB_SHAPE::IsType(), PCB_TEXT::IsType(), PCB_TEXTBOX::IsType(), PCB_VIA::IsType(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), CONVERT_TOOL::makePolysFromChainedSegs(), EE_SELECTION_TOOL::RequestSelection(), SCH_FIELD::SetId(), SCH_BASE_FRAME::UpdateItem(), and EDA_ITEM::Visit().

◆ IterateForward() [1/2]

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

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

Definition at line 302 of file eda_item.h.

304 {
305 for( const auto& it : aList )
306 {
307 if( static_cast<EDA_ITEM*>( it )->Visit( inspector,
308 testData,
309 scanTypes ) == INSPECT_RESULT::QUIT )
310 {
312 }
313 }
314
316 }
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
virtual INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes)
May be re-implemented for each derived class in order to handle all the types given by its member dat...
Definition: eda_item.cpp:91

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

Referenced by GERBER_FILE_IMAGE::Visit().

◆ IterateForward() [2/2]

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

Change first parameter to avoid the DList and use std::vector instead.

Definition at line 322 of file eda_item.h.

324 {
325 for( const auto& it : aList )
326 {
327 if( static_cast<EDA_ITEM*>( it )->Visit( inspector,
328 testData,
329 scanTypes ) == INSPECT_RESULT::QUIT )
330 {
332 }
333 }
334
336 }

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

◆ LoadFile()

bool EXCELLON_IMAGE::LoadFile ( const wxString &  aFullFileName,
EXCELLON_DEFAULTS aDefaults 
)

Read and load a drill (EXCELLON format) file.

When the file cannot be loaded, warning and info messages are stored in m_Messages.

Parameters
aFullFileNameis the full filename of the Excellon file.
aDefaultsis the default values when not found in file.
Returns
true if OK, false if the gerber file was not loaded.

Definition at line 455 of file excellon_read_drill_file.cpp.

456{
457 // Set the default parameter values:
460
461 m_Current_File = wxFopen( aFullFileName, wxT( "rt" ) );
462
463 if( m_Current_File == nullptr )
464 return false;
465
466 // Initial format setting, usualy defined in file, but not always...
467 m_NoTrailingZeros = aDefaults->m_LeadingZero;
468 m_GerbMetric = aDefaults->m_UnitsMM;
469
470 wxString msg;
471 m_FileName = aFullFileName;
472
473 LOCALE_IO toggleIo;
474
475 // FILE_LINE_READER will close the file.
476 FILE_LINE_READER excellonReader( m_Current_File, m_FileName );
477
478 while( true )
479 {
480 if( excellonReader.ReadLine() == nullptr )
481 break;
482
483 char* line = excellonReader.Line();
484 char* text = StrPurge( line );
485
486 if( *text == 0 ) // Skip empty lines
487 continue;
488
490 {
492
493 // Now units (inch/mm) are known, set the coordinate format
494 SelectUnits( m_GerbMetric, aDefaults );
495 }
496 else
497 {
498 switch( *text )
499 {
500 case ';':
501 case 'M':
503 break;
504
505 case 'G': // Line type Gxx : command
507 break;
508
509 case 'X':
510 case 'Y': // command like X12550Y19250
512 break;
513
514 case 'I':
515 case 'J': /* Auxiliary Move command */
517 if( *text == '*' ) // command like X35142Y15945J504
518 {
520 }
521 break;
522
523 case 'T': // Select Tool command (can also create
524 // the tool with an embedded definition)
525 Select_Tool( text );
526 break;
527
528 case '%':
529 break;
530
531 default:
532 msg.Printf( wxT( "Unexpected symbol 0x%2.2X &lt;%c&gt;" ), *text, *text );
533 AddMessageToList( msg );
534 break;
535 } // End switch
536 }
537 }
538
539 // Add our file attribute, to identify the drill file
541 char* text = (char*)file_attribute;
542 int dummyline = 0;
543 dummy.ParseAttribCmd( nullptr, nullptr, 0, text, dummyline );
544 delete m_FileFunction;
546
547 m_InUse = true;
548
549 return true;
550}
bool Execute_Drill_Command(char *&text)
bool Execute_HEADER_And_M_Command(char *&text)
virtual void ResetDefaultValues() override
Set all parameters to a default value, before reading a file.
bool Select_Tool(char *&text)
A LINE_READER that reads from an open file.
Definition: richio.h:173
void ClearMessageList()
Clear the message list.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:41
static const char file_attribute[]
char * StrPurge(char *text)
Remove leading and training spaces, tabs and end of line chars in text.

References GERBER_FILE_IMAGE::AddMessageToList(), GERBER_FILE_IMAGE::ClearMessageList(), dummy, Execute_Drill_Command(), Execute_EXCELLON_G_Command(), Execute_HEADER_And_M_Command(), file_attribute, LINE_READER::Line(), GERBER_FILE_IMAGE::m_Current_File, GERBER_FILE_IMAGE::m_FileFunction, GERBER_FILE_IMAGE::m_FileName, GERBER_FILE_IMAGE::m_GerbMetric, GERBER_FILE_IMAGE::m_IJPos, GERBER_FILE_IMAGE::m_InUse, EXCELLON_DEFAULTS::m_LeadingZero, GERBER_FILE_IMAGE::m_NoTrailingZeros, m_State, EXCELLON_DEFAULTS::m_UnitsMM, READ_HEADER_STATE, GERBER_FILE_IMAGE::ReadIJCoord(), FILE_LINE_READER::ReadLine(), ResetDefaultValues(), Select_Tool(), SelectUnits(), StrPurge(), and text.

◆ LoadGerberFile()

bool GERBER_FILE_IMAGE::LoadGerberFile ( const wxString &  aFullFileName)
inherited

Read and load a gerber file.

If the file cannot be loaded, warning and information messages are stored in m_messagesList.

Parameters
aFullFileNameThe full filename of the Gerber file.
Returns
true if file loaded successfully, false if the gerber file was not loaded.

Definition at line 232 of file readgerb.cpp.

233{
234 int G_command = 0; // command number for G commands like G04
235 int D_commande = 0; // command number for D commands like D02
236 char* text;
237
240
241 // Read the gerber file */
242 m_Current_File = wxFopen( aFullFileName, wxT( "rt" ) );
243
244 if( m_Current_File == nullptr )
245 return false;
246
247 m_FileName = aFullFileName;
248
249 LOCALE_IO toggleIo;
250
251 wxString msg;
252
253 while( true )
254 {
255 if( fgets( lineBuffer, GERBER_BUFZ, m_Current_File ) == nullptr )
256 break;
257
258 m_LineNum++;
260
261 while( text && *text )
262 {
263 switch( *text )
264 {
265 case ' ':
266 case '\r':
267 case '\n':
268 text++;
269 break;
270
271 case '*': // End command
273 text++;
274 break;
275
276 case 'M': // End file
278 while( *text )
279 text++;
280 break;
281
282 case 'G': /* Line type Gxx : command */
283 G_command = CodeNumber( text );
284 Execute_G_Command( text, G_command );
285 break;
286
287 case 'D': /* Line type Dxx : Tool selection (xx > 0) or
288 * command if xx = 0..9 */
289 D_commande = CodeNumber( text );
290 Execute_DCODE_Command( text, D_commande );
291 break;
292
293 case 'X':
294 case 'Y': /* Move or draw command */
296 if( *text == '*' ) // command like X12550Y19250*
297 {
299 }
300 break;
301
302 case 'I':
303 case 'J': /* Auxiliary Move command */
305
306 if( *text == '*' ) // command like X35142Y15945J504*
307 {
309 }
310 break;
311
312 case '%':
314 {
317 }
318 else //Error
319 {
320 AddMessageToList( wxT( "Expected RS274X Command" ) );
322 text++;
323 }
324 break;
325
326 default:
327 msg.Printf( wxT( "Unexpected char 0x%2.2X" ), *text );
328 AddMessageToList( msg );
329 text++;
330 break;
331 }
332 }
333 }
334
335 fclose( m_Current_File );
336
337 m_InUse = true;
338
339 return true;
340}
bool Execute_G_Command(char *&text, int G_command)
Definition: rs274d.cpp:421
virtual void ResetDefaultValues()
Set all parameters to a default value, before reading a file.
bool Execute_DCODE_Command(char *&text, int D_command)
Definition: rs274d.cpp:557
bool ReadRS274XCommand(char *aBuff, unsigned int aBuffSize, char *&aText)
Read a single RS274X command terminated with a %.
Definition: rs274x.cpp:144
int m_CommandState
state of gerber analysis command
@ END_BLOCK
Definition: gerbview.h:65
@ ENTER_RS274X_CMD
Definition: gerbview.h:66
@ CMD_IDLE
Definition: gerbview.h:64
#define GERBER_BUFZ
Definition: readgerb.cpp:228
static char lineBuffer[GERBER_BUFZ+1]
Definition: readgerb.cpp:230

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

◆ Matches() [1/2]

virtual bool EDA_ITEM::Matches ( const EDA_SEARCH_DATA aSearchData,
void *  aAuxData 
) const
inlinevirtualinherited

Compare 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_MARKER, LIB_TEXTBOX, SCH_FIELD, SCH_LABEL_BASE, SCH_PIN, SCH_SHEET, SCH_SHEET_PIN, SCH_SYMBOL, SCH_TEXT, SCH_TEXTBOX, FP_TEXT, FP_TEXTBOX, NETINFO_ITEM, PCB_MARKER, PCB_TEXT, PCB_TEXTBOX, and ZONE.

Definition at line 382 of file eda_item.h.

383 {
384 return false;
385 }

Referenced by SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), SCH_FIND_REPLACE_TOOL::HasMatch(), SCH_MARKER::Matches(), LIB_TEXTBOX::Matches(), SCH_FIELD::Matches(), SCH_LABEL_BASE::Matches(), SCH_PIN::Matches(), SCH_SHEET_PIN::Matches(), SCH_TEXT::Matches(), SCH_TEXTBOX::Matches(), FP_TEXT::Matches(), FP_TEXTBOX::Matches(), NETINFO_ITEM::Matches(), PCB_MARKER::Matches(), PCB_TEXT::Matches(), PCB_TEXTBOX::Matches(), ZONE::Matches(), SCH_FIND_REPLACE_TOOL::ReplaceAndFindNext(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), and SCH_FIND_REPLACE_TOOL::UpdateFind().

◆ Matches() [2/2]

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

Compare 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 117 of file eda_item.cpp.

118{
119 wxString text = aText;
120 wxString searchText = aSearchData.findString;
121
122 // Don't match if searching for replaceable item and the item doesn't support text replace.
123 if( aSearchData.searchAndReplace && !IsReplaceable() )
124 return false;
125
126 if( !aSearchData.matchCase )
127 {
128 text.MakeUpper();
129 searchText.MakeUpper();
130 }
131
133 {
134 int ii = 0;
135
136 while( ii < (int) text.length() )
137 {
138 int next = text.find( searchText, ii );
139
140 if( next == wxNOT_FOUND )
141 return false;
142
143 ii = next;
144 next += searchText.length();
145
146 bool startOK = ( ii == 0 || !wxIsalnum( text.GetChar( ii - 1 ) ) );
147 bool endOK = ( next == (int) text.length() || !wxIsalnum( text.GetChar( next ) ) );
148
149 if( startOK && endOK )
150 return true;
151 else
152 ii++;
153 }
154
155 return false;
156 }
157 else if( aSearchData.matchMode == EDA_SEARCH_MATCH_MODE::WILDCARD )
158 {
159 return text.Matches( searchText );
160 }
161 else
162 {
163 return text.Find( searchText ) != wxNOT_FOUND;
164 }
165}
virtual bool IsReplaceable() const
Override this method in any derived object that supports test find and replace.
Definition: eda_item.h:420
CITER next(CITER it)
Definition: ptree.cpp:126
EDA_SEARCH_MATCH_MODE matchMode

References EDA_SEARCH_DATA::findString, EDA_ITEM::IsReplaceable(), EDA_SEARCH_DATA::matchCase, EDA_SEARCH_DATA::matchMode, next(), EDA_SEARCH_DATA::searchAndReplace, text, WHOLEWORD, and WILDCARD.

◆ 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 231 of file eda_item.cpp.

232{
233 wxFAIL_MSG( wxString::Format( wxT( "Less than operator not defined for item type %s." ),
234 GetClass() ) );
235
236 return false;
237}

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

◆ ReadApertureMacro()

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

Read 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
true if a macro was read in successfully, else false.

Definition at line 974 of file rs274x.cpp.

977{
978 wxString msg;
980
981 // read macro name
982 while( *aText )
983 {
984 if( *aText == '*' )
985 {
986 ++aText;
987 break;
988 }
989
990 am.m_AmName.Append( *aText++ );
991 }
992
993 // Read aperture macro parameters
994 for( ; ; )
995 {
996 if( *aText == '*' )
997 ++aText;
998
999 aText = GetNextLine( aBuff, aBuffSize, aText, gerber_file );
1000
1001 if( aText == nullptr ) // End of File
1002 return false;
1003
1004 // aText points the beginning of a new line.
1005
1006 // Test for the last line in aperture macro lis:
1007 // last line is % or *% sometime found.
1008 if( *aText == '*' )
1009 ++aText;
1010
1011 if( *aText == '%' )
1012 break; // exit with aText still pointing at %
1013
1014 int paramCount = 0; // will be set to the minimal parameters count,
1015 // depending on the actual primitive
1016 int primitive_type = AMP_UNKNOWN;
1017 // Test for a valid symbol at the beginning of a description:
1018 // it can be: a parameter declaration like $1=$2/4
1019 // or a digit (macro primitive selection)
1020 // all other symbols are illegal.
1021 if( *aText == '$' ) // local parameter declaration, inside the aperture macro
1022 {
1025 aText = GetNextLine( aBuff, aBuffSize, aText, gerber_file );
1026
1027 if( aText == nullptr) // End of File
1028 return false;
1029
1030 param.ReadParamFromAmDef( aText );
1031 continue;
1032 }
1033 else if( !isdigit(*aText) ) // Ill. symbol
1034 {
1035 msg.Printf( wxT( "RS274X: Aperture Macro \"%s\": ill. symbol, line: \"%s\"" ),
1036 am.m_AmName, FROM_UTF8( aBuff ) );
1037 AddMessageToList( msg );
1038 primitive_type = AMP_COMMENT;
1039 }
1040 else
1041 primitive_type = ReadInt( aText );
1042
1043 bool is_comment = false;
1044
1045 switch( primitive_type )
1046 {
1047 case AMP_COMMENT: // lines starting by 0 are a comment
1048 paramCount = 0;
1049 is_comment = true;
1050
1051 // Skip comment
1052 while( *aText && ( *aText != '*' ) )
1053 aText++;
1054
1055 break;
1056
1057 case AMP_CIRCLE:
1058 paramCount = 4; // minimal count. can have a optional parameter (rotation)
1059 break;
1060
1061 case AMP_LINE2:
1062 case AMP_LINE20:
1063 paramCount = 7;
1064 break;
1065
1066 case AMP_LINE_CENTER:
1068 paramCount = 6;
1069 break;
1070
1071 case AMP_EOF:
1072 paramCount = 0;
1073 break;
1074
1075 case AMP_OUTLINE:
1076 paramCount = 4; // partial count. other parameters are vertices and rotation
1077 // Second parameter is vertice (coordinate pairs) count.
1078 break;
1079
1080 case AMP_POLYGON:
1081 paramCount = 6;
1082 break;
1083
1084 case AMP_MOIRE:
1085 paramCount = 9;
1086 break;
1087
1088 case AMP_THERMAL:
1089 paramCount = 6;
1090 break;
1091
1092 default:
1093 msg.Printf( wxT( "RS274X: Aperture Macro \"%s\": Invalid primitive id code %d, line %d: \"%s\"" ),
1094 am.m_AmName, primitive_type, m_LineNum, FROM_UTF8( aBuff ) );
1095 AddMessageToList( msg );
1096 return false;
1097 }
1098
1099 if( is_comment )
1100 continue;
1101
1102 AM_PRIMITIVE prim( m_GerbMetric );
1103 prim.m_Primitive_id = (AM_PRIMITIVE_ID) primitive_type;
1104 int ii;
1105
1106 for( ii = 0; ii < paramCount && *aText && *aText != '*'; ++ii )
1107 {
1108 prim.m_Params.push_back( AM_PARAM() );
1109
1110 AM_PARAM& param = prim.m_Params.back();
1111
1112 aText = GetNextLine( aBuff, aBuffSize, aText, gerber_file );
1113
1114 if( aText == nullptr) // End of File
1115 return false;
1116
1117 param.ReadParamFromAmDef( aText );
1118 }
1119
1120 if( ii < paramCount )
1121 {
1122 // maybe some day we can throw an exception and track a line number
1123 msg.Printf( wxT( "RS274X: read macro descr type %d: read %d parameters, insufficient "
1124 "parameters\n" ),
1125 prim.m_Primitive_id, ii );
1126 AddMessageToList( msg );
1127 }
1128
1129 // there are more parameters to read if this is an AMP_OUTLINE
1130 if( prim.m_Primitive_id == AMP_OUTLINE )
1131 {
1132 // so far we have read [0]:exposure, [1]:#points, [2]:X start, [3]: Y start
1133 // Now read all the points, plus trailing rotation in degrees.
1134
1135 // m_Params[1] is a count of polygon points, so it must be given
1136 // in advance, i.e. be immediate.
1137 wxASSERT( prim.m_Params[1].IsImmediate() );
1138
1139 paramCount = (int) prim.m_Params[1].GetValue( nullptr ) * 2 + 1;
1140
1141 for( int jj = 0; jj < paramCount && *aText != '*'; ++jj )
1142 {
1143 prim.m_Params.push_back( AM_PARAM() );
1144
1145 AM_PARAM& param = prim.m_Params.back();
1146
1147 aText = GetNextLine( aBuff, aBuffSize, aText, gerber_file );
1148
1149 if( aText == nullptr ) // End of File
1150 return false;
1151
1152 param.ReadParamFromAmDef( aText );
1153 }
1154 }
1155
1156 // AMP_CIRCLE can have a optional parameter (rotation)
1157 if( prim.m_Primitive_id == AMP_CIRCLE && aText && *aText != '*' )
1158 {
1159 prim.m_Params.push_back( AM_PARAM() );
1160 AM_PARAM& param = prim.m_Params.back();
1161 param.ReadParamFromAmDef( aText );
1162 }
1163
1164 // The primitive description is now parsed: push it to the current aperture macro
1165 am.AddPrimitiveToList( prim );
1166 }
1167
1168 m_aperture_macros.insert( am );
1169
1170 return true;
1171}
AM_PRIMITIVE_ID
The set of all "aperture macro primitives" (primitive numbers).
Definition: am_primitive.h:69
@ AMP_POLYGON
Definition: am_primitive.h:80
@ AMP_LINE_LOWER_LEFT
Definition: am_primitive.h:77
@ AMP_LINE2
Definition: am_primitive.h:74
@ AMP_CIRCLE
Definition: am_primitive.h:73
@ AMP_THERMAL
Definition: am_primitive.h:83
@ AMP_EOF
Definition: am_primitive.h:78
@ AMP_UNKNOWN
Definition: am_primitive.h:70
@ AMP_COMMENT
Definition: am_primitive.h:71
@ AMP_LINE_CENTER
Definition: am_primitive.h:76
@ AMP_MOIRE
Definition: am_primitive.h:82
@ AMP_OUTLINE
Definition: am_primitive.h:79
@ AMP_LINE20
Definition: am_primitive.h:75
Hold a parameter value for an "aperture macro" as defined within standard RS274X.
Definition: am_param.h:285
bool ReadParamFromAmDef(char *&aText)
Read one aperture macro parameter.
Definition: am_param.cpp:175
An aperture macro primitive as given in gerber layer format doc.
Definition: am_primitive.h:93
void AddLocalParamDefToStack()
A deferred parameter can be defined in aperture macro, but outside aperture primitives.
AM_PARAM & GetLastLocalParamDefFromStack()
void AddPrimitiveToList(AM_PRIMITIVE &aPrimitive)
Add a new ptimitive ( AMP_CIRCLE, AMP_LINE2 ...) to the list of primitives to define the full shape o...
char * GetNextLine(char *aBuff, unsigned int aBuffSize, char *aText, FILE *aFile)
Test for an end of line.
Definition: rs274x.cpp:946

References APERTURE_MACRO::AddLocalParamDefToStack(), GERBER_FILE_IMAGE::AddMessageToList(), APERTURE_MACRO::AddPrimitiveToList(), 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(), gerber_file, APERTURE_MACRO::GetLastLocalParamDefFromStack(), GERBER_FILE_IMAGE::GetNextLine(), APERTURE_MACRO::m_AmName, GERBER_FILE_IMAGE::m_aperture_macros, GERBER_FILE_IMAGE::m_GerbMetric, GERBER_FILE_IMAGE::m_LineNum, AM_PRIMITIVE::m_Params, AM_PRIMITIVE::m_Primitive_id, ReadInt(), and AM_PARAM::ReadParamFromAmDef().

Referenced by GERBER_FILE_IMAGE::ExecuteRS274XCommand().

◆ readFileFormat()

void EXCELLON_IMAGE::readFileFormat ( char *&  aText)
private

Read an Altium-specific FILE_FORMAT=X:X attribute that specifies the length and mantissa of the numbers in the gerber file.

Parameters
aTextText containing format and mantissa

Definition at line 720 of file excellon_read_drill_file.cpp.

721{
722 int mantissaDigits = 0;
723 int characteristicDigits = 0;
724
725 // Example String: ;FILE_FORMAT=4:4
726 // The ;FILE_FORMAT potion will already be stripped off.
727 // Parse the rest strictly as single_digit:single_digit like 4:4 or 2:4
728 // Don't allow anything clever like spaces or multiple digits
729 if( *aText != '=' )
730 return;
731
732 aText++;
733
734 if( !isdigit( *aText ) )
735 return;
736
737 characteristicDigits = *aText - '0';
738 aText++;
739
740 if( *aText != ':' )
741 return;
742
743 aText++;
744
745 if( !isdigit( *aText ) )
746 return;
747
748 mantissaDigits = *aText - '0';
749
750 m_hasFormat = true;
751 m_FmtLen.x = m_FmtLen.y = characteristicDigits + mantissaDigits;
752 m_FmtScale.x = m_FmtScale.y = mantissaDigits;
753}

References GERBER_FILE_IMAGE::m_FmtLen, GERBER_FILE_IMAGE::m_FmtScale, and m_hasFormat.

Referenced by Execute_HEADER_And_M_Command().

◆ ReadIJCoord()

VECTOR2I GERBER_FILE_IMAGE::ReadIJCoord ( char *&  Text)
inherited

Return the current coordinate type pointed to by InnJnn Text (InnnnJmmmm)

These coordinates are relative, so if coordinate is absent, its value defaults to 0

Definition at line 171 of file rs274_read_XY_and_IJ_coordinates.cpp.

172{
173 VECTOR2I pos( 0, 0 );
174 bool is_float = false;
175
176 std::string line;
177
178 // Reserve the anticipated length plus an optional sign and decimal
179 line.reserve( std::max( m_FmtLen.x, m_FmtLen.y ) + 3 );
180
181 if( aText == nullptr )
182 return pos;
183
184 while( *aText && ( ( *aText == 'I' ) || ( *aText == 'J' ) ) )
185 {
186 double decimal_scale = 1.0;
187 int nbdigits = 0;
188 int current_coord = 0;
189 char type_coord = *aText++;
190
191 line.clear();
192
193 while( IsNumber( *aText ) )
194 {
195 if( *aText == '.' ) // Force decimal format if reading a floating point number
196 is_float = true;
197
198 // count digits only (sign and decimal point are not counted)
199 if( (*aText >= '0') && (*aText <='9') )
200 nbdigits++;
201
202 line.push_back( *( aText++ ) );
203 }
204
205 double val = strtod( line.data(), nullptr );
206
207 if( is_float )
208 {
209 current_coord = scaletoIU( val, m_GerbMetric );
210 }
211 else
212 {
213 int fmt_scale = ( type_coord == 'I' ) ? m_FmtScale.x : m_FmtScale.y;
214
216 {
217 // no trailing zero format, we need to add missing zeros.
218 int digit_count = ( type_coord == 'I' ) ? m_FmtLen.x : m_FmtLen.y;
219
220 // Truncate the extra digits if the len is more than expected
221 // because the conversion to internal units expect exactly
222 // digit_count digits. Alternatively, add some additional digits
223 // to pad out to the missing zeros
224 if( nbdigits < digit_count )
225 decimal_scale = std::pow<double>( 10, digit_count - nbdigits );
226 }
227
228 double real_scale = scale_list[fmt_scale];
229
230 if( m_GerbMetric )
231 real_scale = real_scale / 25.4;
232
233 current_coord = KiROUND( val * real_scale * decimal_scale );
234 }
235
236 if( type_coord == 'I' )
237 {
238 pos.x = current_coord;
239 }
240 else if( type_coord == 'J' )
241 {
242 pos.y = current_coord;
243 }
244 }
245
246 m_IJPos = pos;
248 m_LastCoordIsIJPos = true;
249
250 return pos;
251}
int scaletoIU(double aCoord, bool isMetric)
Convert a coordinate given in floating point to GerbView's internal units (currently = 10 nanometers)...
static bool IsNumber(char x)
static double scale_list[SCALE_LIST_SIZE]

References ARC_INFO_TYPE_CENTER, IsNumber(), KiROUND(), GERBER_FILE_IMAGE::m_FmtLen, GERBER_FILE_IMAGE::m_FmtScale, GERBER_FILE_IMAGE::m_GerbMetric, GERBER_FILE_IMAGE::m_IJPos, GERBER_FILE_IMAGE::m_LastArcDataType, GERBER_FILE_IMAGE::m_LastCoordIsIJPos, GERBER_FILE_IMAGE::m_NoTrailingZeros, scale_list, scaletoIU(), VECTOR2< T >::x, and VECTOR2< T >::y.

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

◆ ReadRS274XCommand()

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

Read 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 ) == nullptr )
185 {
186 // end of file
187 ok = false;
188 break;
189 }
190 m_LineNum++;
191 aText = aBuff;
192 }
193
194exit:
195 return ok;
196}

References CMD_IDLE, GERBER_FILE_IMAGE::ExecuteRS274XCommand(), exit, GERBER_FILE_IMAGE::m_CommandState, GERBER_FILE_IMAGE::m_Current_File, GERBER_FILE_IMAGE::m_LineNum, and GERBER_FILE_IMAGE::ReadXCommandID().

Referenced by GERBER_FILE_IMAGE::LoadGerberFile().

◆ readToolInformation()

bool EXCELLON_IMAGE::readToolInformation ( char *&  aText)
private

Read a tool definition like T1C0.02 or T1F00S00C0.02 or T1C0.02F00S00 and enter params in TCODE list.

Definition at line 756 of file excellon_read_drill_file.cpp.

757{
758 // Read a tool definition like T1C0.02 or T1F00S00C0.02 or T1C0.02F00S00
759 // and enter the TCODE param in list (using the D_CODE param management, which
760 // is similar to TCODE params.
761 if( *aText == 'T' ) // This is the beginning of the definition
762 aText++;
763
764 // Read tool number:
765 int iprm = ReadInt( aText, false );
766
767 // Skip Feed rate and Spindle speed, if any here
768 while( *aText && ( *aText == 'F' || *aText == 'S' ) )
769 {
770 aText++;
771 ReadInt( aText, false );
772 }
773
774 // Read tool shape
775 if( ! *aText )
777 _( "Tool definition shape not found" ) ) );
778 else if( *aText != 'C' )
780 _( "Tool definition '%c' not supported" ), *aText ) );
781 if( *aText )
782 aText++;
783
784 //read tool diameter:
785 double dprm = ReadDouble( aText, false );
786 m_Has_DCode = true;
787
788 // Initialize Dcode to handle this Tool
789 // Remember: dcodes are >= FIRST_DCODE
790 D_CODE* dcode = GetDCODEOrCreate( iprm + FIRST_DCODE );
791
792 if( dcode == nullptr )
793 return false;
794
795 // conv_scale = scaling factor from inch to Internal Unit
796 double conv_scale = gerbIUScale.IU_PER_MILS * 1000;
797
798 if( m_GerbMetric )
799 conv_scale /= 25.4;
800
801 dcode->m_Size.x = dcode->m_Size.y = KiROUND( dprm * conv_scale );
802 dcode->m_Shape = APT_CIRCLE;
803 dcode->m_Defined = true;
804
805 return true;
806}
int ReadInt(char *&text, bool aSkipSeparator=true)
Read an integer from an ASCII character buffer.
double ReadDouble(char *&text, bool aSkipSeparator=true)
Read a double precision floating point number from an ASCII character buffer.

References _, GERBER_FILE_IMAGE::AddMessageToList(), APT_CIRCLE, FIRST_DCODE, Format(), gerbIUScale, GERBER_FILE_IMAGE::GetDCODEOrCreate(), EDA_IU_SCALE::IU_PER_MILS, KiROUND(), D_CODE::m_Defined, GERBER_FILE_IMAGE::m_GerbMetric, GERBER_FILE_IMAGE::m_Has_DCode, D_CODE::m_Shape, D_CODE::m_Size, ReadDouble(), and ReadInt().

Referenced by Execute_HEADER_And_M_Command(), and Select_Tool().

◆ ReadXCommandID()

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

Read 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}

References text.

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

◆ ReadXYCoord()

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

Return 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 forces truncation of a digit string to a maximum length because the exact coordinate format is not always known.

Definition at line 79 of file rs274_read_XY_and_IJ_coordinates.cpp.

80{
81 VECTOR2I pos( 0, 0 );
82 bool is_float = false;
83
84 std::string line;
85
86 // Reserve the anticipated length plus an optional sign and decimal
87 line.reserve( std::max( m_FmtLen.x, m_FmtLen.y ) + 3 );
88
89 // Set up return value for case where aText == nullptr
90 if( !m_Relative )
91 pos = m_CurrentPos;
92
93 if( aText == nullptr )
94 return pos;
95
96 while( *aText && ( ( *aText == 'X' ) || ( *aText == 'Y' ) || ( *aText == 'A' ) ) )
97 {
98 double decimal_scale = 1.0;
99 int nbdigits = 0;
100 int current_coord = 0;
101 char type_coord = *aText++;
102
103 line.clear();
104
105 while( IsNumber( *aText ) )
106 {
107 if( *aText == '.' ) // Force decimal format if reading a floating point number
108 is_float = true;
109
110 // count digits only (sign and decimal point are not counted)
111 if( (*aText >= '0') && (*aText <='9') )
112 nbdigits++;
113
114 line.push_back( *( aText++ ) );
115 }
116
117 double val = strtod( line.data(), nullptr );
118
119 if( is_float )
120 {
121 current_coord = scaletoIU( val, m_GerbMetric );
122 }
123 else
124 {
125 int fmt_scale = (type_coord == 'X') ? m_FmtScale.x : m_FmtScale.y;
126
128 {
129 // no trailing zero format, we need to add missing zeros.
130 int digit_count = (type_coord == 'X') ? m_FmtLen.x : m_FmtLen.y;
131
132 // Truncate the extra digits if the len is more than expected
133 // because the conversion to internal units expect exactly
134 // digit_count digits. Alternatively, add some additional digits
135 // to pad out to the missing zeros
136 if( nbdigits < digit_count || ( aExcellonMode && ( nbdigits > digit_count ) ) )
137 decimal_scale = std::pow<double>( 10, digit_count - nbdigits );
138 }
139
140 double real_scale = scale_list[fmt_scale];
141
142 if( m_GerbMetric )
143 real_scale = real_scale / 25.4;
144
145 current_coord = KiROUND( val * real_scale * decimal_scale );
146 }
147
148 if( type_coord == 'X' )
149 {
150 pos.x = current_coord;
151 }
152 else if( type_coord == 'Y' )
153 {
154 pos.y = current_coord;
155 }
156 else if( type_coord == 'A' )
157 {
158 m_ArcRadius = current_coord;
160 }
161 }
162
163 if( m_Relative )
164 pos += m_CurrentPos;
165
166 m_CurrentPos = pos;
167 return pos;
168}
@ ARC_INFO_TYPE_RADIUS

References ARC_INFO_TYPE_RADIUS, IsNumber(), KiROUND(), GERBER_FILE_IMAGE::m_ArcRadius, GERBER_FILE_IMAGE::m_CurrentPos, GERBER_FILE_IMAGE::m_FmtLen, GERBER_FILE_IMAGE::m_FmtScale, GERBER_FILE_IMAGE::m_GerbMetric, GERBER_FILE_IMAGE::m_LastArcDataType, GERBER_FILE_IMAGE::m_NoTrailingZeros, GERBER_FILE_IMAGE::m_Relative, scale_list, scaletoIU(), VECTOR2< T >::x, and VECTOR2< T >::y.

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

◆ RemoveAttribute()

void GERBER_FILE_IMAGE::RemoveAttribute ( X2_ATTRIBUTE aAttribute)
inherited

Called when a TD command is found the Gerber file.

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

Parameters
aAttributeis the X2_ATTRIBUTE which stores the full command May be re-implemented for each derived class in order to handle all the types given by its member data.

Implementations should call inspector->Inspect() on types in aScanTypes, and may use IterateForward() to do so on lists of such data.

Parameters
inspectorAn INSPECTOR instance to use in the inspection.
testDataArbitrary data used by the inspector.
aScanTypesWhich KICAD_T types are of interest and the order in which they should be processed.
Returns
#SEARCH_RESULT SEARCH_QUIT if the Iterator is to stop the scan, else #SCAN_CONTINUE, and determined by the inspector.

Definition at line 356 of file gerber_file_image.cpp.

357{
358 /* Called when a %TD command is found
359 * Remove the attribute specified by the %TD command.
360 * is no attribute, all current attributes specified by the %TO and the %TA
361 * commands are cleared.
362 * if a attribute name is specified (for instance %TD.CN*%) is specified,
363 * only this attribute is cleared
364 */
365 wxString cmd = aAttribute.GetPrm( 0 );
367
368 if( cmd.IsEmpty() || cmd == wxT( ".AperFunction" ) )
369 m_AperFunction.Clear();
370}
void ClearAttribute(const wxString *aName)
Remove the net attribute specified by aName.
const wxString & GetPrm(int aIdx)

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

Referenced by GERBER_FILE_IMAGE::ExecuteRS274XCommand().

◆ RenderAsBitmap()

virtual bool EDA_ITEM::RenderAsBitmap ( double  aWorldScale) const
inlinevirtualinherited

Reimplemented in SCH_ITEM.

Definition at line 163 of file eda_item.h.

163{ return false; }

◆ Replace() [1/2]

virtual bool EDA_ITEM::Replace ( const EDA_SEARCH_DATA aSearchData,
void *  aAuxData = nullptr 
)
inlinevirtualinherited

Perform 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 LIB_TEXTBOX, SCH_LABEL_BASE, SCH_PIN, SCH_TEXT, SCH_TEXTBOX, SCH_FIELD, and SCH_SHEET_PIN.

Definition at line 409 of file eda_item.h.

410 {
411 return false;
412 }

◆ Replace() [2/2]

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

Perform 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 168 of file eda_item.cpp.

169{
170 wxString text = aText;
171 wxString searchText = aSearchData.findString;
172 wxString result;
173 bool replaced = false;
174
175 if( !aSearchData.matchCase )
176 {
177 text = text.Upper();
178 searchText = searchText.Upper();
179 }
180
181 int ii = 0;
182
183 while( ii < (int) text.length() )
184 {
185 int next = text.find( searchText, ii );
186
187 if( next == wxNOT_FOUND )
188 {
189 result += aText.Mid( ii, wxString::npos );
190 break;
191 }
192
193 if( next > ii )
194 result += aText.Mid( ii, next - ii );
195
196 ii = next;
197 next += searchText.length();
198
199 bool startOK;
200 bool endOK;
201
203 {
204 startOK = ( ii == 0 || !wxIsalnum( text.GetChar( ii - 1 ) ) );
205 endOK = ( next == (int) text.length() || !wxIsalnum( text.GetChar( next ) ) );
206 }
207 else
208 {
209 startOK = true;
210 endOK = true;
211 }
212
213 if( startOK && endOK )
214 {
215 result += aSearchData.replaceString;
216 replaced = true;
217 ii = next;
218 }
219 else
220 {
221 result += aText.GetChar( ii );
222 ii++;
223 }
224 }
225
226 aText = result;
227 return replaced;
228}
wxString replaceString

References EDA_SEARCH_DATA::findString, EDA_SEARCH_DATA::matchCase, EDA_SEARCH_DATA::matchMode, next(), EDA_SEARCH_DATA::replaceString, text, and WHOLEWORD.

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

◆ ResetDefaultValues()

void EXCELLON_IMAGE::ResetDefaultValues ( )
overridevirtual

Set all parameters to a default value, before reading a file.

Reimplemented from GERBER_FILE_IMAGE.

Definition at line 304 of file excellon_read_drill_file.cpp.

305{
307 SelectUnits( false, nullptr ); // Default unit = inch
308 m_hasFormat = false; // will be true if a Altium file containing
309 // the nn:mm file format is read
310
311 // Files using non decimal can use No Trailing zeros or No leading Zeros
312 // Unfortunately, the identifier (INCH,TZ or INCH,LZ for instance) is not
313 // always set in drill files.
314 // The option leading zeros looks like more frequent, so use this default
315 m_NoTrailingZeros = true;
316}

References m_hasFormat, GERBER_FILE_IMAGE::m_NoTrailingZeros, GERBER_FILE_IMAGE::ResetDefaultValues(), and SelectUnits().

Referenced by LoadFile().

◆ Select_Tool()

bool EXCELLON_IMAGE::Select_Tool ( char *&  text)
private

Definition at line 899 of file excellon_read_drill_file.cpp.

900{
901 // Select the tool from the command line Tn, with n = 1 ... TOOLS_MAX_COUNT - 1
902 // Because some drill file have an embedded TCODE definition (like T1C.008F0S0)
903 // in tool selection command, if the tool is not defined in list,
904 // and the definition is embedded, it will be entered in list
905 char * startline = text; // the tool id starts here.
906 int tool_id = CodeNumber( text );
907
908 // T0 is legal, but is not a selection tool. it is a special command
909 if( tool_id >= 0 )
910 {
911 int dcode_id = tool_id + FIRST_DCODE; // Remember: dcodes are >= FIRST_DCODE
912
913 if( dcode_id > (TOOLS_MAX_COUNT - 1) )
914 dcode_id = TOOLS_MAX_COUNT - 1;
915
916 m_Current_Tool = dcode_id;
917 D_CODE* currDcode = GetDCODE( dcode_id );
918
919 // if the tool does not exist, and the definition is embedded, create this tool
920 if( currDcode == nullptr && tool_id > 0 )
921 {
922 text = startline; // text starts at the beginning of the command
924 currDcode = GetDCODE( dcode_id );
925 }
926
927 // If the Tool is still not existing, create a dummy tool
928 if( !currDcode )
929 currDcode = GetDCODEOrCreate( dcode_id, true );
930
931 if( currDcode )
932 currDcode->m_InUse = true;
933 }
934
935 while( *text )
936 text++;
937
938 return tool_id >= 0;
939}

References GERBER_FILE_IMAGE::CodeNumber(), FIRST_DCODE, GERBER_FILE_IMAGE::GetDCODE(), GERBER_FILE_IMAGE::GetDCODEOrCreate(), GERBER_FILE_IMAGE::m_Current_Tool, D_CODE::m_InUse, readToolInformation(), text, and TOOLS_MAX_COUNT.

Referenced by LoadFile().

◆ SelectUnits()

void EXCELLON_IMAGE::SelectUnits ( bool  aMetric,
EXCELLON_DEFAULTS aDefaults 
)
private

Switch unit selection, and the coordinate format (nn:mm) if not yet set.

Definition at line 1056 of file excellon_read_drill_file.cpp.

1057{
1058 /* Coordinates are measured either in inch or metric (millimeters).
1059 * Inch coordinates are in six digits (00.0000) with increments
1060 * as small as 0.0001 (1/10,000).
1061 * Metric coordinates can be measured in microns (thousandths of a millimeter)
1062 * in one of the following three ways:
1063 * Five digit 10 micron resolution (000.00)
1064 * Six digit 10 micron resolution (0000.00)
1065 * Six digit micron resolution (000.000)
1066 *
1067 * Inches: Default fmt = 2.4 for X and Y axis: 6 digits with 0.0001 resolution
1068 * metric: Default fmt = 3.3 for X and Y axis: 6 digits, 1 micron resolution
1069 *
1070 * However some drill files do not use standard values.
1071 */
1072 if( aMetric )
1073 {
1074 m_GerbMetric = true;
1075
1076 if( !m_hasFormat )
1077 {
1078 if( aDefaults )
1079 {
1080 // number of digits in mantissa
1081 m_FmtScale.x = m_FmtScale.y = aDefaults->m_MmMantissaLen;
1082 // number of digits (mantissa+integer)
1083 m_FmtLen.x = m_FmtLen.y = aDefaults->m_MmIntegerLen
1084 + aDefaults->m_MmMantissaLen;
1085 }
1086 else
1087 {
1090 }
1091 }
1092 }
1093 else
1094 {
1095 m_GerbMetric = false;
1096
1097 if( !m_hasFormat )
1098 {
1099 if( aDefaults )
1100 {
1101 m_FmtScale.x = m_FmtScale.y = aDefaults->m_InchMantissaLen;
1102 m_FmtLen.x = m_FmtLen.y = aDefaults->m_InchIntegerLen
1103 + aDefaults->m_InchMantissaLen;
1104 }
1105 else
1106 {
1109 }
1110 }
1111 }
1112}
#define FMT_MANTISSA_INCH
#define FMT_INTEGER_MM
#define FMT_MANTISSA_MM
#define FMT_INTEGER_INCH

References FMT_INTEGER_INCH, FMT_INTEGER_MM, FMT_MANTISSA_INCH, FMT_MANTISSA_MM, GERBER_FILE_IMAGE::m_FmtLen, GERBER_FILE_IMAGE::m_FmtScale, GERBER_FILE_IMAGE::m_GerbMetric, m_hasFormat, EXCELLON_DEFAULTS::m_InchIntegerLen, EXCELLON_DEFAULTS::m_InchMantissaLen, EXCELLON_DEFAULTS::m_MmIntegerLen, and EXCELLON_DEFAULTS::m_MmMantissaLen.

Referenced by Execute_HEADER_And_M_Command(), LoadFile(), and ResetDefaultValues().

◆ Set() [1/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 }
void set(void *aObject, T aValue)
Definition: property.h:289

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

◆ Set() [2/3]

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

Definition at line 54 of file inspectable.h.

55 {
57 void* object = propMgr.TypeCast( this, TYPE_HASH( *this ), aProperty->OwnerHash() );
58
59 if( object )
60 aProperty->set<T>( object, aValue );
61
62 return object != nullptr;
63 }

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

◆ Set() [3/3]

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

Definition at line 42 of file inspectable.h.

43 {
45 void* object = propMgr.TypeCast( this, TYPE_HASH( *this ), aProperty->OwnerHash() );
46
47 if( object )
48 aProperty->setter( object, aValue );
49
50 return object != nullptr;
51 }
virtual void setter(void *aObject, wxAny &aValue)=0

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

Referenced by PCB_PROPERTIES_PANEL::valueChanged().

◆ SetBrightened()

◆ SetFlags()

void EDA_ITEM::SetFlags ( EDA_ITEM_FLAGS  aMask)
inlineinherited

Definition at line 139 of file eda_item.h.

139{ m_flags |= aMask; }

References EDA_ITEM::m_flags.

Referenced by SCH_EAGLE_PLUGIN::addBusEntries(), PCB_BASE_FRAME::AddFootprintToBoard(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), SCH_ALTIUM_PLUGIN::AddTextBox(), SCH_MOVE_TOOL::AlignElements(), PCB_CONTROL::AppendBoard(), SCH_EDIT_FRAME::BreakSegment(), SCH_EDIT_TOOL::BreakWire(), FOOTPRINT::BuildCourtyardCaches(), SCH_EDIT_TOOL::ChangeTextType(), GRAPHICS_CLEANER::cleanupShapes(), ConvertOutlineToPolygon(), SCH_EDIT_FRAME::ConvertPart(), SCH_DRAWING_TOOLS::createNewText(), SCH_DRAWING_TOOLS::createSheetPin(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCBNEW_JOBS_HANDLER::doFpExportSvg(), PCB_TOOL_BASE::doInteractiveItemPlacement(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), EDIT_TOOL::DragArcTrack(), KIGFX::SCH_PAINTER::draw(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), DRAWING_TOOL::DrawRectangle(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PCB_SELECTION_TOOL::EnterGroup(), PAD_TOOL::explodePad(), SCH_MOVE_TOOL::getConnectedDragItems(), SYMBOL_EDIT_FRAME::GetSymbolFromRedoList(), SYMBOL_EDIT_FRAME::GetSymbolFromUndoList(), EE_COLLECTOR::Inspect(), CONVERT_TOOL::makePolysFromChainedSegs(), CONVERT_TOOL::makePolysFromClosedGraphics(), CONVERT_TOOL::makePolysFromOpenGraphics(), SCH_SCREEN::MarkConnections(), TRACKS_CLEANER::mergeCollinearSegments(), SCH_MOVE_TOOL::moveItem(), SYMBOL_EDITOR_MOVE_TOOL::moveItem(), DIALOG_SYMBOL_PROPERTIES::OnUnitChoice(), KIGFX::ORIGIN_VIEWITEM::ORIGIN_VIEWITEM(), SCH_MOVE_TOOL::orthoLineDrag(), SCH_ALTIUM_PLUGIN::ParseBezier(), SCH_ALTIUM_PLUGIN::ParseBus(), SCH_ALTIUM_PLUGIN::ParseBusEntry(), SCH_ALTIUM_PLUGIN::ParseHarnessPort(), SCH_ALTIUM_PLUGIN::ParseJunction(), SCH_ALTIUM_PLUGIN::ParseLabel(), SCH_ALTIUM_PLUGIN::ParseLine(), SCH_ALTIUM_PLUGIN::ParseNetLabel(), SCH_ALTIUM_PLUGIN::ParseNoERC(), SCH_ALTIUM_PLUGIN::ParsePolygon(), SCH_ALTIUM_PLUGIN::ParsePolyline(), SCH_ALTIUM_PLUGIN::ParsePort(), SCH_ALTIUM_PLUGIN::ParseRectangle(), SCH_ALTIUM_PLUGIN::ParseRoundRectangle(), SCH_ALTIUM_PLUGIN::ParseSheetSymbol(), SCH_ALTIUM_PLUGIN::ParseSignalHarness(), SCH_ALTIUM_PLUGIN::ParseWire(), SCH_EDITOR_CONTROL::Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PL_DRAWING_TOOLS::PlaceItem(), DRAWING_TOOL::PlaceText(), SCH_SYMBOL::Plot(), BACK_ANNOTATE::processNetNameChange(), SCH_EDIT_FRAME::PutDataInPreviousState(), PCB_SELECTION_TOOL::RebuildSelection(), BOARD::Remove(), FOOTPRINT::Remove(), SCH_EDIT_TOOL::RepeatDrawItem(), SCH_EDIT_TOOL::Rotate(), SYMBOL_EDIT_FRAME::SaveCopyInUndoList(), EE_SELECTION_TOOL::SelectAll(), EE_SELECTION_TOOL::selectMultiple(), SCH_EDIT_FRAME::SelectUnit(), EDA_ITEM::SetBrightened(), EDA_ITEM::SetIsShownAsBitmap(), EDA_ITEM::SetModified(), EDA_ITEM::SetSelected(), SCH_DRAWING_TOOLS::SingleClickPlace(), BOARD_COMMIT::Stage(), SCH_LINE_WIRE_BUS_TOOL::startSegments(), DS_DATA_ITEM::SyncDrawItems(), DS_DATA_ITEM_BITMAP::SyncDrawItems(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_DIMENSION_PROPERTIES::TransferDataFromWindow(), DIALOG_TARGET_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace().

◆ SetForceVisible()

void EDA_ITEM::SetForceVisible ( bool  aEnable)
inlineinherited

Set and clear 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 199 of file eda_item.h.

199{ m_forceVisible = aEnable; }

References EDA_ITEM::m_forceVisible.

Referenced by SCH_FIND_REPLACE_TOOL::FindNext(), and SCH_FIND_REPLACE_TOOL::UpdateFind().

◆ SetIsShownAsBitmap()

void EDA_ITEM::SetIsShownAsBitmap ( bool  aBitmap)
inlineinherited

Definition at line 165 of file eda_item.h.

166 {
167 if( aBitmap )
169 else
171 }

References EDA_ITEM::ClearFlags(), IS_SHOWN_AS_BITMAP, and EDA_ITEM::SetFlags().

◆ SetModified()

◆ SetParent()

virtual void EDA_ITEM::SetParent ( EDA_ITEM aParent)
inlinevirtualinherited

Reimplemented in LIB_SYMBOL, and PCB_DIMENSION_BASE.

Definition at line 100 of file eda_item.h.

100{ m_parent = aParent; }

References EDA_ITEM::m_parent.

Referenced by BOARD::Add(), FOOTPRINT::Add(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), BOARD_NETLIST_UPDATER::addNewFootprint(), SCH_SHEET::AddPin(), PAD::AddPrimitive(), PAD::AddPrimitiveAnnotationBox(), PAD::AddPrimitiveArc(), PAD::AddPrimitiveCircle(), PAD::AddPrimitiveCurve(), PAD::AddPrimitivePoly(), PAD::AddPrimitiveRect(), PAD::AddPrimitiveSegment(), SYMBOL_EDITOR_CONTROL::AddSymbolToSchematic(), SCH_SCREEN::Append(), LIB_FIELD::Copy(), SYMBOL_EDIT_FRAME::CreateNewSymbol(), SCH_DRAWING_TOOLS::createNewText(), DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES(), DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES(), PCBNEW_JOBS_HANDLER::doFpExportSvg(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PCB_EDIT_FRAME::ExchangeFootprint(), LIB_SYMBOL::Flatten(), FOOTPRINT::FOOTPRINT(), PCB_PLUGIN::FootprintSave(), DISPLAY_FOOTPRINTS_FRAME::GetFootprint(), CADSTAR_SCH_ARCHIVE_LOADER::getKiCadSchText(), LIB_SYMBOL::LIB_SYMBOL(), SCH_LEGACY_PLUGIN_CACHE::loadAliases(), CADSTAR_SCH_ARCHIVE_LOADER::loadChildSheets(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard(), SCH_SEXPR_PLUGIN::loadHierarchy(), SCH_LEGACY_PLUGIN::loadHierarchy(), KI_TEST::LoadHierarchy(), LIB_SYMBOL::operator=(), FOOTPRINT::operator=(), PCB_PARSER::parseFOOTPRINT_unchecked(), SCH_SEXPR_PARSER::ParseSchematic(), SCH_SEXPR_PARSER::ParseSymbol(), SCH_EDITOR_CONTROL::Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PCB_CONTROL::Paste(), pasteFootprintItemsToFootprintEditor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), BACK_ANNOTATE::processNetNameChange(), BOARD_COMMIT::Push(), SCH_LIB_PLUGIN_CACHE::removeSymbol(), PCB_BASE_EDIT_FRAME::saveCopyInUndoList(), SaveCopyOfZones(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), CLIPBOARD_IO::SaveSelection(), SCH_SHEET_PIN::SCH_SHEET_PIN(), LIB_SYMBOL::SetFields(), PCB_DIMENSION_BASE::SetParent(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_LINE_WIRE_BUS_TOOL::startSegments(), SCH_LABEL_BASE::SwapData(), SCH_SHEET::SwapData(), SCH_SYMBOL::SwapData(), BOARD_ITEM::SwapItemData(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ SetPosition()

◆ SetSelected()

◆ SetState()

void EDA_ITEM::SetState ( EDA_ITEM_FLAGS  type,
bool  state 
)
inlineinherited

Definition at line 128 of file eda_item.h.

129 {
130 if( state )
131 m_status |= type; // state = ON or OFF
132 else
133 m_status &= ~type;
134 }

References EDA_ITEM::m_status.

Referenced by LEGACY_PLUGIN::loadTrackList(), and TRACKS_CLEANER::mergeCollinearSegments().

◆ SetStatus()

void EDA_ITEM::SetStatus ( EDA_ITEM_FLAGS  aStatus)
inlineinherited

Definition at line 137 of file eda_item.h.

137{ m_status = aStatus; }

References EDA_ITEM::m_status.

Referenced by BOARD_NETLIST_UPDATER::UpdateNetlist().

◆ Sort()

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

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 438 of file eda_item.h.

438{ return *aLeft < *aRight; }

◆ StepAndRepeatItem()

void GERBER_FILE_IMAGE::StepAndRepeatItem ( const GERBER_DRAW_ITEM aItem)
inherited

Gerber format has a command Step an Repeat.

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)

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
aItem= the item to repeat

Definition at line 277 of file gerber_file_image.cpp.

278{
279 if( GetLayerParams().m_XRepeatCount < 2 && GetLayerParams().m_YRepeatCount < 2 )
280 return; // Nothing to repeat
281
282 // Duplicate item:
283 for( int ii = 0; ii < GetLayerParams().m_XRepeatCount; ii++ )
284 {
285 for( int jj = 0; jj < GetLayerParams().m_YRepeatCount; jj++ )
286 {
287 // the first gerber item already exists (this is the template)
288 // create duplicate only if ii or jj > 0
289 if( jj == 0 && ii == 0 )
290 continue;
291
292 GERBER_DRAW_ITEM* dupItem = new GERBER_DRAW_ITEM( aItem );
293 VECTOR2I move_vector;
294 move_vector.x = scaletoIU( ii * GetLayerParams().m_StepForRepeat.x,
295 GetLayerParams().m_StepForRepeatMetric );
296 move_vector.y = scaletoIU( jj * GetLayerParams().m_StepForRepeat.y,
297 GetLayerParams().m_StepForRepeatMetric );
298 dupItem->MoveXY( move_vector );
299 AddItemToList( dupItem );
300 }
301 }
302}
void MoveXY(const VECTOR2I &aMoveVector)
Move this object.
int scaletoIU(double aCoord, bool isMetric)
Function scaletoIU converts a distance given in floating point to our internal units.

References GERBER_FILE_IMAGE::AddItemToList(), GERBER_FILE_IMAGE::GetLayerParams(), GERBER_LAYER::m_XRepeatCount, GERBER_LAYER::m_YRepeatCount, GERBER_DRAW_ITEM::MoveXY(), scaletoIU(), VECTOR2< T >::x, and VECTOR2< T >::y.

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

◆ TestFileIsExcellon()

bool EXCELLON_IMAGE::TestFileIsExcellon ( const wxString &  aFullFileName)
static

Performs a heuristics-based check of whether the file is an Excellon drill file.

Does not invoke the full parser.

Parameters
aFullFileNameaFullFileName is the full filename of the Excellon file.
Returns
True if drill file, false otherwise

Definition at line 344 of file excellon_read_drill_file.cpp.

345{
346 char* letter;
347 bool foundM48 = false;
348 bool foundM30 = false;
349 bool foundPercent = false;
350 bool foundT = false;
351 bool foundX = false;
352 bool foundY = false;
353
354 FILE* file = wxFopen( aFullFileName, "rb" );
355
356 if( file == nullptr )
357 return false;
358
359 FILE_LINE_READER excellonReader( file, aFullFileName );
360
361 try
362 {
363 while( true )
364 {
365 if( excellonReader.ReadLine() == nullptr )
366 break;
367
368 // Remove all whitespace from the beginning and end
369 char* line = StrPurge( excellonReader.Line() );
370
371 // Skip empty lines
372 if( *line == 0 )
373 continue;
374
375 // Check that file is not binary (non-printing chars)
376 for( size_t i = 0; i < strlen( line ); i++ )
377 {
378 if( !isascii( line[i] ) )
379 return false;
380 }
381
382 // We don't want to look for any commands after a comment so
383 // just end the line early if we find a comment
384 char* buf = strstr( line, ";" );
385 if( buf != nullptr )
386 *buf = 0;
387
388 // Check for M48 = start of drill header
389 if( strstr( line, "M48" ) )
390 foundM48 = true;
391
392 // Check for M30 = end of drill program
393 if( strstr( line, "M30" ) )
394 if( foundPercent )
395 foundM30 = true; // Found M30 after % = good
396
397 // Check for % on its own line at end of header
398 if( ( letter = strstr( line, "%" ) ) != nullptr )
399 if( ( letter[1] == '\r' ) || ( letter[1] == '\n' ) )
400 foundPercent = true;
401
402 // Check for T<number>
403 if( ( letter = strstr( line, "T" ) ) != nullptr )
404 {
405 if( !foundT && ( foundX || foundY ) )
406 foundT = false; /* Found first T after X or Y */
407 else
408 {
409 // verify next char is digit
410 if( isdigit( letter[1] ) )
411 foundT = true;
412 }
413 }
414
415 // look for X<number> or Y<number>
416 if( ( letter = strstr( line, "X" ) ) != nullptr )
417 if( isdigit( letter[1] ) )
418 foundX = true;
419
420 if( ( letter = strstr( line, "Y" ) ) != nullptr )
421 if( isdigit( letter[1] ) )
422 foundY = true;
423 }
424 }
425 catch( IO_ERROR& )
426 {
427 return false;
428 }
429
430
431 /* Now form logical expression determining if this is a drill file */
432 if( ( ( foundX || foundY ) && foundT ) && ( foundM48 || ( foundPercent && foundM30 ) ) )
433 return true;
434 else if( foundM48 && foundT && foundPercent && foundM30 )
435 /* Pathological case of drill file with valid header
436 and EOF but no drill XY locations. */
437 return true;
438
439 return false;
440}
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:76

References LINE_READER::Line(), FILE_LINE_READER::ReadLine(), and StrPurge().

Referenced by GERBVIEW_FRAME::LoadListOfGerberAndDrillFiles(), and GERBVIEW_FRAME::unarchiveFiles().

◆ TestFileIsRS274()

bool GERBER_FILE_IMAGE::TestFileIsRS274 ( const wxString &  aFullFileName)
staticinherited

Performs a heuristics-based check of whether the file is an RS274 gerber file.

Does not invoke the full parser.

Parameters
aFullFileNameaFullFileName is the full filename of the gerber file.
Returns
True if RS274 file, false otherwise

Definition at line 139 of file readgerb.cpp.

140{
141 char* letter = nullptr;
142 bool foundADD = false;
143 bool foundD0 = false;
144 bool foundD2 = false;
145 bool foundM0 = false;
146 bool foundM2 = false;
147 bool foundStar = false;
148 bool foundX = false;
149 bool foundY = false;
150
151 try
152 {
153 FILE_LINE_READER gerberReader( aFullFileName );
154
155 while( gerberReader.ReadLine() )
156 {
157 // Remove all whitespace from the beginning and end
158 char* line = StrPurge( gerberReader.Line() );
159
160 // Skip empty lines
161 if( *line == 0 )
162 continue;
163
164 // Check that file is not binary (non-printing chars)
165 for( size_t i = 0; i < strlen( line ); i++ )
166 {
167 if( !isascii( line[i] ) )
168 return false;
169 }
170
171 if( strstr( line, "%ADD" ) )
172 foundADD = true;
173
174 if( strstr( line, "D00" ) || strstr( line, "D0" ) )
175 foundD0 = true;
176
177 if( strstr( line, "D02" ) || strstr( line, "D2" ) )
178 foundD2 = true;
179
180 if( strstr( line, "M00" ) || strstr( line, "M0" ) )
181 foundM0 = true;
182
183 if( strstr( line, "M02" ) || strstr( line, "M2" ) )
184 foundM2 = true;
185
186 if( strstr( line, "*" ) )
187 foundStar = true;
188
189 /* look for X<number> or Y<number> */
190 if( ( letter = strstr( line, "X" ) ) != nullptr )
191 {
192 if( isdigit( letter[1] ) )
193 foundX = true;
194 }
195
196 if( ( letter = strstr( line, "Y" ) ) != nullptr )
197 {
198 if( isdigit( letter[1] ) )
199 foundY = true;
200 }
201 }
202 }
203 catch( IO_ERROR& )
204 {
205 return false;
206 }
207
208 // RS-274X
209 if( ( foundD0 || foundD2 || foundM0 || foundM2 ) && foundADD && foundStar
210 && ( foundX || foundY ) )
211 {
212 return true;
213 }
214 // RS-274D. Could be folded into the expression above, but someday
215 // we might want to test for them separately.
216 else if( ( foundD0 || foundD2 || foundM0 || foundM2 ) && !foundADD && foundStar
217 && ( foundX || foundY ) )
218 {
219 return true;
220 }
221
222
223 return false;
224}

References LINE_READER::Line(), FILE_LINE_READER::ReadLine(), and StrPurge().

Referenced by GERBVIEW_FRAME::LoadListOfGerberAndDrillFiles(), and GERBVIEW_FRAME::unarchiveFiles().

◆ Type()

KICAD_T EDA_ITEM::Type ( ) const
inlineinherited

Returns the type of object.

This attribute should never be changed after a ctor sets it, so there is no public "setter" method.

Returns
the type of object.

Definition at line 97 of file eda_item.h.

97{ return m_structType; }

References EDA_ITEM::m_structTy