Added GetBoundingBox() for SCH_GLOBALLABEL and SCH_HIERLABEL.

This commit is contained in:
diemer 2008-03-30 09:27:53 +00:00
parent c86da05a12
commit a853fb11fa
2 changed files with 106 additions and 0 deletions

View File

@ -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, 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() EDA_Rect SCH_TEXT::GetBoundingBox()
{ {
int x, y, dx, dy, dangle, length, height; int x, y, dx, dy, dangle, length, height;

View File

@ -144,6 +144,8 @@ public:
* <corner_count>, x0, y0, ... xn, yn * <corner_count>, x0, y0, ... xn, yn
*/ */
void CreateGraphicShape( int* corner_list, const wxPoint & Pos ); void CreateGraphicShape( int* corner_list, const wxPoint & Pos );
EDA_Rect GetBoundingBox();
}; };
@ -171,6 +173,8 @@ public:
* <corner_count>, x0, y0, ... xn, yn * <corner_count>, x0, y0, ... xn, yn
*/ */
void CreateGraphicShape( int* corner_list, const wxPoint & Pos ); void CreateGraphicShape( int* corner_list, const wxPoint & Pos );
EDA_Rect GetBoundingBox();
}; };
#endif /* CLASS_TEXT_LABEL_H */ #endif /* CLASS_TEXT_LABEL_H */