KiCad PCB EDA Suite
No Matches
Go to the documentation of this file.
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2004 Jean-Pierre Charras, [email protected]
5 * Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 *
20 * or you may search the website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
25#ifndef LIB_SHAPE_H
26#define LIB_SHAPE_H
28#include <lib_item.h>
29#include <eda_shape.h>
32class LIB_SHAPE : public LIB_ITEM, public EDA_SHAPE
35 LIB_SHAPE( LIB_SYMBOL* aParent, SHAPE_T aShape, int aLineWidth = 0,
36 FILL_T aFillType = FILL_T::NO_FILL, KICAD_T aType = LIB_SHAPE_T );
38 // Do not create a copy constructor. The one generated by the compiler is adequate.
42 wxString GetClass() const override
43 {
44 return wxT( "LIB_SHAPE" );
45 }
47 static inline bool ClassOf( const EDA_ITEM* aItem )
48 {
49 return aItem && aItem->Type() == LIB_SHAPE_T;
50 }
52 wxString GetTypeName() const override
53 {
54 return ShowShape();
55 }
57 STROKE_PARAMS GetStroke() const { return m_stroke; }
58 void SetStroke( const STROKE_PARAMS& aStroke ) { m_stroke = aStroke; }
60 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
61 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
63 int GetPenWidth() const override;
66 {
67 if( m_stroke.GetLineStyle() == LINE_STYLE::DEFAULT )
68 return LINE_STYLE::SOLID;
69 else
70 return m_stroke.GetLineStyle();
71 }
73 const BOX2I GetBoundingBox() const override;
75 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
77 void BeginEdit( const VECTOR2I& aStartPoint ) override { beginEdit( aStartPoint ); }
78 bool ContinueEdit( const VECTOR2I& aPosition ) override { return continueEdit( aPosition ); }
79 void CalcEdit( const VECTOR2I& aPosition ) override { calcEdit( aPosition ); }
81 void EndEdit( bool aClosed = false ) override { endEdit( aClosed ); }
82 void SetEditState( int aState ) { setEditState( aState ); }
84 void AddPoint( const VECTOR2I& aPosition );
86 void Offset( const VECTOR2I& aOffset ) override;
88 void MoveTo( const VECTOR2I& aPosition ) override;
90 VECTOR2I GetPosition() const override { return getPosition(); }
91 void SetPosition( const VECTOR2I& aPosition ) override { setPosition( aPosition ); }
93 VECTOR2I GetCenter() const { return getCenter(); }
101 virtual std::vector<SHAPE*> MakeEffectiveShapes( bool aEdgeOnly = false ) const override
102 {
103 return makeEffectiveShapes( aEdgeOnly, true );
104 }
106 void Normalize();
108 void MirrorHorizontal( const VECTOR2I& aCenter ) override;
109 void MirrorVertical( const VECTOR2I& aCenter ) override;
110 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW = true ) override;
112 void Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset,
113 const TRANSFORM& aTransform, bool aDimmed ) const override;
115 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
117 BITMAPS GetMenuImage() const override;
119 EDA_ITEM* Clone() const override;
121 void ViewGetLayers( int aLayers[], int& aCount ) const override;
123 double Similarity( const LIB_ITEM& aOther ) const override;
125 bool operator==( const LIB_ITEM& aOther ) const override;
136 int compare( const LIB_ITEM& aOther, int aCompareFlags = 0 ) const override;
138 void print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
139 const TRANSFORM& aTransform, bool aDimmed ) override;
143#endif // LIB_SHAPE_H
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
VECTOR2I getCenter() const
Definition: eda_shape.cpp:512
void calcEdit(const VECTOR2I &aPosition)
Definition: eda_shape.cpp:1398
bool continueEdit(const VECTOR2I &aPosition)
Definition: eda_shape.cpp:1371
wxString ShowShape() const
Definition: eda_shape.cpp:60
std::vector< SHAPE * > makeEffectiveShapes(bool aEdgeOnly, bool aLineChainOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition: eda_shape.cpp:1207
void beginEdit(const VECTOR2I &aStartPoint)
Definition: eda_shape.cpp:1340
void endEdit(bool aClosed=true)
Finishes editing the shape.
Definition: eda_shape.cpp:1523
void setPosition(const VECTOR2I &aPos)
Definition: eda_shape.cpp:103
VECTOR2I getPosition() const
Definition: eda_shape.cpp:109
Definition: eda_shape.h:390
void setEditState(int aState)
Definition: eda_shape.h:374
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:68
Definition: lib_shape.h:40
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: lib_shape.cpp:46
STROKE_PARAMS GetStroke() const
Definition: lib_shape.h:57
void print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, void *aData, const TRANSFORM &aTransform, bool aDimmed) override
Print the item to aDC.
Definition: lib_shape.cpp:262
bool operator==(const LIB_ITEM &aOther) const override
Test LIB_ITEM objects for equivalence.
Definition: lib_shape.cpp:521
void BeginEdit(const VECTOR2I &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
Definition: lib_shape.h:77
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Display basic info (type, part and convert) about the current item in message panel.
Definition: lib_shape.cpp:448
void EndEdit(bool aClosed=false) override
End an object editing action.
Definition: lib_shape.h:81
void MirrorHorizontal(const VECTOR2I &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_shape.cpp:114
void SetStroke(const STROKE_PARAMS &aStroke)
Definition: lib_shape.h:58
LINE_STYLE GetEffectiveLineStyle() const
Definition: lib_shape.h:65
void AddPoint(const VECTOR2I &aPosition)
Definition: lib_shape.cpp:505
double Similarity(const LIB_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
Definition: lib_shape.cpp:532
void MirrorVertical(const VECTOR2I &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_shape.cpp:120
void Offset(const VECTOR2I &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_shape.cpp:81
void Plot(PLOTTER *aPlotter, bool aBackground, const VECTOR2I &aOffset, const TRANSFORM &aTransform, bool aDimmed) const override
Plot the draw item using the plot object.
Definition: lib_shape.cpp:134
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: lib_shape.cpp:64
int GetPenWidth() const override
Definition: lib_shape.cpp:256
const BOX2I GetBoundingBox() const override
Definition: lib_shape.cpp:438
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW=true) override
Rotate the object about aCenter point.
Definition: lib_shape.cpp:126
wxString GetClass() const override
Return the class name.
Definition: lib_shape.h:42
int compare(const LIB_ITEM &aOther, int aCompareFlags=0) const override
Provide the draw object specific comparison called by the == and < operators.
Definition: lib_shape.cpp:70
void SetEditState(int aState)
Definition: lib_shape.h:82
void SetPosition(const VECTOR2I &aPosition) override
Definition: lib_shape.h:91
bool ContinueEdit(const VECTOR2I &aPosition) override
Continue an edit in progress at aPosition.
Definition: lib_shape.h:78
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: lib_shape.cpp:456
static bool ClassOf(const EDA_ITEM *aItem)
Definition: lib_shape.h:47
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
Definition: lib_shape.h:79
VECTOR2I GetCenter() const
Definition: lib_shape.h:93
wxString GetTypeName() const override
Provide a user-consumable name of the object type.
Definition: lib_shape.h:52
void MoveTo(const VECTOR2I &aPosition) override
Move a draw object to aPosition.
Definition: lib_shape.cpp:87
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: lib_shape.cpp:488
void Normalize()
Definition: lib_shape.cpp:93
VECTOR2I GetPosition() const override
Definition: lib_shape.h:90
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const override
Make a set of SHAPE objects representing the LIB_SHAPE.
Definition: lib_shape.h:101
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
Definition: lib_shape.cpp:550
Define a library symbol object.
Definition: lib_symbol.h:99
Base plotter engine class.
Definition: plotter.h:104
Simple container to manage line stroke parameters.
Definition: stroke_params.h:81
LINE_STYLE GetLineStyle() const
Definition: stroke_params.h:94
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:46
Definition: eda_shape.h:42
Definition: eda_shape.h:54
Dashed line types.
Definition: stroke_params.h:48
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
Definition: typeinfo.h:199