Commit 2cdce05d authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: minor code cleanup and enhancement in zone filling. Commit patch from...

Pcbnew: minor code cleanup and enhancement in zone filling. Commit patch from Marco Mattila. Eeschema: minor bug fix about dangling ends. removed obsolete file
parent e3b4eeb1
/////////////////////////////////////////////////////////////////////////////
// Name: dialog_create_component.cpp
// Purpose:
// Author:
// Modified by:
// Created: 01/14/06 10:14:28
// RCS-ID:
// Copyright:
// Licence:
/////////////////////////////////////////////////////////////////////////////
// Generated by DialogBlocks (unregistered), 01/14/06 10:14:28
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma implementation "dialog_create_component.h"
#endif
#include "fctsys.h"
#include "common.h"
#include "confirm.h"
#include "class_libentry.h"
#include "libeditframe.h"
////@begin includes
////@end includes
#include "dialog_create_component.h"
////@begin XPM images
////@end XPM images
/*!
* WinEDA_CreateCmpDialog type definition
*/
IMPLEMENT_DYNAMIC_CLASS( WinEDA_CreateCmpDialog, wxDialog )
/*!
* WinEDA_CreateCmpDialog event table definition
*/
BEGIN_EVENT_TABLE( WinEDA_CreateCmpDialog, wxDialog )
////@begin WinEDA_CreateCmpDialog event table entries
EVT_BUTTON( wxID_OK, WinEDA_CreateCmpDialog::OnOkClick )
EVT_BUTTON( wxID_CANCEL, WinEDA_CreateCmpDialog::OnCancelClick )
////@end WinEDA_CreateCmpDialog event table entries
END_EVENT_TABLE()
/*!
* WinEDA_CreateCmpDialog constructors
*/
WinEDA_CreateCmpDialog::WinEDA_CreateCmpDialog( )
{
}
WinEDA_CreateCmpDialog::WinEDA_CreateCmpDialog( WinEDA_DrawFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
Create(parent, id, caption, pos, size, style);
}
/*!
* WinEDA_CreateCmpDialog creator
*/
bool WinEDA_CreateCmpDialog::Create( WinEDA_DrawFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
////@begin WinEDA_CreateCmpDialog member initialisation
m_CmpName = NULL;
m_Reference = NULL;
m_AsConvert = NULL;
m_IsPowerSymbol = NULL;
m_PartsAreLocked = NULL;
m_btClose = NULL;
m_PartsCount = NULL;
m_ShowPinNum = NULL;
m_ShowPinname = NULL;
m_PinNameInside = NULL;
m_SetSkew = NULL;
////@end WinEDA_CreateCmpDialog member initialisation
////@begin WinEDA_CreateCmpDialog creation
SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
wxDialog::Create( parent, id, caption, pos, size, style );
CreateControls();
if (GetSizer())
{
GetSizer()->SetSizeHints(this);
}
Centre();
////@end WinEDA_CreateCmpDialog creation
return TRUE;
}
/**********************************************************************************/
void WinEDA_CreateCmpDialog::SetComponentData( LIB_COMPONENT & component )
/**********************************************************************************/
{
WinEDA_LibeditFrame* parent = (WinEDA_LibeditFrame*) GetParent();
parent->SetShowDeMorgan( m_AsConvert->GetValue() );
component.SetPartCount( m_PartsCount->GetSelection() + 1 );
component.GetReference().m_Text = m_Reference->GetValue();
if ( m_PinNameInside->GetValue() == FALSE)
component.SetPinNameOffset( 0 );
else
component.SetPinNameOffset( m_SetSkew->GetValue() );
if ( m_IsPowerSymbol->GetValue() == TRUE )
component.SetPower();
else
component.SetNormal();
/* Set the option "Units locked".
Obviously, cannot be TRUE if there is only one part */
component.LockUnits( m_PartsAreLocked->GetValue() );
if ( component.GetPartCount() <= 1 )
component.LockUnits( false );
}
/*!
* Control creation for WinEDA_CreateCmpDialog
*/
void WinEDA_CreateCmpDialog::CreateControls()
{
////@begin WinEDA_CreateCmpDialog content construction
// Generated by DialogBlocks, 24/04/2009 14:20:19 (unregistered)
WinEDA_CreateCmpDialog* itemDialog1 = this;
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
itemDialog1->SetSizer(itemBoxSizer2);
wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_LEFT|wxALL, 5);
wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer3->Add(itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticBox* itemStaticBoxSizer5Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Name"));
wxStaticBoxSizer* itemStaticBoxSizer5 = new wxStaticBoxSizer(itemStaticBoxSizer5Static, wxVERTICAL);
itemBoxSizer4->Add(itemStaticBoxSizer5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
m_CmpName = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer5->Add(m_CmpName, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
wxStaticBox* itemStaticBoxSizer7Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Reference"));
wxStaticBoxSizer* itemStaticBoxSizer7 = new wxStaticBoxSizer(itemStaticBoxSizer7Static, wxVERTICAL);
itemBoxSizer4->Add(itemStaticBoxSizer7, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
m_Reference = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _("U"), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer7->Add(m_Reference, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer3->Add(itemBoxSizer10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticBox* itemStaticBoxSizer11Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Options"));
wxStaticBoxSizer* itemStaticBoxSizer11 = new wxStaticBoxSizer(itemStaticBoxSizer11Static, wxVERTICAL);
itemBoxSizer10->Add(itemStaticBoxSizer11, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
m_AsConvert = new wxCheckBox( itemDialog1, ID_CHECKBOX3, _("As Convert"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
m_AsConvert->SetValue(false);
itemStaticBoxSizer11->Add(m_AsConvert, 0, wxALIGN_LEFT|wxALL, 5);
m_IsPowerSymbol = new wxCheckBox( itemDialog1, ID_CHECKBOX4, _("Power Symbol"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
m_IsPowerSymbol->SetValue(false);
itemStaticBoxSizer11->Add(m_IsPowerSymbol, 0, wxALIGN_LEFT|wxALL, 5);
m_PartsAreLocked = new wxCheckBox( itemDialog1, ID_CHECKBOX2, _("Parts are locked"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
m_PartsAreLocked->SetValue(false);
itemStaticBoxSizer11->Add(m_PartsAreLocked, 0, wxALIGN_LEFT|wxALL, 5);
wxBoxSizer* itemBoxSizer15 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer3->Add(itemBoxSizer15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxButton* itemButton16 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
itemButton16->SetDefault();
itemBoxSizer15->Add(itemButton16, 0, wxGROW|wxALL, 5);
m_btClose = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer15->Add(m_btClose, 0, wxGROW|wxALL, 5);
wxStaticLine* itemStaticLine18 = new wxStaticLine( itemDialog1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL|wxDOUBLE_BORDER );
itemBoxSizer2->Add(itemStaticLine18, 0, wxGROW|wxALL, 5);
wxBoxSizer* itemBoxSizer19 = new wxBoxSizer(wxHORIZONTAL);
itemBoxSizer2->Add(itemBoxSizer19, 0, wxGROW|wxALL, 5);
wxArrayString m_PartsCountStrings;
m_PartsCountStrings.Add(_("&1"));
m_PartsCountStrings.Add(_("&2"));
m_PartsCountStrings.Add(_("&3"));
m_PartsCountStrings.Add(_("&4"));
m_PartsCountStrings.Add(_("&5"));
m_PartsCountStrings.Add(_("&6"));
m_PartsCountStrings.Add(_("&7"));
m_PartsCountStrings.Add(_("&8"));
m_PartsCountStrings.Add(_("&9"));
m_PartsCountStrings.Add(_("&10"));
m_PartsCountStrings.Add(_("&11"));
m_PartsCountStrings.Add(_("&12"));
m_PartsCountStrings.Add(_("&13"));
m_PartsCountStrings.Add(_("&14"));
m_PartsCountStrings.Add(_("&15"));
m_PartsCountStrings.Add(_("&16"));
m_PartsCountStrings.Add(_("&17"));
m_PartsCountStrings.Add(_("&18"));
m_PartsCountStrings.Add(_("&19"));
m_PartsCountStrings.Add(_("&20"));
m_PartsCountStrings.Add(_("&21"));
m_PartsCountStrings.Add(_("&22"));
m_PartsCountStrings.Add(_("&23"));
m_PartsCountStrings.Add(_("&24"));
m_PartsCountStrings.Add(_("&25"));
m_PartsCountStrings.Add(_("&26"));
m_PartsCount = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Parts per component"), wxDefaultPosition, wxDefaultSize, m_PartsCountStrings, 9, wxRA_SPECIFY_ROWS );
m_PartsCount->SetSelection(0);
itemBoxSizer19->Add(m_PartsCount, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemBoxSizer19->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticBox* itemStaticBoxSizer22Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Draw options"));
wxStaticBoxSizer* itemStaticBoxSizer22 = new wxStaticBoxSizer(itemStaticBoxSizer22Static, wxVERTICAL);
itemBoxSizer19->Add(itemStaticBoxSizer22, 0, wxGROW|wxALL, 5);
m_ShowPinNum = new wxCheckBox( itemDialog1, ID_CHECKBOX1, _("Show Pin Number"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
m_ShowPinNum->SetValue(true);
itemStaticBoxSizer22->Add(m_ShowPinNum, 0, wxALIGN_LEFT|wxALL, 5);
m_ShowPinname = new wxCheckBox( itemDialog1, ID_CHECKBOX5, _("Show Pin Name"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
m_ShowPinname->SetValue(true);
itemStaticBoxSizer22->Add(m_ShowPinname, 0, wxALIGN_LEFT|wxALL, 5);
m_PinNameInside = new wxCheckBox( itemDialog1, ID_CHECKBOX, _("Pin Name Inside"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
m_PinNameInside->SetValue(true);
itemStaticBoxSizer22->Add(m_PinNameInside, 0, wxALIGN_LEFT|wxALL, 5);
wxStaticBox* itemStaticBoxSizer26Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Skew:"));
wxStaticBoxSizer* itemStaticBoxSizer26 = new wxStaticBoxSizer(itemStaticBoxSizer26Static, wxVERTICAL);
itemStaticBoxSizer22->Add(itemStaticBoxSizer26, 0, wxALIGN_LEFT|wxALL, 5);
m_SetSkew = new wxSpinCtrl( itemDialog1, ID_SPINCTRL, _T("40"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 100, 40 );
itemStaticBoxSizer26->Add(m_SetSkew, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
////@end WinEDA_CreateCmpDialog content construction
m_btClose->SetFocus();
}
/*!
* Should we show tooltips?
*/
bool WinEDA_CreateCmpDialog::ShowToolTips()
{
return TRUE;
}
/*!
* Get bitmap resources
*/
wxBitmap WinEDA_CreateCmpDialog::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
////@begin WinEDA_CreateCmpDialog bitmap retrieval
wxUnusedVar(name);
return wxNullBitmap;
////@end WinEDA_CreateCmpDialog bitmap retrieval
}
/*!
* Get icon resources
*/
wxIcon WinEDA_CreateCmpDialog::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin WinEDA_CreateCmpDialog icon retrieval
wxUnusedVar(name);
return wxNullIcon;
////@end WinEDA_CreateCmpDialog icon retrieval
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON
*/
void WinEDA_CreateCmpDialog::OnOkClick( wxCommandEvent& event )
{
if ( m_CmpName->GetValue() == wxEmptyString )
{
DisplayError(this,_("You must provide a name for this component"));
return;
}
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON in WinEDA_CreateCmpDialog.
// Before editing this code, remove the block markers.
event.Skip();
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON in WinEDA_CreateCmpDialog.
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON1
*/
void WinEDA_CreateCmpDialog::OnCancelClick( wxCommandEvent& event )
{
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON1 in WinEDA_CreateCmpDialog.
// Before editing this code, remove the block markers.
event.Skip();
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON1 in WinEDA_CreateCmpDialog.
}
......@@ -920,6 +920,8 @@ bool SCH_LINE::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemLi
bool previousStartState = m_StartIsDangling;
bool previousEndState = m_EndIsDangling;
m_StartIsDangling = m_EndIsDangling = true;
if( GetLayer() == LAYER_WIRE )
{
BOOST_FOREACH( DANGLING_END_ITEM item, aItemList )
......
......@@ -586,6 +586,7 @@ bool SCH_TEXT::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemLi
return false;
bool previousState = m_IsDangling;
m_IsDangling = true;
for( unsigned ii = 0; ii < aItemList.size(); ii++ )
{
......
......@@ -175,6 +175,7 @@ set(PCBNEW_SRCS
work.cpp
xchgmod.cpp
${PCBNEW_SRC_FILL_ZONE}
zones_convert_to_polygons_aux_functions.cpp
zones_by_polygon.cpp
zones_by_polygon_fill_functions.cpp
zone_filling_algorithm.cpp
......
......@@ -419,6 +419,22 @@ void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
size, m_HJustify, m_VJustify, width, m_Italic, m_Bold );
}
void TEXTE_MODULE::DrawUmbilical( WinEDA_DrawPanel* aPanel,
wxDC* aDC,
int aDrawMode,
const wxPoint& aOffset )
{
MODULE* parent = (MODULE*) GetParent();
if( !parent )
return;
GRSetDrawMode( aDC, GR_XOR );
GRLine( &aPanel->m_ClipBox, aDC,
parent->GetPosition().x, parent->GetPosition().y,
GetPosition().x + aOffset.x,
GetPosition().y + aOffset.y,
0, UMBILICAL_COLOR);
}
/* Return text rotation for drawings and plotting
*/
......
......@@ -11,6 +11,7 @@
#define TEXT_is_VALUE 1
#define TEXT_is_DIVERS 2
#define UMBILICAL_COLOR LIGHTBLUE
class TEXTE_MODULE : public BOARD_ITEM, public EDA_TextStruct
{
......@@ -94,6 +95,19 @@ public: TEXTE_MODULE( MODULE* parent, int text_type = TEXT_is_DIVERS );
int aDrawMode,
const wxPoint& offset = ZeroOffset );
/**
* Function DrawUmbilical
* draws a line from the TEXTE_MODULE origin
* to parent MODULE origin.
* @param aPanel = the current DrawPanel
* @param aDC = the current device context
* @param aDrawMode = drawing mode, typically GR_XOR
* @param aOffset = offset for TEXTE_MODULE
*/
void DrawUmbilical( WinEDA_DrawPanel* aPanel,
wxDC* aDC,
int aDrawMode,
const wxPoint& aOffset = ZeroOffset );
/**
* Function DisplayInfo
......
......@@ -139,6 +139,7 @@ static void AbortMoveTextModule( WinEDA_DrawPanel* Panel, wxDC* DC )
Module = (MODULE*) Text->GetParent();
Text->DrawUmbilical( Panel, DC, GR_XOR, -MoveVector );
Text->Draw( Panel, DC, GR_XOR, MoveVector );
// If the text was moved (the move does not change internal data)
......@@ -175,9 +176,16 @@ void WinEDA_BasePcbFrame::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC )
MoveVector.x = MoveVector.y = 0;
DrawPanel->CursorOff( DC );
TextInitialPosition = Text->m_Pos;
TextInitialOrientation = Text->m_Orient;
// Center cursor on initial position of text
GetScreen()->m_Curseur = TextInitialPosition;
DrawPanel->MouseToCursorSchema();
DrawPanel->CursorOn( DC );
Text->DisplayInfo( this );
SetCurItem( Text );
......@@ -195,6 +203,7 @@ void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
if( Text != NULL )
{
DrawPanel->PostDirtyRect( Text->GetBoundingBox() );
Text->DrawUmbilical( DrawPanel, DC, GR_XOR, -MoveVector );
/* Update the coordinates for anchor. */
MODULE* Module = (MODULE*) Text->GetParent();
......@@ -242,12 +251,18 @@ static void Show_MoveTexte_Module( WinEDA_DrawPanel* panel, wxDC* DC,
if( Text == NULL )
return;
/* Undraw the text */
// Erase umbilical and text if necessary
if( erase )
{
Text->DrawUmbilical( panel, DC, GR_XOR, -MoveVector );
Text->Draw( panel, DC, GR_XOR, MoveVector );
}
MoveVector = TextInitialPosition - screen->m_Curseur;
/* Redraw the text */
// Draw umbilical if text moved
if( MoveVector.x || MoveVector.y )
Text->DrawUmbilical( panel, DC, GR_XOR, -MoveVector );
// Redraw text
Text->Draw( panel, DC, GR_XOR, MoveVector );
}
......@@ -35,6 +35,10 @@
#include "PolyLine.h"
extern void BuildUnconnectedThermalStubsPolygonList( std::vector<CPolyPt>& aCornerBuffer,
BOARD* aPcb, ZONE_CONTAINER* aZone,
double aArcCorrection,
int aRoundPadThermalRotation);
extern void Test_For_Copper_Island_And_Remove( BOARD* aPcb,
ZONE_CONTAINER* aZone_container );
extern void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer,
......@@ -54,8 +58,6 @@ static int CopyPolygonsFromKPolygonListToFilledPolysList( ZONE_CONTAINER* aZone
KPolygonSet& aKPolyList );
static int CopyPolygonsFromFilledPolysListTotKPolygonList( ZONE_CONTAINER* aZone,
KPolygonSet& aKPolyList );
static void AddUnconnectedThermalStubsToKPolygonList( std::vector<CPolyPt>& aCornerBuffer,
BOARD* aPcb, ZONE_CONTAINER* aZone );
// Local Variables:
......@@ -162,7 +164,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
EDA_Rect zone_boundingbox = GetBoundingBox();
int biggest_clearance = aPcb->GetBiggestClearanceValue();
biggest_clearance = MAX( biggest_clearance, zone_clearance );
zone_boundingbox.Inflate( biggest_clearance, biggest_clearance );
zone_boundingbox.Inflate( biggest_clearance );
/*
* First : Add pads. Note: pads having the same net as zone are left in zone.
......@@ -367,7 +369,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
// Test thermal stubs connections and add polygons to remove unconnected stubs.
cornerBufferPolysToSubstract.clear();
AddUnconnectedThermalStubsToKPolygonList( cornerBufferPolysToSubstract, aPcb, this );
BuildUnconnectedThermalStubsPolygonList( cornerBufferPolysToSubstract, aPcb, this, s_Correction, s_thermalRot );
/* remove copper areas */
if( cornerBufferPolysToSubstract.size() )
......@@ -387,128 +389,6 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
}
void AddUnconnectedThermalStubsToKPolygonList( std::vector<CPolyPt>& aCornerBuffer,
BOARD* aPcb,
ZONE_CONTAINER* aZone )
{
// polygon buffer
std::vector<wxPoint> corners_buffer;
corners_buffer.reserve( 4 );
wxPoint ptTest[4];
int margin = aZone->m_ZoneMinThickness / 2;
int zone_clearance = max( aZone->m_ZoneClearance, aZone->GetClearance() );
zone_clearance += margin;
EDA_Rect item_boundingbox;
EDA_Rect zone_boundingbox = aZone->GetBoundingBox();
int biggest_clearance = aPcb->GetBiggestClearanceValue();
biggest_clearance = MAX( biggest_clearance, zone_clearance );
zone_boundingbox.Inflate( biggest_clearance );
int iDTRC = ( aZone->m_ThermalReliefCopperBridgeValue - aZone->m_ZoneMinThickness ) / 2;
for( MODULE* module = aPcb->m_Modules; module; module = module->Next() )
{
for( D_PAD* pad = module->m_Pads; pad != NULL; pad = pad->Next() )
{
// check
if( !pad->IsOnLayer( aZone->GetLayer() ) )
continue;
if( pad->GetNet() != aZone->GetNet() )
continue;
item_boundingbox = pad->GetBoundingBox();
item_boundingbox.Inflate( aZone->m_ThermalReliefGapValue );
if( !( item_boundingbox.Intersects( zone_boundingbox ) ) )
continue;
// test point
int dx = ( pad->m_Size.x / 2 ) + aZone->m_ThermalReliefGapValue;
int dy = ( pad->m_Size.y / 2 ) + aZone->m_ThermalReliefGapValue;
// This is CIRCLE pad tweak (for circle pads the thermal stubs are at 45 deg)
int fAngle = pad->m_Orient;
if( pad->m_PadShape == PAD_CIRCLE )
{
dx = (int) ( dx * s_Correction );
dy = dx;
fAngle = s_thermalRot;
}
// compute north, south, west and east points for zone connection.
// Add a small value to ensure point is inside (or outside) zone, not on an edge
ptTest[0] = wxPoint( 0, 3 + dy + margin );
ptTest[1] = wxPoint( 0, -(3 + dy + margin) );
ptTest[2] = wxPoint( 3 + dx + margin, 0 );
ptTest[3] = wxPoint( -(3 + dx + margin), 0 );
// Test all sides
for( int i = 0; i<4; i++ )
{
// rotate point
RotatePoint( &ptTest[i], fAngle );
// translate point
ptTest[i] += pad->ReturnShapePos();
if( aZone->HitTestFilledArea( ptTest[i] ) )
continue;
corners_buffer.clear();
// polygons are rectangles with width of copper bridge value
// contour line width has to be taken into calculation to avoid "thermal stub bleed"
switch( i )
{
case 0:
corners_buffer.push_back( wxPoint( -iDTRC, dy ) );
corners_buffer.push_back( wxPoint( +iDTRC, dy ) );
corners_buffer.push_back( wxPoint( +iDTRC, iDTRC ) );
corners_buffer.push_back( wxPoint( -iDTRC, iDTRC ) );
break;
case 1:
corners_buffer.push_back( wxPoint( -iDTRC, -dy ) );
corners_buffer.push_back( wxPoint( +iDTRC, -dy ) );
corners_buffer.push_back( wxPoint( +iDTRC, -iDTRC ) );
corners_buffer.push_back( wxPoint( -iDTRC, -iDTRC ) );
break;
case 2:
corners_buffer.push_back( wxPoint( dx, -iDTRC ) );
corners_buffer.push_back( wxPoint( dx, iDTRC ) );
corners_buffer.push_back( wxPoint( +iDTRC, iDTRC ) );
corners_buffer.push_back( wxPoint( +iDTRC, -iDTRC ) );
break;
case 3:
corners_buffer.push_back( wxPoint( -dx, -iDTRC ) );
corners_buffer.push_back( wxPoint( -dx, iDTRC ) );
corners_buffer.push_back( wxPoint( -iDTRC, iDTRC ) );
corners_buffer.push_back( wxPoint( -iDTRC, -iDTRC ) );
break;
}
// add computed polygon to list
for( unsigned ic = 0; ic < corners_buffer.size(); ic++ )
{
wxPoint cpos = corners_buffer[ic];
RotatePoint( &cpos, fAngle ); // Rotate according to module orientation
cpos += pad->ReturnShapePos(); // Shift origin to position
CPolyPt corner;
corner.x = cpos.x;
corner.y = cpos.y;
corner.end_contour = ( ic < (corners_buffer.size() - 1) ) ? 0 : 1;
aCornerBuffer.push_back( corner );
}
}
}
}
}
void AddPolygonCornersToKPolygonList( std::vector <CPolyPt>&
aCornersBuffer,
KPolygonSet& aKPolyList )
......
......@@ -44,6 +44,10 @@
// See debug_kbool_key_file_fct.h
extern void BuildUnconnectedThermalStubsPolygonList( std::vector<CPolyPt>& aCornerBuffer,
BOARD* aPcb, ZONE_CONTAINER* aZone,
double aArcCorrection,
int aRoundPadThermalRotation);
extern void Test_For_Copper_Island_And_Remove( BOARD* aPcb,
ZONE_CONTAINER* aZone_container );
extern void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer,
......@@ -483,117 +487,12 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
#define REMOVE_UNUSED_THERMAL_STUBS // Can be commented to skip unused thermal stubs calculations
#ifdef REMOVE_UNUSED_THERMAL_STUBS
// Test thermal stubs connections and add polygons to remove unconnected stubs.
booleng = new Bool_Engine();
ArmBoolEng( booleng, true );
cornerBufferPolysToSubstract.clear();
// Test thermal stubs connections and add polygons to remove unconnected stubs.
for( MODULE* module = aPcb->m_Modules; module; module = module->Next() )
{
for( D_PAD* pad = module->m_Pads; pad != NULL; pad = pad->Next() )
{
// check
if( !pad->IsOnLayer( GetLayer() ) )
continue;
if( pad->GetNet() != GetNet() )
continue;
item_boundingbox = pad->GetBoundingBox();
item_boundingbox.Inflate( m_ThermalReliefGapValue );
if( !( item_boundingbox.Intersects( zone_boundingbox ) ) )
continue;
// test point
int dx =
( pad->m_Size.x / 2 ) + m_ThermalReliefGapValue;
int dy =
( pad->m_Size.y / 2 ) + m_ThermalReliefGapValue;
// This is CIRCLE pad tweak (for circle pads the thermal stubs are at 45 deg)
int fAngle = pad->m_Orient;
if( pad->m_PadShape == PAD_CIRCLE )
{
dx = (int) ( dx * s_Correction );
dy = dx;
fAngle = s_thermalRot;
}
// compute north, south, west and east points for zone connection.
// Add a small value to ensure point is inside (or outside) zone, not on an edge
wxPoint ptTest[4];
ptTest[0] = wxPoint( 0, 3 + dy + margin );
ptTest[1] = wxPoint( 0, -(3 + dy + margin) );
ptTest[2] = wxPoint( 3 + dx + margin, 0 );
ptTest[3] = wxPoint( -(3 + dx + margin), 0 );
// Test all sides
for( int i = 0; i<4; i++ )
{
// rotate point
RotatePoint( &ptTest[i], fAngle );
// translate point
ptTest[i] += pad->ReturnShapePos();
if( HitTestFilledArea( ptTest[i] ) )
continue;
// polygon buffer
std::vector<wxPoint> corners_buffer;
// polygons are rectangles with width of copper bridge value
// contour line width has to be taken into calculation to avoid "thermal stub bleed"
const int iDTRC =
( m_ThermalReliefCopperBridgeValue - m_ZoneMinThickness ) / 2;
switch( i )
{
case 0:
corners_buffer.push_back( wxPoint( -iDTRC, dy ) );
corners_buffer.push_back( wxPoint( +iDTRC, dy ) );
corners_buffer.push_back( wxPoint( +iDTRC, iDTRC ) );
corners_buffer.push_back( wxPoint( -iDTRC, iDTRC ) );
break;
case 1:
corners_buffer.push_back( wxPoint( -iDTRC, -dy ) );
corners_buffer.push_back( wxPoint( +iDTRC, -dy ) );
corners_buffer.push_back( wxPoint( +iDTRC, -iDTRC ) );
corners_buffer.push_back( wxPoint( -iDTRC, -iDTRC ) );
break;
case 2:
corners_buffer.push_back( wxPoint( dx, -iDTRC ) );
corners_buffer.push_back( wxPoint( dx, iDTRC ) );
corners_buffer.push_back( wxPoint( +iDTRC, iDTRC ) );
corners_buffer.push_back( wxPoint( +iDTRC, -iDTRC ) );
break;
case 3:
corners_buffer.push_back( wxPoint( -dx, -iDTRC ) );
corners_buffer.push_back( wxPoint( -dx, iDTRC ) );
corners_buffer.push_back( wxPoint( -iDTRC, iDTRC ) );
corners_buffer.push_back( wxPoint( -iDTRC, -iDTRC ) );
break;
}
// add computed polygon to list
for( unsigned ic = 0; ic < corners_buffer.size(); ic++ )
{
wxPoint cpos = corners_buffer[ic];
RotatePoint( &cpos, fAngle ); // Rotate according to module orientation
cpos += pad->ReturnShapePos(); // Shift origin to position
CPolyPt corner;
corner.x = cpos.x;
corner.y = cpos.y;
corner.end_contour = ( ic < (corners_buffer.size() - 1) ) ? 0 : 1;
cornerBufferPolysToSubstract.push_back( corner );
}
}
}
}
/* compute copper areas */
BuildUnconnectedThermalStubsPolygonList( cornerBufferPolysToSubstract, aPcb, this, s_Correction, s_thermalRot );
/* remove copper areas */
if( cornerBufferPolysToSubstract.size() )
{
/* Add the main corrected polygon (i.e. the filled area using only one outline)
......
/***********************************************/
/* zones_convert_to_polygons_aux_functions.cpp */
/***********************************************/
/* auxiliary functions used to calculare filled copper zones areas
*/
#include <vector>
#include "fctsys.h"
#include "polygons_defs.h"
#include "common.h"
#include "pcbnew.h"
#include "wxPcbStruct.h"
#include "trigo.h"
#include "zones.h"
#include "PolyLine.h"
/**
* Function BuildUnconnectedThermalStubsPolygonList
* Creates a set of polygons corresponding to stubs created by thermal shapes on pads
* which are not connected to a zone (dangling bridges)
* @param aCornerBuffer = a std::vector<CPolyPt> where to store polygons
* @param aPcb = the board.
* @param aZone = a pointer to the ZONE_CONTAINER to examine.
* @param aArcCorrection = a pointer to the ZONE_CONTAINER to examine.
* @param aRoundPadThermalRotation = the rotation in 1.0 degree for thermal stubs in round pads
*/
void BuildUnconnectedThermalStubsPolygonList( std::vector<CPolyPt>& aCornerBuffer,
BOARD* aPcb,
ZONE_CONTAINER* aZone,
double aArcCorrection,
int aRoundPadThermalRotation)
{
std::vector<wxPoint> corners_buffer; // a local polygon buffer to store one stub
corners_buffer.reserve( 4 );
wxPoint ptTest[4];
int zone_clearance = aZone->m_ZoneClearance;
EDA_Rect item_boundingbox;
EDA_Rect zone_boundingbox = aZone->GetBoundingBox();
int biggest_clearance = aPcb->GetBiggestClearanceValue();
biggest_clearance = MAX( biggest_clearance, zone_clearance );
zone_boundingbox.Inflate( biggest_clearance );
// Calculate thermal bridge half width
int iDTRC = aZone->m_ThermalReliefCopperBridgeValue / 2;
// half size of the pen used to draw/plot zones outlines
int pen_radius = aZone->m_ZoneMinThickness / 2;
for( MODULE* module = aPcb->m_Modules; module; module = module->Next() )
{
for( D_PAD* pad = module->m_Pads; pad != NULL; pad = pad->Next() )
{
// check
if( !pad->IsOnLayer( aZone->GetLayer() ) )
continue;
if( pad->GetNet() != aZone->GetNet() )
continue;
item_boundingbox = pad->GetBoundingBox();
item_boundingbox.Inflate( aZone->m_ThermalReliefGapValue );
if( !( item_boundingbox.Intersects( zone_boundingbox ) ) )
continue;
// test point
int dx = ( pad->m_Size.x / 2 ) + aZone->m_ThermalReliefGapValue;
int dy = ( pad->m_Size.y / 2 ) + aZone->m_ThermalReliefGapValue;
// This is CIRCLE pad tweak (for circle pads the thermal stubs are at 45 deg)
int fAngle = pad->m_Orient;
if( pad->m_PadShape == PAD_CIRCLE )
{
dx = (int) ( dx * aArcCorrection );
dy = dx;
fAngle = aRoundPadThermalRotation;
}
// contour line width has to be taken into calculation to avoid "thermal stub bleed"
dx += pen_radius;
dy += pen_radius;
// compute north, south, west and east points for zone connection.
ptTest[0] = wxPoint( 0, dy );
ptTest[1] = wxPoint( 0, -dy );
ptTest[2] = wxPoint( dx, 0 );
ptTest[3] = wxPoint( -dx, 0 );
// Test all sides
for( int i = 0; i < 4; i++ )
{
// rotate point
RotatePoint( &ptTest[i], fAngle );
// translate point
ptTest[i] += pad->ReturnShapePos();
if( aZone->HitTestFilledArea( ptTest[i] ) )
continue;
corners_buffer.clear();
// polygons are rectangles with width of copper bridge value
switch( i )
{
case 0:
corners_buffer.push_back( wxPoint( -iDTRC, dy ) );
corners_buffer.push_back( wxPoint( +iDTRC, dy ) );
corners_buffer.push_back( wxPoint( +iDTRC, iDTRC ) );
corners_buffer.push_back( wxPoint( -iDTRC, iDTRC ) );
break;
case 1:
corners_buffer.push_back( wxPoint( -iDTRC, -dy ) );
corners_buffer.push_back( wxPoint( +iDTRC, -dy ) );
corners_buffer.push_back( wxPoint( +iDTRC, -iDTRC ) );
corners_buffer.push_back( wxPoint( -iDTRC, -iDTRC ) );
break;
case 2:
corners_buffer.push_back( wxPoint( dx, -iDTRC ) );
corners_buffer.push_back( wxPoint( dx, iDTRC ) );
corners_buffer.push_back( wxPoint( +iDTRC, iDTRC ) );
corners_buffer.push_back( wxPoint( +iDTRC, -iDTRC ) );
break;
case 3:
corners_buffer.push_back( wxPoint( -dx, -iDTRC ) );
corners_buffer.push_back( wxPoint( -dx, iDTRC ) );
corners_buffer.push_back( wxPoint( -iDTRC, iDTRC ) );
corners_buffer.push_back( wxPoint( -iDTRC, -iDTRC ) );
break;
}
// add computed polygon to list
for( unsigned ic = 0; ic < corners_buffer.size(); ic++ )
{
wxPoint cpos = corners_buffer[ic];
RotatePoint( &cpos, fAngle ); // Rotate according to module orientation
cpos += pad->ReturnShapePos(); // Shift origin to position
CPolyPt corner;
corner.x = cpos.x;
corner.y = cpos.y;
corner.end_contour = ( ic < (corners_buffer.size() - 1) ) ? 0 : 1;
aCornerBuffer.push_back( corner );
}
}
}
}
}
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