Commit eb94e66c authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Pcbnew: some code cleanup in plot functions.

parent b1c9c542
Loading
Loading
Loading
Loading
+6 −13
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
    wxPoint     offset;
    PLOTTER*    plotter = NULL;

    const PCB_PLOT_PARAMS&  plot_opts = aPcb->GetPlotOptions();
    PCB_PLOT_PARAMS plot_opts;    // starts plotting with default options

    LOCALE_IO   toggle;         // use standard C notation for float numbers

@@ -131,33 +131,26 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
    plotter->SetDefaultLineWidth( 10 * IU_PER_DECIMILS );
    plotter->StartPlot( aFile );

    // Draw items on edge layer
    // Draw items on edge layer (not all, only items useful for drill map
    BRDITEMS_PLOTTER itemplotter( plotter, aPcb, plot_opts );
    itemplotter.SetLayerMask( EDGE_LAYER );

    for( EDA_ITEM* PtStruct = aPcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() )
    {
        switch( PtStruct->Type() )
        {
        case PCB_LINE_T:
            PlotDrawSegment( plotter, plot_opts, (DRAWSEGMENT*) PtStruct, EDGE_LAYER, FILLED );
            itemplotter.PlotDrawSegment( (DRAWSEGMENT*) PtStruct );
            break;

        case PCB_TEXT_T:
            PlotTextePcb( plotter, plot_opts, (TEXTE_PCB*) PtStruct, EDGE_LAYER, FILLED );
            itemplotter.PlotTextePcb( (TEXTE_PCB*) PtStruct );
            break;

        case PCB_DIMENSION_T:
            PlotDimension( plotter, plot_opts, (DIMENSION*) PtStruct, EDGE_LAYER, FILLED );
            break;

        case PCB_TARGET_T:
            PlotPcbTarget( plotter, plot_opts, (PCB_TARGET*) PtStruct, EDGE_LAYER, FILLED );
            break;

        case PCB_MARKER_T:     // do not draw
            break;

        default:
            DisplayError( NULL, wxT( "WinEDA_DrillFrame::GenDrillMap() : Unexpected Draw Type" ) );
            break;
        }
    }
+41 −20
Original line number Diff line number Diff line
@@ -7,14 +7,16 @@

#include <pcb_plot_params.h>


class PLOTTER;
class TEXTE_PCB;
class DRAWSEGMENT;
class DIMENSION;
class MODULE;
class EDGE_MODULE;
class PCB_TARGET;
class TEXTE_MODULE;
class ZONE_CONTAINER;
class BOARD;


// Shared Config keys for plot and print
@@ -43,25 +45,44 @@ class ZONE_CONTAINER;

// Small drill marks diameter value (in 1/10000 inch)
#define SMALL_DRILL 150
// A helper class to plot board items
class BRDITEMS_PLOTTER: public PCB_PLOT_PARAMS
{
    PLOTTER* m_plotter;
    BOARD* m_board;
    int m_layerMask;

public:
    BRDITEMS_PLOTTER( PLOTTER* aPlotter, BOARD* aBoard, const PCB_PLOT_PARAMS& aPlotOpts )
        : PCB_PLOT_PARAMS( aPlotOpts )
    {
        m_plotter = aPlotter;
        m_board = aBoard;
        m_layerMask = 0;
    }

    // Basic functions to plot a board item
    void SetLayerMask( int aLayerMask ){ m_layerMask = aLayerMask; }
    void Plot_Edges_Modules();
    void Plot_1_EdgeModule( EDGE_MODULE* aEdge );
    void PlotTextModule( TEXTE_MODULE* aTextMod, EDA_COLOR_T aColor );
    bool PlotAllTextsModule( MODULE* aModule );
    void PlotDimension( DIMENSION* Dimension );
    void PlotPcbTarget( PCB_TARGET* PtMire );
    void PlotFilledAreas( ZONE_CONTAINER* aZone );
    void PlotTextePcb( TEXTE_PCB* pt_texte );
    void PlotDrawSegment( DRAWSEGMENT* PtSegm );


void PlotTextePcb( PLOTTER* plotter, const PCB_PLOT_PARAMS& aPlotOpts, TEXTE_PCB* pt_texte, int masque_layer,
                   EDA_DRAW_MODE_T trace_mode );

void PlotDrawSegment( PLOTTER* plotter, const PCB_PLOT_PARAMS& aPlotOpts, DRAWSEGMENT* PtSegm, int masque_layer,
                      EDA_DRAW_MODE_T trace_mode );

void PlotDimension( PLOTTER* plotter, const PCB_PLOT_PARAMS& aPlotOpts, DIMENSION* Dimension, int masque_layer,
                    EDA_DRAW_MODE_T trace_mode );

void PlotPcbTarget( PLOTTER* plotter, const PCB_PLOT_PARAMS& aPlotOpts, PCB_TARGET* PtMire, int masque_layer,
                    EDA_DRAW_MODE_T trace_mode );

void Plot_1_EdgeModule( PLOTTER* plotter, const PCB_PLOT_PARAMS& aPlotOpts, EDGE_MODULE* PtEdge,
                        EDA_DRAW_MODE_T trace_mode, int masque_layer );

void PlotFilledAreas( PLOTTER* plotter, const PCB_PLOT_PARAMS& aPlotOpts, ZONE_CONTAINER* aZone,
                      EDA_DRAW_MODE_T trace_mode );
    /**
     * Function getColor
     * @return the layer color
     * @param aLayer = the layer id
     * White color is special: cannot be seen on a white paper
     * and in B&W mode, is plotted as white but other colors are plotted in BLACK
     * so the returned color is LIGHTGRAY when the layer color is WHITE
     */
    EDA_COLOR_T getColor( int aLayer );
};

PLOTTER *StartPlotBoard( BOARD *aBoard,
                         PCB_PLOT_PARAMS *aPlotOpts,