All: remove macros MAX, MIN, ABS from macros.h and replace these macros by std::max, std::min and std::abs (mainly found in old code).

This commit is contained in:
jean-pierre charras 2012-09-22 13:19:37 +02:00
parent 210a7036db
commit b660b033ad
69 changed files with 391 additions and 459 deletions

View File

@ -334,13 +334,13 @@ bool EDA_RECT::Intersects( const EDA_RECT& aRect ) const
rect.Normalize(); // ensure size is >= 0
// calculate the left common area coordinate:
int left = MAX( me.m_Pos.x, rect.m_Pos.x );
int left = std::max( me.m_Pos.x, rect.m_Pos.x );
// calculate the right common area coordinate:
int right = MIN( me.m_Pos.x + me.m_Size.x, rect.m_Pos.x + rect.m_Size.x );
int right = std::min( me.m_Pos.x + me.m_Size.x, rect.m_Pos.x + rect.m_Size.x );
// calculate the upper common area coordinate:
int top = MAX( me.m_Pos.y, aRect.m_Pos.y );
int top = std::max( me.m_Pos.y, aRect.m_Pos.y );
// calculate the lower common area coordinate:
int bottom = MIN( me.m_Pos.y + me.m_Size.y, rect.m_Pos.y + rect.m_Size.y );
int bottom = std::min( me.m_Pos.y + me.m_Size.y, rect.m_Pos.y + rect.m_Size.y );
// if a common area exists, it must have a positive (null accepted) size
if( left <= right && top <= bottom )
@ -436,10 +436,10 @@ void EDA_RECT::Merge( const EDA_RECT& aRect )
wxPoint rect_end = rect.GetEnd();
// Change origin and size in order to contain the given rect
m_Pos.x = MIN( m_Pos.x, rect.m_Pos.x );
m_Pos.y = MIN( m_Pos.y, rect.m_Pos.y );
end.x = MAX( end.x, rect_end.x );
end.y = MAX( end.y, rect_end.y );
m_Pos.x = std::min( m_Pos.x, rect.m_Pos.x );
m_Pos.y = std::min( m_Pos.y, rect.m_Pos.y );
end.x = std::max( end.x, rect_end.x );
end.y = std::max( end.y, rect_end.y );
SetEnd( end );
}
@ -450,10 +450,10 @@ void EDA_RECT::Merge( const wxPoint& aPoint )
wxPoint end = GetEnd();
// Change origin and size in order to contain the given rect
m_Pos.x = MIN( m_Pos.x, aPoint.x );
m_Pos.y = MIN( m_Pos.y, aPoint.y );
end.x = MAX( end.x, aPoint.x );
end.y = MAX( end.y, aPoint.y );
m_Pos.x = std::min( m_Pos.x, aPoint.x );
m_Pos.y = std::min( m_Pos.y, aPoint.y );
end.x = std::max( end.x, aPoint.x );
end.y = std::max( end.y, aPoint.y );
SetEnd( end );
}

View File

@ -22,7 +22,7 @@
#define M_SHAPE_SCALE 6 // default scaling factor for MarkerShapeCorners coordinates
#define CORNERS_COUNT 8
/* corners of the default shape
* real coordinates are these values * .m_ScalingFactor
* actual coordinates are these values * .m_ScalingFactor
*/
static const wxPoint MarkerShapeCorners[CORNERS_COUNT] =
{
@ -50,10 +50,10 @@ void MARKER_BASE::init()
{
wxPoint corner = MarkerShapeCorners[ii];
m_Corners.push_back( corner );
start.x = MIN( start.x, corner.x);
start.y = MIN( start.y, corner.y);
end.x = MAX( end.x, corner.x);
end.y = MAX( end.y, corner.y);
start.x = std::min( start.x, corner.x);
start.y = std::min( start.y, corner.y);
end.x = std::max( end.x, corner.x);
end.y = std::max( end.y, corner.y);
}
m_ShapeBoundingBox.SetOrigin(start);

View File

@ -554,7 +554,7 @@ void PS_PLOTTER::PlotImage( const wxImage & aImage, const wxPoint& aPos,
// Map image size to device
DPOINT end_dev = userToDeviceCoordinates( end );
fprintf( outputFile, "%g %g scale\n",
ABS(end_dev.x - start_dev.x), ABS(end_dev.y - start_dev.y));
std::abs(end_dev.x - start_dev.x), std::abs(end_dev.y - start_dev.y));
// Dimensions of source image (in pixels
fprintf( outputFile, "%d %d 8", pix_size.x, pix_size.y );

View File

@ -538,7 +538,7 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
case WS_COMPANY_NAME:
msg += aTitleBlock.GetCompany();
if( !msg.IsEmpty() )
UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT );
UpperLimit = std::max( UpperLimit, WsItem->m_Posy + SIZETEXT );
bold = true;
break;
@ -550,25 +550,25 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
case WS_COMMENT1:
msg += aTitleBlock.GetComment1();
if( !msg.IsEmpty() )
UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT );
UpperLimit = std::max( UpperLimit, WsItem->m_Posy + SIZETEXT );
break;
case WS_COMMENT2:
msg += aTitleBlock.GetComment2();
if( !msg.IsEmpty() )
UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT );
UpperLimit = std::max( UpperLimit, WsItem->m_Posy + SIZETEXT );
break;
case WS_COMMENT3:
msg += aTitleBlock.GetComment3();
if( !msg.IsEmpty() )
UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT );
UpperLimit = std::max( UpperLimit, WsItem->m_Posy + SIZETEXT );
break;
case WS_COMMENT4:
msg += aTitleBlock.GetComment4();
if( !msg.IsEmpty() )
UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT );
UpperLimit = std::max( UpperLimit, WsItem->m_Posy + SIZETEXT );
break;
case WS_UPPER_SEGMENT:

View File

