Commit ed54bdfc authored by jean-pierre charras's avatar jean-pierre charras

drc: more code cleaning. Added comments and fixed some erroneous comments. Fixed bug 638839.

fixed bug 641982 (I hope)
parent 577a79bc
......@@ -10,7 +10,7 @@ else(ZLIB_FOUND)
# and we try to use it
# Unfortunately, we have no way to know exactlty the path of zlib.h becuase this file
# is in wxWidgets sources, not in wxWidgets include path.
find_path(ZLIB_INCLUDE_DIR PATHS ${wxWidgets_ROOT_DIR}/../src/zlib/ ${wxWidgets_ROOT_DIR}/src/zlib/ DOC "location of zlib include files")
find_path(ZLIB_INCLUDE_DIR zlib.h PATHS ${wxWidgets_ROOT_DIR}/../src/zlib/ ${wxWidgets_ROOT_DIR}/src/zlib/ DOC "location of zlib include files")
find_file(ZLIB_LIBRARIES NAMES ${wxWidgets_LIB_DIR}/libwxzlib-2.8.a ZLIB_LIBRARIES NAMES ${wxWidgets_LIB_DIR}/libwxzlib-2.9.a libwxzlib.a PATHS ${wxWidgets_ROOT_DIR}/lib/ PATH_SUFFIXES gcc_dll DOC "location of wxzlib library file")
endif(ZLIB_FOUND)
......
......@@ -96,6 +96,7 @@ set(PCBNEW_SRCS
dist.cpp
dragsegm.cpp
drc.cpp
drc_marker_functions.cpp
edgemod.cpp
edit.cpp
editedge.cpp
......
......@@ -697,7 +697,7 @@ void MODULE::Set_Rectangle_Encadrement()
*/
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
rayon = pad->m_Rayon;
rayon = pad->m_ShapeMaxRadius;
cx = pad->m_Pos0.x;
cy = pad->m_Pos0.y;
xmin = MIN( xmin, cx - rayon );
......
......@@ -44,7 +44,7 @@ D_PAD::D_PAD( MODULE* parent ) : BOARD_CONNECTED_ITEM( parent, TYPE_PAD )
SetSubRatsnest( 0 ); // used in ratsnest
// calculations
ComputeRayon();
ComputeShapeMaxRadius();
}
......@@ -53,24 +53,32 @@ D_PAD::~D_PAD()
}
/* Calculate the radius of the pad.
/* Calculate the radius of the circle containing the pad.
*/
void D_PAD::ComputeRayon()
void D_PAD::ComputeShapeMaxRadius()
{
switch( m_PadShape & 0x7F )
{
case PAD_CIRCLE:
m_Rayon = m_Size.x / 2;
m_ShapeMaxRadius = m_Size.x / 2;
break;
case PAD_OVAL:
m_Rayon = MAX( m_Size.x, m_Size.y ) / 2;
m_ShapeMaxRadius = MAX( m_Size.x, m_Size.y ) / 2;
break;
case PAD_RECT:
m_ShapeMaxRadius = 1 + (int) ( sqrt( (double) m_Size.y * m_Size.y
+ (double) m_Size.x * m_Size.x ) / 2 );
break;
case PAD_TRAPEZOID:
m_Rayon = (int) ( sqrt( (double) m_Size.y * m_Size.y
{ wxSize fullsize = m_Size;
fullsize.x += ABS(m_DeltaSize.y); // Remember: m_DeltaSize.y is the m_Size.x change
fullsize.y += ABS(m_DeltaSize.x); // Remember: m_DeltaSize.x is the m_Size.y change
m_ShapeMaxRadius = 1 + (int) ( sqrt( (double) m_Size.y * m_Size.y
+ (double) m_Size.x * m_Size.x ) / 2 );
}
break;
}
}
......@@ -84,11 +92,11 @@ void D_PAD::ComputeRayon()
EDA_Rect D_PAD::GetBoundingBox()
{
// Calculate area:
ComputeRayon(); // calculate the radius of the area, considered as a
ComputeShapeMaxRadius(); // calculate the radius of the area, considered as a
// circle
EDA_Rect area;
area.SetOrigin( m_Pos );
area.Inflate( m_Rayon, m_Rayon );
area.Inflate( m_ShapeMaxRadius, m_ShapeMaxRadius );
return area;
}
......@@ -185,7 +193,7 @@ void D_PAD::Copy( D_PAD* source )
m_Size = source->m_Size;
m_DeltaSize = source->m_DeltaSize;
m_Pos0 = source->m_Pos0;
m_Rayon = source->m_Rayon;
m_ShapeMaxRadius = source->m_ShapeMaxRadius;
m_PadShape = source->m_PadShape;
m_Attribut = source->m_Attribut;
m_Orient = source->m_Orient;
......@@ -401,7 +409,7 @@ int D_PAD::ReadDescr( FILE* File, int* LineNum )
m_PadShape = PAD_TRAPEZOID; break;
}
ComputeRayon();
ComputeShapeMaxRadius();
break;
case 'D':
......@@ -766,7 +774,7 @@ bool D_PAD::HitTest( const wxPoint& ref_pos )
deltaY = ref_pos.y - shape_pos.y;
/* Quick test: a test point must be inside the circle. */
if( ( abs( deltaX ) > m_Rayon ) || ( abs( deltaY ) > m_Rayon ) )
if( ( abs( deltaX ) > m_ShapeMaxRadius ) || ( abs( deltaY ) > m_ShapeMaxRadius ) )
return false;
dx = m_Size.x >> 1; // dx also is the radius for rounded pads
......
......@@ -95,7 +95,7 @@ public:
wxPoint m_Pos0; // Initial Pad position (i.e. pas position relative to the module anchor, orientation 0
int m_Rayon; // radius of pad circle
int m_ShapeMaxRadius; // radius of the circle containing the pad shape
int m_Attribut; // NORMAL, PAD_SMD, PAD_CONN
int m_Orient; // in 1/10 degrees
static int m_PadSketchModePenSize; // Pen size used to draw pads in sketch mode
......@@ -252,7 +252,7 @@ public:
void SetPadName( const wxString& name ); // Change pad name
wxString ReturnStringPadName(); // Return pad name as string in a wxString
void ReturnStringPadName( wxString& text ); // Return pad name as string in a buffer
void ComputeRayon(); // compute radius
void ComputeShapeMaxRadius(); // compute radius
const wxPoint ReturnShapePos();
......
......@@ -647,7 +647,7 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event )
m_CurrentPad->m_LocalSolderPasteMargin = g_Pad_Master.m_LocalSolderPasteMargin;
m_CurrentPad->m_LocalSolderPasteMarginRatio = g_Pad_Master.m_LocalSolderPasteMarginRatio;
m_CurrentPad->ComputeRayon();
m_CurrentPad->ComputeShapeMaxRadius();
Module->Set_Rectangle_Encadrement();
m_CurrentPad->DisplayInfo( m_Parent );
......
This diff is collapsed.
/*
* drc_marker_functions.cpp
*/
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2010 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2004-2010 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.fr
* Copyright (C) 2007 Kicad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/* Methods of class DRC to initialize drc markers with messages
* according to items and error ode
*/
#include "fctsys.h"
#include "common.h"
//#include "class_drawpanel.h"
#include "pcbnew.h"
//#include "wxPcbStruct.h"
#include "class_board_design_settings.h"
#include "drc_stuff.h"
MARKER_PCB* DRC::fillMarker( TRACK* aTrack, BOARD_ITEM* aItem, int aErrorCode, MARKER_PCB* fillMe )
{
wxString textA = aTrack->MenuText( m_pcb );
wxString textB;
wxPoint position;
wxPoint posB;
if( aItem ) // aItem might be NULL
{
textB = aItem->MenuText( m_pcb );
posB = aItem->GetPosition();
if( aItem->Type() == TYPE_PAD )
position = aItem->GetPosition();
else if( aItem->Type() == TYPE_VIA )
position = aItem->GetPosition();
else if( aItem->Type() == TYPE_TRACK )
{
TRACK* track = (TRACK*) aItem;
wxPoint endPos = track->m_End;
// either of aItem's start or end will be used for the marker position
// first assume start, then switch at end if needed. decision made on
// distance from end of aTrack.
position = track->m_Start;
double dToEnd = hypot( endPos.x - aTrack->m_End.x,
endPos.y - aTrack->m_End.y );
double dToStart = hypot( position.x - aTrack->m_End.x,
position.y - aTrack->m_End.y );
if( dToEnd < dToStart )
position = endPos;
}
}
else
position = aTrack->GetPosition();
if( fillMe )
{
if( aItem )
fillMe->SetData( aErrorCode, position,
textA, aTrack->GetPosition(),
textB, posB );
else
fillMe->SetData( aErrorCode, position,
textA, aTrack->GetPosition() );
}
else
{
if( aItem )
fillMe = new MARKER_PCB( aErrorCode, position,
textA, aTrack->GetPosition(),
textB, posB );
else
fillMe = new MARKER_PCB( aErrorCode, position,
textA, aTrack->GetPosition() );
}
return fillMe;
}
MARKER_PCB* DRC::fillMarker( D_PAD* aPad, D_PAD* bPad, int aErrorCode, MARKER_PCB* fillMe )
{
wxString textA = aPad->MenuText( m_pcb );
wxString textB = bPad->MenuText( m_pcb );
wxPoint posA = aPad->GetPosition();
wxPoint posB = bPad->GetPosition();
if( fillMe )
fillMe->SetData( aErrorCode, posA, textA, posA, textB, posB );
else
fillMe = new MARKER_PCB( aErrorCode, posA, textA, posA, textB, posB );
return fillMe;
}
MARKER_PCB* DRC::fillMarker( ZONE_CONTAINER* aArea, int aErrorCode, MARKER_PCB* fillMe )
{
wxString textA = aArea->MenuText( m_pcb );
wxPoint posA = aArea->GetPosition();
if( fillMe )
fillMe->SetData( aErrorCode, posA, textA, posA );
else
fillMe = new MARKER_PCB( aErrorCode, posA, textA, posA );
return fillMe;
}
MARKER_PCB* DRC::fillMarker( const ZONE_CONTAINER* aArea,
const wxPoint& aPos,
int aErrorCode,
MARKER_PCB* fillMe )
{
wxString textA = aArea->MenuText( m_pcb );
wxPoint posA = aPos;
if( fillMe )
fillMe->SetData( aErrorCode, posA, textA, posA );
else
fillMe = new MARKER_PCB( aErrorCode, posA, textA, posA );
return fillMe;
}
MARKER_PCB* DRC::fillMarker( int aErrorCode, const wxString& aMessage, MARKER_PCB* fillMe )
{
wxPoint posA; // not displayed
if( fillMe )
fillMe->SetData( aErrorCode, posA, aMessage, posA );
else
fillMe = new MARKER_PCB( aErrorCode, posA, aMessage, posA );
fillMe->SetShowNoCoordinate();
return fillMe;
}
......@@ -179,7 +179,6 @@ private:
int m_ycliphi;
WinEDA_PcbFrame* m_mainWindow;
WinEDA_DrawPanel* m_drawPanel;
BOARD* m_pcb;
DIALOG_DRC_CONTROL* m_ui;
......@@ -306,7 +305,7 @@ private:
* Function checkClearancePadToPad
* @param aRefPad The reference pad to check
* @param aPad Another pad to check against
* @return bool - true if clearance between aRefPad and pad is >= dist_min, else false
* @return bool - true if clearance between aRefPad and aPad is >= dist_min, else false
*/
bool checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad );
......@@ -315,18 +314,18 @@ private:
* Function checkClearanceSegmToPad
* check the distance from a pad to segment. This function uses several
* instance variable not passed in:
* segmLength = length of the segment being tested
* segmAngle = angle d'inclinaison du segment;
* finx, finy = end coordinate of the segment
* spot_cX, spot_cY = position of pad / origin of segment
* @param pad_to_test Is the pad involved in the check
* @param w_segm Hhalf width of the segment to test
* @param dist_min Is the minimum clearance needed
* m_segmLength = length of the segment being tested
* m_segmAngle = angle of the segment with the X axis;
* m_segmEnd = end coordinate of the segment
* m_padToTestPos = position of pad relative to the origin of segment
* @param aPad Is the pad involved in the check
* @param aSegmentWidth width of the segment to test
* @param aMinDist Is the minimum clearance needed
*
* @return false distance >= dist_min,
* true if distance < dist_min
* @return true distance >= dist_min,
* false if distance < dist_min
*/
bool checkClearanceSegmToPad( const D_PAD* pad_to_test, int w_segm, int dist_min );
bool checkClearanceSegmToPad( const D_PAD* aPad, int aSegmentWidth, int aMinDist );
/**
......
......@@ -4,17 +4,10 @@
#include "fctsys.h"
//#include "gr_basic.h"
#include "common.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "pcbnew.h"
//#include "trigo.h"
//#include "drag.h"
//#include "protos.h"
#include "dialog_global_pads_edition_base.h"
......@@ -104,6 +97,8 @@ void DIALOG_GLOBAL_PADS_EDITION::PadPropertiesAccept( wxCommandEvent& event )
EndModal( returncode );
break;
}
m_Parent->OnModify();
}
......@@ -272,7 +267,7 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
break;
}
pt_pad->ComputeRayon();
pt_pad->ComputeShapeMaxRadius();
}
Module->Set_Rectangle_Encadrement();
......
......@@ -110,7 +110,7 @@ void WinEDA_BasePcbFrame::Export_Pad_Settings( D_PAD* pt_pad )
( (MODULE*) pt_pad->GetParent() )->m_Orient;
g_Pad_Master.m_Size = pt_pad->m_Size;
g_Pad_Master.m_DeltaSize = pt_pad->m_DeltaSize;
pt_pad->ComputeRayon();
pt_pad->ComputeShapeMaxRadius();
g_Pad_Master.m_Offset = pt_pad->m_Offset;
g_Pad_Master.m_Drill = pt_pad->m_Drill;
......@@ -163,7 +163,7 @@ void WinEDA_BasePcbFrame::Import_Pad_Settings( D_PAD* aPad, bool aDraw )
aPad->m_Offset.y = 0;
}
aPad->ComputeRayon();
aPad->ComputeShapeMaxRadius();
if( aDraw )
DrawPanel->PostDirtyRect( aPad->GetBoundingBox() );
......@@ -234,7 +234,7 @@ void WinEDA_BasePcbFrame::AddPad( MODULE* Module, bool draw )
void WinEDA_BasePcbFrame::DeletePad( D_PAD* aPad, bool aQuery )
{
MODULE* Module;
if( aPad == NULL )
return;
......
......@@ -265,7 +265,7 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC )
PtPad->m_Masque_Layer = g_TabOneLayerMask[Module->GetLayer()];
PtPad->m_Attribut = PAD_SMD;
PtPad->m_PadShape = PAD_CIRCLE;
PtPad->m_Rayon = PtPad->m_Size.x / 2;
PtPad->ComputeShapeMaxRadius();
D_PAD* newpad = new D_PAD( Module );
newpad->Copy( PtPad );
......
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