GerbView header housekeeping.

This commit is contained in:
Wayne Stambaugh 2021-06-03 14:32:24 -04:00
parent 937f502158
commit 5395a7fe67
15 changed files with 738 additions and 786 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2010-2018 Jean-Pierre Charras jp.charras at wanadoo.fr * Copyright (C) 2010-2018 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2018 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -47,17 +47,11 @@
#include <wx/arrstr.h> #include <wx/arrstr.h>
/** /**
* X2_ATTRIBUTE
* The attribute value consists of a number of substrings separated by a comma * The attribute value consists of a number of substrings separated by a comma
*/ */
class X2_ATTRIBUTE class X2_ATTRIBUTE
{ {
protected:
wxArrayString m_Prms; ///< the list of parameters (after TF) in gbr file
///< the first one is the attribute name,
///< if starting by '.'
public: public:
X2_ATTRIBUTE(); X2_ATTRIBUTE();
~X2_ATTRIBUTE(); ~X2_ATTRIBUTE();
@ -88,8 +82,8 @@ public:
int GetPrmCount() { return int( m_Prms.GetCount() ); } int GetPrmCount() { return int( m_Prms.GetCount() ); }
/** /**
* parse a TF command terminated with a % and fill m_Prms * Parse a TF command terminated with a % and fill m_Prms by the parameters found.
* by the parameters found. *
* @param aFile = a FILE* ptr to the current Gerber file. * @param aFile = a FILE* ptr to the current Gerber file.
* @param aBuffer = the buffer containing current Gerber data (can be null) * @param aBuffer = the buffer containing current Gerber data (can be null)
* @param aBuffSize = the size of the buffer * @param aBuffSize = the size of the buffer
@ -102,12 +96,12 @@ public:
bool ParseAttribCmd( FILE* aFile, char *aBuffer, int aBuffSize, char* &aText, int& aLineNum ); bool ParseAttribCmd( FILE* aFile, char *aBuffer, int aBuffSize, char* &aText, int& aLineNum );
/** /**
* Debug function: pring using wxLogMessage le list of parameters * Debug function: print using wxLogMessage le list of parameters
*/ */
void DbgListPrms(); void DbgListPrms();
/** /**
* return true if the attribute is .FileFunction * Return true if the attribute is .FileFunction
*/ */
bool IsFileFunction() bool IsFileFunction()
{ {
@ -115,7 +109,7 @@ public:
} }
/** /**
* return true if the attribute is .MD5 * Return true if the attribute is .MD5
*/ */
bool IsFileMD5() bool IsFileMD5()
{ {
@ -123,12 +117,17 @@ public:
} }
/** /**
* return true if the attribute is .Part * Return true if the attribute is .Part
*/ */
bool IsFilePart() bool IsFilePart()
{ {
return GetAttribute().IsSameAs( wxT(".Part"), false ); return GetAttribute().IsSameAs( wxT(".Part"), false );
} }
protected:
wxArrayString m_Prms; ///< the list of parameters (after TF) in gbr file
///< the first one is the attribute name,
///< if starting by '.'
}; };
/** /**
@ -149,9 +148,6 @@ public:
class X2_ATTRIBUTE_FILEFUNCTION : public X2_ATTRIBUTE class X2_ATTRIBUTE_FILEFUNCTION : public X2_ATTRIBUTE
{ {
int m_z_order; // the z order of the layer for a board
int m_z_sub_order; // the z sub_order of the copper layer for a board
public: public:
X2_ATTRIBUTE_FILEFUNCTION( X2_ATTRIBUTE& aAttributeBase ); X2_ATTRIBUTE_FILEFUNCTION( X2_ATTRIBUTE& aAttributeBase );
@ -199,6 +195,9 @@ private:
* Initialize the z order priority of the current file, from its attributes * Initialize the z order priority of the current file, from its attributes
*/ */
void set_Z_Order(); void set_Z_Order();
int m_z_order; // the z order of the layer for a board
int m_z_sub_order; // the z sub_order of the copper layer for a board
}; };
#endif // X2_GERBER_ATTRIBUTE_H #endif // X2_GERBER_ATTRIBUTE_H

View File

@ -7,7 +7,7 @@
* *
* Copyright (C) 1992-2017 Jean-Pierre Charras <jp.charras at wanadoo.fr> * Copyright (C) 1992-2017 Jean-Pierre Charras <jp.charras at wanadoo.fr>
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2017 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -36,8 +36,8 @@
* Inside a given aperture primitive, a fixed list of parameters defines info * Inside a given aperture primitive, a fixed list of parameters defines info
* about the shape: size, thickness, number of vertex ... * about the shape: size, thickness, number of vertex ...
* *
* Each parameter can be an immediate value or a defered value. * Each parameter can be an immediate value or a deferred value.
* When value is defered, it is defined when the aperture macro is instancied by * When value is deferred, it is defined when the aperture macro is instanced by
* an ADD macro command * an ADD macro command
* *
* Actual values of a parameter can also be the result of an arithmetic operation. * Actual values of a parameter can also be the result of an arithmetic operation.
@ -45,12 +45,12 @@
* Here is some examples: * Here is some examples:
* An immediate value: * An immediate value:
* 3.5 * 3.5
* A deferend value: * A deferred value:
* $2 means: replace me by the second value given in the ADD command * $2 means: replace me by the second value given in the ADD command
* Actual value as arithmetic calculation: * Actual value as arithmetic calculation:
* $2/2+1 * $2/2+1
* *
* Note also a defered parameter can be defined in aperture macro, * Note also a defer ed parameter can be defined in aperture macro,
* but outside aperture primitives. Example * but outside aperture primitives. Example
* %AMRECTHERM* * %AMRECTHERM*
* $4=$3/2* parameter $4 is half value of parameter $3 * $4=$3/2* parameter $4 is half value of parameter $3
@ -77,7 +77,7 @@
* Example of instanciation: * Example of instanciation:
* %ADD12VECTOR,0.05X0X0*% * %ADD12VECTOR,0.05X0X0*%
* *
* A more complicated aperture macro definition, with parameters and arihmetic operations: * A more complicated aperture macro definition, with parameters and arithmetic operations:
* %AMRNDREC* * %AMRNDREC*
* 0 this is a comment* * 0 this is a comment*
* 21,1,$1+$1,$2+$2-$3-$3,0,0,0* * 21,1,$1+$1,$2+$2-$3-$3,0,0,0*
@ -105,14 +105,14 @@
#include <dcode.h> #include <dcode.h>
/* /*
Values of a parameter can be the result of an arithmetic operation, Values of a parameter can be the result of an arithmetic operation,
between immediate values and defered value. between immediate values and deferred value.
From an idea found in Gerbv, here is the way to evaluate a parameter. From an idea found in Gerbv, here is the way to evaluate a parameter.
a AM_PARAM_ITEM holds info about operands and operators in a parameter definition a AM_PARAM_ITEM holds info about operands and operators in a parameter definition
( a AM_PARAM ) like $2+$2-$3-$3/2 ( a AM_PARAM ) like $2+$2-$3-$3/2
Precedence was recently actually defined in gerber RS274X Precedence was recently actually defined in gerber RS274X
(Previously, there was no actual info about this precedence) (Previously, there was no actual info about this precedence)
This is the usual arithmetic precendence between + - x / ( ), the only ones used in Gerber This is the usual arithmetic precedence between + - x / ( ), the only ones used in Gerber
Before 2015 apr 10, actual value was calculated step to step: Before 2015 apr 10, actual value was calculated step to step:
no precedence, and '(' ')' are ignored. no precedence, and '(' ')' are ignored.
@ -131,7 +131,7 @@ NOP : The no operation. This is the default instruction and are
added as a security measure. added as a security measure.
PUSHVALUE : Pushes an arithmetical value on the stack. This machine only works with floats PUSHVALUE : Pushes an arithmetical value on the stack. This machine only works with floats
on the stack. on the stack.
PUSHPARM: Pushes a defered parameter onto the stack. Gerber aperture macros accepts PUSHPARM: Pushes a deferred parameter onto the stack. Gerber aperture macros accepts
parameters to be set when later declared, so the same macro can parameters to be set when later declared, so the same macro can
be used at several instances. Which parameter to be set is an integer be used at several instances. Which parameter to be set is an integer
and starts with 1. definition is like $1 or $3 and starts with 1. definition is like $1 or $3
@ -210,20 +210,14 @@ private:
typedef std::vector<AM_PARAM_EVAL> AM_PARAM_EVAL_STACK; typedef std::vector<AM_PARAM_EVAL> AM_PARAM_EVAL_STACK;
/** /**
* AM_PARAM * Hold an operand for an AM_PARAM as defined within standard RS274X.
* holds an operand for an AM_PARAM as defined within *
* standard RS274X. The \a value field can be a constant, i.e. "immediate" * The \a value field can be a constant, i.e. "immediate" parameter or it may not be used if
* parameter or it may not be used if this param is going to defer to the * this param is going to defer to the referencing aperture macro. In that case, the \a index
* referencing aperture macro. In that case, the \a index field is an index * field is an index into the aperture macro's parameters.
* into the aperture macro's parameters.
*/ */
class AM_PARAM_ITEM class AM_PARAM_ITEM
{ {
private:
parm_item_type m_type; // the type of item
double m_dvalue; // the value, for PUSHVALUE type item
int m_ivalue; // the integer value, for PUSHPARM type item
public: public:
AM_PARAM_ITEM( parm_item_type aType, double aValue ) AM_PARAM_ITEM( parm_item_type aType, double aValue )
{ {
@ -272,33 +266,31 @@ public:
{ {
return m_type == PUSHPARM; return m_type == PUSHPARM;
} }
private:
parm_item_type m_type; // the type of item
double m_dvalue; // the value, for PUSHVALUE type item
int m_ivalue; // the integer value, for PUSHPARM type item
}; };
/** /**
* AM_PARAM * Hold a parameter value for an "aperture macro" as defined within standard RS274X.
* holds a parameter value for an "aperture macro" as defined within *
* standard RS274X. The parameter can be a constant, i.e. "immediate" parameter, * The parameter can be a constant, i.e. "immediate" parameter, or depend on some deferred
* or depend on some defered values, defined in a D_CODE, by the ADD command. * values, defined in a D_CODE, by the ADD command. Note the actual value could need an
* Note the actual value could need an evaluation from an arithmetical expression * evaluation from an arithmetical expression items in the expression are stored in. A
* items in the expression are stored in . * simple definition is just a value stored in one item in m_paramStack.
* A simple definition is just a value stored in one item in m_paramStack
*/ */
class AM_PARAM class AM_PARAM
{ {
private:
int m_index; // has meaning to define parameter local to an aperture macro
std::vector<AM_PARAM_ITEM> m_paramStack; // list of operands/operators to evalutate the actual value
// if a par def is $3/2, there are 3 items in stack:
// 3 (type PUSHPARM) , / (type DIV), 2 (type PUSHVALUE)
public: public:
AM_PARAM(); AM_PARAM();
/** /**
* function PushOperator * Add an operator/operand to the current stack.
* add an operator/operand to the current stack *
* @param aType = the type of item (NOP, PUSHVALUE, PUSHPARM, ADD, SUB, MUL, DIV, EQUATE) * @param aType is the type of item (NOP, PUSHVALUE, PUSHPARM, ADD, SUB, MUL, DIV, EQUATE)
* @param aValue = the item value, double for PUSHVALUE or int for PUSHPARM type. * @param aValue is the item value, double for PUSHVALUE or int for PUSHPARM type.
*/ */
void PushOperator( parm_item_type aType, double aValue ); void PushOperator( parm_item_type aType, double aValue );
void PushOperator( parm_item_type aType, int aValue = 0); void PushOperator( parm_item_type aType, int aValue = 0);
@ -306,10 +298,11 @@ public:
double GetValue( const D_CODE* aDcode ) const; double GetValue( const D_CODE* aDcode ) const;
/** /**
* Function IsImmediate * Test if this AM_PARAM holds an immediate parameter or is a pointer into a parameter held
* tests if this AM_PARAM holds an immediate parameter or is a pointer * by an owning D_CODE.
* into a parameter held by an owning D_CODE. *
* @return true if the value is immediate, i.e. no defered value in operands used in its definition * @return true if the value is immediate, i.e. no deferred value in operands used in its
* definition.
*/ */
bool IsImmediate() const; bool IsImmediate() const;
@ -324,18 +317,27 @@ public:
} }
/** /**
* Function ReadParam * Read one aperture macro parameter.
* Read one aperture macro parameter *
* a parameter can be: * a parameter can be:
* a number * a number
* a reference to an aperture definition parameter value: $1 ot $3 ... * a reference to an aperture definition parameter value: $1 to $3 ...
* a parameter definition can be complex and have operators between numbers and/or other parameter * a parameter definition can be complex and have operators between numbers and/or other
* parameter
* like $1+3 or $2x2.. * like $1+3 or $2x2..
* Parameters are separated by a comma ( of finish by *) * Parameters are separated by a comma ( of finish by *)
* @param aText = pointer to the parameter to read. Will be modified to point to the next field * @param aText = pointer to the parameter to read. Will be modified to point to the next field
* @return true if a param is read, or false * @return true if a param is read, or false
*/ */
bool ReadParam( char*& aText ); bool ReadParam( char*& aText );
private:
int m_index; ///< has meaning to define parameter local to an aperture macro
std::vector<AM_PARAM_ITEM> m_paramStack; ///< List of operands/operators to evaluate the
///< actual value if a par def is $3/2, there are
///< 3 items in stack: 3 (type PUSHPARM) , / (type
///< DIV), 2 (type PUSHVALUE).
}; };
typedef std::vector<AM_PARAM> AM_PARAMS; typedef std::vector<AM_PARAM> AM_PARAMS;

