diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index 2e7b6f05cf..6f9e8a49f9 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include diff --git a/eeschema/dialogs/dialog_sheet_pin_properties.cpp b/eeschema/dialogs/dialog_sheet_pin_properties.cpp index 2ae0d53188..546ff1dab5 100644 --- a/eeschema/dialogs/dialog_sheet_pin_properties.cpp +++ b/eeschema/dialogs/dialog_sheet_pin_properties.cpp @@ -1,8 +1,8 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2010 Wayne Stambaugh - * Copyright (C) 2018-2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2010 Wayne Stambaugh + * Copyright (C) 2018-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 @@ -24,6 +24,7 @@ #include #include +#include #include #include #include diff --git a/eeschema/dialogs/panel_eeschema_color_settings.cpp b/eeschema/dialogs/panel_eeschema_color_settings.cpp index a3d4ccfa07..2e11fea858 100644 --- a/eeschema/dialogs/panel_eeschema_color_settings.cpp +++ b/eeschema/dialogs/panel_eeschema_color_settings.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2020 Jon Evans - * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-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 @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index 5d60a366ce..07d201c2bc 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 6a933b9f2b..92acc18f0c 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include diff --git a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp index 01a7512cb4..66b257c90b 100644 --- a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp +++ b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #include #include diff --git a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp index d4ce5c61f2..dfb352412d 100644 --- a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp +++ b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp index 53e92e1709..7ea4f4f1ad 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include #include diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp index b8d7d2420f..f45133c0c8 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include diff --git a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp index fa9792f192..cc04ba0ae6 100644 --- a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp +++ b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 54f6bf0461..b8c5c70ab4 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 7bec766b19..503a980cb5 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -34,6 +34,7 @@ #include // for KiROUND #include #include +#include #include #include #include @@ -717,6 +718,18 @@ void SCH_SHEET::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList } +void SCH_SHEET::Move( const wxPoint& aMoveVector ) +{ + m_pos += aMoveVector; + + for( SCH_SHEET_PIN* pin : m_pins ) + pin->Move( aMoveVector ); + + for( SCH_FIELD& field : m_fields ) + field.Move( aMoveVector ); +} + + void SCH_SHEET::Rotate( wxPoint aCenter ) { wxPoint prev = m_pos; diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index a8f1cb02f3..f8c3fbdcef 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -25,46 +25,21 @@ #ifndef SCH_SHEEET_H #define SCH_SHEEET_H -#include -#include #include -class KIID; -class LINE_READER; +class KIID_PATH; class SCH_SCREEN; -class SCH_SHEET; class SCH_SHEET_PIN; class SCH_SHEET_PATH; -class DANGLING_END_ITEM; -class SCH_EDIT_FRAME; -class NETLIST_OBJECT_LIST; +class EDA_DRAW_FRAME; #define MIN_SHEET_WIDTH 500 // Units are mils. #define MIN_SHEET_HEIGHT 150 // Units are mils. -/** - * 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. - */ -enum SHEET_SIDE +enum SHEET_FIELD_TYPE { - SHEET_LEFT_SIDE = 0, - SHEET_RIGHT_SIDE, - SHEET_TOP_SIDE, - SHEET_BOTTOM_SIDE, - SHEET_UNDEFINED_SIDE -}; - - -enum SHEET_FIELD_TYPE { SHEETNAME = 0, SHEETFILENAME, @@ -73,149 +48,6 @@ enum SHEET_FIELD_TYPE { }; -/** - * 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: - SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos = wxPoint( 0, 0 ), - 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; - - /** - * 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; } - - void Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) override; - - /** - * 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. - */ - void CreateGraphicShape( const RENDER_SETTINGS* aSettings, - std::vector & aPoints, const wxPoint& aPos ) const override; - - 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 ); - - void SetEdge( SHEET_SIDE aEdge ); - - SHEET_SIDE GetEdge() const; - - /** - * Adjust label position to edge based on proximity to vertical or horizontal edge - * of the parent sheet. - */ - void ConstrainOnEdge( wxPoint Pos ); - - /** - * 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): - - void Move( const wxPoint& aMoveVector ) override - { - Offset( aMoveVector ); - } - - void MirrorVertically( int aCenter ) override; - void MirrorHorizontally( int aCenter ) override; - void Rotate( wxPoint aCenter ) override; - - bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override - { - return SCH_ITEM::Matches( GetText(), aSearchData ); - } - - bool Replace( const wxFindReplaceData& aSearchData, void* aAuxData = NULL ) override - { - 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; } - - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; - - BITMAPS GetMenuImage() const override; - - void SetPosition( const wxPoint& aPosition ) override { ConstrainOnEdge( aPosition ); } - - bool IsPointClickableAnchor( const wxPoint& aPos ) const override - { - return m_isDangling && GetPosition() == aPos; - } - - bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override; - - 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; -}; - - /** * Sheet symbol placed in a schematic, and is the entry point for a sub schematic. */ @@ -495,17 +327,7 @@ public: // Geometric transforms (used in block operations): - void Move( const wxPoint& aMoveVector ) override - { - m_pos += aMoveVector; - - for( SCH_SHEET_PIN* pin : m_pins ) - pin->Move( aMoveVector ); - - for( SCH_FIELD& field : m_fields ) - field.Move( aMoveVector ); - } - + void Move( const wxPoint& aMoveVector ) override; void MirrorHorizontally( int aCenter ) override; void MirrorVertically( int aCenter ) override; void Rotate( wxPoint aCenter ) override; diff --git a/eeschema/sch_sheet_pin.cpp b/eeschema/sch_sheet_pin.cpp index ff06a0ab37..a0eef8261a 100644 --- a/eeschema/sch_sheet_pin.cpp +++ b/eeschema/sch_sheet_pin.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include diff --git a/eeschema/sch_sheet_pin.h b/eeschema/sch_sheet_pin.h new file mode 100644 index 0000000000..d3638b9342 --- /dev/null +++ b/eeschema/sch_sheet_pin.h @@ -0,0 +1,197 @@ +/* + * 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 + */ + +#ifndef _SCH_SHEEET_PIN_H_ +#define _SCH_SHEEET_PIN_H_ + +#include + +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. + */ +enum SHEET_SIDE +{ + SHEET_LEFT_SIDE = 0, + SHEET_RIGHT_SIDE, + SHEET_TOP_SIDE, + SHEET_BOTTOM_SIDE, + SHEET_UNDEFINED_SIDE +}; + + +/** + * 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: + SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos = wxPoint( 0, 0 ), + 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; + + /** + * 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; } + + void Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) override; + + /** + * 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. + */ + void CreateGraphicShape( const RENDER_SETTINGS* aSettings, + std::vector & aPoints, const wxPoint& aPos ) const override; + + 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 ); + + void SetEdge( SHEET_SIDE aEdge ); + + SHEET_SIDE GetEdge() const; + + /** + * Adjust label position to edge based on proximity to vertical or horizontal edge + * of the parent sheet. + */ + void ConstrainOnEdge( wxPoint Pos ); + + /** + * 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): + + void Move( const wxPoint& aMoveVector ) override + { + Offset( aMoveVector ); + } + + void MirrorVertically( int aCenter ) override; + void MirrorHorizontally( int aCenter ) override; + void Rotate( wxPoint aCenter ) override; + + bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override + { + return SCH_ITEM::Matches( GetText(), aSearchData ); + } + + bool Replace( const wxFindReplaceData& aSearchData, void* aAuxData = NULL ) override + { + 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; } + + wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + + BITMAPS GetMenuImage() const override; + + void SetPosition( const wxPoint& aPosition ) override { ConstrainOnEdge( aPosition ); } + + bool IsPointClickableAnchor( const wxPoint& aPos ) const override + { + return m_isDangling && GetPosition() == aPos; + } + + bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override; + + 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; +}; + +#endif // _SCH_SHEEET_PIN_H_ diff --git a/eeschema/tools/ee_point_editor.cpp b/eeschema/tools/ee_point_editor.cpp index d7225605ce..c10b966925 100644 --- a/eeschema/tools/ee_point_editor.cpp +++ b/eeschema/tools/ee_point_editor.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2019 CERN - * Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019-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 @@ -36,6 +36,7 @@ using namespace std::placeholders; #include #include #include +#include #include #include #include diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 0244bf26b7..08ef70f04d 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index 32e35dee0c..ab5fcd0d6e 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 8e56a25e9b..92f23f5960 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 96133906fd..0c982937ab 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include diff --git a/eeschema/tools/sch_line_wire_bus_tool.cpp b/eeschema/tools/sch_line_wire_bus_tool.cpp index 21028039ef..1b5fe3836e 100644 --- a/eeschema/tools/sch_line_wire_bus_tool.cpp +++ b/eeschema/tools/sch_line_wire_bus_tool.cpp @@ -58,6 +58,7 @@ #include #include #include +#include #include #include #include diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index 1e5df28a8d..a9236e10b1 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include diff --git a/qa/eeschema/test_sch_sheet.cpp b/qa/eeschema/test_sch_sheet.cpp index aa200249b6..e8eb3f8785 100644 --- a/qa/eeschema/test_sch_sheet.cpp +++ b/qa/eeschema/test_sch_sheet.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2019-2020 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2019-2021 KiCad Developers, see CHANGELOG.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 @@ -30,6 +30,7 @@ // Code under test #include +#include #include #include "uuid_test_utils.h"