KiCad PCB EDA Suite
sch_field.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2004-2019 KiCad Developers, see change_log.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
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org 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  */
24 
25 #ifndef CLASS_SCH_FIELD_H
26 #define CLASS_SCH_FIELD_H
27 
28 
29 #include <eda_text.h>
30 #include <sch_item.h>
31 #include <template_fieldnames.h>
32 #include <general.h>
33 
34 
35 class SCH_EDIT_FRAME;
36 class SCH_COMPONENT;
37 class LIB_FIELD;
38 
39 
52 class SCH_FIELD : public SCH_ITEM, public EDA_TEXT
53 {
54  int m_id;
55 
56  wxString m_name;
57 
58 public:
59  SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent,
60  const wxString& aName = wxEmptyString );
61 
62  // Do not create a copy constructor. The one generated by the compiler is adequate.
63 
64  ~SCH_FIELD();
65 
66  wxString GetClass() const override
67  {
68  return wxT( "SCH_FIELD" );
69  }
70 
71  bool IsType( const KICAD_T aScanTypes[] ) override
72  {
73  if( SCH_ITEM::IsType( aScanTypes ) )
74  return true;
75 
76  for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
77  {
79  return true;
80  else if ( *p == SCH_FIELD_LOCATE_VALUE_T && m_id == VALUE )
81  return true;
82  else if ( *p == SCH_FIELD_LOCATE_FOOTPRINT_T && m_id == FOOTPRINT )
83  return true;
84  else if ( *p == SCH_FIELD_LOCATE_DATASHEET_T && m_id == DATASHEET )
85  return true;
86  }
87 
88  return false;
89  }
90 
99  wxString GetName( bool aUseDefaultName = true ) const;
100 
101  void SetName( const wxString& aName ) { m_name = aName; }
102 
103  int GetId() const { return m_id; }
104 
105  void SetId( int aId ) { m_id = aId; }
106 
115  const wxString GetFullyQualifiedText() const;
116 
117  void Place( SCH_EDIT_FRAME* frame, wxDC* DC );
118 
119  const EDA_RECT GetBoundingBox() const override;
120 
126  bool IsHorizJustifyFlipped() const;
127 
132  bool IsVoid() const;
133 
134  void SwapData( SCH_ITEM* aItem ) override;
135 
142  void ImportValues( const LIB_FIELD& aSource );
143 
144  int GetPenSize() const override;
145 
146  void Print( wxDC* aDC, const wxPoint& aOffset ) override;
147 
148  void Move( const wxPoint& aMoveVector ) override
149  {
150  Offset( aMoveVector );
151  }
152 
153  void Rotate( wxPoint aPosition ) override;
154 
162  void MirrorX( int aXaxis_position ) override
163  {
164  }
165 
173  void MirrorY( int aYaxis_position ) override
174  {
175  }
176 
177  bool Matches( wxFindReplaceData& aSearchData, void* aAuxData ) override;
178 
179  bool Replace( wxFindReplaceData& aSearchData, void* aAuxData = NULL ) override;
180 
181  wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
182 
183  BITMAP_DEF GetMenuImage() const override;
184 
185  bool IsReplaceable() const override;
186 
187  wxPoint GetLibPosition() const { return EDA_TEXT::GetTextPos(); }
188 
189  wxPoint GetPosition() const override;
190  void SetPosition( const wxPoint& aPosition ) override;
191 
192  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
193  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
194 
195  void Plot( PLOTTER* aPlotter ) override;
196 
197  EDA_ITEM* Clone() const override;
198 
199 #if defined(DEBUG)
200  void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
201 #endif
202 };
203 
204 
205 #endif /* CLASS_SCH_FIELD_H */
void Move(const wxPoint &aMoveVector) override
Function Move moves the item by aMoveVector to a new position.
Definition: sch_field.h:148
Class SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
void Offset(const wxPoint &aOffset)
Definition: eda_text.h:235
bool IsType(const KICAD_T aScanTypes[]) override
Function IsType Checks whether the item is one of the listed types.
Definition: sch_field.h:71
int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_field.cpp:96
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_field.h:162
SCH_FIELD(const wxPoint &aPos, int aFieldId, SCH_COMPONENT *aParent, const wxString &aName=wxEmptyString)
Definition: sch_field.cpp:51
name of datasheet
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_field.cpp:69
void ImportValues(const LIB_FIELD &aSource)
Function ImportValues copy parameters from a LIB_FIELD source.
Definition: sch_field.cpp:175
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_field.cpp:493
Field object used in symbol libraries.
Definition: lib_field.h:59
void Place(SCH_EDIT_FRAME *frame, wxDC *DC)
Definition: sch_field.cpp:263
int GetId() const
Definition: sch_field.h:103
virtual bool IsType(const KICAD_T aScanTypes[])
Function IsType Checks whether the item is one of the listed types.
Definition: base_struct.h:293
Schematic editor (Eeschema) main window.
wxString m_name
Definition: sch_field.h:56
Field Name Module PCB, i.e. "16DIP300".
Field Reference of part, i.e. "IC21".
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
bool IsVoid() const
Function IsVoid returns true if the field is either empty or holds "~".
Definition: sch_field.cpp:257
Class EDA_TEXT is a mix-in class (via multiple inheritance) that handles texts such as labels,...
Definition: eda_text.h:109
#define VALUE
wxString GetSelectMenuText(EDA_UNITS_T aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_field.cpp:364
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
Definition: sch_field.cpp:396
wxPoint GetLibPosition() const
Definition: sch_field.h:187
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_field.cpp:381
void Print(wxDC *aDC, const wxPoint &aOffset) override
Function Print Print a schematic item.
Definition: sch_field.cpp:114
void MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
Definition: sch_field.h:173
Base plotter engine class.
Definition: plotter.h:97
void Plot(PLOTTER *aPlotter) override
Function Plot plots the schematic item to aPlotter.
Definition: sch_field.cpp:427
bool Replace(wxFindReplaceData &aSearchData, void *aAuxData=NULL) override
Function Replace performs a text replace using the find and replace criteria in aSearchData on items ...
Definition: sch_field.cpp:320
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_field.cpp:194
bool Matches(wxFindReplaceData &aSearchData, void *aAuxData) override
Function Matches compares the item against the search criteria in aSearchData.
Definition: sch_field.cpp:275
void SwapData(SCH_ITEM *aItem) override
Function SwapData swap the internal data structures aItem with the schematic item.
Definition: sch_field.cpp:181
wxString GetName(bool aUseDefaultName=true) const
Function GetName returns the field name.
Definition: sch_field.cpp:370
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
void SetName(const wxString &aName)
Definition: sch_field.h:101
const wxString GetFullyQualifiedText() const
Function GetFullyQualifiedText returns the fully qualified field text by allowing for the part suffix...
Definition: sch_field.cpp:75
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_field.h:66
bool IsHorizJustifyFlipped() const
Function IsHorizJustifyFlipped Returns whether the field will be rendered with the horizontal justifi...
Definition: sch_field.cpp:240
const wxPoint & GetTextPos() const
Definition: eda_text.h:230
bool IsReplaceable() const override
Function IsReplaceable.
Definition: sch_field.cpp:307
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_field.cpp:356
void SetId(int aId)
Definition: sch_field.h:105
int m_id
Field index,.
Definition: sch_field.h:54
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
Definition: sch_field.cpp:478
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
EDA_UNITS_T
Definition: common.h:154