class_gbr_layout.h 4.49 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/*
 * This program source code file is part of KiCad, a free EDA CAD application.
 *
 * Copyright (C) 2012-2014 Jean-Pierre Charras  jp.charras at wanadoo.fr
 * Copyright (C) 1992-2014 KiCad Developers, see change_log.txt for contributors.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, you may find one here:
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * or you may search the http://www.gnu.org website for the version 2 license,
 * or you may write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 */

25 26
/**
 * @file class_gbr_layout.h
27 28
 * @brief Class CLASS_GBR_LAYOUT to handle info to draw/print loaded Gerber images
 * and page frame reference
29 30 31 32 33 34 35 36 37 38
 */

#ifndef CLASS_GBR_LAYOUT_H
#define CLASS_GBR_LAYOUT_H


#include <dlist.h>

#include <class_colors_design_settings.h>
#include <common.h>                         // PAGE_INFO
39
#include <gerbview.h>                       // GERBER_DRAWLAYERS_COUNT
40 41 42
#include <class_title_block.h>
#include <class_gerber_draw_item.h>

43
#include <gr_basic.h>
44 45 46 47 48 49 50 51

/**
 * Class GBR_LAYOUT
 * holds list of GERBER_DRAW_ITEM currently loaded.
 */
class GBR_LAYOUT
{
private:
52 53 54 55
    EDA_RECT            m_BoundingBox;
    TITLE_BLOCK         m_titles;
    wxPoint             m_originAxisPosition;
    std::bitset <GERBER_DRAWLAYERS_COUNT> m_printLayersMask; // When printing: the list of layers to print
56 57
public:

58
    DLIST<GERBER_DRAW_ITEM> m_Drawings;     // linked list of Gerber Items to draw
59 60 61 62

    GBR_LAYOUT();
    ~GBR_LAYOUT();

63
    const wxPoint&      GetAuxOrigin() const
64 65 66 67
    {
        return m_originAxisPosition;
    }

68
    void SetAuxOrigin( const wxPoint& aPosition )
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
    {
        m_originAxisPosition = aPosition;
    }

    TITLE_BLOCK& GetTitleBlock()
    {
        return m_titles;
    }

    void SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
    {
        m_titles = aTitleBlock;
    }

    /**
     * Function ComputeBoundingBox
     * calculates the bounding box containing all Gerber items.
     * @return EDA_RECT - the full item list bounding box
     */
    EDA_RECT ComputeBoundingBox();

    /**
     * Function GetBoundingBox
     * may be called soon after ComputeBoundingBox() to return the same EDA_RECT,
     * as long as the CLASS_GBR_LAYOUT has not changed.
     */
    EDA_RECT GetBoundingBox() const { return m_BoundingBox; }    // override

    void SetBoundingBox( const EDA_RECT& aBox ) { m_BoundingBox = aBox; }

    /**
     * Function Draw.
     * Redraw the CLASS_GBR_LAYOUT items but not cursors, axis or grid.
     * @param aPanel = the panel relative to the board
     * @param aDC = the current device context
     * @param aDrawMode = GR_COPY, GR_OR ... (not always used)
     * @param aOffset = an draw offset value
106 107
     * @param aPrintBlackAndWhite = true to force black and white insdeat of color
     *        useful only to print/plot gebview layers
108 109
     */
    void    Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
110 111
                  GR_DRAWMODE aDrawMode, const wxPoint& aOffset,
                  bool aPrintBlackAndWhite = false );
112
    /**
113 114 115
     * Function SetPrintableLayers
     * changes the list of printable layers
     * @param aLayerMask = The new bit-mask of printable layers
116
     */
117
    void    SetPrintableLayers( const std::bitset <GERBER_DRAWLAYERS_COUNT>& aLayerMask  )
118 119 120 121 122
    {
        m_printLayersMask = aLayerMask;
    }

    /**
123 124 125 126 127 128 129 130 131 132
     * Function GetPrintableLayers
     * @return the bit-mask of printable layers
     */
    std::bitset <GERBER_DRAWLAYERS_COUNT> GetPrintableLayers()
    {
        return m_printLayersMask;
    }

     /**
     * Function IsLayerPrintable
133
     * tests whether a given layer is visible
134
     * @param aLayer = The layer to be tested
135 136
     * @return bool - true if the layer is visible.
     */
137 138 139 140
    bool    IsLayerPrintable( int aLayer ) const
    {
        return m_printLayersMask[ aLayer ];
    }
141 142 143 144 145 146 147 148

#if defined(DEBUG)
    void    Show( int nestLevel, std::ostream& os ) const;  // overload

#endif
};

#endif      // #ifndef CLASS_GBR_LAYOUT_H