2011-10-12 10:03:43 -04:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-02-28 17:56:09 +01:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-12 10:03:43 -04: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
|
|
|
|
*/
|
|
|
|
|
2022-01-24 13:40:39 +00:00
|
|
|
#ifndef SCH_TEXT_H
|
|
|
|
#define SCH_TEXT_H
|
2008-02-21 20:49:15 +00:00
|
|
|
|
2010-11-10 10:30:12 -05:00
|
|
|
|
2012-04-12 17:31:31 -04:00
|
|
|
#include <eda_text.h>
|
2019-05-10 20:57:24 +01:00
|
|
|
#include <sch_item.h>
|
2019-03-11 17:32:05 -04:00
|
|
|
#include <sch_connection.h> // for CONNECTION_TYPE
|
2023-11-12 14:14:41 +00:00
|
|
|
#include <schematic.h>
|
2010-11-10 10:30:12 -05:00
|
|
|
|
|
|
|
|
2020-09-05 17:00:29 +01:00
|
|
|
class HTML_MESSAGE_BOX;
|
2010-11-10 10:30:12 -05:00
|
|
|
|
2011-03-29 15:33:07 -04:00
|
|
|
class SCH_TEXT : public SCH_ITEM, public EDA_TEXT
|
2009-05-12 12:12:34 +00:00
|
|
|
{
|
2008-02-21 20:49:15 +00:00
|
|
|
public:
|
2022-01-24 13:40:39 +00:00
|
|
|
SCH_TEXT( const VECTOR2I& aPos = { 0, 0 }, const wxString& aText = wxEmptyString,
|
2024-04-14 19:04:53 +01:00
|
|
|
SCH_LAYER_ID aLayer = LAYER_NOTES, KICAD_T aType = SCH_TEXT_T );
|
2010-12-21 10:13:09 -05:00
|
|
|
|
|
|
|
SCH_TEXT( const SCH_TEXT& aText );
|
|
|
|
|
2024-04-14 19:04:53 +01:00
|
|
|
~SCH_TEXT() override { }
|
2008-02-21 20:49:15 +00:00
|
|
|
|
2024-04-14 19:04:53 +01:00
|
|
|
static bool ClassOf( const EDA_ITEM* aItem )
|
2019-08-29 07:59:36 -07:00
|
|
|
{
|
|
|
|
return aItem && SCH_TEXT_T == aItem->Type();
|
|
|
|
}
|
|
|
|
|
2024-04-14 19:04:53 +01:00
|
|
|
wxString GetClass() const override
|
2008-02-21 20:49:15 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
return wxT( "SCH_TEXT" );
|
2008-02-21 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
2024-04-14 19:04:53 +01:00
|
|
|
wxString GetFriendlyName() const override
|
|
|
|
{
|
|
|
|
return _( "Text" );
|
|
|
|
}
|
|
|
|
|
2025-07-16 23:20:37 +01:00
|
|
|
KIFONT::FONT* GetDrawFont( const RENDER_SETTINGS* aSettings ) const override;
|
|
|
|
|
2023-05-05 14:21:56 +01:00
|
|
|
virtual wxString GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
|
|
|
|
int aDepth = 0 ) const;
|
2023-04-27 12:56:15 +01:00
|
|
|
|
2023-05-05 14:21:56 +01:00
|
|
|
wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override
|
2023-03-08 10:31:24 -05:00
|
|
|
{
|
2023-11-12 14:14:41 +00:00
|
|
|
SCHEMATIC* schematic = Schematic();
|
|
|
|
|
|
|
|
if( schematic )
|
|
|
|
return GetShownText( &schematic->CurrentSheet(), aAllowExtraText, aDepth );
|
|
|
|
else
|
|
|
|
return GetText();
|
2023-03-08 10:31:24 -05:00
|
|
|
}
|
2020-03-29 02:12:29 +01:00
|
|
|
|
2023-10-30 17:29:38 +00:00
|
|
|
int GetSchTextSize() const { return GetTextWidth(); }
|
|
|
|
void SetSchTextSize( int aSize ) { SetTextSize( VECTOR2I( aSize, aSize ) ); }
|
|
|
|
|
2022-08-27 19:14:57 +01:00
|
|
|
bool IsHypertext() const override
|
|
|
|
{
|
|
|
|
return HasHyperlink();
|
|
|
|
}
|
2022-05-14 15:52:53 +02:00
|
|
|
|
2022-08-27 19:14:57 +01:00
|
|
|
void DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const override;
|
2022-05-14 15:52:53 +02:00
|
|
|
|
2023-08-08 12:32:08 -04:00
|
|
|
void SetExcludedFromSim( bool aExclude ) override { m_excludedFromSim = aExclude; }
|
|
|
|
bool GetExcludedFromSim() const override { return m_excludedFromSim; }
|
2023-04-09 12:14:21 +01:00
|
|
|
|
2010-11-12 09:17:10 -06:00
|
|
|
/**
|
2011-12-08 10:45:01 -05:00
|
|
|
* This offset depends on the orientation, the type of text, and the area required to
|
|
|
|
* draw the associated graphic symbol or to put the text above a wire.
|
2021-03-25 17:13:01 -04:00
|
|
|
*
|
|
|
|
* @return the offset between the SCH_TEXT position and the text itself position
|
2009-05-12 12:12:34 +00:00
|
|
|
*/
|
2022-01-01 01:04:08 -05:00
|
|
|
virtual VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const;
|
2009-05-12 12:12:34 +00:00
|
|
|
|
2022-08-31 10:15:42 +01:00
|
|
|
const BOX2I GetBoundingBox() const override;
|
2008-04-15 19:38:19 +00:00
|
|
|
|
2020-01-28 07:42:42 -08:00
|
|
|
bool operator<( const SCH_ITEM& aItem ) const override;
|
|
|
|
|
2020-12-20 19:18:54 +01:00
|
|
|
int GetTextOffset( const RENDER_SETTINGS* aSettings = nullptr ) const;
|
2020-04-14 13:25:00 +01:00
|
|
|
|
|
|
|
int GetPenWidth() const override;
|
2009-06-30 17:57:27 +00:00
|
|
|
|
2022-01-01 01:04:08 -05:00
|
|
|
void Move( const VECTOR2I& aMoveVector ) override
|
2009-07-27 14:32:40 +00:00
|
|
|
{
|
2017-01-23 14:30:11 -06:00
|
|
|
EDA_TEXT::Offset( aMoveVector );
|
2009-07-27 14:32:40 +00:00
|
|
|
}
|
|
|
|
|
2024-04-14 19:04:53 +01:00
|
|
|
void NormalizeJustification( bool inverse );
|
|
|
|
|
2021-02-16 20:45:25 +00:00
|
|
|
void MirrorHorizontally( int aCenter ) override;
|
|
|
|
void MirrorVertically( int aCenter ) override;
|
2024-04-04 23:51:22 +01:00
|
|
|
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
|
2010-12-21 10:13:09 -05:00
|
|
|
|
2020-11-18 21:40:04 +00:00
|
|
|
virtual void Rotate90( bool aClockwise );
|
2020-11-18 23:34:03 +00:00
|
|
|
virtual void MirrorSpinStyle( bool aLeftRight );
|
2020-11-18 21:40:04 +00:00
|
|
|
|
2024-04-14 19:04:53 +01:00
|
|
|
void BeginEdit( const VECTOR2I& aStartPoint ) override;
|
|
|
|
void CalcEdit( const VECTOR2I& aPosition ) override;
|
|
|
|
|
2022-08-04 22:40:38 -04:00
|
|
|
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
|
2019-08-01 18:10:25 -06:00
|
|
|
{
|
|
|
|
return SCH_ITEM::Matches( GetText(), aSearchData );
|
|
|
|
}
|
2009-06-30 17:57:27 +00:00
|
|
|
|
2022-08-04 22:40:38 -04:00
|
|
|
bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override
|
2011-12-13 10:37:33 -05:00
|
|
|
{
|
2019-08-01 18:10:25 -06:00
|
|
|
return EDA_TEXT::Replace( aSearchData );
|
2011-12-13 10:37:33 -05:00
|
|
|
}
|
|
|
|
|
2024-04-14 19:04:53 +01:00
|
|
|
bool IsReplaceable() const override { return true; }
|
2011-12-13 10:37:33 -05:00
|
|
|
|
2024-11-21 13:18:36 -08:00
|
|
|
std::vector<int> ViewGetLayers() const override;
|
2021-12-07 20:47:12 +00:00
|
|
|
|
2024-06-27 10:11:55 +01:00
|
|
|
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
|
2011-10-12 10:03:43 -04:00
|
|
|
|
2021-03-07 21:59:07 -05:00
|
|
|
BITMAPS GetMenuImage() const override;
|
2012-03-15 10:31:16 -04:00
|
|
|
|
2022-01-01 01:04:08 -05:00
|
|
|
VECTOR2I GetPosition() const override { return EDA_TEXT::GetTextPos(); }
|
2025-02-06 09:47:00 -05:00
|
|
|
void SetPosition( const VECTOR2I& aPosition ) override
|
|
|
|
{
|
|
|
|
EDA_TEXT::SetTextPos( aPosition );
|
|
|
|
}
|
2012-03-15 10:31:16 -04:00
|
|
|
|
2022-01-01 01:04:08 -05:00
|
|
|
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
|
2022-08-31 10:33:46 +01:00
|
|
|
bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
2012-03-15 10:31:16 -04:00
|
|
|
|
2024-04-05 22:35:32 +01:00
|
|
|
void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
|
|
|
|
int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
|
2012-03-15 10:31:16 -04:00
|
|
|
|
2021-10-12 21:05:37 +01:00
|
|
|
EDA_ITEM* Clone() const override
|
|
|
|
{
|
|
|
|
return new SCH_TEXT( *this );
|
|
|
|
}
|
2012-03-17 10:39:27 -04:00
|
|
|
|
2020-04-24 14:36:10 +01:00
|
|
|
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
2012-11-20 12:35:09 +01:00
|
|
|
|
2024-04-14 19:04:53 +01:00
|
|
|
double Similarity( const SCH_ITEM& aItem ) const override;
|
2023-09-14 14:39:42 -07:00
|
|
|
|
2024-04-14 19:04:53 +01:00
|
|
|
bool operator==( const SCH_ITEM& aItem ) const override;
|
2023-09-14 14:39:42 -07:00
|
|
|
|
2008-04-22 16:38:23 +00:00
|
|
|
#if defined(DEBUG)
|
2016-09-25 19:06:49 +02:00
|
|
|
void Show( int nestLevel, std::ostream& os ) const override;
|
2008-04-22 16:38:23 +00:00
|
|
|
#endif
|
2020-05-09 21:27:06 +01:00
|
|
|
|
2020-09-05 17:00:29 +01:00
|
|
|
static HTML_MESSAGE_BOX* ShowSyntaxHelp( wxWindow* aParentWindow );
|
2021-03-25 17:13:01 -04:00
|
|
|
|
2022-10-22 21:32:10 +01:00
|
|
|
protected:
|
2025-03-26 10:13:47 -04:00
|
|
|
void swapData( SCH_ITEM* aItem ) override;
|
|
|
|
|
2023-08-06 20:20:53 +01:00
|
|
|
const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); }
|
|
|
|
|
2024-04-14 19:04:53 +01:00
|
|
|
/**
|
|
|
|
* @copydoc SCH_ITEM::compare()
|
|
|
|
*
|
|
|
|
* The text specific sort order is as follows:
|
|
|
|
* - Text string, case insensitive compare.
|
|
|
|
* - Text horizontal (X) position.
|
|
|
|
* - Text vertical (Y) position.
|
|
|
|
* - Text width.
|
|
|
|
* - Text height.
|
|
|
|
*/
|
|
|
|
int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override;
|
|
|
|
|
2021-03-25 17:13:01 -04:00
|
|
|
protected:
|
2023-08-08 12:32:08 -04:00
|
|
|
bool m_excludedFromSim;
|
2008-02-21 20:49:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-01-24 13:40:39 +00:00
|
|
|
#endif /* SCH_TEXT_H */
|