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_module.cpp
|
|
|
|
* @brief TEXT_MODULE class implementation.
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <wxstruct.h>
|
|
|
|
#include <trigo.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <drawtxt.h>
|
|
|
|
#include <kicad_string.h>
|
|
|
|
#include <pcbcommon.h>
|
|
|
|
#include <colors_selection.h>
|
|
|
|
#include <richio.h>
|
|
|
|
#include <macros.h>
|
|
|
|
#include <wxBasePcbFrame.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_module.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2013-04-07 11:55:18 +00:00
|
|
|
TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, TEXT_TYPE text_type ) :
|
2012-01-14 19:50:32 +00:00
|
|
|
BOARD_ITEM( parent, PCB_MODULE_TEXT_T ),
|
|
|
|
EDA_TEXT()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-05-31 15:18:55 +00:00
|
|
|
MODULE* module = (MODULE*) m_Parent;
|
2007-08-04 20:05:54 +00:00
|
|
|
|
2013-04-07 11:55:18 +00:00
|
|
|
m_Type = text_type;
|
2007-08-04 20:05:54 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
m_NoShow = false;
|
2013-03-26 17:05:47 +00:00
|
|
|
|
|
|
|
// Set text tickness to a default value
|
2013-04-07 11:55:18 +00:00
|
|
|
m_Thickness = Millimeter2iu( 0.15 );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
SetLayer( F_SilkS );
|
2012-01-14 19:50:32 +00:00
|
|
|
|
2012-05-31 15:18:55 +00:00
|
|
|
if( module && ( module->Type() == PCB_MODULE_T ) )
|
2007-08-04 20:05:54 +00:00
|
|
|
{
|
2013-03-13 18:53:58 +00:00
|
|
|
m_Pos = module->GetPosition();
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2013-04-07 11:55:18 +00:00
|
|
|
if( IsBackLayer( module->GetLayer() ) )
|
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
SetLayer( B_SilkS );
|
2013-04-07 11:55:18 +00:00
|
|
|
m_Mirror = true;
|
|
|
|
}
|
2008-03-04 04:22:27 +00:00
|
|
|
else
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
SetLayer( F_SilkS );
|
2013-04-07 11:55:18 +00:00
|
|
|
m_Mirror = false;
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
2007-08-04 20:05:54 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-04 20:05:54 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
TEXTE_MODULE::~TEXTE_MODULE()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-03 12:15:37 +00:00
|
|
|
void TEXTE_MODULE::Rotate( const wxPoint& aRotCentre, double aAngle )
|
|
|
|
{
|
|
|
|
RotatePoint( &m_Pos, aRotCentre, aAngle );
|
|
|
|
m_Orient += aAngle;
|
|
|
|
NORMALIZE_ANGLE_360( m_Orient );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TEXTE_MODULE::Flip(const wxPoint& aCentre )
|
|
|
|
{
|
|
|
|
m_Pos.y = aCentre.y - ( m_Pos.y - aCentre.y );
|
|
|
|
SetLayer( FlipLayer( GetLayer() ) );
|
|
|
|
m_Mirror = !m_Mirror;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-09 08:05:42 +00:00
|
|
|
void TEXTE_MODULE::Copy( TEXTE_MODULE* source )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-04 20:05:54 +00:00
|
|
|
if( source == NULL )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-08-09 08:05:42 +00:00
|
|
|
m_Pos = source->m_Pos;
|
2007-08-23 04:28:46 +00:00
|
|
|
SetLayer( source->GetLayer() );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
m_Mirror = source->m_Mirror;
|
|
|
|
m_NoShow = source->m_NoShow;
|
|
|
|
m_Type = source->m_Type;
|
|
|
|
m_Orient = source->m_Orient;
|
|
|
|
m_Pos0 = source->m_Pos0;
|
|
|
|
m_Size = source->m_Size;
|
2010-11-27 13:09:18 +00:00
|
|
|
m_Thickness = source->m_Thickness;
|
2009-05-30 16:06:01 +00:00
|
|
|
m_Italic = source->m_Italic;
|
2009-11-12 15:43:38 +00:00
|
|
|
m_Bold = source->m_Bold;
|
|
|
|
m_Text = source->m_Text;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-04 20:05:54 +00:00
|
|
|
|
2012-01-14 19:50:32 +00:00
|
|
|
int TEXTE_MODULE::GetLength() const
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-04 20:05:54 +00:00
|
|
|
return m_Text.Len();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
// Update draw coordinates
|
2012-01-14 19:50:32 +00:00
|
|
|
void TEXTE_MODULE::SetDrawCoord()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-05-31 15:18:55 +00:00
|
|
|
MODULE* module = (MODULE*) m_Parent;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-04 20:05:54 +00:00
|
|
|
m_Pos = m_Pos0;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-05-31 15:18:55 +00:00
|
|
|
if( module == NULL )
|
2007-08-04 20:05:54 +00:00
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-05-31 15:18:55 +00:00
|
|
|
double angle = module->GetOrientation();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-04 20:05:54 +00:00
|
|
|
RotatePoint( &m_Pos.x, &m_Pos.y, angle );
|
2012-05-31 15:18:55 +00:00
|
|
|
m_Pos += module->GetPosition();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-04 20:05:54 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
// Update "local" coordinates (coordinates relatives to the footprint
|
|
|
|
// anchor point)
|
2012-01-14 19:50:32 +00:00
|
|
|
void TEXTE_MODULE::SetLocalCoord()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-05-31 15:18:55 +00:00
|
|
|
MODULE* module = (MODULE*) m_Parent;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-05-31 15:18:55 +00:00
|
|
|
if( module == NULL )
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
|
|
|
m_Pos0 = m_Pos;
|
2007-08-04 20:05:54 +00:00
|
|
|
return;
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
m_Pos0 = m_Pos - module->GetPosition();
|
2013-05-05 07:17:48 +00:00
|
|
|
double angle = module->GetOrientation();
|
2007-08-04 20:05:54 +00:00
|
|
|
RotatePoint( &m_Pos0.x, &m_Pos0.y, -angle );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2014-05-04 17:08:36 +00:00
|
|
|
bool TEXTE_MODULE::HitTest( const wxPoint& aPosition ) const
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-08-09 08:05:42 +00:00
|
|
|
wxPoint rel_pos;
|
2013-11-05 17:12:27 +00:00
|
|
|
EDA_RECT area = GetTextBox( -1, -1 );
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2008-03-15 10:24:32 +00:00
|
|
|
/* Rotate refPos to - angle
|
2009-11-12 15:43:38 +00:00
|
|
|
* to test if refPos is within area (which is relative to an horizontal
|
|
|
|
* text)
|
2008-08-09 08:05:42 +00:00
|
|
|
*/
|
2012-03-15 14:31:16 +00:00
|
|
|
rel_pos = aPosition;
|
2008-08-09 08:05:42 +00:00
|
|
|
RotatePoint( &rel_pos, m_Pos, -GetDrawRotation() );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-12-20 17:44:25 +00:00
|
|
|
if( area.Contains( rel_pos ) )
|
2007-08-04 20:05:54 +00:00
|
|
|
return true;
|
2008-03-15 10:24:32 +00:00
|
|
|
|
2007-08-04 20:05:54 +00:00
|
|
|
return false;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-08-09 08:05:42 +00:00
|
|
|
|
2013-11-24 17:48:14 +00:00
|
|
|
/*
|
|
|
|
* Function GetBoundingBox (virtual)
|
2009-11-12 15:43:38 +00:00
|
|
|
* returns the bounding box of this Text (according to text and footprint
|
|
|
|
* orientation)
|
2008-03-15 10:24:32 +00:00
|
|
|
*/
|
2013-11-24 17:48:14 +00:00
|
|
|
const EDA_RECT TEXTE_MODULE::GetBoundingBox() const
|
2008-03-15 10:24:32 +00:00
|
|
|
{
|
2013-05-05 07:17:48 +00:00
|
|
|
double angle = GetDrawRotation();
|
2013-11-05 17:12:27 +00:00
|
|
|
EDA_RECT text_area = GetTextBox( -1, -1 );
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2013-11-05 17:12:27 +00:00
|
|
|
if( angle )
|
|
|
|
text_area = text_area.GetBoundingBoxRotated( m_Pos, m_Orient );
|
2008-04-01 05:21:50 +00:00
|
|
|
|
|
|
|
return text_area;
|
2008-03-15 10:24:32 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-08-09 08:05:42 +00:00
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function Draw
|
2009-11-12 15:43:38 +00:00
|
|
|
* Draw the text according to the footprint pos and orient
|
2008-03-15 10:24:32 +00:00
|
|
|
* @param panel = draw panel, Used to know the clip box
|
|
|
|
* @param DC = Current Device Context
|
|
|
|
* @param offset = draw offset (usually wxPoint(0,0)
|
|
|
|
* @param draw_mode = GR_OR, GR_XOR..
|
2007-08-04 20:05:54 +00:00
|
|
|
*/
|
2012-09-01 13:38:27 +00:00
|
|
|
void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
|
|
|
|
const wxPoint& offset )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2013-06-29 09:52:22 +00:00
|
|
|
MODULE* module = (MODULE*) m_Parent;
|
2007-08-04 20:05:54 +00:00
|
|
|
|
2013-03-31 18:57:31 +00:00
|
|
|
/* parent must *not* be NULL (a module text without a footprint
|
|
|
|
parent has no sense) */
|
|
|
|
wxASSERT( module );
|
2007-08-04 20:05:54 +00:00
|
|
|
|
|
|
|
if( panel == NULL )
|
|
|
|
return;
|
|
|
|
|
2013-03-31 18:57:31 +00:00
|
|
|
BOARD* brd = GetBoard( );
|
|
|
|
EDA_COLOR_T color;
|
|
|
|
// Determine the element color or suppress it element if hidden
|
|
|
|
switch( module->GetLayer() )
|
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
case B_Cu:
|
2013-03-31 18:57:31 +00:00
|
|
|
if( !brd->IsElementVisible( MOD_TEXT_BK_VISIBLE ) )
|
|
|
|
return;
|
|
|
|
color = brd->GetVisibleElementColor( MOD_TEXT_BK_VISIBLE );
|
|
|
|
break;
|
2007-08-04 20:05:54 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
case F_Cu:
|
2013-03-31 18:57:31 +00:00
|
|
|
if( !brd->IsElementVisible( MOD_TEXT_FR_VISIBLE ) )
|
|
|
|
return;
|
|
|
|
color = brd->GetVisibleElementColor( MOD_TEXT_FR_VISIBLE );
|
|
|
|
break;
|
2007-08-04 20:05:54 +00:00
|
|
|
|
2013-03-31 18:57:31 +00:00
|
|
|
default:
|
|
|
|
color = brd->GetLayerColor( module->GetLayer() );
|
|
|
|
}
|
2007-08-04 20:05:54 +00:00
|
|
|
|
2013-03-31 18:57:31 +00:00
|
|
|
// 'Ghost' the element if forced show
|
|
|
|
if( m_NoShow )
|
|
|
|
{
|
|
|
|
if( !brd->IsElementVisible( MOD_TEXT_INVISIBLE ) )
|
|
|
|
return;
|
|
|
|
color = brd->GetVisibleElementColor( MOD_TEXT_INVISIBLE );
|
|
|
|
}
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2013-03-31 18:57:31 +00:00
|
|
|
// Draw mode compensation for the width
|
|
|
|
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent();
|
|
|
|
int width = m_Thickness;
|
2012-01-03 17:14:17 +00:00
|
|
|
if( ( frame->m_DisplayModText == LINE )
|
2013-04-09 17:16:53 +00:00
|
|
|
|| ( DC->LogicalToDeviceXRel( width ) <= MIN_DRAW_WIDTH ) )
|
2007-08-04 20:05:54 +00:00
|
|
|
width = 0;
|
|
|
|
else if( frame->m_DisplayModText == SKETCH )
|
|
|
|
width = -width;
|
|
|
|
|
|
|
|
GRSetDrawMode( DC, draw_mode );
|
2013-06-29 09:52:22 +00:00
|
|
|
wxPoint pos( m_Pos.x - offset.x,
|
2013-03-31 18:57:31 +00:00
|
|
|
m_Pos.y - offset.y);
|
2007-08-04 20:05:54 +00:00
|
|
|
|
2013-03-31 18:57:31 +00:00
|
|
|
// Draw the text anchor point
|
2010-01-31 20:01:46 +00:00
|
|
|
if( brd->IsElementVisible( ANCHOR_VISIBLE ) )
|
2007-08-04 20:05:54 +00:00
|
|
|
{
|
2013-03-31 18:57:31 +00:00
|
|
|
EDA_COLOR_T anchor_color = brd->GetVisibleElementColor(ANCHOR_VISIBLE);
|
2013-06-29 09:52:22 +00:00
|
|
|
GRDrawAnchor( panel->GetClipBox(), DC, pos.x, pos.y,
|
2013-04-09 16:00:46 +00:00
|
|
|
DIM_ANCRE_TEXTE, anchor_color );
|
2009-10-10 01:25:53 +00:00
|
|
|
}
|
2007-08-04 20:05:54 +00:00
|
|
|
|
2013-03-31 18:57:31 +00:00
|
|
|
// Draw the text proper, with the right attributes
|
|
|
|
wxSize size = m_Size;
|
2013-05-05 07:17:48 +00:00
|
|
|
double orient = GetDrawRotation();
|
2007-08-04 20:05:54 +00:00
|
|
|
|
2013-03-31 18:57:31 +00:00
|
|
|
// If the text is mirrored : negate size.x (mirror / Y axis)
|
2008-12-22 21:06:44 +00:00
|
|
|
if( m_Mirror )
|
2007-08-04 20:05:54 +00:00
|
|
|
size.x = -size.x;
|
|
|
|
|
2013-06-29 09:52:22 +00:00
|
|
|
EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
|
|
|
|
DrawGraphicText( clipbox, DC, pos, color, m_Text, orient,
|
2009-11-12 15:43:38 +00:00
|
|
|
size, m_HJustify, m_VJustify, width, m_Italic, m_Bold );
|
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-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2011-07-14 15:42:44 +00:00
|
|
|
/* Draws a line from the TEXTE_MODULE origin to parent MODULE origin.
|
2010-12-28 11:24:42 +00:00
|
|
|
*/
|
2011-01-21 19:30:59 +00:00
|
|
|
void TEXTE_MODULE::DrawUmbilical( EDA_DRAW_PANEL* aPanel,
|
|
|
|
wxDC* aDC,
|
2012-09-01 13:38:27 +00:00
|
|
|
GR_DRAWMODE aDrawMode,
|
2011-01-21 19:30:59 +00:00
|
|
|
const wxPoint& aOffset )
|
2010-11-18 13:38:08 +00:00
|
|
|
{
|
|
|
|
MODULE* parent = (MODULE*) GetParent();
|
2011-12-29 20:11:42 +00:00
|
|
|
|
2010-11-18 13:38:08 +00:00
|
|
|
if( !parent )
|
|
|
|
return;
|
|
|
|
|
|
|
|
GRSetDrawMode( aDC, GR_XOR );
|
2011-12-29 20:11:42 +00:00
|
|
|
GRLine( aPanel->GetClipBox(), aDC,
|
2013-03-18 19:36:07 +00:00
|
|
|
parent->GetPosition(), GetTextPosition() + aOffset,
|
2010-11-18 13:38:08 +00:00
|
|
|
0, UMBILICAL_COLOR);
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/* Return text rotation for drawings and plotting
|
2007-08-04 20:05:54 +00:00
|
|
|
*/
|
2013-05-05 07:17:48 +00:00
|
|
|
double TEXTE_MODULE::GetDrawRotation() const
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-05-31 15:18:55 +00:00
|
|
|
MODULE* module = (MODULE*) m_Parent;
|
2013-05-05 07:17:48 +00:00
|
|
|
double rotation = m_Orient;
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2012-05-31 15:18:55 +00:00
|
|
|
if( module )
|
2013-03-13 18:53:58 +00:00
|
|
|
rotation += module->GetOrientation();
|
2007-08-04 20:05:54 +00:00
|
|
|
|
|
|
|
NORMALIZE_ANGLE_POS( rotation );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
// For angle = 0 .. 180 deg
|
2007-08-04 20:05:54 +00:00
|
|
|
while( rotation > 900 )
|
|
|
|
rotation -= 1800;
|
|
|
|
|
|
|
|
return rotation;
|
|
|
|
}
|
2007-08-06 20:26:59 +00:00
|
|
|
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
// see class_text_mod.h
|
2013-01-12 17:32:24 +00:00
|
|
|
void TEXTE_MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
|
2007-08-20 19:33:15 +00:00
|
|
|
{
|
2009-11-23 21:03:26 +00:00
|
|
|
MODULE* module = (MODULE*) m_Parent;
|
|
|
|
|
2009-08-11 10:27:21 +00:00
|
|
|
if( module == NULL ) // Happens in modedit, and for new texts
|
2007-08-20 19:33:15 +00:00
|
|
|
return;
|
|
|
|
|
2009-08-11 10:27:21 +00:00
|
|
|
wxString msg, Line;
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2009-11-23 21:03:26 +00:00
|
|
|
static const wxString text_type_msg[3] =
|
|
|
|
{
|
2008-08-09 08:05:42 +00:00
|
|
|
_( "Ref." ), _( "Value" ), _( "Text" )
|
|
|
|
};
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
Line = module->GetReference();
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Module" ), Line, DARKCYAN ) );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
|
|
|
Line = m_Text;
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Text" ), Line, BROWN ) );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2013-04-07 11:55:18 +00:00
|
|
|
wxASSERT( m_Type >= TEXT_is_REFERENCE && m_Type <= TEXT_is_DIVERS );
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Type" ), text_type_msg[m_Type], DARKGREEN ) );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
|
|
|
if( m_NoShow )
|
2008-08-09 08:05:42 +00:00
|
|
|
msg = _( "No" );
|
2007-08-20 19:33:15 +00:00
|
|
|
else
|
2008-08-09 08:05:42 +00:00
|
|
|
msg = _( "Yes" );
|
2013-01-12 17:32:24 +00:00
|
|
|
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Display" ), msg, DARKGREEN ) );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2013-04-07 11:55:18 +00:00
|
|
|
// Display text layer
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), DARKGREEN ) );
|
2013-01-12 17:32:24 +00:00
|
|
|
|
2008-12-22 21:06:44 +00:00
|
|
|
if( m_Mirror )
|
|
|
|
msg = _( " Yes" );
|
2013-04-07 11:55:18 +00:00
|
|
|
else
|
|
|
|
msg = _( " No" );
|
2013-01-12 17:32:24 +00:00
|
|
|
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), msg, 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( _( "Orient" ), 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, DARKGREEN ) );
|
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( _( "H Size" ), 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( _( "V Size" ), msg, RED ) );
|
2007-08-20 19:33:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-14 15:42:44 +00:00
|
|
|
wxString TEXTE_MODULE::GetSelectMenuText() const
|
|
|
|
{
|
|
|
|
wxString text;
|
|
|
|
|
|
|
|
switch( m_Type )
|
|
|
|
{
|
|
|
|
case TEXT_is_REFERENCE:
|
2013-04-09 17:49:01 +00:00
|
|
|
text.Printf( _( "Reference %s" ), GetChars( m_Text ) );
|
2011-07-14 15:42:44 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TEXT_is_VALUE:
|
2013-04-09 17:49:01 +00:00
|
|
|
text.Printf( _( "Value %s of %s" ), GetChars( m_Text ),
|
|
|
|
GetChars( ( (MODULE*) GetParent() )->GetReference() ) );
|
2011-07-14 15:42:44 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default: // wrap this one in quotes:
|
2013-04-09 17:49:01 +00:00
|
|
|
text.Printf( _( "Text \"%s\" on %s of %s" ), GetChars( m_Text ),
|
|
|
|
GetChars( GetLayerName() ),
|
|
|
|
GetChars( ( (MODULE*) GetParent() )->GetReference() ) );
|
2011-07-14 15:42:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-17 14:39:27 +00:00
|
|
|
EDA_ITEM* TEXTE_MODULE::Clone() const
|
2012-01-14 19:50:32 +00:00
|
|
|
{
|
|
|
|
return new TEXTE_MODULE( *this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-07 13:09:27 +00:00
|
|
|
const BOX2I TEXTE_MODULE::ViewBBox() const
|
|
|
|
{
|
|
|
|
double angle = GetDrawRotation();
|
|
|
|
EDA_RECT text_area = GetTextBox( -1, -1 );
|
|
|
|
|
|
|
|
if( angle )
|
|
|
|
text_area = text_area.GetBoundingBoxRotated( m_Pos, angle );
|
|
|
|
|
|
|
|
return BOX2I( text_area.GetPosition(), text_area.GetSize() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
void TEXTE_MODULE::ViewGetLayers( int aLayers[], int& aCount ) const
|
|
|
|
{
|
2014-01-26 21:02:48 +00:00
|
|
|
if( m_NoShow ) // Hidden text
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2014-01-26 21:02:48 +00:00
|
|
|
aLayers[0] = ITEM_GAL_LAYER( MOD_TEXT_INVISIBLE );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch( m_Type )
|
2013-04-02 09:03:15 +00:00
|
|
|
{
|
2014-01-26 21:02:48 +00:00
|
|
|
case TEXT_is_REFERENCE:
|
|
|
|
aLayers[0] = ITEM_GAL_LAYER( MOD_REFERENCES_VISIBLE );
|
2013-04-02 09:03:15 +00:00
|
|
|
break;
|
|
|
|
|
2014-01-26 21:02:48 +00:00
|
|
|
case TEXT_is_VALUE:
|
|
|
|
aLayers[0] = ITEM_GAL_LAYER( MOD_VALUES_VISIBLE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
switch( GetParent()->GetLayer() )
|
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
case B_Cu:
|
|
|
|
aLayers[0] = ITEM_GAL_LAYER( MOD_TEXT_BK_VISIBLE ); // how about B_SilkS?
|
2014-01-26 21:02:48 +00:00
|
|
|
break;
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
case F_Cu:
|
|
|
|
aLayers[0] = ITEM_GAL_LAYER( MOD_TEXT_FR_VISIBLE ); // how about F_SilkS?
|
2014-01-26 21:02:48 +00:00
|
|
|
break;
|
2014-05-04 17:08:36 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
wxFAIL_MSG( wxT( "Can't tell text layer" ) );
|
2014-01-26 21:02:48 +00:00
|
|
|
}
|
2013-04-02 09:03:15 +00:00
|
|
|
break;
|
|
|
|
}
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 09:39:08 +00:00
|
|
|
aCount = 1;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|