@ -87,8 +87,8 @@ EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id,
{
wxASSERT( parent );
m_scrollIncrementX = MIN( size.x / 8, 10 );
m_scrollIncrementY = MIN( size.y / 8, 10 );
m_scrollIncrementX = std::min( size.x / 8, 10 );
m_scrollIncrementY = std::min( size.y / 8, 10 );
SetBackgroundColour( MakeColour( g_DrawBgColor ) );
@ -441,8 +441,8 @@ void EDA_DRAW_PANEL::SetClipBox( wxDC& aDC, const wxRect* aRect )
scrollX = KiROUND( Screen->GetGridSize().x * scalar );
scrollY = KiROUND( Screen->GetGridSize().y * scalar );
m_scrollIncrementX = MAX( GetClientSize().x / 8, scrollX );
m_scrollIncrementY = MAX( GetClientSize().y / 8, scrollY );
m_scrollIncrementX = std::max( GetClientSize().x / 8, scrollX );
m_scrollIncrementY = std::max( GetClientSize().y / 8, scrollY );
Screen->m_ScrollbarPos.x = GetScrollPos( wxHORIZONTAL );
Screen->m_ScrollbarPos.y = GetScrollPos( wxVERTICAL );
}
@ -1205,8 +1205,8 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
*/
#define BLOCK_MINSIZE_LIMIT 1
bool BlockIsSmall =
( ABS( screen->m_BlockLocate.GetWidth() ) < BLOCK_MINSIZE_LIMIT )
&& ( ABS( screen->m_BlockLocate.GetHeight() ) < BLOCK_MINSIZE_LIMIT );
( std::abs( screen->m_BlockLocate.GetWidth() ) < BLOCK_MINSIZE_LIMIT )
&& ( std::abs( screen->m_BlockLocate.GetHeight() ) < BLOCK_MINSIZE_LIMIT );
if( (screen->m_BlockLocate.GetState() != STATE_NO_BLOCK) && BlockIsSmall )
{

View File

@ -89,7 +89,7 @@ int Clamp_Text_PenSize( int aPenSize, int aSize, bool aBold )
{
int penSize = aPenSize;
double scale = aBold ? 4.0 : 6.0;
int maxWidth = KiROUND( ABS( aSize ) / scale );
int maxWidth = KiROUND( std::abs( aSize ) / scale );
if( penSize > maxWidth )
penSize = maxWidth;
@ -99,7 +99,7 @@ int Clamp_Text_PenSize( int aPenSize, int aSize, bool aBold )
int Clamp_Text_PenSize( int aPenSize, wxSize aSize, bool aBold )
{
int size = MIN( ABS( aSize.x ), ABS( aSize.y ) );
int size = std::min( std::abs( aSize.x ), std::abs( aSize.y ) );
return Clamp_Text_PenSize( aPenSize, size, aBold );
}
@ -283,7 +283,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
size_v = aSize.y;
if( aWidth == 0 && aBold ) // Use default values if aWidth == 0
aWidth = GetPenSizeForBold( MIN( aSize.x, aSize.y ) );
aWidth = GetPenSizeForBold( std::min( aSize.x, aSize.y ) );
if( aWidth < 0 )
{
@ -311,7 +311,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
if( aPanel )
{
int xm, ym, ll, xc, yc;
ll = ABS( dx );
ll = std::abs( dx );
xc = current_char_pos.x;
yc = current_char_pos.y;
@ -372,7 +372,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
/* if a text size is too small, the text cannot be drawn, and it is drawn as a single
* graphic line */
if( ABS( aSize.x ) < 3 )
if( std::abs( aSize.x ) < 3 )
{
/* draw the text as a line always vertically centered */
wxPoint end( current_char_pos.x + dx, current_char_pos.y );
@ -554,7 +554,7 @@ void PLOTTER::Text( const wxPoint& aPos,
int textPensize = aWidth;
if( textPensize == 0 && aBold ) // Use default values if aWidth == 0
textPensize = GetPenSizeForBold( MIN( aSize.x, aSize.y ) );
textPensize = GetPenSizeForBold( std::min( aSize.x, aSize.y ) );
if( textPensize >= 0 )
textPensize = Clamp_Text_PenSize( aWidth, aSize, aBold );

View File

@ -29,7 +29,6 @@
#include <eda_text.h>
#include <drawtxt.h>
#include <macros.h> // MAX
#include <trigo.h> // RotatePoint
#include <class_drawpanel.h> // EDA_DRAW_PANEL
@ -134,7 +133,7 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
{
text = list->Item( ii );
dx = LenSize( text );
textsize.x = MAX( textsize.x, dx );
textsize.x = std::max( textsize.x, dx );
textsize.y += dy;
}
}

View File

@ -723,7 +723,7 @@ void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
}
else
{
if( ABS( dx ) == ABS( dy ) ) /* segment 45 degrees */
if( std::abs( dx ) == std::abs( dy ) ) // segment 45 degrees
{
dwx = dwy = ( (width * 5) + 4 ) / 7; // = width / 2 * 0.707
if( dy < 0 )
@ -829,10 +829,10 @@ static bool IsGRSPolyDrawable( EDA_RECT* ClipBox, int n, wxPoint Points[] )
for( int ii = 1; ii < n; ii++ ) // calculate rectangle
{
Xmin = MIN( Xmin, Points[ii].x );
Xmax = MAX( Xmax, Points[ii].x );
Ymin = MIN( Ymin, Points[ii].y );
Ymax = MAX( Ymax, Points[ii].y );
Xmin = std::min( Xmin, Points[ii].x );
Xmax = std::max( Xmax, Points[ii].x );
Ymin = std::min( Ymin, Points[ii].y );
Ymax = std::max( Ymax, Points[ii].y );
}
xcliplo = ClipBox->GetX();

View File

@ -7,10 +7,8 @@
#include <fctsys.h>
#include <gr_basic.h>
#include <common.h>
#include <colors.h>
#include <macros.h>
#include <wx/statline.h>
@ -84,7 +82,7 @@ WinEDA_SelColorFrame::WinEDA_SelColorFrame( wxWindow* parent,
if( windowPosition.x < margin )
windowPosition.x = margin;
// Under MACOS, a vertical margin >= 20 is needed by the system menubar
int v_margin = MAX(20, margin);
int v_margin = std::max(20, margin);
if( windowPosition.y < v_margin )
windowPosition.y = v_margin;
if( windowPosition != framepos )

View File

@ -1429,13 +1429,13 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi
msg = WsItem->m_Legende;
DrawGraphicText( m_canvas, aDC, pos, aClr1, msg, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
GetPenSizeForBold( MIN( size.x, size.y ) ), false, true );
GetPenSizeForBold( std::min( size.x, size.y ) ), false, true );
pos.x += ReturnGraphicTextWidth( msg, size.x, false, false );
}
msg = aTb.GetRevision();
DrawGraphicText( m_canvas, aDC, pos, aClr2, msg, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
GetPenSizeForBold( MIN( size.x, size.y ) ), false, true );
GetPenSizeForBold( std::min( size.x, size.y ) ), false, true );
break;
case WS_KICAD_VERSION:
@ -1506,9 +1506,9 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi
DrawGraphicText( m_canvas, aDC, pos, aClr2,
msg, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
GetPenSizeForBold( MIN( size.x, size.y ) ),
GetPenSizeForBold( std::min( size.x, size.y ) ),
false, true );
UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT );
UpperLimit = std::max( UpperLimit, WsItem->m_Posy + SIZETEXT );
}
break;
@ -1518,13 +1518,13 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi
msg = WsItem->m_Legende;
DrawGraphicText( m_canvas, aDC, pos, aClr1, msg, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
GetPenSizeForBold( MIN( size.x, size.y ) ), false, true );
GetPenSizeForBold( std::min( size.x, size.y ) ), false, true );
pos.x += ReturnGraphicTextWidth( msg, size.x, false, false );
}
msg = aTb.GetTitle();
DrawGraphicText( m_canvas, aDC, pos, aClr2, msg, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
GetPenSizeForBold( MIN( size.x, size.y ) ), false, true );
GetPenSizeForBold( std::min( size.x, size.y ) ), false, true );
break;
case WS_COMMENT1:
@ -1537,7 +1537,7 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi
msg, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
aLnW, false, false );
UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT );
UpperLimit = std::max( UpperLimit, WsItem->m_Posy + SIZETEXT );
}
break;
@ -1551,7 +1551,7 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi
msg, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
aLnW, false, false );
UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT );
UpperLimit = std::max( UpperLimit, WsItem->m_Posy + SIZETEXT );
}
break;
@ -1565,7 +1565,7 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi
msg, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
aLnW, false, false );
UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT );
UpperLimit = std::max( UpperLimit, WsItem->m_Posy + SIZETEXT );
}
break;
@ -1579,7 +1579,7 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi
msg, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
aLnW, false, false );
UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT );
UpperLimit = std::max( UpperLimit, WsItem->m_Posy + SIZETEXT );
}
break;

View File

@ -31,7 +31,6 @@
*/
#include <fctsys.h>
#include <macros.h>
#include <id.h>
#include <class_drawpanel.h>
#include <class_base_screen.h>
@ -89,7 +88,7 @@ void EDA_DRAW_FRAME::Window_Zoom( EDA_RECT& Rect )
double scalex = (double) Rect.GetSize().x / size.x;
double bestscale = (double) Rect.GetSize().y / size.y;
bestscale = MAX( bestscale, scalex );
bestscale = std::max( bestscale, scalex );
GetScreen()->SetScalingFactor( bestscale );
RedrawScreen( Rect.Centre(), true );

View File

