2007-06-05 12:10:51 +00:00
|
|
|
/************************************/
|
|
|
|
/* fonctions de la classe TEXTE_PCB */
|
|
|
|
/************************************/
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "wxstruct.h"
|
|
|
|
|
|
|
|
#include "gr_basic.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "pcbnew.h"
|
|
|
|
|
|
|
|
|
2007-08-07 06:21:19 +00:00
|
|
|
/*******************/
|
|
|
|
/* class TEXTE_PCB */
|
|
|
|
/*******************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
TEXTE_PCB::TEXTE_PCB( BOARD_ITEM* parent ) :
|
|
|
|
BOARD_ITEM( parent, TYPETEXTE ),
|
2007-08-07 06:21:19 +00:00
|
|
|
EDA_TextStruct()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-08-07 06:21:19 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Destructeur */
|
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
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* copie de stucture */
|
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;
|
|
|
|
m_Miroir = source->m_Miroir;
|
|
|
|
m_Size = source->m_Size;
|
|
|
|
m_Orient = source->m_Orient;
|
|
|
|
m_Pos = source->m_Pos;
|
|
|
|
m_Layer = source->m_Layer;
|
|
|
|
m_Width = source->m_Width;
|
|
|
|
m_Attributs = source->m_Attributs;
|
|
|
|
m_CharType = source->m_CharType;
|
|
|
|
m_HJustify = source->m_HJustify;
|
|
|
|
m_VJustify = source->m_VJustify;
|
|
|
|
|
|
|
|
m_Text = source->m_Text;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-07 06:21:19 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
void TEXTE_PCB::UnLink()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-07 06:21:19 +00:00
|
|
|
/* Modification du chainage arriere */
|
|
|
|
if( Pback )
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
if( Pback->Type() != TYPEPCB )
|
2007-08-07 06:21:19 +00:00
|
|
|
{
|
|
|
|
Pback->Pnext = Pnext;
|
|
|
|
}
|
|
|
|
else /* Le chainage arriere pointe sur la structure "Pere" */
|
|
|
|
{
|
2007-08-23 04:28:46 +00:00
|
|
|
( (BOARD*) Pback )->m_Drawings = (BOARD_ITEM*) Pnext;
|
2007-08-07 06:21:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Modification du chainage avant */
|
|
|
|
if( Pnext )
|
|
|
|
Pnext->Pback = Pback;
|
|
|
|
|
|
|
|
Pnext = Pback = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-07 06:21:19 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/****************************************************************/
|
2007-08-07 06:21:19 +00:00
|
|
|
int TEXTE_PCB::ReadTextePcbDescr( FILE* File, int* LineNum )
|
2007-06-05 12:10:51 +00:00
|
|
|
/****************************************************************/
|
|
|
|
{
|
2007-08-07 06:21:19 +00:00
|
|
|
char text[1024], Line[1024];
|
|
|
|
int dummy;
|
|
|
|
|
|
|
|
while( GetLine( File, Line, LineNum ) != NULL )
|
|
|
|
{
|
|
|
|
if( strnicmp( Line, "$EndTEXTPCB", 11 ) == 0 )
|
|
|
|
return 0;
|
|
|
|
if( strncmp( Line, "Te", 2 ) == 0 ) /* Texte */
|
|
|
|
{
|
|
|
|
ReadDelimitedText( text, Line + 2, sizeof(text) );
|
|
|
|
m_Text = CONV_FROM_UTF8( text );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if( strncmp( Line, "Po", 2 ) == 0 )
|
|
|
|
{
|
|
|
|
sscanf( Line + 2, " %d %d %d %d %d %d",
|
|
|
|
&m_Pos.x, &m_Pos.y, &m_Size.x, &m_Size.y,
|
|
|
|
&m_Width, &m_Orient );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if( strncmp( Line, "De", 2 ) == 0 )
|
|
|
|
{
|
|
|
|
sscanf( Line + 2, " %d %d %lX %d\n", &m_Layer, &m_Miroir,
|
|
|
|
&m_TimeStamp, &dummy );
|
2007-11-01 05:27:31 +00:00
|
|
|
if( m_Layer < FIRST_COPPER_LAYER )
|
|
|
|
m_Layer = FIRST_COPPER_LAYER;
|
2007-08-07 06:21:19 +00:00
|
|
|
if( m_Layer > LAST_NO_COPPER_LAYER )
|
|
|
|
m_Layer = LAST_NO_COPPER_LAYER;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
bool TEXTE_PCB::Save( FILE* aFile ) const
|
|
|
|
{
|
|
|
|
if( GetState( DELETED ) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if( m_Text.IsEmpty() )
|
|
|
|
return true;
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
bool rc = false;
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
if( fprintf( aFile, "$TEXTPCB\n" ) != sizeof("$TEXTPCB\n")-1 )
|
|
|
|
goto out;
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
fprintf( aFile, "Te \"%s\"\n", CONV_TO_UTF8( m_Text ) );
|
|
|
|
fprintf( aFile, "Po %d %d %d %d %d %d\n",
|
|
|
|
m_Pos.x, m_Pos.y, m_Size.x, m_Size.y, m_Width, m_Orient );
|
|
|
|
fprintf( aFile, "De %d %d %lX %d\n", m_Layer, m_Miroir, m_TimeStamp, 0 );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
if( fprintf( aFile, "$EndTEXTPCB\n" ) != sizeof("$EndTEXTPCB\n")-1 )
|
|
|
|
goto out;
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
rc = true;
|
2008-03-04 04:22:27 +00:00
|
|
|
out:
|
2007-10-30 21:30:58 +00:00
|
|
|
return rc;
|
|
|
|
}
|
2008-03-04 04:22:27 +00:00
|
|
|
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-07 06:21:19 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/**********************************************************************/
|
2007-08-07 06:21:19 +00:00
|
|
|
void TEXTE_PCB::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
|
|
|
|
const wxPoint& offset, int DrawMode )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**********************************************************************/
|
2007-08-07 06:21:19 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*
|
2007-08-07 06:21:19 +00:00
|
|
|
* DrawMode = GR_OR, GR_XOR.., -1 si mode courant.
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-07 06:21:19 +00:00
|
|
|
int color = g_DesignSettings.m_LayerColor[m_Layer];
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-07 06:21:19 +00:00
|
|
|
if( color & ITEM_NOT_SHOW )
|
|
|
|
return;
|
|
|
|
|
|
|
|
EDA_TextStruct::Draw( panel, DC, offset, color,
|
|
|
|
DrawMode, DisplayOpt.DisplayDrawItems,
|
|
|
|
(g_AnchorColor & ITEM_NOT_SHOW) ? -1 : (g_AnchorColor & MASKCOLOR) );
|
|
|
|
}
|
|
|
|
|
2007-08-20 19:33:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// see class_pcb_text.h
|
|
|
|
void TEXTE_PCB::Display_Infos( WinEDA_DrawFrame* frame )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
BOARD* board = (BOARD*) m_Parent;
|
|
|
|
wxASSERT( board );
|
|
|
|
|
2007-08-20 19:33:15 +00:00
|
|
|
frame->MsgPanel->EraseMsgBox();
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
if( m_Parent && m_Parent->Type() == TYPECOTATION )
|
2007-08-20 19:33:15 +00:00
|
|
|
Affiche_1_Parametre( frame, 1, _( "COTATION" ), m_Text, DARKGREEN );
|
|
|
|
else
|
|
|
|
Affiche_1_Parametre( frame, 1, _( "PCB Text" ), m_Text, DARKGREEN );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2007-08-20 19:33:15 +00:00
|
|
|
Affiche_1_Parametre( frame, 28, _( "Layer" ),
|
2008-03-04 04:22:27 +00:00
|
|
|
board->GetLayerName( m_Layer ),
|
2007-08-20 19:33:15 +00:00
|
|
|
g_DesignSettings.m_LayerColor[m_Layer] & MASKCOLOR );
|
|
|
|
|
|
|
|
Affiche_1_Parametre( frame, 36, _( "Mirror" ), wxEmptyString, GREEN );
|
|
|
|
if( m_Miroir & 1 )
|
|
|
|
Affiche_1_Parametre( frame, -1, wxEmptyString, _( "No" ), DARKGREEN );
|
|
|
|
else
|
|
|
|
Affiche_1_Parametre( frame, -1, wxEmptyString, _( "Yes" ), DARKGREEN );
|
|
|
|
|
|
|
|
msg.Printf( wxT( "%.1f" ), (float) m_Orient / 10 );
|
|
|
|
Affiche_1_Parametre( frame, 43, _( "Orient" ), msg, DARKGREEN );
|
|
|
|
|
|
|
|
valeur_param( m_Width, msg );
|
|
|
|
Affiche_1_Parametre( frame, 50, _( "Width" ), msg, MAGENTA );
|
|
|
|
|
|
|
|
valeur_param( m_Size.x, msg );
|
|
|
|
Affiche_1_Parametre( frame, 60, _( "H Size" ), msg, RED );
|
|
|
|
|
|
|
|
valeur_param( m_Size.y, msg );
|
|
|
|
Affiche_1_Parametre( frame, 70, _( "V Size" ), msg, RED );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-07 06:21:19 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Show
|
|
|
|
* is used to output the object tree, currently for debugging only.
|
2008-03-04 04:22:27 +00:00
|
|
|
* @param nestLevel An aid to prettier tree indenting, and is the level
|
2007-08-07 06:21:19 +00:00
|
|
|
* of nesting of this object within the overall tree.
|
|
|
|
* @param os The ostream& to output to.
|
|
|
|
*/
|
|
|
|
void TEXTE_PCB::Show( int nestLevel, std::ostream& os )
|
|
|
|
{
|
|
|
|
// for now, make it look like XML:
|
2007-08-08 03:50:44 +00:00
|
|
|
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() <<
|
2008-03-04 04:22:27 +00:00
|
|
|
" string=\"" << m_Text.mb_str() << "\"/>\n";
|
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
// NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-07 06:21:19 +00:00
|
|
|
#endif
|