2011-10-12 14:03:43 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-03-23 12:16:27 +00:00
|
|
|
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2015-02-21 08:11:58 +00:00
|
|
|
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
|
2020-03-29 01:12:29 +00:00
|
|
|
* Copyright (C) 1992-2020 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-10-07 14:41:30 +00:00
|
|
|
/**
|
|
|
|
* @file sch_text.cpp
|
2016-03-23 12:16:27 +00:00
|
|
|
* @brief Code for handling schematic texts (texts, labels, hlabels and global labels).
|
2011-10-07 14:41:30 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2020-04-06 13:06:57 +00:00
|
|
|
#include <sch_component.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2018-01-28 18:12:26 +00:00
|
|
|
#include <plotter.h>
|
2020-10-25 04:49:02 +00:00
|
|
|
#include <widgets/msgpanel.h>
|
2016-03-23 12:16:27 +00:00
|
|
|
#include <gal/stroke_font.h>
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
2020-10-24 02:06:42 +00:00
|
|
|
#include <kicad_string.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <sch_text.h>
|
2020-05-13 02:00:37 +00:00
|
|
|
#include <schematic.h>
|
2020-03-06 03:00:30 +00:00
|
|
|
#include <settings/color_settings.h>
|
2020-04-14 12:25:00 +00:00
|
|
|
#include <sch_painter.h>
|
|
|
|
#include <default_values.h>
|
2019-09-06 20:15:14 +00:00
|
|
|
#include <wx/debug.h>
|
2020-10-25 13:14:52 +00:00
|
|
|
#include <dialogs/html_messagebox.h>
|
2020-07-07 10:17:30 +00:00
|
|
|
#include <project/project_file.h>
|
|
|
|
#include <project/net_settings.h>
|
2020-11-18 01:21:04 +00:00
|
|
|
#include <core/mirror.h>
|
2020-10-04 17:49:21 +00:00
|
|
|
#include <dialog_helpers.h>
|
2020-10-14 03:37:48 +00:00
|
|
|
#include <trigo.h>
|
2011-07-03 18:51:07 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
using KIGFX::SCH_RENDER_SETTINGS;
|
|
|
|
|
|
|
|
|
2020-12-04 12:48:32 +00:00
|
|
|
bool IncrementLabelMember( wxString& name, int aIncrement )
|
2020-05-27 11:13:57 +00:00
|
|
|
{
|
|
|
|
int ii, nn;
|
|
|
|
long number = 0;
|
|
|
|
|
2020-12-04 12:48:32 +00:00
|
|
|
ii = name.Len() - 1;
|
|
|
|
nn = 0;
|
|
|
|
|
|
|
|
// No number found, but simply repeating the same label is valid
|
2020-05-27 11:13:57 +00:00
|
|
|
|
|
|
|
if( !wxIsdigit( name.GetChar( ii ) ) )
|
2020-12-04 12:48:32 +00:00
|
|
|
return true;
|
2020-05-27 11:13:57 +00:00
|
|
|
|
|
|
|
while( ii >= 0 && wxIsdigit( name.GetChar( ii ) ) )
|
|
|
|
{
|
|
|
|
ii--;
|
|
|
|
nn++;
|
|
|
|
}
|
|
|
|
|
2020-12-04 12:48:32 +00:00
|
|
|
ii++; /* digits are starting at ii position */
|
2020-05-27 11:13:57 +00:00
|
|
|
wxString litt_number = name.Right( nn );
|
|
|
|
|
|
|
|
if( litt_number.ToLong( &number ) )
|
|
|
|
{
|
|
|
|
number += aIncrement;
|
2020-12-04 12:48:32 +00:00
|
|
|
|
|
|
|
// Don't let result go below zero
|
|
|
|
|
|
|
|
if( number > -1 )
|
|
|
|
{
|
|
|
|
name.Remove( ii );
|
|
|
|
name << number;
|
|
|
|
return true;
|
|
|
|
}
|
2020-05-27 11:13:57 +00:00
|
|
|
}
|
2020-12-04 12:48:32 +00:00
|
|
|
return false;
|
2020-05-27 11:13:57 +00:00
|
|
|
}
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-05-05 17:32:07 +00:00
|
|
|
/* Coding polygons for global symbol graphic shapes.
|
|
|
|
* the first parml is the number of corners
|
|
|
|
* others are the corners coordinates in reduced units
|
|
|
|
* the real coordinate is the reduced coordinate * text half size
|
|
|
|
*/
|
2009-05-12 12:12:34 +00:00
|
|
|
static int TemplateIN_HN[] = { 6, 0, 0, -1, -1, -2, -1, -2, 1, -1, 1, 0, 0 };
|
|
|
|
static int TemplateIN_HI[] = { 6, 0, 0, 1, 1, 2, 1, 2, -1, 1, -1, 0, 0 };
|
|
|
|
static int TemplateIN_UP[] = { 6, 0, 0, 1, -1, 1, -2, -1, -2, -1, -1, 0, 0 };
|
|
|
|
static int TemplateIN_BOTTOM[] = { 6, 0, 0, 1, 1, 1, 2, -1, 2, -1, 1, 0, 0 };
|
|
|
|
|
|
|
|
static int TemplateOUT_HN[] = { 6, -2, 0, -1, 1, 0, 1, 0, -1, -1, -1, -2, 0 };
|
|
|
|
static int TemplateOUT_HI[] = { 6, 2, 0, 1, -1, 0, -1, 0, 1, 1, 1, 2, 0 };
|
|
|
|
static int TemplateOUT_UP[] = { 6, 0, -2, 1, -1, 1, 0, -1, 0, -1, -1, 0, -2 };
|
|
|
|
static int TemplateOUT_BOTTOM[] = { 6, 0, 2, 1, 1, 1, 0, -1, 0, -1, 1, 0, 2 };
|
|
|
|
|
|
|
|
static int TemplateUNSPC_HN[] = { 5, 0, -1, -2, -1, -2, 1, 0, 1, 0, -1 };
|
|
|
|
static int TemplateUNSPC_HI[] = { 5, 0, -1, 2, -1, 2, 1, 0, 1, 0, -1 };
|
|
|
|
static int TemplateUNSPC_UP[] = { 5, 1, 0, 1, -2, -1, -2, -1, 0, 1, 0 };
|
|
|
|
static int TemplateUNSPC_BOTTOM[] = { 5, 1, 0, 1, 2, -1, 2, -1, 0, 1, 0 };
|
|
|
|
|
|
|
|
static int TemplateBIDI_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
|
|
|
|
static int TemplateBIDI_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
|
|
|
|
static int TemplateBIDI_UP[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
|
|
|
|
static int TemplateBIDI_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
|
|
|
|
|
|
|
|
static int Template3STATE_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
|
|
|
|
static int Template3STATE_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
|
|
|
|
static int Template3STATE_UP[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
|
|
|
|
static int Template3STATE_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
|
|
|
|
|
|
|
|
static int* TemplateShape[5][4] =
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2010-11-03 14:13:15 +00:00
|
|
|
{ TemplateIN_HN, TemplateIN_UP, TemplateIN_HI, TemplateIN_BOTTOM },
|
|
|
|
{ TemplateOUT_HN, TemplateOUT_UP, TemplateOUT_HI, TemplateOUT_BOTTOM },
|
|
|
|
{ TemplateBIDI_HN, TemplateBIDI_UP, TemplateBIDI_HI, TemplateBIDI_BOTTOM },
|
|
|
|
{ Template3STATE_HN, Template3STATE_UP, Template3STATE_HI, Template3STATE_BOTTOM },
|
|
|
|
{ TemplateUNSPC_HN, TemplateUNSPC_UP, TemplateUNSPC_HI, TemplateUNSPC_BOTTOM }
|
2009-04-05 20:49:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-04-18 20:04:41 +00:00
|
|
|
SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
|
2020-04-14 12:25:00 +00:00
|
|
|
SCH_ITEM( NULL, aType ),
|
2020-04-18 20:04:41 +00:00
|
|
|
EDA_TEXT( text ),
|
2020-04-16 13:22:19 +00:00
|
|
|
m_shape( PINSHEETLABEL_SHAPE::PS_INPUT ),
|
|
|
|
m_isDangling( false ),
|
|
|
|
m_connectionType( CONNECTION_TYPE::NONE ),
|
|
|
|
m_spin_style( LABEL_SPIN_STYLE::LEFT )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2020-11-14 14:29:11 +00:00
|
|
|
m_layer = LAYER_NOTES;
|
2017-01-23 20:30:11 +00:00
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
SetTextPos( pos );
|
2017-01-23 20:30:11 +00:00
|
|
|
SetMultilineAllowed( true );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2009-05-05 17:32:07 +00:00
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
SCH_TEXT::SCH_TEXT( const SCH_TEXT& aText ) :
|
2020-04-16 13:22:19 +00:00
|
|
|
SCH_ITEM( aText ),
|
|
|
|
EDA_TEXT( aText ),
|
|
|
|
m_shape( aText.m_shape ),
|
|
|
|
m_isDangling( aText.m_isDangling ),
|
|
|
|
m_connectionType( aText.m_connectionType ),
|
|
|
|
m_spin_style( aText.m_spin_style )
|
|
|
|
{ }
|
2008-01-21 16:21:41 +00:00
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
2012-03-17 14:39:27 +00:00
|
|
|
EDA_ITEM* SCH_TEXT::Clone() const
|
2010-12-21 15:13:09 +00:00
|
|
|
{
|
|
|
|
return new SCH_TEXT( *this );
|
|
|
|
}
|
2007-09-01 12:00:30 +00:00
|
|
|
|
|
|
|
|
2020-12-04 12:48:32 +00:00
|
|
|
bool SCH_TEXT::IncrementLabel( int aIncrement )
|
2010-12-21 15:13:09 +00:00
|
|
|
{
|
2019-08-02 00:10:25 +00:00
|
|
|
wxString text = GetText();
|
2020-12-04 12:48:32 +00:00
|
|
|
bool ReturnVal = IncrementLabelMember( text, aIncrement );
|
|
|
|
|
|
|
|
if( ReturnVal )
|
|
|
|
SetText( text );
|
|
|
|
|
|
|
|
return ReturnVal;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-20 18:18:54 +00:00
|
|
|
wxPoint SCH_TEXT::GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const
|
2009-05-12 12:12:34 +00:00
|
|
|
{
|
|
|
|
wxPoint text_offset;
|
|
|
|
|
2018-09-16 10:42:28 +00:00
|
|
|
// add an offset to x (or y) position to aid readability of text on a wire or line
|
2020-04-14 12:25:00 +00:00
|
|
|
int dist = GetTextOffset( aSettings ) + GetPenWidth();
|
2016-04-16 07:49:17 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
switch( GetLabelSpinStyle() )
|
2009-05-12 12:12:34 +00:00
|
|
|
{
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::UP:
|
|
|
|
case LABEL_SPIN_STYLE::BOTTOM:
|
2020-04-14 12:25:00 +00:00
|
|
|
text_offset.x = -dist;
|
2020-01-08 19:07:55 +00:00
|
|
|
break; // Vert Orientation
|
2009-05-12 12:12:34 +00:00
|
|
|
default:
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::LEFT:
|
|
|
|
case LABEL_SPIN_STYLE::RIGHT:
|
2020-04-14 12:25:00 +00:00
|
|
|
text_offset.y = -dist;
|
2020-01-08 19:07:55 +00:00
|
|
|
break; // Horiz Orientation
|
2009-05-12 12:12:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return text_offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_TEXT::MirrorY( int aYaxis_position )
|
2009-07-27 14:32:40 +00:00
|
|
|
{
|
2013-03-01 19:59:29 +00:00
|
|
|
// Text is NOT really mirrored; it is moved to a suitable horizontal position
|
2020-01-08 19:07:55 +00:00
|
|
|
SetLabelSpinStyle( GetLabelSpinStyle().MirrorY() );
|
2010-07-11 16:24:44 +00:00
|
|
|
|
2020-10-26 00:44:22 +00:00
|
|
|
SetTextX( MIRRORVAL( GetTextPos().x, aYaxis_position ) );
|
2009-07-27 14:32:40 +00:00
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_TEXT::MirrorX( int aXaxis_position )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
2013-03-01 19:59:29 +00:00
|
|
|
// Text is NOT really mirrored; it is moved to a suitable vertical position
|
2020-01-08 19:07:55 +00:00
|
|
|
SetLabelSpinStyle( GetLabelSpinStyle().MirrorX() );
|
2015-06-26 13:41:56 +00:00
|
|
|
|
2020-10-26 00:44:22 +00:00
|
|
|
SetTextY( MIRRORVAL( GetTextPos().y, aXaxis_position ) );
|
2010-09-05 17:01:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_TEXT::Rotate( wxPoint aPosition )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
wxPoint pt = GetTextPos();
|
|
|
|
RotatePoint( &pt, aPosition, 900 );
|
2020-11-24 18:16:03 +00:00
|
|
|
wxPoint offset = pt - GetTextPos();
|
2011-03-03 01:58:12 +00:00
|
|
|
|
2020-11-24 18:16:03 +00:00
|
|
|
Rotate90( false );
|
2017-01-23 20:30:11 +00:00
|
|
|
|
2020-11-24 18:16:03 +00:00
|
|
|
SetTextPos( GetTextPos() + offset );
|
2010-09-05 17:01:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-18 21:40:04 +00:00
|
|
|
void SCH_TEXT::Rotate90( bool aClockwise )
|
|
|
|
{
|
|
|
|
if( aClockwise )
|
|
|
|
SetLabelSpinStyle( GetLabelSpinStyle().RotateCW() );
|
|
|
|
else
|
|
|
|
SetLabelSpinStyle( GetLabelSpinStyle().RotateCCW() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-18 23:34:03 +00:00
|
|
|
void SCH_TEXT::MirrorSpinStyle( bool aLeftRight )
|
|
|
|
{
|
|
|
|
if( aLeftRight )
|
|
|
|
SetLabelSpinStyle( GetLabelSpinStyle().MirrorY() );
|
|
|
|
else
|
|
|
|
SetLabelSpinStyle( GetLabelSpinStyle().MirrorX() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
void SCH_TEXT::SetLabelSpinStyle( LABEL_SPIN_STYLE aSpinStyle )
|
2009-05-12 12:12:34 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
m_spin_style = aSpinStyle;
|
2009-05-12 12:12:34 +00:00
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
// Assume "Right" and Left" mean which side of the anchor the text will be on
|
|
|
|
// Thus we want to left justify text up agaisnt the anchor if we are on the right
|
2017-01-23 20:30:11 +00:00
|
|
|
switch( aSpinStyle )
|
2009-05-12 12:12:34 +00:00
|
|
|
{
|
2010-11-03 14:13:15 +00:00
|
|
|
default:
|
2019-09-06 20:15:14 +00:00
|
|
|
wxASSERT_MSG( 1, "Bad spin style" );
|
2020-01-10 23:14:37 +00:00
|
|
|
break;
|
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::RIGHT: // Horiz Normal Orientation
|
2019-09-06 20:15:14 +00:00
|
|
|
//
|
2020-01-08 19:07:55 +00:00
|
|
|
m_spin_style = LABEL_SPIN_STYLE::RIGHT; // Handle the error spin style by resetting
|
2017-01-23 20:30:11 +00:00
|
|
|
SetTextAngle( TEXT_ANGLE_HORIZ );
|
|
|
|
SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
|
|
|
SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
|
2009-05-12 12:12:34 +00:00
|
|
|
break;
|
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::UP: // Vert Orientation UP
|
2017-01-23 20:30:11 +00:00
|
|
|
SetTextAngle( TEXT_ANGLE_VERT );
|
|
|
|
SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
|
|
|
SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
|
2009-05-12 12:12:34 +00:00
|
|
|
break;
|
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::LEFT: // Horiz Orientation - Right justified
|
2017-01-23 20:30:11 +00:00
|
|
|
SetTextAngle( TEXT_ANGLE_HORIZ );
|
|
|
|
SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
|
|
|
SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
|
2009-05-12 12:12:34 +00:00
|
|
|
break;
|
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::BOTTOM: // Vert Orientation BOTTOM
|
2017-01-23 20:30:11 +00:00
|
|
|
SetTextAngle( TEXT_ANGLE_VERT );
|
|
|
|
SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
|
|
|
SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
|
2009-05-12 12:12:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2011-10-19 20:32:21 +00:00
|
|
|
void SCH_TEXT::SwapData( SCH_ITEM* aItem )
|
2009-07-27 14:32:40 +00:00
|
|
|
{
|
2011-10-19 20:32:21 +00:00
|
|
|
SCH_TEXT* item = (SCH_TEXT*) aItem;
|
|
|
|
|
2020-11-14 14:29:11 +00:00
|
|
|
std::swap( m_layer, item->m_layer );
|
2017-01-27 21:06:18 +00:00
|
|
|
|
|
|
|
std::swap( m_shape, item->m_shape );
|
2015-06-26 13:41:56 +00:00
|
|
|
std::swap( m_isDangling, item->m_isDangling );
|
2017-01-23 20:30:11 +00:00
|
|
|
std::swap( m_spin_style, item->m_spin_style );
|
|
|
|
|
2019-08-02 00:10:25 +00:00
|
|
|
SwapText( *item );
|
2017-01-23 20:30:11 +00:00
|
|
|
SwapEffects( *item );
|
2009-07-27 14:32:40 +00:00
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2020-01-28 15:42:42 +00:00
|
|
|
bool SCH_TEXT::operator<( const SCH_ITEM& aItem ) const
|
|
|
|
{
|
|
|
|
if( Type() != aItem.Type() )
|
|
|
|
return Type() < aItem.Type();
|
|
|
|
|
|
|
|
auto other = static_cast<const SCH_TEXT*>( &aItem );
|
|
|
|
|
2020-01-28 20:33:23 +00:00
|
|
|
if( GetLayer() != other->GetLayer() )
|
|
|
|
return GetLayer() < other->GetLayer();
|
2020-01-28 15:42:42 +00:00
|
|
|
|
|
|
|
if( GetPosition().x != other->GetPosition().x )
|
|
|
|
return GetPosition().x < other->GetPosition().x;
|
|
|
|
|
|
|
|
if( GetPosition().y != other->GetPosition().y )
|
|
|
|
return GetPosition().y < other->GetPosition().y;
|
|
|
|
|
|
|
|
return GetText() < other->GetText();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-20 18:18:54 +00:00
|
|
|
int SCH_TEXT::GetTextOffset( const RENDER_SETTINGS* aSettings ) const
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
2020-11-17 16:02:47 +00:00
|
|
|
double ratio;
|
2020-04-14 12:25:00 +00:00
|
|
|
|
2020-11-17 16:02:47 +00:00
|
|
|
if( aSettings )
|
2020-12-20 18:18:54 +00:00
|
|
|
ratio = static_cast<const SCH_RENDER_SETTINGS*>( aSettings )->m_TextOffsetRatio;
|
2020-11-17 16:02:47 +00:00
|
|
|
else if( Schematic() )
|
|
|
|
ratio = Schematic()->Settings().m_TextOffsetRatio;
|
|
|
|
else
|
|
|
|
ratio = DEFAULT_TEXT_OFFSET_RATIO; // For previews (such as in Preferences), etc.
|
|
|
|
|
|
|
|
return KiROUND( ratio * GetTextSize().y );
|
2020-04-14 12:25:00 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_TEXT::GetPenWidth() const
|
|
|
|
{
|
|
|
|
return GetEffectiveTextPenWidth();
|
2010-09-05 17:01:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-20 18:18:54 +00:00
|
|
|
void SCH_TEXT::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
2020-11-14 14:29:11 +00:00
|
|
|
COLOR4D color = aSettings->GetLayerColor( m_layer );
|
2020-04-14 12:25:00 +00:00
|
|
|
wxPoint text_offset = aOffset + GetSchematicTextOffset( aSettings );
|
2017-01-23 20:30:11 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
EDA_TEXT::Print( aSettings, text_offset, color );
|
2010-09-05 17:01:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
void SCH_TEXT::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
2010-11-03 14:13:15 +00:00
|
|
|
// Normal text labels cannot be tested for dangling ends.
|
2010-12-10 19:47:44 +00:00
|
|
|
if( Type() == SCH_TEXT_T )
|
2010-11-03 14:13:15 +00:00
|
|
|
return;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
DANGLING_END_ITEM item( LABEL_END, this, GetTextPos() );
|
2010-11-03 14:13:15 +00:00
|
|
|
aItemList.push_back( item );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-17 02:33:16 +00:00
|
|
|
bool SCH_TEXT::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
|
|
|
|
const SCH_SHEET_PATH* aPath )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
|
|
|
// Normal text labels cannot be tested for dangling ends.
|
2010-12-10 19:47:44 +00:00
|
|
|
if( Type() == SCH_TEXT_T )
|
2010-11-03 14:13:15 +00:00
|
|
|
return false;
|
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
bool previousState = m_isDangling;
|
2020-01-18 20:51:28 +00:00
|
|
|
m_isDangling = true;
|
|
|
|
m_connectionType = CONNECTION_TYPE::NONE;
|
2010-11-03 14:13:15 +00:00
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < aItemList.size(); ii++ )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
2010-11-03 14:13:15 +00:00
|
|
|
DANGLING_END_ITEM& item = aItemList[ii];
|
|
|
|
|
2011-12-06 21:02:21 +00:00
|
|
|
if( item.GetItem() == this )
|
2010-11-03 14:13:15 +00:00
|
|
|
continue;
|
|
|
|
|
2011-12-06 21:02:21 +00:00
|
|
|
switch( item.GetType() )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
|
|
|
case PIN_END:
|
|
|
|
case LABEL_END:
|
|
|
|
case SHEET_LABEL_END:
|
2018-10-24 22:49:51 +00:00
|
|
|
case NO_CONNECT_END:
|
2017-01-23 20:30:11 +00:00
|
|
|
if( GetTextPos() == item.GetPosition() )
|
2019-03-11 21:32:05 +00:00
|
|
|
{
|
2011-12-08 15:45:01 +00:00
|
|
|
m_isDangling = false;
|
2011-12-06 21:02:21 +00:00
|
|
|
|
2020-01-17 02:33:16 +00:00
|
|
|
if( aPath && item.GetType() != PIN_END )
|
|
|
|
m_connected_items[ *aPath ].insert( static_cast<SCH_ITEM*>( item.GetItem() ) );
|
2019-03-11 21:32:05 +00:00
|
|
|
}
|
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
case BUS_START_END:
|
2020-01-18 20:51:28 +00:00
|
|
|
m_connectionType = CONNECTION_TYPE::BUS;
|
2020-04-24 23:44:09 +00:00
|
|
|
KI_FALLTHROUGH;
|
2019-03-11 21:32:05 +00:00
|
|
|
|
|
|
|
case WIRE_START_END:
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
|
|
|
// These schematic items have created 2 DANGLING_END_ITEM one per end. But being
|
|
|
|
// a paranoid programmer, I'll check just in case.
|
|
|
|
ii++;
|
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
wxCHECK_MSG( ii < aItemList.size(), previousState != m_isDangling,
|
2010-11-03 14:13:15 +00:00
|
|
|
wxT( "Dangling end type list overflow. Bad programmer!" ) );
|
|
|
|
|
2020-04-19 16:04:14 +00:00
|
|
|
int accuracy = 1; // We have rounding issues with an accuracy of 0
|
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
DANGLING_END_ITEM & nextItem = aItemList[ii];
|
2020-04-19 16:04:14 +00:00
|
|
|
m_isDangling = !TestSegmentHit( GetTextPos(), item.GetPosition(),
|
|
|
|
nextItem.GetPosition(), accuracy );
|
2019-03-11 21:32:05 +00:00
|
|
|
|
|
|
|
if( !m_isDangling )
|
|
|
|
{
|
2020-01-18 20:51:28 +00:00
|
|
|
if( m_connectionType != CONNECTION_TYPE::BUS )
|
|
|
|
m_connectionType = CONNECTION_TYPE::NET;
|
2019-03-11 21:32:05 +00:00
|
|
|
|
|
|
|
// Add the line to the connected items, since it won't be picked
|
|
|
|
// up by a search of intersecting connection points
|
2020-01-17 02:33:16 +00:00
|
|
|
if( aPath )
|
|
|
|
{
|
|
|
|
auto sch_item = static_cast<SCH_ITEM*>( item.GetItem() );
|
|
|
|
AddConnectionTo( *aPath, sch_item );
|
|
|
|
sch_item->AddConnectionTo( *aPath, this );
|
|
|
|
}
|
2019-03-11 21:32:05 +00:00
|
|
|
}
|
2010-11-03 14:13:15 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-03-30 19:55:26 +00:00
|
|
|
if( !m_isDangling )
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
2010-09-05 17:01:48 +00:00
|
|
|
}
|
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
if( m_isDangling )
|
2020-01-18 20:51:28 +00:00
|
|
|
m_connectionType = CONNECTION_TYPE::NONE;
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
return previousState != m_isDangling;
|
2010-09-05 17:01:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-08 13:27:13 +00:00
|
|
|
std::vector<wxPoint> SCH_TEXT::GetConnectionPoints() const
|
2009-05-12 12:12:34 +00:00
|
|
|
{
|
2010-11-03 14:13:15 +00:00
|
|
|
// Normal text labels do not have connection points. All others do.
|
2010-12-10 19:47:44 +00:00
|
|
|
if( Type() == SCH_TEXT_T )
|
2020-09-08 13:27:13 +00:00
|
|
|
return {};
|
2009-05-12 12:12:34 +00:00
|
|
|
|
2020-09-08 13:27:13 +00:00
|
|
|
return { GetTextPos() };
|
2009-05-12 12:12:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-24 17:48:14 +00:00
|
|
|
const EDA_RECT SCH_TEXT::GetBoundingBox() const
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2020-04-14 12:25:00 +00:00
|
|
|
EDA_RECT rect = GetTextBox();
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2018-09-16 10:42:28 +00:00
|
|
|
if( GetTextAngle() != 0 ) // Rotate rect
|
2008-04-15 19:38:19 +00:00
|
|
|
{
|
2010-11-03 14:13:15 +00:00
|
|
|
wxPoint pos = rect.GetOrigin();
|
|
|
|
wxPoint end = rect.GetEnd();
|
2017-01-23 20:30:11 +00:00
|
|
|
|
|
|
|
RotatePoint( &pos, GetTextPos(), GetTextAngle() );
|
|
|
|
RotatePoint( &end, GetTextPos(), GetTextAngle() );
|
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
rect.SetOrigin( pos );
|
|
|
|
rect.SetEnd( end );
|
2008-04-15 19:38:19 +00:00
|
|
|
}
|
2009-05-12 12:12:34 +00:00
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
rect.Normalize();
|
|
|
|
return rect;
|
2008-04-15 19:38:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-29 01:12:29 +00:00
|
|
|
wxString getElectricalTypeLabel( PINSHEETLABEL_SHAPE aType )
|
|
|
|
{
|
|
|
|
switch( aType )
|
|
|
|
{
|
|
|
|
case PINSHEETLABEL_SHAPE::PS_INPUT: return _( "Input" );
|
|
|
|
case PINSHEETLABEL_SHAPE::PS_OUTPUT: return _( "Output" );
|
|
|
|
case PINSHEETLABEL_SHAPE::PS_BIDI: return _( "Bidirectional" );
|
|
|
|
case PINSHEETLABEL_SHAPE::PS_TRISTATE: return _( "Tri-State" );
|
|
|
|
case PINSHEETLABEL_SHAPE::PS_UNSPECIFIED: return _( "Passive" );
|
|
|
|
default: return wxT( "???" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-27 22:28:36 +00:00
|
|
|
void SCH_TEXT::GetContextualTextVars( wxArrayString* aVars ) const
|
|
|
|
{
|
|
|
|
if( Type() == SCH_GLOBAL_LABEL_T || Type() == SCH_HIER_LABEL_T || Type() == SCH_SHEET_PIN_T )
|
|
|
|
aVars->push_back( wxT( "CONNECTION_TYPE" ) );
|
|
|
|
|
2020-11-14 18:11:28 +00:00
|
|
|
if( Type() == SCH_SHEET_PIN_T && m_parent )
|
|
|
|
static_cast<SCH_SHEET*>( m_parent )->GetContextualTextVars( aVars );
|
2020-05-27 22:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-06 13:06:57 +00:00
|
|
|
wxString SCH_TEXT::GetShownText( int aDepth ) const
|
2020-03-29 01:12:29 +00:00
|
|
|
{
|
2020-04-05 19:51:48 +00:00
|
|
|
std::function<bool( wxString* )> textResolver =
|
2020-04-06 13:06:57 +00:00
|
|
|
[&]( wxString* token ) -> bool
|
2020-04-05 19:51:48 +00:00
|
|
|
{
|
|
|
|
if( ( Type() == SCH_GLOBAL_LABEL_T
|
|
|
|
|| Type() == SCH_HIER_LABEL_T
|
|
|
|
|| Type() == SCH_SHEET_PIN_T )
|
|
|
|
&& token->IsSameAs( wxT( "CONNECTION_TYPE" ) ) )
|
|
|
|
{
|
|
|
|
*token = getElectricalTypeLabel( GetShape() );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-11-14 18:11:28 +00:00
|
|
|
if( Type() == SCH_SHEET_PIN_T && m_parent )
|
2020-04-05 19:51:48 +00:00
|
|
|
{
|
2020-11-14 18:11:28 +00:00
|
|
|
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( m_parent );
|
2020-04-05 19:51:48 +00:00
|
|
|
|
2020-04-06 13:06:57 +00:00
|
|
|
if( sheet->ResolveTextVar( token, aDepth ) )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( Type() == SCH_TEXT_T )
|
|
|
|
{
|
|
|
|
if( token->Contains( ':' ) )
|
2020-04-05 19:51:48 +00:00
|
|
|
{
|
2020-07-29 17:02:39 +00:00
|
|
|
if( Schematic()->ResolveCrossReference( token, aDepth ) )
|
|
|
|
return true;
|
2020-04-05 19:51:48 +00:00
|
|
|
}
|
2020-07-28 12:11:11 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
SCHEMATIC* schematic = Schematic();
|
|
|
|
SCH_SHEET* sheet = schematic ? schematic->CurrentSheet().Last() : nullptr;
|
|
|
|
|
|
|
|
if( sheet && sheet->ResolveTextVar( token, aDepth + 1 ) )
|
|
|
|
return true;
|
|
|
|
}
|
2020-04-05 19:51:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
2020-03-29 01:12:29 +00:00
|
|
|
|
2020-04-24 20:33:59 +00:00
|
|
|
bool processTextVars = false;
|
|
|
|
wxString text = EDA_TEXT::GetShownText( &processTextVars );
|
2020-03-29 01:12:29 +00:00
|
|
|
|
2020-04-24 20:33:59 +00:00
|
|
|
if( processTextVars )
|
|
|
|
{
|
2020-12-20 15:08:43 +00:00
|
|
|
wxCHECK_MSG( Schematic(), wxEmptyString, "No parent SCHEMATIC set for SCH_TEXT!" );
|
2020-05-13 02:00:37 +00:00
|
|
|
|
|
|
|
PROJECT* project = nullptr;
|
2020-03-29 01:12:29 +00:00
|
|
|
|
2020-05-21 02:27:48 +00:00
|
|
|
if( Schematic() )
|
|
|
|
project = &Schematic()->Prj();
|
2020-04-06 13:06:57 +00:00
|
|
|
|
2020-04-24 20:33:59 +00:00
|
|
|
if( aDepth < 10 )
|
2021-01-17 15:47:04 +00:00
|
|
|
text = ExpandTextVars( text, &textResolver, nullptr, project );
|
2020-04-24 20:33:59 +00:00
|
|
|
}
|
2020-04-06 13:06:57 +00:00
|
|
|
|
|
|
|
return text;
|
2020-03-29 01:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
wxString SCH_TEXT::GetSelectMenuText( EDA_UNITS aUnits ) const
|
2010-12-10 19:47:44 +00:00
|
|
|
{
|
2020-10-16 00:39:55 +00:00
|
|
|
return wxString::Format( _( "Graphic Text '%s'" ), ShortenedShownText() );
|
2011-03-25 19:16:05 +00:00
|
|
|
}
|
2010-12-13 15:59:00 +00:00
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2017-02-20 12:20:39 +00:00
|
|
|
BITMAP_DEF SCH_TEXT::GetMenuImage() const
|
|
|
|
{
|
2017-06-02 09:51:11 +00:00
|
|
|
return text_xpm;
|
2017-02-20 12:20:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
bool SCH_TEXT::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
2011-03-25 19:16:05 +00:00
|
|
|
{
|
2013-04-07 18:49:13 +00:00
|
|
|
EDA_RECT bBox = GetBoundingBox();
|
|
|
|
bBox.Inflate( aAccuracy );
|
|
|
|
return bBox.Contains( aPosition );
|
2010-12-10 19:47:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
bool SCH_TEXT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
|
2010-12-10 19:47:44 +00:00
|
|
|
{
|
2013-04-07 18:49:13 +00:00
|
|
|
EDA_RECT bBox = GetBoundingBox();
|
|
|
|
bBox.Inflate( aAccuracy );
|
|
|
|
|
|
|
|
if( aContained )
|
|
|
|
return aRect.Contains( bBox );
|
|
|
|
|
|
|
|
return aRect.Intersects( bBox );
|
2010-12-10 19:47:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_TEXT::Plot( PLOTTER* aPlotter )
|
2011-06-17 13:24:22 +00:00
|
|
|
{
|
2020-12-13 22:42:29 +00:00
|
|
|
static std::vector<wxPoint> s_poly;
|
2011-06-17 13:24:22 +00:00
|
|
|
|
2020-12-13 22:42:29 +00:00
|
|
|
RENDER_SETTINGS* settings = aPlotter->RenderSettings();
|
|
|
|
SCH_CONNECTION* connection = Connection();
|
|
|
|
int layer = ( connection && connection->IsBus() ) ? LAYER_BUS : m_layer;
|
|
|
|
COLOR4D color = settings->GetLayerColor( layer );
|
|
|
|
int penWidth = GetEffectiveTextPenWidth( settings->GetDefaultPenWidth() );
|
|
|
|
|
|
|
|
penWidth = std::max( penWidth, settings->GetMinPenWidth() );
|
2020-04-13 19:55:27 +00:00
|
|
|
aPlotter->SetCurrentLineWidth( penWidth );
|
2011-06-17 13:24:22 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
if( IsMultilineAllowed() )
|
2011-06-17 13:24:22 +00:00
|
|
|
{
|
2013-11-29 08:13:43 +00:00
|
|
|
std::vector<wxPoint> positions;
|
2015-01-15 20:01:53 +00:00
|
|
|
wxArrayString strings_list;
|
|
|
|
wxStringSplit( GetShownText(), strings_list, '\n' );
|
|
|
|
positions.reserve( strings_list.Count() );
|
2011-06-17 13:24:22 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
GetLinePositions( positions, (int) strings_list.Count() );
|
2011-06-17 13:24:22 +00:00
|
|
|
|
2015-01-15 20:01:53 +00:00
|
|
|
for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
|
2011-06-17 13:24:22 +00:00
|
|
|
{
|
2020-04-14 12:25:00 +00:00
|
|
|
wxPoint textpos = positions[ii] + GetSchematicTextOffset( aPlotter->RenderSettings() );
|
2015-01-15 20:01:53 +00:00
|
|
|
wxString& txt = strings_list.Item( ii );
|
2019-05-31 12:15:25 +00:00
|
|
|
aPlotter->Text( textpos, color, txt, GetTextAngle(), GetTextSize(), GetHorizJustify(),
|
2020-04-18 20:04:41 +00:00
|
|
|
GetVertJustify(), penWidth, IsItalic(), IsBold() );
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-14 12:25:00 +00:00
|
|
|
wxPoint textpos = GetTextPos() + GetSchematicTextOffset( aPlotter->RenderSettings() );
|
2017-01-23 20:30:11 +00:00
|
|
|
|
|
|
|
aPlotter->Text( textpos, color, GetShownText(), GetTextAngle(), GetTextSize(),
|
2020-04-18 20:04:41 +00:00
|
|
|
GetHorizJustify(), GetVertJustify(), penWidth, IsItalic(), IsBold() );
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
// Draw graphic symbol for global or hierarchical labels
|
2020-12-13 22:42:29 +00:00
|
|
|
CreateGraphicShape( aPlotter->RenderSettings(), s_poly, GetTextPos() );
|
2011-06-17 13:24:22 +00:00
|
|
|
|
2020-12-13 22:42:29 +00:00
|
|
|
if( s_poly.size() )
|
|
|
|
aPlotter->PlotPoly( s_poly, FILL_TYPE::NO_FILL, penWidth );
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
void SCH_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList )
|
2012-11-20 11:35:09 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
switch( Type() )
|
|
|
|
{
|
2019-05-31 12:15:25 +00:00
|
|
|
case SCH_TEXT_T: msg = _( "Graphic Text" ); break;
|
|
|
|
case SCH_LABEL_T: msg = _( "Label" ); break;
|
|
|
|
case SCH_GLOBAL_LABEL_T: msg = _( "Global Label" ); break;
|
|
|
|
case SCH_HIER_LABEL_T: msg = _( "Hierarchical Label" ); break;
|
|
|
|
case SCH_SHEET_PIN_T: msg = _( "Hierarchical Sheet Pin" ); break;
|
2018-09-16 10:42:28 +00:00
|
|
|
default: return;
|
2012-11-20 11:35:09 +00:00
|
|
|
}
|
|
|
|
|
2020-11-18 15:36:47 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( msg, GetShownText() ) );
|
2012-11-20 11:35:09 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
switch( GetLabelSpinStyle() )
|
2012-11-20 11:35:09 +00:00
|
|
|
{
|
2020-01-11 00:04:01 +00:00
|
|
|
case LABEL_SPIN_STYLE::LEFT: msg = _( "Horizontal left" ); break;
|
|
|
|
case LABEL_SPIN_STYLE::UP: msg = _( "Vertical up" ); break;
|
|
|
|
case LABEL_SPIN_STYLE::RIGHT: msg = _( "Horizontal right" ); break;
|
|
|
|
case LABEL_SPIN_STYLE::BOTTOM: msg = _( "Vertical down" ); break;
|
|
|
|
default: msg = wxT( "???" ); break;
|
2012-11-20 11:35:09 +00:00
|
|
|
}
|
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Orientation" ), msg, BROWN ) );
|
2012-11-20 11:35:09 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };
|
2012-11-20 11:35:09 +00:00
|
|
|
int style = 0;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
if( IsItalic() )
|
2012-11-20 11:35:09 +00:00
|
|
|
style = 1;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
if( IsBold() )
|
2012-11-20 11:35:09 +00:00
|
|
|
style += 2;
|
|
|
|
|
2020-11-18 15:36:47 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Style" ), textStyle[style] ) );
|
2012-11-20 11:35:09 +00:00
|
|
|
|
2019-05-31 12:15:25 +00:00
|
|
|
// Display electrical type if it is relevant
|
|
|
|
if( Type() == SCH_GLOBAL_LABEL_T || Type() == SCH_HIER_LABEL_T || Type() == SCH_SHEET_PIN_T )
|
2012-11-20 11:35:09 +00:00
|
|
|
{
|
2020-03-29 01:12:29 +00:00
|
|
|
msg = getElectricalTypeLabel( GetShape() );
|
2020-11-18 15:36:47 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg ) );
|
2012-11-20 11:35:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Display text size (X or Y value, with are the same value in Eeschema)
|
2020-10-02 20:51:24 +00:00
|
|
|
msg = MessageTextFromValue( aFrame->GetUserUnits(), GetTextWidth() );
|
2020-11-18 15:36:47 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Size" ), msg ) );
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2020-07-07 10:17:30 +00:00
|
|
|
SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( aFrame );
|
2020-05-13 02:00:37 +00:00
|
|
|
|
2020-07-07 10:17:30 +00:00
|
|
|
if( frame )
|
2020-05-13 02:00:37 +00:00
|
|
|
{
|
2020-10-07 14:40:12 +00:00
|
|
|
if( SCH_CONNECTION* conn = Connection() )
|
2020-07-07 10:17:30 +00:00
|
|
|
{
|
|
|
|
conn->AppendInfoToMsgPanel( aList );
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2020-07-07 10:17:30 +00:00
|
|
|
NET_SETTINGS& netSettings = Schematic()->Prj().GetProjectFile().NetSettings();
|
|
|
|
const wxString& netname = conn->Name( true );
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2020-07-07 10:17:30 +00:00
|
|
|
if( netSettings.m_NetClassAssignments.count( netname ) )
|
|
|
|
{
|
|
|
|
const wxString& netclassName = netSettings.m_NetClassAssignments[ netname ];
|
2020-11-18 15:36:47 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Assigned Netclass" ), netclassName ) );
|
2020-07-07 10:17:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-11-20 11:35:09 +00:00
|
|
|
}
|
2011-06-17 13:24:22 +00:00
|
|
|
|
2008-04-22 16:38:23 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
|
2011-12-14 17:25:42 +00:00
|
|
|
void SCH_TEXT::Show( int nestLevel, std::ostream& os ) const
|
2008-04-22 16:38:23 +00:00
|
|
|
{
|
|
|
|
// XML output:
|
|
|
|
wxString s = GetClass();
|
|
|
|
|
|
|
|
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str()
|
2020-11-14 14:29:11 +00:00
|
|
|
<< " layer=\"" << m_layer << '"'
|
2020-01-08 19:07:55 +00:00
|
|
|
<< " shape=\"" << static_cast<int>( m_shape ) << '"'
|
2011-12-08 15:45:01 +00:00
|
|
|
<< " dangling=\"" << m_isDangling << '"'
|
2009-05-05 17:32:07 +00:00
|
|
|
<< '>'
|
2019-08-02 00:10:25 +00:00
|
|
|
<< TO_UTF8( GetText() )
|
2009-05-05 17:32:07 +00:00
|
|
|
<< "</" << s.Lower().mb_str() << ">\n";
|
2008-04-22 16:38:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2020-04-18 20:04:41 +00:00
|
|
|
SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text )
|
|
|
|
: SCH_TEXT( pos, text, SCH_LABEL_T )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2020-11-14 14:29:11 +00:00
|
|
|
m_layer = LAYER_LOCLABEL;
|
2020-01-09 07:52:30 +00:00
|
|
|
m_shape = PINSHEETLABEL_SHAPE::PS_INPUT;
|
2011-12-08 15:45:01 +00:00
|
|
|
m_isDangling = true;
|
2017-01-23 20:30:11 +00:00
|
|
|
SetMultilineAllowed( false );
|
2010-11-03 14:13:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-17 14:39:27 +00:00
|
|
|
EDA_ITEM* SCH_LABEL::Clone() const
|
2008-04-15 19:38:19 +00:00
|
|
|
{
|
2010-12-21 15:13:09 +00:00
|
|
|
return new SCH_LABEL( *this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-25 23:39:58 +00:00
|
|
|
bool SCH_LABEL::IsType( const KICAD_T aScanTypes[] ) const
|
2019-06-30 22:06:34 +00:00
|
|
|
{
|
2021-01-15 21:07:23 +00:00
|
|
|
static KICAD_T wireTypes[] = { SCH_LINE_LOCATE_WIRE_T, SCH_PIN_T, EOT };
|
2019-06-30 22:06:34 +00:00
|
|
|
static KICAD_T busTypes[] = { SCH_LINE_LOCATE_BUS_T, EOT };
|
|
|
|
|
|
|
|
if( SCH_ITEM::IsType( aScanTypes ) )
|
|
|
|
return true;
|
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
wxCHECK_MSG( Schematic(), false, "No parent SCHEMATIC set for SCH_LABEL!" );
|
|
|
|
|
|
|
|
SCH_SHEET_PATH current = Schematic()->CurrentSheet();
|
|
|
|
|
2019-06-30 22:06:34 +00:00
|
|
|
for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
|
|
|
|
{
|
|
|
|
if( *p == SCH_LABEL_LOCATE_WIRE_T )
|
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
wxASSERT( m_connected_items.count( current ) );
|
2020-01-17 02:33:16 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
for( SCH_ITEM* connection : m_connected_items.at( current ) )
|
2019-06-30 22:06:34 +00:00
|
|
|
{
|
|
|
|
if( connection->IsType( wireTypes ) )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( *p == SCH_LABEL_LOCATE_BUS_T )
|
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
wxASSERT( m_connected_items.count( current ) );
|
2020-01-17 02:33:16 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
for( SCH_ITEM* connection : m_connected_items.at( current ) )
|
2019-06-30 22:06:34 +00:00
|
|
|
{
|
|
|
|
if( connection->IsType( busTypes ) )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-24 17:48:14 +00:00
|
|
|
const EDA_RECT SCH_LABEL::GetBoundingBox() const
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2020-04-14 12:25:00 +00:00
|
|
|
EDA_RECT rect = GetTextBox();
|
2020-11-17 16:02:47 +00:00
|
|
|
int margin = GetTextOffset();
|
2020-04-17 11:34:32 +00:00
|
|
|
|
|
|
|
rect.Inflate( margin );
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
if( GetTextAngle() != 0.0 )
|
|
|
|
{
|
|
|
|
// Rotate rect
|
2016-03-23 07:41:47 +00:00
|
|
|
wxPoint pos = rect.GetOrigin();
|
|
|
|
wxPoint end = rect.GetEnd();
|
2017-01-23 20:30:11 +00:00
|
|
|
|
|
|
|
RotatePoint( &pos, GetTextPos(), GetTextAngle() );
|
|
|
|
RotatePoint( &end, GetTextPos(), GetTextAngle() );
|
|
|
|
|
2016-03-23 07:41:47 +00:00
|
|
|
rect.SetOrigin( pos );
|
|
|
|
rect.SetEnd( end );
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2016-03-23 07:41:47 +00:00
|
|
|
rect.Normalize();
|
2010-11-03 14:13:15 +00:00
|
|
|
}
|
|
|
|
|
2016-03-23 07:41:47 +00:00
|
|
|
return rect;
|
2010-11-03 14:13:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
wxString SCH_LABEL::GetSelectMenuText( EDA_UNITS aUnits ) const
|
2010-12-13 15:59:00 +00:00
|
|
|
{
|
2020-09-19 18:53:58 +00:00
|
|
|
return wxString::Format( _( "Label '%s'" ), ShortenedShownText() );
|
2011-03-25 19:16:05 +00:00
|
|
|
}
|
2010-12-13 15:59:00 +00:00
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2017-02-20 12:20:39 +00:00
|
|
|
BITMAP_DEF SCH_LABEL::GetMenuImage() const
|
|
|
|
{
|
|
|
|
return add_line_label_xpm;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-17 16:02:47 +00:00
|
|
|
SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) :
|
|
|
|
SCH_TEXT( pos, text, SCH_GLOBAL_LABEL_T ),
|
|
|
|
m_intersheetRefsField( { 0, 0 }, 0, this )
|
2008-04-15 19:38:19 +00:00
|
|
|
{
|
2020-11-14 14:29:11 +00:00
|
|
|
m_layer = LAYER_GLOBLABEL;
|
2020-01-09 07:52:30 +00:00
|
|
|
m_shape = PINSHEETLABEL_SHAPE::PS_BIDI;
|
2011-12-08 15:45:01 +00:00
|
|
|
m_isDangling = true;
|
2017-01-23 20:30:11 +00:00
|
|
|
SetMultilineAllowed( false );
|
2020-11-17 16:02:47 +00:00
|
|
|
|
2020-11-18 21:40:04 +00:00
|
|
|
SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
|
|
|
|
|
2020-11-17 16:02:47 +00:00
|
|
|
m_intersheetRefsField.SetText( wxT( "${INTERSHEET_REFS}" ) );
|
|
|
|
m_intersheetRefsField.SetLayer( LAYER_GLOBLABEL );
|
2020-11-18 21:40:04 +00:00
|
|
|
m_intersheetRefsField.SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
|
2020-11-17 16:02:47 +00:00
|
|
|
m_fieldsAutoplaced = FIELDS_AUTOPLACED_AUTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCH_GLOBALLABEL::SCH_GLOBALLABEL( const SCH_GLOBALLABEL& aGlobalLabel ) :
|
|
|
|
SCH_TEXT( aGlobalLabel ),
|
|
|
|
m_intersheetRefsField( { 0, 0 }, 0, this )
|
|
|
|
{
|
|
|
|
m_intersheetRefsField = aGlobalLabel.m_intersheetRefsField;
|
|
|
|
|
|
|
|
// Re-parent the fields, which before this had aGlobalLabel as parent
|
|
|
|
m_intersheetRefsField.SetParent( this );
|
|
|
|
|
|
|
|
m_fieldsAutoplaced = aGlobalLabel.m_fieldsAutoplaced;
|
2008-04-15 19:38:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-17 14:39:27 +00:00
|
|
|
EDA_ITEM* SCH_GLOBALLABEL::Clone() const
|
2010-12-21 15:13:09 +00:00
|
|
|
{
|
|
|
|
return new SCH_GLOBALLABEL( *this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-17 16:02:47 +00:00
|
|
|
void SCH_GLOBALLABEL::SwapData( SCH_ITEM* aItem )
|
|
|
|
{
|
|
|
|
SCH_TEXT::SwapData( aItem );
|
|
|
|
|
|
|
|
SCH_GLOBALLABEL* globalLabel = static_cast<SCH_GLOBALLABEL*>( aItem );
|
|
|
|
|
|
|
|
// Swap field data wholesale...
|
|
|
|
std::swap( m_intersheetRefsField, globalLabel->m_intersheetRefsField );
|
|
|
|
|
|
|
|
// ...and then reset parent pointers.
|
|
|
|
globalLabel->m_intersheetRefsField.SetParent( globalLabel );
|
|
|
|
m_intersheetRefsField.SetParent( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SEARCH_RESULT SCH_GLOBALLABEL::Visit( INSPECTOR aInspector, void* testData,
|
|
|
|
const KICAD_T aFilterTypes[] )
|
|
|
|
{
|
|
|
|
KICAD_T stype;
|
|
|
|
|
|
|
|
for( const KICAD_T* p = aFilterTypes; (stype = *p) != EOT; ++p )
|
|
|
|
{
|
|
|
|
// If caller wants to inspect my type
|
|
|
|
if( stype == SCH_LOCATE_ANY_T || stype == Type() )
|
|
|
|
{
|
|
|
|
if( SEARCH_RESULT::QUIT == aInspector( this, NULL ) )
|
|
|
|
return SEARCH_RESULT::QUIT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stype == SCH_LOCATE_ANY_T || stype == SCH_FIELD_T )
|
|
|
|
{
|
|
|
|
if( SEARCH_RESULT::QUIT == aInspector( GetIntersheetRefs(), this ) )
|
|
|
|
return SEARCH_RESULT::QUIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return SEARCH_RESULT::CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_GLOBALLABEL::RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction )
|
|
|
|
{
|
|
|
|
aFunction( &m_intersheetRefsField );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-20 18:18:54 +00:00
|
|
|
wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const
|
2008-04-15 19:38:19 +00:00
|
|
|
{
|
2010-11-03 14:13:15 +00:00
|
|
|
wxPoint text_offset;
|
2020-04-17 11:34:32 +00:00
|
|
|
int dist = GetTextOffset( aSettings );
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
switch( m_shape )
|
2008-04-15 19:38:19 +00:00
|
|
|
{
|
2020-01-09 07:52:30 +00:00
|
|
|
case PINSHEETLABEL_SHAPE::PS_INPUT:
|
|
|
|
case PINSHEETLABEL_SHAPE::PS_BIDI:
|
|
|
|
case PINSHEETLABEL_SHAPE::PS_TRISTATE:
|
2020-04-17 11:34:32 +00:00
|
|
|
dist += GetTextHeight() * 3 / 4; // Use three-quarters-height as proxy for triangle size
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
|
|
|
|
2020-01-09 07:52:30 +00:00
|
|
|
case PINSHEETLABEL_SHAPE::PS_OUTPUT:
|
|
|
|
case PINSHEETLABEL_SHAPE::PS_UNSPECIFIED:
|
2010-11-03 14:13:15 +00:00
|
|
|
default:
|
|
|
|
break;
|
2008-04-15 19:38:19 +00:00
|
|
|
}
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
switch( GetLabelSpinStyle() )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2018-09-16 10:42:28 +00:00
|
|
|
default:
|
2020-04-14 12:25:00 +00:00
|
|
|
case LABEL_SPIN_STYLE::LEFT: text_offset.x -= dist; break;
|
|
|
|
case LABEL_SPIN_STYLE::UP: text_offset.y -= dist; break;
|
|
|
|
case LABEL_SPIN_STYLE::RIGHT: text_offset.x += dist; break;
|
|
|
|
case LABEL_SPIN_STYLE::BOTTOM: text_offset.y += dist; break;
|
2010-11-03 14:13:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return text_offset;
|
2008-04-15 19:38:19 +00:00
|
|
|
}
|
|
|
|
|
2009-05-05 17:32:07 +00:00
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
void SCH_GLOBALLABEL::SetLabelSpinStyle( LABEL_SPIN_STYLE aSpinStyle )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
m_spin_style = aSpinStyle;
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
switch( aSpinStyle )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
|
|
|
default:
|
2019-09-06 20:15:14 +00:00
|
|
|
wxASSERT_MSG( 1, "Bad spin style" );
|
2020-11-18 21:40:04 +00:00
|
|
|
m_spin_style = LABEL_SPIN_STYLE::RIGHT;
|
|
|
|
KI_FALLTHROUGH;
|
2020-01-10 23:14:37 +00:00
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::RIGHT: // Horiz Normal Orientation
|
2017-01-23 20:30:11 +00:00
|
|
|
SetTextAngle( TEXT_ANGLE_HORIZ );
|
2020-01-08 19:07:55 +00:00
|
|
|
SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::UP: // Vert Orientation UP
|
2017-01-23 20:30:11 +00:00
|
|
|
SetTextAngle( TEXT_ANGLE_VERT );
|
|
|
|
SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
2010-07-11 16:24:44 +00:00
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::LEFT: // Horiz Orientation
|
2017-01-23 20:30:11 +00:00
|
|
|
SetTextAngle( TEXT_ANGLE_HORIZ );
|
2020-01-08 19:07:55 +00:00
|
|
|
SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
2009-05-05 17:32:07 +00:00
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::BOTTOM: // Vert Orientation BOTTOM
|
2017-01-23 20:30:11 +00:00
|
|
|
SetTextAngle( TEXT_ANGLE_VERT );
|
|
|
|
SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-01-31 18:08:47 +00:00
|
|
|
}
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
|
2020-11-21 23:44:26 +00:00
|
|
|
void SCH_GLOBALLABEL::Rotate( wxPoint aPosition )
|
|
|
|
{
|
|
|
|
wxPoint pt = GetTextPos();
|
|
|
|
RotatePoint( &pt, aPosition, 900 );
|
|
|
|
wxPoint offset = pt - GetTextPos();
|
|
|
|
|
|
|
|
Rotate90( false );
|
|
|
|
|
|
|
|
SetTextPos( GetTextPos() + offset );
|
|
|
|
m_intersheetRefsField.SetTextPos( m_intersheetRefsField.GetTextPos() + offset );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-18 21:40:04 +00:00
|
|
|
void SCH_GLOBALLABEL::Rotate90( bool aClockwise )
|
|
|
|
{
|
|
|
|
SCH_TEXT::Rotate90( aClockwise );
|
|
|
|
|
|
|
|
if( m_intersheetRefsField.GetTextAngle() == TEXT_ANGLE_VERT
|
|
|
|
&& m_intersheetRefsField.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
|
|
|
|
{
|
|
|
|
if( !aClockwise )
|
|
|
|
m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
|
|
|
|
|
|
|
m_intersheetRefsField.SetTextAngle( TEXT_ANGLE_HORIZ );
|
|
|
|
}
|
|
|
|
else if( m_intersheetRefsField.GetTextAngle() == TEXT_ANGLE_VERT
|
|
|
|
&& m_intersheetRefsField.GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
|
|
|
|
{
|
|
|
|
if( !aClockwise )
|
|
|
|
m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
|
|
|
|
|
|
|
m_intersheetRefsField.SetTextAngle( TEXT_ANGLE_HORIZ );
|
|
|
|
}
|
|
|
|
else if( m_intersheetRefsField.GetTextAngle() == TEXT_ANGLE_HORIZ
|
|
|
|
&& m_intersheetRefsField.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
|
|
|
|
{
|
|
|
|
if( aClockwise )
|
|
|
|
m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
|
|
|
|
|
|
|
m_intersheetRefsField.SetTextAngle( TEXT_ANGLE_VERT );
|
|
|
|
}
|
|
|
|
else if( m_intersheetRefsField.GetTextAngle() == TEXT_ANGLE_HORIZ
|
|
|
|
&& m_intersheetRefsField.GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
|
|
|
|
{
|
|
|
|
if( aClockwise )
|
|
|
|
m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
|
|
|
|
|
|
|
m_intersheetRefsField.SetTextAngle( TEXT_ANGLE_VERT );
|
|
|
|
}
|
|
|
|
|
|
|
|
wxPoint pos = m_intersheetRefsField.GetTextPos();
|
|
|
|
RotatePoint( &pos, GetPosition(), aClockwise ? -900 : 900 );
|
|
|
|
m_intersheetRefsField.SetTextPos( pos );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-18 23:34:03 +00:00
|
|
|
void SCH_GLOBALLABEL::MirrorSpinStyle( bool aLeftRight )
|
|
|
|
{
|
|
|
|
SCH_TEXT::MirrorSpinStyle( aLeftRight );
|
|
|
|
|
|
|
|
if( ( aLeftRight && m_intersheetRefsField.GetTextAngle() == TEXT_ANGLE_HORIZ )
|
|
|
|
|| ( !aLeftRight && m_intersheetRefsField.GetTextAngle() == TEXT_ANGLE_VERT ) )
|
|
|
|
{
|
|
|
|
if( m_intersheetRefsField.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
|
|
|
|
m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
|
|
|
else
|
|
|
|
m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
|
|
|
}
|
|
|
|
|
|
|
|
wxPoint pos = m_intersheetRefsField.GetTextPos();
|
|
|
|
wxPoint delta = GetPosition() - pos;
|
|
|
|
|
|
|
|
if( aLeftRight )
|
|
|
|
pos.x = GetPosition().x + delta.x;
|
|
|
|
else
|
|
|
|
pos.y = GetPosition().y + delta.y;
|
|
|
|
|
|
|
|
m_intersheetRefsField.SetTextPos( pos );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-17 16:02:47 +00:00
|
|
|
void SCH_GLOBALLABEL::UpdateIntersheetRefProps()
|
|
|
|
{
|
|
|
|
m_intersheetRefsField.SetTextSize( GetTextSize() );
|
|
|
|
m_intersheetRefsField.SetItalic( IsItalic() );
|
|
|
|
m_intersheetRefsField.SetBold( IsBold() );
|
|
|
|
m_intersheetRefsField.SetTextThickness( GetTextThickness() );
|
|
|
|
|
|
|
|
if( m_fieldsAutoplaced == FIELDS_AUTOPLACED_AUTO )
|
|
|
|
AutoplaceFields( nullptr, false );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_GLOBALLABEL::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
|
|
|
|
{
|
|
|
|
int margin = GetTextOffset();
|
|
|
|
int labelLen = GetBoundingBox().GetSizeMax();
|
|
|
|
int penOffset = GetPenWidth() / 2;
|
|
|
|
|
|
|
|
// Set both axes to penOffset; we're going to overwrite the text axis below
|
|
|
|
wxPoint offset( -penOffset, -penOffset );
|
|
|
|
|
|
|
|
switch( GetLabelSpinStyle() )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case LABEL_SPIN_STYLE::LEFT:
|
|
|
|
m_intersheetRefsField.SetTextAngle( TEXT_ANGLE_HORIZ );
|
|
|
|
m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
|
|
|
offset.x = - ( labelLen + margin / 2 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LABEL_SPIN_STYLE::UP:
|
|
|
|
m_intersheetRefsField.SetTextAngle( TEXT_ANGLE_VERT );
|
|
|
|
m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
|
|
|
offset.y = - ( labelLen + margin / 2 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LABEL_SPIN_STYLE::RIGHT:
|
|
|
|
m_intersheetRefsField.SetTextAngle( TEXT_ANGLE_HORIZ );
|
|
|
|
m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
|
|
|
offset.x = labelLen + margin /2 ;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LABEL_SPIN_STYLE::BOTTOM:
|
|
|
|
m_intersheetRefsField.SetTextAngle( TEXT_ANGLE_VERT );
|
|
|
|
m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
|
|
|
offset.y = labelLen + margin / 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_intersheetRefsField.SetTextPos( GetPosition() + offset );
|
|
|
|
|
|
|
|
m_fieldsAutoplaced = FIELDS_AUTOPLACED_AUTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_GLOBALLABEL::ResolveTextVar( wxString* token, int aDepth ) const
|
|
|
|
{
|
|
|
|
if( token->IsSameAs( wxT( "INTERSHEET_REFS" ) ) && Schematic() )
|
|
|
|
{
|
|
|
|
auto it = Schematic()->GetPageRefsMap().find( GetText() );
|
|
|
|
|
|
|
|
if( it != Schematic()->GetPageRefsMap().end() )
|
|
|
|
{
|
|
|
|
SCHEMATIC_SETTINGS& settings = Schematic()->Settings();
|
|
|
|
std::vector<wxString> pageListCopy;
|
|
|
|
|
|
|
|
pageListCopy.insert( pageListCopy.end(), it->second.begin(), it->second.end() );
|
|
|
|
std::sort( pageListCopy.begin(), pageListCopy.end() );
|
|
|
|
|
|
|
|
token->Printf( "%s", settings.m_IntersheetRefsPrefix );
|
|
|
|
|
|
|
|
if( ( settings.m_IntersheetRefsFormatShort ) && ( pageListCopy.size() > 2 ) )
|
|
|
|
{
|
|
|
|
token->Append( wxString::Format( wxT( "%s..%s" ),
|
|
|
|
pageListCopy.front(),
|
|
|
|
pageListCopy.back() ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for( const wxString& pageNo : pageListCopy )
|
|
|
|
token->Append( wxString::Format( wxT( "%s," ), pageNo ) );
|
|
|
|
|
2020-12-17 14:18:27 +00:00
|
|
|
if( !token->IsEmpty() && token->Last() == ',' )
|
2020-11-17 16:02:47 +00:00
|
|
|
token->RemoveLast();
|
|
|
|
}
|
|
|
|
|
|
|
|
token->Append( settings.m_IntersheetRefsSuffix );
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-20 18:18:54 +00:00
|
|
|
void SCH_GLOBALLABEL::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2020-12-13 22:42:29 +00:00
|
|
|
static std::vector<wxPoint> s_poly;
|
2020-04-04 20:32:14 +00:00
|
|
|
|
2020-12-13 22:42:29 +00:00
|
|
|
SCH_CONNECTION* connection = Connection();
|
|
|
|
int layer = ( connection && connection->IsBus() ) ? LAYER_BUS : m_layer;
|
|
|
|
wxDC* DC = aSettings->GetPrintDC();
|
|
|
|
COLOR4D color = aSettings->GetLayerColor( layer );
|
|
|
|
int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
|
|
|
|
wxPoint text_offset = aOffset + GetSchematicTextOffset( aSettings );
|
2017-01-23 20:30:11 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
EDA_TEXT::Print( aSettings, text_offset, color );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2020-12-13 22:42:29 +00:00
|
|
|
CreateGraphicShape( aSettings, s_poly, GetTextPos() + aOffset );
|
|
|
|
GRPoly( nullptr, DC, s_poly.size(), &s_poly[0], false, penWidth, color, color );
|
2020-12-04 14:48:48 +00:00
|
|
|
|
2020-12-13 22:42:29 +00:00
|
|
|
if( Schematic()->Settings().m_IntersheetRefsShow )
|
2020-11-23 13:29:40 +00:00
|
|
|
m_intersheetRefsField.Print( aSettings, aOffset );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2008-02-20 19:37:17 +00:00
|
|
|
|
2020-11-23 13:29:40 +00:00
|
|
|
void SCH_GLOBALLABEL::Plot( PLOTTER* aPlotter )
|
|
|
|
{
|
|
|
|
SCH_TEXT::Plot( aPlotter );
|
|
|
|
|
|
|
|
bool show = Schematic()->Settings().m_IntersheetRefsShow;
|
2020-12-04 14:48:48 +00:00
|
|
|
|
2020-11-23 13:29:40 +00:00
|
|
|
if ( show )
|
|
|
|
m_intersheetRefsField.Plot( aPlotter );
|
|
|
|
}
|
2008-02-20 19:37:17 +00:00
|
|
|
|
2020-12-20 18:18:54 +00:00
|
|
|
void SCH_GLOBALLABEL::CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings,
|
2020-04-17 11:34:32 +00:00
|
|
|
std::vector<wxPoint>& aPoints, const wxPoint& Pos )
|
2008-02-20 19:37:17 +00:00
|
|
|
{
|
2020-04-17 11:34:32 +00:00
|
|
|
int margin = GetTextOffset( aRenderSettings );
|
|
|
|
int halfSize = ( GetTextHeight() / 2 ) + margin;
|
2020-04-14 12:25:00 +00:00
|
|
|
int linewidth = GetPenWidth();
|
2020-04-18 20:04:41 +00:00
|
|
|
int symb_len = LenSize( GetShownText(), linewidth ) + 2 * margin;
|
2008-12-29 18:02:54 +00:00
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
int x = symb_len + linewidth + 3;
|
2020-05-05 15:52:12 +00:00
|
|
|
int y = halfSize + linewidth + 3;
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2020-04-17 11:34:32 +00:00
|
|
|
aPoints.clear();
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2020-04-17 11:34:32 +00:00
|
|
|
// Create outline shape : 6 points
|
2019-07-10 10:59:09 +00:00
|
|
|
aPoints.emplace_back( wxPoint( 0, 0 ) );
|
|
|
|
aPoints.emplace_back( wxPoint( 0, -y ) ); // Up
|
|
|
|
aPoints.emplace_back( wxPoint( -x, -y ) ); // left
|
|
|
|
aPoints.emplace_back( wxPoint( -x, 0 ) ); // Up left
|
|
|
|
aPoints.emplace_back( wxPoint( -x, y ) ); // left down
|
|
|
|
aPoints.emplace_back( wxPoint( 0, y ) ); // down
|
2010-11-03 14:13:15 +00:00
|
|
|
|
|
|
|
int x_offset = 0;
|
2008-02-20 19:37:17 +00:00
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
switch( m_shape )
|
2010-09-11 16:33:43 +00:00
|
|
|
{
|
2020-01-09 07:52:30 +00:00
|
|
|
case PINSHEETLABEL_SHAPE::PS_INPUT:
|
2016-03-23 07:41:47 +00:00
|
|
|
x_offset = -halfSize;
|
|
|
|
aPoints[0].x += halfSize;
|
2010-09-11 16:33:43 +00:00
|
|
|
break;
|
|
|
|
|
2020-01-09 07:52:30 +00:00
|
|
|
case PINSHEETLABEL_SHAPE::PS_OUTPUT:
|
2016-03-23 07:41:47 +00:00
|
|
|
aPoints[3].x -= halfSize;
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
|
|
|
|
2020-01-09 07:52:30 +00:00
|
|
|
case PINSHEETLABEL_SHAPE::PS_BIDI:
|
|
|
|
case PINSHEETLABEL_SHAPE::PS_TRISTATE:
|
2016-03-23 07:41:47 +00:00
|
|
|
x_offset = -halfSize;
|
|
|
|
aPoints[0].x += halfSize;
|
|
|
|
aPoints[3].x -= halfSize;
|
2010-09-11 16:33:43 +00:00
|
|
|
break;
|
|
|
|
|
2020-01-09 07:52:30 +00:00
|
|
|
case PINSHEETLABEL_SHAPE::PS_UNSPECIFIED:
|
2010-09-11 16:33:43 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2010-11-03 14:13:15 +00:00
|
|
|
|
|
|
|
int angle = 0;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
switch( GetLabelSpinStyle() )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2018-09-16 10:42:28 +00:00
|
|
|
default:
|
2020-04-14 12:25:00 +00:00
|
|
|
case LABEL_SPIN_STYLE::LEFT: break;
|
|
|
|
case LABEL_SPIN_STYLE::UP: angle = -900; break;
|
|
|
|
case LABEL_SPIN_STYLE::RIGHT: angle = 1800; break;
|
|
|
|
case LABEL_SPIN_STYLE::BOTTOM: angle = 900; break;
|
2010-11-03 14:13:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Rotate outlines and move corners in real position
|
2018-09-16 10:42:28 +00:00
|
|
|
for( wxPoint& aPoint : aPoints )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2018-09-16 10:42:28 +00:00
|
|
|
aPoint.x += x_offset;
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
if( angle )
|
2018-09-16 10:42:28 +00:00
|
|
|
RotatePoint( &aPoint, angle );
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2018-09-16 10:42:28 +00:00
|
|
|
aPoint += Pos;
|
2010-11-03 14:13:15 +00:00
|
|
|
}
|
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
aPoints.push_back( aPoints[0] ); // closing
|
2010-09-11 16:33:43 +00:00
|
|
|
}
|
2009-05-05 17:32:07 +00:00
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2013-11-24 17:48:14 +00:00
|
|
|
const EDA_RECT SCH_GLOBALLABEL::GetBoundingBox() const
|
2008-03-30 09:27:53 +00:00
|
|
|
{
|
2020-04-17 11:34:32 +00:00
|
|
|
int x = GetTextPos().x;
|
|
|
|
int y = GetTextPos().y;
|
|
|
|
int penWidth = GetEffectiveTextPenWidth();
|
2020-11-17 16:02:47 +00:00
|
|
|
int margin = GetTextOffset();
|
2020-04-17 11:34:32 +00:00
|
|
|
int height = ( (GetTextHeight() * 15) / 10 ) + penWidth + 2 * margin;
|
2020-04-18 20:04:41 +00:00
|
|
|
int length = LenSize( GetShownText(), penWidth )
|
2020-04-17 11:34:32 +00:00
|
|
|
+ height // add height for triangular shapes
|
|
|
|
+ 2 * margin;
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2020-04-17 11:34:32 +00:00
|
|
|
int dx, dy;
|
2008-03-30 09:27:53 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
switch( GetLabelSpinStyle() ) // respect orientation
|
2008-03-30 09:27:53 +00:00
|
|
|
{
|
2018-09-16 10:42:28 +00:00
|
|
|
default:
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::LEFT:
|
2009-05-05 17:32:07 +00:00
|
|
|
dx = -length;
|
|
|
|
dy = height;
|
2020-04-17 11:34:32 +00:00
|
|
|
x += margin;
|
2009-05-05 17:32:07 +00:00
|
|
|
y -= height / 2;
|
|
|
|
break;
|
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::UP:
|
2009-05-05 17:32:07 +00:00
|
|
|
dx = height;
|
2009-05-12 12:12:34 +00:00
|
|
|
dy = -length;
|
2009-05-05 17:32:07 +00:00
|
|
|
x -= height / 2;
|
2020-04-17 11:34:32 +00:00
|
|
|
y += margin;
|
2009-05-05 17:32:07 +00:00
|
|
|
break;
|
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::RIGHT:
|
2009-05-05 17:32:07 +00:00
|
|
|
dx = length;
|
|
|
|
dy = height;
|
2020-04-17 11:34:32 +00:00
|
|
|
x -= margin;
|
2009-05-05 17:32:07 +00:00
|
|
|
y -= height / 2;
|
|
|
|
break;
|
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::BOTTOM:
|
2010-11-03 14:13:15 +00:00
|
|
|
dx = height;
|
|
|
|
dy = length;
|
|
|
|
x -= height / 2;
|
2020-04-17 11:34:32 +00:00
|
|
|
y -= margin;
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT box( wxPoint( x, y ), wxSize( dx, dy ) );
|
2010-11-03 14:13:15 +00:00
|
|
|
box.Normalize();
|
|
|
|
return box;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
wxString SCH_GLOBALLABEL::GetSelectMenuText( EDA_UNITS aUnits ) const
|
2010-12-13 15:59:00 +00:00
|
|
|
{
|
2020-09-19 18:53:58 +00:00
|
|
|
return wxString::Format( _( "Global Label '%s'" ), ShortenedShownText() );
|
2011-03-25 19:16:05 +00:00
|
|
|
}
|
2010-12-13 15:59:00 +00:00
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2017-02-20 12:20:39 +00:00
|
|
|
BITMAP_DEF SCH_GLOBALLABEL::GetMenuImage() const
|
|
|
|
{
|
|
|
|
return add_glabel_xpm;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-18 20:04:41 +00:00
|
|
|
SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T aType )
|
|
|
|
: SCH_TEXT( pos, text, aType )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2020-11-14 14:29:11 +00:00
|
|
|
m_layer = LAYER_HIERLABEL;
|
2020-01-09 07:52:30 +00:00
|
|
|
m_shape = PINSHEETLABEL_SHAPE::PS_INPUT;
|
2011-12-08 15:45:01 +00:00
|
|
|
m_isDangling = true;
|
2017-01-23 20:30:11 +00:00
|
|
|
SetMultilineAllowed( false );
|
2010-11-03 14:13:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-17 14:39:27 +00:00
|
|
|
EDA_ITEM* SCH_HIERLABEL::Clone() const
|
2010-12-21 15:13:09 +00:00
|
|
|
{
|
|
|
|
return new SCH_HIERLABEL( *this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
void SCH_HIERLABEL::SetLabelSpinStyle( LABEL_SPIN_STYLE aSpinStyle )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
m_spin_style = aSpinStyle;
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
// Assume "Right" and Left" mean which side of the port symbol the text will be on
|
|
|
|
// If we are left of the symbol, we want to right justify to line up with the symbol
|
2017-01-23 20:30:11 +00:00
|
|
|
switch( aSpinStyle )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
|
|
|
default:
|
2020-01-08 19:07:55 +00:00
|
|
|
wxLogWarning( "SetLabelSpinStyle bad spin style" );
|
2020-01-10 23:14:37 +00:00
|
|
|
break;
|
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::LEFT:
|
2019-09-06 20:15:14 +00:00
|
|
|
//
|
2020-01-08 19:07:55 +00:00
|
|
|
m_spin_style = LABEL_SPIN_STYLE::LEFT; // Handle the error spin style by resetting
|
2017-01-23 20:30:11 +00:00
|
|
|
SetTextAngle( TEXT_ANGLE_HORIZ );
|
|
|
|
SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
|
|
|
SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::UP:
|
2017-01-23 20:30:11 +00:00
|
|
|
SetTextAngle( TEXT_ANGLE_VERT );
|
|
|
|
SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
|
|
|
SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::RIGHT:
|
2017-01-23 20:30:11 +00:00
|
|
|
SetTextAngle( TEXT_ANGLE_HORIZ );
|
|
|
|
SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
|
|
|
SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::BOTTOM:
|
2017-01-23 20:30:11 +00:00
|
|
|
SetTextAngle( TEXT_ANGLE_VERT );
|
|
|
|
SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
|
|
|
SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
|
2009-05-05 17:32:07 +00:00
|
|
|
break;
|
2008-03-30 09:27:53 +00:00
|
|
|
}
|
|
|
|
}
|
2008-02-20 19:37:17 +00:00
|
|
|
|
2009-05-05 17:32:07 +00:00
|
|
|
|
2020-12-20 18:18:54 +00:00
|
|
|
void SCH_HIERLABEL::Print( const RENDER_SETTINGS* aSettings, const wxPoint& offset )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
wxCHECK_RET( Schematic(), "No parent SCHEMATIC set for SCH_LABEL!" );
|
|
|
|
|
2009-05-05 17:32:07 +00:00
|
|
|
static std::vector <wxPoint> Poly;
|
2019-05-31 12:15:25 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
wxDC* DC = aSettings->GetPrintDC();
|
2020-10-07 14:40:12 +00:00
|
|
|
SCH_CONNECTION* conn = Connection();
|
2020-04-14 12:25:00 +00:00
|
|
|
bool isBus = conn && conn->IsBus();
|
2020-11-14 14:29:11 +00:00
|
|
|
COLOR4D color = aSettings->GetLayerColor( isBus ? LAYER_BUS : m_layer );
|
2020-04-14 12:25:00 +00:00
|
|
|
int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
|
|
|
|
wxPoint textOffset = offset + GetSchematicTextOffset( aSettings );
|
2008-02-20 19:37:17 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
EDA_TEXT::Print( aSettings, textOffset, color );
|
2017-01-23 20:30:11 +00:00
|
|
|
|
2020-04-17 11:34:32 +00:00
|
|
|
CreateGraphicShape( aSettings, Poly, GetTextPos() + offset );
|
2020-04-14 12:25:00 +00:00
|
|
|
GRPoly( nullptr, DC, Poly.size(), &Poly[0], false, penWidth, color, color );
|
2008-02-20 19:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-20 18:18:54 +00:00
|
|
|
void SCH_HIERLABEL::CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings,
|
2020-04-17 11:34:32 +00:00
|
|
|
std::vector<wxPoint>& aPoints, const wxPoint& Pos )
|
2008-02-20 19:37:17 +00:00
|
|
|
{
|
2020-01-08 19:07:55 +00:00
|
|
|
int* Template = TemplateShape[static_cast<int>( m_shape )][static_cast<int>( m_spin_style )];
|
2020-04-29 14:48:21 +00:00
|
|
|
int halfSize = GetTextHeight() / 2;
|
|
|
|
int imax = *Template;
|
|
|
|
Template++;
|
2009-05-05 17:32:07 +00:00
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
aPoints.clear();
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
for( int ii = 0; ii < imax; ii++ )
|
2008-02-20 19:37:17 +00:00
|
|
|
{
|
2010-11-03 14:13:15 +00:00
|
|
|
wxPoint corner;
|
2016-03-23 07:41:47 +00:00
|
|
|
corner.x = ( halfSize * (*Template) ) + Pos.x;
|
2010-11-03 14:13:15 +00:00
|
|
|
Template++;
|
2008-02-20 19:37:17 +00:00
|
|
|
|
2016-03-23 07:41:47 +00:00
|
|
|
corner.y = ( halfSize * (*Template) ) + Pos.y;
|
2010-11-03 14:13:15 +00:00
|
|
|
Template++;
|
2008-02-20 19:37:17 +00:00
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
aPoints.push_back( corner );
|
2008-02-20 19:37:17 +00:00
|
|
|
}
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2008-03-27 21:24:50 +00:00
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2013-11-24 17:48:14 +00:00
|
|
|
const EDA_RECT SCH_HIERLABEL::GetBoundingBox() const
|
2008-03-30 09:27:53 +00:00
|
|
|
{
|
2020-04-14 12:25:00 +00:00
|
|
|
int penWidth = GetEffectiveTextPenWidth();
|
2020-11-17 16:02:47 +00:00
|
|
|
int margin = GetTextOffset();
|
2020-04-17 11:34:32 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
int x = GetTextPos().x;
|
|
|
|
int y = GetTextPos().y;
|
2008-03-30 09:27:53 +00:00
|
|
|
|
2020-04-17 11:34:32 +00:00
|
|
|
int height = GetTextHeight() + penWidth + 2 * margin;
|
2020-04-18 20:04:41 +00:00
|
|
|
int length = LenSize( GetShownText(), penWidth )
|
2020-04-14 12:25:00 +00:00
|
|
|
+ height // add height for triangular shapes
|
2020-04-17 11:34:32 +00:00
|
|
|
+ 2 * margin;
|
2017-01-23 20:30:11 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
int dx, dy;
|
2008-03-30 09:27:53 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
switch( GetLabelSpinStyle() )
|
2008-03-30 09:27:53 +00:00
|
|
|
{
|
2018-09-16 10:42:28 +00:00
|
|
|
default:
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::LEFT:
|
2009-05-05 17:32:07 +00:00
|
|
|
dx = -length;
|
|
|
|
dy = height;
|
2019-12-30 18:28:00 +00:00
|
|
|
x += Mils2iu( DANGLING_SYMBOL_SIZE );
|
2009-05-05 17:32:07 +00:00
|
|
|
y -= height / 2;
|
|
|
|
break;
|
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::UP:
|
2009-05-05 17:32:07 +00:00
|
|
|
dx = height;
|
2009-05-12 12:12:34 +00:00
|
|
|
dy = -length;
|
2009-05-05 17:32:07 +00:00
|
|
|
x -= height / 2;
|
2019-12-30 18:28:00 +00:00
|
|
|
y += Mils2iu( DANGLING_SYMBOL_SIZE );
|
2009-05-05 17:32:07 +00:00
|
|
|
break;
|
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::RIGHT:
|
2009-05-05 17:32:07 +00:00
|
|
|
dx = length;
|
|
|
|
dy = height;
|
2019-12-30 18:28:00 +00:00
|
|
|
x -= Mils2iu( DANGLING_SYMBOL_SIZE );
|
2009-05-05 17:32:07 +00:00
|
|
|
y -= height / 2;
|
|
|
|
break;
|
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::BOTTOM:
|
2009-05-05 17:32:07 +00:00
|
|
|
dx = height;
|
2009-05-12 12:12:34 +00:00
|
|
|
dy = length;
|
2009-05-05 17:32:07 +00:00
|
|
|
x -= height / 2;
|
2019-12-30 18:28:00 +00:00
|
|
|
y -= Mils2iu( DANGLING_SYMBOL_SIZE );
|
2009-05-05 17:32:07 +00:00
|
|
|
break;
|
2008-03-30 09:27:53 +00:00
|
|
|
}
|
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT box( wxPoint( x, y ), wxSize( dx, dy ) );
|
2008-03-30 09:27:53 +00:00
|
|
|
box.Normalize();
|
|
|
|
return box;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-20 18:18:54 +00:00
|
|
|
wxPoint SCH_HIERLABEL::GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const
|
2009-11-28 09:24:37 +00:00
|
|
|
{
|
2010-11-03 14:13:15 +00:00
|
|
|
wxPoint text_offset;
|
2020-04-17 11:34:32 +00:00
|
|
|
int dist = GetTextOffset( aSettings );
|
2020-04-14 12:25:00 +00:00
|
|
|
|
|
|
|
dist += GetTextWidth();
|
2008-03-27 21:24:50 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
switch( GetLabelSpinStyle() )
|
2008-03-27 21:24:50 +00:00
|
|
|
{
|
2018-09-16 10:42:28 +00:00
|
|
|
default:
|
2020-05-10 21:33:43 +00:00
|
|
|
case LABEL_SPIN_STYLE::LEFT: text_offset.x = -dist; break; // Orientation horiz normale
|
|
|
|
case LABEL_SPIN_STYLE::UP: text_offset.y = -dist; break; // Orientation vert UP
|
|
|
|
case LABEL_SPIN_STYLE::RIGHT: text_offset.x = dist; break; // Orientation horiz inverse
|
|
|
|
case LABEL_SPIN_STYLE::BOTTOM: text_offset.y = dist; break; // Orientation vert BOTTOM
|
2008-03-27 21:24:50 +00:00
|
|
|
}
|
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
return text_offset;
|
2008-03-27 21:24:50 +00:00
|
|
|
}
|
2009-11-28 09:24:37 +00:00
|
|
|
|
2010-07-11 16:24:44 +00:00
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
wxString SCH_HIERLABEL::GetSelectMenuText( EDA_UNITS aUnits ) const
|
2010-12-13 15:59:00 +00:00
|
|
|
{
|
2020-09-19 18:53:58 +00:00
|
|
|
return wxString::Format( _( "Hierarchical Label '%s'" ), ShortenedShownText() );
|
2011-03-25 19:16:05 +00:00
|
|
|
}
|
2017-02-20 12:20:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
BITMAP_DEF SCH_HIERLABEL::GetMenuImage() const
|
|
|
|
{
|
|
|
|
return add_hierarchical_label_xpm;
|
|
|
|
}
|
2020-05-09 20:27:06 +00:00
|
|
|
|
|
|
|
|
2020-09-05 16:00:29 +00:00
|
|
|
HTML_MESSAGE_BOX* SCH_TEXT::ShowSyntaxHelp( wxWindow* aParentWindow )
|
2020-05-09 20:27:06 +00:00
|
|
|
{
|
2020-10-04 17:49:21 +00:00
|
|
|
wxString msg =
|
|
|
|
#include "sch_text_help_md.h"
|
|
|
|
;
|
2020-05-09 20:27:06 +00:00
|
|
|
|
2020-10-20 19:54:28 +00:00
|
|
|
HTML_MESSAGE_BOX* dlg = new HTML_MESSAGE_BOX( nullptr, _( "Syntax Help" ) );
|
2020-11-13 16:14:44 +00:00
|
|
|
wxSize sz( 320, 320 );
|
|
|
|
|
|
|
|
dlg->SetMinSize( dlg->ConvertDialogToPixels( sz ) );
|
|
|
|
dlg->SetDialogSizeInDU( sz.x, sz.y );
|
2020-05-09 20:27:06 +00:00
|
|
|
|
2020-10-04 17:49:21 +00:00
|
|
|
wxString html_txt;
|
|
|
|
ConvertMarkdown2Html( wxGetTranslation( msg ), html_txt );
|
|
|
|
dlg->m_htmlWindow->AppendToPage( html_txt );
|
2020-08-24 22:17:14 +00:00
|
|
|
dlg->ShowModeless();
|
2020-09-05 16:00:29 +00:00
|
|
|
|
|
|
|
return dlg;
|
2020-05-09 20:27:06 +00:00
|
|
|
}
|