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>
|
2016-03-23 12:16:27 +00:00
|
|
|
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-12 14:03:43 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-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
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <macros.h>
|
|
|
|
#include <trigo.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <drawtxt.h>
|
2015-02-21 09:46:44 +00:00
|
|
|
#include <schframe.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <plot_common.h>
|
2013-01-12 17:32:24 +00:00
|
|
|
#include <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>
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <protos.h>
|
|
|
|
#include <sch_text.h>
|
|
|
|
#include <class_netlist_object.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-07-03 18:51:07 +00:00
|
|
|
|
2015-04-22 11:39:00 +00:00
|
|
|
extern void IncrementLabelMember( wxString& name, int aIncrement );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2016-03-25 08:26:11 +00:00
|
|
|
// Only for tests: set DRAW_BBOX to 1 to draw the bounding box of labels
|
|
|
|
#define DRAW_BBOX 0
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2016-04-16 07:49:17 +00:00
|
|
|
// Margin in internal units (mils) between labels and wires
|
|
|
|
#define TXT_MARGIN 4
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
// Names of sheet label types.
|
2009-04-05 20:49:15 +00:00
|
|
|
const char* SheetLabelType[] =
|
|
|
|
{
|
|
|
|
"Input",
|
|
|
|
"Output",
|
|
|
|
"BiDi",
|
|
|
|
"3State",
|
|
|
|
"UnSpc",
|
2013-04-07 11:55:18 +00:00
|
|
|
"???"
|
2009-04-05 20:49:15 +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
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
|
2010-12-21 15:13:09 +00:00
|
|
|
SCH_ITEM( NULL, aType ),
|
2016-02-28 17:33:29 +00:00
|
|
|
EDA_TEXT( text ),
|
|
|
|
m_shape( NET_INPUT )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-05-05 17:32:07 +00:00
|
|
|
m_Layer = LAYER_NOTES;
|
2017-01-23 20:30:11 +00:00
|
|
|
SetTextPos( pos );
|
2011-12-08 15:45:01 +00:00
|
|
|
m_isDangling = false;
|
2017-01-23 20:30:11 +00:00
|
|
|
m_spin_style = 0;
|
|
|
|
|
|
|
|
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 ) :
|
|
|
|
SCH_ITEM( aText ),
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_TEXT( aText )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-12-08 15:45:01 +00:00
|
|
|
m_shape = aText.m_shape;
|
|
|
|
m_isDangling = false;
|
2017-01-27 21:06:18 +00:00
|
|
|
m_spin_style = aText.m_spin_style;
|
2010-12-21 15:13:09 +00:00
|
|
|
}
|
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
|
|
|
|
|
|
|
|
2015-04-22 11:39:00 +00:00
|
|
|
void SCH_TEXT::IncrementLabel( int aIncrement )
|
2010-12-21 15:13:09 +00:00
|
|
|
{
|
2015-04-22 11:39:00 +00:00
|
|
|
IncrementLabelMember( m_Text, aIncrement );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
wxPoint SCH_TEXT::GetSchematicTextOffset() const
|
2009-05-12 12:12:34 +00:00
|
|
|
{
|
|
|
|
wxPoint text_offset;
|
|
|
|
|
2016-04-16 07:49:17 +00:00
|
|
|
// add an offset to x ( or y) position to allow a text to
|
2009-11-03 13:26:31 +00:00
|
|
|
// be on a wire or a line and be readable
|
2016-04-16 07:49:17 +00:00
|
|
|
int thick_offset = TXT_MARGIN +
|
|
|
|
( GetPenSize() + GetDefaultLineThickness() ) / 2;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
switch( GetLabelSpinStyle() )
|
2009-05-12 12:12:34 +00:00
|
|
|
{
|
|
|
|
default:
|
2017-01-23 20:30:11 +00:00
|
|
|
case 0: // Horiz Normal Orientation (left justified)
|
2016-04-16 07:49:17 +00:00
|
|
|
text_offset.y = -thick_offset;
|
2009-05-12 12:12:34 +00:00
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 1: // Vert Orientation UP
|
2016-04-16 07:49:17 +00:00
|
|
|
text_offset.x = -thick_offset;
|
2009-05-12 12:12:34 +00:00
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 2: // Horiz Orientation - Right justified
|
2016-04-16 07:49:17 +00:00
|
|
|
text_offset.y = -thick_offset;
|
2009-05-12 12:12:34 +00:00
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 3: // Vert Orientation BOTTOM
|
2016-04-16 07:49:17 +00:00
|
|
|
text_offset.x = -thick_offset;
|
2009-05-12 12:12:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return text_offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-20 19:43:58 +00:00
|
|
|
bool SCH_TEXT::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint * aFindLocation )
|
2010-03-16 18:22:59 +00:00
|
|
|
{
|
2011-12-13 15:37:33 +00:00
|
|
|
wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText() );
|
2011-12-01 16:49:28 +00:00
|
|
|
|
2010-10-20 19:43:58 +00:00
|
|
|
if( SCH_ITEM::Matches( m_Text, aSearchData ) )
|
|
|
|
{
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT BoundaryBox = GetBoundingBox();
|
2011-10-12 14:03:43 +00:00
|
|
|
|
2010-10-20 19:43:58 +00:00
|
|
|
if( aFindLocation )
|
|
|
|
*aFindLocation = BoundaryBox.Centre();
|
2011-10-12 14:03:43 +00:00
|
|
|
|
2010-10-20 19:43:58 +00:00
|
|
|
return true;
|
|
|
|
}
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
return false;
|
2009-05-12 12:12:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
2017-01-23 20:30:11 +00:00
|
|
|
switch( GetLabelSpinStyle() )
|
2010-07-11 16:24:44 +00:00
|
|
|
{
|
2013-03-01 19:59:29 +00:00
|
|
|
case 0: // horizontal text
|
2017-01-23 20:30:11 +00:00
|
|
|
SetLabelSpinStyle( 2 );
|
2010-07-11 16:24:44 +00:00
|
|
|
break;
|
|
|
|
|
2013-03-01 19:59:29 +00:00
|
|
|
case 2: // invert horizontal text
|
2017-01-23 20:30:11 +00:00
|
|
|
SetLabelSpinStyle( 0 );
|
2010-09-05 17:01:48 +00:00
|
|
|
break;
|
|
|
|
|
2013-03-01 19:59:29 +00:00
|
|
|
case 1: // Vert Orientation UP
|
|
|
|
case 3: // Vert Orientation BOTTOM
|
2010-07-11 16:24:44 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
SetTextX( Mirror( 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
|
2017-01-23 20:30:11 +00:00
|
|
|
switch( GetLabelSpinStyle() )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
2013-03-01 19:59:29 +00:00
|
|
|
case 1: // Vert Orientation UP
|
2017-01-23 20:30:11 +00:00
|
|
|
SetLabelSpinStyle( 3 );
|
2010-09-05 17:01:48 +00:00
|
|
|
break;
|
|
|
|
|
2013-03-01 19:59:29 +00:00
|
|
|
case 3: // Vert Orientation BOTTOM
|
2017-01-23 20:30:11 +00:00
|
|
|
SetLabelSpinStyle( 1 );
|
2010-09-05 17:01:48 +00:00
|
|
|
break;
|
|
|
|
|
2013-03-01 19:59:29 +00:00
|
|
|
case 0: // horizontal text
|
|
|
|
case 2: // invert horizontal text
|
2010-09-05 17:01:48 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2015-06-26 13:41:56 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
SetTextY( Mirror( 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
|
|
|
{
|
|
|
|
int dy;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
wxPoint pt = GetTextPos();
|
|
|
|
RotatePoint( &pt, aPosition, 900 );
|
|
|
|
SetTextPos( pt );
|
2011-03-03 01:58:12 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
SetLabelSpinStyle( (GetLabelSpinStyle() + 1) % 4 );
|
|
|
|
|
|
|
|
switch( GetLabelSpinStyle() )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
2012-09-07 19:29:44 +00:00
|
|
|
case 0: // horizontal text
|
2017-01-23 20:30:11 +00:00
|
|
|
dy = GetTextHeight();
|
2010-09-05 17:01:48 +00:00
|
|
|
break;
|
|
|
|
|
2012-09-07 19:29:44 +00:00
|
|
|
case 1: // Vert Orientation UP
|
2010-09-05 17:01:48 +00:00
|
|
|
dy = 0;
|
|
|
|
break;
|
|
|
|
|
2012-09-07 19:29:44 +00:00
|
|
|
case 2: // invert horizontal text
|
2017-01-23 20:30:11 +00:00
|
|
|
dy = GetTextHeight();
|
2010-09-05 17:01:48 +00:00
|
|
|
break;
|
|
|
|
|
2012-09-07 19:29:44 +00:00
|
|
|
case 3: // Vert Orientation BOTTOM
|
2010-09-05 17:01:48 +00:00
|
|
|
dy = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
dy = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
SetTextY( GetTextPos().y + dy );
|
2010-09-05 17:01:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
void SCH_TEXT::SetLabelSpinStyle( int 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
|
|
|
|
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:
|
2017-01-23 20:30:11 +00:00
|
|
|
case 0: // Horiz Normal Orientation (left justified)
|
|
|
|
SetTextAngle( TEXT_ANGLE_HORIZ );
|
|
|
|
SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
|
|
|
SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
|
2009-05-12 12:12:34 +00:00
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 1: // Vert Orientation UP
|
|
|
|
SetTextAngle( TEXT_ANGLE_VERT );
|
|
|
|
SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
|
|
|
SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
|
2009-05-12 12:12:34 +00:00
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 2: // Horiz Orientation - Right justified
|
|
|
|
SetTextAngle( TEXT_ANGLE_HORIZ );
|
|
|
|
SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
|
|
|
SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
|
2009-05-12 12:12:34 +00:00
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 3: // Vert Orientation BOTTOM
|
|
|
|
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;
|
|
|
|
|
2015-06-26 13:41:56 +00:00
|
|
|
std::swap( m_Text, item->m_Text );
|
|
|
|
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 );
|
|
|
|
|
|
|
|
SwapEffects( *item );
|
2009-07-27 14:32:40 +00:00
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
int SCH_TEXT::GetPenSize() const
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
int pensize = GetThickness();
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
if( pensize == 0 ) // Use default values for pen size
|
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
if( IsBold() )
|
|
|
|
pensize = GetPenSizeForBold( GetTextWidth() );
|
2010-11-03 14:13:15 +00:00
|
|
|
else
|
2012-09-28 17:47:41 +00:00
|
|
|
pensize = GetDefaultLineThickness();
|
2010-09-05 17:01:48 +00:00
|
|
|
}
|
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
// Clip pen size for small texts:
|
2017-01-23 20:30:11 +00:00
|
|
|
pensize = Clamp_Text_PenSize( pensize, GetTextSize(), IsBold() );
|
2010-11-03 14:13:15 +00:00
|
|
|
return pensize;
|
2010-09-05 17:01:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void SCH_TEXT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset,
|
2017-02-20 16:57:41 +00:00
|
|
|
GR_DRAWMODE DrawMode, COLOR4D Color )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
2017-02-20 16:57:41 +00:00
|
|
|
COLOR4D color;
|
2017-01-23 20:30:11 +00:00
|
|
|
int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
|
|
|
|
EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2017-02-20 17:48:27 +00:00
|
|
|
if( Color != COLOR4D::UNSPECIFIED )
|
2012-09-02 12:06:47 +00:00
|
|
|
color = Color;
|
2010-11-03 14:13:15 +00:00
|
|
|
else
|
2016-11-16 10:07:02 +00:00
|
|
|
color = GetLayerColor( GetState( BRIGHTENED ) ? LAYER_BRIGHTENED : m_Layer );
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
GRSetDrawMode( DC, DrawMode );
|
|
|
|
|
|
|
|
wxPoint text_offset = aOffset + GetSchematicTextOffset();
|
2017-01-23 20:30:11 +00:00
|
|
|
|
|
|
|
int savedWidth = GetThickness();
|
|
|
|
SetThickness( linewidth ); // Set the minimum width
|
|
|
|
|
2017-02-20 17:48:27 +00:00
|
|
|
EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, COLOR4D::UNSPECIFIED );
|
2017-01-23 20:30:11 +00:00
|
|
|
|
|
|
|
SetThickness( savedWidth );
|
2011-10-12 14:03:43 +00:00
|
|
|
|
2015-04-02 11:18:19 +00:00
|
|
|
if( m_isDangling && panel)
|
2017-01-23 20:30:11 +00:00
|
|
|
DrawDanglingSymbol( panel, DC, GetTextPos() + aOffset, color );
|
2010-11-03 14:13:15 +00:00
|
|
|
|
|
|
|
// Enable these line to draw the bounding box (debug tests purposes only)
|
2016-03-23 07:41:47 +00:00
|
|
|
#if DRAW_BBOX
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT BoundaryBox = GetBoundingBox();
|
2013-06-29 09:52:22 +00:00
|
|
|
GRRect( clipbox, DC, BoundaryBox, 0, BROWN );
|
2010-11-03 14:13:15 +00:00
|
|
|
}
|
|
|
|
#endif
|
2010-09-05 17:01:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
bool SCH_TEXT::Save( FILE* aFile ) const
|
2009-07-27 14:32:40 +00:00
|
|
|
{
|
2010-11-03 14:13:15 +00:00
|
|
|
bool success = true;
|
|
|
|
const char* shape = "~";
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
if( IsItalic() )
|
2010-11-03 14:13:15 +00:00
|
|
|
shape = "Italic";
|
|
|
|
|
2011-10-05 12:36:32 +00:00
|
|
|
// For compatibility reason, the text must be saved in only one text line
|
|
|
|
// so we replace all E.O.L. by \\n
|
2010-11-03 14:13:15 +00:00
|
|
|
wxString text = m_Text;
|
|
|
|
|
2011-10-05 12:36:32 +00:00
|
|
|
text.Replace( wxT("\n"), wxT( "\\n" ) );
|
2010-07-11 16:24:44 +00:00
|
|
|
|
2011-10-05 12:36:32 +00:00
|
|
|
// Here we should have no CR or LF character in line
|
|
|
|
// This is not always the case if a multiline text was copied (using a copy/paste function)
|
|
|
|
// from a text that uses E.O.L characters that differs from the current EOL format
|
|
|
|
// This is mainly the case under Linux using LF symbol when copying a text from
|
|
|
|
// Windows (using CRLF symbol)
|
|
|
|
// So we must just remove the extra CR left (or LF left under MacOSX)
|
|
|
|
for( unsigned ii = 0; ii < text.Len(); )
|
|
|
|
{
|
|
|
|
if( text[ii] == 0x0A || text[ii] == 0x0D )
|
|
|
|
text.erase( ii, 1 );
|
|
|
|
else
|
|
|
|
ii++;
|
2010-07-11 16:24:44 +00:00
|
|
|
}
|
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
if( fprintf( aFile, "Text Notes %-4d %-4d %-4d %-4d %s %d\n%s\n",
|
2017-01-23 20:30:11 +00:00
|
|
|
GetTextPos().x, GetTextPos().y, GetLabelSpinStyle(), GetTextWidth(),
|
|
|
|
shape, GetThickness(), TO_UTF8( text ) ) == EOF )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
2009-07-27 14:32:40 +00:00
|
|
|
}
|
2009-05-12 12:12:34 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
bool SCH_TEXT::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
char Name1[256];
|
|
|
|
char Name2[256];
|
|
|
|
char Name3[256];
|
|
|
|
int thickness = 0, orient = 0;
|
|
|
|
int x, y, size = 0;
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
Name1[0] = 0; Name2[0] = 0; Name3[0] = 0;
|
|
|
|
|
|
|
|
char* sline = (char*) aLine;
|
|
|
|
|
|
|
|
while( ( *sline != ' ' ) && *sline )
|
|
|
|
sline++;
|
|
|
|
|
|
|
|
// sline points the start of parameters
|
2017-01-23 20:30:11 +00:00
|
|
|
int ii = sscanf( sline, "%255s %d %d %d %d %255s %255s %d", Name1, &x, &y,
|
2010-11-10 15:30:12 +00:00
|
|
|
&orient, &size, Name2, Name3, &thickness );
|
|
|
|
|
|
|
|
if( ii < 4 )
|
|
|
|
{
|
2011-09-30 18:15:37 +00:00
|
|
|
aErrorMsg.Printf( wxT( "Eeschema file text load error at line %d" ),
|
2010-11-10 15:30:12 +00:00
|
|
|
aLine.LineNumber() );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !aLine.ReadLine() )
|
|
|
|
{
|
2011-09-30 18:15:37 +00:00
|
|
|
aErrorMsg.Printf( wxT( "Eeschema file text load error at line %d" ),
|
2010-11-10 15:30:12 +00:00
|
|
|
aLine.LineNumber() );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( size == 0 )
|
2014-05-16 13:57:53 +00:00
|
|
|
size = GetDefaultTextSize();
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
char* text = strtok( (char*) aLine, "\n\r" );
|
|
|
|
|
|
|
|
if( text == NULL )
|
|
|
|
{
|
2011-09-30 18:15:37 +00:00
|
|
|
aErrorMsg.Printf( wxT( "Eeschema file text load error at line %d" ),
|
2010-11-10 15:30:12 +00:00
|
|
|
aLine.LineNumber() );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
wxString val = FROM_UTF8( text );
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2011-03-03 19:08:13 +00:00
|
|
|
for( ; ; )
|
2010-11-10 15:30:12 +00:00
|
|
|
{
|
|
|
|
int i = val.find( wxT( "\\n" ) );
|
|
|
|
|
|
|
|
if( i == wxNOT_FOUND )
|
|
|
|
break;
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
val.erase( i, 2 );
|
|
|
|
val.insert( i, wxT( "\n" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Text = val;
|
2017-01-23 20:30:11 +00:00
|
|
|
|
|
|
|
SetTextSize( wxSize( size, size ) );
|
|
|
|
SetTextPos( wxPoint( x, y ) );
|
|
|
|
|
|
|
|
SetLabelSpinStyle( orient );
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
if( isdigit( Name3[0] ) )
|
|
|
|
{
|
|
|
|
thickness = atol( Name3 );
|
2017-01-23 20:30:11 +00:00
|
|
|
SetBold( thickness != 0 );
|
|
|
|
SetThickness( IsBold() ? GetPenSizeForBold( size ) : 0 );
|
2010-11-10 15:30:12 +00:00
|
|
|
}
|
|
|
|
|
2016-08-11 12:41:06 +00:00
|
|
|
if( strncasecmp( Name2, "Italic", 6 ) == 0 )
|
2017-01-23 20:30:11 +00:00
|
|
|
SetItalic( true );
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_TEXT::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList )
|
|
|
|
{
|
|
|
|
// 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;
|
|
|
|
m_isDangling = true;
|
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:
|
2017-01-23 20:30:11 +00:00
|
|
|
if( GetTextPos() == item.GetPosition() )
|
2011-12-08 15:45:01 +00:00
|
|
|
m_isDangling = false;
|
2011-12-06 21:02:21 +00:00
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
case WIRE_START_END:
|
|
|
|
case BUS_START_END:
|
|
|
|
{
|
|
|
|
// 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!" ) );
|
|
|
|
|
|
|
|
DANGLING_END_ITEM & nextItem = aItemList[ii];
|
2017-01-23 20:30:11 +00:00
|
|
|
m_isDangling = !IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), GetTextPos() );
|
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
|
|
|
}
|
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
return previousState != m_isDangling;
|
2010-09-05 17:01:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
bool SCH_TEXT::IsSelectStateChanged( const wxRect& aRect )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
2010-11-03 14:13:15 +00:00
|
|
|
bool previousState = IsSelected();
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
if( aRect.Contains( GetTextPos() ) )
|
2013-03-30 19:55:26 +00:00
|
|
|
SetFlags( SELECTED );
|
2010-11-03 14:13:15 +00:00
|
|
|
else
|
2015-02-21 08:11:58 +00:00
|
|
|
ClearFlags( SELECTED );
|
2010-11-03 14:13:15 +00:00
|
|
|
|
|
|
|
return previousState != IsSelected();
|
2010-09-05 17:01:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-13 16:27:30 +00:00
|
|
|
void SCH_TEXT::GetConnectionPoints( std::vector< wxPoint >& aPoints ) 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 )
|
2010-11-03 14:13:15 +00:00
|
|
|
return;
|
2009-05-12 12:12:34 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
aPoints.push_back( 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
|
|
|
{
|
|
|
|
// We must pass the effective text thickness to GetTextBox
|
|
|
|
// when calculating the bounding box
|
2017-01-23 20:30:11 +00:00
|
|
|
int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
|
2009-05-12 12:12:34 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT rect = GetTextBox( -1, linewidth );
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
if( GetTextAngle() ) // 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
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
wxString SCH_TEXT::GetSelectMenuText() const
|
2010-12-10 19:47:44 +00:00
|
|
|
{
|
2011-03-26 10:08:50 +00:00
|
|
|
wxString msg;
|
2014-09-13 18:15:45 +00:00
|
|
|
msg.Printf( _( "Graphic Text %s" ), GetChars( ShortenedShownText() ) );
|
2011-03-26 10:08:50 +00:00
|
|
|
return msg;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
void SCH_TEXT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
|
|
|
|
SCH_SHEET_PATH* aSheetPath )
|
2011-10-12 14:03:43 +00:00
|
|
|
{
|
|
|
|
if( GetLayer() == LAYER_NOTES || GetLayer() == LAYER_SHEETLABEL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
NETLIST_OBJECT* item = new NETLIST_OBJECT();
|
2013-09-29 18:24:38 +00:00
|
|
|
item->m_SheetPath = *aSheetPath;
|
|
|
|
item->m_SheetPathInclude = *aSheetPath;
|
2011-10-12 14:03:43 +00:00
|
|
|
item->m_Comp = (SCH_ITEM*) this;
|
|
|
|
item->m_Type = NET_LABEL;
|
|
|
|
|
|
|
|
if( GetLayer() == LAYER_GLOBLABEL )
|
|
|
|
item->m_Type = NET_GLOBLABEL;
|
|
|
|
else if( GetLayer() == LAYER_HIERLABEL )
|
|
|
|
item->m_Type = NET_HIERLABEL;
|
|
|
|
|
|
|
|
item->m_Label = m_Text;
|
2017-01-23 20:30:11 +00:00
|
|
|
item->m_Start = item->m_End = GetTextPos();
|
2011-10-12 14:03:43 +00:00
|
|
|
|
|
|
|
aNetListItems.push_back( item );
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
// If a bus connects to label
|
2011-10-12 14:03:43 +00:00
|
|
|
if( IsBusLabel( m_Text ) )
|
2011-10-12 15:34:52 +00:00
|
|
|
item->ConvertBusToNetListItems( aNetListItems );
|
2011-10-12 14:03:43 +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
|
|
|
{
|
|
|
|
static std::vector <wxPoint> Poly;
|
2017-02-20 16:57:41 +00:00
|
|
|
COLOR4D color = GetLayerColor( GetLayer() );
|
|
|
|
int thickness = GetPenSize();
|
2011-06-17 13:24:22 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
aPlotter->SetCurrentLineWidth( thickness );
|
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
|
|
|
|
2015-01-15 20:01:53 +00:00
|
|
|
GetPositionsOfLinesOfMultilineText(positions, 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
|
|
|
{
|
2016-04-16 07:49:17 +00:00
|
|
|
wxPoint textpos = positions[ii] + GetSchematicTextOffset();
|
2015-01-15 20:01:53 +00:00
|
|
|
wxString& txt = strings_list.Item( ii );
|
2017-01-23 20:30:11 +00:00
|
|
|
aPlotter->Text( textpos, color, txt, GetTextAngle(), GetTextSize(),
|
|
|
|
GetHorizJustify(), GetVertJustify(),
|
|
|
|
thickness, IsItalic(), IsBold() );
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
wxPoint textpos = GetTextPos() + GetSchematicTextOffset();
|
|
|
|
|
|
|
|
aPlotter->Text( textpos, color, GetShownText(), GetTextAngle(), GetTextSize(),
|
|
|
|
GetHorizJustify(), GetVertJustify(),
|
|
|
|
thickness, 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
|
|
|
|
CreateGraphicShape( Poly, GetTextPos() );
|
2011-06-17 13:24:22 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
aPlotter->SetCurrentLineWidth( GetPenSize() );
|
2011-06-17 13:24:22 +00:00
|
|
|
|
|
|
|
if( Poly.size() )
|
|
|
|
aPlotter->PlotPoly( Poly, NO_FILL );
|
|
|
|
}
|
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
|
2012-11-20 11:35:09 +00:00
|
|
|
/*
|
|
|
|
* Display the type, shape, size and some other props to the Message panel
|
|
|
|
*/
|
2013-01-12 17:32:24 +00:00
|
|
|
void SCH_TEXT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
|
2012-11-20 11:35:09 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
switch( Type() )
|
|
|
|
{
|
2013-01-12 17:32:24 +00:00
|
|
|
case SCH_TEXT_T:
|
2014-11-15 19:06:05 +00:00
|
|
|
msg = _( "Graphic Text" );
|
2013-01-12 17:32:24 +00:00
|
|
|
break;
|
2012-11-20 11:35:09 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
case SCH_LABEL_T:
|
|
|
|
msg = _( "Label" );
|
|
|
|
break;
|
2012-11-20 11:35:09 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
case SCH_GLOBAL_LABEL_T:
|
2014-11-15 19:06:05 +00:00
|
|
|
msg = _( "Global Label" );
|
2013-01-12 17:32:24 +00:00
|
|
|
break;
|
2012-11-20 11:35:09 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
case SCH_HIERARCHICAL_LABEL_T:
|
2014-11-15 19:06:05 +00:00
|
|
|
msg = _( "Hierarchical Label" );
|
2013-01-12 17:32:24 +00:00
|
|
|
break;
|
2012-11-20 11:35:09 +00:00
|
|
|
|
|
|
|
case SCH_SHEET_PIN_T:
|
|
|
|
msg = _( "Hierarchical Sheet Pin" );
|
|
|
|
break;
|
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
default:
|
|
|
|
return;
|
2012-11-20 11:35:09 +00:00
|
|
|
}
|
|
|
|
|
2014-09-13 18:15:45 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( msg, GetShownText(), DARKCYAN ) );
|
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
|
|
|
{
|
2013-01-12 17:32:24 +00:00
|
|
|
case 0: // horizontal text
|
|
|
|
msg = _( "Horizontal" );
|
|
|
|
break;
|
2012-11-20 11:35:09 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
case 1: // Vert Orientation UP
|
|
|
|
msg = _( "Vertical up" );
|
|
|
|
break;
|
2012-11-20 11:35:09 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
case 2: // invert horizontal text
|
|
|
|
msg = _( "Horizontal invert" );
|
|
|
|
break;
|
2012-11-20 11:35:09 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
case 3: // Vert Orientation Down
|
|
|
|
msg = _( "Vertical down" );
|
|
|
|
break;
|
2012-11-20 11:35:09 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
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;
|
|
|
|
|
2014-11-15 19:06:05 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Style" ), textStyle[style], BROWN ) );
|
2012-11-20 11:35:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Display electricat type if it is relevant
|
|
|
|
if( (Type() == SCH_GLOBAL_LABEL_T) ||
|
|
|
|
(Type() == SCH_HIERARCHICAL_LABEL_T ) ||
|
|
|
|
(Type() == SCH_SHEET_PIN_T ) )
|
|
|
|
{
|
|
|
|
switch( GetShape() )
|
|
|
|
{
|
2013-01-12 17:32:24 +00:00
|
|
|
case NET_INPUT: msg = _( "Input" ); break;
|
|
|
|
case NET_OUTPUT: msg = _( "Output" ); break;
|
|
|
|
case NET_BIDI: msg = _( "Bidirectional" ); break;
|
|
|
|
case NET_TRISTATE: msg = _( "Tri-State" ); break;
|
|
|
|
case NET_UNSPECIFIED: msg = _( "Passive" ); 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( _( "Type" ), msg, BLUE ) );
|
2012-11-20 11:35:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Display text size (X or Y value, with are the same value in Eeschema)
|
2017-01-23 20:30:11 +00:00
|
|
|
msg = StringFromValue( g_UserUnit, GetTextWidth(), true );
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Size" ), msg, RED ) );
|
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()
|
2009-05-05 17:32:07 +00:00
|
|
|
<< " layer=\"" << m_Layer << '"'
|
2011-12-08 15:45:01 +00:00
|
|
|
<< " shape=\"" << m_shape << '"'
|
|
|
|
<< " dangling=\"" << m_isDangling << '"'
|
2009-05-05 17:32:07 +00:00
|
|
|
<< '>'
|
2011-02-28 18:36:19 +00:00
|
|
|
<< TO_UTF8( m_Text )
|
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
|
|
|
|
2010-12-21 15:13:09 +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
|
|
|
{
|
2010-12-21 15:13:09 +00:00
|
|
|
m_Layer = LAYER_LOCLABEL;
|
2011-12-08 15:45:01 +00:00
|
|
|
m_shape = NET_INPUT;
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
wxPoint SCH_LABEL::GetSchematicTextOffset() const
|
2010-12-21 15:13:09 +00:00
|
|
|
{
|
|
|
|
return SCH_TEXT::GetSchematicTextOffset();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
void SCH_LABEL::SetLabelSpinStyle( int aOrientation )
|
2010-12-21 15:13:09 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
SCH_TEXT::SetLabelSpinStyle( aOrientation );
|
2008-04-15 19:38:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_LABEL::MirrorX( int aXaxis_position )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
|
|
|
// Text is NOT really mirrored; it is moved to a suitable position
|
2017-01-23 20:30:11 +00:00
|
|
|
switch( GetLabelSpinStyle() )
|
2013-03-01 19:59:29 +00:00
|
|
|
{
|
|
|
|
case 1: // Vert Orientation UP
|
2017-01-23 20:30:11 +00:00
|
|
|
SetLabelSpinStyle( 3 );
|
2013-03-01 19:59:29 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: // Vert Orientation BOTTOM
|
2017-01-23 20:30:11 +00:00
|
|
|
SetLabelSpinStyle( 1 );
|
2013-03-01 19:59:29 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0: // horizontal text
|
|
|
|
case 2: // invert horizontal text
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
SetTextY( ::Mirror( GetTextPos().y, aXaxis_position ) );
|
2010-09-05 17:01:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_LABEL::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 );
|
|
|
|
SetTextPos( pt );
|
|
|
|
|
|
|
|
SetLabelSpinStyle( (GetLabelSpinStyle() + 1) % 4 );
|
2010-09-05 17:01:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
bool SCH_LABEL::Save( FILE* aFile ) const
|
|
|
|
{
|
2009-05-05 17:32:07 +00:00
|
|
|
bool success = true;
|
|
|
|
const char* shape = "~";
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
if( IsItalic() )
|
2008-12-19 20:40:08 +00:00
|
|
|
shape = "Italic";
|
|
|
|
|
|
|
|
if( fprintf( aFile, "Text Label %-4d %-4d %-4d %-4d %s %d\n%s\n",
|
2017-01-23 20:30:11 +00:00
|
|
|
GetTextPos().x, GetTextPos().y, GetLabelSpinStyle(), GetTextWidth(), shape,
|
|
|
|
GetThickness(), TO_UTF8( m_Text ) ) == EOF )
|
2008-04-15 19:38:19 +00:00
|
|
|
{
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
bool SCH_LABEL::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
char Name1[256];
|
|
|
|
char Name2[256];
|
|
|
|
char Name3[256];
|
|
|
|
int thickness = 0, size = 0, orient = 0;
|
|
|
|
int x, y;
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
Name1[0] = 0; Name2[0] = 0; Name3[0] = 0;
|
|
|
|
|
|
|
|
char* sline = (char*) aLine;
|
|
|
|
|
|
|
|
while( ( *sline != ' ' ) && *sline )
|
|
|
|
sline++;
|
|
|
|
|
|
|
|
// sline points the start of parameters
|
2017-01-23 20:30:11 +00:00
|
|
|
int ii = sscanf( sline, "%255s %d %d %d %d %255s %255s %d", Name1, &x, &y,
|
2010-11-10 15:30:12 +00:00
|
|
|
&orient, &size, Name2, Name3, &thickness );
|
|
|
|
|
|
|
|
if( ii < 4 )
|
|
|
|
{
|
2011-09-30 18:15:37 +00:00
|
|
|
aErrorMsg.Printf( wxT( "Eeschema file label load error at line %d" ),
|
2010-11-10 15:30:12 +00:00
|
|
|
aLine.LineNumber() );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !aLine.ReadLine() )
|
|
|
|
{
|
2011-09-30 18:15:37 +00:00
|
|
|
aErrorMsg.Printf( wxT( "Eeschema file label load error atline %d" ),
|
2010-11-10 15:30:12 +00:00
|
|
|
aLine.LineNumber() );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( size == 0 )
|
2014-05-16 13:57:53 +00:00
|
|
|
size = GetDefaultTextSize();
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
char* text = strtok( (char*) aLine, "\n\r" );
|
|
|
|
|
|
|
|
if( text == NULL )
|
|
|
|
{
|
2011-09-30 18:15:37 +00:00
|
|
|
aErrorMsg.Printf( wxT( "Eeschema file label load error at line %d" ),
|
2010-11-10 15:30:12 +00:00
|
|
|
aLine.LineNumber() );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
m_Text = FROM_UTF8( text );
|
2017-01-23 20:30:11 +00:00
|
|
|
|
|
|
|
SetTextSize( wxSize( size, size ) );
|
|
|
|
SetTextPos( wxPoint( x, y ) );
|
|
|
|
|
|
|
|
SetLabelSpinStyle( orient );
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
if( isdigit( Name3[0] ) )
|
|
|
|
{
|
|
|
|
thickness = atol( Name3 );
|
2017-01-23 20:30:11 +00:00
|
|
|
SetBold( thickness != 0 );
|
|
|
|
SetThickness( IsBold() ? GetPenSizeForBold( size ) : 0 );
|
2010-11-10 15:30:12 +00:00
|
|
|
}
|
|
|
|
|
2016-08-11 12:41:06 +00:00
|
|
|
if( strcasecmp( Name2, "Italic" ) == 0 )
|
2017-01-23 20:30:11 +00:00
|
|
|
SetItalic( true );
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void SCH_LABEL::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
|
2017-02-20 16:57:41 +00:00
|
|
|
GR_DRAWMODE DrawMode, COLOR4D Color )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
|
|
|
SCH_TEXT::Draw( panel, DC, offset, DrawMode, Color );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-24 17:48:14 +00:00
|
|
|
const EDA_RECT SCH_LABEL::GetBoundingBox() const
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
|
|
|
|
EDA_RECT rect = GetTextBox( -1, linewidth );
|
2010-11-03 14:13:15 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
wxString SCH_LABEL::GetSelectMenuText() const
|
2010-12-13 15:59:00 +00:00
|
|
|
{
|
2011-03-26 10:08:50 +00:00
|
|
|
wxString msg;
|
2014-09-13 18:15:45 +00:00
|
|
|
msg.Printf( _( "Label %s" ), GetChars( ShortenedShownText() ) );
|
2011-03-26 10:08:50 +00:00
|
|
|
return msg;
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) :
|
2010-12-10 19:47:44 +00:00
|
|
|
SCH_TEXT( pos, text, SCH_GLOBAL_LABEL_T )
|
2008-04-15 19:38:19 +00:00
|
|
|
{
|
2009-05-05 17:32:07 +00:00
|
|
|
m_Layer = LAYER_GLOBLABEL;
|
2011-12-08 15:45:01 +00:00
|
|
|
m_shape = NET_BIDI;
|
|
|
|
m_isDangling = true;
|
2017-01-23 20:30:11 +00:00
|
|
|
SetMultilineAllowed( false );
|
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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
bool SCH_GLOBALLABEL::Save( FILE* aFile ) const
|
|
|
|
{
|
2009-05-05 17:32:07 +00:00
|
|
|
bool success = true;
|
|
|
|
const char* shape = "~";
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
if( IsItalic() )
|
2008-12-19 20:40:08 +00:00
|
|
|
shape = "Italic";
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2008-12-19 20:40:08 +00:00
|
|
|
if( fprintf( aFile, "Text GLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n",
|
2017-01-23 20:30:11 +00:00
|
|
|
GetTextPos().x, GetTextPos().y, GetLabelSpinStyle(), GetTextWidth(),
|
|
|
|
SheetLabelType[m_shape], shape, GetThickness(), TO_UTF8( m_Text ) ) == EOF )
|
2008-04-15 19:38:19 +00:00
|
|
|
{
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2009-05-05 17:32:07 +00:00
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
bool SCH_GLOBALLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
char Name1[256];
|
|
|
|
char Name2[256];
|
|
|
|
char Name3[256];
|
|
|
|
int thickness = 0, size = 0, orient = 0;
|
|
|
|
int x, y;
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
Name1[0] = 0; Name2[0] = 0; Name3[0] = 0;
|
|
|
|
|
|
|
|
char* sline = (char*) aLine;
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
while( (*sline != ' ' ) && *sline )
|
|
|
|
sline++;
|
|
|
|
|
|
|
|
// sline points the start of parameters
|
2017-01-23 20:30:11 +00:00
|
|
|
int ii = sscanf( sline, "%255s %d %d %d %d %255s %255s %d", Name1, &x, &y,
|
2010-11-10 15:30:12 +00:00
|
|
|
&orient, &size, Name2, Name3, &thickness );
|
|
|
|
|
|
|
|
if( ii < 4 )
|
|
|
|
{
|
2011-09-30 18:15:37 +00:00
|
|
|
aErrorMsg.Printf( wxT( "Eeschema file global label load error at line %d" ),
|
2010-11-10 15:30:12 +00:00
|
|
|
aLine.LineNumber() );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !aLine.ReadLine() )
|
|
|
|
{
|
2011-09-30 18:15:37 +00:00
|
|
|
aErrorMsg.Printf( wxT( "Eeschema file global label load error at line %d" ),
|
2010-11-10 15:30:12 +00:00
|
|
|
aLine.LineNumber() );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( size == 0 )
|
2014-05-16 13:57:53 +00:00
|
|
|
size = GetDefaultTextSize();
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
char* text = strtok( (char*) aLine, "\n\r" );
|
|
|
|
|
|
|
|
if( text == NULL )
|
|
|
|
{
|
2011-09-30 18:15:37 +00:00
|
|
|
aErrorMsg.Printf( wxT( "Eeschema file global label load error at line %d" ),
|
2010-11-10 15:30:12 +00:00
|
|
|
aLine.LineNumber() );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
m_Text = FROM_UTF8( text );
|
2017-01-23 20:30:11 +00:00
|
|
|
|
|
|
|
SetTextSize( wxSize( size, size ) );
|
|
|
|
SetTextPos( wxPoint( x, y ) );
|
|
|
|
|
|
|
|
SetLabelSpinStyle( orient );
|
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
m_shape = NET_INPUT;
|
2017-01-23 20:30:11 +00:00
|
|
|
SetBold( thickness != 0 );
|
|
|
|
SetThickness( IsBold() ? GetPenSizeForBold( size ) : 0 );
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2016-08-11 12:41:06 +00:00
|
|
|
if( strcasecmp( Name2, SheetLabelType[NET_OUTPUT] ) == 0 )
|
2011-12-08 15:45:01 +00:00
|
|
|
m_shape = NET_OUTPUT;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2016-08-11 12:41:06 +00:00
|
|
|
if( strcasecmp( Name2, SheetLabelType[NET_BIDI] ) == 0 )
|
2011-12-08 15:45:01 +00:00
|
|
|
m_shape = NET_BIDI;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2016-08-11 12:41:06 +00:00
|
|
|
if( strcasecmp( Name2, SheetLabelType[NET_TRISTATE] ) == 0 )
|
2011-12-08 15:45:01 +00:00
|
|
|
m_shape = NET_TRISTATE;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2016-08-11 12:41:06 +00:00
|
|
|
if( strcasecmp( Name2, SheetLabelType[NET_UNSPECIFIED] ) == 0 )
|
2011-12-08 15:45:01 +00:00
|
|
|
m_shape = NET_UNSPECIFIED;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2016-08-11 12:41:06 +00:00
|
|
|
if( strcasecmp( Name3, "Italic" ) == 0 )
|
2017-01-23 20:30:11 +00:00
|
|
|
SetItalic( true );
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_GLOBALLABEL::MirrorY( int aYaxis_position )
|
2008-04-15 19:38:19 +00:00
|
|
|
{
|
2010-11-03 14:13:15 +00:00
|
|
|
/* The global label is NOT really mirrored.
|
|
|
|
* for an horizontal label, the schematic orientation is changed.
|
2010-11-11 17:54:24 +00:00
|
|
|
* for a vertical label, the schematic orientation is not changed.
|
2010-11-03 14:13:15 +00:00
|
|
|
* and the label is moved to a suitable position
|
|
|
|
*/
|
2017-01-23 20:30:11 +00:00
|
|
|
switch( GetLabelSpinStyle() )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
case 0: // horizontal text
|
|
|
|
SetLabelSpinStyle( 2 );
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 2: // invert horizontal text
|
|
|
|
SetLabelSpinStyle( 0 );
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
SetTextX( ::Mirror( GetTextPos().x, aYaxis_position ) );
|
2008-04-15 19:38:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_GLOBALLABEL::MirrorX( int aXaxis_position )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
switch( GetLabelSpinStyle() )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
case 1: // vertical text
|
|
|
|
SetLabelSpinStyle( 3 );
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 3: // invert vertical text
|
|
|
|
SetLabelSpinStyle( 1 );
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
SetTextY( ::Mirror( GetTextPos().y, aXaxis_position ) );
|
2010-11-03 14:13:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_GLOBALLABEL::Rotate( wxPoint aPosition )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
wxPoint pt = GetTextPos();
|
|
|
|
RotatePoint( &pt, aPosition, 900 );
|
|
|
|
SetTextPos( pt );
|
|
|
|
|
|
|
|
SetLabelSpinStyle( (GetLabelSpinStyle() + 3) % 4 );
|
2010-11-03 14:13:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset() const
|
2008-04-15 19:38:19 +00:00
|
|
|
{
|
2010-11-03 14:13:15 +00:00
|
|
|
wxPoint text_offset;
|
2017-01-23 20:30:11 +00:00
|
|
|
int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
|
2009-05-05 17:32:07 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
width = Clamp_Text_PenSize( width, GetTextSize(), IsBold() );
|
|
|
|
int halfSize = GetTextWidth() / 2;
|
2010-11-03 14:13:15 +00:00
|
|
|
int offset = width;
|
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
switch( m_shape )
|
2008-04-15 19:38:19 +00:00
|
|
|
{
|
2010-11-03 14:13:15 +00:00
|
|
|
case NET_INPUT:
|
|
|
|
case NET_BIDI:
|
|
|
|
case NET_TRISTATE:
|
2016-03-23 07:41:47 +00:00
|
|
|
offset += halfSize;
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_OUTPUT:
|
|
|
|
case NET_UNSPECIFIED:
|
2016-04-16 07:49:17 +00:00
|
|
|
offset += TXT_MARGIN;
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
case 0: // Orientation horiz normal
|
2010-11-03 14:13:15 +00:00
|
|
|
text_offset.x -= offset;
|
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 1: // Orientation vert UP
|
2010-11-03 14:13:15 +00:00
|
|
|
text_offset.y -= offset;
|
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 2: // Orientation horiz inverse
|
2010-11-03 14:13:15 +00:00
|
|
|
text_offset.x += offset;
|
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 3: // Orientation vert BOTTOM
|
2010-11-03 14:13:15 +00:00
|
|
|
text_offset.y += offset;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return text_offset;
|
2008-04-15 19:38:19 +00:00
|
|
|
}
|
|
|
|
|
2009-05-05 17:32:07 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
void SCH_GLOBALLABEL::SetLabelSpinStyle( int 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:
|
2017-01-23 20:30:11 +00:00
|
|
|
case 0: // Horiz Normal Orientation
|
|
|
|
SetTextAngle( TEXT_ANGLE_HORIZ );
|
|
|
|
SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
|
|
|
SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 1: // Vert Orientation UP
|
|
|
|
SetTextAngle( TEXT_ANGLE_VERT );
|
|
|
|
SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
|
|
|
SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
2010-07-11 16:24:44 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 2: // Horiz Orientation
|
|
|
|
SetTextAngle( TEXT_ANGLE_HORIZ );
|
|
|
|
SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
|
|
|
SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
2009-05-05 17:32:07 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 3: // Vert Orientation BOTTOM
|
|
|
|
SetTextAngle( TEXT_ANGLE_VERT );
|
|
|
|
SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
|
|
|
SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
|
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
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void SCH_GLOBALLABEL::Draw( EDA_DRAW_PANEL* panel,
|
|
|
|
wxDC* DC,
|
|
|
|
const wxPoint& aOffset,
|
2012-09-01 13:38:27 +00:00
|
|
|
GR_DRAWMODE DrawMode,
|
2017-02-20 16:57:41 +00:00
|
|
|
COLOR4D Color )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-05-05 17:32:07 +00:00
|
|
|
static std::vector <wxPoint> Poly;
|
2017-02-20 16:57:41 +00:00
|
|
|
COLOR4D color;
|
2012-03-26 23:47:08 +00:00
|
|
|
wxPoint text_offset = aOffset + GetSchematicTextOffset();
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2017-02-20 17:48:27 +00:00
|
|
|
if( Color != COLOR4D::UNSPECIFIED )
|
2012-09-02 12:06:47 +00:00
|
|
|
color = Color;
|
2008-02-20 19:37:17 +00:00
|
|
|
else
|
2016-11-16 10:07:02 +00:00
|
|
|
color = GetLayerColor( GetState( BRIGHTENED ) ? LAYER_BRIGHTENED : m_Layer );
|
2008-02-20 19:37:17 +00:00
|
|
|
|
|
|
|
GRSetDrawMode( DC, DrawMode );
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
|
|
|
|
|
|
|
|
linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
|
|
|
|
|
|
|
|
int save_width = GetThickness();
|
|
|
|
SetThickness( linewidth );
|
|
|
|
|
2013-06-29 09:52:22 +00:00
|
|
|
EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
|
2017-02-20 17:48:27 +00:00
|
|
|
EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, COLOR4D::UNSPECIFIED );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
SetThickness( save_width ); // restore initial value
|
|
|
|
|
|
|
|
CreateGraphicShape( Poly, GetTextPos() + aOffset );
|
2013-06-29 09:52:22 +00:00
|
|
|
GRPoly( clipbox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2015-04-02 11:18:19 +00:00
|
|
|
if( m_isDangling && panel )
|
2017-01-23 20:30:11 +00:00
|
|
|
DrawDanglingSymbol( panel, DC, GetTextPos() + aOffset, color );
|
2009-11-28 09:24:37 +00:00
|
|
|
|
|
|
|
// Enable these line to draw the bounding box (debug tests purposes only)
|
2016-03-23 07:41:47 +00:00
|
|
|
#if DRAW_BBOX
|
2009-11-28 09:24:37 +00:00
|
|
|
{
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT BoundaryBox = GetBoundingBox();
|
2013-06-29 09:52:22 +00:00
|
|
|
GRRect( clipbox, DC, BoundaryBox, 0, BROWN );
|
2009-11-28 09:24:37 +00:00
|
|
|
}
|
|
|
|
#endif
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2008-02-20 19:37:17 +00:00
|
|
|
|
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& Pos )
|
2008-02-20 19:37:17 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
int halfSize = GetTextHeight() / 2;
|
|
|
|
int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
|
2008-02-20 19:37:17 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
|
2008-02-20 19:37:17 +00:00
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
aPoints.clear();
|
2008-12-29 18:02:54 +00:00
|
|
|
|
2016-04-16 07:49:17 +00:00
|
|
|
int symb_len = LenSize( GetShownText() ) + ( TXT_MARGIN * 2 );
|
2009-05-05 17:32:07 +00:00
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
// Create outline shape : 6 points
|
|
|
|
int x = symb_len + linewidth + 3;
|
|
|
|
|
2012-09-07 19:29:44 +00:00
|
|
|
// Use negation bar Y position to calculate full vertical size
|
2016-03-23 07:41:47 +00:00
|
|
|
// Search for overbar symbol
|
|
|
|
bool hasOverBar = false;
|
|
|
|
|
|
|
|
for( unsigned ii = 1; ii < m_Text.size(); ii++ )
|
|
|
|
{
|
|
|
|
if( m_Text[ii-1] == '~' && m_Text[ii] != '~' )
|
|
|
|
{
|
|
|
|
hasOverBar = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define Y_CORRECTION 1.40
|
|
|
|
// Note: this factor is due to the fact the Y size of a few letters like [
|
|
|
|
// are bigger than the y size value, and we need a margin for the graphic symbol.
|
|
|
|
int y = KiROUND( halfSize * Y_CORRECTION );
|
|
|
|
|
|
|
|
// Note: this factor is due to the fact we need a margin for the graphic symbol.
|
|
|
|
#define Y_OVERBAR_CORRECTION 1.2
|
|
|
|
if( hasOverBar )
|
2016-03-23 12:16:27 +00:00
|
|
|
y = KiROUND( KIGFX::STROKE_FONT::GetInterline( halfSize, linewidth )
|
|
|
|
* Y_OVERBAR_CORRECTION );
|
2016-03-23 07:41:47 +00:00
|
|
|
|
|
|
|
// Gives room for line thickess and margin
|
|
|
|
y += linewidth // for line thickess
|
|
|
|
+ linewidth/2; // for margin
|
2010-11-03 14:13:15 +00:00
|
|
|
|
|
|
|
// Starting point(anchor)
|
2011-06-17 13:24:22 +00:00
|
|
|
aPoints.push_back( wxPoint( 0, 0 ) );
|
|
|
|
aPoints.push_back( wxPoint( 0, -y ) ); // Up
|
|
|
|
aPoints.push_back( wxPoint( -x, -y ) ); // left
|
|
|
|
aPoints.push_back( wxPoint( -x, 0 ) ); // Up left
|
|
|
|
aPoints.push_back( wxPoint( -x, y ) ); // left down
|
|
|
|
aPoints.push_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
|
|
|
{
|
|
|
|
case NET_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;
|
|
|
|
|
|
|
|
case NET_OUTPUT:
|
2016-03-23 07:41:47 +00:00
|
|
|
aPoints[3].x -= halfSize;
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_BIDI:
|
|
|
|
case NET_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;
|
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
case NET_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
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
case 0: // Orientation horiz normal
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 1: // Orientation vert UP
|
2010-11-03 14:13:15 +00:00
|
|
|
angle = -900;
|
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 2: // Orientation horiz inverse
|
2010-11-03 14:13:15 +00:00
|
|
|
angle = 1800;
|
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 3: // Orientation vert BOTTOM
|
2010-11-03 14:13:15 +00:00
|
|
|
angle = 900;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Rotate outlines and move corners in real position
|
2011-06-17 13:24:22 +00:00
|
|
|
for( unsigned ii = 0; ii < aPoints.size(); ii++ )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2011-06-17 13:24:22 +00:00
|
|
|
aPoints[ii].x += x_offset;
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
if( angle )
|
2011-06-17 13:24:22 +00:00
|
|
|
RotatePoint( &aPoints[ii], angle );
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
aPoints[ii] += 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
|
|
|
{
|
2008-03-30 10:47:03 +00:00
|
|
|
int x, y, dx, dy, length, height;
|
2008-03-30 09:27:53 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
x = GetTextPos().x;
|
|
|
|
y = GetTextPos().y;
|
2008-03-30 11:48:18 +00:00
|
|
|
dx = dy = 0;
|
2008-03-30 09:27:53 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
|
|
|
|
|
|
|
|
height = ( (GetTextHeight() * 15) / 10 ) + width + 2 * TXT_MARGIN;
|
2010-11-03 14:13:15 +00:00
|
|
|
|
|
|
|
// text X size add height for triangular shapes(bidirectional)
|
2014-09-13 18:15:45 +00:00
|
|
|
length = LenSize( GetShownText() ) + height + DANGLING_SYMBOL_SIZE;
|
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
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
case 0: // Horiz Normal Orientation (left justified)
|
2009-05-05 17:32:07 +00:00
|
|
|
dx = -length;
|
|
|
|
dy = height;
|
|
|
|
x += DANGLING_SYMBOL_SIZE;
|
|
|
|
y -= height / 2;
|
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 1: // Vert Orientation 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;
|
2009-05-12 12:12:34 +00:00
|
|
|
y += DANGLING_SYMBOL_SIZE;
|
2009-05-05 17:32:07 +00:00
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 2: // Horiz Orientation - Right justified
|
2009-05-05 17:32:07 +00:00
|
|
|
dx = length;
|
|
|
|
dy = height;
|
|
|
|
x -= DANGLING_SYMBOL_SIZE;
|
|
|
|
y -= height / 2;
|
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 3: // Vert Orientation BOTTOM
|
2010-11-03 14:13:15 +00:00
|
|
|
dx = height;
|
|
|
|
dy = length;
|
|
|
|
x -= height / 2;
|
|
|
|
y -= DANGLING_SYMBOL_SIZE;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
wxString SCH_GLOBALLABEL::GetSelectMenuText() const
|
2010-12-13 15:59:00 +00:00
|
|
|
{
|
2011-03-26 10:08:50 +00:00
|
|
|
wxString msg;
|
2014-09-13 18:15:45 +00:00
|
|
|
msg.Printf( _( "Global Label %s" ), GetChars( ShortenedShownText() ) );
|
2011-03-26 10:08:50 +00:00
|
|
|
return msg;
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-13 15:59:00 +00:00
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
|
|
|
|
SCH_TEXT( pos, text, aType )
|
|
|
|
{
|
|
|
|
m_Layer = LAYER_HIERLABEL;
|
2011-12-08 15:45:01 +00:00
|
|
|
m_shape = NET_INPUT;
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
bool SCH_HIERLABEL::Save( FILE* aFile ) const
|
|
|
|
{
|
|
|
|
bool success = true;
|
|
|
|
const char* shape = "~";
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
if( IsItalic() )
|
2010-11-03 14:13:15 +00:00
|
|
|
shape = "Italic";
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
if( fprintf( aFile, "Text HLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n",
|
2017-01-23 20:30:11 +00:00
|
|
|
GetTextPos().x, GetTextPos().y, GetLabelSpinStyle(), GetTextWidth(),
|
|
|
|
SheetLabelType[m_shape], shape, GetThickness(), TO_UTF8( m_Text ) ) == EOF )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
bool SCH_HIERLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
char Name1[256];
|
|
|
|
char Name2[256];
|
|
|
|
char Name3[256];
|
|
|
|
int thickness = 0, size = 0, orient = 0;
|
|
|
|
int x, y;
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
Name1[0] = 0; Name2[0] = 0; Name3[0] = 0;
|
|
|
|
|
|
|
|
char* sline = (char*) aLine;
|
2011-10-12 14:03:43 +00:00
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
while( (*sline != ' ' ) && *sline )
|
|
|
|
sline++;
|
|
|
|
|
|
|
|
// sline points the start of parameters
|
2017-01-23 20:30:11 +00:00
|
|
|
int ii = sscanf( sline, "%255s %d %d %d %d %255s %255s %d", Name1,
|
|
|
|
&x, &y,
|
2010-11-10 15:30:12 +00:00
|
|
|
&orient, &size, Name2, Name3, &thickness );
|
|
|
|
|
|
|
|
if( ii < 4 )
|
|
|
|
{
|
2011-09-30 18:15:37 +00:00
|
|
|
aErrorMsg.Printf( wxT( "Eeschema file hierarchical label load error at line %d" ),
|
2010-11-10 15:30:12 +00:00
|
|
|
aLine.LineNumber() );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !aLine.ReadLine() )
|
|
|
|
{
|
2011-09-30 18:15:37 +00:00
|
|
|
aErrorMsg.Printf( wxT( "Eeschema file hierarchical label load error at line %d" ),
|
2010-11-10 15:30:12 +00:00
|
|
|
aLine.LineNumber() );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( size == 0 )
|
2014-05-16 13:57:53 +00:00
|
|
|
size = GetDefaultTextSize();
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
char* text = strtok( (char*) aLine, "\n\r" );
|
|
|
|
|
|
|
|
if( text == NULL )
|
|
|
|
{
|
2011-09-30 18:15:37 +00:00
|
|
|
aErrorMsg.Printf( wxT( "Eeschema file hierarchical label load error at line %d" ),
|
2010-11-10 15:30:12 +00:00
|
|
|
aLine.LineNumber() );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
m_Text = FROM_UTF8( text );
|
2017-01-23 20:30:11 +00:00
|
|
|
|
|
|
|
SetTextSize( wxSize( size, size ) );
|
|
|
|
SetTextPos( wxPoint( x, y ) );
|
|
|
|
|
|
|
|
SetLabelSpinStyle( orient );
|
2011-12-08 15:45:01 +00:00
|
|
|
m_shape = NET_INPUT;
|
2017-01-23 20:30:11 +00:00
|
|
|
SetBold( thickness != 0 );
|
|
|
|
|
|
|
|
SetThickness( IsBold() ? GetPenSizeForBold( size ) : 0 );
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2016-08-11 12:41:06 +00:00
|
|
|
if( strcasecmp( Name2, SheetLabelType[NET_OUTPUT] ) == 0 )
|
2011-12-08 15:45:01 +00:00
|
|
|
m_shape = NET_OUTPUT;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2016-08-11 12:41:06 +00:00
|
|
|
if( strcasecmp( Name2, SheetLabelType[NET_BIDI] ) == 0 )
|
2011-12-08 15:45:01 +00:00
|
|
|
m_shape = NET_BIDI;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2016-08-11 12:41:06 +00:00
|
|
|
if( strcasecmp( Name2, SheetLabelType[NET_TRISTATE] ) == 0 )
|
2011-12-08 15:45:01 +00:00
|
|
|
m_shape = NET_TRISTATE;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2016-08-11 12:41:06 +00:00
|
|
|
if( strcasecmp( Name2, SheetLabelType[NET_UNSPECIFIED] ) == 0 )
|
2011-12-08 15:45:01 +00:00
|
|
|
m_shape = NET_UNSPECIFIED;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2016-08-11 12:41:06 +00:00
|
|
|
if( strcasecmp( Name3, "Italic" ) == 0 )
|
2017-01-23 20:30:11 +00:00
|
|
|
SetItalic( true );
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
void SCH_HIERLABEL::SetLabelSpinStyle( int 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:
|
2017-01-23 20:30:11 +00:00
|
|
|
case 0: // Horiz Normal Orientation
|
|
|
|
SetTextAngle( TEXT_ANGLE_HORIZ );
|
|
|
|
SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
|
|
|
SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 1: // Vert Orientation UP
|
|
|
|
SetTextAngle( TEXT_ANGLE_VERT );
|
|
|
|
SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
|
|
|
SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 2: // Horiz Orientation
|
|
|
|
SetTextAngle( TEXT_ANGLE_HORIZ );
|
|
|
|
SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
|
|
|
SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 3: // Vert Orientation BOTTOM
|
|
|
|
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
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void SCH_HIERLABEL::Draw( EDA_DRAW_PANEL* panel,
|
|
|
|
wxDC* DC,
|
|
|
|
const wxPoint& offset,
|
2012-09-01 13:38:27 +00:00
|
|
|
GR_DRAWMODE DrawMode,
|
2017-02-20 16:57:41 +00:00
|
|
|
COLOR4D Color )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2009-05-05 17:32:07 +00:00
|
|
|
static std::vector <wxPoint> Poly;
|
2017-02-20 16:57:41 +00:00
|
|
|
COLOR4D color;
|
2017-01-23 20:30:11 +00:00
|
|
|
int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
|
|
|
|
EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
|
2008-02-20 19:37:17 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
|
2008-02-20 19:37:17 +00:00
|
|
|
|
2017-02-20 17:48:27 +00:00
|
|
|
if( Color != COLOR4D::UNSPECIFIED )
|
2012-09-02 12:06:47 +00:00
|
|
|
color = Color;
|
2008-02-20 19:37:17 +00:00
|
|
|
else
|
2016-11-16 10:07:02 +00:00
|
|
|
color = GetLayerColor( GetState( BRIGHTENED ) ? LAYER_BRIGHTENED : m_Layer );
|
2008-02-20 19:37:17 +00:00
|
|
|
|
|
|
|
GRSetDrawMode( DC, DrawMode );
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
int save_width = GetThickness();
|
|
|
|
SetThickness( linewidth );
|
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
wxPoint text_offset = offset + GetSchematicTextOffset();
|
2017-02-20 17:48:27 +00:00
|
|
|
EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, COLOR4D::UNSPECIFIED );
|
2008-02-20 19:37:17 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
SetThickness( save_width ); // restore initial value
|
|
|
|
|
|
|
|
CreateGraphicShape( Poly, GetTextPos() + offset );
|
2013-06-29 09:52:22 +00:00
|
|
|
GRPoly( clipbox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color );
|
2008-02-20 19:37:17 +00:00
|
|
|
|
2015-04-02 11:18:19 +00:00
|
|
|
if( m_isDangling && panel )
|
2017-01-23 20:30:11 +00:00
|
|
|
DrawDanglingSymbol( panel, DC, GetTextPos() + offset, color );
|
2009-11-28 09:24:37 +00:00
|
|
|
|
|
|
|
// Enable these line to draw the bounding box (debug tests purposes only)
|
2016-03-23 07:41:47 +00:00
|
|
|
#if DRAW_BBOX
|
2009-11-28 09:24:37 +00:00
|
|
|
{
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT BoundaryBox = GetBoundingBox();
|
2013-06-29 09:52:22 +00:00
|
|
|
GRRect( clipbox, DC, BoundaryBox, 0, BROWN );
|
2009-11-28 09:24:37 +00:00
|
|
|
}
|
|
|
|
#endif
|
2008-02-20 19:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
void SCH_HIERLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& Pos )
|
2008-02-20 19:37:17 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
int* Template = TemplateShape[m_shape][m_spin_style];
|
|
|
|
int halfSize = GetTextWidth() / 2;
|
2009-06-02 07:26:49 +00:00
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
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
|
|
|
{
|
2008-03-30 10:47:03 +00:00
|
|
|
int x, y, dx, dy, length, height;
|
2008-03-30 09:27:53 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
x = GetTextPos().x;
|
|
|
|
y = GetTextPos().y;
|
2008-03-30 11:48:18 +00:00
|
|
|
dx = dy = 0;
|
2008-03-30 09:27:53 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
|
|
|
|
|
|
|
|
height = GetTextHeight() + width + 2 * TXT_MARGIN;
|
2014-09-13 18:15:45 +00:00
|
|
|
length = LenSize( GetShownText() )
|
2010-11-03 14:13:15 +00:00
|
|
|
+ height // add height for triangular shapes
|
|
|
|
+ 2 * DANGLING_SYMBOL_SIZE;
|
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
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
case 0: // Horiz Normal Orientation (left justified)
|
2009-05-05 17:32:07 +00:00
|
|
|
dx = -length;
|
|
|
|
dy = height;
|
|
|
|
x += DANGLING_SYMBOL_SIZE;
|
|
|
|
y -= height / 2;
|
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 1: // Vert Orientation 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;
|
2009-05-12 12:12:34 +00:00
|
|
|
y += DANGLING_SYMBOL_SIZE;
|
2009-05-05 17:32:07 +00:00
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 2: // Horiz Orientation - Right justified
|
2009-05-05 17:32:07 +00:00
|
|
|
dx = length;
|
|
|
|
dy = height;
|
|
|
|
x -= DANGLING_SYMBOL_SIZE;
|
|
|
|
y -= height / 2;
|
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 3: // Vert Orientation 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;
|
2009-05-12 12:12:34 +00:00
|
|
|
y -= 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
wxPoint SCH_HIERLABEL::GetSchematicTextOffset() const
|
2009-11-28 09:24:37 +00:00
|
|
|
{
|
2010-11-03 14:13:15 +00:00
|
|
|
wxPoint text_offset;
|
2008-03-27 21:24:50 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
int width = std::max( GetThickness(), GetDefaultLineThickness() );
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
int ii = GetTextWidth() + TXT_MARGIN + width;
|
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
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
case 0: // Orientation horiz normale
|
2010-11-03 14:13:15 +00:00
|
|
|
text_offset.x = -ii;
|
2009-05-05 17:32:07 +00:00
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 1: // Orientation vert UP
|
2010-11-03 14:13:15 +00:00
|
|
|
text_offset.y = -ii;
|
2009-05-05 17:32:07 +00:00
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 2: // Orientation horiz inverse
|
2010-11-03 14:13:15 +00:00
|
|
|
text_offset.x = ii;
|
2009-05-05 17:32:07 +00:00
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 3: // Orientation vert BOTTOM
|
2010-11-03 14:13:15 +00:00
|
|
|
text_offset.y = ii;
|
2009-05-05 17:32:07 +00:00
|
|
|
break;
|
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
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_HIERLABEL::MirrorY( int aYaxis_position )
|
2009-11-28 09:24:37 +00:00
|
|
|
{
|
2010-12-21 15:13:09 +00:00
|
|
|
/* The hierarchical label is NOT really mirrored for an horizontal label, the schematic
|
2011-06-07 15:29:01 +00:00
|
|
|
* orientation is changed. For a vertical label, the schematic orientation is not changed
|
2010-12-21 15:13:09 +00:00
|
|
|
* and the label is moved to a suitable position.
|
|
|
|
*/
|
2017-01-23 20:30:11 +00:00
|
|
|
switch( GetLabelSpinStyle() )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
case 0: // horizontal text
|
|
|
|
SetLabelSpinStyle( 2 );
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
2009-11-28 09:24:37 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 2: // invert horizontal text
|
|
|
|
SetLabelSpinStyle( 0 );
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
SetTextX( Mirror( GetTextPos().x, aYaxis_position ) );
|
2010-11-03 14:13:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_HIERLABEL::MirrorX( int aXaxis_position )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
switch( GetLabelSpinStyle() )
|
2009-11-28 09:24:37 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
case 1: // vertical text
|
|
|
|
SetLabelSpinStyle( 3 );
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
case 3: // invert vertical text
|
|
|
|
SetLabelSpinStyle( 1 );
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
2009-11-28 09:24:37 +00:00
|
|
|
}
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
SetTextY( Mirror( GetTextPos().y, aXaxis_position ) );
|
2010-11-03 14:13:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_HIERLABEL::Rotate( wxPoint aPosition )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
wxPoint pt = GetTextPos();
|
|
|
|
RotatePoint( &pt, aPosition, 900 );
|
|
|
|
SetTextPos( pt );
|
|
|
|
|
|
|
|
SetLabelSpinStyle( (GetLabelSpinStyle() + 3) % 4 );
|
2009-11-28 09:24:37 +00:00
|
|
|
}
|
2010-12-13 15:59:00 +00:00
|
|
|
|
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
wxString SCH_HIERLABEL::GetSelectMenuText() const
|
2010-12-13 15:59:00 +00:00
|
|
|
{
|
2011-03-26 10:08:50 +00:00
|
|
|
wxString msg;
|
2014-09-13 18:15:45 +00:00
|
|
|
msg.Printf( _( "Hierarchical Label %s" ), GetChars( ShortenedShownText() ) );
|
2011-03-26 10:08:50 +00:00
|
|
|
return msg;
|
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;
|
|
|
|
}
|