2011-10-19 20:32:21 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-02-28 16:56:09 +00:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors.
|
2011-10-19 20:32:21 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
/**
|
|
|
|
* @file sch_field.h
|
|
|
|
* @brief Definition of the SCH_FIELD class for Eeschema.
|
|
|
|
*/
|
2008-09-20 17:20:40 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
#ifndef CLASS_SCH_FIELD_H
|
|
|
|
#define CLASS_SCH_FIELD_H
|
2008-09-20 17:20:40 +00:00
|
|
|
|
|
|
|
|
2012-04-12 21:31:31 +00:00
|
|
|
#include <eda_text.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <sch_item_struct.h>
|
|
|
|
#include <general.h>
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
class SCH_EDIT_FRAME;
|
2008-10-06 05:44:29 +00:00
|
|
|
class SCH_COMPONENT;
|
2009-10-08 13:19:28 +00:00
|
|
|
class LIB_FIELD;
|
2008-10-06 05:44:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-12-02 21:44:03 +00:00
|
|
|
* Class SCH_FIELD
|
2010-12-21 15:13:09 +00:00
|
|
|
* instances are attached to a component and provide a place for the component's value,
|
|
|
|
* reference designator, footprint, and user definable name-value pairs of arbitrary purpose.
|
|
|
|
*
|
|
|
|
* <ul> <li>Field 0 is reserved for the component reference.</li>
|
|
|
|
* <li>Field 1 is reserved for the component value.</li>
|
|
|
|
* <li>Field 2 is reserved for the component footprint.</li>
|
|
|
|
* <li>Field 3 is reserved for the component data sheet file.</li>
|
2012-01-09 20:26:55 +00:00
|
|
|
* <li>Field 4 and higher are user defineable.</li></ul>
|
2008-10-06 05:44:29 +00:00
|
|
|
*/
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
class SCH_FIELD : public SCH_ITEM, public EDA_TEXT
|
2008-09-20 17:20:40 +00:00
|
|
|
{
|
2011-12-07 18:47:59 +00:00
|
|
|
int m_id; ///< Field index, @see enum NumFieldType
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2011-12-07 18:47:59 +00:00
|
|
|
wxString m_name;
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2008-09-20 17:20:40 +00:00
|
|
|
public:
|
2010-09-05 17:01:48 +00:00
|
|
|
SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent,
|
2009-12-02 21:44:03 +00:00
|
|
|
wxString aName = wxEmptyString );
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2012-01-09 20:26:55 +00:00
|
|
|
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
~SCH_FIELD();
|
2008-09-20 17:20:40 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
wxString GetClass() const
|
2008-09-20 17:20:40 +00:00
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
return wxT( "SCH_FIELD" );
|
2011-12-07 18:47:59 +00:00
|
|
|
}
|
2008-09-20 17:20:40 +00:00
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
/**
|
|
|
|
* Function GetName
|
2011-12-07 18:47:59 +00:00
|
|
|
* returns the field name.
|
|
|
|
*
|
|
|
|
* @param aUseDefaultName When true return the default field name if the field name is
|
|
|
|
* empty. Otherwise the default field name is returned.
|
|
|
|
* @return A wxString object containing the name of the field.
|
2011-03-25 19:16:05 +00:00
|
|
|
*/
|
2011-12-07 18:47:59 +00:00
|
|
|
wxString GetName( bool aUseDefaultName = true ) const;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2011-12-07 18:47:59 +00:00
|
|
|
void SetName( const wxString& aName ) { m_name = aName; }
|
|
|
|
|
|
|
|
int GetId() const { return m_id; }
|
|
|
|
|
|
|
|
void SetId( int aId ) { m_id = aId; }
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2011-10-21 18:17:51 +00:00
|
|
|
/**
|
2013-03-25 17:09:55 +00:00
|
|
|
* Function GetFullyQualifiedText
|
|
|
|
* returns the fully qualified field text by allowing for the part suffix to be added
|
|
|
|
* to the reference designator field if the component has multiple parts. For all other
|
|
|
|
* fields this is the equivalent of EDA_TEXT::GetText().
|
2011-10-21 18:17:51 +00:00
|
|
|
*
|
2011-11-30 21:15:56 +00:00
|
|
|
* @return a const wxString object containing the field's string.
|
2011-10-21 18:17:51 +00:00
|
|
|
*/
|
2013-03-25 17:09:55 +00:00
|
|
|
const wxString GetFullyQualifiedText() const;
|
2011-10-21 18:17:51 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
void Place( SCH_EDIT_FRAME* frame, wxDC* DC );
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2013-11-24 17:48:14 +00:00
|
|
|
const EDA_RECT GetBoundingBox() const; // Virtual
|
2010-07-30 21:41:55 +00:00
|
|
|
|
2015-12-13 16:56:47 +00:00
|
|
|
/**
|
|
|
|
* Function IsHorizJustifyFlipped
|
|
|
|
* Returns whether the field will be rendered with the horizontal justification
|
|
|
|
* inverted due to rotation or mirroring of the parent.
|
|
|
|
*/
|
|
|
|
bool IsHorizJustifyFlipped() const;
|
|
|
|
|
2010-07-30 21:41:55 +00:00
|
|
|
/**
|
|
|
|
* Function IsVoid
|
|
|
|
* returns true if the field is either empty or holds "~".
|
|
|
|
*/
|
2010-12-10 19:47:44 +00:00
|
|
|
bool IsVoid() const
|
2010-07-30 21:41:55 +00:00
|
|
|
{
|
|
|
|
size_t len = m_Text.Len();
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2010-07-30 21:41:55 +00:00
|
|
|
return len == 0 || ( len == 1 && m_Text[0] == wxChar( '~' ) );
|
|
|
|
}
|
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
void SwapData( SCH_ITEM* aItem );
|
2008-09-20 17:20:40 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function ImportValues
|
2008-12-31 15:01:29 +00:00
|
|
|
* copy parameters from a source.
|
|
|
|
* Pointers and specific values (position) are not copied
|
2009-10-08 13:19:28 +00:00
|
|
|
* @param aSource = the LIB_FIELD to read
|
2008-12-31 15:01:29 +00:00
|
|
|
*/
|
2010-09-05 17:01:48 +00:00
|
|
|
void ImportValues( const LIB_FIELD& aSource );
|
2008-12-31 15:01:29 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
int GetPenSize() const;
|
2009-06-30 17:57:27 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function IsVisible
|
2009-12-30 18:06:12 +00:00
|
|
|
* @return true is this field is visible, false if flagged invisible
|
|
|
|
*/
|
2010-12-10 19:47:44 +00:00
|
|
|
bool IsVisible() const
|
2009-12-30 18:06:12 +00:00
|
|
|
{
|
2015-12-13 16:56:47 +00:00
|
|
|
return !( m_Attributs & TEXT_NO_VISIBLE );
|
2009-12-30 18:06:12 +00:00
|
|
|
}
|
|
|
|
|
2015-02-28 16:56:09 +00:00
|
|
|
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
|
|
|
|
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR );
|
2008-09-20 17:20:40 +00:00
|
|
|
|
|
|
|
bool Save( FILE* aFile ) const;
|
2009-07-27 14:32:40 +00:00
|
|
|
|
|
|
|
// Geometric transforms (used in block operations):
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
void Move( const wxPoint& aMoveVector )
|
2009-07-27 14:32:40 +00:00
|
|
|
{
|
|
|
|
m_Pos += aMoveVector;
|
|
|
|
}
|
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
void Rotate( wxPoint aPosition );
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
/**
|
|
|
|
* @copydoc SCH_ITEM::MirrorX()
|
|
|
|
*
|
|
|
|
* This overload does nothing. Fields are never mirrored alone. They are moved
|
|
|
|
* when the parent component is mirrored. This function is only needed by the
|
2012-03-26 23:47:08 +00:00
|
|
|
* pure function of the master class.
|
2012-03-15 14:31:16 +00:00
|
|
|
*/
|
2012-03-26 23:47:08 +00:00
|
|
|
void MirrorX( int aXaxis_position )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
/**
|
|
|
|
* @copydoc SCH_ITEM::MirrorY()
|
|
|
|
*
|
|
|
|
* This overload does nothing. Fields are never mirrored alone. They are moved
|
|
|
|
* when the parent component is mirrored. This function is only needed by the
|
2012-03-26 23:47:08 +00:00
|
|
|
* pure function of the master class.
|
2009-07-27 14:32:40 +00:00
|
|
|
*/
|
2012-03-26 23:47:08 +00:00
|
|
|
void MirrorY( int aYaxis_position )
|
2009-07-27 14:32:40 +00:00
|
|
|
{
|
|
|
|
}
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation );
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
bool Replace( wxFindReplaceData& aSearchData, void* aAuxData = NULL );
|
2011-12-13 15:37:33 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
wxString GetSelectMenuText() const;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
BITMAP_DEF GetMenuImage() const;
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
bool IsReplaceable() const { return true; }
|
2011-12-01 16:49:28 +00:00
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
wxPoint GetLibPosition() const { return m_Pos; }
|
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
wxPoint GetPosition() const;
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
void SetPosition( const wxPoint& aPosition );
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
bool HitTest( const wxPoint& aPosition, int aAccuracy ) const;
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
bool HitTest( const EDA_RECT& aRect, bool aContained = false, int aAccuracy = 0 ) const;
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
void Plot( PLOTTER* aPlotter );
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
EDA_ITEM* Clone() const;
|
2012-03-17 14:39:27 +00:00
|
|
|
|
2011-12-14 17:25:42 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
|
|
|
|
#endif
|
2008-09-20 17:20:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
#endif /* CLASS_SCH_FIELD_H */
|