View File

@ -10,7 +10,7 @@
* *
* Copyright (C) 1992-2010 Jean-Pierre Charras <jp.charras at wanadoo.fr> * Copyright (C) 1992-2010 Jean-Pierre Charras <jp.charras at wanadoo.fr>
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2010 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -44,10 +44,10 @@ class SHAPE_POLY_SET;
* Inside a given aperture primitive, a fixed list of parameters defines info * Inside a given aperture primitive, a fixed list of parameters defines info
* about the shape: size, thickness, number of vertex ... * about the shape: size, thickness, number of vertex ...
* *
* Each parameter can be an immediate value or a defered value. * Each parameter can be an immediate value or a deferred value.
* When value is defered, it is defined when the aperture macro is instancied by * When value is deferred, it is defined when the aperture macro is instanced by
* an ADD macro command * an ADD macro command
* Note also a defered parameter can be defined in aperture macro, * Note also a deferred parameter can be defined in aperture macro,
* but outside aperture primitives. Example * but outside aperture primitives. Example
* %AMRECTHERM* * %AMRECTHERM*
* $4=$3/2* parameter $4 is half value of parameter $3 * $4=$3/2* parameter $4 is half value of parameter $3
@ -61,31 +61,33 @@ class SHAPE_POLY_SET;
*/ */
/** /**
* Enum AM_PRIMITIVE_ID * The set of all "aperture macro primitives" (primitive numbers).
* is the set of all "aperture macro primitives" (primitive numbers). See *
* Table 3 in http://gerbv.sourceforge.net/docs/rs274xrevd_e.pdf * See Table 3 in http://gerbv.sourceforge.net/docs/rs274xrevd_e.pdf aperture macro primitives
* aperture macro primitives are basic shapes which can be combined to create a complex shape * are basic shapes which can be combined to create a complex shape. This complex shape is
* This complex shape is flashed. * flashed.
*/ */
enum AM_PRIMITIVE_ID { enum AM_PRIMITIVE_ID {
AMP_UNKNOWN = -1, // A value for uninitialized AM_PRIMITIVE. AMP_UNKNOWN = -1, // A value for uninitialized AM_PRIMITIVE.
AMP_COMMENT = 0, // A primitive description is not really a primitive, this is a comment AMP_COMMENT = 0, // A primitive description is not really a primitive, this is a
// comment
AMP_CIRCLE = 1, // Circle. (diameter and position) AMP_CIRCLE = 1, // Circle. (diameter and position)
AMP_LINE2 = 2, // Line with rectangle ends. (Width, start and end pos + rotation) AMP_LINE2 = 2, // Line with rectangle ends. (Width, start and end pos + rotation)
AMP_LINE20 = 20, // Same as AMP_LINE2 AMP_LINE20 = 20, // Same as AMP_LINE2
AMP_LINE_CENTER = 21, // Rectangle. (height, width and center pos + rotation) AMP_LINE_CENTER = 21, // Rectangle. (height, width and center pos + rotation)
AMP_LINE_LOWER_LEFT = 22, // Rectangle. (height, width and left bottom corner pos + rotation) AMP_LINE_LOWER_LEFT = 22, // Rectangle. (height, width and left bottom corner pos + rotation)
AMP_EOF = 3, // End Of File marquer: not really a shape AMP_EOF = 3, // End Of File marker: not really a shape
AMP_OUTLINE = 4, // Free polyline (n corners + rotation) AMP_OUTLINE = 4, // Free polyline (n corners + rotation)
AMP_POLYGON = 5, // Closed regular polygon(diameter, number of vertices (3 to 10), rotation) AMP_POLYGON = 5, // Closed regular polygon(diameter, number of vertices (3 to 10),
// rotation)
AMP_MOIRE = 6, // A cross hair with n concentric circles + rotation AMP_MOIRE = 6, // A cross hair with n concentric circles + rotation
AMP_THERMAL = 7 // Thermal shape (pos, outer and inner diameter, cross hair thickness + rotation) AMP_THERMAL = 7 // Thermal shape (pos, outer and inner diameter, cross hair
// thickness + rotation)
}; };
/** /**
* Struct AM_PRIMITIVE * An aperture macro primitive as given in Table 3 of
* holds an aperture macro primitive as given in Table 3 of
* http://gerbv.sourceforge.net/docs/rs274xrevd_e.pdf * http://gerbv.sourceforge.net/docs/rs274xrevd_e.pdf
*/ */
class AM_PRIMITIVE class AM_PRIMITIVE
@ -96,7 +98,8 @@ public:
// the primitive // the primitive
bool m_GerbMetric; // units for this primitive: bool m_GerbMetric; // units for this primitive:
// false = Inches, true = metric // false = Inches, true = metric
public: AM_PRIMITIVE( bool aGerbMetric, AM_PRIMITIVE_ID aId = AMP_UNKNOWN )
AM_PRIMITIVE( bool aGerbMetric, AM_PRIMITIVE_ID aId = AMP_UNKNOWN )
{ {
primitive_id = aId; primitive_id = aId;
m_GerbMetric = aGerbMetric; m_GerbMetric = aGerbMetric;
@ -106,7 +109,6 @@ public: AM_PRIMITIVE( bool aGerbMetric, AM_PRIMITIVE_ID aId = AMP_UNKNOWN )
~AM_PRIMITIVE() {} ~AM_PRIMITIVE() {}
/** /**
* Function IsAMPrimitiveExposureOn
* @return true if the first parameter is not 0 (it can be only 0 or 1). * @return true if the first parameter is not 0 (it can be only 0 or 1).
* Some but not all primitives use the first parameter as an exposure control. * Some but not all primitives use the first parameter as an exposure control.
* Others are always ON. * Others are always ON.
@ -117,127 +119,129 @@ public: AM_PRIMITIVE( bool aGerbMetric, AM_PRIMITIVE_ID aId = AMP_UNKNOWN )
/* Draw functions: */ /* Draw functions: */
/** GetShapeDim /**
* Calculate a value that can be used to evaluate the size of text * Calculate a value that can be used to evaluate the size of text when displaying the
* when displaying the D-Code of an item * D-Code of an item.
* due to the complexity of the shape of some primitives *
* one cannot calculate the "size" of a shape (only a bounding box) * Due to the complexity of the shape of some primitives one cannot calculate the "size"
* but here, the "dimension" of the shape is the diameter of the primitive * of a shape (only a bounding box) but here, the "dimension" of the shape is the diameter
* or for lines the width of the line * of the primitive or for lines the width of the line.
* @param aParent = the parent GERBER_DRAW_ITEM which is actually drawn *
* @param aParent is the parent GERBER_DRAW_ITEM which is actually drawn
* @return a dimension, or -1 if no dim to calculate * @return a dimension, or -1 if no dim to calculate
*/ */
int GetShapeDim( const GERBER_DRAW_ITEM* aParent ); int GetShapeDim( const GERBER_DRAW_ITEM* aParent );
/** /**
* Function drawBasicShape * Draw (in fact generate the actual polygonal shape of) the primitive shape of an aperture
* Draw (in fact generate the actual polygonal shape of) the primitive shape of an aperture macro instance. * macro instance.
* @param aParent = the parent GERBER_DRAW_ITEM which is actually drawn *
* @param aShapeBuffer = a SHAPE_POLY_SET to put the shape converted to a polygon * @param aParent is the parent GERBER_DRAW_ITEM which is actually drawn.
* @param aShapePos = the actual shape position * @param aShapeBuffer is a SHAPE_POLY_SET to put the shape converted to a polygon.
* @param aShapePos is the actual shape position.
*/ */
void DrawBasicShape( const GERBER_DRAW_ITEM* aParent, void DrawBasicShape( const GERBER_DRAW_ITEM* aParent,
SHAPE_POLY_SET& aShapeBuffer, SHAPE_POLY_SET& aShapeBuffer,
wxPoint aShapePos ); wxPoint aShapePos );
private:
private:
/** /**
* Function ConvertShapeToPolygon * Convert a shape to an equivalent polygon.
* convert a shape to an equivalent polygon. *
* Arcs and circles are approximated by segments * Arcs and circles are approximated by segments. Useful when a shape is not a graphic
* Useful when a shape is not a graphic primitive (shape with hole, * primitive (shape with hole, rotated shape ... ) and cannot be easily drawn.
* rotated shape ... ) and cannot be easily drawn.
*/ */
void ConvertShapeToPolygon( const GERBER_DRAW_ITEM* aParent, void ConvertShapeToPolygon( const GERBER_DRAW_ITEM* aParent, std::vector<wxPoint>& aBuffer );
std::vector<wxPoint>& aBuffer );
}; };
typedef std::vector<AM_PRIMITIVE> AM_PRIMITIVES; typedef std::vector<AM_PRIMITIVE> AM_PRIMITIVES;
/** /**
* Struct APERTURE_MACRO * Support the "aperture macro" defined within standard RS274X.
* helps support the "aperture macro" defined within standard RS274X.
*/ */
struct APERTURE_MACRO struct APERTURE_MACRO
{ {
wxString name; ///< The name of the aperture macro
AM_PRIMITIVES primitives; ///< A sequence of AM_PRIMITIVEs
/* A defered parameter can be defined in aperture macro,
* but outside aperture primitives. Example
* %AMRECTHERM*
* $4=$3/2* parameter $4 is half value of parameter $3
* m_localparamStack handle a list of local defered parameters
*/
AM_PARAMS m_localparamStack;
SHAPE_POLY_SET m_shape; ///< The shape of the item, calculated by GetApertureMacroShape
EDA_RECT m_boundingBox; ///< The bounding box of the item, calculated by GetApertureMacroShape
/** /**
* function GetLocalParam * Usually, parameters are defined inside the aperture primitive using immediate mode or
* Usually, parameters are defined inside the aperture primitive * deferred mode.
* using immediate mode or defered mode. *
* in defered mode the value is defined in a DCODE that want to use the aperture macro. * In deferred mode the value is defined in a DCODE that want to use the aperture macro.
* But some parameters are defined outside the aperture primitive * Some parameters are defined outside the aperture primitive and are local to the aperture
* and are local to the aperture macro * macro.
* @return the value of a defered parameter defined inside the aperture macro *
* @param aDcode = the D_CODE that uses this apertur macro and define defered parameters * @return the value of a deferred parameter defined inside the aperture macro.
* @param aParamId = the param id (defined by $3 or $5 ..) to evaluate * @param aDcode is the D_CODE that uses this aperture macro and define deferred parameters.
* @param aParamId is the param id (defined by $3 or $5 ..) to evaluate.
*/ */
double GetLocalParam( const D_CODE* aDcode, unsigned aParamId ) const; double GetLocalParam( const D_CODE* aDcode, unsigned aParamId ) const;
/** /**
* Function GetApertureMacroShape
* Calculate the primitive shape for flashed items. * Calculate the primitive shape for flashed items.
* When an item is flashed, this is the shape of the item *
* @param aParent = the parent GERBER_DRAW_ITEM which is actually drawn * When an item is flashed, this is the shape of the item.
* @return The shape of the item *
* @param aParent is the parent #GERBER_DRAW_ITEM which is actually drawn.
* @return the shape of the item.
*/ */
SHAPE_POLY_SET* GetApertureMacroShape( const GERBER_DRAW_ITEM* aParent, wxPoint aShapePos ); SHAPE_POLY_SET* GetApertureMacroShape( const GERBER_DRAW_ITEM* aParent, wxPoint aShapePos );
/** /**
* Function DrawApertureMacroShape
* Draw the primitive shape for flashed items. * Draw the primitive shape for flashed items.
* When an item is flashed, this is the shape of the item *
* @param aParent = the parent GERBER_DRAW_ITEM which is actually drawn * When an item is flashed, this is the shape of the item.
* @param aClipBox = DC clip box (NULL is no clip) *
* @param aDC = device context * @param aParent is the parent GERBER_DRAW_ITEM which is actually drawn.
* @param aColor = the color of shape * @param aClipBox is DC clip box (NULL is no clip).
* @param aShapePos = the actual shape position * @param aDC is the device context.
* @param aFilledShape = true to draw in filled mode, false to draw in skecth mode * @param aColor is the color of shape.
* @param aShapePos is the actual shape position.
* @param aFilledShape set to true to draw in filled mode, false to draw in sketch mode.
*/ */
void DrawApertureMacroShape( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox, wxDC* aDC, void DrawApertureMacroShape( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox, wxDC* aDC,
COLOR4D aColor, wxPoint aShapePos, bool aFilledShape ); COLOR4D aColor, wxPoint aShapePos, bool aFilledShape );
/** /**
* Function GetShapeDim * Calculate a value that can be used to evaluate the size of text when displaying the
* Calculate a value that can be used to evaluate the size of text * D-Code of an item.
* when displaying the D-Code of an item *
* due to the complexity of a shape using many primitives * Due to the complexity of a shape using many primitives one cannot calculate the "size" of
* one cannot calculate the "size" of a shape (only abounding box) * a shape (only abounding box) but most of aperture macro are using one or few primitives
* but most of aperture macro are using one or few primitives * and the "dimension" of the shape is the diameter of the primitive (or the max diameter of
* and the "dimension" of the shape is the diameter of the primitive * primitives).
* (or the max diameter of primitives) *
* @param aParent = the parent GERBER_DRAW_ITEM which is actually drawn * @param aParent is the parent #GERBER_DRAW_ITEM which is actually drawn.
* @return a dimension, or -1 if no dim to calculate * @return a dimension, or -1 if no dim to calculate.
*/ */
int GetShapeDim( GERBER_DRAW_ITEM* aParent ); int GetShapeDim( GERBER_DRAW_ITEM* aParent );
/// Returns the bounding box of the shape /// Return the bounding box of the shape.
EDA_RECT GetBoundingBox() const EDA_RECT GetBoundingBox() const
{ {
return m_boundingBox; return m_boundingBox;
} }
wxString name; ///< The name of the aperture macro
AM_PRIMITIVES primitives; ///< A sequence of AM_PRIMITIVEs
/* A deferred parameter can be defined in aperture macro,
* but outside aperture primitives. Example
* %AMRECTHERM*
* $4=$3/2* parameter $4 is half value of parameter $3
* m_localparamStack handle a list of local deferred parameters
*/
AM_PARAMS m_localparamStack;
SHAPE_POLY_SET m_shape; ///< The shape of the item, calculated by GetApertureMacroShape
EDA_RECT m_boundingBox; ///< The bounding box of the item, calculated by
///< GetApertureMacroShape.
}; };
/** /**
* Struct APERTURE_MACRO_less_than * Used by std:set<APERTURE_MACRO> instantiation which uses APERTURE_MACRO.name as its key.
* is used by std:set<APERTURE_MACRO> instantiation which uses
* APERTURE_MACRO.name as its key.
*/ */
struct APERTURE_MACRO_less_than struct APERTURE_MACRO_less_than
{ {
@ -250,9 +254,7 @@ struct APERTURE_MACRO_less_than
/** /**
* Type APERTURE_MACRO_SET * A sorted collection of APERTURE_MACROS whose key is the name field in the APERTURE_MACRO.
* is a sorted collection of APERTURE_MACROS whose key is the name field in
* the APERTURE_MACRO.
*/ */
typedef std::set<APERTURE_MACRO, APERTURE_MACRO_less_than> APERTURE_MACRO_SET; typedef std::set<APERTURE_MACRO, APERTURE_MACRO_less_than> APERTURE_MACRO_SET;
typedef std::pair<APERTURE_MACRO_SET::iterator, bool> APERTURE_MACRO_SET_PAIR; typedef std::pair<APERTURE_MACRO_SET::iterator, bool> APERTURE_MACRO_SET_PAIR;

View File

@ -2,8 +2,8 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2016 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -56,11 +56,6 @@
*/ */
/***************/
/* Class DCODE */
/***************/
D_CODE::D_CODE( int num_dcode ) D_CODE::D_CODE( int num_dcode )
{ {
m_Num_Dcode = num_dcode; m_Num_Dcode = num_dcode;
@ -117,9 +112,11 @@ const wxChar* D_CODE::ShowApertureType( APERTURE_T aType )
return ret; return ret;
} }
int D_CODE::GetShapeDim( GERBER_DRAW_ITEM* aParent ) int D_CODE::GetShapeDim( GERBER_DRAW_ITEM* aParent )
{ {
int dim = -1; int dim = -1;
switch( m_Shape ) switch( m_Shape )
{ {
case APT_CIRCLE: case APT_CIRCLE:
@ -148,9 +145,8 @@ int D_CODE::GetShapeDim( GERBER_DRAW_ITEM* aParent )
} }
void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent, void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox, wxDC* aDC,
EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor, COLOR4D aColor, const wxPoint& aShapePos, bool aFilledShape )
wxPoint aShapePos, bool aFilledShape )
{ {
int radius; int radius;
@ -264,10 +260,8 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent,
} }
void D_CODE::DrawFlashedPolygon( GERBER_DRAW_ITEM* aParent, void D_CODE::DrawFlashedPolygon( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox, wxDC* aDC,
EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor, bool aFilled, const wxPoint& aPosition )
COLOR4D aColor, bool aFilled,
const wxPoint& aPosition )
{ {
if( m_Polygon.OutlineCount() == 0 ) if( m_Polygon.OutlineCount() == 0 )
return; return;
@ -286,6 +280,7 @@ void D_CODE::DrawFlashedPolygon( GERBER_DRAW_ITEM* aParent,
GRClosedPoly( aClipBox, aDC, pointCount, &points[0], aFilled, aColor, aColor ); GRClosedPoly( aClipBox, aDC, pointCount, &points[0], aFilled, aColor, aColor );
} }
// TODO(snh): Remove the hard-coded count // TODO(snh): Remove the hard-coded count
#define SEGS_CNT 64 // number of segments to approximate a circle #define SEGS_CNT 64 // number of segments to approximate a circle
@ -293,8 +288,8 @@ void D_CODE::DrawFlashedPolygon( GERBER_DRAW_ITEM* aParent,
// A helper function for D_CODE::ConvertShapeToPolygon(). Add a hole to a polygon // A helper function for D_CODE::ConvertShapeToPolygon(). Add a hole to a polygon
static void addHoleToPolygon( SHAPE_POLY_SET* aPolygon, static void addHoleToPolygon( SHAPE_POLY_SET* aPolygon,
APERTURE_DEF_HOLETYPE aHoleShape, APERTURE_DEF_HOLETYPE aHoleShape,
wxSize aSize, const wxSize& aSize,
wxPoint aAnchorPos ); const wxPoint& aAnchorPos );
void D_CODE::ConvertShapeToPolygon() void D_CODE::ConvertShapeToPolygon()
@ -422,8 +417,8 @@ void D_CODE::ConvertShapeToPolygon()
// Add a hole to a polygon // Add a hole to a polygon
static void addHoleToPolygon( SHAPE_POLY_SET* aPolygon, static void addHoleToPolygon( SHAPE_POLY_SET* aPolygon,
APERTURE_DEF_HOLETYPE aHoleShape, APERTURE_DEF_HOLETYPE aHoleShape,
wxSize aSize, const wxSize& aSize,
wxPoint aAnchorPos ) const wxPoint& aAnchorPos )
{ {
wxPoint currpos; wxPoint currpos;
SHAPE_POLY_SET holeBuffer; SHAPE_POLY_SET holeBuffer;

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 1992-2010 Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr> * Copyright (C) 1992-2010 Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2010 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -43,8 +43,7 @@ class EDA_RECT;
/** /**
* Enum APERTURE_T * The set of all gerber aperture types allowed, according to page 16 of
* is the set of all gerber aperture types allowed, according to page 16 of
* http://gerbv.sourceforge.net/docs/rs274xrevd_e.pdf * http://gerbv.sourceforge.net/docs/rs274xrevd_e.pdf
*/ */
enum APERTURE_T { enum APERTURE_T {
@ -76,48 +75,19 @@ struct APERTURE_MACRO;
/** /**
* D_CODE * A gerber DCODE (also called Aperture) definition.
* holds a gerber DCODE (also called Aperture) definition.
*/ */
class D_CODE class D_CODE
{ {
private:
APERTURE_MACRO* m_Macro; ///< no ownership, points to
// GERBER.m_aperture_macros element
/**
* parameters used only when this D_CODE holds a reference to an aperture
* macro, and these parameters would customize the macro.
*/
std::vector<double> m_am_params;
public:
wxSize m_Size; ///< Horizontal and vertical dimensions.
APERTURE_T m_Shape; ///< shape ( Line, rectangle, circle , oval .. )
int m_Num_Dcode; ///< D code value ( >= 10 )
wxSize m_Drill; ///< dimension of the hole (if any) (draill file)
APERTURE_DEF_HOLETYPE m_DrillShape; ///< shape of the hole (0 = no hole, round = 1, rect = 2) */
double m_Rotation; ///< shape rotation in degrees
int m_EdgesCount; ///< in aperture definition Polygon only:
///< number of edges for the polygon
bool m_InUse; ///< false if the aperure (previously defined)
///< is not used to draw something
bool m_Defined; ///< false if the aperture is not defined in the header
wxString m_AperFunction; ///< the aperture attribute (created by a %TA.AperFunction command)
///< attached to the D_CODE
SHAPE_POLY_SET m_Polygon; /* Polygon used to draw APT_POLYGON shape and some other
* complex shapes which are converted to polygon
* (shapes with hole )
*/
public: public:
D_CODE( int num_dcode ); D_CODE( int num_dcode );
~D_CODE(); ~D_CODE();
void Clear_D_CODE_Data(); void Clear_D_CODE_Data();
/** /**
* AppendParam()
* Add a parameter to the D_CODE parameter list. * Add a parameter to the D_CODE parameter list.
* used to customize the corresponding aperture macro *
* Used to customize the corresponding aperture macro.
*/ */
void AppendParam( double aValue ) void AppendParam( double aValue )
{ {
@ -125,8 +95,7 @@ public:
} }
/** /**
* GetParamCount() * Return the number of parameters stored in parameter list.
* Returns the number of parameters stored in parameter list.
*/ */
unsigned GetParamCount() const unsigned GetParamCount() const
{ {
@ -134,88 +103,116 @@ public:
} }
/** /**
* GetParam() * Return a parameter stored in parameter list.
* Returns a parameter stored in parameter list. *
* @param aIdx = index of parameter * @param aIdx is the index of parameter.
*/ */
double GetParam( unsigned aIdx ) const double GetParam( unsigned aIdx ) const
{ {
wxASSERT( aIdx <= m_am_params.size() ); wxASSERT( aIdx <= m_am_params.size() );
if( aIdx <= m_am_params.size() ) if( aIdx <= m_am_params.size() )
return m_am_params[aIdx - 1]; return m_am_params[aIdx - 1];
else else
return 0; return 0;
} }
void SetMacro( APERTURE_MACRO* aMacro ) void SetMacro( APERTURE_MACRO* aMacro )
{ {
m_Macro = aMacro; m_Macro = aMacro;
} }
APERTURE_MACRO* GetMacro() const { return m_Macro; } APERTURE_MACRO* GetMacro() const { return m_Macro; }
/** /**
* Function ShowApertureType * Return a character string telling what type of aperture type \a aType is.
* returns a character string telling what type of aperture type \a aType is. *
* @param aType The aperture type to show. * @param aType is the aperture type to show.
*/ */
static const wxChar* ShowApertureType( APERTURE_T aType ); static const wxChar* ShowApertureType( APERTURE_T aType );
/** /**
* Function DrawFlashedShape
* Draw the dcode shape for flashed items. * Draw the dcode shape for flashed items.
* When an item is flashed, the DCode shape is the shape of the item *
* @param aParent = the GERBER_DRAW_ITEM being drawn * When an item is flashed, the DCode shape is the shape of the item.
* @param aClipBox = DC clip box (NULL is no clip) *
* @param aDC = device context * @param aParent is the #GERBER_DRAW_ITEM being drawn.
* @param aColor = the normal color to use * @param aClipBox is the device context clip box (NULL is no clip).
* @param aShapePos = the actual shape position * @param aDC is the device context.
* @param aFilledShape = true to draw in filled mode, false to draw in sketch mode * @param aColor is the normal color to use.
* @param aShapePos is the actual shape position
* @param aFilledShape set to true to draw in filled mode, false to draw in sketch mode
*/ */
void DrawFlashedShape( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox, void DrawFlashedShape( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox, wxDC* aDC,
wxDC* aDC, COLOR4D aColor, COLOR4D aColor, const wxPoint& aShapePos, bool aFilledShape );
wxPoint aShapePos, bool aFilledShape );
/** /**
* Function DrawFlashedPolygon * A helper function used to draw the polygon stored in m_PolyCorners.
* a helper function used to draw the polygon stored ion m_PolyCorners *
* Draw some Apertures shapes when they are defined as filled polygons. * Draw some Apertures shapes when they are defined as filled polygons. APT_POLYGON is
* APT_POLYGON is always a polygon, but some complex shapes are also converted to * always a polygon, but some complex shapes are also converted to polygons (shapes with
* polygons (shapes with holes, some rotated shapes) * holes, some rotated shapes).
* @param aParent = the GERBER_DRAW_ITEM being drawn *
* @param aClipBox = DC clip box (NULL is no clip) * @param aParent is the #GERBER_DRAW_ITEM being drawn.
* @param aDC = device context * @param aClipBox is the device context clip box (NULL is no clip).
* @param aColor = the normal color to use * @param aDC is the device context.
* @param aFilled = true to draw in filled mode, false to draw in sketch mode * @param aColor is the normal color to use.
* @param aPosition = the actual shape position * @param aFilled set to true to draw in filled mode, false to draw in sketch mode.
* @param aPosition is the actual shape position.
*/ */
void DrawFlashedPolygon( GERBER_DRAW_ITEM* aParent, void DrawFlashedPolygon( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox, wxDC* aDC,
EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor, COLOR4D aColor, bool aFilled, const wxPoint& aPosition );
bool aFilled, const wxPoint& aPosition );
/** /**
* Function ConvertShapeToPolygon * Convert a shape to an equivalent polygon.
* convert a shape to an equivalent polygon. *
* Arcs and circles are approximated by segments * Arcs and circles are approximated by segments. Useful when a shape is not a graphic
* Useful when a shape is not a graphic primitive (shape with hole, * primitive (shape with hole, rotated shape ... ) and cannot be easily drawn.
* rotated shape ... ) and cannot be easily drawn.
*/ */
void ConvertShapeToPolygon(); void ConvertShapeToPolygon();
/** /**
* Function GetShapeDim * Calculate a value that can be used to evaluate the size of text when displaying the
* calculates a value that can be used to evaluate the size of text * D-Code of an item.
* when displaying the D-Code of an item *
* due to the complexity of some shapes, * Due to the complexity of some shapes, one cannot calculate the "size" of a shape (only
* one cannot calculate the "size" of a shape (only a bounding box) * a bounding box) but here, the "dimension" of the shape is the diameter of the primitive
* but here, the "dimension" of the shape is the diameter of the primitive * or for lines the width of the line if the shape is a line.
* or for lines the width of the line if the shape is a line *
* @param aParent = the parent GERBER_DRAW_ITEM which is actually drawn * @param aParent is the parent GERBER_DRAW_ITEM which is actually drawn.
* @return a dimension, or -1 if no dim to calculate * @return a dimension, or -1 if no dim to calculate.
*/ */
int GetShapeDim( GERBER_DRAW_ITEM* aParent ); int GetShapeDim( GERBER_DRAW_ITEM* aParent );
public:
wxSize m_Size; ///< Horizontal and vertical dimensions.
APERTURE_T m_Shape; ///< shape ( Line, rectangle, circle , oval .. )
int m_Num_Dcode; ///< D code value ( >= 10 )
wxSize m_Drill; ///< dimension of the hole (if any) (drill file)
APERTURE_DEF_HOLETYPE m_DrillShape; ///< shape of the hole (0 = no hole, round = 1,
///< rect = 2).
double m_Rotation; ///< shape rotation in degrees
int m_EdgesCount; ///< in aperture definition Polygon only:
///< number of edges for the polygon
bool m_InUse; ///< false if the aperture (previously defined)
///< is not used to draw something
bool m_Defined; ///< false if the aperture is not defined in the header
wxString m_AperFunction; ///< the aperture attribute (created by a
///< %TA.AperFunction command).
///< attached to the D_CODE
SHAPE_POLY_SET m_Polygon; /* Polygon used to draw APT_POLYGON shape and some other
* complex shapes which are converted to polygon
* (shapes with hole )
*/
private:
APERTURE_MACRO* m_Macro; ///< no ownership, points to GERBER.m_aperture_macros element.
/**
* parameters used only when this D_CODE holds a reference to an aperture
* macro, and these parameters would customize the macro.
*/
std::vector<double> m_am_params;
}; };

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2011-2018 Jean-Pierre Charras jp.charras at wanadoo.fr * Copyright (C) 2011-2018 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2018 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -39,15 +39,6 @@ class GERBVIEW_FRAME;
*/ */
class LAYERS_MAP_DIALOG : public LAYERS_MAP_DIALOG_BASE class LAYERS_MAP_DIALOG : public LAYERS_MAP_DIALOG_BASE
{ {
private:
GERBVIEW_FRAME* m_Parent;
int m_gerberActiveLayersCount; // Number of initialized gerber layers
static int m_exportBoardCopperLayersCount;
LAYER_NUM m_layersLookUpTable[GERBER_DRAWLAYERS_COUNT]; // Indexes Gerber layers to PCB file layers
// the last value in table is the number of copper layers
int m_buttonTable[int(GERBER_DRAWLAYERS_COUNT)+1]; // Indexes buttons to Gerber layers
wxStaticText* m_layersList[int(GERBER_DRAWLAYERS_COUNT)+1]; // Indexes text strings to buttons
public: LAYERS_MAP_DIALOG( GERBVIEW_FRAME* parent ); public: LAYERS_MAP_DIALOG( GERBVIEW_FRAME* parent );
~LAYERS_MAP_DIALOG() {}; ~LAYERS_MAP_DIALOG() {};
@ -74,9 +65,9 @@ private:
* number. Gerbers that can be identified or which don't map to an * number. Gerbers that can be identified or which don't map to an
* equivalent KiCad PCB layer will be set to UNSELECTED_LAYER. * equivalent KiCad PCB layer will be set to UNSELECTED_LAYER.
* *
* @param aGerber2KicadMapping passed to return KiCad PCB layer number for each Gerber * @param aGerber2KicadMapping passed to return KiCad PCB layer number for each Gerber.
* *
* @return int - The number of loaded Gerbers that have Altium extensions * @return The number of loaded Gerbers that have Altium extensions.
*/ */
int findKnownGerbersLoaded( std::vector<int>& aGerber2KicadMapping ); int findKnownGerbersLoaded( std::vector<int>& aGerber2KicadMapping );
@ -89,9 +80,9 @@ private:
* number. Gerbers that aren't using Altium extensions or which don't map to an * number. Gerbers that aren't using Altium extensions or which don't map to an
* equivalent KiCad PCB layer will be set to UNSELECTED_LAYER. * equivalent KiCad PCB layer will be set to UNSELECTED_LAYER.
* *
* @param aGerber2KicadMapping passed to return KiCad PCB layer number for each Gerber * @param aGerber2KicadMapping passed to return KiCad PCB layer number for each Gerber.
* *
* @return int - The number of loaded Gerbers that have Altium extensions * @return The number of loaded Gerbers that have Altium extensions.
*/ */
int findNumAltiumGerbersLoaded( std::vector<int>& aGerber2KicadMapping ); int findNumAltiumGerbersLoaded( std::vector<int>& aGerber2KicadMapping );
@ -104,9 +95,9 @@ private:
* number. Gerbers that aren't using KiCad naming or which don't map to an * number. Gerbers that aren't using KiCad naming or which don't map to an
* equivalent KiCad PCB layer will be set to UNSELECTED_LAYER. * equivalent KiCad PCB layer will be set to UNSELECTED_LAYER.
* *
* @param aGerber2KicadMapping passed to return KiCad PCB layer number for each Gerber * @param aGerber2KicadMapping passed to return KiCad PCB layer number for each Gerber.
* *
* @return int - The number of loaded Gerbers using KiCad naming conventions * @return The number of loaded Gerbers using KiCad naming conventions.
*/ */
int findNumKiCadGerbersLoaded( std::vector<int>& aGerber2KicadMapping ); int findNumKiCadGerbersLoaded( std::vector<int>& aGerber2KicadMapping );
@ -119,14 +110,24 @@ private:
* number. Gerbers that aren't using X2 File functions or which don't map to an * number. Gerbers that aren't using X2 File functions or which don't map to an
* equivalent KiCad PCB layer will be set to UNSELECTED_LAYER. * equivalent KiCad PCB layer will be set to UNSELECTED_LAYER.
* *
* @param aGerber2KicadMapping passed to return KiCad PCB layer number for each Gerber * @param aGerber2KicadMapping passed to return KiCad PCB layer number for each Gerber.
* *
* @return int - The number of loaded Gerbers with X2 File Functions * @return The number of loaded Gerbers with X2 File Functions.
*/ */
int findNumX2GerbersLoaded( std::vector<int>& aGerber2KicadMapping ); int findNumX2GerbersLoaded( std::vector<int>& aGerber2KicadMapping );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
private:
GERBVIEW_FRAME* m_Parent;
int m_gerberActiveLayersCount; // Number of initialized gerber layers
static int m_exportBoardCopperLayersCount;
// Indexes Gerber layers to PCB file layers the last value in table is the number of
// copper layers.
LAYER_NUM m_layersLookUpTable[GERBER_DRAWLAYERS_COUNT];
int m_buttonTable[int(GERBER_DRAWLAYERS_COUNT)+1]; // Indexes buttons to Gerber layers
wxStaticText* m_layersList[int(GERBER_DRAWLAYERS_COUNT)+1]; // Indexes text strings to buttons
}; };
#endif // DIALOG_LAYERS_SELECT_TO_PCB_H_ #endif // DIALOG_LAYERS_SELECT_TO_PCB_H_

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -33,10 +33,6 @@ class GAL_OPTIONS_PANEL;
class PANEL_GERBVIEW_DISPLAY_OPTIONS : public PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE class PANEL_GERBVIEW_DISPLAY_OPTIONS : public PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE
{ {
private:
GERBVIEW_FRAME* m_Parent;
GAL_OPTIONS_PANEL* m_galOptsPanel;
public: public:
PANEL_GERBVIEW_DISPLAY_OPTIONS( GERBVIEW_FRAME* aFrame, wxWindow* aWindow ); PANEL_GERBVIEW_DISPLAY_OPTIONS( GERBVIEW_FRAME* aFrame, wxWindow* aWindow );
~PANEL_GERBVIEW_DISPLAY_OPTIONS() {}; ~PANEL_GERBVIEW_DISPLAY_OPTIONS() {};
@ -44,6 +40,9 @@ public:
private: private:
bool TransferDataToWindow() override; bool TransferDataToWindow() override;
bool TransferDataFromWindow() override; bool TransferDataFromWindow() override;
GERBVIEW_FRAME* m_Parent;
GAL_OPTIONS_PANEL* m_galOptsPanel;
}; };

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -31,9 +31,6 @@ class GERBVIEW_FRAME;
class PANEL_GERBVIEW_SETTINGS : public PANEL_GERBVIEW_SETTINGS_BASE class PANEL_GERBVIEW_SETTINGS : public PANEL_GERBVIEW_SETTINGS_BASE
{ {
private:
GERBVIEW_FRAME* m_Parent;
public: public:
PANEL_GERBVIEW_SETTINGS( GERBVIEW_FRAME* aFrame, wxWindow* aWindow ); PANEL_GERBVIEW_SETTINGS( GERBVIEW_FRAME* aFrame, wxWindow* aWindow );
~PANEL_GERBVIEW_SETTINGS() {}; ~PANEL_GERBVIEW_SETTINGS() {};
@ -41,6 +38,8 @@ public:
private: private:
bool TransferDataToWindow() override; bool TransferDataToWindow() override;
bool TransferDataFromWindow() override; bool TransferDataFromWindow() override;
GERBVIEW_FRAME* m_Parent;
}; };
#endif //KICAD_PANEL_GERBVIEW_SETTINGS_H #endif //KICAD_PANEL_GERBVIEW_SETTINGS_H

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2011-2016 Jean-Pierre Charras jp.charras at wanadoo.fr * Copyright (C) 2011-2016 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2016 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -73,7 +73,7 @@ enum drill_G_code_t {
DRILL_G_CCWMOVE DRILL_G_CCWMOVE
}; };
// Helper struct to analyse Excellon commands // Helper struct to analyze Excellon commands
struct EXCELLON_CMD struct EXCELLON_CMD
{ {
std::string m_Name; // key string std::string m_Name; // key string
@ -123,27 +123,14 @@ struct EXCELLON_ROUTE_COORD
wxPoint GetPos() { return wxPoint( m_x, m_y ); } wxPoint GetPos() { return wxPoint( m_x, m_y ); }
}; };
/* EXCELLON_IMAGE handle a drill image /**
* It is derived from GERBER_FILE_IMAGE because there is a lot of likeness * Handle a drill image.
* between EXCELLON files and GERBER files *
* DCode aperture are also similat to T Codes. * It is derived from #GERBER_FILE_IMAGE because there is a lot of likeness between EXCELLON
* So we can reuse GERBER_FILE_IMAGE to handle EXCELLON_IMAGE with very few new functions * files and GERBER files. DCode aperture are also similar to T Codes.
*/ */
class EXCELLON_IMAGE : public GERBER_FILE_IMAGE class EXCELLON_IMAGE : public GERBER_FILE_IMAGE
{ {
private:
enum excellon_state {
READ_HEADER_STATE, // When we are in this state, we are reading header
READ_PROGRAM_STATE // When we are in this state, we are reading drill data
};
excellon_state m_State; // state of excellon file analysis
bool m_SlotOn; // true during an oblong drill definition
// by G85 (canned slot) command
bool m_RouteModeOn; // true during a route mode (for instance a oval hole) or a cutout
std::vector<EXCELLON_ROUTE_COORD> m_RoutePositions; // The list of points in a route mode
public: EXCELLON_IMAGE( int layer ) : public: EXCELLON_IMAGE( int layer ) :
GERBER_FILE_IMAGE( layer ) GERBER_FILE_IMAGE( layer )
{ {
@ -164,10 +151,11 @@ public: EXCELLON_IMAGE( int layer ) :
/** /**
* Read and load a drill (EXCELLON format) file. * Read and load a drill (EXCELLON format) file.
* @param aFullFileName = the full filename of the Gerber file *
* when the file cannot be loaded * When the file cannot be loaded, warning and info messages are stored in m_Messages.
* Warning and info messages are stored in m_Messages *
* @return bool if OK, false if the gerber file was not loaded * @param aFullFileName is the full filename of the Gerber file.
* @return true if OK, false if the gerber file was not loaded.
*/ */
bool LoadFile( const wxString& aFullFileName ); bool LoadFile( const wxString& aFullFileName );
@ -177,8 +165,9 @@ private:
bool Execute_EXCELLON_G_Command( char*& text ); bool Execute_EXCELLON_G_Command( char*& text );
bool Execute_Drill_Command( char*& text ); bool Execute_Drill_Command( char*& text );
/** Read a tool definition like T1C0.02 or T1F00S00C0.02 or T1C0.02F00S00 /**
* and enter params in TCODE list * Read a tool definition like T1C0.02 or T1F00S00C0.02 or T1C0.02F00S00
* and enter params in TCODE list.
*/ */
bool readToolInformation( char*& aText ); bool readToolInformation( char*& aText );
@ -187,11 +176,25 @@ private:
return DCodeNumber( aText ); return DCodeNumber( aText );
} }
/** Ends a route command started by M15 ot G01, G02 or G03 command /**
* End a route command started by M15 ot G01, G02 or G03 command.
*/ */
void FinishRouteCommand(); void FinishRouteCommand();
void SelectUnits( bool aMetric ); void SelectUnits( bool aMetric );
private:
enum excellon_state {
READ_HEADER_STATE, // When we are in this state, we are reading header
READ_PROGRAM_STATE // When we are in this state, we are reading drill data
};
excellon_state m_State; // state of excellon file analysis
bool m_SlotOn; // true during an oblong drill definition
// by G85 (canned slot) command
bool m_RouteModeOn; // true during a route mode (for instance a oval hole) or
// a cutout.
std::vector<EXCELLON_ROUTE_COORD> m_RoutePositions; // The list of points in a route mode
}; };

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2007-2014 Jean-Pierre Charras jp.charras at wanadoo.fr * Copyright (C) 2007-2014 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2020 KiCad Developers, see change_log.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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -46,120 +46,122 @@ class GERBVIEW_FRAME;
/** /**
* A helper class to export a Gerber set of files to Pcbnew * A helper class to export a Gerber set of files to Pcbnew.
*/ */
class GBR_TO_PCB_EXPORTER class GBR_TO_PCB_EXPORTER
{ {
public:
GBR_TO_PCB_EXPORTER( GERBVIEW_FRAME* aFrame, const wxString& aFileName );
~GBR_TO_PCB_EXPORTER();
/**
* Save a board from a set of Gerber images.
*/
bool ExportPcb( const LAYER_NUM* aLayerLookUpTable, int aCopperLayers );
private:
/**
* Collect holes from a drill layer.
*
* We'll use these later when writing pads & vias.
*/
void collect_hole( const GERBER_DRAW_ITEM* aGbrItem );
/**
* Write a via to the board file.
*
* Some of these will represent actual vias while others are used to represent
* holes in pads. (We can't generate actual pads because the Gerbers don't contain
* info on how to group them into footprints.)
*/
void export_via( const EXPORT_VIA& aVia );
/**
* Write a non copper line or arc to the board file.
*
* @param aGbrItem is the Gerber item (line, arc) to export.
* @param aLayer is the technical layer to use.
*/
void export_non_copper_item( const GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
/**
* Write a non-copper polygon to the board file.
*
* @param aLayer is the technical layer to use.
*/
void writePcbPolygon( const SHAPE_POLY_SET& aPolys, LAYER_NUM aLayer,
const wxPoint& aOffset = { 0, 0 } );
/**
* Write a zone item to the board file.
*
* @warning This is experimental for tests only.
*
* @param aGbrItem is the Gerber item (line, arc) to export.
* @param aLayer is the technical layer to use.
*/
void writePcbZoneItem( const GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
/**
* Write a track (or via) to the board file.
*
* @param aGbrItem is the Gerber item (line, arc, flashed) to export.
* @param aLayer is the copper layer to use.
*/
void export_copper_item( const GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
/**
* Write a synthetic pad to the board file.
*
* We can't create real pads because the Gerbers don't store grouping/footprint info.
* So we synthesize a pad with a via for the hole (if present) and a copper polygon for
* the pad.
*
* @param aGbrItem is the flashed Gerber item to export.
*/
void export_flashed_copper_item( const GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
/**
* Write a track (not via) to the board file.
*
* @param aGbrItem is the Gerber item (line only) to export.
* @param aLayer is the copper layer to use.
*/
void export_segline_copper_item( const GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
/**
* Write a set of tracks (arcs are approximated by track segments) to the board file.
*
* @param aGbrItem is the Gerber item (arc only) to export.
* @param aLayer is the copper layer to use
*/
void export_segarc_copper_item( const GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
/**
* Basic write function to write a a #TRACK item to the board file from a non flashed item.
*/
void writeCopperLineItem( const wxPoint& aStart, const wxPoint& aEnd,
int aWidth, LAYER_NUM aLayer );
/**
* Write a very basic header to the board file.
*/
void writePcbHeader( const LAYER_NUM* aLayerLookUpTable );
/**
* Map GerbView internal units to millimeters for Pcbnew board files.
*
* @param aValue is a coordinate value to convert in mm.
*/
double MapToPcbUnits( int aValue ) const
{
return aValue / IU_PER_MM;
}
private: private:
GERBVIEW_FRAME* m_gerbview_frame; // the main gerber frame GERBVIEW_FRAME* m_gerbview_frame; // the main gerber frame
wxString m_pcb_file_name; // BOARD file to write to wxString m_pcb_file_name; // BOARD file to write to
FILE* m_fp; // the board file FILE* m_fp; // the board file
int m_pcbCopperLayersCount; int m_pcbCopperLayersCount;
std::vector<EXPORT_VIA> m_vias; std::vector<EXPORT_VIA> m_vias;
public:
GBR_TO_PCB_EXPORTER( GERBVIEW_FRAME* aFrame, const wxString& aFileName );
~GBR_TO_PCB_EXPORTER();
/**
* Function ExportPcb
* saves a board from a set of Gerber images.
*/
bool ExportPcb( const LAYER_NUM* aLayerLookUpTable, int aCopperLayers );
private:
/**
* collect holes from a drill layer.
* We'll use these later when writing pads & vias.
* @param aGbrItem
*/
void collect_hole( const GERBER_DRAW_ITEM* aGbrItem );
/**
* write a via to the board file.
* Some of these will represent actual vias while others are used to represent
* holes in pads. (We can't generate actual pads because the Gerbers don't contain
* info on how to group them into footprints.)
* @param aVia
*/
void export_via( const EXPORT_VIA& aVia );
/**
* write a non copper line or arc to the board file.
* @param aGbrItem = the Gerber item (line, arc) to export
* @param aLayer = the technical layer to use
*/
void export_non_copper_item( const GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
/**
* write a non-copper polygon to the board file.
* @param aLayer = the technical layer to use
*/
void writePcbPolygon( const SHAPE_POLY_SET& aPolys, LAYER_NUM aLayer,
const wxPoint& aOffset = { 0, 0 } );
/**
* write a zone item to the board file.
* Currently: only experimental, for tests
* @param aGbrItem = the Gerber item (line, arc) to export
* @param aLayer = the technical layer to use
*/
void writePcbZoneItem( const GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
/**
* write a track (or via) to the board file.
* @param aGbrItem = the Gerber item (line, arc, flashed) to export
* @param aLayer = the copper layer to use
*/
void export_copper_item( const GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
/**
* Function export_flashed_copper_item
* write a synthetic pad to the board file.
* We can't create real pads because the Gerbers don't store grouping/footprint info.
* So we synthesize a pad with a via for the hole (if present) and a copper polygon for
* the pad.
* @param aGbrItem = the flashed Gerber item to export
*/
void export_flashed_copper_item( const GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
/**
* Function export_segline_copper_item
* write a track (not via) to the board file.
* @param aGbrItem = the Gerber item (line only) to export
* @param aLayer = the copper layer to use
*/
void export_segline_copper_item( const GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
/**
* Function export_segarc_copper_item
* write a set of tracks (arcs are approximated by track segments)
* to the board file.
* @param aGbrItem = the Gerber item (arc only) to export
* @param aLayer = the copper layer to use
*/
void export_segarc_copper_item( const GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
/**
* function writeCopperLineItem
* basic write function to write a a TRACK item
* to the board file, from a non flashed item
*/
void writeCopperLineItem( const wxPoint& aStart,
const wxPoint& aEnd,
int aWidth, LAYER_NUM aLayer );
/**
* function writePcbHeader
* Write a very basic header to the board file
*/
void writePcbHeader( const LAYER_NUM* aLayerLookUpTable );
/** In Pcbnew files units are mm for coordinates.
* So MapToPcbUnits converts internal gerbview to mm any pcbnew value
* @param aValue is a coordinate value to convert in mm
*/
double MapToPcbUnits( int aValue ) const
{
return aValue / IU_PER_MM;
}
}; };

View File

@ -44,11 +44,6 @@ class GERBER_FILE_IMAGE_LIST;
*/ */
class GBR_LAYOUT : public EDA_ITEM class GBR_LAYOUT : public EDA_ITEM
{ {
private:
mutable EDA_RECT m_BoundingBox;
TITLE_BLOCK m_titles;
wxPoint m_originAxisPosition;
public: public:
GBR_LAYOUT(); GBR_LAYOUT();
~GBR_LAYOUT(); ~GBR_LAYOUT();
@ -88,6 +83,11 @@ public:
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
#endif #endif
private:
mutable EDA_RECT m_BoundingBox;
TITLE_BLOCK m_titles;
wxPoint m_originAxisPosition;
}; };
#endif // #ifndef GBR_LAYOUT_H #endif // #ifndef GBR_LAYOUT_H

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software: you can redistribute it and/or modify it * 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 * under the terms of the GNU General Public License as published by the
@ -23,37 +23,11 @@
#include <collector.h> #include <collector.h>
/** /**
* GERBER_COLLECTOR * Use when the right click button is pressed or when the select tool is in effect.
* is intended for use when the right click button is pressed, or when the
* plain "arrow" tool is in effect.
*/ */
class GERBER_COLLECTOR : public COLLECTOR class GERBER_COLLECTOR : public COLLECTOR
{ {
protected:
/**
* A place to hold collected objects which don't match precisely the search
* criteria, but would be acceptable if nothing else is found.
* "2nd" choice, which will be appended to the end of COLLECTOR's prime
* "list" at the end of the search.
*/
std::vector<EDA_ITEM*> m_List2nd;
/**
* Determines which items are to be collected by Inspect()
*/
//const COLLECTORS_GUIDE* m_Guide;
/**
* The number of items that were originally in the primary list before the
* m_List2nd was concatenated onto the end of it.
*/
int m_PrimaryLength;
public: public:
/** /**
* A scan list for all selectable gerber items * A scan list for all selectable gerber items
*/ */
@ -76,59 +50,73 @@ public:
m_List2nd.push_back( item ); m_List2nd.push_back( item );
}*/ }*/
/** /**
* Function SetGuide * Record which COLLECTORS_GUIDE to use.
* records which COLLECTORS_GUIDE to use. *
* @param aGuide Which guide to use in the collection. * @param aGuide is the guide to use in the collection.
*/ */
//void SetGuide( const COLLECTORS_GUIDE* aGuide ) { m_Guide = aGuide; } //void SetGuide( const COLLECTORS_GUIDE* aGuide ) { m_Guide = aGuide; }
/** /**
* Function operator[int] * Overload the [](int) operator to return a EDA_ITEM* instead of an EDA_ITEM* type.
* overloads COLLECTOR::operator[](int) to return a EDA_ITEM* instead of *
* an EDA_ITEM* type.
* @param ndx The index into the list. * @param ndx The index into the list.
* @return EDA_ITEM* - or something derived from it, or NULL. * @return the item collected or NULL.
*/ */
EDA_ITEM* operator[]( int ndx ) const override EDA_ITEM* operator[]( int ndx ) const override
{ {
if( (unsigned)ndx < (unsigned)GetCount() ) if( (unsigned)ndx < (unsigned)GetCount() )
return (EDA_ITEM*) m_list[ ndx ]; return (EDA_ITEM*) m_list[ ndx ];
return NULL; return NULL;
} }
/** /**
* Function GetPrimaryCount * @return The number if items which met the primary search criteria.
* @return int - The number if items which met the primary search criteria
*/ */
int GetPrimaryCount() { return m_PrimaryLength; } int GetPrimaryCount() { return m_PrimaryLength; }
/** /**
* Function Inspect * The examining function within the INSPECTOR which is passed to the Iterate function.
* is the examining function within the INSPECTOR which is passed to the
* Iterate function.
* *
* @param testItem An EDA_ITEM to examine. * @param testItem An EDA_ITEM to examine.
* @param testData is not used in this class. * @param testData is not used in this class.
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan, * @return SEARCH_QUIT if the Iterator is to stop the scan else SCAN_CONTINUE.
* else SCAN_CONTINUE;
*/ */
SEARCH_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override; SEARCH_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
/** /**
* Function Collect * Scan an EDA_ITEM using this class's Inspector method, which does the collection.
* scans an EDA_ITEM using this class's Inspector method, which does the collection. *
* @param aItem An EDA_ITEM to scan * @param aItem An EDA_ITEM to scan
* @param aScanList A list of KICAD_Ts with a terminating EOT, that specs * @param aScanList A list of KICAD_Ts with a terminating EOT, that specs
* what is to be collected and the priority order of the resultant * what is to be collected and the priority order of the resultant
* collection in "m_list". * collection in "m_list".
* @param aRefPos A wxPoint to use in hit-testing. * @param aRefPos A wxPoint to use in hit-testing.
* @param aGuide The COLLECTORS_GUIDE to use in collecting items. * @param aGuide The COLLECTORS_GUIDE to use in collecting items.
*/ */
void Collect( EDA_ITEM* aItem, const KICAD_T aScanList[], void Collect( EDA_ITEM* aItem, const KICAD_T aScanList[],
const wxPoint& aRefPos/*, const COLLECTORS_GUIDE& aGuide */); const wxPoint& aRefPos /*, const COLLECTORS_GUIDE& aGuide */ );
protected:
/**
* A place to hold collected objects which don't match precisely the search
* criteria, but would be acceptable if nothing else is found.
* "2nd" choice, which will be appended to the end of COLLECTOR's prime
* "list" at the end of the search.
*/
std::vector<EDA_ITEM*> m_List2nd;
/**
* Determines which items are to be collected by Inspect()
*/
//const COLLECTORS_GUIDE* m_Guide;
/**
* The number of items that were originally in the primary list before the
* m_List2nd was concatenated onto the end of it.
*/
int m_PrimaryLength;
}; };
#endif #endif

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2010-2016 Jean-Pierre Charras jp.charras at wanadoo.fr * Copyright (C) 2010-2016 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2016 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -40,7 +40,7 @@
* have specific parameters * have specific parameters
* if a Image parameter is set more than once, only the last value is used * if a Image parameter is set more than once, only the last value is used
* Some parameters can change along a file and are not layer specific: they are stored * Some parameters can change along a file and are not layer specific: they are stored
* in GERBER_ITEM items, when instancied. * in GERBER_ITEM items, when instanced.
* *
* In GerbView, to handle these parameters, there are 2 classes: * In GerbView, to handle these parameters, there are 2 classes:
* GERBER_FILE_IMAGE : the main class containing most of parameters and data to plot a graphic layer * GERBER_FILE_IMAGE : the main class containing most of parameters and data to plot a graphic layer
@ -48,7 +48,7 @@
* There is one GERBER_FILE_IMAGE per file and one graphic layer per file or GERBER_FILE_IMAGE * There is one GERBER_FILE_IMAGE per file and one graphic layer per file or GERBER_FILE_IMAGE
* GerbView does not read and merge 2 gerber file in one graphic layer: * GerbView does not read and merge 2 gerber file in one graphic layer:
* I believe this is not possible due to the constraints in Image parameters. * I believe this is not possible due to the constraints in Image parameters.
* GERBER_LAYER : containing the subset of parameters that is layer speficic * GERBER_LAYER : containing the subset of parameters that is layer specific
* A GERBER_FILE_IMAGE must include one GERBER_LAYER to define all parameters to plot a file. * A GERBER_FILE_IMAGE must include one GERBER_LAYER to define all parameters to plot a file.
* But a GERBER_FILE_IMAGE can use more than one GERBER_LAYER. * But a GERBER_FILE_IMAGE can use more than one GERBER_LAYER.
*/ */
@ -62,14 +62,10 @@ class GERBER_FILE_IMAGE;
*/ */
class GERBER_FILE_IMAGE_LIST class GERBER_FILE_IMAGE_LIST
{ {
// the list of loaded images (1 image = 1 gerber file)
std::vector<GERBER_FILE_IMAGE*> m_GERBER_List;
public: public:
GERBER_FILE_IMAGE_LIST(); GERBER_FILE_IMAGE_LIST();
~GERBER_FILE_IMAGE_LIST(); ~GERBER_FILE_IMAGE_LIST();
//Accessor
static GERBER_FILE_IMAGE_LIST& GetImagesList(); static GERBER_FILE_IMAGE_LIST& GetImagesList();
GERBER_FILE_IMAGE* GetGbrImage( int aIdx ); GERBER_FILE_IMAGE* GetGbrImage( int aIdx );
@ -78,8 +74,8 @@ public:
/** /**
* Add a GERBER_FILE_IMAGE* at index aIdx or at the first free location if aIdx < 0 * Add a GERBER_FILE_IMAGE* at index aIdx or at the first free location if aIdx < 0
* *
* @param aGbrImage = the image to add * @param aGbrImage is the image to add.
* @param aIdx = the location to use ( 0 ... GERBER_DRAWLAYERS_COUNT-1 ) * @param aIdx is the location to use ( 0 ... GERBER_DRAWLAYERS_COUNT-1 ).
* @return true if the index used, or -1 if no room to add image * @return true if the index used, or -1 if no room to add image
*/ */
int AddGbrImage( GERBER_FILE_IMAGE* aGbrImage, int aIdx ); int AddGbrImage( GERBER_FILE_IMAGE* aGbrImage, int aIdx );
@ -91,28 +87,29 @@ public:
void DeleteAllImages(); void DeleteAllImages();
/** /**
* Delete the loaded data of image aIdx, freeing the memory. * Delete the loaded data of image \a aIdx, freeing the memory.
* *
* @param aIdx = the index ( 0 ... GERBER_DRAWLAYERS_COUNT-1 ) * @param aIdx is the index ( 0 ... GERBER_DRAWLAYERS_COUNT-1 ).
*/ */
void DeleteImage( int aIdx ); void DeleteImage( int aIdx );
/** /**
* Get the display name for the layer at aIdx. * Get the display name for the layer at \a aIdx.
* *
* @param aIdx = the index ( 0 ... GERBER_DRAWLAYERS_COUNT-1 )
* @param aNameOnly = false (default) to add the layer number (for layers manager)
* or true to return only the name without layer name (status bar)
* @param aFullName = false (default) to ellipsize the name, true to return the full name.
*
* @return a name for image aIdx which can be used in layers manager
* and layer selector or in the status bar
* if a file is loaded, the name is: * if a file is loaded, the name is:
* "<aIdx+1> <short filename> <X2 FileFunction info> if a X2 FileFunction info is found" * "<aIdx+1> <short filename> <X2 FileFunction info> if a X2 FileFunction info is found"
* or (if no FileFunction info) * or (if no FileFunction info)
* "<aIdx+1> <short filename> *" * "<aIdx+1> <short filename> *"
* if no file loaded, the name is: * if no file loaded, the name is:
* "Layer n" with n = aIdx+1 * "Layer n" with n = aIdx+1
*
* @param aIdx is the index ( 0 ... GERBER_DRAWLAYERS_COUNT-1 ).
* @param aNameOnly set to false (default) to add the layer number (for layers manager)
* or true to return only the name without layer name (status bar)/
* @param aFullName set to false (default) to ellipsize the name, true to return the full name.
*
* @return a name for image aIdx which can be used in layers manager and layer selector or
* in the status bar
*/ */
const wxString GetDisplayName( int aIdx, bool aNameOnly = false, bool aFullName = false ); const wxString GetDisplayName( int aIdx, bool aNameOnly = false, bool aFullName = false );
@ -123,6 +120,10 @@ public:
* @return a mapping of old to new layer index * @return a mapping of old to new layer index
*/ */
std::unordered_map<int, int> SortImagesByZOrder(); std::unordered_map<int, int> SortImagesByZOrder();
private:
// the list of loaded images (1 image = 1 gerber file)
std::vector<GERBER_FILE_IMAGE*> m_GERBER_List;
}; };
#endif // ifndef GERBER_FILE_IMAGE_LIST_H #endif // ifndef GERBER_FILE_IMAGE_LIST_H

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2004-2010 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2004-2010 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2010 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2010-2021 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -34,53 +34,22 @@
#include "layer_widget.h" #include "layer_widget.h"
/** /**
* GERBER_LAYER_WIDGET * Abstract functions of LAYER_WIDGET so they may be tied into the GERBVIEW_FRAME's data and
* is here to implement the abtract functions of LAYER_WIDGET so they * we can add a popup menu which is specific to Pcbnew's needs.
* may be tied into the GERBVIEW_FRAME's data and so we can add a popup
* menu which is specific to Pcbnew's needs.
*/ */
class GERBER_LAYER_WIDGET : public LAYER_WIDGET class GERBER_LAYER_WIDGET : public LAYER_WIDGET
{ {
GERBVIEW_FRAME* myframe;
bool m_alwaysShowActiveLayer; // If true: Only shows the current active layer
// even if it is changed
/**
* Function OnRightDownLayers
* puts up a popup menu for the layer panel.
*/
void onRightDownLayers( wxMouseEvent& event );
void onPopupSelection( wxCommandEvent& event );
/// this is for the popup menu, the right click handler has to be installed
/// on every child control within the layer panel.
void installRightLayerClickHandler();
/**
* Virtual Function useAlternateBitmap
* @return true if bitmaps shown in Render layer list
* are alternate bitmaps, or false if they are "normal" bitmaps
*/
virtual bool useAlternateBitmap(int aRow) override;
GERBER_FILE_IMAGE_LIST* GetImagesList();
public: public:
/** /**
* Constructor * @param aParent is the parent frame.
* @param aParent : the parent frame * @param aFocusOwner is the window that has the keyboard focus.
* @param aFocusOwner : the window that has the keyboard focus.
*/ */
GERBER_LAYER_WIDGET( GERBVIEW_FRAME* aParent, wxWindow* aFocusOwner ); GERBER_LAYER_WIDGET( GERBVIEW_FRAME* aParent, wxWindow* aFocusOwner );
void ReFill(); void ReFill();
/** /**
* Function ReFillRender * Rebuild Render for instance after the config is read.
* Rebuild Render for instance after the config is read
*/ */
void ReFillRender(); void ReFillRender();
@ -93,30 +62,28 @@ public:
void OnRenderEnable( int aId, bool isEnabled ) override; void OnRenderEnable( int aId, bool isEnabled ) override;
/** /**
* Function SetLayersManagerTabsText * Update the layer manager tabs labels.
* Update the layer manager tabs labels *
* Useful when changing Language or to set labels to a non default value * Useful when changing Language or to set labels to a non default value.
*/ */
void SetLayersManagerTabsText( ); void SetLayersManagerTabsText( );
//-----</implement LAYER_WIDGET abstract callback functions>---------- //-----</implement LAYER_WIDGET abstract callback functions>----------
/** /**
* Function OnLayerSelected * Ensure the active layer is visible, and other layers not visible when
* ensure the active layer is visible, and other layers not visible * m_alwaysShowActiveLayer is true.
* when m_alwaysShowActiveLayer is true *
* Otherwise do nothing. * @return true m_alwaysShowActiveLayer is true and the canvas is refreshed else false
* @return true m_alwaysShowActiveLayer is true and the canvas is refreshed, * if do nothing.
* and false if do nothing
*/ */
bool OnLayerSelected(); // postprocess after an active layer selection bool OnLayerSelected(); // postprocess after an active layer selection
// ensure active layer visible if // ensure active layer visible if
// m_alwaysShowActiveCopperLayer is true; // m_alwaysShowActiveCopperLayer is true;
/** /**
* Function addRightClickMenuItems * Add menu items to a menu that should be shown when right-clicking the Gerber layer widget.
* add menu items to a menu that should be shown when right-clicking *
* the Gerber layer widget. * @param aMenu is the menu to modify: menuitems will be added to aMenu.
* @param aMenu is the menu to modify: menuitems will be added to aMenu
*/ */
void AddRightClickMenuItems( wxMenu* aMenu ); void AddRightClickMenuItems( wxMenu* aMenu );
@ -132,6 +99,31 @@ protected:
ID_SORT_GBR_LAYERS, ID_SORT_GBR_LAYERS,
ID_LAYER_MANAGER_END = ID_SORT_GBR_LAYERS, ID_LAYER_MANAGER_END = ID_SORT_GBR_LAYERS,
}; };
private:
/**
* Put up a popup menu for the layer panel.
*/
void onRightDownLayers( wxMouseEvent& event );
void onPopupSelection( wxCommandEvent& event );
/// this is for the popup menu, the right click handler has to be installed
/// on every child control within the layer panel.
void installRightLayerClickHandler();
/**
* @return true if bitmaps shown in Render layer list are alternate bitmaps else false if
* they are "normal" bitmaps.
*/
virtual bool useAlternateBitmap( int aRow ) override;
GERBER_FILE_IMAGE_LIST* GetImagesList();
GERBVIEW_FRAME* myframe;
bool m_alwaysShowActiveLayer; // If true: Only shows the current active layer
// even if it is changed
}; };
#endif // GERBER_LAYER_WIDGET_H #endif // GERBER_LAYER_WIDGET_H

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2010 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2010-2021 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -58,41 +58,39 @@
using KIGFX::COLOR4D; using KIGFX::COLOR4D;
/** /**
* LAYER_WIDGET * Manage a list of layers with the notion of a "current" layer, and layer specific visibility
* is abstract and is used to manage a list of layers, with the notion of * control.
* a "current" layer, and layer specific visibility control. You must derive from *
* it to use it so you can implement the abstract functions which recieve the * You must derive from it to use it so you can implement the abstract functions which receive
* events. Each layer is given its own color, and that color can be changed * the events. Each layer is given its own color, and that color can be changed within the UI
* within the UI provided here. This widget knows nothing of the client code, meaning * provided here. This widget knows nothing of the client code, meaning it has no knowledge of
* it has no knowledge of a BOARD or anything. To use it you must derive from * a BOARD or anything. To use it you must derive from this class and implement the abstract
* this class and implement the abstract functions: * functions:
* <p> void OnLayerColorChange( int aLayer, int aColor ); * <p> void OnLayerColorChange( int aLayer, int aColor );
* <p> bool OnLayerSelect( int aLayer ); * <p> bool OnLayerSelect( int aLayer );
* <p> void OnLayerVisible( int aLayer, bool isVisible ); * <p> void OnLayerVisible( int aLayer, bool isVisible );
* <p> void OnRenderColorChange( int id, int aColor ); * <p> void OnRenderColorChange( int id, int aColor );
* <p> void OnRenderEnable( int id, bool isEnabled ); * <p> void OnRenderEnable( int id, bool isEnabled );
* *
* Please note that even if designed toward layers, it is used to * @note Even if designed toward layers, it is used to contain other stuff, too (the second page
* contain other stuff, too (the second page in pcbnew contains render * in pcbnew contains render items, for example).
* items, for example)
*/ */
class LAYER_WIDGET : public wxPanel class LAYER_WIDGET : public wxPanel
{ {
public: public:
/** /**
* Struct ROW * Provide all the data needed to add a row to a LAYER_WIDGET. This is
* provides all the data needed to add a row to a LAYER_WIDGET. This is
* part of the public API for a LAYER_WIDGET. * part of the public API for a LAYER_WIDGET.
*/ */
struct ROW struct ROW
{ {
wxString rowName; ///< the prompt or layername wxString rowName; ///< the prompt or layername
int id; ///< either a layer or "visible element" id int id; ///< either a layer or "visible element" id
COLOR4D color; ///< COLOR4D::UNSPECIFIED if none. COLOR4D color; ///< COLOR4D::UNSPECIFIED if none.
bool state; ///< initial wxCheckBox state bool state; ///< initial wxCheckBox state
wxString tooltip; ///< if not empty, use this tooltip on row wxString tooltip; ///< if not empty, use this tooltip on row
bool changeable; ///< if true, the state can be changed bool changeable; ///< if true, the state can be changed
bool spacer; ///< if true, this row is a spacer bool spacer; ///< if true, this row is a spacer
COLOR4D defaultColor; ///< The default color for the row COLOR4D defaultColor; ///< The default color for the row
ROW( const wxString& aRowName, int aId, COLOR4D aColor = COLOR4D::UNSPECIFIED, ROW( const wxString& aRowName, int aId, COLOR4D aColor = COLOR4D::UNSPECIFIED,
@ -122,150 +120,15 @@ public:
static const wxEventType EVT_LAYER_COLOR_CHANGE; static const wxEventType EVT_LAYER_COLOR_CHANGE;
protected:
wxAuiNotebook* m_notebook;
wxPanel* m_LayerPanel;
wxScrolledWindow* m_LayerScrolledWindow;
wxFlexGridSizer* m_LayersFlexGridSizer;
wxPanel* m_RenderingPanel;
wxScrolledWindow* m_RenderScrolledWindow;
wxFlexGridSizer* m_RenderFlexGridSizer;
wxWindow* m_FocusOwner;
int m_CurrentRow; ///< selected row of layer list
int m_PointSize;
ROW_ICON_PROVIDER* m_IconProvider;
wxString m_smallestLayerString;
/**
* Virtual Function useAlternateBitmap
* @return true if bitmaps shown in Render layer list
* are alternate bitmaps, or false if they are "normal" bitmaps
* This is a virtual function because Pcbnew uses normal bitmaps
* but GerbView uses both bitmaps
* (alternate bitmaps to show layers in use, normal fo others)
*/
virtual bool useAlternateBitmap(int aRow) { return false; }
/**
* Subclasses can override this to provide accurate representation
* of transparent colour swatches.
*/
virtual COLOR4D getBackgroundLayerColor() { return COLOR4D::BLACK; }
/**
* Function encodeId
* is here to allow saving a layer index within a control as its wxControl id,
* but to do so in a way that all child wxControl ids within a wxWindow are unique,
* since this is required by Windows.
* @see getDecodedId()
*/
static int encodeId( int aColumn, int aId );
/**
* Function getDecodedId
* decodes \a aControlId to original un-encoded value. This of
* course holds iff encodedId was called with a LAYER_NUM (this box
* is used for other things than layers, too)
*/
static LAYER_NUM getDecodedId( int aControlId );
void OnLeftDownLayers( wxMouseEvent& event );
/**
* Function OnRightDownLayer
* Called when user right-clicks a layer
*/
void OnRightDownLayer( wxMouseEvent& event, COLOR_SWATCH* aColorSwatch, const wxString& aLayerName );
/**
* Function OnSwatchChanged()
* is called when a user changes a swatch color
*/
void OnLayerSwatchChanged( wxCommandEvent& aEvent );
/**
* Function OnLayerCheckBox
* handles the "is layer visible" checkbox and propogates the
* event to the client's notification function.
*/
void OnLayerCheckBox( wxCommandEvent& event );
/**
* Function OnRightDownRender
* Called when user right-clicks a render option
*/
void OnRightDownRender( wxMouseEvent& aEvent, COLOR_SWATCH* aColorSwatch, const wxString& aRenderName );
/**
* Function OnRenderSwatchChanged
* Called when user has changed the swatch color of a render entry
*/
void OnRenderSwatchChanged( wxCommandEvent& aEvent );
void OnRenderCheckBox( wxCommandEvent& event );
void OnTabChange( wxNotebookEvent& event );
/**
* Function getLayerComp
* returns the component within the m_LayersFlexGridSizer at @a aRow and @a aCol
* or NULL if these parameters are out of range.
*
* @param aRow is the row index
* @param aColumn is the column
* @return wxWindow - the component installed within the sizer at given grid coordinate.
*/
wxWindow* getLayerComp( int aRow, int aColumn ) const;
wxWindow* getRenderComp( int aRow, int aColumn ) const;
/**
* Function findLayerRow
* returns the row index that \a aLayer resides in, or -1 if not found.
*/
int findLayerRow( LAYER_NUM aLayer ) const;
int findRenderRow( int aId ) const;
/**
* Function insertLayerRow
* appends or inserts a new row in the layer portion of the widget.
*/
void insertLayerRow( int aRow, const ROW& aSpec );
void insertRenderRow( int aRow, const ROW& aSpec );
void setLayerCheckbox( LAYER_NUM aLayer, bool isVisible );
void updateLayerRow( int aRow, const wxString& aName );
/**
* Function passOnFocus
* gives away the keyboard focus up to the main parent window.
*/
void passOnFocus();
// popup menu ids.
enum POPUP_ID
{
ID_CHANGE_LAYER_COLOR = wxID_HIGHEST,
ID_CHANGE_RENDER_COLOR,
ID_LAST_VALUE
};
public: public:
/** Constructor /**
* @param aParent is the parent window * @param aParent is the parent window.
* @param aFocusOwner is the window that should be sent the focus after * @param aFocusOwner is the window that should be sent the focus after.
* @param id is the wxWindow id ( default = wxID_ANY) * @param id is the wxWindow id ( default = wxID_ANY).
* @param pos is the window position * @param pos is the window position.
* @param size is the window size * @param size is the window size.
* @param style is the window style * @param style is the window style.
* every operation.
*/ */
LAYER_WIDGET( wxWindow* aParent, wxWindow* aFocusOwner, wxWindowID id = wxID_ANY, LAYER_WIDGET( wxWindow* aParent, wxWindow* aFocusOwner, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
@ -282,36 +145,33 @@ public:
} }
/** /**
* Function GetBestSize * Return the preferred minimum size, taking into consideration the dynamic content.
* returns the preferred minimum size, taking into consideration the *
* dynamic content. Nothing in wxWidgets was reliable enough so this * Nothing in wxWidgets was reliable enough so this overrides one of their functions.
* overrides one of their functions.
*/ */
wxSize GetBestSize() const; wxSize GetBestSize() const;
/** /**
* Function GetLayerRowCount * Return the number of rows in the layer tab.
* returns the number of rows in the layer tab.
*/ */
int GetLayerRowCount() const; int GetLayerRowCount() const;
/** /**
* Function GetRenderRowCount * Return the number of rows in the render tab.
* returns the number of rows in the render tab.
*/ */
int GetRenderRowCount() const; int GetRenderRowCount() const;
/** /**
* Function AppendLayerRow * Append a new row in the layer portion of the widget.
* appends a new row in the layer portion of the widget. The user must *
* ensure that ROW::id is unique for all existing rows on Windows. * The user must ensure that ROW::id is unique for all existing rows on Windows.
*/ */
void AppendLayerRow( const ROW& aRow ); void AppendLayerRow( const ROW& aRow );
/** /**
* Function AppendLayerRows * Append new rows in the layer portion of the widget.
* appends new rows in the layer portion of the widget. The user must *
* ensure that ROW::id is unique for all existing rows on Windows. * The user must ensure that ROW::id is unique for all existing rows on Windows.
*/ */
void AppendLayerRows( const ROW* aRowsArray, int aRowCount ) void AppendLayerRows( const ROW* aRowsArray, int aRowCount )
{ {
@ -322,22 +182,21 @@ public:
} }
/** /**
* Function ClearLayerRows * Empty out the layer rows.
* empties out the layer rows.
*/ */
void ClearLayerRows(); void ClearLayerRows();
/** /**
* Function AppendRenderRow * Append a new row in the render portion of the widget.
* appends a new row in the render portion of the widget. The user must *
* ensure that ROW::id is unique for all existing rows on Windows. * The user must ensure that ROW::id is unique for all existing rows on Windows.
*/ */
void AppendRenderRow( const ROW& aRow ); void AppendRenderRow( const ROW& aRow );
/** /**
* Function AppendRenderRows * Append new rows in the render portion of the widget.
* appends new rows in the render portion of the widget. The user must *
* ensure that ROW::id is unique for all existing rows on Windows. * The user must ensure that ROW::id is unique for all existing rows on Windows.
*/ */
void AppendRenderRows( const ROW* aRowsArray, int aRowCount ) void AppendRenderRows( const ROW* aRowsArray, int aRowCount )
{ {
@ -348,76 +207,68 @@ public:
} }
/** /**
* Function ClearRenderRows * Empty out the render rows.
* empties out the render rows.
*/ */
void ClearRenderRows(); void ClearRenderRows();
/** /**
* Function SelectLayerRow * Change the row selection in the layer list to the given row.
* changes the row selection in the layer list to the given row.
*/ */
void SelectLayerRow( int aRow ); void SelectLayerRow( int aRow );
/** /**
* Function SelectLayer * Change the row selection in the layer list to \a aLayer provided.
* changes the row selection in the layer list to \a aLayer provided.
*/ */
void SelectLayer( LAYER_NUM aLayer ); void SelectLayer( LAYER_NUM aLayer );
/** /**
* Function GetSelectedLayer * Return the selected layer or -1 if none.
* returns the selected layer or -1 if none.
*/ */
LAYER_NUM GetSelectedLayer(); LAYER_NUM GetSelectedLayer();
/** /**
* Function SetLayerVisible * Set \a aLayer visible or not. This does not invoke OnLayerVisible().
* sets \a aLayer visible or not. This does not invoke OnLayerVisible().
*/ */
void SetLayerVisible( LAYER_NUM aLayer, bool isVisible ); void SetLayerVisible( LAYER_NUM aLayer, bool isVisible );
/** /**
* Function IsLayerVisible * Return the visible state of the layer ROW associated with \a aLayer id.
* returns the visible state of the layer ROW associated with \a aLayer id.
*/ */
bool IsLayerVisible( LAYER_NUM aLayer ); bool IsLayerVisible( LAYER_NUM aLayer );
/** /**
* Function SetLayerColor * Change the color of \a aLayer
* changes the color of \a aLayer
*/ */
void SetLayerColor( LAYER_NUM aLayer, COLOR4D aColor ); void SetLayerColor( LAYER_NUM aLayer, COLOR4D aColor );
/** /**
* Function GetLayerColor * Return the color of the layer ROW associated with \a aLayer id.
* returns the color of the layer ROW associated with \a aLayer id.
*/ */
COLOR4D GetLayerColor( LAYER_NUM aLayer ) const; COLOR4D GetLayerColor( LAYER_NUM aLayer ) const;
/** /**
* Function SetRenderState * Set the state of the checkbox associated with \a aId within the Render tab group of the
* sets the state of the checkbox associated with \a aId within the * widget.
* Render tab group of the widget. Does not fire an event, i.e. does *
* not invoke OnRenderEnable(). * This does not fire an event, i.e. does not invoke OnRenderEnable().
* @param aId is the same unique id used when adding a ROW to the *
* Render tab. * @param aId is the same unique id used when adding a ROW to the Render tab.
* @param isSet = the new checkbox state * @param isSet is the new checkbox state.
*/ */
void SetRenderState( int aId, bool isSet ); void SetRenderState( int aId, bool isSet );
/** /**
* Function GetRenderState * Return the state of the checkbox associated with \a aId.
* returns the state of the checkbox associated with \a aId. *
* @return bool - true if checked, else false. * @return true if checked, else false.
*/ */
bool GetRenderState( int aId ); bool GetRenderState( int aId );
void UpdateLayouts(); void UpdateLayouts();
/** /**
* Function UpdateLayerIcons * Update all layer manager icons (layers only).
* Update all layer manager icons (layers only) *
* Useful when loading a file or clearing a layer because they change, * Useful when loading a file or clearing a layer because they change,
* and the indicator arrow icon needs to be updated * and the indicator arrow icon needs to be updated
*/ */
@ -442,65 +293,186 @@ public:
//-----<abstract functions>------------------------------------------- //-----<abstract functions>-------------------------------------------
/** /**
* Function OnLayerColorChange * Notify client code about a layer color change.
* is called to notify client code about a layer color change. Derived *
*es will handle this accordingly. * Derived objects will handle this accordingly.
* @param aLayer is the board layer to change *
* @param aColor is the new color * @param aLayer is the board layer to change.
* @param aColor is the new color.
*/ */
virtual void OnLayerColorChange( int aLayer, COLOR4D aColor ) = 0; virtual void OnLayerColorChange( int aLayer, COLOR4D aColor ) = 0;
/** /**
* Function OnLayerSelect * Notify client code whenever the user selects a different layer.
* is called to notify client code whenever the user selects a different *
* layer. Derived classes will handle this accordingly, and can deny * Derived classes will handle this accordingly, and can deny the change by returning false.
* the change by returning false. *
* @param aLayer is the board layer to select * @param aLayer is the board layer to select.
*/ */
virtual bool OnLayerSelect( int aLayer ) = 0; virtual bool OnLayerSelect( int aLayer ) = 0;
/** /**
* Function OnLayerVisible * Notify client code about a layer visibility change.
* is called to notify client code about a layer visibility change.
* *
* @param aLayer is the board layer to select * @param aLayer is the board layer to select.
* @param isVisible is the new visible state * @param isVisible is the new visible state.
* @param isFinal is true when this is the last of potentially several * @param isFinal is true when this is the last of potentially several such calls, and can
* such calls, and can be used to decide when to update the screen only * be used to decide when to update the screen only one time instead of
* one time instead of several times in the midst of a multiple layer change. * several times in the midst of a multiple layer change.
*/ */
virtual void OnLayerVisible( LAYER_NUM aLayer, bool isVisible, bool isFinal = true ) = 0; virtual void OnLayerVisible( LAYER_NUM aLayer, bool isVisible, bool isFinal = true ) = 0;
/** /**
* Function OnLayerRightClick * Notify client code about a layer being right-clicked.
* is called to notify client code about a layer being right-clicked.
* *
* @param aMenu is the right-click menu containing layer-scoped options. * @param aMenu is the right-click menu containing layer-scoped options.
* It can be used to add extra, wider scoped menu items.
*/ */
virtual void OnLayerRightClick( wxMenu& aMenu ) = 0; virtual void OnLayerRightClick( wxMenu& aMenu ) = 0;
/** /**
* Function OnRenderColorChange * Notify client code whenever the user changes a rendering color.
* is called to notify client code whenever the user changes a rendering *
* color. * @param aId is the same id that was established in a Rendering row via the AddRenderRow()
* @param aId is the same id that was established in a Rendering row * function.
* via the AddRenderRow() function. * @param aColor is the new color.
* @param aColor is the new color
*/ */
virtual void OnRenderColorChange( int aId, COLOR4D aColor ) = 0; virtual void OnRenderColorChange( int aId, COLOR4D aColor ) = 0;
/** /**
* Function OnRenderEnable * Notify client code whenever the user changes an rendering enable in one of the rendering
* is called to notify client code whenever the user changes an rendering * checkboxes.
* enable in one of the rendering checkboxes. *
* @param aId is the same id that was established in a Rendering row * @param aId is the same id that was established in a Rendering row via the AddRenderRow()
* via the AddRenderRow() function. * function.
* @param isEnabled is the state of the checkbox, true if checked. * @param isEnabled is the state of the checkbox, true if checked.
*/ */
virtual void OnRenderEnable( int aId, bool isEnabled ) = 0; virtual void OnRenderEnable( int aId, bool isEnabled ) = 0;
//-----</abstract functions>------------------------------------------ protected:
/**
* @return true if bitmaps shown in Render layer list
* are alternate bitmaps, or false if they are "normal" bitmaps
* This is a virtual function because Pcbnew uses normal bitmaps
* but GerbView uses both bitmaps
* (alternate bitmaps to show layers in use, normal for others)
*/
virtual bool useAlternateBitmap(int aRow) { return false; }
/**
* Subclasses can override this to provide accurate representation
* of transparent color swatches.
*/
virtual COLOR4D getBackgroundLayerColor() { return COLOR4D::BLACK; }
/**
* Allow saving a layer index within a control as its wxControl id.
*
* To do so in a way that all child wxControl ids within a wxWindow are unique, since this
* is required by Windows.
*
* @see getDecodedId()
*/
static int encodeId( int aColumn, int aId );
/**
* Decode \a aControlId to original un-encoded value.
*
* This holds if encodedId was called with a LAYER_NUM (this box is used for other things
* than layers, too).
*/
static LAYER_NUM getDecodedId( int aControlId );
void OnLeftDownLayers( wxMouseEvent& event );
/**
* Called when user right-clicks a layer.
*/
void OnRightDownLayer( wxMouseEvent& event, COLOR_SWATCH* aColorSwatch,
const wxString& aLayerName );
/**
* Called when a user changes a swatch color.
*/
void OnLayerSwatchChanged( wxCommandEvent& aEvent );
/**
* Handle the "is layer visible" checkbox and propagates the event to the client's
* notification function.
*/
void OnLayerCheckBox( wxCommandEvent& event );
/**
* Notify when user right-clicks a render option.
*/
void OnRightDownRender( wxMouseEvent& aEvent, COLOR_SWATCH* aColorSwatch,
const wxString& aRenderName );
/**
* Called when user has changed the swatch color of a render entry.
*/
void OnRenderSwatchChanged( wxCommandEvent& aEvent );
void OnRenderCheckBox( wxCommandEvent& event );
void OnTabChange( wxNotebookEvent& event );
/**
* Return the component within the m_LayersFlexGridSizer at @a aRow and @a aCol
* or NULL if these parameters are out of range.
*
* @param aRow is the row index
* @param aColumn is the column
* @return the component installed within the sizer at given grid coordinate.
*/
wxWindow* getLayerComp( int aRow, int aColumn ) const;
wxWindow* getRenderComp( int aRow, int aColumn ) const;
/**
* Return the row index that \a aLayer resides in, or -1 if not found.
*/
int findLayerRow( LAYER_NUM aLayer ) const;
int findRenderRow( int aId ) const;
/**
* Append or insert a new row in the layer portion of the widget.
*/
void insertLayerRow( int aRow, const ROW& aSpec );
void insertRenderRow( int aRow, const ROW& aSpec );
void setLayerCheckbox( LAYER_NUM aLayer, bool isVisible );
void updateLayerRow( int aRow, const wxString& aName );
/**
* Give away the keyboard focus up to the main parent window.
*/
void passOnFocus();
// popup menu ids.
enum POPUP_ID
{
ID_CHANGE_LAYER_COLOR = wxID_HIGHEST,
ID_CHANGE_RENDER_COLOR,
ID_LAST_VALUE
};
wxAuiNotebook* m_notebook;
wxPanel* m_LayerPanel;
wxScrolledWindow* m_LayerScrolledWindow;
wxFlexGridSizer* m_LayersFlexGridSizer;
wxPanel* m_RenderingPanel;
wxScrolledWindow* m_RenderScrolledWindow;
wxFlexGridSizer* m_RenderFlexGridSizer;
wxWindow* m_FocusOwner;
int m_CurrentRow; ///< selected row of layer list
int m_PointSize;
ROW_ICON_PROVIDER* m_IconProvider;
wxString m_smallestLayerString;
}; };
#endif // LAYERWIDGET_H_ #endif // LAYERWIDGET_H_