|
|
|
@ -45,7 +45,7 @@ TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, int text_type ) : |
|
|
|
SetLayer( SILKSCREEN_N_CMP ); |
|
|
|
if( Module && (Module->Type() == TYPEMODULE) ) |
|
|
|
{ |
|
|
|
m_Pos = Module->m_Pos; |
|
|
|
m_Pos = Module->m_Pos; |
|
|
|
|
|
|
|
int moduleLayer = Module->GetLayer(); |
|
|
|
|
|
|
|
@ -57,8 +57,8 @@ TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, int text_type ) : |
|
|
|
SetLayer( moduleLayer ); |
|
|
|
|
|
|
|
if( moduleLayer == SILKSCREEN_N_CU |
|
|
|
|| moduleLayer == ADHESIVE_N_CU |
|
|
|
|| moduleLayer == COPPER_LAYER_N ) |
|
|
|
|| moduleLayer == ADHESIVE_N_CU |
|
|
|
|| moduleLayer == COPPER_LAYER_N ) |
|
|
|
{ |
|
|
|
m_Miroir = 0; |
|
|
|
} |
|
|
|
@ -74,6 +74,13 @@ TEXTE_MODULE::~TEXTE_MODULE() |
|
|
|
/*******************************************/ |
|
|
|
bool TEXTE_MODULE::Save( FILE* aFile ) const |
|
|
|
/*******************************************/ |
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Save |
|
|
|
* writes the data structures for this object out to a FILE in "*.brd" format. |
|
|
|
* @param aFile The FILE to write to. |
|
|
|
* @return bool - true if success writing else false. |
|
|
|
*/ |
|
|
|
{ |
|
|
|
MODULE* parent = (MODULE*) GetParent(); |
|
|
|
int orient = m_Orient; |
|
|
|
@ -82,25 +89,106 @@ bool TEXTE_MODULE::Save( FILE* aFile ) const |
|
|
|
orient += parent->m_Orient; |
|
|
|
|
|
|
|
int ret = fprintf( aFile, "T%d %d %d %d %d %d %d %c %c %d \"%s\"\n", |
|
|
|
m_Type, |
|
|
|
m_Pos0.x, m_Pos0.y, |
|
|
|
m_Size.y, m_Size.x, |
|
|
|
orient, |
|
|
|
m_Width, |
|
|
|
m_Miroir ? 'N' : 'M', m_NoShow ? 'I' : 'V', |
|
|
|
GetLayer(), |
|
|
|
CONV_TO_UTF8( m_Text ) ); |
|
|
|
|
|
|
|
return (ret > 20); |
|
|
|
m_Type, |
|
|
|
m_Pos0.x, m_Pos0.y, |
|
|
|
m_Size.y, m_Size.x, |
|
|
|
orient, |
|
|
|
m_Width, |
|
|
|
m_Miroir ? 'N' : 'M', m_NoShow ? 'I' : 'V', |
|
|
|
GetLayer(), |
|
|
|
CONV_TO_UTF8( m_Text ) ); |
|
|
|
|
|
|
|
return ret > 20; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************/ |
|
|
|
int TEXTE_MODULE::ReadDescr( char* aLine, FILE* aFile, int* aLineNum ) |
|
|
|
/*********************************************************************/ |
|
|
|
/**
|
|
|
|
* Function ReadLineDescr |
|
|
|
* Read description from a given line in "*.brd" format. |
|
|
|
* @param aLine The current line which contains the first line of description. |
|
|
|
* @param aLine The FILE to read next lines (currently not used). |
|
|
|
* @param LineNum a point to the line count (currently not used). |
|
|
|
* @return int - > 0 if success reading else 0. |
|
|
|
*/ |
|
|
|
{ |
|
|
|
int success = true; |
|
|
|
int type; |
|
|
|
int layer; |
|
|
|
char BufCar1[128], BufCar2[128], BufLine[256]; |
|
|
|
|
|
|
|
layer = SILKSCREEN_N_CMP; |
|
|
|
BufCar1[0] = 0; |
|
|
|
BufCar2[0] = 0; |
|
|
|
if ( sscanf( aLine + 1, "%d %d %d %d %d %d %d %s %s %d", |
|
|
|
&type, |
|
|
|
&m_Pos0.x, &m_Pos0.y, |
|
|
|
&m_Size.y, &m_Size.x, |
|
|
|
&m_Orient, &m_Width, |
|
|
|
BufCar1, BufCar2, &layer ) < 10 ) |
|
|
|
success = true; |
|
|
|
|
|
|
|
if( (type != TEXT_is_REFERENCE) && (type != TEXT_is_VALUE) ) |
|
|
|
type = TEXT_is_DIVERS; |
|
|
|
m_Type = type; |
|
|
|
|
|
|
|
// .m_Orient member must be relative to the parent module
|
|
|
|
m_Orient -= ((MODULE * )m_Parent)->m_Orient; |
|
|
|
if( BufCar1[0] == 'M' ) |
|
|
|
m_Miroir = 0; |
|
|
|
else |
|
|
|
m_Miroir = 1; |
|
|
|
if( BufCar2[0] == 'I' ) |
|
|
|
m_NoShow = 1; |
|
|
|
else |
|
|
|
m_NoShow = 0; |
|
|
|
|
|
|
|
// Test for a reasonnable layer:
|
|
|
|
if( layer < 0 ) |
|
|
|
layer = 0; |
|
|
|
if( layer > LAST_NO_COPPER_LAYER ) |
|
|
|
layer = LAST_NO_COPPER_LAYER; |
|
|
|
if( layer == COPPER_LAYER_N ) |
|
|
|
layer = SILKSCREEN_N_CU; |
|
|
|
else if( layer == CMP_N ) |
|
|
|
layer = SILKSCREEN_N_CMP; |
|
|
|
|
|
|
|
SetLayer( layer ); |
|
|
|
|
|
|
|
/* calcul de la position vraie */ |
|
|
|
SetDrawCoord(); |
|
|
|
/* Lecture de la chaine "text" */ |
|
|
|
ReadDelimitedText( BufLine, aLine, sizeof(BufLine) ); |
|
|
|
m_Text = CONV_FROM_UTF8( BufLine ); |
|
|
|
|
|
|
|
// Test for a reasonnable width:
|
|
|
|
if( m_Width <= 1 ) |
|
|
|
m_Width = 1; |
|
|
|
if( m_Width > TEXTS_MAX_WIDTH ) |
|
|
|
m_Width = TEXTS_MAX_WIDTH; |
|
|
|
|
|
|
|
// Test for a reasonnable size:
|
|
|
|
if( m_Size.x < TEXTS_MIN_SIZE ) |
|
|
|
m_Size.x = TEXTS_MIN_SIZE; |
|
|
|
if( m_Size.y < TEXTS_MIN_SIZE ) |
|
|
|
m_Size.y = TEXTS_MIN_SIZE; |
|
|
|
|
|
|
|
return success; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TEXTE_MODULE::Copy( TEXTE_MODULE* source ) // copy structure
|
|
|
|
/**********************************************/ |
|
|
|
void TEXTE_MODULE::Copy( TEXTE_MODULE* source ) |
|
|
|
/**********************************************/ |
|
|
|
|
|
|
|
// copy structure
|
|
|
|
{ |
|
|
|
if( source == NULL ) |
|
|
|
return; |
|
|
|
|
|
|
|
m_Pos = source->m_Pos; |
|
|
|
m_Pos = source->m_Pos; |
|
|
|
SetLayer( source->GetLayer() ); |
|
|
|
|
|
|
|
m_Miroir = source->m_Miroir; // Show normal / mirror
|
|
|
|
@ -201,27 +289,29 @@ void TEXTE_MODULE:: SetLocalCoord() |
|
|
|
/** Function GetTextRect
|
|
|
|
* @return an EDA_Rect which gives the position and size of the text area (for the O orient footprint) |
|
|
|
*/ |
|
|
|
EDA_Rect TEXTE_MODULE::GetTextRect(void) |
|
|
|
EDA_Rect TEXTE_MODULE::GetTextRect( void ) |
|
|
|
{ |
|
|
|
EDA_Rect area; |
|
|
|
|
|
|
|
int dx, dy; |
|
|
|
dx = ( m_Size.x * GetLength() ) / 2; |
|
|
|
dx = (dx * 10) / 9 ; /* letter size = 10/9 */ |
|
|
|
dx += m_Width / 2; |
|
|
|
dy = ( m_Size.y + m_Width ) / 2; |
|
|
|
int dx, dy; |
|
|
|
|
|
|
|
dx = ( m_Size.x * GetLength() ) / 2; |
|
|
|
dx = (dx * 10) / 9; /* letter size = 10/9 */ |
|
|
|
dx += m_Width / 2; |
|
|
|
dy = ( m_Size.y + m_Width ) / 2; |
|
|
|
|
|
|
|
wxPoint Org = m_Pos; // This is the position of the centre of the area
|
|
|
|
wxPoint Org = m_Pos; // This is the position of the centre of the area
|
|
|
|
Org.x -= dx; |
|
|
|
Org.y -= dy; |
|
|
|
area.SetOrigin( Org); |
|
|
|
area.SetHeight(2 * dy); |
|
|
|
area.SetWidth(2 * dx); |
|
|
|
area.SetOrigin( Org ); |
|
|
|
area.SetHeight( 2 * dy ); |
|
|
|
area.SetWidth( 2 * dx ); |
|
|
|
area.Normalize(); |
|
|
|
|
|
|
|
return area; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function HitTest |
|
|
|
* tests if the given wxPoint is within the bounds of this object. |
|
|
|
@ -230,21 +320,22 @@ EDA_Rect TEXTE_MODULE::GetTextRect(void) |
|
|
|
*/ |
|
|
|
bool TEXTE_MODULE::HitTest( const wxPoint& refPos ) |
|
|
|
{ |
|
|
|
wxPoint rel_pos; |
|
|
|
wxPoint rel_pos; |
|
|
|
EDA_Rect area = GetTextRect(); |
|
|
|
|
|
|
|
/* Rotate refPos to - angle
|
|
|
|
* to test if refPos is within area (which is relative to an horizontal text) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
rel_pos = refPos; |
|
|
|
RotatePoint( &rel_pos, m_Pos, - GetDrawRotation() ); |
|
|
|
RotatePoint( &rel_pos, m_Pos, -GetDrawRotation() ); |
|
|
|
|
|
|
|
if( area.Inside(rel_pos) ) |
|
|
|
if( area.Inside( rel_pos ) ) |
|
|
|
return true; |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetBoundingBox |
|
|
|
* returns the bounding box of this Text (according to text and footprint orientation) |
|
|
|
@ -253,23 +344,24 @@ EDA_Rect TEXTE_MODULE::GetBoundingBox() |
|
|
|
{ |
|
|
|
// Calculate area without text fielsd:
|
|
|
|
EDA_Rect text_area; |
|
|
|
int angle = GetDrawRotation(); |
|
|
|
wxPoint textstart, textend; |
|
|
|
int angle = GetDrawRotation(); |
|
|
|
wxPoint textstart, textend; |
|
|
|
|
|
|
|
text_area = GetTextRect(); |
|
|
|
textstart = text_area.GetOrigin(); |
|
|
|
textend = text_area.GetEnd(); |
|
|
|
RotatePoint( &textstart, m_Pos, angle); |
|
|
|
RotatePoint( &textend, m_Pos, angle); |
|
|
|
textend = text_area.GetEnd(); |
|
|
|
RotatePoint( &textstart, m_Pos, angle ); |
|
|
|
RotatePoint( &textend, m_Pos, angle ); |
|
|
|
|
|
|
|
text_area.SetOrigin(textstart); |
|
|
|
text_area.SetEnd(textend); |
|
|
|
text_area.SetOrigin( textstart ); |
|
|
|
text_area.SetEnd( textend ); |
|
|
|
text_area.Normalize(); |
|
|
|
return text_area; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************************/ |
|
|
|
void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoint& offset ) |
|
|
|
void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoint& offset ) |
|
|
|
/******************************************************************************************/ |
|
|
|
|
|
|
|
/** Function Draw
|
|
|
|
@ -316,11 +408,11 @@ void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, cons |
|
|
|
{ |
|
|
|
int anchor_size = 2 * zoom; |
|
|
|
GRLine( &panel->m_ClipBox, DC, |
|
|
|
pos.x - anchor_size, pos.y, |
|
|
|
pos.x + anchor_size, pos.y, 0, g_AnchorColor ); |
|
|
|
pos.x - anchor_size, pos.y, |
|
|
|
pos.x + anchor_size, pos.y, 0, g_AnchorColor ); |
|
|
|
GRLine( &panel->m_ClipBox, DC, |
|
|
|
pos.x, pos.y - anchor_size, |
|
|
|
pos.x, pos.y + anchor_size, 0, g_AnchorColor ); |
|
|
|
pos.x, pos.y - anchor_size, |
|
|
|
pos.x, pos.y + anchor_size, 0, g_AnchorColor ); |
|
|
|
} |
|
|
|
|
|
|
|
color = g_DesignSettings.m_LayerColor[Module->GetLayer()]; |
|
|
|
@ -346,7 +438,7 @@ void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, cons |
|
|
|
|
|
|
|
/* Trace du texte */ |
|
|
|
DrawGraphicText( panel, DC, pos, color, m_Text, |
|
|
|
orient, size, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, width ); |
|
|
|
orient, size, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, width ); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -382,18 +474,19 @@ void TEXTE_MODULE::Display_Infos( WinEDA_DrawFrame* frame ) |
|
|
|
wxString msg, Line; |
|
|
|
int ii; |
|
|
|
|
|
|
|
MODULE* module = (MODULE*) m_Parent; |
|
|
|
MODULE* module = (MODULE*) m_Parent; |
|
|
|
|
|
|
|
wxASSERT( module ); |
|
|
|
|
|
|
|
if( !module ) |
|
|
|
return; |
|
|
|
|
|
|
|
BOARD* board = (BOARD*) module->m_Parent; |
|
|
|
BOARD* board = (BOARD*) module->m_Parent; |
|
|
|
wxASSERT( board ); |
|
|
|
|
|
|
|
static const wxString text_type_msg[3] = { |
|
|
|
_( "Ref." ), _( "Value" ), _( "Text" ) }; |
|
|
|
_( "Ref." ), _( "Value" ), _( "Text" ) |
|
|
|
}; |
|
|
|
|
|
|
|
frame->MsgPanel->EraseMsgBox(); |
|
|
|
|
|
|
|
@ -409,11 +502,11 @@ void TEXTE_MODULE::Display_Infos( WinEDA_DrawFrame* frame ) |
|
|
|
|
|
|
|
Affiche_1_Parametre( frame, 20, _( "Type" ), text_type_msg[ii], DARKGREEN ); |
|
|
|
|
|
|
|
Affiche_1_Parametre( frame, 25, _( "Display" ), wxEmptyString, DARKGREEN ); |
|
|
|
if( m_NoShow ) |
|
|
|
Affiche_1_Parametre( frame, -1, wxEmptyString, _( "No" ), DARKGREEN ); |
|
|
|
msg = _( "No" ); |
|
|
|
else |
|
|
|
Affiche_1_Parametre( frame, -1, wxEmptyString, _( "Yes" ), DARKGREEN ); |
|
|
|
msg = _( "Yes" ); |
|
|
|
Affiche_1_Parametre( frame, 25, _( "Display" ), msg, DARKGREEN ); |
|
|
|
|
|
|
|
ii = m_Layer; |
|
|
|
if( ii < NB_LAYERS ) |
|
|
|
@ -431,16 +524,16 @@ void TEXTE_MODULE::Display_Infos( WinEDA_DrawFrame* frame ) |
|
|
|
Affiche_1_Parametre( frame, 36, _( "Mirror" ), msg, DARKGREEN ); |
|
|
|
|
|
|
|
msg.Printf( wxT( "%.1f" ), (float) m_Orient / 10 ); |
|
|
|
Affiche_1_Parametre( frame, 42, _( "Orient" ), msg, DARKGREEN ); |
|
|
|
Affiche_1_Parametre( frame, 43, _( "Orient" ), msg, DARKGREEN ); |
|
|
|
|
|
|
|
valeur_param( m_Width, msg ); |
|
|
|
Affiche_1_Parametre( frame, 48, _( "Width" ), msg, DARKGREEN ); |
|
|
|
Affiche_1_Parametre( frame, 51, _( "Width" ), msg, DARKGREEN ); |
|
|
|
|
|
|
|
valeur_param( m_Size.x, msg ); |
|
|
|
Affiche_1_Parametre( frame, 56, _( "H Size" ), msg, RED ); |
|
|
|
Affiche_1_Parametre( frame, 60, _( "H Size" ), msg, RED ); |
|
|
|
|
|
|
|
valeur_param( m_Size.y, msg ); |
|
|
|
Affiche_1_Parametre( frame, 64, _( "V Size" ), msg, RED ); |
|
|
|
Affiche_1_Parametre( frame, 69, _( "V Size" ), msg, RED ); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -459,7 +552,6 @@ bool TEXTE_MODULE::IsOnLayer( int aLayer ) const |
|
|
|
if( m_Layer==ADHESIVE_N_CU || m_Layer==SILKSCREEN_N_CU ) |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
else if( aLayer == CMP_N ) |
|
|
|
{ |
|
|
|
if( m_Layer==ADHESIVE_N_CMP || m_Layer==SILKSCREEN_N_CMP ) |
|
|
|
@ -471,14 +563,15 @@ bool TEXTE_MODULE::IsOnLayer( int aLayer ) const |
|
|
|
|
|
|
|
|
|
|
|
/* see class_text_mod.h
|
|
|
|
bool TEXTE_MODULE::IsOnOneOfTheseLayers( int aLayerMask ) const |
|
|
|
{ |
|
|
|
* bool TEXTE_MODULE::IsOnOneOfTheseLayers( int aLayerMask ) const |
|
|
|
* { |
|
|
|
* |
|
|
|
* } |
|
|
|
*/ |
|
|
|
|
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
#if defined (DEBUG)
|
|
|
|
|
|
|
|
#if defined(DEBUG)
|
|
|
|
/**
|
|
|
|
* Function Show |
|
|
|
* is used to output the object tree, currently for debugging only. |
|
|
|
@ -490,8 +583,10 @@ void TEXTE_MODULE::Show( int nestLevel, std::ostream& os ) |
|
|
|
{ |
|
|
|
// for now, make it look like XML:
|
|
|
|
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << |
|
|
|
" string=\"" << m_Text.mb_str() << "\"/>\n"; |
|
|
|
" string=\"" << m_Text.mb_str() << "\"/>\n"; |
|
|
|
|
|
|
|
// NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endif
|