2011-10-12 14:03:43 +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
|
2021-03-25 21:13:01 +00:00
|
|
|
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-12 14:03:43 +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
|
|
|
|
*/
|
|
|
|
|
2008-02-21 20:49:15 +00:00
|
|
|
#ifndef CLASS_TEXT_LABEL_H
|
|
|
|
#define CLASS_TEXT_LABEL_H
|
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2012-04-12 21:31:31 +00:00
|
|
|
#include <eda_text.h>
|
2019-05-10 19:57:24 +00:00
|
|
|
#include <sch_item.h>
|
2020-11-17 16:02:47 +00:00
|
|
|
#include <sch_field.h>
|
2019-03-11 21:32:05 +00:00
|
|
|
#include <sch_connection.h> // for CONNECTION_TYPE
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
class NETLIST_OBJECT_LIST;
|
2020-09-05 16:00:29 +00:00
|
|
|
class HTML_MESSAGE_BOX;
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2020-01-09 07:52:30 +00:00
|
|
|
/*
|
2020-01-08 19:07:55 +00:00
|
|
|
* Spin style for text items of all kinds on schematics
|
|
|
|
* Basically a higher level abstraction of rotation and justification of text
|
|
|
|
*/
|
|
|
|
class LABEL_SPIN_STYLE
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum SPIN : int
|
|
|
|
{
|
|
|
|
LEFT = 0,
|
|
|
|
UP = 1,
|
|
|
|
RIGHT = 2,
|
|
|
|
BOTTOM = 3
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
LABEL_SPIN_STYLE() = default;
|
|
|
|
constexpr LABEL_SPIN_STYLE( SPIN aSpin ) : m_spin( aSpin )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr bool operator==( SPIN a ) const
|
|
|
|
{
|
|
|
|
return m_spin == a;
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr bool operator!=( SPIN a ) const
|
|
|
|
{
|
|
|
|
return m_spin != a;
|
|
|
|
}
|
|
|
|
|
|
|
|
operator int() const
|
|
|
|
{
|
|
|
|
return static_cast<int>( m_spin );
|
|
|
|
}
|
|
|
|
|
2021-06-01 23:13:53 +00:00
|
|
|
LABEL_SPIN_STYLE RotateCW();
|
2020-01-08 19:07:55 +00:00
|
|
|
|
2021-06-01 23:13:53 +00:00
|
|
|
LABEL_SPIN_STYLE RotateCCW();
|
2020-01-08 19:07:55 +00:00
|
|
|
|
2021-06-08 14:09:24 +00:00
|
|
|
/**
|
|
|
|
* Mirror the label spin style across the X axis or simply swaps up and bottom.
|
2020-01-08 19:07:55 +00:00
|
|
|
*/
|
2021-06-01 23:13:53 +00:00
|
|
|
LABEL_SPIN_STYLE MirrorX();
|
2020-01-08 19:07:55 +00:00
|
|
|
|
2021-06-08 14:09:24 +00:00
|
|
|
/**
|
|
|
|
* Mirror the label spin style across the Y axis or simply swaps left and right.
|
2020-01-08 19:07:55 +00:00
|
|
|
*/
|
2021-06-01 23:13:53 +00:00
|
|
|
LABEL_SPIN_STYLE MirrorY();
|
2020-01-08 19:07:55 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
SPIN m_spin;
|
|
|
|
};
|
2008-02-21 20:49:15 +00:00
|
|
|
|
2021-03-25 21:13:01 +00:00
|
|
|
/*
|
|
|
|
* Shape/Type of #SCH_HIERLABEL and #SCH_GLOBALLABEL.
|
2009-11-03 13:26:31 +00:00
|
|
|
*/
|
2020-01-08 19:07:55 +00:00
|
|
|
enum class PINSHEETLABEL_SHAPE
|
|
|
|
{
|
2020-01-09 07:52:30 +00:00
|
|
|
PS_INPUT, // use "PS_INPUT" instead of "INPUT" to avoid colliding
|
|
|
|
// with a Windows header on msys2
|
|
|
|
PS_OUTPUT,
|
|
|
|
PS_BIDI,
|
|
|
|
PS_TRISTATE,
|
|
|
|
PS_UNSPECIFIED
|
2016-02-28 18:16:59 +00:00
|
|
|
};
|
2008-02-21 20:49:15 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
extern const char* SheetLabelType[]; /* names of types of labels */
|
2009-05-09 21:54:33 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
|
2011-03-29 19:33:07 +00: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:
|
2020-04-14 12:25:00 +00:00
|
|
|
SCH_TEXT( const wxPoint& aPos = wxPoint( 0, 0 ), const wxString& aText = wxEmptyString,
|
2020-04-18 20:04:41 +00:00
|
|
|
KICAD_T aType = SCH_TEXT_T );
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2012-01-09 20:26:55 +00:00
|
|
|
/**
|
2021-06-08 14:09:24 +00:00
|
|
|
* Clone \a aText into a new object. All members are copied as is except
|
2012-01-09 20:26:55 +00:00
|
|
|
* for the #m_isDangling member which is set to false. This prevents newly
|
|
|
|
* copied objects derived from #SCH_TEXT from having their connection state
|
|
|
|
* improperly set.
|
|
|
|
*/
|
2010-12-21 15:13:09 +00:00
|
|
|
SCH_TEXT( const SCH_TEXT& aText );
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
~SCH_TEXT() { }
|
2008-02-21 20:49:15 +00:00
|
|
|
|
2019-08-29 14:59:36 +00:00
|
|
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
|
|
|
{
|
|
|
|
return aItem && SCH_TEXT_T == aItem->Type();
|
|
|
|
}
|
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
virtual 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
|
|
|
}
|
|
|
|
|
2020-05-27 22:28:36 +00:00
|
|
|
/**
|
2021-06-08 14:09:24 +00:00
|
|
|
* Return the set of contextual text variable tokens for this text item.
|
2021-03-25 21:13:01 +00:00
|
|
|
*
|
|
|
|
* @param[out] aVars
|
2020-05-27 22:28:36 +00:00
|
|
|
*/
|
|
|
|
void GetContextualTextVars( wxArrayString* aVars ) const;
|
|
|
|
|
2020-04-06 13:06:57 +00:00
|
|
|
wxString GetShownText( int aDepth = 0 ) const override;
|
2020-03-29 01:12:29 +00:00
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
/**
|
2017-11-18 13:10:32 +00:00
|
|
|
* Increment the label text, if it ends with a number.
|
|
|
|
*
|
|
|
|
* @param aIncrement = the increment value to add to the number ending the text.
|
2010-12-21 15:13:09 +00:00
|
|
|
*/
|
2020-12-04 12:48:32 +00:00
|
|
|
bool IncrementLabel( int aIncrement );
|
2008-02-21 20:49:15 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2017-11-18 13:10:32 +00:00
|
|
|
* Set a spin or rotation angle, along with specific horizontal and vertical justification
|
|
|
|
* styles with each angle.
|
2017-01-23 20:30:11 +00:00
|
|
|
*
|
2021-03-25 21:13:01 +00:00
|
|
|
* @param aSpinStyle Spin style as per #LABEL_SPIN_STYLE storage class, may be the enum
|
|
|
|
* values or int value
|
2009-05-12 12:12:34 +00:00
|
|
|
*/
|
2020-01-08 19:07:55 +00:00
|
|
|
virtual void SetLabelSpinStyle( LABEL_SPIN_STYLE aSpinStyle );
|
2020-11-16 13:15:54 +00:00
|
|
|
LABEL_SPIN_STYLE GetLabelSpinStyle() const { return m_spin_style; }
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
PINSHEETLABEL_SHAPE GetShape() const { return m_shape; }
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2016-02-28 18:16:59 +00:00
|
|
|
void SetShape( PINSHEETLABEL_SHAPE aShape ) { m_shape = aShape; }
|
2009-05-12 12:12:34 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2011-12-08 15:45:01 +00: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 21:13:01 +00:00
|
|
|
*
|
|
|
|
* @return the offset between the SCH_TEXT position and the text itself position
|
2009-05-12 12:12:34 +00:00
|
|
|
*/
|
2020-12-20 18:18:54 +00:00
|
|
|
virtual wxPoint GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const;
|
2009-05-12 12:12:34 +00:00
|
|
|
|
2020-12-20 18:18:54 +00:00
|
|
|
void Print( const RENDER_SETTINGS* aSettings, const wxPoint& offset ) override;
|
2008-02-21 20:49:15 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2017-11-18 13:10:32 +00:00
|
|
|
* Calculate the graphic shape (a polygon) associated to the text.
|
|
|
|
*
|
2012-03-26 23:47:08 +00:00
|
|
|
* @param aPoints A buffer to fill with polygon corners coordinates
|
|
|
|
* @param Pos Position of the shape, for texts and labels: do nothing
|
2010-09-11 16:33:43 +00:00
|
|
|
*/
|
2020-12-20 18:18:54 +00:00
|
|
|
virtual void CreateGraphicShape( const RENDER_SETTINGS* aSettings,
|
2021-03-06 09:27:41 +00:00
|
|
|
std::vector<wxPoint>& aPoints, const wxPoint& Pos ) const
|
2010-09-11 16:33:43 +00:00
|
|
|
{
|
2011-06-17 13:24:22 +00:00
|
|
|
aPoints.clear();
|
2010-09-11 16:33:43 +00:00
|
|
|
}
|
2008-02-21 20:49:15 +00:00
|
|
|
|
2019-04-29 21:17:26 +00:00
|
|
|
void SwapData( SCH_ITEM* aItem ) override;
|
2009-01-31 18:08:47 +00:00
|
|
|
|
2019-04-29 21:17:26 +00:00
|
|
|
const EDA_RECT GetBoundingBox() const override;
|
2008-04-15 19:38:19 +00:00
|
|
|
|
2020-01-28 15:42:42 +00:00
|
|
|
bool operator<( const SCH_ITEM& aItem ) const override;
|
|
|
|
|
2020-12-20 18:18:54 +00:00
|
|
|
int GetTextOffset( const RENDER_SETTINGS* aSettings = nullptr ) const;
|
2020-04-14 12:25:00 +00:00
|
|
|
|
2021-07-25 11:42:19 +00:00
|
|
|
int GetLabelBoxExpansion( const RENDER_SETTINGS* aSettings = nullptr ) const;
|
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
int GetPenWidth() const override;
|
2009-06-30 17:57:27 +00:00
|
|
|
|
2009-07-27 14:32:40 +00:00
|
|
|
// Geometric transforms (used in block operations):
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2019-04-29 21:17:26 +00:00
|
|
|
void Move( const wxPoint& aMoveVector ) override
|
2009-07-27 14:32:40 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
EDA_TEXT::Offset( aMoveVector );
|
2009-07-27 14:32:40 +00:00
|
|
|
}
|
|
|
|
|
2021-02-16 20:45:25 +00:00
|
|
|
void MirrorHorizontally( int aCenter ) override;
|
|
|
|
void MirrorVertically( int aCenter ) override;
|
2021-06-08 14:09:24 +00:00
|
|
|
void Rotate( const wxPoint& aCenter ) override;
|
2010-12-21 15:13:09 +00: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
|
|
|
|
2020-12-20 18:27:51 +00:00
|
|
|
bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override
|
2019-08-02 00:10:25 +00:00
|
|
|
{
|
|
|
|
return SCH_ITEM::Matches( GetText(), aSearchData );
|
|
|
|
}
|
2009-06-30 17:57:27 +00:00
|
|
|
|
2020-12-20 18:27:51 +00:00
|
|
|
bool Replace( const wxFindReplaceData& aSearchData, void* aAuxData ) override
|
2011-12-13 15:37:33 +00:00
|
|
|
{
|
2019-08-02 00:10:25 +00:00
|
|
|
return EDA_TEXT::Replace( aSearchData );
|
2011-12-13 15:37:33 +00:00
|
|
|
}
|
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
virtual bool IsReplaceable() const override { return true; }
|
2011-12-13 15:37:33 +00:00
|
|
|
|
2019-04-29 21:17:26 +00:00
|
|
|
void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2020-01-17 02:33:16 +00:00
|
|
|
bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
|
|
|
|
const SCH_SHEET_PATH* aPath = nullptr ) override;
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2019-04-29 21:17:26 +00:00
|
|
|
bool IsDangling() const override { return m_isDangling; }
|
|
|
|
void SetIsDangling( bool aIsDangling ) { m_isDangling = aIsDangling; }
|
2011-02-05 02:21:11 +00:00
|
|
|
|
2020-09-08 13:27:13 +00:00
|
|
|
std::vector<wxPoint> GetConnectionPoints() const override;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2021-12-07 20:47:12 +00:00
|
|
|
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
|
2011-10-12 14:03:43 +00:00
|
|
|
|
2021-03-08 02:59:07 +00:00
|
|
|
BITMAPS GetMenuImage() const override;
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2020-05-27 14:01:07 +00:00
|
|
|
wxPoint GetPosition() const override { return EDA_TEXT::GetTextPos(); }
|
2019-04-29 21:17:26 +00:00
|
|
|
void SetPosition( const wxPoint& aPosition ) override { EDA_TEXT::SetTextPos( aPosition ); }
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2019-05-05 10:33:34 +00:00
|
|
|
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
|
|
|
|
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
void Plot( PLOTTER* aPlotter ) const override;
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2019-04-29 21:17:26 +00:00
|
|
|
EDA_ITEM* Clone() const override;
|
2012-03-17 14:39:27 +00:00
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
2012-11-20 11:35:09 +00:00
|
|
|
|
2008-04-22 16:38:23 +00:00
|
|
|
#if defined(DEBUG)
|
2016-09-25 17:06:49 +00:00
|
|
|
void Show( int nestLevel, std::ostream& os ) const override;
|
2008-04-22 16:38:23 +00:00
|
|
|
#endif
|
2020-05-09 20:27:06 +00:00
|
|
|
|
2020-09-05 16:00:29 +00:00
|
|
|
static HTML_MESSAGE_BOX* ShowSyntaxHelp( wxWindow* aParentWindow );
|
2021-03-25 21:13:01 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
PINSHEETLABEL_SHAPE m_shape;
|
|
|
|
|
|
|
|
/// True if not connected to another object if the object derive from SCH_TEXT
|
|
|
|
/// supports connections.
|
|
|
|
bool m_isDangling;
|
|
|
|
|
|
|
|
CONNECTION_TYPE m_connectionType;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The orientation of text and any associated drawing elements of derived objects.
|
|
|
|
* - 0 is the horizontal and left justified.
|
|
|
|
* - 1 is vertical and top justified.
|
|
|
|
* - 2 is horizontal and right justified. It is the equivalent of the mirrored 0 orientation.
|
|
|
|
* - 3 is vertical and bottom justified. It is the equivalent of the mirrored 1 orientation.
|
|
|
|
*
|
|
|
|
* This is a duplication of m_Orient, m_HJustified, and m_VJustified in #EDA_TEXT but is
|
|
|
|
* easier to handle than 3 parameters when editing and reading and saving files.
|
|
|
|
*/
|
|
|
|
LABEL_SPIN_STYLE m_spin_style;
|
2008-02-21 20:49:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
class SCH_LABEL : public SCH_TEXT
|
2008-02-21 20:49:15 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-04-18 20:04:41 +00:00
|
|
|
SCH_LABEL( const wxPoint& aPos = wxPoint( 0, 0 ), const wxString& aText = wxEmptyString );
|
2010-12-21 15:13:09 +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
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
~SCH_LABEL() { }
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2019-08-29 14:59:36 +00:00
|
|
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
|
|
|
{
|
|
|
|
return aItem && SCH_LABEL_T == aItem->Type();
|
|
|
|
}
|
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
wxString GetClass() const override
|
2008-02-21 20:49:15 +00:00
|
|
|
{
|
2008-03-27 17:05:59 +00:00
|
|
|
return wxT( "SCH_LABEL" );
|
2008-02-21 20:49:15 +00:00
|
|
|
}
|
2008-04-15 19:38:19 +00:00
|
|
|
|
2019-06-25 23:39:58 +00:00
|
|
|
bool IsType( const KICAD_T aScanTypes[] ) const override;
|
2019-06-30 22:06:34 +00:00
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
const EDA_RECT GetBoundingBox() const override;
|
2009-11-28 09:24:37 +00:00
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
bool IsConnectable() const override { return true; }
|
2011-01-07 19:24:24 +00:00
|
|
|
|
2017-12-19 17:45:56 +00:00
|
|
|
bool CanConnect( const SCH_ITEM* aItem ) const override
|
|
|
|
{
|
2022-06-12 17:15:38 +00:00
|
|
|
switch( aItem->Type() )
|
|
|
|
{
|
|
|
|
case SCH_LINE_T:
|
|
|
|
return aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS;
|
|
|
|
|
|
|
|
case SCH_BUS_WIRE_ENTRY_T:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case SCH_SYMBOL_T:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIER_LABEL_T:
|
|
|
|
case SCH_SHEET_PIN_T:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
2017-12-19 17:45:56 +00:00
|
|
|
}
|
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2021-03-08 02:59:07 +00:00
|
|
|
BITMAPS GetMenuImage() const override;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
bool IsReplaceable() const override { return true; }
|
2011-12-01 16:49:28 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
EDA_ITEM* Clone() const override;
|
2012-03-17 14:39:27 +00:00
|
|
|
|
2021-03-25 21:13:01 +00:00
|
|
|
bool IsPointClickableAnchor( const wxPoint& aPos ) const override
|
|
|
|
{
|
|
|
|
return m_isDangling && GetPosition() == aPos;
|
|
|
|
}
|
2020-10-01 23:53:47 +00:00
|
|
|
|
2010-12-13 15:59:00 +00:00
|
|
|
private:
|
2021-03-25 21:13:01 +00:00
|
|
|
bool doIsConnected( const wxPoint& aPosition ) const override
|
|
|
|
{
|
|
|
|
return EDA_TEXT::GetTextPos() == aPosition;
|
|
|
|
}
|
2008-02-21 20:49:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
class SCH_GLOBALLABEL : public SCH_TEXT
|
2008-02-21 20:49:15 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-04-18 20:04:41 +00:00
|
|
|
SCH_GLOBALLABEL( const wxPoint& aPos = wxPoint( 0, 0 ), const wxString& aText = wxEmptyString );
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2020-11-17 16:02:47 +00:00
|
|
|
SCH_GLOBALLABEL( const SCH_GLOBALLABEL& aGlobalLabel );
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
~SCH_GLOBALLABEL() { }
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2019-08-29 14:59:36 +00:00
|
|
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
|
|
|
{
|
|
|
|
return aItem && SCH_GLOBAL_LABEL_T == aItem->Type();
|
|
|
|
}
|
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
wxString GetClass() const override
|
2008-02-21 20:49:15 +00:00
|
|
|
{
|
2008-03-27 17:05:59 +00:00
|
|
|
return wxT( "SCH_GLOBALLABEL" );
|
2008-02-21 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
2020-11-16 13:15:54 +00:00
|
|
|
EDA_ITEM* Clone() const override;
|
|
|
|
|
2020-11-17 16:02:47 +00:00
|
|
|
void SwapData( SCH_ITEM* aItem ) override;
|
|
|
|
|
|
|
|
SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
|
|
|
|
|
|
|
|
void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction ) override;
|
|
|
|
|
2021-06-08 14:09:24 +00:00
|
|
|
void Rotate( const wxPoint& aCenter ) override;
|
2020-11-18 21:40:04 +00:00
|
|
|
void Rotate90( bool aClockwise ) override;
|
2020-11-18 23:34:03 +00:00
|
|
|
void MirrorSpinStyle( bool aLeftRight ) override;
|
2020-11-18 21:40:04 +00:00
|
|
|
|
2021-02-16 20:45:25 +00:00
|
|
|
void MirrorHorizontally( int aCenter ) override;
|
|
|
|
void MirrorVertically( int aCenter ) override;
|
2021-02-03 19:54:09 +00:00
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
void SetLabelSpinStyle( LABEL_SPIN_STYLE aSpinStyle ) override;
|
2009-05-12 12:12:34 +00:00
|
|
|
|
2020-12-20 18:18:54 +00:00
|
|
|
wxPoint GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
|
2009-05-12 12:12:34 +00:00
|
|
|
|
2021-03-10 16:56:09 +00:00
|
|
|
/**
|
2021-03-25 21:13:01 +00:00
|
|
|
* Return the bounding box on the global label only, without taking in account
|
|
|
|
* the intersheet references.
|
2021-03-10 16:56:09 +00:00
|
|
|
*/
|
|
|
|
const EDA_RECT GetBoundingBoxBase() const;
|
|
|
|
|
|
|
|
/**
|
2021-03-25 21:13:01 +00:00
|
|
|
* Return the bounding box on the global label only, including the intersheet references.
|
2021-03-10 16:56:09 +00:00
|
|
|
*/
|
2016-09-25 17:06:49 +00:00
|
|
|
const EDA_RECT GetBoundingBox() const override;
|
2009-05-05 17:32:07 +00:00
|
|
|
|
2021-09-14 02:54:12 +00:00
|
|
|
/**
|
|
|
|
* Override basic hit test to allow testing separately for label and intersheet refs
|
|
|
|
* which can move independently
|
|
|
|
* @return True if hit in either label or associated intersheet ref
|
|
|
|
*/
|
|
|
|
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
|
|
|
|
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
|
|
|
|
2020-12-20 18:18:54 +00:00
|
|
|
void CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings,
|
2021-03-06 09:27:41 +00:00
|
|
|
std::vector<wxPoint>& aPoints, const wxPoint& aPos ) const override;
|
2009-07-27 14:32:40 +00:00
|
|
|
|
2020-11-17 16:02:47 +00:00
|
|
|
void UpdateIntersheetRefProps();
|
|
|
|
void AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) override;
|
|
|
|
|
|
|
|
bool ResolveTextVar( wxString* token, int aDepth ) const;
|
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
bool IsConnectable() const override { return true; }
|
2011-01-07 19:24:24 +00:00
|
|
|
|
2017-12-19 17:45:56 +00:00
|
|
|
bool CanConnect( const SCH_ITEM* aItem ) const override
|
|
|
|
{
|
2022-06-12 17:15:38 +00:00
|
|
|
switch( aItem->Type() )
|
|
|
|
{
|
|
|
|
case SCH_LINE_T:
|
|
|
|
return aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS;
|
|
|
|
|
|
|
|
case SCH_BUS_WIRE_ENTRY_T:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case SCH_SYMBOL_T:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIER_LABEL_T:
|
|
|
|
case SCH_SHEET_PIN_T:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
2017-12-19 17:45:56 +00:00
|
|
|
}
|
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2021-03-08 02:59:07 +00:00
|
|
|
BITMAPS GetMenuImage() const override;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2020-12-20 18:18:54 +00:00
|
|
|
void Print( const RENDER_SETTINGS* aSettings, const wxPoint& offset ) override;
|
2012-03-17 14:39:27 +00:00
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
void Plot( PLOTTER* aPlotter ) const override;
|
2020-11-23 13:29:40 +00:00
|
|
|
|
2020-11-17 16:02:47 +00:00
|
|
|
SCH_FIELD* GetIntersheetRefs() { return &m_intersheetRefsField; }
|
|
|
|
void SetIntersheetRefs( const SCH_FIELD& aField ) { m_intersheetRefsField = aField; }
|
2020-08-31 14:11:54 +00:00
|
|
|
|
2020-11-15 17:03:27 +00:00
|
|
|
bool IsPointClickableAnchor( const wxPoint& aPos ) const override
|
|
|
|
{
|
|
|
|
return m_isDangling && GetPosition() == aPos;
|
|
|
|
}
|
2020-10-01 23:53:47 +00:00
|
|
|
|
2020-11-17 16:02:47 +00:00
|
|
|
void Move( const wxPoint& aMoveVector ) override
|
|
|
|
{
|
|
|
|
SCH_TEXT::Move( aMoveVector );
|
|
|
|
m_intersheetRefsField.Move( aMoveVector );
|
|
|
|
}
|
|
|
|
|
2010-12-13 15:59:00 +00:00
|
|
|
private:
|
2020-11-15 17:03:27 +00:00
|
|
|
bool doIsConnected( const wxPoint& aPosition ) const override
|
|
|
|
{
|
|
|
|
return EDA_TEXT::GetTextPos() == aPosition;
|
|
|
|
}
|
|
|
|
|
2020-11-17 16:02:47 +00:00
|
|
|
SCH_FIELD m_intersheetRefsField;
|
2008-02-21 20:49:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
class SCH_HIERLABEL : public SCH_TEXT
|
2008-02-21 20:49:15 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-04-14 12:25:00 +00:00
|
|
|
SCH_HIERLABEL( const wxPoint& aPos = wxPoint( 0, 0 ), const wxString& aText = wxEmptyString,
|
2020-04-18 20:04:41 +00:00
|
|
|
KICAD_T aType = SCH_HIER_LABEL_T );
|
2010-12-10 19:47:44 +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
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
~SCH_HIERLABEL() { }
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2020-12-20 18:18:54 +00:00
|
|
|
void Print( const RENDER_SETTINGS* aSettings, const wxPoint& offset ) override;
|
2008-02-21 20:49:15 +00:00
|
|
|
|
2019-08-29 14:59:36 +00:00
|
|
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
|
|
|
{
|
|
|
|
return aItem && SCH_HIER_LABEL_T == aItem->Type();
|
|
|
|
}
|
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
wxString GetClass() const override
|
2008-02-21 20:49:15 +00:00
|
|
|
{
|
2008-03-27 17:05:59 +00:00
|
|
|
return wxT( "SCH_HIERLABEL" );
|
2008-02-21 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
void SetLabelSpinStyle( LABEL_SPIN_STYLE aSpinStyle ) override;
|
2009-05-12 12:12:34 +00:00
|
|
|
|
2020-12-20 18:18:54 +00:00
|
|
|
wxPoint GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
|
2009-05-12 12:12:34 +00:00
|
|
|
|
2020-12-20 18:18:54 +00:00
|
|
|
void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector<wxPoint>& aPoints,
|
2021-03-06 09:27:41 +00:00
|
|
|
const wxPoint& aPos ) const override;
|
|
|
|
void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector<wxPoint>& aPoints,
|
|
|
|
const wxPoint& aPos, PINSHEETLABEL_SHAPE aShape ) const;
|
2008-03-30 09:27:53 +00:00
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
const EDA_RECT GetBoundingBox() const override;
|
2009-01-31 18:08:47 +00:00
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
bool IsConnectable() const override { return true; }
|
2011-01-07 19:24:24 +00:00
|
|
|
|
2017-12-19 17:45:56 +00:00
|
|
|
bool CanConnect( const SCH_ITEM* aItem ) const override
|
|
|
|
{
|
2022-06-12 17:15:38 +00:00
|
|
|
switch( aItem->Type() )
|
|
|
|
{
|
|
|
|
case SCH_LINE_T:
|
|
|
|
return aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS;
|
|
|
|
|
|
|
|
case SCH_BUS_WIRE_ENTRY_T:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case SCH_SYMBOL_T:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIER_LABEL_T:
|
|
|
|
case SCH_SHEET_PIN_T:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
2017-12-19 17:45:56 +00:00
|
|
|
}
|
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2021-03-08 02:59:07 +00:00
|
|
|
BITMAPS GetMenuImage() const override;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
EDA_ITEM* Clone() const override;
|
2012-03-17 14:39:27 +00:00
|
|
|
|
2021-03-25 21:13:01 +00:00
|
|
|
bool IsPointClickableAnchor( const wxPoint& aPos ) const override
|
|
|
|
{
|
|
|
|
return m_isDangling && GetPosition() == aPos;
|
|
|
|
}
|
2020-10-01 23:53:47 +00:00
|
|
|
|
2010-12-13 15:59:00 +00:00
|
|
|
private:
|
2021-03-25 21:13:01 +00:00
|
|
|
bool doIsConnected( const wxPoint& aPosition ) const override
|
|
|
|
{
|
|
|
|
return EDA_TEXT::GetTextPos() == aPosition;
|
|
|
|
}
|
2008-02-21 20:49:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* CLASS_TEXT_LABEL_H */
|