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
|
2022-08-20 09:27:35 +00:00
|
|
|
* Copyright (C) 1992-2022 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
|
|
|
|
*/
|
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
#ifndef SCH_SHEEET_H
|
|
|
|
#define SCH_SHEEET_H
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2020-03-06 12:05:21 +00:00
|
|
|
#include <sch_field.h>
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2021-04-06 21:15:49 +00:00
|
|
|
class KIID_PATH;
|
2010-11-10 15:30:12 +00:00
|
|
|
class SCH_SCREEN;
|
2022-12-25 16:04:45 +00:00
|
|
|
class SCH_SEXPR_PARSER;
|
|
|
|
class SCH_SHEET_LIST;
|
2010-11-10 15:30:12 +00:00
|
|
|
class SCH_SHEET_PIN;
|
|
|
|
class SCH_SHEET_PATH;
|
2021-04-06 21:15:49 +00:00
|
|
|
class EDA_DRAW_FRAME;
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2020-01-22 14:48:34 +00:00
|
|
|
#define MIN_SHEET_WIDTH 500 // Units are mils.
|
|
|
|
#define MIN_SHEET_HEIGHT 150 // Units are mils.
|
2011-06-07 15:29:01 +00:00
|
|
|
|
|
|
|
|
2021-04-06 21:15:49 +00:00
|
|
|
enum SHEET_FIELD_TYPE
|
2019-05-17 16:45:27 +00:00
|
|
|
{
|
2020-03-06 12:05:21 +00:00
|
|
|
SHEETNAME = 0,
|
|
|
|
SHEETFILENAME,
|
|
|
|
|
|
|
|
/// The first 2 are mandatory, and must be instantiated in SCH_SHEET
|
|
|
|
SHEET_MANDATORY_FIELDS
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
/**
|
2017-11-18 13:10:32 +00:00
|
|
|
* Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
|
2008-04-12 18:39:20 +00:00
|
|
|
*/
|
2009-11-04 20:46:53 +00:00
|
|
|
class SCH_SHEET : public SCH_ITEM
|
2008-04-12 18:39:20 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
public:
|
2022-01-01 06:04:08 +00:00
|
|
|
SCH_SHEET( EDA_ITEM* aParent = nullptr, const VECTOR2I& aPos = VECTOR2I( 0, 0 ),
|
2022-09-26 20:31:26 +00:00
|
|
|
wxSize aSize = wxSize( schIUScale.MilsToIU( MIN_SHEET_WIDTH ),
|
|
|
|
schIUScale.MilsToIU( MIN_SHEET_HEIGHT ) ),
|
2021-11-28 17:32:53 +00:00
|
|
|
FIELDS_AUTOPLACED aAutoplaceFields = FIELDS_AUTOPLACED_AUTO );
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2012-01-09 20:26:55 +00:00
|
|
|
/**
|
2017-11-18 13:10:32 +00:00
|
|
|
* Copy \a aSheet into a new object. All sheet pins are copied as is except and
|
2012-01-09 20:26:55 +00:00
|
|
|
* the SCH_SHEET_PIN's #m_Parent pointers are set to the new copied parent object.
|
|
|
|
*/
|
2010-12-21 15:13:09 +00:00
|
|
|
SCH_SHEET( const SCH_SHEET& aSheet );
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
~SCH_SHEET();
|
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_SHEET_T == aItem->Type();
|
|
|
|
}
|
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
wxString GetClass() const override
|
2008-04-12 18:39:20 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
return wxT( "SCH_SHEET" );
|
2008-04-12 18:39:20 +00:00
|
|
|
}
|
|
|
|
|
2015-02-28 16:56:09 +00:00
|
|
|
/**
|
|
|
|
* Return true for items which are moved with the anchor point at mouse cursor
|
2017-11-18 13:10:32 +00:00
|
|
|
* and false for items moved with no reference to anchor.
|
|
|
|
*
|
2015-02-28 16:56:09 +00:00
|
|
|
* Usually return true for small items (labels, junctions) and false for
|
2021-03-25 21:13:01 +00:00
|
|
|
* items which can be large (hierarchical sheets, symbols).
|
2017-11-18 13:10:32 +00:00
|
|
|
*
|
2021-03-25 21:13:01 +00:00
|
|
|
* @return false for a hierarchical sheet.
|
2015-02-28 16:56:09 +00:00
|
|
|
*/
|
2020-12-20 18:44:13 +00:00
|
|
|
bool IsMovableFromAnchorPoint() const override { return false; }
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2020-03-06 12:05:21 +00:00
|
|
|
std::vector<SCH_FIELD>& GetFields() { return m_fields; }
|
2020-12-20 18:44:13 +00:00
|
|
|
const std::vector<SCH_FIELD>& GetFields() const { return m_fields; }
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2020-03-06 20:02:58 +00:00
|
|
|
/**
|
|
|
|
* Set multiple schematic fields.
|
|
|
|
*
|
|
|
|
* @param aFields are the fields to set in this symbol.
|
|
|
|
*/
|
2022-03-02 01:19:58 +00:00
|
|
|
void SetFields( const std::vector<SCH_FIELD>& aFields );
|
2020-03-06 20:02:58 +00:00
|
|
|
|
2023-05-05 13:21:56 +00:00
|
|
|
wxString GetShownName( bool aAllowExtraText ) const
|
|
|
|
{
|
|
|
|
return m_fields[SHEETNAME].GetShownText( aAllowExtraText );
|
|
|
|
}
|
2020-03-06 12:05:21 +00:00
|
|
|
wxString GetName() const { return m_fields[ SHEETNAME ].GetText(); }
|
2022-11-26 00:10:27 +00:00
|
|
|
void SetName( const wxString& aName ) { m_fields[ SHEETNAME ].SetText( aName ); }
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
SCH_SCREEN* GetScreen() const { return m_screen; }
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2020-12-20 18:44:13 +00:00
|
|
|
wxSize GetSize() const { return m_size; }
|
2011-12-08 15:45:01 +00:00
|
|
|
void SetSize( const wxSize& aSize ) { m_size = aSize; }
|
2011-01-20 16:34:57 +00:00
|
|
|
|
2020-03-08 02:18:45 +00:00
|
|
|
int GetBorderWidth() const { return m_borderWidth; }
|
|
|
|
void SetBorderWidth( int aWidth ) { m_borderWidth = aWidth; }
|
|
|
|
|
|
|
|
KIGFX::COLOR4D GetBorderColor() const { return m_borderColor; }
|
|
|
|
void SetBorderColor( KIGFX::COLOR4D aColor ) { m_borderColor = aColor; }
|
|
|
|
|
|
|
|
KIGFX::COLOR4D GetBackgroundColor() const { return m_backgroundColor; }
|
|
|
|
void SetBackgroundColor( KIGFX::COLOR4D aColor ) { m_backgroundColor = aColor; }
|
|
|
|
|
2020-04-26 20:53:29 +00:00
|
|
|
/**
|
|
|
|
* @return true if this sheet is the root sheet.
|
|
|
|
*/
|
2020-05-13 02:00:37 +00:00
|
|
|
bool IsRootSheet() const;
|
2020-04-26 20:53:29 +00:00
|
|
|
|
2011-01-20 16:34:57 +00:00
|
|
|
/**
|
2017-11-18 13:10:32 +00:00
|
|
|
* Set the #SCH_SCREEN associated with this sheet to \a aScreen.
|
|
|
|
*
|
2011-01-20 16:34:57 +00:00
|
|
|
* The screen reference counting is performed by SetScreen. If \a aScreen is not
|
|
|
|
* the same as the current screen, the current screen reference count is decremented
|
|
|
|
* and \a aScreen becomes the screen for the sheet. If the current screen reference
|
|
|
|
* count reaches zero, the current screen is deleted. NULL is a valid value for
|
|
|
|
* \a aScreen.
|
2017-11-18 13:10:32 +00:00
|
|
|
*
|
2011-01-20 16:34:57 +00:00
|
|
|
* @param aScreen The new screen to associate with the sheet.
|
|
|
|
*/
|
|
|
|
void SetScreen( SCH_SCREEN* aScreen );
|
|
|
|
|
|
|
|
/**
|
2017-11-18 13:10:32 +00:00
|
|
|
* Return the number of times the associated screen for the sheet is being used.
|
|
|
|
*
|
|
|
|
* If no screen is associated with the sheet, then zero is returned.
|
2011-01-20 16:34:57 +00:00
|
|
|
*/
|
|
|
|
int GetScreenCount() const;
|
|
|
|
|
2020-05-27 22:28:36 +00:00
|
|
|
/**
|
|
|
|
* Return the list of system text vars & fields for this sheet.
|
|
|
|
*/
|
|
|
|
void GetContextualTextVars( wxArrayString* aVars ) const;
|
|
|
|
|
2020-04-06 13:06:57 +00:00
|
|
|
/**
|
|
|
|
* Resolve any references to system tokens supported by the sheet.
|
2021-03-25 21:13:01 +00:00
|
|
|
*
|
|
|
|
* @param aDepth is a counter to limit recursion and circular references.
|
2020-04-06 13:06:57 +00:00
|
|
|
*/
|
2023-04-27 11:56:15 +00:00
|
|
|
bool ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth = 0 ) const;
|
|
|
|
bool ResolveTextVar( wxString* token, int aDepth = 0 )
|
|
|
|
{
|
|
|
|
return ResolveTextVar( nullptr, token, aDepth );
|
|
|
|
}
|
2020-04-06 13:06:57 +00:00
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
2010-09-05 17:01:48 +00:00
|
|
|
|
|
|
|
/* there is no member for orientation in sch_sheet, to preserve file
|
|
|
|
* format, we detect orientation based on pin edges
|
|
|
|
*/
|
2011-06-17 13:24:22 +00:00
|
|
|
bool IsVerticalOrientation() const;
|
2008-04-30 17:04:22 +00:00
|
|
|
|
2010-06-24 18:31:43 +00:00
|
|
|
/**
|
2011-03-30 19:26:05 +00:00
|
|
|
* Add aSheetPin to the sheet.
|
2010-06-24 18:31:43 +00:00
|
|
|
*
|
2021-03-25 21:13:01 +00:00
|
|
|
* @note Once a sheet pin is added to the sheet, it is owned by the sheet.
|
2011-03-30 19:26:05 +00:00
|
|
|
* Do not delete the sheet pin object or you will likely get a segfault
|
|
|
|
* when the sheet is destroyed.
|
2010-06-24 18:31:43 +00:00
|
|
|
*
|
2011-03-30 19:26:05 +00:00
|
|
|
* @param aSheetPin The sheet pin item to add to the sheet.
|
2010-06-24 18:31:43 +00:00
|
|
|
*/
|
2011-03-30 19:26:05 +00:00
|
|
|
void AddPin( SCH_SHEET_PIN* aSheetPin );
|
2010-06-24 18:31:43 +00:00
|
|
|
|
2020-01-12 18:40:50 +00:00
|
|
|
std::vector<SCH_SHEET_PIN*>& GetPins() { return m_pins; }
|
2022-09-26 20:31:26 +00:00
|
|
|
const std::vector<SCH_SHEET_PIN*>& GetPins() const { return m_pins; }
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2010-06-24 18:31:43 +00:00
|
|
|
/**
|
2011-03-30 19:26:05 +00:00
|
|
|
* Remove \a aSheetPin from the sheet.
|
2010-06-24 18:31:43 +00:00
|
|
|
*
|
2011-03-30 19:26:05 +00:00
|
|
|
* @param aSheetPin The sheet pin item to remove from the sheet.
|
2010-06-24 18:31:43 +00:00
|
|
|
*/
|
2020-12-20 18:44:13 +00:00
|
|
|
void RemovePin( const SCH_SHEET_PIN* aSheetPin );
|
2010-06-24 18:31:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete sheet label which do not have a corresponding hierarchical label.
|
|
|
|
*
|
2021-03-25 21:13:01 +00:00
|
|
|
* @note Make sure you save a copy of the sheet in the undo list before calling
|
2011-03-30 19:26:05 +00:00
|
|
|
* CleanupSheet() otherwise any unreferenced sheet labels will be lost.
|
2010-06-24 18:31:43 +00:00
|
|
|
*/
|
2010-12-10 19:47:44 +00:00
|
|
|
void CleanupSheet();
|
2010-06-24 18:31:43 +00:00
|
|
|
|
|
|
|
/**
|
2011-03-30 19:26:05 +00:00
|
|
|
* Return the sheet pin item found at \a aPosition in the sheet.
|
2010-06-24 18:31:43 +00:00
|
|
|
*
|
2011-03-30 19:26:05 +00:00
|
|
|
* @param aPosition The position to check for a sheet pin.
|
2010-06-24 18:31:43 +00:00
|
|
|
*
|
2011-03-30 19:26:05 +00:00
|
|
|
* @return The sheet pin found at \a aPosition or NULL if no sheet pin is found.
|
2010-06-24 18:31:43 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
SCH_SHEET_PIN* GetPin( const VECTOR2I& aPosition );
|
2010-06-24 18:31:43 +00:00
|
|
|
|
|
|
|
/**
|
2011-03-30 19:26:05 +00:00
|
|
|
* Checks if the sheet already has a sheet pin named \a aName.
|
2010-06-24 18:31:43 +00:00
|
|
|
*
|
2011-03-30 19:26:05 +00:00
|
|
|
* @param aName Name of the sheet pin to search for.
|
|
|
|
* @return True if sheet pin with \a aName is found, otherwise false.
|
2008-04-21 06:34:56 +00:00
|
|
|
*/
|
2020-12-20 18:44:13 +00:00
|
|
|
bool HasPin( const wxString& aName ) const;
|
2010-06-24 18:31:43 +00:00
|
|
|
|
2020-12-20 18:44:13 +00:00
|
|
|
bool HasPins() const { return !m_pins.empty(); }
|
2010-06-24 18:31:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check all sheet labels against schematic for undefined hierarchical labels.
|
|
|
|
*
|
|
|
|
* @return True if there are any undefined labels.
|
|
|
|
*/
|
2020-12-20 18:44:13 +00:00
|
|
|
bool HasUndefinedPins() const;
|
2008-04-21 06:34:56 +00:00
|
|
|
|
2011-06-07 15:29:01 +00:00
|
|
|
/**
|
2017-11-18 13:10:32 +00:00
|
|
|
* Return the minimum width of the sheet based on the widths of the sheet pin text.
|
2011-06-07 15:29:01 +00:00
|
|
|
*
|
|
|
|
* The minimum sheet width is determined by the width of the bounding box of each
|
|
|
|
* hierarchical sheet pin. If two pins are horizontally adjacent ( same Y position )
|
|
|
|
* to each other, the sum of the bounding box widths is used. If at some point in
|
|
|
|
* the future sheet objects can be rotated or pins can be placed in the vertical
|
|
|
|
* orientation, this function will need to be changed.
|
|
|
|
*
|
|
|
|
* @return The minimum width the sheet can be resized.
|
|
|
|
*/
|
2023-01-26 19:56:37 +00:00
|
|
|
int GetMinWidth( bool aFromLeft ) const;
|
2011-06-07 15:29:01 +00:00
|
|
|
|
|
|
|
/**
|
2017-11-18 13:10:32 +00:00
|
|
|
* Return the minimum height that the sheet can be resized based on the sheet pin positions.
|
2011-06-07 15:29:01 +00:00
|
|
|
*
|
|
|
|
* The minimum width of a sheet is determined by the Y axis location of the bottom
|
|
|
|
* most sheet pin. If at some point in the future sheet objects can be rotated or
|
|
|
|
* pins can be placed in the vertical orientation, this function will need to be
|
|
|
|
* changed.
|
|
|
|
*
|
|
|
|
* @return The minimum height the sheet can be resized.
|
|
|
|
*/
|
2023-01-26 19:56:37 +00:00
|
|
|
int GetMinHeight( bool aFromTop ) const;
|
2011-06-07 15:29:01 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
int GetPenWidth() const override;
|
2009-06-30 19:21:41 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
|
2009-01-31 18:08:47 +00:00
|
|
|
|
2020-03-06 20:02:58 +00:00
|
|
|
/**
|
|
|
|
* Return a bounding box for the sheet body but not the fields.
|
|
|
|
*/
|
2022-08-30 23:28:18 +00:00
|
|
|
const BOX2I GetBodyBoundingBox() const;
|
2020-03-06 20:02:58 +00:00
|
|
|
|
2022-08-31 09:15:42 +00:00
|
|
|
const BOX2I GetBoundingBox() const override;
|
2009-01-31 18:08:47 +00:00
|
|
|
|
2011-06-07 15:29:01 +00:00
|
|
|
/**
|
2019-09-02 21:34:50 +00:00
|
|
|
* Rotating around the boundingBox's center can cause walking when the sheetname or
|
|
|
|
* filename is longer than the edge it's on. Use this instead, which always returns
|
|
|
|
* the center of the sheet itself.
|
2011-06-07 15:29:01 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I GetRotationCenter() const;
|
2011-06-07 15:29:01 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void SwapData( SCH_ITEM* aItem ) override;
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2021-03-19 20:27:30 +00:00
|
|
|
* Count our own symbols, without the power symbols.
|
2009-01-04 18:52:57 +00:00
|
|
|
*/
|
2020-11-15 17:03:27 +00:00
|
|
|
int SymbolCount() const;
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2017-11-18 13:10:32 +00:00
|
|
|
* Search the existing hierarchy for an instance of screen loaded from \a aFileName.
|
|
|
|
*
|
2021-03-25 21:13:01 +00:00
|
|
|
* @param aFilename The filename to find (MUST be absolute, and in wxPATH_NATIVE encoding).
|
|
|
|
* @param aScreen A location to return a pointer to the screen (if found).
|
|
|
|
* @return true if found, and a pointer to the screen
|
2009-01-04 18:52:57 +00:00
|
|
|
*/
|
2011-01-20 16:34:57 +00:00
|
|
|
bool SearchHierarchy( const wxString& aFilename, SCH_SCREEN** aScreen );
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2016-02-15 20:24:59 +00:00
|
|
|
/**
|
2017-11-18 13:10:32 +00:00
|
|
|
* Search the existing hierarchy for an instance of screen loaded from \a aFileName.
|
|
|
|
*
|
|
|
|
* Don't bother looking at the root sheet, it must be unique. No other references to
|
|
|
|
* its m_screen otherwise there would be loops in the hierarchy.
|
2016-02-15 20:24:59 +00:00
|
|
|
*
|
2021-03-25 21:13:01 +00:00
|
|
|
* @param[in] aScreen The SCH_SCREEN* screen that we search for.
|
|
|
|
* @param[in] aList The SCH_SHEET_PATH* that must be used.
|
|
|
|
* @return true if found.
|
2016-02-15 20:24:59 +00:00
|
|
|
*/
|
|
|
|
bool LocatePathOfScreen( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aList );
|
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2020-04-26 20:53:29 +00:00
|
|
|
* Count the number of sheets found in "this" sheet including all of the subsheets.
|
2017-11-18 13:10:32 +00:00
|
|
|
*
|
2009-01-06 20:09:32 +00:00
|
|
|
* @return the full count of sheets+subsheets contained by "this"
|
|
|
|
*/
|
2020-05-13 02:00:37 +00:00
|
|
|
int CountSheets() const;
|
2009-01-06 20:09:32 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2017-11-18 13:10:32 +00:00
|
|
|
* Return the filename corresponding to this sheet.
|
|
|
|
*
|
2009-01-06 20:09:32 +00:00
|
|
|
* @return a wxString containing the filename
|
|
|
|
*/
|
2020-03-06 12:05:21 +00:00
|
|
|
wxString GetFileName() const
|
|
|
|
{
|
|
|
|
return m_fields[ SHEETFILENAME ].GetText();
|
|
|
|
}
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
// Set a new filename without changing anything else
|
2021-07-27 12:22:27 +00:00
|
|
|
void SetFileName( const wxString& aFilename )
|
2008-04-12 18:39:20 +00:00
|
|
|
{
|
2012-10-13 18:54:33 +00:00
|
|
|
// Filenames are stored using unix notation
|
2021-07-27 12:22:27 +00:00
|
|
|
wxString tmp = aFilename;
|
|
|
|
tmp.Replace( wxT( "\\" ), wxT( "/" ) );
|
|
|
|
m_fields[ SHEETFILENAME ].SetText( tmp );
|
2008-04-12 18:39:20 +00:00
|
|
|
}
|
|
|
|
|
2009-07-27 14:32:40 +00:00
|
|
|
// Geometric transforms (used in block operations):
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void Move( const VECTOR2I& aMoveVector ) override;
|
2021-03-19 19:55:59 +00:00
|
|
|
void MirrorHorizontally( int aCenter ) override;
|
|
|
|
void MirrorVertically( int aCenter ) override;
|
2022-01-01 06:04:08 +00:00
|
|
|
void Rotate( const VECTOR2I& aCenter ) override;
|
2009-07-27 14:32:40 +00:00
|
|
|
|
2022-08-05 02:40:38 +00:00
|
|
|
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
bool IsReplaceable() const override { return true; }
|
2011-12-13 15:37:33 +00:00
|
|
|
|
2010-06-24 18:31:43 +00:00
|
|
|
/**
|
|
|
|
* Resize this sheet to aSize and adjust all of the labels accordingly.
|
|
|
|
*
|
2021-03-25 21:13:01 +00:00
|
|
|
* @param[in] aSize The new size for this sheet.
|
2010-06-24 18:31:43 +00:00
|
|
|
*/
|
2010-12-10 19:47:44 +00:00
|
|
|
void Resize( const wxSize& aSize );
|
2010-06-24 18:31:43 +00:00
|
|
|
|
2020-03-06 20:02:58 +00:00
|
|
|
void AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) override;
|
2010-10-20 19:43:58 +00:00
|
|
|
|
2016-09-24 18:53:15 +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-11-03 14:13:15 +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
|
|
|
|
{
|
2021-05-11 23:06:52 +00:00
|
|
|
return ( aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_WIRE )
|
|
|
|
|| ( aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_BUS )
|
|
|
|
|| ( aItem->Type() == SCH_NO_CONNECT_T )
|
2021-06-10 14:10:55 +00:00
|
|
|
|| ( aItem->Type() == SCH_SYMBOL_T );
|
2017-12-19 17:45:56 +00:00
|
|
|
}
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
std::vector<VECTOR2I> GetConnectionPoints() const override;
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
|
2022-08-21 19:54:07 +00:00
|
|
|
const std::vector<KICAD_T>& aScanTypes ) override;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2020-11-17 16:02:47 +00:00
|
|
|
void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction ) override;
|
|
|
|
|
2023-01-12 03:27:44 +00:00
|
|
|
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) 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-01-12 18:40:50 +00:00
|
|
|
SCH_SHEET& operator=( const SCH_ITEM& aSheet );
|
2012-01-09 20:26:55 +00:00
|
|
|
|
2020-01-28 20:33:23 +00:00
|
|
|
bool operator <( const SCH_ITEM& aItem ) const override;
|
|
|
|
|
2018-10-21 12:50:31 +00:00
|
|
|
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I GetPosition() const override { return m_pos; }
|
|
|
|
void SetPosition( const VECTOR2I& aPosition ) override;
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
bool HitTest( const VECTOR2I& aPosition, int aAccuracy ) const override;
|
2022-08-31 09:33:46 +00:00
|
|
|
bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2022-02-10 19:49:25 +00:00
|
|
|
void Plot( PLOTTER* aPlotter, bool aBackground ) const override;
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
EDA_ITEM* Clone() const override;
|
2012-03-17 14:39:27 +00:00
|
|
|
|
2020-10-18 20:30:37 +00:00
|
|
|
/**
|
2021-12-06 12:47:18 +00:00
|
|
|
* @return the list of #SCH_SHEET_INSTANCE objects for this sheet.
|
|
|
|
*/
|
2021-12-08 18:36:23 +00:00
|
|
|
const std::vector<SCH_SHEET_INSTANCE>& GetInstances() const { return m_instances; }
|
|
|
|
|
2022-12-09 15:02:16 +00:00
|
|
|
/**
|
|
|
|
* Check to see if this sheet has a root sheet instance.
|
|
|
|
*
|
|
|
|
* @note It is possible for sheets to contain both sheet instances from other projects as
|
|
|
|
* well as a root sheet instance for this schematic. This will happen with a
|
|
|
|
* shared schematic is opened by the schematic editor in stand alone model.
|
|
|
|
*
|
|
|
|
* @return true if the instance data contains a root sheet instance.
|
|
|
|
*/
|
|
|
|
bool HasRootInstance() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the root sheet instance data.
|
|
|
|
*
|
|
|
|
* @note If no root sheet instance data exists, an assertion will be raise in debug builds
|
|
|
|
* and an empty instance will be returned.
|
|
|
|
*
|
|
|
|
* @return the root sheet instance data.
|
|
|
|
*/
|
|
|
|
const SCH_SHEET_INSTANCE& GetRootInstance() const;
|
|
|
|
|
2023-12-01 19:18:47 +00:00
|
|
|
void RemoveInstance( const KIID_PATH& aInstancePath );
|
|
|
|
|
|
|
|
void AddInstance( const SCH_SHEET_INSTANCE& aInstance );
|
|
|
|
|
2022-11-22 19:35:27 +00:00
|
|
|
/**
|
|
|
|
* Compares page numbers of schematic sheets.
|
|
|
|
*
|
|
|
|
* @return 0 if the page numbers are equal, -1 if aPageNumberA < aPageNumberB, 1 otherwise
|
|
|
|
*/
|
|
|
|
static int ComparePageNum( const wxString& aPageNumberA, const wxString& aPageNumberB );
|
|
|
|
|
|
|
|
#if defined(DEBUG)
|
|
|
|
void Show( int nestLevel, std::ostream& os ) const override;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static const wxString GetDefaultFieldName( int aFieldNdx, bool aTranslated = true );
|
|
|
|
|
|
|
|
protected:
|
|
|
|
friend SCH_SHEET_PATH;
|
2022-12-25 16:04:45 +00:00
|
|
|
friend SCH_SEXPR_PARSER;
|
|
|
|
|
|
|
|
void setInstances( const std::vector<SCH_SHEET_INSTANCE>& aInstances )
|
|
|
|
{
|
|
|
|
m_instances = aInstances;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a new instance \a aSheetPath to the instance list.
|
|
|
|
*
|
|
|
|
* If \a aSheetPath does not already exist, it is added to the list. If already exists
|
|
|
|
* in the list, do nothing. Sheet instances allow for the sharing in complex hierarchies
|
|
|
|
* which allows for per instance data such as page number for sheets to stored.
|
|
|
|
*
|
|
|
|
* @warning The #SCH_SHEET_PATH object must be a full hierarchical path which means the
|
|
|
|
* #SCH_SHEET object at index 0 must be the root sheet. A partial sheet path
|
|
|
|
* will raise an assertion on debug builds and silently fail and return false
|
|
|
|
* on release builds.
|
|
|
|
*
|
|
|
|
* @param[in] aInstance is the #SCH_SHEET_PATH of the sheet instance to the instance list.
|
|
|
|
* @return false if the instance already exists, true if the instance was added.
|
|
|
|
*/
|
|
|
|
bool addInstance( const SCH_SHEET_PATH& aInstance );
|
2022-11-22 19:35:27 +00:00
|
|
|
|
2021-12-06 12:47:18 +00:00
|
|
|
/**
|
|
|
|
* Return the sheet page number for \a aInstance.
|
2020-10-18 20:30:37 +00:00
|
|
|
*
|
2021-12-08 18:36:23 +00:00
|
|
|
* @warning The #SCH_SHEET_PATH object must be a full hierarchical path which means the
|
|
|
|
* #SCH_SHEET object at index 0 must be the root sheet. A partial sheet path
|
|
|
|
* will raise an assertion on debug builds and silently fail and return an empty
|
|
|
|
* page number on release builds.
|
|
|
|
*
|
2021-12-06 12:47:18 +00:00
|
|
|
* @return the page number for the requested sheet instance.
|
2020-10-18 20:30:37 +00:00
|
|
|
*/
|
2022-11-22 19:35:27 +00:00
|
|
|
wxString getPageNumber( const SCH_SHEET_PATH& aInstance ) const;
|
2020-10-18 20:30:37 +00:00
|
|
|
|
|
|
|
/**
|
2021-12-06 12:47:18 +00:00
|
|
|
* Set the page number for the sheet instance \a aInstance.
|
2020-10-18 20:30:37 +00:00
|
|
|
*
|
2021-12-08 18:36:23 +00:00
|
|
|
* @warning The #SCH_SHEET_PATH object must be a full hierarchical path which means the
|
|
|
|
* #SCH_SHEET object at index 0 must be the root sheet. A partial sheet path
|
|
|
|
* will raise an assertion on debug builds and silently fail and return on release
|
|
|
|
* builds.
|
|
|
|
*
|
2021-12-06 12:47:18 +00:00
|
|
|
* @param[in] aInstance is the hierarchical path of the sheet.
|
|
|
|
* @param[in] aReference is the new page number for the sheet.
|
2020-10-18 20:30:37 +00:00
|
|
|
*/
|
2022-11-22 19:35:27 +00:00
|
|
|
void setPageNumber( const SCH_SHEET_PATH& aInstance, const wxString& aPageNumber );
|
2020-10-18 20:30:37 +00:00
|
|
|
|
2022-12-25 16:04:45 +00:00
|
|
|
bool getInstance( SCH_SHEET_INSTANCE& aInstance, const KIID_PATH& aSheetPath,
|
|
|
|
bool aTestFromEnd = false ) const;
|
|
|
|
|
2010-06-24 18:31:43 +00:00
|
|
|
/**
|
2011-03-30 19:26:05 +00:00
|
|
|
* Renumber the sheet pins in the sheet.
|
2010-06-24 18:31:43 +00:00
|
|
|
*
|
2011-03-30 19:26:05 +00:00
|
|
|
* This method is used internally by SCH_SHEET to update the pin numbering
|
|
|
|
* when the pin list changes. Make sure you call this method any time a
|
|
|
|
* sheet pin is added or removed.
|
2010-06-24 18:31:43 +00:00
|
|
|
*/
|
2011-03-30 19:26:05 +00:00
|
|
|
void renumberPins();
|
2020-02-04 10:06:30 +00:00
|
|
|
|
2022-07-03 15:21:30 +00:00
|
|
|
/**
|
2022-09-09 21:48:13 +00:00
|
|
|
* Get the sheetpath of this sheet. NB: REQUIRES that the current sheet hierarchy contains
|
|
|
|
* the given sheet.
|
2022-07-03 15:21:30 +00:00
|
|
|
*/
|
2022-09-09 21:48:13 +00:00
|
|
|
SCH_SHEET_PATH findSelf() const;
|
2022-07-03 15:21:30 +00:00
|
|
|
|
2020-02-04 10:06:30 +00:00
|
|
|
private:
|
2022-01-01 06:04:08 +00:00
|
|
|
bool doIsConnected( const VECTOR2I& aPosition ) const override;
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2021-03-25 21:13:01 +00:00
|
|
|
friend class SCH_SHEET_PIN;
|
2022-12-25 16:04:45 +00:00
|
|
|
friend class SCH_SHEET_LIST;
|
2021-03-25 21:13:01 +00:00
|
|
|
|
2022-09-26 20:31:26 +00:00
|
|
|
private:
|
|
|
|
SCH_SCREEN* m_screen; // Screen that contains the physical data for the
|
|
|
|
// sheet. In complex hierarchies multiple sheets
|
|
|
|
// can share a common screen.
|
2021-03-25 21:13:01 +00:00
|
|
|
|
2022-09-26 20:31:26 +00:00
|
|
|
std::vector<SCH_SHEET_PIN*> m_pins; // The list of sheet connection points.
|
2021-03-25 21:13:01 +00:00
|
|
|
std::vector<SCH_FIELD> m_fields;
|
|
|
|
|
2022-09-26 20:31:26 +00:00
|
|
|
VECTOR2I m_pos; // The position of the sheet.
|
|
|
|
wxSize m_size; // The size of the sheet.
|
2021-03-25 21:13:01 +00:00
|
|
|
int m_borderWidth;
|
|
|
|
KIGFX::COLOR4D m_borderColor;
|
|
|
|
KIGFX::COLOR4D m_backgroundColor;
|
|
|
|
|
2021-12-06 12:47:18 +00:00
|
|
|
std::vector<SCH_SHEET_INSTANCE> m_instances;
|
2021-03-25 21:13:01 +00:00
|
|
|
};
|
2011-01-22 19:48:28 +00:00
|
|
|
|
2016-02-15 20:11:50 +00:00
|
|
|
|
2016-06-24 10:55:54 +00:00
|
|
|
#endif // SCH_SHEEET_H
|