DXF importer: fix incorrect line thickness of imported texts.

This commit is contained in:
jean-pierre charras 2018-12-04 20:01:47 +01:00
parent bb18c9201b
commit 3623980611
6 changed files with 20 additions and 16 deletions

View File

@ -361,7 +361,8 @@ void DXF_IMPORT_PLUGIN::addText( const DL_TextData& aData )
double textHeight = mapDim( aData.height );
// The 0.9 factor gives a better height/width ratio with our font
double charWidth = textHeight * 0.9;
double textWidth = charWidth * text.length(); // Rough approximation
double textWidth = charWidth * text.length(); // Rough approximation
double textThickness = textHeight/8.0; // Use a reasonable line thickness for this text
VECTOR2D bottomLeft(0.0, 0.0);
VECTOR2D bottomRight(0.0, 0.0);
@ -447,7 +448,7 @@ void DXF_IMPORT_PLUGIN::addText( const DL_TextData& aData )
double cosine = cos(angleInRads);
double sine = sin(angleInRads);
m_internalImporter.AddText( refPoint, text, textHeight, charWidth, angle,
m_internalImporter.AddText( refPoint, text, textHeight, charWidth, textThickness, angle,
hJustify, vJustify );
// Calculate the boundary box and update the image limits:
@ -484,7 +485,8 @@ void DXF_IMPORT_PLUGIN::addMText( const DL_MTextData& aData )
double textHeight = mapDim( aData.height );
// The 0.9 factor gives a better height/width ratio with our font
double charWidth = textHeight * 0.9;
double textWidth = charWidth * text.length(); // Rough approximation
double textWidth = charWidth * text.length(); // Rough approximation
double textThickness = textHeight/8.0; // Use a reasonable line thickness for this text
VECTOR2D bottomLeft(0.0, 0.0);
VECTOR2D bottomRight(0.0, 0.0);
@ -599,7 +601,8 @@ void DXF_IMPORT_PLUGIN::addMText( const DL_MTextData& aData )
double cosine = cos(angleInRads);
double sine = sin(angleInRads);
m_internalImporter.AddText( textpos, text, textHeight, charWidth, angle, hJustify, vJustify );
m_internalImporter.AddText( textpos, text, textHeight, charWidth,
textThickness, angle, hJustify, vJustify );
bottomLeft.x = bottomLeft.x * cosine - bottomLeft.y * sine;
bottomLeft.y = bottomLeft.x * sine + bottomLeft.y * cosine;

View File

@ -223,7 +223,7 @@ public:
* @param aWidth is the segment thickness in mm. Use -1 for default line thickness
*/
virtual void AddText( const VECTOR2D& aOrigin, const wxString& aText,
double aHeight, double aWidth, double aOrientation,
double aHeight, double aWidth, double aThickness, double aOrientation,
EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify ) = 0;
/**

View File

@ -58,11 +58,11 @@ void GRAPHICS_IMPORTER_BUFFER::AddPolygon( const std::vector< VECTOR2D >& aVerti
void GRAPHICS_IMPORTER_BUFFER::AddText( const VECTOR2D& aOrigin, const wxString& aText,
double aHeight, double aWidth, double aOrientation,
double aHeight, double aWidth, double aThickness, double aOrientation,
EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify )
{
m_shapes.push_back( make_shape< IMPORTED_TEXT >( aOrigin, aText, aHeight, aWidth, aOrientation,
aHJustify, aVJustify ) );
m_shapes.push_back( make_shape< IMPORTED_TEXT >( aOrigin, aText, aHeight, aWidth,
aThickness, aOrientation, aHJustify, aVJustify ) );
}

View File

@ -121,10 +121,10 @@ class IMPORTED_TEXT : public IMPORTED_SHAPE
{
public:
IMPORTED_TEXT( const VECTOR2D& aOrigin, const wxString& aText,
double aHeight, double aWidth, double aOrientation,
double aHeight, double aWidth, double aThickness, double aOrientation,
EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify )
: m_origin( aOrigin ), m_text( aText ),
m_height( aHeight ), m_width( aWidth ),
m_height( aHeight ), m_width( aWidth ), m_thickness( aThickness ),
m_orientation( aOrientation ),
m_hJustify( aHJustify ), m_vJustify( aVJustify )
{
@ -132,8 +132,8 @@ public:
void ImportTo( GRAPHICS_IMPORTER& aImporter ) const override
{
aImporter.AddText( m_origin, m_text, m_height, m_width, m_orientation,
m_hJustify, m_vJustify );
aImporter.AddText( m_origin, m_text, m_height, m_width,
m_thickness, m_orientation, m_hJustify, m_vJustify );
}
private:
@ -141,6 +141,7 @@ private:
const wxString m_text;
double m_height;
double m_width;
double m_thickness;
double m_orientation;
EDA_TEXT_HJUSTIFY_T m_hJustify;
EDA_TEXT_VJUSTIFY_T m_vJustify;
@ -183,7 +184,7 @@ public:
void AddPolygon( const std::vector< VECTOR2D >& aVertices, double aWidth ) override;
void AddText( const VECTOR2D& aOrigin, const wxString& aText,
double aHeight, double aWidth, double aOrientation,
double aHeight, double aWidth, double aThickness, double aOrientation,
EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify ) override;
void AddSpline( const VECTOR2D& aStart, const VECTOR2D& BezierControl1,

View File

@ -129,14 +129,14 @@ void GRAPHICS_IMPORTER_PCBNEW::AddPolygon( const std::vector< VECTOR2D >& aVerti
void GRAPHICS_IMPORTER_PCBNEW::AddText( const VECTOR2D& aOrigin, const wxString& aText,
double aHeight, double aWidth, double aOrientation,
double aHeight, double aWidth, double aThickness, double aOrientation,
EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify )
{
unique_ptr<BOARD_ITEM> boardItem;
EDA_TEXT* textItem;
tie( boardItem, textItem ) = createText();
boardItem->SetLayer( GetLayer() );
textItem->SetThickness( MapLineWidth( aWidth ) );
textItem->SetThickness( MapLineWidth( aThickness ) );
textItem->SetTextPos( MapCoordinate( aOrigin ) );
textItem->SetTextAngle( aOrientation );
textItem->SetTextWidth( aWidth * ImportScalingFactor() );

View File

@ -67,7 +67,7 @@ public:
void AddPolygon( const std::vector< VECTOR2D >& aVertices, double aWidth ) override;
void AddText( const VECTOR2D& aOrigin, const wxString& aText,
double aHeight, double aWidth, double aOrientation,
double aHeight, double aWidth, double aThickness, double aOrientation,
EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify ) override;
void AddSpline( const VECTOR2D& aStart, const VECTOR2D& aBezierControl1,