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>
|
|
|
|
* Copyright (C) 1992-2012 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 <pcbcommon.h>
|
|
|
|
#include <colors_selection.h>
|
|
|
|
#include <richio.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <macros.h>
|
2013-01-12 17:32:24 +00:00
|
|
|
#include <msgpanel.h>
|
|
|
|
#include <base_units.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
|
|
|
{
|
2009-05-05 17:32:07 +00:00
|
|
|
m_MultilineAllowed = true;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-07 06:21:19 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
TEXTE_PCB:: ~TEXTE_PCB()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-08-07 06:21:19 +00:00
|
|
|
|
|
|
|
void TEXTE_PCB::Copy( TEXTE_PCB* source )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-07 06:21:19 +00:00
|
|
|
m_Parent = source->m_Parent;
|
|
|
|
Pback = Pnext = NULL;
|
2008-12-20 20:38:39 +00:00
|
|
|
m_Mirror = source->m_Mirror;
|
2007-08-07 06:21:19 +00:00
|
|
|
m_Size = source->m_Size;
|
|
|
|
m_Orient = source->m_Orient;
|
|
|
|
m_Pos = source->m_Pos;
|
|
|
|
m_Layer = source->m_Layer;
|
2012-02-09 20:33:38 +00:00
|
|
|
m_Thickness = source->m_Thickness;
|
2007-08-07 06:21:19 +00:00
|
|
|
m_Attributs = source->m_Attributs;
|
2008-12-20 17:28:25 +00:00
|
|
|
m_Italic = source->m_Italic;
|
2009-05-30 16:06:01 +00:00
|
|
|
m_Bold = source->m_Bold;
|
2007-08-07 06:21:19 +00:00
|
|
|
m_HJustify = source->m_HJustify;
|
|
|
|
m_VJustify = source->m_VJustify;
|
2009-05-05 17:32:07 +00:00
|
|
|
m_MultilineAllowed = m_MultilineAllowed;
|
2007-08-07 06:21:19 +00:00
|
|
|
|
|
|
|
m_Text = source->m_Text;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-07 06:21:19 +00:00
|
|
|
|
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;
|
|
|
|
|
2012-09-02 12:06:47 +00:00
|
|
|
EDA_COLOR_T color = brd->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;
|
|
|
|
|
2011-07-04 21:32:49 +00:00
|
|
|
if( DisplayOpt.DisplayDrawItems == SKETCH )
|
2009-05-12 13:46:43 +00:00
|
|
|
fillmode = SKETCH;
|
2009-05-30 16:06:01 +00:00
|
|
|
|
2012-09-02 12:06:47 +00:00
|
|
|
EDA_COLOR_T anchor_color = UNSPECIFIED_COLOR;
|
2012-03-26 23:47:08 +00:00
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
if( brd->IsElementVisible( ANCHOR_VISIBLE ) )
|
2011-07-04 21:32:49 +00:00
|
|
|
anchor_color = brd->GetVisibleElementColor( ANCHOR_VISIBLE );
|
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;
|
|
|
|
|
2013-04-29 16:35:07 +00:00
|
|
|
#if defined(__WXDEBUG__)
|
2013-04-18 18:54:03 +00:00
|
|
|
BOARD_ITEM* parent = (BOARD_ITEM*) m_Parent;
|
2008-03-11 05:41:33 +00:00
|
|
|
wxASSERT( parent );
|
|
|
|
|
2013-04-18 18:54:03 +00:00
|
|
|
BOARD* board;
|
2011-10-01 19:24:27 +00:00
|
|
|
if( parent->Type() == PCB_DIMENSION_T )
|
2008-11-24 06:53:43 +00:00
|
|
|
board = (BOARD*) parent->GetParent();
|
2008-03-11 05:41:33 +00:00
|
|
|
else
|
|
|
|
board = (BOARD*) parent;
|
2013-01-12 17:32:24 +00:00
|
|
|
wxASSERT( board );
|
2013-04-18 18:54:03 +00:00
|
|
|
#endif
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( m_Parent && m_Parent->Type() == PCB_DIMENSION_T )
|
2013-04-07 11:55:18 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Dimension" ), m_Text, DARKGREEN ) );
|
2007-08-20 19:33:15 +00:00
|
|
|
else
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "PCB Text" ), m_Text, 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
|
|
|
|
2009-05-01 16:46:56 +00:00
|
|
|
if( !m_Mirror )
|
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
|
|
|
|
2013-05-01 17:32:36 +00:00
|
|
|
msg.Printf( wxT( "%.1f" ), m_Orient / 10.0 );
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Orientation" ), msg, DARKGREEN ) );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
msg = ::CoordinateToString( m_Thickness );
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Thickness" ), msg, MAGENTA ) );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
msg = ::CoordinateToString( m_Size.x );
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Size X" ), msg, RED ) );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
msg = ::CoordinateToString( m_Size.y );
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Size Y" ), msg, RED ) );
|
2007-08-20 19:33:15 +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 );
|
|
|
|
|
|
|
|
if( m_Orient )
|
|
|
|
rect = rect.GetBoundingBoxRotated( m_Pos, m_Orient );
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
RotatePoint( &m_Pos, aRotCentre, aAngle );
|
|
|
|
m_Orient += aAngle;
|
2011-09-28 06:10:15 +00:00
|
|
|
NORMALIZE_ANGLE_360( m_Orient );
|
2009-08-01 19:26:05 +00:00
|
|
|
}
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
void TEXTE_PCB::Flip(const wxPoint& aCentre )
|
|
|
|
{
|
2009-11-12 15:43:38 +00:00
|
|
|
m_Pos.y = aCentre.y - ( m_Pos.y - aCentre.y );
|
2013-04-05 19:04:58 +00:00
|
|
|
SetLayer( FlipLayer( GetLayer() ) );
|
2013-04-07 11:55:18 +00:00
|
|
|
m_Mirror = !m_Mirror;
|
2009-08-01 19:26:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-14 15:42:44 +00:00
|
|
|
wxString TEXTE_PCB::GetSelectMenuText() const
|
|
|
|
{
|
2011-10-22 18:21:57 +00:00
|
|
|
wxString text, shorttxt;
|
2011-07-14 15:42:44 +00:00
|
|
|
|
|
|
|
if( m_Text.Len() < 12 )
|
2011-10-22 18:21:57 +00:00
|
|
|
shorttxt << m_Text;
|
2011-07-14 15:42:44 +00:00
|
|
|
else
|
2013-04-04 21:35:01 +00:00
|
|
|
shorttxt += m_Text.Left( 10 ) + wxT( "..." );
|
2011-07-14 15:42:44 +00:00
|
|
|
|
2013-04-09 17:49:01 +00:00
|
|
|
text.Printf( _( "Pcb Text \"%s\" on %s"),
|
2011-10-22 18:21:57 +00:00
|
|
|
GetChars ( shorttxt ), GetChars( GetLayerName() ) );
|
2011-07-14 15:42:44 +00:00
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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 );
|
|
|
|
}
|