Eeschema: split out SCH_SHEET_PIN declarations into separate header.

This commit is contained in:
Wayne Stambaugh 2021-04-06 17:15:49 -04:00
parent 866c58a6d6
commit 2b86b34124
23 changed files with 239 additions and 187 deletions

View File

@ -38,6 +38,7 @@
#include <sch_pin.h>
#include <sch_sheet.h>
#include <sch_sheet_path.h>
#include <sch_sheet_pin.h>
#include <sch_text.h>
#include <schematic.h>
#include <connection_graph.h>

View File

@ -1,8 +1,8 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2010 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2018-2019 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2010 Wayne Stambaugh <stambaughw@gmail.com>
* 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 <sch_edit_frame.h>
#include <sch_sheet.h>
#include <sch_sheet_pin.h>
#include <sch_validators.h>
#include <dialog_sheet_pin_properties.h>
#include <dialogs/html_messagebox.h>

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
* 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 <sch_no_connect.h>
#include <sch_painter.h>
#include <sch_preview_panel.h>
#include <sch_sheet_pin.h>
#include <sch_text.h>
#include <settings/color_settings.h>
#include <settings/common_settings.h>

View File

@ -32,6 +32,7 @@
#include <sch_marker.h>
#include <sch_reference_list.h>
#include <sch_sheet.h>
#include <sch_sheet_pin.h>
#include <schematic.h>
#include <drawing_sheet/ds_draw_item.h>
#include <drawing_sheet/ds_proxy_view_item.h>

View File

@ -55,6 +55,7 @@
#include <sch_marker.h>
#include <sch_no_connect.h>
#include <sch_sheet.h>
#include <sch_sheet_pin.h>
#include <sch_text.h>
#include <schematic.h>
#include <settings/color_settings.h>

View File

@ -50,6 +50,7 @@
#include <sch_no_connect.h>
#include <sch_screen.h>
#include <sch_sheet.h>
#include <sch_sheet_pin.h>
#include <sch_text.h>
#include <bezier_curves.h>

View File

@ -41,6 +41,7 @@
#include <sch_screen.h>
#include <sch_sheet.h>
#include <sch_sheet_path.h>
#include <sch_sheet_pin.h>
#include <sch_text.h>
#include <schematic.h>
#include <trigo.h>

View File

@ -49,6 +49,7 @@
#include <sch_junction.h>
#include <sch_no_connect.h>
#include <sch_screen.h>
#include <sch_sheet_pin.h>
#include <sch_plugins/kicad/sch_sexpr_parser.h>
#include <template_fieldnames.h>

View File

@ -40,6 +40,7 @@
#include <sch_no_connect.h>
#include <sch_text.h>
#include <sch_sheet.h>
#include <sch_sheet_pin.h>
#include <schematic.h>
#include <sch_plugins/kicad/sch_sexpr_plugin.h>
#include <sch_screen.h>

View File

@ -50,6 +50,7 @@
#include <sch_no_connect.h>
#include <sch_text.h>
#include <sch_sheet.h>
#include <sch_sheet_pin.h>
#include <sch_bitmap.h>
#include <bus_alias.h>
#include <sch_plugins/legacy/sch_legacy_plugin.h>

View File

@ -49,6 +49,7 @@
#include <sch_line.h>
#include <sch_marker.h>
#include <sch_sheet.h>
#include <sch_sheet_pin.h>
#include <sch_text.h>
#include <schematic.h>
#include <symbol_lib_table.h>

View File

@ -34,6 +34,7 @@
#include <math/util.h> // for KiROUND
#include <sch_sheet.h>
#include <sch_sheet_path.h>
#include <sch_sheet_pin.h>
#include <sch_symbol.h>
#include <sch_painter.h>
#include <schematic.h>
@ -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;

View File

@ -25,46 +25,21 @@
#ifndef SCH_SHEEET_H
#define SCH_SHEEET_H
#include <boost/ptr_container/ptr_vector.hpp>
#include <sch_text.h>
#include <sch_field.h>
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 <wxPoint>& 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;

View File

@ -33,6 +33,7 @@
#include <sch_draw_panel.h>
#include <sch_edit_frame.h>
#include <sch_sheet.h>
#include <sch_sheet_pin.h>
#include <sch_painter.h>
#include <trigo.h>

197
eeschema/sch_sheet_pin.h Normal file
View File

@ -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 <sch_text.h>
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 <wxPoint>& 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_

View File

@ -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 <sch_line.h>
#include <sch_bitmap.h>
#include <sch_sheet.h>
#include <sch_sheet_pin.h>
#include <symbol_edit_frame.h>
#include <lib_arc.h>
#include <lib_circle.h>

View File

@ -43,6 +43,7 @@
#include <sch_item.h>
#include <sch_line.h>
#include <sch_sheet.h>
#include <sch_sheet_pin.h>
#include <schematic.h>
#include <tool/tool_event.h>
#include <tool/tool_manager.h>

View File

@ -41,6 +41,7 @@
#include <sch_bus_entry.h>
#include <sch_text.h>
#include <sch_sheet.h>
#include <sch_sheet_pin.h>
#include <sch_bitmap.h>
#include <schematic.h>
#include <class_library.h>

View File

@ -38,6 +38,7 @@
#include <sch_item.h>
#include <sch_symbol.h>
#include <sch_sheet.h>
#include <sch_sheet_pin.h>
#include <sch_text.h>
#include <sch_bitmap.h>
#include <sch_view.h>

View File

@ -44,6 +44,7 @@
#include <sch_line.h>
#include <sch_painter.h>
#include <sch_sheet.h>
#include <sch_sheet_pin.h>
#include <sch_view.h>
#include <schematic.h>
#include <advanced_config.h>

View File

@ -58,6 +58,7 @@
#include <sch_line.h>
#include <sch_screen.h>
#include <sch_sheet.h>
#include <sch_sheet_pin.h>
#include <sch_text.h>
#include <schematic.h>
#include <ee_actions.h>

View File

@ -32,6 +32,7 @@
#include <sch_item.h>
#include <sch_symbol.h>
#include <sch_sheet.h>
#include <sch_sheet_pin.h>
#include <sch_line.h>
#include <sch_edit_frame.h>
#include <eeschema_id.h>

View File

@ -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 <sch_sheet.h>
#include <sch_sheet_pin.h>
#include <schematic.h>
#include "uuid_test_utils.h"