← Back to team overview

kicad-developers team mailing list archive

[PATCH] Make BOARD_ITEM Move/Rotate/Flip abstract

 

There is no good default behaviour for these, so there should not be a
default implementation.
---
 include/class_board_item.h | 15 +++------------
 pcbnew/class_board.h       |  3 +++
 pcbnew/class_netinfo.h     |  4 ++++
 3 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/include/class_board_item.h b/include/class_board_item.h
index 34c275c14..b23baf833 100644
--- a/include/class_board_item.h
+++ b/include/class_board_item.h
@@ -239,10 +239,7 @@ public:
      * move this object.
      * @param aMoveVector - the move vector for this object.
      */
-    virtual void Move( const wxPoint& aMoveVector )
-    {
-        wxMessageBox( wxT( "virtual BOARD_ITEM::Move used, should not occur" ), GetClass() );
-    }
+    virtual void Move( const wxPoint& aMoveVector ) = 0;
 
     /**
      * Function Rotate
@@ -250,20 +247,14 @@ public:
      * @param aRotCentre - the rotation point.
      * @param aAngle - the rotation angle in 0.1 degree.
      */
-    virtual void Rotate( const wxPoint& aRotCentre, double aAngle )
-    {
-        wxMessageBox( wxT( "virtual BOARD_ITEM::Rotate used, should not occur" ), GetClass() );
-    }
+    virtual void Rotate( const wxPoint& aRotCentre, double aAngle ) = 0;
 
     /**
      * Function Flip
      * Flip this object, i.e. change the board side for this object
      * @param aCentre - the rotation point.
      */
-    virtual void Flip( const wxPoint& aCentre )
-    {
-        wxMessageBox( wxT( "virtual BOARD_ITEM::Flip used, should not occur" ), GetClass() );
-    }
+    virtual void Flip( const wxPoint& aCentre ) = 0;
 
     /**
      * Function GetBoard
diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h
index 47381580d..36543cec6 100644
--- a/pcbnew/class_board.h
+++ b/pcbnew/class_board.h
@@ -226,6 +226,9 @@ private:
         return *this;       // just to mute warning
     }
 
+    virtual void Rotate( const wxPoint& aRotCentre, double aAngle ) override { wxFAIL_MSG("Cannot rotate BOARD"); }
+    virtual void Flip( const wxPoint& aCentre ) override                     { wxFAIL_MSG("Cannot flip BOARD"); }
+
 public:
     static inline bool ClassOf( const EDA_ITEM* aItem )
     {
diff --git a/pcbnew/class_netinfo.h b/pcbnew/class_netinfo.h
index f77b0e30b..cb0b8e434 100644
--- a/pcbnew/class_netinfo.h
+++ b/pcbnew/class_netinfo.h
@@ -140,6 +140,10 @@ private:
 
     BOARD*  m_parent;           ///< The parent board the net belongs to.
 
+    virtual void Move( const wxPoint& aMoveVector ) override                 { wxFAIL_MSG("Cannot move NETINFO_ITEM"); }
+    virtual void Rotate( const wxPoint& aRotCentre, double aAngle ) override { wxFAIL_MSG("Cannot rotate NETINFO_ITEM"); }
+    virtual void Flip( const wxPoint& aCentre ) override                     { wxFAIL_MSG("Cannot flip NETINFO_ITEM"); }
+
 public:
 
     D_PADS& Pads()              { return m_PadInNetList; }