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( item ), aDC ); break; case PCB_TEXT_T: - Place_Texte_Pcb( (TEXTE_PCB*) item, aDC ); + Place_Texte_Pcb( static_cast( item ), aDC ); break; case PCB_MODULE_TEXT_T: - PlaceTexteModule( (TEXTE_MODULE*) item, aDC ); + PlaceTexteModule( static_cast( item ), aDC ); break; case PCB_PAD_T: - PlacePad( (D_PAD*) item, aDC ); + PlacePad( static_cast( item ), aDC ); break; case PCB_MODULE_T: - PlaceModule( (MODULE*) item, aDC ); + PlaceModule( static_cast( item ), aDC ); break; case PCB_TARGET_T: - PlaceTarget( (PCB_TARGET*) item, aDC ); + PlaceTarget( static_cast( item ), aDC ); break; case PCB_LINE_T: if( no_tool ) // when no tools: existing item moving. - Place_DrawItem( (DRAWSEGMENT*) item, aDC ); + Place_DrawItem( static_cast( item ), aDC ); break; diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index 935c11d711..91ab881bde 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -430,48 +430,48 @@ void PCB_IO::Format( BOARD_ITEM* aItem, int aNestLevel ) const switch( aItem->Type() ) { case PCB_T: - format( (BOARD*) aItem, aNestLevel ); + format( static_cast( aItem ), aNestLevel ); break; case PCB_DIMENSION_T: - format( ( DIMENSION*) aItem, aNestLevel ); + format( static_cast( aItem ), aNestLevel ); break; case PCB_LINE_T: - format( (DRAWSEGMENT*) aItem, aNestLevel ); + format( static_cast( aItem ), aNestLevel ); break; case PCB_MODULE_EDGE_T: - format( (EDGE_MODULE*) aItem, aNestLevel ); + format( static_cast( aItem ), aNestLevel ); break; case PCB_TARGET_T: - format( (PCB_TARGET*) aItem, aNestLevel ); + format( static_cast( aItem ), aNestLevel ); break; case PCB_MODULE_T: - format( (MODULE*) aItem, aNestLevel ); + format( static_cast( aItem ), aNestLevel ); break; case PCB_PAD_T: - format( (D_PAD*) aItem, aNestLevel ); + format( static_cast( aItem ), aNestLevel ); break; case PCB_TEXT_T: - format( (TEXTE_PCB*) aItem, aNestLevel ); + format( static_cast( aItem ), aNestLevel ); break; case PCB_MODULE_TEXT_T: - format( (TEXTE_MODULE*) aItem, aNestLevel ); + format( static_cast( aItem ), aNestLevel ); break; case PCB_TRACE_T: case PCB_VIA_T: - format( (TRACK*) aItem, aNestLevel ); + format( static_cast( aItem ), aNestLevel ); break; case PCB_ZONE_AREA_T: - format( (ZONE_CONTAINER*) aItem, aNestLevel ); + format( static_cast( aItem ), aNestLevel ); break; default: @@ -599,7 +599,7 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const B_CrtYd, F_CrtYd, B_Fab, - F_Fab, + F_Fab }; for( LSEQ seq = aBoard->GetEnabledLayers().Seq( non_cu, DIM( non_cu ) ); seq; ++seq ) @@ -1403,7 +1403,7 @@ void PCB_IO::format( TEXTE_MODULE* aText, int aNestLevel ) const { case TEXTE_MODULE::TEXT_is_REFERENCE: type = wxT( "reference" ); break; case TEXTE_MODULE::TEXT_is_VALUE: type = wxT( "value" ); break; - default: type = wxT( "user" ); + case TEXTE_MODULE::TEXT_is_DIVERS: type = wxT( "user" ); } // Due to the Pcbnew history, m_Orient is saved in screen value diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index e92c20454c..7d4676f4da 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -1221,7 +1221,7 @@ void LEGACY_PLUGIN::loadMODULE( MODULE* aModule ) int tnum = intParse( line + SZ( "T" ) ); - TEXTE_MODULE* textm; + TEXTE_MODULE* textm = 0; switch( tnum ) { @@ -1233,7 +1233,7 @@ void LEGACY_PLUGIN::loadMODULE( MODULE* aModule ) textm = &aModule->Value(); break; - default: + case TEXTE_MODULE::TEXT_is_DIVERS: // text is a drawing textm = new TEXTE_MODULE( aModule ); aModule->GraphicalItems().PushBack( textm ); @@ -1868,7 +1868,7 @@ void LEGACY_PLUGIN::loadMODULE_TEXT( TEXTE_MODULE* aText ) aText->SetPos0( wxPoint( pos0_x, pos0_y ) ); aText->SetSize( wxSize( size0_x, size0_y ) ); - orient -= ( (MODULE*) aText->GetParent() )->GetOrientation(); + orient -= ( static_cast( aText->GetParent() ) )->GetOrientation(); aText->SetOrientation( orient ); @@ -3832,10 +3832,10 @@ void LEGACY_PLUGIN::saveMODULE( const MODULE* me ) const switch( gr->Type() ) { case PCB_MODULE_TEXT_T: - saveMODULE_TEXT( (TEXTE_MODULE*) gr ); + saveMODULE_TEXT( static_cast( gr )); break; case PCB_MODULE_EDGE_T: - saveMODULE_EDGE( (EDGE_MODULE*) gr ); + saveMODULE_EDGE( static_cast( gr )); break; default: THROW_IO_ERROR( wxString::Format( UNKNOWN_GRAPHIC_FORMAT, gr->Type() ) ); diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index c7d5377fd3..ca0ccc137d 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -656,29 +656,29 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_EDIT_TEXTMODULE: - InstallTextModOptionsFrame( (TEXTE_MODULE*) GetScreen()->GetCurItem(), &dc ); + InstallTextModOptionsFrame( static_cast( GetScreen()->GetCurItem() ), &dc ); m_canvas->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST: m_canvas->MoveCursorToCrossHair(); - StartMoveTexteModule( (TEXTE_MODULE*) GetScreen()->GetCurItem(), &dc ); + StartMoveTexteModule( static_cast( GetScreen()->GetCurItem() ), &dc ); break; case ID_POPUP_PCB_ROTATE_TEXTMODULE: - RotateTextModule( (TEXTE_MODULE*) GetScreen()->GetCurItem(), &dc ); + RotateTextModule( static_cast( GetScreen()->GetCurItem() ), &dc ); m_canvas->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_DELETE_TEXTMODULE: SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT ); - DeleteTextModule( (TEXTE_MODULE*) GetScreen()->GetCurItem() ); + DeleteTextModule( static_cast( GetScreen()->GetCurItem() ) ); SetCurItem( NULL ); m_canvas->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_MOVE_EDGE: - Start_Move_EdgeMod( (EDGE_MODULE*) GetScreen()->GetCurItem(), &dc ); + Start_Move_EdgeMod( static_cast( GetScreen()->GetCurItem() ), &dc ); m_canvas->MoveCursorToCrossHair(); break; @@ -818,7 +818,6 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform ) { - TEXTE_MODULE* textmod; wxPoint pos; double angle = 900; // Necessary +- 900 (+- 90 degrees). // Be prudent: because RotateMarkedItems is used to rotate some items @@ -827,45 +826,15 @@ void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform ) switch( transform ) { case ID_MODEDIT_MODULE_ROTATE: - #define ROTATE( z ) RotatePoint( (&z), angle ) + module->Reference().RotateWithModule( wxPoint(0,0), angle ); + module->Value().RotateWithModule( wxPoint(0,0), angle ); + RotateMarkedItems( module, wxPoint(0,0), true ); - - pos = module->Reference().GetTextPosition(); - ROTATE( pos ); - module->Reference().SetTextPosition( pos ); - module->Reference().SetPos0( module->Reference().GetTextPosition() ); - module->Reference().m_Orient += angle; - - if( module->Reference().m_Orient >= 1800 ) - module->Reference().m_Orient -= 1800; - - pos = module->Value().GetTextPosition(); - ROTATE( pos ); - module->Value().SetTextPosition( pos ); - module->Value().SetPos0( module->Value().m_Pos ); - module->Value().m_Orient += angle; - - if( module->Value().m_Orient >= 1800 ) - module->Value().m_Orient -= 1800; - break; case ID_MODEDIT_MODULE_MIRROR: - // Mirror reference. - textmod = &module->Reference(); - NEGATE( textmod->m_Pos.x ); - NEGATE( textmod->m_Pos0.x ); - - if( textmod->m_Orient ) - textmod->m_Orient = 3600 - textmod->m_Orient; - - // Mirror value. - textmod = &module->Value(); - NEGATE( textmod->m_Pos.x ); - NEGATE( textmod->m_Pos0.x ); - - if( textmod->m_Orient ) - textmod->m_Orient = 3600 - textmod->m_Orient; + module->Reference().MirrorWithModule( 0 ); + module->Value().MirrorWithModule( 0 ); // Mirror pads and graphic items of the footprint: MirrorMarkedItems( module, wxPoint(0,0), true ); diff --git a/pcbnew/modedit_onclick.cpp b/pcbnew/modedit_onclick.cpp index b6f4437e53..70374ca976 100644 --- a/pcbnew/modedit_onclick.cpp +++ b/pcbnew/modedit_onclick.cpp @@ -34,16 +34,16 @@ void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) switch( item->Type() ) { case PCB_MODULE_TEXT_T: - PlaceTexteModule( (TEXTE_MODULE*) item, DC ); + PlaceTexteModule( static_cast( item ), DC ); break; case PCB_MODULE_EDGE_T: SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT ); - Place_EdgeMod( (EDGE_MODULE*) item ); + Place_EdgeMod( static_cast( item ) ); break; case PCB_PAD_T: - PlacePad( (D_PAD*) item, DC ); + PlacePad( static_cast( item ), DC ); break; default: @@ -313,7 +313,7 @@ bool FOOTPRINT_EDIT_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMen HK_EDIT_ITEM ); AddMenuItem( PopMenu, ID_POPUP_PCB_EDIT_TEXTMODULE, msg, KiBitmap( edit_text_xpm ) ); - if( ( (TEXTE_MODULE*) item )->GetType() == TEXTE_MODULE::TEXT_is_DIVERS ) + if( ( static_cast( item ) )->GetType() == TEXTE_MODULE::TEXT_is_DIVERS ) { msg = AddHotkeyName( _("Delete Text Mod." ), g_Module_Editor_Hokeys_Descr, HK_DELETE ); @@ -444,13 +444,13 @@ void FOOTPRINT_EDIT_FRAME::OnEditItemRequest( wxDC* aDC, BOARD_ITEM* aItem ) switch( aItem->Type() ) { case PCB_PAD_T: - InstallPadOptionsFrame( (D_PAD*) aItem ); + InstallPadOptionsFrame( static_cast( aItem ) ); m_canvas->MoveCursorToCrossHair(); break; case PCB_MODULE_T: { - DIALOG_MODULE_MODULE_EDITOR dialog( this, (MODULE*) aItem ); + DIALOG_MODULE_MODULE_EDITOR dialog( this, static_cast( aItem ) ); int ret = dialog.ShowModal(); GetScreen()->GetCurItem()->ClearFlags(); m_canvas->MoveCursorToCrossHair(); @@ -461,13 +461,13 @@ void FOOTPRINT_EDIT_FRAME::OnEditItemRequest( wxDC* aDC, BOARD_ITEM* aItem ) break; case PCB_MODULE_TEXT_T: - InstallTextModOptionsFrame( (TEXTE_MODULE*) aItem, aDC ); + InstallTextModOptionsFrame( static_cast( aItem ), aDC ); m_canvas->MoveCursorToCrossHair(); break; case PCB_MODULE_EDGE_T : m_canvas->MoveCursorToCrossHair(); - InstallFootprintBodyItemPropertiesDlg( (EDGE_MODULE*) aItem ); + InstallFootprintBodyItemPropertiesDlg( static_cast( aItem ) ); m_canvas->Refresh(); break; diff --git a/pcbnew/onleftclick.cpp b/pcbnew/onleftclick.cpp index f423ff9889..cb3dfeaa8a 100644 --- a/pcbnew/onleftclick.cpp +++ b/pcbnew/onleftclick.cpp @@ -35,8 +35,13 @@ #include #include +#include +#include #include #include +#include +#include +#include #include #include @@ -71,7 +76,7 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) } else { - End_Move_Zone_Corner_Or_Outlines( aDC, (ZONE_CONTAINER*) DrawStruct ); + End_Move_Zone_Corner_Or_Outlines( aDC, static_cast( DrawStruct ) ); } exit = true; @@ -81,41 +86,41 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) case PCB_VIA_T: if( DrawStruct->IsDragging() ) { - PlaceDraggedOrMovedTrackSegment( (TRACK*) DrawStruct, aDC ); + PlaceDraggedOrMovedTrackSegment( static_cast( DrawStruct ), aDC ); exit = true; } break; case PCB_TEXT_T: - Place_Texte_Pcb( (TEXTE_PCB*) DrawStruct, aDC ); + Place_Texte_Pcb( static_cast( DrawStruct ), aDC ); exit = true; break; case PCB_MODULE_TEXT_T: - PlaceTexteModule( (TEXTE_MODULE*) DrawStruct, aDC ); + PlaceTexteModule( static_cast( DrawStruct ), aDC ); exit = true; break; case PCB_PAD_T: - PlacePad( (D_PAD*) DrawStruct, aDC ); + PlacePad( static_cast( DrawStruct ), aDC ); exit = true; break; case PCB_MODULE_T: - PlaceModule( (MODULE*) DrawStruct, aDC ); + PlaceModule( static_cast( DrawStruct ), aDC ); exit = true; break; case PCB_TARGET_T: - PlaceTarget( (PCB_TARGET*) DrawStruct, aDC ); + PlaceTarget( static_cast( DrawStruct ), aDC ); exit = true; break; case PCB_LINE_T: if( no_tool ) // when no tools: existing item moving. { - Place_DrawItem( (DRAWSEGMENT*) DrawStruct, aDC ); + Place_DrawItem( static_cast( DrawStruct ), aDC ); exit = true; } @@ -124,7 +129,7 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) case PCB_DIMENSION_T: if( ! DrawStruct->IsNew() ) { // We are moving the text of an existing dimension. Place it - PlaceDimensionText( (DIMENSION*) DrawStruct, aDC ); + PlaceDimensionText( static_cast( DrawStruct ), aDC ); exit = true; } break; @@ -552,39 +557,39 @@ void PCB_EDIT_FRAME::OnEditItemRequest( wxDC* aDC, BOARD_ITEM* aItem ) { case PCB_TRACE_T: case PCB_VIA_T: - Edit_TrackSegm_Width( aDC, (TRACK*) aItem ); + Edit_TrackSegm_Width( aDC, static_cast( aItem ) ); break; case PCB_TEXT_T: - InstallTextPCBOptionsFrame( (TEXTE_PCB*) aItem, aDC ); + InstallTextPCBOptionsFrame( static_cast( aItem ), aDC ); break; case PCB_PAD_T: - InstallPadOptionsFrame( (D_PAD*) aItem ); + InstallPadOptionsFrame( static_cast( aItem ) ); break; case PCB_MODULE_T: - InstallModuleOptionsFrame( (MODULE*) aItem, aDC ); + InstallModuleOptionsFrame( static_cast( aItem ), aDC ); break; case PCB_TARGET_T: - ShowTargetOptionsDialog( (PCB_TARGET*) aItem, aDC ); + ShowTargetOptionsDialog( static_cast( aItem ), aDC ); break; case PCB_DIMENSION_T: - ShowDimensionPropertyDialog( (DIMENSION*) aItem, aDC ); + ShowDimensionPropertyDialog( static_cast( aItem ), aDC ); break; case PCB_MODULE_TEXT_T: - InstallTextModOptionsFrame( (TEXTE_MODULE*) aItem, aDC ); + InstallTextModOptionsFrame( static_cast( aItem ), aDC ); break; case PCB_LINE_T: - InstallGraphicItemPropertiesDialog( (DRAWSEGMENT*) aItem, aDC ); + InstallGraphicItemPropertiesDialog( static_cast( aItem ), aDC ); break; case PCB_ZONE_AREA_T: - Edit_Zone_Params( aDC, (ZONE_CONTAINER*) aItem ); + Edit_Zone_Params( aDC, static_cast( aItem ) ); break; default: diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp index aa210034a3..87e81294df 100644 --- a/pcbnew/onrightclick.cpp +++ b/pcbnew/onrightclick.cpp @@ -180,11 +180,11 @@ bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) break; case PCB_PAD_T: - createPopUpMenuForFpPads( (D_PAD*) item, aPopMenu ); + createPopUpMenuForFpPads( static_cast( item ), aPopMenu ); break; case PCB_MODULE_TEXT_T: - createPopUpMenuForFpTexts( (TEXTE_MODULE*) item, aPopMenu ); + createPopUpMenuForFpTexts( static_cast( item ), aPopMenu ); break; case PCB_LINE_T: // Some graphic items on technical layers diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index bb06015b6e..be3c9d224d 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -214,54 +214,53 @@ bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer ) { case PCB_ZONE_T: case PCB_TRACE_T: - draw( (const TRACK*) item, aLayer ); + draw( static_cast( item ), aLayer ); break; case PCB_VIA_T: - draw( (const VIA*) item, aLayer ); + draw( static_cast( item ), aLayer ); break; case PCB_PAD_T: - draw( (const D_PAD*) item, aLayer ); + draw( static_cast( item ), aLayer ); break; case PCB_LINE_T: case PCB_MODULE_EDGE_T: - draw( (DRAWSEGMENT*) item, aLayer ); + draw( static_cast( item ), aLayer ); break; case PCB_TEXT_T: - draw( (TEXTE_PCB*) item, aLayer ); + draw( static_cast( item ), aLayer ); break; case PCB_MODULE_TEXT_T: - draw( (TEXTE_MODULE*) item, aLayer ); + draw( static_cast( item ), aLayer ); break; case PCB_MODULE_T: - draw( (MODULE*) item, aLayer ); + draw( static_cast( item ), aLayer ); break; case PCB_ZONE_AREA_T: - draw( (ZONE_CONTAINER*) item ); + draw( static_cast( item ) ); break; case PCB_DIMENSION_T: - draw( (DIMENSION*) item, aLayer ); + draw( static_cast( item ), aLayer ); break; case PCB_TARGET_T: - draw( (PCB_TARGET*) item ); + draw( static_cast( item ) ); break; case PCB_MARKER_T: - draw( (MARKER_PCB*) item ); + draw( static_cast( item ) ); break; default: // Painter does not know how to draw the object return false; - break; } return true; diff --git a/pcbnew/print_board_functions.cpp b/pcbnew/print_board_functions.cpp index 54c5f49318..456e57bfeb 100644 --- a/pcbnew/print_board_functions.cpp +++ b/pcbnew/print_board_functions.cpp @@ -404,17 +404,18 @@ static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule, switch( item->Type() ) { case PCB_MODULE_TEXT_T: - if( !( mlayer & aMask ).any() ) - break; + { + if( !( mlayer & aMask ).any() ) + break; - TEXTE_MODULE* textMod; - textMod = (TEXTE_MODULE*) item; - textMod->Draw( aPanel, aDC, aDraw_mode ); - break; + TEXTE_MODULE* textMod = static_cast( item ); + textMod->Draw( aPanel, aDC, aDraw_mode ); + break; + } case PCB_MODULE_EDGE_T: { - EDGE_MODULE* edge = (EDGE_MODULE*) item; + EDGE_MODULE* edge = static_cast( item ); if( !aMask[edge->GetLayer()] ) break; diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 7b12ee4b96..177191e444 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -489,7 +489,7 @@ void EDIT_TOOL::remove( BOARD_ITEM* aItem ) DisplayError( getEditFrame(), _( "Cannot delete VALUE!" ) ); return; - default: // suppress warnings + case TEXTE_MODULE::TEXT_is_DIVERS: // suppress warnings break; } }