@ -322,8 +322,8 @@ static void ComputeBreakPoint( SCH_LINE* aSegment, const wxPoint& aPosition )
}
else
{
if( ABS( midPoint.x - aSegment->GetStartPoint().x ) <
ABS( midPoint.y - aSegment->GetStartPoint().y ) )
if( std::abs( midPoint.x - aSegment->GetStartPoint().x ) <
std::abs( midPoint.y - aSegment->GetStartPoint().y ) )
midPoint.x = aSegment->GetStartPoint().x;
else
midPoint.y = aSegment->GetStartPoint().y;
@ -359,7 +359,7 @@ void SCH_EDIT_FRAME::DeleteCurrentSegment( wxDC* DC )
if( g_HVLines )
{
/* Coerce the line to vertical or horizontal one: */
if( ABS( endpos.x - pt.x ) < ABS( endpos.y - pt.y ) )
if( std::abs( endpos.x - pt.x ) < std::abs( endpos.y - pt.y ) )
endpos.x = pt.x;
else
endpos.y = pt.y;

View File

@ -703,7 +703,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
// Error if unit number selected does not exist ( greater than the number of
// parts in the component ). This can happen if a component has changed in a
// library after a previous annotation.
if( MAX( componentFlatList[ii].GetLibComponent()->GetPartCount(), 1 )
if( std::max( componentFlatList[ii].GetLibComponent()->GetPartCount(), 1 )
< componentFlatList[ii].m_Unit )
{
if( componentFlatList[ii].m_NumRef >= 0 )

View File

@ -3,32 +3,40 @@
*/
#include "fctsys.h"
#include "gr_basic.h"
#include "macros.h"
#include "confirm.h"
#include "eda_doc.h"
#include "kicad_string.h"
#include "wxstruct.h"
#include "general.h"
#include "protos.h"
#include "class_library.h"
#include "dialog_helpers.h"
#include <boost/foreach.hpp>
extern void DisplayCmpDocAndKeywords( wxString& Name );
// Used in DataBaseGetName: this is a callback function for EDA_LIST_DIALOG
// to display keywords and description of a component
void DisplayCmpDocAndKeywords( wxString& Name )
{
LIB_ALIAS* CmpEntry = NULL;
CmpEntry = CMP_LIBRARY::FindLibraryEntry( Name );
if( CmpEntry == NULL )
return;
Name = wxT( "Description: " ) + CmpEntry->GetDescription();
Name += wxT( "\nKey Words: " ) + CmpEntry->GetKeyWords();
}
/*
* Routine name selection of a component library for loading,
* Keys leading the list of the keywords filter
* If Keys = "", research components that correspond
* BufName mask (with * and?)
* Displays a list of filterd components found in libraries for selection,
* Keys is a list of keywords to filter components which do not match these keywords
* If Keys is empty, list components that match BufName mask (with * and?)
*
* Returns
* true if the selected component
* false canceled order
* Place the name of the component has loaded, select from a list in
* BufName
* Returns the name of the selected component, or an ampty string
*/
wxString DataBaseGetName( EDA_DRAW_FRAME* frame, wxString& Keys, wxString& BufName )
{
@ -61,14 +69,15 @@ wxString DataBaseGetName( EDA_DRAW_FRAME* frame, wxString& Keys, wxString& BufNa
if( !Keys.IsEmpty() )
msg += _( "key search criteria <" ) + Keys + wxT( "> " );
DisplayError( frame, msg );
DisplayInfoMessage( frame, msg );
return wxEmptyString;
}
// Show candidate list:
wxString cmpname;
EDA_LIST_DIALOG dlg( frame, _( "Select Component" ), nameList, cmpname, DisplayCmpDoc );
EDA_LIST_DIALOG dlg( frame, _( "Select Component" ), nameList, cmpname,
DisplayCmpDocAndKeywords );
if( dlg.ShowModal() != wxID_OK )
return wxEmptyString;
@ -76,21 +85,3 @@ wxString DataBaseGetName( EDA_DRAW_FRAME* frame, wxString& Keys, wxString& BufNa
cmpname = dlg.GetTextSelection();
return cmpname;
}
void DisplayCmpDoc( wxString& Name )
{
LIB_ALIAS* CmpEntry = NULL;
CmpEntry = CMP_LIBRARY::FindLibraryEntry( Name );
if( CmpEntry == NULL )
return;
wxLogDebug( wxT( "Selected component <%s>, m_Doc: <%s>, m_KeyWord: <%s>." ),
GetChars( Name ), GetChars( CmpEntry->GetDescription() ),
GetChars( CmpEntry->GetKeyWords() ) );
Name = wxT( "Description: " ) + CmpEntry->GetDescription();
Name += wxT( "\nKey Words: " ) + CmpEntry->GetKeyWords();
}

View File

@ -233,7 +233,7 @@ void DIALOG_ERC::ReBuildMatrixPanel()
text = new wxStaticText( m_PanelERCOptions, -1, wxT( "W" ), pos );
text_height = text->GetRect().GetHeight();
bitmap_size.y = MAX( bitmap_size.y, text_height );
bitmap_size.y = std::max( bitmap_size.y, text_height );
SAFE_DELETE( text );
// compute the Y pos interval:
@ -244,8 +244,8 @@ void DIALOG_ERC::ReBuildMatrixPanel()
// Size computation is not made in constructor, in some wxWidgets version,
// and m_BoxSizerForERC_Opt position is always 0,0. and we can't use it
pos.x = MAX( pos.x, 5 );
pos.y = MAX( pos.y, m_ResetOptButton->GetRect().GetHeight() + 30 );
pos.x = std::max( pos.x, 5 );
pos.y = std::max( pos.y, m_ResetOptButton->GetRect().GetHeight() + 30 );
BoxMatrixPosition = pos;
@ -261,7 +261,7 @@ void DIALOG_ERC::ReBuildMatrixPanel()
wxPoint( 5, y + ( bitmap_size.y / 2) - (text_height / 2) ) );
int x = text->GetRect().GetRight();
pos.x = MAX( pos.x, x );
pos.x = std::max( pos.x, x );
}
pos.x += 5;
@ -291,7 +291,7 @@ void DIALOG_ERC::ReBuildMatrixPanel()
CommentERC_V[ii],
txtpos );
BoxMatrixMinSize.x = MAX( BoxMatrixMinSize.x, text->GetRect().GetRight() );
BoxMatrixMinSize.x = std::max( BoxMatrixMinSize.x, text->GetRect().GetRight() );
}
event_id = ID_MATRIX_0 + ii + ( jj * PIN_NMAX );

View File

@ -54,7 +54,7 @@ void DIALOG_LIB_EDIT_PIN::OnPaintShowPanel( wxPaintEvent& event )
EDA_RECT bBox = m_dummyPin->GetBoundingBox();
double xscale = (double) dc_size.x / bBox.GetWidth();
double yscale = (double) dc_size.y / bBox.GetHeight();
double scale = MIN( xscale, yscale );
double scale = std::min( xscale, yscale );
// Give a 10% margin
scale *= 0.9;

View File

@ -452,12 +452,12 @@ void TestOthersItems( unsigned NetItemRef, unsigned netstart,
break;
case NET_NOCONNECT:
local_minconn = MAX( NET_NC, local_minconn );
local_minconn = std::max( NET_NC, local_minconn );
break;
case NET_PIN:
jj = g_NetObjectslist[NetItemTst]->m_ElectricalType;
local_minconn = MAX( MinimalReq[ref_elect_type][jj], local_minconn );
local_minconn = std::max( MinimalReq[ref_elect_type][jj], local_minconn );
if( NetItemTst <= NetItemRef )
break;

View File

@ -231,7 +231,7 @@ void HIERARCHY_NAVIG_DLG::BuildSheetsTree( SCH_SHEET_PATH* list, wxTreeItemId*
ll *= 12; // * char width
#endif
ll += maxposx + 20;
m_TreeSize.x = MAX( m_TreeSize.x, ll );
m_TreeSize.x = std::max( m_TreeSize.x, ll );
m_TreeSize.y += 1;
if( *list == m_Parent->GetCurrentSheet() )

View File

@ -469,10 +469,10 @@ start(%d, %d), end(%d, %d), radius %d" ),
}
/* Start with the start and end point of the arc. */
minX = MIN( startPos.x, endPos.x );
minY = MIN( startPos.y, endPos.y );
maxX = MAX( startPos.x, endPos.x );
maxY = MAX( startPos.y, endPos.y );
minX = std::min( startPos.x, endPos.x );
minY = std::min( startPos.y, endPos.y );
maxX = std::max( startPos.x, endPos.x );
maxY = std::max( startPos.y, endPos.y );
/* Zero degrees is a special case. */
if( angleStart == 0 )

View File

@ -391,15 +391,15 @@ EDA_RECT LIB_BEZIER::GetBoundingBox() const
for( unsigned ii = 1; ii < GetCornerCount(); ii++ )
{
xmin = MIN( xmin, m_PolyPoints[ii].x );
xmax = MAX( xmax, m_PolyPoints[ii].x );
ymin = MIN( ymin, m_PolyPoints[ii].y );
ymax = MAX( ymax, m_PolyPoints[ii].y );
xmin = std::min( xmin, m_PolyPoints[ii].x );
xmax = std::max( xmax, m_PolyPoints[ii].x );
ymin = std::min( ymin, m_PolyPoints[ii].y );
ymax = std::max( ymax, m_PolyPoints[ii].y );
}
rect.SetOrigin( xmin, ymin * -1 );
rect.SetEnd( xmax, ymax * -1 );
rect.Inflate( m_Width / 2, m_Width / 2 );
rect.SetOrigin( xmin, - ymin );
rect.SetEnd( xmax, - ymax );
rect.Inflate( m_Width / 2 );
return rect;
}

View File

@ -1889,12 +1889,12 @@ EDA_RECT LIB_PIN::GetBoundingBox() const
int numberTextHeight = showNum ? KiROUND( m_numTextSize * 1.1 ) : 0;
if( m_shape & INVERT )
minsizeV = MAX( TARGET_PIN_RADIUS, INVERT_PIN_RADIUS );
minsizeV = std::max( TARGET_PIN_RADIUS, INVERT_PIN_RADIUS );
// calculate top left corner position
// for the default pin orientation (PIN_RIGHT)
begin.y = MAX( minsizeV, numberTextHeight + TXTMARGE );
begin.x = MIN( -TARGET_PIN_RADIUS, m_length - (numberTextLength / 2) );
begin.y = std::max( minsizeV, numberTextHeight + TXTMARGE );
begin.x = std::min( -TARGET_PIN_RADIUS, m_length - (numberTextLength / 2) );
// calculate bottom right corner position and adjust top left corner position
int nameTextLength = 0;
@ -1917,15 +1917,15 @@ EDA_RECT LIB_PIN::GetBoundingBox() const
if( nameTextOffset ) // for values > 0, pin name is inside the body
{
end.x = m_length + nameTextLength;
end.y = MIN( -minsizeV, -nameTextHeight / 2 );
end.y = std::min( -minsizeV, -nameTextHeight / 2 );
}
else // if value == 0:
// pin name is outside the body, and above the pin line
// pin num is below the pin line
{
end.x = MAX(m_length, nameTextLength);
end.x = std::max(m_length, nameTextLength);
end.y = -begin.y;
begin.y = MAX( minsizeV, nameTextHeight );
begin.y = std::max( minsizeV, nameTextHeight );
}
// Now, calculate boundary box corners position for the actual pin orientation

View File

@ -362,10 +362,10 @@ EDA_RECT LIB_POLYLINE::GetBoundingBox() const
for( unsigned ii = 1; ii < GetCornerCount(); ii++ )
{
xmin = MIN( xmin, m_PolyPoints[ii].x );
xmax = MAX( xmax, m_PolyPoints[ii].x );
ymin = MIN( ymin, m_PolyPoints[ii].y );
ymax = MAX( ymax, m_PolyPoints[ii].y );
xmin = std::min( xmin, m_PolyPoints[ii].x );
xmax = std::max( xmax, m_PolyPoints[ii].x );
ymin = std::min( ymin, m_PolyPoints[ii].y );
ymax = std::max( ymax, m_PolyPoints[ii].y );
}
rect.SetOrigin( xmin, ymin * -1 );

View File

@ -410,7 +410,7 @@ double LIB_EDIT_FRAME::BestZoom()
double zx =(double) dx / ( margin_scale_factor * (double)size.x );
double zy = (double) dy / ( margin_scale_factor * (double)size.y );
double bestzoom = MAX( zx, zy );
double bestzoom = std::max( zx, zy );
// keep it >= minimal existing zoom (can happen for very small components
// for instance when starting a new component

View File

@ -98,7 +98,7 @@ wxString BOM_LABEL::GetText() const
* Routine to free memory used to calculate the netlist TabNetItems = pointer
* to the main table (list items)
*/
void FreeNetObjectsList( NETLIST_OBJECT_LIST& aNetObjectsBuffer )
static void FreeNetObjectsList( NETLIST_OBJECT_LIST& aNetObjectsBuffer )
{
for( unsigned i = 0; i < aNetObjectsBuffer.size(); i++ )
delete aNetObjectsBuffer[i];

View File

@ -175,7 +175,7 @@ void DIALOG_PLOT_SCHEMATIC::setupPlotPagePDF( PLOTTER * aPlotter, SCH_SCREEN* aS
double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
double scale = MIN( scalex, scaley );
double scale = std::min( scalex, scaley );
aPlotter->SetPageSettings( plotPage );
aPlotter->SetViewport( wxPoint( 0, 0 ), IU_PER_DECIMILS, scale, false );
}

View File

@ -98,7 +98,7 @@ void DIALOG_PLOT_SCHEMATIC::createPSFile( bool aPlotAll, bool aPlotFrameRef )
double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
double scale = MIN( scalex, scaley );
double scale = std::min( scalex, scaley );
wxPoint plot_offset;
plotFileName = m_parent->GetUniqueFilenameForCurrentSheet() + wxT( "." )

View File

@ -4,7 +4,6 @@
#include <colors.h>
class EDA_DRAW_PANEL;
class EDA_DRAW_FRAME;
class PICKED_ITEMS_LIST;
@ -14,15 +13,12 @@ class CMP_LIBRARY;
class SCH_COMPONENT;
class SCH_SCREEN;
class SCH_ITEM;
class PLOTTER;
class SCH_SHEET;
class NETLIST_OBJECT;
/****************/
/* DATABASE.CPP */
/****************/
void DisplayCmpDoc( wxString& Name );
//void DisplayCmpDoc( wxString& Name );
wxString DataBaseGetName( EDA_DRAW_FRAME* frame, wxString& Keys, wxString& BufName );
@ -58,12 +54,6 @@ void DrawDanglingSymbol( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& pos, ED
EDA_COLOR_T ReturnLayerColor( int Layer );
/***************/
/* PINEDIT.CPP */
/***************/
void InstallPineditFrame( LIB_EDIT_FRAME* parent, wxDC* DC, const wxPoint& pos );
/***************/
/* SELPART.CPP */
/***************/
@ -103,18 +93,6 @@ CMP_LIBRARY* SelectLibraryFromList( EDA_DRAW_FRAME* frame );
*/
int GetNameOfPartToLoad( EDA_DRAW_FRAME* frame, CMP_LIBRARY* Lib, wxString& BufName );
/***************/
/* LIBARCH.CPP */
/***************/
bool LibArchive( wxWindow* frame, const wxString& ArchFullFileName );
/***************/
/* OPTIONS.CPP */
/***************/
void DisplayOptionFrame( SCH_EDIT_FRAME* parent, const wxPoint& framepos );
/****************/
/* CONTROLE.CPP */
@ -122,18 +100,4 @@ void DisplayOptionFrame( SCH_EDIT_FRAME* parent, const wxPoint& framepos );
void RemoteCommand( const char* cmdline );
/* Prototypes in netlist_control.cpp */
void FreeNetObjectsList( std::vector <NETLIST_OBJECT*>& aNetObjectslist );
/**
* Function ReturnUserNetlistTypeName
* to retrieve user netlist type names
* @param first_item = true: return first name of the list, false = return next
* @return a wxString : name of the type netlist or empty string
* this function must be called first with "first_item" = true
* and after with "first_item" = false to get all the other existing netlist
* names
*/
wxString ReturnUserNetlistTypeName( bool first_item );
#endif /* __PROTOS_H__ */

View File

@ -123,11 +123,11 @@ EDA_RECT SCH_LINE::GetBoundingBox() const
{
int width = 25;
int xmin = MIN( m_start.x, m_end.x ) - width;
int ymin = MIN( m_start.y, m_end.y ) - width;
int xmin = std::min( m_start.x, m_end.x ) - width;
int ymin = std::min( m_start.y, m_end.y ) - width;
int xmax = MAX( m_start.x, m_end.x ) + width;
int ymax = MAX( m_start.y, m_end.y ) + width;
int xmax = std::max( m_start.x, m_end.x ) + width;
int ymax = std::max( m_start.y, m_end.y ) + width;
// return a rectangle which is [pos,dim) in nature. therefore the +1
EDA_RECT ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );

View File

@ -214,7 +214,7 @@ bool SCH_NO_CONNECT::HitTest( const wxPoint& aPosition, int aAccuracy ) const
wxPoint dist = aPosition - m_pos;
if( ( ABS( dist.x ) <= delta ) && ( ABS( dist.y ) <= delta ) )
if( ( std::abs( dist.x ) <= delta ) && ( std::abs( dist.y ) <= delta ) )
return true;
return false;

View File

@ -393,10 +393,10 @@ bool SCH_SCREEN::IsTerminalPoint( const wxPoint& aPosition, int aLayer )
break;
case LAYER_WIRE:
if( GetItem( aPosition, MAX( g_DrawDefaultLineThickness, 3 ), SCH_BUS_ENTRY_T ) )
if( GetItem( aPosition, std::max( g_DrawDefaultLineThickness, 3 ), SCH_BUS_ENTRY_T ) )
return true;
if( GetItem( aPosition, MAX( g_DrawDefaultLineThickness, 3 ), SCH_JUNCTION_T ) )
if( GetItem( aPosition, std::max( g_DrawDefaultLineThickness, 3 ), SCH_JUNCTION_T ) )
return true;
if( GetPin( aPosition, NULL, true ) )

View File

@ -643,8 +643,8 @@ EDA_RECT SCH_SHEET::GetBoundingBox() const
int textlen2 = ReturnGraphicTextWidth( text, m_fileNameSize, false, lineWidth );
// Calculate bounding box X size:
textlen = MAX( textlen, textlen2 );
end.x = MAX( m_size.x, textlen );
textlen = std::max( textlen, textlen2 );
end.x = std::max( m_size.x, textlen );
// Calculate bounding box pos:
end.y = m_size.y;

View File

@ -1643,7 +1643,7 @@ wxPoint SCH_HIERLABEL::GetSchematicTextOffset() const
{
wxPoint text_offset;
int width = MAX( m_Thickness, g_DrawDefaultLineThickness );
int width = std::max( m_Thickness, g_DrawDefaultLineThickness );
int ii = m_Size.x + TXTMARGE + width;

View File

@ -500,7 +500,7 @@ double SCH_EDIT_FRAME::BestZoom()
double zx =(double) dx / ( margin_scale_factor * (double)size.x );
double zy = (double) dy / ( margin_scale_factor * (double)size.y );
double bestzoom = MAX( zx, zy );
double bestzoom = std::max( zx, zy );
GetScreen()->SetScrollCenterPosition( wxPoint( dx / 2, dy / 2 ) );

View File

@ -49,6 +49,7 @@ CMP_LIBRARY* SelectLibraryFromList( EDA_DRAW_FRAME* frame )
return Lib;
}
extern void DisplayCmpDocAndKeywords( wxString& Name );
int DisplayComponentsNamesInLib( EDA_DRAW_FRAME* frame,
CMP_LIBRARY* Library,
@ -64,7 +65,7 @@ int DisplayComponentsNamesInLib( EDA_DRAW_FRAME* frame,
Library->GetEntryNames( nameList );
EDA_LIST_DIALOG dlg( frame, _( "Select Component" ), nameList, OldName, DisplayCmpDoc );
EDA_LIST_DIALOG dlg( frame, _( "Select Component" ), nameList, OldName, DisplayCmpDocAndKeywords );
if( dlg.ShowModal() != wxID_OK )
return 0;

View File

@ -166,7 +166,7 @@ void LIB_VIEW_FRAME::ReCreateHToolbar()
int parts_count = 1;
if( component )
parts_count = MAX( component->GetPartCount(), 1 );
parts_count = std::max( component->GetPartCount(), 1 );
SelpartBox->Clear();

View File

@ -374,7 +374,7 @@ double LIB_VIEW_FRAME::BestZoom()
( margin_scale_factor * (double)size.y);
// Calculates the best zoom
bestzoom = MAX( zx, zy );
bestzoom = std::max( zx, zy );
// keep it >= minimal existing zoom (can happen for very small components
// like small power symbols

View File

@ -646,14 +646,14 @@ int AM_PRIMITIVE::GetShapeDim( GERBER_DRAW_ITEM* aParent )
case AMP_LINE_CENTER:
{
wxPoint size = mapPt( params[1].GetValue( tool ), params[2].GetValue( tool ), m_GerbMetric );
dim = MIN(size.x, size.y);
dim = std::min(size.x, size.y);
}
break;
case AMP_LINE_LOWER_LEFT:
{
wxPoint size = mapPt( params[1].GetValue( tool ), params[2].GetValue( tool ), m_GerbMetric );
dim = MIN(size.x, size.y);
dim = std::min(size.x, size.y);
}
break;
@ -703,7 +703,7 @@ int AM_PRIMITIVE::GetShapeDim( GERBER_DRAW_ITEM* aParent )
wxSize size;
size.x = pos_max.x - pos_min.x;
size.y = pos_max.y - pos_min.y;
dim = MIN( size.x, size.y );
dim = std::min( size.x, size.y );
}
break;

View File

@ -585,7 +585,7 @@ bool GERBER_DRAW_ITEM::HitTest( const wxPoint& aRefPos )
wxPoint ref_pos = GetXYPosition( aRefPos );
// TODO: a better analyze of the shape (perhaps create a D_CODE::HitTest for flashed items)
int radius = MIN( m_Size.x, m_Size.y ) >> 1;
int radius = std::min( m_Size.x, m_Size.y ) >> 1;
// delta is a vector from m_Start to m_End (an origin of m_Start)
wxPoint delta = m_End - m_Start;

View File

@ -134,11 +134,11 @@ int D_CODE::GetShapeDim( GERBER_DRAW_ITEM* aParent )
case APT_RECT:
case APT_OVAL:
dim = MIN( m_Size.x, m_Size.y );
dim = std::min( m_Size.x, m_Size.y );
break;
case APT_POLYGON:
dim = MIN( m_Size.x, m_Size.y );
dim = std::min( m_Size.x, m_Size.y );
break;
case APT_MACRO:

View File

@ -195,7 +195,7 @@ double GERBVIEW_FRAME::BestZoom()
double y = (double) bbox.GetHeight() / (double) size.y;
GetScreen()->SetScrollCenterPosition( bbox.Centre() );
double best_zoom = MAX( x, y );
double best_zoom = std::max( x, y );
return best_zoom;
}

View File

@ -358,7 +358,7 @@ static void fillArcPOLY( GERBER_DRAW_ITEM* aGbrItem,
int arc_angle = start_angle - end_angle;
// Approximate arc by 36 segments per 360 degree
const int increment_angle = 3600 / 36;
int count = ABS( arc_angle / increment_angle );
int count = std::abs( arc_angle / increment_angle );
// calculate polygon corners
// when arc is counter-clockwise, dummyGbrItem arc goes from end to start

View File

@ -56,18 +56,6 @@ static inline const wxChar* GetChars( const wxString& s )
#endif
}
#ifndef MIN
#define MIN( x, y ) ( (x) > (y) ? (y) : (x) )
#endif
#ifndef MAX
#define MAX( x, y ) ( (x) > (y) ? (x) : (y) )
#endif
#ifndef ABS
#define ABS( y ) ( (y) >= 0 ? (y) : ( -(y) ) )
#endif
#define NEGATE( x ) (x = -x)
/// # of elements in an array

View File

@ -31,7 +31,6 @@
#include <appl_wxstruct.h>
#include <confirm.h>
#include <gestfich.h>
#include <macros.h>
#include <kicad.h>
#include <tree_project_frame.h>
@ -60,7 +59,7 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent,
m_RightWin = NULL; /* A shashwindow that contains the buttons
* and the window display text
*/
m_LeftWin_Width = MAX( 60, GetSize().x/3 );
m_LeftWin_Width = std::max( 60, GetSize().x/3 );
LoadSettings();

View File

@ -1045,7 +1045,7 @@ void CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1,
if( trace & 2 )
{
data = RoutingMatrix.GetDist( row, col, TOP );
data = MAX( data, LocalKeepOut );
data = std::max( data, LocalKeepOut );
RoutingMatrix.SetDist( row, col, TOP, data );
}
}
@ -1171,7 +1171,7 @@ static MODULE* PickModule( PCB_EDIT_FRAME* pcbframe, wxDC* DC )
*
* This function can request some iterations
* Iterations are made until no cell is added to the zone.
* @return: added cells count (i.e. which the attribute CELL_is_ZONE is set)
* @return added cells count (i.e. which the attribute CELL_is_ZONE is set)
*/
int propagate()
{
@ -1182,7 +1182,7 @@ int propagate()
#define NO_CELL_ZONE (HOLE | CELL_is_EDGE | CELL_is_ZONE)
pt_cell_V.reserve( MAX( RoutingMatrix.m_Nrows, RoutingMatrix.m_Ncols ) );
pt_cell_V.reserve( std::max( RoutingMatrix.m_Nrows, RoutingMatrix.m_Ncols ) );
fill( pt_cell_V.begin(), pt_cell_V.end(), 0 );
// Search from left to right and top to bottom.

View File

@ -1,6 +1,7 @@
/**********************************************/
/* board_items_to_polygon_shape_transform.cpp */
/**********************************************/
/***
* @file board_items_to_polygon_shape_transform.cpp
* @brief function to convert shapes of items ( pads, tracks... ) to polygons
*/
/* Function to convert pads and tranck shapes to polygons
* Used to fill zones areas
@ -12,8 +13,6 @@
#include <pcbnew.h>
#include <wxPcbStruct.h>
#include <trigo.h>
#include <macros.h>
#include <class_pad.h>
#include <class_track.h>
#include <class_drawsegment.h>
@ -294,8 +293,8 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor
default:
case PAD_TRAPEZOID:
psize.x += ABS( m_DeltaSize.y );
psize.y += ABS( m_DeltaSize.x );
psize.x += std::abs( m_DeltaSize.y );
psize.y += std::abs( m_DeltaSize.x );
// fall through
case PAD_RECT:

View File

@ -305,7 +305,7 @@ int BOARD::GetBiggestClearanceValue()
for( NETCLASSES::const_iterator nc = m_NetClasses.begin(); nc != m_NetClasses.end(); nc++ )
{
NETCLASS* netclass = nc->second;
clearance = MAX( clearance, netclass->GetClearance() );
clearance = std::max( clearance, netclass->GetClearance() );
}
return clearance;
@ -320,7 +320,7 @@ int BOARD::GetSmallestClearanceValue()
for( NETCLASSES::const_iterator nc = m_NetClasses.begin(); nc != m_NetClasses.end(); nc++ )
{
NETCLASS* netclass = nc->second;
clearance = MIN( clearance, netclass->GetClearance() );
clearance = std::min( clearance, netclass->GetClearance() );
}
return clearance;
@ -2152,7 +2152,7 @@ MODULE* BOARD::GetFootprint( const wxPoint& aPosition, int aActiveLayer,
//off x & offy point to the middle of the box.
int dist = abs( aPosition.x - offx ) + abs( aPosition.y - offy );
//int dist = MIN(lx, ly); // to pick the smallest module (kinda
//int dist = std::min(lx, ly); // to pick the smallest module (kinda
// screwy with same-sized modules -- this is bad!)
if( aActiveLayer == layer )

View File

@ -565,23 +565,23 @@ EDA_RECT DIMENSION::GetBoundingBox() const
ymin = bBox.GetY();
ymax = bBox.GetBottom();
xmin = MIN( xmin, m_crossBarOx );
xmin = MIN( xmin, m_crossBarFx );
ymin = MIN( ymin, m_crossBarOy );
ymin = MIN( ymin, m_crossBarFy );
xmax = MAX( xmax, m_crossBarOx );
xmax = MAX( xmax, m_crossBarFx );
ymax = MAX( ymax, m_crossBarOy );
ymax = MAX( ymax, m_crossBarFy );
xmin = std::min( xmin, m_crossBarOx );
xmin = std::min( xmin, m_crossBarFx );
ymin = std::min( ymin, m_crossBarOy );
ymin = std::min( ymin, m_crossBarFy );
xmax = std::max( xmax, m_crossBarOx );
xmax = std::max( xmax, m_crossBarFx );
ymax = std::max( ymax, m_crossBarOy );
ymax = std::max( ymax, m_crossBarFy );
xmin = MIN( xmin, m_featureLineGOx );
xmin = MIN( xmin, m_featureLineGFx );
ymin = MIN( ymin, m_featureLineGOy );
ymin = MIN( ymin, m_featureLineGFy );
xmax = MAX( xmax, m_featureLineGOx );
xmax = MAX( xmax, m_featureLineGFx );
ymax = MAX( ymax, m_featureLineGOy );
ymax = MAX( ymax, m_featureLineGFy );
xmin = std::min( xmin, m_featureLineGOx );
xmin = std::min( xmin, m_featureLineGFx );
ymin = std::min( ymin, m_featureLineGOy );
ymin = std::min( ymin, m_featureLineGFy );
xmax = std::max( xmax, m_featureLineGOx );
xmax = std::max( xmax, m_featureLineGFx );
ymax = std::max( ymax, m_featureLineGOy );
ymax = std::max( ymax, m_featureLineGFy );
bBox.SetX( xmin );
bBox.SetY( ymin );

View File

@ -403,10 +403,10 @@ EDA_RECT DRAWSEGMENT::GetBoundingBox() const
if( ii == 0 )
p_end = pt;
bbox.SetX( MIN( bbox.GetX(), pt.x ) );
bbox.SetY( MIN( bbox.GetY(), pt.y ) );
p_end.x = MAX( p_end.x, pt.x );
p_end.y = MAX( p_end.y, pt.y );
bbox.SetX( std::min( bbox.GetX(), pt.x ) );
bbox.SetY( std::min( bbox.GetY(), pt.y ) );
p_end.x = std::max( p_end.x, pt.x );
p_end.y = std::max( p_end.y, pt.y );
}
bbox.SetEnd( p_end );

View File

@ -46,8 +46,6 @@
#include <3d_struct.h>
#include <drag.h>
#include <protos.h>
#include <class_board.h>
#include <class_edge_mod.h>
#include <class_module.h>
@ -392,7 +390,7 @@ void MODULE::DrawEdgesOnly( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offs
void MODULE::CalculateBoundingBox()
{
m_BoundaryBox = GetFootPrintRect();
m_Surface = ABS( (double) m_BoundaryBox.GetWidth() * m_BoundaryBox.GetHeight() );
m_Surface = std::abs( (double) m_BoundaryBox.GetWidth() * m_BoundaryBox.GetHeight() );
}

View File

@ -97,7 +97,7 @@ int D_PAD::boundingRadius() const
break;
case PAD_OVAL:
radius = MAX( m_Size.x, m_Size.y ) / 2;
radius = std::max( m_Size.x, m_Size.y ) / 2;
break;
case PAD_RECT:
@ -106,8 +106,8 @@ int D_PAD::boundingRadius() const
break;
case PAD_TRAPEZOID:
x = m_Size.x + ABS( m_DeltaSize.y ); // Remember: m_DeltaSize.y is the m_Size.x change
y = m_Size.y + ABS( m_DeltaSize.x ); // Remember: m_DeltaSize.x is the m_Size.y change
x = m_Size.x + std::abs( m_DeltaSize.y ); // Remember: m_DeltaSize.y is the m_Size.x change
y = m_Size.y + std::abs( m_DeltaSize.x ); // Remember: m_DeltaSize.x is the m_Size.y change
radius = 1 + (int) ( sqrt( (double) y * y + (double) x * x ) / 2 );
break;
@ -390,7 +390,7 @@ int D_PAD::GetSolderMaskMargin()
// ensure mask have a size always >= 0
if( margin < 0 )
{
int minsize = -MIN( m_Size.x, m_Size.y ) / 2;
int minsize = -std::min( m_Size.x, m_Size.y ) / 2;
if( margin < minsize )
minsize = minsize;

View File

@ -38,12 +38,8 @@
#include <layers_id_colors_and_visibility.h>
#include <wxBasePcbFrame.h>
#include <pcbcommon.h>
#include <macros.h>
#include <pcbnew_id.h> // ID_TRACK_BUTT
#include <pcbnew.h>
#include <colors_selection.h>
#include <class_board.h>
@ -544,7 +540,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
/* Draw "No connect" ( / or \ or cross X ) if necessary. : */
if( m_Netname.IsEmpty() && aDrawInfo.m_ShowNCMark )
{
int dx0 = MIN( halfsize.x, halfsize.y );
int dx0 = std::min( halfsize.x, halfsize.y );
EDA_COLOR_T nc_color = BLUE;
if( m_layerMask & LAYER_FRONT ) /* Draw \ */
@ -627,7 +623,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
if( shortname_len == 0 )
return;
shortname_len = MAX( shortname_len, MIN_CHAR_COUNT );
shortname_len = std::max( shortname_len, MIN_CHAR_COUNT );
tsize = std::min( AreaSize.y, AreaSize.x / shortname_len );
if( aDC->LogicalToDeviceXRel( tsize ) >= CHAR_SIZE_MIN ) // Not drawable in size too small.

View File

@ -39,14 +39,10 @@
#include <pcbcommon.h>
#include <colors_selection.h>
#include <wxstruct.h>
#include <macros.h>
#include <wxBasePcbFrame.h>
#include <class_board.h>
#include <class_track.h>
#include <pcbnew.h>
#include <protos.h>
#include <base_units.h>
/**
@ -348,11 +344,11 @@ EDA_RECT TRACK::GetBoundingBox() const
{
radius = ( m_Width + 1 ) / 2;
ymax = MAX( m_Start.y, m_End.y );
xmax = MAX( m_Start.x, m_End.x );
ymax = std::max( m_Start.y, m_End.y );
xmax = std::max( m_Start.x, m_End.x );
ymin = MIN( m_Start.y, m_End.y );
xmin = MIN( m_Start.x, m_End.x );
ymin = std::min( m_Start.y, m_End.y );
xmin = std::min( m_Start.x, m_End.x );
}
if( ShowClearance( this ) )
@ -701,7 +697,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
if( (m_End.x - m_Start.x) != 0 && (m_End.y - m_Start.y) != 0 )
return;
int len = ABS( (m_End.x - m_Start.x) + (m_End.y - m_Start.y) );
int len = std::abs( (m_End.x - m_Start.x) + (m_End.y - m_Start.y) );
if( len < THRESHOLD * m_Width )
return;
@ -722,7 +718,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
if( textlen > 0 )
{
// calculate a good size for the text
int tsize = MIN( m_Width, len / textlen );
int tsize = std::min( m_Width, len / textlen );
wxPoint tpos = m_Start + m_End;
tpos.x /= 2;
tpos.y /= 2;

View File

@ -372,10 +372,10 @@ EDA_RECT ZONE_CONTAINER::GetBoundingBox() const
{
wxPoint corner = GetCornerPosition( i );
ymax = MAX( ymax, corner.y );
xmax = MAX( xmax, corner.x );
ymin = MIN( ymin, corner.y );
xmin = MIN( xmin, corner.x );
ymax = std::max( ymax, corner.y );
xmax = std::max( xmax, corner.x );
ymin = std::min( ymin, corner.y );
xmin = std::min( xmin, corner.x );
}
EDA_RECT ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
@ -497,7 +497,7 @@ bool ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos )
delta.y = refPos.y - m_Poly->m_CornersList[item_pos].y;
// Calculate a distance:
int dist = MAX( abs( delta.x ), abs( delta.y ) );
int dist = std::max( abs( delta.x ), abs( delta.y ) );
if( dist < min_dist ) // this corner is a candidate:
{

View File

@ -32,10 +32,7 @@
#include <class_drawpanel.h>
#include <wxPcbStruct.h>
#include <pcbcommon.h>
#include <macros.h>
#include <pcbnew_id.h>
#include <class_board.h>
#include <class_module.h>
@ -78,7 +75,7 @@ static BOARD_ITEM* AllAreModulesAndReturnSmallestIfSo( GENERAL_COLLECTOR* aColle
int lx = module->m_BoundaryBox.GetWidth();
int ly = module->m_BoundaryBox.GetHeight();
int lmin = MIN( lx, ly );
int lmin = std::min( lx, ly );
if( lmin < minDim )
{
@ -216,7 +213,7 @@ BOARD_ITEM* PCB_BASE_FRAME::PcbGeneralLocateAndDisplay( int aHotKeyCode )
itemMenu.Append( item_title );
itemMenu.AppendSeparator();
int limit = MIN( MAX_ITEMS_IN_PICKER, m_Collector->GetCount() );
int limit = std::min( MAX_ITEMS_IN_PICKER, m_Collector->GetCount() );
for( int i = 0; i<limit; ++i )
{

View File

@ -240,9 +240,7 @@ void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile )
}
/*
* Actual print function.
*/
// Actual SVG file export function.
bool DIALOG_SVG_PRINT::CreateSVGFile( const wxString& aFullFileName )
{
BOARD* brd = m_Parent->GetBoard();
@ -253,7 +251,7 @@ bool DIALOG_SVG_PRINT::CreateSVGFile( const wxString& aFullFileName )
m_plotOpts.SetDrillMarksType( PCB_PLOT_PARAMS::FULL_DRILL_SHAPE );
m_plotOpts.SetMirror( m_printMirror );
m_plotOpts.SetFormat( PLOT_FORMAT_SVG );
EDA_COLOR_T color = BLACK;
EDA_COLOR_T color = UNSPECIFIED_COLOR; // Used layer color to plot ref and value
m_plotOpts.SetReferenceColor( color );
m_plotOpts.SetValueColor( color );

View File

@ -32,9 +32,7 @@
*/
#include <fctsys.h>
#include <class_drawpanel.h>
#include <macros.h>
#include <base_units.h>
#include <confirm.h>
#include <pcbnew.h>
#include <wxPcbStruct.h>
@ -431,8 +429,8 @@ void DIALOG_DESIGN_RULES::FillListBoxWithNetNames( NETS_LIST_CTRL* aListCtrl,
{
wxSize net_needed = sDC.GetTextExtent( (*i)->net );
wxSize class_needed = sDC.GetTextExtent( (*i)->clazz );
net_colsize = MAX( net_colsize, net_needed.x );
class_colsize = MAX( class_colsize, class_needed.x );
net_colsize = std::max( net_colsize, net_needed.x );
class_colsize = std::max( class_colsize, class_needed.x );
aListCtrl->setRowItems( row, (*i)->net, (*i)->clazz );
}

View File

@ -202,19 +202,19 @@ void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 );
// Calculate a suitable scale to fit the available draw area
int dim = m_dummyPad->GetSize().x + ABS( m_dummyPad->GetDelta().y);
int dim = m_dummyPad->GetSize().x + std::abs( m_dummyPad->GetDelta().y);
if( m_dummyPad->GetLocalClearance() > 0 )
dim += m_dummyPad->GetLocalClearance() * 2;
double scale = (double) dc_size.x / dim;
dim = m_dummyPad->GetSize().y + ABS( m_dummyPad->GetDelta().x);
dim = m_dummyPad->GetSize().y + std::abs( m_dummyPad->GetDelta().x);
if( m_dummyPad->GetLocalClearance() > 0 )
dim += m_dummyPad->GetLocalClearance() * 2;
double altscale = (double) dc_size.y / dim;
scale = MIN( scale, altscale );
scale = std::min( scale, altscale );
// Give a margin
scale *= 0.7;
@ -690,8 +690,8 @@ if you do not want this pad plotted in gerber files");
}
wxPoint max_size;
max_size.x = ABS( m_dummyPad->GetOffset().x );
max_size.y = ABS( m_dummyPad->GetOffset().y );
max_size.x = std::abs( m_dummyPad->GetOffset().x );
max_size.y = std::abs( m_dummyPad->GetOffset().y );
max_size.x += m_dummyPad->GetDrillSize().x / 2;
max_size.y += m_dummyPad->GetDrillSize().y / 2;
if( ( m_dummyPad->GetSize().x / 2 < max_size.x ) ||

View File

@ -663,8 +663,8 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad )
// Test DRC:
diag = false;
RotatePoint( &relativePadPos, aRefPad->GetOrientation() );
relativePadPos.x = ABS( relativePadPos.x );
relativePadPos.y = ABS( relativePadPos.y );
relativePadPos.x = std::abs( relativePadPos.x );
relativePadPos.y = std::abs( relativePadPos.y );
if( ( relativePadPos.x - ( (size.x + aRefPad->GetSize().x) / 2 ) ) >= dist_min )
diag = true;
@ -804,8 +804,8 @@ bool DRC::checkClearanceSegmToPad( const D_PAD* aPad, int aSegmentWidth, int aMi
if( aPad->GetShape() == PAD_TRAPEZOID ) // The size is bigger, due to GetDelta() extra size
{
padHalfsize.x += ABS(aPad->GetDelta().y) / 2; // Remember: GetDelta().y is the GetSize().x change
padHalfsize.y += ABS(aPad->GetDelta().x) / 2; // Remember: GetDelta().x is the GetSize().y change
padHalfsize.x += std::abs(aPad->GetDelta().y) / 2; // Remember: GetDelta().y is the GetSize().x change
padHalfsize.y += std::abs(aPad->GetDelta().x) / 2; // Remember: GetDelta().x is the GetSize().y change
}
if( aPad->GetShape() == PAD_CIRCLE )

View File

@ -77,7 +77,7 @@ TEXTE_MODULE* PCB_BASE_FRAME::CreateTextModule( MODULE* Module, wxDC* DC )
Text->m_Text = wxT( "text" );
GetDesignSettings().m_ModuleTextWidth = Clamp_Text_PenSize( GetDesignSettings().m_ModuleTextWidth,
MIN( GetDesignSettings().m_ModuleTextSize.x, GetDesignSettings().m_ModuleTextSize.y ), true );
std::min( GetDesignSettings().m_ModuleTextSize.x, GetDesignSettings().m_ModuleTextSize.y ), true );
Text->m_Size = GetDesignSettings().m_ModuleTextSize;
Text->m_Thickness = GetDesignSettings().m_ModuleTextWidth;
Text->m_Pos = GetScreen()->GetCrossHairPosition();

View File

@ -913,7 +913,7 @@ static void export_vrml_pad( BOARD* pcb, D_PAD* aPad ) //{{{
{
double hole_drill_w = (double) aPad->GetDrillSize().x / 2;
double hole_drill_h = (double) aPad->GetDrillSize().y / 2;
double hole_drill = MIN( hole_drill_w, hole_drill_h );
double hole_drill = std::min( hole_drill_w, hole_drill_h );
double hole_x = aPad->GetPosition().x;
double hole_y = aPad->GetPosition().y;

View File

@ -335,7 +335,7 @@ int EXCELLON_WRITER::CreateDrillFile()
fprintf( m_file, "T%d\n", tool_reference );
}
diam = MIN( hole_descr.m_Hole_Size.x,
diam = std::min( hole_descr.m_Hole_Size.x,
hole_descr.m_Hole_Size.y );
if( diam == 0 )
continue;

View File

@ -6,7 +6,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
@ -28,6 +28,7 @@
*/
#include <fctsys.h>
#include <algorithm>
#include <wxstruct.h>
#include <kicad_string.h>
#include <trigo.h>
@ -283,7 +284,7 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
int tsize = ( ibuf[idx+3] * TEXT_DEFAULT_SIZE ) / 100;
int thickness = m_Reference->m_Size.x / 6;
tsize = MAX( 40, tsize );
tsize = std::max( (int)(5 * IU_PER_MILS), tsize ); // Ensure a minimal size = 5 mils
m_Reference->SetSize( wxSize( tsize, tsize ) );
m_Reference->m_Thickness = thickness;
m_Value->SetOrientation( m_Reference->GetOrientation() );

View File

@ -581,7 +581,7 @@ wxSize LAYER_WIDGET::GetBestSize() const
wxSize layerz = m_LayersFlexGridSizer->GetMinSize();
wxSize renderz = m_RenderFlexGridSizer->GetMinSize();
wxSize clientz( MAX(renderz.x,layerz.x), MAX(renderz.y,layerz.y) );
wxSize clientz( std::max(renderz.x,layerz.x), std::max(renderz.y,layerz.y) );
return ClientToWindowSize( clientz );
@ -656,7 +656,7 @@ wxSize LAYER_WIDGET::GetBestSize() const
renderz += m_RenderingPanel->GetWindowBorderSize();
wxSize clientz( MAX(renderz.x,layerz.x), MAX(renderz.y,layerz.y) );
wxSize clientz( std::max(renderz.x,layerz.x), std::max(renderz.y,layerz.y) );
// wxSize diffz( GetSize() - GetClientSize() );
// clientz += diffz;

View File

@ -102,7 +102,7 @@ BOARD_ITEM* FOOTPRINT_EDIT_FRAME::ModeditLocateAndDisplay( int aHotKeyCode )
itemMenu.Append( item_title );
itemMenu.AppendSeparator();
int limit = MIN( MAX_ITEMS_IN_PICKER, m_Collector->GetCount() );
int limit = std::min( MAX_ITEMS_IN_PICKER, m_Collector->GetCount() );
for( int ii = 0; ii<limit; ++ii )
{

View File

@ -413,7 +413,7 @@ int BuildCornersList_S_Shape( std::vector <wxPoint>& aBuffer,
size.y = min_len;
// Choose a reasonable starting value for the radius of the arcs.
int radius = MIN( aWidth * 5, size.x / 4 );
int radius = std::min( aWidth * 5, size.x / 4 );
int segm_count; // number of full len segments
// the half size segments (first and last segment) are not counted here
@ -647,7 +647,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type )
abort = true;
}
angle = ABS( KiROUND( fval * fcoeff ) );
angle = std::abs( KiROUND( fval * fcoeff ) );
if( angle > 1800 )
angle = 1800;
@ -1016,8 +1016,10 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape()
pad2->SetX0( last_coordinate.x );
polyPoints.push_back( wxPoint( last_coordinate.x, 0 ) );
pad1->SetSize( wxSize( ABS( first_coordinate.y ), ABS( first_coordinate.y ) ) );
pad2->SetSize( wxSize( ABS( last_coordinate.y ), ABS( last_coordinate.y ) ) );
pad1->SetSize( wxSize( std::abs( first_coordinate.y ),
std::abs( first_coordinate.y ) ) );
pad2->SetSize( wxSize( std::abs( last_coordinate.y ),
std::abs( last_coordinate.y ) ) );
pad1->SetY0( first_coordinate.y / 2 );
pad2->SetY0( last_coordinate.y / 2 );
@ -1036,8 +1038,10 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape()
polyPoints.push_back( pt );
}
pad1->SetSize( wxSize( 2 * ABS( first_coordinate.y ), 2 * ABS( first_coordinate.y ) ) );
pad2->SetSize( wxSize( 2 * ABS( last_coordinate.y ), 2 * ABS( last_coordinate.y ) ) );
pad1->SetSize( wxSize( 2 * std::abs( first_coordinate.y ),
2 * std::abs( first_coordinate.y ) ) );
pad2->SetSize( wxSize( 2 * std::abs( last_coordinate.y ),
2 * std::abs( last_coordinate.y ) ) );
break;
}

View File

@ -71,10 +71,20 @@ bool BRDITEMS_PLOTTER::PlotAllTextsModule( MODULE* aModule )
// Plot text fields, if allowed
if( trace_ref )
{
if( GetReferenceColor() == UNSPECIFIED_COLOR )
PlotTextModule( aModule->m_Reference, getColor( textLayer ) );
else
PlotTextModule( aModule->m_Reference, GetReferenceColor() );
}
if( trace_val )
{
if( GetValueColor() == UNSPECIFIED_COLOR )
PlotTextModule( aModule->m_Value, getColor( textLayer ) );
else
PlotTextModule( aModule->m_Value, GetValueColor() );
}
for( textModule = (TEXTE_MODULE*) aModule->m_Drawings.GetFirst();
textModule != NULL; textModule = textModule->Next() )

View File

@ -9,7 +9,6 @@
#include <class_drawpanel.h>
#include <colors_selection.h>
#include <wxBasePcbFrame.h>
#include <macros.h>
#include <class_board.h>
#include <class_module.h>
@ -462,7 +461,7 @@ void PCB_BASE_FRAME::TestForActiveLinksInRatsnest( int aNetCode )
pad = net->m_PadInNetList[ip];
int subnet = pad->GetSubNet();
pad->SetSubRatsnest( subnet );
subratsnest = MAX( subratsnest, subnet );
subratsnest = std::max( subratsnest, subnet );
}
for( unsigned ii = net->m_RatsnestStartIdx; ii < net->m_RatsnestEndIdx; ii++ )

View File

@ -33,10 +33,7 @@
#include <boost/ptr_container/ptr_set.hpp>
#include <fctsys.h>
#include <macros.h> // MAX definition.
#include <specctra_lexer.h>
#include <pcbnew.h>
@ -618,7 +615,7 @@ public:
quote, layer_id.c_str(), quote,
aperture_width );
int wrapNest = MAX( nestLevel+1, 6 );
int wrapNest = std::max( nestLevel+1, 6 );
for( unsigned i=0; i<points.size(); ++i )
{
if( perLine > RIGHTMARGIN )

View File

@ -314,7 +314,7 @@ void Merge_SubNets_Connected_By_CopperAreas( BOARD* aPcb, int aNetcode )
for( unsigned ii = 0; ii < Candidates.size(); ii++ )
{
int subnet = Candidates[ii]->GetSubNet();
next_subnet_free_number = MAX( next_subnet_free_number, subnet );
next_subnet_free_number = std::max( next_subnet_free_number, subnet );
}
next_subnet_free_number++; // This is a subnet we can use with not connected items