diff --git a/pcbnew/exporters/exporter_vrml.h b/pcbnew/exporters/exporter_vrml.h index 3f9d64bc7a..146b683963 100644 --- a/pcbnew/exporters/exporter_vrml.h +++ b/pcbnew/exporters/exporter_vrml.h @@ -102,60 +102,7 @@ struct VRML_COLOR // Handle the board ans its board items to convert them to a VRML representation: class EXPORTER_PCB_VRML { -private: - VRML_COLOR vrml_colors_list[VRML_COLOR_LAST]; - double m_layer_z[PCB_LAYER_ID_COUNT]; - SHAPE_POLY_SET m_pcbOutlines; // stores the board main outlines - - int m_precision; // precision factor when exportin fp shapes - // to separate files - SGNODE* m_sgmaterial[VRML_COLOR_LAST]; - public: - IFSG_TRANSFORM m_OutputPCB; - VRML_LAYER m_holes; - VRML_LAYER m_3D_board; - VRML_LAYER m_top_copper; - VRML_LAYER m_bot_copper; - VRML_LAYER m_top_silk; - VRML_LAYER m_bot_silk; - VRML_LAYER m_top_soldermask; - VRML_LAYER m_bot_soldermask; - VRML_LAYER m_top_paste; - VRML_LAYER m_bot_paste; - VRML_LAYER m_plated_holes; - - std::list< SGNODE* > m_components; - S3D_CACHE* m_Cache3Dmodels; - BOARD* m_Pcb; - - /* true to use VRML inline{} syntax for footprint 3D models, like: - * Inline { url "F:/tmp/pic_programmer/shapes3D/DIP-18_W7.62mm_Socket.wrl" } - * false to merge VRML 3D modeles in the .wrl board file - */ - bool m_UseInlineModelsInBrdfile; - - // 3D subdirectory to copy footprint vrml 3D models when not merged in board file - wxString m_Subdir3DFpModels; - - // true to use relative paths in VRML inline{} for footprint 3D models - // used only if m_UseInlineModelsInBrdfile = true - bool m_UseRelPathIn3DModelFilename; - - // true to reuse component definitions - bool m_ReuseDef; - - // scaling from 0.1 inch to desired VRML unit - double m_WorldScale = 1.0; - - // scaling from mm to desired VRML world scale - double m_BoardToVrmlScale; - - double m_tx; // global translation along X - double m_ty; // global translation along Y - - double m_brd_thickness; // depth of the PCB - EXPORTER_PCB_VRML(); ~EXPORTER_PCB_VRML(); @@ -202,7 +149,7 @@ public: void ExportVrmlPadHole( PAD* aPad ); - // Exoprt a set of polygons without holes. + // Export a set of polygons without holes. // Polygons in SHAPE_POLY_SET must be without hole, i.e. holes must be linked // previously to their main outline. void ExportVrmlPolygonSet( VRML_LAYER* aVlayer, const SHAPE_POLY_SET& aOutlines ); @@ -228,4 +175,58 @@ private: VRML_LAYER* layer, double aHeight, bool aTopPlane ); SGNODE* getSGColor( VRML_COLOR_INDEX colorIdx ); + +public: + IFSG_TRANSFORM m_OutputPCB; + VRML_LAYER m_holes; + VRML_LAYER m_3D_board; + VRML_LAYER m_top_copper; + VRML_LAYER m_bot_copper; + VRML_LAYER m_top_silk; + VRML_LAYER m_bot_silk; + VRML_LAYER m_top_soldermask; + VRML_LAYER m_bot_soldermask; + VRML_LAYER m_top_paste; + VRML_LAYER m_bot_paste; + VRML_LAYER m_plated_holes; + + std::list< SGNODE* > m_components; + S3D_CACHE* m_Cache3Dmodels; + BOARD* m_Pcb; + + /* true to use VRML inline{} syntax for footprint 3D models, like: + * Inline { url "F:/tmp/pic_programmer/shapes3D/DIP-18_W7.62mm_Socket.wrl" } + * false to merge VRML 3D modules in the .wrl board file + */ + bool m_UseInlineModelsInBrdfile; + + // 3D subdirectory to copy footprint vrml 3D models when not merged in board file + wxString m_Subdir3DFpModels; + + // true to use relative paths in VRML inline{} for footprint 3D models + // used only if m_UseInlineModelsInBrdfile = true + bool m_UseRelPathIn3DModelFilename; + + // true to reuse component definitions + bool m_ReuseDef; + + // scaling from 0.1 inch to desired VRML unit + double m_WorldScale = 1.0; + + // scaling from mm to desired VRML world scale + double m_BoardToVrmlScale; + + double m_tx; // global translation along X + double m_ty; // global translation along Y + + double m_brd_thickness; // depth of the PCB + +private: + VRML_COLOR vrml_colors_list[VRML_COLOR_LAST]; + double m_layer_z[PCB_LAYER_ID_COUNT]; + SHAPE_POLY_SET m_pcbOutlines; // stores the board main outlines + + int m_precision; // precision factor when exporting fp shapes + // to separate files + SGNODE* m_sgmaterial[VRML_COLOR_LAST]; }; diff --git a/pcbnew/exporters/gendrill_Excellon_writer.h b/pcbnew/exporters/gendrill_Excellon_writer.h index 4f32c22648..fa4b624caf 100644 --- a/pcbnew/exporters/gendrill_Excellon_writer.h +++ b/pcbnew/exporters/gendrill_Excellon_writer.h @@ -39,19 +39,10 @@ class OUTPUTFORMATTER; /** - * EXCELLON_WRITER is a class mainly used to create Excellon drill files - * However, this class is also used to create drill maps and drill report + * Create Excellon drill, drill map, and drill report files. */ class EXCELLON_WRITER: public GENDRILL_WRITER_BASE { -private: - FILE* m_file; // The output file - bool m_minimalHeader; // True to use minimal header - bool m_mirror; - bool m_useRouteModeForOval; // True to use a route command for oval holes - // False to use a G85 canned mode for oval holes - - public: EXCELLON_WRITER( BOARD* aPcb ); @@ -60,8 +51,7 @@ public: } /** - * Return the plot offset (usually the position - * of the auxiliary axis + * Return the plot offset (usually the position of the auxiliary axis. */ wxPoint GetOffset() { return m_offset; } @@ -74,28 +64,27 @@ public: } /** - * Function SetFormat - * Initialize internal parameters to match the given format - * @param aMetric = true for metric coordinates, false for imperial units - * @param aZerosFmt = DECIMAL_FORMAT, SUPPRESS_LEADING, SUPPRESS_TRAILING, KEEP_ZEROS - * @param aLeftDigits = number of digits for integer part of coordinates - * if <= 0 (default), a suitable value will be used, depending on units - * @param aRightDigits = number of digits for mantissa part of coordinates - * if <= 0 (default), a suitable value will be used, depending on units + * Initialize internal parameters to match the given format. + * + * @param aMetric set to true for metric coordinates, false for imperial units. + * @param aZerosFmt is the zero format DECIMAL_FORMAT, SUPPRESS_LEADING, SUPPRESS_TRAILING, + * or KEEP_ZEROS. + * @param aLeftDigits is the number of digits for integer part of coordinates + * if <= 0 (default), a suitable value will be used, depending on units. + * @param aRightDigits is number of digits for mantissa part of coordinates + * if <= 0 (default), a suitable value will be used, depending on units. */ void SetFormat( bool aMetric, ZEROS_FMT aZerosFmt = DECIMAL_FORMAT, int aLeftDigits = 0, int aRightDigits = 0 ); - - /** - * Function SetOptions - * Initialize internal parameters to match drill options - * @param aMirror = true to create mirrored coordinates (Y coordinates negated) - * @param aMinimalHeader = true to use a minimal header (no comments, no info) - * @param aOffset = drill coordinates offset - * @param aMerge_PTH_NPTH = true to create only one file containing PTH and NPTH - * false to create 2 separate files : one for PTH and one for NPTH + * Initialize internal parameters to match drill options. + * + * @param aMirror set to true to create mirrored coordinates (Y coordinates negated). + * @param aMinimalHeader set to true to use a minimal header (no comments, no info). + * @param aOffset is the drill coordinates offset. + * @param aMerge_PTH_NPTH set to true to create only one file containing PTH and NPTH + * false to create 2 separate files : one for PTH and one for NPTH. */ void SetOptions( bool aMirror, bool aMinimalHeader, wxPoint aOffset, bool aMerge_PTH_NPTH ) { @@ -106,33 +95,34 @@ public: } /** - * Function CreateDrillandMapFilesSet - * Creates the full set of Excellon drill file for the board - * filenames are computed from the board name, and layers id - * @param aPlotDirectory = the output folder - * @param aGenDrill = true to generate the EXCELLON drill file - * @param aGenMap = true to generate a drill map file - * @param aReporter = a REPORTER to return activity or any message (can be NULL) + * Create the full set of Excellon drill file for the board. + * + * File names are computed from the board name and layer ID. + * + * @param aPlotDirectory is the output folder. + * @param aGenDrill set to true to generate the EXCELLON drill file. + * @param aGenMap set to true to generate a drill map file. + * @param aReporter is a #REPORTER to return activity or any message (can be NULL) */ - void CreateDrillandMapFilesSet( const wxString& aPlotDirectory, - bool aGenDrill, bool aGenMap, - REPORTER * aReporter = NULL ); - + void CreateDrillandMapFilesSet( const wxString& aPlotDirectory, bool aGenDrill, bool aGenMap, + REPORTER* aReporter = nullptr ); private: /** - * Function CreateDrillFile - * Creates an Excellon drill file - * @param aFile = an opened file to write to will be closed by CreateDrillFile - * @param aLayerPair = the layer pair for the current holes - * @param aHolesType = the holes type (PTH, NPTH, mixed) - * @return hole count + * Create an Excellon drill file. + * + * @param aFile is an opened file to write to will be closed by CreateDrillFile. + * @param aLayerPair is the layer pair for the current holes. + * @param aHolesType is the holes type (PTH, NPTH, mixed). + * @return the hole count. */ - int createDrillFile( FILE * aFile, DRILL_LAYER_PAIR aLayerPair, - TYPE_FILE aHolesType ); + int createDrillFile( FILE* aFile, DRILL_LAYER_PAIR aLayerPair, TYPE_FILE aHolesType ); - /** Print the DRILL file header. The full header is somethink like: + /** + * Print the DRILL file header. + * + * The full header is something like: * M48 * ;DRILL file {PCBNEW (2007-11-29-b)} date 17/1/2008-21:02:35 * ;FORMAT={ / absolute / / } @@ -141,25 +131,31 @@ private: * ; #@! TF.GenerationSoftware,Kicad,Pcbnew,2017.04 * FMAT,2 * INCH,TZ - * @param aLayerPair = the layer pair for the current holes - * @param aHolesType = the holes type in file (PTH, NPTH, mixed) + * + * @param aLayerPair is the layer pair for the current holes. + * @param aHolesType is the holes type in file (PTH, NPTH, mixed). */ void writeEXCELLONHeader( DRILL_LAYER_PAIR aLayerPair, TYPE_FILE aHolesType ); void writeEXCELLONEndOfFile(); - /** Created a line like: - * X48000Y19500 - * According to the selected format + /** + * Create a line like according to the selected format. */ void writeCoordinates( char* aLine, double aCoordX, double aCoordY ); /** - * write a comment string giving the hole attribute like - * "; #@! TO.P,viatype\n" - * @param aAttribute is the hole attribute + * Write a comment string giving the hole attribute. + * + * @param aAttribute is the hole attribute. */ void writeHoleAttribute( HOLE_ATTRIBUTE aAttribute ); + + FILE* m_file; // The output file + bool m_minimalHeader; // True to use minimal header + bool m_mirror; + bool m_useRouteModeForOval; // True to use a route command for oval holes + // False to use a G85 canned mode for oval holes }; #endif // #ifndef _GENDRILL_EXCELLON_WRITER_ diff --git a/pcbnew/exporters/gendrill_file_writer_base.h b/pcbnew/exporters/gendrill_file_writer_base.h index 9ed11f50dd..010a8ff648 100644 --- a/pcbnew/exporters/gendrill_file_writer_base.h +++ b/pcbnew/exporters/gendrill_file_writer_base.h @@ -74,30 +74,15 @@ public: }; -/* the HOLE_INFO class handle hole which must be drilled (diameter, position and layers) - * For buried or micro vias, the hole is not on all layers. - * So we must generate a drill file for each layer pair (adjacent layers) - * Not plated holes are always through holes, and must be output on a specific drill file - * because they are drilled after the Pcb process is finished. +/** + * Handle hole which must be drilled (diameter, position and layers). + * + * For buried or micro vias, the hole is not on all layers. So we must generate a drill file + * for each layer pair (adjacent layers). Not plated holes are always through holes, and must + * be output on a specific drill file because they are drilled after the PCB process is finished. */ - class HOLE_INFO { -public: - BOARD_ITEM* m_ItemParent; // The pad or via parent of this hole - int m_Hole_Diameter; // hole value, and for oblong: min(hole size x, hole size y) - int m_Tool_Reference; // Tool reference for this hole = 1 ... n (values <=0 must not be used) - wxSize m_Hole_Size; // hole size for oblong holes - double m_Hole_Orient; // Hole rotation (= pad rotation) for oblong holes - int m_Hole_Shape; // hole shape: round (0) or oval (1) - wxPoint m_Hole_Pos; // hole position - PCB_LAYER_ID m_Hole_Bottom_Layer; // hole ending layer (usually back layer) - PCB_LAYER_ID m_Hole_Top_Layer; // hole starting layer (usually front layer): - // m_Hole_Top_Layer < m_Hole_Bottom_Layer - bool m_Hole_NotPlated; // hole not plated. Must be in a specific drill file or section - HOLE_ATTRIBUTE m_HoleAttribute; // Attribute, used in Excellon drill file and to sort holes - // by type. - public: HOLE_INFO() { @@ -111,17 +96,32 @@ public: m_Hole_Top_Layer = F_Cu; m_HoleAttribute = HOLE_ATTRIBUTE::HOLE_UNKNOWN; } + +public: + BOARD_ITEM* m_ItemParent; // The pad or via parent of this hole + int m_Hole_Diameter; // hole value, and for oblong: min(hole size x, hole + // size y). + int m_Tool_Reference; // Tool reference for this hole = 1 ... n (values <=0 + // must not be used). + wxSize m_Hole_Size; // hole size for oblong holes + double m_Hole_Orient; // Hole rotation (= pad rotation) for oblong holes + int m_Hole_Shape; // hole shape: round (0) or oval (1) + wxPoint m_Hole_Pos; // hole position + PCB_LAYER_ID m_Hole_Bottom_Layer; // hole ending layer (usually back layer) + PCB_LAYER_ID m_Hole_Top_Layer; // hole starting layer (usually front layer): + // m_Hole_Top_Layer < m_Hole_Bottom_Layer + bool m_Hole_NotPlated; // hole not plated. Must be in a specific drill file or + // section. + HOLE_ATTRIBUTE m_HoleAttribute; // Attribute, used in Excellon drill file and to sort holes + // by type. }; -/* the DRILL_PRECISION helper class to handle drill precision format in excellon files +/** + * Helper to handle drill precision format in excellon files. */ class DRILL_PRECISION { -public: - int m_Lhs; // Left digit number (integer value of coordinates) - int m_Rhs; // Right digit number (decimal value of coordinates) - public: DRILL_PRECISION( int l = 2, int r = 4 ) { @@ -136,16 +136,18 @@ public: text << m_Lhs << wxT( ":" ) << m_Rhs; return text; } + + int m_Lhs; // Left digit number (integer value of coordinates) + int m_Rhs; // Right digit number (decimal value of coordinates) }; typedef std::pair DRILL_LAYER_PAIR; /** - * GENDRILL_WRITER_BASE is a class to create drill maps and drill report, - * and a helper class to created drill files. - * drill files are created by specialized derived classes, depenfing on the - * file format. + * Create drill maps and drill reports and drill files. + * + * Drill files are created by specialized derived classes, depending on the file format. */ class GENDRILL_WRITER_BASE { @@ -153,7 +155,7 @@ public: enum ZEROS_FMT { // Zero format in coordinates DECIMAL_FORMAT, // Floating point coordinates SUPPRESS_LEADING, // Suppress leading zeros - SUPPRESS_TRAILING, // Suppress trainling zeros + SUPPRESS_TRAILING, // Suppress trailing zeros KEEP_ZEROS // keep zeros }; @@ -163,67 +165,38 @@ public: MIXED_FILE // PHT+NPTH (mixed) }; -protected: - BOARD* m_pcb; - wxString m_drillFileExtension; // .drl or .gbr, depending on format - bool m_unitsMetric; // true = mm, false = inches - ZEROS_FMT m_zeroFormat; // the zero format option for output file - DRILL_PRECISION m_precision; // The current coordinate precision (not used in decimal format) - double m_conversionUnits; // scaling factor to convert the board unites to - // Excellon/Gerber units (i.e inches or mm) - wxPoint m_offset; // Drill offset coordinates - bool m_merge_PTH_NPTH; // True to generate only one drill file - std::vector m_holeListBuffer; // Buffer containing holes - std::vector m_toolListBuffer; // Buffer containing tools - - PLOT_FORMAT m_mapFileFmt; // the format of the map drill file, - // if this map is needed - const PAGE_INFO* m_pageInfo; // the page info used to plot drill maps - // If NULL, use a A4 page format - // This Ctor is protected. - // Use derived classes to build a fully initialized GENDRILL_WRITER_BASE class. - GENDRILL_WRITER_BASE( BOARD* aPcb ) - { - m_pcb = aPcb; - m_conversionUnits = 1.0; - m_unitsMetric = true; - m_mapFileFmt = PLOT_FORMAT::PDF; - m_pageInfo = NULL; - m_merge_PTH_NPTH = false; - m_zeroFormat = DECIMAL_FORMAT; - } - -public: virtual ~GENDRILL_WRITER_BASE() { } /** - * set the option to make separate drill files for PTH and NPTH - * @param aMerge = true to make only one file containing PTH and NPTH - * = false to create 2 separate files + * Set the option to make separate drill files for PTH and NPTH. + * + * @param aMerge set to true to make only one file containing PTH and NPTH or false to + * create 2 separate files. */ void SetMergeOption( bool aMerge ) { m_merge_PTH_NPTH = aMerge; } /** - * Return the plot offset (usually the position - * of the auxiliary axis + * Return the plot offset (usually the position of the auxiliary axis. */ wxPoint GetOffset() { return m_offset; } /** - * Sets the page info used to plot drill maps - * If NULL, a A4 page format will be used - * @param aPageInfo = a reference to the page info, usually used to plot/display the board + * Set the page info used to plot drill maps. + * + * If NULL, a A4 page format will be used. + * + * @param aPageInfo is a reference to the page info, usually used to plot/display the board. */ void SetPageInfo( const PAGE_INFO* aPageInfo ) { m_pageInfo = aPageInfo; } /** - * Initialize the format for the drill map file - * @param aMapFmt = a PlotFormat value (one of - * PLOT_FORMAT_HPGL, PLOT_FORMAT_POST, PLOT_FORMAT_GERBER, - * PLOT_FORMAT_DXF, PLOT_FORMAT_SVG, PLOT_FORMAT_PDF - * the most useful are PLOT_FORMAT_PDF and PLOT_FORMAT_POST + * Initialize the format for the drill map file. + * + * @param aMapFmt a PlotFormat value (one of PLOT_FORMAT_HPGL, PLOT_FORMAT_POST, + * PLOT_FORMAT_GERBER, PLOT_FORMAT_DXF, PLOT_FORMAT_SVG, PLOT_FORMAT_PDF + * the most useful are PLOT_FORMAT_PDF and PLOT_FORMAT_POST. */ void SetMapFileFormat( PLOT_FORMAT aMapFmt ) { @@ -231,21 +204,20 @@ public: } /** - * Function CreateMapFilesSet - * Creates the full set of map files for the board, in PS, PDF ... format - * (use SetMapFileFormat() to select the format) - * filenames are computed from the board name, and layers id - * @param aPlotDirectory = the output folder - * @param aReporter = a REPORTER to return activity or any message (can be NULL) + * Create the full set of map files for the board, in PS, PDF ... format + * (use SetMapFileFormat() to select the format). + * + * File names are computed from the board name and layer ID. + * + * @param aPlotDirectory is the output folder. + * @param aReporter is a REPORTER to return activity or any message (can be NULL) */ - void CreateMapFilesSet( const wxString& aPlotDirectory, REPORTER* aReporter = NULL ); + void CreateMapFilesSet( const wxString& aPlotDirectory, REPORTER* aReporter = nullptr ); /** - * Function GenDrillReportFile - * Create a plain text report file giving a list of drill values and drill count - * for through holes, oblong holes, and for buried vias, - * drill values and drill count per layer pair - * there is only one report for all drill files even when buried or blinds vias exist + * Create a plain text report file giving a list of drill values and drill count for through + * holes, oblong holes, and for buried vias, drill values and drill count per layer pair + * there is only one report for all drill files even when buried or blinds vias exist. * * Here is a sample created by this function: * Drill report for F:/tmp/interf_u/interf_u.brd @@ -287,51 +259,49 @@ public: * * Total unplated holes count 1 * - * @param aFullFileName : the name of the file to create - * - * @return true if the file is created + * @param aFullFileName is the name of the file to create. + * @return true if the file is created. */ bool GenDrillReportFile( const wxString& aFullFileName ); protected: /** - * Function GenDrillMapFile * Plot a map of drill marks for holes. - * Hole list must be created before calling this function, by buildHolesList() - * for the right holes set (PTH, NPTH, buried/blind vias ...) - * the paper sheet to use to plot the map is set in m_pageInfo - * ( calls SetPageInfo() to set it ) - * if NULL, A4 format will be used - * @param aFullFileName : the full filename of the map file to create, - * @param aFormat : one of the supported plot formats (see enum PlotFormat ) + * + * Hole list must be created before calling this function, by buildHolesList() for the + * right holes set (PTH, NPTH, buried/blind vias ...) the paper sheet to use to plot the + * map is set in m_pageInfo ( calls SetPageInfo() to set it ). If NULL, A4 format will + * be used. + * + * @param aFullFileName is the full filename of the map file to create. + * @param aFormat is one of the supported plot formats (see enum PlotFormat ). */ bool genDrillMapFile( const wxString& aFullFileName, PLOT_FORMAT aFormat ); /** - * Function BuildHolesList - * Create the list of holes and tools for a given board - * The list is sorted by increasing drill size. - * Only holes included within aLayerPair are listed. - * If aLayerPair identifies with [F_Cu, B_Cu], then - * pad holes are always included also. + * Create the list of holes and tools for a given board. + * + * The list is sorted by increasing drill size. Only holes included within aLayerPair + * are listed. If aLayerPair identifies with [F_Cu, B_Cu], then pad holes are always + * included also. * * @param aLayerPair is an inclusive range of layers. * @param aGenerateNPTH_list : * true to create NPTH only list (with no plated holes) * false to created plated holes list (with no NPTH ) */ - void buildHolesList( DRILL_LAYER_PAIR aLayerPair, - bool aGenerateNPTH_list ); + void buildHolesList( DRILL_LAYER_PAIR aLayerPair, bool aGenerateNPTH_list ); int getHolesCount() const { return m_holeListBuffer.size(); } - /** Helper function. - * Writes the drill marks in HPGL, POSTSCRIPT or other supported formats - * Each hole size has a symbol (circle, cross X, cross + ...) up to - * PLOTTER::MARKER_COUNT different values. - * If more than PLOTTER::MARKER_COUNT different values, - * these other values share the same mark shape - * @param aPlotter = a PLOTTER instance (HPGL, POSTSCRIPT ... plotter). + /** + * Write the drill marks in HPGL, POSTSCRIPT or other supported formats/ + * + * Each hole size has a symbol (circle, cross X, cross + ...) up to PLOTTER::MARKER_COUNT + * different values. If more than PLOTTER::MARKER_COUNT different values, these other + * values share the same mark shape. + * + * @param aPlotter is a PLOTTER instance (HPGL, POSTSCRIPT ... plotter). */ bool plotDrillMarks( PLOTTER* aPlotter ); @@ -339,15 +309,14 @@ protected: std::vector getUniqueLayerPairs() const; /** - * Function printToolSummary - * prints m_toolListBuffer[] tools to aOut and returns total hole count. - * @param aOut = the current OUTPUTFORMATTER to print summary - * @param aSummaryNPTH = true to print summary for NPTH, false for PTH + * Print m_toolListBuffer[] tools to aOut and returns total hole count. + * + * @param aOut is the current OUTPUTFORMATTER to print summary. + * @param aSummaryNPTH is true to print summary for NPTH, false for PTH. */ unsigned printToolSummary( OUTPUTFORMATTER& aOut, bool aSummaryNPTH ) const; /** - * minor helper function. * @return a string from aPair to identify the layer layer pair. * string is ""-"" * used to generate a filename for drill files and drill maps @@ -355,39 +324,71 @@ protected: const std::string layerPairName( DRILL_LAYER_PAIR aPair ) const; /** - * minor helper function. * @return a string from aLayer to identify the layer. * string are "front" "back" or "in" */ const std::string layerName( PCB_LAYER_ID aLayer ) const; /** + * @param aPair is the layer pair. + * @param aNPTH use true to generate the filename of NPTH holes. + * @param aMerge_PTH_NPTH use true to generate the filename of a file which containd both + * NPH and NPTH holes. * @return a filename which identify the drill file function. * it is the board name with the layer pair names added, and for separate * (PTH and NPTH) files, "-NPH" or "-NPTH" added - * @param aPair = the layer pair - * @param aNPTH = true to generate the filename of NPTH holes - * @param aMerge_PTH_NPTH = true to generate the filename of a file which containd both - * NPH and NPTH holes */ virtual const wxString getDrillFileName( DRILL_LAYER_PAIR aPair, bool aNPTH, bool aMerge_PTH_NPTH ) const; /** - * @return a wxString containing the .FileFunction attribute. - * the standard X2 FileFunction for drill files is - * %TF.FileFunction,Plated[NonPlated],layer1num,layer2num,PTH[NPTH][Blind][Buried],Drill[Route][Mixed]*% - * There is no X1 version, as the Gerber drill files uses only X2 format - * There is a compatible NC drill version. * @param aLayerPair is the layer pair (Drill from rom first layer to second layer) * @param aHoleType is type of drill file (PTH, NPTH, mixed) * @param aCompatNCdrill is true when generating NC (Excellon) compatible drill file + * @return a wxString containing the .FileFunction attribute. + * the standard X2 FileFunction for drill files is + * %TF.FileFunction,Plated[NonPlated],layer1num,layer2num,PTH[NPTH][Blind][Buried], + * Drill[Route][Mixed]*% + * There is no X1 version, as the Gerber drill files uses only X2 format + * There is a compatible NC drill version. */ const wxString BuildFileFunctionAttributeString( DRILL_LAYER_PAIR aLayerPair, TYPE_FILE aHoleType, bool aCompatNCdrill = false ) const; + + +protected: + // Use derived classes to build a fully initialized GENDRILL_WRITER_BASE class. + GENDRILL_WRITER_BASE( BOARD* aPcb ) + { + m_pcb = aPcb; + m_conversionUnits = 1.0; + m_unitsMetric = true; + m_mapFileFmt = PLOT_FORMAT::PDF; + m_pageInfo = nullptr; + m_merge_PTH_NPTH = false; + m_zeroFormat = DECIMAL_FORMAT; + } + + BOARD* m_pcb; + wxString m_drillFileExtension; // .drl or .gbr, depending on format + bool m_unitsMetric; // true = mm, false = inches + ZEROS_FMT m_zeroFormat; // the zero format option for output file + DRILL_PRECISION m_precision; // The current coordinate precision (not + // used in decimal format). + double m_conversionUnits; // scaling factor to convert the board + // unites to Excellon/Gerber units (i.e + // inches or mm) + wxPoint m_offset; // Drill offset coordinates + bool m_merge_PTH_NPTH; // True to generate only one drill file + std::vector m_holeListBuffer; // Buffer containing holes + std::vector m_toolListBuffer; // Buffer containing tools + + PLOT_FORMAT m_mapFileFmt; // the format of the map drill file, + // if this map is needed + const PAGE_INFO* m_pageInfo; // the page info used to plot drill maps + // If NULL, use a A4 page format }; #endif // #define GENDRILL_FILE_WRITER_BASE_H - diff --git a/pcbnew/exporters/gerber_placefile_writer.h b/pcbnew/exporters/gerber_placefile_writer.h index 14334871a3..80a3490c28 100644 --- a/pcbnew/exporters/gerber_placefile_writer.h +++ b/pcbnew/exporters/gerber_placefile_writer.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2019 Jean_Pierre Charras - * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -34,7 +34,7 @@ class FOOTPRINT; class PAD; /** - * PLACEFILE_GERBER_WRITER is a class mainly used to create Gerber drill files + * PLACEFILE_GERBER_WRITER is a class mainly used to create Gerber drill files. */ class PLACEFILE_GERBER_WRITER { @@ -47,10 +47,11 @@ public: /** - * Function SetOptions * Initialize internal parameters to match drill options - * note: PTH and NPTH are always separate files in Gerber format - * @param aOffset = drill coordinates offset + * + * @note PTH and NPTH are always separate files in Gerber format. + * + * @param aOffset is the drill coordinates offset. */ void SetOptions( wxPoint aOffset ) { @@ -58,24 +59,40 @@ public: } /** - * Creates an pnp gerber file - * @param aFullFilename = the full filename - * @param aLayer = layer (F_Cu or B_Cu) to generate - * @param aIncludeBrdEdges = true to include board outlines - * @return component count, or -1 if the file cannot be created + * Create an pnp gerber file. + * + * @param aFullFilename is the full filename. + * @param aLayer is the layer (F_Cu or B_Cu) to generate. + * @param aIncludeBrdEdges use true to include board outlines. + * @return component count, or -1 if the file cannot be created. */ int CreatePlaceFile( wxString& aFullFilename, PCB_LAYER_ID aLayer, bool aIncludeBrdEdges ); /** - * @return a filename which identify the drill file function. * @param aFullBaseFilename = a full filename. it will be modified * to add "-pnp" and set the extension * @param aLayer = layer (F_Cu or B_Cu) to generate + * @return a filename which identify the drill file function. */ const wxString GetPlaceFileName( const wxString& aFullBaseFilename, PCB_LAYER_ID aLayer ) const; private: + /** + * Convert a KiCad footprint orientation to gerber rotation both are in degrees. + */ + double mapRotationAngle( double aAngle ); + + /** + * Find the pad(s) 1 (or pad "A1") of a footprint. + * + * Useful to plot a marker at this (these) position(s). + * + * @param aPadList is the list to fill. + * @param aFootprint is the footprint to test, + */ + void findPads1( std::vector& aPadList, FOOTPRINT* aFootprint ) const; + BOARD* m_pcb; PCB_LAYER_ID m_layer; // The board layer currently used (typically F_Cu or B_Cu) wxPoint m_offset; // Drill offset coordinates @@ -83,20 +100,6 @@ private: bool m_plotPad1Marker; // True to plot a flashed marker shape at pad 1 position bool m_plotOtherPadsMarker; // True to plot a marker shape at other pads position // This is a flashed 0 sized round pad - - /** - * convert a kicad footprint orientation to gerber rotation - * both are in degrees - */ - double mapRotationAngle( double aAngle ); - - /** - * Find the pad(s) 1 (or pad "A1") of a footprint - * Usefull to plot a marker at this (these) position(s) - * @param aPadList is the list to fill - * @param aFootprint is the footprint to test - */ - void findPads1( std::vector& aPadList, FOOTPRINT* aFootprint ) const; }; #endif // #ifndef PLACEFILE_GERBER_WRITER_H diff --git a/pcbnew/import_gfx/dialog_import_gfx.h b/pcbnew/import_gfx/dialog_import_gfx.h index fb6b0800d7..b32994a850 100644 --- a/pcbnew/import_gfx/dialog_import_gfx.h +++ b/pcbnew/import_gfx/dialog_import_gfx.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -67,24 +67,6 @@ public: bool TransferDataFromWindow() override; private: - PCB_BASE_FRAME* m_parent; - std::unique_ptr m_importer; - std::unique_ptr m_gfxImportMgr; - static int m_originUnits; - VECTOR2D m_origin; // This is the offset to add to imported coordinates - // Always in mm - - static wxString m_filename; - static bool m_shouldGroupItems; - static bool m_placementInteractive; - static LAYER_NUM m_layer; - double m_lineWidth; // always in mm: line width when a line width - // is not specified - static int m_lineWidthUnits; - static double m_scaleImport; // a scale factor to change the size of imported - // items m_scaleImport =1.0 means keep original size - static int m_dxfUnits; - // Virtual event handlers void onUnitPositionSelection( wxCommandEvent& event ) override; void onUnitWidthSelection( wxCommandEvent& event ) override; @@ -110,6 +92,24 @@ private: double getPCBdefaultLineWidthMM(); void showPCBdefaultLineWidth(); void showPcbImportOffsets(); + + PCB_BASE_FRAME* m_parent; + std::unique_ptr m_importer; + std::unique_ptr m_gfxImportMgr; + static int m_originUnits; + VECTOR2D m_origin; // This is the offset to add to imported coordinates + // Always in mm + + static wxString m_filename; + static bool m_shouldGroupItems; + static bool m_placementInteractive; + static LAYER_NUM m_layer; + double m_lineWidth; // always in mm: line width when a line width + // is not specified + static int m_lineWidthUnits; + static double m_scaleImport; // a scale factor to change the size of imported + // items m_scaleImport =1.0 means keep original size + static int m_dxfUnits; }; #endif // __DIALOG_IMPORT_GFX_H__ diff --git a/pcbnew/import_gfx/dxf_import_plugin.h b/pcbnew/import_gfx/dxf_import_plugin.h index 49d342cb0e..fcca4ae5df 100644 --- a/pcbnew/import_gfx/dxf_import_plugin.h +++ b/pcbnew/import_gfx/dxf_import_plugin.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -58,6 +58,28 @@ struct SPLINE_CTRL_POINT class DXF2BRD_ENTITY_DATA { public: + DXF2BRD_ENTITY_DATA() { Clear(); }; + + // Reset the entity parameters + void Clear() + { + m_EntityType = DL_UNKNOWN; + m_EntityParseStatus = 0; + m_EntityFlag = 0; + m_SplineDegree = 1; + m_SplineKnotsCount = 0; + m_SplineControlCount = 0; + m_SplineFitCount = 0; + m_SplineTangentStartX = 0.0; + m_SplineTangentStartY = 0.0; + m_SplineTangentEndX = 0.0; + m_SplineTangentEndY = 0.0; + m_BulgeVertex = 0.0; + m_SplineKnotsList.clear(); + m_SplineControlPointList.clear(); + m_SplineFitPointList.clear(); + } + int m_EntityType; // the DXF type of entity int m_EntityParseStatus; // Inside a entity: status of parsing: // 0 = no entity @@ -86,28 +108,6 @@ public: std::vector m_SplineControlPointList; // fit points list, code 11, 21 & 31 (only X and Y cood) std::vector m_SplineFitPointList; - - DXF2BRD_ENTITY_DATA() { Clear(); }; - - // Reset the entity parameters - void Clear() - { - m_EntityType = DL_UNKNOWN; - m_EntityParseStatus = 0; - m_EntityFlag = 0; - m_SplineDegree = 1; - m_SplineKnotsCount = 0; - m_SplineControlCount = 0; - m_SplineFitCount = 0; - m_SplineTangentStartX = 0.0; - m_SplineTangentStartY = 0.0; - m_SplineTangentEndX = 0.0; - m_SplineTangentEndY = 0.0; - m_BulgeVertex = 0.0; - m_SplineKnotsList.clear(); - m_SplineControlPointList.clear(); - m_SplineFitPointList.clear(); - } }; // Magic constants as defined by dxf specification for line weight @@ -162,7 +162,8 @@ public: bool m_bold; bool m_italic; - DXF_IMPORT_STYLE( wxString aName, double aTextHeight, double aWidthFactor, bool aBold, bool aItalic ) + DXF_IMPORT_STYLE( wxString aName, double aTextHeight, double aWidthFactor, bool aBold, + bool aItalic ) { m_name = aName; m_textHeight = aTextHeight; @@ -222,31 +223,6 @@ struct DXF_ARBITRARY_AXIS class DXF_IMPORT_PLUGIN : public GRAPHICS_IMPORT_PLUGIN, public DL_CreationAdapter { -private: - double m_xOffset; // X coord offset for conversion (in mm) - double m_yOffset; // Y coord offset for conversion (in mm) - double m_defaultThickness; // default line thickness for conversion (in mm) - int m_brdLayer; // The board layer to place imported DXF items - int m_version; // the dxf version, not used here - std::string m_codePage; // The code page, not used here - bool m_importAsFPShapes; // Use footprint items instead of board items when true. - // true when the items are imported in the footprint editor - wxString m_messages; // messages generated during dxf file parsing. - // Each message ends by '\n' - DXF2BRD_ENTITY_DATA m_curr_entity; // the current entity parameters when parsing a DXF entity - - double m_minX, m_maxX; // handles image size in mm - double m_minY, m_maxY; // handles image size in mm - - DXF_IMPORT_UNITS m_currentUnit; // current unit during import - - GRAPHICS_IMPORTER_BUFFER m_internalImporter; - - std::vector> m_layers; // List of layers as we import, used just to grab props for objects - std::vector> m_blocks; // List of blocks as we import - std::vector> m_styles; // List of blocks as we import - DXF_IMPORT_BLOCK* m_currentBlock; - public: DXF_IMPORT_PLUGIN(); ~DXF_IMPORT_PLUGIN(); @@ -273,9 +249,10 @@ public: virtual void SetImporter( GRAPHICS_IMPORTER* aImporter ) override; /** - * Allows the import DXF items converted to board graphic items or footprint - * graphic items. - * @param aImportAsFootprintGraphic = true to import in a footprint, false to import on a board + * Allow the import DXF items converted to board graphic items or footprint graphic items. + * + * @param aImportAsFootprintGraphic use true to import in a footprint or false to import on + * a board. */ void ImportAsFootprintGraphic( bool aImportAsFootprintGraphic ) { @@ -283,9 +260,11 @@ public: } /** - * Set the default units when importing DXFs - * DXFs can lack units by design which requires the importing software to make the decision - * @param aUnits is the default unit of the DXF to assume + * Set the default units when importing DXFs. + * + * DXFs can lack units by design which requires the importing software to make the decision. + * + * @param aUnits is the default unit of the DXF to assume. */ void SetUnit( DXF_IMPORT_UNITS aUnit ) { @@ -294,9 +273,11 @@ public: /** * Set the default line width when importing dxf items like lines to Pcbnew. - * because dxf files have no line width explicit parameter, it will be most - * of time the line width of imported lines - * @param aWidth = line width in mm + * + * DXF files have no line width explicit parameter, it will be most of time the line width + * of imported lines. + *f + * @param aWidth is the line width in mm. */ void SetDefaultLineWidthMM( double aWidth ) { @@ -307,10 +288,12 @@ public: /** * Set the coordinate offset between the imported dxf items and Pcbnew. - * because dxf files have the Y axis from bottom to top; - * aOffsetX = 0, and aOffsetY = - vertical page size to import a full page - * @param aOffsetX = the X offset in mm - * @param aOffsetY = the Y offset in mm + * + * DXF files have the Y axis from bottom to top aOffsetX = 0, and aOffsetY = - vertical + * page size to import a full page. + * + * @param aOffsetX is the X offset in mm. + * @param aOffsetY is the Y offset in mm. */ void SetOffset( double aOffsetX, double aOffsetY ) { @@ -320,15 +303,15 @@ public: /** * Set the layer number to import dxf items. - * the layer should be a technical layer, not a copper layer + * + * The layer should be a technical layer, not a copper layer. */ void SetBrdLayer( int aBrdLayer ) { m_brdLayer = aBrdLayer; } /** - * Implementation of the method used for communicate - * with this filter. + * Implementation of the method used for communicate with this filter. * - * @param aFile = the full filename. + * @param aFile is the full filename. */ bool ImportDxfFile( const wxString& aFile ); @@ -353,45 +336,48 @@ private: DXF_ARBITRARY_AXIS getArbitraryAxis( DL_Extrusion* aData ); - /*** - * Converts a given world coordinate point to object coordinate using the given arbitrary axis vectors + /** + * Converts a given world coordinate point to object coordinate using the given arbitrary + * axis vectors. */ VECTOR3D wcsToOcs( const DXF_ARBITRARY_AXIS& arbitraryAxis, VECTOR3D point ); - /*** - * Converts a given object coordinate point to world coordinate using the given arbitrary axis vectors + /** + * Converts a given object coordinate point to world coordinate using the given arbitrary + * axis vectors. */ VECTOR3D ocsToWcs( const DXF_ARBITRARY_AXIS& arbitraryAxis, VECTOR3D point ); /** - * Returns the import layer data + * Return the import layer data. * - * @param aLayerName is the raw string from dxflib getLayer() - * @returns The given layer by name or the placeholder layer inserted in the constructor + * @param aLayerName is the raw string from dxflib getLayer(). + * @returns The given layer by name or the placeholder layer inserted in the constructor. */ DXF_IMPORT_LAYER* getImportLayer( const std::string& aLayerName ); /** - * Returns the import layer block + * Return the import layer block. * - * @param aBlockName is the raw string from dxflib - * @returns The given block by name or nullptr if not found + * @param aBlockName is the raw string from dxflib. + * @return The given block by name or nullptr if not found. */ DXF_IMPORT_BLOCK* getImportBlock( const std::string& aBlockName ); /** - * Returns the import style + * Return the import style. * - * @param aStyleName is the raw string from dxflib - * @returns The given style by name or nullptr if not found + * @param aStyleName is the raw string from dxflib. + * @return The given style by name or nullptr if not found. */ DXF_IMPORT_STYLE* getImportStyle( const std::string& aStyleName ); - // Functions to aid in the creation of a Polyline + // Functions to aid in the creation of a Polyline. void insertLine( const VECTOR2D& aSegStart, const VECTOR2D& aSegEnd, int aWidth ); void insertArc( const VECTOR2D& aSegStart, const VECTOR2D& aSegEnd, double aBulge, int aWidth ); - // Add a dxf spline (stored in m_curr_entity) to the board, after conversion to segments + + // Add a dxf spline (stored in m_curr_entity) to the board, after conversion to segments. void insertSpline( int aWidth ); // Methods from DL_CreationAdapter: @@ -402,7 +388,7 @@ private: * Called for every string variable in the DXF file (e.g. "$ACADVER"). */ virtual void setVariableString( const std::string& key, const std::string& value, - int code ) override; + int code ) override; /** * Called for every int variable in the DXF file (e.g. "$ACADMAINTVER"). @@ -419,7 +405,8 @@ private: virtual void addLinetype( const DL_LinetypeData& data ) override; /** - * Called for each BLOCK in the DXF file + * Called for each BLOCK in the DXF file. + * * These are re-usable elements that may be placed into the model space. The elements * are dereferenced to the model, so we just need to skip the re-parsing for the block * elements. @@ -436,23 +423,33 @@ private: /* Inserts blocks where specified by insert data */ virtual void addInsert( const DL_InsertData& aData ) override; - /** Called for every polyline vertex */ + /** + * Called for every polyline vertex. + */ virtual void addVertex( const DL_VertexData& aData ) override; virtual void addMText( const DL_MTextData& aData) override; virtual void addTextStyle( const DL_StyleData& aData ) override; virtual void endEntity() override; - /** Called for every spline */ + /** + * Called for every spline. + * */ virtual void addSpline( const DL_SplineData& aData ) override; - /** Called for every spline control point */ + /** + * Called for every spline control point. + */ virtual void addControlPoint( const DL_ControlPointData& aData ) override; - /** Called for every spline fit point */ + /** + * Called for every spline fit point. + */ virtual void addFitPoint( const DL_FitPointData& aData ) override; - /** Called for every spline knot value */ + /** + * Called for every spline knot value. + */ virtual void addKnot( const DL_KnotData& aData ) override; // Not yet handled DXF entities: @@ -497,23 +494,38 @@ private: virtual void addImage( const DL_ImageData& ) override { ON_UNSUPPORTED( "addImage" ); } virtual void linkImage( const DL_ImageDefData& ) override {} - virtual void addHatchLoop( const DL_HatchLoopData& ) override { ON_UNSUPPORTED( "addHatchLoop" ); } + virtual void addHatchLoop( const DL_HatchLoopData& ) override + { + ON_UNSUPPORTED( "addHatchLoop" ); + } - virtual void addHatchEdge( const DL_HatchEdgeData& ) override { ON_UNSUPPORTED( "addHatchEdge" ); } + virtual void addHatchEdge( const DL_HatchEdgeData& ) override + { + ON_UNSUPPORTED( "addHatchEdge" ); + } virtual void addXRecord( const std::string& ) override { ON_UNSUPPORTED( "addXRecord" ); } - virtual void addXRecordString( int, const std::string& ) override { ON_UNSUPPORTED( "addXRecordString" ); } + + virtual void addXRecordString( int, const std::string& ) override + { + ON_UNSUPPORTED( "addXRecordString" ); + } + virtual void addXRecordReal( int, double ) override { ON_UNSUPPORTED( "addXRecordReal" ); } virtual void addXRecordInt( int, int ) override { ON_UNSUPPORTED( "addXRecordInt" ); } virtual void addXRecordBool( int, bool ) override { ON_UNSUPPORTED( "addXRecordBool" ); } virtual void addXDataApp( const std::string& ) override { ON_UNSUPPORTED( "addXDataApp" ); } - virtual void addXDataString( int, const std::string& ) override { ON_UNSUPPORTED( "addXDataString" ); } + virtual void addXDataString( int, const std::string& ) override + { + ON_UNSUPPORTED( "addXDataString" ); + } + virtual void addXDataReal( int, double ) override { ON_UNSUPPORTED( "addXDataReal" ); } virtual void addXDataInt( int, int ) override { ON_UNSUPPORTED( "addXDataInt" ); } /** - * Convert a native unicode string into a DXF encoded string. + * Convert a native Unicode string into a DXF encoded string. * * DXF encoding includes the following special sequences: * - %%%c for a diameter sign @@ -523,12 +535,38 @@ private: static wxString toDxfString( const wxString& aStr ); /** - * Converts a DXF encoded string into a native Unicode string. + * Convert a DXF encoded string into a native Unicode string. */ static wxString toNativeString( const wxString& aData ); void writeLine(); void writeMtext(); + +private: + double m_xOffset; // X coord offset for conversion (in mm) + double m_yOffset; // Y coord offset for conversion (in mm) + double m_defaultThickness; // default line thickness for conversion (in mm) + int m_brdLayer; // The board layer to place imported DXF items + int m_version; // the dxf version, not used here + std::string m_codePage; // The code page, not used here + bool m_importAsFPShapes; // Use footprint items instead of board items when true. + // true when the items are imported in the footprint editor + wxString m_messages; // messages generated during dxf file parsing. + // Each message ends by '\n' + DXF2BRD_ENTITY_DATA m_curr_entity; // the current entity parameters when parsing a DXF entity + + double m_minX, m_maxX; // handles image size in mm + double m_minY, m_maxY; // handles image size in mm + + DXF_IMPORT_UNITS m_currentUnit; // current unit during import + + GRAPHICS_IMPORTER_BUFFER m_internalImporter; + + // List of layers as we import, used just to grab props for objects. + std::vector> m_layers; + std::vector> m_blocks; // List of blocks as we import + std::vector> m_styles; // List of blocks as we import + DXF_IMPORT_BLOCK* m_currentBlock; }; #endif // DXF2BRD_ITEMS_H diff --git a/pcbnew/import_gfx/graphics_importer.h b/pcbnew/import_gfx/graphics_importer.h index 3925c561a1..22a011d402 100644 --- a/pcbnew/import_gfx/graphics_importer.h +++ b/pcbnew/import_gfx/graphics_importer.h @@ -255,6 +255,12 @@ protected: m_items.emplace_back( std::move( aItem ) ); } + ///< factor to convert millimeters to Internal Units + double m_millimeterToIu; + + ///< Offset (in mm) for imported coordinates + VECTOR2D m_offsetCoordmm; + private: ///< List of imported items std::list> m_items; @@ -277,13 +283,6 @@ private: ///< Default line thickness for the imported graphics double m_lineWidth; - -protected: - ///< factor to convert millimeters to Internal Units - double m_millimeterToIu; - - ///< Offset (in mm) for imported coordinates - VECTOR2D m_offsetCoordmm; }; #endif /* GRAPHICS_IMPORTER_H */ diff --git a/pcbnew/netlist_reader/netlist_reader.h b/pcbnew/netlist_reader/netlist_reader.h index 2196e8deef..7f775a7c55 100644 --- a/pcbnew/netlist_reader/netlist_reader.h +++ b/pcbnew/netlist_reader/netlist_reader.h @@ -10,7 +10,7 @@ * * Copyright (C) 2012 Jean-Pierre Charras. * Copyright (C) 2013-2017 Wayne Stambaugh . - * Copyright (C) 2012-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2012-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -43,16 +43,12 @@ class COMPONENT; /** - * CMP_READER - * reads a component footprint link file (*.cmp) format. + * Read a component footprint link file (*.cmp) format. */ class CMP_READER { - LINE_READER* m_lineReader; ///< The line reader to read. - public: /** - * CMP_READER constructor. * @param aLineReader is a LINE_READER (in fact a FILE_LINE_READER) * which is owned by me ( and deleted by me) to read * the component footprint link file. @@ -67,21 +63,14 @@ public: if( m_lineReader ) { delete m_lineReader; - m_lineReader = NULL; + m_lineReader = nullptr; } } /** - * Function Load - * read the *.cmp file format contains the component footprint assignments created by CvPcb + * Read the *.cmp file format contains the component footprint assignments created by CvPcb * into \a aNetlist. * - * @param aNetlist is the #NETLIST to read into. - * - * @todo At some point in the future, use the footprint field in the new s-expression - * netlist file to assign a footprint to a component instead of using a secondary - * (*.cmp) file. - * * Sample file footprint assignment entry: * * Cmp-Mod V01 Genere by CvPcb 29/10/2003-13: 11:6 * @@ -92,6 +81,11 @@ public: * IdModule = CP6; * EndCmp * + * @todo At some point in the future, use the footprint field in the new s-expression + * netlist file to assign a footprint to a component instead of using a secondary + * (*.cmp) file. + * + * @param aNetlist is the #NETLIST to read into. * @throw IO_ERROR if a the #LINE_READER IO error occurs. * @throw PARSE_ERROR if an error occurs while parsing the file. * @return true if OK, false if a component reference found in the @@ -100,12 +94,14 @@ public: * print a warning in Pcbnew. */ bool Load( NETLIST* aNetlist ); + +private: + LINE_READER* m_lineReader; ///< The line reader to read. }; /** - * NETLIST_READER - * is a pure virtual class to derive a specific type of netlist reader from. + * A pure virtual class to derive a specific type of netlist reader from. */ class NETLIST_READER { @@ -123,18 +119,16 @@ public: // function. }; - /** - * Constructor * @param aLineReader ownership is taken of this #LINE_READER. * @param aNetlist the #NETLIST object to read into. * @param aFootprintLinkReader ownership is taken of this #CMP_READER. */ NETLIST_READER( LINE_READER* aLineReader, NETLIST* aNetlist, - CMP_READER* aFootprintLinkReader = NULL ) + CMP_READER* aFootprintLinkReader = nullptr ) { - wxASSERT( aLineReader != NULL ); + wxASSERT( aLineReader != nullptr ); m_lineReader = aLineReader; m_footprintReader = aFootprintLinkReader; @@ -146,8 +140,7 @@ public: virtual ~NETLIST_READER(); /** - * Function GuessNetlistFileType - * looks at \a aFileHeaderLine to see if it matches any of the netlist file types it + * Look at \a aFileHeaderLine to see if it matches any of the netlist file types it * knows about. * * @param aLineReader is the #LINE_READER object containing lines from the netlist to test. @@ -156,8 +149,7 @@ public: static NETLIST_FILE_T GuessNetlistFileType( LINE_READER* aLineReader ); /** - * Function GetNetlistReader - * attempts to determine the net list file type of \a aNetlistFileName and return the + * Attempt to determine the net list file type of \a aNetlistFileName and return the * appropriate NETLIST_READER type. * * @param aNetlist is the netlist to load \a aNetlistFileName into. @@ -173,8 +165,7 @@ public: const wxString& aCompFootprintFileName = wxEmptyString ); /** - * Function LoadNetlist - * loads the contents of the netlist file into \a aNetlist. + * Load the contents of the netlist file into \a aNetlist. * * @throw IO_ERROR if a file IO error occurs. * @throw PARSE_ERROR if an error occurs while parsing the file. @@ -182,7 +173,6 @@ public: virtual void LoadNetlist() = 0; /** - * Function GetLineReader() * @return the #LINE_READER associated with the #NETLIST_READER. */ LINE_READER* GetLineReader(); @@ -199,8 +189,7 @@ protected: /** - * LEGACY_NETLIST_READER - * reads the KiCad legacy and the old Orcad netlist formats. + * Read the KiCad legacy and the old Orcad netlist formats. * * The KiCad legacy netlist format was derived directly from an old Orcad netlist format. The * primary difference is the header was changed so this reader can read both formats. @@ -208,22 +197,20 @@ protected: class LEGACY_NETLIST_READER : public NETLIST_READER { /** - * Function loadSymbol - * read the \a aLine containing the description of a component from a legacy format + * Read the \a aLine containing the description of a component from a legacy format * netlist and add it to the netlist. * * Analyze the first line of a component description in netlist: * ( /40C08647 $noname R20 4.7K {Lib=R} * - * @param aText contains the first line of description - * @return the new component created by parsing \a aLine + * @param aText contains the first line of description. + * @return the new component created by parsing \a aLine. * @throw PARSE_ERROR when \a aLine is not a valid component description. */ COMPONENT* loadComponent( char* aText ); /** - * Function loadFootprintFilters - * loads the footprint filter section of netlist file. + * Load the footprint filter section of netlist file. * * Sample legacy footprint filter section: * { Allowed footprints by component: @@ -256,14 +243,13 @@ public: LEGACY_NETLIST_READER( LINE_READER* aLineReader, NETLIST* aNetlist, - CMP_READER* aFootprintLinkReader = NULL ) : + CMP_READER* aFootprintLinkReader = nullptr ) : NETLIST_READER( aLineReader, aNetlist, aFootprintLinkReader ) { } /** - * Function LoadNetlist - * read the netlist file in the legacy format into \a aNetlist. + * Read the netlist file in the legacy format into \a aNetlist. * * The legacy netlist format is: * \# EESchema Netlist Version 1.0 generee le 18/5/2005-12:30:22 @@ -287,26 +273,38 @@ public: /** - * KICAD_NETLIST_PARSER - * is the parser for reading the KiCad s-expression netlist format. + * The parser for reading the KiCad s-expression netlist format. */ class KICAD_NETLIST_PARSER : public NETLIST_LEXER { -private: - NL_T::T token; - LINE_READER* m_lineReader; ///< The line reader used to parse the netlist. Not owned. - NETLIST* m_netlist; ///< The netlist to parse into. Not owned. +public: + KICAD_NETLIST_PARSER( LINE_READER* aReader, NETLIST* aNetlist ); + + void SetLineReader( LINE_READER* aLineReader ); + + void SetNetlist( NETLIST* aNetlist ) { m_netlist = aNetlist; } /** - * Function skipCurrent + * Function Parse + * parse the full netlist + */ + void Parse(); + + // Useful for debug only: + const char* getTokenName( NL_T::T aTok ) + { + return NETLIST_LEXER::TokenName( aTok ); + } + +private: + /** * Skip the current token level, i.e - * search for the RIGHT parenthesis which closes the current description + * search for the RIGHT parenthesis which closes the current description. */ void skipCurrent(); /** - * Function parseComponent - * parse a component description: + * Parse a component description: * (comp (ref P1) * (value DB25FEMELLE) * (footprint DB25FC) @@ -318,8 +316,7 @@ private: void parseComponent(); /** - * Function parseNet - * Parses a section like + * Parse a net section * (net (code 20) (name /PC-A0) * (node (ref BUS1) (pin 62)) * (node (ref U3) (pin 3)) @@ -330,8 +327,7 @@ private: void parseNet(); /** - * Function parseLibPartList - * reads the section "libparts" in the netlist: + * Read the section "libparts" in the netlist: * (libparts * (libpart (lib device) (part C) * (description "Condensateur non polarise") @@ -353,40 +349,21 @@ private: */ void parseLibPartList(); - -public: - KICAD_NETLIST_PARSER( LINE_READER* aReader, NETLIST* aNetlist ); - - void SetLineReader( LINE_READER* aLineReader ); - - void SetNetlist( NETLIST* aNetlist ) { m_netlist = aNetlist; } - - /** - * Function Parse - * parse the full netlist - */ - void Parse(); - - // Useful for debug only: - const char* getTokenName( NL_T::T aTok ) - { - return NETLIST_LEXER::TokenName( aTok ); - } + NL_T::T token; + LINE_READER* m_lineReader; ///< The line reader used to parse the netlist. Not owned. + NETLIST* m_netlist; ///< The netlist to parse into. Not owned. }; /** - * KICAD_NETLIST_READER - * read the new s-expression based KiCad netlist format. + * Read the new s-expression based KiCad netlist format. */ class KICAD_NETLIST_READER : public NETLIST_READER { - KICAD_NETLIST_PARSER* m_parser; ///< The s-expression format parser. - public: KICAD_NETLIST_READER( LINE_READER* aLineReader, NETLIST* aNetlist, - CMP_READER* aFootprintLinkReader = NULL ) : + CMP_READER* aFootprintLinkReader = nullptr ) : NETLIST_READER( aLineReader, aNetlist, aFootprintLinkReader ), m_parser( new KICAD_NETLIST_PARSER( aLineReader, aNetlist ) ) { @@ -398,6 +375,9 @@ public: } virtual void LoadNetlist() override; + +private: + KICAD_NETLIST_PARSER* m_parser; ///< The s-expression format parser. }; diff --git a/pcbnew/netlist_reader/pcb_netlist.h b/pcbnew/netlist_reader/pcb_netlist.h index 4df49f0cf1..56627f8518 100644 --- a/pcbnew/netlist_reader/pcb_netlist.h +++ b/pcbnew/netlist_reader/pcb_netlist.h @@ -42,11 +42,6 @@ class REPORTER; */ class COMPONENT_NET { - wxString m_pinName; - wxString m_netName; - wxString m_pinFunction; - wxString m_pinType; - public: COMPONENT_NET() {} @@ -72,6 +67,12 @@ public: } int Format( OUTPUTFORMATTER* aOut, int aNestLevel, int aCtl ); + +private: + wxString m_pinName; + wxString m_netName; + wxString m_pinFunction; + wxString m_pinType; }; @@ -227,7 +228,7 @@ public: unsigned GetCount() const { return m_components.size(); } /** - * Returns the #COMPONENT at \a aIndex. + * Return the #COMPONENT at \a aIndex. * * @param aIndex the index in #m_components to fetch. * @return a pointer to the #COMPONENT at \a Index.