From 89849cdfa787ba79fdae36b5e67a888e142fed7e Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Thu, 29 Aug 2013 12:06:06 +0200 Subject: [PATCH] Unified Set/GetPosition() for BOARD_ITEMs. --- include/class_board_item.h | 4 ++++ pcbnew/class_board.cpp | 15 ++++++++++++++- pcbnew/class_board.h | 4 ++++ pcbnew/class_pcb_text.h | 10 ++++++++++ pcbnew/class_text_mod.h | 10 ++++++++++ 5 files changed, 42 insertions(+), 1 deletion(-) diff --git a/include/class_board_item.h b/include/class_board_item.h index ea0a10b38f..f63e141ed7 100644 --- a/include/class_board_item.h +++ b/include/class_board_item.h @@ -90,6 +90,10 @@ public: // Do not create a copy constructor. The one generated by the compiler is adequate. + virtual const wxPoint& GetPosition() const = 0; + + virtual void SetPosition( const wxPoint& aPos ) = 0; + /** * A value of wxPoint(0,0) which can be passed to the Draw() functions. */ diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 47a1df6ccb..d49685b8ec 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -123,9 +123,22 @@ BOARD::~BOARD() } +const wxPoint& BOARD::GetPosition() const +{ + wxLogWarning( wxT( "This should not be called on the BOARD object") ); + + return ZeroOffset; +} + +void BOARD::SetPosition( const wxPoint& aPos ) +{ + wxLogWarning( wxT( "This should not be called on the BOARD object") ); +} + + void BOARD::Move( const wxPoint& aMoveVector ) // overload { - + wxLogWarning( wxT( "This should not be called on the BOARD object") ); } diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index 3b8e614475..87fa424973 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -308,6 +308,10 @@ public: BOARD(); ~BOARD(); + virtual const wxPoint& GetPosition() const; + + virtual void SetPosition( const wxPoint& aPos ); + bool IsEmpty() const { return m_Drawings.GetCount() == 0 && m_Modules.GetCount() == 0 && diff --git a/pcbnew/class_pcb_text.h b/pcbnew/class_pcb_text.h index 4bf5395b63..d8896d7ea9 100644 --- a/pcbnew/class_pcb_text.h +++ b/pcbnew/class_pcb_text.h @@ -49,6 +49,16 @@ public: ~TEXTE_PCB(); + virtual const wxPoint& GetPosition() const + { + return m_Pos; + } + + virtual void SetPosition( const wxPoint& aPos ) + { + m_Pos = aPos; + } + void Move( const wxPoint& aMoveVector ) { m_Pos += aMoveVector; diff --git a/pcbnew/class_text_mod.h b/pcbnew/class_text_mod.h index 42add84304..635cef14de 100644 --- a/pcbnew/class_text_mod.h +++ b/pcbnew/class_text_mod.h @@ -79,6 +79,16 @@ public: ~TEXTE_MODULE(); + virtual const wxPoint& GetPosition() const + { + return m_Pos; + } + + virtual void SetPosition( const wxPoint& aPos ) + { + m_Pos = aPos; + } + TEXTE_MODULE* Next() const { return (TEXTE_MODULE*) Pnext; } TEXTE_MODULE* Back() const { return (TEXTE_MODULE*) Pback; }