2021-04-06 21:15:49 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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_SHEEET_PIN_H
|
|
|
|
#define SCH_SHEEET_PIN_H
|
2021-04-06 21:15:49 +00:00
|
|
|
|
2022-01-24 13:40:39 +00:00
|
|
|
#include <sch_label.h>
|
2021-04-06 21:15:49 +00:00
|
|
|
|
|
|
|
class KIID;
|
|
|
|
class LINE_READER;
|
|
|
|
class SCH_SHEET;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Define the edge of the sheet that the sheet pin is positioned.
|
|
|
|
*
|
|
|
|
* SHEET_LEFT_SIDE = 0: pin on left side
|
|
|
|
* SHEET_RIGHT_SIDE = 1: pin on right side
|
|
|
|
* SHEET_TOP_SIDE = 2: pin on top side
|
|
|
|
* SHEET_BOTTOM_SIDE =3: pin on bottom side
|
|
|
|
*
|
|
|
|
* For compatibility reasons, this does not follow same values as text orientation.
|
|
|
|
*/
|
2021-05-31 01:20:43 +00:00
|
|
|
enum class SHEET_SIDE
|
2021-04-06 21:15:49 +00:00
|
|
|
{
|
2021-05-31 01:20:43 +00:00
|
|
|
LEFT = 0,
|
|
|
|
RIGHT,
|
|
|
|
TOP,
|
|
|
|
BOTTOM,
|
|
|
|
UNDEFINED
|
2021-04-06 21:15:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Define a sheet pin (label) used in sheets to create hierarchical schematics.
|
|
|
|
*
|
|
|
|
* A SCH_SHEET_PIN is used to create a hierarchical sheet in the same way a
|
|
|
|
* pin is used in a symbol. It connects the objects in the sheet object
|
|
|
|
* to the objects in the schematic page to the objects in the page that is
|
|
|
|
* represented by the sheet. In a sheet object, a SCH_SHEET_PIN must be
|
|
|
|
* connected to a wire, bus, or label. In the schematic page represented by
|
|
|
|
* the sheet, it corresponds to a hierarchical label.
|
|
|
|
*/
|
|
|
|
class SCH_SHEET_PIN : public SCH_HIERLABEL
|
|
|
|
{
|
|
|
|
public:
|
2022-01-01 06:04:08 +00:00
|
|
|
SCH_SHEET_PIN( SCH_SHEET* parent, const VECTOR2I& pos = VECTOR2I( 0, 0 ),
|
2021-04-06 21:15:49 +00:00
|
|
|
const wxString& text = wxEmptyString );
|
|
|
|
|
|
|
|
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
|
|
|
|
|
|
|
~SCH_SHEET_PIN() { }
|
|
|
|
|
|
|
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
|
|
|
{
|
|
|
|
return aItem && SCH_SHEET_PIN_T == aItem->Type();
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString GetClass() const override
|
|
|
|
{
|
|
|
|
return wxT( "SCH_SHEET_PIN" );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator ==( const SCH_SHEET_PIN* aPin ) const;
|
|
|
|
|
2021-11-28 01:16:40 +00:00
|
|
|
static SHEET_SIDE GetOppositeSide( SHEET_SIDE aSide )
|
|
|
|
{
|
|
|
|
switch( aSide )
|
|
|
|
{
|
|
|
|
case SHEET_SIDE::TOP: return SHEET_SIDE::BOTTOM;
|
|
|
|
case SHEET_SIDE::BOTTOM: return SHEET_SIDE::TOP;
|
|
|
|
case SHEET_SIDE::LEFT: return SHEET_SIDE::RIGHT;
|
|
|
|
case SHEET_SIDE::RIGHT: return SHEET_SIDE::LEFT;
|
|
|
|
default: return SHEET_SIDE::UNDEFINED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-06 21:15:49 +00:00
|
|
|
/**
|
|
|
|
* Return true for items which are moved with the anchor point at mouse cursor
|
|
|
|
* and false for items moved with no reference to anchor (usually large items).
|
|
|
|
*
|
|
|
|
* @return true for a hierarchical sheet pin.
|
|
|
|
*/
|
|
|
|
bool IsMovableFromAnchorPoint() const override { return true; }
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
|
2021-04-06 21:15:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculate the graphic shape (a polygon) associated to the text.
|
|
|
|
*
|
|
|
|
* @param aPoints is a buffer to fill with polygon corners coordinates.
|
|
|
|
* @param aPos is the position of the shape.
|
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector<VECTOR2I>& aPoints,
|
|
|
|
const VECTOR2I& aPos ) const override;
|
2021-04-06 21:15:49 +00:00
|
|
|
|
|
|
|
void SwapData( SCH_ITEM* aItem ) override;
|
|
|
|
|
|
|
|
int GetPenWidth() const override;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the sheet label number.
|
|
|
|
*
|
|
|
|
* @return Number of the sheet label.
|
|
|
|
*/
|
|
|
|
int GetNumber() const { return m_number; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the sheet label number.
|
|
|
|
*
|
|
|
|
* @param aNumber New sheet number label.
|
|
|
|
*/
|
|
|
|
void SetNumber( int aNumber );
|
|
|
|
|
2021-11-28 19:06:08 +00:00
|
|
|
void SetSide( SHEET_SIDE aEdge );
|
2021-04-06 21:15:49 +00:00
|
|
|
|
2021-11-28 19:06:08 +00:00
|
|
|
SHEET_SIDE GetSide() const;
|
2021-04-06 21:15:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adjust label position to edge based on proximity to vertical or horizontal edge
|
|
|
|
* of the parent sheet.
|
|
|
|
*/
|
2023-06-25 18:54:58 +00:00
|
|
|
void ConstrainOnEdge( VECTOR2I aPos, bool aAllowEdgeSwitch );
|
2021-04-06 21:15:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the parent sheet object of this sheet pin.
|
|
|
|
*
|
|
|
|
* @return The sheet that is the parent of this sheet pin or NULL if it does
|
|
|
|
* not have a parent.
|
|
|
|
*/
|
|
|
|
SCH_SHEET* GetParent() const { return (SCH_SHEET*) m_parent; }
|
|
|
|
|
|
|
|
#if defined(DEBUG)
|
|
|
|
void Show( int nestLevel, std::ostream& os ) const override;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Geometric transforms (used in block operations):
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void Move( const VECTOR2I& aMoveVector ) override
|
2021-04-06 21:15:49 +00:00
|
|
|
{
|
|
|
|
Offset( aMoveVector );
|
|
|
|
}
|
|
|
|
|
|
|
|
void MirrorVertically( int aCenter ) override;
|
|
|
|
void MirrorHorizontally( int aCenter ) override;
|
2022-01-01 06:04:08 +00:00
|
|
|
void Rotate( const VECTOR2I& aCenter ) override;
|
2021-04-06 21:15:49 +00:00
|
|
|
|
2022-08-05 02:40:38 +00:00
|
|
|
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
|
2021-04-06 21:15:49 +00:00
|
|
|
{
|
|
|
|
return SCH_ITEM::Matches( GetText(), aSearchData );
|
|
|
|
}
|
|
|
|
|
2022-08-05 02:40:38 +00:00
|
|
|
bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData = nullptr ) override
|
2021-04-06 21:15:49 +00:00
|
|
|
{
|
|
|
|
return EDA_TEXT::Replace( aSearchData );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsReplaceable() const override { return true; }
|
|
|
|
|
|
|
|
void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
|
|
|
|
|
|
|
|
bool IsConnectable() const override { return true; }
|
|
|
|
|
2023-01-12 03:27:44 +00:00
|
|
|
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
|
2021-04-06 21:15:49 +00:00
|
|
|
|
|
|
|
BITMAPS GetMenuImage() const override;
|
|
|
|
|
2023-06-25 18:54:58 +00:00
|
|
|
void SetPosition( const VECTOR2I& aPosition ) override
|
|
|
|
{
|
|
|
|
ConstrainOnEdge( aPosition, true );
|
|
|
|
}
|
2021-04-06 21:15:49 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
|
2021-04-06 21:15:49 +00:00
|
|
|
{
|
|
|
|
return m_isDangling && GetPosition() == aPos;
|
|
|
|
}
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
|
2021-04-06 21:15:49 +00:00
|
|
|
|
|
|
|
EDA_ITEM* Clone() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
int m_number; ///< Label number use for saving sheet label to file.
|
|
|
|
///< Sheet label numbering begins at 2.
|
|
|
|
///< 0 is reserved for the sheet name.
|
|
|
|
///< 1 is reserve for the sheet file name.
|
|
|
|
|
|
|
|
SHEET_SIDE m_edge;
|
|
|
|
};
|
|
|
|
|
2022-01-24 13:40:39 +00:00
|
|
|
#endif // SCH_SHEEET_PIN_H
|