diff --git a/common/base_struct.cpp b/common/base_struct.cpp index c108c37689..3b9cb8d3e6 100644 --- a/common/base_struct.cpp +++ b/common/base_struct.cpp @@ -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 ); } diff --git a/common/class_marker_base.cpp b/common/class_marker_base.cpp index 82188b8cac..b8aa30a058 100644 --- a/common/class_marker_base.cpp +++ b/common/class_marker_base.cpp @@ -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); diff --git a/common/common_plotPS_functions.cpp b/common/common_plotPS_functions.cpp index 44e00aa6c0..a08f4d4fc2 100644 --- a/common/common_plotPS_functions.cpp +++ b/common/common_plotPS_functions.cpp @@ -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 ); diff --git a/common/common_plot_functions.cpp b/common/common_plot_functions.cpp index b312937e91..4cd61a8317 100644 --- a/common/common_plot_functions.cpp +++ b/common/common_plot_functions.cpp @@ -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: diff --git a/common/drawpanel.cpp b/common/drawpanel.cpp index f65ae44873..e890a0c710 100644 --- a/common/drawpanel.cpp +++ b/common/drawpanel.cpp @@ -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 ) { diff --git a/common/drawtxt.cpp b/common/drawtxt.cpp index 0386ce3f4c..4fcd3e9163 100644 --- a/common/drawtxt.cpp +++ b/common/drawtxt.cpp @@ -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 ); diff --git a/common/eda_text.cpp b/common/eda_text.cpp index 35bda7bed7..31085c60e2 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -29,7 +29,6 @@ #include #include -#include // MAX #include // RotatePoint #include // 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; } } diff --git a/common/gr_basic.cpp b/common/gr_basic.cpp index bfe4b3952e..3b43ca1894 100644 --- a/common/gr_basic.cpp +++ b/common/gr_basic.cpp @@ -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(); diff --git a/common/selcolor.cpp b/common/selcolor.cpp index abb0d7e420..f4b395bf09 100644 --- a/common/selcolor.cpp +++ b/common/selcolor.cpp @@ -7,10 +7,8 @@ #include #include - #include #include -#include #include @@ -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 ) diff --git a/common/worksheet.cpp b/common/worksheet.cpp index 9e79735fc5..ff7440ca64 100644 --- a/common/worksheet.cpp +++ b/common/worksheet.cpp @@ -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; diff --git a/common/zoom.cpp b/common/zoom.cpp index 572d197a07..6cd768d03b 100644 --- a/common/zoom.cpp +++ b/common/zoom.cpp @@ -31,7 +31,6 @@ */ #include -#include #include #include #include @@ -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 ); diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index 1939c3ff89..8d79ffad50 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -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; diff --git a/eeschema/component_references_lister.cpp b/eeschema/component_references_lister.cpp index aea5f020ef..d79d987f03 100644 --- a/eeschema/component_references_lister.cpp +++ b/eeschema/component_references_lister.cpp @@ -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 ) diff --git a/eeschema/database.cpp b/eeschema/database.cpp index 0144c3f6b5..355e4d0ddb 100644 --- a/eeschema/database.cpp +++ b/eeschema/database.cpp @@ -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 +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(); -} diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index 1d10993dea..6a0495e733 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -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 ); diff --git a/eeschema/dialogs/dialog_lib_edit_pin.cpp b/eeschema/dialogs/dialog_lib_edit_pin.cpp index 54e5b78c22..245ebd628b 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin.cpp @@ -1,153 +1,153 @@ -#include -#include -#include -#include - -#include -#include -#include - -#include - -DIALOG_LIB_EDIT_PIN::DIALOG_LIB_EDIT_PIN( wxWindow* parent, LIB_PIN* aPin ) : - DIALOG_LIB_EDIT_PIN_BASE( parent ) -{ - // Creates a dummy pin to show on a panel, inside this dialog: - m_dummyPin = new LIB_PIN( *aPin ); - - // m_dummyPin changes do not propagate to other pins of the current lib component, - // so set parent to null and clear flags - m_dummyPin->SetParent( NULL ); - m_dummyPin->ClearFlags(); - - m_panelShowPin->SetBackgroundColour( MakeColour( g_DrawBgColor ) ); - - // Set tab order - m_textPadName->MoveAfterInTabOrder(m_textPinName); - m_sdbSizerButtonsOK->SetDefault(); -} - - -DIALOG_LIB_EDIT_PIN::~DIALOG_LIB_EDIT_PIN() -{ - delete m_dummyPin; -} - - -/* - * Draw (on m_panelShowPin) the pin currently edited - * accroding to current settings in dialog - */ -void DIALOG_LIB_EDIT_PIN::OnPaintShowPanel( wxPaintEvent& event ) -{ - wxPaintDC dc( m_panelShowPin ); - wxSize dc_size = dc.GetSize(); - dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 ); - - // Give a parent to m_dummyPin only from draw purpose. - // In fact m_dummyPin should not have a parent, but draw functions need a parent - // to know some options, about pin texts - LIB_EDIT_FRAME* libframe = (LIB_EDIT_FRAME*) GetParent(); - m_dummyPin->SetParent( libframe->GetComponent() ); - - // Calculate a suitable scale to fit the available draw area - 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 ); - - // Give a 10% margin - scale *= 0.9; - dc.SetUserScale( scale, scale ); - - wxPoint offset = bBox.Centre(); - NEGATE( offset.x ); - NEGATE( offset.y ); - - GRResetPenAndBrush( &dc ); - m_dummyPin->Draw( NULL, &dc, offset, UNSPECIFIED_COLOR, GR_COPY, - NULL, DefaultTransform ); - - m_dummyPin->SetParent(NULL); - - event.Skip(); -} - -void DIALOG_LIB_EDIT_PIN::OnCloseDialog( wxCloseEvent& event ) -{ - EndModal( wxID_CANCEL ); -} - -void DIALOG_LIB_EDIT_PIN::OnCancelButtonClick( wxCommandEvent& event ) -{ - EndModal( wxID_CANCEL ); -} - -void DIALOG_LIB_EDIT_PIN::OnOKButtonClick( wxCommandEvent& event ) -{ - EndModal( wxID_OK ); -} - -// Called when a pin properties changes -void DIALOG_LIB_EDIT_PIN::OnPropertiesChange( wxCommandEvent& event ) -{ - if( ! IsShown() ) // do nothing at init time - return; - - int pinNameSize = ReturnValueFromString( g_UserUnit, GetNameTextSize() ); - int pinNumSize = ReturnValueFromString( g_UserUnit, GetPadNameTextSize()); - int pinOrient = LIB_PIN::GetOrientationCode( GetOrientation() ); - int pinLength = ReturnValueFromString( g_UserUnit, GetLength() ); - int pinShape = LIB_PIN::GetStyleCode( GetStyle() ); - int pinType = GetElectricalType(); - - m_dummyPin->SetName( GetName() ); - m_dummyPin->SetNameTextSize( pinNameSize ); - m_dummyPin->SetNumber( GetPadName() ); - m_dummyPin->SetNumberTextSize( pinNumSize ); - m_dummyPin->SetOrientation( pinOrient ); - m_dummyPin->SetLength( pinLength ); - m_dummyPin->SetShape( pinShape ); - m_dummyPin->SetVisible( GetVisible() ); - m_dummyPin->SetType( pinType ); - - m_panelShowPin->Refresh(); -} - - -void DIALOG_LIB_EDIT_PIN::SetOrientationList( const wxArrayString& list, - const BITMAP_DEF* aBitmaps ) -{ - for ( unsigned ii = 0; ii < list.GetCount(); ii++ ) - { - if( aBitmaps == NULL ) - m_choiceOrientation->Append( list[ii] ); - else - m_choiceOrientation->Insert( list[ii], KiBitmap( aBitmaps[ii] ), ii ); - } -} - - -void DIALOG_LIB_EDIT_PIN::SetElectricalTypeList( const wxArrayString& list, - const BITMAP_DEF* aBitmaps ) -{ - for ( unsigned ii = 0; ii < list.GetCount(); ii++ ) - { - if( aBitmaps == NULL ) - m_choiceElectricalType->Append( list[ii] ); - else - m_choiceElectricalType->Insert( list[ii], KiBitmap( aBitmaps[ii] ), ii ); - } -} - - -void DIALOG_LIB_EDIT_PIN::SetStyleList( const wxArrayString& list, const BITMAP_DEF* aBitmaps ) -{ - for ( unsigned ii = 0; ii < list.GetCount(); ii++ ) - { - if( aBitmaps == NULL ) - m_choiceStyle->Append( list[ii] ); - else - m_choiceStyle->Insert( list[ii], KiBitmap( aBitmaps[ii] ), ii ); - } -} +#include +#include +#include +#include + +#include +#include +#include + +#include + +DIALOG_LIB_EDIT_PIN::DIALOG_LIB_EDIT_PIN( wxWindow* parent, LIB_PIN* aPin ) : + DIALOG_LIB_EDIT_PIN_BASE( parent ) +{ + // Creates a dummy pin to show on a panel, inside this dialog: + m_dummyPin = new LIB_PIN( *aPin ); + + // m_dummyPin changes do not propagate to other pins of the current lib component, + // so set parent to null and clear flags + m_dummyPin->SetParent( NULL ); + m_dummyPin->ClearFlags(); + + m_panelShowPin->SetBackgroundColour( MakeColour( g_DrawBgColor ) ); + + // Set tab order + m_textPadName->MoveAfterInTabOrder(m_textPinName); + m_sdbSizerButtonsOK->SetDefault(); +} + + +DIALOG_LIB_EDIT_PIN::~DIALOG_LIB_EDIT_PIN() +{ + delete m_dummyPin; +} + + +/* + * Draw (on m_panelShowPin) the pin currently edited + * accroding to current settings in dialog + */ +void DIALOG_LIB_EDIT_PIN::OnPaintShowPanel( wxPaintEvent& event ) +{ + wxPaintDC dc( m_panelShowPin ); + wxSize dc_size = dc.GetSize(); + dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 ); + + // Give a parent to m_dummyPin only from draw purpose. + // In fact m_dummyPin should not have a parent, but draw functions need a parent + // to know some options, about pin texts + LIB_EDIT_FRAME* libframe = (LIB_EDIT_FRAME*) GetParent(); + m_dummyPin->SetParent( libframe->GetComponent() ); + + // Calculate a suitable scale to fit the available draw area + EDA_RECT bBox = m_dummyPin->GetBoundingBox(); + double xscale = (double) dc_size.x / bBox.GetWidth(); + double yscale = (double) dc_size.y / bBox.GetHeight(); + double scale = std::min( xscale, yscale ); + + // Give a 10% margin + scale *= 0.9; + dc.SetUserScale( scale, scale ); + + wxPoint offset = bBox.Centre(); + NEGATE( offset.x ); + NEGATE( offset.y ); + + GRResetPenAndBrush( &dc ); + m_dummyPin->Draw( NULL, &dc, offset, UNSPECIFIED_COLOR, GR_COPY, + NULL, DefaultTransform ); + + m_dummyPin->SetParent(NULL); + + event.Skip(); +} + +void DIALOG_LIB_EDIT_PIN::OnCloseDialog( wxCloseEvent& event ) +{ + EndModal( wxID_CANCEL ); +} + +void DIALOG_LIB_EDIT_PIN::OnCancelButtonClick( wxCommandEvent& event ) +{ + EndModal( wxID_CANCEL ); +} + +void DIALOG_LIB_EDIT_PIN::OnOKButtonClick( wxCommandEvent& event ) +{ + EndModal( wxID_OK ); +} + +// Called when a pin properties changes +void DIALOG_LIB_EDIT_PIN::OnPropertiesChange( wxCommandEvent& event ) +{ + if( ! IsShown() ) // do nothing at init time + return; + + int pinNameSize = ReturnValueFromString( g_UserUnit, GetNameTextSize() ); + int pinNumSize = ReturnValueFromString( g_UserUnit, GetPadNameTextSize()); + int pinOrient = LIB_PIN::GetOrientationCode( GetOrientation() ); + int pinLength = ReturnValueFromString( g_UserUnit, GetLength() ); + int pinShape = LIB_PIN::GetStyleCode( GetStyle() ); + int pinType = GetElectricalType(); + + m_dummyPin->SetName( GetName() ); + m_dummyPin->SetNameTextSize( pinNameSize ); + m_dummyPin->SetNumber( GetPadName() ); + m_dummyPin->SetNumberTextSize( pinNumSize ); + m_dummyPin->SetOrientation( pinOrient ); + m_dummyPin->SetLength( pinLength ); + m_dummyPin->SetShape( pinShape ); + m_dummyPin->SetVisible( GetVisible() ); + m_dummyPin->SetType( pinType ); + + m_panelShowPin->Refresh(); +} + + +void DIALOG_LIB_EDIT_PIN::SetOrientationList( const wxArrayString& list, + const BITMAP_DEF* aBitmaps ) +{ + for ( unsigned ii = 0; ii < list.GetCount(); ii++ ) + { + if( aBitmaps == NULL ) + m_choiceOrientation->Append( list[ii] ); + else + m_choiceOrientation->Insert( list[ii], KiBitmap( aBitmaps[ii] ), ii ); + } +} + + +void DIALOG_LIB_EDIT_PIN::SetElectricalTypeList( const wxArrayString& list, + const BITMAP_DEF* aBitmaps ) +{ + for ( unsigned ii = 0; ii < list.GetCount(); ii++ ) + { + if( aBitmaps == NULL ) + m_choiceElectricalType->Append( list[ii] ); + else + m_choiceElectricalType->Insert( list[ii], KiBitmap( aBitmaps[ii] ), ii ); + } +} + + +void DIALOG_LIB_EDIT_PIN::SetStyleList( const wxArrayString& list, const BITMAP_DEF* aBitmaps ) +{ + for ( unsigned ii = 0; ii < list.GetCount(); ii++ ) + { + if( aBitmaps == NULL ) + m_choiceStyle->Append( list[ii] ); + else + m_choiceStyle->Insert( list[ii], KiBitmap( aBitmaps[ii] ), ii ); + } +} diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index e3379d1350..bf42e23d0d 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -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; diff --git a/eeschema/hierarch.cpp b/eeschema/hierarch.cpp index 1df71898f5..64cac94fb1 100644 --- a/eeschema/hierarch.cpp +++ b/eeschema/hierarch.cpp @@ -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() ) diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp index cb028bafd3..1c8e8c752d 100644 --- a/eeschema/lib_arc.cpp +++ b/eeschema/lib_arc.cpp @@ -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 ) diff --git a/eeschema/lib_bezier.cpp b/eeschema/lib_bezier.cpp index 54d85b9017..0ce65c0f55 100644 --- a/eeschema/lib_bezier.cpp +++ b/eeschema/lib_bezier.cpp @@ -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; } diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index c0d1d1150c..2b915ac5cf 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -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 diff --git a/eeschema/lib_polyline.cpp b/eeschema/lib_polyline.cpp index 1ea2645c34..5a4024aaa9 100644 --- a/eeschema/lib_polyline.cpp +++ b/eeschema/lib_polyline.cpp @@ -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 ); diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index 3fca9668d8..2ccd893c9b 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -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 diff --git a/eeschema/netlist.cpp b/eeschema/netlist.cpp index 380eacdb97..5eaeb3a0b5 100644 --- a/eeschema/netlist.cpp +++ b/eeschema/netlist.cpp @@ -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]; diff --git a/eeschema/plot_schematic_PDF.cpp b/eeschema/plot_schematic_PDF.cpp index 9777d0411c..51b5884f85 100644 --- a/eeschema/plot_schematic_PDF.cpp +++ b/eeschema/plot_schematic_PDF.cpp @@ -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 ); } diff --git a/eeschema/plot_schematic_PS.cpp b/eeschema/plot_schematic_PS.cpp index cf759c6e6a..1b0d901140 100644 --- a/eeschema/plot_schematic_PS.cpp +++ b/eeschema/plot_schematic_PS.cpp @@ -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( "." ) diff --git a/eeschema/protos.h b/eeschema/protos.h index df1b6ba9fd..e19c93b8d4 100644 --- a/eeschema/protos.h +++ b/eeschema/protos.h @@ -4,7 +4,6 @@ #include - 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 & 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__ */ diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index bfacb238a4..02fe79d40f 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -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 ) ); diff --git a/eeschema/sch_no_connect.cpp b/eeschema/sch_no_connect.cpp index 4412bee4d3..9132c0852c 100644 --- a/eeschema/sch_no_connect.cpp +++ b/eeschema/sch_no_connect.cpp @@ -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; diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 47716a302b..f6bafdf599 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -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 ) ) diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 758ff3da34..be598815d5 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -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; diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 0d648f913d..2edaf2d35d 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -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; diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 8de5113a58..1a0b80e7e6 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -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 ) ); diff --git a/eeschema/selpart.cpp b/eeschema/selpart.cpp index e5d7f4c747..fce25ce44e 100644 --- a/eeschema/selpart.cpp +++ b/eeschema/selpart.cpp @@ -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; diff --git a/eeschema/tool_viewlib.cpp b/eeschema/tool_viewlib.cpp index c6d7651fb3..8c32511a9c 100644 --- a/eeschema/tool_viewlib.cpp +++ b/eeschema/tool_viewlib.cpp @@ -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(); diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index ab6af1b76c..576a96ffae 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -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 diff --git a/gerbview/class_aperture_macro.cpp b/gerbview/class_aperture_macro.cpp index b9714f6bbc..ad390dab10 100644 --- a/gerbview/class_aperture_macro.cpp +++ b/gerbview/class_aperture_macro.cpp @@ -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; diff --git a/gerbview/class_gerber_draw_item.cpp b/gerbview/class_gerber_draw_item.cpp index 2d428d19e9..1604d897dc 100644 --- a/gerbview/class_gerber_draw_item.cpp +++ b/gerbview/class_gerber_draw_item.cpp @@ -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; diff --git a/gerbview/dcode.cpp b/gerbview/dcode.cpp index 14f02bbf54..8bfa1c4c8b 100644 --- a/gerbview/dcode.cpp +++ b/gerbview/dcode.cpp @@ -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: diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 76e218bef1..04afde15f0 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -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; } diff --git a/gerbview/rs274d.cpp b/gerbview/rs274d.cpp index 2ec452dbc6..1256aeaae3 100644 --- a/gerbview/rs274d.cpp +++ b/gerbview/rs274d.cpp @@ -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 diff --git a/include/macros.h b/include/macros.h index 5c635cfa52..c72863456a 100644 --- a/include/macros.h +++ b/include/macros.h @@ -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 diff --git a/kicad/mainframe.cpp b/kicad/mainframe.cpp index 2d4a07e5bd..0df7bd617a 100644 --- a/kicad/mainframe.cpp +++ b/kicad/mainframe.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include @@ -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(); diff --git a/pcbnew/autorouter/autoplac.cpp b/pcbnew/autorouter/autoplac.cpp index 3d8859bd27..e1461b7e6a 100644 --- a/pcbnew/autorouter/autoplac.cpp +++ b/pcbnew/autorouter/autoplac.cpp @@ -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. diff --git a/pcbnew/board_items_to_polygon_shape_transform.cpp b/pcbnew/board_items_to_polygon_shape_transform.cpp index 1e4b6dc8c5..ac07c13ac2 100644 --- a/pcbnew/board_items_to_polygon_shape_transform.cpp +++ b/pcbnew/board_items_to_polygon_shape_transform.cpp @@ -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 #include #include -#include - #include #include #include @@ -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: diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 57409d3b16..9ca6d13c59 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -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 ) diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp index 31aa1080fa..9ae2970812 100644 --- a/pcbnew/class_dimension.cpp +++ b/pcbnew/class_dimension.cpp @@ -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 ); diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index 6761f8e73e..e591022d71 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -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 ); diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index bfa7e81bd2..0aaedbace2 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -46,8 +46,6 @@ #include <3d_struct.h> #include - -#include #include #include #include @@ -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() ); } diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index 856a26d68b..47eace8b8d 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -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; diff --git a/pcbnew/class_pad_draw_functions.cpp b/pcbnew/class_pad_draw_functions.cpp index ab938c3e62..e9cc99131e 100644 --- a/pcbnew/class_pad_draw_functions.cpp +++ b/pcbnew/class_pad_draw_functions.cpp @@ -38,12 +38,8 @@ #include #include #include -#include - #include // ID_TRACK_BUTT #include -#include - #include @@ -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. diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index 8266895241..2dd7f14d3c 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -39,14 +39,10 @@ #include #include #include -#include #include - #include #include - #include -#include #include /** @@ -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; diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index 7b57d5f303..7f721af36e 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -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: { diff --git a/pcbnew/controle.cpp b/pcbnew/controle.cpp index 5d984f12e3..8e4c8f5915 100644 --- a/pcbnew/controle.cpp +++ b/pcbnew/controle.cpp @@ -32,10 +32,7 @@ #include #include #include -#include - #include - #include #include @@ -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; iGetBoard(); @@ -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 ); diff --git a/pcbnew/dialogs/dialog_design_rules.cpp b/pcbnew/dialogs/dialog_design_rules.cpp index 4732ebf45d..d36f3baaac 100644 --- a/pcbnew/dialogs/dialog_design_rules.cpp +++ b/pcbnew/dialogs/dialog_design_rules.cpp @@ -32,9 +32,7 @@ */ #include #include -#include #include - #include #include #include @@ -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 ); } diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index c88ddea5bc..e2757c1531 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -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 ) || diff --git a/pcbnew/drc_clearance_test_functions.cpp b/pcbnew/drc_clearance_test_functions.cpp index 8ebea8231c..4bb6475789 100644 --- a/pcbnew/drc_clearance_test_functions.cpp +++ b/pcbnew/drc_clearance_test_functions.cpp @@ -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 ) diff --git a/pcbnew/edtxtmod.cpp b/pcbnew/edtxtmod.cpp index 28e7e8a1af..16851abab6 100644 --- a/pcbnew/edtxtmod.cpp +++ b/pcbnew/edtxtmod.cpp @@ -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(); diff --git a/pcbnew/export_vrml.cpp b/pcbnew/export_vrml.cpp index 48c4d1fe1e..33ff523f0c 100644 --- a/pcbnew/export_vrml.cpp +++ b/pcbnew/export_vrml.cpp @@ -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; diff --git a/pcbnew/gendrill.cpp b/pcbnew/gendrill.cpp index f6cdc86e91..121e13c04e 100644 --- a/pcbnew/gendrill.cpp +++ b/pcbnew/gendrill.cpp @@ -335,8 +335,8 @@ int EXCELLON_WRITER::CreateDrillFile() fprintf( m_file, "T%d\n", tool_reference ); } - diam = MIN( hole_descr.m_Hole_Size.x, - hole_descr.m_Hole_Size.y ); + diam = std::min( hole_descr.m_Hole_Size.x, + hole_descr.m_Hole_Size.y ); if( diam == 0 ) continue; diff --git a/pcbnew/gpcb_exchange.cpp b/pcbnew/gpcb_exchange.cpp index 8018f2fc2b..0f3dea142d 100644 --- a/pcbnew/gpcb_exchange.cpp +++ b/pcbnew/gpcb_exchange.cpp @@ -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 +#include #include #include #include @@ -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() ); diff --git a/pcbnew/layer_widget.cpp b/pcbnew/layer_widget.cpp index fba80155f0..63f372ae15 100644 --- a/pcbnew/layer_widget.cpp +++ b/pcbnew/layer_widget.cpp @@ -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; diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index e428022cf7..8aa62a831e 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -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& 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; } diff --git a/pcbnew/plot_rtn.cpp b/pcbnew/plot_rtn.cpp index 39e2994b46..7cfe17bfaa 100644 --- a/pcbnew/plot_rtn.cpp +++ b/pcbnew/plot_rtn.cpp @@ -71,10 +71,20 @@ bool BRDITEMS_PLOTTER::PlotAllTextsModule( MODULE* aModule ) // Plot text fields, if allowed if( trace_ref ) - PlotTextModule( aModule->m_Reference, GetReferenceColor() ); + { + if( GetReferenceColor() == UNSPECIFIED_COLOR ) + PlotTextModule( aModule->m_Reference, getColor( textLayer ) ); + else + PlotTextModule( aModule->m_Reference, GetReferenceColor() ); + } if( trace_val ) - PlotTextModule( aModule->m_Value, GetValueColor() ); + { + 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() ) diff --git a/pcbnew/ratsnest.cpp b/pcbnew/ratsnest.cpp index 2b19175bce..6b5f0c0483 100644 --- a/pcbnew/ratsnest.cpp +++ b/pcbnew/ratsnest.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include @@ -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++ ) diff --git a/pcbnew/specctra.h b/pcbnew/specctra.h index 3c02596148..ff3ad32256 100644 --- a/pcbnew/specctra.h +++ b/pcbnew/specctra.h @@ -33,10 +33,7 @@ #include #include -#include // MAX definition. - #include - #include @@ -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 RIGHTMARGIN ) diff --git a/pcbnew/zones_polygons_test_connections.cpp b/pcbnew/zones_polygons_test_connections.cpp index 66e1a481aa..fc1d4ca9f7 100644 --- a/pcbnew/zones_polygons_test_connections.cpp +++ b/pcbnew/zones_polygons_test_connections.cpp @@ -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