Eeschema: fix Bug #1180902 (Libedit creates empty svg images)
This commit is contained in:
parent
0f885e7f31
commit
172bbc8f9c
|
@ -383,21 +383,59 @@ void LIB_COMPONENT::Plot( PLOTTER* aPlotter, int aUnit, int aConvert,
|
||||||
{
|
{
|
||||||
wxASSERT( aPlotter != NULL );
|
wxASSERT( aPlotter != NULL );
|
||||||
|
|
||||||
|
aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) );
|
||||||
|
bool fill = aPlotter->GetColorMode();
|
||||||
|
|
||||||
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
||||||
{
|
{
|
||||||
|
// Lib Fields not are plotted here, because this plot function
|
||||||
|
// is used to plot schematic items, which have they own fields
|
||||||
|
if( item.Type() == LIB_FIELD_T )
|
||||||
|
continue;
|
||||||
|
|
||||||
if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
|
if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
|
if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) );
|
|
||||||
bool fill = aPlotter->GetColorMode();
|
|
||||||
|
|
||||||
item.Plot( aPlotter, aOffset, fill, aTransform );
|
item.Plot( aPlotter, aOffset, fill, aTransform );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LIB_COMPONENT::PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert,
|
||||||
|
const wxPoint& aOffset, const TRANSFORM& aTransform )
|
||||||
|
{
|
||||||
|
wxASSERT( aPlotter != NULL );
|
||||||
|
|
||||||
|
aPlotter->SetColor( GetLayerColor( LAYER_FIELDS ) );
|
||||||
|
bool fill = aPlotter->GetColorMode();
|
||||||
|
|
||||||
|
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
||||||
|
{
|
||||||
|
if( item.Type() != LIB_FIELD_T )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// The reference is a special case: we shoud change the basic text
|
||||||
|
// to add '?' and the part id
|
||||||
|
LIB_FIELD& field = (LIB_FIELD&) item;
|
||||||
|
wxString tmp = field.GetText();
|
||||||
|
if( field.GetId() == REFERENCE )
|
||||||
|
{
|
||||||
|
wxString text = field.GetFullText( aUnit );
|
||||||
|
field.SetText( text );
|
||||||
|
}
|
||||||
|
item.Plot( aPlotter, aOffset, fill, aTransform );
|
||||||
|
field.SetText( tmp );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void LIB_COMPONENT::RemoveDrawItem( LIB_ITEM* aItem, EDA_DRAW_PANEL* aPanel, wxDC* aDc )
|
void LIB_COMPONENT::RemoveDrawItem( LIB_ITEM* aItem, EDA_DRAW_PANEL* aPanel, wxDC* aDc )
|
||||||
{
|
{
|
||||||
|
|
|
@ -404,7 +404,9 @@ public:
|
||||||
bool aOnlySelected = false );
|
bool aOnlySelected = false );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plot component to plotter.
|
* Plot lib component to plotter.
|
||||||
|
* Lib Fields not are plotted here, because this plot function
|
||||||
|
* is used to plot schematic items, which have they own fields
|
||||||
*
|
*
|
||||||
* @param aPlotter - Plotter object to plot to.
|
* @param aPlotter - Plotter object to plot to.
|
||||||
* @param aUnit - Component part to plot.
|
* @param aUnit - Component part to plot.
|
||||||
|
@ -413,7 +415,20 @@ public:
|
||||||
* @param aTransform - Component plot transform matrix.
|
* @param aTransform - Component plot transform matrix.
|
||||||
*/
|
*/
|
||||||
void Plot( PLOTTER* aPlotter, int aUnit, int aConvert, const wxPoint& aOffset,
|
void Plot( PLOTTER* aPlotter, int aUnit, int aConvert, const wxPoint& aOffset,
|
||||||
const TRANSFORM& aTransform );
|
const TRANSFORM& aTransform );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plot Lib Fields only of the component to plotter.
|
||||||
|
* is used to plot the full lib component, outside the schematic
|
||||||
|
*
|
||||||
|
* @param aPlotter - Plotter object to plot to.
|
||||||
|
* @param aUnit - Component part to plot.
|
||||||
|
* @param aConvert - Component alternate body style to plot.
|
||||||
|
* @param aOffset - Distance to shift the plot coordinates.
|
||||||
|
* @param aTransform - Component plot transform matrix.
|
||||||
|
*/
|
||||||
|
void PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert,
|
||||||
|
const wxPoint& aOffset, const TRANSFORM& aTransform );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new draw \a aItem to the draw object list.
|
* Add a new draw \a aItem to the draw object list.
|
||||||
|
|
|
@ -473,9 +473,33 @@ void LIB_FIELD::Rotate( const wxPoint& center, bool aRotateCCW )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LIB_FIELD::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill,
|
void LIB_FIELD::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
|
||||||
const TRANSFORM& aTransform )
|
const TRANSFORM& aTransform )
|
||||||
{
|
{
|
||||||
|
if( IsVoid() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Calculate the text orientation, according to the component
|
||||||
|
* orientation/mirror */
|
||||||
|
int orient = m_Orient;
|
||||||
|
|
||||||
|
if( aTransform.y1 ) // Rotate component 90 deg.
|
||||||
|
{
|
||||||
|
if( orient == TEXT_ORIENT_HORIZ )
|
||||||
|
orient = TEXT_ORIENT_VERT;
|
||||||
|
else
|
||||||
|
orient = TEXT_ORIENT_HORIZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
EDA_RECT BoundaryBox = GetBoundingBox();
|
||||||
|
EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_CENTER;
|
||||||
|
EDA_TEXT_VJUSTIFY_T vjustify = GR_TEXT_VJUSTIFY_CENTER;
|
||||||
|
wxPoint textpos = aTransform.TransformCoordinate( BoundaryBox.Centre() )
|
||||||
|
+ aOffset;
|
||||||
|
|
||||||
|
aPlotter->Text( textpos, GetDefaultColor(), m_Text, orient, m_Size,
|
||||||
|
hjustify, vjustify,
|
||||||
|
GetPenSize(), m_Italic, m_Bold );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,8 @@
|
||||||
#include <class_library.h>
|
#include <class_library.h>
|
||||||
#include <dialogs/dialog_plot_schematic.h>
|
#include <dialogs/dialog_plot_schematic.h>
|
||||||
|
|
||||||
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
|
|
||||||
void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event )
|
void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
|
@ -103,7 +105,7 @@ void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event )
|
||||||
pageTemp.SetHeightMils( int( componentSize.y * 1.2 ) );
|
pageTemp.SetHeightMils( int( componentSize.y * 1.2 ) );
|
||||||
|
|
||||||
GetScreen()->SetPageSettings( pageTemp );
|
GetScreen()->SetPageSettings( pageTemp );
|
||||||
SVG_Print_Component( FullFileName );
|
SVG_PlotComponent( FullFileName );
|
||||||
GetScreen()->SetPageSettings( pageSave );
|
GetScreen()->SetPageSettings( pageSave );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -136,12 +138,49 @@ void LIB_EDIT_FRAME::CreatePNGorJPEGFile( const wxString& aFileName, bool aFmt_j
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LIB_EDIT_FRAME::SVG_Print_Component( const wxString& FullFileName )
|
void LIB_EDIT_FRAME::SVG_PlotComponent( const wxString& aFullFileName )
|
||||||
{
|
{
|
||||||
bool plotBW = false;
|
const bool plotBW = false;
|
||||||
bool plotFrameRef = false;
|
const PAGE_INFO& pageInfo = GetScreen()->GetPageSettings();
|
||||||
DIALOG_PLOT_SCHEMATIC::plotOneSheetSVG( this, FullFileName, GetScreen(),
|
|
||||||
plotBW, plotFrameRef );
|
SVG_PLOTTER* plotter = new SVG_PLOTTER();
|
||||||
|
plotter->SetPageSettings( pageInfo );
|
||||||
|
plotter->SetDefaultLineWidth( GetDefaultLineThickness() );
|
||||||
|
plotter->SetColorMode( plotBW );
|
||||||
|
|
||||||
|
wxPoint plot_offset;
|
||||||
|
const double scale = 1.0;
|
||||||
|
plotter->SetViewport( plot_offset, IU_PER_DECIMILS, scale, false );
|
||||||
|
|
||||||
|
// Init :
|
||||||
|
plotter->SetCreator( wxT( "Eeschema-SVG" ) );
|
||||||
|
|
||||||
|
if( ! plotter->OpenFile( aFullFileName ) )
|
||||||
|
{
|
||||||
|
delete plotter;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOCALE_IO toggle;
|
||||||
|
|
||||||
|
plotter->StartPlot();
|
||||||
|
|
||||||
|
if( m_component )
|
||||||
|
{
|
||||||
|
TRANSFORM temp; // Uses default transform
|
||||||
|
wxPoint plotPos;
|
||||||
|
plotPos.x = pageInfo.GetWidthIU() /2;
|
||||||
|
plotPos.y = pageInfo.GetHeightIU()/2;
|
||||||
|
|
||||||
|
m_component->Plot( plotter, GetUnit(), GetConvert(), plotPos, temp );
|
||||||
|
|
||||||
|
// Plot lib fields, not plotted by m_component->Plot():
|
||||||
|
m_component->PlotLibFields( plotter, GetUnit(), GetConvert(),
|
||||||
|
plotPos, temp );
|
||||||
|
}
|
||||||
|
|
||||||
|
plotter->EndPlot();
|
||||||
|
delete plotter;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LIB_EDIT_FRAME::PrintPage( wxDC* aDC, LAYER_MSK aPrintMask, bool aPrintMirrorMode, void* aData)
|
void LIB_EDIT_FRAME::PrintPage( wxDC* aDC, LAYER_MSK aPrintMask, bool aPrintMirrorMode, void* aData)
|
||||||
|
|
|
@ -641,11 +641,11 @@ public:
|
||||||
bool aPrintMirrorMode, void* aData = NULL );
|
bool aPrintMirrorMode, void* aData = NULL );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function SVG_Print_Component
|
* Function SVG_PlotComponent
|
||||||
* Creates the SVG print file for the current edited component.
|
* Creates the SVG print file for the current edited component.
|
||||||
* @param aFullFileName = the full filename of the file
|
* @param aFullFileName = the full filename
|
||||||
*/
|
*/
|
||||||
void SVG_Print_Component( const wxString& aFullFileName );
|
void SVG_PlotComponent( const wxString& aFullFileName );
|
||||||
|
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
/*
|
/*
|
||||||
* 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) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||||
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||||
|
* Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
|
||||||
|
* Copyright (C) 1992-2013 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
|
||||||
|
@ -549,9 +551,10 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// note: SCH_SCREEN::Draw is useful only for schematic.
|
/* note: SCH_SCREEN::Draw is useful only for schematic.
|
||||||
// library editor and library viewer do not use a draw list, and therefore
|
* library editor and library viewer do not use a draw list, and therefore
|
||||||
// SCH_SCREEN::Draw draws nothing
|
* SCH_SCREEN::Draw draws nothing
|
||||||
|
*/
|
||||||
void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
|
void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
|
||||||
{
|
{
|
||||||
for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
|
for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
|
||||||
|
@ -568,6 +571,10 @@ void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* note: SCH_SCREEN::Plot is useful only for schematic.
|
||||||
|
* library editor and library viewer do not use a draw list, and therefore
|
||||||
|
* SCH_SCREEN::Plot plots nothing
|
||||||
|
*/
|
||||||
void SCH_SCREEN::Plot( PLOTTER* aPlotter )
|
void SCH_SCREEN::Plot( PLOTTER* aPlotter )
|
||||||
{
|
{
|
||||||
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
||||||
|
|
|
@ -184,6 +184,9 @@ public:
|
||||||
/**
|
/**
|
||||||
* Function Draw
|
* Function Draw
|
||||||
* draws all the items in the screen to \a aCanvas.
|
* draws all the items in the screen to \a aCanvas.
|
||||||
|
* note: this function is useful only for schematic.
|
||||||
|
* library editor and library viewer do not use a draw list, and therefore
|
||||||
|
* draws nothing
|
||||||
* @param aCanvas The canvas item to draw on.
|
* @param aCanvas The canvas item to draw on.
|
||||||
* @param aDC The device context to draw on.
|
* @param aDC The device context to draw on.
|
||||||
* @param aDrawMode The drawing mode.
|
* @param aDrawMode The drawing mode.
|
||||||
|
@ -195,6 +198,9 @@ public:
|
||||||
/**
|
/**
|
||||||
* Function Plot
|
* Function Plot
|
||||||
* plots all the schematic objects to \a aPlotter.
|
* plots all the schematic objects to \a aPlotter.
|
||||||
|
* note: this function is useful only for schematic.
|
||||||
|
* library editor and library viewer do not use a draw list, and therefore
|
||||||
|
* plots nothing
|
||||||
*
|
*
|
||||||
* @param aPlotter The plotter object to plot to.
|
* @param aPlotter The plotter object to plot to.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue