class_pcb_text.h 4.73 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) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
 * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.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 27 28
/**
 * @file class_pcb_text.h
 * @brief TEXTE_PCB class definition.
 */
29

30 31 32
#ifndef CLASS_PCB_TEXT_H
#define CLASS_PCB_TEXT_H

33
#include <eda_text.h>
34 35
#include <class_board_item.h>
#include <PolyLine.h>
36 37 38 39


class LINE_READER;
class EDA_DRAW_PANEL;
40
class MSG_PANEL_ITEM;
41

42

43
class TEXTE_PCB : public BOARD_ITEM, public EDA_TEXT
44 45
{
public:
dickelbeck's avatar
dickelbeck committed
46
    TEXTE_PCB( BOARD_ITEM* parent );
47 48 49

    // Do not create a copy constructor.  The one generated by the compiler is adequate.

dickelbeck's avatar
dickelbeck committed
50 51
    ~TEXTE_PCB();

52 53 54 55 56 57 58 59 60 61
    virtual const wxPoint& GetPosition() const
    {
        return m_Pos;
    }

    virtual void SetPosition( const wxPoint& aPos )
    {
        m_Pos = aPos;
    }

62
    void Move( const wxPoint& aMoveVector )
63 64 65 66
    {
        m_Pos += aMoveVector;
    }

67
    void Rotate( const wxPoint& aRotCentre, double aAngle );
68

69
    void Flip( const wxPoint& aCentre );
70

dickelbeck's avatar
dickelbeck committed
71 72 73
    /* duplicate structure */
    void Copy( TEXTE_PCB* source );

74 75
    void Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
               GR_DRAWMODE aDrawMode, const wxPoint& offset = ZeroOffset );
dickelbeck's avatar
dickelbeck committed
76

77
    void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
78

79
    bool HitTest( const wxPoint& aPosition )
80
    {
81
        return TextHitTest( aPosition );
82
    }
dickelbeck's avatar
dickelbeck committed
83

84 85 86 87
    /** @copydoc BOARD_ITEM::HitTest(const EDA_RECT& aRect,
     *                               bool aContained = true, int aAccuracy ) const
     */
    bool HitTest( const EDA_RECT& aRect, bool aContained = true, int aAccuracy = 0 ) const
88
    {
89
        return TextHitTest( aRect, aContained, aAccuracy );
90
    }
dickelbeck's avatar
dickelbeck committed
91

92
    wxString GetClass() const
93
    {
94
        return wxT( "PTEXT" );
95 96
    }

97
    /**
98 99 100 101
     * Function TransformBoundingBoxWithClearanceToPolygon
     * Convert the text bounding box to a rectangular polygon
     * depending on the text orientation, the bounding box
     * is not always horizontal or vertical
102 103 104
     * Used in filling zones calculations
     * Circles and arcs are approximated by segments
     * @param aCornerBuffer = a buffer to store the polygon
105 106 107 108
     * @param aClearanceValue = the clearance around the text bounding box
     * to the real clearance value (usually near from 1.0)
     */
    void TransformBoundingBoxWithClearanceToPolygon(
109
                    CPOLYGONS_LIST& aCornerBuffer,
110 111 112 113 114 115 116 117 118
                    int                    aClearanceValue ) const;

    /**
     * Function TransformShapeWithClearanceToPolygonSet
     * Convert the text shape to a set of polygons (one by segment)
     * Used in 3D viewer
     * Circles and arcs are approximated by segments
     * @param aCornerBuffer = a buffer to store the polygon
     * @param aClearanceValue = the clearance around the text
119 120 121 122 123
     * @param aCircleToSegmentsCount = the number of segments to approximate a circle
     * @param aCorrectionFactor = the correction to apply to circles radius to keep
     * clearance when the circle is approximated by segment bigger or equal
     * to the real clearance value (usually near from 1.0)
     */
124 125 126 127
    void TransformShapeWithClearanceToPolygonSet( CPOLYGONS_LIST& aCornerBuffer,
                                               int                aClearanceValue,
                                               int                aCircleToSegmentsCount,
                                               double             aCorrectionFactor ) const;
128

129
    wxString GetSelectMenuText() const;
130

131
    BITMAP_DEF GetMenuImage() const { return  add_text_xpm; }
132

133
    EDA_RECT GetBoundingBox() const;
134

135
    EDA_ITEM* Clone() const;
136

137 138 139
    /// @copydoc VIEW_ITEM::ViewBBox()
    virtual const BOX2I ViewBBox() const;

140
#if defined(DEBUG)
141
    virtual void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); }    // override
142
#endif
143 144
};

stambaughw's avatar
stambaughw committed
145
#endif  // #define CLASS_PCB_TEXT_H