7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-11 12:30:14 +00:00

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

@ -1,153 +1,153 @@
#include <fctsys.h>
#include <macros.h>
#include <gr_basic.h>
#include <base_units.h>
#include <libeditframe.h>
#include <class_libentry.h>
#include <lib_pin.h>
#include <dialog_lib_edit_pin.h>
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 <fctsys.h>
#include <macros.h>
#include <gr_basic.h>
#include <base_units.h>
#include <libeditframe.h>
#include <class_libentry.h>
#include <lib_pin.h>
#include <dialog_lib_edit_pin.h>
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 );
}
}

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 );
}

Some files were not shown because too many files have changed in this diff Show More