Commit 1c982007 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: fix issue when KICAD_NANOMETER is defined: when zones use htcth to...

Pcbnew: fix issue when KICAD_NANOMETER is defined: when zones use htcth to show zones areas, hatch lines were incorrectly calculated (hunded of thousand lines created)
Eeschema: fix issue in search: search not made in reference strings.
Minor fixes, code cleaning and comment enhancements.
parent 54c20b57
......@@ -31,7 +31,6 @@
#include "common.h"
#include "trigo.h"
#include "pcbstruct.h"
#include "macros.h"
#include "drawtxt.h"
#include "confirm.h"
#include "layers_id_colors_and_visibility.h"
......@@ -171,7 +170,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
if( g_Parm_3D_Visu.m_Layers < 2 )
g_Parm_3D_Visu.m_Layers = 2;
g_Parm_3D_Visu.m_BoardScale = 2.0 / MAX( g_Parm_3D_Visu.m_BoardSize.x,
g_Parm_3D_Visu.m_BoardScale = 2.0 / max( g_Parm_3D_Visu.m_BoardSize.x,
g_Parm_3D_Visu.m_BoardSize.y );
// @TODO: epoxy_width (board thickness) must be set by user,
......@@ -911,7 +910,7 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
scale = g_Parm_3D_Visu.m_BoardScale;
holeX = (double) m_Drill.x * scale / 2;
holeY = (double) m_Drill.y * scale / 2;
hole = MIN( holeX, holeY );
hole = fmin( holeX, holeY );
/* Calculate the center of the pad. */
shape_pos = ReturnShapePos();
......@@ -1505,10 +1504,12 @@ void CALLBACK tesswxPoint2Vertex( const GLvoid* data )
void CALLBACK tessErrorCB( GLenum errorCode )
{
#if defined(DEBUG)
const GLubyte* errorStr;
errorStr = gluErrorString( errorCode );
// DEBUG //
D( printf( "Tess ERROR: %s\n", errorStr ); )
#endif
}
......@@ -187,11 +187,11 @@ void DIALOG_SCH_FIND::SendEvent( const wxEventType& aEventType )
{
event.SetReplaceString( m_comboReplace->GetValue() );
flags |= FR_SEARCH_REPLACE;
if( m_checkReplaceReferences->GetValue() )
flags |= FR_REPLACE_REFERENCES;
}
if( m_checkReplaceReferences->GetValue() )
flags |= FR_REPLACE_REFERENCES;
if( m_radioForward->GetValue() )
flags |= wxFR_DOWN;
......@@ -232,6 +232,15 @@ void DIALOG_SCH_FIND::SendEvent( const wxEventType& aEventType )
m_findReplaceData->SetFlags( event.GetFlags() );
// when we are no using the find/replace (just find)
// FR_REPLACE_REFERENCES flag bit is always set to 1 in event flags
// but not set in m_findReplaceData
if ( ! HasFlag( wxFR_REPLACEDIALOG ) )
{
flags |= FR_REPLACE_REFERENCES;
event.SetFlags( flags );
}
if( !GetEventHandler()->ProcessEvent( event ) )
{
GetParent()->GetEventHandler()->ProcessEvent( event );
......
......@@ -383,7 +383,7 @@ void GERBVIEW_FRAME::DrawItemsDCodeID( wxDC* aDC, int aDrawMode )
if( gerb_item->GetDcodeDescr() )
width = gerb_item->GetDcodeDescr()->GetShapeDim( gerb_item );
else
width = MIN( gerb_item->m_Size.x, gerb_item->m_Size.y );
width = min( gerb_item->m_Size.x, gerb_item->m_Size.y );
orient = TEXT_ORIENT_HORIZ;
......
......@@ -278,7 +278,7 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
GetScreen()->SetCrossHairPosition( current + Module->m_Pos -
Module->m_BoundaryBox.GetPosition() );
Ymax_size = MAX( Ymax_size, Module->m_BoundaryBox.GetHeight() );
Ymax_size = max( Ymax_size, Module->m_BoundaryBox.GetHeight() );
PlaceModule( Module, NULL, true );
......
......@@ -235,7 +235,7 @@ double PCB_BASE_FRAME::BestZoom()
else
jj = 32.0;
double bestzoom = MAX( ii, jj );
double bestzoom = max( ii, jj );
GetScreen()->SetScrollCenterPosition( bbbox.Centre() );
......
......@@ -532,27 +532,9 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor
* and then moved and rotated acroding to the pad position and orientation
*/
/* WARNING:
* When Kbool calculates the filled areas :
* i.e when substracting holes (thermal shapes) to the full zone area
* under certains circumstances kboll drop some holes.
* These circumstances are:
* some identical holes (same thermal shape and size) are *exactly* on the same vertical line
* And
* nothing else between holes
* And
* angles less than 90 deg between 2 consecutive lines in hole outline (sometime occurs without
* this condition)
* And
* a hole above the identical holes
*
* In fact, it is easy to find these conditions in pad arrays.
* So to avoid this, the workaround is do not use holes outlines that include
* angles less than 90 deg between 2 consecutive lines
* this is made in round and oblong thermal reliefs
*
/*
* Note 1: polygons are drawm using outlines witk a thickness = aMinThicknessValue
* so shapes must keep in account this outline thickness
* so shapes must take in account this outline thickness
*
* Note 2:
* Trapezoidal pads are not considered here because they are very special case
......
......@@ -611,7 +611,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint&
BOARD * brd = GetBoard( );
color = brd->GetLayerColor(m_Layer);
if( brd->IsLayerVisible( m_Layer ) == false && ( color & HIGHLIGHT_FLAG ) != HIGHLIGHT_FLAG )
if( brd->IsLayerVisible( m_Layer ) == false && !( draw_mode & GR_HIGHLIGHT ) )
return;
if( DisplayOpt.ContrastModeDisplay )
......
......@@ -195,7 +195,7 @@ void DIALOG_GENDRILL::InitDisplayParams( void )
}
else
{
if( MIN( pad->m_Drill.x, pad->m_Drill.y ) != 0 )
if( min( pad->m_Drill.x, pad->m_Drill.y ) != 0 )
{
if( pad->m_Attribut == PAD_HOLE_NOT_PLATED )
m_notplatedPadsHoleCount++;
......
......@@ -319,11 +319,11 @@ bool PCB_EDIT_FRAME::Add45DegreeSegment( wxDC* aDC )
dx1 = curTrack->m_End.x - curTrack->m_Start.x;
dy1 = curTrack->m_End.y - curTrack->m_Start.y;
// Segments must be of sufficient length.
if( MAX( abs( dx0 ), abs( dy0 ) ) < ( segm_step_45 * 2 ) )
// Segments should have a min length.
if( max( abs( dx0 ), abs( dy0 ) ) < ( segm_step_45 * 2 ) )
return false;
if( MAX( abs( dx1 ), abs( dy1 ) ) < ( segm_step_45 * 2 ) )
if( max( abs( dx1 ), abs( dy1 ) ) < ( segm_step_45 * 2 ) )
return false;
/* Create a new segment and connect it with the previous 2 segments. */
......@@ -851,7 +851,7 @@ void CalculateSegmentEndPoint( const wxPoint& aPosition, int ox, int oy, int* fx
break;
case 45:
deltax = MIN( deltax, deltay );
deltax = min( deltax, deltay );
deltay = deltax;
/* Recalculate the signs for deltax and deltaY. */
......@@ -946,7 +946,7 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end )
break;
case 45:
iDx = MIN( iDx, iDy );
iDx = min( iDx, iDy );
iDy = iDx;
/* Recalculate the signs for deltax and deltaY. */
......
......@@ -317,7 +317,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
if( GetBoard()->GetCopperLayerCount() < 2 ) // Single layer
ll = LAYER_N_BACK;
else if( ll == LAYER_N_FRONT )
ll = MAX( LAYER_N_BACK, GetBoard()->GetCopperLayerCount() - 2 );
ll = max( LAYER_N_BACK, GetBoard()->GetCopperLayerCount() - 2 );
else
ll--;
......
......@@ -354,8 +354,8 @@ static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule,
pt_pad->m_Drill = wxSize(0,0);
break;
case PRINT_PARAMETERS::SMALL_DRILL_SHAPE:
pt_pad->m_Drill.x = MIN(SMALL_DRILL,pt_pad->m_Drill.x);
pt_pad->m_Drill.y = MIN(SMALL_DRILL,pt_pad->m_Drill.y);
pt_pad->m_Drill.x = min(SMALL_DRILL,pt_pad->m_Drill.x);
pt_pad->m_Drill.y = min(SMALL_DRILL,pt_pad->m_Drill.y);
break;
case PRINT_PARAMETERS::FULL_DRILL_SHAPE:
// Do nothing
......
......@@ -40,11 +40,12 @@ int ZONE_CONTAINER::BuildFilledPolysListData( BOARD* aPcb )
* this zone
*/
if( GetNumCorners() <= 2 ) // malformed zone. Kbool does not like it ...
if( GetNumCorners() <= 2 ) // malformed zone. polygon calculations do not like it ...
return 0;
// Make a smoothed polygon out of the user-drawn polygon if required
if( smoothedPoly ) {
if( smoothedPoly )
{
delete smoothedPoly;
smoothedPoly = NULL;
}
......
......@@ -164,7 +164,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
EDA_RECT item_boundingbox;
EDA_RECT zone_boundingbox = GetBoundingBox();
int biggest_clearance = aPcb->GetBiggestClearanceValue();
biggest_clearance = MAX( biggest_clearance, zone_clearance );
biggest_clearance = max( biggest_clearance, zone_clearance );
zone_boundingbox.Inflate( biggest_clearance );
/*
......@@ -220,7 +220,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
if( item_boundingbox.Intersects( zone_boundingbox ) )
{
int clearance = MAX( zone_clearance, item_clearance );
int clearance = max( zone_clearance, item_clearance );
pad->TransformShapeWithClearanceToPolygon( cornerBufferPolysToSubstract,
clearance,
s_CircleToSegmentsCount,
......@@ -267,7 +267,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
if( item_boundingbox.Intersects( zone_boundingbox ) )
{
int clearance = MAX( zone_clearance, item_clearance );
int clearance = max( zone_clearance, item_clearance );
track->TransformShapeWithClearanceToPolygon( cornerBufferPolysToSubstract,
clearance,
s_CircleToSegmentsCount,
......
......@@ -42,7 +42,7 @@ void BuildUnconnectedThermalStubsPolygonList( std::vector<CPolyPt>& aCornerBuffe
EDA_RECT item_boundingbox;
EDA_RECT zone_boundingbox = aZone->GetBoundingBox();
int biggest_clearance = aPcb->GetBiggestClearanceValue();
biggest_clearance = MAX( biggest_clearance, zone_clearance );
biggest_clearance = max( biggest_clearance, zone_clearance );
zone_boundingbox.Inflate( biggest_clearance );
// half size of the pen used to draw/plot zones outlines
......
......@@ -336,7 +336,7 @@ int BOARD::ClipAreaPolygon( PICKED_ITEMS_LIST * aNewZonesList,
wxPoint(0, 0), CPolyLine::NO_HATCH );
// remove the poly that was automatically created for the new area
// and replace it with a poly from NormalizeWithKbool
// and replace it with a poly from NormalizeAreaOutlines
delete NewArea->m_Poly;
NewArea->m_Poly = new_p;
NewArea->m_Poly->Draw();
......
This diff is collapsed.
......@@ -42,18 +42,6 @@ enum
*/
void ArmBoolEng( Bool_Engine* aBooleng, bool aConvertHoles = false );
#define PCBU_PER_MIL 10
#define NM_PER_MIL 10 // 25400
#define to_int( x ) wxRound( (x) )
#ifndef MIN
#define MIN( x1, x2 ) ( (x1) > (x2) ? (x2) : (x1) )
#endif
#ifndef MAX
#define MAX( x1, x2 ) ( (x1) > (x2) ? (x1) : (x2) )
#endif
class CRect
{
public:
......
......@@ -10,7 +10,7 @@
#include "PolyLine.h"
using namespace std;
#define NM_PER_MIL 25400
/**
......@@ -732,7 +732,6 @@ bool FindLineEllipseIntersections( double a, double b, double c, double d, doubl
}
// Get clearance between 2 segments
// Returns point in segment closest to other segment in x, y
// in clearance > max_cl, just returns max_cl and doesn't return x,y
......@@ -916,7 +915,6 @@ int GetClearanceBetweenSegments( int x1i, int y1i, int x1f, int y1f, int style1,
}
// Get min. distance from (x,y) to line y = a + bx
// if b > DBL_MAX/10, assume vertical line at x = a
// returns closest point on line in xp, yp
......@@ -1056,7 +1054,7 @@ int GetArcIntersections( EllipseKH * el1, EllipseKH * el2,
double yr = el2->yrad*yscale;
// now test NSTEPS positions in arc, moving clockwise (ie. decreasing theta)
double step = M_PI/((NSTEPS-1)*2.0);
double d_prev=0, th_prev;
double d_prev=0;
double th_interp;
double th1;
int n = 0;
......@@ -1101,7 +1099,6 @@ int GetArcIntersections( EllipseKH * el1, EllipseKH * el2,
}
}
d_prev = d;
th_prev = theta;
}
if( x1 )
*x1 = xret[0];
......@@ -1196,4 +1193,3 @@ double GetArcClearance( EllipseKH * el1, EllipseKH * el2,
*y1 = ymin;
return dmin;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment