Commit b27bbe9c authored by charras's avatar charras
Browse files

Eeschema+Pcbnew: code cleanup and refinements in plot SVG format

parent 19e5bc3b
Loading
Loading
Loading
Loading
+12 −14
Original line number Diff line number Diff line
@@ -15,9 +15,9 @@
#include "dcsvg.h"

#include "program.h"
#include "general.h"

// Keys for configuration
#define PLOTSVGPENWIDTH_KEY wxT( "PlotSVGPenWidth")
#define PLOTSVGMODECOLOR_KEY  wxT( "PlotSVGModeColor" )

extern BASE_SCREEN* ActiveScreen;
@@ -25,8 +25,6 @@ extern BASE_SCREEN* ActiveScreen;
#define WIDTH_MIN_VALUE 1

// Variables locales
static int  s_SVGPenMinWidth;       /* Minimum pen width (in internal units) for printing */

static bool s_Print_Frame_Ref     = true;
static int  s_PlotBlackAndWhite = 0;

@@ -88,13 +86,13 @@ void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event )
    m_ImageXSize_mm = 270;
    if( m_Config )
    {
        m_Config->Read( PLOTSVGPENWIDTH_KEY, &s_SVGPenMinWidth );
        m_Config->Read( OPTKEY_PLOT_LINEWIDTH_VALUE, &g_PlotLine_Width );
        m_Config->Read( PLOTSVGMODECOLOR_KEY, &s_PlotBlackAndWhite );
    }

    AddUnitSymbol(* m_TextPenWidth, g_UnitMetric );
    m_DialogPenWidth->SetValue(
        ReturnStringFromValue(g_UnitMetric, s_SVGPenMinWidth, m_Parent->m_InternalUnits ) );
        ReturnStringFromValue(g_UnitMetric, g_PlotLine_Width, m_Parent->m_InternalUnits ) );
    m_Print_Sheet_Ref->SetValue( s_Print_Frame_Ref );
    if (GetSizer())
    {
@@ -107,20 +105,20 @@ void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event )
void DIALOG_SVG_PRINT::SetPenWidth()
/********************************************/
{
    s_SVGPenMinWidth = ReturnValueFromTextCtrl( *m_DialogPenWidth, m_Parent->m_InternalUnits );
    g_PlotLine_Width = ReturnValueFromTextCtrl( *m_DialogPenWidth, m_Parent->m_InternalUnits );

    if( s_SVGPenMinWidth > WIDTH_MAX_VALUE )
    if( g_PlotLine_Width > WIDTH_MAX_VALUE )
    {
        s_SVGPenMinWidth = WIDTH_MAX_VALUE;
        g_PlotLine_Width = WIDTH_MAX_VALUE;
    }

    if( s_SVGPenMinWidth < WIDTH_MIN_VALUE )
    if( g_PlotLine_Width < WIDTH_MIN_VALUE )
    {
        s_SVGPenMinWidth = WIDTH_MIN_VALUE;
        g_PlotLine_Width = WIDTH_MIN_VALUE;
    }

    m_DialogPenWidth->SetValue(
        ReturnStringFromValue(g_UnitMetric, s_SVGPenMinWidth, m_Parent->m_InternalUnits ) );
        ReturnStringFromValue(g_UnitMetric, g_PlotLine_Width, m_Parent->m_InternalUnits ) );
}


@@ -237,8 +235,8 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, BASE_SCREEN* scre
    {
        EDA_Rect tmp = panel->m_ClipBox;
        GRResetPenAndBrush( &dc );
        s_SVGPenMinWidth =  ReturnValueFromTextCtrl( *m_DialogPenWidth, m_Parent->m_InternalUnits );
        SetPenMinWidth( s_SVGPenMinWidth );
        g_PlotLine_Width =  ReturnValueFromTextCtrl( *m_DialogPenWidth, m_Parent->m_InternalUnits );
        SetPenMinWidth( g_PlotLine_Width );
        GRForceBlackPen( m_ModeColorOption->GetSelection() == 0 ? FALSE : true );


@@ -295,7 +293,7 @@ void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event )
    if( m_Config )
    {
        s_PlotBlackAndWhite = m_ModeColorOption->GetSelection();
        m_Config->Write( PLOTSVGPENWIDTH_KEY, s_SVGPenMinWidth );
        m_Config->Write( OPTKEY_PLOT_LINEWIDTH_VALUE, g_PlotLine_Width );
        m_Config->Write( PLOTSVGMODECOLOR_KEY, s_PlotBlackAndWhite );
    }
    EndModal( 0 );
