Commit 86851d39 authored by Lorenzo Marcantonio's avatar Lorenzo Marcantonio

Hide the anchor for hidden text (suggested by Sergey Borshch)

parent 9fd79dfa
...@@ -241,27 +241,47 @@ EDA_RECT TEXTE_MODULE::GetBoundingBox() const ...@@ -241,27 +241,47 @@ EDA_RECT TEXTE_MODULE::GetBoundingBox() const
void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
const wxPoint& offset ) const wxPoint& offset )
{ {
int width, orient; MODULE* module = (MODULE*) m_Parent;
wxSize size;
wxPoint pos; // Center of text
PCB_BASE_FRAME* frame;
MODULE* module = (MODULE*) m_Parent; /* parent must *not* be null
* (a module text without a footprint
* parent has no sense) */
/* parent must *not* be NULL (a module text without a footprint
parent has no sense) */
wxASSERT( module );
if( panel == NULL ) if( panel == NULL )
return; return;
frame = (PCB_BASE_FRAME*) panel->GetParent(); BOARD* brd = GetBoard( );
EDA_COLOR_T color;
// Determine the element color or suppress it element if hidden
switch( module->GetLayer() )
{
case LAYER_N_BACK:
if( !brd->IsElementVisible( MOD_TEXT_BK_VISIBLE ) )
return;
color = brd->GetVisibleElementColor( MOD_TEXT_BK_VISIBLE );
break;
case LAYER_N_FRONT:
if( !brd->IsElementVisible( MOD_TEXT_FR_VISIBLE ) )
return;
color = brd->GetVisibleElementColor( MOD_TEXT_FR_VISIBLE );
break;
pos.x = m_Pos.x - offset.x; default:
pos.y = m_Pos.y - offset.y; color = brd->GetLayerColor( module->GetLayer() );
}
size = m_Size; // 'Ghost' the element if forced show
orient = GetDrawRotation(); if( m_NoShow )
width = m_Thickness; {
if( !brd->IsElementVisible( MOD_TEXT_INVISIBLE ) )
return;
color = brd->GetVisibleElementColor( MOD_TEXT_INVISIBLE );
}
// Draw mode compensation for the width
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent();
int width = m_Thickness;
if( ( frame->m_DisplayModText == LINE ) if( ( frame->m_DisplayModText == LINE )
|| ( DC->LogicalToDeviceXRel( width ) < MIN_DRAW_WIDTH ) ) || ( DC->LogicalToDeviceXRel( width ) < MIN_DRAW_WIDTH ) )
width = 0; width = 0;
...@@ -269,51 +289,32 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, ...@@ -269,51 +289,32 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
width = -width; width = -width;
GRSetDrawMode( DC, draw_mode ); GRSetDrawMode( DC, draw_mode );
wxPoint pos( m_Pos.x - offset.x,
m_Pos.y - offset.y);
BOARD * brd = GetBoard( ); // Draw the text anchor point
EDA_COLOR_T color;
if( brd->IsElementVisible( ANCHOR_VISIBLE ) ) if( brd->IsElementVisible( ANCHOR_VISIBLE ) )
{ {
color = brd->GetVisibleElementColor(ANCHOR_VISIBLE); EDA_COLOR_T anchor_color = brd->GetVisibleElementColor(ANCHOR_VISIBLE);
int anchor_size = DC->DeviceToLogicalXRel( 2 ); int anchor_size = DC->DeviceToLogicalXRel( 2 );
GRLine( panel->GetClipBox(), DC, GRLine( panel->GetClipBox(), DC,
pos.x - anchor_size, pos.y, pos.x - anchor_size, pos.y,
pos.x + anchor_size, pos.y, 0, color ); pos.x + anchor_size, pos.y, 0, anchor_color );
GRLine( panel->GetClipBox(), DC, GRLine( panel->GetClipBox(), DC,
pos.x, pos.y - anchor_size, pos.x, pos.y - anchor_size,
pos.x, pos.y + anchor_size, 0, color ); pos.x, pos.y + anchor_size, 0, anchor_color );
}
color = brd->GetLayerColor(module->GetLayer());
if( module->GetLayer() == LAYER_N_BACK )
{
if( brd->IsElementVisible( MOD_TEXT_BK_VISIBLE ) == false )
return;
color = brd->GetVisibleElementColor(MOD_TEXT_BK_VISIBLE);
}
else if( module->GetLayer() == LAYER_N_FRONT )
{
if( brd->IsElementVisible( MOD_TEXT_FR_VISIBLE ) == false )
return;
color = brd->GetVisibleElementColor(MOD_TEXT_FR_VISIBLE);
} }
if( m_NoShow ) // Draw the text proper, with the right attributes
{ wxSize size = m_Size;
if( brd->IsElementVisible( MOD_TEXT_INVISIBLE ) == false ) int orient = GetDrawRotation();
return;
color = brd->GetVisibleElementColor(MOD_TEXT_INVISIBLE);
}
/* If the text is mirrored : negate size.x (mirror / Y axis) */ // If the text is mirrored : negate size.x (mirror / Y axis)
if( m_Mirror ) if( m_Mirror )
size.x = -size.x; size.x = -size.x;
DrawGraphicText( panel, DC, pos, (enum EDA_COLOR_T) color, m_Text, orient, DrawGraphicText( panel, DC, pos, color, m_Text, orient,
size, m_HJustify, m_VJustify, width, m_Italic, m_Bold ); size, m_HJustify, m_VJustify, width, m_Italic, m_Bold );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment