From 424aac6cf295c11c147aa49420710a37145ee7f5 Mon Sep 17 00:00:00 2001
From: Lorenzo Marcantonio
Date: Wed, 10 Sep 2014 17:18:42 +0200
Subject: [PATCH] TEXTE_MODULE cleanup in preparation for text on different
layers - Removed the friends MODULE and FOOTPRINT_EDIT_FRAME from
TEXTE_MODULE (as in the @todo comment)
- Refactored the Rotate/Flip/Mirror for text in modules into the
TEXTE_MODULE class itself (members RotateWithModule, FlipWithModule,
MirrorWithModule)
- New behaviour in coloring text on screen: reference and value still
take the color from the MOD_TEXT_FR_VISIBLE and MOD_TEXT_BK_VISIBLE
visibles; other text takes the color of the layer containing it
(except when hidden, obviously) but still get its visibility
controlled by those visibles (probably the most intuitive and useful
behaviour)
- Still need to decide: should text on a layer be hidden when the layer
is? Probably yes (still to be implemented);
- Some comment fixed and many cast converted to static_cast
---
include/eda_text.h | 2 +-
pcbnew/block_module_editor.cpp | 32 ++----
...board_items_to_polygon_shape_transform.cpp | 9 +-
pcbnew/class_board.cpp | 4 +-
pcbnew/class_module.cpp | 100 +++++++-----------
pcbnew/class_module.h | 8 +-
pcbnew/class_text_mod.cpp | 96 ++++++++++-------
pcbnew/class_text_mod.h | 20 +++-
pcbnew/collectors.cpp | 5 +-
pcbnew/cross-probing.cpp | 6 +-
pcbnew/dialogs/dialog_edit_module_text.cpp | 2 +-
.../dialog_global_modules_fields_edition.cpp | 9 +-
pcbnew/dialogs/dialog_pad_properties.cpp | 4 +-
pcbnew/edit.cpp | 9 +-
pcbnew/editmod.cpp | 4 +-
pcbnew/editrack-part2.cpp | 4 +-
pcbnew/edtxtmod.cpp | 29 +++--
pcbnew/exporters/export_gencad.cpp | 3 +-
pcbnew/exporters/export_vrml.cpp | 4 +-
pcbnew/hotkeys_board_editor.cpp | 17 +--
pcbnew/kicad_plugin.cpp | 26 ++---
pcbnew/legacy_plugin.cpp | 10 +-
pcbnew/modedit.cpp | 51 ++-------
pcbnew/modedit_onclick.cpp | 16 +--
pcbnew/onleftclick.cpp | 41 +++----
pcbnew/onrightclick.cpp | 4 +-
pcbnew/pcb_painter.cpp | 23 ++--
pcbnew/print_board_functions.cpp | 15 +--
pcbnew/tools/edit_tool.cpp | 2 +-
29 files changed, 265 insertions(+), 290 deletions(-)
diff --git a/include/eda_text.h b/include/eda_text.h
index 7e65ccb098..b7e2e8641d 100644
--- a/include/eda_text.h
+++ b/include/eda_text.h
@@ -111,7 +111,7 @@ public:
*
* @return a const wxString object containing the string of the item.
*/
- virtual const wxString GetText() const { return m_Text; }
+ virtual const wxString& GetText() const { return m_Text; }
virtual void SetText( const wxString& aText ) { m_Text = aText; }
diff --git a/pcbnew/block_module_editor.cpp b/pcbnew/block_module_editor.cpp
index cd2b295435..419effc776 100644
--- a/pcbnew/block_module_editor.cpp
+++ b/pcbnew/block_module_editor.cpp
@@ -461,12 +461,8 @@ void MoveMarkedItems( MODULE* module, wxPoint offset )
switch( item->Type() )
{
case PCB_MODULE_TEXT_T:
- {
- TEXTE_MODULE* tm = (TEXTE_MODULE*) item;
- tm->Offset( offset );
- tm->SetPos0( tm->GetPos0() + offset );
- }
- break;
+ static_cast( item )->Move( offset );
+ break;
case PCB_MODULE_EDGE_T:
{
@@ -588,14 +584,7 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset, bool force_all )
break;
case PCB_MODULE_TEXT_T:
- {
- TEXTE_MODULE* tm = (TEXTE_MODULE*) item;
- tmp = tm->GetTextPosition();
- SETMIRROR( tmp.x );
- tm->SetTextPosition( tmp );
- tmp.y = tm->GetPos0().y;
- tm->SetPos0( tmp );
- }
+ static_cast( item )->MirrorWithModule( offset.x );
break;
default:
@@ -655,18 +644,11 @@ void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all )
break;
case PCB_MODULE_TEXT_T:
- {
- TEXTE_MODULE* tm = (TEXTE_MODULE*) item;
- wxPoint pos = tm->GetTextPosition();
- ROTATE( pos );
- tm->SetTextPosition( pos );
- tm->SetPos0( tm->GetTextPosition() );
- tm->SetOrientation( tm->GetOrientation() + 900 );
- }
- break;
+ static_cast( item )->RotateWithModule( wxPoint( 0, 0 ), 900 );
+ break;
default:
- ;
+ break;
}
item->ClearFlags();
@@ -742,7 +724,7 @@ int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect )
break;
case PCB_MODULE_TEXT_T:
- pos = ( (TEXTE_MODULE*) item )->GetTextPosition();
+ pos = static_cast( item )->GetTextPosition();
if( Rect.Contains( pos ) )
{
diff --git a/pcbnew/board_items_to_polygon_shape_transform.cpp b/pcbnew/board_items_to_polygon_shape_transform.cpp
index 5594bc3e49..dd1562a6fa 100644
--- a/pcbnew/board_items_to_polygon_shape_transform.cpp
+++ b/pcbnew/board_items_to_polygon_shape_transform.cpp
@@ -168,9 +168,12 @@ void MODULE::TransformGraphicShapesWithClearanceToPolygonSet(
switch( item->Type() )
{
case PCB_MODULE_TEXT_T:
- if( ((TEXTE_MODULE*)item)->GetLayer() == aLayer )
- texts.push_back( (TEXTE_MODULE *) item );
- break;
+ {
+ TEXTE_MODULE* text = static_cast( item );
+ if( text->GetLayer() == aLayer )
+ texts.push_back( text );
+ break;
+ }
case PCB_MODULE_EDGE_T:
outline = (EDGE_MODULE*) item;
diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp
index d6efa3b9e6..201de6ff6d 100644
--- a/pcbnew/class_board.cpp
+++ b/pcbnew/class_board.cpp
@@ -168,8 +168,8 @@ void BOARD::Move( const wxPoint& aMoveVector ) // overload
PCB_TARGET_T,
PCB_VIA_T,
PCB_TRACE_T,
- // PCB_PAD_T,
- // PCB_MODULE_TEXT_T,
+ // PCB_PAD_T, Can't be at board level
+ // PCB_MODULE_TEXT_T, Can't be at board level
PCB_MODULE_T,
PCB_ZONE_AREA_T,
EOT
diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp
index cee079c8d6..c22364ce76 100644
--- a/pcbnew/class_module.cpp
+++ b/pcbnew/class_module.cpp
@@ -72,8 +72,8 @@ MODULE::MODULE( BOARD* parent ) :
m_ThermalWidth = 0; // Use zone setting by default
m_ThermalGap = 0; // Use zone setting by default
+ // These are special and mandatory text fields
m_Reference = new TEXTE_MODULE( this, TEXTE_MODULE::TEXT_is_REFERENCE );
-
m_Value = new TEXTE_MODULE( this, TEXTE_MODULE::TEXT_is_VALUE );
// Reserve one void 3D entry, to avoid problems with void list
@@ -131,7 +131,7 @@ MODULE::MODULE( const MODULE& aModule ) :
{
case PCB_MODULE_TEXT_T:
case PCB_MODULE_EDGE_T:
- newItem = (BOARD_ITEM*)item->Clone();
+ newItem = static_cast( item->Clone() );
newItem->SetParent( this );
m_Drawings.PushBack( newItem );
break;
@@ -242,18 +242,21 @@ void MODULE::Copy( MODULE* aModule )
switch( item->Type() )
{
case PCB_MODULE_TEXT_T:
- TEXTE_MODULE * textm;
- textm = new TEXTE_MODULE( this );
- textm->Copy( (TEXTE_MODULE*) item );
- m_Drawings.PushBack( textm );
- break;
+ {
+ TEXTE_MODULE* textm = new TEXTE_MODULE( this );
+ textm->Copy( static_cast( item ) );
+ m_Drawings.PushBack( textm );
+ break;
+ }
case PCB_MODULE_EDGE_T:
- EDGE_MODULE * edge;
- edge = new EDGE_MODULE( this );
- edge->Copy( (EDGE_MODULE*) item );
- m_Drawings.PushBack( edge );
- break;
+ {
+ EDGE_MODULE * edge;
+ edge = new EDGE_MODULE( this );
+ edge->Copy( (EDGE_MODULE*) item );
+ m_Drawings.PushBack( edge );
+ break;
+ }
default:
wxLogMessage( wxT( "MODULE::Copy() Internal Err: unknown type" ) );
@@ -299,9 +302,10 @@ void MODULE::Add( BOARD_ITEM* aBoardItem, bool doAppend )
switch( aBoardItem->Type() )
{
case PCB_MODULE_TEXT_T:
- // Only common texts can be added this way. Reference and value are not hold in the DLIST.
+ // Only user texts can be added this way. Reference and value are not hold in the DLIST.
assert( static_cast( aBoardItem )->GetType() == TEXTE_MODULE::TEXT_is_DIVERS );
- /* no break */
+
+ // no break
case PCB_MODULE_EDGE_T:
if( doAppend )
@@ -337,9 +341,10 @@ BOARD_ITEM* MODULE::Remove( BOARD_ITEM* aBoardItem )
switch( aBoardItem->Type() )
{
case PCB_MODULE_TEXT_T:
- // Only common texts can be added this way. Reference and value are not hold in the DLIST.
+ // Only user texts can be removed this way. Reference and value are not hold in the DLIST.
assert( static_cast( aBoardItem )->GetType() == TEXTE_MODULE::TEXT_is_DIVERS );
- /* no break */
+
+ // no break
case PCB_MODULE_EDGE_T:
return m_Drawings.Remove( static_cast( aBoardItem ) );
@@ -912,8 +917,6 @@ void MODULE::Rotate( const wxPoint& aRotCentre, double aAngle )
void MODULE::Flip( const wxPoint& aCentre )
{
- TEXTE_MODULE* text;
-
// Move module to its final position:
wxPoint finalPos = m_Pos;
@@ -933,24 +936,10 @@ void MODULE::Flip( const wxPoint& aCentre )
pad->Flip( m_Pos );
// Mirror reference.
- text = m_Reference;
- text->m_Pos.y -= m_Pos.y;
- NEGATE( text->m_Pos.y );
- text->m_Pos.y += m_Pos.y;
- NEGATE(text->m_Pos0.y);
- NEGATE_AND_NORMALIZE_ANGLE_POS( text->m_Orient );
- text->SetLayer( FlipLayer( text->GetLayer() ) );
- text->m_Mirror = IsBackLayer( GetLayer() );
+ m_Reference->FlipWithModule( m_Pos.y );
// Mirror value.
- text = m_Value;
- text->m_Pos.y -= m_Pos.y;
- NEGATE( text->m_Pos.y );
- text->m_Pos.y += m_Pos.y;
- NEGATE( text->m_Pos0.y );
- NEGATE_AND_NORMALIZE_ANGLE_POS( text->m_Orient );
- text->SetLayer( FlipLayer( text->GetLayer() ) );
- text->m_Mirror = IsBackLayer( GetLayer() );
+ m_Value->FlipWithModule( m_Pos.y );
// Reverse mirror module graphics and texts.
for( EDA_ITEM* item = m_Drawings; item; item = item->Next() )
@@ -986,14 +975,7 @@ void MODULE::Flip( const wxPoint& aCentre )
break;
case PCB_MODULE_TEXT_T:
- text = (TEXTE_MODULE*) item;
- text->m_Pos.y -= m_Pos.y;
- NEGATE( text->m_Pos.y );
- text->m_Pos.y += m_Pos.y;
- NEGATE( text->m_Pos0.y );
- NEGATE_AND_NORMALIZE_ANGLE_POS( text->m_Orient );
- text->SetLayer( FlipLayer( text->GetLayer() ) );
- text->m_Mirror = IsBackLayer( GetLayer() );
+ static_cast( item )->FlipWithModule( m_Pos.y );
break;
default:
@@ -1032,8 +1014,8 @@ void MODULE::SetPosition( const wxPoint& newpos )
case PCB_MODULE_TEXT_T:
{
- TEXTE_MODULE* text = (TEXTE_MODULE*) item;
- text->m_Pos += delta;
+ TEXTE_MODULE* text = static_cast( item );
+ text->SetTextPosition( text->GetTextPosition() + delta );
break;
}
@@ -1083,19 +1065,21 @@ void MODULE::MoveAnchorPosition( const wxPoint& aMoveVector )
switch( item->Type() )
{
case PCB_MODULE_EDGE_T:
- #undef STRUCT
- #define STRUCT ( (EDGE_MODULE*) item )
- STRUCT->m_Start0 += moveVector;
- STRUCT->m_End0 += moveVector;
- STRUCT->SetDrawCoord();
- break;
+ {
+ EDGE_MODULE* edge = static_cast( item );
+ edge->m_Start0 += moveVector;
+ edge->m_End0 += moveVector;
+ edge->SetDrawCoord();
+ break;
+ }
case PCB_MODULE_TEXT_T:
- #undef STRUCT
- #define STRUCT ( (TEXTE_MODULE*) item )
- STRUCT->SetPos0( STRUCT->GetPos0() + moveVector );
- STRUCT->SetDrawCoord();
- break;
+ {
+ TEXTE_MODULE* text = static_cast( item );
+ text->SetPos0( text->GetPos0() + moveVector );
+ text->SetDrawCoord();
+ break;
+ }
default:
break;
@@ -1135,14 +1119,12 @@ void MODULE::SetOrientation( double newangle )
{
if( item->Type() == PCB_MODULE_EDGE_T )
{
- EDGE_MODULE* edge = (EDGE_MODULE*) item;
- edge->SetDrawCoord();
+ static_cast( item )->SetDrawCoord();
}
else if( item->Type() == PCB_MODULE_TEXT_T )
{
- TEXTE_MODULE* text = (TEXTE_MODULE*) item;
- text->SetDrawCoord();
+ static_cast( item )->SetDrawCoord();
}
}
diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h
index ddae865bd4..9345b7ce4c 100644
--- a/pcbnew/class_module.h
+++ b/pcbnew/class_module.h
@@ -365,7 +365,7 @@ public:
*/
const wxString& GetReference() const
{
- return m_Reference->m_Text;
+ return m_Reference->GetText();
}
/**
@@ -375,7 +375,7 @@ public:
*/
void SetReference( const wxString& aReference )
{
- m_Reference->m_Text = aReference;
+ m_Reference->SetText( aReference );
}
/**
@@ -384,7 +384,7 @@ public:
*/
const wxString& GetValue()
{
- return m_Value->m_Text;
+ return m_Value->GetText();
}
/**
@@ -393,7 +393,7 @@ public:
*/
void SetValue( const wxString& aValue )
{
- m_Value->m_Text = aValue;
+ m_Value->SetText( aValue );
}
/// read/write accessors:
diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp
index e3caf65bf9..624f0781ee 100644
--- a/pcbnew/class_text_mod.cpp
+++ b/pcbnew/class_text_mod.cpp
@@ -102,6 +102,36 @@ void TEXTE_MODULE::Flip(const wxPoint& aCentre )
}
+void TEXTE_MODULE::FlipWithModule( int aOffset )
+{
+ m_Pos.y = aOffset - (m_Pos.y - aOffset);
+ NEGATE_AND_NORMALIZE_ANGLE_POS( m_Orient );
+ SetLayer( FlipLayer( GetLayer() ) );
+ m_Mirror = IsBackLayer( GetLayer() );
+}
+
+
+void TEXTE_MODULE::MirrorWithModule( int aOffset )
+{
+ wxPoint tmp = GetTextPosition();
+ tmp.x = aOffset - (tmp.x - aOffset);
+ SetTextPosition( tmp );
+ tmp.y = GetPos0().y;
+ SetPos0( tmp );
+ NEGATE_AND_NORMALIZE_ANGLE_POS( m_Orient );
+}
+
+
+void TEXTE_MODULE::RotateWithModule( const wxPoint& aOffset, double aAngle )
+{
+ wxPoint pos = GetTextPosition();
+ RotatePoint( &pos, aOffset, aAngle );
+ SetTextPosition( pos );
+ SetPos0( GetTextPosition() );
+ SetOrientation( GetOrientation() + aAngle );
+}
+
+
void TEXTE_MODULE::Copy( TEXTE_MODULE* source )
{
if( source == NULL )
@@ -218,24 +248,31 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
return;
BOARD* brd = GetBoard( );
+
+ // Suppress the element if the layer it is on is on a disabled side
+ LAYER_ID text_layer = GetLayer();
+
+ if( (IsFrontLayer( text_layer ) && !brd->IsElementVisible( MOD_TEXT_FR_VISIBLE )) ||
+ (IsBackLayer( text_layer ) && !brd->IsElementVisible( MOD_TEXT_BK_VISIBLE )) )
+ 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;
- // Determine the element color or suppress it element if hidden
- switch( module->GetLayer() )
+
+ switch( GetType() )
{
- case B_Cu:
- if( !brd->IsElementVisible( MOD_TEXT_BK_VISIBLE ) )
- return;
- color = brd->GetVisibleElementColor( MOD_TEXT_BK_VISIBLE );
+ case TEXT_is_REFERENCE:
+ case TEXT_is_VALUE:
+ if( IsFrontLayer( text_layer ) )
+ color = brd->GetVisibleElementColor( MOD_TEXT_FR_VISIBLE );
+ else
+ color = brd->GetVisibleElementColor( MOD_TEXT_BK_VISIBLE );
break;
- case F_Cu:
- if( !brd->IsElementVisible( MOD_TEXT_FR_VISIBLE ) )
- return;
- color = brd->GetVisibleElementColor( MOD_TEXT_FR_VISIBLE );
- break;
-
- default:
- color = brd->GetLayerColor( module->GetLayer() );
+ case TEXT_is_DIVERS:
+ default: // This is to persuade the compiler that color is always initialized
+ color = brd->GetLayerColor( GetLayer() );
}
// 'Ghost' the element if forced show
@@ -247,7 +284,7 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
}
// Draw mode compensation for the width
- PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent();
+ PCB_BASE_FRAME* frame = static_cast( panel->GetParent() );
int width = m_Thickness;
if( ( frame->m_DisplayModText == LINE )
|| ( DC->LogicalToDeviceXRel( width ) <= MIN_DRAW_WIDTH ) )
@@ -295,7 +332,7 @@ void TEXTE_MODULE::DrawUmbilical( EDA_DRAW_PANEL* aPanel,
GR_DRAWMODE aDrawMode,
const wxPoint& aOffset )
{
- MODULE* parent = (MODULE*) GetParent();
+ MODULE* parent = static_cast( GetParent() );
if( !parent )
return;
@@ -384,22 +421,21 @@ void TEXTE_MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
wxString TEXTE_MODULE::GetSelectMenuText() const
{
wxString text;
+ const wxChar *reference = GetChars( static_cast( GetParent() )->GetReference() );
switch( m_Type )
{
case TEXT_is_REFERENCE:
- text.Printf( _( "Reference %s" ), GetChars( m_Text ) );
+ text.Printf( _( "Reference %s" ), reference );
break;
case TEXT_is_VALUE:
- text.Printf( _( "Value %s of %s" ), GetChars( m_Text ),
- GetChars( ( (MODULE*) GetParent() )->GetReference() ) );
+ text.Printf( _( "Value %s of %s" ), GetChars( m_Text ), reference );
break;
default: // wrap this one in quotes:
text.Printf( _( "Text \"%s\" on %s of %s" ), GetChars( m_Text ),
- GetChars( GetLayerName() ),
- GetChars( ( (MODULE*) GetParent() )->GetReference() ) );
+ GetChars( GetLayerName() ), reference );
break;
}
@@ -443,23 +479,11 @@ void TEXTE_MODULE::ViewGetLayers( int aLayers[], int& aCount ) const
aLayers[0] = ITEM_GAL_LAYER( MOD_VALUES_VISIBLE );
break;
- default:
- switch( GetParent()->GetLayer() )
- {
- case B_Cu:
- aLayers[0] = ITEM_GAL_LAYER( MOD_TEXT_BK_VISIBLE ); // how about B_SilkS?
- break;
-
- case F_Cu:
- aLayers[0] = ITEM_GAL_LAYER( MOD_TEXT_FR_VISIBLE ); // how about F_SilkS?
- break;
-
- default:
- wxFAIL_MSG( wxT( "Can't tell text layer" ) );
- }
- break;
+ case TEXT_is_DIVERS:
+ aLayers[0] = GetLayer();
}
}
aCount = 1;
}
+
diff --git a/pcbnew/class_text_mod.h b/pcbnew/class_text_mod.h
index fff9f20547..f53ca488bb 100644
--- a/pcbnew/class_text_mod.h
+++ b/pcbnew/class_text_mod.h
@@ -48,11 +48,13 @@ class MSG_PANEL_ITEM;
class TEXTE_MODULE : public BOARD_ITEM, public EDA_TEXT
{
- // @todo eliminate these friends, make them use accessors
- friend class MODULE;
- friend class FOOTPRINT_EDIT_FRAME;
-
public:
+ /** Text module type: there must be only one (and only one) for each
+ * of the reference and value texts in one module; others could be
+ * added for the user (DIVERS is French for 'others'). Reference and
+ * value always live on silkscreen (on the module side); other texts
+ * are planned to go on whatever layer the user wants (except
+ * copper, probably) */
enum TEXT_TYPE
{
TEXT_is_REFERENCE = 0,
@@ -92,6 +94,15 @@ public:
void Flip( const wxPoint& aCentre );
+ /// Rotate entity during module rotation
+ void RotateWithModule( const wxPoint& aOffset, double aAngle );
+
+ /// Flip entity during module flip
+ void FlipWithModule( int aOffset );
+
+ /// Mirror entiry during module mirroring
+ void MirrorWithModule( int aOffset );
+
/// @deprecated it seems (but the type is used to 'protect'
//reference and value from deletion, and for identification)
void SetType( TEXT_TYPE aType ) { m_Type = aType; }
@@ -100,6 +111,7 @@ public:
void SetVisible( bool isVisible ) { m_NoShow = !isVisible; }
bool IsVisible() const { return !m_NoShow; }
+ // The Pos0 accessors are for module-relative coordinates
void SetPos0( const wxPoint& aPos ) { m_Pos0 = aPos; SetDrawCoord(); }
const wxPoint& GetPos0() const { return m_Pos0; }
diff --git a/pcbnew/collectors.cpp b/pcbnew/collectors.cpp
index dc047834aa..00425d0b96 100644
--- a/pcbnew/collectors.cpp
+++ b/pcbnew/collectors.cpp
@@ -286,9 +286,10 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, const void* testDa
break;
case PCB_MODULE_TEXT_T:
- module = (MODULE*) item->GetParent();
+ module = static_cast( item->GetParent() );
- if( m_Guide->IgnoreMTextsMarkedNoShow() && !( (TEXTE_MODULE*) item )->IsVisible() )
+ if( m_Guide->IgnoreMTextsMarkedNoShow() &&
+ !static_cast( item )->IsVisible() )
goto exit;
if( module )
diff --git a/pcbnew/cross-probing.cpp b/pcbnew/cross-probing.cpp
index 8000d05adf..d227511f6c 100644
--- a/pcbnew/cross-probing.cpp
+++ b/pcbnew/cross-probing.cpp
@@ -154,12 +154,14 @@ std::string FormatProbeItem( BOARD_ITEM* aItem )
case PCB_MODULE_TEXT_T:
{
- module = (MODULE*) aItem->GetParent();
+ module = static_cast( aItem->GetParent() );
- TEXTE_MODULE* text_mod = (TEXTE_MODULE*) aItem;
+ TEXTE_MODULE* text_mod = static_cast( aItem );
const char* text_key;
+ /* This can't be a switch since the break need to pull out
+ * from the outer switch! */
if( text_mod->GetType() == TEXTE_MODULE::TEXT_is_REFERENCE )
text_key = "$REF:";
else if( text_mod->GetType() == TEXTE_MODULE::TEXT_is_VALUE )
diff --git a/pcbnew/dialogs/dialog_edit_module_text.cpp b/pcbnew/dialogs/dialog_edit_module_text.cpp
index 781b3147ac..c88cf5ecfc 100644
--- a/pcbnew/dialogs/dialog_edit_module_text.cpp
+++ b/pcbnew/dialogs/dialog_edit_module_text.cpp
@@ -123,7 +123,7 @@ void DialogEditModuleText::initDlg( )
m_TextDataTitle->SetLabel( _( "Text:" ) );
break;
- default:
+ case TEXTE_MODULE::TEXT_is_REFERENCE:
m_TextDataTitle->SetLabel( _( "Reference:" ) );
break;
}
diff --git a/pcbnew/dialogs/dialog_global_modules_fields_edition.cpp b/pcbnew/dialogs/dialog_global_modules_fields_edition.cpp
index 9f391c2e24..387e387d6c 100644
--- a/pcbnew/dialogs/dialog_global_modules_fields_edition.cpp
+++ b/pcbnew/dialogs/dialog_global_modules_fields_edition.cpp
@@ -145,7 +145,6 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( const wxString & aFilter, bool aRef,
{
MODULE* module;
BOARD_ITEM* boardItem;
- TEXTE_MODULE* item;
ITEM_PICKER itemWrapper( NULL, UR_CHANGED );
PICKED_ITEMS_LIST undoItemList;
unsigned int ii;
@@ -165,7 +164,7 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( const wxString & aFilter, bool aRef,
if( aRef )
{
- item = &module->Reference();
+ TEXTE_MODULE *item = &module->Reference();
if( item->GetSize() != GetDesignSettings().m_ModuleTextSize ||
item->GetThickness() != GetDesignSettings().m_ModuleTextWidth )
@@ -176,7 +175,7 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( const wxString & aFilter, bool aRef,
if( aValue )
{
- item = &module->Value();
+ TEXTE_MODULE *item = &module->Value();
if( item->GetSize() != GetDesignSettings().m_ModuleTextSize ||
item->GetThickness() != GetDesignSettings().m_ModuleTextWidth )
@@ -192,7 +191,7 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( const wxString & aFilter, bool aRef,
{
if( boardItem->Type() == PCB_MODULE_TEXT_T )
{
- item = (TEXTE_MODULE*) boardItem;
+ TEXTE_MODULE *item = static_cast( boardItem );
if( item->GetSize() != GetDesignSettings().m_ModuleTextSize
|| item->GetThickness() != GetDesignSettings().m_ModuleTextWidth )
@@ -233,7 +232,7 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( const wxString & aFilter, bool aRef,
{
if( boardItem->Type() == PCB_MODULE_TEXT_T )
{
- item = (TEXTE_MODULE*) boardItem;
+ TEXTE_MODULE *item = static_cast( boardItem );
item->SetThickness( GetDesignSettings().m_ModuleTextWidth );
item->SetSize( GetDesignSettings().m_ModuleTextSize );
}
diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp
index 904c14f0bb..cf16ff964c 100644
--- a/pcbnew/dialogs/dialog_pad_properties.cpp
+++ b/pcbnew/dialogs/dialog_pad_properties.cpp
@@ -770,12 +770,12 @@ bool DIALOG_PAD_PROPERTIES::padValuesOK()
error_msgs.Add( _( "Error: Connector pads are not on the solder paste layer\n"
"Use SMD pads instead" ) );
// Fall trough
-/*
case PAD_SMD: // SMD and Connector pads (One external copper layer only)
+/*
if( padlayers_mask[B_Cu] && padlayers_mask[F_Cu] )
error_msgs.Add( _( "Error: only one copper layer allowed for SMD or Connector pads" ) );
- break;
*/
+ break;
}
if( error_msgs.GetCount() )
diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp
index 2fc9a19727..f43ebabde7 100644
--- a/pcbnew/edit.cpp
+++ b/pcbnew/edit.cpp
@@ -932,7 +932,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_PCB_EDIT_TEXTMODULE:
- InstallTextModOptionsFrame( (TEXTE_MODULE*) GetCurItem(), &dc );
+ InstallTextModOptionsFrame( static_cast( GetCurItem() ), &dc );
m_canvas->MoveCursorToCrossHair();
break;
@@ -942,17 +942,16 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST:
m_canvas->MoveCursorToCrossHair();
- StartMoveTexteModule( (TEXTE_MODULE*) GetCurItem(), &dc );
+ StartMoveTexteModule( static_cast( GetCurItem() ), &dc );
break;
case ID_POPUP_PCB_ROTATE_TEXTMODULE:
- RotateTextModule( (TEXTE_MODULE*) GetCurItem(),
- &dc );
+ RotateTextModule( static_cast( GetCurItem() ), &dc );
m_canvas->MoveCursorToCrossHair();
break;
case ID_POPUP_PCB_DELETE_TEXTMODULE:
- DeleteTextModule( (TEXTE_MODULE*) GetCurItem() );
+ DeleteTextModule( static_cast( GetCurItem() ) );
SetCurItem( NULL );
m_canvas->MoveCursorToCrossHair();
break;
diff --git a/pcbnew/editmod.cpp b/pcbnew/editmod.cpp
index 333b36ab8a..1046888e53 100644
--- a/pcbnew/editmod.cpp
+++ b/pcbnew/editmod.cpp
@@ -99,7 +99,7 @@ void FOOTPRINT_EDIT_FRAME::RemoveStruct( EDA_ITEM* Item )
case PCB_MODULE_TEXT_T:
{
- TEXTE_MODULE* text = (TEXTE_MODULE*) Item;
+ TEXTE_MODULE* text = static_cast( Item );
switch( text->GetType() )
{
@@ -111,7 +111,7 @@ void FOOTPRINT_EDIT_FRAME::RemoveStruct( EDA_ITEM* Item )
DisplayError( this, _( "Cannot delete VALUE!" ) );
break;
- default:
+ case TEXTE_MODULE::TEXT_is_DIVERS:
DeleteTextModule( text );
}
}
diff --git a/pcbnew/editrack-part2.cpp b/pcbnew/editrack-part2.cpp
index 9954671ff5..32409a4893 100644
--- a/pcbnew/editrack-part2.cpp
+++ b/pcbnew/editrack-part2.cpp
@@ -263,11 +263,11 @@ void PCB_EDIT_FRAME::Show_1_Ratsnest( EDA_ITEM* item, wxDC* DC )
if( item->Type() == PCB_MODULE_TEXT_T )
{
if( item->GetParent() && ( item->GetParent()->Type() == PCB_MODULE_T ) )
- Module = (MODULE*) item->GetParent();
+ Module = static_cast( item->GetParent() );
}
else if( item->Type() == PCB_MODULE_T )
{
- Module = (MODULE*) item;
+ Module = static_cast( item );
}
if( Module )
diff --git a/pcbnew/edtxtmod.cpp b/pcbnew/edtxtmod.cpp
index 78c1f40d30..3596ae5d18 100644
--- a/pcbnew/edtxtmod.cpp
+++ b/pcbnew/edtxtmod.cpp
@@ -59,14 +59,12 @@ static double TextInitialOrientation; // module text initial orientation for
/* Add a new graphical text to the active module (footprint)
- * Note there always are 2 texts: reference and value.
+ * Note there always are 2 mandatory texts: reference and value.
* New texts have the member TEXTE_MODULE.GetType() set to TEXT_is_DIVERS
*/
TEXTE_MODULE* PCB_BASE_FRAME::CreateTextModule( MODULE* Module, wxDC* DC )
{
- TEXTE_MODULE* Text;
-
- Text = new TEXTE_MODULE( Module );
+ TEXTE_MODULE* Text = new TEXTE_MODULE( Module );
// Add the new text object to the beginning of the draw item list.
if( Module )
@@ -137,7 +135,7 @@ void PCB_BASE_FRAME::DeleteTextModule( TEXTE_MODULE* Text )
if( Text == NULL )
return;
- Module = (MODULE*) Text->GetParent();
+ Module = static_cast( Text->GetParent() );
if( Text->GetType() == TEXTE_MODULE::TEXT_is_DIVERS )
{
@@ -157,7 +155,7 @@ void PCB_BASE_FRAME::DeleteTextModule( TEXTE_MODULE* Text )
static void AbortMoveTextModule( EDA_DRAW_PANEL* Panel, wxDC* DC )
{
BASE_SCREEN* screen = Panel->GetScreen();
- TEXTE_MODULE* Text = (TEXTE_MODULE*) screen->GetCurItem();
+ TEXTE_MODULE* Text = static_cast( screen->GetCurItem() );
MODULE* Module;
Panel->SetMouseCapture( NULL, NULL );
@@ -165,7 +163,7 @@ static void AbortMoveTextModule( EDA_DRAW_PANEL* Panel, wxDC* DC )
if( Text == NULL )
return;
- Module = (MODULE*) Text->GetParent();
+ Module = static_cast( Text->GetParent() );
Text->DrawUmbilical( Panel, DC, GR_XOR, -MoveVector );
Text->Draw( Panel, DC, GR_XOR, MoveVector );
@@ -192,12 +190,10 @@ static void AbortMoveTextModule( EDA_DRAW_PANEL* Panel, wxDC* DC )
*/
void PCB_BASE_FRAME::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC )
{
- MODULE* Module;
-
if( Text == NULL )
return;
- Module = (MODULE*) Text->GetParent();
+ MODULE *Module = static_cast( Text->GetParent() );
Text->SetFlags( IS_MOVED );
Module->SetFlags( IN_EDIT );
@@ -228,7 +224,7 @@ void PCB_BASE_FRAME::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
Text->DrawUmbilical( m_canvas, DC, GR_XOR, -MoveVector );
// Update the coordinates for anchor.
- MODULE* Module = (MODULE*) Text->GetParent();
+ MODULE* Module = static_cast( Text->GetParent() );
if( Module )
{
@@ -273,7 +269,7 @@ static void Show_MoveTexte_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo
bool aErase )
{
BASE_SCREEN* screen = aPanel->GetScreen();
- TEXTE_MODULE* Text = (TEXTE_MODULE*) screen->GetCurItem();
+ TEXTE_MODULE* Text = static_cast( screen->GetCurItem() );
if( Text == NULL )
return;
@@ -308,21 +304,20 @@ void PCB_BASE_FRAME::ResetTextSize( BOARD_ITEM* aItem, wxDC* aDC )
case PCB_TEXT_T:
newSize = GetDesignSettings().m_PcbTextSize;
newThickness = GetDesignSettings().m_PcbTextWidth;
- pcbText = (TEXTE_PCB*) aItem;
- text = (EDA_TEXT*) pcbText;
+ pcbText = static_cast( aItem );
+ text = static_cast( pcbText );
break;
case PCB_MODULE_TEXT_T:
newSize = GetDesignSettings().m_ModuleTextSize;
newThickness = GetDesignSettings().m_ModuleTextWidth;
- moduleText = (TEXTE_MODULE*) aItem;
- text = (EDA_TEXT*) moduleText;
+ moduleText = static_cast( aItem );
+ text = static_cast( moduleText );
break;
default:
// Exit if aItem is not a text field
return;
- break;
}
// Exit if there's nothing to do
diff --git a/pcbnew/exporters/export_gencad.cpp b/pcbnew/exporters/export_gencad.cpp
index 571e8db4cf..6056d11ae9 100644
--- a/pcbnew/exporters/export_gencad.cpp
+++ b/pcbnew/exporters/export_gencad.cpp
@@ -697,7 +697,6 @@ static void CreateComponentsSection( FILE* aFile, BOARD* aPcb )
for( MODULE* module = aPcb->m_Modules; module; module = module->Next() )
{
- TEXTE_MODULE* textmod;
const char* mirror;
const char* flip;
double orient = module->GetOrientation();
@@ -731,7 +730,7 @@ static void CreateComponentsSection( FILE* aFile, BOARD* aPcb )
mirror, flip );
// Text on silk layer: RefDes and value (are they actually useful?)
- textmod = &module->Reference();
+ TEXTE_MODULE *textmod = &module->Reference();
for( int ii = 0; ii < 2; ii++ )
{
diff --git a/pcbnew/exporters/export_vrml.cpp b/pcbnew/exporters/export_vrml.cpp
index f345e4490d..25cd569cf5 100644
--- a/pcbnew/exporters/export_vrml.cpp
+++ b/pcbnew/exporters/export_vrml.cpp
@@ -1211,11 +1211,11 @@ static void export_vrml_module( MODEL_VRML& aModel, BOARD* aPcb, MODULE* aModule
switch( item->Type() )
{
case PCB_MODULE_TEXT_T:
- export_vrml_text_module( dynamic_cast( item ) );
+ export_vrml_text_module( static_cast( item ) );
break;
case PCB_MODULE_EDGE_T:
- export_vrml_edge_module( aModel, dynamic_cast( item ),
+ export_vrml_edge_module( aModel, static_cast( item ),
aModule->GetOrientation() );
break;
diff --git a/pcbnew/hotkeys_board_editor.cpp b/pcbnew/hotkeys_board_editor.cpp
index da2e4f6870..7057f65326 100644
--- a/pcbnew/hotkeys_board_editor.cpp
+++ b/pcbnew/hotkeys_board_editor.cpp
@@ -34,6 +34,9 @@
#include
#include
#include
+#include
+#include
+#include
#include
#include
@@ -900,33 +903,33 @@ bool PCB_EDIT_FRAME::OnHotkeyPlaceItem( wxDC* aDC )
case PCB_TRACE_T:
case PCB_VIA_T:
if( item->IsDragging() )
- PlaceDraggedOrMovedTrackSegment( (TRACK*) item, aDC );
+ PlaceDraggedOrMovedTrackSegment( static_cast