+3 −3
Original line number Diff line number Diff line
@@ -253,8 +253,8 @@ eda_global bool g_EditPinByPinIsOn /* bool: TRUE si edition des pin
;

eda_global int g_LibSymbolDefaultLineWidth; /* default line width  (in EESCHEMA units) used when creating a new graphic item in libedit : 0 = default */
eda_global int g_DrawMinimunLineWidth;      /* Minimum line (in EESCHEMA units) width used to draw items on screen; 0 = single pixel line width */
eda_global int g_PlotPSMinimunLineWidth;    /* Minimum line (in EESCHEMA units) width used to Plot items , postscript format */
eda_global int g_DrawMinimunLineWidth;      /* Minimum line (in EESCHEMA units) thickness used to draw items on screen; 0 = single pixel line width */
eda_global int g_PlotLine_Width;            /* Minimum line (in EESCHEMA units) thickness used to Plot/Print items */

eda_global int g_ItemSelectetColor          // Color to draw selected items
#ifdef MAIN
@@ -270,6 +270,6 @@ eda_global int g_InvisibleItemColor // Color to draw items flagged invis

/* Config keys */
#define MINI_DRAW_LINE_WIDTH_KEY   wxT( "MinimunDrawLineWidth" )
#define MINI_PLOTPS_LINE_WIDTH_KEY wxT( "MinimunPlotPSLineWidth" )
#define OPTKEY_PLOT_LINEWIDTH_VALUE wxT( "PlotLineWidth" )

#endif   // _GENERAL_H_
+5 −5
Original line number Diff line number Diff line
@@ -254,7 +254,7 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
            SetCurrentLineWidth( -1 );
            int thickness = Text->m_Width;
			if( thickness == 0 )	//
				thickness = MAX( g_PlotPSMinimunLineWidth, g_DrawMinimunLineWidth );
				thickness = MAX( g_PlotLine_Width, g_DrawMinimunLineWidth );
            PlotGraphicText( g_PlotFormat, pos, CharColor,
                                 Text->m_Text,
                                 t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT,
@@ -468,7 +468,7 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem,

    int thickness = field->m_Width;
	if( thickness == 0 )
		thickness = MAX( g_PlotPSMinimunLineWidth, g_DrawMinimunLineWidth );
		thickness = MAX( g_PlotLine_Width, g_DrawMinimunLineWidth );
    SetCurrentLineWidth( thickness );

    //@todo not sure what to do here in terms of plotting components that may have multiple REFERENCE entries.
@@ -675,7 +675,7 @@ void PlotTextStruct( EDA_BaseStruct* Struct )
    }

	if( thickness == 0 )
		thickness = MAX( g_PlotPSMinimunLineWidth, g_DrawMinimunLineWidth );
		thickness = MAX( g_PlotLine_Width, g_DrawMinimunLineWidth );
    SetCurrentLineWidth( thickness );

    switch( Orient )
@@ -773,7 +773,7 @@ static void PlotSheetLabelStruct( Hierarchical_PIN_Sheet_Struct* Struct )
    }
    int thickness = Struct->m_Width;
	if( thickness == 0 )
		thickness = MAX( g_PlotPSMinimunLineWidth, g_DrawMinimunLineWidth );
		thickness = MAX( g_PlotLine_Width, g_DrawMinimunLineWidth );
    SetCurrentLineWidth( thickness );

    bool italic = Struct->m_Italic;
