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
/* 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];
......
......@@ -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;
EDA_RECT rect;
......
......@@ -104,7 +104,7 @@ public:
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 );
......
......@@ -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;
int xmin, xmax, ymin, ymax;
......
......@@ -76,7 +76,7 @@ public:
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;
......
......@@ -105,7 +105,7 @@ bool LIB_CIRCLE::HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTra
if( aThreshold < 0 )
aThreshold = GetPenSize() / 2;
int dist = KiROUND( GetLineLength( aPosRef, aTransform.TransformCoordinate( m_Pos ) ) );
int dist = KiROUND( GetLineLength( aPosRef, aTransform.TransformCoordinate( m_Pos ) ) );
if( abs( dist - m_Radius ) <= aThreshold )
return true;
......@@ -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;
......
......@@ -67,7 +67,7 @@ public:
int GetPenSize( ) const;
EDA_RECT GetBoundingBox() const;
const EDA_RECT GetBoundingBox() const; // Virtual
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
......
......@@ -260,7 +260,7 @@ public:
/**
* @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
......
......@@ -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
* calling GetTextBox() that works using top to bottom Y axis orientation.
......
......@@ -165,7 +165,7 @@ public:
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 );
......
......@@ -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;
EDA_RECT bbox;
......
......@@ -139,7 +139,7 @@ public:
bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation );
EDA_RECT GetBoundingBox() const;
const EDA_RECT GetBoundingBox() const; // Virtual
/**
* Function ReturnPinEndPoint
......
......@@ -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;
int xmin, xmax, ymin, ymax;
......
......@@ -78,7 +78,7 @@ public:
bool HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform );
EDA_RECT GetBoundingBox() const;
const EDA_RECT GetBoundingBox() const; // Virtual
int GetPenSize( ) const;
......
......@@ -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;
......
......@@ -71,7 +71,7 @@ public:
int GetPenSize( ) const;
EDA_RECT GetBoundingBox() const;
const EDA_RECT GetBoundingBox() const; // Virtual
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& 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
* calling GetTextBox() that works using top to bottom Y axis orientation.
......
......@@ -96,7 +96,7 @@ public:
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
EDA_RECT GetBoundingBox() const;
const EDA_RECT GetBoundingBox() const; // virtual
void Rotate();
......
......@@ -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();
......
......@@ -90,7 +90,7 @@ public:
*/
wxSize GetSize() const;
EDA_RECT GetBoundingBox() const;
const EDA_RECT GetBoundingBox() const; // Virtual
void SwapData( SCH_ITEM* aItem );
......
......@@ -110,7 +110,7 @@ bool SCH_BUS_BUS_ENTRY::Save( FILE* aFile ) const
}
bool SCH_BUS_ENTRY_BASE::Load( LINE_READER& aLine, wxString& aErrorMsg,
bool SCH_BUS_ENTRY_BASE::Load( LINE_READER& aLine, wxString& aErrorMsg,
SCH_ITEM **out )
{
char Name1[256];
......@@ -136,7 +136,7 @@ bool SCH_BUS_ENTRY_BASE::Load( LINE_READER& aLine, wxString& aErrorMsg,
this_new = new SCH_BUS_WIRE_ENTRY;
*out = this_new;
if( !aLine.ReadLine() || sscanf( (char*) aLine, "%d %d %d %d ",
if( !aLine.ReadLine() || sscanf( (char*) aLine, "%d %d %d %d ",
&this_new->m_pos.x, &this_new->m_pos.y,
&this_new->m_size.x, &this_new->m_size.y ) != 4 )
{
......@@ -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;
......
......@@ -76,7 +76,7 @@ public:
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 )
{
......
......@@ -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();
for( size_t i = 0; i < m_Fields.size(); i++ )
......
......@@ -220,7 +220,7 @@ public:
*/
void SetTimeStamp( time_t aNewTimeStamp );
EDA_RECT GetBoundingBox() const;
const EDA_RECT GetBoundingBox() const; // Virtual
//-----<Fields>-----------------------------------------------------------
......
......@@ -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;
int linewidth = ( m_Thickness == 0 ) ? GetDefaultLineThickness() : m_Thickness;
......
......@@ -100,7 +100,7 @@ public:
void Place( SCH_EDIT_FRAME* frame, wxDC* DC );
EDA_RECT GetBoundingBox() const;
const EDA_RECT GetBoundingBox() const; // Virtual
/**
* Function IsVoid
......
......@@ -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;
......
......@@ -55,7 +55,7 @@ public:
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,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR );
......
......@@ -116,7 +116,7 @@ void SCH_LINE::Show( int nestLevel, std::ostream& os ) const
#endif
EDA_RECT SCH_LINE::GetBoundingBox() const
const EDA_RECT SCH_LINE::GetBoundingBox() const
{
int width = 25;
......
......@@ -76,7 +76,7 @@ public:
void SetEndPoint( const wxPoint& aPosition ) { m_end = aPosition; }
EDA_RECT GetBoundingBox() const;
const EDA_RECT GetBoundingBox() const; // Virtual
/**
* Function GetLength
......
......@@ -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.
* 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();
}
......
......@@ -72,7 +72,7 @@ public:
bool Save( FILE* aFile ) const;
EDA_RECT GetBoundingBox() const;
EDA_RECT const GetBoundingBox() const; // Virtual
// Geometric transforms (used in block operations):
......
......@@ -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;
EDA_RECT box;
......
......@@ -62,7 +62,7 @@ public:
bool Load( LINE_READER& aLine, wxString& aErrorMsg );
EDA_RECT GetBoundingBox() const;
const EDA_RECT GetBoundingBox() const; // Virtual
// Geometric transforms (used in block operations):
......
......@@ -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;
EDA_RECT box( m_pos, m_size );
......
......@@ -398,7 +398,7 @@ public:
GR_DRAWMODE aDrawMode,
EDA_COLOR_T aColor = UNSPECIFIED_COLOR );
EDA_RECT GetBoundingBox() const;
EDA_RECT const GetBoundingBox() const;
/**
* Function GetResizePos
......
......@@ -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
// when calculating the bounding box
......@@ -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;
......@@ -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;
......@@ -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;
......
......@@ -151,7 +151,7 @@ public:
virtual void SwapData( SCH_ITEM* aItem );
virtual EDA_RECT GetBoundingBox() const;
virtual const EDA_RECT GetBoundingBox() const;
virtual bool Save( FILE* aFile ) const;
......@@ -249,7 +249,7 @@ public:
void Rotate( wxPoint aPosition );
EDA_RECT GetBoundingBox() const;
const EDA_RECT GetBoundingBox() const; // Virtual
bool Save( FILE* aFile ) const;
......@@ -298,7 +298,7 @@ public:
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 );
......@@ -353,7 +353,7 @@ public:
bool Load( LINE_READER& aLine, wxString& aErrorMsg );
EDA_RECT GetBoundingBox() const;
const EDA_RECT GetBoundingBox() const; // Virtual
void MirrorY( int aYaxis_position );
......
......@@ -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
EDA_RECT bbox( m_Start, wxSize( 1, 1 ) );
......
......@@ -218,7 +218,7 @@ public:
*/
D_CODE* GetDcodeDescr();
EDA_RECT GetBoundingBox() const;
const EDA_RECT GetBoundingBox() const; // Virtual
/* Display on screen: */
void Draw( EDA_DRAW_PANEL* aPanel,
......
......@@ -283,7 +283,7 @@ public:
* useful to calculate bounding box of rotated items, when
* 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:
* system.
* 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)
printf( "Missing GetBoundingBox()\n" );
......
......@@ -1531,52 +1531,6 @@ public:
*/
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:
int Solve( wxDC* DC, int two_sides );
void Reset_Noroutable( wxDC* DC );
......
This diff is collapsed.
......@@ -2134,7 +2134,7 @@ MODULE* BOARD::GetFootprint( const wxPoint& aPosition, LAYER_NUM aActiveLayer,
// Filter non visible modules if requested
if( (!aVisibleOnly) || IsModuleLayerVisible( layer ) )
{
EDA_RECT bb = pt_module->GetFootPrintRect();
EDA_RECT bb = pt_module->GetFootprintRect();
int offx = bb.GetX() + bb.GetWidth() / 2;
int offy = bb.GetY() + bb.GetHeight() / 2;
......
......@@ -857,7 +857,7 @@ public:
* as long as the BOARD has not changed. Remember, ComputeBoundingBox()'s
* 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; }
......
......@@ -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;
int xmin, xmax, ymin, ymax;
......
......@@ -139,7 +139,8 @@ public:
return wxT( "DIMENSION" );
}
EDA_RECT GetBoundingBox() const;
// Virtual function
const EDA_RECT GetBoundingBox() const;
wxString GetSelectMenuText() const;
......
......@@ -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;
......
......@@ -168,7 +168,7 @@ public:
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 );
......
......@@ -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;
bBox.SetX( m_Pos.x - m_Size/2 );
......
......@@ -92,7 +92,8 @@ public:
*/
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;
......
......@@ -409,12 +409,12 @@ void MODULE::DrawEdgesOnly( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offs
void MODULE::CalculateBoundingBox()
{
m_BoundaryBox = GetFootPrintRect();
m_BoundaryBox = GetFootprintRect();
m_Surface = std::abs( (double) m_BoundaryBox.GetWidth() * m_BoundaryBox.GetHeight() );
}
EDA_RECT MODULE::GetFootPrintRect() const
EDA_RECT MODULE::GetFootprintRect() const
{
EDA_RECT area;
......@@ -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
area.Merge( m_Reference->GetBoundingBox() );
......
......@@ -96,13 +96,14 @@ public:
void CalculateBoundingBox();
/**
* Function GetFootPrintRect()
* Function GetFootprintRect()
* Returns the area of the module footprint excluding any text.
* @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; }
const DLIST<D_PAD>& Pads() const { return m_Pads; }
......
......@@ -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;
wxPoint quadrant1, quadrant2, quadrant3, quadrant4;
......
......@@ -392,7 +392,8 @@ public:
return wxT( "PAD" );
}
EDA_RECT GetBoundingBox() const;
// Virtual function:
const EDA_RECT GetBoundingBox() const;
/**
* Function Compare
......
......@@ -158,7 +158,7 @@ void TEXTE_PCB::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
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 );
......
......@@ -130,7 +130,8 @@ public:
BITMAP_DEF GetMenuImage() const { return add_text_xpm; }
EDA_RECT GetBoundingBox() const;
// Virtual function
const EDA_RECT GetBoundingBox() const;
EDA_ITEM* Clone() const;
......
......@@ -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
* orientation)
*/
EDA_RECT TEXTE_MODULE::GetBoundingBox() const
const EDA_RECT TEXTE_MODULE::GetBoundingBox() const
{
double angle = GetDrawRotation();
EDA_RECT text_area = GetTextBox( -1, -1 );
......
......@@ -123,7 +123,8 @@ public:
*/
double GetDrawRotation() const;
EDA_RECT GetBoundingBox() const;
// Virtual function
const EDA_RECT GetBoundingBox() const;
void SetDrawCoord(); // Set absolute coordinates.
......
......@@ -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
int radius = ( m_Width + 1 ) / 2;
......
......@@ -127,7 +127,8 @@ public:
int GetShape() const { return m_Shape; }
void SetShape( int aShape ) { m_Shape = aShape; }
EDA_RECT GetBoundingBox() const;
// Virtual function
const EDA_RECT GetBoundingBox() const;
/**
* Function GetBestInsertPoint
......
......@@ -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)
......
......@@ -151,10 +151,10 @@ public:
void DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC,
GR_DRAWMODE draw_mode = GR_OR );
/** Function GetBoundingBox
/** Function GetBoundingBox (virtual)
* @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;
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// C++ code generated with wxFormBuilder (version Nov 6 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -22,7 +22,7 @@ DIALOG_EXCHANGE_MODULE_BASE::DIALOG_EXCHANGE_MODULE_BASE( wxWindow* parent, wxWi
wxBoxSizer* bLeftSizer;
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 );
bLeftSizer->Add( m_staticText6, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
......@@ -30,7 +30,7 @@ DIALOG_EXCHANGE_MODULE_BASE::DIALOG_EXCHANGE_MODULE_BASE( wxWindow* parent, wxWi
m_OldModule->SetMaxLength( 0 );
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 );
bLeftSizer->Add( m_staticText7, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
......@@ -38,7 +38,7 @@ DIALOG_EXCHANGE_MODULE_BASE::DIALOG_EXCHANGE_MODULE_BASE( wxWindow* parent, wxWi
m_OldValue->SetMaxLength( 0 );
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 );
bLeftSizer->Add( m_staticText8, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
......@@ -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") };
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->SetSelection( 0 );
m_Selection = new wxRadioBox( this, ID_SELECTION_CLICKED, _("Options"), wxDefaultPosition, wxDefaultSize, m_SelectionNChoices, m_SelectionChoices, 1, wxRA_SPECIFY_COLS );
m_Selection->SetSelection( 2 );
bMiddleSizer->Add( m_Selection, 0, wxALL, 5 );
......@@ -65,13 +65,16 @@ DIALOG_EXCHANGE_MODULE_BASE::DIALOG_EXCHANGE_MODULE_BASE( wxWindow* parent, wxWi
bRightSizer = new wxBoxSizer( wxVERTICAL );
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 );
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 );
bRightSizer->Add( m_Browsebutton, 0, wxALL, 5 );
bRightSizer->Add( m_Browsebutton, 0, wxALL|wxEXPAND, 5 );
bUpperSizer->Add( bRightSizer, 0, wxALIGN_CENTER_VERTICAL, 5 );
......@@ -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_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_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 );
}
......@@ -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_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_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 );
}
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// C++ code generated with wxFormBuilder (version Nov 6 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -47,6 +47,7 @@ class DIALOG_EXCHANGE_MODULE_BASE : public DIALOG_SHIM
wxRadioBox* m_Selection;
wxButton* m_OKbutton;
wxButton* m_Quitbutton;
wxButton* m_buttonCmpList;
wxButton* m_Browsebutton;
wxStaticText* m_staticTextMsg;
wxTextCtrl* m_WinMessages;
......@@ -55,6 +56,7 @@ class DIALOG_EXCHANGE_MODULE_BASE : public DIALOG_SHIM
virtual void OnSelectionClicked( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOkClick( 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(); }
......
......@@ -5,7 +5,7 @@
/*
* 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 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
......@@ -43,11 +43,8 @@
#include <dialog_exchange_modules_base.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 );
class DIALOG_EXCHANGE_MODULE : public DIALOG_EXCHANGE_MODULE_BASE
{
private:
......@@ -64,13 +61,12 @@ private:
void OnOkClick( wxCommandEvent& event );
void OnQuit( wxCommandEvent& event );
void BrowseAndSelectFootprint( wxCommandEvent& event );
void RebuildCmpList( wxCommandEvent& event );
void init();
void ChangeCurrentFootprint();
void ChangeSameFootprints( bool aUseValue );
void ChangeSameFootprints( bool aUseValue);
void ChangeAllFootprints();
int Maj_ListeCmp( const wxString& aReference, const FPID& aOldFootprintFPID,
const FPID& aNewFootprintFPID, bool aShowError );
bool Change_1_Module( MODULE* aModule,
const FPID& aNewFootprintFPID,
PICKED_ITEMS_LIST* aUndoPickList,
......@@ -123,6 +119,7 @@ void DIALOG_EXCHANGE_MODULE::init()
void DIALOG_EXCHANGE_MODULE::OnOkClick( wxCommandEvent& event )
{
m_selectionMode = m_Selection->GetSelection();
switch( m_Selection->GetSelection() )
{
case 0:
......@@ -146,120 +143,51 @@ void DIALOG_EXCHANGE_MODULE::OnOkClick( wxCommandEvent& event )
void DIALOG_EXCHANGE_MODULE::OnSelectionClicked( wxCommandEvent& event )
{
bool enable = true;
switch( m_Selection->GetSelection() )
{
case 0:
case 1:
case 2:
m_NewModule->Enable( true );
m_Browsebutton->Enable( true );
break;
case 3:
m_NewModule->Enable( false );
m_Browsebutton->Enable( false );
enable = false;
break;
}
m_NewModule->Enable( enable );
m_Browsebutton->Enable( enable );
}
/*
* Updates the file name.CMP (if any) after an exchange module
* (By command changeMod), if the modules are managed by this file
*
* If ShowError! = 0 displays error message if the file. Cmp is not found.
* Return 1 if error
* Rebuild the file name.CMP (if any) after exchanging footprints
* if the footprint are managed by this file
* Return false if error
*/
int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& aReference,
const FPID& aOldFootprintFPID,
const FPID& aNewFootprintFPID,
bool aShowError )
void DIALOG_EXCHANGE_MODULE::RebuildCmpList( wxCommandEvent& event )
{
wxFileName fn;
wxFileName tmpFileName;
FILE* FichCmp, * NewFile;
char line[1024];
wxString msg;
if( aOldFootprintFPID == aNewFootprintFPID )
return 0;
// Build CMP file name by changing the extension of NetList filename
fn = m_parent->GetBoard()->GetFileName();
fn.SetExt( ComponentFileExtension );
FichCmp = wxFopen( fn.GetFullPath(), wxT( "rt" ) );
if( FichCmp == NULL )
if( RecreateCmpFile( m_parent->GetBoard(), fn.GetFullPath() ) )
{
if( aShowError )
{
msg.Printf( _( "file <%s> not found" ), GetChars( fn.GetFullPath() ) );
m_WinMessages->AppendText( msg );
}
return 1;
msg.Printf( _( "File '%s' created\n" ),
GetChars( fn.GetFullPath() ) );
}
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 )
else
{
if( strnicmp( line, "Reference = ", 9 ) == 0 )
{
char buf[1024];
strcpy( buf, line + 12 );
strtok( buf, ";\n\r" );
if( stricmp( buf, TO_UTF8( aReference ) ) == 0 )
{
start_descr = true;
}
}
if( (strnicmp( line, "Begin", 5 ) == 0) || (strnicmp( line, "End", 3 ) == 0) )
{
start_descr = false;
}
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 );
start_descr = false;
}
fputs( line, NewFile );
msg.Printf( _( "** Could not create file '%s' ***\n" ),
GetChars( fn.GetFullPath() ) );
}
fclose( FichCmp );
fclose( NewFile );
wxRemoveFile( fn.GetFullPath() );
wxRenameFile( tmpFileName.GetFullPath(), fn.GetFullPath() );
return 0;
m_WinMessages->AppendText( msg );
}
......@@ -401,7 +329,7 @@ void DIALOG_EXCHANGE_MODULE::ChangeAllFootprints()
if( !IsOK( this, _( "Change ALL modules ?" ) ) )
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
*/
PICKED_ITEMS_LIST pickList;
......@@ -460,9 +388,10 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* aModule,
FPID oldFootprintFPID = aModule->GetFPID();
// Load module.
line.Printf( _( "Change module %s (from %s) " ),
line.Printf( _( "Change module %s (from %s) to %s" ),
GetChars( aModule->GetReference() ),
oldFootprintFPID.Format().c_str() );
oldFootprintFPID.Format().c_str(),
aNewFootprintFPID.Format().c_str() );
m_WinMessages->AppendText( line );
wxString moduleName = FROM_UTF8( aNewFootprintFPID.GetFootprintName().c_str() );
......@@ -476,7 +405,7 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* aModule,
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;
}
......@@ -485,13 +414,10 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* aModule,
if( aModule == m_currentModule )
m_currentModule = newModule;
m_WinMessages->AppendText( wxT( "OK\n" ) );
m_WinMessages->AppendText( wxT( " OK\n" ) );
m_parent->Exchange_Module( aModule, newModule, aUndoPickList );
Maj_ListeCmp( newModule->GetReference(),
oldFootprintFPID, aNewFootprintFPID, aShowError );
return true;
}
......@@ -610,7 +536,7 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
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 );
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