Commit 0da38e5b authored by Lorenzo Marcantonio's avatar Lorenzo Marcantonio

More work on module texts, and especially on the collector

The members SetIgnoreMTextsOnCopper, SetIgnoreMTextsOnCmp,
SetIgnoreModulesOnCu, SetIgnoreModulesOnCmp in the collector guide are
renamed to the clearer SetIgnoreMTextsOnBack, SetIgnoreMTextsOnFront,
SetIgnoreModulesOnBack, SetIgnoreModulesOnFront

Modified the collector and drawing behaviour for text in modules as
discussed in the mailing list.

* Now module text on layers different than Silk should work! *

Still need UI support for setting the layer in the module editor.
parent 424aac6c
...@@ -585,10 +585,10 @@ GENERAL_COLLECTORS_GUIDE PCB_BASE_FRAME::GetCollectorsGuide() ...@@ -585,10 +585,10 @@ GENERAL_COLLECTORS_GUIDE PCB_BASE_FRAME::GetCollectorsGuide()
// account for the globals // account for the globals
guide.SetIgnoreMTextsMarkedNoShow( ! m_Pcb->IsElementVisible( MOD_TEXT_INVISIBLE )); guide.SetIgnoreMTextsMarkedNoShow( ! m_Pcb->IsElementVisible( MOD_TEXT_INVISIBLE ));
guide.SetIgnoreMTextsOnCopper( ! m_Pcb->IsElementVisible( MOD_TEXT_BK_VISIBLE )); guide.SetIgnoreMTextsOnBack( ! m_Pcb->IsElementVisible( MOD_TEXT_BK_VISIBLE ));
guide.SetIgnoreMTextsOnCmp( ! m_Pcb->IsElementVisible( MOD_TEXT_FR_VISIBLE )); guide.SetIgnoreMTextsOnFront( ! m_Pcb->IsElementVisible( MOD_TEXT_FR_VISIBLE ));
guide.SetIgnoreModulesOnCu( ! m_Pcb->IsElementVisible( MOD_BK_VISIBLE ) ); guide.SetIgnoreModulesOnBack( ! m_Pcb->IsElementVisible( MOD_BK_VISIBLE ) );
guide.SetIgnoreModulesOnCmp( ! m_Pcb->IsElementVisible( MOD_FR_VISIBLE ) ); guide.SetIgnoreModulesOnFront( ! m_Pcb->IsElementVisible( MOD_FR_VISIBLE ) );
guide.SetIgnorePadsOnBack( ! m_Pcb->IsElementVisible( PAD_BK_VISIBLE ) ); guide.SetIgnorePadsOnBack( ! m_Pcb->IsElementVisible( PAD_BK_VISIBLE ) );
guide.SetIgnorePadsOnFront( ! m_Pcb->IsElementVisible( PAD_FR_VISIBLE ) ); guide.SetIgnorePadsOnFront( ! m_Pcb->IsElementVisible( PAD_FR_VISIBLE ) );
guide.SetIgnoreModulesVals( ! m_Pcb->IsElementVisible( MOD_VALUES_VISIBLE ) ); guide.SetIgnoreModulesVals( ! m_Pcb->IsElementVisible( MOD_VALUES_VISIBLE ) );
......
...@@ -52,7 +52,7 @@ TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, TEXT_TYPE text_type ) : ...@@ -52,7 +52,7 @@ TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, TEXT_TYPE text_type ) :
BOARD_ITEM( parent, PCB_MODULE_TEXT_T ), BOARD_ITEM( parent, PCB_MODULE_TEXT_T ),
EDA_TEXT() EDA_TEXT()
{ {
MODULE* module = (MODULE*) m_Parent; MODULE* module = static_cast<MODULE*>( m_Parent );
m_Type = text_type; m_Type = text_type;
...@@ -63,6 +63,7 @@ TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, TEXT_TYPE text_type ) : ...@@ -63,6 +63,7 @@ TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, TEXT_TYPE text_type ) :
SetLayer( F_SilkS ); SetLayer( F_SilkS );
// Set position and layer if there is already a parent module
if( module && ( module->Type() == PCB_MODULE_T ) ) if( module && ( module->Type() == PCB_MODULE_T ) )
{ {
m_Pos = module->GetPosition(); m_Pos = module->GetPosition();
...@@ -161,33 +162,34 @@ int TEXTE_MODULE::GetLength() const ...@@ -161,33 +162,34 @@ int TEXTE_MODULE::GetLength() const
void TEXTE_MODULE::SetDrawCoord() void TEXTE_MODULE::SetDrawCoord()
{ {
MODULE* module = (MODULE*) m_Parent; const MODULE* module = static_cast<const MODULE*>( m_Parent );
m_Pos = m_Pos0; m_Pos = m_Pos0;
if( module == NULL ) if( module )
return; {
double angle = module->GetOrientation(); double angle = module->GetOrientation();
RotatePoint( &m_Pos.x, &m_Pos.y, angle ); RotatePoint( &m_Pos.x, &m_Pos.y, angle );
m_Pos += module->GetPosition(); m_Pos += module->GetPosition();
}
} }
void TEXTE_MODULE::SetLocalCoord() void TEXTE_MODULE::SetLocalCoord()
{ {
MODULE* module = (MODULE*) m_Parent; const MODULE* module = static_cast<const MODULE*>( m_Parent );
if( module == NULL ) if( module )
{ {
m_Pos0 = m_Pos;
return;
}
m_Pos0 = m_Pos - module->GetPosition(); m_Pos0 = m_Pos - module->GetPosition();
double angle = module->GetOrientation(); double angle = module->GetOrientation();
RotatePoint( &m_Pos0.x, &m_Pos0.y, -angle ); RotatePoint( &m_Pos0.x, &m_Pos0.y, -angle );
}
else
{
m_Pos0 = m_Pos;
}
} }
...@@ -196,9 +198,8 @@ bool TEXTE_MODULE::HitTest( const wxPoint& aPosition ) const ...@@ -196,9 +198,8 @@ bool TEXTE_MODULE::HitTest( const wxPoint& aPosition ) const
wxPoint rel_pos; wxPoint rel_pos;
EDA_RECT area = GetTextBox( -1, -1 ); EDA_RECT area = GetTextBox( -1, -1 );
/* Rotate refPos to - angle /* Rotate refPos to - angle to test if refPos is within area (which
* to test if refPos is within area (which is relative to an horizontal * is relative to an horizontal text)
* text)
*/ */
rel_pos = aPosition; rel_pos = aPosition;
RotatePoint( &rel_pos, m_Pos, -GetDrawRotation() ); RotatePoint( &rel_pos, m_Pos, -GetDrawRotation() );
...@@ -238,28 +239,30 @@ const EDA_RECT TEXTE_MODULE::GetBoundingBox() const ...@@ -238,28 +239,30 @@ const 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 )
{ {
MODULE* module = (MODULE*) m_Parent; if( panel == NULL )
return;
MODULE* module = static_cast<MODULE*>( m_Parent );
/* parent must *not* be NULL (a module text without a footprint /* parent must *not* be NULL (a module text without a footprint
parent has no sense) */ parent has no sense) */
wxASSERT( module ); wxASSERT( module );
if( panel == NULL )
return;
BOARD* brd = GetBoard( ); BOARD* brd = GetBoard( );
// Suppress the element if the layer it is on is on a disabled side /* Reference and values takes the color from the corresponding Visibles
LAYER_ID text_layer = GetLayer(); other texts take the color of the layer they are on */
EDA_COLOR_T color;
/* For reference and value suppress the element if the layer it is
* on is on a disabled side, user text also has standard layer
* hiding.
* If the whole module side is disabled this isn't even called */
LAYER_ID text_layer = GetLayer();
if( (IsFrontLayer( text_layer ) && !brd->IsElementVisible( MOD_TEXT_FR_VISIBLE )) || if( (IsFrontLayer( text_layer ) && !brd->IsElementVisible( MOD_TEXT_FR_VISIBLE )) ||
(IsBackLayer( text_layer ) && !brd->IsElementVisible( MOD_TEXT_BK_VISIBLE )) ) (IsBackLayer( text_layer ) && !brd->IsElementVisible( MOD_TEXT_BK_VISIBLE )) )
return; return;
/* Reference and values takes the color from the corresponding Visibles
other texts take the color of the layer they are on */
EDA_COLOR_T color;
switch( GetType() ) switch( GetType() )
{ {
case TEXT_is_REFERENCE: case TEXT_is_REFERENCE:
...@@ -270,9 +273,12 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, ...@@ -270,9 +273,12 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
color = brd->GetVisibleElementColor( MOD_TEXT_BK_VISIBLE ); color = brd->GetVisibleElementColor( MOD_TEXT_BK_VISIBLE );
break; break;
default: // Otherwise the compiler is not sure about initializing color
case TEXT_is_DIVERS: case TEXT_is_DIVERS:
default: // This is to persuade the compiler that color is always initialized if( brd->IsLayerVisible( m_Layer ) )
color = brd->GetLayerColor( GetLayer() ); color = brd->GetLayerColor( GetLayer() );
else
return;
} }
// 'Ghost' the element if forced show // 'Ghost' the element if forced show
......
...@@ -255,13 +255,13 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, const void* testDa ...@@ -255,13 +255,13 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, const void* testDa
} }
else // smd, so use pads test after module test else // smd, so use pads test after module test
{ {
module = (MODULE*) item->GetParent(); module = static_cast<MODULE*>( item->GetParent() );
} }
break; break;
case PCB_VIA_T: // vias are on many layers, so layer test is specific case PCB_VIA_T: // vias are on many layers, so layer test is specific
via = (VIA*) item; via = static_cast<VIA*>( item );
break; break;
case PCB_TRACE_T: case PCB_TRACE_T:
...@@ -286,34 +286,53 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, const void* testDa ...@@ -286,34 +286,53 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, const void* testDa
break; break;
case PCB_MODULE_TEXT_T: case PCB_MODULE_TEXT_T:
module = static_cast<MODULE*>( item->GetParent() ); {
TEXTE_MODULE *text = static_cast<TEXTE_MODULE*>( item );
if( m_Guide->IgnoreMTextsMarkedNoShow() && !text->IsVisible() )
goto exit;
if( m_Guide->IgnoreMTextsMarkedNoShow() && if( m_Guide->IgnoreMTextsOnBack() && IsBackLayer( text->GetLayer() ) )
!static_cast<TEXTE_MODULE*>( item )->IsVisible() )
goto exit; goto exit;
if( module ) if( m_Guide->IgnoreMTextsOnFront() && IsFrontLayer( text->GetLayer() ) )
{
if( m_Guide->IgnoreMTextsOnCopper() && module->GetLayer()==B_Cu )
goto exit; goto exit;
if( m_Guide->IgnoreMTextsOnCmp() && module->GetLayer()==F_Cu ) /* The three text types have different criteria: reference
* and value have their own ignore flags; user text instead
* follows their layer visibility. Checking this here is
* simpler than later (when layer visibility is checked for
* other entities) */
switch( text->GetType() )
{
case TEXTE_MODULE::TEXT_is_REFERENCE:
if( m_Guide->IgnoreModulesRefs() )
goto exit; goto exit;
break;
if( m_Guide->IgnoreModulesVals() && item == &module->Value() ) case TEXTE_MODULE::TEXT_is_VALUE:
if( m_Guide->IgnoreModulesVals() )
goto exit; goto exit;
break;
if( m_Guide->IgnoreModulesRefs() && item == &module->Reference() ) case TEXTE_MODULE::TEXT_is_DIVERS:
if( !m_Guide->IsLayerVisible( text->GetLayer() )
&& m_Guide->IgnoreNonVisibleLayers() )
goto exit; goto exit;
break;
}
// Extract the module since it could be hidden
module = static_cast<MODULE*>( item->GetParent() );
} }
break; break;
case PCB_MODULE_T: case PCB_MODULE_T:
module = (MODULE*) item; module = static_cast<MODULE*>( item );
break; break;
case PCB_MARKER_T: case PCB_MARKER_T:
marker = (MARKER_PCB*) item; marker = static_cast<MARKER_PCB*>( item );
break; break;
default: default:
...@@ -324,10 +343,10 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, const void* testDa ...@@ -324,10 +343,10 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, const void* testDa
if( module ) // true from case PCB_PAD_T, PCB_MODULE_TEXT_T, or PCB_MODULE_T if( module ) // true from case PCB_PAD_T, PCB_MODULE_TEXT_T, or PCB_MODULE_T
{ {
if( m_Guide->IgnoreModulesOnCu() && module->GetLayer()==B_Cu ) if( m_Guide->IgnoreModulesOnBack() && (module->GetLayer() == B_Cu) )
goto exit; goto exit;
if( m_Guide->IgnoreModulesOnCmp() && module->GetLayer()==F_Cu ) if( m_Guide->IgnoreModulesOnFront() && (module->GetLayer() == F_Cu) )
goto exit; goto exit;
} }
...@@ -358,14 +377,20 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, const void* testDa ...@@ -358,14 +377,20 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, const void* testDa
goto exit; goto exit;
} }
if( item->IsOnLayer( m_Guide->GetPreferredLayer() ) || m_Guide->IgnorePreferredLayer() ) if( item->IsOnLayer( m_Guide->GetPreferredLayer() ) ||
m_Guide->IgnorePreferredLayer() )
{ {
LAYER_ID layer = item->GetLayer(); LAYER_ID layer = item->GetLayer();
// Modules and their subcomponents: text and pads are not sensitive to the layer /* Modules and their subcomponents: reference, value and pads
// visibility controls. They all have their own separate visibility controls * are not sensitive to the layer visibility controls. They all
// for vias, GetLayer() has no meaning, but IsOnLayer() works fine * have their own separate visibility controls for vias,
if( via || module || pad || m_Guide->IsLayerVisible( layer ) || !m_Guide->IgnoreNonVisibleLayers() ) * GetLayer() has no meaning, but IsOnLayer() works fine. User
* text in module *is* sensitive to layer visibility but that
* was already handled */
if( via || module || pad || m_Guide->IsLayerVisible( layer )
|| !m_Guide->IgnoreNonVisibleLayers() )
{ {
if( !m_Guide->IsLayerLocked( layer ) || !m_Guide->IgnoreLockedLayers() ) if( !m_Guide->IsLayerLocked( layer ) || !m_Guide->IgnoreLockedLayers() )
{ {
...@@ -390,9 +415,14 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, const void* testDa ...@@ -390,9 +415,14 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, const void* testDa
LAYER_ID layer = item->GetLayer(); LAYER_ID layer = item->GetLayer();
// Modules and their subcomponents: text and pads are not sensitive to the layer /* Modules and their subcomponents: reference, value and pads
// visibility controls. They all have their own separate visibility controls * are not sensitive to the layer visibility controls. They all
if( via || module || pad || m_Guide->IsLayerVisible( layer ) || !m_Guide->IgnoreNonVisibleLayers() ) * have their own separate visibility controls. User texts
* follows layer visibility controls (but that was already
* checked) */
if( via || module || pad || m_Guide->IsLayerVisible( layer )
|| !m_Guide->IgnoreNonVisibleLayers() )
{ {
if( !m_Guide->IsLayerLocked( layer ) || !m_Guide->IgnoreLockedLayers() ) if( !m_Guide->IsLayerLocked( layer ) || !m_Guide->IgnoreLockedLayers() )
{ {
......
...@@ -131,28 +131,28 @@ public: ...@@ -131,28 +131,28 @@ public:
can simply omit from scanTypes[] PCB_ZONE_T */ can simply omit from scanTypes[] PCB_ZONE_T */
/** /**
* Function IgnoreMTextsOnCu * Function IgnoreMTextsOnBack
* @return bool - true if should ignore MTexts on copper layer. * @return bool - true if should ignore MTexts on back layers
*/ */
virtual bool IgnoreMTextsOnCopper() const = 0; virtual bool IgnoreMTextsOnBack() const = 0;
/** /**
* Function IgnoreMTextsOnCmp * Function IgnoreMTextsOnFront
* @return bool - true if should ignore MTexts on component layer. * @return bool - true if should ignore MTexts on front layers.
*/ */
virtual bool IgnoreMTextsOnCmp() const = 0; virtual bool IgnoreMTextsOnFront() const = 0;
/** /**
* Function IgnoreModulesOnCu * Function IgnoreModulesOnBack
* @return bool - true if should ignore MODULEs on Back Side. * @return bool - true if should ignore MODULEs on Back Side.
*/ */
virtual bool IgnoreModulesOnCu() const = 0; virtual bool IgnoreModulesOnBack() const = 0;
/** /**
* Function IgnoreModulesOnCmp * Function IgnoreModulesOnFront
* @return bool - ture if should ignore MODULEs on Front Side. * @return bool - ture if should ignore MODULEs on Front Side.
*/ */
virtual bool IgnoreModulesOnCmp() const = 0; virtual bool IgnoreModulesOnFront() const = 0;
/** /**
* Function IgnorePadsOnBack * Function IgnorePadsOnBack
...@@ -395,10 +395,10 @@ private: ...@@ -395,10 +395,10 @@ private:
bool m_IncludeSecondary; bool m_IncludeSecondary;
bool m_IgnoreMTextsMarkedNoShow; bool m_IgnoreMTextsMarkedNoShow;
bool m_IgnoreMTextsOnCopper; bool m_IgnoreMTextsOnBack;
bool m_IgnoreMTextsOnCmp; bool m_IgnoreMTextsOnFront;
bool m_IgnoreModulesOnCu; bool m_IgnoreModulesOnBack;
bool m_IgnoreModulesOnCmp; bool m_IgnoreModulesOnFront;
bool m_IgnorePadsOnFront; bool m_IgnorePadsOnFront;
bool m_IgnorePadsOnBack; bool m_IgnorePadsOnBack;
bool m_IgnoreModulesVals; bool m_IgnoreModulesVals;
...@@ -429,10 +429,10 @@ public: ...@@ -429,10 +429,10 @@ public:
#endif #endif
m_IgnoreMTextsMarkedNoShow = true; // g_ModuleTextNOVColor; m_IgnoreMTextsMarkedNoShow = true; // g_ModuleTextNOVColor;
m_IgnoreMTextsOnCopper = true; m_IgnoreMTextsOnBack = true;
m_IgnoreMTextsOnCmp = false; m_IgnoreMTextsOnFront = false;
m_IgnoreModulesOnCu = true; // !Show_Modules_Cmp; m_IgnoreModulesOnBack = true; // !Show_Modules_Cmp;
m_IgnoreModulesOnCmp = false; m_IgnoreModulesOnFront = false;
m_IgnorePadsOnFront = false; m_IgnorePadsOnFront = false;
m_IgnorePadsOnBack = false; m_IgnorePadsOnBack = false;
...@@ -530,31 +530,31 @@ public: ...@@ -530,31 +530,31 @@ public:
/** /**
* Function IgnoreMTextsOnCu * Function IgnoreMTextsOnCu
* @return bool - true if should ignore MTexts on copper layer. * @return bool - true if should ignore MTexts on back layers
*/ */
bool IgnoreMTextsOnCopper() const { return m_IgnoreMTextsOnCopper; } bool IgnoreMTextsOnBack() const { return m_IgnoreMTextsOnBack; }
void SetIgnoreMTextsOnCopper( bool ignore ) { m_IgnoreMTextsOnCopper = ignore; } void SetIgnoreMTextsOnBack( bool ignore ) { m_IgnoreMTextsOnBack = ignore; }
/** /**
* Function IgnoreMTextsOnCmp * Function IgnoreMTextsOnFront
* @return bool - true if should ignore MTexts on component layer. * @return bool - true if should ignore MTexts on front layers
*/ */
bool IgnoreMTextsOnCmp() const { return m_IgnoreMTextsOnCmp; } bool IgnoreMTextsOnFront() const { return m_IgnoreMTextsOnFront; }
void SetIgnoreMTextsOnCmp( bool ignore ) { m_IgnoreMTextsOnCmp = ignore; } void SetIgnoreMTextsOnFront( bool ignore ) { m_IgnoreMTextsOnFront = ignore; }
/** /**
* Function IgnoreModulesOnCu * Function IgnoreModulesOnBack
* @return bool - true if should ignore MODULEs on copper layer. * @return bool - true if should ignore MODULEs on the back side
*/ */
bool IgnoreModulesOnCu() const { return m_IgnoreModulesOnCu; } bool IgnoreModulesOnBack() const { return m_IgnoreModulesOnBack; }
void SetIgnoreModulesOnCu( bool ignore ) { m_IgnoreModulesOnCu = ignore; } void SetIgnoreModulesOnBack( bool ignore ) { m_IgnoreModulesOnBack = ignore; }
/** /**
* Function IgnoreModulesOnCmp * Function IgnoreModulesOnFront
* @return bool - true if should ignore MODULEs on component layer. * @return bool - true if should ignore MODULEs on component layer.
*/ */
bool IgnoreModulesOnCmp() const { return m_IgnoreModulesOnCmp; } bool IgnoreModulesOnFront() const { return m_IgnoreModulesOnFront; }
void SetIgnoreModulesOnCmp( bool ignore ) { m_IgnoreModulesOnCmp = ignore; } void SetIgnoreModulesOnFront( bool ignore ) { m_IgnoreModulesOnFront = ignore; }
/** /**
* Function IgnorePadsOnBack * Function IgnorePadsOnBack
......
...@@ -233,8 +233,8 @@ int MODULE_TOOLS::EnumeratePads( TOOL_EVENT& aEvent ) ...@@ -233,8 +233,8 @@ int MODULE_TOOLS::EnumeratePads( TOOL_EVENT& aEvent )
GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide(); GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide();
guide.SetIgnoreMTextsMarkedNoShow( true ); guide.SetIgnoreMTextsMarkedNoShow( true );
guide.SetIgnoreMTextsOnCopper( true ); guide.SetIgnoreMTextsOnBack( true );
guide.SetIgnoreMTextsOnCmp( true ); guide.SetIgnoreMTextsOnFront( true );
guide.SetIgnoreModulesVals( true ); guide.SetIgnoreModulesVals( true );
guide.SetIgnoreModulesRefs( true ); guide.SetIgnoreModulesRefs( true );
......
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