@@ -843,7 +843,7 @@ void PlotSheetStruct( DrawSheetStruct* Struct )
    if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
        SetColorMapPS( ReturnLayerColor( Struct->m_Layer ) );

    int thickness = MAX( g_PlotPSMinimunLineWidth, g_DrawMinimunLineWidth );
    int thickness = MAX( g_PlotLine_Width, g_DrawMinimunLineWidth );
    SetCurrentLineWidth( thickness );

    Move_Plume( Struct->m_Pos, 'U' );
+7 −7
Original line number Diff line number Diff line
@@ -271,7 +271,7 @@ void WinEDA_PlotPSFrame::CreateControls()
    SetFocus(); // make the ESC work
    m_DefaultLineSizeCtrl = new WinEDA_ValueCtrl( this, _(
                                                      "Default Line Width" ),
                                                  g_PlotPSMinimunLineWidth,
                                                  g_PlotLine_Width,
                                                  g_UnitMetric, m_DefaultLineSizeCtrlSizer,
                                                  EESCHEMA_INTERNAL_UNIT );
}
@@ -363,9 +363,9 @@ void WinEDA_PlotPSFrame::InitOptVars()
    Plot_Sheet_Ref   = m_Plot_Sheet_Ref->GetValue();
    g_PlotPSColorOpt = m_PlotPSColorOption->GetSelection();
    PS_SizeSelect    = m_SizeOption->GetSelection();
    g_PlotPSMinimunLineWidth = m_DefaultLineSizeCtrl->GetValue();
    if( g_PlotPSMinimunLineWidth < 1 )
        g_PlotPSMinimunLineWidth = 1;
    g_PlotLine_Width = m_DefaultLineSizeCtrl->GetValue();
    if( g_PlotLine_Width < 1 )
        g_PlotLine_Width = 1;
}


@@ -479,7 +479,7 @@ void WinEDA_PlotPSFrame::PlotOneSheetPS( const wxString& FileName,
    m_MsgBox->AppendText( Line );

    InitPlotParametresPS( plot_offset, sheet, g_PlotScaleX, g_PlotScaleY );
    SetDefaultLineWidthPS( g_PlotPSMinimunLineWidth );
    SetDefaultLineWidthPS( g_PlotLine_Width );

    /* Init : */
    PrintHeaderPS( PlotOutput, wxT( "EESchema-PS" ), FileName, 1, BBox, wxLANDSCAPE );
@@ -531,10 +531,10 @@ void WinEDA_PlotPSFrame::PlotOneSheetPS( const wxString& FileName,

            case LAYER_BUS:         /* Trait large */
            {
                fprintf( PlotOutput, "%d setlinewidth\n", g_PlotPSMinimunLineWidth * 3 );
                fprintf( PlotOutput, "%d setlinewidth\n", g_PlotLine_Width * 3 );
                Move_Plume( StartPos, 'U' );
                Move_Plume( EndPos, 'D' );
                fprintf( PlotOutput, "%d setlinewidth\n", g_PlotPSMinimunLineWidth );
                fprintf( PlotOutput, "%d setlinewidth\n", g_PlotLine_Width );
            }
                break;

+2 −3
Original line number Diff line number Diff line
@@ -163,7 +163,7 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father,
    {
        g_DrawMinimunLineWidth = config->Read( MINI_DRAW_LINE_WIDTH_KEY,
                                               (long) 0 );
        g_PlotPSMinimunLineWidth = config->Read( MINI_PLOTPS_LINE_WIDTH_KEY,
        g_PlotLine_Width = config->Read( OPTKEY_PLOT_LINEWIDTH_VALUE,
                                                 (long) 4 );
    }

@@ -368,8 +368,7 @@ void WinEDA_SchematicFrame::OnCloseWindow( wxCloseEvent& Event )
    if( config )
    {
        config->Write( MINI_DRAW_LINE_WIDTH_KEY, (long) g_DrawMinimunLineWidth );
        config->Write( MINI_PLOTPS_LINE_WIDTH_KEY,
                       (long) g_PlotPSMinimunLineWidth );
        config->Write( OPTKEY_PLOT_LINEWIDTH_VALUE, (long) g_PlotLine_Width );
    }

    Destroy();
Loading