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>
|
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
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <protos.h>
|
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
|
|
|
|
2012-09-02 12:06:47 +00:00
|
|
|
EDA_TEXT::Draw( panel, DC, offset, color,
|
|
|
|
DrawMode, fillmode, anchor_color );
|
2007-08-07 06:21:19 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void TEXTE_PCB::DisplayInfo( EDA_DRAW_FRAME* frame )
|
2007-08-20 19:33:15 +00:00
|
|
|
{
|
2009-05-01 16:46:56 +00:00
|
|
|
wxString msg;
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2008-03-11 05:41:33 +00:00
|
|
|
BOARD* board;
|
|
|
|
BOARD_ITEM* parent = (BOARD_ITEM*) m_Parent;
|
2009-05-01 16:46:56 +00:00
|
|
|
|
2008-03-11 05:41:33 +00:00
|
|
|
wxASSERT( parent );
|
|
|
|
|
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;
|
2008-03-04 04:22:27 +00:00
|
|
|
wxASSERT( board );
|
|
|
|
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->ClearMsgPanel();
|
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 )
|
2010-04-23 09:54:40 +00:00
|
|
|
frame->AppendMsgPanel( _( "DIMENSION" ), m_Text, DARKGREEN );
|
2007-08-20 19:33:15 +00:00
|
|
|
else
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->AppendMsgPanel( _( "PCB Text" ), m_Text, DARKGREEN );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->AppendMsgPanel( _( "Layer" ),
|
2009-10-11 13:04:47 +00:00
|
|
|
board->GetLayerName( m_Layer ), BLUE );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2009-05-01 16:46:56 +00:00
|
|
|
if( !m_Mirror )
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->AppendMsgPanel( _( "Mirror" ), _( "No" ), DARKGREEN );
|
2007-08-20 19:33:15 +00:00
|
|
|
else
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->AppendMsgPanel( _( "Mirror" ), _( "Yes" ), DARKGREEN );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
|
|
|
msg.Printf( wxT( "%.1f" ), (float) m_Orient / 10 );
|
2011-07-04 21:32:49 +00:00
|
|
|
frame->AppendMsgPanel( _( "Orientation" ), msg, DARKGREEN );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2012-04-27 06:11:41 +00:00
|
|
|
msg = frame->CoordinateToString( m_Thickness );
|
2010-11-27 13:09:18 +00:00
|
|
|
frame->AppendMsgPanel( _( "Thickness" ), msg, MAGENTA );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2012-04-27 06:11:41 +00:00
|
|
|
msg = frame->CoordinateToString( m_Size.x );
|
2011-07-04 21:32:49 +00:00
|
|
|
frame->AppendMsgPanel( _( "Size X" ), msg, RED );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2012-04-27 06:11:41 +00:00
|
|
|
msg = frame->CoordinateToString( m_Size.y );
|
2011-07-04 21:32:49 +00:00
|
|
|
frame->AppendMsgPanel( _( "Size Y" ), msg, RED );
|
2007-08-20 19:33:15 +00:00
|
|
|
}
|
|
|
|
|
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 );
|
2011-09-28 06:10:15 +00:00
|
|
|
// NEGATE( m_Orient ); not needed: m_Mirror handles this
|
2012-05-30 17:38:52 +00:00
|
|
|
if( GetLayer() == LAYER_N_BACK
|
|
|
|
|| GetLayer() == LAYER_N_FRONT
|
|
|
|
|| GetLayer() == SILKSCREEN_N_BACK
|
|
|
|
|| GetLayer() == SILKSCREEN_N_FRONT )
|
2009-08-01 19:26:05 +00:00
|
|
|
{
|
2009-11-12 15:43:38 +00:00
|
|
|
m_Mirror = not m_Mirror; /* inverse mirror */
|
2009-08-01 19:26:05 +00:00
|
|
|
}
|
2012-04-11 09:47:57 +00:00
|
|
|
SetLayer( BOARD::ReturnFlippedLayerNumber( GetLayer() ) );
|
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
|
2011-10-22 18:21:57 +00:00
|
|
|
shorttxt += m_Text.Left( 10 ) + wxT( ".." );
|
2011-07-14 15:42:44 +00:00
|
|
|
|
2011-10-22 18:21:57 +00:00
|
|
|
text.Printf( _( "Pcb Text %s on %s"),
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-07 06:21:19 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
|
2011-12-14 17:25:42 +00:00
|
|
|
void TEXTE_PCB::Show( int nestLevel, std::ostream& os ) const
|
2007-08-07 06:21:19 +00:00
|
|
|
{
|
|
|
|
// for now, make it look like XML:
|
2007-08-08 03:50:44 +00:00
|
|
|
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() <<
|
2009-05-01 16:46:56 +00:00
|
|
|
" string=\"" << m_Text.mb_str() << "\"/>\n";
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
// NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str()
|
|
|
|
// << ">\n";
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2009-05-01 16:46:56 +00:00
|
|
|
|
2007-08-07 06:21:19 +00:00
|
|
|
#endif
|