Commit b8c2e4dd authored by Marco Mattila's avatar Marco Mattila

Remove redundant bounding box calculation code from pcbnew.

parent 2b216bcc
......@@ -198,7 +198,6 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
for( ; Module != NULL; Module = Module->Next() )
{
Module->Set_Rectangle_Encadrement();
Module->SetRectangleExinscrit();
moduleList.push_back(Module);
}
sort( moduleList.begin(), moduleList.end(), sortModulesbySize );
......@@ -254,12 +253,12 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
}
GetScreen()->SetCrossHairPosition( current + Module->m_Pos -
Module->m_RealBoundaryBox.GetPosition() );
Ymax_size = MAX( Ymax_size, Module->m_RealBoundaryBox.GetHeight() );
Module->m_BoundaryBox.GetPosition() );
Ymax_size = MAX( Ymax_size, Module->m_BoundaryBox.GetHeight() );
Place_Module( Module, NULL, true );
current.x += Module->m_RealBoundaryBox.GetWidth() + pas_grille;
current.x += Module->m_BoundaryBox.GetWidth() + pas_grille;
}
DrawPanel->Refresh();
......
......@@ -122,7 +122,6 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
for( ; Module != NULL; Module = Module->Next() )
{
Module->Set_Rectangle_Encadrement();
Module->SetRectangleExinscrit();
NbTotalModules ++;
}
......@@ -204,7 +203,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
{
int Angle_Rot_Module = 1800;
Rotate_Module( DC, Module, Angle_Rot_Module, false );
Module->SetRectangleExinscrit();
Module->Set_Rectangle_Encadrement();
error = RecherchePlacementModule( Module, DC );
MinCout *= OrientPenality[ii];
if( BestScore > MinCout ) /* This orientation is best. */
......@@ -277,7 +276,6 @@ end_of_tst:
GetScreen()->SetCrossHairPosition( CurrPosition );
Module->Set_Rectangle_Encadrement();
Module->SetRectangleExinscrit();
GenModuleOnBoard( Module );
Module->m_ModuleStatus |= MODULE_is_PLACED;
......@@ -491,10 +489,10 @@ void PCB_EDIT_FRAME::GenModuleOnBoard( MODULE* Module )
int masque_layer;
D_PAD* Pad;
ox = Module->m_RealBoundaryBox.m_Pos.x - marge;
fx = Module->m_RealBoundaryBox.GetRight() + marge;
oy = Module->m_RealBoundaryBox.m_Pos.y - marge;
fy = Module->m_RealBoundaryBox.GetBottom() + marge;
ox = Module->m_BoundaryBox.m_Pos.x - marge;
fx = Module->m_BoundaryBox.GetRight() + marge;
oy = Module->m_BoundaryBox.m_Pos.y - marge;
fy = Module->m_BoundaryBox.GetBottom() + marge;
if( ox < GetBoard()->m_BoundaryBox.m_Pos.x )
ox = GetBoard()->m_BoundaryBox.m_Pos.x;
......@@ -571,10 +569,10 @@ int PCB_EDIT_FRAME::RecherchePlacementModule( MODULE* Module, wxDC* DC )
LastPosOK.y = GetBoard()->m_BoundaryBox.m_Pos.y;
cx = Module->m_Pos.x; cy = Module->m_Pos.y;
ox = Module->m_RealBoundaryBox.m_Pos.x - cx;
fx = Module->m_RealBoundaryBox.m_Size.x + ox;
oy = Module->m_RealBoundaryBox.m_Pos.y - cy;
fy = Module->m_RealBoundaryBox.m_Size.y + oy;
ox = Module->m_BoundaryBox.m_Pos.x - cx;
fx = Module->m_BoundaryBox.m_Size.x + ox;
oy = Module->m_BoundaryBox.m_Pos.y - cy;
fy = Module->m_BoundaryBox.m_Size.y + oy;
CurrPosition.x = GetBoard()->m_BoundaryBox.m_Pos.x - ox;
CurrPosition.y = GetBoard()->m_BoundaryBox.m_Pos.y - oy;
......@@ -626,8 +624,8 @@ int PCB_EDIT_FRAME::RecherchePlacementModule( MODULE* Module, wxDC* DC )
}
cx = Module->m_Pos.x; cy = Module->m_Pos.y;
Module->m_RealBoundaryBox.m_Pos.x = ox + CurrPosition.x;
Module->m_RealBoundaryBox.m_Pos.y = oy + CurrPosition.y;
Module->m_BoundaryBox.m_Pos.x = ox + CurrPosition.x;
Module->m_BoundaryBox.m_Pos.y = oy + CurrPosition.y;
DrawModuleOutlines( DrawPanel, DC, Module );
......@@ -646,8 +644,8 @@ int PCB_EDIT_FRAME::RecherchePlacementModule( MODULE* Module, wxDC* DC )
if( DisplayChevelu )
Compute_Ratsnest_PlaceModule( DC );
DisplayChevelu = 0;
Module->m_RealBoundaryBox.m_Pos.x = ox + CurrPosition.x;
Module->m_RealBoundaryBox.m_Pos.y = oy + CurrPosition.y;
Module->m_BoundaryBox.m_Pos.x = ox + CurrPosition.x;
Module->m_BoundaryBox.m_Pos.y = oy + CurrPosition.y;
g_Offset_Module.y = cy - CurrPosition.y;
DrawModuleOutlines( DrawPanel, DC, Module );
......@@ -683,8 +681,8 @@ int PCB_EDIT_FRAME::RecherchePlacementModule( MODULE* Module, wxDC* DC )
Compute_Ratsnest_PlaceModule( DC );
/* Regeneration of the modified variable. */
Module->m_RealBoundaryBox.m_Pos.x = ox + cx;
Module->m_RealBoundaryBox.m_Pos.y = oy + cy;
Module->m_BoundaryBox.m_Pos.x = ox + cx;
Module->m_BoundaryBox.m_Pos.y = oy + cy;
CurrPosition = LastPosOK;
GetBoard()->m_Status_Pcb &= ~( RATSNEST_ITEM_LOCAL_OK | LISTE_PAD_OK );
......@@ -807,10 +805,10 @@ int TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide )
side = BOTTOM; otherside = TOP;
}
ox = Module->m_RealBoundaryBox.m_Pos.x;
fx = Module->m_RealBoundaryBox.GetRight();
oy = Module->m_RealBoundaryBox.m_Pos.y;
fy = Module->m_RealBoundaryBox.GetBottom();
ox = Module->m_BoundaryBox.m_Pos.x;
fx = Module->m_BoundaryBox.GetRight();
oy = Module->m_BoundaryBox.m_Pos.y;
fy = Module->m_BoundaryBox.GetBottom();
error = TstRectangle( Pcb, ox, oy, fx, fy, side );
if( error < 0 )
......@@ -1031,7 +1029,6 @@ static MODULE* PickModule( PCB_EDIT_FRAME* pcbframe, wxDC* DC )
for( ; Module != NULL; Module = Module->Next() )
{
Module->Set_Rectangle_Encadrement();
Module->SetRectangleExinscrit();
moduleList.push_back(Module);
}
sort( moduleList.begin(), moduleList.end(), Tri_PlaceModules );
......
......@@ -761,94 +761,20 @@ unsigned BOARD::GetNodesCount()
bool BOARD::ComputeBoundingBox( bool aBoardEdgesOnly )
{
int rayon, cx, cy, d, xmin, ymin, xmax, ymax;
bool hasItems = false;
xmin = ymin = INT_MAX;
xmax = ymax = INT_MIN;
EDA_RECT area;
// Check segments, dimensions, texts, and fiducials
for( EDA_ITEM* PtStruct = m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() )
for( BOARD_ITEM* item = m_Drawings; item != NULL; item = item->Next() )
{
switch( PtStruct->Type() )
{
case TYPE_DRAWSEGMENT:
{
DRAWSEGMENT* ptr;
ptr = (DRAWSEGMENT*) PtStruct;
d = (ptr->m_Width / 2) + 1;
if( aBoardEdgesOnly && ptr->GetLayer() != EDGE_N )
break;
if( ptr->m_Shape == S_CIRCLE )
{
cx = ptr->m_Start.x; cy = ptr->m_Start.y;
rayon = (int) hypot( (double) ( ptr->m_End.x - cx ),
(double) ( ptr->m_End.y - cy ) );
rayon += d;
xmin = MIN( xmin, cx - rayon );
ymin = MIN( ymin, cy - rayon );
xmax = MAX( xmax, cx + rayon );
ymax = MAX( ymax, cy + rayon );
hasItems = true;
}
else
{
cx = MIN( ptr->m_Start.x, ptr->m_End.x );
cy = MIN( ptr->m_Start.y, ptr->m_End.y );
xmin = MIN( xmin, cx - d );
ymin = MIN( ymin, cy - d );
cx = MAX( ptr->m_Start.x, ptr->m_End.x );
cy = MAX( ptr->m_Start.y, ptr->m_End.y );
xmax = MAX( xmax, cx + d );
ymax = MAX( ymax, cy + d );
hasItems = true;
}
break;
}
case TYPE_DIMENSION:
{
if( aBoardEdgesOnly )
break;
EDA_RECT rect = ((DIMENSION*) PtStruct)->GetBoundingBox();
xmin = MIN( xmin, rect.GetX() );
ymin = MIN( ymin, rect.GetY() );
xmax = MAX( xmax, rect.GetRight() );
ymax = MAX( ymax, rect.GetBottom() );
hasItems = true;
break;
}
case TYPE_TEXTE:
{
if( aBoardEdgesOnly )
break;
EDA_RECT rect = ((TEXTE_PCB*) PtStruct)->GetTextBox( -1 );
xmin = MIN( xmin, rect.GetX() );
ymin = MIN( ymin, rect.GetY() );
xmax = MAX( xmax, rect.GetRight() );
ymax = MAX( ymax, rect.GetBottom() );
hasItems = true;
break;
}
case TYPE_MIRE:
{
if( aBoardEdgesOnly )
break;
if( aBoardEdgesOnly && item->Type() != TYPE_DRAWSEGMENT && item->GetLayer() != EDGE_N )
continue;
EDA_RECT rect = ((DIMENSION*) PtStruct)->GetBoundingBox();
xmin = MIN( xmin, rect.GetX() );
ymin = MIN( ymin, rect.GetY() );
xmax = MAX( xmax, rect.GetRight() );
ymax = MAX( ymax, rect.GetBottom() );
hasItems = true;
break;
}
default:
break;
}
if( !hasItems )
area = item->GetBoundingBox();
else
area.Merge( item->GetBoundingBox() );
hasItems = true;
}
if( !aBoardEdgesOnly )
......@@ -856,41 +782,30 @@ bool BOARD::ComputeBoundingBox( bool aBoardEdgesOnly )
// Check modules
for( MODULE* module = m_Modules; module; module = module->Next() )
{
EDA_RECT bBox = module->GetBoundingBox();
xmin = MIN( xmin, bBox.GetX() );
ymin = MIN( ymin, bBox.GetY() );
xmax = MAX( xmax, bBox.GetRight() );
ymax = MAX( ymax, bBox.GetBottom() );
if( !hasItems )
area = module->GetBoundingBox();
else
area.Merge( module->GetBoundingBox() );
hasItems = true;
}
// Check tracks
for( TRACK* track = m_Track; track; track = track->Next() )
{
d = ( track->m_Width / 2 ) + 1;
cx = MIN( track->m_Start.x, track->m_End.x );
cy = MIN( track->m_Start.y, track->m_End.y );
xmin = MIN( xmin, cx - d );
ymin = MIN( ymin, cy - d );
cx = MAX( track->m_Start.x, track->m_End.x );
cy = MAX( track->m_Start.y, track->m_End.y );
xmax = MAX( xmax, cx + d );
ymax = MAX( ymax, cy + d );
if( !hasItems )
area = track->GetBoundingBox();
else
area.Merge( track->GetBoundingBox() );
hasItems = true;
}
// Check segment zones
for( TRACK* track = m_Zone; track; track = track->Next() )
{
d = ( track->m_Width / 2 ) + 1;
cx = MIN( track->m_Start.x, track->m_End.x );
cy = MIN( track->m_Start.y, track->m_End.y );
xmin = MIN( xmin, cx - d );
ymin = MIN( ymin, cy - d );
cx = MAX( track->m_Start.x, track->m_End.x );
cy = MAX( track->m_Start.y, track->m_End.y );
xmax = MAX( xmax, cx + d );
ymax = MAX( ymax, cy + d );
if( !hasItems )
area = track->GetBoundingBox();
else
area.Merge( track->GetBoundingBox() );
hasItems = true;
}
......@@ -898,11 +813,12 @@ bool BOARD::ComputeBoundingBox( bool aBoardEdgesOnly )
for( unsigned int i = 0; i < m_ZoneDescriptorList.size(); i++ )
{
ZONE_CONTAINER* aZone = m_ZoneDescriptorList[i];
EDA_RECT bBox = aZone->GetBoundingBox();
xmin = MIN( xmin, bBox.GetX() );
ymin = MIN( ymin, bBox.GetY() );
xmax = MAX( xmax, bBox.GetRight() );
ymax = MAX( ymax, bBox.GetBottom() );
if( !hasItems )
area = aZone->GetBoundingBox();
else
area.Merge( aZone->GetBoundingBox() );
area.Merge( aZone->GetBoundingBox() );
hasItems = true;
}
}
......@@ -911,23 +827,20 @@ bool BOARD::ComputeBoundingBox( bool aBoardEdgesOnly )
{
if( m_PcbFrame->m_Draw_Sheet_Ref )
{
xmin = ymin = 0;
xmax = m_PcbFrame->GetScreen()->ReturnPageSize().x;
ymax = m_PcbFrame->GetScreen()->ReturnPageSize().y;
area.SetOrigin( 0, 0 );
area.SetEnd( m_PcbFrame->GetScreen()->ReturnPageSize().x,
m_PcbFrame->GetScreen()->ReturnPageSize().y );
}
else
{
xmin = -m_PcbFrame->GetScreen()->ReturnPageSize().x / 2;
ymin = -m_PcbFrame->GetScreen()->ReturnPageSize().y / 2;
xmax = m_PcbFrame->GetScreen()->ReturnPageSize().x / 2;
ymax = m_PcbFrame->GetScreen()->ReturnPageSize().y / 2;
area.SetOrigin( -m_PcbFrame->GetScreen()->ReturnPageSize().x / 2,
-m_PcbFrame->GetScreen()->ReturnPageSize().y / 2 );
area.SetEnd( m_PcbFrame->GetScreen()->ReturnPageSize().x / 2,
m_PcbFrame->GetScreen()->ReturnPageSize().y / 2 );
}
}
m_BoundaryBox.SetX( xmin );
m_BoundaryBox.SetY( ymin );
m_BoundaryBox.SetWidth( xmax - xmin );
m_BoundaryBox.SetHeight( ymax - ymin );
m_BoundaryBox = area;
return hasItems;
}
......
......@@ -623,94 +623,10 @@ int MODULE::ReadDescr( LINE_READER* aReader )
}
/* Update the bounding rectangle of the module
*
* The bounding box includes outlines and pads, but not the fields.
* The rectangle is:
* for orientation 0
* coordinates relative to the module anchor.
*/
void MODULE::Set_Rectangle_Encadrement()
{
int width;
int cx, cy, uxf, uyf, rayon;
int xmax, ymax;
int xmin, ymin;
/* Initial coordinates of the module has a nonzero limit value. */
xmin = ymin = -250;
xmax = ymax = 250;
for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings.GetFirst();
edge; edge = edge->Next() )
{
if( edge->Type() != TYPE_EDGE_MODULE )
continue;
width = edge->m_Width / 2;
switch( edge->m_Shape )
{
case S_ARC:
case S_CIRCLE:
{
cx = edge->m_Start0.x;
cy = edge->m_Start0.y; // center
uxf = edge->m_End0.x;
uyf = edge->m_End0.y;
rayon = (int) hypot( (double) ( cx - uxf ), (double) ( cy - uyf ) );
rayon += width;
xmin = MIN( xmin, cx - rayon );
ymin = MIN( ymin, cy - rayon );
xmax = MAX( xmax, cx + rayon );
ymax = MAX( ymax, cy + rayon );
break;
}
case S_SEGMENT:
xmin = MIN( xmin, edge->m_Start0.x - width );
xmin = MIN( xmin, edge->m_End0.x - width );
ymin = MIN( ymin, edge->m_Start0.y - width );
ymin = MIN( ymin, edge->m_End0.y - width );
xmax = MAX( xmax, edge->m_Start0.x + width );
xmax = MAX( xmax, edge->m_End0.x + width );
ymax = MAX( ymax, edge->m_Start0.y + width );
ymax = MAX( ymax, edge->m_End0.y + width );
break;
case S_POLYGON:
{
std::vector<wxPoint> polyPoints = edge->GetPolyPoints();
for( unsigned ii = 0; ii < polyPoints.size(); ii++ )
{
wxPoint pt = polyPoints[ii];
xmin = MIN( xmin, (pt.x - width) );
ymin = MIN( ymin, (pt.y - width) );
xmax = MAX( xmax, (pt.x + width) );
ymax = MAX( ymax, (pt.y + width) );
}
break;
}
}
}
/* Pads: find the min and max coordinates and update the bounding box.
*/
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
rayon = pad->m_ShapeMaxRadius;
cx = pad->m_Pos0.x;
cy = pad->m_Pos0.y;
xmin = MIN( xmin, cx - rayon );
ymin = MIN( ymin, cy - rayon );
xmax = MAX( xmax, cx + rayon );
ymax = MAX( ymax, cy + rayon );
}
m_BoundaryBox.m_Pos.x = xmin;
m_BoundaryBox.m_Pos.y = ymin;
m_BoundaryBox.SetWidth( xmax - xmin );
m_BoundaryBox.SetHeight( ymax - ymin );
m_BoundaryBox = GetFootPrintRect();
m_Surface = ABS( (double) m_BoundaryBox.GetWidth() * m_BoundaryBox.GetHeight() );
}
......@@ -723,60 +639,27 @@ EDA_RECT MODULE::GetFootPrintRect() const
area.Inflate( 500 ); // Give a min size
for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings.GetFirst(); edge; edge = edge->Next() )
{
if( edge->Type() != TYPE_EDGE_MODULE ) // Should not occur
continue;
area.Merge( edge->GetBoundingBox() );
}
if( edge->Type() == TYPE_TEXTE_MODULE )
area.Merge( edge->GetBoundingBox() );
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
area.Merge( pad->GetBoundingBox() );
}
return area;
}
/* Equivalent to Module::Set_Rectangle_Encadrement() but in board coordinates:
* Updates the module bounding box on the board
* The rectangle is the rectangle with outlines and pads, but not the fields
* Also updates the surface (.M_Surface) module.
*/
void MODULE::SetRectangleExinscrit()
{
m_RealBoundaryBox = GetFootPrintRect();
m_Surface = ABS( (double) m_RealBoundaryBox.GetWidth() * m_RealBoundaryBox.GetHeight() );
}
/**
* Function GetBoundingBox
* returns the full bounding box of this Footprint, including fields
* Mainly used to redraw the screen area occupied by the footprint
*/
EDA_RECT MODULE::GetBoundingBox() const
{
EDA_RECT area = GetFootPrintRect();
// Calculate extended area including text field:
EDA_RECT text_area;
text_area = m_Reference->GetBoundingBox();
area.Merge( text_area );
text_area = m_Value->GetBoundingBox();
area.Merge( text_area );
area.Merge( m_Reference->GetBoundingBox() );
area.Merge( m_Value->GetBoundingBox() );
for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings.GetFirst(); edge; edge = edge->Next() )
{
if( edge->Type() != TYPE_TEXTE_MODULE )
continue;
text_area = ( (TEXTE_MODULE*) edge )->GetBoundingBox();
area.Merge( text_area );
}
if( edge->Type() == TYPE_TEXTE_MODULE )
area.Merge( edge->GetBoundingBox() );
// Add the Clearance shape size: (shape around the pads when the
// clearance is shown. Not optimized, but the draw cost is small
......@@ -866,49 +749,30 @@ void MODULE::DisplayInfo( EDA_DRAW_FRAME* frame )
}
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
* @param refPos A wxPoint to test
* @return bool - true if a hit, else false
*/
bool MODULE::HitTest( const wxPoint& refPos )
bool MODULE::HitTest( const wxPoint& aRefPos )
{
/* Calculation of the cursor coordinate relative to module */
wxPoint pos = refPos - m_Pos;
RotatePoint( &pos, -m_Orient );
/* Check if cursor is in the rectangle. */
if( m_BoundaryBox.Contains( pos ) )
if( m_BoundaryBox.Contains( aRefPos ) )
return true;
return false;
}
/**
* Function HitTest (overlaid)
* tests if the given EDA_RECT intersect the bounds of this object.
* @param refArea : the given EDA_RECT
* @return bool - true if a hit, else false
*/
bool MODULE::HitTest( EDA_RECT& refArea )
bool MODULE::HitTest( EDA_RECT& aRefArea )
{
bool is_out_of_box = false;
if( m_BoundaryBox.m_Pos.x < aRefArea.GetX() )
return false;
if( m_BoundaryBox.m_Pos.y < aRefArea.GetY() )
return false;
SetRectangleExinscrit();
if( m_BoundaryBox.GetRight() > aRefArea.GetRight() )
return false;
if( m_RealBoundaryBox.m_Pos.x < refArea.GetX() )
is_out_of_box = true;
if( m_RealBoundaryBox.m_Pos.y < refArea.GetY() )
is_out_of_box = true;
if( m_RealBoundaryBox.GetRight() > refArea.GetRight() )
is_out_of_box = true;
if( m_RealBoundaryBox.GetBottom() > refArea.GetBottom() )
is_out_of_box = true;
if( m_BoundaryBox.GetBottom() > aRefArea.GetBottom() )
return false;
return is_out_of_box ? false : true;
return true;
}
......
......@@ -58,9 +58,7 @@ public:
* routing. */
int m_ModuleStatus; /* For autoplace: flags (LOCKED,
* AUTOPLACED) */
EDA_RECT m_BoundaryBox; /* Bounding box coordinates relatives
* to the anchor, orient 0*/
EDA_RECT m_RealBoundaryBox; /* Bounding box : coordinates on board,
EDA_RECT m_BoundaryBox; /* Bounding box : coordinates on board,
* real orientation */
int m_PadNum; // Pad count
int m_AltPadNum; /* Pad with netcode > 0 (active pads)
......@@ -115,31 +113,25 @@ public:
* void Add( BOARD_ITEM* aBoardItem, bool doInsert = true );
*/
/**
* Function Set_Rectangle_Encadrement
* calculates the bounding box for orient 0 at origin = module anchor)
* calculates the bounding box in board coordinates.
*/
void Set_Rectangle_Encadrement();
/**
* Function SetRectangleExinscrit
* Calculates the real bounding box according to the board position,
* and real orientation and also calculates the area value (used in
* automatic placement)
*/
void SetRectangleExinscrit();
/**
* Function GetFootPrintRect()
* Returns the area of the module footprint excluding any text.
* @return EDA_RECT - The rectangle containing the footprint.
*/
EDA_RECT GetFootPrintRect() const;
/**
* Function GetBoundingBox
* returns the bounding box of this Footprint
* Mainly used to redraw the screen area occupied by the footprint
* returns the bounding box of this
* tootprint. Mainly used to redraw the screen area occupied by
* the footprint.
* @return EDA_RECT - The rectangle containing the footprint and texts.
*/
EDA_RECT GetBoundingBox() const;
......@@ -261,19 +253,19 @@ public:
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
* @param refPos A wxPoint to test
* @return bool - true if a hit, else false
* @param aRefPos is a wxPoint to test.
* @return bool - true if a hit, else false.
*/
bool HitTest( const wxPoint& refPos );
bool HitTest( const wxPoint& aRefPos );
/**
* Function HitTest (overlaid)
* tests if the given EDA_RECT intersect the bounds of this object.
* @param refArea : the given EDA_RECT
* @return bool - true if a hit, else false
* @param aRefArea is the given EDA_RECT.
* @return bool - true if a hit, else false.
*/
bool HitTest( EDA_RECT& refArea );
bool HitTest( EDA_RECT& aRefArea );
/**
* Function GetReference
......
......@@ -135,6 +135,8 @@ public:
virtual BITMAP_DEF GetMenuImage() const { return add_text_xpm; }
virtual EDA_RECT GetBoundingBox() const { return GetTextBox(); };
#if defined(DEBUG)
/**
* Function Show
......
......@@ -209,13 +209,9 @@ MODULE* Locate_Prefered_Module( BOARD* aPcb, const wxPoint& aPosition, int aActi
/* Test of minimum size to choosing the best candidate. */
int offx = pt_module->m_BoundaryBox.m_Size.x / 2 +
pt_module->m_BoundaryBox.m_Pos.x +
pt_module->m_Pos.x;
int offy = pt_module->m_BoundaryBox.m_Size.y / 2
+ pt_module->m_BoundaryBox.m_Pos.y
+ pt_module->m_Pos.y;
EDA_RECT bb = pt_module->GetFootPrintRect();
int offx = bb.GetX() + bb.GetWidth() / 2;
int offy = bb.GetY() + bb.GetHeight() / 2;
//off x & offy point to the middle of the box.
int dist = abs( aPosition.x - offx ) + abs( aPosition.y - offy );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment