2008-11-14 22:40:31 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: dialog_copper_zones.cpp
|
|
|
|
// Author: jean-pierre Charras
|
|
|
|
// Created: 09/oct/2008
|
2011-09-23 13:57:12 +00:00
|
|
|
// Licence: GNU License
|
2008-11-14 22:40:31 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2011-02-19 10:13:09 +00:00
|
|
|
#include <wx/wx.h>
|
|
|
|
#include <wx/imaglist.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <appl_wxstruct.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <PolyLine.h>
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <trigo.h>
|
|
|
|
#include <zones.h>
|
2012-04-13 18:51:24 +00:00
|
|
|
#include <base_units.h>
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
#include <class_zone_settings.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
2012-02-06 05:44:19 +00:00
|
|
|
#include <dialog_copper_zones_base.h>
|
2012-02-06 09:10:32 +00:00
|
|
|
#include <wx/listctrl.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class DIALOG_COPPER_ZONE
|
|
|
|
* is the derived class from dialog_copper_zone_frame created by wxFormBuilder
|
|
|
|
*/
|
|
|
|
class DIALOG_COPPER_ZONE : public DIALOG_COPPER_ZONE_BASE
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DIALOG_COPPER_ZONE( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSettings );
|
|
|
|
|
|
|
|
private:
|
|
|
|
PCB_BASE_FRAME* m_Parent;
|
|
|
|
wxConfig* m_Config; ///< Current config
|
|
|
|
|
|
|
|
ZONE_EDIT_T m_OnExitCode; ///< exit code: ZONE_ABORT if no change,
|
|
|
|
///< ZONE_OK if new values accepted
|
|
|
|
///< ZONE_EXPORT_VALUES if values are exported to others zones
|
|
|
|
|
|
|
|
ZONE_SETTINGS m_settings;
|
|
|
|
ZONE_SETTINGS* m_ptr;
|
|
|
|
|
|
|
|
bool m_NetSortingByPadCount; ///< false = alphabetic sort.
|
|
|
|
///< true = pad count sort.
|
|
|
|
|
|
|
|
long m_NetFiltering;
|
|
|
|
std::vector<int> m_LayerId; ///< Handle the real layer number from layer
|
|
|
|
///< name position in m_LayerSelectionCtrl
|
|
|
|
|
|
|
|
static wxString m_netNameShowFilter; ///< the filter to show nets (default * "*").
|
|
|
|
///< static to keep this pattern for an entire pcbnew session
|
|
|
|
|
|
|
|
wxListView* m_LayerSelectionCtrl;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function initDialog
|
|
|
|
* fills in the dialog controls using the current settings.
|
|
|
|
*/
|
|
|
|
void initDialog();
|
|
|
|
|
|
|
|
void OnButtonOkClick( wxCommandEvent& event );
|
|
|
|
void OnButtonCancelClick( wxCommandEvent& event );
|
|
|
|
void OnClose( wxCloseEvent& event );
|
|
|
|
void OnSize( wxSizeEvent& event );
|
|
|
|
void OnCornerSmoothingModeChoice( wxCommandEvent& event );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function AcceptOptions
|
|
|
|
* @param aPromptForErrors is true to prompt user on incorrect params.
|
|
|
|
* @param aUseExportableSetupOnly is true to use exportable parametres only (used to export this setup to other zones).
|
|
|
|
* @return bool - false if incorrect options, true if ok.
|
|
|
|
*/
|
|
|
|
bool AcceptOptions( bool aPromptForErrors, bool aUseExportableSetupOnly = false );
|
|
|
|
|
|
|
|
void OnNetSortingOptionSelected( wxCommandEvent& event );
|
|
|
|
void ExportSetupToOtherCopperZones( wxCommandEvent& event );
|
|
|
|
void OnPadsInZoneClick( wxCommandEvent& event );
|
|
|
|
void OnRunFiltersButtonClick( wxCommandEvent& event );
|
|
|
|
|
|
|
|
|
|
|
|
void buildAvailableListOfNets();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function initListNetsParams
|
|
|
|
* initializes m_NetSortingByPadCount and m_NetFiltering values
|
|
|
|
* according to m_NetDisplayOption selection.
|
|
|
|
*/
|
|
|
|
void initListNetsParams();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function makeLayerBitmap
|
|
|
|
* creates the colored rectangle bitmaps used in the layer selection widget.
|
|
|
|
* @param aColor is the color to fill the rectangle with.
|
|
|
|
*/
|
|
|
|
wxBitmap makeLayerBitmap( int aColor );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#define LAYER_BITMAP_SIZE_X 20
|
|
|
|
#define LAYER_BITMAP_SIZE_Y 10
|
2011-02-19 10:13:09 +00:00
|
|
|
|
2011-03-01 22:36:38 +00:00
|
|
|
// Initialize static member variables
|
|
|
|
wxString DIALOG_COPPER_ZONE::m_netNameShowFilter( wxT( "*" ) );
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2011-02-23 22:38:01 +00:00
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
ZONE_EDIT_T InvokeCopperZonesEditor( PCB_BASE_FRAME* aCaller, ZONE_SETTINGS* aSettings )
|
|
|
|
{
|
|
|
|
DIALOG_COPPER_ZONE dlg( aCaller, aSettings );
|
|
|
|
|
|
|
|
ZONE_EDIT_T result = ZONE_EDIT_T( dlg.ShowModal() );
|
|
|
|
|
|
|
|
// D(printf( "%s: result:%d\n", __FUNCTION__, result );)
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DIALOG_COPPER_ZONE::DIALOG_COPPER_ZONE( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSettings ) :
|
|
|
|
DIALOG_COPPER_ZONE_BASE( aParent )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2012-02-06 05:44:19 +00:00
|
|
|
m_Parent = aParent;
|
2011-12-16 20:12:49 +00:00
|
|
|
m_Config = wxGetApp().GetSettings();
|
2012-02-06 05:44:19 +00:00
|
|
|
|
|
|
|
m_ptr = aSettings;
|
|
|
|
m_settings = *aSettings;
|
|
|
|
|
|
|
|
m_NetSortingByPadCount = true; // false = alphabetic sort, true = pad count sort
|
2010-11-13 19:21:16 +00:00
|
|
|
m_OnExitCode = ZONE_ABORT;
|
2009-08-23 15:22:44 +00:00
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
SetReturnCode( ZONE_ABORT ); // Will be changed on buttons click
|
2010-02-19 13:23:58 +00:00
|
|
|
|
2011-02-19 10:13:09 +00:00
|
|
|
m_LayerSelectionCtrl = new wxListView( this, wxID_ANY,
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxLC_NO_HEADER | wxLC_REPORT
|
|
|
|
| wxLC_SINGLE_SEL | wxRAISED_BORDER );
|
|
|
|
wxListItem col0;
|
|
|
|
col0.SetId( 0 );
|
|
|
|
m_LayerSelectionCtrl->InsertColumn( 0, col0 );
|
|
|
|
m_layerSizer->Add( m_LayerSelectionCtrl, 1,
|
|
|
|
wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
|
|
|
|
|
2011-03-01 22:36:38 +00:00
|
|
|
// Fix static text widget minimum width to a suitable value so that
|
|
|
|
// resizing the dialog is not necessary when changing the corner smoothing type.
|
|
|
|
// Depends on the default text in the widget.
|
|
|
|
m_cornerSmoothingTitle->SetMinSize( m_cornerSmoothingTitle->GetSize() );
|
|
|
|
|
2010-02-03 17:38:32 +00:00
|
|
|
initDialog();
|
2010-01-20 12:43:05 +00:00
|
|
|
|
2010-02-03 17:38:32 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
2011-02-23 22:38:01 +00:00
|
|
|
|
2012-05-29 18:10:56 +00:00
|
|
|
Center();
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 22:36:38 +00:00
|
|
|
void DIALOG_COPPER_ZONE::initDialog()
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
BOARD* board = m_Parent->GetBoard();
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2008-11-22 20:50:30 +00:00
|
|
|
wxString msg;
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
if( m_settings.m_Zone_45_Only )
|
2008-11-14 22:40:31 +00:00
|
|
|
m_OrientEdgesOpt->SetSelection( 1 );
|
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
m_FillModeCtrl->SetSelection( m_settings.m_FillMode ? 1 : 0 );
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2010-07-12 14:07:09 +00:00
|
|
|
AddUnitSymbol( *m_ClearanceValueTitle, g_UserUnit );
|
2012-04-13 18:51:24 +00:00
|
|
|
msg = ReturnStringFromValue( g_UserUnit, m_settings.m_ZoneClearance );
|
2008-11-14 22:40:31 +00:00
|
|
|
m_ZoneClearanceCtrl->SetValue( msg );
|
|
|
|
|
2010-07-12 14:07:09 +00:00
|
|
|
AddUnitSymbol( *m_MinThicknessValueTitle, g_UserUnit );
|
2012-04-13 18:51:24 +00:00
|
|
|
msg = ReturnStringFromValue( g_UserUnit, m_settings.m_ZoneMinThickness );
|
2008-11-22 20:50:30 +00:00
|
|
|
m_ZoneMinThicknessCtrl->SetValue( msg );
|
|
|
|
|
2012-02-24 23:23:46 +00:00
|
|
|
switch( m_settings.GetPadConnection() )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
|
|
|
case PAD_NOT_IN_ZONE: // Pads are not covered
|
|
|
|
m_PadInZoneOpt->SetSelection( 2 );
|
|
|
|
break;
|
|
|
|
|
2012-02-24 23:23:46 +00:00
|
|
|
default:
|
2008-11-14 22:40:31 +00:00
|
|
|
case THERMAL_PAD: // Use thermal relief for pads
|
|
|
|
m_PadInZoneOpt->SetSelection( 1 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_IN_ZONE: // pads are covered by copper
|
|
|
|
m_PadInZoneOpt->SetSelection( 0 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-02-24 23:23:46 +00:00
|
|
|
if( m_settings.GetPadConnection() != THERMAL_PAD )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
|
|
|
m_AntipadSizeValue->Enable( false );
|
|
|
|
m_CopperWidthValue->Enable( false );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_AntipadSizeValue->Enable( true );
|
|
|
|
m_CopperWidthValue->Enable( true );
|
|
|
|
}
|
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
m_PriorityLevelCtrl->SetValue( m_settings.m_ZonePriority );
|
2012-01-29 19:29:19 +00:00
|
|
|
|
2010-07-12 14:07:09 +00:00
|
|
|
AddUnitSymbol( *m_AntipadSizeText, g_UserUnit );
|
|
|
|
AddUnitSymbol( *m_CopperBridgeWidthText, g_UserUnit );
|
2012-04-13 18:51:24 +00:00
|
|
|
PutValueInLocalUnits( *m_AntipadSizeValue, m_settings.m_ThermalReliefGap );
|
|
|
|
PutValueInLocalUnits( *m_CopperWidthValue, m_settings.m_ThermalReliefCopperBridge );
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
m_cornerSmoothingChoice->SetSelection( m_settings.GetCornerSmoothingType() );
|
2011-02-21 19:43:59 +00:00
|
|
|
|
2012-04-13 18:51:24 +00:00
|
|
|
PutValueInLocalUnits( *m_cornerSmoothingCtrl, m_settings.GetCornerRadius() );
|
2011-02-21 19:43:59 +00:00
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
switch( m_settings.m_Zone_HatchingStyle )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
|
|
|
case CPolyLine::NO_HATCH:
|
|
|
|
m_OutlineAppearanceCtrl->SetSelection( 0 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CPolyLine::DIAGONAL_EDGE:
|
|
|
|
m_OutlineAppearanceCtrl->SetSelection( 1 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CPolyLine::DIAGONAL_FULL:
|
|
|
|
m_OutlineAppearanceCtrl->SetSelection( 2 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-01-12 13:15:13 +00:00
|
|
|
m_ArcApproximationOpt->SetSelection(
|
2012-02-06 05:44:19 +00:00
|
|
|
m_settings.m_ArcToSegmentsCount == ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF ? 1 : 0 );
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2011-02-19 10:13:09 +00:00
|
|
|
// Build copper layer list and append to layer widget
|
|
|
|
int layerCount = board->GetCopperLayerCount();
|
|
|
|
int layerNumber, itemIndex, layerColor;
|
|
|
|
wxImageList* imageList = new wxImageList( LAYER_BITMAP_SIZE_X, LAYER_BITMAP_SIZE_Y );
|
|
|
|
m_LayerSelectionCtrl->AssignImageList( imageList, wxIMAGE_LIST_SMALL );
|
|
|
|
for( int ii = 0; ii < layerCount; ii++ )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2011-02-19 10:13:09 +00:00
|
|
|
layerNumber = LAYER_N_BACK;
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2011-02-19 10:13:09 +00:00
|
|
|
if( layerCount <= 1 || ii < layerCount - 1 )
|
|
|
|
layerNumber = ii;
|
|
|
|
else if( ii == layerCount - 1 )
|
|
|
|
layerNumber = LAYER_N_FRONT;
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2011-02-19 10:13:09 +00:00
|
|
|
m_LayerId.insert( m_LayerId.begin(), layerNumber );
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2011-02-19 10:13:09 +00:00
|
|
|
msg = board->GetLayerName( layerNumber ).Trim();
|
|
|
|
layerColor = board->GetLayerColor( layerNumber );
|
|
|
|
imageList->Add( makeLayerBitmap( layerColor ) );
|
|
|
|
itemIndex = m_LayerSelectionCtrl->InsertItem( 0, msg, ii );
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
if( m_settings.m_CurrentZone_Layer == layerNumber )
|
2011-02-19 10:13:09 +00:00
|
|
|
m_LayerSelectionCtrl->Select( itemIndex );
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
|
|
|
|
2010-08-23 12:13:48 +00:00
|
|
|
wxString netNameDoNotShowFilter = wxT( "N-*" );
|
2008-11-22 11:10:40 +00:00
|
|
|
if( m_Config )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2010-08-23 12:13:48 +00:00
|
|
|
int opt = m_Config->Read( ZONE_NET_SORT_OPTION_KEY, 1l );
|
|
|
|
m_NetDisplayOption->SetSelection( opt );
|
|
|
|
m_Config->Read( ZONE_NET_FILTER_STRING_KEY, netNameDoNotShowFilter );
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
2010-08-23 12:13:48 +00:00
|
|
|
else
|
|
|
|
m_NetDisplayOption->SetSelection( 1 );
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2010-11-13 19:21:16 +00:00
|
|
|
m_ShowNetNameFilter->SetValue( m_netNameShowFilter );
|
2010-08-23 12:13:48 +00:00
|
|
|
initListNetsParams();
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2010-08-23 12:13:48 +00:00
|
|
|
// Build list of nets:
|
|
|
|
m_DoNotShowNetNameFilter->SetValue( netNameDoNotShowFilter );
|
|
|
|
buildAvailableListOfNets();
|
2011-02-21 19:43:59 +00:00
|
|
|
|
|
|
|
wxCommandEvent event;
|
|
|
|
OnCornerSmoothingModeChoice( event );
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 22:36:38 +00:00
|
|
|
void DIALOG_COPPER_ZONE::OnButtonCancelClick( wxCommandEvent& event )
|
2011-02-19 10:13:09 +00:00
|
|
|
{
|
|
|
|
Close( true );
|
|
|
|
}
|
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
void DIALOG_COPPER_ZONE::OnButtonOkClick( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
m_netNameShowFilter = m_ShowNetNameFilter->GetValue();
|
|
|
|
|
|
|
|
if( AcceptOptions( true ) )
|
|
|
|
{
|
2012-02-06 07:14:51 +00:00
|
|
|
*m_ptr = m_settings;
|
2012-02-06 05:44:19 +00:00
|
|
|
EndModal( ZONE_OK );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-19 10:13:09 +00:00
|
|
|
|
2012-02-06 07:14:51 +00:00
|
|
|
// called on system close button
|
2011-03-01 22:36:38 +00:00
|
|
|
void DIALOG_COPPER_ZONE::OnClose( wxCloseEvent& event )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2012-02-06 05:44:19 +00:00
|
|
|
if( m_OnExitCode != ZONE_ABORT )
|
|
|
|
*m_ptr = m_settings;
|
|
|
|
|
2009-08-23 15:22:44 +00:00
|
|
|
EndModal( m_OnExitCode );
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 22:36:38 +00:00
|
|
|
void DIALOG_COPPER_ZONE::OnSize( wxSizeEvent& event )
|
2011-02-23 22:38:01 +00:00
|
|
|
{
|
|
|
|
Layout();
|
|
|
|
|
|
|
|
// Set layer list column width to widget width minus a few pixels
|
|
|
|
m_LayerSelectionCtrl->SetColumnWidth( 0, m_LayerSelectionCtrl->GetSize().x - 5 );
|
2011-03-01 08:38:08 +00:00
|
|
|
event.Skip();
|
2011-02-23 22:38:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 22:36:38 +00:00
|
|
|
bool DIALOG_COPPER_ZONE::AcceptOptions( bool aPromptForErrors, bool aUseExportableSetupOnly )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
|
|
|
switch( m_PadInZoneOpt->GetSelection() )
|
|
|
|
{
|
|
|
|
case 2:
|
2012-02-06 05:44:19 +00:00
|
|
|
// Pads are not covered
|
2012-02-24 23:23:46 +00:00
|
|
|
m_settings.SetPadConnection( PAD_NOT_IN_ZONE );
|
2008-11-14 22:40:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2012-02-06 05:44:19 +00:00
|
|
|
// Use thermal relief for pads
|
2012-02-24 23:23:46 +00:00
|
|
|
m_settings.SetPadConnection( THERMAL_PAD );
|
2008-11-14 22:40:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0:
|
2012-02-06 05:44:19 +00:00
|
|
|
// pads are covered by copper
|
2012-02-24 23:23:46 +00:00
|
|
|
m_settings.SetPadConnection( PAD_IN_ZONE );
|
2008-11-14 22:40:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch( m_OutlineAppearanceCtrl->GetSelection() )
|
|
|
|
{
|
|
|
|
case 0:
|
2012-02-06 05:44:19 +00:00
|
|
|
m_settings.m_Zone_HatchingStyle = CPolyLine::NO_HATCH;
|
2008-11-14 22:40:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2012-02-06 05:44:19 +00:00
|
|
|
m_settings.m_Zone_HatchingStyle = CPolyLine::DIAGONAL_EDGE;
|
2008-11-14 22:40:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2012-02-06 05:44:19 +00:00
|
|
|
m_settings.m_Zone_HatchingStyle = CPolyLine::DIAGONAL_FULL;
|
2008-11-14 22:40:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
m_settings.m_ArcToSegmentsCount = m_ArcApproximationOpt->GetSelection() == 1 ?
|
2010-01-12 13:15:13 +00:00
|
|
|
ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF :
|
|
|
|
ARC_APPROX_SEGMENTS_COUNT_LOW_DEF;
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2008-11-22 11:10:40 +00:00
|
|
|
if( m_Config )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2008-11-22 11:10:40 +00:00
|
|
|
m_Config->Write( ZONE_NET_OUTLINES_HATCH_OPTION_KEY,
|
2012-02-06 05:44:19 +00:00
|
|
|
(long) m_settings.m_Zone_HatchingStyle );
|
|
|
|
wxString filter = m_DoNotShowNetNameFilter->GetValue();
|
|
|
|
m_Config->Write( ZONE_NET_FILTER_STRING_KEY, filter );
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
|
|
|
|
2010-08-23 12:13:48 +00:00
|
|
|
m_netNameShowFilter = m_ShowNetNameFilter->GetValue();
|
2012-02-06 05:44:19 +00:00
|
|
|
m_settings.m_FillMode = (m_FillModeCtrl->GetSelection() == 0) ? 0 : 1;
|
2008-11-14 22:40:31 +00:00
|
|
|
|
|
|
|
wxString txtvalue = m_ZoneClearanceCtrl->GetValue();
|
2012-04-16 17:39:32 +00:00
|
|
|
m_settings.m_ZoneClearance = ReturnValueFromString( g_UserUnit, txtvalue );
|
2008-11-22 20:50:30 +00:00
|
|
|
|
2012-05-29 18:10:56 +00:00
|
|
|
// Test if this is a reasonable value for this parameter
|
2011-09-30 18:15:37 +00:00
|
|
|
// A too large value can hang Pcbnew
|
2009-03-03 19:42:49 +00:00
|
|
|
#define CLEARANCE_MAX_VALUE 5000 // in 1/10000 inch
|
2012-02-06 05:44:19 +00:00
|
|
|
if( m_settings.m_ZoneClearance > CLEARANCE_MAX_VALUE )
|
2009-03-03 19:42:49 +00:00
|
|
|
{
|
2011-02-19 10:13:09 +00:00
|
|
|
DisplayError( this, _( "Clearance must be smaller than 0.5\" / 12.7 mm." ) );
|
2009-03-03 19:42:49 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-11-22 20:50:30 +00:00
|
|
|
txtvalue = m_ZoneMinThicknessCtrl->GetValue();
|
2012-04-16 17:39:32 +00:00
|
|
|
m_settings.m_ZoneMinThickness = ReturnValueFromString( g_UserUnit, txtvalue );
|
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
if( m_settings.m_ZoneMinThickness < 10 )
|
2008-12-03 10:32:53 +00:00
|
|
|
{
|
|
|
|
DisplayError( this,
|
2012-04-16 17:39:32 +00:00
|
|
|
_( "Minimum width must be larger than 0.001\" / 0.0254 mm." ) );
|
2008-12-03 10:32:53 +00:00
|
|
|
return false;
|
|
|
|
}
|
2008-11-22 20:50:30 +00:00
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
m_settings.SetCornerSmoothingType( m_cornerSmoothingChoice->GetSelection() );
|
2011-02-21 19:43:59 +00:00
|
|
|
txtvalue = m_cornerSmoothingCtrl->GetValue();
|
2012-04-16 17:39:32 +00:00
|
|
|
m_settings.SetCornerRadius( ReturnValueFromString( g_UserUnit, txtvalue ) );
|
2011-02-21 19:43:59 +00:00
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
m_settings.m_ZonePriority = m_PriorityLevelCtrl->GetValue();
|
2012-01-29 19:29:19 +00:00
|
|
|
|
2008-11-14 22:40:31 +00:00
|
|
|
if( m_OrientEdgesOpt->GetSelection() == 0 )
|
2012-02-06 05:44:19 +00:00
|
|
|
m_settings.m_Zone_45_Only = false;
|
2008-11-14 22:40:31 +00:00
|
|
|
else
|
2012-02-06 05:44:19 +00:00
|
|
|
m_settings.m_Zone_45_Only = true;
|
|
|
|
|
2012-04-16 17:39:32 +00:00
|
|
|
m_settings.m_ThermalReliefGap = ReturnValueFromTextCtrl( *m_AntipadSizeValue );
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2012-04-16 17:39:32 +00:00
|
|
|
m_settings.m_ThermalReliefCopperBridge = ReturnValueFromTextCtrl( *m_CopperWidthValue );
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
m_Config->Write( ZONE_THERMAL_RELIEF_GAP_STRING_KEY, (long) m_settings.m_ThermalReliefGap );
|
2008-11-24 20:46:41 +00:00
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
m_Config->Write( ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY, (long) m_settings.m_ThermalReliefCopperBridge );
|
|
|
|
|
|
|
|
if( m_settings.m_ThermalReliefCopperBridge <= m_settings.m_ZoneMinThickness )
|
2008-11-24 20:46:41 +00:00
|
|
|
{
|
2009-01-24 19:30:39 +00:00
|
|
|
DisplayError( this,
|
2011-02-19 10:13:09 +00:00
|
|
|
_( "Thermal relief spoke width is larger than the minimum width." ) );
|
2008-11-24 20:46:41 +00:00
|
|
|
return false;
|
|
|
|
}
|
2008-11-14 22:40:31 +00:00
|
|
|
|
|
|
|
// If we use only exportable to others zones parameters, exit here:
|
|
|
|
if( aUseExportableSetupOnly )
|
|
|
|
return true;
|
|
|
|
|
2011-03-01 22:36:38 +00:00
|
|
|
// Get the layer selection for this zone
|
2011-02-19 10:13:09 +00:00
|
|
|
int ii = m_LayerSelectionCtrl->GetFirstSelected();
|
2011-03-01 22:36:38 +00:00
|
|
|
|
2008-11-14 22:40:31 +00:00
|
|
|
if( ii < 0 && aPromptForErrors )
|
|
|
|
{
|
2011-02-19 10:13:09 +00:00
|
|
|
DisplayError( this, _( "No layer selected." ) );
|
2008-11-14 22:40:31 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
m_settings.m_CurrentZone_Layer = m_LayerId[ii];
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2011-03-01 22:36:38 +00:00
|
|
|
// Get the net name selection for this zone
|
2008-11-14 22:40:31 +00:00
|
|
|
ii = m_ListNetNameSelection->GetSelection();
|
2011-03-01 22:36:38 +00:00
|
|
|
|
2008-11-14 22:40:31 +00:00
|
|
|
if( ii < 0 && aPromptForErrors )
|
|
|
|
{
|
2011-02-19 10:13:09 +00:00
|
|
|
DisplayError( this, _( "No net selected." ) );
|
2008-11-14 22:40:31 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-08-23 15:22:44 +00:00
|
|
|
if( ii == 0 ) // the not connected option was selected: this is not a good practice: warn:
|
2009-01-24 19:30:39 +00:00
|
|
|
{
|
2009-08-23 15:22:44 +00:00
|
|
|
if( !IsOK( this, _(
|
|
|
|
"You have chosen the \"not connected\" option. This will create insulated copper islands. Are you sure ?" ) )
|
2009-01-24 19:30:39 +00:00
|
|
|
)
|
2009-08-23 15:22:44 +00:00
|
|
|
return false;
|
|
|
|
}
|
2009-01-24 19:30:39 +00:00
|
|
|
|
2008-11-14 22:40:31 +00:00
|
|
|
wxString net_name = m_ListNetNameSelection->GetString( ii );
|
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
m_settings.m_NetcodeSelection = 0;
|
2009-01-24 19:30:39 +00:00
|
|
|
|
2011-03-01 22:36:38 +00:00
|
|
|
// Search net_code for this net, if a net was selected
|
2009-01-24 19:30:39 +00:00
|
|
|
if( m_ListNetNameSelection->GetSelection() > 0 )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2009-08-23 15:22:44 +00:00
|
|
|
NETINFO_ITEM* net = m_Parent->GetBoard()->FindNet( net_name );
|
2009-05-24 18:28:36 +00:00
|
|
|
if( net )
|
2012-02-06 05:44:19 +00:00
|
|
|
m_settings.m_NetcodeSelection = net->GetNet();
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
void DIALOG_COPPER_ZONE::OnCornerSmoothingModeChoice( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
int selection = m_cornerSmoothingChoice->GetSelection();
|
|
|
|
|
|
|
|
switch( selection )
|
|
|
|
{
|
|
|
|
case ZONE_SETTINGS::SMOOTHING_NONE:
|
|
|
|
m_cornerSmoothingTitle->Enable( false );
|
|
|
|
m_cornerSmoothingCtrl->Enable( false );
|
|
|
|
break;
|
|
|
|
case ZONE_SETTINGS::SMOOTHING_CHAMFER:
|
|
|
|
m_cornerSmoothingTitle->Enable( true );
|
|
|
|
m_cornerSmoothingCtrl->Enable( true );
|
|
|
|
m_cornerSmoothingTitle->SetLabel( _( "Chamfer distance" ) );
|
|
|
|
AddUnitSymbol( *m_cornerSmoothingTitle, g_UserUnit );
|
|
|
|
break;
|
|
|
|
case ZONE_SETTINGS::SMOOTHING_FILLET:
|
|
|
|
m_cornerSmoothingTitle->Enable( true );
|
|
|
|
m_cornerSmoothingCtrl->Enable( true );
|
|
|
|
m_cornerSmoothingTitle->SetLabel( _( "Fillet radius" ) );
|
|
|
|
AddUnitSymbol( *m_cornerSmoothingTitle, g_UserUnit );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2011-03-01 22:36:38 +00:00
|
|
|
void DIALOG_COPPER_ZONE::OnNetSortingOptionSelected( wxCommandEvent& event )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2010-08-23 12:13:48 +00:00
|
|
|
initListNetsParams();
|
|
|
|
buildAvailableListOfNets();
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2010-08-23 12:13:48 +00:00
|
|
|
m_netNameShowFilter = m_ShowNetNameFilter->GetValue();
|
2008-11-22 11:10:40 +00:00
|
|
|
if( m_Config )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2010-08-23 12:13:48 +00:00
|
|
|
m_Config->Write( ZONE_NET_SORT_OPTION_KEY, (long) m_NetDisplayOption->GetSelection() );
|
|
|
|
wxString Filter = m_DoNotShowNetNameFilter->GetValue();
|
2008-11-22 11:10:40 +00:00
|
|
|
m_Config->Write( ZONE_NET_FILTER_STRING_KEY, Filter );
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 22:36:38 +00:00
|
|
|
void DIALOG_COPPER_ZONE::ExportSetupToOtherCopperZones( wxCommandEvent& event )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
|
|
|
if( !AcceptOptions( true, true ) )
|
|
|
|
return;
|
|
|
|
|
2008-12-03 10:32:53 +00:00
|
|
|
// Export settings ( but layer and netcode ) to others zones:
|
2009-01-05 05:21:35 +00:00
|
|
|
BOARD* pcb = m_Parent->GetBoard();
|
2008-11-14 22:40:31 +00:00
|
|
|
for( int ii = 0; ii < pcb->GetAreaCount(); ii++ )
|
|
|
|
{
|
|
|
|
ZONE_CONTAINER* zone = pcb->GetArea( ii );
|
2012-02-06 05:44:19 +00:00
|
|
|
m_settings.ExportSetting( *zone, false ); // false = partial export
|
2010-02-19 13:23:58 +00:00
|
|
|
m_Parent->OnModify();
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
2010-01-12 13:15:13 +00:00
|
|
|
|
2009-08-23 15:22:44 +00:00
|
|
|
m_OnExitCode = ZONE_EXPORT_VALUES; // values are exported to others zones
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 22:36:38 +00:00
|
|
|
void DIALOG_COPPER_ZONE::OnPadsInZoneClick( wxCommandEvent& event )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
|
|
|
switch( m_PadInZoneOpt->GetSelection() )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
m_AntipadSizeValue->Enable( false );
|
|
|
|
m_CopperWidthValue->Enable( false );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
m_AntipadSizeValue->Enable( true );
|
|
|
|
m_CopperWidthValue->Enable( true );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-08-23 12:13:48 +00:00
|
|
|
|
|
|
|
|
2011-03-01 22:36:38 +00:00
|
|
|
void DIALOG_COPPER_ZONE::initListNetsParams()
|
2010-08-23 12:13:48 +00:00
|
|
|
{
|
|
|
|
switch( m_NetDisplayOption->GetSelection() )
|
|
|
|
{
|
|
|
|
case 0:
|
2010-11-13 19:21:16 +00:00
|
|
|
m_NetSortingByPadCount = false;
|
2010-08-23 12:13:48 +00:00
|
|
|
m_NetFiltering = false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2010-11-13 19:21:16 +00:00
|
|
|
m_NetSortingByPadCount = true;
|
2010-08-23 12:13:48 +00:00
|
|
|
m_NetFiltering = false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2010-11-13 19:21:16 +00:00
|
|
|
m_NetSortingByPadCount = false;
|
2010-08-23 12:13:48 +00:00
|
|
|
m_NetFiltering = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
2010-11-13 19:21:16 +00:00
|
|
|
m_NetSortingByPadCount = true;
|
2010-08-23 12:13:48 +00:00
|
|
|
m_NetFiltering = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 22:36:38 +00:00
|
|
|
void DIALOG_COPPER_ZONE::OnRunFiltersButtonClick( wxCommandEvent& event )
|
2010-08-23 12:13:48 +00:00
|
|
|
{
|
|
|
|
m_netNameShowFilter = m_ShowNetNameFilter->GetValue();
|
2010-11-13 19:21:16 +00:00
|
|
|
|
2011-03-01 22:36:38 +00:00
|
|
|
// Ensure filtered option for nets
|
2010-08-23 12:13:48 +00:00
|
|
|
if( m_NetDisplayOption->GetSelection() == 0 )
|
|
|
|
m_NetDisplayOption->SetSelection( 2 );
|
|
|
|
else if( m_NetDisplayOption->GetSelection() == 1 )
|
|
|
|
m_NetDisplayOption->SetSelection( 3 );
|
|
|
|
initListNetsParams();
|
|
|
|
buildAvailableListOfNets();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 22:36:38 +00:00
|
|
|
void DIALOG_COPPER_ZONE::buildAvailableListOfNets()
|
2010-08-23 12:13:48 +00:00
|
|
|
{
|
2011-08-27 23:31:56 +00:00
|
|
|
wxArrayString listNetName;
|
2010-08-23 12:13:48 +00:00
|
|
|
|
2010-11-13 19:21:16 +00:00
|
|
|
m_Parent->GetBoard()->ReturnSortedNetnamesList( listNetName, m_NetSortingByPadCount );
|
2010-08-23 12:13:48 +00:00
|
|
|
|
|
|
|
if( m_NetFiltering )
|
|
|
|
{
|
|
|
|
wxString doNotShowFilter = m_DoNotShowNetNameFilter->GetValue();
|
|
|
|
wxString ShowFilter = m_ShowNetNameFilter->GetValue();
|
2011-08-27 23:31:56 +00:00
|
|
|
|
2010-08-23 12:13:48 +00:00
|
|
|
for( unsigned ii = 0; ii < listNetName.GetCount(); ii++ )
|
|
|
|
{
|
|
|
|
if( listNetName[ii].Matches( doNotShowFilter ) )
|
|
|
|
{
|
|
|
|
listNetName.RemoveAt( ii );
|
|
|
|
ii--;
|
|
|
|
}
|
|
|
|
else if( !listNetName[ii].Matches( ShowFilter ) )
|
|
|
|
{
|
|
|
|
listNetName.RemoveAt( ii );
|
|
|
|
ii--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-08-27 23:31:56 +00:00
|
|
|
|
2010-08-23 12:13:48 +00:00
|
|
|
listNetName.Insert( wxT( "<no net>" ), 0 );
|
|
|
|
|
2011-08-27 23:31:56 +00:00
|
|
|
// Ensure currently selected net for the zone is visible, regardless of filters
|
|
|
|
int selectedNetListNdx = -1;
|
2012-02-06 05:44:19 +00:00
|
|
|
int net_select = m_settings.m_NetcodeSelection;
|
2011-08-27 23:31:56 +00:00
|
|
|
|
2010-08-23 12:13:48 +00:00
|
|
|
if( net_select > 0 )
|
|
|
|
{
|
|
|
|
NETINFO_ITEM* equipot = m_Parent->GetBoard()->FindNet( net_select );
|
2011-08-27 23:31:56 +00:00
|
|
|
if( equipot )
|
2010-08-23 12:13:48 +00:00
|
|
|
{
|
2011-08-27 23:31:56 +00:00
|
|
|
selectedNetListNdx = listNetName.Index( equipot->GetNetname() );
|
|
|
|
|
|
|
|
if( wxNOT_FOUND == selectedNetListNdx )
|
2010-08-23 12:13:48 +00:00
|
|
|
{
|
2011-08-27 23:31:56 +00:00
|
|
|
// the currently selected net must *always* be visible.
|
|
|
|
listNetName.Insert( equipot->GetNetname(), 0 );
|
|
|
|
selectedNetListNdx = 0;
|
2010-08-23 12:13:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-08-27 23:31:56 +00:00
|
|
|
else if( net_select == 0 )
|
|
|
|
selectedNetListNdx = 0; // SetSelection() on "<no net>"
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// selectedNetListNdx remains -1, no net selected.
|
|
|
|
}
|
|
|
|
|
|
|
|
m_ListNetNameSelection->Clear();
|
|
|
|
m_ListNetNameSelection->InsertItems( listNetName, 0 );
|
|
|
|
m_ListNetNameSelection->SetSelection( 0 );
|
|
|
|
|
|
|
|
if( selectedNetListNdx >= 0 )
|
|
|
|
{
|
|
|
|
m_ListNetNameSelection->SetSelection( selectedNetListNdx );
|
|
|
|
m_ListNetNameSelection->EnsureVisible( selectedNetListNdx );
|
|
|
|
}
|
2010-08-23 12:13:48 +00:00
|
|
|
}
|
2011-02-19 10:13:09 +00:00
|
|
|
|
|
|
|
|
2011-03-01 22:36:38 +00:00
|
|
|
wxBitmap DIALOG_COPPER_ZONE::makeLayerBitmap( int aColor )
|
2011-02-19 10:13:09 +00:00
|
|
|
{
|
|
|
|
wxBitmap bitmap( LAYER_BITMAP_SIZE_X, LAYER_BITMAP_SIZE_Y );
|
|
|
|
wxBrush brush;
|
|
|
|
wxMemoryDC iconDC;
|
|
|
|
|
|
|
|
iconDC.SelectObject( bitmap );
|
|
|
|
brush.SetColour( MakeColour( aColor ) );
|
|
|
|
brush.SetStyle( wxSOLID );
|
|
|
|
iconDC.SetBrush( brush );
|
|
|
|
iconDC.DrawRectangle( 0, 0, LAYER_BITMAP_SIZE_X, LAYER_BITMAP_SIZE_Y );
|
|
|
|
|
|
|
|
return bitmap;
|
|
|
|
}
|