svg: Use grouping

Uses existing grouping in SVG output.  Sets schematic components as a
grouped element in SVG as well as pcbnew elements per layer.

Fixes: lp:1011754
* https://bugs.launchpad.net/kicad/+bug/1011754
This commit is contained in:
Seth Hillbrand 2019-01-26 16:58:33 -08:00
parent 37741048ce
commit b14bc1bead
3 changed files with 37 additions and 0 deletions

View File

@ -288,6 +288,24 @@ void SVG_PLOTTER::SetCurrentLineWidth( int width, void* aData )
} }
void SVG_PLOTTER::StartBlock( void* aData )
{
std::string* idstr = reinterpret_cast<std::string*>( aData );
fputs( "<svg:g ", outputFile );
if( idstr )
fprintf( outputFile, "id=\"%s\"", idstr->c_str() );
fprintf( outputFile, ">\n" );
}
void SVG_PLOTTER::EndBlock( void* aData )
{
fprintf( outputFile, "</g>\n" );
}
/* initialize m_red, m_green, m_blue ( 0 ... 255) /* initialize m_red, m_green, m_blue ( 0 ... 255)
* from reduced values r, g ,b ( 0.0 to 1.0 ) * from reduced values r, g ,b ( 0.0 to 1.0 )
*/ */

View File

@ -1968,6 +1968,7 @@ void SCH_COMPONENT::Plot( PLOTTER* aPlotter )
if( PART_SPTR part = m_part.lock() ) if( PART_SPTR part = m_part.lock() )
{ {
temp = GetTransform(); temp = GetTransform();
aPlotter->StartBlock( nullptr );
part->Plot( aPlotter, GetUnit(), GetConvert(), m_Pos, temp ); part->Plot( aPlotter, GetUnit(), GetConvert(), m_Pos, temp );
@ -1975,6 +1976,8 @@ void SCH_COMPONENT::Plot( PLOTTER* aPlotter )
{ {
m_Fields[i].Plot( aPlotter ); m_Fields[i].Plot( aPlotter );
} }
aPlotter->EndBlock( nullptr );
} }
} }

View File

@ -936,6 +936,22 @@ public:
double aScaleFactor ) override; double aScaleFactor ) override;
virtual void PenTo( const wxPoint& pos, char plume ) override; virtual void PenTo( const wxPoint& pos, char plume ) override;
/**
* calling this function allows one to define the beginning of a group
* of drawing items (used in SVG format to separate components)
* @param aData should be a string for the SVG ID tage
*/
virtual void StartBlock( void* aData ) override;
/**
* calling this function allows one to define the end of a group of drawing
* items the group is started by StartBlock()
* @param aData should be null
*/
virtual void EndBlock( void* aData ) override;
virtual void Text( const wxPoint& aPos, virtual void Text( const wxPoint& aPos,
const COLOR4D aColor, const COLOR4D aColor,
const wxString& aText, const wxString& aText,