From a853fb11fa8dd28eb9b3c52b9fffccf7537c4b6f Mon Sep 17 00:00:00 2001 From: diemer Date: Sun, 30 Mar 2008 09:27:53 +0000 Subject: [PATCH] Added GetBoundingBox() for SCH_GLOBALLABEL and SCH_HIERLABEL. --- eeschema/class_text-label.cpp | 102 ++++++++++++++++++++++++++++++++++ eeschema/class_text-label.h | 4 ++ 2 files changed, 106 insertions(+) diff --git a/eeschema/class_text-label.cpp b/eeschema/class_text-label.cpp index b13f0d47d1..2393faf3f0 100644 --- a/eeschema/class_text-label.cpp +++ b/eeschema/class_text-label.cpp @@ -305,6 +305,56 @@ void SCH_HIERLABEL::CreateGraphicShape( int* corner_list, const wxPoint& Pos ) } } +EDA_Rect SCH_HIERLABEL::GetBoundingBox() +{ + int x, y, dx, dy, dangle, length, height; + + x = m_Pos.x; + y = m_Pos.y; + + if( m_IsDangling ) + dangle = DANGLING_SYMBOL_SIZE; + else + dangle = 0; + + height = m_Size.y + 2*TXTMARGE; + length = ( Pitch() * GetLength() ) + height + 2*dangle; // add height for triangular shapes + + switch( m_Orient ) // respect orientation + { + case 0: /* Horiz Normal Orientation (left justified) */ + dx = -length; + dy = height; + x += dangle; + y -= height/2; + break; + + case 1: /* Vert Orientation UP */ + dx = height; + dy = length; + x -= height/2; + y -= dangle; + break; + + case 2: /* Horiz Orientation - Right justified */ + dx = length; + dy = height; + x -= dangle; + y -= height/2; + break; + + case 3: /* Vert Orientation BOTTOM */ + dx = height; + dy = -length; + x -= height/2; + y += dangle; + break; + } + + EDA_Rect box(wxPoint(x,y), wxSize(dx,dy) ); + box.Normalize(); + return box; +} /*******************************************************************************************/ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& draw_offset, @@ -469,6 +519,58 @@ void SCH_GLOBALLABEL::CreateGraphicShape( int* corner_list, const wxPoint& Pos ) } +EDA_Rect SCH_GLOBALLABEL::GetBoundingBox() +{ + int x, y, dx, dy, dangle, length, height; + + x = m_Pos.x; + y = m_Pos.y; + + if( m_IsDangling ) + dangle = DANGLING_SYMBOL_SIZE; + else + dangle = 0; + + height = m_Size.y + 2*TXTMARGE; + length = ( Pitch() * GetLength() ) + 2* height + 2*dangle; // add 2*height for triangular shapes (bidirectional) + + switch( m_Orient ) // respect orientation + { + case 0: /* Horiz Normal Orientation (left justified) */ + dx = -length; + dy = height; + x += dangle; + y -= height/2; + break; + + case 1: /* Vert Orientation UP */ + dx = height; + dy = length; + x -= height/2; + y -= dangle; + break; + + case 2: /* Horiz Orientation - Right justified */ + dx = length; + dy = height; + x -= dangle; + y -= height/2; + break; + + case 3: /* Vert Orientation BOTTOM */ + dx = height; + dy = -length; + x -= height/2; + y += dangle; + break; + } + + EDA_Rect box(wxPoint(x,y), wxSize(dx,dy) ); + box.Normalize(); + return box; +} + + EDA_Rect SCH_TEXT::GetBoundingBox() { int x, y, dx, dy, dangle, length, height; diff --git a/eeschema/class_text-label.h b/eeschema/class_text-label.h index 896f15639e..2e804c84ea 100644 --- a/eeschema/class_text-label.h +++ b/eeschema/class_text-label.h @@ -144,6 +144,8 @@ public: * , x0, y0, ... xn, yn */ void CreateGraphicShape( int* corner_list, const wxPoint & Pos ); + + EDA_Rect GetBoundingBox(); }; @@ -171,6 +173,8 @@ public: * , x0, y0, ... xn, yn */ void CreateGraphicShape( int* corner_list, const wxPoint & Pos ); + + EDA_Rect GetBoundingBox(); }; #endif /* CLASS_TEXT_LABEL_H */