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
|
2016-02-27 19:35:45 +00:00
|
|
|
* Copyright (C) 1992-2016 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-09-30 18:15:37 +00:00
|
|
|
/**
|
|
|
|
* @file sch_sheet.h
|
|
|
|
* @brief Definition of the SCH_SHEET class for Eeschema.
|
|
|
|
*/
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
#ifndef SCH_SHEEET_H
|
|
|
|
#define SCH_SHEEET_H
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2010-06-24 18:31:43 +00:00
|
|
|
#include <boost/ptr_container/ptr_vector.hpp>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <sch_text.h>
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
class LINE_READER;
|
|
|
|
class SCH_SCREEN;
|
|
|
|
class SCH_SHEET;
|
|
|
|
class SCH_SHEET_PIN;
|
|
|
|
class SCH_SHEET_PATH;
|
|
|
|
class DANGLING_END_ITEM;
|
2010-12-08 20:12:46 +00:00
|
|
|
class SCH_EDIT_FRAME;
|
2013-09-25 19:09:57 +00:00
|
|
|
class NETLIST_OBJECT_LIST;
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2011-06-07 15:29:01 +00:00
|
|
|
#define MIN_SHEET_WIDTH 500
|
|
|
|
#define MIN_SHEET_HEIGHT 150
|
|
|
|
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/**
|
2011-12-08 15:45:01 +00:00
|
|
|
* Class SCH_SHEET_PIN
|
|
|
|
* defines a sheet pin (label) used in sheets to create hierarchical schematics.
|
2009-11-04 20:46:53 +00:00
|
|
|
*
|
|
|
|
* A SCH_SHEET_PIN is used to create a hierarchical sheet in the same way a
|
2009-12-02 21:44:03 +00:00
|
|
|
* pin is used in a component. It connects the objects in the sheet object
|
|
|
|
* to the objects in the schematic page to the objects in the page that is
|
2009-11-04 20:46:53 +00:00
|
|
|
* 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.
|
2009-01-04 18:52:57 +00:00
|
|
|
*/
|
2010-09-05 17:01:48 +00:00
|
|
|
class SCH_SHEET_PIN : public SCH_HIERLABEL
|
2008-04-12 18:39:20 +00:00
|
|
|
{
|
2016-07-06 09:22:56 +00:00
|
|
|
public:
|
2011-12-08 15:45:01 +00:00
|
|
|
/**
|
|
|
|
* Defines the edge of the sheet that the sheet pin is positioned
|
2015-06-27 09:12:32 +00:00
|
|
|
* 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
|
2011-12-08 15:45:01 +00:00
|
|
|
*
|
|
|
|
* For compatibility reasons, this does not follow same values as text orientation.
|
|
|
|
*/
|
2015-06-27 09:12:32 +00:00
|
|
|
enum SHEET_SIDE
|
|
|
|
{
|
|
|
|
SHEET_LEFT_SIDE = 0,
|
|
|
|
SHEET_RIGHT_SIDE,
|
|
|
|
SHEET_TOP_SIDE,
|
|
|
|
SHEET_BOTTOM_SIDE,
|
|
|
|
SHEET_UNDEFINED_SIDE
|
|
|
|
};
|
2016-07-06 09:22:56 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2015-06-27 09:12:32 +00:00
|
|
|
SHEET_SIDE m_edge;
|
2010-06-24 18:31:43 +00:00
|
|
|
|
2010-03-16 18:22:59 +00:00
|
|
|
public:
|
|
|
|
SCH_SHEET_PIN( SCH_SHEET* parent,
|
|
|
|
const wxPoint& pos = wxPoint( 0, 0 ),
|
|
|
|
const wxString& text = wxEmptyString );
|
2008-04-12 18:39:20 +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-11-04 20:46:53 +00:00
|
|
|
~SCH_SHEET_PIN() { }
|
2008-04-22 16:38:23 +00:00
|
|
|
|
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_PIN" );
|
2008-04-12 18:39:20 +00:00
|
|
|
}
|
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
bool operator ==( const SCH_SHEET_PIN* aPin ) const;
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2015-02-28 16:56:09 +00:00
|
|
|
/**
|
|
|
|
* Virtual function IsMovableFromAnchorPoint
|
|
|
|
* Return true for items which are moved with the anchor point at mouse cursor
|
2015-07-24 10:23:34 +00:00
|
|
|
* and false for items moved with no reference to anchor (usually large items)
|
|
|
|
* @return true for a hierarchical sheet pin
|
2015-02-28 16:56:09 +00:00
|
|
|
*/
|
2016-09-25 17:06:49 +00:00
|
|
|
bool IsMovableFromAnchorPoint() override { return true; }
|
2015-02-28 16:56:09 +00:00
|
|
|
|
|
|
|
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
|
2016-09-25 17:06:49 +00:00
|
|
|
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
|
2010-09-11 16:33:43 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2011-03-30 19:26:05 +00:00
|
|
|
* Function CreateGraphicShape (virtual)
|
2010-09-11 16:33:43 +00:00
|
|
|
* Calculates the graphic shape (a polygon) associated to the text
|
2011-06-17 13:24:22 +00:00
|
|
|
* @param aPoints = a buffer to fill with polygon corners coordinates
|
2010-12-14 15:56:30 +00:00
|
|
|
* @param aPos = Position of the shape
|
2010-09-11 16:33:43 +00:00
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
void CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& aPos ) override;
|
2012-03-26 23:47:08 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void SwapData( SCH_ITEM* aItem ) override;
|
2010-12-14 15:56:30 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
int GetPenSize() const override;
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2010-06-24 18:31:43 +00:00
|
|
|
/**
|
|
|
|
* Get the sheet label number.
|
|
|
|
*
|
|
|
|
* @return Number of the sheet label.
|
|
|
|
*/
|
2011-12-08 15:45:01 +00:00
|
|
|
int GetNumber() const { return m_number; }
|
2010-06-24 18:31:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the sheet label number.
|
|
|
|
*
|
|
|
|
* @param aNumber - New sheet number label.
|
|
|
|
*/
|
2011-03-25 19:16:05 +00:00
|
|
|
void SetNumber( int aNumber );
|
2011-06-07 15:29:01 +00:00
|
|
|
|
2015-06-27 09:12:32 +00:00
|
|
|
void SetEdge( SHEET_SIDE aEdge );
|
2011-06-07 15:29:01 +00:00
|
|
|
|
2015-06-27 09:12:32 +00:00
|
|
|
SHEET_SIDE GetEdge() const;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
|
|
|
/**
|
2011-10-21 13:59:15 +00:00
|
|
|
* Function ConstrainOnEdge
|
2011-03-30 19:26:05 +00:00
|
|
|
* is used to adjust label position to edge based on proximity to vertical / horizontal edge
|
2010-12-21 15:13:09 +00:00
|
|
|
* of the parent sheet.
|
|
|
|
*/
|
2011-10-21 13:59:15 +00:00
|
|
|
void ConstrainOnEdge( wxPoint Pos );
|
2010-06-24 18:31:43 +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; }
|
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
bool Save( FILE* aFile ) const override;
|
2008-04-30 17:04:22 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
bool Load( LINE_READER& aLine, wxString& aErrorMsg ) override;
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2009-11-03 13:26:31 +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
|
2009-05-05 18:25:47 +00:00
|
|
|
|
2009-07-27 14:32:40 +00:00
|
|
|
// Geometric transforms (used in block operations):
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
void Move( const wxPoint& aMoveVector ) override
|
2009-07-27 14:32:40 +00:00
|
|
|
{
|
|
|
|
m_Pos += aMoveVector;
|
|
|
|
}
|
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void MirrorY( int aYaxis_position ) override;
|
2010-12-14 15:56:30 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void Rotate( wxPoint aPosition ) override;
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void MirrorX( int aXaxis_position ) override;
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation ) override;
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
bool Replace( wxFindReplaceData& aSearchData, void* aAuxData = NULL ) override
|
2011-12-13 15:37:33 +00:00
|
|
|
{
|
|
|
|
return EDA_ITEM::Replace( aSearchData, m_Text );
|
|
|
|
}
|
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
bool IsReplaceable() const override { return true; }
|
2011-12-13 15:37:33 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
|
2011-01-07 19:24:24 +00:00
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
bool IsConnectable() const override { return true; }
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
wxString GetSelectMenuText() const override;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
BITMAP_DEF GetMenuImage() const override { return add_hierar_pin_xpm; }
|
2011-10-21 13:59:15 +00:00
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
void SetPosition( const wxPoint& aPosition ) override { ConstrainOnEdge( aPosition ); }
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override;
|
2012-03-17 14:39:27 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
EDA_ITEM* Clone() const override;
|
2008-04-12 18:39:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
typedef boost::ptr_vector<SCH_SHEET_PIN> SCH_SHEET_PINS;
|
2010-06-24 18:31:43 +00:00
|
|
|
|
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
/**
|
|
|
|
* Class SCH_SHEET
|
|
|
|
* is the 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
|
|
|
{
|
2012-01-05 08:07:11 +00:00
|
|
|
friend class SCH_SHEET_PIN;
|
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
/// Screen that contains the physical data for the sheet. In complex hierarchies
|
|
|
|
/// multiple sheets can share a common screen.
|
|
|
|
SCH_SCREEN* m_screen;
|
2010-06-24 18:31:43 +00:00
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
/// The list of sheet connection points.
|
|
|
|
SCH_SHEET_PINS m_pins;
|
|
|
|
|
|
|
|
/// The file name is also in the #SCH_SCREEN object associated with the sheet. It is
|
|
|
|
/// also needed here for loading after reading the sheet description from file.
|
|
|
|
wxString m_fileName;
|
|
|
|
|
|
|
|
/// This is equivalent to the reference designator for components and is stored in F0
|
|
|
|
/// sheet pin in the schematic file.
|
|
|
|
wxString m_name;
|
|
|
|
|
|
|
|
/// The height of the text used to draw the sheet name.
|
|
|
|
int m_sheetNameSize;
|
|
|
|
|
|
|
|
/// The height of the text used to draw the file name.
|
|
|
|
int m_fileNameSize;
|
|
|
|
|
|
|
|
/// The position of the sheet.
|
|
|
|
wxPoint m_pos;
|
|
|
|
|
|
|
|
/// The size of the sheet.
|
|
|
|
wxSize m_size;
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
public:
|
|
|
|
SCH_SHEET( const wxPoint& pos = wxPoint( 0, 0 ) );
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2012-01-09 20:26:55 +00:00
|
|
|
/**
|
|
|
|
* Copy Constructor
|
|
|
|
* clones \a aSheet into a new object. All sheet pins are copied as is except and
|
|
|
|
* 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
|
|
|
|
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
|
|
|
/**
|
|
|
|
* Virtual function IsMovableFromAnchorPoint
|
|
|
|
* 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 return true for small items (labels, junctions) and false for
|
2016-02-15 20:24:59 +00:00
|
|
|
* items which can be large (hierarchical sheets, compoments)
|
2015-02-28 16:56:09 +00:00
|
|
|
* @return false for a hierarchical sheet
|
|
|
|
*/
|
2016-09-25 17:06:49 +00:00
|
|
|
bool IsMovableFromAnchorPoint() override { return false; }
|
2011-12-08 15:45:01 +00:00
|
|
|
|
|
|
|
wxString GetName() const { return m_name; }
|
|
|
|
|
|
|
|
void SetName( const wxString& aName ) { m_name = aName; }
|
|
|
|
|
|
|
|
int GetSheetNameSize() const { return m_sheetNameSize; }
|
|
|
|
|
|
|
|
void SetSheetNameSize( int aSize ) { m_sheetNameSize = aSize; }
|
|
|
|
|
|
|
|
int GetFileNameSize() const { return m_fileNameSize; }
|
|
|
|
|
|
|
|
void SetFileNameSize( int aSize ) { m_fileNameSize = aSize; }
|
|
|
|
|
|
|
|
SCH_SCREEN* GetScreen() { return m_screen; }
|
|
|
|
|
|
|
|
wxSize GetSize() { return m_size; }
|
|
|
|
|
|
|
|
void SetSize( const wxSize& aSize ) { m_size = aSize; }
|
2011-01-20 16:34:57 +00:00
|
|
|
|
2016-07-06 09:22:56 +00:00
|
|
|
/**
|
|
|
|
* Function GetRootSheet
|
|
|
|
*
|
|
|
|
* returns the root sheet of this SCH_SHEET object.
|
|
|
|
*
|
|
|
|
* The root (top level) sheet can be found by walking up the parent links until the only
|
|
|
|
* sheet that has no parent is found. The root sheet can be found from any sheet without
|
|
|
|
* having to maintain a global root sheet pointer.
|
|
|
|
*
|
|
|
|
* @return a SCH_SHEET pointer to the root sheet.
|
|
|
|
*/
|
|
|
|
SCH_SHEET* GetRootSheet();
|
|
|
|
|
2011-01-20 16:34:57 +00:00
|
|
|
/**
|
|
|
|
* Function SetScreen
|
|
|
|
* sets the screen associated with this sheet to \a aScreen.
|
|
|
|
* <p>
|
|
|
|
* 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.
|
|
|
|
* </p>
|
|
|
|
* @param aScreen The new screen to associate with the sheet.
|
|
|
|
*/
|
|
|
|
void SetScreen( SCH_SCREEN* aScreen );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetScreenCount
|
|
|
|
* returns 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.
|
|
|
|
*/
|
|
|
|
int GetScreenCount() const;
|
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
bool Save( FILE* aFile ) const override;
|
2008-04-30 17:04:22 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
bool Load( LINE_READER& aLine, wxString& aErrorMsg ) override;
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void GetMsgPanelInfo( 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
|
|
|
*
|
2011-03-30 19:26:05 +00:00
|
|
|
* Note: Once a sheet pin is added to the sheet, it is owned by the sheet.
|
|
|
|
* 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
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
SCH_SHEET_PINS& GetPins() { return m_pins; }
|
2010-06-24 18:31:43 +00:00
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
SCH_SHEET_PINS& GetPins() const
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2011-03-30 19:26:05 +00:00
|
|
|
return const_cast< SCH_SHEET_PINS& >( 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
|
|
|
*/
|
2011-03-30 19:26:05 +00:00
|
|
|
void RemovePin( SCH_SHEET_PIN* aSheetPin );
|
2010-06-24 18:31:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete sheet label which do not have a corresponding hierarchical label.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
*/
|
2011-03-30 19:26:05 +00:00
|
|
|
SCH_SHEET_PIN* GetPin( const wxPoint& 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.
|
2010-06-24 18:31:43 +00:00
|
|
|
*
|
2011-03-30 19:26:05 +00:00
|
|
|
* @return True if sheet pin with \a aName is found, otherwise false.
|
2008-04-21 06:34:56 +00:00
|
|
|
*/
|
2011-03-30 19:26:05 +00:00
|
|
|
bool HasPin( const wxString& aName );
|
2010-06-24 18:31:43 +00:00
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
bool HasPins() { 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.
|
|
|
|
*/
|
2011-03-30 19:26:05 +00:00
|
|
|
bool HasUndefinedPins();
|
2008-04-21 06:34:56 +00:00
|
|
|
|
2011-06-07 15:29:01 +00:00
|
|
|
/**
|
|
|
|
* Function GetMinWidth
|
|
|
|
* returns the minimum width of the sheet based on the widths of the sheet pin text.
|
|
|
|
*
|
|
|
|
* <p>
|
|
|
|
* 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.
|
|
|
|
* </p>
|
|
|
|
*
|
|
|
|
* @return The minimum width the sheet can be resized.
|
|
|
|
*/
|
|
|
|
int GetMinWidth() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetMinHeight
|
|
|
|
* returns the minimum height that the sheet can be resized based on the sheet pin
|
|
|
|
* positions.
|
|
|
|
*
|
|
|
|
* <p>
|
|
|
|
* 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.
|
|
|
|
* </p>
|
|
|
|
*
|
|
|
|
* @return The minimum height the sheet can be resized.
|
|
|
|
*/
|
|
|
|
int GetMinHeight() const;
|
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
int GetPenSize() const override;
|
2009-06-30 19:21:41 +00:00
|
|
|
|
2015-02-28 16:56:09 +00:00
|
|
|
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
|
2016-09-25 17:06:49 +00:00
|
|
|
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
|
2009-01-31 18:08:47 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
EDA_RECT const GetBoundingBox() const override;
|
2009-01-31 18:08:47 +00:00
|
|
|
|
2011-06-07 15:29:01 +00:00
|
|
|
/**
|
|
|
|
* Function GetResizePos
|
|
|
|
* returns the position of the lower right corner of the sheet in drawing units.
|
|
|
|
*
|
|
|
|
* @return A wxPoint containing lower right corner of the sheet in drawing units.
|
|
|
|
*/
|
|
|
|
wxPoint GetResizePosition() const;
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
* Function ComponentCount
|
2009-01-04 18:52:57 +00:00
|
|
|
* count our own components, without the power components.
|
2009-01-06 20:09:32 +00:00
|
|
|
* @return the component count.
|
2009-01-04 18:52:57 +00:00
|
|
|
*/
|
2010-12-10 19:47:44 +00:00
|
|
|
int ComponentCount();
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function Load.
|
2011-12-08 15:45:01 +00:00
|
|
|
* for the sheet: load the file m_fileName
|
2009-01-04 18:52:57 +00:00
|
|
|
* if a screen already exists, the file is already read.
|
2011-12-08 15:45:01 +00:00
|
|
|
* m_screen point on the screen, and its m_RefCount is
|
2009-11-03 13:26:31 +00:00
|
|
|
* incremented
|
2009-01-04 18:52:57 +00:00
|
|
|
* else creates a new associated screen and load the data file.
|
2010-12-10 19:47:44 +00:00
|
|
|
* @param aFrame = a SCH_EDIT_FRAME pointer to the maim schematic frame
|
2009-01-04 18:52:57 +00:00
|
|
|
* @return true if OK
|
|
|
|
*/
|
2010-12-10 19:47:44 +00:00
|
|
|
bool Load( SCH_EDIT_FRAME* aFrame );
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function SearchHierarchy
|
2009-01-04 18:52:57 +00:00
|
|
|
* search the existing hierarchy for an instance of screen "FileName".
|
|
|
|
* @param aFilename = the filename to find
|
2010-12-14 15:56:30 +00:00
|
|
|
* @param aScreen = a location to return a pointer to the screen (if found)
|
2009-01-04 18:52:57 +00:00
|
|
|
* @return bool if found, and a pointer to the screen
|
|
|
|
*/
|
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
|
|
|
/**
|
|
|
|
* Function LocatePathOfScreen
|
|
|
|
* search the existing hierarchy for an instance of screen "FileName".
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* @param aScreen = the SCH_SCREEN* screen that we search for
|
|
|
|
* @param aList = the SCH_SHEET_PATH* that must be used
|
|
|
|
* @return true if found
|
|
|
|
*/
|
|
|
|
bool LocatePathOfScreen( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aList );
|
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function CountSheets
|
2009-01-06 20:09:32 +00:00
|
|
|
* calculates the number of sheets found in "this"
|
|
|
|
* this number includes the full subsheets count
|
|
|
|
* @return the full count of sheets+subsheets contained by "this"
|
|
|
|
*/
|
2010-12-10 19:47:44 +00:00
|
|
|
int CountSheets();
|
2009-01-06 20:09:32 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function GetFileName
|
2009-01-06 20:09:32 +00:00
|
|
|
* return the filename corresponding to this sheet
|
|
|
|
* @return a wxString containing the filename
|
|
|
|
*/
|
2011-06-17 13:24:22 +00:00
|
|
|
wxString GetFileName( void ) const;
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
// Set a new filename without changing anything else
|
2010-06-24 18:31:43 +00:00
|
|
|
void SetFileName( const wxString& aFilename )
|
2008-04-12 18:39:20 +00:00
|
|
|
{
|
2011-12-08 15:45:01 +00:00
|
|
|
m_fileName = aFilename;
|
2012-10-13 18:54:33 +00:00
|
|
|
// Filenames are stored using unix notation
|
2016-02-15 20:24:59 +00:00
|
|
|
m_fileName.Replace( wxT("\\"), wxT("/") );
|
2008-04-12 18:39:20 +00:00
|
|
|
}
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
bool ChangeFileName( SCH_EDIT_FRAME* aFrame, const wxString& aFileName );
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
//void RemoveSheet(SCH_SHEET* sheet);
|
2009-01-04 18:52:57 +00:00
|
|
|
//to remove a sheet, just delete it
|
|
|
|
//-- the destructor should take care of everything else.
|
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
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
void Move( const wxPoint& aMoveVector ) override
|
2009-07-27 14:32:40 +00:00
|
|
|
{
|
2011-12-08 15:45:01 +00:00
|
|
|
m_pos += aMoveVector;
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2016-06-29 20:07:55 +00:00
|
|
|
for( SCH_SHEET_PIN& pin : m_pins )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2011-03-30 19:26:05 +00:00
|
|
|
pin.Move( aMoveVector );
|
2009-07-27 14:32:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void MirrorY( int aYaxis_position ) override;
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void MirrorX( int aXaxis_position ) override;
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void Rotate( wxPoint aPosition ) override;
|
2009-07-27 14:32:40 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation ) override;
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
bool Replace( wxFindReplaceData& aSearchData, void* aAuxData = NULL ) override;
|
2011-12-13 15:37:33 +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.
|
|
|
|
*
|
|
|
|
* @param aSize - The new size for this sheet.
|
|
|
|
*/
|
2010-12-10 19:47:44 +00:00
|
|
|
void Resize( const wxSize& aSize );
|
2010-06-24 18:31:43 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function GetSheetNamePosition
|
2010-10-20 19:43:58 +00:00
|
|
|
* @return the position of the anchor of sheet name text
|
|
|
|
*/
|
2011-03-25 19:16:05 +00:00
|
|
|
wxPoint GetSheetNamePosition();
|
2010-10-20 19:43:58 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function GetFileNamePosition
|
2010-10-20 19:43:58 +00:00
|
|
|
* @return the position of the anchor of filename text
|
|
|
|
*/
|
2011-03-25 19:16:05 +00:00
|
|
|
wxPoint GetFileNamePosition();
|
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
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
bool IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList ) override;
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
bool IsDangling() const override;
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
bool IsSelectStateChanged( const wxRect& aRect ) 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
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const override;
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2016-07-12 19:05:54 +00:00
|
|
|
SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
wxString GetSelectMenuText() const override;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
BITMAP_DEF GetMenuImage() const override { return add_hierarchical_subsheet_xpm; }
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
|
2016-09-25 17:06:49 +00:00
|
|
|
SCH_SHEET_PATH* aSheetPath ) override;
|
2011-10-12 14:03:43 +00:00
|
|
|
|
2012-01-09 20:26:55 +00:00
|
|
|
SCH_ITEM& operator=( const SCH_ITEM& aSheet );
|
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
wxPoint GetPosition() const override { return m_pos; }
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void SetPosition( const wxPoint& aPosition ) override;
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override;
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
bool HitTest( const EDA_RECT& aRect, bool aContained = false, int aAccuracy = 0 ) const override;
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void Plot( PLOTTER* aPlotter ) 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
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
#if defined(DEBUG)
|
2016-09-25 17:06:49 +00:00
|
|
|
void Show( int nestLevel, std::ostream& os ) const override;
|
2009-01-04 18:52:57 +00:00
|
|
|
#endif
|
2010-06-24 18:31:43 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
/**
|
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();
|
2008-04-12 18:39:20 +00:00
|
|
|
};
|
|
|
|
|
2011-01-22 19:48:28 +00:00
|
|
|
|
2016-06-24 10:55:54 +00:00
|
|
|
typedef std::vector< SCH_SHEET* > SCH_SHEETS; // no ownership over contained SCH_SHEETs
|
2016-02-15 20:11:50 +00:00
|
|
|
|
2016-06-24 10:55:54 +00:00
|
|
|
#endif // SCH_SHEEET_H
|