2011-09-30 14:15:37 -04:00
|
|
|
/**
|
|
|
|
* @file common_plot_functions.cpp
|
2013-05-21 09:18:25 +02:00
|
|
|
* @brief Kicad: Common plotting functions
|
2011-09-30 14:15:37 -04:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-22 22:33:36 -06:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <base_struct.h>
|
|
|
|
#include <plot_common.h>
|
|
|
|
#include <worksheet.h>
|
|
|
|
#include <class_base_screen.h>
|
|
|
|
#include <drawtxt.h>
|
|
|
|
#include <class_title_block.h>
|
2013-05-21 09:18:25 +02:00
|
|
|
#include "worksheet_shape_builder.h"
|
2008-03-22 05:55:06 +00:00
|
|
|
|
2012-08-29 18:59:50 +02:00
|
|
|
|
|
|
|
wxString GetDefaultPlotExtension( PlotFormat aFormat )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-08-29 18:59:50 +02:00
|
|
|
switch( aFormat )
|
|
|
|
{
|
|
|
|
case PLOT_FORMAT_DXF:
|
|
|
|
return DXF_PLOTTER::GetDefaultFileExtension();
|
|
|
|
|
|
|
|
case PLOT_FORMAT_POST:
|
|
|
|
return PS_PLOTTER::GetDefaultFileExtension();
|
|
|
|
|
|
|
|
case PLOT_FORMAT_PDF:
|
|
|
|
return PDF_PLOTTER::GetDefaultFileExtension();
|
|
|
|
|
|
|
|
case PLOT_FORMAT_HPGL:
|
|
|
|
return HPGL_PLOTTER::GetDefaultFileExtension();
|
2011-12-30 23:44:00 -06:00
|
|
|
|
2012-08-29 18:59:50 +02:00
|
|
|
case PLOT_FORMAT_GERBER:
|
|
|
|
return GERBER_PLOTTER::GetDefaultFileExtension();
|
2011-12-22 15:57:50 -06:00
|
|
|
|
2012-09-15 14:13:03 +02:00
|
|
|
case PLOT_FORMAT_SVG:
|
|
|
|
return SVG_PLOTTER::GetDefaultFileExtension();
|
|
|
|
|
2012-08-29 18:59:50 +02:00
|
|
|
default:
|
|
|
|
wxASSERT( false );
|
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
}
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2013-05-21 09:18:25 +02:00
|
|
|
|
|
|
|
|
2012-08-29 18:59:50 +02:00
|
|
|
void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
|
|
|
|
const PAGE_INFO& aPageInfo,
|
|
|
|
int aSheetNumber, int aNumberOfSheets,
|
2013-05-21 09:18:25 +02:00
|
|
|
const wxString &aSheetDesc, const wxString &aFilename )
|
2012-08-29 18:59:50 +02:00
|
|
|
{
|
2013-05-21 09:18:25 +02:00
|
|
|
/* Note: Page sizes values are given in mils
|
|
|
|
*/
|
|
|
|
double iusPerMil = plotter->GetIUsPerDecimil() * 10.0;
|
2012-08-29 18:59:50 +02:00
|
|
|
wxSize pageSize = aPageInfo.GetSizeMils(); // in mils
|
2008-03-22 05:55:06 +00:00
|
|
|
|
2013-05-21 09:18:25 +02:00
|
|
|
wxPoint LTmargin;
|
|
|
|
LTmargin.x = aPageInfo.GetLeftMarginMils() * iusPerMil;
|
|
|
|
LTmargin.y = aPageInfo.GetTopMarginMils() * iusPerMil;
|
2013-03-28 00:38:20 +04:00
|
|
|
|
2013-05-21 09:18:25 +02:00
|
|
|
wxPoint RBmargin;
|
|
|
|
RBmargin.x = aPageInfo.GetRightMarginMils() * iusPerMil;
|
|
|
|
RBmargin.y = aPageInfo.GetBottomMarginMils() * iusPerMil;
|
2013-03-28 00:38:20 +04:00
|
|
|
|
2013-05-21 09:18:25 +02:00
|
|
|
EDA_COLOR_T plotColor = plotter->GetColorMode() ? RED : BLACK;
|
|
|
|
plotter->SetColor( plotColor );
|
2013-03-28 00:38:20 +04:00
|
|
|
plotter->SetCurrentLineWidth( PLOTTER::DEFAULT_LINE_WIDTH );
|
2013-05-21 09:18:25 +02:00
|
|
|
WS_DRAW_ITEM_LIST drawList;
|
|
|
|
|
|
|
|
drawList.BuildWorkSheetGraphicList( pageSize, LTmargin, RBmargin,
|
|
|
|
aPageInfo.GetType(), aFilename,
|
|
|
|
aSheetDesc,
|
|
|
|
aTitleBlock, aNumberOfSheets, aSheetNumber,
|
|
|
|
PLOTTER::DEFAULT_LINE_WIDTH, iusPerMil,
|
|
|
|
plotColor, plotColor );
|
|
|
|
|
|
|
|
// Draw item list
|
|
|
|
for( WS_DRAW_ITEM_BASE* item = drawList.GetFirst(); item;
|
|
|
|
item = drawList.GetNext() )
|
2013-03-28 00:38:20 +04:00
|
|
|
{
|
2013-05-21 09:18:25 +02:00
|
|
|
switch( item->GetType() )
|
2013-03-28 00:38:20 +04:00
|
|
|
{
|
2013-05-21 09:18:25 +02:00
|
|
|
case WS_DRAW_ITEM_BASE::wsg_line:
|
2013-03-28 00:38:20 +04:00
|
|
|
{
|
2013-05-21 09:18:25 +02:00
|
|
|
WS_DRAW_ITEM_LINE* line = (WS_DRAW_ITEM_LINE*) item;
|
|
|
|
plotter->MoveTo( line->GetStart() );
|
|
|
|
plotter->FinishTo( line->GetEnd() );
|
2013-03-28 00:38:20 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2013-05-21 09:18:25 +02:00
|
|
|
case WS_DRAW_ITEM_BASE::wsg_rect:
|
|
|
|
{
|
|
|
|
WS_DRAW_ITEM_RECT* rect = (WS_DRAW_ITEM_RECT*) item;
|
|
|
|
plotter->Rect( rect->GetStart(), rect->GetEnd(), NO_FILL ); }
|
2013-03-28 00:38:20 +04:00
|
|
|
break;
|
|
|
|
|
2013-05-21 09:18:25 +02:00
|
|
|
case WS_DRAW_ITEM_BASE::wsg_text:
|
2013-03-28 00:38:20 +04:00
|
|
|
{
|
2013-05-21 09:18:25 +02:00
|
|
|
WS_DRAW_ITEM_TEXT* text = (WS_DRAW_ITEM_TEXT*) item;
|
|
|
|
plotter->Text( text->GetTextPosition(), text->GetColor(),
|
|
|
|
text->GetText(), text->GetOrientation(),
|
|
|
|
text->GetSize(),
|
|
|
|
text->GetHorizJustify(), text->GetVertJustify(),
|
|
|
|
text->GetPenWidth(),
|
|
|
|
text->IsItalic(), text->IsBold() );
|
2013-03-28 00:38:20 +04:00
|
|
|
}
|
2013-05-21 09:18:25 +02:00
|
|
|
break;
|
2013-03-28 00:38:20 +04:00
|
|
|
|
2013-05-21 09:18:25 +02:00
|
|
|
case WS_DRAW_ITEM_BASE::wsg_poly:
|
2013-03-28 00:38:20 +04:00
|
|
|
{
|
2013-05-21 09:18:25 +02:00
|
|
|
WS_DRAW_ITEM_POLYGON* poly = (WS_DRAW_ITEM_POLYGON*) item;
|
|
|
|
plotter->PlotPoly( poly->m_Corners, NO_FILL );
|
2013-03-28 00:38:20 +04:00
|
|
|
}
|
2008-03-22 05:55:06 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|