|
|
@ -14,11 +14,11 @@ |
|
|
|
#include "gestfich.h"
|
|
|
|
|
|
|
|
#include "dialog_SVG_print_base.h"
|
|
|
|
|
|
|
|
#include "dcsvg.h"
|
|
|
|
|
|
|
|
#include "program.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "libeditframe.h"
|
|
|
|
|
|
|
|
// Keys for configuration
|
|
|
|
#define PLOTSVGMODECOLOR_KEY wxT( "PlotSVGModeColor" )
|
|
|
@ -35,7 +35,6 @@ class DIALOG_SVG_PRINT : public DIALOG_SVG_PRINT_base |
|
|
|
{ |
|
|
|
private: |
|
|
|
WinEDA_DrawFrame * m_Parent; |
|
|
|
int m_ImageXSize_mm; |
|
|
|
wxConfig* m_Config; |
|
|
|
|
|
|
|
public: |
|
|
@ -51,8 +50,11 @@ private: |
|
|
|
void OnSetColorModeSelected( wxCommandEvent& event ); |
|
|
|
void SetPenWidth(); |
|
|
|
void PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref ); |
|
|
|
bool DrawPage( const wxString& FullFileName, BASE_SCREEN* screen, |
|
|
|
bool aPrint_Sheet_Ref ); |
|
|
|
public: |
|
|
|
static bool DrawSVGPage( WinEDA_DrawFrame * frame, |
|
|
|
const wxString& FullFileName, BASE_SCREEN* screen, |
|
|
|
bool aPrintBlackAndWhite = false, |
|
|
|
bool aPrint_Sheet_Ref = false); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -66,6 +68,15 @@ void WinEDA_DrawFrame::SVG_Print( wxCommandEvent& event ) |
|
|
|
frame.ShowModal(); |
|
|
|
} |
|
|
|
|
|
|
|
/* Creates the SVG print file for the current edited component.
|
|
|
|
*/ |
|
|
|
void WinEDA_LibeditFrame::SVG_Print_Component( const wxString& FullFileName ) |
|
|
|
{ |
|
|
|
DIALOG_SVG_PRINT::DrawSVGPage( this, FullFileName, GetScreen() ); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* DIALOG_SVG_PRINT functions |
|
|
@ -82,7 +93,6 @@ void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event ) |
|
|
|
{ |
|
|
|
SetFocus(); // Make ESC key working
|
|
|
|
|
|
|
|
m_ImageXSize_mm = 270; |
|
|
|
if( m_Config ) |
|
|
|
{ |
|
|
|
m_Config->Read( PLOTSVGMODECOLOR_KEY, &s_PlotBlackAndWhite ); |
|
|
@ -130,6 +140,9 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref ) |
|
|
|
|
|
|
|
SetPenWidth(); |
|
|
|
|
|
|
|
g_DrawDefaultLineThickness = |
|
|
|
ReturnValueFromTextCtrl( *m_DialogPenWidth, m_Parent->m_InternalUnits ); |
|
|
|
|
|
|
|
BASE_SCREEN* screen = m_Parent->GetBaseScreen(); |
|
|
|
BASE_SCREEN* oldscreen = screen; |
|
|
|
|
|
|
@ -162,7 +175,8 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref ) |
|
|
|
|
|
|
|
fn = schframe->GetUniqueFilenameForCurrentSheet( ) + wxT( ".svg" ); |
|
|
|
|
|
|
|
bool success = DrawPage( fn.GetFullPath(), schscreen, |
|
|
|
bool success = DrawSVGPage( m_Parent, fn.GetFullPath(), schscreen, |
|
|
|
m_ModeColorOption->GetSelection() == 0 ? false : true, |
|
|
|
aPrint_Sheet_Ref ); |
|
|
|
msg = _( "Create file " ) + fn.GetFullPath(); |
|
|
|
if( !success ) |
|
|
@ -182,8 +196,11 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref ) |
|
|
|
fn = screen->m_FileName; |
|
|
|
|
|
|
|
fn.SetExt( wxT( "svg" ) ); |
|
|
|
fn.MakeAbsolute( ); |
|
|
|
|
|
|
|
bool success = DrawPage( fn.GetFullPath(), screen, aPrint_Sheet_Ref ); |
|
|
|
bool success = DrawSVGPage( m_Parent, fn.GetFullPath(), screen, |
|
|
|
m_ModeColorOption->GetSelection() == 0 ? false : true, |
|
|
|
aPrint_Sheet_Ref ); |
|
|
|
msg = _( "Create file " ) + fn.GetFullPath(); |
|
|
|
|
|
|
|
if( !success ) |
|
|
@ -196,16 +213,16 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref ) |
|
|
|
ActiveScreen = oldscreen; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, |
|
|
|
bool DIALOG_SVG_PRINT::DrawSVGPage( WinEDA_DrawFrame * frame, |
|
|
|
const wxString& FullFileName, |
|
|
|
BASE_SCREEN* screen, |
|
|
|
bool aPrintBlackAndWhite, |
|
|
|
bool aPrint_Sheet_Ref) |
|
|
|
{ |
|
|
|
int tmpzoom; |
|
|
|
wxPoint tmp_startvisu; |
|
|
|
wxSize SheetSize; // Sheet size in internal units
|
|
|
|
wxPoint old_org; |
|
|
|
double dpi; |
|
|
|
bool success = true; |
|
|
|
|
|
|
|
tmp_startvisu = screen->m_StartVisu; |
|
|
@ -216,17 +233,13 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, |
|
|
|
SheetSize = screen->ReturnPageSize( ); |
|
|
|
|
|
|
|
screen->SetScalingFactor( 1.0 ); |
|
|
|
dpi = (double) SheetSize.x * 25.4 / m_ImageXSize_mm; |
|
|
|
WinEDA_DrawPanel* panel = frame->DrawPanel; |
|
|
|
|
|
|
|
WinEDA_DrawPanel* panel = m_Parent->DrawPanel; |
|
|
|
|
|
|
|
wxSVGFileDC dc( FullFileName, SheetSize.x, SheetSize.y, dpi ); |
|
|
|
wxSVGFileDC dc( FullFileName, SheetSize.x, SheetSize.y ); |
|
|
|
|
|
|
|
EDA_Rect tmp = panel->m_ClipBox; |
|
|
|
GRResetPenAndBrush( &dc ); |
|
|
|
g_DrawDefaultLineThickness = |
|
|
|
ReturnValueFromTextCtrl( *m_DialogPenWidth, m_Parent->m_InternalUnits ); |
|
|
|
GRForceBlackPen( m_ModeColorOption->GetSelection() == 0 ? false : true ); |
|
|
|
GRForceBlackPen( aPrintBlackAndWhite ); |
|
|
|
|
|
|
|
|
|
|
|
panel->m_ClipBox.SetX( -0x3FFFFF0 ); |
|
|
@ -237,13 +250,13 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, |
|
|
|
screen->m_IsPrinting = true; |
|
|
|
SetLocaleTo_C_standard( ); // Switch the locale to standard C (needed
|
|
|
|
// to print floating point numbers like 1.3)
|
|
|
|
m_Parent->PrintPage( &dc, aPrint_Sheet_Ref, 1, false ); |
|
|
|
frame->PrintPage( &dc, aPrint_Sheet_Ref, 1, false ); |
|
|
|
SetLocaleTo_Default( ); // revert to the current locale
|
|
|
|
screen->m_IsPrinting = false; |
|
|
|
panel->m_ClipBox = tmp; |
|
|
|
|
|
|
|
|
|
|
|
GRForceBlackPen( FALSE ); |
|
|
|
GRForceBlackPen( false ); |
|
|
|
|
|
|
|
screen->m_StartVisu = tmp_startvisu; |
|
|
|
screen->m_DrawOrg = old_org; |
|
|
|