2012-01-14 19:50:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2012-06-08 09:56:42 +00:00
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2015-02-28 20:50:35 +00:00
|
|
|
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-01-14 19:50:32 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file class_pcb_text.cpp
|
|
|
|
* @brief Class TEXTE_PCB texts on copper or technical layers implementation
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <wxstruct.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <base_struct.h>
|
|
|
|
#include <drawtxt.h>
|
|
|
|
#include <kicad_string.h>
|
|
|
|
#include <trigo.h>
|
|
|
|
#include <richio.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <macros.h>
|
2017-08-04 12:43:02 +00:00
|
|
|
#include <wxPcbStruct.h>
|
2013-01-12 17:32:24 +00:00
|
|
|
#include <msgpanel.h>
|
|
|
|
#include <base_units.h>
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_pcb_text.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
TEXTE_PCB::TEXTE_PCB( BOARD_ITEM* parent ) :
|
2011-10-01 19:24:27 +00:00
|
|
|
BOARD_ITEM( parent, PCB_TEXT_T ),
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_TEXT()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
SetMultilineAllowed( true );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-07 06:21:19 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
TEXTE_PCB::~TEXTE_PCB()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-08-07 06:21:19 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
void TEXTE_PCB::SetTextAngle( double aAngle )
|
|
|
|
{
|
|
|
|
EDA_TEXT::SetTextAngle( NormalizeAngle360( aAngle ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void TEXTE_PCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
|
2012-09-01 13:38:27 +00:00
|
|
|
GR_DRAWMODE DrawMode, const wxPoint& offset )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-07-04 21:32:49 +00:00
|
|
|
BOARD* brd = GetBoard();
|
2010-01-31 20:01:46 +00:00
|
|
|
|
|
|
|
if( brd->IsLayerVisible( m_Layer ) == false )
|
2007-08-07 06:21:19 +00:00
|
|
|
return;
|
|
|
|
|
2017-08-04 12:43:02 +00:00
|
|
|
auto frame = static_cast<PCB_EDIT_FRAME*> ( panel->GetParent() );
|
|
|
|
auto color = frame->Settings().Colors().GetLayerColor( m_Layer );
|
2009-10-10 01:25:53 +00:00
|
|
|
|
2012-01-03 17:14:17 +00:00
|
|
|
EDA_DRAW_MODE_T fillmode = FILLED;
|
2015-04-07 11:52:29 +00:00
|
|
|
DISPLAY_OPTIONS* displ_opts =
|
|
|
|
panel ? (DISPLAY_OPTIONS*)panel->GetDisplayOptions() : NULL;
|
2012-01-03 17:14:17 +00:00
|
|
|
|
2015-02-02 08:06:39 +00:00
|
|
|
if( displ_opts && displ_opts->m_DisplayDrawItemsFill == SKETCH )
|
2009-05-12 13:46:43 +00:00
|
|
|
fillmode = SKETCH;
|
2009-05-30 16:06:01 +00:00
|
|
|
|
2015-05-27 20:13:51 +00:00
|
|
|
// shade text if high contrast mode is active
|
|
|
|
if( ( DrawMode & GR_ALLOW_HIGHCONTRAST ) && displ_opts && displ_opts->m_ContrastModeDisplay )
|
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
|
2015-05-27 20:13:51 +00:00
|
|
|
|
|
|
|
if( !IsOnLayer( curr_layer ) )
|
2017-02-20 16:57:41 +00:00
|
|
|
color = COLOR4D( DARKDARKGRAY );
|
2015-05-27 20:13:51 +00:00
|
|
|
}
|
|
|
|
|
2017-02-20 17:48:27 +00:00
|
|
|
COLOR4D anchor_color = COLOR4D::UNSPECIFIED;
|
2012-03-26 23:47:08 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
if( brd->IsElementVisible( LAYER_ANCHOR ) )
|
2017-08-04 12:43:02 +00:00
|
|
|
anchor_color = frame->Settings().Colors().GetItemColor( LAYER_ANCHOR );
|
2010-01-31 20:01:46 +00:00
|
|
|
|
2013-06-29 09:52:22 +00:00
|
|
|
EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
|
|
|
|
EDA_TEXT::Draw( clipbox, DC, offset, color,
|
2012-09-02 12:06:47 +00:00
|
|
|
DrawMode, fillmode, anchor_color );
|
2013-11-05 17:12:27 +00:00
|
|
|
|
|
|
|
// Enable these line to draw the bounding box (debug tests purposes only)
|
|
|
|
#if 0
|
|
|
|
{
|
|
|
|
EDA_RECT BoundaryBox = GetBoundingBox();
|
|
|
|
GRRect( clipbox, DC, BoundaryBox, 0, BROWN );
|
|
|
|
}
|
|
|
|
#endif
|
2007-08-07 06:21:19 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
void TEXTE_PCB::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
|
2007-08-20 19:33:15 +00:00
|
|
|
{
|
2009-05-01 16:46:56 +00:00
|
|
|
wxString msg;
|
|
|
|
|
2015-02-28 20:50:35 +00:00
|
|
|
wxCHECK_RET( m_Parent != NULL, wxT( "TEXTE_PCB::GetMsgPanelInfo() m_Parent is NULL." ) );
|
2008-03-11 05:41:33 +00:00
|
|
|
|
2015-02-28 20:50:35 +00:00
|
|
|
if( m_Parent->Type() == PCB_DIMENSION_T )
|
2014-09-13 18:15:45 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Dimension" ), GetShownText(), DARKGREEN ) );
|
2007-08-20 19:33:15 +00:00
|
|
|
else
|
2014-09-13 18:15:45 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "PCB Text" ), GetShownText(), DARKGREEN ) );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2013-04-07 11:55:18 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), BLUE ) );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
if( !IsMirrored() )
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), _( "No" ), DARKGREEN ) );
|
2007-08-20 19:33:15 +00:00
|
|
|
else
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), _( "Yes" ), DARKGREEN ) );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
msg.Printf( wxT( "%.1f" ), GetTextAngle() / 10.0 );
|
2014-11-15 19:06:05 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, DARKGREEN ) );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
msg = ::CoordinateToString( GetThickness() );
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Thickness" ), msg, MAGENTA ) );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
msg = ::CoordinateToString( GetTextWidth() );
|
2014-11-15 19:06:05 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, RED ) );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
msg = ::CoordinateToString( GetTextHeight() );
|
2014-11-15 19:06:05 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, RED ) );
|
2007-08-20 19:33:15 +00:00
|
|
|
}
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
|
2013-11-24 17:48:14 +00:00
|
|
|
const EDA_RECT TEXTE_PCB::GetBoundingBox() const
|
2013-11-05 17:12:27 +00:00
|
|
|
{
|
|
|
|
EDA_RECT rect = GetTextBox( -1, -1 );
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
if( GetTextAngle() )
|
|
|
|
rect = rect.GetBoundingBoxRotated( GetTextPos(), GetTextAngle() );
|
2013-11-05 17:12:27 +00:00
|
|
|
|
|
|
|
return rect;
|
|
|
|
}
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
void TEXTE_PCB::Rotate( const wxPoint& aRotCentre, double aAngle )
|
2009-08-01 19:26:05 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
wxPoint pt = GetTextPos();
|
|
|
|
RotatePoint( &pt, aRotCentre, aAngle );
|
|
|
|
SetTextPos( pt );
|
|
|
|
|
|
|
|
SetTextAngle( GetTextAngle() + aAngle );
|
2009-08-01 19:26:05 +00:00
|
|
|
}
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
void TEXTE_PCB::Flip( const wxPoint& aCentre )
|
2009-08-01 19:26:05 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
SetTextY( aCentre.y - ( GetTextPos().y - aCentre.y ) );
|
|
|
|
|
2015-12-27 15:51:13 +00:00
|
|
|
int copperLayerCount = GetBoard()->GetCopperLayerCount();
|
2017-01-23 20:30:11 +00:00
|
|
|
|
2015-12-27 15:51:13 +00:00
|
|
|
SetLayer( FlipLayer( GetLayer(), copperLayerCount ) );
|
2017-01-23 20:30:11 +00:00
|
|
|
SetMirrored( !IsMirrored() );
|
2009-08-01 19:26:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-14 15:42:44 +00:00
|
|
|
wxString TEXTE_PCB::GetSelectMenuText() const
|
|
|
|
{
|
2014-09-13 18:15:45 +00:00
|
|
|
wxString text;
|
2011-07-14 15:42:44 +00:00
|
|
|
|
2013-04-09 17:49:01 +00:00
|
|
|
text.Printf( _( "Pcb Text \"%s\" on %s"),
|
2014-09-13 18:15:45 +00:00
|
|
|
GetChars ( ShortenedShownText() ), GetChars( GetLayerName() ) );
|
2011-07-14 15:42:44 +00:00
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-20 12:20:39 +00:00
|
|
|
BITMAP_DEF TEXTE_PCB::GetMenuImage() const
|
|
|
|
{
|
2017-06-02 09:51:11 +00:00
|
|
|
return text_xpm;
|
2017-02-20 12:20:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-17 14:39:27 +00:00
|
|
|
EDA_ITEM* TEXTE_PCB::Clone() const
|
2012-01-14 19:50:32 +00:00
|
|
|
{
|
|
|
|
return new TEXTE_PCB( *this );
|
|
|
|
}
|