Commit 5f01f123 authored by jean-pierre charras's avatar jean-pierre charras

All: GetBoundingBox returns now a const EDA_RECT.

Pcbnew: Code cleaning and bug fix in autoplace functions
Dialog exchange footprints has now a separate button to update the .cmp file, only on request.
parent 78670eeb
...@@ -532,7 +532,7 @@ double EDA_RECT::GetArea() const ...@@ -532,7 +532,7 @@ double EDA_RECT::GetArea() const
/* Calculate the bounding box of this, when rotated /* Calculate the bounding box of this, when rotated
*/ */
EDA_RECT EDA_RECT::GetBoundingBoxRotated( wxPoint aRotCenter, double aAngle ) const EDA_RECT EDA_RECT::GetBoundingBoxRotated( wxPoint aRotCenter, double aAngle )
{ {
wxPoint corners[4]; wxPoint corners[4];
......
...@@ -484,7 +484,7 @@ void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf ...@@ -484,7 +484,7 @@ void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf
} }
EDA_RECT LIB_ARC::GetBoundingBox() const const EDA_RECT LIB_ARC::GetBoundingBox() const
{ {
int minX, minY, maxX, maxY, angleStart, angleEnd; int minX, minY, maxX, maxY, angleStart, angleEnd;
EDA_RECT rect; EDA_RECT rect;
......
...@@ -104,7 +104,7 @@ public: ...@@ -104,7 +104,7 @@ public:
bool HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ); bool HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform );
EDA_RECT GetBoundingBox() const; const EDA_RECT GetBoundingBox() const; // Virtual
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ); void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
......
...@@ -378,7 +378,7 @@ bool LIB_BEZIER::HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTra ...@@ -378,7 +378,7 @@ bool LIB_BEZIER::HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTra
} }
EDA_RECT LIB_BEZIER::GetBoundingBox() const const EDA_RECT LIB_BEZIER::GetBoundingBox() const
{ {
EDA_RECT rect; EDA_RECT rect;
int xmin, xmax, ymin, ymax; int xmin, xmax, ymin, ymax;
......
...@@ -76,7 +76,7 @@ public: ...@@ -76,7 +76,7 @@ public:
bool HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTransform ); bool HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTransform );
EDA_RECT GetBoundingBox() const; const EDA_RECT GetBoundingBox() const; // Virtual
bool Inside( EDA_RECT& aRect ) const; bool Inside( EDA_RECT& aRect ) const;
......
...@@ -251,7 +251,7 @@ void LIB_CIRCLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& ...@@ -251,7 +251,7 @@ void LIB_CIRCLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
} }
EDA_RECT LIB_CIRCLE::GetBoundingBox() const const EDA_RECT LIB_CIRCLE::GetBoundingBox() const
{ {
EDA_RECT rect; EDA_RECT rect;
......
...@@ -67,7 +67,7 @@ public: ...@@ -67,7 +67,7 @@ public:
int GetPenSize( ) const; int GetPenSize( ) const;
EDA_RECT GetBoundingBox() const; const EDA_RECT GetBoundingBox() const; // Virtual
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ); void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
......
...@@ -260,7 +260,7 @@ public: ...@@ -260,7 +260,7 @@ public:
/** /**
* @return the boundary box for this, in library coordinates * @return the boundary box for this, in library coordinates
*/ */
virtual EDA_RECT GetBoundingBox() const { return EDA_ITEM::GetBoundingBox(); } virtual const EDA_RECT GetBoundingBox() const { return EDA_ITEM::GetBoundingBox(); }
/** /**
* Function GetMsgPanelInfo * Function GetMsgPanelInfo
......
...@@ -524,7 +524,7 @@ wxString LIB_FIELD::GetFullText( int unit ) ...@@ -524,7 +524,7 @@ wxString LIB_FIELD::GetFullText( int unit )
} }
EDA_RECT LIB_FIELD::GetBoundingBox() const const EDA_RECT LIB_FIELD::GetBoundingBox() const
{ {
/* Y coordinates for LIB_ITEMS are bottom to top, so we must invert the Y position when /* Y coordinates for LIB_ITEMS are bottom to top, so we must invert the Y position when
* calling GetTextBox() that works using top to bottom Y axis orientation. * calling GetTextBox() that works using top to bottom Y axis orientation.
......
...@@ -165,7 +165,7 @@ public: ...@@ -165,7 +165,7 @@ public:
return (m_Attributs & TEXT_NO_VISIBLE) == 0 ? true : false; return (m_Attributs & TEXT_NO_VISIBLE) == 0 ? true : false;
} }
EDA_RECT GetBoundingBox() const; const EDA_RECT GetBoundingBox() const; // Virtual
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ); void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
......
...@@ -1869,7 +1869,7 @@ void LIB_PIN::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) ...@@ -1869,7 +1869,7 @@ void LIB_PIN::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
} }
EDA_RECT LIB_PIN::GetBoundingBox() const const EDA_RECT LIB_PIN::GetBoundingBox() const
{ {
LIB_COMPONENT* entry = (LIB_COMPONENT*) m_Parent; LIB_COMPONENT* entry = (LIB_COMPONENT*) m_Parent;
EDA_RECT bbox; EDA_RECT bbox;
......
...@@ -139,7 +139,7 @@ public: ...@@ -139,7 +139,7 @@ public:
bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation ); bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation );
EDA_RECT GetBoundingBox() const; const EDA_RECT GetBoundingBox() const; // Virtual
/** /**
* Function ReturnPinEndPoint * Function ReturnPinEndPoint
......
...@@ -353,7 +353,7 @@ bool LIB_POLYLINE::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& ...@@ -353,7 +353,7 @@ bool LIB_POLYLINE::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM&
} }
EDA_RECT LIB_POLYLINE::GetBoundingBox() const const EDA_RECT LIB_POLYLINE::GetBoundingBox() const
{ {
EDA_RECT rect; EDA_RECT rect;
int xmin, xmax, ymin, ymax; int xmin, xmax, ymin, ymax;
......
...@@ -78,7 +78,7 @@ public: ...@@ -78,7 +78,7 @@ public:
bool HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ); bool HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform );
EDA_RECT GetBoundingBox() const; const EDA_RECT GetBoundingBox() const; // Virtual
int GetPenSize( ) const; int GetPenSize( ) const;
......
...@@ -256,7 +256,7 @@ void LIB_RECTANGLE::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) ...@@ -256,7 +256,7 @@ void LIB_RECTANGLE::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
} }
EDA_RECT LIB_RECTANGLE::GetBoundingBox() const const EDA_RECT LIB_RECTANGLE::GetBoundingBox() const
{ {
EDA_RECT rect; EDA_RECT rect;
......
...@@ -71,7 +71,7 @@ public: ...@@ -71,7 +71,7 @@ public:
int GetPenSize( ) const; int GetPenSize( ) const;
EDA_RECT GetBoundingBox() const; const EDA_RECT GetBoundingBox() const; // Virtual
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ); void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
......
...@@ -430,7 +430,7 @@ void LIB_TEXT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) ...@@ -430,7 +430,7 @@ void LIB_TEXT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
} }
EDA_RECT LIB_TEXT::GetBoundingBox() const const EDA_RECT LIB_TEXT::GetBoundingBox() const
{ {
/* Y coordinates for LIB_ITEMS are bottom to top, so we must invert the Y position when /* Y coordinates for LIB_ITEMS are bottom to top, so we must invert the Y position when
* calling GetTextBox() that works using top to bottom Y axis orientation. * calling GetTextBox() that works using top to bottom Y axis orientation.
......
...@@ -96,7 +96,7 @@ public: ...@@ -96,7 +96,7 @@ public:
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ); void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
EDA_RECT GetBoundingBox() const; const EDA_RECT GetBoundingBox() const; // virtual
void Rotate(); void Rotate();
......
...@@ -176,7 +176,7 @@ bool SCH_BITMAP::Load( LINE_READER& aLine, wxString& aErrorMsg ) ...@@ -176,7 +176,7 @@ bool SCH_BITMAP::Load( LINE_READER& aLine, wxString& aErrorMsg )
} }
EDA_RECT SCH_BITMAP::GetBoundingBox() const const EDA_RECT SCH_BITMAP::GetBoundingBox() const
{ {
EDA_RECT rect = m_Image->GetBoundingBox(); EDA_RECT rect = m_Image->GetBoundingBox();
......
...@@ -90,7 +90,7 @@ public: ...@@ -90,7 +90,7 @@ public:
*/ */
wxSize GetSize() const; wxSize GetSize() const;
EDA_RECT GetBoundingBox() const; const EDA_RECT GetBoundingBox() const; // Virtual
void SwapData( SCH_ITEM* aItem ); void SwapData( SCH_ITEM* aItem );
......
...@@ -153,7 +153,7 @@ bool SCH_BUS_ENTRY_BASE::Load( LINE_READER& aLine, wxString& aErrorMsg, ...@@ -153,7 +153,7 @@ bool SCH_BUS_ENTRY_BASE::Load( LINE_READER& aLine, wxString& aErrorMsg,
} }
EDA_RECT SCH_BUS_ENTRY_BASE::GetBoundingBox() const const EDA_RECT SCH_BUS_ENTRY_BASE::GetBoundingBox() const
{ {
EDA_RECT box; EDA_RECT box;
......
...@@ -76,7 +76,7 @@ public: ...@@ -76,7 +76,7 @@ public:
static bool Load( LINE_READER& aLine, wxString& aErrorMsg, SCH_ITEM **out ); static bool Load( LINE_READER& aLine, wxString& aErrorMsg, SCH_ITEM **out );
EDA_RECT GetBoundingBox() const; const EDA_RECT GetBoundingBox() const; // Virtual
void Move( const wxPoint& aMoveVector ) void Move( const wxPoint& aMoveVector )
{ {
......
...@@ -1430,7 +1430,7 @@ EDA_RECT SCH_COMPONENT::GetBodyBoundingBox() const ...@@ -1430,7 +1430,7 @@ EDA_RECT SCH_COMPONENT::GetBodyBoundingBox() const
} }
EDA_RECT SCH_COMPONENT::GetBoundingBox() const const EDA_RECT SCH_COMPONENT::GetBoundingBox() const
{ {
EDA_RECT bbox = GetBodyBoundingBox(); EDA_RECT bbox = GetBodyBoundingBox();
for( size_t i = 0; i < m_Fields.size(); i++ ) for( size_t i = 0; i < m_Fields.size(); i++ )
......
...@@ -220,7 +220,7 @@ public: ...@@ -220,7 +220,7 @@ public:
*/ */
void SetTimeStamp( time_t aNewTimeStamp ); void SetTimeStamp( time_t aNewTimeStamp );
EDA_RECT GetBoundingBox() const; const EDA_RECT GetBoundingBox() const; // Virtual
//-----<Fields>----------------------------------------------------------- //-----<Fields>-----------------------------------------------------------
......
...@@ -259,7 +259,7 @@ void SCH_FIELD::SwapData( SCH_ITEM* aItem ) ...@@ -259,7 +259,7 @@ void SCH_FIELD::SwapData( SCH_ITEM* aItem )
} }
EDA_RECT SCH_FIELD::GetBoundingBox() const const EDA_RECT SCH_FIELD::GetBoundingBox() const
{ {
SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent; SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent;
int linewidth = ( m_Thickness == 0 ) ? GetDefaultLineThickness() : m_Thickness; int linewidth = ( m_Thickness == 0 ) ? GetDefaultLineThickness() : m_Thickness;
......
...@@ -100,7 +100,7 @@ public: ...@@ -100,7 +100,7 @@ public:
void Place( SCH_EDIT_FRAME* frame, wxDC* DC ); void Place( SCH_EDIT_FRAME* frame, wxDC* DC );
EDA_RECT GetBoundingBox() const; const EDA_RECT GetBoundingBox() const; // Virtual
/** /**
* Function IsVoid * Function IsVoid
......
...@@ -98,7 +98,7 @@ bool SCH_JUNCTION::Load( LINE_READER& aLine, wxString& aErrorMsg ) ...@@ -98,7 +98,7 @@ bool SCH_JUNCTION::Load( LINE_READER& aLine, wxString& aErrorMsg )
} }
EDA_RECT SCH_JUNCTION::GetBoundingBox() const const EDA_RECT SCH_JUNCTION::GetBoundingBox() const
{ {
EDA_RECT rect; EDA_RECT rect;
......
...@@ -55,7 +55,7 @@ public: ...@@ -55,7 +55,7 @@ public:
void SwapData( SCH_ITEM* aItem ); void SwapData( SCH_ITEM* aItem );
EDA_RECT GetBoundingBox() const; const EDA_RECT GetBoundingBox() const; // Virtual
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ); GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR );
......
...@@ -116,7 +116,7 @@ void SCH_LINE::Show( int nestLevel, std::ostream& os ) const ...@@ -116,7 +116,7 @@ void SCH_LINE::Show( int nestLevel, std::ostream& os ) const
#endif #endif
EDA_RECT SCH_LINE::GetBoundingBox() const const EDA_RECT SCH_LINE::GetBoundingBox() const
{ {
int width = 25; int width = 25;
......
...@@ -76,7 +76,7 @@ public: ...@@ -76,7 +76,7 @@ public:
void SetEndPoint( const wxPoint& aPosition ) { m_end = aPosition; } void SetEndPoint( const wxPoint& aPosition ) { m_end = aPosition; }
EDA_RECT GetBoundingBox() const; const EDA_RECT GetBoundingBox() const; // Virtual
/** /**
* Function GetLength * Function GetLength
......
...@@ -151,7 +151,7 @@ bool SCH_MARKER::Matches( wxFindReplaceData& aSearchData, wxPoint * aFindLocatio ...@@ -151,7 +151,7 @@ bool SCH_MARKER::Matches( wxFindReplaceData& aSearchData, wxPoint * aFindLocatio
* object, and the units should be in the pcb or schematic coordinate system. * object, and the units should be in the pcb or schematic coordinate system.
* It is OK to overestimate the size by a few counts. * It is OK to overestimate the size by a few counts.
*/ */
EDA_RECT SCH_MARKER::GetBoundingBox() const const EDA_RECT SCH_MARKER::GetBoundingBox() const
{ {
return GetBoundingBoxMarker(); return GetBoundingBoxMarker();
} }
......
...@@ -72,7 +72,7 @@ public: ...@@ -72,7 +72,7 @@ public:
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
EDA_RECT GetBoundingBox() const; EDA_RECT const GetBoundingBox() const; // Virtual
// Geometric transforms (used in block operations): // Geometric transforms (used in block operations):
......
...@@ -71,7 +71,7 @@ void SCH_NO_CONNECT::SwapData( SCH_ITEM* aItem ) ...@@ -71,7 +71,7 @@ void SCH_NO_CONNECT::SwapData( SCH_ITEM* aItem )
} }
EDA_RECT SCH_NO_CONNECT::GetBoundingBox() const const EDA_RECT SCH_NO_CONNECT::GetBoundingBox() const
{ {
int delta = ( GetPenSize() + m_size.x ) / 2; int delta = ( GetPenSize() + m_size.x ) / 2;
EDA_RECT box; EDA_RECT box;
......
...@@ -62,7 +62,7 @@ public: ...@@ -62,7 +62,7 @@ public:
bool Load( LINE_READER& aLine, wxString& aErrorMsg ); bool Load( LINE_READER& aLine, wxString& aErrorMsg );
EDA_RECT GetBoundingBox() const; const EDA_RECT GetBoundingBox() const; // Virtual
// Geometric transforms (used in block operations): // Geometric transforms (used in block operations):
......
...@@ -628,7 +628,7 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, ...@@ -628,7 +628,7 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
} }
EDA_RECT SCH_SHEET::GetBoundingBox() const const EDA_RECT SCH_SHEET::GetBoundingBox() const
{ {
wxPoint end; wxPoint end;
EDA_RECT box( m_pos, m_size ); EDA_RECT box( m_pos, m_size );
......
...@@ -398,7 +398,7 @@ public: ...@@ -398,7 +398,7 @@ public:
GR_DRAWMODE aDrawMode, GR_DRAWMODE aDrawMode,
EDA_COLOR_T aColor = UNSPECIFIED_COLOR ); EDA_COLOR_T aColor = UNSPECIFIED_COLOR );
EDA_RECT GetBoundingBox() const; EDA_RECT const GetBoundingBox() const;
/** /**
* Function GetResizePos * Function GetResizePos
......
...@@ -574,7 +574,7 @@ void SCH_TEXT::GetConnectionPoints( vector< wxPoint >& aPoints ) const ...@@ -574,7 +574,7 @@ void SCH_TEXT::GetConnectionPoints( vector< wxPoint >& aPoints ) const
} }
EDA_RECT SCH_TEXT::GetBoundingBox() const const EDA_RECT SCH_TEXT::GetBoundingBox() const
{ {
// We must pass the effective text thickness to GetTextBox // We must pass the effective text thickness to GetTextBox
// when calculating the bounding box // when calculating the bounding box
...@@ -969,7 +969,7 @@ void SCH_LABEL::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset, ...@@ -969,7 +969,7 @@ void SCH_LABEL::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
} }
EDA_RECT SCH_LABEL::GetBoundingBox() const const EDA_RECT SCH_LABEL::GetBoundingBox() const
{ {
int x, y, dx, dy, length, height; int x, y, dx, dy, length, height;
...@@ -1397,7 +1397,7 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const ...@@ -1397,7 +1397,7 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const
} }
EDA_RECT SCH_GLOBALLABEL::GetBoundingBox() const const EDA_RECT SCH_GLOBALLABEL::GetBoundingBox() const
{ {
int x, y, dx, dy, length, height; int x, y, dx, dy, length, height;
...@@ -1663,7 +1663,7 @@ void SCH_HIERLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wx ...@@ -1663,7 +1663,7 @@ void SCH_HIERLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wx
} }
EDA_RECT SCH_HIERLABEL::GetBoundingBox() const const EDA_RECT SCH_HIERLABEL::GetBoundingBox() const
{ {
int x, y, dx, dy, length, height; int x, y, dx, dy, length, height;
......
...@@ -151,7 +151,7 @@ public: ...@@ -151,7 +151,7 @@ public:
virtual void SwapData( SCH_ITEM* aItem ); virtual void SwapData( SCH_ITEM* aItem );
virtual EDA_RECT GetBoundingBox() const; virtual const EDA_RECT GetBoundingBox() const;
virtual bool Save( FILE* aFile ) const; virtual bool Save( FILE* aFile ) const;
...@@ -249,7 +249,7 @@ public: ...@@ -249,7 +249,7 @@ public:
void Rotate( wxPoint aPosition ); void Rotate( wxPoint aPosition );
EDA_RECT GetBoundingBox() const; const EDA_RECT GetBoundingBox() const; // Virtual
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
...@@ -298,7 +298,7 @@ public: ...@@ -298,7 +298,7 @@ public:
bool Load( LINE_READER& aLine, wxString& aErrorMsg ); bool Load( LINE_READER& aLine, wxString& aErrorMsg );
EDA_RECT GetBoundingBox() const; const EDA_RECT GetBoundingBox() const; // Virtual
void CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& aPos ); void CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& aPos );
...@@ -353,7 +353,7 @@ public: ...@@ -353,7 +353,7 @@ public:
bool Load( LINE_READER& aLine, wxString& aErrorMsg ); bool Load( LINE_READER& aLine, wxString& aErrorMsg );
EDA_RECT GetBoundingBox() const; const EDA_RECT GetBoundingBox() const; // Virtual
void MirrorY( int aYaxis_position ); void MirrorY( int aYaxis_position );
......
...@@ -234,7 +234,7 @@ D_CODE* GERBER_DRAW_ITEM::GetDcodeDescr() ...@@ -234,7 +234,7 @@ D_CODE* GERBER_DRAW_ITEM::GetDcodeDescr()
} }
EDA_RECT GERBER_DRAW_ITEM::GetBoundingBox() const const EDA_RECT GERBER_DRAW_ITEM::GetBoundingBox() const
{ {
// return a rectangle which is (pos,dim) in nature. therefore the +1 // return a rectangle which is (pos,dim) in nature. therefore the +1
EDA_RECT bbox( m_Start, wxSize( 1, 1 ) ); EDA_RECT bbox( m_Start, wxSize( 1, 1 ) );
......
...@@ -218,7 +218,7 @@ public: ...@@ -218,7 +218,7 @@ public:
*/ */
D_CODE* GetDcodeDescr(); D_CODE* GetDcodeDescr();
EDA_RECT GetBoundingBox() const; const EDA_RECT GetBoundingBox() const; // Virtual
/* Display on screen: */ /* Display on screen: */
void Draw( EDA_DRAW_PANEL* aPanel, void Draw( EDA_DRAW_PANEL* aPanel,
......
...@@ -283,7 +283,7 @@ public: ...@@ -283,7 +283,7 @@ public:
* useful to calculate bounding box of rotated items, when * useful to calculate bounding box of rotated items, when
* rotation if not k*90 degrees * rotation if not k*90 degrees
*/ */
EDA_RECT GetBoundingBoxRotated( wxPoint aRotCenter, double aAngle ); const EDA_RECT GetBoundingBoxRotated( wxPoint aRotCenter, double aAngle );
}; };
...@@ -476,7 +476,7 @@ public: ...@@ -476,7 +476,7 @@ public:
* system. * system.
* It is OK to overestimate the size by a few counts. * It is OK to overestimate the size by a few counts.
*/ */
virtual EDA_RECT GetBoundingBox() const virtual const EDA_RECT GetBoundingBox() const
{ {
#if defined(DEBUG) #if defined(DEBUG)
printf( "Missing GetBoundingBox()\n" ); printf( "Missing GetBoundingBox()\n" );
......
...@@ -1531,52 +1531,6 @@ public: ...@@ -1531,52 +1531,6 @@ public:
*/ */
void AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ); void AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC );
/**
* Function GetOptimalModulePlacement
* searches for the optimal position of the \a aModule.
*
* @param aModule A pointer to the MODULE object to get the optimal placement.
* @param aDC The device context to draw on.
* @return 1 if placement impossible or 0 if OK.
*/
int GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC );
void GenModuleOnBoard( MODULE* Module );
/**
* Function Compute_Ratsnest_PlaceModule
* displays the module's ratsnest during displacement, and assess the "cost"
* of the position.
*
* The cost is the longest ratsnest distance with penalty for connections
* approaching 45 degrees.
*/
double Compute_Ratsnest_PlaceModule( wxDC* DC );
/**
* Function GenPlaceBoard
* generates board board (component side copper + rating):
* Allocate the memory needed to represent in "bitmap" on the grid
* Current:
* - The size of clearance area of component (the board)
* - The bitmap PENALTIES
* And initialize the cells of the board has
* - Hole in the cells occupied by a segment EDGE
* - CELL_is_ZONE for cell internal contour EDGE (if closed)
*
* Placement surface (board) gives the cells internal to the contour
* PCB, and among the latter the free cells and cells already occupied
*
* The bitmap PENALTIES give cells occupied by the modules,
* Plus a surface penalty related to the number of pads of the module
*
* Bitmap of the penalty is set to 0
* Occupation cell is a 0 leaves
*/
int GenPlaceBoard();
void DrawInfoPlace( wxDC* DC );
// Autorouting: // Autorouting:
int Solve( wxDC* DC, int two_sides ); int Solve( wxDC* DC, int two_sides );
void Reset_Noroutable( wxDC* DC ); void Reset_Noroutable( wxDC* DC );
......
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
#include <pcbcommon.h> #include <pcbcommon.h>
#include <msgpanel.h> #include <msgpanel.h>
#include <protos.h>
#include <autorout.h> #include <autorout.h>
#include <cell.h> #include <cell.h>
#include <colors_selection.h> #include <colors_selection.h>
...@@ -50,6 +49,8 @@ ...@@ -50,6 +49,8 @@
#include <class_track.h> #include <class_track.h>
#include <class_drawsegment.h> #include <class_drawsegment.h>
#include <convert_to_biu.h> #include <convert_to_biu.h>
#include <base_units.h>
#include <protos.h>
#define GAIN 16 #define GAIN 16
...@@ -57,22 +58,22 @@ ...@@ -57,22 +58,22 @@
/* Penalty for guidance given by CntRot90 and CntRot180: /* Penalty for guidance given by CntRot90 and CntRot180:
* graduated from 0 (rotation allowed) to 10 (rotation count null) * graduated from 0 (rotation allowed) to 10 (rotation not allowed)
* the count is increased. * the count is increased.
*/ */
static const double OrientPenality[11] = static const double OrientPenality[11] =
{ {
2.0f, // CntRot = 0 rotation prohibited 2.0, // CntRot = 0 rotation prohibited
1.9f, // CntRot = 1 1.9, // CntRot = 1
1.8f, // CntRot = 2 1.8, // CntRot = 2
1.7f, // CntRot = 3 1.7, // CntRot = 3
1.6f, // CntRot = 4 1.6, // CntRot = 4
1.5f, // CntRot = 5 1.5, // CntRot = 5
1.4f, // CntRot = 5 1.4, // CntRot = 5
1.3f, // CntRot = 7 1.3, // CntRot = 7
1.2f, // CntRot = 8 1.2, // CntRot = 8
1.1f, // CntRot = 9 1.1, // CntRot = 9
1.0f // CntRot = 10 rotation authorized, no penalty 1.0 // CntRot = 10 rotation authorized, no penalty
}; };
// Cell states. // Cell states.
...@@ -81,10 +82,40 @@ static const double OrientPenality[11] = ...@@ -81,10 +82,40 @@ static const double OrientPenality[11] =
static wxPoint CurrPosition; // Current position of the current module placement static wxPoint CurrPosition; // Current position of the current module placement
static bool AutoPlaceShowAll = true;
double MinCout; double MinCout;
/* generates the Routing matrix, used to fing the best placement
* of a footprint.
* Allocate a "bitmap" which is an image of the real board
* the bitmap handles:
* - The free areas
* - penalties (cell not occupied, but near occupied areas)
* - cells occupied by footprints, board cutout ...
*/
int genPlacementRoutingMatrix( BOARD* aBrd, EDA_MSG_PANEL* messagePanel );
/* searches for the optimal position of aModule.
* return 1 if placement impossible or 0 if OK.
*/
static int getOptimalModulePlacement( PCB_EDIT_FRAME* aFrame,
MODULE* aModule, wxDC* aDC );
/*
* Function compute_Ratsnest_PlaceModule
* displays the module's ratsnest during displacement, and assess the "cost"
* of the position.
*
* The cost is the longest ratsnest distance with penalty for connections
* approaching 45 degrees.
*/
static double compute_Ratsnest_PlaceModule( BOARD* aBrd );
/* Place a footprint on the Routing matrix.
*/
void genModuleOnRoutingMatrix( MODULE* Module );
static void drawInfoPlace( BOARD* aBrd, wxDC* DC );
static int TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide ); static int TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide );
static void CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1, static void CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1,
...@@ -103,6 +134,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) ...@@ -103,6 +134,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
// Undo: init list // Undo: init list
PICKED_ITEMS_LIST newList; PICKED_ITEMS_LIST newList;
newList.m_Status = UR_CHANGED; newList.m_Status = UR_CHANGED;
ITEM_PICKER picker( NULL, UR_CHANGED ); ITEM_PICKER picker( NULL, UR_CHANGED );
...@@ -127,12 +159,14 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) ...@@ -127,12 +159,14 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
break; break;
case PLACE_ALL: case PLACE_ALL:
if( !IsOK( this, _( "Footprints NOT LOCKED will be moved" ) ) ) if( !IsOK( this, _( "Footprints NOT LOCKED will be moved" ) ) )
return; return;
break; break;
case PLACE_INCREMENTAL: case PLACE_INCREMENTAL:
if( !IsOK( this, _( "Footprints NOT PLACED will be moved" ) ) ) if( !IsOK( this, _( "Footprints NOT PLACED will be moved" ) ) )
return; return;
...@@ -146,11 +180,11 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) ...@@ -146,11 +180,11 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
RoutingMatrix.m_GridRouting = (int) GetScreen()->GetGridSize().x; RoutingMatrix.m_GridRouting = (int) GetScreen()->GetGridSize().x;
// Ensure Board.m_GridRouting has a reasonable value: // Ensure Board.m_GridRouting has a reasonable value:
if( RoutingMatrix.m_GridRouting < 10*IU_PER_MILS ) if( RoutingMatrix.m_GridRouting < 10 * IU_PER_MILS )
RoutingMatrix.m_GridRouting = 10*IU_PER_MILS; // Min value = 1/1000 inch RoutingMatrix.m_GridRouting = 10 * IU_PER_MILS; // Min value = 1/100 inch
// Compute module parameters used in auto place // Compute module parameters used in auto place
if( GenPlaceBoard() == 0 ) if( genPlacementRoutingMatrix( GetBoard(), m_messagePanel ) == 0 )
return; return;
int moduleCount = 0; int moduleCount = 0;
...@@ -163,6 +197,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) ...@@ -163,6 +197,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
switch( place_mode ) switch( place_mode )
{ {
case PLACE_1_MODULE: case PLACE_1_MODULE:
if( currModule == Module ) if( currModule == Module )
{ {
// Module will be placed, add to undo. // Module will be placed, add to undo.
...@@ -202,6 +237,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) ...@@ -202,6 +237,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
break; break;
case PLACE_INCREMENTAL: case PLACE_INCREMENTAL:
if( Module->IsLocked() ) if( Module->IsLocked() )
{ {
Module->SetIsPlaced( false ); Module->SetIsPlaced( false );
...@@ -227,7 +263,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) ...@@ -227,7 +263,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
} }
else else
{ {
GenModuleOnBoard( Module ); genModuleOnRoutingMatrix( Module );
} }
} }
...@@ -242,13 +278,13 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) ...@@ -242,13 +278,13 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
while( ( Module = PickModule( this, DC ) ) != NULL ) while( ( Module = PickModule( this, DC ) ) != NULL )
{ {
// Display some info about activity, module placement can take a while: // Display some info about activity, module placement can take a while:
msg.Printf( _("Place module %d of %d"), cnt, moduleCount ); msg.Printf( _( "Place module %d of %d" ), cnt, moduleCount );
SetStatusText( msg ); SetStatusText( msg );
// Display fill area of interest, barriers, penalties. // Display fill area of interest, barriers, penalties.
DrawInfoPlace( DC ); drawInfoPlace( GetBoard(), DC );
error = GetOptimalModulePlacement( Module, DC ); error = getOptimalModulePlacement( this, Module, DC );
double BestScore = MinCout; double BestScore = MinCout;
PosOK = CurrPosition; PosOK = CurrPosition;
...@@ -263,7 +299,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) ...@@ -263,7 +299,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
int Angle_Rot_Module = 1800; int Angle_Rot_Module = 1800;
Rotate_Module( DC, Module, Angle_Rot_Module, false ); Rotate_Module( DC, Module, Angle_Rot_Module, false );
Module->CalculateBoundingBox(); Module->CalculateBoundingBox();
error = GetOptimalModulePlacement( Module, DC ); error = getOptimalModulePlacement( this, Module, DC );
MinCout *= OrientPenality[ii]; MinCout *= OrientPenality[ii];
if( BestScore > MinCout ) // This orientation is best. if( BestScore > MinCout ) // This orientation is best.
...@@ -288,7 +324,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) ...@@ -288,7 +324,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
{ {
int Angle_Rot_Module = 900; int Angle_Rot_Module = 900;
Rotate_Module( DC, Module, Angle_Rot_Module, false ); Rotate_Module( DC, Module, Angle_Rot_Module, false );
error = GetOptimalModulePlacement( Module, DC ); error = getOptimalModulePlacement( this, Module, DC );
MinCout *= OrientPenality[ii]; MinCout *= OrientPenality[ii];
if( BestScore > MinCout ) // This orientation is best. if( BestScore > MinCout ) // This orientation is best.
...@@ -313,7 +349,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) ...@@ -313,7 +349,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
{ {
int Angle_Rot_Module = 2700; int Angle_Rot_Module = 2700;
Rotate_Module( DC, Module, Angle_Rot_Module, false ); Rotate_Module( DC, Module, Angle_Rot_Module, false );
error = GetOptimalModulePlacement( Module, DC ); error = getOptimalModulePlacement( this, Module, DC );
MinCout *= OrientPenality[ii]; MinCout *= OrientPenality[ii];
if( BestScore > MinCout ) // This orientation is best. if( BestScore > MinCout ) // This orientation is best.
...@@ -344,7 +380,7 @@ end_of_tst: ...@@ -344,7 +380,7 @@ end_of_tst:
Module->CalculateBoundingBox(); Module->CalculateBoundingBox();
GenModuleOnBoard( Module ); genModuleOnRoutingMatrix( Module );
Module->SetIsPlaced( true ); Module->SetIsPlaced( true );
Module->SetNeedsPlaced( false ); Module->SetNeedsPlaced( false );
} }
...@@ -369,7 +405,7 @@ end_of_tst: ...@@ -369,7 +405,7 @@ end_of_tst:
} }
void PCB_EDIT_FRAME::DrawInfoPlace( wxDC* DC ) void drawInfoPlace( BOARD* aBrd, wxDC* DC )
{ {
int ii, jj; int ii, jj;
EDA_COLOR_T color; EDA_COLOR_T color;
...@@ -402,41 +438,41 @@ void PCB_EDIT_FRAME::DrawInfoPlace( wxDC* DC ) ...@@ -402,41 +438,41 @@ void PCB_EDIT_FRAME::DrawInfoPlace( wxDC* DC )
color = LIGHTGREEN; color = LIGHTGREEN;
else // Display the filling and keep out regions. else // Display the filling and keep out regions.
{ {
if( RoutingMatrix.GetDist( ii, jj, TOP ) || if( RoutingMatrix.GetDist( ii, jj, TOP )
RoutingMatrix.GetDist( ii, jj, BOTTOM ) ) || RoutingMatrix.GetDist( ii, jj, BOTTOM ) )
color = DARKGRAY; color = DARKGRAY;
} }
GRPutPixel( m_canvas->GetClipBox(), DC, ox, oy, color ); GRPutPixel( NULL, DC, ox, oy, color );
} }
} }
} }
int PCB_EDIT_FRAME::GenPlaceBoard() int genPlacementRoutingMatrix( BOARD* aBrd, EDA_MSG_PANEL* messagePanel )
{ {
wxString msg; wxString msg;
RoutingMatrix.UnInitRoutingMatrix(); RoutingMatrix.UnInitRoutingMatrix();
EDA_RECT bbox = GetBoard()->ComputeBoundingBox( true ); EDA_RECT bbox = aBrd->ComputeBoundingBox( true );
if( bbox.GetWidth() == 0 || bbox.GetHeight() == 0 ) if( bbox.GetWidth() == 0 || bbox.GetHeight() == 0 )
{ {
DisplayError( this, _( "No PCB edge found, unknown board size!" ) ); DisplayError( NULL, _( "No PCB edge found, unknown board size!" ) );
return 0; return 0;
} }
RoutingMatrix.ComputeMatrixSize( GetBoard(), true ); RoutingMatrix.ComputeMatrixSize( aBrd, true );
int nbCells = RoutingMatrix.m_Ncols * RoutingMatrix.m_Nrows; int nbCells = RoutingMatrix.m_Ncols * RoutingMatrix.m_Nrows;
m_messagePanel->EraseMsgBox(); messagePanel->EraseMsgBox();
msg.Printf( wxT( "%d" ), RoutingMatrix.m_Ncols ); msg.Printf( wxT( "%d" ), RoutingMatrix.m_Ncols );
m_messagePanel->SetMessage( 1, _( "Cols" ), msg, GREEN ); messagePanel->SetMessage( 1, _( "Cols" ), msg, GREEN );
msg.Printf( wxT( "%d" ), RoutingMatrix.m_Nrows ); msg.Printf( wxT( "%d" ), RoutingMatrix.m_Nrows );
m_messagePanel->SetMessage( 7, _( "Lines" ), msg, GREEN ); messagePanel->SetMessage( 7, _( "Lines" ), msg, GREEN );
msg.Printf( wxT( "%d" ), nbCells ); msg.Printf( wxT( "%d" ), nbCells );
m_messagePanel->SetMessage( 14, _( "Cells." ), msg, YELLOW ); messagePanel->SetMessage( 14, _( "Cells." ), msg, YELLOW );
// Choose the number of board sides. // Choose the number of board sides.
RoutingMatrix.m_RoutingLayersCount = 2; RoutingMatrix.m_RoutingLayersCount = 2;
...@@ -445,7 +481,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard() ...@@ -445,7 +481,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
// Display memory usage. // Display memory usage.
msg.Printf( wxT( "%d" ), RoutingMatrix.m_MemSize / 1024 ); msg.Printf( wxT( "%d" ), RoutingMatrix.m_MemSize / 1024 );
m_messagePanel->SetMessage( 24, wxT( "Mem(Kb)" ), msg, CYAN ); messagePanel->SetMessage( 24, wxT( "Mem(Kb)" ), msg, CYAN );
g_Route_Layer_BOTTOM = LAYER_N_FRONT; g_Route_Layer_BOTTOM = LAYER_N_FRONT;
...@@ -461,7 +497,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard() ...@@ -461,7 +497,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
TmpSegm.SetNet( -1 ); TmpSegm.SetNet( -1 );
TmpSegm.SetWidth( RoutingMatrix.m_GridRouting / 2 ); TmpSegm.SetWidth( RoutingMatrix.m_GridRouting / 2 );
EDA_ITEM* PtStruct = GetBoard()->m_Drawings; EDA_ITEM* PtStruct = aBrd->m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{ {
...@@ -509,19 +545,21 @@ int PCB_EDIT_FRAME::GenPlaceBoard() ...@@ -509,19 +545,21 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
} }
/* Place module on board. /* Place module on Routing matrix.
*/ */
void PCB_EDIT_FRAME::GenModuleOnBoard( MODULE* Module ) void genModuleOnRoutingMatrix( MODULE* Module )
{ {
int ox, oy, fx, fy; int ox, oy, fx, fy;
int marge = RoutingMatrix.m_GridRouting / 2;
int layerMask; int layerMask;
D_PAD* Pad; D_PAD* Pad;
ox = Module->GetBoundingBox().GetX() - marge; EDA_RECT fpBBox = Module->GetBoundingBox();
fx = Module->GetBoundingBox().GetRight() + marge;
oy = Module->GetBoundingBox().GetY() - marge; fpBBox.Inflate( RoutingMatrix.m_GridRouting / 2 );
fy = Module->GetBoundingBox().GetBottom() + marge; ox = fpBBox.GetX();
fx = fpBBox.GetRight();
oy = fpBBox.GetY();
fy = fpBBox.GetBottom();
if( ox < RoutingMatrix.m_BrdBox.GetX() ) if( ox < RoutingMatrix.m_BrdBox.GetX() )
ox = RoutingMatrix.m_BrdBox.GetX(); ox = RoutingMatrix.m_BrdBox.GetX();
...@@ -558,63 +596,62 @@ void PCB_EDIT_FRAME::GenModuleOnBoard( MODULE* Module ) ...@@ -558,63 +596,62 @@ void PCB_EDIT_FRAME::GenModuleOnBoard( MODULE* Module )
TraceFilledRectangle( ox, oy, fx, fy, layerMask, TraceFilledRectangle( ox, oy, fx, fy, layerMask,
CELL_is_MODULE, WRITE_OR_CELL ); CELL_is_MODULE, WRITE_OR_CELL );
int trackWidth = GetBoard()->m_NetClasses.GetDefault()->GetTrackWidth(); // Trace pads + clearance areas.
int clearance = GetBoard()->m_NetClasses.GetDefault()->GetClearance();
// Trace pads and surface safely.
marge = trackWidth + clearance;
for( Pad = Module->Pads(); Pad != NULL; Pad = Pad->Next() ) for( Pad = Module->Pads(); Pad != NULL; Pad = Pad->Next() )
{ {
::PlacePad( Pad, CELL_is_MODULE, marge, WRITE_OR_CELL ); int margin = (RoutingMatrix.m_GridRouting / 2) + Pad->GetClearance();
::PlacePad( Pad, CELL_is_MODULE, margin, WRITE_OR_CELL );
} }
// Trace clearance. // Trace clearance.
marge = ( RoutingMatrix.m_GridRouting * Module->GetPadCount() ) / GAIN; int margin = ( RoutingMatrix.m_GridRouting * Module->GetPadCount() ) / GAIN;
CreateKeepOutRectangle( ox, oy, fx, fy, marge, KEEP_OUT_MARGIN, layerMask ); CreateKeepOutRectangle( ox, oy, fx, fy, margin, KEEP_OUT_MARGIN, layerMask );
} }
int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC ) int getOptimalModulePlacement( PCB_EDIT_FRAME* aFrame, MODULE* aModule, wxDC* aDC )
{ {
int cx, cy;
int ox, oy, fx, fy; // occupying part of the module focuses on the cursor
int error = 1; int error = 1;
int showRat = 0;
wxPoint LastPosOK; wxPoint LastPosOK;
double mincout, cout, Score; double min_cost, curr_cost, Score;
int keepOut;
bool TstOtherSide; bool TstOtherSide;
bool showRats = g_Show_Module_Ratsnest; bool showRats = g_Show_Module_Ratsnest;
BOARD* brd = aFrame->GetBoard();
g_Show_Module_Ratsnest = false; g_Show_Module_Ratsnest = false;
SetMsgPanel( aModule ); brd->m_Status_Pcb &= ~RATSNEST_ITEM_LOCAL_OK;
aFrame->SetMsgPanel( aModule );
LastPosOK = RoutingMatrix.m_BrdBox.GetOrigin();
wxPoint mod_pos = aModule->GetPosition();
EDA_RECT fpBBox = aModule->GetFootprintRect();
LastPosOK.x = RoutingMatrix.m_BrdBox.GetX(); // Move fpBBox to have the footprint position at (0,0)
LastPosOK.y = RoutingMatrix.m_BrdBox.GetY(); fpBBox.Move( -mod_pos );
wxPoint fpBBoxOrg = fpBBox.GetOrigin();
cx = aModule->GetPosition().x; // Calculate the limit of the footprint position, relative
cy = aModule->GetPosition().y; // to the routing matrix area
ox = aModule->GetBoundingBox().GetX() - cx; wxPoint xylimit = RoutingMatrix.m_BrdBox.GetEnd() - fpBBox.GetEnd();
fx = aModule->GetBoundingBox().GetWidth() + ox;
oy = aModule->GetBoundingBox().GetY() - cy;
fy = aModule->GetBoundingBox().GetHeight() + oy;
CurrPosition.x = RoutingMatrix.m_BrdBox.GetX() - ox; wxPoint initialPos = RoutingMatrix.m_BrdBox.GetOrigin() - fpBBoxOrg;
CurrPosition.y = RoutingMatrix.m_BrdBox.GetY() - oy;
// Module placement on grid. // Stay on grid.
CurrPosition.x -= CurrPosition.x % RoutingMatrix.m_GridRouting; initialPos.x -= initialPos.x % RoutingMatrix.m_GridRouting;
CurrPosition.y -= CurrPosition.y % RoutingMatrix.m_GridRouting; initialPos.y -= initialPos.y % RoutingMatrix.m_GridRouting;
g_Offset_Module.x = cx - CurrPosition.x; CurrPosition = initialPos;
g_Offset_Module.y = cy - CurrPosition.y;
GetBoard()->m_Status_Pcb &= ~RATSNEST_ITEM_LOCAL_OK;
/* Test pads, a printed circuit with components of the 2 dimensions // Undraw the current footprint
* can become a component on opposite side if there is at least 1 patch g_Offset_Module = wxPoint( 0, 0 );
* appearing on the other side. DrawModuleOutlines( aFrame->GetCanvas(), aDC, aModule );
g_Offset_Module = mod_pos - CurrPosition;
/* Examine pads, and set TstOtherSide to true if a footprint
* has at least 1 pad through.
*/ */
TstOtherSide = false; TstOtherSide = false;
...@@ -636,102 +673,75 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC ) ...@@ -636,102 +673,75 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC )
} }
} }
DrawModuleOutlines( m_canvas, aDC, aModule ); // Draw the initial bounding box position
fpBBox.SetOrigin( fpBBoxOrg + CurrPosition );
GRRect( aFrame->GetCanvas()->GetClipBox(), aDC, fpBBox, 0, BROWN );
mincout = -1.0; min_cost = -1.0;
SetStatusText( wxT( "Score ??, pos ??" ) ); aFrame->SetStatusText( wxT( "Score ??, pos ??" ) );
for( ; CurrPosition.x < RoutingMatrix.m_BrdBox.GetRight() - fx; for( ; CurrPosition.x < xylimit.x; CurrPosition.x += RoutingMatrix.m_GridRouting )
CurrPosition.x += RoutingMatrix.m_GridRouting )
{ {
wxYield(); wxYield();
if( m_canvas->GetAbortRequest() ) if( aFrame->GetCanvas()->GetAbortRequest() )
{ {
if( IsOK( this, _( "OK to abort?" ) ) ) if( IsOK( aFrame, _( "OK to abort?" ) ) )
return ESC; return ESC;
else else
m_canvas->SetAbortRequest( false ); aFrame->GetCanvas()->SetAbortRequest( false );
} }
cx = aModule->GetPosition().x; CurrPosition.y = initialPos.y;
cy = aModule->GetPosition().y;
aModule->GetBoundingBox().SetX( ox + CurrPosition.x );
aModule->GetBoundingBox().SetY( oy + CurrPosition.y );
DrawModuleOutlines( m_canvas, aDC, aModule );
g_Offset_Module.x = cx - CurrPosition.x;
CurrPosition.y = RoutingMatrix.m_BrdBox.GetY() - oy;
// Placement on grid. for( ; CurrPosition.y < xylimit.y; CurrPosition.y += RoutingMatrix.m_GridRouting )
CurrPosition.y -= CurrPosition.y % RoutingMatrix.m_GridRouting;
DrawModuleOutlines( m_canvas, aDC, aModule );
for( ; CurrPosition.y < RoutingMatrix.m_BrdBox.GetBottom() - fy;
CurrPosition.y += RoutingMatrix.m_GridRouting )
{ {
#ifndef USE_WX_OVERLAY #ifndef USE_WX_OVERLAY
// Erase traces. // Erase traces.
DrawModuleOutlines( m_canvas, aDC, aModule ); GRRect( aFrame->GetCanvas()->GetClipBox(), aDC, fpBBox, 0, BROWN );
if( showRat )
Compute_Ratsnest_PlaceModule( aDC );
#endif #endif
showRat = 0;
aModule->GetBoundingBox().SetX( ox + CurrPosition.x );
aModule->GetBoundingBox().SetY( oy + CurrPosition.y );
g_Offset_Module.y = cy - CurrPosition.y; fpBBox.SetOrigin( fpBBoxOrg + CurrPosition );
g_Offset_Module = mod_pos - CurrPosition;
#ifndef USE_WX_OVERLAY #ifndef USE_WX_OVERLAY
DrawModuleOutlines( m_canvas, aDC, aModule ); // Draw at new place
GRRect( aFrame->GetCanvas()->GetClipBox(), aDC, fpBBox, 0, BROWN );
#endif #endif
keepOut = TstModuleOnBoard( GetBoard(), aModule, TstOtherSide ); int keepOutCost = TstModuleOnBoard( brd, aModule, TstOtherSide );
if( keepOut >= 0 ) // i.e. if the module can be put here if( keepOutCost >= 0 ) // i.e. if the module can be put here
{ {
error = 0; error = 0;
build_ratsnest_module( aModule ); aFrame->build_ratsnest_module( aModule );
cout = Compute_Ratsnest_PlaceModule( aDC ); curr_cost = compute_Ratsnest_PlaceModule( brd );
showRat = 1; Score = curr_cost + keepOutCost;
Score = cout + keepOut;
if( (mincout >= Score ) || (mincout < 0 ) ) if( (min_cost >= Score ) || (min_cost < 0 ) )
{ {
LastPosOK = CurrPosition; LastPosOK = CurrPosition;
mincout = Score; min_cost = Score;
wxString msg; wxString msg;
msg.Printf( wxT( "Score %g, pos %3.4g, %3.4g" ), msg.Printf( wxT( "Score %g, pos %s, %s" ),
mincout, min_cost,
(double) LastPosOK.x / 10000, ::CoordinateToString( LastPosOK.x ),
(double) LastPosOK.y / 10000 ); ::CoordinateToString( LastPosOK.y ) );
SetStatusText( msg ); aFrame->SetStatusText( msg );
} }
} }
if( showRat )
Compute_Ratsnest_PlaceModule( aDC );
showRat = 0;
} }
} }
DrawModuleOutlines( m_canvas, aDC, aModule ); // erasing the last traces // erasing the last traces
GRRect( aFrame->GetCanvas()->GetClipBox(), aDC, fpBBox, 0, BROWN );
g_Show_Module_Ratsnest = showRats; g_Show_Module_Ratsnest = showRats;
if( showRat )
Compute_Ratsnest_PlaceModule( aDC );
// Regeneration of the modified variable. // Regeneration of the modified variable.
aModule->GetBoundingBox().SetX( ox + cx );
aModule->GetBoundingBox().SetY( oy + cy );
CurrPosition = LastPosOK; CurrPosition = LastPosOK;
GetBoard()->m_Status_Pcb &= ~( RATSNEST_ITEM_LOCAL_OK | LISTE_PAD_OK ); brd->m_Status_Pcb &= ~( RATSNEST_ITEM_LOCAL_OK | LISTE_PAD_OK );
MinCout = mincout; MinCout = min_cost;
return error; return error;
} }
...@@ -740,29 +750,29 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC ) ...@@ -740,29 +750,29 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC )
* - is a free zone (except OCCUPED_By_MODULE returns) * - is a free zone (except OCCUPED_By_MODULE returns)
* - is on the working surface of the board (otherwise returns OUT_OF_BOARD) * - is on the working surface of the board (otherwise returns OUT_OF_BOARD)
* *
* Returns 0 if OK * Returns OUT_OF_BOARD, or, OCCUPED_By_MODULE or 0 if OK
*/ */
int TstRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int side ) int TstRectangle( BOARD* Pcb, const EDA_RECT& aRect, int side )
{ {
int row, col; EDA_RECT rect = aRect;
int row_min, row_max, col_min, col_max;
unsigned int data;
ux0 -= Pcb->GetBoundingBox().GetX(); rect.Inflate( RoutingMatrix.m_GridRouting / 2 );
uy0 -= Pcb->GetBoundingBox().GetY();
ux1 -= Pcb->GetBoundingBox().GetX();
uy1 -= Pcb->GetBoundingBox().GetY();
row_max = uy1 / RoutingMatrix.m_GridRouting; wxPoint start = rect.GetOrigin();
col_max = ux1 / RoutingMatrix.m_GridRouting; wxPoint end = rect.GetEnd();
row_min = uy0 / RoutingMatrix.m_GridRouting;
if( uy0 > row_min * RoutingMatrix.m_GridRouting ) start -= RoutingMatrix.m_BrdBox.GetOrigin();
row_min++; end -= RoutingMatrix.m_BrdBox.GetOrigin();
col_min = ux0 / RoutingMatrix.m_GridRouting; int row_min = start.y / RoutingMatrix.m_GridRouting;
int row_max = end.y / RoutingMatrix.m_GridRouting;
int col_min = start.x / RoutingMatrix.m_GridRouting;
int col_max = end.x / RoutingMatrix.m_GridRouting;
if( ux0 > col_min * RoutingMatrix.m_GridRouting ) if( start.y > row_min * RoutingMatrix.m_GridRouting )
row_min++;
if( start.x > col_min * RoutingMatrix.m_GridRouting )
col_min++; col_min++;
if( row_min < 0 ) if( row_min < 0 )
...@@ -777,16 +787,16 @@ int TstRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int side ) ...@@ -777,16 +787,16 @@ int TstRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int side )
if( col_max >= ( RoutingMatrix.m_Ncols - 1 ) ) if( col_max >= ( RoutingMatrix.m_Ncols - 1 ) )
col_max = RoutingMatrix.m_Ncols - 1; col_max = RoutingMatrix.m_Ncols - 1;
for( row = row_min; row <= row_max; row++ ) for( int row = row_min; row <= row_max; row++ )
{ {
for( col = col_min; col <= col_max; col++ ) for( int col = col_min; col <= col_max; col++ )
{ {
data = RoutingMatrix.GetCell( row, col, side ); unsigned int data = RoutingMatrix.GetCell( row, col, side );
if( ( data & CELL_is_ZONE ) == 0 ) if( ( data & CELL_is_ZONE ) == 0 )
return OUT_OF_BOARD; return OUT_OF_BOARD;
if( data & CELL_is_MODULE ) if( (data & CELL_is_MODULE) )
return OCCUPED_By_MODULE; return OCCUPED_By_MODULE;
} }
} }
...@@ -796,30 +806,26 @@ int TstRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int side ) ...@@ -796,30 +806,26 @@ int TstRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int side )
/* Calculates and returns the clearance area of the rectangular surface /* Calculates and returns the clearance area of the rectangular surface
* (ux, ux .. y0, y1): * aRect):
* (Sum of cells in terms of distance) * (Sum of cells in terms of distance)
*/ */
unsigned int CalculateKeepOutArea( int ux0, int uy0, int ux1, int uy1, int side ) unsigned int CalculateKeepOutArea( const EDA_RECT& aRect, int side )
{ {
int row, col; wxPoint start = aRect.GetOrigin();
int row_min, row_max, col_min, col_max; wxPoint end = aRect.GetEnd();
unsigned int keepOut;
ux0 -= RoutingMatrix.m_BrdBox.GetX(); start -= RoutingMatrix.m_BrdBox.GetOrigin();
uy0 -= RoutingMatrix.m_BrdBox.GetY(); end -= RoutingMatrix.m_BrdBox.GetOrigin();
ux1 -= RoutingMatrix.m_BrdBox.GetX();
uy1 -= RoutingMatrix.m_BrdBox.GetY();
row_max = uy1 / RoutingMatrix.m_GridRouting; int row_min = start.y / RoutingMatrix.m_GridRouting;
col_max = ux1 / RoutingMatrix.m_GridRouting; int row_max = end.y / RoutingMatrix.m_GridRouting;
row_min = uy0 / RoutingMatrix.m_GridRouting; int col_min = start.x / RoutingMatrix.m_GridRouting;
int col_max = end.x / RoutingMatrix.m_GridRouting;
if( uy0 > row_min * RoutingMatrix.m_GridRouting ) if( start.y > row_min * RoutingMatrix.m_GridRouting )
row_min++; row_min++;
col_min = ux0 / RoutingMatrix.m_GridRouting; if( start.x > col_min * RoutingMatrix.m_GridRouting )
if( ux0 > col_min * RoutingMatrix.m_GridRouting )
col_min++; col_min++;
if( row_min < 0 ) if( row_min < 0 )
...@@ -834,98 +840,89 @@ unsigned int CalculateKeepOutArea( int ux0, int uy0, int ux1, int uy1, int side ...@@ -834,98 +840,89 @@ unsigned int CalculateKeepOutArea( int ux0, int uy0, int ux1, int uy1, int side
if( col_max >= ( RoutingMatrix.m_Ncols - 1 ) ) if( col_max >= ( RoutingMatrix.m_Ncols - 1 ) )
col_max = RoutingMatrix.m_Ncols - 1; col_max = RoutingMatrix.m_Ncols - 1;
keepOut = 0; unsigned int keepOutCost = 0;
for( row = row_min; row <= row_max; row++ ) for( int row = row_min; row <= row_max; row++ )
{ {
for( col = col_min; col <= col_max; col++ ) for( int col = col_min; col <= col_max; col++ )
{ {
keepOut += RoutingMatrix.GetDist( row, col, side ); // RoutingMatrix.GetDist returns the "cost" of the cell
// at position (row, col)
// in autoplace this is the cost of the cell, if it is
// inside aRect
keepOutCost += RoutingMatrix.GetDist( row, col, side );
} }
} }
return keepOut; return keepOutCost;
} }
/* Test if the module can be placed on the board. /* Test if the module can be placed on the board.
* Returns the value TstRectangle(). * Returns the value TstRectangle().
* Module is known by its rectangle * Module is known by its bounding box
*/ */
int TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide ) int TstModuleOnBoard( BOARD* Pcb, MODULE* aModule, bool TstOtherSide )
{ {
int ox, oy, fx, fy; int side = TOP;
int error, marge, side, otherside; int otherside = BOTTOM;
side = TOP; otherside = BOTTOM;
if( Module->GetLayer() == LAYER_N_BACK ) if( aModule->GetLayer() == LAYER_N_BACK )
{ {
side = BOTTOM; otherside = TOP; side = BOTTOM; otherside = TOP;
} }
ox = Module->GetBoundingBox().GetX(); EDA_RECT fpBBox = aModule->GetFootprintRect();
fx = Module->GetBoundingBox().GetRight(); fpBBox.Move( -g_Offset_Module );
oy = Module->GetBoundingBox().GetY();
fy = Module->GetBoundingBox().GetBottom();
error = TstRectangle( Pcb, ox, oy, fx, fy, side ); int diag = TstRectangle( Pcb, fpBBox, side );
if( error < 0 ) if( diag < 0 )
return error; return diag;
if( TstOtherSide ) if( TstOtherSide )
{ {
error = TstRectangle( Pcb, ox, oy, fx, fy, otherside ); diag = TstRectangle( Pcb, fpBBox, otherside );
if( error < 0 ) if( diag < 0 )
return error; return diag;
} }
marge = ( RoutingMatrix.m_GridRouting * Module->GetPadCount() ) / GAIN; int marge = ( RoutingMatrix.m_GridRouting * aModule->GetPadCount() ) / GAIN;
return CalculateKeepOutArea( ox - marge, oy - marge, fx + marge, fy + marge, side ); fpBBox.Inflate( marge );
return CalculateKeepOutArea( fpBBox, side );
} }
double PCB_EDIT_FRAME::Compute_Ratsnest_PlaceModule( wxDC* DC ) double compute_Ratsnest_PlaceModule( BOARD* aBrd )
{ {
double cout, icout; double curr_cost;
wxPoint start; // start point of a ratsnest wxPoint start; // start point of a ratsnest
wxPoint end; // end point of a ratsnest wxPoint end; // end point of a ratsnest
int dx, dy; int dx, dy;
if( ( GetBoard()->m_Status_Pcb & RATSNEST_ITEM_LOCAL_OK ) == 0 ) if( ( aBrd->m_Status_Pcb & RATSNEST_ITEM_LOCAL_OK ) == 0 )
return -1; return -1;
cout = 0; curr_cost = 0;
EDA_COLOR_T color = g_ColorsSettings.GetItemColor(RATSNEST_VISIBLE);
if( AutoPlaceShowAll ) for( unsigned ii = 0; ii < aBrd->m_LocalRatsnest.size(); ii++ )
GRSetDrawMode( DC, GR_XOR );
for( unsigned ii = 0; ii < GetBoard()->m_LocalRatsnest.size(); ii++ )
{ {
RATSNEST_ITEM* pt_local_rats_nest = &GetBoard()->m_LocalRatsnest[ii]; RATSNEST_ITEM* pt_local_rats_nest = &aBrd->m_LocalRatsnest[ii];
if( ( pt_local_rats_nest->m_Status & LOCAL_RATSNEST_ITEM ) ) if( ( pt_local_rats_nest->m_Status & LOCAL_RATSNEST_ITEM ) )
continue; // Skip ratsnest between 2 pads of the current module continue; // Skip ratsnest between 2 pads of the current module
// Skip modules not inside the board area // Skip modules not inside the board area
MODULE * module = pt_local_rats_nest->m_PadEnd->GetParent(); MODULE* module = pt_local_rats_nest->m_PadEnd->GetParent();
if( !RoutingMatrix.m_BrdBox.Contains( module->GetPosition() ) ) if( !RoutingMatrix.m_BrdBox.Contains( module->GetPosition() ) )
continue; continue;
start = pt_local_rats_nest->m_PadStart->GetPosition() - g_Offset_Module; start = pt_local_rats_nest->m_PadStart->GetPosition() - g_Offset_Module;
end = pt_local_rats_nest->m_PadEnd->GetPosition(); end = pt_local_rats_nest->m_PadEnd->GetPosition();
#ifndef USE_WX_OVERLAY
if( AutoPlaceShowAll )
{
GRLine( m_canvas->GetClipBox(), DC, start, end, 0, color );
}
#endif
// Cost of the ratsnest. // Cost of the ratsnest.
dx = end.x - start.x; dx = end.x - start.x;
dy = end.y - start.y; dy = end.y - start.y;
...@@ -942,11 +939,11 @@ double PCB_EDIT_FRAME::Compute_Ratsnest_PlaceModule( wxDC* DC ) ...@@ -942,11 +939,11 @@ double PCB_EDIT_FRAME::Compute_Ratsnest_PlaceModule( wxDC* DC )
// the penalty is max for 45 degrees ratsnests, // the penalty is max for 45 degrees ratsnests,
// and 0 for horizontal or vertical ratsnests. // and 0 for horizontal or vertical ratsnests.
// For Horizontal and Vertical ratsnests, dy = 0; // For Horizontal and Vertical ratsnests, dy = 0;
icout = hypot( dx, dy * 2.0 ); double conn_cost = hypot( dx, dy * 2.0 );
cout += icout; // Total cost = sum of costs of each connection curr_cost += conn_cost; // Total cost = sum of costs of each connection
} }
return cout; return curr_cost;
} }
...@@ -957,8 +954,8 @@ double PCB_EDIT_FRAME::Compute_Ratsnest_PlaceModule( wxDC* DC ) ...@@ -957,8 +954,8 @@ double PCB_EDIT_FRAME::Compute_Ratsnest_PlaceModule( wxDC* DC )
* incremented by value aKeepOut * incremented by value aKeepOut
* Cell outside this rectangle, but inside the rectangle * Cell outside this rectangle, but inside the rectangle
* x0,y0 -marge to x1,y1 + marge are incremented by a decreasing value * x0,y0 -marge to x1,y1 + marge are incremented by a decreasing value
* (aKeepOut ... 0). The decreasing value de pends on the distance to the first rectangle * (aKeepOut ... 0). The decreasing value depends on the distance to the first rectangle
* Therefore the cost is high in rect x0,y0 a x1,y1, and decrease outside this rectangle * Therefore the cost is high in rect x0,y0 to x1,y1, and decrease outside this rectangle
*/ */
void CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1, void CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1,
int marge, int aKeepOut, int aLayerMask ) int marge, int aKeepOut, int aLayerMask )
...@@ -1027,6 +1024,12 @@ void CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1, ...@@ -1027,6 +1024,12 @@ void CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1,
for( col = col_min; col <= col_max; col++ ) for( col = col_min; col <= col_max; col++ )
{ {
// RoutingMatrix Dist map containt the "cost" of the cell
// at position (row, col)
// in autoplace this is the cost of the cell, when
// a footprint overlaps it, near a "master" footprint
// this cost is hight near the "master" footprint
// and decrease with the distance
cgain = 256; cgain = 256;
LocalKeepOut = aKeepOut; LocalKeepOut = aKeepOut;
...@@ -1097,7 +1100,7 @@ static MODULE* PickModule( PCB_EDIT_FRAME* pcbframe, wxDC* DC ) ...@@ -1097,7 +1100,7 @@ static MODULE* PickModule( PCB_EDIT_FRAME* pcbframe, wxDC* DC )
for( ; Module != NULL; Module = Module->Next() ) for( ; Module != NULL; Module = Module->Next() )
{ {
Module->CalculateBoundingBox(); Module->CalculateBoundingBox();
moduleList.push_back(Module); moduleList.push_back( Module );
} }
sort( moduleList.begin(), moduleList.end(), Tri_PlaceModules ); sort( moduleList.begin(), moduleList.end(), Tri_PlaceModules );
...@@ -1182,7 +1185,7 @@ int propagate() ...@@ -1182,7 +1185,7 @@ int propagate()
{ {
int row, col; int row, col;
long current_cell, old_cell_H; long current_cell, old_cell_H;
std::vector< long > pt_cell_V; std::vector<long> pt_cell_V;
int nbpoints = 0; int nbpoints = 0;
#define NO_CELL_ZONE (HOLE | CELL_is_EDGE | CELL_is_ZONE) #define NO_CELL_ZONE (HOLE | CELL_is_EDGE | CELL_is_ZONE)
......
...@@ -2134,7 +2134,7 @@ MODULE* BOARD::GetFootprint( const wxPoint& aPosition, LAYER_NUM aActiveLayer, ...@@ -2134,7 +2134,7 @@ MODULE* BOARD::GetFootprint( const wxPoint& aPosition, LAYER_NUM aActiveLayer,
// Filter non visible modules if requested // Filter non visible modules if requested
if( (!aVisibleOnly) || IsModuleLayerVisible( layer ) ) if( (!aVisibleOnly) || IsModuleLayerVisible( layer ) )
{ {
EDA_RECT bb = pt_module->GetFootPrintRect(); EDA_RECT bb = pt_module->GetFootprintRect();
int offx = bb.GetX() + bb.GetWidth() / 2; int offx = bb.GetX() + bb.GetWidth() / 2;
int offy = bb.GetY() + bb.GetHeight() / 2; int offy = bb.GetY() + bb.GetHeight() / 2;
......
...@@ -857,7 +857,7 @@ public: ...@@ -857,7 +857,7 @@ public:
* as long as the BOARD has not changed. Remember, ComputeBoundingBox()'s * as long as the BOARD has not changed. Remember, ComputeBoundingBox()'s
* aBoardEdgesOnly argument is considered in this return value also. * aBoardEdgesOnly argument is considered in this return value also.
*/ */
EDA_RECT GetBoundingBox() const { return m_BoundingBox; } // override const EDA_RECT GetBoundingBox() const { return m_BoundingBox; } // override
void SetBoundingBox( const EDA_RECT& aBox ) { m_BoundingBox = aBox; } void SetBoundingBox( const EDA_RECT& aBox ) { m_BoundingBox = aBox; }
......
...@@ -446,7 +446,7 @@ bool DIMENSION::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) ...@@ -446,7 +446,7 @@ bool DIMENSION::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy )
} }
EDA_RECT DIMENSION::GetBoundingBox() const const EDA_RECT DIMENSION::GetBoundingBox() const
{ {
EDA_RECT bBox; EDA_RECT bBox;
int xmin, xmax, ymin, ymax; int xmin, xmax, ymin, ymax;
......
...@@ -139,7 +139,8 @@ public: ...@@ -139,7 +139,8 @@ public:
return wxT( "DIMENSION" ); return wxT( "DIMENSION" );
} }
EDA_RECT GetBoundingBox() const; // Virtual function
const EDA_RECT GetBoundingBox() const;
wxString GetSelectMenuText() const; wxString GetSelectMenuText() const;
......
...@@ -360,7 +360,7 @@ void DRAWSEGMENT::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) ...@@ -360,7 +360,7 @@ void DRAWSEGMENT::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
} }
EDA_RECT DRAWSEGMENT::GetBoundingBox() const const EDA_RECT DRAWSEGMENT::GetBoundingBox() const
{ {
EDA_RECT bbox; EDA_RECT bbox;
......
...@@ -168,7 +168,7 @@ public: ...@@ -168,7 +168,7 @@ public:
virtual void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ); virtual void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
virtual EDA_RECT GetBoundingBox() const; virtual const EDA_RECT GetBoundingBox() const;
virtual bool HitTest( const wxPoint& aPosition ); virtual bool HitTest( const wxPoint& aPosition );
......
...@@ -194,7 +194,7 @@ void PCB_TARGET::Flip(const wxPoint& aCentre ) ...@@ -194,7 +194,7 @@ void PCB_TARGET::Flip(const wxPoint& aCentre )
} }
EDA_RECT PCB_TARGET::GetBoundingBox() const const EDA_RECT PCB_TARGET::GetBoundingBox() const
{ {
EDA_RECT bBox; EDA_RECT bBox;
bBox.SetX( m_Pos.x - m_Size/2 ); bBox.SetX( m_Pos.x - m_Size/2 );
......
...@@ -92,7 +92,8 @@ public: ...@@ -92,7 +92,8 @@ public:
*/ */
bool HitTest( const EDA_RECT& aRect, bool aContained = true, int aAccuracy = 0 ) const; bool HitTest( const EDA_RECT& aRect, bool aContained = true, int aAccuracy = 0 ) const;
EDA_RECT GetBoundingBox() const; // Virtual function
const EDA_RECT GetBoundingBox() const;
wxString GetSelectMenuText() const; wxString GetSelectMenuText() const;
......
...@@ -409,12 +409,12 @@ void MODULE::DrawEdgesOnly( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offs ...@@ -409,12 +409,12 @@ void MODULE::DrawEdgesOnly( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offs
void MODULE::CalculateBoundingBox() void MODULE::CalculateBoundingBox()
{ {
m_BoundaryBox = GetFootPrintRect(); m_BoundaryBox = GetFootprintRect();
m_Surface = std::abs( (double) m_BoundaryBox.GetWidth() * m_BoundaryBox.GetHeight() ); m_Surface = std::abs( (double) m_BoundaryBox.GetWidth() * m_BoundaryBox.GetHeight() );
} }
EDA_RECT MODULE::GetFootPrintRect() const EDA_RECT MODULE::GetFootprintRect() const
{ {
EDA_RECT area; EDA_RECT area;
...@@ -433,9 +433,9 @@ EDA_RECT MODULE::GetFootPrintRect() const ...@@ -433,9 +433,9 @@ EDA_RECT MODULE::GetFootPrintRect() const
} }
EDA_RECT MODULE::GetBoundingBox() const const EDA_RECT MODULE::GetBoundingBox() const
{ {
EDA_RECT area = GetFootPrintRect(); EDA_RECT area = GetFootprintRect();
// Calculate extended area including text fields // Calculate extended area including text fields
area.Merge( m_Reference->GetBoundingBox() ); area.Merge( m_Reference->GetBoundingBox() );
......
...@@ -96,13 +96,14 @@ public: ...@@ -96,13 +96,14 @@ public:
void CalculateBoundingBox(); void CalculateBoundingBox();
/** /**
* Function GetFootPrintRect() * Function GetFootprintRect()
* Returns the area of the module footprint excluding any text. * Returns the area of the module footprint excluding any text.
* @return EDA_RECT - The rectangle containing the footprint. * @return EDA_RECT - The rectangle containing the footprint.
*/ */
EDA_RECT GetFootPrintRect() const; EDA_RECT GetFootprintRect() const;
EDA_RECT GetBoundingBox() const; // Virtual function
const EDA_RECT GetBoundingBox() const;
DLIST<D_PAD>& Pads() { return m_Pads; } DLIST<D_PAD>& Pads() { return m_Pads; }
const DLIST<D_PAD>& Pads() const { return m_Pads; } const DLIST<D_PAD>& Pads() const { return m_Pads; }
......
...@@ -119,7 +119,7 @@ int D_PAD::boundingRadius() const ...@@ -119,7 +119,7 @@ int D_PAD::boundingRadius() const
} }
EDA_RECT D_PAD::GetBoundingBox() const const EDA_RECT D_PAD::GetBoundingBox() const
{ {
EDA_RECT area; EDA_RECT area;
wxPoint quadrant1, quadrant2, quadrant3, quadrant4; wxPoint quadrant1, quadrant2, quadrant3, quadrant4;
......
...@@ -392,7 +392,8 @@ public: ...@@ -392,7 +392,8 @@ public:
return wxT( "PAD" ); return wxT( "PAD" );
} }
EDA_RECT GetBoundingBox() const; // Virtual function:
const EDA_RECT GetBoundingBox() const;
/** /**
* Function Compare * Function Compare
......
...@@ -158,7 +158,7 @@ void TEXTE_PCB::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) ...@@ -158,7 +158,7 @@ void TEXTE_PCB::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
aList.push_back( MSG_PANEL_ITEM( _( "Size Y" ), msg, RED ) ); aList.push_back( MSG_PANEL_ITEM( _( "Size Y" ), msg, RED ) );
} }
EDA_RECT TEXTE_PCB::GetBoundingBox() const const EDA_RECT TEXTE_PCB::GetBoundingBox() const
{ {
EDA_RECT rect = GetTextBox( -1, -1 ); EDA_RECT rect = GetTextBox( -1, -1 );
......
...@@ -130,7 +130,8 @@ public: ...@@ -130,7 +130,8 @@ public:
BITMAP_DEF GetMenuImage() const { return add_text_xpm; } BITMAP_DEF GetMenuImage() const { return add_text_xpm; }
EDA_RECT GetBoundingBox() const; // Virtual function
const EDA_RECT GetBoundingBox() const;
EDA_ITEM* Clone() const; EDA_ITEM* Clone() const;
......
...@@ -182,12 +182,12 @@ bool TEXTE_MODULE::HitTest( const wxPoint& aPosition ) ...@@ -182,12 +182,12 @@ bool TEXTE_MODULE::HitTest( const wxPoint& aPosition )
} }
/** /*
* Function GetBoundingBox * Function GetBoundingBox (virtual)
* returns the bounding box of this Text (according to text and footprint * returns the bounding box of this Text (according to text and footprint
* orientation) * orientation)
*/ */
EDA_RECT TEXTE_MODULE::GetBoundingBox() const const EDA_RECT TEXTE_MODULE::GetBoundingBox() const
{ {
double angle = GetDrawRotation(); double angle = GetDrawRotation();
EDA_RECT text_area = GetTextBox( -1, -1 ); EDA_RECT text_area = GetTextBox( -1, -1 );
......
...@@ -123,7 +123,8 @@ public: ...@@ -123,7 +123,8 @@ public:
*/ */
double GetDrawRotation() const; double GetDrawRotation() const;
EDA_RECT GetBoundingBox() const; // Virtual function
const EDA_RECT GetBoundingBox() const;
void SetDrawCoord(); // Set absolute coordinates. void SetDrawCoord(); // Set absolute coordinates.
......
...@@ -310,7 +310,7 @@ STATUS_FLAGS TRACK::IsPointOnEnds( const wxPoint& point, int min_dist ) ...@@ -310,7 +310,7 @@ STATUS_FLAGS TRACK::IsPointOnEnds( const wxPoint& point, int min_dist )
} }
EDA_RECT TRACK::GetBoundingBox() const const EDA_RECT TRACK::GetBoundingBox() const
{ {
// end of track is round, this is its radius, rounded up // end of track is round, this is its radius, rounded up
int radius = ( m_Width + 1 ) / 2; int radius = ( m_Width + 1 ) / 2;
......
...@@ -127,7 +127,8 @@ public: ...@@ -127,7 +127,8 @@ public:
int GetShape() const { return m_Shape; } int GetShape() const { return m_Shape; }
void SetShape( int aShape ) { m_Shape = aShape; } void SetShape( int aShape ) { m_Shape = aShape; }
EDA_RECT GetBoundingBox() const; // Virtual function
const EDA_RECT GetBoundingBox() const;
/** /**
* Function GetBestInsertPoint * Function GetBestInsertPoint
......
...@@ -358,7 +358,7 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel, ...@@ -358,7 +358,7 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel,
} }
EDA_RECT ZONE_CONTAINER::GetBoundingBox() const const EDA_RECT ZONE_CONTAINER::GetBoundingBox() const
{ {
const int PRELOAD = 0x7FFFFFFF; // Biggest integer (32 bits) const int PRELOAD = 0x7FFFFFFF; // Biggest integer (32 bits)
......
...@@ -151,10 +151,10 @@ public: ...@@ -151,10 +151,10 @@ public:
void DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC, void DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC,
GR_DRAWMODE draw_mode = GR_OR ); GR_DRAWMODE draw_mode = GR_OR );
/** Function GetBoundingBox /** Function GetBoundingBox (virtual)
* @return an EDA_RECT that is the bounding box of the zone outline * @return an EDA_RECT that is the bounding box of the zone outline
*/ */
EDA_RECT GetBoundingBox() const; const EDA_RECT GetBoundingBox() const;
int GetClearance( BOARD_CONNECTED_ITEM* aItem = NULL ) const; int GetClearance( BOARD_CONNECTED_ITEM* aItem = NULL ) const;
......
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 8 2012) // C++ code generated with wxFormBuilder (version Nov 6 2013)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
...@@ -22,7 +22,7 @@ DIALOG_EXCHANGE_MODULE_BASE::DIALOG_EXCHANGE_MODULE_BASE( wxWindow* parent, wxWi ...@@ -22,7 +22,7 @@ DIALOG_EXCHANGE_MODULE_BASE::DIALOG_EXCHANGE_MODULE_BASE( wxWindow* parent, wxWi
wxBoxSizer* bLeftSizer; wxBoxSizer* bLeftSizer;
bLeftSizer = new wxBoxSizer( wxVERTICAL ); bLeftSizer = new wxBoxSizer( wxVERTICAL );
m_staticText6 = new wxStaticText( this, wxID_ANY, _("Current Module"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText6 = new wxStaticText( this, wxID_ANY, _("Current footprint"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText6->Wrap( -1 ); m_staticText6->Wrap( -1 );
bLeftSizer->Add( m_staticText6, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); bLeftSizer->Add( m_staticText6, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
...@@ -30,7 +30,7 @@ DIALOG_EXCHANGE_MODULE_BASE::DIALOG_EXCHANGE_MODULE_BASE( wxWindow* parent, wxWi ...@@ -30,7 +30,7 @@ DIALOG_EXCHANGE_MODULE_BASE::DIALOG_EXCHANGE_MODULE_BASE( wxWindow* parent, wxWi
m_OldModule->SetMaxLength( 0 ); m_OldModule->SetMaxLength( 0 );
bLeftSizer->Add( m_OldModule, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); bLeftSizer->Add( m_OldModule, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticText7 = new wxStaticText( this, wxID_ANY, _("Current Value"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText7 = new wxStaticText( this, wxID_ANY, _("Current value"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText7->Wrap( -1 ); m_staticText7->Wrap( -1 );
bLeftSizer->Add( m_staticText7, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); bLeftSizer->Add( m_staticText7, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
...@@ -38,7 +38,7 @@ DIALOG_EXCHANGE_MODULE_BASE::DIALOG_EXCHANGE_MODULE_BASE( wxWindow* parent, wxWi ...@@ -38,7 +38,7 @@ DIALOG_EXCHANGE_MODULE_BASE::DIALOG_EXCHANGE_MODULE_BASE( wxWindow* parent, wxWi
m_OldValue->SetMaxLength( 0 ); m_OldValue->SetMaxLength( 0 );
bLeftSizer->Add( m_OldValue, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); bLeftSizer->Add( m_OldValue, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticText8 = new wxStaticText( this, wxID_ANY, _("New Module"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText8 = new wxStaticText( this, wxID_ANY, _("New footprint"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText8->Wrap( -1 ); m_staticText8->Wrap( -1 );
bLeftSizer->Add( m_staticText8, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); bLeftSizer->Add( m_staticText8, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
...@@ -54,8 +54,8 @@ DIALOG_EXCHANGE_MODULE_BASE::DIALOG_EXCHANGE_MODULE_BASE( wxWindow* parent, wxWi ...@@ -54,8 +54,8 @@ DIALOG_EXCHANGE_MODULE_BASE::DIALOG_EXCHANGE_MODULE_BASE( wxWindow* parent, wxWi
wxString m_SelectionChoices[] = { _("Change module"), _("Change same modules"), _("Ch. same module+value"), _("Change all") }; wxString m_SelectionChoices[] = { _("Change module"), _("Change same modules"), _("Ch. same module+value"), _("Change all") };
int m_SelectionNChoices = sizeof( m_SelectionChoices ) / sizeof( wxString ); int m_SelectionNChoices = sizeof( m_SelectionChoices ) / sizeof( wxString );
m_Selection = new wxRadioBox( this, ID_SELECTION_CLICKED, _("Browse Libs modules"), wxDefaultPosition, wxDefaultSize, m_SelectionNChoices, m_SelectionChoices, 1, wxRA_SPECIFY_COLS ); m_Selection = new wxRadioBox( this, ID_SELECTION_CLICKED, _("Options"), wxDefaultPosition, wxDefaultSize, m_SelectionNChoices, m_SelectionChoices, 1, wxRA_SPECIFY_COLS );
m_Selection->SetSelection( 0 ); m_Selection->SetSelection( 2 );
bMiddleSizer->Add( m_Selection, 0, wxALL, 5 ); bMiddleSizer->Add( m_Selection, 0, wxALL, 5 );
...@@ -65,13 +65,16 @@ DIALOG_EXCHANGE_MODULE_BASE::DIALOG_EXCHANGE_MODULE_BASE( wxWindow* parent, wxWi ...@@ -65,13 +65,16 @@ DIALOG_EXCHANGE_MODULE_BASE::DIALOG_EXCHANGE_MODULE_BASE( wxWindow* parent, wxWi
bRightSizer = new wxBoxSizer( wxVERTICAL ); bRightSizer = new wxBoxSizer( wxVERTICAL );
m_OKbutton = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 ); m_OKbutton = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );
bRightSizer->Add( m_OKbutton, 0, wxALL, 5 ); bRightSizer->Add( m_OKbutton, 0, wxALL|wxEXPAND, 5 );
m_Quitbutton = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 ); m_Quitbutton = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 );
bRightSizer->Add( m_Quitbutton, 0, wxALL, 5 ); bRightSizer->Add( m_Quitbutton, 0, wxALL|wxEXPAND, 5 );
m_buttonCmpList = new wxButton( this, wxID_ANY, _("Rebuild .cmp List"), wxDefaultPosition, wxDefaultSize, 0 );
bRightSizer->Add( m_buttonCmpList, 0, wxALL|wxEXPAND, 5 );
m_Browsebutton = new wxButton( this, wxID_ANY, _("Browse"), wxDefaultPosition, wxDefaultSize, 0 ); m_Browsebutton = new wxButton( this, wxID_ANY, _("Browse"), wxDefaultPosition, wxDefaultSize, 0 );
bRightSizer->Add( m_Browsebutton, 0, wxALL, 5 ); bRightSizer->Add( m_Browsebutton, 0, wxALL|wxEXPAND, 5 );
bUpperSizer->Add( bRightSizer, 0, wxALIGN_CENTER_VERTICAL, 5 ); bUpperSizer->Add( bRightSizer, 0, wxALIGN_CENTER_VERTICAL, 5 );
...@@ -98,6 +101,7 @@ DIALOG_EXCHANGE_MODULE_BASE::DIALOG_EXCHANGE_MODULE_BASE( wxWindow* parent, wxWi ...@@ -98,6 +101,7 @@ DIALOG_EXCHANGE_MODULE_BASE::DIALOG_EXCHANGE_MODULE_BASE( wxWindow* parent, wxWi
m_Selection->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnSelectionClicked ), NULL, this ); m_Selection->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnSelectionClicked ), NULL, this );
m_OKbutton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnOkClick ), NULL, this ); m_OKbutton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnOkClick ), NULL, this );
m_Quitbutton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnQuit ), NULL, this ); m_Quitbutton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnQuit ), NULL, this );
m_buttonCmpList->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::RebuildCmpList ), NULL, this );
m_Browsebutton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::BrowseAndSelectFootprint ), NULL, this ); m_Browsebutton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::BrowseAndSelectFootprint ), NULL, this );
} }
...@@ -107,6 +111,7 @@ DIALOG_EXCHANGE_MODULE_BASE::~DIALOG_EXCHANGE_MODULE_BASE() ...@@ -107,6 +111,7 @@ DIALOG_EXCHANGE_MODULE_BASE::~DIALOG_EXCHANGE_MODULE_BASE()
m_Selection->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnSelectionClicked ), NULL, this ); m_Selection->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnSelectionClicked ), NULL, this );
m_OKbutton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnOkClick ), NULL, this ); m_OKbutton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnOkClick ), NULL, this );
m_Quitbutton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnQuit ), NULL, this ); m_Quitbutton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnQuit ), NULL, this );
m_buttonCmpList->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::RebuildCmpList ), NULL, this );
m_Browsebutton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::BrowseAndSelectFootprint ), NULL, this ); m_Browsebutton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::BrowseAndSelectFootprint ), NULL, this );
} }
...@@ -20,8 +20,10 @@ ...@@ -20,8 +20,10 @@
<property name="path">.</property> <property name="path">.</property>
<property name="precompiled_header"></property> <property name="precompiled_header"></property>
<property name="relative_path">1</property> <property name="relative_path">1</property>
<property name="skip_lua_events">1</property>
<property name="skip_php_events">1</property> <property name="skip_php_events">1</property>
<property name="skip_python_events">1</property> <property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_enum">0</property> <property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property> <property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1"> <object class="Dialog" expanded="1">
...@@ -141,7 +143,7 @@ ...@@ -141,7 +143,7 @@
<property name="gripper">0</property> <property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">Current Module</property> <property name="label">Current footprint</property>
<property name="max_size"></property> <property name="max_size"></property>
<property name="maximize_button">0</property> <property name="maximize_button">0</property>
<property name="maximum_size"></property> <property name="maximum_size"></property>
...@@ -315,7 +317,7 @@ ...@@ -315,7 +317,7 @@
<property name="gripper">0</property> <property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">Current Value</property> <property name="label">Current value</property>
<property name="max_size"></property> <property name="max_size"></property>
<property name="maximize_button">0</property> <property name="maximize_button">0</property>
<property name="maximum_size"></property> <property name="maximum_size"></property>
...@@ -489,7 +491,7 @@ ...@@ -489,7 +491,7 @@
<property name="gripper">0</property> <property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">New Module</property> <property name="label">New footprint</property>
<property name="max_size"></property> <property name="max_size"></property>
<property name="maximize_button">0</property> <property name="maximize_button">0</property>
<property name="maximum_size"></property> <property name="maximum_size"></property>
...@@ -675,7 +677,7 @@ ...@@ -675,7 +677,7 @@
<property name="gripper">0</property> <property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">ID_SELECTION_CLICKED</property> <property name="id">ID_SELECTION_CLICKED</property>
<property name="label">Browse Libs modules</property> <property name="label">Options</property>
<property name="majorDimension">1</property> <property name="majorDimension">1</property>
<property name="max_size"></property> <property name="max_size"></property>
<property name="maximize_button">0</property> <property name="maximize_button">0</property>
...@@ -692,7 +694,7 @@ ...@@ -692,7 +694,7 @@
<property name="pin_button">1</property> <property name="pin_button">1</property>
<property name="pos"></property> <property name="pos"></property>
<property name="resize">Resizable</property> <property name="resize">Resizable</property>
<property name="selection">0</property> <property name="selection">2</property>
<property name="show">1</property> <property name="show">1</property>
<property name="size"></property> <property name="size"></property>
<property name="style">wxRA_SPECIFY_COLS</property> <property name="style">wxRA_SPECIFY_COLS</property>
...@@ -745,7 +747,7 @@ ...@@ -745,7 +747,7 @@
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL</property> <property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxButton" expanded="1"> <object class="wxButton" expanded="1">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
...@@ -833,7 +835,7 @@ ...@@ -833,7 +835,7 @@
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL</property> <property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxButton" expanded="1"> <object class="wxButton" expanded="1">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
...@@ -921,7 +923,95 @@ ...@@ -921,7 +923,95 @@
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL</property> <property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Rebuild .cmp List</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_buttonCmpList</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">RebuildCmpList</event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxButton" expanded="1"> <object class="wxButton" expanded="1">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
......
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 8 2012) // C++ code generated with wxFormBuilder (version Nov 6 2013)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
...@@ -47,6 +47,7 @@ class DIALOG_EXCHANGE_MODULE_BASE : public DIALOG_SHIM ...@@ -47,6 +47,7 @@ class DIALOG_EXCHANGE_MODULE_BASE : public DIALOG_SHIM
wxRadioBox* m_Selection; wxRadioBox* m_Selection;
wxButton* m_OKbutton; wxButton* m_OKbutton;
wxButton* m_Quitbutton; wxButton* m_Quitbutton;
wxButton* m_buttonCmpList;
wxButton* m_Browsebutton; wxButton* m_Browsebutton;
wxStaticText* m_staticTextMsg; wxStaticText* m_staticTextMsg;
wxTextCtrl* m_WinMessages; wxTextCtrl* m_WinMessages;
...@@ -55,6 +56,7 @@ class DIALOG_EXCHANGE_MODULE_BASE : public DIALOG_SHIM ...@@ -55,6 +56,7 @@ class DIALOG_EXCHANGE_MODULE_BASE : public DIALOG_SHIM
virtual void OnSelectionClicked( wxCommandEvent& event ) { event.Skip(); } virtual void OnSelectionClicked( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnQuit( wxCommandEvent& event ) { event.Skip(); } virtual void OnQuit( wxCommandEvent& event ) { event.Skip(); }
virtual void RebuildCmpList( wxCommandEvent& event ) { event.Skip(); }
virtual void BrowseAndSelectFootprint( wxCommandEvent& event ) { event.Skip(); } virtual void BrowseAndSelectFootprint( wxCommandEvent& event ) { event.Skip(); }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2013 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
...@@ -43,11 +43,8 @@ ...@@ -43,11 +43,8 @@
#include <dialog_exchange_modules_base.h> #include <dialog_exchange_modules_base.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
static char* quiet_gcc_4_4_3; // GCC 4.4.3 and next ..
static bool RecreateCmpFile( BOARD * aBrd, const wxString& aFullCmpFileName ); static bool RecreateCmpFile( BOARD * aBrd, const wxString& aFullCmpFileName );
class DIALOG_EXCHANGE_MODULE : public DIALOG_EXCHANGE_MODULE_BASE class DIALOG_EXCHANGE_MODULE : public DIALOG_EXCHANGE_MODULE_BASE
{ {
private: private:
...@@ -64,13 +61,12 @@ private: ...@@ -64,13 +61,12 @@ private:
void OnOkClick( wxCommandEvent& event ); void OnOkClick( wxCommandEvent& event );
void OnQuit( wxCommandEvent& event ); void OnQuit( wxCommandEvent& event );
void BrowseAndSelectFootprint( wxCommandEvent& event ); void BrowseAndSelectFootprint( wxCommandEvent& event );
void RebuildCmpList( wxCommandEvent& event );
void init(); void init();
void ChangeCurrentFootprint(); void ChangeCurrentFootprint();
void ChangeSameFootprints( bool aUseValue ); void ChangeSameFootprints( bool aUseValue);
void ChangeAllFootprints(); void ChangeAllFootprints();
int Maj_ListeCmp( const wxString& aReference, const FPID& aOldFootprintFPID,
const FPID& aNewFootprintFPID, bool aShowError );
bool Change_1_Module( MODULE* aModule, bool Change_1_Module( MODULE* aModule,
const FPID& aNewFootprintFPID, const FPID& aNewFootprintFPID,
PICKED_ITEMS_LIST* aUndoPickList, PICKED_ITEMS_LIST* aUndoPickList,
...@@ -123,6 +119,7 @@ void DIALOG_EXCHANGE_MODULE::init() ...@@ -123,6 +119,7 @@ void DIALOG_EXCHANGE_MODULE::init()
void DIALOG_EXCHANGE_MODULE::OnOkClick( wxCommandEvent& event ) void DIALOG_EXCHANGE_MODULE::OnOkClick( wxCommandEvent& event )
{ {
m_selectionMode = m_Selection->GetSelection(); m_selectionMode = m_Selection->GetSelection();
switch( m_Selection->GetSelection() ) switch( m_Selection->GetSelection() )
{ {
case 0: case 0:
...@@ -146,120 +143,51 @@ void DIALOG_EXCHANGE_MODULE::OnOkClick( wxCommandEvent& event ) ...@@ -146,120 +143,51 @@ void DIALOG_EXCHANGE_MODULE::OnOkClick( wxCommandEvent& event )
void DIALOG_EXCHANGE_MODULE::OnSelectionClicked( wxCommandEvent& event ) void DIALOG_EXCHANGE_MODULE::OnSelectionClicked( wxCommandEvent& event )
{ {
bool enable = true;
switch( m_Selection->GetSelection() ) switch( m_Selection->GetSelection() )
{ {
case 0: case 0:
case 1: case 1:
case 2: case 2:
m_NewModule->Enable( true );
m_Browsebutton->Enable( true );
break; break;
case 3: case 3:
m_NewModule->Enable( false ); enable = false;
m_Browsebutton->Enable( false );
break; break;
} }
m_NewModule->Enable( enable );
m_Browsebutton->Enable( enable );
} }
/* /*
* Updates the file name.CMP (if any) after an exchange module * Rebuild the file name.CMP (if any) after exchanging footprints
* (By command changeMod), if the modules are managed by this file * if the footprint are managed by this file
* * Return false if error
* If ShowError! = 0 displays error message if the file. Cmp is not found.
* Return 1 if error
*/ */
int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& aReference, void DIALOG_EXCHANGE_MODULE::RebuildCmpList( wxCommandEvent& event )
const FPID& aOldFootprintFPID,
const FPID& aNewFootprintFPID,
bool aShowError )
{ {
wxFileName fn; wxFileName fn;
wxFileName tmpFileName;
FILE* FichCmp, * NewFile;
char line[1024];
wxString msg; wxString msg;
if( aOldFootprintFPID == aNewFootprintFPID )
return 0;
// Build CMP file name by changing the extension of NetList filename // Build CMP file name by changing the extension of NetList filename
fn = m_parent->GetBoard()->GetFileName(); fn = m_parent->GetBoard()->GetFileName();
fn.SetExt( ComponentFileExtension ); fn.SetExt( ComponentFileExtension );
FichCmp = wxFopen( fn.GetFullPath(), wxT( "rt" ) ); if( RecreateCmpFile( m_parent->GetBoard(), fn.GetFullPath() ) )
if( FichCmp == NULL )
{
if( aShowError )
{
msg.Printf( _( "file <%s> not found" ), GetChars( fn.GetFullPath() ) );
m_WinMessages->AppendText( msg );
}
return 1;
}
tmpFileName = fn;
tmpFileName.SetExt( wxT( "$$$" ) );
NewFile = wxFopen( tmpFileName.GetFullPath(), wxT( "wt" ) );
if( NewFile == NULL )
{
if( aShowError )
{
msg.Printf( _( "Unable to create file <%s>" ),
GetChars( tmpFileName.GetFullPath() ) );
m_WinMessages->AppendText( msg );
}
return 1;
}
quiet_gcc_4_4_3 = fgets( line, sizeof(line), FichCmp );
fprintf( NewFile, "Cmp-Mod V01 Created by PcbNew date = %s\n", TO_UTF8( DateAndTime() ) );
bool start_descr = false;
while( fgets( line, sizeof(line), FichCmp ) != NULL )
{
if( strnicmp( line, "Reference = ", 9 ) == 0 )
{ {
char buf[1024]; msg.Printf( _( "File '%s' created\n" ),
strcpy( buf, line + 12 ); GetChars( fn.GetFullPath() ) );
strtok( buf, ";\n\r" );
if( stricmp( buf, TO_UTF8( aReference ) ) == 0 )
{
start_descr = true;
}
} }
else
if( (strnicmp( line, "Begin", 5 ) == 0) || (strnicmp( line, "End", 3 ) == 0) )
{ {
start_descr = false; msg.Printf( _( "** Could not create file '%s' ***\n" ),
GetChars( fn.GetFullPath() ) );
} }
if( start_descr && strnicmp( line, "IdModule", 8 ) == 0 )
{
sprintf( line + 8, " = %s;\n", aNewFootprintFPID.Format().c_str() );
msg = wxT( " * in <" ) + fn.GetFullPath() + wxT( ">.\n" );
m_WinMessages->AppendText( msg ); m_WinMessages->AppendText( msg );
start_descr = false;
}
fputs( line, NewFile );
}
fclose( FichCmp );
fclose( NewFile );
wxRemoveFile( fn.GetFullPath() );
wxRenameFile( tmpFileName.GetFullPath(), fn.GetFullPath() );
return 0;
} }
...@@ -401,7 +329,7 @@ void DIALOG_EXCHANGE_MODULE::ChangeAllFootprints() ...@@ -401,7 +329,7 @@ void DIALOG_EXCHANGE_MODULE::ChangeAllFootprints()
if( !IsOK( this, _( "Change ALL modules ?" ) ) ) if( !IsOK( this, _( "Change ALL modules ?" ) ) )
return; return;
/* The change is done from the last module for the routine /* The change is done from the last module because the function
* Change_1_Module () modifies the last module in the list * Change_1_Module () modifies the last module in the list
*/ */
PICKED_ITEMS_LIST pickList; PICKED_ITEMS_LIST pickList;
...@@ -460,9 +388,10 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* aModule, ...@@ -460,9 +388,10 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* aModule,
FPID oldFootprintFPID = aModule->GetFPID(); FPID oldFootprintFPID = aModule->GetFPID();
// Load module. // Load module.
line.Printf( _( "Change module %s (from %s) " ), line.Printf( _( "Change module %s (from %s) to %s" ),
GetChars( aModule->GetReference() ), GetChars( aModule->GetReference() ),
oldFootprintFPID.Format().c_str() ); oldFootprintFPID.Format().c_str(),
aNewFootprintFPID.Format().c_str() );
m_WinMessages->AppendText( line ); m_WinMessages->AppendText( line );
wxString moduleName = FROM_UTF8( aNewFootprintFPID.GetFootprintName().c_str() ); wxString moduleName = FROM_UTF8( aNewFootprintFPID.GetFootprintName().c_str() );
...@@ -476,7 +405,7 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* aModule, ...@@ -476,7 +405,7 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* aModule,
if( newModule == NULL ) // New module not found, redraw the old one. if( newModule == NULL ) // New module not found, redraw the old one.
{ {
m_WinMessages->AppendText( wxT( "No\n" ) ); m_WinMessages->AppendText( wxT( " No\n" ) );
return false; return false;
} }
...@@ -485,13 +414,10 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* aModule, ...@@ -485,13 +414,10 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* aModule,
if( aModule == m_currentModule ) if( aModule == m_currentModule )
m_currentModule = newModule; m_currentModule = newModule;
m_WinMessages->AppendText( wxT( "OK\n" ) ); m_WinMessages->AppendText( wxT( " OK\n" ) );
m_parent->Exchange_Module( aModule, newModule, aUndoPickList ); m_parent->Exchange_Module( aModule, newModule, aUndoPickList );
Maj_ListeCmp( newModule->GetReference(),
oldFootprintFPID, aNewFootprintFPID, aShowError );
return true; return true;
} }
...@@ -610,7 +536,7 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent ) ...@@ -610,7 +536,7 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
if( ! RecreateCmpFile( GetBoard(), fn.GetFullPath() ) ) if( ! RecreateCmpFile( GetBoard(), fn.GetFullPath() ) )
{ {
msg = _( "Unable to create file " ) + fn.GetFullPath(); msg.Printf( _( "Could not create file '%s'" ), GetChars(fn.GetFullPath() ) );
DisplayError( this, msg ); DisplayError( this, msg );
return; return;
} }
......
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