diff --git a/eeschema/sch_bitmap.h b/eeschema/sch_bitmap.h index 43eefb065a..f7fa54cbd8 100644 --- a/eeschema/sch_bitmap.h +++ b/eeschema/sch_bitmap.h @@ -78,6 +78,11 @@ public: m_image->SetScale( aScale ); } + static inline bool ClassOf( const EDA_ITEM* aItem ) + { + return aItem && SCH_BITMAP_T == aItem->Type(); + } + wxString GetClass() const override { return wxT( "SCH_BITMAP" ); diff --git a/eeschema/sch_bus_entry.h b/eeschema/sch_bus_entry.h index 93b6a09bc4..59c9a91d07 100644 --- a/eeschema/sch_bus_entry.h +++ b/eeschema/sch_bus_entry.h @@ -132,6 +132,11 @@ public: ~SCH_BUS_WIRE_ENTRY() { } + static inline bool ClassOf( const EDA_ITEM* aItem ) + { + return aItem && SCH_BUS_WIRE_ENTRY_T == aItem->Type(); + } + wxString GetClass() const override { return wxT( "SCH_BUS_WIRE_ENTRY" ); @@ -174,6 +179,11 @@ public: ~SCH_BUS_BUS_ENTRY() { } + static inline bool ClassOf( const EDA_ITEM* aItem ) + { + return aItem && SCH_BUS_BUS_ENTRY_T == aItem->Type(); + } + wxString GetClass() const override { return wxT( "SCH_BUS_BUS_ENTRY" ); diff --git a/eeschema/sch_field.h b/eeschema/sch_field.h index e430881fca..b516257c55 100644 --- a/eeschema/sch_field.h +++ b/eeschema/sch_field.h @@ -63,6 +63,11 @@ public: ~SCH_FIELD(); + static inline bool ClassOf( const EDA_ITEM* aItem ) + { + return aItem && SCH_FIELD_T == aItem->Type(); + } + wxString GetClass() const override { return wxT( "SCH_FIELD" ); diff --git a/eeschema/sch_junction.h b/eeschema/sch_junction.h index e01e2c832b..967480ea40 100644 --- a/eeschema/sch_junction.h +++ b/eeschema/sch_junction.h @@ -41,6 +41,11 @@ public: ~SCH_JUNCTION() { } + static inline bool ClassOf( const EDA_ITEM* aItem ) + { + return aItem && SCH_JUNCTION_T == aItem->Type(); + } + wxString GetClass() const override { return wxT( "SCH_JUNCTION" ); diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h index 9c16871022..abb4a60742 100644 --- a/eeschema/sch_line.h +++ b/eeschema/sch_line.h @@ -57,6 +57,11 @@ public: SCH_LINE* Next() const { return (SCH_LINE*) Pnext; } SCH_LINE* Back() const { return (SCH_LINE*) Pback; } + static inline bool ClassOf( const EDA_ITEM* aItem ) + { + return aItem && SCH_LINE_T == aItem->Type(); + } + wxString GetClass() const override { return wxT( "SCH_LINE" ); diff --git a/eeschema/sch_marker.h b/eeschema/sch_marker.h index 7cf993ee03..853e4ef0dc 100644 --- a/eeschema/sch_marker.h +++ b/eeschema/sch_marker.h @@ -38,6 +38,11 @@ public: // Do not create a copy constructor. The one generated by the compiler is adequate. + static inline bool ClassOf( const EDA_ITEM* aItem ) + { + return aItem && SCH_MARKER_T == aItem->Type(); + } + wxString GetClass() const override { return wxT( "SCH_MARKER" ); diff --git a/eeschema/sch_no_connect.h b/eeschema/sch_no_connect.h index d2a8cddca4..3b6bde80c9 100644 --- a/eeschema/sch_no_connect.h +++ b/eeschema/sch_no_connect.h @@ -46,6 +46,11 @@ public: ~SCH_NO_CONNECT() { } + static inline bool ClassOf( const EDA_ITEM* aItem ) + { + return aItem && SCH_NO_CONNECT_T == aItem->Type(); + } + wxString GetClass() const override { return wxT( "SCH_NO_CONNECT" ); diff --git a/eeschema/sch_pin.h b/eeschema/sch_pin.h index 33faf048f1..221e9dfd9a 100644 --- a/eeschema/sch_pin.h +++ b/eeschema/sch_pin.h @@ -49,6 +49,11 @@ public: SCH_PIN& operator=( const SCH_PIN& aPin ); + static inline bool ClassOf( const EDA_ITEM* aItem ) + { + return aItem && SCH_PIN_T == aItem->Type(); + } + wxString GetClass() const override { return wxT( "SCH_PIN" ); diff --git a/eeschema/sch_screen.h b/eeschema/sch_screen.h index adc6f691a2..703cd4aaad 100644 --- a/eeschema/sch_screen.h +++ b/eeschema/sch_screen.h @@ -105,6 +105,11 @@ public: DLIST< SCH_ITEM > & GetDrawList() { return m_drawList; } + static inline bool ClassOf( const EDA_ITEM* aItem ) + { + return aItem && SCH_SCREEN_T == aItem->Type(); + } + virtual wxString GetClass() const override { return wxT( "SCH_SCREEN" ); diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index 8c2d736825..892a74020b 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -91,6 +91,11 @@ public: ~SCH_SHEET_PIN() { } + static inline bool ClassOf( const EDA_ITEM* aItem ) + { + return aItem && SCH_SHEET_PIN_T == aItem->Type(); + } + wxString GetClass() const override { return wxT( "SCH_SHEET_PIN" ); @@ -243,6 +248,11 @@ public: ~SCH_SHEET(); + static inline bool ClassOf( const EDA_ITEM* aItem ) + { + return aItem && SCH_SHEET_T == aItem->Type(); + } + wxString GetClass() const override { return wxT( "SCH_SHEET" ); diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h index b37752e847..9baf17ddd3 100644 --- a/eeschema/sch_text.h +++ b/eeschema/sch_text.h @@ -93,6 +93,11 @@ public: ~SCH_TEXT() { } + static inline bool ClassOf( const EDA_ITEM* aItem ) + { + return aItem && SCH_TEXT_T == aItem->Type(); + } + virtual wxString GetClass() const override { return wxT( "SCH_TEXT" ); @@ -217,6 +222,11 @@ public: ~SCH_LABEL() { } + static inline bool ClassOf( const EDA_ITEM* aItem ) + { + return aItem && SCH_LABEL_T == aItem->Type(); + } + wxString GetClass() const override { return wxT( "SCH_LABEL" ); @@ -258,6 +268,11 @@ public: void Print( wxDC* DC, const wxPoint& offset ) override; + static inline bool ClassOf( const EDA_ITEM* aItem ) + { + return aItem && SCH_GLOBAL_LABEL_T == aItem->Type(); + } + wxString GetClass() const override { return wxT( "SCH_GLOBALLABEL" ); @@ -303,6 +318,11 @@ public: void Print( wxDC* DC, const wxPoint& offset ) override; + static inline bool ClassOf( const EDA_ITEM* aItem ) + { + return aItem && SCH_HIER_LABEL_T == aItem->Type(); + } + wxString GetClass() const override { return wxT( "SCH_HIERLABEL" ); diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index e23ef1ede7..d763c944ca 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -696,12 +696,13 @@ bool EE_SELECTION_TOOL::selectMultiple() view->Query( selectionBox, selectedItems ); // Get the list of selected items // Sheet pins aren't in the view; add them by hand - for( KIGFX::VIEW::LAYER_ITEM_PAIR& pair : selectedItems ) + for( auto& pair : selectedItems ) { - if( static_cast( pair.first )->Type() == SCH_SHEET_T ) + auto item = dynamic_cast( pair.first ); + + if( auto sheet = dyn_cast( item ) ) { - SCH_SHEET* sheet = (SCH_SHEET*) pair.first; - int layer = pair.second; + int layer = pair.second; for( SCH_SHEET_PIN& pin : sheet->GetPins() ) selectedItems.emplace_back( KIGFX::VIEW::LAYER_ITEM_PAIR( &pin, layer ) );